diff --git a/docker-compose.coolify.yml b/docker-compose.coolify.yml index f57aeb8..c9b118d 100644 --- a/docker-compose.coolify.yml +++ b/docker-compose.coolify.yml @@ -50,6 +50,7 @@ services: LLMPROXY_ADMIN_PASSWORD_FILE: ${LLMPROXY_ADMIN_PASSWORD_FILE:-/data/admin-password} LLMPROXY_ADMIN_PASSWORD_DISABLED: ${LLMPROXY_ADMIN_PASSWORD_DISABLED:-0} LLMPROXY_CATALOG_TTL: ${LLMPROXY_CATALOG_TTL:-5s} + LLMPROXY_FAILOVER_COOLDOWN: ${LLMPROXY_FAILOVER_COOLDOWN:-30s} LLMPROXY_MAX_BODY_BYTES: ${LLMPROXY_MAX_BODY_BYTES:-10485760} LLMPROXY_MAX_EMBEDDING_BATCH: ${LLMPROXY_MAX_EMBEDDING_BATCH:-2048} LLMPROXY_PRICING_FILE: ${LLMPROXY_PRICING_FILE:-} diff --git a/docs/concepts/architecture.md b/docs/concepts/architecture.md index 5f2b8ba..f23d19d 100644 --- a/docs/concepts/architecture.md +++ b/docs/concepts/architecture.md @@ -226,6 +226,15 @@ silent pick makes routing a mystery. A dry-run `resolve` endpoint answers another model, but only one hop, resolved in the same query, so lookup stays single-step and cycles are unrepresentable. +### An alias with several targets fails over before the first byte + +An alias may list several targets with a declared strategy. The strategy is +explicit, so the pick is never silent. The proxy tries the next target only +before it writes a byte to the caller, because the body passes through +unchanged and a partial response cannot be taken back. Rotation, in-flight +counts and cooldowns are kept in memory per replica: they are hints about +the near past, not state, and the database stays the source of truth. + ### Admin mutations are audited in-transaction Every admin mutation writes a metadata-only `admin_event` row in the same diff --git a/docs/guides/models.md b/docs/guides/models.md index 468e41f..4f10662 100644 --- a/docs/guides/models.md +++ b/docs/guides/models.md @@ -142,10 +142,72 @@ Three rules, enforced at write time: Usage is recorded against the name the caller passed, so two teams pointing at one model stay distinguishable in the summaries. +## Point a name at several models + +Give `targets` and a `strategy` to spread one name over several models, for +example the same model on two providers: + +```bash +curl -s $P/admin/v1/models -H "authorization: Bearer $ADMIN" \ + -H 'content-type: application/json' \ + -d '{"alias": "acme/smart", "targets": ["glm-tensorx", "glm-vllm"], "strategy": "failover"}' +``` + +```json +{ + "alias": "acme/smart", + "target": null, + "targets": [ + {"alias": "glm-tensorx", "weight": 1}, + {"alias": "glm-vllm", "weight": 1} + ], + "strategy": "failover", + "capabilities": ["chat", "chat_stream"] +} +``` + +The strategy picks the first target for each request: + +| `strategy` | First target | +|---|---| +| `failover` (default) | The first in the list | +| `round_robin` | The next in the list, in turn | +| `weighted` | A random pick, in proportion to `weight` | +| `least_busy` | The one with the fewest requests in flight | + +A target entry is a model name, or `{"alias": "...", "weight": 3}`. A weight +is used only by `weighted` and defaults to 1. + +With every strategy, the proxy tries the next target when an attempt fails +before any byte reaches the caller: + +- The upstream is unreachable. +- The upstream answers 429 or a 5xx status. + +After the first byte, the response is the caller's, and an error after that +point is relayed as it is. A target that failed goes to the end of the order +for `LLMPROXY_FAILOVER_COOLDOWN` (30 seconds by default). The response header +`x-llmproxy-attempts` gives the number of targets tried. Each failed attempt +is recorded as a usage row flagged `failed_over`, which request counts leave +out. + +The rules of [a single target](#point-a-name-at-another-model) apply to each +target. Two more apply to the list: + +- **Capabilities are the intersection.** The name serves only what every + target serves. +- **Prices come from the target that answered,** unless the name has a price + of its own. + +A `strategy` with one target, or an unknown one, is 400 `invalid_strategy`. A +name listed twice is 400 `invalid_target`. + ## Edit a model `PATCH /admin/v1/models/{alias}` takes any of `alias`, `provider`, -`capabilities`, `upstream_name`, `target`, `pricing` and `hidden`. Everything +`capabilities`, `upstream_name`, `target`, `targets`, `strategy`, `pricing` +and `hidden`. `targets` replaces the whole list, and `strategy` alone keeps +the list. Everything is editable in place; nothing here needs deleting and recreating. ```bash @@ -213,10 +275,26 @@ curl -s "$P/admin/v1/resolve?model=qwen-72b&endpoint=chat&stream=true" \ "provider": "vllm-1", "upstream_name": "Qwen/Qwen2.5-VL-72B-Instruct", "url": "http://10.0.0.5:8000/v1/chat/completions", - "capabilities": ["chat", "chat_stream", "completions"] + "capabilities": ["chat", "chat_stream", "completions"], + "strategy": null, + "targets": [ + { + "alias": "qwen-72b", + "provider": "vllm-1", + "upstream_name": "Qwen/Qwen2.5-VL-72B-Instruct", + "url": "http://10.0.0.5:8000/v1/chat/completions", + "weight": 1, + "cooling_down": false, + "cooldown_until": null + } + ] } ``` +For a name with several targets, `targets` lists them in the order the +next request would try, and `cooling_down` marks a target that failed +recently. The order is per replica. + `endpoint` defaults to `chat`; `stream=true` additionally requires `chat_stream`. `url` reflects any per-endpoint override. The failure modes are the data-plane ones: 404 `model_not_found` (unknown name or disabled provider) diff --git a/docs/reference/api.md b/docs/reference/api.md index 2f2cafe..4719ee7 100644 --- a/docs/reference/api.md +++ b/docs/reference/api.md @@ -11,7 +11,7 @@ The full machine-readable spec is in [openapi.yaml](openapi.yaml). |---|---|---| | `POST /v1/chat/completions` | **Supported** | Unary JSON and SSE streaming. Vision content parts, tool/function calls, response_format, logprobs etc. pass through untouched. Capability `chat` (+ `chat_stream` for streaming). | | `POST /v1/completions` | **Supported** | Legacy text completions, unary and streamed. Capability `completions`. | -| `GET /v1/models` | **Supported** | Aliases on enabled providers, minus the hidden ones; `?endpoint=chat\|embeddings\|...` filters by capability. `?include_hidden=1` adds hidden models and needs an API key or session (401 without one). `?include_pricing=1` adds `pricing` (per million units, the prices in force) and `pricing_inherited`, and needs an API key or session too. Each entry carries the OpenAI fields plus `capabilities` (resolved), `alias_of` (the model this name points at, or `null`) and `hidden`. Public, no API key required. | +| `GET /v1/models` | **Supported** | Aliases on enabled providers, minus the hidden ones; `?endpoint=chat\|embeddings\|...` filters by capability. `?include_hidden=1` adds hidden models and needs an API key or session (401 without one). `?include_pricing=1` adds `pricing` (per million units, the prices in force) and `pricing_inherited`, and needs an API key or session too. Each entry carries the OpenAI fields plus `capabilities` (resolved), `alias_of` (the model this name points at, or `null`), `targets` and `strategy` (for an alias with several targets, else `null`) and `hidden`. Public, no API key required. | | `GET /v1/models/{id}` | Not yet | Trivial to add; nothing has needed it. | | `POST /v1/embeddings` | **Supported** | Unary passthrough. Capability `embeddings`. Array `input` is capped at `LLMPROXY_MAX_EMBEDDING_BATCH` items (default 2048); larger batches get 400 `embedding_batch_too_large`. | | `POST /v1/audio/transcriptions` | Planned | Streamed multipart, no disk spill; `audio_seconds` unit reserved. | @@ -29,8 +29,10 @@ only exposes curated aliases and provider names. Its `include_hidden=1` form is not, since it names models an admin took off the list. Model names callers see are curated aliases, globally unique across all -providers; there is no bare-upstream-name fallback and no multi-provider -resolution. Calling an endpoint outside a model's capability set fails at the +providers; there is no bare-upstream-name fallback. An alias can point at +several models, and the proxy then picks one per request by the alias's +strategy (see [models](../guides/models.md#point-a-name-at-several-models)). +Calling an endpoint outside a model's capability set fails at the proxy with a 400 naming the supported capabilities, never with a confusing upstream 404. @@ -38,7 +40,8 @@ Every response carries `x-llmproxy-provider` and `x-llmproxy-model`. When the provider has rate-limit tracking configured, responses also carry `x-llmproxy-ratelimit-requests-remaining`, `x-llmproxy-ratelimit-requests-limit`, `x-llmproxy-ratelimit-tokens-remaining` and `x-llmproxy-ratelimit-tokens-limit` -(only the observed values are set). Errors are +(only the observed values are set). A request to an alias with several +targets also carries `x-llmproxy-attempts`, the number of targets tried. Errors are OpenAI-shaped with an added `llmproxy.source` field plus `x-llmproxy-error-source: proxy|upstream`; upstream error bodies and status codes pass through intact. @@ -89,7 +92,7 @@ together; a pair nothing carries simply matches nothing. `outcome` takes |---|---| | `GET /stats/series?bucket&since&until` | Bucketed usage across everyone | | `GET /stats/summary?since&until` | Usage aggregated per (principal, provider, model, endpoint, client, tags) | -| `GET /stats/requests?limit&offset` | One page of the filtered request metadata log (never content), newest first; returns `{requests, limit, offset, total}` | +| `GET /stats/requests?limit&offset` | One page of the filtered request metadata log (never content), newest first, with `failed_over` set on attempts another target replaced; returns `{requests, limit, offset, total}` | | `GET /stats/requests/facets?since&until` | Distinct principals, keys, providers, models, clients and tags in the window, for the explorer's filter options | | `GET /stats/errors?bucket&since&until` | The errors dashboard in one call: a gap-filled series of counts per outcome, plus a breakdown per (provider, model, endpoint, client, tags, outcome, error_kind, status_code) with request count, average duration, last-seen and time-to-outcome bands (<1s, 1-5s, 5-15s, 15-30s, 30-60s, 60-120s, >=120s). Rows with outcome `ok` are included so error rates have their denominator. | | `GET /stats/performance?bucket&since&until` | The performance view in one call: a summary, a gap-filled series and a per-model breakdown. Each holds `requests`, `measured`, and `duration_ms`, `ttft_ms` and `tokens_per_second` as `{mean, p50, p95}`, null when no request qualifies. The summary and the series also hold `concurrency` as `{average, peak}`. A range with more than 500,000 requests is a 400 `range_too_large`. | @@ -125,7 +128,7 @@ Proxy-generated errors: 404 `unknown_relay_token`, 404 |---|---| | `POST/GET/PATCH/DELETE /providers[/{name}]` | Register, inspect, edit, unregister providers (upstream key encrypted at rest, never returned) | | `GET /providers/{name}/discover` | Upstream model listing; read-only, never auto-binds | -| `POST/GET/PATCH/DELETE /models[/{alias}]` | Bind upstream models to globally unique aliases with capability sets and per-unit prices; a name can instead `target` another model and inherit its provider, capabilities and prices (one hop). Everything, including the name, is editable in place; a binding serves as soon as it exists (disable the provider to take it offline) | +| `POST/GET/PATCH/DELETE /models[/{alias}]` | Bind upstream models to globally unique aliases with capability sets and per-unit prices; a name can instead `target` another model and inherit its provider, capabilities and prices (one hop), or list several `targets` with a `strategy`. Everything, including the name, is editable in place; a binding serves as soon as it exists (disable the provider to take it offline) | | `GET /resolve?model&endpoint&stream` | Dry-run alias resolution | | `POST/GET /principals` | Users and service principals | | `POST /principals/{id}/revoke-sessions` | Delete every browser session of a principal (API keys untouched) | @@ -133,7 +136,7 @@ Proxy-generated errors: 404 `unknown_relay_token`, 404 | `POST/GET /pricing` | Load/inspect the versioned pricing feed (bulk; per-model prices go through `/models`) | | `GET /usage/summary?since&until&principal` | Usage and cost by principal/model/endpoint/unit | | `GET /usage/series?bucket&since&until&principal` | Usage bucketed by hour/day/week/month across everyone | -| `GET /requests?limit&offset` | The request metadata log with per-unit quantities (who, key, model, outcome, tokens; never content); same filters as `/stats/requests` | +| `GET /requests?limit&offset` | The request metadata log with per-unit quantities (who, key, model, outcome, `failed_over`, tokens; never content); same filters as `/stats/requests` | | `GET /events` | Metadata-only admin audit trail | ### Pagination diff --git a/docs/reference/configuration.md b/docs/reference/configuration.md index 11525d5..a5306b9 100644 --- a/docs/reference/configuration.md +++ b/docs/reference/configuration.md @@ -30,6 +30,7 @@ default, so check the value when a setting looks like it was ignored. | `LLMPROXY_ADMIN_PASSWORD_FILE` | `.llmproxy/admin-password` | Where the generated admin password lives (created mode 0600). Ignored when `LLMPROXY_ADMIN_PASSWORD` is set | | `LLMPROXY_ADMIN_PASSWORD_DISABLED` | `false` | Disable password login entirely, for SSO-only deployments | | `LLMPROXY_CATALOG_TTL` | `5s` | Alias-resolution cache TTL. Admin API mutations invalidate the cache immediately; this TTL bounds staleness for changes made directly in the database or from another instance | +| `LLMPROXY_FAILOVER_COOLDOWN` | `30s` | How long an alias target that failed goes to the end of the order. `0` disables the cooldown. Kept per replica | | `LLMPROXY_MAX_BODY_BYTES` | `10485760` (10 MiB) | Request body ceiling on the `/v1` endpoints. Oversize requests get 413 `request_too_large` | | `LLMPROXY_MAX_EMBEDDING_BATCH` | `2048` | Maximum items in an embeddings `input` array. `0` or negative disables the check | | `LLMPROXY_PRICING_FILE` | empty | Path to a pricing feed JSON loaded at startup. Stored only when its `version` differs from the active feed. Format in [pricing](../guides/pricing.md#load-a-whole-price-list) | diff --git a/docs/reference/openapi.yaml b/docs/reference/openapi.yaml index 936cc8f..c30e541 100644 --- a/docs/reference/openapi.yaml +++ b/docs/reference/openapi.yaml @@ -123,6 +123,12 @@ components: description: Upstream model name the alias resolved to. schema: type: string + XLLMProxyAttempts: + description: > + Number of alias targets tried, the last one being the one that + answered. Above 1 only for an alias with several targets. + schema: + type: integer XLLMProxyErrorSource: description: > `proxy` when the error was generated by llmproxy itself, `upstream` @@ -266,7 +272,19 @@ components: nullable: true description: > The model this name points at, `null` when it binds a provider - directly. An extension to the OpenAI shape. + directly or has several targets. An extension to the OpenAI shape. + targets: + type: [array, "null"] + items: + type: string + description: > + The models an alias with several targets points at, in order; + `null` otherwise. An extension to the OpenAI shape. + strategy: + type: [string, "null"] + description: > + How an alias with several targets picks one; `null` otherwise. An + extension to the OpenAI shape. hidden: type: boolean description: > @@ -674,6 +692,16 @@ components: provider itself. `provider`, `upstream_name` and `capabilities` above are always the resolved ones; for an alias they are the target's. + targets: + type: array + items: + $ref: '#/components/schemas/AliasTarget' + description: > + The targets of an alias with several, in order. Empty otherwise. + `provider` and `upstream_name` are the first target's, and + `capabilities` is the intersection over all of them. + strategy: + $ref: '#/components/schemas/Strategy' pricing: $ref: '#/components/schemas/ModelPricing' pricing_inherited: @@ -688,6 +716,45 @@ components: serves requests under this name. The flag is the row's own: hiding a model does not hide the aliases pointing at it. + AliasTarget: + type: object + required: [alias, provider, weight] + properties: + alias: + type: string + provider: + type: string + description: The provider this target routes to. + weight: + type: integer + minimum: 1 + description: Share of requests under the `weighted` strategy. + + TargetSpec: + description: A model name, or an object with a weight. + oneOf: + - type: string + - type: object + required: [alias] + properties: + alias: + type: string + weight: + type: integer + minimum: 0 + default: 1 + + Strategy: + type: [string, "null"] + enum: [failover, round_robin, weighted, least_busy, null] + description: > + How an alias with several targets picks the first target to try: + `failover` the first in the list, `round_robin` each in turn, + `weighted` at random by weight, `least_busy` the one with the fewest + requests in flight. With any strategy, an attempt that fails before + the first byte (unreachable, 429 or 5xx) moves on to the next target. + `null` for a model with one target or none. + ModelPricing: type: object description: > @@ -706,8 +773,8 @@ components: type: object description: > A model either routes to a provider's model (`provider` + - `upstream_name`) or is a name for a model already bound (`target`). - Give one or the other, never both. + `upstream_name`) or is a name for models already bound (`target` or + `targets`). Give one of the three, never several. properties: alias: type: string @@ -727,6 +794,19 @@ components: `upstream_name`. It must route to a provider itself (aliases are one hop) and the new model needs its own `alias`. Provider, upstream model, capabilities and prices are inherited. + targets: + type: array + items: + $ref: '#/components/schemas/TargetSpec' + description: > + Several models this one points at, in order. Each follows the + `target` rules. A name listed twice is 400 `invalid_target`. + strategy: + type: string + enum: [failover, round_robin, weighted, least_busy] + description: > + Needs at least two `targets`, else 400 `invalid_strategy`. + Defaults to `failover`. capabilities: type: array items: @@ -771,6 +851,17 @@ components: `upstream_name` in the same call. Sending `provider`, `upstream_name` or `capabilities` for a model that stays an alias is rejected with `invalid_target`. + targets: + type: array + items: + $ref: '#/components/schemas/TargetSpec' + description: > + Replace the whole target list. An empty list turns the model back + into a binding of its own, like an empty `target`. + strategy: + type: string + enum: [failover, round_robin, weighted, least_busy] + description: Change the strategy and keep the target list. pricing: $ref: '#/components/schemas/ModelPricing' hidden: @@ -801,6 +892,32 @@ components: type: array items: $ref: '#/components/schemas/Capability' + strategy: + $ref: '#/components/schemas/Strategy' + targets: + type: array + description: > + Every target, in the order the next request would try them. The + order and cooldowns are per replica. + items: + type: object + properties: + alias: + type: string + provider: + type: string + upstream_name: + type: string + url: + type: string + weight: + type: integer + cooling_down: + type: boolean + description: True when the target failed within the cooldown. + cooldown_until: + type: [string, 'null'] + format: date-time Principal: type: object @@ -1233,6 +1350,8 @@ paths: $ref: '#/components/headers/XLLMProxyProvider' x-llmproxy-model: $ref: '#/components/headers/XLLMProxyModel' + x-llmproxy-attempts: + $ref: '#/components/headers/XLLMProxyAttempts' content: application/json: schema: @@ -1282,6 +1401,8 @@ paths: $ref: '#/components/headers/XLLMProxyProvider' x-llmproxy-model: $ref: '#/components/headers/XLLMProxyModel' + x-llmproxy-attempts: + $ref: '#/components/headers/XLLMProxyAttempts' x-llmproxy-error-source: $ref: '#/components/headers/XLLMProxyErrorSource' @@ -1308,6 +1429,8 @@ paths: $ref: '#/components/headers/XLLMProxyProvider' x-llmproxy-model: $ref: '#/components/headers/XLLMProxyModel' + x-llmproxy-attempts: + $ref: '#/components/headers/XLLMProxyAttempts' content: application/json: schema: @@ -1368,6 +1491,8 @@ paths: $ref: '#/components/headers/XLLMProxyProvider' x-llmproxy-model: $ref: '#/components/headers/XLLMProxyModel' + x-llmproxy-attempts: + $ref: '#/components/headers/XLLMProxyAttempts' content: application/json: schema: @@ -2703,6 +2828,11 @@ paths: type: boolean cancelled: type: boolean + failed_over: + type: boolean + description: > + An attempt given up on before another alias + target was tried. Request counts leave it out. cost: type: [number, 'null'] unpriced: diff --git a/internal/catalog/balance.go b/internal/catalog/balance.go new file mode 100644 index 0000000..c3aac44 --- /dev/null +++ b/internal/catalog/balance.go @@ -0,0 +1,174 @@ +package catalog + +import ( + "math/rand/v2" + "sync" + "time" +) + +// Strategies an alias with several targets may declare. +var Strategies = []string{"failover", "round_robin", "weighted", "least_busy"} + +func IsStrategy(name string) bool { + for _, s := range Strategies { + if s == name { + return true + } + } + return false +} + +// Plan lists the routes of one alias. Strategy is empty with one route. +type Plan struct { + Alias string + Strategy string + Routes []*Route +} + +// Capabilities is the intersection over every route. +func (p *Plan) Capabilities() map[string]bool { + out := map[string]bool{} + for cap := range p.Routes[0].Capabilities { + out[cap] = true + } + for _, r := range p.Routes[1:] { + for cap := range out { + if !r.Capabilities[cap] { + delete(out, cap) + } + } + } + return out +} + +// Balancer holds the per-replica rotation, in-flight and cooldown state. +type Balancer struct { + cooldown time.Duration + now func() time.Time + rand func(n int) int + + mu sync.Mutex + next map[string]uint64 + inflight map[string]int + cooledUntil map[string]time.Time +} + +func NewBalancer(cooldown time.Duration) *Balancer { + return &Balancer{ + cooldown: cooldown, + now: time.Now, + rand: rand.IntN, + next: map[string]uint64{}, + inflight: map[string]int{}, + cooledUntil: map[string]time.Time{}, + } +} + +// TargetKey names the model a route serves, whichever alias reaches it. +func (r *Route) TargetKey() string { + if r.TargetAlias != "" { + return r.TargetAlias + } + return r.Alias +} + +// Order puts the strategy's pick first and routes in cooldown last. +func (b *Balancer) Order(p *Plan) []*Route { + if len(p.Routes) < 2 { + return p.Routes + } + b.mu.Lock() + defer b.mu.Unlock() + start := b.start(p) + ordered := make([]*Route, 0, len(p.Routes)) + ordered = append(ordered, p.Routes[start]) + for i, r := range p.Routes { + if i != start { + ordered = append(ordered, r) + } + } + now := b.now() + ready := make([]*Route, 0, len(ordered)) + var cooled []*Route + for _, r := range ordered { + if until, ok := b.cooledUntil[r.TargetKey()]; ok && now.Before(until) { + cooled = append(cooled, r) + } else { + ready = append(ready, r) + } + } + if len(ready) == 0 { + return p.Routes + } + return append(ready, cooled...) +} + +func (b *Balancer) start(p *Plan) int { + switch p.Strategy { + case "round_robin": + n := b.next[p.Alias] + b.next[p.Alias] = n + 1 + return int(n % uint64(len(p.Routes))) + case "weighted": + total := 0 + for _, r := range p.Routes { + total += max(r.Weight, 1) + } + pick := b.rand(total) + for i, r := range p.Routes { + pick -= max(r.Weight, 1) + if pick < 0 { + return i + } + } + case "least_busy": + best := 0 + for i, r := range p.Routes { + if b.inflight[r.TargetKey()] < b.inflight[p.Routes[best].TargetKey()] { + best = i + } + } + return best + } + return 0 +} + +// Fail puts a route in cooldown. +func (b *Balancer) Fail(r *Route) { + if b.cooldown <= 0 { + return + } + b.mu.Lock() + b.cooledUntil[r.TargetKey()] = b.now().Add(b.cooldown) + b.mu.Unlock() +} + +// CoolingDown reports whether a route is in cooldown and until when. +func (b *Balancer) CoolingDown(r *Route) (bool, time.Time) { + b.mu.Lock() + defer b.mu.Unlock() + until, ok := b.cooledUntil[r.TargetKey()] + if !ok { + return false, time.Time{} + } + if !b.now().Before(until) { + delete(b.cooledUntil, r.TargetKey()) + return false, time.Time{} + } + return true, until +} + +// Acquire counts a request in flight until the returned func runs. +func (b *Balancer) Acquire(r *Route) func() { + key := r.TargetKey() + b.mu.Lock() + b.inflight[key]++ + b.mu.Unlock() + return func() { + b.mu.Lock() + if b.inflight[key]--; b.inflight[key] <= 0 { + delete(b.inflight, key) + } + b.mu.Unlock() + } +} diff --git a/internal/catalog/balance_test.go b/internal/catalog/balance_test.go new file mode 100644 index 0000000..c02da3e --- /dev/null +++ b/internal/catalog/balance_test.go @@ -0,0 +1,134 @@ +package catalog + +import ( + "testing" + "time" +) + +func testPlan(strategy string, names ...string) *Plan { + p := &Plan{Alias: "ha", Strategy: strategy} + for _, n := range names { + p.Routes = append(p.Routes, &Route{Alias: "ha", TargetAlias: n, ProviderName: n, Weight: 1}) + } + return p +} + +func names(routes []*Route) string { + out := "" + for _, r := range routes { + out += r.TargetAlias + } + return out +} + +func newTestBalancer(cooldown time.Duration) (*Balancer, *time.Time) { + now := time.Unix(1000, 0) + b := NewBalancer(cooldown) + b.now = func() time.Time { return now } + return b, &now +} + +func TestOrderFailoverKeepsListedOrder(t *testing.T) { + b, _ := newTestBalancer(time.Minute) + p := testPlan("failover", "a", "b", "c") + for i := 0; i < 3; i++ { + if got := names(b.Order(p)); got != "abc" { + t.Fatalf("order = %s", got) + } + } +} + +func TestOrderRoundRobinRotatesStart(t *testing.T) { + b, _ := newTestBalancer(time.Minute) + p := testPlan("round_robin", "a", "b", "c") + var got []string + for i := 0; i < 4; i++ { + got = append(got, names(b.Order(p))) + } + want := []string{"abc", "bac", "cab", "abc"} + for i := range want { + if got[i] != want[i] { + t.Fatalf("orders = %v, want %v", got, want) + } + } +} + +func TestOrderWeightedFollowsWeights(t *testing.T) { + b, _ := newTestBalancer(time.Minute) + p := testPlan("weighted", "a", "b") + p.Routes[0].Weight = 3 + p.Routes[1].Weight = 1 + picks := []int{0, 2, 3} + i := 0 + b.rand = func(n int) int { + if n != 4 { + t.Fatalf("rand range = %d, want total weight 4", n) + } + v := picks[i] + i++ + return v + } + for _, want := range []string{"ab", "ab", "ba"} { + if got := names(b.Order(p)); got != want { + t.Fatalf("order = %s, want %s", got, want) + } + } +} + +func TestOrderLeastBusyPicksFewestInFlight(t *testing.T) { + b, _ := newTestBalancer(time.Minute) + p := testPlan("least_busy", "a", "b", "c") + releaseA := b.Acquire(p.Routes[0]) + releaseB := b.Acquire(p.Routes[1]) + if got := names(b.Order(p)); got != "cab" { + t.Fatalf("order = %s", got) + } + releaseA() + releaseB() + if got := names(b.Order(p)); got != "abc" { + t.Fatalf("after release = %s", got) + } +} + +func TestOrderMovesCooledTargetsLast(t *testing.T) { + b, now := newTestBalancer(30 * time.Second) + p := testPlan("failover", "a", "b", "c") + b.Fail(p.Routes[0]) + if got := names(b.Order(p)); got != "bca" { + t.Fatalf("order = %s", got) + } + if cooled, _ := b.CoolingDown(p.Routes[0]); !cooled { + t.Fatal("a must be cooling down") + } + b.Fail(p.Routes[1]) + b.Fail(p.Routes[2]) + if got := names(b.Order(p)); got != "abc" { + t.Fatalf("all cooled = %s, want listed order", got) + } + *now = now.Add(31 * time.Second) + if got := names(b.Order(p)); got != "abc" { + t.Fatalf("after expiry = %s", got) + } + if cooled, _ := b.CoolingDown(p.Routes[0]); cooled { + t.Fatal("cooldown must expire") + } +} + +func TestZeroCooldownDisables(t *testing.T) { + b, _ := newTestBalancer(0) + p := testPlan("failover", "a", "b") + b.Fail(p.Routes[0]) + if got := names(b.Order(p)); got != "ab" { + t.Fatalf("order = %s", got) + } +} + +func TestPlanCapabilitiesIntersect(t *testing.T) { + p := testPlan("failover", "a", "b") + p.Routes[0].Capabilities = map[string]bool{"chat": true, "chat_stream": true, "embeddings": true} + p.Routes[1].Capabilities = map[string]bool{"chat": true, "chat_stream": true} + caps := p.Capabilities() + if !caps["chat"] || !caps["chat_stream"] || caps["embeddings"] { + t.Fatalf("caps = %v", caps) + } +} diff --git a/internal/catalog/catalog.go b/internal/catalog/catalog.go index 2793b99..86390fc 100644 --- a/internal/catalog/catalog.go +++ b/internal/catalog/catalog.go @@ -1,13 +1,7 @@ -// Package catalog: alias resolution. -// -// The one rule: a caller-facing model name is a globally unique alias mapping -// to exactly one (provider, upstream model) pair, so resolution can never be -// ambiguous; ambiguity is rejected at write time by the alias unique -// constraint. A name may reach that pair through one hop, by pointing at -// another binding, which the store resolves in the same query — so this stays -// a single lookup and a chain can never loop. Resolution takes the endpoint -// into account: the binding's provider must be enabled and the endpoint in -// the capability set. +// Package catalog resolves a caller-facing alias to an ordered plan of routes. +// Aliases are globally unique, so resolution is never ambiguous. An alias +// reaches its targets through at most one hop, and every route's provider is +// enabled. package catalog import ( @@ -65,6 +59,7 @@ type Route struct { TimeoutConnect time.Duration TimeoutRead time.Duration MaxConcurrency int + Weight int Alias string // TargetAlias is the alias this one points at, empty when the model // routes to a provider directly. Pricing falls through it. @@ -103,7 +98,7 @@ func boolStr(b bool) string { type cacheEntry struct { expires time.Time - route *Route // nil means "known absent" + plan *Plan // nil means "known absent" } type Catalog struct { @@ -125,12 +120,12 @@ func (c *Catalog) Invalidate() { c.mu.Unlock() } -func (c *Catalog) Resolve(ctx context.Context, alias, endpoint string, streaming bool) (*Route, *apierr.ProxyError) { - route, err := c.lookup(ctx, alias) +func (c *Catalog) Resolve(ctx context.Context, alias, endpoint string, streaming bool) (*Plan, *apierr.ProxyError) { + plan, err := c.lookup(ctx, alias) if err != nil { return nil, apierr.New(500, "internal_error", "catalog lookup failed") } - if route == nil { + if plan == nil { return nil, apierr.Newf(404, "model_not_found", "model '%s' does not exist or its provider is disabled", alias).WithParam("model") } @@ -138,15 +133,16 @@ func (c *Catalog) Resolve(ctx context.Context, alias, endpoint string, streaming if streaming && endpoint == "chat" { needed = append(needed, "chat_stream") } + caps := plan.Capabilities() var missing []string for _, cap := range needed { - if !route.Capabilities[cap] { + if !caps[cap] { missing = append(missing, cap) } } if len(missing) > 0 { - supported := make([]string, 0, len(route.Capabilities)) - for cap := range route.Capabilities { + supported := make([]string, 0, len(caps)) + for cap := range caps { supported = append(supported, cap) } sort.Strings(supported) @@ -154,35 +150,52 @@ func (c *Catalog) Resolve(ctx context.Context, alias, endpoint string, streaming "model '%s' does not support %v; supported capabilities: %v", alias, missing, supported).WithParam("model") } - return route, nil + return plan, nil } -func (c *Catalog) lookup(ctx context.Context, alias string) (*Route, error) { +func (c *Catalog) lookup(ctx context.Context, alias string) (*Plan, error) { now := time.Now() c.mu.Lock() if entry, ok := c.cache[alias]; ok && entry.expires.After(now) { c.mu.Unlock() - return entry.route, nil + return entry.plan, nil } c.mu.Unlock() - route, err := c.load(ctx, alias) + plan, err := c.load(ctx, alias) if err != nil { return nil, err } c.mu.Lock() - c.cache[alias] = cacheEntry{expires: now.Add(c.ttl), route: route} + c.cache[alias] = cacheEntry{expires: now.Add(c.ttl), plan: plan} c.mu.Unlock() - return route, nil + return plan, nil } -func (c *Catalog) load(ctx context.Context, alias string) (*Route, error) { - binding, provider, overrides, err := c.store.ResolveAlias(ctx, alias) - if err != nil || binding == nil || provider == nil { +func (c *Catalog) load(ctx context.Context, alias string) (*Plan, error) { + binding, targets, err := c.store.ResolveAlias(ctx, alias) + if err != nil || binding == nil || len(targets) == 0 { return nil, err } + plan := &Plan{Alias: binding.Alias, Strategy: binding.Strategy} + for _, t := range targets { + route, err := c.route(binding.Alias, t) + if err != nil { + return nil, err + } + plan.Routes = append(plan.Routes, route) + } + if len(plan.Routes) < 2 { + plan.Strategy = "" + } + return plan, nil +} + +func (c *Catalog) route(alias string, t store.ResolvedTarget) (*Route, error) { + binding, provider := t.Binding, t.Provider credential := "" if provider.CredentialCiphertext.Valid && provider.CredentialCiphertext.String != "" { + var err error credential, err = secrets.DecryptCredential(c.secret, provider.CredentialCiphertext.String) if err != nil { return nil, err @@ -194,6 +207,10 @@ func (c *Catalog) load(ctx context.Context, alias string) (*Route, error) { caps[cap] = true } } + targetAlias := binding.TargetAlias + if binding.Alias != alias { + targetAlias = binding.Alias + } return &Route{ ProviderID: provider.ID, ProviderName: provider.Name, @@ -205,11 +222,12 @@ func (c *Catalog) load(ctx context.Context, alias string) (*Route, error) { TimeoutConnect: time.Duration(provider.TimeoutConnect * float64(time.Second)), TimeoutRead: time.Duration(provider.TimeoutRead * float64(time.Second)), MaxConcurrency: int(provider.MaxConcurrency.Int64), - Alias: binding.Alias, - TargetAlias: binding.TargetAlias, + Weight: max(t.Weight, 1), + Alias: alias, + TargetAlias: targetAlias, UpstreamName: binding.UpstreamName, Capabilities: caps, - URLOverrides: overrides, + URLOverrides: t.Overrides, RateLimitHeaders: ParseRateLimitHeaders(provider.RateLimitHeaders), }, nil } diff --git a/internal/config/config.go b/internal/config/config.go index 240264d..c094096 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -43,6 +43,7 @@ type Config struct { AdminPasswordDisabled bool CatalogTTL time.Duration + FailoverCooldown time.Duration MaxBodyBytes int64 MaxEmbeddingBatch int PricingFile string @@ -79,6 +80,7 @@ func FromEnv() Config { AdminPasswordFile: envStr("LLMPROXY_ADMIN_PASSWORD_FILE", ".llmproxy/admin-password"), AdminPasswordDisabled: envBool("LLMPROXY_ADMIN_PASSWORD_DISABLED", false), CatalogTTL: envDuration("LLMPROXY_CATALOG_TTL", 5*time.Second), + FailoverCooldown: envDuration("LLMPROXY_FAILOVER_COOLDOWN", 30*time.Second), MaxBodyBytes: envInt64("LLMPROXY_MAX_BODY_BYTES", 10<<20), MaxEmbeddingBatch: envInt("LLMPROXY_MAX_EMBEDDING_BATCH", 2048), PricingFile: envStr("LLMPROXY_PRICING_FILE", ""), diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 1ec94c7..bcda25a 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -55,6 +55,11 @@ func (m *Metrics) ObserveRequest(endpoint, provider, alias, outcome string, dura m.Inc("llmproxy_request_seconds_count", append([][2]string{}, base...), 1) } +// ObserveFailover counts one alias target given up on. reason is "unreachable" or the status code. +func (m *Metrics) ObserveFailover(provider, alias, reason string) { + m.Inc("llmproxy_failover_total", [][2]string{{"provider", provider}, {"model", alias}, {"reason", reason}}, 1) +} + func (m *Metrics) ObserveUnits(provider, alias, unit string, quantity float64, priced bool) { m.Inc("llmproxy_usage_units_total", [][2]string{{"provider", provider}, {"model", alias}, {"unit", unit}}, quantity) diff --git a/internal/server/admin.go b/internal/server/admin.go index c9cd5c7..f9cda26 100644 --- a/internal/server/admin.go +++ b/internal/server/admin.go @@ -436,15 +436,81 @@ func modelView(b *store.ModelBinding, idx *pricing.Index) map[string]any { "pricing": prices, "pricing_inherited": inherited, "hidden": b.Hidden, + "targets": targetViews(b.Targets), + "strategy": nil, } // provider, upstream_name and capabilities are the resolved ones either // way; target says where they came from. if b.TargetAlias != "" { view["target"] = b.TargetAlias } + if b.Strategy != "" { + view["strategy"] = b.Strategy + } return view } +func targetViews(targets []store.BindingTarget) []map[string]any { + out := make([]map[string]any, 0, len(targets)) + for _, t := range targets { + out = append(out, map[string]any{"alias": t.Alias, "provider": t.Provider, "weight": t.Weight}) + } + return out +} + +// targetSpec is one entry of "targets": a model name, or {alias, weight}. +type targetSpec struct { + Alias string `json:"alias"` + Weight int `json:"weight"` +} + +func (t *targetSpec) UnmarshalJSON(data []byte) error { + if len(data) > 0 && data[0] == '"' { + return json.Unmarshal(data, &t.Alias) + } + type plain targetSpec + return json.Unmarshal(data, (*plain)(t)) +} + +// resolveTargets checks every target of an alias and settles its strategy. +func (s *Server) resolveTargets(ctx context.Context, alias string, specs []targetSpec, + strategy string) ([]store.BindingTarget, string, *apierr.ProxyError) { + if strategy != "" && !catalog.IsStrategy(strategy) { + return nil, "", apierr.Newf(400, "invalid_strategy", "strategy must be one of %v", catalog.Strategies) + } + if strategy != "" && len(specs) < 2 { + return nil, "", apierr.New(400, "invalid_strategy", "a strategy needs two or more targets") + } + if len(specs) > 1 && strategy == "" { + strategy = "failover" + } + seen := make(map[string]bool) + out := make([]store.BindingTarget, 0, len(specs)) + for _, spec := range specs { + if seen[spec.Alias] { + return nil, "", apierr.Newf(400, "invalid_target", "'%s' is listed twice", spec.Alias) + } + seen[spec.Alias] = true + if spec.Weight < 0 { + return nil, "", apierr.New(400, "invalid_target", "weight must be 1 or more") + } + target, perr := s.resolveTarget(ctx, alias, spec.Alias) + if perr != nil { + return nil, "", perr + } + out = append(out, store.BindingTarget{ID: target.ID, Alias: target.Alias, Weight: max(spec.Weight, 1)}) + } + return out, strategy, nil +} + +func targetNames(targets []store.BindingTarget) string { + names := make([]string, 0, len(targets)) + for _, t := range targets { + names = append(names, "'"+t.Alias+"'") + } + return strings.Join(names, ", ") +} + // parsePricing validates a per-million price map from a request body. The map // is the model's complete price set: units left out are unpriced afterwards. func parsePricing(prices map[string]*float64) (map[string]float64, *apierr.ProxyError) { @@ -494,10 +560,10 @@ func (s *Server) resolveTarget(ctx context.Context, alias, target string) (*stor if binding == nil { return nil, apierr.Newf(404, "model_not_found", "no model named '%s' to point at", target) } - if binding.TargetID.Valid { + if len(binding.Targets) > 0 { return nil, apierr.Newf(400, "invalid_target", - "'%s' is itself an alias for '%s'; point at that instead (aliases are one hop)", - target, binding.TargetAlias) + "'%s' is itself an alias for %s; point at that instead (aliases are one hop)", + target, targetNames(binding.Targets)) } return binding, nil } @@ -529,6 +595,8 @@ func (s *Server) handleModelCreate(w http.ResponseWriter, r *http.Request, auth Provider string `json:"provider"` UpstreamName string `json:"upstream_name"` Target string `json:"target"` + Targets []targetSpec `json:"targets"` + Strategy string `json:"strategy"` Capabilities []string `json:"capabilities"` Origin string `json:"origin"` Pricing map[string]*float64 `json:"pricing"` @@ -538,12 +606,20 @@ func (s *Server) handleModelCreate(w http.ResponseWriter, r *http.Request, auth writeProxyError(w, perr) return } - // A model points either at a provider's model or at another model. + // A model points either at a provider's model or at other models. alias := body.Alias + specs := body.Targets if body.Target != "" { + if len(specs) > 0 { + writeProxyError(w, apierr.New(400, "invalid_target", "give either 'target' or 'targets', not both")) + return + } + specs = []targetSpec{{Alias: body.Target}} + } + if len(specs) > 0 { if body.Provider != "" || body.UpstreamName != "" { writeProxyError(w, apierr.New(400, "invalid_target", - "give either 'target' or 'provider' and 'upstream_name', not both")) + "give either targets or 'provider' and 'upstream_name', not both")) return } if alias == "" { @@ -551,6 +627,9 @@ func (s *Server) handleModelCreate(w http.ResponseWriter, r *http.Request, auth "an alias for another model needs its own name")) return } + } else if body.Strategy != "" { + writeProxyError(w, apierr.New(400, "invalid_strategy", "a strategy needs two or more targets")) + return } else if body.UpstreamName == "" || len(body.UpstreamName) > 200 { writeProxyError(w, apierr.New(400, "invalid_upstream_name", "upstream_name is required (max 200 chars)")) @@ -586,19 +665,15 @@ func (s *Server) handleModelCreate(w http.ResponseWriter, r *http.Request, auth } binding := &store.ModelBinding{Alias: alias, Origin: body.Origin, Hidden: body.Hidden} - if body.Target != "" { - target, perr := s.resolveTarget(r.Context(), alias, body.Target) + if len(specs) > 0 { + // Provider, upstream name and capabilities all come from the targets. + targets, strategy, perr := s.resolveTargets(r.Context(), alias, specs, body.Strategy) if perr != nil { writeProxyError(w, perr) return } - // Provider, upstream name and capabilities all come from the target. - binding.TargetID = sql.NullString{String: target.ID, Valid: true} - binding.TargetAlias = target.Alias - binding.ProviderID = target.ProviderID - binding.ProviderName = target.ProviderName - binding.UpstreamName = target.UpstreamName - binding.CapabilitySet = target.CapabilitySet + binding.Targets = targets + binding.Strategy = strategy } else { capabilitySet, perr := normalizeCapabilities(body.Capabilities) if perr != nil { @@ -627,6 +702,10 @@ func (s *Server) handleModelCreate(w http.ResponseWriter, r *http.Request, auth internalErr(w, "failed to create binding") return } + if binding, err = s.store.GetBindingByID(r.Context(), binding.ID); err != nil || binding == nil { + internalErr(w, "failed to load binding") + return + } if body.Pricing != nil { sets := map[string]map[string]float64{binding.Alias: prices} if err := s.setModelPricing(r.Context(), binding.Alias, sets, auth.PrincipalID); err != nil { @@ -674,6 +753,8 @@ func (s *Server) handleModelPatch(w http.ResponseWriter, r *http.Request, auth * Capabilities *[]string `json:"capabilities"` UpstreamName *string `json:"upstream_name"` Target *string `json:"target"` + Targets *[]targetSpec `json:"targets"` + Strategy *string `json:"strategy"` Pricing map[string]*float64 `json:"pricing"` Hidden *bool `json:"hidden"` } @@ -691,32 +772,63 @@ func (s *Server) handleModelPatch(w http.ResponseWriter, r *http.Request, auth * return } // Switching between the two kinds is an edit like any other: point the - // model at another model, or give it a provider of its own. + // model at other models, or give it a provider of its own. + specs := body.Targets if body.Target != nil { - if *body.Target == "" { - binding.TargetID = sql.NullString{} - binding.TargetAlias = "" - } else { - target, perr := s.resolveTarget(r.Context(), binding.Alias, *body.Target) - if perr != nil { - writeProxyError(w, perr) - return - } - binding.TargetID = sql.NullString{String: target.ID, Valid: true} - binding.TargetAlias = target.Alias - binding.ProviderID = target.ProviderID - binding.ProviderName = target.ProviderName - binding.UpstreamName = target.UpstreamName - binding.CapabilitySet = target.CapabilitySet + if specs != nil { + writeProxyError(w, apierr.New(400, "invalid_target", "give either 'target' or 'targets', not both")) + return + } + specs = &[]targetSpec{} + if *body.Target != "" { + specs = &[]targetSpec{{Alias: *body.Target}} + } + } + cleared := specs != nil && len(*specs) == 0 + switch { + case cleared: + binding.Targets = nil + binding.TargetID = sql.NullString{} + binding.TargetAlias = "" + binding.Strategy = "" + if body.Strategy != nil && *body.Strategy != "" { + writeProxyError(w, apierr.New(400, "invalid_strategy", "a strategy needs two or more targets")) + return + } + case specs != nil: + strategy := binding.Strategy + if body.Strategy != nil { + strategy = *body.Strategy + } else if len(*specs) < 2 { + strategy = "" + } + targets, strategy, perr := s.resolveTargets(r.Context(), binding.Alias, *specs, strategy) + if perr != nil { + writeProxyError(w, perr) + return + } + binding.Targets = targets + binding.Strategy = strategy + case body.Strategy != nil: + specs := make([]targetSpec, 0, len(binding.Targets)) + for _, t := range binding.Targets { + specs = append(specs, targetSpec{Alias: t.Alias, Weight: t.Weight}) + } + targets, strategy, perr := s.resolveTargets(r.Context(), binding.Alias, specs, *body.Strategy) + if perr != nil { + writeProxyError(w, perr) + return } + binding.Targets = targets + binding.Strategy = strategy } - if binding.TargetID.Valid { + if len(binding.Targets) > 0 { // An alias owns nothing but its name and its price; the rest is the - // target's and would silently do nothing. + // targets' and would silently do nothing. if body.Capabilities != nil || body.UpstreamName != nil || body.Provider != nil { writeProxyError(w, apierr.Newf(400, "invalid_target", - "'%s' is an alias for '%s' and inherits its provider, model and capabilities; "+ - "edit that one, or clear the target first", binding.Alias, binding.TargetAlias)) + "'%s' is an alias for %s and inherits its provider, model and capabilities; "+ + "edit that one, or clear the target first", binding.Alias, targetNames(binding.Targets))) return } } else { @@ -751,7 +863,7 @@ func (s *Server) handleModelPatch(w http.ResponseWriter, r *http.Request, auth * } // Clearing the target leaves a model with no route unless this call // gave it one. - if body.Target != nil && *body.Target == "" && binding.UpstreamName == "" { + if cleared && binding.UpstreamName == "" { writeProxyError(w, apierr.New(400, "invalid_upstream_name", "clearing the target needs 'provider' and 'upstream_name' in the same call")) return @@ -788,6 +900,12 @@ func (s *Server) handleModelPatch(w http.ResponseWriter, r *http.Request, auth * internalErr(w, "failed to update binding") return } + updated, err := s.store.GetBindingByID(r.Context(), binding.ID) + if err != nil || updated == nil { + internalErr(w, "failed to load binding") + return + } + binding = updated renamed := binding.Alias != oldAlias if body.Pricing != nil || renamed { if body.Pricing == nil { @@ -845,22 +963,47 @@ func (s *Server) handleResolve(w http.ResponseWriter, r *http.Request, auth *Aut endpoint = "chat" } stream := r.URL.Query().Get("stream") == "true" - route, perr := s.catalog.Resolve(r.Context(), model, endpoint, stream) + plan, perr := s.catalog.Resolve(r.Context(), model, endpoint, stream) if perr != nil { writeProxyError(w, perr) return } - caps := make([]string, 0, len(route.Capabilities)) - for c := range route.Capabilities { + route := plan.Routes[0] + planCaps := plan.Capabilities() + caps := make([]string, 0, len(planCaps)) + for c := range planCaps { caps = append(caps, c) } sort.Strings(caps) + targets := make([]map[string]any, 0, len(plan.Routes)) + for _, rt := range plan.Routes { + cooling, until := s.balancer.CoolingDown(rt) + t := map[string]any{ + "alias": rt.TargetKey(), + "provider": rt.ProviderName, + "upstream_name": rt.UpstreamName, + "url": rt.EndpointURL(endpoint), + "weight": max(rt.Weight, 1), + "cooling_down": cooling, + "cooldown_until": nil, + } + if cooling { + t["cooldown_until"] = until.UTC().Format(time.RFC3339) + } + targets = append(targets, t) + } + var strategy any + if plan.Strategy != "" { + strategy = plan.Strategy + } writeJSON(w, 200, map[string]any{ "alias": route.Alias, "provider": route.ProviderName, "upstream_name": route.UpstreamName, "url": route.EndpointURL(endpoint), "capabilities": caps, + "strategy": strategy, + "targets": targets, }) } @@ -1163,6 +1306,7 @@ func (s *Server) serveRequestLog(w http.ResponseWriter, r *http.Request) { "status_code": nil, "streamed": ev.Streamed, "cancelled": ev.Cancelled, + "failed_over": ev.FailedOver, "cost": nil, "unpriced": ev.Unpriced, "duration_ms": ev.DurationMs, diff --git a/internal/server/aliastargets_test.go b/internal/server/aliastargets_test.go new file mode 100644 index 0000000..211072a --- /dev/null +++ b/internal/server/aliastargets_test.go @@ -0,0 +1,118 @@ +package server_test + +import ( + "context" + "testing" +) + +func TestAliasWithSeveralTargetsThroughAdminAPI(t *testing.T) { + e := newEnv(t) + a := e.addTarget(t, "pa", e.upstream.srv.URL, "") + b := e.addTarget(t, "pb", e.upstream.srv.URL, "") + + resp, body := e.request(t, "POST", "/admin/v1/models", e.adminKey, map[string]any{ + "alias": "ha", "strategy": "failover", "targets": []any{a.Alias}, + }) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_strategy" { + t.Fatalf("strategy with one target: %d %s", resp.StatusCode, body) + } + resp, body = e.request(t, "POST", "/admin/v1/models", e.adminKey, map[string]any{ + "alias": "ha", "strategy": "fastest", "targets": []any{a.Alias, b.Alias}, + }) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_strategy" { + t.Fatalf("unknown strategy: %d %s", resp.StatusCode, body) + } + resp, body = e.request(t, "POST", "/admin/v1/models", e.adminKey, map[string]any{ + "alias": "ha", "targets": []any{a.Alias, a.Alias}, + }) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_target" { + t.Fatalf("duplicate target: %d %s", resp.StatusCode, body) + } + resp, body = e.request(t, "POST", "/admin/v1/models", e.adminKey, map[string]any{ + "alias": "ha", "target": a.Alias, "targets": []any{b.Alias}, + }) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_target" { + t.Fatalf("target and targets: %d %s", resp.StatusCode, body) + } + + resp, body = e.request(t, "POST", "/admin/v1/models", e.adminKey, map[string]any{ + "alias": "ha", "targets": []any{b.Alias, map[string]any{"alias": a.Alias, "weight": 3}}, + }) + view := decode(t, body) + if resp.StatusCode != 201 || view["strategy"] != "failover" || view["target"] != nil { + t.Fatalf("create: %d %s", resp.StatusCode, body) + } + targets := view["targets"].([]any) + if len(targets) != 2 || targets[0].(map[string]any)["alias"] != b.Alias || + targets[1].(map[string]any)["weight"] != 3.0 || + targets[0].(map[string]any)["provider"] != "pb" || targets[1].(map[string]any)["provider"] != "pa" { + t.Fatalf("targets = %v", targets) + } + if caps := view["capabilities"].([]any); len(caps) != 2 { + t.Fatalf("capabilities = %v", caps) + } + + resp, body = e.request(t, "POST", "/admin/v1/models", e.adminKey, map[string]any{ + "alias": "two-hop", "targets": []any{a.Alias, "ha"}, + }) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_target" { + t.Fatalf("alias as a target: %d %s", resp.StatusCode, body) + } + + resp, body = e.request(t, "PATCH", "/admin/v1/models/ha", e.adminKey, map[string]any{ + "strategy": "weighted", "targets": []any{map[string]any{"alias": a.Alias, "weight": 3}, b.Alias}, + }) + view = decode(t, body) + if resp.StatusCode != 200 || view["strategy"] != "weighted" || + view["targets"].([]any)[0].(map[string]any)["alias"] != a.Alias { + t.Fatalf("reorder: %d %s", resp.StatusCode, body) + } + resp, body = e.request(t, "PATCH", "/admin/v1/models/ha", e.adminKey, map[string]any{"strategy": "round_robin"}) + if resp.StatusCode != 200 || decode(t, body)["strategy"] != "round_robin" { + t.Fatalf("strategy only: %d %s", resp.StatusCode, body) + } + resp, body = e.request(t, "PATCH", "/admin/v1/models/ha", e.adminKey, map[string]any{"upstream_name": "x"}) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_target" { + t.Fatalf("route edit on an alias: %d %s", resp.StatusCode, body) + } + + resp, body = e.request(t, "GET", "/admin/v1/resolve?model=ha", e.adminKey, nil) + view = decode(t, body) + if resp.StatusCode != 200 || view["strategy"] != "round_robin" { + t.Fatalf("resolve: %d %s", resp.StatusCode, body) + } + cands := view["targets"].([]any) + if len(cands) != 2 || cands[0].(map[string]any)["provider"] != "pa" || + cands[0].(map[string]any)["cooling_down"] != false { + t.Fatalf("resolve targets = %v", cands) + } + + resp, body = e.request(t, "PATCH", "/admin/v1/models/ha", e.adminKey, map[string]any{"targets": []any{b.Alias}}) + view = decode(t, body) + if resp.StatusCode != 200 || view["strategy"] != nil || view["target"] != b.Alias || view["provider"] != "pb" { + t.Fatalf("back to one target: %d %s", resp.StatusCode, body) + } + resp, body = e.request(t, "PATCH", "/admin/v1/models/ha", e.adminKey, map[string]any{"strategy": "failover"}) + if resp.StatusCode != 400 || errorCode(t, body) != "invalid_strategy" { + t.Fatalf("strategy on one target: %d %s", resp.StatusCode, body) + } + + resp, body = e.request(t, "PATCH", "/admin/v1/models/ha", e.adminKey, map[string]any{"target": a.Alias}) + if resp.StatusCode != 200 || decode(t, body)["target"] != a.Alias { + t.Fatalf("legacy target: %d %s", resp.StatusCode, body) + } + + events, err := e.st.ListAdminEvents(context.Background(), 50, 0) + if err != nil { + t.Fatal(err) + } + updates := 0 + for _, ev := range events { + if ev.Action == "model.update" && ev.TargetRef == "ha" { + updates++ + } + } + if updates != 4 { + t.Fatalf("model.update events for ha = %d, want 4", updates) + } +} diff --git a/internal/server/failover_test.go b/internal/server/failover_test.go new file mode 100644 index 0000000..5cc34b8 --- /dev/null +++ b/internal/server/failover_test.go @@ -0,0 +1,315 @@ +package server_test + +import ( + "context" + "database/sql" + "fmt" + "io" + "net/http" + "net/http/httptest" + "strings" + "sync" + "testing" + "time" + + "github.com/greyhavenhq/llmproxy/internal/secrets" + "github.com/greyhavenhq/llmproxy/internal/store" +) + +type scriptedUpstream struct { + srv *httptest.Server + mu sync.Mutex + auth []string +} + +func newScripted(t *testing.T, handler http.HandlerFunc) *scriptedUpstream { + t.Helper() + u := &scriptedUpstream{} + u.srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + u.mu.Lock() + u.auth = append(u.auth, r.Header.Get("Authorization")) + u.mu.Unlock() + handler(w, r) + })) + t.Cleanup(u.srv.Close) + return u +} + +func (u *scriptedUpstream) calls() []string { + u.mu.Lock() + defer u.mu.Unlock() + return append([]string(nil), u.auth...) +} + +func statusHandler(status int, body string, headers map[string]string) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + _, _ = io.Copy(io.Discard, r.Body) + for k, v := range headers { + w.Header().Set(k, v) + } + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(status) + fmt.Fprint(w, body) + } +} + +func (e *env) upstreamCalls() int { + e.upstream.mu.Lock() + defer e.upstream.mu.Unlock() + return len(e.upstream.requests) +} + +// addTarget creates a provider at baseURL with one direct model on it. +func (e *env) addTarget(t *testing.T, name, baseURL, rateLimitHeaders string) *store.ModelBinding { + t.Helper() + ctx := context.Background() + encrypted, err := secrets.EncryptCredential(e.secret, upstreamKey) + if err != nil { + t.Fatal(err) + } + p := &store.Provider{Name: name, WireFormat: "openai", BaseURL: baseURL, + CredentialCiphertext: sql.NullString{String: encrypted, Valid: true}, + VerifyTLS: true, TimeoutConnect: 5, TimeoutRead: 30, Enabled: true, + RateLimitHeaders: rateLimitHeaders} + if err := e.st.CreateProvider(ctx, p, nil, nil); err != nil { + t.Fatal(err) + } + b := &store.ModelBinding{Alias: name + "-m", ProviderID: p.ID, UpstreamName: "up-" + name, + CapabilitySet: "chat,chat_stream", Origin: "declared"} + if err := e.st.CreateBinding(ctx, b, nil); err != nil { + t.Fatal(err) + } + return b +} + +func (e *env) addHA(t *testing.T, targets ...*store.ModelBinding) { + t.Helper() + ctx := context.Background() + alpha, err := e.st.GetBindingByAlias(ctx, "alpha") + if err != nil { + t.Fatal(err) + } + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", Strategy: "failover"} + for _, b := range append(targets, alpha) { + ha.Targets = append(ha.Targets, store.BindingTarget{ID: b.ID}) + } + if err := e.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } +} + +func haChat(stream bool, content string) map[string]any { + return map[string]any{"model": "ha", "stream": stream, + "messages": []any{map[string]any{"role": "user", "content": content}}} +} + +func TestFailoverOnRefusedConnection(t *testing.T) { + e := newEnv(t) + dead := httptest.NewServer(http.NotFoundHandler()) + deadURL := dead.URL + dead.Close() + e.addHA(t, e.addTarget(t, "dead", deadURL+"/v1", "")) + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, haChat(false, "hi")) + if resp.StatusCode != 200 { + t.Fatalf("chat: %d %s", resp.StatusCode, body) + } + if resp.Header.Get("x-llmproxy-provider") != "fake" || resp.Header.Get("x-llmproxy-model") != "m-alpha" || + resp.Header.Get("x-llmproxy-attempts") != "2" { + t.Fatalf("headers: %v", resp.Header) + } + e.waitUsage(t, func(ev store.UsageEvent) bool { + return ev.Alias == "ha" && ev.FailedOver && ev.Outcome == "unreachable" && ev.ErrorKind == "connection_error" + }) + e.waitUsage(t, func(ev store.UsageEvent) bool { return ev.Alias == "ha" && !ev.FailedOver && ev.Outcome == "ok" }) + + mresp, err := http.Get(e.proxy.URL + "/metrics") + if err != nil { + t.Fatal(err) + } + metrics, _ := io.ReadAll(mresp.Body) + mresp.Body.Close() + if !strings.Contains(string(metrics), `llmproxy_failover_total{model="ha",provider="dead",reason="unreachable"} 1`) { + t.Fatalf("failover metric missing:\n%s", metrics) + } + + _, logBody := e.request(t, "GET", "/stats/requests?model=ha", e.adminKey, nil) + flags := map[string]bool{} + for _, row := range decode(t, logBody)["requests"].([]any) { + entry := row.(map[string]any) + flags[entry["outcome"].(string)] = entry["failed_over"] == true + } + if !flags["unreachable"] || flags["ok"] { + t.Fatalf("failed_over flags in the request log: %v %s", flags, logBody) + } + + if resp, body := e.request(t, "POST", "/admin/v1/models", e.adminKey, + map[string]any{"alias": "one", "target": "alpha"}); resp.StatusCode != 201 { + t.Fatalf("create one: %d %s", resp.StatusCode, body) + } + _, modelsBody := e.request(t, "GET", "/v1/models", e.memberKey, nil) + for _, m := range decode(t, modelsBody)["data"].([]any) { + entry := m.(map[string]any) + switch entry["id"] { + case "ha": + targets, _ := entry["targets"].([]any) + if entry["strategy"] != "failover" || len(targets) != 2 || targets[0] != "dead-m" || targets[1] != "alpha" { + t.Fatalf("ha in /v1/models: %v", entry) + } + case "one": + if entry["alias_of"] != "alpha" || entry["targets"] != nil || entry["strategy"] != nil { + t.Fatalf("one in /v1/models: %v", entry) + } + } + } +} + +func TestFailoverOnRetryableStatus(t *testing.T) { + for _, status := range []int{429, 503} { + t.Run(fmt.Sprint(status), func(t *testing.T) { + e := newEnv(t) + failing := newScripted(t, statusHandler(status, `{"error":{"message":"busy","type":"overloaded"}}`, + map[string]string{"x-ratelimit-remaining-requests": "5"})) + e.addHA(t, e.addTarget(t, "flaky", failing.srv.URL+"/v1", + "remaining_requests:x-ratelimit-remaining-requests")) + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, haChat(false, "hi")) + if resp.StatusCode != 200 || resp.Header.Get("x-llmproxy-attempts") != "2" { + t.Fatalf("chat: %d %v %s", resp.StatusCode, resp.Header, body) + } + if got := resp.Header.Get("x-llmproxy-ratelimit-requests-remaining"); got != "" { + t.Fatalf("rate-limit header leaked from failed attempt: %q", got) + } + if calls := failing.calls(); len(calls) != 1 || calls[0] != "Bearer "+upstreamKey { + t.Fatalf("failed attempt credential: %v", calls) + } + if e.upstream.last(t).Header.Get("Authorization") != "Bearer "+upstreamKey { + t.Fatal("second attempt credential missing") + } + e.waitUsage(t, func(ev store.UsageEvent) bool { + return ev.FailedOver && ev.Outcome == "upstream_error" && ev.StatusCode.Int64 == int64(status) && + ev.ErrorKind == "overloaded" + }) + }) + } +} + +func TestNoFailoverOnClientError(t *testing.T) { + e := newEnv(t) + bad := newScripted(t, statusHandler(400, `{"error":{"message":"bad","type":"invalid_request_error"}}`, nil)) + e.addHA(t, e.addTarget(t, "bad", bad.srv.URL+"/v1", "")) + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, haChat(false, "hi")) + if resp.StatusCode != 400 || resp.Header.Get("x-llmproxy-attempts") != "1" { + t.Fatalf("chat: %d %v %s", resp.StatusCode, resp.Header, body) + } + if n := e.upstreamCalls(); n != 0 { + t.Fatalf("second target called %d times", n) + } +} + +func TestLastTargetResponsePassesThrough(t *testing.T) { + e := newEnv(t) + first := newScripted(t, statusHandler(503, `{"error":{"message":"first"}}`, nil)) + second := newScripted(t, statusHandler(503, `{"error":{"message":"second"}}`, nil)) + ctx := context.Background() + a, b := e.addTarget(t, "first", first.srv.URL+"/v1", ""), e.addTarget(t, "second", second.srv.URL+"/v1", "") + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", Strategy: "failover", + Targets: []store.BindingTarget{{ID: a.ID}, {ID: b.ID}}} + if err := e.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, haChat(false, "hi")) + if resp.StatusCode != 503 || !strings.Contains(string(body), "second") { + t.Fatalf("chat: %d %s", resp.StatusCode, body) + } + if resp.Header.Get("x-llmproxy-attempts") != "2" || resp.Header.Get("x-llmproxy-provider") != "second" { + t.Fatalf("headers: %v", resp.Header) + } +} + +func TestStreamFailoverBeforeFirstByte(t *testing.T) { + e := newEnv(t) + failing := newScripted(t, statusHandler(503, `{"error":{"message":"busy"}}`, nil)) + e.addHA(t, e.addTarget(t, "flaky", failing.srv.URL+"/v1", "")) + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, haChat(true, "hi")) + if resp.StatusCode != 200 || !strings.Contains(string(body), "word2") { + t.Fatalf("stream: %d %s", resp.StatusCode, body) + } + if calls := failing.calls(); len(calls) != 1 || calls[0] != "Bearer "+upstreamKey { + t.Fatalf("failed attempt credential: %v", calls) + } + if e.upstream.last(t).Header.Get("Authorization") != "Bearer "+upstreamKey { + t.Fatal("second attempt credential missing") + } + e.waitUsage(t, func(ev store.UsageEvent) bool { return ev.Alias == "ha" && ev.Streamed && ev.Outcome == "ok" }) +} + +func TestNoFailoverAfterFirstStreamByte(t *testing.T) { + e := newEnv(t) + breaking := newScripted(t, func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/event-stream") + w.WriteHeader(200) + _, _ = w.Write(sseChunk("up-breaking", map[string]any{"content": "partial"}, nil, nil, false)) + w.(http.Flusher).Flush() + panic(http.ErrAbortHandler) + }) + e.addHA(t, e.addTarget(t, "breaking", breaking.srv.URL+"/v1", "")) + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, haChat(true, "hi")) + if resp.StatusCode != 200 || !strings.Contains(string(body), "partial") { + t.Fatalf("stream: %d %s", resp.StatusCode, body) + } + if resp.Header.Get("x-llmproxy-attempts") != "1" { + t.Fatalf("attempts: %q", resp.Header.Get("x-llmproxy-attempts")) + } + if n := e.upstreamCalls(); n != 0 { + t.Fatalf("second target called %d times after the first byte", n) + } +} + +func TestClientCancelStopsFailover(t *testing.T) { + e := newEnv(t) + hanging := newScripted(t, func(w http.ResponseWriter, r *http.Request) { + _, _ = io.Copy(io.Discard, r.Body) + <-r.Context().Done() + }) + e.addHA(t, e.addTarget(t, "hanging", hanging.srv.URL+"/v1", "")) + + ctx, cancel := context.WithTimeout(context.Background(), 300*time.Millisecond) + defer cancel() + req, _ := http.NewRequestWithContext(ctx, "POST", e.proxy.URL+"/v1/chat/completions", + strings.NewReader(`{"model":"ha","messages":[{"role":"user","content":"hi"}]}`)) + req.Header.Set("Authorization", "Bearer "+e.memberKey) + if resp, err := http.DefaultClient.Do(req); err == nil { + resp.Body.Close() + t.Fatal("expected the client to time out") + } + e.waitUsage(t, func(ev store.UsageEvent) bool { return ev.Alias == "ha" && ev.Cancelled }) + time.Sleep(200 * time.Millisecond) + if n := e.upstreamCalls(); n != 0 { + t.Fatalf("second target called %d times after cancel", n) + } +} + +func TestFailoverMarkerNeverReachesDisk(t *testing.T) { + e := newEnv(t) + echo := newScripted(t, func(w http.ResponseWriter, r *http.Request) { + raw, _ := io.ReadAll(r.Body) + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(503) + fmt.Fprintf(w, `{"error":{"message":%q,"type":%q}}`, raw, raw) + }) + e.addHA(t, e.addTarget(t, "echo", echo.srv.URL+"/v1", "")) + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, + haChat(false, "SECRETMARKER-failover content")) + if resp.StatusCode != 200 { + t.Fatalf("chat: %d %s", resp.StatusCode, body) + } + e.waitUsage(t, func(ev store.UsageEvent) bool { return ev.FailedOver }) + e.waitUsage(t, func(ev store.UsageEvent) bool { return ev.Alias == "ha" && ev.Outcome == "ok" }) + assertNoMarkerOnDisk(t, e) +} diff --git a/internal/server/litellm.go b/internal/server/litellm.go index 57a35ca..6e7f219 100644 --- a/internal/server/litellm.go +++ b/internal/server/litellm.go @@ -1,7 +1,9 @@ package server import ( + "context" "database/sql" + "math" "net/http" "net/url" "regexp" @@ -19,10 +21,10 @@ import ( // The mapping: a LiteLLM "deployment" (model_name + litellm_params) becomes a // provider (api_base + api_key, reused across deployments with the same // api_base) plus a model binding (model_name as the alias, litellm_params -// .model as the upstream name). One deliberate divergence: aliases are -// globally unique, so re-registering the same mapping is an idempotent -// success but a second different deployment under one model_name (LiteLLM's -// load balancing) is rejected with 409. +// .model as the upstream name). Re-registering the same mapping is an +// idempotent success. A second deployment under one model_name becomes a +// hidden "@" model, and model_name an alias over all +// of them with the weighted strategy. var providerNameStrip = regexp.MustCompile(`[^a-z0-9._-]+`) var providerNameLead = regexp.MustCompile(`^[^a-z0-9]+`) @@ -108,9 +110,9 @@ func (s *Server) ensureProviderFor(w http.ResponseWriter, r *http.Request, auth return p } -func litellmDeploymentView(b *store.ModelBinding, apiBase string) map[string]any { +func litellmDeploymentView(modelName string, b *store.ModelBinding, apiBase string) map[string]any { return map[string]any{ - "model_name": b.Alias, + "model_name": modelName, "litellm_params": map[string]any{ "model": b.UpstreamName, "api_base": apiBase, @@ -120,6 +122,24 @@ func litellmDeploymentView(b *store.ModelBinding, apiBase string) map[string]any } } +// isDeployment reports whether target was created for a deployment of alias. +func isDeployment(alias string, target *store.ModelBinding) bool { + return target.Hidden && strings.HasPrefix(target.Alias, alias+"@") +} + +// deploymentName picks a free "@" name. +func (s *Server) deploymentName(ctx context.Context, modelName, providerName string) (string, error) { + base := modelName + "@" + providerName + name := base + for i := 2; ; i++ { + taken, err := s.store.GetBindingByAlias(ctx, name) + if err != nil || taken == nil { + return name, err + } + name = base + "-" + strconv.Itoa(i) + } +} + // capabilitiesForMode maps LiteLLM's model_info.mode to a capability set. func capabilitiesForMode(mode string) string { switch mode { @@ -136,9 +156,10 @@ func (s *Server) handleLiteLLMModelNew(w http.ResponseWriter, r *http.Request, a var body struct { ModelName string `json:"model_name"` LiteLLMParams struct { - Model string `json:"model"` - APIBase string `json:"api_base"` - APIKey string `json:"api_key"` + Model string `json:"model"` + APIBase string `json:"api_base"` + APIKey string `json:"api_key"` + Weight float64 `json:"weight"` } `json:"litellm_params"` ModelInfo map[string]any `json:"model_info"` } @@ -172,15 +193,23 @@ func (s *Server) handleLiteLLMModelNew(w http.ResponseWriter, r *http.Request, a internalErr(w, "failed to check alias") return } - if existing != nil { - if existing.ProviderID == provider.ID && existing.UpstreamName == body.LiteLLMParams.Model { - writeJSON(w, 200, litellmDeploymentView(existing, provider.BaseURL)) + matches := func(b *store.ModelBinding) bool { + return b.ProviderID == provider.ID && b.UpstreamName == body.LiteLLMParams.Model + } + if existing != nil && len(existing.Targets) == 0 && matches(existing) { + writeJSON(w, 200, litellmDeploymentView(existing.Alias, existing, provider.BaseURL)) + return + } + for _, t := range targetsOf(existing) { + target, err := s.store.GetBindingByID(r.Context(), t.ID) + if err != nil { + internalErr(w, "failed to load target") + return + } + if target != nil && matches(target) { + writeJSON(w, 200, litellmDeploymentView(existing.Alias, target, provider.BaseURL)) return } - writeProxyError(w, apierr.Newf(409, "alias_exists", - "model_name '%s' is already bound to a different deployment; aliases are globally unique", - body.ModelName)) - return } mode, _ := body.ModelInfo["mode"].(string) @@ -192,13 +221,80 @@ func (s *Server) handleLiteLLMModelNew(w http.ResponseWriter, r *http.Request, a Origin: "declared", ProviderName: provider.Name, } + if existing != nil { + name, err := s.deploymentName(r.Context(), body.ModelName, provider.Name) + if err != nil { + internalErr(w, "failed to check alias") + return + } + binding.Alias = name + binding.Hidden = true + } audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.create", TargetKind: "model", TargetRef: binding.Alias} if err := s.store.CreateBinding(r.Context(), binding, audit); err != nil { internalErr(w, "failed to create binding") return } + if existing != nil { + weight := max(int(math.Round(body.LiteLLMParams.Weight)), 1) + if perr := s.addDeployment(r.Context(), auth, existing, binding, weight); perr != nil { + s.invalidate() + writeProxyError(w, perr) + return + } + } s.invalidate() - writeJSON(w, 200, litellmDeploymentView(binding, provider.BaseURL)) + writeJSON(w, 200, litellmDeploymentView(body.ModelName, binding, provider.BaseURL)) +} + +func targetsOf(b *store.ModelBinding) []store.BindingTarget { + if b == nil { + return nil + } + return b.Targets +} + +// addDeployment makes deployment one more target of existing. A direct model +// keeps its id: it moves to a hidden deployment name, and a new alias takes +// its place. +func (s *Server) addDeployment(ctx context.Context, auth *Auth, existing, deployment *store.ModelBinding, + weight int) *apierr.ProxyError { + alias := existing + if len(existing.Targets) == 0 { + name, err := s.deploymentName(ctx, existing.Alias, existing.ProviderName) + if err != nil { + return apierr.New(500, "internal_error", "failed to check alias") + } + moved := *existing + moved.Alias = name + moved.Hidden = true + audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.update", TargetKind: "model", TargetRef: name} + if err := s.store.UpdateBinding(ctx, &moved, audit); err != nil { + return apierr.New(500, "internal_error", "failed to update binding") + } + alias = &store.ModelBinding{ + Alias: existing.Alias, + Origin: existing.Origin, + Hidden: existing.Hidden, + Targets: []store.BindingTarget{{ID: moved.ID, Alias: name, Weight: 1}}, + } + } + alias.Targets = append(alias.Targets, store.BindingTarget{ID: deployment.ID, Alias: deployment.Alias, Weight: weight}) + if alias.Strategy == "" { + alias.Strategy = "weighted" + } + audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.update", TargetKind: "model", TargetRef: alias.Alias} + if alias.ID == "" { + audit.Action = "model.create" + if err := s.store.CreateBinding(ctx, alias, audit); err != nil { + return apierr.New(500, "internal_error", "failed to create binding") + } + return nil + } + if err := s.store.UpdateBinding(ctx, alias, audit); err != nil { + return apierr.New(500, "internal_error", "failed to update binding") + } + return nil } func (s *Server) handleLiteLLMModelInfo(w http.ResponseWriter, r *http.Request, auth *Auth) { @@ -216,9 +312,37 @@ func (s *Server) handleLiteLLMModelInfo(w http.ResponseWriter, r *http.Request, for _, p := range providers { baseByID[p.ID] = p.BaseURL } + byID := make(map[string]*store.ModelBinding, len(bindings)) + for i := range bindings { + byID[bindings[i].ID] = &bindings[i] + } + // A deployment target is listed under its alias, not on its own. + listed := make(map[string]bool) + for _, b := range bindings { + if b.Strategy == "" { + continue + } + for _, t := range b.Targets { + if target := byID[t.ID]; target != nil && isDeployment(b.Alias, target) { + listed[t.ID] = true + } + } + } data := make([]map[string]any, 0, len(bindings)) for i := range bindings { - data = append(data, litellmDeploymentView(&bindings[i], baseByID[bindings[i].ProviderID])) + b := &bindings[i] + if listed[b.ID] { + continue + } + if b.Strategy == "" { + data = append(data, litellmDeploymentView(b.Alias, b, baseByID[b.ProviderID])) + continue + } + for _, t := range b.Targets { + if target := byID[t.ID]; target != nil { + data = append(data, litellmDeploymentView(b.Alias, target, baseByID[target.ProviderID])) + } + } } writeJSON(w, 200, map[string]any{"data": data}) } @@ -240,11 +364,111 @@ func (s *Server) handleLiteLLMModelDelete(w http.ResponseWriter, r *http.Request writeProxyError(w, apierr.Newf(404, "model_not_found", "no deployment with id '%s'", body.ID)) return } - audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.delete", TargetKind: "model", TargetRef: binding.Alias} - if err := s.store.DeleteBinding(r.Context(), binding.ID, audit); err != nil { - internalErr(w, "failed to delete binding") + modelName, perr := s.deleteDeployment(r.Context(), auth, binding) + s.invalidate() + if perr != nil { + writeProxyError(w, perr) return } - s.invalidate() - writeJSON(w, 200, map[string]any{"deleted": body.ID, "model_name": binding.Alias}) + writeJSON(w, 200, map[string]any{"deleted": body.ID, "model_name": modelName}) +} + +// deleteDeployment removes a model and returns the model_name it served +// under. A target of several-target aliases leaves them first. An alias +// with one deployment left becomes that model again. +func (s *Server) deleteDeployment(ctx context.Context, auth *Auth, binding *store.ModelBinding) (string, *apierr.ProxyError) { + internal := func(msg string) (string, *apierr.ProxyError) { + return "", apierr.New(500, "internal_error", msg) + } + names, err := s.store.ListBindingsTargeting(ctx, binding.ID) + if err != nil { + return internal("failed to check aliases") + } + var aliases []*store.ModelBinding + for _, name := range names { + alias, err := s.store.GetBindingByAlias(ctx, name) + if err != nil || alias == nil { + return internal("failed to load alias") + } + if alias.Strategy == "" { + return "", apierr.Newf(409, "model_in_use", + "'%s' is the target of '%s'; delete or repoint that first", binding.Alias, name) + } + aliases = append(aliases, alias) + } + + modelName := binding.Alias + for _, alias := range aliases { + if isDeployment(alias.Alias, binding) { + modelName = alias.Alias + } + kept := alias.Targets[:0] + for _, t := range alias.Targets { + if t.ID != binding.ID { + kept = append(kept, t) + } + } + alias.Targets = kept + audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.update", TargetKind: "model", TargetRef: alias.Alias} + if err := s.store.UpdateBinding(ctx, alias, audit); err != nil { + return internal("failed to update alias") + } + } + + // Deleting a several-target alias takes its deployments with it. + var deployments []*store.ModelBinding + for _, t := range binding.Targets { + target, err := s.store.GetBindingByID(ctx, t.ID) + if err != nil { + return internal("failed to load target") + } + if target != nil && binding.Strategy != "" && isDeployment(binding.Alias, target) { + deployments = append(deployments, target) + } + } + audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.delete", TargetKind: "model", TargetRef: binding.Alias} + if err := s.store.DeleteBinding(ctx, binding.ID, audit); err != nil { + return internal("failed to delete binding") + } + for _, d := range deployments { + if _, perr := s.deleteDeployment(ctx, auth, d); perr != nil { + return "", perr + } + } + + for _, alias := range aliases { + if perr := s.collapseAlias(ctx, auth, alias); perr != nil { + return "", perr + } + } + return modelName, nil +} + +// collapseAlias turns an alias with one deployment left back into that model. +func (s *Server) collapseAlias(ctx context.Context, auth *Auth, alias *store.ModelBinding) *apierr.ProxyError { + if len(alias.Targets) != 1 { + return nil + } + last, err := s.store.GetBindingByID(ctx, alias.Targets[0].ID) + if err != nil { + return apierr.New(500, "internal_error", "failed to load target") + } + if last == nil || !isDeployment(alias.Alias, last) { + return nil + } + names, err := s.store.ListBindingsTargeting(ctx, last.ID) + if err != nil || len(names) != 1 { + return nil + } + audit := &store.Audit{Actor: auth.PrincipalID, Action: "model.delete", TargetKind: "model", TargetRef: alias.Alias} + if err := s.store.DeleteBinding(ctx, alias.ID, audit); err != nil { + return apierr.New(500, "internal_error", "failed to delete binding") + } + last.Alias = alias.Alias + last.Hidden = alias.Hidden + audit = &store.Audit{Actor: auth.PrincipalID, Action: "model.update", TargetKind: "model", TargetRef: last.Alias} + if err := s.store.UpdateBinding(ctx, last, audit); err != nil { + return apierr.New(500, "internal_error", "failed to update binding") + } + return nil } diff --git a/internal/server/litellm_test.go b/internal/server/litellm_test.go index b69abb3..84bd383 100644 --- a/internal/server/litellm_test.go +++ b/internal/server/litellm_test.go @@ -44,20 +44,6 @@ func TestLiteLLMManagementCompat(t *testing.T) { t.Fatalf("re-register: %d %s", resp.StatusCode, body) } - // A different mapping under the same model_name is rejected (aliases are - // unique; llmproxy does not do LiteLLM-style multi-deployment balancing). - conflicting := map[string]any{ - "model_name": "acme/zdr-kimi", - "litellm_params": map[string]any{ - "model": "some-other-model", - "api_base": e.upstream.srv.URL + "/v1", - }, - } - resp, body = e.request(t, "POST", "/model/new", e.adminKey, conflicting) - if resp.StatusCode != 409 || errorCode(t, body) != "alias_exists" { - t.Fatalf("conflicting deployment: %d %s", resp.StatusCode, body) - } - // A deployment on an already-known api_base reuses that provider (the // seeded "fake" provider points at the same upstream). _, body = e.request(t, "GET", "/admin/v1/providers", e.adminKey, nil) @@ -161,3 +147,117 @@ func TestRootOpenAIAliases(t *testing.T) { t.Fatalf("POST /embeddings: %d %s", resp.StatusCode, body) } } + +// A second deployment under one model_name becomes another target of that alias. +func TestLiteLLMDeploymentsShareModelName(t *testing.T) { + e := newEnv(t) + other := strings.Replace(e.upstream.srv.URL, "127.0.0.1", "localhost", 1) + deploy := func(model, base string, weight int) (int, map[string]any) { + t.Helper() + params := map[string]any{"model": model, "api_base": base, "api_key": upstreamKey} + if weight > 0 { + params["weight"] = weight + } + resp, body := e.request(t, "POST", "/model/new", e.adminKey, map[string]any{ + "model_name": "shared", "litellm_params": params, + }) + return resp.StatusCode, decode(t, body) + } + idOf := func(view map[string]any) string { + info, _ := view["model_info"].(map[string]any) + id, _ := info["id"].(string) + return id + } + resolve := func() map[string]any { + t.Helper() + resp, body := e.request(t, "GET", "/admin/v1/resolve?model=shared", e.adminKey, nil) + if resp.StatusCode != 200 { + t.Fatalf("resolve: %d %s", resp.StatusCode, body) + } + return decode(t, body) + } + listing := func() []map[string]any { + t.Helper() + _, body := e.request(t, "GET", "/model/info", e.adminKey, nil) + var out []map[string]any + for _, d := range decode(t, body)["data"].([]any) { + dep := d.(map[string]any) + if strings.Contains(dep["model_name"].(string), "@") { + t.Fatalf("a target created for a deployment is listed on its own: %v", dep) + } + if dep["model_name"] == "shared" { + out = append(out, dep) + } + } + return out + } + + code, first := deploy("m1", e.upstream.srv.URL+"/v1", 0) + if code != 200 { + t.Fatalf("first deployment: %d %v", code, first) + } + code, second := deploy("m2", other+"/v1", 3) + if code != 200 || second["model_name"] != "shared" || idOf(second) == "" || idOf(second) == idOf(first) { + t.Fatalf("second deployment: %d %v", code, second) + } + if code, again := deploy("m2", other+"/v1", 3); code != 200 || idOf(again) != idOf(second) { + t.Fatalf("re-register second: %d %v", code, again) + } + code, firstAgain := deploy("m1", e.upstream.srv.URL+"/v1", 0) + if code != 200 { + t.Fatalf("re-register first: %d %v", code, firstAgain) + } + + plan := resolve() + targets, _ := plan["targets"].([]any) + if plan["strategy"] != "weighted" || len(targets) != 2 { + t.Fatalf("plan after two deployments: %v", plan) + } + if w := targets[1].(map[string]any)["weight"]; w != float64(3) { + t.Fatalf("weight from litellm_params: %v", w) + } + + deps := listing() + if len(deps) != 2 { + t.Fatalf("/model/info deployments: %v", deps) + } + models := map[string]string{} + for _, d := range deps { + models[d["litellm_params"].(map[string]any)["model"].(string)] = idOf(d) + } + if models["m2"] != idOf(second) || models["m1"] == "" || models["m1"] != idOf(firstAgain) { + t.Fatalf("/model/info ids: %v", models) + } + + resp, body := e.request(t, "POST", "/v1/chat/completions", e.memberKey, map[string]any{ + "model": "shared", "messages": []map[string]any{{"role": "user", "content": "hi"}}, + }) + if resp.StatusCode != 200 { + t.Fatalf("chat through shared: %d %s", resp.StatusCode, body) + } + + resp, body = e.request(t, "POST", "/model/delete", e.adminKey, map[string]any{"id": idOf(second)}) + if resp.StatusCode != 200 || decode(t, body)["model_name"] != "shared" { + t.Fatalf("delete one deployment: %d %s", resp.StatusCode, body) + } + plan = resolve() + if plan["strategy"] != nil || plan["upstream_name"] != "m1" { + t.Fatalf("plan after delete: %v", plan) + } + deps = listing() + if len(deps) != 1 || deps[0]["litellm_params"].(map[string]any)["model"] != "m1" { + t.Fatalf("/model/info after delete: %v", deps) + } + + resp, body = e.request(t, "POST", "/model/delete", e.adminKey, map[string]any{"id": idOf(deps[0])}) + if resp.StatusCode != 200 { + t.Fatalf("delete last deployment: %d %s", resp.StatusCode, body) + } + if deps = listing(); len(deps) != 0 { + t.Fatalf("/model/info after deleting all: %v", deps) + } + _, body = e.request(t, "GET", "/admin/v1/models", e.adminKey, nil) + if strings.Contains(string(body), "shared") { + t.Fatalf("models left behind: %s", body) + } +} diff --git a/internal/server/openai.go b/internal/server/openai.go index 8cfe90b..9967ba6 100644 --- a/internal/server/openai.go +++ b/internal/server/openai.go @@ -8,6 +8,7 @@ import ( "errors" "io" "net/http" + "strconv" "strings" "time" @@ -57,10 +58,17 @@ func (s *Server) handleListModels(w http.ResponseWriter, r *http.Request) { // capabilities and alias_of are extensions to the OpenAI shape: // curated catalog metadata, no credentials, ignored by clients that // only read id. - var aliasOf any + var aliasOf, targets, strategy any if b.TargetAlias != "" { aliasOf = b.TargetAlias } + if len(b.Targets) > 1 { + names := make([]string, 0, len(b.Targets)) + for _, t := range b.Targets { + names = append(names, t.Alias) + } + targets, strategy = names, b.Strategy + } entry := map[string]any{ "id": b.Alias, "object": "model", @@ -68,6 +76,8 @@ func (s *Server) handleListModels(w http.ResponseWriter, r *http.Request) { "owned_by": b.ProviderName, "capabilities": splitCapabilitySet(b.CapabilitySet), "alias_of": aliasOf, + "targets": targets, + "strategy": strategy, "hidden": b.Hidden, } // Prices are what the proxy bills this model at, per million units, so @@ -142,13 +152,11 @@ func (s *Server) proxyCompletion(w http.ResponseWriter, r *http.Request, auth *A return } - route, rerr := s.catalog.Resolve(r.Context(), model, endpoint, stream) + plan, rerr := s.catalog.Resolve(r.Context(), model, endpoint, stream) if rerr != nil { writeProxyError(w, rerr) return } - - fields["model"], _ = json.Marshal(route.UpstreamName) if stream { var opts map[string]any if raw, ok := fields["stream_options"]; ok { @@ -160,10 +168,26 @@ func (s *Server) proxyCompletion(w http.ResponseWriter, r *http.Request, auth *A opts["include_usage"] = true fields["stream_options"], _ = json.Marshal(opts) } + routes := s.balancer.Order(plan) + for i, route := range routes { + if s.attempt(w, r, auth, endpoint, fields, stream, route, i+1, i == len(routes)-1) { + return + } + } +} + +// failoverBodyBytes bounds what is read from a failed attempt to classify its error. +const failoverBodyBytes = 64 << 10 + +// attempt sends the request to one alias target. It returns false when the +// caller must try the next target, which only happens before any byte is written. +func (s *Server) attempt(w http.ResponseWriter, r *http.Request, auth *Auth, endpoint string, + fields map[string]json.RawMessage, stream bool, route *catalog.Route, n int, last bool) bool { + fields["model"], _ = json.Marshal(route.UpstreamName) outBody, err := json.Marshal(fields) if err != nil { writeProxyError(w, apierr.New(400, "invalid_json", "request body could not be re-encoded")) - return + return true } reqCtx := r.Context() @@ -176,7 +200,7 @@ func (s *Server) proxyCompletion(w http.ResponseWriter, r *http.Request, auth *A route.EndpointURL(endpoint), bytes.NewReader(outBody)) if err != nil { writeProxyError(w, apierr.New(500, "internal_error", "failed to build upstream request")) - return + return true } req.Header.Set("Content-Type", "application/json") req.Header.Set("Accept", "application/json, text/event-stream") @@ -184,34 +208,64 @@ func (s *Server) proxyCompletion(w http.ResponseWriter, r *http.Request, auth *A req.Header.Set("Authorization", "Bearer "+route.Credential) } + defer s.balancer.Acquire(route)() + w.Header().Set("x-llmproxy-attempts", strconv.Itoa(n)) started := time.Now() resp, err := s.pool.ClientFor(route).Do(req) if err != nil { // A caller that hung up before the upstream answered is a // cancellation, not a provider failure. - outcome, cancelled, kind := "unreachable", false, errClass(err) if r.Context().Err() != nil { - outcome, cancelled, kind = "cancelled", true, "" + s.recordUsageAsync(auth, route, endpoint, usageOutcome{ + Outcome: "cancelled", Cancelled: true, Streamed: stream, + DurationMs: time.Since(started).Milliseconds(), + }) + writeProxyError(w, apierr.Newf(502, "provider_unreachable", + "request to provider '%s' failed: %s", route.ProviderName, errClass(err))) + return true } s.recordUsageAsync(auth, route, endpoint, usageOutcome{ - Outcome: outcome, ErrorKind: kind, Cancelled: cancelled, Streamed: stream, - DurationMs: time.Since(started).Milliseconds(), + Outcome: "unreachable", ErrorKind: errClass(err), Streamed: stream, + DurationMs: time.Since(started).Milliseconds(), FailedOver: !last, }) + if !last { + s.failOver(route, "unreachable") + return false + } writeProxyError(w, apierr.Newf(502, "provider_unreachable", "request to provider '%s' failed: %s", route.ProviderName, errClass(err))) - return + return true } defer resp.Body.Close() + if !last && (resp.StatusCode == http.StatusTooManyRequests || resp.StatusCode >= 500) { + data, _ := io.ReadAll(io.LimitReader(resp.Body, failoverBodyBytes)) + s.observeRateLimit(resp, route) + s.recordUsageAsync(auth, route, endpoint, usageOutcome{ + StatusCode: resp.StatusCode, Outcome: "upstream_error", ErrorKind: errorKindFromBody(data), + Streamed: stream, DurationMs: time.Since(started).Milliseconds(), FailedOver: true, + }) + s.failOver(route, strconv.Itoa(resp.StatusCode)) + return false + } + w.Header().Set("x-llmproxy-provider", route.ProviderName) w.Header().Set("x-llmproxy-model", route.UpstreamName) - s.observeRateLimit(w, resp, route) + if reading := s.observeRateLimit(resp, route); reading != nil { + setRateLimitResponseHeaders(w, reading) + } if !stream || resp.StatusCode >= 400 { s.relayUnary(w, auth, route, endpoint, resp, stream, started) - return + return true } s.relayStream(w, r, auth, route, endpoint, resp, started) + return true +} + +func (s *Server) failOver(route *catalog.Route, reason string) { + s.balancer.Fail(route) + s.metrics.ObserveFailover(route.ProviderName, route.Alias, reason) } // maxUnaryResponseBytes caps buffered upstream bodies. Oversize responses are diff --git a/internal/server/persistence_test.go b/internal/server/persistence_test.go index 6b475b2..c1d8841 100644 --- a/internal/server/persistence_test.go +++ b/internal/server/persistence_test.go @@ -48,7 +48,11 @@ func TestMarkerNeverReachesDisk(t *testing.T) { t.Fatal("chat failed") } e.waitUsage(t, func(ev store.UsageEvent) bool { return ev.Outcome == "ok" }) + assertNoMarkerOnDisk(t, e) +} +func assertNoMarkerOnDisk(t *testing.T, e *env) { + t.Helper() // Flush the WAL so everything SQLite knows about is in the main file. if _, err := e.st.DB().Exec("PRAGMA wal_checkpoint(TRUNCATE)"); err != nil { t.Fatal(err) diff --git a/internal/server/ratelimit.go b/internal/server/ratelimit.go index eeba361..25ae3f1 100644 --- a/internal/server/ratelimit.go +++ b/internal/server/ratelimit.go @@ -311,15 +311,15 @@ func (t *RateLimitTracker) Drain() []*store.RateLimitSample { // observeRateLimit is the single call site that reads upstream rate-limit // headers, updates the in-memory tracker, sets response headers, updates // Prometheus gauges, and flushes finished buckets to the store. -func (s *Server) observeRateLimit(w http.ResponseWriter, resp *http.Response, route *catalog.Route) { +// observeRateLimit records the upstream's rate-limit telemetry and returns the reading, or nil. +func (s *Server) observeRateLimit(resp *http.Response, route *catalog.Route) *RateLimitReading { reading := readRateLimitHeaders(resp.Header, route.RateLimitHeaders) if reading == nil { - return + return nil } reading.ProviderID = route.ProviderID reading.ProviderName = route.ProviderName - setRateLimitResponseHeaders(w, reading) setRateLimitGauges(s.metrics, route.ProviderName, reading) finished := s.rateLimits.Observe(reading, time.Now()) @@ -330,6 +330,7 @@ func (s *Server) observeRateLimit(w http.ResponseWriter, resp *http.Response, ro } }) } + return reading } func (s *Server) flushRateLimitSample(sample *store.RateLimitSample) { diff --git a/internal/server/server.go b/internal/server/server.go index 9a49791..5fa717b 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -32,9 +32,11 @@ type Server struct { store *store.Store secret []byte catalog *catalog.Catalog - pool *upstream.Pool - metrics *metrics.Metrics - pricing atomic.Pointer[pricing.Index] + // balancer orders alias targets and tracks cooldowns, per replica. + balancer *catalog.Balancer + pool *upstream.Pool + metrics *metrics.Metrics + pricing atomic.Pointer[pricing.Index] // transparent is the HTTP client for the transparent Anthropic relay; // separate from the provider pool because there is no provider row. @@ -69,6 +71,7 @@ func New(cfg config.Config, st *store.Store, secret []byte) *Server { store: st, secret: secret, catalog: catalog.New(st, secret, cfg.CatalogTTL), + balancer: catalog.NewBalancer(cfg.FailoverCooldown), pool: upstream.New(), metrics: metrics.New(), rateLimits: NewRateLimitTracker(), diff --git a/internal/server/uidist/assets/index-DNvsmEwg.js b/internal/server/uidist/assets/index-DNvsmEwg.js new file mode 100644 index 0000000..e913a77 --- /dev/null +++ b/internal/server/uidist/assets/index-DNvsmEwg.js @@ -0,0 +1,311 @@ +var H2=Object.defineProperty;var P2=(e,r,a)=>r in e?H2(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var ch=(e,r,a)=>P2(e,typeof r!="symbol"?r+"":r,a);function $2(e,r){for(var a=0;al[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(o){if(o.ep)return;o.ep=!0;const c=a(o);fetch(o.href,c)}})();function bc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dh={exports:{}},Ys={};/** + * @license React + * react-jsx-runtime.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Iy;function F2(){if(Iy)return Ys;Iy=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(l,o,c){var d=null;if(c!==void 0&&(d=""+c),o.key!==void 0&&(d=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:l,key:d,ref:o!==void 0?o:null,props:c}}return Ys.Fragment=r,Ys.jsx=a,Ys.jsxs=a,Ys}var qy;function V2(){return qy||(qy=1,dh.exports=F2()),dh.exports}var s=V2(),fh={exports:{}},Fe={};/** + * @license React + * react.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Hy;function G2(){if(Hy)return Fe;Hy=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function y(U){return U===null||typeof U!="object"?null:(U=b&&U[b]||U["@@iterator"],typeof U=="function"?U:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,T={};function N(U,V,M){this.props=U,this.context=V,this.refs=T,this.updater=M||k}N.prototype.isReactComponent={},N.prototype.setState=function(U,V){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,V,"setState")},N.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function R(){}R.prototype=N.prototype;function D(U,V,M){this.props=U,this.context=V,this.refs=T,this.updater=M||k}var I=D.prototype=new R;I.constructor=D,j(I,N.prototype),I.isPureReactComponent=!0;var O=Array.isArray;function E(){}var C={H:null,A:null,T:null,S:null},z=Object.prototype.hasOwnProperty;function Y(U,V,M){var se=M.ref;return{$$typeof:e,type:U,key:V,ref:se!==void 0?se:null,props:M}}function q(U,V){return Y(U.type,V,U.props)}function P(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function K(U){var V={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(M){return V[M]})}var ue=/\/+/g;function le(U,V){return typeof U=="object"&&U!==null&&U.key!=null?K(""+U.key):V.toString(36)}function W(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(E,E):(U.status="pending",U.then(function(V){U.status==="pending"&&(U.status="fulfilled",U.value=V)},function(V){U.status==="pending"&&(U.status="rejected",U.reason=V)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function B(U,V,M,se,X){var ce=typeof U;(ce==="undefined"||ce==="boolean")&&(U=null);var re=!1;if(U===null)re=!0;else switch(ce){case"bigint":case"string":case"number":re=!0;break;case"object":switch(U.$$typeof){case e:case r:re=!0;break;case x:return re=U._init,B(re(U._payload),V,M,se,X)}}if(re)return X=X(U),re=se===""?"."+le(U,0):se,O(X)?(M="",re!=null&&(M=re.replace(ue,"$&/")+"/"),B(X,V,M,"",function(we){return we})):X!=null&&(P(X)&&(X=q(X,M+(X.key==null||U&&U.key===X.key?"":(""+X.key).replace(ue,"$&/")+"/")+re)),V.push(X)),1;re=0;var be=se===""?".":se+":";if(O(U))for(var fe=0;fe>>1,A=B[Z];if(0>>1;Zo(M,ae))seo(X,M)?(B[Z]=X,B[se]=ae,Z=se):(B[Z]=M,B[V]=ae,Z=V);else if(seo(X,ae))B[Z]=X,B[se]=ae,Z=se;else break e}}return F}function o(B,F){var ae=B.sortIndex-F.sortIndex;return ae!==0?ae:B.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var h=[],m=[],x=1,v=null,b=3,y=!1,k=!1,j=!1,T=!1,N=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function I(B){for(var F=a(m);F!==null;){if(F.callback===null)l(m);else if(F.startTime<=B)l(m),F.sortIndex=F.expirationTime,r(h,F);else break;F=a(m)}}function O(B){if(j=!1,I(B),!k)if(a(h)!==null)k=!0,E||(E=!0,K());else{var F=a(m);F!==null&&W(O,F.startTime-B)}}var E=!1,C=-1,z=5,Y=-1;function q(){return T?!0:!(e.unstable_now()-YB&&q());){var Z=v.callback;if(typeof Z=="function"){v.callback=null,b=v.priorityLevel;var A=Z(v.expirationTime<=B);if(B=e.unstable_now(),typeof A=="function"){v.callback=A,I(B),F=!0;break t}v===a(h)&&l(h),I(B)}else l(h);v=a(h)}if(v!==null)F=!0;else{var U=a(m);U!==null&&W(O,U.startTime-B),F=!1}}break e}finally{v=null,b=ae,y=!1}F=void 0}}finally{F?K():E=!1}}}var K;if(typeof D=="function")K=function(){D(P)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,le=ue.port2;ue.port1.onmessage=P,K=function(){le.postMessage(null)}}else K=function(){N(P,0)};function W(B,F){C=N(function(){B(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125Z?(B.sortIndex=ae,r(m,B),a(h)===null&&B===a(m)&&(j?(R(C),C=-1):j=!0,W(O,ae-Z))):(B.sortIndex=A,r(h,B),k||y||(k=!0,E||(E=!0,K()))),B},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(B){var F=b;return function(){var ae=b;b=F;try{return B.apply(this,arguments)}finally{b=ae}}}})(ph)),ph}var Fy;function K2(){return Fy||(Fy=1,mh.exports=X2()),mh.exports}var gh={exports:{}},bn={};/** + * @license React + * react-dom.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vy;function Q2(){if(Vy)return bn;Vy=1;var e=Hm();function r(h){var m="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),gh.exports=Q2(),gh.exports}/** + * @license React + * react-dom-client.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yy;function Z2(){if(Yy)return Xs;Yy=1;var e=K2(),r=Hm(),a=P0();function l(t){var n="https://react.dev/errors/"+t;if(1A||(t.current=Z[A],Z[A]=null,A--)}function M(t,n){A++,Z[A]=t.current,t.current=n}var se=U(null),X=U(null),ce=U(null),re=U(null);function be(t,n){switch(M(ce,n),M(X,t),M(se,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?oy(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=oy(n),t=uy(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}V(se),M(se,t)}function fe(){V(se),V(X),V(ce)}function we(t){t.memoizedState!==null&&M(re,t);var n=se.current,i=uy(n,t.type);n!==i&&(M(X,t),M(se,i))}function Ee(t){X.current===t&&(V(se),V(X)),re.current===t&&(V(re),$s._currentValue=ae)}var Se,Ie;function Be(t){if(Se===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);Se=n&&n[1]||"",Ie=-1)":-1p||H[u]!==ee[p]){var oe=` +`+H[u].replace(" at new "," at ");return t.displayName&&oe.includes("")&&(oe=oe.replace("",t.displayName)),oe}while(1<=u&&0<=p);break}}}finally{Mt=!1,Error.prepareStackTrace=i}return(i=t?t.displayName||t.name:"")?Be(i):""}function Et(t,n){switch(t.tag){case 26:case 27:case 5:return Be(t.type);case 16:return Be("Lazy");case 13:return t.child!==n&&n!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Nt(t.type,!1);case 11:return Nt(t.type.render,!1);case 1:return Nt(t.type,!0);case 31:return Be("Activity");default:return""}}function Bt(t){try{var n="",i=null;do n+=Et(t,i),i=t,t=t.return;while(t);return n}catch(u){return` +Error generating stack: `+u.message+` +`+u.stack}}var Rt=Object.prototype.hasOwnProperty,Dt=e.unstable_scheduleCallback,zt=e.unstable_cancelCallback,ye=e.unstable_shouldYield,pt=e.unstable_requestPaint,Q=e.unstable_now,Pe=e.unstable_getCurrentPriorityLevel,ne=e.unstable_ImmediatePriority,L=e.unstable_UserBlockingPriority,he=e.unstable_NormalPriority,ke=e.unstable_LowPriority,ze=e.unstable_IdlePriority,an=e.log,Tn=e.unstable_setDisableYieldValue,Wt=null,Tt=null;function un(t){if(typeof an=="function"&&Tn(t),Tt&&typeof Tt.setStrictMode=="function")try{Tt.setStrictMode(Wt,t)}catch{}}var st=Math.clz32?Math.clz32:Eo,Tr=Math.log,Hn=Math.LN2;function Eo(t){return t>>>=0,t===0?32:31-(Tr(t)/Hn|0)|0}var bl=256,ei=262144,Sa=4194304;function yn(t){var n=t&42;if(n!==0)return n;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function ti(t,n,i){var u=t.pendingLanes;if(u===0)return 0;var p=0,g=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var _=u&134217727;return _!==0?(u=_&~g,u!==0?p=yn(u):(w&=_,w!==0?p=yn(w):i||(i=_&~t,i!==0&&(p=yn(i))))):(_=u&~g,_!==0?p=yn(_):w!==0?p=yn(w):i||(i=u&~t,i!==0&&(p=yn(i)))),p===0?0:n!==0&&n!==p&&(n&g)===0&&(g=p&-p,i=n&-n,g>=i||g===32&&(i&4194048)!==0)?n:p}function qe(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function mt(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 wt(){var t=Sa;return Sa<<=1,(Sa&62914560)===0&&(Sa=4194304),t}function jn(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function cn(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Ar(t,n,i,u,p,g){var w=t.pendingLanes;t.pendingLanes=i,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=i,t.entangledLanes&=i,t.errorRecoveryDisabledLanes&=i,t.shellSuspendCounter=0;var _=t.entanglements,H=t.expirationTimes,ee=t.hiddenUpdates;for(i=w&~i;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var zk=/[\n"\\]/g;function Wn(t){return t.replace(zk,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function rd(t,n,i,u,p,g,w,_){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),n!=null?w==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+Jn(n)):t.value!==""+Jn(n)&&(t.value=""+Jn(n)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),n!=null?ad(t,w,Jn(n)):i!=null?ad(t,w,Jn(i)):u!=null&&t.removeAttribute("value"),p==null&&g!=null&&(t.defaultChecked=!!g),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?t.name=""+Jn(_):t.removeAttribute("name")}function ng(t,n,i,u,p,g,w,_){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),n!=null||i!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){nd(t);return}i=i!=null?""+Jn(i):"",n=n!=null?""+Jn(n):i,_||n===t.value||(t.value=n),t.defaultValue=n}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=_?t.checked:!!u,t.defaultChecked=!!u,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),nd(t)}function ad(t,n,i){n==="number"&&_o(t.ownerDocument)===t||t.defaultValue===""+i||(t.defaultValue=""+i)}function si(t,n,i,u){if(t=t.options,n){n={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ud=!1;if(Kr)try{var ss={};Object.defineProperty(ss,"passive",{get:function(){ud=!0}}),window.addEventListener("test",ss,ss),window.removeEventListener("test",ss,ss)}catch{ud=!1}var ka=null,cd=null,Ro=null;function ug(){if(Ro)return Ro;var t,n=cd,i=n.length,u,p="value"in ka?ka.value:ka.textContent,g=p.length;for(t=0;t=cs),pg=" ",gg=!1;function xg(t,n){switch(t){case"keyup":return uC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vg(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var di=!1;function dC(t,n){switch(t){case"compositionend":return vg(n);case"keypress":return n.which!==32?null:(gg=!0,pg);case"textInput":return t=n.data,t===pg&&gg?null:t;default:return null}}function fC(t,n){if(di)return t==="compositionend"||!pd&&xg(t,n)?(t=ug(),Ro=cd=ka=null,di=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-t};t=u}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=Ng(i)}}function Tg(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Tg(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Ag(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=_o(t.document);n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=_o(t.document)}return n}function vd(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var bC=Kr&&"documentMode"in document&&11>=document.documentMode,fi=null,yd=null,ms=null,bd=!1;function _g(t,n,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;bd||fi==null||fi!==_o(u)||(u=fi,"selectionStart"in u&&vd(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ms&&hs(ms,u)||(ms=u,u=Cu(yd,"onSelect"),0>=w,p-=w,Mr=1<<32-st(n)+p|i<Xe?(at=_e,_e=null):at=_e.sibling;var ct=te(G,_e,J[Xe],me);if(ct===null){_e===null&&(_e=at);break}t&&_e&&ct.alternate===null&&n(G,_e),$=g(ct,$,Xe),ut===null?De=ct:ut.sibling=ct,ut=ct,_e=at}if(Xe===J.length)return i(G,_e),lt&&Zr(G,Xe),De;if(_e===null){for(;XeXe?(at=_e,_e=null):at=_e.sibling;var Ga=te(G,_e,ct.value,me);if(Ga===null){_e===null&&(_e=at);break}t&&_e&&Ga.alternate===null&&n(G,_e),$=g(Ga,$,Xe),ut===null?De=Ga:ut.sibling=Ga,ut=Ga,_e=at}if(ct.done)return i(G,_e),lt&&Zr(G,Xe),De;if(_e===null){for(;!ct.done;Xe++,ct=J.next())ct=pe(G,ct.value,me),ct!==null&&($=g(ct,$,Xe),ut===null?De=ct:ut.sibling=ct,ut=ct);return lt&&Zr(G,Xe),De}for(_e=u(_e);!ct.done;Xe++,ct=J.next())ct=ie(_e,G,Xe,ct.value,me),ct!==null&&(t&&ct.alternate!==null&&_e.delete(ct.key===null?Xe:ct.key),$=g(ct,$,Xe),ut===null?De=ct:ut.sibling=ct,ut=ct);return t&&_e.forEach(function(q2){return n(G,q2)}),lt&&Zr(G,Xe),De}function bt(G,$,J,me){if(typeof J=="object"&&J!==null&&J.type===j&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case y:e:{for(var De=J.key;$!==null;){if($.key===De){if(De=J.type,De===j){if($.tag===7){i(G,$.sibling),me=p($,J.props.children),me.return=G,G=me;break e}}else if($.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===z&&Ml(De)===$.type){i(G,$.sibling),me=p($,J.props),bs(me,J),me.return=G,G=me;break e}i(G,$);break}else n(G,$);$=$.sibling}J.type===j?(me=Nl(J.props.children,G.mode,me,J.key),me.return=G,G=me):(me=Po(J.type,J.key,J.props,null,G.mode,me),bs(me,J),me.return=G,G=me)}return w(G);case k:e:{for(De=J.key;$!==null;){if($.key===De)if($.tag===4&&$.stateNode.containerInfo===J.containerInfo&&$.stateNode.implementation===J.implementation){i(G,$.sibling),me=p($,J.children||[]),me.return=G,G=me;break e}else{i(G,$);break}else n(G,$);$=$.sibling}me=Ed(J,G.mode,me),me.return=G,G=me}return w(G);case z:return J=Ml(J),bt(G,$,J,me)}if(W(J))return Te(G,$,J,me);if(K(J)){if(De=K(J),typeof De!="function")throw Error(l(150));return J=De.call(J),Ue(G,$,J,me)}if(typeof J.then=="function")return bt(G,$,Ko(J),me);if(J.$$typeof===D)return bt(G,$,Vo(G,J),me);Qo(G,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,$!==null&&$.tag===6?(i(G,$.sibling),me=p($,J),me.return=G,G=me):(i(G,$),me=Nd(J,G.mode,me),me.return=G,G=me),w(G)):i(G,$)}return function(G,$,J,me){try{ys=0;var De=bt(G,$,J,me);return ji=null,De}catch(_e){if(_e===Si||_e===Yo)throw _e;var ut=$n(29,_e,null,G.mode);return ut.lanes=me,ut.return=G,ut}finally{}}}var Dl=Wg(!0),ex=Wg(!1),Aa=!1;function Id(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function qd(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function _a(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Ma(t,n,i){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(dt&2)!==0){var p=u.pending;return p===null?n.next=n:(n.next=p.next,p.next=n),u.pending=n,n=Ho(t),Ug(t,null,i),n}return qo(t,u,n,i),Ho(t)}function ws(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194048)!==0)){var u=n.lanes;u&=t.pendingLanes,i|=u,n.lanes=i,An(t,i)}}function Hd(t,n){var i=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,i===u)){var p=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var w={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};g===null?p=g=w:g=g.next=w,i=i.next}while(i!==null);g===null?p=g=n:g=g.next=n}else p=g=n;i={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}var Pd=!1;function Ss(){if(Pd){var t=wi;if(t!==null)throw t}}function js(t,n,i,u){Pd=!1;var p=t.updateQueue;Aa=!1;var g=p.firstBaseUpdate,w=p.lastBaseUpdate,_=p.shared.pending;if(_!==null){p.shared.pending=null;var H=_,ee=H.next;H.next=null,w===null?g=ee:w.next=ee,w=H;var oe=t.alternate;oe!==null&&(oe=oe.updateQueue,_=oe.lastBaseUpdate,_!==w&&(_===null?oe.firstBaseUpdate=ee:_.next=ee,oe.lastBaseUpdate=H))}if(g!==null){var pe=p.baseState;w=0,oe=ee=H=null,_=g;do{var te=_.lane&-536870913,ie=te!==_.lane;if(ie?(rt&te)===te:(u&te)===te){te!==0&&te===bi&&(Pd=!0),oe!==null&&(oe=oe.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Te=t,Ue=_;te=n;var bt=i;switch(Ue.tag){case 1:if(Te=Ue.payload,typeof Te=="function"){pe=Te.call(bt,pe,te);break e}pe=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=Ue.payload,te=typeof Te=="function"?Te.call(bt,pe,te):Te,te==null)break e;pe=v({},pe,te);break e;case 2:Aa=!0}}te=_.callback,te!==null&&(t.flags|=64,ie&&(t.flags|=8192),ie=p.callbacks,ie===null?p.callbacks=[te]:ie.push(te))}else ie={lane:te,tag:_.tag,payload:_.payload,callback:_.callback,next:null},oe===null?(ee=oe=ie,H=pe):oe=oe.next=ie,w|=te;if(_=_.next,_===null){if(_=p.shared.pending,_===null)break;ie=_,_=ie.next,ie.next=null,p.lastBaseUpdate=ie,p.shared.pending=null}}while(!0);oe===null&&(H=pe),p.baseState=H,p.firstBaseUpdate=ee,p.lastBaseUpdate=oe,g===null&&(p.shared.lanes=0),La|=w,t.lanes=w,t.memoizedState=pe}}function tx(t,n){if(typeof t!="function")throw Error(l(191,t));t.call(n)}function nx(t,n){var i=t.callbacks;if(i!==null)for(t.callbacks=null,t=0;tg?g:8;var w=B.T,_={};B.T=_,of(t,!1,n,i);try{var H=p(),ee=B.S;if(ee!==null&&ee(_,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var oe=AC(H,u);Ns(t,n,oe,Xn(t))}else Ns(t,n,u,Xn(t))}catch(pe){Ns(t,n,{then:function(){},status:"rejected",reason:pe},Xn())}finally{F.p=g,w!==null&&_.types!==null&&(w.types=_.types),B.T=w}}function zC(){}function lf(t,n,i,u){if(t.tag!==5)throw Error(l(476));var p=Ox(t).queue;Dx(t,p,n,ae,i===null?zC:function(){return zx(t),i(u)})}function Ox(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ta,lastRenderedState:ae},next:null};var i={};return n.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ta,lastRenderedState:i},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function zx(t){var n=Ox(t);n.next===null&&(n=t.alternate.memoizedState),Ns(t,n.next.queue,{},Xn())}function sf(){return hn($s)}function Lx(){return $t().memoizedState}function Ux(){return $t().memoizedState}function LC(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var i=Xn();t=_a(i);var u=Ma(n,t,i);u!==null&&(Ln(u,n,i),ws(u,n,i)),n={cache:zd()},t.payload=n;return}n=n.return}}function UC(t,n,i){var u=Xn();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},iu(t)?Ix(n,i):(i=kd(t,n,i,u),i!==null&&(Ln(i,t,u),qx(i,n,u)))}function Bx(t,n,i){var u=Xn();Ns(t,n,i,u)}function Ns(t,n,i,u){var p={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(iu(t))Ix(n,p);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var w=n.lastRenderedState,_=g(w,i);if(p.hasEagerState=!0,p.eagerState=_,Pn(_,w))return qo(t,n,p,0),St===null&&Io(),!1}catch{}finally{}if(i=kd(t,n,p,u),i!==null)return Ln(i,t,u),qx(i,n,u),!0}return!1}function of(t,n,i,u){if(u={lane:2,revertLane:qf(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},iu(t)){if(n)throw Error(l(479))}else n=kd(t,i,u,2),n!==null&&Ln(n,t,2)}function iu(t){var n=t.alternate;return t===Ye||n!==null&&n===Ye}function Ix(t,n){Ci=Wo=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function qx(t,n,i){if((i&4194048)!==0){var u=n.lanes;u&=t.pendingLanes,i|=u,n.lanes=i,An(t,i)}}var Es={readContext:hn,use:nu,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useLayoutEffect:It,useInsertionEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useSyncExternalStore:It,useId:It,useHostTransitionStatus:It,useFormState:It,useActionState:It,useOptimistic:It,useMemoCache:It,useCacheRefresh:It};Es.useEffectEvent=It;var Hx={readContext:hn,use:nu,useCallback:function(t,n){return kn().memoizedState=[t,n===void 0?null:n],t},useContext:hn,useEffect:kx,useImperativeHandle:function(t,n,i){i=i!=null?i.concat([t]):null,au(4194308,4,Tx.bind(null,n,t),i)},useLayoutEffect:function(t,n){return au(4194308,4,t,n)},useInsertionEffect:function(t,n){au(4,2,t,n)},useMemo:function(t,n){var i=kn();n=n===void 0?null:n;var u=t();if(Ol){un(!0);try{t()}finally{un(!1)}}return i.memoizedState=[u,n],u},useReducer:function(t,n,i){var u=kn();if(i!==void 0){var p=i(n);if(Ol){un(!0);try{i(n)}finally{un(!1)}}}else p=n;return u.memoizedState=u.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},u.queue=t,t=t.dispatch=UC.bind(null,Ye,t),[u.memoizedState,t]},useRef:function(t){var n=kn();return t={current:t},n.memoizedState=t},useState:function(t){t=ef(t);var n=t.queue,i=Bx.bind(null,Ye,n);return n.dispatch=i,[t.memoizedState,i]},useDebugValue:rf,useDeferredValue:function(t,n){var i=kn();return af(i,t,n)},useTransition:function(){var t=ef(!1);return t=Dx.bind(null,Ye,t.queue,!0,!1),kn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,i){var u=Ye,p=kn();if(lt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=n(),St===null)throw Error(l(349));(rt&127)!==0||ox(u,n,i)}p.memoizedState=i;var g={value:i,getSnapshot:n};return p.queue=g,kx(cx.bind(null,u,g,t),[t]),u.flags|=2048,Ei(9,{destroy:void 0},ux.bind(null,u,g,i,n),null),i},useId:function(){var t=kn(),n=St.identifierPrefix;if(lt){var i=Rr,u=Mr;i=(u&~(1<<32-st(u)-1)).toString(32)+i,n="_"+n+"R_"+i,i=eu++,0<\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?w.createElement("select",{is:u.is}):w.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?w.createElement(p,{is:u.is}):w.createElement(p)}}g[dn]=n,g[_n]=u;e:for(w=n.child;w!==null;){if(w.tag===5||w.tag===6)g.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===n)break e;for(;w.sibling===null;){if(w.return===null||w.return===n)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}n.stateNode=g;e:switch(pn(g,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&ra(n)}}return _t(n),Sf(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,i),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==u&&ra(n);else{if(typeof u!="string"&&n.stateNode===null)throw Error(l(166));if(t=ce.current,vi(n)){if(t=n.stateNode,i=n.memoizedProps,u=null,p=fn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}t[dn]=n,t=!!(t.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||iy(t.nodeValue,i)),t||Ea(n,!0)}else t=Nu(t).createTextNode(u),t[dn]=n,n.stateNode=t}return _t(n),null;case 31:if(i=n.memoizedState,t===null||t.memoizedState!==null){if(u=vi(n),i!==null){if(t===null){if(!u)throw Error(l(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(l(557));t[dn]=n}else El(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;_t(n),t=!1}else i=Md(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=i),t=!0;if(!t)return n.flags&256?(Vn(n),n):(Vn(n),null);if((n.flags&128)!==0)throw Error(l(558))}return _t(n),null;case 13:if(u=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=vi(n),u!==null&&u.dehydrated!==null){if(t===null){if(!p)throw Error(l(318));if(p=n.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(l(317));p[dn]=n}else El(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;_t(n),p=!1}else p=Md(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return n.flags&256?(Vn(n),n):(Vn(n),null)}return Vn(n),(n.flags&128)!==0?(n.lanes=i,n):(i=u!==null,t=t!==null&&t.memoizedState!==null,i&&(u=n.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048)),i!==t&&i&&(n.child.flags|=8192),du(n,n.updateQueue),_t(n),null);case 4:return fe(),t===null&&Ff(n.stateNode.containerInfo),_t(n),null;case 10:return Wr(n.type),_t(n),null;case 19:if(V(Pt),u=n.memoizedState,u===null)return _t(n),null;if(p=(n.flags&128)!==0,g=u.rendering,g===null)if(p)As(u,!1);else{if(qt!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(g=Jo(t),g!==null){for(n.flags|=128,As(u,!1),t=g.updateQueue,n.updateQueue=t,du(n,t),n.subtreeFlags=0,t=i,i=n.child;i!==null;)Bg(i,t),i=i.sibling;return M(Pt,Pt.current&1|2),lt&&Zr(n,u.treeForkCount),n.child}t=t.sibling}u.tail!==null&&Q()>gu&&(n.flags|=128,p=!0,As(u,!1),n.lanes=4194304)}else{if(!p)if(t=Jo(g),t!==null){if(n.flags|=128,p=!0,t=t.updateQueue,n.updateQueue=t,du(n,t),As(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!lt)return _t(n),null}else 2*Q()-u.renderingStartTime>gu&&i!==536870912&&(n.flags|=128,p=!0,As(u,!1),n.lanes=4194304);u.isBackwards?(g.sibling=n.child,n.child=g):(t=u.last,t!==null?t.sibling=g:n.child=g,u.last=g)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=Q(),t.sibling=null,i=Pt.current,M(Pt,p?i&1|2:i&1),lt&&Zr(n,u.treeForkCount),t):(_t(n),null);case 22:case 23:return Vn(n),Fd(),u=n.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(n.flags|=8192):u&&(n.flags|=8192),u?(i&536870912)!==0&&(n.flags&128)===0&&(_t(n),n.subtreeFlags&6&&(n.flags|=8192)):_t(n),i=n.updateQueue,i!==null&&du(n,i.retryQueue),i=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),u=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),u!==i&&(n.flags|=2048),t!==null&&V(_l),null;case 24:return i=null,t!==null&&(i=t.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),Wr(Yt),_t(n),null;case 25:return null;case 30:return null}throw Error(l(156,n.tag))}function PC(t,n){switch(Ad(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return Wr(Yt),fe(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return Ee(n),null;case 31:if(n.memoizedState!==null){if(Vn(n),n.alternate===null)throw Error(l(340));El()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(Vn(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(l(340));El()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return V(Pt),null;case 4:return fe(),null;case 10:return Wr(n.type),null;case 22:case 23:return Vn(n),Fd(),t!==null&&V(_l),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return Wr(Yt),null;case 25:return null;default:return null}}function dv(t,n){switch(Ad(n),n.tag){case 3:Wr(Yt),fe();break;case 26:case 27:case 5:Ee(n);break;case 4:fe();break;case 31:n.memoizedState!==null&&Vn(n);break;case 13:Vn(n);break;case 19:V(Pt);break;case 10:Wr(n.type);break;case 22:case 23:Vn(n),Fd(),t!==null&&V(_l);break;case 24:Wr(Yt)}}function _s(t,n){try{var i=n.updateQueue,u=i!==null?i.lastEffect:null;if(u!==null){var p=u.next;i=p;do{if((i.tag&t)===t){u=void 0;var g=i.create,w=i.inst;u=g(),w.destroy=u}i=i.next}while(i!==p)}}catch(_){xt(n,n.return,_)}}function Oa(t,n,i){try{var u=n.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var g=p.next;u=g;do{if((u.tag&t)===t){var w=u.inst,_=w.destroy;if(_!==void 0){w.destroy=void 0,p=n;var H=i,ee=_;try{ee()}catch(oe){xt(p,H,oe)}}}u=u.next}while(u!==g)}}catch(oe){xt(n,n.return,oe)}}function fv(t){var n=t.updateQueue;if(n!==null){var i=t.stateNode;try{nx(n,i)}catch(u){xt(t,t.return,u)}}}function hv(t,n,i){i.props=zl(t.type,t.memoizedProps),i.state=t.memoizedState;try{i.componentWillUnmount()}catch(u){xt(t,n,u)}}function Ms(t,n){try{var i=t.ref;if(i!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof i=="function"?t.refCleanup=i(u):i.current=u}}catch(p){xt(t,n,p)}}function Dr(t,n){var i=t.ref,u=t.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(p){xt(t,n,p)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(p){xt(t,n,p)}else i.current=null}function mv(t){var n=t.type,i=t.memoizedProps,u=t.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":i.autoFocus&&u.focus();break e;case"img":i.src?u.src=i.src:i.srcSet&&(u.srcset=i.srcSet)}}catch(p){xt(t,t.return,p)}}function jf(t,n,i){try{var u=t.stateNode;c2(u,t.type,i,n),u[_n]=n}catch(p){xt(t,t.return,p)}}function pv(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Ha(t.type)||t.tag===4}function kf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||pv(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Ha(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Cf(t,n,i){var u=t.tag;if(u===5||u===6)t=t.stateNode,n?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(t,n):(n=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,n.appendChild(t),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Xr));else if(u!==4&&(u===27&&Ha(t.type)&&(i=t.stateNode,n=null),t=t.child,t!==null))for(Cf(t,n,i),t=t.sibling;t!==null;)Cf(t,n,i),t=t.sibling}function fu(t,n,i){var u=t.tag;if(u===5||u===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(u!==4&&(u===27&&Ha(t.type)&&(i=t.stateNode),t=t.child,t!==null))for(fu(t,n,i),t=t.sibling;t!==null;)fu(t,n,i),t=t.sibling}function gv(t){var n=t.stateNode,i=t.memoizedProps;try{for(var u=t.type,p=n.attributes;p.length;)n.removeAttributeNode(p[0]);pn(n,u,i),n[dn]=t,n[_n]=i}catch(g){xt(t,t.return,g)}}var aa=!1,Qt=!1,Nf=!1,xv=typeof WeakSet=="function"?WeakSet:Set,sn=null;function $C(t,n){if(t=t.containerInfo,Yf=Du,t=Ag(t),vd(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var u=i.getSelection&&i.getSelection();if(u&&u.rangeCount!==0){i=u.anchorNode;var p=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var w=0,_=-1,H=-1,ee=0,oe=0,pe=t,te=null;t:for(;;){for(var ie;pe!==i||p!==0&&pe.nodeType!==3||(_=w+p),pe!==g||u!==0&&pe.nodeType!==3||(H=w+u),pe.nodeType===3&&(w+=pe.nodeValue.length),(ie=pe.firstChild)!==null;)te=pe,pe=ie;for(;;){if(pe===t)break t;if(te===i&&++ee===p&&(_=w),te===g&&++oe===u&&(H=w),(ie=pe.nextSibling)!==null)break;pe=te,te=pe.parentNode}pe=ie}i=_===-1||H===-1?null:{start:_,end:H}}else i=null}i=i||{start:0,end:0}}else i=null;for(Xf={focusedElem:t,selectionRange:i},Du=!1,sn=n;sn!==null;)if(n=sn,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,sn=t;else for(;sn!==null;){switch(n=sn,g=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.updateQueue,t=t!==null?t.events:null,t!==null))for(i=0;i title"))),pn(g,u,i),g[dn]=t,ln(g),u=g;break e;case"link":var w=jy("link","href",p).get(u+(i.href||""));if(w){for(var _=0;_bt&&(w=bt,bt=Ue,Ue=w);var G=Eg(_,Ue),$=Eg(_,bt);if(G&&$&&(ie.rangeCount!==1||ie.anchorNode!==G.node||ie.anchorOffset!==G.offset||ie.focusNode!==$.node||ie.focusOffset!==$.offset)){var J=pe.createRange();J.setStart(G.node,G.offset),ie.removeAllRanges(),Ue>bt?(ie.addRange(J),ie.extend($.node,$.offset)):(J.setEnd($.node,$.offset),ie.addRange(J))}}}}for(pe=[],ie=_;ie=ie.parentNode;)ie.nodeType===1&&pe.push({element:ie,left:ie.scrollLeft,top:ie.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_i?32:i,B.T=null,i=Df,Df=null;var g=Ba,w=ua;if(en=0,Ri=Ba=null,ua=0,(dt&6)!==0)throw Error(l(331));var _=dt;if(dt|=4,Tv(g.current),Cv(g,g.current,w,i),dt=_,Us(0,!1),Tt&&typeof Tt.onPostCommitFiberRoot=="function")try{Tt.onPostCommitFiberRoot(Wt,g)}catch{}return!0}finally{F.p=p,B.T=u,Gv(t,n)}}function Xv(t,n,i){n=tr(i,n),n=ff(t.stateNode,n,2),t=Ma(t,n,2),t!==null&&(cn(t,2),Or(t))}function xt(t,n,i){if(t.tag===3)Xv(t,t,i);else for(;n!==null;){if(n.tag===3){Xv(n,t,i);break}else if(n.tag===1){var u=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Ua===null||!Ua.has(u))){t=tr(i,t),i=Kx(2),u=Ma(n,i,2),u!==null&&(Qx(i,u,n,t),cn(u,2),Or(u));break}}n=n.return}}function Uf(t,n,i){var u=t.pingCache;if(u===null){u=t.pingCache=new GC;var p=new Set;u.set(n,p)}else p=u.get(n),p===void 0&&(p=new Set,u.set(n,p));p.has(i)||(Af=!0,p.add(i),t=ZC.bind(null,t,n,i),n.then(t,t))}function ZC(t,n,i){var u=t.pingCache;u!==null&&u.delete(n),t.pingedLanes|=t.suspendedLanes&i,t.warmLanes&=~i,St===t&&(rt&i)===i&&(qt===4||qt===3&&(rt&62914560)===rt&&300>Q()-pu?(dt&2)===0&&Di(t,0):_f|=i,Mi===rt&&(Mi=0)),Or(t)}function Kv(t,n){n===0&&(n=wt()),t=Cl(t,n),t!==null&&(cn(t,n),Or(t))}function JC(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Kv(t,i)}function WC(t,n){var i=0;switch(t.tag){case 31:case 13:var u=t.stateNode,p=t.memoizedState;p!==null&&(i=p.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(l(314))}u!==null&&u.delete(n),Kv(t,i)}function e2(t,n){return Dt(t,n)}var Su=null,zi=null,Bf=!1,ju=!1,If=!1,qa=0;function Or(t){t!==zi&&t.next===null&&(zi===null?Su=zi=t:zi=zi.next=t),ju=!0,Bf||(Bf=!0,n2())}function Us(t,n){if(!If&&ju){If=!0;do for(var i=!1,u=Su;u!==null;){if(t!==0){var p=u.pendingLanes;if(p===0)var g=0;else{var w=u.suspendedLanes,_=u.pingedLanes;g=(1<<31-st(42|t)+1)-1,g&=p&~(w&~_),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(i=!0,Wv(u,g))}else g=rt,g=ti(u,u===St?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||qe(u,g)||(i=!0,Wv(u,g));u=u.next}while(i);If=!1}}function t2(){Qv()}function Qv(){ju=Bf=!1;var t=0;qa!==0&&f2()&&(t=qa);for(var n=Q(),i=null,u=Su;u!==null;){var p=u.next,g=Zv(u,n);g===0?(u.next=null,i===null?Su=p:i.next=p,p===null&&(zi=i)):(i=u,(t!==0||(g&3)!==0)&&(ju=!0)),u=p}en!==0&&en!==5||Us(t),qa!==0&&(qa=0)}function Zv(t,n){for(var i=t.suspendedLanes,u=t.pingedLanes,p=t.expirationTimes,g=t.pendingLanes&-62914561;0_)break;var oe=H.transferSize,pe=H.initiatorType;oe&&sy(pe)&&(H=H.responseEnd,w+=oe*(H<_?1:(_-ee)/(H-ee)))}if(--u,n+=8*(g+w)/(p.duration/1e3),t++,10"u"?null:document;function yy(t,n,i){var u=Li;if(u&&typeof n=="string"&&n){var p=Wn(n);p='link[rel="'+t+'"][href="'+p+'"]',typeof i=="string"&&(p+='[crossorigin="'+i+'"]'),vy.has(p)||(vy.add(p),t={rel:t,crossOrigin:i,href:n},u.querySelector(p)===null&&(n=u.createElement("link"),pn(n,"link",t),ln(n),u.head.appendChild(n)))}}function w2(t){ca.D(t),yy("dns-prefetch",t,null)}function S2(t,n){ca.C(t,n),yy("preconnect",t,n)}function j2(t,n,i){ca.L(t,n,i);var u=Li;if(u&&t&&n){var p='link[rel="preload"][as="'+Wn(n)+'"]';n==="image"&&i&&i.imageSrcSet?(p+='[imagesrcset="'+Wn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(p+='[imagesizes="'+Wn(i.imageSizes)+'"]')):p+='[href="'+Wn(t)+'"]';var g=p;switch(n){case"style":g=Ui(t);break;case"script":g=Bi(t)}sr.has(g)||(t=v({rel:"preload",href:n==="image"&&i&&i.imageSrcSet?void 0:t,as:n},i),sr.set(g,t),u.querySelector(p)!==null||n==="style"&&u.querySelector(Hs(g))||n==="script"&&u.querySelector(Ps(g))||(n=u.createElement("link"),pn(n,"link",t),ln(n),u.head.appendChild(n)))}}function k2(t,n){ca.m(t,n);var i=Li;if(i&&t){var u=n&&typeof n.as=="string"?n.as:"script",p='link[rel="modulepreload"][as="'+Wn(u)+'"][href="'+Wn(t)+'"]',g=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Bi(t)}if(!sr.has(g)&&(t=v({rel:"modulepreload",href:t},n),sr.set(g,t),i.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Ps(g)))return}u=i.createElement("link"),pn(u,"link",t),ln(u),i.head.appendChild(u)}}}function C2(t,n,i){ca.S(t,n,i);var u=Li;if(u&&t){var p=li(u).hoistableStyles,g=Ui(t);n=n||"default";var w=p.get(g);if(!w){var _={loading:0,preload:null};if(w=u.querySelector(Hs(g)))_.loading=5;else{t=v({rel:"stylesheet",href:t,"data-precedence":n},i),(i=sr.get(g))&&th(t,i);var H=w=u.createElement("link");ln(H),pn(H,"link",t),H._p=new Promise(function(ee,oe){H.onload=ee,H.onerror=oe}),H.addEventListener("load",function(){_.loading|=1}),H.addEventListener("error",function(){_.loading|=2}),_.loading|=4,Tu(w,n,u)}w={type:"stylesheet",instance:w,count:1,state:_},p.set(g,w)}}}function N2(t,n){ca.X(t,n);var i=Li;if(i&&t){var u=li(i).hoistableScripts,p=Bi(t),g=u.get(p);g||(g=i.querySelector(Ps(p)),g||(t=v({src:t,async:!0},n),(n=sr.get(p))&&nh(t,n),g=i.createElement("script"),ln(g),pn(g,"link",t),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function E2(t,n){ca.M(t,n);var i=Li;if(i&&t){var u=li(i).hoistableScripts,p=Bi(t),g=u.get(p);g||(g=i.querySelector(Ps(p)),g||(t=v({src:t,async:!0,type:"module"},n),(n=sr.get(p))&&nh(t,n),g=i.createElement("script"),ln(g),pn(g,"link",t),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function by(t,n,i,u){var p=(p=ce.current)?Eu(p):null;if(!p)throw Error(l(446));switch(t){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(n=Ui(i.href),i=li(p).hoistableStyles,u=i.get(n),u||(u={type:"style",instance:null,count:0,state:null},i.set(n,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){t=Ui(i.href);var g=li(p).hoistableStyles,w=g.get(t);if(w||(p=p.ownerDocument||p,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,w),(g=p.querySelector(Hs(t)))&&!g._p&&(w.instance=g,w.state.loading=5),sr.has(t)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},sr.set(t,i),g||T2(p,t,i,w.state))),n&&u===null)throw Error(l(528,""));return w}if(n&&u!==null)throw Error(l(529,""));return null;case"script":return n=i.async,i=i.src,typeof i=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Bi(i),i=li(p).hoistableScripts,u=i.get(n),u||(u={type:"script",instance:null,count:0,state:null},i.set(n,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,t))}}function Ui(t){return'href="'+Wn(t)+'"'}function Hs(t){return'link[rel="stylesheet"]['+t+"]"}function wy(t){return v({},t,{"data-precedence":t.precedence,precedence:null})}function T2(t,n,i,u){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?u.loading=1:(n=t.createElement("link"),u.preload=n,n.addEventListener("load",function(){return u.loading|=1}),n.addEventListener("error",function(){return u.loading|=2}),pn(n,"link",i),ln(n),t.head.appendChild(n))}function Bi(t){return'[src="'+Wn(t)+'"]'}function Ps(t){return"script[async]"+t}function Sy(t,n,i){if(n.count++,n.instance===null)switch(n.type){case"style":var u=t.querySelector('style[data-href~="'+Wn(i.href)+'"]');if(u)return n.instance=u,ln(u),u;var p=v({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),ln(u),pn(u,"style",p),Tu(u,i.precedence,t),n.instance=u;case"stylesheet":p=Ui(i.href);var g=t.querySelector(Hs(p));if(g)return n.state.loading|=4,n.instance=g,ln(g),g;u=wy(i),(p=sr.get(p))&&th(u,p),g=(t.ownerDocument||t).createElement("link"),ln(g);var w=g;return w._p=new Promise(function(_,H){w.onload=_,w.onerror=H}),pn(g,"link",u),n.state.loading|=4,Tu(g,i.precedence,t),n.instance=g;case"script":return g=Bi(i.src),(p=t.querySelector(Ps(g)))?(n.instance=p,ln(p),p):(u=i,(p=sr.get(g))&&(u=v({},i),nh(u,p)),t=t.ownerDocument||t,p=t.createElement("script"),ln(p),pn(p,"link",u),t.head.appendChild(p),n.instance=p);case"void":return null;default:throw Error(l(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(u=n.instance,n.state.loading|=4,Tu(u,i.precedence,t));return n.instance}function Tu(t,n,i){for(var u=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,g=p,w=0;w title"):null)}function A2(t,n,i){if(i===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return t=n.disabled,typeof n.precedence=="string"&&t==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Cy(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function _2(t,n,i,u){if(i.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var p=Ui(u.href),g=n.querySelector(Hs(p));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=_u.bind(t),n.then(t,t)),i.state.loading|=4,i.instance=g,ln(g);return}g=n.ownerDocument||n,u=wy(u),(p=sr.get(p))&&th(u,p),g=g.createElement("link"),ln(g);var w=g;w._p=new Promise(function(_,H){w.onload=_,w.onerror=H}),pn(g,"link",u),i.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(i,n),(n=i.state.preload)&&(i.state.loading&3)===0&&(t.count++,i=_u.bind(t),n.addEventListener("load",i),n.addEventListener("error",i))}}var rh=0;function M2(t,n){return t.stylesheets&&t.count===0&&Ru(t,t.stylesheets),0rh?50:800)+n);return t.unsuspend=i,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function _u(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ru(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Mu=null;function Ru(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Mu=new Map,n.forEach(R2,t),Mu=null,_u.call(t))}function R2(t,n){if(!(n.state.loading&4)){var i=Mu.get(t);if(i)var u=i.get(null);else{i=new Map,Mu.set(t,i);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),hh.exports=Z2(),hh.exports}var W2=J2();class wc extends Error{constructor(a,l,o){super(a);ch(this,"code");ch(this,"status");this.code=l,this.status=o}}async function qu(e,r,a){const l=await fetch(r,{method:e,headers:a!==void 0?{"Content-Type":"application/json"}:void 0,body:a!==void 0?JSON.stringify(a):void 0,credentials:"same-origin"}),o=await l.text();let c=null;try{c=o?JSON.parse(o):null}catch{}if(!l.ok){const d=c==null?void 0:c.error;throw new wc((d==null?void 0:d.message)??`HTTP ${l.status}`,(d==null?void 0:d.code)??"http_error",l.status)}return c}const He={get:e=>qu("GET",e),post:(e,r)=>qu("POST",e,r),patch:(e,r)=>qu("PATCH",e,r),del:e=>qu("DELETE",e)};function ha(e,r){for(const a of e.split(",")){const l=a.indexOf(":");if(l>0&&a.slice(0,l)===r)return a.slice(l+1)}return""}function eN(e){return e?e.split(",").filter(Boolean):[]}function tN(e){return e.trim().split(" ")[0]||"unknown"}function ao(e){return e.trim().split(" ")[0].split("/")[0]||"unknown"}function co(e){if(e<1e3)return`${e} ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const r=Math.round(e/1e3),a=Math.floor(r/60),l=r%60;return`${a}m ${String(l).padStart(2,"0")}s`}function Pm(e){return e==null?"unpriced":`$${e.toFixed(6)}`}function Ir(e){return e==null?"unpriced":e===0?"$0":e<.01?`$${e.toFixed(5)}`:e<1e3?`$${e.toFixed(2)}`:`$${new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}`}function Vt(e){return e?new Intl.NumberFormat().format(e):""}function Ht(e){return new Intl.NumberFormat().format(e)}function Re(e){return Math.abs(e)<1e3?new Intl.NumberFormat().format(e):new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1}).format(e)}function $0(e){if(!e)return"";const r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleString()}function tl(e){if(!e)return"";const r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleDateString()}function F0(e){var r,a,l="";if(typeof e=="string"||typeof e=="number")l+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r{const a=new Array(e.length+r.length);for(let l=0;l({classGroupId:e,validator:r}),G0=(e=new Map,r=null,a)=>({nextPart:e,validators:r,classGroupId:a}),sc="-",Ky=[],aN="arbitrary..",lN=e=>{const r=sN(e),{conflictingClassGroups:a,conflictingClassGroupModifiers:l}=e;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return iN(d);const f=d.split(sc),h=f[0]===""&&f.length>1?1:0;return Y0(f,h,r)},getConflictingClassGroupIds:(d,f)=>{if(f){const h=l[d],m=a[d];return h?m?nN(m,h):h:m||Ky}return a[d]||Ky}}},Y0=(e,r,a)=>{if(e.length-r===0)return a.classGroupId;const o=e[r],c=a.nextPart.get(o);if(c){const m=Y0(e,r+1,c);if(m)return m}const d=a.validators;if(d===null)return;const f=r===0?e.join(sc):e.slice(r).join(sc),h=d.length;for(let m=0;me.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),a=r.indexOf(":"),l=r.slice(0,a);return l?aN+l:void 0})(),sN=e=>{const{theme:r,classGroups:a}=e;return oN(a,r)},oN=(e,r)=>{const a=G0();for(const l in e){const o=e[l];$m(o,a,l,r)}return a},$m=(e,r,a,l)=>{const o=e.length;for(let c=0;c{if(typeof e=="string"){cN(e,r,a);return}if(typeof e=="function"){dN(e,r,a,l);return}fN(e,r,a,l)},cN=(e,r,a)=>{const l=e===""?r:X0(r,e);l.classGroupId=a},dN=(e,r,a,l)=>{if(hN(e)){$m(e(l),r,a,l);return}r.validators===null&&(r.validators=[]),r.validators.push(rN(a,e))},fN=(e,r,a,l)=>{const o=Object.entries(e),c=o.length;for(let d=0;d{let a=e;const l=r.split(sc),o=l.length;for(let c=0;c"isThemeGetter"in e&&e.isThemeGetter===!0,mN=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,a=Object.create(null),l=Object.create(null);const o=(c,d)=>{a[c]=d,r++,r>e&&(r=0,l=a,a=Object.create(null))};return{get(c){let d=a[c];if(d!==void 0)return d;if((d=l[c])!==void 0)return o(c,d),d},set(c,d){c in a?a[c]=d:o(c,d)}}},sm="!",Qy=":",pN=[],Zy=(e,r,a,l,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:a,maybePostfixModifierPosition:l,isExternal:o}),gN=e=>{const{prefix:r,experimentalParseClassName:a}=e;let l=o=>{const c=[];let d=0,f=0,h=0,m;const x=o.length;for(let j=0;jh?m-h:void 0;return Zy(c,y,b,k)};if(r){const o=r+Qy,c=l;l=d=>d.startsWith(o)?c(d.slice(o.length)):Zy(pN,!1,d,void 0,!0)}if(a){const o=l;l=c=>a({className:c,parseClassName:o})}return l},xN=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((a,l)=>{r.set(a,1e6+l)}),a=>{const l=[];let o=[];for(let c=0;c0&&(o.sort(),l.push(...o),o=[]),l.push(d)):o.push(d)}return o.length>0&&(o.sort(),l.push(...o)),l}},vN=e=>({cache:mN(e.cacheSize),parseClassName:gN(e),sortModifiers:xN(e),postfixLookupClassGroupIds:yN(e),...lN(e)}),yN=e=>{const r=Object.create(null),a=e.postfixLookupClassGroups;if(a)for(let l=0;l{const{parseClassName:a,getClassGroupId:l,getConflictingClassGroupIds:o,sortModifiers:c,postfixLookupClassGroupIds:d}=r,f=[],h=e.trim().split(bN);let m="";for(let x=h.length-1;x>=0;x-=1){const v=h[x],{isExternal:b,modifiers:y,hasImportantModifier:k,baseClassName:j,maybePostfixModifierPosition:T}=a(v);if(b){m=v+(m.length>0?" "+m:m);continue}let N=!!T,R;if(N){const C=j.substring(0,T);R=l(C);const z=R&&d[R]?l(j):void 0;z&&z!==R&&(R=z,N=!1)}else R=l(j);if(!R){if(!N){m=v+(m.length>0?" "+m:m);continue}if(R=l(j),!R){m=v+(m.length>0?" "+m:m);continue}N=!1}const D=y.length===0?"":y.length===1?y[0]:c(y).join(":"),I=k?D+sm:D,O=I+R;if(f.indexOf(O)>-1)continue;f.push(O);const E=o(R,N);for(let C=0;C0?" "+m:m)}return m},SN=(...e)=>{let r=0,a,l,o="";for(;r{if(typeof e=="string")return e;let r,a="";for(let l=0;l{let a,l,o,c;const d=h=>{const m=r.reduce((x,v)=>v(x),e());return a=vN(m),l=a.cache.get,o=a.cache.set,c=f,f(h)},f=h=>{const m=l(h);if(m)return m;const x=wN(h,a);return o(h,x),x};return c=d,(...h)=>c(SN(...h))},kN=[],tn=e=>{const r=a=>a[e]||kN;return r.isThemeGetter=!0,r},Q0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Z0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,CN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,NN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,EN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,TN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,AN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,_N=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ya=e=>CN.test(e),We=e=>!!e&&!Number.isNaN(Number(e)),zr=e=>!!e&&Number.isInteger(Number(e)),xh=e=>e.endsWith("%")&&We(e.slice(0,-1)),da=e=>NN.test(e),J0=()=>!0,MN=e=>EN.test(e)&&!TN.test(e),Fm=()=>!1,RN=e=>AN.test(e),DN=e=>_N.test(e),ON=e=>!je(e)&&!Ce(e),zN=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),LN=e=>ml(e,t1,Fm),je=e=>Q0.test(e),Bl=e=>ml(e,n1,MN),Jy=e=>ml(e,FN,We),UN=e=>ml(e,a1,J0),BN=e=>ml(e,r1,Fm),Wy=e=>ml(e,W0,Fm),IN=e=>ml(e,e1,DN),Hu=e=>ml(e,l1,RN),Ce=e=>Z0.test(e),Ks=e=>Ql(e,n1),qN=e=>Ql(e,r1),eb=e=>Ql(e,W0),HN=e=>Ql(e,t1),PN=e=>Ql(e,e1),Pu=e=>Ql(e,l1,!0),$N=e=>Ql(e,a1,!0),ml=(e,r,a)=>{const l=Q0.exec(e);return l?l[1]?r(l[1]):a(l[2]):!1},Ql=(e,r,a=!1)=>{const l=Z0.exec(e);return l?l[1]?r(l[1]):a:!1},W0=e=>e==="position"||e==="percentage",e1=e=>e==="image"||e==="url",t1=e=>e==="length"||e==="size"||e==="bg-size",n1=e=>e==="length",FN=e=>e==="number",r1=e=>e==="family-name",a1=e=>e==="number"||e==="weight",l1=e=>e==="shadow",VN=()=>{const e=tn("color"),r=tn("font"),a=tn("text"),l=tn("font-weight"),o=tn("tracking"),c=tn("leading"),d=tn("breakpoint"),f=tn("container"),h=tn("spacing"),m=tn("radius"),x=tn("shadow"),v=tn("inset-shadow"),b=tn("text-shadow"),y=tn("drop-shadow"),k=tn("blur"),j=tn("perspective"),T=tn("aspect"),N=tn("ease"),R=tn("animate"),D=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...I(),Ce,je],E=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],z=()=>[Ce,je,h],Y=()=>[Ya,"full","auto",...z()],q=()=>[zr,"none","subgrid",Ce,je],P=()=>["auto",{span:["full",zr,Ce,je]},zr,Ce,je],K=()=>[zr,"auto",Ce,je],ue=()=>["auto","min","max","fr",Ce,je],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],W=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...z()],F=()=>[Ya,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...z()],ae=()=>[Ya,"screen","full","dvw","lvw","svw","min","max","fit",...z()],Z=()=>[Ya,"screen","full","lh","dvh","lvh","svh","min","max","fit",...z()],A=()=>[e,Ce,je],U=()=>[...I(),eb,Wy,{position:[Ce,je]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],M=()=>["auto","cover","contain",HN,LN,{size:[Ce,je]}],se=()=>[xh,Ks,Bl],X=()=>["","none","full",m,Ce,je],ce=()=>["",We,Ks,Bl],re=()=>["solid","dashed","dotted","double"],be=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[We,xh,eb,Wy],we=()=>["","none",k,Ce,je],Ee=()=>["none",We,Ce,je],Se=()=>["none",We,Ce,je],Ie=()=>[We,Ce,je],Be=()=>[Ya,"full",...z()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[da],breakpoint:[da],color:[J0],container:[da],"drop-shadow":[da],ease:["in","out","in-out"],font:[ON],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[da],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[da],shadow:[da],spacing:["px",We],text:[da],"text-shadow":[da],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ya,je,Ce,T]}],container:["container"],"container-type":[{"@container":["","normal","size",Ce,je]}],"container-named":[zN],columns:[{columns:[We,je,Ce,f]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:Y()}],"inset-x":[{"inset-x":Y()}],"inset-y":[{"inset-y":Y()}],start:[{"inset-s":Y(),start:Y()}],end:[{"inset-e":Y(),end:Y()}],"inset-bs":[{"inset-bs":Y()}],"inset-be":[{"inset-be":Y()}],top:[{top:Y()}],right:[{right:Y()}],bottom:[{bottom:Y()}],left:[{left:Y()}],visibility:["visible","invisible","collapse"],z:[{z:[zr,"auto",Ce,je]}],basis:[{basis:[Ya,"full","auto",f,...z()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[We,Ya,"auto","initial","none",je]}],grow:[{grow:["",We,Ce,je]}],shrink:[{shrink:["",We,Ce,je]}],order:[{order:[zr,"first","last","none",Ce,je]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ue()}],"auto-rows":[{"auto-rows":ue()}],gap:[{gap:z()}],"gap-x":[{"gap-x":z()}],"gap-y":[{"gap-y":z()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...W(),"normal"]}],"justify-self":[{"justify-self":["auto",...W()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...W(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...W(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...W(),"baseline"]}],"place-self":[{"place-self":["auto",...W()]}],p:[{p:z()}],px:[{px:z()}],py:[{py:z()}],ps:[{ps:z()}],pe:[{pe:z()}],pbs:[{pbs:z()}],pbe:[{pbe:z()}],pt:[{pt:z()}],pr:[{pr:z()}],pb:[{pb:z()}],pl:[{pl:z()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mbs:[{mbs:B()}],mbe:[{mbe:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":z()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":z()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...ae()]}],"min-inline-size":[{"min-inline":["auto",...ae()]}],"max-inline-size":[{"max-inline":["none",...ae()]}],"block-size":[{block:["auto",...Z()]}],"min-block-size":[{"min-block":["auto",...Z()]}],"max-block-size":[{"max-block":["none",...Z()]}],w:[{w:[f,"screen",...F()]}],"min-w":[{"min-w":[f,"screen","none",...F()]}],"max-w":[{"max-w":[f,"screen","none","prose",{screen:[d]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",a,Ks,Bl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,$N,UN]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",xh,je]}],"font-family":[{font:[qN,BN,r]}],"font-features":[{"font-features":[je]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Ce,je]}],"line-clamp":[{"line-clamp":[We,"none",Ce,Jy]}],leading:[{leading:[c,...z()]}],"list-image":[{"list-image":["none",Ce,je]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ce,je]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[We,"from-font","auto",Ce,Bl]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[We,"auto",Ce,je]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:z()}],"tab-size":[{tab:[zr,Ce,je]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ce,je]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ce,je]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:U()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:M()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},zr,Ce,je],radial:["",Ce,je],conic:[zr,Ce,je]},PN,IN]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:X()}],"rounded-s":[{"rounded-s":X()}],"rounded-e":[{"rounded-e":X()}],"rounded-t":[{"rounded-t":X()}],"rounded-r":[{"rounded-r":X()}],"rounded-b":[{"rounded-b":X()}],"rounded-l":[{"rounded-l":X()}],"rounded-ss":[{"rounded-ss":X()}],"rounded-se":[{"rounded-se":X()}],"rounded-ee":[{"rounded-ee":X()}],"rounded-es":[{"rounded-es":X()}],"rounded-tl":[{"rounded-tl":X()}],"rounded-tr":[{"rounded-tr":X()}],"rounded-br":[{"rounded-br":X()}],"rounded-bl":[{"rounded-bl":X()}],"border-w":[{border:ce()}],"border-w-x":[{"border-x":ce()}],"border-w-y":[{"border-y":ce()}],"border-w-s":[{"border-s":ce()}],"border-w-e":[{"border-e":ce()}],"border-w-bs":[{"border-bs":ce()}],"border-w-be":[{"border-be":ce()}],"border-w-t":[{"border-t":ce()}],"border-w-r":[{"border-r":ce()}],"border-w-b":[{"border-b":ce()}],"border-w-l":[{"border-l":ce()}],"divide-x":[{"divide-x":ce()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ce()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[We,Ce,je]}],"outline-w":[{outline:["",We,Ks,Bl]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",x,Pu,Hu]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",v,Pu,Hu]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:ce()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[We,Bl]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":ce()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",b,Pu,Hu]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[We,Ce,je]}],"mix-blend":[{"mix-blend":[...be(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":be()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[We]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[Ce,je]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":I()}],"mask-image-conic-pos":[{"mask-conic":[We]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:U()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:M()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ce,je]}],filter:[{filter:["","none",Ce,je]}],blur:[{blur:we()}],brightness:[{brightness:[We,Ce,je]}],contrast:[{contrast:[We,Ce,je]}],"drop-shadow":[{"drop-shadow":["","none",y,Pu,Hu]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",We,Ce,je]}],"hue-rotate":[{"hue-rotate":[We,Ce,je]}],invert:[{invert:["",We,Ce,je]}],saturate:[{saturate:[We,Ce,je]}],sepia:[{sepia:["",We,Ce,je]}],"backdrop-filter":[{"backdrop-filter":["","none",Ce,je]}],"backdrop-blur":[{"backdrop-blur":we()}],"backdrop-brightness":[{"backdrop-brightness":[We,Ce,je]}],"backdrop-contrast":[{"backdrop-contrast":[We,Ce,je]}],"backdrop-grayscale":[{"backdrop-grayscale":["",We,Ce,je]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[We,Ce,je]}],"backdrop-invert":[{"backdrop-invert":["",We,Ce,je]}],"backdrop-opacity":[{"backdrop-opacity":[We,Ce,je]}],"backdrop-saturate":[{"backdrop-saturate":[We,Ce,je]}],"backdrop-sepia":[{"backdrop-sepia":["",We,Ce,je]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":z()}],"border-spacing-x":[{"border-spacing-x":z()}],"border-spacing-y":[{"border-spacing-y":z()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ce,je]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[We,"initial",Ce,je]}],ease:[{ease:["linear","initial",N,Ce,je]}],delay:[{delay:[We,Ce,je]}],animate:[{animate:["none",R,Ce,je]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,Ce,je]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:Ee()}],"rotate-x":[{"rotate-x":Ee()}],"rotate-y":[{"rotate-y":Ee()}],"rotate-z":[{"rotate-z":Ee()}],scale:[{scale:Se()}],"scale-x":[{"scale-x":Se()}],"scale-y":[{"scale-y":Se()}],"scale-z":[{"scale-z":Se()}],"scale-3d":["scale-3d"],skew:[{skew:Ie()}],"skew-x":[{"skew-x":Ie()}],"skew-y":[{"skew-y":Ie()}],transform:[{transform:[Ce,je,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Be()}],"translate-x":[{"translate-x":Be()}],"translate-y":[{"translate-y":Be()}],"translate-z":[{"translate-z":Be()}],"translate-none":["translate-none"],zoom:[{zoom:[zr,Ce,je]}],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ce,je]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":z()}],"scroll-mx":[{"scroll-mx":z()}],"scroll-my":[{"scroll-my":z()}],"scroll-ms":[{"scroll-ms":z()}],"scroll-me":[{"scroll-me":z()}],"scroll-mbs":[{"scroll-mbs":z()}],"scroll-mbe":[{"scroll-mbe":z()}],"scroll-mt":[{"scroll-mt":z()}],"scroll-mr":[{"scroll-mr":z()}],"scroll-mb":[{"scroll-mb":z()}],"scroll-ml":[{"scroll-ml":z()}],"scroll-p":[{"scroll-p":z()}],"scroll-px":[{"scroll-px":z()}],"scroll-py":[{"scroll-py":z()}],"scroll-ps":[{"scroll-ps":z()}],"scroll-pe":[{"scroll-pe":z()}],"scroll-pbs":[{"scroll-pbs":z()}],"scroll-pbe":[{"scroll-pbe":z()}],"scroll-pt":[{"scroll-pt":z()}],"scroll-pr":[{"scroll-pr":z()}],"scroll-pb":[{"scroll-pb":z()}],"scroll-pl":[{"scroll-pl":z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ce,je]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[We,Ks,Bl,Jy]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},GN=jN(VN);function Ne(...e){return GN(V0(e))}function i1({className:e}){return s.jsx("svg",{viewBox:"0 0 151.08 184",className:Ne("h-6 w-auto",e),"aria-hidden":"true",fill:"currentColor",children:s.jsx("path",{d:"M131.08,52.32l-18.67-10.96h-1.01l-16.68,9.79v-20.19s-18.67-10.96-18.67-10.96h-1.01l-18.67,10.96v20.19s-16.68-9.79-16.68-9.79h-1.01l-18.67,10.96v.72s0,78.5,0,78.5l18.67,11.12h1.02l16.67-9.92v20.16s18.67,11.12,18.67,11.12h1.02l18.67-11.12v-20.16s16.67,9.92,16.67,9.92h1.02l18.67-11.12V52.32ZM39.18,43.38l16.7,9.81-16.7,9.94-16.7-9.94,16.7-9.81ZM22,55.23l16.18,9.63v54.28l-16.18,9.5V55.23ZM38.18,121.46v18.57l-15.7-9.35,15.7-9.22ZM40.18,140.03v-18.57l15.7,9.22-15.7,9.35ZM56.36,128.64l-16.18-9.5v-54.28l16.18-9.63v73.41ZM92.72,53.04v19.46l-16.18-9.5v-19.49l16.18-9.63v19.16ZM75.54,84.48l-16.7-9.94,16.7-9.81,16.7,9.81-16.7,9.94ZM76.54,41.18v-18.57l15.7,9.22-15.7,9.35ZM74.54,22.61v18.57l-15.7-9.35,15.7-9.22ZM58.36,33.87l16.18,9.63v19.49l-16.18,9.5v-38.63ZM58.36,76.58l16.18,9.63v54.28l-16.18,9.5v-73.41ZM74.54,142.81v18.57l-15.7-9.35,15.7-9.22ZM76.54,161.38v-18.57l15.7,9.22-15.7,9.35ZM92.72,149.99l-16.18-9.5v-54.28l16.18-9.63v73.41ZM112.9,43.97l15.7,9.22-15.7,9.35v-18.57ZM110.9,43.97v18.57l-15.7-9.35,15.7-9.22ZM94.72,55.23l16.18,9.63v54.28l-16.18,9.5V55.23ZM111.9,140.63l-16.7-9.95,16.7-9.81,16.7,9.81-16.7,9.95ZM129.08,128.64l-16.18-9.5v-54.28l16.18-9.63v73.41Z"})})}function tb(e,r){if(typeof e=="function")return e(r);e!=null&&(e.current=r)}function Sc(...e){return r=>{let a=!1;const l=e.map(o=>{const c=tb(o,r);return!a&&typeof c=="function"&&(a=!0),c});if(a)return()=>{for(let o=0;o{const{children:a,...l}=e,o=S.Children.toArray(a),c=o.find(YN);if(c){const d=c.props.children,f=o.map(h=>h===c?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:h);return s.jsx(om,{...l,ref:r,children:S.isValidElement(d)?S.cloneElement(d,void 0,f):null})}return s.jsx(om,{...l,ref:r,children:a})});xa.displayName="Slot";var om=S.forwardRef((e,r)=>{const{children:a,...l}=e;if(S.isValidElement(a)){const o=KN(a);return S.cloneElement(a,{...XN(l,a.props),ref:r?Sc(r,o):o})}return S.Children.count(a)>1?S.Children.only(null):null});om.displayName="SlotClone";var s1=({children:e})=>s.jsx(s.Fragment,{children:e});function YN(e){return S.isValidElement(e)&&e.type===s1}function XN(e,r){const a={...r};for(const l in r){const o=e[l],c=r[l];/^on[A-Z]/.test(l)?o&&c?a[l]=(...f)=>{c(...f),o(...f)}:o&&(a[l]=o):l==="style"?a[l]={...o,...c}:l==="className"&&(a[l]=[o,c].filter(Boolean).join(" "))}return{...e,...a}}function KN(e){var l,o;let r=(l=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:l.get,a=r&&"isReactWarning"in r&&r.isReactWarning;return a?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,a=r&&"isReactWarning"in r&&r.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}const nb=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,rb=V0,o1=(e,r)=>a=>{var l;if((r==null?void 0:r.variants)==null)return rb(e,a==null?void 0:a.class,a==null?void 0:a.className);const{variants:o,defaultVariants:c}=r,d=Object.keys(o).map(m=>{const x=a==null?void 0:a[m],v=c==null?void 0:c[m];if(x===null)return null;const b=nb(x)||nb(v);return o[m][b]}),f=a&&Object.entries(a).reduce((m,x)=>{let[v,b]=x;return b===void 0||(m[v]=b),m},{}),h=r==null||(l=r.compoundVariants)===null||l===void 0?void 0:l.reduce((m,x)=>{let{class:v,className:b,...y}=x;return Object.entries(y).every(k=>{let[j,T]=k;return Array.isArray(T)?T.includes({...c,...f}[j]):{...c,...f}[j]===T})?[...m,v,b]:m},[]);return rb(e,d,h,a==null?void 0:a.class,a==null?void 0:a.className)},Vm=o1("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function Me({className:e,variant:r,size:a,asChild:l=!1,...o}){const c=l?xa:"button";return s.jsx(c,{"data-slot":"button",className:Ne(Vm({variant:r,size:a,className:e})),...o})}function Ft({className:e,type:r,...a}){return s.jsx("input",{type:r,"data-slot":"input",autoComplete:"off",className:Ne("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...a})}var yo=P0();const u1=bc(yo);var QN=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ge=QN.reduce((e,r)=>{const a=S.forwardRef((l,o)=>{const{asChild:c,...d}=l,f=c?xa:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(f,{...d,ref:o})});return a.displayName=`Primitive.${r}`,{...e,[r]:a}},{});function c1(e,r){e&&yo.flushSync(()=>e.dispatchEvent(r))}var ZN="Label",d1=S.forwardRef((e,r)=>s.jsx(Ge.label,{...e,ref:r,onMouseDown:a=>{var o;a.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}}));d1.displayName=ZN;var JN=d1;function rn({className:e,...r}){return s.jsx(JN,{"data-slot":"label",className:Ne("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...r})}/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const WN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),f1=(...e)=>e.filter((r,a,l)=>!!r&&r.trim()!==""&&l.indexOf(r)===a).join(" ").trim();/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var eE={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"};/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const tE=S.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,iconNode:d,...f},h)=>S.createElement("svg",{ref:h,...eE,width:r,height:r,stroke:e,strokeWidth:l?Number(a)*24/Number(r):a,className:f1("lucide",o),...f},[...d.map(([m,x])=>S.createElement(m,x)),...Array.isArray(c)?c:[c]]));/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ht=(e,r)=>{const a=S.forwardRef(({className:l,...o},c)=>S.createElement(tE,{ref:c,iconNode:r,className:f1(`lucide-${WN(e)}`,l),...o}));return a.displayName=`${e}`,a};/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const nE=ht("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rE=ht("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aE=ht("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const h1=ht("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lE=ht("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jc=ht("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ji=ht("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iE=ht("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const um=ht("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const sE=ht("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oE=ht("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gm=ht("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"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const uE=ht("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cE=ht("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bo=ht("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const m1=ht("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dE=ht("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fE=ht("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hE=ht("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const p1=ht("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mE=ht("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pl=ht("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pE=ht("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gE=ht("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xE=ht("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vE=ht("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"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cm=ht("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yE=ht("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ym=ht("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kc=ht("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.454.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bE=ht("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function kt({className:e,...r}){return s.jsx(fE,{role:"status","aria-label":"Loading",className:Ne("size-4 animate-spin",e),...r})}var wE="Separator",ab="horizontal",SE=["horizontal","vertical"],g1=S.forwardRef((e,r)=>{const{decorative:a,orientation:l=ab,...o}=e,c=jE(l)?l:ab,f=a?{role:"none"}:{"aria-orientation":c==="vertical"?c:void 0,role:"separator"};return s.jsx(Ge.div,{"data-orientation":c,...f,...o,ref:r})});g1.displayName=wE;function jE(e){return SE.includes(e)}var kE=g1;function lb({className:e,orientation:r="horizontal",decorative:a=!0,...l}){return s.jsx(kE,{"data-slot":"separator",decorative:a,orientation:r,className:Ne("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...l})}function Ke({className:e,...r}){return s.jsx("div",{"data-slot":"card",className:Ne("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...r})}function Ze({className:e,...r}){return s.jsx("div",{"data-slot":"card-header",className:Ne("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...r})}function Je({className:e,...r}){return s.jsx("div",{"data-slot":"card-title",className:Ne("leading-none font-semibold",e),...r})}function it({className:e,...r}){return s.jsx("div",{"data-slot":"card-description",className:Ne("text-muted-foreground text-sm",e),...r})}function CE({className:e,...r}){return s.jsx("div",{"data-slot":"card-action",className:Ne("col-start-2 row-span-2 row-start-1 self-start justify-self-end",e),...r})}function Qe({className:e,...r}){return s.jsx("div",{"data-slot":"card-content",className:Ne("px-6",e),...r})}function NE({me:e,onLogin:r}){const[a,l]=S.useState(""),[o,c]=S.useState(null),[d,f]=S.useState(!1),h=async m=>{m.preventDefault(),f(!0),c(null);try{await He.post("/auth/password",{password:a}),r()}catch(x){c(x instanceof wc?x.message:"login failed"),f(!1)}};return s.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:s.jsxs(Ke,{className:"w-full max-w-sm",children:[s.jsxs(Ze,{className:"items-center text-center",children:[s.jsx(i1,{className:"mx-auto mb-2 h-10"}),s.jsx(Je,{className:"font-serif text-2xl",children:"llmproxy"})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[e.sso_enabled&&s.jsx(Me,{className:"w-full",onClick:()=>window.location.href="/auth/login",children:"Sign in with SSO"}),e.sso_enabled&&e.password_enabled&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(lb,{className:"flex-1"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),s.jsx(lb,{className:"flex-1"})]}),e.password_enabled&&s.jsxs("form",{onSubmit:h,className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"admin-password",children:"Admin password"}),s.jsx(Ft,{id:"admin-password",type:"password",autoComplete:"current-password",value:a,onChange:m=>l(m.target.value),"aria-invalid":o!=null}),o&&s.jsx("p",{className:"text-sm text-destructive",children:o})]}),s.jsxs(Me,{type:"submit",variant:e.sso_enabled?"outline":"default",disabled:d||a==="",className:"w-full",children:[d&&s.jsx(kt,{}),"Sign in as admin"]})]}),!e.sso_enabled&&!e.password_enabled&&s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Password login is disabled and no SSO is configured. Mint a key with ",s.jsx("code",{className:"font-mono",children:"llmproxy key create"})," and use the API directly."]})]})]})})}var EE=e=>{switch(e){case"success":return _E;case"info":return RE;case"warning":return ME;case"error":return DE;default:return null}},TE=Array(12).fill(0),AE=({visible:e,className:r})=>ve.createElement("div",{className:["sonner-loading-wrapper",r].filter(Boolean).join(" "),"data-visible":e},ve.createElement("div",{className:"sonner-spinner"},TE.map((a,l)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${l}`})))),_E=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),ME=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),RE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),DE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),OE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),zE=()=>{let[e,r]=ve.useState(document.hidden);return ve.useEffect(()=>{let a=()=>{r(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),e},dm=1,LE=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let r=this.subscribers.indexOf(e);this.subscribers.splice(r,1)}),this.publish=e=>{this.subscribers.forEach(r=>r(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var r;let{message:a,...l}=e,o=typeof(e==null?void 0:e.id)=="number"||((r=e.id)==null?void 0:r.length)>0?e.id:dm++,c=this.toasts.find(f=>f.id===o),d=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),c?this.toasts=this.toasts.map(f=>f.id===o?(this.publish({...f,...e,id:o,title:a}),{...f,...e,id:o,dismissible:d,title:a}):f):this.addToast({title:a,...l,dismissible:d,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(r=>{this.subscribers.forEach(a=>a({id:r.id,dismiss:!0}))}),this.subscribers.forEach(r=>r({id:e,dismiss:!0})),e),this.message=(e,r)=>this.create({...r,message:e}),this.error=(e,r)=>this.create({...r,message:e,type:"error"}),this.success=(e,r)=>this.create({...r,type:"success",message:e}),this.info=(e,r)=>this.create({...r,type:"info",message:e}),this.warning=(e,r)=>this.create({...r,type:"warning",message:e}),this.loading=(e,r)=>this.create({...r,type:"loading",message:e}),this.promise=(e,r)=>{if(!r)return;let a;r.loading!==void 0&&(a=this.create({...r,promise:e,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let l=e instanceof Promise?e:e(),o=a!==void 0,c,d=l.then(async h=>{if(c=["resolve",h],ve.isValidElement(h))o=!1,this.create({id:a,type:"default",message:h});else if(BE(h)&&!h.ok){o=!1;let m=typeof r.error=="function"?await r.error(`HTTP error! status: ${h.status}`):r.error,x=typeof r.description=="function"?await r.description(`HTTP error! status: ${h.status}`):r.description;this.create({id:a,type:"error",message:m,description:x})}else if(r.success!==void 0){o=!1;let m=typeof r.success=="function"?await r.success(h):r.success,x=typeof r.description=="function"?await r.description(h):r.description;this.create({id:a,type:"success",message:m,description:x})}}).catch(async h=>{if(c=["reject",h],r.error!==void 0){o=!1;let m=typeof r.error=="function"?await r.error(h):r.error,x=typeof r.description=="function"?await r.description(h):r.description;this.create({id:a,type:"error",message:m,description:x})}}).finally(()=>{var h;o&&(this.dismiss(a),a=void 0),(h=r.finally)==null||h.call(r)}),f=()=>new Promise((h,m)=>d.then(()=>c[0]==="reject"?m(c[1]):h(c[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:f}:Object.assign(a,{unwrap:f})},this.custom=(e,r)=>{let a=(r==null?void 0:r.id)||dm++;return this.create({jsx:e(a),id:a,...r}),a},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Bn=new LE,UE=(e,r)=>{let a=(r==null?void 0:r.id)||dm++;return Bn.addToast({title:e,...r,id:a}),a},BE=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",IE=UE,qE=()=>Bn.toasts,HE=()=>Bn.getActiveToasts(),Ve=Object.assign(IE,{success:Bn.success,info:Bn.info,warning:Bn.warning,error:Bn.error,custom:Bn.custom,message:Bn.message,promise:Bn.promise,dismiss:Bn.dismiss,loading:Bn.loading},{getHistory:qE,getToasts:HE});function PE(e,{insertAt:r}={}){if(typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css",r==="top"&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}PE(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} +`);function $u(e){return e.label!==void 0}var $E=3,FE="32px",VE="16px",ib=4e3,GE=356,YE=14,XE=20,KE=200;function vr(...e){return e.filter(Boolean).join(" ")}function QE(e){let[r,a]=e.split("-"),l=[];return r&&l.push(r),a&&l.push(a),l}var ZE=e=>{var r,a,l,o,c,d,f,h,m,x,v;let{invert:b,toast:y,unstyled:k,interacting:j,setHeights:T,visibleToasts:N,heights:R,index:D,toasts:I,expanded:O,removeToast:E,defaultRichColors:C,closeButton:z,style:Y,cancelButtonStyle:q,actionButtonStyle:P,className:K="",descriptionClassName:ue="",duration:le,position:W,gap:B,loadingIcon:F,expandByDefault:ae,classNames:Z,icons:A,closeButtonAriaLabel:U="Close toast",pauseWhenPageIsHidden:V}=e,[M,se]=ve.useState(null),[X,ce]=ve.useState(null),[re,be]=ve.useState(!1),[fe,we]=ve.useState(!1),[Ee,Se]=ve.useState(!1),[Ie,Be]=ve.useState(!1),[Mt,Nt]=ve.useState(!1),[Et,Bt]=ve.useState(0),[Rt,Dt]=ve.useState(0),zt=ve.useRef(y.duration||le||ib),ye=ve.useRef(null),pt=ve.useRef(null),Q=D===0,Pe=D+1<=N,ne=y.type,L=y.dismissible!==!1,he=y.className||"",ke=y.descriptionClassName||"",ze=ve.useMemo(()=>R.findIndex(qe=>qe.toastId===y.id)||0,[R,y.id]),an=ve.useMemo(()=>{var qe;return(qe=y.closeButton)!=null?qe:z},[y.closeButton,z]),Tn=ve.useMemo(()=>y.duration||le||ib,[y.duration,le]),Wt=ve.useRef(0),Tt=ve.useRef(0),un=ve.useRef(0),st=ve.useRef(null),[Tr,Hn]=W.split("-"),Eo=ve.useMemo(()=>R.reduce((qe,mt,wt)=>wt>=ze?qe:qe+mt.height,0),[R,ze]),bl=zE(),ei=y.invert||b,Sa=ne==="loading";Tt.current=ve.useMemo(()=>ze*B+Eo,[ze,Eo]),ve.useEffect(()=>{zt.current=Tn},[Tn]),ve.useEffect(()=>{be(!0)},[]),ve.useEffect(()=>{let qe=pt.current;if(qe){let mt=qe.getBoundingClientRect().height;return Dt(mt),T(wt=>[{toastId:y.id,height:mt,position:y.position},...wt]),()=>T(wt=>wt.filter(jn=>jn.toastId!==y.id))}},[T,y.id]),ve.useLayoutEffect(()=>{if(!re)return;let qe=pt.current,mt=qe.style.height;qe.style.height="auto";let wt=qe.getBoundingClientRect().height;qe.style.height=mt,Dt(wt),T(jn=>jn.find(cn=>cn.toastId===y.id)?jn.map(cn=>cn.toastId===y.id?{...cn,height:wt}:cn):[{toastId:y.id,height:wt,position:y.position},...jn])},[re,y.title,y.description,T,y.id]);let yn=ve.useCallback(()=>{we(!0),Bt(Tt.current),T(qe=>qe.filter(mt=>mt.toastId!==y.id)),setTimeout(()=>{E(y)},KE)},[y,E,T,Tt]);ve.useEffect(()=>{if(y.promise&&ne==="loading"||y.duration===1/0||y.type==="loading")return;let qe;return O||j||V&&bl?(()=>{if(un.current{var mt;(mt=y.onAutoClose)==null||mt.call(y,y),yn()},zt.current)),()=>clearTimeout(qe)},[O,j,y,ne,V,bl,yn]),ve.useEffect(()=>{y.delete&&yn()},[yn,y.delete]);function ti(){var qe,mt,wt;return A!=null&&A.loading?ve.createElement("div",{className:vr(Z==null?void 0:Z.loader,(qe=y==null?void 0:y.classNames)==null?void 0:qe.loader,"sonner-loader"),"data-visible":ne==="loading"},A.loading):F?ve.createElement("div",{className:vr(Z==null?void 0:Z.loader,(mt=y==null?void 0:y.classNames)==null?void 0:mt.loader,"sonner-loader"),"data-visible":ne==="loading"},F):ve.createElement(AE,{className:vr(Z==null?void 0:Z.loader,(wt=y==null?void 0:y.classNames)==null?void 0:wt.loader),visible:ne==="loading"})}return ve.createElement("li",{tabIndex:0,ref:pt,className:vr(K,he,Z==null?void 0:Z.toast,(r=y==null?void 0:y.classNames)==null?void 0:r.toast,Z==null?void 0:Z.default,Z==null?void 0:Z[ne],(a=y==null?void 0:y.classNames)==null?void 0:a[ne]),"data-sonner-toast":"","data-rich-colors":(l=y.richColors)!=null?l:C,"data-styled":!(y.jsx||y.unstyled||k),"data-mounted":re,"data-promise":!!y.promise,"data-swiped":Mt,"data-removed":fe,"data-visible":Pe,"data-y-position":Tr,"data-x-position":Hn,"data-index":D,"data-front":Q,"data-swiping":Ee,"data-dismissible":L,"data-type":ne,"data-invert":ei,"data-swipe-out":Ie,"data-swipe-direction":X,"data-expanded":!!(O||ae&&re),style:{"--index":D,"--toasts-before":D,"--z-index":I.length-D,"--offset":`${fe?Et:Tt.current}px`,"--initial-height":ae?"auto":`${Rt}px`,...Y,...y.style},onDragEnd:()=>{Se(!1),se(null),st.current=null},onPointerDown:qe=>{Sa||!L||(ye.current=new Date,Bt(Tt.current),qe.target.setPointerCapture(qe.pointerId),qe.target.tagName!=="BUTTON"&&(Se(!0),st.current={x:qe.clientX,y:qe.clientY}))},onPointerUp:()=>{var qe,mt,wt,jn;if(Ie||!L)return;st.current=null;let cn=Number(((qe=pt.current)==null?void 0:qe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ar=Number(((mt=pt.current)==null?void 0:mt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),_r=new Date().getTime()-((wt=ye.current)==null?void 0:wt.getTime()),An=M==="x"?cn:Ar,mr=Math.abs(An)/_r;if(Math.abs(An)>=XE||mr>.11){Bt(Tt.current),(jn=y.onDismiss)==null||jn.call(y,y),ce(M==="x"?cn>0?"right":"left":Ar>0?"down":"up"),yn(),Be(!0),Nt(!1);return}Se(!1),se(null)},onPointerMove:qe=>{var mt,wt,jn,cn;if(!st.current||!L||((mt=window.getSelection())==null?void 0:mt.toString().length)>0)return;let Ar=qe.clientY-st.current.y,_r=qe.clientX-st.current.x,An=(wt=e.swipeDirections)!=null?wt:QE(W);!M&&(Math.abs(_r)>1||Math.abs(Ar)>1)&&se(Math.abs(_r)>Math.abs(Ar)?"x":"y");let mr={x:0,y:0};M==="y"?(An.includes("top")||An.includes("bottom"))&&(An.includes("top")&&Ar<0||An.includes("bottom")&&Ar>0)&&(mr.y=Ar):M==="x"&&(An.includes("left")||An.includes("right"))&&(An.includes("left")&&_r<0||An.includes("right")&&_r>0)&&(mr.x=_r),(Math.abs(mr.x)>0||Math.abs(mr.y)>0)&&Nt(!0),(jn=pt.current)==null||jn.style.setProperty("--swipe-amount-x",`${mr.x}px`),(cn=pt.current)==null||cn.style.setProperty("--swipe-amount-y",`${mr.y}px`)}},an&&!y.jsx?ve.createElement("button",{"aria-label":U,"data-disabled":Sa,"data-close-button":!0,onClick:Sa||!L?()=>{}:()=>{var qe;yn(),(qe=y.onDismiss)==null||qe.call(y,y)},className:vr(Z==null?void 0:Z.closeButton,(o=y==null?void 0:y.classNames)==null?void 0:o.closeButton)},(c=A==null?void 0:A.close)!=null?c:OE):null,y.jsx||S.isValidElement(y.title)?y.jsx?y.jsx:typeof y.title=="function"?y.title():y.title:ve.createElement(ve.Fragment,null,ne||y.icon||y.promise?ve.createElement("div",{"data-icon":"",className:vr(Z==null?void 0:Z.icon,(d=y==null?void 0:y.classNames)==null?void 0:d.icon)},y.promise||y.type==="loading"&&!y.icon?y.icon||ti():null,y.type!=="loading"?y.icon||(A==null?void 0:A[ne])||EE(ne):null):null,ve.createElement("div",{"data-content":"",className:vr(Z==null?void 0:Z.content,(f=y==null?void 0:y.classNames)==null?void 0:f.content)},ve.createElement("div",{"data-title":"",className:vr(Z==null?void 0:Z.title,(h=y==null?void 0:y.classNames)==null?void 0:h.title)},typeof y.title=="function"?y.title():y.title),y.description?ve.createElement("div",{"data-description":"",className:vr(ue,ke,Z==null?void 0:Z.description,(m=y==null?void 0:y.classNames)==null?void 0:m.description)},typeof y.description=="function"?y.description():y.description):null),S.isValidElement(y.cancel)?y.cancel:y.cancel&&$u(y.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:y.cancelButtonStyle||q,onClick:qe=>{var mt,wt;$u(y.cancel)&&L&&((wt=(mt=y.cancel).onClick)==null||wt.call(mt,qe),yn())},className:vr(Z==null?void 0:Z.cancelButton,(x=y==null?void 0:y.classNames)==null?void 0:x.cancelButton)},y.cancel.label):null,S.isValidElement(y.action)?y.action:y.action&&$u(y.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:y.actionButtonStyle||P,onClick:qe=>{var mt,wt;$u(y.action)&&((wt=(mt=y.action).onClick)==null||wt.call(mt,qe),!qe.defaultPrevented&&yn())},className:vr(Z==null?void 0:Z.actionButton,(v=y==null?void 0:y.classNames)==null?void 0:v.actionButton)},y.action.label):null))};function sb(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function JE(e,r){let a={};return[e,r].forEach((l,o)=>{let c=o===1,d=c?"--mobile-offset":"--offset",f=c?VE:FE;function h(m){["top","right","bottom","left"].forEach(x=>{a[`${d}-${x}`]=typeof m=="number"?`${m}px`:m})}typeof l=="number"||typeof l=="string"?h(l):typeof l=="object"?["top","right","bottom","left"].forEach(m=>{l[m]===void 0?a[`${d}-${m}`]=f:a[`${d}-${m}`]=typeof l[m]=="number"?`${l[m]}px`:l[m]}):h(f)}),a}var WE=S.forwardRef(function(e,r){let{invert:a,position:l="bottom-right",hotkey:o=["altKey","KeyT"],expand:c,closeButton:d,className:f,offset:h,mobileOffset:m,theme:x="light",richColors:v,duration:b,style:y,visibleToasts:k=$E,toastOptions:j,dir:T=sb(),gap:N=YE,loadingIcon:R,icons:D,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:O}=e,[E,C]=ve.useState([]),z=ve.useMemo(()=>Array.from(new Set([l].concat(E.filter(V=>V.position).map(V=>V.position)))),[E,l]),[Y,q]=ve.useState([]),[P,K]=ve.useState(!1),[ue,le]=ve.useState(!1),[W,B]=ve.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=ve.useRef(null),ae=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),Z=ve.useRef(null),A=ve.useRef(!1),U=ve.useCallback(V=>{C(M=>{var se;return(se=M.find(X=>X.id===V.id))!=null&&se.delete||Bn.dismiss(V.id),M.filter(({id:X})=>X!==V.id)})},[]);return ve.useEffect(()=>Bn.subscribe(V=>{if(V.dismiss){C(M=>M.map(se=>se.id===V.id?{...se,delete:!0}:se));return}setTimeout(()=>{u1.flushSync(()=>{C(M=>{let se=M.findIndex(X=>X.id===V.id);return se!==-1?[...M.slice(0,se),{...M[se],...V},...M.slice(se+1)]:[V,...M]})})})}),[]),ve.useEffect(()=>{if(x!=="system"){B(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?B("dark"):B("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:M})=>{B(M?"dark":"light")})}catch{V.addListener(({matches:se})=>{try{B(se?"dark":"light")}catch(X){console.error(X)}})}},[x]),ve.useEffect(()=>{E.length<=1&&K(!1)},[E]),ve.useEffect(()=>{let V=M=>{var se,X;o.every(ce=>M[ce]||M.code===ce)&&(K(!0),(se=F.current)==null||se.focus()),M.code==="Escape"&&(document.activeElement===F.current||(X=F.current)!=null&&X.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[o]),ve.useEffect(()=>{if(F.current)return()=>{Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null,A.current=!1)}},[F.current]),ve.createElement("section",{ref:r,"aria-label":`${I} ${ae}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},z.map((V,M)=>{var se;let[X,ce]=V.split("-");return E.length?ve.createElement("ol",{key:V,dir:T==="auto"?sb():T,tabIndex:-1,ref:F,className:f,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":X,"data-lifted":P&&E.length>1&&!c,"data-x-position":ce,style:{"--front-toast-height":`${((se=Y[0])==null?void 0:se.height)||0}px`,"--width":`${GE}px`,"--gap":`${N}px`,...y,...JE(h,m)},onBlur:re=>{A.current&&!re.currentTarget.contains(re.relatedTarget)&&(A.current=!1,Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||A.current||(A.current=!0,Z.current=re.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{ue||K(!1)},onDragEnd:()=>K(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||le(!0)},onPointerUp:()=>le(!1)},E.filter(re=>!re.position&&M===0||re.position===V).map((re,be)=>{var fe,we;return ve.createElement(ZE,{key:re.id,icons:D,index:be,toast:re,defaultRichColors:v,duration:(fe=j==null?void 0:j.duration)!=null?fe:b,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:a,visibleToasts:k,closeButton:(we=j==null?void 0:j.closeButton)!=null?we:d,interacting:ue,position:V,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:U,toasts:E.filter(Ee=>Ee.position==re.position),heights:Y.filter(Ee=>Ee.position==re.position),setHeights:q,expandByDefault:c,gap:N,loadingIcon:R,expanded:P,pauseWhenPageIsHidden:O,swipeDirections:e.swipeDirections})})):null}))});function Ut(e,r=[]){const[a,l]=S.useState(null),[o,c]=S.useState(null),[d,f]=S.useState(!0),h=S.useRef(e);h.current=e;const m=S.useCallback(()=>{f(!0),h.current().then(x=>{l(x),c(null)}).catch(x=>{c(x instanceof wc?x.message:String(x))}).finally(()=>f(!1))},r);return S.useEffect(()=>{m()},[m]),{data:a,error:o,loading:d,reload:m}}function gn({className:e,...r}){return s.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:s.jsx("table",{"data-slot":"table",className:Ne("w-full caption-bottom text-sm",e),...r})})}function xn({className:e,...r}){return s.jsx("thead",{"data-slot":"table-header",className:Ne("[&_tr]:border-b",e),...r})}function vn({className:e,...r}){return s.jsx("tbody",{"data-slot":"table-body",className:Ne("[&_tr:last-child]:border-0",e),...r})}function Oe({className:e,...r}){return s.jsx("tr",{"data-slot":"table-row",className:Ne("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function ge({className:e,...r}){return s.jsx("th",{"data-slot":"table-head",className:Ne("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function de({className:e,...r}){return s.jsx("td",{"data-slot":"table-cell",className:Ne("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function eT(e,r){const a=S.createContext(r),l=c=>{const{children:d,...f}=c,h=S.useMemo(()=>f,Object.values(f));return s.jsx(a.Provider,{value:h,children:d})};l.displayName=e+"Provider";function o(c){const d=S.useContext(a);if(d)return d;if(r!==void 0)return r;throw new Error(`\`${c}\` must be used within \`${e}\``)}return[l,o]}function Nr(e,r=[]){let a=[];function l(c,d){const f=S.createContext(d),h=a.length;a=[...a,d];const m=v=>{var N;const{scope:b,children:y,...k}=v,j=((N=b==null?void 0:b[e])==null?void 0:N[h])||f,T=S.useMemo(()=>k,Object.values(k));return s.jsx(j.Provider,{value:T,children:y})};m.displayName=c+"Provider";function x(v,b){var j;const y=((j=b==null?void 0:b[e])==null?void 0:j[h])||f,k=S.useContext(y);if(k)return k;if(d!==void 0)return d;throw new Error(`\`${v}\` must be used within \`${c}\``)}return[m,x]}const o=()=>{const c=a.map(d=>S.createContext(d));return function(f){const h=(f==null?void 0:f[e])||c;return S.useMemo(()=>({[`__scope${e}`]:{...f,[e]:h}}),[f,h])}};return o.scopeName=e,[l,tT(o,...r)]}function tT(...e){const r=e[0];if(e.length===1)return r;const a=()=>{const l=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const d=l.reduce((f,{useScope:h,scopeName:m})=>{const v=h(c)[`__scope${m}`];return{...f,...v}},{});return S.useMemo(()=>({[`__scope${r.scopeName}`]:d}),[d])}};return a.scopeName=r.scopeName,a}function Ae(e,r,{checkForDefaultPrevented:a=!0}={}){return function(o){if(e==null||e(o),a===!1||!o.defaultPrevented)return r==null?void 0:r(o)}}var Nn=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},nT=Y2.useId||(()=>{}),rT=0;function Pr(e){const[r,a]=S.useState(nT());return Nn(()=>{a(l=>l??String(rT++))},[e]),e||(r?`radix-${r}`:"")}function fr(e){const r=S.useRef(e);return S.useEffect(()=>{r.current=e}),S.useMemo(()=>(...a)=>{var l;return(l=r.current)==null?void 0:l.call(r,...a)},[])}function nl({prop:e,defaultProp:r,onChange:a=()=>{}}){const[l,o]=aT({defaultProp:r,onChange:a}),c=e!==void 0,d=c?e:l,f=fr(a),h=S.useCallback(m=>{if(c){const v=typeof m=="function"?m(e):m;v!==e&&f(v)}else o(m)},[c,e,o,f]);return[d,h]}function aT({defaultProp:e,onChange:r}){const a=S.useState(e),[l]=a,o=S.useRef(l),c=fr(r);return S.useEffect(()=>{o.current!==l&&(c(l),o.current=l)},[l,o,c]),a}function lT(e,r=globalThis==null?void 0:globalThis.document){const a=fr(e);S.useEffect(()=>{const l=o=>{o.key==="Escape"&&a(o)};return r.addEventListener("keydown",l,{capture:!0}),()=>r.removeEventListener("keydown",l,{capture:!0})},[a,r])}var iT="DismissableLayer",fm="dismissableLayer.update",sT="dismissableLayer.pointerDownOutside",oT="dismissableLayer.focusOutside",ob,x1=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Cc=S.forwardRef((e,r)=>{const{disableOutsidePointerEvents:a=!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:c,onInteractOutside:d,onDismiss:f,...h}=e,m=S.useContext(x1),[x,v]=S.useState(null),b=(x==null?void 0:x.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=S.useState({}),k=ft(r,C=>v(C)),j=Array.from(m.layers),[T]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(T),R=x?j.indexOf(x):-1,D=m.layersWithOutsidePointerEventsDisabled.size>0,I=R>=N,O=dT(C=>{const z=C.target,Y=[...m.branches].some(q=>q.contains(z));!I||Y||(o==null||o(C),d==null||d(C),C.defaultPrevented||f==null||f())},b),E=fT(C=>{const z=C.target;[...m.branches].some(q=>q.contains(z))||(c==null||c(C),d==null||d(C),C.defaultPrevented||f==null||f())},b);return lT(C=>{R===m.layers.size-1&&(l==null||l(C),!C.defaultPrevented&&f&&(C.preventDefault(),f()))},b),S.useEffect(()=>{if(x)return a&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(ob=b.body.style.pointerEvents,b.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(x)),m.layers.add(x),ub(),()=>{a&&m.layersWithOutsidePointerEventsDisabled.size===1&&(b.body.style.pointerEvents=ob)}},[x,b,a,m]),S.useEffect(()=>()=>{x&&(m.layers.delete(x),m.layersWithOutsidePointerEventsDisabled.delete(x),ub())},[x,m]),S.useEffect(()=>{const C=()=>y({});return document.addEventListener(fm,C),()=>document.removeEventListener(fm,C)},[]),s.jsx(Ge.div,{...h,ref:k,style:{pointerEvents:D?I?"auto":"none":void 0,...e.style},onFocusCapture:Ae(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Ae(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ae(e.onPointerDownCapture,O.onPointerDownCapture)})});Cc.displayName=iT;var uT="DismissableLayerBranch",cT=S.forwardRef((e,r)=>{const a=S.useContext(x1),l=S.useRef(null),o=ft(r,l);return S.useEffect(()=>{const c=l.current;if(c)return a.branches.add(c),()=>{a.branches.delete(c)}},[a.branches]),s.jsx(Ge.div,{...e,ref:o})});cT.displayName=uT;function dT(e,r=globalThis==null?void 0:globalThis.document){const a=fr(e),l=S.useRef(!1),o=S.useRef(()=>{});return S.useEffect(()=>{const c=f=>{if(f.target&&!l.current){let h=function(){v1(sT,a,m,{discrete:!0})};const m={originalEvent:f};f.pointerType==="touch"?(r.removeEventListener("click",o.current),o.current=h,r.addEventListener("click",o.current,{once:!0})):h()}else r.removeEventListener("click",o.current);l.current=!1},d=window.setTimeout(()=>{r.addEventListener("pointerdown",c)},0);return()=>{window.clearTimeout(d),r.removeEventListener("pointerdown",c),r.removeEventListener("click",o.current)}},[r,a]),{onPointerDownCapture:()=>l.current=!0}}function fT(e,r=globalThis==null?void 0:globalThis.document){const a=fr(e),l=S.useRef(!1);return S.useEffect(()=>{const o=c=>{c.target&&!l.current&&v1(oT,a,{originalEvent:c},{discrete:!1})};return r.addEventListener("focusin",o),()=>r.removeEventListener("focusin",o)},[r,a]),{onFocusCapture:()=>l.current=!0,onBlurCapture:()=>l.current=!1}}function ub(){const e=new CustomEvent(fm);document.dispatchEvent(e)}function v1(e,r,a,{discrete:l}){const o=a.originalEvent.target,c=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});r&&o.addEventListener(e,r,{once:!0}),l?c1(o,c):o.dispatchEvent(c)}var vh="focusScope.autoFocusOnMount",yh="focusScope.autoFocusOnUnmount",cb={bubbles:!1,cancelable:!0},hT="FocusScope",Nc=S.forwardRef((e,r)=>{const{loop:a=!1,trapped:l=!1,onMountAutoFocus:o,onUnmountAutoFocus:c,...d}=e,[f,h]=S.useState(null),m=fr(o),x=fr(c),v=S.useRef(null),b=ft(r,j=>h(j)),y=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(l){let j=function(D){if(y.paused||!f)return;const I=D.target;f.contains(I)?v.current=I:Qa(v.current,{select:!0})},T=function(D){if(y.paused||!f)return;const I=D.relatedTarget;I!==null&&(f.contains(I)||Qa(v.current,{select:!0}))},N=function(D){if(document.activeElement===document.body)for(const O of D)O.removedNodes.length>0&&Qa(f)};document.addEventListener("focusin",j),document.addEventListener("focusout",T);const R=new MutationObserver(N);return f&&R.observe(f,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",T),R.disconnect()}}},[l,f,y.paused]),S.useEffect(()=>{if(f){fb.add(y);const j=document.activeElement;if(!f.contains(j)){const N=new CustomEvent(vh,cb);f.addEventListener(vh,m),f.dispatchEvent(N),N.defaultPrevented||(mT(yT(y1(f)),{select:!0}),document.activeElement===j&&Qa(f))}return()=>{f.removeEventListener(vh,m),setTimeout(()=>{const N=new CustomEvent(yh,cb);f.addEventListener(yh,x),f.dispatchEvent(N),N.defaultPrevented||Qa(j??document.body,{select:!0}),f.removeEventListener(yh,x),fb.remove(y)},0)}}},[f,m,x,y]);const k=S.useCallback(j=>{if(!a&&!l||y.paused)return;const T=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(T&&N){const R=j.currentTarget,[D,I]=pT(R);D&&I?!j.shiftKey&&N===I?(j.preventDefault(),a&&Qa(D,{select:!0})):j.shiftKey&&N===D&&(j.preventDefault(),a&&Qa(I,{select:!0})):N===R&&j.preventDefault()}},[a,l,y.paused]);return s.jsx(Ge.div,{tabIndex:-1,...d,ref:b,onKeyDown:k})});Nc.displayName=hT;function mT(e,{select:r=!1}={}){const a=document.activeElement;for(const l of e)if(Qa(l,{select:r}),document.activeElement!==a)return}function pT(e){const r=y1(e),a=db(r,e),l=db(r.reverse(),e);return[a,l]}function y1(e){const r=[],a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:l=>{const o=l.tagName==="INPUT"&&l.type==="hidden";return l.disabled||l.hidden||o?NodeFilter.FILTER_SKIP:l.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;a.nextNode();)r.push(a.currentNode);return r}function db(e,r){for(const a of e)if(!gT(a,{upTo:r}))return a}function gT(e,{upTo:r}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(r!==void 0&&e===r)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function xT(e){return e instanceof HTMLInputElement&&"select"in e}function Qa(e,{select:r=!1}={}){if(e&&e.focus){const a=document.activeElement;e.focus({preventScroll:!0}),e!==a&&xT(e)&&r&&e.select()}}var fb=vT();function vT(){let e=[];return{add(r){const a=e[0];r!==a&&(a==null||a.pause()),e=hb(e,r),e.unshift(r)},remove(r){var a;e=hb(e,r),(a=e[0])==null||a.resume()}}}function hb(e,r){const a=[...e],l=a.indexOf(r);return l!==-1&&a.splice(l,1),a}function yT(e){return e.filter(r=>r.tagName!=="A")}var bT="Portal",Ec=S.forwardRef((e,r)=>{var f;const{container:a,...l}=e,[o,c]=S.useState(!1);Nn(()=>c(!0),[]);const d=a||o&&((f=globalThis==null?void 0:globalThis.document)==null?void 0:f.body);return d?u1.createPortal(s.jsx(Ge.div,{...l,ref:r}),d):null});Ec.displayName=bT;function wT(e,r){return S.useReducer((a,l)=>r[a][l]??a,e)}var Vr=e=>{const{present:r,children:a}=e,l=ST(r),o=typeof a=="function"?a({present:l.isPresent}):S.Children.only(a),c=ft(l.ref,jT(o));return typeof a=="function"||l.isPresent?S.cloneElement(o,{ref:c}):null};Vr.displayName="Presence";function ST(e){const[r,a]=S.useState(),l=S.useRef({}),o=S.useRef(e),c=S.useRef("none"),d=e?"mounted":"unmounted",[f,h]=wT(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const m=Fu(l.current);c.current=f==="mounted"?m:"none"},[f]),Nn(()=>{const m=l.current,x=o.current;if(x!==e){const b=c.current,y=Fu(m);e?h("MOUNT"):y==="none"||(m==null?void 0:m.display)==="none"?h("UNMOUNT"):h(x&&b!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),Nn(()=>{if(r){let m;const x=r.ownerDocument.defaultView??window,v=y=>{const j=Fu(l.current).includes(y.animationName);if(y.target===r&&j&&(h("ANIMATION_END"),!o.current)){const T=r.style.animationFillMode;r.style.animationFillMode="forwards",m=x.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=T)})}},b=y=>{y.target===r&&(c.current=Fu(l.current))};return r.addEventListener("animationstart",b),r.addEventListener("animationcancel",v),r.addEventListener("animationend",v),()=>{x.clearTimeout(m),r.removeEventListener("animationstart",b),r.removeEventListener("animationcancel",v),r.removeEventListener("animationend",v)}}else h("ANIMATION_END")},[r,h]),{isPresent:["mounted","unmountSuspended"].includes(f),ref:S.useCallback(m=>{m&&(l.current=getComputedStyle(m)),a(m)},[])}}function Fu(e){return(e==null?void 0:e.animationName)||"none"}function jT(e){var l,o;let r=(l=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:l.get,a=r&&"isReactWarning"in r&&r.isReactWarning;return a?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,a=r&&"isReactWarning"in r&&r.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var bh=0;function Xm(){S.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??mb()),document.body.insertAdjacentElement("beforeend",e[1]??mb()),bh++,()=>{bh===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),bh--}},[])}function mb(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var qr=function(){return qr=Object.assign||function(r){for(var a,l=1,o=arguments.length;l"u")return qT;var r=HT(e),a=document.documentElement.clientWidth,l=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,l-a+r[2]-r[0])}},$T=j1(),Yi="data-scroll-locked",FT=function(e,r,a,l){var o=e.left,c=e.top,d=e.right,f=e.gap;return a===void 0&&(a="margin"),` + .`.concat(CT,` { + overflow: hidden `).concat(l,`; + padding-right: `).concat(f,"px ").concat(l,`; + } + body[`).concat(Yi,`] { + overflow: hidden `).concat(l,`; + overscroll-behavior: contain; + `).concat([r&&"position: relative ".concat(l,";"),a==="margin"&&` + padding-left: `.concat(o,`px; + padding-top: `).concat(c,`px; + padding-right: `).concat(d,`px; + margin-left:0; + margin-top:0; + margin-right: `).concat(f,"px ").concat(l,`; + `),a==="padding"&&"padding-right: ".concat(f,"px ").concat(l,";")].filter(Boolean).join(""),` + } + + .`).concat(rc,` { + right: `).concat(f,"px ").concat(l,`; + } + + .`).concat(ac,` { + margin-right: `).concat(f,"px ").concat(l,`; + } + + .`).concat(rc," .").concat(rc,` { + right: 0 `).concat(l,`; + } + + .`).concat(ac," .").concat(ac,` { + margin-right: 0 `).concat(l,`; + } + + body[`).concat(Yi,`] { + `).concat(NT,": ").concat(f,`px; + } +`)},gb=function(){var e=parseInt(document.body.getAttribute(Yi)||"0",10);return isFinite(e)?e:0},VT=function(){S.useEffect(function(){return document.body.setAttribute(Yi,(gb()+1).toString()),function(){var e=gb()-1;e<=0?document.body.removeAttribute(Yi):document.body.setAttribute(Yi,e.toString())}},[])},GT=function(e){var r=e.noRelative,a=e.noImportant,l=e.gapMode,o=l===void 0?"margin":l;VT();var c=S.useMemo(function(){return PT(o)},[o]);return S.createElement($T,{styles:FT(c,!r,o,a?"":"!important")})},hm=!1;if(typeof window<"u")try{var Vu=Object.defineProperty({},"passive",{get:function(){return hm=!0,!0}});window.addEventListener("test",Vu,Vu),window.removeEventListener("test",Vu,Vu)}catch{hm=!1}var qi=hm?{passive:!1}:!1,YT=function(e){return e.tagName==="TEXTAREA"},k1=function(e,r){if(!(e instanceof Element))return!1;var a=window.getComputedStyle(e);return a[r]!=="hidden"&&!(a.overflowY===a.overflowX&&!YT(e)&&a[r]==="visible")},XT=function(e){return k1(e,"overflowY")},KT=function(e){return k1(e,"overflowX")},xb=function(e,r){var a=r.ownerDocument,l=r;do{typeof ShadowRoot<"u"&&l instanceof ShadowRoot&&(l=l.host);var o=C1(e,l);if(o){var c=N1(e,l),d=c[1],f=c[2];if(d>f)return!0}l=l.parentNode}while(l&&l!==a.body);return!1},QT=function(e){var r=e.scrollTop,a=e.scrollHeight,l=e.clientHeight;return[r,a,l]},ZT=function(e){var r=e.scrollLeft,a=e.scrollWidth,l=e.clientWidth;return[r,a,l]},C1=function(e,r){return e==="v"?XT(r):KT(r)},N1=function(e,r){return e==="v"?QT(r):ZT(r)},JT=function(e,r){return e==="h"&&r==="rtl"?-1:1},WT=function(e,r,a,l,o){var c=JT(e,window.getComputedStyle(r).direction),d=c*l,f=a.target,h=r.contains(f),m=!1,x=d>0,v=0,b=0;do{if(!f)break;var y=N1(e,f),k=y[0],j=y[1],T=y[2],N=j-T-c*k;(k||N)&&C1(e,f)&&(v+=N,b+=k);var R=f.parentNode;f=R&&R.nodeType===Node.DOCUMENT_FRAGMENT_NODE?R.host:R}while(!h&&f!==document.body||h&&(r.contains(f)||r===f));return(x&&Math.abs(v)<1||!x&&Math.abs(b)<1)&&(m=!0),m},Gu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},vb=function(e){return[e.deltaX,e.deltaY]},yb=function(e){return e&&"current"in e?e.current:e},eA=function(e,r){return e[0]===r[0]&&e[1]===r[1]},tA=function(e){return` + .block-interactivity-`.concat(e,` {pointer-events: none;} + .allow-interactivity-`).concat(e,` {pointer-events: all;} +`)},nA=0,Hi=[];function rA(e){var r=S.useRef([]),a=S.useRef([0,0]),l=S.useRef(),o=S.useState(nA++)[0],c=S.useState(j1)[0],d=S.useRef(e);S.useEffect(function(){d.current=e},[e]),S.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var j=kT([e.lockRef.current],(e.shards||[]).map(yb),!0).filter(Boolean);return j.forEach(function(T){return T.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),j.forEach(function(T){return T.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var f=S.useCallback(function(j,T){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!d.current.allowPinchZoom;var N=Gu(j),R=a.current,D="deltaX"in j?j.deltaX:R[0]-N[0],I="deltaY"in j?j.deltaY:R[1]-N[1],O,E=j.target,C=Math.abs(D)>Math.abs(I)?"h":"v";if("touches"in j&&C==="h"&&E.type==="range")return!1;var z=window.getSelection(),Y=z&&z.anchorNode,q=Y?Y===E||Y.contains(E):!1;if(q)return!1;var P=xb(C,E);if(!P)return!0;if(P?O=C:(O=C==="v"?"h":"v",P=xb(C,E)),!P)return!1;if(!l.current&&"changedTouches"in j&&(D||I)&&(l.current=O),!O)return!0;var K=l.current||O;return WT(K,T,j,K==="h"?D:I)},[]),h=S.useCallback(function(j){var T=j;if(!(!Hi.length||Hi[Hi.length-1]!==c)){var N="deltaY"in T?vb(T):Gu(T),R=r.current.filter(function(O){return O.name===T.type&&(O.target===T.target||T.target===O.shadowParent)&&eA(O.delta,N)})[0];if(R&&R.should){T.cancelable&&T.preventDefault();return}if(!R){var D=(d.current.shards||[]).map(yb).filter(Boolean).filter(function(O){return O.contains(T.target)}),I=D.length>0?f(T,D[0]):!d.current.noIsolation;I&&T.cancelable&&T.preventDefault()}}},[]),m=S.useCallback(function(j,T,N,R){var D={name:j,delta:T,target:N,should:R,shadowParent:aA(N)};r.current.push(D),setTimeout(function(){r.current=r.current.filter(function(I){return I!==D})},1)},[]),x=S.useCallback(function(j){a.current=Gu(j),l.current=void 0},[]),v=S.useCallback(function(j){m(j.type,vb(j),j.target,f(j,e.lockRef.current))},[]),b=S.useCallback(function(j){m(j.type,Gu(j),j.target,f(j,e.lockRef.current))},[]);S.useEffect(function(){return Hi.push(c),e.setCallbacks({onScrollCapture:v,onWheelCapture:v,onTouchMoveCapture:b}),document.addEventListener("wheel",h,qi),document.addEventListener("touchmove",h,qi),document.addEventListener("touchstart",x,qi),function(){Hi=Hi.filter(function(j){return j!==c}),document.removeEventListener("wheel",h,qi),document.removeEventListener("touchmove",h,qi),document.removeEventListener("touchstart",x,qi)}},[]);var y=e.removeScrollBar,k=e.inert;return S.createElement(S.Fragment,null,k?S.createElement(c,{styles:tA(o)}):null,y?S.createElement(GT,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aA(e){for(var r=null;e!==null;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}const lA=DT(S1,rA);var Ac=S.forwardRef(function(e,r){return S.createElement(Tc,qr({},e,{ref:r,sideCar:lA}))});Ac.classNames=Tc.classNames;var iA=function(e){if(typeof document>"u")return null;var r=Array.isArray(e)?e[0]:e;return r.ownerDocument.body},Pi=new WeakMap,Yu=new WeakMap,Xu={},kh=0,E1=function(e){return e&&(e.host||E1(e.parentNode))},sA=function(e,r){return r.map(function(a){if(e.contains(a))return a;var l=E1(a);return l&&e.contains(l)?l:(console.error("aria-hidden",a,"in not contained inside",e,". Doing nothing"),null)}).filter(function(a){return!!a})},oA=function(e,r,a,l){var o=sA(r,Array.isArray(e)?e:[e]);Xu[a]||(Xu[a]=new WeakMap);var c=Xu[a],d=[],f=new Set,h=new Set(o),m=function(v){!v||f.has(v)||(f.add(v),m(v.parentNode))};o.forEach(m);var x=function(v){!v||h.has(v)||Array.prototype.forEach.call(v.children,function(b){if(f.has(b))x(b);else try{var y=b.getAttribute(l),k=y!==null&&y!=="false",j=(Pi.get(b)||0)+1,T=(c.get(b)||0)+1;Pi.set(b,j),c.set(b,T),d.push(b),j===1&&k&&Yu.set(b,!0),T===1&&b.setAttribute(a,"true"),k||b.setAttribute(l,"true")}catch(N){console.error("aria-hidden: cannot operate on ",b,N)}})};return x(r),f.clear(),kh++,function(){d.forEach(function(v){var b=Pi.get(v)-1,y=c.get(v)-1;Pi.set(v,b),c.set(v,y),b||(Yu.has(v)||v.removeAttribute(l),Yu.delete(v)),y||v.removeAttribute(a)}),kh--,kh||(Pi=new WeakMap,Pi=new WeakMap,Yu=new WeakMap,Xu={})}},Km=function(e,r,a){a===void 0&&(a="data-aria-hidden");var l=Array.from(Array.isArray(e)?e:[e]),o=iA(e);return o?(l.push.apply(l,Array.from(o.querySelectorAll("[aria-live], script"))),oA(l,o,a,"aria-hidden")):function(){return null}},Qm="Dialog",[T1,A1]=Nr(Qm),[uA,Er]=T1(Qm),_1=e=>{const{__scopeDialog:r,children:a,open:l,defaultOpen:o,onOpenChange:c,modal:d=!0}=e,f=S.useRef(null),h=S.useRef(null),[m=!1,x]=nl({prop:l,defaultProp:o,onChange:c});return s.jsx(uA,{scope:r,triggerRef:f,contentRef:h,contentId:Pr(),titleId:Pr(),descriptionId:Pr(),open:m,onOpenChange:x,onOpenToggle:S.useCallback(()=>x(v=>!v),[x]),modal:d,children:a})};_1.displayName=Qm;var M1="DialogTrigger",R1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=Er(M1,a),c=ft(r,o.triggerRef);return s.jsx(Ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Wm(o.open),...l,ref:c,onClick:Ae(e.onClick,o.onOpenToggle)})});R1.displayName=M1;var Zm="DialogPortal",[cA,D1]=T1(Zm,{forceMount:void 0}),O1=e=>{const{__scopeDialog:r,forceMount:a,children:l,container:o}=e,c=Er(Zm,r);return s.jsx(cA,{scope:r,forceMount:a,children:S.Children.map(l,d=>s.jsx(Vr,{present:a||c.open,children:s.jsx(Ec,{asChild:!0,container:o,children:d})}))})};O1.displayName=Zm;var oc="DialogOverlay",z1=S.forwardRef((e,r)=>{const a=D1(oc,e.__scopeDialog),{forceMount:l=a.forceMount,...o}=e,c=Er(oc,e.__scopeDialog);return c.modal?s.jsx(Vr,{present:l||c.open,children:s.jsx(dA,{...o,ref:r})}):null});z1.displayName=oc;var dA=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=Er(oc,a);return s.jsx(Ac,{as:xa,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Ge.div,{"data-state":Wm(o.open),...l,ref:r,style:{pointerEvents:"auto",...l.style}})})}),Fl="DialogContent",L1=S.forwardRef((e,r)=>{const a=D1(Fl,e.__scopeDialog),{forceMount:l=a.forceMount,...o}=e,c=Er(Fl,e.__scopeDialog);return s.jsx(Vr,{present:l||c.open,children:c.modal?s.jsx(fA,{...o,ref:r}):s.jsx(hA,{...o,ref:r})})});L1.displayName=Fl;var fA=S.forwardRef((e,r)=>{const a=Er(Fl,e.__scopeDialog),l=S.useRef(null),o=ft(r,a.contentRef,l);return S.useEffect(()=>{const c=l.current;if(c)return Km(c)},[]),s.jsx(U1,{...e,ref:o,trapFocus:a.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(e.onCloseAutoFocus,c=>{var d;c.preventDefault(),(d=a.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Ae(e.onPointerDownOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0;(d.button===2||f)&&c.preventDefault()}),onFocusOutside:Ae(e.onFocusOutside,c=>c.preventDefault())})}),hA=S.forwardRef((e,r)=>{const a=Er(Fl,e.__scopeDialog),l=S.useRef(!1),o=S.useRef(!1);return s.jsx(U1,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:c=>{var d,f;(d=e.onCloseAutoFocus)==null||d.call(e,c),c.defaultPrevented||(l.current||(f=a.triggerRef.current)==null||f.focus(),c.preventDefault()),l.current=!1,o.current=!1},onInteractOutside:c=>{var h,m;(h=e.onInteractOutside)==null||h.call(e,c),c.defaultPrevented||(l.current=!0,c.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const d=c.target;((m=a.triggerRef.current)==null?void 0:m.contains(d))&&c.preventDefault(),c.detail.originalEvent.type==="focusin"&&o.current&&c.preventDefault()}})}),U1=S.forwardRef((e,r)=>{const{__scopeDialog:a,trapFocus:l,onOpenAutoFocus:o,onCloseAutoFocus:c,...d}=e,f=Er(Fl,a),h=S.useRef(null),m=ft(r,h);return Xm(),s.jsxs(s.Fragment,{children:[s.jsx(Nc,{asChild:!0,loop:!0,trapped:l,onMountAutoFocus:o,onUnmountAutoFocus:c,children:s.jsx(Cc,{role:"dialog",id:f.contentId,"aria-describedby":f.descriptionId,"aria-labelledby":f.titleId,"data-state":Wm(f.open),...d,ref:m,onDismiss:()=>f.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(pA,{titleId:f.titleId}),s.jsx(xA,{contentRef:h,descriptionId:f.descriptionId})]})]})}),Jm="DialogTitle",B1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=Er(Jm,a);return s.jsx(Ge.h2,{id:o.titleId,...l,ref:r})});B1.displayName=Jm;var I1="DialogDescription",q1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=Er(I1,a);return s.jsx(Ge.p,{id:o.descriptionId,...l,ref:r})});q1.displayName=I1;var H1="DialogClose",P1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=Er(H1,a);return s.jsx(Ge.button,{type:"button",...l,ref:r,onClick:Ae(e.onClick,()=>o.onOpenChange(!1))})});P1.displayName=H1;function Wm(e){return e?"open":"closed"}var $1="DialogTitleWarning",[mA,F1]=eT($1,{contentName:Fl,titleName:Jm,docsSlug:"dialog"}),pA=({titleId:e})=>{const r=F1($1),a=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users. + +If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component. + +For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return S.useEffect(()=>{e&&(document.getElementById(e)||console.error(a))},[a,e]),null},gA="DialogDescriptionWarning",xA=({contentRef:e,descriptionId:r})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${F1(gA).contentName}}.`;return S.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");r&&o&&(document.getElementById(r)||console.warn(l))},[l,e,r]),null},vA=_1,yA=R1,bA=O1,wA=z1,SA=L1,jA=B1,kA=q1,V1=P1,G1="AlertDialog",[CA]=Nr(G1,[A1]),ya=A1(),Y1=e=>{const{__scopeAlertDialog:r,...a}=e,l=ya(r);return s.jsx(vA,{...l,...a,modal:!0})};Y1.displayName=G1;var NA="AlertDialogTrigger",X1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(yA,{...o,...l,ref:r})});X1.displayName=NA;var EA="AlertDialogPortal",K1=e=>{const{__scopeAlertDialog:r,...a}=e,l=ya(r);return s.jsx(bA,{...l,...a})};K1.displayName=EA;var TA="AlertDialogOverlay",Q1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(wA,{...o,...l,ref:r})});Q1.displayName=TA;var Xi="AlertDialogContent",[AA,_A]=CA(Xi),Z1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,children:l,...o}=e,c=ya(a),d=S.useRef(null),f=ft(r,d),h=S.useRef(null);return s.jsx(mA,{contentName:Xi,titleName:J1,docsSlug:"alert-dialog",children:s.jsx(AA,{scope:a,cancelRef:h,children:s.jsxs(SA,{role:"alertdialog",...c,...o,ref:f,onOpenAutoFocus:Ae(o.onOpenAutoFocus,m=>{var x;m.preventDefault(),(x=h.current)==null||x.focus({preventScroll:!0})}),onPointerDownOutside:m=>m.preventDefault(),onInteractOutside:m=>m.preventDefault(),children:[s.jsx(s1,{children:l}),s.jsx(RA,{contentRef:d})]})})})});Z1.displayName=Xi;var J1="AlertDialogTitle",W1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(jA,{...o,...l,ref:r})});W1.displayName=J1;var ew="AlertDialogDescription",tw=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(kA,{...o,...l,ref:r})});tw.displayName=ew;var MA="AlertDialogAction",nw=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(V1,{...o,...l,ref:r})});nw.displayName=MA;var rw="AlertDialogCancel",aw=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,{cancelRef:o}=_A(rw,a),c=ya(a),d=ft(r,o);return s.jsx(V1,{...c,...l,ref:d})});aw.displayName=rw;var RA=({contentRef:e})=>{const r=`\`${Xi}\` requires a description for the component to be accessible for screen reader users. + +You can add a description to the \`${Xi}\` by passing a \`${ew}\` component as a child, which also benefits sighted users by adding visible context to the dialog. + +Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Xi}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. + +For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return S.useEffect(()=>{var l;document.getElementById((l=e.current)==null?void 0:l.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null},DA=Y1,OA=X1,zA=K1,LA=Q1,UA=Z1,BA=nw,IA=aw,qA=W1,HA=tw;function rl({...e}){return s.jsx(DA,{"data-slot":"alert-dialog",...e})}function al({...e}){return s.jsx(OA,{"data-slot":"alert-dialog-trigger",...e})}function PA({...e}){return s.jsx(zA,{"data-slot":"alert-dialog-portal",...e})}function $A({className:e,...r}){return s.jsx(LA,{"data-slot":"alert-dialog-overlay",className:Ne("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function ll({className:e,...r}){return s.jsxs(PA,{children:[s.jsx($A,{}),s.jsx(UA,{"data-slot":"alert-dialog-content",className:Ne("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r})]})}function il({className:e,...r}){return s.jsx("div",{"data-slot":"alert-dialog-header",className:Ne("flex flex-col gap-2 text-center sm:text-left",e),...r})}function sl({className:e,...r}){return s.jsx("div",{"data-slot":"alert-dialog-footer",className:Ne("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function ol({className:e,...r}){return s.jsx(qA,{"data-slot":"alert-dialog-title",className:Ne("text-lg font-semibold",e),...r})}function ul({className:e,...r}){return s.jsx(HA,{"data-slot":"alert-dialog-description",className:Ne("text-muted-foreground text-sm",e),...r})}function cl({className:e,...r}){return s.jsx(BA,{className:Ne(Vm(),e),...r})}function dl({className:e,...r}){return s.jsx(IA,{className:Ne(Vm({variant:"outline"}),e),...r})}function FA(){return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(VA,{}),s.jsx(GA,{})]})}function VA(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/my/keys")),[o,c]=S.useState(""),[d,f]=S.useState(!1),[h,m]=S.useState(null),x=async b=>{b.preventDefault(),f(!0);try{const y=await He.post("/my/keys",{label:o});m(y),c(""),l()}catch(y){Ve.error(String(y instanceof Error?y.message:y))}finally{f(!1)}},v=async b=>{try{await He.del(`/my/keys/${b}`),Ve.success("Key deleted"),l()}catch(y){Ve.error(String(y instanceof Error?y.message:y))}};return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Your API keys"}),s.jsx(it,{children:"Shown exactly once at creation; only a keyed hash is stored."})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsxs("form",{onSubmit:x,className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ft,{className:"w-64",placeholder:"Label (e.g. laptop)",maxLength:120,value:o,onChange:b=>c(b.target.value)}),s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Create key"]})]}),h&&s.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-4",children:[s.jsxs("p",{className:"mb-2 text-sm font-medium",children:["New key",h.label?` "${h.label}"`:""," — copy it now, it will not be shown again."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-sm",children:h.key}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Copy key",onClick:()=>{navigator.clipboard.writeText(h.key??""),Ve.success("Copied to clipboard")},children:s.jsx(Gm,{})})]})]}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Label"}),s.jsx(ge,{children:"Key"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.keys.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No keys yet."})}),e==null?void 0:e.keys.map(b=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:b.label||s.jsx("span",{className:"text-muted-foreground",children:"(no label)"})}),s.jsxs(de,{className:"font-mono text-xs",children:["***",b.key_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(b.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(b.last_used_at)||"never"}),s.jsx(de,{className:"whitespace-nowrap",children:s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsx(ol,{children:"Delete this key?"}),s.jsxs(ul,{children:["Anything using"," ",b.label?`"${b.label}"`:`***${b.key_suffix}`," ","stops working immediately. This cannot be undone."]})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>v(b.id),children:"Delete"})]})]})]})})]},b.id))]})]})]})]})}function GA(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/my/relay-tokens")),[o,c]=S.useState(""),[d,f]=S.useState(!1),[h,m]=S.useState(null),x=async y=>{y.preventDefault(),f(!0);try{const k=await He.post("/my/relay-tokens",{label:o});m(k),c(""),l()}catch(k){Ve.error(String(k instanceof Error?k.message:k))}finally{f(!1)}},v=async y=>{try{await He.del(`/my/relay-tokens/${y}`),Ve.success("Relay token deleted"),l()}catch(k){Ve.error(String(k instanceof Error?k.message:k))}},b=y=>`export ANTHROPIC_BASE_URL=${window.location.origin}/transparent/anthropic/${y} +claude`;return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Relay tokens"}),s.jsx(it,{children:"Tracks your usage on the transparent Anthropic relay. Your Anthropic credentials pass through untouched; the token grants no proxy access."})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsxs("form",{onSubmit:x,className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ft,{className:"w-64",placeholder:"Label (e.g. claude-code laptop)",maxLength:120,value:o,onChange:y=>c(y.target.value)}),s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Create relay token"]})]}),(h==null?void 0:h.token)&&s.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-4",children:[s.jsxs("p",{className:"mb-2 text-sm font-medium",children:["New relay token",h.label?` "${h.label}"`:""," — copy the setup command now, the token will not be shown again."]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("pre",{className:"flex-1 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-sm",children:b(h.token)}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Copy setup command",onClick:()=>{navigator.clipboard.writeText(b(h.token??"")),Ve.success("Copied to clipboard")},children:s.jsx(Gm,{})})]}),s.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Make it permanent via your shell profile or ",'"env"'," in ~/.claude/settings.json."]})]}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Label"}),s.jsx(ge,{children:"Token"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.relay_tokens.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No relay tokens yet."})}),e==null?void 0:e.relay_tokens.map(y=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:y.label||s.jsx("span",{className:"text-muted-foreground",children:"(no label)"})}),s.jsxs(de,{className:"font-mono text-xs",children:["***",y.token_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(y.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(y.last_used_at)||"never"}),s.jsx(de,{className:"whitespace-nowrap",children:s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsx(ol,{children:"Delete this relay token?"}),s.jsxs(ul,{children:["Anything relaying through"," ",y.label?`"${y.label}"`:`***${y.token_suffix}`," ","stops working immediately. This cannot be undone."]})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>v(y.id),children:"Delete"})]})]})]})})]},y.id))]})]})]})]})}const mm="llmproxy:querychange";function YA(e){return window.addEventListener("popstate",e),window.addEventListener(mm,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(mm,e)}}const XA=()=>window.location.search;function Gt(e,r=""){const a=S.useSyncExternalStore(YA,XA),l=new URLSearchParams(a).get(e)??r,o=S.useCallback(c=>{const d=new URLSearchParams(window.location.search);c?d.set(e,c):d.delete(e);const f=d.toString();window.history.replaceState(null,"",window.location.pathname+(f?"?"+f:"")),window.dispatchEvent(new Event(mm))},[e]);return[l,o]}const ma={name:"",fill:"fill-chart-1",swatch:"bg-chart-1",stroke:"stroke-chart-1"},Vl={name:"",fill:"fill-chart-2 dark:fill-chart-4",swatch:"bg-chart-2 dark:bg-chart-4",stroke:"stroke-chart-2 dark:stroke-chart-4"},ep={name:"",fill:"fill-chart-3",swatch:"bg-chart-3"},Jt=52,lw=22,nn=176,KA=24,QA=2;function iw(){const e=S.useRef(null),[r,a]=S.useState(0);return S.useLayoutEffect(()=>{const l=e.current;if(!l)return;a(l.getBoundingClientRect().width);const o=new ResizeObserver(c=>{a(c[0].contentRect.width)});return o.observe(l),()=>o.disconnect()},[]),[e,r]}function sw(e,r,a=4){if(!(e>0))return[0,1];const l=Math.pow(10,Math.floor(Math.log10(e/a))),o=e/a/l;let c=(o<=1?1:o<=2?2:o<=5?5:10)*l;r&&(c=Math.max(1,Math.round(c)));const d=(Math.floor(e/c)+1)*c,f=[];for(let h=0;h<=d+c/2;h+=c)f.push(Number(h.toFixed(10)));return f}function ZA(e,r,a,l,o){const c=o?Math.min(4,a/2,l):0;return`M${e},${r+l} L${e},${r+c} Q${e},${r} ${e+c},${r} L${e+a-c},${r} Q${e+a},${r} ${e+a},${r+c} L${e+a},${r+l} Z`}function Wa({points:e,series:r,format:a,integer:l,emptyMessage:o="No usage in this range.",className:c}){var I;const[d,f]=iw(),[h,m]=S.useState(null),x=e.map(O=>O.values.reduce((E,C)=>E+(C??0),0)),v=Math.max(0,...x),b=sw(v,l===!0),y=b[b.length-1]||1,k=Math.max(0,f-Jt),j=e.length>0?k/e.length:0,T=Math.max(2,Math.min(KA,j-6)),N=O=>nn-O/y*nn,R=x.indexOf(v),D=Math.max(1,Math.ceil(e.length/8));return s.jsxs("div",{className:Ne("flex flex-col gap-2",c),children:[r.length>1&&s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:r.map(O=>s.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:Ne("size-2.5 rounded-xs",O.swatch),"aria-hidden":!0}),O.name]},O.name))}),s.jsxs("div",{ref:d,className:"relative w-full",children:[s.jsxs("svg",{width:f,height:nn+lw,className:"block overflow-visible",onPointerLeave:()=>m(null),children:[b.map(O=>s.jsxs("g",{children:[s.jsx("line",{x1:Jt,x2:f,y1:N(O),y2:N(O),className:"stroke-border",strokeWidth:1}),s.jsx("text",{x:Jt-8,y:N(O)+3,textAnchor:"end",className:"fill-muted-foreground text-[10px] tabular-nums",children:a(O)})]},O)),h!==null&&s.jsx("rect",{x:Jt+h*j,y:0,width:Math.max(j,1),height:nn,className:"fill-foreground/5"}),e.map((O,E)=>{const C=Jt+E*j+(j-T)/2;let z=-1;O.values.forEach((q,P)=>{q!==null&&q>0&&(z=P)});let Y=nn;return s.jsx("g",{children:O.values.map((q,P)=>{if(q===null||q<=0)return null;const K=q/y*nn,ue=Math.max(1,K-(Y0&&j>=30&&s.jsx("text",{x:Jt+R*j+j/2,y:N(v)-6,textAnchor:"middle",className:"fill-foreground text-[10px] font-medium tabular-nums",children:a(v)}),e.map((O,E)=>E%D===0?s.jsx("text",{x:Jt+E*j+j/2,y:nn+15,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:O.label},E):null),s.jsx("line",{x1:Jt,x2:f,y1:nn,y2:nn,className:"stroke-border",strokeWidth:1}),e.map((O,E)=>s.jsx("rect",{x:Jt+E*j,y:0,width:Math.max(j,1),height:nn,fill:"transparent",tabIndex:0,role:"button","aria-label":`${O.title}: ${O.values.map((C,z)=>`${r[z].name||"value"} ${C===null?"unpriced":a(C)}`).join(", ")}`,onPointerEnter:()=>m(E),onFocus:()=>m(E),onBlur:()=>m(null),className:"outline-none focus-visible:stroke-ring focus-visible:[stroke-width:2]"},E))]}),v===0&&s.jsx("p",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2 text-center text-sm text-muted-foreground",children:o}),h!==null&&e[h]&&s.jsxs("div",{className:"pointer-events-none absolute z-10 min-w-36 -translate-x-1/2 rounded-md border bg-popover p-2 text-xs shadow-md",style:{left:Math.min(Math.max(Jt+h*j+j/2,Jt+70),Math.max(f-70,Jt+70)),top:0},children:[s.jsx("p",{className:"mb-1 text-muted-foreground",children:e[h].title}),e[h].values.map((O,E)=>s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ne("h-0.5 w-3 rounded-full",r[E].swatch),"aria-hidden":!0}),s.jsx("span",{className:"font-medium tabular-nums",children:O===null?"unpriced":a(O)}),r[E].name&&s.jsx("span",{className:"text-muted-foreground",children:r[E].name})]},E)),(I=e[h].rows)==null?void 0:I.map(O=>s.jsxs("p",{className:"flex items-center gap-1.5 pl-[18px]",children:[s.jsx("span",{className:"font-medium tabular-nums",children:O.value}),s.jsx("span",{className:"text-muted-foreground",children:O.label})]},O.label))]})]})]})}function bb({points:e,series:r,format:a,integer:l,emptyMessage:o="No data in this range.",className:c}){var O;const[d,f]=iw(),[h,m]=S.useState(null),x=e.flatMap(E=>E.values.filter(C=>C!==null)),v=Math.max(0,...x),b=sw(v,l===!0),y=b[b.length-1]||1,k=Math.max(0,f-Jt),j=e.length>0?k/e.length:0,T=E=>Jt+E*j+j/2,N=E=>nn-E/y*nn,R=Math.max(1,Math.ceil(e.length/8)),D=(E,C)=>{var z;return((z=e[E])==null?void 0:z.values[C])??null},I=E=>{const C=[];let z=[];return e.forEach((Y,q)=>{D(q,E)===null?(z.length&&C.push(z),z=[]):z.push(q)}),z.length&&C.push(z),C};return s.jsxs("div",{className:Ne("flex flex-col gap-2",c),children:[r.length>1&&s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:r.map(E=>s.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:Ne("h-0.5 w-3 rounded-full",E.swatch),"aria-hidden":!0}),E.name]},E.name))}),s.jsxs("div",{ref:d,className:"relative w-full",children:[s.jsxs("svg",{width:f,height:nn+lw,className:"block overflow-visible",onPointerLeave:()=>m(null),children:[b.map(E=>s.jsxs("g",{children:[s.jsx("line",{x1:Jt,x2:f,y1:N(E),y2:N(E),className:"stroke-border",strokeWidth:1}),s.jsx("text",{x:Jt-8,y:N(E)+3,textAnchor:"end",className:"fill-muted-foreground text-[10px] tabular-nums",children:a(E)})]},E)),h!==null&&s.jsx("line",{x1:T(h),x2:T(h),y1:0,y2:nn,className:"stroke-muted-foreground/50",strokeWidth:1}),r.map((E,C)=>I(C).map(z=>z.length===1?s.jsx("circle",{cx:T(z[0]),cy:N(D(z[0],C)),r:4,className:Ne(E.fill,"stroke-card"),strokeWidth:2},`${C}-${z[0]}`):s.jsx("path",{d:z.map((Y,q)=>`${q===0?"M":"L"}${T(Y)},${N(D(Y,C))}`).join(" "),fill:"none",className:E.stroke,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"},`${C}-${z[0]}`))),h!==null&&r.map((E,C)=>{const z=D(h,C);return z===null?null:s.jsx("circle",{cx:T(h),cy:N(z),r:4,className:Ne(E.fill,"stroke-card"),strokeWidth:2},C)}),e.map((E,C)=>C%R===0?s.jsx("text",{x:T(C),y:nn+15,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:E.label},C):null),s.jsx("line",{x1:Jt,x2:f,y1:nn,y2:nn,className:"stroke-border",strokeWidth:1}),e.map((E,C)=>s.jsx("rect",{x:Jt+C*j,y:0,width:Math.max(j,1),height:nn,fill:"transparent",tabIndex:0,role:"button","aria-label":`${E.title}: ${E.values.map((z,Y)=>`${r[Y].name||"value"} ${z===null?"none":a(z)}`).join(", ")}`,onPointerEnter:()=>m(C),onFocus:()=>m(C),onBlur:()=>m(null),className:"outline-none focus-visible:stroke-ring focus-visible:[stroke-width:2]"},C))]}),x.length===0&&s.jsx("p",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2 text-center text-sm text-muted-foreground",children:o}),h!==null&&e[h]&&s.jsxs("div",{className:"pointer-events-none absolute z-10 min-w-36 -translate-x-1/2 rounded-md border bg-popover p-2 text-xs shadow-md",style:{left:Math.min(Math.max(T(h),Jt+70),Math.max(f-70,Jt+70)),top:0},children:[s.jsx("p",{className:"mb-1 text-muted-foreground",children:e[h].title}),e[h].values.map((E,C)=>s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ne("h-0.5 w-3 rounded-full",r[C].swatch),"aria-hidden":!0}),s.jsx("span",{className:"font-medium tabular-nums",children:E===null?"—":a(E)}),r[C].name&&s.jsx("span",{className:"text-muted-foreground",children:r[C].name})]},C)),(O=e[h].rows)==null?void 0:O.map(E=>s.jsxs("p",{className:"flex items-center gap-1.5 pl-[18px]",children:[s.jsx("span",{className:"font-medium tabular-nums",children:E.value}),s.jsx("span",{className:"text-muted-foreground",children:E.label})]},E.label))]})]})]})}const Hl=[{fill:"fill-chart-1",swatch:"bg-chart-1"},{fill:"fill-chart-5",swatch:"bg-chart-5"},{fill:"fill-chart-3",swatch:"bg-chart-3"},{fill:"fill-border",swatch:"bg-border"}],Ch=Hl.length;function _c(e,r,a){if(e.length<=Ch)return{slices:e.map(r),overflow:[]};const l=e.slice(Ch-1);return{slices:[...e.slice(0,Ch-1).map(r),a(l)],overflow:l.map(r)}}function JA(e,r,a,l,o,c){const d=(h,m)=>`${e+h*Math.sin(m)},${r-h*Math.cos(m)}`;if(c-o>=Math.PI*2-1e-9){const h=(m,x)=>`M${e},${r-m} A${m},${m} 0 1 ${x} ${e},${r+m} A${m},${m} 0 1 ${x} ${e},${r-m} Z`;return`${h(a,1)} ${h(l,0)}`}const f=c-o>Math.PI?1:0;return`M${d(a,o)} A${a},${a} 0 ${f} 1 ${d(a,c)} L${d(l,c)} A${l},${l} 0 ${f} 0 ${d(l,o)} Z`}const Nh=20;function lo({slices:e,overflow:r=[],format:a,emptyMessage:l="No usage in this range."}){var D;const[o,c]=S.useState(null),[d,f]=S.useState(0),h=r.length>0?e.length-1:-1,m=()=>f(I=>I===0?Math.min(Nh,r.length):0),x=e.reduce((I,O)=>I+O.value,0),v=168,b=82,y=50,k=v/2,j=v/2;if(x<=0)return s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:l});const T=e.length>1?2/((y+b)/2):0;let N=0;const R=e.map((I,O)=>{const E=I.value/x*Math.PI*2,C=N+T/2,z=Math.max(C,N+E-T/2);return N+=E,{slice:I,a0:C,a1:z,i:O}});return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("svg",{width:v,height:v,className:"block",onPointerLeave:()=>c(null),children:R.map(({slice:I,a0:O,a1:E,i:C})=>s.jsx("path",{d:JA(k,j,b,y,O,E),className:Ne(Hl[C%Hl.length].fill,"outline-none transition-opacity focus-visible:stroke-ring focus-visible:[stroke-width:2]",o!==null&&o!==C&&"opacity-50",C===h&&"cursor-pointer"),tabIndex:0,role:C===h?"button":"img","aria-label":`${I.label}: ${a(I.value)} (${Math.round(I.value/x*100)}%)`+(C===h?d===0?"; activate to expand":"; activate to collapse":""),onClick:C===h?m:void 0,onKeyDown:C===h?z=>{(z.key==="Enter"||z.key===" ")&&(z.preventDefault(),m())}:void 0,onPointerEnter:()=>c(C),onFocus:()=>c(C),onBlur:()=>c(null)},C))}),o!==null&&e[o]&&s.jsxs("div",{className:"pointer-events-none absolute left-1/2 top-0 z-10 min-w-32 -translate-x-1/2 rounded-md border bg-popover p-2 text-xs shadow-md",children:[s.jsx("p",{className:"mb-1 text-muted-foreground",children:e[o].label}),s.jsxs("p",{className:"font-medium tabular-nums",children:[a(e[o].value)," ",s.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",(e[o].value/x*100).toFixed(1),"%"]})]}),(D=e[o].rows)==null?void 0:D.map(I=>s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium tabular-nums",children:I.value}),s.jsx("span",{className:"text-muted-foreground",children:I.label})]},I.label))]})]}),s.jsxs("ul",{className:"min-w-48 flex-1",children:[e.map((I,O)=>s.jsx("li",{className:Ne("rounded-sm text-sm",o===O&&"bg-foreground/5"),onPointerEnter:()=>c(O),onPointerLeave:()=>c(null),children:O===h?s.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":d>0,onClick:m,children:[s.jsx("span",{className:Ne("size-2.5 shrink-0 rounded-xs",Hl[O%Hl.length].swatch),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",children:I.label}),d>0?s.jsx(Ji,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):s.jsx(um,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground",children:a(I.value)}),s.jsxs("span",{className:"w-12 text-right tabular-nums",children:[(I.value/x*100).toFixed(1),"%"]})]}):s.jsxs("span",{className:"flex items-center gap-2 px-1 py-1",children:[s.jsx("span",{className:Ne("size-2.5 shrink-0 rounded-xs",Hl[O%Hl.length].swatch),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",title:I.label,children:I.label}),s.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground",children:a(I.value)}),s.jsxs("span",{className:"w-12 text-right tabular-nums",children:[(I.value/x*100).toFixed(1),"%"]})]})},O)),r.slice(0,d).map((I,O)=>s.jsxs("li",{className:"flex items-center gap-2 py-1 pl-[26px] pr-1 text-sm",onPointerEnter:()=>c(h),onPointerLeave:()=>c(null),children:[s.jsx("span",{className:"truncate font-mono text-xs",title:I.label,children:I.label}),s.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground",children:a(I.value)}),s.jsxs("span",{className:"w-12 text-right tabular-nums",children:[(I.value/x*100).toFixed(1),"%"]})]},`overflow-${O}`)),d>0&&df(I=>Math.min(I+Nh,r.length)),children:["Show ",Math.min(Nh,r.length-d)," more"]})})]})]})}function Ki({rows:e,format:r,emptyMessage:a="No usage in this range."}){const l=Math.max(0,...e.map(c=>c.value));if(e.length===0||l<=0)return s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:a});const o=e.reduce((c,d)=>c+d.value,0);return s.jsx("ul",{className:"flex flex-col gap-2",children:e.map((c,d)=>s.jsxs("li",{className:"grid grid-cols-[minmax(6rem,14rem)_1fr_auto] items-center gap-3 text-sm",children:[s.jsx("span",{className:"truncate font-mono text-xs",title:c.title??c.label,children:c.label}),s.jsx("span",{className:"h-2 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:s.jsx("span",{className:"block h-full rounded-full bg-chart-1",style:{width:`${Math.max(1,c.value/l*100)}%`}})}),s.jsxs("span",{className:"tabular-nums text-muted-foreground",children:[r(c.value),c.note&&s.jsx("span",{className:"ml-2 text-xs",children:c.note}),s.jsxs("span",{className:"ml-2 inline-block w-12 text-right text-foreground",children:[(c.value/o*100).toFixed(1),"%"]})]})]},d))})}function Qn({label:e,value:r,secondary:a,delta:l,hint:o}){return s.jsxs("div",{className:"flex flex-col gap-1 rounded-lg border bg-card p-4",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),s.jsxs("span",{className:"text-2xl font-semibold",children:[r,a&&s.jsx("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:a})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:l==null?o??" ":s.jsxs(s.Fragment,{children:[l>=0?"+":"",Math.round(l*100),"% vs previous"]})})]})}function wb(e,[r,a]){return Math.min(a,Math.max(r,e))}function tp(e){const r=e+"CollectionProvider",[a,l]=Nr(r),[o,c]=a(r,{collectionRef:{current:null},itemMap:new Map}),d=y=>{const{scope:k,children:j}=y,T=ve.useRef(null),N=ve.useRef(new Map).current;return s.jsx(o,{scope:k,itemMap:N,collectionRef:T,children:j})};d.displayName=r;const f=e+"CollectionSlot",h=ve.forwardRef((y,k)=>{const{scope:j,children:T}=y,N=c(f,j),R=ft(k,N.collectionRef);return s.jsx(xa,{ref:R,children:T})});h.displayName=f;const m=e+"CollectionItemSlot",x="data-radix-collection-item",v=ve.forwardRef((y,k)=>{const{scope:j,children:T,...N}=y,R=ve.useRef(null),D=ft(k,R),I=c(m,j);return ve.useEffect(()=>(I.itemMap.set(R,{ref:R,...N}),()=>void I.itemMap.delete(R))),s.jsx(xa,{[x]:"",ref:D,children:T})});v.displayName=m;function b(y){const k=c(e+"CollectionConsumer",y);return ve.useCallback(()=>{const T=k.collectionRef.current;if(!T)return[];const N=Array.from(T.querySelectorAll(`[${x}]`));return Array.from(k.itemMap.values()).sort((I,O)=>N.indexOf(I.ref.current)-N.indexOf(O.ref.current))},[k.collectionRef,k.itemMap])}return[{Provider:d,Slot:h,ItemSlot:v},b,l]}var WA=S.createContext(void 0);function Mc(e){const r=S.useContext(WA);return e||r||"ltr"}const e_=["top","right","bottom","left"],fl=Math.min,pa=Math.max,uc=Math.round,Ku=Math.floor,ga=e=>({x:e,y:e}),t_={left:"right",right:"left",bottom:"top",top:"bottom"};function ow(e,r,a){return pa(e,fl(r,a))}function va(e,r){return typeof e=="function"?e(r):e}function hl(e){return e.split("-")[0]}function Wi(e){return e.split("-")[1]}function np(e){return e==="x"?"y":"x"}function rp(e){return e==="y"?"height":"width"}function Hr(e){const r=e[0];return r==="t"||r==="b"?"y":"x"}function ap(e){return np(Hr(e))}function n_(e,r,a){a===void 0&&(a=!1);const l=Wi(e),o=ap(e),c=rp(o);let d=o==="x"?l===(a?"end":"start")?"right":"left":l==="start"?"bottom":"top";return r.reference[c]>r.floating[c]&&(d=cc(d)),[d,cc(d)]}function r_(e){const r=cc(e);return[pm(e),r,pm(r)]}function pm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Sb=["left","right"],jb=["right","left"],a_=["top","bottom"],l_=["bottom","top"];function i_(e,r,a){switch(e){case"top":case"bottom":return a?r?jb:Sb:r?Sb:jb;case"left":case"right":return r?a_:l_;default:return[]}}function s_(e,r,a,l){const o=Wi(e);let c=i_(hl(e),a==="start",l);return o&&(c=c.map(d=>d+"-"+o),r&&(c=c.concat(c.map(pm)))),c}function cc(e){const r=hl(e);return t_[r]+e.slice(r.length)}function o_(e){var r,a,l,o;return{top:(r=e.top)!=null?r:0,right:(a=e.right)!=null?a:0,bottom:(l=e.bottom)!=null?l:0,left:(o=e.left)!=null?o:0}}function uw(e){return typeof e!="number"?o_(e):{top:e,right:e,bottom:e,left:e}}function dc(e){const{x:r,y:a,width:l,height:o}=e;return{width:l,height:o,top:a,left:r,right:r+l,bottom:a+o,x:r,y:a}}function kb(e,r,a){let{reference:l,floating:o}=e;const c=Hr(r),d=ap(r),f=rp(d),h=hl(r),m=c==="y",x=l.x+l.width/2-o.width/2,v=l.y+l.height/2-o.height/2,b=l[f]/2-o[f]/2;let y;switch(h){case"top":y={x,y:l.y-o.height};break;case"bottom":y={x,y:l.y+l.height};break;case"right":y={x:l.x+l.width,y:v};break;case"left":y={x:l.x-o.width,y:v};break;default:y={x:l.x,y:l.y}}const k=Wi(r);return k&&(y[d]+=b*(k==="end"?1:-1)*(a&&m?-1:1)),y}async function u_(e,r){var a;r===void 0&&(r={});const{x:l,y:o,platform:c,rects:d,elements:f,strategy:h}=e,{boundary:m="clippingAncestors",rootBoundary:x="viewport",elementContext:v="floating",altBoundary:b=!1,padding:y=0}=va(r,e),k=uw(y),T=f[b?v==="floating"?"reference":"floating":v],N=dc(await c.getClippingRect({element:(a=await(c.isElement==null?void 0:c.isElement(T)))==null||a?T:T.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(f.floating)),boundary:m,rootBoundary:x,strategy:h})),R=v==="floating"?{x:l,y:o,width:d.floating.width,height:d.floating.height}:d.reference,D=await(c.getOffsetParent==null?void 0:c.getOffsetParent(f.floating)),I=await(c.isElement==null?void 0:c.isElement(D))&&await(c.getScale==null?void 0:c.getScale(D))||{x:1,y:1},O=dc(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:R,offsetParent:D,strategy:h}):R);return{top:(N.top-O.top+k.top)/I.y,bottom:(O.bottom-N.bottom+k.bottom)/I.y,left:(N.left-O.left+k.left)/I.x,right:(O.right-N.right+k.right)/I.x}}const c_=50,d_=async(e,r,a)=>{const{placement:l="bottom",strategy:o="absolute",middleware:c=[],platform:d}=a,f=d.detectOverflow?d:{...d,detectOverflow:u_},h=await(d.isRTL==null?void 0:d.isRTL(r));let m=await d.getElementRects({reference:e,floating:r,strategy:o}),{x,y:v}=kb(m,l,h),b=l,y=0;const k={};for(let j=0;j({name:"arrow",options:e,async fn(r){const{x:a,y:l,placement:o,rects:c,platform:d,elements:f,middlewareData:h}=r,{element:m,padding:x=0}=va(e,r)||{};if(m==null)return{};const v=uw(x),b={x:a,y:l},y=ap(o),k=rp(y),j=await d.getDimensions(m),T=y==="y",N=T?"top":"left",R=T?"bottom":"right",D=T?"clientHeight":"clientWidth",I=c.reference[k]+c.reference[y]-b[y]-c.floating[k],O=b[y]-c.reference[y],E=await(d.getOffsetParent==null?void 0:d.getOffsetParent(m));let C=E?E[D]:0;(!C||!await(d.isElement==null?void 0:d.isElement(E)))&&(C=f.floating[D]||c.floating[k]);const z=I/2-O/2,Y=C/2-j[k]/2-1,q=fl(v[N],Y),P=fl(v[R],Y),K=C-j[k]-P,ue=C/2-j[k]/2+z,le=ow(q,ue,K),W=!h.arrow&&Wi(o)!=null&&ue!==le&&c.reference[k]/2-(uele<=0)){var P,K;const le=(((P=c.flip)==null?void 0:P.index)||0)+1,W=C[le];if(W&&(!(v==="alignment"?R!==Hr(W):!1)||q.every(ae=>Hr(ae.placement)===R?ae.overflows[0]>0:!0)))return{data:{index:le,overflows:q},reset:{placement:W}};let B=(K=q.filter(F=>F.overflows[0]<=0).sort((F,ae)=>F.overflows[1]-ae.overflows[1])[0])==null?void 0:K.placement;if(!B)switch(y){case"bestFit":{var ue;const F=(ue=q.filter(ae=>{if(E){const Z=Hr(ae.placement);return Z===R||Z==="y"}return!0}).map(ae=>[ae.placement,ae.overflows.filter(Z=>Z>0).reduce((Z,A)=>Z+A,0)]).sort((ae,Z)=>ae[1]-Z[1])[0])==null?void 0:ue[0];F&&(B=F);break}case"initialPlacement":B=f;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Cb(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function Nb(e){return e_.some(r=>e[r]>=0)}const m_=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(r){const{rects:a,platform:l}=r,{strategy:o="referenceHidden",...c}=va(e,r);switch(o){case"referenceHidden":{const d=await l.detectOverflow(r,{...c,elementContext:"reference"}),f=Cb(d,a.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:Nb(f)}}}case"escaped":{const d=await l.detectOverflow(r,{...c,altBoundary:!0}),f=Cb(d,a.floating);return{data:{escapedOffsets:f,escaped:Nb(f)}}}default:return{}}}}},cw=new Set(["left","top"]);async function p_(e,r){const{placement:a,platform:l,elements:o}=e,c=await(l.isRTL==null?void 0:l.isRTL(o.floating)),d=hl(a),f=Wi(a),h=Hr(a)==="y",m=cw.has(d)?-1:1,x=c&&h?-1:1,v=va(r,e);let{mainAxis:b,crossAxis:y,alignmentAxis:k}=typeof v=="number"?{mainAxis:v,crossAxis:0,alignmentAxis:null}:{mainAxis:v.mainAxis||0,crossAxis:v.crossAxis||0,alignmentAxis:v.alignmentAxis};return f&&typeof k=="number"&&(y=f==="end"?k*-1:k),h?{x:y*x,y:b*m}:{x:b*m,y:y*x}}const g_=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(r){var a,l;const{x:o,y:c,placement:d,middlewareData:f}=r,h=await p_(r,e);return d===((a=f.offset)==null?void 0:a.placement)&&(l=f.arrow)!=null&&l.alignmentOffset?{}:{x:o+h.x,y:c+h.y,data:{...h,placement:d}}}}},x_=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(r){const{x:a,y:l,placement:o,platform:c}=r,{mainAxis:d=!0,crossAxis:f=!1,limiter:h={fn:R=>{let{x:D,y:I}=R;return{x:D,y:I}}},...m}=va(e,r),x={x:a,y:l},v=await c.detectOverflow(r,m),b=Hr(o),y=np(b);let k=x[y],j=x[b];const T=(R,D)=>ow(D+v[R==="y"?"top":"left"],D,D-v[R==="y"?"bottom":"right"]);d&&(k=T(y,k)),f&&(j=T(b,j));const N=h.fn({...r,[y]:k,[b]:j});return{...N,data:{x:N.x-a,y:N.y-l,enabled:{[y]:d,[b]:f}}}}}},v_=function(e){return e===void 0&&(e={}),{options:e,fn(r){var a,l;const{x:o,y:c,placement:d,rects:f,middlewareData:h}=r,{offset:m=0,mainAxis:x=!0,crossAxis:v=!0}=va(e,r),b={x:o,y:c},y=Hr(d),k=np(y);let j=b[k],T=b[y];const N=va(m,r),R=typeof N=="number"?{mainAxis:N,crossAxis:0}:{mainAxis:(a=N.mainAxis)!=null?a:0,crossAxis:(l=N.crossAxis)!=null?l:0};if(x){const O=k==="y"?"height":"width",E=f.reference[k]-f.floating[O]+R.mainAxis,C=f.reference[k]+f.reference[O]-R.mainAxis;jC&&(j=C)}if(v){var D,I;const O=k==="y"?"width":"height",E=cw.has(hl(d)),C=f.reference[y]-f.floating[O]+(E&&((D=h.offset)==null?void 0:D[y])||0)+(E?0:R.crossAxis),z=f.reference[y]+f.reference[O]+(E?0:((I=h.offset)==null?void 0:I[y])||0)-(E?R.crossAxis:0);Tz&&(T=z)}return{[k]:j,[y]:T}}}},y_=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(r){const{placement:a,rects:l,platform:o,elements:c}=r,{apply:d=()=>{},...f}=va(e,r),h=await o.detectOverflow(r,f),m=hl(a),x=Wi(a),v=Hr(a)==="y",{width:b,height:y}=l.floating;let k,j;m==="top"||m==="bottom"?(k=m,j=x===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(j=m,k=x==="end"?"top":"bottom");const T=y-h.top-h.bottom,N=b-h.left-h.right,R=fl(y-h[k],T),D=fl(b-h[j],N),I=r.middlewareData.shift,O=!I;let E=R,C=D;I!=null&&I.enabled.x&&(C=N),I!=null&&I.enabled.y&&(E=T),O&&!x&&(v?C=b-2*pa(h.left,h.right):E=y-2*pa(h.top,h.bottom)),await d({...r,availableWidth:C,availableHeight:E});const z=await o.getDimensions(c.floating);return b!==z.width||y!==z.height?{reset:{rects:!0}}:{}}}};function Rc(){return typeof window<"u"}function es(e){return dw(e)?(e.nodeName||"").toLowerCase():"#document"}function In(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function ba(e){var r;return(r=(dw(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function dw(e){return Rc()?e instanceof Node||e instanceof In(e).Node:!1}function $r(e){return Rc()?e instanceof Element||e instanceof In(e).Element:!1}function gl(e){return Rc()?e instanceof HTMLElement||e instanceof In(e).HTMLElement:!1}function Eb(e){return!Rc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof In(e).ShadowRoot}function Dc(e){const{overflow:r,overflowX:a,overflowY:l,display:o}=Fr(e);return/auto|scroll|overlay|hidden|clip/.test(r+l+a)&&o!=="inline"&&o!=="contents"}function b_(e){return/^(table|td|th)$/.test(es(e))}function Oc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const w_=/transform|translate|scale|rotate|perspective|filter/,S_=/paint|layout|strict|content/,Il=e=>!!e&&e!=="none";let Eh;function lp(e){const r=$r(e)?Fr(e):e;return Il(r.transform)||Il(r.translate)||Il(r.scale)||Il(r.rotate)||Il(r.perspective)||!ip()&&(Il(r.backdropFilter)||Il(r.filter))||w_.test(r.willChange||"")||S_.test(r.contain||"")}function j_(e){let r=Gl(e);for(;gl(r)&&!fo(r);){if(lp(r))return r;if(Oc(r))return null;r=Gl(r)}return null}function ip(){return Eh==null&&(Eh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Eh}function fo(e){return/^(html|body|#document)$/.test(es(e))}function Fr(e){return In(e).getComputedStyle(e)}function zc(e){return $r(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gl(e){if(es(e)==="html")return e;const r=e.assignedSlot||e.parentNode||Eb(e)&&e.host||ba(e);return Eb(r)?r.host:r}function fw(e){const r=Gl(e);return fo(r)?(e.ownerDocument||e).body:gl(r)&&Dc(r)?r:fw(r)}function ho(e,r,a){var l;r===void 0&&(r=[]),a===void 0&&(a=!0);const o=fw(e),c=o===((l=e.ownerDocument)==null?void 0:l.body),d=In(o);if(c){const f=gm(d);return r.concat(d,d.visualViewport||[],Dc(o)?o:[],f&&a?ho(f):[])}else return r.concat(o,ho(o,[],a))}function gm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function hw(e){const r=Fr(e);let a=parseFloat(r.width)||0,l=parseFloat(r.height)||0;const o=gl(e),c=o?e.offsetWidth:a,d=o?e.offsetHeight:l,f=uc(a)!==c||uc(l)!==d;return f&&(a=c,l=d),{width:a,height:l,$:f}}function sp(e){return $r(e)?e:e.contextElement}function Qi(e){const r=sp(e);if(!gl(r))return ga(1);const a=r.getBoundingClientRect(),{width:l,height:o,$:c}=hw(r);let d=(c?uc(a.width):a.width)/l,f=(c?uc(a.height):a.height)/o;return(!d||!Number.isFinite(d))&&(d=1),(!f||!Number.isFinite(f))&&(f=1),{x:d,y:f}}const k_=ga(0);function mw(e){const r=In(e);return!ip()||!r.visualViewport?k_:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function C_(e,r,a){return r===void 0&&(r=!1),!!a&&r&&a===In(e)}function Yl(e,r,a,l){r===void 0&&(r=!1),a===void 0&&(a=!1);const o=e.getBoundingClientRect(),c=sp(e);let d=ga(1);r&&(l?$r(l)&&(d=Qi(l)):d=Qi(e));const f=C_(c,a,l)?mw(c):ga(0);let h=(o.left+f.x)/d.x,m=(o.top+f.y)/d.y,x=o.width/d.x,v=o.height/d.y;if(c&&l){const b=In(c),y=$r(l)?In(l):l;let k=b,j=gm(k);for(;j&&y!==k;){const T=Qi(j),N=j.getBoundingClientRect(),R=Fr(j),D=N.left+(j.clientLeft+parseFloat(R.paddingLeft))*T.x,I=N.top+(j.clientTop+parseFloat(R.paddingTop))*T.y;h*=T.x,m*=T.y,x*=T.x,v*=T.y,h+=D,m+=I,k=In(j),j=gm(k)}}return dc({width:x,height:v,x:h,y:m})}function Lc(e,r){const a=zc(e).scrollLeft;return r?r.left+a:Yl(ba(e)).left+a}function pw(e,r){const a=e.getBoundingClientRect(),l=a.left+r.scrollLeft-Lc(e,a),o=a.top+r.scrollTop;return{x:l,y:o}}function N_(e){let{elements:r,rect:a,offsetParent:l,strategy:o}=e;const c=o==="fixed",d=ba(l),f=r?Oc(r.floating):!1;if(l===d||f&&c)return a;let h={scrollLeft:0,scrollTop:0},m=ga(1);const x=ga(0),v=gl(l);if((v||!c)&&((es(l)!=="body"||Dc(d))&&(h=zc(l)),v)){const y=Yl(l);m=Qi(l),x.x=y.x+l.clientLeft,x.y=y.y+l.clientTop}const b=d&&!v&&!c?pw(d,h):ga(0);return{width:a.width*m.x,height:a.height*m.y,x:a.x*m.x-h.scrollLeft*m.x+x.x+b.x,y:a.y*m.y-h.scrollTop*m.y+x.y+b.y}}function E_(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function T_(e){const r=zc(e),a=e.ownerDocument.body,l=pa(e.scrollWidth,e.clientWidth,a.scrollWidth,a.clientWidth),o=pa(e.scrollHeight,e.clientHeight,a.scrollHeight,a.clientHeight);let c=-r.scrollLeft+Lc(e);const d=-r.scrollTop;return Fr(a).direction==="rtl"&&(c+=pa(e.clientWidth,a.clientWidth)-l),{width:l,height:o,x:c,y:d}}const A_=25;function __(e,r,a){a===void 0&&(a="viewport");const l=a==="layoutViewport",o=In(e),c=ba(e),d=o.visualViewport;let f=c.clientWidth,h=c.clientHeight,m=0,x=0;if(d){const b=!ip()||r==="fixed";l?b||(m=-d.offsetLeft,x=-d.offsetTop):(f=d.width,h=d.height,b&&(m=d.offsetLeft,x=d.offsetTop))}if(Lc(c)<=0){const b=c.ownerDocument,y=b.body,k=getComputedStyle(y),j=b.compatMode==="CSS1Compat"&&parseFloat(k.marginLeft)+parseFloat(k.marginRight)||0,T=Math.abs(c.clientWidth-y.clientWidth-j),N=getComputedStyle(c).scrollbarGutter==="stable both-edges"?T/2:T;N<=A_&&(f-=N)}return{width:f,height:h,x:m,y:x}}function M_(e,r){const a=Yl(e,!0,r==="fixed"),l=a.top+e.clientTop,o=a.left+e.clientLeft,c=Qi(e),d=e.clientWidth*c.x,f=e.clientHeight*c.y,h=o*c.x,m=l*c.y;return{width:d,height:f,x:h,y:m}}function Tb(e,r,a){let l;if(r==="viewport"||r==="layoutViewport")l=__(e,a,r);else if(r==="document")l=T_(ba(e));else if($r(r))l=M_(r,a);else{const o=mw(e);l={x:r.x-o.x,y:r.y-o.y,width:r.width,height:r.height}}return dc(l)}function R_(e,r){const a=r.get(e);if(a)return a;let l=ho(e,[],!1).filter(f=>$r(f)&&es(f)!=="body"),o=null;const c=Fr(e).position==="fixed";let d=c?Gl(e):e;for(;$r(d)&&!fo(d);){const f=Fr(d),h=lp(d),m=o?o.position:c?"fixed":"";!h&&(m==="fixed"||m==="absolute"&&f.position==="static")?l=l.filter(v=>v!==d):o=f,d=Gl(d)}return r.set(e,l),l}function D_(e){let{element:r,boundary:a,rootBoundary:l,strategy:o}=e;const d=[...a==="clippingAncestors"?Oc(r)?[]:R_(r,this._c):[].concat(a),l],f=Tb(r,d[0],o);let h=f.top,m=f.right,x=f.bottom,v=f.left;for(let b=1;b{f(!1,1e-7)},1e3)}C=!1}try{l=new IntersectionObserver(z,{...E,root:c.ownerDocument})}catch{l=new IntersectionObserver(z,E)}l.observe(e)}const h=In(e),m=()=>f(a);return h.addEventListener("resize",m),f(!0),()=>{h.removeEventListener("resize",m),d()}}function q_(e,r,a,l){l===void 0&&(l={});const{ancestorScroll:o=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:h=!1}=l,m=sp(e),x=o||c?[...m?ho(m):[],...r?ho(r):[]]:[];x.forEach(N=>{o&&N.addEventListener("scroll",a),c&&N.addEventListener("resize",a)});const v=m&&f?I_(m,a,c):null;let b=-1,y=null;d&&(y=new ResizeObserver(N=>{let[R]=N;R&&R.target===m&&y&&r&&(y.unobserve(r),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var D;(D=y)==null||D.observe(r)})),a()}),m&&!h&&y.observe(m),r&&y.observe(r));let k,j=h?Yl(e):null;h&&T();function T(){const N=Yl(e);j&&!xw(j,N)&&a(),j=N,k=requestAnimationFrame(T)}return a(),()=>{var N;x.forEach(R=>{o&&R.removeEventListener("scroll",a),c&&R.removeEventListener("resize",a)}),v==null||v(),(N=y)==null||N.disconnect(),y=null,h&&cancelAnimationFrame(k)}}const H_=g_,P_=x_,$_=h_,F_=y_,V_=m_,_b=f_,G_=v_,Y_=(e,r,a)=>{const l=new Map,o=a??{},c={...B_,...o.platform,_c:l};return d_(e,r,{...o,platform:c})};var X_=typeof document<"u",K_=function(){},lc=X_?S.useLayoutEffect:K_;function fc(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(typeof e=="function"&&e.toString()===r.toString())return!0;let a,l,o;if(e&&r&&typeof e=="object"){if(Array.isArray(e)){if(a=e.length,a!==r.length)return!1;for(l=a;l--!==0;)if(!fc(e[l],r[l]))return!1;return!0}if(o=Object.keys(e),a=o.length,a!==Object.keys(r).length)return!1;for(l=a;l--!==0;)if(!{}.hasOwnProperty.call(r,o[l]))return!1;for(l=a;l--!==0;){const c=o[l];if(!(c==="_owner"&&e.$$typeof)&&!fc(e[c],r[c]))return!1}return!0}return e!==e&&r!==r}function vw(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Mb(e,r){const a=vw(e);return Math.round(r*a)/a}function Ah(e){const r=S.useRef(e);return lc(()=>{r.current=e}),r}function Q_(e){e===void 0&&(e={});const{placement:r="bottom",strategy:a="absolute",middleware:l=[],platform:o,elements:{reference:c,floating:d}={},transform:f=!0,whileElementsMounted:h,open:m}=e,[x,v]=S.useState({x:0,y:0,strategy:a,placement:r,middlewareData:{},isPositioned:!1}),[b,y]=S.useState(l);fc(b,l)||y(l);const[k,j]=S.useState(null),[T,N]=S.useState(null),R=S.useCallback(ae=>{ae!==E.current&&(E.current=ae,j(ae))},[]),D=S.useCallback(ae=>{ae!==C.current&&(C.current=ae,N(ae))},[]),I=c||k,O=d||T,E=S.useRef(null),C=S.useRef(null),z=S.useRef(x),Y=h!=null,q=Ah(h),P=Ah(o),K=Ah(m),ue=S.useCallback(()=>{if(!E.current||!C.current)return;const ae={placement:r,strategy:a,middleware:b};P.current&&(ae.platform=P.current),Y_(E.current,C.current,ae).then(Z=>{const A={...Z,isPositioned:K.current!==!1};le.current&&!fc(z.current,A)&&(z.current=A,yo.flushSync(()=>{v(A)}))})},[b,r,a,P,K]);lc(()=>{m===!1&&z.current.isPositioned&&(z.current.isPositioned=!1,v(ae=>({...ae,isPositioned:!1})))},[m]);const le=S.useRef(!1);lc(()=>(le.current=!0,()=>{le.current=!1}),[]),lc(()=>{if(I&&(E.current=I),O&&(C.current=O),I&&O){if(q.current)return q.current(I,O,ue);ue()}},[I,O,ue,q,Y]);const W=S.useMemo(()=>({reference:E,floating:C,setReference:R,setFloating:D}),[R,D]),B=S.useMemo(()=>({reference:I,floating:O}),[I,O]),F=S.useMemo(()=>{const ae={position:a,left:0,top:0};if(!B.floating)return ae;const Z=Mb(B.floating,x.x),A=Mb(B.floating,x.y);return f?{...ae,transform:"translate("+Z+"px, "+A+"px)",...vw(B.floating)>=1.5&&{willChange:"transform"}}:{position:a,left:Z,top:A}},[a,f,B.floating,x.x,x.y]);return S.useMemo(()=>({...x,update:ue,refs:W,elements:B,floatingStyles:F}),[x,ue,W,B,F])}const Z_=e=>{function r(a){return{}.hasOwnProperty.call(a,"current")}return{name:"arrow",options:e,fn(a){const{element:l,padding:o}=typeof e=="function"?e(a):e;return l&&r(l)?l.current!=null?_b({element:l.current,padding:o}).fn(a):{}:l?_b({element:l,padding:o}).fn(a):{}}}},J_=(e,r)=>{const a=H_(e);return{name:a.name,fn:a.fn,options:[e,r]}},W_=(e,r)=>{const a=P_(e);return{name:a.name,fn:a.fn,options:[e,r]}},eM=(e,r)=>({fn:G_(e).fn,options:[e,r]}),tM=(e,r)=>{const a=$_(e);return{name:a.name,fn:a.fn,options:[e,r]}},nM=(e,r)=>{const a=F_(e);return{name:a.name,fn:a.fn,options:[e,r]}},rM=(e,r)=>{const a=V_(e);return{name:a.name,fn:a.fn,options:[e,r]}},aM=(e,r)=>{const a=Z_(e);return{name:a.name,fn:a.fn,options:[e,r]}};var lM="Arrow",yw=S.forwardRef((e,r)=>{const{children:a,width:l=10,height:o=5,...c}=e;return s.jsx(Ge.svg,{...c,ref:r,width:l,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?a:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});yw.displayName=lM;var iM=yw;function op(e){const[r,a]=S.useState(void 0);return Nn(()=>{if(e){a({width:e.offsetWidth,height:e.offsetHeight});const l=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const c=o[0];let d,f;if("borderBoxSize"in c){const h=c.borderBoxSize,m=Array.isArray(h)?h[0]:h;d=m.inlineSize,f=m.blockSize}else d=e.offsetWidth,f=e.offsetHeight;a({width:d,height:f})});return l.observe(e,{box:"border-box"}),()=>l.unobserve(e)}else a(void 0)},[e]),r}var up="Popper",[bw,Uc]=Nr(up),[sM,ww]=bw(up),Sw=e=>{const{__scopePopper:r,children:a}=e,[l,o]=S.useState(null);return s.jsx(sM,{scope:r,anchor:l,onAnchorChange:o,children:a})};Sw.displayName=up;var jw="PopperAnchor",kw=S.forwardRef((e,r)=>{const{__scopePopper:a,virtualRef:l,...o}=e,c=ww(jw,a),d=S.useRef(null),f=ft(r,d);return S.useEffect(()=>{c.onAnchorChange((l==null?void 0:l.current)||d.current)}),l?null:s.jsx(Ge.div,{...o,ref:f})});kw.displayName=jw;var cp="PopperContent",[oM,uM]=bw(cp),Cw=S.forwardRef((e,r)=>{var re,be,fe,we,Ee,Se;const{__scopePopper:a,side:l="bottom",sideOffset:o=0,align:c="center",alignOffset:d=0,arrowPadding:f=0,avoidCollisions:h=!0,collisionBoundary:m=[],collisionPadding:x=0,sticky:v="partial",hideWhenDetached:b=!1,updatePositionStrategy:y="optimized",onPlaced:k,...j}=e,T=ww(cp,a),[N,R]=S.useState(null),D=ft(r,Ie=>R(Ie)),[I,O]=S.useState(null),E=op(I),C=(E==null?void 0:E.width)??0,z=(E==null?void 0:E.height)??0,Y=l+(c!=="center"?"-"+c:""),q=typeof x=="number"?x:{top:0,right:0,bottom:0,left:0,...x},P=Array.isArray(m)?m:[m],K=P.length>0,ue={padding:q,boundary:P.filter(dM),altBoundary:K},{refs:le,floatingStyles:W,placement:B,isPositioned:F,middlewareData:ae}=Q_({strategy:"fixed",placement:Y,whileElementsMounted:(...Ie)=>q_(...Ie,{animationFrame:y==="always"}),elements:{reference:T.anchor},middleware:[J_({mainAxis:o+z,alignmentAxis:d}),h&&W_({mainAxis:!0,crossAxis:!1,limiter:v==="partial"?eM():void 0,...ue}),h&&tM({...ue}),nM({...ue,apply:({elements:Ie,rects:Be,availableWidth:Mt,availableHeight:Nt})=>{const{width:Et,height:Bt}=Be.reference,Rt=Ie.floating.style;Rt.setProperty("--radix-popper-available-width",`${Mt}px`),Rt.setProperty("--radix-popper-available-height",`${Nt}px`),Rt.setProperty("--radix-popper-anchor-width",`${Et}px`),Rt.setProperty("--radix-popper-anchor-height",`${Bt}px`)}}),I&&aM({element:I,padding:f}),fM({arrowWidth:C,arrowHeight:z}),b&&rM({strategy:"referenceHidden",...ue})]}),[Z,A]=Tw(B),U=fr(k);Nn(()=>{F&&(U==null||U())},[F,U]);const V=(re=ae.arrow)==null?void 0:re.x,M=(be=ae.arrow)==null?void 0:be.y,se=((fe=ae.arrow)==null?void 0:fe.centerOffset)!==0,[X,ce]=S.useState();return Nn(()=>{N&&ce(window.getComputedStyle(N).zIndex)},[N]),s.jsx("div",{ref:le.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:F?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(we=ae.transformOrigin)==null?void 0:we.x,(Ee=ae.transformOrigin)==null?void 0:Ee.y].join(" "),...((Se=ae.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(oM,{scope:a,placedSide:Z,onArrowChange:O,arrowX:V,arrowY:M,shouldHideArrow:se,children:s.jsx(Ge.div,{"data-side":Z,"data-align":A,...j,ref:D,style:{...j.style,animation:F?void 0:"none"}})})})});Cw.displayName=cp;var Nw="PopperArrow",cM={top:"bottom",right:"left",bottom:"top",left:"right"},Ew=S.forwardRef(function(r,a){const{__scopePopper:l,...o}=r,c=uM(Nw,l),d=cM[c.placedSide];return s.jsx("span",{ref:c.onArrowChange,style:{position:"absolute",left:c.arrowX,top:c.arrowY,[d]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[c.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[c.placedSide],visibility:c.shouldHideArrow?"hidden":void 0},children:s.jsx(iM,{...o,ref:a,style:{...o.style,display:"block"}})})});Ew.displayName=Nw;function dM(e){return e!==null}var fM=e=>({name:"transformOrigin",options:e,fn(r){var T,N,R;const{placement:a,rects:l,middlewareData:o}=r,d=((T=o.arrow)==null?void 0:T.centerOffset)!==0,f=d?0:e.arrowWidth,h=d?0:e.arrowHeight,[m,x]=Tw(a),v={start:"0%",center:"50%",end:"100%"}[x],b=(((N=o.arrow)==null?void 0:N.x)??0)+f/2,y=(((R=o.arrow)==null?void 0:R.y)??0)+h/2;let k="",j="";return m==="bottom"?(k=d?v:`${b}px`,j=`${-h}px`):m==="top"?(k=d?v:`${b}px`,j=`${l.floating.height+h}px`):m==="right"?(k=`${-h}px`,j=d?v:`${y}px`):m==="left"&&(k=`${l.floating.width+h}px`,j=d?v:`${y}px`),{data:{x:k,y:j}}}});function Tw(e){const[r,a="center"]=e.split("-");return[r,a]}var Aw=Sw,_w=kw,Mw=Cw,Rw=Ew;function dp(e){const r=S.useRef({value:e,previous:e});return S.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}var hM="VisuallyHidden",Dw=S.forwardRef((e,r)=>s.jsx(Ge.span,{...e,ref:r,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));Dw.displayName=hM;var mM=[" ","Enter","ArrowUp","ArrowDown"],pM=[" ","Enter"],wo="Select",[Bc,Ic,gM]=tp(wo),[ts]=Nr(wo,[gM,Uc]),qc=Uc(),[xM,xl]=ts(wo),[vM,yM]=ts(wo),Ow=e=>{const{__scopeSelect:r,children:a,open:l,defaultOpen:o,onOpenChange:c,value:d,defaultValue:f,onValueChange:h,dir:m,name:x,autoComplete:v,disabled:b,required:y,form:k}=e,j=qc(r),[T,N]=S.useState(null),[R,D]=S.useState(null),[I,O]=S.useState(!1),E=Mc(m),[C=!1,z]=nl({prop:l,defaultProp:o,onChange:c}),[Y,q]=nl({prop:d,defaultProp:f,onChange:h}),P=S.useRef(null),K=T?k||!!T.closest("form"):!0,[ue,le]=S.useState(new Set),W=Array.from(ue).map(B=>B.props.value).join(";");return s.jsx(Aw,{...j,children:s.jsxs(xM,{required:y,scope:r,trigger:T,onTriggerChange:N,valueNode:R,onValueNodeChange:D,valueNodeHasChildren:I,onValueNodeHasChildrenChange:O,contentId:Pr(),value:Y,onValueChange:q,open:C,onOpenChange:z,dir:E,triggerPointerDownPosRef:P,disabled:b,children:[s.jsx(Bc.Provider,{scope:r,children:s.jsx(vM,{scope:e.__scopeSelect,onNativeOptionAdd:S.useCallback(B=>{le(F=>new Set(F).add(B))},[]),onNativeOptionRemove:S.useCallback(B=>{le(F=>{const ae=new Set(F);return ae.delete(B),ae})},[]),children:a})}),K?s.jsxs(rS,{"aria-hidden":!0,required:y,tabIndex:-1,name:x,autoComplete:v,value:Y,onChange:B=>q(B.target.value),disabled:b,form:k,children:[Y===void 0?s.jsx("option",{value:""}):null,Array.from(ue)]},W):null]})})};Ow.displayName=wo;var zw="SelectTrigger",Lw=S.forwardRef((e,r)=>{const{__scopeSelect:a,disabled:l=!1,...o}=e,c=qc(a),d=xl(zw,a),f=d.disabled||l,h=ft(r,d.onTriggerChange),m=Ic(a),x=S.useRef("touch"),[v,b,y]=aS(j=>{const T=m().filter(D=>!D.disabled),N=T.find(D=>D.value===d.value),R=lS(T,j,N);R!==void 0&&d.onValueChange(R.value)}),k=j=>{f||(d.onOpenChange(!0),y()),j&&(d.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return s.jsx(_w,{asChild:!0,...c,children:s.jsx(Ge.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":nS(d.value)?"":void 0,...o,ref:h,onClick:Ae(o.onClick,j=>{j.currentTarget.focus(),x.current!=="mouse"&&k(j)}),onPointerDown:Ae(o.onPointerDown,j=>{x.current=j.pointerType;const T=j.target;T.hasPointerCapture(j.pointerId)&&T.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(k(j),j.preventDefault())}),onKeyDown:Ae(o.onKeyDown,j=>{const T=v.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&b(j.key),!(T&&j.key===" ")&&mM.includes(j.key)&&(k(),j.preventDefault())})})})});Lw.displayName=zw;var Uw="SelectValue",Bw=S.forwardRef((e,r)=>{const{__scopeSelect:a,className:l,style:o,children:c,placeholder:d="",...f}=e,h=xl(Uw,a),{onValueNodeHasChildrenChange:m}=h,x=c!==void 0,v=ft(r,h.onValueNodeChange);return Nn(()=>{m(x)},[m,x]),s.jsx(Ge.span,{...f,ref:v,style:{pointerEvents:"none"},children:nS(h.value)?s.jsx(s.Fragment,{children:d}):c})});Bw.displayName=Uw;var bM="SelectIcon",Iw=S.forwardRef((e,r)=>{const{__scopeSelect:a,children:l,...o}=e;return s.jsx(Ge.span,{"aria-hidden":!0,...o,ref:r,children:l||"▼"})});Iw.displayName=bM;var wM="SelectPortal",qw=e=>s.jsx(Ec,{asChild:!0,...e});qw.displayName=wM;var Xl="SelectContent",Hw=S.forwardRef((e,r)=>{const a=xl(Xl,e.__scopeSelect),[l,o]=S.useState();if(Nn(()=>{o(new DocumentFragment)},[]),!a.open){const c=l;return c?yo.createPortal(s.jsx(Pw,{scope:e.__scopeSelect,children:s.jsx(Bc.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),c):null}return s.jsx($w,{...e,ref:r})});Hw.displayName=Xl;var br=10,[Pw,vl]=ts(Xl),SM="SelectContentImpl",$w=S.forwardRef((e,r)=>{const{__scopeSelect:a,position:l="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:c,onPointerDownOutside:d,side:f,sideOffset:h,align:m,alignOffset:x,arrowPadding:v,collisionBoundary:b,collisionPadding:y,sticky:k,hideWhenDetached:j,avoidCollisions:T,...N}=e,R=xl(Xl,a),[D,I]=S.useState(null),[O,E]=S.useState(null),C=ft(r,re=>I(re)),[z,Y]=S.useState(null),[q,P]=S.useState(null),K=Ic(a),[ue,le]=S.useState(!1),W=S.useRef(!1);S.useEffect(()=>{if(D)return Km(D)},[D]),Xm();const B=S.useCallback(re=>{const[be,...fe]=K().map(Se=>Se.ref.current),[we]=fe.slice(-1),Ee=document.activeElement;for(const Se of re)if(Se===Ee||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===be&&O&&(O.scrollTop=0),Se===we&&O&&(O.scrollTop=O.scrollHeight),Se==null||Se.focus(),document.activeElement!==Ee))return},[K,O]),F=S.useCallback(()=>B([z,D]),[B,z,D]);S.useEffect(()=>{ue&&F()},[ue,F]);const{onOpenChange:ae,triggerPointerDownPosRef:Z}=R;S.useEffect(()=>{if(D){let re={x:0,y:0};const be=we=>{var Ee,Se;re={x:Math.abs(Math.round(we.pageX)-(((Ee=Z.current)==null?void 0:Ee.x)??0)),y:Math.abs(Math.round(we.pageY)-(((Se=Z.current)==null?void 0:Se.y)??0))}},fe=we=>{re.x<=10&&re.y<=10?we.preventDefault():D.contains(we.target)||ae(!1),document.removeEventListener("pointermove",be),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",be),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",be),document.removeEventListener("pointerup",fe,{capture:!0})}}},[D,ae,Z]),S.useEffect(()=>{const re=()=>ae(!1);return window.addEventListener("blur",re),window.addEventListener("resize",re),()=>{window.removeEventListener("blur",re),window.removeEventListener("resize",re)}},[ae]);const[A,U]=aS(re=>{const be=K().filter(Ee=>!Ee.disabled),fe=be.find(Ee=>Ee.ref.current===document.activeElement),we=lS(be,re,fe);we&&setTimeout(()=>we.ref.current.focus())}),V=S.useCallback((re,be,fe)=>{const we=!W.current&&!fe;(R.value!==void 0&&R.value===be||we)&&(Y(re),we&&(W.current=!0))},[R.value]),M=S.useCallback(()=>D==null?void 0:D.focus(),[D]),se=S.useCallback((re,be,fe)=>{const we=!W.current&&!fe;(R.value!==void 0&&R.value===be||we)&&P(re)},[R.value]),X=l==="popper"?xm:Fw,ce=X===xm?{side:f,sideOffset:h,align:m,alignOffset:x,arrowPadding:v,collisionBoundary:b,collisionPadding:y,sticky:k,hideWhenDetached:j,avoidCollisions:T}:{};return s.jsx(Pw,{scope:a,content:D,viewport:O,onViewportChange:E,itemRefCallback:V,selectedItem:z,onItemLeave:M,itemTextRefCallback:se,focusSelectedItem:F,selectedItemText:q,position:l,isPositioned:ue,searchRef:A,children:s.jsx(Ac,{as:xa,allowPinchZoom:!0,children:s.jsx(Nc,{asChild:!0,trapped:R.open,onMountAutoFocus:re=>{re.preventDefault()},onUnmountAutoFocus:Ae(o,re=>{var be;(be=R.trigger)==null||be.focus({preventScroll:!0}),re.preventDefault()}),children:s.jsx(Cc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:re=>re.preventDefault(),onDismiss:()=>R.onOpenChange(!1),children:s.jsx(X,{role:"listbox",id:R.contentId,"data-state":R.open?"open":"closed",dir:R.dir,onContextMenu:re=>re.preventDefault(),...N,...ce,onPlaced:()=>le(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Ae(N.onKeyDown,re=>{const be=re.ctrlKey||re.altKey||re.metaKey;if(re.key==="Tab"&&re.preventDefault(),!be&&re.key.length===1&&U(re.key),["ArrowUp","ArrowDown","Home","End"].includes(re.key)){let we=K().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);if(["ArrowUp","End"].includes(re.key)&&(we=we.slice().reverse()),["ArrowUp","ArrowDown"].includes(re.key)){const Ee=re.target,Se=we.indexOf(Ee);we=we.slice(Se+1)}setTimeout(()=>B(we)),re.preventDefault()}})})})})})})});$w.displayName=SM;var jM="SelectItemAlignedPosition",Fw=S.forwardRef((e,r)=>{const{__scopeSelect:a,onPlaced:l,...o}=e,c=xl(Xl,a),d=vl(Xl,a),[f,h]=S.useState(null),[m,x]=S.useState(null),v=ft(r,C=>x(C)),b=Ic(a),y=S.useRef(!1),k=S.useRef(!0),{viewport:j,selectedItem:T,selectedItemText:N,focusSelectedItem:R}=d,D=S.useCallback(()=>{if(c.trigger&&c.valueNode&&f&&m&&j&&T&&N){const C=c.trigger.getBoundingClientRect(),z=m.getBoundingClientRect(),Y=c.valueNode.getBoundingClientRect(),q=N.getBoundingClientRect();if(c.dir!=="rtl"){const Ee=q.left-z.left,Se=Y.left-Ee,Ie=C.left-Se,Be=C.width+Ie,Mt=Math.max(Be,z.width),Nt=window.innerWidth-br,Et=wb(Se,[br,Math.max(br,Nt-Mt)]);f.style.minWidth=Be+"px",f.style.left=Et+"px"}else{const Ee=z.right-q.right,Se=window.innerWidth-Y.right-Ee,Ie=window.innerWidth-C.right-Se,Be=C.width+Ie,Mt=Math.max(Be,z.width),Nt=window.innerWidth-br,Et=wb(Se,[br,Math.max(br,Nt-Mt)]);f.style.minWidth=Be+"px",f.style.right=Et+"px"}const P=b(),K=window.innerHeight-br*2,ue=j.scrollHeight,le=window.getComputedStyle(m),W=parseInt(le.borderTopWidth,10),B=parseInt(le.paddingTop,10),F=parseInt(le.borderBottomWidth,10),ae=parseInt(le.paddingBottom,10),Z=W+B+ue+ae+F,A=Math.min(T.offsetHeight*5,Z),U=window.getComputedStyle(j),V=parseInt(U.paddingTop,10),M=parseInt(U.paddingBottom,10),se=C.top+C.height/2-br,X=K-se,ce=T.offsetHeight/2,re=T.offsetTop+ce,be=W+B+re,fe=Z-be;if(be<=se){const Ee=P.length>0&&T===P[P.length-1].ref.current;f.style.bottom="0px";const Se=m.clientHeight-j.offsetTop-j.offsetHeight,Ie=Math.max(X,ce+(Ee?M:0)+Se+F),Be=be+Ie;f.style.height=Be+"px"}else{const Ee=P.length>0&&T===P[0].ref.current;f.style.top="0px";const Ie=Math.max(se,W+j.offsetTop+(Ee?V:0)+ce)+fe;f.style.height=Ie+"px",j.scrollTop=be-se+j.offsetTop}f.style.margin=`${br}px 0`,f.style.minHeight=A+"px",f.style.maxHeight=K+"px",l==null||l(),requestAnimationFrame(()=>y.current=!0)}},[b,c.trigger,c.valueNode,f,m,j,T,N,c.dir,l]);Nn(()=>D(),[D]);const[I,O]=S.useState();Nn(()=>{m&&O(window.getComputedStyle(m).zIndex)},[m]);const E=S.useCallback(C=>{C&&k.current===!0&&(D(),R==null||R(),k.current=!1)},[D,R]);return s.jsx(CM,{scope:a,contentWrapper:f,shouldExpandOnScrollRef:y,onScrollButtonChange:E,children:s.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:s.jsx(Ge.div,{...o,ref:v,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});Fw.displayName=jM;var kM="SelectPopperPosition",xm=S.forwardRef((e,r)=>{const{__scopeSelect:a,align:l="start",collisionPadding:o=br,...c}=e,d=qc(a);return s.jsx(Mw,{...d,...c,ref:r,align:l,collisionPadding:o,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});xm.displayName=kM;var[CM,fp]=ts(Xl,{}),vm="SelectViewport",Vw=S.forwardRef((e,r)=>{const{__scopeSelect:a,nonce:l,...o}=e,c=vl(vm,a),d=fp(vm,a),f=ft(r,c.onViewportChange),h=S.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),s.jsx(Bc.Slot,{scope:a,children:s.jsx(Ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ae(o.onScroll,m=>{const x=m.currentTarget,{contentWrapper:v,shouldExpandOnScrollRef:b}=d;if(b!=null&&b.current&&v){const y=Math.abs(h.current-x.scrollTop);if(y>0){const k=window.innerHeight-br*2,j=parseFloat(v.style.minHeight),T=parseFloat(v.style.height),N=Math.max(j,T);if(N0?I:0,v.style.justifyContent="flex-end")}}}h.current=x.scrollTop})})})]})});Vw.displayName=vm;var Gw="SelectGroup",[NM,EM]=ts(Gw),TM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e,o=Pr();return s.jsx(NM,{scope:a,id:o,children:s.jsx(Ge.div,{role:"group","aria-labelledby":o,...l,ref:r})})});TM.displayName=Gw;var Yw="SelectLabel",AM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e,o=EM(Yw,a);return s.jsx(Ge.div,{id:o.id,...l,ref:r})});AM.displayName=Yw;var hc="SelectItem",[_M,Xw]=ts(hc),Kw=S.forwardRef((e,r)=>{const{__scopeSelect:a,value:l,disabled:o=!1,textValue:c,...d}=e,f=xl(hc,a),h=vl(hc,a),m=f.value===l,[x,v]=S.useState(c??""),[b,y]=S.useState(!1),k=ft(r,R=>{var D;return(D=h.itemRefCallback)==null?void 0:D.call(h,R,l,o)}),j=Pr(),T=S.useRef("touch"),N=()=>{o||(f.onValueChange(l),f.onOpenChange(!1))};if(l==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(_M,{scope:a,value:l,disabled:o,textId:j,isSelected:m,onItemTextChange:S.useCallback(R=>{v(D=>D||((R==null?void 0:R.textContent)??"").trim())},[]),children:s.jsx(Bc.ItemSlot,{scope:a,value:l,disabled:o,textValue:x,children:s.jsx(Ge.div,{role:"option","aria-labelledby":j,"data-highlighted":b?"":void 0,"aria-selected":m&&b,"data-state":m?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...d,ref:k,onFocus:Ae(d.onFocus,()=>y(!0)),onBlur:Ae(d.onBlur,()=>y(!1)),onClick:Ae(d.onClick,()=>{T.current!=="mouse"&&N()}),onPointerUp:Ae(d.onPointerUp,()=>{T.current==="mouse"&&N()}),onPointerDown:Ae(d.onPointerDown,R=>{T.current=R.pointerType}),onPointerMove:Ae(d.onPointerMove,R=>{var D;T.current=R.pointerType,o?(D=h.onItemLeave)==null||D.call(h):T.current==="mouse"&&R.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ae(d.onPointerLeave,R=>{var D;R.currentTarget===document.activeElement&&((D=h.onItemLeave)==null||D.call(h))}),onKeyDown:Ae(d.onKeyDown,R=>{var I;((I=h.searchRef)==null?void 0:I.current)!==""&&R.key===" "||(pM.includes(R.key)&&N(),R.key===" "&&R.preventDefault())})})})})});Kw.displayName=hc;var to="SelectItemText",Qw=S.forwardRef((e,r)=>{const{__scopeSelect:a,className:l,style:o,...c}=e,d=xl(to,a),f=vl(to,a),h=Xw(to,a),m=yM(to,a),[x,v]=S.useState(null),b=ft(r,N=>v(N),h.onItemTextChange,N=>{var R;return(R=f.itemTextRefCallback)==null?void 0:R.call(f,N,h.value,h.disabled)}),y=x==null?void 0:x.textContent,k=S.useMemo(()=>s.jsx("option",{value:h.value,disabled:h.disabled,children:y},h.value),[h.disabled,h.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:T}=m;return Nn(()=>(j(k),()=>T(k)),[j,T,k]),s.jsxs(s.Fragment,{children:[s.jsx(Ge.span,{id:h.textId,...c,ref:b}),h.isSelected&&d.valueNode&&!d.valueNodeHasChildren?yo.createPortal(c.children,d.valueNode):null]})});Qw.displayName=to;var Zw="SelectItemIndicator",Jw=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e;return Xw(Zw,a).isSelected?s.jsx(Ge.span,{"aria-hidden":!0,...l,ref:r}):null});Jw.displayName=Zw;var ym="SelectScrollUpButton",Ww=S.forwardRef((e,r)=>{const a=vl(ym,e.__scopeSelect),l=fp(ym,e.__scopeSelect),[o,c]=S.useState(!1),d=ft(r,l.onScrollButtonChange);return Nn(()=>{if(a.viewport&&a.isPositioned){let f=function(){const m=h.scrollTop>0;c(m)};const h=a.viewport;return f(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[a.viewport,a.isPositioned]),o?s.jsx(tS,{...e,ref:d,onAutoScroll:()=>{const{viewport:f,selectedItem:h}=a;f&&h&&(f.scrollTop=f.scrollTop-h.offsetHeight)}}):null});Ww.displayName=ym;var bm="SelectScrollDownButton",eS=S.forwardRef((e,r)=>{const a=vl(bm,e.__scopeSelect),l=fp(bm,e.__scopeSelect),[o,c]=S.useState(!1),d=ft(r,l.onScrollButtonChange);return Nn(()=>{if(a.viewport&&a.isPositioned){let f=function(){const m=h.scrollHeight-h.clientHeight,x=Math.ceil(h.scrollTop)h.removeEventListener("scroll",f)}},[a.viewport,a.isPositioned]),o?s.jsx(tS,{...e,ref:d,onAutoScroll:()=>{const{viewport:f,selectedItem:h}=a;f&&h&&(f.scrollTop=f.scrollTop+h.offsetHeight)}}):null});eS.displayName=bm;var tS=S.forwardRef((e,r)=>{const{__scopeSelect:a,onAutoScroll:l,...o}=e,c=vl("SelectScrollButton",a),d=S.useRef(null),f=Ic(a),h=S.useCallback(()=>{d.current!==null&&(window.clearInterval(d.current),d.current=null)},[]);return S.useEffect(()=>()=>h(),[h]),Nn(()=>{var x;const m=f().find(v=>v.ref.current===document.activeElement);(x=m==null?void 0:m.ref.current)==null||x.scrollIntoView({block:"nearest"})},[f]),s.jsx(Ge.div,{"aria-hidden":!0,...o,ref:r,style:{flexShrink:0,...o.style},onPointerDown:Ae(o.onPointerDown,()=>{d.current===null&&(d.current=window.setInterval(l,50))}),onPointerMove:Ae(o.onPointerMove,()=>{var m;(m=c.onItemLeave)==null||m.call(c),d.current===null&&(d.current=window.setInterval(l,50))}),onPointerLeave:Ae(o.onPointerLeave,()=>{h()})})}),MM="SelectSeparator",RM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e;return s.jsx(Ge.div,{"aria-hidden":!0,...l,ref:r})});RM.displayName=MM;var wm="SelectArrow",DM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e,o=qc(a),c=xl(wm,a),d=vl(wm,a);return c.open&&d.position==="popper"?s.jsx(Rw,{...o,...l,ref:r}):null});DM.displayName=wm;function nS(e){return e===""||e===void 0}var rS=S.forwardRef((e,r)=>{const{value:a,...l}=e,o=S.useRef(null),c=ft(r,o),d=dp(a);return S.useEffect(()=>{const f=o.current,h=window.HTMLSelectElement.prototype,x=Object.getOwnPropertyDescriptor(h,"value").set;if(d!==a&&x){const v=new Event("change",{bubbles:!0});x.call(f,a),f.dispatchEvent(v)}},[d,a]),s.jsx(Dw,{asChild:!0,children:s.jsx("select",{...l,ref:c,defaultValue:a})})});rS.displayName="BubbleSelect";function aS(e){const r=fr(e),a=S.useRef(""),l=S.useRef(0),o=S.useCallback(d=>{const f=a.current+d;r(f),(function h(m){a.current=m,window.clearTimeout(l.current),m!==""&&(l.current=window.setTimeout(()=>h(""),1e3))})(f)},[r]),c=S.useCallback(()=>{a.current="",window.clearTimeout(l.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(l.current),[]),[a,o,c]}function lS(e,r,a){const o=r.length>1&&Array.from(r).every(m=>m===r[0])?r[0]:r,c=a?e.indexOf(a):-1;let d=OM(e,Math.max(c,0));o.length===1&&(d=d.filter(m=>m!==a));const h=d.find(m=>m.textValue.toLowerCase().startsWith(o.toLowerCase()));return h!==a?h:void 0}function OM(e,r){return e.map((a,l)=>e[(r+l)%e.length])}var zM=Ow,LM=Lw,UM=Bw,BM=Iw,IM=qw,qM=Hw,HM=Vw,PM=Kw,$M=Qw,FM=Jw,VM=Ww,GM=eS;function Sr({...e}){return s.jsx(zM,{"data-slot":"select",...e})}function jr({...e}){return s.jsx(UM,{"data-slot":"select-value",...e})}function kr({className:e,size:r="default",children:a,...l}){return s.jsxs(LM,{"data-slot":"select-trigger","data-size":r,className:Ne("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...l,children:[a,s.jsx(BM,{asChild:!0,children:s.jsx(Ji,{className:"size-4 opacity-50"})})]})}function Cr({className:e,children:r,position:a="popper",...l}){return s.jsx(IM,{children:s.jsxs(qM,{"data-slot":"select-content",className:Ne("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,...l,children:[s.jsx(YM,{}),s.jsx(HM,{className:Ne("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),s.jsx(XM,{})]})})}function hr({className:e,children:r,...a}){return s.jsxs(PM,{"data-slot":"select-item",className:Ne("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...a,children:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(FM,{children:s.jsx(jc,{className:"size-4"})})}),s.jsx($M,{children:r})]})}function YM({className:e,...r}){return s.jsx(VM,{"data-slot":"select-scroll-up-button",className:Ne("flex cursor-default items-center justify-center py-1",e),...r,children:s.jsx(sE,{className:"size-4"})})}function XM({className:e,...r}){return s.jsx(GM,{"data-slot":"select-scroll-down-button",className:Ne("flex cursor-default items-center justify-center py-1",e),...r,children:s.jsx(Ji,{className:"size-4"})})}const _h="all";function Lt({label:e,value:r,onChange:a,options:l,allLabel:o}){const c=l.map(d=>typeof d=="string"?{value:d,label:d}:d);return s.jsxs("div",{className:"relative",children:[s.jsxs(Sr,{value:r||_h,onValueChange:d=>a(d===_h?"":d),children:[s.jsx(kr,{className:"w-44","aria-label":e,children:s.jsx(jr,{className:r?"pr-6":void 0})}),s.jsxs(Cr,{children:[s.jsx(hr,{value:_h,children:o}),c.map(d=>s.jsx(hr,{value:d.value,children:d.label},d.value))]})]}),r&&s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Clear ${e.toLowerCase()} filter`,title:`Clear ${e.toLowerCase()} filter`,className:"absolute top-1/2 right-8 size-6 -translate-y-1/2",onClick:()=>a(""),children:s.jsx(kc,{className:"size-3.5"})})]})}function KM({rows:e,withPrincipal:r}){return s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[r&&s.jsx(ge,{children:"User"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{children:"Endpoint"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Cost"})]})}),s.jsxs(vn,{children:[e.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:r?8:7,className:"text-muted-foreground",children:"No usage recorded yet."})}),e.map((a,l)=>s.jsxs(Oe,{children:[r&&s.jsx(de,{className:"wrap-anywhere",children:a.principal}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:a.model}),s.jsx(de,{children:a.endpoint}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(a.requests)}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(a.units.input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(a.units.cached_input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(a.units.output_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:a.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Pm(a.cost)})]},l))]})]})}const Mh=[{key:"24h",label:"Last 24 hours",bucket:"hour",count:24},{key:"7d",label:"Last 7 days",bucket:"day",count:7},{key:"30d",label:"Last 30 days",bucket:"day",count:30},{key:"12w",label:"Last 12 weeks",bucket:"week",count:12},{key:"12mo",label:"Last 12 months",bucket:"month",count:12},{key:"all",label:"All time",bucket:"month",count:0}];function QM(e,r){const a=new Date(e);return a.setUTCMilliseconds(0),a.setUTCSeconds(0),a.setUTCMinutes(0),r==="hour"?a:(a.setUTCHours(0),r==="month"?(a.setUTCDate(1),a):(r==="week"&&a.setUTCDate(a.getUTCDate()-(a.getUTCDay()+6)%7),a))}function Rb(e,r,a){const l=new Date(e);return r==="hour"?l.setUTCHours(l.getUTCHours()+a):r==="day"?l.setUTCDate(l.getUTCDate()+a):r==="week"?l.setUTCDate(l.getUTCDate()+a*7):l.setUTCMonth(l.getUTCMonth()+a),l}const Za={timeZone:"UTC"};function ZM(e,r){const a=new Date(e);return r==="hour"?a.toLocaleTimeString(void 0,{...Za,hour:"2-digit",minute:"2-digit"}):r==="month"?a.toLocaleDateString(void 0,{...Za,month:"short",year:"2-digit"}):a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric"})}function JM(e,r){const a=new Date(e);switch(r){case"hour":return`${a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric"})}, ${a.toLocaleTimeString(void 0,{...Za,hour:"2-digit",minute:"2-digit"})} UTC`;case"week":return`Week of ${a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric",year:"numeric"})}`;case"month":return a.toLocaleDateString(void 0,{...Za,month:"long",year:"numeric"});default:return a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric",year:"numeric"})}}function Lr(e,r){return e.reduce((a,l)=>a+r(l),0)}function Qu(e,r,a){return!a||r===0?null:(e-r)/r}function fa(e){return(e.units.input_tokens??0)+(e.units.output_tokens??0)}function Rh(e,r,a){const l=new Map;for(const o of e){const c=r(o);let d=l.get(c);d||(d=a(o),l.set(c,d)),d.requests+=o.requests,d.cancelled+=o.cancelled,o.cost!==null&&(d.cost=(d.cost??0)+o.cost);for(const[f,h]of Object.entries(o.units))d.units[f]=(d.units[f]??0)+h}return l}function iS(e){const r={requests:0,cost:null,units:{}};for(const a of e){r.requests+=a.requests,a.cost!==null&&(r.cost=(r.cost??0)+a.cost);for(const[l,o]of Object.entries(a.units))r.units[l]=(r.units[l]??0)+o}return r}function Db(e,r,a){const l=(o,c)=>({label:c??o.principal??"",value:r(o),rows:a(o)});return _c(e,o=>l(o),o=>l(iS(o),`Other (${o.length} users)`))}function WM({ssoEnabled:e}){var ne;const[r,a]=Gt("range","30d"),[l,o]=Gt("user"),[c,d]=Gt("provider"),[f,h]=Gt("model"),[m,x]=Gt("client"),[v,b]=S.useState(!1),[y,k]=S.useState(!1),[j,T]=S.useState(!1),N=Mh.find(L=>L.key===r)??Mh[2],D=QM(new Date,N.bucket),I=N.count?Rb(D,N.bucket,-(N.count-1)):null,O=I?Rb(I,N.bucket,-N.count):null,E=(l?`&principal=${encodeURIComponent(l)}`:"")+(c?`&provider=${encodeURIComponent(c)}`:"")+(f?`&model=${encodeURIComponent(f)}`:"")+(m?`&client=${encodeURIComponent(m)}`:""),C=Ut(()=>He.get(`/stats/series?bucket=${N.bucket}`+(O?`&since=${O.toISOString()}`:"")+E),[r,l,c,f,m]),z=Ut(()=>He.get("/stats/summary"+(I?`?since=${I.toISOString()}`:"")),[r]),Y=((ne=C.data)==null?void 0:ne.series)??[],q=I?I.getTime():-1/0,P=Y.filter(L=>new Date(L.start).getTime()>=q),K=Y.filter(L=>new Date(L.start).getTime()0,le=L=>L.units.input_tokens??0,W=L=>L.units.output_tokens??0,B=L=>L.units.cached_input_tokens??0,F=Lr(P,L=>L.requests),ae=Lr(P,le),Z=Lr(P,B),A=Lr(P,W),U=Lr(P,L=>L.cost??0),V=P.some(L=>L.cost!==null),M=Lr(P,L=>L.unpriced_requests),se=L=>new Date(L.start).getTime()===D.getTime(),X=L=>ZM(L.start,N.bucket),ce=L=>JM(L.start,N.bucket)+(se(L)?" · in progress":""),re=P.map(L=>{const he=L.ok+L.cancelled,ke=[...L.cancelled?[{label:"cancelled",value:Ht(L.cancelled)}]:[],...he>0?[{label:"avg input / request",value:Re(Math.round(le(L)/he))},{label:"avg output / response",value:Re(Math.round(W(L)/he))}]:[]];return{label:X(L),title:ce(L),values:[he,L.failed],rows:ke.length?ke:void 0}}),be=P.map(L=>({label:X(L),title:ce(L),values:[le(L),B(L),W(L)]})),fe=P.map(L=>({label:X(L),title:ce(L),values:[L.cost],rows:L.unpriced_requests?[{label:"unpriced requests",value:Ht(L.unpriced_requests)}]:void 0})),we=S.useMemo(()=>{var L;return((L=z.data)==null?void 0:L.usage)??[]},[z.data]),Ee=S.useMemo(()=>({principals:[...new Set(we.map(L=>L.principal))].sort(),providers:[...new Set(we.map(L=>L.provider))].sort(),models:[...new Set(we.filter(L=>L.model).map(L=>L.model))].sort(),clients:[...new Set(we.filter(L=>L.client).map(L=>ao(L.client)))].sort()}),[we]),Se=S.useMemo(()=>we.filter(L=>(!l||L.principal===l)&&(!c||L.provider===c)&&(!f||L.model===f)&&(!m||ao(L.client)===m)),[we,l,c,f,m]),Ie=S.useMemo(()=>[...Rh(Se,L=>L.model,L=>({model:L.model,requests:0,cancelled:0,cost:null,units:{}})).values()].sort((L,he)=>fa(he)-fa(L)),[Se]),Be=Ie.reduce((L,he)=>L+fa(he),0),{slices:Mt,overflow:Nt}=S.useMemo(()=>{const L=(he,ke)=>({label:ke??(he.model||"(none)"),value:fa(he),rows:[{label:"requests",value:Ht(he.requests)},...he.units.cached_input_tokens?[{label:"cached input",value:Re(he.units.cached_input_tokens)}]:[],...he.cost!==null?[{label:"cost",value:Ir(he.cost)}]:[]]});return _c(Ie,he=>L(he),he=>L(iS(he),`Other (${he.length} models)`))},[Ie]),Et=S.useMemo(()=>[...Rh(Se,L=>L.principal,L=>({principal:L.principal,requests:0,cancelled:0,cost:null,units:{}})).values()],[Se]),Bt=S.useMemo(()=>Db([...Et].sort((L,he)=>fa(he)-fa(L)),fa,L=>[{label:"requests",value:Ht(L.requests)},...L.units.cached_input_tokens?[{label:"cached input",value:Re(L.units.cached_input_tokens)}]:[],...L.cost!==null?[{label:"cost",value:Ir(L.cost)}]:[]]),[Et]),Rt=S.useMemo(()=>Db(Et.filter(L=>L.cost!==null).sort((L,he)=>(he.cost??0)-(L.cost??0)),L=>L.cost??0,L=>[{label:"tokens",value:Re(fa(L))},{label:"requests",value:Ht(L.requests)}]),[Et]),Dt=S.useMemo(()=>{const L=new Map;for(const he of Se){const ke=he.client?j?tN(he.client):ao(he.client):"unknown";let ze=L.get(ke);ze||(ze={label:ke,requests:0,cancelled:0,cost:null,units:{},exact:new Set},L.set(ke,ze)),ze.requests+=he.requests,ze.cancelled+=he.cancelled,he.cost!==null&&(ze.cost=(ze.cost??0)+he.cost);for(const[an,Tn]of Object.entries(he.units))ze.units[an]=(ze.units[an]??0)+Tn;he.client&&ze.exact.add(he.client)}return[...L.values()].sort((he,ke)=>ke.requests-he.requests)},[Se,j]),zt=Dt.reduce((L,he)=>L+he.requests,0),ye=S.useMemo(()=>Dt.map(L=>({label:L.label,title:L.exact.size?[...L.exact].sort().join(` +`):"no User-Agent header",value:L.requests})),[Dt]),pt=S.useMemo(()=>[...Rh(Se,he=>`${he.principal}\0${he.model}\0${he.endpoint}`,he=>({principal:he.principal,model:he.model,endpoint:he.endpoint,requests:0,cancelled:0,cost:null,units:{}})).values()].sort((he,ke)=>he.principal!==ke.principal?he.principal.localeCompare(ke.principal):he.model!==ke.model?he.model.localeCompare(ke.model):he.endpoint.localeCompare(ke.endpoint)),[Se]),Q=C.loading&&!C.data||z.loading&&!z.data,Pe=!Q&&(C.loading||z.loading);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Sr,{value:r,onValueChange:a,children:[s.jsx(kr,{className:"w-44","aria-label":"Time range",children:s.jsx(jr,{})}),s.jsx(Cr,{children:Mh.map(L=>s.jsx(hr,{value:L.key,children:L.label},L.key))})]}),s.jsx(Lt,{label:"User",value:l,onChange:o,options:Ee.principals,allLabel:"All users"}),s.jsx(Lt,{label:"Provider",value:c,onChange:d,options:Ee.providers,allLabel:"All providers"}),s.jsx(Lt,{label:"Model",value:f,onChange:h,options:Ee.models,allLabel:"All models"}),s.jsx(Lt,{label:"Client",value:m,onChange:x,options:Ee.clients,allLabel:"All clients"}),(l||c||f||m)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{o(""),d(""),h(""),x("")},children:[s.jsx(bo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>{C.reload(),z.reload()},children:s.jsx(pl,{})})]}),Q?s.jsx(kt,{}):C.error||z.error?s.jsx("p",{className:"text-sm text-destructive",children:C.error??z.error}):s.jsxs("div",{className:Pe?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Qn,{label:"Requests",value:Re(F),delta:Qu(F,Lr(K,L=>L.requests),ue)}),s.jsx(Qn,{label:"Input tokens",value:Re(ae),secondary:Z>0?`${Re(Z)} cached`:void 0,delta:Qu(ae,Lr(K,le),ue)}),s.jsx(Qn,{label:"Output tokens",value:Re(A),delta:Qu(A,Lr(K,W),ue)}),s.jsx(Qn,{label:"Cost",value:V?Ir(U):"unpriced",delta:V?Qu(U,Lr(K,L=>L.cost??0),ue):null,hint:M?`${Ht(M)} request${M===1?"":"s"} unpriced`:void 0})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Ke,{className:v?"min-w-0 lg:col-span-2":"min-w-0",children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Models"}),s.jsx(it,{children:"Share of total tokens, cached input excluded."})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":v?"Show chart":"Show all models as a table",title:v?"Show chart":"Show all models as a table",onClick:()=>b(L=>!L),children:v?s.jsx(lE,{}):s.jsx(cm,{})})]}),s.jsx(Qe,{children:v?s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Share"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Cost"})]})}),s.jsxs(vn,{children:[Ie.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No usage in this range."})}),Ie.map((L,he)=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:L.model||s.jsx("span",{className:"text-muted-foreground",children:"(none)"})}),s.jsx(de,{className:"text-right tabular-nums",children:Be>0?`${(fa(L)/Be*100).toFixed(1)}%`:""}),s.jsx(de,{className:"text-right tabular-nums",children:Re(L.requests)}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(L.units.input_tokens),children:L.units.input_tokens?Re(L.units.input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(L.units.cached_input_tokens),children:L.units.cached_input_tokens?Re(L.units.cached_input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(L.units.output_tokens),children:L.units.output_tokens?Re(L.units.output_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:L.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Ir(L.cost)})]},he))]})]}):s.jsx(lo,{slices:Mt,overflow:Nt,format:Re},`${r} ${l} ${c} ${f} ${m}`)})]}),s.jsxs(Ke,{className:y?"min-w-0 lg:col-span-2":"min-w-0",children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Clients"}),s.jsx(it,{children:j?"Requests per client version, from the User-Agent.":"Requests per client, from the User-Agent."})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Me,{variant:j?"secondary":"outline",size:"icon-sm","aria-label":j?"Group by tool":"Split by version","aria-pressed":j,title:j?"Group by tool":"Split by version",onClick:()=>T(L=>!L),children:s.jsx(yE,{})}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":y?"Show chart":"Show all clients as a table",title:y?"Show chart":"Show all clients as a table",onClick:()=>k(L=>!L),children:y?s.jsx(h1,{}):s.jsx(cm,{})})]})]}),s.jsx(Qe,{children:y?s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Client"}),s.jsx(ge,{className:"text-right",children:"Share"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Cost"})]})}),s.jsxs(vn,{children:[Dt.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No usage in this range."})}),Dt.map((L,he)=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",title:L.exact.size?[...L.exact].sort().join(` +`):void 0,children:L.label}),s.jsx(de,{className:"text-right tabular-nums",children:zt>0?`${(L.requests/zt*100).toFixed(1)}%`:""}),s.jsx(de,{className:"text-right tabular-nums",children:Re(L.requests)}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(L.units.input_tokens),children:L.units.input_tokens?Re(L.units.input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(L.units.cached_input_tokens),children:L.units.cached_input_tokens?Re(L.units.cached_input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(L.units.output_tokens),children:L.units.output_tokens?Re(L.units.output_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:L.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Ir(L.cost)})]},he))]})]}):s.jsx(Ki,{rows:ye,format:Re})})]}),e&&s.jsxs(s.Fragment,{children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"User tokens"}),s.jsx(it,{children:"Share of total tokens per user, cached input excluded."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:Bt.slices,overflow:Bt.overflow,format:Re},`${r} ${l} ${c} ${f} ${m}`)})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"User cost"}),s.jsx(it,{children:"Share of total cost per user."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:Rt.slices,overflow:Rt.overflow,format:Ir,emptyMessage:"Nothing priced in this range."},`${r} ${l} ${c} ${f} ${m}`)})]})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Tokens"}),s.jsxs(it,{children:["Input, cached input and output per ",N.bucket,"."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:be,series:[{...ma,name:"input"},{...ep,name:"cached"},{...Vl,name:"output"}],format:Re})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Requests"}),s.jsxs(it,{children:["Per ",N.bucket,", split by outcome."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:re,series:[{...ma,name:"ok"},{...Vl,name:"failed"}],format:Re,integer:!0})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Cost"}),s.jsxs(it,{children:["Per ",N.bucket,", from the model prices; unpriced stays empty, never zero."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:fe,series:[{...ma,name:"cost"}],format:L=>Ir(L),emptyMessage:"Nothing priced in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:l?"By model":"By user and model"}),s.jsxs(it,{children:["Totals by ",l?"":"user, ","model and endpoint."]})]}),s.jsx(Qe,{children:s.jsx(KM,{rows:pt,withPrincipal:!l})})]})]})]})}const cr=[{key:"24h",label:"Last 24 hours",bucket:"hour",count:24},{key:"7d",label:"Last 7 days",bucket:"day",count:7},{key:"30d",label:"Last 30 days",bucket:"day",count:30},{key:"12w",label:"Last 12 weeks",bucket:"week",count:12},{key:"12mo",label:"Last 12 months",bucket:"month",count:12},{key:"all",label:"All time",bucket:"month",count:0}];function Hc(e,r){const a=new Date(e);return a.setUTCMilliseconds(0),a.setUTCSeconds(0),a.setUTCMinutes(0),r==="hour"?a:(a.setUTCHours(0),r==="month"?(a.setUTCDate(1),a):(r==="week"&&a.setUTCDate(a.getUTCDate()-(a.getUTCDay()+6)%7),a))}function mo(e,r,a){const l=new Date(e);return r==="hour"?l.setUTCHours(l.getUTCHours()+a):r==="day"?l.setUTCDate(l.getUTCDate()+a):r==="week"?l.setUTCDate(l.getUTCDate()+a*7):l.setUTCMonth(l.getUTCMonth()+a),l}const Ja={timeZone:"UTC"};function hp(e,r){const a=new Date(e);return r==="hour"?a.toLocaleTimeString(void 0,{...Ja,hour:"2-digit",minute:"2-digit"}):r==="month"?a.toLocaleDateString(void 0,{...Ja,month:"short",year:"2-digit"}):a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric"})}function mp(e,r){const a=new Date(e);switch(r){case"hour":return`${a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric"})}, ${a.toLocaleTimeString(void 0,{...Ja,hour:"2-digit",minute:"2-digit"})} UTC`;case"week":return`Week of ${a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric",year:"numeric"})}`;case"month":return a.toLocaleDateString(void 0,{...Ja,month:"long",year:"numeric"});default:return a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric",year:"numeric"})}}const sS="untagged";function Qs(){return{requests:0,cost:null,units:{}}}function eR(e,r){e.requests+=r.requests,r.cost!==null&&(e.cost=(e.cost??0)+r.cost);for(const[a,l]of Object.entries(r.units))e.units[a]=(e.units[a]??0)+l}function Zu(e,r,a){const l=new Map;for(const o of e){const c=r(o);let d=l.get(c);d||(d=a(c),l.set(c,d)),eR(d,o)}return[...l.values()]}function tR(e){return(e.units.input_tokens??0)+(e.units.output_tokens??0)}function Xa(e,r){return e.reduce((a,l)=>a+r(l),0)}function Dh(e,r,a){return!a||r===0?null:(e-r)/r}function Ob(e){return ha(e.tags,"app")||sS}function nR(e){return ha(e.tags,"context")||sS}function rR(){var pt;const[e,r]=Gt("range","30d"),[a,l]=Gt("app"),[o,c]=Gt("context"),[d,f]=Gt("user"),[h,m]=Gt("model"),[x,v]=S.useState(!1),b=cr.find(Q=>Q.key===e)??cr[2],k=Hc(new Date,b.bucket),j=b.count?mo(k,b.bucket,-(b.count-1)):null,T=j?mo(j,b.bucket,-b.count):null,N="&app_tagged=1"+(a?`&tag=${encodeURIComponent(`app:${a}`)}`:"")+(o?`&tag=${encodeURIComponent(`context:${o}`)}`:"")+(d?`&principal=${encodeURIComponent(d)}`:"")+(h?`&model=${encodeURIComponent(h)}`:""),R=Ut(()=>He.get(`/stats/series?bucket=${b.bucket}`+(T?`&since=${T.toISOString()}`:"")+N),[e,a,o,d,h]),D=Ut(()=>He.get(`/stats/series?bucket=${b.bucket}`+(T?`&since=${T.toISOString()}`:"")+N+"&endpoint=embeddings"),[e,a,o,d,h]),I=Ut(()=>He.get("/stats/summary?app_tagged=1"+(j?`&since=${j.toISOString()}`:"")),[e]),O=((pt=R.data)==null?void 0:pt.series)??[],E=j?j.getTime():-1/0,C=O.filter(Q=>new Date(Q.start).getTime()>=E),z=O.filter(Q=>new Date(Q.start).getTime()0,q=S.useMemo(()=>{var Pe;const Q=new Map;for(const ne of((Pe=D.data)==null?void 0:Pe.series)??[])Q.set(ne.start,ne);return Q},[D.data]),P=Q=>Q.units.output_tokens??0,K=Q=>Q.units.cached_input_tokens??0,ue=Q=>{var Pe;return((Pe=q.get(Q.start))==null?void 0:Pe.units.input_tokens)??0},le=Q=>Math.max(0,(Q.units.input_tokens??0)-ue(Q)),W=Xa(C,Q=>Q.requests),B=Xa(C,le),F=Xa(C,P),ae=Xa(C,K),Z=B+F,A=Xa(C,ue),U=Q=>new Date(Q.start).getTime()===k.getTime(),V=Q=>hp(Q.start,b.bucket),M=Q=>mp(Q.start,b.bucket)+(U(Q)?" · in progress":""),se=C.map(Q=>({label:V(Q),title:M(Q),values:[Q.ok+Q.cancelled,Q.failed],rows:Q.cancelled?[{label:"cancelled",value:Ht(Q.cancelled)}]:void 0})),X=C.map(Q=>({label:V(Q),title:M(Q),values:[le(Q),K(Q),P(Q)]})),ce=C.map(Q=>({label:V(Q),title:M(Q),values:[ue(Q)]})),re=S.useMemo(()=>{var Q;return((Q=I.data)==null?void 0:Q.usage)??[]},[I.data]),be=S.useMemo(()=>[...new Set(re.map(Q=>ha(Q.tags,"app")).filter(Boolean))].sort(),[re]),fe=S.useMemo(()=>[...new Set(re.filter(Q=>!a||ha(Q.tags,"app")===a).map(Q=>ha(Q.tags,"context")).filter(Boolean))].sort(),[re,a]),we=S.useMemo(()=>[...new Set(re.map(Q=>Q.principal))].sort(),[re]),Ee=S.useMemo(()=>[...new Set(re.map(Q=>Q.model))].sort(),[re]),Se=S.useMemo(()=>re.filter(Q=>(!a||ha(Q.tags,"app")===a)&&(!o||ha(Q.tags,"context")===o)&&(!d||Q.principal===d)&&(!h||Q.model===h)),[re,a,o,d,h]),Ie=S.useMemo(()=>Zu(Se,Ob,Q=>({name:Q,...Qs()})).sort((Q,Pe)=>Pe.requests-Q.requests),[Se]),Be=Ie.reduce((Q,Pe)=>Q+Pe.requests,0),Mt=S.useMemo(()=>Ie.map(Q=>({label:Q.name,value:Q.requests})),[Ie]),Nt=S.useMemo(()=>Zu(Se,Q=>Q.principal,Q=>({name:Q,...Qs()})).sort((Q,Pe)=>Pe.requests-Q.requests),[Se]),Et=S.useMemo(()=>{const Q=(Pe,ne)=>({label:ne??Pe.name??"",value:Pe.requests,rows:[{label:"tokens",value:Re(tR(Pe))}]});return _c(Nt,Pe=>Q(Pe),Pe=>{const ne=Qs();for(const L of Pe){ne.requests+=L.requests;for(const[he,ke]of Object.entries(L.units))ne.units[he]=(ne.units[he]??0)+ke}return Q(ne,`Other (${Pe.length} users)`)})},[Nt]),Bt=S.useMemo(()=>Zu(Se,nR,Q=>({name:Q,...Qs()})).sort((Q,Pe)=>Pe.requests-Q.requests),[Se]),Rt=S.useMemo(()=>Bt.map(Q=>({label:Q.name,value:Q.requests})),[Bt]),Dt=S.useMemo(()=>Zu(Se,Q=>`${Ob(Q)} ${Q.model}`,Q=>{const Pe=Q.indexOf(" ");return{name:Q.slice(0,Pe),model:Q.slice(Pe+1),...Qs()}}).sort((Q,Pe)=>Q.name!==Pe.name?Q.name.localeCompare(Pe.name):Q.model.localeCompare(Pe.model)),[Se]),zt=R.loading&&!R.data||I.loading&&!I.data,ye=!zt&&(R.loading||I.loading||D.loading);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Sr,{value:e,onValueChange:r,children:[s.jsx(kr,{className:"w-44","aria-label":"Time range",children:s.jsx(jr,{})}),s.jsx(Cr,{children:cr.map(Q=>s.jsx(hr,{value:Q.key,children:Q.label},Q.key))})]}),s.jsx(Lt,{label:"App",value:a,onChange:Q=>{l(Q),c("")},options:be,allLabel:"All apps"}),a&&s.jsx(Lt,{label:"Context",value:o,onChange:c,options:fe,allLabel:"All contexts"}),s.jsx(Lt,{label:"User",value:d,onChange:f,options:we,allLabel:"All users"}),s.jsx(Lt,{label:"Model",value:h,onChange:m,options:Ee,allLabel:"All models"}),(a||o||d||h)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{l(""),c(""),f(""),m("")},children:[s.jsx(bo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>{R.reload(),I.reload(),D.reload()},children:s.jsx(pl,{})})]}),zt?s.jsx(kt,{}):R.error||I.error||D.error?s.jsx("p",{className:"text-sm text-destructive",children:R.error??I.error??D.error}):s.jsxs("div",{className:ye?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[s.jsx(Qn,{label:"Requests",value:Re(W),delta:Dh(W,Xa(z,Q=>Q.requests),Y)}),s.jsx(Qn,{label:"Tokens",value:Re(Z),secondary:`${Re(B)} in · ${Re(ae)} cached · ${Re(F)} out`,delta:Dh(Z,Xa(z,Q=>le(Q)+P(Q)),Y)}),s.jsx(Qn,{label:"Embedding",value:Re(A),secondary:"in",delta:Dh(A,Xa(z,ue),Y)})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Ke,{className:x?"min-w-0 lg:col-span-2":"min-w-0",children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Apps"}),s.jsx(it,{children:"Requests per app, from the app tag."})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":x?"Show chart":"Show all apps as a table",title:x?"Show chart":"Show all apps as a table",onClick:()=>v(Q=>!Q),children:x?s.jsx(h1,{}):s.jsx(cm,{})})]}),s.jsx(Qe,{children:x?s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"App"}),s.jsx(ge,{className:"text-right",children:"Share"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Spend"})]})}),s.jsxs(vn,{children:[Ie.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No usage in this range."})}),Ie.map((Q,Pe)=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:Q.name}),s.jsx(de,{className:"text-right tabular-nums",children:Be>0?`${(Q.requests/Be*100).toFixed(1)}%`:""}),s.jsx(de,{className:"text-right tabular-nums",children:Re(Q.requests)}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(Q.units.input_tokens),children:Q.units.input_tokens?Re(Q.units.input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(Q.units.cached_input_tokens),children:Q.units.cached_input_tokens?Re(Q.units.cached_input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(Q.units.output_tokens),children:Q.units.output_tokens?Re(Q.units.output_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:Q.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Ir(Q.cost)})]},Pe))]})]}):s.jsx(Ki,{rows:Mt,format:Re})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Users"}),s.jsx(it,{children:"Share of requests per user."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:Et.slices,overflow:Et.overflow,format:Re,emptyMessage:"No usage in this range."},`${e} ${a} ${o} ${d} ${h}`)})]}),a&&s.jsxs(Ke,{className:"lg:col-span-2",children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Contexts"}),s.jsxs(it,{children:["Requests per context in ",a,"."]})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:Rt,format:Re})})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Tokens"}),s.jsxs(it,{children:["Chat input, cached input and output per ",b.bucket,"."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:X,series:[{...ma,name:"input"},{...ep,name:"cached"},{...Vl,name:"output"}],format:Re})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Embedding"}),s.jsxs(it,{children:["Input tokens on embeddings per ",b.bucket,"."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:ce,series:[{...ma,name:"input"}],format:Re,emptyMessage:"No embeddings in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Requests"}),s.jsxs(it,{children:["Per ",b.bucket,", split by outcome."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:se,series:[{...ma,name:"ok"},{...Vl,name:"failed"}],format:Re,integer:!0})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:a?"By model":"By app and model"}),s.jsxs(it,{children:["Totals by ",a?"":"app and ","model."]})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[!a&&s.jsx(ge,{children:"App"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Spend"})]})}),s.jsxs(vn,{children:[Dt.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:a?6:7,className:"text-muted-foreground",children:"No usage in this range."})}),Dt.map((Q,Pe)=>s.jsxs(Oe,{children:[!a&&s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:Q.name}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:Q.model}),s.jsx(de,{className:"text-right tabular-nums",children:Re(Q.requests)}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(Q.units.input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(Q.units.cached_input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Vt(Q.units.output_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Q.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Ir(Q.cost)})]},Pe))]})]})})]})]})]})}const aR=o1("inline-flex items-center justify-center rounded-md border font-medium w-fit max-w-full whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",muted:"border-transparent bg-muted text-muted-foreground [a&]:hover:bg-muted/80",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent/10 [a&]:hover:text-accent-foreground",success:"border-transparent bg-[#1a7f37] text-white [a&]:hover:bg-[#1a7f37]/90",warning:"border-transparent bg-[#9a6700] text-white [a&]:hover:bg-[#9a6700]/90",info:"border-transparent bg-[#0969da] text-white [a&]:hover:bg-[#0969da]/90",tag:"border-border bg-card text-foreground [a&]:hover:bg-muted",value:"border-transparent bg-muted text-foreground font-mono [a&]:hover:bg-muted/80",whatsapp:"border-transparent bg-[#22c55e] text-white [a&]:hover:bg-[#22c55e]/90",email:"border-transparent bg-[#4b5563] text-white [a&]:hover:bg-[#4b5563]/90",telegram:"border-transparent bg-[#3b82f6] text-white [a&]:hover:bg-[#3b82f6]/90",zulip:"border-transparent bg-[#a855f7] text-white [a&]:hover:bg-[#a855f7]/90",platform:"border-transparent bg-[#f97316] text-white [a&]:hover:bg-[#f97316]/90"},size:{sm:"text-xs px-1.5 py-0",default:"text-xs px-2 py-0.5",lg:"text-sm px-3 py-1 [&>svg]:size-3.5"}},defaultVariants:{variant:"default",size:"default"}});function on({className:e,variant:r,size:a,asChild:l=!1,...o}){const c=l?xa:"span";return s.jsx(c,{"data-slot":"badge",className:Ne(aR({variant:r,size:a}),e),...o})}const lR=["<1s","1–5s","5–15s","15–30s","30–60s","60–120s","≥120s"],Oh=[{key:"upstream_error",name:"provider error",series:ma},{key:"unreachable",name:"unreachable",series:ep},{key:"cancelled",name:"cancelled",series:Vl}],iR="untagged";function pp(e){return e.outcome!=="ok"}function oS(e){return e.error_kind?e.error_kind:e.outcome==="upstream_error"&&e.status_code?`http ${e.status_code}`:e.outcome}function zh(e,r){const a=new Map;for(const l of e){const o=r(l);let c=a.get(o);c||(c={label:o,errors:0,total:0},a.set(o,c)),c.total+=l.requests,pp(l)&&(c.errors+=l.requests)}return[...a.values()].filter(l=>l.errors>0).sort((l,o)=>o.errors-l.errors)}function Lh(e){return e.map(r=>({label:r.label,value:r.errors,note:`${(r.errors/r.total*100).toFixed(1)}% of ${Re(r.total)} req`}))}function sR(e){const r=new Map;for(const a of e){if(!pp(a))continue;const l=oS(a),o=`${a.provider}\0${a.model}\0${l}\0${a.status_code??""}`;let c=r.get(o);c||(c={provider:a.provider,model:a.model,outcome:a.outcome,label:l,statusCode:a.status_code,requests:0,weightedMs:0,lastSeen:""},r.set(o,c)),c.requests+=a.requests,c.weightedMs+=a.avg_ms*a.requests,a.last_seen>c.lastSeen&&(c.lastSeen=a.last_seen)}return[...r.values()].sort((a,l)=>l.requests-a.requests)}function oR(e){const r=new URLSearchParams;return e.provider&&r.set("provider",e.provider),e.model&&r.set("model",e.model),r.set("outcome",e.outcome),"/requests?"+r.toString()}function uR(){var U,V,M,se;const[e,r]=Gt("range","7d"),[a,l]=Gt("user"),[o,c]=Gt("provider"),[d,f]=Gt("model"),[h,m]=Gt("app"),x=cr.find(X=>X.key===e)??cr[1],v=Hc(new Date,x.bucket),b=x.count?mo(v,x.bucket,-(x.count-1)):null,y=b?`&since=${b.toISOString()}`:"",k=(a?`&principal=${encodeURIComponent(a)}`:"")+(o?`&provider=${encodeURIComponent(o)}`:"")+(d?`&model=${encodeURIComponent(d)}`:"")+(h?`&tag=${encodeURIComponent(`app:${h}`)}`:""),j=Ut(()=>He.get(`/stats/errors?bucket=${x.bucket}`+y+k),[e,a,o,d,h]),T=Ut(()=>He.get("/stats/requests/facets"+(y?"?"+y.slice(1):"")),[e]),N=((U=j.data)==null?void 0:U.series)??[],R=S.useMemo(()=>{var X;return((X=j.data)==null?void 0:X.breakdown)??[]},[j.data]),D=N.reduce((X,ce)=>X+ce.requests,0),I=N.reduce((X,ce)=>X+ce.upstream_error+ce.unreachable,0),O=N.reduce((X,ce)=>X+ce.cancelled,0),E=X=>D>0?`${(X/D*100).toFixed(1)}% of requests`:void 0,C=S.useMemo(()=>R.filter(pp),[R]),z=C.reduce((X,ce)=>X+ce.requests,0),Y=z>0?C.reduce((X,ce)=>X+ce.avg_ms*ce.requests,0)/z:null,q=X=>new Date(X).getTime()===v.getTime(),P=N.map(X=>({label:hp(X.start,x.bucket),title:mp(X.start,x.bucket)+(q(X.start)?" · in progress":""),values:[X.upstream_error,X.unreachable,X.cancelled],rows:[{label:"requests total",value:Ht(X.requests)}]})),K=lR.map((X,ce)=>{const re=be=>C.filter(fe=>fe.outcome===be).reduce((fe,we)=>fe+(we.bands[ce]??0),0);return{label:X,title:`Time to failure ${X}`,values:Oh.map(be=>re(be.key))}}),ue=S.useMemo(()=>Lh(zh(R,X=>X.provider||"(none)")),[R]),le=S.useMemo(()=>Lh(zh(R,X=>ha(X.tags,"app")||iR)),[R]),W=S.useMemo(()=>Lh(zh(R,X=>X.model||"(none)")),[R]),B=S.useMemo(()=>{const X=new Map;for(const re of C){const be=oS(re);X.set(be,(X.get(be)??0)+re.requests)}const ce=[...X.entries()].sort((re,be)=>be[1]-re[1]);return _c(ce,([re,be])=>({label:re,value:be}),re=>({label:`Other (${re.length} kinds)`,value:re.reduce((be,[,fe])=>be+fe,0)}))},[C]),F=S.useMemo(()=>sR(R).slice(0,50),[R]),ae=S.useMemo(()=>{var X;return[...new Set((((X=T.data)==null?void 0:X.tags)??[]).filter(ce=>ce.startsWith("app:")).map(ce=>ce.slice(4)))].sort()},[T.data]),Z=j.loading&&!j.data,A=!Z&&j.loading;return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Sr,{value:e,onValueChange:r,children:[s.jsx(kr,{className:"w-44","aria-label":"Time range",children:s.jsx(jr,{})}),s.jsx(Cr,{children:cr.map(X=>s.jsx(hr,{value:X.key,children:X.label},X.key))})]}),s.jsx(Lt,{label:"User",value:a,onChange:l,options:((V=T.data)==null?void 0:V.principals)??[],allLabel:"All users"}),s.jsx(Lt,{label:"Provider",value:o,onChange:c,options:((M=T.data)==null?void 0:M.providers)??[],allLabel:"All providers"}),s.jsx(Lt,{label:"Model",value:d,onChange:f,options:((se=T.data)==null?void 0:se.models)??[],allLabel:"All models"}),s.jsx(Lt,{label:"App",value:h,onChange:m,options:ae,allLabel:"All apps"}),(a||o||d||h)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{l(""),c(""),f(""),m("")},children:[s.jsx(bo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>j.reload(),children:s.jsx(pl,{})})]}),Z?s.jsx(kt,{}):j.error?s.jsx("p",{className:"text-sm text-destructive",children:j.error}):s.jsxs("div",{className:A?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Qn,{label:"Requests",value:Re(D)}),s.jsx(Qn,{label:"Failed",value:Re(I),hint:E(I)}),s.jsx(Qn,{label:"Cancelled",value:Re(O),hint:E(O)}),s.jsx(Qn,{label:"Avg time to failure",value:Y===null?"—":co(Math.round(Y))})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures over time"}),s.jsxs(it,{children:["Per ",x.bucket,", split by class."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:P,series:Oh.map(X=>({...X.series,name:X.name})),format:Re,integer:!0,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Time to failure"}),s.jsx(it,{children:"How long requests ran before failing. A pile-up near a round number is a timeout."})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:K,series:Oh.map(X=>({...X.series,name:X.name})),format:Re,integer:!0,emptyMessage:"No failures in this range."})})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures by provider"}),s.jsx(it,{children:"Each bar with the provider's own failure rate."})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:ue,format:Re,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures by app"}),s.jsx(it,{children:"From the app tag; untagged traffic grouped."})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:le,format:Re,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures by model"}),s.jsx(it,{children:"Each bar with the model's own failure rate."})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:W,format:Re,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failure kinds"}),s.jsx(it,{children:"Provider error codes and transport classes."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:B.slices,overflow:B.overflow,format:Re,emptyMessage:"No failures in this range."},`${e} ${a} ${o} ${d} ${h}`)})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Error signatures"}),s.jsx(it,{children:"Each distinct failure, newest last seen. Open one in the request explorer."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Error"}),s.jsx(ge,{children:"Provider"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Avg time"}),s.jsx(ge,{className:"text-right",children:"Last seen"}),s.jsx(ge,{})]})}),s.jsxs(vn,{children:[F.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No failures in this range."})}),F.map((X,ce)=>s.jsxs(Oe,{children:[s.jsx(de,{children:s.jsxs(on,{variant:X.outcome==="cancelled"?"warning":"destructive",children:[X.label,X.outcome!=="cancelled"&&X.statusCode&&X.label!==`http ${X.statusCode}`?` · ${X.statusCode}`:""]})}),s.jsx(de,{className:"font-mono text-xs",children:X.provider||"—"}),s.jsx(de,{className:"font-mono text-xs",children:X.model||"—"}),s.jsx(de,{className:"text-right tabular-nums",children:Ht(X.requests)}),s.jsx(de,{className:"text-right tabular-nums",children:co(Math.round(X.weightedMs/X.requests))}),s.jsx(de,{className:"whitespace-nowrap text-right text-xs",children:$0(X.lastSeen)}),s.jsx(de,{className:"text-right",children:s.jsxs("a",{href:oR(X),className:"inline-flex items-center gap-1 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:["explore",s.jsx(rE,{className:"size-3"})]})})]},ce))]})]})})]})]})]})}const cR=[{...ma,name:"p50"},{...Vl,name:"p95"}],dR=[{...ma,name:"average"},{...Vl,name:"peak"}],$i=e=>co(Math.round(e)),Uh=e=>`${Ht(Math.round(e))} tok/s`,zb=e=>Number.isInteger(e)?Re(e):e<.01?"<0.01":e<10?e.toFixed(2):Re(Math.round(e)),Sm=(e,r)=>e===null?"—":r(e);function Bh({label:e,figure:r,format:a}){return s.jsx(Qn,{label:`${e}, median`,value:Sm(r.p50,a),secondary:r.p95===null?void 0:`p95 ${a(r.p95)}`,hint:r.mean===null?void 0:`mean ${a(r.mean)}`})}function fR(){var P,K,ue,le,W,B;const[e,r]=Gt("range","7d"),[a,l]=Gt("user"),[o,c]=Gt("provider"),[d,f]=Gt("model"),[h,m]=Gt("app"),x=cr.find(F=>F.key===e)??cr[1],v=Hc(new Date,x.bucket),b=x.count?mo(v,x.bucket,-(x.count-1)):null,y=b?`&since=${b.toISOString()}`:"",k=(a?`&principal=${encodeURIComponent(a)}`:"")+(o?`&provider=${encodeURIComponent(o)}`:"")+(d?`&model=${encodeURIComponent(d)}`:"")+(h?`&tag=${encodeURIComponent(`app:${h}`)}`:""),j=Ut(()=>He.get(`/stats/performance?bucket=${x.bucket}`+y+k),[e,a,o,d,h]),T=Ut(()=>He.get("/stats/requests/facets"+(y?"?"+y.slice(1):"")),[e]),N=S.useMemo(()=>{var F;return[...new Set((((F=T.data)==null?void 0:F.tags)??[]).filter(ae=>ae.startsWith("app:")).map(ae=>ae.slice(4)))].sort()},[T.data]),R=(P=j.data)==null?void 0:P.summary,D=((K=j.data)==null?void 0:K.series)??[],I=((ue=j.data)==null?void 0:ue.models)??[],O=F=>new Date(F).getTime()===v.getTime(),E=F=>D.map(ae=>({label:hp(ae.start,x.bucket),title:mp(ae.start,x.bucket)+(O(ae.start)?" · in progress":""),values:F(ae),rows:[{label:"requests",value:Ht(ae.requests)}]})),C=[{title:"Duration",description:"Time from request to last byte.",points:E(F=>[F.duration_ms.p50,F.duration_ms.p95]),format:$i},{title:"Time to first token",description:"Time from request to the first content event.",points:E(F=>[F.ttft_ms.p50,F.ttft_ms.p95]),format:$i},{title:"Output speed",description:"Output tokens per second after the first token.",points:E(F=>[F.tokens_per_second.p50,F.tokens_per_second.p95]),format:Uh}],z=E(F=>[F.concurrency.average,F.concurrency.peak]),Y=j.loading&&!j.data,q=!Y&&j.loading;return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Sr,{value:e,onValueChange:r,children:[s.jsx(kr,{className:"w-44","aria-label":"Time range",children:s.jsx(jr,{})}),s.jsx(Cr,{children:cr.map(F=>s.jsx(hr,{value:F.key,children:F.label},F.key))})]}),s.jsx(Lt,{label:"User",value:a,onChange:l,options:((le=T.data)==null?void 0:le.principals)??[],allLabel:"All users"}),s.jsx(Lt,{label:"Provider",value:o,onChange:c,options:((W=T.data)==null?void 0:W.providers)??[],allLabel:"All providers"}),s.jsx(Lt,{label:"Model",value:d,onChange:f,options:((B=T.data)==null?void 0:B.models)??[],allLabel:"All models"}),s.jsx(Lt,{label:"App",value:h,onChange:m,options:N,allLabel:"All apps"}),(a||o||d||h)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{l(""),c(""),f(""),m("")},children:[s.jsx(bo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>j.reload(),children:s.jsx(pl,{})})]}),Y?s.jsx(kt,{}):j.error?s.jsx("p",{className:"text-sm text-destructive",children:j.error}):R?s.jsxs("div",{className:q?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Bh,{label:"Duration",figure:R.duration_ms,format:$i}),s.jsx(Bh,{label:"Time to first token",figure:R.ttft_ms,format:$i}),s.jsx(Bh,{label:"Output speed",figure:R.tokens_per_second,format:Uh}),s.jsx(Qn,{label:"Concurrent requests, average",value:zb(R.concurrency.average),secondary:`peak ${Ht(R.concurrency.peak)}`,hint:`${Ht(R.requests)} requests`})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[C.map(F=>s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:F.title}),s.jsx(it,{children:F.description})]}),s.jsx(Qe,{children:s.jsx(bb,{points:F.points,series:cR,format:F.format})})]},F.title)),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Concurrent requests"}),s.jsx(it,{children:"Requests in flight at the same time."})]}),s.jsx(Qe,{children:s.jsx(bb,{points:z,series:dR,format:zb})})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"By model"}),s.jsx(it,{children:"Median and p95 for each model."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Provider"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Duration"}),s.jsx(ge,{className:"text-right",children:"First token"}),s.jsx(ge,{className:"text-right",children:"Output speed"})]})}),s.jsxs(vn,{children:[I.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:"No requests in this range."})}),I.map(F=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs",children:F.provider||"—"}),s.jsx(de,{className:"font-mono text-xs",children:F.model||"—"}),s.jsx(de,{className:"text-right tabular-nums",children:Ht(F.requests)}),s.jsx(Ih,{figure:F.duration_ms,format:$i}),s.jsx(Ih,{figure:F.ttft_ms,format:$i}),s.jsx(Ih,{figure:F.tokens_per_second,format:Uh})]},`${F.provider} ${F.model}`))]})]})})]})]}):null]})}function Ih({figure:e,format:r}){return s.jsxs(de,{className:"whitespace-nowrap text-right tabular-nums",children:[Sm(e.p50,r),s.jsxs("span",{className:"text-muted-foreground",children:[" / ",Sm(e.p95,r)]})]})}const jm=[{value:"failover",label:"Failover",hint:"Use the first target. Try the next one if it fails."},{value:"round_robin",label:"Round robin",hint:"Send each request to the next target in turn."},{value:"weighted",label:"Weighted",hint:"A higher weight gets more requests."},{value:"least_busy",label:"Least busy",hint:"Send each request to the target with the fewest open requests."}];function uS(e){var r;return((r=jm.find(a=>a.value===e))==null?void 0:r.label)??e??""}function cS(e,r){const a=r.reduce((l,o)=>l+Math.max(o,1),0);return`${Math.round(Math.max(e,1)/a*100)}%`}var gp="Checkbox",[hR]=Nr(gp),[mR,pR]=hR(gp),dS=S.forwardRef((e,r)=>{const{__scopeCheckbox:a,name:l,checked:o,defaultChecked:c,required:d,disabled:f,value:h="on",onCheckedChange:m,form:x,...v}=e,[b,y]=S.useState(null),k=ft(r,I=>y(I)),j=S.useRef(!1),T=b?x||!!b.closest("form"):!0,[N=!1,R]=nl({prop:o,defaultProp:c,onChange:m}),D=S.useRef(N);return S.useEffect(()=>{const I=b==null?void 0:b.form;if(I){const O=()=>R(D.current);return I.addEventListener("reset",O),()=>I.removeEventListener("reset",O)}},[b,R]),s.jsxs(mR,{scope:a,state:N,disabled:f,children:[s.jsx(Ge.button,{type:"button",role:"checkbox","aria-checked":el(N)?"mixed":N,"aria-required":d,"data-state":mS(N),"data-disabled":f?"":void 0,disabled:f,value:h,...v,ref:k,onKeyDown:Ae(e.onKeyDown,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:Ae(e.onClick,I=>{R(O=>el(O)?!0:!O),T&&(j.current=I.isPropagationStopped(),j.current||I.stopPropagation())})}),T&&s.jsx(gR,{control:b,bubbles:!j.current,name:l,value:h,checked:N,required:d,disabled:f,form:x,style:{transform:"translateX(-100%)"},defaultChecked:el(c)?!1:c})]})});dS.displayName=gp;var fS="CheckboxIndicator",hS=S.forwardRef((e,r)=>{const{__scopeCheckbox:a,forceMount:l,...o}=e,c=pR(fS,a);return s.jsx(Vr,{present:l||el(c.state)||c.state===!0,children:s.jsx(Ge.span,{"data-state":mS(c.state),"data-disabled":c.disabled?"":void 0,...o,ref:r,style:{pointerEvents:"none",...e.style}})})});hS.displayName=fS;var gR=e=>{const{control:r,checked:a,bubbles:l=!0,defaultChecked:o,...c}=e,d=S.useRef(null),f=dp(a),h=op(r);S.useEffect(()=>{const x=d.current,v=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(v,"checked").set;if(f!==a&&y){const k=new Event("click",{bubbles:l});x.indeterminate=el(a),y.call(x,el(a)?!1:a),x.dispatchEvent(k)}},[f,a,l]);const m=S.useRef(el(a)?!1:a);return s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??m.current,...c,tabIndex:-1,ref:d,style:{...e.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function el(e){return e==="indeterminate"}function mS(e){return el(e)?"indeterminate":e?"checked":"unchecked"}var xR=dS,vR=hS;function xp({className:e,...r}){return s.jsx(xR,{"data-slot":"checkbox",className:Ne("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:s.jsx(vR,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:s.jsx(jc,{className:"size-3.5"})})})}function Ju({label:e,sortKey:r,active:a,onSort:l,numeric:o}){return s.jsx(ge,{className:o?"text-right":void 0,children:s.jsxs("button",{type:"button",onClick:()=>l(r),"aria-label":`Sort by ${e.toLowerCase()}`,className:Ne("cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring",a?"font-medium text-foreground":"hover:text-foreground"),children:[e,a&&s.jsxs("span",{"aria-hidden":!0,children:[" ",r==="name"?"↑":"↓"]})]})})}function yR(){var j;const[e,r]=Gt("range","30d"),[a,l]=S.useState("name"),[o,c]=S.useState(!1),d=cr.find(T=>T.key===e)??cr[2],f=Hc(new Date,d.bucket),h=d.count?mo(f,d.bucket,-(d.count-1)):null,m=Ut(()=>He.get("/v1/models?include_hidden=1"),[]),x=Ut(()=>He.get("/stats/summary"+(h?`?since=${h.toISOString()}`:"")),[e]),v=S.useMemo(()=>{var D,I;const T=new Map;for(const O of((D=x.data)==null?void 0:D.usage)??[]){let E=T.get(O.model);E||(E={requests:0,tokens:0,cost:null},T.set(O.model,E)),E.requests+=O.requests,E.tokens+=(O.units.input_tokens??0)+(O.units.output_tokens??0),O.cost!==null&&(E.cost=(E.cost??0)+O.cost)}const N=(((I=m.data)==null?void 0:I.data)??[]).filter(O=>o||!O.hidden).map(O=>{var E,C,z;return{model:O,requests:((E=T.get(O.id))==null?void 0:E.requests)??0,tokens:((C=T.get(O.id))==null?void 0:C.tokens)??0,cost:((z=T.get(O.id))==null?void 0:z.cost)??null}}),R=(O,E)=>O.model.id.localeCompare(E.model.id);return N.sort((O,E)=>a==="name"?R(O,E):a==="cost"?(E.cost??-1)-(O.cost??-1)||R(O,E):E[a]-O[a]||R(O,E))},[m.data,x.data,a,o]),b=(((j=m.data)==null?void 0:j.data)??[]).filter(T=>T.hidden).length,y=m.loading&&!m.data,k=!y&&(m.loading||x.loading);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Sr,{value:e,onValueChange:r,children:[s.jsx(kr,{className:"w-44","aria-label":"Time range",children:s.jsx(jr,{})}),s.jsx(Cr,{children:cr.map(T=>s.jsx(hr,{value:T.key,children:T.label},T.key))})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>{m.reload(),x.reload()},children:s.jsx(pl,{})}),b>0&&s.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(xp,{checked:o,onCheckedChange:T=>c(T===!0)}),"Show hidden"]})]}),y?s.jsx(kt,{}):m.error||x.error?s.jsx("p",{className:"text-sm text-destructive",children:m.error??x.error}):s.jsxs(Ke,{className:k?"opacity-60":void 0,children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Models"}),s.jsx(it,{children:"Every model you can call, and how much it is used."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(Ju,{label:"Model",sortKey:"name",active:a==="name",onSort:l}),s.jsx(ge,{children:"Capabilities"}),s.jsx(Ju,{label:"Requests",sortKey:"requests",active:a==="requests",onSort:l,numeric:!0}),s.jsx(Ju,{label:"Tokens",sortKey:"tokens",active:a==="tokens",onSort:l,numeric:!0}),s.jsx(Ju,{label:"Spend",sortKey:"cost",active:a==="cost",onSort:l,numeric:!0})]})}),s.jsxs(vn,{children:[v.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No models available yet."})}),v.map(T=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-medium wrap-anywhere",children:s.jsxs("span",{className:"flex flex-col",children:[s.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[T.model.id,T.model.hidden&&s.jsx(on,{variant:"muted",children:"hidden"})]}),T.model.alias_of&&s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["→ ",T.model.alias_of]}),T.model.targets&&s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["→ ",T.model.targets.join(", ")," ",s.jsxs("span",{className:"font-sans",children:["· ",uS(T.model.strategy)]})]})]})}),s.jsx(de,{children:s.jsx("div",{className:"flex flex-wrap gap-1",children:T.model.capabilities.map(N=>s.jsx(on,{variant:"muted",children:N},N))})}),s.jsx(de,{className:"text-right tabular-nums",children:T.requests?Re(T.requests):""}),s.jsx(de,{className:"text-right tabular-nums",title:Vt(T.tokens),children:T.tokens?Re(T.tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:T.requests?T.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Ir(T.cost):""})]},T.model.id))]})]})})]})]})}function bR(e){const r=Date.now()-new Date(e).getTime();if(r<6e4)return"just now";const a=Math.floor(r/6e4);if(a<60)return`${a}m ago`;const l=Math.floor(a/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Lb(e,r){return e===void 0||r===void 0||r===0?null:`${Math.round(e/r*100)}%`}function Ub({label:e,remaining:r,limit:a}){if(r===void 0&&a===void 0)return null;const l=a&&a>0?(r??0)/a:null,o=l===null?"bg-muted-foreground":l>.5?"bg-green-500":l>.2?"bg-yellow-500":"bg-red-500";return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:e}),s.jsxs("span",{className:"tabular-nums",children:[r!==void 0?Ht(r):"?",a!==void 0?` / ${Ht(a)}`:"",Lb(r,a)&&s.jsxs("span",{className:"ml-1 text-muted-foreground",children:["(",Lb(r,a),")"]})]})]}),l!==null&&s.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:Ne("h-full rounded-full transition-all",o),style:{width:`${Math.max(l*100,1)}%`}})})]})}function wR({snap:e}){const r=e.limit_requests!==void 0||e.remaining_requests!==void 0,a=e.limit_tokens!==void 0||e.remaining_tokens!==void 0;return s.jsxs(Ke,{children:[s.jsx(Ze,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Je,{className:"text-base font-medium",children:e.provider}),s.jsxs("span",{className:Ne("text-xs tabular-nums",e.stale?"text-yellow-600 dark:text-yellow-400":"text-muted-foreground"),title:new Date(e.observed_at).toLocaleString(),children:[bR(e.observed_at),e.stale&&" (stale)"]})]})}),s.jsxs(Qe,{className:"flex flex-col gap-3",children:[r&&s.jsx(Ub,{label:"Requests",remaining:e.remaining_requests,limit:e.limit_requests}),a&&s.jsx(Ub,{label:"Tokens",remaining:e.remaining_tokens,limit:e.limit_tokens}),!r&&!a&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"No rate-limit data yet."})]})]})}function SR(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/stats/rate-limits"),[]);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"font-serif text-lg font-semibold",children:"Provider rate limits"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Upstream quota reported by each configured provider."})]}),s.jsxs(Me,{variant:"outline",size:"sm",onClick:l,disabled:r,children:[r?s.jsx(kt,{}):s.jsx(pl,{className:"size-4"}),"Refresh"]})]}),r&&!e?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(kt,{className:"size-6"})}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):(e==null?void 0:e.rate_limits.length)===0?s.jsx(Ke,{children:s.jsx(Qe,{className:"py-8 text-center text-sm text-muted-foreground",children:"No provider reports rate limits yet."})}):s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:e==null?void 0:e.rate_limits.map(o=>s.jsx(wR,{snap:o},o.provider_id))})]})}const jR=[{key:"overview",label:"Overview"},{key:"apps",label:"Apps"},{key:"models",label:"Models"},{key:"providers",label:"Providers"},{key:"errors",label:"Errors"},{key:"performance",label:"Performance"}];function kR({value:e,onChange:r}){return s.jsx("nav",{className:"-mt-2 flex items-center gap-4 border-b text-sm",children:jR.map(a=>s.jsx("button",{type:"button","aria-current":e===a.key?"page":void 0,onClick:()=>r(a.key),className:Ne("cursor-pointer border-b-2 px-0.5 pb-2 outline-none focus-visible:ring-2 focus-visible:ring-ring",e===a.key?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:a.label},a.key))})}function CR({ssoEnabled:e,sub:r,onSubChange:a}){return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(kR,{value:r,onChange:a}),r==="apps"?s.jsx(rR,{}):r==="models"?s.jsx(yR,{}):r==="providers"?s.jsx(SR,{}):r==="errors"?s.jsx(uR,{}):r==="performance"?s.jsx(fR,{}):s.jsx(WM,{ssoEnabled:e})]})}var vp="Switch",[NR]=Nr(vp),[ER,TR]=NR(vp),pS=S.forwardRef((e,r)=>{const{__scopeSwitch:a,name:l,checked:o,defaultChecked:c,required:d,disabled:f,value:h="on",onCheckedChange:m,form:x,...v}=e,[b,y]=S.useState(null),k=ft(r,D=>y(D)),j=S.useRef(!1),T=b?x||!!b.closest("form"):!0,[N=!1,R]=nl({prop:o,defaultProp:c,onChange:m});return s.jsxs(ER,{scope:a,checked:N,disabled:f,children:[s.jsx(Ge.button,{type:"button",role:"switch","aria-checked":N,"aria-required":d,"data-state":vS(N),"data-disabled":f?"":void 0,disabled:f,value:h,...v,ref:k,onClick:Ae(e.onClick,D=>{R(I=>!I),T&&(j.current=D.isPropagationStopped(),j.current||D.stopPropagation())})}),T&&s.jsx(AR,{control:b,bubbles:!j.current,name:l,value:h,checked:N,required:d,disabled:f,form:x,style:{transform:"translateX(-100%)"}})]})});pS.displayName=vp;var gS="SwitchThumb",xS=S.forwardRef((e,r)=>{const{__scopeSwitch:a,...l}=e,o=TR(gS,a);return s.jsx(Ge.span,{"data-state":vS(o.checked),"data-disabled":o.disabled?"":void 0,...l,ref:r})});xS.displayName=gS;var AR=e=>{const{control:r,checked:a,bubbles:l=!0,...o}=e,c=S.useRef(null),d=dp(a),f=op(r);return S.useEffect(()=>{const h=c.current,m=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(m,"checked").set;if(d!==a&&v){const b=new Event("click",{bubbles:l});v.call(h,a),h.dispatchEvent(b)}},[d,a,l]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a,...o,tabIndex:-1,ref:c,style:{...e.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function vS(e){return e?"checked":"unchecked"}var _R=pS,MR=xS;function Bb({className:e,...r}){return s.jsx(_R,{"data-slot":"switch",className:Ne("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-[#7F7F79] focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:s.jsx(MR,{"data-slot":"switch-thumb",className:"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"})})}function Fi(e){return e instanceof Error?e.message:String(e)}const RR={limit_requests:"x-ratelimit-limit-requests",remaining_requests:"x-ratelimit-remaining-requests",limit_tokens:"x-ratelimit-limit-tokens",remaining_tokens:"x-ratelimit-remaining-tokens"};function DR(e){return{name:e.name,base_url:e.base_url,api_key:"",remove_credential:!1,verify_tls:e.verify_tls,timeout_connect:String(e.timeout_connect),timeout_read:String(e.timeout_read),max_concurrency:e.max_concurrency===null?"":String(e.max_concurrency),rate_limit_headers:e.rate_limit_headers?{...e.rate_limit_headers}:{}}}function OR(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/admin/v1/providers")),[o,c]=S.useState({name:"",base_url:"",api_key:""}),[d,f]=S.useState(!1),[h,m]=S.useState(null),[x,v]=S.useState(!1),[b,y]=S.useState(null),[k,j]=S.useState(null),T=async E=>{E.preventDefault(),f(!0);try{await He.post("/admin/v1/providers",{name:o.name.trim(),wire_format:"openai",base_url:o.base_url.trim(),...o.api_key!==""?{api_key:o.api_key}:{}}),Ve.success(`Provider "${o.name.trim()}" registered`),c({name:"",base_url:"",api_key:""}),l()}catch(C){Ve.error(Fi(C))}finally{f(!1)}},N=async()=>{if(!h)return;const E=Number(h.timeout_connect),C=Number(h.timeout_read);if(!(E>0)||!(C>0)){Ve.error("Timeouts must be positive seconds");return}const z=h.max_concurrency.trim()===""?0:Number(h.max_concurrency);if(!Number.isInteger(z)||z<0){Ve.error("Max concurrency must be a whole number, or empty for unlimited");return}v(!0);try{const Y=Object.keys(h.rate_limit_headers).length>0?h.rate_limit_headers:{};await He.patch(`/admin/v1/providers/${encodeURIComponent(h.name)}`,{base_url:h.base_url.trim(),verify_tls:h.verify_tls,timeout_connect:E,timeout_read:C,max_concurrency:z,rate_limit_headers:Y,...h.api_key!==""?{api_key:h.api_key}:{},...h.remove_credential?{remove_credential:!0}:{}}),Ve.success(`Provider "${h.name}" updated`),m(null),l()}catch(Y){Ve.error(Fi(Y))}finally{v(!1)}},R=async E=>{try{await He.patch(`/admin/v1/providers/${encodeURIComponent(E.name)}`,{enabled:!E.enabled}),l()}catch(C){Ve.error(Fi(C))}},D=async E=>{try{await He.del(`/admin/v1/providers/${encodeURIComponent(E)}`),Ve.success(`Provider "${E}" deleted`),(k==null?void 0:k.provider)===E&&j(null),l()}catch(C){Ve.error(Fi(C))}},I=async E=>{y(E);try{const C=await He.get(`/admin/v1/providers/${encodeURIComponent(E)}/discover`);j({provider:E,models:C.models})}catch(C){Ve.error(Fi(C))}finally{y(null)}},O=async(E,C)=>{try{await He.post("/admin/v1/models",{alias:C,provider:E,upstream_name:C,capabilities:["chat","chat_stream"]}),Ve.success(`Bound "${C}" (chat capabilities; adjust in Models)`),I(E)}catch(z){Ve.error(Fi(z))}};return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Register a provider"}),s.jsxs(it,{children:["An upstream OpenAI-compatible endpoint (vLLM, SGLang, OpenAI, ...). The base URL includes ",s.jsx("code",{className:"font-mono",children:"/v1"}),"."]})]}),s.jsx(Qe,{children:s.jsxs("form",{onSubmit:T,className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"p-name",children:"Name"}),s.jsx(Ft,{id:"p-name",placeholder:"vllm-1",value:o.name,onChange:E=>c({...o,name:E.target.value}),required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"p-url",children:"Base URL"}),s.jsx(Ft,{id:"p-url",placeholder:"http://10.0.0.5:8000/v1",value:o.base_url,onChange:E=>c({...o,base_url:E.target.value}),required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"p-key",children:"Upstream API key (optional)"}),s.jsx(Ft,{id:"p-key",type:"password",autoComplete:"off",value:o.api_key,onChange:E=>c({...o,api_key:E.target.value})})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Register"]})})]})})]}),s.jsxs(Ke,{children:[s.jsx(Ze,{children:s.jsx(Je,{className:"font-serif",children:"Providers"})}),s.jsx(Qe,{children:r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Name"}),s.jsx(ge,{children:"Base URL"}),s.jsx(ge,{children:"Credential"}),s.jsx(ge,{title:"Read timeout · max concurrency",children:"Limits"}),s.jsx(ge,{children:"Enabled"}),s.jsx(ge,{className:"w-56"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.providers.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:"No providers registered yet."})}),e==null?void 0:e.providers.map(E=>(h==null?void 0:h.name)===E.name?s.jsxs(Oe,{className:"bg-muted/30 hover:bg-muted/30",children:[s.jsx(de,{className:"align-top font-medium",children:E.name}),s.jsx(de,{colSpan:5,children:s.jsxs("div",{className:"flex flex-col gap-4 py-1",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"e-url",children:"Base URL"}),s.jsx(Ft,{id:"e-url",value:h.base_url,onChange:C=>m({...h,base_url:C.target.value})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"e-key",children:"Upstream API key"}),s.jsx(Ft,{id:"e-key",type:"password",autoComplete:"off",placeholder:E.has_credential?"unchanged":"none",value:h.api_key,disabled:h.remove_credential,onChange:C=>m({...h,api_key:C.target.value})}),E.has_credential&&s.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(xp,{checked:h.remove_credential,onCheckedChange:C=>m({...h,remove_credential:C===!0})}),"Remove the stored key"]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"e-conc",children:"Max concurrency"}),s.jsx(Ft,{id:"e-conc",inputMode:"numeric",placeholder:"unlimited",value:h.max_concurrency,onChange:C=>m({...h,max_concurrency:C.target.value})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"e-connect",children:"Connect timeout (s)"}),s.jsx(Ft,{id:"e-connect",inputMode:"decimal",value:h.timeout_connect,onChange:C=>m({...h,timeout_connect:C.target.value})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"e-read",children:"Read timeout (s)"}),s.jsx(Ft,{id:"e-read",inputMode:"decimal",value:h.timeout_read,onChange:C=>m({...h,timeout_read:C.target.value})}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Caps the wait for a response; whole request on non-streaming calls."})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"e-tls",children:"Verify TLS"}),s.jsx(Bb,{id:"e-tls",checked:h.verify_tls,onCheckedChange:C=>m({...h,verify_tls:C})})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(rn,{children:"Rate limit headers"}),Object.keys(h.rate_limit_headers).length===0&&s.jsx(Me,{variant:"outline",size:"sm",type:"button",onClick:()=>m({...h,rate_limit_headers:{...RR}}),children:"Use standard headers"}),Object.keys(h.rate_limit_headers).length>0&&s.jsx(Me,{variant:"outline",size:"sm",type:"button",onClick:()=>m({...h,rate_limit_headers:{}}),children:"Clear"})]}),Object.keys(h.rate_limit_headers).length>0&&s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:Object.entries(h.rate_limit_headers).map(([C,z])=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:C}),s.jsx(Ft,{value:z,onChange:Y=>m({...h,rate_limit_headers:{...h.rate_limit_headers,[C]:Y.target.value}})})]},C))}),Object.keys(h.rate_limit_headers).length===0&&s.jsx("p",{className:"text-xs text-muted-foreground",children:'Not configured. Click "Use standard headers" to track upstream rate limits.'})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",disabled:x,onClick:N,children:[x&&s.jsx(kt,{}),"Save"]}),s.jsx(Me,{variant:"outline",size:"sm",onClick:()=>m(null),children:"Cancel"})]})]})})]},E.name):s.jsxs(Oe,{children:[s.jsx(de,{className:"font-medium wrap-anywhere",children:E.name}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:E.base_url}),s.jsx(de,{children:E.has_credential?s.jsx(on,{variant:"secondary",children:"set"}):s.jsx(on,{variant:"muted",children:"none"})}),s.jsxs(de,{className:"whitespace-nowrap text-xs text-muted-foreground",title:"Read timeout · max concurrency",children:[E.timeout_read,"s ·"," ",E.max_concurrency===null?"unlimited":E.max_concurrency]}),s.jsx(de,{children:s.jsx(Bb,{checked:E.enabled,onCheckedChange:()=>R(E),"aria-label":`Enable ${E.name}`})}),s.jsxs(de,{className:"flex items-center justify-end gap-1 whitespace-nowrap",children:[s.jsxs(Me,{variant:"outline",size:"sm",disabled:b===E.name,onClick:()=>I(E.name),children:[b===E.name?s.jsx(kt,{}):s.jsx(pl,{}),"Discover models"]}),s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Edit ${E.name}`,onClick:()=>m(DR(E)),children:s.jsx(p1,{})}),s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Delete ${E.name}`,children:s.jsx(Ym,{})})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:['Delete provider "',E.name,'"?']}),s.jsx(ul,{children:"All model bindings on this provider are deleted with it, and calls to those aliases start failing immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>D(E.name),children:"Delete"})]})]})]})]})]},E.name))]})]})})]}),k&&s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsxs(Je,{className:"font-serif",children:['Models on "',k.provider,'"']}),s.jsx(it,{children:"Read from the upstream's own model list. Binding uses the upstream name as the alias with chat capabilities; refine aliases and capabilities in the Models tab."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Upstream name"}),s.jsx(ge,{children:"Bound alias"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[k.models.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:3,className:"text-muted-foreground",children:"The upstream reported no models."})}),k.models.map(E=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:E.upstream_name}),s.jsx(de,{children:E.bound_alias?s.jsx(on,{variant:"secondary",children:E.bound_alias}):s.jsx("span",{className:"text-muted-foreground",children:"not bound"})}),s.jsx(de,{children:!E.bound_alias&&s.jsx(Me,{variant:"outline",size:"sm",onClick:()=>O(k.provider,E.upstream_name),children:"Bind"})})]},E.upstream_name))]})]})})]})]})}function km({id:e,value:r,onChange:a,options:l,loading:o,note:c,placeholder:d,className:f}){const[h,m]=S.useState(!1),[x,v]=S.useState(0),[b,y]=S.useState(!1),k=S.useRef(null),j=S.useRef(null),T=S.useRef(!1),N=S.useMemo(()=>{if(!b)return l.slice(0,50);const O=r.trim().toLowerCase();return l.filter(C=>C.value.toLowerCase().includes(O)).slice(0,50)},[l,r,b]),R=()=>{y(!1);const E=l.slice(0,50).findIndex(C=>C.value===r);v(E>=0?E:0),m(!0)};S.useEffect(()=>{const O=E=>{var C;(C=k.current)!=null&&C.contains(E.target)||m(!1)};return document.addEventListener("pointerdown",O),()=>document.removeEventListener("pointerdown",O)},[]);const D=O=>{a(O.value),y(!1),m(!1)},I=O=>{if(O.key==="ArrowDown"||O.key==="ArrowUp"){if(O.preventDefault(),!h){R();return}const E=O.key==="ArrowDown"?1:-1;v(C=>(C+E+N.length)%Math.max(N.length,1))}else O.key==="Enter"&&h&&N[x]?(O.preventDefault(),D(N[x])):O.key==="Escape"&&m(!1)};return s.jsxs("div",{ref:k,className:Ne("relative",f),children:[s.jsx(Ft,{ref:j,id:e,role:"combobox","aria-expanded":h,"aria-autocomplete":"list",autoComplete:"off",className:"pr-14 font-mono text-xs",placeholder:d,value:r,onChange:O=>{a(O.target.value),y(!0),v(0),m(!0)},onFocus:R,onKeyDown:I}),s.jsxs("div",{className:"absolute inset-y-0 right-1 flex items-center",children:[o?s.jsx(kt,{className:"text-muted-foreground mr-1"}):r!==""&&s.jsx("button",{type:"button","aria-label":"Clear",tabIndex:-1,className:"text-muted-foreground hover:text-foreground rounded p-1",onPointerDown:O=>O.preventDefault(),onClick:()=>{var O;a(""),y(!1),v(0),m(!0),(O=j.current)==null||O.focus()},children:s.jsx(kc,{className:"size-3.5"})}),s.jsx("button",{type:"button","aria-label":"Show options",tabIndex:-1,className:"text-muted-foreground hover:text-foreground rounded p-1",onPointerDown:O=>{O.preventDefault(),T.current=h},onClick:()=>{var O;(O=j.current)==null||O.focus(),T.current?m(!1):R()},children:s.jsx(Ji,{className:Ne("size-4 transition-transform",h&&"rotate-180")})})]}),h&&(N.length>0||c)&&s.jsxs("div",{className:"bg-popover absolute z-20 mt-1 max-h-64 w-full overflow-y-auto rounded-md border p-1 shadow-md",children:[c&&s.jsx("p",{className:"text-muted-foreground px-2 py-1.5 text-xs",children:c}),N.map((O,E)=>s.jsxs("button",{type:"button",role:"option","aria-selected":E===x,className:Ne("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left text-xs",E===x&&"bg-accent text-accent-foreground"),onPointerEnter:()=>v(E),onClick:()=>D(O),children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(jc,{className:Ne("size-3.5 shrink-0",O.value!==r&&"invisible")}),s.jsx("span",{className:"truncate font-mono",children:O.value})]}),O.hint&&s.jsx("span",{className:"text-muted-foreground shrink-0",children:O.hint})]},O.value))]})]})}var qh="rovingFocusGroup.onEntryFocus",zR={bubbles:!1,cancelable:!0},Pc="RovingFocusGroup",[Cm,yS,LR]=tp(Pc),[UR,$c]=Nr(Pc,[LR]),[BR,IR]=UR(Pc),bS=S.forwardRef((e,r)=>s.jsx(Cm.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(Cm.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(qR,{...e,ref:r})})}));bS.displayName=Pc;var qR=S.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:a,orientation:l,loop:o=!1,dir:c,currentTabStopId:d,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:h,onEntryFocus:m,preventScrollOnEntryFocus:x=!1,...v}=e,b=S.useRef(null),y=ft(r,b),k=Mc(c),[j=null,T]=nl({prop:d,defaultProp:f,onChange:h}),[N,R]=S.useState(!1),D=fr(m),I=yS(a),O=S.useRef(!1),[E,C]=S.useState(0);return S.useEffect(()=>{const z=b.current;if(z)return z.addEventListener(qh,D),()=>z.removeEventListener(qh,D)},[D]),s.jsx(BR,{scope:a,orientation:l,dir:k,loop:o,currentTabStopId:j,onItemFocus:S.useCallback(z=>T(z),[T]),onItemShiftTab:S.useCallback(()=>R(!0),[]),onFocusableItemAdd:S.useCallback(()=>C(z=>z+1),[]),onFocusableItemRemove:S.useCallback(()=>C(z=>z-1),[]),children:s.jsx(Ge.div,{tabIndex:N||E===0?-1:0,"data-orientation":l,...v,ref:y,style:{outline:"none",...e.style},onMouseDown:Ae(e.onMouseDown,()=>{O.current=!0}),onFocus:Ae(e.onFocus,z=>{const Y=!O.current;if(z.target===z.currentTarget&&Y&&!N){const q=new CustomEvent(qh,zR);if(z.currentTarget.dispatchEvent(q),!q.defaultPrevented){const P=I().filter(B=>B.focusable),K=P.find(B=>B.active),ue=P.find(B=>B.id===j),W=[K,ue,...P].filter(Boolean).map(B=>B.ref.current);jS(W,x)}}O.current=!1}),onBlur:Ae(e.onBlur,()=>R(!1))})})}),wS="RovingFocusGroupItem",SS=S.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:a,focusable:l=!0,active:o=!1,tabStopId:c,...d}=e,f=Pr(),h=c||f,m=IR(wS,a),x=m.currentTabStopId===h,v=yS(a),{onFocusableItemAdd:b,onFocusableItemRemove:y}=m;return S.useEffect(()=>{if(l)return b(),()=>y()},[l,b,y]),s.jsx(Cm.ItemSlot,{scope:a,id:h,focusable:l,active:o,children:s.jsx(Ge.span,{tabIndex:x?0:-1,"data-orientation":m.orientation,...d,ref:r,onMouseDown:Ae(e.onMouseDown,k=>{l?m.onItemFocus(h):k.preventDefault()}),onFocus:Ae(e.onFocus,()=>m.onItemFocus(h)),onKeyDown:Ae(e.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){m.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const j=$R(k,m.orientation,m.dir);if(j!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let N=v().filter(R=>R.focusable).map(R=>R.ref.current);if(j==="last")N.reverse();else if(j==="prev"||j==="next"){j==="prev"&&N.reverse();const R=N.indexOf(k.currentTarget);N=m.loop?FR(N,R+1):N.slice(R+1)}setTimeout(()=>jS(N))}})})})});SS.displayName=wS;var HR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function PR(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function $R(e,r,a){const l=PR(e.key,a);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(l))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(l)))return HR[l]}function jS(e,r=!1){const a=document.activeElement;for(const l of e)if(l===a||(l.focus({preventScroll:r}),document.activeElement!==a))return}function FR(e,r){return e.map((a,l)=>e[(r+l)%e.length])}var kS=bS,CS=SS,yp="Tabs",[VR]=Nr(yp,[$c]),NS=$c(),[GR,bp]=VR(yp),ES=S.forwardRef((e,r)=>{const{__scopeTabs:a,value:l,onValueChange:o,defaultValue:c,orientation:d="horizontal",dir:f,activationMode:h="automatic",...m}=e,x=Mc(f),[v,b]=nl({prop:l,onChange:o,defaultProp:c});return s.jsx(GR,{scope:a,baseId:Pr(),value:v,onValueChange:b,orientation:d,dir:x,activationMode:h,children:s.jsx(Ge.div,{dir:x,"data-orientation":d,...m,ref:r})})});ES.displayName=yp;var TS="TabsList",AS=S.forwardRef((e,r)=>{const{__scopeTabs:a,loop:l=!0,...o}=e,c=bp(TS,a),d=NS(a);return s.jsx(kS,{asChild:!0,...d,orientation:c.orientation,dir:c.dir,loop:l,children:s.jsx(Ge.div,{role:"tablist","aria-orientation":c.orientation,...o,ref:r})})});AS.displayName=TS;var _S="TabsTrigger",MS=S.forwardRef((e,r)=>{const{__scopeTabs:a,value:l,disabled:o=!1,...c}=e,d=bp(_S,a),f=NS(a),h=OS(d.baseId,l),m=zS(d.baseId,l),x=l===d.value;return s.jsx(CS,{asChild:!0,...f,focusable:!o,active:x,children:s.jsx(Ge.button,{type:"button",role:"tab","aria-selected":x,"aria-controls":m,"data-state":x?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:h,...c,ref:r,onMouseDown:Ae(e.onMouseDown,v=>{!o&&v.button===0&&v.ctrlKey===!1?d.onValueChange(l):v.preventDefault()}),onKeyDown:Ae(e.onKeyDown,v=>{[" ","Enter"].includes(v.key)&&d.onValueChange(l)}),onFocus:Ae(e.onFocus,()=>{const v=d.activationMode!=="manual";!x&&!o&&v&&d.onValueChange(l)})})})});MS.displayName=_S;var RS="TabsContent",DS=S.forwardRef((e,r)=>{const{__scopeTabs:a,value:l,forceMount:o,children:c,...d}=e,f=bp(RS,a),h=OS(f.baseId,l),m=zS(f.baseId,l),x=l===f.value,v=S.useRef(x);return S.useEffect(()=>{const b=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(b)},[]),s.jsx(Vr,{present:o||x,children:({present:b})=>s.jsx(Ge.div,{"data-state":x?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":h,hidden:!b,id:m,tabIndex:0,...d,ref:r,style:{...e.style,animationDuration:v.current?"0s":void 0},children:b&&c})})});DS.displayName=RS;function OS(e,r){return`${e}-trigger-${r}`}function zS(e,r){return`${e}-content-${r}`}var YR=ES,XR=AS,KR=MS,QR=DS;function Nm({className:e,...r}){return s.jsx(YR,{"data-slot":"tabs",className:Ne("flex flex-col gap-2",e),...r})}function Em({className:e,...r}){return s.jsx(XR,{"data-slot":"tabs-list",className:Ne("bg-[rgb(var(--border))] text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...r})}function or({className:e,...r}){return s.jsx(KR,{"data-slot":"tabs-trigger",className:Ne("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function Ur({className:e,...r}){return s.jsx(QR,{"data-slot":"tabs-content",className:Ne("flex-1 outline-none",e),...r})}const ZR=["chat","chat_stream","completions","embeddings","transcription","vision"],Fc=[{unit:"input_tokens",label:"Input $/M",short:"in"},{unit:"output_tokens",label:"Output $/M",short:"out"},{unit:"cached_input_tokens",label:"Cached input $/M",short:"cached"}];function no(e){return e instanceof Error?e.message:String(e)}function JR(e){const r={};for(const{unit:a}of Fc)e[a]!==void 0&&(r[a]=String(e[a]));return r}function Ib(e){const r={};for(const{unit:a}of Fc){const l=(e[a]??"").trim();if(l==="")continue;const o=Number(l);if(!isFinite(o)||o<0)return null;r[a]=o}return r}function qb({id:e,value:r,onChange:a,inherited:l}){return s.jsx(s.Fragment,{children:Fc.map(({unit:o,label:c})=>s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:`${e}-${o}`,children:c}),s.jsx(Ft,{id:`${e}-${o}`,type:"number",min:"0",step:"any",placeholder:l?"inherited":"unpriced",value:r[o]??"",onChange:d=>a({...r,[o]:d.target.value})})]},o))})}function WR({model:e}){const r=Fc.filter(({unit:a})=>e.pricing[a]!==void 0).map(({unit:a,short:l})=>`${l} ${e.pricing[a]}`);return r.length===0?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):s.jsxs("span",{className:"tabular-nums",children:[r.map((a,l)=>s.jsxs("span",{className:"whitespace-nowrap",children:[l>0&&" · ",a]},a)),e.pricing_inherited&&s.jsx(on,{variant:"muted",className:"ml-2",title:"Priced under the upstream model name",children:"inherited"})]})}function Hb({value:e,onChange:r}){return s.jsx(s.Fragment,{children:ZR.map(a=>s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx(xp,{checked:e.includes(a),onCheckedChange:l=>r(l===!0?[...e,a]:e.filter(o=>o!==a))}),a]},a))})}function Hh(e,r){return e.filter(a=>a.target===null&&a.targets.length===0&&a.alias!==r).map(a=>({value:a.alias,hint:`${a.provider} · ${a.upstream_name}`}))}function io(e){return e.map(r=>({alias:r.alias.trim(),weight:r.weight})).filter(r=>r.alias!=="")}function Pb(e){return e.strategy!=="weighted"?e.targets:[...e.targets].sort((r,a)=>a.weight-r.weight)}function $b({id:e,targets:r,strategy:a,options:l,onChange:o,note:c}){var m;const d=io(r).length>1,f=x=>o(x,a),h=(x,v)=>{const b=[...r];[b[x],b[x+v]]=[b[x+v],b[x]],f(b)};return s.jsxs("div",{className:"flex flex-col gap-2 sm:col-span-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(rn,{htmlFor:`${e}-target-0`,className:"flex-1",children:r.length>1?"Models it points at":"Model it points at"}),d&&a==="weighted"&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"w-31 text-sm font-medium",children:"Weight"}),s.jsx("span",{className:"w-26"})]})]}),r.map((x,v)=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(km,{id:`${e}-target-${v}`,className:"flex-1",value:x.alias,onChange:b=>f(r.map((y,k)=>k===v?{...y,alias:b}:y)),options:l.filter(b=>b.value===x.alias||!r.some(y=>y.alias===b.value)),note:c}),d&&a==="weighted"&&s.jsx(Ft,{type:"number",min:1,"aria-label":`Weight of target ${v+1}`,className:"w-20",value:x.weight,onChange:b=>f(r.map((y,k)=>k===v?{...y,weight:Math.max(1,Number(b.target.value)||1)}:y))}),d&&a==="weighted"&&s.jsx("span",{className:"w-10 text-right text-sm text-muted-foreground tabular-nums",children:x.alias.trim()?cS(x.weight,io(r).map(b=>b.weight)):""}),r.length>1&&s.jsxs(s.Fragment,{children:[s.jsx(Me,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Move target ${v+1} up`,disabled:v===0,onClick:()=>h(v,-1),children:s.jsx(aE,{})}),s.jsx(Me,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Move target ${v+1} down`,disabled:v===r.length-1,onClick:()=>h(v,1),children:s.jsx(nE,{})}),s.jsx(Me,{type:"button",variant:"ghost",size:"icon-sm","aria-label":`Remove target ${v+1}`,onClick:()=>f(r.filter((b,y)=>y!==v)),children:s.jsx(kc,{})})]})]},v)),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Me,{type:"button",variant:"outline",size:"sm",onClick:()=>f([...r,{alias:"",weight:1}]),children:[s.jsx(mE,{}),"Add target"]}),d&&s.jsxs(s.Fragment,{children:[s.jsxs(Sr,{value:a,onValueChange:x=>o(r,x),children:[s.jsx(kr,{size:"sm",className:"w-36","aria-label":"Strategy",children:s.jsx(jr,{})}),s.jsx(Cr,{children:jm.map(x=>s.jsx(hr,{value:x.value,children:x.label},x.value))})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:(m=jm.find(x=>x.value===a))==null?void 0:m.hint})]})]})]})}function Fb({value:e,onChange:r}){return s.jsx(Nm,{value:e,onValueChange:a=>r(a),children:s.jsxs(Em,{children:[s.jsx(or,{value:"provider",children:"Provider model"}),s.jsx(or,{value:"alias",children:"Alias → model"})]})})}const Vb=new Map;function Gb(e){const[r,a]=S.useState([]),[l,o]=S.useState(!1),[c,d]=S.useState(null);S.useEffect(()=>{if(e===""){a([]),d(null);return}const m=Vb.get(e);if(m){a(m),d(null);return}let x=!0;return o(!0),d(null),He.get(`/admin/v1/providers/${encodeURIComponent(e)}/discover`).then(v=>{x&&(Vb.set(e,v.models),a(v.models))}).catch(v=>x&&d(no(v))).finally(()=>x&&o(!1)),()=>{x=!1}},[e]);const f=r.map(m=>({value:m.upstream_name,hint:m.bound_alias?`bound to ${m.bound_alias}`:void 0})),h=e?c?`Could not list this provider's models (${c}). Type the name.`:l?"Asking the provider what it serves…":r.length===0?"The provider listed no models. Type the name.":void 0:"Select a provider to list its models.";return{options:f,loading:l,note:h}}function eD(){var D,I,O,E;const e=Ut(()=>He.get("/admin/v1/models")),r=Ut(()=>He.get("/admin/v1/providers")),[a,l]=S.useState({kind:"provider",alias:"",provider:"",upstream_name:"",targets:[{alias:"",weight:1}],strategy:"failover",capabilities:["chat","chat_stream"],prices:{}}),[o,c]=S.useState(!1),[d,f]=S.useState(null),h=Gb(a.kind==="provider"?a.provider:""),m=Gb((d==null?void 0:d.kind)==="provider"?d.provider:""),x=((D=e.data)==null?void 0:D.models)??[],v=S.useRef("");S.useEffect(()=>{if(!(a.kind!=="provider"||a.provider==="")&&v.current!==a.provider&&!(h.loading||h.options.length===0)&&(v.current=a.provider,a.upstream_name.trim()==="")){const C=h.options.find(z=>!z.hint)??h.options[0];l(z=>({...z,upstream_name:C.value}))}},[a.kind,a.provider,a.upstream_name,h.loading,h.options]);const b=C=>{if(C.kind==="alias"){const z=io(C.targets);return z.length>1?{targets:z,strategy:C.strategy}:{targets:z}}return{provider:C.provider,upstream_name:C.upstream_name.trim(),capabilities:C.capabilities}},y=C=>C.kind==="alias"?io(C.targets).length===0?"Pick the model this one points at":C.alias.trim()===""?"An alias for another model needs its own name":null:C.upstream_name.trim()===""?"Upstream model name is required":C.capabilities.length===0?"Pick at least one capability":null,k=async C=>{C.preventDefault();const z=y(a);if(z){Ve.error(z);return}const Y=Ib(a.prices);if(Y===null){Ve.error("Prices must be non-negative numbers");return}const q=a.alias.trim()||a.upstream_name.trim();c(!0);try{await He.post("/admin/v1/models",{alias:q,...b(a),pricing:Object.keys(Y).length>0?Y:void 0}),Ve.success(`Model "${q}" bound`),l({...a,alias:"",upstream_name:"",targets:[{alias:"",weight:1}],strategy:"failover",prices:{}}),e.reload()}catch(P){Ve.error(no(P))}finally{c(!1)}},j=async()=>{if(!d)return;if(d.alias.trim()===""){Ve.error("Alias is required");return}const C=y(d);if(C){Ve.error(C);return}const z=Ib(d.prices);if(z===null){Ve.error("Prices must be non-negative numbers");return}try{await He.patch(`/admin/v1/models/${encodeURIComponent(d.original)}`,{alias:d.alias.trim(),...d.kind==="alias"?b(d):{target:"",...b(d)},pricing:z}),Ve.success(d.alias.trim()===d.original?`Model "${d.original}" updated`:`Model "${d.original}" renamed to "${d.alias.trim()}"`),f(null),e.reload()}catch(Y){Ve.error(no(Y))}},T=async(C,z)=>{try{await He.patch(`/admin/v1/models/${encodeURIComponent(C)}`,{hidden:z}),Ve.success(z?`Model "${C}" hidden`:`Model "${C}" shown`),e.reload()}catch(Y){Ve.error(no(Y))}},N=async C=>{try{await He.del(`/admin/v1/models/${encodeURIComponent(C)}`),Ve.success(`Model "${C}" deleted`),e.reload()}catch(z){Ve.error(no(z))}},R=s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"m-alias",children:a.kind==="alias"?"Name":"Alias"}),s.jsx(Ft,{id:"m-alias",placeholder:a.kind==="alias"?"a new name for it":a.upstream_name.trim()||"same as the upstream name",value:a.alias,onChange:C=>l({...a,alias:C.target.value})})]});return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Bind a model"}),s.jsxs(it,{children:["A model name is what callers pass as ",s.jsx("code",{className:"font-mono",children:"model"}),"; names are globally unique and serve as soon as they exist (disable the provider to take its models offline). It either points at a provider's model, or at another model already bound, in which case it inherits that one's provider, capabilities and prices. Prices are per million units: a unit left blank records usage as unpriced rather than free."]})]}),s.jsx(Qe,{children:s.jsxs("form",{onSubmit:k,className:"flex flex-col gap-4",children:[s.jsx(Fb,{value:a.kind,onChange:C=>l({...a,kind:C})}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[a.kind==="alias"&&R,a.kind==="provider"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{children:"Provider"}),s.jsxs(Sr,{value:a.provider,onValueChange:C=>l({...a,provider:C}),required:!0,children:[s.jsx(kr,{className:"w-full",children:s.jsx(jr,{placeholder:"Select a provider"})}),s.jsx(Cr,{children:(I=r.data)==null?void 0:I.providers.map(C=>s.jsx(hr,{value:C.name,children:C.name},C.name))})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"m-upstream",children:"Upstream model name"}),s.jsx(km,{id:"m-upstream",value:a.upstream_name,onChange:C=>l({...a,upstream_name:C}),...h})]})]}):s.jsx($b,{id:"m",targets:a.targets,strategy:a.strategy,options:Hh(x),onChange:(C,z)=>l({...a,targets:C,strategy:z}),note:Hh(x).length>0?void 0:"Bind a provider model first; an alias points at one of those."}),a.kind==="provider"&&R]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:s.jsx(qb,{id:"new",value:a.prices,onChange:C=>l({...a,prices:C}),inherited:a.kind==="alias"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2",children:[a.kind==="provider"?s.jsx(Hb,{value:a.capabilities,onChange:C=>l({...a,capabilities:C})}):s.jsx("span",{className:"text-sm text-muted-foreground",children:"Capabilities are inherited from the model it points at."}),s.jsxs(Me,{type:"submit",disabled:o||(a.kind==="provider"?a.provider===""||a.upstream_name.trim()==="":io(a.targets).length===0||a.alias.trim()===""),children:[o&&s.jsx(kt,{}),"Bind model"]})]})]})})]}),s.jsxs(Ke,{children:[s.jsx(Ze,{children:s.jsx(Je,{className:"font-serif",children:"Models"})}),s.jsx(Qe,{children:e.loading&&!e.data?s.jsx(kt,{}):e.error?s.jsx("p",{className:"text-sm text-destructive",children:e.error}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Alias"}),s.jsx(ge,{children:"Provider"}),s.jsx(ge,{children:"Upstream name"}),s.jsx(ge,{children:"Capabilities"}),s.jsx(ge,{children:"Pricing ($/M)"}),s.jsx(ge,{className:"w-32"})]})}),s.jsxs(vn,{children:[((O=e.data)==null?void 0:O.models.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:"No model bindings yet. Register a provider first, then bind models here or from provider discovery."})}),(E=e.data)==null?void 0:E.models.map(C=>{var z;return(d==null?void 0:d.original)===C.alias?s.jsx(Oe,{children:s.jsx(de,{colSpan:6,children:s.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[s.jsx(Fb,{value:d.kind,onChange:Y=>f({...d,kind:Y})}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[d.kind==="provider"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{children:"Provider"}),s.jsxs(Sr,{value:d.provider,onValueChange:Y=>f({...d,provider:Y}),children:[s.jsx(kr,{className:"w-full",children:s.jsx(jr,{})}),s.jsx(Cr,{children:(z=r.data)==null?void 0:z.providers.map(Y=>s.jsx(hr,{value:Y.name,children:Y.name},Y.name))})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"edit-upstream",children:"Upstream model name"}),s.jsx(km,{id:"edit-upstream",value:d.upstream_name,onChange:Y=>f({...d,upstream_name:Y}),...m})]})]}):s.jsx($b,{id:"edit",targets:d.targets,strategy:d.strategy,options:Hh(x,d.original),onChange:(Y,q)=>f({...d,targets:Y,strategy:q})}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(rn,{htmlFor:"edit-alias",children:"Name"}),s.jsx(Ft,{id:"edit-alias",value:d.alias,onChange:Y=>f({...d,alias:Y.target.value})})]})]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:s.jsx(qb,{id:"edit",value:d.prices,onChange:Y=>f({...d,prices:Y}),inherited:d.kind==="alias"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2",children:[d.kind==="provider"?s.jsx(Hb,{value:d.capabilities,onChange:Y=>f({...d,capabilities:Y})}):s.jsx("span",{className:"text-sm text-muted-foreground",children:"Capabilities are inherited from the model it points at."}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{size:"sm",onClick:j,children:"Save"}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>f(null),children:"Cancel"})]})]})]})})},C.alias):s.jsxs(Oe,{children:[s.jsx(de,{className:"font-medium wrap-anywhere",children:s.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[C.alias,C.hidden&&s.jsx(on,{variant:"muted",children:"hidden"})]})}),s.jsx(de,{className:"wrap-anywhere",children:C.targets.length>1?s.jsx("span",{className:"flex flex-col",children:[...new Set(Pb(C).map(Y=>Y.provider))].map(Y=>s.jsx("span",{children:Y},Y))}):C.provider}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:C.targets.length>1?s.jsxs("span",{className:"flex flex-col",children:[Pb(C).map(Y=>s.jsxs("span",{children:["→ ",Y.alias,C.strategy==="weighted"&&s.jsxs("span",{className:"text-muted-foreground",children:[" ",cS(Y.weight,C.targets.map(q=>q.weight))]})]},Y.alias)),s.jsx("span",{className:"font-sans text-muted-foreground",children:uS(C.strategy)})]}):C.target?s.jsxs("span",{className:"flex flex-col",children:[s.jsxs("span",{children:["→ ",C.target]}),s.jsx("span",{className:"text-muted-foreground",children:C.upstream_name})]}):C.upstream_name}),s.jsx(de,{children:s.jsx("div",{className:"flex flex-wrap gap-1",children:C.capabilities.map(Y=>s.jsx(on,{variant:"muted",children:Y},Y))})}),s.jsx(de,{className:"text-sm",children:s.jsx(WR,{model:C})}),s.jsxs(de,{className:"whitespace-nowrap",children:[s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":C.hidden?`Show ${C.alias}`:`Hide ${C.alias}`,title:"Hidden from the model list. It still answers calls.",onClick:()=>T(C.alias,!C.hidden),children:C.hidden?s.jsx(uE,{}):s.jsx(cE,{})}),s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Edit ${C.alias}`,onClick:()=>f({original:C.alias,kind:C.target||C.targets.length>0?"alias":"provider",alias:C.alias,provider:C.provider,upstream_name:C.upstream_name,targets:C.targets.length>0?C.targets.map(Y=>({...Y})):[{alias:C.target??"",weight:1}],strategy:C.strategy??"failover",capabilities:[...C.capabilities],prices:C.pricing_inherited?{}:JR(C.pricing)}),children:s.jsx(p1,{})}),s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Delete ${C.alias}`,children:s.jsx(Ym,{})})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:['Delete model "',C.alias,'"?']}),s.jsx(ul,{children:"Callers using this name get model_not_found immediately. Usage history is kept, and a model other names point at cannot be deleted until they are."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>N(C.alias),children:"Delete"})]})]})]})]})]},C.alias)})]})]})})]})]})}const Ph=[{key:"24h",label:"Last 24 hours",hours:24},{key:"7d",label:"Last 7 days",hours:168},{key:"30d",label:"Last 30 days",hours:720},{key:"all",label:"All time",hours:0},{key:"custom",label:"Custom range",hours:0}],tD=[25,50,100,200],nD=[{value:"failed",label:"Errors only"},{value:"upstream_error",label:"Provider errors"},{value:"unreachable",label:"Unreachable"},{value:"cancelled",label:"Cancelled"},{value:"ok",label:"OK only"}];function rD(e){return e?`${e}T00:00:00Z`:null}function aD(e){if(!e)return null;const r=new Date(`${e}T00:00:00Z`);return r.setUTCDate(r.getUTCDate()+1),r.toISOString()}function lD(e){const r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function iD({row:e}){return e.cancelled?s.jsx(on,{variant:"warning",children:"cancelled"}):e.outcome==="ok"?s.jsx(on,{variant:"success",children:"ok"}):s.jsxs(on,{variant:"destructive",children:[e.error_kind||e.outcome,e.status_code?` · ${e.status_code}`:""]})}function sD({row:e}){return s.jsxs("span",{className:"flex items-baseline",children:[s.jsx("span",{className:"max-w-36 truncate",title:e.principal,children:e.principal}),e.key_suffix&&s.jsxs("span",{className:"ml-1.5 shrink-0 font-mono text-xs text-muted-foreground",title:e.key_label||void 0,children:["···",e.key_suffix]})]})}function oD({row:e}){const r=ha(e.tags,"app");return r?s.jsx(on,{variant:"tag",size:"sm",className:"max-w-full font-mono",title:r,children:s.jsx("span",{className:"min-w-0 truncate",children:r})}):e.client?s.jsx("span",{className:"font-mono text-xs text-muted-foreground",title:e.client,children:ao(e.client)}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}function uD({row:e}){const r=e.units.input_tokens,a=e.units.output_tokens;return!r&&!a?s.jsx("span",{className:"text-muted-foreground",children:"—"}):s.jsxs("span",{className:"whitespace-nowrap tabular-nums",children:[Re(r??0),s.jsx("span",{className:"text-muted-foreground",children:" → "}),Re(a??0)]})}function yr({label:e,children:r}){return s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),s.jsx("span",{className:"text-sm",children:r})]})}function cD({row:e}){const r=Object.entries(e.units).sort();return s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-3 py-2 md:grid-cols-4",children:[s.jsx(yr,{label:"Provider",children:s.jsx("span",{className:"font-mono text-xs",children:e.provider||"—"})}),s.jsx(yr,{label:"Endpoint",children:e.endpoint}),s.jsx(yr,{label:"Key",children:e.key_suffix?s.jsxs("span",{className:"font-mono text-xs",children:[e.key_label?`${e.key_label} `:"","···",e.key_suffix]}):"—"}),s.jsx(yr,{label:"Recorded (UTC)",children:s.jsx("span",{className:"font-mono text-xs",children:e.ts.replace("T"," ").slice(0,19)})}),s.jsx(yr,{label:"Client",children:s.jsx("span",{className:"break-all font-mono text-xs",children:e.client||"—"})}),s.jsx(yr,{label:"Tags",children:e.tags?s.jsx("span",{className:"flex flex-wrap gap-1",children:eN(e.tags).map(a=>s.jsx(on,{variant:"tag",size:"sm",className:"font-mono",children:a},a))}):"—"}),s.jsxs(yr,{label:"Outcome",children:[e.outcome,e.error_kind?` · ${e.error_kind}`:"",e.status_code?` · http ${e.status_code}`:"",e.streamed?" · streamed":""]}),s.jsx(yr,{label:"Cost",children:e.cost!==null?s.jsx("span",{className:"tabular-nums",children:Pm(e.cost)}):e.unpriced?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):"—"}),r.map(([a,l])=>s.jsx(yr,{label:a.replaceAll("_"," "),children:s.jsx("span",{className:"tabular-nums",children:Vt(l)||"0"})},a)),e.ttft_ms!==null&&s.jsx(yr,{label:"First token",children:s.jsxs("span",{className:"tabular-nums",children:[Ht(e.ttft_ms)," ms"]})}),s.jsx(yr,{label:"Duration",children:s.jsxs("span",{className:"tabular-nums",children:[Ht(e.duration_ms)," ms"]})})]})}function dD(){var Ie,Be,Mt,Nt,Et,Bt,Rt,Dt,zt;const e=S.useMemo(()=>new URLSearchParams(window.location.search),[]),[r,a]=S.useState("7d"),[l,o]=S.useState(""),[c,d]=S.useState(""),[f,h]=S.useState(e.get("principal")??""),[m,x]=S.useState(""),[v,b]=S.useState(""),[y,k]=S.useState(e.get("model")??""),[j,T]=S.useState(e.get("provider")??""),[N,R]=S.useState(e.get("app")??""),[D,I]=S.useState(e.get("outcome")??""),[O,E]=S.useState(50),[C,z]=S.useState(0),[Y,q]=S.useState(null),[P,K]=S.useState(0),ue=()=>K(ye=>ye+1),le=r==="custom",W=Ph.find(ye=>ye.key===r)??Ph[1],{since:B,until:F}=S.useMemo(()=>le?{since:rD(l),until:aD(c)}:W.hours?{since:new Date(Date.now()-W.hours*36e5).toISOString(),until:null}:{since:null,until:null},[r,le,l,c,P]),ae=(B?`&since=${encodeURIComponent(B)}`:"")+(F?`&until=${encodeURIComponent(F)}`:""),Z=(f?`&principal=${encodeURIComponent(f)}`:"")+(m?`&key=${encodeURIComponent(m)}`:"")+(v?`&client=${encodeURIComponent(v)}`:"")+(y?`&model=${encodeURIComponent(y)}`:"")+(j?`&provider=${encodeURIComponent(j)}`:"")+(N?`&tag=${encodeURIComponent(`app:${N}`)}`:"")+(D?`&outcome=${encodeURIComponent(D)}`:""),A=Ut(()=>He.get(`/stats/requests?limit=${O}&offset=${C*O}`+ae+Z),[P,B,F,f,m,v,y,j,N,D,O,C]),U=Ut(()=>He.get("/stats/requests/facets"+(ae?"?"+ae.slice(1):"")),[P,B,F]),V=C===0&&!le;S.useEffect(()=>{if(!V)return;const ye=setInterval(ue,3e4);return()=>clearInterval(ye)},[V]);function M(ye){return pt=>{ye(pt),z(0),q(null)}}const se=(((Ie=U.data)==null?void 0:Ie.keys)??[]).map(ye=>({value:ye.id,label:`${ye.principal} · ${ye.label||`…${ye.key_suffix}`}`})),X=[...new Set((((Be=U.data)==null?void 0:Be.clients)??[]).map(ye=>ao(ye)))].sort(),ce=[...new Set((((Mt=U.data)==null?void 0:Mt.tags)??[]).filter(ye=>ye.startsWith("app:")).map(ye=>ye.slice(4)))].sort(),re=f||m||v||y||j||N||D;function be(){h(""),x(""),b(""),k(""),T(""),R(""),I(""),z(0),q(null)}const fe=((Nt=A.data)==null?void 0:Nt.total)??0,we=((Et=A.data)==null?void 0:Et.requests.length)??0,Ee=fe===0?0:C*O+1,Se=Math.max(1,Math.ceil(fe/O));return s.jsxs(Ke,{children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Request explorer"}),s.jsx(it,{children:"Metadata only; content is never stored. Click a row for details."})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:ue,children:s.jsx(pl,{})})]}),s.jsxs(Qe,{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Sr,{value:r,onValueChange:M(a),children:[s.jsx(kr,{className:"w-44","aria-label":"Range",children:s.jsx(jr,{})}),s.jsx(Cr,{children:Ph.map(ye=>s.jsx(hr,{value:ye.key,children:ye.label},ye.key))})]}),le&&s.jsxs(s.Fragment,{children:[s.jsx(Ft,{type:"date",className:"w-40","aria-label":"From (UTC)",value:l,onChange:ye=>M(o)(ye.target.value)}),s.jsx(Ft,{type:"date",className:"w-40","aria-label":"To (UTC)",value:c,onChange:ye=>M(d)(ye.target.value)})]}),s.jsx(Lt,{label:"User",value:f,onChange:M(h),options:((Bt=U.data)==null?void 0:Bt.principals)??[],allLabel:"All users"}),s.jsx(Lt,{label:"Key",value:m,onChange:M(x),options:se,allLabel:"All keys"}),s.jsx(Lt,{label:"Client",value:v,onChange:M(b),options:X,allLabel:"All clients"}),s.jsx(Lt,{label:"App",value:N,onChange:M(R),options:ce,allLabel:"All apps"}),s.jsx(Lt,{label:"Model",value:y,onChange:M(k),options:((Rt=U.data)==null?void 0:Rt.models)??[],allLabel:"All models"}),s.jsx(Lt,{label:"Provider",value:j,onChange:M(T),options:((Dt=U.data)==null?void 0:Dt.providers)??[],allLabel:"All providers"}),s.jsx(Lt,{label:"Outcome",value:D,onChange:M(I),options:nD,allLabel:"All outcomes"}),re&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:be,children:[s.jsx(bo,{})," Clear filters"]})]}),A.loading&&!A.data?s.jsx(kt,{}):A.error?s.jsx("p",{className:"text-sm text-destructive",children:A.error}):s.jsxs(s.Fragment,{children:[s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{className:"w-6"}),s.jsx(ge,{children:"Time"}),s.jsx(ge,{children:"User"}),s.jsx(ge,{children:"App"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{children:"Status"}),s.jsx(ge,{className:"text-right",children:"Tokens"}),s.jsx(ge,{className:"text-right",children:"Cost"}),s.jsx(ge,{className:"text-right",children:"First token"}),s.jsx(ge,{className:"text-right",children:"Duration"})]})}),s.jsxs(vn,{children:[we===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:10,className:"text-muted-foreground",children:re||B?"No requests match these filters.":"No requests recorded yet."})}),(zt=A.data)==null?void 0:zt.requests.map(ye=>s.jsxs(S.Fragment,{children:[s.jsxs(Oe,{className:"cursor-pointer",onClick:()=>q(Y===ye.id?null:ye.id),children:[s.jsx(de,{className:"pr-0",children:s.jsx("button",{type:"button","aria-label":Y===ye.id?"Hide details":"Show details","aria-expanded":Y===ye.id,className:"flex cursor-pointer items-center rounded-sm text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",children:Y===ye.id?s.jsx(Ji,{className:"size-3.5"}):s.jsx(um,{className:"size-3.5"})})}),s.jsx(de,{className:"whitespace-nowrap text-xs",title:$0(ye.ts),children:lD(ye.ts)}),s.jsx(de,{children:s.jsx(sD,{row:ye})}),s.jsx(de,{className:"max-w-44",children:s.jsx(oD,{row:ye})}),s.jsx(de,{className:"max-w-44 truncate font-mono text-xs",title:ye.model||void 0,children:ye.model||s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx(de,{children:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(iD,{row:ye}),ye.failed_over&&s.jsx(on,{variant:"muted",title:"Another target answered this request.",children:"failed over"}),ye.streamed&&s.jsx("span",{title:"streamed",children:s.jsx(bE,{className:"size-3 text-muted-foreground","aria-label":"streamed"})})]})}),s.jsx(de,{className:"text-right",title:ye.units.input_tokens||ye.units.output_tokens?`${Vt(ye.units.input_tokens)||0} in · ${Vt(ye.units.output_tokens)||0} out`+(ye.units.cached_input_tokens?` · ${Vt(ye.units.cached_input_tokens)} cached`:""):void 0,children:s.jsx(uD,{row:ye})}),s.jsx(de,{className:"text-right tabular-nums",children:ye.cost!==null?Pm(ye.cost):ye.unpriced?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx(de,{className:"text-right tabular-nums",children:ye.ttft_ms===null?s.jsx("span",{className:"text-muted-foreground",children:"—"}):co(ye.ttft_ms)}),s.jsx(de,{className:"text-right tabular-nums",children:co(ye.duration_ms)})]}),Y===ye.id&&s.jsxs(Oe,{className:"bg-muted/30 hover:bg-muted/30",children:[s.jsx(de,{}),s.jsx(de,{colSpan:9,children:s.jsx(cD,{row:ye})})]})]},ye.id))]})]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:fe===0?"No requests":`Showing ${Ht(Ee)}–${Ht(Ee+we-1)} of ${Ht(fe)}`}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Sr,{value:String(O),onValueChange:ye=>M(E)(Number(ye)),children:[s.jsx(kr,{className:"w-32","aria-label":"Page size",children:s.jsx(jr,{})}),s.jsx(Cr,{children:tD.map(ye=>s.jsxs(hr,{value:String(ye),children:[ye," per page"]},ye))})]}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",C+1," of ",Ht(Se)]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Previous page",disabled:C===0,onClick:()=>{z(C-1),q(null)},children:s.jsx(iE,{})}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Next page",disabled:C+1>=Se,onClick:()=>{z(C+1),q(null)},children:s.jsx(um,{})})]})]})]})]})]})}function fD(e){return e instanceof Error?e.message:String(e)}function hD(){const{data:e,loading:r,error:a}=Ut(()=>He.get("/admin/v1/principals?limit=500")),l=(e==null?void 0:e.principals.filter(o=>o.kind==="user"))??[];return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Users"}),s.jsx(it,{children:"People appear after their first sign-in."})]}),s.jsx(Qe,{children:r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Name"}),s.jsx(ge,{children:"Role"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[l.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:3,className:"text-muted-foreground",children:"No users yet."})}),l.map(o=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:o.name}),s.jsx(de,{children:o.role==="admin"?s.jsx(on,{variant:"secondary",children:"admin"}):"member"}),s.jsx(de,{className:"text-right whitespace-nowrap",children:s.jsx(mD,{principal:o})})]},o.id))]})]})})]})}function mD({principal:e}){const r=async()=>{try{await He.post(`/admin/v1/principals/${e.id}/revoke-sessions`),Ve.success(`Signed out ${e.name}`)}catch(a){Ve.error(fD(a))}};return s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Sign out"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Sign out ",e.name," everywhere?"]}),s.jsx(ul,{children:"Their sessions end now. API keys keep working."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:r,children:"Sign out"})]})]})]})}function $h(e){return e instanceof Error?e.message:String(e)}function pD(){const{data:e,loading:r,error:a,reload:l}=Ut(async()=>{const[{principals:k},{keys:j}]=await Promise.all([He.get("/admin/v1/principals?limit=500"),He.get("/admin/v1/keys?limit=500")]),T=new Set(k.filter(N=>N.kind==="service").map(N=>N.name));return{users:new Set(k.filter(N=>N.kind==="user").map(N=>N.name)),services:T,keys:j.filter(N=>N.principal&&T.has(N.principal))}}),[o,c]=S.useState(""),[d,f]=S.useState(!1),[h,m]=S.useState(null),x=async k=>{const j=await He.post("/admin/v1/keys",{principal:k,label:""});m(j),l()},v=async k=>{if(k.preventDefault(),e!=null&&e.users.has(o)){Ve.error(`"${o}" is a user, not a service`);return}f(!0);try{if(!(e!=null&&e.services.has(o)))try{await He.post("/admin/v1/principals",{name:o,kind:"service",role:"member"})}catch(j){if(!(j instanceof wc&&j.code==="principal_exists"))throw j}await x(o),c("")}catch(j){Ve.error($h(j))}finally{f(!1)}},b=async k=>{try{await x(k.principal??""),await He.del(`/admin/v1/keys/${k.id}`),l()}catch(j){Ve.error($h(j))}},y=async k=>{try{await He.del(`/admin/v1/keys/${k}`),Ve.success("Key deleted"),l()}catch(j){Ve.error($h(j))}};return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Services"}),s.jsx(it,{children:"API keys for machines and shared tools rather than people."})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsxs("form",{onSubmit:v,className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ft,{className:"w-64",placeholder:"Name (e.g. batch-service)",maxLength:120,pattern:"[a-z0-9][a-z0-9._\\-]*",title:"lowercase letters, digits, dots, dashes, underscores",required:!0,value:o,onChange:k=>c(k.target.value)}),s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Create service"]})]}),h&&s.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-4",children:[s.jsxs("p",{className:"mb-2 text-sm font-medium",children:["Key for ",h.principal," — copy it now, it will not be shown again."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-sm",children:h.key}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Copy key",onClick:()=>{navigator.clipboard.writeText(h.key??""),Ve.success("Copied to clipboard")},children:s.jsx(Gm,{})})]})]}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Service"}),s.jsx(ge,{children:"Key"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-40"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.keys.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No services yet."})}),e==null?void 0:e.keys.map(k=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:k.principal}),s.jsxs(de,{className:"font-mono text-xs",children:["***",k.key_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(k.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(k.last_used_at)||"never"}),s.jsxs(de,{className:"text-right whitespace-nowrap",children:[s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Rotate"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Rotate the key of ",k.principal,"?"]}),s.jsx(ul,{children:"The old key stops working immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>b(k),children:"Rotate"})]})]})]}),s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Delete ",k.principal,"?"]}),s.jsx(ul,{children:"Its key stops working immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>y(k.id),children:"Delete"})]})]})]})]})]},k.id))]})]})]})]})}function gD(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/admin/v1/keys?limit=500")),[o,c]=S.useState(""),d=o.trim().toLowerCase(),f=((e==null?void 0:e.keys)??[]).filter(m=>`${m.principal} ${m.label} ${m.key_suffix}`.toLowerCase().includes(d)),h=async m=>{try{await He.del(`/admin/v1/keys/${m}`),Ve.success("Key deleted"),l()}catch(x){Ve.error(x instanceof Error?x.message:String(x))}};return s.jsxs(Ke,{children:[s.jsx(Ze,{children:s.jsx(Je,{className:"font-serif",children:"All keys"})}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsx(Ft,{className:"w-64",placeholder:"Filter by owner, label or suffix",value:o,onChange:m=>c(m.target.value)}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Owner"}),s.jsx(ge,{children:"Label"}),s.jsx(ge,{children:"Key"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[f.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:e!=null&&e.keys.length?"No match.":"No keys yet."})}),f.map(m=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:m.principal}),s.jsx(de,{className:"wrap-anywhere",children:m.label||s.jsx("span",{className:"text-muted-foreground",children:"(no label)"})}),s.jsxs(de,{className:"font-mono text-xs",children:["***",m.key_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(m.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(m.last_used_at)||"never"}),s.jsx(de,{className:"whitespace-nowrap",children:s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Delete this key of ",m.principal,"?"]}),s.jsx(ul,{children:"It stops working immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>h(m.id),children:"Delete"})]})]})]})})]},m.id))]})]})]})]})}function xD(e,r){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const vD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,bD={};function Yb(e,r){return(bD.jsx?yD:vD).test(e)}const wD=/[ \t\n\f\r]/g;function SD(e){return typeof e=="object"?e.type==="text"?Xb(e.value):!1:Xb(e)}function Xb(e){return e.replace(wD,"")===""}class So{constructor(r,a,l){this.normal=a,this.property=r,l&&(this.space=l)}}So.prototype.normal={};So.prototype.property={};So.prototype.space=void 0;function LS(e,r){const a={},l={};for(const o of e)Object.assign(a,o.property),Object.assign(l,o.normal);return new So(a,l,r)}function Tm(e){return e.toLowerCase()}class qn{constructor(r,a){this.attribute=a,this.property=r}}qn.prototype.attribute="";qn.prototype.booleanish=!1;qn.prototype.boolean=!1;qn.prototype.commaOrSpaceSeparated=!1;qn.prototype.commaSeparated=!1;qn.prototype.defined=!1;qn.prototype.mustUseProperty=!1;qn.prototype.number=!1;qn.prototype.overloadedBoolean=!1;qn.prototype.property="";qn.prototype.spaceSeparated=!1;qn.prototype.space=void 0;let jD=0;const $e=Zl(),Zt=Zl(),Am=Zl(),xe=Zl(),jt=Zl(),$l=Zl(),Kn=Zl();function Zl(){return 2**++jD}const _m=Object.freeze(Object.defineProperty({__proto__:null,boolean:$e,booleanish:Zt,commaOrSpaceSeparated:Kn,commaSeparated:$l,number:xe,overloadedBoolean:Am,spaceSeparated:jt},Symbol.toStringTag,{value:"Module"})),Fh=Object.keys(_m);class wp extends qn{constructor(r,a,l,o){let c=-1;if(super(r,a),Kb(this,"space",o),typeof l=="number")for(;++c4&&a.slice(0,4)==="data"&&TD.test(r)){if(r.charAt(4)==="-"){const c=r.slice(5).replace(Qb,MD);l="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=r.slice(4);if(!Qb.test(c)){let d=c.replace(ED,_D);d.charAt(0)!=="-"&&(d="-"+d),r="data"+d}}o=wp}return new o(l,r)}function _D(e){return"-"+e.toLowerCase()}function MD(e){return e.charAt(1).toUpperCase()}const RD=LS([US,kD,qS,HS,PS],"html"),Sp=LS([US,CD,qS,HS,PS],"svg");function DD(e){return e.join(" ").trim()}var Vi={},Vh,Zb;function OD(){if(Zb)return Vh;Zb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,a=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,h=` +`,m="/",x="*",v="",b="comment",y="declaration";function k(T,N){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];N=N||{};var R=1,D=1;function I(le){var W=le.match(r);W&&(R+=W.length);var B=le.lastIndexOf(h);D=~B?le.length-B:D+le.length}function O(){var le={line:R,column:D};return function(W){return W.position=new E(le),Y(),W}}function E(le){this.start=le,this.end={line:R,column:D},this.source=N.source}E.prototype.content=T;function C(le){var W=new Error(N.source+":"+R+":"+D+": "+le);if(W.reason=le,W.filename=N.source,W.line=R,W.column=D,W.source=T,!N.silent)throw W}function z(le){var W=le.exec(T);if(W){var B=W[0];return I(B),T=T.slice(B.length),W}}function Y(){z(a)}function q(le){var W;for(le=le||[];W=P();)W!==!1&&le.push(W);return le}function P(){var le=O();if(!(m!=T.charAt(0)||x!=T.charAt(1))){for(var W=2;v!=T.charAt(W)&&(x!=T.charAt(W)||m!=T.charAt(W+1));)++W;if(W+=2,v===T.charAt(W-1))return C("End of comment missing");var B=T.slice(2,W-2);return D+=2,I(B),T=T.slice(W),D+=2,le({type:b,comment:B})}}function K(){var le=O(),W=z(l);if(W){if(P(),!z(o))return C("property missing ':'");var B=z(c),F=le({type:y,property:j(W[0].replace(e,v)),value:B?j(B[0].replace(e,v)):v});return z(d),F}}function ue(){var le=[];q(le);for(var W;W=K();)W!==!1&&(le.push(W),q(le));return le}return Y(),ue()}function j(T){return T?T.replace(f,v):v}return Vh=k,Vh}var Jb;function zD(){if(Jb)return Vi;Jb=1;var e=Vi&&Vi.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.default=a;const r=e(OD());function a(l,o){let c=null;if(!l||typeof l!="string")return c;const d=(0,r.default)(l),f=typeof o=="function";return d.forEach(h=>{if(h.type!=="declaration")return;const{property:m,value:x}=h;f?o(m,x,h):x&&(c=c||{},c[m]=x)}),c}return Vi}var Zs={},Wb;function LD(){if(Wb)return Zs;Wb=1,Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,a=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=function(m){return!m||a.test(m)||e.test(m)},d=function(m,x){return x.toUpperCase()},f=function(m,x){return"".concat(x,"-")},h=function(m,x){return x===void 0&&(x={}),c(m)?m:(m=m.toLowerCase(),x.reactCompat?m=m.replace(o,f):m=m.replace(l,f),m.replace(r,d))};return Zs.camelCase=h,Zs}var Js,e0;function UD(){if(e0)return Js;e0=1;var e=Js&&Js.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=e(zD()),a=LD();function l(o,c){var d={};return!o||typeof o!="string"||(0,r.default)(o,function(f,h){f&&h&&(d[(0,a.camelCase)(f,c)]=h)}),d}return l.default=l,Js=l,Js}var BD=UD();const ID=bc(BD),$S=FS("end"),jp=FS("start");function FS(e){return r;function r(a){const l=a&&a.position&&a.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function qD(e){const r=jp(e),a=$S(e);if(r&&a)return{start:r,end:a}}function so(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?t0(e.position):"start"in e||"end"in e?t0(e):"line"in e||"column"in e?Mm(e):""}function Mm(e){return n0(e&&e.line)+":"+n0(e&&e.column)}function t0(e){return Mm(e&&e.start)+"-"+Mm(e&&e.end)}function n0(e){return e&&typeof e=="number"?e:1}class Sn extends Error{constructor(r,a,l){super(),typeof a=="string"&&(l=a,a=void 0);let o="",c={},d=!1;if(a&&("line"in a&&"column"in a?c={place:a}:"start"in a&&"end"in a?c={place:a}:"type"in a?c={ancestors:[a],place:a.position}:c={...a}),typeof r=="string"?o=r:!c.cause&&r&&(d=!0,o=r.message,c.cause=r),!c.ruleId&&!c.source&&typeof l=="string"){const h=l.indexOf(":");h===-1?c.ruleId=l:(c.source=l.slice(0,h),c.ruleId=l.slice(h+1))}if(!c.place&&c.ancestors&&c.ancestors){const h=c.ancestors[c.ancestors.length-1];h&&(c.place=h.position)}const f=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=so(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=d&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const kp={}.hasOwnProperty,HD=new Map,PD=/[A-Z]/g,$D=new Set(["table","tbody","thead","tfoot","tr"]),FD=new Set(["td","th"]),VS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function VD(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=r.filePath||void 0;let l;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=WD(a,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=JD(a,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:l,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?Sp:RD,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},c=GS(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function GS(e,r,a){if(r.type==="element")return GD(e,r,a);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return YD(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return KD(e,r,a);if(r.type==="mdxjsEsm")return XD(e,r);if(r.type==="root")return QD(e,r,a);if(r.type==="text")return ZD(e,r)}function GD(e,r,a){const l=e.schema;let o=l;r.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=Sp,e.schema=o),e.ancestors.push(r);const c=XS(e,r.tagName,!1),d=eO(e,r);let f=Np(e,r);return $D.has(r.tagName)&&(f=f.filter(function(h){return typeof h=="string"?!SD(h):!0})),YS(e,d,c,r),Cp(d,f),e.ancestors.pop(),e.schema=l,e.create(r,c,d,a)}function YD(e,r){if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}po(e,r.position)}function XD(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);po(e,r.position)}function KD(e,r,a){const l=e.schema;let o=l;r.name==="svg"&&l.space==="html"&&(o=Sp,e.schema=o),e.ancestors.push(r);const c=r.name===null?e.Fragment:XS(e,r.name,!0),d=tO(e,r),f=Np(e,r);return YS(e,d,c,r),Cp(d,f),e.ancestors.pop(),e.schema=l,e.create(r,c,d,a)}function QD(e,r,a){const l={};return Cp(l,Np(e,r)),e.create(r,e.Fragment,l,a)}function ZD(e,r){return r.value}function YS(e,r,a,l){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(r.node=l)}function Cp(e,r){if(r.length>0){const a=r.length>1?r:r[0];a&&(e.children=a)}}function JD(e,r,a){return l;function l(o,c,d,f){const m=Array.isArray(d.children)?a:r;return f?m(c,d,f):m(c,d)}}function WD(e,r){return a;function a(l,o,c,d){const f=Array.isArray(c.children),h=jp(l);return r(o,c,d,f,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function eO(e,r){const a={};let l,o;for(o in r.properties)if(o!=="children"&&kp.call(r.properties,o)){const c=nO(e,o,r.properties[o]);if(c){const[d,f]=c;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&FD.has(r.tagName)?l=f:a[d]=f}}if(l){const c=a.style||(a.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return a}function tO(e,r){const a={};for(const l of r.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const c=l.data.estree.body[0];c.type;const d=c.expression;d.type;const f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else po(e,r.position);else{const o=l.name;let c;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const f=l.value.data.estree.body[0];f.type,c=e.evaluater.evaluateExpression(f.expression)}else po(e,r.position);else c=l.value===null?!0:l.value;a[o]=c}return a}function Np(e,r){const a=[];let l=-1;const o=e.passKeys?new Map:HD;for(;++lo?0:o+r:r=r>o?o:r,a=a>0?a:0,l.length<1e4)d=Array.from(l),d.unshift(r,a),e.splice(...d);else for(a&&e.splice(r,a);c0?(Zn(e,e.length,0,r),e):r}const l0={}.hasOwnProperty;function QS(e){const r={};let a=-1;for(;++a13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function wr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=yl(/[A-Za-z]/),wn=yl(/[\dA-Za-z]/),dO=yl(/[#-'*+\--9=?A-Z^-~]/);function mc(e){return e!==null&&(e<32||e===127)}const Rm=yl(/\d/),fO=yl(/[\dA-Fa-f]/),hO=yl(/[!-/:-@[-`{-~]/);function Le(e){return e!==null&&e<-2}function Ct(e){return e!==null&&(e<0||e===32)}function nt(e){return e===-2||e===-1||e===32}const Vc=yl(new RegExp("\\p{P}|\\p{S}","u")),Kl=yl(/\s/);function yl(e){return r;function r(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function rs(e){const r=[];let a=-1,l=0,o=0;for(;++a55295&&c<57344){const f=e.charCodeAt(a+1);c<56320&&f>56319&&f<57344?(d=String.fromCharCode(c,f),o=1):d="�"}else d=String.fromCharCode(c);d&&(r.push(e.slice(l,a),encodeURIComponent(d)),l=a+o+1,d=""),o&&(a+=o,o=0)}return r.join("")+e.slice(l)}function ot(e,r,a,l){const o=l?l-1:Number.POSITIVE_INFINITY;let c=0;return d;function d(h){return nt(h)?(e.enter(a),f(h)):r(h)}function f(h){return nt(h)&&c++d))return;const C=r.events.length;let z=C,Y,q;for(;z--;)if(r.events[z][0]==="exit"&&r.events[z][1].type==="chunkFlow"){if(Y){q=r.events[z][1].end;break}Y=!0}for(N(l),E=C;ED;){const O=a[I];r.containerState=O[1],O[0].exit.call(r,e)}a.length=D}function R(){o.write([null]),c=void 0,o=void 0,r.containerState._closeFlow=void 0}}function vO(e,r,a){return ot(e,e.attempt(this.parser.constructs.document,r,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Zi(e){if(e===null||Ct(e)||Kl(e))return 1;if(Vc(e))return 2}function Gc(e,r,a){const l=[];let o=-1;for(;++o1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const v={...e[l][1].end},b={...e[a][1].start};s0(v,-h),s0(b,h),d={type:h>1?"strongSequence":"emphasisSequence",start:v,end:{...e[l][1].end}},f={type:h>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:b},c={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[a][1].start}},o={type:h>1?"strong":"emphasis",start:{...d.start},end:{...f.end}},e[l][1].end={...d.start},e[a][1].start={...f.end},m=[],e[l][1].end.offset-e[l][1].start.offset&&(m=ur(m,[["enter",e[l][1],r],["exit",e[l][1],r]])),m=ur(m,[["enter",o,r],["enter",d,r],["exit",d,r],["enter",c,r]]),m=ur(m,Gc(r.parser.constructs.insideSpan.null,e.slice(l+1,a),r)),m=ur(m,[["exit",c,r],["enter",f,r],["exit",f,r],["exit",o,r]]),e[a][1].end.offset-e[a][1].start.offset?(x=2,m=ur(m,[["enter",e[a][1],r],["exit",e[a][1],r]])):x=0,Zn(e,l-1,a-l+3,m),a=l+m.length-x-2;break}}for(a=-1;++a0&&nt(E)?ot(e,R,"linePrefix",c+1)(E):R(E)}function R(E){return E===null||Le(E)?e.check(o0,j,I)(E):(e.enter("codeFlowValue"),D(E))}function D(E){return E===null||Le(E)?(e.exit("codeFlowValue"),R(E)):(e.consume(E),D)}function I(E){return e.exit("codeFenced"),r(E)}function O(E,C,z){let Y=0;return q;function q(W){return E.enter("lineEnding"),E.consume(W),E.exit("lineEnding"),P}function P(W){return E.enter("codeFencedFence"),nt(W)?ot(E,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):K(W)}function K(W){return W===f?(E.enter("codeFencedFenceSequence"),ue(W)):z(W)}function ue(W){return W===f?(Y++,E.consume(W),ue):Y>=d?(E.exit("codeFencedFenceSequence"),nt(W)?ot(E,le,"whitespace")(W):le(W)):z(W)}function le(W){return W===null||Le(W)?(E.exit("codeFencedFence"),C(W)):z(W)}}}function _O(e,r,a){const l=this;return o;function o(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c)}function c(d){return l.parser.lazy[l.now().line]?a(d):r(d)}}const Yh={name:"codeIndented",tokenize:RO},MO={partial:!0,tokenize:DO};function RO(e,r,a){const l=this;return o;function o(m){return e.enter("codeIndented"),ot(e,c,"linePrefix",5)(m)}function c(m){const x=l.events[l.events.length-1];return x&&x[1].type==="linePrefix"&&x[2].sliceSerialize(x[1],!0).length>=4?d(m):a(m)}function d(m){return m===null?h(m):Le(m)?e.attempt(MO,d,h)(m):(e.enter("codeFlowValue"),f(m))}function f(m){return m===null||Le(m)?(e.exit("codeFlowValue"),d(m)):(e.consume(m),f)}function h(m){return e.exit("codeIndented"),r(m)}}function DO(e,r,a){const l=this;return o;function o(d){return l.parser.lazy[l.now().line]?a(d):Le(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):ot(e,c,"linePrefix",5)(d)}function c(d){const f=l.events[l.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?r(d):Le(d)?o(d):a(d)}}const OO={name:"codeText",previous:LO,resolve:zO,tokenize:UO};function zO(e){let r=e.length-4,a=3,l,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(l=a;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return rthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(r,a,l){const o=a||0;this.setCursor(Math.trunc(r));const c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return l&&Ws(this.left,l),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),Ws(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),Ws(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r=4?r(d):e.interrupt(l.parser.constructs.flow,a,r)(d)}}function nj(e,r,a,l,o,c,d,f,h){const m=h||Number.POSITIVE_INFINITY;let x=0;return v;function v(N){return N===60?(e.enter(l),e.enter(o),e.enter(c),e.consume(N),e.exit(c),b):N===null||N===32||N===41||mc(N)?a(N):(e.enter(l),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),j(N))}function b(N){return N===62?(e.enter(c),e.consume(N),e.exit(c),e.exit(o),e.exit(l),r):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(N))}function y(N){return N===62?(e.exit("chunkString"),e.exit(f),b(N)):N===null||N===60||Le(N)?a(N):(e.consume(N),N===92?k:y)}function k(N){return N===60||N===62||N===92?(e.consume(N),y):y(N)}function j(N){return!x&&(N===null||N===41||Ct(N))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(l),r(N)):x999||y===null||y===91||y===93&&!h||y===94&&!f&&"_hiddenFootnoteSupport"in d.parser.constructs?a(y):y===93?(e.exit(c),e.enter(o),e.consume(y),e.exit(o),e.exit(l),r):Le(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),x):(e.enter("chunkString",{contentType:"string"}),v(y))}function v(y){return y===null||y===91||y===93||Le(y)||f++>999?(e.exit("chunkString"),x(y)):(e.consume(y),h||(h=!nt(y)),y===92?b:v)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,v):v(y)}}function aj(e,r,a,l,o,c){let d;return f;function f(b){return b===34||b===39||b===40?(e.enter(l),e.enter(o),e.consume(b),e.exit(o),d=b===40?41:b,h):a(b)}function h(b){return b===d?(e.enter(o),e.consume(b),e.exit(o),e.exit(l),r):(e.enter(c),m(b))}function m(b){return b===d?(e.exit(c),h(d)):b===null?a(b):Le(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),ot(e,m,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),x(b))}function x(b){return b===d||b===null||Le(b)?(e.exit("chunkString"),m(b)):(e.consume(b),b===92?v:x)}function v(b){return b===d||b===92?(e.consume(b),x):x(b)}}function oo(e,r){let a;return l;function l(o){return Le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,l):nt(o)?ot(e,l,a?"linePrefix":"lineSuffix")(o):r(o)}}const VO={name:"definition",tokenize:YO},GO={partial:!0,tokenize:XO};function YO(e,r,a){const l=this;let o;return c;function c(y){return e.enter("definition"),d(y)}function d(y){return rj.call(l,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return o=wr(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),h):a(y)}function h(y){return Ct(y)?oo(e,m)(y):m(y)}function m(y){return nj(e,x,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function x(y){return e.attempt(GO,v,v)(y)}function v(y){return nt(y)?ot(e,b,"whitespace")(y):b(y)}function b(y){return y===null||Le(y)?(e.exit("definition"),l.parser.defined.push(o),r(y)):a(y)}}function XO(e,r,a){return l;function l(f){return Ct(f)?oo(e,o)(f):a(f)}function o(f){return aj(e,c,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function c(f){return nt(f)?ot(e,d,"whitespace")(f):d(f)}function d(f){return f===null||Le(f)?r(f):a(f)}}const KO={name:"hardBreakEscape",tokenize:QO};function QO(e,r,a){return l;function l(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return Le(c)?(e.exit("hardBreakEscape"),r(c)):a(c)}}const ZO={name:"headingAtx",resolve:JO,tokenize:WO};function JO(e,r){let a=e.length-2,l=3,o,c;return e[l][1].type==="whitespace"&&(l+=2),a-2>l&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(l===a-1||a-4>l&&e[a-2][1].type==="whitespace")&&(a-=l+1===a?2:4),a>l&&(o={type:"atxHeadingText",start:e[l][1].start,end:e[a][1].end},c={type:"chunkText",start:e[l][1].start,end:e[a][1].end,contentType:"text"},Zn(e,l,a-l+1,[["enter",o,r],["enter",c,r],["exit",c,r],["exit",o,r]])),e}function WO(e,r,a){let l=0;return o;function o(x){return e.enter("atxHeading"),c(x)}function c(x){return e.enter("atxHeadingSequence"),d(x)}function d(x){return x===35&&l++<6?(e.consume(x),d):x===null||Ct(x)?(e.exit("atxHeadingSequence"),f(x)):a(x)}function f(x){return x===35?(e.enter("atxHeadingSequence"),h(x)):x===null||Le(x)?(e.exit("atxHeading"),r(x)):nt(x)?ot(e,f,"whitespace")(x):(e.enter("atxHeadingText"),m(x))}function h(x){return x===35?(e.consume(x),h):(e.exit("atxHeadingSequence"),f(x))}function m(x){return x===null||x===35||Ct(x)?(e.exit("atxHeadingText"),f(x)):(e.consume(x),m)}}const ez=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],c0=["pre","script","style","textarea"],tz={concrete:!0,name:"htmlFlow",resolveTo:az,tokenize:lz},nz={partial:!0,tokenize:sz},rz={partial:!0,tokenize:iz};function az(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function lz(e,r,a){const l=this;let o,c,d,f,h;return m;function m(M){return x(M)}function x(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),v}function v(M){return M===33?(e.consume(M),b):M===47?(e.consume(M),c=!0,j):M===63?(e.consume(M),o=3,l.interrupt?r:A):Cn(M)?(e.consume(M),d=String.fromCharCode(M),T):a(M)}function b(M){return M===45?(e.consume(M),o=2,y):M===91?(e.consume(M),o=5,f=0,k):Cn(M)?(e.consume(M),o=4,l.interrupt?r:A):a(M)}function y(M){return M===45?(e.consume(M),l.interrupt?r:A):a(M)}function k(M){const se="CDATA[";return M===se.charCodeAt(f++)?(e.consume(M),f===se.length?l.interrupt?r:K:k):a(M)}function j(M){return Cn(M)?(e.consume(M),d=String.fromCharCode(M),T):a(M)}function T(M){if(M===null||M===47||M===62||Ct(M)){const se=M===47,X=d.toLowerCase();return!se&&!c&&c0.includes(X)?(o=1,l.interrupt?r(M):K(M)):ez.includes(d.toLowerCase())?(o=6,se?(e.consume(M),N):l.interrupt?r(M):K(M)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?a(M):c?R(M):D(M))}return M===45||wn(M)?(e.consume(M),d+=String.fromCharCode(M),T):a(M)}function N(M){return M===62?(e.consume(M),l.interrupt?r:K):a(M)}function R(M){return nt(M)?(e.consume(M),R):q(M)}function D(M){return M===47?(e.consume(M),q):M===58||M===95||Cn(M)?(e.consume(M),I):nt(M)?(e.consume(M),D):q(M)}function I(M){return M===45||M===46||M===58||M===95||wn(M)?(e.consume(M),I):O(M)}function O(M){return M===61?(e.consume(M),E):nt(M)?(e.consume(M),O):D(M)}function E(M){return M===null||M===60||M===61||M===62||M===96?a(M):M===34||M===39?(e.consume(M),h=M,C):nt(M)?(e.consume(M),E):z(M)}function C(M){return M===h?(e.consume(M),h=null,Y):M===null||Le(M)?a(M):(e.consume(M),C)}function z(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Ct(M)?O(M):(e.consume(M),z)}function Y(M){return M===47||M===62||nt(M)?D(M):a(M)}function q(M){return M===62?(e.consume(M),P):a(M)}function P(M){return M===null||Le(M)?K(M):nt(M)?(e.consume(M),P):a(M)}function K(M){return M===45&&o===2?(e.consume(M),B):M===60&&o===1?(e.consume(M),F):M===62&&o===4?(e.consume(M),U):M===63&&o===3?(e.consume(M),A):M===93&&o===5?(e.consume(M),Z):Le(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(nz,V,ue)(M)):M===null||Le(M)?(e.exit("htmlFlowData"),ue(M)):(e.consume(M),K)}function ue(M){return e.check(rz,le,V)(M)}function le(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),W}function W(M){return M===null||Le(M)?ue(M):(e.enter("htmlFlowData"),K(M))}function B(M){return M===45?(e.consume(M),A):K(M)}function F(M){return M===47?(e.consume(M),d="",ae):K(M)}function ae(M){if(M===62){const se=d.toLowerCase();return c0.includes(se)?(e.consume(M),U):K(M)}return Cn(M)&&d.length<8?(e.consume(M),d+=String.fromCharCode(M),ae):K(M)}function Z(M){return M===93?(e.consume(M),A):K(M)}function A(M){return M===62?(e.consume(M),U):M===45&&o===2?(e.consume(M),A):K(M)}function U(M){return M===null||Le(M)?(e.exit("htmlFlowData"),V(M)):(e.consume(M),U)}function V(M){return e.exit("htmlFlow"),r(M)}}function iz(e,r,a){const l=this;return o;function o(d){return Le(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):a(d)}function c(d){return l.parser.lazy[l.now().line]?a(d):r(d)}}function sz(e,r,a){return l;function l(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(jo,r,a)}}const oz={name:"htmlText",tokenize:uz};function uz(e,r,a){const l=this;let o,c,d;return f;function f(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),h}function h(A){return A===33?(e.consume(A),m):A===47?(e.consume(A),O):A===63?(e.consume(A),D):Cn(A)?(e.consume(A),z):a(A)}function m(A){return A===45?(e.consume(A),x):A===91?(e.consume(A),c=0,k):Cn(A)?(e.consume(A),R):a(A)}function x(A){return A===45?(e.consume(A),y):a(A)}function v(A){return A===null?a(A):A===45?(e.consume(A),b):Le(A)?(d=v,F(A)):(e.consume(A),v)}function b(A){return A===45?(e.consume(A),y):v(A)}function y(A){return A===62?B(A):A===45?b(A):v(A)}function k(A){const U="CDATA[";return A===U.charCodeAt(c++)?(e.consume(A),c===U.length?j:k):a(A)}function j(A){return A===null?a(A):A===93?(e.consume(A),T):Le(A)?(d=j,F(A)):(e.consume(A),j)}function T(A){return A===93?(e.consume(A),N):j(A)}function N(A){return A===62?B(A):A===93?(e.consume(A),N):j(A)}function R(A){return A===null||A===62?B(A):Le(A)?(d=R,F(A)):(e.consume(A),R)}function D(A){return A===null?a(A):A===63?(e.consume(A),I):Le(A)?(d=D,F(A)):(e.consume(A),D)}function I(A){return A===62?B(A):D(A)}function O(A){return Cn(A)?(e.consume(A),E):a(A)}function E(A){return A===45||wn(A)?(e.consume(A),E):C(A)}function C(A){return Le(A)?(d=C,F(A)):nt(A)?(e.consume(A),C):B(A)}function z(A){return A===45||wn(A)?(e.consume(A),z):A===47||A===62||Ct(A)?Y(A):a(A)}function Y(A){return A===47?(e.consume(A),B):A===58||A===95||Cn(A)?(e.consume(A),q):Le(A)?(d=Y,F(A)):nt(A)?(e.consume(A),Y):B(A)}function q(A){return A===45||A===46||A===58||A===95||wn(A)?(e.consume(A),q):P(A)}function P(A){return A===61?(e.consume(A),K):Le(A)?(d=P,F(A)):nt(A)?(e.consume(A),P):Y(A)}function K(A){return A===null||A===60||A===61||A===62||A===96?a(A):A===34||A===39?(e.consume(A),o=A,ue):Le(A)?(d=K,F(A)):nt(A)?(e.consume(A),K):(e.consume(A),le)}function ue(A){return A===o?(e.consume(A),o=void 0,W):A===null?a(A):Le(A)?(d=ue,F(A)):(e.consume(A),ue)}function le(A){return A===null||A===34||A===39||A===60||A===61||A===96?a(A):A===47||A===62||Ct(A)?Y(A):(e.consume(A),le)}function W(A){return A===47||A===62||Ct(A)?Y(A):a(A)}function B(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),r):a(A)}function F(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),ae}function ae(A){return nt(A)?ot(e,Z,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):Z(A)}function Z(A){return e.enter("htmlTextData"),d(A)}}const Ap={name:"labelEnd",resolveAll:hz,resolveTo:mz,tokenize:pz},cz={tokenize:gz},dz={tokenize:xz},fz={tokenize:vz};function hz(e){let r=-1;const a=[];for(;++r=3&&(m===null||Le(m))?(e.exit("thematicBreak"),r(m)):a(m)}function h(m){return m===o?(e.consume(m),l++,h):(e.exit("thematicBreakSequence"),nt(m)?ot(e,f,"whitespace")(m):f(m))}}const Un={continuation:{tokenize:Tz},exit:_z,name:"list",tokenize:Ez},Cz={partial:!0,tokenize:Mz},Nz={partial:!0,tokenize:Az};function Ez(e,r,a){const l=this,o=l.events[l.events.length-1];let c=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return f;function f(y){const k=l.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!l.containerState.marker||y===l.containerState.marker:Rm(y)){if(l.containerState.type||(l.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(ic,a,m)(y):m(y);if(!l.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(y)}return a(y)}function h(y){return Rm(y)&&++d<10?(e.consume(y),h):(!l.interrupt||d<2)&&(l.containerState.marker?y===l.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),m(y)):a(y)}function m(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||y,e.check(jo,l.interrupt?a:x,e.attempt(Cz,b,v))}function x(y){return l.containerState.initialBlankLine=!0,c++,b(y)}function v(y){return nt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):a(y)}function b(y){return l.containerState.size=c+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(y)}}function Tz(e,r,a){const l=this;return l.containerState._closeFlow=void 0,e.check(jo,o,c);function o(f){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,ot(e,r,"listItemIndent",l.containerState.size+1)(f)}function c(f){return l.containerState.furtherBlankLines||!nt(f)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,d(f)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(Nz,r,d)(f))}function d(f){return l.containerState._closeFlow=!0,l.interrupt=void 0,ot(e,e.attempt(Un,r,a),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function Az(e,r,a){const l=this;return ot(e,o,"listItemIndent",l.containerState.size+1);function o(c){const d=l.events[l.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===l.containerState.size?r(c):a(c)}}function _z(e){e.exit(this.containerState.type)}function Mz(e,r,a){const l=this;return ot(e,o,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const d=l.events[l.events.length-1];return!nt(c)&&d&&d[1].type==="listItemPrefixWhitespace"?r(c):a(c)}}const d0={name:"setextUnderline",resolveTo:Rz,tokenize:Dz};function Rz(e,r){let a=e.length,l,o,c;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){l=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!c&&e[a][1].type==="definition"&&(c=a);const d={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",d,r]),e.splice(c+1,0,["exit",e[l][1],r]),e[l][1].end={...e[c][1].end}):e[l][1]=d,e.push(["exit",d,r]),e}function Dz(e,r,a){const l=this;let o;return c;function c(m){let x=l.events.length,v;for(;x--;)if(l.events[x][1].type!=="lineEnding"&&l.events[x][1].type!=="linePrefix"&&l.events[x][1].type!=="content"){v=l.events[x][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||v)?(e.enter("setextHeadingLine"),o=m,d(m)):a(m)}function d(m){return e.enter("setextHeadingLineSequence"),f(m)}function f(m){return m===o?(e.consume(m),f):(e.exit("setextHeadingLineSequence"),nt(m)?ot(e,h,"lineSuffix")(m):h(m))}function h(m){return m===null||Le(m)?(e.exit("setextHeadingLine"),r(m)):a(m)}}const Oz={tokenize:zz};function zz(e){const r=this,a=e.attempt(jo,l,e.attempt(this.parser.constructs.flowInitial,o,ot(e,e.attempt(this.parser.constructs.flow,o,e.attempt(qO,o)),"linePrefix")));return a;function l(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),r.currentConstruct=void 0,a}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),r.currentConstruct=void 0,a}}const Lz={resolveAll:ij()},Uz=lj("string"),Bz=lj("text");function lj(e){return{resolveAll:ij(e==="text"?Iz:void 0),tokenize:r};function r(a){const l=this,o=this.parser.constructs[e],c=a.attempt(o,d,f);return d;function d(x){return m(x)?c(x):f(x)}function f(x){if(x===null){a.consume(x);return}return a.enter("data"),a.consume(x),h}function h(x){return m(x)?(a.exit("data"),c(x)):(a.consume(x),h)}function m(x){if(x===null)return!0;const v=o[x];let b=-1;if(v)for(;++b-1){const f=d[0];typeof f=="string"?d[0]=f.slice(l):d.shift()}c>0&&d.push(e[o].slice(0,c))}return d}function Jz(e,r){let a=-1;const l=[];let o;for(;++a0){const an=he.tokenStack[he.tokenStack.length-1];(an[1]||h0).call(he,void 0,an[0])}for(L.position={start:Ka(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:Ka(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},ze=-1;++ze0&&(l.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:l,children:[{type:"text",value:a}]};return r.meta&&(c.data={meta:r.meta}),e.patch(r,c),c=e.applyData(r,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(r,c),c}function f4(e,r){const a={type:"element",tagName:"del",properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function h4(e,r){const a={type:"element",tagName:"em",properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function m4(e,r){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(r.identifier).toUpperCase(),o=rs(l.toLowerCase()),c=e.footnoteOrder.indexOf(l);let d,f=e.footnoteCounts.get(l);f===void 0?(f=0,e.footnoteOrder.push(l),d=e.footnoteOrder.length):d=c+1,f+=1,e.footnoteCounts.set(l,f);const h={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(r,h);const m={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(r,m),e.applyData(r,m)}function p4(e,r){const a={type:"element",tagName:"h"+r.depth,properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function g4(e,r){if(e.options.allowDangerousHtml){const a={type:"raw",value:r.value};return e.patch(r,a),e.applyData(r,a)}}function uj(e,r){const a=r.referenceType;let l="]";if(a==="collapsed"?l+="[]":a==="full"&&(l+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+l}];const o=e.all(r),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=l:o.push({type:"text",value:l}),o}function x4(e,r){const a=String(r.identifier).toUpperCase(),l=e.definitionById.get(a);if(!l)return uj(e,r);const o={src:rs(l.url||""),alt:r.alt};l.title!==null&&l.title!==void 0&&(o.title=l.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(r,c),e.applyData(r,c)}function v4(e,r){const a={src:rs(r.url)};r.alt!==null&&r.alt!==void 0&&(a.alt=r.alt),r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(r,l),e.applyData(r,l)}function y4(e,r){const a={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};e.patch(r,a);const l={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(r,l),e.applyData(r,l)}function b4(e,r){const a=String(r.identifier).toUpperCase(),l=e.definitionById.get(a);if(!l)return uj(e,r);const o={href:rs(l.url||"")};l.title!==null&&l.title!==void 0&&(o.title=l.title);const c={type:"element",tagName:"a",properties:o,children:e.all(r)};return e.patch(r,c),e.applyData(r,c)}function w4(e,r){const a={href:rs(r.url)};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"a",properties:a,children:e.all(r)};return e.patch(r,l),e.applyData(r,l)}function S4(e,r,a){const l=e.all(r),o=a?j4(a):cj(r),c={},d=[];if(typeof r.checked=="boolean"){const x=l[0];let v;x&&x.type==="element"&&x.tagName==="p"?v=x:(v={type:"element",tagName:"p",properties:{},children:[]},l.unshift(v)),v.children.length>0&&v.children.unshift({type:"text",value:" "}),v.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let f=-1;for(;++f1}function k4(e,r){const a={},l=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(a.start=r.start);++o0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},f=jp(r.children[1]),h=$S(r.children[r.children.length-1]);f&&h&&(d.position={start:f,end:h}),o.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,c),e.applyData(r,c)}function A4(e,r,a){const l=a?a.children:void 0,c=(l?l.indexOf(r):1)===0?"th":"td",d=a&&a.type==="table"?a.align:void 0,f=d?d.length:r.children.length;let h=-1;const m=[];for(;++h0,!0),l[0]),o=l.index+l[0].length,l=a.exec(r);return c.push(g0(r.slice(o),o>0,!1)),c.join("")}function g0(e,r,a){let l=0,o=e.length;if(r){let c=e.codePointAt(l);for(;c===m0||c===p0;)l++,c=e.codePointAt(l)}if(a){let c=e.codePointAt(o-1);for(;c===m0||c===p0;)o--,c=e.codePointAt(o-1)}return o>l?e.slice(l,o):""}function R4(e,r){const a={type:"text",value:M4(String(r.value))};return e.patch(r,a),e.applyData(r,a)}function D4(e,r){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,a),e.applyData(r,a)}const O4={blockquote:u4,break:c4,code:d4,delete:f4,emphasis:h4,footnoteReference:m4,heading:p4,html:g4,imageReference:x4,image:v4,inlineCode:y4,linkReference:b4,link:w4,listItem:S4,list:k4,paragraph:C4,root:N4,strong:E4,table:T4,tableCell:_4,tableRow:A4,text:R4,thematicBreak:D4,toml:Wu,yaml:Wu,definition:Wu,footnoteDefinition:Wu};function Wu(){}const dj=-1,Yc=0,uo=1,pc=2,_p=3,Mp=4,Rp=5,Dp=6,fj=7,hj=8,mj=typeof self=="object"?self:globalThis,x0=(e,r)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new mj[e](r)},z4=(e,r)=>{const a=(o,c)=>(e.set(c,o),o),l=o=>{if(e.has(o))return e.get(o);const[c,d]=r[o];switch(c){case Yc:case dj:return a(d,o);case uo:{const f=a([],o);for(const h of d)f.push(l(h));return f}case pc:{const f=a({},o);for(const[h,m]of d)f[l(h)]=l(m);return f}case _p:return a(new Date(d),o);case Mp:{const{source:f,flags:h}=d;return a(new RegExp(f,h),o)}case Rp:{const f=a(new Map,o);for(const[h,m]of d)f.set(l(h),l(m));return f}case Dp:{const f=a(new Set,o);for(const h of d)f.add(l(h));return f}case fj:{const{name:f,message:h}=d;return a(typeof mj[f]=="function"?x0(f,h):new Error(h),o)}case hj:return a(BigInt(d),o);case"BigInt":return a(Object(BigInt(d)),o);case"ArrayBuffer":return a(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:f}=new Uint8Array(d);return a(new DataView(f),d)}}return a(x0(c,d),o)};return l},v0=e=>z4(new Map,e)(0),Pl="",{toString:L4}={},{keys:U4}=Object,eo=e=>{const r=typeof e;if(r!=="object"||!e)return[Yc,r];const a=L4.call(e).slice(8,-1);switch(a){case"Array":return[uo,Pl];case"Object":return[pc,Pl];case"Date":return[_p,Pl];case"RegExp":return[Mp,Pl];case"Map":return[Rp,Pl];case"Set":return[Dp,Pl];case"DataView":return[uo,a]}return a.includes("Array")?[uo,a]:e instanceof Error?[fj,e.name||"Error"]:[pc,a]},ec=([e,r])=>e===Yc&&(r==="function"||r==="symbol"),B4=(e,r,a,l)=>{const o=(d,f)=>{const h=l.push(d)-1;return a.set(f,h),h},c=d=>{if(a.has(d))return a.get(d);let[f,h]=eo(d);switch(f){case Yc:{let x=d;switch(h){case"bigint":f=hj,x=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);x=null;break;case"undefined":return o([dj],d)}return o([f,x],d)}case uo:{if(h){let b=d;return h==="DataView"?b=new Uint8Array(d.buffer):h==="ArrayBuffer"&&(b=new Uint8Array(d)),o([h,[...b]],d)}const x=[],v=o([f,x],d);for(const b of d)x.push(c(b));return v}case pc:{if(h)switch(h){case"BigInt":return o([h,d.toString()],d);case"Boolean":case"Number":case"String":return o([h,d.valueOf()],d)}if(r&&"toJSON"in d)return c(d.toJSON());const x=[],v=o([f,x],d);for(const b of U4(d))(e||!ec(eo(d[b])))&&x.push([c(b),c(d[b])]);return v}case _p:return o([f,isNaN(d.getTime())?Pl:d.toISOString()],d);case Mp:{const{source:x,flags:v}=d;return o([f,{source:x,flags:v}],d)}case Rp:{const x=[],v=o([f,x],d);for(const[b,y]of d)(e||!(ec(eo(b))||ec(eo(y))))&&x.push([c(b),c(y)]);return v}case Dp:{const x=[],v=o([f,x],d);for(const b of d)(e||!ec(eo(b)))&&x.push(c(b));return v}}const{message:m}=d;return o([f,{name:h,message:m}],d)};return c},y0=(e,{json:r,lossy:a}={})=>{const l=[];return B4(!(r||a),!!r,new Map,l)(e),l},gc=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?v0(y0(e,r)):structuredClone(e):(e,r)=>v0(y0(e,r));function I4(e,r){const a=[{type:"text",value:"↩"}];return r>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),a}function q4(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function H4(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||I4,l=e.options.footnoteBackLabel||q4,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let h=-1;for(;++h0&&k.push({type:"text",value:" "});let R=typeof a=="string"?a:a(h,y);typeof R=="string"&&(R={type:"text",value:R}),k.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(h,y),className:["data-footnote-backref"]},children:Array.isArray(R)?R:[R]})}const T=x[x.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const R=T.children[T.children.length-1];R&&R.type==="text"?R.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...k)}else x.push(...k);const N={type:"element",tagName:"li",properties:{id:r+"fn-"+b},children:e.wrap(x,!0)};e.patch(m,N),f.push(N)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...gc(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:` +`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` +`}]}}const Xc=(function(e){if(e==null)return V4;if(typeof e=="function")return Kc(e);if(typeof e=="object")return Array.isArray(e)?P4(e):$4(e);if(typeof e=="string")return F4(e);throw new Error("Expected function, string, or object as test")});function P4(e){const r=[];let a=-1;for(;++a":""))+")"})}return b;function b(){let y=pj,k,j,T;if((!r||c(h,m,x[x.length-1]||void 0))&&(y=K4(a(h,x)),y[0]===Om))return y;if("children"in h&&h.children){const N=h;if(N.children&&y[0]!==X4)for(j=(l?N.children.length:-1)+d,T=x.concat(N);j>-1&&j0&&a.push({type:"text",value:` +`}),a}function b0(e){let r=0,a=e.charCodeAt(r);for(;a===9||a===32;)r++,a=e.charCodeAt(r);return e.slice(r)}function w0(e,r){const a=Z4(e,r),l=a.one(e,void 0),o=H4(a),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&c.children.push({type:"text",value:` +`},o),c}function n3(e,r){return e&&"run"in e?async function(a,l){const o=w0(a,{file:l,...r});await e.run(o,l)}:function(a,l){return w0(a,{file:l,...e||r})}}function S0(e){if(e)throw e}var Kh,j0;function r3(){if(j0)return Kh;j0=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,o=function(m){return typeof Array.isArray=="function"?Array.isArray(m):r.call(m)==="[object Array]"},c=function(m){if(!m||r.call(m)!=="[object Object]")return!1;var x=e.call(m,"constructor"),v=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!x&&!v)return!1;var b;for(b in m);return typeof b>"u"||e.call(m,b)},d=function(m,x){a&&x.name==="__proto__"?a(m,x.name,{enumerable:!0,configurable:!0,value:x.newValue,writable:!0}):m[x.name]=x.newValue},f=function(m,x){if(x==="__proto__")if(e.call(m,x)){if(l)return l(m,x).value}else return;return m[x]};return Kh=function h(){var m,x,v,b,y,k,j=arguments[0],T=1,N=arguments.length,R=!1;for(typeof j=="boolean"&&(R=j,j=arguments[1]||{},T=2),(j==null||typeof j!="object"&&typeof j!="function")&&(j={});Td.length;let h;f&&d.push(o);try{h=e.apply(this,d)}catch(m){const x=m;if(f&&a)throw x;return o(x)}f||(h&&h.then&&typeof h.then=="function"?h.then(c,o):h instanceof Error?o(h):c(h))}function o(d,...f){a||(a=!0,r(d,...f))}function c(d){o(null,d)}}const Br={basename:s3,dirname:o3,extname:u3,join:c3,sep:"/"};function s3(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');ko(e);let a=0,l=-1,o=e.length,c;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else l<0&&(c=!0,l=o+1);return l<0?"":e.slice(a,l)}if(r===e)return"";let d=-1,f=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else d<0&&(c=!0,d=o+1),f>-1&&(e.codePointAt(o)===r.codePointAt(f--)?f<0&&(l=o):(f=-1,l=d));return a===l?l=d:l<0&&(l=e.length),e.slice(a,l)}function o3(e){if(ko(e),e.length===0)return".";let r=-1,a=e.length,l;for(;--a;)if(e.codePointAt(a)===47){if(l){r=a;break}}else l||(l=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function u3(e){ko(e);let r=e.length,a=-1,l=0,o=-1,c=0,d;for(;r--;){const f=e.codePointAt(r);if(f===47){if(d){l=r+1;break}continue}a<0&&(d=!0,a=r+1),f===46?o<0?o=r:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||a<0||c===0||c===1&&o===a-1&&o===l+1?"":e.slice(o,a)}function c3(...e){let r=-1,a;for(;++r0&&e.codePointAt(e.length-1)===47&&(a+="/"),r?"/"+a:a}function f3(e,r){let a="",l=0,o=-1,c=0,d=-1,f,h;for(;++d<=e.length;){if(d2){if(h=a.lastIndexOf("/"),h!==a.length-1){h<0?(a="",l=0):(a=a.slice(0,h),l=a.length-1-a.lastIndexOf("/")),o=d,c=0;continue}}else if(a.length>0){a="",l=0,o=d,c=0;continue}}r&&(a=a.length>0?a+"/..":"..",l=2)}else a.length>0?a+="/"+e.slice(o+1,d):a=e.slice(o+1,d),l=d-o-1;o=d,c=0}else f===46&&c>-1?c++:c=-1}return a}function ko(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const h3={cwd:m3};function m3(){return"/"}function Um(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function p3(e){if(typeof e=="string")e=new URL(e);else if(!Um(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return g3(e)}function g3(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const r=e.pathname;let a=-1;for(;++a0){let[y,...k]=x;const j=l[b][1];Lm(j)&&Lm(y)&&(y=Qh(!0,j,y)),l[b]=[m,y,...k]}}}}const b3=new zp().freeze();function em(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function tm(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nm(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function C0(e){if(!Lm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function N0(e,r,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function tc(e){return w3(e)?e:new xj(e)}function w3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function S3(e){return typeof e=="string"||j3(e)}function j3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const k3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",E0=[],T0={allowDangerousHtml:!0},C3=/^(https?|ircs?|mailto|xmpp)$/i,N3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function E3(e){const r=T3(e),a=A3(e);return _3(r.runSync(r.parse(a),a),e)}function T3(e){const r=e.rehypePlugins||E0,a=e.remarkPlugins||E0,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...T0}:T0;return b3().use(o4).use(a).use(n3,l).use(r)}function A3(e){const r=e.children||"",a=new xj;return typeof r=="string"&&(a.value=r),a}function _3(e,r){const a=r.allowedElements,l=r.allowElement,o=r.components,c=r.disallowedElements,d=r.skipHtml,f=r.unwrapDisallowed,h=r.urlTransform||M3;for(const x of N3)Object.hasOwn(r,x.from)&&(""+x.from+(x.to?"use `"+x.to+"` instead":"remove it")+k3+x.id,void 0);return Op(e,m),VD(e,{Fragment:s.Fragment,components:o,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function m(x,v,b){if(x.type==="raw"&&b&&typeof v=="number")return d?b.children.splice(v,1):b.children[v]={type:"text",value:x.value},v;if(x.type==="element"){let y;for(y in Gh)if(Object.hasOwn(Gh,y)&&Object.hasOwn(x.properties,y)){const k=x.properties[y],j=Gh[y];(j===null||j.includes(x.tagName))&&(x.properties[y]=h(String(k||""),y,x))}}if(x.type==="element"){let y=a?!a.includes(x.tagName):c?c.includes(x.tagName):!1;if(!y&&l&&typeof v=="number"&&(y=!l(x,v,b)),y&&b&&typeof v=="number")return f&&x.children?b.children.splice(v,1,...x.children):b.children.splice(v,1),v}}}function M3(e){const r=e.indexOf(":"),a=e.indexOf("?"),l=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||a!==-1&&r>a||l!==-1&&r>l||C3.test(e.slice(0,r))?e:""}function R3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function vj(e,r,a){const o=Xc((a||{}).ignore||[]),c=D3(r);let d=-1;for(;++d0?{type:"text",value:E}:void 0),E===!1?b.lastIndex=I+1:(k!==I&&R.push({type:"text",value:m.value.slice(k,I)}),Array.isArray(E)?R.push(...E):E&&R.push(E),k=I+D[0].length,N=!0),!b.global)break;D=b.exec(m.value)}return N?(k?\]}]+$/.exec(e);if(!r)return[e,void 0];e=e.slice(0,r.index);let a=r[0],l=a.indexOf(")");const o=A0(e,"(");let c=A0(e,")");for(;l!==-1&&o>c;)e+=a.slice(0,l+1),a=a.slice(l+1),l=a.indexOf(")"),c++;return[e,a]}function yj(e,r){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Kl(a)||Vc(a))&&(!r||a!==47)}bj.peek=l5;function Z3(){this.buffer()}function J3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function W3(){this.buffer()}function e5(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function t5(e){const r=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=wr(this.sliceSerialize(e)).toLowerCase(),a.label=r}function n5(e){this.exit(e)}function r5(e){const r=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=wr(this.sliceSerialize(e)).toLowerCase(),a.label=r}function a5(e){this.exit(e)}function l5(){return"["}function bj(e,r,a,l){const o=a.createTracker(l);let c=o.move("[^");const d=a.enter("footnoteReference"),f=a.enter("reference");return c+=o.move(a.safe(a.associationId(e),{after:"]",before:c})),f(),d(),c+=o.move("]"),c}function i5(){return{enter:{gfmFootnoteCallString:Z3,gfmFootnoteCall:J3,gfmFootnoteDefinitionLabelString:W3,gfmFootnoteDefinition:e5},exit:{gfmFootnoteCallString:t5,gfmFootnoteCall:n5,gfmFootnoteDefinitionLabelString:r5,gfmFootnoteDefinition:a5}}}function s5(e){let r=!1;return e&&e.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:a,footnoteReference:bj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(l,o,c,d){const f=c.createTracker(d);let h=f.move("[^");const m=c.enter("footnoteDefinition"),x=c.enter("label");return h+=f.move(c.safe(c.associationId(l),{before:h,after:"]"})),x(),h+=f.move("]:"),l.children&&l.children.length>0&&(f.shift(4),h+=f.move((r?` +`:" ")+c.indentLines(c.containerFlow(l,f.current()),r?wj:o5))),m(),h}}function o5(e,r,a){return r===0?e:wj(e,r,a)}function wj(e,r,a){return(a?"":" ")+e}const u5=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Sj.peek=m5;function c5(){return{canContainEols:["delete"],enter:{strikethrough:f5},exit:{strikethrough:h5}}}function d5(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:u5}],handlers:{delete:Sj}}}function f5(e){this.enter({type:"delete",children:[]},e)}function h5(e){this.exit(e)}function Sj(e,r,a,l){const o=a.createTracker(l),c=a.enter("strikethrough");let d=o.move("~~");return d+=a.containerPhrasing(e,{...o.current(),before:d,after:"~"}),d+=o.move("~~"),c(),d}function m5(){return"~"}function p5(e){return e.length}function g5(e,r){const a=r||{},l=(a.align||[]).concat(),o=a.stringLength||p5,c=[],d=[],f=[],h=[];let m=0,x=-1;for(;++xm&&(m=e[x].length);++Nh[N])&&(h[N]=D)}j.push(R)}d[x]=j,f[x]=T}let v=-1;if(typeof l=="object"&&"length"in l)for(;++vh[v]&&(h[v]=R),y[v]=R),b[v]=D}d.splice(1,0,b),f.splice(1,0,y),x=-1;const k=[];for(;++x "),c.shift(2);const d=a.indentLines(a.containerFlow(e,c.current()),y5);return o(),d}function y5(e,r,a){return">"+(a?"":" ")+e}function b5(e,r){return M0(e,r.inConstruct,!0)&&!M0(e,r.notInConstruct,!1)}function M0(e,r,a){if(typeof r=="string"&&(r=[r]),!r||r.length===0)return a;let l=-1;for(;++ld&&(d=c):c=1,o=l+r.length,l=a.indexOf(r,o);return d}function S5(e,r){return!!(r.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function j5(e){const r=e.options.fence||"`";if(r!=="`"&&r!=="~")throw new Error("Cannot serialize code with `"+r+"` for `options.fence`, expected `` ` `` or `~`");return r}function k5(e,r,a,l){const o=j5(a),c=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(S5(e,a)){const v=a.enter("codeIndented"),b=a.indentLines(c,C5);return v(),b}const f=a.createTracker(l),h=o.repeat(Math.max(w5(c,o)+1,3)),m=a.enter("codeFenced");let x=f.move(h);if(e.lang){const v=a.enter(`codeFencedLang${d}`);x+=f.move(a.safe(e.lang,{before:x,after:" ",encode:["`"],...f.current()})),v()}if(e.lang&&e.meta){const v=a.enter(`codeFencedMeta${d}`);x+=f.move(" "),x+=f.move(a.safe(e.meta,{before:x,after:` +`,encode:["`"],...f.current()})),v()}return x+=f.move(` +`),c&&(x+=f.move(c+` +`)),x+=f.move(h),m(),x}function C5(e,r,a){return(a?"":" ")+e}function Lp(e){const r=e.options.quote||'"';if(r!=='"'&&r!=="'")throw new Error("Cannot serialize title with `"+r+"` for `options.quote`, expected `\"`, or `'`");return r}function N5(e,r,a,l){const o=Lp(a),c=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let f=a.enter("label");const h=a.createTracker(l);let m=h.move("[");return m+=h.move(a.safe(a.associationId(e),{before:m,after:"]",...h.current()})),m+=h.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(a.safe(e.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(f=a.enter("destinationRaw"),m+=h.move(a.safe(e.url,{before:m,after:e.title?" ":` +`,...h.current()}))),f(),e.title&&(f=a.enter(`title${c}`),m+=h.move(" "+o),m+=h.move(a.safe(e.title,{before:m,after:o,...h.current()})),m+=h.move(o),f()),d(),m}function E5(e){const r=e.options.emphasis||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize emphasis with `"+r+"` for `options.emphasis`, expected `*`, or `_`");return r}function go(e){return"&#x"+e.toString(16).toUpperCase()+";"}function xc(e,r,a){const l=Zi(e),o=Zi(r);return l===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}jj.peek=T5;function jj(e,r,a,l){const o=E5(a),c=a.enter("emphasis"),d=a.createTracker(l),f=d.move(o);let h=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const m=h.charCodeAt(0),x=xc(l.before.charCodeAt(l.before.length-1),m,o);x.inside&&(h=go(m)+h.slice(1));const v=h.charCodeAt(h.length-1),b=xc(l.after.charCodeAt(0),v,o);b.inside&&(h=h.slice(0,-1)+go(v));const y=d.move(o);return c(),a.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},f+h+y}function T5(e,r,a){return a.options.emphasis||"*"}function A5(e,r){let a=!1;return Op(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return a=!0,Om}),!!((!e.depth||e.depth<3)&&Ep(e)&&(r.options.setext||a))}function _5(e,r,a,l){const o=Math.max(Math.min(6,e.depth||1),1),c=a.createTracker(l);if(A5(e,a)){const x=a.enter("headingSetext"),v=a.enter("phrasing"),b=a.containerPhrasing(e,{...c.current(),before:` +`,after:` +`});return v(),x(),b+` +`+(o===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` +`))+1))}const d="#".repeat(o),f=a.enter("headingAtx"),h=a.enter("phrasing");c.move(d+" ");let m=a.containerPhrasing(e,{before:"# ",after:` +`,...c.current()});return/^[\t ]/.test(m)&&(m=go(m.charCodeAt(0))+m.slice(1)),m=m?d+" "+m:d,a.options.closeAtx&&(m+=" "+d),h(),f(),m}kj.peek=M5;function kj(e){return e.value||""}function M5(){return"<"}Cj.peek=R5;function Cj(e,r,a,l){const o=Lp(a),c=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let f=a.enter("label");const h=a.createTracker(l);let m=h.move("![");return m+=h.move(a.safe(e.alt,{before:m,after:"]",...h.current()})),m+=h.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(a.safe(e.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(f=a.enter("destinationRaw"),m+=h.move(a.safe(e.url,{before:m,after:e.title?" ":")",...h.current()}))),f(),e.title&&(f=a.enter(`title${c}`),m+=h.move(" "+o),m+=h.move(a.safe(e.title,{before:m,after:o,...h.current()})),m+=h.move(o),f()),m+=h.move(")"),d(),m}function R5(){return"!"}Nj.peek=D5;function Nj(e,r,a,l){const o=e.referenceType,c=a.enter("imageReference");let d=a.enter("label");const f=a.createTracker(l);let h=f.move("![");const m=a.safe(e.alt,{before:h,after:"]",...f.current()});h+=f.move(m+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const v=a.safe(a.associationId(e),{before:h,after:"]",...f.current()});return d(),a.stack=x,c(),o==="full"||!m||m!==v?h+=f.move(v+"]"):o==="shortcut"?h=h.slice(0,-1):h+=f.move("]"),h}function D5(){return"!"}Ej.peek=O5;function Ej(e,r,a){let l=e.value||"",o="`",c=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++c\u007F]/.test(e.url))}Aj.peek=z5;function Aj(e,r,a,l){const o=Lp(a),c=o==='"'?"Quote":"Apostrophe",d=a.createTracker(l);let f,h;if(Tj(e,a)){const x=a.stack;a.stack=[],f=a.enter("autolink");let v=d.move("<");return v+=d.move(a.containerPhrasing(e,{before:v,after:">",...d.current()})),v+=d.move(">"),f(),a.stack=x,v}f=a.enter("link"),h=a.enter("label");let m=d.move("[");return m+=d.move(a.containerPhrasing(e,{before:m,after:"](",...d.current()})),m+=d.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(a.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(h=a.enter("destinationRaw"),m+=d.move(a.safe(e.url,{before:m,after:e.title?" ":")",...d.current()}))),h(),e.title&&(h=a.enter(`title${c}`),m+=d.move(" "+o),m+=d.move(a.safe(e.title,{before:m,after:o,...d.current()})),m+=d.move(o),h()),m+=d.move(")"),f(),m}function z5(e,r,a){return Tj(e,a)?"<":"["}_j.peek=L5;function _j(e,r,a,l){const o=e.referenceType,c=a.enter("linkReference");let d=a.enter("label");const f=a.createTracker(l);let h=f.move("[");const m=a.containerPhrasing(e,{before:h,after:"]",...f.current()});h+=f.move(m+"]["),d();const x=a.stack;a.stack=[],d=a.enter("reference");const v=a.safe(a.associationId(e),{before:h,after:"]",...f.current()});return d(),a.stack=x,c(),o==="full"||!m||m!==v?h+=f.move(v+"]"):o==="shortcut"?h=h.slice(0,-1):h+=f.move("]"),h}function L5(){return"["}function Up(e){const r=e.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function U5(e){const r=Up(e),a=e.options.bulletOther;if(!a)return r==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+a+"`) to be different");return a}function B5(e){const r=e.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function Mj(e){const r=e.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function I5(e,r,a,l){const o=a.enter("list"),c=a.bulletCurrent;let d=e.ordered?B5(a):Up(a);const f=e.ordered?d==="."?")":".":U5(a);let h=r&&a.bulletLastUsed?d===a.bulletLastUsed:!1;if(!e.ordered){const x=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&x&&(!x.children||!x.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(h=!0),Mj(a)===d&&x){let v=-1;for(;++v-1?r.start:1)+(a.options.incrementListMarker===!1?0:r.children.indexOf(e))+c);let d=c.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||e.spread))&&(d=Math.ceil(d/4)*4);const f=a.createTracker(l);f.move(c+" ".repeat(d-c.length)),f.shift(d);const h=a.enter("listItem"),m=a.indentLines(a.containerFlow(e,f.current()),x);return h(),m;function x(v,b,y){return b?(y?"":" ".repeat(d))+v:(y?c:c+" ".repeat(d-c.length))+v}}function P5(e,r,a,l){const o=a.enter("paragraph"),c=a.enter("phrasing"),d=a.containerPhrasing(e,l);return c(),o(),d}const $5=Xc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function F5(e,r,a,l){return(e.children.some(function(d){return $5(d)})?a.containerPhrasing:a.containerFlow).call(a,e,l)}function V5(e){const r=e.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}Rj.peek=G5;function Rj(e,r,a,l){const o=V5(a),c=a.enter("strong"),d=a.createTracker(l),f=d.move(o+o);let h=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const m=h.charCodeAt(0),x=xc(l.before.charCodeAt(l.before.length-1),m,o);x.inside&&(h=go(m)+h.slice(1));const v=h.charCodeAt(h.length-1),b=xc(l.after.charCodeAt(0),v,o);b.inside&&(h=h.slice(0,-1)+go(v));const y=d.move(o+o);return c(),a.attentionEncodeSurroundingInfo={after:b.outside,before:x.outside},f+h+y}function G5(e,r,a){return a.options.strong||"*"}function Y5(e,r,a,l){return a.safe(e.value,l)}function X5(e){const r=e.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function K5(e,r,a){const l=(Mj(a)+(a.options.ruleSpaces?" ":"")).repeat(X5(a));return a.options.ruleSpaces?l.slice(0,-1):l}const Dj={blockquote:v5,break:R0,code:k5,definition:N5,emphasis:jj,hardBreak:R0,heading:_5,html:kj,image:Cj,imageReference:Nj,inlineCode:Ej,link:Aj,linkReference:_j,list:I5,listItem:H5,paragraph:P5,root:F5,strong:Rj,text:Y5,thematicBreak:K5};function Q5(){return{enter:{table:Z5,tableData:D0,tableHeader:D0,tableRow:W5},exit:{codeText:e6,table:J5,tableData:im,tableHeader:im,tableRow:im}}}function Z5(e){const r=e._align;this.enter({type:"table",align:r.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function J5(e){this.exit(e),this.data.inTable=void 0}function W5(e){this.enter({type:"tableRow",children:[]},e)}function im(e){this.exit(e)}function D0(e){this.enter({type:"tableCell",children:[]},e)}function e6(e){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,t6));const a=this.stack[this.stack.length-1];a.type,a.value=r,this.exit(e)}function t6(e,r){return r==="|"?r:e}function n6(e){const r=e||{},a=r.tableCellPadding,l=r.tablePipeAlign,o=r.stringLength,c=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` +`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:d,tableCell:h,tableRow:f}};function d(y,k,j,T){return m(x(y,j,T),y.align)}function f(y,k,j,T){const N=v(y,j,T),R=m([N]);return R.slice(0,R.indexOf(` +`))}function h(y,k,j,T){const N=j.enter("tableCell"),R=j.enter("phrasing"),D=j.containerPhrasing(y,{...T,before:c,after:c});return R(),N(),D}function m(y,k){return g5(y,{align:k,alignDelimiters:l,padding:a,stringLength:o})}function x(y,k,j){const T=y.children;let N=-1;const R=[],D=k.enter("table");for(;++N0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const b6={tokenize:T6,partial:!0};function w6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:C6,continuation:{tokenize:N6},exit:E6}},text:{91:{name:"gfmFootnoteCall",tokenize:k6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:S6,resolveTo:j6}}}}function S6(e,r,a){const l=this;let o=l.events.length;const c=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d;for(;o--;){const h=l.events[o][1];if(h.type==="labelImage"){d=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return f;function f(h){if(!d||!d._balanced)return a(h);const m=wr(l.sliceSerialize({start:d.end,end:l.now()}));return m.codePointAt(0)!==94||!c.includes(m.slice(1))?a(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),r(h))}}function j6(e,r){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},f=[e[a+1],e[a+2],["enter",l,r],e[a+3],e[a+4],["enter",o,r],["exit",o,r],["enter",c,r],["enter",d,r],["exit",d,r],["exit",c,r],e[e.length-2],e[e.length-1],["exit",l,r]];return e.splice(a,e.length-a+1,...f),e}function k6(e,r,a){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c=0,d;return f;function f(v){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(v),e.exit("gfmFootnoteCallLabelMarker"),h}function h(v){return v!==94?a(v):(e.enter("gfmFootnoteCallMarker"),e.consume(v),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",m)}function m(v){if(c>999||v===93&&!d||v===null||v===91||Ct(v))return a(v);if(v===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return o.includes(wr(l.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(v),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):a(v)}return Ct(v)||(d=!0),c++,e.consume(v),v===92?x:m}function x(v){return v===91||v===92||v===93?(e.consume(v),c++,m):m(v)}}function C6(e,r,a){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c,d=0,f;return h;function h(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",x):a(k)}function x(k){if(d>999||k===93&&!f||k===null||k===91||Ct(k))return a(k);if(k===93){e.exit("chunkString");const j=e.exit("gfmFootnoteDefinitionLabelString");return c=wr(l.sliceSerialize(j)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Ct(k)||(f=!0),d++,e.consume(k),k===92?v:x}function v(k){return k===91||k===92||k===93?(e.consume(k),d++,x):x(k)}function b(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),o.includes(c)||o.push(c),ot(e,y,"gfmFootnoteDefinitionWhitespace")):a(k)}function y(k){return r(k)}}function N6(e,r,a){return e.check(jo,r,e.attempt(b6,r,a))}function E6(e){e.exit("gfmFootnoteDefinition")}function T6(e,r,a){const l=this;return ot(e,o,"gfmFootnoteDefinitionIndent",5);function o(c){const d=l.events[l.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?r(c):a(c)}}function A6(e){let a=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:c,resolveAll:o};return a==null&&(a=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(d,f){let h=-1;for(;++h1?h(k):(d.consume(k),v++,y);if(v<2&&!a)return h(k);const T=d.exit("strikethroughSequenceTemporary"),N=Zi(k);return T._open=!N||N===2&&!!j,T._close=!j||j===2&&!!N,f(k)}}}class _6{constructor(){this.map=[]}add(r,a,l){M6(this,r,a,l)}consume(r){if(this.map.sort(function(c,d){return c[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const l=[];for(;a>0;)a-=1,l.push(r.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),r.length=this.map[a][0];l.push(r.slice()),r.length=0;let o=l.pop();for(;o;){for(const c of o)r.push(c);o=l.pop()}this.map.length=0}}function M6(e,r,a,l){let o=0;if(!(a===0&&l.length===0)){for(;o-1;){const le=l.events[P][1].type;if(le==="lineEnding"||le==="linePrefix")P--;else break}const K=P>-1?l.events[P][1].type:null,ue=K==="tableHead"||K==="tableRow"?E:h;return ue===E&&l.parser.lazy[l.now().line]?a(q):ue(q)}function h(q){return e.enter("tableHead"),e.enter("tableRow"),m(q)}function m(q){return q===124||(d=!0,c+=1),x(q)}function x(q){return q===null?a(q):Le(q)?c>1?(c=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(q),e.exit("lineEnding"),y):a(q):nt(q)?ot(e,x,"whitespace")(q):(c+=1,d&&(d=!1,o+=1),q===124?(e.enter("tableCellDivider"),e.consume(q),e.exit("tableCellDivider"),d=!0,x):(e.enter("data"),v(q)))}function v(q){return q===null||q===124||Ct(q)?(e.exit("data"),x(q)):(e.consume(q),q===92?b:v)}function b(q){return q===92||q===124?(e.consume(q),v):v(q)}function y(q){return l.interrupt=!1,l.parser.lazy[l.now().line]?a(q):(e.enter("tableDelimiterRow"),d=!1,nt(q)?ot(e,k,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(q):k(q))}function k(q){return q===45||q===58?T(q):q===124?(d=!0,e.enter("tableCellDivider"),e.consume(q),e.exit("tableCellDivider"),j):O(q)}function j(q){return nt(q)?ot(e,T,"whitespace")(q):T(q)}function T(q){return q===58?(c+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(q),e.exit("tableDelimiterMarker"),N):q===45?(c+=1,N(q)):q===null||Le(q)?I(q):O(q)}function N(q){return q===45?(e.enter("tableDelimiterFiller"),R(q)):O(q)}function R(q){return q===45?(e.consume(q),R):q===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(q),e.exit("tableDelimiterMarker"),D):(e.exit("tableDelimiterFiller"),D(q))}function D(q){return nt(q)?ot(e,I,"whitespace")(q):I(q)}function I(q){return q===124?k(q):q===null||Le(q)?!d||o!==c?O(q):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(q)):O(q)}function O(q){return a(q)}function E(q){return e.enter("tableRow"),C(q)}function C(q){return q===124?(e.enter("tableCellDivider"),e.consume(q),e.exit("tableCellDivider"),C):q===null||Le(q)?(e.exit("tableRow"),r(q)):nt(q)?ot(e,C,"whitespace")(q):(e.enter("data"),z(q))}function z(q){return q===null||q===124||Ct(q)?(e.exit("data"),C(q)):(e.consume(q),q===92?Y:z)}function Y(q){return q===92||q===124?(e.consume(q),z):z(q)}}function z6(e,r){let a=-1,l=!0,o=0,c=[0,0,0,0],d=[0,0,0,0],f=!1,h=0,m,x,v;const b=new _6;for(;++aa[2]+1){const k=a[2]+1,j=a[3]-a[2]-1;e.add(k,j,[])}}e.add(a[3]+1,0,[["exit",v,r]])}return o!==void 0&&(c.end=Object.assign({},Gi(r.events,o)),e.add(o,0,[["exit",c,r]]),c=void 0),c}function z0(e,r,a,l,o){const c=[],d=Gi(r.events,a);o&&(o.end=Object.assign({},d),c.push(["exit",o,r])),l.end=Object.assign({},d),c.push(["exit",l,r]),e.add(a+1,0,c)}function Gi(e,r){const a=e[r],l=a[0]==="enter"?"start":"end";return a[1][l]}const L6={name:"tasklistCheck",tokenize:B6};function U6(){return{text:{91:L6}}}function B6(e,r,a){const l=this;return o;function o(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?a(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),c)}function c(h){return Ct(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),d):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),d):a(h)}function d(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(h)}function f(h){return Le(h)?r(h):nt(h)?e.check({tokenize:I6},r,a)(h):a(h)}}function I6(e,r,a){return ot(e,l,"whitespace");function l(o){return o===null?a(o):r(o)}}function q6(e){return QS([d6(),w6(),A6(e),D6(),U6()])}const H6={};function P6(e){const r=this,a=e||H6,l=r.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),c=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),d=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(q6(a)),c.push(s6()),d.push(o6(a))}const $6={a:({children:e,...r})=>s.jsx("a",{...r,target:"_blank",rel:"noopener noreferrer",children:e}),img:({alt:e})=>s.jsx("span",{className:"text-muted-foreground",children:e||"(image)"})};function F6({text:e,className:r}){return s.jsx("div",{className:Ne("chat-markdown",r),children:s.jsx(E3,{remarkPlugins:[P6,B3],components:$6,children:e})})}function V6({className:e,...r}){return s.jsx("textarea",{"data-slot":"textarea",className:Ne("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...r})}var Im=["Enter"," "],G6=["ArrowDown","PageUp","Home"],Pj=["ArrowUp","PageDown","End"],Y6=[...G6,...Pj],X6={ltr:[...Im,"ArrowRight"],rtl:[...Im,"ArrowLeft"]},K6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Co="Menu",[xo,Q6,Z6]=tp(Co),[Jl,$j]=Nr(Co,[Z6,Uc,$c]),Qc=Uc(),Fj=$c(),[J6,Wl]=Jl(Co),[W6,No]=Jl(Co),Vj=e=>{const{__scopeMenu:r,open:a=!1,children:l,dir:o,onOpenChange:c,modal:d=!0}=e,f=Qc(r),[h,m]=S.useState(null),x=S.useRef(!1),v=fr(c),b=Mc(o);return S.useEffect(()=>{const y=()=>{x.current=!0,document.addEventListener("pointerdown",k,{capture:!0,once:!0}),document.addEventListener("pointermove",k,{capture:!0,once:!0})},k=()=>x.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",k,{capture:!0}),document.removeEventListener("pointermove",k,{capture:!0})}},[]),s.jsx(Aw,{...f,children:s.jsx(J6,{scope:r,open:a,onOpenChange:v,content:h,onContentChange:m,children:s.jsx(W6,{scope:r,onClose:S.useCallback(()=>v(!1),[v]),isUsingKeyboardRef:x,dir:b,modal:d,children:l})})})};Vj.displayName=Co;var eL="MenuAnchor",Ip=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e,o=Qc(a);return s.jsx(_w,{...o,...l,ref:r})});Ip.displayName=eL;var qp="MenuPortal",[tL,Gj]=Jl(qp,{forceMount:void 0}),Yj=e=>{const{__scopeMenu:r,forceMount:a,children:l,container:o}=e,c=Wl(qp,r);return s.jsx(tL,{scope:r,forceMount:a,children:s.jsx(Vr,{present:a||c.open,children:s.jsx(Ec,{asChild:!0,container:o,children:l})})})};Yj.displayName=qp;var dr="MenuContent",[nL,Hp]=Jl(dr),Xj=S.forwardRef((e,r)=>{const a=Gj(dr,e.__scopeMenu),{forceMount:l=a.forceMount,...o}=e,c=Wl(dr,e.__scopeMenu),d=No(dr,e.__scopeMenu);return s.jsx(xo.Provider,{scope:e.__scopeMenu,children:s.jsx(Vr,{present:l||c.open,children:s.jsx(xo.Slot,{scope:e.__scopeMenu,children:d.modal?s.jsx(rL,{...o,ref:r}):s.jsx(aL,{...o,ref:r})})})})}),rL=S.forwardRef((e,r)=>{const a=Wl(dr,e.__scopeMenu),l=S.useRef(null),o=ft(r,l);return S.useEffect(()=>{const c=l.current;if(c)return Km(c)},[]),s.jsx(Pp,{...e,ref:o,trapFocus:a.open,disableOutsidePointerEvents:a.open,disableOutsideScroll:!0,onFocusOutside:Ae(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>a.onOpenChange(!1)})}),aL=S.forwardRef((e,r)=>{const a=Wl(dr,e.__scopeMenu);return s.jsx(Pp,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>a.onOpenChange(!1)})}),Pp=S.forwardRef((e,r)=>{const{__scopeMenu:a,loop:l=!1,trapFocus:o,onOpenAutoFocus:c,onCloseAutoFocus:d,disableOutsidePointerEvents:f,onEntryFocus:h,onEscapeKeyDown:m,onPointerDownOutside:x,onFocusOutside:v,onInteractOutside:b,onDismiss:y,disableOutsideScroll:k,...j}=e,T=Wl(dr,a),N=No(dr,a),R=Qc(a),D=Fj(a),I=Q6(a),[O,E]=S.useState(null),C=S.useRef(null),z=ft(r,C,T.onContentChange),Y=S.useRef(0),q=S.useRef(""),P=S.useRef(0),K=S.useRef(null),ue=S.useRef("right"),le=S.useRef(0),W=k?Ac:S.Fragment,B=k?{as:xa,allowPinchZoom:!0}:void 0,F=Z=>{var re,be;const A=q.current+Z,U=I().filter(fe=>!fe.disabled),V=document.activeElement,M=(re=U.find(fe=>fe.ref.current===V))==null?void 0:re.textValue,se=U.map(fe=>fe.textValue),X=gL(se,A,M),ce=(be=U.find(fe=>fe.textValue===X))==null?void 0:be.ref.current;(function fe(we){q.current=we,window.clearTimeout(Y.current),we!==""&&(Y.current=window.setTimeout(()=>fe(""),1e3))})(A),ce&&setTimeout(()=>ce.focus())};S.useEffect(()=>()=>window.clearTimeout(Y.current),[]),Xm();const ae=S.useCallback(Z=>{var U,V;return ue.current===((U=K.current)==null?void 0:U.side)&&vL(Z,(V=K.current)==null?void 0:V.area)},[]);return s.jsx(nL,{scope:a,searchRef:q,onItemEnter:S.useCallback(Z=>{ae(Z)&&Z.preventDefault()},[ae]),onItemLeave:S.useCallback(Z=>{var A;ae(Z)||((A=C.current)==null||A.focus(),E(null))},[ae]),onTriggerLeave:S.useCallback(Z=>{ae(Z)&&Z.preventDefault()},[ae]),pointerGraceTimerRef:P,onPointerGraceIntentChange:S.useCallback(Z=>{K.current=Z},[]),children:s.jsx(W,{...B,children:s.jsx(Nc,{asChild:!0,trapped:o,onMountAutoFocus:Ae(c,Z=>{var A;Z.preventDefault(),(A=C.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:d,children:s.jsx(Cc,{asChild:!0,disableOutsidePointerEvents:f,onEscapeKeyDown:m,onPointerDownOutside:x,onFocusOutside:v,onInteractOutside:b,onDismiss:y,children:s.jsx(kS,{asChild:!0,...D,dir:N.dir,orientation:"vertical",loop:l,currentTabStopId:O,onCurrentTabStopIdChange:E,onEntryFocus:Ae(h,Z=>{N.isUsingKeyboardRef.current||Z.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Mw,{role:"menu","aria-orientation":"vertical","data-state":ck(T.open),"data-radix-menu-content":"",dir:N.dir,...R,...j,ref:z,style:{outline:"none",...j.style},onKeyDown:Ae(j.onKeyDown,Z=>{const U=Z.target.closest("[data-radix-menu-content]")===Z.currentTarget,V=Z.ctrlKey||Z.altKey||Z.metaKey,M=Z.key.length===1;U&&(Z.key==="Tab"&&Z.preventDefault(),!V&&M&&F(Z.key));const se=C.current;if(Z.target!==se||!Y6.includes(Z.key))return;Z.preventDefault();const ce=I().filter(re=>!re.disabled).map(re=>re.ref.current);Pj.includes(Z.key)&&ce.reverse(),mL(ce)}),onBlur:Ae(e.onBlur,Z=>{Z.currentTarget.contains(Z.target)||(window.clearTimeout(Y.current),q.current="")}),onPointerMove:Ae(e.onPointerMove,vo(Z=>{const A=Z.target,U=le.current!==Z.clientX;if(Z.currentTarget.contains(A)&&U){const V=Z.clientX>le.current?"right":"left";ue.current=V,le.current=Z.clientX}}))})})})})})})});Xj.displayName=dr;var lL="MenuGroup",$p=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e;return s.jsx(Ge.div,{role:"group",...l,ref:r})});$p.displayName=lL;var iL="MenuLabel",Kj=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e;return s.jsx(Ge.div,{...l,ref:r})});Kj.displayName=iL;var vc="MenuItem",L0="menu.itemSelect",Zc=S.forwardRef((e,r)=>{const{disabled:a=!1,onSelect:l,...o}=e,c=S.useRef(null),d=No(vc,e.__scopeMenu),f=Hp(vc,e.__scopeMenu),h=ft(r,c),m=S.useRef(!1),x=()=>{const v=c.current;if(!a&&v){const b=new CustomEvent(L0,{bubbles:!0,cancelable:!0});v.addEventListener(L0,y=>l==null?void 0:l(y),{once:!0}),c1(v,b),b.defaultPrevented?m.current=!1:d.onClose()}};return s.jsx(Qj,{...o,ref:h,disabled:a,onClick:Ae(e.onClick,x),onPointerDown:v=>{var b;(b=e.onPointerDown)==null||b.call(e,v),m.current=!0},onPointerUp:Ae(e.onPointerUp,v=>{var b;m.current||(b=v.currentTarget)==null||b.click()}),onKeyDown:Ae(e.onKeyDown,v=>{const b=f.searchRef.current!=="";a||b&&v.key===" "||Im.includes(v.key)&&(v.currentTarget.click(),v.preventDefault())})})});Zc.displayName=vc;var Qj=S.forwardRef((e,r)=>{const{__scopeMenu:a,disabled:l=!1,textValue:o,...c}=e,d=Hp(vc,a),f=Fj(a),h=S.useRef(null),m=ft(r,h),[x,v]=S.useState(!1),[b,y]=S.useState("");return S.useEffect(()=>{const k=h.current;k&&y((k.textContent??"").trim())},[c.children]),s.jsx(xo.ItemSlot,{scope:a,disabled:l,textValue:o??b,children:s.jsx(CS,{asChild:!0,...f,focusable:!l,children:s.jsx(Ge.div,{role:"menuitem","data-highlighted":x?"":void 0,"aria-disabled":l||void 0,"data-disabled":l?"":void 0,...c,ref:m,onPointerMove:Ae(e.onPointerMove,vo(k=>{l?d.onItemLeave(k):(d.onItemEnter(k),k.defaultPrevented||k.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ae(e.onPointerLeave,vo(k=>d.onItemLeave(k))),onFocus:Ae(e.onFocus,()=>v(!0)),onBlur:Ae(e.onBlur,()=>v(!1))})})})}),sL="MenuCheckboxItem",Zj=S.forwardRef((e,r)=>{const{checked:a=!1,onCheckedChange:l,...o}=e;return s.jsx(nk,{scope:e.__scopeMenu,checked:a,children:s.jsx(Zc,{role:"menuitemcheckbox","aria-checked":yc(a)?"mixed":a,...o,ref:r,"data-state":Vp(a),onSelect:Ae(o.onSelect,()=>l==null?void 0:l(yc(a)?!0:!a),{checkForDefaultPrevented:!1})})})});Zj.displayName=sL;var Jj="MenuRadioGroup",[oL,uL]=Jl(Jj,{value:void 0,onValueChange:()=>{}}),Wj=S.forwardRef((e,r)=>{const{value:a,onValueChange:l,...o}=e,c=fr(l);return s.jsx(oL,{scope:e.__scopeMenu,value:a,onValueChange:c,children:s.jsx($p,{...o,ref:r})})});Wj.displayName=Jj;var ek="MenuRadioItem",tk=S.forwardRef((e,r)=>{const{value:a,...l}=e,o=uL(ek,e.__scopeMenu),c=a===o.value;return s.jsx(nk,{scope:e.__scopeMenu,checked:c,children:s.jsx(Zc,{role:"menuitemradio","aria-checked":c,...l,ref:r,"data-state":Vp(c),onSelect:Ae(l.onSelect,()=>{var d;return(d=o.onValueChange)==null?void 0:d.call(o,a)},{checkForDefaultPrevented:!1})})})});tk.displayName=ek;var Fp="MenuItemIndicator",[nk,cL]=Jl(Fp,{checked:!1}),rk=S.forwardRef((e,r)=>{const{__scopeMenu:a,forceMount:l,...o}=e,c=cL(Fp,a);return s.jsx(Vr,{present:l||yc(c.checked)||c.checked===!0,children:s.jsx(Ge.span,{...o,ref:r,"data-state":Vp(c.checked)})})});rk.displayName=Fp;var dL="MenuSeparator",ak=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e;return s.jsx(Ge.div,{role:"separator","aria-orientation":"horizontal",...l,ref:r})});ak.displayName=dL;var fL="MenuArrow",lk=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e,o=Qc(a);return s.jsx(Rw,{...o,...l,ref:r})});lk.displayName=fL;var hL="MenuSub",[N9,ik]=Jl(hL),ro="MenuSubTrigger",sk=S.forwardRef((e,r)=>{const a=Wl(ro,e.__scopeMenu),l=No(ro,e.__scopeMenu),o=ik(ro,e.__scopeMenu),c=Hp(ro,e.__scopeMenu),d=S.useRef(null),{pointerGraceTimerRef:f,onPointerGraceIntentChange:h}=c,m={__scopeMenu:e.__scopeMenu},x=S.useCallback(()=>{d.current&&window.clearTimeout(d.current),d.current=null},[]);return S.useEffect(()=>x,[x]),S.useEffect(()=>{const v=f.current;return()=>{window.clearTimeout(v),h(null)}},[f,h]),s.jsx(Ip,{asChild:!0,...m,children:s.jsx(Qj,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":o.contentId,"data-state":ck(a.open),...e,ref:Sc(r,o.onTriggerChange),onClick:v=>{var b;(b=e.onClick)==null||b.call(e,v),!(e.disabled||v.defaultPrevented)&&(v.currentTarget.focus(),a.open||a.onOpenChange(!0))},onPointerMove:Ae(e.onPointerMove,vo(v=>{c.onItemEnter(v),!v.defaultPrevented&&!e.disabled&&!a.open&&!d.current&&(c.onPointerGraceIntentChange(null),d.current=window.setTimeout(()=>{a.onOpenChange(!0),x()},100))})),onPointerLeave:Ae(e.onPointerLeave,vo(v=>{var y,k;x();const b=(y=a.content)==null?void 0:y.getBoundingClientRect();if(b){const j=(k=a.content)==null?void 0:k.dataset.side,T=j==="right",N=T?-5:5,R=b[T?"left":"right"],D=b[T?"right":"left"];c.onPointerGraceIntentChange({area:[{x:v.clientX+N,y:v.clientY},{x:R,y:b.top},{x:D,y:b.top},{x:D,y:b.bottom},{x:R,y:b.bottom}],side:j}),window.clearTimeout(f.current),f.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(v),v.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:Ae(e.onKeyDown,v=>{var y;const b=c.searchRef.current!=="";e.disabled||b&&v.key===" "||X6[l.dir].includes(v.key)&&(a.onOpenChange(!0),(y=a.content)==null||y.focus(),v.preventDefault())})})})});sk.displayName=ro;var ok="MenuSubContent",uk=S.forwardRef((e,r)=>{const a=Gj(dr,e.__scopeMenu),{forceMount:l=a.forceMount,...o}=e,c=Wl(dr,e.__scopeMenu),d=No(dr,e.__scopeMenu),f=ik(ok,e.__scopeMenu),h=S.useRef(null),m=ft(r,h);return s.jsx(xo.Provider,{scope:e.__scopeMenu,children:s.jsx(Vr,{present:l||c.open,children:s.jsx(xo.Slot,{scope:e.__scopeMenu,children:s.jsx(Pp,{id:f.contentId,"aria-labelledby":f.triggerId,...o,ref:m,align:"start",side:d.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:x=>{var v;d.isUsingKeyboardRef.current&&((v=h.current)==null||v.focus()),x.preventDefault()},onCloseAutoFocus:x=>x.preventDefault(),onFocusOutside:Ae(e.onFocusOutside,x=>{x.target!==f.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:Ae(e.onEscapeKeyDown,x=>{d.onClose(),x.preventDefault()}),onKeyDown:Ae(e.onKeyDown,x=>{var y;const v=x.currentTarget.contains(x.target),b=K6[d.dir].includes(x.key);v&&b&&(c.onOpenChange(!1),(y=f.trigger)==null||y.focus(),x.preventDefault())})})})})})});uk.displayName=ok;function ck(e){return e?"open":"closed"}function yc(e){return e==="indeterminate"}function Vp(e){return yc(e)?"indeterminate":e?"checked":"unchecked"}function mL(e){const r=document.activeElement;for(const a of e)if(a===r||(a.focus(),document.activeElement!==r))return}function pL(e,r){return e.map((a,l)=>e[(r+l)%e.length])}function gL(e,r,a){const o=r.length>1&&Array.from(r).every(m=>m===r[0])?r[0]:r,c=a?e.indexOf(a):-1;let d=pL(e,Math.max(c,0));o.length===1&&(d=d.filter(m=>m!==a));const h=d.find(m=>m.toLowerCase().startsWith(o.toLowerCase()));return h!==a?h:void 0}function xL(e,r){const{x:a,y:l}=e;let o=!1;for(let c=0,d=r.length-1;cl!=x>l&&a<(m-f)*(l-h)/(x-h)+f&&(o=!o)}return o}function vL(e,r){if(!r)return!1;const a={x:e.clientX,y:e.clientY};return xL(a,r)}function vo(e){return r=>r.pointerType==="mouse"?e(r):void 0}var yL=Vj,bL=Ip,wL=Yj,SL=Xj,jL=$p,kL=Kj,CL=Zc,NL=Zj,EL=Wj,TL=tk,AL=rk,_L=ak,ML=lk,RL=sk,DL=uk,Gp="DropdownMenu",[OL]=Nr(Gp,[$j]),En=$j(),[zL,dk]=OL(Gp),fk=e=>{const{__scopeDropdownMenu:r,children:a,dir:l,open:o,defaultOpen:c,onOpenChange:d,modal:f=!0}=e,h=En(r),m=S.useRef(null),[x=!1,v]=nl({prop:o,defaultProp:c,onChange:d});return s.jsx(zL,{scope:r,triggerId:Pr(),triggerRef:m,contentId:Pr(),open:x,onOpenChange:v,onOpenToggle:S.useCallback(()=>v(b=>!b),[v]),modal:f,children:s.jsx(yL,{...h,open:x,onOpenChange:v,dir:l,modal:f,children:a})})};fk.displayName=Gp;var hk="DropdownMenuTrigger",mk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,disabled:l=!1,...o}=e,c=dk(hk,a),d=En(a);return s.jsx(bL,{asChild:!0,...d,children:s.jsx(Ge.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":l?"":void 0,disabled:l,...o,ref:Sc(r,c.triggerRef),onPointerDown:Ae(e.onPointerDown,f=>{!l&&f.button===0&&f.ctrlKey===!1&&(c.onOpenToggle(),c.open||f.preventDefault())}),onKeyDown:Ae(e.onKeyDown,f=>{l||(["Enter"," "].includes(f.key)&&c.onOpenToggle(),f.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(f.key)&&f.preventDefault())})})})});mk.displayName=hk;var LL="DropdownMenuPortal",pk=e=>{const{__scopeDropdownMenu:r,...a}=e,l=En(r);return s.jsx(wL,{...l,...a})};pk.displayName=LL;var gk="DropdownMenuContent",xk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=dk(gk,a),c=En(a),d=S.useRef(!1);return s.jsx(SL,{id:o.contentId,"aria-labelledby":o.triggerId,...c,...l,ref:r,onCloseAutoFocus:Ae(e.onCloseAutoFocus,f=>{var h;d.current||(h=o.triggerRef.current)==null||h.focus(),d.current=!1,f.preventDefault()}),onInteractOutside:Ae(e.onInteractOutside,f=>{const h=f.detail.originalEvent,m=h.button===0&&h.ctrlKey===!0,x=h.button===2||m;(!o.modal||x)&&(d.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xk.displayName=gk;var UL="DropdownMenuGroup",BL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(jL,{...o,...l,ref:r})});BL.displayName=UL;var IL="DropdownMenuLabel",vk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(kL,{...o,...l,ref:r})});vk.displayName=IL;var qL="DropdownMenuItem",yk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(CL,{...o,...l,ref:r})});yk.displayName=qL;var HL="DropdownMenuCheckboxItem",bk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(NL,{...o,...l,ref:r})});bk.displayName=HL;var PL="DropdownMenuRadioGroup",$L=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(EL,{...o,...l,ref:r})});$L.displayName=PL;var FL="DropdownMenuRadioItem",VL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(TL,{...o,...l,ref:r})});VL.displayName=FL;var GL="DropdownMenuItemIndicator",wk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(AL,{...o,...l,ref:r})});wk.displayName=GL;var YL="DropdownMenuSeparator",Sk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(_L,{...o,...l,ref:r})});Sk.displayName=YL;var XL="DropdownMenuArrow",KL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(ML,{...o,...l,ref:r})});KL.displayName=XL;var QL="DropdownMenuSubTrigger",ZL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(RL,{...o,...l,ref:r})});ZL.displayName=QL;var JL="DropdownMenuSubContent",WL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(DL,{...o,...l,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});WL.displayName=JL;var e9=fk,t9=mk,n9=pk,r9=xk,a9=vk,l9=yk,i9=bk,s9=wk,o9=Sk;function jk({...e}){return s.jsx(e9,{"data-slot":"dropdown-menu",...e})}function kk({...e}){return s.jsx(t9,{"data-slot":"dropdown-menu-trigger",...e})}function Ck({className:e,sideOffset:r=4,...a}){return s.jsx(n9,{children:s.jsx(r9,{"data-slot":"dropdown-menu-content",sideOffset:r,className:Ne("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...a})})}function u9({className:e,inset:r,variant:a="default",...l}){return s.jsx(l9,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":a,className:Ne("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...l})}function c9({className:e,children:r,checked:a,...l}){return s.jsxs(i9,{"data-slot":"dropdown-menu-checkbox-item",className:Ne("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...l,children:[s.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:s.jsx(s9,{children:s.jsx(jc,{className:"size-4"})})}),r]})}function qm({className:e,inset:r,...a}){return s.jsx(a9,{"data-slot":"dropdown-menu-label","data-inset":r,className:Ne("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...a})}function Nk({className:e,...r}){return s.jsx(o9,{"data-slot":"dropdown-menu-separator",className:Ne("bg-border -mx-1 my-1 h-px",e),...r})}const Ek="llmproxy.playground.models",U0="llmproxy.playground.webfetch",d9={type:"function",function:{name:"web_fetch",description:"Fetch a public web page over HTTP(S) and return its text content.",parameters:{type:"object",properties:{url:{type:"string",description:"The absolute http(s) URL to fetch."}},required:["url"]}}},f9=5;function h9(){try{const e=JSON.parse(localStorage.getItem(Ek)??"[]");return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}catch{return[]}}function B0(e){return e.images.length===0?e.text:[...e.text?[{type:"text",text:e.text}]:[],...e.images.map(r=>({type:"image_url",image_url:{url:r.dataUrl}}))]}function m9(){var q;const e=Ut(async()=>{const[P,K]=await Promise.all([He.get("/v1/models?endpoint=chat"),He.get("/v1/models?endpoint=chat_stream")]);return{chat:P,streamable:new Set(K.data.map(ue=>ue.id))}}),[r,a]=S.useState(h9),[l,o]=S.useState(()=>localStorage.getItem(U0)==="1"),[c,d]=S.useState([]),[f,h]=S.useState(""),[m,x]=S.useState([]),[v,b]=S.useState(!1),y=S.useRef(null),k=S.useRef(1),j=S.useRef(null),T=S.useRef(null),N=(((q=e.data)==null?void 0:q.chat.data)??[]).map(P=>P.id);S.useEffect(()=>{e.data&&a(P=>{const K=P.filter(ue=>N.includes(ue));return K.length===P.length?P:K})},[e.data]),S.useEffect(()=>{localStorage.setItem(Ek,JSON.stringify(r))},[r]),S.useEffect(()=>{localStorage.setItem(U0,l?"1":"0")},[l]),S.useEffect(()=>()=>{var P;return(P=y.current)==null?void 0:P.abort()},[]);const R=(P,K)=>{a(ue=>K?[...ue,P]:ue.filter(le=>le!==P))},D=(P,K,ue)=>{d(le=>le.map(W=>W.id===P?{...W,replies:{...W.replies,[K]:{...W.replies[K],...ue}}}:W))},I=async(P,K,ue,le,W)=>{var be;const B=[];for(const fe of K){B.push({role:"user",content:B0(fe)});const we=fe.replies[P];(we==null?void 0:we.status)==="done"&&we.text&&B.push({role:"assistant",content:we.text})}B.push({role:"user",content:B0(ue)});const F=((be=e.data)==null?void 0:be.streamable.has(P))??!0,ae=performance.now();let Z,A="",U,V;const M=[],se=(fe,we)=>D(ue.id,P,{status:fe,error:we,text:A,firstTokenMs:Z,promptTokens:U,completionTokens:V,totalMs:performance.now()-ae}),X=fe=>{fe&&(fe.prompt_tokens!==void 0&&(U=(U??0)+fe.prompt_tokens),fe.completion_tokens!==void 0&&(V=(V??0)+fe.completion_tokens))},ce=(fe,we)=>{Z===void 0&&(Z=performance.now()-ae),we&&A&&(A+=` + +`),A+=fe,D(ue.id,P,{text:A})},re=async()=>{var Mt,Nt,Et,Bt,Rt,Dt,zt;const fe=await fetch("/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({model:P,messages:B,stream:F,...le?{tools:[d9]}:{}}),signal:W});if(!fe.ok||!fe.body){let ye=`HTTP ${fe.status}`;try{ye=((Mt=(await fe.json()).error)==null?void 0:Mt.message)??ye}catch{}return se("error",ye),"error"}if(!F){const ye=await fe.json(),pt=(Et=(Nt=ye.choices)==null?void 0:Nt[0])==null?void 0:Et.message,Q=typeof(pt==null?void 0:pt.content)=="string"?pt.content:"";Q&&ce(Q,!0),X(ye.usage);const Pe=(pt==null?void 0:pt.tool_calls)??[];return Pe.length>0&&B.push({role:"assistant",content:Q||null,tool_calls:Pe}),Pe}const we=fe.body.getReader(),Ee=new TextDecoder,Se=[];let Ie="",Be="";for(;;){const{done:ye,value:pt}=await we.read();if(ye)break;Be+=Ee.decode(pt,{stream:!0});let Q;for(;(Q=Be.indexOf(` +`))>=0;){const Pe=Be.slice(0,Q).trim();if(Be=Be.slice(Q+1),!Pe.startsWith("data:"))continue;const ne=Pe.slice(5).trim();if(!ne||ne==="[DONE]")continue;let L;try{L=JSON.parse(ne)}catch{continue}const he=(Rt=(Bt=L.choices)==null?void 0:Bt[0])==null?void 0:Rt.delta;he!=null&&he.content&&(ce(he.content,Ie===""),Ie+=he.content);for(const ke of(he==null?void 0:he.tool_calls)??[]){const ze=ke.index??0;Se[ze]??(Se[ze]={id:"",type:"function",function:{name:"",arguments:""}}),ke.id&&(Se[ze].id=ke.id),(Dt=ke.function)!=null&&Dt.name&&(Se[ze].function.name+=ke.function.name),(zt=ke.function)!=null&&zt.arguments&&(Se[ze].function.arguments+=ke.function.arguments)}X(L.usage)}}return Se.length>0&&B.push({role:"assistant",content:Ie||null,tool_calls:Se}),Se};try{for(let fe=0;fe{const P=f.trim();if(!P&&m.length===0||r.length===0||v)return;const K=c,ue={id:k.current++,text:P,images:m,replies:{}};for(const W of r)ue.replies[W]={text:"",status:"streaming"};d([...K,ue]),h(""),x([]),b(!0),requestAnimationFrame(()=>{var W;return(W=T.current)==null?void 0:W.scrollIntoView({behavior:"smooth"})});const le=new AbortController;y.current=le,await Promise.all(r.map(W=>I(W,K,ue,l,le.signal))),b(!1)},E=()=>{var P;return(P=y.current)==null?void 0:P.abort()},C=P=>{for(const K of P){if(!K.type.startsWith("image/"))continue;const ue=new FileReader;ue.onload=()=>{const le=ue.result;typeof le=="string"&&x(W=>[...W,{name:K.name,dataUrl:le}])},ue.readAsDataURL(K)}},z=P=>{const K=Array.from(P.clipboardData.files);K.length>0&&(P.preventDefault(),C(K))},Y=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),O())};return e.loading&&!e.data?s.jsx(kt,{}):e.error?s.jsx("p",{className:"text-sm text-destructive",children:e.error}):s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Playground"}),s.jsx(it,{children:"Chat with your models straight from the browser; nothing is saved."}),s.jsxs(CE,{className:"flex flex-wrap items-center justify-end gap-2",children:[s.jsxs(Me,{variant:l?"secondary":"outline","aria-pressed":l,title:"Let the model fetch public web pages",onClick:()=>o(P=>!P),children:[s.jsx(m1,{}),"Web fetch: ",l?"on":"off"]}),s.jsxs(jk,{children:[s.jsx(kk,{asChild:!0,children:s.jsxs(Me,{variant:"outline",children:[r.length===0?"Select models":r.length===1?r[0]:`${r.length} models`,s.jsx(Ji,{})]})}),s.jsxs(Ck,{align:"end",className:"max-h-96",children:[s.jsx(qm,{className:"font-normal text-muted-foreground",children:"Pick several to compare"}),s.jsx(Nk,{}),N.length===0&&s.jsx(qm,{className:"font-normal text-muted-foreground",children:"No chat models configured"}),N.map(P=>s.jsx(c9,{checked:r.includes(P),onCheckedChange:K=>R(P,K===!0),onSelect:K=>K.preventDefault(),children:P},P))]})]}),c.length>0&&s.jsxs(Me,{variant:"outline",disabled:v,onClick:()=>d([]),children:[s.jsx(Ym,{}),"Clear chat"]})]})]}),s.jsxs(Qe,{className:"flex flex-col gap-6",children:[c.length===0&&s.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:r.length===0?"Select a model to start.":"Send a message to start."}),c.map(P=>s.jsx(p9,{turn:P},P.id)),s.jsx("div",{ref:T}),s.jsxs("div",{className:"flex flex-col gap-2 border-t pt-4",children:[m.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:m.map((P,K)=>s.jsxs("div",{className:"relative",children:[s.jsx("img",{src:P.dataUrl,alt:P.name,className:"h-16 w-16 rounded-md border object-cover"}),s.jsx(Me,{variant:"secondary",size:"icon-sm","aria-label":`Remove ${P.name}`,className:"absolute -top-2 -right-2 size-5 rounded-full",onClick:()=>x(ue=>ue.filter((le,W)=>W!==K)),children:s.jsx(kc,{className:"size-3"})})]},K))}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsx("input",{ref:j,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:P=>{C(P.target.files??[]),P.target.value=""}}),s.jsx(Me,{variant:"outline",size:"icon","aria-label":"Attach image",title:"Attach image",onClick:()=>{var P;return(P=j.current)==null?void 0:P.click()},children:s.jsx(dE,{})}),s.jsx(V6,{className:"max-h-48 min-h-9",rows:1,placeholder:r.length>1?`Message ${r.length} models`:"Message",value:f,onChange:P=>h(P.target.value),onKeyDown:Y,onPaste:z}),v?s.jsx(Me,{variant:"outline",size:"icon","aria-label":"Stop",title:"Stop",onClick:E,children:s.jsx(gE,{})}):s.jsx(Me,{size:"icon","aria-label":"Send",title:"Send",disabled:!f.trim()&&m.length===0||r.length===0,onClick:()=>void O(),children:s.jsx(pE,{})})]})]})]})]})}function p9({turn:e}){const r=Object.keys(e.replies);return s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"ml-auto max-w-[85%]",children:s.jsxs("div",{className:"rounded-lg bg-primary px-3 py-2 text-sm whitespace-pre-wrap text-primary-foreground",children:[e.images.length>0&&s.jsx("div",{className:"mb-1 flex flex-wrap gap-2",children:e.images.map((a,l)=>s.jsx("img",{src:a.dataUrl,alt:a.name,className:"max-h-40 rounded-md"},l))}),e.text]})}),s.jsx("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(260px,1fr))]",children:r.map(a=>s.jsx(g9,{model:a,reply:e.replies[a],solo:r.length===1},a))})]})}function g9({model:e,reply:r,solo:a}){return s.jsxs("div",{className:a?"":"rounded-lg border p-3",children:[s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[s.jsx(on,{variant:"secondary",className:"font-mono",children:e}),r.status==="streaming"&&s.jsx(kt,{className:"size-3"}),s.jsx(x9,{reply:r})]}),r.tools&&r.tools.length>0&&s.jsx("div",{className:"mb-1 flex flex-col gap-0.5",children:r.tools.map((l,o)=>s.jsxs("span",{className:"flex items-center gap-1 break-all text-xs text-muted-foreground",children:[s.jsx(m1,{className:"size-3 shrink-0"}),l]},o))}),r.status==="error"?s.jsx("p",{className:"text-sm text-destructive",children:r.error}):s.jsx("div",{className:"text-sm",children:r.text?s.jsx(F6,{text:r.text}):r.status==="done"&&s.jsx("span",{className:"text-muted-foreground",children:"(empty response)"})})]})}function x9({reply:e}){if(e.status!=="done")return null;const r=[];if(e.firstTokenMs!==void 0&&r.push(`${(e.firstTokenMs/1e3).toFixed(2)}s to first token`),e.totalMs!==void 0&&r.push(`${(e.totalMs/1e3).toFixed(2)}s total`),e.completionTokens&&e.totalMs){const a=e.firstTokenMs!==void 0&&e.totalMs-e.firstTokenMs>100?e.totalMs-e.firstTokenMs:e.totalMs;r.push(`${(e.completionTokens/(a/1e3)).toFixed(1)} tok/s`)}return(e.promptTokens!==void 0||e.completionTokens!==void 0)&&r.push(`${e.promptTokens??"?"} in / ${e.completionTokens??"?"} out`),r.length===0?null:s.jsx("span",{className:"text-xs text-muted-foreground",children:r.join(" · ")})}const I0="llmproxy-theme",Tk=S.createContext({theme:"system",resolvedTheme:"light",setTheme:()=>{}});function q0(){return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function v9({children:e}){const[r,a]=S.useState(()=>{const d=localStorage.getItem(I0);return d==="light"||d==="dark"?d:"system"}),l=r==="system"?q0():r,o=S.useCallback(d=>{const f=d==="system"?q0():d;document.documentElement.classList.toggle("dark",f==="dark")},[]),c=S.useCallback(d=>{a(d),localStorage.setItem(I0,d),o(d)},[o]);return S.useEffect(()=>{o(r);const d=matchMedia("(prefers-color-scheme: dark)"),f=()=>o(r);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[r,o]),s.jsx(Tk.Provider,{value:{theme:r,resolvedTheme:l,setTheme:c},children:e})}function Ak(){return S.useContext(Tk)}function y9(){const[e,r]=S.useState(null),[a,l]=S.useState(!1),o=S.useCallback(()=>{He.get("/auth/me").then(r).catch(()=>l(!0))},[]);return S.useEffect(o,[o]),a?s.jsx("div",{className:"flex min-h-screen items-center justify-center",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"The proxy is not reachable. Reload to retry."})}):e===null?s.jsx("div",{className:"flex min-h-screen items-center justify-center",children:s.jsx(kt,{className:"size-6"})}):e.authenticated?s.jsx(j9,{me:e}):s.jsx(NE,{me:e,onLogin:o})}function b9(){const{theme:e,setTheme:r}=Ak(),a={light:"dark",dark:"system",system:"light"},l={light:s.jsx(vE,{}),dark:s.jsx(hE,{}),system:s.jsx(xE,{})};return s.jsx(Me,{variant:"ghost",size:"icon","aria-label":`Theme: ${e}. Switch to ${a[e]}`,title:`Theme: ${e}`,onClick:()=>r(a[e]),children:l[e]})}const w9=["providers","models","users","services","all-keys"],S9=["overview","apps","models","providers","errors","performance"];function H0(e){const r=window.location.pathname.replace(/^\/+/,"").split("/");let a=r[0];if(a==="activity"&&(a="requests"),e&&w9.includes(a))return{tab:"admin",sub:a,usageSub:"overview"};const l=["usage","requests","keys","playground"].includes(a)?a:"usage",o=l==="usage"&&S9.includes(r[1])?r[1]:"overview";return{tab:l,sub:"providers",usageSub:o}}function j9({me:e}){const r=e.role==="admin",[a,l]=S.useState(()=>H0(r));S.useEffect(()=>{const h=()=>l(H0(r));return window.addEventListener("popstate",h),()=>window.removeEventListener("popstate",h)},[r]);const o=h=>{l(h);let m="/"+(h.tab==="admin"?h.sub:h.tab);if(h.tab==="usage"&&h.usageSub!=="overview"&&(m+="/"+h.usageSub),window.location.pathname!==m){const x=a.tab==="usage"&&h.tab==="usage";window.history.pushState(null,"",m+(x?window.location.search:""))}},c=h=>o({...a,tab:h}),d=h=>o({...a,tab:"admin",sub:h}),f=h=>o({...a,tab:"usage",usageSub:h});return s.jsxs(Nm,{value:a.tab,onValueChange:c,children:[s.jsx("header",{className:"border-b bg-card",children:s.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3",children:[s.jsxs("a",{href:"/usage",onClick:h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),c("usage"))},className:"flex items-center gap-2 rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[s.jsx(i1,{className:"h-6"}),s.jsx("span",{className:"font-serif text-lg font-semibold",children:"llmproxy"})]}),s.jsxs(Em,{children:[s.jsx(or,{value:"usage",children:"Usage"}),s.jsx(or,{value:"requests",children:"Requests"}),s.jsx(or,{value:"keys",children:"API keys"}),s.jsx(or,{value:"playground",children:"Playground"}),r&&s.jsx(or,{value:"admin",children:"Admin"})]}),s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[s.jsx(b9,{}),s.jsxs(jk,{children:[s.jsx(kk,{asChild:!0,children:s.jsxs(Me,{variant:"ghost",className:"gap-2",children:[s.jsx(oE,{}),s.jsx("span",{className:"max-w-40 truncate",children:e.name}),r&&s.jsx(on,{variant:"secondary",children:"admin"})]})}),s.jsxs(Ck,{align:"end",children:[s.jsxs(qm,{className:"font-normal text-muted-foreground",children:["Signed in as ",e.name]}),s.jsx(Nk,{}),s.jsx(u9,{onClick:()=>window.location.href="/auth/logout",children:"Sign out"})]})]})]})]})}),s.jsxs("main",{className:"mx-auto flex w-full max-w-6xl flex-col gap-6 px-4 py-8",children:[s.jsx(Ur,{value:"usage",children:s.jsx(CR,{ssoEnabled:e.sso_enabled,sub:a.usageSub,onSubChange:f})}),s.jsx(Ur,{value:"requests",children:s.jsx(dD,{})}),s.jsx(Ur,{value:"keys",children:s.jsx(FA,{})}),s.jsx(Ur,{value:"playground",forceMount:!0,className:"data-[state=inactive]:hidden",children:s.jsx(m9,{})}),r&&s.jsx(Ur,{value:"admin",children:s.jsxs(Nm,{value:a.sub,onValueChange:d,className:"gap-6",children:[s.jsxs(Em,{children:[s.jsx(or,{value:"providers",children:"Providers"}),s.jsx(or,{value:"models",children:"Models"}),s.jsx(or,{value:"users",children:"Users"}),s.jsx(or,{value:"services",children:"Services"}),s.jsx(or,{value:"all-keys",children:"All keys"})]}),s.jsx(Ur,{value:"providers",children:s.jsx(OR,{})}),s.jsx(Ur,{value:"models",children:s.jsx(eD,{})}),s.jsx(Ur,{value:"users",children:s.jsx(hD,{})}),s.jsx(Ur,{value:"services",children:s.jsx(pD,{})}),s.jsx(Ur,{value:"all-keys",children:s.jsx(gD,{})})]})})]})]})}const k9=({...e})=>{const{resolvedTheme:r}=Ak();return s.jsx(WE,{theme:r,className:"toaster group",style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)"},...e})};W2.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsxs(v9,{children:[s.jsx(y9,{}),s.jsx(k9,{position:"bottom-right"})]})})); diff --git a/internal/server/uidist/assets/index-BSye0vLa.css b/internal/server/uidist/assets/index-DmusaFEh.css similarity index 81% rename from internal/server/uidist/assets/index-BSye0vLa.css rename to internal/server/uidist/assets/index-DmusaFEh.css index aa4d265..f6d0a46 100644 --- a/internal/server/uidist/assets/index-BSye0vLa.css +++ b/internal/server/uidist/assets/index-DmusaFEh.css @@ -1 +1 @@ -/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:forwards;--tw-animation-iteration-count:1;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0}}}@layer theme{:root,:host{--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--color-red-500:oklch(63.7% .237 25.331);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-green-500:oklch(72.3% .219 149.579);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-lg:32rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-widest:.1em;--leading-relaxed:1.625;--radius-xs:.125rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Aspekta", ui-sans-serif, system-ui, sans-serif;--default-mono-font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--color-popover:rgb(var(--popover));--color-popover-foreground:rgb(var(--popover-foreground));--color-border:rgb(var(--border))}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:rgb(var(--border));outline-color:rgb(var(--ring))}@supports (color:color-mix(in lab,red,red)){*{outline-color:color-mix(in oklab,rgb(var(--ring)) 50%,transparent)}}body{background-color:rgb(var(--background));color:rgb(var(--foreground));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Aspekta,ui-sans-serif,system-ui,sans-serif}}@layer components;@layer utilities{.\@container\/card-header{container:card-header/inline-size}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{inset-inline:0}.inset-y-0{inset-block:0}.-top-2{top:calc(var(--spacing) * -2)}.top-0{top:0}.top-1\/2,.top-\[50\%\]{top:50%}.-right-2{right:calc(var(--spacing) * -2)}.right-1{right:var(--spacing)}.right-2{right:calc(var(--spacing) * 2)}.right-8{right:calc(var(--spacing) * 8)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing) * 2)}.left-\[50\%\]{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.col-start-2{grid-column-start:2}.row-span-2{grid-row:span 2/span 2}.row-start-1{grid-row-start:1}.-mx-1{margin-inline:calc(var(--spacing) * -1)}.mx-auto{margin-inline:auto}.my-1{margin-block:var(--spacing)}.-mt-2{margin-top:calc(var(--spacing) * -2)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mr-1{margin-right:var(--spacing)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-1{margin-left:var(--spacing)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.table-caption{display:table-caption}.table-cell{display:table-cell}.table-row{display:table-row}.field-sizing-content{field-sizing:content}.size-2{width:calc(var(--spacing) * 2);height:calc(var(--spacing) * 2)}.size-2\.5{width:calc(var(--spacing) * 2.5);height:calc(var(--spacing) * 2.5)}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-8{width:calc(var(--spacing) * 8);height:calc(var(--spacing) * 8)}.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9)}.size-10{width:calc(var(--spacing) * 10);height:calc(var(--spacing) * 10)}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-16{height:calc(var(--spacing) * 16)}.h-\[1\.15rem\]{height:1.15rem}.h-\[calc\(100\%-1px\)\]{height:calc(100% - 1px)}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-full{height:100%}.h-px{height:1px}.max-h-\(--radix-dropdown-menu-content-available-height\){max-height:var(--radix-dropdown-menu-content-available-height)}.max-h-\(--radix-select-content-available-height\){max-height:var(--radix-select-content-available-height)}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-16{min-height:calc(var(--spacing) * 16)}.min-h-screen{min-height:100vh}.w-3{width:calc(var(--spacing) * 3)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-24{width:calc(var(--spacing) * 24)}.w-32{width:calc(var(--spacing) * 32)}.w-40{width:calc(var(--spacing) * 40)}.w-44{width:calc(var(--spacing) * 44)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.max-w-6xl{max-width:var(--container-6xl)}.max-w-36{max-width:calc(var(--spacing) * 36)}.max-w-40{max-width:calc(var(--spacing) * 40)}.max-w-44{max-width:calc(var(--spacing) * 44)}.max-w-\[85\%\]{max-width:85%}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-full{max-width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-32{min-width:calc(var(--spacing) * 32)}.min-w-36{min-width:calc(var(--spacing) * 36)}.min-w-48{min-width:calc(var(--spacing) * 48)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.caption-bottom{caption-side:bottom}.origin-\(--radix-dropdown-menu-content-transform-origin\){transform-origin:var(--radix-dropdown-menu-content-transform-origin)}.origin-\(--radix-select-content-transform-origin\){transform-origin:var(--radix-select-content-transform-origin)}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-\[-50\%\]{--tw-translate-x:-50%;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[-50\%\]{--tw-translate-y:-50%;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-180{rotate:180deg}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.scroll-my-1{scroll-margin-block:var(--spacing)}.auto-rows-min{grid-auto-rows:min-content}.\[grid-template-columns\:repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[minmax\(6rem\,14rem\)_1fr_auto\]{grid-template-columns:minmax(6rem,14rem) 1fr auto}.grid-rows-\[auto_auto\]{grid-template-rows:auto auto}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-x-8{column-gap:calc(var(--spacing) * 8)}.gap-y-1{row-gap:var(--spacing)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.gap-y-3{row-gap:calc(var(--spacing) * 3)}.gap-y-4{row-gap:calc(var(--spacing) * 4)}.self-start{align-self:flex-start}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[4px\]{border-radius:4px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:calc(var(--radius) + 2px)}.rounded-md{border-radius:var(--radius)}.rounded-sm{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.rounded-xs{border-radius:var(--radius-xs)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-border{border-color:rgb(var(--border))}.border-foreground{border-color:rgb(var(--foreground))}.border-input{border-color:rgb(var(--input))}.border-primary\/40{border-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){.border-primary\/40{border-color:color-mix(in oklab,rgb(var(--primary)) 40%,transparent)}}.border-transparent{border-color:#0000}.bg-\[\#1a7f37\]{background-color:#1a7f37}.bg-\[\#3b82f6\]{background-color:#3b82f6}.bg-\[\#4b5563\]{background-color:#4b5563}.bg-\[\#9a6700\]{background-color:#9a6700}.bg-\[\#22c55e\]{background-color:#22c55e}.bg-\[\#0969da\]{background-color:#0969da}.bg-\[\#a855f7\]{background-color:#a855f7}.bg-\[\#f97316\]{background-color:#f97316}.bg-\[rgb\(var\(--border\)\)\]{background-color:rgb(var(--border))}.bg-accent{background-color:rgb(var(--accent))}.bg-background{background-color:rgb(var(--background))}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}}.bg-border{background-color:rgb(var(--border))}.bg-card{background-color:rgb(var(--card))}.bg-chart-1{background-color:rgb(var(--chart-1))}.bg-chart-2{background-color:rgb(var(--chart-2))}.bg-chart-3{background-color:rgb(var(--chart-3))}.bg-chart-5{background-color:rgb(var(--chart-5))}.bg-destructive{background-color:rgb(var(--destructive))}.bg-foreground\/5{background-color:rgb(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.bg-foreground\/5{background-color:color-mix(in oklab,rgb(var(--foreground)) 5%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-muted{background-color:rgb(var(--muted))}.bg-muted-foreground{background-color:rgb(var(--muted-foreground))}.bg-muted\/30{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/30{background-color:color-mix(in oklab,rgb(var(--muted)) 30%,transparent)}}.bg-muted\/50{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/50{background-color:color-mix(in oklab,rgb(var(--muted)) 50%,transparent)}}.bg-popover{background-color:rgb(var(--popover))}.bg-primary,.bg-primary\/5{background-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){.bg-primary\/5{background-color:color-mix(in oklab,rgb(var(--primary)) 5%,transparent)}}.bg-red-500{background-color:var(--color-red-500)}.bg-secondary{background-color:rgb(var(--secondary))}.bg-transparent{background-color:#0000}.bg-yellow-500{background-color:var(--color-yellow-500)}.fill-border{fill:rgb(var(--border))}.fill-chart-1{fill:rgb(var(--chart-1))}.fill-chart-2{fill:rgb(var(--chart-2))}.fill-chart-3{fill:rgb(var(--chart-3))}.fill-chart-5{fill:rgb(var(--chart-5))}.fill-current{fill:currentColor}.fill-foreground,.fill-foreground\/5{fill:rgb(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.fill-foreground\/5{fill:color-mix(in oklab,rgb(var(--foreground)) 5%,transparent)}}.fill-muted-foreground{fill:rgb(var(--muted-foreground))}.stroke-border{stroke:rgb(var(--border))}.stroke-card{stroke:rgb(var(--card))}.stroke-chart-1{stroke:rgb(var(--chart-1))}.stroke-chart-2{stroke:rgb(var(--chart-2))}.stroke-muted-foreground\/50{stroke:rgb(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.stroke-muted-foreground\/50{stroke:color-mix(in oklab,rgb(var(--muted-foreground)) 50%,transparent)}}.object-cover{object-fit:cover}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-\[3px\]{padding:3px}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0{padding-block:0}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-12{padding-block:calc(var(--spacing) * 12)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pr-0{padding-right:0}.pr-1{padding-right:var(--spacing)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-6{padding-right:calc(var(--spacing) * 6)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pr-14{padding-right:calc(var(--spacing) * 14)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-8{padding-left:calc(var(--spacing) * 8)}.pl-\[18px\]{padding-left:18px}.pl-\[26px\]{padding-left:26px}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.align-top{vertical-align:top}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}.font-serif{font-family:"Source Serif 4",Source Serif Pro,Georgia,serif}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-sm\/relaxed{font-size:var(--text-sm);line-height:var(--leading-relaxed)}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.text-balance{text-wrap:balance}.wrap-anywhere{overflow-wrap:anywhere}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent-foreground{color:rgb(var(--accent-foreground))}.text-card-foreground{color:rgb(var(--card-foreground))}.text-current{color:currentColor}.text-destructive{color:rgb(var(--destructive))}.text-foreground{color:rgb(var(--foreground))}.text-muted-foreground{color:rgb(var(--muted-foreground))}.text-popover-foreground{color:rgb(var(--popover-foreground))}.text-primary{color:rgb(var(--primary))}.text-primary-foreground{color:rgb(var(--primary-foreground))}.text-secondary-foreground{color:rgb(var(--secondary-foreground))}.text-white{color:var(--color-white)}.text-yellow-600{color:var(--color-yellow-600)}.lowercase{text-transform:lowercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline-hidden{--tw-outline-style:none;outline-style:none}@media(forced-colors:active){.outline-hidden{outline-offset:2px;outline:2px solid #0000}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-\[color\,box-shadow\]{transition-property:color,box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-shadow{transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-none{transition-property:none}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.running{animation-play-state:running}.group-data-\[disabled\=true\]\:pointer-events-none:is(:where(.group)[data-disabled=true] *){pointer-events:none}.group-data-\[disabled\=true\]\:opacity-50:is(:where(.group)[data-disabled=true] *){opacity:.5}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.peer-disabled\:opacity-50:is(:where(.peer):disabled~*){opacity:.5}.selection\:bg-primary ::selection{background-color:rgb(var(--primary))}.selection\:bg-primary::selection{background-color:rgb(var(--primary))}.selection\:text-primary-foreground ::selection{color:rgb(var(--primary-foreground))}.selection\:text-primary-foreground::selection{color:rgb(var(--primary-foreground))}.file\:inline-flex::file-selector-button{display:inline-flex}.file\:h-7::file-selector-button{height:calc(var(--spacing) * 7)}.file\:border-0::file-selector-button{border-style:var(--tw-border-style);border-width:0}.file\:bg-transparent::file-selector-button{background-color:#0000}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-foreground::file-selector-button{color:rgb(var(--foreground))}.placeholder\:text-muted-foreground::placeholder{color:rgb(var(--muted-foreground))}@media(hover:hover){.hover\:bg-accent:hover{background-color:rgb(var(--accent))}.hover\:bg-destructive\/90:hover{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-destructive\/90:hover{background-color:color-mix(in oklab,rgb(var(--destructive)) 90%,transparent)}}.hover\:bg-muted\/30:hover{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/30:hover{background-color:color-mix(in oklab,rgb(var(--muted)) 30%,transparent)}}.hover\:bg-muted\/50:hover{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab,rgb(var(--muted)) 50%,transparent)}}.hover\:bg-primary\/90:hover{background-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,rgb(var(--primary)) 90%,transparent)}}.hover\:bg-secondary\/80:hover{background-color:rgb(var(--secondary))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-secondary\/80:hover{background-color:color-mix(in oklab,rgb(var(--secondary)) 80%,transparent)}}.hover\:text-accent-foreground:hover{color:rgb(var(--accent-foreground))}.hover\:text-foreground:hover{color:rgb(var(--foreground))}.hover\:underline:hover{text-decoration-line:underline}}.focus\:bg-accent:focus{background-color:rgb(var(--accent))}.focus\:text-accent-foreground:focus{color:rgb(var(--accent-foreground))}.focus-visible\:border-ring:focus-visible{border-color:rgb(var(--ring))}.focus-visible\:stroke-ring:focus-visible{stroke:rgb(var(--ring))}.focus-visible\:\[stroke-width\:2\]:focus-visible{stroke-width:2px}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-destructive\/20:focus-visible{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-destructive\/20:focus-visible{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 20%, transparent)}}.focus-visible\:ring-ring:focus-visible,.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:rgb(var(--ring))}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:color-mix(in oklab, rgb(var(--ring)) 50%, transparent)}}.focus-visible\:outline-1:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-ring:focus-visible{outline-color:rgb(var(--ring))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.has-data-\[slot\=card-action\]\:grid-cols-\[1fr_auto\]:has([data-slot=card-action]){grid-template-columns:1fr auto}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing) * 2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing) * 3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing) * 4)}.aria-invalid\:border-destructive[aria-invalid=true]{border-color:rgb(var(--destructive))}.aria-invalid\:ring-destructive\/20[aria-invalid=true]{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.aria-invalid\:ring-destructive\/20[aria-invalid=true]{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 20%, transparent)}}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[inset\]\:pl-8[data-inset]{padding-left:calc(var(--spacing) * 8)}.data-\[orientation\=horizontal\]\:h-px[data-orientation=horizontal]{height:1px}.data-\[orientation\=horizontal\]\:w-full[data-orientation=horizontal]{width:100%}.data-\[orientation\=vertical\]\:h-full[data-orientation=vertical]{height:100%}.data-\[orientation\=vertical\]\:w-px[data-orientation=vertical]{width:1px}.data-\[placeholder\]\:text-muted-foreground[data-placeholder]{color:rgb(var(--muted-foreground))}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:var(--spacing);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=bottom\]\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:calc(2*var(--spacing)*-1)}.data-\[side\=left\]\:-translate-x-1[data-side=left]{--tw-translate-x:calc(var(--spacing) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:calc(2*var(--spacing))}.data-\[side\=right\]\:translate-x-1[data-side=right]{--tw-translate-x:var(--spacing);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:calc(2*var(--spacing)*-1)}.data-\[side\=top\]\:-translate-y-1[data-side=top]{--tw-translate-y:calc(var(--spacing) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:calc(2*var(--spacing))}.data-\[size\=default\]\:h-9[data-size=default]{height:calc(var(--spacing) * 9)}.data-\[size\=sm\]\:h-8[data-size=sm]{height:calc(var(--spacing) * 8)}:is(.\*\:data-\[slot\=select-value\]\:line-clamp-1>*)[data-slot=select-value]{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}:is(.\*\:data-\[slot\=select-value\]\:flex>*)[data-slot=select-value]{display:flex}:is(.\*\:data-\[slot\=select-value\]\:items-center>*)[data-slot=select-value]{align-items:center}:is(.\*\:data-\[slot\=select-value\]\:gap-2>*)[data-slot=select-value]{gap:calc(var(--spacing) * 2)}.data-\[state\=active\]\:bg-card[data-state=active]{background-color:rgb(var(--card))}.data-\[state\=active\]\:shadow-sm[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-\[calc\(100\%-2px\)\][data-state=checked]{--tw-translate-x: calc(100% - 2px) ;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[state\=checked\]\:border-primary[data-state=checked]{border-color:rgb(var(--primary))}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:rgb(var(--primary))}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:rgb(var(--primary-foreground))}.data-\[state\=closed\]\:animate-out[data-state=closed]{animation:exit var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,forwards)}.data-\[state\=closed\]\:fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\[state\=closed\]\:zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\[state\=inactive\]\:hidden[data-state=inactive]{display:none}.data-\[state\=open\]\:animate-in[data-state=open]{animation:enter var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,forwards)}.data-\[state\=open\]\:bg-accent[data-state=open]{background-color:rgb(var(--accent))}.data-\[state\=open\]\:text-accent-foreground[data-state=open]{color:rgb(var(--accent-foreground))}.data-\[state\=open\]\:fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\[state\=open\]\:zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:rgb(var(--muted))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-\[\#7F7F79\][data-state=unchecked]{background-color:#7f7f79}.data-\[variant\=destructive\]\:text-destructive[data-variant=destructive]{color:rgb(var(--destructive))}.data-\[variant\=destructive\]\:focus\:bg-destructive\/10[data-variant=destructive]:focus{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.data-\[variant\=destructive\]\:focus\:bg-destructive\/10[data-variant=destructive]:focus{background-color:color-mix(in oklab,rgb(var(--destructive)) 10%,transparent)}}.data-\[variant\=destructive\]\:focus\:text-destructive[data-variant=destructive]:focus{color:rgb(var(--destructive))}@media(min-width:40rem){.sm\:col-span-2{grid-column:span 2/span 2}.sm\:max-w-lg{max-width:var(--container-lg)}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:p-12{padding:calc(var(--spacing) * 12)}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.dark\:border-input:is(.dark *){border-color:rgb(var(--input))}.dark\:bg-chart-4:is(.dark *){background-color:rgb(var(--chart-4))}.dark\:bg-destructive\/60:is(.dark *){background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:bg-destructive\/60:is(.dark *){background-color:color-mix(in oklab,rgb(var(--destructive)) 60%,transparent)}}.dark\:bg-input\/30:is(.dark *){background-color:rgb(var(--input))}@supports (color:color-mix(in lab,red,red)){.dark\:bg-input\/30:is(.dark *){background-color:color-mix(in oklab,rgb(var(--input)) 30%,transparent)}}.dark\:fill-chart-4:is(.dark *){fill:rgb(var(--chart-4))}.dark\:stroke-chart-4:is(.dark *){stroke:rgb(var(--chart-4))}.dark\:text-muted-foreground:is(.dark *){color:rgb(var(--muted-foreground))}.dark\:text-yellow-400:is(.dark *){color:var(--color-yellow-400)}@media(hover:hover){.dark\:hover\:bg-accent\/50:is(.dark *):hover{background-color:rgb(var(--accent))}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-accent\/50:is(.dark *):hover{background-color:color-mix(in oklab,rgb(var(--accent)) 50%,transparent)}}.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:rgb(var(--input))}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:color-mix(in oklab,rgb(var(--input)) 50%,transparent)}}}.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 40%, transparent)}}.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 40%, transparent)}}.dark\:data-\[state\=active\]\:border-input:is(.dark *)[data-state=active]{border-color:rgb(var(--input))}.dark\:data-\[state\=active\]\:bg-input\/30:is(.dark *)[data-state=active]{background-color:rgb(var(--input))}@supports (color:color-mix(in lab,red,red)){.dark\:data-\[state\=active\]\:bg-input\/30:is(.dark *)[data-state=active]{background-color:color-mix(in oklab,rgb(var(--input)) 30%,transparent)}}.dark\:data-\[state\=active\]\:text-foreground:is(.dark *)[data-state=active]{color:rgb(var(--foreground))}.dark\:data-\[state\=checked\]\:bg-primary:is(.dark *)[data-state=checked]{background-color:rgb(var(--primary))}.dark\:data-\[state\=checked\]\:bg-primary-foreground:is(.dark *)[data-state=checked]{background-color:rgb(var(--primary-foreground))}.dark\:data-\[state\=unchecked\]\:bg-foreground:is(.dark *)[data-state=unchecked]{background-color:rgb(var(--foreground))}.dark\:data-\[state\=unchecked\]\:bg-input:is(.dark *)[data-state=unchecked]{background-color:rgb(var(--input))}.dark\:data-\[variant\=destructive\]\:focus\:bg-destructive\/20:is(.dark *)[data-variant=destructive]:focus{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:data-\[variant\=destructive\]\:focus\:bg-destructive\/20:is(.dark *)[data-variant=destructive]:focus{background-color:color-mix(in oklab,rgb(var(--destructive)) 20%,transparent)}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-6 svg:not([class*=size-]){width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.\[\&_svg\:not\(\[class\*\=\'text-\'\]\)\]\:text-muted-foreground svg:not([class*=text-]){color:rgb(var(--muted-foreground))}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\.border-b\]\:pb-6.border-b{padding-bottom:calc(var(--spacing) * 6)}.\[\.border-t\]\:pt-6.border-t{padding-top:calc(var(--spacing) * 6)}:is(.\*\:\[span\]\:last\:flex>*):is(span):last-child{display:flex}:is(.\*\:\[span\]\:last\:items-center>*):is(span):last-child{align-items:center}:is(.\*\:\[span\]\:last\:gap-2>*):is(span):last-child{gap:calc(var(--spacing) * 2)}:is(.data-\[variant\=destructive\]\:\*\:\[svg\]\:\!text-destructive[data-variant=destructive]>*):is(svg){color:rgb(var(--destructive))!important}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y:2px;translate:var(--tw-translate-x) var(--tw-translate-y)}.\[\&\>a\]\:underline>a{text-decoration-line:underline}.\[\&\>a\]\:underline-offset-4>a{text-underline-offset:4px}.\[\&\>a\:hover\]\:text-primary>a:hover{color:rgb(var(--primary))}.\[\&\>svg\]\:pointer-events-none>svg{pointer-events:none}.\[\&\>svg\]\:size-3>svg{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.\[\&\>svg\]\:size-3\.5>svg{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.\[\&\>tr\]\:last\:border-b-0>tr:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){a.\[a\&\]\:hover\:bg-\[\#1a7f37\]\/90:hover{background-color:#1a7f37e6}a.\[a\&\]\:hover\:bg-\[\#3b82f6\]\/90:hover{background-color:#3b82f6e6}a.\[a\&\]\:hover\:bg-\[\#4b5563\]\/90:hover{background-color:#4b5563e6}a.\[a\&\]\:hover\:bg-\[\#9a6700\]\/90:hover{background-color:#9a6700e6}a.\[a\&\]\:hover\:bg-\[\#22c55e\]\/90:hover{background-color:#22c55ee6}a.\[a\&\]\:hover\:bg-\[\#0969da\]\/90:hover{background-color:#0969dae6}a.\[a\&\]\:hover\:bg-\[\#a855f7\]\/90:hover{background-color:#a855f7e6}a.\[a\&\]\:hover\:bg-\[\#f97316\]\/90:hover{background-color:#f97316e6}a.\[a\&\]\:hover\:bg-accent\/10:hover{background-color:rgb(var(--accent))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-accent\/10:hover{background-color:color-mix(in oklab,rgb(var(--accent)) 10%,transparent)}}a.\[a\&\]\:hover\:bg-destructive\/90:hover{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-destructive\/90:hover{background-color:color-mix(in oklab,rgb(var(--destructive)) 90%,transparent)}}a.\[a\&\]\:hover\:bg-muted:hover,a.\[a\&\]\:hover\:bg-muted\/80:hover{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-muted\/80:hover{background-color:color-mix(in oklab,rgb(var(--muted)) 80%,transparent)}}a.\[a\&\]\:hover\:bg-primary\/90:hover{background-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,rgb(var(--primary)) 90%,transparent)}}a.\[a\&\]\:hover\:bg-secondary\/90:hover{background-color:rgb(var(--secondary))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-secondary\/90:hover{background-color:color-mix(in oklab,rgb(var(--secondary)) 90%,transparent)}}a.\[a\&\]\:hover\:text-accent-foreground:hover{color:rgb(var(--accent-foreground))}}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:forwards}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}@font-face{font-family:Aspekta;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/Aspekta-400.woff2)format("woff2")}@font-face{font-family:Aspekta;font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/Aspekta-500.woff2)format("woff2")}@font-face{font-family:Aspekta;font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/Aspekta-600.woff2)format("woff2")}@font-face{font-family:Aspekta;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/Aspekta-700.woff2)format("woff2")}:root{--background:240 240 236;--foreground:22 22 20;--card:249 249 247;--card-foreground:22 22 20;--popover:249 249 247;--popover-foreground:22 22 20;--primary:217 94 42;--primary-foreground:249 249 247;--secondary:240 240 236;--secondary-foreground:47 47 44;--muted:240 240 236;--muted-foreground:87 87 83;--accent:221 221 215;--accent-foreground:22 22 20;--destructive:180 50 50;--destructive-foreground:249 249 247;--border:196 196 189;--input:196 196 189;--ring:217 94 42;--chart-1:217 94 42;--chart-2:87 87 83;--chart-3:127 127 121;--chart-4:166 166 159;--chart-5:47 47 44;--radius:.375rem}.dark{--background:22 22 20;--foreground:249 249 247;--card:47 47 44;--card-foreground:249 249 247;--popover:47 47 44;--popover-foreground:249 249 247;--primary:217 94 42;--primary-foreground:249 249 247;--secondary:87 87 83;--secondary-foreground:249 249 247;--muted:87 87 83;--muted-foreground:196 196 189;--accent:87 87 83;--accent-foreground:249 249 247;--destructive:180 50 50;--destructive-foreground:249 249 247;--border:87 87 83;--input:87 87 83;--ring:217 94 42;--chart-1:217 94 42;--chart-2:196 196 189;--chart-3:166 166 159;--chart-4:127 127 121;--chart-5:240 240 236}.chat-markdown{overflow-wrap:break-word;line-height:1.55}.chat-markdown>:first-child{margin-top:0}.chat-markdown>:last-child{margin-bottom:0}.chat-markdown p{margin:.5em 0}.chat-markdown h1,.chat-markdown h2,.chat-markdown h3,.chat-markdown h4,.chat-markdown h5,.chat-markdown h6{margin:1em 0 .4em;font-size:1em;font-weight:600;line-height:1.3}.chat-markdown h1{font-size:1.15em}.chat-markdown h2{font-size:1.08em}.chat-markdown ul,.chat-markdown ol{margin:.5em 0;padding-left:1.4em}.chat-markdown ul{list-style:outside}.chat-markdown ol{list-style:decimal}.chat-markdown li,.chat-markdown li>ul,.chat-markdown li>ol{margin:.2em 0}.chat-markdown li::marker{color:rgb(var(--muted-foreground))}.chat-markdown code{font-family:var(--font-mono);background:rgb(var(--muted));border:1px solid rgb(var(--border) / .6);border-radius:4px;padding:.1em .35em;font-size:.9em}.chat-markdown pre{background:rgb(var(--muted));border:1px solid rgb(var(--border) / .6);border-radius:var(--radius);margin:.6em 0;padding:.6em .75em;overflow-x:auto}.chat-markdown pre code{background:0 0;border:none;padding:0;font-size:.85em;line-height:1.5}.chat-markdown blockquote{border-left:3px solid rgb(var(--border));color:rgb(var(--muted-foreground));margin:.6em 0;padding:.1em 0 .1em .9em}.chat-markdown a{color:rgb(var(--primary));text-underline-offset:2px;text-decoration:underline}.chat-markdown table{border-collapse:collapse;margin:.6em 0;font-size:.95em;display:block;overflow-x:auto}.chat-markdown th,.chat-markdown td{border:1px solid rgb(var(--border));text-align:left;padding:4px 10px}.chat-markdown th{background:rgb(var(--muted));font-weight:600}.chat-markdown hr{border:none;border-top:1px solid rgb(var(--border));margin:1em 0}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0)scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1))rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0)scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1))rotate(var(--tw-exit-rotate,0))}} +/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-space-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-animation-delay:0s;--tw-animation-direction:normal;--tw-animation-duration:initial;--tw-animation-fill-mode:forwards;--tw-animation-iteration-count:1;--tw-enter-opacity:1;--tw-enter-rotate:0;--tw-enter-scale:1;--tw-enter-translate-x:0;--tw-enter-translate-y:0;--tw-exit-opacity:1;--tw-exit-rotate:0;--tw-exit-scale:1;--tw-exit-translate-x:0;--tw-exit-translate-y:0}}}@layer theme{:root,:host{--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--color-red-500:oklch(63.7% .237 25.331);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-green-500:oklch(72.3% .219 149.579);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-sm:24rem;--container-lg:32rem;--container-6xl:72rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height: 1.5 ;--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--tracking-tight:-.025em;--tracking-widest:.1em;--leading-relaxed:1.625;--radius-xs:.125rem;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:"Aspekta", ui-sans-serif, system-ui, sans-serif;--default-mono-font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;--color-popover:rgb(var(--popover));--color-popover-foreground:rgb(var(--popover-foreground));--color-border:rgb(var(--border))}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}*{border-color:rgb(var(--border));outline-color:rgb(var(--ring))}@supports (color:color-mix(in lab,red,red)){*{outline-color:color-mix(in oklab,rgb(var(--ring)) 50%,transparent)}}body{background-color:rgb(var(--background));color:rgb(var(--foreground));-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:Aspekta,ui-sans-serif,system-ui,sans-serif}}@layer components;@layer utilities{.\@container\/card-header{container:card-header/inline-size}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{inset-inline:0}.inset-y-0{inset-block:0}.-top-2{top:calc(var(--spacing) * -2)}.top-0{top:0}.top-1\/2,.top-\[50\%\]{top:50%}.-right-2{right:calc(var(--spacing) * -2)}.right-1{right:var(--spacing)}.right-2{right:calc(var(--spacing) * 2)}.right-8{right:calc(var(--spacing) * 8)}.left-1\/2{left:50%}.left-2{left:calc(var(--spacing) * 2)}.left-\[50\%\]{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-50{z-index:50}.col-start-2{grid-column-start:2}.row-span-2{grid-row:span 2/span 2}.row-start-1{grid-row-start:1}.-mx-1{margin-inline:calc(var(--spacing) * -1)}.mx-auto{margin-inline:auto}.my-1{margin-block:var(--spacing)}.-mt-2{margin-top:calc(var(--spacing) * -2)}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mr-1{margin-right:var(--spacing)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.ml-1{margin-left:var(--spacing)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-auto{margin-left:auto}.block{display:block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.table-caption{display:table-caption}.table-cell{display:table-cell}.table-row{display:table-row}.field-sizing-content{field-sizing:content}.size-2{width:calc(var(--spacing) * 2);height:calc(var(--spacing) * 2)}.size-2\.5{width:calc(var(--spacing) * 2.5);height:calc(var(--spacing) * 2.5)}.size-3{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-4{width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.size-5{width:calc(var(--spacing) * 5);height:calc(var(--spacing) * 5)}.size-6{width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.size-8{width:calc(var(--spacing) * 8);height:calc(var(--spacing) * 8)}.size-9{width:calc(var(--spacing) * 9);height:calc(var(--spacing) * 9)}.size-10{width:calc(var(--spacing) * 10);height:calc(var(--spacing) * 10)}.h-0\.5{height:calc(var(--spacing) * .5)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-9{height:calc(var(--spacing) * 9)}.h-10{height:calc(var(--spacing) * 10)}.h-16{height:calc(var(--spacing) * 16)}.h-\[1\.15rem\]{height:1.15rem}.h-\[calc\(100\%-1px\)\]{height:calc(100% - 1px)}.h-\[var\(--radix-select-trigger-height\)\]{height:var(--radix-select-trigger-height)}.h-full{height:100%}.h-px{height:1px}.max-h-\(--radix-dropdown-menu-content-available-height\){max-height:var(--radix-dropdown-menu-content-available-height)}.max-h-\(--radix-select-content-available-height\){max-height:var(--radix-select-content-available-height)}.max-h-40{max-height:calc(var(--spacing) * 40)}.max-h-48{max-height:calc(var(--spacing) * 48)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-16{min-height:calc(var(--spacing) * 16)}.min-h-screen{min-height:100vh}.w-3{width:calc(var(--spacing) * 3)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-26{width:calc(var(--spacing) * 26)}.w-31{width:calc(var(--spacing) * 31)}.w-32{width:calc(var(--spacing) * 32)}.w-36{width:calc(var(--spacing) * 36)}.w-40{width:calc(var(--spacing) * 40)}.w-44{width:calc(var(--spacing) * 44)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-auto{width:auto}.w-fit{width:fit-content}.w-full{width:100%}.max-w-6xl{max-width:var(--container-6xl)}.max-w-36{max-width:calc(var(--spacing) * 36)}.max-w-40{max-width:calc(var(--spacing) * 40)}.max-w-44{max-width:calc(var(--spacing) * 44)}.max-w-\[85\%\]{max-width:85%}.max-w-\[calc\(100\%-2rem\)\]{max-width:calc(100% - 2rem)}.max-w-full{max-width:100%}.max-w-sm{max-width:var(--container-sm)}.min-w-0{min-width:0}.min-w-32{min-width:calc(var(--spacing) * 32)}.min-w-36{min-width:calc(var(--spacing) * 36)}.min-w-48{min-width:calc(var(--spacing) * 48)}.min-w-\[8rem\]{min-width:8rem}.min-w-\[var\(--radix-select-trigger-width\)\]{min-width:var(--radix-select-trigger-width)}.flex-1{flex:1}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.caption-bottom{caption-side:bottom}.origin-\(--radix-dropdown-menu-content-transform-origin\){transform-origin:var(--radix-dropdown-menu-content-transform-origin)}.origin-\(--radix-select-content-transform-origin\){transform-origin:var(--radix-select-content-transform-origin)}.-translate-x-1\/2{--tw-translate-x: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-\[-50\%\]{--tw-translate-x:-50%;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y: -50% ;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-\[-50\%\]{--tw-translate-y:-50%;translate:var(--tw-translate-x) var(--tw-translate-y)}.rotate-180{rotate:180deg}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.scroll-my-1{scroll-margin-block:var(--spacing)}.auto-rows-min{grid-auto-rows:min-content}.\[grid-template-columns\:repeat\(auto-fit\,minmax\(260px\,1fr\)\)\]{grid-template-columns:repeat(auto-fit,minmax(260px,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-\[minmax\(6rem\,14rem\)_1fr_auto\]{grid-template-columns:minmax(6rem,14rem) 1fr auto}.grid-rows-\[auto_auto\]{grid-template-rows:auto auto}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-row{flex-direction:row}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-4{column-gap:calc(var(--spacing) * 4)}.gap-x-6{column-gap:calc(var(--spacing) * 6)}.gap-x-8{column-gap:calc(var(--spacing) * 8)}.gap-y-1{row-gap:var(--spacing)}.gap-y-2{row-gap:calc(var(--spacing) * 2)}.gap-y-3{row-gap:calc(var(--spacing) * 3)}.gap-y-4{row-gap:calc(var(--spacing) * 4)}.self-start{align-self:flex-start}.justify-self-end{justify-self:flex-end}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-x-hidden{overflow-x:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[4px\]{border-radius:4px}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:calc(var(--radius) + 2px)}.rounded-md{border-radius:var(--radius)}.rounded-sm{border-radius:calc(var(--radius) - 2px)}.rounded-xl{border-radius:calc(var(--radius) + 4px)}.rounded-xs{border-radius:var(--radius-xs)}.border{border-style:var(--tw-border-style);border-width:1px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-border{border-color:rgb(var(--border))}.border-foreground{border-color:rgb(var(--foreground))}.border-input{border-color:rgb(var(--input))}.border-primary\/40{border-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){.border-primary\/40{border-color:color-mix(in oklab,rgb(var(--primary)) 40%,transparent)}}.border-transparent{border-color:#0000}.bg-\[\#1a7f37\]{background-color:#1a7f37}.bg-\[\#3b82f6\]{background-color:#3b82f6}.bg-\[\#4b5563\]{background-color:#4b5563}.bg-\[\#9a6700\]{background-color:#9a6700}.bg-\[\#22c55e\]{background-color:#22c55e}.bg-\[\#0969da\]{background-color:#0969da}.bg-\[\#a855f7\]{background-color:#a855f7}.bg-\[\#f97316\]{background-color:#f97316}.bg-\[rgb\(var\(--border\)\)\]{background-color:rgb(var(--border))}.bg-accent{background-color:rgb(var(--accent))}.bg-background{background-color:rgb(var(--background))}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab,red,red)){.bg-black\/50{background-color:color-mix(in oklab,var(--color-black) 50%,transparent)}}.bg-border{background-color:rgb(var(--border))}.bg-card{background-color:rgb(var(--card))}.bg-chart-1{background-color:rgb(var(--chart-1))}.bg-chart-2{background-color:rgb(var(--chart-2))}.bg-chart-3{background-color:rgb(var(--chart-3))}.bg-chart-5{background-color:rgb(var(--chart-5))}.bg-destructive{background-color:rgb(var(--destructive))}.bg-foreground\/5{background-color:rgb(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.bg-foreground\/5{background-color:color-mix(in oklab,rgb(var(--foreground)) 5%,transparent)}}.bg-green-500{background-color:var(--color-green-500)}.bg-muted{background-color:rgb(var(--muted))}.bg-muted-foreground{background-color:rgb(var(--muted-foreground))}.bg-muted\/30{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/30{background-color:color-mix(in oklab,rgb(var(--muted)) 30%,transparent)}}.bg-muted\/50{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.bg-muted\/50{background-color:color-mix(in oklab,rgb(var(--muted)) 50%,transparent)}}.bg-popover{background-color:rgb(var(--popover))}.bg-primary,.bg-primary\/5{background-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){.bg-primary\/5{background-color:color-mix(in oklab,rgb(var(--primary)) 5%,transparent)}}.bg-red-500{background-color:var(--color-red-500)}.bg-secondary{background-color:rgb(var(--secondary))}.bg-transparent{background-color:#0000}.bg-yellow-500{background-color:var(--color-yellow-500)}.fill-border{fill:rgb(var(--border))}.fill-chart-1{fill:rgb(var(--chart-1))}.fill-chart-2{fill:rgb(var(--chart-2))}.fill-chart-3{fill:rgb(var(--chart-3))}.fill-chart-5{fill:rgb(var(--chart-5))}.fill-current{fill:currentColor}.fill-foreground,.fill-foreground\/5{fill:rgb(var(--foreground))}@supports (color:color-mix(in lab,red,red)){.fill-foreground\/5{fill:color-mix(in oklab,rgb(var(--foreground)) 5%,transparent)}}.fill-muted-foreground{fill:rgb(var(--muted-foreground))}.stroke-border{stroke:rgb(var(--border))}.stroke-card{stroke:rgb(var(--card))}.stroke-chart-1{stroke:rgb(var(--chart-1))}.stroke-chart-2{stroke:rgb(var(--chart-2))}.stroke-muted-foreground\/50{stroke:rgb(var(--muted-foreground))}@supports (color:color-mix(in lab,red,red)){.stroke-muted-foreground\/50{stroke:color-mix(in oklab,rgb(var(--muted-foreground)) 50%,transparent)}}.object-cover{object-fit:cover}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-\[3px\]{padding:3px}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0{padding-block:0}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-8{padding-block:calc(var(--spacing) * 8)}.py-12{padding-block:calc(var(--spacing) * 12)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pr-0{padding-right:0}.pr-1{padding-right:var(--spacing)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-6{padding-right:calc(var(--spacing) * 6)}.pr-8{padding-right:calc(var(--spacing) * 8)}.pr-14{padding-right:calc(var(--spacing) * 14)}.pb-2{padding-bottom:calc(var(--spacing) * 2)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-8{padding-left:calc(var(--spacing) * 8)}.pl-\[18px\]{padding-left:18px}.pl-\[26px\]{padding-left:26px}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.align-middle{vertical-align:middle}.align-top{vertical-align:top}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace}.font-sans{font-family:Aspekta,ui-sans-serif,system-ui,sans-serif}.font-serif{font-family:"Source Serif 4",Source Serif Pro,Georgia,serif}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-sm\/relaxed{font-size:var(--text-sm);line-height:var(--leading-relaxed)}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.leading-none{--tw-leading:1;line-height:1}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.tracking-widest{--tw-tracking:var(--tracking-widest);letter-spacing:var(--tracking-widest)}.text-balance{text-wrap:balance}.wrap-anywhere{overflow-wrap:anywhere}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent-foreground{color:rgb(var(--accent-foreground))}.text-card-foreground{color:rgb(var(--card-foreground))}.text-current{color:currentColor}.text-destructive{color:rgb(var(--destructive))}.text-foreground{color:rgb(var(--foreground))}.text-muted-foreground{color:rgb(var(--muted-foreground))}.text-popover-foreground{color:rgb(var(--popover-foreground))}.text-primary{color:rgb(var(--primary))}.text-primary-foreground{color:rgb(var(--primary-foreground))}.text-secondary-foreground{color:rgb(var(--secondary-foreground))}.text-white{color:var(--color-white)}.text-yellow-600{color:var(--color-yellow-600)}.lowercase{text-transform:lowercase}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal,) var(--tw-slashed-zero,) var(--tw-numeric-figure,) var(--tw-numeric-spacing,) var(--tw-numeric-fraction,)}.underline-offset-2{text-underline-offset:2px}.underline-offset-4{text-underline-offset:4px}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.shadow-xs{--tw-shadow:0 1px 2px 0 var(--tw-shadow-color,#0000000d);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.ring-0{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.outline-hidden{--tw-outline-style:none;outline-style:none}@media(forced-colors:active){.outline-hidden{outline-offset:2px;outline:2px solid #0000}}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-\[color\,box-shadow\]{transition-property:color,box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-shadow{transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-none{transition-property:none}.duration-200{--tw-duration:.2s;transition-duration:.2s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.running{animation-play-state:running}.group-data-\[disabled\=true\]\:pointer-events-none:is(:where(.group)[data-disabled=true] *){pointer-events:none}.group-data-\[disabled\=true\]\:opacity-50:is(:where(.group)[data-disabled=true] *){opacity:.5}.peer-disabled\:cursor-not-allowed:is(:where(.peer):disabled~*){cursor:not-allowed}.peer-disabled\:opacity-50:is(:where(.peer):disabled~*){opacity:.5}.selection\:bg-primary ::selection{background-color:rgb(var(--primary))}.selection\:bg-primary::selection{background-color:rgb(var(--primary))}.selection\:text-primary-foreground ::selection{color:rgb(var(--primary-foreground))}.selection\:text-primary-foreground::selection{color:rgb(var(--primary-foreground))}.file\:inline-flex::file-selector-button{display:inline-flex}.file\:h-7::file-selector-button{height:calc(var(--spacing) * 7)}.file\:border-0::file-selector-button{border-style:var(--tw-border-style);border-width:0}.file\:bg-transparent::file-selector-button{background-color:#0000}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-foreground::file-selector-button{color:rgb(var(--foreground))}.placeholder\:text-muted-foreground::placeholder{color:rgb(var(--muted-foreground))}@media(hover:hover){.hover\:bg-accent:hover{background-color:rgb(var(--accent))}.hover\:bg-destructive\/90:hover{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-destructive\/90:hover{background-color:color-mix(in oklab,rgb(var(--destructive)) 90%,transparent)}}.hover\:bg-muted\/30:hover{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/30:hover{background-color:color-mix(in oklab,rgb(var(--muted)) 30%,transparent)}}.hover\:bg-muted\/50:hover{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-muted\/50:hover{background-color:color-mix(in oklab,rgb(var(--muted)) 50%,transparent)}}.hover\:bg-primary\/90:hover{background-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,rgb(var(--primary)) 90%,transparent)}}.hover\:bg-secondary\/80:hover{background-color:rgb(var(--secondary))}@supports (color:color-mix(in lab,red,red)){.hover\:bg-secondary\/80:hover{background-color:color-mix(in oklab,rgb(var(--secondary)) 80%,transparent)}}.hover\:text-accent-foreground:hover{color:rgb(var(--accent-foreground))}.hover\:text-foreground:hover{color:rgb(var(--foreground))}.hover\:underline:hover{text-decoration-line:underline}}.focus\:bg-accent:focus{background-color:rgb(var(--accent))}.focus\:text-accent-foreground:focus{color:rgb(var(--accent-foreground))}.focus-visible\:border-ring:focus-visible{border-color:rgb(var(--ring))}.focus-visible\:stroke-ring:focus-visible{stroke:rgb(var(--ring))}.focus-visible\:\[stroke-width\:2\]:focus-visible{stroke-width:2px}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-\[3px\]:focus-visible{--tw-ring-shadow:var(--tw-ring-inset,) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus-visible\:ring-destructive\/20:focus-visible{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-destructive\/20:focus-visible{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 20%, transparent)}}.focus-visible\:ring-ring:focus-visible,.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:rgb(var(--ring))}@supports (color:color-mix(in lab,red,red)){.focus-visible\:ring-ring\/50:focus-visible{--tw-ring-color:color-mix(in oklab, rgb(var(--ring)) 50%, transparent)}}.focus-visible\:outline-1:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-ring:focus-visible{outline-color:rgb(var(--ring))}.disabled\:pointer-events-none:disabled{pointer-events:none}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}.has-data-\[slot\=card-action\]\:grid-cols-\[1fr_auto\]:has([data-slot=card-action]){grid-template-columns:1fr auto}.has-\[\>svg\]\:px-2\.5:has(>svg){padding-inline:calc(var(--spacing) * 2.5)}.has-\[\>svg\]\:px-3:has(>svg){padding-inline:calc(var(--spacing) * 3)}.has-\[\>svg\]\:px-4:has(>svg){padding-inline:calc(var(--spacing) * 4)}.aria-invalid\:border-destructive[aria-invalid=true]{border-color:rgb(var(--destructive))}.aria-invalid\:ring-destructive\/20[aria-invalid=true]{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.aria-invalid\:ring-destructive\/20[aria-invalid=true]{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 20%, transparent)}}.data-\[disabled\]\:pointer-events-none[data-disabled]{pointer-events:none}.data-\[disabled\]\:opacity-50[data-disabled]{opacity:.5}.data-\[inset\]\:pl-8[data-inset]{padding-left:calc(var(--spacing) * 8)}.data-\[orientation\=horizontal\]\:h-px[data-orientation=horizontal]{height:1px}.data-\[orientation\=horizontal\]\:w-full[data-orientation=horizontal]{width:100%}.data-\[orientation\=vertical\]\:h-full[data-orientation=vertical]{height:100%}.data-\[orientation\=vertical\]\:w-px[data-orientation=vertical]{width:1px}.data-\[placeholder\]\:text-muted-foreground[data-placeholder]{color:rgb(var(--muted-foreground))}.data-\[side\=bottom\]\:translate-y-1[data-side=bottom]{--tw-translate-y:var(--spacing);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=bottom\]\:slide-in-from-top-2[data-side=bottom]{--tw-enter-translate-y:calc(2*var(--spacing)*-1)}.data-\[side\=left\]\:-translate-x-1[data-side=left]{--tw-translate-x:calc(var(--spacing) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=left\]\:slide-in-from-right-2[data-side=left]{--tw-enter-translate-x:calc(2*var(--spacing))}.data-\[side\=right\]\:translate-x-1[data-side=right]{--tw-translate-x:var(--spacing);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=right\]\:slide-in-from-left-2[data-side=right]{--tw-enter-translate-x:calc(2*var(--spacing)*-1)}.data-\[side\=top\]\:-translate-y-1[data-side=top]{--tw-translate-y:calc(var(--spacing) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[side\=top\]\:slide-in-from-bottom-2[data-side=top]{--tw-enter-translate-y:calc(2*var(--spacing))}.data-\[size\=default\]\:h-9[data-size=default]{height:calc(var(--spacing) * 9)}.data-\[size\=sm\]\:h-8[data-size=sm]{height:calc(var(--spacing) * 8)}:is(.\*\:data-\[slot\=select-value\]\:line-clamp-1>*)[data-slot=select-value]{-webkit-line-clamp:1;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}:is(.\*\:data-\[slot\=select-value\]\:flex>*)[data-slot=select-value]{display:flex}:is(.\*\:data-\[slot\=select-value\]\:items-center>*)[data-slot=select-value]{align-items:center}:is(.\*\:data-\[slot\=select-value\]\:gap-2>*)[data-slot=select-value]{gap:calc(var(--spacing) * 2)}.data-\[state\=active\]\:bg-card[data-state=active]{background-color:rgb(var(--card))}.data-\[state\=active\]\:shadow-sm[data-state=active]{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.data-\[state\=checked\]\:translate-x-\[calc\(100\%-2px\)\][data-state=checked]{--tw-translate-x: calc(100% - 2px) ;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[state\=checked\]\:border-primary[data-state=checked]{border-color:rgb(var(--primary))}.data-\[state\=checked\]\:bg-primary[data-state=checked]{background-color:rgb(var(--primary))}.data-\[state\=checked\]\:text-primary-foreground[data-state=checked]{color:rgb(var(--primary-foreground))}.data-\[state\=closed\]\:animate-out[data-state=closed]{animation:exit var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,forwards)}.data-\[state\=closed\]\:fade-out-0[data-state=closed]{--tw-exit-opacity:0}.data-\[state\=closed\]\:zoom-out-95[data-state=closed]{--tw-exit-scale:.95}.data-\[state\=inactive\]\:hidden[data-state=inactive]{display:none}.data-\[state\=open\]\:animate-in[data-state=open]{animation:enter var(--tw-animation-duration,var(--tw-duration,.15s))var(--tw-ease,ease)var(--tw-animation-delay,0s)var(--tw-animation-iteration-count,1)var(--tw-animation-direction,normal)var(--tw-animation-fill-mode,forwards)}.data-\[state\=open\]\:bg-accent[data-state=open]{background-color:rgb(var(--accent))}.data-\[state\=open\]\:text-accent-foreground[data-state=open]{color:rgb(var(--accent-foreground))}.data-\[state\=open\]\:fade-in-0[data-state=open]{--tw-enter-opacity:0}.data-\[state\=open\]\:zoom-in-95[data-state=open]{--tw-enter-scale:.95}.data-\[state\=selected\]\:bg-muted[data-state=selected]{background-color:rgb(var(--muted))}.data-\[state\=unchecked\]\:translate-x-0[data-state=unchecked]{--tw-translate-x:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.data-\[state\=unchecked\]\:bg-\[\#7F7F79\][data-state=unchecked]{background-color:#7f7f79}.data-\[variant\=destructive\]\:text-destructive[data-variant=destructive]{color:rgb(var(--destructive))}.data-\[variant\=destructive\]\:focus\:bg-destructive\/10[data-variant=destructive]:focus{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.data-\[variant\=destructive\]\:focus\:bg-destructive\/10[data-variant=destructive]:focus{background-color:color-mix(in oklab,rgb(var(--destructive)) 10%,transparent)}}.data-\[variant\=destructive\]\:focus\:text-destructive[data-variant=destructive]:focus{color:rgb(var(--destructive))}@media(min-width:40rem){.sm\:col-span-2{grid-column:span 2/span 2}.sm\:max-w-lg{max-width:var(--container-lg)}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:justify-end{justify-content:flex-end}.sm\:text-left{text-align:left}}@media(min-width:48rem){.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.md\:p-12{padding:calc(var(--spacing) * 12)}.md\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media(min-width:64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}.dark\:border-input:is(.dark *){border-color:rgb(var(--input))}.dark\:bg-chart-4:is(.dark *){background-color:rgb(var(--chart-4))}.dark\:bg-destructive\/60:is(.dark *){background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:bg-destructive\/60:is(.dark *){background-color:color-mix(in oklab,rgb(var(--destructive)) 60%,transparent)}}.dark\:bg-input\/30:is(.dark *){background-color:rgb(var(--input))}@supports (color:color-mix(in lab,red,red)){.dark\:bg-input\/30:is(.dark *){background-color:color-mix(in oklab,rgb(var(--input)) 30%,transparent)}}.dark\:fill-chart-4:is(.dark *){fill:rgb(var(--chart-4))}.dark\:stroke-chart-4:is(.dark *){stroke:rgb(var(--chart-4))}.dark\:text-muted-foreground:is(.dark *){color:rgb(var(--muted-foreground))}.dark\:text-yellow-400:is(.dark *){color:var(--color-yellow-400)}@media(hover:hover){.dark\:hover\:bg-accent\/50:is(.dark *):hover{background-color:rgb(var(--accent))}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-accent\/50:is(.dark *):hover{background-color:color-mix(in oklab,rgb(var(--accent)) 50%,transparent)}}.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:rgb(var(--input))}@supports (color:color-mix(in lab,red,red)){.dark\:hover\:bg-input\/50:is(.dark *):hover{background-color:color-mix(in oklab,rgb(var(--input)) 50%,transparent)}}}.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:focus-visible\:ring-destructive\/40:is(.dark *):focus-visible{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 40%, transparent)}}.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:aria-invalid\:ring-destructive\/40:is(.dark *)[aria-invalid=true]{--tw-ring-color:color-mix(in oklab, rgb(var(--destructive)) 40%, transparent)}}.dark\:data-\[state\=active\]\:border-input:is(.dark *)[data-state=active]{border-color:rgb(var(--input))}.dark\:data-\[state\=active\]\:bg-input\/30:is(.dark *)[data-state=active]{background-color:rgb(var(--input))}@supports (color:color-mix(in lab,red,red)){.dark\:data-\[state\=active\]\:bg-input\/30:is(.dark *)[data-state=active]{background-color:color-mix(in oklab,rgb(var(--input)) 30%,transparent)}}.dark\:data-\[state\=active\]\:text-foreground:is(.dark *)[data-state=active]{color:rgb(var(--foreground))}.dark\:data-\[state\=checked\]\:bg-primary:is(.dark *)[data-state=checked]{background-color:rgb(var(--primary))}.dark\:data-\[state\=checked\]\:bg-primary-foreground:is(.dark *)[data-state=checked]{background-color:rgb(var(--primary-foreground))}.dark\:data-\[state\=unchecked\]\:bg-foreground:is(.dark *)[data-state=unchecked]{background-color:rgb(var(--foreground))}.dark\:data-\[state\=unchecked\]\:bg-input:is(.dark *)[data-state=unchecked]{background-color:rgb(var(--input))}.dark\:data-\[variant\=destructive\]\:focus\:bg-destructive\/20:is(.dark *)[data-variant=destructive]:focus{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){.dark\:data-\[variant\=destructive\]\:focus\:bg-destructive\/20:is(.dark *)[data-variant=destructive]:focus{background-color:color-mix(in oklab,rgb(var(--destructive)) 20%,transparent)}}.\[\&_svg\]\:pointer-events-none svg{pointer-events:none}.\[\&_svg\]\:shrink-0 svg{flex-shrink:0}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-4 svg:not([class*=size-]){width:calc(var(--spacing) * 4);height:calc(var(--spacing) * 4)}.\[\&_svg\:not\(\[class\*\=\'size-\'\]\)\]\:size-6 svg:not([class*=size-]){width:calc(var(--spacing) * 6);height:calc(var(--spacing) * 6)}.\[\&_svg\:not\(\[class\*\=\'text-\'\]\)\]\:text-muted-foreground svg:not([class*=text-]){color:rgb(var(--muted-foreground))}.\[\&_tr\]\:border-b tr{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.\[\&_tr\:last-child\]\:border-0 tr:last-child{border-style:var(--tw-border-style);border-width:0}.\[\&\:has\(\[role\=checkbox\]\)\]\:pr-0:has([role=checkbox]){padding-right:0}.\[\.border-b\]\:pb-6.border-b{padding-bottom:calc(var(--spacing) * 6)}.\[\.border-t\]\:pt-6.border-t{padding-top:calc(var(--spacing) * 6)}:is(.\*\:\[span\]\:last\:flex>*):is(span):last-child{display:flex}:is(.\*\:\[span\]\:last\:items-center>*):is(span):last-child{align-items:center}:is(.\*\:\[span\]\:last\:gap-2>*):is(span):last-child{gap:calc(var(--spacing) * 2)}:is(.data-\[variant\=destructive\]\:\*\:\[svg\]\:\!text-destructive[data-variant=destructive]>*):is(svg){color:rgb(var(--destructive))!important}.\[\&\>\[role\=checkbox\]\]\:translate-y-\[2px\]>[role=checkbox]{--tw-translate-y:2px;translate:var(--tw-translate-x) var(--tw-translate-y)}.\[\&\>a\]\:underline>a{text-decoration-line:underline}.\[\&\>a\]\:underline-offset-4>a{text-underline-offset:4px}.\[\&\>a\:hover\]\:text-primary>a:hover{color:rgb(var(--primary))}.\[\&\>svg\]\:pointer-events-none>svg{pointer-events:none}.\[\&\>svg\]\:size-3>svg{width:calc(var(--spacing) * 3);height:calc(var(--spacing) * 3)}.\[\&\>svg\]\:size-3\.5>svg{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.\[\&\>tr\]\:last\:border-b-0>tr:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media(hover:hover){a.\[a\&\]\:hover\:bg-\[\#1a7f37\]\/90:hover{background-color:#1a7f37e6}a.\[a\&\]\:hover\:bg-\[\#3b82f6\]\/90:hover{background-color:#3b82f6e6}a.\[a\&\]\:hover\:bg-\[\#4b5563\]\/90:hover{background-color:#4b5563e6}a.\[a\&\]\:hover\:bg-\[\#9a6700\]\/90:hover{background-color:#9a6700e6}a.\[a\&\]\:hover\:bg-\[\#22c55e\]\/90:hover{background-color:#22c55ee6}a.\[a\&\]\:hover\:bg-\[\#0969da\]\/90:hover{background-color:#0969dae6}a.\[a\&\]\:hover\:bg-\[\#a855f7\]\/90:hover{background-color:#a855f7e6}a.\[a\&\]\:hover\:bg-\[\#f97316\]\/90:hover{background-color:#f97316e6}a.\[a\&\]\:hover\:bg-accent\/10:hover{background-color:rgb(var(--accent))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-accent\/10:hover{background-color:color-mix(in oklab,rgb(var(--accent)) 10%,transparent)}}a.\[a\&\]\:hover\:bg-destructive\/90:hover{background-color:rgb(var(--destructive))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-destructive\/90:hover{background-color:color-mix(in oklab,rgb(var(--destructive)) 90%,transparent)}}a.\[a\&\]\:hover\:bg-muted:hover,a.\[a\&\]\:hover\:bg-muted\/80:hover{background-color:rgb(var(--muted))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-muted\/80:hover{background-color:color-mix(in oklab,rgb(var(--muted)) 80%,transparent)}}a.\[a\&\]\:hover\:bg-primary\/90:hover{background-color:rgb(var(--primary))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-primary\/90:hover{background-color:color-mix(in oklab,rgb(var(--primary)) 90%,transparent)}}a.\[a\&\]\:hover\:bg-secondary\/90:hover{background-color:rgb(var(--secondary))}@supports (color:color-mix(in lab,red,red)){a.\[a\&\]\:hover\:bg-secondary\/90:hover{background-color:color-mix(in oklab,rgb(var(--secondary)) 90%,transparent)}}a.\[a\&\]\:hover\:text-accent-foreground:hover{color:rgb(var(--accent-foreground))}}}@property --tw-animation-delay{syntax:"*";inherits:false;initial-value:0s}@property --tw-animation-direction{syntax:"*";inherits:false;initial-value:normal}@property --tw-animation-duration{syntax:"*";inherits:false}@property --tw-animation-fill-mode{syntax:"*";inherits:false;initial-value:forwards}@property --tw-animation-iteration-count{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-enter-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-enter-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-opacity{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-rotate{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-scale{syntax:"*";inherits:false;initial-value:1}@property --tw-exit-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-exit-translate-y{syntax:"*";inherits:false;initial-value:0}@font-face{font-family:Aspekta;font-style:normal;font-weight:400;font-display:swap;src:url(/fonts/Aspekta-400.woff2)format("woff2")}@font-face{font-family:Aspekta;font-style:normal;font-weight:500;font-display:swap;src:url(/fonts/Aspekta-500.woff2)format("woff2")}@font-face{font-family:Aspekta;font-style:normal;font-weight:600;font-display:swap;src:url(/fonts/Aspekta-600.woff2)format("woff2")}@font-face{font-family:Aspekta;font-style:normal;font-weight:700;font-display:swap;src:url(/fonts/Aspekta-700.woff2)format("woff2")}:root{--background:240 240 236;--foreground:22 22 20;--card:249 249 247;--card-foreground:22 22 20;--popover:249 249 247;--popover-foreground:22 22 20;--primary:217 94 42;--primary-foreground:249 249 247;--secondary:240 240 236;--secondary-foreground:47 47 44;--muted:240 240 236;--muted-foreground:87 87 83;--accent:221 221 215;--accent-foreground:22 22 20;--destructive:180 50 50;--destructive-foreground:249 249 247;--border:196 196 189;--input:196 196 189;--ring:217 94 42;--chart-1:217 94 42;--chart-2:87 87 83;--chart-3:127 127 121;--chart-4:166 166 159;--chart-5:47 47 44;--radius:.375rem}.dark{--background:22 22 20;--foreground:249 249 247;--card:47 47 44;--card-foreground:249 249 247;--popover:47 47 44;--popover-foreground:249 249 247;--primary:217 94 42;--primary-foreground:249 249 247;--secondary:87 87 83;--secondary-foreground:249 249 247;--muted:87 87 83;--muted-foreground:196 196 189;--accent:87 87 83;--accent-foreground:249 249 247;--destructive:180 50 50;--destructive-foreground:249 249 247;--border:87 87 83;--input:87 87 83;--ring:217 94 42;--chart-1:217 94 42;--chart-2:196 196 189;--chart-3:166 166 159;--chart-4:127 127 121;--chart-5:240 240 236}.chat-markdown{overflow-wrap:break-word;line-height:1.55}.chat-markdown>:first-child{margin-top:0}.chat-markdown>:last-child{margin-bottom:0}.chat-markdown p{margin:.5em 0}.chat-markdown h1,.chat-markdown h2,.chat-markdown h3,.chat-markdown h4,.chat-markdown h5,.chat-markdown h6{margin:1em 0 .4em;font-size:1em;font-weight:600;line-height:1.3}.chat-markdown h1{font-size:1.15em}.chat-markdown h2{font-size:1.08em}.chat-markdown ul,.chat-markdown ol{margin:.5em 0;padding-left:1.4em}.chat-markdown ul{list-style:outside}.chat-markdown ol{list-style:decimal}.chat-markdown li,.chat-markdown li>ul,.chat-markdown li>ol{margin:.2em 0}.chat-markdown li::marker{color:rgb(var(--muted-foreground))}.chat-markdown code{font-family:var(--font-mono);background:rgb(var(--muted));border:1px solid rgb(var(--border) / .6);border-radius:4px;padding:.1em .35em;font-size:.9em}.chat-markdown pre{background:rgb(var(--muted));border:1px solid rgb(var(--border) / .6);border-radius:var(--radius);margin:.6em 0;padding:.6em .75em;overflow-x:auto}.chat-markdown pre code{background:0 0;border:none;padding:0;font-size:.85em;line-height:1.5}.chat-markdown blockquote{border-left:3px solid rgb(var(--border));color:rgb(var(--muted-foreground));margin:.6em 0;padding:.1em 0 .1em .9em}.chat-markdown a{color:rgb(var(--primary));text-underline-offset:2px;text-decoration:underline}.chat-markdown table{border-collapse:collapse;margin:.6em 0;font-size:.95em;display:block;overflow-x:auto}.chat-markdown th,.chat-markdown td{border:1px solid rgb(var(--border));text-align:left;padding:4px 10px}.chat-markdown th{background:rgb(var(--muted));font-weight:600}.chat-markdown hr{border:none;border-top:1px solid rgb(var(--border));margin:1em 0}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}@keyframes enter{0%{opacity:var(--tw-enter-opacity,1);transform:translate3d(var(--tw-enter-translate-x,0),var(--tw-enter-translate-y,0),0)scale3d(var(--tw-enter-scale,1),var(--tw-enter-scale,1),var(--tw-enter-scale,1))rotate(var(--tw-enter-rotate,0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity,1);transform:translate3d(var(--tw-exit-translate-x,0),var(--tw-exit-translate-y,0),0)scale3d(var(--tw-exit-scale,1),var(--tw-exit-scale,1),var(--tw-exit-scale,1))rotate(var(--tw-exit-rotate,0))}} diff --git a/internal/server/uidist/assets/index-Zsi56dHY.js b/internal/server/uidist/assets/index-Zsi56dHY.js deleted file mode 100644 index ce925d3..0000000 --- a/internal/server/uidist/assets/index-Zsi56dHY.js +++ /dev/null @@ -1,296 +0,0 @@ -var z2=Object.defineProperty;var L2=(e,r,a)=>r in e?z2(e,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[r]=a;var uh=(e,r,a)=>L2(e,typeof r!="symbol"?r+"":r,a);function U2(e,r){for(var a=0;al[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))l(o);new MutationObserver(o=>{for(const c of o)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&l(d)}).observe(document,{childList:!0,subtree:!0});function a(o){const c={};return o.integrity&&(c.integrity=o.integrity),o.referrerPolicy&&(c.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?c.credentials="include":o.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function l(o){if(o.ep)return;o.ep=!0;const c=a(o);fetch(o.href,c)}})();function bc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ch={exports:{}},Ys={};/** - * @license React - * react-jsx-runtime.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Ly;function B2(){if(Ly)return Ys;Ly=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function a(l,o,c){var d=null;if(c!==void 0&&(d=""+c),o.key!==void 0&&(d=""+o.key),"key"in o){c={};for(var f in o)f!=="key"&&(c[f]=o[f])}else c=o;return o=c.ref,{$$typeof:e,type:l,key:d,ref:o!==void 0?o:null,props:c}}return Ys.Fragment=r,Ys.jsx=a,Ys.jsxs=a,Ys}var Uy;function I2(){return Uy||(Uy=1,ch.exports=B2()),ch.exports}var s=I2(),dh={exports:{}},Fe={};/** - * @license React - * react.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var By;function q2(){if(By)return Fe;By=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),l=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),x=Symbol.for("react.activity"),b=Symbol.iterator;function y(U){return U===null||typeof U!="object"?null:(U=b&&U[b]||U["@@iterator"],typeof U=="function"?U:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,T={};function C(U,V,M){this.props=U,this.context=V,this.refs=T,this.updater=M||k}C.prototype.isReactComponent={},C.prototype.setState=function(U,V){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,V,"setState")},C.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function R(){}R.prototype=C.prototype;function D(U,V,M){this.props=U,this.context=V,this.refs=T,this.updater=M||k}var I=D.prototype=new R;I.constructor=D,j(I,C.prototype),I.isPureReactComponent=!0;var O=Array.isArray;function E(){}var N={H:null,A:null,T:null,S:null},L=Object.prototype.hasOwnProperty;function X(U,V,M){var se=M.ref;return{$$typeof:e,type:U,key:V,ref:se!==void 0?se:null,props:M}}function H(U,V){return X(U.type,V,U.props)}function P(U){return typeof U=="object"&&U!==null&&U.$$typeof===e}function K(U){var V={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(M){return V[M]})}var ue=/\/+/g;function le(U,V){return typeof U=="object"&&U!==null&&U.key!=null?K(""+U.key):V.toString(36)}function W(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(E,E):(U.status="pending",U.then(function(V){U.status==="pending"&&(U.status="fulfilled",U.value=V)},function(V){U.status==="pending"&&(U.status="rejected",U.reason=V)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function B(U,V,M,se,Y){var ce=typeof U;(ce==="undefined"||ce==="boolean")&&(U=null);var re=!1;if(U===null)re=!0;else switch(ce){case"bigint":case"string":case"number":re=!0;break;case"object":switch(U.$$typeof){case e:case r:re=!0;break;case v:return re=U._init,B(re(U._payload),V,M,se,Y)}}if(re)return Y=Y(U),re=se===""?"."+le(U,0):se,O(Y)?(M="",re!=null&&(M=re.replace(ue,"$&/")+"/"),B(Y,V,M,"",function(we){return we})):Y!=null&&(P(Y)&&(Y=H(Y,M+(Y.key==null||U&&U.key===Y.key?"":(""+Y.key).replace(ue,"$&/")+"/")+re)),V.push(Y)),1;re=0;var ye=se===""?".":se+":";if(O(U))for(var fe=0;fe>>1,A=B[Z];if(0>>1;Zo(M,ae))seo(Y,M)?(B[Z]=Y,B[se]=ae,Z=se):(B[Z]=M,B[V]=ae,Z=V);else if(seo(Y,ae))B[Z]=Y,B[se]=ae,Z=se;else break e}}return F}function o(B,F){var ae=B.sortIndex-F.sortIndex;return ae!==0?ae:B.id-F.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,f=d.now();e.unstable_now=function(){return d.now()-f}}var h=[],m=[],v=1,x=null,b=3,y=!1,k=!1,j=!1,T=!1,C=typeof setTimeout=="function"?setTimeout:null,R=typeof clearTimeout=="function"?clearTimeout:null,D=typeof setImmediate<"u"?setImmediate:null;function I(B){for(var F=a(m);F!==null;){if(F.callback===null)l(m);else if(F.startTime<=B)l(m),F.sortIndex=F.expirationTime,r(h,F);else break;F=a(m)}}function O(B){if(j=!1,I(B),!k)if(a(h)!==null)k=!0,E||(E=!0,K());else{var F=a(m);F!==null&&W(O,F.startTime-B)}}var E=!1,N=-1,L=5,X=-1;function H(){return T?!0:!(e.unstable_now()-XB&&H());){var Z=x.callback;if(typeof Z=="function"){x.callback=null,b=x.priorityLevel;var A=Z(x.expirationTime<=B);if(B=e.unstable_now(),typeof A=="function"){x.callback=A,I(B),F=!0;break t}x===a(h)&&l(h),I(B)}else l(h);x=a(h)}if(x!==null)F=!0;else{var U=a(m);U!==null&&W(O,U.startTime-B),F=!1}}break e}finally{x=null,b=ae,y=!1}F=void 0}}finally{F?K():E=!1}}}var K;if(typeof D=="function")K=function(){D(P)};else if(typeof MessageChannel<"u"){var ue=new MessageChannel,le=ue.port2;ue.port1.onmessage=P,K=function(){le.postMessage(null)}}else K=function(){C(P,0)};function W(B,F){N=C(function(){B(e.unstable_now())},F)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125Z?(B.sortIndex=ae,r(m,B),a(h)===null&&B===a(m)&&(j?(R(N),N=-1):j=!0,W(O,ae-Z))):(B.sortIndex=A,r(h,B),k||y||(k=!0,E||(E=!0,K()))),B},e.unstable_shouldYield=H,e.unstable_wrapCallback=function(B){var F=b;return function(){var ae=b;b=F;try{return B.apply(this,arguments)}finally{b=ae}}}})(mh)),mh}var Hy;function $2(){return Hy||(Hy=1,hh.exports=P2()),hh.exports}var ph={exports:{}},bn={};/** - * @license React - * react-dom.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Py;function F2(){if(Py)return bn;Py=1;var e=Um();function r(h){var m="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),ph.exports=F2(),ph.exports}/** - * @license React - * react-dom-client.production.js - * - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Fy;function V2(){if(Fy)return Xs;Fy=1;var e=$2(),r=Um(),a=B0();function l(t){var n="https://react.dev/errors/"+t;if(1A||(t.current=Z[A],Z[A]=null,A--)}function M(t,n){A++,Z[A]=t.current,t.current=n}var se=U(null),Y=U(null),ce=U(null),re=U(null);function ye(t,n){switch(M(ce,n),M(Y,t),M(se,null),n.nodeType){case 9:case 11:t=(t=n.documentElement)&&(t=t.namespaceURI)?ly(t):0;break;default:if(t=n.tagName,n=n.namespaceURI)n=ly(n),t=iy(n,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}V(se),M(se,t)}function fe(){V(se),V(Y),V(ce)}function we(t){t.memoizedState!==null&&M(re,t);var n=se.current,i=iy(n,t.type);n!==i&&(M(Y,t),M(se,i))}function Ee(t){Y.current===t&&(V(se),V(Y)),re.current===t&&(V(re),$s._currentValue=ae)}var Se,Ie;function Be(t){if(Se===void 0)try{throw Error()}catch(i){var n=i.stack.trim().match(/\n( *(at )?)/);Se=n&&n[1]||"",Ie=-1)":-1p||q[u]!==ee[p]){var oe=` -`+q[u].replace(" at new "," at ");return t.displayName&&oe.includes("")&&(oe=oe.replace("",t.displayName)),oe}while(1<=u&&0<=p);break}}}finally{Mt=!1,Error.prepareStackTrace=i}return(i=t?t.displayName||t.name:"")?Be(i):""}function Et(t,n){switch(t.tag){case 26:case 27:case 5:return Be(t.type);case 16:return Be("Lazy");case 13:return t.child!==n&&n!==null?Be("Suspense Fallback"):Be("Suspense");case 19:return Be("SuspenseList");case 0:case 15:return Nt(t.type,!1);case 11:return Nt(t.type.render,!1);case 1:return Nt(t.type,!0);case 31:return Be("Activity");default:return""}}function Bt(t){try{var n="",i=null;do n+=Et(t,i),i=t,t=t.return;while(t);return n}catch(u){return` -Error generating stack: `+u.message+` -`+u.stack}}var Rt=Object.prototype.hasOwnProperty,Dt=e.unstable_scheduleCallback,zt=e.unstable_cancelCallback,be=e.unstable_shouldYield,mt=e.unstable_requestPaint,Q=e.unstable_now,Pe=e.unstable_getCurrentPriorityLevel,ne=e.unstable_ImmediatePriority,z=e.unstable_UserBlockingPriority,he=e.unstable_NormalPriority,ke=e.unstable_LowPriority,ze=e.unstable_IdlePriority,an=e.log,Tn=e.unstable_setDisableYieldValue,en=null,Tt=null;function on(t){if(typeof an=="function"&&Tn(t),Tt&&typeof Tt.setStrictMode=="function")try{Tt.setStrictMode(en,t)}catch{}}var st=Math.clz32?Math.clz32:No,kr=Math.log,Hn=Math.LN2;function No(t){return t>>>=0,t===0?32:31-(kr(t)/Hn|0)|0}var bl=256,ei=262144,Sa=4194304;function yn(t){var n=t&42;if(n!==0)return n;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function ti(t,n,i){var u=t.pendingLanes;if(u===0)return 0;var p=0,g=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var _=u&134217727;return _!==0?(u=_&~g,u!==0?p=yn(u):(w&=_,w!==0?p=yn(w):i||(i=_&~t,i!==0&&(p=yn(i))))):(_=u&~g,_!==0?p=yn(_):w!==0?p=yn(w):i||(i=u&~t,i!==0&&(p=yn(i)))),p===0?0:n!==0&&n!==p&&(n&g)===0&&(g=p&-p,i=n&-n,g>=i||g===32&&(i&4194048)!==0)?n:p}function qe(t,n){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&n)===0}function ht(t,n){switch(t){case 1:case 2:case 4:case 8:case 64:return n+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 n+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 wt(){var t=Sa;return Sa<<=1,(Sa&62914560)===0&&(Sa=4194304),t}function jn(t){for(var n=[],i=0;31>i;i++)n.push(t);return n}function un(t,n){t.pendingLanes|=n,n!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Cr(t,n,i,u,p,g){var w=t.pendingLanes;t.pendingLanes=i,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=i,t.entangledLanes&=i,t.errorRecoveryDisabledLanes&=i,t.shellSuspendCounter=0;var _=t.entanglements,q=t.expirationTimes,ee=t.hiddenUpdates;for(i=w&~i;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var Ak=/[\n"\\]/g;function Wn(t){return t.replace(Ak,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function nd(t,n,i,u,p,g,w,_){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),n!=null?w==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+Jn(n)):t.value!==""+Jn(n)&&(t.value=""+Jn(n)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),n!=null?rd(t,w,Jn(n)):i!=null?rd(t,w,Jn(i)):u!=null&&t.removeAttribute("value"),p==null&&g!=null&&(t.defaultChecked=!!g),p!=null&&(t.checked=p&&typeof p!="function"&&typeof p!="symbol"),_!=null&&typeof _!="function"&&typeof _!="symbol"&&typeof _!="boolean"?t.name=""+Jn(_):t.removeAttribute("name")}function Wp(t,n,i,u,p,g,w,_){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(t.type=g),n!=null||i!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){td(t);return}i=i!=null?""+Jn(i):"",n=n!=null?""+Jn(n):i,_||n===t.value||(t.value=n),t.defaultValue=n}u=u??p,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=_?t.checked:!!u,t.defaultChecked=!!u,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),td(t)}function rd(t,n,i){n==="number"&&Ao(t.ownerDocument)===t||t.defaultValue===""+i||(t.defaultValue=""+i)}function si(t,n,i,u){if(t=t.options,n){n={};for(var p=0;p"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),od=!1;if(Kr)try{var ss={};Object.defineProperty(ss,"passive",{get:function(){od=!0}}),window.addEventListener("test",ss,ss),window.removeEventListener("test",ss,ss)}catch{od=!1}var ka=null,ud=null,Mo=null;function ig(){if(Mo)return Mo;var t,n=ud,i=n.length,u,p="value"in ka?ka.value:ka.textContent,g=p.length;for(t=0;t=cs),fg=" ",hg=!1;function mg(t,n){switch(t){case"keyup":return rC.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function pg(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var di=!1;function lC(t,n){switch(t){case"compositionend":return pg(n);case"keypress":return n.which!==32?null:(hg=!0,fg);case"textInput":return t=n.data,t===fg&&hg?null:t;default:return null}}function iC(t,n){if(di)return t==="compositionend"||!md&&mg(t,n)?(t=ig(),Mo=ud=ka=null,di=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1=n)return{node:i,offset:n-t};t=u}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=jg(i)}}function Cg(t,n){return t&&n?t===n?!0:t&&t.nodeType===3?!1:n&&n.nodeType===3?Cg(t,n.parentNode):"contains"in t?t.contains(n):t.compareDocumentPosition?!!(t.compareDocumentPosition(n)&16):!1:!1}function Ng(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var n=Ao(t.document);n instanceof t.HTMLIFrameElement;){try{var i=typeof n.contentWindow.location.href=="string"}catch{i=!1}if(i)t=n.contentWindow;else break;n=Ao(t.document)}return n}function xd(t){var n=t&&t.nodeName&&t.nodeName.toLowerCase();return n&&(n==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||n==="textarea"||t.contentEditable==="true")}var mC=Kr&&"documentMode"in document&&11>=document.documentMode,fi=null,vd=null,ms=null,yd=!1;function Eg(t,n,i){var u=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;yd||fi==null||fi!==Ao(u)||(u=fi,"selectionStart"in u&&xd(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ms&&hs(ms,u)||(ms=u,u=ku(vd,"onSelect"),0>=w,p-=w,Er=1<<32-st(n)+p|i<Xe?(at=_e,_e=null):at=_e.sibling;var ct=te(G,_e,J[Xe],me);if(ct===null){_e===null&&(_e=at);break}t&&_e&&ct.alternate===null&&n(G,_e),$=g(ct,$,Xe),ut===null?De=ct:ut.sibling=ct,ut=ct,_e=at}if(Xe===J.length)return i(G,_e),lt&&Zr(G,Xe),De;if(_e===null){for(;XeXe?(at=_e,_e=null):at=_e.sibling;var Ga=te(G,_e,ct.value,me);if(Ga===null){_e===null&&(_e=at);break}t&&_e&&Ga.alternate===null&&n(G,_e),$=g(Ga,$,Xe),ut===null?De=Ga:ut.sibling=Ga,ut=Ga,_e=at}if(ct.done)return i(G,_e),lt&&Zr(G,Xe),De;if(_e===null){for(;!ct.done;Xe++,ct=J.next())ct=pe(G,ct.value,me),ct!==null&&($=g(ct,$,Xe),ut===null?De=ct:ut.sibling=ct,ut=ct);return lt&&Zr(G,Xe),De}for(_e=u(_e);!ct.done;Xe++,ct=J.next())ct=ie(_e,G,Xe,ct.value,me),ct!==null&&(t&&ct.alternate!==null&&_e.delete(ct.key===null?Xe:ct.key),$=g(ct,$,Xe),ut===null?De=ct:ut.sibling=ct,ut=ct);return t&&_e.forEach(function(O2){return n(G,O2)}),lt&&Zr(G,Xe),De}function yt(G,$,J,me){if(typeof J=="object"&&J!==null&&J.type===j&&J.key===null&&(J=J.props.children),typeof J=="object"&&J!==null){switch(J.$$typeof){case y:e:{for(var De=J.key;$!==null;){if($.key===De){if(De=J.type,De===j){if($.tag===7){i(G,$.sibling),me=p($,J.props.children),me.return=G,G=me;break e}}else if($.elementType===De||typeof De=="object"&&De!==null&&De.$$typeof===L&&Ml(De)===$.type){i(G,$.sibling),me=p($,J.props),bs(me,J),me.return=G,G=me;break e}i(G,$);break}else n(G,$);$=$.sibling}J.type===j?(me=Nl(J.props.children,G.mode,me,J.key),me.return=G,G=me):(me=Ho(J.type,J.key,J.props,null,G.mode,me),bs(me,J),me.return=G,G=me)}return w(G);case k:e:{for(De=J.key;$!==null;){if($.key===De)if($.tag===4&&$.stateNode.containerInfo===J.containerInfo&&$.stateNode.implementation===J.implementation){i(G,$.sibling),me=p($,J.children||[]),me.return=G,G=me;break e}else{i(G,$);break}else n(G,$);$=$.sibling}me=Nd(J,G.mode,me),me.return=G,G=me}return w(G);case L:return J=Ml(J),yt(G,$,J,me)}if(W(J))return Te(G,$,J,me);if(K(J)){if(De=K(J),typeof De!="function")throw Error(l(150));return J=De.call(J),Ue(G,$,J,me)}if(typeof J.then=="function")return yt(G,$,Xo(J),me);if(J.$$typeof===D)return yt(G,$,Fo(G,J),me);Ko(G,J)}return typeof J=="string"&&J!==""||typeof J=="number"||typeof J=="bigint"?(J=""+J,$!==null&&$.tag===6?(i(G,$.sibling),me=p($,J),me.return=G,G=me):(i(G,$),me=Cd(J,G.mode,me),me.return=G,G=me),w(G)):i(G,$)}return function(G,$,J,me){try{ys=0;var De=yt(G,$,J,me);return ji=null,De}catch(_e){if(_e===Si||_e===Go)throw _e;var ut=$n(29,_e,null,G.mode);return ut.lanes=me,ut.return=G,ut}finally{}}}var Dl=Qg(!0),Zg=Qg(!1),Aa=!1;function Bd(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Id(t,n){t=t.updateQueue,n.updateQueue===t&&(n.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function _a(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Ma(t,n,i){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(dt&2)!==0){var p=u.pending;return p===null?n.next=n:(n.next=p.next,p.next=n),u.pending=n,n=qo(t),Og(t,null,i),n}return Io(t,u,n,i),qo(t)}function ws(t,n,i){if(n=n.updateQueue,n!==null&&(n=n.shared,(i&4194048)!==0)){var u=n.lanes;u&=t.pendingLanes,i|=u,n.lanes=i,An(t,i)}}function qd(t,n){var i=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,i===u)){var p=null,g=null;if(i=i.firstBaseUpdate,i!==null){do{var w={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};g===null?p=g=w:g=g.next=w,i=i.next}while(i!==null);g===null?p=g=n:g=g.next=n}else p=g=n;i={baseState:u.baseState,firstBaseUpdate:p,lastBaseUpdate:g,shared:u.shared,callbacks:u.callbacks},t.updateQueue=i;return}t=i.lastBaseUpdate,t===null?i.firstBaseUpdate=n:t.next=n,i.lastBaseUpdate=n}var Hd=!1;function Ss(){if(Hd){var t=wi;if(t!==null)throw t}}function js(t,n,i,u){Hd=!1;var p=t.updateQueue;Aa=!1;var g=p.firstBaseUpdate,w=p.lastBaseUpdate,_=p.shared.pending;if(_!==null){p.shared.pending=null;var q=_,ee=q.next;q.next=null,w===null?g=ee:w.next=ee,w=q;var oe=t.alternate;oe!==null&&(oe=oe.updateQueue,_=oe.lastBaseUpdate,_!==w&&(_===null?oe.firstBaseUpdate=ee:_.next=ee,oe.lastBaseUpdate=q))}if(g!==null){var pe=p.baseState;w=0,oe=ee=q=null,_=g;do{var te=_.lane&-536870913,ie=te!==_.lane;if(ie?(rt&te)===te:(u&te)===te){te!==0&&te===bi&&(Hd=!0),oe!==null&&(oe=oe.next={lane:0,tag:_.tag,payload:_.payload,callback:null,next:null});e:{var Te=t,Ue=_;te=n;var yt=i;switch(Ue.tag){case 1:if(Te=Ue.payload,typeof Te=="function"){pe=Te.call(yt,pe,te);break e}pe=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=Ue.payload,te=typeof Te=="function"?Te.call(yt,pe,te):Te,te==null)break e;pe=x({},pe,te);break e;case 2:Aa=!0}}te=_.callback,te!==null&&(t.flags|=64,ie&&(t.flags|=8192),ie=p.callbacks,ie===null?p.callbacks=[te]:ie.push(te))}else ie={lane:te,tag:_.tag,payload:_.payload,callback:_.callback,next:null},oe===null?(ee=oe=ie,q=pe):oe=oe.next=ie,w|=te;if(_=_.next,_===null){if(_=p.shared.pending,_===null)break;ie=_,_=ie.next,ie.next=null,p.lastBaseUpdate=ie,p.shared.pending=null}}while(!0);oe===null&&(q=pe),p.baseState=q,p.firstBaseUpdate=ee,p.lastBaseUpdate=oe,g===null&&(p.shared.lanes=0),La|=w,t.lanes=w,t.memoizedState=pe}}function Jg(t,n){if(typeof t!="function")throw Error(l(191,t));t.call(n)}function Wg(t,n){var i=t.callbacks;if(i!==null)for(t.callbacks=null,t=0;tg?g:8;var w=B.T,_={};B.T=_,sf(t,!1,n,i);try{var q=p(),ee=B.S;if(ee!==null&&ee(_,q),q!==null&&typeof q=="object"&&typeof q.then=="function"){var oe=jC(q,u);Ns(t,n,oe,Xn(t))}else Ns(t,n,u,Xn(t))}catch(pe){Ns(t,n,{then:function(){},status:"rejected",reason:pe},Xn())}finally{F.p=g,w!==null&&_.types!==null&&(w.types=_.types),B.T=w}}function AC(){}function af(t,n,i,u){if(t.tag!==5)throw Error(l(476));var p=Mx(t).queue;_x(t,p,n,ae,i===null?AC:function(){return Rx(t),i(u)})}function Mx(t){var n=t.memoizedState;if(n!==null)return n;n={memoizedState:ae,baseState:ae,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ta,lastRenderedState:ae},next:null};var i={};return n.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ta,lastRenderedState:i},next:null},t.memoizedState=n,t=t.alternate,t!==null&&(t.memoizedState=n),n}function Rx(t){var n=Mx(t);n.next===null&&(n=t.alternate.memoizedState),Ns(t,n.next.queue,{},Xn())}function lf(){return fn($s)}function Dx(){return $t().memoizedState}function Ox(){return $t().memoizedState}function _C(t){for(var n=t.return;n!==null;){switch(n.tag){case 24:case 3:var i=Xn();t=_a(i);var u=Ma(n,t,i);u!==null&&(Ln(u,n,i),ws(u,n,i)),n={cache:Od()},t.payload=n;return}n=n.return}}function MC(t,n,i){var u=Xn();i={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},lu(t)?Lx(n,i):(i=jd(t,n,i,u),i!==null&&(Ln(i,t,u),Ux(i,n,u)))}function zx(t,n,i){var u=Xn();Ns(t,n,i,u)}function Ns(t,n,i,u){var p={lane:u,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(lu(t))Lx(n,p);else{var g=t.alternate;if(t.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var w=n.lastRenderedState,_=g(w,i);if(p.hasEagerState=!0,p.eagerState=_,Pn(_,w))return Io(t,n,p,0),St===null&&Bo(),!1}catch{}finally{}if(i=jd(t,n,p,u),i!==null)return Ln(i,t,u),Ux(i,n,u),!0}return!1}function sf(t,n,i,u){if(u={lane:2,revertLane:If(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},lu(t)){if(n)throw Error(l(479))}else n=jd(t,i,u,2),n!==null&&Ln(n,t,2)}function lu(t){var n=t.alternate;return t===Ye||n!==null&&n===Ye}function Lx(t,n){Ci=Jo=!0;var i=t.pending;i===null?n.next=n:(n.next=i.next,i.next=n),t.pending=n}function Ux(t,n,i){if((i&4194048)!==0){var u=n.lanes;u&=t.pendingLanes,i|=u,n.lanes=i,An(t,i)}}var Es={readContext:fn,use:tu,useCallback:It,useContext:It,useEffect:It,useImperativeHandle:It,useLayoutEffect:It,useInsertionEffect:It,useMemo:It,useReducer:It,useRef:It,useState:It,useDebugValue:It,useDeferredValue:It,useTransition:It,useSyncExternalStore:It,useId:It,useHostTransitionStatus:It,useFormState:It,useActionState:It,useOptimistic:It,useMemoCache:It,useCacheRefresh:It};Es.useEffectEvent=It;var Bx={readContext:fn,use:tu,useCallback:function(t,n){return kn().memoizedState=[t,n===void 0?null:n],t},useContext:fn,useEffect:wx,useImperativeHandle:function(t,n,i){i=i!=null?i.concat([t]):null,ru(4194308,4,Cx.bind(null,n,t),i)},useLayoutEffect:function(t,n){return ru(4194308,4,t,n)},useInsertionEffect:function(t,n){ru(4,2,t,n)},useMemo:function(t,n){var i=kn();n=n===void 0?null:n;var u=t();if(Ol){on(!0);try{t()}finally{on(!1)}}return i.memoizedState=[u,n],u},useReducer:function(t,n,i){var u=kn();if(i!==void 0){var p=i(n);if(Ol){on(!0);try{i(n)}finally{on(!1)}}}else p=n;return u.memoizedState=u.baseState=p,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:p},u.queue=t,t=t.dispatch=MC.bind(null,Ye,t),[u.memoizedState,t]},useRef:function(t){var n=kn();return t={current:t},n.memoizedState=t},useState:function(t){t=Wd(t);var n=t.queue,i=zx.bind(null,Ye,n);return n.dispatch=i,[t.memoizedState,i]},useDebugValue:nf,useDeferredValue:function(t,n){var i=kn();return rf(i,t,n)},useTransition:function(){var t=Wd(!1);return t=_x.bind(null,Ye,t.queue,!0,!1),kn().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,n,i){var u=Ye,p=kn();if(lt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=n(),St===null)throw Error(l(349));(rt&127)!==0||lx(u,n,i)}p.memoizedState=i;var g={value:i,getSnapshot:n};return p.queue=g,wx(sx.bind(null,u,g,t),[t]),u.flags|=2048,Ei(9,{destroy:void 0},ix.bind(null,u,g,i,n),null),i},useId:function(){var t=kn(),n=St.identifierPrefix;if(lt){var i=Tr,u=Er;i=(u&~(1<<32-st(u)-1)).toString(32)+i,n="_"+n+"R_"+i,i=Wo++,0<\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof u.is=="string"?w.createElement("select",{is:u.is}):w.createElement("select"),u.multiple?g.multiple=!0:u.size&&(g.size=u.size);break;default:g=typeof u.is=="string"?w.createElement(p,{is:u.is}):w.createElement(p)}}g[cn]=n,g[_n]=u;e:for(w=n.child;w!==null;){if(w.tag===5||w.tag===6)g.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===n)break e;for(;w.sibling===null;){if(w.return===null||w.return===n)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}n.stateNode=g;e:switch(mn(g,p,u),p){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&ra(n)}}return _t(n),wf(n,n.type,t===null?null:t.memoizedProps,n.pendingProps,i),null;case 6:if(t&&n.stateNode!=null)t.memoizedProps!==u&&ra(n);else{if(typeof u!="string"&&n.stateNode===null)throw Error(l(166));if(t=ce.current,vi(n)){if(t=n.stateNode,i=n.memoizedProps,u=null,p=dn,p!==null)switch(p.tag){case 27:case 5:u=p.memoizedProps}t[cn]=n,t=!!(t.nodeValue===i||u!==null&&u.suppressHydrationWarning===!0||ry(t.nodeValue,i)),t||Ea(n,!0)}else t=Cu(t).createTextNode(u),t[cn]=n,n.stateNode=t}return _t(n),null;case 31:if(i=n.memoizedState,t===null||t.memoizedState!==null){if(u=vi(n),i!==null){if(t===null){if(!u)throw Error(l(318));if(t=n.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(l(557));t[cn]=n}else El(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;_t(n),t=!1}else i=_d(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=i),t=!0;if(!t)return n.flags&256?(Vn(n),n):(Vn(n),null);if((n.flags&128)!==0)throw Error(l(558))}return _t(n),null;case 13:if(u=n.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(p=vi(n),u!==null&&u.dehydrated!==null){if(t===null){if(!p)throw Error(l(318));if(p=n.memoizedState,p=p!==null?p.dehydrated:null,!p)throw Error(l(317));p[cn]=n}else El(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;_t(n),p=!1}else p=_d(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=p),p=!0;if(!p)return n.flags&256?(Vn(n),n):(Vn(n),null)}return Vn(n),(n.flags&128)!==0?(n.lanes=i,n):(i=u!==null,t=t!==null&&t.memoizedState!==null,i&&(u=n.child,p=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(p=u.alternate.memoizedState.cachePool.pool),g=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(g=u.memoizedState.cachePool.pool),g!==p&&(u.flags|=2048)),i!==t&&i&&(n.child.flags|=8192),cu(n,n.updateQueue),_t(n),null);case 4:return fe(),t===null&&$f(n.stateNode.containerInfo),_t(n),null;case 10:return Wr(n.type),_t(n),null;case 19:if(V(Pt),u=n.memoizedState,u===null)return _t(n),null;if(p=(n.flags&128)!==0,g=u.rendering,g===null)if(p)As(u,!1);else{if(qt!==0||t!==null&&(t.flags&128)!==0)for(t=n.child;t!==null;){if(g=Zo(t),g!==null){for(n.flags|=128,As(u,!1),t=g.updateQueue,n.updateQueue=t,cu(n,t),n.subtreeFlags=0,t=i,i=n.child;i!==null;)zg(i,t),i=i.sibling;return M(Pt,Pt.current&1|2),lt&&Zr(n,u.treeForkCount),n.child}t=t.sibling}u.tail!==null&&Q()>pu&&(n.flags|=128,p=!0,As(u,!1),n.lanes=4194304)}else{if(!p)if(t=Zo(g),t!==null){if(n.flags|=128,p=!0,t=t.updateQueue,n.updateQueue=t,cu(n,t),As(u,!0),u.tail===null&&u.tailMode==="hidden"&&!g.alternate&&!lt)return _t(n),null}else 2*Q()-u.renderingStartTime>pu&&i!==536870912&&(n.flags|=128,p=!0,As(u,!1),n.lanes=4194304);u.isBackwards?(g.sibling=n.child,n.child=g):(t=u.last,t!==null?t.sibling=g:n.child=g,u.last=g)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=Q(),t.sibling=null,i=Pt.current,M(Pt,p?i&1|2:i&1),lt&&Zr(n,u.treeForkCount),t):(_t(n),null);case 22:case 23:return Vn(n),$d(),u=n.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(n.flags|=8192):u&&(n.flags|=8192),u?(i&536870912)!==0&&(n.flags&128)===0&&(_t(n),n.subtreeFlags&6&&(n.flags|=8192)):_t(n),i=n.updateQueue,i!==null&&cu(n,i.retryQueue),i=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),u=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(u=n.memoizedState.cachePool.pool),u!==i&&(n.flags|=2048),t!==null&&V(_l),null;case 24:return i=null,t!==null&&(i=t.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),Wr(Gt),_t(n),null;case 25:return null;case 30:return null}throw Error(l(156,n.tag))}function LC(t,n){switch(Td(n),n.tag){case 1:return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 3:return Wr(Gt),fe(),t=n.flags,(t&65536)!==0&&(t&128)===0?(n.flags=t&-65537|128,n):null;case 26:case 27:case 5:return Ee(n),null;case 31:if(n.memoizedState!==null){if(Vn(n),n.alternate===null)throw Error(l(340));El()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 13:if(Vn(n),t=n.memoizedState,t!==null&&t.dehydrated!==null){if(n.alternate===null)throw Error(l(340));El()}return t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 19:return V(Pt),null;case 4:return fe(),null;case 10:return Wr(n.type),null;case 22:case 23:return Vn(n),$d(),t!==null&&V(_l),t=n.flags,t&65536?(n.flags=t&-65537|128,n):null;case 24:return Wr(Gt),null;case 25:return null;default:return null}}function ov(t,n){switch(Td(n),n.tag){case 3:Wr(Gt),fe();break;case 26:case 27:case 5:Ee(n);break;case 4:fe();break;case 31:n.memoizedState!==null&&Vn(n);break;case 13:Vn(n);break;case 19:V(Pt);break;case 10:Wr(n.type);break;case 22:case 23:Vn(n),$d(),t!==null&&V(_l);break;case 24:Wr(Gt)}}function _s(t,n){try{var i=n.updateQueue,u=i!==null?i.lastEffect:null;if(u!==null){var p=u.next;i=p;do{if((i.tag&t)===t){u=void 0;var g=i.create,w=i.inst;u=g(),w.destroy=u}i=i.next}while(i!==p)}}catch(_){gt(n,n.return,_)}}function Oa(t,n,i){try{var u=n.updateQueue,p=u!==null?u.lastEffect:null;if(p!==null){var g=p.next;u=g;do{if((u.tag&t)===t){var w=u.inst,_=w.destroy;if(_!==void 0){w.destroy=void 0,p=n;var q=i,ee=_;try{ee()}catch(oe){gt(p,q,oe)}}}u=u.next}while(u!==g)}}catch(oe){gt(n,n.return,oe)}}function uv(t){var n=t.updateQueue;if(n!==null){var i=t.stateNode;try{Wg(n,i)}catch(u){gt(t,t.return,u)}}}function cv(t,n,i){i.props=zl(t.type,t.memoizedProps),i.state=t.memoizedState;try{i.componentWillUnmount()}catch(u){gt(t,n,u)}}function Ms(t,n){try{var i=t.ref;if(i!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof i=="function"?t.refCleanup=i(u):i.current=u}}catch(p){gt(t,n,p)}}function Ar(t,n){var i=t.ref,u=t.refCleanup;if(i!==null)if(typeof u=="function")try{u()}catch(p){gt(t,n,p)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(p){gt(t,n,p)}else i.current=null}function dv(t){var n=t.type,i=t.memoizedProps,u=t.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":i.autoFocus&&u.focus();break e;case"img":i.src?u.src=i.src:i.srcSet&&(u.srcset=i.srcSet)}}catch(p){gt(t,t.return,p)}}function Sf(t,n,i){try{var u=t.stateNode;a2(u,t.type,i,n),u[_n]=n}catch(p){gt(t,t.return,p)}}function fv(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&Ha(t.type)||t.tag===4}function jf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||fv(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&Ha(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function kf(t,n,i){var u=t.tag;if(u===5||u===6)t=t.stateNode,n?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(t,n):(n=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,n.appendChild(t),i=i._reactRootContainer,i!=null||n.onclick!==null||(n.onclick=Xr));else if(u!==4&&(u===27&&Ha(t.type)&&(i=t.stateNode,n=null),t=t.child,t!==null))for(kf(t,n,i),t=t.sibling;t!==null;)kf(t,n,i),t=t.sibling}function du(t,n,i){var u=t.tag;if(u===5||u===6)t=t.stateNode,n?i.insertBefore(t,n):i.appendChild(t);else if(u!==4&&(u===27&&Ha(t.type)&&(i=t.stateNode),t=t.child,t!==null))for(du(t,n,i),t=t.sibling;t!==null;)du(t,n,i),t=t.sibling}function hv(t){var n=t.stateNode,i=t.memoizedProps;try{for(var u=t.type,p=n.attributes;p.length;)n.removeAttributeNode(p[0]);mn(n,u,i),n[cn]=t,n[_n]=i}catch(g){gt(t,t.return,g)}}var aa=!1,Kt=!1,Cf=!1,mv=typeof WeakSet=="function"?WeakSet:Set,sn=null;function UC(t,n){if(t=t.containerInfo,Gf=Ru,t=Ng(t),xd(t)){if("selectionStart"in t)var i={start:t.selectionStart,end:t.selectionEnd};else e:{i=(i=t.ownerDocument)&&i.defaultView||window;var u=i.getSelection&&i.getSelection();if(u&&u.rangeCount!==0){i=u.anchorNode;var p=u.anchorOffset,g=u.focusNode;u=u.focusOffset;try{i.nodeType,g.nodeType}catch{i=null;break e}var w=0,_=-1,q=-1,ee=0,oe=0,pe=t,te=null;t:for(;;){for(var ie;pe!==i||p!==0&&pe.nodeType!==3||(_=w+p),pe!==g||u!==0&&pe.nodeType!==3||(q=w+u),pe.nodeType===3&&(w+=pe.nodeValue.length),(ie=pe.firstChild)!==null;)te=pe,pe=ie;for(;;){if(pe===t)break t;if(te===i&&++ee===p&&(_=w),te===g&&++oe===u&&(q=w),(ie=pe.nextSibling)!==null)break;pe=te,te=pe.parentNode}pe=ie}i=_===-1||q===-1?null:{start:_,end:q}}else i=null}i=i||{start:0,end:0}}else i=null;for(Yf={focusedElem:t,selectionRange:i},Ru=!1,sn=n;sn!==null;)if(n=sn,t=n.child,(n.subtreeFlags&1028)!==0&&t!==null)t.return=n,sn=t;else for(;sn!==null;){switch(n=sn,g=n.alternate,t=n.flags,n.tag){case 0:if((t&4)!==0&&(t=n.updateQueue,t=t!==null?t.events:null,t!==null))for(i=0;i title"))),mn(g,u,i),g[cn]=t,ln(g),u=g;break e;case"link":var w=by("link","href",p).get(u+(i.href||""));if(w){for(var _=0;_yt&&(w=yt,yt=Ue,Ue=w);var G=kg(_,Ue),$=kg(_,yt);if(G&&$&&(ie.rangeCount!==1||ie.anchorNode!==G.node||ie.anchorOffset!==G.offset||ie.focusNode!==$.node||ie.focusOffset!==$.offset)){var J=pe.createRange();J.setStart(G.node,G.offset),ie.removeAllRanges(),Ue>yt?(ie.addRange(J),ie.extend($.node,$.offset)):(J.setEnd($.node,$.offset),ie.addRange(J))}}}}for(pe=[],ie=_;ie=ie.parentNode;)ie.nodeType===1&&pe.push({element:ie,left:ie.scrollLeft,top:ie.scrollTop});for(typeof _.focus=="function"&&_.focus(),_=0;_i?32:i,B.T=null,i=Rf,Rf=null;var g=Ba,w=ua;if(tn=0,Ri=Ba=null,ua=0,(dt&6)!==0)throw Error(l(331));var _=dt;if(dt|=4,Cv(g.current),Sv(g,g.current,w,i),dt=_,Us(0,!1),Tt&&typeof Tt.onPostCommitFiberRoot=="function")try{Tt.onPostCommitFiberRoot(en,g)}catch{}return!0}finally{F.p=p,B.T=u,$v(t,n)}}function Vv(t,n,i){n=tr(i,n),n=df(t.stateNode,n,2),t=Ma(t,n,2),t!==null&&(un(t,2),_r(t))}function gt(t,n,i){if(t.tag===3)Vv(t,t,i);else for(;n!==null;){if(n.tag===3){Vv(n,t,i);break}else if(n.tag===1){var u=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(Ua===null||!Ua.has(u))){t=tr(i,t),i=Gx(2),u=Ma(n,i,2),u!==null&&(Yx(i,u,n,t),un(u,2),_r(u));break}}n=n.return}}function Lf(t,n,i){var u=t.pingCache;if(u===null){u=t.pingCache=new qC;var p=new Set;u.set(n,p)}else p=u.get(n),p===void 0&&(p=new Set,u.set(n,p));p.has(i)||(Tf=!0,p.add(i),t=VC.bind(null,t,n,i),n.then(t,t))}function VC(t,n,i){var u=t.pingCache;u!==null&&u.delete(n),t.pingedLanes|=t.suspendedLanes&i,t.warmLanes&=~i,St===t&&(rt&i)===i&&(qt===4||qt===3&&(rt&62914560)===rt&&300>Q()-mu?(dt&2)===0&&Di(t,0):Af|=i,Mi===rt&&(Mi=0)),_r(t)}function Gv(t,n){n===0&&(n=wt()),t=Cl(t,n),t!==null&&(un(t,n),_r(t))}function GC(t){var n=t.memoizedState,i=0;n!==null&&(i=n.retryLane),Gv(t,i)}function YC(t,n){var i=0;switch(t.tag){case 31:case 13:var u=t.stateNode,p=t.memoizedState;p!==null&&(i=p.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(l(314))}u!==null&&u.delete(n),Gv(t,i)}function XC(t,n){return Dt(t,n)}var wu=null,zi=null,Uf=!1,Su=!1,Bf=!1,qa=0;function _r(t){t!==zi&&t.next===null&&(zi===null?wu=zi=t:zi=zi.next=t),Su=!0,Uf||(Uf=!0,QC())}function Us(t,n){if(!Bf&&Su){Bf=!0;do for(var i=!1,u=wu;u!==null;){if(t!==0){var p=u.pendingLanes;if(p===0)var g=0;else{var w=u.suspendedLanes,_=u.pingedLanes;g=(1<<31-st(42|t)+1)-1,g&=p&~(w&~_),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(i=!0,Qv(u,g))}else g=rt,g=ti(u,u===St?g:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(g&3)===0||qe(u,g)||(i=!0,Qv(u,g));u=u.next}while(i);Bf=!1}}function KC(){Yv()}function Yv(){Su=Uf=!1;var t=0;qa!==0&&i2()&&(t=qa);for(var n=Q(),i=null,u=wu;u!==null;){var p=u.next,g=Xv(u,n);g===0?(u.next=null,i===null?wu=p:i.next=p,p===null&&(zi=i)):(i=u,(t!==0||(g&3)!==0)&&(Su=!0)),u=p}tn!==0&&tn!==5||Us(t),qa!==0&&(qa=0)}function Xv(t,n){for(var i=t.suspendedLanes,u=t.pingedLanes,p=t.expirationTimes,g=t.pendingLanes&-62914561;0_)break;var oe=q.transferSize,pe=q.initiatorType;oe&&ay(pe)&&(q=q.responseEnd,w+=oe*(q<_?1:(_-ee)/(q-ee)))}if(--u,n+=8*(g+w)/(p.duration/1e3),t++,10"u"?null:document;function gy(t,n,i){var u=Li;if(u&&typeof n=="string"&&n){var p=Wn(n);p='link[rel="'+t+'"][href="'+p+'"]',typeof i=="string"&&(p+='[crossorigin="'+i+'"]'),py.has(p)||(py.add(p),t={rel:t,crossOrigin:i,href:n},u.querySelector(p)===null&&(n=u.createElement("link"),mn(n,"link",t),ln(n),u.head.appendChild(n)))}}function p2(t){ca.D(t),gy("dns-prefetch",t,null)}function g2(t,n){ca.C(t,n),gy("preconnect",t,n)}function x2(t,n,i){ca.L(t,n,i);var u=Li;if(u&&t&&n){var p='link[rel="preload"][as="'+Wn(n)+'"]';n==="image"&&i&&i.imageSrcSet?(p+='[imagesrcset="'+Wn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(p+='[imagesizes="'+Wn(i.imageSizes)+'"]')):p+='[href="'+Wn(t)+'"]';var g=p;switch(n){case"style":g=Ui(t);break;case"script":g=Bi(t)}sr.has(g)||(t=x({rel:"preload",href:n==="image"&&i&&i.imageSrcSet?void 0:t,as:n},i),sr.set(g,t),u.querySelector(p)!==null||n==="style"&&u.querySelector(Hs(g))||n==="script"&&u.querySelector(Ps(g))||(n=u.createElement("link"),mn(n,"link",t),ln(n),u.head.appendChild(n)))}}function v2(t,n){ca.m(t,n);var i=Li;if(i&&t){var u=n&&typeof n.as=="string"?n.as:"script",p='link[rel="modulepreload"][as="'+Wn(u)+'"][href="'+Wn(t)+'"]',g=p;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Bi(t)}if(!sr.has(g)&&(t=x({rel:"modulepreload",href:t},n),sr.set(g,t),i.querySelector(p)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Ps(g)))return}u=i.createElement("link"),mn(u,"link",t),ln(u),i.head.appendChild(u)}}}function y2(t,n,i){ca.S(t,n,i);var u=Li;if(u&&t){var p=li(u).hoistableStyles,g=Ui(t);n=n||"default";var w=p.get(g);if(!w){var _={loading:0,preload:null};if(w=u.querySelector(Hs(g)))_.loading=5;else{t=x({rel:"stylesheet",href:t,"data-precedence":n},i),(i=sr.get(g))&&eh(t,i);var q=w=u.createElement("link");ln(q),mn(q,"link",t),q._p=new Promise(function(ee,oe){q.onload=ee,q.onerror=oe}),q.addEventListener("load",function(){_.loading|=1}),q.addEventListener("error",function(){_.loading|=2}),_.loading|=4,Eu(w,n,u)}w={type:"stylesheet",instance:w,count:1,state:_},p.set(g,w)}}}function b2(t,n){ca.X(t,n);var i=Li;if(i&&t){var u=li(i).hoistableScripts,p=Bi(t),g=u.get(p);g||(g=i.querySelector(Ps(p)),g||(t=x({src:t,async:!0},n),(n=sr.get(p))&&th(t,n),g=i.createElement("script"),ln(g),mn(g,"link",t),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function w2(t,n){ca.M(t,n);var i=Li;if(i&&t){var u=li(i).hoistableScripts,p=Bi(t),g=u.get(p);g||(g=i.querySelector(Ps(p)),g||(t=x({src:t,async:!0,type:"module"},n),(n=sr.get(p))&&th(t,n),g=i.createElement("script"),ln(g),mn(g,"link",t),i.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},u.set(p,g))}}function xy(t,n,i,u){var p=(p=ce.current)?Nu(p):null;if(!p)throw Error(l(446));switch(t){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(n=Ui(i.href),i=li(p).hoistableStyles,u=i.get(n),u||(u={type:"style",instance:null,count:0,state:null},i.set(n,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){t=Ui(i.href);var g=li(p).hoistableStyles,w=g.get(t);if(w||(p=p.ownerDocument||p,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(t,w),(g=p.querySelector(Hs(t)))&&!g._p&&(w.instance=g,w.state.loading=5),sr.has(t)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},sr.set(t,i),g||S2(p,t,i,w.state))),n&&u===null)throw Error(l(528,""));return w}if(n&&u!==null)throw Error(l(529,""));return null;case"script":return n=i.async,i=i.src,typeof i=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Bi(i),i=li(p).hoistableScripts,u=i.get(n),u||(u={type:"script",instance:null,count:0,state:null},i.set(n,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,t))}}function Ui(t){return'href="'+Wn(t)+'"'}function Hs(t){return'link[rel="stylesheet"]['+t+"]"}function vy(t){return x({},t,{"data-precedence":t.precedence,precedence:null})}function S2(t,n,i,u){t.querySelector('link[rel="preload"][as="style"]['+n+"]")?u.loading=1:(n=t.createElement("link"),u.preload=n,n.addEventListener("load",function(){return u.loading|=1}),n.addEventListener("error",function(){return u.loading|=2}),mn(n,"link",i),ln(n),t.head.appendChild(n))}function Bi(t){return'[src="'+Wn(t)+'"]'}function Ps(t){return"script[async]"+t}function yy(t,n,i){if(n.count++,n.instance===null)switch(n.type){case"style":var u=t.querySelector('style[data-href~="'+Wn(i.href)+'"]');if(u)return n.instance=u,ln(u),u;var p=x({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),ln(u),mn(u,"style",p),Eu(u,i.precedence,t),n.instance=u;case"stylesheet":p=Ui(i.href);var g=t.querySelector(Hs(p));if(g)return n.state.loading|=4,n.instance=g,ln(g),g;u=vy(i),(p=sr.get(p))&&eh(u,p),g=(t.ownerDocument||t).createElement("link"),ln(g);var w=g;return w._p=new Promise(function(_,q){w.onload=_,w.onerror=q}),mn(g,"link",u),n.state.loading|=4,Eu(g,i.precedence,t),n.instance=g;case"script":return g=Bi(i.src),(p=t.querySelector(Ps(g)))?(n.instance=p,ln(p),p):(u=i,(p=sr.get(g))&&(u=x({},i),th(u,p)),t=t.ownerDocument||t,p=t.createElement("script"),ln(p),mn(p,"link",u),t.head.appendChild(p),n.instance=p);case"void":return null;default:throw Error(l(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(u=n.instance,n.state.loading|=4,Eu(u,i.precedence,t));return n.instance}function Eu(t,n,i){for(var u=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),p=u.length?u[u.length-1]:null,g=p,w=0;w title"):null)}function j2(t,n,i){if(i===1||n.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return t=n.disabled,typeof n.precedence=="string"&&t==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function Sy(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function k2(t,n,i,u){if(i.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var p=Ui(u.href),g=n.querySelector(Hs(p));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(t.count++,t=Au.bind(t),n.then(t,t)),i.state.loading|=4,i.instance=g,ln(g);return}g=n.ownerDocument||n,u=vy(u),(p=sr.get(p))&&eh(u,p),g=g.createElement("link"),ln(g);var w=g;w._p=new Promise(function(_,q){w.onload=_,w.onerror=q}),mn(g,"link",u),i.instance=g}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(i,n),(n=i.state.preload)&&(i.state.loading&3)===0&&(t.count++,i=Au.bind(t),n.addEventListener("load",i),n.addEventListener("error",i))}}var nh=0;function C2(t,n){return t.stylesheets&&t.count===0&&Mu(t,t.stylesheets),0nh?50:800)+n);return t.unsuspend=i,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(p)}}:null}function Au(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Mu(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var _u=null;function Mu(t,n){t.stylesheets=null,t.unsuspend!==null&&(t.count++,_u=new Map,n.forEach(N2,t),_u=null,Au.call(t))}function N2(t,n){if(!(n.state.loading&4)){var i=_u.get(t);if(i)var u=i.get(null);else{i=new Map,_u.set(t,i);for(var p=t.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(r){console.error(r)}}return e(),fh.exports=V2(),fh.exports}var Y2=G2();class wc extends Error{constructor(a,l,o){super(a);uh(this,"code");uh(this,"status");this.code=l,this.status=o}}async function Iu(e,r,a){const l=await fetch(r,{method:e,headers:a!==void 0?{"Content-Type":"application/json"}:void 0,body:a!==void 0?JSON.stringify(a):void 0,credentials:"same-origin"}),o=await l.text();let c=null;try{c=o?JSON.parse(o):null}catch{}if(!l.ok){const d=c==null?void 0:c.error;throw new wc((d==null?void 0:d.message)??`HTTP ${l.status}`,(d==null?void 0:d.code)??"http_error",l.status)}return c}const He={get:e=>Iu("GET",e),post:(e,r)=>Iu("POST",e,r),patch:(e,r)=>Iu("PATCH",e,r),del:e=>Iu("DELETE",e)};function ha(e,r){for(const a of e.split(",")){const l=a.indexOf(":");if(l>0&&a.slice(0,l)===r)return a.slice(l+1)}return""}function X2(e){return e?e.split(",").filter(Boolean):[]}function K2(e){return e.trim().split(" ")[0]||"unknown"}function ao(e){return e.trim().split(" ")[0].split("/")[0]||"unknown"}function uo(e){if(e<1e3)return`${e} ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const r=Math.round(e/1e3),a=Math.floor(r/60),l=r%60;return`${a}m ${String(l).padStart(2,"0")}s`}function Bm(e){return e==null?"unpriced":`$${e.toFixed(6)}`}function zr(e){return e==null?"unpriced":e===0?"$0":e<.01?`$${e.toFixed(5)}`:e<1e3?`$${e.toFixed(2)}`:`$${new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)}`}function Ft(e){return e?new Intl.NumberFormat().format(e):""}function Ht(e){return new Intl.NumberFormat().format(e)}function Re(e){return Math.abs(e)<1e3?new Intl.NumberFormat().format(e):new Intl.NumberFormat(void 0,{notation:"compact",maximumFractionDigits:1}).format(e)}function I0(e){if(!e)return"";const r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleString()}function tl(e){if(!e)return"";const r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleDateString()}function q0(e){var r,a,l="";if(typeof e=="string"||typeof e=="number")l+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r{const a=new Array(e.length+r.length);for(let l=0;l({classGroupId:e,validator:r}),P0=(e=new Map,r=null,a)=>({nextPart:e,validators:r,classGroupId:a}),sc="-",Gy=[],J2="arbitrary..",W2=e=>{const r=tN(e),{conflictingClassGroups:a,conflictingClassGroupModifiers:l}=e;return{getClassGroupId:d=>{if(d.startsWith("[")&&d.endsWith("]"))return eN(d);const f=d.split(sc),h=f[0]===""&&f.length>1?1:0;return $0(f,h,r)},getConflictingClassGroupIds:(d,f)=>{if(f){const h=l[d],m=a[d];return h?m?Q2(m,h):h:m||Gy}return a[d]||Gy}}},$0=(e,r,a)=>{if(e.length-r===0)return a.classGroupId;const o=e[r],c=a.nextPart.get(o);if(c){const m=$0(e,r+1,c);if(m)return m}const d=a.validators;if(d===null)return;const f=r===0?e.join(sc):e.slice(r).join(sc),h=d.length;for(let m=0;me.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),a=r.indexOf(":"),l=r.slice(0,a);return l?J2+l:void 0})(),tN=e=>{const{theme:r,classGroups:a}=e;return nN(a,r)},nN=(e,r)=>{const a=P0();for(const l in e){const o=e[l];Im(o,a,l,r)}return a},Im=(e,r,a,l)=>{const o=e.length;for(let c=0;c{if(typeof e=="string"){aN(e,r,a);return}if(typeof e=="function"){lN(e,r,a,l);return}iN(e,r,a,l)},aN=(e,r,a)=>{const l=e===""?r:F0(r,e);l.classGroupId=a},lN=(e,r,a,l)=>{if(sN(e)){Im(e(l),r,a,l);return}r.validators===null&&(r.validators=[]),r.validators.push(Z2(a,e))},iN=(e,r,a,l)=>{const o=Object.entries(e),c=o.length;for(let d=0;d{let a=e;const l=r.split(sc),o=l.length;for(let c=0;c"isThemeGetter"in e&&e.isThemeGetter===!0,oN=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,a=Object.create(null),l=Object.create(null);const o=(c,d)=>{a[c]=d,r++,r>e&&(r=0,l=a,a=Object.create(null))};return{get(c){let d=a[c];if(d!==void 0)return d;if((d=l[c])!==void 0)return o(c,d),d},set(c,d){c in a?a[c]=d:o(c,d)}}},lm="!",Yy=":",uN=[],Xy=(e,r,a,l,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:a,maybePostfixModifierPosition:l,isExternal:o}),cN=e=>{const{prefix:r,experimentalParseClassName:a}=e;let l=o=>{const c=[];let d=0,f=0,h=0,m;const v=o.length;for(let j=0;jh?m-h:void 0;return Xy(c,y,b,k)};if(r){const o=r+Yy,c=l;l=d=>d.startsWith(o)?c(d.slice(o.length)):Xy(uN,!1,d,void 0,!0)}if(a){const o=l;l=c=>a({className:c,parseClassName:o})}return l},dN=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((a,l)=>{r.set(a,1e6+l)}),a=>{const l=[];let o=[];for(let c=0;c0&&(o.sort(),l.push(...o),o=[]),l.push(d)):o.push(d)}return o.length>0&&(o.sort(),l.push(...o)),l}},fN=e=>({cache:oN(e.cacheSize),parseClassName:cN(e),sortModifiers:dN(e),postfixLookupClassGroupIds:hN(e),...W2(e)}),hN=e=>{const r=Object.create(null),a=e.postfixLookupClassGroups;if(a)for(let l=0;l{const{parseClassName:a,getClassGroupId:l,getConflictingClassGroupIds:o,sortModifiers:c,postfixLookupClassGroupIds:d}=r,f=[],h=e.trim().split(mN);let m="";for(let v=h.length-1;v>=0;v-=1){const x=h[v],{isExternal:b,modifiers:y,hasImportantModifier:k,baseClassName:j,maybePostfixModifierPosition:T}=a(x);if(b){m=x+(m.length>0?" "+m:m);continue}let C=!!T,R;if(C){const N=j.substring(0,T);R=l(N);const L=R&&d[R]?l(j):void 0;L&&L!==R&&(R=L,C=!1)}else R=l(j);if(!R){if(!C){m=x+(m.length>0?" "+m:m);continue}if(R=l(j),!R){m=x+(m.length>0?" "+m:m);continue}C=!1}const D=y.length===0?"":y.length===1?y[0]:c(y).join(":"),I=k?D+lm:D,O=I+R;if(f.indexOf(O)>-1)continue;f.push(O);const E=o(R,C);for(let N=0;N0?" "+m:m)}return m},gN=(...e)=>{let r=0,a,l,o="";for(;r{if(typeof e=="string")return e;let r,a="";for(let l=0;l{let a,l,o,c;const d=h=>{const m=r.reduce((v,x)=>x(v),e());return a=fN(m),l=a.cache.get,o=a.cache.set,c=f,f(h)},f=h=>{const m=l(h);if(m)return m;const v=pN(h,a);return o(h,v),v};return c=d,(...h)=>c(gN(...h))},vN=[],nn=e=>{const r=a=>a[e]||vN;return r.isThemeGetter=!0,r},G0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Y0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,yN=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,bN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,wN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,SN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ya=e=>yN.test(e),We=e=>!!e&&!Number.isNaN(Number(e)),Mr=e=>!!e&&Number.isInteger(Number(e)),gh=e=>e.endsWith("%")&&We(e.slice(0,-1)),da=e=>bN.test(e),X0=()=>!0,CN=e=>wN.test(e)&&!SN.test(e),qm=()=>!1,NN=e=>jN.test(e),EN=e=>kN.test(e),TN=e=>!je(e)&&!Ce(e),AN=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),_N=e=>ml(e,Z0,qm),je=e=>G0.test(e),Bl=e=>ml(e,J0,CN),Ky=e=>ml(e,BN,We),MN=e=>ml(e,e1,X0),RN=e=>ml(e,W0,qm),Qy=e=>ml(e,K0,qm),DN=e=>ml(e,Q0,EN),qu=e=>ml(e,t1,NN),Ce=e=>Y0.test(e),Ks=e=>Ql(e,J0),ON=e=>Ql(e,W0),Zy=e=>Ql(e,K0),zN=e=>Ql(e,Z0),LN=e=>Ql(e,Q0),Hu=e=>Ql(e,t1,!0),UN=e=>Ql(e,e1,!0),ml=(e,r,a)=>{const l=G0.exec(e);return l?l[1]?r(l[1]):a(l[2]):!1},Ql=(e,r,a=!1)=>{const l=Y0.exec(e);return l?l[1]?r(l[1]):a:!1},K0=e=>e==="position"||e==="percentage",Q0=e=>e==="image"||e==="url",Z0=e=>e==="length"||e==="size"||e==="bg-size",J0=e=>e==="length",BN=e=>e==="number",W0=e=>e==="family-name",e1=e=>e==="number"||e==="weight",t1=e=>e==="shadow",IN=()=>{const e=nn("color"),r=nn("font"),a=nn("text"),l=nn("font-weight"),o=nn("tracking"),c=nn("leading"),d=nn("breakpoint"),f=nn("container"),h=nn("spacing"),m=nn("radius"),v=nn("shadow"),x=nn("inset-shadow"),b=nn("text-shadow"),y=nn("drop-shadow"),k=nn("blur"),j=nn("perspective"),T=nn("aspect"),C=nn("ease"),R=nn("animate"),D=()=>["auto","avoid","all","avoid-page","page","left","right","column"],I=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],O=()=>[...I(),Ce,je],E=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[Ce,je,h],X=()=>[Ya,"full","auto",...L()],H=()=>[Mr,"none","subgrid",Ce,je],P=()=>["auto",{span:["full",Mr,Ce,je]},Mr,Ce,je],K=()=>[Mr,"auto",Ce,je],ue=()=>["auto","min","max","fr",Ce,je],le=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],W=()=>["start","end","center","stretch","center-safe","end-safe"],B=()=>["auto",...L()],F=()=>[Ya,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],ae=()=>[Ya,"screen","full","dvw","lvw","svw","min","max","fit",...L()],Z=()=>[Ya,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],A=()=>[e,Ce,je],U=()=>[...I(),Zy,Qy,{position:[Ce,je]}],V=()=>["no-repeat",{repeat:["","x","y","space","round"]}],M=()=>["auto","cover","contain",zN,_N,{size:[Ce,je]}],se=()=>[gh,Ks,Bl],Y=()=>["","none","full",m,Ce,je],ce=()=>["",We,Ks,Bl],re=()=>["solid","dashed","dotted","double"],ye=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],fe=()=>[We,gh,Zy,Qy],we=()=>["","none",k,Ce,je],Ee=()=>["none",We,Ce,je],Se=()=>["none",We,Ce,je],Ie=()=>[We,Ce,je],Be=()=>[Ya,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[da],breakpoint:[da],color:[X0],container:[da],"drop-shadow":[da],ease:["in","out","in-out"],font:[TN],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[da],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[da],shadow:[da],spacing:["px",We],text:[da],"text-shadow":[da],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ya,je,Ce,T]}],container:["container"],"container-type":[{"@container":["","normal","size",Ce,je]}],"container-named":[AN],columns:[{columns:[We,je,Ce,f]}],"break-after":[{"break-after":D()}],"break-before":[{"break-before":D()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:O()}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:X()}],"inset-x":[{"inset-x":X()}],"inset-y":[{"inset-y":X()}],start:[{"inset-s":X(),start:X()}],end:[{"inset-e":X(),end:X()}],"inset-bs":[{"inset-bs":X()}],"inset-be":[{"inset-be":X()}],top:[{top:X()}],right:[{right:X()}],bottom:[{bottom:X()}],left:[{left:X()}],visibility:["visible","invisible","collapse"],z:[{z:[Mr,"auto",Ce,je]}],basis:[{basis:[Ya,"full","auto",f,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[We,Ya,"auto","initial","none",je]}],grow:[{grow:["",We,Ce,je]}],shrink:[{shrink:["",We,Ce,je]}],order:[{order:[Mr,"first","last","none",Ce,je]}],"grid-cols":[{"grid-cols":H()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":K()}],"col-end":[{"col-end":K()}],"grid-rows":[{"grid-rows":H()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":K()}],"row-end":[{"row-end":K()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":ue()}],"auto-rows":[{"auto-rows":ue()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...le(),"normal"]}],"justify-items":[{"justify-items":[...W(),"normal"]}],"justify-self":[{"justify-self":["auto",...W()]}],"align-content":[{content:["normal",...le()]}],"align-items":[{items:[...W(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...W(),{baseline:["","last"]}]}],"place-content":[{"place-content":le()}],"place-items":[{"place-items":[...W(),"baseline"]}],"place-self":[{"place-self":["auto",...W()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:B()}],mx:[{mx:B()}],my:[{my:B()}],ms:[{ms:B()}],me:[{me:B()}],mbs:[{mbs:B()}],mbe:[{mbe:B()}],mt:[{mt:B()}],mr:[{mr:B()}],mb:[{mb:B()}],ml:[{ml:B()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:F()}],"inline-size":[{inline:["auto",...ae()]}],"min-inline-size":[{"min-inline":["auto",...ae()]}],"max-inline-size":[{"max-inline":["none",...ae()]}],"block-size":[{block:["auto",...Z()]}],"min-block-size":[{"min-block":["auto",...Z()]}],"max-block-size":[{"max-block":["none",...Z()]}],w:[{w:[f,"screen",...F()]}],"min-w":[{"min-w":[f,"screen","none",...F()]}],"max-w":[{"max-w":[f,"screen","none","prose",{screen:[d]},...F()]}],h:[{h:["screen","lh",...F()]}],"min-h":[{"min-h":["screen","lh","none",...F()]}],"max-h":[{"max-h":["screen","lh",...F()]}],"font-size":[{text:["base",a,Ks,Bl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[l,UN,MN]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",gh,je]}],"font-family":[{font:[ON,RN,r]}],"font-features":[{"font-features":[je]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,Ce,je]}],"line-clamp":[{"line-clamp":[We,"none",Ce,Ky]}],leading:[{leading:[c,...L()]}],"list-image":[{"list-image":["none",Ce,je]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ce,je]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...re(),"wavy"]}],"text-decoration-thickness":[{decoration:[We,"from-font","auto",Ce,Bl]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[We,"auto",Ce,je]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[Mr,Ce,je]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ce,je]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ce,je]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:U()}],"bg-repeat":[{bg:V()}],"bg-size":[{bg:M()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Mr,Ce,je],radial:["",Ce,je],conic:[Mr,Ce,je]},LN,DN]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:Y()}],"rounded-s":[{"rounded-s":Y()}],"rounded-e":[{"rounded-e":Y()}],"rounded-t":[{"rounded-t":Y()}],"rounded-r":[{"rounded-r":Y()}],"rounded-b":[{"rounded-b":Y()}],"rounded-l":[{"rounded-l":Y()}],"rounded-ss":[{"rounded-ss":Y()}],"rounded-se":[{"rounded-se":Y()}],"rounded-ee":[{"rounded-ee":Y()}],"rounded-es":[{"rounded-es":Y()}],"rounded-tl":[{"rounded-tl":Y()}],"rounded-tr":[{"rounded-tr":Y()}],"rounded-br":[{"rounded-br":Y()}],"rounded-bl":[{"rounded-bl":Y()}],"border-w":[{border:ce()}],"border-w-x":[{"border-x":ce()}],"border-w-y":[{"border-y":ce()}],"border-w-s":[{"border-s":ce()}],"border-w-e":[{"border-e":ce()}],"border-w-bs":[{"border-bs":ce()}],"border-w-be":[{"border-be":ce()}],"border-w-t":[{"border-t":ce()}],"border-w-r":[{"border-r":ce()}],"border-w-b":[{"border-b":ce()}],"border-w-l":[{"border-l":ce()}],"divide-x":[{"divide-x":ce()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":ce()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...re(),"hidden","none"]}],"divide-style":[{divide:[...re(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...re(),"none","hidden"]}],"outline-offset":[{"outline-offset":[We,Ce,je]}],"outline-w":[{outline:["",We,Ks,Bl]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",v,Hu,qu]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",x,Hu,qu]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:ce()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[We,Bl]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":ce()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",b,Hu,qu]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[We,Ce,je]}],"mix-blend":[{"mix-blend":[...ye(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ye()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[We]}],"mask-image-linear-from-pos":[{"mask-linear-from":fe()}],"mask-image-linear-to-pos":[{"mask-linear-to":fe()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":fe()}],"mask-image-t-to-pos":[{"mask-t-to":fe()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":fe()}],"mask-image-r-to-pos":[{"mask-r-to":fe()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":fe()}],"mask-image-b-to-pos":[{"mask-b-to":fe()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":fe()}],"mask-image-l-to-pos":[{"mask-l-to":fe()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":fe()}],"mask-image-x-to-pos":[{"mask-x-to":fe()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":fe()}],"mask-image-y-to-pos":[{"mask-y-to":fe()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[Ce,je]}],"mask-image-radial-from-pos":[{"mask-radial-from":fe()}],"mask-image-radial-to-pos":[{"mask-radial-to":fe()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":I()}],"mask-image-conic-pos":[{"mask-conic":[We]}],"mask-image-conic-from-pos":[{"mask-conic-from":fe()}],"mask-image-conic-to-pos":[{"mask-conic-to":fe()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:U()}],"mask-repeat":[{mask:V()}],"mask-size":[{mask:M()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ce,je]}],filter:[{filter:["","none",Ce,je]}],blur:[{blur:we()}],brightness:[{brightness:[We,Ce,je]}],contrast:[{contrast:[We,Ce,je]}],"drop-shadow":[{"drop-shadow":["","none",y,Hu,qu]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",We,Ce,je]}],"hue-rotate":[{"hue-rotate":[We,Ce,je]}],invert:[{invert:["",We,Ce,je]}],saturate:[{saturate:[We,Ce,je]}],sepia:[{sepia:["",We,Ce,je]}],"backdrop-filter":[{"backdrop-filter":["","none",Ce,je]}],"backdrop-blur":[{"backdrop-blur":we()}],"backdrop-brightness":[{"backdrop-brightness":[We,Ce,je]}],"backdrop-contrast":[{"backdrop-contrast":[We,Ce,je]}],"backdrop-grayscale":[{"backdrop-grayscale":["",We,Ce,je]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[We,Ce,je]}],"backdrop-invert":[{"backdrop-invert":["",We,Ce,je]}],"backdrop-opacity":[{"backdrop-opacity":[We,Ce,je]}],"backdrop-saturate":[{"backdrop-saturate":[We,Ce,je]}],"backdrop-sepia":[{"backdrop-sepia":["",We,Ce,je]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ce,je]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[We,"initial",Ce,je]}],ease:[{ease:["linear","initial",C,Ce,je]}],delay:[{delay:[We,Ce,je]}],animate:[{animate:["none",R,Ce,je]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[j,Ce,je]}],"perspective-origin":[{"perspective-origin":O()}],rotate:[{rotate:Ee()}],"rotate-x":[{"rotate-x":Ee()}],"rotate-y":[{"rotate-y":Ee()}],"rotate-z":[{"rotate-z":Ee()}],scale:[{scale:Se()}],"scale-x":[{"scale-x":Se()}],"scale-y":[{"scale-y":Se()}],"scale-z":[{"scale-z":Se()}],"scale-3d":["scale-3d"],skew:[{skew:Ie()}],"skew-x":[{"skew-x":Ie()}],"skew-y":[{"skew-y":Ie()}],transform:[{transform:[Ce,je,"","none","gpu","cpu"]}],"transform-origin":[{origin:O()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Be()}],"translate-x":[{"translate-x":Be()}],"translate-y":[{"translate-y":Be()}],"translate-z":[{"translate-z":Be()}],"translate-none":["translate-none"],zoom:[{zoom:[Mr,Ce,je]}],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ce,je]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ce,je]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[We,Ks,Bl,Ky]}],stroke:[{stroke:["none",...A()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},qN=xN(IN);function Ne(...e){return qN(H0(e))}function n1({className:e}){return s.jsx("svg",{viewBox:"0 0 151.08 184",className:Ne("h-6 w-auto",e),"aria-hidden":"true",fill:"currentColor",children:s.jsx("path",{d:"M131.08,52.32l-18.67-10.96h-1.01l-16.68,9.79v-20.19s-18.67-10.96-18.67-10.96h-1.01l-18.67,10.96v20.19s-16.68-9.79-16.68-9.79h-1.01l-18.67,10.96v.72s0,78.5,0,78.5l18.67,11.12h1.02l16.67-9.92v20.16s18.67,11.12,18.67,11.12h1.02l18.67-11.12v-20.16s16.67,9.92,16.67,9.92h1.02l18.67-11.12V52.32ZM39.18,43.38l16.7,9.81-16.7,9.94-16.7-9.94,16.7-9.81ZM22,55.23l16.18,9.63v54.28l-16.18,9.5V55.23ZM38.18,121.46v18.57l-15.7-9.35,15.7-9.22ZM40.18,140.03v-18.57l15.7,9.22-15.7,9.35ZM56.36,128.64l-16.18-9.5v-54.28l16.18-9.63v73.41ZM92.72,53.04v19.46l-16.18-9.5v-19.49l16.18-9.63v19.16ZM75.54,84.48l-16.7-9.94,16.7-9.81,16.7,9.81-16.7,9.94ZM76.54,41.18v-18.57l15.7,9.22-15.7,9.35ZM74.54,22.61v18.57l-15.7-9.35,15.7-9.22ZM58.36,33.87l16.18,9.63v19.49l-16.18,9.5v-38.63ZM58.36,76.58l16.18,9.63v54.28l-16.18,9.5v-73.41ZM74.54,142.81v18.57l-15.7-9.35,15.7-9.22ZM76.54,161.38v-18.57l15.7,9.22-15.7,9.35ZM92.72,149.99l-16.18-9.5v-54.28l16.18-9.63v73.41ZM112.9,43.97l15.7,9.22-15.7,9.35v-18.57ZM110.9,43.97v18.57l-15.7-9.35,15.7-9.22ZM94.72,55.23l16.18,9.63v54.28l-16.18,9.5V55.23ZM111.9,140.63l-16.7-9.95,16.7-9.81,16.7,9.81-16.7,9.95ZM129.08,128.64l-16.18-9.5v-54.28l16.18-9.63v73.41Z"})})}function Jy(e,r){if(typeof e=="function")return e(r);e!=null&&(e.current=r)}function Sc(...e){return r=>{let a=!1;const l=e.map(o=>{const c=Jy(o,r);return!a&&typeof c=="function"&&(a=!0),c});if(a)return()=>{for(let o=0;o{const{children:a,...l}=e,o=S.Children.toArray(a),c=o.find(HN);if(c){const d=c.props.children,f=o.map(h=>h===c?S.Children.count(d)>1?S.Children.only(null):S.isValidElement(d)?d.props.children:null:h);return s.jsx(im,{...l,ref:r,children:S.isValidElement(d)?S.cloneElement(d,void 0,f):null})}return s.jsx(im,{...l,ref:r,children:a})});xa.displayName="Slot";var im=S.forwardRef((e,r)=>{const{children:a,...l}=e;if(S.isValidElement(a)){const o=$N(a);return S.cloneElement(a,{...PN(l,a.props),ref:r?Sc(r,o):o})}return S.Children.count(a)>1?S.Children.only(null):null});im.displayName="SlotClone";var r1=({children:e})=>s.jsx(s.Fragment,{children:e});function HN(e){return S.isValidElement(e)&&e.type===r1}function PN(e,r){const a={...r};for(const l in r){const o=e[l],c=r[l];/^on[A-Z]/.test(l)?o&&c?a[l]=(...f)=>{c(...f),o(...f)}:o&&(a[l]=o):l==="style"?a[l]={...o,...c}:l==="className"&&(a[l]=[o,c].filter(Boolean).join(" "))}return{...e,...a}}function $N(e){var l,o;let r=(l=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:l.get,a=r&&"isReactWarning"in r&&r.isReactWarning;return a?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,a=r&&"isReactWarning"in r&&r.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}const Wy=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,eb=H0,a1=(e,r)=>a=>{var l;if((r==null?void 0:r.variants)==null)return eb(e,a==null?void 0:a.class,a==null?void 0:a.className);const{variants:o,defaultVariants:c}=r,d=Object.keys(o).map(m=>{const v=a==null?void 0:a[m],x=c==null?void 0:c[m];if(v===null)return null;const b=Wy(v)||Wy(x);return o[m][b]}),f=a&&Object.entries(a).reduce((m,v)=>{let[x,b]=v;return b===void 0||(m[x]=b),m},{}),h=r==null||(l=r.compoundVariants)===null||l===void 0?void 0:l.reduce((m,v)=>{let{class:x,className:b,...y}=v;return Object.entries(y).every(k=>{let[j,T]=k;return Array.isArray(T)?T.includes({...c,...f}[j]):{...c,...f}[j]===T})?[...m,x,b]:m},[]);return eb(e,d,h,a==null?void 0:a.class,a==null?void 0:a.className)},Hm=a1("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function Me({className:e,variant:r,size:a,asChild:l=!1,...o}){const c=l?xa:"button";return s.jsx(c,{"data-slot":"button",className:Ne(Hm({variant:r,size:a,className:e})),...o})}function Wt({className:e,type:r,...a}){return s.jsx("input",{type:r,"data-slot":"input",autoComplete:"off",className:Ne("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",e),...a})}var vo=B0();const l1=bc(vo);var FN=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ge=FN.reduce((e,r)=>{const a=S.forwardRef((l,o)=>{const{asChild:c,...d}=l,f=c?xa:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(f,{...d,ref:o})});return a.displayName=`Primitive.${r}`,{...e,[r]:a}},{});function i1(e,r){e&&vo.flushSync(()=>e.dispatchEvent(r))}var VN="Label",s1=S.forwardRef((e,r)=>s.jsx(Ge.label,{...e,ref:r,onMouseDown:a=>{var o;a.target.closest("button, input, select, textarea")||((o=e.onMouseDown)==null||o.call(e,a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}}));s1.displayName=VN;var GN=s1;function Jt({className:e,...r}){return s.jsx(GN,{"data-slot":"label",className:Ne("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...r})}/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const YN=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),o1=(...e)=>e.filter((r,a,l)=>!!r&&r.trim()!==""&&l.indexOf(r)===a).join(" ").trim();/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var XN={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"};/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KN=S.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,iconNode:d,...f},h)=>S.createElement("svg",{ref:h,...XN,width:r,height:r,stroke:e,strokeWidth:l?Number(a)*24/Number(r):a,className:o1("lucide",o),...f},[...d.map(([m,v])=>S.createElement(m,v)),...Array.isArray(c)?c:[c]]));/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bt=(e,r)=>{const a=S.forwardRef(({className:l,...o},c)=>S.createElement(KN,{ref:c,iconNode:r,className:o1(`lucide-${YN(e)}`,l),...o}));return a.displayName=`${e}`,a};/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QN=bt("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const u1=bt("ChartBar",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16h8",key:"srdodz"}],["path",{d:"M7 11h12",key:"127s9w"}],["path",{d:"M7 6h3",key:"w9rmul"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZN=bt("ChartPie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const jc=bt("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Ji=bt("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JN=bt("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sm=bt("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const WN=bt("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eE=bt("CircleUserRound",[["path",{d:"M18 20a6 6 0 0 0-12 0",key:"1qehca"}],["circle",{cx:"12",cy:"10",r:"4",key:"1h16sb"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Pm=bt("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"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const tE=bt("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nE=bt("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yo=bt("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const c1=bt("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rE=bt("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aE=bt("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lE=bt("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const d1=bt("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pl=bt("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const iE=bt("SendHorizontal",[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sE=bt("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oE=bt("SunMoon",[["path",{d:"M12 8a2.83 2.83 0 0 0 4 4 4 4 0 1 1-4-4",key:"1fu5g2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.9 4.9 1.4 1.4",key:"b9915j"}],["path",{d:"m17.7 17.7 1.4 1.4",key:"qc3ed3"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.3 17.7-1.4 1.4",key:"5gca6"}],["path",{d:"m19.1 4.9-1.4 1.4",key:"wpu9u6"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uE=bt("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"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const om=bt("TableProperties",[["path",{d:"M15 3v18",key:"14nvp0"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cE=bt("Tags",[["path",{d:"m15 5 6.3 6.3a2.4 2.4 0 0 1 0 3.4L17 19",key:"1cbfv1"}],["path",{d:"M9.586 5.586A2 2 0 0 0 8.172 5H3a1 1 0 0 0-1 1v5.172a2 2 0 0 0 .586 1.414L8.29 18.29a2.426 2.426 0 0 0 3.42 0l3.58-3.58a2.426 2.426 0 0 0 0-3.42z",key:"135mg7"}],["circle",{cx:"6.5",cy:"9.5",r:".5",fill:"currentColor",key:"5pm5xn"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $m=bt("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const Fm=bt("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** - * @license lucide-react v0.454.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dE=bt("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function kt({className:e,...r}){return s.jsx(aE,{role:"status","aria-label":"Loading",className:Ne("size-4 animate-spin",e),...r})}var fE="Separator",tb="horizontal",hE=["horizontal","vertical"],f1=S.forwardRef((e,r)=>{const{decorative:a,orientation:l=tb,...o}=e,c=mE(l)?l:tb,f=a?{role:"none"}:{"aria-orientation":c==="vertical"?c:void 0,role:"separator"};return s.jsx(Ge.div,{"data-orientation":c,...f,...o,ref:r})});f1.displayName=fE;function mE(e){return hE.includes(e)}var pE=f1;function nb({className:e,orientation:r="horizontal",decorative:a=!0,...l}){return s.jsx(pE,{"data-slot":"separator",decorative:a,orientation:r,className:Ne("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...l})}function Ke({className:e,...r}){return s.jsx("div",{"data-slot":"card",className:Ne("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e),...r})}function Ze({className:e,...r}){return s.jsx("div",{"data-slot":"card-header",className:Ne("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",e),...r})}function Je({className:e,...r}){return s.jsx("div",{"data-slot":"card-title",className:Ne("leading-none font-semibold",e),...r})}function it({className:e,...r}){return s.jsx("div",{"data-slot":"card-description",className:Ne("text-muted-foreground text-sm",e),...r})}function gE({className:e,...r}){return s.jsx("div",{"data-slot":"card-action",className:Ne("col-start-2 row-span-2 row-start-1 self-start justify-self-end",e),...r})}function Qe({className:e,...r}){return s.jsx("div",{"data-slot":"card-content",className:Ne("px-6",e),...r})}function xE({me:e,onLogin:r}){const[a,l]=S.useState(""),[o,c]=S.useState(null),[d,f]=S.useState(!1),h=async m=>{m.preventDefault(),f(!0),c(null);try{await He.post("/auth/password",{password:a}),r()}catch(v){c(v instanceof wc?v.message:"login failed"),f(!1)}};return s.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:s.jsxs(Ke,{className:"w-full max-w-sm",children:[s.jsxs(Ze,{className:"items-center text-center",children:[s.jsx(n1,{className:"mx-auto mb-2 h-10"}),s.jsx(Je,{className:"font-serif text-2xl",children:"llmproxy"})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[e.sso_enabled&&s.jsx(Me,{className:"w-full",onClick:()=>window.location.href="/auth/login",children:"Sign in with SSO"}),e.sso_enabled&&e.password_enabled&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(nb,{className:"flex-1"}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"or"}),s.jsx(nb,{className:"flex-1"})]}),e.password_enabled&&s.jsxs("form",{onSubmit:h,className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"admin-password",children:"Admin password"}),s.jsx(Wt,{id:"admin-password",type:"password",autoComplete:"current-password",value:a,onChange:m=>l(m.target.value),"aria-invalid":o!=null}),o&&s.jsx("p",{className:"text-sm text-destructive",children:o})]}),s.jsxs(Me,{type:"submit",variant:e.sso_enabled?"outline":"default",disabled:d||a==="",className:"w-full",children:[d&&s.jsx(kt,{}),"Sign in as admin"]})]}),!e.sso_enabled&&!e.password_enabled&&s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Password login is disabled and no SSO is configured. Mint a key with ",s.jsx("code",{className:"font-mono",children:"llmproxy key create"})," and use the API directly."]})]})]})})}var vE=e=>{switch(e){case"success":return wE;case"info":return jE;case"warning":return SE;case"error":return kE;default:return null}},yE=Array(12).fill(0),bE=({visible:e,className:r})=>ve.createElement("div",{className:["sonner-loading-wrapper",r].filter(Boolean).join(" "),"data-visible":e},ve.createElement("div",{className:"sonner-spinner"},yE.map((a,l)=>ve.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${l}`})))),wE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),SE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),jE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),kE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),CE=ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ve.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),NE=()=>{let[e,r]=ve.useState(document.hidden);return ve.useEffect(()=>{let a=()=>{r(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),e},um=1,EE=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let r=this.subscribers.indexOf(e);this.subscribers.splice(r,1)}),this.publish=e=>{this.subscribers.forEach(r=>r(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var r;let{message:a,...l}=e,o=typeof(e==null?void 0:e.id)=="number"||((r=e.id)==null?void 0:r.length)>0?e.id:um++,c=this.toasts.find(f=>f.id===o),d=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(o)&&this.dismissedToasts.delete(o),c?this.toasts=this.toasts.map(f=>f.id===o?(this.publish({...f,...e,id:o,title:a}),{...f,...e,id:o,dismissible:d,title:a}):f):this.addToast({title:a,...l,dismissible:d,id:o}),o},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(r=>{this.subscribers.forEach(a=>a({id:r.id,dismiss:!0}))}),this.subscribers.forEach(r=>r({id:e,dismiss:!0})),e),this.message=(e,r)=>this.create({...r,message:e}),this.error=(e,r)=>this.create({...r,message:e,type:"error"}),this.success=(e,r)=>this.create({...r,type:"success",message:e}),this.info=(e,r)=>this.create({...r,type:"info",message:e}),this.warning=(e,r)=>this.create({...r,type:"warning",message:e}),this.loading=(e,r)=>this.create({...r,type:"loading",message:e}),this.promise=(e,r)=>{if(!r)return;let a;r.loading!==void 0&&(a=this.create({...r,promise:e,type:"loading",message:r.loading,description:typeof r.description!="function"?r.description:void 0}));let l=e instanceof Promise?e:e(),o=a!==void 0,c,d=l.then(async h=>{if(c=["resolve",h],ve.isValidElement(h))o=!1,this.create({id:a,type:"default",message:h});else if(AE(h)&&!h.ok){o=!1;let m=typeof r.error=="function"?await r.error(`HTTP error! status: ${h.status}`):r.error,v=typeof r.description=="function"?await r.description(`HTTP error! status: ${h.status}`):r.description;this.create({id:a,type:"error",message:m,description:v})}else if(r.success!==void 0){o=!1;let m=typeof r.success=="function"?await r.success(h):r.success,v=typeof r.description=="function"?await r.description(h):r.description;this.create({id:a,type:"success",message:m,description:v})}}).catch(async h=>{if(c=["reject",h],r.error!==void 0){o=!1;let m=typeof r.error=="function"?await r.error(h):r.error,v=typeof r.description=="function"?await r.description(h):r.description;this.create({id:a,type:"error",message:m,description:v})}}).finally(()=>{var h;o&&(this.dismiss(a),a=void 0),(h=r.finally)==null||h.call(r)}),f=()=>new Promise((h,m)=>d.then(()=>c[0]==="reject"?m(c[1]):h(c[1])).catch(m));return typeof a!="string"&&typeof a!="number"?{unwrap:f}:Object.assign(a,{unwrap:f})},this.custom=(e,r)=>{let a=(r==null?void 0:r.id)||um++;return this.create({jsx:e(a),id:a,...r}),a},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Bn=new EE,TE=(e,r)=>{let a=(r==null?void 0:r.id)||um++;return Bn.addToast({title:e,...r,id:a}),a},AE=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",_E=TE,ME=()=>Bn.toasts,RE=()=>Bn.getActiveToasts(),Ve=Object.assign(_E,{success:Bn.success,info:Bn.info,warning:Bn.warning,error:Bn.error,custom:Bn.custom,message:Bn.message,promise:Bn.promise,dismiss:Bn.dismiss,loading:Bn.loading},{getHistory:ME,getToasts:RE});function DE(e,{insertAt:r}={}){if(typeof document>"u")return;let a=document.head||document.getElementsByTagName("head")[0],l=document.createElement("style");l.type="text/css",r==="top"&&a.firstChild?a.insertBefore(l,a.firstChild):a.appendChild(l),l.styleSheet?l.styleSheet.cssText=e:l.appendChild(document.createTextNode(e))}DE(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} -`);function Pu(e){return e.label!==void 0}var OE=3,zE="32px",LE="16px",rb=4e3,UE=356,BE=14,IE=20,qE=200;function xr(...e){return e.filter(Boolean).join(" ")}function HE(e){let[r,a]=e.split("-"),l=[];return r&&l.push(r),a&&l.push(a),l}var PE=e=>{var r,a,l,o,c,d,f,h,m,v,x;let{invert:b,toast:y,unstyled:k,interacting:j,setHeights:T,visibleToasts:C,heights:R,index:D,toasts:I,expanded:O,removeToast:E,defaultRichColors:N,closeButton:L,style:X,cancelButtonStyle:H,actionButtonStyle:P,className:K="",descriptionClassName:ue="",duration:le,position:W,gap:B,loadingIcon:F,expandByDefault:ae,classNames:Z,icons:A,closeButtonAriaLabel:U="Close toast",pauseWhenPageIsHidden:V}=e,[M,se]=ve.useState(null),[Y,ce]=ve.useState(null),[re,ye]=ve.useState(!1),[fe,we]=ve.useState(!1),[Ee,Se]=ve.useState(!1),[Ie,Be]=ve.useState(!1),[Mt,Nt]=ve.useState(!1),[Et,Bt]=ve.useState(0),[Rt,Dt]=ve.useState(0),zt=ve.useRef(y.duration||le||rb),be=ve.useRef(null),mt=ve.useRef(null),Q=D===0,Pe=D+1<=C,ne=y.type,z=y.dismissible!==!1,he=y.className||"",ke=y.descriptionClassName||"",ze=ve.useMemo(()=>R.findIndex(qe=>qe.toastId===y.id)||0,[R,y.id]),an=ve.useMemo(()=>{var qe;return(qe=y.closeButton)!=null?qe:L},[y.closeButton,L]),Tn=ve.useMemo(()=>y.duration||le||rb,[y.duration,le]),en=ve.useRef(0),Tt=ve.useRef(0),on=ve.useRef(0),st=ve.useRef(null),[kr,Hn]=W.split("-"),No=ve.useMemo(()=>R.reduce((qe,ht,wt)=>wt>=ze?qe:qe+ht.height,0),[R,ze]),bl=NE(),ei=y.invert||b,Sa=ne==="loading";Tt.current=ve.useMemo(()=>ze*B+No,[ze,No]),ve.useEffect(()=>{zt.current=Tn},[Tn]),ve.useEffect(()=>{ye(!0)},[]),ve.useEffect(()=>{let qe=mt.current;if(qe){let ht=qe.getBoundingClientRect().height;return Dt(ht),T(wt=>[{toastId:y.id,height:ht,position:y.position},...wt]),()=>T(wt=>wt.filter(jn=>jn.toastId!==y.id))}},[T,y.id]),ve.useLayoutEffect(()=>{if(!re)return;let qe=mt.current,ht=qe.style.height;qe.style.height="auto";let wt=qe.getBoundingClientRect().height;qe.style.height=ht,Dt(wt),T(jn=>jn.find(un=>un.toastId===y.id)?jn.map(un=>un.toastId===y.id?{...un,height:wt}:un):[{toastId:y.id,height:wt,position:y.position},...jn])},[re,y.title,y.description,T,y.id]);let yn=ve.useCallback(()=>{we(!0),Bt(Tt.current),T(qe=>qe.filter(ht=>ht.toastId!==y.id)),setTimeout(()=>{E(y)},qE)},[y,E,T,Tt]);ve.useEffect(()=>{if(y.promise&&ne==="loading"||y.duration===1/0||y.type==="loading")return;let qe;return O||j||V&&bl?(()=>{if(on.current{var ht;(ht=y.onAutoClose)==null||ht.call(y,y),yn()},zt.current)),()=>clearTimeout(qe)},[O,j,y,ne,V,bl,yn]),ve.useEffect(()=>{y.delete&&yn()},[yn,y.delete]);function ti(){var qe,ht,wt;return A!=null&&A.loading?ve.createElement("div",{className:xr(Z==null?void 0:Z.loader,(qe=y==null?void 0:y.classNames)==null?void 0:qe.loader,"sonner-loader"),"data-visible":ne==="loading"},A.loading):F?ve.createElement("div",{className:xr(Z==null?void 0:Z.loader,(ht=y==null?void 0:y.classNames)==null?void 0:ht.loader,"sonner-loader"),"data-visible":ne==="loading"},F):ve.createElement(bE,{className:xr(Z==null?void 0:Z.loader,(wt=y==null?void 0:y.classNames)==null?void 0:wt.loader),visible:ne==="loading"})}return ve.createElement("li",{tabIndex:0,ref:mt,className:xr(K,he,Z==null?void 0:Z.toast,(r=y==null?void 0:y.classNames)==null?void 0:r.toast,Z==null?void 0:Z.default,Z==null?void 0:Z[ne],(a=y==null?void 0:y.classNames)==null?void 0:a[ne]),"data-sonner-toast":"","data-rich-colors":(l=y.richColors)!=null?l:N,"data-styled":!(y.jsx||y.unstyled||k),"data-mounted":re,"data-promise":!!y.promise,"data-swiped":Mt,"data-removed":fe,"data-visible":Pe,"data-y-position":kr,"data-x-position":Hn,"data-index":D,"data-front":Q,"data-swiping":Ee,"data-dismissible":z,"data-type":ne,"data-invert":ei,"data-swipe-out":Ie,"data-swipe-direction":Y,"data-expanded":!!(O||ae&&re),style:{"--index":D,"--toasts-before":D,"--z-index":I.length-D,"--offset":`${fe?Et:Tt.current}px`,"--initial-height":ae?"auto":`${Rt}px`,...X,...y.style},onDragEnd:()=>{Se(!1),se(null),st.current=null},onPointerDown:qe=>{Sa||!z||(be.current=new Date,Bt(Tt.current),qe.target.setPointerCapture(qe.pointerId),qe.target.tagName!=="BUTTON"&&(Se(!0),st.current={x:qe.clientX,y:qe.clientY}))},onPointerUp:()=>{var qe,ht,wt,jn;if(Ie||!z)return;st.current=null;let un=Number(((qe=mt.current)==null?void 0:qe.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Cr=Number(((ht=mt.current)==null?void 0:ht.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Nr=new Date().getTime()-((wt=be.current)==null?void 0:wt.getTime()),An=M==="x"?un:Cr,hr=Math.abs(An)/Nr;if(Math.abs(An)>=IE||hr>.11){Bt(Tt.current),(jn=y.onDismiss)==null||jn.call(y,y),ce(M==="x"?un>0?"right":"left":Cr>0?"down":"up"),yn(),Be(!0),Nt(!1);return}Se(!1),se(null)},onPointerMove:qe=>{var ht,wt,jn,un;if(!st.current||!z||((ht=window.getSelection())==null?void 0:ht.toString().length)>0)return;let Cr=qe.clientY-st.current.y,Nr=qe.clientX-st.current.x,An=(wt=e.swipeDirections)!=null?wt:HE(W);!M&&(Math.abs(Nr)>1||Math.abs(Cr)>1)&&se(Math.abs(Nr)>Math.abs(Cr)?"x":"y");let hr={x:0,y:0};M==="y"?(An.includes("top")||An.includes("bottom"))&&(An.includes("top")&&Cr<0||An.includes("bottom")&&Cr>0)&&(hr.y=Cr):M==="x"&&(An.includes("left")||An.includes("right"))&&(An.includes("left")&&Nr<0||An.includes("right")&&Nr>0)&&(hr.x=Nr),(Math.abs(hr.x)>0||Math.abs(hr.y)>0)&&Nt(!0),(jn=mt.current)==null||jn.style.setProperty("--swipe-amount-x",`${hr.x}px`),(un=mt.current)==null||un.style.setProperty("--swipe-amount-y",`${hr.y}px`)}},an&&!y.jsx?ve.createElement("button",{"aria-label":U,"data-disabled":Sa,"data-close-button":!0,onClick:Sa||!z?()=>{}:()=>{var qe;yn(),(qe=y.onDismiss)==null||qe.call(y,y)},className:xr(Z==null?void 0:Z.closeButton,(o=y==null?void 0:y.classNames)==null?void 0:o.closeButton)},(c=A==null?void 0:A.close)!=null?c:CE):null,y.jsx||S.isValidElement(y.title)?y.jsx?y.jsx:typeof y.title=="function"?y.title():y.title:ve.createElement(ve.Fragment,null,ne||y.icon||y.promise?ve.createElement("div",{"data-icon":"",className:xr(Z==null?void 0:Z.icon,(d=y==null?void 0:y.classNames)==null?void 0:d.icon)},y.promise||y.type==="loading"&&!y.icon?y.icon||ti():null,y.type!=="loading"?y.icon||(A==null?void 0:A[ne])||vE(ne):null):null,ve.createElement("div",{"data-content":"",className:xr(Z==null?void 0:Z.content,(f=y==null?void 0:y.classNames)==null?void 0:f.content)},ve.createElement("div",{"data-title":"",className:xr(Z==null?void 0:Z.title,(h=y==null?void 0:y.classNames)==null?void 0:h.title)},typeof y.title=="function"?y.title():y.title),y.description?ve.createElement("div",{"data-description":"",className:xr(ue,ke,Z==null?void 0:Z.description,(m=y==null?void 0:y.classNames)==null?void 0:m.description)},typeof y.description=="function"?y.description():y.description):null),S.isValidElement(y.cancel)?y.cancel:y.cancel&&Pu(y.cancel)?ve.createElement("button",{"data-button":!0,"data-cancel":!0,style:y.cancelButtonStyle||H,onClick:qe=>{var ht,wt;Pu(y.cancel)&&z&&((wt=(ht=y.cancel).onClick)==null||wt.call(ht,qe),yn())},className:xr(Z==null?void 0:Z.cancelButton,(v=y==null?void 0:y.classNames)==null?void 0:v.cancelButton)},y.cancel.label):null,S.isValidElement(y.action)?y.action:y.action&&Pu(y.action)?ve.createElement("button",{"data-button":!0,"data-action":!0,style:y.actionButtonStyle||P,onClick:qe=>{var ht,wt;Pu(y.action)&&((wt=(ht=y.action).onClick)==null||wt.call(ht,qe),!qe.defaultPrevented&&yn())},className:xr(Z==null?void 0:Z.actionButton,(x=y==null?void 0:y.classNames)==null?void 0:x.actionButton)},y.action.label):null))};function ab(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function $E(e,r){let a={};return[e,r].forEach((l,o)=>{let c=o===1,d=c?"--mobile-offset":"--offset",f=c?LE:zE;function h(m){["top","right","bottom","left"].forEach(v=>{a[`${d}-${v}`]=typeof m=="number"?`${m}px`:m})}typeof l=="number"||typeof l=="string"?h(l):typeof l=="object"?["top","right","bottom","left"].forEach(m=>{l[m]===void 0?a[`${d}-${m}`]=f:a[`${d}-${m}`]=typeof l[m]=="number"?`${l[m]}px`:l[m]}):h(f)}),a}var FE=S.forwardRef(function(e,r){let{invert:a,position:l="bottom-right",hotkey:o=["altKey","KeyT"],expand:c,closeButton:d,className:f,offset:h,mobileOffset:m,theme:v="light",richColors:x,duration:b,style:y,visibleToasts:k=OE,toastOptions:j,dir:T=ab(),gap:C=BE,loadingIcon:R,icons:D,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:O}=e,[E,N]=ve.useState([]),L=ve.useMemo(()=>Array.from(new Set([l].concat(E.filter(V=>V.position).map(V=>V.position)))),[E,l]),[X,H]=ve.useState([]),[P,K]=ve.useState(!1),[ue,le]=ve.useState(!1),[W,B]=ve.useState(v!=="system"?v:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=ve.useRef(null),ae=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),Z=ve.useRef(null),A=ve.useRef(!1),U=ve.useCallback(V=>{N(M=>{var se;return(se=M.find(Y=>Y.id===V.id))!=null&&se.delete||Bn.dismiss(V.id),M.filter(({id:Y})=>Y!==V.id)})},[]);return ve.useEffect(()=>Bn.subscribe(V=>{if(V.dismiss){N(M=>M.map(se=>se.id===V.id?{...se,delete:!0}:se));return}setTimeout(()=>{l1.flushSync(()=>{N(M=>{let se=M.findIndex(Y=>Y.id===V.id);return se!==-1?[...M.slice(0,se),{...M[se],...V},...M.slice(se+1)]:[V,...M]})})})}),[]),ve.useEffect(()=>{if(v!=="system"){B(v);return}if(v==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?B("dark"):B("light")),typeof window>"u")return;let V=window.matchMedia("(prefers-color-scheme: dark)");try{V.addEventListener("change",({matches:M})=>{B(M?"dark":"light")})}catch{V.addListener(({matches:se})=>{try{B(se?"dark":"light")}catch(Y){console.error(Y)}})}},[v]),ve.useEffect(()=>{E.length<=1&&K(!1)},[E]),ve.useEffect(()=>{let V=M=>{var se,Y;o.every(ce=>M[ce]||M.code===ce)&&(K(!0),(se=F.current)==null||se.focus()),M.code==="Escape"&&(document.activeElement===F.current||(Y=F.current)!=null&&Y.contains(document.activeElement))&&K(!1)};return document.addEventListener("keydown",V),()=>document.removeEventListener("keydown",V)},[o]),ve.useEffect(()=>{if(F.current)return()=>{Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null,A.current=!1)}},[F.current]),ve.createElement("section",{ref:r,"aria-label":`${I} ${ae}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},L.map((V,M)=>{var se;let[Y,ce]=V.split("-");return E.length?ve.createElement("ol",{key:V,dir:T==="auto"?ab():T,tabIndex:-1,ref:F,className:f,"data-sonner-toaster":!0,"data-theme":W,"data-y-position":Y,"data-lifted":P&&E.length>1&&!c,"data-x-position":ce,style:{"--front-toast-height":`${((se=X[0])==null?void 0:se.height)||0}px`,"--width":`${UE}px`,"--gap":`${C}px`,...y,...$E(h,m)},onBlur:re=>{A.current&&!re.currentTarget.contains(re.relatedTarget)&&(A.current=!1,Z.current&&(Z.current.focus({preventScroll:!0}),Z.current=null))},onFocus:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||A.current||(A.current=!0,Z.current=re.relatedTarget)},onMouseEnter:()=>K(!0),onMouseMove:()=>K(!0),onMouseLeave:()=>{ue||K(!1)},onDragEnd:()=>K(!1),onPointerDown:re=>{re.target instanceof HTMLElement&&re.target.dataset.dismissible==="false"||le(!0)},onPointerUp:()=>le(!1)},E.filter(re=>!re.position&&M===0||re.position===V).map((re,ye)=>{var fe,we;return ve.createElement(PE,{key:re.id,icons:D,index:ye,toast:re,defaultRichColors:x,duration:(fe=j==null?void 0:j.duration)!=null?fe:b,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:a,visibleToasts:k,closeButton:(we=j==null?void 0:j.closeButton)!=null?we:d,interacting:ue,position:V,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:U,toasts:E.filter(Ee=>Ee.position==re.position),heights:X.filter(Ee=>Ee.position==re.position),setHeights:H,expandByDefault:c,gap:C,loadingIcon:R,expanded:P,pauseWhenPageIsHidden:O,swipeDirections:e.swipeDirections})})):null}))});function Ut(e,r=[]){const[a,l]=S.useState(null),[o,c]=S.useState(null),[d,f]=S.useState(!0),h=S.useRef(e);h.current=e;const m=S.useCallback(()=>{f(!0),h.current().then(v=>{l(v),c(null)}).catch(v=>{c(v instanceof wc?v.message:String(v))}).finally(()=>f(!1))},r);return S.useEffect(()=>{m()},[m]),{data:a,error:o,loading:d,reload:m}}function gn({className:e,...r}){return s.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:s.jsx("table",{"data-slot":"table",className:Ne("w-full caption-bottom text-sm",e),...r})})}function xn({className:e,...r}){return s.jsx("thead",{"data-slot":"table-header",className:Ne("[&_tr]:border-b",e),...r})}function vn({className:e,...r}){return s.jsx("tbody",{"data-slot":"table-body",className:Ne("[&_tr:last-child]:border-0",e),...r})}function Oe({className:e,...r}){return s.jsx("tr",{"data-slot":"table-row",className:Ne("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",e),...r})}function ge({className:e,...r}){return s.jsx("th",{"data-slot":"table-head",className:Ne("text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function de({className:e,...r}){return s.jsx("td",{"data-slot":"table-cell",className:Ne("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",e),...r})}function VE(e,r){const a=S.createContext(r),l=c=>{const{children:d,...f}=c,h=S.useMemo(()=>f,Object.values(f));return s.jsx(a.Provider,{value:h,children:d})};l.displayName=e+"Provider";function o(c){const d=S.useContext(a);if(d)return d;if(r!==void 0)return r;throw new Error(`\`${c}\` must be used within \`${e}\``)}return[l,o]}function Sr(e,r=[]){let a=[];function l(c,d){const f=S.createContext(d),h=a.length;a=[...a,d];const m=x=>{var C;const{scope:b,children:y,...k}=x,j=((C=b==null?void 0:b[e])==null?void 0:C[h])||f,T=S.useMemo(()=>k,Object.values(k));return s.jsx(j.Provider,{value:T,children:y})};m.displayName=c+"Provider";function v(x,b){var j;const y=((j=b==null?void 0:b[e])==null?void 0:j[h])||f,k=S.useContext(y);if(k)return k;if(d!==void 0)return d;throw new Error(`\`${x}\` must be used within \`${c}\``)}return[m,v]}const o=()=>{const c=a.map(d=>S.createContext(d));return function(f){const h=(f==null?void 0:f[e])||c;return S.useMemo(()=>({[`__scope${e}`]:{...f,[e]:h}}),[f,h])}};return o.scopeName=e,[l,GE(o,...r)]}function GE(...e){const r=e[0];if(e.length===1)return r;const a=()=>{const l=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const d=l.reduce((f,{useScope:h,scopeName:m})=>{const x=h(c)[`__scope${m}`];return{...f,...x}},{});return S.useMemo(()=>({[`__scope${r.scopeName}`]:d}),[d])}};return a.scopeName=r.scopeName,a}function Ae(e,r,{checkForDefaultPrevented:a=!0}={}){return function(o){if(e==null||e(o),a===!1||!o.defaultPrevented)return r==null?void 0:r(o)}}var Nn=globalThis!=null&&globalThis.document?S.useLayoutEffect:()=>{},YE=H2.useId||(()=>{}),XE=0;function Br(e){const[r,a]=S.useState(YE());return Nn(()=>{a(l=>l??String(XE++))},[e]),e||(r?`radix-${r}`:"")}function fr(e){const r=S.useRef(e);return S.useEffect(()=>{r.current=e}),S.useMemo(()=>(...a)=>{var l;return(l=r.current)==null?void 0:l.call(r,...a)},[])}function nl({prop:e,defaultProp:r,onChange:a=()=>{}}){const[l,o]=KE({defaultProp:r,onChange:a}),c=e!==void 0,d=c?e:l,f=fr(a),h=S.useCallback(m=>{if(c){const x=typeof m=="function"?m(e):m;x!==e&&f(x)}else o(m)},[c,e,o,f]);return[d,h]}function KE({defaultProp:e,onChange:r}){const a=S.useState(e),[l]=a,o=S.useRef(l),c=fr(r);return S.useEffect(()=>{o.current!==l&&(c(l),o.current=l)},[l,o,c]),a}function QE(e,r=globalThis==null?void 0:globalThis.document){const a=fr(e);S.useEffect(()=>{const l=o=>{o.key==="Escape"&&a(o)};return r.addEventListener("keydown",l,{capture:!0}),()=>r.removeEventListener("keydown",l,{capture:!0})},[a,r])}var ZE="DismissableLayer",cm="dismissableLayer.update",JE="dismissableLayer.pointerDownOutside",WE="dismissableLayer.focusOutside",lb,h1=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kc=S.forwardRef((e,r)=>{const{disableOutsidePointerEvents:a=!1,onEscapeKeyDown:l,onPointerDownOutside:o,onFocusOutside:c,onInteractOutside:d,onDismiss:f,...h}=e,m=S.useContext(h1),[v,x]=S.useState(null),b=(v==null?void 0:v.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=S.useState({}),k=ft(r,N=>x(N)),j=Array.from(m.layers),[T]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),C=j.indexOf(T),R=v?j.indexOf(v):-1,D=m.layersWithOutsidePointerEventsDisabled.size>0,I=R>=C,O=nT(N=>{const L=N.target,X=[...m.branches].some(H=>H.contains(L));!I||X||(o==null||o(N),d==null||d(N),N.defaultPrevented||f==null||f())},b),E=rT(N=>{const L=N.target;[...m.branches].some(H=>H.contains(L))||(c==null||c(N),d==null||d(N),N.defaultPrevented||f==null||f())},b);return QE(N=>{R===m.layers.size-1&&(l==null||l(N),!N.defaultPrevented&&f&&(N.preventDefault(),f()))},b),S.useEffect(()=>{if(v)return a&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(lb=b.body.style.pointerEvents,b.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(v)),m.layers.add(v),ib(),()=>{a&&m.layersWithOutsidePointerEventsDisabled.size===1&&(b.body.style.pointerEvents=lb)}},[v,b,a,m]),S.useEffect(()=>()=>{v&&(m.layers.delete(v),m.layersWithOutsidePointerEventsDisabled.delete(v),ib())},[v,m]),S.useEffect(()=>{const N=()=>y({});return document.addEventListener(cm,N),()=>document.removeEventListener(cm,N)},[]),s.jsx(Ge.div,{...h,ref:k,style:{pointerEvents:D?I?"auto":"none":void 0,...e.style},onFocusCapture:Ae(e.onFocusCapture,E.onFocusCapture),onBlurCapture:Ae(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:Ae(e.onPointerDownCapture,O.onPointerDownCapture)})});kc.displayName=ZE;var eT="DismissableLayerBranch",tT=S.forwardRef((e,r)=>{const a=S.useContext(h1),l=S.useRef(null),o=ft(r,l);return S.useEffect(()=>{const c=l.current;if(c)return a.branches.add(c),()=>{a.branches.delete(c)}},[a.branches]),s.jsx(Ge.div,{...e,ref:o})});tT.displayName=eT;function nT(e,r=globalThis==null?void 0:globalThis.document){const a=fr(e),l=S.useRef(!1),o=S.useRef(()=>{});return S.useEffect(()=>{const c=f=>{if(f.target&&!l.current){let h=function(){m1(JE,a,m,{discrete:!0})};const m={originalEvent:f};f.pointerType==="touch"?(r.removeEventListener("click",o.current),o.current=h,r.addEventListener("click",o.current,{once:!0})):h()}else r.removeEventListener("click",o.current);l.current=!1},d=window.setTimeout(()=>{r.addEventListener("pointerdown",c)},0);return()=>{window.clearTimeout(d),r.removeEventListener("pointerdown",c),r.removeEventListener("click",o.current)}},[r,a]),{onPointerDownCapture:()=>l.current=!0}}function rT(e,r=globalThis==null?void 0:globalThis.document){const a=fr(e),l=S.useRef(!1);return S.useEffect(()=>{const o=c=>{c.target&&!l.current&&m1(WE,a,{originalEvent:c},{discrete:!1})};return r.addEventListener("focusin",o),()=>r.removeEventListener("focusin",o)},[r,a]),{onFocusCapture:()=>l.current=!0,onBlurCapture:()=>l.current=!1}}function ib(){const e=new CustomEvent(cm);document.dispatchEvent(e)}function m1(e,r,a,{discrete:l}){const o=a.originalEvent.target,c=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:a});r&&o.addEventListener(e,r,{once:!0}),l?i1(o,c):o.dispatchEvent(c)}var xh="focusScope.autoFocusOnMount",vh="focusScope.autoFocusOnUnmount",sb={bubbles:!1,cancelable:!0},aT="FocusScope",Cc=S.forwardRef((e,r)=>{const{loop:a=!1,trapped:l=!1,onMountAutoFocus:o,onUnmountAutoFocus:c,...d}=e,[f,h]=S.useState(null),m=fr(o),v=fr(c),x=S.useRef(null),b=ft(r,j=>h(j)),y=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(l){let j=function(D){if(y.paused||!f)return;const I=D.target;f.contains(I)?x.current=I:Qa(x.current,{select:!0})},T=function(D){if(y.paused||!f)return;const I=D.relatedTarget;I!==null&&(f.contains(I)||Qa(x.current,{select:!0}))},C=function(D){if(document.activeElement===document.body)for(const O of D)O.removedNodes.length>0&&Qa(f)};document.addEventListener("focusin",j),document.addEventListener("focusout",T);const R=new MutationObserver(C);return f&&R.observe(f,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",T),R.disconnect()}}},[l,f,y.paused]),S.useEffect(()=>{if(f){ub.add(y);const j=document.activeElement;if(!f.contains(j)){const C=new CustomEvent(xh,sb);f.addEventListener(xh,m),f.dispatchEvent(C),C.defaultPrevented||(lT(cT(p1(f)),{select:!0}),document.activeElement===j&&Qa(f))}return()=>{f.removeEventListener(xh,m),setTimeout(()=>{const C=new CustomEvent(vh,sb);f.addEventListener(vh,v),f.dispatchEvent(C),C.defaultPrevented||Qa(j??document.body,{select:!0}),f.removeEventListener(vh,v),ub.remove(y)},0)}}},[f,m,v,y]);const k=S.useCallback(j=>{if(!a&&!l||y.paused)return;const T=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,C=document.activeElement;if(T&&C){const R=j.currentTarget,[D,I]=iT(R);D&&I?!j.shiftKey&&C===I?(j.preventDefault(),a&&Qa(D,{select:!0})):j.shiftKey&&C===D&&(j.preventDefault(),a&&Qa(I,{select:!0})):C===R&&j.preventDefault()}},[a,l,y.paused]);return s.jsx(Ge.div,{tabIndex:-1,...d,ref:b,onKeyDown:k})});Cc.displayName=aT;function lT(e,{select:r=!1}={}){const a=document.activeElement;for(const l of e)if(Qa(l,{select:r}),document.activeElement!==a)return}function iT(e){const r=p1(e),a=ob(r,e),l=ob(r.reverse(),e);return[a,l]}function p1(e){const r=[],a=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:l=>{const o=l.tagName==="INPUT"&&l.type==="hidden";return l.disabled||l.hidden||o?NodeFilter.FILTER_SKIP:l.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;a.nextNode();)r.push(a.currentNode);return r}function ob(e,r){for(const a of e)if(!sT(a,{upTo:r}))return a}function sT(e,{upTo:r}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(r!==void 0&&e===r)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function oT(e){return e instanceof HTMLInputElement&&"select"in e}function Qa(e,{select:r=!1}={}){if(e&&e.focus){const a=document.activeElement;e.focus({preventScroll:!0}),e!==a&&oT(e)&&r&&e.select()}}var ub=uT();function uT(){let e=[];return{add(r){const a=e[0];r!==a&&(a==null||a.pause()),e=cb(e,r),e.unshift(r)},remove(r){var a;e=cb(e,r),(a=e[0])==null||a.resume()}}}function cb(e,r){const a=[...e],l=a.indexOf(r);return l!==-1&&a.splice(l,1),a}function cT(e){return e.filter(r=>r.tagName!=="A")}var dT="Portal",Nc=S.forwardRef((e,r)=>{var f;const{container:a,...l}=e,[o,c]=S.useState(!1);Nn(()=>c(!0),[]);const d=a||o&&((f=globalThis==null?void 0:globalThis.document)==null?void 0:f.body);return d?l1.createPortal(s.jsx(Ge.div,{...l,ref:r}),d):null});Nc.displayName=dT;function fT(e,r){return S.useReducer((a,l)=>r[a][l]??a,e)}var Vr=e=>{const{present:r,children:a}=e,l=hT(r),o=typeof a=="function"?a({present:l.isPresent}):S.Children.only(a),c=ft(l.ref,mT(o));return typeof a=="function"||l.isPresent?S.cloneElement(o,{ref:c}):null};Vr.displayName="Presence";function hT(e){const[r,a]=S.useState(),l=S.useRef({}),o=S.useRef(e),c=S.useRef("none"),d=e?"mounted":"unmounted",[f,h]=fT(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return S.useEffect(()=>{const m=$u(l.current);c.current=f==="mounted"?m:"none"},[f]),Nn(()=>{const m=l.current,v=o.current;if(v!==e){const b=c.current,y=$u(m);e?h("MOUNT"):y==="none"||(m==null?void 0:m.display)==="none"?h("UNMOUNT"):h(v&&b!==y?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,h]),Nn(()=>{if(r){let m;const v=r.ownerDocument.defaultView??window,x=y=>{const j=$u(l.current).includes(y.animationName);if(y.target===r&&j&&(h("ANIMATION_END"),!o.current)){const T=r.style.animationFillMode;r.style.animationFillMode="forwards",m=v.setTimeout(()=>{r.style.animationFillMode==="forwards"&&(r.style.animationFillMode=T)})}},b=y=>{y.target===r&&(c.current=$u(l.current))};return r.addEventListener("animationstart",b),r.addEventListener("animationcancel",x),r.addEventListener("animationend",x),()=>{v.clearTimeout(m),r.removeEventListener("animationstart",b),r.removeEventListener("animationcancel",x),r.removeEventListener("animationend",x)}}else h("ANIMATION_END")},[r,h]),{isPresent:["mounted","unmountSuspended"].includes(f),ref:S.useCallback(m=>{m&&(l.current=getComputedStyle(m)),a(m)},[])}}function $u(e){return(e==null?void 0:e.animationName)||"none"}function mT(e){var l,o;let r=(l=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:l.get,a=r&&"isReactWarning"in r&&r.isReactWarning;return a?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,a=r&&"isReactWarning"in r&&r.isReactWarning,a?e.props.ref:e.props.ref||e.ref)}var yh=0;function Vm(){S.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??db()),document.body.insertAdjacentElement("beforeend",e[1]??db()),yh++,()=>{yh===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),yh--}},[])}function db(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Lr=function(){return Lr=Object.assign||function(r){for(var a,l=1,o=arguments.length;l"u")return MT;var r=RT(e),a=document.documentElement.clientWidth,l=window.innerWidth;return{left:r[0],top:r[1],right:r[2],gap:Math.max(0,l-a+r[2]-r[0])}},OT=y1(),Yi="data-scroll-locked",zT=function(e,r,a,l){var o=e.left,c=e.top,d=e.right,f=e.gap;return a===void 0&&(a="margin"),` - .`.concat(gT,` { - overflow: hidden `).concat(l,`; - padding-right: `).concat(f,"px ").concat(l,`; - } - body[`).concat(Yi,`] { - overflow: hidden `).concat(l,`; - overscroll-behavior: contain; - `).concat([r&&"position: relative ".concat(l,";"),a==="margin"&&` - padding-left: `.concat(o,`px; - padding-top: `).concat(c,`px; - padding-right: `).concat(d,`px; - margin-left:0; - margin-top:0; - margin-right: `).concat(f,"px ").concat(l,`; - `),a==="padding"&&"padding-right: ".concat(f,"px ").concat(l,";")].filter(Boolean).join(""),` - } - - .`).concat(rc,` { - right: `).concat(f,"px ").concat(l,`; - } - - .`).concat(ac,` { - margin-right: `).concat(f,"px ").concat(l,`; - } - - .`).concat(rc," .").concat(rc,` { - right: 0 `).concat(l,`; - } - - .`).concat(ac," .").concat(ac,` { - margin-right: 0 `).concat(l,`; - } - - body[`).concat(Yi,`] { - `).concat(xT,": ").concat(f,`px; - } -`)},hb=function(){var e=parseInt(document.body.getAttribute(Yi)||"0",10);return isFinite(e)?e:0},LT=function(){S.useEffect(function(){return document.body.setAttribute(Yi,(hb()+1).toString()),function(){var e=hb()-1;e<=0?document.body.removeAttribute(Yi):document.body.setAttribute(Yi,e.toString())}},[])},UT=function(e){var r=e.noRelative,a=e.noImportant,l=e.gapMode,o=l===void 0?"margin":l;LT();var c=S.useMemo(function(){return DT(o)},[o]);return S.createElement(OT,{styles:zT(c,!r,o,a?"":"!important")})},dm=!1;if(typeof window<"u")try{var Fu=Object.defineProperty({},"passive",{get:function(){return dm=!0,!0}});window.addEventListener("test",Fu,Fu),window.removeEventListener("test",Fu,Fu)}catch{dm=!1}var qi=dm?{passive:!1}:!1,BT=function(e){return e.tagName==="TEXTAREA"},b1=function(e,r){if(!(e instanceof Element))return!1;var a=window.getComputedStyle(e);return a[r]!=="hidden"&&!(a.overflowY===a.overflowX&&!BT(e)&&a[r]==="visible")},IT=function(e){return b1(e,"overflowY")},qT=function(e){return b1(e,"overflowX")},mb=function(e,r){var a=r.ownerDocument,l=r;do{typeof ShadowRoot<"u"&&l instanceof ShadowRoot&&(l=l.host);var o=w1(e,l);if(o){var c=S1(e,l),d=c[1],f=c[2];if(d>f)return!0}l=l.parentNode}while(l&&l!==a.body);return!1},HT=function(e){var r=e.scrollTop,a=e.scrollHeight,l=e.clientHeight;return[r,a,l]},PT=function(e){var r=e.scrollLeft,a=e.scrollWidth,l=e.clientWidth;return[r,a,l]},w1=function(e,r){return e==="v"?IT(r):qT(r)},S1=function(e,r){return e==="v"?HT(r):PT(r)},$T=function(e,r){return e==="h"&&r==="rtl"?-1:1},FT=function(e,r,a,l,o){var c=$T(e,window.getComputedStyle(r).direction),d=c*l,f=a.target,h=r.contains(f),m=!1,v=d>0,x=0,b=0;do{if(!f)break;var y=S1(e,f),k=y[0],j=y[1],T=y[2],C=j-T-c*k;(k||C)&&w1(e,f)&&(x+=C,b+=k);var R=f.parentNode;f=R&&R.nodeType===Node.DOCUMENT_FRAGMENT_NODE?R.host:R}while(!h&&f!==document.body||h&&(r.contains(f)||r===f));return(v&&Math.abs(x)<1||!v&&Math.abs(b)<1)&&(m=!0),m},Vu=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},pb=function(e){return[e.deltaX,e.deltaY]},gb=function(e){return e&&"current"in e?e.current:e},VT=function(e,r){return e[0]===r[0]&&e[1]===r[1]},GT=function(e){return` - .block-interactivity-`.concat(e,` {pointer-events: none;} - .allow-interactivity-`).concat(e,` {pointer-events: all;} -`)},YT=0,Hi=[];function XT(e){var r=S.useRef([]),a=S.useRef([0,0]),l=S.useRef(),o=S.useState(YT++)[0],c=S.useState(y1)[0],d=S.useRef(e);S.useEffect(function(){d.current=e},[e]),S.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(o));var j=pT([e.lockRef.current],(e.shards||[]).map(gb),!0).filter(Boolean);return j.forEach(function(T){return T.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),j.forEach(function(T){return T.classList.remove("allow-interactivity-".concat(o))})}}},[e.inert,e.lockRef.current,e.shards]);var f=S.useCallback(function(j,T){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!d.current.allowPinchZoom;var C=Vu(j),R=a.current,D="deltaX"in j?j.deltaX:R[0]-C[0],I="deltaY"in j?j.deltaY:R[1]-C[1],O,E=j.target,N=Math.abs(D)>Math.abs(I)?"h":"v";if("touches"in j&&N==="h"&&E.type==="range")return!1;var L=window.getSelection(),X=L&&L.anchorNode,H=X?X===E||X.contains(E):!1;if(H)return!1;var P=mb(N,E);if(!P)return!0;if(P?O=N:(O=N==="v"?"h":"v",P=mb(N,E)),!P)return!1;if(!l.current&&"changedTouches"in j&&(D||I)&&(l.current=O),!O)return!0;var K=l.current||O;return FT(K,T,j,K==="h"?D:I)},[]),h=S.useCallback(function(j){var T=j;if(!(!Hi.length||Hi[Hi.length-1]!==c)){var C="deltaY"in T?pb(T):Vu(T),R=r.current.filter(function(O){return O.name===T.type&&(O.target===T.target||T.target===O.shadowParent)&&VT(O.delta,C)})[0];if(R&&R.should){T.cancelable&&T.preventDefault();return}if(!R){var D=(d.current.shards||[]).map(gb).filter(Boolean).filter(function(O){return O.contains(T.target)}),I=D.length>0?f(T,D[0]):!d.current.noIsolation;I&&T.cancelable&&T.preventDefault()}}},[]),m=S.useCallback(function(j,T,C,R){var D={name:j,delta:T,target:C,should:R,shadowParent:KT(C)};r.current.push(D),setTimeout(function(){r.current=r.current.filter(function(I){return I!==D})},1)},[]),v=S.useCallback(function(j){a.current=Vu(j),l.current=void 0},[]),x=S.useCallback(function(j){m(j.type,pb(j),j.target,f(j,e.lockRef.current))},[]),b=S.useCallback(function(j){m(j.type,Vu(j),j.target,f(j,e.lockRef.current))},[]);S.useEffect(function(){return Hi.push(c),e.setCallbacks({onScrollCapture:x,onWheelCapture:x,onTouchMoveCapture:b}),document.addEventListener("wheel",h,qi),document.addEventListener("touchmove",h,qi),document.addEventListener("touchstart",v,qi),function(){Hi=Hi.filter(function(j){return j!==c}),document.removeEventListener("wheel",h,qi),document.removeEventListener("touchmove",h,qi),document.removeEventListener("touchstart",v,qi)}},[]);var y=e.removeScrollBar,k=e.inert;return S.createElement(S.Fragment,null,k?S.createElement(c,{styles:GT(o)}):null,y?S.createElement(UT,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function KT(e){for(var r=null;e!==null;)e instanceof ShadowRoot&&(r=e.host,e=e.host),e=e.parentNode;return r}const QT=kT(v1,XT);var Tc=S.forwardRef(function(e,r){return S.createElement(Ec,Lr({},e,{ref:r,sideCar:QT}))});Tc.classNames=Ec.classNames;var ZT=function(e){if(typeof document>"u")return null;var r=Array.isArray(e)?e[0]:e;return r.ownerDocument.body},Pi=new WeakMap,Gu=new WeakMap,Yu={},jh=0,j1=function(e){return e&&(e.host||j1(e.parentNode))},JT=function(e,r){return r.map(function(a){if(e.contains(a))return a;var l=j1(a);return l&&e.contains(l)?l:(console.error("aria-hidden",a,"in not contained inside",e,". Doing nothing"),null)}).filter(function(a){return!!a})},WT=function(e,r,a,l){var o=JT(r,Array.isArray(e)?e:[e]);Yu[a]||(Yu[a]=new WeakMap);var c=Yu[a],d=[],f=new Set,h=new Set(o),m=function(x){!x||f.has(x)||(f.add(x),m(x.parentNode))};o.forEach(m);var v=function(x){!x||h.has(x)||Array.prototype.forEach.call(x.children,function(b){if(f.has(b))v(b);else try{var y=b.getAttribute(l),k=y!==null&&y!=="false",j=(Pi.get(b)||0)+1,T=(c.get(b)||0)+1;Pi.set(b,j),c.set(b,T),d.push(b),j===1&&k&&Gu.set(b,!0),T===1&&b.setAttribute(a,"true"),k||b.setAttribute(l,"true")}catch(C){console.error("aria-hidden: cannot operate on ",b,C)}})};return v(r),f.clear(),jh++,function(){d.forEach(function(x){var b=Pi.get(x)-1,y=c.get(x)-1;Pi.set(x,b),c.set(x,y),b||(Gu.has(x)||x.removeAttribute(l),Gu.delete(x)),y||x.removeAttribute(a)}),jh--,jh||(Pi=new WeakMap,Pi=new WeakMap,Gu=new WeakMap,Yu={})}},Gm=function(e,r,a){a===void 0&&(a="data-aria-hidden");var l=Array.from(Array.isArray(e)?e:[e]),o=ZT(e);return o?(l.push.apply(l,Array.from(o.querySelectorAll("[aria-live], script"))),WT(l,o,a,"aria-hidden")):function(){return null}},Ym="Dialog",[k1,C1]=Sr(Ym),[eA,jr]=k1(Ym),N1=e=>{const{__scopeDialog:r,children:a,open:l,defaultOpen:o,onOpenChange:c,modal:d=!0}=e,f=S.useRef(null),h=S.useRef(null),[m=!1,v]=nl({prop:l,defaultProp:o,onChange:c});return s.jsx(eA,{scope:r,triggerRef:f,contentRef:h,contentId:Br(),titleId:Br(),descriptionId:Br(),open:m,onOpenChange:v,onOpenToggle:S.useCallback(()=>v(x=>!x),[v]),modal:d,children:a})};N1.displayName=Ym;var E1="DialogTrigger",T1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=jr(E1,a),c=ft(r,o.triggerRef);return s.jsx(Ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Qm(o.open),...l,ref:c,onClick:Ae(e.onClick,o.onOpenToggle)})});T1.displayName=E1;var Xm="DialogPortal",[tA,A1]=k1(Xm,{forceMount:void 0}),_1=e=>{const{__scopeDialog:r,forceMount:a,children:l,container:o}=e,c=jr(Xm,r);return s.jsx(tA,{scope:r,forceMount:a,children:S.Children.map(l,d=>s.jsx(Vr,{present:a||c.open,children:s.jsx(Nc,{asChild:!0,container:o,children:d})}))})};_1.displayName=Xm;var oc="DialogOverlay",M1=S.forwardRef((e,r)=>{const a=A1(oc,e.__scopeDialog),{forceMount:l=a.forceMount,...o}=e,c=jr(oc,e.__scopeDialog);return c.modal?s.jsx(Vr,{present:l||c.open,children:s.jsx(nA,{...o,ref:r})}):null});M1.displayName=oc;var nA=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=jr(oc,a);return s.jsx(Tc,{as:xa,allowPinchZoom:!0,shards:[o.contentRef],children:s.jsx(Ge.div,{"data-state":Qm(o.open),...l,ref:r,style:{pointerEvents:"auto",...l.style}})})}),Fl="DialogContent",R1=S.forwardRef((e,r)=>{const a=A1(Fl,e.__scopeDialog),{forceMount:l=a.forceMount,...o}=e,c=jr(Fl,e.__scopeDialog);return s.jsx(Vr,{present:l||c.open,children:c.modal?s.jsx(rA,{...o,ref:r}):s.jsx(aA,{...o,ref:r})})});R1.displayName=Fl;var rA=S.forwardRef((e,r)=>{const a=jr(Fl,e.__scopeDialog),l=S.useRef(null),o=ft(r,a.contentRef,l);return S.useEffect(()=>{const c=l.current;if(c)return Gm(c)},[]),s.jsx(D1,{...e,ref:o,trapFocus:a.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(e.onCloseAutoFocus,c=>{var d;c.preventDefault(),(d=a.triggerRef.current)==null||d.focus()}),onPointerDownOutside:Ae(e.onPointerDownOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0;(d.button===2||f)&&c.preventDefault()}),onFocusOutside:Ae(e.onFocusOutside,c=>c.preventDefault())})}),aA=S.forwardRef((e,r)=>{const a=jr(Fl,e.__scopeDialog),l=S.useRef(!1),o=S.useRef(!1);return s.jsx(D1,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:c=>{var d,f;(d=e.onCloseAutoFocus)==null||d.call(e,c),c.defaultPrevented||(l.current||(f=a.triggerRef.current)==null||f.focus(),c.preventDefault()),l.current=!1,o.current=!1},onInteractOutside:c=>{var h,m;(h=e.onInteractOutside)==null||h.call(e,c),c.defaultPrevented||(l.current=!0,c.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const d=c.target;((m=a.triggerRef.current)==null?void 0:m.contains(d))&&c.preventDefault(),c.detail.originalEvent.type==="focusin"&&o.current&&c.preventDefault()}})}),D1=S.forwardRef((e,r)=>{const{__scopeDialog:a,trapFocus:l,onOpenAutoFocus:o,onCloseAutoFocus:c,...d}=e,f=jr(Fl,a),h=S.useRef(null),m=ft(r,h);return Vm(),s.jsxs(s.Fragment,{children:[s.jsx(Cc,{asChild:!0,loop:!0,trapped:l,onMountAutoFocus:o,onUnmountAutoFocus:c,children:s.jsx(kc,{role:"dialog",id:f.contentId,"aria-describedby":f.descriptionId,"aria-labelledby":f.titleId,"data-state":Qm(f.open),...d,ref:m,onDismiss:()=>f.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(iA,{titleId:f.titleId}),s.jsx(oA,{contentRef:h,descriptionId:f.descriptionId})]})]})}),Km="DialogTitle",O1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=jr(Km,a);return s.jsx(Ge.h2,{id:o.titleId,...l,ref:r})});O1.displayName=Km;var z1="DialogDescription",L1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=jr(z1,a);return s.jsx(Ge.p,{id:o.descriptionId,...l,ref:r})});L1.displayName=z1;var U1="DialogClose",B1=S.forwardRef((e,r)=>{const{__scopeDialog:a,...l}=e,o=jr(U1,a);return s.jsx(Ge.button,{type:"button",...l,ref:r,onClick:Ae(e.onClick,()=>o.onOpenChange(!1))})});B1.displayName=U1;function Qm(e){return e?"open":"closed"}var I1="DialogTitleWarning",[lA,q1]=VE(I1,{contentName:Fl,titleName:Km,docsSlug:"dialog"}),iA=({titleId:e})=>{const r=q1(I1),a=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users. - -If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component. - -For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return S.useEffect(()=>{e&&(document.getElementById(e)||console.error(a))},[a,e]),null},sA="DialogDescriptionWarning",oA=({contentRef:e,descriptionId:r})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${q1(sA).contentName}}.`;return S.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");r&&o&&(document.getElementById(r)||console.warn(l))},[l,e,r]),null},uA=N1,cA=T1,dA=_1,fA=M1,hA=R1,mA=O1,pA=L1,H1=B1,P1="AlertDialog",[gA]=Sr(P1,[C1]),ya=C1(),$1=e=>{const{__scopeAlertDialog:r,...a}=e,l=ya(r);return s.jsx(uA,{...l,...a,modal:!0})};$1.displayName=P1;var xA="AlertDialogTrigger",F1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(cA,{...o,...l,ref:r})});F1.displayName=xA;var vA="AlertDialogPortal",V1=e=>{const{__scopeAlertDialog:r,...a}=e,l=ya(r);return s.jsx(dA,{...l,...a})};V1.displayName=vA;var yA="AlertDialogOverlay",G1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(fA,{...o,...l,ref:r})});G1.displayName=yA;var Xi="AlertDialogContent",[bA,wA]=gA(Xi),Y1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,children:l,...o}=e,c=ya(a),d=S.useRef(null),f=ft(r,d),h=S.useRef(null);return s.jsx(lA,{contentName:Xi,titleName:X1,docsSlug:"alert-dialog",children:s.jsx(bA,{scope:a,cancelRef:h,children:s.jsxs(hA,{role:"alertdialog",...c,...o,ref:f,onOpenAutoFocus:Ae(o.onOpenAutoFocus,m=>{var v;m.preventDefault(),(v=h.current)==null||v.focus({preventScroll:!0})}),onPointerDownOutside:m=>m.preventDefault(),onInteractOutside:m=>m.preventDefault(),children:[s.jsx(r1,{children:l}),s.jsx(jA,{contentRef:d})]})})})});Y1.displayName=Xi;var X1="AlertDialogTitle",K1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(mA,{...o,...l,ref:r})});K1.displayName=X1;var Q1="AlertDialogDescription",Z1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(pA,{...o,...l,ref:r})});Z1.displayName=Q1;var SA="AlertDialogAction",J1=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,o=ya(a);return s.jsx(H1,{...o,...l,ref:r})});J1.displayName=SA;var W1="AlertDialogCancel",ew=S.forwardRef((e,r)=>{const{__scopeAlertDialog:a,...l}=e,{cancelRef:o}=wA(W1,a),c=ya(a),d=ft(r,o);return s.jsx(H1,{...c,...l,ref:d})});ew.displayName=W1;var jA=({contentRef:e})=>{const r=`\`${Xi}\` requires a description for the component to be accessible for screen reader users. - -You can add a description to the \`${Xi}\` by passing a \`${Q1}\` component as a child, which also benefits sighted users by adding visible context to the dialog. - -Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Xi}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component. - -For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return S.useEffect(()=>{var l;document.getElementById((l=e.current)==null?void 0:l.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null},kA=$1,CA=F1,NA=V1,EA=G1,TA=Y1,AA=J1,_A=ew,MA=K1,RA=Z1;function rl({...e}){return s.jsx(kA,{"data-slot":"alert-dialog",...e})}function al({...e}){return s.jsx(CA,{"data-slot":"alert-dialog-trigger",...e})}function DA({...e}){return s.jsx(NA,{"data-slot":"alert-dialog-portal",...e})}function OA({className:e,...r}){return s.jsx(EA,{"data-slot":"alert-dialog-overlay",className:Ne("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...r})}function ll({className:e,...r}){return s.jsxs(DA,{children:[s.jsx(OA,{}),s.jsx(TA,{"data-slot":"alert-dialog-content",className:Ne("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...r})]})}function il({className:e,...r}){return s.jsx("div",{"data-slot":"alert-dialog-header",className:Ne("flex flex-col gap-2 text-center sm:text-left",e),...r})}function sl({className:e,...r}){return s.jsx("div",{"data-slot":"alert-dialog-footer",className:Ne("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function ol({className:e,...r}){return s.jsx(MA,{"data-slot":"alert-dialog-title",className:Ne("text-lg font-semibold",e),...r})}function ul({className:e,...r}){return s.jsx(RA,{"data-slot":"alert-dialog-description",className:Ne("text-muted-foreground text-sm",e),...r})}function cl({className:e,...r}){return s.jsx(AA,{className:Ne(Hm(),e),...r})}function dl({className:e,...r}){return s.jsx(_A,{className:Ne(Hm({variant:"outline"}),e),...r})}function zA(){return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(LA,{}),s.jsx(UA,{})]})}function LA(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/my/keys")),[o,c]=S.useState(""),[d,f]=S.useState(!1),[h,m]=S.useState(null),v=async b=>{b.preventDefault(),f(!0);try{const y=await He.post("/my/keys",{label:o});m(y),c(""),l()}catch(y){Ve.error(String(y instanceof Error?y.message:y))}finally{f(!1)}},x=async b=>{try{await He.del(`/my/keys/${b}`),Ve.success("Key deleted"),l()}catch(y){Ve.error(String(y instanceof Error?y.message:y))}};return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Your API keys"}),s.jsx(it,{children:"Shown exactly once at creation; only a keyed hash is stored."})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsxs("form",{onSubmit:v,className:"flex flex-wrap items-center gap-2",children:[s.jsx(Wt,{className:"w-64",placeholder:"Label (e.g. laptop)",maxLength:120,value:o,onChange:b=>c(b.target.value)}),s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Create key"]})]}),h&&s.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-4",children:[s.jsxs("p",{className:"mb-2 text-sm font-medium",children:["New key",h.label?` "${h.label}"`:""," — copy it now, it will not be shown again."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-sm",children:h.key}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Copy key",onClick:()=>{navigator.clipboard.writeText(h.key??""),Ve.success("Copied to clipboard")},children:s.jsx(Pm,{})})]})]}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Label"}),s.jsx(ge,{children:"Key"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.keys.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No keys yet."})}),e==null?void 0:e.keys.map(b=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:b.label||s.jsx("span",{className:"text-muted-foreground",children:"(no label)"})}),s.jsxs(de,{className:"font-mono text-xs",children:["***",b.key_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(b.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(b.last_used_at)||"never"}),s.jsx(de,{className:"whitespace-nowrap",children:s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsx(ol,{children:"Delete this key?"}),s.jsxs(ul,{children:["Anything using"," ",b.label?`"${b.label}"`:`***${b.key_suffix}`," ","stops working immediately. This cannot be undone."]})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>x(b.id),children:"Delete"})]})]})]})})]},b.id))]})]})]})]})}function UA(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/my/relay-tokens")),[o,c]=S.useState(""),[d,f]=S.useState(!1),[h,m]=S.useState(null),v=async y=>{y.preventDefault(),f(!0);try{const k=await He.post("/my/relay-tokens",{label:o});m(k),c(""),l()}catch(k){Ve.error(String(k instanceof Error?k.message:k))}finally{f(!1)}},x=async y=>{try{await He.del(`/my/relay-tokens/${y}`),Ve.success("Relay token deleted"),l()}catch(k){Ve.error(String(k instanceof Error?k.message:k))}},b=y=>`export ANTHROPIC_BASE_URL=${window.location.origin}/transparent/anthropic/${y} -claude`;return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Relay tokens"}),s.jsx(it,{children:"Tracks your usage on the transparent Anthropic relay. Your Anthropic credentials pass through untouched; the token grants no proxy access."})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsxs("form",{onSubmit:v,className:"flex flex-wrap items-center gap-2",children:[s.jsx(Wt,{className:"w-64",placeholder:"Label (e.g. claude-code laptop)",maxLength:120,value:o,onChange:y=>c(y.target.value)}),s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Create relay token"]})]}),(h==null?void 0:h.token)&&s.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-4",children:[s.jsxs("p",{className:"mb-2 text-sm font-medium",children:["New relay token",h.label?` "${h.label}"`:""," — copy the setup command now, the token will not be shown again."]}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("pre",{className:"flex-1 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-sm",children:b(h.token)}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Copy setup command",onClick:()=>{navigator.clipboard.writeText(b(h.token??"")),Ve.success("Copied to clipboard")},children:s.jsx(Pm,{})})]}),s.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Make it permanent via your shell profile or ",'"env"'," in ~/.claude/settings.json."]})]}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Label"}),s.jsx(ge,{children:"Token"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.relay_tokens.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No relay tokens yet."})}),e==null?void 0:e.relay_tokens.map(y=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:y.label||s.jsx("span",{className:"text-muted-foreground",children:"(no label)"})}),s.jsxs(de,{className:"font-mono text-xs",children:["***",y.token_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(y.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(y.last_used_at)||"never"}),s.jsx(de,{className:"whitespace-nowrap",children:s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsx(ol,{children:"Delete this relay token?"}),s.jsxs(ul,{children:["Anything relaying through"," ",y.label?`"${y.label}"`:`***${y.token_suffix}`," ","stops working immediately. This cannot be undone."]})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>x(y.id),children:"Delete"})]})]})]})})]},y.id))]})]})]})]})}const fm="llmproxy:querychange";function BA(e){return window.addEventListener("popstate",e),window.addEventListener(fm,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(fm,e)}}const IA=()=>window.location.search;function Vt(e,r=""){const a=S.useSyncExternalStore(BA,IA),l=new URLSearchParams(a).get(e)??r,o=S.useCallback(c=>{const d=new URLSearchParams(window.location.search);c?d.set(e,c):d.delete(e);const f=d.toString();window.history.replaceState(null,"",window.location.pathname+(f?"?"+f:"")),window.dispatchEvent(new Event(fm))},[e]);return[l,o]}const ma={name:"",fill:"fill-chart-1",swatch:"bg-chart-1",stroke:"stroke-chart-1"},Vl={name:"",fill:"fill-chart-2 dark:fill-chart-4",swatch:"bg-chart-2 dark:bg-chart-4",stroke:"stroke-chart-2 dark:stroke-chart-4"},Zm={name:"",fill:"fill-chart-3",swatch:"bg-chart-3"},Zt=52,tw=22,rn=176,qA=24,HA=2;function nw(){const e=S.useRef(null),[r,a]=S.useState(0);return S.useLayoutEffect(()=>{const l=e.current;if(!l)return;a(l.getBoundingClientRect().width);const o=new ResizeObserver(c=>{a(c[0].contentRect.width)});return o.observe(l),()=>o.disconnect()},[]),[e,r]}function rw(e,r,a=4){if(!(e>0))return[0,1];const l=Math.pow(10,Math.floor(Math.log10(e/a))),o=e/a/l;let c=(o<=1?1:o<=2?2:o<=5?5:10)*l;r&&(c=Math.max(1,Math.round(c)));const d=(Math.floor(e/c)+1)*c,f=[];for(let h=0;h<=d+c/2;h+=c)f.push(Number(h.toFixed(10)));return f}function PA(e,r,a,l,o){const c=o?Math.min(4,a/2,l):0;return`M${e},${r+l} L${e},${r+c} Q${e},${r} ${e+c},${r} L${e+a-c},${r} Q${e+a},${r} ${e+a},${r+c} L${e+a},${r+l} Z`}function Wa({points:e,series:r,format:a,integer:l,emptyMessage:o="No usage in this range.",className:c}){var I;const[d,f]=nw(),[h,m]=S.useState(null),v=e.map(O=>O.values.reduce((E,N)=>E+(N??0),0)),x=Math.max(0,...v),b=rw(x,l===!0),y=b[b.length-1]||1,k=Math.max(0,f-Zt),j=e.length>0?k/e.length:0,T=Math.max(2,Math.min(qA,j-6)),C=O=>rn-O/y*rn,R=v.indexOf(x),D=Math.max(1,Math.ceil(e.length/8));return s.jsxs("div",{className:Ne("flex flex-col gap-2",c),children:[r.length>1&&s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:r.map(O=>s.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:Ne("size-2.5 rounded-xs",O.swatch),"aria-hidden":!0}),O.name]},O.name))}),s.jsxs("div",{ref:d,className:"relative w-full",children:[s.jsxs("svg",{width:f,height:rn+tw,className:"block overflow-visible",onPointerLeave:()=>m(null),children:[b.map(O=>s.jsxs("g",{children:[s.jsx("line",{x1:Zt,x2:f,y1:C(O),y2:C(O),className:"stroke-border",strokeWidth:1}),s.jsx("text",{x:Zt-8,y:C(O)+3,textAnchor:"end",className:"fill-muted-foreground text-[10px] tabular-nums",children:a(O)})]},O)),h!==null&&s.jsx("rect",{x:Zt+h*j,y:0,width:Math.max(j,1),height:rn,className:"fill-foreground/5"}),e.map((O,E)=>{const N=Zt+E*j+(j-T)/2;let L=-1;O.values.forEach((H,P)=>{H!==null&&H>0&&(L=P)});let X=rn;return s.jsx("g",{children:O.values.map((H,P)=>{if(H===null||H<=0)return null;const K=H/y*rn,ue=Math.max(1,K-(X0&&j>=30&&s.jsx("text",{x:Zt+R*j+j/2,y:C(x)-6,textAnchor:"middle",className:"fill-foreground text-[10px] font-medium tabular-nums",children:a(x)}),e.map((O,E)=>E%D===0?s.jsx("text",{x:Zt+E*j+j/2,y:rn+15,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:O.label},E):null),s.jsx("line",{x1:Zt,x2:f,y1:rn,y2:rn,className:"stroke-border",strokeWidth:1}),e.map((O,E)=>s.jsx("rect",{x:Zt+E*j,y:0,width:Math.max(j,1),height:rn,fill:"transparent",tabIndex:0,role:"button","aria-label":`${O.title}: ${O.values.map((N,L)=>`${r[L].name||"value"} ${N===null?"unpriced":a(N)}`).join(", ")}`,onPointerEnter:()=>m(E),onFocus:()=>m(E),onBlur:()=>m(null),className:"outline-none focus-visible:stroke-ring focus-visible:[stroke-width:2]"},E))]}),x===0&&s.jsx("p",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2 text-center text-sm text-muted-foreground",children:o}),h!==null&&e[h]&&s.jsxs("div",{className:"pointer-events-none absolute z-10 min-w-36 -translate-x-1/2 rounded-md border bg-popover p-2 text-xs shadow-md",style:{left:Math.min(Math.max(Zt+h*j+j/2,Zt+70),Math.max(f-70,Zt+70)),top:0},children:[s.jsx("p",{className:"mb-1 text-muted-foreground",children:e[h].title}),e[h].values.map((O,E)=>s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ne("h-0.5 w-3 rounded-full",r[E].swatch),"aria-hidden":!0}),s.jsx("span",{className:"font-medium tabular-nums",children:O===null?"unpriced":a(O)}),r[E].name&&s.jsx("span",{className:"text-muted-foreground",children:r[E].name})]},E)),(I=e[h].rows)==null?void 0:I.map(O=>s.jsxs("p",{className:"flex items-center gap-1.5 pl-[18px]",children:[s.jsx("span",{className:"font-medium tabular-nums",children:O.value}),s.jsx("span",{className:"text-muted-foreground",children:O.label})]},O.label))]})]})]})}function xb({points:e,series:r,format:a,integer:l,emptyMessage:o="No data in this range.",className:c}){var O;const[d,f]=nw(),[h,m]=S.useState(null),v=e.flatMap(E=>E.values.filter(N=>N!==null)),x=Math.max(0,...v),b=rw(x,l===!0),y=b[b.length-1]||1,k=Math.max(0,f-Zt),j=e.length>0?k/e.length:0,T=E=>Zt+E*j+j/2,C=E=>rn-E/y*rn,R=Math.max(1,Math.ceil(e.length/8)),D=(E,N)=>{var L;return((L=e[E])==null?void 0:L.values[N])??null},I=E=>{const N=[];let L=[];return e.forEach((X,H)=>{D(H,E)===null?(L.length&&N.push(L),L=[]):L.push(H)}),L.length&&N.push(L),N};return s.jsxs("div",{className:Ne("flex flex-col gap-2",c),children:[r.length>1&&s.jsx("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1",children:r.map(E=>s.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[s.jsx("span",{className:Ne("h-0.5 w-3 rounded-full",E.swatch),"aria-hidden":!0}),E.name]},E.name))}),s.jsxs("div",{ref:d,className:"relative w-full",children:[s.jsxs("svg",{width:f,height:rn+tw,className:"block overflow-visible",onPointerLeave:()=>m(null),children:[b.map(E=>s.jsxs("g",{children:[s.jsx("line",{x1:Zt,x2:f,y1:C(E),y2:C(E),className:"stroke-border",strokeWidth:1}),s.jsx("text",{x:Zt-8,y:C(E)+3,textAnchor:"end",className:"fill-muted-foreground text-[10px] tabular-nums",children:a(E)})]},E)),h!==null&&s.jsx("line",{x1:T(h),x2:T(h),y1:0,y2:rn,className:"stroke-muted-foreground/50",strokeWidth:1}),r.map((E,N)=>I(N).map(L=>L.length===1?s.jsx("circle",{cx:T(L[0]),cy:C(D(L[0],N)),r:4,className:Ne(E.fill,"stroke-card"),strokeWidth:2},`${N}-${L[0]}`):s.jsx("path",{d:L.map((X,H)=>`${H===0?"M":"L"}${T(X)},${C(D(X,N))}`).join(" "),fill:"none",className:E.stroke,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"},`${N}-${L[0]}`))),h!==null&&r.map((E,N)=>{const L=D(h,N);return L===null?null:s.jsx("circle",{cx:T(h),cy:C(L),r:4,className:Ne(E.fill,"stroke-card"),strokeWidth:2},N)}),e.map((E,N)=>N%R===0?s.jsx("text",{x:T(N),y:rn+15,textAnchor:"middle",className:"fill-muted-foreground text-[10px]",children:E.label},N):null),s.jsx("line",{x1:Zt,x2:f,y1:rn,y2:rn,className:"stroke-border",strokeWidth:1}),e.map((E,N)=>s.jsx("rect",{x:Zt+N*j,y:0,width:Math.max(j,1),height:rn,fill:"transparent",tabIndex:0,role:"button","aria-label":`${E.title}: ${E.values.map((L,X)=>`${r[X].name||"value"} ${L===null?"none":a(L)}`).join(", ")}`,onPointerEnter:()=>m(N),onFocus:()=>m(N),onBlur:()=>m(null),className:"outline-none focus-visible:stroke-ring focus-visible:[stroke-width:2]"},N))]}),v.length===0&&s.jsx("p",{className:"pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2 text-center text-sm text-muted-foreground",children:o}),h!==null&&e[h]&&s.jsxs("div",{className:"pointer-events-none absolute z-10 min-w-36 -translate-x-1/2 rounded-md border bg-popover p-2 text-xs shadow-md",style:{left:Math.min(Math.max(T(h),Zt+70),Math.max(f-70,Zt+70)),top:0},children:[s.jsx("p",{className:"mb-1 text-muted-foreground",children:e[h].title}),e[h].values.map((E,N)=>s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ne("h-0.5 w-3 rounded-full",r[N].swatch),"aria-hidden":!0}),s.jsx("span",{className:"font-medium tabular-nums",children:E===null?"—":a(E)}),r[N].name&&s.jsx("span",{className:"text-muted-foreground",children:r[N].name})]},N)),(O=e[h].rows)==null?void 0:O.map(E=>s.jsxs("p",{className:"flex items-center gap-1.5 pl-[18px]",children:[s.jsx("span",{className:"font-medium tabular-nums",children:E.value}),s.jsx("span",{className:"text-muted-foreground",children:E.label})]},E.label))]})]})]})}const Hl=[{fill:"fill-chart-1",swatch:"bg-chart-1"},{fill:"fill-chart-5",swatch:"bg-chart-5"},{fill:"fill-chart-3",swatch:"bg-chart-3"},{fill:"fill-border",swatch:"bg-border"}],kh=Hl.length;function Ac(e,r,a){if(e.length<=kh)return{slices:e.map(r),overflow:[]};const l=e.slice(kh-1);return{slices:[...e.slice(0,kh-1).map(r),a(l)],overflow:l.map(r)}}function $A(e,r,a,l,o,c){const d=(h,m)=>`${e+h*Math.sin(m)},${r-h*Math.cos(m)}`;if(c-o>=Math.PI*2-1e-9){const h=(m,v)=>`M${e},${r-m} A${m},${m} 0 1 ${v} ${e},${r+m} A${m},${m} 0 1 ${v} ${e},${r-m} Z`;return`${h(a,1)} ${h(l,0)}`}const f=c-o>Math.PI?1:0;return`M${d(a,o)} A${a},${a} 0 ${f} 1 ${d(a,c)} L${d(l,c)} A${l},${l} 0 ${f} 0 ${d(l,o)} Z`}const Ch=20;function lo({slices:e,overflow:r=[],format:a,emptyMessage:l="No usage in this range."}){var D;const[o,c]=S.useState(null),[d,f]=S.useState(0),h=r.length>0?e.length-1:-1,m=()=>f(I=>I===0?Math.min(Ch,r.length):0),v=e.reduce((I,O)=>I+O.value,0),x=168,b=82,y=50,k=x/2,j=x/2;if(v<=0)return s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:l});const T=e.length>1?2/((y+b)/2):0;let C=0;const R=e.map((I,O)=>{const E=I.value/v*Math.PI*2,N=C+T/2,L=Math.max(N,C+E-T/2);return C+=E,{slice:I,a0:N,a1:L,i:O}});return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-8 gap-y-4",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsx("svg",{width:x,height:x,className:"block",onPointerLeave:()=>c(null),children:R.map(({slice:I,a0:O,a1:E,i:N})=>s.jsx("path",{d:$A(k,j,b,y,O,E),className:Ne(Hl[N%Hl.length].fill,"outline-none transition-opacity focus-visible:stroke-ring focus-visible:[stroke-width:2]",o!==null&&o!==N&&"opacity-50",N===h&&"cursor-pointer"),tabIndex:0,role:N===h?"button":"img","aria-label":`${I.label}: ${a(I.value)} (${Math.round(I.value/v*100)}%)`+(N===h?d===0?"; activate to expand":"; activate to collapse":""),onClick:N===h?m:void 0,onKeyDown:N===h?L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),m())}:void 0,onPointerEnter:()=>c(N),onFocus:()=>c(N),onBlur:()=>c(null)},N))}),o!==null&&e[o]&&s.jsxs("div",{className:"pointer-events-none absolute left-1/2 top-0 z-10 min-w-32 -translate-x-1/2 rounded-md border bg-popover p-2 text-xs shadow-md",children:[s.jsx("p",{className:"mb-1 text-muted-foreground",children:e[o].label}),s.jsxs("p",{className:"font-medium tabular-nums",children:[a(e[o].value)," ",s.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",(e[o].value/v*100).toFixed(1),"%"]})]}),(D=e[o].rows)==null?void 0:D.map(I=>s.jsxs("p",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"font-medium tabular-nums",children:I.value}),s.jsx("span",{className:"text-muted-foreground",children:I.label})]},I.label))]})]}),s.jsxs("ul",{className:"min-w-48 flex-1",children:[e.map((I,O)=>s.jsx("li",{className:Ne("rounded-sm text-sm",o===O&&"bg-foreground/5"),onPointerEnter:()=>c(O),onPointerLeave:()=>c(null),children:O===h?s.jsxs("button",{type:"button",className:"flex w-full cursor-pointer items-center gap-2 rounded-sm px-1 py-1 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring","aria-expanded":d>0,onClick:m,children:[s.jsx("span",{className:Ne("size-2.5 shrink-0 rounded-xs",Hl[O%Hl.length].swatch),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",children:I.label}),d>0?s.jsx(Ji,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}):s.jsx(sm,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),s.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground",children:a(I.value)}),s.jsxs("span",{className:"w-12 text-right tabular-nums",children:[(I.value/v*100).toFixed(1),"%"]})]}):s.jsxs("span",{className:"flex items-center gap-2 px-1 py-1",children:[s.jsx("span",{className:Ne("size-2.5 shrink-0 rounded-xs",Hl[O%Hl.length].swatch),"aria-hidden":!0}),s.jsx("span",{className:"truncate font-mono text-xs",title:I.label,children:I.label}),s.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground",children:a(I.value)}),s.jsxs("span",{className:"w-12 text-right tabular-nums",children:[(I.value/v*100).toFixed(1),"%"]})]})},O)),r.slice(0,d).map((I,O)=>s.jsxs("li",{className:"flex items-center gap-2 py-1 pl-[26px] pr-1 text-sm",onPointerEnter:()=>c(h),onPointerLeave:()=>c(null),children:[s.jsx("span",{className:"truncate font-mono text-xs",title:I.label,children:I.label}),s.jsx("span",{className:"ml-auto tabular-nums text-muted-foreground",children:a(I.value)}),s.jsxs("span",{className:"w-12 text-right tabular-nums",children:[(I.value/v*100).toFixed(1),"%"]})]},`overflow-${O}`)),d>0&&df(I=>Math.min(I+Ch,r.length)),children:["Show ",Math.min(Ch,r.length-d)," more"]})})]})]})}function Ki({rows:e,format:r,emptyMessage:a="No usage in this range."}){const l=Math.max(0,...e.map(c=>c.value));if(e.length===0||l<=0)return s.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:a});const o=e.reduce((c,d)=>c+d.value,0);return s.jsx("ul",{className:"flex flex-col gap-2",children:e.map((c,d)=>s.jsxs("li",{className:"grid grid-cols-[minmax(6rem,14rem)_1fr_auto] items-center gap-3 text-sm",children:[s.jsx("span",{className:"truncate font-mono text-xs",title:c.title??c.label,children:c.label}),s.jsx("span",{className:"h-2 overflow-hidden rounded-full bg-muted","aria-hidden":!0,children:s.jsx("span",{className:"block h-full rounded-full bg-chart-1",style:{width:`${Math.max(1,c.value/l*100)}%`}})}),s.jsxs("span",{className:"tabular-nums text-muted-foreground",children:[r(c.value),c.note&&s.jsx("span",{className:"ml-2 text-xs",children:c.note}),s.jsxs("span",{className:"ml-2 inline-block w-12 text-right text-foreground",children:[(c.value/o*100).toFixed(1),"%"]})]})]},d))})}function Qn({label:e,value:r,secondary:a,delta:l,hint:o}){return s.jsxs("div",{className:"flex flex-col gap-1 rounded-lg border bg-card p-4",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),s.jsxs("span",{className:"text-2xl font-semibold",children:[r,a&&s.jsx("span",{className:"ml-2 text-sm font-normal text-muted-foreground",children:a})]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:l==null?o??" ":s.jsxs(s.Fragment,{children:[l>=0?"+":"",Math.round(l*100),"% vs previous"]})})]})}function vb(e,[r,a]){return Math.min(a,Math.max(r,e))}function Jm(e){const r=e+"CollectionProvider",[a,l]=Sr(r),[o,c]=a(r,{collectionRef:{current:null},itemMap:new Map}),d=y=>{const{scope:k,children:j}=y,T=ve.useRef(null),C=ve.useRef(new Map).current;return s.jsx(o,{scope:k,itemMap:C,collectionRef:T,children:j})};d.displayName=r;const f=e+"CollectionSlot",h=ve.forwardRef((y,k)=>{const{scope:j,children:T}=y,C=c(f,j),R=ft(k,C.collectionRef);return s.jsx(xa,{ref:R,children:T})});h.displayName=f;const m=e+"CollectionItemSlot",v="data-radix-collection-item",x=ve.forwardRef((y,k)=>{const{scope:j,children:T,...C}=y,R=ve.useRef(null),D=ft(k,R),I=c(m,j);return ve.useEffect(()=>(I.itemMap.set(R,{ref:R,...C}),()=>void I.itemMap.delete(R))),s.jsx(xa,{[v]:"",ref:D,children:T})});x.displayName=m;function b(y){const k=c(e+"CollectionConsumer",y);return ve.useCallback(()=>{const T=k.collectionRef.current;if(!T)return[];const C=Array.from(T.querySelectorAll(`[${v}]`));return Array.from(k.itemMap.values()).sort((I,O)=>C.indexOf(I.ref.current)-C.indexOf(O.ref.current))},[k.collectionRef,k.itemMap])}return[{Provider:d,Slot:h,ItemSlot:x},b,l]}var FA=S.createContext(void 0);function _c(e){const r=S.useContext(FA);return e||r||"ltr"}const VA=["top","right","bottom","left"],fl=Math.min,pa=Math.max,uc=Math.round,Xu=Math.floor,ga=e=>({x:e,y:e}),GA={left:"right",right:"left",bottom:"top",top:"bottom"};function aw(e,r,a){return pa(e,fl(r,a))}function va(e,r){return typeof e=="function"?e(r):e}function hl(e){return e.split("-")[0]}function Wi(e){return e.split("-")[1]}function Wm(e){return e==="x"?"y":"x"}function ep(e){return e==="y"?"height":"width"}function Ur(e){const r=e[0];return r==="t"||r==="b"?"y":"x"}function tp(e){return Wm(Ur(e))}function YA(e,r,a){a===void 0&&(a=!1);const l=Wi(e),o=tp(e),c=ep(o);let d=o==="x"?l===(a?"end":"start")?"right":"left":l==="start"?"bottom":"top";return r.reference[c]>r.floating[c]&&(d=cc(d)),[d,cc(d)]}function XA(e){const r=cc(e);return[hm(e),r,hm(r)]}function hm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const yb=["left","right"],bb=["right","left"],KA=["top","bottom"],QA=["bottom","top"];function ZA(e,r,a){switch(e){case"top":case"bottom":return a?r?bb:yb:r?yb:bb;case"left":case"right":return r?KA:QA;default:return[]}}function JA(e,r,a,l){const o=Wi(e);let c=ZA(hl(e),a==="start",l);return o&&(c=c.map(d=>d+"-"+o),r&&(c=c.concat(c.map(hm)))),c}function cc(e){const r=hl(e);return GA[r]+e.slice(r.length)}function WA(e){var r,a,l,o;return{top:(r=e.top)!=null?r:0,right:(a=e.right)!=null?a:0,bottom:(l=e.bottom)!=null?l:0,left:(o=e.left)!=null?o:0}}function lw(e){return typeof e!="number"?WA(e):{top:e,right:e,bottom:e,left:e}}function dc(e){const{x:r,y:a,width:l,height:o}=e;return{width:l,height:o,top:a,left:r,right:r+l,bottom:a+o,x:r,y:a}}function wb(e,r,a){let{reference:l,floating:o}=e;const c=Ur(r),d=tp(r),f=ep(d),h=hl(r),m=c==="y",v=l.x+l.width/2-o.width/2,x=l.y+l.height/2-o.height/2,b=l[f]/2-o[f]/2;let y;switch(h){case"top":y={x:v,y:l.y-o.height};break;case"bottom":y={x:v,y:l.y+l.height};break;case"right":y={x:l.x+l.width,y:x};break;case"left":y={x:l.x-o.width,y:x};break;default:y={x:l.x,y:l.y}}const k=Wi(r);return k&&(y[d]+=b*(k==="end"?1:-1)*(a&&m?-1:1)),y}async function e_(e,r){var a;r===void 0&&(r={});const{x:l,y:o,platform:c,rects:d,elements:f,strategy:h}=e,{boundary:m="clippingAncestors",rootBoundary:v="viewport",elementContext:x="floating",altBoundary:b=!1,padding:y=0}=va(r,e),k=lw(y),T=f[b?x==="floating"?"reference":"floating":x],C=dc(await c.getClippingRect({element:(a=await(c.isElement==null?void 0:c.isElement(T)))==null||a?T:T.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(f.floating)),boundary:m,rootBoundary:v,strategy:h})),R=x==="floating"?{x:l,y:o,width:d.floating.width,height:d.floating.height}:d.reference,D=await(c.getOffsetParent==null?void 0:c.getOffsetParent(f.floating)),I=await(c.isElement==null?void 0:c.isElement(D))&&await(c.getScale==null?void 0:c.getScale(D))||{x:1,y:1},O=dc(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:f,rect:R,offsetParent:D,strategy:h}):R);return{top:(C.top-O.top+k.top)/I.y,bottom:(O.bottom-C.bottom+k.bottom)/I.y,left:(C.left-O.left+k.left)/I.x,right:(O.right-C.right+k.right)/I.x}}const t_=50,n_=async(e,r,a)=>{const{placement:l="bottom",strategy:o="absolute",middleware:c=[],platform:d}=a,f=d.detectOverflow?d:{...d,detectOverflow:e_},h=await(d.isRTL==null?void 0:d.isRTL(r));let m=await d.getElementRects({reference:e,floating:r,strategy:o}),{x:v,y:x}=wb(m,l,h),b=l,y=0;const k={};for(let j=0;j({name:"arrow",options:e,async fn(r){const{x:a,y:l,placement:o,rects:c,platform:d,elements:f,middlewareData:h}=r,{element:m,padding:v=0}=va(e,r)||{};if(m==null)return{};const x=lw(v),b={x:a,y:l},y=tp(o),k=ep(y),j=await d.getDimensions(m),T=y==="y",C=T?"top":"left",R=T?"bottom":"right",D=T?"clientHeight":"clientWidth",I=c.reference[k]+c.reference[y]-b[y]-c.floating[k],O=b[y]-c.reference[y],E=await(d.getOffsetParent==null?void 0:d.getOffsetParent(m));let N=E?E[D]:0;(!N||!await(d.isElement==null?void 0:d.isElement(E)))&&(N=f.floating[D]||c.floating[k]);const L=I/2-O/2,X=N/2-j[k]/2-1,H=fl(x[C],X),P=fl(x[R],X),K=N-j[k]-P,ue=N/2-j[k]/2+L,le=aw(H,ue,K),W=!h.arrow&&Wi(o)!=null&&ue!==le&&c.reference[k]/2-(uele<=0)){var P,K;const le=(((P=c.flip)==null?void 0:P.index)||0)+1,W=N[le];if(W&&(!(x==="alignment"?R!==Ur(W):!1)||H.every(ae=>Ur(ae.placement)===R?ae.overflows[0]>0:!0)))return{data:{index:le,overflows:H},reset:{placement:W}};let B=(K=H.filter(F=>F.overflows[0]<=0).sort((F,ae)=>F.overflows[1]-ae.overflows[1])[0])==null?void 0:K.placement;if(!B)switch(y){case"bestFit":{var ue;const F=(ue=H.filter(ae=>{if(E){const Z=Ur(ae.placement);return Z===R||Z==="y"}return!0}).map(ae=>[ae.placement,ae.overflows.filter(Z=>Z>0).reduce((Z,A)=>Z+A,0)]).sort((ae,Z)=>ae[1]-Z[1])[0])==null?void 0:ue[0];F&&(B=F);break}case"initialPlacement":B=f;break}if(o!==B)return{reset:{placement:B}}}return{}}}};function Sb(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function jb(e){return VA.some(r=>e[r]>=0)}const l_=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(r){const{rects:a,platform:l}=r,{strategy:o="referenceHidden",...c}=va(e,r);switch(o){case"referenceHidden":{const d=await l.detectOverflow(r,{...c,elementContext:"reference"}),f=Sb(d,a.reference);return{data:{referenceHiddenOffsets:f,referenceHidden:jb(f)}}}case"escaped":{const d=await l.detectOverflow(r,{...c,altBoundary:!0}),f=Sb(d,a.floating);return{data:{escapedOffsets:f,escaped:jb(f)}}}default:return{}}}}},iw=new Set(["left","top"]);async function i_(e,r){const{placement:a,platform:l,elements:o}=e,c=await(l.isRTL==null?void 0:l.isRTL(o.floating)),d=hl(a),f=Wi(a),h=Ur(a)==="y",m=iw.has(d)?-1:1,v=c&&h?-1:1,x=va(r,e);let{mainAxis:b,crossAxis:y,alignmentAxis:k}=typeof x=="number"?{mainAxis:x,crossAxis:0,alignmentAxis:null}:{mainAxis:x.mainAxis||0,crossAxis:x.crossAxis||0,alignmentAxis:x.alignmentAxis};return f&&typeof k=="number"&&(y=f==="end"?k*-1:k),h?{x:y*v,y:b*m}:{x:b*m,y:y*v}}const s_=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(r){var a,l;const{x:o,y:c,placement:d,middlewareData:f}=r,h=await i_(r,e);return d===((a=f.offset)==null?void 0:a.placement)&&(l=f.arrow)!=null&&l.alignmentOffset?{}:{x:o+h.x,y:c+h.y,data:{...h,placement:d}}}}},o_=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(r){const{x:a,y:l,placement:o,platform:c}=r,{mainAxis:d=!0,crossAxis:f=!1,limiter:h={fn:R=>{let{x:D,y:I}=R;return{x:D,y:I}}},...m}=va(e,r),v={x:a,y:l},x=await c.detectOverflow(r,m),b=Ur(o),y=Wm(b);let k=v[y],j=v[b];const T=(R,D)=>aw(D+x[R==="y"?"top":"left"],D,D-x[R==="y"?"bottom":"right"]);d&&(k=T(y,k)),f&&(j=T(b,j));const C=h.fn({...r,[y]:k,[b]:j});return{...C,data:{x:C.x-a,y:C.y-l,enabled:{[y]:d,[b]:f}}}}}},u_=function(e){return e===void 0&&(e={}),{options:e,fn(r){var a,l;const{x:o,y:c,placement:d,rects:f,middlewareData:h}=r,{offset:m=0,mainAxis:v=!0,crossAxis:x=!0}=va(e,r),b={x:o,y:c},y=Ur(d),k=Wm(y);let j=b[k],T=b[y];const C=va(m,r),R=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:(a=C.mainAxis)!=null?a:0,crossAxis:(l=C.crossAxis)!=null?l:0};if(v){const O=k==="y"?"height":"width",E=f.reference[k]-f.floating[O]+R.mainAxis,N=f.reference[k]+f.reference[O]-R.mainAxis;jN&&(j=N)}if(x){var D,I;const O=k==="y"?"width":"height",E=iw.has(hl(d)),N=f.reference[y]-f.floating[O]+(E&&((D=h.offset)==null?void 0:D[y])||0)+(E?0:R.crossAxis),L=f.reference[y]+f.reference[O]+(E?0:((I=h.offset)==null?void 0:I[y])||0)-(E?R.crossAxis:0);TL&&(T=L)}return{[k]:j,[y]:T}}}},c_=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(r){const{placement:a,rects:l,platform:o,elements:c}=r,{apply:d=()=>{},...f}=va(e,r),h=await o.detectOverflow(r,f),m=hl(a),v=Wi(a),x=Ur(a)==="y",{width:b,height:y}=l.floating;let k,j;m==="top"||m==="bottom"?(k=m,j=v===(await(o.isRTL==null?void 0:o.isRTL(c.floating))?"start":"end")?"left":"right"):(j=m,k=v==="end"?"top":"bottom");const T=y-h.top-h.bottom,C=b-h.left-h.right,R=fl(y-h[k],T),D=fl(b-h[j],C),I=r.middlewareData.shift,O=!I;let E=R,N=D;I!=null&&I.enabled.x&&(N=C),I!=null&&I.enabled.y&&(E=T),O&&!v&&(x?N=b-2*pa(h.left,h.right):E=y-2*pa(h.top,h.bottom)),await d({...r,availableWidth:N,availableHeight:E});const L=await o.getDimensions(c.floating);return b!==L.width||y!==L.height?{reset:{rects:!0}}:{}}}};function Mc(){return typeof window<"u"}function es(e){return sw(e)?(e.nodeName||"").toLowerCase():"#document"}function In(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function ba(e){var r;return(r=(sw(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function sw(e){return Mc()?e instanceof Node||e instanceof In(e).Node:!1}function Ir(e){return Mc()?e instanceof Element||e instanceof In(e).Element:!1}function gl(e){return Mc()?e instanceof HTMLElement||e instanceof In(e).HTMLElement:!1}function kb(e){return!Mc()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof In(e).ShadowRoot}function Rc(e){const{overflow:r,overflowX:a,overflowY:l,display:o}=qr(e);return/auto|scroll|overlay|hidden|clip/.test(r+l+a)&&o!=="inline"&&o!=="contents"}function d_(e){return/^(table|td|th)$/.test(es(e))}function Dc(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const f_=/transform|translate|scale|rotate|perspective|filter/,h_=/paint|layout|strict|content/,Il=e=>!!e&&e!=="none";let Nh;function np(e){const r=Ir(e)?qr(e):e;return Il(r.transform)||Il(r.translate)||Il(r.scale)||Il(r.rotate)||Il(r.perspective)||!rp()&&(Il(r.backdropFilter)||Il(r.filter))||f_.test(r.willChange||"")||h_.test(r.contain||"")}function m_(e){let r=Gl(e);for(;gl(r)&&!co(r);){if(np(r))return r;if(Dc(r))return null;r=Gl(r)}return null}function rp(){return Nh==null&&(Nh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Nh}function co(e){return/^(html|body|#document)$/.test(es(e))}function qr(e){return In(e).getComputedStyle(e)}function Oc(e){return Ir(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gl(e){if(es(e)==="html")return e;const r=e.assignedSlot||e.parentNode||kb(e)&&e.host||ba(e);return kb(r)?r.host:r}function ow(e){const r=Gl(e);return co(r)?(e.ownerDocument||e).body:gl(r)&&Rc(r)?r:ow(r)}function fo(e,r,a){var l;r===void 0&&(r=[]),a===void 0&&(a=!0);const o=ow(e),c=o===((l=e.ownerDocument)==null?void 0:l.body),d=In(o);if(c){const f=mm(d);return r.concat(d,d.visualViewport||[],Rc(o)?o:[],f&&a?fo(f):[])}else return r.concat(o,fo(o,[],a))}function mm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function uw(e){const r=qr(e);let a=parseFloat(r.width)||0,l=parseFloat(r.height)||0;const o=gl(e),c=o?e.offsetWidth:a,d=o?e.offsetHeight:l,f=uc(a)!==c||uc(l)!==d;return f&&(a=c,l=d),{width:a,height:l,$:f}}function ap(e){return Ir(e)?e:e.contextElement}function Qi(e){const r=ap(e);if(!gl(r))return ga(1);const a=r.getBoundingClientRect(),{width:l,height:o,$:c}=uw(r);let d=(c?uc(a.width):a.width)/l,f=(c?uc(a.height):a.height)/o;return(!d||!Number.isFinite(d))&&(d=1),(!f||!Number.isFinite(f))&&(f=1),{x:d,y:f}}const p_=ga(0);function cw(e){const r=In(e);return!rp()||!r.visualViewport?p_:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function g_(e,r,a){return r===void 0&&(r=!1),!!a&&r&&a===In(e)}function Yl(e,r,a,l){r===void 0&&(r=!1),a===void 0&&(a=!1);const o=e.getBoundingClientRect(),c=ap(e);let d=ga(1);r&&(l?Ir(l)&&(d=Qi(l)):d=Qi(e));const f=g_(c,a,l)?cw(c):ga(0);let h=(o.left+f.x)/d.x,m=(o.top+f.y)/d.y,v=o.width/d.x,x=o.height/d.y;if(c&&l){const b=In(c),y=Ir(l)?In(l):l;let k=b,j=mm(k);for(;j&&y!==k;){const T=Qi(j),C=j.getBoundingClientRect(),R=qr(j),D=C.left+(j.clientLeft+parseFloat(R.paddingLeft))*T.x,I=C.top+(j.clientTop+parseFloat(R.paddingTop))*T.y;h*=T.x,m*=T.y,v*=T.x,x*=T.y,h+=D,m+=I,k=In(j),j=mm(k)}}return dc({width:v,height:x,x:h,y:m})}function zc(e,r){const a=Oc(e).scrollLeft;return r?r.left+a:Yl(ba(e)).left+a}function dw(e,r){const a=e.getBoundingClientRect(),l=a.left+r.scrollLeft-zc(e,a),o=a.top+r.scrollTop;return{x:l,y:o}}function x_(e){let{elements:r,rect:a,offsetParent:l,strategy:o}=e;const c=o==="fixed",d=ba(l),f=r?Dc(r.floating):!1;if(l===d||f&&c)return a;let h={scrollLeft:0,scrollTop:0},m=ga(1);const v=ga(0),x=gl(l);if((x||!c)&&((es(l)!=="body"||Rc(d))&&(h=Oc(l)),x)){const y=Yl(l);m=Qi(l),v.x=y.x+l.clientLeft,v.y=y.y+l.clientTop}const b=d&&!x&&!c?dw(d,h):ga(0);return{width:a.width*m.x,height:a.height*m.y,x:a.x*m.x-h.scrollLeft*m.x+v.x+b.x,y:a.y*m.y-h.scrollTop*m.y+v.y+b.y}}function v_(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function y_(e){const r=Oc(e),a=e.ownerDocument.body,l=pa(e.scrollWidth,e.clientWidth,a.scrollWidth,a.clientWidth),o=pa(e.scrollHeight,e.clientHeight,a.scrollHeight,a.clientHeight);let c=-r.scrollLeft+zc(e);const d=-r.scrollTop;return qr(a).direction==="rtl"&&(c+=pa(e.clientWidth,a.clientWidth)-l),{width:l,height:o,x:c,y:d}}const b_=25;function w_(e,r,a){a===void 0&&(a="viewport");const l=a==="layoutViewport",o=In(e),c=ba(e),d=o.visualViewport;let f=c.clientWidth,h=c.clientHeight,m=0,v=0;if(d){const b=!rp()||r==="fixed";l?b||(m=-d.offsetLeft,v=-d.offsetTop):(f=d.width,h=d.height,b&&(m=d.offsetLeft,v=d.offsetTop))}if(zc(c)<=0){const b=c.ownerDocument,y=b.body,k=getComputedStyle(y),j=b.compatMode==="CSS1Compat"&&parseFloat(k.marginLeft)+parseFloat(k.marginRight)||0,T=Math.abs(c.clientWidth-y.clientWidth-j),C=getComputedStyle(c).scrollbarGutter==="stable both-edges"?T/2:T;C<=b_&&(f-=C)}return{width:f,height:h,x:m,y:v}}function S_(e,r){const a=Yl(e,!0,r==="fixed"),l=a.top+e.clientTop,o=a.left+e.clientLeft,c=Qi(e),d=e.clientWidth*c.x,f=e.clientHeight*c.y,h=o*c.x,m=l*c.y;return{width:d,height:f,x:h,y:m}}function Cb(e,r,a){let l;if(r==="viewport"||r==="layoutViewport")l=w_(e,a,r);else if(r==="document")l=y_(ba(e));else if(Ir(r))l=S_(r,a);else{const o=cw(e);l={x:r.x-o.x,y:r.y-o.y,width:r.width,height:r.height}}return dc(l)}function j_(e,r){const a=r.get(e);if(a)return a;let l=fo(e,[],!1).filter(f=>Ir(f)&&es(f)!=="body"),o=null;const c=qr(e).position==="fixed";let d=c?Gl(e):e;for(;Ir(d)&&!co(d);){const f=qr(d),h=np(d),m=o?o.position:c?"fixed":"";!h&&(m==="fixed"||m==="absolute"&&f.position==="static")?l=l.filter(x=>x!==d):o=f,d=Gl(d)}return r.set(e,l),l}function k_(e){let{element:r,boundary:a,rootBoundary:l,strategy:o}=e;const d=[...a==="clippingAncestors"?Dc(r)?[]:j_(r,this._c):[].concat(a),l],f=Cb(r,d[0],o);let h=f.top,m=f.right,v=f.bottom,x=f.left;for(let b=1;b{f(!1,1e-7)},1e3)}N=!1}try{l=new IntersectionObserver(L,{...E,root:c.ownerDocument})}catch{l=new IntersectionObserver(L,E)}l.observe(e)}const h=In(e),m=()=>f(a);return h.addEventListener("resize",m),f(!0),()=>{h.removeEventListener("resize",m),d()}}function M_(e,r,a,l){l===void 0&&(l={});const{ancestorScroll:o=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:f=typeof IntersectionObserver=="function",animationFrame:h=!1}=l,m=ap(e),v=o||c?[...m?fo(m):[],...r?fo(r):[]]:[];v.forEach(C=>{o&&C.addEventListener("scroll",a),c&&C.addEventListener("resize",a)});const x=m&&f?__(m,a,c):null;let b=-1,y=null;d&&(y=new ResizeObserver(C=>{let[R]=C;R&&R.target===m&&y&&r&&(y.unobserve(r),cancelAnimationFrame(b),b=requestAnimationFrame(()=>{var D;(D=y)==null||D.observe(r)})),a()}),m&&!h&&y.observe(m),r&&y.observe(r));let k,j=h?Yl(e):null;h&&T();function T(){const C=Yl(e);j&&!hw(j,C)&&a(),j=C,k=requestAnimationFrame(T)}return a(),()=>{var C;v.forEach(R=>{o&&R.removeEventListener("scroll",a),c&&R.removeEventListener("resize",a)}),x==null||x(),(C=y)==null||C.disconnect(),y=null,h&&cancelAnimationFrame(k)}}const R_=s_,D_=o_,O_=a_,z_=c_,L_=l_,Eb=r_,U_=u_,B_=(e,r,a)=>{const l=new Map,o=a??{},c={...A_,...o.platform,_c:l};return n_(e,r,{...o,platform:c})};var I_=typeof document<"u",q_=function(){},lc=I_?S.useLayoutEffect:q_;function fc(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(typeof e=="function"&&e.toString()===r.toString())return!0;let a,l,o;if(e&&r&&typeof e=="object"){if(Array.isArray(e)){if(a=e.length,a!==r.length)return!1;for(l=a;l--!==0;)if(!fc(e[l],r[l]))return!1;return!0}if(o=Object.keys(e),a=o.length,a!==Object.keys(r).length)return!1;for(l=a;l--!==0;)if(!{}.hasOwnProperty.call(r,o[l]))return!1;for(l=a;l--!==0;){const c=o[l];if(!(c==="_owner"&&e.$$typeof)&&!fc(e[c],r[c]))return!1}return!0}return e!==e&&r!==r}function mw(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Tb(e,r){const a=mw(e);return Math.round(r*a)/a}function Th(e){const r=S.useRef(e);return lc(()=>{r.current=e}),r}function H_(e){e===void 0&&(e={});const{placement:r="bottom",strategy:a="absolute",middleware:l=[],platform:o,elements:{reference:c,floating:d}={},transform:f=!0,whileElementsMounted:h,open:m}=e,[v,x]=S.useState({x:0,y:0,strategy:a,placement:r,middlewareData:{},isPositioned:!1}),[b,y]=S.useState(l);fc(b,l)||y(l);const[k,j]=S.useState(null),[T,C]=S.useState(null),R=S.useCallback(ae=>{ae!==E.current&&(E.current=ae,j(ae))},[]),D=S.useCallback(ae=>{ae!==N.current&&(N.current=ae,C(ae))},[]),I=c||k,O=d||T,E=S.useRef(null),N=S.useRef(null),L=S.useRef(v),X=h!=null,H=Th(h),P=Th(o),K=Th(m),ue=S.useCallback(()=>{if(!E.current||!N.current)return;const ae={placement:r,strategy:a,middleware:b};P.current&&(ae.platform=P.current),B_(E.current,N.current,ae).then(Z=>{const A={...Z,isPositioned:K.current!==!1};le.current&&!fc(L.current,A)&&(L.current=A,vo.flushSync(()=>{x(A)}))})},[b,r,a,P,K]);lc(()=>{m===!1&&L.current.isPositioned&&(L.current.isPositioned=!1,x(ae=>({...ae,isPositioned:!1})))},[m]);const le=S.useRef(!1);lc(()=>(le.current=!0,()=>{le.current=!1}),[]),lc(()=>{if(I&&(E.current=I),O&&(N.current=O),I&&O){if(H.current)return H.current(I,O,ue);ue()}},[I,O,ue,H,X]);const W=S.useMemo(()=>({reference:E,floating:N,setReference:R,setFloating:D}),[R,D]),B=S.useMemo(()=>({reference:I,floating:O}),[I,O]),F=S.useMemo(()=>{const ae={position:a,left:0,top:0};if(!B.floating)return ae;const Z=Tb(B.floating,v.x),A=Tb(B.floating,v.y);return f?{...ae,transform:"translate("+Z+"px, "+A+"px)",...mw(B.floating)>=1.5&&{willChange:"transform"}}:{position:a,left:Z,top:A}},[a,f,B.floating,v.x,v.y]);return S.useMemo(()=>({...v,update:ue,refs:W,elements:B,floatingStyles:F}),[v,ue,W,B,F])}const P_=e=>{function r(a){return{}.hasOwnProperty.call(a,"current")}return{name:"arrow",options:e,fn(a){const{element:l,padding:o}=typeof e=="function"?e(a):e;return l&&r(l)?l.current!=null?Eb({element:l.current,padding:o}).fn(a):{}:l?Eb({element:l,padding:o}).fn(a):{}}}},$_=(e,r)=>{const a=R_(e);return{name:a.name,fn:a.fn,options:[e,r]}},F_=(e,r)=>{const a=D_(e);return{name:a.name,fn:a.fn,options:[e,r]}},V_=(e,r)=>({fn:U_(e).fn,options:[e,r]}),G_=(e,r)=>{const a=O_(e);return{name:a.name,fn:a.fn,options:[e,r]}},Y_=(e,r)=>{const a=z_(e);return{name:a.name,fn:a.fn,options:[e,r]}},X_=(e,r)=>{const a=L_(e);return{name:a.name,fn:a.fn,options:[e,r]}},K_=(e,r)=>{const a=P_(e);return{name:a.name,fn:a.fn,options:[e,r]}};var Q_="Arrow",pw=S.forwardRef((e,r)=>{const{children:a,width:l=10,height:o=5,...c}=e;return s.jsx(Ge.svg,{...c,ref:r,width:l,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?a:s.jsx("polygon",{points:"0,0 30,0 15,10"})})});pw.displayName=Q_;var Z_=pw;function lp(e){const[r,a]=S.useState(void 0);return Nn(()=>{if(e){a({width:e.offsetWidth,height:e.offsetHeight});const l=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const c=o[0];let d,f;if("borderBoxSize"in c){const h=c.borderBoxSize,m=Array.isArray(h)?h[0]:h;d=m.inlineSize,f=m.blockSize}else d=e.offsetWidth,f=e.offsetHeight;a({width:d,height:f})});return l.observe(e,{box:"border-box"}),()=>l.unobserve(e)}else a(void 0)},[e]),r}var ip="Popper",[gw,Lc]=Sr(ip),[J_,xw]=gw(ip),vw=e=>{const{__scopePopper:r,children:a}=e,[l,o]=S.useState(null);return s.jsx(J_,{scope:r,anchor:l,onAnchorChange:o,children:a})};vw.displayName=ip;var yw="PopperAnchor",bw=S.forwardRef((e,r)=>{const{__scopePopper:a,virtualRef:l,...o}=e,c=xw(yw,a),d=S.useRef(null),f=ft(r,d);return S.useEffect(()=>{c.onAnchorChange((l==null?void 0:l.current)||d.current)}),l?null:s.jsx(Ge.div,{...o,ref:f})});bw.displayName=yw;var sp="PopperContent",[W_,eM]=gw(sp),ww=S.forwardRef((e,r)=>{var re,ye,fe,we,Ee,Se;const{__scopePopper:a,side:l="bottom",sideOffset:o=0,align:c="center",alignOffset:d=0,arrowPadding:f=0,avoidCollisions:h=!0,collisionBoundary:m=[],collisionPadding:v=0,sticky:x="partial",hideWhenDetached:b=!1,updatePositionStrategy:y="optimized",onPlaced:k,...j}=e,T=xw(sp,a),[C,R]=S.useState(null),D=ft(r,Ie=>R(Ie)),[I,O]=S.useState(null),E=lp(I),N=(E==null?void 0:E.width)??0,L=(E==null?void 0:E.height)??0,X=l+(c!=="center"?"-"+c:""),H=typeof v=="number"?v:{top:0,right:0,bottom:0,left:0,...v},P=Array.isArray(m)?m:[m],K=P.length>0,ue={padding:H,boundary:P.filter(nM),altBoundary:K},{refs:le,floatingStyles:W,placement:B,isPositioned:F,middlewareData:ae}=H_({strategy:"fixed",placement:X,whileElementsMounted:(...Ie)=>M_(...Ie,{animationFrame:y==="always"}),elements:{reference:T.anchor},middleware:[$_({mainAxis:o+L,alignmentAxis:d}),h&&F_({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?V_():void 0,...ue}),h&&G_({...ue}),Y_({...ue,apply:({elements:Ie,rects:Be,availableWidth:Mt,availableHeight:Nt})=>{const{width:Et,height:Bt}=Be.reference,Rt=Ie.floating.style;Rt.setProperty("--radix-popper-available-width",`${Mt}px`),Rt.setProperty("--radix-popper-available-height",`${Nt}px`),Rt.setProperty("--radix-popper-anchor-width",`${Et}px`),Rt.setProperty("--radix-popper-anchor-height",`${Bt}px`)}}),I&&K_({element:I,padding:f}),rM({arrowWidth:N,arrowHeight:L}),b&&X_({strategy:"referenceHidden",...ue})]}),[Z,A]=kw(B),U=fr(k);Nn(()=>{F&&(U==null||U())},[F,U]);const V=(re=ae.arrow)==null?void 0:re.x,M=(ye=ae.arrow)==null?void 0:ye.y,se=((fe=ae.arrow)==null?void 0:fe.centerOffset)!==0,[Y,ce]=S.useState();return Nn(()=>{C&&ce(window.getComputedStyle(C).zIndex)},[C]),s.jsx("div",{ref:le.setFloating,"data-radix-popper-content-wrapper":"",style:{...W,transform:F?W.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Y,"--radix-popper-transform-origin":[(we=ae.transformOrigin)==null?void 0:we.x,(Ee=ae.transformOrigin)==null?void 0:Ee.y].join(" "),...((Se=ae.hide)==null?void 0:Se.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:s.jsx(W_,{scope:a,placedSide:Z,onArrowChange:O,arrowX:V,arrowY:M,shouldHideArrow:se,children:s.jsx(Ge.div,{"data-side":Z,"data-align":A,...j,ref:D,style:{...j.style,animation:F?void 0:"none"}})})})});ww.displayName=sp;var Sw="PopperArrow",tM={top:"bottom",right:"left",bottom:"top",left:"right"},jw=S.forwardRef(function(r,a){const{__scopePopper:l,...o}=r,c=eM(Sw,l),d=tM[c.placedSide];return s.jsx("span",{ref:c.onArrowChange,style:{position:"absolute",left:c.arrowX,top:c.arrowY,[d]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[c.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[c.placedSide],visibility:c.shouldHideArrow?"hidden":void 0},children:s.jsx(Z_,{...o,ref:a,style:{...o.style,display:"block"}})})});jw.displayName=Sw;function nM(e){return e!==null}var rM=e=>({name:"transformOrigin",options:e,fn(r){var T,C,R;const{placement:a,rects:l,middlewareData:o}=r,d=((T=o.arrow)==null?void 0:T.centerOffset)!==0,f=d?0:e.arrowWidth,h=d?0:e.arrowHeight,[m,v]=kw(a),x={start:"0%",center:"50%",end:"100%"}[v],b=(((C=o.arrow)==null?void 0:C.x)??0)+f/2,y=(((R=o.arrow)==null?void 0:R.y)??0)+h/2;let k="",j="";return m==="bottom"?(k=d?x:`${b}px`,j=`${-h}px`):m==="top"?(k=d?x:`${b}px`,j=`${l.floating.height+h}px`):m==="right"?(k=`${-h}px`,j=d?x:`${y}px`):m==="left"&&(k=`${l.floating.width+h}px`,j=d?x:`${y}px`),{data:{x:k,y:j}}}});function kw(e){const[r,a="center"]=e.split("-");return[r,a]}var Cw=vw,Nw=bw,Ew=ww,Tw=jw;function op(e){const r=S.useRef({value:e,previous:e});return S.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}var aM="VisuallyHidden",Aw=S.forwardRef((e,r)=>s.jsx(Ge.span,{...e,ref:r,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));Aw.displayName=aM;var lM=[" ","Enter","ArrowUp","ArrowDown"],iM=[" ","Enter"],bo="Select",[Uc,Bc,sM]=Jm(bo),[ts]=Sr(bo,[sM,Lc]),Ic=Lc(),[oM,xl]=ts(bo),[uM,cM]=ts(bo),_w=e=>{const{__scopeSelect:r,children:a,open:l,defaultOpen:o,onOpenChange:c,value:d,defaultValue:f,onValueChange:h,dir:m,name:v,autoComplete:x,disabled:b,required:y,form:k}=e,j=Ic(r),[T,C]=S.useState(null),[R,D]=S.useState(null),[I,O]=S.useState(!1),E=_c(m),[N=!1,L]=nl({prop:l,defaultProp:o,onChange:c}),[X,H]=nl({prop:d,defaultProp:f,onChange:h}),P=S.useRef(null),K=T?k||!!T.closest("form"):!0,[ue,le]=S.useState(new Set),W=Array.from(ue).map(B=>B.props.value).join(";");return s.jsx(Cw,{...j,children:s.jsxs(oM,{required:y,scope:r,trigger:T,onTriggerChange:C,valueNode:R,onValueNodeChange:D,valueNodeHasChildren:I,onValueNodeHasChildrenChange:O,contentId:Br(),value:X,onValueChange:H,open:N,onOpenChange:L,dir:E,triggerPointerDownPosRef:P,disabled:b,children:[s.jsx(Uc.Provider,{scope:r,children:s.jsx(uM,{scope:e.__scopeSelect,onNativeOptionAdd:S.useCallback(B=>{le(F=>new Set(F).add(B))},[]),onNativeOptionRemove:S.useCallback(B=>{le(F=>{const ae=new Set(F);return ae.delete(B),ae})},[]),children:a})}),K?s.jsxs(Ww,{"aria-hidden":!0,required:y,tabIndex:-1,name:v,autoComplete:x,value:X,onChange:B=>H(B.target.value),disabled:b,form:k,children:[X===void 0?s.jsx("option",{value:""}):null,Array.from(ue)]},W):null]})})};_w.displayName=bo;var Mw="SelectTrigger",Rw=S.forwardRef((e,r)=>{const{__scopeSelect:a,disabled:l=!1,...o}=e,c=Ic(a),d=xl(Mw,a),f=d.disabled||l,h=ft(r,d.onTriggerChange),m=Bc(a),v=S.useRef("touch"),[x,b,y]=eS(j=>{const T=m().filter(D=>!D.disabled),C=T.find(D=>D.value===d.value),R=tS(T,j,C);R!==void 0&&d.onValueChange(R.value)}),k=j=>{f||(d.onOpenChange(!0),y()),j&&(d.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return s.jsx(Nw,{asChild:!0,...c,children:s.jsx(Ge.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:f,"data-disabled":f?"":void 0,"data-placeholder":Jw(d.value)?"":void 0,...o,ref:h,onClick:Ae(o.onClick,j=>{j.currentTarget.focus(),v.current!=="mouse"&&k(j)}),onPointerDown:Ae(o.onPointerDown,j=>{v.current=j.pointerType;const T=j.target;T.hasPointerCapture(j.pointerId)&&T.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(k(j),j.preventDefault())}),onKeyDown:Ae(o.onKeyDown,j=>{const T=x.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&b(j.key),!(T&&j.key===" ")&&lM.includes(j.key)&&(k(),j.preventDefault())})})})});Rw.displayName=Mw;var Dw="SelectValue",Ow=S.forwardRef((e,r)=>{const{__scopeSelect:a,className:l,style:o,children:c,placeholder:d="",...f}=e,h=xl(Dw,a),{onValueNodeHasChildrenChange:m}=h,v=c!==void 0,x=ft(r,h.onValueNodeChange);return Nn(()=>{m(v)},[m,v]),s.jsx(Ge.span,{...f,ref:x,style:{pointerEvents:"none"},children:Jw(h.value)?s.jsx(s.Fragment,{children:d}):c})});Ow.displayName=Dw;var dM="SelectIcon",zw=S.forwardRef((e,r)=>{const{__scopeSelect:a,children:l,...o}=e;return s.jsx(Ge.span,{"aria-hidden":!0,...o,ref:r,children:l||"▼"})});zw.displayName=dM;var fM="SelectPortal",Lw=e=>s.jsx(Nc,{asChild:!0,...e});Lw.displayName=fM;var Xl="SelectContent",Uw=S.forwardRef((e,r)=>{const a=xl(Xl,e.__scopeSelect),[l,o]=S.useState();if(Nn(()=>{o(new DocumentFragment)},[]),!a.open){const c=l;return c?vo.createPortal(s.jsx(Bw,{scope:e.__scopeSelect,children:s.jsx(Uc.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),c):null}return s.jsx(Iw,{...e,ref:r})});Uw.displayName=Xl;var yr=10,[Bw,vl]=ts(Xl),hM="SelectContentImpl",Iw=S.forwardRef((e,r)=>{const{__scopeSelect:a,position:l="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:c,onPointerDownOutside:d,side:f,sideOffset:h,align:m,alignOffset:v,arrowPadding:x,collisionBoundary:b,collisionPadding:y,sticky:k,hideWhenDetached:j,avoidCollisions:T,...C}=e,R=xl(Xl,a),[D,I]=S.useState(null),[O,E]=S.useState(null),N=ft(r,re=>I(re)),[L,X]=S.useState(null),[H,P]=S.useState(null),K=Bc(a),[ue,le]=S.useState(!1),W=S.useRef(!1);S.useEffect(()=>{if(D)return Gm(D)},[D]),Vm();const B=S.useCallback(re=>{const[ye,...fe]=K().map(Se=>Se.ref.current),[we]=fe.slice(-1),Ee=document.activeElement;for(const Se of re)if(Se===Ee||(Se==null||Se.scrollIntoView({block:"nearest"}),Se===ye&&O&&(O.scrollTop=0),Se===we&&O&&(O.scrollTop=O.scrollHeight),Se==null||Se.focus(),document.activeElement!==Ee))return},[K,O]),F=S.useCallback(()=>B([L,D]),[B,L,D]);S.useEffect(()=>{ue&&F()},[ue,F]);const{onOpenChange:ae,triggerPointerDownPosRef:Z}=R;S.useEffect(()=>{if(D){let re={x:0,y:0};const ye=we=>{var Ee,Se;re={x:Math.abs(Math.round(we.pageX)-(((Ee=Z.current)==null?void 0:Ee.x)??0)),y:Math.abs(Math.round(we.pageY)-(((Se=Z.current)==null?void 0:Se.y)??0))}},fe=we=>{re.x<=10&&re.y<=10?we.preventDefault():D.contains(we.target)||ae(!1),document.removeEventListener("pointermove",ye),Z.current=null};return Z.current!==null&&(document.addEventListener("pointermove",ye),document.addEventListener("pointerup",fe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ye),document.removeEventListener("pointerup",fe,{capture:!0})}}},[D,ae,Z]),S.useEffect(()=>{const re=()=>ae(!1);return window.addEventListener("blur",re),window.addEventListener("resize",re),()=>{window.removeEventListener("blur",re),window.removeEventListener("resize",re)}},[ae]);const[A,U]=eS(re=>{const ye=K().filter(Ee=>!Ee.disabled),fe=ye.find(Ee=>Ee.ref.current===document.activeElement),we=tS(ye,re,fe);we&&setTimeout(()=>we.ref.current.focus())}),V=S.useCallback((re,ye,fe)=>{const we=!W.current&&!fe;(R.value!==void 0&&R.value===ye||we)&&(X(re),we&&(W.current=!0))},[R.value]),M=S.useCallback(()=>D==null?void 0:D.focus(),[D]),se=S.useCallback((re,ye,fe)=>{const we=!W.current&&!fe;(R.value!==void 0&&R.value===ye||we)&&P(re)},[R.value]),Y=l==="popper"?pm:qw,ce=Y===pm?{side:f,sideOffset:h,align:m,alignOffset:v,arrowPadding:x,collisionBoundary:b,collisionPadding:y,sticky:k,hideWhenDetached:j,avoidCollisions:T}:{};return s.jsx(Bw,{scope:a,content:D,viewport:O,onViewportChange:E,itemRefCallback:V,selectedItem:L,onItemLeave:M,itemTextRefCallback:se,focusSelectedItem:F,selectedItemText:H,position:l,isPositioned:ue,searchRef:A,children:s.jsx(Tc,{as:xa,allowPinchZoom:!0,children:s.jsx(Cc,{asChild:!0,trapped:R.open,onMountAutoFocus:re=>{re.preventDefault()},onUnmountAutoFocus:Ae(o,re=>{var ye;(ye=R.trigger)==null||ye.focus({preventScroll:!0}),re.preventDefault()}),children:s.jsx(kc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:re=>re.preventDefault(),onDismiss:()=>R.onOpenChange(!1),children:s.jsx(Y,{role:"listbox",id:R.contentId,"data-state":R.open?"open":"closed",dir:R.dir,onContextMenu:re=>re.preventDefault(),...C,...ce,onPlaced:()=>le(!0),ref:N,style:{display:"flex",flexDirection:"column",outline:"none",...C.style},onKeyDown:Ae(C.onKeyDown,re=>{const ye=re.ctrlKey||re.altKey||re.metaKey;if(re.key==="Tab"&&re.preventDefault(),!ye&&re.key.length===1&&U(re.key),["ArrowUp","ArrowDown","Home","End"].includes(re.key)){let we=K().filter(Ee=>!Ee.disabled).map(Ee=>Ee.ref.current);if(["ArrowUp","End"].includes(re.key)&&(we=we.slice().reverse()),["ArrowUp","ArrowDown"].includes(re.key)){const Ee=re.target,Se=we.indexOf(Ee);we=we.slice(Se+1)}setTimeout(()=>B(we)),re.preventDefault()}})})})})})})});Iw.displayName=hM;var mM="SelectItemAlignedPosition",qw=S.forwardRef((e,r)=>{const{__scopeSelect:a,onPlaced:l,...o}=e,c=xl(Xl,a),d=vl(Xl,a),[f,h]=S.useState(null),[m,v]=S.useState(null),x=ft(r,N=>v(N)),b=Bc(a),y=S.useRef(!1),k=S.useRef(!0),{viewport:j,selectedItem:T,selectedItemText:C,focusSelectedItem:R}=d,D=S.useCallback(()=>{if(c.trigger&&c.valueNode&&f&&m&&j&&T&&C){const N=c.trigger.getBoundingClientRect(),L=m.getBoundingClientRect(),X=c.valueNode.getBoundingClientRect(),H=C.getBoundingClientRect();if(c.dir!=="rtl"){const Ee=H.left-L.left,Se=X.left-Ee,Ie=N.left-Se,Be=N.width+Ie,Mt=Math.max(Be,L.width),Nt=window.innerWidth-yr,Et=vb(Se,[yr,Math.max(yr,Nt-Mt)]);f.style.minWidth=Be+"px",f.style.left=Et+"px"}else{const Ee=L.right-H.right,Se=window.innerWidth-X.right-Ee,Ie=window.innerWidth-N.right-Se,Be=N.width+Ie,Mt=Math.max(Be,L.width),Nt=window.innerWidth-yr,Et=vb(Se,[yr,Math.max(yr,Nt-Mt)]);f.style.minWidth=Be+"px",f.style.right=Et+"px"}const P=b(),K=window.innerHeight-yr*2,ue=j.scrollHeight,le=window.getComputedStyle(m),W=parseInt(le.borderTopWidth,10),B=parseInt(le.paddingTop,10),F=parseInt(le.borderBottomWidth,10),ae=parseInt(le.paddingBottom,10),Z=W+B+ue+ae+F,A=Math.min(T.offsetHeight*5,Z),U=window.getComputedStyle(j),V=parseInt(U.paddingTop,10),M=parseInt(U.paddingBottom,10),se=N.top+N.height/2-yr,Y=K-se,ce=T.offsetHeight/2,re=T.offsetTop+ce,ye=W+B+re,fe=Z-ye;if(ye<=se){const Ee=P.length>0&&T===P[P.length-1].ref.current;f.style.bottom="0px";const Se=m.clientHeight-j.offsetTop-j.offsetHeight,Ie=Math.max(Y,ce+(Ee?M:0)+Se+F),Be=ye+Ie;f.style.height=Be+"px"}else{const Ee=P.length>0&&T===P[0].ref.current;f.style.top="0px";const Ie=Math.max(se,W+j.offsetTop+(Ee?V:0)+ce)+fe;f.style.height=Ie+"px",j.scrollTop=ye-se+j.offsetTop}f.style.margin=`${yr}px 0`,f.style.minHeight=A+"px",f.style.maxHeight=K+"px",l==null||l(),requestAnimationFrame(()=>y.current=!0)}},[b,c.trigger,c.valueNode,f,m,j,T,C,c.dir,l]);Nn(()=>D(),[D]);const[I,O]=S.useState();Nn(()=>{m&&O(window.getComputedStyle(m).zIndex)},[m]);const E=S.useCallback(N=>{N&&k.current===!0&&(D(),R==null||R(),k.current=!1)},[D,R]);return s.jsx(gM,{scope:a,contentWrapper:f,shouldExpandOnScrollRef:y,onScrollButtonChange:E,children:s.jsx("div",{ref:h,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:s.jsx(Ge.div,{...o,ref:x,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});qw.displayName=mM;var pM="SelectPopperPosition",pm=S.forwardRef((e,r)=>{const{__scopeSelect:a,align:l="start",collisionPadding:o=yr,...c}=e,d=Ic(a);return s.jsx(Ew,{...d,...c,ref:r,align:l,collisionPadding:o,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});pm.displayName=pM;var[gM,up]=ts(Xl,{}),gm="SelectViewport",Hw=S.forwardRef((e,r)=>{const{__scopeSelect:a,nonce:l,...o}=e,c=vl(gm,a),d=up(gm,a),f=ft(r,c.onViewportChange),h=S.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),s.jsx(Uc.Slot,{scope:a,children:s.jsx(Ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:f,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Ae(o.onScroll,m=>{const v=m.currentTarget,{contentWrapper:x,shouldExpandOnScrollRef:b}=d;if(b!=null&&b.current&&x){const y=Math.abs(h.current-v.scrollTop);if(y>0){const k=window.innerHeight-yr*2,j=parseFloat(x.style.minHeight),T=parseFloat(x.style.height),C=Math.max(j,T);if(C0?I:0,x.style.justifyContent="flex-end")}}}h.current=v.scrollTop})})})]})});Hw.displayName=gm;var Pw="SelectGroup",[xM,vM]=ts(Pw),yM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e,o=Br();return s.jsx(xM,{scope:a,id:o,children:s.jsx(Ge.div,{role:"group","aria-labelledby":o,...l,ref:r})})});yM.displayName=Pw;var $w="SelectLabel",bM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e,o=vM($w,a);return s.jsx(Ge.div,{id:o.id,...l,ref:r})});bM.displayName=$w;var hc="SelectItem",[wM,Fw]=ts(hc),Vw=S.forwardRef((e,r)=>{const{__scopeSelect:a,value:l,disabled:o=!1,textValue:c,...d}=e,f=xl(hc,a),h=vl(hc,a),m=f.value===l,[v,x]=S.useState(c??""),[b,y]=S.useState(!1),k=ft(r,R=>{var D;return(D=h.itemRefCallback)==null?void 0:D.call(h,R,l,o)}),j=Br(),T=S.useRef("touch"),C=()=>{o||(f.onValueChange(l),f.onOpenChange(!1))};if(l==="")throw new Error("A must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(wM,{scope:a,value:l,disabled:o,textId:j,isSelected:m,onItemTextChange:S.useCallback(R=>{x(D=>D||((R==null?void 0:R.textContent)??"").trim())},[]),children:s.jsx(Uc.ItemSlot,{scope:a,value:l,disabled:o,textValue:v,children:s.jsx(Ge.div,{role:"option","aria-labelledby":j,"data-highlighted":b?"":void 0,"aria-selected":m&&b,"data-state":m?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...d,ref:k,onFocus:Ae(d.onFocus,()=>y(!0)),onBlur:Ae(d.onBlur,()=>y(!1)),onClick:Ae(d.onClick,()=>{T.current!=="mouse"&&C()}),onPointerUp:Ae(d.onPointerUp,()=>{T.current==="mouse"&&C()}),onPointerDown:Ae(d.onPointerDown,R=>{T.current=R.pointerType}),onPointerMove:Ae(d.onPointerMove,R=>{var D;T.current=R.pointerType,o?(D=h.onItemLeave)==null||D.call(h):T.current==="mouse"&&R.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ae(d.onPointerLeave,R=>{var D;R.currentTarget===document.activeElement&&((D=h.onItemLeave)==null||D.call(h))}),onKeyDown:Ae(d.onKeyDown,R=>{var I;((I=h.searchRef)==null?void 0:I.current)!==""&&R.key===" "||(iM.includes(R.key)&&C(),R.key===" "&&R.preventDefault())})})})})});Vw.displayName=hc;var to="SelectItemText",Gw=S.forwardRef((e,r)=>{const{__scopeSelect:a,className:l,style:o,...c}=e,d=xl(to,a),f=vl(to,a),h=Fw(to,a),m=cM(to,a),[v,x]=S.useState(null),b=ft(r,C=>x(C),h.onItemTextChange,C=>{var R;return(R=f.itemTextRefCallback)==null?void 0:R.call(f,C,h.value,h.disabled)}),y=v==null?void 0:v.textContent,k=S.useMemo(()=>s.jsx("option",{value:h.value,disabled:h.disabled,children:y},h.value),[h.disabled,h.value,y]),{onNativeOptionAdd:j,onNativeOptionRemove:T}=m;return Nn(()=>(j(k),()=>T(k)),[j,T,k]),s.jsxs(s.Fragment,{children:[s.jsx(Ge.span,{id:h.textId,...c,ref:b}),h.isSelected&&d.valueNode&&!d.valueNodeHasChildren?vo.createPortal(c.children,d.valueNode):null]})});Gw.displayName=to;var Yw="SelectItemIndicator",Xw=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e;return Fw(Yw,a).isSelected?s.jsx(Ge.span,{"aria-hidden":!0,...l,ref:r}):null});Xw.displayName=Yw;var xm="SelectScrollUpButton",Kw=S.forwardRef((e,r)=>{const a=vl(xm,e.__scopeSelect),l=up(xm,e.__scopeSelect),[o,c]=S.useState(!1),d=ft(r,l.onScrollButtonChange);return Nn(()=>{if(a.viewport&&a.isPositioned){let f=function(){const m=h.scrollTop>0;c(m)};const h=a.viewport;return f(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[a.viewport,a.isPositioned]),o?s.jsx(Zw,{...e,ref:d,onAutoScroll:()=>{const{viewport:f,selectedItem:h}=a;f&&h&&(f.scrollTop=f.scrollTop-h.offsetHeight)}}):null});Kw.displayName=xm;var vm="SelectScrollDownButton",Qw=S.forwardRef((e,r)=>{const a=vl(vm,e.__scopeSelect),l=up(vm,e.__scopeSelect),[o,c]=S.useState(!1),d=ft(r,l.onScrollButtonChange);return Nn(()=>{if(a.viewport&&a.isPositioned){let f=function(){const m=h.scrollHeight-h.clientHeight,v=Math.ceil(h.scrollTop)h.removeEventListener("scroll",f)}},[a.viewport,a.isPositioned]),o?s.jsx(Zw,{...e,ref:d,onAutoScroll:()=>{const{viewport:f,selectedItem:h}=a;f&&h&&(f.scrollTop=f.scrollTop+h.offsetHeight)}}):null});Qw.displayName=vm;var Zw=S.forwardRef((e,r)=>{const{__scopeSelect:a,onAutoScroll:l,...o}=e,c=vl("SelectScrollButton",a),d=S.useRef(null),f=Bc(a),h=S.useCallback(()=>{d.current!==null&&(window.clearInterval(d.current),d.current=null)},[]);return S.useEffect(()=>()=>h(),[h]),Nn(()=>{var v;const m=f().find(x=>x.ref.current===document.activeElement);(v=m==null?void 0:m.ref.current)==null||v.scrollIntoView({block:"nearest"})},[f]),s.jsx(Ge.div,{"aria-hidden":!0,...o,ref:r,style:{flexShrink:0,...o.style},onPointerDown:Ae(o.onPointerDown,()=>{d.current===null&&(d.current=window.setInterval(l,50))}),onPointerMove:Ae(o.onPointerMove,()=>{var m;(m=c.onItemLeave)==null||m.call(c),d.current===null&&(d.current=window.setInterval(l,50))}),onPointerLeave:Ae(o.onPointerLeave,()=>{h()})})}),SM="SelectSeparator",jM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e;return s.jsx(Ge.div,{"aria-hidden":!0,...l,ref:r})});jM.displayName=SM;var ym="SelectArrow",kM=S.forwardRef((e,r)=>{const{__scopeSelect:a,...l}=e,o=Ic(a),c=xl(ym,a),d=vl(ym,a);return c.open&&d.position==="popper"?s.jsx(Tw,{...o,...l,ref:r}):null});kM.displayName=ym;function Jw(e){return e===""||e===void 0}var Ww=S.forwardRef((e,r)=>{const{value:a,...l}=e,o=S.useRef(null),c=ft(r,o),d=op(a);return S.useEffect(()=>{const f=o.current,h=window.HTMLSelectElement.prototype,v=Object.getOwnPropertyDescriptor(h,"value").set;if(d!==a&&v){const x=new Event("change",{bubbles:!0});v.call(f,a),f.dispatchEvent(x)}},[d,a]),s.jsx(Aw,{asChild:!0,children:s.jsx("select",{...l,ref:c,defaultValue:a})})});Ww.displayName="BubbleSelect";function eS(e){const r=fr(e),a=S.useRef(""),l=S.useRef(0),o=S.useCallback(d=>{const f=a.current+d;r(f),(function h(m){a.current=m,window.clearTimeout(l.current),m!==""&&(l.current=window.setTimeout(()=>h(""),1e3))})(f)},[r]),c=S.useCallback(()=>{a.current="",window.clearTimeout(l.current)},[]);return S.useEffect(()=>()=>window.clearTimeout(l.current),[]),[a,o,c]}function tS(e,r,a){const o=r.length>1&&Array.from(r).every(m=>m===r[0])?r[0]:r,c=a?e.indexOf(a):-1;let d=CM(e,Math.max(c,0));o.length===1&&(d=d.filter(m=>m!==a));const h=d.find(m=>m.textValue.toLowerCase().startsWith(o.toLowerCase()));return h!==a?h:void 0}function CM(e,r){return e.map((a,l)=>e[(r+l)%e.length])}var NM=_w,EM=Rw,TM=Ow,AM=zw,_M=Lw,MM=Uw,RM=Hw,DM=Vw,OM=Gw,zM=Xw,LM=Kw,UM=Qw;function Hr({...e}){return s.jsx(NM,{"data-slot":"select",...e})}function Pr({...e}){return s.jsx(TM,{"data-slot":"select-value",...e})}function $r({className:e,size:r="default",children:a,...l}){return s.jsxs(EM,{"data-slot":"select-trigger","data-size":r,className:Ne("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...l,children:[a,s.jsx(AM,{asChild:!0,children:s.jsx(Ji,{className:"size-4 opacity-50"})})]})}function Fr({className:e,children:r,position:a="popper",...l}){return s.jsx(_M,{children:s.jsxs(MM,{"data-slot":"select-content",className:Ne("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,...l,children:[s.jsx(BM,{}),s.jsx(RM,{className:Ne("p-1",a==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),s.jsx(IM,{})]})})}function wr({className:e,children:r,...a}){return s.jsxs(DM,{"data-slot":"select-item",className:Ne("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...a,children:[s.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:s.jsx(zM,{children:s.jsx(jc,{className:"size-4"})})}),s.jsx(OM,{children:r})]})}function BM({className:e,...r}){return s.jsx(LM,{"data-slot":"select-scroll-up-button",className:Ne("flex cursor-default items-center justify-center py-1",e),...r,children:s.jsx(WN,{className:"size-4"})})}function IM({className:e,...r}){return s.jsx(UM,{"data-slot":"select-scroll-down-button",className:Ne("flex cursor-default items-center justify-center py-1",e),...r,children:s.jsx(Ji,{className:"size-4"})})}const Ah="all";function Lt({label:e,value:r,onChange:a,options:l,allLabel:o}){const c=l.map(d=>typeof d=="string"?{value:d,label:d}:d);return s.jsxs("div",{className:"relative",children:[s.jsxs(Hr,{value:r||Ah,onValueChange:d=>a(d===Ah?"":d),children:[s.jsx($r,{className:"w-44","aria-label":e,children:s.jsx(Pr,{className:r?"pr-6":void 0})}),s.jsxs(Fr,{children:[s.jsx(wr,{value:Ah,children:o}),c.map(d=>s.jsx(wr,{value:d.value,children:d.label},d.value))]})]}),r&&s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Clear ${e.toLowerCase()} filter`,title:`Clear ${e.toLowerCase()} filter`,className:"absolute top-1/2 right-8 size-6 -translate-y-1/2",onClick:()=>a(""),children:s.jsx(Fm,{className:"size-3.5"})})]})}function qM({rows:e,withPrincipal:r}){return s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[r&&s.jsx(ge,{children:"User"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{children:"Endpoint"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Cost"})]})}),s.jsxs(vn,{children:[e.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:r?8:7,className:"text-muted-foreground",children:"No usage recorded yet."})}),e.map((a,l)=>s.jsxs(Oe,{children:[r&&s.jsx(de,{className:"wrap-anywhere",children:a.principal}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:a.model}),s.jsx(de,{children:a.endpoint}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(a.requests)}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(a.units.input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(a.units.cached_input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(a.units.output_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:a.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):Bm(a.cost)})]},l))]})]})}const _h=[{key:"24h",label:"Last 24 hours",bucket:"hour",count:24},{key:"7d",label:"Last 7 days",bucket:"day",count:7},{key:"30d",label:"Last 30 days",bucket:"day",count:30},{key:"12w",label:"Last 12 weeks",bucket:"week",count:12},{key:"12mo",label:"Last 12 months",bucket:"month",count:12},{key:"all",label:"All time",bucket:"month",count:0}];function HM(e,r){const a=new Date(e);return a.setUTCMilliseconds(0),a.setUTCSeconds(0),a.setUTCMinutes(0),r==="hour"?a:(a.setUTCHours(0),r==="month"?(a.setUTCDate(1),a):(r==="week"&&a.setUTCDate(a.getUTCDate()-(a.getUTCDay()+6)%7),a))}function Ab(e,r,a){const l=new Date(e);return r==="hour"?l.setUTCHours(l.getUTCHours()+a):r==="day"?l.setUTCDate(l.getUTCDate()+a):r==="week"?l.setUTCDate(l.getUTCDate()+a*7):l.setUTCMonth(l.getUTCMonth()+a),l}const Za={timeZone:"UTC"};function PM(e,r){const a=new Date(e);return r==="hour"?a.toLocaleTimeString(void 0,{...Za,hour:"2-digit",minute:"2-digit"}):r==="month"?a.toLocaleDateString(void 0,{...Za,month:"short",year:"2-digit"}):a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric"})}function $M(e,r){const a=new Date(e);switch(r){case"hour":return`${a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric"})}, ${a.toLocaleTimeString(void 0,{...Za,hour:"2-digit",minute:"2-digit"})} UTC`;case"week":return`Week of ${a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric",year:"numeric"})}`;case"month":return a.toLocaleDateString(void 0,{...Za,month:"long",year:"numeric"});default:return a.toLocaleDateString(void 0,{...Za,month:"short",day:"numeric",year:"numeric"})}}function Rr(e,r){return e.reduce((a,l)=>a+r(l),0)}function Ku(e,r,a){return!a||r===0?null:(e-r)/r}function fa(e){return(e.units.input_tokens??0)+(e.units.output_tokens??0)}function Mh(e,r,a){const l=new Map;for(const o of e){const c=r(o);let d=l.get(c);d||(d=a(o),l.set(c,d)),d.requests+=o.requests,d.cancelled+=o.cancelled,o.cost!==null&&(d.cost=(d.cost??0)+o.cost);for(const[f,h]of Object.entries(o.units))d.units[f]=(d.units[f]??0)+h}return l}function nS(e){const r={requests:0,cost:null,units:{}};for(const a of e){r.requests+=a.requests,a.cost!==null&&(r.cost=(r.cost??0)+a.cost);for(const[l,o]of Object.entries(a.units))r.units[l]=(r.units[l]??0)+o}return r}function _b(e,r,a){const l=(o,c)=>({label:c??o.principal??"",value:r(o),rows:a(o)});return Ac(e,o=>l(o),o=>l(nS(o),`Other (${o.length} users)`))}function FM({ssoEnabled:e}){var ne;const[r,a]=Vt("range","30d"),[l,o]=Vt("user"),[c,d]=Vt("provider"),[f,h]=Vt("model"),[m,v]=Vt("client"),[x,b]=S.useState(!1),[y,k]=S.useState(!1),[j,T]=S.useState(!1),C=_h.find(z=>z.key===r)??_h[2],D=HM(new Date,C.bucket),I=C.count?Ab(D,C.bucket,-(C.count-1)):null,O=I?Ab(I,C.bucket,-C.count):null,E=(l?`&principal=${encodeURIComponent(l)}`:"")+(c?`&provider=${encodeURIComponent(c)}`:"")+(f?`&model=${encodeURIComponent(f)}`:"")+(m?`&client=${encodeURIComponent(m)}`:""),N=Ut(()=>He.get(`/stats/series?bucket=${C.bucket}`+(O?`&since=${O.toISOString()}`:"")+E),[r,l,c,f,m]),L=Ut(()=>He.get("/stats/summary"+(I?`?since=${I.toISOString()}`:"")),[r]),X=((ne=N.data)==null?void 0:ne.series)??[],H=I?I.getTime():-1/0,P=X.filter(z=>new Date(z.start).getTime()>=H),K=X.filter(z=>new Date(z.start).getTime()0,le=z=>z.units.input_tokens??0,W=z=>z.units.output_tokens??0,B=z=>z.units.cached_input_tokens??0,F=Rr(P,z=>z.requests),ae=Rr(P,le),Z=Rr(P,B),A=Rr(P,W),U=Rr(P,z=>z.cost??0),V=P.some(z=>z.cost!==null),M=Rr(P,z=>z.unpriced_requests),se=z=>new Date(z.start).getTime()===D.getTime(),Y=z=>PM(z.start,C.bucket),ce=z=>$M(z.start,C.bucket)+(se(z)?" · in progress":""),re=P.map(z=>{const he=z.ok+z.cancelled,ke=[...z.cancelled?[{label:"cancelled",value:Ht(z.cancelled)}]:[],...he>0?[{label:"avg input / request",value:Re(Math.round(le(z)/he))},{label:"avg output / response",value:Re(Math.round(W(z)/he))}]:[]];return{label:Y(z),title:ce(z),values:[he,z.failed],rows:ke.length?ke:void 0}}),ye=P.map(z=>({label:Y(z),title:ce(z),values:[le(z),B(z),W(z)]})),fe=P.map(z=>({label:Y(z),title:ce(z),values:[z.cost],rows:z.unpriced_requests?[{label:"unpriced requests",value:Ht(z.unpriced_requests)}]:void 0})),we=S.useMemo(()=>{var z;return((z=L.data)==null?void 0:z.usage)??[]},[L.data]),Ee=S.useMemo(()=>({principals:[...new Set(we.map(z=>z.principal))].sort(),providers:[...new Set(we.map(z=>z.provider))].sort(),models:[...new Set(we.filter(z=>z.model).map(z=>z.model))].sort(),clients:[...new Set(we.filter(z=>z.client).map(z=>ao(z.client)))].sort()}),[we]),Se=S.useMemo(()=>we.filter(z=>(!l||z.principal===l)&&(!c||z.provider===c)&&(!f||z.model===f)&&(!m||ao(z.client)===m)),[we,l,c,f,m]),Ie=S.useMemo(()=>[...Mh(Se,z=>z.model,z=>({model:z.model,requests:0,cancelled:0,cost:null,units:{}})).values()].sort((z,he)=>fa(he)-fa(z)),[Se]),Be=Ie.reduce((z,he)=>z+fa(he),0),{slices:Mt,overflow:Nt}=S.useMemo(()=>{const z=(he,ke)=>({label:ke??(he.model||"(none)"),value:fa(he),rows:[{label:"requests",value:Ht(he.requests)},...he.units.cached_input_tokens?[{label:"cached input",value:Re(he.units.cached_input_tokens)}]:[],...he.cost!==null?[{label:"cost",value:zr(he.cost)}]:[]]});return Ac(Ie,he=>z(he),he=>z(nS(he),`Other (${he.length} models)`))},[Ie]),Et=S.useMemo(()=>[...Mh(Se,z=>z.principal,z=>({principal:z.principal,requests:0,cancelled:0,cost:null,units:{}})).values()],[Se]),Bt=S.useMemo(()=>_b([...Et].sort((z,he)=>fa(he)-fa(z)),fa,z=>[{label:"requests",value:Ht(z.requests)},...z.units.cached_input_tokens?[{label:"cached input",value:Re(z.units.cached_input_tokens)}]:[],...z.cost!==null?[{label:"cost",value:zr(z.cost)}]:[]]),[Et]),Rt=S.useMemo(()=>_b(Et.filter(z=>z.cost!==null).sort((z,he)=>(he.cost??0)-(z.cost??0)),z=>z.cost??0,z=>[{label:"tokens",value:Re(fa(z))},{label:"requests",value:Ht(z.requests)}]),[Et]),Dt=S.useMemo(()=>{const z=new Map;for(const he of Se){const ke=he.client?j?K2(he.client):ao(he.client):"unknown";let ze=z.get(ke);ze||(ze={label:ke,requests:0,cancelled:0,cost:null,units:{},exact:new Set},z.set(ke,ze)),ze.requests+=he.requests,ze.cancelled+=he.cancelled,he.cost!==null&&(ze.cost=(ze.cost??0)+he.cost);for(const[an,Tn]of Object.entries(he.units))ze.units[an]=(ze.units[an]??0)+Tn;he.client&&ze.exact.add(he.client)}return[...z.values()].sort((he,ke)=>ke.requests-he.requests)},[Se,j]),zt=Dt.reduce((z,he)=>z+he.requests,0),be=S.useMemo(()=>Dt.map(z=>({label:z.label,title:z.exact.size?[...z.exact].sort().join(` -`):"no User-Agent header",value:z.requests})),[Dt]),mt=S.useMemo(()=>[...Mh(Se,he=>`${he.principal}\0${he.model}\0${he.endpoint}`,he=>({principal:he.principal,model:he.model,endpoint:he.endpoint,requests:0,cancelled:0,cost:null,units:{}})).values()].sort((he,ke)=>he.principal!==ke.principal?he.principal.localeCompare(ke.principal):he.model!==ke.model?he.model.localeCompare(ke.model):he.endpoint.localeCompare(ke.endpoint)),[Se]),Q=N.loading&&!N.data||L.loading&&!L.data,Pe=!Q&&(N.loading||L.loading);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Hr,{value:r,onValueChange:a,children:[s.jsx($r,{className:"w-44","aria-label":"Time range",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:_h.map(z=>s.jsx(wr,{value:z.key,children:z.label},z.key))})]}),s.jsx(Lt,{label:"User",value:l,onChange:o,options:Ee.principals,allLabel:"All users"}),s.jsx(Lt,{label:"Provider",value:c,onChange:d,options:Ee.providers,allLabel:"All providers"}),s.jsx(Lt,{label:"Model",value:f,onChange:h,options:Ee.models,allLabel:"All models"}),s.jsx(Lt,{label:"Client",value:m,onChange:v,options:Ee.clients,allLabel:"All clients"}),(l||c||f||m)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{o(""),d(""),h(""),v("")},children:[s.jsx(yo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>{N.reload(),L.reload()},children:s.jsx(pl,{})})]}),Q?s.jsx(kt,{}):N.error||L.error?s.jsx("p",{className:"text-sm text-destructive",children:N.error??L.error}):s.jsxs("div",{className:Pe?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Qn,{label:"Requests",value:Re(F),delta:Ku(F,Rr(K,z=>z.requests),ue)}),s.jsx(Qn,{label:"Input tokens",value:Re(ae),secondary:Z>0?`${Re(Z)} cached`:void 0,delta:Ku(ae,Rr(K,le),ue)}),s.jsx(Qn,{label:"Output tokens",value:Re(A),delta:Ku(A,Rr(K,W),ue)}),s.jsx(Qn,{label:"Cost",value:V?zr(U):"unpriced",delta:V?Ku(U,Rr(K,z=>z.cost??0),ue):null,hint:M?`${Ht(M)} request${M===1?"":"s"} unpriced`:void 0})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Ke,{className:x?"min-w-0 lg:col-span-2":"min-w-0",children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Models"}),s.jsx(it,{children:"Share of total tokens, cached input excluded."})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":x?"Show chart":"Show all models as a table",title:x?"Show chart":"Show all models as a table",onClick:()=>b(z=>!z),children:x?s.jsx(ZN,{}):s.jsx(om,{})})]}),s.jsx(Qe,{children:x?s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Share"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Cost"})]})}),s.jsxs(vn,{children:[Ie.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No usage in this range."})}),Ie.map((z,he)=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:z.model||s.jsx("span",{className:"text-muted-foreground",children:"(none)"})}),s.jsx(de,{className:"text-right tabular-nums",children:Be>0?`${(fa(z)/Be*100).toFixed(1)}%`:""}),s.jsx(de,{className:"text-right tabular-nums",children:Re(z.requests)}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(z.units.input_tokens),children:z.units.input_tokens?Re(z.units.input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(z.units.cached_input_tokens),children:z.units.cached_input_tokens?Re(z.units.cached_input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(z.units.output_tokens),children:z.units.output_tokens?Re(z.units.output_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:z.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):zr(z.cost)})]},he))]})]}):s.jsx(lo,{slices:Mt,overflow:Nt,format:Re},`${r} ${l} ${c} ${f} ${m}`)})]}),s.jsxs(Ke,{className:y?"min-w-0 lg:col-span-2":"min-w-0",children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Clients"}),s.jsx(it,{children:j?"Requests per client version, from the User-Agent.":"Requests per client, from the User-Agent."})]}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Me,{variant:j?"secondary":"outline",size:"icon-sm","aria-label":j?"Group by tool":"Split by version","aria-pressed":j,title:j?"Group by tool":"Split by version",onClick:()=>T(z=>!z),children:s.jsx(cE,{})}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":y?"Show chart":"Show all clients as a table",title:y?"Show chart":"Show all clients as a table",onClick:()=>k(z=>!z),children:y?s.jsx(u1,{}):s.jsx(om,{})})]})]}),s.jsx(Qe,{children:y?s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Client"}),s.jsx(ge,{className:"text-right",children:"Share"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Cost"})]})}),s.jsxs(vn,{children:[Dt.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No usage in this range."})}),Dt.map((z,he)=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",title:z.exact.size?[...z.exact].sort().join(` -`):void 0,children:z.label}),s.jsx(de,{className:"text-right tabular-nums",children:zt>0?`${(z.requests/zt*100).toFixed(1)}%`:""}),s.jsx(de,{className:"text-right tabular-nums",children:Re(z.requests)}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(z.units.input_tokens),children:z.units.input_tokens?Re(z.units.input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(z.units.cached_input_tokens),children:z.units.cached_input_tokens?Re(z.units.cached_input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(z.units.output_tokens),children:z.units.output_tokens?Re(z.units.output_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:z.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):zr(z.cost)})]},he))]})]}):s.jsx(Ki,{rows:be,format:Re})})]}),e&&s.jsxs(s.Fragment,{children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"User tokens"}),s.jsx(it,{children:"Share of total tokens per user, cached input excluded."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:Bt.slices,overflow:Bt.overflow,format:Re},`${r} ${l} ${c} ${f} ${m}`)})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"User cost"}),s.jsx(it,{children:"Share of total cost per user."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:Rt.slices,overflow:Rt.overflow,format:zr,emptyMessage:"Nothing priced in this range."},`${r} ${l} ${c} ${f} ${m}`)})]})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Tokens"}),s.jsxs(it,{children:["Input, cached input and output per ",C.bucket,"."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:ye,series:[{...ma,name:"input"},{...Zm,name:"cached"},{...Vl,name:"output"}],format:Re})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Requests"}),s.jsxs(it,{children:["Per ",C.bucket,", split by outcome."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:re,series:[{...ma,name:"ok"},{...Vl,name:"failed"}],format:Re,integer:!0})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Cost"}),s.jsxs(it,{children:["Per ",C.bucket,", from the model prices; unpriced stays empty, never zero."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:fe,series:[{...ma,name:"cost"}],format:z=>zr(z),emptyMessage:"Nothing priced in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:l?"By model":"By user and model"}),s.jsxs(it,{children:["Totals by ",l?"":"user, ","model and endpoint."]})]}),s.jsx(Qe,{children:s.jsx(qM,{rows:mt,withPrincipal:!l})})]})]})]})}const cr=[{key:"24h",label:"Last 24 hours",bucket:"hour",count:24},{key:"7d",label:"Last 7 days",bucket:"day",count:7},{key:"30d",label:"Last 30 days",bucket:"day",count:30},{key:"12w",label:"Last 12 weeks",bucket:"week",count:12},{key:"12mo",label:"Last 12 months",bucket:"month",count:12},{key:"all",label:"All time",bucket:"month",count:0}];function qc(e,r){const a=new Date(e);return a.setUTCMilliseconds(0),a.setUTCSeconds(0),a.setUTCMinutes(0),r==="hour"?a:(a.setUTCHours(0),r==="month"?(a.setUTCDate(1),a):(r==="week"&&a.setUTCDate(a.getUTCDate()-(a.getUTCDay()+6)%7),a))}function ho(e,r,a){const l=new Date(e);return r==="hour"?l.setUTCHours(l.getUTCHours()+a):r==="day"?l.setUTCDate(l.getUTCDate()+a):r==="week"?l.setUTCDate(l.getUTCDate()+a*7):l.setUTCMonth(l.getUTCMonth()+a),l}const Ja={timeZone:"UTC"};function cp(e,r){const a=new Date(e);return r==="hour"?a.toLocaleTimeString(void 0,{...Ja,hour:"2-digit",minute:"2-digit"}):r==="month"?a.toLocaleDateString(void 0,{...Ja,month:"short",year:"2-digit"}):a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric"})}function dp(e,r){const a=new Date(e);switch(r){case"hour":return`${a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric"})}, ${a.toLocaleTimeString(void 0,{...Ja,hour:"2-digit",minute:"2-digit"})} UTC`;case"week":return`Week of ${a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric",year:"numeric"})}`;case"month":return a.toLocaleDateString(void 0,{...Ja,month:"long",year:"numeric"});default:return a.toLocaleDateString(void 0,{...Ja,month:"short",day:"numeric",year:"numeric"})}}const rS="untagged";function Qs(){return{requests:0,cost:null,units:{}}}function VM(e,r){e.requests+=r.requests,r.cost!==null&&(e.cost=(e.cost??0)+r.cost);for(const[a,l]of Object.entries(r.units))e.units[a]=(e.units[a]??0)+l}function Qu(e,r,a){const l=new Map;for(const o of e){const c=r(o);let d=l.get(c);d||(d=a(c),l.set(c,d)),VM(d,o)}return[...l.values()]}function GM(e){return(e.units.input_tokens??0)+(e.units.output_tokens??0)}function Xa(e,r){return e.reduce((a,l)=>a+r(l),0)}function Rh(e,r,a){return!a||r===0?null:(e-r)/r}function Mb(e){return ha(e.tags,"app")||rS}function YM(e){return ha(e.tags,"context")||rS}function XM(){var mt;const[e,r]=Vt("range","30d"),[a,l]=Vt("app"),[o,c]=Vt("context"),[d,f]=Vt("user"),[h,m]=Vt("model"),[v,x]=S.useState(!1),b=cr.find(Q=>Q.key===e)??cr[2],k=qc(new Date,b.bucket),j=b.count?ho(k,b.bucket,-(b.count-1)):null,T=j?ho(j,b.bucket,-b.count):null,C="&app_tagged=1"+(a?`&tag=${encodeURIComponent(`app:${a}`)}`:"")+(o?`&tag=${encodeURIComponent(`context:${o}`)}`:"")+(d?`&principal=${encodeURIComponent(d)}`:"")+(h?`&model=${encodeURIComponent(h)}`:""),R=Ut(()=>He.get(`/stats/series?bucket=${b.bucket}`+(T?`&since=${T.toISOString()}`:"")+C),[e,a,o,d,h]),D=Ut(()=>He.get(`/stats/series?bucket=${b.bucket}`+(T?`&since=${T.toISOString()}`:"")+C+"&endpoint=embeddings"),[e,a,o,d,h]),I=Ut(()=>He.get("/stats/summary?app_tagged=1"+(j?`&since=${j.toISOString()}`:"")),[e]),O=((mt=R.data)==null?void 0:mt.series)??[],E=j?j.getTime():-1/0,N=O.filter(Q=>new Date(Q.start).getTime()>=E),L=O.filter(Q=>new Date(Q.start).getTime()0,H=S.useMemo(()=>{var Pe;const Q=new Map;for(const ne of((Pe=D.data)==null?void 0:Pe.series)??[])Q.set(ne.start,ne);return Q},[D.data]),P=Q=>Q.units.output_tokens??0,K=Q=>Q.units.cached_input_tokens??0,ue=Q=>{var Pe;return((Pe=H.get(Q.start))==null?void 0:Pe.units.input_tokens)??0},le=Q=>Math.max(0,(Q.units.input_tokens??0)-ue(Q)),W=Xa(N,Q=>Q.requests),B=Xa(N,le),F=Xa(N,P),ae=Xa(N,K),Z=B+F,A=Xa(N,ue),U=Q=>new Date(Q.start).getTime()===k.getTime(),V=Q=>cp(Q.start,b.bucket),M=Q=>dp(Q.start,b.bucket)+(U(Q)?" · in progress":""),se=N.map(Q=>({label:V(Q),title:M(Q),values:[Q.ok+Q.cancelled,Q.failed],rows:Q.cancelled?[{label:"cancelled",value:Ht(Q.cancelled)}]:void 0})),Y=N.map(Q=>({label:V(Q),title:M(Q),values:[le(Q),K(Q),P(Q)]})),ce=N.map(Q=>({label:V(Q),title:M(Q),values:[ue(Q)]})),re=S.useMemo(()=>{var Q;return((Q=I.data)==null?void 0:Q.usage)??[]},[I.data]),ye=S.useMemo(()=>[...new Set(re.map(Q=>ha(Q.tags,"app")).filter(Boolean))].sort(),[re]),fe=S.useMemo(()=>[...new Set(re.filter(Q=>!a||ha(Q.tags,"app")===a).map(Q=>ha(Q.tags,"context")).filter(Boolean))].sort(),[re,a]),we=S.useMemo(()=>[...new Set(re.map(Q=>Q.principal))].sort(),[re]),Ee=S.useMemo(()=>[...new Set(re.map(Q=>Q.model))].sort(),[re]),Se=S.useMemo(()=>re.filter(Q=>(!a||ha(Q.tags,"app")===a)&&(!o||ha(Q.tags,"context")===o)&&(!d||Q.principal===d)&&(!h||Q.model===h)),[re,a,o,d,h]),Ie=S.useMemo(()=>Qu(Se,Mb,Q=>({name:Q,...Qs()})).sort((Q,Pe)=>Pe.requests-Q.requests),[Se]),Be=Ie.reduce((Q,Pe)=>Q+Pe.requests,0),Mt=S.useMemo(()=>Ie.map(Q=>({label:Q.name,value:Q.requests})),[Ie]),Nt=S.useMemo(()=>Qu(Se,Q=>Q.principal,Q=>({name:Q,...Qs()})).sort((Q,Pe)=>Pe.requests-Q.requests),[Se]),Et=S.useMemo(()=>{const Q=(Pe,ne)=>({label:ne??Pe.name??"",value:Pe.requests,rows:[{label:"tokens",value:Re(GM(Pe))}]});return Ac(Nt,Pe=>Q(Pe),Pe=>{const ne=Qs();for(const z of Pe){ne.requests+=z.requests;for(const[he,ke]of Object.entries(z.units))ne.units[he]=(ne.units[he]??0)+ke}return Q(ne,`Other (${Pe.length} users)`)})},[Nt]),Bt=S.useMemo(()=>Qu(Se,YM,Q=>({name:Q,...Qs()})).sort((Q,Pe)=>Pe.requests-Q.requests),[Se]),Rt=S.useMemo(()=>Bt.map(Q=>({label:Q.name,value:Q.requests})),[Bt]),Dt=S.useMemo(()=>Qu(Se,Q=>`${Mb(Q)} ${Q.model}`,Q=>{const Pe=Q.indexOf(" ");return{name:Q.slice(0,Pe),model:Q.slice(Pe+1),...Qs()}}).sort((Q,Pe)=>Q.name!==Pe.name?Q.name.localeCompare(Pe.name):Q.model.localeCompare(Pe.model)),[Se]),zt=R.loading&&!R.data||I.loading&&!I.data,be=!zt&&(R.loading||I.loading||D.loading);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Hr,{value:e,onValueChange:r,children:[s.jsx($r,{className:"w-44","aria-label":"Time range",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:cr.map(Q=>s.jsx(wr,{value:Q.key,children:Q.label},Q.key))})]}),s.jsx(Lt,{label:"App",value:a,onChange:Q=>{l(Q),c("")},options:ye,allLabel:"All apps"}),a&&s.jsx(Lt,{label:"Context",value:o,onChange:c,options:fe,allLabel:"All contexts"}),s.jsx(Lt,{label:"User",value:d,onChange:f,options:we,allLabel:"All users"}),s.jsx(Lt,{label:"Model",value:h,onChange:m,options:Ee,allLabel:"All models"}),(a||o||d||h)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{l(""),c(""),f(""),m("")},children:[s.jsx(yo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>{R.reload(),I.reload(),D.reload()},children:s.jsx(pl,{})})]}),zt?s.jsx(kt,{}):R.error||I.error||D.error?s.jsx("p",{className:"text-sm text-destructive",children:R.error??I.error??D.error}):s.jsxs("div",{className:be?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[s.jsx(Qn,{label:"Requests",value:Re(W),delta:Rh(W,Xa(L,Q=>Q.requests),X)}),s.jsx(Qn,{label:"Tokens",value:Re(Z),secondary:`${Re(B)} in · ${Re(ae)} cached · ${Re(F)} out`,delta:Rh(Z,Xa(L,Q=>le(Q)+P(Q)),X)}),s.jsx(Qn,{label:"Embedding",value:Re(A),secondary:"in",delta:Rh(A,Xa(L,ue),X)})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Ke,{className:v?"min-w-0 lg:col-span-2":"min-w-0",children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Apps"}),s.jsx(it,{children:"Requests per app, from the app tag."})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":v?"Show chart":"Show all apps as a table",title:v?"Show chart":"Show all apps as a table",onClick:()=>x(Q=>!Q),children:v?s.jsx(u1,{}):s.jsx(om,{})})]}),s.jsx(Qe,{children:v?s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"App"}),s.jsx(ge,{className:"text-right",children:"Share"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Spend"})]})}),s.jsxs(vn,{children:[Ie.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No usage in this range."})}),Ie.map((Q,Pe)=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:Q.name}),s.jsx(de,{className:"text-right tabular-nums",children:Be>0?`${(Q.requests/Be*100).toFixed(1)}%`:""}),s.jsx(de,{className:"text-right tabular-nums",children:Re(Q.requests)}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(Q.units.input_tokens),children:Q.units.input_tokens?Re(Q.units.input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(Q.units.cached_input_tokens),children:Q.units.cached_input_tokens?Re(Q.units.cached_input_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(Q.units.output_tokens),children:Q.units.output_tokens?Re(Q.units.output_tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:Q.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):zr(Q.cost)})]},Pe))]})]}):s.jsx(Ki,{rows:Mt,format:Re})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Users"}),s.jsx(it,{children:"Share of requests per user."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:Et.slices,overflow:Et.overflow,format:Re,emptyMessage:"No usage in this range."},`${e} ${a} ${o} ${d} ${h}`)})]}),a&&s.jsxs(Ke,{className:"lg:col-span-2",children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Contexts"}),s.jsxs(it,{children:["Requests per context in ",a,"."]})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:Rt,format:Re})})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Tokens"}),s.jsxs(it,{children:["Chat input, cached input and output per ",b.bucket,"."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:Y,series:[{...ma,name:"input"},{...Zm,name:"cached"},{...Vl,name:"output"}],format:Re})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Embedding"}),s.jsxs(it,{children:["Input tokens on embeddings per ",b.bucket,"."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:ce,series:[{...ma,name:"input"}],format:Re,emptyMessage:"No embeddings in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Requests"}),s.jsxs(it,{children:["Per ",b.bucket,", split by outcome."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:se,series:[{...ma,name:"ok"},{...Vl,name:"failed"}],format:Re,integer:!0})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:a?"By model":"By app and model"}),s.jsxs(it,{children:["Totals by ",a?"":"app and ","model."]})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[!a&&s.jsx(ge,{children:"App"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Input"}),s.jsx(ge,{className:"text-right",children:"Cached"}),s.jsx(ge,{className:"text-right",children:"Output"}),s.jsx(ge,{className:"text-right",children:"Spend"})]})}),s.jsxs(vn,{children:[Dt.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:a?6:7,className:"text-muted-foreground",children:"No usage in this range."})}),Dt.map((Q,Pe)=>s.jsxs(Oe,{children:[!a&&s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:Q.name}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:Q.model}),s.jsx(de,{className:"text-right tabular-nums",children:Re(Q.requests)}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(Q.units.input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(Q.units.cached_input_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Ft(Q.units.output_tokens)}),s.jsx(de,{className:"text-right tabular-nums",children:Q.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):zr(Q.cost)})]},Pe))]})]})})]})]})]})}const KM=a1("inline-flex items-center justify-center rounded-md border font-medium w-fit max-w-full whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",muted:"border-transparent bg-muted text-muted-foreground [a&]:hover:bg-muted/80",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent/10 [a&]:hover:text-accent-foreground",success:"border-transparent bg-[#1a7f37] text-white [a&]:hover:bg-[#1a7f37]/90",warning:"border-transparent bg-[#9a6700] text-white [a&]:hover:bg-[#9a6700]/90",info:"border-transparent bg-[#0969da] text-white [a&]:hover:bg-[#0969da]/90",tag:"border-border bg-card text-foreground [a&]:hover:bg-muted",value:"border-transparent bg-muted text-foreground font-mono [a&]:hover:bg-muted/80",whatsapp:"border-transparent bg-[#22c55e] text-white [a&]:hover:bg-[#22c55e]/90",email:"border-transparent bg-[#4b5563] text-white [a&]:hover:bg-[#4b5563]/90",telegram:"border-transparent bg-[#3b82f6] text-white [a&]:hover:bg-[#3b82f6]/90",zulip:"border-transparent bg-[#a855f7] text-white [a&]:hover:bg-[#a855f7]/90",platform:"border-transparent bg-[#f97316] text-white [a&]:hover:bg-[#f97316]/90"},size:{sm:"text-xs px-1.5 py-0",default:"text-xs px-2 py-0.5",lg:"text-sm px-3 py-1 [&>svg]:size-3.5"}},defaultVariants:{variant:"default",size:"default"}});function pn({className:e,variant:r,size:a,asChild:l=!1,...o}){const c=l?xa:"span";return s.jsx(c,{"data-slot":"badge",className:Ne(KM({variant:r,size:a}),e),...o})}const QM=["<1s","1–5s","5–15s","15–30s","30–60s","60–120s","≥120s"],Dh=[{key:"upstream_error",name:"provider error",series:ma},{key:"unreachable",name:"unreachable",series:Zm},{key:"cancelled",name:"cancelled",series:Vl}],ZM="untagged";function fp(e){return e.outcome!=="ok"}function aS(e){return e.error_kind?e.error_kind:e.outcome==="upstream_error"&&e.status_code?`http ${e.status_code}`:e.outcome}function Oh(e,r){const a=new Map;for(const l of e){const o=r(l);let c=a.get(o);c||(c={label:o,errors:0,total:0},a.set(o,c)),c.total+=l.requests,fp(l)&&(c.errors+=l.requests)}return[...a.values()].filter(l=>l.errors>0).sort((l,o)=>o.errors-l.errors)}function zh(e){return e.map(r=>({label:r.label,value:r.errors,note:`${(r.errors/r.total*100).toFixed(1)}% of ${Re(r.total)} req`}))}function JM(e){const r=new Map;for(const a of e){if(!fp(a))continue;const l=aS(a),o=`${a.provider}\0${a.model}\0${l}\0${a.status_code??""}`;let c=r.get(o);c||(c={provider:a.provider,model:a.model,outcome:a.outcome,label:l,statusCode:a.status_code,requests:0,weightedMs:0,lastSeen:""},r.set(o,c)),c.requests+=a.requests,c.weightedMs+=a.avg_ms*a.requests,a.last_seen>c.lastSeen&&(c.lastSeen=a.last_seen)}return[...r.values()].sort((a,l)=>l.requests-a.requests)}function WM(e){const r=new URLSearchParams;return e.provider&&r.set("provider",e.provider),e.model&&r.set("model",e.model),r.set("outcome",e.outcome),"/requests?"+r.toString()}function eR(){var U,V,M,se;const[e,r]=Vt("range","7d"),[a,l]=Vt("user"),[o,c]=Vt("provider"),[d,f]=Vt("model"),[h,m]=Vt("app"),v=cr.find(Y=>Y.key===e)??cr[1],x=qc(new Date,v.bucket),b=v.count?ho(x,v.bucket,-(v.count-1)):null,y=b?`&since=${b.toISOString()}`:"",k=(a?`&principal=${encodeURIComponent(a)}`:"")+(o?`&provider=${encodeURIComponent(o)}`:"")+(d?`&model=${encodeURIComponent(d)}`:"")+(h?`&tag=${encodeURIComponent(`app:${h}`)}`:""),j=Ut(()=>He.get(`/stats/errors?bucket=${v.bucket}`+y+k),[e,a,o,d,h]),T=Ut(()=>He.get("/stats/requests/facets"+(y?"?"+y.slice(1):"")),[e]),C=((U=j.data)==null?void 0:U.series)??[],R=S.useMemo(()=>{var Y;return((Y=j.data)==null?void 0:Y.breakdown)??[]},[j.data]),D=C.reduce((Y,ce)=>Y+ce.requests,0),I=C.reduce((Y,ce)=>Y+ce.upstream_error+ce.unreachable,0),O=C.reduce((Y,ce)=>Y+ce.cancelled,0),E=Y=>D>0?`${(Y/D*100).toFixed(1)}% of requests`:void 0,N=S.useMemo(()=>R.filter(fp),[R]),L=N.reduce((Y,ce)=>Y+ce.requests,0),X=L>0?N.reduce((Y,ce)=>Y+ce.avg_ms*ce.requests,0)/L:null,H=Y=>new Date(Y).getTime()===x.getTime(),P=C.map(Y=>({label:cp(Y.start,v.bucket),title:dp(Y.start,v.bucket)+(H(Y.start)?" · in progress":""),values:[Y.upstream_error,Y.unreachable,Y.cancelled],rows:[{label:"requests total",value:Ht(Y.requests)}]})),K=QM.map((Y,ce)=>{const re=ye=>N.filter(fe=>fe.outcome===ye).reduce((fe,we)=>fe+(we.bands[ce]??0),0);return{label:Y,title:`Time to failure ${Y}`,values:Dh.map(ye=>re(ye.key))}}),ue=S.useMemo(()=>zh(Oh(R,Y=>Y.provider||"(none)")),[R]),le=S.useMemo(()=>zh(Oh(R,Y=>ha(Y.tags,"app")||ZM)),[R]),W=S.useMemo(()=>zh(Oh(R,Y=>Y.model||"(none)")),[R]),B=S.useMemo(()=>{const Y=new Map;for(const re of N){const ye=aS(re);Y.set(ye,(Y.get(ye)??0)+re.requests)}const ce=[...Y.entries()].sort((re,ye)=>ye[1]-re[1]);return Ac(ce,([re,ye])=>({label:re,value:ye}),re=>({label:`Other (${re.length} kinds)`,value:re.reduce((ye,[,fe])=>ye+fe,0)}))},[N]),F=S.useMemo(()=>JM(R).slice(0,50),[R]),ae=S.useMemo(()=>{var Y;return[...new Set((((Y=T.data)==null?void 0:Y.tags)??[]).filter(ce=>ce.startsWith("app:")).map(ce=>ce.slice(4)))].sort()},[T.data]),Z=j.loading&&!j.data,A=!Z&&j.loading;return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Hr,{value:e,onValueChange:r,children:[s.jsx($r,{className:"w-44","aria-label":"Time range",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:cr.map(Y=>s.jsx(wr,{value:Y.key,children:Y.label},Y.key))})]}),s.jsx(Lt,{label:"User",value:a,onChange:l,options:((V=T.data)==null?void 0:V.principals)??[],allLabel:"All users"}),s.jsx(Lt,{label:"Provider",value:o,onChange:c,options:((M=T.data)==null?void 0:M.providers)??[],allLabel:"All providers"}),s.jsx(Lt,{label:"Model",value:d,onChange:f,options:((se=T.data)==null?void 0:se.models)??[],allLabel:"All models"}),s.jsx(Lt,{label:"App",value:h,onChange:m,options:ae,allLabel:"All apps"}),(a||o||d||h)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{l(""),c(""),f(""),m("")},children:[s.jsx(yo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>j.reload(),children:s.jsx(pl,{})})]}),Z?s.jsx(kt,{}):j.error?s.jsx("p",{className:"text-sm text-destructive",children:j.error}):s.jsxs("div",{className:A?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Qn,{label:"Requests",value:Re(D)}),s.jsx(Qn,{label:"Failed",value:Re(I),hint:E(I)}),s.jsx(Qn,{label:"Cancelled",value:Re(O),hint:E(O)}),s.jsx(Qn,{label:"Avg time to failure",value:X===null?"—":uo(Math.round(X))})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures over time"}),s.jsxs(it,{children:["Per ",v.bucket,", split by class."]})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:P,series:Dh.map(Y=>({...Y.series,name:Y.name})),format:Re,integer:!0,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Time to failure"}),s.jsx(it,{children:"How long requests ran before failing. A pile-up near a round number is a timeout."})]}),s.jsx(Qe,{children:s.jsx(Wa,{points:K,series:Dh.map(Y=>({...Y.series,name:Y.name})),format:Re,integer:!0,emptyMessage:"No failures in this range."})})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures by provider"}),s.jsx(it,{children:"Each bar with the provider's own failure rate."})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:ue,format:Re,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures by app"}),s.jsx(it,{children:"From the app tag; untagged traffic grouped."})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:le,format:Re,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failures by model"}),s.jsx(it,{children:"Each bar with the model's own failure rate."})]}),s.jsx(Qe,{children:s.jsx(Ki,{rows:W,format:Re,emptyMessage:"No failures in this range."})})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Failure kinds"}),s.jsx(it,{children:"Provider error codes and transport classes."})]}),s.jsx(Qe,{children:s.jsx(lo,{slices:B.slices,overflow:B.overflow,format:Re,emptyMessage:"No failures in this range."},`${e} ${a} ${o} ${d} ${h}`)})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Error signatures"}),s.jsx(it,{children:"Each distinct failure, newest last seen. Open one in the request explorer."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Error"}),s.jsx(ge,{children:"Provider"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Avg time"}),s.jsx(ge,{className:"text-right",children:"Last seen"}),s.jsx(ge,{})]})}),s.jsxs(vn,{children:[F.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:7,className:"text-muted-foreground",children:"No failures in this range."})}),F.map((Y,ce)=>s.jsxs(Oe,{children:[s.jsx(de,{children:s.jsxs(pn,{variant:Y.outcome==="cancelled"?"warning":"destructive",children:[Y.label,Y.outcome!=="cancelled"&&Y.statusCode&&Y.label!==`http ${Y.statusCode}`?` · ${Y.statusCode}`:""]})}),s.jsx(de,{className:"font-mono text-xs",children:Y.provider||"—"}),s.jsx(de,{className:"font-mono text-xs",children:Y.model||"—"}),s.jsx(de,{className:"text-right tabular-nums",children:Ht(Y.requests)}),s.jsx(de,{className:"text-right tabular-nums",children:uo(Math.round(Y.weightedMs/Y.requests))}),s.jsx(de,{className:"whitespace-nowrap text-right text-xs",children:I0(Y.lastSeen)}),s.jsx(de,{className:"text-right",children:s.jsxs("a",{href:WM(Y),className:"inline-flex items-center gap-1 text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:["explore",s.jsx(QN,{className:"size-3"})]})})]},ce))]})]})})]})]})]})}const tR=[{...ma,name:"p50"},{...Vl,name:"p95"}],nR=[{...ma,name:"average"},{...Vl,name:"peak"}],$i=e=>uo(Math.round(e)),Lh=e=>`${Ht(Math.round(e))} tok/s`,Rb=e=>Number.isInteger(e)?Re(e):e<.01?"<0.01":e<10?e.toFixed(2):Re(Math.round(e)),bm=(e,r)=>e===null?"—":r(e);function Uh({label:e,figure:r,format:a}){return s.jsx(Qn,{label:`${e}, median`,value:bm(r.p50,a),secondary:r.p95===null?void 0:`p95 ${a(r.p95)}`,hint:r.mean===null?void 0:`mean ${a(r.mean)}`})}function rR(){var P,K,ue,le,W,B;const[e,r]=Vt("range","7d"),[a,l]=Vt("user"),[o,c]=Vt("provider"),[d,f]=Vt("model"),[h,m]=Vt("app"),v=cr.find(F=>F.key===e)??cr[1],x=qc(new Date,v.bucket),b=v.count?ho(x,v.bucket,-(v.count-1)):null,y=b?`&since=${b.toISOString()}`:"",k=(a?`&principal=${encodeURIComponent(a)}`:"")+(o?`&provider=${encodeURIComponent(o)}`:"")+(d?`&model=${encodeURIComponent(d)}`:"")+(h?`&tag=${encodeURIComponent(`app:${h}`)}`:""),j=Ut(()=>He.get(`/stats/performance?bucket=${v.bucket}`+y+k),[e,a,o,d,h]),T=Ut(()=>He.get("/stats/requests/facets"+(y?"?"+y.slice(1):"")),[e]),C=S.useMemo(()=>{var F;return[...new Set((((F=T.data)==null?void 0:F.tags)??[]).filter(ae=>ae.startsWith("app:")).map(ae=>ae.slice(4)))].sort()},[T.data]),R=(P=j.data)==null?void 0:P.summary,D=((K=j.data)==null?void 0:K.series)??[],I=((ue=j.data)==null?void 0:ue.models)??[],O=F=>new Date(F).getTime()===x.getTime(),E=F=>D.map(ae=>({label:cp(ae.start,v.bucket),title:dp(ae.start,v.bucket)+(O(ae.start)?" · in progress":""),values:F(ae),rows:[{label:"requests",value:Ht(ae.requests)}]})),N=[{title:"Duration",description:"Time from request to last byte.",points:E(F=>[F.duration_ms.p50,F.duration_ms.p95]),format:$i},{title:"Time to first token",description:"Time from request to the first content event.",points:E(F=>[F.ttft_ms.p50,F.ttft_ms.p95]),format:$i},{title:"Output speed",description:"Output tokens per second after the first token.",points:E(F=>[F.tokens_per_second.p50,F.tokens_per_second.p95]),format:Lh}],L=E(F=>[F.concurrency.average,F.concurrency.peak]),X=j.loading&&!j.data,H=!X&&j.loading;return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Hr,{value:e,onValueChange:r,children:[s.jsx($r,{className:"w-44","aria-label":"Time range",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:cr.map(F=>s.jsx(wr,{value:F.key,children:F.label},F.key))})]}),s.jsx(Lt,{label:"User",value:a,onChange:l,options:((le=T.data)==null?void 0:le.principals)??[],allLabel:"All users"}),s.jsx(Lt,{label:"Provider",value:o,onChange:c,options:((W=T.data)==null?void 0:W.providers)??[],allLabel:"All providers"}),s.jsx(Lt,{label:"Model",value:d,onChange:f,options:((B=T.data)==null?void 0:B.models)??[],allLabel:"All models"}),s.jsx(Lt,{label:"App",value:h,onChange:m,options:C,allLabel:"All apps"}),(a||o||d||h)&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:()=>{l(""),c(""),f(""),m("")},children:[s.jsx(yo,{}),"Clear filters"]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>j.reload(),children:s.jsx(pl,{})})]}),X?s.jsx(kt,{}):j.error?s.jsx("p",{className:"text-sm text-destructive",children:j.error}):R?s.jsxs("div",{className:H?"flex flex-col gap-6 opacity-60":"flex flex-col gap-6",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Uh,{label:"Duration",figure:R.duration_ms,format:$i}),s.jsx(Uh,{label:"Time to first token",figure:R.ttft_ms,format:$i}),s.jsx(Uh,{label:"Output speed",figure:R.tokens_per_second,format:Lh}),s.jsx(Qn,{label:"Concurrent requests, average",value:Rb(R.concurrency.average),secondary:`peak ${Ht(R.concurrency.peak)}`,hint:`${Ht(R.requests)} requests`})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[N.map(F=>s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:F.title}),s.jsx(it,{children:F.description})]}),s.jsx(Qe,{children:s.jsx(xb,{points:F.points,series:tR,format:F.format})})]},F.title)),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Concurrent requests"}),s.jsx(it,{children:"Requests in flight at the same time."})]}),s.jsx(Qe,{children:s.jsx(xb,{points:L,series:nR,format:Rb})})]})]}),s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"By model"}),s.jsx(it,{children:"Median and p95 for each model."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Provider"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{className:"text-right",children:"Requests"}),s.jsx(ge,{className:"text-right",children:"Duration"}),s.jsx(ge,{className:"text-right",children:"First token"}),s.jsx(ge,{className:"text-right",children:"Output speed"})]})}),s.jsxs(vn,{children:[I.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:"No requests in this range."})}),I.map(F=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs",children:F.provider||"—"}),s.jsx(de,{className:"font-mono text-xs",children:F.model||"—"}),s.jsx(de,{className:"text-right tabular-nums",children:Ht(F.requests)}),s.jsx(Bh,{figure:F.duration_ms,format:$i}),s.jsx(Bh,{figure:F.ttft_ms,format:$i}),s.jsx(Bh,{figure:F.tokens_per_second,format:Lh})]},`${F.provider} ${F.model}`))]})]})})]})]}):null]})}function Bh({figure:e,format:r}){return s.jsxs(de,{className:"whitespace-nowrap text-right tabular-nums",children:[bm(e.p50,r),s.jsxs("span",{className:"text-muted-foreground",children:[" / ",bm(e.p95,r)]})]})}var hp="Checkbox",[aR]=Sr(hp),[lR,iR]=aR(hp),lS=S.forwardRef((e,r)=>{const{__scopeCheckbox:a,name:l,checked:o,defaultChecked:c,required:d,disabled:f,value:h="on",onCheckedChange:m,form:v,...x}=e,[b,y]=S.useState(null),k=ft(r,I=>y(I)),j=S.useRef(!1),T=b?v||!!b.closest("form"):!0,[C=!1,R]=nl({prop:o,defaultProp:c,onChange:m}),D=S.useRef(C);return S.useEffect(()=>{const I=b==null?void 0:b.form;if(I){const O=()=>R(D.current);return I.addEventListener("reset",O),()=>I.removeEventListener("reset",O)}},[b,R]),s.jsxs(lR,{scope:a,state:C,disabled:f,children:[s.jsx(Ge.button,{type:"button",role:"checkbox","aria-checked":el(C)?"mixed":C,"aria-required":d,"data-state":oS(C),"data-disabled":f?"":void 0,disabled:f,value:h,...x,ref:k,onKeyDown:Ae(e.onKeyDown,I=>{I.key==="Enter"&&I.preventDefault()}),onClick:Ae(e.onClick,I=>{R(O=>el(O)?!0:!O),T&&(j.current=I.isPropagationStopped(),j.current||I.stopPropagation())})}),T&&s.jsx(sR,{control:b,bubbles:!j.current,name:l,value:h,checked:C,required:d,disabled:f,form:v,style:{transform:"translateX(-100%)"},defaultChecked:el(c)?!1:c})]})});lS.displayName=hp;var iS="CheckboxIndicator",sS=S.forwardRef((e,r)=>{const{__scopeCheckbox:a,forceMount:l,...o}=e,c=iR(iS,a);return s.jsx(Vr,{present:l||el(c.state)||c.state===!0,children:s.jsx(Ge.span,{"data-state":oS(c.state),"data-disabled":c.disabled?"":void 0,...o,ref:r,style:{pointerEvents:"none",...e.style}})})});sS.displayName=iS;var sR=e=>{const{control:r,checked:a,bubbles:l=!0,defaultChecked:o,...c}=e,d=S.useRef(null),f=op(a),h=lp(r);S.useEffect(()=>{const v=d.current,x=window.HTMLInputElement.prototype,y=Object.getOwnPropertyDescriptor(x,"checked").set;if(f!==a&&y){const k=new Event("click",{bubbles:l});v.indeterminate=el(a),y.call(v,el(a)?!1:a),v.dispatchEvent(k)}},[f,a,l]);const m=S.useRef(el(a)?!1:a);return s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:o??m.current,...c,tabIndex:-1,ref:d,style:{...e.style,...h,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function el(e){return e==="indeterminate"}function oS(e){return el(e)?"indeterminate":e?"checked":"unchecked"}var oR=lS,uR=sS;function mp({className:e,...r}){return s.jsx(oR,{"data-slot":"checkbox",className:Ne("peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:s.jsx(uR,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:s.jsx(jc,{className:"size-3.5"})})})}function Zu({label:e,sortKey:r,active:a,onSort:l,numeric:o}){return s.jsx(ge,{className:o?"text-right":void 0,children:s.jsxs("button",{type:"button",onClick:()=>l(r),"aria-label":`Sort by ${e.toLowerCase()}`,className:Ne("cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring",a?"font-medium text-foreground":"hover:text-foreground"),children:[e,a&&s.jsxs("span",{"aria-hidden":!0,children:[" ",r==="name"?"↑":"↓"]})]})})}function cR(){var j;const[e,r]=Vt("range","30d"),[a,l]=S.useState("name"),[o,c]=S.useState(!1),d=cr.find(T=>T.key===e)??cr[2],f=qc(new Date,d.bucket),h=d.count?ho(f,d.bucket,-(d.count-1)):null,m=Ut(()=>He.get("/v1/models?include_hidden=1"),[]),v=Ut(()=>He.get("/stats/summary"+(h?`?since=${h.toISOString()}`:"")),[e]),x=S.useMemo(()=>{var D,I;const T=new Map;for(const O of((D=v.data)==null?void 0:D.usage)??[]){let E=T.get(O.model);E||(E={requests:0,tokens:0,cost:null},T.set(O.model,E)),E.requests+=O.requests,E.tokens+=(O.units.input_tokens??0)+(O.units.output_tokens??0),O.cost!==null&&(E.cost=(E.cost??0)+O.cost)}const C=(((I=m.data)==null?void 0:I.data)??[]).filter(O=>o||!O.hidden).map(O=>{var E,N,L;return{model:O,requests:((E=T.get(O.id))==null?void 0:E.requests)??0,tokens:((N=T.get(O.id))==null?void 0:N.tokens)??0,cost:((L=T.get(O.id))==null?void 0:L.cost)??null}}),R=(O,E)=>O.model.id.localeCompare(E.model.id);return C.sort((O,E)=>a==="name"?R(O,E):a==="cost"?(E.cost??-1)-(O.cost??-1)||R(O,E):E[a]-O[a]||R(O,E))},[m.data,v.data,a,o]),b=(((j=m.data)==null?void 0:j.data)??[]).filter(T=>T.hidden).length,y=m.loading&&!m.data,k=!y&&(m.loading||v.loading);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Hr,{value:e,onValueChange:r,children:[s.jsx($r,{className:"w-44","aria-label":"Time range",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:cr.map(T=>s.jsx(wr,{value:T.key,children:T.label},T.key))})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:()=>{m.reload(),v.reload()},children:s.jsx(pl,{})}),b>0&&s.jsxs("label",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(mp,{checked:o,onCheckedChange:T=>c(T===!0)}),"Show hidden"]})]}),y?s.jsx(kt,{}):m.error||v.error?s.jsx("p",{className:"text-sm text-destructive",children:m.error??v.error}):s.jsxs(Ke,{className:k?"opacity-60":void 0,children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Models"}),s.jsx(it,{children:"Every model you can call, and how much it is used."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(Zu,{label:"Model",sortKey:"name",active:a==="name",onSort:l}),s.jsx(ge,{children:"Capabilities"}),s.jsx(Zu,{label:"Requests",sortKey:"requests",active:a==="requests",onSort:l,numeric:!0}),s.jsx(Zu,{label:"Tokens",sortKey:"tokens",active:a==="tokens",onSort:l,numeric:!0}),s.jsx(Zu,{label:"Spend",sortKey:"cost",active:a==="cost",onSort:l,numeric:!0})]})}),s.jsxs(vn,{children:[x.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No models available yet."})}),x.map(T=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-medium wrap-anywhere",children:s.jsxs("span",{className:"flex flex-col",children:[s.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[T.model.id,T.model.hidden&&s.jsx(pn,{variant:"muted",children:"hidden"})]}),T.model.alias_of&&s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["→ ",T.model.alias_of]})]})}),s.jsx(de,{children:s.jsx("div",{className:"flex flex-wrap gap-1",children:T.model.capabilities.map(C=>s.jsx(pn,{variant:"muted",children:C},C))})}),s.jsx(de,{className:"text-right tabular-nums",children:T.requests?Re(T.requests):""}),s.jsx(de,{className:"text-right tabular-nums",title:Ft(T.tokens),children:T.tokens?Re(T.tokens):""}),s.jsx(de,{className:"text-right tabular-nums",children:T.requests?T.cost===null?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):zr(T.cost):""})]},T.model.id))]})]})})]})]})}function dR(e){const r=Date.now()-new Date(e).getTime();if(r<6e4)return"just now";const a=Math.floor(r/6e4);if(a<60)return`${a}m ago`;const l=Math.floor(a/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function Db(e,r){return e===void 0||r===void 0||r===0?null:`${Math.round(e/r*100)}%`}function Ob({label:e,remaining:r,limit:a}){if(r===void 0&&a===void 0)return null;const l=a&&a>0?(r??0)/a:null,o=l===null?"bg-muted-foreground":l>.5?"bg-green-500":l>.2?"bg-yellow-500":"bg-red-500";return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-baseline justify-between text-xs",children:[s.jsx("span",{className:"text-muted-foreground",children:e}),s.jsxs("span",{className:"tabular-nums",children:[r!==void 0?Ht(r):"?",a!==void 0?` / ${Ht(a)}`:"",Db(r,a)&&s.jsxs("span",{className:"ml-1 text-muted-foreground",children:["(",Db(r,a),")"]})]})]}),l!==null&&s.jsx("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-muted",children:s.jsx("div",{className:Ne("h-full rounded-full transition-all",o),style:{width:`${Math.max(l*100,1)}%`}})})]})}function fR({snap:e}){const r=e.limit_requests!==void 0||e.remaining_requests!==void 0,a=e.limit_tokens!==void 0||e.remaining_tokens!==void 0;return s.jsxs(Ke,{children:[s.jsx(Ze,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Je,{className:"text-base font-medium",children:e.provider}),s.jsxs("span",{className:Ne("text-xs tabular-nums",e.stale?"text-yellow-600 dark:text-yellow-400":"text-muted-foreground"),title:new Date(e.observed_at).toLocaleString(),children:[dR(e.observed_at),e.stale&&" (stale)"]})]})}),s.jsxs(Qe,{className:"flex flex-col gap-3",children:[r&&s.jsx(Ob,{label:"Requests",remaining:e.remaining_requests,limit:e.limit_requests}),a&&s.jsx(Ob,{label:"Tokens",remaining:e.remaining_tokens,limit:e.limit_tokens}),!r&&!a&&s.jsx("p",{className:"text-sm text-muted-foreground",children:"No rate-limit data yet."})]})]})}function hR(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/stats/rate-limits"),[]);return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"font-serif text-lg font-semibold",children:"Provider rate limits"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Upstream quota reported by each configured provider."})]}),s.jsxs(Me,{variant:"outline",size:"sm",onClick:l,disabled:r,children:[r?s.jsx(kt,{}):s.jsx(pl,{className:"size-4"}),"Refresh"]})]}),r&&!e?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(kt,{className:"size-6"})}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):(e==null?void 0:e.rate_limits.length)===0?s.jsx(Ke,{children:s.jsx(Qe,{className:"py-8 text-center text-sm text-muted-foreground",children:"No provider reports rate limits yet."})}):s.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:e==null?void 0:e.rate_limits.map(o=>s.jsx(fR,{snap:o},o.provider_id))})]})}const mR=[{key:"overview",label:"Overview"},{key:"apps",label:"Apps"},{key:"models",label:"Models"},{key:"providers",label:"Providers"},{key:"errors",label:"Errors"},{key:"performance",label:"Performance"}];function pR({value:e,onChange:r}){return s.jsx("nav",{className:"-mt-2 flex items-center gap-4 border-b text-sm",children:mR.map(a=>s.jsx("button",{type:"button","aria-current":e===a.key?"page":void 0,onClick:()=>r(a.key),className:Ne("cursor-pointer border-b-2 px-0.5 pb-2 outline-none focus-visible:ring-2 focus-visible:ring-ring",e===a.key?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:a.label},a.key))})}function gR({ssoEnabled:e,sub:r,onSubChange:a}){return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(pR,{value:r,onChange:a}),r==="apps"?s.jsx(XM,{}):r==="models"?s.jsx(cR,{}):r==="providers"?s.jsx(hR,{}):r==="errors"?s.jsx(eR,{}):r==="performance"?s.jsx(rR,{}):s.jsx(FM,{ssoEnabled:e})]})}var pp="Switch",[xR]=Sr(pp),[vR,yR]=xR(pp),uS=S.forwardRef((e,r)=>{const{__scopeSwitch:a,name:l,checked:o,defaultChecked:c,required:d,disabled:f,value:h="on",onCheckedChange:m,form:v,...x}=e,[b,y]=S.useState(null),k=ft(r,D=>y(D)),j=S.useRef(!1),T=b?v||!!b.closest("form"):!0,[C=!1,R]=nl({prop:o,defaultProp:c,onChange:m});return s.jsxs(vR,{scope:a,checked:C,disabled:f,children:[s.jsx(Ge.button,{type:"button",role:"switch","aria-checked":C,"aria-required":d,"data-state":fS(C),"data-disabled":f?"":void 0,disabled:f,value:h,...x,ref:k,onClick:Ae(e.onClick,D=>{R(I=>!I),T&&(j.current=D.isPropagationStopped(),j.current||D.stopPropagation())})}),T&&s.jsx(bR,{control:b,bubbles:!j.current,name:l,value:h,checked:C,required:d,disabled:f,form:v,style:{transform:"translateX(-100%)"}})]})});uS.displayName=pp;var cS="SwitchThumb",dS=S.forwardRef((e,r)=>{const{__scopeSwitch:a,...l}=e,o=yR(cS,a);return s.jsx(Ge.span,{"data-state":fS(o.checked),"data-disabled":o.disabled?"":void 0,...l,ref:r})});dS.displayName=cS;var bR=e=>{const{control:r,checked:a,bubbles:l=!0,...o}=e,c=S.useRef(null),d=op(a),f=lp(r);return S.useEffect(()=>{const h=c.current,m=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(m,"checked").set;if(d!==a&&x){const b=new Event("click",{bubbles:l});x.call(h,a),h.dispatchEvent(b)}},[d,a,l]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:a,...o,tabIndex:-1,ref:c,style:{...e.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function fS(e){return e?"checked":"unchecked"}var wR=uS,SR=dS;function zb({className:e,...r}){return s.jsx(wR,{"data-slot":"switch",className:Ne("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-[#7F7F79] focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...r,children:s.jsx(SR,{"data-slot":"switch-thumb",className:"bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"})})}function Fi(e){return e instanceof Error?e.message:String(e)}const jR={limit_requests:"x-ratelimit-limit-requests",remaining_requests:"x-ratelimit-remaining-requests",limit_tokens:"x-ratelimit-limit-tokens",remaining_tokens:"x-ratelimit-remaining-tokens"};function kR(e){return{name:e.name,base_url:e.base_url,api_key:"",remove_credential:!1,verify_tls:e.verify_tls,timeout_connect:String(e.timeout_connect),timeout_read:String(e.timeout_read),max_concurrency:e.max_concurrency===null?"":String(e.max_concurrency),rate_limit_headers:e.rate_limit_headers?{...e.rate_limit_headers}:{}}}function CR(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/admin/v1/providers")),[o,c]=S.useState({name:"",base_url:"",api_key:""}),[d,f]=S.useState(!1),[h,m]=S.useState(null),[v,x]=S.useState(!1),[b,y]=S.useState(null),[k,j]=S.useState(null),T=async E=>{E.preventDefault(),f(!0);try{await He.post("/admin/v1/providers",{name:o.name.trim(),wire_format:"openai",base_url:o.base_url.trim(),...o.api_key!==""?{api_key:o.api_key}:{}}),Ve.success(`Provider "${o.name.trim()}" registered`),c({name:"",base_url:"",api_key:""}),l()}catch(N){Ve.error(Fi(N))}finally{f(!1)}},C=async()=>{if(!h)return;const E=Number(h.timeout_connect),N=Number(h.timeout_read);if(!(E>0)||!(N>0)){Ve.error("Timeouts must be positive seconds");return}const L=h.max_concurrency.trim()===""?0:Number(h.max_concurrency);if(!Number.isInteger(L)||L<0){Ve.error("Max concurrency must be a whole number, or empty for unlimited");return}x(!0);try{const X=Object.keys(h.rate_limit_headers).length>0?h.rate_limit_headers:{};await He.patch(`/admin/v1/providers/${encodeURIComponent(h.name)}`,{base_url:h.base_url.trim(),verify_tls:h.verify_tls,timeout_connect:E,timeout_read:N,max_concurrency:L,rate_limit_headers:X,...h.api_key!==""?{api_key:h.api_key}:{},...h.remove_credential?{remove_credential:!0}:{}}),Ve.success(`Provider "${h.name}" updated`),m(null),l()}catch(X){Ve.error(Fi(X))}finally{x(!1)}},R=async E=>{try{await He.patch(`/admin/v1/providers/${encodeURIComponent(E.name)}`,{enabled:!E.enabled}),l()}catch(N){Ve.error(Fi(N))}},D=async E=>{try{await He.del(`/admin/v1/providers/${encodeURIComponent(E)}`),Ve.success(`Provider "${E}" deleted`),(k==null?void 0:k.provider)===E&&j(null),l()}catch(N){Ve.error(Fi(N))}},I=async E=>{y(E);try{const N=await He.get(`/admin/v1/providers/${encodeURIComponent(E)}/discover`);j({provider:E,models:N.models})}catch(N){Ve.error(Fi(N))}finally{y(null)}},O=async(E,N)=>{try{await He.post("/admin/v1/models",{alias:N,provider:E,upstream_name:N,capabilities:["chat","chat_stream"]}),Ve.success(`Bound "${N}" (chat capabilities; adjust in Models)`),I(E)}catch(L){Ve.error(Fi(L))}};return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Register a provider"}),s.jsxs(it,{children:["An upstream OpenAI-compatible endpoint (vLLM, SGLang, OpenAI, ...). The base URL includes ",s.jsx("code",{className:"font-mono",children:"/v1"}),"."]})]}),s.jsx(Qe,{children:s.jsxs("form",{onSubmit:T,className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"p-name",children:"Name"}),s.jsx(Wt,{id:"p-name",placeholder:"vllm-1",value:o.name,onChange:E=>c({...o,name:E.target.value}),required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"p-url",children:"Base URL"}),s.jsx(Wt,{id:"p-url",placeholder:"http://10.0.0.5:8000/v1",value:o.base_url,onChange:E=>c({...o,base_url:E.target.value}),required:!0})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"p-key",children:"Upstream API key (optional)"}),s.jsx(Wt,{id:"p-key",type:"password",autoComplete:"off",value:o.api_key,onChange:E=>c({...o,api_key:E.target.value})})]}),s.jsx("div",{className:"flex items-end",children:s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Register"]})})]})})]}),s.jsxs(Ke,{children:[s.jsx(Ze,{children:s.jsx(Je,{className:"font-serif",children:"Providers"})}),s.jsx(Qe,{children:r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Name"}),s.jsx(ge,{children:"Base URL"}),s.jsx(ge,{children:"Credential"}),s.jsx(ge,{title:"Read timeout · max concurrency",children:"Limits"}),s.jsx(ge,{children:"Enabled"}),s.jsx(ge,{className:"w-56"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.providers.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:"No providers registered yet."})}),e==null?void 0:e.providers.map(E=>(h==null?void 0:h.name)===E.name?s.jsxs(Oe,{className:"bg-muted/30 hover:bg-muted/30",children:[s.jsx(de,{className:"align-top font-medium",children:E.name}),s.jsx(de,{colSpan:5,children:s.jsxs("div",{className:"flex flex-col gap-4 py-1",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"e-url",children:"Base URL"}),s.jsx(Wt,{id:"e-url",value:h.base_url,onChange:N=>m({...h,base_url:N.target.value})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"e-key",children:"Upstream API key"}),s.jsx(Wt,{id:"e-key",type:"password",autoComplete:"off",placeholder:E.has_credential?"unchanged":"none",value:h.api_key,disabled:h.remove_credential,onChange:N=>m({...h,api_key:N.target.value})}),E.has_credential&&s.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[s.jsx(mp,{checked:h.remove_credential,onCheckedChange:N=>m({...h,remove_credential:N===!0})}),"Remove the stored key"]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"e-conc",children:"Max concurrency"}),s.jsx(Wt,{id:"e-conc",inputMode:"numeric",placeholder:"unlimited",value:h.max_concurrency,onChange:N=>m({...h,max_concurrency:N.target.value})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"e-connect",children:"Connect timeout (s)"}),s.jsx(Wt,{id:"e-connect",inputMode:"decimal",value:h.timeout_connect,onChange:N=>m({...h,timeout_connect:N.target.value})})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"e-read",children:"Read timeout (s)"}),s.jsx(Wt,{id:"e-read",inputMode:"decimal",value:h.timeout_read,onChange:N=>m({...h,timeout_read:N.target.value})}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Caps the wait for a response; whole request on non-streaming calls."})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"e-tls",children:"Verify TLS"}),s.jsx(zb,{id:"e-tls",checked:h.verify_tls,onCheckedChange:N=>m({...h,verify_tls:N})})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Jt,{children:"Rate limit headers"}),Object.keys(h.rate_limit_headers).length===0&&s.jsx(Me,{variant:"outline",size:"sm",type:"button",onClick:()=>m({...h,rate_limit_headers:{...jR}}),children:"Use standard headers"}),Object.keys(h.rate_limit_headers).length>0&&s.jsx(Me,{variant:"outline",size:"sm",type:"button",onClick:()=>m({...h,rate_limit_headers:{}}),children:"Clear"})]}),Object.keys(h.rate_limit_headers).length>0&&s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:Object.entries(h.rate_limit_headers).map(([N,L])=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:N}),s.jsx(Wt,{value:L,onChange:X=>m({...h,rate_limit_headers:{...h.rate_limit_headers,[N]:X.target.value}})})]},N))}),Object.keys(h.rate_limit_headers).length===0&&s.jsx("p",{className:"text-xs text-muted-foreground",children:'Not configured. Click "Use standard headers" to track upstream rate limits.'})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Me,{size:"sm",disabled:v,onClick:C,children:[v&&s.jsx(kt,{}),"Save"]}),s.jsx(Me,{variant:"outline",size:"sm",onClick:()=>m(null),children:"Cancel"})]})]})})]},E.name):s.jsxs(Oe,{children:[s.jsx(de,{className:"font-medium wrap-anywhere",children:E.name}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:E.base_url}),s.jsx(de,{children:E.has_credential?s.jsx(pn,{variant:"secondary",children:"set"}):s.jsx(pn,{variant:"muted",children:"none"})}),s.jsxs(de,{className:"whitespace-nowrap text-xs text-muted-foreground",title:"Read timeout · max concurrency",children:[E.timeout_read,"s ·"," ",E.max_concurrency===null?"unlimited":E.max_concurrency]}),s.jsx(de,{children:s.jsx(zb,{checked:E.enabled,onCheckedChange:()=>R(E),"aria-label":`Enable ${E.name}`})}),s.jsxs(de,{className:"flex items-center justify-end gap-1 whitespace-nowrap",children:[s.jsxs(Me,{variant:"outline",size:"sm",disabled:b===E.name,onClick:()=>I(E.name),children:[b===E.name?s.jsx(kt,{}):s.jsx(pl,{}),"Discover models"]}),s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Edit ${E.name}`,onClick:()=>m(kR(E)),children:s.jsx(d1,{})}),s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Delete ${E.name}`,children:s.jsx($m,{})})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:['Delete provider "',E.name,'"?']}),s.jsx(ul,{children:"All model bindings on this provider are deleted with it, and calls to those aliases start failing immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>D(E.name),children:"Delete"})]})]})]})]})]},E.name))]})]})})]}),k&&s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsxs(Je,{className:"font-serif",children:['Models on "',k.provider,'"']}),s.jsx(it,{children:"Read from the upstream's own model list. Binding uses the upstream name as the alias with chat capabilities; refine aliases and capabilities in the Models tab."})]}),s.jsx(Qe,{children:s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Upstream name"}),s.jsx(ge,{children:"Bound alias"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[k.models.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:3,className:"text-muted-foreground",children:"The upstream reported no models."})}),k.models.map(E=>s.jsxs(Oe,{children:[s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:E.upstream_name}),s.jsx(de,{children:E.bound_alias?s.jsx(pn,{variant:"secondary",children:E.bound_alias}):s.jsx("span",{className:"text-muted-foreground",children:"not bound"})}),s.jsx(de,{children:!E.bound_alias&&s.jsx(Me,{variant:"outline",size:"sm",onClick:()=>O(k.provider,E.upstream_name),children:"Bind"})})]},E.upstream_name))]})]})})]})]})}function Ju({id:e,value:r,onChange:a,options:l,loading:o,note:c,placeholder:d,className:f}){const[h,m]=S.useState(!1),[v,x]=S.useState(0),[b,y]=S.useState(!1),k=S.useRef(null),j=S.useRef(null),T=S.useRef(!1),C=S.useMemo(()=>{if(!b)return l.slice(0,50);const O=r.trim().toLowerCase();return l.filter(N=>N.value.toLowerCase().includes(O)).slice(0,50)},[l,r,b]),R=()=>{y(!1);const E=l.slice(0,50).findIndex(N=>N.value===r);x(E>=0?E:0),m(!0)};S.useEffect(()=>{const O=E=>{var N;(N=k.current)!=null&&N.contains(E.target)||m(!1)};return document.addEventListener("pointerdown",O),()=>document.removeEventListener("pointerdown",O)},[]);const D=O=>{a(O.value),y(!1),m(!1)},I=O=>{if(O.key==="ArrowDown"||O.key==="ArrowUp"){if(O.preventDefault(),!h){R();return}const E=O.key==="ArrowDown"?1:-1;x(N=>(N+E+C.length)%Math.max(C.length,1))}else O.key==="Enter"&&h&&C[v]?(O.preventDefault(),D(C[v])):O.key==="Escape"&&m(!1)};return s.jsxs("div",{ref:k,className:Ne("relative",f),children:[s.jsx(Wt,{ref:j,id:e,role:"combobox","aria-expanded":h,"aria-autocomplete":"list",autoComplete:"off",className:"pr-14 font-mono text-xs",placeholder:d,value:r,onChange:O=>{a(O.target.value),y(!0),x(0),m(!0)},onFocus:R,onKeyDown:I}),s.jsxs("div",{className:"absolute inset-y-0 right-1 flex items-center",children:[o?s.jsx(kt,{className:"text-muted-foreground mr-1"}):r!==""&&s.jsx("button",{type:"button","aria-label":"Clear",tabIndex:-1,className:"text-muted-foreground hover:text-foreground rounded p-1",onPointerDown:O=>O.preventDefault(),onClick:()=>{var O;a(""),y(!1),x(0),m(!0),(O=j.current)==null||O.focus()},children:s.jsx(Fm,{className:"size-3.5"})}),s.jsx("button",{type:"button","aria-label":"Show options",tabIndex:-1,className:"text-muted-foreground hover:text-foreground rounded p-1",onPointerDown:O=>{O.preventDefault(),T.current=h},onClick:()=>{var O;(O=j.current)==null||O.focus(),T.current?m(!1):R()},children:s.jsx(Ji,{className:Ne("size-4 transition-transform",h&&"rotate-180")})})]}),h&&(C.length>0||c)&&s.jsxs("div",{className:"bg-popover absolute z-20 mt-1 max-h-64 w-full overflow-y-auto rounded-md border p-1 shadow-md",children:[c&&s.jsx("p",{className:"text-muted-foreground px-2 py-1.5 text-xs",children:c}),C.map((O,E)=>s.jsxs("button",{type:"button",role:"option","aria-selected":E===v,className:Ne("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left text-xs",E===v&&"bg-accent text-accent-foreground"),onPointerEnter:()=>x(E),onClick:()=>D(O),children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx(jc,{className:Ne("size-3.5 shrink-0",O.value!==r&&"invisible")}),s.jsx("span",{className:"truncate font-mono",children:O.value})]}),O.hint&&s.jsx("span",{className:"text-muted-foreground shrink-0",children:O.hint})]},O.value))]})]})}var Ih="rovingFocusGroup.onEntryFocus",NR={bubbles:!1,cancelable:!0},Hc="RovingFocusGroup",[wm,hS,ER]=Jm(Hc),[TR,Pc]=Sr(Hc,[ER]),[AR,_R]=TR(Hc),mS=S.forwardRef((e,r)=>s.jsx(wm.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(wm.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(MR,{...e,ref:r})})}));mS.displayName=Hc;var MR=S.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:a,orientation:l,loop:o=!1,dir:c,currentTabStopId:d,defaultCurrentTabStopId:f,onCurrentTabStopIdChange:h,onEntryFocus:m,preventScrollOnEntryFocus:v=!1,...x}=e,b=S.useRef(null),y=ft(r,b),k=_c(c),[j=null,T]=nl({prop:d,defaultProp:f,onChange:h}),[C,R]=S.useState(!1),D=fr(m),I=hS(a),O=S.useRef(!1),[E,N]=S.useState(0);return S.useEffect(()=>{const L=b.current;if(L)return L.addEventListener(Ih,D),()=>L.removeEventListener(Ih,D)},[D]),s.jsx(AR,{scope:a,orientation:l,dir:k,loop:o,currentTabStopId:j,onItemFocus:S.useCallback(L=>T(L),[T]),onItemShiftTab:S.useCallback(()=>R(!0),[]),onFocusableItemAdd:S.useCallback(()=>N(L=>L+1),[]),onFocusableItemRemove:S.useCallback(()=>N(L=>L-1),[]),children:s.jsx(Ge.div,{tabIndex:C||E===0?-1:0,"data-orientation":l,...x,ref:y,style:{outline:"none",...e.style},onMouseDown:Ae(e.onMouseDown,()=>{O.current=!0}),onFocus:Ae(e.onFocus,L=>{const X=!O.current;if(L.target===L.currentTarget&&X&&!C){const H=new CustomEvent(Ih,NR);if(L.currentTarget.dispatchEvent(H),!H.defaultPrevented){const P=I().filter(B=>B.focusable),K=P.find(B=>B.active),ue=P.find(B=>B.id===j),W=[K,ue,...P].filter(Boolean).map(B=>B.ref.current);xS(W,v)}}O.current=!1}),onBlur:Ae(e.onBlur,()=>R(!1))})})}),pS="RovingFocusGroupItem",gS=S.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:a,focusable:l=!0,active:o=!1,tabStopId:c,...d}=e,f=Br(),h=c||f,m=_R(pS,a),v=m.currentTabStopId===h,x=hS(a),{onFocusableItemAdd:b,onFocusableItemRemove:y}=m;return S.useEffect(()=>{if(l)return b(),()=>y()},[l,b,y]),s.jsx(wm.ItemSlot,{scope:a,id:h,focusable:l,active:o,children:s.jsx(Ge.span,{tabIndex:v?0:-1,"data-orientation":m.orientation,...d,ref:r,onMouseDown:Ae(e.onMouseDown,k=>{l?m.onItemFocus(h):k.preventDefault()}),onFocus:Ae(e.onFocus,()=>m.onItemFocus(h)),onKeyDown:Ae(e.onKeyDown,k=>{if(k.key==="Tab"&&k.shiftKey){m.onItemShiftTab();return}if(k.target!==k.currentTarget)return;const j=OR(k,m.orientation,m.dir);if(j!==void 0){if(k.metaKey||k.ctrlKey||k.altKey||k.shiftKey)return;k.preventDefault();let C=x().filter(R=>R.focusable).map(R=>R.ref.current);if(j==="last")C.reverse();else if(j==="prev"||j==="next"){j==="prev"&&C.reverse();const R=C.indexOf(k.currentTarget);C=m.loop?zR(C,R+1):C.slice(R+1)}setTimeout(()=>xS(C))}})})})});gS.displayName=pS;var RR={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function DR(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function OR(e,r,a){const l=DR(e.key,a);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(l))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(l)))return RR[l]}function xS(e,r=!1){const a=document.activeElement;for(const l of e)if(l===a||(l.focus({preventScroll:r}),document.activeElement!==a))return}function zR(e,r){return e.map((a,l)=>e[(r+l)%e.length])}var vS=mS,yS=gS,gp="Tabs",[LR]=Sr(gp,[Pc]),bS=Pc(),[UR,xp]=LR(gp),wS=S.forwardRef((e,r)=>{const{__scopeTabs:a,value:l,onValueChange:o,defaultValue:c,orientation:d="horizontal",dir:f,activationMode:h="automatic",...m}=e,v=_c(f),[x,b]=nl({prop:l,onChange:o,defaultProp:c});return s.jsx(UR,{scope:a,baseId:Br(),value:x,onValueChange:b,orientation:d,dir:v,activationMode:h,children:s.jsx(Ge.div,{dir:v,"data-orientation":d,...m,ref:r})})});wS.displayName=gp;var SS="TabsList",jS=S.forwardRef((e,r)=>{const{__scopeTabs:a,loop:l=!0,...o}=e,c=xp(SS,a),d=bS(a);return s.jsx(vS,{asChild:!0,...d,orientation:c.orientation,dir:c.dir,loop:l,children:s.jsx(Ge.div,{role:"tablist","aria-orientation":c.orientation,...o,ref:r})})});jS.displayName=SS;var kS="TabsTrigger",CS=S.forwardRef((e,r)=>{const{__scopeTabs:a,value:l,disabled:o=!1,...c}=e,d=xp(kS,a),f=bS(a),h=TS(d.baseId,l),m=AS(d.baseId,l),v=l===d.value;return s.jsx(yS,{asChild:!0,...f,focusable:!o,active:v,children:s.jsx(Ge.button,{type:"button",role:"tab","aria-selected":v,"aria-controls":m,"data-state":v?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:h,...c,ref:r,onMouseDown:Ae(e.onMouseDown,x=>{!o&&x.button===0&&x.ctrlKey===!1?d.onValueChange(l):x.preventDefault()}),onKeyDown:Ae(e.onKeyDown,x=>{[" ","Enter"].includes(x.key)&&d.onValueChange(l)}),onFocus:Ae(e.onFocus,()=>{const x=d.activationMode!=="manual";!v&&!o&&x&&d.onValueChange(l)})})})});CS.displayName=kS;var NS="TabsContent",ES=S.forwardRef((e,r)=>{const{__scopeTabs:a,value:l,forceMount:o,children:c,...d}=e,f=xp(NS,a),h=TS(f.baseId,l),m=AS(f.baseId,l),v=l===f.value,x=S.useRef(v);return S.useEffect(()=>{const b=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(b)},[]),s.jsx(Vr,{present:o||v,children:({present:b})=>s.jsx(Ge.div,{"data-state":v?"active":"inactive","data-orientation":f.orientation,role:"tabpanel","aria-labelledby":h,hidden:!b,id:m,tabIndex:0,...d,ref:r,style:{...e.style,animationDuration:x.current?"0s":void 0},children:b&&c})})});ES.displayName=NS;function TS(e,r){return`${e}-trigger-${r}`}function AS(e,r){return`${e}-content-${r}`}var BR=wS,IR=jS,qR=CS,HR=ES;function Sm({className:e,...r}){return s.jsx(BR,{"data-slot":"tabs",className:Ne("flex flex-col gap-2",e),...r})}function jm({className:e,...r}){return s.jsx(IR,{"data-slot":"tabs-list",className:Ne("bg-[rgb(var(--border))] text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",e),...r})}function or({className:e,...r}){return s.jsx(qR,{"data-slot":"tabs-trigger",className:Ne("data-[state=active]:bg-card dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r})}function Dr({className:e,...r}){return s.jsx(HR,{"data-slot":"tabs-content",className:Ne("flex-1 outline-none",e),...r})}const PR=["chat","chat_stream","completions","embeddings","transcription","vision"],$c=[{unit:"input_tokens",label:"Input $/M",short:"in"},{unit:"output_tokens",label:"Output $/M",short:"out"},{unit:"cached_input_tokens",label:"Cached input $/M",short:"cached"}];function no(e){return e instanceof Error?e.message:String(e)}function $R(e){const r={};for(const{unit:a}of $c)e[a]!==void 0&&(r[a]=String(e[a]));return r}function Lb(e){const r={};for(const{unit:a}of $c){const l=(e[a]??"").trim();if(l==="")continue;const o=Number(l);if(!isFinite(o)||o<0)return null;r[a]=o}return r}function Ub({id:e,value:r,onChange:a,inherited:l}){return s.jsx(s.Fragment,{children:$c.map(({unit:o,label:c})=>s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:`${e}-${o}`,children:c}),s.jsx(Wt,{id:`${e}-${o}`,type:"number",min:"0",step:"any",placeholder:l?"inherited":"unpriced",value:r[o]??"",onChange:d=>a({...r,[o]:d.target.value})})]},o))})}function FR({model:e}){const r=$c.filter(({unit:a})=>e.pricing[a]!==void 0).map(({unit:a,short:l})=>`${l} ${e.pricing[a]}`);return r.length===0?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):s.jsxs("span",{className:"tabular-nums",children:[r.map((a,l)=>s.jsxs("span",{className:"whitespace-nowrap",children:[l>0&&" · ",a]},a)),e.pricing_inherited&&s.jsx(pn,{variant:"muted",className:"ml-2",title:"Priced under the upstream model name",children:"inherited"})]})}function Bb({value:e,onChange:r}){return s.jsx(s.Fragment,{children:PR.map(a=>s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx(mp,{checked:e.includes(a),onCheckedChange:l=>r(l===!0?[...e,a]:e.filter(o=>o!==a))}),a]},a))})}function Ib(e,r){return e.filter(a=>a.target===null&&a.alias!==r).map(a=>({value:a.alias,hint:`${a.provider} · ${a.upstream_name}`}))}function qb({value:e,onChange:r}){return s.jsx(Sm,{value:e,onValueChange:a=>r(a),children:s.jsxs(jm,{children:[s.jsx(or,{value:"provider",children:"Provider model"}),s.jsx(or,{value:"alias",children:"Alias → model"})]})})}const Hb=new Map;function Pb(e){const[r,a]=S.useState([]),[l,o]=S.useState(!1),[c,d]=S.useState(null);S.useEffect(()=>{if(e===""){a([]),d(null);return}const m=Hb.get(e);if(m){a(m),d(null);return}let v=!0;return o(!0),d(null),He.get(`/admin/v1/providers/${encodeURIComponent(e)}/discover`).then(x=>{v&&(Hb.set(e,x.models),a(x.models))}).catch(x=>v&&d(no(x))).finally(()=>v&&o(!1)),()=>{v=!1}},[e]);const f=r.map(m=>({value:m.upstream_name,hint:m.bound_alias?`bound to ${m.bound_alias}`:void 0})),h=e?c?`Could not list this provider's models (${c}). Type the name.`:l?"Asking the provider what it serves…":r.length===0?"The provider listed no models. Type the name.":void 0:"Select a provider to list its models.";return{options:f,loading:l,note:h}}function VR(){var D,I,O,E;const e=Ut(()=>He.get("/admin/v1/models")),r=Ut(()=>He.get("/admin/v1/providers")),[a,l]=S.useState({kind:"provider",alias:"",provider:"",upstream_name:"",target:"",capabilities:["chat","chat_stream"],prices:{}}),[o,c]=S.useState(!1),[d,f]=S.useState(null),h=Pb(a.kind==="provider"?a.provider:""),m=Pb((d==null?void 0:d.kind)==="provider"?d.provider:""),v=((D=e.data)==null?void 0:D.models)??[],x=S.useRef("");S.useEffect(()=>{if(!(a.kind!=="provider"||a.provider==="")&&x.current!==a.provider&&!(h.loading||h.options.length===0)&&(x.current=a.provider,a.upstream_name.trim()==="")){const N=h.options.find(L=>!L.hint)??h.options[0];l(L=>({...L,upstream_name:N.value}))}},[a.kind,a.provider,a.upstream_name,h.loading,h.options]);const b=N=>N.kind==="alias"?{target:N.target.trim()}:{provider:N.provider,upstream_name:N.upstream_name.trim(),capabilities:N.capabilities},y=N=>N.kind==="alias"?N.target.trim()===""?"Pick the model this one points at":N.alias.trim()===""?"An alias for another model needs its own name":null:N.upstream_name.trim()===""?"Upstream model name is required":N.capabilities.length===0?"Pick at least one capability":null,k=async N=>{N.preventDefault();const L=y(a);if(L){Ve.error(L);return}const X=Lb(a.prices);if(X===null){Ve.error("Prices must be non-negative numbers");return}const H=a.alias.trim()||a.upstream_name.trim();c(!0);try{await He.post("/admin/v1/models",{alias:H,...b(a),pricing:Object.keys(X).length>0?X:void 0}),Ve.success(`Model "${H}" bound`),l({...a,alias:"",upstream_name:"",target:"",prices:{}}),e.reload()}catch(P){Ve.error(no(P))}finally{c(!1)}},j=async()=>{if(!d)return;if(d.alias.trim()===""){Ve.error("Alias is required");return}const N=y(d);if(N){Ve.error(N);return}const L=Lb(d.prices);if(L===null){Ve.error("Prices must be non-negative numbers");return}try{await He.patch(`/admin/v1/models/${encodeURIComponent(d.original)}`,{alias:d.alias.trim(),target:d.kind==="alias"?d.target.trim():"",...d.kind==="alias"?{}:b(d),pricing:L}),Ve.success(d.alias.trim()===d.original?`Model "${d.original}" updated`:`Model "${d.original}" renamed to "${d.alias.trim()}"`),f(null),e.reload()}catch(X){Ve.error(no(X))}},T=async(N,L)=>{try{await He.patch(`/admin/v1/models/${encodeURIComponent(N)}`,{hidden:L}),Ve.success(L?`Model "${N}" hidden`:`Model "${N}" shown`),e.reload()}catch(X){Ve.error(no(X))}},C=async N=>{try{await He.del(`/admin/v1/models/${encodeURIComponent(N)}`),Ve.success(`Model "${N}" deleted`),e.reload()}catch(L){Ve.error(no(L))}},R=s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"m-alias",children:a.kind==="alias"?"Name":"Alias"}),s.jsx(Wt,{id:"m-alias",placeholder:a.kind==="alias"?"a new name for it":a.upstream_name.trim()||"same as the upstream name",value:a.alias,onChange:N=>l({...a,alias:N.target.value})})]});return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Bind a model"}),s.jsxs(it,{children:["A model name is what callers pass as ",s.jsx("code",{className:"font-mono",children:"model"}),"; names are globally unique and serve as soon as they exist (disable the provider to take its models offline). It either points at a provider's model, or at another model already bound, in which case it inherits that one's provider, capabilities and prices. Prices are per million units: a unit left blank records usage as unpriced rather than free."]})]}),s.jsx(Qe,{children:s.jsxs("form",{onSubmit:k,className:"flex flex-col gap-4",children:[s.jsx(qb,{value:a.kind,onChange:N=>l({...a,kind:N})}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[a.kind==="alias"&&R,a.kind==="provider"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{children:"Provider"}),s.jsxs(Hr,{value:a.provider,onValueChange:N=>l({...a,provider:N}),required:!0,children:[s.jsx($r,{className:"w-full",children:s.jsx(Pr,{placeholder:"Select a provider"})}),s.jsx(Fr,{children:(I=r.data)==null?void 0:I.providers.map(N=>s.jsx(wr,{value:N.name,children:N.name},N.name))})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"m-upstream",children:"Upstream model name"}),s.jsx(Ju,{id:"m-upstream",value:a.upstream_name,onChange:N=>l({...a,upstream_name:N}),...h})]})]}):s.jsxs("div",{className:"flex flex-col gap-2 sm:col-span-2",children:[s.jsx(Jt,{htmlFor:"m-target",children:"Model it points at"}),s.jsx(Ju,{id:"m-target",value:a.target,onChange:N=>l({...a,target:N}),options:Ib(v),note:v.some(N=>N.target===null)?void 0:"Bind a provider model first; an alias points at one of those."})]}),a.kind==="provider"&&R]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:s.jsx(Ub,{id:"new",value:a.prices,onChange:N=>l({...a,prices:N}),inherited:a.kind==="alias"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2",children:[a.kind==="provider"?s.jsx(Bb,{value:a.capabilities,onChange:N=>l({...a,capabilities:N})}):s.jsx("span",{className:"text-sm text-muted-foreground",children:"Capabilities are inherited from the model it points at."}),s.jsxs(Me,{type:"submit",disabled:o||(a.kind==="provider"?a.provider===""||a.upstream_name.trim()==="":a.target.trim()===""||a.alias.trim()===""),children:[o&&s.jsx(kt,{}),"Bind model"]})]})]})})]}),s.jsxs(Ke,{children:[s.jsx(Ze,{children:s.jsx(Je,{className:"font-serif",children:"Models"})}),s.jsx(Qe,{children:e.loading&&!e.data?s.jsx(kt,{}):e.error?s.jsx("p",{className:"text-sm text-destructive",children:e.error}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Alias"}),s.jsx(ge,{children:"Provider"}),s.jsx(ge,{children:"Upstream name"}),s.jsx(ge,{children:"Capabilities"}),s.jsx(ge,{children:"Pricing ($/M)"}),s.jsx(ge,{className:"w-32"})]})}),s.jsxs(vn,{children:[((O=e.data)==null?void 0:O.models.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:"No model bindings yet. Register a provider first, then bind models here or from provider discovery."})}),(E=e.data)==null?void 0:E.models.map(N=>{var L;return(d==null?void 0:d.original)===N.alias?s.jsx(Oe,{children:s.jsx(de,{colSpan:6,children:s.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[s.jsx(qb,{value:d.kind,onChange:X=>f({...d,kind:X})}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[d.kind==="provider"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{children:"Provider"}),s.jsxs(Hr,{value:d.provider,onValueChange:X=>f({...d,provider:X}),children:[s.jsx($r,{className:"w-full",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:(L=r.data)==null?void 0:L.providers.map(X=>s.jsx(wr,{value:X.name,children:X.name},X.name))})]})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"edit-upstream",children:"Upstream model name"}),s.jsx(Ju,{id:"edit-upstream",value:d.upstream_name,onChange:X=>f({...d,upstream_name:X}),...m})]})]}):s.jsxs("div",{className:"flex flex-col gap-2 sm:col-span-2",children:[s.jsx(Jt,{htmlFor:"edit-target",children:"Model it points at"}),s.jsx(Ju,{id:"edit-target",value:d.target,onChange:X=>f({...d,target:X}),options:Ib(v,d.original)})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Jt,{htmlFor:"edit-alias",children:"Name"}),s.jsx(Wt,{id:"edit-alias",value:d.alias,onChange:X=>f({...d,alias:X.target.value})})]})]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-3",children:s.jsx(Ub,{id:"edit",value:d.prices,onChange:X=>f({...d,prices:X}),inherited:d.kind==="alias"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2",children:[d.kind==="provider"?s.jsx(Bb,{value:d.capabilities,onChange:X=>f({...d,capabilities:X})}):s.jsx("span",{className:"text-sm text-muted-foreground",children:"Capabilities are inherited from the model it points at."}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Me,{size:"sm",onClick:j,children:"Save"}),s.jsx(Me,{variant:"ghost",size:"sm",onClick:()=>f(null),children:"Cancel"})]})]})]})})},N.alias):s.jsxs(Oe,{children:[s.jsx(de,{className:"font-medium wrap-anywhere",children:s.jsxs("span",{className:"flex flex-wrap items-center gap-2",children:[N.alias,N.hidden&&s.jsx(pn,{variant:"muted",children:"hidden"})]})}),s.jsx(de,{className:"wrap-anywhere",children:N.provider}),s.jsx(de,{className:"font-mono text-xs wrap-anywhere",children:N.target?s.jsxs("span",{className:"flex flex-col",children:[s.jsxs("span",{children:["→ ",N.target]}),s.jsx("span",{className:"text-muted-foreground",children:N.upstream_name})]}):N.upstream_name}),s.jsx(de,{children:s.jsx("div",{className:"flex flex-wrap gap-1",children:N.capabilities.map(X=>s.jsx(pn,{variant:"muted",children:X},X))})}),s.jsx(de,{className:"text-sm",children:s.jsx(FR,{model:N})}),s.jsxs(de,{className:"whitespace-nowrap",children:[s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":N.hidden?`Show ${N.alias}`:`Hide ${N.alias}`,title:"Hidden from the model list. It still answers calls.",onClick:()=>T(N.alias,!N.hidden),children:N.hidden?s.jsx(tE,{}):s.jsx(nE,{})}),s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Edit ${N.alias}`,onClick:()=>f({original:N.alias,kind:N.target?"alias":"provider",alias:N.alias,provider:N.provider,upstream_name:N.upstream_name,target:N.target??"",capabilities:[...N.capabilities],prices:N.pricing_inherited?{}:$R(N.pricing)}),children:s.jsx(d1,{})}),s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"icon-sm","aria-label":`Delete ${N.alias}`,children:s.jsx($m,{})})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:['Delete model "',N.alias,'"?']}),s.jsx(ul,{children:"Callers using this name get model_not_found immediately. Usage history is kept, and a model other names point at cannot be deleted until they are."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>C(N.alias),children:"Delete"})]})]})]})]})]},N.alias)})]})]})})]})]})}const qh=[{key:"24h",label:"Last 24 hours",hours:24},{key:"7d",label:"Last 7 days",hours:168},{key:"30d",label:"Last 30 days",hours:720},{key:"all",label:"All time",hours:0},{key:"custom",label:"Custom range",hours:0}],GR=[25,50,100,200],YR=[{value:"failed",label:"Errors only"},{value:"upstream_error",label:"Provider errors"},{value:"unreachable",label:"Unreachable"},{value:"cancelled",label:"Cancelled"},{value:"ok",label:"OK only"}];function XR(e){return e?`${e}T00:00:00Z`:null}function KR(e){if(!e)return null;const r=new Date(`${e}T00:00:00Z`);return r.setUTCDate(r.getUTCDate()+1),r.toISOString()}function QR(e){const r=new Date(e);return isNaN(r.getTime())?e:r.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ZR({row:e}){return e.cancelled?s.jsx(pn,{variant:"warning",children:"cancelled"}):e.outcome==="ok"?s.jsx(pn,{variant:"success",children:"ok"}):s.jsxs(pn,{variant:"destructive",children:[e.error_kind||e.outcome,e.status_code?` · ${e.status_code}`:""]})}function JR({row:e}){return s.jsxs("span",{className:"flex items-baseline",children:[s.jsx("span",{className:"max-w-36 truncate",title:e.principal,children:e.principal}),e.key_suffix&&s.jsxs("span",{className:"ml-1.5 shrink-0 font-mono text-xs text-muted-foreground",title:e.key_label||void 0,children:["···",e.key_suffix]})]})}function WR({row:e}){const r=ha(e.tags,"app");return r?s.jsx(pn,{variant:"tag",size:"sm",className:"max-w-full font-mono",title:r,children:s.jsx("span",{className:"min-w-0 truncate",children:r})}):e.client?s.jsx("span",{className:"font-mono text-xs text-muted-foreground",title:e.client,children:ao(e.client)}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}function eD({row:e}){const r=e.units.input_tokens,a=e.units.output_tokens;return!r&&!a?s.jsx("span",{className:"text-muted-foreground",children:"—"}):s.jsxs("span",{className:"whitespace-nowrap tabular-nums",children:[Re(r??0),s.jsx("span",{className:"text-muted-foreground",children:" → "}),Re(a??0)]})}function vr({label:e,children:r}){return s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:e}),s.jsx("span",{className:"text-sm",children:r})]})}function tD({row:e}){const r=Object.entries(e.units).sort();return s.jsxs("div",{className:"grid grid-cols-2 gap-x-8 gap-y-3 py-2 md:grid-cols-4",children:[s.jsx(vr,{label:"Provider",children:s.jsx("span",{className:"font-mono text-xs",children:e.provider||"—"})}),s.jsx(vr,{label:"Endpoint",children:e.endpoint}),s.jsx(vr,{label:"Key",children:e.key_suffix?s.jsxs("span",{className:"font-mono text-xs",children:[e.key_label?`${e.key_label} `:"","···",e.key_suffix]}):"—"}),s.jsx(vr,{label:"Recorded (UTC)",children:s.jsx("span",{className:"font-mono text-xs",children:e.ts.replace("T"," ").slice(0,19)})}),s.jsx(vr,{label:"Client",children:s.jsx("span",{className:"break-all font-mono text-xs",children:e.client||"—"})}),s.jsx(vr,{label:"Tags",children:e.tags?s.jsx("span",{className:"flex flex-wrap gap-1",children:X2(e.tags).map(a=>s.jsx(pn,{variant:"tag",size:"sm",className:"font-mono",children:a},a))}):"—"}),s.jsxs(vr,{label:"Outcome",children:[e.outcome,e.error_kind?` · ${e.error_kind}`:"",e.status_code?` · http ${e.status_code}`:"",e.streamed?" · streamed":""]}),s.jsx(vr,{label:"Cost",children:e.cost!==null?s.jsx("span",{className:"tabular-nums",children:Bm(e.cost)}):e.unpriced?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):"—"}),r.map(([a,l])=>s.jsx(vr,{label:a.replaceAll("_"," "),children:s.jsx("span",{className:"tabular-nums",children:Ft(l)||"0"})},a)),e.ttft_ms!==null&&s.jsx(vr,{label:"First token",children:s.jsxs("span",{className:"tabular-nums",children:[Ht(e.ttft_ms)," ms"]})}),s.jsx(vr,{label:"Duration",children:s.jsxs("span",{className:"tabular-nums",children:[Ht(e.duration_ms)," ms"]})})]})}function nD(){var Ie,Be,Mt,Nt,Et,Bt,Rt,Dt,zt;const e=S.useMemo(()=>new URLSearchParams(window.location.search),[]),[r,a]=S.useState("7d"),[l,o]=S.useState(""),[c,d]=S.useState(""),[f,h]=S.useState(e.get("principal")??""),[m,v]=S.useState(""),[x,b]=S.useState(""),[y,k]=S.useState(e.get("model")??""),[j,T]=S.useState(e.get("provider")??""),[C,R]=S.useState(e.get("app")??""),[D,I]=S.useState(e.get("outcome")??""),[O,E]=S.useState(50),[N,L]=S.useState(0),[X,H]=S.useState(null),[P,K]=S.useState(0),ue=()=>K(be=>be+1),le=r==="custom",W=qh.find(be=>be.key===r)??qh[1],{since:B,until:F}=S.useMemo(()=>le?{since:XR(l),until:KR(c)}:W.hours?{since:new Date(Date.now()-W.hours*36e5).toISOString(),until:null}:{since:null,until:null},[r,le,l,c,P]),ae=(B?`&since=${encodeURIComponent(B)}`:"")+(F?`&until=${encodeURIComponent(F)}`:""),Z=(f?`&principal=${encodeURIComponent(f)}`:"")+(m?`&key=${encodeURIComponent(m)}`:"")+(x?`&client=${encodeURIComponent(x)}`:"")+(y?`&model=${encodeURIComponent(y)}`:"")+(j?`&provider=${encodeURIComponent(j)}`:"")+(C?`&tag=${encodeURIComponent(`app:${C}`)}`:"")+(D?`&outcome=${encodeURIComponent(D)}`:""),A=Ut(()=>He.get(`/stats/requests?limit=${O}&offset=${N*O}`+ae+Z),[P,B,F,f,m,x,y,j,C,D,O,N]),U=Ut(()=>He.get("/stats/requests/facets"+(ae?"?"+ae.slice(1):"")),[P,B,F]),V=N===0&&!le;S.useEffect(()=>{if(!V)return;const be=setInterval(ue,3e4);return()=>clearInterval(be)},[V]);function M(be){return mt=>{be(mt),L(0),H(null)}}const se=(((Ie=U.data)==null?void 0:Ie.keys)??[]).map(be=>({value:be.id,label:`${be.principal} · ${be.label||`…${be.key_suffix}`}`})),Y=[...new Set((((Be=U.data)==null?void 0:Be.clients)??[]).map(be=>ao(be)))].sort(),ce=[...new Set((((Mt=U.data)==null?void 0:Mt.tags)??[]).filter(be=>be.startsWith("app:")).map(be=>be.slice(4)))].sort(),re=f||m||x||y||j||C||D;function ye(){h(""),v(""),b(""),k(""),T(""),R(""),I(""),L(0),H(null)}const fe=((Nt=A.data)==null?void 0:Nt.total)??0,we=((Et=A.data)==null?void 0:Et.requests.length)??0,Ee=fe===0?0:N*O+1,Se=Math.max(1,Math.ceil(fe/O));return s.jsxs(Ke,{children:[s.jsxs(Ze,{className:"flex flex-row items-start justify-between",children:[s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(Je,{className:"font-serif",children:"Request explorer"}),s.jsx(it,{children:"Metadata only; content is never stored. Click a row for details."})]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Refresh",onClick:ue,children:s.jsx(pl,{})})]}),s.jsxs(Qe,{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(Hr,{value:r,onValueChange:M(a),children:[s.jsx($r,{className:"w-44","aria-label":"Range",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:qh.map(be=>s.jsx(wr,{value:be.key,children:be.label},be.key))})]}),le&&s.jsxs(s.Fragment,{children:[s.jsx(Wt,{type:"date",className:"w-40","aria-label":"From (UTC)",value:l,onChange:be=>M(o)(be.target.value)}),s.jsx(Wt,{type:"date",className:"w-40","aria-label":"To (UTC)",value:c,onChange:be=>M(d)(be.target.value)})]}),s.jsx(Lt,{label:"User",value:f,onChange:M(h),options:((Bt=U.data)==null?void 0:Bt.principals)??[],allLabel:"All users"}),s.jsx(Lt,{label:"Key",value:m,onChange:M(v),options:se,allLabel:"All keys"}),s.jsx(Lt,{label:"Client",value:x,onChange:M(b),options:Y,allLabel:"All clients"}),s.jsx(Lt,{label:"App",value:C,onChange:M(R),options:ce,allLabel:"All apps"}),s.jsx(Lt,{label:"Model",value:y,onChange:M(k),options:((Rt=U.data)==null?void 0:Rt.models)??[],allLabel:"All models"}),s.jsx(Lt,{label:"Provider",value:j,onChange:M(T),options:((Dt=U.data)==null?void 0:Dt.providers)??[],allLabel:"All providers"}),s.jsx(Lt,{label:"Outcome",value:D,onChange:M(I),options:YR,allLabel:"All outcomes"}),re&&s.jsxs(Me,{variant:"ghost",size:"sm",onClick:ye,children:[s.jsx(yo,{})," Clear filters"]})]}),A.loading&&!A.data?s.jsx(kt,{}):A.error?s.jsx("p",{className:"text-sm text-destructive",children:A.error}):s.jsxs(s.Fragment,{children:[s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{className:"w-6"}),s.jsx(ge,{children:"Time"}),s.jsx(ge,{children:"User"}),s.jsx(ge,{children:"App"}),s.jsx(ge,{children:"Model"}),s.jsx(ge,{children:"Status"}),s.jsx(ge,{className:"text-right",children:"Tokens"}),s.jsx(ge,{className:"text-right",children:"Cost"}),s.jsx(ge,{className:"text-right",children:"First token"}),s.jsx(ge,{className:"text-right",children:"Duration"})]})}),s.jsxs(vn,{children:[we===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:10,className:"text-muted-foreground",children:re||B?"No requests match these filters.":"No requests recorded yet."})}),(zt=A.data)==null?void 0:zt.requests.map(be=>s.jsxs(S.Fragment,{children:[s.jsxs(Oe,{className:"cursor-pointer",onClick:()=>H(X===be.id?null:be.id),children:[s.jsx(de,{className:"pr-0",children:s.jsx("button",{type:"button","aria-label":X===be.id?"Hide details":"Show details","aria-expanded":X===be.id,className:"flex cursor-pointer items-center rounded-sm text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",children:X===be.id?s.jsx(Ji,{className:"size-3.5"}):s.jsx(sm,{className:"size-3.5"})})}),s.jsx(de,{className:"whitespace-nowrap text-xs",title:I0(be.ts),children:QR(be.ts)}),s.jsx(de,{children:s.jsx(JR,{row:be})}),s.jsx(de,{className:"max-w-44",children:s.jsx(WR,{row:be})}),s.jsx(de,{className:"max-w-44 truncate font-mono text-xs",title:be.model||void 0,children:be.model||s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx(de,{children:s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(ZR,{row:be}),be.streamed&&s.jsx("span",{title:"streamed",children:s.jsx(dE,{className:"size-3 text-muted-foreground","aria-label":"streamed"})})]})}),s.jsx(de,{className:"text-right",title:be.units.input_tokens||be.units.output_tokens?`${Ft(be.units.input_tokens)||0} in · ${Ft(be.units.output_tokens)||0} out`+(be.units.cached_input_tokens?` · ${Ft(be.units.cached_input_tokens)} cached`:""):void 0,children:s.jsx(eD,{row:be})}),s.jsx(de,{className:"text-right tabular-nums",children:be.cost!==null?Bm(be.cost):be.unpriced?s.jsx("span",{className:"text-muted-foreground",children:"unpriced"}):s.jsx("span",{className:"text-muted-foreground",children:"—"})}),s.jsx(de,{className:"text-right tabular-nums",children:be.ttft_ms===null?s.jsx("span",{className:"text-muted-foreground",children:"—"}):uo(be.ttft_ms)}),s.jsx(de,{className:"text-right tabular-nums",children:uo(be.duration_ms)})]}),X===be.id&&s.jsxs(Oe,{className:"bg-muted/30 hover:bg-muted/30",children:[s.jsx(de,{}),s.jsx(de,{colSpan:9,children:s.jsx(tD,{row:be})})]})]},be.id))]})]}),s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:fe===0?"No requests":`Showing ${Ht(Ee)}–${Ht(Ee+we-1)} of ${Ht(fe)}`}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Hr,{value:String(O),onValueChange:be=>M(E)(Number(be)),children:[s.jsx($r,{className:"w-32","aria-label":"Page size",children:s.jsx(Pr,{})}),s.jsx(Fr,{children:GR.map(be=>s.jsxs(wr,{value:String(be),children:[be," per page"]},be))})]}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",N+1," of ",Ht(Se)]}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Previous page",disabled:N===0,onClick:()=>{L(N-1),H(null)},children:s.jsx(JN,{})}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Next page",disabled:N+1>=Se,onClick:()=>{L(N+1),H(null)},children:s.jsx(sm,{})})]})]})]})]})]})}function rD(e){return e instanceof Error?e.message:String(e)}function aD(){const{data:e,loading:r,error:a}=Ut(()=>He.get("/admin/v1/principals?limit=500")),l=(e==null?void 0:e.principals.filter(o=>o.kind==="user"))??[];return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Users"}),s.jsx(it,{children:"People appear after their first sign-in."})]}),s.jsx(Qe,{children:r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Name"}),s.jsx(ge,{children:"Role"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[l.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:3,className:"text-muted-foreground",children:"No users yet."})}),l.map(o=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:o.name}),s.jsx(de,{children:o.role==="admin"?s.jsx(pn,{variant:"secondary",children:"admin"}):"member"}),s.jsx(de,{className:"text-right whitespace-nowrap",children:s.jsx(lD,{principal:o})})]},o.id))]})]})})]})}function lD({principal:e}){const r=async()=>{try{await He.post(`/admin/v1/principals/${e.id}/revoke-sessions`),Ve.success(`Signed out ${e.name}`)}catch(a){Ve.error(rD(a))}};return s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Sign out"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Sign out ",e.name," everywhere?"]}),s.jsx(ul,{children:"Their sessions end now. API keys keep working."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:r,children:"Sign out"})]})]})]})}function Hh(e){return e instanceof Error?e.message:String(e)}function iD(){const{data:e,loading:r,error:a,reload:l}=Ut(async()=>{const[{principals:k},{keys:j}]=await Promise.all([He.get("/admin/v1/principals?limit=500"),He.get("/admin/v1/keys?limit=500")]),T=new Set(k.filter(C=>C.kind==="service").map(C=>C.name));return{users:new Set(k.filter(C=>C.kind==="user").map(C=>C.name)),services:T,keys:j.filter(C=>C.principal&&T.has(C.principal))}}),[o,c]=S.useState(""),[d,f]=S.useState(!1),[h,m]=S.useState(null),v=async k=>{const j=await He.post("/admin/v1/keys",{principal:k,label:""});m(j),l()},x=async k=>{if(k.preventDefault(),e!=null&&e.users.has(o)){Ve.error(`"${o}" is a user, not a service`);return}f(!0);try{if(!(e!=null&&e.services.has(o)))try{await He.post("/admin/v1/principals",{name:o,kind:"service",role:"member"})}catch(j){if(!(j instanceof wc&&j.code==="principal_exists"))throw j}await v(o),c("")}catch(j){Ve.error(Hh(j))}finally{f(!1)}},b=async k=>{try{await v(k.principal??""),await He.del(`/admin/v1/keys/${k.id}`),l()}catch(j){Ve.error(Hh(j))}},y=async k=>{try{await He.del(`/admin/v1/keys/${k}`),Ve.success("Key deleted"),l()}catch(j){Ve.error(Hh(j))}};return s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Services"}),s.jsx(it,{children:"API keys for machines and shared tools rather than people."})]}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsxs("form",{onSubmit:x,className:"flex flex-wrap items-center gap-2",children:[s.jsx(Wt,{className:"w-64",placeholder:"Name (e.g. batch-service)",maxLength:120,pattern:"[a-z0-9][a-z0-9._\\-]*",title:"lowercase letters, digits, dots, dashes, underscores",required:!0,value:o,onChange:k=>c(k.target.value)}),s.jsxs(Me,{type:"submit",disabled:d,children:[d&&s.jsx(kt,{}),"Create service"]})]}),h&&s.jsxs("div",{className:"rounded-md border border-primary/40 bg-primary/5 p-4",children:[s.jsxs("p",{className:"mb-2 text-sm font-medium",children:["Key for ",h.principal," — copy it now, it will not be shown again."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"flex-1 overflow-x-auto rounded bg-background px-2 py-1.5 font-mono text-sm",children:h.key}),s.jsx(Me,{variant:"outline",size:"icon-sm","aria-label":"Copy key",onClick:()=>{navigator.clipboard.writeText(h.key??""),Ve.success("Copied to clipboard")},children:s.jsx(Pm,{})})]})]}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Service"}),s.jsx(ge,{children:"Key"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-40"})]})}),s.jsxs(vn,{children:[(e==null?void 0:e.keys.length)===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:5,className:"text-muted-foreground",children:"No services yet."})}),e==null?void 0:e.keys.map(k=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:k.principal}),s.jsxs(de,{className:"font-mono text-xs",children:["***",k.key_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(k.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(k.last_used_at)||"never"}),s.jsxs(de,{className:"text-right whitespace-nowrap",children:[s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Rotate"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Rotate the key of ",k.principal,"?"]}),s.jsx(ul,{children:"The old key stops working immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>b(k),children:"Rotate"})]})]})]}),s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Delete ",k.principal,"?"]}),s.jsx(ul,{children:"Its key stops working immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>y(k.id),children:"Delete"})]})]})]})]})]},k.id))]})]})]})]})}function sD(){const{data:e,loading:r,error:a,reload:l}=Ut(()=>He.get("/admin/v1/keys?limit=500")),[o,c]=S.useState(""),d=o.trim().toLowerCase(),f=((e==null?void 0:e.keys)??[]).filter(m=>`${m.principal} ${m.label} ${m.key_suffix}`.toLowerCase().includes(d)),h=async m=>{try{await He.del(`/admin/v1/keys/${m}`),Ve.success("Key deleted"),l()}catch(v){Ve.error(v instanceof Error?v.message:String(v))}};return s.jsxs(Ke,{children:[s.jsx(Ze,{children:s.jsx(Je,{className:"font-serif",children:"All keys"})}),s.jsxs(Qe,{className:"flex flex-col gap-4",children:[s.jsx(Wt,{className:"w-64",placeholder:"Filter by owner, label or suffix",value:o,onChange:m=>c(m.target.value)}),r&&!e?s.jsx(kt,{}):a?s.jsx("p",{className:"text-sm text-destructive",children:a}):s.jsxs(gn,{children:[s.jsx(xn,{children:s.jsxs(Oe,{children:[s.jsx(ge,{children:"Owner"}),s.jsx(ge,{children:"Label"}),s.jsx(ge,{children:"Key"}),s.jsx(ge,{children:"Created"}),s.jsx(ge,{children:"Last used"}),s.jsx(ge,{className:"w-24"})]})}),s.jsxs(vn,{children:[f.length===0&&s.jsx(Oe,{children:s.jsx(de,{colSpan:6,className:"text-muted-foreground",children:e!=null&&e.keys.length?"No match.":"No keys yet."})}),f.map(m=>s.jsxs(Oe,{children:[s.jsx(de,{className:"wrap-anywhere",children:m.principal}),s.jsx(de,{className:"wrap-anywhere",children:m.label||s.jsx("span",{className:"text-muted-foreground",children:"(no label)"})}),s.jsxs(de,{className:"font-mono text-xs",children:["***",m.key_suffix]}),s.jsx(de,{className:"whitespace-nowrap",children:tl(m.created_at)}),s.jsx(de,{className:"whitespace-nowrap",children:tl(m.last_used_at)||"never"}),s.jsx(de,{className:"whitespace-nowrap",children:s.jsxs(rl,{children:[s.jsx(al,{asChild:!0,children:s.jsx(Me,{variant:"ghost",size:"sm",children:"Delete"})}),s.jsxs(ll,{children:[s.jsxs(il,{children:[s.jsxs(ol,{children:["Delete this key of ",m.principal,"?"]}),s.jsx(ul,{children:"It stops working immediately."})]}),s.jsxs(sl,{children:[s.jsx(dl,{children:"Cancel"}),s.jsx(cl,{onClick:()=>h(m.id),children:"Delete"})]})]})]})})]},m.id))]})]})]})]})}function oD(e,r){const a={};return(e[e.length-1]===""?[...e,""]:e).join((a.padRight?" ":"")+","+(a.padLeft===!1?"":" ")).trim()}const uD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dD={};function $b(e,r){return(dD.jsx?cD:uD).test(e)}const fD=/[ \t\n\f\r]/g;function hD(e){return typeof e=="object"?e.type==="text"?Fb(e.value):!1:Fb(e)}function Fb(e){return e.replace(fD,"")===""}class wo{constructor(r,a,l){this.normal=a,this.property=r,l&&(this.space=l)}}wo.prototype.normal={};wo.prototype.property={};wo.prototype.space=void 0;function _S(e,r){const a={},l={};for(const o of e)Object.assign(a,o.property),Object.assign(l,o.normal);return new wo(a,l,r)}function km(e){return e.toLowerCase()}class qn{constructor(r,a){this.attribute=a,this.property=r}}qn.prototype.attribute="";qn.prototype.booleanish=!1;qn.prototype.boolean=!1;qn.prototype.commaOrSpaceSeparated=!1;qn.prototype.commaSeparated=!1;qn.prototype.defined=!1;qn.prototype.mustUseProperty=!1;qn.prototype.number=!1;qn.prototype.overloadedBoolean=!1;qn.prototype.property="";qn.prototype.spaceSeparated=!1;qn.prototype.space=void 0;let mD=0;const $e=Zl(),Qt=Zl(),Cm=Zl(),xe=Zl(),jt=Zl(),$l=Zl(),Kn=Zl();function Zl(){return 2**++mD}const Nm=Object.freeze(Object.defineProperty({__proto__:null,boolean:$e,booleanish:Qt,commaOrSpaceSeparated:Kn,commaSeparated:$l,number:xe,overloadedBoolean:Cm,spaceSeparated:jt},Symbol.toStringTag,{value:"Module"})),Ph=Object.keys(Nm);class vp extends qn{constructor(r,a,l,o){let c=-1;if(super(r,a),Vb(this,"space",o),typeof l=="number")for(;++c4&&a.slice(0,4)==="data"&&yD.test(r)){if(r.charAt(4)==="-"){const c=r.slice(5).replace(Gb,SD);l="data"+c.charAt(0).toUpperCase()+c.slice(1)}else{const c=r.slice(4);if(!Gb.test(c)){let d=c.replace(vD,wD);d.charAt(0)!=="-"&&(d="-"+d),r="data"+d}}o=vp}return new o(l,r)}function wD(e){return"-"+e.toLowerCase()}function SD(e){return e.charAt(1).toUpperCase()}const jD=_S([MS,pD,OS,zS,LS],"html"),yp=_S([MS,gD,OS,zS,LS],"svg");function kD(e){return e.join(" ").trim()}var Vi={},$h,Yb;function CD(){if(Yb)return $h;Yb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,a=/^\s*/,l=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,c=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,d=/^[;\s]*/,f=/^\s+|\s+$/g,h=` -`,m="/",v="*",x="",b="comment",y="declaration";function k(T,C){if(typeof T!="string")throw new TypeError("First argument must be a string");if(!T)return[];C=C||{};var R=1,D=1;function I(le){var W=le.match(r);W&&(R+=W.length);var B=le.lastIndexOf(h);D=~B?le.length-B:D+le.length}function O(){var le={line:R,column:D};return function(W){return W.position=new E(le),X(),W}}function E(le){this.start=le,this.end={line:R,column:D},this.source=C.source}E.prototype.content=T;function N(le){var W=new Error(C.source+":"+R+":"+D+": "+le);if(W.reason=le,W.filename=C.source,W.line=R,W.column=D,W.source=T,!C.silent)throw W}function L(le){var W=le.exec(T);if(W){var B=W[0];return I(B),T=T.slice(B.length),W}}function X(){L(a)}function H(le){var W;for(le=le||[];W=P();)W!==!1&&le.push(W);return le}function P(){var le=O();if(!(m!=T.charAt(0)||v!=T.charAt(1))){for(var W=2;x!=T.charAt(W)&&(v!=T.charAt(W)||m!=T.charAt(W+1));)++W;if(W+=2,x===T.charAt(W-1))return N("End of comment missing");var B=T.slice(2,W-2);return D+=2,I(B),T=T.slice(W),D+=2,le({type:b,comment:B})}}function K(){var le=O(),W=L(l);if(W){if(P(),!L(o))return N("property missing ':'");var B=L(c),F=le({type:y,property:j(W[0].replace(e,x)),value:B?j(B[0].replace(e,x)):x});return L(d),F}}function ue(){var le=[];H(le);for(var W;W=K();)W!==!1&&(le.push(W),H(le));return le}return X(),ue()}function j(T){return T?T.replace(f,x):x}return $h=k,$h}var Xb;function ND(){if(Xb)return Vi;Xb=1;var e=Vi&&Vi.__importDefault||function(l){return l&&l.__esModule?l:{default:l}};Object.defineProperty(Vi,"__esModule",{value:!0}),Vi.default=a;const r=e(CD());function a(l,o){let c=null;if(!l||typeof l!="string")return c;const d=(0,r.default)(l),f=typeof o=="function";return d.forEach(h=>{if(h.type!=="declaration")return;const{property:m,value:v}=h;f?o(m,v,h):v&&(c=c||{},c[m]=v)}),c}return Vi}var Zs={},Kb;function ED(){if(Kb)return Zs;Kb=1,Object.defineProperty(Zs,"__esModule",{value:!0}),Zs.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,r=/-([a-z])/g,a=/^[^-]+$/,l=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,c=function(m){return!m||a.test(m)||e.test(m)},d=function(m,v){return v.toUpperCase()},f=function(m,v){return"".concat(v,"-")},h=function(m,v){return v===void 0&&(v={}),c(m)?m:(m=m.toLowerCase(),v.reactCompat?m=m.replace(o,f):m=m.replace(l,f),m.replace(r,d))};return Zs.camelCase=h,Zs}var Js,Qb;function TD(){if(Qb)return Js;Qb=1;var e=Js&&Js.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},r=e(ND()),a=ED();function l(o,c){var d={};return!o||typeof o!="string"||(0,r.default)(o,function(f,h){f&&h&&(d[(0,a.camelCase)(f,c)]=h)}),d}return l.default=l,Js=l,Js}var AD=TD();const _D=bc(AD),US=BS("end"),bp=BS("start");function BS(e){return r;function r(a){const l=a&&a.position&&a.position[e]||{};if(typeof l.line=="number"&&l.line>0&&typeof l.column=="number"&&l.column>0)return{line:l.line,column:l.column,offset:typeof l.offset=="number"&&l.offset>-1?l.offset:void 0}}}function MD(e){const r=bp(e),a=US(e);if(r&&a)return{start:r,end:a}}function io(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Zb(e.position):"start"in e||"end"in e?Zb(e):"line"in e||"column"in e?Em(e):""}function Em(e){return Jb(e&&e.line)+":"+Jb(e&&e.column)}function Zb(e){return Em(e&&e.start)+"-"+Em(e&&e.end)}function Jb(e){return e&&typeof e=="number"?e:1}class Sn extends Error{constructor(r,a,l){super(),typeof a=="string"&&(l=a,a=void 0);let o="",c={},d=!1;if(a&&("line"in a&&"column"in a?c={place:a}:"start"in a&&"end"in a?c={place:a}:"type"in a?c={ancestors:[a],place:a.position}:c={...a}),typeof r=="string"?o=r:!c.cause&&r&&(d=!0,o=r.message,c.cause=r),!c.ruleId&&!c.source&&typeof l=="string"){const h=l.indexOf(":");h===-1?c.ruleId=l:(c.source=l.slice(0,h),c.ruleId=l.slice(h+1))}if(!c.place&&c.ancestors&&c.ancestors){const h=c.ancestors[c.ancestors.length-1];h&&(c.place=h.position)}const f=c.place&&"start"in c.place?c.place.start:c.place;this.ancestors=c.ancestors||void 0,this.cause=c.cause||void 0,this.column=f?f.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=f?f.line:void 0,this.name=io(c.place)||"1:1",this.place=c.place||void 0,this.reason=this.message,this.ruleId=c.ruleId||void 0,this.source=c.source||void 0,this.stack=d&&c.cause&&typeof c.cause.stack=="string"?c.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const wp={}.hasOwnProperty,RD=new Map,DD=/[A-Z]/g,OD=new Set(["table","tbody","thead","tfoot","tr"]),zD=new Set(["td","th"]),IS="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function LD(e,r){if(!r||r.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const a=r.filePath||void 0;let l;if(r.development){if(typeof r.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");l=FD(a,r.jsxDEV)}else{if(typeof r.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof r.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");l=$D(a,r.jsx,r.jsxs)}const o={Fragment:r.Fragment,ancestors:[],components:r.components||{},create:l,elementAttributeNameCase:r.elementAttributeNameCase||"react",evaluater:r.createEvaluater?r.createEvaluater():void 0,filePath:a,ignoreInvalidStyle:r.ignoreInvalidStyle||!1,passKeys:r.passKeys!==!1,passNode:r.passNode||!1,schema:r.space==="svg"?yp:jD,stylePropertyNameCase:r.stylePropertyNameCase||"dom",tableCellAlignToStyle:r.tableCellAlignToStyle!==!1},c=qS(o,e,void 0);return c&&typeof c!="string"?c:o.create(e,o.Fragment,{children:c||void 0},void 0)}function qS(e,r,a){if(r.type==="element")return UD(e,r,a);if(r.type==="mdxFlowExpression"||r.type==="mdxTextExpression")return BD(e,r);if(r.type==="mdxJsxFlowElement"||r.type==="mdxJsxTextElement")return qD(e,r,a);if(r.type==="mdxjsEsm")return ID(e,r);if(r.type==="root")return HD(e,r,a);if(r.type==="text")return PD(e,r)}function UD(e,r,a){const l=e.schema;let o=l;r.tagName.toLowerCase()==="svg"&&l.space==="html"&&(o=yp,e.schema=o),e.ancestors.push(r);const c=PS(e,r.tagName,!1),d=VD(e,r);let f=jp(e,r);return OD.has(r.tagName)&&(f=f.filter(function(h){return typeof h=="string"?!hD(h):!0})),HS(e,d,c,r),Sp(d,f),e.ancestors.pop(),e.schema=l,e.create(r,c,d,a)}function BD(e,r){if(r.data&&r.data.estree&&e.evaluater){const l=r.data.estree.body[0];return l.type,e.evaluater.evaluateExpression(l.expression)}mo(e,r.position)}function ID(e,r){if(r.data&&r.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(r.data.estree);mo(e,r.position)}function qD(e,r,a){const l=e.schema;let o=l;r.name==="svg"&&l.space==="html"&&(o=yp,e.schema=o),e.ancestors.push(r);const c=r.name===null?e.Fragment:PS(e,r.name,!0),d=GD(e,r),f=jp(e,r);return HS(e,d,c,r),Sp(d,f),e.ancestors.pop(),e.schema=l,e.create(r,c,d,a)}function HD(e,r,a){const l={};return Sp(l,jp(e,r)),e.create(r,e.Fragment,l,a)}function PD(e,r){return r.value}function HS(e,r,a,l){typeof a!="string"&&a!==e.Fragment&&e.passNode&&(r.node=l)}function Sp(e,r){if(r.length>0){const a=r.length>1?r:r[0];a&&(e.children=a)}}function $D(e,r,a){return l;function l(o,c,d,f){const m=Array.isArray(d.children)?a:r;return f?m(c,d,f):m(c,d)}}function FD(e,r){return a;function a(l,o,c,d){const f=Array.isArray(c.children),h=bp(l);return r(o,c,d,f,{columnNumber:h?h.column-1:void 0,fileName:e,lineNumber:h?h.line:void 0},void 0)}}function VD(e,r){const a={};let l,o;for(o in r.properties)if(o!=="children"&&wp.call(r.properties,o)){const c=YD(e,o,r.properties[o]);if(c){const[d,f]=c;e.tableCellAlignToStyle&&d==="align"&&typeof f=="string"&&zD.has(r.tagName)?l=f:a[d]=f}}if(l){const c=a.style||(a.style={});c[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=l}return a}function GD(e,r){const a={};for(const l of r.attributes)if(l.type==="mdxJsxExpressionAttribute")if(l.data&&l.data.estree&&e.evaluater){const c=l.data.estree.body[0];c.type;const d=c.expression;d.type;const f=d.properties[0];f.type,Object.assign(a,e.evaluater.evaluateExpression(f.argument))}else mo(e,r.position);else{const o=l.name;let c;if(l.value&&typeof l.value=="object")if(l.value.data&&l.value.data.estree&&e.evaluater){const f=l.value.data.estree.body[0];f.type,c=e.evaluater.evaluateExpression(f.expression)}else mo(e,r.position);else c=l.value===null?!0:l.value;a[o]=c}return a}function jp(e,r){const a=[];let l=-1;const o=e.passKeys?new Map:RD;for(;++lo?0:o+r:r=r>o?o:r,a=a>0?a:0,l.length<1e4)d=Array.from(l),d.unshift(r,a),e.splice(...d);else for(a&&e.splice(r,a);c0?(Zn(e,e.length,0,r),e):r}const t0={}.hasOwnProperty;function FS(e){const r={};let a=-1;for(;++a13&&a<32||a>126&&a<160||a>55295&&a<57344||a>64975&&a<65008||(a&65535)===65535||(a&65535)===65534||a>1114111?"�":String.fromCodePoint(a)}function br(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Cn=yl(/[A-Za-z]/),wn=yl(/[\dA-Za-z]/),nO=yl(/[#-'*+\--9=?A-Z^-~]/);function mc(e){return e!==null&&(e<32||e===127)}const Tm=yl(/\d/),rO=yl(/[\dA-Fa-f]/),aO=yl(/[!-/:-@[-`{-~]/);function Le(e){return e!==null&&e<-2}function Ct(e){return e!==null&&(e<0||e===32)}function nt(e){return e===-2||e===-1||e===32}const Fc=yl(new RegExp("\\p{P}|\\p{S}","u")),Kl=yl(/\s/);function yl(e){return r;function r(a){return a!==null&&a>-1&&e.test(String.fromCharCode(a))}}function rs(e){const r=[];let a=-1,l=0,o=0;for(;++a55295&&c<57344){const f=e.charCodeAt(a+1);c<56320&&f>56319&&f<57344?(d=String.fromCharCode(c,f),o=1):d="�"}else d=String.fromCharCode(c);d&&(r.push(e.slice(l,a),encodeURIComponent(d)),l=a+o+1,d=""),o&&(a+=o,o=0)}return r.join("")+e.slice(l)}function ot(e,r,a,l){const o=l?l-1:Number.POSITIVE_INFINITY;let c=0;return d;function d(h){return nt(h)?(e.enter(a),f(h)):r(h)}function f(h){return nt(h)&&c++d))return;const N=r.events.length;let L=N,X,H;for(;L--;)if(r.events[L][0]==="exit"&&r.events[L][1].type==="chunkFlow"){if(X){H=r.events[L][1].end;break}X=!0}for(C(l),E=N;ED;){const O=a[I];r.containerState=O[1],O[0].exit.call(r,e)}a.length=D}function R(){o.write([null]),c=void 0,o=void 0,r.containerState._closeFlow=void 0}}function uO(e,r,a){return ot(e,e.attempt(this.parser.constructs.document,r,a),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Zi(e){if(e===null||Ct(e)||Kl(e))return 1;if(Fc(e))return 2}function Vc(e,r,a){const l=[];let o=-1;for(;++o1&&e[a][1].end.offset-e[a][1].start.offset>1?2:1;const x={...e[l][1].end},b={...e[a][1].start};r0(x,-h),r0(b,h),d={type:h>1?"strongSequence":"emphasisSequence",start:x,end:{...e[l][1].end}},f={type:h>1?"strongSequence":"emphasisSequence",start:{...e[a][1].start},end:b},c={type:h>1?"strongText":"emphasisText",start:{...e[l][1].end},end:{...e[a][1].start}},o={type:h>1?"strong":"emphasis",start:{...d.start},end:{...f.end}},e[l][1].end={...d.start},e[a][1].start={...f.end},m=[],e[l][1].end.offset-e[l][1].start.offset&&(m=ur(m,[["enter",e[l][1],r],["exit",e[l][1],r]])),m=ur(m,[["enter",o,r],["enter",d,r],["exit",d,r],["enter",c,r]]),m=ur(m,Vc(r.parser.constructs.insideSpan.null,e.slice(l+1,a),r)),m=ur(m,[["exit",c,r],["enter",f,r],["exit",f,r],["exit",o,r]]),e[a][1].end.offset-e[a][1].start.offset?(v=2,m=ur(m,[["enter",e[a][1],r],["exit",e[a][1],r]])):v=0,Zn(e,l-1,a-l+3,m),a=l+m.length-v-2;break}}for(a=-1;++a0&&nt(E)?ot(e,R,"linePrefix",c+1)(E):R(E)}function R(E){return E===null||Le(E)?e.check(a0,j,I)(E):(e.enter("codeFlowValue"),D(E))}function D(E){return E===null||Le(E)?(e.exit("codeFlowValue"),R(E)):(e.consume(E),D)}function I(E){return e.exit("codeFenced"),r(E)}function O(E,N,L){let X=0;return H;function H(W){return E.enter("lineEnding"),E.consume(W),E.exit("lineEnding"),P}function P(W){return E.enter("codeFencedFence"),nt(W)?ot(E,K,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(W):K(W)}function K(W){return W===f?(E.enter("codeFencedFenceSequence"),ue(W)):L(W)}function ue(W){return W===f?(X++,E.consume(W),ue):X>=d?(E.exit("codeFencedFenceSequence"),nt(W)?ot(E,le,"whitespace")(W):le(W)):L(W)}function le(W){return W===null||Le(W)?(E.exit("codeFencedFence"),N(W)):L(W)}}}function wO(e,r,a){const l=this;return o;function o(d){return d===null?a(d):(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c)}function c(d){return l.parser.lazy[l.now().line]?a(d):r(d)}}const Vh={name:"codeIndented",tokenize:jO},SO={partial:!0,tokenize:kO};function jO(e,r,a){const l=this;return o;function o(m){return e.enter("codeIndented"),ot(e,c,"linePrefix",5)(m)}function c(m){const v=l.events[l.events.length-1];return v&&v[1].type==="linePrefix"&&v[2].sliceSerialize(v[1],!0).length>=4?d(m):a(m)}function d(m){return m===null?h(m):Le(m)?e.attempt(SO,d,h)(m):(e.enter("codeFlowValue"),f(m))}function f(m){return m===null||Le(m)?(e.exit("codeFlowValue"),d(m)):(e.consume(m),f)}function h(m){return e.exit("codeIndented"),r(m)}}function kO(e,r,a){const l=this;return o;function o(d){return l.parser.lazy[l.now().line]?a(d):Le(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),o):ot(e,c,"linePrefix",5)(d)}function c(d){const f=l.events[l.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?r(d):Le(d)?o(d):a(d)}}const CO={name:"codeText",previous:EO,resolve:NO,tokenize:TO};function NO(e){let r=e.length-4,a=3,l,o;if((e[a][1].type==="lineEnding"||e[a][1].type==="space")&&(e[r][1].type==="lineEnding"||e[r][1].type==="space")){for(l=a;++l=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+r+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return rthis.left.length?this.right.slice(this.right.length-l+this.left.length,this.right.length-r+this.left.length).reverse():this.left.slice(r).concat(this.right.slice(this.right.length-l+this.left.length).reverse())}splice(r,a,l){const o=a||0;this.setCursor(Math.trunc(r));const c=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return l&&Ws(this.left,l),c.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(r){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(r)}pushMany(r){this.setCursor(Number.POSITIVE_INFINITY),Ws(this.left,r)}unshift(r){this.setCursor(0),this.right.push(r)}unshiftMany(r){this.setCursor(0),Ws(this.right,r.reverse())}setCursor(r){if(!(r===this.left.length||r>this.left.length&&this.right.length===0||r<0&&this.left.length===0))if(r=4?r(d):e.interrupt(l.parser.constructs.flow,a,r)(d)}}function QS(e,r,a,l,o,c,d,f,h){const m=h||Number.POSITIVE_INFINITY;let v=0;return x;function x(C){return C===60?(e.enter(l),e.enter(o),e.enter(c),e.consume(C),e.exit(c),b):C===null||C===32||C===41||mc(C)?a(C):(e.enter(l),e.enter(d),e.enter(f),e.enter("chunkString",{contentType:"string"}),j(C))}function b(C){return C===62?(e.enter(c),e.consume(C),e.exit(c),e.exit(o),e.exit(l),r):(e.enter(f),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===62?(e.exit("chunkString"),e.exit(f),b(C)):C===null||C===60||Le(C)?a(C):(e.consume(C),C===92?k:y)}function k(C){return C===60||C===62||C===92?(e.consume(C),y):y(C)}function j(C){return!v&&(C===null||C===41||Ct(C))?(e.exit("chunkString"),e.exit(f),e.exit(d),e.exit(l),r(C)):v999||y===null||y===91||y===93&&!h||y===94&&!f&&"_hiddenFootnoteSupport"in d.parser.constructs?a(y):y===93?(e.exit(c),e.enter(o),e.consume(y),e.exit(o),e.exit(l),r):Le(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),v):(e.enter("chunkString",{contentType:"string"}),x(y))}function x(y){return y===null||y===91||y===93||Le(y)||f++>999?(e.exit("chunkString"),v(y)):(e.consume(y),h||(h=!nt(y)),y===92?b:x)}function b(y){return y===91||y===92||y===93?(e.consume(y),f++,x):x(y)}}function JS(e,r,a,l,o,c){let d;return f;function f(b){return b===34||b===39||b===40?(e.enter(l),e.enter(o),e.consume(b),e.exit(o),d=b===40?41:b,h):a(b)}function h(b){return b===d?(e.enter(o),e.consume(b),e.exit(o),e.exit(l),r):(e.enter(c),m(b))}function m(b){return b===d?(e.exit(c),h(d)):b===null?a(b):Le(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),ot(e,m,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),v(b))}function v(b){return b===d||b===null||Le(b)?(e.exit("chunkString"),m(b)):(e.consume(b),b===92?x:v)}function x(b){return b===d||b===92?(e.consume(b),v):v(b)}}function so(e,r){let a;return l;function l(o){return Le(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a=!0,l):nt(o)?ot(e,l,a?"linePrefix":"lineSuffix")(o):r(o)}}const LO={name:"definition",tokenize:BO},UO={partial:!0,tokenize:IO};function BO(e,r,a){const l=this;let o;return c;function c(y){return e.enter("definition"),d(y)}function d(y){return ZS.call(l,e,f,a,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function f(y){return o=br(l.sliceSerialize(l.events[l.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),h):a(y)}function h(y){return Ct(y)?so(e,m)(y):m(y)}function m(y){return QS(e,v,a,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function v(y){return e.attempt(UO,x,x)(y)}function x(y){return nt(y)?ot(e,b,"whitespace")(y):b(y)}function b(y){return y===null||Le(y)?(e.exit("definition"),l.parser.defined.push(o),r(y)):a(y)}}function IO(e,r,a){return l;function l(f){return Ct(f)?so(e,o)(f):a(f)}function o(f){return JS(e,c,a,"definitionTitle","definitionTitleMarker","definitionTitleString")(f)}function c(f){return nt(f)?ot(e,d,"whitespace")(f):d(f)}function d(f){return f===null||Le(f)?r(f):a(f)}}const qO={name:"hardBreakEscape",tokenize:HO};function HO(e,r,a){return l;function l(c){return e.enter("hardBreakEscape"),e.consume(c),o}function o(c){return Le(c)?(e.exit("hardBreakEscape"),r(c)):a(c)}}const PO={name:"headingAtx",resolve:$O,tokenize:FO};function $O(e,r){let a=e.length-2,l=3,o,c;return e[l][1].type==="whitespace"&&(l+=2),a-2>l&&e[a][1].type==="whitespace"&&(a-=2),e[a][1].type==="atxHeadingSequence"&&(l===a-1||a-4>l&&e[a-2][1].type==="whitespace")&&(a-=l+1===a?2:4),a>l&&(o={type:"atxHeadingText",start:e[l][1].start,end:e[a][1].end},c={type:"chunkText",start:e[l][1].start,end:e[a][1].end,contentType:"text"},Zn(e,l,a-l+1,[["enter",o,r],["enter",c,r],["exit",c,r],["exit",o,r]])),e}function FO(e,r,a){let l=0;return o;function o(v){return e.enter("atxHeading"),c(v)}function c(v){return e.enter("atxHeadingSequence"),d(v)}function d(v){return v===35&&l++<6?(e.consume(v),d):v===null||Ct(v)?(e.exit("atxHeadingSequence"),f(v)):a(v)}function f(v){return v===35?(e.enter("atxHeadingSequence"),h(v)):v===null||Le(v)?(e.exit("atxHeading"),r(v)):nt(v)?ot(e,f,"whitespace")(v):(e.enter("atxHeadingText"),m(v))}function h(v){return v===35?(e.consume(v),h):(e.exit("atxHeadingSequence"),f(v))}function m(v){return v===null||v===35||Ct(v)?(e.exit("atxHeadingText"),f(v)):(e.consume(v),m)}}const VO=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],i0=["pre","script","style","textarea"],GO={concrete:!0,name:"htmlFlow",resolveTo:KO,tokenize:QO},YO={partial:!0,tokenize:JO},XO={partial:!0,tokenize:ZO};function KO(e){let r=e.length;for(;r--&&!(e[r][0]==="enter"&&e[r][1].type==="htmlFlow"););return r>1&&e[r-2][1].type==="linePrefix"&&(e[r][1].start=e[r-2][1].start,e[r+1][1].start=e[r-2][1].start,e.splice(r-2,2)),e}function QO(e,r,a){const l=this;let o,c,d,f,h;return m;function m(M){return v(M)}function v(M){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(M),x}function x(M){return M===33?(e.consume(M),b):M===47?(e.consume(M),c=!0,j):M===63?(e.consume(M),o=3,l.interrupt?r:A):Cn(M)?(e.consume(M),d=String.fromCharCode(M),T):a(M)}function b(M){return M===45?(e.consume(M),o=2,y):M===91?(e.consume(M),o=5,f=0,k):Cn(M)?(e.consume(M),o=4,l.interrupt?r:A):a(M)}function y(M){return M===45?(e.consume(M),l.interrupt?r:A):a(M)}function k(M){const se="CDATA[";return M===se.charCodeAt(f++)?(e.consume(M),f===se.length?l.interrupt?r:K:k):a(M)}function j(M){return Cn(M)?(e.consume(M),d=String.fromCharCode(M),T):a(M)}function T(M){if(M===null||M===47||M===62||Ct(M)){const se=M===47,Y=d.toLowerCase();return!se&&!c&&i0.includes(Y)?(o=1,l.interrupt?r(M):K(M)):VO.includes(d.toLowerCase())?(o=6,se?(e.consume(M),C):l.interrupt?r(M):K(M)):(o=7,l.interrupt&&!l.parser.lazy[l.now().line]?a(M):c?R(M):D(M))}return M===45||wn(M)?(e.consume(M),d+=String.fromCharCode(M),T):a(M)}function C(M){return M===62?(e.consume(M),l.interrupt?r:K):a(M)}function R(M){return nt(M)?(e.consume(M),R):H(M)}function D(M){return M===47?(e.consume(M),H):M===58||M===95||Cn(M)?(e.consume(M),I):nt(M)?(e.consume(M),D):H(M)}function I(M){return M===45||M===46||M===58||M===95||wn(M)?(e.consume(M),I):O(M)}function O(M){return M===61?(e.consume(M),E):nt(M)?(e.consume(M),O):D(M)}function E(M){return M===null||M===60||M===61||M===62||M===96?a(M):M===34||M===39?(e.consume(M),h=M,N):nt(M)?(e.consume(M),E):L(M)}function N(M){return M===h?(e.consume(M),h=null,X):M===null||Le(M)?a(M):(e.consume(M),N)}function L(M){return M===null||M===34||M===39||M===47||M===60||M===61||M===62||M===96||Ct(M)?O(M):(e.consume(M),L)}function X(M){return M===47||M===62||nt(M)?D(M):a(M)}function H(M){return M===62?(e.consume(M),P):a(M)}function P(M){return M===null||Le(M)?K(M):nt(M)?(e.consume(M),P):a(M)}function K(M){return M===45&&o===2?(e.consume(M),B):M===60&&o===1?(e.consume(M),F):M===62&&o===4?(e.consume(M),U):M===63&&o===3?(e.consume(M),A):M===93&&o===5?(e.consume(M),Z):Le(M)&&(o===6||o===7)?(e.exit("htmlFlowData"),e.check(YO,V,ue)(M)):M===null||Le(M)?(e.exit("htmlFlowData"),ue(M)):(e.consume(M),K)}function ue(M){return e.check(XO,le,V)(M)}function le(M){return e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),W}function W(M){return M===null||Le(M)?ue(M):(e.enter("htmlFlowData"),K(M))}function B(M){return M===45?(e.consume(M),A):K(M)}function F(M){return M===47?(e.consume(M),d="",ae):K(M)}function ae(M){if(M===62){const se=d.toLowerCase();return i0.includes(se)?(e.consume(M),U):K(M)}return Cn(M)&&d.length<8?(e.consume(M),d+=String.fromCharCode(M),ae):K(M)}function Z(M){return M===93?(e.consume(M),A):K(M)}function A(M){return M===62?(e.consume(M),U):M===45&&o===2?(e.consume(M),A):K(M)}function U(M){return M===null||Le(M)?(e.exit("htmlFlowData"),V(M)):(e.consume(M),U)}function V(M){return e.exit("htmlFlow"),r(M)}}function ZO(e,r,a){const l=this;return o;function o(d){return Le(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),c):a(d)}function c(d){return l.parser.lazy[l.now().line]?a(d):r(d)}}function JO(e,r,a){return l;function l(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(So,r,a)}}const WO={name:"htmlText",tokenize:ez};function ez(e,r,a){const l=this;let o,c,d;return f;function f(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),h}function h(A){return A===33?(e.consume(A),m):A===47?(e.consume(A),O):A===63?(e.consume(A),D):Cn(A)?(e.consume(A),L):a(A)}function m(A){return A===45?(e.consume(A),v):A===91?(e.consume(A),c=0,k):Cn(A)?(e.consume(A),R):a(A)}function v(A){return A===45?(e.consume(A),y):a(A)}function x(A){return A===null?a(A):A===45?(e.consume(A),b):Le(A)?(d=x,F(A)):(e.consume(A),x)}function b(A){return A===45?(e.consume(A),y):x(A)}function y(A){return A===62?B(A):A===45?b(A):x(A)}function k(A){const U="CDATA[";return A===U.charCodeAt(c++)?(e.consume(A),c===U.length?j:k):a(A)}function j(A){return A===null?a(A):A===93?(e.consume(A),T):Le(A)?(d=j,F(A)):(e.consume(A),j)}function T(A){return A===93?(e.consume(A),C):j(A)}function C(A){return A===62?B(A):A===93?(e.consume(A),C):j(A)}function R(A){return A===null||A===62?B(A):Le(A)?(d=R,F(A)):(e.consume(A),R)}function D(A){return A===null?a(A):A===63?(e.consume(A),I):Le(A)?(d=D,F(A)):(e.consume(A),D)}function I(A){return A===62?B(A):D(A)}function O(A){return Cn(A)?(e.consume(A),E):a(A)}function E(A){return A===45||wn(A)?(e.consume(A),E):N(A)}function N(A){return Le(A)?(d=N,F(A)):nt(A)?(e.consume(A),N):B(A)}function L(A){return A===45||wn(A)?(e.consume(A),L):A===47||A===62||Ct(A)?X(A):a(A)}function X(A){return A===47?(e.consume(A),B):A===58||A===95||Cn(A)?(e.consume(A),H):Le(A)?(d=X,F(A)):nt(A)?(e.consume(A),X):B(A)}function H(A){return A===45||A===46||A===58||A===95||wn(A)?(e.consume(A),H):P(A)}function P(A){return A===61?(e.consume(A),K):Le(A)?(d=P,F(A)):nt(A)?(e.consume(A),P):X(A)}function K(A){return A===null||A===60||A===61||A===62||A===96?a(A):A===34||A===39?(e.consume(A),o=A,ue):Le(A)?(d=K,F(A)):nt(A)?(e.consume(A),K):(e.consume(A),le)}function ue(A){return A===o?(e.consume(A),o=void 0,W):A===null?a(A):Le(A)?(d=ue,F(A)):(e.consume(A),ue)}function le(A){return A===null||A===34||A===39||A===60||A===61||A===96?a(A):A===47||A===62||Ct(A)?X(A):(e.consume(A),le)}function W(A){return A===47||A===62||Ct(A)?X(A):a(A)}function B(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),r):a(A)}function F(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),ae}function ae(A){return nt(A)?ot(e,Z,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):Z(A)}function Z(A){return e.enter("htmlTextData"),d(A)}}const Np={name:"labelEnd",resolveAll:az,resolveTo:lz,tokenize:iz},tz={tokenize:sz},nz={tokenize:oz},rz={tokenize:uz};function az(e){let r=-1;const a=[];for(;++r=3&&(m===null||Le(m))?(e.exit("thematicBreak"),r(m)):a(m)}function h(m){return m===o?(e.consume(m),l++,h):(e.exit("thematicBreakSequence"),nt(m)?ot(e,f,"whitespace")(m):f(m))}}const Un={continuation:{tokenize:yz},exit:wz,name:"list",tokenize:vz},gz={partial:!0,tokenize:Sz},xz={partial:!0,tokenize:bz};function vz(e,r,a){const l=this,o=l.events[l.events.length-1];let c=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,d=0;return f;function f(y){const k=l.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(k==="listUnordered"?!l.containerState.marker||y===l.containerState.marker:Tm(y)){if(l.containerState.type||(l.containerState.type=k,e.enter(k,{_container:!0})),k==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(ic,a,m)(y):m(y);if(!l.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),h(y)}return a(y)}function h(y){return Tm(y)&&++d<10?(e.consume(y),h):(!l.interrupt||d<2)&&(l.containerState.marker?y===l.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),m(y)):a(y)}function m(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),l.containerState.marker=l.containerState.marker||y,e.check(So,l.interrupt?a:v,e.attempt(gz,b,x))}function v(y){return l.containerState.initialBlankLine=!0,c++,b(y)}function x(y){return nt(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),b):a(y)}function b(y){return l.containerState.size=c+l.sliceSerialize(e.exit("listItemPrefix"),!0).length,r(y)}}function yz(e,r,a){const l=this;return l.containerState._closeFlow=void 0,e.check(So,o,c);function o(f){return l.containerState.furtherBlankLines=l.containerState.furtherBlankLines||l.containerState.initialBlankLine,ot(e,r,"listItemIndent",l.containerState.size+1)(f)}function c(f){return l.containerState.furtherBlankLines||!nt(f)?(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,d(f)):(l.containerState.furtherBlankLines=void 0,l.containerState.initialBlankLine=void 0,e.attempt(xz,r,d)(f))}function d(f){return l.containerState._closeFlow=!0,l.interrupt=void 0,ot(e,e.attempt(Un,r,a),"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(f)}}function bz(e,r,a){const l=this;return ot(e,o,"listItemIndent",l.containerState.size+1);function o(c){const d=l.events[l.events.length-1];return d&&d[1].type==="listItemIndent"&&d[2].sliceSerialize(d[1],!0).length===l.containerState.size?r(c):a(c)}}function wz(e){e.exit(this.containerState.type)}function Sz(e,r,a){const l=this;return ot(e,o,"listItemPrefixWhitespace",l.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(c){const d=l.events[l.events.length-1];return!nt(c)&&d&&d[1].type==="listItemPrefixWhitespace"?r(c):a(c)}}const s0={name:"setextUnderline",resolveTo:jz,tokenize:kz};function jz(e,r){let a=e.length,l,o,c;for(;a--;)if(e[a][0]==="enter"){if(e[a][1].type==="content"){l=a;break}e[a][1].type==="paragraph"&&(o=a)}else e[a][1].type==="content"&&e.splice(a,1),!c&&e[a][1].type==="definition"&&(c=a);const d={type:"setextHeading",start:{...e[l][1].start},end:{...e[e.length-1][1].end}};return e[o][1].type="setextHeadingText",c?(e.splice(o,0,["enter",d,r]),e.splice(c+1,0,["exit",e[l][1],r]),e[l][1].end={...e[c][1].end}):e[l][1]=d,e.push(["exit",d,r]),e}function kz(e,r,a){const l=this;let o;return c;function c(m){let v=l.events.length,x;for(;v--;)if(l.events[v][1].type!=="lineEnding"&&l.events[v][1].type!=="linePrefix"&&l.events[v][1].type!=="content"){x=l.events[v][1].type==="paragraph";break}return!l.parser.lazy[l.now().line]&&(l.interrupt||x)?(e.enter("setextHeadingLine"),o=m,d(m)):a(m)}function d(m){return e.enter("setextHeadingLineSequence"),f(m)}function f(m){return m===o?(e.consume(m),f):(e.exit("setextHeadingLineSequence"),nt(m)?ot(e,h,"lineSuffix")(m):h(m))}function h(m){return m===null||Le(m)?(e.exit("setextHeadingLine"),r(m)):a(m)}}const Cz={tokenize:Nz};function Nz(e){const r=this,a=e.attempt(So,l,e.attempt(this.parser.constructs.flowInitial,o,ot(e,e.attempt(this.parser.constructs.flow,o,e.attempt(MO,o)),"linePrefix")));return a;function l(c){if(c===null){e.consume(c);return}return e.enter("lineEndingBlank"),e.consume(c),e.exit("lineEndingBlank"),r.currentConstruct=void 0,a}function o(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),r.currentConstruct=void 0,a}}const Ez={resolveAll:ej()},Tz=WS("string"),Az=WS("text");function WS(e){return{resolveAll:ej(e==="text"?_z:void 0),tokenize:r};function r(a){const l=this,o=this.parser.constructs[e],c=a.attempt(o,d,f);return d;function d(v){return m(v)?c(v):f(v)}function f(v){if(v===null){a.consume(v);return}return a.enter("data"),a.consume(v),h}function h(v){return m(v)?(a.exit("data"),c(v)):(a.consume(v),h)}function m(v){if(v===null)return!0;const x=o[v];let b=-1;if(x)for(;++b-1){const f=d[0];typeof f=="string"?d[0]=f.slice(l):d.shift()}c>0&&d.push(e[o].slice(0,c))}return d}function $z(e,r){let a=-1;const l=[];let o;for(;++a0){const an=he.tokenStack[he.tokenStack.length-1];(an[1]||u0).call(he,void 0,an[0])}for(z.position={start:Ka(ne.length>0?ne[0][1].start:{line:1,column:1,offset:0}),end:Ka(ne.length>0?ne[ne.length-2][1].end:{line:1,column:1,offset:0})},ze=-1;++ze0&&(l.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:l,children:[{type:"text",value:a}]};return r.meta&&(c.data={meta:r.meta}),e.patch(r,c),c=e.applyData(r,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(r,c),c}function r4(e,r){const a={type:"element",tagName:"del",properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function a4(e,r){const a={type:"element",tagName:"em",properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function l4(e,r){const a=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",l=String(r.identifier).toUpperCase(),o=rs(l.toLowerCase()),c=e.footnoteOrder.indexOf(l);let d,f=e.footnoteCounts.get(l);f===void 0?(f=0,e.footnoteOrder.push(l),d=e.footnoteOrder.length):d=c+1,f+=1,e.footnoteCounts.set(l,f);const h={type:"element",tagName:"a",properties:{href:"#"+a+"fn-"+o,id:a+"fnref-"+o+(f>1?"-"+f:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(r,h);const m={type:"element",tagName:"sup",properties:{},children:[h]};return e.patch(r,m),e.applyData(r,m)}function i4(e,r){const a={type:"element",tagName:"h"+r.depth,properties:{},children:e.all(r)};return e.patch(r,a),e.applyData(r,a)}function s4(e,r){if(e.options.allowDangerousHtml){const a={type:"raw",value:r.value};return e.patch(r,a),e.applyData(r,a)}}function rj(e,r){const a=r.referenceType;let l="]";if(a==="collapsed"?l+="[]":a==="full"&&(l+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+l}];const o=e.all(r),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=l:o.push({type:"text",value:l}),o}function o4(e,r){const a=String(r.identifier).toUpperCase(),l=e.definitionById.get(a);if(!l)return rj(e,r);const o={src:rs(l.url||""),alt:r.alt};l.title!==null&&l.title!==void 0&&(o.title=l.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(r,c),e.applyData(r,c)}function u4(e,r){const a={src:rs(r.url)};r.alt!==null&&r.alt!==void 0&&(a.alt=r.alt),r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(r,l),e.applyData(r,l)}function c4(e,r){const a={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};e.patch(r,a);const l={type:"element",tagName:"code",properties:{},children:[a]};return e.patch(r,l),e.applyData(r,l)}function d4(e,r){const a=String(r.identifier).toUpperCase(),l=e.definitionById.get(a);if(!l)return rj(e,r);const o={href:rs(l.url||"")};l.title!==null&&l.title!==void 0&&(o.title=l.title);const c={type:"element",tagName:"a",properties:o,children:e.all(r)};return e.patch(r,c),e.applyData(r,c)}function f4(e,r){const a={href:rs(r.url)};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"a",properties:a,children:e.all(r)};return e.patch(r,l),e.applyData(r,l)}function h4(e,r,a){const l=e.all(r),o=a?m4(a):aj(r),c={},d=[];if(typeof r.checked=="boolean"){const v=l[0];let x;v&&v.type==="element"&&v.tagName==="p"?x=v:(x={type:"element",tagName:"p",properties:{},children:[]},l.unshift(x)),x.children.length>0&&x.children.unshift({type:"text",value:" "}),x.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let f=-1;for(;++f1}function p4(e,r){const a={},l=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(a.start=r.start);++o0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(a,!0)},f=bp(r.children[1]),h=US(r.children[r.children.length-1]);f&&h&&(d.position={start:f,end:h}),o.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,c),e.applyData(r,c)}function b4(e,r,a){const l=a?a.children:void 0,c=(l?l.indexOf(r):1)===0?"th":"td",d=a&&a.type==="table"?a.align:void 0,f=d?d.length:r.children.length;let h=-1;const m=[];for(;++h0,!0),l[0]),o=l.index+l[0].length,l=a.exec(r);return c.push(f0(r.slice(o),o>0,!1)),c.join("")}function f0(e,r,a){let l=0,o=e.length;if(r){let c=e.codePointAt(l);for(;c===c0||c===d0;)l++,c=e.codePointAt(l)}if(a){let c=e.codePointAt(o-1);for(;c===c0||c===d0;)o--,c=e.codePointAt(o-1)}return o>l?e.slice(l,o):""}function j4(e,r){const a={type:"text",value:S4(String(r.value))};return e.patch(r,a),e.applyData(r,a)}function k4(e,r){const a={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,a),e.applyData(r,a)}const C4={blockquote:e4,break:t4,code:n4,delete:r4,emphasis:a4,footnoteReference:l4,heading:i4,html:s4,imageReference:o4,image:u4,inlineCode:c4,linkReference:d4,link:f4,listItem:h4,list:p4,paragraph:g4,root:x4,strong:v4,table:y4,tableCell:w4,tableRow:b4,text:j4,thematicBreak:k4,toml:Wu,yaml:Wu,definition:Wu,footnoteDefinition:Wu};function Wu(){}const lj=-1,Gc=0,oo=1,pc=2,Ep=3,Tp=4,Ap=5,_p=6,ij=7,sj=8,oj=typeof self=="object"?self:globalThis,h0=(e,r)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new oj[e](r)},N4=(e,r)=>{const a=(o,c)=>(e.set(c,o),o),l=o=>{if(e.has(o))return e.get(o);const[c,d]=r[o];switch(c){case Gc:case lj:return a(d,o);case oo:{const f=a([],o);for(const h of d)f.push(l(h));return f}case pc:{const f=a({},o);for(const[h,m]of d)f[l(h)]=l(m);return f}case Ep:return a(new Date(d),o);case Tp:{const{source:f,flags:h}=d;return a(new RegExp(f,h),o)}case Ap:{const f=a(new Map,o);for(const[h,m]of d)f.set(l(h),l(m));return f}case _p:{const f=a(new Set,o);for(const h of d)f.add(l(h));return f}case ij:{const{name:f,message:h}=d;return a(typeof oj[f]=="function"?h0(f,h):new Error(h),o)}case sj:return a(BigInt(d),o);case"BigInt":return a(Object(BigInt(d)),o);case"ArrayBuffer":return a(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:f}=new Uint8Array(d);return a(new DataView(f),d)}}return a(h0(c,d),o)};return l},m0=e=>N4(new Map,e)(0),Pl="",{toString:E4}={},{keys:T4}=Object,eo=e=>{const r=typeof e;if(r!=="object"||!e)return[Gc,r];const a=E4.call(e).slice(8,-1);switch(a){case"Array":return[oo,Pl];case"Object":return[pc,Pl];case"Date":return[Ep,Pl];case"RegExp":return[Tp,Pl];case"Map":return[Ap,Pl];case"Set":return[_p,Pl];case"DataView":return[oo,a]}return a.includes("Array")?[oo,a]:e instanceof Error?[ij,e.name||"Error"]:[pc,a]},ec=([e,r])=>e===Gc&&(r==="function"||r==="symbol"),A4=(e,r,a,l)=>{const o=(d,f)=>{const h=l.push(d)-1;return a.set(f,h),h},c=d=>{if(a.has(d))return a.get(d);let[f,h]=eo(d);switch(f){case Gc:{let v=d;switch(h){case"bigint":f=sj,v=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+h);v=null;break;case"undefined":return o([lj],d)}return o([f,v],d)}case oo:{if(h){let b=d;return h==="DataView"?b=new Uint8Array(d.buffer):h==="ArrayBuffer"&&(b=new Uint8Array(d)),o([h,[...b]],d)}const v=[],x=o([f,v],d);for(const b of d)v.push(c(b));return x}case pc:{if(h)switch(h){case"BigInt":return o([h,d.toString()],d);case"Boolean":case"Number":case"String":return o([h,d.valueOf()],d)}if(r&&"toJSON"in d)return c(d.toJSON());const v=[],x=o([f,v],d);for(const b of T4(d))(e||!ec(eo(d[b])))&&v.push([c(b),c(d[b])]);return x}case Ep:return o([f,isNaN(d.getTime())?Pl:d.toISOString()],d);case Tp:{const{source:v,flags:x}=d;return o([f,{source:v,flags:x}],d)}case Ap:{const v=[],x=o([f,v],d);for(const[b,y]of d)(e||!(ec(eo(b))||ec(eo(y))))&&v.push([c(b),c(y)]);return x}case _p:{const v=[],x=o([f,v],d);for(const b of d)(e||!ec(eo(b)))&&v.push(c(b));return x}}const{message:m}=d;return o([f,{name:h,message:m}],d)};return c},p0=(e,{json:r,lossy:a}={})=>{const l=[];return A4(!(r||a),!!r,new Map,l)(e),l},gc=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?m0(p0(e,r)):structuredClone(e):(e,r)=>m0(p0(e,r));function _4(e,r){const a=[{type:"text",value:"↩"}];return r>1&&a.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),a}function M4(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function R4(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",a=e.options.footnoteBackContent||_4,l=e.options.footnoteBackLabel||M4,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},f=[];let h=-1;for(;++h0&&k.push({type:"text",value:" "});let R=typeof a=="string"?a:a(h,y);typeof R=="string"&&(R={type:"text",value:R}),k.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+b+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof l=="string"?l:l(h,y),className:["data-footnote-backref"]},children:Array.isArray(R)?R:[R]})}const T=v[v.length-1];if(T&&T.type==="element"&&T.tagName==="p"){const R=T.children[T.children.length-1];R&&R.type==="text"?R.value+=" ":T.children.push({type:"text",value:" "}),T.children.push(...k)}else v.push(...k);const C={type:"element",tagName:"li",properties:{id:r+"fn-"+b},children:e.wrap(v,!0)};e.patch(m,C),f.push(C)}if(f.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...gc(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:` -`},{type:"element",tagName:"ol",properties:{},children:e.wrap(f,!0)},{type:"text",value:` -`}]}}const Yc=(function(e){if(e==null)return L4;if(typeof e=="function")return Xc(e);if(typeof e=="object")return Array.isArray(e)?D4(e):O4(e);if(typeof e=="string")return z4(e);throw new Error("Expected function, string, or object as test")});function D4(e){const r=[];let a=-1;for(;++a":""))+")"})}return b;function b(){let y=uj,k,j,T;if((!r||c(h,m,v[v.length-1]||void 0))&&(y=q4(a(h,v)),y[0]===_m))return y;if("children"in h&&h.children){const C=h;if(C.children&&y[0]!==I4)for(j=(l?C.children.length:-1)+d,T=v.concat(C);j>-1&&j0&&a.push({type:"text",value:` -`}),a}function g0(e){let r=0,a=e.charCodeAt(r);for(;a===9||a===32;)r++,a=e.charCodeAt(r);return e.slice(r)}function x0(e,r){const a=P4(e,r),l=a.one(e,void 0),o=R4(a),c=Array.isArray(l)?{type:"root",children:l}:l||{type:"root",children:[]};return o&&c.children.push({type:"text",value:` -`},o),c}function Y4(e,r){return e&&"run"in e?async function(a,l){const o=x0(a,{file:l,...r});await e.run(o,l)}:function(a,l){return x0(a,{file:l,...e||r})}}function v0(e){if(e)throw e}var Yh,y0;function X4(){if(y0)return Yh;y0=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,a=Object.defineProperty,l=Object.getOwnPropertyDescriptor,o=function(m){return typeof Array.isArray=="function"?Array.isArray(m):r.call(m)==="[object Array]"},c=function(m){if(!m||r.call(m)!=="[object Object]")return!1;var v=e.call(m,"constructor"),x=m.constructor&&m.constructor.prototype&&e.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!v&&!x)return!1;var b;for(b in m);return typeof b>"u"||e.call(m,b)},d=function(m,v){a&&v.name==="__proto__"?a(m,v.name,{enumerable:!0,configurable:!0,value:v.newValue,writable:!0}):m[v.name]=v.newValue},f=function(m,v){if(v==="__proto__")if(e.call(m,v)){if(l)return l(m,v).value}else return;return m[v]};return Yh=function h(){var m,v,x,b,y,k,j=arguments[0],T=1,C=arguments.length,R=!1;for(typeof j=="boolean"&&(R=j,j=arguments[1]||{},T=2),(j==null||typeof j!="object"&&typeof j!="function")&&(j={});Td.length;let h;f&&d.push(o);try{h=e.apply(this,d)}catch(m){const v=m;if(f&&a)throw v;return o(v)}f||(h&&h.then&&typeof h.then=="function"?h.then(c,o):h instanceof Error?o(h):c(h))}function o(d,...f){a||(a=!0,r(d,...f))}function c(d){o(null,d)}}const Or={basename:J4,dirname:W4,extname:e3,join:t3,sep:"/"};function J4(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');jo(e);let a=0,l=-1,o=e.length,c;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else l<0&&(c=!0,l=o+1);return l<0?"":e.slice(a,l)}if(r===e)return"";let d=-1,f=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){a=o+1;break}}else d<0&&(c=!0,d=o+1),f>-1&&(e.codePointAt(o)===r.codePointAt(f--)?f<0&&(l=o):(f=-1,l=d));return a===l?l=d:l<0&&(l=e.length),e.slice(a,l)}function W4(e){if(jo(e),e.length===0)return".";let r=-1,a=e.length,l;for(;--a;)if(e.codePointAt(a)===47){if(l){r=a;break}}else l||(l=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function e3(e){jo(e);let r=e.length,a=-1,l=0,o=-1,c=0,d;for(;r--;){const f=e.codePointAt(r);if(f===47){if(d){l=r+1;break}continue}a<0&&(d=!0,a=r+1),f===46?o<0?o=r:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||a<0||c===0||c===1&&o===a-1&&o===l+1?"":e.slice(o,a)}function t3(...e){let r=-1,a;for(;++r0&&e.codePointAt(e.length-1)===47&&(a+="/"),r?"/"+a:a}function r3(e,r){let a="",l=0,o=-1,c=0,d=-1,f,h;for(;++d<=e.length;){if(d2){if(h=a.lastIndexOf("/"),h!==a.length-1){h<0?(a="",l=0):(a=a.slice(0,h),l=a.length-1-a.lastIndexOf("/")),o=d,c=0;continue}}else if(a.length>0){a="",l=0,o=d,c=0;continue}}r&&(a=a.length>0?a+"/..":"..",l=2)}else a.length>0?a+="/"+e.slice(o+1,d):a=e.slice(o+1,d),l=d-o-1;o=d,c=0}else f===46&&c>-1?c++:c=-1}return a}function jo(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const a3={cwd:l3};function l3(){return"/"}function Dm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function i3(e){if(typeof e=="string")e=new URL(e);else if(!Dm(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return s3(e)}function s3(e){if(e.hostname!==""){const l=new TypeError('File URL host must be "localhost" or empty on darwin');throw l.code="ERR_INVALID_FILE_URL_HOST",l}const r=e.pathname;let a=-1;for(;++a0){let[y,...k]=v;const j=l[b][1];Rm(j)&&Rm(y)&&(y=Xh(!0,j,y)),l[b]=[m,y,...k]}}}}const d3=new Rp().freeze();function Jh(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Wh(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function em(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function w0(e){if(!Rm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function S0(e,r,a){if(!a)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function tc(e){return f3(e)?e:new dj(e)}function f3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function h3(e){return typeof e=="string"||m3(e)}function m3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const p3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",j0=[],k0={allowDangerousHtml:!0},g3=/^(https?|ircs?|mailto|xmpp)$/i,x3=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function v3(e){const r=y3(e),a=b3(e);return w3(r.runSync(r.parse(a),a),e)}function y3(e){const r=e.rehypePlugins||j0,a=e.remarkPlugins||j0,l=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...k0}:k0;return d3().use(Wz).use(a).use(Y4,l).use(r)}function b3(e){const r=e.children||"",a=new dj;return typeof r=="string"&&(a.value=r),a}function w3(e,r){const a=r.allowedElements,l=r.allowElement,o=r.components,c=r.disallowedElements,d=r.skipHtml,f=r.unwrapDisallowed,h=r.urlTransform||S3;for(const v of x3)Object.hasOwn(r,v.from)&&(""+v.from+(v.to?"use `"+v.to+"` instead":"remove it")+p3+v.id,void 0);return Mp(e,m),LD(e,{Fragment:s.Fragment,components:o,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function m(v,x,b){if(v.type==="raw"&&b&&typeof x=="number")return d?b.children.splice(x,1):b.children[x]={type:"text",value:v.value},x;if(v.type==="element"){let y;for(y in Fh)if(Object.hasOwn(Fh,y)&&Object.hasOwn(v.properties,y)){const k=v.properties[y],j=Fh[y];(j===null||j.includes(v.tagName))&&(v.properties[y]=h(String(k||""),y,v))}}if(v.type==="element"){let y=a?!a.includes(v.tagName):c?c.includes(v.tagName):!1;if(!y&&l&&typeof x=="number"&&(y=!l(v,x,b)),y&&b&&typeof x=="number")return f&&v.children?b.children.splice(x,1,...v.children):b.children.splice(x,1),x}}}function S3(e){const r=e.indexOf(":"),a=e.indexOf("?"),l=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||a!==-1&&r>a||l!==-1&&r>l||g3.test(e.slice(0,r))?e:""}function j3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function fj(e,r,a){const o=Yc((a||{}).ignore||[]),c=k3(r);let d=-1;for(;++d0?{type:"text",value:E}:void 0),E===!1?b.lastIndex=I+1:(k!==I&&R.push({type:"text",value:m.value.slice(k,I)}),Array.isArray(E)?R.push(...E):E&&R.push(E),k=I+D[0].length,C=!0),!b.global)break;D=b.exec(m.value)}return C?(k?\]}]+$/.exec(e);if(!r)return[e,void 0];e=e.slice(0,r.index);let a=r[0],l=a.indexOf(")");const o=C0(e,"(");let c=C0(e,")");for(;l!==-1&&o>c;)e+=a.slice(0,l+1),a=a.slice(l+1),l=a.indexOf(")"),c++;return[e,a]}function hj(e,r){const a=e.input.charCodeAt(e.index-1);return(e.index===0||Kl(a)||Fc(a))&&(!r||a!==47)}mj.peek=Q3;function P3(){this.buffer()}function $3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function F3(){this.buffer()}function V3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function G3(e){const r=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=br(this.sliceSerialize(e)).toLowerCase(),a.label=r}function Y3(e){this.exit(e)}function X3(e){const r=this.resume(),a=this.stack[this.stack.length-1];a.type,a.identifier=br(this.sliceSerialize(e)).toLowerCase(),a.label=r}function K3(e){this.exit(e)}function Q3(){return"["}function mj(e,r,a,l){const o=a.createTracker(l);let c=o.move("[^");const d=a.enter("footnoteReference"),f=a.enter("reference");return c+=o.move(a.safe(a.associationId(e),{after:"]",before:c})),f(),d(),c+=o.move("]"),c}function Z3(){return{enter:{gfmFootnoteCallString:P3,gfmFootnoteCall:$3,gfmFootnoteDefinitionLabelString:F3,gfmFootnoteDefinition:V3},exit:{gfmFootnoteCallString:G3,gfmFootnoteCall:Y3,gfmFootnoteDefinitionLabelString:X3,gfmFootnoteDefinition:K3}}}function J3(e){let r=!1;return e&&e.firstLineBlank&&(r=!0),{handlers:{footnoteDefinition:a,footnoteReference:mj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function a(l,o,c,d){const f=c.createTracker(d);let h=f.move("[^");const m=c.enter("footnoteDefinition"),v=c.enter("label");return h+=f.move(c.safe(c.associationId(l),{before:h,after:"]"})),v(),h+=f.move("]:"),l.children&&l.children.length>0&&(f.shift(4),h+=f.move((r?` -`:" ")+c.indentLines(c.containerFlow(l,f.current()),r?pj:W3))),m(),h}}function W3(e,r,a){return r===0?e:pj(e,r,a)}function pj(e,r,a){return(a?"":" ")+e}const e5=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];gj.peek=l5;function t5(){return{canContainEols:["delete"],enter:{strikethrough:r5},exit:{strikethrough:a5}}}function n5(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:e5}],handlers:{delete:gj}}}function r5(e){this.enter({type:"delete",children:[]},e)}function a5(e){this.exit(e)}function gj(e,r,a,l){const o=a.createTracker(l),c=a.enter("strikethrough");let d=o.move("~~");return d+=a.containerPhrasing(e,{...o.current(),before:d,after:"~"}),d+=o.move("~~"),c(),d}function l5(){return"~"}function i5(e){return e.length}function s5(e,r){const a=r||{},l=(a.align||[]).concat(),o=a.stringLength||i5,c=[],d=[],f=[],h=[];let m=0,v=-1;for(;++vm&&(m=e[v].length);++Ch[C])&&(h[C]=D)}j.push(R)}d[v]=j,f[v]=T}let x=-1;if(typeof l=="object"&&"length"in l)for(;++xh[x]&&(h[x]=R),y[x]=R),b[x]=D}d.splice(1,0,b),f.splice(1,0,y),v=-1;const k=[];for(;++v "),c.shift(2);const d=a.indentLines(a.containerFlow(e,c.current()),c5);return o(),d}function c5(e,r,a){return">"+(a?"":" ")+e}function d5(e,r){return E0(e,r.inConstruct,!0)&&!E0(e,r.notInConstruct,!1)}function E0(e,r,a){if(typeof r=="string"&&(r=[r]),!r||r.length===0)return a;let l=-1;for(;++ld&&(d=c):c=1,o=l+r.length,l=a.indexOf(r,o);return d}function h5(e,r){return!!(r.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function m5(e){const r=e.options.fence||"`";if(r!=="`"&&r!=="~")throw new Error("Cannot serialize code with `"+r+"` for `options.fence`, expected `` ` `` or `~`");return r}function p5(e,r,a,l){const o=m5(a),c=e.value||"",d=o==="`"?"GraveAccent":"Tilde";if(h5(e,a)){const x=a.enter("codeIndented"),b=a.indentLines(c,g5);return x(),b}const f=a.createTracker(l),h=o.repeat(Math.max(f5(c,o)+1,3)),m=a.enter("codeFenced");let v=f.move(h);if(e.lang){const x=a.enter(`codeFencedLang${d}`);v+=f.move(a.safe(e.lang,{before:v,after:" ",encode:["`"],...f.current()})),x()}if(e.lang&&e.meta){const x=a.enter(`codeFencedMeta${d}`);v+=f.move(" "),v+=f.move(a.safe(e.meta,{before:v,after:` -`,encode:["`"],...f.current()})),x()}return v+=f.move(` -`),c&&(v+=f.move(c+` -`)),v+=f.move(h),m(),v}function g5(e,r,a){return(a?"":" ")+e}function Dp(e){const r=e.options.quote||'"';if(r!=='"'&&r!=="'")throw new Error("Cannot serialize title with `"+r+"` for `options.quote`, expected `\"`, or `'`");return r}function x5(e,r,a,l){const o=Dp(a),c=o==='"'?"Quote":"Apostrophe",d=a.enter("definition");let f=a.enter("label");const h=a.createTracker(l);let m=h.move("[");return m+=h.move(a.safe(a.associationId(e),{before:m,after:"]",...h.current()})),m+=h.move("]: "),f(),!e.url||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(a.safe(e.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(f=a.enter("destinationRaw"),m+=h.move(a.safe(e.url,{before:m,after:e.title?" ":` -`,...h.current()}))),f(),e.title&&(f=a.enter(`title${c}`),m+=h.move(" "+o),m+=h.move(a.safe(e.title,{before:m,after:o,...h.current()})),m+=h.move(o),f()),d(),m}function v5(e){const r=e.options.emphasis||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize emphasis with `"+r+"` for `options.emphasis`, expected `*`, or `_`");return r}function po(e){return"&#x"+e.toString(16).toUpperCase()+";"}function xc(e,r,a){const l=Zi(e),o=Zi(r);return l===void 0?o===void 0?a==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:l===1?o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===void 0?{inside:!1,outside:!1}:o===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}xj.peek=y5;function xj(e,r,a,l){const o=v5(a),c=a.enter("emphasis"),d=a.createTracker(l),f=d.move(o);let h=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const m=h.charCodeAt(0),v=xc(l.before.charCodeAt(l.before.length-1),m,o);v.inside&&(h=po(m)+h.slice(1));const x=h.charCodeAt(h.length-1),b=xc(l.after.charCodeAt(0),x,o);b.inside&&(h=h.slice(0,-1)+po(x));const y=d.move(o);return c(),a.attentionEncodeSurroundingInfo={after:b.outside,before:v.outside},f+h+y}function y5(e,r,a){return a.options.emphasis||"*"}function b5(e,r){let a=!1;return Mp(e,function(l){if("value"in l&&/\r?\n|\r/.test(l.value)||l.type==="break")return a=!0,_m}),!!((!e.depth||e.depth<3)&&kp(e)&&(r.options.setext||a))}function w5(e,r,a,l){const o=Math.max(Math.min(6,e.depth||1),1),c=a.createTracker(l);if(b5(e,a)){const v=a.enter("headingSetext"),x=a.enter("phrasing"),b=a.containerPhrasing(e,{...c.current(),before:` -`,after:` -`});return x(),v(),b+` -`+(o===1?"=":"-").repeat(b.length-(Math.max(b.lastIndexOf("\r"),b.lastIndexOf(` -`))+1))}const d="#".repeat(o),f=a.enter("headingAtx"),h=a.enter("phrasing");c.move(d+" ");let m=a.containerPhrasing(e,{before:"# ",after:` -`,...c.current()});return/^[\t ]/.test(m)&&(m=po(m.charCodeAt(0))+m.slice(1)),m=m?d+" "+m:d,a.options.closeAtx&&(m+=" "+d),h(),f(),m}vj.peek=S5;function vj(e){return e.value||""}function S5(){return"<"}yj.peek=j5;function yj(e,r,a,l){const o=Dp(a),c=o==='"'?"Quote":"Apostrophe",d=a.enter("image");let f=a.enter("label");const h=a.createTracker(l);let m=h.move("![");return m+=h.move(a.safe(e.alt,{before:m,after:"]",...h.current()})),m+=h.move("]("),f(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(f=a.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(a.safe(e.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(f=a.enter("destinationRaw"),m+=h.move(a.safe(e.url,{before:m,after:e.title?" ":")",...h.current()}))),f(),e.title&&(f=a.enter(`title${c}`),m+=h.move(" "+o),m+=h.move(a.safe(e.title,{before:m,after:o,...h.current()})),m+=h.move(o),f()),m+=h.move(")"),d(),m}function j5(){return"!"}bj.peek=k5;function bj(e,r,a,l){const o=e.referenceType,c=a.enter("imageReference");let d=a.enter("label");const f=a.createTracker(l);let h=f.move("![");const m=a.safe(e.alt,{before:h,after:"]",...f.current()});h+=f.move(m+"]["),d();const v=a.stack;a.stack=[],d=a.enter("reference");const x=a.safe(a.associationId(e),{before:h,after:"]",...f.current()});return d(),a.stack=v,c(),o==="full"||!m||m!==x?h+=f.move(x+"]"):o==="shortcut"?h=h.slice(0,-1):h+=f.move("]"),h}function k5(){return"!"}wj.peek=C5;function wj(e,r,a){let l=e.value||"",o="`",c=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(l);)o+="`";for(/[^ \r\n]/.test(l)&&(/^[ \r\n]/.test(l)&&/[ \r\n]$/.test(l)||/^`|`$/.test(l))&&(l=" "+l+" ");++c\u007F]/.test(e.url))}jj.peek=N5;function jj(e,r,a,l){const o=Dp(a),c=o==='"'?"Quote":"Apostrophe",d=a.createTracker(l);let f,h;if(Sj(e,a)){const v=a.stack;a.stack=[],f=a.enter("autolink");let x=d.move("<");return x+=d.move(a.containerPhrasing(e,{before:x,after:">",...d.current()})),x+=d.move(">"),f(),a.stack=v,x}f=a.enter("link"),h=a.enter("label");let m=d.move("[");return m+=d.move(a.containerPhrasing(e,{before:m,after:"](",...d.current()})),m+=d.move("]("),h(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(h=a.enter("destinationLiteral"),m+=d.move("<"),m+=d.move(a.safe(e.url,{before:m,after:">",...d.current()})),m+=d.move(">")):(h=a.enter("destinationRaw"),m+=d.move(a.safe(e.url,{before:m,after:e.title?" ":")",...d.current()}))),h(),e.title&&(h=a.enter(`title${c}`),m+=d.move(" "+o),m+=d.move(a.safe(e.title,{before:m,after:o,...d.current()})),m+=d.move(o),h()),m+=d.move(")"),f(),m}function N5(e,r,a){return Sj(e,a)?"<":"["}kj.peek=E5;function kj(e,r,a,l){const o=e.referenceType,c=a.enter("linkReference");let d=a.enter("label");const f=a.createTracker(l);let h=f.move("[");const m=a.containerPhrasing(e,{before:h,after:"]",...f.current()});h+=f.move(m+"]["),d();const v=a.stack;a.stack=[],d=a.enter("reference");const x=a.safe(a.associationId(e),{before:h,after:"]",...f.current()});return d(),a.stack=v,c(),o==="full"||!m||m!==x?h+=f.move(x+"]"):o==="shortcut"?h=h.slice(0,-1):h+=f.move("]"),h}function E5(){return"["}function Op(e){const r=e.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function T5(e){const r=Op(e),a=e.options.bulletOther;if(!a)return r==="*"?"-":"*";if(a!=="*"&&a!=="+"&&a!=="-")throw new Error("Cannot serialize items with `"+a+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(a===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+a+"`) to be different");return a}function A5(e){const r=e.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function Cj(e){const r=e.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function _5(e,r,a,l){const o=a.enter("list"),c=a.bulletCurrent;let d=e.ordered?A5(a):Op(a);const f=e.ordered?d==="."?")":".":T5(a);let h=r&&a.bulletLastUsed?d===a.bulletLastUsed:!1;if(!e.ordered){const v=e.children?e.children[0]:void 0;if((d==="*"||d==="-")&&v&&(!v.children||!v.children[0])&&a.stack[a.stack.length-1]==="list"&&a.stack[a.stack.length-2]==="listItem"&&a.stack[a.stack.length-3]==="list"&&a.stack[a.stack.length-4]==="listItem"&&a.indexStack[a.indexStack.length-1]===0&&a.indexStack[a.indexStack.length-2]===0&&a.indexStack[a.indexStack.length-3]===0&&(h=!0),Cj(a)===d&&v){let x=-1;for(;++x-1?r.start:1)+(a.options.incrementListMarker===!1?0:r.children.indexOf(e))+c);let d=c.length+1;(o==="tab"||o==="mixed"&&(r&&r.type==="list"&&r.spread||e.spread))&&(d=Math.ceil(d/4)*4);const f=a.createTracker(l);f.move(c+" ".repeat(d-c.length)),f.shift(d);const h=a.enter("listItem"),m=a.indentLines(a.containerFlow(e,f.current()),v);return h(),m;function v(x,b,y){return b?(y?"":" ".repeat(d))+x:(y?c:c+" ".repeat(d-c.length))+x}}function D5(e,r,a,l){const o=a.enter("paragraph"),c=a.enter("phrasing"),d=a.containerPhrasing(e,l);return c(),o(),d}const O5=Yc(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function z5(e,r,a,l){return(e.children.some(function(d){return O5(d)})?a.containerPhrasing:a.containerFlow).call(a,e,l)}function L5(e){const r=e.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}Nj.peek=U5;function Nj(e,r,a,l){const o=L5(a),c=a.enter("strong"),d=a.createTracker(l),f=d.move(o+o);let h=d.move(a.containerPhrasing(e,{after:o,before:f,...d.current()}));const m=h.charCodeAt(0),v=xc(l.before.charCodeAt(l.before.length-1),m,o);v.inside&&(h=po(m)+h.slice(1));const x=h.charCodeAt(h.length-1),b=xc(l.after.charCodeAt(0),x,o);b.inside&&(h=h.slice(0,-1)+po(x));const y=d.move(o+o);return c(),a.attentionEncodeSurroundingInfo={after:b.outside,before:v.outside},f+h+y}function U5(e,r,a){return a.options.strong||"*"}function B5(e,r,a,l){return a.safe(e.value,l)}function I5(e){const r=e.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function q5(e,r,a){const l=(Cj(a)+(a.options.ruleSpaces?" ":"")).repeat(I5(a));return a.options.ruleSpaces?l.slice(0,-1):l}const Ej={blockquote:u5,break:T0,code:p5,definition:x5,emphasis:xj,hardBreak:T0,heading:w5,html:vj,image:yj,imageReference:bj,inlineCode:wj,link:jj,linkReference:kj,list:_5,listItem:R5,paragraph:D5,root:z5,strong:Nj,text:B5,thematicBreak:q5};function H5(){return{enter:{table:P5,tableData:A0,tableHeader:A0,tableRow:F5},exit:{codeText:V5,table:$5,tableData:am,tableHeader:am,tableRow:am}}}function P5(e){const r=e._align;this.enter({type:"table",align:r.map(function(a){return a==="none"?null:a}),children:[]},e),this.data.inTable=!0}function $5(e){this.exit(e),this.data.inTable=void 0}function F5(e){this.enter({type:"tableRow",children:[]},e)}function am(e){this.exit(e)}function A0(e){this.enter({type:"tableCell",children:[]},e)}function V5(e){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,G5));const a=this.stack[this.stack.length-1];a.type,a.value=r,this.exit(e)}function G5(e,r){return r==="|"?r:e}function Y5(e){const r=e||{},a=r.tableCellPadding,l=r.tablePipeAlign,o=r.stringLength,c=a?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:` -`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:b,table:d,tableCell:h,tableRow:f}};function d(y,k,j,T){return m(v(y,j,T),y.align)}function f(y,k,j,T){const C=x(y,j,T),R=m([C]);return R.slice(0,R.indexOf(` -`))}function h(y,k,j,T){const C=j.enter("tableCell"),R=j.enter("phrasing"),D=j.containerPhrasing(y,{...T,before:c,after:c});return R(),C(),D}function m(y,k){return s5(y,{align:k,alignDelimiters:l,padding:a,stringLength:o})}function v(y,k,j){const T=y.children;let C=-1;const R=[],D=k.enter("table");for(;++C0&&!a&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),a}const d6={tokenize:y6,partial:!0};function f6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:g6,continuation:{tokenize:x6},exit:v6}},text:{91:{name:"gfmFootnoteCall",tokenize:p6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:h6,resolveTo:m6}}}}function h6(e,r,a){const l=this;let o=l.events.length;const c=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let d;for(;o--;){const h=l.events[o][1];if(h.type==="labelImage"){d=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return f;function f(h){if(!d||!d._balanced)return a(h);const m=br(l.sliceSerialize({start:d.end,end:l.now()}));return m.codePointAt(0)!==94||!c.includes(m.slice(1))?a(h):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),r(h))}}function m6(e,r){let a=e.length;for(;a--;)if(e[a][1].type==="labelImage"&&e[a][0]==="enter"){e[a][1];break}e[a+1][1].type="data",e[a+3][1].type="gfmFootnoteCallLabelMarker";const l={type:"gfmFootnoteCall",start:Object.assign({},e[a+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[a+3][1].end),end:Object.assign({},e[a+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const c={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},d={type:"chunkString",contentType:"string",start:Object.assign({},c.start),end:Object.assign({},c.end)},f=[e[a+1],e[a+2],["enter",l,r],e[a+3],e[a+4],["enter",o,r],["exit",o,r],["enter",c,r],["enter",d,r],["exit",d,r],["exit",c,r],e[e.length-2],e[e.length-1],["exit",l,r]];return e.splice(a,e.length-a+1,...f),e}function p6(e,r,a){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c=0,d;return f;function f(x){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),h}function h(x){return x!==94?a(x):(e.enter("gfmFootnoteCallMarker"),e.consume(x),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",m)}function m(x){if(c>999||x===93&&!d||x===null||x===91||Ct(x))return a(x);if(x===93){e.exit("chunkString");const b=e.exit("gfmFootnoteCallString");return o.includes(br(l.sliceSerialize(b)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(x),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):a(x)}return Ct(x)||(d=!0),c++,e.consume(x),x===92?v:m}function v(x){return x===91||x===92||x===93?(e.consume(x),c++,m):m(x)}}function g6(e,r,a){const l=this,o=l.parser.gfmFootnotes||(l.parser.gfmFootnotes=[]);let c,d=0,f;return h;function h(k){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(k){return k===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",v):a(k)}function v(k){if(d>999||k===93&&!f||k===null||k===91||Ct(k))return a(k);if(k===93){e.exit("chunkString");const j=e.exit("gfmFootnoteDefinitionLabelString");return c=br(l.sliceSerialize(j)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(k),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),b}return Ct(k)||(f=!0),d++,e.consume(k),k===92?x:v}function x(k){return k===91||k===92||k===93?(e.consume(k),d++,v):v(k)}function b(k){return k===58?(e.enter("definitionMarker"),e.consume(k),e.exit("definitionMarker"),o.includes(c)||o.push(c),ot(e,y,"gfmFootnoteDefinitionWhitespace")):a(k)}function y(k){return r(k)}}function x6(e,r,a){return e.check(So,r,e.attempt(d6,r,a))}function v6(e){e.exit("gfmFootnoteDefinition")}function y6(e,r,a){const l=this;return ot(e,o,"gfmFootnoteDefinitionIndent",5);function o(c){const d=l.events[l.events.length-1];return d&&d[1].type==="gfmFootnoteDefinitionIndent"&&d[2].sliceSerialize(d[1],!0).length===4?r(c):a(c)}}function b6(e){let a=(e||{}).singleTilde;const l={name:"strikethrough",tokenize:c,resolveAll:o};return a==null&&(a=!0),{text:{126:l},insideSpan:{null:[l]},attentionMarkers:{null:[126]}};function o(d,f){let h=-1;for(;++h1?h(k):(d.consume(k),x++,y);if(x<2&&!a)return h(k);const T=d.exit("strikethroughSequenceTemporary"),C=Zi(k);return T._open=!C||C===2&&!!j,T._close=!j||j===2&&!!C,f(k)}}}class w6{constructor(){this.map=[]}add(r,a,l){S6(this,r,a,l)}consume(r){if(this.map.sort(function(c,d){return c[0]-d[0]}),this.map.length===0)return;let a=this.map.length;const l=[];for(;a>0;)a-=1,l.push(r.slice(this.map[a][0]+this.map[a][1]),this.map[a][2]),r.length=this.map[a][0];l.push(r.slice()),r.length=0;let o=l.pop();for(;o;){for(const c of o)r.push(c);o=l.pop()}this.map.length=0}}function S6(e,r,a,l){let o=0;if(!(a===0&&l.length===0)){for(;o-1;){const le=l.events[P][1].type;if(le==="lineEnding"||le==="linePrefix")P--;else break}const K=P>-1?l.events[P][1].type:null,ue=K==="tableHead"||K==="tableRow"?E:h;return ue===E&&l.parser.lazy[l.now().line]?a(H):ue(H)}function h(H){return e.enter("tableHead"),e.enter("tableRow"),m(H)}function m(H){return H===124||(d=!0,c+=1),v(H)}function v(H){return H===null?a(H):Le(H)?c>1?(c=0,l.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(H),e.exit("lineEnding"),y):a(H):nt(H)?ot(e,v,"whitespace")(H):(c+=1,d&&(d=!1,o+=1),H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),d=!0,v):(e.enter("data"),x(H)))}function x(H){return H===null||H===124||Ct(H)?(e.exit("data"),v(H)):(e.consume(H),H===92?b:x)}function b(H){return H===92||H===124?(e.consume(H),x):x(H)}function y(H){return l.interrupt=!1,l.parser.lazy[l.now().line]?a(H):(e.enter("tableDelimiterRow"),d=!1,nt(H)?ot(e,k,"linePrefix",l.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(H):k(H))}function k(H){return H===45||H===58?T(H):H===124?(d=!0,e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),j):O(H)}function j(H){return nt(H)?ot(e,T,"whitespace")(H):T(H)}function T(H){return H===58?(c+=1,d=!0,e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),C):H===45?(c+=1,C(H)):H===null||Le(H)?I(H):O(H)}function C(H){return H===45?(e.enter("tableDelimiterFiller"),R(H)):O(H)}function R(H){return H===45?(e.consume(H),R):H===58?(d=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(H),e.exit("tableDelimiterMarker"),D):(e.exit("tableDelimiterFiller"),D(H))}function D(H){return nt(H)?ot(e,I,"whitespace")(H):I(H)}function I(H){return H===124?k(H):H===null||Le(H)?!d||o!==c?O(H):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(H)):O(H)}function O(H){return a(H)}function E(H){return e.enter("tableRow"),N(H)}function N(H){return H===124?(e.enter("tableCellDivider"),e.consume(H),e.exit("tableCellDivider"),N):H===null||Le(H)?(e.exit("tableRow"),r(H)):nt(H)?ot(e,N,"whitespace")(H):(e.enter("data"),L(H))}function L(H){return H===null||H===124||Ct(H)?(e.exit("data"),N(H)):(e.consume(H),H===92?X:L)}function X(H){return H===92||H===124?(e.consume(H),L):L(H)}}function N6(e,r){let a=-1,l=!0,o=0,c=[0,0,0,0],d=[0,0,0,0],f=!1,h=0,m,v,x;const b=new w6;for(;++aa[2]+1){const k=a[2]+1,j=a[3]-a[2]-1;e.add(k,j,[])}}e.add(a[3]+1,0,[["exit",x,r]])}return o!==void 0&&(c.end=Object.assign({},Gi(r.events,o)),e.add(o,0,[["exit",c,r]]),c=void 0),c}function M0(e,r,a,l,o){const c=[],d=Gi(r.events,a);o&&(o.end=Object.assign({},d),c.push(["exit",o,r])),l.end=Object.assign({},d),c.push(["exit",l,r]),e.add(a+1,0,c)}function Gi(e,r){const a=e[r],l=a[0]==="enter"?"start":"end";return a[1][l]}const E6={name:"tasklistCheck",tokenize:A6};function T6(){return{text:{91:E6}}}function A6(e,r,a){const l=this;return o;function o(h){return l.previous!==null||!l._gfmTasklistFirstContentOfListItem?a(h):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),c)}function c(h){return Ct(h)?(e.enter("taskListCheckValueUnchecked"),e.consume(h),e.exit("taskListCheckValueUnchecked"),d):h===88||h===120?(e.enter("taskListCheckValueChecked"),e.consume(h),e.exit("taskListCheckValueChecked"),d):a(h)}function d(h){return h===93?(e.enter("taskListCheckMarker"),e.consume(h),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),f):a(h)}function f(h){return Le(h)?r(h):nt(h)?e.check({tokenize:_6},r,a)(h):a(h)}}function _6(e,r,a){return ot(e,l,"whitespace");function l(o){return o===null?a(o):r(o)}}function M6(e){return FS([n6(),f6(),b6(e),k6(),T6()])}const R6={};function D6(e){const r=this,a=e||R6,l=r.data(),o=l.micromarkExtensions||(l.micromarkExtensions=[]),c=l.fromMarkdownExtensions||(l.fromMarkdownExtensions=[]),d=l.toMarkdownExtensions||(l.toMarkdownExtensions=[]);o.push(M6(a)),c.push(J5()),d.push(W5(a))}const O6={a:({children:e,...r})=>s.jsx("a",{...r,target:"_blank",rel:"noopener noreferrer",children:e}),img:({alt:e})=>s.jsx("span",{className:"text-muted-foreground",children:e||"(image)"})};function z6({text:e,className:r}){return s.jsx("div",{className:Ne("chat-markdown",r),children:s.jsx(v3,{remarkPlugins:[D6,A3],components:O6,children:e})})}function L6({className:e,...r}){return s.jsx("textarea",{"data-slot":"textarea",className:Ne("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...r})}var zm=["Enter"," "],U6=["ArrowDown","PageUp","Home"],Lj=["ArrowUp","PageDown","End"],B6=[...U6,...Lj],I6={ltr:[...zm,"ArrowRight"],rtl:[...zm,"ArrowLeft"]},q6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},ko="Menu",[go,H6,P6]=Jm(ko),[Jl,Uj]=Sr(ko,[P6,Lc,Pc]),Kc=Lc(),Bj=Pc(),[$6,Wl]=Jl(ko),[F6,Co]=Jl(ko),Ij=e=>{const{__scopeMenu:r,open:a=!1,children:l,dir:o,onOpenChange:c,modal:d=!0}=e,f=Kc(r),[h,m]=S.useState(null),v=S.useRef(!1),x=fr(c),b=_c(o);return S.useEffect(()=>{const y=()=>{v.current=!0,document.addEventListener("pointerdown",k,{capture:!0,once:!0}),document.addEventListener("pointermove",k,{capture:!0,once:!0})},k=()=>v.current=!1;return document.addEventListener("keydown",y,{capture:!0}),()=>{document.removeEventListener("keydown",y,{capture:!0}),document.removeEventListener("pointerdown",k,{capture:!0}),document.removeEventListener("pointermove",k,{capture:!0})}},[]),s.jsx(Cw,{...f,children:s.jsx($6,{scope:r,open:a,onOpenChange:x,content:h,onContentChange:m,children:s.jsx(F6,{scope:r,onClose:S.useCallback(()=>x(!1),[x]),isUsingKeyboardRef:v,dir:b,modal:d,children:l})})})};Ij.displayName=ko;var V6="MenuAnchor",Lp=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e,o=Kc(a);return s.jsx(Nw,{...o,...l,ref:r})});Lp.displayName=V6;var Up="MenuPortal",[G6,qj]=Jl(Up,{forceMount:void 0}),Hj=e=>{const{__scopeMenu:r,forceMount:a,children:l,container:o}=e,c=Wl(Up,r);return s.jsx(G6,{scope:r,forceMount:a,children:s.jsx(Vr,{present:a||c.open,children:s.jsx(Nc,{asChild:!0,container:o,children:l})})})};Hj.displayName=Up;var dr="MenuContent",[Y6,Bp]=Jl(dr),Pj=S.forwardRef((e,r)=>{const a=qj(dr,e.__scopeMenu),{forceMount:l=a.forceMount,...o}=e,c=Wl(dr,e.__scopeMenu),d=Co(dr,e.__scopeMenu);return s.jsx(go.Provider,{scope:e.__scopeMenu,children:s.jsx(Vr,{present:l||c.open,children:s.jsx(go.Slot,{scope:e.__scopeMenu,children:d.modal?s.jsx(X6,{...o,ref:r}):s.jsx(K6,{...o,ref:r})})})})}),X6=S.forwardRef((e,r)=>{const a=Wl(dr,e.__scopeMenu),l=S.useRef(null),o=ft(r,l);return S.useEffect(()=>{const c=l.current;if(c)return Gm(c)},[]),s.jsx(Ip,{...e,ref:o,trapFocus:a.open,disableOutsidePointerEvents:a.open,disableOutsideScroll:!0,onFocusOutside:Ae(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>a.onOpenChange(!1)})}),K6=S.forwardRef((e,r)=>{const a=Wl(dr,e.__scopeMenu);return s.jsx(Ip,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>a.onOpenChange(!1)})}),Ip=S.forwardRef((e,r)=>{const{__scopeMenu:a,loop:l=!1,trapFocus:o,onOpenAutoFocus:c,onCloseAutoFocus:d,disableOutsidePointerEvents:f,onEntryFocus:h,onEscapeKeyDown:m,onPointerDownOutside:v,onFocusOutside:x,onInteractOutside:b,onDismiss:y,disableOutsideScroll:k,...j}=e,T=Wl(dr,a),C=Co(dr,a),R=Kc(a),D=Bj(a),I=H6(a),[O,E]=S.useState(null),N=S.useRef(null),L=ft(r,N,T.onContentChange),X=S.useRef(0),H=S.useRef(""),P=S.useRef(0),K=S.useRef(null),ue=S.useRef("right"),le=S.useRef(0),W=k?Tc:S.Fragment,B=k?{as:xa,allowPinchZoom:!0}:void 0,F=Z=>{var re,ye;const A=H.current+Z,U=I().filter(fe=>!fe.disabled),V=document.activeElement,M=(re=U.find(fe=>fe.ref.current===V))==null?void 0:re.textValue,se=U.map(fe=>fe.textValue),Y=sL(se,A,M),ce=(ye=U.find(fe=>fe.textValue===Y))==null?void 0:ye.ref.current;(function fe(we){H.current=we,window.clearTimeout(X.current),we!==""&&(X.current=window.setTimeout(()=>fe(""),1e3))})(A),ce&&setTimeout(()=>ce.focus())};S.useEffect(()=>()=>window.clearTimeout(X.current),[]),Vm();const ae=S.useCallback(Z=>{var U,V;return ue.current===((U=K.current)==null?void 0:U.side)&&uL(Z,(V=K.current)==null?void 0:V.area)},[]);return s.jsx(Y6,{scope:a,searchRef:H,onItemEnter:S.useCallback(Z=>{ae(Z)&&Z.preventDefault()},[ae]),onItemLeave:S.useCallback(Z=>{var A;ae(Z)||((A=N.current)==null||A.focus(),E(null))},[ae]),onTriggerLeave:S.useCallback(Z=>{ae(Z)&&Z.preventDefault()},[ae]),pointerGraceTimerRef:P,onPointerGraceIntentChange:S.useCallback(Z=>{K.current=Z},[]),children:s.jsx(W,{...B,children:s.jsx(Cc,{asChild:!0,trapped:o,onMountAutoFocus:Ae(c,Z=>{var A;Z.preventDefault(),(A=N.current)==null||A.focus({preventScroll:!0})}),onUnmountAutoFocus:d,children:s.jsx(kc,{asChild:!0,disableOutsidePointerEvents:f,onEscapeKeyDown:m,onPointerDownOutside:v,onFocusOutside:x,onInteractOutside:b,onDismiss:y,children:s.jsx(vS,{asChild:!0,...D,dir:C.dir,orientation:"vertical",loop:l,currentTabStopId:O,onCurrentTabStopIdChange:E,onEntryFocus:Ae(h,Z=>{C.isUsingKeyboardRef.current||Z.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Ew,{role:"menu","aria-orientation":"vertical","data-state":ak(T.open),"data-radix-menu-content":"",dir:C.dir,...R,...j,ref:L,style:{outline:"none",...j.style},onKeyDown:Ae(j.onKeyDown,Z=>{const U=Z.target.closest("[data-radix-menu-content]")===Z.currentTarget,V=Z.ctrlKey||Z.altKey||Z.metaKey,M=Z.key.length===1;U&&(Z.key==="Tab"&&Z.preventDefault(),!V&&M&&F(Z.key));const se=N.current;if(Z.target!==se||!B6.includes(Z.key))return;Z.preventDefault();const ce=I().filter(re=>!re.disabled).map(re=>re.ref.current);Lj.includes(Z.key)&&ce.reverse(),lL(ce)}),onBlur:Ae(e.onBlur,Z=>{Z.currentTarget.contains(Z.target)||(window.clearTimeout(X.current),H.current="")}),onPointerMove:Ae(e.onPointerMove,xo(Z=>{const A=Z.target,U=le.current!==Z.clientX;if(Z.currentTarget.contains(A)&&U){const V=Z.clientX>le.current?"right":"left";ue.current=V,le.current=Z.clientX}}))})})})})})})});Pj.displayName=dr;var Q6="MenuGroup",qp=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e;return s.jsx(Ge.div,{role:"group",...l,ref:r})});qp.displayName=Q6;var Z6="MenuLabel",$j=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e;return s.jsx(Ge.div,{...l,ref:r})});$j.displayName=Z6;var vc="MenuItem",R0="menu.itemSelect",Qc=S.forwardRef((e,r)=>{const{disabled:a=!1,onSelect:l,...o}=e,c=S.useRef(null),d=Co(vc,e.__scopeMenu),f=Bp(vc,e.__scopeMenu),h=ft(r,c),m=S.useRef(!1),v=()=>{const x=c.current;if(!a&&x){const b=new CustomEvent(R0,{bubbles:!0,cancelable:!0});x.addEventListener(R0,y=>l==null?void 0:l(y),{once:!0}),i1(x,b),b.defaultPrevented?m.current=!1:d.onClose()}};return s.jsx(Fj,{...o,ref:h,disabled:a,onClick:Ae(e.onClick,v),onPointerDown:x=>{var b;(b=e.onPointerDown)==null||b.call(e,x),m.current=!0},onPointerUp:Ae(e.onPointerUp,x=>{var b;m.current||(b=x.currentTarget)==null||b.click()}),onKeyDown:Ae(e.onKeyDown,x=>{const b=f.searchRef.current!=="";a||b&&x.key===" "||zm.includes(x.key)&&(x.currentTarget.click(),x.preventDefault())})})});Qc.displayName=vc;var Fj=S.forwardRef((e,r)=>{const{__scopeMenu:a,disabled:l=!1,textValue:o,...c}=e,d=Bp(vc,a),f=Bj(a),h=S.useRef(null),m=ft(r,h),[v,x]=S.useState(!1),[b,y]=S.useState("");return S.useEffect(()=>{const k=h.current;k&&y((k.textContent??"").trim())},[c.children]),s.jsx(go.ItemSlot,{scope:a,disabled:l,textValue:o??b,children:s.jsx(yS,{asChild:!0,...f,focusable:!l,children:s.jsx(Ge.div,{role:"menuitem","data-highlighted":v?"":void 0,"aria-disabled":l||void 0,"data-disabled":l?"":void 0,...c,ref:m,onPointerMove:Ae(e.onPointerMove,xo(k=>{l?d.onItemLeave(k):(d.onItemEnter(k),k.defaultPrevented||k.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ae(e.onPointerLeave,xo(k=>d.onItemLeave(k))),onFocus:Ae(e.onFocus,()=>x(!0)),onBlur:Ae(e.onBlur,()=>x(!1))})})})}),J6="MenuCheckboxItem",Vj=S.forwardRef((e,r)=>{const{checked:a=!1,onCheckedChange:l,...o}=e;return s.jsx(Qj,{scope:e.__scopeMenu,checked:a,children:s.jsx(Qc,{role:"menuitemcheckbox","aria-checked":yc(a)?"mixed":a,...o,ref:r,"data-state":Pp(a),onSelect:Ae(o.onSelect,()=>l==null?void 0:l(yc(a)?!0:!a),{checkForDefaultPrevented:!1})})})});Vj.displayName=J6;var Gj="MenuRadioGroup",[W6,eL]=Jl(Gj,{value:void 0,onValueChange:()=>{}}),Yj=S.forwardRef((e,r)=>{const{value:a,onValueChange:l,...o}=e,c=fr(l);return s.jsx(W6,{scope:e.__scopeMenu,value:a,onValueChange:c,children:s.jsx(qp,{...o,ref:r})})});Yj.displayName=Gj;var Xj="MenuRadioItem",Kj=S.forwardRef((e,r)=>{const{value:a,...l}=e,o=eL(Xj,e.__scopeMenu),c=a===o.value;return s.jsx(Qj,{scope:e.__scopeMenu,checked:c,children:s.jsx(Qc,{role:"menuitemradio","aria-checked":c,...l,ref:r,"data-state":Pp(c),onSelect:Ae(l.onSelect,()=>{var d;return(d=o.onValueChange)==null?void 0:d.call(o,a)},{checkForDefaultPrevented:!1})})})});Kj.displayName=Xj;var Hp="MenuItemIndicator",[Qj,tL]=Jl(Hp,{checked:!1}),Zj=S.forwardRef((e,r)=>{const{__scopeMenu:a,forceMount:l,...o}=e,c=tL(Hp,a);return s.jsx(Vr,{present:l||yc(c.checked)||c.checked===!0,children:s.jsx(Ge.span,{...o,ref:r,"data-state":Pp(c.checked)})})});Zj.displayName=Hp;var nL="MenuSeparator",Jj=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e;return s.jsx(Ge.div,{role:"separator","aria-orientation":"horizontal",...l,ref:r})});Jj.displayName=nL;var rL="MenuArrow",Wj=S.forwardRef((e,r)=>{const{__scopeMenu:a,...l}=e,o=Kc(a);return s.jsx(Tw,{...o,...l,ref:r})});Wj.displayName=rL;var aL="MenuSub",[x9,ek]=Jl(aL),ro="MenuSubTrigger",tk=S.forwardRef((e,r)=>{const a=Wl(ro,e.__scopeMenu),l=Co(ro,e.__scopeMenu),o=ek(ro,e.__scopeMenu),c=Bp(ro,e.__scopeMenu),d=S.useRef(null),{pointerGraceTimerRef:f,onPointerGraceIntentChange:h}=c,m={__scopeMenu:e.__scopeMenu},v=S.useCallback(()=>{d.current&&window.clearTimeout(d.current),d.current=null},[]);return S.useEffect(()=>v,[v]),S.useEffect(()=>{const x=f.current;return()=>{window.clearTimeout(x),h(null)}},[f,h]),s.jsx(Lp,{asChild:!0,...m,children:s.jsx(Fj,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":a.open,"aria-controls":o.contentId,"data-state":ak(a.open),...e,ref:Sc(r,o.onTriggerChange),onClick:x=>{var b;(b=e.onClick)==null||b.call(e,x),!(e.disabled||x.defaultPrevented)&&(x.currentTarget.focus(),a.open||a.onOpenChange(!0))},onPointerMove:Ae(e.onPointerMove,xo(x=>{c.onItemEnter(x),!x.defaultPrevented&&!e.disabled&&!a.open&&!d.current&&(c.onPointerGraceIntentChange(null),d.current=window.setTimeout(()=>{a.onOpenChange(!0),v()},100))})),onPointerLeave:Ae(e.onPointerLeave,xo(x=>{var y,k;v();const b=(y=a.content)==null?void 0:y.getBoundingClientRect();if(b){const j=(k=a.content)==null?void 0:k.dataset.side,T=j==="right",C=T?-5:5,R=b[T?"left":"right"],D=b[T?"right":"left"];c.onPointerGraceIntentChange({area:[{x:x.clientX+C,y:x.clientY},{x:R,y:b.top},{x:D,y:b.top},{x:D,y:b.bottom},{x:R,y:b.bottom}],side:j}),window.clearTimeout(f.current),f.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(x),x.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:Ae(e.onKeyDown,x=>{var y;const b=c.searchRef.current!=="";e.disabled||b&&x.key===" "||I6[l.dir].includes(x.key)&&(a.onOpenChange(!0),(y=a.content)==null||y.focus(),x.preventDefault())})})})});tk.displayName=ro;var nk="MenuSubContent",rk=S.forwardRef((e,r)=>{const a=qj(dr,e.__scopeMenu),{forceMount:l=a.forceMount,...o}=e,c=Wl(dr,e.__scopeMenu),d=Co(dr,e.__scopeMenu),f=ek(nk,e.__scopeMenu),h=S.useRef(null),m=ft(r,h);return s.jsx(go.Provider,{scope:e.__scopeMenu,children:s.jsx(Vr,{present:l||c.open,children:s.jsx(go.Slot,{scope:e.__scopeMenu,children:s.jsx(Ip,{id:f.contentId,"aria-labelledby":f.triggerId,...o,ref:m,align:"start",side:d.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:v=>{var x;d.isUsingKeyboardRef.current&&((x=h.current)==null||x.focus()),v.preventDefault()},onCloseAutoFocus:v=>v.preventDefault(),onFocusOutside:Ae(e.onFocusOutside,v=>{v.target!==f.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:Ae(e.onEscapeKeyDown,v=>{d.onClose(),v.preventDefault()}),onKeyDown:Ae(e.onKeyDown,v=>{var y;const x=v.currentTarget.contains(v.target),b=q6[d.dir].includes(v.key);x&&b&&(c.onOpenChange(!1),(y=f.trigger)==null||y.focus(),v.preventDefault())})})})})})});rk.displayName=nk;function ak(e){return e?"open":"closed"}function yc(e){return e==="indeterminate"}function Pp(e){return yc(e)?"indeterminate":e?"checked":"unchecked"}function lL(e){const r=document.activeElement;for(const a of e)if(a===r||(a.focus(),document.activeElement!==r))return}function iL(e,r){return e.map((a,l)=>e[(r+l)%e.length])}function sL(e,r,a){const o=r.length>1&&Array.from(r).every(m=>m===r[0])?r[0]:r,c=a?e.indexOf(a):-1;let d=iL(e,Math.max(c,0));o.length===1&&(d=d.filter(m=>m!==a));const h=d.find(m=>m.toLowerCase().startsWith(o.toLowerCase()));return h!==a?h:void 0}function oL(e,r){const{x:a,y:l}=e;let o=!1;for(let c=0,d=r.length-1;cl!=v>l&&a<(m-f)*(l-h)/(v-h)+f&&(o=!o)}return o}function uL(e,r){if(!r)return!1;const a={x:e.clientX,y:e.clientY};return oL(a,r)}function xo(e){return r=>r.pointerType==="mouse"?e(r):void 0}var cL=Ij,dL=Lp,fL=Hj,hL=Pj,mL=qp,pL=$j,gL=Qc,xL=Vj,vL=Yj,yL=Kj,bL=Zj,wL=Jj,SL=Wj,jL=tk,kL=rk,$p="DropdownMenu",[CL]=Sr($p,[Uj]),En=Uj(),[NL,lk]=CL($p),ik=e=>{const{__scopeDropdownMenu:r,children:a,dir:l,open:o,defaultOpen:c,onOpenChange:d,modal:f=!0}=e,h=En(r),m=S.useRef(null),[v=!1,x]=nl({prop:o,defaultProp:c,onChange:d});return s.jsx(NL,{scope:r,triggerId:Br(),triggerRef:m,contentId:Br(),open:v,onOpenChange:x,onOpenToggle:S.useCallback(()=>x(b=>!b),[x]),modal:f,children:s.jsx(cL,{...h,open:v,onOpenChange:x,dir:l,modal:f,children:a})})};ik.displayName=$p;var sk="DropdownMenuTrigger",ok=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,disabled:l=!1,...o}=e,c=lk(sk,a),d=En(a);return s.jsx(dL,{asChild:!0,...d,children:s.jsx(Ge.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":l?"":void 0,disabled:l,...o,ref:Sc(r,c.triggerRef),onPointerDown:Ae(e.onPointerDown,f=>{!l&&f.button===0&&f.ctrlKey===!1&&(c.onOpenToggle(),c.open||f.preventDefault())}),onKeyDown:Ae(e.onKeyDown,f=>{l||(["Enter"," "].includes(f.key)&&c.onOpenToggle(),f.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(f.key)&&f.preventDefault())})})})});ok.displayName=sk;var EL="DropdownMenuPortal",uk=e=>{const{__scopeDropdownMenu:r,...a}=e,l=En(r);return s.jsx(fL,{...l,...a})};uk.displayName=EL;var ck="DropdownMenuContent",dk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=lk(ck,a),c=En(a),d=S.useRef(!1);return s.jsx(hL,{id:o.contentId,"aria-labelledby":o.triggerId,...c,...l,ref:r,onCloseAutoFocus:Ae(e.onCloseAutoFocus,f=>{var h;d.current||(h=o.triggerRef.current)==null||h.focus(),d.current=!1,f.preventDefault()}),onInteractOutside:Ae(e.onInteractOutside,f=>{const h=f.detail.originalEvent,m=h.button===0&&h.ctrlKey===!0,v=h.button===2||m;(!o.modal||v)&&(d.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});dk.displayName=ck;var TL="DropdownMenuGroup",AL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(mL,{...o,...l,ref:r})});AL.displayName=TL;var _L="DropdownMenuLabel",fk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(pL,{...o,...l,ref:r})});fk.displayName=_L;var ML="DropdownMenuItem",hk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(gL,{...o,...l,ref:r})});hk.displayName=ML;var RL="DropdownMenuCheckboxItem",mk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(xL,{...o,...l,ref:r})});mk.displayName=RL;var DL="DropdownMenuRadioGroup",OL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(vL,{...o,...l,ref:r})});OL.displayName=DL;var zL="DropdownMenuRadioItem",LL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(yL,{...o,...l,ref:r})});LL.displayName=zL;var UL="DropdownMenuItemIndicator",pk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(bL,{...o,...l,ref:r})});pk.displayName=UL;var BL="DropdownMenuSeparator",gk=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(wL,{...o,...l,ref:r})});gk.displayName=BL;var IL="DropdownMenuArrow",qL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(SL,{...o,...l,ref:r})});qL.displayName=IL;var HL="DropdownMenuSubTrigger",PL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(jL,{...o,...l,ref:r})});PL.displayName=HL;var $L="DropdownMenuSubContent",FL=S.forwardRef((e,r)=>{const{__scopeDropdownMenu:a,...l}=e,o=En(a);return s.jsx(kL,{...o,...l,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});FL.displayName=$L;var VL=ik,GL=ok,YL=uk,XL=dk,KL=fk,QL=hk,ZL=mk,JL=pk,WL=gk;function xk({...e}){return s.jsx(VL,{"data-slot":"dropdown-menu",...e})}function vk({...e}){return s.jsx(GL,{"data-slot":"dropdown-menu-trigger",...e})}function yk({className:e,sideOffset:r=4,...a}){return s.jsx(YL,{children:s.jsx(XL,{"data-slot":"dropdown-menu-content",sideOffset:r,className:Ne("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...a})})}function e9({className:e,inset:r,variant:a="default",...l}){return s.jsx(QL,{"data-slot":"dropdown-menu-item","data-inset":r,"data-variant":a,className:Ne("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...l})}function t9({className:e,children:r,checked:a,...l}){return s.jsxs(ZL,{"data-slot":"dropdown-menu-checkbox-item",className:Ne("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...l,children:[s.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:s.jsx(JL,{children:s.jsx(jc,{className:"size-4"})})}),r]})}function Lm({className:e,inset:r,...a}){return s.jsx(KL,{"data-slot":"dropdown-menu-label","data-inset":r,className:Ne("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...a})}function bk({className:e,...r}){return s.jsx(WL,{"data-slot":"dropdown-menu-separator",className:Ne("bg-border -mx-1 my-1 h-px",e),...r})}const wk="llmproxy.playground.models",D0="llmproxy.playground.webfetch",n9={type:"function",function:{name:"web_fetch",description:"Fetch a public web page over HTTP(S) and return its text content.",parameters:{type:"object",properties:{url:{type:"string",description:"The absolute http(s) URL to fetch."}},required:["url"]}}},r9=5;function a9(){try{const e=JSON.parse(localStorage.getItem(wk)??"[]");return Array.isArray(e)?e.filter(r=>typeof r=="string"):[]}catch{return[]}}function O0(e){return e.images.length===0?e.text:[...e.text?[{type:"text",text:e.text}]:[],...e.images.map(r=>({type:"image_url",image_url:{url:r.dataUrl}}))]}function l9(){var H;const e=Ut(async()=>{const[P,K]=await Promise.all([He.get("/v1/models?endpoint=chat"),He.get("/v1/models?endpoint=chat_stream")]);return{chat:P,streamable:new Set(K.data.map(ue=>ue.id))}}),[r,a]=S.useState(a9),[l,o]=S.useState(()=>localStorage.getItem(D0)==="1"),[c,d]=S.useState([]),[f,h]=S.useState(""),[m,v]=S.useState([]),[x,b]=S.useState(!1),y=S.useRef(null),k=S.useRef(1),j=S.useRef(null),T=S.useRef(null),C=(((H=e.data)==null?void 0:H.chat.data)??[]).map(P=>P.id);S.useEffect(()=>{e.data&&a(P=>{const K=P.filter(ue=>C.includes(ue));return K.length===P.length?P:K})},[e.data]),S.useEffect(()=>{localStorage.setItem(wk,JSON.stringify(r))},[r]),S.useEffect(()=>{localStorage.setItem(D0,l?"1":"0")},[l]),S.useEffect(()=>()=>{var P;return(P=y.current)==null?void 0:P.abort()},[]);const R=(P,K)=>{a(ue=>K?[...ue,P]:ue.filter(le=>le!==P))},D=(P,K,ue)=>{d(le=>le.map(W=>W.id===P?{...W,replies:{...W.replies,[K]:{...W.replies[K],...ue}}}:W))},I=async(P,K,ue,le,W)=>{var ye;const B=[];for(const fe of K){B.push({role:"user",content:O0(fe)});const we=fe.replies[P];(we==null?void 0:we.status)==="done"&&we.text&&B.push({role:"assistant",content:we.text})}B.push({role:"user",content:O0(ue)});const F=((ye=e.data)==null?void 0:ye.streamable.has(P))??!0,ae=performance.now();let Z,A="",U,V;const M=[],se=(fe,we)=>D(ue.id,P,{status:fe,error:we,text:A,firstTokenMs:Z,promptTokens:U,completionTokens:V,totalMs:performance.now()-ae}),Y=fe=>{fe&&(fe.prompt_tokens!==void 0&&(U=(U??0)+fe.prompt_tokens),fe.completion_tokens!==void 0&&(V=(V??0)+fe.completion_tokens))},ce=(fe,we)=>{Z===void 0&&(Z=performance.now()-ae),we&&A&&(A+=` - -`),A+=fe,D(ue.id,P,{text:A})},re=async()=>{var Mt,Nt,Et,Bt,Rt,Dt,zt;const fe=await fetch("/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({model:P,messages:B,stream:F,...le?{tools:[n9]}:{}}),signal:W});if(!fe.ok||!fe.body){let be=`HTTP ${fe.status}`;try{be=((Mt=(await fe.json()).error)==null?void 0:Mt.message)??be}catch{}return se("error",be),"error"}if(!F){const be=await fe.json(),mt=(Et=(Nt=be.choices)==null?void 0:Nt[0])==null?void 0:Et.message,Q=typeof(mt==null?void 0:mt.content)=="string"?mt.content:"";Q&&ce(Q,!0),Y(be.usage);const Pe=(mt==null?void 0:mt.tool_calls)??[];return Pe.length>0&&B.push({role:"assistant",content:Q||null,tool_calls:Pe}),Pe}const we=fe.body.getReader(),Ee=new TextDecoder,Se=[];let Ie="",Be="";for(;;){const{done:be,value:mt}=await we.read();if(be)break;Be+=Ee.decode(mt,{stream:!0});let Q;for(;(Q=Be.indexOf(` -`))>=0;){const Pe=Be.slice(0,Q).trim();if(Be=Be.slice(Q+1),!Pe.startsWith("data:"))continue;const ne=Pe.slice(5).trim();if(!ne||ne==="[DONE]")continue;let z;try{z=JSON.parse(ne)}catch{continue}const he=(Rt=(Bt=z.choices)==null?void 0:Bt[0])==null?void 0:Rt.delta;he!=null&&he.content&&(ce(he.content,Ie===""),Ie+=he.content);for(const ke of(he==null?void 0:he.tool_calls)??[]){const ze=ke.index??0;Se[ze]??(Se[ze]={id:"",type:"function",function:{name:"",arguments:""}}),ke.id&&(Se[ze].id=ke.id),(Dt=ke.function)!=null&&Dt.name&&(Se[ze].function.name+=ke.function.name),(zt=ke.function)!=null&&zt.arguments&&(Se[ze].function.arguments+=ke.function.arguments)}Y(z.usage)}}return Se.length>0&&B.push({role:"assistant",content:Ie||null,tool_calls:Se}),Se};try{for(let fe=0;fe{const P=f.trim();if(!P&&m.length===0||r.length===0||x)return;const K=c,ue={id:k.current++,text:P,images:m,replies:{}};for(const W of r)ue.replies[W]={text:"",status:"streaming"};d([...K,ue]),h(""),v([]),b(!0),requestAnimationFrame(()=>{var W;return(W=T.current)==null?void 0:W.scrollIntoView({behavior:"smooth"})});const le=new AbortController;y.current=le,await Promise.all(r.map(W=>I(W,K,ue,l,le.signal))),b(!1)},E=()=>{var P;return(P=y.current)==null?void 0:P.abort()},N=P=>{for(const K of P){if(!K.type.startsWith("image/"))continue;const ue=new FileReader;ue.onload=()=>{const le=ue.result;typeof le=="string"&&v(W=>[...W,{name:K.name,dataUrl:le}])},ue.readAsDataURL(K)}},L=P=>{const K=Array.from(P.clipboardData.files);K.length>0&&(P.preventDefault(),N(K))},X=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),O())};return e.loading&&!e.data?s.jsx(kt,{}):e.error?s.jsx("p",{className:"text-sm text-destructive",children:e.error}):s.jsxs(Ke,{children:[s.jsxs(Ze,{children:[s.jsx(Je,{className:"font-serif",children:"Playground"}),s.jsx(it,{children:"Chat with your models straight from the browser; nothing is saved."}),s.jsxs(gE,{className:"flex flex-wrap items-center justify-end gap-2",children:[s.jsxs(Me,{variant:l?"secondary":"outline","aria-pressed":l,title:"Let the model fetch public web pages",onClick:()=>o(P=>!P),children:[s.jsx(c1,{}),"Web fetch: ",l?"on":"off"]}),s.jsxs(xk,{children:[s.jsx(vk,{asChild:!0,children:s.jsxs(Me,{variant:"outline",children:[r.length===0?"Select models":r.length===1?r[0]:`${r.length} models`,s.jsx(Ji,{})]})}),s.jsxs(yk,{align:"end",className:"max-h-96",children:[s.jsx(Lm,{className:"font-normal text-muted-foreground",children:"Pick several to compare"}),s.jsx(bk,{}),C.length===0&&s.jsx(Lm,{className:"font-normal text-muted-foreground",children:"No chat models configured"}),C.map(P=>s.jsx(t9,{checked:r.includes(P),onCheckedChange:K=>R(P,K===!0),onSelect:K=>K.preventDefault(),children:P},P))]})]}),c.length>0&&s.jsxs(Me,{variant:"outline",disabled:x,onClick:()=>d([]),children:[s.jsx($m,{}),"Clear chat"]})]})]}),s.jsxs(Qe,{className:"flex flex-col gap-6",children:[c.length===0&&s.jsx("p",{className:"py-12 text-center text-sm text-muted-foreground",children:r.length===0?"Select a model to start.":"Send a message to start."}),c.map(P=>s.jsx(i9,{turn:P},P.id)),s.jsx("div",{ref:T}),s.jsxs("div",{className:"flex flex-col gap-2 border-t pt-4",children:[m.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:m.map((P,K)=>s.jsxs("div",{className:"relative",children:[s.jsx("img",{src:P.dataUrl,alt:P.name,className:"h-16 w-16 rounded-md border object-cover"}),s.jsx(Me,{variant:"secondary",size:"icon-sm","aria-label":`Remove ${P.name}`,className:"absolute -top-2 -right-2 size-5 rounded-full",onClick:()=>v(ue=>ue.filter((le,W)=>W!==K)),children:s.jsx(Fm,{className:"size-3"})})]},K))}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsx("input",{ref:j,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:P=>{N(P.target.files??[]),P.target.value=""}}),s.jsx(Me,{variant:"outline",size:"icon","aria-label":"Attach image",title:"Attach image",onClick:()=>{var P;return(P=j.current)==null?void 0:P.click()},children:s.jsx(rE,{})}),s.jsx(L6,{className:"max-h-48 min-h-9",rows:1,placeholder:r.length>1?`Message ${r.length} models`:"Message",value:f,onChange:P=>h(P.target.value),onKeyDown:X,onPaste:L}),x?s.jsx(Me,{variant:"outline",size:"icon","aria-label":"Stop",title:"Stop",onClick:E,children:s.jsx(sE,{})}):s.jsx(Me,{size:"icon","aria-label":"Send",title:"Send",disabled:!f.trim()&&m.length===0||r.length===0,onClick:()=>void O(),children:s.jsx(iE,{})})]})]})]})]})}function i9({turn:e}){const r=Object.keys(e.replies);return s.jsxs("div",{className:"flex flex-col gap-3",children:[s.jsx("div",{className:"ml-auto max-w-[85%]",children:s.jsxs("div",{className:"rounded-lg bg-primary px-3 py-2 text-sm whitespace-pre-wrap text-primary-foreground",children:[e.images.length>0&&s.jsx("div",{className:"mb-1 flex flex-wrap gap-2",children:e.images.map((a,l)=>s.jsx("img",{src:a.dataUrl,alt:a.name,className:"max-h-40 rounded-md"},l))}),e.text]})}),s.jsx("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(260px,1fr))]",children:r.map(a=>s.jsx(s9,{model:a,reply:e.replies[a],solo:r.length===1},a))})]})}function s9({model:e,reply:r,solo:a}){return s.jsxs("div",{className:a?"":"rounded-lg border p-3",children:[s.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[s.jsx(pn,{variant:"secondary",className:"font-mono",children:e}),r.status==="streaming"&&s.jsx(kt,{className:"size-3"}),s.jsx(o9,{reply:r})]}),r.tools&&r.tools.length>0&&s.jsx("div",{className:"mb-1 flex flex-col gap-0.5",children:r.tools.map((l,o)=>s.jsxs("span",{className:"flex items-center gap-1 break-all text-xs text-muted-foreground",children:[s.jsx(c1,{className:"size-3 shrink-0"}),l]},o))}),r.status==="error"?s.jsx("p",{className:"text-sm text-destructive",children:r.error}):s.jsx("div",{className:"text-sm",children:r.text?s.jsx(z6,{text:r.text}):r.status==="done"&&s.jsx("span",{className:"text-muted-foreground",children:"(empty response)"})})]})}function o9({reply:e}){if(e.status!=="done")return null;const r=[];if(e.firstTokenMs!==void 0&&r.push(`${(e.firstTokenMs/1e3).toFixed(2)}s to first token`),e.totalMs!==void 0&&r.push(`${(e.totalMs/1e3).toFixed(2)}s total`),e.completionTokens&&e.totalMs){const a=e.firstTokenMs!==void 0&&e.totalMs-e.firstTokenMs>100?e.totalMs-e.firstTokenMs:e.totalMs;r.push(`${(e.completionTokens/(a/1e3)).toFixed(1)} tok/s`)}return(e.promptTokens!==void 0||e.completionTokens!==void 0)&&r.push(`${e.promptTokens??"?"} in / ${e.completionTokens??"?"} out`),r.length===0?null:s.jsx("span",{className:"text-xs text-muted-foreground",children:r.join(" · ")})}const z0="llmproxy-theme",Sk=S.createContext({theme:"system",resolvedTheme:"light",setTheme:()=>{}});function L0(){return matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function u9({children:e}){const[r,a]=S.useState(()=>{const d=localStorage.getItem(z0);return d==="light"||d==="dark"?d:"system"}),l=r==="system"?L0():r,o=S.useCallback(d=>{const f=d==="system"?L0():d;document.documentElement.classList.toggle("dark",f==="dark")},[]),c=S.useCallback(d=>{a(d),localStorage.setItem(z0,d),o(d)},[o]);return S.useEffect(()=>{o(r);const d=matchMedia("(prefers-color-scheme: dark)"),f=()=>o(r);return d.addEventListener("change",f),()=>d.removeEventListener("change",f)},[r,o]),s.jsx(Sk.Provider,{value:{theme:r,resolvedTheme:l,setTheme:c},children:e})}function jk(){return S.useContext(Sk)}function c9(){const[e,r]=S.useState(null),[a,l]=S.useState(!1),o=S.useCallback(()=>{He.get("/auth/me").then(r).catch(()=>l(!0))},[]);return S.useEffect(o,[o]),a?s.jsx("div",{className:"flex min-h-screen items-center justify-center",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:"The proxy is not reachable. Reload to retry."})}):e===null?s.jsx("div",{className:"flex min-h-screen items-center justify-center",children:s.jsx(kt,{className:"size-6"})}):e.authenticated?s.jsx(m9,{me:e}):s.jsx(xE,{me:e,onLogin:o})}function d9(){const{theme:e,setTheme:r}=jk(),a={light:"dark",dark:"system",system:"light"},l={light:s.jsx(uE,{}),dark:s.jsx(lE,{}),system:s.jsx(oE,{})};return s.jsx(Me,{variant:"ghost",size:"icon","aria-label":`Theme: ${e}. Switch to ${a[e]}`,title:`Theme: ${e}`,onClick:()=>r(a[e]),children:l[e]})}const f9=["providers","models","users","services","all-keys"],h9=["overview","apps","models","providers","errors","performance"];function U0(e){const r=window.location.pathname.replace(/^\/+/,"").split("/");let a=r[0];if(a==="activity"&&(a="requests"),e&&f9.includes(a))return{tab:"admin",sub:a,usageSub:"overview"};const l=["usage","requests","keys","playground"].includes(a)?a:"usage",o=l==="usage"&&h9.includes(r[1])?r[1]:"overview";return{tab:l,sub:"providers",usageSub:o}}function m9({me:e}){const r=e.role==="admin",[a,l]=S.useState(()=>U0(r));S.useEffect(()=>{const h=()=>l(U0(r));return window.addEventListener("popstate",h),()=>window.removeEventListener("popstate",h)},[r]);const o=h=>{l(h);let m="/"+(h.tab==="admin"?h.sub:h.tab);if(h.tab==="usage"&&h.usageSub!=="overview"&&(m+="/"+h.usageSub),window.location.pathname!==m){const v=a.tab==="usage"&&h.tab==="usage";window.history.pushState(null,"",m+(v?window.location.search:""))}},c=h=>o({...a,tab:h}),d=h=>o({...a,tab:"admin",sub:h}),f=h=>o({...a,tab:"usage",usageSub:h});return s.jsxs(Sm,{value:a.tab,onValueChange:c,children:[s.jsx("header",{className:"border-b bg-card",children:s.jsxs("div",{className:"mx-auto flex max-w-6xl flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3",children:[s.jsxs("a",{href:"/usage",onClick:h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),c("usage"))},className:"flex items-center gap-2 rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50",children:[s.jsx(n1,{className:"h-6"}),s.jsx("span",{className:"font-serif text-lg font-semibold",children:"llmproxy"})]}),s.jsxs(jm,{children:[s.jsx(or,{value:"usage",children:"Usage"}),s.jsx(or,{value:"requests",children:"Requests"}),s.jsx(or,{value:"keys",children:"API keys"}),s.jsx(or,{value:"playground",children:"Playground"}),r&&s.jsx(or,{value:"admin",children:"Admin"})]}),s.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[s.jsx(d9,{}),s.jsxs(xk,{children:[s.jsx(vk,{asChild:!0,children:s.jsxs(Me,{variant:"ghost",className:"gap-2",children:[s.jsx(eE,{}),s.jsx("span",{className:"max-w-40 truncate",children:e.name}),r&&s.jsx(pn,{variant:"secondary",children:"admin"})]})}),s.jsxs(yk,{align:"end",children:[s.jsxs(Lm,{className:"font-normal text-muted-foreground",children:["Signed in as ",e.name]}),s.jsx(bk,{}),s.jsx(e9,{onClick:()=>window.location.href="/auth/logout",children:"Sign out"})]})]})]})]})}),s.jsxs("main",{className:"mx-auto flex w-full max-w-6xl flex-col gap-6 px-4 py-8",children:[s.jsx(Dr,{value:"usage",children:s.jsx(gR,{ssoEnabled:e.sso_enabled,sub:a.usageSub,onSubChange:f})}),s.jsx(Dr,{value:"requests",children:s.jsx(nD,{})}),s.jsx(Dr,{value:"keys",children:s.jsx(zA,{})}),s.jsx(Dr,{value:"playground",forceMount:!0,className:"data-[state=inactive]:hidden",children:s.jsx(l9,{})}),r&&s.jsx(Dr,{value:"admin",children:s.jsxs(Sm,{value:a.sub,onValueChange:d,className:"gap-6",children:[s.jsxs(jm,{children:[s.jsx(or,{value:"providers",children:"Providers"}),s.jsx(or,{value:"models",children:"Models"}),s.jsx(or,{value:"users",children:"Users"}),s.jsx(or,{value:"services",children:"Services"}),s.jsx(or,{value:"all-keys",children:"All keys"})]}),s.jsx(Dr,{value:"providers",children:s.jsx(CR,{})}),s.jsx(Dr,{value:"models",children:s.jsx(VR,{})}),s.jsx(Dr,{value:"users",children:s.jsx(aD,{})}),s.jsx(Dr,{value:"services",children:s.jsx(iD,{})}),s.jsx(Dr,{value:"all-keys",children:s.jsx(sD,{})})]})})]})]})}const p9=({...e})=>{const{resolvedTheme:r}=jk();return s.jsx(FE,{theme:r,className:"toaster group",style:{"--normal-bg":"var(--color-popover)","--normal-text":"var(--color-popover-foreground)","--normal-border":"var(--color-border)"},...e})};Y2.createRoot(document.getElementById("root")).render(s.jsx(S.StrictMode,{children:s.jsxs(u9,{children:[s.jsx(c9,{}),s.jsx(p9,{position:"bottom-right"})]})})); diff --git a/internal/server/uidist/index.html b/internal/server/uidist/index.html index a11edd9..cf85bcd 100644 --- a/internal/server/uidist/index.html +++ b/internal/server/uidist/index.html @@ -14,8 +14,8 @@ } } catch {} - - + +
diff --git a/internal/server/usagerec.go b/internal/server/usagerec.go index 6649855..9b6ac68 100644 --- a/internal/server/usagerec.go +++ b/internal/server/usagerec.go @@ -126,6 +126,8 @@ type usageOutcome struct { // TS is when the response ended, taken before the async hop so that // TS minus DurationMs is the request's start. TS string + // FailedOver marks an attempt given up on before another alias target was tried. + FailedOver bool } // extractUsage pulls the usage object out of a unary JSON response. @@ -338,7 +340,9 @@ func (s *Server) priceAndInsert(ctx context.Context, ev *store.UsageEvent, provi if pricedAny { ev.Cost = sql.NullFloat64{Float64: cost, Valid: true} } - s.metrics.ObserveRequest(ev.Endpoint, providerName, ev.Alias, ev.Outcome, ev.DurationMs) + if !ev.FailedOver { + s.metrics.ObserveRequest(ev.Endpoint, providerName, ev.Alias, ev.Outcome, ev.DurationMs) + } if err := s.store.InsertUsageEvent(ctx, ev, rows); err != nil { // Never let accounting failures break or block the data plane. slog.Error("failed to record usage event", "error", err) @@ -362,6 +366,7 @@ func (s *Server) recordUsage(ctx context.Context, auth *Auth, route *catalog.Rou DurationMs: rec.DurationMs, TTFTMs: rec.TTFTMs, TS: rec.TS, + FailedOver: rec.FailedOver, } if rec.StatusCode != 0 { ev.StatusCode = sql.NullInt64{Int64: int64(rec.StatusCode), Valid: true} diff --git a/internal/store/migrate.go b/internal/store/migrate.go index 2ae6bda..a668432 100644 --- a/internal/store/migrate.go +++ b/internal/store/migrate.go @@ -82,6 +82,8 @@ var migrations = []migration{ addColumn("009_model_binding_hidden", "model_binding", "hidden", "INTEGER NOT NULL DEFAULT 0"), addColumn("010_provider_rate_limit_headers", "provider", "rate_limit_headers", "TEXT NOT NULL DEFAULT ''"), addColumn("011_usage_event_ttft_ms", "usage_event", "ttft_ms", "INTEGER"), + addColumn("012_model_binding_strategy", "model_binding", "strategy", "TEXT NOT NULL DEFAULT ''"), + addColumn("013_usage_event_failed_over", "usage_event", "failed_over", "INTEGER NOT NULL DEFAULT 0"), } // migrate applies every pending migration in order. Each runs in its own diff --git a/internal/store/migrate_test.go b/internal/store/migrate_test.go index 339a3b8..78f768e 100644 --- a/internal/store/migrate_test.go +++ b/internal/store/migrate_test.go @@ -75,7 +75,7 @@ func TestMigrateUpgradesLegacyDump(t *testing.T) { t.Fatalf("begin: %v", err) } defer func() { _ = tx.Rollback() }() - for _, col := range []string{"client", "tags", "ttft_ms"} { + for _, col := range []string{"client", "tags", "ttft_ms", "failed_over"} { ok, err := st.columnExists(ctx, tx, "usage_event", col) if err != nil { t.Fatalf("columnExists %s: %v", col, err) diff --git a/internal/store/providers.go b/internal/store/providers.go index 00234a9..ae7b627 100644 --- a/internal/store/providers.go +++ b/internal/store/providers.go @@ -4,6 +4,8 @@ import ( "context" "database/sql" "errors" + "sort" + "strings" "github.com/greyhavenhq/llmproxy/internal/secrets" ) @@ -111,6 +113,9 @@ func (s *Store) DeleteProvider(ctx context.Context, providerID string, audit *Au return err } defer tx.Rollback() + if err := s.dropProviderTargetsTx(ctx, tx, providerID); err != nil { + return err + } for _, stmt := range []string{ // Aliases of this provider's models go with them; leaving them would // strand rows pointing at nothing. @@ -161,7 +166,7 @@ const bindingColumns = `b.id, b.alias, COALESCE(t.provider_id, b.provider_id), COALESCE(t.upstream_name, b.upstream_name), COALESCE(t.capability_set, b.capability_set), b.origin, b.discovered_at, b.created_at, b.target_id, COALESCE(t.alias, ''), p.name, - b.hidden` + b.hidden, b.strategy` func scanBinding(row interface{ Scan(...any) error }) (*ModelBinding, error) { var b ModelBinding @@ -170,7 +175,7 @@ func scanBinding(row interface{ Scan(...any) error }) (*ModelBinding, error) { var hidden int64 err := row.Scan(&b.ID, &b.Alias, &b.ProviderID, &b.UpstreamName, &b.CapabilitySet, &b.Origin, &b.DiscoveredAt, &b.CreatedAt, - &b.TargetID, &b.TargetAlias, &b.ProviderName, &hidden) + &b.TargetID, &b.TargetAlias, &b.ProviderName, &hidden, &b.Strategy) if err != nil { if errors.Is(err, sql.ErrNoRows) { return nil, nil @@ -178,76 +183,157 @@ func scanBinding(row interface{ Scan(...any) error }) (*ModelBinding, error) { return nil, err } b.Hidden = hidden != 0 + if b.TargetID.Valid { + b.Targets = []BindingTarget{{ID: b.TargetID.String, Alias: b.TargetAlias, Provider: b.ProviderName, Weight: 1}} + } return &b, nil } +// targetsWhere selects bindings with a listed target matching cond, which +// reads columns of the target binding t2 and its provider p2. +func targetsWhere(cond string) string { + return `EXISTS (SELECT 1 FROM model_binding_target bt + JOIN model_binding t2 ON t2.id = bt.target_id + JOIN provider p2 ON p2.id = t2.provider_id + WHERE bt.binding_id = b.id AND ` + cond + `)` +} + +// attachTargets fills Targets for aliases stored in the target table, and +// their capabilities as the intersection over every target. +func (s *Store) attachTargets(ctx context.Context, bindings []*ModelBinding) error { + multi := map[string]*ModelBinding{} + var ids []any + for _, b := range bindings { + if b != nil && b.Strategy != "" { + multi[b.ID] = b + b.Targets = nil + ids = append(ids, b.ID) + } + } + if len(ids) == 0 { + return nil + } + rows, err := s.db.QueryContext(ctx, s.q(` + SELECT bt.binding_id, bt.target_id, t.alias, p.name, bt.weight, t.capability_set + FROM model_binding_target bt JOIN model_binding t ON t.id = bt.target_id + JOIN provider p ON p.id = t.provider_id + WHERE bt.binding_id IN (`+placeholders(len(ids))+`) + ORDER BY bt.binding_id, bt.position`), ids...) + if err != nil { + return err + } + defer rows.Close() + caps := map[string]map[string]bool{} + for rows.Next() { + var bindingID, capabilitySet string + var t BindingTarget + if err := rows.Scan(&bindingID, &t.ID, &t.Alias, &t.Provider, &t.Weight, &capabilitySet); err != nil { + return err + } + b := multi[bindingID] + own := map[string]bool{} + for _, c := range strings.Split(capabilitySet, ",") { + own[c] = true + } + if len(b.Targets) == 0 { + caps[bindingID] = own + } else { + for c := range caps[bindingID] { + if !own[c] { + delete(caps[bindingID], c) + } + } + } + b.Targets = append(b.Targets, t) + } + for id, set := range caps { + list := make([]string, 0, len(set)) + for c := range set { + if c != "" { + list = append(list, c) + } + } + sort.Strings(list) + multi[id].CapabilitySet = strings.Join(list, ",") + } + return rows.Err() +} + +func (s *Store) getBinding(ctx context.Context, where string, arg any) (*ModelBinding, error) { + row := s.db.QueryRowContext(ctx, s.q(`SELECT `+bindingColumns+bindingSource+where), arg) + b, err := scanBinding(row) + if err != nil || b == nil { + return nil, err + } + return b, s.attachTargets(ctx, []*ModelBinding{b}) +} + func (s *Store) GetBindingByID(ctx context.Context, id string) (*ModelBinding, error) { - row := s.db.QueryRowContext(ctx, s.q(`SELECT `+bindingColumns+bindingSource+` WHERE b.id = ?`), id) - return scanBinding(row) + return s.getBinding(ctx, ` WHERE b.id = ?`, id) } func (s *Store) GetBindingByAlias(ctx context.Context, alias string) (*ModelBinding, error) { - row := s.db.QueryRowContext(ctx, s.q(`SELECT `+bindingColumns+bindingSource+` WHERE b.alias = ?`), alias) - return scanBinding(row) + return s.getBinding(ctx, ` WHERE b.alias = ?`, alias) } -func (s *Store) ListBindings(ctx context.Context, providerName string, limit, offset int) ([]ModelBinding, error) { - query := `SELECT ` + bindingColumns + bindingSource - var args []any - if providerName != "" { - query += ` WHERE p.name = ?` - args = append(args, providerName) - } - query += ` ORDER BY b.alias LIMIT ? OFFSET ?` - args = append(args, limit, offset) +func (s *Store) listBindings(ctx context.Context, query string, args ...any) ([]ModelBinding, error) { rows, err := s.db.QueryContext(ctx, s.q(query), args...) if err != nil { return nil, err } - defer rows.Close() var out []ModelBinding for rows.Next() { b, err := scanBinding(rows) if err != nil { + rows.Close() return nil, err } out = append(out, *b) } - return out, rows.Err() + rows.Close() + if err := rows.Err(); err != nil { + return nil, err + } + ptrs := make([]*ModelBinding, len(out)) + for i := range out { + ptrs[i] = &out[i] + } + return out, s.attachTargets(ctx, ptrs) +} + +func (s *Store) ListBindings(ctx context.Context, providerName string, limit, offset int) ([]ModelBinding, error) { + query := `SELECT ` + bindingColumns + bindingSource + var args []any + if providerName != "" { + query += ` WHERE (p.name = ? OR ` + targetsWhere(`p2.name = ?`) + `)` + args = append(args, providerName, providerName) + } + query += ` ORDER BY b.alias LIMIT ? OFFSET ?` + args = append(args, limit, offset) + return s.listBindings(ctx, query, args...) } // ListServableBindings returns bindings on enabled providers, for the // caller-facing model list. An alias is servable when its target's provider -// is enabled, which the resolved join already accounts for. Hidden rows are +// is enabled, which the resolved join already accounts for, or with several +// targets when any target's provider is enabled. Hidden rows are // left out unless includeHidden asks for them; they stay servable either way, // hidden is a listing flag only. func (s *Store) ListServableBindings(ctx context.Context, includeHidden bool) ([]ModelBinding, error) { - where := ` WHERE p.enabled = 1` + where := ` WHERE ((b.strategy = '' AND p.enabled = 1) OR ` + targetsWhere(`p2.enabled = 1`) + `)` if !includeHidden { where += ` AND b.hidden = 0` } - rows, err := s.db.QueryContext(ctx, - s.q(`SELECT `+bindingColumns+bindingSource+where+` ORDER BY b.alias`)) - if err != nil { - return nil, err - } - defer rows.Close() - var out []ModelBinding - for rows.Next() { - b, err := scanBinding(rows) - if err != nil { - return nil, err - } - out = append(out, *b) - } - return out, rows.Err() + return s.listBindings(ctx, `SELECT `+bindingColumns+bindingSource+where+` ORDER BY b.alias`) } // ListBindingsTargeting returns the aliases pointing at a binding, so a // delete can refuse to strand them. func (s *Store) ListBindingsTargeting(ctx context.Context, bindingID string) ([]string, error) { rows, err := s.db.QueryContext(ctx, - s.q(`SELECT alias FROM model_binding WHERE target_id = ? ORDER BY alias`), bindingID) + s.q(`SELECT alias FROM model_binding WHERE target_id = ? + UNION SELECT b.alias FROM model_binding_target bt JOIN model_binding b ON b.id = bt.binding_id + WHERE bt.target_id = ? ORDER BY 1`), bindingID, bindingID) if err != nil { return nil, err } @@ -263,30 +349,157 @@ func (s *Store) ListBindingsTargeting(ctx context.Context, bindingID string) ([] return out, rows.Err() } +// prepareTargets picks the storage form for an alias: one target goes in +// target_id, several go in model_binding_target with a strategy. An alias +// borrows its first target's provider id to satisfy the reference. +func (s *Store) prepareTargets(ctx context.Context, tx *sql.Tx, b *ModelBinding) error { + switch { + case len(b.Targets) == 1: + b.TargetID = sql.NullString{String: b.Targets[0].ID, Valid: true} + b.Strategy = "" + case len(b.Targets) > 1: + b.TargetID = sql.NullString{} + if b.Strategy == "" { + b.Strategy = "failover" + } + for i := range b.Targets { + if b.Targets[i].Weight < 1 { + b.Targets[i].Weight = 1 + } + } + default: + b.Strategy = "" + } + first := b.TargetID.String + if len(b.Targets) > 1 { + first = b.Targets[0].ID + } + if first == "" { + return nil + } + return tx.QueryRowContext(ctx, s.q(`SELECT provider_id FROM model_binding WHERE id = ?`), first). + Scan(&b.ProviderID) +} + // ownRouting returns the columns a row stores for itself. An alias keeps none -// of its own: it borrows the target's provider id only to satisfy the -// reference, and reads everything through the join. +// of its own and reads everything through the join or the target table. func ownRouting(b *ModelBinding) (providerID, upstreamName, capabilitySet string) { - if b.TargetID.Valid { + if b.TargetID.Valid || b.Strategy != "" { return b.ProviderID, "", "" } return b.ProviderID, b.UpstreamName, b.CapabilitySet } +func (s *Store) writeTargetsTx(ctx context.Context, tx *sql.Tx, b *ModelBinding) error { + if _, err := tx.ExecContext(ctx, s.q(`DELETE FROM model_binding_target WHERE binding_id = ?`), b.ID); err != nil { + return err + } + if b.Strategy == "" { + return nil + } + for i, t := range b.Targets { + if _, err := tx.ExecContext(ctx, s.q(` + INSERT INTO model_binding_target (binding_id, target_id, position, weight) VALUES (?, ?, ?, ?)`), + b.ID, t.ID, i, t.Weight); err != nil { + return err + } + } + return nil +} + +// dropProviderTargetsTx removes a provider's models from aliases with several +// targets. An alias left with one target becomes a plain alias, with none it +// is deleted. +func (s *Store) dropProviderTargetsTx(ctx context.Context, tx *sql.Tx, providerID string) error { + rows, err := tx.QueryContext(ctx, s.q(` + SELECT DISTINCT bt.binding_id FROM model_binding_target bt + JOIN model_binding t ON t.id = bt.target_id WHERE t.provider_id = ?`), providerID) + if err != nil { + return err + } + var affected []string + for rows.Next() { + var id string + if err := rows.Scan(&id); err != nil { + rows.Close() + return err + } + affected = append(affected, id) + } + rows.Close() + if err := rows.Err(); err != nil { + return err + } + if _, err := tx.ExecContext(ctx, s.q(`DELETE FROM model_binding_target + WHERE target_id IN (SELECT id FROM model_binding WHERE provider_id = ?)`), providerID); err != nil { + return err + } + for _, id := range affected { + var remaining []string + rows, err := tx.QueryContext(ctx, s.q(` + SELECT target_id FROM model_binding_target WHERE binding_id = ? ORDER BY position`), id) + if err != nil { + return err + } + for rows.Next() { + var t string + if err := rows.Scan(&t); err != nil { + rows.Close() + return err + } + remaining = append(remaining, t) + } + rows.Close() + if err := rows.Err(); err != nil { + return err + } + var stmts []string + var args [][]any + switch len(remaining) { + case 0: + stmts = []string{`DELETE FROM model_binding WHERE id = ?`} + args = [][]any{{id}} + case 1: + stmts = []string{ + `DELETE FROM model_binding_target WHERE binding_id = ?`, + `UPDATE model_binding SET strategy = '', target_id = ?, + provider_id = (SELECT provider_id FROM model_binding WHERE id = ?) WHERE id = ?`, + } + args = [][]any{{id}, {remaining[0], remaining[0], id}} + default: + stmts = []string{`UPDATE model_binding SET + provider_id = (SELECT provider_id FROM model_binding WHERE id = ?) WHERE id = ?`} + args = [][]any{{remaining[0], id}} + } + for i, stmt := range stmts { + if _, err := tx.ExecContext(ctx, s.q(stmt), args[i]...); err != nil { + return err + } + } + } + return nil +} + func (s *Store) CreateBinding(ctx context.Context, b *ModelBinding, audit *Audit) error { b.ID = secrets.NewID() b.CreatedAt = Now() - providerID, upstreamName, capabilitySet := ownRouting(b) tx, err := s.db.BeginTx(ctx, nil) if err != nil { return err } defer tx.Rollback() + if err := s.prepareTargets(ctx, tx, b); err != nil { + return err + } + providerID, upstreamName, capabilitySet := ownRouting(b) if _, err := tx.ExecContext(ctx, s.q(` - INSERT INTO model_binding (id, alias, provider_id, upstream_name, capability_set, origin, discovered_at, created_at, target_id, hidden) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), + INSERT INTO model_binding (id, alias, provider_id, upstream_name, capability_set, origin, discovered_at, created_at, target_id, hidden, strategy) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), b.ID, b.Alias, providerID, upstreamName, - capabilitySet, b.Origin, b.DiscoveredAt, b.CreatedAt, b.TargetID, boolInt(b.Hidden)); err != nil { + capabilitySet, b.Origin, b.DiscoveredAt, b.CreatedAt, b.TargetID, boolInt(b.Hidden), b.Strategy); err != nil { + return err + } + if err := s.writeTargetsTx(ctx, tx, b); err != nil { return err } if err := s.auditTx(ctx, tx, audit); err != nil { @@ -301,11 +514,17 @@ func (s *Store) UpdateBinding(ctx context.Context, b *ModelBinding, audit *Audit return err } defer tx.Rollback() + if err := s.prepareTargets(ctx, tx, b); err != nil { + return err + } providerID, upstreamName, capabilitySet := ownRouting(b) if _, err := tx.ExecContext(ctx, s.q(` UPDATE model_binding SET alias = ?, provider_id = ?, upstream_name = ?, capability_set = ?, - target_id = ?, hidden = ? WHERE id = ?`), - b.Alias, providerID, upstreamName, capabilitySet, b.TargetID, boolInt(b.Hidden), b.ID); err != nil { + target_id = ?, hidden = ?, strategy = ? WHERE id = ?`), + b.Alias, providerID, upstreamName, capabilitySet, b.TargetID, boolInt(b.Hidden), b.Strategy, b.ID); err != nil { + return err + } + if err := s.writeTargetsTx(ctx, tx, b); err != nil { return err } if err := s.auditTx(ctx, tx, audit); err != nil { @@ -320,9 +539,13 @@ func (s *Store) DeleteBinding(ctx context.Context, bindingID string, audit *Audi return err } defer tx.Rollback() - if _, err := tx.ExecContext(ctx, - s.q(`DELETE FROM model_binding WHERE id = ?`), bindingID); err != nil { - return err + for _, stmt := range []string{ + `DELETE FROM model_binding_target WHERE binding_id = ?`, + `DELETE FROM model_binding WHERE id = ?`, + } { + if _, err := tx.ExecContext(ctx, s.q(stmt), bindingID); err != nil { + return err + } } if err := s.auditTx(ctx, tx, audit); err != nil { return err @@ -330,23 +553,54 @@ func (s *Store) DeleteBinding(ctx context.Context, bindingID string, audit *Audi return tx.Commit() } -// ResolveAlias loads the routing row for an alias on an enabled provider, or -// nil when there is none. -func (s *Store) ResolveAlias(ctx context.Context, alias string) (*ModelBinding, *Provider, map[string]string, error) { +// ResolveAlias loads an alias and its servable targets in order: the binding +// itself when it routes through one hop or less, each listed target on an +// enabled provider otherwise. A nil binding means there is nothing to serve. +func (s *Store) ResolveAlias(ctx context.Context, alias string) (*ModelBinding, []ResolvedTarget, error) { binding, err := s.GetBindingByAlias(ctx, alias) if err != nil || binding == nil { - return nil, nil, nil, err + return nil, nil, err + } + var out []ResolvedTarget + if binding.Strategy == "" { + t, err := s.resolveTarget(ctx, binding, 1) + if err != nil || t == nil { + return nil, nil, err + } + return binding, []ResolvedTarget{*t}, nil + } + for _, bt := range binding.Targets { + target, err := s.GetBindingByID(ctx, bt.ID) + if err != nil { + return nil, nil, err + } + if target == nil { + continue + } + t, err := s.resolveTarget(ctx, target, bt.Weight) + if err != nil { + return nil, nil, err + } + if t != nil { + out = append(out, *t) + } + } + if len(out) == 0 { + return nil, nil, nil } + return binding, out, nil +} + +func (s *Store) resolveTarget(ctx context.Context, b *ModelBinding, weight int) (*ResolvedTarget, error) { row := s.db.QueryRowContext(ctx, - s.q(`SELECT `+providerColumns+` FROM provider WHERE id = ? AND enabled = 1`), - binding.ProviderID) + s.q(`SELECT `+providerColumns+` FROM provider WHERE id = ? AND enabled = 1`), b.ProviderID) provider, err := scanProvider(row) if err != nil || provider == nil { - return nil, nil, nil, err + return nil, err } overrides, err := s.ListEndpointOverrides(ctx, provider.ID) if err != nil { - return nil, nil, nil, err + return nil, err } - return binding, provider, overrides, nil + return &ResolvedTarget{Binding: b, Provider: provider, Overrides: overrides, Weight: weight}, nil } diff --git a/internal/store/schema.go b/internal/store/schema.go index ad7dd53..1d83c3b 100644 --- a/internal/store/schema.go +++ b/internal/store/schema.go @@ -82,6 +82,8 @@ CREATE TABLE IF NOT EXISTS provider_endpoint ( -- which is enforced at write time. An alias row inherits its target's -- provider, upstream name and capabilities, so its own upstream_name and -- capability_set are empty and provider_id only satisfies the reference. +-- An alias with several targets leaves target_id empty, lists them in +-- model_binding_target, and sets strategy. One target means no strategy. CREATE TABLE IF NOT EXISTS model_binding ( id TEXT PRIMARY KEY, alias TEXT NOT NULL UNIQUE, @@ -92,15 +94,25 @@ CREATE TABLE IF NOT EXISTS model_binding ( discovered_at TEXT, created_at TEXT NOT NULL, target_id TEXT REFERENCES model_binding(id), - hidden INTEGER NOT NULL DEFAULT 0 + hidden INTEGER NOT NULL DEFAULT 0, + strategy TEXT NOT NULL DEFAULT '' ); +CREATE TABLE IF NOT EXISTS model_binding_target ( + binding_id TEXT NOT NULL REFERENCES model_binding(id), + target_id TEXT NOT NULL REFERENCES model_binding(id), + position INTEGER NOT NULL, + weight INTEGER NOT NULL DEFAULT 1, + PRIMARY KEY (binding_id, target_id) +); +CREATE INDEX IF NOT EXISTS idx_model_binding_target_target ON model_binding_target(target_id); -- client is the caller's User-Agent header, truncated. tags is the caller's -- x-llmproxy-tags header, normalised to a canonical comma-separated -- "key:value" list. Both are header metadata only, never request or response -- content. error_kind is a classification token: the proxy's transport error -- class on unreachable, the upstream's error type/code (sanitised to a short -- identifier charset) on upstream_error. Never an error message: provider --- messages can echo request content. +-- messages can echo request content. failed_over marks an attempt that failed +-- before another alias target was tried. Request counts exclude it. CREATE TABLE IF NOT EXISTS usage_event ( id TEXT PRIMARY KEY, ts TEXT NOT NULL, @@ -120,7 +132,8 @@ CREATE TABLE IF NOT EXISTS usage_event ( cost DOUBLE PRECISION, unpriced INTEGER NOT NULL DEFAULT 0, duration_ms INTEGER NOT NULL DEFAULT 0, - ttft_ms INTEGER + ttft_ms INTEGER, + failed_over INTEGER NOT NULL DEFAULT 0 ); CREATE INDEX IF NOT EXISTS idx_usage_event_ts ON usage_event(ts); CREATE INDEX IF NOT EXISTS idx_usage_event_principal ON usage_event(principal_id); diff --git a/internal/store/targets_test.go b/internal/store/targets_test.go new file mode 100644 index 0000000..15d6168 --- /dev/null +++ b/internal/store/targets_test.go @@ -0,0 +1,264 @@ +package store_test + +import ( + "context" + "database/sql" + "testing" + + "github.com/greyhavenhq/llmproxy/internal/store" +) + +type targetFixture struct { + st *store.Store + pa, pb *store.Provider + a, b *store.ModelBinding +} + +func newTargetFixture(t *testing.T) *targetFixture { + t.Helper() + ctx := context.Background() + f := &targetFixture{st: openTestStore(t)} + mk := func(name string) *store.Provider { + p := &store.Provider{Name: name, WireFormat: "openai", BaseURL: "https://" + name, + VerifyTLS: true, TimeoutConnect: 5, TimeoutRead: 30, Enabled: true} + if err := f.st.CreateProvider(ctx, p, nil, nil); err != nil { + t.Fatal(err) + } + return p + } + f.pa, f.pb = mk("pa"), mk("pb") + bind := func(alias string, p *store.Provider, caps string) *store.ModelBinding { + b := &store.ModelBinding{Alias: alias, ProviderID: p.ID, UpstreamName: "up-" + alias, + CapabilitySet: caps, Origin: "declared"} + if err := f.st.CreateBinding(ctx, b, nil); err != nil { + t.Fatal(err) + } + return b + } + f.a = bind("a", f.pa, "chat,chat_stream,embeddings") + f.b = bind("b", f.pb, "chat,chat_stream") + return f +} + +func (f *targetFixture) alias(t *testing.T, name string) *store.ModelBinding { + t.Helper() + b, err := f.st.GetBindingByAlias(context.Background(), name) + if err != nil || b == nil { + t.Fatalf("get %s: %v %v", name, b, err) + } + return b +} + +func TestAliasTargetsRoundTrip(t *testing.T) { + ctx := context.Background() + f := newTargetFixture(t) + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", Strategy: "weighted", + Targets: []store.BindingTarget{{ID: f.b.ID, Weight: 3}, {ID: f.a.ID, Weight: 1}}} + if err := f.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } + got := f.alias(t, "ha") + if got.Strategy != "weighted" || len(got.Targets) != 2 { + t.Fatalf("got %+v", got) + } + if got.Targets[0].Alias != "b" || got.Targets[0].Weight != 3 || got.Targets[1].Alias != "a" || + got.Targets[0].Provider != "pb" || got.Targets[1].Provider != "pa" { + t.Fatalf("targets = %+v", got.Targets) + } + if got.TargetID.Valid { + t.Fatal("multi-target alias must not set target_id") + } + if got.CapabilitySet != "chat,chat_stream" { + t.Fatalf("capabilities = %q, want the intersection", got.CapabilitySet) + } + + list, err := f.st.ListBindings(ctx, "", 100, 0) + if err != nil { + t.Fatal(err) + } + for _, b := range list { + if b.Alias == "ha" && (len(b.Targets) != 2 || b.CapabilitySet != "chat,chat_stream") { + t.Fatalf("list targets = %+v", b.Targets) + } + } + for _, p := range []string{"pa", "pb"} { + byProvider, err := f.st.ListBindings(ctx, p, 100, 0) + if err != nil { + t.Fatal(err) + } + found := false + for _, b := range byProvider { + found = found || b.Alias == "ha" + } + if !found { + t.Fatalf("ha not listed under provider %s", p) + } + } +} + +func TestAliasSwitchBetweenOneAndSeveralTargets(t *testing.T) { + ctx := context.Background() + f := newTargetFixture(t) + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", + Targets: []store.BindingTarget{{ID: f.a.ID}}} + if err := f.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } + got := f.alias(t, "ha") + if !got.TargetID.Valid || got.TargetID.String != f.a.ID || got.Strategy != "" { + t.Fatalf("one target: %+v", got) + } + if len(got.Targets) != 1 || got.Targets[0].Alias != "a" || got.UpstreamName != "up-a" { + t.Fatalf("one target read: %+v", got) + } + + got.Targets = []store.BindingTarget{{ID: f.a.ID}, {ID: f.b.ID}} + got.Strategy = "round_robin" + if err := f.st.UpdateBinding(ctx, got, nil); err != nil { + t.Fatal(err) + } + got = f.alias(t, "ha") + if got.TargetID.Valid || got.Strategy != "round_robin" || len(got.Targets) != 2 { + t.Fatalf("two targets: %+v", got) + } + if got.Targets[0].Weight != 1 { + t.Fatalf("default weight = %d", got.Targets[0].Weight) + } + + got.Targets = []store.BindingTarget{{ID: f.b.ID}} + got.Strategy = "" + if err := f.st.UpdateBinding(ctx, got, nil); err != nil { + t.Fatal(err) + } + got = f.alias(t, "ha") + if !got.TargetID.Valid || got.TargetID.String != f.b.ID || got.Strategy != "" || len(got.Targets) != 1 { + t.Fatalf("back to one: %+v", got) + } + if got.UpstreamName != "up-b" || got.ProviderName != "pb" { + t.Fatalf("one target routing: %+v", got) + } +} + +func TestDeleteGuardSeesSeveralTargets(t *testing.T) { + ctx := context.Background() + f := newTargetFixture(t) + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", Strategy: "failover", + Targets: []store.BindingTarget{{ID: f.a.ID}, {ID: f.b.ID}}} + if err := f.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } + one := &store.ModelBinding{Alias: "one", Origin: "declared", TargetID: sql.NullString{String: f.b.ID, Valid: true}} + if err := f.st.CreateBinding(ctx, one, nil); err != nil { + t.Fatal(err) + } + got, err := f.st.ListBindingsTargeting(ctx, f.b.ID) + if err != nil { + t.Fatal(err) + } + if len(got) != 2 || got[0] != "ha" || got[1] != "one" { + t.Fatalf("targeting = %v", got) + } +} + +func TestResolveAliasSeveralTargets(t *testing.T) { + ctx := context.Background() + f := newTargetFixture(t) + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", Strategy: "failover", + Targets: []store.BindingTarget{{ID: f.b.ID}, {ID: f.a.ID, Weight: 2}}} + if err := f.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } + b, targets, err := f.st.ResolveAlias(ctx, "ha") + if err != nil || b == nil { + t.Fatalf("resolve: %v %v", b, err) + } + if b.Strategy != "failover" || len(targets) != 2 { + t.Fatalf("resolved %+v %d", b, len(targets)) + } + if targets[0].Binding.Alias != "b" || targets[0].Provider.Name != "pb" || targets[1].Weight != 2 { + t.Fatalf("targets[0] = %+v", targets[0]) + } + + f.pb.Enabled = false + if err := f.st.UpdateProvider(ctx, f.pb, nil); err != nil { + t.Fatal(err) + } + _, targets, err = f.st.ResolveAlias(ctx, "ha") + if err != nil || len(targets) != 1 || targets[0].Binding.Alias != "a" { + t.Fatalf("disabled provider target not dropped: %+v %v", targets, err) + } + servable, err := f.st.ListServableBindings(ctx, false) + if err != nil { + t.Fatal(err) + } + found := false + for _, s := range servable { + found = found || s.Alias == "ha" + } + if !found { + t.Fatal("ha must stay servable while one target provider is enabled") + } + + _, direct, err := f.st.ResolveAlias(ctx, "a") + if err != nil || len(direct) != 1 || direct[0].Binding.UpstreamName != "up-a" { + t.Fatalf("direct resolve: %+v %v", direct, err) + } +} + +func TestDeleteProviderShrinksAliasTargets(t *testing.T) { + ctx := context.Background() + f := newTargetFixture(t) + ha := &store.ModelBinding{Alias: "ha", Origin: "declared", Strategy: "failover", + Targets: []store.BindingTarget{{ID: f.a.ID}, {ID: f.b.ID}}} + if err := f.st.CreateBinding(ctx, ha, nil); err != nil { + t.Fatal(err) + } + if err := f.st.DeleteProvider(ctx, f.pa.ID, nil); err != nil { + t.Fatal(err) + } + got := f.alias(t, "ha") + if got.Strategy != "" || !got.TargetID.Valid || got.TargetID.String != f.b.ID || got.ProviderName != "pb" { + t.Fatalf("after provider delete: %+v", got) + } +} + +func TestUsageEventFailedOverRoundTrip(t *testing.T) { + ctx := context.Background() + st := openTestStore(t) + ev := &store.UsageEvent{PrincipalID: "p", APIKeyID: "k", ProviderID: "x", Alias: "ha", + UpstreamName: "u", Endpoint: "chat", Outcome: "unreachable", FailedOver: true} + if err := st.InsertUsageEvent(ctx, ev, nil); err != nil { + t.Fatal(err) + } + evs, err := st.ListUsageEvents(ctx) + if err != nil || len(evs) != 1 || !evs[0].FailedOver { + t.Fatalf("events = %+v %v", evs, err) + } +} + +func TestRequestCountsExcludeFailedOver(t *testing.T) { + ctx := context.Background() + st := openTestStore(t) + for _, ev := range []*store.UsageEvent{ + {PrincipalID: "p", APIKeyID: "k", ProviderID: "x", Alias: "ha", UpstreamName: "u", + Endpoint: "chat", Outcome: "upstream_error", StatusCode: sql.NullInt64{Int64: 429, Valid: true}, FailedOver: true}, + {PrincipalID: "p", APIKeyID: "k", ProviderID: "y", Alias: "ha", UpstreamName: "u", + Endpoint: "chat", Outcome: "ok", StatusCode: sql.NullInt64{Int64: 200, Valid: true}}, + } { + if err := st.InsertUsageEvent(ctx, ev, nil); err != nil { + t.Fatal(err) + } + } + summary, err := st.UsageSummary(ctx, "", "", "") + if err != nil || len(summary) != 1 || summary[0].Requests != 1 { + t.Fatalf("summary = %+v %v", summary, err) + } + series, err := st.UsageSeries(ctx, store.UsageFilter{}, false) + if err != nil || len(series) != 1 || series[0].Requests != 1 || series[0].Failed != 0 { + t.Fatalf("series = %+v %v", series, err) + } + errs, err := st.ErrorSeries(ctx, store.UsageFilter{}, false) + if err != nil || len(errs) != 1 || errs[0].Requests != 2 { + t.Fatalf("error series = %+v %v", errs, err) + } +} diff --git a/internal/store/types.go b/internal/store/types.go index 011f330..4eb10be 100644 --- a/internal/store/types.go +++ b/internal/store/types.go @@ -97,6 +97,27 @@ type ModelBinding struct { // TargetAlias is empty for a direct binding. TargetAlias string ProviderName string + // Strategy is set only on an alias with two or more targets. + Strategy string + // Targets lists an alias's targets in order, empty for a direct binding. + // On write, two or more targets use the target table, one sets TargetID. + Targets []BindingTarget +} + +type BindingTarget struct { + ID string + Alias string + Provider string + Weight int +} + +// ResolvedTarget is one servable target of an alias, or the binding itself +// when it routes directly. +type ResolvedTarget struct { + Binding *ModelBinding + Provider *Provider + Overrides map[string]string + Weight int } type UsageEvent struct { @@ -128,7 +149,8 @@ type UsageEvent struct { DurationMs int64 // TTFTMs is the time to the first content event of a stream. Null on // unary requests and on streams that ended before any content. - TTFTMs sql.NullInt64 + TTFTMs sql.NullInt64 + FailedOver bool } type UsageQuantity struct { @@ -185,6 +207,7 @@ type RequestLogRow struct { StatusCode sql.NullInt64 Streamed bool Cancelled bool + FailedOver bool Cost sql.NullFloat64 Unpriced bool DurationMs int64 diff --git a/internal/store/usage.go b/internal/store/usage.go index b5b8019..be7be88 100644 --- a/internal/store/usage.go +++ b/internal/store/usage.go @@ -23,11 +23,11 @@ func (s *Store) InsertUsageEvent(ctx context.Context, ev *UsageEvent, quantities defer tx.Rollback() if _, err := tx.ExecContext(ctx, s.q(` INSERT INTO usage_event (id, ts, principal_id, api_key_id, provider_id, alias, upstream_name, - endpoint, client, tags, status_code, outcome, error_kind, cancelled, streamed, cost, unpriced, duration_ms, ttft_ms) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), + endpoint, client, tags, status_code, outcome, error_kind, cancelled, streamed, cost, unpriced, duration_ms, ttft_ms, failed_over) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), ev.ID, ev.TS, ev.PrincipalID, ev.APIKeyID, ev.ProviderID, ev.Alias, ev.UpstreamName, ev.Endpoint, ev.Client, ev.Tags, ev.StatusCode, ev.Outcome, ev.ErrorKind, boolInt(ev.Cancelled), boolInt(ev.Streamed), - ev.Cost, boolInt(ev.Unpriced), ev.DurationMs, ev.TTFTMs); err != nil { + ev.Cost, boolInt(ev.Unpriced), ev.DurationMs, ev.TTFTMs, boolInt(ev.FailedOver)); err != nil { return err } for _, q := range quantities { @@ -45,7 +45,8 @@ func (s *Store) InsertUsageEvent(ctx context.Context, ev *UsageEvent, quantities func (s *Store) ListUsageEvents(ctx context.Context) ([]UsageEvent, error) { rows, err := s.db.QueryContext(ctx, s.q(` SELECT id, ts, principal_id, api_key_id, provider_id, alias, upstream_name, endpoint, - client, tags, status_code, outcome, error_kind, cancelled, streamed, cost, unpriced, duration_ms, ttft_ms + client, tags, status_code, outcome, error_kind, cancelled, streamed, cost, unpriced, duration_ms, ttft_ms, + failed_over FROM usage_event ORDER BY ts`)) if err != nil { return nil, err @@ -54,12 +55,13 @@ func (s *Store) ListUsageEvents(ctx context.Context) ([]UsageEvent, error) { var out []UsageEvent for rows.Next() { var ev UsageEvent - var cancelled, streamed, unpriced int64 + var cancelled, streamed, unpriced, failedOver int64 if err := rows.Scan(&ev.ID, &ev.TS, &ev.PrincipalID, &ev.APIKeyID, &ev.ProviderID, &ev.Alias, &ev.UpstreamName, &ev.Endpoint, &ev.Client, &ev.Tags, &ev.StatusCode, &ev.Outcome, - &ev.ErrorKind, &cancelled, &streamed, &ev.Cost, &unpriced, &ev.DurationMs, &ev.TTFTMs); err != nil { + &ev.ErrorKind, &cancelled, &streamed, &ev.Cost, &unpriced, &ev.DurationMs, &ev.TTFTMs, &failedOver); err != nil { return nil, err } + ev.FailedOver = failedOver != 0 ev.Cancelled = cancelled != 0 ev.Streamed = streamed != 0 ev.Unpriced = unpriced != 0 @@ -100,7 +102,7 @@ func (s *Store) ListRequests(ctx context.Context, f UsageFilter, limit, offset i rows, err := s.db.QueryContext(ctx, s.q(` SELECT e.id, e.ts, COALESCE(pp.name, e.principal_id), `+providerNameSQL+`, e.alias, e.endpoint, e.client, e.tags, e.api_key_id, COALESCE(k.label, ''), COALESCE(k.key_suffix, ''), e.outcome, - e.error_kind, e.status_code, e.streamed, e.cancelled, e.cost, e.unpriced, e.duration_ms, e.ttft_ms + e.error_kind, e.status_code, e.streamed, e.cancelled, e.cost, e.unpriced, e.duration_ms, e.ttft_ms, e.failed_over FROM usage_event e LEFT JOIN principal pp ON e.principal_id = pp.id LEFT JOIN provider p ON e.provider_id = p.id @@ -115,15 +117,16 @@ func (s *Store) ListRequests(ctx context.Context, f UsageFilter, limit, offset i ids := make([]any, 0, limit) for rows.Next() { var r RequestLogRow - var streamed, cancelled, unpriced int64 + var streamed, cancelled, unpriced, failedOver int64 if err := rows.Scan(&r.ID, &r.TS, &r.PrincipalName, &r.Provider, &r.Alias, &r.Endpoint, &r.Client, &r.Tags, &r.APIKeyID, &r.KeyLabel, &r.KeySuffix, &r.Outcome, - &r.ErrorKind, &r.StatusCode, &streamed, &cancelled, &r.Cost, &unpriced, &r.DurationMs, &r.TTFTMs); err != nil { + &r.ErrorKind, &r.StatusCode, &streamed, &cancelled, &r.Cost, &unpriced, &r.DurationMs, &r.TTFTMs, &failedOver); err != nil { return nil, err } r.Streamed = streamed != 0 r.Cancelled = cancelled != 0 r.Unpriced = unpriced != 0 + r.FailedOver = failedOver != 0 r.Units = make(map[string]float64) index[r.ID] = len(out) ids = append(ids, r.ID) @@ -312,6 +315,9 @@ const providerNameSQL = `CASE WHEN p.name IS NOT NULL THEN p.name ` + // request log still show them. const completedSQL = ` AND (e.cancelled = 1 OR e.outcome = 'ok')` +// servedSQL drops attempts that failed over to another target: the request is counted once. +const servedSQL = ` AND e.failed_over = 0` + // addQuantity accumulates one aggregated quantity into a units map, // normalising input_tokens to the non-cached input; see the comment on // anthropicProviderID. @@ -407,6 +413,7 @@ func usageWhere(f UsageFilter) (string, []any) { // Empty principalID/since/until disable the corresponding filter. func (s *Store) UsageSummary(ctx context.Context, principalID, since, until string) ([]UsageSummaryRow, error) { where, args := usageWhere(UsageFilter{PrincipalID: principalID, Since: since, Until: until}) + where += servedSQL rowsByKey := make(map[[3]string]*UsageSummaryRow) events, err := s.db.QueryContext(ctx, s.q(` @@ -542,6 +549,7 @@ func (s *Store) UsageSeries(ctx context.Context, f UsageFilter, hourly bool) ([] bucket = "SUBSTR(e.ts, 1, 13)" } where, args := usageWhere(f) + where += servedSQL // A cancelled request is its own outcome, so the three counts partition // the total exactly. diff --git a/ui/src/components/ModelsCatalog.tsx b/ui/src/components/ModelsCatalog.tsx index b6c8a02..f6dc637 100644 --- a/ui/src/components/ModelsCatalog.tsx +++ b/ui/src/components/ModelsCatalog.tsx @@ -20,6 +20,7 @@ import { import { addBuckets, floorBucket, RANGES } from '@/lib/timerange' import { useAsync } from '@/lib/useAsync' import { useQueryParam } from '@/lib/useQueryParam' +import { strategyLabel } from '@/lib/strategies' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Checkbox } from '@/components/ui/checkbox' @@ -249,6 +250,12 @@ export function ModelsCatalog() { → {r.model.alias_of} )} + {r.model.targets && ( + + → {r.model.targets.join(', ')}{' '} + · {strategyLabel(r.model.strategy)} + + )} diff --git a/ui/src/lib/api.ts b/ui/src/lib/api.ts index 2b222f6..294fd77 100644 --- a/ui/src/lib/api.ts +++ b/ui/src/lib/api.ts @@ -164,6 +164,12 @@ export interface RateLimitSnapshot { reset_tokens_at?: string } +export interface AliasTarget { + alias: string + provider?: string + weight: number +} + export interface Model { alias: string // provider, upstream_name and capabilities are always the resolved ones: @@ -173,6 +179,10 @@ export interface Model { upstream_name: string capabilities: string[] target: string | null + // targets lists an alias with several targets in order; it is empty + // otherwise, and strategy is null. + targets: AliasTarget[] + strategy: string | null origin: string created_at: string // Prices per million units, keyed by unit; a unit without an entry is @@ -207,6 +217,9 @@ export interface CatalogModel { owned_by: string capabilities: string[] alias_of: string | null + // targets and strategy are set on an alias with several targets. + targets: string[] | null + strategy: string | null // Only ever true on a list fetched with include_hidden=1; the plain list // leaves hidden models out. hidden: boolean @@ -239,6 +252,8 @@ export interface RequestRow { status_code: number | null streamed: boolean cancelled: boolean + // failed_over marks an attempt given up on before another target was tried. + failed_over: boolean cost: number | null unpriced: boolean duration_ms: number diff --git a/ui/src/lib/strategies.ts b/ui/src/lib/strategies.ts new file mode 100644 index 0000000..0b0965f --- /dev/null +++ b/ui/src/lib/strategies.ts @@ -0,0 +1,15 @@ +export const STRATEGIES = [ + { value: 'failover', label: 'Failover', hint: 'Use the first target. Try the next one if it fails.' }, + { value: 'round_robin', label: 'Round robin', hint: 'Send each request to the next target in turn.' }, + { value: 'weighted', label: 'Weighted', hint: 'A higher weight gets more requests.' }, + { value: 'least_busy', label: 'Least busy', hint: 'Send each request to the target with the fewest open requests.' }, +] + +export function strategyLabel(strategy: string | null): string { + return STRATEGIES.find((s) => s.value === strategy)?.label ?? strategy ?? '' +} + +export function weightShare(weight: number, weights: number[]): string { + const total = weights.reduce((sum, w) => sum + Math.max(w, 1), 0) + return `${Math.round((Math.max(weight, 1) / total) * 100)}%` +} diff --git a/ui/src/pages/Models.tsx b/ui/src/pages/Models.tsx index ef993be..28d61a0 100644 --- a/ui/src/pages/Models.tsx +++ b/ui/src/pages/Models.tsx @@ -1,7 +1,14 @@ import { useEffect, useRef, useState } from 'react' import { toast } from 'sonner' -import { api, type DiscoveredModel, type Model, type Provider } from '@/lib/api' +import { + api, + type AliasTarget, + type DiscoveredModel, + type Model, + type Provider, +} from '@/lib/api' import { useAsync } from '@/lib/useAsync' +import { STRATEGIES, strategyLabel, weightShare } from '@/lib/strategies' import { Combobox, type ComboboxOption } from '@/components/Combobox' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' @@ -43,7 +50,7 @@ import { AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog' -import { Eye, EyeOff, Pencil, Trash2 } from 'lucide-react' +import { ArrowDown, ArrowUp, Eye, EyeOff, Pencil, Plus, Trash2, X } from 'lucide-react' // vision is declarative: it tells callers the model reads images, and gates // nothing. The others gate the endpoints of the same name. @@ -183,7 +190,8 @@ interface ModelForm { alias: string provider: string upstream_name: string - target: string + targets: AliasTarget[] + strategy: string capabilities: string[] prices: PriceForm } @@ -196,10 +204,162 @@ interface EditState extends ModelForm { // hop, so an alias never targets another alias. function targetOptions(models: Model[], self?: string): ComboboxOption[] { return models - .filter((m) => m.target === null && m.alias !== self) + .filter((m) => m.target === null && m.targets.length === 0 && m.alias !== self) .map((m) => ({ value: m.alias, hint: `${m.provider} · ${m.upstream_name}` })) } +function filledTargets(targets: AliasTarget[]): AliasTarget[] { + return targets + .map((t) => ({ alias: t.alias.trim(), weight: t.weight })) + .filter((t) => t.alias !== '') +} + +// Weighted targets list the most used first. Other strategies keep their order. +function listedTargets(m: { strategy: string | null; targets: AliasTarget[] }): AliasTarget[] { + if (m.strategy !== 'weighted') return m.targets + return [...m.targets].sort((a, b) => b.weight - a.weight) +} + +// An ordered list of targets. The strategy appears once there are two. +function TargetsField({ + id, + targets, + strategy, + options, + onChange, + note, +}: { + id: string + targets: AliasTarget[] + strategy: string + options: ComboboxOption[] + onChange: (targets: AliasTarget[], strategy: string) => void + note?: string +}) { + const several = filledTargets(targets).length > 1 + const set = (next: AliasTarget[]) => onChange(next, strategy) + const move = (i: number, step: number) => { + const next = [...targets] + ;[next[i], next[i + step]] = [next[i + step], next[i]] + set(next) + } + return ( +
+
+ + {several && strategy === 'weighted' && ( + <> + Weight + + + )} +
+ {targets.map((t, i) => ( +
+ set(targets.map((x, j) => (j === i ? { ...x, alias: v } : x)))} + options={options.filter( + (o) => o.value === t.alias || !targets.some((x) => x.alias === o.value), + )} + note={note} + /> + {several && strategy === 'weighted' && ( + + set( + targets.map((x, j) => + j === i ? { ...x, weight: Math.max(1, Number(e.target.value) || 1) } : x, + ), + ) + } + /> + )} + {several && strategy === 'weighted' && ( + + {t.alias.trim() + ? weightShare(t.weight, filledTargets(targets).map((x) => x.weight)) + : ''} + + )} + {targets.length > 1 && ( + <> + + + + + )} +
+ ))} +
+ + {several && ( + <> + + + {STRATEGIES.find((s) => s.value === strategy)?.hint} + + + )} +
+
+ ) +} + // Both kinds stay visible side by side; the fields below follow the choice. function KindSwitch({ value, onChange }: { value: Kind; onChange: (kind: Kind) => void }) { return ( @@ -280,7 +440,8 @@ export function Models() { alias: '', provider: '', upstream_name: '', - target: '', + targets: [{ alias: '', weight: 1 }], + strategy: 'failover', capabilities: ['chat', 'chat_stream'], prices: {}, }) @@ -306,18 +467,21 @@ export function Models() { }, [form.kind, form.provider, form.upstream_name, newDiscovery.loading, newDiscovery.options]) // The two kinds send different bodies; everything else is shared. - const routing = (f: ModelForm) => - f.kind === 'alias' - ? { target: f.target.trim() } - : { - provider: f.provider, - upstream_name: f.upstream_name.trim(), - capabilities: f.capabilities, - } + const routing = (f: ModelForm) => { + if (f.kind === 'alias') { + const targets = filledTargets(f.targets) + return targets.length > 1 ? { targets, strategy: f.strategy } : { targets } + } + return { + provider: f.provider, + upstream_name: f.upstream_name.trim(), + capabilities: f.capabilities, + } + } const invalid = (f: ModelForm): string | null => { if (f.kind === 'alias') { - if (f.target.trim() === '') return 'Pick the model this one points at' + if (filledTargets(f.targets).length === 0) return 'Pick the model this one points at' if (f.alias.trim() === '') return 'An alias for another model needs its own name' return null } @@ -348,7 +512,14 @@ export function Models() { pricing: Object.keys(prices).length > 0 ? prices : undefined, }) toast.success(`Model "${alias}" bound`) - setForm({ ...form, alias: '', upstream_name: '', target: '', prices: {} }) + setForm({ + ...form, + alias: '', + upstream_name: '', + targets: [{ alias: '', weight: 1 }], + strategy: 'failover', + prices: {}, + }) models.reload() } catch (err) { toast.error(errMsg(err)) @@ -378,8 +549,7 @@ export function Models() { alias: editing.alias.trim(), // An empty target turns an alias back into its own binding, which is // why the provider fields ride along. - target: editing.kind === 'alias' ? editing.target.trim() : '', - ...(editing.kind === 'alias' ? {} : routing(editing)), + ...(editing.kind === 'alias' ? routing(editing) : { target: '', ...routing(editing) }), pricing: prices, }) toast.success( @@ -486,20 +656,18 @@ export function Models() { ) : ( -
- - setForm({ ...form, target: v })} - options={targetOptions(allModels)} - note={ - allModels.some((m) => m.target === null) - ? undefined - : 'Bind a provider model first; an alias points at one of those.' - } - /> -
+ setForm({ ...form, targets, strategy })} + note={ + targetOptions(allModels).length > 0 + ? undefined + : 'Bind a provider model first; an alias points at one of those.' + } + /> )} {form.kind === 'provider' && nameField} @@ -528,7 +696,7 @@ export function Models() { busy || (form.kind === 'provider' ? form.provider === '' || form.upstream_name.trim() === '' - : form.target.trim() === '' || form.alias.trim() === '') + : filledTargets(form.targets).length === 0 || form.alias.trim() === '') } > {busy && } @@ -616,15 +784,15 @@ export function Models() { ) : ( -
- - setEditing({ ...editing, target: v })} - options={targetOptions(allModels, editing.original)} - /> -
+ + setEditing({ ...editing, targets, strategy }) + } + /> )}
@@ -682,9 +850,34 @@ export function Models() { {m.hidden && hidden} - {m.provider} + + {m.targets.length > 1 ? ( + + {[...new Set(listedTargets(m).map((t) => t.provider))].map((p) => ( + {p} + ))} + + ) : ( + m.provider + )} + - {m.target ? ( + {m.targets.length > 1 ? ( + + {listedTargets(m).map((t) => ( + + → {t.alias} + {m.strategy === 'weighted' && ( + + {' '} + {weightShare(t.weight, m.targets.map((x) => x.weight))} + + )} + + ))} + {strategyLabel(m.strategy)} + + ) : m.target ? ( // An alias shows what it points at, and under it // where that lands. @@ -724,11 +917,15 @@ export function Models() { onClick={() => setEditing({ original: m.alias, - kind: m.target ? 'alias' : 'provider', + kind: m.target || m.targets.length > 0 ? 'alias' : 'provider', alias: m.alias, provider: m.provider, upstream_name: m.upstream_name, - target: m.target ?? '', + targets: + m.targets.length > 0 + ? m.targets.map((t) => ({ ...t })) + : [{ alias: m.target ?? '', weight: 1 }], + strategy: m.strategy ?? 'failover', capabilities: [...m.capabilities], // Inherited prices show as blank so saving // keeps inheriting; a typed value overrides. diff --git a/ui/src/pages/Requests.tsx b/ui/src/pages/Requests.tsx index fc80e12..c47c79e 100644 --- a/ui/src/pages/Requests.tsx +++ b/ui/src/pages/Requests.tsx @@ -561,6 +561,11 @@ export function Requests() { + {r.failed_over && ( + + failed over + + )} {r.streamed && (