diff --git a/docs/development.md b/docs/development.md index 9e6892e..410044f 100644 --- a/docs/development.md +++ b/docs/development.md @@ -165,8 +165,7 @@ uv run python -m ezmsg.dashboard.build_frontend Then verify the package and tests: ```bash -PYTHONPYCACHEPREFIX=/tmp/pycache .venv/bin/pytest tests/backend -q -uv run python -m build +uv run pytest tests/backend -q ``` The `_web/` bundle under `src/ezmsg/dashboard/` is part of the Python package and should be updated as part of the release. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 8373a56..7dcc5b3 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -2296,9 +2296,9 @@ } }, "node_modules/postcss": { - "version": "8.5.8", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz", - "integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==", + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.12.tgz", + "integrity": "sha512-W62t/Se6rA0Az3DfCL0AqJwXuKwBeYg6nOaIgzP+xZ7N5BFCI7DYi1qs6ygUYT6rvfi6t9k65UMLJC+PHZpDAA==", "dev": true, "funding": [ { diff --git a/frontend/src/components/ProfilingPanel.tsx b/frontend/src/components/ProfilingPanel.tsx index 1d83828..71c870d 100644 --- a/frontend/src/components/ProfilingPanel.tsx +++ b/frontend/src/components/ProfilingPanel.tsx @@ -3,8 +3,13 @@ import { createPortal } from "react-dom"; import { Panel } from "./Panel"; import { TraceTimingPanel, type TimingTraceSample } from "./TraceTimingPanel"; +import { buildRelayAliasIndex, classifyComponents } from "./topologyGraph"; import { buildLeaseColorMap, leaseColorForEndpoint } from "../utils/traceColors"; -import { endpointIdFromStreamAddress } from "../utils/streamAddress"; +import { + endpointIdFromStreamAddress, + parseTopicAndEndpoint, + streamAddressWithoutEndpoint, +} from "../utils/streamAddress"; import type { GraphSnapshotPayload, ProfilingTraceControlRequest, @@ -54,6 +59,7 @@ type PublisherActivityTone = "idle" | "active" | "backpressure"; type SubscriberContributor = { id: string; endpointId: string; + displayEndpointId: string; topic: string; processId: string; pid: number; @@ -66,6 +72,7 @@ type SubscriberContributor = { type PublisherRow = { id: string; endpointId: string; + displayEndpointId: string; topic: string; processId: string; pid: number; @@ -169,8 +176,31 @@ function isRecord(value: unknown): value is Record { return typeof value === "object" && value !== null; } +function canonicalizeProfilingTopic( + topic: string, + relayEndpointByInternalTopic: Map +): string { + return ( + relayEndpointByInternalTopic.get(topic) + ?? relayEndpointByInternalTopic.get(streamAddressWithoutEndpoint(topic)) + ?? topic + ); +} + +function canonicalizeProfilingEndpointId( + endpointId: string, + relayEndpointByInternalTopic: Map +): string { + const { topic, endpointToken } = parseTopicAndEndpoint(endpointId); + if (topic.length === 0 || endpointToken.length === 0) { + return endpointId; + } + return `${canonicalizeProfilingTopic(topic, relayEndpointByInternalTopic)}:${endpointToken}`; +} + function extractTraceSamples( - event: ProfilingTraceEnvelope | null + event: ProfilingTraceEnvelope | null, + relayEndpointByInternalTopic: Map ): PublisherTraceSample[] { if (!event) { return []; @@ -203,11 +233,16 @@ function extractTraceSamples( ) { continue; } + const canonicalEndpointId = canonicalizeProfilingEndpointId( + endpointId, + relayEndpointByInternalTopic + ); + const canonicalTopic = canonicalizeProfilingTopic(topic, relayEndpointByInternalTopic); out.push({ - rowId: `${processId}:${endpointId}`, + rowId: `${processId}:${canonicalEndpointId}`, processId, - endpointId, - topic, + endpointId: canonicalEndpointId, + topic: canonicalTopic, timestamp: typeof timestamp === "number" && Number.isFinite(timestamp) ? timestamp @@ -229,12 +264,22 @@ function extractTraceSamples( function toContributor( process: ProcessProfilingSnapshotPayload, subscriber: SubscriberProfilingSnapshot, - endpointOwnerById: Map + endpointOwnerById: Map, + endpointOwnerByTopic: Map, + relayEndpointByInternalTopic: Map ): SubscriberContributor { + const topic = canonicalizeProfilingTopic( + subscriber.topic, + relayEndpointByInternalTopic + ); return { id: `${process.process_id}:${subscriber.endpoint_id}`, endpointId: subscriber.endpoint_id, - topic: subscriber.topic, + displayEndpointId: canonicalizeProfilingEndpointId( + subscriber.endpoint_id, + relayEndpointByInternalTopic + ), + topic, processId: process.process_id, pid: process.pid, host: process.host, @@ -243,20 +288,34 @@ function toContributor( typeof subscriber.channel_kind_last === "string" ? subscriber.channel_kind_last : "unknown", - unitAddress: endpointOwnerById.get(subscriber.endpoint_id) ?? null, + unitAddress: + endpointOwnerById.get(subscriber.endpoint_id) + ?? endpointOwnerByTopic.get(topic) + ?? null, }; } function topicScopeForPublisher( topic: string, - graphSnapshot: GraphSnapshotPayload | null + graphSnapshot: GraphSnapshotPayload | null, + relayEndpointByInternalTopic: Map ): Set { - const candidateTopics = new Set([topic]); - const routedTopics = graphSnapshot?.graph[topic]; - if (Array.isArray(routedTopics)) { + const normalizedTopic = canonicalizeProfilingTopic( + topic, + relayEndpointByInternalTopic + ); + const candidateTopics = new Set([normalizedTopic]); + const rawTopics = new Set([topic, normalizedTopic]); + for (const rawTopic of rawTopics) { + const routedTopics = graphSnapshot?.graph[rawTopic]; + if (!Array.isArray(routedTopics)) { + continue; + } for (const routedTopic of routedTopics) { if (typeof routedTopic === "string") { - candidateTopics.add(routedTopic); + candidateTopics.add( + canonicalizeProfilingTopic(routedTopic, relayEndpointByInternalTopic) + ); } } } @@ -278,9 +337,14 @@ function sampleTopicMatchesScope(sampleTopic: string, topicScope: Set): function contributorListForPublisher( topic: string, subscribers: SubscriberContributor[], - graphSnapshot: GraphSnapshotPayload | null + graphSnapshot: GraphSnapshotPayload | null, + relayEndpointByInternalTopic: Map ): SubscriberContributor[] { - const candidateTopics = topicScopeForPublisher(topic, graphSnapshot); + const candidateTopics = topicScopeForPublisher( + topic, + graphSnapshot, + relayEndpointByInternalTopic + ); return subscribers .filter((subscriber) => candidateTopics.has(subscriber.topic)) @@ -302,7 +366,9 @@ function toPublisherRow( publisher: PublisherProfilingSnapshot, allSubscribers: SubscriberContributor[], graphSnapshot: GraphSnapshotPayload | null, - endpointOwnerById: Map + endpointOwnerById: Map, + endpointOwnerByTopic: Map, + relayEndpointByInternalTopic: Map ): PublisherRow { const rowId = `${process.process_id}:${publisher.endpoint_id}`; const rawNumBuffers = publisher["num_buffers"]; @@ -310,10 +376,18 @@ function toPublisherRow( typeof rawNumBuffers === "number" && Number.isFinite(rawNumBuffers) ? Math.max(0, Math.trunc(rawNumBuffers)) : null; + const topic = canonicalizeProfilingTopic( + publisher.topic, + relayEndpointByInternalTopic + ); return { id: rowId, endpointId: publisher.endpoint_id, - topic: publisher.topic, + displayEndpointId: canonicalizeProfilingEndpointId( + publisher.endpoint_id, + relayEndpointByInternalTopic + ), + topic, processId: process.process_id, pid: process.pid, host: process.host, @@ -328,11 +402,15 @@ function toPublisherRow( numBuffers ), contributors: contributorListForPublisher( - publisher.topic, + topic, allSubscribers, - graphSnapshot + graphSnapshot, + relayEndpointByInternalTopic ), - unitAddress: endpointOwnerById.get(publisher.endpoint_id) ?? null, + unitAddress: + endpointOwnerById.get(publisher.endpoint_id) + ?? endpointOwnerByTopic.get(topic) + ?? null, }; } @@ -379,41 +457,74 @@ export function ProfilingPanel({ () => (profilingSnapshot ? Object.values(profilingSnapshot) : []), [profilingSnapshot] ); + const topologyComponents = useMemo( + () => (graphSnapshot ? classifyComponents(graphSnapshot) : null), + [graphSnapshot] + ); + const relayEndpointByInternalTopic = useMemo(() => { + if (!topologyComponents) { + return new Map(); + } + return buildRelayAliasIndex(topologyComponents.collections).endpointByInternalTopic; + }, [topologyComponents]); const endpointOwnerById = useMemo(() => { const index = new Map(); - if (!graphSnapshot) { + if (!topologyComponents) { return index; } - for (const session of Object.values(graphSnapshot.sessions)) { - const metadata = isRecord(session.metadata) ? session.metadata : null; - const components = - metadata && isRecord(metadata.components) ? metadata.components : null; - if (!components) { - continue; + const registerOwner = (componentAddress: string, streamAddress: string) => { + const endpointId = endpointIdFromStreamAddress(streamAddress); + if (endpointId && !index.has(endpointId)) { + index.set(endpointId, componentAddress); } - for (const [componentAddress, rawComponent] of Object.entries(components)) { - if (!isRecord(rawComponent) || !isRecord(rawComponent.streams)) { - continue; - } - for (const stream of Object.values(rawComponent.streams)) { - if (!isRecord(stream) || typeof stream.address !== "string") { - continue; - } - const endpointId = endpointIdFromStreamAddress(stream.address); - if (endpointId && !index.has(endpointId)) { - index.set(endpointId, componentAddress); - } - } + }; + for (const unit of topologyComponents.units.values()) { + for (const stream of unit.streams) { + registerOwner(unit.address, stream.address); + } + } + for (const collection of topologyComponents.collections.values()) { + for (const stream of collection.streams) { + registerOwner(collection.address, stream.address); } } return index; - }, [graphSnapshot]); + }, [topologyComponents]); + const endpointOwnerByTopic = useMemo(() => { + const index = new Map(); + if (!topologyComponents) { + return index; + } + const registerOwner = (componentAddress: string, streamAddress: string) => { + index.set(streamAddress, componentAddress); + index.set(streamAddressWithoutEndpoint(streamAddress), componentAddress); + }; + for (const unit of topologyComponents.units.values()) { + for (const stream of unit.streams) { + registerOwner(unit.address, stream.address); + } + } + for (const collection of topologyComponents.collections.values()) { + for (const stream of collection.streams) { + registerOwner(collection.address, stream.address); + } + } + return index; + }, [topologyComponents]); const publisherRows = useMemo(() => { const allSubscribers: SubscriberContributor[] = []; for (const process of processRows) { for (const subscriber of Object.values(process.subscribers)) { - allSubscribers.push(toContributor(process, subscriber, endpointOwnerById)); + allSubscribers.push( + toContributor( + process, + subscriber, + endpointOwnerById, + endpointOwnerByTopic, + relayEndpointByInternalTopic + ) + ); } } @@ -426,7 +537,9 @@ export function ProfilingPanel({ publisher, allSubscribers, graphSnapshot, - endpointOwnerById + endpointOwnerById, + endpointOwnerByTopic, + relayEndpointByInternalTopic ) ); } @@ -443,7 +556,13 @@ export function ProfilingPanel({ } return a.endpointId.localeCompare(b.endpointId); }); - }, [endpointOwnerById, graphSnapshot, processRows]); + }, [ + endpointOwnerById, + endpointOwnerByTopic, + graphSnapshot, + processRows, + relayEndpointByInternalTopic, + ]); const filteredRows = useMemo(() => { const query = searchText.trim().toLowerCase(); @@ -537,7 +656,10 @@ export function ProfilingPanel({ if (!latestTraceEvent || activeTraceRowIds.length === 0) { return; } - const extracted = extractTraceSamples(latestTraceEvent); + const extracted = extractTraceSamples( + latestTraceEvent, + relayEndpointByInternalTopic + ); if (extracted.length === 0) { return; } @@ -547,7 +669,11 @@ export function ProfilingPanel({ .filter((row): row is PublisherRow => row !== undefined) .map((row) => ({ row, - topicScope: topicScopeForPublisher(row.topic, graphSnapshot), + topicScope: topicScopeForPublisher( + row.topic, + graphSnapshot, + relayEndpointByInternalTopic + ), })); const topicScopeByRowId = new Map( activeRowsWithTopicScope.map((entry) => [entry.row.id, entry.topicScope]) @@ -594,7 +720,13 @@ export function ProfilingPanel({ } return changed ? next : previous; }); - }, [activeTraceRowIds, graphSnapshot, latestTraceEvent, rowById]); + }, [ + activeTraceRowIds, + graphSnapshot, + latestTraceEvent, + relayEndpointByInternalTopic, + rowById, + ]); const applyTraceControl = async ( row: PublisherRow, @@ -649,8 +781,8 @@ export function ProfilingPanel({ process_id: row.processId, enabled: nextOpen, publisher_endpoint_id: nextOpen ? row.endpointId : null, - publisher_topic: nextOpen ? row.topic : null, - subscriber_topic: null, + publisher_topic: null, + subscriber_topic: nextOpen ? row.topic : null, metrics: nextOpen ? defaultTraceMetrics : null, sample_mod: 1, ttl_seconds: null, @@ -717,7 +849,13 @@ export function ProfilingPanel({ : TRACE_DEFAULT_WINDOW_SECONDS ); const activeTraceTopicScope = activeTraceRow - ? Array.from(topicScopeForPublisher(activeTraceRow.topic, graphSnapshot)) + ? Array.from( + topicScopeForPublisher( + activeTraceRow.topic, + graphSnapshot, + relayEndpointByInternalTopic + ) + ) : []; const activeTraceSubscriberEndpointIds = activeTraceSamples .filter( @@ -923,8 +1061,8 @@ export function ProfilingPanel({
Endpoint - - {row.endpointId} + + {row.displayEndpointId}
@@ -1044,8 +1182,11 @@ export function ProfilingPanel({
Endpoint - - {contributor.endpointId} + + {contributor.displayEndpointId}
diff --git a/frontend/src/components/TopologyPanel.tsx b/frontend/src/components/TopologyPanel.tsx index 6846386..20e4729 100644 --- a/frontend/src/components/TopologyPanel.tsx +++ b/frontend/src/components/TopologyPanel.tsx @@ -224,7 +224,12 @@ export function TopologyPanel({ ] ); const flowData = useMemo(() => { - if (computedFlowData.nodes.length > 0 && validateFlowData(computedFlowData)) { + if (computedFlowData.nodes.length === 0) { + flowCacheByScopeRef.current.delete(flowScopeKey); + return computedFlowData; + } + + if (validateFlowData(computedFlowData)) { flowCacheByScopeRef.current.set(flowScopeKey, computedFlowData); return computedFlowData; } diff --git a/frontend/src/components/topologyFlowData.test.tsx b/frontend/src/components/topologyFlowData.test.tsx index 6e15b50..235f46d 100644 --- a/frontend/src/components/topologyFlowData.test.tsx +++ b/frontend/src/components/topologyFlowData.test.tsx @@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; import { dashboardFixtures } from "../fixtures/dashboardFixtures"; import { buildFlowData, validateFlowData, type FlowData, type LayoutMode } from "./topologyFlowData"; +import type { GraphSnapshotPayload } from "../types/api"; type Box = { id: string; @@ -110,6 +111,104 @@ function flowForFixture( ); } +function inputStream(address: string) { + return { + name: address.split("/").pop() ?? address, + address, + msg_type: "builtins.str", + leaky: false, + max_queue: 1, + }; +} + +function outputStream(address: string) { + return { + name: address.split("/").pop() ?? address, + address, + msg_type: "builtins.str", + num_buffers: 4, + buf_size: 256, + force_tcp: false, + }; +} + +function topicStream(address: string) { + return { + name: address.split("/").pop() ?? address, + address, + msg_type: "builtins.str", + }; +} + +function relayStream( + address: string, + metadataType: "RelayMetadata" | "InputRelayMetadata" | "OutputRelayMetadata", + relayInputTopic: string, + relayOutputTopic: string, + extra: Record = {} +) { + return { + name: address.split("/").pop() ?? address, + address, + msg_type: "builtins.str", + metadata_type: metadataType, + relay_group: relayInputTopic.split("/").slice(0, -1).join("/"), + relay_input_topic: relayInputTopic, + relay_output_topic: relayOutputTopic, + ...extra, + }; +} + +function relayCollapseSnapshot( + graph: Record, + component: Record +): GraphSnapshotPayload { + return { + graph, + edge_owners: [], + sessions: { + "relay-session": { + edges: [], + metadata: { + components: { + "SYSTEM/SOURCE": { + name: "SOURCE", + component_type: "fixture.Source", + streams: { + OUTPUT: outputStream("SYSTEM/SOURCE/OUTPUT:source-output"), + }, + tasks: [], + }, + "SYSTEM/PASSTHROUGH": component, + "SYSTEM/SINK": { + name: "SINK", + component_type: "fixture.Sink", + streams: { + INPUT: inputStream("SYSTEM/SINK/INPUT:sink-input"), + }, + tasks: [], + }, + }, + }, + }, + }, + processes: {}, + }; +} + +function visibleExternalEdges(flow: FlowData): string[] { + return flow.edges + .filter((edge) => edge.className !== "topology-internal-edge") + .map((edge) => `${edge.source}->${edge.target}`) + .sort(); +} + +function findNode(flow: FlowData, id: string) { + const node = flow.nodes.find((entry) => entry.id === id); + expect(node, `Missing node ${id}`).toBeDefined(); + return node!; +} + describe("topologyFlowData", () => { it("lays out dense unit internals without overlap in both layouts", () => { for (const layoutMode of ["tb", "lr"] as LayoutMode[]) { @@ -193,4 +292,188 @@ describe("topologyFlowData", () => { "nested scope: ROOT_TOPIC overlaps INNER" ).toBe(0); }); + + it("collapses neutral relay runtime topics to the relay endpoint", () => { + const flow = buildFlowData( + relayCollapseSnapshot( + { + "SYSTEM/SOURCE/OUTPUT": ["SYSTEM/PASSTHROUGH/IN"], + "SYSTEM/PASSTHROUGH/IN": ["SYSTEM/PASSTHROUGH/MID"], + "SYSTEM/PASSTHROUGH/MID": ["SYSTEM/PASSTHROUGH/OUT", "SYSTEM/PASSTHROUGH/__relays__/MID/INPUT"], + "SYSTEM/PASSTHROUGH/__relays__/MID/OUTPUT": ["SYSTEM/PASSTHROUGH/MID"], + "SYSTEM/PASSTHROUGH/OUT": ["SYSTEM/SINK/INPUT"], + }, + { + name: "PASSTHROUGH", + component_type: "fixture.Passthrough", + children: [], + topics: { + IN: topicStream("SYSTEM/PASSTHROUGH/IN"), + OUT: topicStream("SYSTEM/PASSTHROUGH/OUT"), + }, + relays: { + MID: relayStream( + "SYSTEM/PASSTHROUGH/MID", + "RelayMetadata", + "SYSTEM/PASSTHROUGH/__relays__/MID/INPUT", + "SYSTEM/PASSTHROUGH/__relays__/MID/OUTPUT", + { + leaky: true, + max_queue: 9, + num_buffers: 6, + } + ), + }, + } + ), + "tb", + null, + "curved", + false + ); + + expect(validateFlowData(flow)).toBe(true); + expect(flow.nodes.some((node) => node.id.includes("__relays__"))).toBe(false); + expect(flow.edges.some((edge) => edge.id.includes("__relays__"))).toBe(false); + expect(visibleExternalEdges(flow)).toEqual([ + "stream:SYSTEM/PASSTHROUGH/OUT->stream:SYSTEM/SINK/INPUT:sink-input", + "stream:SYSTEM/SOURCE/OUTPUT:source-output->stream:SYSTEM/PASSTHROUGH/IN", + ]); + }); + + it("collapses input relay runtime topics to the collection boundary endpoints", () => { + const flow = buildFlowData( + relayCollapseSnapshot( + { + "SYSTEM/SOURCE/OUTPUT": ["SYSTEM/PASSTHROUGH/IN"], + "SYSTEM/PASSTHROUGH/IN": ["SYSTEM/PASSTHROUGH/__relays__/IN/INPUT"], + "SYSTEM/PASSTHROUGH/__relays__/IN/OUTPUT": ["SYSTEM/PASSTHROUGH/OUT"], + "SYSTEM/PASSTHROUGH/OUT": ["SYSTEM/SINK/INPUT"], + }, + { + name: "PASSTHROUGH", + component_type: "fixture.Passthrough", + children: [], + topics: { + OUT: topicStream("SYSTEM/PASSTHROUGH/OUT"), + }, + relays: { + IN: relayStream( + "SYSTEM/PASSTHROUGH/IN", + "InputRelayMetadata", + "SYSTEM/PASSTHROUGH/__relays__/IN/INPUT", + "SYSTEM/PASSTHROUGH/__relays__/IN/OUTPUT", + { + leaky: true, + max_queue: 7, + } + ), + }, + } + ), + "tb", + null, + "curved", + false + ); + + expect(validateFlowData(flow)).toBe(true); + expect(flow.nodes.some((node) => node.id.includes("__relays__"))).toBe(false); + expect(flow.edges.some((edge) => edge.id.includes("__relays__"))).toBe(false); + expect(visibleExternalEdges(flow)).toEqual([ + "stream:SYSTEM/PASSTHROUGH/OUT->stream:SYSTEM/SINK/INPUT:sink-input", + "stream:SYSTEM/SOURCE/OUTPUT:source-output->stream:SYSTEM/PASSTHROUGH/IN", + ]); + }); + + it("collapses output relay runtime topics to the collection boundary endpoints", () => { + const flow = buildFlowData( + relayCollapseSnapshot( + { + "SYSTEM/SOURCE/OUTPUT": ["SYSTEM/PASSTHROUGH/IN"], + "SYSTEM/PASSTHROUGH/IN": ["SYSTEM/PASSTHROUGH/__relays__/OUT/INPUT"], + "SYSTEM/PASSTHROUGH/__relays__/OUT/OUTPUT": ["SYSTEM/PASSTHROUGH/OUT"], + "SYSTEM/PASSTHROUGH/OUT": ["SYSTEM/SINK/INPUT"], + }, + { + name: "PASSTHROUGH", + component_type: "fixture.Passthrough", + children: [], + topics: { + IN: topicStream("SYSTEM/PASSTHROUGH/IN"), + }, + relays: { + OUT: relayStream( + "SYSTEM/PASSTHROUGH/OUT", + "OutputRelayMetadata", + "SYSTEM/PASSTHROUGH/__relays__/OUT/INPUT", + "SYSTEM/PASSTHROUGH/__relays__/OUT/OUTPUT", + { + num_buffers: 8, + force_tcp: true, + } + ), + }, + } + ), + "tb", + null, + "curved", + false + ); + + expect(validateFlowData(flow)).toBe(true); + expect(flow.nodes.some((node) => node.id.includes("__relays__"))).toBe(false); + expect(flow.edges.some((edge) => edge.id.includes("__relays__"))).toBe(false); + expect(visibleExternalEdges(flow)).toEqual([ + "stream:SYSTEM/PASSTHROUGH/OUT->stream:SYSTEM/SINK/INPUT:sink-input", + "stream:SYSTEM/SOURCE/OUTPUT:source-output->stream:SYSTEM/PASSTHROUGH/IN", + ]); + }); + + it("renders neutral collection topics and relays on the same lane with distinct legend styling", () => { + for (const layoutMode of ["tb", "lr"] as LayoutMode[]) { + const flow = buildFlowData( + relayCollapseSnapshot( + {}, + { + name: "PASSTHROUGH", + component_type: "fixture.Passthrough", + children: [], + topics: { + MID_TOPIC: topicStream("SYSTEM/PASSTHROUGH/MID_TOPIC"), + }, + relays: { + MID_RELAY: relayStream( + "SYSTEM/PASSTHROUGH/MID_RELAY", + "RelayMetadata", + "SYSTEM/PASSTHROUGH/__relays__/MID_RELAY/INPUT", + "SYSTEM/PASSTHROUGH/__relays__/MID_RELAY/OUTPUT", + { + leaky: true, + max_queue: 2, + num_buffers: 2, + } + ), + }, + } + ), + layoutMode, + null, + "curved", + false + ); + + expect(validateFlowData(flow)).toBe(true); + + const topicNode = findNode(flow, "stream:SYSTEM/PASSTHROUGH/MID_TOPIC"); + const relayNode = findNode(flow, "stream:SYSTEM/PASSTHROUGH/MID_RELAY"); + + expect(topicNode.position.y).toBe(relayNode.position.y); + expect(topicNode.style?.borderRadius).toBe(relayNode.style?.borderRadius); + expect(topicNode.style?.border).not.toBe(relayNode.style?.border); + expect(topicNode.style?.background).not.toBe(relayNode.style?.background); + expect(topicNode.style?.color).not.toBe(relayNode.style?.color); + } + }); }); diff --git a/frontend/src/components/topologyFlowData.tsx b/frontend/src/components/topologyFlowData.tsx index 6beb385..0ee0b20 100644 --- a/frontend/src/components/topologyFlowData.tsx +++ b/frontend/src/components/topologyFlowData.tsx @@ -2,6 +2,7 @@ import { MarkerType, Position, type Edge, type Node } from "reactflow"; import { belongsToCollection, + buildRelayAliasIndex, buildCollectionParentMap, classifyComponents, computeRanks, @@ -86,6 +87,21 @@ function compactMsgType(msgType: string | null): string | null { return `${short.slice(0, 15)}…`; } +function isNeutralCollectionStream(stream: UnitComponent["streams"][number]): boolean { + return stream.collectionKind !== null && stream.direction === "unknown"; +} + +function scopedNeutralStreamOwnerId(streamAddress: string): string { + return `stream:${streamAddress}`; +} + +function laneCount(...groups: Array<{ length: number }>): number { + return Math.max( + 1, + groups.reduce((count, group) => count + (group.length > 0 ? 1 : 0), 0) + ); +} + export function compactCollectionAddress(address: string): string { const parts = address.split("/"); if (parts.length <= 2) { @@ -121,6 +137,9 @@ function streamLabelClassName( ownerKind: "unit" | "collection" ): string { if (ownerKind === "collection" && stream.collectionKind) { + if (className === "is-unknown") { + return "mono topology-stream-label is-collection"; + } return "mono topology-stream-label is-collection"; } return `mono topology-stream-label ${className}`; @@ -159,7 +178,7 @@ function streamNodeVisualStyle( border: darkMode ? "1px solid #fb923c" : "1px solid #f8b66f", background: darkMode ? "#2a2115" : "#fff8ef", color: darkMode ? "#fdba74" : "#8a4f10", - borderRadius: 10, + borderRadius: 999, }; } if (className === "is-output") { @@ -179,10 +198,10 @@ function streamNodeVisualStyle( }; } return { - border: darkMode ? "1px solid #c084fc" : "1px solid #d3accb", - background: darkMode ? "#251b33" : "#fbf3f8", + border: darkMode ? "1px solid #d8b4fe" : "1px solid #b07aa1", + background: darkMode ? "#2a1d3a" : "#f8eef5", color: darkMode ? "#e9d5ff" : "#6f3f66", - borderRadius: 10, + borderRadius: 999, }; } @@ -389,6 +408,7 @@ export function buildFlowData( ? "smoothstep" : "default"; const { units, collections } = classifyComponents(graphSnapshot); + const relayAliasIndex = buildRelayAliasIndex(collections); const visibleAddresses = visibleComponentAddresses( units, collections, @@ -416,6 +436,12 @@ export function buildFlowData( const scopedCollectionOwnerId = scopedCollection ? `scope:${scopedCollection.address}` : null; + const scopedNeutralStreams = scopedCollection + ? scopedCollection.streams.filter(isNeutralCollectionStream) + : []; + const scopedNeutralStreamByOwnerId = new Map( + scopedNeutralStreams.map((stream) => [scopedNeutralStreamOwnerId(stream.address), stream] as const) + ); const unitOwnerByStreamAddress = new Map(); const collectionOwnerByStreamAddress = new Map(); @@ -431,6 +457,9 @@ export function buildFlowData( collectionOwnerByStreamAddress.set(streamAddressWithoutEndpoint(stream.address), collection.address); } } + for (const [internalTopic, collectionAddress] of relayAliasIndex.collectionByInternalTopic.entries()) { + collectionOwnerByStreamAddress.set(internalTopic, collectionAddress); + } const canonicalStreamByAlias = new Map(); for (const unit of units.values()) { @@ -445,13 +474,26 @@ export function buildFlowData( canonicalStreamByAlias.set(streamAddressWithoutEndpoint(stream.address), stream.address); } } + for (const [internalTopic, endpointAddress] of relayAliasIndex.endpointByInternalTopic.entries()) { + canonicalStreamByAlias.set(internalTopic, endpointAddress); + } + + const canonicalizeStreamAddress = (streamAddress: string): string => + canonicalStreamByAlias.get(streamAddress) + ?? canonicalStreamByAlias.get(streamAddressWithoutEndpoint(streamAddress)) + ?? streamAddress; const rawEdges: Array<{ from: string; to: string }> = []; for (const [fromTopic, toTopics] of Object.entries(graphSnapshot.graph)) { for (const toTopic of toTopics) { + const from = canonicalizeStreamAddress(fromTopic); + const to = canonicalizeStreamAddress(toTopic); + if (from === to) { + continue; + } rawEdges.push({ - from: canonicalStreamByAlias.get(fromTopic) ?? fromTopic, - to: canonicalStreamByAlias.get(toTopic) ?? toTopic, + from, + to, }); } } @@ -476,6 +518,7 @@ export function buildFlowData( | "unit" | "collection" | "scope_collection" + | "scope_collection_stream" | "collection_proxy" | "orphan"; } @@ -499,6 +542,12 @@ export function buildFlowData( }); } } + for (const stream of scopedNeutralStreams) { + registerStreamOwner(stream.address, { + ownerId: scopedNeutralStreamOwnerId(stream.address), + ownerKind: "scope_collection_stream", + }); + } const ownedStreams = new Set(streamOwnerByAddress.keys()); const relevantRawEdges = rawEdges.filter( @@ -523,6 +572,11 @@ export function buildFlowData( ownerIds.add(ownerId); ownerLabel.set(ownerId, collection.name); } + for (const stream of scopedNeutralStreams) { + const ownerId = scopedNeutralStreamOwnerId(stream.address); + ownerIds.add(ownerId); + ownerLabel.set(ownerId, streamDisplayName(stream.name, stream.address)); + } for (const streamAddress of relevantStreams) { if (streamOwnerByAddress.has(streamAddress)) { continue; @@ -694,10 +748,14 @@ export function buildFlowData( ownerSizeById.set(`unit:${unit.address}`, { width, height }); } for (const collection of visibleCollections.values()) { - const inputs = collection.streams.filter((stream) => stream.direction === "input").length; - const outputs = collection.streams.filter((stream) => stream.direction === "output").length; - const unknown = collection.streams.filter((stream) => stream.direction === "unknown").length; - const maxRows = Math.max(1, inputs, outputs, unknown); + const inputStreams = collection.streams.filter((stream) => stream.direction === "input"); + const outputStreams = collection.streams.filter((stream) => stream.direction === "output"); + const neutralStreams = collection.streams.filter(isNeutralCollectionStream); + const inputs = inputStreams.length; + const outputs = outputStreams.length; + const neutral = neutralStreams.length; + const rowLanes = laneCount(inputStreams, neutralStreams, outputStreams); + const maxRows = Math.max(1, inputs, outputs, neutral); const streamDrivenWidth = Math.max( layoutMode === "lr" ? COLLECTION_NODE_WIDTH : 300, requiredRowWidth( @@ -718,24 +776,25 @@ export function buildFlowData( 124, COLLECTION_NODE_HEADER_HEIGHT + 16 - + Math.max(1, inputs, outputs) * 30 - + (unknown > 0 ? STREAM_NODE_HEIGHT + 12 : 0) + + Math.max(1, inputs, neutral, outputs) * 30 + 12 ) : Math.max( 176, COLLECTION_NODE_HEADER_HEIGHT - + 14 - + Math.max( - 1, - (inputs > 0 ? 1 : 0) - + (unknown > 0 ? 1 : 0) - + (outputs > 0 ? 1 : 0) - ) * STREAM_NODE_HEIGHT - + 12 + + 18 + + rowLanes * STREAM_NODE_HEIGHT + + Math.max(0, rowLanes - 1) * 12 + + 16 ); ownerSizeById.set(`collection:${collection.address}`, { width, height }); } + for (const stream of scopedNeutralStreams) { + ownerSizeById.set(scopedNeutralStreamOwnerId(stream.address), { + width: STREAM_NODE_WIDTH, + height: STREAM_NODE_HEIGHT, + }); + } for (const ownerId of orderedOwnerIds) { if (ownerSizeById.has(ownerId)) { continue; @@ -853,7 +912,10 @@ export function buildFlowData( if (scopedCollection && scopedCollectionOwnerId) { const scopedOwnerIds = orderedOwnerIds.filter( - (ownerId) => ownerId.startsWith("unit:") || ownerId.startsWith("collection:") + (ownerId) => + ownerId.startsWith("unit:") + || ownerId.startsWith("collection:") + || scopedNeutralStreamByOwnerId.has(ownerId) ); let minX = 24; let minY = 32; @@ -885,8 +947,11 @@ export function buildFlowData( const scopedInputs = scopedCollection.streams.filter((stream) => stream.direction === "input"); const scopedOutputs = scopedCollection.streams.filter((stream) => stream.direction === "output"); - const scopedUnknown = scopedCollection.streams.filter((stream) => stream.direction === "unknown"); - const scopedStreamMax = Math.max(1, scopedInputs.length, scopedOutputs.length, scopedUnknown.length); + const scopedStreamMax = Math.max( + 1, + scopedInputs.length, + scopedOutputs.length + ); const scopedRowMinWidth = requiredRowWidth( scopedStreamMax, STREAM_NODE_WIDTH, @@ -904,12 +969,12 @@ export function buildFlowData( scopedHeaderBase, scopedStreamTop + Math.max(1, scopedInputs.length, scopedOutputs.length) * 30 - + (scopedUnknown.length > 0 ? STREAM_NODE_HEIGHT + 10 : 0) + 8 ) - : hasScopedInputRow - ? Math.max(scopedHeaderBase, scopedStreamTop + STREAM_NODE_HEIGHT + 8) - : scopedHeaderBase; + : Math.max( + scopedHeaderBase, + scopedStreamTop + (hasScopedInputRow ? STREAM_NODE_HEIGHT + 8 : 0) + ); const scopeBottomPadding = layoutMode === "tb" ? hasScopedOutputRow ? Math.max(COLLECTION_SCOPE_BOTTOM_PADDING, STREAM_NODE_HEIGHT + 20) @@ -1087,23 +1152,8 @@ export function buildFlowData( }, }); }); - if (scopedUnknown.length > 0) { - placeUnitStreamRow( - scopedCollectionOwnerId, - scopeSize, - scopedUnknown, - 56 + Math.max(scopedInputs.length, scopedOutputs.length) * rowStep + 4, - "is-unknown", - "collection", - layoutMode, - nodes - ); - } } else { - const topInputY = Math.max( - scopedStreamTop, - scopeHeaderHeight - STREAM_NODE_HEIGHT - 8 - ); + const topInputY = scopedStreamTop; const scopeFooterTop = scopeHeaderHeight + scopeContentHeight; const bottomOutputY = Math.min( scopeSize.height - STREAM_NODE_HEIGHT - 10, @@ -1129,27 +1179,52 @@ export function buildFlowData( layoutMode, nodes ); - if (scopedUnknown.length > 0) { - const unknownRowY = chooseScopedUnknownRowY( - scopedOwnerIds, - ownerPosition, - ownerSizeById, - scopePos.y, - scopeHeaderHeight, - scopeContentHeight, - scopeSize.height - ); - placeUnitStreamRow( - scopedCollectionOwnerId, - scopeSize, - scopedUnknown, - unknownRowY, - "is-unknown", - "collection", - layoutMode, - nodes - ); + } + + for (const ownerId of scopedOwnerIds) { + const stream = scopedNeutralStreamByOwnerId.get(ownerId); + if (!stream) { + continue; } + const position = ownerPosition.get(ownerId); + if (!position) { + continue; + } + const visual = streamNodeVisualStyle(stream, "is-unknown", "collection", darkMode); + nodes.push({ + id: ownerId, + parentNode: scopedCollectionOwnerId, + extent: "parent", + draggable: false, + data: { + label: ( + + + {streamDisplayName(stream.name, stream.address)} + + {compactMsgType(stream.msgType) ? ( + [{compactMsgType(stream.msgType)}] + ) : null} + + ), + }, + position: { x: position.x - scopePos.x, y: position.y - scopePos.y }, + sourcePosition: layoutMode === "tb" ? Position.Bottom : Position.Right, + targetPosition: layoutMode === "tb" ? Position.Top : Position.Left, + style: { + width: STREAM_NODE_WIDTH, + height: STREAM_NODE_HEIGHT, + borderRadius: visual.borderRadius, + border: visual.border, + background: visual.background, + color: visual.color, + fontSize: 8, + padding: "0 6px", + }, + }); } } @@ -1222,7 +1297,7 @@ export function buildFlowData( const inputs = collection.streams.filter((stream) => stream.direction === "input"); const outputs = collection.streams.filter((stream) => stream.direction === "output"); - const unknown = collection.streams.filter((stream) => stream.direction === "unknown"); + const neutral = collection.streams.filter(isNeutralCollectionStream); if (layoutMode === "lr") { const rowStep = 30; @@ -1302,25 +1377,37 @@ export function buildFlowData( }); }); - if (unknown.length > 0) { - placeUnitStreamRow( - nodeId, - size, - unknown, - size.height - STREAM_NODE_HEIGHT - 10, - "is-unknown", - "collection", - layoutMode, - nodes - ); - } + placeUnitStreamRow( + nodeId, + size, + neutral, + top, + "is-unknown", + "collection", + layoutMode, + nodes + ); } else { const topInputY = 86; const bottomOutputY = Math.max( topInputY + STREAM_NODE_HEIGHT + 10, size.height - STREAM_NODE_HEIGHT - 12 ); + const neutralY = Math.min( + bottomOutputY - STREAM_NODE_HEIGHT - 12, + Math.floor((topInputY + bottomOutputY) / 2) + ); placeUnitStreamRow(nodeId, size, inputs, topInputY, "is-input", "collection", layoutMode, nodes); + placeUnitStreamRow( + nodeId, + size, + neutral, + neutralY, + "is-unknown", + "collection", + layoutMode, + nodes + ); placeUnitStreamRow( nodeId, size, @@ -1331,18 +1418,6 @@ export function buildFlowData( layoutMode, nodes ); - if (unknown.length > 0) { - placeUnitStreamRow( - nodeId, - size, - unknown, - Math.floor((size.height - STREAM_NODE_HEIGHT) / 2) + 14, - "is-unknown", - "collection", - layoutMode, - nodes - ); - } } } diff --git a/frontend/src/components/topologyGraph.test.ts b/frontend/src/components/topologyGraph.test.ts index a7d2eb1..07adec1 100644 --- a/frontend/src/components/topologyGraph.test.ts +++ b/frontend/src/components/topologyGraph.test.ts @@ -32,6 +32,20 @@ function collection(address: string, children: string[]): CollectionComponent { }; } +function stream(address: string, direction: "input" | "output" | "unknown" = "unknown") { + return { + name: address.split("/").pop() ?? address, + address, + direction, + msgType: "builtins.str", + collectionKind: null, + relayMetadataType: null, + relayGroup: null, + relayInputTopic: null, + relayOutputTopic: null, + } as const; +} + describe("topologyGraph helpers", () => { it("builds nested scope paths and parent membership", () => { const collections = new Map([ @@ -84,6 +98,10 @@ describe("topologyGraph helpers", () => { direction: "output", msgType: "builtins.str", collectionKind: null, + relayMetadataType: null, + relayGroup: null, + relayInputTopic: null, + relayOutputTopic: null, }, ], }, @@ -105,4 +123,74 @@ describe("topologyGraph helpers", () => { rootScopeHasExternalStreamContext(graphSnapshot, units, collections, "LAB") ).toBe(true); }); + + it("treats relay-internal topics as collection-owned root context", () => { + const units = new Map([ + [ + "SYSTEM/SOURCE", + { + ...unit("SYSTEM/SOURCE"), + streams: [stream("SYSTEM/SOURCE/OUTPUT:source-output", "output")], + }, + ], + [ + "SYSTEM/SINK", + { + ...unit("SYSTEM/SINK"), + streams: [stream("SYSTEM/SINK/INPUT:sink-input", "input")], + }, + ], + ]); + const collections = new Map([ + [ + "SYSTEM", + collection("SYSTEM", [ + "SYSTEM/SOURCE", + "SYSTEM/PASSTHROUGH", + "SYSTEM/SINK", + ]), + ], + [ + "SYSTEM/PASSTHROUGH", + { + ...collection("SYSTEM/PASSTHROUGH", []), + streams: [ + { + ...stream("SYSTEM/PASSTHROUGH/IN", "input"), + name: "IN", + collectionKind: "relay", + relayMetadataType: "InputRelayMetadata", + relayGroup: "SYSTEM/PASSTHROUGH/__relays__/IN", + relayInputTopic: "SYSTEM/PASSTHROUGH/__relays__/IN/INPUT", + relayOutputTopic: "SYSTEM/PASSTHROUGH/__relays__/IN/OUTPUT", + }, + { + ...stream("SYSTEM/PASSTHROUGH/OUT", "output"), + name: "OUT", + collectionKind: "topic", + }, + ], + }, + ], + ]); + const graphSnapshot: GraphSnapshotPayload = { + graph: { + "SYSTEM/SOURCE/OUTPUT": ["SYSTEM/PASSTHROUGH/__relays__/IN/INPUT"], + "SYSTEM/PASSTHROUGH/__relays__/IN/OUTPUT": ["SYSTEM/PASSTHROUGH/OUT"], + "SYSTEM/PASSTHROUGH/OUT": ["SYSTEM/SINK/INPUT"], + }, + edge_owners: [], + sessions: {}, + processes: {}, + }; + + expect( + rootScopeHasExternalStreamContext( + graphSnapshot, + units, + collections, + "SYSTEM" + ) + ).toBe(false); + }); }); diff --git a/frontend/src/components/topologyGraph.ts b/frontend/src/components/topologyGraph.ts index 06266ea..349025d 100644 --- a/frontend/src/components/topologyGraph.ts +++ b/frontend/src/components/topologyGraph.ts @@ -4,18 +4,29 @@ import { streamAddressWithoutEndpoint } from "../utils/streamAddress"; type AnyRecord = Record; export type StreamDirection = "input" | "output" | "unknown"; +export type RelayMetadataType = + | "RelayMetadata" + | "InputRelayMetadata" + | "OutputRelayMetadata" + | null; + +export type ComponentStream = { + name: string; + address: string; + direction: StreamDirection; + msgType: string | null; + collectionKind: "topic" | "relay" | null; + relayMetadataType: RelayMetadataType; + relayGroup: string | null; + relayInputTopic: string | null; + relayOutputTopic: string | null; +}; export type UnitComponent = { address: string; name: string; componentType: string; - streams: Array<{ - name: string; - address: string; - direction: StreamDirection; - msgType: string | null; - collectionKind: "topic" | "relay" | null; - }>; + streams: ComponentStream[]; tasks: Array<{ name: string; subscribes: string | null; @@ -27,21 +38,37 @@ export type CollectionComponent = { address: string; name: string; componentType: string; - streams: Array<{ - name: string; - address: string; - direction: StreamDirection; - msgType: string | null; - collectionKind: "topic" | "relay" | null; - }>; + streams: ComponentStream[]; children: string[]; }; +export type TopologyComponents = { + units: Map; + collections: Map; +}; + +export type RelayAliasIndex = { + endpointByInternalTopic: Map; + collectionByInternalTopic: Map; +}; + function isRecord(value: unknown): value is AnyRecord { return typeof value === "object" && value !== null; } -function streamDirection(stream: AnyRecord): StreamDirection { +function streamDirection( + stream: AnyRecord, + relayType: RelayMetadataType = null +): StreamDirection { + if (relayType === "RelayMetadata") { + return "unknown"; + } + if (relayType === "InputRelayMetadata") { + return "input"; + } + if (relayType === "OutputRelayMetadata") { + return "output"; + } const hasInputHints = "leaky" in stream || "max_queue" in stream; if (hasInputHints) { return "input"; @@ -66,46 +93,95 @@ function streamDirection(stream: AnyRecord): StreamDirection { return "unknown"; } +function relayMetadataType(stream: AnyRecord): RelayMetadataType { + const explicitType = + typeof stream.metadata_type === "string" + ? stream.metadata_type + : typeof stream.__type__ === "string" + ? stream.__type__ + : typeof stream.type === "string" + ? stream.type + : null; + if (typeof explicitType === "string") { + if ( + explicitType === "InputRelayMetadata" + || explicitType.endsWith(".InputRelayMetadata") + ) { + return "InputRelayMetadata"; + } + if ( + explicitType === "OutputRelayMetadata" + || explicitType.endsWith(".OutputRelayMetadata") + ) { + return "OutputRelayMetadata"; + } + if ( + explicitType === "RelayMetadata" + || explicitType.endsWith(".RelayMetadata") + ) { + return "RelayMetadata"; + } + } + + const hasInputHints = "leaky" in stream || "max_queue" in stream; + const hasOutputHints = + "num_buffers" in stream + || "buf_size" in stream + || "force_tcp" in stream + || "host" in stream + || "port" in stream; + if (hasInputHints && !hasOutputHints) { + return "InputRelayMetadata"; + } + if (hasOutputHints && !hasInputHints) { + return "OutputRelayMetadata"; + } + if (hasInputHints || hasOutputHints) { + return "RelayMetadata"; + } + return null; +} + function parseStreamEntries( streams: AnyRecord | null, collectionKind: "topic" | "relay" | null = null -): Array<{ - name: string; - address: string; - direction: StreamDirection; - msgType: string | null; - collectionKind: "topic" | "relay" | null; -}> { +): ComponentStream[] { if (!streams) { return []; } - const out: Array<{ - name: string; - address: string; - direction: StreamDirection; - msgType: string | null; - collectionKind: "topic" | "relay" | null; - }> = []; + const out: ComponentStream[] = []; for (const [streamName, streamValue] of Object.entries(streams)) { if (!isRecord(streamValue) || typeof streamValue.address !== "string") { continue; } + const isRelay = collectionKind === "relay"; + const parsedRelayMetadataType = isRelay ? relayMetadataType(streamValue) : null; out.push({ name: streamName, address: streamValue.address, - direction: streamDirection(streamValue), + direction: streamDirection(streamValue, parsedRelayMetadataType), msgType: typeof streamValue.msg_type === "string" ? streamValue.msg_type : null, collectionKind, + relayMetadataType: parsedRelayMetadataType, + relayGroup: + isRelay && typeof streamValue.relay_group === "string" + ? streamValue.relay_group + : null, + relayInputTopic: + isRelay && typeof streamValue.relay_input_topic === "string" + ? streamValue.relay_input_topic + : null, + relayOutputTopic: + isRelay && typeof streamValue.relay_output_topic === "string" + ? streamValue.relay_output_topic + : null, }); } out.sort((a, b) => a.address.localeCompare(b.address)); return out; } -export function classifyComponents(graphSnapshot: GraphSnapshotPayload): { - units: Map; - collections: Map; -} { +export function classifyComponents(graphSnapshot: GraphSnapshotPayload): TopologyComponents { const componentRecords = new Map(); for (const session of Object.values(graphSnapshot.sessions)) { const metadata = isRecord(session.metadata) ? session.metadata : null; @@ -131,27 +207,23 @@ export function classifyComponents(graphSnapshot: GraphSnapshotPayload): { ? component.component_type : "Component"; + const topicStreams = parseStreamEntries( + isRecord(component.topics) ? component.topics : null, + "topic" + ); + const relayStreams = parseStreamEntries( + isRecord(component.relays) ? component.relays : null, + "relay" + ); const childrenRaw = Array.isArray(component.children) ? component.children.filter((value): value is string => typeof value === "string") : []; - if (childrenRaw.length > 0) { - const collectionStreamMap = new Map(); - for (const stream of parseStreamEntries( - isRecord(component.topics) ? component.topics : null, - "topic" - )) { + if (childrenRaw.length > 0 || topicStreams.length > 0 || relayStreams.length > 0) { + const collectionStreamMap = new Map(); + for (const stream of topicStreams) { collectionStreamMap.set(stream.address, stream); } - for (const stream of parseStreamEntries( - isRecord(component.relays) ? component.relays : null, - "relay" - )) { + for (const stream of relayStreams) { collectionStreamMap.set(stream.address, stream); } collections.set(address, { @@ -210,6 +282,35 @@ export function classifyComponents(graphSnapshot: GraphSnapshotPayload): { return { units, collections }; } +function registerAlias(index: Map, streamAddress: string | null, value: T): void { + if (!streamAddress) { + return; + } + index.set(streamAddress, value); + index.set(streamAddressWithoutEndpoint(streamAddress), value); +} + +export function buildRelayAliasIndex( + collections: Map +): RelayAliasIndex { + const endpointByInternalTopic = new Map(); + const collectionByInternalTopic = new Map(); + + for (const collection of collections.values()) { + for (const stream of collection.streams) { + if (stream.collectionKind !== "relay") { + continue; + } + registerAlias(endpointByInternalTopic, stream.relayInputTopic, stream.address); + registerAlias(endpointByInternalTopic, stream.relayOutputTopic, stream.address); + registerAlias(collectionByInternalTopic, stream.relayInputTopic, collection.address); + registerAlias(collectionByInternalTopic, stream.relayOutputTopic, collection.address); + } + } + + return { endpointByInternalTopic, collectionByInternalTopic }; +} + export function computeRanks( ownerIds: string[], edges: Array<{ from: string; to: string }> @@ -349,6 +450,7 @@ export function rootScopeHasExternalStreamContext( rootCollectionAddress: string ): boolean { const parentByAddress = buildCollectionParentMap(collections); + const relayAliasIndex = buildRelayAliasIndex(collections); const ownerByStreamAddress = new Map(); const registerOwner = (streamAddress: string, ownerAddress: string) => { ownerByStreamAddress.set(streamAddress, ownerAddress); @@ -364,6 +466,9 @@ export function rootScopeHasExternalStreamContext( registerOwner(stream.address, collection.address); } } + for (const [internalTopic, collectionAddress] of relayAliasIndex.collectionByInternalTopic.entries()) { + ownerByStreamAddress.set(internalTopic, collectionAddress); + } const streamAddresses = new Set(); for (const [fromTopic, toTopics] of Object.entries(graphSnapshot.graph)) { diff --git a/frontend/src/components/topologyTrace.ts b/frontend/src/components/topologyTrace.ts index c441ad4..ef5fc60 100644 --- a/frontend/src/components/topologyTrace.ts +++ b/frontend/src/components/topologyTrace.ts @@ -2,7 +2,11 @@ import { MarkerType } from "reactflow"; import type { GraphSnapshotPayload } from "../types/api"; import { streamAddressWithoutEndpoint } from "../utils/streamAddress"; -import type { CollectionComponent, UnitComponent } from "./topologyGraph"; +import { + buildRelayAliasIndex, + type CollectionComponent, + type UnitComponent, +} from "./topologyGraph"; import type { FlowData } from "./topologyFlowData"; export type TopologyComponents = { @@ -29,6 +33,10 @@ export function buildCanonicalStreamAliasIndex( canonicalByAlias.set(streamAddressWithoutEndpoint(stream.address), stream.address); } } + const relayAliasIndex = buildRelayAliasIndex(topologyComponents.collections); + for (const [internalTopic, endpointAddress] of relayAliasIndex.endpointByInternalTopic.entries()) { + canonicalByAlias.set(internalTopic, endpointAddress); + } return canonicalByAlias; } diff --git a/frontend/src/hooks/useDashboardData.ts b/frontend/src/hooks/useDashboardData.ts index 039d484..6973965 100644 --- a/frontend/src/hooks/useDashboardData.ts +++ b/frontend/src/hooks/useDashboardData.ts @@ -548,11 +548,12 @@ export function useDashboardData(options?: DashboardDataOptions) { }; } + const requestedTopic = request.publisher_topic ?? request.subscriber_topic; const scenario = (dashboardFixture.traceScenarios ?? []).find( (candidate) => candidate.processId === request.process_id && candidate.publisherEndpointId === request.publisher_endpoint_id - && candidate.publisherTopic === request.publisher_topic + && candidate.publisherTopic === requestedTopic ); if (scenario) { diff --git a/frontend/tests/e2e/dashboard.spec.ts-snapshots/long-labels-topology-dark-darwin.png b/frontend/tests/e2e/dashboard.spec.ts-snapshots/long-labels-topology-dark-darwin.png index 2b5416b..2a0bc4a 100644 Binary files a/frontend/tests/e2e/dashboard.spec.ts-snapshots/long-labels-topology-dark-darwin.png and b/frontend/tests/e2e/dashboard.spec.ts-snapshots/long-labels-topology-dark-darwin.png differ diff --git a/frontend/tests/e2e/dashboard.spec.ts-snapshots/nested-collections-pipeline-scope-dark-darwin.png b/frontend/tests/e2e/dashboard.spec.ts-snapshots/nested-collections-pipeline-scope-dark-darwin.png index 7bd1026..a067450 100644 Binary files a/frontend/tests/e2e/dashboard.spec.ts-snapshots/nested-collections-pipeline-scope-dark-darwin.png and b/frontend/tests/e2e/dashboard.spec.ts-snapshots/nested-collections-pipeline-scope-dark-darwin.png differ diff --git a/pyproject.toml b/pyproject.toml index 1255844..32615f5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,4 +57,4 @@ norecursedirs = "tests/helpers" addopts = "-p no:warnings" [tool.uv.sources] -ezmsg = { git = "https://github.com/ezmsg-org/ezmsg", branch = "feature/dashboard-integration" } \ No newline at end of file +# ezmsg = { path = "../ezmsg", editable = true } \ No newline at end of file diff --git a/src/ezmsg/dashboard/_web/assets/index-Cofzl4Dj.js b/src/ezmsg/dashboard/_web/assets/index-Cofzl4Dj.js new file mode 100644 index 0000000..1565f96 --- /dev/null +++ b/src/ezmsg/dashboard/_web/assets/index-Cofzl4Dj.js @@ -0,0 +1,60 @@ +(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();function Ap(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mp={exports:{}},pl={},Rp={exports:{}},_e={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var To=Symbol.for("react.element"),ny=Symbol.for("react.portal"),ry=Symbol.for("react.fragment"),sy=Symbol.for("react.strict_mode"),oy=Symbol.for("react.profiler"),iy=Symbol.for("react.provider"),ly=Symbol.for("react.context"),ay=Symbol.for("react.forward_ref"),uy=Symbol.for("react.suspense"),cy=Symbol.for("react.memo"),dy=Symbol.for("react.lazy"),dd=Symbol.iterator;function fy(e){return e===null||typeof e!="object"?null:(e=dd&&e[dd]||e["@@iterator"],typeof e=="function"?e:null)}var Op={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Lp=Object.assign,$p={};function fs(e,t,n){this.props=e,this.context=t,this.refs=$p,this.updater=n||Op}fs.prototype.isReactComponent={};fs.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};fs.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Bp(){}Bp.prototype=fs.prototype;function Xu(e,t,n){this.props=e,this.context=t,this.refs=$p,this.updater=n||Op}var Qu=Xu.prototype=new Bp;Qu.constructor=Xu;Lp(Qu,fs.prototype);Qu.isPureReactComponent=!0;var fd=Array.isArray,jp=Object.prototype.hasOwnProperty,Zu={current:null},Fp={key:!0,ref:!0,__self:!0,__source:!0};function zp(e,t,n){var r,s={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)jp.call(t,r)&&!Fp.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1>>1,R=I[F];if(0>>1;Fs(re,b))Js(fe,re)?(I[F]=fe,I[J]=b,F=J):(I[F]=re,I[Q]=b,F=Q);else if(Js(fe,b))I[F]=fe,I[J]=b,F=J;else break e}}return S}function s(I,S){var b=I.sortIndex-S.sortIndex;return b!==0?b:I.id-S.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var a=[],u=[],c=1,d=null,f=3,h=!1,_=!1,x=!1,N=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(I){for(var S=n(u);S!==null;){if(S.callback===null)r(u);else if(S.startTime<=I)r(u),S.sortIndex=S.expirationTime,t(a,S);else break;S=n(u)}}function w(I){if(x=!1,y(I),!_)if(n(a)!==null)_=!0,T(P);else{var S=n(u);S!==null&&M(w,S.startTime-I)}}function P(I,S){_=!1,x&&(x=!1,p(A),A=-1),h=!0;var b=f;try{for(y(S),d=n(a);d!==null&&(!(d.expirationTime>S)||I&&!U());){var F=d.callback;if(typeof F=="function"){d.callback=null,f=d.priorityLevel;var R=F(d.expirationTime<=S);S=e.unstable_now(),typeof R=="function"?d.callback=R:d===n(a)&&r(a),y(S)}else r(a);d=n(a)}if(d!==null)var X=!0;else{var Q=n(u);Q!==null&&M(w,Q.startTime-S),X=!1}return X}finally{d=null,f=b,h=!1}}var L=!1,O=null,A=-1,j=5,z=-1;function U(){return!(e.unstable_now()-zI||125F?(I.sortIndex=b,t(u,I),n(a)===null&&I===n(u)&&(x?(p(A),A=-1):x=!0,M(w,b-F))):(I.sortIndex=R,t(a,I),_||h||(_=!0,T(P))),I},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(I){var S=f;return function(){var b=f;f=S;try{return I.apply(this,arguments)}finally{f=b}}}})(Vp);Wp.exports=Vp;var Ey=Wp.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ny=E,St=Ey;function ne(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),$a=Object.prototype.hasOwnProperty,Ty=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,hd={},md={};function ky(e){return $a.call(md,e)?!0:$a.call(hd,e)?!1:Ty.test(e)?md[e]=!0:(hd[e]=!0,!1)}function Cy(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Iy(e,t,n,r){if(t===null||typeof t>"u"||Cy(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function dt(e,t,n,r,s,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var Je={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Je[e]=new dt(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Je[t]=new dt(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Je[e]=new dt(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Je[e]=new dt(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Je[e]=new dt(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Je[e]=new dt(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Je[e]=new dt(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Je[e]=new dt(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Je[e]=new dt(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ju=/[\-:]([a-z])/g;function ec(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ju,ec);Je[t]=new dt(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ju,ec);Je[t]=new dt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ju,ec);Je[t]=new dt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Je[e]=new dt(e,1,!1,e.toLowerCase(),null,!1,!1)});Je.xlinkHref=new dt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Je[e]=new dt(e,1,!1,e.toLowerCase(),null,!0,!0)});function tc(e,t,n,r){var s=Je.hasOwnProperty(t)?Je[t]:null;(s!==null?s.type!==0:r||!(2l||s[i]!==o[l]){var a=` +`+s[i].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=i&&0<=l);break}}}finally{Vl=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Os(e):""}function by(e){switch(e.tag){case 5:return Os(e.type);case 16:return Os("Lazy");case 13:return Os("Suspense");case 19:return Os("SuspenseList");case 0:case 2:case 15:return e=Gl(e.type,!1),e;case 11:return e=Gl(e.type.render,!1),e;case 1:return e=Gl(e.type,!0),e;default:return""}}function za(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Pr:return"Fragment";case br:return"Portal";case Ba:return"Profiler";case nc:return"StrictMode";case ja:return"Suspense";case Fa:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Kp:return(e.displayName||"Context")+".Consumer";case Yp:return(e._context.displayName||"Context")+".Provider";case rc:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case sc:return t=e.displayName||null,t!==null?t:za(e.type)||"Memo";case Nn:t=e._payload,e=e._init;try{return za(e(t))}catch{}}return null}function Py(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return za(t);case 8:return t===nc?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Un(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Qp(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ay(e){var t=Qp(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Lo(e){e._valueTracker||(e._valueTracker=Ay(e))}function Zp(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Qp(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Pi(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Da(e,t){var n=t.checked;return je({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function yd(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Un(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function qp(e,t){t=t.checked,t!=null&&tc(e,"checked",t,!1)}function Ua(e,t){qp(e,t);var n=Un(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ha(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ha(e,t.type,Un(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function vd(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ha(e,t,n){(t!=="number"||Pi(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ls=Array.isArray;function Vr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=$o.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function qs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ds={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},My=["Webkit","ms","Moz","O"];Object.keys(Ds).forEach(function(e){My.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ds[t]=Ds[e]})});function nh(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ds.hasOwnProperty(e)&&Ds[e]?(""+t).trim():t+"px"}function rh(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=nh(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Ry=je({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ga(e,t){if(t){if(Ry[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ne(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ne(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ne(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ne(62))}}function Ya(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ka=null;function oc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Xa=null,Gr=null,Yr=null;function wd(e){if(e=Io(e)){if(typeof Xa!="function")throw Error(ne(280));var t=e.stateNode;t&&(t=vl(t),Xa(e.stateNode,e.type,t))}}function sh(e){Gr?Yr?Yr.push(e):Yr=[e]:Gr=e}function oh(){if(Gr){var e=Gr,t=Yr;if(Yr=Gr=null,wd(e),t)for(e=0;e>>=0,e===0?32:31-(Wy(e)/Vy|0)|0}var Bo=64,jo=4194304;function $s(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Oi(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~s;l!==0?r=$s(l):(o&=i,o!==0&&(r=$s(o)))}else i=n&~s,i!==0?r=$s(i):o!==0&&(r=$s(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function ko(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Ut(t),e[t]=n}function Xy(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Hs),Pd=" ",Ad=!1;function Th(e,t){switch(e){case"keyup":return Ev.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function kh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ar=!1;function Tv(e,t){switch(e){case"compositionend":return kh(t);case"keypress":return t.which!==32?null:(Ad=!0,Pd);case"textInput":return e=t.data,e===Pd&&Ad?null:e;default:return null}}function kv(e,t){if(Ar)return e==="compositionend"||!pc&&Th(e,t)?(e=Eh(),gi=cc=An=null,Ar=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Ld(n)}}function Ph(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ph(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ah(){for(var e=window,t=Pi();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Pi(e.document)}return t}function hc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Lv(e){var t=Ah(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ph(n.ownerDocument.documentElement,n)){if(r!==null&&hc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=$d(n,o);var i=$d(n,r);s&&i&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Mr=null,tu=null,Vs=null,nu=!1;function Bd(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;nu||Mr==null||Mr!==Pi(r)||(r=Mr,"selectionStart"in r&&hc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Vs&&so(Vs,r)||(Vs=r,r=Bi(tu,"onSelect"),0Lr||(e.current=au[Lr],au[Lr]=null,Lr--)}function Ce(e,t){Lr++,au[Lr]=e.current,e.current=t}var Hn={},it=Vn(Hn),gt=Vn(!1),dr=Hn;function ts(e,t){var n=e.type.contextTypes;if(!n)return Hn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function yt(e){return e=e.childContextTypes,e!=null}function Fi(){Ae(gt),Ae(it)}function Wd(e,t,n){if(it.current!==Hn)throw Error(ne(168));Ce(it,t),Ce(gt,n)}function zh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(ne(108,Py(e)||"Unknown",s));return je({},n,r)}function zi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Hn,dr=it.current,Ce(it,e),Ce(gt,gt.current),!0}function Vd(e,t,n){var r=e.stateNode;if(!r)throw Error(ne(169));n?(e=zh(e,t,dr),r.__reactInternalMemoizedMergedChildContext=e,Ae(gt),Ae(it),Ce(it,e)):Ae(gt),Ce(gt,n)}var ln=null,_l=!1,ia=!1;function Dh(e){ln===null?ln=[e]:ln.push(e)}function Yv(e){_l=!0,Dh(e)}function Gn(){if(!ia&&ln!==null){ia=!0;var e=0,t=Te;try{var n=ln;for(Te=1;e>=i,s-=i,an=1<<32-Ut(t)+s|n<A?(j=O,O=null):j=O.sibling;var z=f(p,O,y[A],w);if(z===null){O===null&&(O=j);break}e&&O&&z.alternate===null&&t(p,O),g=o(z,g,A),L===null?P=z:L.sibling=z,L=z,O=j}if(A===y.length)return n(p,O),Re&&Zn(p,A),P;if(O===null){for(;AA?(j=O,O=null):j=O.sibling;var U=f(p,O,z.value,w);if(U===null){O===null&&(O=j);break}e&&O&&U.alternate===null&&t(p,O),g=o(U,g,A),L===null?P=U:L.sibling=U,L=U,O=j}if(z.done)return n(p,O),Re&&Zn(p,A),P;if(O===null){for(;!z.done;A++,z=y.next())z=d(p,z.value,w),z!==null&&(g=o(z,g,A),L===null?P=z:L.sibling=z,L=z);return Re&&Zn(p,A),P}for(O=r(p,O);!z.done;A++,z=y.next())z=h(O,p,A,z.value,w),z!==null&&(e&&z.alternate!==null&&O.delete(z.key===null?A:z.key),g=o(z,g,A),L===null?P=z:L.sibling=z,L=z);return e&&O.forEach(function(Z){return t(p,Z)}),Re&&Zn(p,A),P}function N(p,g,y,w){if(typeof y=="object"&&y!==null&&y.type===Pr&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Oo:e:{for(var P=y.key,L=g;L!==null;){if(L.key===P){if(P=y.type,P===Pr){if(L.tag===7){n(p,L.sibling),g=s(L,y.props.children),g.return=p,p=g;break e}}else if(L.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Nn&&Kd(P)===L.type){n(p,L.sibling),g=s(L,y.props),g.ref=Ss(p,L,y),g.return=p,p=g;break e}n(p,L);break}else t(p,L);L=L.sibling}y.type===Pr?(g=ar(y.props.children,p.mode,w,y.key),g.return=p,p=g):(w=Ni(y.type,y.key,y.props,null,p.mode,w),w.ref=Ss(p,g,y),w.return=p,p=w)}return i(p);case br:e:{for(L=y.key;g!==null;){if(g.key===L)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(p,g.sibling),g=s(g,y.children||[]),g.return=p,p=g;break e}else{n(p,g);break}else t(p,g);g=g.sibling}g=ha(y,p.mode,w),g.return=p,p=g}return i(p);case Nn:return L=y._init,N(p,g,L(y._payload),w)}if(Ls(y))return _(p,g,y,w);if(ys(y))return x(p,g,y,w);Vo(p,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(p,g.sibling),g=s(g,y),g.return=p,p=g):(n(p,g),g=pa(y,p.mode,w),g.return=p,p=g),i(p)):n(p,g)}return N}var rs=Vh(!0),Gh=Vh(!1),Hi=Vn(null),Wi=null,jr=null,vc=null;function _c(){vc=jr=Wi=null}function xc(e){var t=Hi.current;Ae(Hi),e._currentValue=t}function du(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Xr(e,t){Wi=e,vc=jr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ht=!0),e.firstContext=null)}function Mt(e){var t=e._currentValue;if(vc!==e)if(e={context:e,memoizedValue:t,next:null},jr===null){if(Wi===null)throw Error(ne(308));jr=e,Wi.dependencies={lanes:0,firstContext:e}}else jr=jr.next=e;return t}var rr=null;function wc(e){rr===null?rr=[e]:rr.push(e)}function Yh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,wc(t)):(n.next=s.next,s.next=n),t.interleaved=n,mn(e,r)}function mn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Tn=!1;function Sc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Kh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function dn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Bn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Se&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,mn(e,n)}return s=r.interleaved,s===null?(t.next=t,wc(r)):(t.next=s.next,s.next=t),r.interleaved=t,mn(e,n)}function vi(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,lc(e,n)}}function Xd(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Vi(e,t,n,r){var s=e.updateQueue;Tn=!1;var o=s.firstBaseUpdate,i=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var a=l,u=a.next;a.next=null,i===null?o=u:i.next=u,i=a;var c=e.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==i&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(o!==null){var d=s.baseState;i=0,c=u=a=null,l=o;do{var f=l.lane,h=l.eventTime;if((r&f)===f){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var _=e,x=l;switch(f=t,h=n,x.tag){case 1:if(_=x.payload,typeof _=="function"){d=_.call(h,d,f);break e}d=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=x.payload,f=typeof _=="function"?_.call(h,d,f):_,f==null)break e;d=je({},d,f);break e;case 2:Tn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=s.effects,f===null?s.effects=[l]:f.push(l))}else h={eventTime:h,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=d):c=c.next=h,i|=f;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;f=l,l=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(c===null&&(a=d),s.baseState=a,s.firstBaseUpdate=u,s.lastBaseUpdate=c,t=s.shared.interleaved,t!==null){s=t;do i|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);hr|=i,e.lanes=i,e.memoizedState=d}}function Qd(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=aa.transition;aa.transition={};try{e(!1),t()}finally{Te=n,aa.transition=r}}function dm(){return Rt().memoizedState}function Zv(e,t,n){var r=Fn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},fm(e))pm(t,n);else if(n=Yh(e,t,n,r),n!==null){var s=ut();Ht(n,e,r,s),hm(n,t,r)}}function qv(e,t,n){var r=Fn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(fm(e))pm(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,l=o(i,n);if(s.hasEagerState=!0,s.eagerState=l,Vt(l,i)){var a=t.interleaved;a===null?(s.next=s,wc(t)):(s.next=a.next,a.next=s),t.interleaved=s;return}}catch{}finally{}n=Yh(e,t,s,r),n!==null&&(s=ut(),Ht(n,e,r,s),hm(n,t,r))}}function fm(e){var t=e.alternate;return e===Be||t!==null&&t===Be}function pm(e,t){Gs=Yi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hm(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,lc(e,n)}}var Ki={readContext:Mt,useCallback:nt,useContext:nt,useEffect:nt,useImperativeHandle:nt,useInsertionEffect:nt,useLayoutEffect:nt,useMemo:nt,useReducer:nt,useRef:nt,useState:nt,useDebugValue:nt,useDeferredValue:nt,useTransition:nt,useMutableSource:nt,useSyncExternalStore:nt,useId:nt,unstable_isNewReconciler:!1},Jv={readContext:Mt,useCallback:function(e,t){return Kt().memoizedState=[e,t===void 0?null:t],e},useContext:Mt,useEffect:qd,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,xi(4194308,4,im.bind(null,t,e),n)},useLayoutEffect:function(e,t){return xi(4194308,4,e,t)},useInsertionEffect:function(e,t){return xi(4,2,e,t)},useMemo:function(e,t){var n=Kt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Kt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Zv.bind(null,Be,e),[r.memoizedState,e]},useRef:function(e){var t=Kt();return e={current:e},t.memoizedState=e},useState:Zd,useDebugValue:Pc,useDeferredValue:function(e){return Kt().memoizedState=e},useTransition:function(){var e=Zd(!1),t=e[0];return e=Qv.bind(null,e[1]),Kt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Be,s=Kt();if(Re){if(n===void 0)throw Error(ne(407));n=n()}else{if(n=t(),Xe===null)throw Error(ne(349));pr&30||qh(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,qd(em.bind(null,r,o,e),[e]),r.flags|=2048,po(9,Jh.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Kt(),t=Xe.identifierPrefix;if(Re){var n=un,r=an;n=(r&~(1<<32-Ut(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=co++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Xt]=t,e[lo]=r,Nm(e,t,!1,!1),t.stateNode=e;e:{switch(i=Ya(n,r),n){case"dialog":Pe("cancel",e),Pe("close",e),s=r;break;case"iframe":case"object":case"embed":Pe("load",e),s=r;break;case"video":case"audio":for(s=0;sis&&(t.flags|=128,r=!0,Es(o,!1),t.lanes=4194304)}else{if(!r)if(e=Gi(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Es(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!Re)return rt(t),null}else 2*Ue()-o.renderingStartTime>is&&n!==1073741824&&(t.flags|=128,r=!0,Es(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Ue(),t.sibling=null,n=Oe.current,Ce(Oe,r?n&1|2:n&1),t):(rt(t),null);case 22:case 23:return $c(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?_t&1073741824&&(rt(t),t.subtreeFlags&6&&(t.flags|=8192)):rt(t),null;case 24:return null;case 25:return null}throw Error(ne(156,t.tag))}function l_(e,t){switch(gc(t),t.tag){case 1:return yt(t.type)&&Fi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ss(),Ae(gt),Ae(it),Tc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Nc(t),null;case 13:if(Ae(Oe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ne(340));ns()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ae(Oe),null;case 4:return ss(),null;case 10:return xc(t.type._context),null;case 22:case 23:return $c(),null;case 24:return null;default:return null}}var Yo=!1,ot=!1,a_=typeof WeakSet=="function"?WeakSet:Set,ue=null;function Fr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ze(e,t,r)}else n.current=null}function xu(e,t,n){try{n()}catch(r){ze(e,t,r)}}var cf=!1;function u_(e,t){if(ru=Li,e=Ah(),hc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,l=-1,a=-1,u=0,c=0,d=e,f=null;t:for(;;){for(var h;d!==n||s!==0&&d.nodeType!==3||(l=i+s),d!==o||r!==0&&d.nodeType!==3||(a=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(h=d.firstChild)!==null;)f=d,d=h;for(;;){if(d===e)break t;if(f===n&&++u===s&&(l=i),f===o&&++c===r&&(a=i),(h=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(su={focusedElem:e,selectionRange:n},Li=!1,ue=t;ue!==null;)if(t=ue,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ue=e;else for(;ue!==null;){t=ue;try{var _=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var x=_.memoizedProps,N=_.memoizedState,p=t.stateNode,g=p.getSnapshotBeforeUpdate(t.elementType===t.type?x:$t(t.type,x),N);p.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ne(163))}}catch(w){ze(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,ue=e;break}ue=t.return}return _=cf,cf=!1,_}function Ys(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&xu(t,n,o)}s=s.next}while(s!==r)}}function Sl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function wu(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Cm(e){var t=e.alternate;t!==null&&(e.alternate=null,Cm(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Xt],delete t[lo],delete t[lu],delete t[Vv],delete t[Gv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Im(e){return e.tag===5||e.tag===3||e.tag===4}function df(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Im(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Su(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ji));else if(r!==4&&(e=e.child,e!==null))for(Su(e,t,n),e=e.sibling;e!==null;)Su(e,t,n),e=e.sibling}function Eu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Eu(e,t,n),e=e.sibling;e!==null;)Eu(e,t,n),e=e.sibling}var Ze=null,Bt=!1;function xn(e,t,n){for(n=n.child;n!==null;)bm(e,t,n),n=n.sibling}function bm(e,t,n){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(hl,n)}catch{}switch(n.tag){case 5:ot||Fr(n,t);case 6:var r=Ze,s=Bt;Ze=null,xn(e,t,n),Ze=r,Bt=s,Ze!==null&&(Bt?(e=Ze,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ze.removeChild(n.stateNode));break;case 18:Ze!==null&&(Bt?(e=Ze,n=n.stateNode,e.nodeType===8?oa(e.parentNode,n):e.nodeType===1&&oa(e,n),no(e)):oa(Ze,n.stateNode));break;case 4:r=Ze,s=Bt,Ze=n.stateNode.containerInfo,Bt=!0,xn(e,t,n),Ze=r,Bt=s;break;case 0:case 11:case 14:case 15:if(!ot&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&xu(n,t,i),s=s.next}while(s!==r)}xn(e,t,n);break;case 1:if(!ot&&(Fr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ze(n,t,l)}xn(e,t,n);break;case 21:xn(e,t,n);break;case 22:n.mode&1?(ot=(r=ot)||n.memoizedState!==null,xn(e,t,n),ot=r):xn(e,t,n);break;default:xn(e,t,n)}}function ff(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new a_),t.forEach(function(r){var s=v_.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Ot(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=i),r&=~o}if(r=s,r=Ue()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*d_(r/1960))-r,10e?16:e,Mn===null)var r=!1;else{if(e=Mn,Mn=null,Zi=0,Se&6)throw Error(ne(331));var s=Se;for(Se|=4,ue=e.current;ue!==null;){var o=ue,i=o.child;if(ue.flags&16){var l=o.deletions;if(l!==null){for(var a=0;aUe()-Oc?lr(e,0):Rc|=n),vt(e,t)}function Bm(e,t){t===0&&(e.mode&1?(t=jo,jo<<=1,!(jo&130023424)&&(jo=4194304)):t=1);var n=ut();e=mn(e,t),e!==null&&(ko(e,t,n),vt(e,n))}function y_(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Bm(e,n)}function v_(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(ne(314))}r!==null&&r.delete(t),Bm(e,n)}var jm;jm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||gt.current)ht=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ht=!1,o_(e,t,n);ht=!!(e.flags&131072)}else ht=!1,Re&&t.flags&1048576&&Uh(t,Ui,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wi(e,t),e=t.pendingProps;var s=ts(t,it.current);Xr(t,n),s=Cc(null,t,r,e,s,n);var o=Ic();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,yt(r)?(o=!0,zi(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,Sc(t),s.updater=wl,t.stateNode=s,s._reactInternals=t,pu(t,r,e,n),t=gu(null,t,r,!0,o,n)):(t.tag=0,Re&&o&&mc(t),lt(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wi(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=x_(r),e=$t(r,e),s){case 0:t=mu(null,t,r,e,n);break e;case 1:t=lf(null,t,r,e,n);break e;case 11:t=sf(null,t,r,e,n);break e;case 14:t=of(null,t,r,$t(r.type,e),n);break e}throw Error(ne(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:$t(r,s),mu(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:$t(r,s),lf(e,t,r,s,n);case 3:e:{if(wm(t),e===null)throw Error(ne(387));r=t.pendingProps,o=t.memoizedState,s=o.element,Kh(e,t),Vi(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=os(Error(ne(423)),t),t=af(e,t,r,n,s);break e}else if(r!==s){s=os(Error(ne(424)),t),t=af(e,t,r,n,s);break e}else for(xt=$n(t.stateNode.containerInfo.firstChild),wt=t,Re=!0,Ft=null,n=Gh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(ns(),r===s){t=gn(e,t,n);break e}lt(e,t,r,n)}t=t.child}return t;case 5:return Xh(t),e===null&&cu(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,ou(r,s)?i=null:o!==null&&ou(r,o)&&(t.flags|=32),xm(e,t),lt(e,t,i,n),t.child;case 6:return e===null&&cu(t),null;case 13:return Sm(e,t,n);case 4:return Ec(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=rs(t,null,r,n):lt(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:$t(r,s),sf(e,t,r,s,n);case 7:return lt(e,t,t.pendingProps,n),t.child;case 8:return lt(e,t,t.pendingProps.children,n),t.child;case 12:return lt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,i=s.value,Ce(Hi,r._currentValue),r._currentValue=i,o!==null)if(Vt(o.value,i)){if(o.children===s.children&&!gt.current){t=gn(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){i=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=dn(-1,n&-n),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),du(o.return,n,t),l.lanes|=n;break}a=a.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(ne(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),du(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}lt(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Xr(t,n),s=Mt(s),r=r(s),t.flags|=1,lt(e,t,r,n),t.child;case 14:return r=t.type,s=$t(r,t.pendingProps),s=$t(r.type,s),of(e,t,r,s,n);case 15:return vm(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:$t(r,s),wi(e,t),t.tag=1,yt(r)?(e=!0,zi(t)):e=!1,Xr(t,n),mm(t,r,s),pu(t,r,s,n),gu(null,t,r,!0,e,n);case 19:return Em(e,t,n);case 22:return _m(e,t,n)}throw Error(ne(156,t.tag))};function Fm(e,t){return fh(e,t)}function __(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bt(e,t,n,r){return new __(e,t,n,r)}function jc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function x_(e){if(typeof e=="function")return jc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===rc)return 11;if(e===sc)return 14}return 2}function zn(e,t){var n=e.alternate;return n===null?(n=bt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ni(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")jc(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Pr:return ar(n.children,s,o,t);case nc:i=8,s|=8;break;case Ba:return e=bt(12,n,t,s|2),e.elementType=Ba,e.lanes=o,e;case ja:return e=bt(13,n,t,s),e.elementType=ja,e.lanes=o,e;case Fa:return e=bt(19,n,t,s),e.elementType=Fa,e.lanes=o,e;case Xp:return Nl(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Yp:i=10;break e;case Kp:i=9;break e;case rc:i=11;break e;case sc:i=14;break e;case Nn:i=16,r=null;break e}throw Error(ne(130,e==null?e:typeof e,""))}return t=bt(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function ar(e,t,n,r){return e=bt(7,e,r,t),e.lanes=n,e}function Nl(e,t,n,r){return e=bt(22,e,r,t),e.elementType=Xp,e.lanes=n,e.stateNode={isHidden:!1},e}function pa(e,t,n){return e=bt(6,e,null,t),e.lanes=n,e}function ha(e,t,n){return t=bt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function w_(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Kl(0),this.expirationTimes=Kl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Kl(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Fc(e,t,n,r,s,o,i,l,a){return e=new w_(e,t,n,l,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=bt(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Sc(o),e}function S_(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Hm)}catch(e){console.error(e)}}Hm(),Hp.exports=Nt;var Wm=Hp.exports,xf=Wm;La.createRoot=xf.createRoot,La.hydrateRoot=xf.hydrateRoot;function el({title:e,subtitle:t,children:n}){const r=!!e||!!t;return m.jsxs("section",{className:`panel ${r?"":"panel--headerless"}`.trim(),children:[r?m.jsxs("header",{className:"panel__header",children:[e?m.jsx("h2",{children:e}):null,t?m.jsx("p",{children:t}):null]}):null,m.jsx("div",{className:"panel__body",children:n})]})}const tl=["#93c5fd","#a78bfa","#f9a8d4","#86efac","#fdba74","#67e8f9","#fca5a5","#c4b5fd","#fde68a","#6ee7b7","#fda4af","#5eead4","#ddd6fe","#bef264","#fbcfe8","#bae6fd"];function C_(e){let t=0;for(let n=0;n>>0;return t}function I_(e){return`hsl(${(e*137.508%360).toFixed(1)} 75% 68%)`}function wf(e){const t=[...new Set(e)].sort(),n={};for(let r=0;re.layout.cols){$_(e);for(let o=0;ol+a+1||(e.beginPath(),e.moveTo(c,t.top),e.lineTo(c,t.top+t.plotHeight),e.stroke())}for(let u=0;u<=t.yTicks;u+=1){const c=t.plotBottom-u/t.yTicks*(t.plotBottom-t.plotTop);e.beginPath(),e.moveTo(l,c),e.lineTo(l+a,c),e.stroke()}e.strokeStyle=s.axis,e.beginPath(),e.moveTo(l,t.plotBottom),e.lineTo(l+a,t.plotBottom),e.stroke()}function rl(e,t,{color:n,lineWidth:r,alpha:s=1,lineDash:o=[],startCol:i,endCol:l,yMaxMs:a,layout:u}){const c=Math.max(0,i-1),d=Math.min(u.cols-1,l+1);e.strokeStyle=n,e.lineWidth=r,e.globalAlpha=s,e.setLineDash(o),e.beginPath();const f=[];let h=null,_=Number.NaN,x=!1;for(let N=c-1;N>=0;N-=1){const p=t[N];if(Number.isFinite(p)){h=N,_=p,x=p>a;break}}for(let N=c;N<=d;N+=1){const p=t[N];if(!Number.isFinite(p))continue;const g=p>a;if(g&&!x&&f.push(N),h!==null&&Number.isFinite(_)){const y=_>a;if(!(y&&g)){const w=u.left+h+.5,P=y?u.plotTop:mo(_,a,u),L=u.left+N+.5,O=g?u.plotTop:mo(p,a,u);e.moveTo(w,P),e.lineTo(L,O)}}h=N,_=p,x=g}if(e.stroke(),e.setLineDash([]),e.globalAlpha=1,f.length>0){e.fillStyle=n,e.globalAlpha=Math.min(1,s+.1);for(const N of f){const p=u.left+N;e.fillRect(p,u.plotTop,1,3)}e.globalAlpha=1}}function Ef(e,t,n,{color:r,alpha:s,lineDash:o=[],startCol:i,endCol:l,yMaxMs:a,layout:u}){e.strokeStyle=r,e.lineWidth=1,e.globalAlpha=s,e.setLineDash(o);for(let c=i;c<=l;c+=1){const d=t[c],f=n[c];if(!Number.isFinite(d)||!Number.isFinite(f)||f<=d)continue;const h=u.left+c+.5,_=d>a?u.plotTop:mo(d,a,u),x=f>a?u.plotTop:mo(f,a,u);e.beginPath(),e.moveTo(h,_),e.lineTo(h,x),e.stroke()}e.setLineDash([]),e.globalAlpha=1}function Nf(e,t,{color:n,alpha:r,startCol:s,endCol:o,yMaxMs:i,layout:l}){const a=Math.max(0,s-1),u=Math.min(l.cols-1,o+1);let c=null,d=null;for(let f=a;f<=u;f+=1){const h=t[f];!Number.isFinite(h)||h<=0||(c===null&&(c=f),d=f)}if(!(c===null||d===null)){e.fillStyle=n,e.globalAlpha=r,e.beginPath(),e.moveTo(l.left+c+.5,l.plotBottom);for(let f=c;f<=d;f+=1){const h=t[f];if(!Number.isFinite(h)||h<=0)continue;const _=Math.min(h,i),x=l.left+f+.5,N=mo(_,i,l);e.lineTo(x,N)}e.lineTo(l.left+d+.5,l.plotBottom),e.closePath(),e.fill(),e.globalAlpha=1}}function F_(e,{leaseBins:t,userBins:n,color:r,startCol:s,endCol:o,yMaxMs:i,layout:l}){if(Nf(e,t,{color:r,alpha:.18,startCol:s,endCol:o,yMaxMs:i,layout:l}),n!==null){const a=new Float32Array(n.length);a.fill(Number.NaN);for(let u=s;u<=o&&u9&&(n*=10,r=1),Math.max(Dr,r*n)}function kf(e){if(!Number.isFinite(e)||e<=0)return js;const t=1e3/e;return D_(t*1.25)}function Cf(e,t,n,r,s,o,i){let l=e.get(o),a=t.get(o),u=n.get(o),c=r.get(o),d=s.get(o);return l||(l=nl(i),e.set(o,l)),a||(a=nl(i),t.set(o,a)),u||(u=new Float64Array(i),n.set(o,u)),c||(c=new Uint16Array(i),r.set(o,c)),d||(d=new Int32Array(i),d.fill(-2147483648),s.set(o,d)),{bins:l,peakBins:a,sumBins:u,countBins:c,cycleBins:d}}function U_({samples:e,publisherProcessId:t,publisherEndpointId:n,nominalPublishRateHz:r,topic:s,topicScope:o,leaseColorMap:i,selectedSubscriberEndpointId:l=null,windowSeconds:a,onWindowSecondsChange:u,darkMode:c=!1}){const d=E.useRef(null),f=E.useRef(null),h=E.useRef(null),_=E.useRef(null),x=E.useRef(!0),N=E.useRef(!1),[p,g]=E.useState(()=>a.toFixed(1)),[y,w]=E.useState(!0),[P,L]=E.useState(`${js.toFixed(2)}`),[O,A]=E.useState("lease_time_ns"),j=E.useMemo(()=>l?Qs(l,i):null,[i,l]),z=c?Vm:b_,U=E.useMemo(()=>Qo(P),[P]),Z=E.useMemo(()=>o&&o.length>0?o:[s],[s,o]),D=E.useMemo(()=>[...Z].sort().join("|"),[Z]),v=`${t}|${n}`,k=M=>{const I=Qo(M??p);if(I===null||!u){g(a.toFixed(1));return}const S=gr(I,.5,30);u(S),g(S.toFixed(1))},T=()=>{var M;if(y){const I=((M=h.current)==null?void 0:M.yMaxMs)??kf(r);L(I.toFixed(2)),w(!1);return}w(!0)};return E.useEffect(()=>{g(a.toFixed(1))},[a]),E.useEffect(()=>{const M=d.current;if(!M)return;const I=M.getContext("2d");if(!I)return;const S=Math.max(1,window.devicePixelRatio||1),b=M_(M,a),F=Math.floor(b.width*S),R=Math.floor(b.height*S),X=f.current,Q=!X||X.width!==F||X.height!==R;Q&&(M.width=F,M.height=R,f.current={width:F,height:R}),I.setTransform(S,0,0,S,0,0);const re=Math.max(1,a*1e9),J=kf(r),fe=y?J:Math.max(Dr,U??js);let V=h.current;const me=V===null||Q||V.layout.cols!==b.cols||V.layout.width!==b.width||V.windowNs!==re||V.scopeSignature!==D||V.publisherSignature!==v;if(me&&(V=R_(b,re,D,v,fe),h.current=V,_.current=null,I.fillStyle=z.background,I.fillRect(0,0,b.width,b.height)),V===null)return;const K=new Set;let C=V.lastTimestamp,B=!1,te=V.lastWipeCycle,q=null;V.originNs!==null&&Number.isFinite(V.lastTimestamp)&&(q=ma(V.lastTimestamp,V.originNs,V.windowNs,V.layout.cols));const ae=e!==_.current?e:[];e!==_.current&&(_.current=e);for(const oe of ae){if(!Number.isFinite(oe.timestamp)||!Number.isFinite(oe.value)||!O_(oe.topic,Z))continue;const ee=oe.metric==="publish_delta_ns"&&oe.processId===t&&oe.endpointId===n,ge=oe.metric==="lease_time_ns",de=oe.metric==="user_span_ns";if(!ee&&!ge&&!de||(V.originNs===null&&(V.originNs=oe.timestamp),V.originNs===null||oe.timestamp0&&(B_(V,q,Y,K),q=Y):q=Y,ee){$>V.publishCycle[H]&&(V.publishCycle[H]=$,V.publishBins[H]=Number.NaN,V.publishPeakBins[H]=Number.NaN,V.publishSumBins[H]=0,V.publishCountBins[H]=0,K.add(H));const se=Math.min(65535,V.publishCountBins[H]+1);V.publishCountBins[H]=se,V.publishSumBins[H]+=G;const le=V.publishSumBins[H]/se,we=V.publishBins[H];(!Number.isFinite(we)||Math.abs(le-we)>1e-6)&&(V.publishBins[H]=le,K.add(H));const Ee=V.publishPeakBins[H];(!Number.isFinite(Ee)||G>Ee)&&(V.publishPeakBins[H]=G,K.add(H))}else{const se=ge?Cf(V.leaseBinsByEndpoint,V.leasePeakBinsByEndpoint,V.leaseSumByEndpoint,V.leaseCountByEndpoint,V.leaseCycleByEndpoint,oe.endpointId,V.layout.cols):Cf(V.userBinsByEndpoint,V.userPeakBinsByEndpoint,V.userSumByEndpoint,V.userCountByEndpoint,V.userCycleByEndpoint,oe.endpointId,V.layout.cols);$>se.cycleBins[H]&&(se.cycleBins[H]=$,se.bins[H]=Number.NaN,se.peakBins[H]=Number.NaN,se.sumBins[H]=0,se.countBins[H]=0,K.add(H));const le=Math.min(65535,se.countBins[H]+1);se.countBins[H]=le,se.sumBins[H]+=G;const we=se.sumBins[H]/le,Ee=se.bins[H];(!Number.isFinite(Ee)||Math.abs(we-Ee)>1e-6)&&(se.bins[H]=we,K.add(H));const be=se.peakBins[H];(!Number.isFinite(be)||G>be)&&(se.peakBins[H]=G,K.add(H))}C=Math.max(C,oe.timestamp),B=!0}const pe=y&&!x.current;if(x.current=y,y?pe?V.yMaxMs=J:te>V.lastWipeCycle&&(V.lastWipeCycle=te,V.yMaxMs=J):V.yMaxMs=Math.max(Dr,U??js),y){const oe=V.yMaxMs.toFixed(2);P!==oe&&L(oe)}if(B&&V.originNs!==null){const oe=ma(C,V.originNs,V.windowNs,V.layout.cols);K.add(oe.col),V.lastCursorCol!==null&&Sf(K,V.lastCursorCol,V.layout.cols);const ee=(oe.col+P_)%V.layout.cols;Sf(K,ee,V.layout.cols),V.lastCursorCol=ee,V.lastTimestamp=C}if((me||K.size>0)&&(I.fillStyle=z.background,I.fillRect(0,0,V.layout.width,V.layout.height),z_(I,V,0,V.layout.cols-1,O,l,i,z)),V.lastTimestamp<=0){I.fillStyle=z.background,I.fillRect(0,0,V.layout.width,V.layout.height),I.fillStyle=z.waitingText,I.font='12px "Avenir Next", sans-serif',I.fillText("Waiting for trace samples...",V.layout.left,26),Tf(I,V,a,z);return}Tf(I,V,a,z)},[y,c,Z,i,U,r,n,t,v,l,e,O,D,a,z]),m.jsxs("div",{className:"timing-trace",children:[m.jsxs("div",{className:"timing-trace__controls",children:[m.jsxs("div",{className:"timing-trace__controls-left",children:[m.jsxs("label",{className:"timing-trace__axis-input",children:[m.jsx("span",{children:"Window (s)"}),m.jsx("input",{type:"number",min:.5,max:30,step:"0.5",value:p,onChange:M=>{const I=M.target.value;g(I),N.current||k(I)},onMouseDown:()=>{N.current=!1},onBlur:()=>{N.current=!1,k()},onKeyDown:M=>{if(M.key==="Enter"){N.current=!1,k();return}if(M.key==="ArrowUp"||M.key==="ArrowDown"){M.preventDefault(),N.current=!1;const I=Qo(p)??a,S=M.key==="ArrowUp"?.5:-.5,b=gr(I+S,.5,30);g(b.toFixed(1)),u==null||u(b);return}(M.key.length===1||M.key==="Backspace"||M.key==="Delete")&&(N.current=!0)}})]}),m.jsxs("span",{className:"timing-trace__legend-item is-static",children:[m.jsx("i",{style:{background:z.publish}}),"Publish Delta"]}),l?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"timing-trace__legend-item is-static",children:[m.jsx("i",{style:{background:"transparent",border:`2px solid ${j??"#94a3b8"}`}}),"Lease Time"]}),m.jsxs("span",{className:"timing-trace__legend-item is-static",children:[m.jsx("i",{style:{background:j??"#94a3b8"}}),"User Span"]})]}):m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:`timing-trace__legend-item timing-trace__legend-toggle ${O==="lease_time_ns"?"is-active":""}`,onClick:()=>A("lease_time_ns"),"aria-pressed":O==="lease_time_ns",children:"Lease Time"}),m.jsx("button",{type:"button",className:`timing-trace__legend-item timing-trace__legend-toggle ${O==="user_span_ns"?"is-active":""}`,onClick:()=>A("user_span_ns"),"aria-pressed":O==="user_span_ns",children:"User Span"})]})]}),m.jsxs("div",{className:"timing-trace__controls-right",children:[m.jsxs("label",{className:"timing-trace__axis-input timing-trace__axis-input--ymax",children:[m.jsx("span",{children:"Y max (ms)"}),m.jsx("input",{type:"number",min:Dr,step:"0.1",value:P,onChange:M=>L(M.target.value),onBlur:()=>{const M=Qo(P);if(M===null){L(`${js.toFixed(2)}`);return}const I=Math.max(Dr,M);L(I.toFixed(2))},disabled:y})]}),m.jsx("button",{type:"button",role:"switch","aria-checked":y,className:`timing-trace__mode-toggle ${y?"is-auto":"is-fixed"}`,onClick:T,title:y?"Switch to Fixed Y":"Switch to Auto Y",children:m.jsx("span",{className:"timing-trace__mode-toggle-label",children:y?"Auto":"Fixed"})})]})]}),m.jsx("canvas",{ref:d,className:"timing-trace__canvas"})]})}function $e(e){return e.split(":")[0]??e}function bl(e){const[t,...n]=e.split(":");return{topic:t??"",endpointToken:n.join(":")}}function H_(e){const{endpointToken:t}=bl(e);return t.length>0?t:null}function W_(e){const{topic:t,endpointToken:n}=bl(e);return{topic:t.length>0?t:null,endpointId:n.length>0?n:null}}function Sn(e){return typeof e=="object"&&e!==null}function V_(e){if("leaky"in e||"max_queue"in e)return"input";if("num_buffers"in e||"buf_size"in e||"force_tcp"in e||"host"in e||"port"in e)return"output";const r=typeof e.name=="string"?e.name.toUpperCase():"",s=typeof e.address=="string"?e.address.toUpperCase():"";return r.includes("INPUT")||s.includes("/INPUT")?"input":r.includes("OUTPUT")||s.includes("/OUTPUT")?"output":"unknown"}function G_(e){const t=typeof e.metadata_type=="string"?e.metadata_type:typeof e.__type__=="string"?e.__type__:typeof e.type=="string"?e.type:null;if(typeof t=="string"){if(t==="InputRelayMetadata"||t.endsWith(".InputRelayMetadata"))return"InputRelayMetadata";if(t==="OutputRelayMetadata"||t.endsWith(".OutputRelayMetadata"))return"OutputRelayMetadata";if(t==="RelayMetadata"||t.endsWith(".RelayMetadata"))return"RelayMetadata"}const n="leaky"in e||"max_queue"in e,r="num_buffers"in e||"buf_size"in e||"force_tcp"in e||"host"in e||"port"in e;return n&&!r?"InputRelayMetadata":r&&!n?"OutputRelayMetadata":n||r?"RelayMetadata":null}function ga(e,t=null){if(!e)return[];const n=[];for(const[r,s]of Object.entries(e)){if(!Sn(s)||typeof s.address!="string")continue;const o=t==="relay";n.push({name:r,address:s.address,direction:V_(s),msgType:typeof s.msg_type=="string"?s.msg_type:null,collectionKind:t,relayMetadataType:o?G_(s):null,relayGroup:o&&typeof s.relay_group=="string"?s.relay_group:null,relayInputTopic:o&&typeof s.relay_input_topic=="string"?s.relay_input_topic:null,relayOutputTopic:o&&typeof s.relay_output_topic=="string"?s.relay_output_topic:null})}return n.sort((r,s)=>r.address.localeCompare(s.address)),n}function Hc(e){const t=new Map;for(const s of Object.values(e.sessions)){const o=Sn(s.metadata)?s.metadata:null,i=o&&Sn(o.components)?o.components:null;if(i)for(const[l,a]of Object.entries(i))!Sn(a)||t.has(l)||t.set(l,a)}const n=new Map,r=new Map;for(const[s,o]of t.entries()){const i=typeof o.name=="string"?o.name:s,l=typeof o.component_type=="string"?o.component_type:"Component",a=ga(Sn(o.topics)?o.topics:null,"topic"),u=ga(Sn(o.relays)?o.relays:null,"relay"),c=Array.isArray(o.children)?o.children.filter(_=>typeof _=="string"):[];if(c.length>0||a.length>0||u.length>0){const _=new Map;for(const x of a)_.set(x.address,x);for(const x of u)_.set(x.address,x);r.set(s,{address:s,name:i,componentType:l,streams:Array.from(_.values()).sort((x,N)=>x.address.localeCompare(N.address)),children:c})}const d=Sn(o.streams)?o.streams:null;if(!d)continue;const h=(Array.isArray(o.tasks)?o.tasks:[]).filter(Sn).map(_=>{if(typeof _.name!="string")return null;const x=Array.isArray(_.publishes)?_.publishes.filter(N=>typeof N=="string"):[];return{name:_.name,subscribes:typeof _.subscribes=="string"?_.subscribes:null,publishes:x}}).filter(_=>_!==null).sort((_,x)=>_.name.localeCompare(x.name));n.set(s,{address:s,name:i,componentType:l,streams:ga(d),tasks:h})}return{units:n,collections:r}}function Zo(e,t,n){t&&(e.set(t,n),e.set($e(t),n))}function Pl(e){const t=new Map,n=new Map;for(const r of e.values())for(const s of r.streams)s.collectionKind==="relay"&&(Zo(t,s.relayInputTopic,s.address),Zo(t,s.relayOutputTopic,s.address),Zo(n,s.relayInputTopic,r.address),Zo(n,s.relayOutputTopic,r.address));return{endpointByInternalTopic:t,collectionByInternalTopic:n}}function Y_(e,t){const n=new Map;for(const s of e)n.set(s,0);const r=Math.max(1,e.length);for(let s=0;sa&&(n.set(i.to,u),o=!0)}if(!o)break}return n}function Iu(e,t,n){if(n){const o=t.get(n);return o?o.children.filter(i=>e.has(i)||t.has(i)):[]}const r=new Set;for(const o of t.values())for(const i of o.children)r.add(i);const s=[...Array.from(t.keys()),...Array.from(e.keys())].filter(o=>!r.has(o));return s.length>0?s:Array.from(e.keys())}function Al(e){const t=new Map;for(const[n,r]of e.entries())for(const s of r.children)t.has(s)||t.set(s,n);return t}function K_(e,t){if(!t||!e.has(t))return[];const n=Al(e),r=[],s=new Set;let o=t;for(;o&&!s.has(o);)s.add(o),r.push(o),o=n.get(o);return r.reverse()}function X_(e,t,n){const r=n.get(e);return r?r.children.some(s=>t.has(s)||n.has(s)):!1}function bu(e,t,n){if(e===t)return!0;const r=new Set;let s=e;for(;s&&!r.has(s);){r.add(s);const o=n.get(s);if(!o)return!1;if(o===t)return!0;s=o}return!1}function Q_(e,t,n,r){const s=Al(n),o=Pl(n),i=new Map,l=(u,c)=>{i.set(u,c),i.set($e(u),c)};for(const u of t.values())for(const c of u.streams)l(c.address,u.address);for(const u of n.values())for(const c of u.streams)l(c.address,u.address);for(const[u,c]of o.collectionByInternalTopic.entries())i.set(u,c);const a=new Set;for(const[u,c]of Object.entries(e.graph)){a.add(u);for(const d of c)a.add(d)}for(const u of a){const c=i.get(u);if(!c||!bu(c,r,s))return!0}return!1}const go=2,Z_=.5,q_=30,J_=new Set(["publish_delta_ns"]),e1=new Set(["lease_time_ns","user_span_ns"]);function Jn(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function t1(e){return`${e.toFixed(1)} Hz`}function n1(e){return!Number.isFinite(e)||e<=0?"":Math.abs(e-Math.round(e))<1e-6?`${Math.round(e)}s`:`${e.toFixed(1)}s`}function r1(e,t,n){return Math.min(n,Math.max(t,e))}function Pu(e){return!Number.isFinite(e)||e<=0?go:r1(e,Z_,q_)}function s1(e){if(!Number.isFinite(e)||e<=0)return go;const t=Math.max(go,Math.round(10/e));return Pu(t)}function o1(e,t=48){return e.length<=t?e:`${e.slice(0,t-1)}…`}function i1(e,t,n){return n!==null&&n>0&&t/n>.5?"backpressure":e>0?"active":"idle"}function If(e){return typeof e=="object"&&e!==null}function ls(e,t){return t.get(e)??t.get($e(e))??e}function Ym(e,t){const{topic:n,endpointToken:r}=bl(e);return n.length===0||r.length===0?e:`${ls(n,t)}:${r}`}function l1(e,t){if(!e)return[];const n=[];for(const[r,s]of Object.entries(e.data.batches)){if(!If(s))continue;const o=s.samples;if(Array.isArray(o))for(const i of o){if(!If(i))continue;const l=i.endpoint_id,a=i.topic,u=i.metric,c=i.value,d=i.timestamp,f=i.sample_seq;typeof l!="string"||typeof a!="string"||typeof u!="string"||typeof c!="number"||!Number.isFinite(c)||n.push({rowId:`${r}:${l}`,processId:r,endpointId:l,topic:ls(a,t),timestamp:typeof d=="number"&&Number.isFinite(d)?d:e.data.timestamp,metric:u,value:c,sampleSeq:typeof f=="number"&&Number.isFinite(f)?Math.trunc(f):null,channelKind:typeof i.channel_kind=="string"?i.channel_kind:null})}}return n}function a1(e,t,n,r,s){const o=ls(t.topic,s);return{id:`${e.process_id}:${t.endpoint_id}`,endpointId:t.endpoint_id,displayEndpointId:Ym(t.endpoint_id,s),topic:o,processId:e.process_id,pid:e.pid,host:e.host,messagesWindow:Jn(t.messages_received_window),channelKindLast:typeof t.channel_kind_last=="string"?t.channel_kind_last:"unknown",unitAddress:n.get(t.endpoint_id)??r.get(o)??null}}function Au(e,t,n){const r=ls(e,n),s=new Set([r]),o=new Set([e,r]);for(const i of o){const l=t==null?void 0:t.graph[i];if(Array.isArray(l))for(const a of l)typeof a=="string"&&s.add(ls(a,n))}return s}function bf(e,t){if(t.has(e))return!0;for(const n of t)if(e.startsWith(`${n}:`))return!0;return!1}function u1(e,t,n,r){const s=Au(e,n,r);return t.filter(o=>s.has(o.topic)).sort((o,i)=>{const l=o.topic.localeCompare(i.topic);if(l!==0)return l;const a=o.processId.localeCompare(i.processId);return a!==0?a:o.endpointId.localeCompare(i.endpointId)})}function c1(e,t,n,r,s,o,i){const l=`${e.process_id}:${t.endpoint_id}`,a=t.num_buffers,u=typeof a=="number"&&Number.isFinite(a)?Math.max(0,Math.trunc(a)):null,c=ls(t.topic,i);return{id:l,endpointId:t.endpoint_id,displayEndpointId:Ym(t.endpoint_id,i),topic:c,processId:e.process_id,pid:e.pid,host:e.host,windowSeconds:Jn(e.window_seconds),publishRateHzWindow:Jn(t.publish_rate_hz_window),messagesPublishedWindow:Jn(t.messages_published_window),inflightCurrent:Jn(t.inflight_messages_current),numBuffers:u,activityTone:i1(Jn(t.messages_published_window),Jn(t.inflight_messages_current),u),contributors:u1(c,n,r,i),unitAddress:s.get(t.endpoint_id)??o.get(c)??null}}function d1({graphSnapshot:e,profilingSnapshot:t,latestTraceEvent:n,setProfilingTraceControl:r,focusPublisherEndpointId:s=null,focusPublisherTopic:o=null,focusSubscriberEndpointId:i=null,focusActionId:l=0,hideFilters:a=!1,defaultTraceMetrics:u=["publish_delta_ns","lease_time_ns","user_span_ns"],traceDockHost:c=null,onTraceDockStateChange:d,traceCloseSignal:f=0,onPublisherSelect:h,onSubscriberSelect:_,darkMode:x=!1}){const[N,p]=E.useState(""),[g,y]=E.useState([]),[w,P]=E.useState([]),[L,O]=E.useState({}),[A,j]=E.useState({}),[z,U]=E.useState({}),[Z,D]=E.useState({}),[v,k]=E.useState({}),T=E.useRef(f),M=E.useRef(-1),I=E.useRef({}),S=E.useMemo(()=>t?Object.values(t):[],[t]),b=E.useMemo(()=>e?Hc(e):null,[e]),F=E.useMemo(()=>b?Pl(b.collections).endpointByInternalTopic:new Map,[b]),R=E.useMemo(()=>{const $=new Map;if(!b)return $;const G=(Y,se)=>{const le=H_(se);le&&!$.has(le)&&$.set(le,Y)};for(const Y of b.units.values())for(const se of Y.streams)G(Y.address,se.address);for(const Y of b.collections.values())for(const se of Y.streams)G(Y.address,se.address);return $},[b]),X=E.useMemo(()=>{const $=new Map;if(!b)return $;const G=(Y,se)=>{$.set(se,Y),$.set($e(se),Y)};for(const Y of b.units.values())for(const se of Y.streams)G(Y.address,se.address);for(const Y of b.collections.values())for(const se of Y.streams)G(Y.address,se.address);return $},[b]),Q=E.useMemo(()=>{const $=[];for(const Y of S)for(const se of Object.values(Y.subscribers))$.push(a1(Y,se,R,X,F));const G=[];for(const Y of S)for(const se of Object.values(Y.publishers))G.push(c1(Y,se,$,e,R,X,F));return G.sort((Y,se)=>{const le=Y.topic.localeCompare(se.topic);if(le!==0)return le;const we=Y.processId.localeCompare(se.processId);return we!==0?we:Y.endpointId.localeCompare(se.endpointId)})},[R,X,e,S,F]),re=E.useMemo(()=>{const $=N.trim().toLowerCase();return Q.filter(G=>$.length===0?!0:G.topic.toLowerCase().includes($)||G.endpointId.toLowerCase().includes($)||G.processId.toLowerCase().includes($))},[Q,N]),J=E.useMemo(()=>new Map(Q.map($=>[$.id,$])),[Q]);E.useEffect(()=>{if(l!==M.current){if(s){const $=Q.filter(G=>G.endpointId===s?!0:o?G.topic===o:!1).map(G=>G.id);if($.length===0)return;M.current=l,p(""),y($),k({}),window.requestAnimationFrame(()=>{var G;(G=I.current[$[0]])==null||G.scrollIntoView({block:"nearest",behavior:"smooth"})});return}if(i){const $=Q.filter(G=>G.contributors.some(Y=>Y.endpointId===i)).map(G=>G.id);if($.length===0)return;M.current=l,p(""),y($),k(G=>{const Y={...G};for(const se of $)Y[se]=i;return Y}),window.requestAnimationFrame(()=>{var G;(G=I.current[$[0]])==null||G.scrollIntoView({block:"nearest",behavior:"smooth"})});return}}},[s,o,i,l,Q]),E.useEffect(()=>{if(!n||w.length===0)return;const $=l1(n,F);if($.length===0)return;const G=new Set(w),Y=w.map(le=>J.get(le)).filter(le=>le!==void 0).map(le=>({row:le,topicScope:Au(le.topic,e,F)})),se=new Map(Y.map(le=>[le.row.id,le.topicScope]));O(le=>{let we=!1;const Ee={...le},be={};for(const ce of $){const he=new Set,xe=J.get(ce.rowId),ke=se.get(ce.rowId);if(xe&&G.has(ce.rowId)&&ke&&bf(ce.topic,ke)&&J_.has(ce.metric)&&he.add(ce.rowId),e1.has(ce.metric))for(const Fe of Y)bf(ce.topic,Fe.topicScope)&&he.add(Fe.row.id);for(const Fe of he){const ye=be[Fe];ye?ye.push(ce):be[Fe]=[ce]}}for(const[ce,he]of Object.entries(be))he.length!==0&&(Ee[ce]=he,we=!0);return we?Ee:le})},[w,e,n,F,J]);const fe=async($,G)=>{if(!A[$.id]){j(Y=>({...Y,[$.id]:!0})),U(Y=>({...Y,[$.id]:null})),G?(O(Y=>({...Y,[$.id]:[]})),D(Y=>Y[$.id]!==void 0?Y:{...Y,[$.id]:s1($.publishRateHzWindow)}),P([$.id])):P(Y=>Y.includes($.id)?Y.filter(se=>se!==$.id):Y);try{if(G){const Y=w.find(se=>se!==$.id);if(Y){const se=J.get(Y);se&&await r({process_id:se.processId,enabled:!1,publisher_endpoint_id:null,publisher_topic:null,subscriber_topic:null,metrics:null,sample_mod:1,ttl_seconds:null,timeout:2})}}await r({process_id:$.processId,enabled:G,publisher_endpoint_id:G?$.endpointId:null,publisher_topic:null,subscriber_topic:G?$.topic:null,metrics:G?u:null,sample_mod:1,ttl_seconds:null,timeout:2})}catch(Y){const se=Y instanceof Error?Y.message:"Trace control request failed.";U(le=>({...le,[$.id]:se})),P(le=>G?le.filter(we=>we!==$.id):le.includes($.id)?le:[...le,$.id])}finally{j(Y=>({...Y,[$.id]:!1}))}}},V=$=>{const G=!g.includes($.id);G&&(h==null||h({unitAddress:$.unitAddress,endpointId:$.endpointId,topic:$.topic})),y(Y=>Y.includes($.id)?Y.filter(se=>se!==$.id):[...Y,$.id]),G||k(Y=>({...Y,[$.id]:null})),!G&&w.includes($.id)&&fe($,!1)},me=($,G)=>{fe($,G)},K=a,C=w[0]??null,B=C?J.get(C)??null:null,te=C?L[C]??[]:[],q=C?!!A[C]:!1,ae=C?z[C]??null:null,pe=Pu(C?Z[C]??go:go),oe=B?Array.from(Au(B.topic,e,F)):[],ee=te.filter($=>$.metric==="lease_time_ns"||$.metric==="user_span_ns").map($=>$.endpointId),ge=wf([...(B==null?void 0:B.contributors.map($=>$.endpointId))??[],...ee]),de=C?v[C]??null:null;E.useEffect(()=>{if(f===T.current)return;T.current=f;const $=w[0];if(!$)return;const G=J.get($);if(!G){P([]);return}P([]),r({process_id:G.processId,enabled:!1,publisher_endpoint_id:null,publisher_topic:null,subscriber_topic:null,metrics:null,sample_mod:1,ttl_seconds:null,timeout:2})},[w,J,r,f]),E.useEffect(()=>{if(d){if(!B){d(null);return}d({active:!0,topic:B.topic,endpointId:B.endpointId,status:q?"applying":"capturing"})}},[q,B,d]);const H=c&&B?Wm.createPortal(m.jsxs("div",{className:"trace-dock-trace",children:[te.length===0?m.jsx("p",{className:"muted",children:"Waiting for trace samples on this publisher endpoint."}):m.jsx(U_,{samples:te,publisherProcessId:B.processId,publisherEndpointId:B.endpointId,nominalPublishRateHz:B.publishRateHzWindow,topic:B.topic,topicScope:oe,leaseColorMap:ge,selectedSubscriberEndpointId:de,windowSeconds:pe,darkMode:x,onWindowSecondsChange:$=>D(G=>({...G,[B.id]:Pu($)}))}),ae?m.jsx("p",{className:"patch-status err",children:ae}):null]}),c):null;return m.jsxs(el,{children:[Q.length===0?m.jsx("div",{className:"panel-section",children:m.jsx("p",{className:"muted",children:"No publishers snapshot entries available."})}):m.jsxs(m.Fragment,{children:[K?null:m.jsx("div",{className:"settings-search",children:m.jsx("input",{type:"search",placeholder:"Search topic, endpoint, or process",value:N,onChange:$=>p($.target.value)})}),re.length===0?m.jsx("div",{className:"panel-section",children:m.jsx("p",{className:"muted",children:"No publishers match the current filter."})}):m.jsx("div",{className:"publisher-list",children:re.map($=>{const G=g.includes($.id),Y=w.includes($.id),se=!!A[$.id],le=n1($.windowSeconds),we=wf($.contributors.map(ce=>ce.endpointId)),Ee=v[$.id]??null,be=$.contributors.some(ce=>ce.endpointId===Ee)?Ee:null;return m.jsxs("article",{ref:ce=>{I.current[$.id]=ce},className:`publisher-row activity-${$.activityTone}`,children:[m.jsxs("button",{type:"button",className:"publisher-row__toggle",onClick:()=>V($),"aria-expanded":G,children:[m.jsxs("div",{className:"publisher-row__top",children:[m.jsx("div",{className:"publisher-row__identity",children:m.jsx("div",{className:"publisher-row__identity-text",children:m.jsx("p",{className:"mono publisher-topic",title:$.topic,children:$.topic})})}),m.jsx("span",{className:"publisher-caret",children:G?"▾":"▸"})]}),m.jsxs("div",{className:"publisher-row__metrics",children:[m.jsxs("div",{children:[m.jsx("span",{children:"Rate"}),m.jsx("strong",{children:t1($.publishRateHzWindow)})]}),m.jsxs("div",{children:[m.jsx("span",{children:le?`Msgs (${le})`:"Msgs"}),m.jsx("strong",{children:$.messagesPublishedWindow})]}),m.jsxs("div",{children:[m.jsx("span",{children:"Inflight"}),m.jsx("strong",{children:$.numBuffers===null?`${$.inflightCurrent}`:`${$.inflightCurrent} / ${$.numBuffers}`})]}),m.jsxs("div",{children:[m.jsx("span",{children:"Subscribers"}),m.jsx("strong",{children:$.contributors.length})]})]})]}),G?m.jsxs("div",{className:"publisher-row__details",children:[m.jsxs("div",{className:"publisher-kpis",children:[m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Host"}),m.jsx("strong",{children:$.host})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"PID"}),m.jsx("strong",{children:$.pid})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Process"}),m.jsx("strong",{className:"mono",title:$.processId,children:$.processId.slice(0,8)})]})]}),m.jsx("div",{className:"publisher-detail-line",children:m.jsxs("div",{className:"publisher-endpoint",children:[m.jsx("span",{children:"Endpoint"}),m.jsx("code",{className:"mono",title:$.displayEndpointId,children:$.displayEndpointId})]})}),m.jsxs("div",{className:"panel-section",children:[m.jsxs("button",{type:"button",className:`publisher-trace-button ${Y?"is-stop":"is-start"}`,onClick:()=>me($,!Y),disabled:se,"aria-pressed":Y,children:[m.jsx("span",{"aria-hidden":"true",className:"publisher-trace-button__icon",children:Y?"■":"▶"}),m.jsx("span",{children:se?"Applying...":Y?"Stop Profiling Trace":"Start Profiling Trace"})]}),m.jsx("div",{className:"subscriber-section-header",children:m.jsx("h3",{children:"Subscribers"})}),$.contributors.length===0?m.jsx("p",{className:"muted",children:"No subscriber profiling data is available for this topic."}):m.jsx("div",{className:"subscriber-list",children:$.contributors.map(ce=>{const he=be===ce.endpointId;return m.jsxs("article",{className:`subscriber-item ${he?"is-expanded":""}`,children:[m.jsxs("button",{type:"button",className:"subscriber-item__summary",onClick:()=>{const xe=he?null:ce.endpointId;xe&&(_==null||_({unitAddress:ce.unitAddress,endpointId:ce.endpointId,topic:ce.topic})),k(ke=>({...ke,[$.id]:xe}))},children:[m.jsx("div",{className:"subscriber-item__identity",children:m.jsx("p",{className:"mono subscriber-topic-short",title:ce.topic,children:m.jsxs("span",{className:"subscriber-topic-with-color",children:[m.jsx("i",{className:"subscriber-trace-dot",style:{background:Qs(ce.endpointId,we)}}),m.jsx("span",{className:"subscriber-topic-label",children:o1(ce.topic,72)})]})})}),m.jsxs("div",{className:"subscriber-item__metrics",children:[m.jsxs("span",{children:[m.jsx("em",{children:le?`Msgs (${le})`:"Msgs"}),m.jsx("strong",{children:ce.messagesWindow})]}),m.jsxs("span",{children:[m.jsx("em",{children:"Channel"}),m.jsx("strong",{children:ce.channelKindLast})]})]})]}),he?m.jsx("div",{className:"subscriber-item__detail",children:m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"publisher-kpis",children:[m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Host"}),m.jsx("strong",{children:ce.host})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"PID"}),m.jsx("strong",{children:ce.pid})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Process"}),m.jsx("strong",{className:"mono",title:ce.processId,children:ce.processId.slice(0,8)})]})]}),m.jsx("div",{className:"publisher-detail-line",children:m.jsxs("div",{className:"publisher-endpoint",children:[m.jsx("span",{children:"Endpoint"}),m.jsx("code",{className:"mono",title:ce.displayEndpointId,children:ce.displayEndpointId})]})})]})}):null]},ce.id)})})]})]}):null]},$.id)})})]}),H]})}function f1(e){const t=e.field_type.toLowerCase();return Array.isArray(e.choices)&&e.choices.length>0?"choice":t.includes("bool")?"boolean":t.includes("int")||t.includes("float")||t.includes("double")||t.includes("number")?"number":t.includes("str")||t.includes("string")?"text":"json"}function p1(e){return typeof e=="boolean"?"boolean":typeof e=="number"?"number":typeof e=="string"?"text":"json"}function Pf(e,t){if(!e||typeof e!="object")return;const n=t.split(".").filter(s=>s.length>0);let r=e;for(const s of n){if(!r||typeof r!="object"||!(s in r))return;r=r[s]}return r}function Km(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Xm(e,t=""){if(!e||typeof e!="object"||Array.isArray(e))return t.length>0?[t]:[];const n=Object.entries(e);if(n.length===0)return t.length>0?[t]:[];const r=[];for(const[s,o]of n){const i=t.length>0?`${t}.${s}`:s,l=Xm(o,i);l.length===0?r.push(i):r.push(...l)}return r}function h1(e){if(e.mode==="boolean")return!!e.currentValue;if(e.mode==="choice"){const t=e.choices??[],n=Math.max(0,t.findIndex(r=>JSON.stringify(r)===JSON.stringify(e.currentValue)));return String(n)}return e.mode==="number"?typeof e.currentValue=="number"?String(e.currentValue):"":e.mode==="text"?typeof e.currentValue=="string"?e.currentValue:"":Km(e.currentValue)}function m1(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>e[s]===t[s])}function g1({settings:e,patchSettingField:t,focusComponentAddress:n=null,focusActionId:r=0,onComponentSelect:s}){const o=E.useMemo(()=>e?Object.keys(e).sort():[],[e]),i=E.useMemo(()=>o.join("|"),[o]),l=E.useMemo(()=>new Set(o),[i]),[a,u]=E.useState(null),[c,d]=E.useState(""),[f,h]=E.useState({}),[_,x]=E.useState({}),[N,p]=E.useState({}),[g,y]=E.useState({}),w=E.useRef({}),P=E.useRef({}),L=E.useRef(null);E.useEffect(()=>{a&&!o.includes(a)&&u(null)},[o,a]),E.useEffect(()=>{!n||!l.has(n)||(d(""),u(n),window.requestAnimationFrame(()=>{var v;(v=w.current[n])==null||v.scrollIntoView({block:"nearest",behavior:"smooth"})}))},[l,r,n]);const O=a?e==null?void 0:e[a]:null,A=E.useMemo(()=>(O==null?void 0:O.structured_value)??(O==null?void 0:O.repr_value),[O]),j=E.useMemo(()=>{var M;if(!O)return[];const v=((M=O.settings_schema)==null?void 0:M.fields)??[];if(v.length>0)return v.map(I=>{const S=Pf(A,I.name);return{path:I.name,mode:f1(I),currentValue:S??I.default??null,description:I.description,bounds:I.bounds,choices:I.choices,isInteger:I.field_type.toLowerCase().includes("int")}});const k=Xm(A);return(k.length>0?k:["value"]).map(I=>{const S=I==="value"?A:Pf(A,I);return{path:I,mode:p1(S),currentValue:S,description:null,bounds:null,choices:null,isInteger:Number.isInteger(S)}})},[O,A]),z=!!(O!=null&&O.patchable),U=E.useMemo(()=>{const v=c.trim().toLowerCase();return v?o.filter(k=>{const T=e==null?void 0:e[k],M=typeof(T==null?void 0:T.component_name)=="string"?T.component_name:"",I=typeof(T==null?void 0:T.component_type)=="string"?T.component_type:"";return k.toLowerCase().includes(v)||M.toLowerCase().includes(v)||I.toLowerCase().includes(v)}):o},[o,c,e]);E.useEffect(()=>{const v={};for(const T of j)v[T.path]=h1(T);const k=L.current!==a;h(T=>{if(k)return v;const M={};for(const[I,S]of Object.entries(v)){const b=T[I],F=P.current[I];M[I]=b===void 0||b===F?S:b}return m1(T,M)?T:M}),k&&(x({}),p({}),y({})),P.current=v,L.current=a},[j,a]);const Z=v=>{const k=f[v.path];if(v.mode==="boolean")return!!k;if(v.mode==="choice"){const T=Number.parseInt(String(k),10),M=v.choices??[];if(!Number.isInteger(T)||T<0||T>=M.length)throw new Error("A valid choice must be selected.");return M[T]}if(v.mode==="number"){const T=Number.parseFloat(String(k));if(!Number.isFinite(T))throw new Error("Value must be a valid number.");return v.isInteger?Math.trunc(T):T}if(v.mode==="text")return String(k??"");try{return JSON.parse(String(k??""))}catch{throw new Error("Value must be valid JSON.")}},D=async v=>{if(!a||!z)return;let k;try{k=Z(v)}catch(T){p(M=>({...M,[v.path]:T instanceof Error?T.message:"Invalid field value."})),y(M=>({...M,[v.path]:null}));return}x(T=>({...T,[v.path]:!0})),p(T=>({...T,[v.path]:null})),y(T=>({...T,[v.path]:null}));try{const T=await t(a,v.path,k);y(M=>({...M,[v.path]:`Applied ${T.field_path}`}))}catch(T){p(M=>({...M,[v.path]:T instanceof Error?T.message:"Patch request failed."}))}finally{x(T=>({...T,[v.path]:!1}))}};return m.jsx(el,{children:o.length===0?m.jsx("div",{className:"panel-section",children:m.jsx("p",{className:"muted",children:"No settings snapshot entries available."})}):m.jsxs("div",{className:"settings-component-list",children:[m.jsx("div",{className:"settings-search",children:m.jsx("input",{type:"search",placeholder:"Search component, type, or address",value:c,onChange:v=>d(v.target.value)})}),U.map(v=>{const k=(e==null?void 0:e[v])??null,T=a===v,M=!!(k!=null&&k.patchable),I=typeof(k==null?void 0:k.component_name)=="string"&&k.component_name.length>0?k.component_name:v.split("/")[v.split("/").length-1]??v;return m.jsxs("article",{ref:S=>{w.current[v]=S},className:`settings-component-row ${T?"is-expanded":""}`,children:[m.jsxs("button",{type:"button",className:"settings-component-row__toggle","aria-expanded":T,onClick:()=>u(S=>{const b=S===v?null:v;return s==null||s(b),b}),children:[m.jsxs("div",{className:"settings-component-row__identity",children:[m.jsxs("div",{className:"settings-component-row__heading",children:[m.jsx("p",{className:"mono settings-component-title",title:I,children:I}),k!=null&&k.component_type?m.jsx("span",{className:"settings-type",title:k.component_type,children:k.component_type}):null]}),m.jsx("p",{className:"mono settings-component-address",title:v,children:v})]}),m.jsxs("div",{className:"settings-component-row__meta",children:[m.jsx("span",{className:`settings-access ${M?"is-patchable":"is-readonly"}`,children:M?"patchable":"read only"}),m.jsx("span",{className:"publisher-caret",children:T?"▾":"▸"})]})]}),T?m.jsx("section",{className:"settings-detail",children:j.length===0?m.jsx("p",{className:"muted",children:"No fields available for this component."}):m.jsx("div",{className:"settings-fields",children:j.map(S=>{var X,Q;const b=_[S.path]===!0,F=!z,R=f[S.path];return m.jsxs("div",{className:`settings-field-row ${F?"is-disabled":""}`,children:[m.jsxs("div",{className:"settings-field-row__meta",children:[m.jsx("label",{className:"mono",children:S.path}),S.description?m.jsx("p",{className:"muted",children:S.description}):null,S.bounds?m.jsxs("p",{className:"muted",children:["Bounds: [",S.bounds[0]??"-inf",", ",S.bounds[1]??"+inf","]"]}):null]}),m.jsxs("div",{className:`settings-field-row__control ${S.mode==="boolean"?"is-boolean":""}`,children:[S.mode==="boolean"?m.jsxs("label",{className:"patch-checkbox",children:[m.jsx("input",{type:"checkbox",checked:!!R,onChange:re=>h(J=>({...J,[S.path]:re.target.checked})),disabled:F||b}),m.jsx("span",{children:"Enabled"})]}):null,S.mode==="choice"?m.jsx("select",{value:String(R??"0"),onChange:re=>h(J=>({...J,[S.path]:re.target.value})),disabled:F||b,children:(S.choices??[]).map((re,J)=>m.jsx("option",{value:String(J),children:Km(re)},`${S.path}-${J}`))}):null,S.mode==="number"?m.jsx("input",{type:"number",value:String(R??""),min:((X=S.bounds)==null?void 0:X[0])??void 0,max:((Q=S.bounds)==null?void 0:Q[1])??void 0,step:"any",onChange:re=>h(J=>({...J,[S.path]:re.target.value})),disabled:F||b}):null,S.mode==="text"?m.jsx("input",{type:"text",value:String(R??""),onChange:re=>h(J=>({...J,[S.path]:re.target.value})),disabled:F||b}):null,S.mode==="json"?m.jsx("textarea",{value:String(R??""),rows:4,spellCheck:!1,className:"mono",onChange:re=>h(J=>({...J,[S.path]:re.target.value})),disabled:F||b}):null,m.jsx("button",{type:"button",onClick:()=>{D(S)},disabled:F||b,children:b?"Applying...":"Apply"})]}),g[S.path]?m.jsx("p",{className:"patch-status ok",children:g[S.path]}):null,N[S.path]?m.jsx("p",{className:"patch-status err",children:N[S.path]}):null]},S.path)})})}):null]},v)})]})})}function et(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?N1:E1;Jm.useSyncExternalStore=as.useSyncExternalStore!==void 0?as.useSyncExternalStore:T1;qm.exports=Jm;var k1=qm.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 Ml=E,C1=k1;function I1(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var b1=typeof Object.is=="function"?Object.is:I1,P1=C1.useSyncExternalStore,A1=Ml.useRef,M1=Ml.useEffect,R1=Ml.useMemo,O1=Ml.useDebugValue;Zm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=A1(null);if(o.current===null){var i={hasValue:!1,value:null};o.current=i}else i=o.current;o=R1(function(){function a(h){if(!u){if(u=!0,c=h,h=r(h),s!==void 0&&i.hasValue){var _=i.value;if(s(_,h))return d=_}return d=h}if(_=d,b1(c,h))return _;var x=r(h);return s!==void 0&&s(_,x)?(c=h,_):(c=h,d=x)}var u=!1,c,d,f=n===void 0?null:n;return[function(){return a(t())},f===null?void 0:function(){return a(f())}]},[t,n,r,s]);var l=P1(e,o[0],o[1]);return M1(function(){i.hasValue=!0,i.value=l},[l]),O1(l),l};Qm.exports=Zm;var L1=Qm.exports;const $1=Ap(L1),B1={},Af=e=>{let t;const n=new Set,r=(c,d)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(_=>_(t,h))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{(B1?"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()}},u=t=e(r,s,a);return a},j1=e=>e?Af(e):Af,{useDebugValue:F1}=W,{useSyncExternalStoreWithSelector:z1}=$1,D1=e=>e;function eg(e,t=D1,n){const r=z1(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return F1(r),r}const Mf=(e,t)=>{const n=j1(e),r=(s,o=t)=>eg(n,s,o);return Object.assign(r,n),r},U1=(e,t)=>e?Mf(e,t):Mf;function Qe(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,s]of e)if(!Object.is(s,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}var H1={value:()=>{}};function Rl(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Ti.prototype=Rl.prototype={constructor:Ti,on:function(e,t){var n=this._,r=W1(e+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(s),r=0,s,o;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Of.hasOwnProperty(t)?{space:Of[t],local:e}:e}function G1(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Mu&&t.documentElement.namespaceURI===Mu?t.createElement(e):t.createElementNS(n,e)}}function Y1(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function tg(e){var t=Ol(e);return(t.local?Y1:G1)(t)}function K1(){}function Wc(e){return e==null?K1:function(){return this.querySelector(e)}}function X1(e){typeof e!="function"&&(e=Wc(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s=y&&(y=g+1);!(P=N[y])&&++y<_;);w._next=P||null}}return i=new Et(i,r),i._enter=l,i._exit=a,i}function mx(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gx(){return new Et(this._exit||this._groups.map(og),this._parents)}function yx(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function vx(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,i=Math.min(s,o),l=new Array(s),a=0;a=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function xx(e){e||(e=wx);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,s=new Array(r),o=0;ot?1:e>=t?0:NaN}function Sx(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ex(){return Array.from(this)}function Nx(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Lx:typeof t=="function"?Bx:$x)(e,t,n??"")):us(this.node(),e)}function us(e,t){return e.style.getPropertyValue(t)||ig(e).getComputedStyle(e,null).getPropertyValue(t)}function Fx(e){return function(){delete this[e]}}function zx(e,t){return function(){this[e]=t}}function Dx(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Ux(e,t){return arguments.length>1?this.each((t==null?Fx:typeof t=="function"?Dx:zx)(e,t)):this.node()[e]}function lg(e){return e.trim().split(/^|\s+/)}function Vc(e){return e.classList||new ag(e)}function ag(e){this._node=e,this._names=lg(e.getAttribute("class")||"")}ag.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ug(e,t){for(var n=Vc(e),r=-1,s=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function gw(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n()=>e;function Ru(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:i,y:l,dx:a,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Ru.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function kw(e){return!e.ctrlKey&&!e.button}function Cw(){return this.parentNode}function Iw(e,t){return t??{x:e.x,y:e.y}}function bw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Pw(){var e=kw,t=Cw,n=Iw,r=bw,s={},o=Rl("start","drag","end"),i=0,l,a,u,c,d=0;function f(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",N).on("touchmove.drag",p,Tw).on("touchend.drag touchcancel.drag",g).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,P){if(!(c||!e.call(this,w,P))){var L=y(this,t.call(this,w,P),w,P,"mouse");L&&(It(w.view).on("mousemove.drag",_,yo).on("mouseup.drag",x,yo),pg(w.view),va(w),u=!1,l=w.clientX,a=w.clientY,L("start",w))}}function _(w){if(Zr(w),!u){var P=w.clientX-l,L=w.clientY-a;u=P*P+L*L>d}s.mouse("drag",w)}function x(w){It(w.view).on("mousemove.drag mouseup.drag",null),hg(w.view,u),Zr(w),s.mouse("end",w)}function N(w,P){if(e.call(this,w,P)){var L=w.changedTouches,O=t.call(this,w,P),A=L.length,j,z;for(j=0;j>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Jo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Jo(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=Mw.exec(e))?new mt(t[1],t[2],t[3],1):(t=Rw.exec(e))?new mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Ow.exec(e))?Jo(t[1],t[2],t[3],t[4]):(t=Lw.exec(e))?Jo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=$w.exec(e))?Df(t[1],t[2]/100,t[3]/100,1):(t=Bw.exec(e))?Df(t[1],t[2]/100,t[3]/100,t[4]):Lf.hasOwnProperty(e)?jf(Lf[e]):e==="transparent"?new mt(NaN,NaN,NaN,0):null}function jf(e){return new mt(e>>16&255,e>>8&255,e&255,1)}function Jo(e,t,n,r){return r<=0&&(e=t=n=NaN),new mt(e,t,n,r)}function zw(e){return e instanceof Ao||(e=xo(e)),e?(e=e.rgb(),new mt(e.r,e.g,e.b,e.opacity)):new mt}function Ou(e,t,n,r){return arguments.length===1?zw(e):new mt(e,t,n,r??1)}function mt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Gc(mt,Ou,mg(Ao,{brighter(e){return e=e==null?ol:Math.pow(ol,e),new mt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vo:Math.pow(vo,e),new mt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new mt(ur(this.r),ur(this.g),ur(this.b),il(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:Ff,formatHex:Ff,formatHex8:Dw,formatRgb:zf,toString:zf}));function Ff(){return`#${or(this.r)}${or(this.g)}${or(this.b)}`}function Dw(){return`#${or(this.r)}${or(this.g)}${or(this.b)}${or((isNaN(this.opacity)?1:this.opacity)*255)}`}function zf(){const e=il(this.opacity);return`${e===1?"rgb(":"rgba("}${ur(this.r)}, ${ur(this.g)}, ${ur(this.b)}${e===1?")":`, ${e})`}`}function il(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ur(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function or(e){return e=ur(e),(e<16?"0":"")+e.toString(16)}function Df(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new zt(e,t,n,r)}function gg(e){if(e instanceof zt)return new zt(e.h,e.s,e.l,e.opacity);if(e instanceof Ao||(e=xo(e)),!e)return new zt;if(e instanceof zt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),i=NaN,l=o-s,a=(o+s)/2;return l?(t===o?i=(n-r)/l+(n0&&a<1?0:i,new zt(i,l,a,e.opacity)}function Uw(e,t,n,r){return arguments.length===1?gg(e):new zt(e,t,n,r??1)}function zt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Gc(zt,Uw,mg(Ao,{brighter(e){return e=e==null?ol:Math.pow(ol,e),new zt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vo:Math.pow(vo,e),new zt(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,s=2*n-r;return new mt(_a(e>=240?e-240:e+120,s,r),_a(e,s,r),_a(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new zt(Uf(this.h),ei(this.s),ei(this.l),il(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=il(this.opacity);return`${e===1?"hsl(":"hsla("}${Uf(this.h)}, ${ei(this.s)*100}%, ${ei(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Uf(e){return e=(e||0)%360,e<0?e+360:e}function ei(e){return Math.max(0,Math.min(1,e||0))}function _a(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 yg=e=>()=>e;function Hw(e,t){return function(n){return e+n*t}}function Ww(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 Vw(e){return(e=+e)==1?vg:function(t,n){return n-t?Ww(t,n,e):yg(isNaN(t)?n:t)}}function vg(e,t){var n=t-e;return n?Hw(e,n):yg(isNaN(e)?t:e)}const Hf=function e(t){var n=Vw(t);function r(s,o){var i=n((s=Ou(s)).r,(o=Ou(o)).r),l=n(s.g,o.g),a=n(s.b,o.b),u=vg(s.opacity,o.opacity);return function(c){return s.r=i(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return r.gamma=e,r}(1);function kn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Lu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,xa=new RegExp(Lu.source,"g");function Gw(e){return function(){return e}}function Yw(e){return function(t){return e(t)+""}}function Kw(e,t){var n=Lu.lastIndex=xa.lastIndex=0,r,s,o,i=-1,l=[],a=[];for(e=e+"",t=t+"";(r=Lu.exec(e))&&(s=xa.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),l[i]?l[i]+=o:l[++i]=o),(r=r[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,a.push({i,x:kn(r,s)})),n=xa.lastIndex;return n180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,r)-2,x:kn(u,c)})):c&&d.push(s(d)+"rotate("+c+r)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,r)-2,x:kn(u,c)}):c&&d.push(s(d)+"skewX("+c+r)}function a(u,c,d,f,h,_){if(u!==d||c!==f){var x=h.push(s(h)+"scale(",null,",",null,")");_.push({i:x-4,x:kn(u,d)},{i:x-2,x:kn(c,f)})}else(d!==1||f!==1)&&h.push(s(h)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=e(u),c=e(c),o(u.translateX,u.translateY,c.translateX,c.translateY,d,f),i(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(h){for(var _=-1,x=f.length,N;++_=0&&e._call.call(void 0,t),e=e._next;--cs}function Gf(){yr=(al=wo.now())+Ll,cs=Fs=0;try{sS()}finally{cs=0,iS(),yr=0}}function oS(){var e=wo.now(),t=e-al;t>wg&&(Ll-=t,al=e)}function iS(){for(var e,t=ll,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:ll=n);zs=e,Bu(r)}function Bu(e){if(!cs){Fs&&(Fs=clearTimeout(Fs));var t=e-yr;t>24?(e<1/0&&(Fs=setTimeout(Gf,e-wo.now()-Ll)),Ts&&(Ts=clearInterval(Ts))):(Ts||(al=wo.now(),Ts=setInterval(oS,wg)),cs=1,Sg(Gf))}}function Yf(e,t,n){var r=new ul;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var lS=Rl("start","end","cancel","interrupt"),aS=[],Ng=0,Kf=1,ju=2,ki=3,Xf=4,Fu=5,Ci=6;function $l(e,t,n,r,s,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;uS(e,n,{name:t,index:r,group:s,on:lS,tween:aS,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ng})}function Kc(e,t){var n=Gt(e,t);if(n.state>Ng)throw new Error("too late; already scheduled");return n}function en(e,t){var n=Gt(e,t);if(n.state>ki)throw new Error("too late; already running");return n}function Gt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function uS(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Eg(o,0,n.time);function o(u){n.state=Kf,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var c,d,f,h;if(n.state!==Kf)return a();for(c in r)if(h=r[c],h.name===n.name){if(h.state===ki)return Yf(i);h.state===Xf?(h.state=Ci,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+cju&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function FS(e,t,n){var r,s,o=jS(t)?Kc:en;return function(){var i=o(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function zS(e,t){var n=this._id;return arguments.length<2?Gt(this.node(),n).on.on(e):this.each(FS(n,e,t))}function DS(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function US(){return this.on("end.remove",DS(this._id))}function HS(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Wc(e));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i()=>e;function hE(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){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:s}})}function cn(e,t,n){this.k=e,this.x=t,this.y=n}cn.prototype={constructor:cn,scale:function(e){return e===1?this:new cn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new cn(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 fn=new cn(1,0,0);cn.prototype;function wa(e){e.stopImmediatePropagation()}function ks(e){e.preventDefault(),e.stopImmediatePropagation()}function mE(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function gE(){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 Qf(){return this.__zoom||fn}function yE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vE(){return navigator.maxTouchPoints||"ontouchstart"in this}function _E(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function Ig(){var e=mE,t=gE,n=_E,r=yE,s=vE,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,a=nS,u=Rl("start","zoom","end"),c,d,f,h=500,_=150,x=0,N=10;function p(v){v.property("__zoom",Qf).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",j).on("dblclick.zoom",z).filter(s).on("touchstart.zoom",U).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",D).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(v,k,T,M){var I=v.selection?v.selection():v;I.property("__zoom",Qf),v!==I?P(v,k,T,M):I.interrupt().each(function(){L(this,arguments).event(M).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},p.scaleBy=function(v,k,T,M){p.scaleTo(v,function(){var I=this.__zoom.k,S=typeof k=="function"?k.apply(this,arguments):k;return I*S},T,M)},p.scaleTo=function(v,k,T,M){p.transform(v,function(){var I=t.apply(this,arguments),S=this.__zoom,b=T==null?w(I):typeof T=="function"?T.apply(this,arguments):T,F=S.invert(b),R=typeof k=="function"?k.apply(this,arguments):k;return n(y(g(S,R),b,F),I,i)},T,M)},p.translateBy=function(v,k,T,M){p.transform(v,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof T=="function"?T.apply(this,arguments):T),t.apply(this,arguments),i)},null,M)},p.translateTo=function(v,k,T,M,I){p.transform(v,function(){var S=t.apply(this,arguments),b=this.__zoom,F=M==null?w(S):typeof M=="function"?M.apply(this,arguments):M;return n(fn.translate(F[0],F[1]).scale(b.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof T=="function"?-T.apply(this,arguments):-T),S,i)},M,I)};function g(v,k){return k=Math.max(o[0],Math.min(o[1],k)),k===v.k?v:new cn(k,v.x,v.y)}function y(v,k,T){var M=k[0]-T[0]*v.k,I=k[1]-T[1]*v.k;return M===v.x&&I===v.y?v:new cn(v.k,M,I)}function w(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function P(v,k,T,M){v.on("start.zoom",function(){L(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(M).end()}).tween("zoom",function(){var I=this,S=arguments,b=L(I,S).event(M),F=t.apply(I,S),R=T==null?w(F):typeof T=="function"?T.apply(I,S):T,X=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Q=I.__zoom,re=typeof k=="function"?k.apply(I,S):k,J=a(Q.invert(R).concat(X/Q.k),re.invert(R).concat(X/re.k));return function(fe){if(fe===1)fe=re;else{var V=J(fe),me=X/V[2];fe=new cn(me,R[0]-V[0]*me,R[1]-V[1]*me)}b.zoom(null,fe)}})}function L(v,k,T){return!T&&v.__zooming||new O(v,k)}function O(v,k){this.that=v,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,k),this.taps=0}O.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,k){return this.mouse&&v!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var k=It(this.that).datum();u.call(v,this.that,new hE(v,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:u}),k)}};function A(v,...k){if(!e.apply(this,arguments))return;var T=L(this,k).event(v),M=this.__zoom,I=Math.max(o[0],Math.min(o[1],M.k*Math.pow(2,r.apply(this,arguments)))),S=jt(v);if(T.wheel)(T.mouse[0][0]!==S[0]||T.mouse[0][1]!==S[1])&&(T.mouse[1]=M.invert(T.mouse[0]=S)),clearTimeout(T.wheel);else{if(M.k===I)return;T.mouse=[S,M.invert(S)],Ii(this),T.start()}ks(v),T.wheel=setTimeout(b,_),T.zoom("mouse",n(y(g(M,I),T.mouse[0],T.mouse[1]),T.extent,i));function b(){T.wheel=null,T.end()}}function j(v,...k){if(f||!e.apply(this,arguments))return;var T=v.currentTarget,M=L(this,k,!0).event(v),I=It(v.view).on("mousemove.zoom",R,!0).on("mouseup.zoom",X,!0),S=jt(v,T),b=v.clientX,F=v.clientY;pg(v.view),wa(v),M.mouse=[S,this.__zoom.invert(S)],Ii(this),M.start();function R(Q){if(ks(Q),!M.moved){var re=Q.clientX-b,J=Q.clientY-F;M.moved=re*re+J*J>x}M.event(Q).zoom("mouse",n(y(M.that.__zoom,M.mouse[0]=jt(Q,T),M.mouse[1]),M.extent,i))}function X(Q){I.on("mousemove.zoom mouseup.zoom",null),hg(Q.view,M.moved),ks(Q),M.event(Q).end()}}function z(v,...k){if(e.apply(this,arguments)){var T=this.__zoom,M=jt(v.changedTouches?v.changedTouches[0]:v,this),I=T.invert(M),S=T.k*(v.shiftKey?.5:2),b=n(y(g(T,S),M,I),t.apply(this,k),i);ks(v),l>0?It(this).transition().duration(l).call(P,b,M,v):It(this).call(p.transform,b,M,v)}}function U(v,...k){if(e.apply(this,arguments)){var T=v.touches,M=T.length,I=L(this,k,v.changedTouches.length===M).event(v),S,b,F,R;for(wa(v),b=0;b"[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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,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.`},bg=vn.error001();function Ie(e,t){const n=E.useContext(Bl);if(n===null)throw new Error(bg);return eg(n,e,t)}const Ye=()=>{const e=E.useContext(Bl);if(e===null)throw new Error(bg);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},wE=e=>e.userSelectionActive?"none":"all";function Qc({position:e,children:t,className:n,style:r,...s}){const o=Ie(wE),i=`${e}`.split("-");return W.createElement("div",{className:et(["react-flow__panel",n,...i]),style:{...r,pointerEvents:o},...s},t)}function SE({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:W.createElement(Qc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},W.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const EE=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:a,className:u,...c})=>{const d=E.useRef(null),[f,h]=E.useState({x:0,y:0,width:0,height:0}),_=et(["react-flow__edge-textwrapper",u]);return E.useEffect(()=>{if(d.current){const x=d.current.getBBox();h({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),typeof n>"u"||!n?null:W.createElement("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:_,visibility:f.width?"visible":"hidden",...c},s&&W.createElement("rect",{width:f.width+2*i[0],x:-i[0],y:-i[1],height:f.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),W.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:d,style:r},n),a)};var NE=E.memo(EE);const Zc=e=>({width:e.offsetWidth,height:e.offsetHeight}),ds=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),qc=(e={x:0,y:0},t)=>({x:ds(e.x,t[0][0],t[1][0]),y:ds(e.y,t[0][1],t[1][1])}),Zf=(e,t,n)=>en?-ds(Math.abs(e-n),1,50)/50:0,Pg=(e,t)=>{const n=Zf(e.x,35,t.width-35)*20,r=Zf(e.y,35,t.height-35)*20;return[n,r]},Ag=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Mg=(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)}),So=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Rg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),qf=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),TE=(e,t)=>Rg(Mg(So(e),So(t))),zu=(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)},kE=e=>Pt(e.width)&&Pt(e.height)&&Pt(e.x)&&Pt(e.y),Pt=e=>!isNaN(e)&&isFinite(e),De=Symbol.for("internals"),Og=["Enter"," ","Escape"],CE=(e,t)=>{},IE=e=>"nativeEvent"in e;function Du(e){var s,o;const t=IE(e)?e.nativeEvent:e,n=((o=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:o[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const Lg=e=>"clientX"in e,Dn=(e,t)=>{var o,i;const n=Lg(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},cl=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Mo=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:f,interactionWidth:h=20})=>W.createElement(W.Fragment,null,W.createElement("path",{id:e,style:c,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:f}),h&&W.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),s&&Pt(n)&&Pt(r)?W.createElement(NE,{x:n,y:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u}):null);Mo.displayName="BaseEdge";function Cs(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function $g({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n{const[N,p,g]=jg({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return W.createElement(Mo,{path:N,labelX:p,labelY:g,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:_,interactionWidth:x})});Jc.displayName="SimpleBezierEdge";const ep={[ie.Left]:{x:-1,y:0},[ie.Right]:{x:1,y:0},[ie.Top]:{x:0,y:-1},[ie.Bottom]:{x:0,y:1}},bE=({source:e,sourcePosition:t=ie.Bottom,target:n})=>t===ie.Left||t===ie.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function PE({source:e,sourcePosition:t=ie.Bottom,target:n,targetPosition:r=ie.Top,center:s,offset:o}){const i=ep[t],l=ep[r],a={x:e.x+i.x*o,y:e.y+i.y*o},u={x:n.x+l.x*o,y:n.y+l.y*o},c=bE({source:a,sourcePosition:t,target:u}),d=c.x!==0?"x":"y",f=c[d];let h=[],_,x;const N={x:0,y:0},p={x:0,y:0},[g,y,w,P]=$g({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[d]*l[d]===-1){_=s.x??g,x=s.y??y;const O=[{x:_,y:a.y},{x:_,y:u.y}],A=[{x:a.x,y:x},{x:u.x,y:x}];i[d]===f?h=d==="x"?O:A:h=d==="x"?A:O}else{const O=[{x:a.x,y:u.y}],A=[{x:u.x,y:a.y}];if(d==="x"?h=i.x===f?A:O:h=i.y===f?O:A,t===r){const D=Math.abs(e[d]-n[d]);if(D<=o){const v=Math.min(o-1,o-D);i[d]===f?N[d]=(a[d]>e[d]?-1:1)*v:p[d]=(u[d]>n[d]?-1:1)*v}}if(t!==r){const D=d==="x"?"y":"x",v=i[d]===l[D],k=a[D]>u[D],T=a[D]=Z?(_=(j.x+z.x)/2,x=h[0].y):(_=h[0].x,x=(j.y+z.y)/2)}return[[e,{x:a.x+N.x,y:a.y+N.y},...h,{x:u.x+p.x,y:u.y+p.y},n],_,x,w,P]}function AE(e,t,n,r){const s=Math.min(tp(e,t)/2,tp(t,n)/2,r),{x:o,y:i}=t;if(e.x===o&&o===n.x||e.y===i&&i===n.y)return`L${o} ${i}`;if(e.y===i){const u=e.x{let y="";return g>0&&g{const[p,g,y]=Uu({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:x==null?void 0:x.borderRadius,offset:x==null?void 0:x.offset});return W.createElement(Mo,{path:p,labelX:g,labelY:y,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:_,interactionWidth:N})});jl.displayName="SmoothStepEdge";const ed=E.memo(e=>{var t;return W.createElement(jl,{...e,pathOptions:E.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});ed.displayName="StepEdge";function ME({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,i,l]=$g({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,i,l]}const td=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:f,interactionWidth:h})=>{const[_,x,N]=ME({sourceX:e,sourceY:t,targetX:n,targetY:r});return W.createElement(Mo,{path:_,labelX:x,labelY:N,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:f,interactionWidth:h})});td.displayName="StraightEdge";function ri(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function np({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case ie.Left:return[t-ri(t-r,o),n];case ie.Right:return[t+ri(r-t,o),n];case ie.Top:return[t,n-ri(n-s,o)];case ie.Bottom:return[t,n+ri(s-n,o)]}}function Fg({sourceX:e,sourceY:t,sourcePosition:n=ie.Bottom,targetX:r,targetY:s,targetPosition:o=ie.Top,curvature:i=.25}){const[l,a]=np({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[u,c]=np({pos:o,x1:r,y1:s,x2:e,y2:t,c:i}),[d,f,h,_]=Bg({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:c});return[`M${e},${t} C${l},${a} ${u},${c} ${r},${s}`,d,f,h,_]}const dl=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=ie.Bottom,targetPosition:o=ie.Top,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:_,pathOptions:x,interactionWidth:N})=>{const[p,g,y]=Fg({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:x==null?void 0:x.curvature});return W.createElement(Mo,{path:p,labelX:g,labelY:y,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:_,interactionWidth:N})});dl.displayName="BezierEdge";const nd=E.createContext(null),RE=nd.Provider;nd.Consumer;const OE=()=>E.useContext(nd),LE=e=>"id"in e&&"source"in e&&"target"in e,$E=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Hu=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,BE=(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)),jE=(e,t)=>{if(!e.source||!e.target)return t;let n;return LE(e)?n={...e}:n={...e,id:$E(e)},BE(n,t)?t:t.concat(n)},Wu=({x:e,y:t},[n,r,s],o,[i,l])=>{const a={x:(e-n)/s,y:(t-r)/s};return o?{x:i*Math.round(a.x/i),y:l*Math.round(a.y/l)}:a},zg=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),cr=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-r};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:s}},Fl=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:o,y:i}=cr(s,t).positionAbsolute;return Mg(r,So({x:o,y:i,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Rg(n)},Dg=(e,t,[n,r,s]=[0,0,1],o=!1,i=!1,l=[0,0])=>{const a={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},u=[];return e.forEach(c=>{const{width:d,height:f,selectable:h=!0,hidden:_=!1}=c;if(i&&!h||_)return!1;const{positionAbsolute:x}=cr(c,l),N={x:x.x,y:x.y,width:d||0,height:f||0},p=zu(a,N),g=typeof d>"u"||typeof f>"u"||d===null||f===null,y=o&&p>0,w=(d||0)*(f||0);(g||y||p>=w||c.dragging)&&u.push(c)}),u},Ug=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},Hg=(e,t,n,r,s,o=.1)=>{const i=t/(e.width*(1+o)),l=n/(e.height*(1+o)),a=Math.min(i,l),u=ds(a,r,s),c=e.x+e.width/2,d=e.y+e.height/2,f=t/2-c*u,h=n/2-d*u;return{x:f,y:h,zoom:u}},er=(e,t=0)=>e.transition().duration(t);function rp(e,t,n,r){return(t[n]||[]).reduce((s,o)=>{var i,l;return`${e.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((l=e.positionAbsolute)==null?void 0:l.y)??0)+o.y+o.height/2}),s},[])}function FE(e,t,n,r,s,o){const{x:i,y:l}=Dn(e),u=t.elementsFromPoint(i,l).find(_=>_.classList.contains("react-flow__handle"));if(u){const _=u.getAttribute("data-nodeid");if(_){const x=rd(void 0,u),N=u.getAttribute("data-handleid"),p=o({nodeId:_,id:N,type:x});if(p){const g=s.find(y=>y.nodeId===_&&y.type===x&&y.id===N);return{handle:{id:N,type:x,nodeId:_,x:(g==null?void 0:g.x)||n.x,y:(g==null?void 0:g.y)||n.y},validHandleResult:p}}}}let c=[],d=1/0;if(s.forEach(_=>{const x=Math.sqrt((_.x-n.x)**2+(_.y-n.y)**2);if(x<=r){const N=o(_);x<=d&&(x_.isValid),h=c.some(({handle:_})=>_.type==="target");return c.find(({handle:_,validHandleResult:x})=>h?_.type==="target":f?x.isValid:!0)||c[0]}const zE={source:null,target:null,sourceHandle:null,targetHandle:null},Wg=()=>({handleDomNode:null,isValid:!1,connection:zE,endHandle:null});function Vg(e,t,n,r,s,o,i){const l=s==="target",a=i.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),u={...Wg(),handleDomNode:a};if(a){const c=rd(void 0,a),d=a.getAttribute("data-nodeid"),f=a.getAttribute("data-handleid"),h=a.classList.contains("connectable"),_=a.classList.contains("connectableend"),x={source:l?d:n,sourceHandle:l?f:r,target:l?n:d,targetHandle:l?r:f};u.connection=x,h&&_&&(t===vr.Strict?l&&c==="source"||!l&&c==="target":d!==n||f!==r)&&(u.endHandle={nodeId:d,handleId:f,type:c},u.isValid=o(x))}return u}function DE({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[De]){const{handleBounds:i}=o[De];let l=[],a=[];i&&(l=rp(o,i,"source",`${t}-${n}-${r}`),a=rp(o,i,"target",`${t}-${n}-${r}`)),s.push(...l,...a)}return s},[])}function rd(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Sa(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function UE(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Gg({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:i,isValidConnection:l,edgeUpdaterType:a,onReconnectEnd:u}){const c=Ag(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:h,connectionRadius:_,onConnectStart:x,panBy:N,getNodes:p,cancelConnection:g}=o();let y=0,w;const{x:P,y:L}=Dn(e),O=c==null?void 0:c.elementFromPoint(P,L),A=rd(a,O),j=f==null?void 0:f.getBoundingClientRect();if(!j||!A)return;let z,U=Dn(e,j),Z=!1,D=null,v=!1,k=null;const T=DE({nodes:p(),nodeId:n,handleId:t,handleType:A}),M=()=>{if(!h)return;const[b,F]=Pg(U,j);N({x:b,y:F}),y=requestAnimationFrame(M)};i({connectionPosition:U,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:A,connectionStartHandle:{nodeId:n,handleId:t,type:A},connectionEndHandle:null}),x==null||x(e,{nodeId:n,handleId:t,handleType:A});function I(b){const{transform:F}=o();U=Dn(b,j);const{handle:R,validHandleResult:X}=FE(b,c,Wu(U,F,!1,[1,1]),_,T,Q=>Vg(Q,d,n,t,s?"target":"source",l,c));if(w=R,Z||(M(),Z=!0),k=X.handleDomNode,D=X.connection,v=X.isValid,i({connectionPosition:w&&v?zg({x:w.x,y:w.y},F):U,connectionStatus:UE(!!w,v),connectionEndHandle:X.endHandle}),!w&&!v&&!k)return Sa(z);D.source!==D.target&&k&&(Sa(z),z=k,k.classList.add("connecting","react-flow__handle-connecting"),k.classList.toggle("valid",v),k.classList.toggle("react-flow__handle-valid",v))}function S(b){var F,R;(w||k)&&D&&v&&(r==null||r(D)),(R=(F=o()).onConnectEnd)==null||R.call(F,b),a&&(u==null||u(b)),Sa(z),g(),cancelAnimationFrame(y),Z=!1,v=!1,D=null,k=null,c.removeEventListener("mousemove",I),c.removeEventListener("mouseup",S),c.removeEventListener("touchmove",I),c.removeEventListener("touchend",S)}c.addEventListener("mousemove",I),c.addEventListener("mouseup",S),c.addEventListener("touchmove",I),c.addEventListener("touchend",S)}const sp=()=>!0,HE=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),WE=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:i}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},Yg=E.forwardRef(({type:e="source",position:t=ie.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:l,children:a,className:u,onMouseDown:c,onTouchStart:d,...f},h)=>{var j,z;const _=i||null,x=e==="target",N=Ye(),p=OE(),{connectOnClick:g,noPanClassName:y}=Ie(HE,Qe),{connecting:w,clickConnecting:P}=Ie(WE(p,_,e),Qe);p||(z=(j=N.getState()).onError)==null||z.call(j,"010",vn.error010());const L=U=>{const{defaultEdgeOptions:Z,onConnect:D,hasDefaultEdges:v}=N.getState(),k={...Z,...U};if(v){const{edges:T,setEdges:M}=N.getState();M(jE(k,T))}D==null||D(k),l==null||l(k)},O=U=>{if(!p)return;const Z=Lg(U);s&&(Z&&U.button===0||!Z)&&Gg({event:U,handleId:_,nodeId:p,onConnect:L,isTarget:x,getState:N.getState,setState:N.setState,isValidConnection:n||N.getState().isValidConnection||sp}),Z?c==null||c(U):d==null||d(U)},A=U=>{const{onClickConnectStart:Z,onClickConnectEnd:D,connectionClickStartHandle:v,connectionMode:k,isValidConnection:T}=N.getState();if(!p||!v&&!s)return;if(!v){Z==null||Z(U,{nodeId:p,handleId:_,handleType:e}),N.setState({connectionClickStartHandle:{nodeId:p,type:e,handleId:_}});return}const M=Ag(U.target),I=n||T||sp,{connection:S,isValid:b}=Vg({nodeId:p,id:_,type:e},k,v.nodeId,v.handleId||null,v.type,I,M);b&&L(S),D==null||D(U),N.setState({connectionClickStartHandle:null})};return W.createElement("div",{"data-handleid":_,"data-nodeid":p,"data-handlepos":t,"data-id":`${p}-${_}-${e}`,className:et(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,u,{source:!x,target:x,connectable:r,connectablestart:s,connectableend:o,connecting:P,connectionindicator:r&&(s&&!w||o&&w)}]),onMouseDown:O,onTouchStart:O,onClick:g?A:void 0,ref:h,...f},a)});Yg.displayName="Handle";var fl=E.memo(Yg);const Kg=({data:e,isConnectable:t,targetPosition:n=ie.Top,sourcePosition:r=ie.Bottom})=>W.createElement(W.Fragment,null,W.createElement(fl,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,W.createElement(fl,{type:"source",position:r,isConnectable:t}));Kg.displayName="DefaultNode";var Vu=E.memo(Kg);const Xg=({data:e,isConnectable:t,sourcePosition:n=ie.Bottom})=>W.createElement(W.Fragment,null,e==null?void 0:e.label,W.createElement(fl,{type:"source",position:n,isConnectable:t}));Xg.displayName="InputNode";var Qg=E.memo(Xg);const Zg=({data:e,isConnectable:t,targetPosition:n=ie.Top})=>W.createElement(W.Fragment,null,W.createElement(fl,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);Zg.displayName="OutputNode";var qg=E.memo(Zg);const sd=()=>null;sd.displayName="GroupNode";const VE=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),si=e=>e.id;function GE(e,t){return Qe(e.selectedNodes.map(si),t.selectedNodes.map(si))&&Qe(e.selectedEdges.map(si),t.selectedEdges.map(si))}const Jg=E.memo(({onSelectionChange:e})=>{const t=Ye(),{selectedNodes:n,selectedEdges:r}=Ie(VE,GE);return E.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});Jg.displayName="SelectionListener";const YE=e=>!!e.onSelectionChange;function KE({onSelectionChange:e}){const t=Ie(YE);return e||t?W.createElement(Jg,{onSelectionChange:e}):null}const XE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Er(e,t){E.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ve(e,t,n){E.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const QE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:a,nodesDraggable:u,nodesConnectable:c,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:h,elevateNodesOnSelect:_,minZoom:x,maxZoom:N,nodeExtent:p,onNodesChange:g,onEdgesChange:y,elementsSelectable:w,connectionMode:P,snapGrid:L,snapToGrid:O,translateExtent:A,connectOnClick:j,defaultEdgeOptions:z,fitView:U,fitViewOptions:Z,onNodesDelete:D,onEdgesDelete:v,onNodeDrag:k,onNodeDragStart:T,onNodeDragStop:M,onSelectionDrag:I,onSelectionDragStart:S,onSelectionDragStop:b,noPanClassName:F,nodeOrigin:R,rfId:X,autoPanOnConnect:Q,autoPanOnNodeDrag:re,onError:J,connectionRadius:fe,isValidConnection:V,nodeDragThreshold:me})=>{const{setNodes:K,setEdges:C,setDefaultNodesAndEdges:B,setMinZoom:te,setMaxZoom:q,setTranslateExtent:ae,setNodeExtent:pe,reset:oe}=Ie(XE,Qe),ee=Ye();return E.useEffect(()=>{const ge=r==null?void 0:r.map(de=>({...de,...z}));return B(n,ge),()=>{oe()}},[]),ve("defaultEdgeOptions",z,ee.setState),ve("connectionMode",P,ee.setState),ve("onConnect",s,ee.setState),ve("onConnectStart",o,ee.setState),ve("onConnectEnd",i,ee.setState),ve("onClickConnectStart",l,ee.setState),ve("onClickConnectEnd",a,ee.setState),ve("nodesDraggable",u,ee.setState),ve("nodesConnectable",c,ee.setState),ve("nodesFocusable",d,ee.setState),ve("edgesFocusable",f,ee.setState),ve("edgesUpdatable",h,ee.setState),ve("elementsSelectable",w,ee.setState),ve("elevateNodesOnSelect",_,ee.setState),ve("snapToGrid",O,ee.setState),ve("snapGrid",L,ee.setState),ve("onNodesChange",g,ee.setState),ve("onEdgesChange",y,ee.setState),ve("connectOnClick",j,ee.setState),ve("fitViewOnInit",U,ee.setState),ve("fitViewOnInitOptions",Z,ee.setState),ve("onNodesDelete",D,ee.setState),ve("onEdgesDelete",v,ee.setState),ve("onNodeDrag",k,ee.setState),ve("onNodeDragStart",T,ee.setState),ve("onNodeDragStop",M,ee.setState),ve("onSelectionDrag",I,ee.setState),ve("onSelectionDragStart",S,ee.setState),ve("onSelectionDragStop",b,ee.setState),ve("noPanClassName",F,ee.setState),ve("nodeOrigin",R,ee.setState),ve("rfId",X,ee.setState),ve("autoPanOnConnect",Q,ee.setState),ve("autoPanOnNodeDrag",re,ee.setState),ve("onError",J,ee.setState),ve("connectionRadius",fe,ee.setState),ve("isValidConnection",V,ee.setState),ve("nodeDragThreshold",me,ee.setState),Er(e,K),Er(t,C),Er(x,te),Er(N,q),Er(A,ae),Er(p,pe),null},op={display:"none"},ZE={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},e0="react-flow__node-desc",t0="react-flow__edge-desc",qE="react-flow__aria-live",JE=e=>e.ariaLiveMessage;function eN({rfId:e}){const t=Ie(JE);return W.createElement("div",{id:`${qE}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ZE},t)}function tN({rfId:e,disableKeyboardA11y:t}){return W.createElement(W.Fragment,null,W.createElement("div",{id:`${e0}-${e}`,style:op},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),W.createElement("div",{id:`${t0}-${e}`,style:op},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&W.createElement(eN,{rfId:e}))}var No=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=E.useState(!1),s=E.useRef(!1),o=E.useRef(new Set([])),[i,l]=E.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),c=u.reduce((d,f)=>d.concat(...f),[]);return[u,c]}return[[],[]]},[e]);return E.useEffect(()=>{const a=typeof document<"u"?document:null,u=(t==null?void 0:t.target)||a;if(e!==null){const c=h=>{if(s.current=h.ctrlKey||h.metaKey||h.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Du(h))return!1;const x=lp(h.code,l);o.current.add(h[x]),ip(i,o.current,!1)&&(h.preventDefault(),r(!0))},d=h=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Du(h))return!1;const x=lp(h.code,l);ip(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[x]),h.key==="Meta"&&o.current.clear(),s.current=!1},f=()=>{o.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",c),u==null||u.addEventListener("keyup",d),window.addEventListener("blur",f),()=>{u==null||u.removeEventListener("keydown",c),u==null||u.removeEventListener("keyup",d),window.removeEventListener("blur",f)}}},[e,r]),n};function ip(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function lp(e,t){return t.includes(e)?"code":"key"}function n0(e,t,n,r){var l,a;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),i=cr(o,r);return n0(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((l=o[De])==null?void 0:l.z)??0)>(n.z??0)?((a=o[De])==null?void 0:a.z)??0:n.z??0},r)}function r0(e,t,n){e.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:i,y:l,z:a}=n0(r,e,{...r.position,z:((o=r[De])==null?void 0:o.z)??0},t);r.positionAbsolute={x:i,y:l},r[De].z=a,n!=null&&n[r.id]&&(r[De].isParent=!0)}})}function Ea(e,t,n,r){const s=new Map,o={},i=r?1e3:0;return e.forEach(l=>{var h;const a=(Pt(l.zIndex)?l.zIndex:0)+(l.selected?i:0),u=t.get(l.id),c={...l,positionAbsolute:{x:l.position.x,y:l.position.y}},d=l.parentNode||l.parentId;d&&(o[d]=!0);const f=(u==null?void 0:u.type)&&(u==null?void 0:u.type)!==l.type;Object.defineProperty(c,De,{enumerable:!1,value:{handleBounds:f||(h=u==null?void 0:u[De])==null?void 0:h.handleBounds,z:a}}),s.set(l.id,c)}),r0(s,n,o),s}function s0(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:i,d3Zoom:l,d3Selection:a,fitViewOnInitDone:u,fitViewOnInit:c,nodeOrigin:d}=e(),f=t.initial&&!u&&c;if(l&&a&&(f||!t.initial)){const _=n().filter(N=>{var g;const p=t.includeHiddenNodes?N.width&&N.height:!N.hidden;return(g=t.nodes)!=null&&g.length?p&&t.nodes.some(y=>y.id===N.id):p}),x=_.every(N=>N.width&&N.height);if(_.length>0&&x){const N=Fl(_,d),{x:p,y:g,zoom:y}=Hg(N,r,s,t.minZoom??o,t.maxZoom??i,t.padding??.1),w=fn.translate(p,g).scale(y);return typeof t.duration=="number"&&t.duration>0?l.transform(er(a,t.duration),w):l.transform(a,w),!0}}return!1}function nN(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[De]:r[De],selected:n.selected})}),new Map(t)}function rN(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function oi({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:a,hasDefaultEdges:u}=n();e!=null&&e.length&&(a&&r({nodeInternals:nN(e,s)}),i==null||i(e)),t!=null&&t.length&&(u&&r({edges:rN(t,o)}),l==null||l(t))}const Nr=()=>{},sN={zoomIn:Nr,zoomOut:Nr,zoomTo:Nr,getZoom:()=>1,setViewport:Nr,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Nr,fitBounds:Nr,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},oN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),iN=()=>{const e=Ye(),{d3Zoom:t,d3Selection:n}=Ie(oN,Qe);return E.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(er(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(er(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(er(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[i,l,a]=e.getState().transform,u=fn.translate(s.x??i,s.y??l).scale(s.zoom??a);t.transform(er(n,o==null?void 0:o.duration),u)},getViewport:()=>{const[s,o,i]=e.getState().transform;return{x:s,y:o,zoom:i}},fitView:s=>s0(e.getState,s),setCenter:(s,o,i)=>{const{width:l,height:a,maxZoom:u}=e.getState(),c=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:u,d=l/2-s*c,f=a/2-o*c,h=fn.translate(d,f).scale(c);t.transform(er(n,i==null?void 0:i.duration),h)},fitBounds:(s,o)=>{const{width:i,height:l,minZoom:a,maxZoom:u}=e.getState(),{x:c,y:d,zoom:f}=Hg(s,i,l,a,u,(o==null?void 0:o.padding)??.1),h=fn.translate(c,d).scale(f);t.transform(er(n,o==null?void 0:o.duration),h)},project:s=>{const{transform:o,snapToGrid:i,snapGrid:l}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Wu(s,o,i,l)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:i,snapGrid:l,domNode:a}=e.getState();if(!a)return s;const{x:u,y:c}=a.getBoundingClientRect(),d={x:s.x-u,y:s.y-c};return Wu(d,o,i,l)},flowToScreenPosition:s=>{const{transform:o,domNode:i}=e.getState();if(!i)return s;const{x:l,y:a}=i.getBoundingClientRect(),u=zg(s,o);return{x:u.x+l,y:u.y+a}},viewportInitialized:!0}:sN,[t,n])};function od(){const e=iN(),t=Ye(),n=E.useCallback(()=>t.getState().getNodes().map(x=>({...x})),[]),r=E.useCallback(x=>t.getState().nodeInternals.get(x),[]),s=E.useCallback(()=>{const{edges:x=[]}=t.getState();return x.map(N=>({...N}))},[]),o=E.useCallback(x=>{const{edges:N=[]}=t.getState();return N.find(p=>p.id===x)},[]),i=E.useCallback(x=>{const{getNodes:N,setNodes:p,hasDefaultNodes:g,onNodesChange:y}=t.getState(),w=N(),P=typeof x=="function"?x(w):x;if(g)p(P);else if(y){const L=P.length===0?w.map(O=>({type:"remove",id:O.id})):P.map(O=>({item:O,type:"reset"}));y(L)}},[]),l=E.useCallback(x=>{const{edges:N=[],setEdges:p,hasDefaultEdges:g,onEdgesChange:y}=t.getState(),w=typeof x=="function"?x(N):x;if(g)p(w);else if(y){const P=w.length===0?N.map(L=>({type:"remove",id:L.id})):w.map(L=>({item:L,type:"reset"}));y(P)}},[]),a=E.useCallback(x=>{const N=Array.isArray(x)?x:[x],{getNodes:p,setNodes:g,hasDefaultNodes:y,onNodesChange:w}=t.getState();if(y){const L=[...p(),...N];g(L)}else if(w){const P=N.map(L=>({item:L,type:"add"}));w(P)}},[]),u=E.useCallback(x=>{const N=Array.isArray(x)?x:[x],{edges:p=[],setEdges:g,hasDefaultEdges:y,onEdgesChange:w}=t.getState();if(y)g([...p,...N]);else if(w){const P=N.map(L=>({item:L,type:"add"}));w(P)}},[]),c=E.useCallback(()=>{const{getNodes:x,edges:N=[],transform:p}=t.getState(),[g,y,w]=p;return{nodes:x().map(P=>({...P})),edges:N.map(P=>({...P})),viewport:{x:g,y,zoom:w}}},[]),d=E.useCallback(({nodes:x,edges:N})=>{const{nodeInternals:p,getNodes:g,edges:y,hasDefaultNodes:w,hasDefaultEdges:P,onNodesDelete:L,onEdgesDelete:O,onNodesChange:A,onEdgesChange:j}=t.getState(),z=(x||[]).map(k=>k.id),U=(N||[]).map(k=>k.id),Z=g().reduce((k,T)=>{const M=T.parentNode||T.parentId,I=!z.includes(T.id)&&M&&k.find(b=>b.id===M);return(typeof T.deletable=="boolean"?T.deletable:!0)&&(z.includes(T.id)||I)&&k.push(T),k},[]),D=y.filter(k=>typeof k.deletable=="boolean"?k.deletable:!0),v=D.filter(k=>U.includes(k.id));if(Z||v){const k=Ug(Z,D),T=[...v,...k],M=T.reduce((I,S)=>(I.includes(S.id)||I.push(S.id),I),[]);if((P||w)&&(P&&t.setState({edges:y.filter(I=>!M.includes(I.id))}),w&&(Z.forEach(I=>{p.delete(I.id)}),t.setState({nodeInternals:new Map(p)}))),M.length>0&&(O==null||O(T),j&&j(M.map(I=>({id:I,type:"remove"})))),Z.length>0&&(L==null||L(Z),A)){const I=Z.map(S=>({id:S.id,type:"remove"}));A(I)}}},[]),f=E.useCallback(x=>{const N=kE(x),p=N?null:t.getState().nodeInternals.get(x.id);return!N&&!p?[null,null,N]:[N?x:qf(p),p,N]},[]),h=E.useCallback((x,N=!0,p)=>{const[g,y,w]=f(x);return g?(p||t.getState().getNodes()).filter(P=>{if(!w&&(P.id===y.id||!P.positionAbsolute))return!1;const L=qf(P),O=zu(L,g);return N&&O>0||O>=g.width*g.height}):[]},[]),_=E.useCallback((x,N,p=!0)=>{const[g]=f(x);if(!g)return!1;const y=zu(g,N);return p&&y>0||y>=g.width*g.height},[]);return E.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:i,setEdges:l,addNodes:a,addEdges:u,toObject:c,deleteElements:d,getIntersectingNodes:h,isNodeIntersecting:_}),[e,n,r,s,o,i,l,a,u,c,d,h,_])}const lN={actInsideInputWithModifier:!1};var aN=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ye(),{deleteElements:r}=od(),s=No(e,lN),o=No(t);E.useEffect(()=>{if(s){const{edges:i,getNodes:l}=n.getState(),a=l().filter(c=>c.selected),u=i.filter(c=>c.selected);r({nodes:a,edges:u}),n.setState({nodesSelectionActive:!1})}},[s]),E.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function uN(e){const t=Ye();E.useEffect(()=>{let n;const r=()=>{var o,i;if(!e.current)return;const s=Zc(e.current);(s.height===0||s.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",vn.error004())),t.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const id={position:"absolute",width:"100%",height:"100%",top:0,left:0},cN=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,ii=e=>({x:e.x,y:e.y,zoom:e.k}),Tr=(e,t)=>e.target.closest(`.${t}`),ap=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),up=e=>{const t=e.ctrlKey&&cl()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},dN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),fN=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:a=ir.Free,zoomOnDoubleClick:u=!0,elementsSelectable:c,panOnDrag:d=!0,defaultViewport:f,translateExtent:h,minZoom:_,maxZoom:x,zoomActivationKeyCode:N,preventScrolling:p=!0,children:g,noWheelClassName:y,noPanClassName:w})=>{const P=E.useRef(),L=Ye(),O=E.useRef(!1),A=E.useRef(!1),j=E.useRef(null),z=E.useRef({x:0,y:0,zoom:0}),{d3Zoom:U,d3Selection:Z,d3ZoomHandler:D,userSelectionActive:v}=Ie(dN,Qe),k=No(N),T=E.useRef(0),M=E.useRef(!1),I=E.useRef();return uN(j),E.useEffect(()=>{if(j.current){const S=j.current.getBoundingClientRect(),b=Ig().scaleExtent([_,x]).translateExtent(h),F=It(j.current).call(b),R=fn.translate(f.x,f.y).scale(ds(f.zoom,_,x)),X=[[0,0],[S.width,S.height]],Q=b.constrain()(R,X,h);b.transform(F,Q),b.wheelDelta(up),L.setState({d3Zoom:b,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[Q.x,Q.y,Q.k],domNode:j.current.closest(".react-flow")})}},[]),E.useEffect(()=>{Z&&U&&(i&&!k&&!v?Z.on("wheel.zoom",S=>{if(Tr(S,y))return!1;S.preventDefault(),S.stopImmediatePropagation();const b=Z.property("__zoom").k||1;if(S.ctrlKey&&o){const V=jt(S),me=up(S),K=b*Math.pow(2,me);U.scaleTo(Z,K,V,S);return}const F=S.deltaMode===1?20:1;let R=a===ir.Vertical?0:S.deltaX*F,X=a===ir.Horizontal?0:S.deltaY*F;!cl()&&S.shiftKey&&a!==ir.Vertical&&(R=S.deltaY*F,X=0),U.translateBy(Z,-(R/b)*l,-(X/b)*l,{internal:!0});const Q=ii(Z.property("__zoom")),{onViewportChangeStart:re,onViewportChange:J,onViewportChangeEnd:fe}=L.getState();clearTimeout(I.current),M.current||(M.current=!0,t==null||t(S,Q),re==null||re(Q)),M.current&&(e==null||e(S,Q),J==null||J(Q),I.current=setTimeout(()=>{n==null||n(S,Q),fe==null||fe(Q),M.current=!1},150))},{passive:!1}):typeof D<"u"&&Z.on("wheel.zoom",function(S,b){if(!p&&S.type==="wheel"&&!S.ctrlKey||Tr(S,y))return null;S.preventDefault(),D.call(this,S,b)},{passive:!1}))},[v,i,a,Z,U,D,k,o,p,y,t,e,n]),E.useEffect(()=>{U&&U.on("start",S=>{var R,X;if(!S.sourceEvent||S.sourceEvent.internal)return null;T.current=(R=S.sourceEvent)==null?void 0:R.button;const{onViewportChangeStart:b}=L.getState(),F=ii(S.transform);O.current=!0,z.current=F,((X=S.sourceEvent)==null?void 0:X.type)==="mousedown"&&L.setState({paneDragging:!0}),b==null||b(F),t==null||t(S.sourceEvent,F)})},[U,t]),E.useEffect(()=>{U&&(v&&!O.current?U.on("zoom",null):v||U.on("zoom",S=>{var F;const{onViewportChange:b}=L.getState();if(L.setState({transform:[S.transform.x,S.transform.y,S.transform.k]}),A.current=!!(r&&ap(d,T.current??0)),(e||b)&&!((F=S.sourceEvent)!=null&&F.internal)){const R=ii(S.transform);b==null||b(R),e==null||e(S.sourceEvent,R)}}))},[v,U,e,d,r]),E.useEffect(()=>{U&&U.on("end",S=>{if(!S.sourceEvent||S.sourceEvent.internal)return null;const{onViewportChangeEnd:b}=L.getState();if(O.current=!1,L.setState({paneDragging:!1}),r&&ap(d,T.current??0)&&!A.current&&r(S.sourceEvent),A.current=!1,(n||b)&&cN(z.current,S.transform)){const F=ii(S.transform);z.current=F,clearTimeout(P.current),P.current=setTimeout(()=>{b==null||b(F),n==null||n(S.sourceEvent,F)},i?150:0)}})},[U,i,d,n,r]),E.useEffect(()=>{U&&U.filter(S=>{const b=k||s,F=o&&S.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&S.button===1&&S.type==="mousedown"&&(Tr(S,"react-flow__node")||Tr(S,"react-flow__edge")))return!0;if(!d&&!b&&!i&&!u&&!o||v||!u&&S.type==="dblclick"||Tr(S,y)&&S.type==="wheel"||Tr(S,w)&&(S.type!=="wheel"||i&&S.type==="wheel"&&!k)||!o&&S.ctrlKey&&S.type==="wheel"||!b&&!i&&!F&&S.type==="wheel"||!d&&(S.type==="mousedown"||S.type==="touchstart")||Array.isArray(d)&&!d.includes(S.button)&&S.type==="mousedown")return!1;const R=Array.isArray(d)&&d.includes(S.button)||!S.button||S.button<=1;return(!S.ctrlKey||S.type==="wheel")&&R})},[v,U,s,o,i,u,d,c,k]),W.createElement("div",{className:"react-flow__renderer",ref:j,style:id},g)},pN=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hN(){const{userSelectionActive:e,userSelectionRect:t}=Ie(pN,Qe);return e&&t?W.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function cp(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(s>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),t.position.x<0){const i=Math.abs(t.position.x);r.position.x=r.position.x-i,r.style.width+=i,t.position.x=0}if(t.position.y<0){const i=Math.abs(t.position.y);r.position.y=r.position.y-i,r.style.height+=i,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function mN(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const o=e.filter(l=>l.id===s.id);if(o.length===0)return r.push(s),r;const i={...s};for(const l of o)if(l)switch(l.type){case"select":{i.selected=l.selected;break}case"position":{typeof l.position<"u"&&(i.position=l.position),typeof l.positionAbsolute<"u"&&(i.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(i.dragging=l.dragging),i.expandParent&&cp(r,i);break}case"dimensions":{typeof l.dimensions<"u"&&(i.width=l.dimensions.width,i.height=l.dimensions.height),typeof l.updateStyle<"u"&&(i.style={...i.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(i.resizing=l.resizing),i.expandParent&&cp(r,i);break}case"remove":return r}return r.push(i),r},n)}function gN(e,t){return mN(e,t)}const Cn=(e,t)=>({id:e,type:"select",selected:t});function Ur(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Cn(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Cn(r.id,!1))),n},[])}const Na=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},yN=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),o0=E.memo(({isSelecting:e,selectionMode:t=Eo.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:a,onPaneMouseMove:u,onPaneMouseLeave:c,children:d})=>{const f=E.useRef(null),h=Ye(),_=E.useRef(0),x=E.useRef(0),N=E.useRef(),{userSelectionActive:p,elementsSelectable:g,dragging:y}=Ie(yN,Qe),w=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),_.current=0,x.current=0},P=D=>{o==null||o(D),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},L=D=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){D.preventDefault();return}i==null||i(D)},O=l?D=>l(D):void 0,A=D=>{const{resetSelectedElements:v,domNode:k}=h.getState();if(N.current=k==null?void 0:k.getBoundingClientRect(),!g||!e||D.button!==0||D.target!==f.current||!N.current)return;const{x:T,y:M}=Dn(D,N.current);v(),h.setState({userSelectionRect:{width:0,height:0,startX:T,startY:M,x:T,y:M}}),r==null||r(D)},j=D=>{const{userSelectionRect:v,nodeInternals:k,edges:T,transform:M,onNodesChange:I,onEdgesChange:S,nodeOrigin:b,getNodes:F}=h.getState();if(!e||!N.current||!v)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const R=Dn(D,N.current),X=v.startX??0,Q=v.startY??0,re={...v,x:R.xK.id),me=fe.map(K=>K.id);if(_.current!==me.length){_.current=me.length;const K=Ur(J,me);K.length&&(I==null||I(K))}if(x.current!==V.length){x.current=V.length;const K=Ur(T,V);K.length&&(S==null||S(K))}h.setState({userSelectionRect:re})},z=D=>{if(D.button!==0)return;const{userSelectionRect:v}=h.getState();!p&&v&&D.target===f.current&&(P==null||P(D)),h.setState({nodesSelectionActive:_.current>0}),w(),s==null||s(D)},U=D=>{p&&(h.setState({nodesSelectionActive:_.current>0}),s==null||s(D)),w()},Z=g&&(e||p);return W.createElement("div",{className:et(["react-flow__pane",{dragging:y,selection:e}]),onClick:Z?void 0:Na(P,f),onContextMenu:Na(L,f),onWheel:Na(O,f),onMouseEnter:Z?void 0:a,onMouseDown:Z?A:void 0,onMouseMove:Z?j:u,onMouseUp:Z?z:void 0,onMouseLeave:Z?U:c,ref:f,style:id},d,W.createElement(hN,null))});o0.displayName="Pane";function i0(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:i0(r,t):!1}function dp(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function vN(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!i0(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var o,i;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=s.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function _N(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function l0(e,t,n,r,s=[0,0],o){const i=_N(e,e.extent||r);let l=i;const a=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(a&&e.width&&e.height){const d=n.get(a),{x:f,y:h}=cr(d,s).positionAbsolute;l=d&&Pt(f)&&Pt(h)&&Pt(d.width)&&Pt(d.height)?[[f+e.width*s[0],h+e.height*s[1]],[f+d.width-e.width+e.width*s[0],h+d.height-e.height+e.height*s[1]]]:l}else o==null||o("005",vn.error005()),l=i;else if(e.extent&&a&&e.extent!=="parent"){const d=n.get(a),{x:f,y:h}=cr(d,s).positionAbsolute;l=[[e.extent[0][0]+f,e.extent[0][1]+h],[e.extent[1][0]+f,e.extent[1][1]+h]]}let u={x:0,y:0};if(a){const d=n.get(a);u=cr(d,s).positionAbsolute}const c=l&&l!=="parent"?qc(t,l):t;return{position:{x:c.x-u.x,y:c.y-u.y},positionAbsolute:c}}function Ta({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?r.find(s=>s.id===e):r[0],r]}const fp=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),i=t.getBoundingClientRect(),l={x:i.width*r[0],y:i.height*r[1]};return o.map(a=>{const u=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(u.left-i.left-l.x)/n,y:(u.top-i.top-l.y)/n,...Zc(a)}})};function Is(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function Gu({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:l,onError:a}=t.getState(),u=l.get(e);if(!u){a==null||a("012",vn.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var c;return(c=r==null?void 0:r.current)==null?void 0:c.blur()})):s([e])}function xN(){const e=Ye();return E.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,a={x:(i-r[0])/r[2],y:(l-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(a.x/s[0]):a.x,ySnapped:o?s[1]*Math.round(a.y/s[1]):a.y,...a}},[])}function ka(e){return(t,n,r)=>e==null?void 0:e(t,r)}function a0({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:i}){const l=Ye(),[a,u]=E.useState(!1),c=E.useRef([]),d=E.useRef({x:null,y:null}),f=E.useRef(0),h=E.useRef(null),_=E.useRef({x:0,y:0}),x=E.useRef(null),N=E.useRef(!1),p=E.useRef(!1),g=E.useRef(!1),y=xN();return E.useEffect(()=>{if(e!=null&&e.current){const w=It(e.current),P=({x:A,y:j})=>{const{nodeInternals:z,onNodeDrag:U,onSelectionDrag:Z,updateNodePositions:D,nodeExtent:v,snapGrid:k,snapToGrid:T,nodeOrigin:M,onError:I}=l.getState();d.current={x:A,y:j};let S=!1,b={x:0,y:0,x2:0,y2:0};if(c.current.length>1&&v){const R=Fl(c.current,M);b=So(R)}if(c.current=c.current.map(R=>{const X={x:A-R.distance.x,y:j-R.distance.y};T&&(X.x=k[0]*Math.round(X.x/k[0]),X.y=k[1]*Math.round(X.y/k[1]));const Q=[[v[0][0],v[0][1]],[v[1][0],v[1][1]]];c.current.length>1&&v&&!R.extent&&(Q[0][0]=R.positionAbsolute.x-b.x+v[0][0],Q[1][0]=R.positionAbsolute.x+(R.width??0)-b.x2+v[1][0],Q[0][1]=R.positionAbsolute.y-b.y+v[0][1],Q[1][1]=R.positionAbsolute.y+(R.height??0)-b.y2+v[1][1]);const re=l0(R,X,z,Q,M,I);return S=S||R.position.x!==re.position.x||R.position.y!==re.position.y,R.position=re.position,R.positionAbsolute=re.positionAbsolute,R}),!S)return;D(c.current,!0,!0),u(!0);const F=s?U:ka(Z);if(F&&x.current){const[R,X]=Ta({nodeId:s,dragItems:c.current,nodeInternals:z});F(x.current,R,X)}},L=()=>{if(!h.current)return;const[A,j]=Pg(_.current,h.current);if(A!==0||j!==0){const{transform:z,panBy:U}=l.getState();d.current.x=(d.current.x??0)-A/z[2],d.current.y=(d.current.y??0)-j/z[2],U({x:A,y:j})&&P(d.current)}f.current=requestAnimationFrame(L)},O=A=>{var M;const{nodeInternals:j,multiSelectionActive:z,nodesDraggable:U,unselectNodesAndEdges:Z,onNodeDragStart:D,onSelectionDragStart:v}=l.getState();p.current=!0;const k=s?D:ka(v);(!i||!o)&&!z&&s&&((M=j.get(s))!=null&&M.selected||Z()),s&&o&&i&&Gu({id:s,store:l,nodeRef:e});const T=y(A);if(d.current=T,c.current=vN(j,U,T,s),k&&c.current){const[I,S]=Ta({nodeId:s,dragItems:c.current,nodeInternals:j});k(A.sourceEvent,I,S)}};if(t)w.on(".drag",null);else{const A=Pw().on("start",j=>{const{domNode:z,nodeDragThreshold:U}=l.getState();U===0&&O(j),g.current=!1;const Z=y(j);d.current=Z,h.current=(z==null?void 0:z.getBoundingClientRect())||null,_.current=Dn(j.sourceEvent,h.current)}).on("drag",j=>{var D,v;const z=y(j),{autoPanOnNodeDrag:U,nodeDragThreshold:Z}=l.getState();if(j.sourceEvent.type==="touchmove"&&j.sourceEvent.touches.length>1&&(g.current=!0),!g.current){if(!N.current&&p.current&&U&&(N.current=!0,L()),!p.current){const k=z.xSnapped-(((D=d==null?void 0:d.current)==null?void 0:D.x)??0),T=z.ySnapped-(((v=d==null?void 0:d.current)==null?void 0:v.y)??0);Math.sqrt(k*k+T*T)>Z&&O(j)}(d.current.x!==z.xSnapped||d.current.y!==z.ySnapped)&&c.current&&p.current&&(x.current=j.sourceEvent,_.current=Dn(j.sourceEvent,h.current),P(z))}}).on("end",j=>{if(!(!p.current||g.current)&&(u(!1),N.current=!1,p.current=!1,cancelAnimationFrame(f.current),c.current)){const{updateNodePositions:z,nodeInternals:U,onNodeDragStop:Z,onSelectionDragStop:D}=l.getState(),v=s?Z:ka(D);if(z(c.current,!1,!1),v){const[k,T]=Ta({nodeId:s,dragItems:c.current,nodeInternals:U});v(j.sourceEvent,k,T)}}}).filter(j=>{const z=j.target;return!j.button&&(!n||!dp(z,`.${n}`,e))&&(!r||dp(z,r,e))});return w.call(A),()=>{w.on(".drag",null)}}}},[e,t,n,r,o,l,s,i,y]),a}function u0(){const e=Ye();return E.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:i,snapToGrid:l,snapGrid:a,onError:u,nodesDraggable:c}=e.getState(),d=i().filter(g=>g.selected&&(g.draggable||c&&typeof g.draggable>"u")),f=l?a[0]:5,h=l?a[1]:5,_=n.isShiftPressed?4:1,x=n.x*f*_,N=n.y*h*_,p=d.map(g=>{if(g.positionAbsolute){const y={x:g.positionAbsolute.x+x,y:g.positionAbsolute.y+N};l&&(y.x=a[0]*Math.round(y.x/a[0]),y.y=a[1]*Math.round(y.y/a[1]));const{positionAbsolute:w,position:P}=l0(g,y,r,s,void 0,u);g.position=P,g.positionAbsolute=w}return g});o(p,!0,!1)},[])}const Jr={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var bs=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:i,xPosOrigin:l,yPosOrigin:a,selected:u,onClick:c,onMouseEnter:d,onMouseMove:f,onMouseLeave:h,onContextMenu:_,onDoubleClick:x,style:N,className:p,isDraggable:g,isSelectable:y,isConnectable:w,isFocusable:P,selectNodesOnDrag:L,sourcePosition:O,targetPosition:A,hidden:j,resizeObserver:z,dragHandle:U,zIndex:Z,isParent:D,noDragClassName:v,noPanClassName:k,initialized:T,disableKeyboardA11y:M,ariaLabel:I,rfId:S,hasHandleBounds:b})=>{const F=Ye(),R=E.useRef(null),X=E.useRef(null),Q=E.useRef(O),re=E.useRef(A),J=E.useRef(r),fe=y||g||c||d||f||h,V=u0(),me=Is(n,F.getState,d),K=Is(n,F.getState,f),C=Is(n,F.getState,h),B=Is(n,F.getState,_),te=Is(n,F.getState,x),q=oe=>{const{nodeDragThreshold:ee}=F.getState();if(y&&(!L||!g||ee>0)&&Gu({id:n,store:F,nodeRef:R}),c){const ge=F.getState().nodeInternals.get(n);ge&&c(oe,{...ge})}},ae=oe=>{if(!Du(oe)&&!M)if(Og.includes(oe.key)&&y){const ee=oe.key==="Escape";Gu({id:n,store:F,unselect:ee,nodeRef:R})}else g&&u&&Object.prototype.hasOwnProperty.call(Jr,oe.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${oe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),V({x:Jr[oe.key].x,y:Jr[oe.key].y,isShiftPressed:oe.shiftKey}))};E.useEffect(()=>()=>{X.current&&(z==null||z.unobserve(X.current),X.current=null)},[]),E.useEffect(()=>{if(R.current&&!j){const oe=R.current;(!T||!b||X.current!==oe)&&(X.current&&(z==null||z.unobserve(X.current)),z==null||z.observe(oe),X.current=oe)}},[j,T,b]),E.useEffect(()=>{const oe=J.current!==r,ee=Q.current!==O,ge=re.current!==A;R.current&&(oe||ee||ge)&&(oe&&(J.current=r),ee&&(Q.current=O),ge&&(re.current=A),F.getState().updateNodeDimensions([{id:n,nodeElement:R.current,forceUpdate:!0}]))},[n,r,O,A]);const pe=a0({nodeRef:R,disabled:j||!g,noDragClassName:v,handleSelector:U,nodeId:n,isSelectable:y,selectNodesOnDrag:L});return j?null:W.createElement("div",{className:et(["react-flow__node",`react-flow__node-${r}`,{[k]:g},p,{selected:u,selectable:y,parent:D,dragging:pe}]),ref:R,style:{zIndex:Z,transform:`translate(${l}px,${a}px)`,pointerEvents:fe?"all":"none",visibility:T?"visible":"hidden",...N},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:me,onMouseMove:K,onMouseLeave:C,onContextMenu:B,onClick:q,onDoubleClick:te,onKeyDown:P?ae:void 0,tabIndex:P?0:void 0,role:P?"button":void 0,"aria-describedby":M?void 0:`${e0}-${S}`,"aria-label":I},W.createElement(RE,{value:n},W.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:i,selected:u,isConnectable:w,sourcePosition:O,targetPosition:A,dragging:pe,dragHandle:U,zIndex:Z})))};return t.displayName="NodeWrapper",E.memo(t)};const wN=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Fl(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function SN({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ye(),{width:s,height:o,x:i,y:l,transformString:a,userSelectionActive:u}=Ie(wN,Qe),c=u0(),d=E.useRef(null);if(E.useEffect(()=>{var _;n||(_=d.current)==null||_.focus({preventScroll:!0})},[n]),a0({nodeRef:d}),u||!s||!o)return null;const f=e?_=>{const x=r.getState().getNodes().filter(N=>N.selected);e(_,x)}:void 0,h=_=>{Object.prototype.hasOwnProperty.call(Jr,_.key)&&c({x:Jr[_.key].x,y:Jr[_.key].y,isShiftPressed:_.shiftKey})};return W.createElement("div",{className:et(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a}},W.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:s,height:o,top:l,left:i}}))}var EN=E.memo(SN);const NN=e=>e.nodesSelectionActive,c0=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:l,onMove:a,onMoveStart:u,onMoveEnd:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:h,onSelectionStart:_,onSelectionEnd:x,multiSelectionKeyCode:N,panActivationKeyCode:p,zoomActivationKeyCode:g,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:P,panOnScroll:L,panOnScrollSpeed:O,panOnScrollMode:A,zoomOnDoubleClick:j,panOnDrag:z,defaultViewport:U,translateExtent:Z,minZoom:D,maxZoom:v,preventScrolling:k,onSelectionContextMenu:T,noWheelClassName:M,noPanClassName:I,disableKeyboardA11y:S})=>{const b=Ie(NN),F=No(d),R=No(p),X=R||z,Q=R||L,re=F||f&&X!==!0;return aN({deleteKeyCode:l,multiSelectionKeyCode:N}),W.createElement(fN,{onMove:a,onMoveStart:u,onMoveEnd:c,onPaneContextMenu:o,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:P,panOnScroll:Q,panOnScrollSpeed:O,panOnScrollMode:A,zoomOnDoubleClick:j,panOnDrag:!F&&X,defaultViewport:U,translateExtent:Z,minZoom:D,maxZoom:v,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:M,noPanClassName:I},W.createElement(o0,{onSelectionStart:_,onSelectionEnd:x,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:X,isSelecting:!!re,selectionMode:h},e,b&&W.createElement(EN,{onSelectionContextMenu:T,noPanClassName:I,disableKeyboardA11y:S})))};c0.displayName="FlowRenderer";var TN=E.memo(c0);function kN(e){return Ie(E.useCallback(n=>e?Dg(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function CN(e){const t={input:bs(e.input||Qg),default:bs(e.default||Vu),output:bs(e.output||qg),group:bs(e.group||sd)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=bs(e[o]||Vu),s),n);return{...t,...r}}const IN=({x:e,y:t,width:n,height:r,origin:s})=>!n||!r?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-r*s[1]},bN=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),d0=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:i}=Ie(bN,Qe),l=kN(e.onlyRenderVisibleElements),a=E.useRef(),u=E.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const c=new ResizeObserver(d=>{const f=d.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));o(f)});return a.current=c,c},[]);return E.useEffect(()=>()=>{var c;(c=a==null?void 0:a.current)==null||c.disconnect()},[]),W.createElement("div",{className:"react-flow__nodes",style:id},l.map(c=>{var P,L,O;let d=c.type||"default";e.nodeTypes[d]||(i==null||i("003",vn.error003(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,h=!!(c.draggable||t&&typeof c.draggable>"u"),_=!!(c.selectable||s&&typeof c.selectable>"u"),x=!!(c.connectable||n&&typeof c.connectable>"u"),N=!!(c.focusable||r&&typeof c.focusable>"u"),p=e.nodeExtent?qc(c.positionAbsolute,e.nodeExtent):c.positionAbsolute,g=(p==null?void 0:p.x)??0,y=(p==null?void 0:p.y)??0,w=IN({x:g,y,width:c.width??0,height:c.height??0,origin:e.nodeOrigin});return W.createElement(f,{key:c.id,id:c.id,className:c.className,style:c.style,type:d,data:c.data,sourcePosition:c.sourcePosition||ie.Bottom,targetPosition:c.targetPosition||ie.Top,hidden:c.hidden,xPos:g,yPos:y,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!c.selected,isDraggable:h,isSelectable:_,isConnectable:x,isFocusable:N,resizeObserver:u,dragHandle:c.dragHandle,zIndex:((P=c[De])==null?void 0:P.z)??0,isParent:!!((L=c[De])!=null&&L.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!c.width&&!!c.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:c.ariaLabel,hasHandleBounds:!!((O=c[De])!=null&&O.handleBounds)})}))};d0.displayName="NodeRenderer";var PN=E.memo(d0);const AN=(e,t,n)=>n===ie.Left?e-t:n===ie.Right?e+t:e,MN=(e,t,n)=>n===ie.Top?e-t:n===ie.Bottom?e+t:e,pp="react-flow__edgeupdater",hp=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:l})=>W.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:et([pp,`${pp}-${l}`]),cx:AN(t,r,e),cy:MN(n,r,e),r,stroke:"transparent",fill:"transparent"}),RN=()=>!0;var kr=e=>{const t=({id:n,className:r,type:s,data:o,onClick:i,onEdgeDoubleClick:l,selected:a,animated:u,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:_,labelBgBorderRadius:x,style:N,source:p,target:g,sourceX:y,sourceY:w,targetX:P,targetY:L,sourcePosition:O,targetPosition:A,elementsSelectable:j,hidden:z,sourceHandleId:U,targetHandleId:Z,onContextMenu:D,onMouseEnter:v,onMouseMove:k,onMouseLeave:T,reconnectRadius:M,onReconnect:I,onReconnectStart:S,onReconnectEnd:b,markerEnd:F,markerStart:R,rfId:X,ariaLabel:Q,isFocusable:re,isReconnectable:J,pathOptions:fe,interactionWidth:V,disableKeyboardA11y:me})=>{const K=E.useRef(null),[C,B]=E.useState(!1),[te,q]=E.useState(!1),ae=Ye(),pe=E.useMemo(()=>`url('#${Hu(R,X)}')`,[R,X]),oe=E.useMemo(()=>`url('#${Hu(F,X)}')`,[F,X]);if(z)return null;const ee=he=>{var Me;const{edges:xe,addSelectedEdges:ke,unselectNodesAndEdges:Fe,multiSelectionActive:ye}=ae.getState(),tt=xe.find(ms=>ms.id===n);tt&&(j&&(ae.setState({nodesSelectionActive:!1}),tt.selected&&ye?(Fe({nodes:[],edges:[tt]}),(Me=K.current)==null||Me.blur()):ke([n])),i&&i(he,tt))},ge=Cs(n,ae.getState,l),de=Cs(n,ae.getState,D),H=Cs(n,ae.getState,v),$=Cs(n,ae.getState,k),G=Cs(n,ae.getState,T),Y=(he,xe)=>{if(he.button!==0)return;const{edges:ke,isValidConnection:Fe}=ae.getState(),ye=xe?g:p,tt=(xe?Z:U)||null,Me=xe?"target":"source",ms=Fe||RN,zl=xe,gs=ke.find(Yn=>Yn.id===n);q(!0),S==null||S(he,gs,Me);const Dl=Yn=>{q(!1),b==null||b(Yn,gs,Me)};Gg({event:he,handleId:tt,nodeId:ye,onConnect:Yn=>I==null?void 0:I(gs,Yn),isTarget:zl,getState:ae.getState,setState:ae.setState,isValidConnection:ms,edgeUpdaterType:Me,onReconnectEnd:Dl})},se=he=>Y(he,!0),le=he=>Y(he,!1),we=()=>B(!0),Ee=()=>B(!1),be=!j&&!i,ce=he=>{var xe;if(!me&&Og.includes(he.key)&&j){const{unselectNodesAndEdges:ke,addSelectedEdges:Fe,edges:ye}=ae.getState();he.key==="Escape"?((xe=K.current)==null||xe.blur(),ke({edges:[ye.find(Me=>Me.id===n)]})):Fe([n])}};return W.createElement("g",{className:et(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:a,animated:u,inactive:be,updating:C}]),onClick:ee,onDoubleClick:ge,onContextMenu:de,onMouseEnter:H,onMouseMove:$,onMouseLeave:G,onKeyDown:re?ce:void 0,tabIndex:re?0:void 0,role:re?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":Q===null?void 0:Q||`Edge from ${p} to ${g}`,"aria-describedby":re?`${t0}-${X}`:void 0,ref:K},!te&&W.createElement(e,{id:n,source:p,target:g,selected:a,animated:u,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:_,labelBgBorderRadius:x,data:o,style:N,sourceX:y,sourceY:w,targetX:P,targetY:L,sourcePosition:O,targetPosition:A,sourceHandleId:U,targetHandleId:Z,markerStart:pe,markerEnd:oe,pathOptions:fe,interactionWidth:V}),J&&W.createElement(W.Fragment,null,(J==="source"||J===!0)&&W.createElement(hp,{position:O,centerX:y,centerY:w,radius:M,onMouseDown:se,onMouseEnter:we,onMouseOut:Ee,type:"source"}),(J==="target"||J===!0)&&W.createElement(hp,{position:A,centerX:P,centerY:L,radius:M,onMouseDown:le,onMouseEnter:we,onMouseOut:Ee,type:"target"})))};return t.displayName="EdgeWrapper",E.memo(t)};function ON(e){const t={default:kr(e.default||dl),straight:kr(e.bezier||td),step:kr(e.step||ed),smoothstep:kr(e.step||jl),simplebezier:kr(e.simplebezier||Jc)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=kr(e[o]||dl),s),n);return{...t,...r}}function mp(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case ie.Top:return{x:r+o/2,y:s};case ie.Right:return{x:r+o,y:s+i/2};case ie.Bottom:return{x:r+o/2,y:s+i};case ie.Left:return{x:r,y:s+i/2}}}function gp(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const LN=(e,t,n,r,s,o)=>{const i=mp(n,e,t),l=mp(o,r,s);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function $N({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:i,height:l,transform:a}){const u={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+o)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const c=So({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:i/a[2],height:l/a[2]}),d=Math.max(0,Math.min(c.x2,u.x2)-Math.max(c.x,u.x)),f=Math.max(0,Math.min(c.y2,u.y2)-Math.max(c.y,u.y));return Math.ceil(d*f)>0}function yp(e){var r,s,o,i,l;const t=((r=e==null?void 0:e[De])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const BN=[{level:0,isMaxLevel:!0,edges:[]}];function jN(e,t,n=!1){let r=-1;const s=e.reduce((i,l)=>{var c,d;const a=Pt(l.zIndex);let u=a?l.zIndex:0;if(n){const f=t.get(l.target),h=t.get(l.source),_=l.selected||(f==null?void 0:f.selected)||(h==null?void 0:h.selected),x=Math.max(((c=h==null?void 0:h[De])==null?void 0:c.z)||0,((d=f==null?void 0:f[De])==null?void 0:d.z)||0,1e3);u=(a?l.zIndex:0)+(_?x:0)}return i[u]?i[u].push(l):i[u]=[l],r=u>r?u:r,i},{}),o=Object.entries(s).map(([i,l])=>{const a=+i;return{edges:l,level:a,isMaxLevel:a===r}});return o.length===0?BN:o}function FN(e,t,n){const r=Ie(E.useCallback(s=>e?s.edges.filter(o=>{const i=t.get(o.source),l=t.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&$N({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:l.width,targetHeight:l.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return jN(r,t,n)}const zN=({color:e="none",strokeWidth:t=1})=>W.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),DN=({color:e="none",strokeWidth:t=1})=>W.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),vp={[_r.Arrow]:zN,[_r.ArrowClosed]:DN};function UN(e){const t=Ye();return E.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(vp,e)?vp[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",vn.error009(e)),null)},[e])}const HN=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const a=UN(t);return a?W.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0"},W.createElement(a,{color:n,strokeWidth:i})):null},WN=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const l=Hu(i,t);r.includes(l)||(s.push({id:l,color:i.color||e,...i}),r.push(l))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},f0=({defaultColor:e,rfId:t})=>{const n=Ie(E.useCallback(WN({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,i)=>o.id!==s[i].id)));return W.createElement("defs",null,n.map(r=>W.createElement(HN,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};f0.displayName="MarkerDefinitions";var VN=E.memo(f0);const GN=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),p0=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:c,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:_,reconnectRadius:x,children:N,disableKeyboardA11y:p})=>{const{edgesFocusable:g,edgesUpdatable:y,elementsSelectable:w,width:P,height:L,connectionMode:O,nodeInternals:A,onError:j}=Ie(GN,Qe),z=FN(t,A,n);return P?W.createElement(W.Fragment,null,z.map(({level:U,edges:Z,isMaxLevel:D})=>W.createElement("svg",{key:U,style:{zIndex:U},width:P,height:L,className:"react-flow__edges react-flow__container"},D&&W.createElement(VN,{defaultColor:e,rfId:r}),W.createElement("g",null,Z.map(v=>{const[k,T,M]=yp(A.get(v.source)),[I,S,b]=yp(A.get(v.target));if(!M||!b)return null;let F=v.type||"default";s[F]||(j==null||j("011",vn.error011(F)),F="default");const R=s[F]||s.default,X=O===vr.Strict?S.target:(S.target??[]).concat(S.source??[]),Q=gp(T.source,v.sourceHandle),re=gp(X,v.targetHandle),J=(Q==null?void 0:Q.position)||ie.Bottom,fe=(re==null?void 0:re.position)||ie.Top,V=!!(v.focusable||g&&typeof v.focusable>"u"),me=v.reconnectable||v.updatable,K=typeof f<"u"&&(me||y&&typeof me>"u");if(!Q||!re)return j==null||j("008",vn.error008(Q,v)),null;const{sourceX:C,sourceY:B,targetX:te,targetY:q}=LN(k,Q,J,I,re,fe);return W.createElement(R,{key:v.id,id:v.id,className:et([v.className,o]),type:F,data:v.data,selected:!!v.selected,animated:!!v.animated,hidden:!!v.hidden,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,style:v.style,source:v.source,target:v.target,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerEnd:v.markerEnd,markerStart:v.markerStart,sourceX:C,sourceY:B,targetX:te,targetY:q,sourcePosition:J,targetPosition:fe,elementsSelectable:w,onContextMenu:i,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,onClick:c,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:_,reconnectRadius:x,rfId:r,ariaLabel:v.ariaLabel,isFocusable:V,isReconnectable:K,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth,disableKeyboardA11y:p})})))),N):null};p0.displayName="EdgeRenderer";var YN=E.memo(p0);const KN=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function XN({children:e}){const t=Ie(KN);return W.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function QN(e){const t=od(),n=E.useRef(!1);E.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const ZN={[ie.Left]:ie.Right,[ie.Right]:ie.Left,[ie.Top]:ie.Bottom,[ie.Bottom]:ie.Top},h0=({nodeId:e,handleType:t,style:n,type:r=Pn.Bezier,CustomComponent:s,connectionStatus:o})=>{var L,O,A;const{fromNode:i,handleId:l,toX:a,toY:u,connectionMode:c}=Ie(E.useCallback(j=>({fromNode:j.nodeInternals.get(e),handleId:j.connectionHandleId,toX:(j.connectionPosition.x-j.transform[0])/j.transform[2],toY:(j.connectionPosition.y-j.transform[1])/j.transform[2],connectionMode:j.connectionMode}),[e]),Qe),d=(L=i==null?void 0:i[De])==null?void 0:L.handleBounds;let f=d==null?void 0:d[t];if(c===vr.Loose&&(f=f||(d==null?void 0:d[t==="source"?"target":"source"])),!i||!f)return null;const h=l?f.find(j=>j.id===l):f[0],_=h?h.x+h.width/2:(i.width??0)/2,x=h?h.y+h.height/2:i.height??0,N=(((O=i.positionAbsolute)==null?void 0:O.x)??0)+_,p=(((A=i.positionAbsolute)==null?void 0:A.y)??0)+x,g=h==null?void 0:h.position,y=g?ZN[g]:null;if(!g||!y)return null;if(s)return W.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:h,fromX:N,fromY:p,toX:a,toY:u,fromPosition:g,toPosition:y,connectionStatus:o});let w="";const P={sourceX:N,sourceY:p,sourcePosition:g,targetX:a,targetY:u,targetPosition:y};return r===Pn.Bezier?[w]=Fg(P):r===Pn.Step?[w]=Uu({...P,borderRadius:0}):r===Pn.SmoothStep?[w]=Uu(P):r===Pn.SimpleBezier?[w]=jg(P):w=`M${N},${p} ${a},${u}`,W.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};h0.displayName="ConnectionLine";const qN=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function JN({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:i,width:l,height:a,connectionStatus:u}=Ie(qN,Qe);return!(s&&o&&l&&i)?null:W.createElement("svg",{style:e,width:l,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},W.createElement("g",{className:et(["react-flow__connection",u])},W.createElement(h0,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:u})))}function _p(e,t){return E.useRef(null),Ye(),E.useMemo(()=>t(e),[e])}const m0=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:a,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:_,onSelectionStart:x,onSelectionEnd:N,connectionLineType:p,connectionLineStyle:g,connectionLineComponent:y,connectionLineContainerStyle:w,selectionKeyCode:P,selectionOnDrag:L,selectionMode:O,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:z,deleteKeyCode:U,onlyRenderVisibleElements:Z,elementsSelectable:D,selectNodesOnDrag:v,defaultViewport:k,translateExtent:T,minZoom:M,maxZoom:I,preventScrolling:S,defaultMarkerColor:b,zoomOnScroll:F,zoomOnPinch:R,panOnScroll:X,panOnScrollSpeed:Q,panOnScrollMode:re,zoomOnDoubleClick:J,panOnDrag:fe,onPaneClick:V,onPaneMouseEnter:me,onPaneMouseMove:K,onPaneMouseLeave:C,onPaneScroll:B,onPaneContextMenu:te,onEdgeContextMenu:q,onEdgeMouseEnter:ae,onEdgeMouseMove:pe,onEdgeMouseLeave:oe,onReconnect:ee,onReconnectStart:ge,onReconnectEnd:de,reconnectRadius:H,noDragClassName:$,noWheelClassName:G,noPanClassName:Y,elevateEdgesOnSelect:se,disableKeyboardA11y:le,nodeOrigin:we,nodeExtent:Ee,rfId:be})=>{const ce=_p(e,CN),he=_p(t,ON);return QN(o),W.createElement(TN,{onPaneClick:V,onPaneMouseEnter:me,onPaneMouseMove:K,onPaneMouseLeave:C,onPaneContextMenu:te,onPaneScroll:B,deleteKeyCode:U,selectionKeyCode:P,selectionOnDrag:L,selectionMode:O,onSelectionStart:x,onSelectionEnd:N,multiSelectionKeyCode:A,panActivationKeyCode:j,zoomActivationKeyCode:z,elementsSelectable:D,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:F,zoomOnPinch:R,zoomOnDoubleClick:J,panOnScroll:X,panOnScrollSpeed:Q,panOnScrollMode:re,panOnDrag:fe,defaultViewport:k,translateExtent:T,minZoom:M,maxZoom:I,onSelectionContextMenu:_,preventScrolling:S,noDragClassName:$,noWheelClassName:G,noPanClassName:Y,disableKeyboardA11y:le},W.createElement(XN,null,W.createElement(YN,{edgeTypes:he,onEdgeClick:l,onEdgeDoubleClick:u,onlyRenderVisibleElements:Z,onEdgeContextMenu:q,onEdgeMouseEnter:ae,onEdgeMouseMove:pe,onEdgeMouseLeave:oe,onReconnect:ee,onReconnectStart:ge,onReconnectEnd:de,reconnectRadius:H,defaultMarkerColor:b,noPanClassName:Y,elevateEdgesOnSelect:!!se,disableKeyboardA11y:le,rfId:be},W.createElement(JN,{style:g,type:p,component:y,containerStyle:w})),W.createElement("div",{className:"react-flow__edgelabel-renderer"}),W.createElement(PN,{nodeTypes:ce,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,selectNodesOnDrag:v,onlyRenderVisibleElements:Z,noPanClassName:Y,noDragClassName:$,disableKeyboardA11y:le,nodeOrigin:we,nodeExtent:Ee,rfId:be})))};m0.displayName="GraphView";var eT=E.memo(m0);const Yu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],wn={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Yu,nodeExtent:Yu,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:vr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:CE,isValidConnection:void 0},tT=()=>U1((e,t)=>({...wn,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:Ea(n,r,s,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",i=s?Ea(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:l,domNode:a,nodeOrigin:u}=t(),c=a==null?void 0:a.querySelector(".react-flow__viewport");if(!c)return;const d=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(d.transform),h=n.reduce((x,N)=>{const p=s.get(N.id);if(p!=null&&p.hidden)s.set(p.id,{...p,[De]:{...p[De],handleBounds:void 0}});else if(p){const g=Zc(N.nodeElement);!!(g.width&&g.height&&(p.width!==g.width||p.height!==g.height||N.forceUpdate))&&(s.set(p.id,{...p,[De]:{...p[De],handleBounds:{source:fp(".source",N.nodeElement,f,u),target:fp(".target",N.nodeElement,f,u)}},...g}),x.push({id:p.id,type:"dimensions",dimensions:g}))}return x},[]);r0(s,u);const _=i||o&&!i&&s0(t,{initial:!0,...l});e({nodeInternals:new Map(s),fitViewOnInitDone:_}),(h==null?void 0:h.length)>0&&(r==null||r(h))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(l=>{const a={id:l.id,type:"position",dragging:s};return r&&(a.positionAbsolute=l.positionAbsolute,a.position=l.position),a});o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:i,getNodes:l,elevateNodesOnSelect:a}=t();if(n!=null&&n.length){if(o){const u=gN(n,l()),c=Ea(u,s,i,a);e({nodeInternals:c})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let i,l=null;r?i=n.map(a=>Cn(a,!0)):(i=Ur(o(),n),l=Ur(s,[])),oi({changedNodes:i,changedEdges:l,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let i,l=null;r?i=n.map(a=>Cn(a,!0)):(i=Ur(s,n),l=Ur(o(),[])),oi({changedNodes:l,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),i=n||o(),l=r||s,a=i.map(c=>(c.selected=!1,Cn(c.id,!1))),u=l.map(c=>Cn(c.id,!1));oi({changedNodes:a,changedEdges:u,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(l=>l.selected).map(l=>Cn(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Cn(l.id,!1));oi({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=qc(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:i,d3Selection:l,translateExtent:a}=t();if(!i||!l||!n.x&&!n.y)return!1;const u=fn.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),c=[[0,0],[s,o]],d=i==null?void 0:i.constrain()(u,c,a);return i.transform(l,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:wn.connectionNodeId,connectionHandleId:wn.connectionHandleId,connectionHandleType:wn.connectionHandleType,connectionStatus:wn.connectionStatus,connectionStartHandle:wn.connectionStartHandle,connectionEndHandle:wn.connectionEndHandle}),reset:()=>e({...wn})}),Object.is),g0=({children:e})=>{const t=E.useRef(null);return t.current||(t.current=tT()),W.createElement(xE,{value:t.current},e)};g0.displayName="ReactFlowProvider";const y0=({children:e})=>E.useContext(Bl)?W.createElement(W.Fragment,null,e):W.createElement(g0,null,e);y0.displayName="ReactFlowWrapper";const nT={input:Qg,default:Vu,output:qg,group:sd},rT={default:dl,straight:td,step:ed,smoothstep:jl,simplebezier:Jc},sT=[0,0],oT=[15,15],iT={x:0,y:0,zoom:1},lT={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},v0=E.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=nT,edgeTypes:i=rT,onNodeClick:l,onEdgeClick:a,onInit:u,onMove:c,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:_,onConnectEnd:x,onClickConnectStart:N,onClickConnectEnd:p,onNodeMouseEnter:g,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:P,onNodeDoubleClick:L,onNodeDragStart:O,onNodeDrag:A,onNodeDragStop:j,onNodesDelete:z,onEdgesDelete:U,onSelectionChange:Z,onSelectionDragStart:D,onSelectionDrag:v,onSelectionDragStop:k,onSelectionContextMenu:T,onSelectionStart:M,onSelectionEnd:I,connectionMode:S=vr.Strict,connectionLineType:b=Pn.Bezier,connectionLineStyle:F,connectionLineComponent:R,connectionLineContainerStyle:X,deleteKeyCode:Q="Backspace",selectionKeyCode:re="Shift",selectionOnDrag:J=!1,selectionMode:fe=Eo.Full,panActivationKeyCode:V="Space",multiSelectionKeyCode:me=cl()?"Meta":"Control",zoomActivationKeyCode:K=cl()?"Meta":"Control",snapToGrid:C=!1,snapGrid:B=oT,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:q=!0,nodesDraggable:ae,nodesConnectable:pe,nodesFocusable:oe,nodeOrigin:ee=sT,edgesFocusable:ge,edgesUpdatable:de,elementsSelectable:H,defaultViewport:$=iT,minZoom:G=.5,maxZoom:Y=2,translateExtent:se=Yu,preventScrolling:le=!0,nodeExtent:we,defaultMarkerColor:Ee="#b1b1b7",zoomOnScroll:be=!0,zoomOnPinch:ce=!0,panOnScroll:he=!1,panOnScrollSpeed:xe=.5,panOnScrollMode:ke=ir.Free,zoomOnDoubleClick:Fe=!0,panOnDrag:ye=!0,onPaneClick:tt,onPaneMouseEnter:Me,onPaneMouseMove:ms,onPaneMouseLeave:zl,onPaneScroll:gs,onPaneContextMenu:Dl,children:ld,onEdgeContextMenu:Yn,onEdgeDoubleClick:E0,onEdgeMouseEnter:N0,onEdgeMouseMove:T0,onEdgeMouseLeave:k0,onEdgeUpdate:C0,onEdgeUpdateStart:I0,onEdgeUpdateEnd:b0,onReconnect:P0,onReconnectStart:A0,onReconnectEnd:M0,reconnectRadius:R0=10,edgeUpdaterRadius:O0=10,onNodesChange:L0,onEdgesChange:$0,noDragClassName:B0="nodrag",noWheelClassName:j0="nowheel",noPanClassName:ad="nopan",fitView:F0=!1,fitViewOptions:z0,connectOnClick:D0=!0,attributionPosition:U0,proOptions:H0,defaultEdgeOptions:W0,elevateNodesOnSelect:V0=!0,elevateEdgesOnSelect:G0=!1,disableKeyboardA11y:ud=!1,autoPanOnConnect:Y0=!0,autoPanOnNodeDrag:K0=!0,connectionRadius:X0=20,isValidConnection:Q0,onError:Z0,style:q0,id:cd,nodeDragThreshold:J0,...ey},ty)=>{const Ul=cd||"1";return W.createElement("div",{...ey,style:{...q0,...lT},ref:ty,className:et(["react-flow",s]),"data-testid":"rf__wrapper",id:cd},W.createElement(y0,null,W.createElement(eT,{onInit:u,onMove:c,onMoveStart:d,onMoveEnd:f,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:g,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:P,onNodeDoubleClick:L,nodeTypes:o,edgeTypes:i,connectionLineType:b,connectionLineStyle:F,connectionLineComponent:R,connectionLineContainerStyle:X,selectionKeyCode:re,selectionOnDrag:J,selectionMode:fe,deleteKeyCode:Q,multiSelectionKeyCode:me,panActivationKeyCode:V,zoomActivationKeyCode:K,onlyRenderVisibleElements:te,selectNodesOnDrag:q,defaultViewport:$,translateExtent:se,minZoom:G,maxZoom:Y,preventScrolling:le,zoomOnScroll:be,zoomOnPinch:ce,zoomOnDoubleClick:Fe,panOnScroll:he,panOnScrollSpeed:xe,panOnScrollMode:ke,panOnDrag:ye,onPaneClick:tt,onPaneMouseEnter:Me,onPaneMouseMove:ms,onPaneMouseLeave:zl,onPaneScroll:gs,onPaneContextMenu:Dl,onSelectionContextMenu:T,onSelectionStart:M,onSelectionEnd:I,onEdgeContextMenu:Yn,onEdgeDoubleClick:E0,onEdgeMouseEnter:N0,onEdgeMouseMove:T0,onEdgeMouseLeave:k0,onReconnect:P0??C0,onReconnectStart:A0??I0,onReconnectEnd:M0??b0,reconnectRadius:R0??O0,defaultMarkerColor:Ee,noDragClassName:B0,noWheelClassName:j0,noPanClassName:ad,elevateEdgesOnSelect:G0,rfId:Ul,disableKeyboardA11y:ud,nodeOrigin:ee,nodeExtent:we}),W.createElement(QE,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:_,onConnectEnd:x,onClickConnectStart:N,onClickConnectEnd:p,nodesDraggable:ae,nodesConnectable:pe,nodesFocusable:oe,edgesFocusable:ge,edgesUpdatable:de,elementsSelectable:H,elevateNodesOnSelect:V0,minZoom:G,maxZoom:Y,nodeExtent:we,onNodesChange:L0,onEdgesChange:$0,snapToGrid:C,snapGrid:B,connectionMode:S,translateExtent:se,connectOnClick:D0,defaultEdgeOptions:W0,fitView:F0,fitViewOptions:z0,onNodesDelete:z,onEdgesDelete:U,onNodeDragStart:O,onNodeDrag:A,onNodeDragStop:j,onSelectionDrag:v,onSelectionDragStart:D,onSelectionDragStop:k,noPanClassName:ad,nodeOrigin:ee,rfId:Ul,autoPanOnConnect:Y0,autoPanOnNodeDrag:K0,onError:Z0,connectionRadius:X0,isValidConnection:Q0,nodeDragThreshold:J0}),W.createElement(KE,{onSelectionChange:Z}),ld,W.createElement(SE,{proOptions:H0,position:U0}),W.createElement(tN,{rfId:Ul,disableKeyboardA11y:ud})))});v0.displayName="ReactFlow";const _0=({id:e,x:t,y:n,width:r,height:s,style:o,color:i,strokeColor:l,strokeWidth:a,className:u,borderRadius:c,shapeRendering:d,onClick:f,selected:h})=>{const{background:_,backgroundColor:x}=o||{},N=i||_||x;return W.createElement("rect",{className:et(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:c,ry:c,width:r,height:s,fill:N,stroke:l,strokeWidth:a,shapeRendering:d,onClick:f?p=>f(p,e):void 0})};_0.displayName="MiniMapNode";var aT=E.memo(_0);const uT=e=>e.nodeOrigin,cT=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Ca=e=>e instanceof Function?e:()=>e;function dT({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=aT,onClick:i}){const l=Ie(cT,Qe),a=Ie(uT),u=Ca(t),c=Ca(e),d=Ca(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return W.createElement(W.Fragment,null,l.map(h=>{const{x:_,y:x}=cr(h,a).positionAbsolute;return W.createElement(o,{key:h.id,x:_,y:x,width:h.width,height:h.height,style:h.style,selected:h.selected,className:d(h),color:u(h),borderRadius:r,strokeColor:c(h),strokeWidth:s,shapeRendering:f,onClick:i,id:h.id})}))}var fT=E.memo(dT);const pT=200,hT=150,mT=e=>{const t=e.getNodes(),n={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:n,boundingRect:t.length>0?TE(Fl(t,e.nodeOrigin),n):n,rfId:e.rfId}},gT="react-flow__minimap-desc";function x0({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:l,maskColor:a="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:c=1,position:d="bottom-right",onClick:f,onNodeClick:h,pannable:_=!1,zoomable:x=!1,ariaLabel:N="React Flow mini map",inversePan:p=!1,zoomStep:g=10,offsetScale:y=5}){const w=Ye(),P=E.useRef(null),{boundingRect:L,viewBB:O,rfId:A}=Ie(mT,Qe),j=(e==null?void 0:e.width)??pT,z=(e==null?void 0:e.height)??hT,U=L.width/j,Z=L.height/z,D=Math.max(U,Z),v=D*j,k=D*z,T=y*D,M=L.x-(v-L.width)/2-T,I=L.y-(k-L.height)/2-T,S=v+T*2,b=k+T*2,F=`${gT}-${A}`,R=E.useRef(0);R.current=D,E.useEffect(()=>{if(P.current){const re=It(P.current),J=me=>{const{transform:K,d3Selection:C,d3Zoom:B}=w.getState();if(me.sourceEvent.type!=="wheel"||!C||!B)return;const te=-me.sourceEvent.deltaY*(me.sourceEvent.deltaMode===1?.05:me.sourceEvent.deltaMode?1:.002)*g,q=K[2]*Math.pow(2,te);B.scaleTo(C,q)},fe=me=>{const{transform:K,d3Selection:C,d3Zoom:B,translateExtent:te,width:q,height:ae}=w.getState();if(me.sourceEvent.type!=="mousemove"||!C||!B)return;const pe=R.current*Math.max(1,K[2])*(p?-1:1),oe={x:K[0]-me.sourceEvent.movementX*pe,y:K[1]-me.sourceEvent.movementY*pe},ee=[[0,0],[q,ae]],ge=fn.translate(oe.x,oe.y).scale(K[2]),de=B.constrain()(ge,ee,te);B.transform(C,de)},V=Ig().on("zoom",_?fe:null).on("zoom.wheel",x?J:null);return re.call(V),()=>{re.on("zoom",null)}}},[_,x,p,g]);const X=f?re=>{const J=jt(re);f(re,{x:J[0],y:J[1]})}:void 0,Q=h?(re,J)=>{const fe=w.getState().nodeInternals.get(J);h(re,fe)}:void 0;return W.createElement(Qc,{position:d,style:e,className:et(["react-flow__minimap",t]),"data-testid":"rf__minimap"},W.createElement("svg",{width:j,height:z,viewBox:`${M} ${I} ${S} ${b}`,role:"img","aria-labelledby":F,ref:P,onClick:X},N&&W.createElement("title",{id:F},N),W.createElement(fT,{onClick:Q,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),W.createElement("path",{className:"react-flow__minimap-mask",d:`M${M-T},${I-T}h${S+T*2}v${b+T*2}h${-S-T*2}z + M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fill:a,fillRule:"evenodd",stroke:u,strokeWidth:c,pointerEvents:"none"})))}x0.displayName="MiniMap";var yT=E.memo(x0);function vT(){return W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},W.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function _T(){return W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},W.createElement("path",{d:"M0 0h32v4.2H0z"}))}function xT(){return W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},W.createElement("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 wT(){return W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},W.createElement("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 ST(){return W.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},W.createElement("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"}))}const Hr=({children:e,className:t,...n})=>W.createElement("button",{type:"button",className:et(["react-flow__controls-button",t]),...n},e);Hr.displayName="ControlButton";const ET=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),w0=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:i,onFitView:l,onInteractiveChange:a,className:u,children:c,position:d="bottom-left"})=>{const f=Ye(),[h,_]=E.useState(!1),{isInteractive:x,minZoomReached:N,maxZoomReached:p}=Ie(ET,Qe),{zoomIn:g,zoomOut:y,fitView:w}=od();if(E.useEffect(()=>{_(!0)},[]),!h)return null;const P=()=>{g(),o==null||o()},L=()=>{y(),i==null||i()},O=()=>{w(s),l==null||l()},A=()=>{f.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),a==null||a(!x)};return W.createElement(Qc,{className:et(["react-flow__controls",u]),position:d,style:e,"data-testid":"rf__controls"},t&&W.createElement(W.Fragment,null,W.createElement(Hr,{onClick:P,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:p},W.createElement(vT,null)),W.createElement(Hr,{onClick:L,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:N},W.createElement(_T,null))),n&&W.createElement(Hr,{className:"react-flow__controls-fitview",onClick:O,title:"fit view","aria-label":"fit view"},W.createElement(xT,null)),r&&W.createElement(Hr,{className:"react-flow__controls-interactive",onClick:A,title:"toggle interactivity","aria-label":"toggle interactivity"},x?W.createElement(ST,null):W.createElement(wT,null)),c)};w0.displayName="Controls";var NT=E.memo(w0),Wt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Wt||(Wt={}));function TT({color:e,dimensions:t,lineWidth:n}){return W.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function kT({color:e,radius:t}){return W.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const CT={[Wt.Dots]:"#91919a",[Wt.Lines]:"#eee",[Wt.Cross]:"#e2e2e2"},IT={[Wt.Dots]:1,[Wt.Lines]:1,[Wt.Cross]:6},bT=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function S0({id:e,variant:t=Wt.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:i,style:l,className:a}){const u=E.useRef(null),{transform:c,patternId:d}=Ie(bT,Qe),f=i||CT[t],h=r||IT[t],_=t===Wt.Dots,x=t===Wt.Cross,N=Array.isArray(n)?n:[n,n],p=[N[0]*c[2]||1,N[1]*c[2]||1],g=h*c[2],y=x?[g,g]:p,w=_?[g/o,g/o]:[y[0]/o,y[1]/o];return W.createElement("svg",{className:et(["react-flow__background",a]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},W.createElement("pattern",{id:d+e,x:c[0]%p[0],y:c[1]%p[1],width:p[0],height:p[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},_?W.createElement(kT,{color:f,radius:g/o}):W.createElement(TT,{dimensions:y,color:f,lineWidth:s})),W.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}S0.displayName="Background";var PT=E.memo(S0);const Ia=320,ba=120,xp=["#94a3b8","#60a5fa","#22d3ee","#34d399"],AT=["rgba(226, 232, 240, 0.28)","rgba(219, 234, 254, 0.28)","rgba(207, 250, 254, 0.28)","rgba(209, 250, 229, 0.24)"],MT=88,RT=120,OT=72,LT=58,st=100,Ne=30,tr=96,Pa=22,Aa=6,wp=10,$T=20,Sp=240,li=300,Ma=168,Ra=74,Ep=58,Ps=48,BT=87,jT=26,FT=30,zT=.36,DT=240,UT=.35,HT=1.8,WT=st*2+tr+60;function VT(e,t,n){const r=Math.min(176,Math.max(104,e.length*7.4)),s=Math.min(112,Math.max(66,n(t).length*6.1+14));return r+s+BT+jT}function GT(e,t,n){const r=Math.min(220,Math.max(96,e.length*8)),s=Math.min(122,Math.max(66,n(t).length*6.1+14));return r+s+FT}function ai(e,t,n,r){return e<=0?r:e*t+Math.max(0,e-1)*n+r}function ui(e,t=40){return e.length<=t?e:`${e.slice(0,Math.max(1,t-1))}…`}function Ku(e){const t=$e(e),n=t.split("/");return n.length<=3?t:`${n[n.length-2]}/${n[n.length-1]}`}function As(e){const t=e.split(".");return t[t.length-1]||e}function En(e,t){const n=e.trim().length>0?e.trim():Ku(t),r=n.split("/");return r.length>0?r[r.length-1]??n:n}function ft(e){if(!e)return null;const t=e.replace(/^builtins\./,""),n=t.split("."),r=n.length>0?n[n.length-1]:t;return r.length<=16?r:`${r.slice(0,15)}…`}function bi(e){const t=e.split("/");return t.length<=2?e:t.slice(Math.max(0,t.length-3)).join("/")}function Oa(e,t,n){return[e,t,n].join(` +`)}function Kn(e,t){const n=[e.address];return e.msgType&&n.push(`Message Type: ${e.msgType}`),t==="collection"&&e.collectionKind==="topic"&&n.push("Collection Topic"),t==="collection"&&e.collectionKind==="relay"&&n.push("Collection Relay"),n.join(` +`)}function Ms(e,t,n){return n==="collection"&&e.collectionKind?"mono topology-stream-label is-collection":`mono topology-stream-label ${t}`}function Rs(e,t,n,r){return n==="collection"&&e.collectionKind?e.collectionKind==="topic"?t==="is-output"?{border:r?"1px solid #fb923c":"1px solid #f28e2b",background:r?"#2e1f10":"#fff1dd",color:r?"#fed7aa":"#8a4f10",borderRadius:999}:t==="is-input"?{border:r?"1px solid #f59e0b":"1px solid #f6a44d",background:r?"#2a2115":"#fff8ef",color:r?"#fdba74":"#8a4f10",borderRadius:999}:{border:r?"1px solid #fb923c":"1px solid #f8b66f",background:r?"#2a2115":"#fff8ef",color:r?"#fdba74":"#8a4f10",borderRadius:10}:t==="is-output"?{border:r?"1px solid #d8b4fe":"1px solid #b07aa1",background:r?"#2a1d3a":"#f8eef5",color:r?"#e9d5ff":"#6f3f66",borderRadius:999}:t==="is-input"?{border:r?"1px solid #c084fc":"1px solid #c194b7",background:r?"#251b33":"#fbf3f8",color:r?"#e9d5ff":"#6f3f66",borderRadius:999}:{border:r?"1px solid #c084fc":"1px solid #d3accb",background:r?"#251b33":"#fbf3f8",color:r?"#e9d5ff":"#6f3f66",borderRadius:10}:{border:t==="is-input"?r?"1px solid #818cf8":"1px solid #c7d2fe":t==="is-output"?r?"1px solid #22d3ee":"1px solid #7dd3fc":r?"1px solid #4b5563":"1px solid #cbd5e1",background:t==="is-input"?r?"#1d2644":"#eef2ff":t==="is-output"?r?"#0f2e37":"#ecfeff":r?"#182235":"#f8fafc",color:r?"#dbeafe":"#1e293b",borderRadius:t==="is-unknown"?8:999}}function Wr(e){return e.trim().toUpperCase().replace(/^INPUT_/,"").replace(/^OUTPUT_/,"").replace(/^TOPIC_/,"")}function YT(e){const t=new Set,n=new Map,r=new Map;for(const s of e){t.add(s.address);const o=$e(s.address);n.set(o,s.address),r.set(Wr(s.name),s.address),r.set(Wr(En(s.name,s.address)),s.address),r.set(Wr(o),s.address);const i=o.split("/").pop();i&&r.set(Wr(i),s.address)}return{addressSet:t,withoutEndpointMap:n,normalizedNameMap:r}}function KT(e,t,n,r,s,o,i){const l=s+8,a=s+o,u=Math.max(l,Math.min(i-Ne-10,a-Ne-8)),c=Math.max(l,Math.min(u,Math.floor((i-Ne)/2))),d=e.map(N=>{const p=t.get(N),g=n.get(N);if(!p||!g)return null;const y=p.y-r;return{top:y,bottom:y+g.height}}).filter(N=>N!==null).sort((N,p)=>N.top-p.top);if(d.length===0)return c;let f=c,h=-1,_=l;for(const N of d){const p=N.top-_;p>=Ne+8&&p>h&&(h=p,f=_+Math.floor((p-Ne)/2)),_=Math.max(_,N.bottom)}const x=a-_;return x>=Ne+8&&x>h&&(f=_+Math.floor((x-Ne)/2)),Math.max(l,Math.min(u,f))}function ci(e,t){if(!e)return null;if(t.addressSet.has(e))return e;if(t.withoutEndpointMap.has(e))return t.withoutEndpointMap.get(e)??null;const n=e.split(":")[0];if(t.withoutEndpointMap.has(n))return t.withoutEndpointMap.get(n)??null;const r=Wr(e);if(t.normalizedNameMap.has(r))return t.normalizedNameMap.get(r)??null;const s=Wr(n.split("/").pop()??"");if(t.normalizedNameMap.has(s))return t.normalizedNameMap.get(s)??null;for(const o of t.addressSet)if(o.startsWith(`${e}:`)||o.startsWith(`${n}:`))return o;return null}function XT(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)}function QT(e){if(!Array.isArray(e.nodes)||!Array.isArray(e.edges))return!1;const t=new Set;for(const n of e.nodes)if(!n||typeof n.id!="string"||n.id.length===0||t.has(n.id)||(t.add(n.id),!XT(n.position)))return!1;for(const n of e.nodes)if(typeof n.parentNode=="string"&&!t.has(n.parentNode))return!1;for(const n of e.edges)if(!n||typeof n.source!="string"||typeof n.target!="string"||!t.has(n.source)||!t.has(n.target))return!1;return!0}function ZT(e,t,n,r,s,o){var me,K;const i=r==="orthogonal"?"step":r==="smooth"?"smoothstep":"default",{units:l,collections:a}=Hc(e),u=Pl(a),c=Iu(l,a,n),d=new Map,f=new Map;for(const C of c){const B=l.get(C);if(B){d.set(C,B);continue}const te=a.get(C);te&&f.set(C,te)}const h=new Set(d.keys()),_=new Set(f.keys()),x=Al(a),N=n?a.get(n)??null:null,p=N?`scope:${N.address}`:null,g=new Map,y=new Map;for(const C of l.values())for(const B of C.streams)g.set(B.address,C.address),g.set($e(B.address),C.address);for(const C of a.values())for(const B of C.streams)y.set(B.address,C.address),y.set($e(B.address),C.address);for(const[C,B]of u.collectionByInternalTopic.entries())y.set(C,B);const w=new Map;for(const C of l.values())for(const B of C.streams)w.set(B.address,B.address),w.set($e(B.address),B.address);for(const C of a.values())for(const B of C.streams)w.set(B.address,B.address),w.set($e(B.address),B.address);for(const[C,B]of u.endpointByInternalTopic.entries())w.set(C,B);const P=C=>w.get(C)??w.get($e(C))??C,L=[];for(const[C,B]of Object.entries(e.graph))for(const te of B){const q=P(C),ae=P(te);q!==ae&&L.push({from:q,to:ae})}const O=new Map,A=(C,B)=>{O.set(C,B),O.set($e(C),B)};for(const C of d.values())for(const B of C.streams)A(B.address,{ownerId:`unit:${C.address}`,ownerKind:"unit"});for(const C of f.values())for(const B of C.streams)A(B.address,{ownerId:`collection:${C.address}`,ownerKind:"collection"});const j=new Set(O.keys()),z=L.filter(C=>j.has(C.from)||j.has(C.to)),U=new Set(j);for(const C of z)U.add(C.from),U.add(C.to);const Z=new Set,D=new Map;for(const C of d.values()){const B=`unit:${C.address}`;Z.add(B),D.set(B,C.name)}for(const C of f.values()){const B=`collection:${C.address}`;Z.add(B),D.set(B,C.name)}for(const C of U){if(O.has(C))continue;const B=y.get(C),te=g.get(C);if(B&&_.has(B)){A(C,{ownerId:`collection:${B}`,ownerKind:"collection"});continue}if(te&&h.has(te)){A(C,{ownerId:`unit:${te}`,ownerKind:"unit"});continue}if(N&&p&&(B&&bu(B,N.address,x)||te&&bu(te,N.address,x))){A(C,{ownerId:p,ownerKind:"scope_collection"});continue}const q=te??B??null;if(q){let pe=x.get(q)??null;for(;pe;){if(_.has(pe)){A(C,{ownerId:`collection:${pe}`,ownerKind:"collection_proxy"});break}pe=x.get(pe)??null}if(O.has(C))continue}const ae=`orphan:${C}`;A(C,{ownerId:ae,ownerKind:"orphan"}),Z.add(ae),D.set(ae,Ku(C))}const v=[],k=new Set;for(const C of z){const B=(me=O.get(C.from))==null?void 0:me.ownerId,te=(K=O.get(C.to))==null?void 0:K.ownerId;if(!B||!te||B===te||!Z.has(B)||!Z.has(te))continue;const q=`${B}->${te}`;k.has(q)||(k.add(q),v.push({from:B,to:te}))}const T=Array.from(Z).sort((C,B)=>{const te=D.get(C)??C,q=D.get(B)??B;return te.localeCompare(q)}),M=Y_(T,v),I=new Map;for(const C of T){const B=M.get(C)??0,te=I.get(B);te?te.push(C):I.set(B,[C])}const S=new Map;for(const C of d.values()){const B=C.streams.filter(G=>G.direction==="input").length,te=C.streams.filter(G=>G.direction==="output").length,q=C.streams.filter(G=>G.direction==="unknown").length,ae=C.tasks.length,pe=Math.max(1,B,te,ae,q),oe=GT(C.name,C.componentType,As),ee=ai(pe,st,Aa,22),ge=ai(ae,tr,wp,$T),de=t==="lr"?Math.max(WT,oe):Math.max(220,oe,ee,ge);if(t==="lr"){const G=Math.max(1,B,te,ae),Y=Math.max(126,Ps+16+G*30+(q>0?Ne+12:0)+12);S.set(`unit:${C.address}`,{width:de,height:Y});continue}const H=Math.max(1,(B>0?1:0)+(ae>0?1:0)+(q>0?1:0)+(te>0?1:0)),$=Math.max(216,Ps+18+H*Ne+Math.max(0,H-1)*12+16);S.set(`unit:${C.address}`,{width:de,height:$})}for(const C of f.values()){const B=C.streams.filter(de=>de.direction==="input").length,te=C.streams.filter(de=>de.direction==="output").length,q=C.streams.filter(de=>de.direction==="unknown").length,ae=Math.max(1,B,te,q),pe=Math.max(t==="lr"?li:300,ai(ae,st,Aa,22)),oe=VT(C.name,C.componentType,As),ee=Math.max(pe,oe),ge=t==="lr"?Math.max(124,Ra+16+Math.max(1,B,te)*30+(q>0?Ne+12:0)+12):Math.max(176,Ra+14+Math.max(1,(B>0?1:0)+(q>0?1:0)+(te>0?1:0))*Ne+12);S.set(`collection:${C.address}`,{width:ee,height:ge})}for(const C of T)S.has(C)||S.set(C,{width:Sp,height:74});const b=new Map,F=Array.from(I.keys()).sort((C,B)=>C-B);if(t==="tb"){let C=28;for(const B of F){const te=I.get(B)??[];let q=24,ae=0;for(const pe of te){const oe=S.get(pe)??{width:Ia,height:ba};b.set(pe,{x:q,y:C}),q+=oe.width+OT,ae=Math.max(ae,oe.height)}C+=ae+MT}}else{let C=24;for(const B of F){const te=I.get(B)??[];let q=28,ae=0;for(const pe of te){const oe=S.get(pe)??{width:Ia,height:ba};b.set(pe,{x:C,y:q}),q+=oe.height+LT,ae=Math.max(ae,oe.width)}C+=ae+RT}}const R=[],X=[],Q={stroke:s?"#8fa3bc":"#475569",strokeWidth:1.5},re={type:_r.ArrowClosed,width:12,height:12,color:s?"#8fa3bc":"#475569"};function J(C,B,te,q,ae,pe,oe,ee){if(te.length===0)return;const ge=B.width-22,de=te.length*st,H=te.length>1?Math.max(6,Math.min(16,Math.floor((ge-de)/(te.length-1)))):0,$=de+H*Math.max(0,te.length-1),G=11+Math.max(0,Math.floor((ge-$)/2));te.forEach((Y,se)=>{const le=Rs(Y,ae,pe,s),we=G+se*(st+H);ee.push({id:`stream:${Y.address}`,parentNode:C,extent:"parent",draggable:!1,data:{label:m.jsxs("span",{className:Ms(Y,ae,pe),title:Kn(Y,pe),children:[m.jsx("span",{className:"topology-stream-name",children:En(Y.name,Y.address)}),ft(Y.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(Y.msgType),"]"]}):null]})},position:{x:we,y:q},sourcePosition:oe==="tb"?ie.Bottom:ie.Right,targetPosition:oe==="tb"?ie.Top:ie.Left,style:{width:st,height:Ne,borderRadius:le.borderRadius,border:le.border,background:le.background,color:le.color,fontSize:8,padding:"0 6px"}})})}if(N&&p){const C=T.filter(he=>he.startsWith("unit:")||he.startsWith("collection:"));let B=24,te=32,q=24+li,ae=32+Ma;if(C.length>0){B=Number.POSITIVE_INFINITY,te=Number.POSITIVE_INFINITY,q=Number.NEGATIVE_INFINITY,ae=Number.NEGATIVE_INFINITY;for(const he of C){const xe=b.get(he),ke=S.get(he);!xe||!ke||(B=Math.min(B,xe.x),te=Math.min(te,xe.y),q=Math.max(q,xe.x+ke.width),ae=Math.max(ae,xe.y+ke.height))}(!Number.isFinite(B)||!Number.isFinite(te))&&(B=24,te=32,q=24+li,ae=32+Ma)}const pe=N.streams.filter(he=>he.direction==="input"),oe=N.streams.filter(he=>he.direction==="output"),ee=N.streams.filter(he=>he.direction==="unknown"),ge=Math.max(1,pe.length,oe.length,ee.length),de=ai(ge,st,Aa,24),H=pe.length>0,$=oe.length>0,G=t==="lr"?72:76,Y=t==="lr"?108:64,se=28,le=t==="lr"?Math.max(Y,G+Math.max(1,pe.length,oe.length)*30+(ee.length>0?Ne+10:0)+8):H?Math.max(Y,G+Ne+8):Y,we=t==="tb"?$?Math.max(Ep,Ne+20):20:Ep,Ee=Math.max(0,ae-te),be={x:B-se,y:te-le},ce={width:Math.max(360,q-B+se*2,de+se*2),height:Math.max(180,Ee+le+we)};if(C.length>0){const he=(B+q)/2,xe=be.x+se,ke=be.x+ce.width-se,Fe=(xe+ke)/2,ye=Math.round(Fe-he);if(ye!==0)for(const tt of C){const Me=b.get(tt);Me&&b.set(tt,{x:Me.x+ye,y:Me.y})}}if(R.push({id:p,position:be,sourcePosition:t==="tb"?ie.Bottom:ie.Right,targetPosition:t==="tb"?ie.Top:ie.Left,data:{label:m.jsxs("div",{className:"topology-collection-label topology-collection-label--scope",title:Oa(N.name,N.address,N.componentType),children:[m.jsxs("span",{className:"topology-title-row topology-title-row--collection",children:[m.jsxs("span",{className:"topology-title-row",children:[m.jsx("strong",{children:N.name}),m.jsx("span",{className:"topology-unit-type",title:N.componentType,children:As(N.componentType)})]}),m.jsx("button",{type:"button","data-scope-up":"true",className:"topology-collection-scope-up-btn nodrag nopan",title:"Go up one scope","aria-label":`Go up from ${N.name}`,onPointerDown:he=>{he.stopPropagation()},onMouseDown:he=>{he.stopPropagation()},onClick:he=>{var xe;he.stopPropagation(),(xe=o==null?void 0:o.goUpFromScope)==null||xe.call(o,N.address)},children:"↑ Up"})]}),m.jsx("span",{className:"mono",children:bi(N.address)})]})},style:{width:ce.width,height:ce.height,border:`2px dashed ${s?"#4b647e":xp[0]}`,borderRadius:14,background:s?"rgba(15, 23, 42, 0.45)":"rgba(226, 232, 240, 0.24)",color:s?"#e2e8f0":"#0f172a",padding:10,zIndex:-1},draggable:!1,selectable:!1}),t==="lr"){const ke=Math.max(1,pe.length,oe.length)*30,Fe=Math.max(G,le-ke-8);pe.forEach((ye,tt)=>{const Me=Rs(ye,"is-input","collection",s);R.push({id:`stream:${ye.address}`,parentNode:p,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsxs("span",{className:Ms(ye,"is-input","collection"),title:Kn(ye,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(ye.name,ye.address)}),ft(ye.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(ye.msgType),"]"]}):null]})},position:{x:12,y:Fe+tt*30},style:{width:st,height:Ne,borderRadius:Me.borderRadius,border:Me.border,background:Me.background,color:Me.color,padding:"0 6px"}})}),oe.forEach((ye,tt)=>{const Me=Rs(ye,"is-output","collection",s);R.push({id:`stream:${ye.address}`,parentNode:p,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsxs("span",{className:Ms(ye,"is-output","collection"),title:Kn(ye,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(ye.name,ye.address)}),ft(ye.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(ye.msgType),"]"]}):null]})},position:{x:ce.width-st-12,y:Fe+tt*30},style:{width:st,height:Ne,borderRadius:Me.borderRadius,border:Me.border,background:Me.background,color:Me.color,padding:"0 6px"}})}),ee.length>0&&J(p,ce,ee,56+Math.max(pe.length,oe.length)*30+4,"is-unknown","collection",t,R)}else{const he=Math.max(G,le-Ne-8),xe=le+Ee,ke=Math.min(ce.height-Ne-10,xe+Math.max(6,Math.floor((we-Ne)/2)));if(J(p,ce,pe,he,"is-input","collection",t,R),J(p,ce,oe,ke,"is-output","collection",t,R),ee.length>0){const Fe=KT(C,b,S,be.y,le,Ee,ce.height);J(p,ce,ee,Fe,"is-unknown","collection",t,R)}}}for(const C of f.values()){const B=`collection:${C.address}`,te=b.get(B)??{x:0,y:0},q=S.get(B)??{width:li,height:Ma};R.push({id:B,position:te,sourcePosition:t==="tb"?ie.Bottom:ie.Right,targetPosition:t==="tb"?ie.Top:ie.Left,data:{label:m.jsxs("div",{className:"topology-collection-label",title:Oa(C.name,C.address,C.componentType),children:[m.jsxs("span",{className:"topology-title-row topology-title-row--collection",children:[m.jsxs("span",{className:"topology-title-row",children:[m.jsx("strong",{children:C.name}),m.jsx("span",{className:"topology-unit-type",title:C.componentType,children:As(C.componentType)})]}),m.jsx("button",{type:"button","data-open-collection":"true",className:"topology-collection-open-btn nodrag nopan",title:"Open collection scope","aria-label":`Open ${C.name} scope`,onPointerDown:ee=>{ee.stopPropagation()},onMouseDown:ee=>{ee.stopPropagation()},onClick:ee=>{var ge;ee.stopPropagation(),(ge=o==null?void 0:o.openCollectionScope)==null||ge.call(o,C.address)},children:"Open"})]}),m.jsx("span",{className:"mono",children:bi(C.address)})]})},style:{width:q.width,height:q.height,border:`2px dashed ${s?"#4f8ccf":xp[1]}`,borderRadius:12,background:s?"rgba(30, 58, 95, 0.34)":AT[1],color:s?"#e2e8f0":"#0f172a",padding:10}});const ae=C.streams.filter(ee=>ee.direction==="input"),pe=C.streams.filter(ee=>ee.direction==="output"),oe=C.streams.filter(ee=>ee.direction==="unknown");if(t==="lr"){const ge=Ra+6;ae.forEach((de,H)=>{const $=Rs(de,"is-input","collection",s);R.push({id:`stream:${de.address}`,parentNode:B,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsxs("span",{className:Ms(de,"is-input","collection"),title:Kn(de,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(de.name,de.address)}),ft(de.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(de.msgType),"]"]}):null]})},position:{x:10,y:ge+H*30},style:{width:st,height:Ne,borderRadius:$.borderRadius,border:$.border,background:$.background,color:$.color,padding:"0 6px"}})}),pe.forEach((de,H)=>{const $=Rs(de,"is-output","collection",s);R.push({id:`stream:${de.address}`,parentNode:B,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsxs("span",{className:Ms(de,"is-output","collection"),title:Kn(de,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(de.name,de.address)}),ft(de.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(de.msgType),"]"]}):null]})},position:{x:q.width-st-10,y:ge+H*30},style:{width:st,height:Ne,borderRadius:$.borderRadius,border:$.border,background:$.background,color:$.color,padding:"0 6px"}})}),oe.length>0&&J(B,q,oe,q.height-Ne-10,"is-unknown","collection",t,R)}else{const ge=Math.max(86+Ne+10,q.height-Ne-12);J(B,q,ae,86,"is-input","collection",t,R),J(B,q,pe,ge,"is-output","collection",t,R),oe.length>0&&J(B,q,oe,Math.floor((q.height-Ne)/2)+14,"is-unknown","collection",t,R)}}for(const C of d.values()){const B=`unit:${C.address}`,te=b.get(B)??{x:0,y:0},q=S.get(B)??{width:Ia,height:ba},ae=C.streams.filter(de=>de.direction==="input"),pe=C.streams.filter(de=>de.direction==="output"),oe=C.streams.filter(de=>de.direction==="unknown"),ee=new Set(C.streams.map(de=>de.address)),ge=YT(C.streams);if(R.push({id:B,position:te,data:{label:m.jsxs("div",{className:"topology-unit-label",children:[m.jsxs("span",{className:"topology-title-row",title:Oa(C.name,C.address,C.componentType),children:[m.jsx("strong",{children:C.name}),m.jsx("span",{className:"topology-unit-type",title:C.componentType,children:As(C.componentType)})]}),m.jsx("span",{className:"mono topology-unit-address",title:C.address,children:ui(bi(C.address),34)})]})},style:{width:q.width,height:q.height,border:s?"1px solid #3b82f6":"1px solid #93c5fd",borderRadius:12,background:s?"#0f1f35":"#f8fbff",padding:10}}),t==="lr"){const de=Ps+6;ae.forEach((H,$)=>{R.push({id:`stream:${H.address}`,parentNode:B,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsxs("span",{className:"mono topology-stream-label is-input",title:Kn(H,"unit"),children:[m.jsx("span",{className:"topology-stream-name",children:En(H.name,H.address)}),ft(H.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(H.msgType),"]"]}):null]})},position:{x:10,y:de+$*30},style:{width:st,height:Ne,borderRadius:999,border:s?"1px solid #818cf8":"1px solid #c7d2fe",background:s?"#1d2644":"#eef2ff",padding:"0 6px"}})}),pe.forEach((H,$)=>{R.push({id:`stream:${H.address}`,parentNode:B,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsxs("span",{className:"mono topology-stream-label is-output",title:Kn(H,"unit"),children:[m.jsx("span",{className:"topology-stream-name",children:En(H.name,H.address)}),ft(H.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ft(H.msgType),"]"]}):null]})},position:{x:q.width-st-10,y:de+$*30},style:{width:st,height:Ne,borderRadius:999,border:s?"1px solid #22d3ee":"1px solid #7dd3fc",background:s?"#0f2e37":"#ecfeff",padding:"0 6px"}})}),C.tasks.forEach((H,$)=>{const G=`task:${C.address}:${H.name}`,Y=ci(H.subscribes,ge),se=Array.from(new Set(H.publishes.map(le=>ci(le,ge)).filter(le=>le!==null)));R.push({id:G,parentNode:B,extent:"parent",draggable:!1,sourcePosition:ie.Right,targetPosition:ie.Left,data:{label:m.jsx("span",{className:"mono topology-task-label",title:H.name,children:ui(H.name,15)})},position:{x:Math.floor((q.width-tr)/2),y:de+$*30+4},style:{width:tr,height:Pa,borderRadius:999,border:s?"1px solid #41536c":"1px solid #dbe2ea",background:s?"#1a273a":"#f1f5f9",padding:"0 6px"}}),Y&&ee.has(Y)&&X.push({id:`edge:internal:${C.address}:${H.name}:sub`,source:`stream:${Y}`,target:G,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:re,style:Q});for(const le of se)ee.has(le)&&X.push({id:`edge:internal:${C.address}:${H.name}:${le}`,source:G,target:`stream:${le}`,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:re,style:Q})}),oe.length>0&&J(B,q,oe,q.height-Ne-8,"is-unknown","unit",t,R)}else{const de=Ps+Ne+12,H=q.height-Ne-12,$=H-8,G=de+Math.max(0,Math.floor(($-de-Pa)/2));J(B,q,ae,Ps+2,"is-input","unit",t,R),J(B,q,pe,H,"is-output","unit",t,R),oe.length>0&&J(B,q,oe,G+28,"is-unknown","unit",t,R);const Y=C.tasks.length,se=q.width-20,le=Y*tr,we=Y>1?Math.max(wp,Math.min(22,Math.floor((se-le)/(Y-1)))):0,Ee=le+we*Math.max(0,Y-1),be=10+Math.max(0,Math.floor((se-Ee)/2));C.tasks.forEach((ce,he)=>{const xe=`task:${C.address}:${ce.name}`,ke=ci(ce.subscribes,ge),Fe=Array.from(new Set(ce.publishes.map(ye=>ci(ye,ge)).filter(ye=>ye!==null)));R.push({id:xe,parentNode:B,extent:"parent",draggable:!1,sourcePosition:ie.Bottom,targetPosition:ie.Top,data:{label:m.jsx("span",{className:"mono topology-task-label",title:ce.name,children:ui(ce.name,15)})},position:{x:be+he*(tr+we),y:G},style:{width:tr,height:Pa,borderRadius:999,border:s?"1px solid #41536c":"1px solid #dbe2ea",background:s?"#1a273a":"#f1f5f9",padding:"0 6px"}}),ke&&ee.has(ke)&&X.push({id:`edge:internal:${C.address}:tb:${ce.name}:sub`,source:`stream:${ke}`,target:xe,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:re,style:Q});for(const ye of Fe)ee.has(ye)&&X.push({id:`edge:internal:${C.address}:tb:${ce.name}:${ye}`,source:xe,target:`stream:${ye}`,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:re,style:Q})})}}for(const C of U){const B=O.get(C);if(B&&B.ownerKind!=="orphan")continue;const te=`orphan:${C}`,q=b.get(te)??{x:0,y:0};R.push({id:`stream:${C}`,position:q,sourcePosition:t==="tb"?ie.Bottom:ie.Right,targetPosition:t==="tb"?ie.Top:ie.Left,data:{label:m.jsxs("div",{className:"mono topology-orphan-label",children:[m.jsx("strong",{children:Ku(C)}),m.jsx("span",{children:ui(C,54)})]})},style:{width:Sp,border:s?"1px solid #41536c":"1px solid #dbe2ea",borderRadius:10,background:s?"#111c2e":"#ffffff",padding:6}})}const fe=C=>{const B=O.get(C);return B?B.ownerKind==="unit"||B.ownerKind==="collection"||B.ownerKind==="scope_collection"||B.ownerKind==="orphan"?`stream:${C}`:B.ownerId:`stream:${C}`},V=C=>{var B;return((B=O.get(C))==null?void 0:B.ownerId)??null};for(const C of z){const B=fe(C.from),te=fe(C.to);if(B===te)continue;const q=V(C.from),ae=V(C.to);if(!(q&&ae&&q===ae&&q.startsWith("scope:"))&&!(q&&ae&&q===ae&&q.startsWith("collection:"))){if(q&&ae&&q===ae&&q.startsWith("unit:")){const pe=d.get(q.slice(5));if(pe&&pe.tasks.length>0)continue}X.push({id:`edge:${C.from}->${C.to}`,source:B,target:te,type:i,zIndex:1,markerEnd:{type:_r.ArrowClosed,width:12,height:12,color:s?"#8fa3bc":"#64748b"},style:{stroke:s?"#8fa3bc":"#64748b",strokeWidth:1.2}})}}return{nodes:R,edges:X}}function qT(e){const t=new Map;if(!e)return t;for(const r of e.units.values())for(const s of r.streams)t.set(s.address,s.address),t.set($e(s.address),s.address);for(const r of e.collections.values())for(const s of r.streams)t.set(s.address,s.address),t.set($e(s.address),s.address);const n=Pl(e.collections);for(const[r,s]of n.endpointByInternalTopic.entries())t.set(r,s);return t}function JT(e,t){const n=new Set;for(const r of e){const s=t.get(r)??t.get($e(r))??null;s&&(n.add(s),n.add($e(s)))}return n}function e2(e,t,n){if(!e||t.size===0)return t;const r=new Map;for(const[l,a]of Object.entries(e.graph)){const u=n.get(l)??n.get($e(l))??l,c=r.get(u)??[];for(const d of a){const f=n.get(d)??n.get($e(d))??d;c.push(f)}r.set(u,c)}const s=new Set,o=Array.from(t);for(;o.length>0;){const l=o.shift();if(!l||s.has(l))continue;s.add(l);const a=r.get(l)??[];for(const u of a)s.has(u)||o.push(u)}const i=new Set;for(const l of s)i.add(l),i.add($e(l));return i}function t2(e,t){if(t.size===0||e.edges.length===0)return e;const n=a=>{if(!a)return!1;const u=$e(a);return t.has(a)||t.has(u)},r=new Map;e.edges.forEach((a,u)=>{const c=r.get(a.source);c?c.push(u):r.set(a.source,[u])});const s=new Set,o=new Set,i=[],l=a=>{o.has(a)||(o.add(a),i.push(a))};for(e.edges.forEach((a,u)=>{const c=a.source.startsWith("stream:")?a.source.slice(7):null,d=n2(a.id);n(c??d)&&(s.add(u),l(a.target))});i.length>0;){const a=i.shift();if(!a)continue;const u=r.get(a);if(!(!u||u.length===0))for(const c of u)s.has(c)||(s.add(c),l(e.edges[c].target))}return s.size===0?e:{nodes:e.nodes,edges:e.edges.map((a,u)=>{if(!s.has(u)||typeof a.className=="string"&&a.className.includes("topology-internal-edge"))return a;const d=typeof a.markerEnd=="object"&&a.markerEnd!==null?{...a.markerEnd,color:"#2563eb"}:{type:_r.ArrowClosed,width:12,height:12,color:"#2563eb"};return{...a,animated:!0,markerEnd:d,style:{...a.style??{},stroke:"#2563eb",strokeWidth:1.7}}})}}function n2(e){if(!e.startsWith("edge:")||e.startsWith("edge:internal:"))return null;const t=e.slice(5),n=t.indexOf("->");if(n<=0)return null;const r=t.slice(0,n);return r.length>0?r:null}function r2(e){const t=new Map;if(!e)return t;for(const n of e.units.values())for(const r of n.streams){const s={direction:r.direction,unitAddress:n.address};t.set(r.address,s),t.set($e(r.address),s)}return t}function s2(e){const t=new Map;if(!e)return t;const n=(r,s)=>{const o=s.split(":").slice(1).join(":");o.length>0&&!t.has(o)&&t.set(o,r)};for(const r of e.units.values())for(const s of r.streams)n(r.address,s.address);for(const r of e.collections.values())for(const s of r.streams)n(r.address,s.address);return t}function o2(e,t,n){if(!e)return null;const{topic:r,endpointToken:s}=bl(n);let o=-1,i=null;const l=(a,u,c)=>{const d=i2(t,u,c,r,s);d>o&&(o=d,i=a)};for(const a of e.units.values())for(const u of a.streams)l(a.address,u.address,u.direction);for(const a of e.collections.values())for(const u of a.streams)l(a.address,u.address,u.direction);return o>0?i:null}function i2(e,t,n,r,s){if(e==="publisher"&&n!=="output"||e==="subscriber"&&n!=="input")return-1;let o=0;const i=$e(t);return r.length>0&&(i===r?o+=12:t.startsWith(`${r}:`)?o+=8:t.includes(r)&&(o+=2)),s.length>0&&(t.endsWith(`:${s}`)?o+=14:t.includes(s)&&(o+=7)),o}function l2(e,t,n){if(e.kind!=="publisher"&&e.kind!=="subscriber")return null;const r=e.streamAddress.split(":").slice(1).join(":");return e.unitAddress??t.get(r)??n(e.kind,e.streamAddress)??null}function a2(e,t,n,r){if(e.kind==="unit")return`unit:${e.unitAddress}`;if(e.kind==="collection")return`collection:${e.collectionAddress}`;if(t&&(r!=null&&r.units.has(t)))return`unit:${t}`;if(t&&(r!=null&&r.collections.has(t)))return`collection:${t}`;const s=e.streamAddress;if(!s)return null;const o=s.split(":").slice(1).join(":"),i=s.split(":")[0]??"",l=n.nodes.find(a=>{if(!a.id.startsWith("stream:"))return!1;const u=a.id.slice(7);return u.includes(o)||u.startsWith(i)});return(l==null?void 0:l.id)??null}function u2({autoFocusOnSelection:e,focusSelection:t,focusRequestId:n,flowInitTick:r,flowInstanceRef:s,flowData:o,topologyComponents:i,activeScope:l,parentCollectionByAddress:a,componentAddressByEndpointId:u,componentAddressByStreamSelection:c,setScopeCollectionAddress:d}){const f=E.useRef(0),h=E.useRef(null),_=E.useRef(null);E.useEffect(()=>{if(!e||!t||n<=0||f.current===n||!s.current)return;const N=l2(t,u,c),p=t.kind==="unit"?t.unitAddress:t.kind==="collection"?t.collectionAddress:N;if(p&&i){const P=a.get(p)??null;if(P!==l){h.current=n,d(P);return}}const g=a2(t,N,o,i);if(!g||!o.nodes.some(P=>P.id===g))return;const y=()=>{const P=s.current;if(!P){_.current=null;return}P.fitView({nodes:[{id:g}],padding:zT,duration:DT,minZoom:UT,maxZoom:HT}),f.current=n,h.current=null,_.current=null};if(h.current===n){if(_.current===n)return;_.current=n,requestAnimationFrame(()=>{requestAnimationFrame(y)});return}y()},[l,e,u,c,o,r,n,t,s,a,d,i])}function c2(e){return Object.values(e).reduce((t,n)=>t+n.length,0)}function d2({graphSnapshot:e,profilingSnapshot:t=null,recentEvents:n,immersive:r=!1,showLegend:s=!0,showMiniMap:o=!0,darkMode:i=!1,defaultLayout:l="tb",edgeConnectorStyle:a="curved",autoFitOnLayoutScopeChange:u=!0,autoFocusOnSelection:c=!0,focusSelection:d=null,focusRequestId:f=0,onEntitySelect:h}){var de;const _=E.useRef(null),x=E.useRef(null),N=E.useRef(new Map),p=E.useRef(""),g=E.useRef(null),y=E.useRef(new Map),[w,P]=E.useState(!1),[L,O]=E.useState(0),[A,j]=E.useState(null),[z,U]=E.useState([]),Z=l;E.useEffect(()=>{if(!t){y.current=new Map,U([]);return}const H=y.current,$=new Map,G=new Set;for(const le of Object.values(t)){const we=le.process_id;for(const Ee of Object.values(le.publishers)){const be=typeof Ee.messages_published_total=="number"&&Number.isFinite(Ee.messages_published_total)?Ee.messages_published_total:0,ce=`${we}:${Ee.endpoint_id}`,he=H.get(ce);he!==void 0&&be>he&&G.add(`${Ee.topic}:${Ee.endpoint_id}`),$.set(ce,be)}}y.current=$;const Y=Array.from(G).sort(),se=Y.join("|");se!==p.current&&(p.current=se,U(Y))},[t]);const D=E.useMemo(()=>e?Hc(e):null,[e]),v=E.useMemo(()=>D?Al(D.collections):new Map,[D]),k=E.useMemo(()=>D?K_(D.collections,A):[],[D,A]),T=E.useMemo(()=>r2(D),[D]),M=E.useMemo(()=>s2(D),[D]),I=E.useMemo(()=>(H,$)=>o2(D,H,$),[D]),S=E.useMemo(()=>qT(D),[D]),b=E.useMemo(()=>JT(z,S),[z,S]),F=E.useMemo(()=>e2(e,b,S),[b,S,e]),R=k.length>0?k[k.length-1]:null,X=E.useCallback(H=>{D!=null&&D.collections.has(H)&&j(H)},[D]),Q=E.useCallback(H=>{j(v.get(H)??null)},[v]),re=`${Z}:${R??"root"}`,J=E.useMemo(()=>e?ZT(e,Z,R,a,i,{openCollectionScope:X,goUpFromScope:Q}):{nodes:[],edges:[]},[e,Z,R,a,i,X,Q]),fe=E.useMemo(()=>{if(J.nodes.length>0&&QT(J))return N.current.set(re,J),J;const H=N.current.get(re);return H&&H.nodes.length>0?H:J},[J,re]),V=E.useMemo(()=>t2(fe,F),[F,fe]),me=H=>{H.startsWith("collection:")&&X(H.slice(11))},K=H=>{if(H.startsWith("unit:")){h==null||h({kind:"unit",unitAddress:H.slice(5)});return}if(H.startsWith("collection:")){h==null||h({kind:"collection",collectionAddress:H.slice(11)});return}if(H.startsWith("stream:")){const $=H.slice(7),G=T.get($)??T.get($e($));if(!G){h==null||h(null);return}if(G.direction==="output"){h==null||h({kind:"publisher",streamAddress:$,unitAddress:G.unitAddress});return}if(G.direction==="input"){h==null||h({kind:"subscriber",streamAddress:$,unitAddress:G.unitAddress});return}}h==null||h(null)};if(E.useEffect(()=>{!D||!A||D.collections.has(A)||j(null)},[A,D]),E.useEffect(()=>{if(!D||!e){g.current=null;return}const H=Iu(D.units,D.collections,null),$=H.length===1?H[0]:null,G=$!==null&&Q_(e,D.units,D.collections,$),Y=$!==null&&D.collections.has($)&&X_($,D.units,D.collections)&&!G,se=`${H.slice().sort().join("|")}::${Y?"ready":"wait"}`;g.current!==se&&(g.current=se,A===null&&(!Y||!$||j($)))},[e,A,D]),E.useEffect(()=>{if(!D||!A)return;Iu(D.units,D.collections,A).length===0&&j(null)},[A,D]),u2({autoFocusOnSelection:c,focusSelection:d,focusRequestId:f,flowInitTick:L,flowInstanceRef:x,flowData:fe,topologyComponents:D,activeScope:R,parentCollectionByAddress:v,componentAddressByEndpointId:M,componentAddressByStreamSelection:I,setScopeCollectionAddress:j}),E.useEffect(()=>{const H=()=>{var Y;const $=((Y=_.current)==null?void 0:Y.closest(".dashboard-layout"))??_.current,G=document.fullscreenElement;if(!$||!G){P(!1);return}P(G===$||G.contains($))};return document.addEventListener("fullscreenchange",H),()=>{document.removeEventListener("fullscreenchange",H)}},[]),!e)return r?m.jsx("section",{className:"topology-immersive",children:m.jsx("div",{className:"topology-empty-state",children:m.jsx("p",{children:"Waiting for initial snapshot..."})})}):m.jsx(el,{title:"Topology",subtitle:"Live graph, process ownership, and edge changes",children:m.jsx("div",{className:"placeholder",children:m.jsx("p",{children:"Waiting for initial snapshot..."})})});const C=Object.keys(e.graph).length,B=c2(e.graph),te=Object.keys(e.sessions).length,q=Object.values(e.processes),ae=((de=_.current)==null?void 0:de.closest(".dashboard-layout"))??_.current??document.documentElement,pe=async()=>{if(ae)try{document.fullscreenElement?await document.exitFullscreen():await ae.requestFullscreen()}catch{}},oe=m.jsxs("div",{className:"topology-flow-toolbar",children:[m.jsx("span",{className:"topology-flow-toolbar__label",children:"Scope"}),m.jsx("button",{type:"button",className:`topology-layout-btn ${R?"":"is-active"}`,onClick:()=>j(null),children:"Root"}),m.jsx("button",{type:"button",className:"topology-layout-btn",disabled:!R,onClick:()=>{R&&j(v.get(R)??null)},children:"Up"}),k.length>0?m.jsx("span",{className:"topology-scope-sep",children:"|"}):null,k.length>0?m.jsx("span",{className:"topology-scope-trail",children:k.map((H,$)=>{const G=D==null?void 0:D.collections.get(H),Y=(G==null?void 0:G.name)??bi(H),se=G?[G.name,G.address,G.componentType].join(` +`):H,le=$===k.length-1;return m.jsxs("span",{className:"topology-scope-segment",children:[le?m.jsx("span",{className:"topology-scope-tail",title:se,children:Y}):m.jsx("button",{type:"button",className:"topology-scope-chip",title:se,onClick:()=>j(H),children:Y}),le?null:m.jsx("span",{className:"topology-scope-slash",children:"/"})]},`scope-${H}`)})}):null]}),ee=m.jsxs("div",{className:"topology-viewport-legend","aria-label":"Topology legend",children:[m.jsx("span",{className:"topology-viewport-legend__title",children:"Legend"}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-collection"}),"Collection"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-input"}),"Subscriber"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-output"}),"Publisher"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-topic"}),"Collection Topic"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-relay"}),"Collection Relay"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-task"}),"Task"]})]}),ge=m.jsxs(m.Fragment,{children:[r?null:oe,m.jsxs("div",{className:`topology-flow-shell ${r?"is-immersive":""} ${i?"is-dark":""}`,ref:_,children:[r?m.jsx("div",{className:"topology-viewport-top-controls",children:oe}):null,r&&s?m.jsx("div",{className:"topology-viewport-bottom-dock",children:ee}):null,r||!s?null:ee,m.jsxs(v0,{nodes:V.nodes,edges:V.edges,fitView:!0,fitViewOptions:{padding:.18,minZoom:.4},minZoom:.2,maxZoom:2.4,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onInit:H=>{x.current=H,O($=>$+1)},onPaneClick:()=>h==null?void 0:h(null),onNodeClick:(H,$)=>{if($.id.startsWith("scope:")){const G=H.target,Y=G==null?void 0:G.closest('[data-scope-up="true"]');if(Y){if(!Y.disabled){const se=$.id.slice(6);Q(se)}return}}if($.id.startsWith("collection:")){const G=H.target;if(G!=null&&G.closest('[data-open-collection="true"]')){me($.id);return}h==null||h({kind:"collection",collectionAddress:$.id.slice(11)});return}K($.id)},proOptions:{hideAttribution:!0},children:[m.jsx(PT,{color:i?"#243244":"#d5deea",gap:24}),o?m.jsx(yT,{pannable:!0,zoomable:!0,maskColor:i?"rgba(2, 6, 23, 0.72)":"rgba(15, 23, 42, 0.10)",style:{background:i?"#0e1728":"#f8fafc",border:i?"1px solid #334155":"1px solid #dbe2ea",borderRadius:8},nodeColor:H=>H.id.startsWith("collection:")?i?"#1d4f79":"#dbeafe":H.id.startsWith("unit:")?i?"#1e3a62":"#bfdbfe":i?"#334155":"#cbd5e1"}):null,m.jsx(NT,{showFitView:!1,showInteractive:!1,children:m.jsx(Hr,{className:"topology-control-btn",title:w?"Exit fullscreen":"Enter fullscreen","aria-label":w?"Exit fullscreen":"Enter fullscreen",onClick:()=>{pe()},children:"⛶"})})]},u?`topology-flow-${Z}-${R??"root"}`:"topology-flow-stable")]})]});return r?m.jsx("section",{className:"topology-immersive",children:ge}):m.jsxs(el,{title:"Topology",subtitle:"Low-level publisher/subscriber wiring with optional metadata overlays",children:[m.jsxs("div",{className:"stats-grid",children:[m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Topics"}),m.jsx("strong",{children:C})]}),m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Edges"}),m.jsx("strong",{children:B})]}),m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Sessions"}),m.jsx("strong",{children:te})]}),m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Processes"}),m.jsx("strong",{children:q.length})]})]}),ge,m.jsxs("div",{className:"panel-section",children:[m.jsx("h3",{children:"Process Ownership"}),q.length===0?m.jsx("p",{className:"muted",children:"No process ownership in current snapshot."}):m.jsxs("table",{className:"data-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Process ID"}),m.jsx("th",{children:"PID"}),m.jsx("th",{children:"Host"}),m.jsx("th",{children:"Units"})]})}),m.jsx("tbody",{children:q.map(H=>m.jsxs("tr",{children:[m.jsx("td",{className:"mono",children:H.process_id.slice(0,8)}),m.jsx("td",{children:H.pid??"-"}),m.jsx("td",{children:H.host??"-"}),m.jsx("td",{children:H.units.length})]},H.process_id))})]})]}),m.jsxs("div",{className:"panel-section",children:[m.jsx("h3",{children:"Recent Topology Changes"}),n.length===0?m.jsx("p",{className:"muted",children:"No topology events received yet."}):m.jsx("ul",{className:"event-list",children:n.slice(0,8).map(H=>m.jsxs("li",{className:"event-item",children:[m.jsx("span",{className:"event-pill",children:H.data.event_type}),m.jsxs("span",{className:"mono",children:["seq ",H.data.seq]}),m.jsx("span",{children:H.data.changed_topics.length>0?H.data.changed_topics.join(", "):"No topic list"})]},`topo-${H.data.seq}`))})]})]})}function We(e,t,n,r=!0){return{repr_value:n,structured_value:n,settings_schema:null,serialized_present:!0,patchable:r,patch_error:null,component_type:t,component_name:e}}function tn(e,t,n,r={},s={}){return{process_id:e,pid:t,host:"fixture-host",window_seconds:2,timestamp:1711111111,publishers:r,subscribers:s}}function Np(e,t,n){return{endpoint_id:e,topic:t,messages_published_total:n.messagesPublishedTotal??n.messagesPublishedWindow*10,messages_published_window:n.messagesPublishedWindow,publish_rate_hz_window:n.publishRateHzWindow,inflight_messages_current:n.inflightCurrent??0,num_buffers:n.numBuffers??8,timestamp:n.timestamp??1711111111}}function Tp(e,t,n){return{endpoint_id:e,topic:t,messages_received_total:n.messagesReceivedTotal??n.messagesReceivedWindow*10,messages_received_window:n.messagesReceivedWindow,channel_kind_last:n.channelKindLast??"fifo",timestamp:n.timestamp??1711111111}}function Dt(e,t="builtins.str"){return{address:e,msg_type:t,leaky:!1}}function Qt(e,t,n="builtins.str"){return{address:e,msg_type:n,host:"127.0.0.1",port:t}}function at(e,t,n){return{name:e,subscribes:t,publishes:n}}function Le(e){return String(e).padStart(2,"0")}const nn={name:"root-scope-navigation",health:{status:"ok",graph_session_active:!0,graph_address:"127.0.0.1:25978"},snapshot:{snapshot:{graph:{"SYSTEM/PING_TOPIC":["GLOBAL_PING_TOPIC"]},edge_owners:[],sessions:{"fixture-session":{edges:[{from_topic:"SYSTEM/PING_TOPIC",to_topic:"GLOBAL_PING_TOPIC"}],metadata:{components:{SYSTEM:{name:"SYSTEM",component_type:"fixture.TestSystem",children:["SYSTEM/PING"],topics:{PING:{address:"SYSTEM/PING_TOPIC",msg_type:"builtins.str"}}},"SYSTEM/PING":{name:"PING",component_type:"fixture.MessageGenerator",streams:{OUTPUT:{address:"SYSTEM/PING_TOPIC:ping-output-endpoint",msg_type:"builtins.str",host:"127.0.0.1",port:9001}},tasks:[{name:"emit",subscribes:null,publishes:["SYSTEM/PING_TOPIC"]}]}}}}},processes:{"fixture-process":{process_id:"fixture-process",pid:4201,host:"fixture-host",units:["SYSTEM/PING"]}}},settings:{SYSTEM:We("SYSTEM","fixture.TestSystem",{enabled:!0}),"SYSTEM/PING":We("PING","fixture.MessageGenerator",{rate_hz:10,message:"ping"})},profiling:{"fixture-process":tn("fixture-process",4201,["SYSTEM/PING"],{"SYSTEM/PING_TOPIC:ping-output-endpoint":{endpoint_id:"ping-output-endpoint",topic:"SYSTEM/PING_TOPIC",messages_published_total:120,messages_published_window:20,publish_rate_hz_window:10,inflight_messages_current:1,num_buffers:8,timestamp:1711111111}})}}},f2={name:"wide-fanout",health:nn.health,snapshot:{snapshot:{graph:{"STRESS/SOURCE_A":["STRESS/FANOUT_1","STRESS/FANOUT_2","STRESS/FANOUT_3","STRESS/FANOUT_4","STRESS/FANOUT_5","STRESS/FANOUT_6"],"STRESS/SOURCE_B":["STRESS/FANOUT_1","STRESS/FANOUT_2"],"STRESS/FANOUT_1":["STRESS/SINK_1"],"STRESS/FANOUT_2":["STRESS/SINK_2"],"STRESS/FANOUT_3":["STRESS/SINK_3"],"STRESS/FANOUT_4":["STRESS/SINK_4"],"STRESS/FANOUT_5":["STRESS/SINK_5"],"STRESS/FANOUT_6":["STRESS/SINK_6"]},edge_owners:[],sessions:{"wide-session":{edges:[],metadata:{components:{STRESS:{name:"STRESS",component_type:"fixture.StressCollection",children:["STRESS/AGGREGATOR","STRESS/SINK_1","STRESS/SINK_2","STRESS/SINK_3","STRESS/SINK_4","STRESS/SINK_5","STRESS/SINK_6"]},"STRESS/AGGREGATOR":{name:"AGGREGATOR",component_type:"fixture.AggregatorUnit",streams:{INPUT_ALPHA:{address:"STRESS/SOURCE_A:input-alpha",msg_type:"builtins.str",leaky:!1},INPUT_BETA:{address:"STRESS/SOURCE_B:input-beta",msg_type:"builtins.str",leaky:!1},OUTPUT_1:{address:"STRESS/FANOUT_1:fanout-1",msg_type:"builtins.str",host:"127.0.0.1",port:9101},OUTPUT_2:{address:"STRESS/FANOUT_2:fanout-2",msg_type:"builtins.str",host:"127.0.0.1",port:9102},OUTPUT_3:{address:"STRESS/FANOUT_3:fanout-3",msg_type:"builtins.str",host:"127.0.0.1",port:9103},OUTPUT_4:{address:"STRESS/FANOUT_4:fanout-4",msg_type:"builtins.str",host:"127.0.0.1",port:9104},OUTPUT_5:{address:"STRESS/FANOUT_5:fanout-5",msg_type:"builtins.str",host:"127.0.0.1",port:9105},OUTPUT_6:{address:"STRESS/FANOUT_6:fanout-6",msg_type:"builtins.str",host:"127.0.0.1",port:9106}},tasks:[{name:"normalize_payload",subscribes:"STRESS/SOURCE_A",publishes:["STRESS/FANOUT_1","STRESS/FANOUT_2"]},{name:"deduplicate_messages",subscribes:"STRESS/SOURCE_B",publishes:["STRESS/FANOUT_3","STRESS/FANOUT_4"]},{name:"route_priority_messages",subscribes:"STRESS/SOURCE_A",publishes:["STRESS/FANOUT_5","STRESS/FANOUT_6"]}]},...Object.fromEntries(Array.from({length:6},(e,t)=>{const n=t+1;return[`STRESS/SINK_${n}`,{name:`SINK_${n}`,component_type:"fixture.DebugOutput",streams:{INPUT:{address:`STRESS/FANOUT_${n}:sink-${n}`,msg_type:"builtins.str",leaky:!1}},tasks:[{name:"on_message",subscribes:`STRESS/FANOUT_${n}`,publishes:[]}]}]}))}}}},processes:{"wide-process":{process_id:"wide-process",pid:4301,host:"fixture-host",units:["STRESS/AGGREGATOR","STRESS/SINK_1","STRESS/SINK_2","STRESS/SINK_3","STRESS/SINK_4","STRESS/SINK_5","STRESS/SINK_6"]}}},settings:{STRESS:We("STRESS","fixture.StressCollection",{mode:"stress"}),"STRESS/AGGREGATOR":We("AGGREGATOR","fixture.AggregatorUnit",{batch_size:64,strategy:"spread"})},profiling:{"wide-process":tn("wide-process",4301)}}},p2={name:"long-labels",health:nn.health,snapshot:{snapshot:{graph:{"LONG_SCOPE/EXTRAORDINARILY_VERBOSE_PUBLISHER_TOPIC_NAME":["LONG_SCOPE/ULTRA_VERBOSE_SUBSCRIBER_TOPIC_NAME"]},edge_owners:[],sessions:{"long-session":{edges:[],metadata:{components:{LONG_SCOPE:{name:"EXTRAORDINARILY_VERBOSE_COLLECTION_NAME_FOR_LAYOUT_TESTING",component_type:"fixture.deep.namespace.ExtremelyLongCollectionComponentType",children:["LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME"]},"LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME":{name:"COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME",component_type:"fixture.deep.namespace.componenttypes.ExceptionallyLongComponentTypeName",streams:{OUTPUT_WITH_A_LONG_NAME:{address:"LONG_SCOPE/EXTRAORDINARILY_VERBOSE_PUBLISHER_TOPIC_NAME:publisher-endpoint-with-a-very-long-token",msg_type:"fixtures.messages.ReallyLongStructuredMessageTypeName",host:"127.0.0.1",port:9201},INPUT_WITH_A_LONG_NAME:{address:"LONG_SCOPE/ULTRA_VERBOSE_SUBSCRIBER_TOPIC_NAME:subscriber-endpoint-with-a-very-long-token",msg_type:"fixtures.messages.ReallyLongStructuredMessageTypeName",leaky:!1}},tasks:[{name:"task_with_a_surprisingly_long_name_for_a_single_render_chip",subscribes:"LONG_SCOPE/ULTRA_VERBOSE_SUBSCRIBER_TOPIC_NAME",publishes:["LONG_SCOPE/EXTRAORDINARILY_VERBOSE_PUBLISHER_TOPIC_NAME"]}]}}}}},processes:{"long-process":{process_id:"long-process",pid:4401,host:"fixture-host",units:["LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME"]}}},settings:{LONG_SCOPE:We("EXTRAORDINARILY_VERBOSE_COLLECTION_NAME_FOR_LAYOUT_TESTING","fixture.deep.namespace.ExtremelyLongCollectionComponentType",{debug_mode_enabled:!0}),"LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME":We("COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME","fixture.deep.namespace.componenttypes.ExceptionallyLongComponentTypeName",{default_payload:"the_quick_brown_fox_jumps_over_the_lazy_dog_repeatedly_to_stress_text_overflow"})},profiling:{"long-process":tn("long-process",4401)}}},h2={name:"semantic-stream-names",health:nn.health,snapshot:{snapshot:{graph:{"SIN/OUTPUT_SIGNAL_TOPIC":["SIN/WAVEFORM_TOPIC"]},edge_owners:[],sessions:{"semantic-stream-session":{edges:[],metadata:{components:{SIN:{name:"SIN",component_type:"fixture.LFO",streams:{INPUT_SIGNAL:Dt("SIN/INPUT_SIGNAL_TOPIC:sin-input-signal","fixtures.array.AxisArray"),INPUT_SETTINGS:Dt("SIN/INPUT_SETTINGS_TOPIC:sin-input-settings","fixtures.config.LFOSettings"),OUTPUT_SIGNAL:Qt("SIN/OUTPUT_SIGNAL_TOPIC:sin-output-signal",9211,"fixtures.array.AxisArray")},tasks:[at("on_signal","SIN/INPUT_SIGNAL_TOPIC",[]),at("on_settings","SIN/INPUT_SETTINGS_TOPIC",[]),at("generate",null,["SIN/OUTPUT_SIGNAL_TOPIC"])]}}}}},processes:{"semantic-stream-process":{process_id:"semantic-stream-process",pid:4451,host:"fixture-host",units:["SIN"]}}},settings:{SIN:We("SIN","fixture.LFO",{freq:1.5,update_rate:60})},profiling:{"semantic-stream-process":tn("semantic-stream-process",4451)}}},Xn=Array.from({length:6},(e,t)=>`TRACE_LAB/SPARSE_SUB_${Le(t+1)}`),Qn=Array.from({length:8},(e,t)=>`TRACE_LAB/DENSE_SUB_${Le(t+1)}`),m2={name:"profiling-trace-rates",health:nn.health,snapshot:{snapshot:{graph:Object.fromEntries([["TRACE_LAB/SPARSE_TOPIC",Xn.map((e,t)=>`TRACE_LAB/SPARSE_SUB_${Le(t+1)}_TOPIC`)],["TRACE_LAB/DENSE_TOPIC",Qn.map((e,t)=>`TRACE_LAB/DENSE_SUB_${Le(t+1)}_TOPIC`)]]),edge_owners:[],sessions:{"trace-session":{edges:[],metadata:{components:{TRACE_LAB:{name:"TRACE_LAB",component_type:"fixture.TraceLabCollection",children:["TRACE_LAB/SPARSE_PUB","TRACE_LAB/DENSE_PUB",...Xn,...Qn]},"TRACE_LAB/SPARSE_PUB":{name:"SPARSE_PUB",component_type:"fixture.TracePublisherUnit",streams:{OUTPUT:Qt("TRACE_LAB/SPARSE_TOPIC:sparse-publisher-endpoint",9901)},tasks:[at("publish_sparse",null,["TRACE_LAB/SPARSE_TOPIC"])]},"TRACE_LAB/DENSE_PUB":{name:"DENSE_PUB",component_type:"fixture.TracePublisherUnit",streams:{OUTPUT:Qt("TRACE_LAB/DENSE_TOPIC:dense-publisher-endpoint",9902)},tasks:[at("publish_dense",null,["TRACE_LAB/DENSE_TOPIC"])]},...Object.fromEntries(Xn.map((e,t)=>{const n=Le(t+1);return[e,{name:`SPARSE_SUB_${n}`,component_type:"fixture.TraceSubscriberUnit",streams:{INPUT:Dt(`TRACE_LAB/SPARSE_SUB_${n}_TOPIC:sparse-subscriber-${n}`)},tasks:[at(`consume_sparse_${n}`,`TRACE_LAB/SPARSE_SUB_${n}_TOPIC`,[])]}]})),...Object.fromEntries(Qn.map((e,t)=>{const n=Le(t+1);return[e,{name:`DENSE_SUB_${n}`,component_type:"fixture.TraceSubscriberUnit",streams:{INPUT:Dt(`TRACE_LAB/DENSE_SUB_${n}_TOPIC:dense-subscriber-${n}`)},tasks:[at(`consume_dense_${n}`,`TRACE_LAB/DENSE_SUB_${n}_TOPIC`,[])]}]}))}}}},processes:{"trace-process":{process_id:"trace-process",pid:5001,host:"fixture-host",units:["TRACE_LAB/SPARSE_PUB","TRACE_LAB/DENSE_PUB",...Xn,...Qn]}}},settings:{TRACE_LAB:We("TRACE_LAB","fixture.TraceLabCollection",{trace_enabled:!0}),"TRACE_LAB/SPARSE_PUB":We("SPARSE_PUB","fixture.TracePublisherUnit",{publish_rate_hz:1}),"TRACE_LAB/DENSE_PUB":We("DENSE_PUB","fixture.TracePublisherUnit",{publish_rate_hz:60})},profiling:{"trace-process":tn("trace-process",5001,["TRACE_LAB/SPARSE_PUB","TRACE_LAB/DENSE_PUB",...Xn,...Qn],{"TRACE_LAB/SPARSE_TOPIC:sparse-publisher-endpoint":Np("sparse-publisher-endpoint","TRACE_LAB/SPARSE_TOPIC",{messagesPublishedWindow:2,publishRateHzWindow:1,numBuffers:4}),"TRACE_LAB/DENSE_TOPIC:dense-publisher-endpoint":Np("dense-publisher-endpoint","TRACE_LAB/DENSE_TOPIC",{messagesPublishedWindow:120,publishRateHzWindow:60,inflightCurrent:2,numBuffers:16})},{...Object.fromEntries(Xn.map((e,t)=>{const n=Le(t+1);return[`TRACE_LAB/SPARSE_SUB_${n}_TOPIC:sparse-subscriber-${n}`,Tp(`sparse-subscriber-${n}`,`TRACE_LAB/SPARSE_SUB_${n}_TOPIC`,{messagesReceivedWindow:2,channelKindLast:t%2===0?"fifo":"shared_memory"})]})),...Object.fromEntries(Qn.map((e,t)=>{const n=Le(t+1);return[`TRACE_LAB/DENSE_SUB_${n}_TOPIC:dense-subscriber-${n}`,Tp(`dense-subscriber-${n}`,`TRACE_LAB/DENSE_SUB_${n}_TOPIC`,{messagesReceivedWindow:120,channelKindLast:t<3?"tcp":t%2===0?"fifo":"shared_memory"})]}))})}},traceScenarios:[{processId:"trace-process",publisherEndpointId:"sparse-publisher-endpoint",publisherTopic:"TRACE_LAB/SPARSE_TOPIC",eventIntervalMs:140,samplesPerTick:1,timestampStepNs:1e9,publishDeltaNsBase:94e7,publishDeltaNsJitter:12e7,subscribers:Xn.map((e,t)=>{const n=Le(t+1);return{endpointId:`sparse-subscriber-${n}`,topic:`TRACE_LAB/SPARSE_SUB_${n}_TOPIC`,leaseTimeNsBase:7e6+t*8e5,userSpanNsBase:25e5+t*24e4}})},{processId:"trace-process",publisherEndpointId:"dense-publisher-endpoint",publisherTopic:"TRACE_LAB/DENSE_TOPIC",eventIntervalMs:100,samplesPerTick:12,timestampStepNs:16666667,publishDeltaNsBase:164e5,publishDeltaNsJitter:24e5,subscribers:Qn.map((e,t)=>{const n=Le(t+1);return{endpointId:`dense-subscriber-${n}`,topic:`TRACE_LAB/DENSE_SUB_${n}_TOPIC`,leaseTimeNsBase:13e5+t*14e4,userSpanNsBase:92e4+t*11e4}})}]},g2={name:"nested-collections",health:nn.health,snapshot:{snapshot:{graph:{"LAB/PIPELINE/ROOT_TOPIC":["LAB/PIPELINE/INNER/INNER_TOPIC"],"LAB/PIPELINE/INNER/INNER_TOPIC":["LAB/PIPELINE/LEAF_TOPIC"]},edge_owners:[],sessions:{"nested-session":{edges:[],metadata:{components:{LAB:{name:"LAB",component_type:"fixture.RootCollection",children:["LAB/PIPELINE"]},"LAB/PIPELINE":{name:"PIPELINE",component_type:"fixture.PipelineCollection",children:["LAB/PIPELINE/SOURCE","LAB/PIPELINE/INNER"],topics:{ROOT_TOPIC:{address:"LAB/PIPELINE/ROOT_TOPIC",msg_type:"builtins.str"}}},"LAB/PIPELINE/INNER":{name:"INNER",component_type:"fixture.InnerCollection",children:["LAB/PIPELINE/INNER/SINK"],topics:{INNER_TOPIC:{address:"LAB/PIPELINE/INNER/INNER_TOPIC",msg_type:"builtins.str"}}},"LAB/PIPELINE/SOURCE":{name:"SOURCE",component_type:"fixture.SourceUnit",streams:{OUTPUT:{address:"LAB/PIPELINE/ROOT_TOPIC:source-output",msg_type:"builtins.str",host:"127.0.0.1",port:9301}},tasks:[{name:"emit_root_topic",subscribes:null,publishes:["LAB/PIPELINE/ROOT_TOPIC"]}]},"LAB/PIPELINE/INNER/SINK":{name:"SINK",component_type:"fixture.SinkUnit",streams:{INPUT:{address:"LAB/PIPELINE/INNER/INNER_TOPIC:inner-input",msg_type:"builtins.str",leaky:!1},OUTPUT:{address:"LAB/PIPELINE/LEAF_TOPIC:leaf-output",msg_type:"builtins.str",host:"127.0.0.1",port:9302}},tasks:[{name:"relay_nested_topic",subscribes:"LAB/PIPELINE/INNER/INNER_TOPIC",publishes:["LAB/PIPELINE/LEAF_TOPIC"]}]},"CONTROL/PROBE":{name:"PROBE",component_type:"fixture.RootProbe",streams:{OUTPUT:{address:"CONTROL/PROBE_TOPIC:probe-output",msg_type:"builtins.str",host:"127.0.0.1",port:9303}},tasks:[{name:"probe_root_scope",subscribes:null,publishes:["CONTROL/PROBE_TOPIC"]}]}}}}},processes:{"nested-process":{process_id:"nested-process",pid:4501,host:"fixture-host",units:["LAB/PIPELINE/SOURCE","LAB/PIPELINE/INNER/SINK","CONTROL/PROBE"]}}},settings:{LAB:We("LAB","fixture.RootCollection",{enabled:!0}),"LAB/PIPELINE":We("PIPELINE","fixture.PipelineCollection",{stage_count:2}),"LAB/PIPELINE/INNER":We("INNER","fixture.InnerCollection",{nested:!0})},profiling:{"nested-process":tn("nested-process",4501)}}},y2={name:"orphan-streams",health:nn.health,snapshot:{snapshot:{graph:{"ORPHAN/INPUT_TOPIC":["SYSTEM/PROCESS_TOPIC"],"SYSTEM/PROCESS_TOPIC":["ORPHAN/OUTPUT_TOPIC"]},edge_owners:[],sessions:{"orphan-session":{edges:[],metadata:{components:{"SYSTEM/PROCESSOR":{name:"PROCESSOR",component_type:"fixture.ProcessorUnit",streams:{INPUT:{address:"SYSTEM/PROCESS_TOPIC:processor-input",msg_type:"builtins.str",leaky:!1},OUTPUT:{address:"SYSTEM/PROCESS_TOPIC:processor-output",msg_type:"builtins.str",host:"127.0.0.1",port:9401}},tasks:[{name:"transform_orphan_stream",subscribes:"SYSTEM/PROCESS_TOPIC",publishes:["SYSTEM/PROCESS_TOPIC"]}]}}}}},processes:{"orphan-process":{process_id:"orphan-process",pid:4601,host:"fixture-host",units:["SYSTEM/PROCESSOR"]}}},settings:{"SYSTEM/PROCESSOR":We("PROCESSOR","fixture.ProcessorUnit",{amplify:2})},profiling:{"orphan-process":tn("orphan-process",4601)}}},Cr=12,v2={name:"dense-unit-layout",health:nn.health,snapshot:{snapshot:{graph:Object.fromEntries(Array.from({length:Cr},(e,t)=>{const n=Le(t+1);return[`MATRIX/IN_${n}_TOPIC`,[`MATRIX/OUT_${n}_TOPIC`]]})),edge_owners:[],sessions:{"dense-unit-session":{edges:[],metadata:{components:{MATRIX:{name:"MATRIX",component_type:"fixture.MatrixCollection",children:["MATRIX/ROUTER"]},"MATRIX/ROUTER":{name:"ROUTER",component_type:"fixture.DenseRouter",streams:Object.fromEntries([...Array.from({length:Cr},(e,t)=>{const n=Le(t+1);return[`INPUT_${n}`,Dt(`MATRIX/IN_${n}_TOPIC:router-input-${n}`)]}),...Array.from({length:Cr},(e,t)=>{const n=Le(t+1);return[`OUTPUT_${n}`,Qt(`MATRIX/OUT_${n}_TOPIC:router-output-${n}`,9500+t)]})]),tasks:Array.from({length:Cr},(e,t)=>{const n=Le(t+1);return at(`route_lane_${n}`,`MATRIX/IN_${n}_TOPIC`,[`MATRIX/OUT_${n}_TOPIC`])})}}}}},processes:{"dense-unit-process":{process_id:"dense-unit-process",pid:4701,host:"fixture-host",units:["MATRIX/ROUTER"]}}},settings:{MATRIX:We("MATRIX","fixture.MatrixCollection",{lanes:Cr}),"MATRIX/ROUTER":We("ROUTER","fixture.DenseRouter",{lanes:Cr,parallelism:4})},profiling:{"dense-unit-process":tn("dense-unit-process",4701)}}},on=12,di=Array.from({length:on},(e,t)=>`MEGA/SRC_${Le(t+1)}`),fi=Array.from({length:on},(e,t)=>`MEGA/SINK_${Le(t+1)}`),_2={name:"massive-fanout",health:nn.health,snapshot:{snapshot:{graph:Object.fromEntries([...Array.from({length:on},(e,t)=>{const n=Le(t+1);return[`MEGA/SRC_${n}_TOPIC`,[`MEGA/HUB_IN_${n}_TOPIC`]]}),...Array.from({length:on},(e,t)=>{const n=Le(t+1);return[`MEGA/HUB_OUT_${n}_TOPIC`,[`MEGA/SINK_${n}_IN_TOPIC`]]})]),edge_owners:[],sessions:{"mega-session":{edges:[],metadata:{components:{MEGA:{name:"MEGA",component_type:"fixture.MegaScope",children:[...di,"MEGA/HUB",...fi]},...Object.fromEntries(di.map((e,t)=>{const n=Le(t+1);return[e,{name:`SRC_${n}`,component_type:"fixture.SourceUnit",streams:{OUTPUT:Qt(`MEGA/SRC_${n}_TOPIC:source-output-${n}`,9600+t)},tasks:[at(`emit_lane_${n}`,null,[`MEGA/SRC_${n}_TOPIC`])]}]})),"MEGA/HUB":{name:"HUB",component_type:"fixture.HubRouter",streams:Object.fromEntries([...Array.from({length:on},(e,t)=>{const n=Le(t+1);return[`INPUT_${n}`,Dt(`MEGA/HUB_IN_${n}_TOPIC:hub-input-${n}`)]}),...Array.from({length:on},(e,t)=>{const n=Le(t+1);return[`OUTPUT_${n}`,Qt(`MEGA/HUB_OUT_${n}_TOPIC:hub-output-${n}`,9700+t)]})]),tasks:Array.from({length:on},(e,t)=>{const n=Le(t+1);return at(`fanout_lane_${n}`,`MEGA/HUB_IN_${n}_TOPIC`,[`MEGA/HUB_OUT_${n}_TOPIC`])})},...Object.fromEntries(fi.map((e,t)=>{const n=Le(t+1);return[e,{name:`SINK_${n}`,component_type:"fixture.SinkUnit",streams:{INPUT:Dt(`MEGA/SINK_${n}_IN_TOPIC:sink-input-${n}`)},tasks:[at(`consume_lane_${n}`,`MEGA/SINK_${n}_IN_TOPIC`,[])]}]}))}}}},processes:{"mega-process":{process_id:"mega-process",pid:4801,host:"fixture-host",units:[...di,"MEGA/HUB",...fi]}}},settings:{MEGA:We("MEGA","fixture.MegaScope",{lanes:on}),"MEGA/HUB":We("HUB","fixture.HubRouter",{lanes:on,fanout_mode:"parallel"})},profiling:{"mega-process":tn("mega-process",4801,[...di,"MEGA/HUB",...fi])}}},x2={name:"cyclic-feedback",health:nn.health,snapshot:{snapshot:{graph:{"ALPHA/OUT_TOPIC":["BETA/IN_TOPIC"],"BETA/OUT_TOPIC":["GAMMA/IN_TOPIC"],"GAMMA/OUT_TOPIC":["ALPHA/IN_TOPIC"],"GAMMA/AUDIT_TOPIC":["MONITOR/IN_TOPIC"]},edge_owners:[],sessions:{"cycle-session":{edges:[],metadata:{components:{ALPHA:{name:"ALPHA",component_type:"fixture.FeedbackStage",streams:{INPUT:Dt("ALPHA/IN_TOPIC:alpha-input"),OUTPUT:Qt("ALPHA/OUT_TOPIC:alpha-output",9801)},tasks:[at("forward_alpha","ALPHA/IN_TOPIC",["ALPHA/OUT_TOPIC"])]},BETA:{name:"BETA",component_type:"fixture.FeedbackStage",streams:{INPUT:Dt("BETA/IN_TOPIC:beta-input"),OUTPUT:Qt("BETA/OUT_TOPIC:beta-output",9802)},tasks:[at("forward_beta","BETA/IN_TOPIC",["BETA/OUT_TOPIC"])]},GAMMA:{name:"GAMMA",component_type:"fixture.FeedbackStage",streams:{INPUT:Dt("GAMMA/IN_TOPIC:gamma-input"),OUTPUT:Qt("GAMMA/OUT_TOPIC:gamma-output",9803),OUTPUT_AUDIT:Qt("GAMMA/AUDIT_TOPIC:gamma-audit",9804)},tasks:[at("fanout_gamma","GAMMA/IN_TOPIC",["GAMMA/OUT_TOPIC","GAMMA/AUDIT_TOPIC"])]},MONITOR:{name:"MONITOR",component_type:"fixture.MonitorUnit",streams:{INPUT:Dt("MONITOR/IN_TOPIC:monitor-input")},tasks:[at("observe_cycle","MONITOR/IN_TOPIC",[])]}}}}},processes:{"cycle-process":{process_id:"cycle-process",pid:4901,host:"fixture-host",units:["ALPHA","BETA","GAMMA","MONITOR"]}}},settings:{ALPHA:We("ALPHA","fixture.FeedbackStage",{gain:1}),GAMMA:We("GAMMA","fixture.FeedbackStage",{audit_enabled:!0})},profiling:{"cycle-process":tn("cycle-process",4901)}}},w2={"root-scope-navigation":nn,"wide-fanout":f2,"long-labels":p2,"semantic-stream-names":h2,"profiling-trace-rates":m2,"nested-collections":g2,"orphan-streams":y2,"dense-unit-layout":v2,"massive-fanout":_2,"cyclic-feedback":x2};function S2(e){return e?w2[e]??null:null}const E2=120,N2=250,T2=1e3,k2=.05,C2=5e3,I2=60;function Ir(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function b2(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("fixture")}function P2(e,t,n){const r=t.split(".").filter(i=>i.length>0);if(r.length===0)return n;const s=e&&typeof e=="object"&&!Array.isArray(e)?Ir(e):{};let o=s;return r.forEach((i,l)=>{if(l===r.length-1){o[i]=n;return}const u=o[i],c=u&&typeof u=="object"&&!Array.isArray(u)?{...u}:{};o[i]=c,o=c}),s}function kp(e,t){return t}function A2(e,t,n){return Math.min(n,Math.max(t,e))}function M2(e){const t=kp(void 0,k2),n=Math.max(1,Math.trunc(kp(void 0,C2))),r=new URLSearchParams({profiling_interval:t.toString(),profiling_max_samples:n.toString()}).toString(),s=e.includes("?")?"&":"?";return`${e}${s}${r}`}function R2(){const e=window.location.protocol==="https:"?"wss":"ws";return M2(`${e}://${window.location.host}/ws/events`)}async function Cp(e){const t=e.includes("?")?"&":"?",n=`${e}${t}_ts=${Date.now()}`,r=await fetch(n,{cache:"no-store",headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(!r.ok)throw new Error(`${e} failed (${r.status})`);return await r.json()}async function Ip(e,t){const n=e.includes("?")?"&":"?",r=`${e}${n}_ts=${Date.now()}`,s=await fetch(r,{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json","Cache-Control":"no-cache",Pragma:"no-cache"},body:JSON.stringify(t)});if(!s.ok){let o=`${e} failed (${s.status})`;try{const i=await s.json();typeof i.detail=="string"&&i.detail.length>0&&(o=i.detail)}catch{}throw new Error(o)}return await s.json()}function bp(e){return typeof e=="object"&&e!==null}function O2(e){return bp(e)?typeof e.kind=="string"&&bp(e.data):!1}function L2(e){const[t,n]=E.useState(null),[r,s]=E.useState(null),[o,i]=E.useState(null),[l,a]=E.useState([]),[u,c]=E.useState("connecting"),[d,f]=E.useState(null),[h,_]=E.useState(null),x=Math.round(A2(((e==null?void 0:e.snapshotPollSeconds)??2)*1e3,500,3e4)),N=E.useMemo(()=>S2(b2()),[]),p=E.useRef(null),g=E.useRef(null),y=E.useRef(new Map),w=E.useRef(new Map),P=E.useRef(new Map),L=E.useCallback(k=>{const T=y.current.get(k);T!==void 0&&(window.clearInterval(T),y.current.delete(k))},[]),O=E.useCallback(()=>{for(const k of y.current.values())window.clearInterval(k);y.current.clear(),w.current.clear(),P.current.clear()},[]),A=E.useCallback(async()=>{if(N){const T=Ir(N.snapshot);s(T),_(Date.now());return}const k=await Cp("/api/snapshot");s(k),_(Date.now())},[N]),j=E.useCallback(async()=>{if(N){n(Ir(N.health));return}const k=await Cp("/api/health");n(k)},[N]);E.useEffect(()=>{if(N)return O(),n(Ir(N.health)),s(Ir(N.snapshot)),i(null),a([]),c("open"),f(null),_(Date.now()),()=>{O()}},[O,N]);const z=E.useCallback(()=>{p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{A().catch(k=>{const T=k instanceof Error?k.message:"Snapshot refresh failed.";f(T)}),p.current=null},N2)},[A]);E.useEffect(()=>{N||(j().catch(k=>{const T=k instanceof Error?k.message:"Health check failed.";f(T)}),A().catch(k=>{const T=k instanceof Error?k.message:"Initial snapshot failed.";f(T)}))},[N,j,A]),E.useEffect(()=>{if(N)return;const k=window.setInterval(()=>{A().catch(T=>{const M=T instanceof Error?T.message:"Snapshot poll failed.";f(M)})},x);return()=>{window.clearInterval(k)}},[N,A,x]),E.useEffect(()=>{if(N)return;let k=!1,T=null;const M=()=>{k||(c("connecting"),T=new WebSocket(R2()),T.onopen=()=>{k||(c("open"),f(null))},T.onmessage=I=>{let S=null;try{S=JSON.parse(I.data)}catch{return}if(!O2(S))return;const b=S;a(F=>[b,...F].slice(0,E2)),b.kind==="topology.changed"&&z(),b.kind==="settings.changed"&&s(F=>{if(!F)return F;const R=b,X=F.settings[R.data.component_address]??null,Q={...F.settings,[R.data.component_address]:{...R.data.value,patchable:(X==null?void 0:X.patchable)??!1,patch_error:(X==null?void 0:X.patch_error)??null,component_type:(X==null?void 0:X.component_type)??null,component_name:(X==null?void 0:X.component_name)??null}};return{...F,settings:Q}}),b.kind==="profiling.trace"&&i(b),b.kind==="system.error"&&f(b.data.message)},T.onerror=()=>{k||c("closed")},T.onclose=()=>{k||(c("closed"),g.current=window.setTimeout(()=>{M()},T2))})};return M(),()=>{k=!0,T!==null&&T.close(),g.current!==null&&window.clearTimeout(g.current),p.current!==null&&window.clearTimeout(p.current)}},[N,z]);const U=E.useMemo(()=>l.filter(k=>k.kind==="topology.changed"),[l]),Z=E.useCallback(async()=>{try{await A()}catch(k){const T=k instanceof Error?k.message:"Snapshot refresh failed.";f(T)}},[A]),D=E.useCallback(async(k,T,M,I=2)=>{if(N){let F=null;return s(R=>{if(!R)return R;const X=R.settings[k];if(!X)return R;const Q=X.structured_value??X.repr_value,re=P2(Q,T,M);return F={...X,structured_value:re,repr_value:re},{...R,settings:{...R.settings,[k]:F}}}),_(Date.now()),{component_address:k,field_path:T,updated_value:F??Ir(N.snapshot.settings[k])}}const S=encodeURIComponent(k),b=await Ip(`/api/settings/${S}/field`,{field_path:T,value:M,timeout:I});return s(F=>{if(!F)return F;const R=F.settings[b.component_address]??null;return{...F,settings:{...F.settings,[b.component_address]:{...b.updated_value,patchable:(R==null?void 0:R.patchable)??!0,patch_error:(R==null?void 0:R.patch_error)??null,component_type:(R==null?void 0:R.component_type)??null,component_name:(R==null?void 0:R.component_name)??null}}}}),_(Date.now()),b},[N]),v=E.useCallback(async k=>{if(N){const T=`${k.process_id}:${k.publisher_endpoint_id??"*"}`;if(!k.enabled){if(k.publisher_endpoint_id)L(T);else for(const I of Array.from(y.current.keys()))I.startsWith(`${k.process_id}:`)&&L(I);return{process_id:k.process_id,unit_address:"",enabled:!1,control:{fixture:!0,metrics:k.metrics??[]}}}const M=(N.traceScenarios??[]).find(I=>I.processId===k.process_id&&I.publisherEndpointId===k.publisher_endpoint_id&&I.publisherTopic===k.publisher_topic);if(M){L(T),P.current.has(T)||P.current.set(T,Date.now()*1e6),w.current.has(T)||w.current.set(T,0);const I=()=>{const b=P.current.get(T)??Date.now()*1e6,F=w.current.get(T)??0,R=[],X=new Set(k.metrics??[]),Q=X.size===0||X.has("publish_delta_ns"),re=X.size===0||X.has("lease_time_ns"),J=X.size===0||X.has("user_span_ns");for(let fe=0;fe=9466848e5&&e<=41024448e5?e:e>=946684800&&e<=4102444800?e*1e3:null}function H2(e){return e.toLowerCase().includes("collection")}function W2(e){if(e.kind==="unit")return{kind:"unit",unitAddress:e.unitAddress};if(e.kind==="collection")return{kind:"collection",collectionAddress:e.collectionAddress};const t=W_(e.streamAddress);return{kind:e.kind,unitAddress:e.unitAddress,endpointId:t.endpointId,topic:t.topic}}function V2(e,t){var r;const n=((r=t==null?void 0:t[e])==null?void 0:r.component_type)??"";return H2(n)?{kind:"collection",collectionAddress:e}:{kind:"unit",unitAddress:e}}function G2(e){return(e==null?void 0:e.kind)==="unit"?e.unitAddress:(e==null?void 0:e.kind)==="collection"?e.collectionAddress:null}function Y2(e){if(!e||typeof e!="object")return Lt;const t=e,n=typeof t.snapshotPollSeconds=="number"&&Number.isFinite(t.snapshotPollSeconds)?Math.min(30,Math.max(.5,t.snapshotPollSeconds)):Lt.snapshotPollSeconds,r=typeof t.inspectorWidthPx=="number"&&Number.isFinite(t.inspectorWidthPx)?Math.min(900,Math.max(360,Math.round(t.inspectorWidthPx))):Lt.inspectorWidthPx,s=t.traceMetricsPreset==="publish+lease"||t.traceMetricsPreset==="publish"||t.traceMetricsPreset==="publish+lease+user"?t.traceMetricsPreset:Lt.traceMetricsPreset,o=t.edgeConnectorStyle==="orthogonal"||t.edgeConnectorStyle==="smooth"||t.edgeConnectorStyle==="curved"?t.edgeConnectorStyle:Lt.edgeConnectorStyle;return{snapshotPollSeconds:n,themeMode:t.themeMode==="dark"?"dark":"light",topologyDefaultLayout:t.topologyDefaultLayout==="lr"?"lr":"tb",edgeConnectorStyle:o,showLegend:typeof t.showLegend=="boolean"?t.showLegend:Lt.showLegend,showMiniMap:typeof t.showMiniMap=="boolean"?t.showMiniMap:Lt.showMiniMap,traceMetricsPreset:s,autoFitOnLayoutScopeChange:typeof t.autoFitOnLayoutScopeChange=="boolean"?t.autoFitOnLayoutScopeChange:Lt.autoFitOnLayoutScopeChange,autoFocusOnInspectorSelection:typeof t.autoFocusOnInspectorSelection=="boolean"?t.autoFocusOnInspectorSelection:Lt.autoFocusOnInspectorSelection,inspectorWidthPx:r}}function K2(e,t,n){const r=[],s=[];return e==="closed"?r.push("WebSocket disconnected"):e==="connecting"&&s.push("WebSocket connecting"),t===null?s.push("Graph health pending"):t||r.push("Graph session inactive"),n&&r.push(n),r.length>0?{tone:"err",tooltip:r.join(" · ")}:s.length>0?{tone:"warn",tooltip:s.join(" · ")}:{tone:"ok",tooltip:"Connected: GraphServer reachable, WebSocket open, session active."}}function X2(){const[e,t]=E.useState(null),[n,r]=E.useState(!1),[s,o]=E.useState(0),[i,l]=E.useState(0),[a,u]=E.useState(!1),[c,d]=E.useState(!0),[f,h]=E.useState(!1),[_,x]=E.useState(null),[N,p]=E.useState(0),[g,y]=E.useState(null),[w,P]=E.useState(null),[L,O]=E.useState(0),[A,j]=E.useState(()=>{try{const K=window.localStorage.getItem(Pp);return K?Y2(JSON.parse(K)):Lt}catch{return Lt}});E.useEffect(()=>{window.localStorage.setItem(Pp,JSON.stringify(A))},[A]);const{health:z,snapshot:U,latestTraceEvent:Z,connectionState:D,error:v,lastSnapshotUpdateMs:k,topologyEvents:T,patchSettingField:M,setProfilingTraceControl:I}=L2({snapshotPollSeconds:A.snapshotPollSeconds}),S=E.useMemo(()=>{let K=0;for(const C of Object.values((U==null?void 0:U.profiling)??{}))if(typeof C.timestamp=="number"&&Number.isFinite(C.timestamp)){const B=U2(C.timestamp);B!==null&&(K=Math.max(K,B))}return K<=0?k:K},[k,U==null?void 0:U.profiling]),b=z!=null&&z.graph_address&&z.graph_address.length>0?z.graph_address:D2,F=S?new Date(S).toLocaleTimeString():"n/a",R=E.useMemo(()=>K2(D,(z==null?void 0:z.graph_session_active)??null,v),[D,z==null?void 0:z.graph_session_active,v]),X=E.useMemo(()=>A.traceMetricsPreset==="publish"?["publish_delta_ns"]:A.traceMetricsPreset==="publish+lease"?["publish_delta_ns","lease_time_ns"]:["publish_delta_ns","lease_time_ns","user_span_ns"],[A.traceMetricsPreset]),Q=E.useMemo(()=>({"--inspector-width":`${A.inspectorWidthPx}px`}),[A.inspectorWidthPx]),re=K=>{if(P(null),!K){t(null);return}h(!1);const C=W2(K);C.kind==="unit"||C.kind==="collection"?(d(!1),l(B=>B+1)):(u(!1),o(B=>B+1)),t(C)},J=K=>{P(K),O(C=>C+1)},fe=()=>{p(K=>K+1),x(null)},V=()=>{if(a){u(!1);return}if(c){u(!0),d(!1);return}u(!0)},me=()=>{if(c){d(!1);return}if(a){d(!0),u(!1);return}d(!0)};return m.jsxs("div",{className:`dashboard-layout is-comfortable ${f?"is-inspector-collapsed ":""}${A.themeMode==="dark"?"is-dark":""}`,style:Q,children:[m.jsx("aside",{className:"dashboard-inspector dashboard-inspector--pinned",children:m.jsxs("div",{className:`dashboard-inspector__body ${a?"is-publishers-collapsed ":""}${c?"is-settings-collapsed":""}`,children:[m.jsxs("section",{className:"inspector-section inspector-section--split",children:[m.jsxs("header",{className:"inspector-section__header",children:[m.jsx("span",{children:"Publishers"}),m.jsx("button",{type:"button",className:"inspector-section__collapse-btn",onClick:V,children:a?"Expand":"Collapse"})]}),a?null:m.jsx("div",{className:"inspector-section__content inspector-section__content--scroll",children:m.jsx(d1,{graphSnapshot:(U==null?void 0:U.snapshot)??null,profilingSnapshot:(U==null?void 0:U.profiling)??null,latestTraceEvent:Z,setProfilingTraceControl:I,darkMode:A.themeMode==="dark",focusPublisherEndpointId:(e==null?void 0:e.kind)==="publisher"?e.endpointId:null,focusPublisherTopic:(e==null?void 0:e.kind)==="publisher"?e.topic:null,focusSubscriberEndpointId:(e==null?void 0:e.kind)==="subscriber"?e.endpointId:null,focusActionId:s,hideFilters:!1,defaultTraceMetrics:X,traceDockHost:g,onTraceDockStateChange:x,traceCloseSignal:N,onPublisherSelect:K=>{t({kind:"publisher",unitAddress:K.unitAddress,endpointId:K.endpointId,topic:K.topic}),J({kind:"publisher",streamAddress:`${K.topic}:${K.endpointId}`,unitAddress:K.unitAddress})},onSubscriberSelect:K=>{t({kind:"subscriber",unitAddress:K.unitAddress,endpointId:K.endpointId,topic:K.topic}),J({kind:"subscriber",streamAddress:`${K.topic}:${K.endpointId}`,unitAddress:K.unitAddress})}})})]}),m.jsxs("section",{className:"inspector-section inspector-section--split",children:[m.jsxs("header",{className:"inspector-section__header",children:[m.jsx("span",{children:"Settings"}),m.jsx("button",{type:"button",className:"inspector-section__collapse-btn",onClick:me,children:c?"Expand":"Collapse"})]}),c?null:m.jsx("div",{className:"inspector-section__content inspector-section__content--scroll",children:m.jsx(g1,{settings:(U==null?void 0:U.settings)??null,patchSettingField:M,focusComponentAddress:G2(e),focusActionId:i,onComponentSelect:K=>{if(!K){t(null);return}l(B=>B+1);const C=V2(K,U==null?void 0:U.settings);t(C),J(C.kind==="collection"?{kind:"collection",collectionAddress:C.collectionAddress}:{kind:"unit",unitAddress:C.unitAddress})}})})]})]})}),m.jsxs("div",{className:"dashboard-main",children:[m.jsxs("div",{className:"dashboard-viewport",children:[m.jsx(d2,{graphSnapshot:(U==null?void 0:U.snapshot)??null,profilingSnapshot:(U==null?void 0:U.profiling)??null,recentEvents:T,immersive:!0,showLegend:A.showLegend,showMiniMap:A.showMiniMap,darkMode:A.themeMode==="dark",defaultLayout:A.topologyDefaultLayout,edgeConnectorStyle:A.edgeConnectorStyle,autoFitOnLayoutScopeChange:A.autoFitOnLayoutScopeChange,autoFocusOnSelection:A.autoFocusOnInspectorSelection,focusSelection:w,focusRequestId:L,onEntitySelect:re}),m.jsxs("section",{className:"dashboard-brand-card",children:[m.jsx("span",{className:`dashboard-health-dot is-${R.tone}`,title:R.tooltip,"aria-label":R.tooltip}),m.jsx("img",{src:$2,alt:"ezmsg",className:"dashboard-brand-logo-image"}),m.jsx("div",{className:"dashboard-brand-card__title-row",children:m.jsx("h1",{className:"mono",children:"ezmsg-dashboard"})}),m.jsxs("p",{className:"dashboard-brand-card__meta-line",children:[m.jsxs("span",{className:"mono",children:["GraphServer ",b]}),m.jsx("span",{children:"·"}),m.jsxs("span",{className:"mono",children:["Snapshot ",F]})]})]}),m.jsxs("div",{className:"dashboard-floating-control-dock","aria-label":"Viewport shortcuts",children:[m.jsx("button",{type:"button",className:"topology-layout-btn dashboard-floating-shortcut-btn",onClick:()=>j(K=>({...K,topologyDefaultLayout:K.topologyDefaultLayout==="lr"?"tb":"lr"})),title:A.topologyDefaultLayout==="lr"?"Topology layout: left-to-right":"Topology layout: top-to-bottom","aria-label":A.topologyDefaultLayout==="lr"?"Topology layout left-to-right":"Topology layout top-to-bottom",children:A.topologyDefaultLayout==="lr"?m.jsx(z2,{}):m.jsx(F2,{})}),m.jsx("button",{type:"button",className:"topology-layout-btn dashboard-floating-shortcut-btn",onClick:()=>j(K=>({...K,themeMode:K.themeMode==="dark"?"light":"dark"})),title:A.themeMode==="dark"?"Theme: dark":"Theme: light","aria-label":A.themeMode==="dark"?"Theme dark":"Theme light",children:A.themeMode==="dark"?m.jsx(j2,{}):m.jsx(B2,{})}),m.jsx("button",{type:"button",className:"topology-layout-btn dashboard-floating-gear-btn",onClick:()=>r(!0),title:"Global Settings","aria-label":"Global Settings",children:"⚙"})]}),m.jsx("button",{type:"button",className:`topology-layout-btn dashboard-floating-inspector-btn ${f?"is-collapsed":""}`.trim(),onClick:()=>h(K=>!K),title:f?"Show Inspector":"Hide Inspector","aria-label":f?"Show Inspector":"Hide Inspector",children:f?"«":"»"}),n?m.jsx("div",{className:"dashboard-modal-backdrop",onClick:()=>r(!1),children:m.jsxs("section",{className:"dashboard-modal",onClick:K=>K.stopPropagation(),children:[m.jsxs("header",{className:"dashboard-modal__header",children:[m.jsx("h2",{children:"Global Settings"}),m.jsx("button",{type:"button",className:"topology-layout-btn",onClick:()=>r(!1),children:"Close"})]}),m.jsxs("div",{className:"dashboard-modal__body",children:[m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Snapshot Poll Frequency (seconds)"}),m.jsx("input",{type:"number",min:.5,max:30,step:.5,value:A.snapshotPollSeconds,onChange:K=>{const C=Number.parseFloat(K.target.value);Number.isFinite(C)&&j(B=>({...B,snapshotPollSeconds:Math.max(.5,Math.min(30,C))}))}})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Theme"}),m.jsxs("select",{value:A.themeMode,onChange:K=>j(C=>({...C,themeMode:K.target.value==="dark"?"dark":"light"})),children:[m.jsx("option",{value:"light",children:"Light"}),m.jsx("option",{value:"dark",children:"Dark"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Default Topology Layout"}),m.jsxs("select",{value:A.topologyDefaultLayout,onChange:K=>j(C=>({...C,topologyDefaultLayout:K.target.value==="lr"?"lr":"tb"})),children:[m.jsx("option",{value:"tb",children:"Top to Bottom"}),m.jsx("option",{value:"lr",children:"Left to Right"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Edge Connector Type"}),m.jsxs("select",{value:A.edgeConnectorStyle,onChange:K=>j(C=>({...C,edgeConnectorStyle:K.target.value==="orthogonal"||K.target.value==="smooth"?K.target.value:"curved"})),children:[m.jsx("option",{value:"curved",children:"Curved (Bezier)"}),m.jsx("option",{value:"orthogonal",children:"Orthogonal (Step)"}),m.jsx("option",{value:"smooth",children:"Smooth Step"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Default Trace Metrics"}),m.jsxs("select",{value:A.traceMetricsPreset,onChange:K=>j(C=>({...C,traceMetricsPreset:K.target.value==="publish"||K.target.value==="publish+lease"?K.target.value:"publish+lease+user"})),children:[m.jsx("option",{value:"publish+lease+user",children:"Publish + Lease + User"}),m.jsx("option",{value:"publish+lease",children:"Publish + Lease"}),m.jsx("option",{value:"publish",children:"Publish Only"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Inspector Width (px)"}),m.jsx("input",{type:"number",min:360,max:900,step:10,value:A.inspectorWidthPx,onChange:K=>{const C=Number.parseInt(K.target.value,10);Number.isFinite(C)&&j(B=>({...B,inspectorWidthPx:Math.max(360,Math.min(900,C))}))}})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:A.autoFocusOnInspectorSelection,onChange:K=>j(C=>({...C,autoFocusOnInspectorSelection:K.target.checked}))}),m.jsx("span",{children:"Auto-focus topology on inspector selection"})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:A.autoFitOnLayoutScopeChange,onChange:K=>j(C=>({...C,autoFitOnLayoutScopeChange:K.target.checked}))}),m.jsx("span",{children:"Auto-fit on layout/scope change"})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:A.showLegend,onChange:K=>j(C=>({...C,showLegend:K.target.checked}))}),m.jsx("span",{children:"Show legend"})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:A.showMiniMap,onChange:K=>j(C=>({...C,showMiniMap:K.target.checked}))}),m.jsx("span",{children:"Show minimap"})]})]})]})}):null]}),_!=null&&_.active?m.jsxs("section",{className:"trace-dock",children:[m.jsxs("header",{className:"trace-dock__header",children:[m.jsx("div",{className:"trace-dock__title-wrap",children:m.jsx("h3",{children:"Realtime Profiling Trace"})}),m.jsxs("div",{className:"trace-dock__actions",children:[m.jsx("span",{className:`trace-status ${_.status==="capturing"?"is-live":""}`,children:_.status}),m.jsx("button",{type:"button",className:"topology-layout-btn trace-dock__close-btn",onClick:fe,title:"Close trace","aria-label":"Close trace",children:"✕"})]})]}),m.jsx("div",{className:"trace-dock__body",children:m.jsx("div",{className:"trace-dock__host",ref:y})})]}):null]})]})}La.createRoot(document.getElementById("root")).render(m.jsx(W.StrictMode,{children:m.jsx(X2,{})})); diff --git a/src/ezmsg/dashboard/_web/assets/index-KcK4UZ3i.js b/src/ezmsg/dashboard/_web/assets/index-KcK4UZ3i.js deleted file mode 100644 index 58565e2..0000000 --- a/src/ezmsg/dashboard/_web/assets/index-KcK4UZ3i.js +++ /dev/null @@ -1,60 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();function Cp(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ip={exports:{}},fl={},bp={exports:{}},_e={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var To=Symbol.for("react.element"),q0=Symbol.for("react.portal"),J0=Symbol.for("react.fragment"),ey=Symbol.for("react.strict_mode"),ty=Symbol.for("react.profiler"),ny=Symbol.for("react.provider"),ry=Symbol.for("react.context"),sy=Symbol.for("react.forward_ref"),oy=Symbol.for("react.suspense"),iy=Symbol.for("react.memo"),ly=Symbol.for("react.lazy"),ad=Symbol.iterator;function ay(e){return e===null||typeof e!="object"?null:(e=ad&&e[ad]||e["@@iterator"],typeof e=="function"?e:null)}var Pp={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Ap=Object.assign,Rp={};function fs(e,t,n){this.props=e,this.context=t,this.refs=Rp,this.updater=n||Pp}fs.prototype.isReactComponent={};fs.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};fs.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Mp(){}Mp.prototype=fs.prototype;function Gu(e,t,n){this.props=e,this.context=t,this.refs=Rp,this.updater=n||Pp}var Yu=Gu.prototype=new Mp;Yu.constructor=Gu;Ap(Yu,fs.prototype);Yu.isPureReactComponent=!0;var ud=Array.isArray,Op=Object.prototype.hasOwnProperty,Ku={current:null},Lp={key:!0,ref:!0,__self:!0,__source:!0};function $p(e,t,n){var r,s={},o=null,i=null;if(t!=null)for(r in t.ref!==void 0&&(i=t.ref),t.key!==void 0&&(o=""+t.key),t)Op.call(t,r)&&!Lp.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1>>1,j=C[B];if(0>>1;Bs(ne,b))ses(fe,ne)?(C[B]=fe,C[se]=b,B=se):(C[B]=ne,C[Q]=b,B=Q);else if(ses(fe,b))C[B]=fe,C[se]=b,B=se;else break e}}return S}function s(C,S){var b=C.sortIndex-S.sortIndex;return b!==0?b:C.id-S.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var a=[],u=[],c=1,d=null,f=3,h=!1,x=!1,_=!1,T=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,g=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(C){for(var S=n(u);S!==null;){if(S.callback===null)r(u);else if(S.startTime<=C)r(u),S.sortIndex=S.expirationTime,t(a,S);else break;S=n(u)}}function w(C){if(_=!1,y(C),!x)if(n(a)!==null)x=!0,N(P);else{var S=n(u);S!==null&&M(w,S.startTime-C)}}function P(C,S){x=!1,_&&(_=!1,p(R),R=-1),h=!0;var b=f;try{for(y(S),d=n(a);d!==null&&(!(d.expirationTime>S)||C&&!H());){var B=d.callback;if(typeof B=="function"){d.callback=null,f=d.priorityLevel;var j=B(d.expirationTime<=S);S=e.unstable_now(),typeof j=="function"?d.callback=j:d===n(a)&&r(a),y(S)}else r(a);d=n(a)}if(d!==null)var Y=!0;else{var Q=n(u);Q!==null&&M(w,Q.startTime-S),Y=!1}return Y}finally{d=null,f=b,h=!1}}var O=!1,L=null,R=-1,F=5,D=-1;function H(){return!(e.unstable_now()-DC||125B?(C.sortIndex=b,t(u,C),n(a)===null&&C===n(u)&&(_?(p(R),R=-1):_=!0,M(w,b-B))):(C.sortIndex=j,t(a,C),x||h||(x=!0,N(P))),C},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(C){var S=f;return function(){var b=f;f=S;try{return C.apply(this,arguments)}finally{f=b}}}})(Dp);zp.exports=Dp;var _y=zp.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var xy=E,xt=_y;function J(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ma=Object.prototype.hasOwnProperty,wy=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,dd={},fd={};function Sy(e){return Ma.call(fd,e)?!0:Ma.call(dd,e)?!1:wy.test(e)?fd[e]=!0:(dd[e]=!0,!1)}function Ey(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Ny(e,t,n,r){if(t===null||typeof t>"u"||Ey(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function at(e,t,n,r,s,o,i){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=i}var Ze={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ze[e]=new at(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ze[t]=new at(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ze[e]=new at(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ze[e]=new at(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Ze[e]=new at(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ze[e]=new at(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ze[e]=new at(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ze[e]=new at(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ze[e]=new at(e,5,!1,e.toLowerCase(),null,!1,!1)});var Qu=/[\-:]([a-z])/g;function Zu(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Qu,Zu);Ze[t]=new at(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Qu,Zu);Ze[t]=new at(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Qu,Zu);Ze[t]=new at(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ze[e]=new at(e,1,!1,e.toLowerCase(),null,!1,!1)});Ze.xlinkHref=new at("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ze[e]=new at(e,1,!1,e.toLowerCase(),null,!0,!0)});function qu(e,t,n,r){var s=Ze.hasOwnProperty(t)?Ze[t]:null;(s!==null?s.type!==0:r||!(2l||s[i]!==o[l]){var a=` -`+s[i].replace(" at new "," at ");return e.displayName&&a.includes("")&&(a=a.replace("",e.displayName)),a}while(1<=i&&0<=l);break}}}finally{Ul=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Os(e):""}function Ty(e){switch(e.tag){case 5:return Os(e.type);case 16:return Os("Lazy");case 13:return Os("Suspense");case 19:return Os("SuspenseList");case 0:case 2:case 15:return e=Hl(e.type,!1),e;case 11:return e=Hl(e.type.render,!1),e;case 1:return e=Hl(e.type,!0),e;default:return""}}function Ba(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Ar:return"Fragment";case Pr:return"Portal";case Oa:return"Profiler";case Ju:return"StrictMode";case La:return"Suspense";case $a:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Wp:return(e.displayName||"Context")+".Consumer";case Hp:return(e._context.displayName||"Context")+".Provider";case ec:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tc:return t=e.displayName||null,t!==null?t:Ba(e.type)||"Memo";case Nn:t=e._payload,e=e._init;try{return Ba(e(t))}catch{}}return null}function ky(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ba(t);case 8:return t===Ju?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Un(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Gp(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Cy(e){var t=Gp(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(i){r=""+i,o.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Lo(e){e._valueTracker||(e._valueTracker=Cy(e))}function Yp(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Gp(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function bi(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function ja(e,t){var n=t.checked;return Le({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function hd(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Un(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Kp(e,t){t=t.checked,t!=null&&qu(e,"checked",t,!1)}function Fa(e,t){Kp(e,t);var n=Un(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?za(e,t.type,n):t.hasOwnProperty("defaultValue")&&za(e,t.type,Un(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function md(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function za(e,t,n){(t!=="number"||bi(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Ls=Array.isArray;function Gr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=$o.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function qs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ds={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Iy=["Webkit","ms","Moz","O"];Object.keys(Ds).forEach(function(e){Iy.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ds[t]=Ds[e]})});function qp(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ds.hasOwnProperty(e)&&Ds[e]?(""+t).trim():t+"px"}function Jp(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=qp(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var by=Le({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ha(e,t){if(t){if(by[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(J(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(J(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(J(61))}if(t.style!=null&&typeof t.style!="object")throw Error(J(62))}}function Wa(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Va=null;function nc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ga=null,Yr=null,Kr=null;function vd(e){if(e=Io(e)){if(typeof Ga!="function")throw Error(J(280));var t=e.stateNode;t&&(t=yl(t),Ga(e.stateNode,e.type,t))}}function eh(e){Yr?Kr?Kr.push(e):Kr=[e]:Yr=e}function th(){if(Yr){var e=Yr,t=Kr;if(Kr=Yr=null,vd(e),t)for(e=0;e>>=0,e===0?32:31-(zy(e)/Dy|0)|0}var Bo=64,jo=4194304;function $s(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mi(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,o=e.pingedLanes,i=n&268435455;if(i!==0){var l=i&~s;l!==0?r=$s(l):(o&=i,o!==0&&(r=$s(o)))}else i=n&~s,i!==0?r=$s(i):o!==0&&(r=$s(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,o=t&-t,s>=o||s===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function ko(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-zt(t),e[t]=n}function Vy(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Hs),Cd=" ",Id=!1;function wh(e,t){switch(e){case"keyup":return _v.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sh(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Rr=!1;function wv(e,t){switch(e){case"compositionend":return Sh(t);case"keypress":return t.which!==32?null:(Id=!0,Cd);case"textInput":return e=t.data,e===Cd&&Id?null:e;default:return null}}function Sv(e,t){if(Rr)return e==="compositionend"||!cc&&wh(e,t)?(e=_h(),mi=lc=An=null,Rr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Rd(n)}}function kh(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?kh(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ch(){for(var e=window,t=bi();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=bi(e.document)}return t}function dc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Av(e){var t=Ch(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&kh(n.ownerDocument.documentElement,n)){if(r!==null&&dc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,o=Math.min(r.start,s);r=r.end===void 0?o:Math.min(r.end,s),!e.extend&&o>r&&(s=r,r=o,o=s),s=Md(n,o);var i=Md(n,r);s&&i&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,Mr=null,qa=null,Vs=null,Ja=!1;function Od(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ja||Mr==null||Mr!==bi(r)||(r=Mr,"selectionStart"in r&&dc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Vs&&so(Vs,r)||(Vs=r,r=$i(qa,"onSelect"),0$r||(e.current=ou[$r],ou[$r]=null,$r--)}function ke(e,t){$r++,ou[$r]=e.current,e.current=t}var Hn={},rt=Vn(Hn),ht=Vn(!1),fr=Hn;function ns(e,t){var n=e.type.contextTypes;if(!n)return Hn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},o;for(o in n)s[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function mt(e){return e=e.childContextTypes,e!=null}function ji(){be(ht),be(rt)}function Dd(e,t,n){if(rt.current!==Hn)throw Error(J(168));ke(rt,t),ke(ht,n)}function $h(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(J(108,ky(e)||"Unknown",s));return Le({},n,r)}function Fi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Hn,fr=rt.current,ke(rt,e),ke(ht,ht.current),!0}function Ud(e,t,n){var r=e.stateNode;if(!r)throw Error(J(169));n?(e=$h(e,t,fr),r.__reactInternalMemoizedMergedChildContext=e,be(ht),be(rt),ke(rt,e)):be(ht),ke(ht,n)}var ln=null,vl=!1,ra=!1;function Bh(e){ln===null?ln=[e]:ln.push(e)}function Hv(e){vl=!0,Bh(e)}function Gn(){if(!ra&&ln!==null){ra=!0;var e=0,t=Te;try{var n=ln;for(Te=1;e>=i,s-=i,an=1<<32-zt(t)+s|n<R?(F=L,L=null):F=L.sibling;var D=f(p,L,y[R],w);if(D===null){L===null&&(L=F);break}e&&L&&D.alternate===null&&t(p,L),g=o(D,g,R),O===null?P=D:O.sibling=D,O=D,L=F}if(R===y.length)return n(p,L),Pe&&Zn(p,R),P;if(L===null){for(;RR?(F=L,L=null):F=L.sibling;var H=f(p,L,D.value,w);if(H===null){L===null&&(L=F);break}e&&L&&H.alternate===null&&t(p,L),g=o(H,g,R),O===null?P=H:O.sibling=H,O=H,L=F}if(D.done)return n(p,L),Pe&&Zn(p,R),P;if(L===null){for(;!D.done;R++,D=y.next())D=d(p,D.value,w),D!==null&&(g=o(D,g,R),O===null?P=D:O.sibling=D,O=D);return Pe&&Zn(p,R),P}for(L=r(p,L);!D.done;R++,D=y.next())D=h(L,p,R,D.value,w),D!==null&&(e&&D.alternate!==null&&L.delete(D.key===null?R:D.key),g=o(D,g,R),O===null?P=D:O.sibling=D,O=D);return e&&L.forEach(function(Z){return t(p,Z)}),Pe&&Zn(p,R),P}function T(p,g,y,w){if(typeof y=="object"&&y!==null&&y.type===Ar&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case Oo:e:{for(var P=y.key,O=g;O!==null;){if(O.key===P){if(P=y.type,P===Ar){if(O.tag===7){n(p,O.sibling),g=s(O,y.props.children),g.return=p,p=g;break e}}else if(O.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Nn&&Vd(P)===O.type){n(p,O.sibling),g=s(O,y.props),g.ref=Ss(p,O,y),g.return=p,p=g;break e}n(p,O);break}else t(p,O);O=O.sibling}y.type===Ar?(g=ur(y.props.children,p.mode,w,y.key),g.return=p,p=g):(w=Ei(y.type,y.key,y.props,null,p.mode,w),w.ref=Ss(p,g,y),w.return=p,p=w)}return i(p);case Pr:e:{for(O=y.key;g!==null;){if(g.key===O)if(g.tag===4&&g.stateNode.containerInfo===y.containerInfo&&g.stateNode.implementation===y.implementation){n(p,g.sibling),g=s(g,y.children||[]),g.return=p,p=g;break e}else{n(p,g);break}else t(p,g);g=g.sibling}g=da(y,p.mode,w),g.return=p,p=g}return i(p);case Nn:return O=y._init,T(p,g,O(y._payload),w)}if(Ls(y))return x(p,g,y,w);if(ys(y))return _(p,g,y,w);Vo(p,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,g!==null&&g.tag===6?(n(p,g.sibling),g=s(g,y),g.return=p,p=g):(n(p,g),g=ca(y,p.mode,w),g.return=p,p=g),i(p)):n(p,g)}return T}var ss=Dh(!0),Uh=Dh(!1),Ui=Vn(null),Hi=null,Fr=null,mc=null;function gc(){mc=Fr=Hi=null}function yc(e){var t=Ui.current;be(Ui),e._currentValue=t}function au(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Qr(e,t){Hi=e,mc=Fr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ft=!0),e.firstContext=null)}function Pt(e){var t=e._currentValue;if(mc!==e)if(e={context:e,memoizedValue:t,next:null},Fr===null){if(Hi===null)throw Error(J(308));Fr=e,Hi.dependencies={lanes:0,firstContext:e}}else Fr=Fr.next=e;return t}var sr=null;function vc(e){sr===null?sr=[e]:sr.push(e)}function Hh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,vc(t)):(n.next=s.next,s.next=n),t.interleaved=n,mn(e,r)}function mn(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Tn=!1;function _c(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Wh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function dn(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Bn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Se&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,mn(e,n)}return s=r.interleaved,s===null?(t.next=t,vc(r)):(t.next=s.next,s.next=t),r.interleaved=t,mn(e,n)}function yi(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sc(e,n)}}function Gd(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?s=o=i:o=o.next=i,n=n.next}while(n!==null);o===null?s=o=t:o=o.next=t}else s=o=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Wi(e,t,n,r){var s=e.updateQueue;Tn=!1;var o=s.firstBaseUpdate,i=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var a=l,u=a.next;a.next=null,i===null?o=u:i.next=u,i=a;var c=e.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==i&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(o!==null){var d=s.baseState;i=0,c=u=a=null,l=o;do{var f=l.lane,h=l.eventTime;if((r&f)===f){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var x=e,_=l;switch(f=t,h=n,_.tag){case 1:if(x=_.payload,typeof x=="function"){d=x.call(h,d,f);break e}d=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=_.payload,f=typeof x=="function"?x.call(h,d,f):x,f==null)break e;d=Le({},d,f);break e;case 2:Tn=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=s.effects,f===null?s.effects=[l]:f.push(l))}else h={eventTime:h,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=d):c=c.next=h,i|=f;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;f=l,l=f.next,f.next=null,s.lastBaseUpdate=f,s.shared.pending=null}}while(!0);if(c===null&&(a=d),s.baseState=a,s.firstBaseUpdate=u,s.lastBaseUpdate=c,t=s.shared.interleaved,t!==null){s=t;do i|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);mr|=i,e.lanes=i,e.memoizedState=d}}function Yd(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=oa.transition;oa.transition={};try{e(!1),t()}finally{Te=n,oa.transition=r}}function lm(){return At().memoizedState}function Yv(e,t,n){var r=Fn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},am(e))um(t,n);else if(n=Hh(e,t,n,r),n!==null){var s=it();Dt(n,e,r,s),cm(n,t,r)}}function Kv(e,t,n){var r=Fn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(am(e))um(t,s);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var i=t.lastRenderedState,l=o(i,n);if(s.hasEagerState=!0,s.eagerState=l,Ht(l,i)){var a=t.interleaved;a===null?(s.next=s,vc(t)):(s.next=a.next,a.next=s),t.interleaved=s;return}}catch{}finally{}n=Hh(e,t,s,r),n!==null&&(s=it(),Dt(n,e,r,s),cm(n,t,r))}}function am(e){var t=e.alternate;return e===Oe||t!==null&&t===Oe}function um(e,t){Gs=Gi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function cm(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sc(e,n)}}var Yi={readContext:Pt,useCallback:Je,useContext:Je,useEffect:Je,useImperativeHandle:Je,useInsertionEffect:Je,useLayoutEffect:Je,useMemo:Je,useReducer:Je,useRef:Je,useState:Je,useDebugValue:Je,useDeferredValue:Je,useTransition:Je,useMutableSource:Je,useSyncExternalStore:Je,useId:Je,unstable_isNewReconciler:!1},Xv={readContext:Pt,useCallback:function(e,t){return Yt().memoizedState=[e,t===void 0?null:t],e},useContext:Pt,useEffect:Xd,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,_i(4194308,4,nm.bind(null,t,e),n)},useLayoutEffect:function(e,t){return _i(4194308,4,e,t)},useInsertionEffect:function(e,t){return _i(4,2,e,t)},useMemo:function(e,t){var n=Yt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Yt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Yv.bind(null,Oe,e),[r.memoizedState,e]},useRef:function(e){var t=Yt();return e={current:e},t.memoizedState=e},useState:Kd,useDebugValue:Cc,useDeferredValue:function(e){return Yt().memoizedState=e},useTransition:function(){var e=Kd(!1),t=e[0];return e=Gv.bind(null,e[1]),Yt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Oe,s=Yt();if(Pe){if(n===void 0)throw Error(J(407));n=n()}else{if(n=t(),Ye===null)throw Error(J(349));hr&30||Kh(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Xd(Qh.bind(null,r,o,e),[e]),r.flags|=2048,po(9,Xh.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=Yt(),t=Ye.identifierPrefix;if(Pe){var n=un,r=an;n=(r&~(1<<32-zt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=co++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[Kt]=t,e[lo]=r,xm(e,t,!1,!1),t.stateNode=e;e:{switch(i=Wa(n,r),n){case"dialog":Ie("cancel",e),Ie("close",e),s=r;break;case"iframe":case"object":case"embed":Ie("load",e),s=r;break;case"video":case"audio":for(s=0;sls&&(t.flags|=128,r=!0,Es(o,!1),t.lanes=4194304)}else{if(!r)if(e=Vi(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Es(o,!0),o.tail===null&&o.tailMode==="hidden"&&!i.alternate&&!Pe)return et(t),null}else 2*Fe()-o.renderingStartTime>ls&&n!==1073741824&&(t.flags|=128,r=!0,Es(o,!1),t.lanes=4194304);o.isBackwards?(i.sibling=t.child,t.child=i):(n=o.last,n!==null?n.sibling=i:t.child=i,o.last=i)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=Fe(),t.sibling=null,n=Re.current,ke(Re,r?n&1|2:n&1),t):(et(t),null);case 22:case 23:return Mc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?yt&1073741824&&(et(t),t.subtreeFlags&6&&(t.flags|=8192)):et(t),null;case 24:return null;case 25:return null}throw Error(J(156,t.tag))}function r_(e,t){switch(pc(t),t.tag){case 1:return mt(t.type)&&ji(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return os(),be(ht),be(rt),Sc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return wc(t),null;case 13:if(be(Re),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(J(340));rs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return be(Re),null;case 4:return os(),null;case 10:return yc(t.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var Yo=!1,nt=!1,s_=typeof WeakSet=="function"?WeakSet:Set,ue=null;function zr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){$e(e,t,r)}else n.current=null}function yu(e,t,n){try{n()}catch(r){$e(e,t,r)}}var lf=!1;function o_(e,t){if(eu=Oi,e=Ch(),dc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var i=0,l=-1,a=-1,u=0,c=0,d=e,f=null;t:for(;;){for(var h;d!==n||s!==0&&d.nodeType!==3||(l=i+s),d!==o||r!==0&&d.nodeType!==3||(a=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(h=d.firstChild)!==null;)f=d,d=h;for(;;){if(d===e)break t;if(f===n&&++u===s&&(l=i),f===o&&++c===r&&(a=i),(h=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(tu={focusedElem:e,selectionRange:n},Oi=!1,ue=t;ue!==null;)if(t=ue,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ue=e;else for(;ue!==null;){t=ue;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var _=x.memoizedProps,T=x.memoizedState,p=t.stateNode,g=p.getSnapshotBeforeUpdate(t.elementType===t.type?_:Ot(t.type,_),T);p.__reactInternalSnapshotBeforeUpdate=g}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(J(163))}}catch(w){$e(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,ue=e;break}ue=t.return}return x=lf,lf=!1,x}function Ys(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var o=s.destroy;s.destroy=void 0,o!==void 0&&yu(t,n,o)}s=s.next}while(s!==r)}}function wl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vu(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Em(e){var t=e.alternate;t!==null&&(e.alternate=null,Em(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Kt],delete t[lo],delete t[su],delete t[Dv],delete t[Uv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Nm(e){return e.tag===5||e.tag===3||e.tag===4}function af(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Nm(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function _u(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Bi));else if(r!==4&&(e=e.child,e!==null))for(_u(e,t,n),e=e.sibling;e!==null;)_u(e,t,n),e=e.sibling}function xu(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(xu(e,t,n),e=e.sibling;e!==null;)xu(e,t,n),e=e.sibling}var Xe=null,Lt=!1;function xn(e,t,n){for(n=n.child;n!==null;)Tm(e,t,n),n=n.sibling}function Tm(e,t,n){if(Qt&&typeof Qt.onCommitFiberUnmount=="function")try{Qt.onCommitFiberUnmount(pl,n)}catch{}switch(n.tag){case 5:nt||zr(n,t);case 6:var r=Xe,s=Lt;Xe=null,xn(e,t,n),Xe=r,Lt=s,Xe!==null&&(Lt?(e=Xe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Xe.removeChild(n.stateNode));break;case 18:Xe!==null&&(Lt?(e=Xe,n=n.stateNode,e.nodeType===8?na(e.parentNode,n):e.nodeType===1&&na(e,n),no(e)):na(Xe,n.stateNode));break;case 4:r=Xe,s=Lt,Xe=n.stateNode.containerInfo,Lt=!0,xn(e,t,n),Xe=r,Lt=s;break;case 0:case 11:case 14:case 15:if(!nt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var o=s,i=o.destroy;o=o.tag,i!==void 0&&(o&2||o&4)&&yu(n,t,i),s=s.next}while(s!==r)}xn(e,t,n);break;case 1:if(!nt&&(zr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){$e(n,t,l)}xn(e,t,n);break;case 21:xn(e,t,n);break;case 22:n.mode&1?(nt=(r=nt)||n.memoizedState!==null,xn(e,t,n),nt=r):xn(e,t,n);break;default:xn(e,t,n)}}function uf(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new s_),t.forEach(function(r){var s=h_.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Rt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=i),r&=~o}if(r=s,r=Fe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*l_(r/1960))-r,10e?16:e,Rn===null)var r=!1;else{if(e=Rn,Rn=null,Qi=0,Se&6)throw Error(J(331));var s=Se;for(Se|=4,ue=e.current;ue!==null;){var o=ue,i=o.child;if(ue.flags&16){var l=o.deletions;if(l!==null){for(var a=0;aFe()-Ac?ar(e,0):Pc|=n),gt(e,t)}function Mm(e,t){t===0&&(e.mode&1?(t=jo,jo<<=1,!(jo&130023424)&&(jo=4194304)):t=1);var n=it();e=mn(e,t),e!==null&&(ko(e,t,n),gt(e,n))}function p_(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Mm(e,n)}function h_(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(J(314))}r!==null&&r.delete(t),Mm(e,n)}var Om;Om=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ht.current)ft=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ft=!1,t_(e,t,n);ft=!!(e.flags&131072)}else ft=!1,Pe&&t.flags&1048576&&jh(t,Di,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;xi(e,t),e=t.pendingProps;var s=ns(t,rt.current);Qr(t,n),s=Nc(null,t,r,e,s,n);var o=Tc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,mt(r)?(o=!0,Fi(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,_c(t),s.updater=xl,t.stateNode=s,s._reactInternals=t,cu(t,r,e,n),t=pu(null,t,r,!0,o,n)):(t.tag=0,Pe&&o&&fc(t),st(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(xi(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=g_(r),e=Ot(r,e),s){case 0:t=fu(null,t,r,e,n);break e;case 1:t=rf(null,t,r,e,n);break e;case 11:t=tf(null,t,r,e,n);break e;case 14:t=nf(null,t,r,Ot(r.type,e),n);break e}throw Error(J(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ot(r,s),fu(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ot(r,s),rf(e,t,r,s,n);case 3:e:{if(ym(t),e===null)throw Error(J(387));r=t.pendingProps,o=t.memoizedState,s=o.element,Wh(e,t),Wi(t,r,null,n);var i=t.memoizedState;if(r=i.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){s=is(Error(J(423)),t),t=sf(e,t,r,n,s);break e}else if(r!==s){s=is(Error(J(424)),t),t=sf(e,t,r,n,s);break e}else for(vt=$n(t.stateNode.containerInfo.firstChild),_t=t,Pe=!0,Bt=null,n=Uh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(rs(),r===s){t=gn(e,t,n);break e}st(e,t,r,n)}t=t.child}return t;case 5:return Vh(t),e===null&&lu(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,i=s.children,nu(r,s)?i=null:o!==null&&nu(r,o)&&(t.flags|=32),gm(e,t),st(e,t,i,n),t.child;case 6:return e===null&&lu(t),null;case 13:return vm(e,t,n);case 4:return xc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ss(t,null,r,n):st(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ot(r,s),tf(e,t,r,s,n);case 7:return st(e,t,t.pendingProps,n),t.child;case 8:return st(e,t,t.pendingProps.children,n),t.child;case 12:return st(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,o=t.memoizedProps,i=s.value,ke(Ui,r._currentValue),r._currentValue=i,o!==null)if(Ht(o.value,i)){if(o.children===s.children&&!ht.current){t=gn(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){i=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=dn(-1,n&-n),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),au(o.return,n,t),l.lanes|=n;break}a=a.next}}else if(o.tag===10)i=o.type===t.type?null:o.child;else if(o.tag===18){if(i=o.return,i===null)throw Error(J(341));i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),au(i,n,t),i=o.sibling}else i=o.child;if(i!==null)i.return=o;else for(i=o;i!==null;){if(i===t){i=null;break}if(o=i.sibling,o!==null){o.return=i.return,i=o;break}i=i.return}o=i}st(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Qr(t,n),s=Pt(s),r=r(s),t.flags|=1,st(e,t,r,n),t.child;case 14:return r=t.type,s=Ot(r,t.pendingProps),s=Ot(r.type,s),nf(e,t,r,s,n);case 15:return hm(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ot(r,s),xi(e,t),t.tag=1,mt(r)?(e=!0,Fi(t)):e=!1,Qr(t,n),dm(t,r,s),cu(t,r,s,n),pu(null,t,r,!0,e,n);case 19:return _m(e,t,n);case 22:return mm(e,t,n)}throw Error(J(156,t.tag))};function Lm(e,t){return ah(e,t)}function m_(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ct(e,t,n,r){return new m_(e,t,n,r)}function Lc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function g_(e){if(typeof e=="function")return Lc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ec)return 11;if(e===tc)return 14}return 2}function zn(e,t){var n=e.alternate;return n===null?(n=Ct(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ei(e,t,n,r,s,o){var i=2;if(r=e,typeof e=="function")Lc(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case Ar:return ur(n.children,s,o,t);case Ju:i=8,s|=8;break;case Oa:return e=Ct(12,n,t,s|2),e.elementType=Oa,e.lanes=o,e;case La:return e=Ct(13,n,t,s),e.elementType=La,e.lanes=o,e;case $a:return e=Ct(19,n,t,s),e.elementType=$a,e.lanes=o,e;case Vp:return El(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Hp:i=10;break e;case Wp:i=9;break e;case ec:i=11;break e;case tc:i=14;break e;case Nn:i=16,r=null;break e}throw Error(J(130,e==null?e:typeof e,""))}return t=Ct(i,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function ur(e,t,n,r){return e=Ct(7,e,r,t),e.lanes=n,e}function El(e,t,n,r){return e=Ct(22,e,r,t),e.elementType=Vp,e.lanes=n,e.stateNode={isHidden:!1},e}function ca(e,t,n){return e=Ct(6,e,null,t),e.lanes=n,e}function da(e,t,n){return t=Ct(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function y_(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Vl(0),this.expirationTimes=Vl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Vl(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function $c(e,t,n,r,s,o,i,l,a){return e=new y_(e,t,n,l,a),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ct(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_c(o),e}function v_(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Fm)}catch(e){console.error(e)}}Fm(),Fp.exports=St;var zm=Fp.exports,yf=zm;Ra.createRoot=yf.createRoot,Ra.hydrateRoot=yf.hydrateRoot;function Ji({title:e,subtitle:t,children:n}){const r=!!e||!!t;return m.jsxs("section",{className:`panel ${r?"":"panel--headerless"}`.trim(),children:[r?m.jsxs("header",{className:"panel__header",children:[e?m.jsx("h2",{children:e}):null,t?m.jsx("p",{children:t}):null]}):null,m.jsx("div",{className:"panel__body",children:n})]})}const el=["#93c5fd","#a78bfa","#f9a8d4","#86efac","#fdba74","#67e8f9","#fca5a5","#c4b5fd","#fde68a","#6ee7b7","#fda4af","#5eead4","#ddd6fe","#bef264","#fbcfe8","#bae6fd"];function E_(e){let t=0;for(let n=0;n>>0;return t}function N_(e){return`hsl(${(e*137.508%360).toFixed(1)} 75% 68%)`}function vf(e){const t=[...new Set(e)].sort(),n={};for(let r=0;re.layout.cols){R_(e);for(let o=0;ol+a+1||(e.beginPath(),e.moveTo(c,t.top),e.lineTo(c,t.top+t.plotHeight),e.stroke())}for(let u=0;u<=t.yTicks;u+=1){const c=t.plotBottom-u/t.yTicks*(t.plotBottom-t.plotTop);e.beginPath(),e.moveTo(l,c),e.lineTo(l+a,c),e.stroke()}e.strokeStyle=s.axis,e.beginPath(),e.moveTo(l,t.plotBottom),e.lineTo(l+a,t.plotBottom),e.stroke()}function nl(e,t,{color:n,lineWidth:r,alpha:s=1,lineDash:o=[],startCol:i,endCol:l,yMaxMs:a,layout:u}){const c=Math.max(0,i-1),d=Math.min(u.cols-1,l+1);e.strokeStyle=n,e.lineWidth=r,e.globalAlpha=s,e.setLineDash(o),e.beginPath();const f=[];let h=null,x=Number.NaN,_=!1;for(let T=c-1;T>=0;T-=1){const p=t[T];if(Number.isFinite(p)){h=T,x=p,_=p>a;break}}for(let T=c;T<=d;T+=1){const p=t[T];if(!Number.isFinite(p))continue;const g=p>a;if(g&&!_&&f.push(T),h!==null&&Number.isFinite(x)){const y=x>a;if(!(y&&g)){const w=u.left+h+.5,P=y?u.plotTop:mo(x,a,u),O=u.left+T+.5,L=g?u.plotTop:mo(p,a,u);e.moveTo(w,P),e.lineTo(O,L)}}h=T,x=p,_=g}if(e.stroke(),e.setLineDash([]),e.globalAlpha=1,f.length>0){e.fillStyle=n,e.globalAlpha=Math.min(1,s+.1);for(const T of f){const p=u.left+T;e.fillRect(p,u.plotTop,1,3)}e.globalAlpha=1}}function xf(e,t,n,{color:r,alpha:s,lineDash:o=[],startCol:i,endCol:l,yMaxMs:a,layout:u}){e.strokeStyle=r,e.lineWidth=1,e.globalAlpha=s,e.setLineDash(o);for(let c=i;c<=l;c+=1){const d=t[c],f=n[c];if(!Number.isFinite(d)||!Number.isFinite(f)||f<=d)continue;const h=u.left+c+.5,x=d>a?u.plotTop:mo(d,a,u),_=f>a?u.plotTop:mo(f,a,u);e.beginPath(),e.moveTo(h,x),e.lineTo(h,_),e.stroke()}e.setLineDash([]),e.globalAlpha=1}function wf(e,t,{color:n,alpha:r,startCol:s,endCol:o,yMaxMs:i,layout:l}){const a=Math.max(0,s-1),u=Math.min(l.cols-1,o+1);let c=null,d=null;for(let f=a;f<=u;f+=1){const h=t[f];!Number.isFinite(h)||h<=0||(c===null&&(c=f),d=f)}if(!(c===null||d===null)){e.fillStyle=n,e.globalAlpha=r,e.beginPath(),e.moveTo(l.left+c+.5,l.plotBottom);for(let f=c;f<=d;f+=1){const h=t[f];if(!Number.isFinite(h)||h<=0)continue;const x=Math.min(h,i),_=l.left+f+.5,T=mo(x,i,l);e.lineTo(_,T)}e.lineTo(l.left+d+.5,l.plotBottom),e.closePath(),e.fill(),e.globalAlpha=1}}function L_(e,{leaseBins:t,userBins:n,color:r,startCol:s,endCol:o,yMaxMs:i,layout:l}){if(wf(e,t,{color:r,alpha:.18,startCol:s,endCol:o,yMaxMs:i,layout:l}),n!==null){const a=new Float32Array(n.length);a.fill(Number.NaN);for(let u=s;u<=o&&u9&&(n*=10,r=1),Math.max(Ur,r*n)}function Ef(e){if(!Number.isFinite(e)||e<=0)return js;const t=1e3/e;return B_(t*1.25)}function Nf(e,t,n,r,s,o,i){let l=e.get(o),a=t.get(o),u=n.get(o),c=r.get(o),d=s.get(o);return l||(l=tl(i),e.set(o,l)),a||(a=tl(i),t.set(o,a)),u||(u=new Float64Array(i),n.set(o,u)),c||(c=new Uint16Array(i),r.set(o,c)),d||(d=new Int32Array(i),d.fill(-2147483648),s.set(o,d)),{bins:l,peakBins:a,sumBins:u,countBins:c,cycleBins:d}}function j_({samples:e,publisherProcessId:t,publisherEndpointId:n,nominalPublishRateHz:r,topic:s,topicScope:o,leaseColorMap:i,selectedSubscriberEndpointId:l=null,windowSeconds:a,onWindowSecondsChange:u,darkMode:c=!1}){const d=E.useRef(null),f=E.useRef(null),h=E.useRef(null),x=E.useRef(null),_=E.useRef(!0),T=E.useRef(!1),[p,g]=E.useState(()=>a.toFixed(1)),[y,w]=E.useState(!0),[P,O]=E.useState(`${js.toFixed(2)}`),[L,R]=E.useState("lease_time_ns"),F=E.useMemo(()=>l?Qs(l,i):null,[i,l]),D=c?Dm:T_,H=E.useMemo(()=>Qo(P),[P]),Z=E.useMemo(()=>o&&o.length>0?o:[s],[s,o]),U=E.useMemo(()=>[...Z].sort().join("|"),[Z]),v=`${t}|${n}`,k=M=>{const C=Qo(M??p);if(C===null||!u){g(a.toFixed(1));return}const S=yr(C,.5,30);u(S),g(S.toFixed(1))},N=()=>{var M;if(y){const C=((M=h.current)==null?void 0:M.yMaxMs)??Ef(r);O(C.toFixed(2)),w(!1);return}w(!0)};return E.useEffect(()=>{g(a.toFixed(1))},[a]),E.useEffect(()=>{const M=d.current;if(!M)return;const C=M.getContext("2d");if(!C)return;const S=Math.max(1,window.devicePixelRatio||1),b=I_(M,a),B=Math.floor(b.width*S),j=Math.floor(b.height*S),Y=f.current,Q=!Y||Y.width!==B||Y.height!==j;Q&&(M.width=B,M.height=j,f.current={width:B,height:j}),C.setTransform(S,0,0,S,0,0);const ne=Math.max(1,a*1e9),se=Ef(r),fe=y?se:Math.max(Ur,H??js);let W=h.current;const A=W===null||Q||W.layout.cols!==b.cols||W.layout.width!==b.width||W.windowNs!==ne||W.scopeSignature!==U||W.publisherSignature!==v;if(A&&(W=b_(b,ne,U,v,fe),h.current=W,x.current=null,C.fillStyle=D.background,C.fillRect(0,0,b.width,b.height)),W===null)return;const I=new Set;let G=W.lastTimestamp,X=!1,ie=W.lastWipeCycle,le=null;W.originNs!==null&&Number.isFinite(W.lastTimestamp)&&(le=fa(W.lastTimestamp,W.originNs,W.windowNs,W.layout.cols));const ce=e!==x.current?e:[];e!==x.current&&(x.current=e);for(const oe of ce){if(!Number.isFinite(oe.timestamp)||!Number.isFinite(oe.value)||!P_(oe.topic,Z))continue;const K=oe.metric==="publish_delta_ns"&&oe.processId===t&&oe.endpointId===n,z=oe.metric==="lease_time_ns",ee=oe.metric==="user_span_ns";if(!K&&!z&&!ee||(W.originNs===null&&(W.originNs=oe.timestamp),W.originNs===null||oe.timestamp0&&(M_(W,le,ae,I),le=ae):le=ae,K){q>W.publishCycle[$]&&(W.publishCycle[$]=q,W.publishBins[$]=Number.NaN,W.publishPeakBins[$]=Number.NaN,W.publishSumBins[$]=0,W.publishCountBins[$]=0,I.add($));const pe=Math.min(65535,W.publishCountBins[$]+1);W.publishCountBins[$]=pe,W.publishSumBins[$]+=te;const we=W.publishSumBins[$]/pe,de=W.publishBins[$];(!Number.isFinite(de)||Math.abs(we-de)>1e-6)&&(W.publishBins[$]=we,I.add($));const me=W.publishPeakBins[$];(!Number.isFinite(me)||te>me)&&(W.publishPeakBins[$]=te,I.add($))}else{const pe=z?Nf(W.leaseBinsByEndpoint,W.leasePeakBinsByEndpoint,W.leaseSumByEndpoint,W.leaseCountByEndpoint,W.leaseCycleByEndpoint,oe.endpointId,W.layout.cols):Nf(W.userBinsByEndpoint,W.userPeakBinsByEndpoint,W.userSumByEndpoint,W.userCountByEndpoint,W.userCycleByEndpoint,oe.endpointId,W.layout.cols);q>pe.cycleBins[$]&&(pe.cycleBins[$]=q,pe.bins[$]=Number.NaN,pe.peakBins[$]=Number.NaN,pe.sumBins[$]=0,pe.countBins[$]=0,I.add($));const we=Math.min(65535,pe.countBins[$]+1);pe.countBins[$]=we,pe.sumBins[$]+=te;const de=pe.sumBins[$]/we,me=pe.bins[$];(!Number.isFinite(me)||Math.abs(de-me)>1e-6)&&(pe.bins[$]=de,I.add($));const ge=pe.peakBins[$];(!Number.isFinite(ge)||te>ge)&&(pe.peakBins[$]=te,I.add($))}G=Math.max(G,oe.timestamp),X=!0}const he=y&&!_.current;if(_.current=y,y?he?W.yMaxMs=se:ie>W.lastWipeCycle&&(W.lastWipeCycle=ie,W.yMaxMs=se):W.yMaxMs=Math.max(Ur,H??js),y){const oe=W.yMaxMs.toFixed(2);P!==oe&&O(oe)}if(X&&W.originNs!==null){const oe=fa(G,W.originNs,W.windowNs,W.layout.cols);I.add(oe.col),W.lastCursorCol!==null&&_f(I,W.lastCursorCol,W.layout.cols);const K=(oe.col+k_)%W.layout.cols;_f(I,K,W.layout.cols),W.lastCursorCol=K,W.lastTimestamp=G}if((A||I.size>0)&&(C.fillStyle=D.background,C.fillRect(0,0,W.layout.width,W.layout.height),$_(C,W,0,W.layout.cols-1,L,l,i,D)),W.lastTimestamp<=0){C.fillStyle=D.background,C.fillRect(0,0,W.layout.width,W.layout.height),C.fillStyle=D.waitingText,C.font='12px "Avenir Next", sans-serif',C.fillText("Waiting for trace samples...",W.layout.left,26),Sf(C,W,a,D);return}Sf(C,W,a,D)},[y,c,Z,i,H,r,n,t,v,l,e,L,U,a,D]),m.jsxs("div",{className:"timing-trace",children:[m.jsxs("div",{className:"timing-trace__controls",children:[m.jsxs("div",{className:"timing-trace__controls-left",children:[m.jsxs("label",{className:"timing-trace__axis-input",children:[m.jsx("span",{children:"Window (s)"}),m.jsx("input",{type:"number",min:.5,max:30,step:"0.5",value:p,onChange:M=>{const C=M.target.value;g(C),T.current||k(C)},onMouseDown:()=>{T.current=!1},onBlur:()=>{T.current=!1,k()},onKeyDown:M=>{if(M.key==="Enter"){T.current=!1,k();return}if(M.key==="ArrowUp"||M.key==="ArrowDown"){M.preventDefault(),T.current=!1;const C=Qo(p)??a,S=M.key==="ArrowUp"?.5:-.5,b=yr(C+S,.5,30);g(b.toFixed(1)),u==null||u(b);return}(M.key.length===1||M.key==="Backspace"||M.key==="Delete")&&(T.current=!0)}})]}),m.jsxs("span",{className:"timing-trace__legend-item is-static",children:[m.jsx("i",{style:{background:D.publish}}),"Publish Delta"]}),l?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"timing-trace__legend-item is-static",children:[m.jsx("i",{style:{background:"transparent",border:`2px solid ${F??"#94a3b8"}`}}),"Lease Time"]}),m.jsxs("span",{className:"timing-trace__legend-item is-static",children:[m.jsx("i",{style:{background:F??"#94a3b8"}}),"User Span"]})]}):m.jsxs(m.Fragment,{children:[m.jsx("button",{type:"button",className:`timing-trace__legend-item timing-trace__legend-toggle ${L==="lease_time_ns"?"is-active":""}`,onClick:()=>R("lease_time_ns"),"aria-pressed":L==="lease_time_ns",children:"Lease Time"}),m.jsx("button",{type:"button",className:`timing-trace__legend-item timing-trace__legend-toggle ${L==="user_span_ns"?"is-active":""}`,onClick:()=>R("user_span_ns"),"aria-pressed":L==="user_span_ns",children:"User Span"})]})]}),m.jsxs("div",{className:"timing-trace__controls-right",children:[m.jsxs("label",{className:"timing-trace__axis-input timing-trace__axis-input--ymax",children:[m.jsx("span",{children:"Y max (ms)"}),m.jsx("input",{type:"number",min:Ur,step:"0.1",value:P,onChange:M=>O(M.target.value),onBlur:()=>{const M=Qo(P);if(M===null){O(`${js.toFixed(2)}`);return}const C=Math.max(Ur,M);O(C.toFixed(2))},disabled:y})]}),m.jsx("button",{type:"button",role:"switch","aria-checked":y,className:`timing-trace__mode-toggle ${y?"is-auto":"is-fixed"}`,onClick:N,title:y?"Switch to Fixed Y":"Switch to Auto Y",children:m.jsx("span",{className:"timing-trace__mode-toggle-label",children:y?"Auto":"Fixed"})})]})]}),m.jsx("canvas",{ref:d,className:"timing-trace__canvas"})]})}function He(e){return e.split(":")[0]??e}function zc(e){const[t,...n]=e.split(":");return{topic:t??"",endpointToken:n.join(":")}}function F_(e){const{endpointToken:t}=zc(e);return t.length>0?t:null}function z_(e){const{topic:t,endpointToken:n}=zc(e);return{topic:t.length>0?t:null,endpointId:n.length>0?n:null}}const go=2,D_=.5,U_=30,H_=new Set(["publish_delta_ns"]),W_=new Set(["lease_time_ns","user_span_ns"]);function Jn(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function V_(e){return`${e.toFixed(1)} Hz`}function G_(e){return!Number.isFinite(e)||e<=0?"":Math.abs(e-Math.round(e))<1e-6?`${Math.round(e)}s`:`${e.toFixed(1)}s`}function Y_(e,t,n){return Math.min(n,Math.max(t,e))}function Tu(e){return!Number.isFinite(e)||e<=0?go:Y_(e,D_,U_)}function K_(e){if(!Number.isFinite(e)||e<=0)return go;const t=Math.max(go,Math.round(10/e));return Tu(t)}function X_(e,t=48){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Q_(e,t,n){return n!==null&&n>0&&t/n>.5?"backpressure":e>0?"active":"idle"}function nr(e){return typeof e=="object"&&e!==null}function Z_(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e.data.batches)){if(!nr(r))continue;const s=r.samples;if(Array.isArray(s))for(const o of s){if(!nr(o))continue;const i=o.endpoint_id,l=o.topic,a=o.metric,u=o.value,c=o.timestamp,d=o.sample_seq;typeof i!="string"||typeof l!="string"||typeof a!="string"||typeof u!="number"||!Number.isFinite(u)||t.push({rowId:`${n}:${i}`,processId:n,endpointId:i,topic:l,timestamp:typeof c=="number"&&Number.isFinite(c)?c:e.data.timestamp,metric:a,value:u,sampleSeq:typeof d=="number"&&Number.isFinite(d)?Math.trunc(d):null,channelKind:typeof o.channel_kind=="string"?o.channel_kind:null})}}return t}function q_(e,t,n){return{id:`${e.process_id}:${t.endpoint_id}`,endpointId:t.endpoint_id,topic:t.topic,processId:e.process_id,pid:e.pid,host:e.host,messagesWindow:Jn(t.messages_received_window),channelKindLast:typeof t.channel_kind_last=="string"?t.channel_kind_last:"unknown",unitAddress:n.get(t.endpoint_id)??null}}function ku(e,t){const n=new Set([e]),r=t==null?void 0:t.graph[e];if(Array.isArray(r))for(const s of r)typeof s=="string"&&n.add(s);return n}function Tf(e,t){if(t.has(e))return!0;for(const n of t)if(e.startsWith(`${n}:`))return!0;return!1}function J_(e,t,n){const r=ku(e,n);return t.filter(s=>r.has(s.topic)).sort((s,o)=>{const i=s.topic.localeCompare(o.topic);if(i!==0)return i;const l=s.processId.localeCompare(o.processId);return l!==0?l:s.endpointId.localeCompare(o.endpointId)})}function e1(e,t,n,r,s){const o=`${e.process_id}:${t.endpoint_id}`,i=t.num_buffers,l=typeof i=="number"&&Number.isFinite(i)?Math.max(0,Math.trunc(i)):null;return{id:o,endpointId:t.endpoint_id,topic:t.topic,processId:e.process_id,pid:e.pid,host:e.host,windowSeconds:Jn(e.window_seconds),publishRateHzWindow:Jn(t.publish_rate_hz_window),messagesPublishedWindow:Jn(t.messages_published_window),inflightCurrent:Jn(t.inflight_messages_current),numBuffers:l,activityTone:Q_(Jn(t.messages_published_window),Jn(t.inflight_messages_current),l),contributors:J_(t.topic,n,r),unitAddress:s.get(t.endpoint_id)??null}}function t1({graphSnapshot:e,profilingSnapshot:t,latestTraceEvent:n,setProfilingTraceControl:r,focusPublisherEndpointId:s=null,focusPublisherTopic:o=null,focusSubscriberEndpointId:i=null,focusActionId:l=0,hideFilters:a=!1,defaultTraceMetrics:u=["publish_delta_ns","lease_time_ns","user_span_ns"],traceDockHost:c=null,onTraceDockStateChange:d,traceCloseSignal:f=0,onPublisherSelect:h,onSubscriberSelect:x,darkMode:_=!1}){const[T,p]=E.useState(""),[g,y]=E.useState([]),[w,P]=E.useState([]),[O,L]=E.useState({}),[R,F]=E.useState({}),[D,H]=E.useState({}),[Z,U]=E.useState({}),[v,k]=E.useState({}),N=E.useRef(f),M=E.useRef(-1),C=E.useRef({}),S=E.useMemo(()=>t?Object.values(t):[],[t]),b=E.useMemo(()=>{const z=new Map;if(!e)return z;for(const ee of Object.values(e.sessions)){const $=nr(ee.metadata)?ee.metadata:null,q=$&&nr($.components)?$.components:null;if(q){for(const[te,ae]of Object.entries(q))if(!(!nr(ae)||!nr(ae.streams)))for(const pe of Object.values(ae.streams)){if(!nr(pe)||typeof pe.address!="string")continue;const we=F_(pe.address);we&&!z.has(we)&&z.set(we,te)}}}return z},[e]),B=E.useMemo(()=>{const z=[];for(const $ of S)for(const q of Object.values($.subscribers))z.push(q_($,q,b));const ee=[];for(const $ of S)for(const q of Object.values($.publishers))ee.push(e1($,q,z,e,b));return ee.sort(($,q)=>{const te=$.topic.localeCompare(q.topic);if(te!==0)return te;const ae=$.processId.localeCompare(q.processId);return ae!==0?ae:$.endpointId.localeCompare(q.endpointId)})},[b,e,S]),j=E.useMemo(()=>{const z=T.trim().toLowerCase();return B.filter(ee=>z.length===0?!0:ee.topic.toLowerCase().includes(z)||ee.endpointId.toLowerCase().includes(z)||ee.processId.toLowerCase().includes(z))},[B,T]),Y=E.useMemo(()=>new Map(B.map(z=>[z.id,z])),[B]);E.useEffect(()=>{if(l!==M.current){if(s){const z=B.filter(ee=>ee.endpointId===s?!0:o?ee.topic===o:!1).map(ee=>ee.id);if(z.length===0)return;M.current=l,p(""),y(z),k({}),window.requestAnimationFrame(()=>{var ee;(ee=C.current[z[0]])==null||ee.scrollIntoView({block:"nearest",behavior:"smooth"})});return}if(i){const z=B.filter(ee=>ee.contributors.some($=>$.endpointId===i)).map(ee=>ee.id);if(z.length===0)return;M.current=l,p(""),y(z),k(ee=>{const $={...ee};for(const q of z)$[q]=i;return $}),window.requestAnimationFrame(()=>{var ee;(ee=C.current[z[0]])==null||ee.scrollIntoView({block:"nearest",behavior:"smooth"})});return}}},[s,o,i,l,B]),E.useEffect(()=>{if(!n||w.length===0)return;const z=Z_(n);if(z.length===0)return;const ee=new Set(w),$=w.map(te=>Y.get(te)).filter(te=>te!==void 0).map(te=>({row:te,topicScope:ku(te.topic,e)})),q=new Map($.map(te=>[te.row.id,te.topicScope]));L(te=>{let ae=!1;const pe={...te},we={};for(const de of z){const me=new Set,ge=Y.get(de.rowId),Ee=q.get(de.rowId);if(ge&&ee.has(de.rowId)&&Ee&&Tf(de.topic,Ee)&&H_.has(de.metric)&&me.add(de.rowId),W_.has(de.metric))for(const ye of $)Tf(de.topic,ye.topicScope)&&me.add(ye.row.id);for(const ye of me){const Ae=we[ye];Ae?Ae.push(de):we[ye]=[de]}}for(const[de,me]of Object.entries(we))me.length!==0&&(pe[de]=me,ae=!0);return ae?pe:te})},[w,e,n,Y]);const Q=async(z,ee)=>{if(!R[z.id]){F($=>({...$,[z.id]:!0})),H($=>({...$,[z.id]:null})),ee?(L($=>({...$,[z.id]:[]})),U($=>$[z.id]!==void 0?$:{...$,[z.id]:K_(z.publishRateHzWindow)}),P([z.id])):P($=>$.includes(z.id)?$.filter(q=>q!==z.id):$);try{if(ee){const $=w.find(q=>q!==z.id);if($){const q=Y.get($);q&&await r({process_id:q.processId,enabled:!1,publisher_endpoint_id:null,publisher_topic:null,subscriber_topic:null,metrics:null,sample_mod:1,ttl_seconds:null,timeout:2})}}await r({process_id:z.processId,enabled:ee,publisher_endpoint_id:ee?z.endpointId:null,publisher_topic:ee?z.topic:null,subscriber_topic:null,metrics:ee?u:null,sample_mod:1,ttl_seconds:null,timeout:2})}catch($){const q=$ instanceof Error?$.message:"Trace control request failed.";H(te=>({...te,[z.id]:q})),P(te=>ee?te.filter(ae=>ae!==z.id):te.includes(z.id)?te:[...te,z.id])}finally{F($=>({...$,[z.id]:!1}))}}},ne=z=>{const ee=!g.includes(z.id);ee&&(h==null||h({unitAddress:z.unitAddress,endpointId:z.endpointId,topic:z.topic})),y($=>$.includes(z.id)?$.filter(q=>q!==z.id):[...$,z.id]),ee||k($=>({...$,[z.id]:null})),!ee&&w.includes(z.id)&&Q(z,!1)},se=(z,ee)=>{Q(z,ee)},fe=a,W=w[0]??null,A=W?Y.get(W)??null:null,I=W?O[W]??[]:[],G=W?!!R[W]:!1,X=W?D[W]??null:null,ie=Tu(W?Z[W]??go:go),le=A?Array.from(ku(A.topic,e)):[],ce=I.filter(z=>z.metric==="lease_time_ns"||z.metric==="user_span_ns").map(z=>z.endpointId),he=vf([...(A==null?void 0:A.contributors.map(z=>z.endpointId))??[],...ce]),oe=W?v[W]??null:null;E.useEffect(()=>{if(f===N.current)return;N.current=f;const z=w[0];if(!z)return;const ee=Y.get(z);if(!ee){P([]);return}P([]),r({process_id:ee.processId,enabled:!1,publisher_endpoint_id:null,publisher_topic:null,subscriber_topic:null,metrics:null,sample_mod:1,ttl_seconds:null,timeout:2})},[w,Y,r,f]),E.useEffect(()=>{if(d){if(!A){d(null);return}d({active:!0,topic:A.topic,endpointId:A.endpointId,status:G?"applying":"capturing"})}},[G,A,d]);const K=c&&A?zm.createPortal(m.jsxs("div",{className:"trace-dock-trace",children:[I.length===0?m.jsx("p",{className:"muted",children:"Waiting for trace samples on this publisher endpoint."}):m.jsx(j_,{samples:I,publisherProcessId:A.processId,publisherEndpointId:A.endpointId,nominalPublishRateHz:A.publishRateHzWindow,topic:A.topic,topicScope:le,leaseColorMap:he,selectedSubscriberEndpointId:oe,windowSeconds:ie,darkMode:_,onWindowSecondsChange:z=>U(ee=>({...ee,[A.id]:Tu(z)}))}),X?m.jsx("p",{className:"patch-status err",children:X}):null]}),c):null;return m.jsxs(Ji,{children:[B.length===0?m.jsx("div",{className:"panel-section",children:m.jsx("p",{className:"muted",children:"No publishers snapshot entries available."})}):m.jsxs(m.Fragment,{children:[fe?null:m.jsx("div",{className:"settings-search",children:m.jsx("input",{type:"search",placeholder:"Search topic, endpoint, or process",value:T,onChange:z=>p(z.target.value)})}),j.length===0?m.jsx("div",{className:"panel-section",children:m.jsx("p",{className:"muted",children:"No publishers match the current filter."})}):m.jsx("div",{className:"publisher-list",children:j.map(z=>{const ee=g.includes(z.id),$=w.includes(z.id),q=!!R[z.id],te=G_(z.windowSeconds),ae=vf(z.contributors.map(de=>de.endpointId)),pe=v[z.id]??null,we=z.contributors.some(de=>de.endpointId===pe)?pe:null;return m.jsxs("article",{ref:de=>{C.current[z.id]=de},className:`publisher-row activity-${z.activityTone}`,children:[m.jsxs("button",{type:"button",className:"publisher-row__toggle",onClick:()=>ne(z),"aria-expanded":ee,children:[m.jsxs("div",{className:"publisher-row__top",children:[m.jsx("div",{className:"publisher-row__identity",children:m.jsx("div",{className:"publisher-row__identity-text",children:m.jsx("p",{className:"mono publisher-topic",title:z.topic,children:z.topic})})}),m.jsx("span",{className:"publisher-caret",children:ee?"▾":"▸"})]}),m.jsxs("div",{className:"publisher-row__metrics",children:[m.jsxs("div",{children:[m.jsx("span",{children:"Rate"}),m.jsx("strong",{children:V_(z.publishRateHzWindow)})]}),m.jsxs("div",{children:[m.jsx("span",{children:te?`Msgs (${te})`:"Msgs"}),m.jsx("strong",{children:z.messagesPublishedWindow})]}),m.jsxs("div",{children:[m.jsx("span",{children:"Inflight"}),m.jsx("strong",{children:z.numBuffers===null?`${z.inflightCurrent}`:`${z.inflightCurrent} / ${z.numBuffers}`})]}),m.jsxs("div",{children:[m.jsx("span",{children:"Subscribers"}),m.jsx("strong",{children:z.contributors.length})]})]})]}),ee?m.jsxs("div",{className:"publisher-row__details",children:[m.jsxs("div",{className:"publisher-kpis",children:[m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Host"}),m.jsx("strong",{children:z.host})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"PID"}),m.jsx("strong",{children:z.pid})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Process"}),m.jsx("strong",{className:"mono",title:z.processId,children:z.processId.slice(0,8)})]})]}),m.jsx("div",{className:"publisher-detail-line",children:m.jsxs("div",{className:"publisher-endpoint",children:[m.jsx("span",{children:"Endpoint"}),m.jsx("code",{className:"mono",title:z.endpointId,children:z.endpointId})]})}),m.jsxs("div",{className:"panel-section",children:[m.jsxs("button",{type:"button",className:`publisher-trace-button ${$?"is-stop":"is-start"}`,onClick:()=>se(z,!$),disabled:q,"aria-pressed":$,children:[m.jsx("span",{"aria-hidden":"true",className:"publisher-trace-button__icon",children:$?"■":"▶"}),m.jsx("span",{children:q?"Applying...":$?"Stop Profiling Trace":"Start Profiling Trace"})]}),m.jsx("div",{className:"subscriber-section-header",children:m.jsx("h3",{children:"Subscribers"})}),z.contributors.length===0?m.jsx("p",{className:"muted",children:"No subscriber profiling data is available for this topic."}):m.jsx("div",{className:"subscriber-list",children:z.contributors.map(de=>{const me=we===de.endpointId;return m.jsxs("article",{className:`subscriber-item ${me?"is-expanded":""}`,children:[m.jsxs("button",{type:"button",className:"subscriber-item__summary",onClick:()=>{const ge=me?null:de.endpointId;ge&&(x==null||x({unitAddress:de.unitAddress,endpointId:de.endpointId,topic:de.topic})),k(Ee=>({...Ee,[z.id]:ge}))},children:[m.jsx("div",{className:"subscriber-item__identity",children:m.jsx("p",{className:"mono subscriber-topic-short",title:de.topic,children:m.jsxs("span",{className:"subscriber-topic-with-color",children:[m.jsx("i",{className:"subscriber-trace-dot",style:{background:Qs(de.endpointId,ae)}}),m.jsx("span",{className:"subscriber-topic-label",children:X_(de.topic,72)})]})})}),m.jsxs("div",{className:"subscriber-item__metrics",children:[m.jsxs("span",{children:[m.jsx("em",{children:te?`Msgs (${te})`:"Msgs"}),m.jsx("strong",{children:de.messagesWindow})]}),m.jsxs("span",{children:[m.jsx("em",{children:"Channel"}),m.jsx("strong",{children:de.channelKindLast})]})]})]}),me?m.jsx("div",{className:"subscriber-item__detail",children:m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"publisher-kpis",children:[m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Host"}),m.jsx("strong",{children:de.host})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"PID"}),m.jsx("strong",{children:de.pid})]}),m.jsxs("article",{className:"mini-kpi",children:[m.jsx("span",{children:"Process"}),m.jsx("strong",{className:"mono",title:de.processId,children:de.processId.slice(0,8)})]})]}),m.jsx("div",{className:"publisher-detail-line",children:m.jsxs("div",{className:"publisher-endpoint",children:[m.jsx("span",{children:"Endpoint"}),m.jsx("code",{className:"mono",title:de.endpointId,children:de.endpointId})]})})]})}):null]},de.id)})})]})]}):null]},z.id)})})]}),K]})}function n1(e){const t=e.field_type.toLowerCase();return Array.isArray(e.choices)&&e.choices.length>0?"choice":t.includes("bool")?"boolean":t.includes("int")||t.includes("float")||t.includes("double")||t.includes("number")?"number":t.includes("str")||t.includes("string")?"text":"json"}function r1(e){return typeof e=="boolean"?"boolean":typeof e=="number"?"number":typeof e=="string"?"text":"json"}function kf(e,t){if(!e||typeof e!="object")return;const n=t.split(".").filter(s=>s.length>0);let r=e;for(const s of n){if(!r||typeof r!="object"||!(s in r))return;r=r[s]}return r}function Hm(e){try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Wm(e,t=""){if(!e||typeof e!="object"||Array.isArray(e))return t.length>0?[t]:[];const n=Object.entries(e);if(n.length===0)return t.length>0?[t]:[];const r=[];for(const[s,o]of n){const i=t.length>0?`${t}.${s}`:s,l=Wm(o,i);l.length===0?r.push(i):r.push(...l)}return r}function s1(e){if(e.mode==="boolean")return!!e.currentValue;if(e.mode==="choice"){const t=e.choices??[],n=Math.max(0,t.findIndex(r=>JSON.stringify(r)===JSON.stringify(e.currentValue)));return String(n)}return e.mode==="number"?typeof e.currentValue=="number"?String(e.currentValue):"":e.mode==="text"?typeof e.currentValue=="string"?e.currentValue:"":Hm(e.currentValue)}function o1(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(s=>e[s]===t[s])}function i1({settings:e,patchSettingField:t,focusComponentAddress:n=null,focusActionId:r=0,onComponentSelect:s}){const o=E.useMemo(()=>e?Object.keys(e).sort():[],[e]),i=E.useMemo(()=>o.join("|"),[o]),l=E.useMemo(()=>new Set(o),[i]),[a,u]=E.useState(null),[c,d]=E.useState(""),[f,h]=E.useState({}),[x,_]=E.useState({}),[T,p]=E.useState({}),[g,y]=E.useState({}),w=E.useRef({}),P=E.useRef({}),O=E.useRef(null);E.useEffect(()=>{a&&!o.includes(a)&&u(null)},[o,a]),E.useEffect(()=>{!n||!l.has(n)||(d(""),u(n),window.requestAnimationFrame(()=>{var v;(v=w.current[n])==null||v.scrollIntoView({block:"nearest",behavior:"smooth"})}))},[l,r,n]);const L=a?e==null?void 0:e[a]:null,R=E.useMemo(()=>(L==null?void 0:L.structured_value)??(L==null?void 0:L.repr_value),[L]),F=E.useMemo(()=>{var M;if(!L)return[];const v=((M=L.settings_schema)==null?void 0:M.fields)??[];if(v.length>0)return v.map(C=>{const S=kf(R,C.name);return{path:C.name,mode:n1(C),currentValue:S??C.default??null,description:C.description,bounds:C.bounds,choices:C.choices,isInteger:C.field_type.toLowerCase().includes("int")}});const k=Wm(R);return(k.length>0?k:["value"]).map(C=>{const S=C==="value"?R:kf(R,C);return{path:C,mode:r1(S),currentValue:S,description:null,bounds:null,choices:null,isInteger:Number.isInteger(S)}})},[L,R]),D=!!(L!=null&&L.patchable),H=E.useMemo(()=>{const v=c.trim().toLowerCase();return v?o.filter(k=>{const N=e==null?void 0:e[k],M=typeof(N==null?void 0:N.component_name)=="string"?N.component_name:"",C=typeof(N==null?void 0:N.component_type)=="string"?N.component_type:"";return k.toLowerCase().includes(v)||M.toLowerCase().includes(v)||C.toLowerCase().includes(v)}):o},[o,c,e]);E.useEffect(()=>{const v={};for(const N of F)v[N.path]=s1(N);const k=O.current!==a;h(N=>{if(k)return v;const M={};for(const[C,S]of Object.entries(v)){const b=N[C],B=P.current[C];M[C]=b===void 0||b===B?S:b}return o1(N,M)?N:M}),k&&(_({}),p({}),y({})),P.current=v,O.current=a},[F,a]);const Z=v=>{const k=f[v.path];if(v.mode==="boolean")return!!k;if(v.mode==="choice"){const N=Number.parseInt(String(k),10),M=v.choices??[];if(!Number.isInteger(N)||N<0||N>=M.length)throw new Error("A valid choice must be selected.");return M[N]}if(v.mode==="number"){const N=Number.parseFloat(String(k));if(!Number.isFinite(N))throw new Error("Value must be a valid number.");return v.isInteger?Math.trunc(N):N}if(v.mode==="text")return String(k??"");try{return JSON.parse(String(k??""))}catch{throw new Error("Value must be valid JSON.")}},U=async v=>{if(!a||!D)return;let k;try{k=Z(v)}catch(N){p(M=>({...M,[v.path]:N instanceof Error?N.message:"Invalid field value."})),y(M=>({...M,[v.path]:null}));return}_(N=>({...N,[v.path]:!0})),p(N=>({...N,[v.path]:null})),y(N=>({...N,[v.path]:null}));try{const N=await t(a,v.path,k);y(M=>({...M,[v.path]:`Applied ${N.field_path}`}))}catch(N){p(M=>({...M,[v.path]:N instanceof Error?N.message:"Patch request failed."}))}finally{_(N=>({...N,[v.path]:!1}))}};return m.jsx(Ji,{children:o.length===0?m.jsx("div",{className:"panel-section",children:m.jsx("p",{className:"muted",children:"No settings snapshot entries available."})}):m.jsxs("div",{className:"settings-component-list",children:[m.jsx("div",{className:"settings-search",children:m.jsx("input",{type:"search",placeholder:"Search component, type, or address",value:c,onChange:v=>d(v.target.value)})}),H.map(v=>{const k=(e==null?void 0:e[v])??null,N=a===v,M=!!(k!=null&&k.patchable),C=typeof(k==null?void 0:k.component_name)=="string"&&k.component_name.length>0?k.component_name:v.split("/")[v.split("/").length-1]??v;return m.jsxs("article",{ref:S=>{w.current[v]=S},className:`settings-component-row ${N?"is-expanded":""}`,children:[m.jsxs("button",{type:"button",className:"settings-component-row__toggle","aria-expanded":N,onClick:()=>u(S=>{const b=S===v?null:v;return s==null||s(b),b}),children:[m.jsxs("div",{className:"settings-component-row__identity",children:[m.jsxs("div",{className:"settings-component-row__heading",children:[m.jsx("p",{className:"mono settings-component-title",title:C,children:C}),k!=null&&k.component_type?m.jsx("span",{className:"settings-type",title:k.component_type,children:k.component_type}):null]}),m.jsx("p",{className:"mono settings-component-address",title:v,children:v})]}),m.jsxs("div",{className:"settings-component-row__meta",children:[m.jsx("span",{className:`settings-access ${M?"is-patchable":"is-readonly"}`,children:M?"patchable":"read only"}),m.jsx("span",{className:"publisher-caret",children:N?"▾":"▸"})]})]}),N?m.jsx("section",{className:"settings-detail",children:F.length===0?m.jsx("p",{className:"muted",children:"No fields available for this component."}):m.jsx("div",{className:"settings-fields",children:F.map(S=>{var Y,Q;const b=x[S.path]===!0,B=!D,j=f[S.path];return m.jsxs("div",{className:`settings-field-row ${B?"is-disabled":""}`,children:[m.jsxs("div",{className:"settings-field-row__meta",children:[m.jsx("label",{className:"mono",children:S.path}),S.description?m.jsx("p",{className:"muted",children:S.description}):null,S.bounds?m.jsxs("p",{className:"muted",children:["Bounds: [",S.bounds[0]??"-inf",", ",S.bounds[1]??"+inf","]"]}):null]}),m.jsxs("div",{className:`settings-field-row__control ${S.mode==="boolean"?"is-boolean":""}`,children:[S.mode==="boolean"?m.jsxs("label",{className:"patch-checkbox",children:[m.jsx("input",{type:"checkbox",checked:!!j,onChange:ne=>h(se=>({...se,[S.path]:ne.target.checked})),disabled:B||b}),m.jsx("span",{children:"Enabled"})]}):null,S.mode==="choice"?m.jsx("select",{value:String(j??"0"),onChange:ne=>h(se=>({...se,[S.path]:ne.target.value})),disabled:B||b,children:(S.choices??[]).map((ne,se)=>m.jsx("option",{value:String(se),children:Hm(ne)},`${S.path}-${se}`))}):null,S.mode==="number"?m.jsx("input",{type:"number",value:String(j??""),min:((Y=S.bounds)==null?void 0:Y[0])??void 0,max:((Q=S.bounds)==null?void 0:Q[1])??void 0,step:"any",onChange:ne=>h(se=>({...se,[S.path]:ne.target.value})),disabled:B||b}):null,S.mode==="text"?m.jsx("input",{type:"text",value:String(j??""),onChange:ne=>h(se=>({...se,[S.path]:ne.target.value})),disabled:B||b}):null,S.mode==="json"?m.jsx("textarea",{value:String(j??""),rows:4,spellCheck:!1,className:"mono",onChange:ne=>h(se=>({...se,[S.path]:ne.target.value})),disabled:B||b}):null,m.jsx("button",{type:"button",onClick:()=>{U(S)},disabled:B||b,children:b?"Applying...":"Apply"})]}),g[S.path]?m.jsx("p",{className:"patch-status ok",children:g[S.path]}):null,T[S.path]?m.jsx("p",{className:"patch-status err",children:T[S.path]}):null]},S.path)})})}):null]},v)})]})})}function qe(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h1:p1;Km.useSyncExternalStore=as.useSyncExternalStore!==void 0?as.useSyncExternalStore:m1;Ym.exports=Km;var g1=Ym.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 Il=E,y1=g1;function v1(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var _1=typeof Object.is=="function"?Object.is:v1,x1=y1.useSyncExternalStore,w1=Il.useRef,S1=Il.useEffect,E1=Il.useMemo,N1=Il.useDebugValue;Gm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=w1(null);if(o.current===null){var i={hasValue:!1,value:null};o.current=i}else i=o.current;o=E1(function(){function a(h){if(!u){if(u=!0,c=h,h=r(h),s!==void 0&&i.hasValue){var x=i.value;if(s(x,h))return d=x}return d=h}if(x=d,_1(c,h))return x;var _=r(h);return s!==void 0&&s(x,_)?(c=h,x):(c=h,d=_)}var u=!1,c,d,f=n===void 0?null:n;return[function(){return a(t())},f===null?void 0:function(){return a(f())}]},[t,n,r,s]);var l=x1(e,o[0],o[1]);return S1(function(){i.hasValue=!0,i.value=l},[l]),N1(l),l};Vm.exports=Gm;var T1=Vm.exports;const k1=Cp(T1),C1={},Cf=e=>{let t;const n=new Set,r=(c,d)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(x=>x(t,h))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{(C1?"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()}},u=t=e(r,s,a);return a},I1=e=>e?Cf(e):Cf,{useDebugValue:b1}=V,{useSyncExternalStoreWithSelector:P1}=k1,A1=e=>e;function Xm(e,t=A1,n){const r=P1(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return b1(r),r}const If=(e,t)=>{const n=I1(e),r=(s,o=t)=>Xm(n,s,o);return Object.assign(r,n),r},R1=(e,t)=>e?If(e,t):If;function Ke(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,s]of e)if(!Object.is(s,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}var M1={value:()=>{}};function bl(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Ni.prototype=bl.prototype={constructor:Ni,on:function(e,t){var n=this._,r=O1(e+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(s),r=0,s,o;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Pf.hasOwnProperty(t)?{space:Pf[t],local:e}:e}function $1(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cu&&t.documentElement.namespaceURI===Cu?t.createElement(e):t.createElementNS(n,e)}}function B1(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Qm(e){var t=Pl(e);return(t.local?B1:$1)(t)}function j1(){}function Dc(e){return e==null?j1:function(){return this.querySelector(e)}}function F1(e){typeof e!="function"&&(e=Dc(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s=y&&(y=g+1);!(P=T[y])&&++y=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function cx(e){e||(e=dx);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,s=new Array(r),o=0;ot?1:e>=t?0:NaN}function fx(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function px(){return Array.from(this)}function hx(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Tx:typeof t=="function"?Cx:kx)(e,t,n??"")):us(this.node(),e)}function us(e,t){return e.style.getPropertyValue(t)||tg(e).getComputedStyle(e,null).getPropertyValue(t)}function bx(e){return function(){delete this[e]}}function Px(e,t){return function(){this[e]=t}}function Ax(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Rx(e,t){return arguments.length>1?this.each((t==null?bx:typeof t=="function"?Ax:Px)(e,t)):this.node()[e]}function ng(e){return e.trim().split(/^|\s+/)}function Uc(e){return e.classList||new rg(e)}function rg(e){this._node=e,this._names=ng(e.getAttribute("class")||"")}rg.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function sg(e,t){for(var n=Uc(e),r=-1,s=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function iw(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n()=>e;function Iu(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:i,y:l,dx:a,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:a,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Iu.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function gw(e){return!e.ctrlKey&&!e.button}function yw(){return this.parentNode}function vw(e,t){return t??{x:e.x,y:e.y}}function _w(){return navigator.maxTouchPoints||"ontouchstart"in this}function xw(){var e=gw,t=yw,n=vw,r=_w,s={},o=bl("start","drag","end"),i=0,l,a,u,c,d=0;function f(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",T).on("touchmove.drag",p,mw).on("touchend.drag touchcancel.drag",g).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,P){if(!(c||!e.call(this,w,P))){var O=y(this,t.call(this,w,P),w,P,"mouse");O&&(kt(w.view).on("mousemove.drag",x,yo).on("mouseup.drag",_,yo),ag(w.view),ha(w),u=!1,l=w.clientX,a=w.clientY,O("start",w))}}function x(w){if(qr(w),!u){var P=w.clientX-l,O=w.clientY-a;u=P*P+O*O>d}s.mouse("drag",w)}function _(w){kt(w.view).on("mousemove.drag mouseup.drag",null),ug(w.view,u),qr(w),s.mouse("end",w)}function T(w,P){if(e.call(this,w,P)){var O=w.changedTouches,L=t.call(this,w,P),R=O.length,F,D;for(F=0;F>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?qo(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?qo(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=Sw.exec(e))?new pt(t[1],t[2],t[3],1):(t=Ew.exec(e))?new pt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Nw.exec(e))?qo(t[1],t[2],t[3],t[4]):(t=Tw.exec(e))?qo(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=kw.exec(e))?Bf(t[1],t[2]/100,t[3]/100,1):(t=Cw.exec(e))?Bf(t[1],t[2]/100,t[3]/100,t[4]):Af.hasOwnProperty(e)?Of(Af[e]):e==="transparent"?new pt(NaN,NaN,NaN,0):null}function Of(e){return new pt(e>>16&255,e>>8&255,e&255,1)}function qo(e,t,n,r){return r<=0&&(e=t=n=NaN),new pt(e,t,n,r)}function Pw(e){return e instanceof Ao||(e=xo(e)),e?(e=e.rgb(),new pt(e.r,e.g,e.b,e.opacity)):new pt}function bu(e,t,n,r){return arguments.length===1?Pw(e):new pt(e,t,n,r??1)}function pt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Hc(pt,bu,cg(Ao,{brighter(e){return e=e==null?sl:Math.pow(sl,e),new pt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vo:Math.pow(vo,e),new pt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new pt(cr(this.r),cr(this.g),cr(this.b),ol(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:Aw,formatRgb:$f,toString:$f}));function Lf(){return`#${ir(this.r)}${ir(this.g)}${ir(this.b)}`}function Aw(){return`#${ir(this.r)}${ir(this.g)}${ir(this.b)}${ir((isNaN(this.opacity)?1:this.opacity)*255)}`}function $f(){const e=ol(this.opacity);return`${e===1?"rgb(":"rgba("}${cr(this.r)}, ${cr(this.g)}, ${cr(this.b)}${e===1?")":`, ${e})`}`}function ol(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function cr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ir(e){return e=cr(e),(e<16?"0":"")+e.toString(16)}function Bf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new jt(e,t,n,r)}function dg(e){if(e instanceof jt)return new jt(e.h,e.s,e.l,e.opacity);if(e instanceof Ao||(e=xo(e)),!e)return new jt;if(e instanceof jt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),i=NaN,l=o-s,a=(o+s)/2;return l?(t===o?i=(n-r)/l+(n0&&a<1?0:i,new jt(i,l,a,e.opacity)}function Rw(e,t,n,r){return arguments.length===1?dg(e):new jt(e,t,n,r??1)}function jt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Hc(jt,Rw,cg(Ao,{brighter(e){return e=e==null?sl:Math.pow(sl,e),new jt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vo:Math.pow(vo,e),new jt(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,s=2*n-r;return new pt(ma(e>=240?e-240:e+120,s,r),ma(e,s,r),ma(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new jt(jf(this.h),Jo(this.s),Jo(this.l),ol(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=ol(this.opacity);return`${e===1?"hsl(":"hsla("}${jf(this.h)}, ${Jo(this.s)*100}%, ${Jo(this.l)*100}%${e===1?")":`, ${e})`}`}}));function jf(e){return e=(e||0)%360,e<0?e+360:e}function Jo(e){return Math.max(0,Math.min(1,e||0))}function ma(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 fg=e=>()=>e;function Mw(e,t){return function(n){return e+n*t}}function Ow(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 Lw(e){return(e=+e)==1?pg:function(t,n){return n-t?Ow(t,n,e):fg(isNaN(t)?n:t)}}function pg(e,t){var n=t-e;return n?Mw(e,n):fg(isNaN(e)?t:e)}const Ff=function e(t){var n=Lw(t);function r(s,o){var i=n((s=bu(s)).r,(o=bu(o)).r),l=n(s.g,o.g),a=n(s.b,o.b),u=pg(s.opacity,o.opacity);return function(c){return s.r=i(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return r.gamma=e,r}(1);function kn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Pu=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ga=new RegExp(Pu.source,"g");function $w(e){return function(){return e}}function Bw(e){return function(t){return e(t)+""}}function jw(e,t){var n=Pu.lastIndex=ga.lastIndex=0,r,s,o,i=-1,l=[],a=[];for(e=e+"",t=t+"";(r=Pu.exec(e))&&(s=ga.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),l[i]?l[i]+=o:l[++i]=o),(r=r[0])===(s=s[0])?l[i]?l[i]+=s:l[++i]=s:(l[++i]=null,a.push({i,x:kn(r,s)})),n=ga.lastIndex;return n180?c+=360:c-u>180&&(u+=360),f.push({i:d.push(s(d)+"rotate(",null,r)-2,x:kn(u,c)})):c&&d.push(s(d)+"rotate("+c+r)}function l(u,c,d,f){u!==c?f.push({i:d.push(s(d)+"skewX(",null,r)-2,x:kn(u,c)}):c&&d.push(s(d)+"skewX("+c+r)}function a(u,c,d,f,h,x){if(u!==d||c!==f){var _=h.push(s(h)+"scale(",null,",",null,")");x.push({i:_-4,x:kn(u,d)},{i:_-2,x:kn(c,f)})}else(d!==1||f!==1)&&h.push(s(h)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=e(u),c=e(c),o(u.translateX,u.translateY,c.translateX,c.translateY,d,f),i(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(h){for(var x=-1,_=f.length,T;++x<_;)d[(T=f[x]).i]=T.x(h);return d.join("")}}}var Dw=mg(Fw,"px, ","px)","deg)"),Uw=mg(zw,", ",")",")"),Hw=1e-12;function Df(e){return((e=Math.exp(e))+1/e)/2}function Ww(e){return((e=Math.exp(e))-1/e)/2}function Vw(e){return((e=Math.exp(2*e))-1)/(e+1)}const Gw=function e(t,n,r){function s(o,i){var l=o[0],a=o[1],u=o[2],c=i[0],d=i[1],f=i[2],h=c-l,x=d-a,_=h*h+x*x,T,p;if(_=0&&e._call.call(void 0,t),e=e._next;--cs}function Uf(){vr=(ll=wo.now())+Al,cs=Fs=0;try{Kw()}finally{cs=0,Qw(),vr=0}}function Xw(){var e=wo.now(),t=e-ll;t>gg&&(Al-=t,ll=e)}function Qw(){for(var e,t=il,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:il=n);zs=e,Ru(r)}function Ru(e){if(!cs){Fs&&(Fs=clearTimeout(Fs));var t=e-vr;t>24?(e<1/0&&(Fs=setTimeout(Uf,e-wo.now()-Al)),Ts&&(Ts=clearInterval(Ts))):(Ts||(ll=wo.now(),Ts=setInterval(Xw,gg)),cs=1,yg(Uf))}}function Hf(e,t,n){var r=new al;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var Zw=bl("start","end","cancel","interrupt"),qw=[],_g=0,Wf=1,Mu=2,Ti=3,Vf=4,Ou=5,ki=6;function Rl(e,t,n,r,s,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Jw(e,n,{name:t,index:r,group:s,on:Zw,tween:qw,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:_g})}function Vc(e,t){var n=Wt(e,t);if(n.state>_g)throw new Error("too late; already scheduled");return n}function Jt(e,t){var n=Wt(e,t);if(n.state>Ti)throw new Error("too late; already running");return n}function Wt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Jw(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=vg(o,0,n.time);function o(u){n.state=Wf,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var c,d,f,h;if(n.state!==Wf)return a();for(c in r)if(h=r[c],h.name===n.name){if(h.state===Ti)return Hf(i);h.state===Vf?(h.state=ki,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+cMu&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function bS(e,t,n){var r,s,o=IS(t)?Vc:Jt;return function(){var i=o(this,e),l=i.on;l!==r&&(s=(r=l).copy()).on(t,n),i.on=s}}function PS(e,t){var n=this._id;return arguments.length<2?Wt(this.node(),n).on.on(e):this.each(bS(n,e,t))}function AS(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function RS(){return this.on("end.remove",AS(this._id))}function MS(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Dc(e));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i()=>e;function sE(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){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:s}})}function cn(e,t,n){this.k=e,this.x=t,this.y=n}cn.prototype={constructor:cn,scale:function(e){return e===1?this:new cn(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new cn(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 fn=new cn(1,0,0);cn.prototype;function ya(e){e.stopImmediatePropagation()}function ks(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 Gf(){return this.__zoom||fn}function lE(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function aE(){return navigator.maxTouchPoints||"ontouchstart"in this}function uE(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function Eg(){var e=oE,t=iE,n=uE,r=lE,s=aE,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Gw,u=bl("start","zoom","end"),c,d,f,h=500,x=150,_=0,T=10;function p(v){v.property("__zoom",Gf).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",D).filter(s).on("touchstart.zoom",H).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",U).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}p.transform=function(v,k,N,M){var C=v.selection?v.selection():v;C.property("__zoom",Gf),v!==C?P(v,k,N,M):C.interrupt().each(function(){O(this,arguments).event(M).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},p.scaleBy=function(v,k,N,M){p.scaleTo(v,function(){var C=this.__zoom.k,S=typeof k=="function"?k.apply(this,arguments):k;return C*S},N,M)},p.scaleTo=function(v,k,N,M){p.transform(v,function(){var C=t.apply(this,arguments),S=this.__zoom,b=N==null?w(C):typeof N=="function"?N.apply(this,arguments):N,B=S.invert(b),j=typeof k=="function"?k.apply(this,arguments):k;return n(y(g(S,j),b,B),C,i)},N,M)},p.translateBy=function(v,k,N,M){p.transform(v,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),i)},null,M)},p.translateTo=function(v,k,N,M,C){p.transform(v,function(){var S=t.apply(this,arguments),b=this.__zoom,B=M==null?w(S):typeof M=="function"?M.apply(this,arguments):M;return n(fn.translate(B[0],B[1]).scale(b.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof N=="function"?-N.apply(this,arguments):-N),S,i)},M,C)};function g(v,k){return k=Math.max(o[0],Math.min(o[1],k)),k===v.k?v:new cn(k,v.x,v.y)}function y(v,k,N){var M=k[0]-N[0]*v.k,C=k[1]-N[1]*v.k;return M===v.x&&C===v.y?v:new cn(v.k,M,C)}function w(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function P(v,k,N,M){v.on("start.zoom",function(){O(this,arguments).event(M).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(M).end()}).tween("zoom",function(){var C=this,S=arguments,b=O(C,S).event(M),B=t.apply(C,S),j=N==null?w(B):typeof N=="function"?N.apply(C,S):N,Y=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),Q=C.__zoom,ne=typeof k=="function"?k.apply(C,S):k,se=a(Q.invert(j).concat(Y/Q.k),ne.invert(j).concat(Y/ne.k));return function(fe){if(fe===1)fe=ne;else{var W=se(fe),A=Y/W[2];fe=new cn(A,j[0]-W[0]*A,j[1]-W[1]*A)}b.zoom(null,fe)}})}function O(v,k,N){return!N&&v.__zooming||new L(v,k)}function L(v,k){this.that=v,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,k),this.taps=0}L.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,k){return this.mouse&&v!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var k=kt(this.that).datum();u.call(v,this.that,new sE(v,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:u}),k)}};function R(v,...k){if(!e.apply(this,arguments))return;var N=O(this,k).event(v),M=this.__zoom,C=Math.max(o[0],Math.min(o[1],M.k*Math.pow(2,r.apply(this,arguments)))),S=$t(v);if(N.wheel)(N.mouse[0][0]!==S[0]||N.mouse[0][1]!==S[1])&&(N.mouse[1]=M.invert(N.mouse[0]=S)),clearTimeout(N.wheel);else{if(M.k===C)return;N.mouse=[S,M.invert(S)],Ci(this),N.start()}ks(v),N.wheel=setTimeout(b,x),N.zoom("mouse",n(y(g(M,C),N.mouse[0],N.mouse[1]),N.extent,i));function b(){N.wheel=null,N.end()}}function F(v,...k){if(f||!e.apply(this,arguments))return;var N=v.currentTarget,M=O(this,k,!0).event(v),C=kt(v.view).on("mousemove.zoom",j,!0).on("mouseup.zoom",Y,!0),S=$t(v,N),b=v.clientX,B=v.clientY;ag(v.view),ya(v),M.mouse=[S,this.__zoom.invert(S)],Ci(this),M.start();function j(Q){if(ks(Q),!M.moved){var ne=Q.clientX-b,se=Q.clientY-B;M.moved=ne*ne+se*se>_}M.event(Q).zoom("mouse",n(y(M.that.__zoom,M.mouse[0]=$t(Q,N),M.mouse[1]),M.extent,i))}function Y(Q){C.on("mousemove.zoom mouseup.zoom",null),ug(Q.view,M.moved),ks(Q),M.event(Q).end()}}function D(v,...k){if(e.apply(this,arguments)){var N=this.__zoom,M=$t(v.changedTouches?v.changedTouches[0]:v,this),C=N.invert(M),S=N.k*(v.shiftKey?.5:2),b=n(y(g(N,S),M,C),t.apply(this,k),i);ks(v),l>0?kt(this).transition().duration(l).call(P,b,M,v):kt(this).call(p.transform,b,M,v)}}function H(v,...k){if(e.apply(this,arguments)){var N=v.touches,M=N.length,C=O(this,k,v.changedTouches.length===M).event(v),S,b,B,j;for(ya(v),b=0;b"[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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,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.`},Ng=vn.error001();function Ce(e,t){const n=E.useContext(Ml);if(n===null)throw new Error(Ng);return Xm(n,e,t)}const Ve=()=>{const e=E.useContext(Ml);if(e===null)throw new Error(Ng);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},dE=e=>e.userSelectionActive?"none":"all";function Yc({position:e,children:t,className:n,style:r,...s}){const o=Ce(dE),i=`${e}`.split("-");return V.createElement("div",{className:qe(["react-flow__panel",n,...i]),style:{...r,pointerEvents:o},...s},t)}function fE({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:V.createElement(Yc,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},V.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const pE=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:a,className:u,...c})=>{const d=E.useRef(null),[f,h]=E.useState({x:0,y:0,width:0,height:0}),x=qe(["react-flow__edge-textwrapper",u]);return E.useEffect(()=>{if(d.current){const _=d.current.getBBox();h({x:_.x,y:_.y,width:_.width,height:_.height})}},[n]),typeof n>"u"||!n?null:V.createElement("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:x,visibility:f.width?"visible":"hidden",...c},s&&V.createElement("rect",{width:f.width+2*i[0],x:-i[0],y:-i[1],height:f.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),V.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:d,style:r},n),a)};var hE=E.memo(pE);const Kc=e=>({width:e.offsetWidth,height:e.offsetHeight}),ds=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Xc=(e={x:0,y:0},t)=>({x:ds(e.x,t[0][0],t[1][0]),y:ds(e.y,t[0][1],t[1][1])}),Yf=(e,t,n)=>en?-ds(Math.abs(e-n),1,50)/50:0,Tg=(e,t)=>{const n=Yf(e.x,35,t.width-35)*20,r=Yf(e.y,35,t.height-35)*20;return[n,r]},kg=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Cg=(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)}),So=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ig=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Kf=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),mE=(e,t)=>Ig(Cg(So(e),So(t))),Lu=(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)},gE=e=>It(e.width)&&It(e.height)&&It(e.x)&&It(e.y),It=e=>!isNaN(e)&&isFinite(e),Be=Symbol.for("internals"),bg=["Enter"," ","Escape"],yE=(e,t)=>{},vE=e=>"nativeEvent"in e;function $u(e){var s,o;const t=vE(e)?e.nativeEvent:e,n=((o=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:o[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const Pg=e=>"clientX"in e,Dn=(e,t)=>{var o,i;const n=Pg(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},ul=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Ro=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:f,interactionWidth:h=20})=>V.createElement(V.Fragment,null,V.createElement("path",{id:e,style:c,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:f}),h&&V.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),s&&It(n)&&It(r)?V.createElement(hE,{x:n,y:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u}):null);Ro.displayName="BaseEdge";function Cs(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function Ag({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n{const[T,p,g]=Mg({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return V.createElement(Ro,{path:T,labelX:p,labelY:g,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:x,interactionWidth:_})});Qc.displayName="SimpleBezierEdge";const Qf={[re.Left]:{x:-1,y:0},[re.Right]:{x:1,y:0},[re.Top]:{x:0,y:-1},[re.Bottom]:{x:0,y:1}},_E=({source:e,sourcePosition:t=re.Bottom,target:n})=>t===re.Left||t===re.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function xE({source:e,sourcePosition:t=re.Bottom,target:n,targetPosition:r=re.Top,center:s,offset:o}){const i=Qf[t],l=Qf[r],a={x:e.x+i.x*o,y:e.y+i.y*o},u={x:n.x+l.x*o,y:n.y+l.y*o},c=_E({source:a,sourcePosition:t,target:u}),d=c.x!==0?"x":"y",f=c[d];let h=[],x,_;const T={x:0,y:0},p={x:0,y:0},[g,y,w,P]=Ag({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[d]*l[d]===-1){x=s.x??g,_=s.y??y;const L=[{x,y:a.y},{x,y:u.y}],R=[{x:a.x,y:_},{x:u.x,y:_}];i[d]===f?h=d==="x"?L:R:h=d==="x"?R:L}else{const L=[{x:a.x,y:u.y}],R=[{x:u.x,y:a.y}];if(d==="x"?h=i.x===f?R:L:h=i.y===f?L:R,t===r){const U=Math.abs(e[d]-n[d]);if(U<=o){const v=Math.min(o-1,o-U);i[d]===f?T[d]=(a[d]>e[d]?-1:1)*v:p[d]=(u[d]>n[d]?-1:1)*v}}if(t!==r){const U=d==="x"?"y":"x",v=i[d]===l[U],k=a[U]>u[U],N=a[U]=Z?(x=(F.x+D.x)/2,_=h[0].y):(x=h[0].x,_=(F.y+D.y)/2)}return[[e,{x:a.x+T.x,y:a.y+T.y},...h,{x:u.x+p.x,y:u.y+p.y},n],x,_,w,P]}function wE(e,t,n,r){const s=Math.min(Zf(e,t)/2,Zf(t,n)/2,r),{x:o,y:i}=t;if(e.x===o&&o===n.x||e.y===i&&i===n.y)return`L${o} ${i}`;if(e.y===i){const u=e.x{let y="";return g>0&&g{const[p,g,y]=Bu({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return V.createElement(Ro,{path:p,labelX:g,labelY:y,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:h,markerStart:x,interactionWidth:T})});Ol.displayName="SmoothStepEdge";const Zc=E.memo(e=>{var t;return V.createElement(Ol,{...e,pathOptions:E.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Zc.displayName="StepEdge";function SE({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,i,l]=Ag({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,i,l]}const qc=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:f,interactionWidth:h})=>{const[x,_,T]=SE({sourceX:e,sourceY:t,targetX:n,targetY:r});return V.createElement(Ro,{path:x,labelX:_,labelY:T,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:a,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:f,interactionWidth:h})});qc.displayName="StraightEdge";function ni(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function qf({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case re.Left:return[t-ni(t-r,o),n];case re.Right:return[t+ni(r-t,o),n];case re.Top:return[t,n-ni(n-s,o)];case re.Bottom:return[t,n+ni(s-n,o)]}}function Og({sourceX:e,sourceY:t,sourcePosition:n=re.Bottom,targetX:r,targetY:s,targetPosition:o=re.Top,curvature:i=.25}){const[l,a]=qf({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[u,c]=qf({pos:o,x1:r,y1:s,x2:e,y2:t,c:i}),[d,f,h,x]=Rg({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:a,targetControlX:u,targetControlY:c});return[`M${e},${t} C${l},${a} ${u},${c} ${r},${s}`,d,f,h,x]}const cl=E.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=re.Bottom,targetPosition:o=re.Top,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:x,pathOptions:_,interactionWidth:T})=>{const[p,g,y]=Og({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:_==null?void 0:_.curvature});return V.createElement(Ro,{path:p,labelX:g,labelY:y,label:i,labelStyle:l,labelShowBg:a,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:x,interactionWidth:T})});cl.displayName="BezierEdge";const Jc=E.createContext(null),EE=Jc.Provider;Jc.Consumer;const NE=()=>E.useContext(Jc),TE=e=>"id"in e&&"source"in e&&"target"in e,kE=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,ju=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,CE=(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)),IE=(e,t)=>{if(!e.source||!e.target)return t;let n;return TE(e)?n={...e}:n={...e,id:kE(e)},CE(n,t)?t:t.concat(n)},Fu=({x:e,y:t},[n,r,s],o,[i,l])=>{const a={x:(e-n)/s,y:(t-r)/s};return o?{x:i*Math.round(a.x/i),y:l*Math.round(a.y/l)}:a},Lg=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),dr=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-r};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:s}},Ll=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:o,y:i}=dr(s,t).positionAbsolute;return Cg(r,So({x:o,y:i,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ig(n)},$g=(e,t,[n,r,s]=[0,0,1],o=!1,i=!1,l=[0,0])=>{const a={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},u=[];return e.forEach(c=>{const{width:d,height:f,selectable:h=!0,hidden:x=!1}=c;if(i&&!h||x)return!1;const{positionAbsolute:_}=dr(c,l),T={x:_.x,y:_.y,width:d||0,height:f||0},p=Lu(a,T),g=typeof d>"u"||typeof f>"u"||d===null||f===null,y=o&&p>0,w=(d||0)*(f||0);(g||y||p>=w||c.dragging)&&u.push(c)}),u},Bg=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},jg=(e,t,n,r,s,o=.1)=>{const i=t/(e.width*(1+o)),l=n/(e.height*(1+o)),a=Math.min(i,l),u=ds(a,r,s),c=e.x+e.width/2,d=e.y+e.height/2,f=t/2-c*u,h=n/2-d*u;return{x:f,y:h,zoom:u}},er=(e,t=0)=>e.transition().duration(t);function Jf(e,t,n,r){return(t[n]||[]).reduce((s,o)=>{var i,l;return`${e.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((l=e.positionAbsolute)==null?void 0:l.y)??0)+o.y+o.height/2}),s},[])}function bE(e,t,n,r,s,o){const{x:i,y:l}=Dn(e),u=t.elementsFromPoint(i,l).find(x=>x.classList.contains("react-flow__handle"));if(u){const x=u.getAttribute("data-nodeid");if(x){const _=ed(void 0,u),T=u.getAttribute("data-handleid"),p=o({nodeId:x,id:T,type:_});if(p){const g=s.find(y=>y.nodeId===x&&y.type===_&&y.id===T);return{handle:{id:T,type:_,nodeId:x,x:(g==null?void 0:g.x)||n.x,y:(g==null?void 0:g.y)||n.y},validHandleResult:p}}}}let c=[],d=1/0;if(s.forEach(x=>{const _=Math.sqrt((x.x-n.x)**2+(x.y-n.y)**2);if(_<=r){const T=o(x);_<=d&&(_x.isValid),h=c.some(({handle:x})=>x.type==="target");return c.find(({handle:x,validHandleResult:_})=>h?x.type==="target":f?_.isValid:!0)||c[0]}const PE={source:null,target:null,sourceHandle:null,targetHandle:null},Fg=()=>({handleDomNode:null,isValid:!1,connection:PE,endHandle:null});function zg(e,t,n,r,s,o,i){const l=s==="target",a=i.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),u={...Fg(),handleDomNode:a};if(a){const c=ed(void 0,a),d=a.getAttribute("data-nodeid"),f=a.getAttribute("data-handleid"),h=a.classList.contains("connectable"),x=a.classList.contains("connectableend"),_={source:l?d:n,sourceHandle:l?f:r,target:l?n:d,targetHandle:l?r:f};u.connection=_,h&&x&&(t===_r.Strict?l&&c==="source"||!l&&c==="target":d!==n||f!==r)&&(u.endHandle={nodeId:d,handleId:f,type:c},u.isValid=o(_))}return u}function AE({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[Be]){const{handleBounds:i}=o[Be];let l=[],a=[];i&&(l=Jf(o,i,"source",`${t}-${n}-${r}`),a=Jf(o,i,"target",`${t}-${n}-${r}`)),s.push(...l,...a)}return s},[])}function ed(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function va(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function RE(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Dg({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:i,isValidConnection:l,edgeUpdaterType:a,onReconnectEnd:u}){const c=kg(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:h,connectionRadius:x,onConnectStart:_,panBy:T,getNodes:p,cancelConnection:g}=o();let y=0,w;const{x:P,y:O}=Dn(e),L=c==null?void 0:c.elementFromPoint(P,O),R=ed(a,L),F=f==null?void 0:f.getBoundingClientRect();if(!F||!R)return;let D,H=Dn(e,F),Z=!1,U=null,v=!1,k=null;const N=AE({nodes:p(),nodeId:n,handleId:t,handleType:R}),M=()=>{if(!h)return;const[b,B]=Tg(H,F);T({x:b,y:B}),y=requestAnimationFrame(M)};i({connectionPosition:H,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:R,connectionStartHandle:{nodeId:n,handleId:t,type:R},connectionEndHandle:null}),_==null||_(e,{nodeId:n,handleId:t,handleType:R});function C(b){const{transform:B}=o();H=Dn(b,F);const{handle:j,validHandleResult:Y}=bE(b,c,Fu(H,B,!1,[1,1]),x,N,Q=>zg(Q,d,n,t,s?"target":"source",l,c));if(w=j,Z||(M(),Z=!0),k=Y.handleDomNode,U=Y.connection,v=Y.isValid,i({connectionPosition:w&&v?Lg({x:w.x,y:w.y},B):H,connectionStatus:RE(!!w,v),connectionEndHandle:Y.endHandle}),!w&&!v&&!k)return va(D);U.source!==U.target&&k&&(va(D),D=k,k.classList.add("connecting","react-flow__handle-connecting"),k.classList.toggle("valid",v),k.classList.toggle("react-flow__handle-valid",v))}function S(b){var B,j;(w||k)&&U&&v&&(r==null||r(U)),(j=(B=o()).onConnectEnd)==null||j.call(B,b),a&&(u==null||u(b)),va(D),g(),cancelAnimationFrame(y),Z=!1,v=!1,U=null,k=null,c.removeEventListener("mousemove",C),c.removeEventListener("mouseup",S),c.removeEventListener("touchmove",C),c.removeEventListener("touchend",S)}c.addEventListener("mousemove",C),c.addEventListener("mouseup",S),c.addEventListener("touchmove",C),c.addEventListener("touchend",S)}const ep=()=>!0,ME=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),OE=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:i}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},Ug=E.forwardRef(({type:e="source",position:t=re.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:l,children:a,className:u,onMouseDown:c,onTouchStart:d,...f},h)=>{var F,D;const x=i||null,_=e==="target",T=Ve(),p=NE(),{connectOnClick:g,noPanClassName:y}=Ce(ME,Ke),{connecting:w,clickConnecting:P}=Ce(OE(p,x,e),Ke);p||(D=(F=T.getState()).onError)==null||D.call(F,"010",vn.error010());const O=H=>{const{defaultEdgeOptions:Z,onConnect:U,hasDefaultEdges:v}=T.getState(),k={...Z,...H};if(v){const{edges:N,setEdges:M}=T.getState();M(IE(k,N))}U==null||U(k),l==null||l(k)},L=H=>{if(!p)return;const Z=Pg(H);s&&(Z&&H.button===0||!Z)&&Dg({event:H,handleId:x,nodeId:p,onConnect:O,isTarget:_,getState:T.getState,setState:T.setState,isValidConnection:n||T.getState().isValidConnection||ep}),Z?c==null||c(H):d==null||d(H)},R=H=>{const{onClickConnectStart:Z,onClickConnectEnd:U,connectionClickStartHandle:v,connectionMode:k,isValidConnection:N}=T.getState();if(!p||!v&&!s)return;if(!v){Z==null||Z(H,{nodeId:p,handleId:x,handleType:e}),T.setState({connectionClickStartHandle:{nodeId:p,type:e,handleId:x}});return}const M=kg(H.target),C=n||N||ep,{connection:S,isValid:b}=zg({nodeId:p,id:x,type:e},k,v.nodeId,v.handleId||null,v.type,C,M);b&&O(S),U==null||U(H),T.setState({connectionClickStartHandle:null})};return V.createElement("div",{"data-handleid":x,"data-nodeid":p,"data-handlepos":t,"data-id":`${p}-${x}-${e}`,className:qe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,u,{source:!_,target:_,connectable:r,connectablestart:s,connectableend:o,connecting:P,connectionindicator:r&&(s&&!w||o&&w)}]),onMouseDown:L,onTouchStart:L,onClick:g?R:void 0,ref:h,...f},a)});Ug.displayName="Handle";var dl=E.memo(Ug);const Hg=({data:e,isConnectable:t,targetPosition:n=re.Top,sourcePosition:r=re.Bottom})=>V.createElement(V.Fragment,null,V.createElement(dl,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,V.createElement(dl,{type:"source",position:r,isConnectable:t}));Hg.displayName="DefaultNode";var zu=E.memo(Hg);const Wg=({data:e,isConnectable:t,sourcePosition:n=re.Bottom})=>V.createElement(V.Fragment,null,e==null?void 0:e.label,V.createElement(dl,{type:"source",position:n,isConnectable:t}));Wg.displayName="InputNode";var Vg=E.memo(Wg);const Gg=({data:e,isConnectable:t,targetPosition:n=re.Top})=>V.createElement(V.Fragment,null,V.createElement(dl,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);Gg.displayName="OutputNode";var Yg=E.memo(Gg);const td=()=>null;td.displayName="GroupNode";const LE=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),ri=e=>e.id;function $E(e,t){return Ke(e.selectedNodes.map(ri),t.selectedNodes.map(ri))&&Ke(e.selectedEdges.map(ri),t.selectedEdges.map(ri))}const Kg=E.memo(({onSelectionChange:e})=>{const t=Ve(),{selectedNodes:n,selectedEdges:r}=Ce(LE,$E);return E.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});Kg.displayName="SelectionListener";const BE=e=>!!e.onSelectionChange;function jE({onSelectionChange:e}){const t=Ce(BE);return e||t?V.createElement(Kg,{onSelectionChange:e}):null}const FE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Nr(e,t){E.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ve(e,t,n){E.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const zE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:a,nodesDraggable:u,nodesConnectable:c,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:h,elevateNodesOnSelect:x,minZoom:_,maxZoom:T,nodeExtent:p,onNodesChange:g,onEdgesChange:y,elementsSelectable:w,connectionMode:P,snapGrid:O,snapToGrid:L,translateExtent:R,connectOnClick:F,defaultEdgeOptions:D,fitView:H,fitViewOptions:Z,onNodesDelete:U,onEdgesDelete:v,onNodeDrag:k,onNodeDragStart:N,onNodeDragStop:M,onSelectionDrag:C,onSelectionDragStart:S,onSelectionDragStop:b,noPanClassName:B,nodeOrigin:j,rfId:Y,autoPanOnConnect:Q,autoPanOnNodeDrag:ne,onError:se,connectionRadius:fe,isValidConnection:W,nodeDragThreshold:A})=>{const{setNodes:I,setEdges:G,setDefaultNodesAndEdges:X,setMinZoom:ie,setMaxZoom:le,setTranslateExtent:ce,setNodeExtent:he,reset:oe}=Ce(FE,Ke),K=Ve();return E.useEffect(()=>{const z=r==null?void 0:r.map(ee=>({...ee,...D}));return X(n,z),()=>{oe()}},[]),ve("defaultEdgeOptions",D,K.setState),ve("connectionMode",P,K.setState),ve("onConnect",s,K.setState),ve("onConnectStart",o,K.setState),ve("onConnectEnd",i,K.setState),ve("onClickConnectStart",l,K.setState),ve("onClickConnectEnd",a,K.setState),ve("nodesDraggable",u,K.setState),ve("nodesConnectable",c,K.setState),ve("nodesFocusable",d,K.setState),ve("edgesFocusable",f,K.setState),ve("edgesUpdatable",h,K.setState),ve("elementsSelectable",w,K.setState),ve("elevateNodesOnSelect",x,K.setState),ve("snapToGrid",L,K.setState),ve("snapGrid",O,K.setState),ve("onNodesChange",g,K.setState),ve("onEdgesChange",y,K.setState),ve("connectOnClick",F,K.setState),ve("fitViewOnInit",H,K.setState),ve("fitViewOnInitOptions",Z,K.setState),ve("onNodesDelete",U,K.setState),ve("onEdgesDelete",v,K.setState),ve("onNodeDrag",k,K.setState),ve("onNodeDragStart",N,K.setState),ve("onNodeDragStop",M,K.setState),ve("onSelectionDrag",C,K.setState),ve("onSelectionDragStart",S,K.setState),ve("onSelectionDragStop",b,K.setState),ve("noPanClassName",B,K.setState),ve("nodeOrigin",j,K.setState),ve("rfId",Y,K.setState),ve("autoPanOnConnect",Q,K.setState),ve("autoPanOnNodeDrag",ne,K.setState),ve("onError",se,K.setState),ve("connectionRadius",fe,K.setState),ve("isValidConnection",W,K.setState),ve("nodeDragThreshold",A,K.setState),Nr(e,I),Nr(t,G),Nr(_,ie),Nr(T,le),Nr(R,ce),Nr(p,he),null},tp={display:"none"},DE={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Xg="react-flow__node-desc",Qg="react-flow__edge-desc",UE="react-flow__aria-live",HE=e=>e.ariaLiveMessage;function WE({rfId:e}){const t=Ce(HE);return V.createElement("div",{id:`${UE}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:DE},t)}function VE({rfId:e,disableKeyboardA11y:t}){return V.createElement(V.Fragment,null,V.createElement("div",{id:`${Xg}-${e}`,style:tp},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),V.createElement("div",{id:`${Qg}-${e}`,style:tp},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&V.createElement(WE,{rfId:e}))}var No=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=E.useState(!1),s=E.useRef(!1),o=E.useRef(new Set([])),[i,l]=E.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),c=u.reduce((d,f)=>d.concat(...f),[]);return[u,c]}return[[],[]]},[e]);return E.useEffect(()=>{const a=typeof document<"u"?document:null,u=(t==null?void 0:t.target)||a;if(e!==null){const c=h=>{if(s.current=h.ctrlKey||h.metaKey||h.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&$u(h))return!1;const _=rp(h.code,l);o.current.add(h[_]),np(i,o.current,!1)&&(h.preventDefault(),r(!0))},d=h=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&$u(h))return!1;const _=rp(h.code,l);np(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[_]),h.key==="Meta"&&o.current.clear(),s.current=!1},f=()=>{o.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",c),u==null||u.addEventListener("keyup",d),window.addEventListener("blur",f),()=>{u==null||u.removeEventListener("keydown",c),u==null||u.removeEventListener("keyup",d),window.removeEventListener("blur",f)}}},[e,r]),n};function np(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function rp(e,t){return t.includes(e)?"code":"key"}function Zg(e,t,n,r){var l,a;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),i=dr(o,r);return Zg(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((l=o[Be])==null?void 0:l.z)??0)>(n.z??0)?((a=o[Be])==null?void 0:a.z)??0:n.z??0},r)}function qg(e,t,n){e.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:i,y:l,z:a}=Zg(r,e,{...r.position,z:((o=r[Be])==null?void 0:o.z)??0},t);r.positionAbsolute={x:i,y:l},r[Be].z=a,n!=null&&n[r.id]&&(r[Be].isParent=!0)}})}function _a(e,t,n,r){const s=new Map,o={},i=r?1e3:0;return e.forEach(l=>{var h;const a=(It(l.zIndex)?l.zIndex:0)+(l.selected?i:0),u=t.get(l.id),c={...l,positionAbsolute:{x:l.position.x,y:l.position.y}},d=l.parentNode||l.parentId;d&&(o[d]=!0);const f=(u==null?void 0:u.type)&&(u==null?void 0:u.type)!==l.type;Object.defineProperty(c,Be,{enumerable:!1,value:{handleBounds:f||(h=u==null?void 0:u[Be])==null?void 0:h.handleBounds,z:a}}),s.set(l.id,c)}),qg(s,n,o),s}function Jg(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:i,d3Zoom:l,d3Selection:a,fitViewOnInitDone:u,fitViewOnInit:c,nodeOrigin:d}=e(),f=t.initial&&!u&&c;if(l&&a&&(f||!t.initial)){const x=n().filter(T=>{var g;const p=t.includeHiddenNodes?T.width&&T.height:!T.hidden;return(g=t.nodes)!=null&&g.length?p&&t.nodes.some(y=>y.id===T.id):p}),_=x.every(T=>T.width&&T.height);if(x.length>0&&_){const T=Ll(x,d),{x:p,y:g,zoom:y}=jg(T,r,s,t.minZoom??o,t.maxZoom??i,t.padding??.1),w=fn.translate(p,g).scale(y);return typeof t.duration=="number"&&t.duration>0?l.transform(er(a,t.duration),w):l.transform(a,w),!0}}return!1}function GE(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Be]:r[Be],selected:n.selected})}),new Map(t)}function YE(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function si({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:a,hasDefaultEdges:u}=n();e!=null&&e.length&&(a&&r({nodeInternals:GE(e,s)}),i==null||i(e)),t!=null&&t.length&&(u&&r({edges:YE(t,o)}),l==null||l(t))}const Tr=()=>{},KE={zoomIn:Tr,zoomOut:Tr,zoomTo:Tr,getZoom:()=>1,setViewport:Tr,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Tr,fitBounds:Tr,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},XE=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),QE=()=>{const e=Ve(),{d3Zoom:t,d3Selection:n}=Ce(XE,Ke);return E.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(er(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(er(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(er(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[i,l,a]=e.getState().transform,u=fn.translate(s.x??i,s.y??l).scale(s.zoom??a);t.transform(er(n,o==null?void 0:o.duration),u)},getViewport:()=>{const[s,o,i]=e.getState().transform;return{x:s,y:o,zoom:i}},fitView:s=>Jg(e.getState,s),setCenter:(s,o,i)=>{const{width:l,height:a,maxZoom:u}=e.getState(),c=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:u,d=l/2-s*c,f=a/2-o*c,h=fn.translate(d,f).scale(c);t.transform(er(n,i==null?void 0:i.duration),h)},fitBounds:(s,o)=>{const{width:i,height:l,minZoom:a,maxZoom:u}=e.getState(),{x:c,y:d,zoom:f}=jg(s,i,l,a,u,(o==null?void 0:o.padding)??.1),h=fn.translate(c,d).scale(f);t.transform(er(n,o==null?void 0:o.duration),h)},project:s=>{const{transform:o,snapToGrid:i,snapGrid:l}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Fu(s,o,i,l)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:i,snapGrid:l,domNode:a}=e.getState();if(!a)return s;const{x:u,y:c}=a.getBoundingClientRect(),d={x:s.x-u,y:s.y-c};return Fu(d,o,i,l)},flowToScreenPosition:s=>{const{transform:o,domNode:i}=e.getState();if(!i)return s;const{x:l,y:a}=i.getBoundingClientRect(),u=Lg(s,o);return{x:u.x+l,y:u.y+a}},viewportInitialized:!0}:KE,[t,n])};function nd(){const e=QE(),t=Ve(),n=E.useCallback(()=>t.getState().getNodes().map(_=>({..._})),[]),r=E.useCallback(_=>t.getState().nodeInternals.get(_),[]),s=E.useCallback(()=>{const{edges:_=[]}=t.getState();return _.map(T=>({...T}))},[]),o=E.useCallback(_=>{const{edges:T=[]}=t.getState();return T.find(p=>p.id===_)},[]),i=E.useCallback(_=>{const{getNodes:T,setNodes:p,hasDefaultNodes:g,onNodesChange:y}=t.getState(),w=T(),P=typeof _=="function"?_(w):_;if(g)p(P);else if(y){const O=P.length===0?w.map(L=>({type:"remove",id:L.id})):P.map(L=>({item:L,type:"reset"}));y(O)}},[]),l=E.useCallback(_=>{const{edges:T=[],setEdges:p,hasDefaultEdges:g,onEdgesChange:y}=t.getState(),w=typeof _=="function"?_(T):_;if(g)p(w);else if(y){const P=w.length===0?T.map(O=>({type:"remove",id:O.id})):w.map(O=>({item:O,type:"reset"}));y(P)}},[]),a=E.useCallback(_=>{const T=Array.isArray(_)?_:[_],{getNodes:p,setNodes:g,hasDefaultNodes:y,onNodesChange:w}=t.getState();if(y){const O=[...p(),...T];g(O)}else if(w){const P=T.map(O=>({item:O,type:"add"}));w(P)}},[]),u=E.useCallback(_=>{const T=Array.isArray(_)?_:[_],{edges:p=[],setEdges:g,hasDefaultEdges:y,onEdgesChange:w}=t.getState();if(y)g([...p,...T]);else if(w){const P=T.map(O=>({item:O,type:"add"}));w(P)}},[]),c=E.useCallback(()=>{const{getNodes:_,edges:T=[],transform:p}=t.getState(),[g,y,w]=p;return{nodes:_().map(P=>({...P})),edges:T.map(P=>({...P})),viewport:{x:g,y,zoom:w}}},[]),d=E.useCallback(({nodes:_,edges:T})=>{const{nodeInternals:p,getNodes:g,edges:y,hasDefaultNodes:w,hasDefaultEdges:P,onNodesDelete:O,onEdgesDelete:L,onNodesChange:R,onEdgesChange:F}=t.getState(),D=(_||[]).map(k=>k.id),H=(T||[]).map(k=>k.id),Z=g().reduce((k,N)=>{const M=N.parentNode||N.parentId,C=!D.includes(N.id)&&M&&k.find(b=>b.id===M);return(typeof N.deletable=="boolean"?N.deletable:!0)&&(D.includes(N.id)||C)&&k.push(N),k},[]),U=y.filter(k=>typeof k.deletable=="boolean"?k.deletable:!0),v=U.filter(k=>H.includes(k.id));if(Z||v){const k=Bg(Z,U),N=[...v,...k],M=N.reduce((C,S)=>(C.includes(S.id)||C.push(S.id),C),[]);if((P||w)&&(P&&t.setState({edges:y.filter(C=>!M.includes(C.id))}),w&&(Z.forEach(C=>{p.delete(C.id)}),t.setState({nodeInternals:new Map(p)}))),M.length>0&&(L==null||L(N),F&&F(M.map(C=>({id:C,type:"remove"})))),Z.length>0&&(O==null||O(Z),R)){const C=Z.map(S=>({id:S.id,type:"remove"}));R(C)}}},[]),f=E.useCallback(_=>{const T=gE(_),p=T?null:t.getState().nodeInternals.get(_.id);return!T&&!p?[null,null,T]:[T?_:Kf(p),p,T]},[]),h=E.useCallback((_,T=!0,p)=>{const[g,y,w]=f(_);return g?(p||t.getState().getNodes()).filter(P=>{if(!w&&(P.id===y.id||!P.positionAbsolute))return!1;const O=Kf(P),L=Lu(O,g);return T&&L>0||L>=g.width*g.height}):[]},[]),x=E.useCallback((_,T,p=!0)=>{const[g]=f(_);if(!g)return!1;const y=Lu(g,T);return p&&y>0||y>=g.width*g.height},[]);return E.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:i,setEdges:l,addNodes:a,addEdges:u,toObject:c,deleteElements:d,getIntersectingNodes:h,isNodeIntersecting:x}),[e,n,r,s,o,i,l,a,u,c,d,h,x])}const ZE={actInsideInputWithModifier:!1};var qE=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ve(),{deleteElements:r}=nd(),s=No(e,ZE),o=No(t);E.useEffect(()=>{if(s){const{edges:i,getNodes:l}=n.getState(),a=l().filter(c=>c.selected),u=i.filter(c=>c.selected);r({nodes:a,edges:u}),n.setState({nodesSelectionActive:!1})}},[s]),E.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function JE(e){const t=Ve();E.useEffect(()=>{let n;const r=()=>{var o,i;if(!e.current)return;const s=Kc(e.current);(s.height===0||s.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",vn.error004())),t.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const rd={position:"absolute",width:"100%",height:"100%",top:0,left:0},eN=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,oi=e=>({x:e.x,y:e.y,zoom:e.k}),kr=(e,t)=>e.target.closest(`.${t}`),sp=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),op=e=>{const t=e.ctrlKey&&ul()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},tN=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),nN=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:a=lr.Free,zoomOnDoubleClick:u=!0,elementsSelectable:c,panOnDrag:d=!0,defaultViewport:f,translateExtent:h,minZoom:x,maxZoom:_,zoomActivationKeyCode:T,preventScrolling:p=!0,children:g,noWheelClassName:y,noPanClassName:w})=>{const P=E.useRef(),O=Ve(),L=E.useRef(!1),R=E.useRef(!1),F=E.useRef(null),D=E.useRef({x:0,y:0,zoom:0}),{d3Zoom:H,d3Selection:Z,d3ZoomHandler:U,userSelectionActive:v}=Ce(tN,Ke),k=No(T),N=E.useRef(0),M=E.useRef(!1),C=E.useRef();return JE(F),E.useEffect(()=>{if(F.current){const S=F.current.getBoundingClientRect(),b=Eg().scaleExtent([x,_]).translateExtent(h),B=kt(F.current).call(b),j=fn.translate(f.x,f.y).scale(ds(f.zoom,x,_)),Y=[[0,0],[S.width,S.height]],Q=b.constrain()(j,Y,h);b.transform(B,Q),b.wheelDelta(op),O.setState({d3Zoom:b,d3Selection:B,d3ZoomHandler:B.on("wheel.zoom"),transform:[Q.x,Q.y,Q.k],domNode:F.current.closest(".react-flow")})}},[]),E.useEffect(()=>{Z&&H&&(i&&!k&&!v?Z.on("wheel.zoom",S=>{if(kr(S,y))return!1;S.preventDefault(),S.stopImmediatePropagation();const b=Z.property("__zoom").k||1;if(S.ctrlKey&&o){const W=$t(S),A=op(S),I=b*Math.pow(2,A);H.scaleTo(Z,I,W,S);return}const B=S.deltaMode===1?20:1;let j=a===lr.Vertical?0:S.deltaX*B,Y=a===lr.Horizontal?0:S.deltaY*B;!ul()&&S.shiftKey&&a!==lr.Vertical&&(j=S.deltaY*B,Y=0),H.translateBy(Z,-(j/b)*l,-(Y/b)*l,{internal:!0});const Q=oi(Z.property("__zoom")),{onViewportChangeStart:ne,onViewportChange:se,onViewportChangeEnd:fe}=O.getState();clearTimeout(C.current),M.current||(M.current=!0,t==null||t(S,Q),ne==null||ne(Q)),M.current&&(e==null||e(S,Q),se==null||se(Q),C.current=setTimeout(()=>{n==null||n(S,Q),fe==null||fe(Q),M.current=!1},150))},{passive:!1}):typeof U<"u"&&Z.on("wheel.zoom",function(S,b){if(!p&&S.type==="wheel"&&!S.ctrlKey||kr(S,y))return null;S.preventDefault(),U.call(this,S,b)},{passive:!1}))},[v,i,a,Z,H,U,k,o,p,y,t,e,n]),E.useEffect(()=>{H&&H.on("start",S=>{var j,Y;if(!S.sourceEvent||S.sourceEvent.internal)return null;N.current=(j=S.sourceEvent)==null?void 0:j.button;const{onViewportChangeStart:b}=O.getState(),B=oi(S.transform);L.current=!0,D.current=B,((Y=S.sourceEvent)==null?void 0:Y.type)==="mousedown"&&O.setState({paneDragging:!0}),b==null||b(B),t==null||t(S.sourceEvent,B)})},[H,t]),E.useEffect(()=>{H&&(v&&!L.current?H.on("zoom",null):v||H.on("zoom",S=>{var B;const{onViewportChange:b}=O.getState();if(O.setState({transform:[S.transform.x,S.transform.y,S.transform.k]}),R.current=!!(r&&sp(d,N.current??0)),(e||b)&&!((B=S.sourceEvent)!=null&&B.internal)){const j=oi(S.transform);b==null||b(j),e==null||e(S.sourceEvent,j)}}))},[v,H,e,d,r]),E.useEffect(()=>{H&&H.on("end",S=>{if(!S.sourceEvent||S.sourceEvent.internal)return null;const{onViewportChangeEnd:b}=O.getState();if(L.current=!1,O.setState({paneDragging:!1}),r&&sp(d,N.current??0)&&!R.current&&r(S.sourceEvent),R.current=!1,(n||b)&&eN(D.current,S.transform)){const B=oi(S.transform);D.current=B,clearTimeout(P.current),P.current=setTimeout(()=>{b==null||b(B),n==null||n(S.sourceEvent,B)},i?150:0)}})},[H,i,d,n,r]),E.useEffect(()=>{H&&H.filter(S=>{const b=k||s,B=o&&S.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&S.button===1&&S.type==="mousedown"&&(kr(S,"react-flow__node")||kr(S,"react-flow__edge")))return!0;if(!d&&!b&&!i&&!u&&!o||v||!u&&S.type==="dblclick"||kr(S,y)&&S.type==="wheel"||kr(S,w)&&(S.type!=="wheel"||i&&S.type==="wheel"&&!k)||!o&&S.ctrlKey&&S.type==="wheel"||!b&&!i&&!B&&S.type==="wheel"||!d&&(S.type==="mousedown"||S.type==="touchstart")||Array.isArray(d)&&!d.includes(S.button)&&S.type==="mousedown")return!1;const j=Array.isArray(d)&&d.includes(S.button)||!S.button||S.button<=1;return(!S.ctrlKey||S.type==="wheel")&&j})},[v,H,s,o,i,u,d,c,k]),V.createElement("div",{className:"react-flow__renderer",ref:F,style:rd},g)},rN=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function sN(){const{userSelectionActive:e,userSelectionRect:t}=Ce(rN,Ke);return e&&t?V.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function ip(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(s>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),t.position.x<0){const i=Math.abs(t.position.x);r.position.x=r.position.x-i,r.style.width+=i,t.position.x=0}if(t.position.y<0){const i=Math.abs(t.position.y);r.position.y=r.position.y-i,r.style.height+=i,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function oN(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const o=e.filter(l=>l.id===s.id);if(o.length===0)return r.push(s),r;const i={...s};for(const l of o)if(l)switch(l.type){case"select":{i.selected=l.selected;break}case"position":{typeof l.position<"u"&&(i.position=l.position),typeof l.positionAbsolute<"u"&&(i.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(i.dragging=l.dragging),i.expandParent&&ip(r,i);break}case"dimensions":{typeof l.dimensions<"u"&&(i.width=l.dimensions.width,i.height=l.dimensions.height),typeof l.updateStyle<"u"&&(i.style={...i.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(i.resizing=l.resizing),i.expandParent&&ip(r,i);break}case"remove":return r}return r.push(i),r},n)}function iN(e,t){return oN(e,t)}const Cn=(e,t)=>({id:e,type:"select",selected:t});function Hr(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Cn(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Cn(r.id,!1))),n},[])}const xa=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},lN=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),e0=E.memo(({isSelecting:e,selectionMode:t=Eo.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:a,onPaneMouseMove:u,onPaneMouseLeave:c,children:d})=>{const f=E.useRef(null),h=Ve(),x=E.useRef(0),_=E.useRef(0),T=E.useRef(),{userSelectionActive:p,elementsSelectable:g,dragging:y}=Ce(lN,Ke),w=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),x.current=0,_.current=0},P=U=>{o==null||o(U),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},O=U=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){U.preventDefault();return}i==null||i(U)},L=l?U=>l(U):void 0,R=U=>{const{resetSelectedElements:v,domNode:k}=h.getState();if(T.current=k==null?void 0:k.getBoundingClientRect(),!g||!e||U.button!==0||U.target!==f.current||!T.current)return;const{x:N,y:M}=Dn(U,T.current);v(),h.setState({userSelectionRect:{width:0,height:0,startX:N,startY:M,x:N,y:M}}),r==null||r(U)},F=U=>{const{userSelectionRect:v,nodeInternals:k,edges:N,transform:M,onNodesChange:C,onEdgesChange:S,nodeOrigin:b,getNodes:B}=h.getState();if(!e||!T.current||!v)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const j=Dn(U,T.current),Y=v.startX??0,Q=v.startY??0,ne={...v,x:j.xI.id),A=fe.map(I=>I.id);if(x.current!==A.length){x.current=A.length;const I=Hr(se,A);I.length&&(C==null||C(I))}if(_.current!==W.length){_.current=W.length;const I=Hr(N,W);I.length&&(S==null||S(I))}h.setState({userSelectionRect:ne})},D=U=>{if(U.button!==0)return;const{userSelectionRect:v}=h.getState();!p&&v&&U.target===f.current&&(P==null||P(U)),h.setState({nodesSelectionActive:x.current>0}),w(),s==null||s(U)},H=U=>{p&&(h.setState({nodesSelectionActive:x.current>0}),s==null||s(U)),w()},Z=g&&(e||p);return V.createElement("div",{className:qe(["react-flow__pane",{dragging:y,selection:e}]),onClick:Z?void 0:xa(P,f),onContextMenu:xa(O,f),onWheel:xa(L,f),onMouseEnter:Z?void 0:a,onMouseDown:Z?R:void 0,onMouseMove:Z?F:u,onMouseUp:Z?D:void 0,onMouseLeave:Z?H:c,ref:f,style:rd},d,V.createElement(sN,null))});e0.displayName="Pane";function t0(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:t0(r,t):!1}function lp(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function aN(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!t0(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var o,i;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=s.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function uN(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function n0(e,t,n,r,s=[0,0],o){const i=uN(e,e.extent||r);let l=i;const a=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(a&&e.width&&e.height){const d=n.get(a),{x:f,y:h}=dr(d,s).positionAbsolute;l=d&&It(f)&&It(h)&&It(d.width)&&It(d.height)?[[f+e.width*s[0],h+e.height*s[1]],[f+d.width-e.width+e.width*s[0],h+d.height-e.height+e.height*s[1]]]:l}else o==null||o("005",vn.error005()),l=i;else if(e.extent&&a&&e.extent!=="parent"){const d=n.get(a),{x:f,y:h}=dr(d,s).positionAbsolute;l=[[e.extent[0][0]+f,e.extent[0][1]+h],[e.extent[1][0]+f,e.extent[1][1]+h]]}let u={x:0,y:0};if(a){const d=n.get(a);u=dr(d,s).positionAbsolute}const c=l&&l!=="parent"?Xc(t,l):t;return{position:{x:c.x-u.x,y:c.y-u.y},positionAbsolute:c}}function wa({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?r.find(s=>s.id===e):r[0],r]}const ap=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),i=t.getBoundingClientRect(),l={x:i.width*r[0],y:i.height*r[1]};return o.map(a=>{const u=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),position:a.getAttribute("data-handlepos"),x:(u.left-i.left-l.x)/n,y:(u.top-i.top-l.y)/n,...Kc(a)}})};function Is(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function Du({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:l,onError:a}=t.getState(),u=l.get(e);if(!u){a==null||a("012",vn.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var c;return(c=r==null?void 0:r.current)==null?void 0:c.blur()})):s([e])}function cN(){const e=Ve();return E.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,a={x:(i-r[0])/r[2],y:(l-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(a.x/s[0]):a.x,ySnapped:o?s[1]*Math.round(a.y/s[1]):a.y,...a}},[])}function Sa(e){return(t,n,r)=>e==null?void 0:e(t,r)}function r0({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:i}){const l=Ve(),[a,u]=E.useState(!1),c=E.useRef([]),d=E.useRef({x:null,y:null}),f=E.useRef(0),h=E.useRef(null),x=E.useRef({x:0,y:0}),_=E.useRef(null),T=E.useRef(!1),p=E.useRef(!1),g=E.useRef(!1),y=cN();return E.useEffect(()=>{if(e!=null&&e.current){const w=kt(e.current),P=({x:R,y:F})=>{const{nodeInternals:D,onNodeDrag:H,onSelectionDrag:Z,updateNodePositions:U,nodeExtent:v,snapGrid:k,snapToGrid:N,nodeOrigin:M,onError:C}=l.getState();d.current={x:R,y:F};let S=!1,b={x:0,y:0,x2:0,y2:0};if(c.current.length>1&&v){const j=Ll(c.current,M);b=So(j)}if(c.current=c.current.map(j=>{const Y={x:R-j.distance.x,y:F-j.distance.y};N&&(Y.x=k[0]*Math.round(Y.x/k[0]),Y.y=k[1]*Math.round(Y.y/k[1]));const Q=[[v[0][0],v[0][1]],[v[1][0],v[1][1]]];c.current.length>1&&v&&!j.extent&&(Q[0][0]=j.positionAbsolute.x-b.x+v[0][0],Q[1][0]=j.positionAbsolute.x+(j.width??0)-b.x2+v[1][0],Q[0][1]=j.positionAbsolute.y-b.y+v[0][1],Q[1][1]=j.positionAbsolute.y+(j.height??0)-b.y2+v[1][1]);const ne=n0(j,Y,D,Q,M,C);return S=S||j.position.x!==ne.position.x||j.position.y!==ne.position.y,j.position=ne.position,j.positionAbsolute=ne.positionAbsolute,j}),!S)return;U(c.current,!0,!0),u(!0);const B=s?H:Sa(Z);if(B&&_.current){const[j,Y]=wa({nodeId:s,dragItems:c.current,nodeInternals:D});B(_.current,j,Y)}},O=()=>{if(!h.current)return;const[R,F]=Tg(x.current,h.current);if(R!==0||F!==0){const{transform:D,panBy:H}=l.getState();d.current.x=(d.current.x??0)-R/D[2],d.current.y=(d.current.y??0)-F/D[2],H({x:R,y:F})&&P(d.current)}f.current=requestAnimationFrame(O)},L=R=>{var M;const{nodeInternals:F,multiSelectionActive:D,nodesDraggable:H,unselectNodesAndEdges:Z,onNodeDragStart:U,onSelectionDragStart:v}=l.getState();p.current=!0;const k=s?U:Sa(v);(!i||!o)&&!D&&s&&((M=F.get(s))!=null&&M.selected||Z()),s&&o&&i&&Du({id:s,store:l,nodeRef:e});const N=y(R);if(d.current=N,c.current=aN(F,H,N,s),k&&c.current){const[C,S]=wa({nodeId:s,dragItems:c.current,nodeInternals:F});k(R.sourceEvent,C,S)}};if(t)w.on(".drag",null);else{const R=xw().on("start",F=>{const{domNode:D,nodeDragThreshold:H}=l.getState();H===0&&L(F),g.current=!1;const Z=y(F);d.current=Z,h.current=(D==null?void 0:D.getBoundingClientRect())||null,x.current=Dn(F.sourceEvent,h.current)}).on("drag",F=>{var U,v;const D=y(F),{autoPanOnNodeDrag:H,nodeDragThreshold:Z}=l.getState();if(F.sourceEvent.type==="touchmove"&&F.sourceEvent.touches.length>1&&(g.current=!0),!g.current){if(!T.current&&p.current&&H&&(T.current=!0,O()),!p.current){const k=D.xSnapped-(((U=d==null?void 0:d.current)==null?void 0:U.x)??0),N=D.ySnapped-(((v=d==null?void 0:d.current)==null?void 0:v.y)??0);Math.sqrt(k*k+N*N)>Z&&L(F)}(d.current.x!==D.xSnapped||d.current.y!==D.ySnapped)&&c.current&&p.current&&(_.current=F.sourceEvent,x.current=Dn(F.sourceEvent,h.current),P(D))}}).on("end",F=>{if(!(!p.current||g.current)&&(u(!1),T.current=!1,p.current=!1,cancelAnimationFrame(f.current),c.current)){const{updateNodePositions:D,nodeInternals:H,onNodeDragStop:Z,onSelectionDragStop:U}=l.getState(),v=s?Z:Sa(U);if(D(c.current,!1,!1),v){const[k,N]=wa({nodeId:s,dragItems:c.current,nodeInternals:H});v(F.sourceEvent,k,N)}}}).filter(F=>{const D=F.target;return!F.button&&(!n||!lp(D,`.${n}`,e))&&(!r||lp(D,r,e))});return w.call(R),()=>{w.on(".drag",null)}}}},[e,t,n,r,o,l,s,i,y]),a}function s0(){const e=Ve();return E.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:i,snapToGrid:l,snapGrid:a,onError:u,nodesDraggable:c}=e.getState(),d=i().filter(g=>g.selected&&(g.draggable||c&&typeof g.draggable>"u")),f=l?a[0]:5,h=l?a[1]:5,x=n.isShiftPressed?4:1,_=n.x*f*x,T=n.y*h*x,p=d.map(g=>{if(g.positionAbsolute){const y={x:g.positionAbsolute.x+_,y:g.positionAbsolute.y+T};l&&(y.x=a[0]*Math.round(y.x/a[0]),y.y=a[1]*Math.round(y.y/a[1]));const{positionAbsolute:w,position:P}=n0(g,y,r,s,void 0,u);g.position=P,g.positionAbsolute=w}return g});o(p,!0,!1)},[])}const es={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var bs=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:i,xPosOrigin:l,yPosOrigin:a,selected:u,onClick:c,onMouseEnter:d,onMouseMove:f,onMouseLeave:h,onContextMenu:x,onDoubleClick:_,style:T,className:p,isDraggable:g,isSelectable:y,isConnectable:w,isFocusable:P,selectNodesOnDrag:O,sourcePosition:L,targetPosition:R,hidden:F,resizeObserver:D,dragHandle:H,zIndex:Z,isParent:U,noDragClassName:v,noPanClassName:k,initialized:N,disableKeyboardA11y:M,ariaLabel:C,rfId:S,hasHandleBounds:b})=>{const B=Ve(),j=E.useRef(null),Y=E.useRef(null),Q=E.useRef(L),ne=E.useRef(R),se=E.useRef(r),fe=y||g||c||d||f||h,W=s0(),A=Is(n,B.getState,d),I=Is(n,B.getState,f),G=Is(n,B.getState,h),X=Is(n,B.getState,x),ie=Is(n,B.getState,_),le=oe=>{const{nodeDragThreshold:K}=B.getState();if(y&&(!O||!g||K>0)&&Du({id:n,store:B,nodeRef:j}),c){const z=B.getState().nodeInternals.get(n);z&&c(oe,{...z})}},ce=oe=>{if(!$u(oe)&&!M)if(bg.includes(oe.key)&&y){const K=oe.key==="Escape";Du({id:n,store:B,unselect:K,nodeRef:j})}else g&&u&&Object.prototype.hasOwnProperty.call(es,oe.key)&&(B.setState({ariaLiveMessage:`Moved selected node ${oe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),W({x:es[oe.key].x,y:es[oe.key].y,isShiftPressed:oe.shiftKey}))};E.useEffect(()=>()=>{Y.current&&(D==null||D.unobserve(Y.current),Y.current=null)},[]),E.useEffect(()=>{if(j.current&&!F){const oe=j.current;(!N||!b||Y.current!==oe)&&(Y.current&&(D==null||D.unobserve(Y.current)),D==null||D.observe(oe),Y.current=oe)}},[F,N,b]),E.useEffect(()=>{const oe=se.current!==r,K=Q.current!==L,z=ne.current!==R;j.current&&(oe||K||z)&&(oe&&(se.current=r),K&&(Q.current=L),z&&(ne.current=R),B.getState().updateNodeDimensions([{id:n,nodeElement:j.current,forceUpdate:!0}]))},[n,r,L,R]);const he=r0({nodeRef:j,disabled:F||!g,noDragClassName:v,handleSelector:H,nodeId:n,isSelectable:y,selectNodesOnDrag:O});return F?null:V.createElement("div",{className:qe(["react-flow__node",`react-flow__node-${r}`,{[k]:g},p,{selected:u,selectable:y,parent:U,dragging:he}]),ref:j,style:{zIndex:Z,transform:`translate(${l}px,${a}px)`,pointerEvents:fe?"all":"none",visibility:N?"visible":"hidden",...T},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:A,onMouseMove:I,onMouseLeave:G,onContextMenu:X,onClick:le,onDoubleClick:ie,onKeyDown:P?ce:void 0,tabIndex:P?0:void 0,role:P?"button":void 0,"aria-describedby":M?void 0:`${Xg}-${S}`,"aria-label":C},V.createElement(EE,{value:n},V.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:i,selected:u,isConnectable:w,sourcePosition:L,targetPosition:R,dragging:he,dragHandle:H,zIndex:Z})))};return t.displayName="NodeWrapper",E.memo(t)};const dN=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Ll(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function fN({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ve(),{width:s,height:o,x:i,y:l,transformString:a,userSelectionActive:u}=Ce(dN,Ke),c=s0(),d=E.useRef(null);if(E.useEffect(()=>{var x;n||(x=d.current)==null||x.focus({preventScroll:!0})},[n]),r0({nodeRef:d}),u||!s||!o)return null;const f=e?x=>{const _=r.getState().getNodes().filter(T=>T.selected);e(x,_)}:void 0,h=x=>{Object.prototype.hasOwnProperty.call(es,x.key)&&c({x:es[x.key].x,y:es[x.key].y,isShiftPressed:x.shiftKey})};return V.createElement("div",{className:qe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a}},V.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:s,height:o,top:l,left:i}}))}var pN=E.memo(fN);const hN=e=>e.nodesSelectionActive,o0=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:l,onMove:a,onMoveStart:u,onMoveEnd:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:h,onSelectionStart:x,onSelectionEnd:_,multiSelectionKeyCode:T,panActivationKeyCode:p,zoomActivationKeyCode:g,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:P,panOnScroll:O,panOnScrollSpeed:L,panOnScrollMode:R,zoomOnDoubleClick:F,panOnDrag:D,defaultViewport:H,translateExtent:Z,minZoom:U,maxZoom:v,preventScrolling:k,onSelectionContextMenu:N,noWheelClassName:M,noPanClassName:C,disableKeyboardA11y:S})=>{const b=Ce(hN),B=No(d),j=No(p),Y=j||D,Q=j||O,ne=B||f&&Y!==!0;return qE({deleteKeyCode:l,multiSelectionKeyCode:T}),V.createElement(nN,{onMove:a,onMoveStart:u,onMoveEnd:c,onPaneContextMenu:o,elementsSelectable:y,zoomOnScroll:w,zoomOnPinch:P,panOnScroll:Q,panOnScrollSpeed:L,panOnScrollMode:R,zoomOnDoubleClick:F,panOnDrag:!B&&Y,defaultViewport:H,translateExtent:Z,minZoom:U,maxZoom:v,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:M,noPanClassName:C},V.createElement(e0,{onSelectionStart:x,onSelectionEnd:_,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Y,isSelecting:!!ne,selectionMode:h},e,b&&V.createElement(pN,{onSelectionContextMenu:N,noPanClassName:C,disableKeyboardA11y:S})))};o0.displayName="FlowRenderer";var mN=E.memo(o0);function gN(e){return Ce(E.useCallback(n=>e?$g(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function yN(e){const t={input:bs(e.input||Vg),default:bs(e.default||zu),output:bs(e.output||Yg),group:bs(e.group||td)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=bs(e[o]||zu),s),n);return{...t,...r}}const vN=({x:e,y:t,width:n,height:r,origin:s})=>!n||!r?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-r*s[1]},_N=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),i0=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:i}=Ce(_N,Ke),l=gN(e.onlyRenderVisibleElements),a=E.useRef(),u=E.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const c=new ResizeObserver(d=>{const f=d.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));o(f)});return a.current=c,c},[]);return E.useEffect(()=>()=>{var c;(c=a==null?void 0:a.current)==null||c.disconnect()},[]),V.createElement("div",{className:"react-flow__nodes",style:rd},l.map(c=>{var P,O,L;let d=c.type||"default";e.nodeTypes[d]||(i==null||i("003",vn.error003(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,h=!!(c.draggable||t&&typeof c.draggable>"u"),x=!!(c.selectable||s&&typeof c.selectable>"u"),_=!!(c.connectable||n&&typeof c.connectable>"u"),T=!!(c.focusable||r&&typeof c.focusable>"u"),p=e.nodeExtent?Xc(c.positionAbsolute,e.nodeExtent):c.positionAbsolute,g=(p==null?void 0:p.x)??0,y=(p==null?void 0:p.y)??0,w=vN({x:g,y,width:c.width??0,height:c.height??0,origin:e.nodeOrigin});return V.createElement(f,{key:c.id,id:c.id,className:c.className,style:c.style,type:d,data:c.data,sourcePosition:c.sourcePosition||re.Bottom,targetPosition:c.targetPosition||re.Top,hidden:c.hidden,xPos:g,yPos:y,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!c.selected,isDraggable:h,isSelectable:x,isConnectable:_,isFocusable:T,resizeObserver:u,dragHandle:c.dragHandle,zIndex:((P=c[Be])==null?void 0:P.z)??0,isParent:!!((O=c[Be])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!c.width&&!!c.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:c.ariaLabel,hasHandleBounds:!!((L=c[Be])!=null&&L.handleBounds)})}))};i0.displayName="NodeRenderer";var xN=E.memo(i0);const wN=(e,t,n)=>n===re.Left?e-t:n===re.Right?e+t:e,SN=(e,t,n)=>n===re.Top?e-t:n===re.Bottom?e+t:e,up="react-flow__edgeupdater",cp=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:l})=>V.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:qe([up,`${up}-${l}`]),cx:wN(t,r,e),cy:SN(n,r,e),r,stroke:"transparent",fill:"transparent"}),EN=()=>!0;var Cr=e=>{const t=({id:n,className:r,type:s,data:o,onClick:i,onEdgeDoubleClick:l,selected:a,animated:u,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:x,labelBgBorderRadius:_,style:T,source:p,target:g,sourceX:y,sourceY:w,targetX:P,targetY:O,sourcePosition:L,targetPosition:R,elementsSelectable:F,hidden:D,sourceHandleId:H,targetHandleId:Z,onContextMenu:U,onMouseEnter:v,onMouseMove:k,onMouseLeave:N,reconnectRadius:M,onReconnect:C,onReconnectStart:S,onReconnectEnd:b,markerEnd:B,markerStart:j,rfId:Y,ariaLabel:Q,isFocusable:ne,isReconnectable:se,pathOptions:fe,interactionWidth:W,disableKeyboardA11y:A})=>{const I=E.useRef(null),[G,X]=E.useState(!1),[ie,le]=E.useState(!1),ce=Ve(),he=E.useMemo(()=>`url('#${ju(j,Y)}')`,[j,Y]),oe=E.useMemo(()=>`url('#${ju(B,Y)}')`,[B,Y]);if(D)return null;const K=ye=>{var Vt;const{edges:Ae,addSelectedEdges:xe,unselectNodesAndEdges:ut,multiSelectionActive:je}=ce.getState(),nn=Ae.find(ms=>ms.id===n);nn&&(F&&(ce.setState({nodesSelectionActive:!1}),nn.selected&&je?(ut({nodes:[],edges:[nn]}),(Vt=I.current)==null||Vt.blur()):xe([n])),i&&i(ye,nn))},z=Cs(n,ce.getState,l),ee=Cs(n,ce.getState,U),$=Cs(n,ce.getState,v),q=Cs(n,ce.getState,k),te=Cs(n,ce.getState,N),ae=(ye,Ae)=>{if(ye.button!==0)return;const{edges:xe,isValidConnection:ut}=ce.getState(),je=Ae?g:p,nn=(Ae?Z:H)||null,Vt=Ae?"target":"source",ms=ut||EN,Bl=Ae,gs=xe.find(Yn=>Yn.id===n);le(!0),S==null||S(ye,gs,Vt);const jl=Yn=>{le(!1),b==null||b(Yn,gs,Vt)};Dg({event:ye,handleId:nn,nodeId:je,onConnect:Yn=>C==null?void 0:C(gs,Yn),isTarget:Bl,getState:ce.getState,setState:ce.setState,isValidConnection:ms,edgeUpdaterType:Vt,onReconnectEnd:jl})},pe=ye=>ae(ye,!0),we=ye=>ae(ye,!1),de=()=>X(!0),me=()=>X(!1),ge=!F&&!i,Ee=ye=>{var Ae;if(!A&&bg.includes(ye.key)&&F){const{unselectNodesAndEdges:xe,addSelectedEdges:ut,edges:je}=ce.getState();ye.key==="Escape"?((Ae=I.current)==null||Ae.blur(),xe({edges:[je.find(Vt=>Vt.id===n)]})):ut([n])}};return V.createElement("g",{className:qe(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:a,animated:u,inactive:ge,updating:G}]),onClick:K,onDoubleClick:z,onContextMenu:ee,onMouseEnter:$,onMouseMove:q,onMouseLeave:te,onKeyDown:ne?Ee:void 0,tabIndex:ne?0:void 0,role:ne?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":Q===null?void 0:Q||`Edge from ${p} to ${g}`,"aria-describedby":ne?`${Qg}-${Y}`:void 0,ref:I},!ie&&V.createElement(e,{id:n,source:p,target:g,selected:a,animated:u,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:x,labelBgBorderRadius:_,data:o,style:T,sourceX:y,sourceY:w,targetX:P,targetY:O,sourcePosition:L,targetPosition:R,sourceHandleId:H,targetHandleId:Z,markerStart:he,markerEnd:oe,pathOptions:fe,interactionWidth:W}),se&&V.createElement(V.Fragment,null,(se==="source"||se===!0)&&V.createElement(cp,{position:L,centerX:y,centerY:w,radius:M,onMouseDown:pe,onMouseEnter:de,onMouseOut:me,type:"source"}),(se==="target"||se===!0)&&V.createElement(cp,{position:R,centerX:P,centerY:O,radius:M,onMouseDown:we,onMouseEnter:de,onMouseOut:me,type:"target"})))};return t.displayName="EdgeWrapper",E.memo(t)};function NN(e){const t={default:Cr(e.default||cl),straight:Cr(e.bezier||qc),step:Cr(e.step||Zc),smoothstep:Cr(e.step||Ol),simplebezier:Cr(e.simplebezier||Qc)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Cr(e[o]||cl),s),n);return{...t,...r}}function dp(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case re.Top:return{x:r+o/2,y:s};case re.Right:return{x:r+o,y:s+i/2};case re.Bottom:return{x:r+o/2,y:s+i};case re.Left:return{x:r,y:s+i/2}}}function fp(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const TN=(e,t,n,r,s,o)=>{const i=dp(n,e,t),l=dp(o,r,s);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function kN({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:i,height:l,transform:a}){const u={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+o)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);const c=So({x:(0-a[0])/a[2],y:(0-a[1])/a[2],width:i/a[2],height:l/a[2]}),d=Math.max(0,Math.min(c.x2,u.x2)-Math.max(c.x,u.x)),f=Math.max(0,Math.min(c.y2,u.y2)-Math.max(c.y,u.y));return Math.ceil(d*f)>0}function pp(e){var r,s,o,i,l;const t=((r=e==null?void 0:e[Be])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const CN=[{level:0,isMaxLevel:!0,edges:[]}];function IN(e,t,n=!1){let r=-1;const s=e.reduce((i,l)=>{var c,d;const a=It(l.zIndex);let u=a?l.zIndex:0;if(n){const f=t.get(l.target),h=t.get(l.source),x=l.selected||(f==null?void 0:f.selected)||(h==null?void 0:h.selected),_=Math.max(((c=h==null?void 0:h[Be])==null?void 0:c.z)||0,((d=f==null?void 0:f[Be])==null?void 0:d.z)||0,1e3);u=(a?l.zIndex:0)+(x?_:0)}return i[u]?i[u].push(l):i[u]=[l],r=u>r?u:r,i},{}),o=Object.entries(s).map(([i,l])=>{const a=+i;return{edges:l,level:a,isMaxLevel:a===r}});return o.length===0?CN:o}function bN(e,t,n){const r=Ce(E.useCallback(s=>e?s.edges.filter(o=>{const i=t.get(o.source),l=t.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&kN({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:l.width,targetHeight:l.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return IN(r,t,n)}const PN=({color:e="none",strokeWidth:t=1})=>V.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),AN=({color:e="none",strokeWidth:t=1})=>V.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),hp={[xr.Arrow]:PN,[xr.ArrowClosed]:AN};function RN(e){const t=Ve();return E.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(hp,e)?hp[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",vn.error009(e)),null)},[e])}const MN=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const a=RN(t);return a?V.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0"},V.createElement(a,{color:n,strokeWidth:i})):null},ON=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const l=ju(i,t);r.includes(l)||(s.push({id:l,color:i.color||e,...i}),r.push(l))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},l0=({defaultColor:e,rfId:t})=>{const n=Ce(E.useCallback(ON({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,i)=>o.id!==s[i].id)));return V.createElement("defs",null,n.map(r=>V.createElement(MN,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};l0.displayName="MarkerDefinitions";var LN=E.memo(l0);const $N=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),a0=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:a,onEdgeMouseLeave:u,onEdgeClick:c,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:x,reconnectRadius:_,children:T,disableKeyboardA11y:p})=>{const{edgesFocusable:g,edgesUpdatable:y,elementsSelectable:w,width:P,height:O,connectionMode:L,nodeInternals:R,onError:F}=Ce($N,Ke),D=bN(t,R,n);return P?V.createElement(V.Fragment,null,D.map(({level:H,edges:Z,isMaxLevel:U})=>V.createElement("svg",{key:H,style:{zIndex:H},width:P,height:O,className:"react-flow__edges react-flow__container"},U&&V.createElement(LN,{defaultColor:e,rfId:r}),V.createElement("g",null,Z.map(v=>{const[k,N,M]=pp(R.get(v.source)),[C,S,b]=pp(R.get(v.target));if(!M||!b)return null;let B=v.type||"default";s[B]||(F==null||F("011",vn.error011(B)),B="default");const j=s[B]||s.default,Y=L===_r.Strict?S.target:(S.target??[]).concat(S.source??[]),Q=fp(N.source,v.sourceHandle),ne=fp(Y,v.targetHandle),se=(Q==null?void 0:Q.position)||re.Bottom,fe=(ne==null?void 0:ne.position)||re.Top,W=!!(v.focusable||g&&typeof v.focusable>"u"),A=v.reconnectable||v.updatable,I=typeof f<"u"&&(A||y&&typeof A>"u");if(!Q||!ne)return F==null||F("008",vn.error008(Q,v)),null;const{sourceX:G,sourceY:X,targetX:ie,targetY:le}=TN(k,Q,se,C,ne,fe);return V.createElement(j,{key:v.id,id:v.id,className:qe([v.className,o]),type:B,data:v.data,selected:!!v.selected,animated:!!v.animated,hidden:!!v.hidden,label:v.label,labelStyle:v.labelStyle,labelShowBg:v.labelShowBg,labelBgStyle:v.labelBgStyle,labelBgPadding:v.labelBgPadding,labelBgBorderRadius:v.labelBgBorderRadius,style:v.style,source:v.source,target:v.target,sourceHandleId:v.sourceHandle,targetHandleId:v.targetHandle,markerEnd:v.markerEnd,markerStart:v.markerStart,sourceX:G,sourceY:X,targetX:ie,targetY:le,sourcePosition:se,targetPosition:fe,elementsSelectable:w,onContextMenu:i,onMouseEnter:l,onMouseMove:a,onMouseLeave:u,onClick:c,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:x,reconnectRadius:_,rfId:r,ariaLabel:v.ariaLabel,isFocusable:W,isReconnectable:I,pathOptions:"pathOptions"in v?v.pathOptions:void 0,interactionWidth:v.interactionWidth,disableKeyboardA11y:p})})))),T):null};a0.displayName="EdgeRenderer";var BN=E.memo(a0);const jN=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function FN({children:e}){const t=Ce(jN);return V.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function zN(e){const t=nd(),n=E.useRef(!1);E.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const DN={[re.Left]:re.Right,[re.Right]:re.Left,[re.Top]:re.Bottom,[re.Bottom]:re.Top},u0=({nodeId:e,handleType:t,style:n,type:r=Pn.Bezier,CustomComponent:s,connectionStatus:o})=>{var O,L,R;const{fromNode:i,handleId:l,toX:a,toY:u,connectionMode:c}=Ce(E.useCallback(F=>({fromNode:F.nodeInternals.get(e),handleId:F.connectionHandleId,toX:(F.connectionPosition.x-F.transform[0])/F.transform[2],toY:(F.connectionPosition.y-F.transform[1])/F.transform[2],connectionMode:F.connectionMode}),[e]),Ke),d=(O=i==null?void 0:i[Be])==null?void 0:O.handleBounds;let f=d==null?void 0:d[t];if(c===_r.Loose&&(f=f||(d==null?void 0:d[t==="source"?"target":"source"])),!i||!f)return null;const h=l?f.find(F=>F.id===l):f[0],x=h?h.x+h.width/2:(i.width??0)/2,_=h?h.y+h.height/2:i.height??0,T=(((L=i.positionAbsolute)==null?void 0:L.x)??0)+x,p=(((R=i.positionAbsolute)==null?void 0:R.y)??0)+_,g=h==null?void 0:h.position,y=g?DN[g]:null;if(!g||!y)return null;if(s)return V.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:h,fromX:T,fromY:p,toX:a,toY:u,fromPosition:g,toPosition:y,connectionStatus:o});let w="";const P={sourceX:T,sourceY:p,sourcePosition:g,targetX:a,targetY:u,targetPosition:y};return r===Pn.Bezier?[w]=Og(P):r===Pn.Step?[w]=Bu({...P,borderRadius:0}):r===Pn.SmoothStep?[w]=Bu(P):r===Pn.SimpleBezier?[w]=Mg(P):w=`M${T},${p} ${a},${u}`,V.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};u0.displayName="ConnectionLine";const UN=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function HN({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:i,width:l,height:a,connectionStatus:u}=Ce(UN,Ke);return!(s&&o&&l&&i)?null:V.createElement("svg",{style:e,width:l,height:a,className:"react-flow__edges react-flow__connectionline react-flow__container"},V.createElement("g",{className:qe(["react-flow__connection",u])},V.createElement(u0,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:u})))}function mp(e,t){return E.useRef(null),Ve(),E.useMemo(()=>t(e),[e])}const c0=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:a,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:x,onSelectionStart:_,onSelectionEnd:T,connectionLineType:p,connectionLineStyle:g,connectionLineComponent:y,connectionLineContainerStyle:w,selectionKeyCode:P,selectionOnDrag:O,selectionMode:L,multiSelectionKeyCode:R,panActivationKeyCode:F,zoomActivationKeyCode:D,deleteKeyCode:H,onlyRenderVisibleElements:Z,elementsSelectable:U,selectNodesOnDrag:v,defaultViewport:k,translateExtent:N,minZoom:M,maxZoom:C,preventScrolling:S,defaultMarkerColor:b,zoomOnScroll:B,zoomOnPinch:j,panOnScroll:Y,panOnScrollSpeed:Q,panOnScrollMode:ne,zoomOnDoubleClick:se,panOnDrag:fe,onPaneClick:W,onPaneMouseEnter:A,onPaneMouseMove:I,onPaneMouseLeave:G,onPaneScroll:X,onPaneContextMenu:ie,onEdgeContextMenu:le,onEdgeMouseEnter:ce,onEdgeMouseMove:he,onEdgeMouseLeave:oe,onReconnect:K,onReconnectStart:z,onReconnectEnd:ee,reconnectRadius:$,noDragClassName:q,noWheelClassName:te,noPanClassName:ae,elevateEdgesOnSelect:pe,disableKeyboardA11y:we,nodeOrigin:de,nodeExtent:me,rfId:ge})=>{const Ee=mp(e,yN),ye=mp(t,NN);return zN(o),V.createElement(mN,{onPaneClick:W,onPaneMouseEnter:A,onPaneMouseMove:I,onPaneMouseLeave:G,onPaneContextMenu:ie,onPaneScroll:X,deleteKeyCode:H,selectionKeyCode:P,selectionOnDrag:O,selectionMode:L,onSelectionStart:_,onSelectionEnd:T,multiSelectionKeyCode:R,panActivationKeyCode:F,zoomActivationKeyCode:D,elementsSelectable:U,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:B,zoomOnPinch:j,zoomOnDoubleClick:se,panOnScroll:Y,panOnScrollSpeed:Q,panOnScrollMode:ne,panOnDrag:fe,defaultViewport:k,translateExtent:N,minZoom:M,maxZoom:C,onSelectionContextMenu:x,preventScrolling:S,noDragClassName:q,noWheelClassName:te,noPanClassName:ae,disableKeyboardA11y:we},V.createElement(FN,null,V.createElement(BN,{edgeTypes:ye,onEdgeClick:l,onEdgeDoubleClick:u,onlyRenderVisibleElements:Z,onEdgeContextMenu:le,onEdgeMouseEnter:ce,onEdgeMouseMove:he,onEdgeMouseLeave:oe,onReconnect:K,onReconnectStart:z,onReconnectEnd:ee,reconnectRadius:$,defaultMarkerColor:b,noPanClassName:ae,elevateEdgesOnSelect:!!pe,disableKeyboardA11y:we,rfId:ge},V.createElement(HN,{style:g,type:p,component:y,containerStyle:w})),V.createElement("div",{className:"react-flow__edgelabel-renderer"}),V.createElement(xN,{nodeTypes:Ee,onNodeClick:i,onNodeDoubleClick:a,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,selectNodesOnDrag:v,onlyRenderVisibleElements:Z,noPanClassName:ae,noDragClassName:q,disableKeyboardA11y:we,nodeOrigin:de,nodeExtent:me,rfId:ge})))};c0.displayName="GraphView";var WN=E.memo(c0);const Uu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],wn={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Uu,nodeExtent:Uu,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:_r.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:yE,isValidConnection:void 0},VN=()=>R1((e,t)=>({...wn,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:_a(n,r,s,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",i=s?_a(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:l,domNode:a,nodeOrigin:u}=t(),c=a==null?void 0:a.querySelector(".react-flow__viewport");if(!c)return;const d=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(d.transform),h=n.reduce((_,T)=>{const p=s.get(T.id);if(p!=null&&p.hidden)s.set(p.id,{...p,[Be]:{...p[Be],handleBounds:void 0}});else if(p){const g=Kc(T.nodeElement);!!(g.width&&g.height&&(p.width!==g.width||p.height!==g.height||T.forceUpdate))&&(s.set(p.id,{...p,[Be]:{...p[Be],handleBounds:{source:ap(".source",T.nodeElement,f,u),target:ap(".target",T.nodeElement,f,u)}},...g}),_.push({id:p.id,type:"dimensions",dimensions:g}))}return _},[]);qg(s,u);const x=i||o&&!i&&Jg(t,{initial:!0,...l});e({nodeInternals:new Map(s),fitViewOnInitDone:x}),(h==null?void 0:h.length)>0&&(r==null||r(h))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(l=>{const a={id:l.id,type:"position",dragging:s};return r&&(a.positionAbsolute=l.positionAbsolute,a.position=l.position),a});o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:i,getNodes:l,elevateNodesOnSelect:a}=t();if(n!=null&&n.length){if(o){const u=iN(n,l()),c=_a(u,s,i,a);e({nodeInternals:c})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let i,l=null;r?i=n.map(a=>Cn(a,!0)):(i=Hr(o(),n),l=Hr(s,[])),si({changedNodes:i,changedEdges:l,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let i,l=null;r?i=n.map(a=>Cn(a,!0)):(i=Hr(s,n),l=Hr(o(),[])),si({changedNodes:l,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),i=n||o(),l=r||s,a=i.map(c=>(c.selected=!1,Cn(c.id,!1))),u=l.map(c=>Cn(c.id,!1));si({changedNodes:a,changedEdges:u,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(l=>l.selected).map(l=>Cn(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Cn(l.id,!1));si({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=Xc(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:i,d3Selection:l,translateExtent:a}=t();if(!i||!l||!n.x&&!n.y)return!1;const u=fn.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),c=[[0,0],[s,o]],d=i==null?void 0:i.constrain()(u,c,a);return i.transform(l,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:wn.connectionNodeId,connectionHandleId:wn.connectionHandleId,connectionHandleType:wn.connectionHandleType,connectionStatus:wn.connectionStatus,connectionStartHandle:wn.connectionStartHandle,connectionEndHandle:wn.connectionEndHandle}),reset:()=>e({...wn})}),Object.is),d0=({children:e})=>{const t=E.useRef(null);return t.current||(t.current=VN()),V.createElement(cE,{value:t.current},e)};d0.displayName="ReactFlowProvider";const f0=({children:e})=>E.useContext(Ml)?V.createElement(V.Fragment,null,e):V.createElement(d0,null,e);f0.displayName="ReactFlowWrapper";const GN={input:Vg,default:zu,output:Yg,group:td},YN={default:cl,straight:qc,step:Zc,smoothstep:Ol,simplebezier:Qc},KN=[0,0],XN=[15,15],QN={x:0,y:0,zoom:1},ZN={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},p0=E.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=GN,edgeTypes:i=YN,onNodeClick:l,onEdgeClick:a,onInit:u,onMove:c,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:x,onConnectEnd:_,onClickConnectStart:T,onClickConnectEnd:p,onNodeMouseEnter:g,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:P,onNodeDoubleClick:O,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:F,onNodesDelete:D,onEdgesDelete:H,onSelectionChange:Z,onSelectionDragStart:U,onSelectionDrag:v,onSelectionDragStop:k,onSelectionContextMenu:N,onSelectionStart:M,onSelectionEnd:C,connectionMode:S=_r.Strict,connectionLineType:b=Pn.Bezier,connectionLineStyle:B,connectionLineComponent:j,connectionLineContainerStyle:Y,deleteKeyCode:Q="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:se=!1,selectionMode:fe=Eo.Full,panActivationKeyCode:W="Space",multiSelectionKeyCode:A=ul()?"Meta":"Control",zoomActivationKeyCode:I=ul()?"Meta":"Control",snapToGrid:G=!1,snapGrid:X=XN,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:le=!0,nodesDraggable:ce,nodesConnectable:he,nodesFocusable:oe,nodeOrigin:K=KN,edgesFocusable:z,edgesUpdatable:ee,elementsSelectable:$,defaultViewport:q=QN,minZoom:te=.5,maxZoom:ae=2,translateExtent:pe=Uu,preventScrolling:we=!0,nodeExtent:de,defaultMarkerColor:me="#b1b1b7",zoomOnScroll:ge=!0,zoomOnPinch:Ee=!0,panOnScroll:ye=!1,panOnScrollSpeed:Ae=.5,panOnScrollMode:xe=lr.Free,zoomOnDoubleClick:ut=!0,panOnDrag:je=!0,onPaneClick:nn,onPaneMouseEnter:Vt,onPaneMouseMove:ms,onPaneMouseLeave:Bl,onPaneScroll:gs,onPaneContextMenu:jl,children:sd,onEdgeContextMenu:Yn,onEdgeDoubleClick:_0,onEdgeMouseEnter:x0,onEdgeMouseMove:w0,onEdgeMouseLeave:S0,onEdgeUpdate:E0,onEdgeUpdateStart:N0,onEdgeUpdateEnd:T0,onReconnect:k0,onReconnectStart:C0,onReconnectEnd:I0,reconnectRadius:b0=10,edgeUpdaterRadius:P0=10,onNodesChange:A0,onEdgesChange:R0,noDragClassName:M0="nodrag",noWheelClassName:O0="nowheel",noPanClassName:od="nopan",fitView:L0=!1,fitViewOptions:$0,connectOnClick:B0=!0,attributionPosition:j0,proOptions:F0,defaultEdgeOptions:z0,elevateNodesOnSelect:D0=!0,elevateEdgesOnSelect:U0=!1,disableKeyboardA11y:id=!1,autoPanOnConnect:H0=!0,autoPanOnNodeDrag:W0=!0,connectionRadius:V0=20,isValidConnection:G0,onError:Y0,style:K0,id:ld,nodeDragThreshold:X0,...Q0},Z0)=>{const Fl=ld||"1";return V.createElement("div",{...Q0,style:{...K0,...ZN},ref:Z0,className:qe(["react-flow",s]),"data-testid":"rf__wrapper",id:ld},V.createElement(f0,null,V.createElement(WN,{onInit:u,onMove:c,onMoveStart:d,onMoveEnd:f,onNodeClick:l,onEdgeClick:a,onNodeMouseEnter:g,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:P,onNodeDoubleClick:O,nodeTypes:o,edgeTypes:i,connectionLineType:b,connectionLineStyle:B,connectionLineComponent:j,connectionLineContainerStyle:Y,selectionKeyCode:ne,selectionOnDrag:se,selectionMode:fe,deleteKeyCode:Q,multiSelectionKeyCode:A,panActivationKeyCode:W,zoomActivationKeyCode:I,onlyRenderVisibleElements:ie,selectNodesOnDrag:le,defaultViewport:q,translateExtent:pe,minZoom:te,maxZoom:ae,preventScrolling:we,zoomOnScroll:ge,zoomOnPinch:Ee,zoomOnDoubleClick:ut,panOnScroll:ye,panOnScrollSpeed:Ae,panOnScrollMode:xe,panOnDrag:je,onPaneClick:nn,onPaneMouseEnter:Vt,onPaneMouseMove:ms,onPaneMouseLeave:Bl,onPaneScroll:gs,onPaneContextMenu:jl,onSelectionContextMenu:N,onSelectionStart:M,onSelectionEnd:C,onEdgeContextMenu:Yn,onEdgeDoubleClick:_0,onEdgeMouseEnter:x0,onEdgeMouseMove:w0,onEdgeMouseLeave:S0,onReconnect:k0??E0,onReconnectStart:C0??N0,onReconnectEnd:I0??T0,reconnectRadius:b0??P0,defaultMarkerColor:me,noDragClassName:M0,noWheelClassName:O0,noPanClassName:od,elevateEdgesOnSelect:U0,rfId:Fl,disableKeyboardA11y:id,nodeOrigin:K,nodeExtent:de}),V.createElement(zE,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:x,onConnectEnd:_,onClickConnectStart:T,onClickConnectEnd:p,nodesDraggable:ce,nodesConnectable:he,nodesFocusable:oe,edgesFocusable:z,edgesUpdatable:ee,elementsSelectable:$,elevateNodesOnSelect:D0,minZoom:te,maxZoom:ae,nodeExtent:de,onNodesChange:A0,onEdgesChange:R0,snapToGrid:G,snapGrid:X,connectionMode:S,translateExtent:pe,connectOnClick:B0,defaultEdgeOptions:z0,fitView:L0,fitViewOptions:$0,onNodesDelete:D,onEdgesDelete:H,onNodeDragStart:L,onNodeDrag:R,onNodeDragStop:F,onSelectionDrag:v,onSelectionDragStart:U,onSelectionDragStop:k,noPanClassName:od,nodeOrigin:K,rfId:Fl,autoPanOnConnect:H0,autoPanOnNodeDrag:W0,onError:Y0,connectionRadius:V0,isValidConnection:G0,nodeDragThreshold:X0}),V.createElement(jE,{onSelectionChange:Z}),sd,V.createElement(fE,{proOptions:F0,position:j0}),V.createElement(VE,{rfId:Fl,disableKeyboardA11y:id})))});p0.displayName="ReactFlow";const h0=({id:e,x:t,y:n,width:r,height:s,style:o,color:i,strokeColor:l,strokeWidth:a,className:u,borderRadius:c,shapeRendering:d,onClick:f,selected:h})=>{const{background:x,backgroundColor:_}=o||{},T=i||x||_;return V.createElement("rect",{className:qe(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:c,ry:c,width:r,height:s,fill:T,stroke:l,strokeWidth:a,shapeRendering:d,onClick:f?p=>f(p,e):void 0})};h0.displayName="MiniMapNode";var qN=E.memo(h0);const JN=e=>e.nodeOrigin,eT=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Ea=e=>e instanceof Function?e:()=>e;function tT({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=qN,onClick:i}){const l=Ce(eT,Ke),a=Ce(JN),u=Ea(t),c=Ea(e),d=Ea(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return V.createElement(V.Fragment,null,l.map(h=>{const{x,y:_}=dr(h,a).positionAbsolute;return V.createElement(o,{key:h.id,x,y:_,width:h.width,height:h.height,style:h.style,selected:h.selected,className:d(h),color:u(h),borderRadius:r,strokeColor:c(h),strokeWidth:s,shapeRendering:f,onClick:i,id:h.id})}))}var nT=E.memo(tT);const rT=200,sT=150,oT=e=>{const t=e.getNodes(),n={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:n,boundingRect:t.length>0?mE(Ll(t,e.nodeOrigin),n):n,rfId:e.rfId}},iT="react-flow__minimap-desc";function m0({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:l,maskColor:a="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:c=1,position:d="bottom-right",onClick:f,onNodeClick:h,pannable:x=!1,zoomable:_=!1,ariaLabel:T="React Flow mini map",inversePan:p=!1,zoomStep:g=10,offsetScale:y=5}){const w=Ve(),P=E.useRef(null),{boundingRect:O,viewBB:L,rfId:R}=Ce(oT,Ke),F=(e==null?void 0:e.width)??rT,D=(e==null?void 0:e.height)??sT,H=O.width/F,Z=O.height/D,U=Math.max(H,Z),v=U*F,k=U*D,N=y*U,M=O.x-(v-O.width)/2-N,C=O.y-(k-O.height)/2-N,S=v+N*2,b=k+N*2,B=`${iT}-${R}`,j=E.useRef(0);j.current=U,E.useEffect(()=>{if(P.current){const ne=kt(P.current),se=A=>{const{transform:I,d3Selection:G,d3Zoom:X}=w.getState();if(A.sourceEvent.type!=="wheel"||!G||!X)return;const ie=-A.sourceEvent.deltaY*(A.sourceEvent.deltaMode===1?.05:A.sourceEvent.deltaMode?1:.002)*g,le=I[2]*Math.pow(2,ie);X.scaleTo(G,le)},fe=A=>{const{transform:I,d3Selection:G,d3Zoom:X,translateExtent:ie,width:le,height:ce}=w.getState();if(A.sourceEvent.type!=="mousemove"||!G||!X)return;const he=j.current*Math.max(1,I[2])*(p?-1:1),oe={x:I[0]-A.sourceEvent.movementX*he,y:I[1]-A.sourceEvent.movementY*he},K=[[0,0],[le,ce]],z=fn.translate(oe.x,oe.y).scale(I[2]),ee=X.constrain()(z,K,ie);X.transform(G,ee)},W=Eg().on("zoom",x?fe:null).on("zoom.wheel",_?se:null);return ne.call(W),()=>{ne.on("zoom",null)}}},[x,_,p,g]);const Y=f?ne=>{const se=$t(ne);f(ne,{x:se[0],y:se[1]})}:void 0,Q=h?(ne,se)=>{const fe=w.getState().nodeInternals.get(se);h(ne,fe)}:void 0;return V.createElement(Yc,{position:d,style:e,className:qe(["react-flow__minimap",t]),"data-testid":"rf__minimap"},V.createElement("svg",{width:F,height:D,viewBox:`${M} ${C} ${S} ${b}`,role:"img","aria-labelledby":B,ref:P,onClick:Y},T&&V.createElement("title",{id:B},T),V.createElement(nT,{onClick:Q,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:l}),V.createElement("path",{className:"react-flow__minimap-mask",d:`M${M-N},${C-N}h${S+N*2}v${b+N*2}h${-S-N*2}z - M${L.x},${L.y}h${L.width}v${L.height}h${-L.width}z`,fill:a,fillRule:"evenodd",stroke:u,strokeWidth:c,pointerEvents:"none"})))}m0.displayName="MiniMap";var lT=E.memo(m0);function aT(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},V.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function uT(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},V.createElement("path",{d:"M0 0h32v4.2H0z"}))}function cT(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},V.createElement("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 dT(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},V.createElement("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 fT(){return V.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},V.createElement("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"}))}const Wr=({children:e,className:t,...n})=>V.createElement("button",{type:"button",className:qe(["react-flow__controls-button",t]),...n},e);Wr.displayName="ControlButton";const pT=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),g0=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:i,onFitView:l,onInteractiveChange:a,className:u,children:c,position:d="bottom-left"})=>{const f=Ve(),[h,x]=E.useState(!1),{isInteractive:_,minZoomReached:T,maxZoomReached:p}=Ce(pT,Ke),{zoomIn:g,zoomOut:y,fitView:w}=nd();if(E.useEffect(()=>{x(!0)},[]),!h)return null;const P=()=>{g(),o==null||o()},O=()=>{y(),i==null||i()},L=()=>{w(s),l==null||l()},R=()=>{f.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),a==null||a(!_)};return V.createElement(Yc,{className:qe(["react-flow__controls",u]),position:d,style:e,"data-testid":"rf__controls"},t&&V.createElement(V.Fragment,null,V.createElement(Wr,{onClick:P,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:p},V.createElement(aT,null)),V.createElement(Wr,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:T},V.createElement(uT,null))),n&&V.createElement(Wr,{className:"react-flow__controls-fitview",onClick:L,title:"fit view","aria-label":"fit view"},V.createElement(cT,null)),r&&V.createElement(Wr,{className:"react-flow__controls-interactive",onClick:R,title:"toggle interactivity","aria-label":"toggle interactivity"},_?V.createElement(fT,null):V.createElement(dT,null)),c)};g0.displayName="Controls";var hT=E.memo(g0),Ut;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ut||(Ut={}));function mT({color:e,dimensions:t,lineWidth:n}){return V.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function gT({color:e,radius:t}){return V.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const yT={[Ut.Dots]:"#91919a",[Ut.Lines]:"#eee",[Ut.Cross]:"#e2e2e2"},vT={[Ut.Dots]:1,[Ut.Lines]:1,[Ut.Cross]:6},_T=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function y0({id:e,variant:t=Ut.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:i,style:l,className:a}){const u=E.useRef(null),{transform:c,patternId:d}=Ce(_T,Ke),f=i||yT[t],h=r||vT[t],x=t===Ut.Dots,_=t===Ut.Cross,T=Array.isArray(n)?n:[n,n],p=[T[0]*c[2]||1,T[1]*c[2]||1],g=h*c[2],y=_?[g,g]:p,w=x?[g/o,g/o]:[y[0]/o,y[1]/o];return V.createElement("svg",{className:qe(["react-flow__background",a]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},V.createElement("pattern",{id:d+e,x:c[0]%p[0],y:c[1]%p[1],width:p[0],height:p[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},x?V.createElement(gT,{color:f,radius:g/o}):V.createElement(mT,{dimensions:y,color:f,lineWidth:s})),V.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}y0.displayName="Background";var xT=E.memo(y0);function Sn(e){return typeof e=="object"&&e!==null}function wT(e){if("leaky"in e||"max_queue"in e)return"input";if("num_buffers"in e||"buf_size"in e||"force_tcp"in e||"host"in e||"port"in e)return"output";const r=typeof e.name=="string"?e.name.toUpperCase():"",s=typeof e.address=="string"?e.address.toUpperCase():"";return r.includes("INPUT")||s.includes("/INPUT")?"input":r.includes("OUTPUT")||s.includes("/OUTPUT")?"output":"unknown"}function Na(e,t=null){if(!e)return[];const n=[];for(const[r,s]of Object.entries(e))!Sn(s)||typeof s.address!="string"||n.push({name:r,address:s.address,direction:wT(s),msgType:typeof s.msg_type=="string"?s.msg_type:null,collectionKind:t});return n.sort((r,s)=>r.address.localeCompare(s.address)),n}function v0(e){const t=new Map;for(const s of Object.values(e.sessions)){const o=Sn(s.metadata)?s.metadata:null,i=o&&Sn(o.components)?o.components:null;if(i)for(const[l,a]of Object.entries(i))!Sn(a)||t.has(l)||t.set(l,a)}const n=new Map,r=new Map;for(const[s,o]of t.entries()){const i=typeof o.name=="string"?o.name:s,l=typeof o.component_type=="string"?o.component_type:"Component",a=Array.isArray(o.children)?o.children.filter(f=>typeof f=="string"):[];if(a.length>0){const f=new Map;for(const h of Na(Sn(o.topics)?o.topics:null,"topic"))f.set(h.address,h);for(const h of Na(Sn(o.relays)?o.relays:null,"relay"))f.set(h.address,h);r.set(s,{address:s,name:i,componentType:l,streams:Array.from(f.values()).sort((h,x)=>h.address.localeCompare(x.address)),children:a})}const u=Sn(o.streams)?o.streams:null;if(!u)continue;const d=(Array.isArray(o.tasks)?o.tasks:[]).filter(Sn).map(f=>{if(typeof f.name!="string")return null;const h=Array.isArray(f.publishes)?f.publishes.filter(x=>typeof x=="string"):[];return{name:f.name,subscribes:typeof f.subscribes=="string"?f.subscribes:null,publishes:h}}).filter(f=>f!==null).sort((f,h)=>f.name.localeCompare(h.name));n.set(s,{address:s,name:i,componentType:l,streams:Na(u),tasks:d})}return{units:n,collections:r}}function ST(e,t){const n=new Map;for(const s of e)n.set(s,0);const r=Math.max(1,e.length);for(let s=0;sa&&(n.set(i.to,u),o=!0)}if(!o)break}return n}function Hu(e,t,n){if(n){const o=t.get(n);return o?o.children.filter(i=>e.has(i)||t.has(i)):[]}const r=new Set;for(const o of t.values())for(const i of o.children)r.add(i);const s=[...Array.from(t.keys()),...Array.from(e.keys())].filter(o=>!r.has(o));return s.length>0?s:Array.from(e.keys())}function $l(e){const t=new Map;for(const[n,r]of e.entries())for(const s of r.children)t.has(s)||t.set(s,n);return t}function ET(e,t){if(!t||!e.has(t))return[];const n=$l(e),r=[],s=new Set;let o=t;for(;o&&!s.has(o);)s.add(o),r.push(o),o=n.get(o);return r.reverse()}function NT(e,t,n){const r=n.get(e);return r?r.children.some(s=>t.has(s)||n.has(s)):!1}function Wu(e,t,n){if(e===t)return!0;const r=new Set;let s=e;for(;s&&!r.has(s);){r.add(s);const o=n.get(s);if(!o)return!1;if(o===t)return!0;s=o}return!1}function TT(e,t,n,r){const s=$l(n),o=new Map,i=(a,u)=>{o.set(a,u),o.set(He(a),u)};for(const a of t.values())for(const u of a.streams)i(u.address,a.address);for(const a of n.values())for(const u of a.streams)i(u.address,a.address);const l=new Set;for(const[a,u]of Object.entries(e.graph)){l.add(a);for(const c of u)l.add(c)}for(const a of l){const u=o.get(a);if(!u||!Wu(u,r,s))return!0}return!1}const Ta=320,ka=120,gp=["#94a3b8","#60a5fa","#22d3ee","#34d399"],kT=["rgba(226, 232, 240, 0.28)","rgba(219, 234, 254, 0.28)","rgba(207, 250, 254, 0.28)","rgba(209, 250, 229, 0.24)"],CT=88,IT=120,bT=72,PT=58,tt=100,Ne=30,tr=96,Ca=22,Ia=6,yp=10,AT=20,vp=240,ii=300,ba=168,Pa=74,_p=58,Ps=48,RT=87,MT=26,OT=30,LT=.36,$T=240,BT=.35,jT=1.8,FT=tt*2+tr+60;function zT(e,t,n){const r=Math.min(176,Math.max(104,e.length*7.4)),s=Math.min(112,Math.max(66,n(t).length*6.1+14));return r+s+RT+MT}function DT(e,t,n){const r=Math.min(220,Math.max(96,e.length*8)),s=Math.min(122,Math.max(66,n(t).length*6.1+14));return r+s+OT}function li(e,t,n,r){return e<=0?r:e*t+Math.max(0,e-1)*n+r}function ai(e,t=40){return e.length<=t?e:`${e.slice(0,Math.max(1,t-1))}…`}function Vu(e){const t=He(e),n=t.split("/");return n.length<=3?t:`${n[n.length-2]}/${n[n.length-1]}`}function As(e){const t=e.split(".");return t[t.length-1]||e}function En(e,t){const n=e.trim().length>0?e.trim():Vu(t),r=n.split("/");return r.length>0?r[r.length-1]??n:n}function ct(e){if(!e)return null;const t=e.replace(/^builtins\./,""),n=t.split("."),r=n.length>0?n[n.length-1]:t;return r.length<=16?r:`${r.slice(0,15)}…`}function Ii(e){const t=e.split("/");return t.length<=2?e:t.slice(Math.max(0,t.length-3)).join("/")}function Aa(e,t,n){return[e,t,n].join(` -`)}function Kn(e,t){const n=[e.address];return e.msgType&&n.push(`Message Type: ${e.msgType}`),t==="collection"&&e.collectionKind==="topic"&&n.push("Collection Topic"),t==="collection"&&e.collectionKind==="relay"&&n.push("Collection Relay"),n.join(` -`)}function Rs(e,t,n){return n==="collection"&&e.collectionKind?"mono topology-stream-label is-collection":`mono topology-stream-label ${t}`}function Ms(e,t,n,r){return n==="collection"&&e.collectionKind?e.collectionKind==="topic"?t==="is-output"?{border:r?"1px solid #fb923c":"1px solid #f28e2b",background:r?"#2e1f10":"#fff1dd",color:r?"#fed7aa":"#8a4f10",borderRadius:999}:t==="is-input"?{border:r?"1px solid #f59e0b":"1px solid #f6a44d",background:r?"#2a2115":"#fff8ef",color:r?"#fdba74":"#8a4f10",borderRadius:999}:{border:r?"1px solid #fb923c":"1px solid #f8b66f",background:r?"#2a2115":"#fff8ef",color:r?"#fdba74":"#8a4f10",borderRadius:10}:t==="is-output"?{border:r?"1px solid #d8b4fe":"1px solid #b07aa1",background:r?"#2a1d3a":"#f8eef5",color:r?"#e9d5ff":"#6f3f66",borderRadius:999}:t==="is-input"?{border:r?"1px solid #c084fc":"1px solid #c194b7",background:r?"#251b33":"#fbf3f8",color:r?"#e9d5ff":"#6f3f66",borderRadius:999}:{border:r?"1px solid #c084fc":"1px solid #d3accb",background:r?"#251b33":"#fbf3f8",color:r?"#e9d5ff":"#6f3f66",borderRadius:10}:{border:t==="is-input"?r?"1px solid #818cf8":"1px solid #c7d2fe":t==="is-output"?r?"1px solid #22d3ee":"1px solid #7dd3fc":r?"1px solid #4b5563":"1px solid #cbd5e1",background:t==="is-input"?r?"#1d2644":"#eef2ff":t==="is-output"?r?"#0f2e37":"#ecfeff":r?"#182235":"#f8fafc",color:r?"#dbeafe":"#1e293b",borderRadius:t==="is-unknown"?8:999}}function Vr(e){return e.trim().toUpperCase().replace(/^INPUT_/,"").replace(/^OUTPUT_/,"").replace(/^TOPIC_/,"")}function UT(e){const t=new Set,n=new Map,r=new Map;for(const s of e){t.add(s.address);const o=He(s.address);n.set(o,s.address),r.set(Vr(s.name),s.address),r.set(Vr(En(s.name,s.address)),s.address),r.set(Vr(o),s.address);const i=o.split("/").pop();i&&r.set(Vr(i),s.address)}return{addressSet:t,withoutEndpointMap:n,normalizedNameMap:r}}function HT(e,t,n,r,s,o,i){const l=s+8,a=s+o,u=Math.max(l,Math.min(i-Ne-10,a-Ne-8)),c=Math.max(l,Math.min(u,Math.floor((i-Ne)/2))),d=e.map(T=>{const p=t.get(T),g=n.get(T);if(!p||!g)return null;const y=p.y-r;return{top:y,bottom:y+g.height}}).filter(T=>T!==null).sort((T,p)=>T.top-p.top);if(d.length===0)return c;let f=c,h=-1,x=l;for(const T of d){const p=T.top-x;p>=Ne+8&&p>h&&(h=p,f=x+Math.floor((p-Ne)/2)),x=Math.max(x,T.bottom)}const _=a-x;return _>=Ne+8&&_>h&&(f=x+Math.floor((_-Ne)/2)),Math.max(l,Math.min(u,f))}function ui(e,t){if(!e)return null;if(t.addressSet.has(e))return e;if(t.withoutEndpointMap.has(e))return t.withoutEndpointMap.get(e)??null;const n=e.split(":")[0];if(t.withoutEndpointMap.has(n))return t.withoutEndpointMap.get(n)??null;const r=Vr(e);if(t.normalizedNameMap.has(r))return t.normalizedNameMap.get(r)??null;const s=Vr(n.split("/").pop()??"");if(t.normalizedNameMap.has(s))return t.normalizedNameMap.get(s)??null;for(const o of t.addressSet)if(o.startsWith(`${e}:`)||o.startsWith(`${n}:`))return o;return null}function WT(e){return typeof e=="object"&&e!==null&&typeof e.x=="number"&&Number.isFinite(e.x)&&typeof e.y=="number"&&Number.isFinite(e.y)}function VT(e){if(!Array.isArray(e.nodes)||!Array.isArray(e.edges))return!1;const t=new Set;for(const n of e.nodes)if(!n||typeof n.id!="string"||n.id.length===0||t.has(n.id)||(t.add(n.id),!WT(n.position)))return!1;for(const n of e.nodes)if(typeof n.parentNode=="string"&&!t.has(n.parentNode))return!1;for(const n of e.edges)if(!n||typeof n.source!="string"||typeof n.target!="string"||!t.has(n.source)||!t.has(n.target))return!1;return!0}function GT(e,t,n,r,s,o){var fe,W;const i=r==="orthogonal"?"step":r==="smooth"?"smoothstep":"default",{units:l,collections:a}=v0(e),u=Hu(l,a,n),c=new Map,d=new Map;for(const A of u){const I=l.get(A);if(I){c.set(A,I);continue}const G=a.get(A);G&&d.set(A,G)}const f=new Set(c.keys()),h=new Set(d.keys()),x=$l(a),_=n?a.get(n)??null:null,T=_?`scope:${_.address}`:null,p=new Map,g=new Map;for(const A of l.values())for(const I of A.streams)p.set(I.address,A.address),p.set(He(I.address),A.address);for(const A of a.values())for(const I of A.streams)g.set(I.address,A.address),g.set(He(I.address),A.address);const y=new Map;for(const A of l.values())for(const I of A.streams)y.set(I.address,I.address),y.set(He(I.address),I.address);for(const A of a.values())for(const I of A.streams)y.set(I.address,I.address),y.set(He(I.address),I.address);const w=[];for(const[A,I]of Object.entries(e.graph))for(const G of I)w.push({from:y.get(A)??A,to:y.get(G)??G});const P=new Map,O=(A,I)=>{P.set(A,I),P.set(He(A),I)};for(const A of c.values())for(const I of A.streams)O(I.address,{ownerId:`unit:${A.address}`,ownerKind:"unit"});for(const A of d.values())for(const I of A.streams)O(I.address,{ownerId:`collection:${A.address}`,ownerKind:"collection"});const L=new Set(P.keys()),R=w.filter(A=>L.has(A.from)||L.has(A.to)),F=new Set(L);for(const A of R)F.add(A.from),F.add(A.to);const D=new Set,H=new Map;for(const A of c.values()){const I=`unit:${A.address}`;D.add(I),H.set(I,A.name)}for(const A of d.values()){const I=`collection:${A.address}`;D.add(I),H.set(I,A.name)}for(const A of F){if(P.has(A))continue;const I=g.get(A),G=p.get(A);if(I&&h.has(I)){O(A,{ownerId:`collection:${I}`,ownerKind:"collection"});continue}if(G&&f.has(G)){O(A,{ownerId:`unit:${G}`,ownerKind:"unit"});continue}if(_&&T&&(I&&Wu(I,_.address,x)||G&&Wu(G,_.address,x))){O(A,{ownerId:T,ownerKind:"scope_collection"});continue}const X=G??I??null;if(X){let le=x.get(X)??null;for(;le;){if(h.has(le)){O(A,{ownerId:`collection:${le}`,ownerKind:"collection_proxy"});break}le=x.get(le)??null}if(P.has(A))continue}const ie=`orphan:${A}`;O(A,{ownerId:ie,ownerKind:"orphan"}),D.add(ie),H.set(ie,Vu(A))}const Z=[],U=new Set;for(const A of R){const I=(fe=P.get(A.from))==null?void 0:fe.ownerId,G=(W=P.get(A.to))==null?void 0:W.ownerId;if(!I||!G||I===G||!D.has(I)||!D.has(G))continue;const X=`${I}->${G}`;U.has(X)||(U.add(X),Z.push({from:I,to:G}))}const v=Array.from(D).sort((A,I)=>{const G=H.get(A)??A,X=H.get(I)??I;return G.localeCompare(X)}),k=ST(v,Z),N=new Map;for(const A of v){const I=k.get(A)??0,G=N.get(I);G?G.push(A):N.set(I,[A])}const M=new Map;for(const A of c.values()){const I=A.streams.filter($=>$.direction==="input").length,G=A.streams.filter($=>$.direction==="output").length,X=A.streams.filter($=>$.direction==="unknown").length,ie=A.tasks.length,le=Math.max(1,I,G,ie,X),ce=DT(A.name,A.componentType,As),he=li(le,tt,Ia,22),oe=li(ie,tr,yp,AT),K=t==="lr"?Math.max(FT,ce):Math.max(220,ce,he,oe);if(t==="lr"){const $=Math.max(1,I,G,ie),q=Math.max(126,Ps+16+$*30+(X>0?Ne+12:0)+12);M.set(`unit:${A.address}`,{width:K,height:q});continue}const z=Math.max(1,(I>0?1:0)+(ie>0?1:0)+(X>0?1:0)+(G>0?1:0)),ee=Math.max(216,Ps+18+z*Ne+Math.max(0,z-1)*12+16);M.set(`unit:${A.address}`,{width:K,height:ee})}for(const A of d.values()){const I=A.streams.filter(K=>K.direction==="input").length,G=A.streams.filter(K=>K.direction==="output").length,X=A.streams.filter(K=>K.direction==="unknown").length,ie=Math.max(1,I,G,X),le=Math.max(t==="lr"?ii:300,li(ie,tt,Ia,22)),ce=zT(A.name,A.componentType,As),he=Math.max(le,ce),oe=t==="lr"?Math.max(124,Pa+16+Math.max(1,I,G)*30+(X>0?Ne+12:0)+12):Math.max(176,Pa+14+Math.max(1,(I>0?1:0)+(X>0?1:0)+(G>0?1:0))*Ne+12);M.set(`collection:${A.address}`,{width:he,height:oe})}for(const A of v)M.has(A)||M.set(A,{width:vp,height:74});const C=new Map,S=Array.from(N.keys()).sort((A,I)=>A-I);if(t==="tb"){let A=28;for(const I of S){const G=N.get(I)??[];let X=24,ie=0;for(const le of G){const ce=M.get(le)??{width:Ta,height:ka};C.set(le,{x:X,y:A}),X+=ce.width+bT,ie=Math.max(ie,ce.height)}A+=ie+CT}}else{let A=24;for(const I of S){const G=N.get(I)??[];let X=28,ie=0;for(const le of G){const ce=M.get(le)??{width:Ta,height:ka};C.set(le,{x:A,y:X}),X+=ce.height+PT,ie=Math.max(ie,ce.width)}A+=ie+IT}}const b=[],B=[],j={stroke:s?"#8fa3bc":"#475569",strokeWidth:1.5},Y={type:xr.ArrowClosed,width:12,height:12,color:s?"#8fa3bc":"#475569"};function Q(A,I,G,X,ie,le,ce,he){if(G.length===0)return;const oe=I.width-22,K=G.length*tt,z=G.length>1?Math.max(6,Math.min(16,Math.floor((oe-K)/(G.length-1)))):0,ee=K+z*Math.max(0,G.length-1),$=11+Math.max(0,Math.floor((oe-ee)/2));G.forEach((q,te)=>{const ae=Ms(q,ie,le,s),pe=$+te*(tt+z);he.push({id:`stream:${q.address}`,parentNode:A,extent:"parent",draggable:!1,data:{label:m.jsxs("span",{className:Rs(q,ie,le),title:Kn(q,le),children:[m.jsx("span",{className:"topology-stream-name",children:En(q.name,q.address)}),ct(q.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(q.msgType),"]"]}):null]})},position:{x:pe,y:X},sourcePosition:ce==="tb"?re.Bottom:re.Right,targetPosition:ce==="tb"?re.Top:re.Left,style:{width:tt,height:Ne,borderRadius:ae.borderRadius,border:ae.border,background:ae.background,color:ae.color,fontSize:8,padding:"0 6px"}})})}if(_&&T){const A=v.filter(ge=>ge.startsWith("unit:")||ge.startsWith("collection:"));let I=24,G=32,X=24+ii,ie=32+ba;if(A.length>0){I=Number.POSITIVE_INFINITY,G=Number.POSITIVE_INFINITY,X=Number.NEGATIVE_INFINITY,ie=Number.NEGATIVE_INFINITY;for(const ge of A){const Ee=C.get(ge),ye=M.get(ge);!Ee||!ye||(I=Math.min(I,Ee.x),G=Math.min(G,Ee.y),X=Math.max(X,Ee.x+ye.width),ie=Math.max(ie,Ee.y+ye.height))}(!Number.isFinite(I)||!Number.isFinite(G))&&(I=24,G=32,X=24+ii,ie=32+ba)}const le=_.streams.filter(ge=>ge.direction==="input"),ce=_.streams.filter(ge=>ge.direction==="output"),he=_.streams.filter(ge=>ge.direction==="unknown"),oe=Math.max(1,le.length,ce.length,he.length),K=li(oe,tt,Ia,24),z=le.length>0,ee=ce.length>0,$=t==="lr"?72:76,q=t==="lr"?108:64,te=28,ae=t==="lr"?Math.max(q,$+Math.max(1,le.length,ce.length)*30+(he.length>0?Ne+10:0)+8):z?Math.max(q,$+Ne+8):q,pe=t==="tb"?ee?Math.max(_p,Ne+20):20:_p,we=Math.max(0,ie-G),de={x:I-te,y:G-ae},me={width:Math.max(360,X-I+te*2,K+te*2),height:Math.max(180,we+ae+pe)};if(A.length>0){const ge=(I+X)/2,Ee=de.x+te,ye=de.x+me.width-te,Ae=(Ee+ye)/2,xe=Math.round(Ae-ge);if(xe!==0)for(const ut of A){const je=C.get(ut);je&&C.set(ut,{x:je.x+xe,y:je.y})}}if(b.push({id:T,position:de,sourcePosition:t==="tb"?re.Bottom:re.Right,targetPosition:t==="tb"?re.Top:re.Left,data:{label:m.jsxs("div",{className:"topology-collection-label topology-collection-label--scope",title:Aa(_.name,_.address,_.componentType),children:[m.jsxs("span",{className:"topology-title-row topology-title-row--collection",children:[m.jsxs("span",{className:"topology-title-row",children:[m.jsx("strong",{children:_.name}),m.jsx("span",{className:"topology-unit-type",title:_.componentType,children:As(_.componentType)})]}),m.jsx("button",{type:"button","data-scope-up":"true",className:"topology-collection-scope-up-btn nodrag nopan",title:"Go up one scope","aria-label":`Go up from ${_.name}`,onPointerDown:ge=>{ge.stopPropagation()},onMouseDown:ge=>{ge.stopPropagation()},onClick:ge=>{var Ee;ge.stopPropagation(),(Ee=o==null?void 0:o.goUpFromScope)==null||Ee.call(o,_.address)},children:"↑ Up"})]}),m.jsx("span",{className:"mono",children:Ii(_.address)})]})},style:{width:me.width,height:me.height,border:`2px dashed ${s?"#4b647e":gp[0]}`,borderRadius:14,background:s?"rgba(15, 23, 42, 0.45)":"rgba(226, 232, 240, 0.24)",color:s?"#e2e8f0":"#0f172a",padding:10,zIndex:-1},draggable:!1,selectable:!1}),t==="lr"){const ye=Math.max(1,le.length,ce.length)*30,Ae=Math.max($,ae-ye-8);le.forEach((xe,ut)=>{const je=Ms(xe,"is-input","collection",s);b.push({id:`stream:${xe.address}`,parentNode:T,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsxs("span",{className:Rs(xe,"is-input","collection"),title:Kn(xe,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(xe.name,xe.address)}),ct(xe.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(xe.msgType),"]"]}):null]})},position:{x:12,y:Ae+ut*30},style:{width:tt,height:Ne,borderRadius:je.borderRadius,border:je.border,background:je.background,color:je.color,padding:"0 6px"}})}),ce.forEach((xe,ut)=>{const je=Ms(xe,"is-output","collection",s);b.push({id:`stream:${xe.address}`,parentNode:T,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsxs("span",{className:Rs(xe,"is-output","collection"),title:Kn(xe,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(xe.name,xe.address)}),ct(xe.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(xe.msgType),"]"]}):null]})},position:{x:me.width-tt-12,y:Ae+ut*30},style:{width:tt,height:Ne,borderRadius:je.borderRadius,border:je.border,background:je.background,color:je.color,padding:"0 6px"}})}),he.length>0&&Q(T,me,he,56+Math.max(le.length,ce.length)*30+4,"is-unknown","collection",t,b)}else{const ge=Math.max($,ae-Ne-8),Ee=ae+we,ye=Math.min(me.height-Ne-10,Ee+Math.max(6,Math.floor((pe-Ne)/2)));if(Q(T,me,le,ge,"is-input","collection",t,b),Q(T,me,ce,ye,"is-output","collection",t,b),he.length>0){const Ae=HT(A,C,M,de.y,ae,we,me.height);Q(T,me,he,Ae,"is-unknown","collection",t,b)}}}for(const A of d.values()){const I=`collection:${A.address}`,G=C.get(I)??{x:0,y:0},X=M.get(I)??{width:ii,height:ba};b.push({id:I,position:G,sourcePosition:t==="tb"?re.Bottom:re.Right,targetPosition:t==="tb"?re.Top:re.Left,data:{label:m.jsxs("div",{className:"topology-collection-label",title:Aa(A.name,A.address,A.componentType),children:[m.jsxs("span",{className:"topology-title-row topology-title-row--collection",children:[m.jsxs("span",{className:"topology-title-row",children:[m.jsx("strong",{children:A.name}),m.jsx("span",{className:"topology-unit-type",title:A.componentType,children:As(A.componentType)})]}),m.jsx("button",{type:"button","data-open-collection":"true",className:"topology-collection-open-btn nodrag nopan",title:"Open collection scope","aria-label":`Open ${A.name} scope`,onPointerDown:he=>{he.stopPropagation()},onMouseDown:he=>{he.stopPropagation()},onClick:he=>{var oe;he.stopPropagation(),(oe=o==null?void 0:o.openCollectionScope)==null||oe.call(o,A.address)},children:"Open"})]}),m.jsx("span",{className:"mono",children:Ii(A.address)})]})},style:{width:X.width,height:X.height,border:`2px dashed ${s?"#4f8ccf":gp[1]}`,borderRadius:12,background:s?"rgba(30, 58, 95, 0.34)":kT[1],color:s?"#e2e8f0":"#0f172a",padding:10}});const ie=A.streams.filter(he=>he.direction==="input"),le=A.streams.filter(he=>he.direction==="output"),ce=A.streams.filter(he=>he.direction==="unknown");if(t==="lr"){const oe=Pa+6;ie.forEach((K,z)=>{const ee=Ms(K,"is-input","collection",s);b.push({id:`stream:${K.address}`,parentNode:I,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsxs("span",{className:Rs(K,"is-input","collection"),title:Kn(K,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(K.name,K.address)}),ct(K.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(K.msgType),"]"]}):null]})},position:{x:10,y:oe+z*30},style:{width:tt,height:Ne,borderRadius:ee.borderRadius,border:ee.border,background:ee.background,color:ee.color,padding:"0 6px"}})}),le.forEach((K,z)=>{const ee=Ms(K,"is-output","collection",s);b.push({id:`stream:${K.address}`,parentNode:I,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsxs("span",{className:Rs(K,"is-output","collection"),title:Kn(K,"collection"),children:[m.jsx("span",{className:"topology-stream-name",children:En(K.name,K.address)}),ct(K.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(K.msgType),"]"]}):null]})},position:{x:X.width-tt-10,y:oe+z*30},style:{width:tt,height:Ne,borderRadius:ee.borderRadius,border:ee.border,background:ee.background,color:ee.color,padding:"0 6px"}})}),ce.length>0&&Q(I,X,ce,X.height-Ne-10,"is-unknown","collection",t,b)}else{const oe=Math.max(86+Ne+10,X.height-Ne-12);Q(I,X,ie,86,"is-input","collection",t,b),Q(I,X,le,oe,"is-output","collection",t,b),ce.length>0&&Q(I,X,ce,Math.floor((X.height-Ne)/2)+14,"is-unknown","collection",t,b)}}for(const A of c.values()){const I=`unit:${A.address}`,G=C.get(I)??{x:0,y:0},X=M.get(I)??{width:Ta,height:ka},ie=A.streams.filter(K=>K.direction==="input"),le=A.streams.filter(K=>K.direction==="output"),ce=A.streams.filter(K=>K.direction==="unknown"),he=new Set(A.streams.map(K=>K.address)),oe=UT(A.streams);if(b.push({id:I,position:G,data:{label:m.jsxs("div",{className:"topology-unit-label",children:[m.jsxs("span",{className:"topology-title-row",title:Aa(A.name,A.address,A.componentType),children:[m.jsx("strong",{children:A.name}),m.jsx("span",{className:"topology-unit-type",title:A.componentType,children:As(A.componentType)})]}),m.jsx("span",{className:"mono topology-unit-address",title:A.address,children:ai(Ii(A.address),34)})]})},style:{width:X.width,height:X.height,border:s?"1px solid #3b82f6":"1px solid #93c5fd",borderRadius:12,background:s?"#0f1f35":"#f8fbff",padding:10}}),t==="lr"){const K=Ps+6;ie.forEach((z,ee)=>{b.push({id:`stream:${z.address}`,parentNode:I,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsxs("span",{className:"mono topology-stream-label is-input",title:Kn(z,"unit"),children:[m.jsx("span",{className:"topology-stream-name",children:En(z.name,z.address)}),ct(z.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(z.msgType),"]"]}):null]})},position:{x:10,y:K+ee*30},style:{width:tt,height:Ne,borderRadius:999,border:s?"1px solid #818cf8":"1px solid #c7d2fe",background:s?"#1d2644":"#eef2ff",padding:"0 6px"}})}),le.forEach((z,ee)=>{b.push({id:`stream:${z.address}`,parentNode:I,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsxs("span",{className:"mono topology-stream-label is-output",title:Kn(z,"unit"),children:[m.jsx("span",{className:"topology-stream-name",children:En(z.name,z.address)}),ct(z.msgType)?m.jsxs("span",{className:"topology-stream-type",children:["[",ct(z.msgType),"]"]}):null]})},position:{x:X.width-tt-10,y:K+ee*30},style:{width:tt,height:Ne,borderRadius:999,border:s?"1px solid #22d3ee":"1px solid #7dd3fc",background:s?"#0f2e37":"#ecfeff",padding:"0 6px"}})}),A.tasks.forEach((z,ee)=>{const $=`task:${A.address}:${z.name}`,q=ui(z.subscribes,oe),te=Array.from(new Set(z.publishes.map(ae=>ui(ae,oe)).filter(ae=>ae!==null)));b.push({id:$,parentNode:I,extent:"parent",draggable:!1,sourcePosition:re.Right,targetPosition:re.Left,data:{label:m.jsx("span",{className:"mono topology-task-label",title:z.name,children:ai(z.name,15)})},position:{x:Math.floor((X.width-tr)/2),y:K+ee*30+4},style:{width:tr,height:Ca,borderRadius:999,border:s?"1px solid #41536c":"1px solid #dbe2ea",background:s?"#1a273a":"#f1f5f9",padding:"0 6px"}}),q&&he.has(q)&&B.push({id:`edge:internal:${A.address}:${z.name}:sub`,source:`stream:${q}`,target:$,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:Y,style:j});for(const ae of te)he.has(ae)&&B.push({id:`edge:internal:${A.address}:${z.name}:${ae}`,source:$,target:`stream:${ae}`,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:Y,style:j})}),ce.length>0&&Q(I,X,ce,X.height-Ne-8,"is-unknown","unit",t,b)}else{const K=Ps+Ne+12,z=X.height-Ne-12,ee=z-8,$=K+Math.max(0,Math.floor((ee-K-Ca)/2));Q(I,X,ie,Ps+2,"is-input","unit",t,b),Q(I,X,le,z,"is-output","unit",t,b),ce.length>0&&Q(I,X,ce,$+28,"is-unknown","unit",t,b);const q=A.tasks.length,te=X.width-20,ae=q*tr,pe=q>1?Math.max(yp,Math.min(22,Math.floor((te-ae)/(q-1)))):0,we=ae+pe*Math.max(0,q-1),de=10+Math.max(0,Math.floor((te-we)/2));A.tasks.forEach((me,ge)=>{const Ee=`task:${A.address}:${me.name}`,ye=ui(me.subscribes,oe),Ae=Array.from(new Set(me.publishes.map(xe=>ui(xe,oe)).filter(xe=>xe!==null)));b.push({id:Ee,parentNode:I,extent:"parent",draggable:!1,sourcePosition:re.Bottom,targetPosition:re.Top,data:{label:m.jsx("span",{className:"mono topology-task-label",title:me.name,children:ai(me.name,15)})},position:{x:de+ge*(tr+pe),y:$},style:{width:tr,height:Ca,borderRadius:999,border:s?"1px solid #41536c":"1px solid #dbe2ea",background:s?"#1a273a":"#f1f5f9",padding:"0 6px"}}),ye&&he.has(ye)&&B.push({id:`edge:internal:${A.address}:tb:${me.name}:sub`,source:`stream:${ye}`,target:Ee,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:Y,style:j});for(const xe of Ae)he.has(xe)&&B.push({id:`edge:internal:${A.address}:tb:${me.name}:${xe}`,source:Ee,target:`stream:${xe}`,type:i,zIndex:20,className:"topology-internal-edge",markerEnd:Y,style:j})})}}for(const A of F){const I=P.get(A);if(I&&I.ownerKind!=="orphan")continue;const G=`orphan:${A}`,X=C.get(G)??{x:0,y:0};b.push({id:`stream:${A}`,position:X,sourcePosition:t==="tb"?re.Bottom:re.Right,targetPosition:t==="tb"?re.Top:re.Left,data:{label:m.jsxs("div",{className:"mono topology-orphan-label",children:[m.jsx("strong",{children:Vu(A)}),m.jsx("span",{children:ai(A,54)})]})},style:{width:vp,border:s?"1px solid #41536c":"1px solid #dbe2ea",borderRadius:10,background:s?"#111c2e":"#ffffff",padding:6}})}const ne=A=>{const I=P.get(A);return I?I.ownerKind==="unit"||I.ownerKind==="collection"||I.ownerKind==="scope_collection"||I.ownerKind==="orphan"?`stream:${A}`:I.ownerId:`stream:${A}`},se=A=>{var I;return((I=P.get(A))==null?void 0:I.ownerId)??null};for(const A of R){const I=ne(A.from),G=ne(A.to);if(I===G)continue;const X=se(A.from),ie=se(A.to);if(!(X&&ie&&X===ie&&X.startsWith("scope:"))&&!(X&&ie&&X===ie&&X.startsWith("collection:"))){if(X&&ie&&X===ie&&X.startsWith("unit:")){const le=c.get(X.slice(5));if(le&&le.tasks.length>0)continue}B.push({id:`edge:${A.from}->${A.to}`,source:I,target:G,type:i,zIndex:1,markerEnd:{type:xr.ArrowClosed,width:12,height:12,color:s?"#8fa3bc":"#64748b"},style:{stroke:s?"#8fa3bc":"#64748b",strokeWidth:1.2}})}}return{nodes:b,edges:B}}function YT(e){const t=new Map;if(!e)return t;for(const n of e.units.values())for(const r of n.streams)t.set(r.address,r.address),t.set(He(r.address),r.address);for(const n of e.collections.values())for(const r of n.streams)t.set(r.address,r.address),t.set(He(r.address),r.address);return t}function KT(e,t){const n=new Set;for(const r of e){const s=t.get(r)??t.get(He(r))??null;s&&(n.add(s),n.add(He(s)))}return n}function XT(e,t,n){if(!e||t.size===0)return t;const r=new Map;for(const[l,a]of Object.entries(e.graph)){const u=n.get(l)??n.get(He(l))??l,c=r.get(u)??[];for(const d of a){const f=n.get(d)??n.get(He(d))??d;c.push(f)}r.set(u,c)}const s=new Set,o=Array.from(t);for(;o.length>0;){const l=o.shift();if(!l||s.has(l))continue;s.add(l);const a=r.get(l)??[];for(const u of a)s.has(u)||o.push(u)}const i=new Set;for(const l of s)i.add(l),i.add(He(l));return i}function QT(e,t){if(t.size===0||e.edges.length===0)return e;const n=a=>{if(!a)return!1;const u=He(a);return t.has(a)||t.has(u)},r=new Map;e.edges.forEach((a,u)=>{const c=r.get(a.source);c?c.push(u):r.set(a.source,[u])});const s=new Set,o=new Set,i=[],l=a=>{o.has(a)||(o.add(a),i.push(a))};for(e.edges.forEach((a,u)=>{const c=a.source.startsWith("stream:")?a.source.slice(7):null,d=ZT(a.id);n(c??d)&&(s.add(u),l(a.target))});i.length>0;){const a=i.shift();if(!a)continue;const u=r.get(a);if(!(!u||u.length===0))for(const c of u)s.has(c)||(s.add(c),l(e.edges[c].target))}return s.size===0?e:{nodes:e.nodes,edges:e.edges.map((a,u)=>{if(!s.has(u)||typeof a.className=="string"&&a.className.includes("topology-internal-edge"))return a;const d=typeof a.markerEnd=="object"&&a.markerEnd!==null?{...a.markerEnd,color:"#2563eb"}:{type:xr.ArrowClosed,width:12,height:12,color:"#2563eb"};return{...a,animated:!0,markerEnd:d,style:{...a.style??{},stroke:"#2563eb",strokeWidth:1.7}}})}}function ZT(e){if(!e.startsWith("edge:")||e.startsWith("edge:internal:"))return null;const t=e.slice(5),n=t.indexOf("->");if(n<=0)return null;const r=t.slice(0,n);return r.length>0?r:null}function qT(e){const t=new Map;if(!e)return t;for(const n of e.units.values())for(const r of n.streams){const s={direction:r.direction,unitAddress:n.address};t.set(r.address,s),t.set(He(r.address),s)}return t}function JT(e){const t=new Map;if(!e)return t;const n=(r,s)=>{const o=s.split(":").slice(1).join(":");o.length>0&&!t.has(o)&&t.set(o,r)};for(const r of e.units.values())for(const s of r.streams)n(r.address,s.address);for(const r of e.collections.values())for(const s of r.streams)n(r.address,s.address);return t}function e2(e,t,n){if(!e)return null;const{topic:r,endpointToken:s}=zc(n);let o=-1,i=null;const l=(a,u,c)=>{const d=t2(t,u,c,r,s);d>o&&(o=d,i=a)};for(const a of e.units.values())for(const u of a.streams)l(a.address,u.address,u.direction);for(const a of e.collections.values())for(const u of a.streams)l(a.address,u.address,u.direction);return o>0?i:null}function t2(e,t,n,r,s){if(e==="publisher"&&n!=="output"||e==="subscriber"&&n!=="input")return-1;let o=0;const i=He(t);return r.length>0&&(i===r?o+=12:t.startsWith(`${r}:`)?o+=8:t.includes(r)&&(o+=2)),s.length>0&&(t.endsWith(`:${s}`)?o+=14:t.includes(s)&&(o+=7)),o}function n2(e,t,n){if(e.kind!=="publisher"&&e.kind!=="subscriber")return null;const r=e.streamAddress.split(":").slice(1).join(":");return e.unitAddress??t.get(r)??n(e.kind,e.streamAddress)??null}function r2(e,t,n,r){if(e.kind==="unit")return`unit:${e.unitAddress}`;if(e.kind==="collection")return`collection:${e.collectionAddress}`;if(t&&(r!=null&&r.units.has(t)))return`unit:${t}`;if(t&&(r!=null&&r.collections.has(t)))return`collection:${t}`;const s=e.streamAddress;if(!s)return null;const o=s.split(":").slice(1).join(":"),i=s.split(":")[0]??"",l=n.nodes.find(a=>{if(!a.id.startsWith("stream:"))return!1;const u=a.id.slice(7);return u.includes(o)||u.startsWith(i)});return(l==null?void 0:l.id)??null}function s2({autoFocusOnSelection:e,focusSelection:t,focusRequestId:n,flowInitTick:r,flowInstanceRef:s,flowData:o,topologyComponents:i,activeScope:l,parentCollectionByAddress:a,componentAddressByEndpointId:u,componentAddressByStreamSelection:c,setScopeCollectionAddress:d}){const f=E.useRef(0),h=E.useRef(null),x=E.useRef(null);E.useEffect(()=>{if(!e||!t||n<=0||f.current===n||!s.current)return;const T=n2(t,u,c),p=t.kind==="unit"?t.unitAddress:t.kind==="collection"?t.collectionAddress:T;if(p&&i){const P=a.get(p)??null;if(P!==l){h.current=n,d(P);return}}const g=r2(t,T,o,i);if(!g||!o.nodes.some(P=>P.id===g))return;const y=()=>{const P=s.current;if(!P){x.current=null;return}P.fitView({nodes:[{id:g}],padding:LT,duration:$T,minZoom:BT,maxZoom:jT}),f.current=n,h.current=null,x.current=null};if(h.current===n){if(x.current===n)return;x.current=n,requestAnimationFrame(()=>{requestAnimationFrame(y)});return}y()},[l,e,u,c,o,r,n,t,s,a,d,i])}function o2(e){return Object.values(e).reduce((t,n)=>t+n.length,0)}function i2({graphSnapshot:e,profilingSnapshot:t=null,recentEvents:n,immersive:r=!1,showLegend:s=!0,showMiniMap:o=!0,darkMode:i=!1,defaultLayout:l="tb",edgeConnectorStyle:a="curved",autoFitOnLayoutScopeChange:u=!0,autoFocusOnSelection:c=!0,focusSelection:d=null,focusRequestId:f=0,onEntitySelect:h}){var ee;const x=E.useRef(null),_=E.useRef(null),T=E.useRef(new Map),p=E.useRef(""),g=E.useRef(null),y=E.useRef(new Map),[w,P]=E.useState(!1),[O,L]=E.useState(0),[R,F]=E.useState(null),[D,H]=E.useState([]),Z=l;E.useEffect(()=>{if(!t){y.current=new Map,H([]);return}const $=y.current,q=new Map,te=new Set;for(const we of Object.values(t)){const de=we.process_id;for(const me of Object.values(we.publishers)){const ge=typeof me.messages_published_total=="number"&&Number.isFinite(me.messages_published_total)?me.messages_published_total:0,Ee=`${de}:${me.endpoint_id}`,ye=$.get(Ee);ye!==void 0&&ge>ye&&te.add(`${me.topic}:${me.endpoint_id}`),q.set(Ee,ge)}}y.current=q;const ae=Array.from(te).sort(),pe=ae.join("|");pe!==p.current&&(p.current=pe,H(ae))},[t]);const U=E.useMemo(()=>e?v0(e):null,[e]),v=E.useMemo(()=>U?$l(U.collections):new Map,[U]),k=E.useMemo(()=>U?ET(U.collections,R):[],[U,R]),N=E.useMemo(()=>qT(U),[U]),M=E.useMemo(()=>JT(U),[U]),C=E.useMemo(()=>($,q)=>e2(U,$,q),[U]),S=E.useMemo(()=>YT(U),[U]),b=E.useMemo(()=>KT(D,S),[D,S]),B=E.useMemo(()=>XT(e,b,S),[b,S,e]),j=k.length>0?k[k.length-1]:null,Y=E.useCallback($=>{U!=null&&U.collections.has($)&&F($)},[U]),Q=E.useCallback($=>{F(v.get($)??null)},[v]),ne=`${Z}:${j??"root"}`,se=E.useMemo(()=>e?GT(e,Z,j,a,i,{openCollectionScope:Y,goUpFromScope:Q}):{nodes:[],edges:[]},[e,Z,j,a,i,Y,Q]),fe=E.useMemo(()=>{if(se.nodes.length>0&&VT(se))return T.current.set(ne,se),se;const $=T.current.get(ne);return $&&$.nodes.length>0?$:se},[se,ne]),W=E.useMemo(()=>QT(fe,B),[B,fe]),A=$=>{$.startsWith("collection:")&&Y($.slice(11))},I=$=>{if($.startsWith("unit:")){h==null||h({kind:"unit",unitAddress:$.slice(5)});return}if($.startsWith("collection:")){h==null||h({kind:"collection",collectionAddress:$.slice(11)});return}if($.startsWith("stream:")){const q=$.slice(7),te=N.get(q)??N.get(He(q));if(!te){h==null||h(null);return}if(te.direction==="output"){h==null||h({kind:"publisher",streamAddress:q,unitAddress:te.unitAddress});return}if(te.direction==="input"){h==null||h({kind:"subscriber",streamAddress:q,unitAddress:te.unitAddress});return}}h==null||h(null)};if(E.useEffect(()=>{!U||!R||U.collections.has(R)||F(null)},[R,U]),E.useEffect(()=>{if(!U||!e){g.current=null;return}const $=Hu(U.units,U.collections,null),q=$.length===1?$[0]:null,te=q!==null&&TT(e,U.units,U.collections,q),ae=q!==null&&U.collections.has(q)&&NT(q,U.units,U.collections)&&!te,pe=`${$.slice().sort().join("|")}::${ae?"ready":"wait"}`;g.current!==pe&&(g.current=pe,R===null&&(!ae||!q||F(q)))},[e,R,U]),E.useEffect(()=>{if(!U||!R)return;Hu(U.units,U.collections,R).length===0&&F(null)},[R,U]),s2({autoFocusOnSelection:c,focusSelection:d,focusRequestId:f,flowInitTick:O,flowInstanceRef:_,flowData:fe,topologyComponents:U,activeScope:j,parentCollectionByAddress:v,componentAddressByEndpointId:M,componentAddressByStreamSelection:C,setScopeCollectionAddress:F}),E.useEffect(()=>{const $=()=>{var ae;const q=((ae=x.current)==null?void 0:ae.closest(".dashboard-layout"))??x.current,te=document.fullscreenElement;if(!q||!te){P(!1);return}P(te===q||te.contains(q))};return document.addEventListener("fullscreenchange",$),()=>{document.removeEventListener("fullscreenchange",$)}},[]),!e)return r?m.jsx("section",{className:"topology-immersive",children:m.jsx("div",{className:"topology-empty-state",children:m.jsx("p",{children:"Waiting for initial snapshot..."})})}):m.jsx(Ji,{title:"Topology",subtitle:"Live graph, process ownership, and edge changes",children:m.jsx("div",{className:"placeholder",children:m.jsx("p",{children:"Waiting for initial snapshot..."})})});const G=Object.keys(e.graph).length,X=o2(e.graph),ie=Object.keys(e.sessions).length,le=Object.values(e.processes),ce=((ee=x.current)==null?void 0:ee.closest(".dashboard-layout"))??x.current??document.documentElement,he=async()=>{if(ce)try{document.fullscreenElement?await document.exitFullscreen():await ce.requestFullscreen()}catch{}},oe=m.jsxs("div",{className:"topology-flow-toolbar",children:[m.jsx("span",{className:"topology-flow-toolbar__label",children:"Scope"}),m.jsx("button",{type:"button",className:`topology-layout-btn ${j?"":"is-active"}`,onClick:()=>F(null),children:"Root"}),m.jsx("button",{type:"button",className:"topology-layout-btn",disabled:!j,onClick:()=>{j&&F(v.get(j)??null)},children:"Up"}),k.length>0?m.jsx("span",{className:"topology-scope-sep",children:"|"}):null,k.length>0?m.jsx("span",{className:"topology-scope-trail",children:k.map(($,q)=>{const te=U==null?void 0:U.collections.get($),ae=(te==null?void 0:te.name)??Ii($),pe=te?[te.name,te.address,te.componentType].join(` -`):$,we=q===k.length-1;return m.jsxs("span",{className:"topology-scope-segment",children:[we?m.jsx("span",{className:"topology-scope-tail",title:pe,children:ae}):m.jsx("button",{type:"button",className:"topology-scope-chip",title:pe,onClick:()=>F($),children:ae}),we?null:m.jsx("span",{className:"topology-scope-slash",children:"/"})]},`scope-${$}`)})}):null]}),K=m.jsxs("div",{className:"topology-viewport-legend","aria-label":"Topology legend",children:[m.jsx("span",{className:"topology-viewport-legend__title",children:"Legend"}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-collection"}),"Collection"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-input"}),"Subscriber"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-output"}),"Publisher"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-topic"}),"Collection Topic"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-relay"}),"Collection Relay"]}),m.jsxs("span",{className:"topology-viewport-legend__item",children:[m.jsx("i",{className:"topology-viewport-legend__swatch is-task"}),"Task"]})]}),z=m.jsxs(m.Fragment,{children:[r?null:oe,m.jsxs("div",{className:`topology-flow-shell ${r?"is-immersive":""} ${i?"is-dark":""}`,ref:x,children:[r?m.jsx("div",{className:"topology-viewport-top-controls",children:oe}):null,r&&s?m.jsx("div",{className:"topology-viewport-bottom-dock",children:K}):null,r||!s?null:K,m.jsxs(p0,{nodes:W.nodes,edges:W.edges,fitView:!0,fitViewOptions:{padding:.18,minZoom:.4},minZoom:.2,maxZoom:2.4,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onInit:$=>{_.current=$,L(q=>q+1)},onPaneClick:()=>h==null?void 0:h(null),onNodeClick:($,q)=>{if(q.id.startsWith("scope:")){const te=$.target,ae=te==null?void 0:te.closest('[data-scope-up="true"]');if(ae){if(!ae.disabled){const pe=q.id.slice(6);Q(pe)}return}}if(q.id.startsWith("collection:")){const te=$.target;if(te!=null&&te.closest('[data-open-collection="true"]')){A(q.id);return}h==null||h({kind:"collection",collectionAddress:q.id.slice(11)});return}I(q.id)},proOptions:{hideAttribution:!0},children:[m.jsx(xT,{color:i?"#243244":"#d5deea",gap:24}),o?m.jsx(lT,{pannable:!0,zoomable:!0,maskColor:i?"rgba(2, 6, 23, 0.72)":"rgba(15, 23, 42, 0.10)",style:{background:i?"#0e1728":"#f8fafc",border:i?"1px solid #334155":"1px solid #dbe2ea",borderRadius:8},nodeColor:$=>$.id.startsWith("collection:")?i?"#1d4f79":"#dbeafe":$.id.startsWith("unit:")?i?"#1e3a62":"#bfdbfe":i?"#334155":"#cbd5e1"}):null,m.jsx(hT,{showFitView:!1,showInteractive:!1,children:m.jsx(Wr,{className:"topology-control-btn",title:w?"Exit fullscreen":"Enter fullscreen","aria-label":w?"Exit fullscreen":"Enter fullscreen",onClick:()=>{he()},children:"⛶"})})]},u?`topology-flow-${Z}-${j??"root"}`:"topology-flow-stable")]})]});return r?m.jsx("section",{className:"topology-immersive",children:z}):m.jsxs(Ji,{title:"Topology",subtitle:"Low-level publisher/subscriber wiring with optional metadata overlays",children:[m.jsxs("div",{className:"stats-grid",children:[m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Topics"}),m.jsx("strong",{children:G})]}),m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Edges"}),m.jsx("strong",{children:X})]}),m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Sessions"}),m.jsx("strong",{children:ie})]}),m.jsxs("article",{className:"stat-card",children:[m.jsx("span",{children:"Processes"}),m.jsx("strong",{children:le.length})]})]}),z,m.jsxs("div",{className:"panel-section",children:[m.jsx("h3",{children:"Process Ownership"}),le.length===0?m.jsx("p",{className:"muted",children:"No process ownership in current snapshot."}):m.jsxs("table",{className:"data-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Process ID"}),m.jsx("th",{children:"PID"}),m.jsx("th",{children:"Host"}),m.jsx("th",{children:"Units"})]})}),m.jsx("tbody",{children:le.map($=>m.jsxs("tr",{children:[m.jsx("td",{className:"mono",children:$.process_id.slice(0,8)}),m.jsx("td",{children:$.pid??"-"}),m.jsx("td",{children:$.host??"-"}),m.jsx("td",{children:$.units.length})]},$.process_id))})]})]}),m.jsxs("div",{className:"panel-section",children:[m.jsx("h3",{children:"Recent Topology Changes"}),n.length===0?m.jsx("p",{className:"muted",children:"No topology events received yet."}):m.jsx("ul",{className:"event-list",children:n.slice(0,8).map($=>m.jsxs("li",{className:"event-item",children:[m.jsx("span",{className:"event-pill",children:$.data.event_type}),m.jsxs("span",{className:"mono",children:["seq ",$.data.seq]}),m.jsx("span",{children:$.data.changed_topics.length>0?$.data.changed_topics.join(", "):"No topic list"})]},`topo-${$.data.seq}`))})]})]})}function De(e,t,n,r=!0){return{repr_value:n,structured_value:n,settings_schema:null,serialized_present:!0,patchable:r,patch_error:null,component_type:t,component_name:e}}function en(e,t,n,r={},s={}){return{process_id:e,pid:t,host:"fixture-host",window_seconds:2,timestamp:1711111111,publishers:r,subscribers:s}}function xp(e,t,n){return{endpoint_id:e,topic:t,messages_published_total:n.messagesPublishedTotal??n.messagesPublishedWindow*10,messages_published_window:n.messagesPublishedWindow,publish_rate_hz_window:n.publishRateHzWindow,inflight_messages_current:n.inflightCurrent??0,num_buffers:n.numBuffers??8,timestamp:n.timestamp??1711111111}}function wp(e,t,n){return{endpoint_id:e,topic:t,messages_received_total:n.messagesReceivedTotal??n.messagesReceivedWindow*10,messages_received_window:n.messagesReceivedWindow,channel_kind_last:n.channelKindLast??"fifo",timestamp:n.timestamp??1711111111}}function Ft(e,t="builtins.str"){return{address:e,msg_type:t,leaky:!1}}function Xt(e,t,n="builtins.str"){return{address:e,msg_type:n,host:"127.0.0.1",port:t}}function ot(e,t,n){return{name:e,subscribes:t,publishes:n}}function Me(e){return String(e).padStart(2,"0")}const tn={name:"root-scope-navigation",health:{status:"ok",graph_session_active:!0,graph_address:"127.0.0.1:25978"},snapshot:{snapshot:{graph:{"SYSTEM/PING_TOPIC":["GLOBAL_PING_TOPIC"]},edge_owners:[],sessions:{"fixture-session":{edges:[{from_topic:"SYSTEM/PING_TOPIC",to_topic:"GLOBAL_PING_TOPIC"}],metadata:{components:{SYSTEM:{name:"SYSTEM",component_type:"fixture.TestSystem",children:["SYSTEM/PING"],topics:{PING:{address:"SYSTEM/PING_TOPIC",msg_type:"builtins.str"}}},"SYSTEM/PING":{name:"PING",component_type:"fixture.MessageGenerator",streams:{OUTPUT:{address:"SYSTEM/PING_TOPIC:ping-output-endpoint",msg_type:"builtins.str",host:"127.0.0.1",port:9001}},tasks:[{name:"emit",subscribes:null,publishes:["SYSTEM/PING_TOPIC"]}]}}}}},processes:{"fixture-process":{process_id:"fixture-process",pid:4201,host:"fixture-host",units:["SYSTEM/PING"]}}},settings:{SYSTEM:De("SYSTEM","fixture.TestSystem",{enabled:!0}),"SYSTEM/PING":De("PING","fixture.MessageGenerator",{rate_hz:10,message:"ping"})},profiling:{"fixture-process":en("fixture-process",4201,["SYSTEM/PING"],{"SYSTEM/PING_TOPIC:ping-output-endpoint":{endpoint_id:"ping-output-endpoint",topic:"SYSTEM/PING_TOPIC",messages_published_total:120,messages_published_window:20,publish_rate_hz_window:10,inflight_messages_current:1,num_buffers:8,timestamp:1711111111}})}}},l2={name:"wide-fanout",health:tn.health,snapshot:{snapshot:{graph:{"STRESS/SOURCE_A":["STRESS/FANOUT_1","STRESS/FANOUT_2","STRESS/FANOUT_3","STRESS/FANOUT_4","STRESS/FANOUT_5","STRESS/FANOUT_6"],"STRESS/SOURCE_B":["STRESS/FANOUT_1","STRESS/FANOUT_2"],"STRESS/FANOUT_1":["STRESS/SINK_1"],"STRESS/FANOUT_2":["STRESS/SINK_2"],"STRESS/FANOUT_3":["STRESS/SINK_3"],"STRESS/FANOUT_4":["STRESS/SINK_4"],"STRESS/FANOUT_5":["STRESS/SINK_5"],"STRESS/FANOUT_6":["STRESS/SINK_6"]},edge_owners:[],sessions:{"wide-session":{edges:[],metadata:{components:{STRESS:{name:"STRESS",component_type:"fixture.StressCollection",children:["STRESS/AGGREGATOR","STRESS/SINK_1","STRESS/SINK_2","STRESS/SINK_3","STRESS/SINK_4","STRESS/SINK_5","STRESS/SINK_6"]},"STRESS/AGGREGATOR":{name:"AGGREGATOR",component_type:"fixture.AggregatorUnit",streams:{INPUT_ALPHA:{address:"STRESS/SOURCE_A:input-alpha",msg_type:"builtins.str",leaky:!1},INPUT_BETA:{address:"STRESS/SOURCE_B:input-beta",msg_type:"builtins.str",leaky:!1},OUTPUT_1:{address:"STRESS/FANOUT_1:fanout-1",msg_type:"builtins.str",host:"127.0.0.1",port:9101},OUTPUT_2:{address:"STRESS/FANOUT_2:fanout-2",msg_type:"builtins.str",host:"127.0.0.1",port:9102},OUTPUT_3:{address:"STRESS/FANOUT_3:fanout-3",msg_type:"builtins.str",host:"127.0.0.1",port:9103},OUTPUT_4:{address:"STRESS/FANOUT_4:fanout-4",msg_type:"builtins.str",host:"127.0.0.1",port:9104},OUTPUT_5:{address:"STRESS/FANOUT_5:fanout-5",msg_type:"builtins.str",host:"127.0.0.1",port:9105},OUTPUT_6:{address:"STRESS/FANOUT_6:fanout-6",msg_type:"builtins.str",host:"127.0.0.1",port:9106}},tasks:[{name:"normalize_payload",subscribes:"STRESS/SOURCE_A",publishes:["STRESS/FANOUT_1","STRESS/FANOUT_2"]},{name:"deduplicate_messages",subscribes:"STRESS/SOURCE_B",publishes:["STRESS/FANOUT_3","STRESS/FANOUT_4"]},{name:"route_priority_messages",subscribes:"STRESS/SOURCE_A",publishes:["STRESS/FANOUT_5","STRESS/FANOUT_6"]}]},...Object.fromEntries(Array.from({length:6},(e,t)=>{const n=t+1;return[`STRESS/SINK_${n}`,{name:`SINK_${n}`,component_type:"fixture.DebugOutput",streams:{INPUT:{address:`STRESS/FANOUT_${n}:sink-${n}`,msg_type:"builtins.str",leaky:!1}},tasks:[{name:"on_message",subscribes:`STRESS/FANOUT_${n}`,publishes:[]}]}]}))}}}},processes:{"wide-process":{process_id:"wide-process",pid:4301,host:"fixture-host",units:["STRESS/AGGREGATOR","STRESS/SINK_1","STRESS/SINK_2","STRESS/SINK_3","STRESS/SINK_4","STRESS/SINK_5","STRESS/SINK_6"]}}},settings:{STRESS:De("STRESS","fixture.StressCollection",{mode:"stress"}),"STRESS/AGGREGATOR":De("AGGREGATOR","fixture.AggregatorUnit",{batch_size:64,strategy:"spread"})},profiling:{"wide-process":en("wide-process",4301)}}},a2={name:"long-labels",health:tn.health,snapshot:{snapshot:{graph:{"LONG_SCOPE/EXTRAORDINARILY_VERBOSE_PUBLISHER_TOPIC_NAME":["LONG_SCOPE/ULTRA_VERBOSE_SUBSCRIBER_TOPIC_NAME"]},edge_owners:[],sessions:{"long-session":{edges:[],metadata:{components:{LONG_SCOPE:{name:"EXTRAORDINARILY_VERBOSE_COLLECTION_NAME_FOR_LAYOUT_TESTING",component_type:"fixture.deep.namespace.ExtremelyLongCollectionComponentType",children:["LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME"]},"LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME":{name:"COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME",component_type:"fixture.deep.namespace.componenttypes.ExceptionallyLongComponentTypeName",streams:{OUTPUT_WITH_A_LONG_NAME:{address:"LONG_SCOPE/EXTRAORDINARILY_VERBOSE_PUBLISHER_TOPIC_NAME:publisher-endpoint-with-a-very-long-token",msg_type:"fixtures.messages.ReallyLongStructuredMessageTypeName",host:"127.0.0.1",port:9201},INPUT_WITH_A_LONG_NAME:{address:"LONG_SCOPE/ULTRA_VERBOSE_SUBSCRIBER_TOPIC_NAME:subscriber-endpoint-with-a-very-long-token",msg_type:"fixtures.messages.ReallyLongStructuredMessageTypeName",leaky:!1}},tasks:[{name:"task_with_a_surprisingly_long_name_for_a_single_render_chip",subscribes:"LONG_SCOPE/ULTRA_VERBOSE_SUBSCRIBER_TOPIC_NAME",publishes:["LONG_SCOPE/EXTRAORDINARILY_VERBOSE_PUBLISHER_TOPIC_NAME"]}]}}}}},processes:{"long-process":{process_id:"long-process",pid:4401,host:"fixture-host",units:["LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME"]}}},settings:{LONG_SCOPE:De("EXTRAORDINARILY_VERBOSE_COLLECTION_NAME_FOR_LAYOUT_TESTING","fixture.deep.namespace.ExtremelyLongCollectionComponentType",{debug_mode_enabled:!0}),"LONG_SCOPE/COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME":De("COMPONENT_WITH_EXCEPTIONALLY_LONG_NAME","fixture.deep.namespace.componenttypes.ExceptionallyLongComponentTypeName",{default_payload:"the_quick_brown_fox_jumps_over_the_lazy_dog_repeatedly_to_stress_text_overflow"})},profiling:{"long-process":en("long-process",4401)}}},u2={name:"semantic-stream-names",health:tn.health,snapshot:{snapshot:{graph:{"SIN/OUTPUT_SIGNAL_TOPIC":["SIN/WAVEFORM_TOPIC"]},edge_owners:[],sessions:{"semantic-stream-session":{edges:[],metadata:{components:{SIN:{name:"SIN",component_type:"fixture.LFO",streams:{INPUT_SIGNAL:Ft("SIN/INPUT_SIGNAL_TOPIC:sin-input-signal","fixtures.array.AxisArray"),INPUT_SETTINGS:Ft("SIN/INPUT_SETTINGS_TOPIC:sin-input-settings","fixtures.config.LFOSettings"),OUTPUT_SIGNAL:Xt("SIN/OUTPUT_SIGNAL_TOPIC:sin-output-signal",9211,"fixtures.array.AxisArray")},tasks:[ot("on_signal","SIN/INPUT_SIGNAL_TOPIC",[]),ot("on_settings","SIN/INPUT_SETTINGS_TOPIC",[]),ot("generate",null,["SIN/OUTPUT_SIGNAL_TOPIC"])]}}}}},processes:{"semantic-stream-process":{process_id:"semantic-stream-process",pid:4451,host:"fixture-host",units:["SIN"]}}},settings:{SIN:De("SIN","fixture.LFO",{freq:1.5,update_rate:60})},profiling:{"semantic-stream-process":en("semantic-stream-process",4451)}}},Xn=Array.from({length:6},(e,t)=>`TRACE_LAB/SPARSE_SUB_${Me(t+1)}`),Qn=Array.from({length:8},(e,t)=>`TRACE_LAB/DENSE_SUB_${Me(t+1)}`),c2={name:"profiling-trace-rates",health:tn.health,snapshot:{snapshot:{graph:Object.fromEntries([["TRACE_LAB/SPARSE_TOPIC",Xn.map((e,t)=>`TRACE_LAB/SPARSE_SUB_${Me(t+1)}_TOPIC`)],["TRACE_LAB/DENSE_TOPIC",Qn.map((e,t)=>`TRACE_LAB/DENSE_SUB_${Me(t+1)}_TOPIC`)]]),edge_owners:[],sessions:{"trace-session":{edges:[],metadata:{components:{TRACE_LAB:{name:"TRACE_LAB",component_type:"fixture.TraceLabCollection",children:["TRACE_LAB/SPARSE_PUB","TRACE_LAB/DENSE_PUB",...Xn,...Qn]},"TRACE_LAB/SPARSE_PUB":{name:"SPARSE_PUB",component_type:"fixture.TracePublisherUnit",streams:{OUTPUT:Xt("TRACE_LAB/SPARSE_TOPIC:sparse-publisher-endpoint",9901)},tasks:[ot("publish_sparse",null,["TRACE_LAB/SPARSE_TOPIC"])]},"TRACE_LAB/DENSE_PUB":{name:"DENSE_PUB",component_type:"fixture.TracePublisherUnit",streams:{OUTPUT:Xt("TRACE_LAB/DENSE_TOPIC:dense-publisher-endpoint",9902)},tasks:[ot("publish_dense",null,["TRACE_LAB/DENSE_TOPIC"])]},...Object.fromEntries(Xn.map((e,t)=>{const n=Me(t+1);return[e,{name:`SPARSE_SUB_${n}`,component_type:"fixture.TraceSubscriberUnit",streams:{INPUT:Ft(`TRACE_LAB/SPARSE_SUB_${n}_TOPIC:sparse-subscriber-${n}`)},tasks:[ot(`consume_sparse_${n}`,`TRACE_LAB/SPARSE_SUB_${n}_TOPIC`,[])]}]})),...Object.fromEntries(Qn.map((e,t)=>{const n=Me(t+1);return[e,{name:`DENSE_SUB_${n}`,component_type:"fixture.TraceSubscriberUnit",streams:{INPUT:Ft(`TRACE_LAB/DENSE_SUB_${n}_TOPIC:dense-subscriber-${n}`)},tasks:[ot(`consume_dense_${n}`,`TRACE_LAB/DENSE_SUB_${n}_TOPIC`,[])]}]}))}}}},processes:{"trace-process":{process_id:"trace-process",pid:5001,host:"fixture-host",units:["TRACE_LAB/SPARSE_PUB","TRACE_LAB/DENSE_PUB",...Xn,...Qn]}}},settings:{TRACE_LAB:De("TRACE_LAB","fixture.TraceLabCollection",{trace_enabled:!0}),"TRACE_LAB/SPARSE_PUB":De("SPARSE_PUB","fixture.TracePublisherUnit",{publish_rate_hz:1}),"TRACE_LAB/DENSE_PUB":De("DENSE_PUB","fixture.TracePublisherUnit",{publish_rate_hz:60})},profiling:{"trace-process":en("trace-process",5001,["TRACE_LAB/SPARSE_PUB","TRACE_LAB/DENSE_PUB",...Xn,...Qn],{"TRACE_LAB/SPARSE_TOPIC:sparse-publisher-endpoint":xp("sparse-publisher-endpoint","TRACE_LAB/SPARSE_TOPIC",{messagesPublishedWindow:2,publishRateHzWindow:1,numBuffers:4}),"TRACE_LAB/DENSE_TOPIC:dense-publisher-endpoint":xp("dense-publisher-endpoint","TRACE_LAB/DENSE_TOPIC",{messagesPublishedWindow:120,publishRateHzWindow:60,inflightCurrent:2,numBuffers:16})},{...Object.fromEntries(Xn.map((e,t)=>{const n=Me(t+1);return[`TRACE_LAB/SPARSE_SUB_${n}_TOPIC:sparse-subscriber-${n}`,wp(`sparse-subscriber-${n}`,`TRACE_LAB/SPARSE_SUB_${n}_TOPIC`,{messagesReceivedWindow:2,channelKindLast:t%2===0?"fifo":"shared_memory"})]})),...Object.fromEntries(Qn.map((e,t)=>{const n=Me(t+1);return[`TRACE_LAB/DENSE_SUB_${n}_TOPIC:dense-subscriber-${n}`,wp(`dense-subscriber-${n}`,`TRACE_LAB/DENSE_SUB_${n}_TOPIC`,{messagesReceivedWindow:120,channelKindLast:t<3?"tcp":t%2===0?"fifo":"shared_memory"})]}))})}},traceScenarios:[{processId:"trace-process",publisherEndpointId:"sparse-publisher-endpoint",publisherTopic:"TRACE_LAB/SPARSE_TOPIC",eventIntervalMs:140,samplesPerTick:1,timestampStepNs:1e9,publishDeltaNsBase:94e7,publishDeltaNsJitter:12e7,subscribers:Xn.map((e,t)=>{const n=Me(t+1);return{endpointId:`sparse-subscriber-${n}`,topic:`TRACE_LAB/SPARSE_SUB_${n}_TOPIC`,leaseTimeNsBase:7e6+t*8e5,userSpanNsBase:25e5+t*24e4}})},{processId:"trace-process",publisherEndpointId:"dense-publisher-endpoint",publisherTopic:"TRACE_LAB/DENSE_TOPIC",eventIntervalMs:100,samplesPerTick:12,timestampStepNs:16666667,publishDeltaNsBase:164e5,publishDeltaNsJitter:24e5,subscribers:Qn.map((e,t)=>{const n=Me(t+1);return{endpointId:`dense-subscriber-${n}`,topic:`TRACE_LAB/DENSE_SUB_${n}_TOPIC`,leaseTimeNsBase:13e5+t*14e4,userSpanNsBase:92e4+t*11e4}})}]},d2={name:"nested-collections",health:tn.health,snapshot:{snapshot:{graph:{"LAB/PIPELINE/ROOT_TOPIC":["LAB/PIPELINE/INNER/INNER_TOPIC"],"LAB/PIPELINE/INNER/INNER_TOPIC":["LAB/PIPELINE/LEAF_TOPIC"]},edge_owners:[],sessions:{"nested-session":{edges:[],metadata:{components:{LAB:{name:"LAB",component_type:"fixture.RootCollection",children:["LAB/PIPELINE"]},"LAB/PIPELINE":{name:"PIPELINE",component_type:"fixture.PipelineCollection",children:["LAB/PIPELINE/SOURCE","LAB/PIPELINE/INNER"],topics:{ROOT_TOPIC:{address:"LAB/PIPELINE/ROOT_TOPIC",msg_type:"builtins.str"}}},"LAB/PIPELINE/INNER":{name:"INNER",component_type:"fixture.InnerCollection",children:["LAB/PIPELINE/INNER/SINK"],topics:{INNER_TOPIC:{address:"LAB/PIPELINE/INNER/INNER_TOPIC",msg_type:"builtins.str"}}},"LAB/PIPELINE/SOURCE":{name:"SOURCE",component_type:"fixture.SourceUnit",streams:{OUTPUT:{address:"LAB/PIPELINE/ROOT_TOPIC:source-output",msg_type:"builtins.str",host:"127.0.0.1",port:9301}},tasks:[{name:"emit_root_topic",subscribes:null,publishes:["LAB/PIPELINE/ROOT_TOPIC"]}]},"LAB/PIPELINE/INNER/SINK":{name:"SINK",component_type:"fixture.SinkUnit",streams:{INPUT:{address:"LAB/PIPELINE/INNER/INNER_TOPIC:inner-input",msg_type:"builtins.str",leaky:!1},OUTPUT:{address:"LAB/PIPELINE/LEAF_TOPIC:leaf-output",msg_type:"builtins.str",host:"127.0.0.1",port:9302}},tasks:[{name:"relay_nested_topic",subscribes:"LAB/PIPELINE/INNER/INNER_TOPIC",publishes:["LAB/PIPELINE/LEAF_TOPIC"]}]},"CONTROL/PROBE":{name:"PROBE",component_type:"fixture.RootProbe",streams:{OUTPUT:{address:"CONTROL/PROBE_TOPIC:probe-output",msg_type:"builtins.str",host:"127.0.0.1",port:9303}},tasks:[{name:"probe_root_scope",subscribes:null,publishes:["CONTROL/PROBE_TOPIC"]}]}}}}},processes:{"nested-process":{process_id:"nested-process",pid:4501,host:"fixture-host",units:["LAB/PIPELINE/SOURCE","LAB/PIPELINE/INNER/SINK","CONTROL/PROBE"]}}},settings:{LAB:De("LAB","fixture.RootCollection",{enabled:!0}),"LAB/PIPELINE":De("PIPELINE","fixture.PipelineCollection",{stage_count:2}),"LAB/PIPELINE/INNER":De("INNER","fixture.InnerCollection",{nested:!0})},profiling:{"nested-process":en("nested-process",4501)}}},f2={name:"orphan-streams",health:tn.health,snapshot:{snapshot:{graph:{"ORPHAN/INPUT_TOPIC":["SYSTEM/PROCESS_TOPIC"],"SYSTEM/PROCESS_TOPIC":["ORPHAN/OUTPUT_TOPIC"]},edge_owners:[],sessions:{"orphan-session":{edges:[],metadata:{components:{"SYSTEM/PROCESSOR":{name:"PROCESSOR",component_type:"fixture.ProcessorUnit",streams:{INPUT:{address:"SYSTEM/PROCESS_TOPIC:processor-input",msg_type:"builtins.str",leaky:!1},OUTPUT:{address:"SYSTEM/PROCESS_TOPIC:processor-output",msg_type:"builtins.str",host:"127.0.0.1",port:9401}},tasks:[{name:"transform_orphan_stream",subscribes:"SYSTEM/PROCESS_TOPIC",publishes:["SYSTEM/PROCESS_TOPIC"]}]}}}}},processes:{"orphan-process":{process_id:"orphan-process",pid:4601,host:"fixture-host",units:["SYSTEM/PROCESSOR"]}}},settings:{"SYSTEM/PROCESSOR":De("PROCESSOR","fixture.ProcessorUnit",{amplify:2})},profiling:{"orphan-process":en("orphan-process",4601)}}},Ir=12,p2={name:"dense-unit-layout",health:tn.health,snapshot:{snapshot:{graph:Object.fromEntries(Array.from({length:Ir},(e,t)=>{const n=Me(t+1);return[`MATRIX/IN_${n}_TOPIC`,[`MATRIX/OUT_${n}_TOPIC`]]})),edge_owners:[],sessions:{"dense-unit-session":{edges:[],metadata:{components:{MATRIX:{name:"MATRIX",component_type:"fixture.MatrixCollection",children:["MATRIX/ROUTER"]},"MATRIX/ROUTER":{name:"ROUTER",component_type:"fixture.DenseRouter",streams:Object.fromEntries([...Array.from({length:Ir},(e,t)=>{const n=Me(t+1);return[`INPUT_${n}`,Ft(`MATRIX/IN_${n}_TOPIC:router-input-${n}`)]}),...Array.from({length:Ir},(e,t)=>{const n=Me(t+1);return[`OUTPUT_${n}`,Xt(`MATRIX/OUT_${n}_TOPIC:router-output-${n}`,9500+t)]})]),tasks:Array.from({length:Ir},(e,t)=>{const n=Me(t+1);return ot(`route_lane_${n}`,`MATRIX/IN_${n}_TOPIC`,[`MATRIX/OUT_${n}_TOPIC`])})}}}}},processes:{"dense-unit-process":{process_id:"dense-unit-process",pid:4701,host:"fixture-host",units:["MATRIX/ROUTER"]}}},settings:{MATRIX:De("MATRIX","fixture.MatrixCollection",{lanes:Ir}),"MATRIX/ROUTER":De("ROUTER","fixture.DenseRouter",{lanes:Ir,parallelism:4})},profiling:{"dense-unit-process":en("dense-unit-process",4701)}}},on=12,ci=Array.from({length:on},(e,t)=>`MEGA/SRC_${Me(t+1)}`),di=Array.from({length:on},(e,t)=>`MEGA/SINK_${Me(t+1)}`),h2={name:"massive-fanout",health:tn.health,snapshot:{snapshot:{graph:Object.fromEntries([...Array.from({length:on},(e,t)=>{const n=Me(t+1);return[`MEGA/SRC_${n}_TOPIC`,[`MEGA/HUB_IN_${n}_TOPIC`]]}),...Array.from({length:on},(e,t)=>{const n=Me(t+1);return[`MEGA/HUB_OUT_${n}_TOPIC`,[`MEGA/SINK_${n}_IN_TOPIC`]]})]),edge_owners:[],sessions:{"mega-session":{edges:[],metadata:{components:{MEGA:{name:"MEGA",component_type:"fixture.MegaScope",children:[...ci,"MEGA/HUB",...di]},...Object.fromEntries(ci.map((e,t)=>{const n=Me(t+1);return[e,{name:`SRC_${n}`,component_type:"fixture.SourceUnit",streams:{OUTPUT:Xt(`MEGA/SRC_${n}_TOPIC:source-output-${n}`,9600+t)},tasks:[ot(`emit_lane_${n}`,null,[`MEGA/SRC_${n}_TOPIC`])]}]})),"MEGA/HUB":{name:"HUB",component_type:"fixture.HubRouter",streams:Object.fromEntries([...Array.from({length:on},(e,t)=>{const n=Me(t+1);return[`INPUT_${n}`,Ft(`MEGA/HUB_IN_${n}_TOPIC:hub-input-${n}`)]}),...Array.from({length:on},(e,t)=>{const n=Me(t+1);return[`OUTPUT_${n}`,Xt(`MEGA/HUB_OUT_${n}_TOPIC:hub-output-${n}`,9700+t)]})]),tasks:Array.from({length:on},(e,t)=>{const n=Me(t+1);return ot(`fanout_lane_${n}`,`MEGA/HUB_IN_${n}_TOPIC`,[`MEGA/HUB_OUT_${n}_TOPIC`])})},...Object.fromEntries(di.map((e,t)=>{const n=Me(t+1);return[e,{name:`SINK_${n}`,component_type:"fixture.SinkUnit",streams:{INPUT:Ft(`MEGA/SINK_${n}_IN_TOPIC:sink-input-${n}`)},tasks:[ot(`consume_lane_${n}`,`MEGA/SINK_${n}_IN_TOPIC`,[])]}]}))}}}},processes:{"mega-process":{process_id:"mega-process",pid:4801,host:"fixture-host",units:[...ci,"MEGA/HUB",...di]}}},settings:{MEGA:De("MEGA","fixture.MegaScope",{lanes:on}),"MEGA/HUB":De("HUB","fixture.HubRouter",{lanes:on,fanout_mode:"parallel"})},profiling:{"mega-process":en("mega-process",4801,[...ci,"MEGA/HUB",...di])}}},m2={name:"cyclic-feedback",health:tn.health,snapshot:{snapshot:{graph:{"ALPHA/OUT_TOPIC":["BETA/IN_TOPIC"],"BETA/OUT_TOPIC":["GAMMA/IN_TOPIC"],"GAMMA/OUT_TOPIC":["ALPHA/IN_TOPIC"],"GAMMA/AUDIT_TOPIC":["MONITOR/IN_TOPIC"]},edge_owners:[],sessions:{"cycle-session":{edges:[],metadata:{components:{ALPHA:{name:"ALPHA",component_type:"fixture.FeedbackStage",streams:{INPUT:Ft("ALPHA/IN_TOPIC:alpha-input"),OUTPUT:Xt("ALPHA/OUT_TOPIC:alpha-output",9801)},tasks:[ot("forward_alpha","ALPHA/IN_TOPIC",["ALPHA/OUT_TOPIC"])]},BETA:{name:"BETA",component_type:"fixture.FeedbackStage",streams:{INPUT:Ft("BETA/IN_TOPIC:beta-input"),OUTPUT:Xt("BETA/OUT_TOPIC:beta-output",9802)},tasks:[ot("forward_beta","BETA/IN_TOPIC",["BETA/OUT_TOPIC"])]},GAMMA:{name:"GAMMA",component_type:"fixture.FeedbackStage",streams:{INPUT:Ft("GAMMA/IN_TOPIC:gamma-input"),OUTPUT:Xt("GAMMA/OUT_TOPIC:gamma-output",9803),OUTPUT_AUDIT:Xt("GAMMA/AUDIT_TOPIC:gamma-audit",9804)},tasks:[ot("fanout_gamma","GAMMA/IN_TOPIC",["GAMMA/OUT_TOPIC","GAMMA/AUDIT_TOPIC"])]},MONITOR:{name:"MONITOR",component_type:"fixture.MonitorUnit",streams:{INPUT:Ft("MONITOR/IN_TOPIC:monitor-input")},tasks:[ot("observe_cycle","MONITOR/IN_TOPIC",[])]}}}}},processes:{"cycle-process":{process_id:"cycle-process",pid:4901,host:"fixture-host",units:["ALPHA","BETA","GAMMA","MONITOR"]}}},settings:{ALPHA:De("ALPHA","fixture.FeedbackStage",{gain:1}),GAMMA:De("GAMMA","fixture.FeedbackStage",{audit_enabled:!0})},profiling:{"cycle-process":en("cycle-process",4901)}}},g2={"root-scope-navigation":tn,"wide-fanout":l2,"long-labels":a2,"semantic-stream-names":u2,"profiling-trace-rates":c2,"nested-collections":d2,"orphan-streams":f2,"dense-unit-layout":p2,"massive-fanout":h2,"cyclic-feedback":m2};function y2(e){return e?g2[e]??null:null}const v2=120,_2=250,x2=1e3,w2=.05,S2=5e3,E2=60;function br(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function N2(){return typeof window>"u"?null:new URLSearchParams(window.location.search).get("fixture")}function T2(e,t,n){const r=t.split(".").filter(i=>i.length>0);if(r.length===0)return n;const s=e&&typeof e=="object"&&!Array.isArray(e)?br(e):{};let o=s;return r.forEach((i,l)=>{if(l===r.length-1){o[i]=n;return}const u=o[i],c=u&&typeof u=="object"&&!Array.isArray(u)?{...u}:{};o[i]=c,o=c}),s}function Sp(e,t){return t}function k2(e,t,n){return Math.min(n,Math.max(t,e))}function C2(e){const t=Sp(void 0,w2),n=Math.max(1,Math.trunc(Sp(void 0,S2))),r=new URLSearchParams({profiling_interval:t.toString(),profiling_max_samples:n.toString()}).toString(),s=e.includes("?")?"&":"?";return`${e}${s}${r}`}function I2(){const e=window.location.protocol==="https:"?"wss":"ws";return C2(`${e}://${window.location.host}/ws/events`)}async function Ep(e){const t=e.includes("?")?"&":"?",n=`${e}${t}_ts=${Date.now()}`,r=await fetch(n,{cache:"no-store",headers:{"Cache-Control":"no-cache",Pragma:"no-cache"}});if(!r.ok)throw new Error(`${e} failed (${r.status})`);return await r.json()}async function Np(e,t){const n=e.includes("?")?"&":"?",r=`${e}${n}_ts=${Date.now()}`,s=await fetch(r,{method:"POST",cache:"no-store",headers:{"Content-Type":"application/json","Cache-Control":"no-cache",Pragma:"no-cache"},body:JSON.stringify(t)});if(!s.ok){let o=`${e} failed (${s.status})`;try{const i=await s.json();typeof i.detail=="string"&&i.detail.length>0&&(o=i.detail)}catch{}throw new Error(o)}return await s.json()}function Tp(e){return typeof e=="object"&&e!==null}function b2(e){return Tp(e)?typeof e.kind=="string"&&Tp(e.data):!1}function P2(e){const[t,n]=E.useState(null),[r,s]=E.useState(null),[o,i]=E.useState(null),[l,a]=E.useState([]),[u,c]=E.useState("connecting"),[d,f]=E.useState(null),[h,x]=E.useState(null),_=Math.round(k2(((e==null?void 0:e.snapshotPollSeconds)??2)*1e3,500,3e4)),T=E.useMemo(()=>y2(N2()),[]),p=E.useRef(null),g=E.useRef(null),y=E.useRef(new Map),w=E.useRef(new Map),P=E.useRef(new Map),O=E.useCallback(k=>{const N=y.current.get(k);N!==void 0&&(window.clearInterval(N),y.current.delete(k))},[]),L=E.useCallback(()=>{for(const k of y.current.values())window.clearInterval(k);y.current.clear(),w.current.clear(),P.current.clear()},[]),R=E.useCallback(async()=>{if(T){const N=br(T.snapshot);s(N),x(Date.now());return}const k=await Ep("/api/snapshot");s(k),x(Date.now())},[T]),F=E.useCallback(async()=>{if(T){n(br(T.health));return}const k=await Ep("/api/health");n(k)},[T]);E.useEffect(()=>{if(T)return L(),n(br(T.health)),s(br(T.snapshot)),i(null),a([]),c("open"),f(null),x(Date.now()),()=>{L()}},[L,T]);const D=E.useCallback(()=>{p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{R().catch(k=>{const N=k instanceof Error?k.message:"Snapshot refresh failed.";f(N)}),p.current=null},_2)},[R]);E.useEffect(()=>{T||(F().catch(k=>{const N=k instanceof Error?k.message:"Health check failed.";f(N)}),R().catch(k=>{const N=k instanceof Error?k.message:"Initial snapshot failed.";f(N)}))},[T,F,R]),E.useEffect(()=>{if(T)return;const k=window.setInterval(()=>{R().catch(N=>{const M=N instanceof Error?N.message:"Snapshot poll failed.";f(M)})},_);return()=>{window.clearInterval(k)}},[T,R,_]),E.useEffect(()=>{if(T)return;let k=!1,N=null;const M=()=>{k||(c("connecting"),N=new WebSocket(I2()),N.onopen=()=>{k||(c("open"),f(null))},N.onmessage=C=>{let S=null;try{S=JSON.parse(C.data)}catch{return}if(!b2(S))return;const b=S;a(B=>[b,...B].slice(0,v2)),b.kind==="topology.changed"&&D(),b.kind==="settings.changed"&&s(B=>{if(!B)return B;const j=b,Y=B.settings[j.data.component_address]??null,Q={...B.settings,[j.data.component_address]:{...j.data.value,patchable:(Y==null?void 0:Y.patchable)??!1,patch_error:(Y==null?void 0:Y.patch_error)??null,component_type:(Y==null?void 0:Y.component_type)??null,component_name:(Y==null?void 0:Y.component_name)??null}};return{...B,settings:Q}}),b.kind==="profiling.trace"&&i(b),b.kind==="system.error"&&f(b.data.message)},N.onerror=()=>{k||c("closed")},N.onclose=()=>{k||(c("closed"),g.current=window.setTimeout(()=>{M()},x2))})};return M(),()=>{k=!0,N!==null&&N.close(),g.current!==null&&window.clearTimeout(g.current),p.current!==null&&window.clearTimeout(p.current)}},[T,D]);const H=E.useMemo(()=>l.filter(k=>k.kind==="topology.changed"),[l]),Z=E.useCallback(async()=>{try{await R()}catch(k){const N=k instanceof Error?k.message:"Snapshot refresh failed.";f(N)}},[R]),U=E.useCallback(async(k,N,M,C=2)=>{if(T){let B=null;return s(j=>{if(!j)return j;const Y=j.settings[k];if(!Y)return j;const Q=Y.structured_value??Y.repr_value,ne=T2(Q,N,M);return B={...Y,structured_value:ne,repr_value:ne},{...j,settings:{...j.settings,[k]:B}}}),x(Date.now()),{component_address:k,field_path:N,updated_value:B??br(T.snapshot.settings[k])}}const S=encodeURIComponent(k),b=await Np(`/api/settings/${S}/field`,{field_path:N,value:M,timeout:C});return s(B=>{if(!B)return B;const j=B.settings[b.component_address]??null;return{...B,settings:{...B.settings,[b.component_address]:{...b.updated_value,patchable:(j==null?void 0:j.patchable)??!0,patch_error:(j==null?void 0:j.patch_error)??null,component_type:(j==null?void 0:j.component_type)??null,component_name:(j==null?void 0:j.component_name)??null}}}}),x(Date.now()),b},[T]),v=E.useCallback(async k=>{if(T){const N=`${k.process_id}:${k.publisher_endpoint_id??"*"}`;if(!k.enabled){if(k.publisher_endpoint_id)O(N);else for(const C of Array.from(y.current.keys()))C.startsWith(`${k.process_id}:`)&&O(C);return{process_id:k.process_id,unit_address:"",enabled:!1,control:{fixture:!0,metrics:k.metrics??[]}}}const M=(T.traceScenarios??[]).find(C=>C.processId===k.process_id&&C.publisherEndpointId===k.publisher_endpoint_id&&C.publisherTopic===k.publisher_topic);if(M){O(N),P.current.has(N)||P.current.set(N,Date.now()*1e6),w.current.has(N)||w.current.set(N,0);const C=()=>{const b=P.current.get(N)??Date.now()*1e6,B=w.current.get(N)??0,j=[],Y=new Set(k.metrics??[]),Q=Y.size===0||Y.has("publish_delta_ns"),ne=Y.size===0||Y.has("lease_time_ns"),se=Y.size===0||Y.has("user_span_ns");for(let fe=0;fe=9466848e5&&e<=41024448e5?e:e>=946684800&&e<=4102444800?e*1e3:null}function j2(e){return e.toLowerCase().includes("collection")}function F2(e){if(e.kind==="unit")return{kind:"unit",unitAddress:e.unitAddress};if(e.kind==="collection")return{kind:"collection",collectionAddress:e.collectionAddress};const t=z_(e.streamAddress);return{kind:e.kind,unitAddress:e.unitAddress,endpointId:t.endpointId,topic:t.topic}}function z2(e,t){var r;const n=((r=t==null?void 0:t[e])==null?void 0:r.component_type)??"";return j2(n)?{kind:"collection",collectionAddress:e}:{kind:"unit",unitAddress:e}}function D2(e){return(e==null?void 0:e.kind)==="unit"?e.unitAddress:(e==null?void 0:e.kind)==="collection"?e.collectionAddress:null}function U2(e){if(!e||typeof e!="object")return Mt;const t=e,n=typeof t.snapshotPollSeconds=="number"&&Number.isFinite(t.snapshotPollSeconds)?Math.min(30,Math.max(.5,t.snapshotPollSeconds)):Mt.snapshotPollSeconds,r=typeof t.inspectorWidthPx=="number"&&Number.isFinite(t.inspectorWidthPx)?Math.min(900,Math.max(360,Math.round(t.inspectorWidthPx))):Mt.inspectorWidthPx,s=t.traceMetricsPreset==="publish+lease"||t.traceMetricsPreset==="publish"||t.traceMetricsPreset==="publish+lease+user"?t.traceMetricsPreset:Mt.traceMetricsPreset,o=t.edgeConnectorStyle==="orthogonal"||t.edgeConnectorStyle==="smooth"||t.edgeConnectorStyle==="curved"?t.edgeConnectorStyle:Mt.edgeConnectorStyle;return{snapshotPollSeconds:n,themeMode:t.themeMode==="dark"?"dark":"light",topologyDefaultLayout:t.topologyDefaultLayout==="lr"?"lr":"tb",edgeConnectorStyle:o,showLegend:typeof t.showLegend=="boolean"?t.showLegend:Mt.showLegend,showMiniMap:typeof t.showMiniMap=="boolean"?t.showMiniMap:Mt.showMiniMap,traceMetricsPreset:s,autoFitOnLayoutScopeChange:typeof t.autoFitOnLayoutScopeChange=="boolean"?t.autoFitOnLayoutScopeChange:Mt.autoFitOnLayoutScopeChange,autoFocusOnInspectorSelection:typeof t.autoFocusOnInspectorSelection=="boolean"?t.autoFocusOnInspectorSelection:Mt.autoFocusOnInspectorSelection,inspectorWidthPx:r}}function H2(e,t,n){const r=[],s=[];return e==="closed"?r.push("WebSocket disconnected"):e==="connecting"&&s.push("WebSocket connecting"),t===null?s.push("Graph health pending"):t||r.push("Graph session inactive"),n&&r.push(n),r.length>0?{tone:"err",tooltip:r.join(" · ")}:s.length>0?{tone:"warn",tooltip:s.join(" · ")}:{tone:"ok",tooltip:"Connected: GraphServer reachable, WebSocket open, session active."}}function W2(){const[e,t]=E.useState(null),[n,r]=E.useState(!1),[s,o]=E.useState(0),[i,l]=E.useState(0),[a,u]=E.useState(!1),[c,d]=E.useState(!0),[f,h]=E.useState(!1),[x,_]=E.useState(null),[T,p]=E.useState(0),[g,y]=E.useState(null),[w,P]=E.useState(null),[O,L]=E.useState(0),[R,F]=E.useState(()=>{try{const I=window.localStorage.getItem(kp);return I?U2(JSON.parse(I)):Mt}catch{return Mt}});E.useEffect(()=>{window.localStorage.setItem(kp,JSON.stringify(R))},[R]);const{health:D,snapshot:H,latestTraceEvent:Z,connectionState:U,error:v,lastSnapshotUpdateMs:k,topologyEvents:N,patchSettingField:M,setProfilingTraceControl:C}=P2({snapshotPollSeconds:R.snapshotPollSeconds}),S=E.useMemo(()=>{let I=0;for(const G of Object.values((H==null?void 0:H.profiling)??{}))if(typeof G.timestamp=="number"&&Number.isFinite(G.timestamp)){const X=B2(G.timestamp);X!==null&&(I=Math.max(I,X))}return I<=0?k:I},[k,H==null?void 0:H.profiling]),b=D!=null&&D.graph_address&&D.graph_address.length>0?D.graph_address:$2,B=S?new Date(S).toLocaleTimeString():"n/a",j=E.useMemo(()=>H2(U,(D==null?void 0:D.graph_session_active)??null,v),[U,D==null?void 0:D.graph_session_active,v]),Y=E.useMemo(()=>R.traceMetricsPreset==="publish"?["publish_delta_ns"]:R.traceMetricsPreset==="publish+lease"?["publish_delta_ns","lease_time_ns"]:["publish_delta_ns","lease_time_ns","user_span_ns"],[R.traceMetricsPreset]),Q=E.useMemo(()=>({"--inspector-width":`${R.inspectorWidthPx}px`}),[R.inspectorWidthPx]),ne=I=>{if(P(null),!I){t(null);return}h(!1);const G=F2(I);G.kind==="unit"||G.kind==="collection"?(d(!1),l(X=>X+1)):(u(!1),o(X=>X+1)),t(G)},se=I=>{P(I),L(G=>G+1)},fe=()=>{p(I=>I+1),_(null)},W=()=>{if(a){u(!1);return}if(c){u(!0),d(!1);return}u(!0)},A=()=>{if(c){d(!1);return}if(a){d(!0),u(!1);return}d(!0)};return m.jsxs("div",{className:`dashboard-layout is-comfortable ${f?"is-inspector-collapsed ":""}${R.themeMode==="dark"?"is-dark":""}`,style:Q,children:[m.jsx("aside",{className:"dashboard-inspector dashboard-inspector--pinned",children:m.jsxs("div",{className:`dashboard-inspector__body ${a?"is-publishers-collapsed ":""}${c?"is-settings-collapsed":""}`,children:[m.jsxs("section",{className:"inspector-section inspector-section--split",children:[m.jsxs("header",{className:"inspector-section__header",children:[m.jsx("span",{children:"Publishers"}),m.jsx("button",{type:"button",className:"inspector-section__collapse-btn",onClick:W,children:a?"Expand":"Collapse"})]}),a?null:m.jsx("div",{className:"inspector-section__content inspector-section__content--scroll",children:m.jsx(t1,{graphSnapshot:(H==null?void 0:H.snapshot)??null,profilingSnapshot:(H==null?void 0:H.profiling)??null,latestTraceEvent:Z,setProfilingTraceControl:C,darkMode:R.themeMode==="dark",focusPublisherEndpointId:(e==null?void 0:e.kind)==="publisher"?e.endpointId:null,focusPublisherTopic:(e==null?void 0:e.kind)==="publisher"?e.topic:null,focusSubscriberEndpointId:(e==null?void 0:e.kind)==="subscriber"?e.endpointId:null,focusActionId:s,hideFilters:!1,defaultTraceMetrics:Y,traceDockHost:g,onTraceDockStateChange:_,traceCloseSignal:T,onPublisherSelect:I=>{t({kind:"publisher",unitAddress:I.unitAddress,endpointId:I.endpointId,topic:I.topic}),se({kind:"publisher",streamAddress:`${I.topic}:${I.endpointId}`,unitAddress:I.unitAddress})},onSubscriberSelect:I=>{t({kind:"subscriber",unitAddress:I.unitAddress,endpointId:I.endpointId,topic:I.topic}),se({kind:"subscriber",streamAddress:`${I.topic}:${I.endpointId}`,unitAddress:I.unitAddress})}})})]}),m.jsxs("section",{className:"inspector-section inspector-section--split",children:[m.jsxs("header",{className:"inspector-section__header",children:[m.jsx("span",{children:"Settings"}),m.jsx("button",{type:"button",className:"inspector-section__collapse-btn",onClick:A,children:c?"Expand":"Collapse"})]}),c?null:m.jsx("div",{className:"inspector-section__content inspector-section__content--scroll",children:m.jsx(i1,{settings:(H==null?void 0:H.settings)??null,patchSettingField:M,focusComponentAddress:D2(e),focusActionId:i,onComponentSelect:I=>{if(!I){t(null);return}l(X=>X+1);const G=z2(I,H==null?void 0:H.settings);t(G),se(G.kind==="collection"?{kind:"collection",collectionAddress:G.collectionAddress}:{kind:"unit",unitAddress:G.unitAddress})}})})]})]})}),m.jsxs("div",{className:"dashboard-main",children:[m.jsxs("div",{className:"dashboard-viewport",children:[m.jsx(i2,{graphSnapshot:(H==null?void 0:H.snapshot)??null,profilingSnapshot:(H==null?void 0:H.profiling)??null,recentEvents:N,immersive:!0,showLegend:R.showLegend,showMiniMap:R.showMiniMap,darkMode:R.themeMode==="dark",defaultLayout:R.topologyDefaultLayout,edgeConnectorStyle:R.edgeConnectorStyle,autoFitOnLayoutScopeChange:R.autoFitOnLayoutScopeChange,autoFocusOnSelection:R.autoFocusOnInspectorSelection,focusSelection:w,focusRequestId:O,onEntitySelect:ne}),m.jsxs("section",{className:"dashboard-brand-card",children:[m.jsx("span",{className:`dashboard-health-dot is-${j.tone}`,title:j.tooltip,"aria-label":j.tooltip}),m.jsx("img",{src:A2,alt:"ezmsg",className:"dashboard-brand-logo-image"}),m.jsx("div",{className:"dashboard-brand-card__title-row",children:m.jsx("h1",{className:"mono",children:"ezmsg-dashboard"})}),m.jsxs("p",{className:"dashboard-brand-card__meta-line",children:[m.jsxs("span",{className:"mono",children:["GraphServer ",b]}),m.jsx("span",{children:"·"}),m.jsxs("span",{className:"mono",children:["Snapshot ",B]})]})]}),m.jsxs("div",{className:"dashboard-floating-control-dock","aria-label":"Viewport shortcuts",children:[m.jsx("button",{type:"button",className:"topology-layout-btn dashboard-floating-shortcut-btn",onClick:()=>F(I=>({...I,topologyDefaultLayout:I.topologyDefaultLayout==="lr"?"tb":"lr"})),title:R.topologyDefaultLayout==="lr"?"Topology layout: left-to-right":"Topology layout: top-to-bottom","aria-label":R.topologyDefaultLayout==="lr"?"Topology layout left-to-right":"Topology layout top-to-bottom",children:R.topologyDefaultLayout==="lr"?m.jsx(L2,{}):m.jsx(O2,{})}),m.jsx("button",{type:"button",className:"topology-layout-btn dashboard-floating-shortcut-btn",onClick:()=>F(I=>({...I,themeMode:I.themeMode==="dark"?"light":"dark"})),title:R.themeMode==="dark"?"Theme: dark":"Theme: light","aria-label":R.themeMode==="dark"?"Theme dark":"Theme light",children:R.themeMode==="dark"?m.jsx(M2,{}):m.jsx(R2,{})}),m.jsx("button",{type:"button",className:"topology-layout-btn dashboard-floating-gear-btn",onClick:()=>r(!0),title:"Global Settings","aria-label":"Global Settings",children:"⚙"})]}),m.jsx("button",{type:"button",className:`topology-layout-btn dashboard-floating-inspector-btn ${f?"is-collapsed":""}`.trim(),onClick:()=>h(I=>!I),title:f?"Show Inspector":"Hide Inspector","aria-label":f?"Show Inspector":"Hide Inspector",children:f?"«":"»"}),n?m.jsx("div",{className:"dashboard-modal-backdrop",onClick:()=>r(!1),children:m.jsxs("section",{className:"dashboard-modal",onClick:I=>I.stopPropagation(),children:[m.jsxs("header",{className:"dashboard-modal__header",children:[m.jsx("h2",{children:"Global Settings"}),m.jsx("button",{type:"button",className:"topology-layout-btn",onClick:()=>r(!1),children:"Close"})]}),m.jsxs("div",{className:"dashboard-modal__body",children:[m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Snapshot Poll Frequency (seconds)"}),m.jsx("input",{type:"number",min:.5,max:30,step:.5,value:R.snapshotPollSeconds,onChange:I=>{const G=Number.parseFloat(I.target.value);Number.isFinite(G)&&F(X=>({...X,snapshotPollSeconds:Math.max(.5,Math.min(30,G))}))}})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Theme"}),m.jsxs("select",{value:R.themeMode,onChange:I=>F(G=>({...G,themeMode:I.target.value==="dark"?"dark":"light"})),children:[m.jsx("option",{value:"light",children:"Light"}),m.jsx("option",{value:"dark",children:"Dark"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Default Topology Layout"}),m.jsxs("select",{value:R.topologyDefaultLayout,onChange:I=>F(G=>({...G,topologyDefaultLayout:I.target.value==="lr"?"lr":"tb"})),children:[m.jsx("option",{value:"tb",children:"Top to Bottom"}),m.jsx("option",{value:"lr",children:"Left to Right"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Edge Connector Type"}),m.jsxs("select",{value:R.edgeConnectorStyle,onChange:I=>F(G=>({...G,edgeConnectorStyle:I.target.value==="orthogonal"||I.target.value==="smooth"?I.target.value:"curved"})),children:[m.jsx("option",{value:"curved",children:"Curved (Bezier)"}),m.jsx("option",{value:"orthogonal",children:"Orthogonal (Step)"}),m.jsx("option",{value:"smooth",children:"Smooth Step"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Default Trace Metrics"}),m.jsxs("select",{value:R.traceMetricsPreset,onChange:I=>F(G=>({...G,traceMetricsPreset:I.target.value==="publish"||I.target.value==="publish+lease"?I.target.value:"publish+lease+user"})),children:[m.jsx("option",{value:"publish+lease+user",children:"Publish + Lease + User"}),m.jsx("option",{value:"publish+lease",children:"Publish + Lease"}),m.jsx("option",{value:"publish",children:"Publish Only"})]})]}),m.jsxs("label",{className:"dashboard-setting-row",children:[m.jsx("span",{children:"Inspector Width (px)"}),m.jsx("input",{type:"number",min:360,max:900,step:10,value:R.inspectorWidthPx,onChange:I=>{const G=Number.parseInt(I.target.value,10);Number.isFinite(G)&&F(X=>({...X,inspectorWidthPx:Math.max(360,Math.min(900,G))}))}})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:R.autoFocusOnInspectorSelection,onChange:I=>F(G=>({...G,autoFocusOnInspectorSelection:I.target.checked}))}),m.jsx("span",{children:"Auto-focus topology on inspector selection"})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:R.autoFitOnLayoutScopeChange,onChange:I=>F(G=>({...G,autoFitOnLayoutScopeChange:I.target.checked}))}),m.jsx("span",{children:"Auto-fit on layout/scope change"})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:R.showLegend,onChange:I=>F(G=>({...G,showLegend:I.target.checked}))}),m.jsx("span",{children:"Show legend"})]}),m.jsxs("label",{className:"dashboard-setting-toggle",children:[m.jsx("input",{type:"checkbox",checked:R.showMiniMap,onChange:I=>F(G=>({...G,showMiniMap:I.target.checked}))}),m.jsx("span",{children:"Show minimap"})]})]})]})}):null]}),x!=null&&x.active?m.jsxs("section",{className:"trace-dock",children:[m.jsxs("header",{className:"trace-dock__header",children:[m.jsx("div",{className:"trace-dock__title-wrap",children:m.jsx("h3",{children:"Realtime Profiling Trace"})}),m.jsxs("div",{className:"trace-dock__actions",children:[m.jsx("span",{className:`trace-status ${x.status==="capturing"?"is-live":""}`,children:x.status}),m.jsx("button",{type:"button",className:"topology-layout-btn trace-dock__close-btn",onClick:fe,title:"Close trace","aria-label":"Close trace",children:"✕"})]})]}),m.jsx("div",{className:"trace-dock__body",children:m.jsx("div",{className:"trace-dock__host",ref:y})})]}):null]})]})}Ra.createRoot(document.getElementById("root")).render(m.jsx(V.StrictMode,{children:m.jsx(W2,{})})); diff --git a/src/ezmsg/dashboard/_web/index.html b/src/ezmsg/dashboard/_web/index.html index 4cbe944..69e9a87 100644 --- a/src/ezmsg/dashboard/_web/index.html +++ b/src/ezmsg/dashboard/_web/index.html @@ -5,7 +5,7 @@ ezmsg-dashboard - +