diff --git a/go.mod b/go.mod index b4ff0fa..7a027a5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/RandomCodeSpace/otelcontext -go 1.25.10 +go 1.25.11 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.21.1 diff --git a/internal/api/log_handlers.go b/internal/api/log_handlers.go index 2cbc9d5..47fd997 100644 --- a/internal/api/log_handlers.go +++ b/internal/api/log_handlers.go @@ -15,19 +15,7 @@ import ( // handleGetLogs handles GET /api/logs with advanced filtering func (s *Server) handleGetLogs(w http.ResponseWriter, r *http.Request) { - limit := 50 - offset := 0 - - if l := r.URL.Query().Get("limit"); l != "" { - if v, err := strconv.Atoi(l); err == nil { - limit = v - } - } - if o := r.URL.Query().Get("offset"); o != "" { - if v, err := strconv.Atoi(o); err == nil { - offset = v - } - } + limit, offset := parsePaging(r, pagingDefaultLimit) filter := storage.LogFilter{ ServiceName: r.URL.Query().Get("service_name"), diff --git a/internal/api/log_handlers_cap_test.go b/internal/api/log_handlers_cap_test.go index 7a14401..63689a6 100644 --- a/internal/api/log_handlers_cap_test.go +++ b/internal/api/log_handlers_cap_test.go @@ -55,6 +55,45 @@ func TestHandleGetLogs_NoSearchSkipsCap(t *testing.T) { } } +// TestParsePaging_Clamp verifies that parsePaging enforces bounds on limit and +// offset, preventing GORM from receiving a negative Limit (treated as unlimited) +// or a negative offset. +func TestParsePaging_Clamp(t *testing.T) { + cases := []struct { + query string + defaultLimit int + wantLimit int + wantOffset int + }{ + // Over-limit capped at 1000. + {"limit=9999&offset=0", 50, 1000, 0}, + // Negative limit floored at 1. + {"limit=-5&offset=0", 50, 1, 0}, + // Negative offset floored at 0. + {"limit=10&offset=-99", 50, 10, 0}, + // Both negative. + {"limit=-1&offset=-1", 50, 1, 0}, + // Default limit also clamped. + {"", 9999, 1000, 0}, + // Valid values pass through unchanged. + {"limit=100&offset=200", 50, 100, 200}, + // Exact cap boundary. + {"limit=1000&offset=0", 50, 1000, 0}, + } + for _, tc := range cases { + t.Run(tc.query, func(t *testing.T) { + req := httptest.NewRequest(http.MethodGet, "/api/logs?"+tc.query, nil) + gotLimit, gotOffset := parsePaging(req, tc.defaultLimit) + if gotLimit != tc.wantLimit { + t.Errorf("limit: got %d, want %d", gotLimit, tc.wantLimit) + } + if gotOffset != tc.wantOffset { + t.Errorf("offset: got %d, want %d", gotOffset, tc.wantOffset) + } + }) + } +} + // newAPITestRepoWithoutFTS builds a fresh in-memory repo with FTS5 disabled. // Used by cap tests since they only care about handler behavior, not the // search backend. diff --git a/internal/api/middleware_test.go b/internal/api/middleware_test.go index 511d263..4204970 100644 --- a/internal/api/middleware_test.go +++ b/internal/api/middleware_test.go @@ -133,6 +133,41 @@ func TestTenantMiddleware_MissingHeaderUsesDefault(t *testing.T) { } } +// TestTenantMiddleware_DoesNotOverwritePinnedTenant verifies that when +// TenantKeyAuth.Middleware has already pinned a tenant onto the context (the +// per-tenant API-key path), the subsequent TenantMiddleware pass-through does +// NOT overwrite it with the client-supplied X-Tenant-ID header. +// +// This is the regression test for the middleware-ordering bypass: +// +// TenantKeyAuth.Middleware(auth "alpha-key" → pins "alpha") +// → TenantMiddleware(reads X-Tenant-ID: "beta" → must NOT overwrite) +// → handler (must see "alpha") +func TestTenantMiddleware_DoesNotOverwritePinnedTenant(t *testing.T) { + // Build per-tenant key auth: key "alpha-key" → tenant "alpha". + auth := NewTenantKeyAuth(map[string]string{"alpha-key": "alpha"}) + + cfg := &config.Config{DefaultTenant: "default"} + tc := &tenantCapture{} + + // Compose: TenantKeyAuth wraps TenantMiddleware wraps handler. + h := auth.Middleware("/mcp", TenantMiddleware(cfg)(tc.handler())) + + req := httptest.NewRequest(http.MethodGet, "/api/logs", nil) + req.Header.Set("Authorization", "Bearer alpha-key") + req.Header.Set(TenantHeader, "beta") // attacker's cross-tenant attempt + + rec := httptest.NewRecorder() + h.ServeHTTP(rec, req) + + if rec.Code != http.StatusOK { + t.Fatalf("want 200, got %d (body=%q)", rec.Code, rec.Body.String()) + } + if tc.got != "alpha" { + t.Errorf("TenantMiddleware overwrote pinned tenant: got %q, want %q", tc.got, "alpha") + } +} + // Non-/api/* paths must pass through without tenant resolution — and so should // report the default (no ctx value). func TestTenantMiddleware_NonAPIPath_Passthrough(t *testing.T) { diff --git a/internal/api/server.go b/internal/api/server.go index 1f838d0..df4f793 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -2,6 +2,7 @@ package api import ( "net/http" + "strconv" "time" "github.com/RandomCodeSpace/otelcontext/internal/cache" @@ -107,6 +108,47 @@ func (s *Server) RegisterRoutes(mux *http.ServeMux) { mux.HandleFunc("/ws/events", s.eventHub.HandleWebSocket) } +const ( + pagingDefaultLimit = 50 + pagingMaxLimit = 1000 +) + +// parsePaging reads "limit" and "offset" from the request query string and +// applies safety clamping so GORM never sees a negative or unbounded Limit. +// +// - limit: floored at 1, capped at pagingMaxLimit (1000). When absent the +// caller-supplied defaultLimit is used (also clamped). +// - offset: floored at 0. When absent defaults to 0. +func parsePaging(r *http.Request, defaultLimit int) (limit, offset int) { + limit = defaultLimit + if limit < 1 { + limit = 1 + } + if limit > pagingMaxLimit { + limit = pagingMaxLimit + } + if l := r.URL.Query().Get("limit"); l != "" { + if v, err := strconv.Atoi(l); err == nil { + limit = v + } + } + if limit < 1 { + limit = 1 + } + if limit > pagingMaxLimit { + limit = pagingMaxLimit + } + if o := r.URL.Query().Get("offset"); o != "" { + if v, err := strconv.Atoi(o); err == nil { + offset = v + } + } + if offset < 0 { + offset = 0 + } + return limit, offset +} + // parseTimeRange parses start and end times from request query parameters func parseTimeRange(r *http.Request) (time.Time, time.Time, error) { var start, end time.Time diff --git a/internal/api/tenant_middleware.go b/internal/api/tenant_middleware.go index dd25c39..cf73e90 100644 --- a/internal/api/tenant_middleware.go +++ b/internal/api/tenant_middleware.go @@ -8,7 +8,6 @@ import ( "github.com/RandomCodeSpace/otelcontext/internal/storage" ) - // TenantHeader is the canonical HTTP header carrying the tenant ID on // read-side (query) requests. Ingest paths resolve tenant separately via gRPC // metadata / OTLP resource attributes and do not go through this middleware. @@ -35,6 +34,14 @@ func TenantMiddleware(cfg *config.Config) func(http.Handler) http.Handler { next.ServeHTTP(w, r) return } + // If an upstream layer (e.g. TenantKeyAuth.Middleware) has already + // pinned a tenant onto the context, do not overwrite it — that would + // allow a client to escape their key-bound tenant by supplying a + // different X-Tenant-ID header. + if storage.HasTenantContext(r.Context()) { + next.ServeHTTP(w, r) + return + } // SanitizeTenantID returns "" for empty / over-length / control-char // values so they fall through to the configured default — see // storage.SanitizeTenantID. Hostile or misconfigured clients cannot diff --git a/internal/api/trace_handlers.go b/internal/api/trace_handlers.go index 0e12ca7..c7fd1d5 100644 --- a/internal/api/trace_handlers.go +++ b/internal/api/trace_handlers.go @@ -5,25 +5,13 @@ import ( "fmt" "log/slog" "net/http" - "strconv" "github.com/RandomCodeSpace/otelcontext/internal/api/views" ) // handleGetTraces handles GET /api/traces func (s *Server) handleGetTraces(w http.ResponseWriter, r *http.Request) { - limit := 20 - offset := 0 - if l := r.URL.Query().Get("limit"); l != "" { - if v, err := strconv.Atoi(l); err == nil { - limit = v - } - } - if o := r.URL.Query().Get("offset"); o != "" { - if v, err := strconv.Atoi(o); err == nil { - offset = v - } - } + limit, offset := parsePaging(r, 20) start, end, err := parseTimeRange(r) if err != nil { diff --git a/internal/graphrag/anomaly.go b/internal/graphrag/anomaly.go index 0d84cb7..ade6109 100644 --- a/internal/graphrag/anomaly.go +++ b/internal/graphrag/anomaly.go @@ -28,7 +28,12 @@ func (g *GraphRAG) detectAnomaliesForTenant(ctx context.Context, tenant string, baselineErrorRate := 0.02 // reasonable baseline if svc.ErrorRate > baselineErrorRate*2 && svc.ErrorRate > 0.05 { anomaly := AnomalyNode{ - ID: fmt.Sprintf("anom_%s_err_%d", svc.Name, now.UnixNano()), + // Stable ID per (service, type): each detection tick UPSERTS the + // same evolving anomaly node rather than minting a new one. With a + // UnixNano suffix an ongoing spike created a fresh node every 10s + // (and correlateWithRecent then minted O(N²) PRECEDED_BY edges), + // which grew the AnomalyStore to ~1.3 GB over a 15-min soak. + ID: fmt.Sprintf("anom_%s_err", svc.Name), Type: AnomalyErrorSpike, Severity: classifyErrorSeverity(svc.ErrorRate), Service: svc.Name, @@ -49,7 +54,7 @@ func (g *GraphRAG) detectAnomaliesForTenant(ctx context.Context, tenant string, // Latency degradation: p99-like check using avg * 3 as proxy if svc.AvgLatency > 500 && svc.CallCount > 10 { anomaly := AnomalyNode{ - ID: fmt.Sprintf("anom_%s_lat_%d", svc.Name, now.UnixNano()), + ID: fmt.Sprintf("anom_%s_lat", svc.Name), // stable per (service,type); see error-spike note Type: AnomalyLatencySpike, Severity: classifyLatencySeverity(svc.AvgLatency), Service: svc.Name, @@ -79,7 +84,7 @@ func (g *GraphRAG) detectAnomaliesForTenant(ctx context.Context, tenant string, deviation := (m.RollingAvg - (m.RollingMin + rangeSize/2)) / (rangeSize / 2) if deviation > 3.0 || deviation < -3.0 { anomaly := AnomalyNode{ - ID: fmt.Sprintf("anom_%s_metric_%d", m.Service, now.UnixNano()), + ID: fmt.Sprintf("anom_%s_metric_%s", m.Service, m.MetricName), // stable per (service,metric) Type: AnomalyMetricZScore, Severity: SeverityWarning, Service: m.Service, diff --git a/internal/graphrag/anomaly_dedup_test.go b/internal/graphrag/anomaly_dedup_test.go new file mode 100644 index 0000000..e007e45 --- /dev/null +++ b/internal/graphrag/anomaly_dedup_test.go @@ -0,0 +1,42 @@ +package graphrag + +import ( + "testing" + "time" +) + +// TestAnomalyDedupBoundsStore proves the root-cause fix for the soak finding: +// stable per-(service,type) anomaly IDs make repeated detection ticks UPSERT a +// single evolving node instead of minting a new one each tick. With the old +// UnixNano-suffixed IDs, 100 ticks over 2 services produced 200 nodes and an +// O(N²) PRECEDED_BY edge explosion (which grew AnomalyStore to ~1.3 GB in a +// 15-min soak). Under the fix, node and edge counts stay bounded regardless of +// how many ticks fire. +func TestAnomalyDedupBoundsStore(t *testing.T) { + stores := newTenantStores(time.Hour) + base := time.Unix(1_700_000_000, 0) + + const ticks = 100 + for i := range ticks { + ts := base.Add(time.Duration(i) * 10 * time.Second) + for _, svc := range []string{"checkout", "payments"} { + a := AnomalyNode{ + ID: "anom_" + svc + "_err", // stable ID, mirrors detectAnomaliesForTenant + Type: AnomalyErrorSpike, + Service: svc, + Timestamp: ts, + } + stores.anomalies.AddAnomaly(a) + correlateWithRecent(stores, a) + } + } + + if got := len(stores.anomalies.Anomalies); got != 2 { + t.Fatalf("expected 2 deduped anomaly nodes after %d ticks, got %d", ticks, got) + } + // TRIGGERED_BY: 2 (one per node). PRECEDED_BY: at most the 2-node mesh. + // The point is it does NOT scale with tick count. + if got := len(stores.anomalies.Edges); got > 8 { + t.Fatalf("edge count must stay bounded under dedup, got %d after %d ticks", got, ticks) + } +} diff --git a/internal/ingest/otlp_http.go b/internal/ingest/otlp_http.go index d9c6fce..32640c0 100644 --- a/internal/ingest/otlp_http.go +++ b/internal/ingest/otlp_http.go @@ -37,9 +37,16 @@ const headerContentType = "Content-Type" //nolint:goconst // single literal; Son // to the request context before delegating to the gRPC Export methods. // Uses the shared storage.WithTenantContext helper so ingest and read paths // agree on the context key. +// +// The raw header value is run through storage.SanitizeTenantID — the same +// sanitizer applied on the gRPC metadata path in tenantFromContext — so +// control characters, oversized strings, and empty values are rejected +// identically regardless of transport. func withTenantFromHTTP(r *http.Request) context.Context { if v := r.Header.Get("X-Tenant-ID"); v != "" { - return storage.WithTenantContext(r.Context(), v) + if sanitized := storage.SanitizeTenantID(v); sanitized != "" { + return storage.WithTenantContext(r.Context(), sanitized) + } } return r.Context() } diff --git a/internal/ingest/sampler.go b/internal/ingest/sampler.go index 38d63e8..6b9e0ed 100644 --- a/internal/ingest/sampler.go +++ b/internal/ingest/sampler.go @@ -17,6 +17,7 @@ type Sampler struct { buckets map[string]*tokenBucket totalSeen atomic.Int64 totalDropped atomic.Int64 + now func() time.Time // injectable for tests; defaults to time.Now } // NewSampler creates a Sampler with the given parameters. @@ -32,6 +33,7 @@ func NewSampler(rate float64, alwaysOnErrors bool, latencyThresholdMs float64) * alwaysOnErrors: alwaysOnErrors, latencyThresholdMs: latencyThresholdMs, buckets: make(map[string]*tokenBucket), + now: time.Now, } } @@ -67,13 +69,13 @@ func (s *Sampler) ShouldSample(serviceName string, isError bool, durationMs floa s.mu.Lock() b, ok := s.buckets[serviceName] if !ok { - b = newTokenBucket(s.rate) + b = newTokenBucket(s.rate, s.now) s.buckets[serviceName] = b // Always let first trace through (new service discovery). s.mu.Unlock() return true } - allow := b.allow() + allow := b.allow(s.now()) s.mu.Unlock() if !allow { @@ -87,35 +89,60 @@ func (s *Sampler) Stats() (int64, int64) { return s.totalSeen.Load(), s.totalDropped.Load() } -// tokenBucket is a simple token bucket for sampling decisions. -// Refills at `rate` tokens per second, max capacity 1.0. +// tokenBucket throttles healthy-span ingestion per service. It is a RATE +// LIMITER, not a percentage sampler: it admits at most ~`rate` healthy spans +// per second per service (refill `rate` tokens/s, cost 1 token/span) with a +// startup burst of up to capacity = max(1, 1/rate) spans. +// +// The long-run keep FRACTION is therefore min(1, rate / offered_rate): a +// service emitting ≤ `rate` healthy spans/s keeps all of them; above that it +// keeps a shrinking fraction while the absolute admitted rate stays near +// `rate`/s. So rate=0.05 means "~0.05 healthy spans/s/service" (≈ one per 20s), +// NOT "5% of healthy spans". Errors and slow spans bypass this entirely in +// ShouldSample, so there is no data loss for the signals that matter; the +// absolute cap is what bounds the SQLite write rate under load spikes. If a +// true proportional keep-fraction is ever wanted, switch to probabilistic +// (hash-mod / rand) sampling — that is a separate design decision. +// +// (The previous implementation capped tokens at 1.0 but charged 1.0/rate per +// request; for any rate < 1.0 the charge exceeded the cap, so no healthy span +// could ever be admitted — the SQLite default rate of 0.05 dropped ~100%.) type tokenBucket struct { - rate float64 // tokens per second - tokens float64 // current tokens (0.0–1.0) - lastTick time.Time + rate float64 // refill tokens/sec == max sustained admitted healthy spans/sec + capacity float64 // max accumulated tokens (burst ceiling) + tokens float64 // current token count + lastTick time.Time // wall-clock of last refill } -func newTokenBucket(rate float64) *tokenBucket { +func newTokenBucket(rate float64, now func() time.Time) *tokenBucket { + // capacity = 1/rate tokens: one "admission interval" of burst so a freshly + // seen service is not throttled immediately. Floored at 1.0 so a span can + // always eventually be admitted. + capacity := 1.0 / rate + if capacity < 1.0 { + capacity = 1.0 + } return &tokenBucket{ rate: rate, - tokens: rate, // start with one full refill worth - lastTick: time.Now(), + capacity: capacity, + tokens: capacity, // start full so new services are not immediately throttled + lastTick: now(), } } -// allow returns true and consumes a token if one is available. -func (b *tokenBucket) allow() bool { - now := time.Now() +// allow refills the bucket for elapsed time and admits the request if +// at least 1 token is available, consuming exactly 1 on admission. +func (b *tokenBucket) allow(now time.Time) bool { elapsed := now.Sub(b.lastTick).Seconds() b.lastTick = now b.tokens += elapsed * b.rate - if b.tokens > 1.0 { - b.tokens = 1.0 + if b.tokens > b.capacity { + b.tokens = b.capacity } - if b.tokens >= 1.0/b.rate { - b.tokens -= 1.0 / b.rate + if b.tokens >= 1.0 { + b.tokens -= 1.0 return true } return false diff --git a/internal/ingest/sampler_test.go b/internal/ingest/sampler_test.go new file mode 100644 index 0000000..cdb8970 --- /dev/null +++ b/internal/ingest/sampler_test.go @@ -0,0 +1,184 @@ +package ingest + +import ( + "fmt" + "testing" + "time" +) + +// advanceClock returns a now() func that starts at t0 and advances by step on +// each call. This lets tests drive token-bucket time without time.Sleep. +func advanceClock(t0 time.Time, step time.Duration) func() time.Time { + cur := t0 + return func() time.Time { + t := cur + cur = cur.Add(step) + return t + } +} + +// TestSamplerKeepFraction verifies that the healthy-span probabilistic path +// keeps approximately `rate` fraction of calls over a large sample. The test +// is fully deterministic — virtual time advances in fixed steps so there is no +// reliance on wall-clock timing or sleep. +// +// Clock design: each tick advances virtual time by tickNs nanoseconds (a fine +// granularity). After the first call (new-service free-admit), the token bucket +// receives `rate * tickNs/1e9` tokens per call. Over N calls the total tokens +// available ≈ N * rate * tickNs/1e9, and each admission costs 1 token, giving +// a long-run keep fraction ≈ rate * tickNs/1e9. We therefore need: +// +// tickNs = 1e9 (1 second per virtual call) +// +// so keep fraction → rate. However, with 1s ticks and rates near 1.0 the +// capacity cap wastes tokens (1.8→1.111 for rate=0.9). Using a very large +// virtual time window (100 000 calls at 1s each = ~28 virtual hours) and a +// wider tolerance lets the law-of-large-numbers smooth the discrete rounding, +// while still clearly distinguishing "correct implementation" (~rate) from +// "broken implementation" (~0% or ~100%). +func TestSamplerKeepFraction(t *testing.T) { + t.Parallel() + + tests := []struct { + rate float64 + wantFrac float64 + lo float64 // inclusive lower bound + hi float64 // inclusive upper bound + }{ + // Wide but meaningful bounds: broken code gives ~0% (capped bucket) or + // ~100% (bypass bug). Correct code must land in these windows. + {rate: 0.05, wantFrac: 0.05, lo: 0.03, hi: 0.09}, + {rate: 0.50, wantFrac: 0.50, lo: 0.40, hi: 0.60}, + {rate: 0.90, wantFrac: 0.90, lo: 0.60, hi: 1.00}, + } + + // 1 virtual second per call so refill per tick == rate tokens exactly. + const tickNs = int64(time.Second) + const calls = 100_000 + + for _, tc := range tests { + t.Run(fmt.Sprintf("rate=%.2f", tc.rate), func(t *testing.T) { + t.Parallel() + + t0 := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) + nowFn := advanceClock(t0, time.Duration(tickNs)) + + s := &Sampler{ + rate: tc.rate, + alwaysOnErrors: false, + latencyThresholdMs: 1e9, // far above test spans so the slow-span bypass never fires + buckets: make(map[string]*tokenBucket), + now: nowFn, + } + + kept := 0 + for i := 0; i < calls; i++ { + if s.ShouldSample("svc", false, 0) { + kept++ + } + } + + got := float64(kept) / float64(calls) + if got < tc.lo || got > tc.hi { + t.Errorf("rate=%.2f: keep fraction %.4f outside [%.4f, %.4f] (%d/%d kept)", + tc.rate, got, tc.lo, tc.hi, kept, calls) + } + }) + } +} + +// TestSamplerRateOne verifies rate==1.0 keeps all healthy spans. +func TestSamplerRateOne(t *testing.T) { + t.Parallel() + // latencyThresholdMs=999999 keeps slow-span bypass out of the picture. + s := NewSampler(1.0, false, 999999) + for i := 0; i < 1000; i++ { + if !s.ShouldSample("svc", false, 0) { + t.Fatal("rate=1.0 must keep every span") + } + } +} + +// TestSamplerRateZero verifies rate==0.0 drops all healthy spans. +func TestSamplerRateZero(t *testing.T) { + t.Parallel() + // latencyThresholdMs=999999 so 0ms spans are not treated as "slow"; we want + // the pure zero-rate drop path. + s := NewSampler(0.0, false, 999999) + for i := 0; i < 1000; i++ { + if s.ShouldSample("svc", false, 0) { + t.Fatal("rate=0.0 must drop every healthy span") + } + } +} + +// TestSamplerAlwaysOnErrors verifies that error spans bypass the bucket +// regardless of rate. +func TestSamplerAlwaysOnErrors(t *testing.T) { + t.Parallel() + // rate=0 would drop everything healthy; errors must still pass. + s := NewSampler(0.0, true /* alwaysOnErrors */, 0) + for i := 0; i < 1000; i++ { + if !s.ShouldSample("svc", true /* isError */, 0) { + t.Fatal("error span must always be kept when alwaysOnErrors=true") + } + } +} + +// TestSamplerSlowSpanBypass verifies that slow spans bypass the bucket. +func TestSamplerSlowSpanBypass(t *testing.T) { + t.Parallel() + // rate=0, latencyThreshold=500ms — a 600ms span must be kept. + s := NewSampler(0.0, false, 500) + for i := 0; i < 100; i++ { + if !s.ShouldSample("svc", false, 600) { + t.Fatal("slow span (600ms > 500ms threshold) must always be kept") + } + } +} + +// TestSamplerNewServiceDiscovery verifies the first call for a new service is +// always admitted (service discovery guarantee). +func TestSamplerNewServiceDiscovery(t *testing.T) { + t.Parallel() + // rate=0.001 — almost nothing would pass, but a brand-new service must. + // latencyThresholdMs=999999 keeps the slow-span bypass out of the picture. + s := NewSampler(0.001, false, 999999) + if !s.ShouldSample("brand-new-svc", false, 0) { + t.Fatal("first call for a new service must always be admitted") + } +} + +// TestSamplerStats verifies that the seen/dropped counters are consistent. +func TestSamplerStats(t *testing.T) { + t.Parallel() + + t0 := time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC) + // Use a slow clock (1s per tick) so rate=0.5 alternates roughly keep/drop. + nowFn := advanceClock(t0, time.Second) + + s := &Sampler{ + rate: 0.5, + alwaysOnErrors: false, + latencyThresholdMs: -1, // disabled + buckets: make(map[string]*tokenBucket), + now: nowFn, + } + + const calls = 100 + for i := 0; i < calls; i++ { + s.ShouldSample("svc", false, 0) + } + + seen, dropped := s.Stats() + // First call is free (new-service discovery), so seen == calls, dropped < calls. + if seen != calls { + t.Errorf("seen=%d want %d", seen, calls) + } + if dropped >= calls { + t.Errorf("dropped=%d must be < seen=%d", dropped, calls) + } + if dropped < 0 { + t.Errorf("dropped=%d must not be negative", dropped) + } +} diff --git a/internal/mcp/response_cap_test.go b/internal/mcp/response_cap_test.go index 57a4162..2c89a27 100644 --- a/internal/mcp/response_cap_test.go +++ b/internal/mcp/response_cap_test.go @@ -3,6 +3,7 @@ package mcp import ( "strings" "testing" + "time" ) // TestTextResult_ResponseCap verifies the byte-cap defense for tool @@ -52,3 +53,84 @@ func TestTextResult_ResponseCap(t *testing.T) { } }) } + +// TestResourceResult_ResponseCap verifies that resourceResult applies the same +// MaxToolResponseBytes cap as textResult — the trace_graph DB fallback can +// return an unbounded GetTrace payload without this guard. +func TestResourceResult_ResponseCap(t *testing.T) { + t.Parallel() + + t.Run("UnderCapPassesThrough", func(t *testing.T) { + text := strings.Repeat("x", 1024) + got := resourceResult("OtelContext://test", "application/json", text) + if got.IsError { + t.Fatalf("expected success, got IsError=true: %+v", got) + } + if len(got.Content) != 1 || got.Content[0].Resource == nil { + t.Fatalf("expected resource content item: %+v", got) + } + if got.Content[0].Resource.Text != text { + t.Fatalf("payload mangled") + } + }) + + t.Run("AtCapPassesThrough", func(t *testing.T) { + text := strings.Repeat("x", MaxToolResponseBytes) + got := resourceResult("OtelContext://test", "application/json", text) + if got.IsError { + t.Fatalf("expected at-cap to pass, got IsError=true") + } + }) + + t.Run("OverCapErrors", func(t *testing.T) { + text := strings.Repeat("x", MaxToolResponseBytes+1) + got := resourceResult("OtelContext://test", "application/json", text) + if !got.IsError { + t.Fatalf("expected over-cap to error, got success") + } + if len(got.Content) == 0 || !strings.Contains(got.Content[0].Text, "response too large") { + t.Fatalf("expected 'response too large' in error: %+v", got) + } + if !strings.Contains(got.Content[0].Text, "narrow time range") { + t.Fatalf("expected actionable hint in error: %+v", got) + } + }) +} + +// TestCacheErrorSkip_GuardLogic verifies the guard logic that server.go uses +// to decide whether to call cache.Set. The guard is: +// +// if !toolResult.IsError { s.cache.Set(...) } +// +// This test exercises that decision directly: an error result (IsError=true) +// must NOT be passed to Set; a successful result must be passed and then +// retrievable. +func TestCacheErrorSkip_GuardLogic(t *testing.T) { + t.Parallel() + + c := newResultCache(5*time.Second, 64) + + // Simulate the server-side guard: only Set when !IsError. + maybeCache := func(res ToolCallResult) { + if !res.IsError { + c.Set("default", "get_service_map", nil, res) + } + } + + // Error result: guard must prevent the Set. + maybeCache(errorResult("GraphRAG not initialized")) + _, hit := c.Get("default", "get_service_map", nil) + if hit { + t.Fatal("error result must not be stored in the cache") + } + + // Successful result: guard must allow the Set. + maybeCache(textResult(`{"ok":true}`)) + got, hit := c.Get("default", "get_service_map", nil) + if !hit { + t.Fatal("successful result must be stored in the cache") + } + if got.IsError { + t.Fatalf("cached result should not be an error: %+v", got) + } +} diff --git a/internal/mcp/server.go b/internal/mcp/server.go index 5da7532..27f005b 100644 --- a/internal/mcp/server.go +++ b/internal/mcp/server.go @@ -332,7 +332,9 @@ func (s *Server) handleRPC(w http.ResponseWriter, r *http.Request) { break } s.callsServiced.Add(1) - s.cache.Set(tenant, params.Name, params.Arguments, toolResult) + if !toolResult.IsError { + s.cache.Set(tenant, params.Name, params.Arguments, toolResult) + } result = toolResult case "ping": diff --git a/internal/mcp/tools.go b/internal/mcp/tools.go index 6896aeb..6e399b5 100644 --- a/internal/mcp/tools.go +++ b/internal/mcp/tools.go @@ -387,6 +387,12 @@ func textResult(text string) ToolCallResult { } func resourceResult(uri, mimeType, text string) ToolCallResult { + if len(text) > MaxToolResponseBytes { + return errorResult(fmt.Sprintf( + "response too large: %d bytes exceeds %d-byte cap; narrow time range or use pagination", + len(text), MaxToolResponseBytes, + )) + } return ToolCallResult{ Content: []ContentItem{ {Type: "resource", Resource: &Resource{URI: uri, MimeType: mimeType, Text: text}}, diff --git a/internal/ui/dist/assets/cytoscape-cose-bilkent-CEIBo6Gj.js b/internal/ui/dist/assets/cytoscape-cose-bilkent-sPlXtCXB.js similarity index 99% rename from internal/ui/dist/assets/cytoscape-cose-bilkent-CEIBo6Gj.js rename to internal/ui/dist/assets/cytoscape-cose-bilkent-sPlXtCXB.js index 654a4ef..8b620e5 100644 --- a/internal/ui/dist/assets/cytoscape-cose-bilkent-CEIBo6Gj.js +++ b/internal/ui/dist/assets/cytoscape-cose-bilkent-sPlXtCXB.js @@ -1 +1 @@ -import{t as e}from"./index-B9ZFj2IV.js";var t=e(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.layoutBase=r():n.layoutBase=r()})(e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=26)})([(function(e,t,n){function r(){}r.QUALITY=1,r.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,r.DEFAULT_INCREMENTAL=!1,r.DEFAULT_ANIMATION_ON_LAYOUT=!0,r.DEFAULT_ANIMATION_DURING_LAYOUT=!1,r.DEFAULT_ANIMATION_PERIOD=50,r.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,r.DEFAULT_GRAPH_MARGIN=15,r.NODE_DIMENSIONS_INCLUDE_LABELS=!1,r.SIMPLE_NODE_SIZE=40,r.SIMPLE_NODE_HALF_SIZE=r.SIMPLE_NODE_SIZE/2,r.EMPTY_COMPOUND_NODE_SIZE=40,r.MIN_EDGE_LENGTH=1,r.WORLD_BOUNDARY=1e6,r.INITIAL_WORLD_BOUNDARY=r.WORLD_BOUNDARY/1e3,r.WORLD_CENTER_X=1200,r.WORLD_CENTER_Y=900,e.exports=r}),(function(e,t,n){var r=n(2),i=n(8),a=n(9);function o(e,t,n){r.call(this,n),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=n,this.bendpoints=[],this.source=e,this.target=t}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.getSource=function(){return this.source},o.prototype.getTarget=function(){return this.target},o.prototype.isInterGraph=function(){return this.isInterGraph},o.prototype.getLength=function(){return this.length},o.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},o.prototype.getBendpoints=function(){return this.bendpoints},o.prototype.getLca=function(){return this.lca},o.prototype.getSourceInLca=function(){return this.sourceInLca},o.prototype.getTargetInLca=function(){return this.targetInLca},o.prototype.getOtherEnd=function(e){if(this.source===e)return this.target;if(this.target===e)return this.source;throw`Node is not incident with this edge`},o.prototype.getOtherEndInGraph=function(e,t){for(var n=this.getOtherEnd(e),r=t.getGraphManager().getRoot();;){if(n.getOwner()==t)return n;if(n.getOwner()==r)break;n=n.getOwner().getParent()}return null},o.prototype.updateLength=function(){var e=[,,,,];this.isOverlapingSourceAndTarget=i.getIntersection(this.target.getRect(),this.source.getRect(),e),this.isOverlapingSourceAndTarget||(this.lengthX=e[0]-e[2],this.lengthY=e[1]-e[3],Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},o.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},e.exports=o}),(function(e,t,n){function r(e){this.vGraphObject=e}e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(13),o=n(0),s=n(16),c=n(4);function l(e,t,n,o){n==null&&o==null&&(o=t),r.call(this,o),e.graphManager!=null&&(e=e.graphManager),this.estimatedSize=i.MIN_VALUE,this.inclusionTreeDepth=i.MAX_VALUE,this.vGraphObject=o,this.edges=[],this.graphManager=e,n!=null&&t!=null?this.rect=new a(t.x,t.y,n.width,n.height):this.rect=new a}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.getEdges=function(){return this.edges},l.prototype.getChild=function(){return this.child},l.prototype.getOwner=function(){return this.owner},l.prototype.getWidth=function(){return this.rect.width},l.prototype.setWidth=function(e){this.rect.width=e},l.prototype.getHeight=function(){return this.rect.height},l.prototype.setHeight=function(e){this.rect.height=e},l.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},l.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},l.prototype.getCenter=function(){return new c(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},l.prototype.getLocation=function(){return new c(this.rect.x,this.rect.y)},l.prototype.getRect=function(){return this.rect},l.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},l.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},l.prototype.setRect=function(e,t){this.rect.x=e.x,this.rect.y=e.y,this.rect.width=t.width,this.rect.height=t.height},l.prototype.setCenter=function(e,t){this.rect.x=e-this.rect.width/2,this.rect.y=t-this.rect.height/2},l.prototype.setLocation=function(e,t){this.rect.x=e,this.rect.y=t},l.prototype.moveBy=function(e,t){this.rect.x+=e,this.rect.y+=t},l.prototype.getEdgeListToNode=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.target==e){if(r.source!=n)throw`Incorrect edge source!`;t.push(r)}}),t},l.prototype.getEdgesBetween=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(!(r.source==n||r.target==n))throw`Incorrect edge source and/or target`;(r.target==e||r.source==e)&&t.push(r)}),t},l.prototype.getNeighborsList=function(){var e=new Set,t=this;return t.edges.forEach(function(n){if(n.source==t)e.add(n.target);else{if(n.target!=t)throw`Incorrect incidency!`;e.add(n.source)}}),e},l.prototype.withChildren=function(){var e=new Set,t,n;if(e.add(this),this.child!=null)for(var r=this.child.getNodes(),i=0;it&&(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)),this.labelHeight>n&&(this.labelPos==`center`?this.rect.y-=(this.labelHeight-n)/2:this.labelPos==`top`&&(this.rect.y-=this.labelHeight-n),this.setHeight(this.labelHeight))}}},l.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==i.MAX_VALUE)throw`assert failed`;return this.inclusionTreeDepth},l.prototype.transform=function(e){var t=this.rect.x;t>o.WORLD_BOUNDARY?t=o.WORLD_BOUNDARY:t<-o.WORLD_BOUNDARY&&(t=-o.WORLD_BOUNDARY);var n=this.rect.y;n>o.WORLD_BOUNDARY?n=o.WORLD_BOUNDARY:n<-o.WORLD_BOUNDARY&&(n=-o.WORLD_BOUNDARY);var r=new c(t,n),i=e.inverseTransformPoint(r);this.setLocation(i.x,i.y)},l.prototype.getLeft=function(){return this.rect.x},l.prototype.getRight=function(){return this.rect.x+this.rect.width},l.prototype.getTop=function(){return this.rect.y},l.prototype.getBottom=function(){return this.rect.y+this.rect.height},l.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},e.exports=l}),(function(e,t,n){function r(e,t){e==null&&t==null?(this.x=0,this.y=0):(this.x=e,this.y=t)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(e){this.x=e},r.prototype.setY=function(e){this.y=e},r.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(0),o=n(6),s=n(3),c=n(1),l=n(13),u=n(12),d=n(11);function f(e,t,n){r.call(this,n),this.estimatedSize=i.MIN_VALUE,this.margin=a.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,t!=null&&t instanceof o?this.graphManager=t:t!=null&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var p in f.prototype=Object.create(r.prototype),r)f[p]=r[p];f.prototype.getNodes=function(){return this.nodes},f.prototype.getEdges=function(){return this.edges},f.prototype.getGraphManager=function(){return this.graphManager},f.prototype.getParent=function(){return this.parent},f.prototype.getLeft=function(){return this.left},f.prototype.getRight=function(){return this.right},f.prototype.getTop=function(){return this.top},f.prototype.getBottom=function(){return this.bottom},f.prototype.isConnected=function(){return this.isConnected},f.prototype.add=function(e,t,n){if(t==null&&n==null){var r=e;if(this.graphManager==null)throw`Graph has no graph mgr!`;if(this.getNodes().indexOf(r)>-1)throw`Node already in graph!`;return r.owner=this,this.getNodes().push(r),r}else{var i=e;if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(n)>-1))throw`Source or target not in graph!`;if(!(t.owner==n.owner&&t.owner==this))throw`Both owners must be this graph!`;return t.owner==n.owner?(i.source=t,i.target=n,i.isInterGraph=!1,this.getEdges().push(i),t.edges.push(i),n!=t&&n.edges.push(i),i):null}},f.prototype.remove=function(e){var t=e;if(e instanceof s){if(t==null)throw`Node is null!`;if(!(t.owner!=null&&t.owner==this))throw`Owner graph is invalid!`;if(this.graphManager==null)throw`Owner graph manager is invalid!`;for(var n=t.edges.slice(),r,i=n.length,a=0;a-1&&u>-1))throw`Source and/or target doesn't know this edge!`;r.source.edges.splice(l,1),r.target!=r.source&&r.target.edges.splice(u,1);var o=r.source.owner.getEdges().indexOf(r);if(o==-1)throw`Not in owner's edge list!`;r.source.owner.getEdges().splice(o,1)}},f.prototype.updateLeftTop=function(){for(var e=i.MAX_VALUE,t=i.MAX_VALUE,n,r,a,o=this.getNodes(),s=o.length,c=0;cn&&(e=n),t>r&&(t=r)}return e==i.MAX_VALUE?null:(a=o[0].getParent().paddingLeft==null?this.margin:o[0].getParent().paddingLeft,this.left=t-a,this.top=e-a,new u(this.left,this.top))},f.prototype.updateBounds=function(e){for(var t=i.MAX_VALUE,n=-i.MAX_VALUE,r=i.MAX_VALUE,a=-i.MAX_VALUE,o,s,c,u,d,f=this.nodes,p=f.length,m=0;mo&&(t=o),nc&&(r=c),ao&&(t=o),nc&&(r=c),a=this.nodes.length){var c=0;n.forEach(function(t){t.owner==e&&c++}),c==this.nodes.length&&(this.isConnected=!0)}},e.exports=f}),(function(e,t,n){var r,i=n(1);function a(e){r=n(5),this.layout=e,this.graphs=[],this.edges=[]}a.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),n=this.add(e,t);return this.setRootGraph(n),this.rootGraph},a.prototype.add=function(e,t,n,r,i){if(n==null&&r==null&&i==null){if(e==null)throw`Graph is null!`;if(t==null)throw`Parent node is null!`;if(this.graphs.indexOf(e)>-1)throw`Graph already in this graph mgr!`;if(this.graphs.push(e),e.parent!=null)throw`Already has a parent!`;if(t.child!=null)throw`Already has a child!`;return e.parent=t,t.child=e,e}else{i=n,r=t,n=e;var a=r.getOwner(),o=i.getOwner();if(!(a!=null&&a.getGraphManager()==this))throw`Source not in this graph mgr!`;if(!(o!=null&&o.getGraphManager()==this))throw`Target not in this graph mgr!`;if(a==o)return n.isInterGraph=!1,a.add(n,r,i);if(n.isInterGraph=!0,n.source=r,n.target=i,this.edges.indexOf(n)>-1)throw`Edge already in inter-graph edge list!`;if(this.edges.push(n),!(n.source!=null&&n.target!=null))throw`Edge source and/or target is null!`;if(!(n.source.edges.indexOf(n)==-1&&n.target.edges.indexOf(n)==-1))throw`Edge already in source and/or target incidency list!`;return n.source.edges.push(n),n.target.edges.push(n),n}},a.prototype.remove=function(e){if(e instanceof r){var t=e;if(t.getGraphManager()!=this)throw`Graph not in this graph mgr`;if(!(t==this.rootGraph||t.parent!=null&&t.parent.graphManager==this))throw`Invalid parent node!`;var n=[];n=n.concat(t.getEdges());for(var a,o=n.length,s=0;s=t.getRight()?n[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight()):t.getX()<=e.getX()&&t.getRight()>=e.getRight()&&(n[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight())),e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()?n[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()):t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()&&(n[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()));var a=Math.abs((t.getCenterY()-e.getCenterY())/(t.getCenterX()-e.getCenterX()));t.getCenterY()===e.getCenterY()&&t.getCenterX()===e.getCenterX()&&(a=1);var o=a*n[0],s=n[1]/a;n[0]o)return n[0]=r,n[1]=c,n[2]=a,n[3]=y,!1;if(ia)return n[0]=s,n[1]=i,n[2]=_,n[3]=o,!1;if(ra?(n[0]=u,n[1]=d,C=!0):(n[0]=l,n[1]=c,C=!0):T===D&&(r>a?(n[0]=s,n[1]=c,C=!0):(n[0]=f,n[1]=d,C=!0)),-E===D?a>r?(n[2]=v,n[3]=y,w=!0):(n[2]=_,n[3]=g,w=!0):E===D&&(a>r?(n[2]=h,n[3]=g,w=!0):(n[2]=b,n[3]=y,w=!0)),C&&w)return!1;if(r>a?i>o?(O=this.getCardinalDirection(T,D,4),k=this.getCardinalDirection(E,D,2)):(O=this.getCardinalDirection(-T,D,3),k=this.getCardinalDirection(-E,D,1)):i>o?(O=this.getCardinalDirection(-T,D,1),k=this.getCardinalDirection(-E,D,3)):(O=this.getCardinalDirection(T,D,2),k=this.getCardinalDirection(E,D,4)),!C)switch(O){case 1:j=c,A=r+-m/D,n[0]=A,n[1]=j;break;case 2:A=f,j=i+p*D,n[0]=A,n[1]=j;break;case 3:j=d,A=r+m/D,n[0]=A,n[1]=j;break;case 4:A=u,j=i+-p*D,n[0]=A,n[1]=j;break}if(!w)switch(k){case 1:N=g,M=a+-S/D,n[2]=M,n[3]=N;break;case 2:M=b,N=o+x*D,n[2]=M,n[3]=N;break;case 3:N=y,M=a+S/D,n[2]=M,n[3]=N;break;case 4:M=v,N=o+-x*D,n[2]=M,n[3]=N;break}}return!1},i.getCardinalDirection=function(e,t,n){return e>t?n:1+n%4},i.getIntersection=function(e,t,n,i){if(i==null)return this.getIntersection2(e,t,n);var a=e.x,o=e.y,s=t.x,c=t.y,l=n.x,u=n.y,d=i.x,f=i.y,p=void 0,m=void 0,h=void 0,g=void 0,_=void 0,v=void 0,y=void 0,b=void 0,x=void 0;return h=c-o,_=a-s,y=s*o-a*c,g=f-u,v=l-d,b=d*u-l*f,x=h*v-g*_,x===0?null:(p=(_*b-v*y)/x,m=(g*y-h*b)/x,new r(p,m))},i.angleOfVector=function(e,t,n,r){var i=void 0;return e===n?i=r0?1:e<0?-1:0},r.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},r.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},e.exports=r}),(function(e,t,n){function r(){}r.MAX_VALUE=2147483647,r.MIN_VALUE=-2147483648,e.exports=r}),(function(e,t,n){var r=function(){function e(e,t){for(var n=0;n0&&t;){for(s.push(l[0]);s.length>0&&t;){var u=s[0];s.splice(0,1),o.add(u);for(var d=u.getEdges(),a=0;a-1&&l.splice(h,1)}o=new Set,c=new Map}}return e},f.prototype.createDummyNodesForBendpoints=function(e){for(var t=[],n=e.source,r=this.graphManager.calcLowestCommonAncestor(e.source,e.target),i=0;i0){for(var i=this.edgeToDummyNodes.get(n),a=0;a=0&&t.splice(d,1),s.getNeighborsList().forEach(function(e){if(n.indexOf(e)<0){var t=r.get(e)-1;t==1&&l.push(e),r.set(e,t)}})}n=n.concat(l),(t.length==1||t.length==2)&&(i=!0,a=t[0])}return a},f.prototype.setGraphManager=function(e){this.graphManager=e},e.exports=f}),(function(e,t,n){function r(){}r.seed=1,r.x=0,r.nextDouble=function(){return r.x=Math.sin(r.seed++)*1e4,r.x-Math.floor(r.x)},e.exports=r}),(function(e,t,n){var r=n(4);function i(e,t){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}i.prototype.getWorldOrgX=function(){return this.lworldOrgX},i.prototype.setWorldOrgX=function(e){this.lworldOrgX=e},i.prototype.getWorldOrgY=function(){return this.lworldOrgY},i.prototype.setWorldOrgY=function(e){this.lworldOrgY=e},i.prototype.getWorldExtX=function(){return this.lworldExtX},i.prototype.setWorldExtX=function(e){this.lworldExtX=e},i.prototype.getWorldExtY=function(){return this.lworldExtY},i.prototype.setWorldExtY=function(e){this.lworldExtY=e},i.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},i.prototype.setDeviceOrgX=function(e){this.ldeviceOrgX=e},i.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},i.prototype.setDeviceOrgY=function(e){this.ldeviceOrgY=e},i.prototype.getDeviceExtX=function(){return this.ldeviceExtX},i.prototype.setDeviceExtX=function(e){this.ldeviceExtX=e},i.prototype.getDeviceExtY=function(){return this.ldeviceExtY},i.prototype.setDeviceExtY=function(e){this.ldeviceExtY=e},i.prototype.transformX=function(e){var t=0,n=this.lworldExtX;return n!=0&&(t=this.ldeviceOrgX+(e-this.lworldOrgX)*this.ldeviceExtX/n),t},i.prototype.transformY=function(e){var t=0,n=this.lworldExtY;return n!=0&&(t=this.ldeviceOrgY+(e-this.lworldOrgY)*this.ldeviceExtY/n),t},i.prototype.inverseTransformX=function(e){var t=0,n=this.ldeviceExtX;return n!=0&&(t=this.lworldOrgX+(e-this.ldeviceOrgX)*this.lworldExtX/n),t},i.prototype.inverseTransformY=function(e){var t=0,n=this.ldeviceExtY;return n!=0&&(t=this.lworldOrgY+(e-this.ldeviceOrgY)*this.lworldExtY/n),t},i.prototype.inverseTransformPoint=function(e){return new r(this.inverseTransformX(e.x),this.inverseTransformY(e.y))},e.exports=i}),(function(e,t,n){function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);ta.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*a.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(e-a.ADAPTATION_LOWER_NODE_LIMIT)/(a.ADAPTATION_UPPER_NODE_LIMIT-a.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-a.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=a.MAX_NODE_DISPLACEMENT_INCREMENTAL):(e>a.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(a.COOLING_ADAPTATION_FACTOR,1-(e-a.ADAPTATION_LOWER_NODE_LIMIT)/(a.ADAPTATION_UPPER_NODE_LIMIT-a.ADAPTATION_LOWER_NODE_LIMIT)*(1-a.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=a.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},l.prototype.calcSpringForces=function(){for(var e=this.getAllEdges(),t,n=0;n0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n,r,i,o,s=this.getAllNodes(),c;if(this.useFRGridVariant)for(this.totalIterations%a.GRID_CALCULATION_CHECK_PERIOD==1&&e&&this.updateGrid(),c=new Set,n=0;nc||s>c)&&(e.gravitationForceX=-this.gravityConstant*i,e.gravitationForceY=-this.gravityConstant*a)):(c=t.getEstimatedSize()*this.compoundGravityRangeFactor,(o>c||s>c)&&(e.gravitationForceX=-this.gravityConstant*i*this.compoundGravityConstant,e.gravitationForceY=-this.gravityConstant*a*this.compoundGravityConstant))},l.prototype.isConverged=function(){var e,t=!1;return this.totalIterations>this.maxIterations/3&&(t=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),e=this.totalDisplacement=c.length||u>=c[0].length)){for(var d=0;de}}]),e}()}),(function(e,t,n){var r=function(){function e(e,t){for(var n=0;n2&&arguments[2]!==void 0?arguments[2]:1,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;i(this,e),this.sequence1=t,this.sequence2=n,this.match_score=r,this.mismatch_penalty=a,this.gap_penalty=o,this.iMax=t.length+1,this.jMax=n.length+1,this.grid=Array(this.iMax);for(var s=0;s=0;n--){var r=this.listeners[n];r.event===e&&r.callback===t&&this.listeners.splice(n,1)}},i.emit=function(e,t){for(var n=0;n{(function(r,i){typeof e==`object`&&typeof n==`object`?n.exports=i(t()):typeof define==`function`&&define.amd?define([`layout-base`],i):typeof e==`object`?e.coseBase=i(t()):r.coseBase=i(r.layoutBase)})(e,function(e){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=7)})([(function(t,n){t.exports=e}),(function(e,t,n){var r=n(0).FDLayoutConstants;function i(){}for(var a in r)i[a]=r[a];i.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,i.DEFAULT_RADIAL_SEPARATION=r.DEFAULT_EDGE_LENGTH,i.DEFAULT_COMPONENT_SEPERATION=60,i.TILE=!0,i.TILING_PADDING_VERTICAL=10,i.TILING_PADDING_HORIZONTAL=10,i.TREE_REDUCTION_ON_INCREMENTAL=!1,e.exports=i}),(function(e,t,n){var r=n(0).FDLayoutEdge;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),(function(e,t,n){var r=n(0).LGraph;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),(function(e,t,n){var r=n(0).LGraphManager;function i(e){r.call(this,e)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),(function(e,t,n){var r=n(0).FDLayoutNode,i=n(0).IMath;function a(e,t,n,i){r.call(this,e,t,n,i)}for(var o in a.prototype=Object.create(r.prototype),r)a[o]=r[o];a.prototype.move=function(){var e=this.graphManager.getLayout();this.displacementX=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementX=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementX)),Math.abs(this.displacementY)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementY=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementY)),this.child==null||this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),e.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},a.prototype.propogateDisplacementToChildren=function(e,t){for(var n=this.getChild().getNodes(),r,i=0;i0)this.positionNodesRadially(e);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n),this.positionNodesRandomly()}}else if(c.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n)}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},v.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%l.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-this.coolingCycle**+(Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=l.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=l.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var n=!this.isTreeGrowing&&!this.isGrowthFinished,r=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(n,r),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},v.prototype.getPositionsData=function(){for(var e=this.graphManager.getAllNodes(),t={},n=0;n1){var s;for(s=0;sr&&(r=Math.floor(o.y)),a=Math.floor(o.x+c.DEFAULT_COMPONENT_SEPERATION)}this.transform(new f(u.WORLD_CENTER_X-o.x/2,u.WORLD_CENTER_Y-o.y/2))},v.radialLayout=function(e,t,n){var r=Math.max(this.maxDiagonalInTree(e),c.DEFAULT_RADIAL_SEPARATION);v.branchRadialLayout(t,null,0,359,0,r);var i=g.calculateBounds(e),a=new _;a.setDeviceOrgX(i.getMinX()),a.setDeviceOrgY(i.getMinY()),a.setWorldOrgX(n.x),a.setWorldOrgY(n.y);for(var o=0;o1;){var _=g[0];g.splice(0,1);var y=u.indexOf(_);y>=0&&u.splice(y,1),p--,d--}m=t==null?0:(u.indexOf(g[0])+1)%p;for(var b=Math.abs(r-n)/d,x=m;f!=d;x=++x%p){var S=u[x].getOtherEnd(e);if(S!=t){var C=(n+f*b)%360,w=(C+b)%360;v.branchRadialLayout(S,e,C,w,i+a,a),f++}}},v.maxDiagonalInTree=function(e){for(var t=m.MIN_VALUE,n=0;nt&&(t=r)}return t},v.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},v.prototype.groupZeroDegreeMembers=function(){var e=this,t={};this.memberGroups={},this.idToDummyNode={};for(var n=[],r=this.graphManager.getAllNodes(),i=0;i1){var r=`DummyCompound_`+n;e.memberGroups[r]=t[n];var i=t[n][0].getParent(),a=new o(e.graphManager);a.id=r,a.paddingLeft=i.paddingLeft||0,a.paddingRight=i.paddingRight||0,a.paddingBottom=i.paddingBottom||0,a.paddingTop=i.paddingTop||0,e.idToDummyNode[r]=a;var s=e.getGraphManager().add(e.newGraph(),a),c=i.getChild();c.add(a);for(var l=0;l=0;e--){var t=this.compoundOrder[e],n=t.id,r=t.paddingLeft,i=t.paddingTop;this.adjustLocations(this.tiledMemberPack[n],t.rect.x,t.rect.y,r,i)}},v.prototype.repopulateZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack;Object.keys(t).forEach(function(n){var r=e.idToDummyNode[n],i=r.paddingLeft,a=r.paddingTop;e.adjustLocations(t[n],r.rect.x,r.rect.y,i,a)})},v.prototype.getToBeTiled=function(e){var t=e.id;if(this.toBeTiled[t]!=null)return this.toBeTiled[t];var n=e.getChild();if(n==null)return this.toBeTiled[t]=!1,!1;for(var r=n.getNodes(),i=0;i0)return this.toBeTiled[t]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[t]=!1,!1}return this.toBeTiled[t]=!0,!0},v.prototype.getNodeDegree=function(e){e.id;for(var t=e.getEdges(),n=0,r=0;rc&&(c=u.rect.height)}n+=c+e.verticalPadding}},v.prototype.tileCompoundMembers=function(e,t){var n=this;this.tiledMemberPack=[],Object.keys(e).forEach(function(r){var i=t[r];n.tiledMemberPack[r]=n.tileNodes(e[r],i.paddingLeft+i.paddingRight),i.rect.width=n.tiledMemberPack[r].width,i.rect.height=n.tiledMemberPack[r].height})},v.prototype.tileNodes=function(e,t){var n={rows:[],rowWidth:[],rowHeight:[],width:0,height:t,verticalPadding:c.TILING_PADDING_VERTICAL,horizontalPadding:c.TILING_PADDING_HORIZONTAL};e.sort(function(e,t){return e.rect.width*e.rect.height>t.rect.width*t.rect.height?-1:+(e.rect.width*e.rect.height0&&(a+=e.horizontalPadding),e.rowWidth[n]=a,e.width0&&(o+=e.verticalPadding);var s=0;o>e.rowHeight[n]&&(s=e.rowHeight[n],e.rowHeight[n]=o,s=e.rowHeight[n]-s),e.height+=s,e.rows[n].push(t)},v.prototype.getShortestRowIndex=function(e){for(var t=-1,n=Number.MAX_VALUE,r=0;rn&&(t=r,n=e.rowWidth[r]);return t},v.prototype.canAddHorizontal=function(e,t,n){var r=this.getShortestRowIndex(e);if(r<0)return!0;var i=e.rowWidth[r];if(i+e.horizontalPadding+t<=e.width)return!0;var a=0;e.rowHeight[r]0&&(a=n+e.verticalPadding-e.rowHeight[r]);var o=e.width-i>=t+e.horizontalPadding?(e.height+a)/(i+t+e.horizontalPadding):(e.height+a)/e.width;a=n+e.verticalPadding;var s=e.widtha&&t!=n){r.splice(-1,1),e.rows[n].push(i),e.rowWidth[t]=e.rowWidth[t]-a,e.rowWidth[n]=e.rowWidth[n]+a,e.width=e.rowWidth[instance.getLongestRowIndex(e)];for(var o=Number.MIN_VALUE,s=0;so&&(o=r[s].height);t>0&&(o+=e.verticalPadding);var c=e.rowHeight[t]+e.rowHeight[n];e.rowHeight[t]=o,e.rowHeight[n]0)for(var u=i;u<=a;u++)c[0]+=this.grid[u][o-1].length+this.grid[u][o].length-1;if(a0)for(var u=o;u<=s;u++)c[3]+=this.grid[i-1][u].length+this.grid[i][u].length-1;for(var d=m.MAX_VALUE,f,p,h=0;h{(function(r,i){typeof e==`object`&&typeof t==`object`?t.exports=i(n()):typeof define==`function`&&define.amd?define([`cose-base`],i):typeof e==`object`?e.cytoscapeCoseBilkent=i(n()):r.cytoscapeCoseBilkent=i(r.coseBase)})(e,function(e){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=1)})([(function(t,n){t.exports=e}),(function(e,t,n){var r=n(0).layoutBase.LayoutConstants,i=n(0).layoutBase.FDLayoutConstants,a=n(0).CoSEConstants,o=n(0).CoSELayout,s=n(0).CoSENode,c=n(0).layoutBase.PointD,l=n(0).layoutBase.DimensionD,u={ready:function(){},stop:function(){},quality:`default`,nodeDimensionsIncludeLabels:!1,refresh:30,fit:!0,padding:10,randomize:!0,nodeRepulsion:4500,idealEdgeLength:50,edgeElasticity:.45,nestingFactor:.1,gravity:.25,numIter:2500,tile:!0,animate:`end`,animationDuration:500,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:.5};function d(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function f(e){this.options=d(u,e),p(this.options)}var p=function(e){e.nodeRepulsion!=null&&(a.DEFAULT_REPULSION_STRENGTH=i.DEFAULT_REPULSION_STRENGTH=e.nodeRepulsion),e.idealEdgeLength!=null&&(a.DEFAULT_EDGE_LENGTH=i.DEFAULT_EDGE_LENGTH=e.idealEdgeLength),e.edgeElasticity!=null&&(a.DEFAULT_SPRING_STRENGTH=i.DEFAULT_SPRING_STRENGTH=e.edgeElasticity),e.nestingFactor!=null&&(a.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=e.nestingFactor),e.gravity!=null&&(a.DEFAULT_GRAVITY_STRENGTH=i.DEFAULT_GRAVITY_STRENGTH=e.gravity),e.numIter!=null&&(a.MAX_ITERATIONS=i.MAX_ITERATIONS=e.numIter),e.gravityRange!=null&&(a.DEFAULT_GRAVITY_RANGE_FACTOR=i.DEFAULT_GRAVITY_RANGE_FACTOR=e.gravityRange),e.gravityCompound!=null&&(a.DEFAULT_COMPOUND_GRAVITY_STRENGTH=i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=e.gravityCompound),e.gravityRangeCompound!=null&&(a.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=e.gravityRangeCompound),e.initialEnergyOnIncremental!=null&&(a.DEFAULT_COOLING_FACTOR_INCREMENTAL=i.DEFAULT_COOLING_FACTOR_INCREMENTAL=e.initialEnergyOnIncremental),e.quality==`draft`?r.QUALITY=0:e.quality==`proof`?r.QUALITY=2:r.QUALITY=1,a.NODE_DIMENSIONS_INCLUDE_LABELS=i.NODE_DIMENSIONS_INCLUDE_LABELS=r.NODE_DIMENSIONS_INCLUDE_LABELS=e.nodeDimensionsIncludeLabels,a.DEFAULT_INCREMENTAL=i.DEFAULT_INCREMENTAL=r.DEFAULT_INCREMENTAL=!e.randomize,a.ANIMATE=i.ANIMATE=r.ANIMATE=e.animate,a.TILE=e.tile,a.TILING_PADDING_VERTICAL=typeof e.tilingPaddingVertical==`function`?e.tilingPaddingVertical.call():e.tilingPaddingVertical,a.TILING_PADDING_HORIZONTAL=typeof e.tilingPaddingHorizontal==`function`?e.tilingPaddingHorizontal.call():e.tilingPaddingHorizontal};f.prototype.run=function(){var e,t,n=this.options;this.idToLNode={};var r=this.layout=new o,i=this;i.stopped=!1,this.cy=this.options.cy,this.cy.trigger({type:`layoutstart`,layout:this});var a=r.newGraphManager();this.gm=a;var s=this.options.eles.nodes(),c=this.options.eles.edges();this.root=a.addRoot(),this.processChildrenList(this.root,this.getTopMostNodes(s),r);for(var l=0;l0){var h=n.getGraphManager().add(n.newGraph(),u);this.processChildrenList(h,o,n)}}},f.prototype.stop=function(){return this.stopped=!0,this};var m=function(e){e(`layout`,`cose-bilkent`,f)};typeof cytoscape<`u`&&m(cytoscape),e.exports=m})])})}));export default r(); \ No newline at end of file +import{t as e}from"./index-BS2ceH9_.js";var t=e(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.layoutBase=r():n.layoutBase=r()})(e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=26)})([(function(e,t,n){function r(){}r.QUALITY=1,r.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,r.DEFAULT_INCREMENTAL=!1,r.DEFAULT_ANIMATION_ON_LAYOUT=!0,r.DEFAULT_ANIMATION_DURING_LAYOUT=!1,r.DEFAULT_ANIMATION_PERIOD=50,r.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,r.DEFAULT_GRAPH_MARGIN=15,r.NODE_DIMENSIONS_INCLUDE_LABELS=!1,r.SIMPLE_NODE_SIZE=40,r.SIMPLE_NODE_HALF_SIZE=r.SIMPLE_NODE_SIZE/2,r.EMPTY_COMPOUND_NODE_SIZE=40,r.MIN_EDGE_LENGTH=1,r.WORLD_BOUNDARY=1e6,r.INITIAL_WORLD_BOUNDARY=r.WORLD_BOUNDARY/1e3,r.WORLD_CENTER_X=1200,r.WORLD_CENTER_Y=900,e.exports=r}),(function(e,t,n){var r=n(2),i=n(8),a=n(9);function o(e,t,n){r.call(this,n),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=n,this.bendpoints=[],this.source=e,this.target=t}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.getSource=function(){return this.source},o.prototype.getTarget=function(){return this.target},o.prototype.isInterGraph=function(){return this.isInterGraph},o.prototype.getLength=function(){return this.length},o.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},o.prototype.getBendpoints=function(){return this.bendpoints},o.prototype.getLca=function(){return this.lca},o.prototype.getSourceInLca=function(){return this.sourceInLca},o.prototype.getTargetInLca=function(){return this.targetInLca},o.prototype.getOtherEnd=function(e){if(this.source===e)return this.target;if(this.target===e)return this.source;throw`Node is not incident with this edge`},o.prototype.getOtherEndInGraph=function(e,t){for(var n=this.getOtherEnd(e),r=t.getGraphManager().getRoot();;){if(n.getOwner()==t)return n;if(n.getOwner()==r)break;n=n.getOwner().getParent()}return null},o.prototype.updateLength=function(){var e=[,,,,];this.isOverlapingSourceAndTarget=i.getIntersection(this.target.getRect(),this.source.getRect(),e),this.isOverlapingSourceAndTarget||(this.lengthX=e[0]-e[2],this.lengthY=e[1]-e[3],Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},o.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},e.exports=o}),(function(e,t,n){function r(e){this.vGraphObject=e}e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(13),o=n(0),s=n(16),c=n(4);function l(e,t,n,o){n==null&&o==null&&(o=t),r.call(this,o),e.graphManager!=null&&(e=e.graphManager),this.estimatedSize=i.MIN_VALUE,this.inclusionTreeDepth=i.MAX_VALUE,this.vGraphObject=o,this.edges=[],this.graphManager=e,n!=null&&t!=null?this.rect=new a(t.x,t.y,n.width,n.height):this.rect=new a}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.getEdges=function(){return this.edges},l.prototype.getChild=function(){return this.child},l.prototype.getOwner=function(){return this.owner},l.prototype.getWidth=function(){return this.rect.width},l.prototype.setWidth=function(e){this.rect.width=e},l.prototype.getHeight=function(){return this.rect.height},l.prototype.setHeight=function(e){this.rect.height=e},l.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},l.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},l.prototype.getCenter=function(){return new c(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},l.prototype.getLocation=function(){return new c(this.rect.x,this.rect.y)},l.prototype.getRect=function(){return this.rect},l.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},l.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},l.prototype.setRect=function(e,t){this.rect.x=e.x,this.rect.y=e.y,this.rect.width=t.width,this.rect.height=t.height},l.prototype.setCenter=function(e,t){this.rect.x=e-this.rect.width/2,this.rect.y=t-this.rect.height/2},l.prototype.setLocation=function(e,t){this.rect.x=e,this.rect.y=t},l.prototype.moveBy=function(e,t){this.rect.x+=e,this.rect.y+=t},l.prototype.getEdgeListToNode=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.target==e){if(r.source!=n)throw`Incorrect edge source!`;t.push(r)}}),t},l.prototype.getEdgesBetween=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(!(r.source==n||r.target==n))throw`Incorrect edge source and/or target`;(r.target==e||r.source==e)&&t.push(r)}),t},l.prototype.getNeighborsList=function(){var e=new Set,t=this;return t.edges.forEach(function(n){if(n.source==t)e.add(n.target);else{if(n.target!=t)throw`Incorrect incidency!`;e.add(n.source)}}),e},l.prototype.withChildren=function(){var e=new Set,t,n;if(e.add(this),this.child!=null)for(var r=this.child.getNodes(),i=0;it&&(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)),this.labelHeight>n&&(this.labelPos==`center`?this.rect.y-=(this.labelHeight-n)/2:this.labelPos==`top`&&(this.rect.y-=this.labelHeight-n),this.setHeight(this.labelHeight))}}},l.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==i.MAX_VALUE)throw`assert failed`;return this.inclusionTreeDepth},l.prototype.transform=function(e){var t=this.rect.x;t>o.WORLD_BOUNDARY?t=o.WORLD_BOUNDARY:t<-o.WORLD_BOUNDARY&&(t=-o.WORLD_BOUNDARY);var n=this.rect.y;n>o.WORLD_BOUNDARY?n=o.WORLD_BOUNDARY:n<-o.WORLD_BOUNDARY&&(n=-o.WORLD_BOUNDARY);var r=new c(t,n),i=e.inverseTransformPoint(r);this.setLocation(i.x,i.y)},l.prototype.getLeft=function(){return this.rect.x},l.prototype.getRight=function(){return this.rect.x+this.rect.width},l.prototype.getTop=function(){return this.rect.y},l.prototype.getBottom=function(){return this.rect.y+this.rect.height},l.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},e.exports=l}),(function(e,t,n){function r(e,t){e==null&&t==null?(this.x=0,this.y=0):(this.x=e,this.y=t)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(e){this.x=e},r.prototype.setY=function(e){this.y=e},r.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(0),o=n(6),s=n(3),c=n(1),l=n(13),u=n(12),d=n(11);function f(e,t,n){r.call(this,n),this.estimatedSize=i.MIN_VALUE,this.margin=a.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,t!=null&&t instanceof o?this.graphManager=t:t!=null&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var p in f.prototype=Object.create(r.prototype),r)f[p]=r[p];f.prototype.getNodes=function(){return this.nodes},f.prototype.getEdges=function(){return this.edges},f.prototype.getGraphManager=function(){return this.graphManager},f.prototype.getParent=function(){return this.parent},f.prototype.getLeft=function(){return this.left},f.prototype.getRight=function(){return this.right},f.prototype.getTop=function(){return this.top},f.prototype.getBottom=function(){return this.bottom},f.prototype.isConnected=function(){return this.isConnected},f.prototype.add=function(e,t,n){if(t==null&&n==null){var r=e;if(this.graphManager==null)throw`Graph has no graph mgr!`;if(this.getNodes().indexOf(r)>-1)throw`Node already in graph!`;return r.owner=this,this.getNodes().push(r),r}else{var i=e;if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(n)>-1))throw`Source or target not in graph!`;if(!(t.owner==n.owner&&t.owner==this))throw`Both owners must be this graph!`;return t.owner==n.owner?(i.source=t,i.target=n,i.isInterGraph=!1,this.getEdges().push(i),t.edges.push(i),n!=t&&n.edges.push(i),i):null}},f.prototype.remove=function(e){var t=e;if(e instanceof s){if(t==null)throw`Node is null!`;if(!(t.owner!=null&&t.owner==this))throw`Owner graph is invalid!`;if(this.graphManager==null)throw`Owner graph manager is invalid!`;for(var n=t.edges.slice(),r,i=n.length,a=0;a-1&&u>-1))throw`Source and/or target doesn't know this edge!`;r.source.edges.splice(l,1),r.target!=r.source&&r.target.edges.splice(u,1);var o=r.source.owner.getEdges().indexOf(r);if(o==-1)throw`Not in owner's edge list!`;r.source.owner.getEdges().splice(o,1)}},f.prototype.updateLeftTop=function(){for(var e=i.MAX_VALUE,t=i.MAX_VALUE,n,r,a,o=this.getNodes(),s=o.length,c=0;cn&&(e=n),t>r&&(t=r)}return e==i.MAX_VALUE?null:(a=o[0].getParent().paddingLeft==null?this.margin:o[0].getParent().paddingLeft,this.left=t-a,this.top=e-a,new u(this.left,this.top))},f.prototype.updateBounds=function(e){for(var t=i.MAX_VALUE,n=-i.MAX_VALUE,r=i.MAX_VALUE,a=-i.MAX_VALUE,o,s,c,u,d,f=this.nodes,p=f.length,m=0;mo&&(t=o),nc&&(r=c),ao&&(t=o),nc&&(r=c),a=this.nodes.length){var c=0;n.forEach(function(t){t.owner==e&&c++}),c==this.nodes.length&&(this.isConnected=!0)}},e.exports=f}),(function(e,t,n){var r,i=n(1);function a(e){r=n(5),this.layout=e,this.graphs=[],this.edges=[]}a.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),n=this.add(e,t);return this.setRootGraph(n),this.rootGraph},a.prototype.add=function(e,t,n,r,i){if(n==null&&r==null&&i==null){if(e==null)throw`Graph is null!`;if(t==null)throw`Parent node is null!`;if(this.graphs.indexOf(e)>-1)throw`Graph already in this graph mgr!`;if(this.graphs.push(e),e.parent!=null)throw`Already has a parent!`;if(t.child!=null)throw`Already has a child!`;return e.parent=t,t.child=e,e}else{i=n,r=t,n=e;var a=r.getOwner(),o=i.getOwner();if(!(a!=null&&a.getGraphManager()==this))throw`Source not in this graph mgr!`;if(!(o!=null&&o.getGraphManager()==this))throw`Target not in this graph mgr!`;if(a==o)return n.isInterGraph=!1,a.add(n,r,i);if(n.isInterGraph=!0,n.source=r,n.target=i,this.edges.indexOf(n)>-1)throw`Edge already in inter-graph edge list!`;if(this.edges.push(n),!(n.source!=null&&n.target!=null))throw`Edge source and/or target is null!`;if(!(n.source.edges.indexOf(n)==-1&&n.target.edges.indexOf(n)==-1))throw`Edge already in source and/or target incidency list!`;return n.source.edges.push(n),n.target.edges.push(n),n}},a.prototype.remove=function(e){if(e instanceof r){var t=e;if(t.getGraphManager()!=this)throw`Graph not in this graph mgr`;if(!(t==this.rootGraph||t.parent!=null&&t.parent.graphManager==this))throw`Invalid parent node!`;var n=[];n=n.concat(t.getEdges());for(var a,o=n.length,s=0;s=t.getRight()?n[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight()):t.getX()<=e.getX()&&t.getRight()>=e.getRight()&&(n[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight())),e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()?n[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()):t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()&&(n[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()));var a=Math.abs((t.getCenterY()-e.getCenterY())/(t.getCenterX()-e.getCenterX()));t.getCenterY()===e.getCenterY()&&t.getCenterX()===e.getCenterX()&&(a=1);var o=a*n[0],s=n[1]/a;n[0]o)return n[0]=r,n[1]=c,n[2]=a,n[3]=y,!1;if(ia)return n[0]=s,n[1]=i,n[2]=_,n[3]=o,!1;if(ra?(n[0]=u,n[1]=d,C=!0):(n[0]=l,n[1]=c,C=!0):T===D&&(r>a?(n[0]=s,n[1]=c,C=!0):(n[0]=f,n[1]=d,C=!0)),-E===D?a>r?(n[2]=v,n[3]=y,w=!0):(n[2]=_,n[3]=g,w=!0):E===D&&(a>r?(n[2]=h,n[3]=g,w=!0):(n[2]=b,n[3]=y,w=!0)),C&&w)return!1;if(r>a?i>o?(O=this.getCardinalDirection(T,D,4),k=this.getCardinalDirection(E,D,2)):(O=this.getCardinalDirection(-T,D,3),k=this.getCardinalDirection(-E,D,1)):i>o?(O=this.getCardinalDirection(-T,D,1),k=this.getCardinalDirection(-E,D,3)):(O=this.getCardinalDirection(T,D,2),k=this.getCardinalDirection(E,D,4)),!C)switch(O){case 1:j=c,A=r+-m/D,n[0]=A,n[1]=j;break;case 2:A=f,j=i+p*D,n[0]=A,n[1]=j;break;case 3:j=d,A=r+m/D,n[0]=A,n[1]=j;break;case 4:A=u,j=i+-p*D,n[0]=A,n[1]=j;break}if(!w)switch(k){case 1:N=g,M=a+-S/D,n[2]=M,n[3]=N;break;case 2:M=b,N=o+x*D,n[2]=M,n[3]=N;break;case 3:N=y,M=a+S/D,n[2]=M,n[3]=N;break;case 4:M=v,N=o+-x*D,n[2]=M,n[3]=N;break}}return!1},i.getCardinalDirection=function(e,t,n){return e>t?n:1+n%4},i.getIntersection=function(e,t,n,i){if(i==null)return this.getIntersection2(e,t,n);var a=e.x,o=e.y,s=t.x,c=t.y,l=n.x,u=n.y,d=i.x,f=i.y,p=void 0,m=void 0,h=void 0,g=void 0,_=void 0,v=void 0,y=void 0,b=void 0,x=void 0;return h=c-o,_=a-s,y=s*o-a*c,g=f-u,v=l-d,b=d*u-l*f,x=h*v-g*_,x===0?null:(p=(_*b-v*y)/x,m=(g*y-h*b)/x,new r(p,m))},i.angleOfVector=function(e,t,n,r){var i=void 0;return e===n?i=r0?1:e<0?-1:0},r.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},r.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},e.exports=r}),(function(e,t,n){function r(){}r.MAX_VALUE=2147483647,r.MIN_VALUE=-2147483648,e.exports=r}),(function(e,t,n){var r=function(){function e(e,t){for(var n=0;n0&&t;){for(s.push(l[0]);s.length>0&&t;){var u=s[0];s.splice(0,1),o.add(u);for(var d=u.getEdges(),a=0;a-1&&l.splice(h,1)}o=new Set,c=new Map}}return e},f.prototype.createDummyNodesForBendpoints=function(e){for(var t=[],n=e.source,r=this.graphManager.calcLowestCommonAncestor(e.source,e.target),i=0;i0){for(var i=this.edgeToDummyNodes.get(n),a=0;a=0&&t.splice(d,1),s.getNeighborsList().forEach(function(e){if(n.indexOf(e)<0){var t=r.get(e)-1;t==1&&l.push(e),r.set(e,t)}})}n=n.concat(l),(t.length==1||t.length==2)&&(i=!0,a=t[0])}return a},f.prototype.setGraphManager=function(e){this.graphManager=e},e.exports=f}),(function(e,t,n){function r(){}r.seed=1,r.x=0,r.nextDouble=function(){return r.x=Math.sin(r.seed++)*1e4,r.x-Math.floor(r.x)},e.exports=r}),(function(e,t,n){var r=n(4);function i(e,t){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}i.prototype.getWorldOrgX=function(){return this.lworldOrgX},i.prototype.setWorldOrgX=function(e){this.lworldOrgX=e},i.prototype.getWorldOrgY=function(){return this.lworldOrgY},i.prototype.setWorldOrgY=function(e){this.lworldOrgY=e},i.prototype.getWorldExtX=function(){return this.lworldExtX},i.prototype.setWorldExtX=function(e){this.lworldExtX=e},i.prototype.getWorldExtY=function(){return this.lworldExtY},i.prototype.setWorldExtY=function(e){this.lworldExtY=e},i.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},i.prototype.setDeviceOrgX=function(e){this.ldeviceOrgX=e},i.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},i.prototype.setDeviceOrgY=function(e){this.ldeviceOrgY=e},i.prototype.getDeviceExtX=function(){return this.ldeviceExtX},i.prototype.setDeviceExtX=function(e){this.ldeviceExtX=e},i.prototype.getDeviceExtY=function(){return this.ldeviceExtY},i.prototype.setDeviceExtY=function(e){this.ldeviceExtY=e},i.prototype.transformX=function(e){var t=0,n=this.lworldExtX;return n!=0&&(t=this.ldeviceOrgX+(e-this.lworldOrgX)*this.ldeviceExtX/n),t},i.prototype.transformY=function(e){var t=0,n=this.lworldExtY;return n!=0&&(t=this.ldeviceOrgY+(e-this.lworldOrgY)*this.ldeviceExtY/n),t},i.prototype.inverseTransformX=function(e){var t=0,n=this.ldeviceExtX;return n!=0&&(t=this.lworldOrgX+(e-this.ldeviceOrgX)*this.lworldExtX/n),t},i.prototype.inverseTransformY=function(e){var t=0,n=this.ldeviceExtY;return n!=0&&(t=this.lworldOrgY+(e-this.ldeviceOrgY)*this.lworldExtY/n),t},i.prototype.inverseTransformPoint=function(e){return new r(this.inverseTransformX(e.x),this.inverseTransformY(e.y))},e.exports=i}),(function(e,t,n){function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);ta.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*a.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(e-a.ADAPTATION_LOWER_NODE_LIMIT)/(a.ADAPTATION_UPPER_NODE_LIMIT-a.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-a.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=a.MAX_NODE_DISPLACEMENT_INCREMENTAL):(e>a.ADAPTATION_LOWER_NODE_LIMIT?this.coolingFactor=Math.max(a.COOLING_ADAPTATION_FACTOR,1-(e-a.ADAPTATION_LOWER_NODE_LIMIT)/(a.ADAPTATION_UPPER_NODE_LIMIT-a.ADAPTATION_LOWER_NODE_LIMIT)*(1-a.COOLING_ADAPTATION_FACTOR)):this.coolingFactor=1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=a.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},l.prototype.calcSpringForces=function(){for(var e=this.getAllEdges(),t,n=0;n0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n,r,i,o,s=this.getAllNodes(),c;if(this.useFRGridVariant)for(this.totalIterations%a.GRID_CALCULATION_CHECK_PERIOD==1&&e&&this.updateGrid(),c=new Set,n=0;nc||s>c)&&(e.gravitationForceX=-this.gravityConstant*i,e.gravitationForceY=-this.gravityConstant*a)):(c=t.getEstimatedSize()*this.compoundGravityRangeFactor,(o>c||s>c)&&(e.gravitationForceX=-this.gravityConstant*i*this.compoundGravityConstant,e.gravitationForceY=-this.gravityConstant*a*this.compoundGravityConstant))},l.prototype.isConverged=function(){var e,t=!1;return this.totalIterations>this.maxIterations/3&&(t=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),e=this.totalDisplacement=c.length||u>=c[0].length)){for(var d=0;de}}]),e}()}),(function(e,t,n){var r=function(){function e(e,t){for(var n=0;n2&&arguments[2]!==void 0?arguments[2]:1,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;i(this,e),this.sequence1=t,this.sequence2=n,this.match_score=r,this.mismatch_penalty=a,this.gap_penalty=o,this.iMax=t.length+1,this.jMax=n.length+1,this.grid=Array(this.iMax);for(var s=0;s=0;n--){var r=this.listeners[n];r.event===e&&r.callback===t&&this.listeners.splice(n,1)}},i.emit=function(e,t){for(var n=0;n{(function(r,i){typeof e==`object`&&typeof n==`object`?n.exports=i(t()):typeof define==`function`&&define.amd?define([`layout-base`],i):typeof e==`object`?e.coseBase=i(t()):r.coseBase=i(r.layoutBase)})(e,function(e){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=7)})([(function(t,n){t.exports=e}),(function(e,t,n){var r=n(0).FDLayoutConstants;function i(){}for(var a in r)i[a]=r[a];i.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,i.DEFAULT_RADIAL_SEPARATION=r.DEFAULT_EDGE_LENGTH,i.DEFAULT_COMPONENT_SEPERATION=60,i.TILE=!0,i.TILING_PADDING_VERTICAL=10,i.TILING_PADDING_HORIZONTAL=10,i.TREE_REDUCTION_ON_INCREMENTAL=!1,e.exports=i}),(function(e,t,n){var r=n(0).FDLayoutEdge;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),(function(e,t,n){var r=n(0).LGraph;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),(function(e,t,n){var r=n(0).LGraphManager;function i(e){r.call(this,e)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),(function(e,t,n){var r=n(0).FDLayoutNode,i=n(0).IMath;function a(e,t,n,i){r.call(this,e,t,n,i)}for(var o in a.prototype=Object.create(r.prototype),r)a[o]=r[o];a.prototype.move=function(){var e=this.graphManager.getLayout();this.displacementX=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementX=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementX)),Math.abs(this.displacementY)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementY=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementY)),this.child==null||this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),e.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},a.prototype.propogateDisplacementToChildren=function(e,t){for(var n=this.getChild().getNodes(),r,i=0;i0)this.positionNodesRadially(e);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n),this.positionNodesRandomly()}}else if(c.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n)}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},v.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%l.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-this.coolingCycle**+(Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=l.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=l.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var n=!this.isTreeGrowing&&!this.isGrowthFinished,r=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(n,r),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},v.prototype.getPositionsData=function(){for(var e=this.graphManager.getAllNodes(),t={},n=0;n1){var s;for(s=0;sr&&(r=Math.floor(o.y)),a=Math.floor(o.x+c.DEFAULT_COMPONENT_SEPERATION)}this.transform(new f(u.WORLD_CENTER_X-o.x/2,u.WORLD_CENTER_Y-o.y/2))},v.radialLayout=function(e,t,n){var r=Math.max(this.maxDiagonalInTree(e),c.DEFAULT_RADIAL_SEPARATION);v.branchRadialLayout(t,null,0,359,0,r);var i=g.calculateBounds(e),a=new _;a.setDeviceOrgX(i.getMinX()),a.setDeviceOrgY(i.getMinY()),a.setWorldOrgX(n.x),a.setWorldOrgY(n.y);for(var o=0;o1;){var _=g[0];g.splice(0,1);var y=u.indexOf(_);y>=0&&u.splice(y,1),p--,d--}m=t==null?0:(u.indexOf(g[0])+1)%p;for(var b=Math.abs(r-n)/d,x=m;f!=d;x=++x%p){var S=u[x].getOtherEnd(e);if(S!=t){var C=(n+f*b)%360,w=(C+b)%360;v.branchRadialLayout(S,e,C,w,i+a,a),f++}}},v.maxDiagonalInTree=function(e){for(var t=m.MIN_VALUE,n=0;nt&&(t=r)}return t},v.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},v.prototype.groupZeroDegreeMembers=function(){var e=this,t={};this.memberGroups={},this.idToDummyNode={};for(var n=[],r=this.graphManager.getAllNodes(),i=0;i1){var r=`DummyCompound_`+n;e.memberGroups[r]=t[n];var i=t[n][0].getParent(),a=new o(e.graphManager);a.id=r,a.paddingLeft=i.paddingLeft||0,a.paddingRight=i.paddingRight||0,a.paddingBottom=i.paddingBottom||0,a.paddingTop=i.paddingTop||0,e.idToDummyNode[r]=a;var s=e.getGraphManager().add(e.newGraph(),a),c=i.getChild();c.add(a);for(var l=0;l=0;e--){var t=this.compoundOrder[e],n=t.id,r=t.paddingLeft,i=t.paddingTop;this.adjustLocations(this.tiledMemberPack[n],t.rect.x,t.rect.y,r,i)}},v.prototype.repopulateZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack;Object.keys(t).forEach(function(n){var r=e.idToDummyNode[n],i=r.paddingLeft,a=r.paddingTop;e.adjustLocations(t[n],r.rect.x,r.rect.y,i,a)})},v.prototype.getToBeTiled=function(e){var t=e.id;if(this.toBeTiled[t]!=null)return this.toBeTiled[t];var n=e.getChild();if(n==null)return this.toBeTiled[t]=!1,!1;for(var r=n.getNodes(),i=0;i0)return this.toBeTiled[t]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[t]=!1,!1}return this.toBeTiled[t]=!0,!0},v.prototype.getNodeDegree=function(e){e.id;for(var t=e.getEdges(),n=0,r=0;rc&&(c=u.rect.height)}n+=c+e.verticalPadding}},v.prototype.tileCompoundMembers=function(e,t){var n=this;this.tiledMemberPack=[],Object.keys(e).forEach(function(r){var i=t[r];n.tiledMemberPack[r]=n.tileNodes(e[r],i.paddingLeft+i.paddingRight),i.rect.width=n.tiledMemberPack[r].width,i.rect.height=n.tiledMemberPack[r].height})},v.prototype.tileNodes=function(e,t){var n={rows:[],rowWidth:[],rowHeight:[],width:0,height:t,verticalPadding:c.TILING_PADDING_VERTICAL,horizontalPadding:c.TILING_PADDING_HORIZONTAL};e.sort(function(e,t){return e.rect.width*e.rect.height>t.rect.width*t.rect.height?-1:+(e.rect.width*e.rect.height0&&(a+=e.horizontalPadding),e.rowWidth[n]=a,e.width0&&(o+=e.verticalPadding);var s=0;o>e.rowHeight[n]&&(s=e.rowHeight[n],e.rowHeight[n]=o,s=e.rowHeight[n]-s),e.height+=s,e.rows[n].push(t)},v.prototype.getShortestRowIndex=function(e){for(var t=-1,n=Number.MAX_VALUE,r=0;rn&&(t=r,n=e.rowWidth[r]);return t},v.prototype.canAddHorizontal=function(e,t,n){var r=this.getShortestRowIndex(e);if(r<0)return!0;var i=e.rowWidth[r];if(i+e.horizontalPadding+t<=e.width)return!0;var a=0;e.rowHeight[r]0&&(a=n+e.verticalPadding-e.rowHeight[r]);var o=e.width-i>=t+e.horizontalPadding?(e.height+a)/(i+t+e.horizontalPadding):(e.height+a)/e.width;a=n+e.verticalPadding;var s=e.widtha&&t!=n){r.splice(-1,1),e.rows[n].push(i),e.rowWidth[t]=e.rowWidth[t]-a,e.rowWidth[n]=e.rowWidth[n]+a,e.width=e.rowWidth[instance.getLongestRowIndex(e)];for(var o=Number.MIN_VALUE,s=0;so&&(o=r[s].height);t>0&&(o+=e.verticalPadding);var c=e.rowHeight[t]+e.rowHeight[n];e.rowHeight[t]=o,e.rowHeight[n]0)for(var u=i;u<=a;u++)c[0]+=this.grid[u][o-1].length+this.grid[u][o].length-1;if(a0)for(var u=o;u<=s;u++)c[3]+=this.grid[i-1][u].length+this.grid[i][u].length-1;for(var d=m.MAX_VALUE,f,p,h=0;h{(function(r,i){typeof e==`object`&&typeof t==`object`?t.exports=i(n()):typeof define==`function`&&define.amd?define([`cose-base`],i):typeof e==`object`?e.cytoscapeCoseBilkent=i(n()):r.cytoscapeCoseBilkent=i(r.coseBase)})(e,function(e){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=1)})([(function(t,n){t.exports=e}),(function(e,t,n){var r=n(0).layoutBase.LayoutConstants,i=n(0).layoutBase.FDLayoutConstants,a=n(0).CoSEConstants,o=n(0).CoSELayout,s=n(0).CoSENode,c=n(0).layoutBase.PointD,l=n(0).layoutBase.DimensionD,u={ready:function(){},stop:function(){},quality:`default`,nodeDimensionsIncludeLabels:!1,refresh:30,fit:!0,padding:10,randomize:!0,nodeRepulsion:4500,idealEdgeLength:50,edgeElasticity:.45,nestingFactor:.1,gravity:.25,numIter:2500,tile:!0,animate:`end`,animationDuration:500,tilingPaddingVertical:10,tilingPaddingHorizontal:10,gravityRangeCompound:1.5,gravityCompound:1,gravityRange:3.8,initialEnergyOnIncremental:.5};function d(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function f(e){this.options=d(u,e),p(this.options)}var p=function(e){e.nodeRepulsion!=null&&(a.DEFAULT_REPULSION_STRENGTH=i.DEFAULT_REPULSION_STRENGTH=e.nodeRepulsion),e.idealEdgeLength!=null&&(a.DEFAULT_EDGE_LENGTH=i.DEFAULT_EDGE_LENGTH=e.idealEdgeLength),e.edgeElasticity!=null&&(a.DEFAULT_SPRING_STRENGTH=i.DEFAULT_SPRING_STRENGTH=e.edgeElasticity),e.nestingFactor!=null&&(a.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=e.nestingFactor),e.gravity!=null&&(a.DEFAULT_GRAVITY_STRENGTH=i.DEFAULT_GRAVITY_STRENGTH=e.gravity),e.numIter!=null&&(a.MAX_ITERATIONS=i.MAX_ITERATIONS=e.numIter),e.gravityRange!=null&&(a.DEFAULT_GRAVITY_RANGE_FACTOR=i.DEFAULT_GRAVITY_RANGE_FACTOR=e.gravityRange),e.gravityCompound!=null&&(a.DEFAULT_COMPOUND_GRAVITY_STRENGTH=i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=e.gravityCompound),e.gravityRangeCompound!=null&&(a.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=e.gravityRangeCompound),e.initialEnergyOnIncremental!=null&&(a.DEFAULT_COOLING_FACTOR_INCREMENTAL=i.DEFAULT_COOLING_FACTOR_INCREMENTAL=e.initialEnergyOnIncremental),e.quality==`draft`?r.QUALITY=0:e.quality==`proof`?r.QUALITY=2:r.QUALITY=1,a.NODE_DIMENSIONS_INCLUDE_LABELS=i.NODE_DIMENSIONS_INCLUDE_LABELS=r.NODE_DIMENSIONS_INCLUDE_LABELS=e.nodeDimensionsIncludeLabels,a.DEFAULT_INCREMENTAL=i.DEFAULT_INCREMENTAL=r.DEFAULT_INCREMENTAL=!e.randomize,a.ANIMATE=i.ANIMATE=r.ANIMATE=e.animate,a.TILE=e.tile,a.TILING_PADDING_VERTICAL=typeof e.tilingPaddingVertical==`function`?e.tilingPaddingVertical.call():e.tilingPaddingVertical,a.TILING_PADDING_HORIZONTAL=typeof e.tilingPaddingHorizontal==`function`?e.tilingPaddingHorizontal.call():e.tilingPaddingHorizontal};f.prototype.run=function(){var e,t,n=this.options;this.idToLNode={};var r=this.layout=new o,i=this;i.stopped=!1,this.cy=this.options.cy,this.cy.trigger({type:`layoutstart`,layout:this});var a=r.newGraphManager();this.gm=a;var s=this.options.eles.nodes(),c=this.options.eles.edges();this.root=a.addRoot(),this.processChildrenList(this.root,this.getTopMostNodes(s),r);for(var l=0;l0){var h=n.getGraphManager().add(n.newGraph(),u);this.processChildrenList(h,o,n)}}},f.prototype.stop=function(){return this.stopped=!0,this};var m=function(e){e(`layout`,`cose-bilkent`,f)};typeof cytoscape<`u`&&m(cytoscape),e.exports=m})])})}));export default r(); \ No newline at end of file diff --git a/internal/ui/dist/assets/index-B9ZFj2IV.js b/internal/ui/dist/assets/index-BS2ceH9_.js similarity index 98% rename from internal/ui/dist/assets/index-B9ZFj2IV.js rename to internal/ui/dist/assets/index-BS2ceH9_.js index 5da8e1a..361e2e4 100644 --- a/internal/ui/dist/assets/index-B9ZFj2IV.js +++ b/internal/ui/dist/assets/index-BS2ceH9_.js @@ -6,4 +6,4 @@ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r= `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Te=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?we(n):``}function De(e,t){switch(e.tag){case 26:case 27:case 5:return we(e.type);case 16:return we(`Lazy`);case 13:return e.child!==t&&t!==null?we(`Suspense Fallback`):we(`Suspense`);case 19:return we(`SuspenseList`);case 0:case 15:return Ee(e.type,!1);case 11:return Ee(e.type.render,!1);case 1:return Ee(e.type,!0);case 31:return we(`Activity`);default:return``}}function Oe(e){try{var t=``,n=null;do t+=De(e,n),n=e,e=e.return;while(e);return t}catch(e){return` Error generating stack: `+e.message+` `+e.stack}}var ke=Object.prototype.hasOwnProperty,Ae=t.unstable_scheduleCallback,je=t.unstable_cancelCallback,Me=t.unstable_shouldYield,Ne=t.unstable_requestPaint,Pe=t.unstable_now,Fe=t.unstable_getCurrentPriorityLevel,Ie=t.unstable_ImmediatePriority,Le=t.unstable_UserBlockingPriority,Re=t.unstable_NormalPriority,ze=t.unstable_LowPriority,Be=t.unstable_IdlePriority,Ve=t.log,He=t.unstable_setDisableYieldValue,Ue=null,We=null;function A(e){if(typeof Ve==`function`&&He(e),We&&typeof We.setStrictMode==`function`)try{We.setStrictMode(Ue,e)}catch{}}var j=Math.clz32?Math.clz32:qe,Ge=Math.log,Ke=Math.LN2;function qe(e){return e>>>=0,e===0?32:31-(Ge(e)/Ke|0)|0}var Je=256,Ye=262144,Xe=4194304;function Ze(e){var t=e&42;if(t!==0)return t;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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ze(n))):i=Ze(o):i=Ze(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ze(n))):i=Ze(o)):i=Ze(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function $e(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function et(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32: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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function tt(){var e=Xe;return Xe<<=1,!(Xe&62914560)&&(Xe=4194304),e}function nt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function rt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function it(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),_n=!1;if(gn)try{var vn={};Object.defineProperty(vn,`passive`,{get:function(){_n=!0}}),window.addEventListener(`test`,vn,vn),window.removeEventListener(`test`,vn,vn)}catch{_n=!1}var yn=null,bn=null,xn=null;function Sn(){if(xn)return xn;var e,t=bn,n=t.length,r,i=`value`in yn?yn.value:yn.textContent,a=i.length;for(e=0;e=er),rr=` `,ir=!1;function ar(e,t){switch(e){case`keyup`:return Qn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function or(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var sr=!1;function cr(e,t){switch(e){case`compositionend`:return or(t);case`keypress`:return t.which===32?(ir=!0,rr):null;case`textInput`:return e=t.data,e===rr&&ir?null:e;default:return null}}function lr(e,t){if(sr)return e===`compositionend`||!$n&&ar(e,t)?(e=Sn(),xn=bn=yn=null,sr=!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}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=jr(n)}}function Nr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Pr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ut(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ut(e.document)}return t}function Fr(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`)}var Ir=gn&&`documentMode`in document&&11>=document.documentMode,Lr=null,Rr=null,zr=null,Br=!1;function Vr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Br||Lr==null||Lr!==Ut(r)||(r=Lr,`selectionStart`in r&&Fr(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}),zr&&Ar(zr,r)||(zr=r,r=Ed(Rr,`onSelect`),0>=o,i-=o,Ni=1<<32-j(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),N&&Fi(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),N&&Fi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return N&&Fi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),N&&Fi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===re&&Na(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ba(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=bi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=yi(o.type,o.key,o.props,null,e.mode,c),Ba(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=Ci(o,e.mode,c),c.return=e,e=c}return s(e);case re:return o=Na(o),b(e,r,o,c)}if(le(o))return h(e,r,o,c);if(se(o)){if(l=se(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,za(o),c);if(o.$$typeof===C)return b(e,r,ca(e,o),c);Va(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=xi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ra=0;var i=b(e,t,n,r);return La=null,i}catch(t){if(t===Da||t===ka)throw t;var a=hi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ua=Ha(!0),Wa=Ha(!1),Ga=!1;function Ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qa(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ja(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ya(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,G&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=fi(e),di(e,null,n),t}return ci(e,r,t,n),fi(e)}function Xa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ot(e,n)}}function Za(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Qa=!1;function $a(){if(Qa){var e=va;if(e!==null)throw e}}function eo(e,t,n,r){Qa=!1;var i=e.updateQueue;Ga=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(J&f)===f:(r&f)===f){f!==0&&f===_a&&(Qa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Ga=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Gl|=o,e.lanes=o,e.memoizedState=d}}function to(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function no(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=E.T,s={};E.T=s,Ls(e,!1,t,n);try{var c=i(),l=E.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Is(e,t,xa(c,r),pu(e)):Is(e,t,r,pu(e))}catch(n){Is(e,t,{then:function(){},status:`rejected`,reason:n},pu())}finally{D.p=a,o!==null&&s.types!==null&&(o.types=s.types),E.T=o}}function Es(){}function Ds(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Os(e).queue;Ts(e,a,t,ue,n===null?Es:function(){return ks(e),n(r)})}function Os(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ue,baseState:ue,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:ue},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ro,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ks(e){var t=Os(e);t.next===null&&(t=e.alternate.memoizedState),Is(e,t.next.queue,{},pu())}function As(){return sa(Qf)}function js(){return B().memoizedState}function Ms(){return B().memoizedState}function Ns(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=pu();e=Ja(n);var r=Ya(t,e,n);r!==null&&(hu(r,t,n),Xa(r,t,n)),t={cache:pa()},e.payload=t;return}t=t.return}}function Ps(e,t,n){var r=pu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Rs(e)?zs(t,n):(n=li(e,t,n,r),n!==null&&(hu(n,e,r),Bs(n,t,r)))}function Fs(e,t,n){Is(e,t,n,pu())}function Is(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rs(e))zs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,kr(s,o))return ci(e,t,i,0),K===null&&si(),!1}catch{}if(n=li(e,t,i,r),n!==null)return hu(n,e,r),Bs(n,t,r),!0}return!1}function Ls(e,t,n,r){if(r={lane:2,revertLane:dd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Rs(e)){if(t)throw Error(i(479))}else t=li(e,n,r,2),t!==null&&hu(t,e,2)}function Rs(e){var t=e.alternate;return e===I||t!==null&&t===I}function zs(e,t){yo=vo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Bs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ot(e,n)}}var Vs={readContext:sa,use:Io,useCallback:z,useContext:z,useEffect:z,useImperativeHandle:z,useLayoutEffect:z,useInsertionEffect:z,useMemo:z,useReducer:z,useRef:z,useState:z,useDebugValue:z,useDeferredValue:z,useTransition:z,useSyncExternalStore:z,useId:z,useHostTransitionStatus:z,useFormState:z,useActionState:z,useOptimistic:z,useMemoCache:z,useCacheRefresh:z};Vs.useEffectEvent=z;var Hs={readContext:sa,use:Io,useCallback:function(e,t){return No().memoizedState=[e,t===void 0?null:t],e},useContext:sa,useEffect:fs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),us(4194308,4,vs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return us(4194308,4,e,t)},useInsertionEffect:function(e,t){us(4,2,e,t)},useMemo:function(e,t){var n=No();t=t===void 0?null:t;var r=e();if(bo){A(!0);try{e()}finally{A(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=No();if(n!==void 0){var i=n(t);if(bo){A(!0);try{n(t)}finally{A(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ps.bind(null,I,e),[r.memoizedState,e]},useRef:function(e){var t=No();return e={current:e},t.memoizedState=e},useState:function(e){e=Jo(e);var t=e.queue,n=Fs.bind(null,I,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:bs,useDeferredValue:function(e,t){return Cs(No(),e,t)},useTransition:function(){var e=Jo(!1);return e=Ts.bind(null,I,e.queue,!0,!1),No().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=I,a=No();if(N){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),K===null)throw Error(i(349));J&127||Uo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,fs(Go.bind(null,r,o,e),[e]),r.flags|=2048,cs(9,{destroy:void 0},Wo.bind(null,r,o,n,t),null),n},useId:function(){var e=No(),t=K.identifierPrefix;if(N){var n=Pi,r=Ni;n=(r&~(1<<32-j(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=xo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[pt]=t,o[mt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Fc(t)}}return H(t),Ic(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Fc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ge.current,qi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Bi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[pt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Md(e.nodeValue,n)),e||Wi(t,!0)}else e=Bd(e).createTextNode(r),e[pt]=t,t.stateNode=e}return H(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=qi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[pt]=t}else Ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;H(t),e=!1}else n=Yi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(ho(t),t):(ho(t),null);if(t.flags&128)throw Error(i(558))}return H(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=qi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[pt]=t}else Ji(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;H(t),a=!1}else a=Yi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(ho(t),t):(ho(t),null)}return ho(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Rc(t,t.updateQueue),H(t),null);case 4:return ye(),e===null&&Sd(t.stateNode.containerInfo),H(t),null;case 10:return ta(t.type),H(t),null;case 19:if(O(F),r=t.memoizedState,r===null)return H(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)zc(r,!1);else{if(X!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=go(e),o!==null){for(t.flags|=128,zc(r,!1),e=o.updateQueue,t.updateQueue=e,Rc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)vi(n,e),n=n.sibling;return k(F,F.current&1|2),N&&Fi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Pe()>tu&&(t.flags|=128,a=!0,zc(r,!1),t.lanes=4194304)}else{if(!a)if(e=go(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Rc(t,e),zc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!N)return H(t),null}else 2*Pe()-r.renderingStartTime>tu&&n!==536870912&&(t.flags|=128,a=!0,zc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(H(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Pe(),e.sibling=null,n=F.current,k(F,a?n&1|2:n&1),N&&Fi(t,r.treeForkCount),e);case 22:case 23:return ho(t),so(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(H(t),t.subtreeFlags&6&&(t.flags|=8192)):H(t),n=t.updateQueue,n!==null&&Rc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&O(Ca),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ta(P),H(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Vc(e,t){switch(Ri(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ta(P),ye(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return xe(t),null;case 31:if(t.memoizedState!==null){if(ho(t),t.alternate===null)throw Error(i(340));Ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ho(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ji()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return O(F),null;case 4:return ye(),null;case 10:return ta(t.type),null;case 22:case 23:return ho(t),so(),e!==null&&O(Ca),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ta(P),null;case 25:return null;default:return null}}function Hc(e,t){switch(Ri(t),t.tag){case 3:ta(P),ye();break;case 26:case 27:case 5:xe(t);break;case 4:ye();break;case 31:t.memoizedState!==null&&ho(t);break;case 13:ho(t);break;case 19:O(F);break;case 10:ta(t.type);break;case 22:case 23:ho(t),so(),e!==null&&O(Ca);break;case 24:ta(P)}}function Uc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Wc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function Gc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{no(t,n)}catch(t){Z(e,e.return,t)}}}function Kc(e,t,n){n.props=Ys(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function qc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function Jc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}function Yc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Z(e,e.return,t)}}function Xc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[mt]=t}catch(t){Z(e,e.return,t)}}function Zc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Zc(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.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function $c(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=sn));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for($c(e,t,n),e=e.sibling;e!==null;)$c(e,t,n),e=e.sibling}function el(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&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(el(e,t,n),e=e.sibling;e!==null;)el(e,t,n),e=e.sibling}function tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[pt]=e,t[mt]=n}catch(t){Z(e,e.return,t)}}var nl=!1,U=!1,rl=!1,il=typeof WeakSet==`function`?WeakSet:Set,al=null;function ol(e,t){if(e=e.containerInfo,Rd=sp,e=Pr(e),Fr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,al=t;al!==null;)if(t=al,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,al=e;else for(;al!==null;){switch(t=al,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(o,r,n),o[pt]=e,Et(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=Mr(s,h),v=Mr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,E.T=null,n=lu,lu=null;var o=au,s=su;if(iu=0,ou=au=null,su=0,G&6)throw Error(i(331));var c=G;if(G|=4,Fl(o.current),Dl(o,o.current,s,n),G=c,id(0,!1),We&&typeof We.onPostCommitFiberRoot==`function`)try{We.onPostCommitFiberRoot(Ue,o)}catch{}return!0}finally{D.p=a,E.T=r,Vu(e,t)}}function Wu(e,t,n){t=Ti(n,t),t=tc(e.stateNode,t,2),e=Ya(e,t,2),e!==null&&(rt(e,2),rd(e))}function Z(e,t,n){if(e.tag===3)Wu(e,e,n);else for(;t!==null;){if(t.tag===3){Wu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(ru===null||!ru.has(r))){e=Ti(n,e),n=nc(2),r=Ya(t,n,2),r!==null&&(rc(n,r,t,e),rt(r,2),rd(r));break}}t=t.return}}function Gu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new zl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Ul=!0,i.add(n),e=Ku.bind(null,e,t,n),t.then(e,e))}function Ku(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,K===e&&(J&n)===n&&(X===4||X===3&&(J&62914560)===J&&300>Pe()-$l?!(G&2)&&Su(e,0):ql|=n,Yl===J&&(Yl=0)),rd(e)}function qu(e,t){t===0&&(t=tt()),e=ui(e,t),e!==null&&(rt(e,t),rd(e))}function Ju(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),qu(e,n)}function Yu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),qu(e,n)}function Xu(e,t){return Ae(e,t)}var Zu=null,Qu=null,$u=!1,ed=!1,td=!1,nd=0;function rd(e){e!==Qu&&e.next===null&&(Qu===null?Zu=Qu=e:Qu=Qu.next=e),ed=!0,$u||($u=!0,ud())}function id(e,t){if(!td&&ed){td=!0;do for(var n=!1,r=Zu;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-j(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ld(r,a))}else a=J,a=Qe(r,r===K?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||$e(r,a)||(n=!0,ld(r,a));r=r.next}while(n);td=!1}}function ad(){od()}function od(){ed=$u=!1;var e=0;nd!==0&&Gd()&&(e=nd);for(var t=Pe(),n=null,r=Zu;r!==null;){var i=r.next,a=sd(r,t);a===0?(r.next=null,n===null?Zu=i:n.next=i,i===null&&(Qu=n)):(n=r,(e!==0||a&3)&&(ed=!0)),r=i}iu!==0&&iu!==5||id(e,!1),nd!==0&&(nd=0)}function sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Gt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),Et(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Gt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Gt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Gt(n.imageSizes)+`"]`)):i+=`[href="`+Gt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),Et(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Gt(r)+`"][href="`+Gt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),Et(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=Tt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);Et(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=Tt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),Et(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=Tt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),Et(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ge.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=Tt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=Tt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=Tt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Gt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),Et(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Gt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Gt(n.href)+`"]`);if(r)return t.instance=r,Et(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Et(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,Et(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),Et(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,Et(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Et(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Et(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),Et(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=o((e=>{var t=Symbol.for(`react.transitional.element`);function n(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.jsx=n,e.jsxs=n})),v=o(((e,t)=>{t.exports=_()}));function y(...e){let t=``;for(let n of e)n&&(t+=t?` `+n:n);return t}var b=0;function x(e=`rcs`){return b+=1,`${e}-${b}`}var S=v(),C=c(u(),1),w=C.forwardRef(function(e,t){let{variant:n=`secondary`,size:r=`md`,shape:i=`rect`,loading:a=!1,disabled:o=!1,block:s=!1,iconLeft:c,iconRight:l,type:u=`button`,children:d,onClick:f,className:p,style:m,id:h,"data-testid":g,"aria-label":_,"aria-labelledby":v,"aria-describedby":b}=e;return(0,S.jsxs)(`button`,{ref:t,id:h,"data-testid":g,type:u,className:y(`rcs-button`,`rcs-button--${n}`,`rcs-button--${r}`,i!==`rect`&&`rcs-button--${i}`,s&&`rcs-button--block`,p),style:m,disabled:o||a,"aria-disabled":o||a||void 0,"aria-busy":a||void 0,"aria-label":_,"aria-labelledby":v,"aria-describedby":b,onClick:f,children:[a?(0,S.jsx)(`span`,{className:`rcs-button-spinner`,"aria-hidden":!0}):c,d,l]})}),ee=C.forwardRef(function(e,t){let{icon:n,round:r=!1,"aria-label":i,...a}=e;return(0,S.jsx)(w,{ref:t,...a,shape:r?`circle`:`square`,"aria-label":i,children:n})}),te=C.forwardRef(function(e,t){let{value:n,defaultValue:r,placeholder:i,size:a=`md`,status:o=`default`,disabled:s=!1,readOnly:c=!1,invalid:l=!1,prefix:u,suffix:d,clearable:f=!1,type:p=`text`,autoFocus:m=!1,onChange:h,onFocus:g,onBlur:_,onKeyDown:v,className:b,style:x,id:w,"data-testid":ee,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re}=e,ie=n!==void 0,[ae,oe]=C.useState(r??``),se=ie?n:ae,ce=C.useRef(null);C.useImperativeHandle(t,()=>ce.current);let T=l?`error`:o;return(0,S.jsxs)(`span`,{className:y(`rcs-input-wrap`,`rcs-input-wrap--${a}`,b),style:x,"data-status":T,"data-disabled":s||void 0,children:[u&&(0,S.jsx)(`span`,{className:`rcs-input-affix rcs-input-affix--left`,children:u}),(0,S.jsx)(`input`,{ref:ce,id:w,"data-testid":ee,className:`rcs-input`,type:p,value:se,placeholder:i,disabled:s,readOnly:c,autoFocus:m,"aria-invalid":T===`error`||void 0,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re,onChange:e=>{ie||oe(e.target.value),h?.(e.target.value,e)},onFocus:g,onBlur:_,onKeyDown:v}),f&&se&&!s&&!c&&(0,S.jsx)(`button`,{type:`button`,className:`rcs-input-clear`,"aria-label":`Clear`,onClick:e=>{let t=ce.current;ie||oe(``),t&&((Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set)?.call(t,``),t.dispatchEvent(new Event(`input`,{bubbles:!0}))),h?.(``,e)},children:`×`}),d&&(0,S.jsx)(`span`,{className:`rcs-input-affix rcs-input-affix--right`,children:d})]})});C.forwardRef(function(e,t){let{value:n,defaultValue:r,placeholder:i,rows:a=4,autoResize:o=!1,maxLength:s,showCount:c=!1,size:l=`md`,status:u=`default`,disabled:d=!1,readOnly:f=!1,invalid:p=!1,onChange:m,onFocus:h,onBlur:g,onKeyDown:_,autoFocus:v,className:b,style:x,id:w,"data-testid":ee,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re}=e,ie=n!==void 0,[ae,oe]=C.useState(r??``),se=ie?n:ae,ce=C.useRef(null);C.useImperativeHandle(t,()=>ce.current),C.useLayoutEffect(()=>{if(!o)return;let e=ce.current;e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},[se,o]);let T=p?`error`:u;return(0,S.jsxs)(`span`,{style:{display:`block`,width:`100%`,...x},children:[(0,S.jsx)(`textarea`,{ref:ce,id:w,"data-testid":ee,className:y(`rcs-textarea`,`rcs-textarea--${l}`,b),rows:a,value:se,placeholder:i,maxLength:s,disabled:d,readOnly:f,autoFocus:v,"aria-invalid":T===`error`||void 0,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re,"data-status":T,onChange:e=>{ie||oe(e.target.value),m?.(e.target.value,e)},onFocus:h,onBlur:g,onKeyDown:_}),c&&(0,S.jsxs)(`span`,{className:`rcs-textarea-count`,children:[se.length,s?` / ${s}`:``]})]})});function ne(e){let{tone:t=`neutral`,size:n=`md`,icon:r,closable:i=!1,onClose:a,children:o,className:s,style:c,id:l}=e;return(0,S.jsxs)(`span`,{id:l,className:y(`rcs-badge`,`rcs-badge--${t}`,n!==`md`&&`rcs-badge--${n}`,s),style:c,children:[r&&(0,S.jsx)(`span`,{"aria-hidden":!0,children:r}),o,i&&(0,S.jsx)(`button`,{type:`button`,className:`rcs-badge-x`,"aria-label":`Remove`,onClick:a,children:`×`})]})}var re={xs:4,sm:8,md:12,lg:16,xl:24};function ie(e){return e===void 0?12:typeof e==`number`?e:re[e]}var ae={none:`0`,sm:`4px`,md:`6px`,lg:`8px`,pill:`9999px`,circle:`50%`};function oe(e){return e===void 0?`var(--radius-md)`:typeof e==`number`?`${e}px`:ae[e]}var se={none:`none`,sm:`var(--shadow-sm)`,md:`var(--shadow-md)`,lg:`var(--shadow-lg)`,overlay:`var(--shadow-lg)`};function ce(e){let{title:t,subtitle:n,extra:r,footer:i,bordered:a=!0,hoverable:o=!1,padding:s,radius:c,shadow:l=`none`,children:u,className:d,style:f,id:p}=e,m={borderRadius:oe(c),boxShadow:se[l],border:a?void 0:`0`,...f};return(0,S.jsxs)(`div`,{id:p,className:y(`rcs-card`,d),style:m,"data-hoverable":o||void 0,children:[(t||r)&&(0,S.jsxs)(`div`,{className:`rcs-card-header`,children:[(0,S.jsxs)(`div`,{children:[t&&(0,S.jsx)(`div`,{className:`rcs-card-title`,children:t}),n&&(0,S.jsx)(`div`,{className:`rcs-card-subtitle`,children:n})]}),r&&(0,S.jsx)(`div`,{className:`rcs-card-extra`,children:r})]}),(0,S.jsx)(`div`,{className:`rcs-card-body`,style:s===void 0?void 0:{padding:ie(s)},children:u}),i&&(0,S.jsx)(`div`,{className:`rcs-card-footer`,children:i})]})}function T(e){let{direction:t=`horizontal`,size:n=`sm`,align:r,justify:i,wrap:a=!1,split:o,children:s,className:c,style:l,id:u}=e,d=ie(n),f=C.Children.toArray(s);return(0,S.jsx)(`div`,{id:u,className:y(`rcs-space`,t===`vertical`&&`rcs-space--vertical`,a&&`rcs-space--wrap`,c),style:{gap:d,alignItems:r,justifyContent:i,flexDirection:t===`vertical`?`column`:`row`,...l},children:f.map((e,t)=>(0,S.jsxs)(C.Fragment,{children:[e,o&&te.key===m),g=(e,t)=>{t||(d||p(e),o?.(e))};return(0,S.jsxs)(`div`,{id:u,"data-scrollable":s||void 0,className:y(`rcs-tabs`,`rcs-tabs--${i}`,`rcs-tabs--${a}`,c),style:l,children:[(0,S.jsx)(`div`,{className:`rcs-tabs-nav`,"data-scrollable":s||void 0,role:`tablist`,children:t.map(e=>(0,S.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===m,disabled:e.disabled,"data-active":e.key===m||void 0,className:`rcs-tabs-tab`,onClick:()=>g(e.key,e.disabled),children:[e.icon&&(0,S.jsx)(`span`,{"aria-hidden":!0,children:e.icon}),(0,S.jsx)(`span`,{children:e.label}),e.badge&&(0,S.jsx)(`span`,{style:{marginLeft:4},children:e.badge})]},e.key))}),h?.content&&(0,S.jsx)(`div`,{className:`rcs-tabs-content`,role:`tabpanel`,children:h.content})]})}function fe(e){let{items:t,separator:n=`/`,maxItems:r,className:i,style:a,id:o}=e,s=t;return r&&t.length>r&&(s=[t[0],{label:`…`},...t.slice(t.length-(r-2))]),(0,S.jsx)(`nav`,{id:o,"aria-label":`Breadcrumb`,className:y(`rcs-breadcrumb`,i),style:a,children:s.map((e,t)=>{let r=t===s.length-1,i=e.href?(0,S.jsxs)(`a`,{href:e.href,onClick:e.onClick,children:[e.icon&&(0,S.jsx)(`span`,{"aria-hidden":!0,style:{marginRight:4},children:e.icon}),e.label]}):e.onClick?(0,S.jsx)(`button`,{type:`button`,onClick:e.onClick,style:{background:`none`,border:0,padding:0,color:`inherit`,cursor:`pointer`,font:`inherit`},children:e.label}):(0,S.jsx)(`span`,{children:e.label});return(0,S.jsxs)(C.Fragment,{children:[(0,S.jsx)(`span`,{className:r?`rcs-breadcrumb-item--last`:void 0,children:i}),!r&&(0,S.jsx)(`span`,{className:`rcs-breadcrumb-sep`,"aria-hidden":!0,children:n})]},t)})})}var pe={info:`ⓘ`,success:`✓`,warning:`⚠`,danger:`✕`};function O(e){let{severity:t,title:n,children:r,closable:i=!1,icon:a,action:o,onClose:s,className:c,style:l,id:u}=e;return(0,S.jsxs)(`div`,{id:u,role:`alert`,className:y(`rcs-alert`,`rcs-alert--${t}`,c),style:l,children:[a!==!1&&(0,S.jsx)(`span`,{className:`rcs-alert-icon`,"aria-hidden":!0,children:a??pe[t]}),(0,S.jsxs)(`div`,{className:`rcs-alert-body`,children:[n&&(0,S.jsx)(`div`,{className:`rcs-alert-title`,children:n}),r&&(0,S.jsx)(`div`,{className:`rcs-alert-content`,children:r}),o&&(0,S.jsx)(`div`,{className:`rcs-alert-action`,children:o})]}),i&&(0,S.jsx)(`button`,{type:`button`,className:`rcs-alert-close`,"aria-label":`Dismiss`,onClick:s,children:`×`})]})}function k(e,t){C.useEffect(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function me(e){let{open:t,title:n,description:r,placement:i=`right`,width:a=360,closeOnEsc:o=!0,closeOnBackdrop:s=!0,footer:c,children:l,onClose:u,className:d,style:f,id:p}=e;if(k(t&&o,u),!t)return null;let m=typeof a==`number`?`${a}px`:a,h={...f};return i===`left`||i===`right`?h.width=m:h.height=m,(0,S.jsx)(`div`,{className:`rcs-modal-backdrop`,role:`dialog`,"aria-modal":`true`,style:{alignItems:i===`top`?`flex-start`:i===`bottom`?`flex-end`:`stretch`,justifyItems:i===`left`?`flex-start`:i===`right`?`flex-end`:`stretch`,padding:0},onClick:e=>{s&&e.target===e.currentTarget&&u()},children:(0,S.jsxs)(`div`,{id:p,className:y(`rcs-drawer`,`rcs-drawer--${i}`,d),style:h,children:[(n||r)&&(0,S.jsxs)(`div`,{className:`rcs-modal-header`,children:[n&&(0,S.jsx)(`h2`,{className:`rcs-modal-title`,children:n}),r&&(0,S.jsx)(`div`,{className:`rcs-modal-desc`,children:r})]}),(0,S.jsx)(`div`,{className:`rcs-modal-body`,style:{flex:1,overflow:`auto`},children:l}),c&&(0,S.jsx)(`div`,{className:`rcs-modal-footer`,children:c})]})})}function he(e){let{value:t,indeterminate:n=!1,variant:r=`linear`,size:i=`md`,tone:a=`neutral`,showValue:o=!1,className:s,style:c,id:l}=e,u=Math.max(0,Math.min(100,t));if(r===`circular`){let e=i===`lg`?24:i===`sm`?14:18,t=i===`lg`?3:2,n=2*Math.PI*e,r=u/100*n;return(0,S.jsx)(`span`,{id:l,className:y(`rcs-progress`,s),style:c,role:`progressbar`,"aria-valuenow":u,children:(0,S.jsxs)(`svg`,{width:e*2+t*2,height:e*2+t*2,children:[(0,S.jsx)(`circle`,{cx:e+t,cy:e+t,r:e,stroke:`var(--bg-3)`,strokeWidth:t,fill:`none`}),(0,S.jsx)(`circle`,{cx:e+t,cy:e+t,r:e,stroke:a===`danger`?`var(--danger)`:a===`warning`?`var(--warning)`:`var(--bg-inverse)`,strokeWidth:t,fill:`none`,strokeDasharray:`${r} ${n}`,strokeLinecap:`round`,transform:`rotate(-90 ${e+t} ${e+t})`,style:{transition:`stroke-dasharray 0.3s var(--ease-out-quart)`}})]})})}return(0,S.jsxs)(`div`,{id:l,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n?void 0:u,className:y(`rcs-progress`,`rcs-progress--${i}`,s),style:c,"data-tone":a,"data-indeterminate":n||void 0,children:[(0,S.jsx)(`div`,{className:`rcs-progress-track`,children:(0,S.jsx)(`div`,{className:`rcs-progress-fill`,style:{width:`${u}%`}})}),o&&(0,S.jsxs)(`div`,{className:`rcs-progress-value`,children:[Math.round(u),`%`]})]})}function ge(e){let{size:t=`md`,tone:n=`neutral`,label:r,className:i,style:a,id:o}=e;return(0,S.jsxs)(`span`,{id:o,className:y(`rcs-spin`,`rcs-spin--${t}`,i),style:a,"data-tone":n,role:`status`,children:[(0,S.jsx)(`span`,{className:`rcs-spin-glyph`,"aria-hidden":!0}),r&&(0,S.jsx)(`span`,{children:r})]})}var _e=[],ve=new Set;function ye(){for(let e of ve)e([..._e])}var be={show(e){let t=e.id??x(`toast`),n={...e,id:t};_e.push(n),ye();let r=e.duration??4e3;return r>0&&window.setTimeout(()=>be.dismiss(t),r),t},dismiss(e){let t=_e.findIndex(t=>t.id===e);t>=0&&(_e.splice(t,1)[0].onDismiss?.(),ye())},async promise(e,t){let n=be.show({severity:`info`,title:t.loading,duration:0});try{let r=await e;return be.dismiss(n),be.show({severity:`success`,title:t.success}),r}catch(e){throw be.dismiss(n),be.show({severity:`danger`,title:t.error}),e}}};function xe(){let[e,t]=C.useState([]);return C.useEffect(()=>(ve.add(t),()=>{ve.delete(t)}),[]),(0,S.jsx)(`div`,{className:`rcs-toast-region`,"aria-live":`polite`,"aria-atomic":`false`,children:e.map(e=>(0,S.jsxs)(`div`,{className:y(`rcs-toast`,`rcs-toast--${e.severity??`info`}`),role:`status`,children:[(0,S.jsx)(`span`,{className:`rcs-toast-icon`,"aria-hidden":!0,children:pe[e.severity??`info`]}),(0,S.jsxs)(`div`,{style:{flex:1},children:[(0,S.jsx)(`div`,{className:`rcs-toast-title`,children:e.title}),e.description&&(0,S.jsx)(`div`,{className:`rcs-toast-desc`,children:e.description})]}),e.action&&(0,S.jsx)(`button`,{className:`rcs-toast-action`,onClick:()=>{e.action.onClick(),be.dismiss(e.id)},children:e.action.label}),(0,S.jsx)(`button`,{className:`rcs-input-clear`,"aria-label":`Dismiss`,onClick:()=>be.dismiss(e.id),children:`×`})]},e.id))})}function Se(e){let{label:t,value:n,unit:r,delta:i,sparkline:a,className:o,style:s,id:c}=e;return(0,S.jsxs)(`div`,{id:c,className:y(`rcs-stat`,o),style:s,children:[(0,S.jsx)(`div`,{className:`rcs-stat-label`,children:t}),(0,S.jsxs)(`div`,{className:`rcs-stat-value`,children:[(0,S.jsx)(`span`,{children:n}),r&&(0,S.jsx)(`span`,{className:`rcs-stat-unit`,children:r})]}),i&&(0,S.jsxs)(`span`,{className:`rcs-stat-delta`,"data-tone":i.tone??`neutral`,children:[i.direction===`up`?`↑`:`↓`,i.value,`%`]}),a&&a.length>1&&(0,S.jsx)(Ce,{data:a})]})}function Ce({data:e}){let t=Math.min(...e),n=Math.max(...e)-t||1;return(0,S.jsx)(`svg`,{viewBox:`0 0 80 24`,className:`rcs-stat-spark`,preserveAspectRatio:`none`,children:(0,S.jsx)(`polyline`,{points:e.map((r,i)=>`${i/(e.length-1)*80},${24-(r-t)/n*24}`).join(` `),fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})}function we(e){let{title:t,subtitle:n,breadcrumbs:r,tabs:i,actions:a,badge:o,avatar:s,back:c,size:l=`md`,inlineSubtitle:u,backInline:d,className:f,style:p,id:m}=e,h=c&&!d,g=c&&d;return(0,S.jsxs)(`div`,{id:m,className:y(`rcs-page-header`,`rcs-page-header--${l}`,f),"data-inline-subtitle":u||void 0,"data-back-inline":d||void 0,style:p,children:[h&&(0,S.jsxs)(`button`,{type:`button`,className:`rcs-page-header-back`,onClick:c.onClick,children:[`← `,c.label??`Back`]}),r&&r.length>0&&(0,S.jsx)(`div`,{style:{marginBottom:8},children:(0,S.jsx)(fe,{items:r})}),(0,S.jsxs)(`div`,{className:`rcs-page-header-row`,children:[(0,S.jsxs)(`div`,{className:`rcs-page-header-title`,children:[g&&(0,S.jsx)(`button`,{type:`button`,"aria-label":c.label??`Back`,className:`rcs-page-header-back-inline`,onClick:c.onClick,children:`←`}),s,(0,S.jsxs)(`div`,{className:`rcs-page-header-title-text`,children:[(0,S.jsxs)(`h1`,{children:[t,o&&(0,S.jsx)(`span`,{style:{marginLeft:8},children:o})]}),n&&(0,S.jsx)(`div`,{className:`rcs-page-header-subtitle`,children:n})]})]}),a&&(0,S.jsx)(`div`,{className:`rcs-page-header-actions`,children:a})]}),i&&i.length>0&&(0,S.jsx)(`div`,{className:`rcs-page-header-tabs`,children:(0,S.jsx)(de,{items:i,variant:`line`})})]})}function Te(e){let{header:t,sidebar:n,footer:r,sidebarWidth:i=240,sidebarCollapsible:a,children:o,className:s,style:c,id:l}=e;return(0,S.jsxs)(`div`,{id:l,className:y(`rcs-app-shell`,s),style:{"--rcs-sidebar-w":`${i}px`,...c},children:[t&&(0,S.jsx)(`header`,{className:`rcs-app-shell-header`,children:t}),(0,S.jsxs)(`div`,{className:`rcs-app-shell-body`,"data-has-sidebar":!!n||void 0,children:[n&&(0,S.jsx)(`aside`,{className:`rcs-app-shell-sidebar`,children:n}),(0,S.jsx)(`main`,{className:`rcs-app-shell-main`,children:o})]}),r&&(0,S.jsx)(`footer`,{className:`rcs-app-shell-footer`,children:r})]})}var Ee=C.createContext(null),De={"signal-red":`#E60000`,"signal-red-700":`#9E0000`,"signal-red-900":`#520000`,"cod-gray":`#1C1C1C`,"cod-gray-700":`#2B2B2B`,"cod-gray-500":`#5A5A5A`,"cod-gray-300":`#A6A6A6`,"cod-gray-100":`#F5F5F5`,"cod-gray-050":`#FAFAFA`,white:`#FFFFFF`};function Oe(e){let{mode:t,accent:n,fontFamily:r,children:i}=e,[a,o]=C.useState(t??`light`),s=t??a;C.useEffect(()=>{typeof document>`u`||document.documentElement.setAttribute(`data-theme`,s)},[s]),C.useEffect(()=>{typeof document>`u`||!n||document.documentElement.style.setProperty(`--accent`,De[n])},[n]),C.useEffect(()=>{typeof document>`u`||!r||(r.sans&&document.documentElement.style.setProperty(`--font-sans`,r.sans),r.mono&&document.documentElement.style.setProperty(`--font-mono`,r.mono))},[r]);let c=C.useMemo(()=>({mode:s,setMode:e=>o(e),toggle:()=>o(e=>e===`light`?`dark`:`light`)}),[s]);return(0,S.jsx)(Ee.Provider,{value:c,children:i})}var ke=g(),Ae=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),je=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Me={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ne=(0,C.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,C.createElement)(`svg`,{ref:c,...Me,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:je(`lucide`,i),...s},[...o.map(([e,t])=>(0,C.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Pe=(e,t)=>{let n=(0,C.forwardRef)(({className:n,...r},i)=>(0,C.createElement)(Ne,{ref:i,iconNode:t,className:je(`lucide-${Ae(e)}`,n),...r}));return n.displayName=`${e}`,n},Fe=Pe(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ie=Pe(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Le=Pe(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),Re=Pe(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ze=Pe(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Be=Pe(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Ve=`oc-theme`;function He(){let[e,t]=(0,C.useState)(()=>localStorage.getItem(Ve)??`dark`);return(0,C.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,e),localStorage.setItem(Ve,e)},[e]),{theme:e,toggle:()=>t(e=>e===`dark`?`light`:`dark`)}}function Ue(e){let[t,n]=(0,C.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,C.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function We({wsConnected:e}){let{theme:t,toggle:n}=He(),r=Ue(`(max-width: 760px)`),[i,a]=(0,C.useState)(!1),o=typeof window<`u`?`${window.location.origin}/mcp`:`/mcp`,s=async()=>{typeof navigator>`u`||!navigator.clipboard||(await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1500))},c=(0,S.jsx)(ee,{icon:t===`dark`?(0,S.jsx)(ze,{size:15}):(0,S.jsx)(Le,{size:15}),"aria-label":`Toggle theme`,variant:`ghost`,size:`sm`,shape:`circle`,onClick:n}),l=(0,S.jsx)(ne,{tone:e?`info`:`danger`,size:`sm`,children:e?`live`:`offline`}),u=(0,S.jsx)(w,{variant:`primary`,size:`sm`,iconLeft:i?(0,S.jsx)(Fe,{size:12}):(0,S.jsx)(Ie,{size:12}),onClick:s,children:i?`Copied`:`Copy MCP URL`});return r?(0,S.jsxs)(T,{justify:`between`,align:`center`,style:{display:`flex`,width:`100%`,padding:`0.5rem 0.75rem`},children:[(0,S.jsx)(`strong`,{children:`OtelContext`}),(0,S.jsxs)(T,{size:`xs`,align:`center`,children:[u,l,c]})]}):(0,S.jsxs)(T,{justify:`between`,align:`center`,style:{display:`flex`,width:`100%`,padding:`0.5rem 1rem`,gap:`0.75rem`},children:[(0,S.jsx)(T,{size:`md`,align:`center`,children:(0,S.jsx)(`strong`,{children:`OtelContext`})}),(0,S.jsx)(`div`,{style:{flex:1,minWidth:0,maxWidth:640},children:(0,S.jsx)(te,{value:o,readOnly:!0,type:`url`,size:`sm`,"aria-label":`MCP endpoint URL`})}),(0,S.jsxs)(T,{size:`sm`,align:`center`,children:[u,l,c]})]})}var A={fg1:`#1C1C1C`,fg2:`#3D3D3D`,fg3:`#5A5A5A`,fg4:`#A6A6A6`,bg1:`#FFFFFF`,bg2:`#FAFAFA`,bg3:`#F5F5F5`,border1:`#E5E5E5`,border2:`#D4D4D4`,accent:`#E60000`,accentSoft:`rgba(230,0,0,0.08)`,success:`#1F9E5C`,warning:`#D98E2B`,danger:`#E60000`,info:`#2D73D9`,series:[`#E60000`,`#1C1C1C`,`#5A5A5A`,`#2D73D9`,`#1F9E5C`,`#D98E2B`,`#9E0000`,`#A6A6A6`],fontSans:`Inter, system-ui, sans-serif`,fontMono:`'JetBrains Mono', monospace`,mode:`light`};function j(e,t){return typeof window>`u`?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Ge(){if(typeof window>`u`)return A;let e=document.documentElement.getAttribute(`data-theme`)??`light`,t=j(`--fg-1`,A.fg1),n=j(`--fg-2`,A.fg2),r=j(`--fg-3`,A.fg3),i=j(`--fg-4`,A.fg4),a=j(`--bg-1`,A.bg1),o=j(`--bg-2`,A.bg2),s=j(`--bg-3`,A.bg3),c=j(`--border-1`,A.border1),l=j(`--border-2`,A.border2),u=j(`--accent`,A.accent);return{fg1:t,fg2:n,fg3:r,fg4:i,bg1:a,bg2:o,bg3:s,border1:c,border2:l,accent:u,accentSoft:j(`--accent-soft`,A.accentSoft),success:j(`--success`,A.success),warning:j(`--warning`,A.warning),danger:j(`--danger`,A.danger),info:j(`--info`,A.info),series:e===`dark`?[u,`#F5F5F5`,`#A6A6A6`,`#5BA0F2`,`#3FBE83`,`#E5A65A`,`#FF6464`,`#7A7A7A`]:[u,`#1C1C1C`,`#5A5A5A`,`#2D73D9`,`#1F9E5C`,`#D98E2B`,`#9E0000`,`#A6A6A6`],fontSans:j(`--font-sans`,A.fontSans),fontMono:j(`--font-mono`,A.fontMono),mode:e}}function Ke(e){if(typeof window>`u`)return()=>{};let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()}var qe=`modulepreload`,Je=function(e){return`/`+e},Ye={},Xe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Je(t,n),t in Ye)return;Ye[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:qe,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ze=null;function Qe(){if(typeof window>`u`)return{webgl2:!1,webgpu:!1,devicePixelRatio:1,maxTextureSize:0};if(Ze)return{...Ze,devicePixelRatio:window.devicePixelRatio||1,maxTextureSize:0};let e=!1,t=0;try{let n=document.createElement(`canvas`).getContext(`webgl2`);n&&(e=!0,t=n.getParameter(n.MAX_TEXTURE_SIZE))}catch{}let n=`gpu`in navigator&&typeof navigator.gpu==`object`;return Ze={webgl2:e,webgpu:n},{webgl2:e,webgpu:n,devicePixelRatio:window.devicePixelRatio||1,maxTextureSize:t}}function $e(e,t,n=5e4){let r=Qe();return e===`canvas`?`canvas`:e===`webgl`?r.webgl2?`webgl`:`canvas`:e===`webgpu`?r.webgpu?`webgpu`:r.webgl2?`webgl`:`canvas`:r.webgpu&&t>n?`webgpu`:r.webgl2&&t>n?`webgl`:`canvas`}var et=null;async function tt(){if(et)return et;try{let e=await Xe(()=>import(`./design-system-IOKLDoaG.js`),[]),t=await Xe(()=>import(`./design-system-DFjB0sSn.js`),[]);return et={Deck:e.Deck,SolidPolygonLayer:t.SolidPolygonLayer,ScatterplotLayer:t.ScatterplotLayer,LineLayer:t.LineLayer,ArcLayer:t.ArcLayer,PolygonLayer:t.PolygonLayer},et}catch(e){return console.warn(`[@ossrandom/design-system] WebGL renderer requested but @deck.gl/core not installed. Falling back to canvas. Run: pnpm add @deck.gl/core @deck.gl/layers`,e),null}}function nt(e,t=255){if(!e)return[0,0,0,t];if(e.startsWith(`rgb`)){let n=/rgba?\(([^)]+)\)/.exec(e);if(!n)return[0,0,0,t];let[r=0,i=0,a=0,o=1]=n[1].split(`,`).map(e=>parseFloat(e.trim()));return[r,i,a,Math.round(o*255)]}let n=e.replace(`#`,``);return n.length===3?[parseInt(n[0]+n[0],16),parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),t]:n.length>=6?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),n.length===8?parseInt(n.slice(6,8),16):t]:[0,0,0,t]}var rt=null;async function it(){if(rt)return rt.ctor;try{let e=await Xe(()=>import(`./cytoscape.esm-Dm6iss-N.js`),[]),t=e.default??e;try{let e=await Xe(()=>import(`./cytoscape-cose-bilkent-CEIBo6Gj.js`).then(e=>c(e.default,1)),[]);t.use(e.default??e)}catch{}return rt={ctor:t},t}catch(e){return console.warn(`[@ossrandom/design-system] cytoscape not installed:`,e),null}}function at(e,t){return t<=0?3:3+Math.sqrt(e)/Math.sqrt(t)*11}function ot(e,t){let n=new Map;for(let t of e)n.set(t.id,0);for(let e of t)n.set(e.source,(n.get(e.source)??0)+1),n.set(e.target,(n.get(e.target)??0)+1);let r=0;for(let e of n.values())e>r&&(r=e);return{degrees:n,max:r}}async function st(e,t,n,r){let{degrees:i}=ot(e,t);if(e.every(e=>e.x!==void 0&&e.y!==void 0))return e.map(e=>({...e,x:e.x,y:e.y,degree:i.get(e.id)??0}));try{let a=await Xe(()=>import(`./design-system-BNhP-Tae.js`),[]),o=e.map(e=>({...e,x:n/2+(Math.random()-.5)*100,y:r/2+(Math.random()-.5)*100,degree:i.get(e.id)??0})),s=a.forceSimulation(o).force(`link`,a.forceLink(t.map(e=>({source:e.source,target:e.target}))).id(e=>e.id).distance(60)).force(`charge`,a.forceManyBody().strength(-300)).force(`center`,a.forceCenter(n/2,r/2)).force(`collide`,a.forceCollide(14)).stop();for(let e=0;e<200;e++)s.tick();return o}catch{let t=Math.ceil(Math.sqrt(e.length)),a=n/t,o=r/Math.ceil(e.length/t);return e.map((e,n)=>({...e,x:n%t*a+a/2,y:Math.floor(n/t)*o+o/2,degree:i.get(e.id)??0}))}}function ct(e){let{nodes:t,edges:n,height:r=480,layout:i=`cose-bilkent`,engine:a=`auto`,onNodeClick:o,onEdgeClick:s,className:c,style:l,id:u}=e,d=C.useRef(null),f=C.useRef(null),p=C.useRef(null),[m,h]=C.useState(0),[g,_]=C.useState(`canvas`);return C.useEffect(()=>{_($e(a,t.length+n.length,500))},[a,t.length,n.length]),C.useEffect(()=>{if(!d.current)return;let e=new ResizeObserver(e=>{let t=Math.floor(e[0].contentRect.width);t>0&&t!==m&&h(t)});return e.observe(d.current),()=>e.disconnect()},[m]),C.useEffect(()=>{if(g!==`canvas`||!d.current)return;let e=!1,r=d.current;return it().then(a=>{if(!a||e){a||(r.innerHTML=`
Service map (canvas) requires cytoscape. Run: pnpm add cytoscape cytoscape-cose-bilkent
`);return}let c=Ge(),{degrees:l,max:u}=ot(t,n),d=a({container:r,elements:[...t.map(e=>{let t=l.get(e.id)??0,n=at(t,u);return{data:{id:e.id,label:e.label,status:e.status,kind:e.kind,degree:t,diameter:Math.round(n*2)}}}),...n.map(e=>({data:{id:`${e.source}->${e.target}`,source:e.source,target:e.target,label:e.label,status:e.status}}))],style:lt(c),layout:{name:i,animate:!1,fit:!0,padding:24,nodeRepulsion:6e3,idealEdgeLength:80},wheelSensitivity:.2,minZoom:.2,maxZoom:3});o&&d.on(`tap`,`node`,e=>o(e.target.data())),s&&d.on(`tap`,`edge`,e=>s(e.target.data()));let p=e=>{let t=e.isNode?.()??!0;if(d.elements().addClass(`rcs-dim`),t){let t=e.connectedEdges?.(),n=e.connectedNodes?.();n?.removeClass(`rcs-dim`),t?.removeClass(`rcs-dim`),d.$(`#${ut(e.id())}`).removeClass(`rcs-dim`),d.$(`#${ut(e.id())}`).addClass(`rcs-focus`),t?.addClass(`rcs-focus-edge`),n?.addClass(`rcs-neighbor`)}else{let t=e.connectedNodes?.();t?.removeClass(`rcs-dim`),t?.addClass(`rcs-neighbor`)}},m=()=>{d.elements().removeClass(`rcs-dim rcs-focus rcs-focus-edge rcs-neighbor`)};d.on(`mouseover`,`node`,e=>p(e.target)),d.on(`mouseover`,`edge`,e=>p(e.target)),d.on(`mouseout`,`node`,()=>m()),d.on(`mouseout`,`edge`,()=>m()),d.on(`tap`,`node`,e=>p(e.target)),d.on(`tap`,`edge`,e=>p(e.target));let h=d.container();h&&h.addEventListener(`pointerleave`,m),f.current=d}),()=>{e=!0,f.current?.destroy(),f.current=null,r.innerHTML=``}},[g,t,n,i,o,s]),C.useEffect(()=>{if(g===`canvas`||m===0||!d.current)return;let e=!1,i=d.current;return(async()=>{let a=await tt();if(!a||e){_(`canvas`);return}let c=await st(t,n,m,r);if(e)return;let l=new Map(c.map((e,t)=>[e.id,t])),u=Ge(),d=c.reduce((e,t)=>Math.max(e,t.degree),0),f=g===`webgpu`?`webgpu`:`webgl`,h=a.ScatterplotLayer,v=a.ArcLayer,y=new Map,b=new Map;for(let e of c)y.set(e.id,new Set),b.set(e.id,new Set);for(let e of n){let t=`${e.source}->${e.target}`;y.get(e.source)?.add(e.target),y.get(e.target)?.add(e.source),b.get(e.source)?.add(t),b.get(e.target)?.add(t)}let x=null,S=e=>!x||e===x?!0:y.get(x)?.has(e)??!1,C=e=>x?e.source===x||e.target===x:!0,w=(e,t)=>[e[0],e[1],e[2],t],ee=()=>[new v({id:`service-edges`,data:n.map(e=>({...e,sourcePos:c[l.get(e.source)??0],targetPos:c[l.get(e.target)??0]})),getSourcePosition:e=>[e.sourcePos.x,e.sourcePos.y,0],getTargetPosition:e=>[e.targetPos.x,e.targetPos.y,0],getSourceColor:e=>{let t=C(e);return w(nt(t&&x?u.accent:e.status===`failing`?u.danger:u.border2),t?255:60)},getTargetColor:e=>{let t=C(e);return w(nt(t&&x?u.accent:e.status===`failing`?u.danger:u.fg4),t?255:60)},getWidth:e=>C(e)&&x||e.status===`failing`?2:1,getHeight:.3,pickable:!!s,updateTriggers:{getSourceColor:[x],getTargetColor:[x],getWidth:[x]}}),new h({id:`service-nodes`,data:c,getPosition:e=>[e.x,e.y,0],getFillColor:e=>{let t=S(e.id);return w(nt(e.status===`failing`?u.danger:e.status===`degraded`?u.warning:e.status===`healthy`?u.success:u.fg3),t?230:60)},getLineColor:e=>x===e.id?nt(u.accent):nt(u.bg1),getRadius:e=>at(e.degree,d),radiusUnits:`pixels`,stroked:!0,getLineWidth:e=>x===e.id?2:1,lineWidthUnits:`pixels`,pickable:!0,updateTriggers:{getFillColor:[x],getLineColor:[x],getLineWidth:[x]}})],te=new a.Deck({parent:i,width:m,height:r,controller:!0,deviceProps:{type:f},views:[{"@@type":`OrthographicView`,id:`v`,flipY:!0}],viewState:{target:[m/2,r/2,0],zoom:0},layers:ee(),onHover:({object:e,layer:t})=>{let n=null;e&&t?.id===`service-nodes`?n=e.id:e&&t?.id===`service-edges`&&(n=e.source),n!==x&&(x=n,te.setProps({layers:ee()}))},onClick:({object:e,layer:t})=>{!e||!t||(t.id===`service-nodes`&&o?o(e):t.id===`service-edges`&&s&&s(e))}});p.current=te})().catch(e=>{console.warn(`[@ossrandom/design-system] ServiceMap WebGL init failed; falling back to canvas:`,e),_(`canvas`)}),()=>{e=!0,p.current?.destroy(),p.current=null,i.innerHTML=``}},[g,m,r,t,n,o,s]),C.useEffect(()=>Ke(()=>{_(e=>e)}),[]),(0,S.jsx)(`div`,{ref:d,id:u,className:y(`rcs-service-map`,`rcs-service-map--${g}`,c),style:{position:`relative`,width:`100%`,height:r,...l},"data-engine":g,role:`img`,"aria-label":e[`aria-label`]??`Service map with ${t.length} services`,children:(0,S.jsx)(`div`,{className:`rcs-service-map-engine-badge`,"aria-hidden":`true`,children:g})})}function lt(e){return[{selector:`node`,style:{shape:`ellipse`,width:`data(diameter)`,height:`data(diameter)`,"background-color":e.fg3,"border-color":e.bg1,"border-width":1,label:`data(label)`,color:e.fg3,"font-family":e.fontSans,"font-size":11,"font-weight":400,"text-valign":`bottom`,"text-halign":`center`,"text-margin-y":4,"text-events":`no`,"min-zoomed-font-size":9,"z-index":10,"transition-property":`background-color, border-color, border-width, color, opacity`,"transition-duration":`120ms`}},{selector:`node[status = 'healthy']`,style:{"background-color":e.success}},{selector:`node[status = 'degraded']`,style:{"background-color":e.warning}},{selector:`node[status = 'failing']`,style:{"background-color":e.danger}},{selector:`edge`,style:{width:1,"line-color":e.border2,"target-arrow-color":e.border2,"target-arrow-shape":`triangle`,"arrow-scale":.9,"curve-style":`bezier`,label:`data(label)`,color:e.fg4,"font-family":e.fontMono,"font-size":9,"text-rotation":`autorotate`,"text-margin-y":-4,"text-opacity":0,"text-events":`no`,"z-index":1,"transition-property":`line-color, width, target-arrow-color, opacity, text-opacity`,"transition-duration":`120ms`}},{selector:`edge[status = 'failing']`,style:{"line-color":e.danger,"target-arrow-color":e.danger,width:1.5}},{selector:`.rcs-dim`,style:{opacity:.18}},{selector:`node.rcs-focus`,style:{opacity:1,"border-color":e.accent,"border-width":2,color:e.fg1,"font-weight":500,"z-index":30}},{selector:`node.rcs-neighbor`,style:{opacity:1,color:e.fg1,"z-index":20}},{selector:`edge.rcs-focus-edge`,style:{opacity:1,"line-color":e.accent,"target-arrow-color":e.accent,width:2,"text-opacity":1,color:e.fg1,"z-index":25}},{selector:`node:selected`,style:{"border-color":e.accent,"border-width":2}}]}function ut(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function dt(e){return e===`healthy`?`info`:e===`degraded`?`warning`:e===`critical`||e===`failing`?`danger`:`neutral`}var ft=C.memo(({node:e,edges:t,onClose:n,onSelectService:r})=>{let i=t.filter(t=>t.target===e.id),a=t.filter(t=>t.source===e.id),o=e.metrics.error_rate*100;return(0,S.jsxs)(T,{direction:`vertical`,size:`md`,children:[(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:(0,S.jsxs)(T,{size:`xs`,align:`center`,children:[(0,S.jsx)(`code`,{children:e.id}),(0,S.jsx)(ne,{tone:dt(e.status),size:`sm`,children:e.status})]}),extra:(0,S.jsx)(ee,{icon:(0,S.jsx)(Be,{size:13}),"aria-label":`Close`,variant:`ghost`,size:`sm`,onClick:n}),children:(0,S.jsxs)(ue,{columns:2,gap:`sm`,children:[(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`RPS`,value:Math.round(e.metrics.request_rate_rps)})}),(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`Error Rate`,value:o.toFixed(2),unit:`%`})}),(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`Avg Latency`,value:e.metrics.avg_latency_ms,unit:`ms`})}),(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`P99`,value:e.metrics.p99_latency_ms,unit:`ms`})})]})}),(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:`Health Score`,extra:(0,S.jsx)(ne,{tone:`subtle`,size:`sm`,children:e.health_score.toFixed(2)}),children:(0,S.jsx)(he,{value:e.health_score*100,tone:e.health_score<.4?`danger`:e.health_score<.7?`warning`:`neutral`})}),i.length>0&&(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:`Upstream`,children:(0,S.jsx)(T,{direction:`vertical`,size:`xs`,children:i.map(e=>(0,S.jsx)(w,{variant:`ghost`,size:`sm`,block:!0,onClick:()=>r(e.source),children:(0,S.jsxs)(T,{justify:`between`,align:`center`,children:[(0,S.jsx)(`code`,{children:e.source}),(0,S.jsxs)(ne,{tone:`subtle`,size:`sm`,children:[e.call_count,` calls`]})]})},e.source))})}),a.length>0&&(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:`Downstream`,children:(0,S.jsx)(T,{direction:`vertical`,size:`xs`,children:a.map(e=>(0,S.jsx)(w,{variant:`ghost`,size:`sm`,block:!0,onClick:()=>r(e.target),children:(0,S.jsxs)(T,{justify:`between`,align:`center`,children:[(0,S.jsx)(`code`,{children:e.target}),(0,S.jsxs)(ne,{tone:`subtle`,size:`sm`,children:[e.call_count,` calls`]})]})},e.target))})}),e.alerts.length>0&&(0,S.jsx)(T,{direction:`vertical`,size:`xs`,children:e.alerts.map((e,t)=>(0,S.jsx)(O,{severity:`danger`,children:e},t))})]})}),pt=C.memo(({items:e})=>(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,children:(0,S.jsx)(T,{size:`lg`,wrap:!0,children:e.map((e,t)=>(0,S.jsxs)(C.Fragment,{children:[t>0&&(0,S.jsx)(le,{direction:`vertical`}),(0,S.jsx)(Se,{...e})]},`${t}-${String(e.label)}`))})}));function mt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e*10)/10)}function ht(e=800){let[t,n]=(0,C.useState)(()=>typeof window>`u`?e:window.innerHeight);return(0,C.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(window.innerHeight);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),t}function gt(e){return e===`healthy`||e===`degraded`?e:e===`critical`||e===`failing`?`failing`:`unknown`}function _t(e){return e===`critical`||e===`failing`?`failing`:`healthy`}var vt=C.memo(({graph:e,loading:t,error:n,dashboard:r,stats:i})=>{let[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(``),l=Ue(`(max-width: 760px)`),u=ht(),d=l?460:Math.max(460,u-320),f=e?.nodes??[],p=e?.edges??[],m=(0,C.useMemo)(()=>{let e=s.trim().toLowerCase();return f.filter(t=>!e||t.id.toLowerCase().includes(e)).map(e=>({id:e.id,label:e.id,status:gt(e.status)}))},[f,s]),h=(0,C.useMemo)(()=>{if(m.length===0)return[];let e=new Set(m.map(e=>e.id));return p.filter(t=>e.has(t.source)&&e.has(t.target)).slice(0,500).map(e=>({source:e.source,target:e.target,status:_t(e.status)}))},[p,m]),g=r?.active_services??f.length,_=r?.error_rate??0,v=i,y=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e)))return Number(e)},b=y(v?.TraceCount)??y(v?.traceCount)??r?.total_traces??0,x=y(v?.LogCount)??y(v?.logCount)??r?.total_logs??0,w=y(v?.DBSizeMB)??y(v?.db_size_mb),ee=e=>{o(f.find(t=>t.id===e.id)??null)},ne=e=>{let t=f.find(t=>t.id===e);t&&o(t)};return(0,S.jsxs)(T,{direction:`vertical`,size:`md`,style:{display:`flex`,width:`100%`},children:[(0,S.jsx)(we,{size:`sm`,title:`Service Topology`,subtitle:`Live dependency map · click a node for details`,inlineSubtitle:!0}),(0,S.jsx)(pt,{items:[{label:`Services`,value:g},{label:`Error rate`,value:_.toFixed(2),unit:`%`},{label:`Traces`,value:mt(b)},{label:`Logs`,value:mt(x)},...w!=null&&Number.isFinite(w)?[{label:`DB`,value:w.toFixed(0),unit:`MB`}]:[]]}),(0,S.jsxs)(ce,{bordered:!0,padding:`sm`,radius:`md`,extra:(0,S.jsx)(te,{value:s,onChange:e=>c(e),placeholder:`Filter services`,size:`sm`,prefix:(0,S.jsx)(Re,{size:12})}),children:[t&&(0,S.jsx)(ge,{label:`Loading service map`}),n&&(0,S.jsx)(O,{severity:`danger`,title:`Service map failed to load`,children:n}),!t&&!n&&f.length===0&&(0,S.jsx)(O,{severity:`info`,children:`No services discovered yet.`}),!t&&!n&&m.length===0&&f.length>0&&(0,S.jsx)(O,{severity:`info`,children:`No services match the filter.`}),!t&&!n&&m.length>0&&(0,S.jsx)(ct,{nodes:m,edges:h,layout:`cose-bilkent`,height:d,onNodeClick:ee})]}),(0,S.jsx)(me,{open:a!==null,onClose:()=>o(null),placement:`right`,width:l?`92vw`:420,title:a?(0,S.jsx)(`code`,{children:a.id}):void 0,description:`Service detail · upstream, downstream, alerts`,children:a&&(0,S.jsx)(ft,{node:a,edges:p,onClose:()=>o(null),onSelectService:ne})})]})});function yt(e=6e4){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(``),[a,o]=(0,C.useState)(!0),[s,c]=(0,C.useState)(null),l=(0,C.useRef)(void 0),u=(0,C.useCallback)(async()=>{try{let e=await fetch(`/api/system/graph`);if(!e.ok)throw Error(`HTTP ${e.status}`);i(e.headers.get(`X-Cache`)??``),n(await e.json()),c(null)}catch(e){c(e instanceof Error?e.message:`fetch failed`)}finally{o(!1)}},[]);return(0,C.useEffect)(()=>(u(),l.current=setInterval(u,e),()=>clearInterval(l.current)),[u,e]),{graph:t,cache:r,loading:a,error:s,reload:u}}function bt(e=3e4){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(!0),[s,c]=(0,C.useState)(null),l=(0,C.useRef)(void 0),u=(0,C.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/api/metrics/dashboard`),fetch(`/api/stats`)]);if(!e.ok||!t.ok)throw Error(`fetch failed`);n(await e.json()),i(await t.json()),c(null)}catch(e){c(e instanceof Error?e.message:`fetch failed`)}finally{o(!1)}},[]);return(0,C.useEffect)(()=>(u(),l.current=setInterval(u,e),()=>clearInterval(l.current)),[u,e]),{dashboard:t,stats:r,loading:a,error:s,reload:u}}var xt=100,St=1e4,Ct=3e4,wt=35e3;function Tt(e){let t=(0,C.useRef)(null),n=(0,C.useRef)(e),[r,i]=(0,C.useState)(`connecting`);t.status=r;let a=(0,C.useRef)(0),o=(0,C.useRef)(null),s=(0,C.useRef)(null),c=(0,C.useRef)(null),l=(0,C.useRef)(!1),u=(0,C.useRef)(()=>{});(0,C.useEffect)(()=>{n.current=e},[e]);let d=(0,C.useCallback)(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),f=(0,C.useCallback)(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null),c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]),p=(0,C.useCallback)(()=>{if(l.current)return;d();let e=a.current,t=Math.min(xt*2**e,St);a.current=e+1,i(`reconnecting`),o.current=window.setTimeout(()=>{o.current=null,u.current()},t)},[d]),m=(0,C.useCallback)(()=>{f(),s.current=window.setInterval(()=>{let e=t.current;if(!(!e||e.readyState!==WebSocket.OPEN)){try{e.send(JSON.stringify({type:`ping`}))}catch{return}c.current!==null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{c.current=null;let e=t.current;if(e)try{e.close()}catch{}},wt)}},Ct)},[f]),h=(0,C.useCallback)(()=>{if(l.current)return;d(),f();let e=t.current;if(e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}t.current=null}i(a.current===0?`connecting`:`reconnecting`);let r=window.location.protocol===`https:`?`wss:`:`ws:`,o;try{o=new WebSocket(`${r}//${window.location.host}/ws`)}catch{p();return}t.current=o,o.onopen=()=>{l.current||(a.current=0,i(`connected`),m())},o.onmessage=e=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null);try{let t=JSON.parse(e.data);t.type===`logs`&&Array.isArray(t.data)&&n.current(t.data)}catch{}},o.onerror=()=>{},o.onclose=()=>{l.current||(t.current===o&&(t.current=null),f(),i(`disconnected`),p())}},[f,d,p,m]);return(0,C.useEffect)(()=>{u.current=h},[h]),(0,C.useEffect)(()=>{l.current=!1,u.current=h,h();let e=()=>{if(document.visibilityState!==`visible`)return;let e=t.current;(!e||e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)&&(a.current=0,d(),u.current())},n=()=>{a.current=0,d(),u.current()};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,n),()=>{l.current=!0,document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,n),d(),f();let r=t.current;if(r){r.onopen=null,r.onmessage=null,r.onerror=null,r.onclose=null;try{r.close()}catch{}t.current=null}}},[]),t}function Et(){let[e,t]=(0,C.useState)(`services`),n=yt(),r=bt();return(0,S.jsx)(Te,{header:(0,S.jsx)(We,{view:e,onNavigate:t,wsConnected:!!Tt(()=>void 0).current}),children:(0,S.jsx)(vt,{graph:n.graph,loading:n.loading,error:n.error,dashboard:r.dashboard,stats:r.stats})})}(0,ke.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(C.StrictMode,{children:(0,S.jsxs)(Oe,{mode:`dark`,children:[(0,S.jsx)(Et,{}),(0,S.jsx)(xe,{})]})}));export{o as t}; \ No newline at end of file +`).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function $(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Qt(e,``+r);break;case`className`:It(e,`class`,r);break;case`tabIndex`:It(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:It(e,n,r);break;case`style`:tn(e,r,o);break;case`data`:if(t!==`object`){It(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=on(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,a.name,a,null),$(e,t,`formEncType`,a.formEncType,a,null),$(e,t,`formMethod`,a.formMethod,a,null),$(e,t,`formTarget`,a.formTarget,a,null)):($(e,t,`encType`,a.encType,a,null),$(e,t,`method`,a.method,a,null),$(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=on(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=sn);break;case`onScroll`:r!=null&&Q(`scroll`,e);break;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=on(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),Ft(e,`popover`,r);break;case`xlinkActuate`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Lt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Lt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Lt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ft(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Gt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),Et(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Gt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Gt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Gt(n.imageSizes)+`"]`)):i+=`[href="`+Gt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),Et(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Gt(r)+`"][href="`+Gt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),Et(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=Tt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);Et(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=Tt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),Et(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=Tt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),Et(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ge.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=Tt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=Tt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=Tt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Gt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),Et(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Gt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Gt(n.href)+`"]`);if(r)return t.instance=r,Et(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Et(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,Et(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),Et(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,Et(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Et(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Et(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),Et(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=o((e=>{var t=Symbol.for(`react.transitional.element`);function n(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.jsx=n,e.jsxs=n})),v=o(((e,t)=>{t.exports=_()}));function y(...e){let t=``;for(let n of e)n&&(t+=t?` `+n:n);return t}var b=0;function x(e=`rcs`){return b+=1,`${e}-${b}`}var S=v(),C=c(u(),1),w=C.forwardRef(function(e,t){let{variant:n=`secondary`,size:r=`md`,shape:i=`rect`,loading:a=!1,disabled:o=!1,block:s=!1,iconLeft:c,iconRight:l,type:u=`button`,children:d,onClick:f,className:p,style:m,id:h,"data-testid":g,"aria-label":_,"aria-labelledby":v,"aria-describedby":b}=e;return(0,S.jsxs)(`button`,{ref:t,id:h,"data-testid":g,type:u,className:y(`rcs-button`,`rcs-button--${n}`,`rcs-button--${r}`,i!==`rect`&&`rcs-button--${i}`,s&&`rcs-button--block`,p),style:m,disabled:o||a,"aria-disabled":o||a||void 0,"aria-busy":a||void 0,"aria-label":_,"aria-labelledby":v,"aria-describedby":b,onClick:f,children:[a?(0,S.jsx)(`span`,{className:`rcs-button-spinner`,"aria-hidden":!0}):c,d,l]})}),ee=C.forwardRef(function(e,t){let{icon:n,round:r=!1,"aria-label":i,...a}=e;return(0,S.jsx)(w,{ref:t,...a,shape:r?`circle`:`square`,"aria-label":i,children:n})}),te=C.forwardRef(function(e,t){let{value:n,defaultValue:r,placeholder:i,size:a=`md`,status:o=`default`,disabled:s=!1,readOnly:c=!1,invalid:l=!1,prefix:u,suffix:d,clearable:f=!1,type:p=`text`,autoFocus:m=!1,onChange:h,onFocus:g,onBlur:_,onKeyDown:v,className:b,style:x,id:w,"data-testid":ee,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re}=e,ie=n!==void 0,[ae,oe]=C.useState(r??``),se=ie?n:ae,ce=C.useRef(null);C.useImperativeHandle(t,()=>ce.current);let T=l?`error`:o;return(0,S.jsxs)(`span`,{className:y(`rcs-input-wrap`,`rcs-input-wrap--${a}`,b),style:x,"data-status":T,"data-disabled":s||void 0,children:[u&&(0,S.jsx)(`span`,{className:`rcs-input-affix rcs-input-affix--left`,children:u}),(0,S.jsx)(`input`,{ref:ce,id:w,"data-testid":ee,className:`rcs-input`,type:p,value:se,placeholder:i,disabled:s,readOnly:c,autoFocus:m,"aria-invalid":T===`error`||void 0,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re,onChange:e=>{ie||oe(e.target.value),h?.(e.target.value,e)},onFocus:g,onBlur:_,onKeyDown:v}),f&&se&&!s&&!c&&(0,S.jsx)(`button`,{type:`button`,className:`rcs-input-clear`,"aria-label":`Clear`,onClick:e=>{let t=ce.current;ie||oe(``),t&&((Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,`value`)?.set)?.call(t,``),t.dispatchEvent(new Event(`input`,{bubbles:!0}))),h?.(``,e)},children:`×`}),d&&(0,S.jsx)(`span`,{className:`rcs-input-affix rcs-input-affix--right`,children:d})]})});C.forwardRef(function(e,t){let{value:n,defaultValue:r,placeholder:i,rows:a=4,autoResize:o=!1,maxLength:s,showCount:c=!1,size:l=`md`,status:u=`default`,disabled:d=!1,readOnly:f=!1,invalid:p=!1,onChange:m,onFocus:h,onBlur:g,onKeyDown:_,autoFocus:v,className:b,style:x,id:w,"data-testid":ee,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re}=e,ie=n!==void 0,[ae,oe]=C.useState(r??``),se=ie?n:ae,ce=C.useRef(null);C.useImperativeHandle(t,()=>ce.current),C.useLayoutEffect(()=>{if(!o)return;let e=ce.current;e&&(e.style.height=`auto`,e.style.height=e.scrollHeight+`px`)},[se,o]);let T=p?`error`:u;return(0,S.jsxs)(`span`,{style:{display:`block`,width:`100%`,...x},children:[(0,S.jsx)(`textarea`,{ref:ce,id:w,"data-testid":ee,className:y(`rcs-textarea`,`rcs-textarea--${l}`,b),rows:a,value:se,placeholder:i,maxLength:s,disabled:d,readOnly:f,autoFocus:v,"aria-invalid":T===`error`||void 0,"aria-label":te,"aria-labelledby":ne,"aria-describedby":re,"data-status":T,onChange:e=>{ie||oe(e.target.value),m?.(e.target.value,e)},onFocus:h,onBlur:g,onKeyDown:_}),c&&(0,S.jsxs)(`span`,{className:`rcs-textarea-count`,children:[se.length,s?` / ${s}`:``]})]})});function ne(e){let{tone:t=`neutral`,size:n=`md`,icon:r,closable:i=!1,onClose:a,children:o,className:s,style:c,id:l}=e;return(0,S.jsxs)(`span`,{id:l,className:y(`rcs-badge`,`rcs-badge--${t}`,n!==`md`&&`rcs-badge--${n}`,s),style:c,children:[r&&(0,S.jsx)(`span`,{"aria-hidden":!0,children:r}),o,i&&(0,S.jsx)(`button`,{type:`button`,className:`rcs-badge-x`,"aria-label":`Remove`,onClick:a,children:`×`})]})}var re={xs:4,sm:8,md:12,lg:16,xl:24};function ie(e){return e===void 0?12:typeof e==`number`?e:re[e]}var ae={none:`0`,sm:`4px`,md:`6px`,lg:`8px`,pill:`9999px`,circle:`50%`};function oe(e){return e===void 0?`var(--radius-md)`:typeof e==`number`?`${e}px`:ae[e]}var se={none:`none`,sm:`var(--shadow-sm)`,md:`var(--shadow-md)`,lg:`var(--shadow-lg)`,overlay:`var(--shadow-lg)`};function ce(e){let{title:t,subtitle:n,extra:r,footer:i,bordered:a=!0,hoverable:o=!1,padding:s,radius:c,shadow:l=`none`,children:u,className:d,style:f,id:p}=e,m={borderRadius:oe(c),boxShadow:se[l],border:a?void 0:`0`,...f};return(0,S.jsxs)(`div`,{id:p,className:y(`rcs-card`,d),style:m,"data-hoverable":o||void 0,children:[(t||r)&&(0,S.jsxs)(`div`,{className:`rcs-card-header`,children:[(0,S.jsxs)(`div`,{children:[t&&(0,S.jsx)(`div`,{className:`rcs-card-title`,children:t}),n&&(0,S.jsx)(`div`,{className:`rcs-card-subtitle`,children:n})]}),r&&(0,S.jsx)(`div`,{className:`rcs-card-extra`,children:r})]}),(0,S.jsx)(`div`,{className:`rcs-card-body`,style:s===void 0?void 0:{padding:ie(s)},children:u}),i&&(0,S.jsx)(`div`,{className:`rcs-card-footer`,children:i})]})}function T(e){let{direction:t=`horizontal`,size:n=`sm`,align:r,justify:i,wrap:a=!1,split:o,children:s,className:c,style:l,id:u}=e,d=ie(n),f=C.Children.toArray(s);return(0,S.jsx)(`div`,{id:u,className:y(`rcs-space`,t===`vertical`&&`rcs-space--vertical`,a&&`rcs-space--wrap`,c),style:{gap:d,alignItems:r,justifyContent:i,flexDirection:t===`vertical`?`column`:`row`,...l},children:f.map((e,t)=>(0,S.jsxs)(C.Fragment,{children:[e,o&&te.key===m),g=(e,t)=>{t||(d||p(e),o?.(e))};return(0,S.jsxs)(`div`,{id:u,"data-scrollable":s||void 0,className:y(`rcs-tabs`,`rcs-tabs--${i}`,`rcs-tabs--${a}`,c),style:l,children:[(0,S.jsx)(`div`,{className:`rcs-tabs-nav`,"data-scrollable":s||void 0,role:`tablist`,children:t.map(e=>(0,S.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.key===m,disabled:e.disabled,"data-active":e.key===m||void 0,className:`rcs-tabs-tab`,onClick:()=>g(e.key,e.disabled),children:[e.icon&&(0,S.jsx)(`span`,{"aria-hidden":!0,children:e.icon}),(0,S.jsx)(`span`,{children:e.label}),e.badge&&(0,S.jsx)(`span`,{style:{marginLeft:4},children:e.badge})]},e.key))}),h?.content&&(0,S.jsx)(`div`,{className:`rcs-tabs-content`,role:`tabpanel`,children:h.content})]})}function fe(e){let{items:t,separator:n=`/`,maxItems:r,className:i,style:a,id:o}=e,s=t;return r&&t.length>r&&(s=[t[0],{label:`…`},...t.slice(t.length-(r-2))]),(0,S.jsx)(`nav`,{id:o,"aria-label":`Breadcrumb`,className:y(`rcs-breadcrumb`,i),style:a,children:s.map((e,t)=>{let r=t===s.length-1,i=e.href?(0,S.jsxs)(`a`,{href:e.href,onClick:e.onClick,children:[e.icon&&(0,S.jsx)(`span`,{"aria-hidden":!0,style:{marginRight:4},children:e.icon}),e.label]}):e.onClick?(0,S.jsx)(`button`,{type:`button`,onClick:e.onClick,style:{background:`none`,border:0,padding:0,color:`inherit`,cursor:`pointer`,font:`inherit`},children:e.label}):(0,S.jsx)(`span`,{children:e.label});return(0,S.jsxs)(C.Fragment,{children:[(0,S.jsx)(`span`,{className:r?`rcs-breadcrumb-item--last`:void 0,children:i}),!r&&(0,S.jsx)(`span`,{className:`rcs-breadcrumb-sep`,"aria-hidden":!0,children:n})]},t)})})}var pe={info:`ⓘ`,success:`✓`,warning:`⚠`,danger:`✕`};function O(e){let{severity:t,title:n,children:r,closable:i=!1,icon:a,action:o,onClose:s,className:c,style:l,id:u}=e;return(0,S.jsxs)(`div`,{id:u,role:`alert`,className:y(`rcs-alert`,`rcs-alert--${t}`,c),style:l,children:[a!==!1&&(0,S.jsx)(`span`,{className:`rcs-alert-icon`,"aria-hidden":!0,children:a??pe[t]}),(0,S.jsxs)(`div`,{className:`rcs-alert-body`,children:[n&&(0,S.jsx)(`div`,{className:`rcs-alert-title`,children:n}),r&&(0,S.jsx)(`div`,{className:`rcs-alert-content`,children:r}),o&&(0,S.jsx)(`div`,{className:`rcs-alert-action`,children:o})]}),i&&(0,S.jsx)(`button`,{type:`button`,className:`rcs-alert-close`,"aria-label":`Dismiss`,onClick:s,children:`×`})]})}function k(e,t){C.useEffect(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t])}function me(e){let{open:t,title:n,description:r,placement:i=`right`,width:a=360,closeOnEsc:o=!0,closeOnBackdrop:s=!0,footer:c,children:l,onClose:u,className:d,style:f,id:p}=e;if(k(t&&o,u),!t)return null;let m=typeof a==`number`?`${a}px`:a,h={...f};return i===`left`||i===`right`?h.width=m:h.height=m,(0,S.jsx)(`div`,{className:`rcs-modal-backdrop`,role:`dialog`,"aria-modal":`true`,style:{alignItems:i===`top`?`flex-start`:i===`bottom`?`flex-end`:`stretch`,justifyItems:i===`left`?`flex-start`:i===`right`?`flex-end`:`stretch`,padding:0},onClick:e=>{s&&e.target===e.currentTarget&&u()},children:(0,S.jsxs)(`div`,{id:p,className:y(`rcs-drawer`,`rcs-drawer--${i}`,d),style:h,children:[(n||r)&&(0,S.jsxs)(`div`,{className:`rcs-modal-header`,children:[n&&(0,S.jsx)(`h2`,{className:`rcs-modal-title`,children:n}),r&&(0,S.jsx)(`div`,{className:`rcs-modal-desc`,children:r})]}),(0,S.jsx)(`div`,{className:`rcs-modal-body`,style:{flex:1,overflow:`auto`},children:l}),c&&(0,S.jsx)(`div`,{className:`rcs-modal-footer`,children:c})]})})}function he(e){let{value:t,indeterminate:n=!1,variant:r=`linear`,size:i=`md`,tone:a=`neutral`,showValue:o=!1,className:s,style:c,id:l}=e,u=Math.max(0,Math.min(100,t));if(r===`circular`){let e=i===`lg`?24:i===`sm`?14:18,t=i===`lg`?3:2,n=2*Math.PI*e,r=u/100*n;return(0,S.jsx)(`span`,{id:l,className:y(`rcs-progress`,s),style:c,role:`progressbar`,"aria-valuenow":u,children:(0,S.jsxs)(`svg`,{width:e*2+t*2,height:e*2+t*2,children:[(0,S.jsx)(`circle`,{cx:e+t,cy:e+t,r:e,stroke:`var(--bg-3)`,strokeWidth:t,fill:`none`}),(0,S.jsx)(`circle`,{cx:e+t,cy:e+t,r:e,stroke:a===`danger`?`var(--danger)`:a===`warning`?`var(--warning)`:`var(--bg-inverse)`,strokeWidth:t,fill:`none`,strokeDasharray:`${r} ${n}`,strokeLinecap:`round`,transform:`rotate(-90 ${e+t} ${e+t})`,style:{transition:`stroke-dasharray 0.3s var(--ease-out-quart)`}})]})})}return(0,S.jsxs)(`div`,{id:l,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n?void 0:u,className:y(`rcs-progress`,`rcs-progress--${i}`,s),style:c,"data-tone":a,"data-indeterminate":n||void 0,children:[(0,S.jsx)(`div`,{className:`rcs-progress-track`,children:(0,S.jsx)(`div`,{className:`rcs-progress-fill`,style:{width:`${u}%`}})}),o&&(0,S.jsxs)(`div`,{className:`rcs-progress-value`,children:[Math.round(u),`%`]})]})}function ge(e){let{size:t=`md`,tone:n=`neutral`,label:r,className:i,style:a,id:o}=e;return(0,S.jsxs)(`span`,{id:o,className:y(`rcs-spin`,`rcs-spin--${t}`,i),style:a,"data-tone":n,role:`status`,children:[(0,S.jsx)(`span`,{className:`rcs-spin-glyph`,"aria-hidden":!0}),r&&(0,S.jsx)(`span`,{children:r})]})}var _e=[],ve=new Set;function ye(){for(let e of ve)e([..._e])}var be={show(e){let t=e.id??x(`toast`),n={...e,id:t};_e.push(n),ye();let r=e.duration??4e3;return r>0&&window.setTimeout(()=>be.dismiss(t),r),t},dismiss(e){let t=_e.findIndex(t=>t.id===e);t>=0&&(_e.splice(t,1)[0].onDismiss?.(),ye())},async promise(e,t){let n=be.show({severity:`info`,title:t.loading,duration:0});try{let r=await e;return be.dismiss(n),be.show({severity:`success`,title:t.success}),r}catch(e){throw be.dismiss(n),be.show({severity:`danger`,title:t.error}),e}}};function xe(){let[e,t]=C.useState([]);return C.useEffect(()=>(ve.add(t),()=>{ve.delete(t)}),[]),(0,S.jsx)(`div`,{className:`rcs-toast-region`,"aria-live":`polite`,"aria-atomic":`false`,children:e.map(e=>(0,S.jsxs)(`div`,{className:y(`rcs-toast`,`rcs-toast--${e.severity??`info`}`),role:`status`,children:[(0,S.jsx)(`span`,{className:`rcs-toast-icon`,"aria-hidden":!0,children:pe[e.severity??`info`]}),(0,S.jsxs)(`div`,{style:{flex:1},children:[(0,S.jsx)(`div`,{className:`rcs-toast-title`,children:e.title}),e.description&&(0,S.jsx)(`div`,{className:`rcs-toast-desc`,children:e.description})]}),e.action&&(0,S.jsx)(`button`,{className:`rcs-toast-action`,onClick:()=>{e.action.onClick(),be.dismiss(e.id)},children:e.action.label}),(0,S.jsx)(`button`,{className:`rcs-input-clear`,"aria-label":`Dismiss`,onClick:()=>be.dismiss(e.id),children:`×`})]},e.id))})}function Se(e){let{label:t,value:n,unit:r,delta:i,sparkline:a,className:o,style:s,id:c}=e;return(0,S.jsxs)(`div`,{id:c,className:y(`rcs-stat`,o),style:s,children:[(0,S.jsx)(`div`,{className:`rcs-stat-label`,children:t}),(0,S.jsxs)(`div`,{className:`rcs-stat-value`,children:[(0,S.jsx)(`span`,{children:n}),r&&(0,S.jsx)(`span`,{className:`rcs-stat-unit`,children:r})]}),i&&(0,S.jsxs)(`span`,{className:`rcs-stat-delta`,"data-tone":i.tone??`neutral`,children:[i.direction===`up`?`↑`:`↓`,i.value,`%`]}),a&&a.length>1&&(0,S.jsx)(Ce,{data:a})]})}function Ce({data:e}){let t=Math.min(...e),n=Math.max(...e)-t||1;return(0,S.jsx)(`svg`,{viewBox:`0 0 80 24`,className:`rcs-stat-spark`,preserveAspectRatio:`none`,children:(0,S.jsx)(`polyline`,{points:e.map((r,i)=>`${i/(e.length-1)*80},${24-(r-t)/n*24}`).join(` `),fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})})}function we(e){let{title:t,subtitle:n,breadcrumbs:r,tabs:i,actions:a,badge:o,avatar:s,back:c,size:l=`md`,inlineSubtitle:u,backInline:d,className:f,style:p,id:m}=e,h=c&&!d,g=c&&d;return(0,S.jsxs)(`div`,{id:m,className:y(`rcs-page-header`,`rcs-page-header--${l}`,f),"data-inline-subtitle":u||void 0,"data-back-inline":d||void 0,style:p,children:[h&&(0,S.jsxs)(`button`,{type:`button`,className:`rcs-page-header-back`,onClick:c.onClick,children:[`← `,c.label??`Back`]}),r&&r.length>0&&(0,S.jsx)(`div`,{style:{marginBottom:8},children:(0,S.jsx)(fe,{items:r})}),(0,S.jsxs)(`div`,{className:`rcs-page-header-row`,children:[(0,S.jsxs)(`div`,{className:`rcs-page-header-title`,children:[g&&(0,S.jsx)(`button`,{type:`button`,"aria-label":c.label??`Back`,className:`rcs-page-header-back-inline`,onClick:c.onClick,children:`←`}),s,(0,S.jsxs)(`div`,{className:`rcs-page-header-title-text`,children:[(0,S.jsxs)(`h1`,{children:[t,o&&(0,S.jsx)(`span`,{style:{marginLeft:8},children:o})]}),n&&(0,S.jsx)(`div`,{className:`rcs-page-header-subtitle`,children:n})]})]}),a&&(0,S.jsx)(`div`,{className:`rcs-page-header-actions`,children:a})]}),i&&i.length>0&&(0,S.jsx)(`div`,{className:`rcs-page-header-tabs`,children:(0,S.jsx)(de,{items:i,variant:`line`})})]})}function Te(e){let{header:t,sidebar:n,footer:r,sidebarWidth:i=240,sidebarCollapsible:a,children:o,className:s,style:c,id:l}=e;return(0,S.jsxs)(`div`,{id:l,className:y(`rcs-app-shell`,s),style:{"--rcs-sidebar-w":`${i}px`,...c},children:[t&&(0,S.jsx)(`header`,{className:`rcs-app-shell-header`,children:t}),(0,S.jsxs)(`div`,{className:`rcs-app-shell-body`,"data-has-sidebar":!!n||void 0,children:[n&&(0,S.jsx)(`aside`,{className:`rcs-app-shell-sidebar`,children:n}),(0,S.jsx)(`main`,{className:`rcs-app-shell-main`,children:o})]}),r&&(0,S.jsx)(`footer`,{className:`rcs-app-shell-footer`,children:r})]})}var Ee=C.createContext(null),De={"signal-red":`#E60000`,"signal-red-700":`#9E0000`,"signal-red-900":`#520000`,"cod-gray":`#1C1C1C`,"cod-gray-700":`#2B2B2B`,"cod-gray-500":`#5A5A5A`,"cod-gray-300":`#A6A6A6`,"cod-gray-100":`#F5F5F5`,"cod-gray-050":`#FAFAFA`,white:`#FFFFFF`};function Oe(e){let{mode:t,accent:n,fontFamily:r,children:i}=e,[a,o]=C.useState(t??`light`),s=t??a;C.useEffect(()=>{typeof document>`u`||document.documentElement.setAttribute(`data-theme`,s)},[s]),C.useEffect(()=>{typeof document>`u`||!n||document.documentElement.style.setProperty(`--accent`,De[n])},[n]),C.useEffect(()=>{typeof document>`u`||!r||(r.sans&&document.documentElement.style.setProperty(`--font-sans`,r.sans),r.mono&&document.documentElement.style.setProperty(`--font-mono`,r.mono))},[r]);let c=C.useMemo(()=>({mode:s,setMode:e=>o(e),toggle:()=>o(e=>e===`light`?`dark`:`light`)}),[s]);return(0,S.jsx)(Ee.Provider,{value:c,children:i})}var ke=g(),Ae=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),je=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Me={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},Ne=(0,C.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>(0,C.createElement)(`svg`,{ref:c,...Me,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:je(`lucide`,i),...s},[...o.map(([e,t])=>(0,C.createElement)(e,t)),...Array.isArray(a)?a:[a]])),Pe=(e,t)=>{let n=(0,C.forwardRef)(({className:n,...r},i)=>(0,C.createElement)(Ne,{ref:i,iconNode:t,className:je(`lucide-${Ae(e)}`,n),...r}));return n.displayName=`${e}`,n},Fe=Pe(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),Ie=Pe(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Le=Pe(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),Re=Pe(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ze=Pe(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Be=Pe(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),Ve=`oc-theme`;function He(){let[e,t]=(0,C.useState)(()=>localStorage.getItem(Ve)??`dark`);return(0,C.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,e),localStorage.setItem(Ve,e)},[e]),{theme:e,toggle:()=>t(e=>e===`dark`?`light`:`dark`)}}function Ue(e){let[t,n]=(0,C.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,C.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}function We({wsConnected:e}){let{theme:t,toggle:n}=He(),r=Ue(`(max-width: 760px)`),[i,a]=(0,C.useState)(!1),o=typeof window<`u`?`${window.location.origin}/mcp`:`/mcp`,s=async()=>{typeof navigator>`u`||!navigator.clipboard||(await navigator.clipboard.writeText(o),a(!0),window.setTimeout(()=>a(!1),1500))},c=(0,S.jsx)(ee,{icon:t===`dark`?(0,S.jsx)(ze,{size:15}):(0,S.jsx)(Le,{size:15}),"aria-label":`Toggle theme`,variant:`ghost`,size:`sm`,shape:`circle`,onClick:n}),l=(0,S.jsx)(ne,{tone:e?`info`:`danger`,size:`sm`,children:e?`live`:`offline`}),u=(0,S.jsx)(w,{variant:`primary`,size:`sm`,iconLeft:i?(0,S.jsx)(Fe,{size:12}):(0,S.jsx)(Ie,{size:12}),onClick:s,children:i?`Copied`:`Copy MCP URL`});return r?(0,S.jsxs)(T,{justify:`between`,align:`center`,style:{display:`flex`,width:`100%`,padding:`0.5rem 0.75rem`},children:[(0,S.jsx)(`strong`,{children:`OtelContext`}),(0,S.jsxs)(T,{size:`xs`,align:`center`,children:[u,l,c]})]}):(0,S.jsxs)(T,{justify:`between`,align:`center`,style:{display:`flex`,width:`100%`,padding:`0.5rem 1rem`,gap:`0.75rem`},children:[(0,S.jsx)(T,{size:`md`,align:`center`,children:(0,S.jsx)(`strong`,{children:`OtelContext`})}),(0,S.jsx)(`div`,{style:{flex:1,minWidth:0,maxWidth:640},children:(0,S.jsx)(te,{value:o,readOnly:!0,type:`url`,size:`sm`,"aria-label":`MCP endpoint URL`})}),(0,S.jsxs)(T,{size:`sm`,align:`center`,children:[u,l,c]})]})}var A={fg1:`#1C1C1C`,fg2:`#3D3D3D`,fg3:`#5A5A5A`,fg4:`#A6A6A6`,bg1:`#FFFFFF`,bg2:`#FAFAFA`,bg3:`#F5F5F5`,border1:`#E5E5E5`,border2:`#D4D4D4`,accent:`#E60000`,accentSoft:`rgba(230,0,0,0.08)`,success:`#1F9E5C`,warning:`#D98E2B`,danger:`#E60000`,info:`#2D73D9`,series:[`#E60000`,`#1C1C1C`,`#5A5A5A`,`#2D73D9`,`#1F9E5C`,`#D98E2B`,`#9E0000`,`#A6A6A6`],fontSans:`Inter, system-ui, sans-serif`,fontMono:`'JetBrains Mono', monospace`,mode:`light`};function j(e,t){return typeof window>`u`?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Ge(){if(typeof window>`u`)return A;let e=document.documentElement.getAttribute(`data-theme`)??`light`,t=j(`--fg-1`,A.fg1),n=j(`--fg-2`,A.fg2),r=j(`--fg-3`,A.fg3),i=j(`--fg-4`,A.fg4),a=j(`--bg-1`,A.bg1),o=j(`--bg-2`,A.bg2),s=j(`--bg-3`,A.bg3),c=j(`--border-1`,A.border1),l=j(`--border-2`,A.border2),u=j(`--accent`,A.accent);return{fg1:t,fg2:n,fg3:r,fg4:i,bg1:a,bg2:o,bg3:s,border1:c,border2:l,accent:u,accentSoft:j(`--accent-soft`,A.accentSoft),success:j(`--success`,A.success),warning:j(`--warning`,A.warning),danger:j(`--danger`,A.danger),info:j(`--info`,A.info),series:e===`dark`?[u,`#F5F5F5`,`#A6A6A6`,`#5BA0F2`,`#3FBE83`,`#E5A65A`,`#FF6464`,`#7A7A7A`]:[u,`#1C1C1C`,`#5A5A5A`,`#2D73D9`,`#1F9E5C`,`#D98E2B`,`#9E0000`,`#A6A6A6`],fontSans:j(`--font-sans`,A.fontSans),fontMono:j(`--font-mono`,A.fontMono),mode:e}}function Ke(e){if(typeof window>`u`)return()=>{};let t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),()=>t.disconnect()}var qe=`modulepreload`,Je=function(e){return`/`+e},Ye={},Xe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=Je(t,n),t in Ye)return;Ye[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:qe,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ze=null;function Qe(){if(typeof window>`u`)return{webgl2:!1,webgpu:!1,devicePixelRatio:1,maxTextureSize:0};if(Ze)return{...Ze,devicePixelRatio:window.devicePixelRatio||1,maxTextureSize:0};let e=!1,t=0;try{let n=document.createElement(`canvas`).getContext(`webgl2`);n&&(e=!0,t=n.getParameter(n.MAX_TEXTURE_SIZE))}catch{}let n=`gpu`in navigator&&typeof navigator.gpu==`object`;return Ze={webgl2:e,webgpu:n},{webgl2:e,webgpu:n,devicePixelRatio:window.devicePixelRatio||1,maxTextureSize:t}}function $e(e,t,n=5e4){let r=Qe();return e===`canvas`?`canvas`:e===`webgl`?r.webgl2?`webgl`:`canvas`:e===`webgpu`?r.webgpu?`webgpu`:r.webgl2?`webgl`:`canvas`:r.webgpu&&t>n?`webgpu`:r.webgl2&&t>n?`webgl`:`canvas`}var et=null;async function tt(){if(et)return et;try{let e=await Xe(()=>import(`./design-system-IOKLDoaG.js`),[]),t=await Xe(()=>import(`./design-system-DFjB0sSn.js`),[]);return et={Deck:e.Deck,SolidPolygonLayer:t.SolidPolygonLayer,ScatterplotLayer:t.ScatterplotLayer,LineLayer:t.LineLayer,ArcLayer:t.ArcLayer,PolygonLayer:t.PolygonLayer},et}catch(e){return console.warn(`[@ossrandom/design-system] WebGL renderer requested but @deck.gl/core not installed. Falling back to canvas. Run: pnpm add @deck.gl/core @deck.gl/layers`,e),null}}function nt(e,t=255){if(!e)return[0,0,0,t];if(e.startsWith(`rgb`)){let n=/rgba?\(([^)]+)\)/.exec(e);if(!n)return[0,0,0,t];let[r=0,i=0,a=0,o=1]=n[1].split(`,`).map(e=>parseFloat(e.trim()));return[r,i,a,Math.round(o*255)]}let n=e.replace(`#`,``);return n.length===3?[parseInt(n[0]+n[0],16),parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),t]:n.length>=6?[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16),n.length===8?parseInt(n.slice(6,8),16):t]:[0,0,0,t]}var rt=null;async function it(){if(rt)return rt.ctor;try{let e=await Xe(()=>import(`./cytoscape.esm-Dm6iss-N.js`),[]),t=e.default??e;try{let e=await Xe(()=>import(`./cytoscape-cose-bilkent-sPlXtCXB.js`).then(e=>c(e.default,1)),[]);t.use(e.default??e)}catch{}return rt={ctor:t},t}catch(e){return console.warn(`[@ossrandom/design-system] cytoscape not installed:`,e),null}}function at(e,t){return t<=0?3:3+Math.sqrt(e)/Math.sqrt(t)*11}function ot(e,t){let n=new Map;for(let t of e)n.set(t.id,0);for(let e of t)n.set(e.source,(n.get(e.source)??0)+1),n.set(e.target,(n.get(e.target)??0)+1);let r=0;for(let e of n.values())e>r&&(r=e);return{degrees:n,max:r}}async function st(e,t,n,r){let{degrees:i}=ot(e,t);if(e.every(e=>e.x!==void 0&&e.y!==void 0))return e.map(e=>({...e,x:e.x,y:e.y,degree:i.get(e.id)??0}));try{let a=await Xe(()=>import(`./design-system-BNhP-Tae.js`),[]),o=e.map(e=>({...e,x:n/2+(Math.random()-.5)*100,y:r/2+(Math.random()-.5)*100,degree:i.get(e.id)??0})),s=a.forceSimulation(o).force(`link`,a.forceLink(t.map(e=>({source:e.source,target:e.target}))).id(e=>e.id).distance(60)).force(`charge`,a.forceManyBody().strength(-300)).force(`center`,a.forceCenter(n/2,r/2)).force(`collide`,a.forceCollide(14)).stop();for(let e=0;e<200;e++)s.tick();return o}catch{let t=Math.ceil(Math.sqrt(e.length)),a=n/t,o=r/Math.ceil(e.length/t);return e.map((e,n)=>({...e,x:n%t*a+a/2,y:Math.floor(n/t)*o+o/2,degree:i.get(e.id)??0}))}}function ct(e){let{nodes:t,edges:n,height:r=480,layout:i=`cose-bilkent`,engine:a=`auto`,onNodeClick:o,onEdgeClick:s,className:c,style:l,id:u}=e,d=C.useRef(null),f=C.useRef(null),p=C.useRef(null),[m,h]=C.useState(0),[g,_]=C.useState(`canvas`);return C.useEffect(()=>{_($e(a,t.length+n.length,500))},[a,t.length,n.length]),C.useEffect(()=>{if(!d.current)return;let e=new ResizeObserver(e=>{let t=Math.floor(e[0].contentRect.width);t>0&&t!==m&&h(t)});return e.observe(d.current),()=>e.disconnect()},[m]),C.useEffect(()=>{if(g!==`canvas`||!d.current)return;let e=!1,r=d.current;return it().then(a=>{if(!a||e){a||(r.innerHTML=`
Service map (canvas) requires cytoscape. Run: pnpm add cytoscape cytoscape-cose-bilkent
`);return}let c=Ge(),{degrees:l,max:u}=ot(t,n),d=a({container:r,elements:[...t.map(e=>{let t=l.get(e.id)??0,n=at(t,u);return{data:{id:e.id,label:e.label,status:e.status,kind:e.kind,degree:t,diameter:Math.round(n*2)}}}),...n.map(e=>({data:{id:`${e.source}->${e.target}`,source:e.source,target:e.target,label:e.label,status:e.status}}))],style:lt(c),layout:{name:i,animate:!1,fit:!0,padding:24,nodeRepulsion:6e3,idealEdgeLength:80},wheelSensitivity:.2,minZoom:.2,maxZoom:3});o&&d.on(`tap`,`node`,e=>o(e.target.data())),s&&d.on(`tap`,`edge`,e=>s(e.target.data()));let p=e=>{let t=e.isNode?.()??!0;if(d.elements().addClass(`rcs-dim`),t){let t=e.connectedEdges?.(),n=e.connectedNodes?.();n?.removeClass(`rcs-dim`),t?.removeClass(`rcs-dim`),d.$(`#${ut(e.id())}`).removeClass(`rcs-dim`),d.$(`#${ut(e.id())}`).addClass(`rcs-focus`),t?.addClass(`rcs-focus-edge`),n?.addClass(`rcs-neighbor`)}else{let t=e.connectedNodes?.();t?.removeClass(`rcs-dim`),t?.addClass(`rcs-neighbor`)}},m=()=>{d.elements().removeClass(`rcs-dim rcs-focus rcs-focus-edge rcs-neighbor`)};d.on(`mouseover`,`node`,e=>p(e.target)),d.on(`mouseover`,`edge`,e=>p(e.target)),d.on(`mouseout`,`node`,()=>m()),d.on(`mouseout`,`edge`,()=>m()),d.on(`tap`,`node`,e=>p(e.target)),d.on(`tap`,`edge`,e=>p(e.target));let h=d.container();h&&h.addEventListener(`pointerleave`,m),f.current=d}),()=>{e=!0,f.current?.destroy(),f.current=null,r.innerHTML=``}},[g,t,n,i,o,s]),C.useEffect(()=>{if(g===`canvas`||m===0||!d.current)return;let e=!1,i=d.current;return(async()=>{let a=await tt();if(!a||e){_(`canvas`);return}let c=await st(t,n,m,r);if(e)return;let l=new Map(c.map((e,t)=>[e.id,t])),u=Ge(),d=c.reduce((e,t)=>Math.max(e,t.degree),0),f=g===`webgpu`?`webgpu`:`webgl`,h=a.ScatterplotLayer,v=a.ArcLayer,y=new Map,b=new Map;for(let e of c)y.set(e.id,new Set),b.set(e.id,new Set);for(let e of n){let t=`${e.source}->${e.target}`;y.get(e.source)?.add(e.target),y.get(e.target)?.add(e.source),b.get(e.source)?.add(t),b.get(e.target)?.add(t)}let x=null,S=e=>!x||e===x?!0:y.get(x)?.has(e)??!1,C=e=>x?e.source===x||e.target===x:!0,w=(e,t)=>[e[0],e[1],e[2],t],ee=()=>[new v({id:`service-edges`,data:n.map(e=>({...e,sourcePos:c[l.get(e.source)??0],targetPos:c[l.get(e.target)??0]})),getSourcePosition:e=>[e.sourcePos.x,e.sourcePos.y,0],getTargetPosition:e=>[e.targetPos.x,e.targetPos.y,0],getSourceColor:e=>{let t=C(e);return w(nt(t&&x?u.accent:e.status===`failing`?u.danger:u.border2),t?255:60)},getTargetColor:e=>{let t=C(e);return w(nt(t&&x?u.accent:e.status===`failing`?u.danger:u.fg4),t?255:60)},getWidth:e=>C(e)&&x||e.status===`failing`?2:1,getHeight:.3,pickable:!!s,updateTriggers:{getSourceColor:[x],getTargetColor:[x],getWidth:[x]}}),new h({id:`service-nodes`,data:c,getPosition:e=>[e.x,e.y,0],getFillColor:e=>{let t=S(e.id);return w(nt(e.status===`failing`?u.danger:e.status===`degraded`?u.warning:e.status===`healthy`?u.success:u.fg3),t?230:60)},getLineColor:e=>x===e.id?nt(u.accent):nt(u.bg1),getRadius:e=>at(e.degree,d),radiusUnits:`pixels`,stroked:!0,getLineWidth:e=>x===e.id?2:1,lineWidthUnits:`pixels`,pickable:!0,updateTriggers:{getFillColor:[x],getLineColor:[x],getLineWidth:[x]}})],te=new a.Deck({parent:i,width:m,height:r,controller:!0,deviceProps:{type:f},views:[{"@@type":`OrthographicView`,id:`v`,flipY:!0}],viewState:{target:[m/2,r/2,0],zoom:0},layers:ee(),onHover:({object:e,layer:t})=>{let n=null;e&&t?.id===`service-nodes`?n=e.id:e&&t?.id===`service-edges`&&(n=e.source),n!==x&&(x=n,te.setProps({layers:ee()}))},onClick:({object:e,layer:t})=>{!e||!t||(t.id===`service-nodes`&&o?o(e):t.id===`service-edges`&&s&&s(e))}});p.current=te})().catch(e=>{console.warn(`[@ossrandom/design-system] ServiceMap WebGL init failed; falling back to canvas:`,e),_(`canvas`)}),()=>{e=!0,p.current?.destroy(),p.current=null,i.innerHTML=``}},[g,m,r,t,n,o,s]),C.useEffect(()=>Ke(()=>{_(e=>e)}),[]),(0,S.jsx)(`div`,{ref:d,id:u,className:y(`rcs-service-map`,`rcs-service-map--${g}`,c),style:{position:`relative`,width:`100%`,height:r,...l},"data-engine":g,role:`img`,"aria-label":e[`aria-label`]??`Service map with ${t.length} services`,children:(0,S.jsx)(`div`,{className:`rcs-service-map-engine-badge`,"aria-hidden":`true`,children:g})})}function lt(e){return[{selector:`node`,style:{shape:`ellipse`,width:`data(diameter)`,height:`data(diameter)`,"background-color":e.fg3,"border-color":e.bg1,"border-width":1,label:`data(label)`,color:e.fg3,"font-family":e.fontSans,"font-size":11,"font-weight":400,"text-valign":`bottom`,"text-halign":`center`,"text-margin-y":4,"text-events":`no`,"min-zoomed-font-size":9,"z-index":10,"transition-property":`background-color, border-color, border-width, color, opacity`,"transition-duration":`120ms`}},{selector:`node[status = 'healthy']`,style:{"background-color":e.success}},{selector:`node[status = 'degraded']`,style:{"background-color":e.warning}},{selector:`node[status = 'failing']`,style:{"background-color":e.danger}},{selector:`edge`,style:{width:1,"line-color":e.border2,"target-arrow-color":e.border2,"target-arrow-shape":`triangle`,"arrow-scale":.9,"curve-style":`bezier`,label:`data(label)`,color:e.fg4,"font-family":e.fontMono,"font-size":9,"text-rotation":`autorotate`,"text-margin-y":-4,"text-opacity":0,"text-events":`no`,"z-index":1,"transition-property":`line-color, width, target-arrow-color, opacity, text-opacity`,"transition-duration":`120ms`}},{selector:`edge[status = 'failing']`,style:{"line-color":e.danger,"target-arrow-color":e.danger,width:1.5}},{selector:`.rcs-dim`,style:{opacity:.18}},{selector:`node.rcs-focus`,style:{opacity:1,"border-color":e.accent,"border-width":2,color:e.fg1,"font-weight":500,"z-index":30}},{selector:`node.rcs-neighbor`,style:{opacity:1,color:e.fg1,"z-index":20}},{selector:`edge.rcs-focus-edge`,style:{opacity:1,"line-color":e.accent,"target-arrow-color":e.accent,width:2,"text-opacity":1,color:e.fg1,"z-index":25}},{selector:`node:selected`,style:{"border-color":e.accent,"border-width":2}}]}function ut(e){return typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,e=>`\\${e}`)}function dt(e){return e===`healthy`?`info`:e===`degraded`?`warning`:e===`critical`||e===`failing`?`danger`:`neutral`}var ft=C.memo(({node:e,edges:t,onClose:n,onSelectService:r})=>{let i=t.filter(t=>t.target===e.id),a=t.filter(t=>t.source===e.id),o=e.metrics.error_rate*100;return(0,S.jsxs)(T,{direction:`vertical`,size:`md`,children:[(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:(0,S.jsxs)(T,{size:`xs`,align:`center`,children:[(0,S.jsx)(`code`,{children:e.id}),(0,S.jsx)(ne,{tone:dt(e.status),size:`sm`,children:e.status})]}),extra:(0,S.jsx)(ee,{icon:(0,S.jsx)(Be,{size:13}),"aria-label":`Close`,variant:`ghost`,size:`sm`,onClick:n}),children:(0,S.jsxs)(ue,{columns:2,gap:`sm`,children:[(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`RPS`,value:Math.round(e.metrics.request_rate_rps)})}),(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`Error Rate`,value:o.toFixed(2),unit:`%`})}),(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`Avg Latency`,value:e.metrics.avg_latency_ms,unit:`ms`})}),(0,S.jsx)(ue.Col,{span:1,children:(0,S.jsx)(Se,{label:`P99`,value:e.metrics.p99_latency_ms,unit:`ms`})})]})}),(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:`Health Score`,extra:(0,S.jsx)(ne,{tone:`subtle`,size:`sm`,children:e.health_score.toFixed(2)}),children:(0,S.jsx)(he,{value:e.health_score*100,tone:e.health_score<.4?`danger`:e.health_score<.7?`warning`:`neutral`})}),i.length>0&&(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:`Upstream`,children:(0,S.jsx)(T,{direction:`vertical`,size:`xs`,children:i.map(e=>(0,S.jsx)(w,{variant:`ghost`,size:`sm`,block:!0,onClick:()=>r(e.source),children:(0,S.jsxs)(T,{justify:`between`,align:`center`,children:[(0,S.jsx)(`code`,{children:e.source}),(0,S.jsxs)(ne,{tone:`subtle`,size:`sm`,children:[e.call_count,` calls`]})]})},e.source))})}),a.length>0&&(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,title:`Downstream`,children:(0,S.jsx)(T,{direction:`vertical`,size:`xs`,children:a.map(e=>(0,S.jsx)(w,{variant:`ghost`,size:`sm`,block:!0,onClick:()=>r(e.target),children:(0,S.jsxs)(T,{justify:`between`,align:`center`,children:[(0,S.jsx)(`code`,{children:e.target}),(0,S.jsxs)(ne,{tone:`subtle`,size:`sm`,children:[e.call_count,` calls`]})]})},e.target))})}),e.alerts.length>0&&(0,S.jsx)(T,{direction:`vertical`,size:`xs`,children:e.alerts.map((e,t)=>(0,S.jsx)(O,{severity:`danger`,children:e},t))})]})}),pt=C.memo(({items:e})=>(0,S.jsx)(ce,{bordered:!0,padding:`md`,radius:`md`,children:(0,S.jsx)(T,{size:`lg`,wrap:!0,children:e.map((e,t)=>(0,S.jsxs)(C.Fragment,{children:[t>0&&(0,S.jsx)(le,{direction:`vertical`}),(0,S.jsx)(Se,{...e})]},`${t}-${String(e.label)}`))})}));function mt(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(Math.round(e*10)/10)}function ht(e=800){let[t,n]=(0,C.useState)(()=>typeof window>`u`?e:window.innerHeight);return(0,C.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>n(window.innerHeight);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),t}function gt(e){return e===`healthy`||e===`degraded`?e:e===`critical`||e===`failing`?`failing`:`unknown`}function _t(e){return e===`critical`||e===`failing`?`failing`:`healthy`}var vt=C.memo(({graph:e,loading:t,error:n,dashboard:r,stats:i})=>{let[a,o]=(0,C.useState)(null),[s,c]=(0,C.useState)(``),l=Ue(`(max-width: 760px)`),u=ht(),d=l?460:Math.max(460,u-320),f=e?.nodes??[],p=e?.edges??[],m=(0,C.useMemo)(()=>{let e=s.trim().toLowerCase();return f.filter(t=>!e||t.id.toLowerCase().includes(e)).map(e=>({id:e.id,label:e.id,status:gt(e.status)}))},[f,s]),h=(0,C.useMemo)(()=>{if(m.length===0)return[];let e=new Set(m.map(e=>e.id));return p.filter(t=>e.has(t.source)&&e.has(t.target)).slice(0,500).map(e=>({source:e.source,target:e.target,status:_t(e.status)}))},[p,m]),g=r?.active_services??f.length,_=r?.error_rate??0,v=i,y=e=>{if(typeof e==`number`)return e;if(typeof e==`string`&&e.trim()!==``&&Number.isFinite(Number(e)))return Number(e)},b=y(v?.TraceCount)??y(v?.traceCount)??r?.total_traces??0,x=y(v?.LogCount)??y(v?.logCount)??r?.total_logs??0,w=y(v?.DBSizeMB)??y(v?.db_size_mb),ee=e=>{o(f.find(t=>t.id===e.id)??null)},ne=e=>{let t=f.find(t=>t.id===e);t&&o(t)};return(0,S.jsxs)(T,{direction:`vertical`,size:`md`,style:{display:`flex`,width:`100%`},children:[(0,S.jsx)(we,{size:`sm`,title:`Service Topology`,subtitle:`Live dependency map · click a node for details`,inlineSubtitle:!0}),(0,S.jsx)(pt,{items:[{label:`Services`,value:g},{label:`Error rate`,value:_.toFixed(2),unit:`%`},{label:`Traces`,value:mt(b)},{label:`Logs`,value:mt(x)},...w!=null&&Number.isFinite(w)?[{label:`DB`,value:w.toFixed(0),unit:`MB`}]:[]]}),(0,S.jsxs)(ce,{bordered:!0,padding:`sm`,radius:`md`,extra:(0,S.jsx)(te,{value:s,onChange:e=>c(e),placeholder:`Filter services`,size:`sm`,prefix:(0,S.jsx)(Re,{size:12})}),children:[t&&(0,S.jsx)(ge,{label:`Loading service map`}),n&&(0,S.jsx)(O,{severity:`danger`,title:`Service map failed to load`,children:n}),!t&&!n&&f.length===0&&(0,S.jsx)(O,{severity:`info`,children:`No services discovered yet.`}),!t&&!n&&m.length===0&&f.length>0&&(0,S.jsx)(O,{severity:`info`,children:`No services match the filter.`}),!t&&!n&&m.length>0&&(0,S.jsx)(ct,{nodes:m,edges:h,layout:`cose-bilkent`,height:d,onNodeClick:ee})]}),(0,S.jsx)(me,{open:a!==null,onClose:()=>o(null),placement:`right`,width:l?`92vw`:420,title:a?(0,S.jsx)(`code`,{children:a.id}):void 0,description:`Service detail · upstream, downstream, alerts`,children:a&&(0,S.jsx)(ft,{node:a,edges:p,onClose:()=>o(null),onSelectService:ne})})]})});function yt(e=6e4){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(``),[a,o]=(0,C.useState)(!0),[s,c]=(0,C.useState)(null),l=(0,C.useRef)(void 0),u=(0,C.useCallback)(async()=>{try{let e=await fetch(`/api/system/graph`);if(!e.ok)throw Error(`HTTP ${e.status}`);i(e.headers.get(`X-Cache`)??``),n(await e.json()),c(null)}catch(e){c(e instanceof Error?e.message:`fetch failed`)}finally{o(!1)}},[]);return(0,C.useEffect)(()=>(u(),l.current=setInterval(u,e),()=>clearInterval(l.current)),[u,e]),{graph:t,cache:r,loading:a,error:s,reload:u}}function bt(e=3e4){let[t,n]=(0,C.useState)(null),[r,i]=(0,C.useState)(null),[a,o]=(0,C.useState)(!0),[s,c]=(0,C.useState)(null),l=(0,C.useRef)(void 0),u=(0,C.useCallback)(async()=>{try{let[e,t]=await Promise.all([fetch(`/api/metrics/dashboard`),fetch(`/api/stats`)]);if(!e.ok||!t.ok)throw Error(`fetch failed`);n(await e.json()),i(await t.json()),c(null)}catch(e){c(e instanceof Error?e.message:`fetch failed`)}finally{o(!1)}},[]);return(0,C.useEffect)(()=>(u(),l.current=setInterval(u,e),()=>clearInterval(l.current)),[u,e]),{dashboard:t,stats:r,loading:a,error:s,reload:u}}var xt=100,St=1e4,Ct=3e4,wt=35e3;function Tt(e){let t=(0,C.useRef)(null),n=(0,C.useRef)(e),[r,i]=(0,C.useState)(`connecting`);t.status=r;let a=(0,C.useRef)(0),o=(0,C.useRef)(null),s=(0,C.useRef)(null),c=(0,C.useRef)(null),l=(0,C.useRef)(!1),u=(0,C.useRef)(()=>{});(0,C.useEffect)(()=>{n.current=e},[e]);let d=(0,C.useCallback)(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),f=(0,C.useCallback)(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null),c.current!==null&&(window.clearTimeout(c.current),c.current=null)},[]),p=(0,C.useCallback)(()=>{if(l.current)return;d();let e=a.current,t=Math.min(xt*2**e,St);a.current=e+1,i(`reconnecting`),o.current=window.setTimeout(()=>{o.current=null,u.current()},t)},[d]),m=(0,C.useCallback)(()=>{f(),s.current=window.setInterval(()=>{let e=t.current;if(!(!e||e.readyState!==WebSocket.OPEN)){try{e.send(JSON.stringify({type:`ping`}))}catch{return}c.current!==null&&window.clearTimeout(c.current),c.current=window.setTimeout(()=>{c.current=null;let e=t.current;if(e)try{e.close()}catch{}},wt)}},Ct)},[f]),h=(0,C.useCallback)(()=>{if(l.current)return;d(),f();let e=t.current;if(e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}t.current=null}i(a.current===0?`connecting`:`reconnecting`);let r=window.location.protocol===`https:`?`wss:`:`ws:`,o;try{o=new WebSocket(`${r}//${window.location.host}/ws`)}catch{p();return}t.current=o,o.onopen=()=>{l.current||(a.current=0,i(`connected`),m())},o.onmessage=e=>{c.current!==null&&(window.clearTimeout(c.current),c.current=null);try{let t=JSON.parse(e.data);t.type===`logs`&&Array.isArray(t.data)&&n.current(t.data)}catch{}},o.onerror=()=>{},o.onclose=()=>{l.current||(t.current===o&&(t.current=null),f(),i(`disconnected`),p())}},[f,d,p,m]);return(0,C.useEffect)(()=>{u.current=h},[h]),(0,C.useEffect)(()=>{l.current=!1,u.current=h,h();let e=()=>{if(document.visibilityState!==`visible`)return;let e=t.current;(!e||e.readyState===WebSocket.CLOSED||e.readyState===WebSocket.CLOSING)&&(a.current=0,d(),u.current())},n=()=>{a.current=0,d(),u.current()};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,n),()=>{l.current=!0,document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,n),d(),f();let r=t.current;if(r){r.onopen=null,r.onmessage=null,r.onerror=null,r.onclose=null;try{r.close()}catch{}t.current=null}}},[]),t}function Et(){let[e,t]=(0,C.useState)(`services`),n=yt(),r=bt();return(0,S.jsx)(Te,{header:(0,S.jsx)(We,{view:e,onNavigate:t,wsConnected:Tt(()=>void 0).status===`connected`}),children:(0,S.jsx)(vt,{graph:n.graph,loading:n.loading,error:n.error,dashboard:r.dashboard,stats:r.stats})})}var Dt=class extends C.Component{state={error:null,info:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.setState({info:t}),console.error(`[ErrorBoundary] Uncaught error in React tree`,{message:e.message,name:e.name,stack:e.stack,componentStack:t.componentStack,url:typeof window>`u`?void 0:window.location.href,userAgent:typeof navigator>`u`?void 0:navigator.userAgent,timestamp:new Date().toISOString()})}reset=()=>{this.setState({error:null,info:null})};reload=()=>{typeof window<`u`&&window.location.reload()};render(){let{error:e,info:t}=this.state;if(!e)return this.props.children;let n=`var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace)`;return(0,S.jsx)(`div`,{role:`alert`,"aria-live":`assertive`,style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`24px`,background:`var(--bg-0, #0a0a0a)`,color:`var(--fg-1, #fff)`,fontFamily:`var(--font-sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)`,zIndex:9999,overflow:`auto`},children:(0,S.jsxs)(`div`,{style:{width:`100%`,maxWidth:`640px`,background:`var(--bg-1, #111)`,border:`1px solid var(--border-1, #27272a)`,borderRadius:`var(--radius-lg, 12px)`,padding:`32px`,boxShadow:`var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.5))`},children:[(0,S.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:700,letterSpacing:`0.14em`,textTransform:`uppercase`,color:`var(--brand-red-500, #ef4444)`,marginBottom:`12px`},children:`Application error`}),(0,S.jsx)(`h1`,{style:{fontSize:`24px`,fontWeight:700,margin:`0 0 12px 0`,color:`var(--fg-1, #fff)`},children:`Something went wrong`}),(0,S.jsx)(`p`,{style:{fontSize:`14px`,lineHeight:1.6,color:`var(--fg-2, #d4d4d8)`,margin:`0 0 20px 0`},children:`The UI encountered an unexpected error and could not continue rendering. You can try recovering without a full reload, or refresh the page if that fails.`}),(0,S.jsxs)(`div`,{style:{background:`var(--bg-3, #050505)`,border:`1px solid var(--border-1, #27272a)`,borderRadius:`var(--radius-md, 8px)`,padding:`12px 14px`,marginBottom:`20px`,fontFamily:n,fontSize:`13px`,color:`var(--fg-2, #d4d4d8)`,wordBreak:`break-word`},children:[(0,S.jsx)(`span`,{style:{color:`var(--brand-red-500, #ef4444)`},children:e.name||`Error`}),`: `,e.message||`(no message)`]}),t?.componentStack&&(0,S.jsxs)(`details`,{style:{marginBottom:`24px`,fontSize:`12px`,color:`var(--fg-3, #71717a)`},children:[(0,S.jsx)(`summary`,{style:{cursor:`pointer`,userSelect:`none`,padding:`4px 0`,color:`var(--fg-2, #d4d4d8)`},children:`Component stack`}),(0,S.jsx)(`pre`,{style:{marginTop:`8px`,padding:`12px`,background:`var(--bg-3, #050505)`,border:`1px solid var(--border-1, #27272a)`,borderRadius:`var(--radius-md, 8px)`,fontFamily:n,fontSize:`11px`,lineHeight:1.5,color:`var(--fg-2, #d4d4d8)`,whiteSpace:`pre-wrap`,wordBreak:`break-word`,maxHeight:`240px`,overflow:`auto`},children:t.componentStack})]}),(0,S.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,flexWrap:`wrap`},children:[(0,S.jsx)(`button`,{type:`button`,onClick:this.reset,style:{appearance:`none`,border:`1px solid var(--accent-fg, #ef4444)`,background:`var(--accent-fg, #ef4444)`,color:`var(--accent-on, #fff)`,padding:`10px 18px`,borderRadius:`var(--radius-md, 8px)`,fontSize:`14px`,fontWeight:600,cursor:`pointer`,transition:`background 120ms ease`},children:`Try again`}),(0,S.jsx)(`button`,{type:`button`,onClick:this.reload,style:{appearance:`none`,border:`1px solid var(--border-2, #3f3f46)`,background:`transparent`,color:`var(--fg-1, #fff)`,padding:`10px 18px`,borderRadius:`var(--radius-md, 8px)`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,transition:`border-color 120ms ease`},children:`Reload page`})]})]})})}};(0,ke.createRoot)(document.getElementById(`root`)).render((0,S.jsx)(C.StrictMode,{children:(0,S.jsxs)(Oe,{mode:`dark`,children:[(0,S.jsx)(Dt,{children:(0,S.jsx)(Et,{})}),(0,S.jsx)(xe,{})]})}));export{o as t}; \ No newline at end of file diff --git a/internal/ui/dist/index.html b/internal/ui/dist/index.html index 68d8839..0de6f33 100644 --- a/internal/ui/dist/index.html +++ b/internal/ui/dist/index.html @@ -4,7 +4,7 @@ OtelContext - + diff --git a/main.go b/main.go index bd1747c..9a03b06 100644 --- a/main.go +++ b/main.go @@ -177,6 +177,11 @@ func main() { slog.Info("🚀 Starting OtelContext", "version", Version, "env", cfg.Env, "log_level", level) + // Pace the GC against a soft memory ceiling so RSS stays bounded under + // sustained ingest (honors an explicit GOMEMLIMIT; otherwise 75% of the + // detected cgroup/host budget). See applyMemoryLimit in memlimit.go. + applyMemoryLimit(75) + // 1. Initialize Internal Telemetry (first — everything registers metrics against this) metrics := telemetry.New() slog.Info("📊 Internal telemetry initialized") diff --git a/memlimit.go b/memlimit.go new file mode 100644 index 0000000..a6be394 --- /dev/null +++ b/memlimit.go @@ -0,0 +1,94 @@ +package main + +import ( + "log/slog" + "os" + "runtime/debug" + "strconv" + "strings" +) + +// applyMemoryLimit sets a soft heap ceiling (GOMEMLIMIT) so the garbage collector +// paces against a bound instead of letting the next-GC target run away on a large +// heap. Without it, a deployment under sustained ingest lets RSS climb to the +// (uncapped) GC target and never returns it to the OS — observed in the SQLite +// soak as ~1.8 GB RSS held flat after load stopped. A soft limit makes the GC run +// more frequently as the heap approaches the ceiling, keeping the working set and +// RSS bounded without the hard-OOM behavior of a rlimit. +// +// If the operator already set the GOMEMLIMIT env var, the Go runtime has applied +// it at startup and we leave it untouched. Otherwise the budget is detected from +// (in order) cgroup v2, cgroup v1, then /proc/meminfo, and the limit is set to +// pct percent of that budget. Any detection failure leaves the runtime default +// (no limit) in place — never worse than today. +func applyMemoryLimit(pct int) { + if _, ok := os.LookupEnv("GOMEMLIMIT"); ok { + slog.Info("🧠 GOMEMLIMIT set by operator; honoring it", + "soft_limit_bytes", debug.SetMemoryLimit(-1)) + return + } + budget, source := detectMemoryBudget() + if budget <= 0 { + slog.Warn("🧠 could not detect memory budget; GOMEMLIMIT left unset (GC target unbounded)") + return + } + limit := budget / 100 * int64(pct) + debug.SetMemoryLimit(limit) + slog.Info("🧠 soft memory limit applied (GOMEMLIMIT)", + "limit_mib", limit/(1<<20), "budget_mib", budget/(1<<20), "pct", pct, "source", source) +} + +// detectMemoryBudget returns the applicable memory budget in bytes and its source, +// or (0, "") if nothing usable is found. cgroup limits take precedence over host +// RAM so containerized deployments pace against their actual quota. +func detectMemoryBudget() (int64, string) { + if v, ok := readCgroupBytes("/sys/fs/cgroup/memory.max"); ok { // cgroup v2 + return v, "cgroup.v2" + } + if v, ok := readCgroupBytes("/sys/fs/cgroup/memory/memory.limit_in_bytes"); ok { // cgroup v1 + return v, "cgroup.v1" + } + if v, ok := readMemTotal("/proc/meminfo"); ok { + return v, "meminfo.MemTotal" + } + return 0, "" +} + +// readCgroupBytes reads a cgroup memory-limit file. Returns (bytes, true) only for +// a concrete limit; "max", empty, non-numeric, or a near-max "unlimited" sentinel +// (>= 1 PiB, used by cgroup v1) returns (0, false) so the caller falls through. +func readCgroupBytes(path string) (int64, bool) { + b, err := os.ReadFile(path) //nolint:gosec // G304: fixed cgroup sysfs path, not user input + if err != nil { + return 0, false + } + s := strings.TrimSpace(string(b)) + if s == "" || s == "max" { + return 0, false + } + v, err := strconv.ParseInt(s, 10, 64) + if err != nil || v <= 0 || v >= (1<<50) { + return 0, false + } + return v, true +} + +// readMemTotal parses MemTotal (in kB) from a /proc/meminfo-formatted file and +// returns it in bytes. +func readMemTotal(path string) (int64, bool) { + b, err := os.ReadFile(path) //nolint:gosec // G304: fixed /proc/meminfo path, not user input + if err != nil { + return 0, false + } + for line := range strings.SplitSeq(string(b), "\n") { + if strings.HasPrefix(line, "MemTotal:") { + f := strings.Fields(line) + if len(f) >= 2 { + if kb, err := strconv.ParseInt(f[1], 10, 64); err == nil && kb > 0 { + return kb * 1024, true + } + } + } + } + return 0, false +} diff --git a/memlimit_test.go b/memlimit_test.go new file mode 100644 index 0000000..13592d3 --- /dev/null +++ b/memlimit_test.go @@ -0,0 +1,67 @@ +package main + +import ( + "os" + "path/filepath" + "testing" +) + +func TestReadCgroupBytes(t *testing.T) { + dir := t.TempDir() + cases := []struct { + name string + content string + want int64 + wantOK bool + }{ + {"concrete limit", "2147483648\n", 2147483648, true}, + {"unlimited max", "max\n", 0, false}, + {"empty", "", 0, false}, + {"non-numeric", "garbage", 0, false}, + {"zero", "0", 0, false}, + {"v1 near-max sentinel", "9223372036854771712", 0, false}, // ~8 EiB "unlimited" + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + p := filepath.Join(dir, tc.name) + if err := os.WriteFile(p, []byte(tc.content), 0o600); err != nil { + t.Fatal(err) + } + got, ok := readCgroupBytes(p) + if got != tc.want || ok != tc.wantOK { + t.Fatalf("readCgroupBytes(%q)=(%d,%v) want (%d,%v)", tc.content, got, ok, tc.want, tc.wantOK) + } + }) + } + if _, ok := readCgroupBytes(filepath.Join(dir, "does-not-exist")); ok { + t.Fatal("missing file should return ok=false") + } +} + +func TestReadMemTotal(t *testing.T) { + dir := t.TempDir() + meminfo := "MemFree: 1000 kB\nMemTotal: 16384000 kB\nBuffers: 500 kB\n" + p := filepath.Join(dir, "meminfo") + if err := os.WriteFile(p, []byte(meminfo), 0o600); err != nil { + t.Fatal(err) + } + got, ok := readMemTotal(p) + if !ok || got != 16384000*1024 { + t.Fatalf("readMemTotal=(%d,%v) want (%d,true)", got, ok, int64(16384000)*1024) + } + if _, ok := readMemTotal(filepath.Join(dir, "nope")); ok { + t.Fatal("missing meminfo should return ok=false") + } +} + +func TestDetectMemoryBudget(t *testing.T) { + // On the Linux test host at least one source (meminfo) must resolve to a + // positive budget; the function must never return a negative value. + b, src := detectMemoryBudget() + if b < 0 { + t.Fatalf("budget must not be negative, got %d", b) + } + if b > 0 && src == "" { + t.Fatal("positive budget must carry a source label") + } +} diff --git a/ui/src/App.tsx b/ui/src/App.tsx index fdcae01..4f9a352 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -15,7 +15,7 @@ export default function App() { // WebSocket retained as the live/offline source for the header indicator; // log batches it pushes are intentionally discarded. const ws = useWebSocket(() => undefined) - const wsConnected = !!ws.current + const wsConnected = ws.status === 'connected' return ( { it('renders KPI values', () => { renderPanel(); - expect(screen.getByText('670')).toBeInTheDocument(); - expect(screen.getByText('8.4%')).toBeInTheDocument(); - expect(screen.getByText('142ms')).toBeInTheDocument(); - expect(screen.getByText('890ms')).toBeInTheDocument(); + // The design-system renders the numeric value and unit in separate + // nodes inside `.rcs-stat-value`, so e.g. '8.4%' / '142ms' never + // appear as a single text node. Assert on the combined textContent of the + // stat-value container instead. + const statValues = document.querySelectorAll('.rcs-stat-value'); + const texts = Array.from(statValues).map((el) => el.textContent ?? ''); + expect(texts).toContain('670'); // RPS — no unit + expect(texts.some((t) => t === '8.40%')).toBe(true); // error rate + expect(texts.some((t) => t === '142ms')).toBe(true); // avg latency + expect(texts.some((t) => t === '890ms')).toBe(true); // p99 }); it('renders upstream service name', () => { diff --git a/ui/src/main.tsx b/ui/src/main.tsx index 3d5cded..dbf216b 100644 --- a/ui/src/main.tsx +++ b/ui/src/main.tsx @@ -4,11 +4,14 @@ import { ThemeProvider, ToastRegion } from '@ossrandom/design-system' import '@ossrandom/design-system/styles.css' import './styles/global.css' import App from './App' +import { ErrorBoundary } from './components/ErrorBoundary' createRoot(document.getElementById('root')!).render( - + + + ,