diff --git a/.env.example b/.env.example index e0315178f33869bea3728ab81acd9a69950d0484..ddf4d6103af3c0825af541af1b2b2dac265b39cd 100644 --- a/.env.example +++ b/.env.example @@ -4,10 +4,22 @@ # Nunca commitear el archivo .env real (debe estar en .gitignore). # Ubicacion recomendada: en la raiz del proyecto (al lado de docker-compose.yml). -HF_TOKEN= # HuggingFace Pro API key (Inference API) -OPENROUTER_API_KEY= # Fallback LLM si HF esta saturado -FINNHUB_API_KEY= # Noticias financieras (finnhub.io) -TELEGRAM_BOT_TOKEN= # Bot de alertas (@BotFather) -DATABASE_URL=file:./backend/prisma/polysignal.db # SQLite local (relativo a backend/) -PORT=7860 # HuggingFace Spaces requiere 7860 +# HuggingFace +HF_TOKEN= # HuggingFace Pro API key (Inference API) +HF_SPACE_MODERNFINBERT_URL=blackmistcode/polysignal-modernfinbert +HF_SPACE_QWEN_URL=blackmistcode/polysignal-qwen3-8b + +# Fallbacks y datos +OPENROUTER_API_KEY= # Fallback LLM si HF esta saturado +FINNHUB_API_KEY= # Noticias financieras (finnhub.io) + +# Alertas +TELEGRAM_BOT_TOKEN= # Bot de alertas (@BotFather) + +# Base de datos y auth +DATABASE_URL=file:./backend/prisma/polysignal.db +JWT_SECRET=supersecreto-demasiado-largo-para-la-hackathon-2026 + +# Servidor +PORT=7860 # HuggingFace Spaces requiere 7860 NODE_ENV=production diff --git a/README.md b/README.md index 42bc431579dbb980d417a1f0f6ce77c5cbea1dba..8a3c0a46cd5de6761d6d5e8f7f5a23f970fee967 100644 --- a/README.md +++ b/README.md @@ -8,55 +8,127 @@ PolySignal analiza mercados de Polymarket cruzando noticias de Finnhub con model **No ejecuta ordenes reales.** Es una herramienta de analisis e inteligencia. -**Idioma:** Espanol. +**Idioma:** Espanol. **Moneda base:** Euro (€). ## Stack - **Backend:** Node.js 26 + Express.js 5 + Socket.io + node-cron -- **ORM:** Prisma 7 + SQLite -- **Frontend:** Vanilla JS + Vite 8 + Leaflet.js + Chart.js + Socket.io client -- **IA:** HuggingFace Inference API (ModernFinBERT, Qwen3-8B) + OpenRouter fallback +- **ORM:** Prisma 6 + SQLite +- **Frontend:** Vanilla JS + Vite 7 + Leaflet.js + Chart.js + Socket.io client +- **IA:** HuggingFace Spaces (ModernFinBERT + Qwen3-8B) + OpenRouter fallback - **Datos:** Polymarket Gamma API + Finnhub REST - **Deploy:** HuggingFace Spaces (Docker, puerto 7860) ## Estado del proyecto -> **Nota importante:** El backend actualmente contiene solo stubs/documentacion JSDoc. El frontend funciona de forma independiente con **datos mock** realistas para la demo. Puedes ejecutar y visualizar todo el dashboard sin necesidad de configurar claves de API ni base de datos. +El backend es **totalmente funcional**: + +- API REST completa con autenticacion JWT. +- Pipeline de IA con cadena de fallback (Spaces HF → API HF → OpenRouter → rule-based). +- Scheduler de tareas periodicas (sync mercados, generacion de senales, P&L, alertas). +- WebSocket en tiempo real para precios y senales. +- Base de datos SQLite con Prisma ORM. + +El frontend **consume datos reales del backend** y tiene **fallback a datos mock** cuando el backend no responde (modo demo sin configuracion). ## Estructura ``` polysignal/ -├── backend/ # API REST + Servicios + Scheduler (stubs) +├── backend/ # API REST + Servicios + Scheduler │ ├── package.json │ ├── prisma/ -│ │ └── schema.prisma # Schema SQLite (Prisma) +│ │ ├── schema.prisma # Schema SQLite (User, Market, AISignal, Position, Watchlist, Alert) +│ │ ├── migrations/ # Migraciones de Prisma +│ │ └── seed.js # Usuarios demo (admin + user) │ └── src/ -│ ├── index.js # Entry point Express -│ ├── config.js # Variables de entorno -│ ├── scheduler.js # Jobs periodicos (cron) -│ ├── routes/ # Endpoints REST (/api/v1) -│ ├── services/ # Logica de negocio + integraciones -│ └── socket/ # Eventos Socket.io +│ ├── index.js # Entry point: HTTP server + Socket.io + scheduler +│ ├── app.js # Express: middlewares + rutas + manejo de errores +│ ├── config.js # Variables de entorno validadas con Zod +│ ├── scheduler.js # Jobs periodicos (cron): sync, senales IA, PnL, alertas +│ ├── auth/ # Autenticacion JWT + bcrypt +│ │ ├── auth.controller.js +│ │ ├── auth.service.js +│ │ ├── auth.routes.js +│ │ ├── auth.validators.js +│ │ └── jwt.js +│ ├── markets/ # Mercados de Polymarket +│ │ ├── markets.controller.js +│ │ ├── markets.service.js +│ │ ├── markets.routes.js +│ │ ├── markets.validators.js +│ │ ├── markets.repository.js +│ │ └── polymarket.client.js +│ ├── signals/ # Pipeline de IA (ModernFinBERT + Qwen3-8B) +│ │ ├── signals.controller.js +│ │ ├── signals.service.js +│ │ ├── signals.routes.js +│ │ ├── signals.repository.js +│ │ ├── aiPipeline.js # Pipeline IA con fallback chain +│ │ └── finnhub.client.js # Noticias financieras +│ ├── positions/ # Simulador de posiciones virtuales +│ │ ├── positions.controller.js +│ │ ├── positions.service.js +│ │ ├── positions.routes.js +│ │ ├── positions.validators.js +│ │ ├── positions.repository.js +│ │ └── kelly.js # Criterio de Kelly (sizing) +│ ├── watchlist/ # Lista de seguimiento +│ │ ├── watchlist.controller.js +│ │ ├── watchlist.service.js +│ │ ├── watchlist.routes.js +│ │ ├── watchlist.validators.js +│ │ └── watchlist.repository.js +│ ├── alerts/ # Alertas por Telegram +│ │ ├── alerts.controller.js +│ │ ├── alerts.service.js +│ │ ├── alerts.routes.js +│ │ ├── alerts.repository.js +│ │ └── telegram.client.js +│ ├── middlewares/ # Middlewares reutilizables +│ │ ├── validate.js # Validacion Zod generica +│ │ ├── requireAuth.js # Autenticacion JWT +│ │ ├── rateLimitLogin.js # Rate limit login +│ │ ├── errorHandler.js # Manejo centralizado de errores +│ │ └── notFound.js # 404 +│ ├── utils/ # Utilidades compartidas +│ │ ├── apiResponse.js # Helpers de respuesta HTTP +│ │ ├── httpClient.js # Cliente HTTP con retry + timeout +│ │ ├── logger.js # Pino (logs estructurados) +│ │ └── prisma.js # Singleton PrismaClient +│ └── socket/ +│ └── broadcaster.js # Emisor de eventos Socket.io │ -├── frontend/ # SPA Vanilla JS con Vite -│ ├── index.html # Punto de entrada HTML -│ ├── package.json # Dependencias del frontend -│ ├── vite.config.js # Configuracion de Vite (proxy + build) +├── frontend/ # SPA Vanilla JS con Vite +│ ├── index.html # Punto de entrada HTML +│ ├── package.json +│ ├── vite.config.js # Proxy a backend + build config │ └── src/ -│ ├── main.js # Entry point de Vite -│ ├── app.js # Logica principal SPA + Socket.io -│ ├── api.js # Cliente REST -│ ├── charts.js # Chart.js (historial + sparklines) -│ ├── map.js # Leaflet (mapa mundial interactivo) -│ ├── simulator.js # Simulador de posiciones virtuales -│ └── style.css # Estilos dark terminal / fintech +│ ├── main.js # Entry point de Vite +│ ├── app.js # Logica principal SPA + Socket.io +│ ├── api.js # Cliente REST del backend +│ ├── charts.js # Chart.js (historial + sparklines) +│ ├── map.js # Leaflet (mapa mundial interactivo) +│ ├── simulator.js # Simulador de posiciones virtuales +│ └── style.css # Estilos dark terminal / fintech +│ +├── spaces/ # HuggingFace Spaces (ZeroGPU) +│ ├── modernfinbert/ # Space de ModernFinBERT +│ │ ├── app.py +│ │ ├── requirements.txt +│ │ └── README.md +│ └── qwen3-8b/ # Space de Qwen3-8B +│ ├── app.py +│ ├── Dockerfile +│ ├── requirements.txt +│ └── README.md │ -├── package.json # Root con workspaces + scripts conjuntos -├── docker-compose.yml # Orquestacion local -├── Dockerfile # Build para HuggingFace Spaces -├── .env.example # Variables de entorno de ejemplo +├── package.json # Root con workspaces + scripts conjuntos +├── docker-compose.yml # Orquestacion local +├── Dockerfile # Build para HuggingFace Spaces +├── .env.example # Variables de entorno de ejemplo +├── SECURITY_HEALTHCHECK.md # Auditoria de seguridad y arquitectura └── README.md ``` @@ -71,13 +143,11 @@ polysignal/ # 1. Instalar dependencias (root + todos los workspaces) npm install -# 2. (Opcional) Configurar variables de entorno para backend -# Si solo vas a probar el frontend, este paso NO es necesario. +# 2. Configurar variables de entorno cp .env.example .env -# Editar .env con tus claves +# Editar .env con tus claves (HF_TOKEN, HF_SPACE_*, OPENROUTER_API_KEY, etc.) -# 3. (Opcional) Generar base de datos y cliente Prisma -# Solo necesario si vas a desarrollar el backend. +# 3. Generar base de datos y cliente Prisma npm run db:migrate npm run db:generate @@ -98,9 +168,46 @@ npm run dev El frontend consume datos mock localmente cuando el backend no responde, por lo que el dashboard es totalmente funcional para la demo sin configuracion adicional. +## Arquitectura del Backend + +El backend sigue una arquitectura **Layered (Controller → Service → Repository)**: + +| Capa | Responsabilidad | Ejemplo | +|------|----------------|---------| +| **Controller** | Recibir HTTP request, delegar a Service, responder | `markets.controller.js` | +| **Service** | Logica de negocio, validaciones, coordinacion | `markets.service.js` | +| **Repository** | Acceso a datos via Prisma ORM | `markets.repository.js` | +| **Client** | Integracion con APIs externas | `polymarket.client.js`, `finnhub.client.js` | +| **Middleware** | Cross-cutting concerns (auth, validacion, rate limiting) | `requireAuth.js`, `validate.js` | + +### Pipeline de IA + +``` +Noticias (Finnhub) + ↓ +Filtrado (ModernFinBERT Space / API directa) + ↓ (descarta neutrales, score < 0.65) +Generacion de senal (Qwen3-8B Space / API directa) + ↓ +Fallback: OpenRouter (deepseek-chat) + ↓ +Fallback: Rule-based (precio del mercado) + ↓ +Persistencia (SQLite) + Emision Socket.io +``` + +### Scheduler (node-cron) + +| Job | Frecuencia | Descripcion | +|-----|-----------|-------------| +| syncMarkets | Cada 30s | Sincroniza precios desde Polymarket Gamma API | +| generateSignals | Cada 5 min | Genera senales IA para top 20 mercados activos | +| updatePositionsPnL | Cada 30s | Recalcula P&L de posiciones abiertas | +| processAlerts | Cada 60s | Revisa watchlist y envia alertas Telegram | + ## Arquitectura del Frontend -El frontend es una SPA (Single Page Application) construida con **Vite 8** como bundler y dev server. Las librerias (Chart.js, Leaflet, Socket.io client) se gestionan como dependencias npm en lugar de CDN, lo que permite tree-shaking y un build optimizado para produccion. +El frontend es una SPA construida con **Vite 7** como bundler y dev server. ### Caracteristicas visuales @@ -130,7 +237,7 @@ npm run dev # Levantar solo el frontend (Vite con hot reload) npm run dev:frontend -# Levantar backend y frontend simultaneamente en una sola terminal +# Levantar backend y frontend simultaneamente npm run dev:all # Build de produccion del frontend (genera frontend/dist/) @@ -138,16 +245,13 @@ npm run build:frontend # Preview del build de produccion npm run preview:frontend -``` - -### Build de produccion -```bash -npm run build:frontend +# Base de datos +npm run db:migrate # Crear/actualizar migraciones +npm run db:generate # Generar cliente Prisma +npm run db:studio # Explorar BD con Prisma Studio ``` -Esto genera los assets optimizados en `frontend/dist/`. En produccion (HuggingFace Spaces), el backend Express sirve directamente esa carpeta como archivos estaticos. - ## Deploy en HuggingFace Spaces 1. Crear Space tipo "Docker" @@ -166,6 +270,30 @@ docker build -t polysignal . docker run -p 7860:7860 --env-file .env polysignal ``` +## Variables de entorno + +```env +# HuggingFace +HF_TOKEN= # API key de HuggingFace (Inference API) +HF_SPACE_MODERNFINBERT_URL= # URL del Space (ej: usuario/modernfinbert) +HF_SPACE_QWEN_URL= # URL del Space (ej: usuario/qwen3-8b) + +# Fallbacks y datos +OPENROUTER_API_KEY= # Fallback LLM si HF esta saturado +FINNHUB_API_KEY= # Noticias financieras (finnhub.io) + +# Alertas +TELEGRAM_BOT_TOKEN= # Bot de alertas (@BotFather) + +# Base de datos y auth +DATABASE_URL=file:./backend/prisma/polysignal.db +JWT_SECRET=minimo-32-caracteres # Secreto para firmar JWT + +# Servidor +PORT=7860 # Puerto requerido por HuggingFace Spaces +NODE_ENV=production # development | production +``` + ## Equipo Hackathon CIFO Barcelona La Violeta — 13-18 mayo 2026 diff --git a/backend/package.json b/backend/package.json index eed33a1327ee7d2f5a1662ea30bc13e626f0a485..3e11aee1b8540086661764ebd68a168d0b81da41 100644 --- a/backend/package.json +++ b/backend/package.json @@ -17,6 +17,7 @@ "db:studio": "prisma studio" }, "dependencies": { + "@gradio/client": "^2.2.0", "@prisma/client": "^6.19.2", "bcryptjs": "^2.4.3", "cors": "^2.8.5", diff --git a/backend/src/alerts/alerts.controller.js b/backend/src/alerts/alerts.controller.js index 38958edce4c3389825a280479cdf36f10e9230f8..4a3381b337a9e2589f7174df7315c82db0a639c6 100644 --- a/backend/src/alerts/alerts.controller.js +++ b/backend/src/alerts/alerts.controller.js @@ -1,3 +1,13 @@ +/** + * Controladores del modulo de alertas. + * + * Responsabilidades: + * - list(req, res) → devuelve el historial de alertas del usuario autenticado. + * + * Endpoint (bajo /api/v1/alerts, protegido por requireAuth): + * GET / → lista paginada de alertas. + */ + import { ok } from '../utils/apiResponse.js'; import { alertsService } from './alerts.service.js'; diff --git a/backend/src/alerts/alerts.repository.js b/backend/src/alerts/alerts.repository.js index 7066c27de09dd9da22c09459e15afb31f6e82080..38aa934ed0cc27784c340202b0396d584c59ed45 100644 --- a/backend/src/alerts/alerts.repository.js +++ b/backend/src/alerts/alerts.repository.js @@ -1,3 +1,17 @@ +/** + * Repositorio de acceso a datos para el modelo Alert. + * + * Responsabilidades: + * - create(data) → inserta una nueva alerta. + * - findByUser(...) → alertas paginadas del usuario con datos del mercado. + * - findRecent(...) → busca alerta reciente en ventana de tiempo (deduplicacion). + * + * Campos: + * type (price_threshold|signal_change), message, sentAt. + * + * Todas las operaciones usan Prisma ORM. + */ + import { prisma } from '../utils/prisma.js'; export const alertsRepository = { diff --git a/backend/src/alerts/alerts.routes.js b/backend/src/alerts/alerts.routes.js index e2df712c6b4c71a226d44da022635cf3fcd8ae1f..ea8098dfff721ab0cb353b1a5ab9023698645f10 100644 --- a/backend/src/alerts/alerts.routes.js +++ b/backend/src/alerts/alerts.routes.js @@ -1,3 +1,12 @@ +/** + * Rutas REST del modulo de alertas. + * + * Endpoint (montado en /api/v1/alerts): + * GET / → listar alertas del usuario autenticado. + * + * Requiere autenticacion JWT (router.use(requireAuth)). + */ + import { Router } from 'express'; import { requireAuth } from '../middlewares/requireAuth.js'; import { alertsController } from './alerts.controller.js'; diff --git a/backend/src/alerts/alerts.service.js b/backend/src/alerts/alerts.service.js index ba9ee38cb5e3a5e58348cf9369799d43cfca5cf5..1babeb25f217603accecbb2758f63befcf4c4a9a 100644 --- a/backend/src/alerts/alerts.service.js +++ b/backend/src/alerts/alerts.service.js @@ -1,3 +1,24 @@ +/** + * Logica de negocio del modulo de alertas. + * + * Responsabilidades: + * - list(userId, query) → devuelve alertas paginadas del usuario. + * - processAll() → revisa la watchlist cada 60s (scheduler): + * 1. Obtiene entradas de watchlist con alertThreshold. + * 2. Si yesPrice >= alertThreshold y no hay alerta reciente (5 min dedup): + * - Crea alerta en base de datos. + * - Envía mensaje por Telegram (si hay bot token y chatId). + * - Emite evento 'price_alert' por Socket.io. + * + * Tipos de alerta: + * - price_threshold : umbral de precio cruzado. + * - signal_change : cambio de senal IA (reservado para futuras versiones). + * + * Consumido por: + * - alerts.controller.js (API REST). + * - scheduler.js (processAlerts cada 60s). + */ + import { z } from 'zod'; import { alertsRepository } from './alerts.repository.js'; import { watchlistRepository } from '../watchlist/watchlist.repository.js'; diff --git a/backend/src/alerts/telegram.client.js b/backend/src/alerts/telegram.client.js index b2f23189c3009944bae5d2e77e499e60c9f4a320..21e807231feec97183fb88709a226d7d00df6d97 100644 --- a/backend/src/alerts/telegram.client.js +++ b/backend/src/alerts/telegram.client.js @@ -1,3 +1,20 @@ +/** + * Servicio de envio de alertas por Telegram Bot API. + * + * Responsabilidades: + * - sendMessage(chatId, text) → POST a api.telegram.org/bot/sendMessage. + * - Parse_mode: HTML (permite formato basico: , ). + * - Si falta TELEGRAM_BOT_TOKEN o chatId, la funcion retorna silenciosamente. + * - Errores de red se capturan y loguean como warn (no bloquean el flujo). + * + * Consumido por: + * - alerts.service.js → processAll() cuando se dispara una alerta. + * + * Seguridad: + * - El token se lee de variables de entorno (nunca hardcodeado). + * - Se recomienda escapar entidades HTML si el texto incluye input de usuario. + */ + import { httpPost } from '../utils/httpClient.js'; import { config } from '../config.js'; import { logger } from '../utils/logger.js'; diff --git a/backend/src/app.js b/backend/src/app.js index 539af09abe9082441fe178f07cc99dffe3d1d278..85e84eb5acfb2185fd8274ab9a3e3dd136fe2402 100644 --- a/backend/src/app.js +++ b/backend/src/app.js @@ -1,3 +1,26 @@ +/** + * Aplicacion Express principal — configuracion de middlewares y montaje de rutas. + * + * Middlewares aplicados (en orden): + * 1. helmet() — headers de seguridad (X-Frame-Options, HSTS, etc.). + * 2. cors() — CORS con origen configurable (CORS_ORIGIN). + * 3. rateLimit() — 200 peticiones / 15 min por IP. + * 4. express.json() — parseo de JSON con limite de 1 MB. + * + * Rutas REST montadas bajo /api/v1: + * - /auth → login, perfil (auth.routes.js) + * - /markets → listado y detalle de mercados (markets.routes.js) + * - /markets → senales IA por mercado (signals.routes.js, subruta) + * - /positions → simulador de posiciones virtuales (positions.routes.js) + * - /watchlist → lista de seguimiento (watchlist.routes.js) + * - /alerts → historial de alertas (alerts.routes.js) + * - /health → healthcheck basico + * + * Manejo de errores: + * - notFound → 404 para rutas no definidas. + * - errorHandler → 500 generico en produccion, detalles en desarrollo. + */ + import express from 'express'; import cors from 'cors'; import helmet from 'helmet'; diff --git a/backend/src/auth/auth.controller.js b/backend/src/auth/auth.controller.js index 92d511f9c274558fd334a982bd9b6c7b1013783d..26ad7cdf2f3266c7b770fb1e8f079e604576a274 100644 --- a/backend/src/auth/auth.controller.js +++ b/backend/src/auth/auth.controller.js @@ -1,3 +1,16 @@ +/** + * Controladores del modulo de autenticacion. + * + * Responsabilidades: + * - login → recibir credenciales, delegar validacion a auth.service.js, + * responder con { token, user }. + * - me → devolver el usuario autenticado extraido del JWT (req.user). + * + * Errores: + * - 401 INVALID_CREDENTIALS → email o password incorrectos (mensaje generico). + * - 401 UNAUTHORIZED → token invalido o ausente (en requireAuth). + */ + import * as authService from './auth.service.js'; import { ok } from '../utils/apiResponse.js'; diff --git a/backend/src/auth/auth.routes.js b/backend/src/auth/auth.routes.js index 5e884fca70a7f143e3bd95cc98a373637f12dcdd..de9d1a1bc3cea89253a72f406dbc03b5e85b38a5 100644 --- a/backend/src/auth/auth.routes.js +++ b/backend/src/auth/auth.routes.js @@ -1,3 +1,19 @@ +/** + * Rutas REST de autenticacion. + * + * Endpoints: + * POST /api/v1/auth/login + * → rateLimitLogin (5 intentos / 15 min) + * → validate(loginSchema) + * → authController.login + * → Devuelve JWT + objeto usuario. + * + * GET /api/v1/auth/me + * → requireAuth + * → authController.me + * → Devuelve el usuario autenticado (req.user). + */ + import { Router } from 'express'; import * as ctrl from './auth.controller.js'; import { loginSchema } from './auth.validators.js'; diff --git a/backend/src/auth/auth.service.js b/backend/src/auth/auth.service.js index 97df6780c67b4f0b1906fe52aaa46a77c3f261cb..9f4c1b672b68476772f31efb3bab0f2564f211d6 100644 --- a/backend/src/auth/auth.service.js +++ b/backend/src/auth/auth.service.js @@ -1,3 +1,20 @@ +/** + * Logica de negocio del modulo de autenticacion. + * + * Responsabilidades: + * - login({ email, password }) → buscar usuario, comparar hash con bcrypt, + * verificar que este activo (isActive) y firmar JWT. + * + * Seguridad: + * - Mensaje generico en fallo ("Email or password is incorrect") + * para no revelar si el email existe. + * - Bcrypt con salt rounds configurable (BCRYPT_ROUNDS, default 10). + * - JWT firmado con HS256 y expiracion (JWT_EXPIRES_IN). + * + * Devuelve: + * { token: string, user: { id, email } } + */ + import bcrypt from 'bcryptjs'; import { prisma } from '../utils/prisma.js'; import { HttpError } from '../utils/apiResponse.js'; diff --git a/backend/src/auth/auth.validators.js b/backend/src/auth/auth.validators.js index e691e20a78918be131d2a76324284084288eee87..80850cdeffb11b81b64c68530e203c649dca1c99 100644 --- a/backend/src/auth/auth.validators.js +++ b/backend/src/auth/auth.validators.js @@ -1,3 +1,14 @@ +/** + * Esquemas Zod para validar inputs del modulo de autenticacion. + * + * Responsabilidades: + * - loginSchema: validar email (formato correcto, lowercase, trim) + * y password (minimo 8 caracteres). + * + * Consumido por: + * - auth.routes.js → validate(loginSchema) en POST /login. + */ + import { z } from 'zod'; export const loginSchema = z.object({ diff --git a/backend/src/auth/jwt.js b/backend/src/auth/jwt.js index c5ed76c0b96787d0ee88875c125d4b7376099813..91be686ba27eaaa873b452d121da020199073dee 100644 --- a/backend/src/auth/jwt.js +++ b/backend/src/auth/jwt.js @@ -1,3 +1,19 @@ +/** + * Helpers para firmar y verificar tokens JWT. + * + * Responsabilidades: + * - signToken(payload) → firma un token HS256 con expiracion configurable. + * - verifyToken(token) → verifica firma, expiracion y algoritmo (solo HS256). + * + * Consumido por: + * - auth.service.js → al hacer login exitoso. + * - requireAuth.js → en cada peticion protegida. + * + * Configuracion: + * - JWT_SECRET : minimo 32 chars (validado en config.js). + * - JWT_EXPIRES_IN: default '1h'. + */ + import jwt from 'jsonwebtoken'; import { config } from '../config.js'; diff --git a/backend/src/config.js b/backend/src/config.js index 76b609390044c75f012f336ee72747b60a51fb2a..e55e22e0a9a60c3ba55e8289f4d0c0b5205105c2 100644 --- a/backend/src/config.js +++ b/backend/src/config.js @@ -1,3 +1,22 @@ +/** + * Configuracion centralizada de variables de entorno. + * + * Carga los valores de process.env mediante dotenv, los valida con Zod + * y expone constantes tipadas como: PORT, DATABASE_URL, JWT_SECRET, + * HF_TOKEN, HF_SPACE_MODERNFINBERT_URL, HF_SPACE_QWEN_URL, etc. + * + * Variables clave: + * - PORT: 7860 (requerido por HuggingFace Spaces). + * - DATABASE_URL: SQLite local para desarrollo, PostgreSQL para produccion. + * - JWT_SECRET: minimo 32 caracteres, usado para firmar tokens de autenticacion. + * - HF_TOKEN / HF_SPACE_*: credenciales para los Spaces de HuggingFace (IA). + * - OPENROUTER_API_KEY: fallback LLM si los Spaces estan saturados. + * - FINNHUB_API_KEY: noticias financieras para el pipeline de senales. + * - TELEGRAM_BOT_TOKEN: bot de alertas (@BotFather). + * + * Si falla la validacion, el proceso termina con error antes de levantar el servidor. + */ + import 'dotenv/config'; import { z } from 'zod'; @@ -11,6 +30,8 @@ const schema = z.object({ CORS_ORIGIN: z.string().default('http://localhost:5173'), LOG_LEVEL: z.enum(['trace', 'debug', 'info', 'warn', 'error', 'fatal']).default('info'), HF_TOKEN: z.string().optional(), + HF_SPACE_MODERNFINBERT_URL: z.string().optional(), + HF_SPACE_QWEN_URL: z.string().optional(), OPENROUTER_API_KEY: z.string().optional(), FINNHUB_API_KEY: z.string().optional(), TELEGRAM_BOT_TOKEN: z.string().optional(), diff --git a/backend/src/index.js b/backend/src/index.js index a402ce14197e6a45bb3fb1d7ac44811bca52ca4d..c055637955cd15dd0277a4eb56669295424b010d 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,3 +1,20 @@ +/** + * Entry point de la aplicacion PolySignal. + * + * Inicializa el servidor HTTP nativo de Node.js, monta Express sobre el, + * configura Socket.io para comunicacion en tiempo real, arranca el scheduler + * de tareas periodicas (node-cron) y gestiona el cierre limpio ante SIGTERM/SIGINT. + * + * Flujo de arranque: + * 1. Crear servidor HTTP y adjuntar Express (app.js). + * 2. Inicializar Socket.io con CORS permitido desde CORS_ORIGIN. + * 3. Conectar el broadcaster (socket/broadcaster.js) para emitir eventos. + * 4. Escuchar en el puerto configurado (default 7860 para HF Spaces). + * 5. En modo no-test, iniciar scheduler (sync mercados, senales IA, PnL, alertas). + * + * Puerto por defecto: 7860 (requerido por HuggingFace Spaces). + */ + import http from 'node:http'; import { Server as IOServer } from 'socket.io'; import app from './app.js'; diff --git a/backend/src/markets/markets.controller.js b/backend/src/markets/markets.controller.js index 8996ad95da035910d8aa2c2ce13510c40300554e..b6dad714d2b738cff906295a9730d41b6d37b581 100644 --- a/backend/src/markets/markets.controller.js +++ b/backend/src/markets/markets.controller.js @@ -1,3 +1,18 @@ +/** + * Controladores del modulo de mercados. + * + * Responsabilidades: + * - list(req, res) → listado paginado y filtrado de mercados activos. + * - getById(req, res) → detalle de un mercado por su ID nativo de Polymarket. + * + * Datos expuestos: + * - id, question, category, countryCode, yesPrice, noPrice, + * volumeEur, liquidityEur, status, closesAt, lastSynced. + * + * Errores: + * - 404 NOT_FOUND si el mercado no existe. + */ + import { ok } from '../utils/apiResponse.js'; import { marketsService } from './markets.service.js'; diff --git a/backend/src/markets/markets.repository.js b/backend/src/markets/markets.repository.js index 9d32aa9047da3588b22e4702a973eef6e40f6514..c87809991f1dc0bf6159007d2f9b4e02a26574f9 100644 --- a/backend/src/markets/markets.repository.js +++ b/backend/src/markets/markets.repository.js @@ -1,3 +1,16 @@ +/** + * Repositorio de acceso a datos para el modelo Market. + * + * Responsabilidades: + * - findMany({ limit, offset, category, status }) → listado paginado y filtrado. + * - count({ category, status }) → conteo para paginacion. + * - findById(id) → busqueda por ID nativo. + * - upsert(market) → crea o actualiza un mercado. + * + * Todas las operaciones usan Prisma ORM (queries parametrizadas, sin SQL injection). + * El orden por defecto es descendente por volumen (volumeEur). + */ + import { prisma } from '../utils/prisma.js'; export const marketsRepository = { diff --git a/backend/src/markets/markets.routes.js b/backend/src/markets/markets.routes.js index 739e194bc46f53a3b0369dc724e32c2d045052c3..75e14e47c0d6bbaf4d0a5d9a6ae7fe3979d13cbb 100644 --- a/backend/src/markets/markets.routes.js +++ b/backend/src/markets/markets.routes.js @@ -1,3 +1,13 @@ +/** + * Rutas REST del modulo de mercados. + * + * Endpoints (montados en /api/v1/markets): + * GET / → listado paginado/filtrado (validate listQuery en query). + * GET /:id → detalle de mercado (validate idParam en params). + * + * No requieren autenticacion (datos publicos de Polymarket). + */ + import { Router } from 'express'; import { validate } from '../middlewares/validate.js'; import { marketsController } from './markets.controller.js'; diff --git a/backend/src/markets/markets.service.js b/backend/src/markets/markets.service.js index 5fd6ae480f4fee898f9a3d8b746b229ca3873992..938d609ceaba3d6d3e3b215999970e93beaccd73 100644 --- a/backend/src/markets/markets.service.js +++ b/backend/src/markets/markets.service.js @@ -1,3 +1,18 @@ +/** + * Logica de negocio del modulo de mercados. + * + * Responsabilidades: + * - list(query) → delega a marketsRepository.findMany + count para paginacion. + * - getById(id) → busca un mercado; si no existe lanza 404. + * + * Consumido por: + * - markets.controller.js (API REST). + * - scheduler.js (syncMarkets cada 30s). + * + * No contiene logica de scraping directa; delega a polymarket.client.js + * y persiste via marketsRepository. + */ + import { HttpError } from '../utils/apiResponse.js'; import { marketsRepository } from './markets.repository.js'; diff --git a/backend/src/markets/markets.validators.js b/backend/src/markets/markets.validators.js index 978e877a6b61fabf2c8027e58dd72f6516af9155..658f95e9f75ea7306620fba10759945c3135f0b9 100644 --- a/backend/src/markets/markets.validators.js +++ b/backend/src/markets/markets.validators.js @@ -1,3 +1,14 @@ +/** + * Esquemas Zod para validar inputs del modulo de mercados. + * + * Responsabilidades: + * - listQuery → limit (1-100, default 20), offset, category enum, status enum. + * - idParam → string no vacio para el parametro :id. + * + * Consumido por: + * - markets.routes.js → validate(listQuery, 'query') y validate(idParam, 'params'). + */ + import { z } from 'zod'; export const listQuery = z.object({ diff --git a/backend/src/markets/polymarket.client.js b/backend/src/markets/polymarket.client.js index 50db3ec421bdd5eccb9c921381e935e96de7a373..3494d3420c47a2cc4e214f0e789be74d7f60d0d3 100644 --- a/backend/src/markets/polymarket.client.js +++ b/backend/src/markets/polymarket.client.js @@ -1,3 +1,19 @@ +/** + * Cliente de integracion con Polymarket Gamma API. + * + * Responsabilidades: + * - fetchActiveMarkets(limit) → obtiene mercados activos desde gamma-api.polymarket.com. + * - mapMarket(raw) → normaliza campos crudos a la estructura del modelo Market: + * * id, question, category, countryCode + * * yesPrice / noPrice (parseados desde outcomePrices JSON) + * * volumeEur / liquidityEur (convertidos de USD a EUR con tasa 0.93) + * * status (active | closed | resolved) derivado de flags active/closed/archived + * * closesAt, lastSynced + * + * No requiere autenticacion. No usa CLOB API (solo datos publicos de mercado). + * Consumido por scheduler.js cada 30 segundos. + */ + import { httpGet } from '../utils/httpClient.js'; const GAMMA_URL = 'https://gamma-api.polymarket.com/markets'; diff --git a/backend/src/middlewares/errorHandler.js b/backend/src/middlewares/errorHandler.js index efb921bea83819e496cdefa2948a3483605289ed..23f74aded56d5ab7deac200f18b16581f67ffc2b 100644 --- a/backend/src/middlewares/errorHandler.js +++ b/backend/src/middlewares/errorHandler.js @@ -1,3 +1,15 @@ +/** + * Middleware centralizado de manejo de errores. + * + * Responsabilidades: + * - Capturar errores lanzados por controladores, servicios o middlewares. + * - Si es HttpError conocido: responder con el status y codigo definido. + * - Si es error inesperado: loguear el stack y responder 500 generico + * ("Internal server error") para no filtrar detalles internos en produccion. + * + * Montado al final de app.js como ultimo middleware. + */ + import { HttpError } from '../utils/apiResponse.js'; import { logger } from '../utils/logger.js'; diff --git a/backend/src/middlewares/notFound.js b/backend/src/middlewares/notFound.js index e7d6440069fc458d0cd9801d84041f00364122c1..175597d1fd01e8cc7dcda2a3b4f2f8077bff8408 100644 --- a/backend/src/middlewares/notFound.js +++ b/backend/src/middlewares/notFound.js @@ -1,3 +1,13 @@ +/** + * Middleware para rutas no definidas (404). + * + * Responsabilidades: + * - Responder con 404 y un JSON estandarizado cuando ninguna ruta coincide. + * - Incluye el metodo y path solicitado para facilitar debugging. + * + * Montado al final de app.js, justo antes del errorHandler. + */ + export const notFound = (req, res) => res.status(404).json({ ok: false, diff --git a/backend/src/middlewares/rateLimitLogin.js b/backend/src/middlewares/rateLimitLogin.js index f25ee11d133a5ccdd04543b59a69d810eca5bd21..30132b2a7b8dd942862fcee17391964363c94bbb 100644 --- a/backend/src/middlewares/rateLimitLogin.js +++ b/backend/src/middlewares/rateLimitLogin.js @@ -1,3 +1,15 @@ +/** + * Rate limiter especifico para el endpoint de login. + * + * Responsabilidades: + * - Limitar a 5 intentos de login cada 15 minutos por IP. + * - Mitigar ataques de fuerza bruta contra credenciales. + * - Responder 429 con codigo TOO_MANY_REQUESTS cuando se excede. + * + * Aplicado unicamente en POST /api/v1/auth/login. + * El rate limiter global (200 req / 15 min) tambien protege el resto de la API. + */ + import rateLimit from 'express-rate-limit'; export const rateLimitLogin = rateLimit({ diff --git a/backend/src/middlewares/requireAuth.js b/backend/src/middlewares/requireAuth.js index 3fa6ebcd98cf7b570bb0b756d77850e4167b74a1..28ed8f5b266623c5071c945b8e03719b3cc7965d 100644 --- a/backend/src/middlewares/requireAuth.js +++ b/backend/src/middlewares/requireAuth.js @@ -1,3 +1,19 @@ +/** + * Middleware de autenticacion JWT. + * + * Responsabilidades: + * - Extraer el header Authorization: Bearer . + * - Verificar la firma y expiracion del token con jwt.verify(). + * - Buscar el usuario en la base de datos y comprobar que esta activo (isActive). + * - Adjuntar req.user para que controladores y servicios posteriores lo usen. + * + * Rutas protegidas: + * - Todas bajo /positions, /watchlist, /alerts. + * - GET /auth/me. + * + * Si falta token, es invalido o el usuario no existe/inactivo → 401 UNAUTHORIZED. + */ + import { verifyToken } from '../auth/jwt.js'; import { prisma } from '../utils/prisma.js'; import { HttpError } from '../utils/apiResponse.js'; diff --git a/backend/src/middlewares/validate.js b/backend/src/middlewares/validate.js index 12c14060842576b4672d06586872a06079e6264b..1959f34039c19f63981edade1f60d3996393051f 100644 --- a/backend/src/middlewares/validate.js +++ b/backend/src/middlewares/validate.js @@ -1,3 +1,19 @@ +/** + * Middleware generico de validacion de inputs con Zod. + * + * Responsabilidades: + * - Ejecutar schema.safeParse() sobre el source indicado (body, query, params). + * - Si falla: propagar HttpError 400 con los errores de validacion detallados. + * - Si pasa: reemplazar req[source] por los datos parseados (coercion incluida). + * + * Uso tipico: + * router.post('/', validate(createBody), controller.create); + * router.get('/', validate(listQuery, 'query'), controller.list); + * router.get('/:id', validate(idParam, 'params'), controller.getById); + * + * Fuente por defecto: 'body'. Para query y params debe especificarse explicitamente. + */ + import { HttpError } from '../utils/apiResponse.js'; export const validate = (schema, source = 'body') => (req, _res, next) => { diff --git a/backend/src/positions/kelly.js b/backend/src/positions/kelly.js index 257be5ba8f65230935536c31dc9b516796c6de89..63f96269d24d299bf81779a2e1a76c100f7f54a5 100644 --- a/backend/src/positions/kelly.js +++ b/backend/src/positions/kelly.js @@ -1,7 +1,20 @@ /** - * Kelly criterion capped at 25%. - * k = (odds * pWin - pLose) / odds - * odds = (1 / price) - 1 + * Criterio de Kelly para sizing de posiciones, limitado al 25%. + * + * Formula: + * odds = (1 / price) - 1 + * k = (odds * pWin - pLose) / odds + * return min(max(k, 0), 0.25) + * + * Parametros: + * - price : precio actual del outcome (0 < price < 1). + * - pWin : probabilidad de ganar (usamos confidence de la senal IA). + * + * Devuelve: + * Fraccion del capital virtual recomendada (0.0 a 0.25). + * + * Consumido por: + * - positions.service.js → al abrir una posicion. */ export function kellyFraction(price, pWin) { if (!price || price <= 0 || price >= 1 || !pWin) return 0; diff --git a/backend/src/positions/positions.controller.js b/backend/src/positions/positions.controller.js index af3a9dfb720828bb855f7c3be45ea4f28d25ba41..bb54353f6716f15a472aacb77e2e5c7055219e9a 100644 --- a/backend/src/positions/positions.controller.js +++ b/backend/src/positions/positions.controller.js @@ -1,3 +1,17 @@ +/** + * Controladores del modulo de posiciones (simulador virtual). + * + * Responsabilidades: + * - open(req, res) → abre una posicion virtual en un mercado. + * - list(req, res) → lista las posiciones del usuario autenticado. + * - close(req, res) → cierra una posicion y calcula P&L final. + * + * Endpoints (bajo /api/v1/positions, protegidos por requireAuth): + * POST / → abrir posicion. + * GET / → listar posiciones (opcional ?status=open|closed). + * DELETE /:id → cerrar posicion. + */ + import { ok, created, noContent } from '../utils/apiResponse.js'; import { positionsService } from './positions.service.js'; diff --git a/backend/src/positions/positions.repository.js b/backend/src/positions/positions.repository.js index 6d4943eafdae41756f9dfc084c62297a9ab71703..43cdd37e14d0e2ba657ba39ea68fc782321a6f49 100644 --- a/backend/src/positions/positions.repository.js +++ b/backend/src/positions/positions.repository.js @@ -1,3 +1,16 @@ +/** + * Repositorio de acceso a datos para el modelo Position. + * + * Responsabilidades: + * - create(data) → inserta una nueva posicion virtual. + * - findByUser(userId, status) → lista posiciones del usuario con datos del mercado. + * - findByIdAndUser(id, userId) → busca posicion propia del usuario. + * - findAllOpen() → todas las posiciones abiertas (para recalcular P&L). + * - update(id, data) → actualiza precio, P&L, estado, etc. + * + * Todas las operaciones usan Prisma ORM. + */ + import { prisma } from '../utils/prisma.js'; export const positionsRepository = { diff --git a/backend/src/positions/positions.routes.js b/backend/src/positions/positions.routes.js index 67365a492002352d0c7ec614e8cd893b99e55ad3..a111f3e91ab00b58179fa899d4a667a9d6a26e3f 100644 --- a/backend/src/positions/positions.routes.js +++ b/backend/src/positions/positions.routes.js @@ -1,3 +1,14 @@ +/** + * Rutas REST del modulo de posiciones (simulador virtual). + * + * Endpoints (montados en /api/v1/positions): + * POST / → abrir posicion (validate openBody). + * GET / → listar posiciones (validate listQuery en query). + * DELETE /:id → cerrar posicion (validate idParam en params). + * + * Todas las rutas requieren autenticacion JWT (router.use(requireAuth)). + */ + import { Router } from 'express'; import { validate } from '../middlewares/validate.js'; import { requireAuth } from '../middlewares/requireAuth.js'; diff --git a/backend/src/positions/positions.service.js b/backend/src/positions/positions.service.js index 3e9ebb20c971f2f2a64deb28100a7ab43bacd90d..d932b68a342baf3a4c3724872558d16d1121898e 100644 --- a/backend/src/positions/positions.service.js +++ b/backend/src/positions/positions.service.js @@ -1,3 +1,23 @@ +/** + * Logica de negocio del modulo de posiciones (simulador virtual). + * + * Responsabilidades: + * - open(userId, { marketId, outcome, amountEur }) + * → valida que el mercado exista y este activo, obtiene precio de entrada, + * calcula fraccion de Kelly y crea la posicion. + * - list(userId, status) → devuelve posiciones del usuario. + * - close(id, userId) → calcula P&L final con el precio actual y marca como cerrada. + * - updateAllPnL() → recalcula P&L de todas las posiciones abiertas (scheduler). + * + * Calculos: + * - P&L = amountEur * (currentPrice / entryPrice - 1). + * - Kelly = (odds * pWin - pLose) / odds, capped al 25%. + * + * Consumido por: + * - positions.controller.js (API REST). + * - scheduler.js (updatePositionsPnL cada 30s). + */ + import { HttpError } from '../utils/apiResponse.js'; import { positionsRepository } from './positions.repository.js'; import { marketsRepository } from '../markets/markets.repository.js'; diff --git a/backend/src/positions/positions.validators.js b/backend/src/positions/positions.validators.js index b605023259c1ba77dc132b9af81fccc10c688de0..3d27386be70902c840fab0c68808f7947a74326d 100644 --- a/backend/src/positions/positions.validators.js +++ b/backend/src/positions/positions.validators.js @@ -1,3 +1,15 @@ +/** + * Esquemas Zod para validar inputs del modulo de posiciones. + * + * Responsabilidades: + * - openBody → marketId (string), outcome ('YES'|'NO'), amountEur (positivo, max 100k). + * - idParam → coerce a numero entero positivo. + * - listQuery → status opcional ('open'|'closed'). + * + * Consumido por: + * - positions.routes.js → validate() en POST, GET y DELETE. + */ + import { z } from 'zod'; export const openBody = z.object({ diff --git a/backend/src/scheduler.js b/backend/src/scheduler.js index 63a4497899bf9ae94db7743468e6262ed572a24f..9a4de45bd2dfaa6983f7b94d9e95c85c7a9a2dfe 100644 --- a/backend/src/scheduler.js +++ b/backend/src/scheduler.js @@ -1,3 +1,16 @@ +/** + * Scheduler de tareas periodicas usando node-cron. + * + * Define y ejecuta los 4 jobs principales del backend: + * 1. syncMarkets — cada 30s, sincroniza precios desde Polymarket Gamma API. + * 2. generateSignals — cada 5 min, genera senales IA para el top 20 mercados activos. + * 3. updatePositionsPnL — cada 30s, recalcula P&L de posiciones abiertas. + * 4. processAlerts — cada 60s, revisa watchlist y envia alertas por Telegram. + * + * Cada job captura sus propios errores para evitar que un fallo afecte a los demas. + * Se ejecuta inmediatamente al arrancar (llamada manual) y luego segun cron. + */ + import { schedule } from 'node-cron'; import { fetchActiveMarkets } from './markets/polymarket.client.js'; import { marketsRepository } from './markets/markets.repository.js'; diff --git a/backend/src/signals/aiPipeline.js b/backend/src/signals/aiPipeline.js index af013bd2ba1342e5af06b66f056afd563081a707..f883065ea69e5a1fbf4ae669601d31642f18e4be 100644 --- a/backend/src/signals/aiPipeline.js +++ b/backend/src/signals/aiPipeline.js @@ -1,3 +1,23 @@ +/** + * Pipeline de inteligencia artificial para generacion de senales de trading. + * + * Flujo de tres fases con fallback: + * 1. Filtrado de noticias (Finnhub + ModernFinBERT Space o API directa HF). + * → descarta noticias neutrales o con score < 0.65. + * 2. Generacion de senal (Qwen3-8B Space o API directa HF). + * → analiza mercado + noticias filtradas y genera: + * { signal: 'bullish'|'bearish'|'neutral', confidence, summary, keyRisk }. + * 3. Fallbacks: + * - Si falla el Space de Qwen → intenta API directa de HuggingFace. + * - Si falla HF directa → intenta OpenRouter (deepseek-chat). + * - Si todo falla → regla basada en precio (rule-based). + * + * Consumido por: + * - signals.service.js → generateForMarket(market). + * - scheduler.js → cada 5 minutos para los 20 mercados activos. + */ + +import { Client } from '@gradio/client'; import { httpPost } from '../utils/httpClient.js'; import { config } from '../config.js'; import { logger } from '../utils/logger.js'; @@ -9,6 +29,10 @@ const QWEN_MODEL = 'Qwen/Qwen3-8B'; const OPENROUTER_API = 'https://openrouter.ai/api/v1/chat/completions'; const OPENROUTER_MODEL = 'deepseek/deepseek-chat-v3-0324:free'; +// Cached Gradio clients for Spaces +let modernFinBERTClient = null; +let qwenClient = null; + // ── helpers ────────────────────────────────────────────────────────────────── function hfHeaders() { @@ -43,9 +67,42 @@ function buildPrompt(market, headlines) { ].join('\n'); } -// ── FinBERT filtering ───────────────────────────────────────────────────────── +// ── Gradio Spaces clients ──────────────────────────────────────────────────── -async function filterWithFinBERT(articles) { +async function getModernFinBERTClient() { + if (!modernFinBERTClient && config.HF_SPACE_MODERNFINBERT_URL) { + modernFinBERTClient = await Client.connect(config.HF_SPACE_MODERNFINBERT_URL); + } + return modernFinBERTClient; +} + +async function getQwenClient() { + if (!qwenClient && config.HF_SPACE_QWEN_URL) { + qwenClient = await Client.connect(config.HF_SPACE_QWEN_URL); + } + return qwenClient; +} + +// ── FinBERT filtering via Space or direct API ───────────────────────────────── + +async function filterWithFinBERTSpace(articles) { + if (!articles.length) return articles; + const client = await getModernFinBERTClient(); + if (!client) return articles; + + const textBlock = articles.map((a) => a.headline).join('\n'); + const result = await client.predict('/predict', { text_block: textBlock }); + // Gradio returns: { data: [ [ {label, score}, ... ] ], ... } + const sentiments = result.data[0]; + return articles.filter((_, i) => { + const r = sentiments[i]; + if (!r) return false; + const label = String(r.label).toLowerCase(); + return label !== 'neutral' && (typeof r.score === 'number' ? r.score : parseFloat(r.score)) >= 0.65; + }); +} + +async function filterWithFinBERTDirect(articles) { if (!articles.length) return articles; const inputs = articles.map((a) => a.headline); const results = await httpPost( @@ -60,7 +117,44 @@ async function filterWithFinBERT(articles) { }); } -// ── LLM generation ──────────────────────────────────────────────────────────── +async function filterWithFinBERT(articles) { + // Prefer Space if configured, fallback to direct API + if (config.HF_SPACE_MODERNFINBERT_URL) { + try { + return await filterWithFinBERTSpace(articles); + } catch (err) { + logger.warn({ err: err.message }, 'ModernFinBERT Space failed, falling back to direct API'); + } + } + if (config.HF_TOKEN) { + return await filterWithFinBERTDirect(articles); + } + return articles; +} + +// ── LLM generation via Space or direct API ─────────────────────────────────── + +async function generateWithQwenSpace(market, headlines) { + const client = await getQwenClient(); + if (!client) return null; + + const newsSummary = headlines.length + ? headlines.map((h) => `- ${h.headline}`).join('\n') + : 'No relevant news available.'; + + const marketContext = [ + `Market: "${market.question}"`, + `YES price: ${market.yesPrice ?? 'N/A'} | NO price: ${market.noPrice ?? 'N/A'}`, + ].join('\n'); + + const result = await client.predict('/predict', { + market_context: marketContext, + news_summary: newsSummary, + }); + + // result.data[0] → { signal, confidence, summary, keyRisk } + return result.data[0]; +} async function callChatCompletion(url, model, messages, authHeader) { const data = await httpPost( @@ -71,7 +165,7 @@ async function callChatCompletion(url, model, messages, authHeader) { return data?.choices?.[0]?.message?.content ?? null; } -async function generateWithQwen3(market, headlines) { +async function generateWithQwen3Direct(market, headlines) { const content = await callChatCompletion( `${HF_API}/${QWEN_MODEL}/v1/chat/completions`, QWEN_MODEL, @@ -119,7 +213,7 @@ function ruleBasedSignal(market) { function validateSignal(result) { if (!result) return false; - const validSignals = ['bullish', 'bearish', 'neutral']; + const validSignals = ['bullish', 'bearish', 'neutral', 'buy', 'sell', 'hold']; return ( validSignals.includes(result.signal) && typeof result.confidence === 'number' && @@ -130,6 +224,16 @@ function validateSignal(result) { ); } +function normalizeSignal(result) { + if (!result) return result; + // Normalize buy/sell/hold to bullish/bearish/neutral for downstream compatibility + const signalMap = { buy: 'bullish', sell: 'bearish', hold: 'neutral' }; + if (result.signal in signalMap) { + result.signal = signalMap[result.signal]; + } + return result; +} + // ── public API ──────────────────────────────────────────────────────────────── export async function run(market) { @@ -138,10 +242,10 @@ export async function run(market) { try { const allNews = await fetchFinancialNews(30); const relevant = filterNewsByRelevance(allNews, market.question); - if (config.HF_TOKEN && relevant.length) { + if (relevant.length) { headlines = await filterWithFinBERT(relevant); } else { - headlines = relevant.slice(0, 10); + headlines = []; } } catch (err) { logger.warn({ err: err.message, marketId: market.id }, 'news fetch failed, continuing without news'); @@ -150,15 +254,28 @@ export async function run(market) { // Step 2: LLM signal generation with fallback chain let result = null; - if (config.HF_TOKEN) { + // Try Space first + if (config.HF_SPACE_QWEN_URL) { + try { + result = await generateWithQwenSpace(market, headlines); + result = normalizeSignal(result); + if (!validateSignal(result)) result = null; + } catch (err) { + logger.warn({ err: err.message, marketId: market.id }, 'Qwen Space failed, trying direct API'); + } + } + + // Fallback to direct HF API + if (!result && config.HF_TOKEN) { try { - result = await generateWithQwen3(market, headlines); + result = await generateWithQwen3Direct(market, headlines); if (!validateSignal(result)) result = null; } catch (err) { - logger.warn({ err: err.message, marketId: market.id }, 'Qwen3 failed, trying OpenRouter'); + logger.warn({ err: err.message, marketId: market.id }, 'Qwen3 direct API failed, trying OpenRouter'); } } + // Fallback to OpenRouter if (!result && config.OPENROUTER_API_KEY) { try { result = await generateWithOpenRouter(market, headlines); @@ -168,6 +285,7 @@ export async function run(market) { } } + // Final fallback if (!result) { result = ruleBasedSignal(market); } diff --git a/backend/src/signals/finnhub.client.js b/backend/src/signals/finnhub.client.js index 2e8200b889d326ee4aa8b63224553dd07725db0a..3aad51268a26183298d7cc79c2a3e939af17c3b4 100644 --- a/backend/src/signals/finnhub.client.js +++ b/backend/src/signals/finnhub.client.js @@ -1,3 +1,19 @@ +/** + * Servicio de integracion con Finnhub REST API. + * + * Responsabilidades: + * - fetchFinancialNews(count) → obtiene titulares de noticias financieras. + * - filterNewsByRelevance(articles, question) → filtra por keywords del mercado. + * + * Restricciones: + * - Free tier: maximo 60 llamadas/minuto. + * - Solo se invoca durante la generacion de senales (cada 5 min). + * - Si FINNHUB_API_KEY no esta configurado, devuelve array vacio. + * + * Consumido por: + * - aiPipeline.js → fase 1 de filtrado de noticias. + */ + import { httpGet } from '../utils/httpClient.js'; import { config } from '../config.js'; diff --git a/backend/src/signals/signals.controller.js b/backend/src/signals/signals.controller.js index 219f827a0338e86c9973f779ed8fd32e0f0904b9..1d32ba0120174d8e58dcdf48adbe10b58c209237 100644 --- a/backend/src/signals/signals.controller.js +++ b/backend/src/signals/signals.controller.js @@ -1,3 +1,17 @@ +/** + * Controladores del modulo de senales IA. + * + * Responsabilidades: + * - getLatest(req, res) → devuelve la senal mas reciente de un mercado. + * + * Endpoint: + * GET /api/v1/markets/:marketId/signal + * + * Errores: + * - 404 NOT_FOUND si el mercado no existe. + * - 404 NOT_FOUND si aun no hay senal generada para ese mercado. + */ + import { ok } from '../utils/apiResponse.js'; import { signalsService } from './signals.service.js'; diff --git a/backend/src/signals/signals.repository.js b/backend/src/signals/signals.repository.js index 25f36e32249c53e93c9da2dfe37a92a5559c9cfd..a04e1f5905bb4bd4e4f74a158d2a8d5380e30176 100644 --- a/backend/src/signals/signals.repository.js +++ b/backend/src/signals/signals.repository.js @@ -1,3 +1,16 @@ +/** + * Repositorio de acceso a datos para el modelo AISignal. + * + * Responsabilidades: + * - create(data) → inserta una nueva senal generada por IA. + * - findLatestByMarket(id) → devuelve la senal mas reciente de un mercado. + * + * Campos persistidos: + * signal, confidence, summary, keyRisk, newsCount, modelVersion, generatedAt. + * + * Todas las operaciones usan Prisma ORM. + */ + import { prisma } from '../utils/prisma.js'; export const signalsRepository = { diff --git a/backend/src/signals/signals.routes.js b/backend/src/signals/signals.routes.js index 3e0557e8d8016026e852f498536c51b06a95e425..b7dd690beb74de2e154e6b2887aae3f2249d023e 100644 --- a/backend/src/signals/signals.routes.js +++ b/backend/src/signals/signals.routes.js @@ -1,3 +1,12 @@ +/** + * Rutas REST del modulo de senales IA. + * + * Endpoint (montado en /api/v1/markets): + * GET /:marketId/signal → senal mas reciente del mercado. + * + * No requiere autenticacion (datos publicos). + */ + import { Router } from 'express'; import { signalsController } from './signals.controller.js'; diff --git a/backend/src/signals/signals.service.js b/backend/src/signals/signals.service.js index 54002a8d8ca271ed5a0518adc4878048c47cb4fa..e8b59b3df280067f5c9133393b84bf9eee584c70 100644 --- a/backend/src/signals/signals.service.js +++ b/backend/src/signals/signals.service.js @@ -1,3 +1,21 @@ +/** + * Logica de negocio del modulo de senales IA. + * + * Responsabilidades: + * - getLatest(marketId) → devuelve la ultima senal persistida de un mercado. + * - generateForMarket(market) → ejecuta el pipeline de IA (aiPipeline.js) y persiste + * el resultado en AISignal. Emite evento 'ai_signal' por Socket.io. + * + * Flujo de generacion: + * 1. aiPipeline.run(market) → obtiene { signal, confidence, summary, keyRisk, newsCount }. + * 2. signalsRepository.create(...) → persiste en SQLite. + * 3. emitAiSignal(...) → notifica a clientes conectados en tiempo real. + * + * Consumido por: + * - scheduler.js cada 5 minutos para los 20 mercados mas activos. + * - signals.controller.js para el endpoint GET /markets/:id/signal. + */ + import { HttpError } from '../utils/apiResponse.js'; import { signalsRepository } from './signals.repository.js'; import { marketsRepository } from '../markets/markets.repository.js'; diff --git a/backend/src/socket/broadcaster.js b/backend/src/socket/broadcaster.js index d4e293f9d5208d5f3793dbba3325b07db136d60e..240b4dc04162d98e077dbf028e8391863a7bc27c 100644 --- a/backend/src/socket/broadcaster.js +++ b/backend/src/socket/broadcaster.js @@ -1,3 +1,18 @@ +/** + * Broadcaster de eventos en tiempo real via Socket.io. + * + * Actua como un wrapper singleton sobre la instancia de Socket.io. + * Responsabilidades: + * - Recibir la instancia de io en el arranque (attachBroadcaster). + * - Emitir eventos tipados a todos los clientes conectados: + * * market_update → cambio de precio/volumen de un mercado. + * * ai_signal → nueva senal generada por el pipeline de IA. + * * price_alert → alerta de umbral de precio o cambio de senal. + * + * Los controladores y servicios importan estas funciones para notificar + * sin acoplarse directamente a Socket.io. + */ + let _io = null; export function attachBroadcaster(io) { diff --git a/backend/src/utils/apiResponse.js b/backend/src/utils/apiResponse.js index 6397dc5ffa7702639128fe7871927c6cce40b589..5cb8552a3df5cd70c01699d90f081e11b0903257 100644 --- a/backend/src/utils/apiResponse.js +++ b/backend/src/utils/apiResponse.js @@ -1,3 +1,17 @@ +/** + * Helpers para respuestas HTTP estandarizadas y manejo de errores. + * + * Funciones de respuesta exitosa: + * - ok(res, data, meta) → 200 con { ok: true, data } y meta opcional. + * - created(res, data) → 201 con { ok: true, data }. + * - noContent(res) → 204 sin body. + * + * Clase HttpError: + * - Extiende Error nativo. + * - Campos: status (HTTP), code (string identificador), message, details (opcional). + * - Usada por middlewares y servicios para propagar errores controlados. + */ + export const ok = (res, data, meta) => res.status(200).json(meta ? { ok: true, data, meta } : { ok: true, data }); diff --git a/backend/src/utils/httpClient.js b/backend/src/utils/httpClient.js index 716fa8899ead3c5f0d5eaff23d9ea680666befe7..4693251f95f91053388bf5192e7f28f8770c5851 100644 --- a/backend/src/utils/httpClient.js +++ b/backend/src/utils/httpClient.js @@ -1,3 +1,18 @@ +/** + * Cliente HTTP reutilizable con retry y timeout. + * + * Responsabilidades: + * - Realizar peticiones GET y POST usando fetch nativo de Node.js. + * - Aplicar timeout via AbortController. + * - Reintentar automaticamente ante errores de red o HTTP 429/5xx. + * - Backoff exponencial con tope de 30s. + * - Inyectar User-Agent: PolySignal/1.0 en todas las peticiones. + * + * Uso: + * const data = await httpGet(url, { headers, timeout, retries }); + * const data = await httpPost(url, body, { headers, timeout, retries }); + */ + import { logger } from './logger.js'; const DEFAULT_TIMEOUT_MS = 10_000; diff --git a/backend/src/utils/logger.js b/backend/src/utils/logger.js index 3100e5bcc2b3e0292a3f4f1c7d86af9697748e4b..60cdcadfe050502f2dc6fcb11abfab73bd7800de 100644 --- a/backend/src/utils/logger.js +++ b/backend/src/utils/logger.js @@ -1,3 +1,14 @@ +/** + * Logger estructurado basado en Pino. + * + * Responsabilidades: + * - Loguear eventos del servidor en formato JSON (facil de parsear). + * - Nivel configurable via LOG_LEVEL (trace, debug, info, warn, error, fatal). + * - Usado por todos los modulos para trazabilidad sin bloquear el event loop. + * + * En produccion se puede redirigir stdout a un agregador de logs (Datadog, etc.). + */ + import pino from 'pino'; export const logger = pino({ diff --git a/backend/src/utils/prisma.js b/backend/src/utils/prisma.js index 329ffb817c5c2b5bed2713a79a43bc71de7c8a00..061dddc1dba42bbe2cc1ec03a05ad3a441966c1a 100644 --- a/backend/src/utils/prisma.js +++ b/backend/src/utils/prisma.js @@ -1,3 +1,16 @@ +/** + * Instancia singleton de PrismaClient. + * + * Responsabilidades: + * - Gestionar la conexion a SQLite (desarrollo) o PostgreSQL (produccion). + * - Reutilizar la misma instancia en hot-reload (guardada en globalThis). + * - Loguear solo warns y errores para no saturar la salida. + * + * Relaciones: + * - Todos los repositories importan este prisma para ejecutar queries. + * - schema.prisma define los modelos: User, Market, AISignal, Position, Watchlist, Alert. + */ + import { PrismaClient } from '@prisma/client'; const globalForPrisma = globalThis; diff --git a/backend/src/watchlist/watchlist.controller.js b/backend/src/watchlist/watchlist.controller.js index 78908a6a6e6814a7c669c19090ce5690b9820670..929819e997eed652edc2d5bb94b6bac14b98d714 100644 --- a/backend/src/watchlist/watchlist.controller.js +++ b/backend/src/watchlist/watchlist.controller.js @@ -1,3 +1,17 @@ +/** + * Controladores del modulo de lista de seguimiento (watchlist). + * + * Responsabilidades: + * - add(req, res) → anade un mercado a la watchlist con umbral de alerta opcional. + * - remove(req, res) → elimina un mercado de la watchlist. + * - list(req, res) → devuelve la watchlist del usuario autenticado. + * + * Endpoints (bajo /api/v1/watchlist, protegidos por requireAuth): + * POST / → anadir mercado. + * GET / → listar watchlist. + * DELETE /:marketId → eliminar mercado. + */ + import { ok, created, noContent } from '../utils/apiResponse.js'; import { watchlistService } from './watchlist.service.js'; diff --git a/backend/src/watchlist/watchlist.repository.js b/backend/src/watchlist/watchlist.repository.js index fc8693da407bb3d1c64ae76891e2b8cf58e6b84b..0082f718497c73958344716671459f7f30a841ad 100644 --- a/backend/src/watchlist/watchlist.repository.js +++ b/backend/src/watchlist/watchlist.repository.js @@ -1,3 +1,18 @@ +/** + * Repositorio de acceso a datos para el modelo Watchlist. + * + * Responsabilidades: + * - create(data) → inserta entrada en watchlist. + * - findByUser(userId) → lista con datos del mercado asociado. + * - deleteByUserAndMarket(...) → elimina entrada especifica. + * - findAllWithThreshold() → entradas con alertThreshold definido (para alertas). + * + * Constraint: + * - @@unique([userId, marketId]) → un usuario no puede duplicar un mercado. + * + * Todas las operaciones usan Prisma ORM. + */ + import { prisma } from '../utils/prisma.js'; export const watchlistRepository = { diff --git a/backend/src/watchlist/watchlist.routes.js b/backend/src/watchlist/watchlist.routes.js index 1cf62cde9f2f1a193eded90ffed332ef443740e8..2564624196f7a7c5644c0ab6be709c81e39587e4 100644 --- a/backend/src/watchlist/watchlist.routes.js +++ b/backend/src/watchlist/watchlist.routes.js @@ -1,3 +1,14 @@ +/** + * Rutas REST del modulo de lista de seguimiento (watchlist). + * + * Endpoints (montados en /api/v1/watchlist): + * POST / → anadir mercado (validate addBody). + * GET / → listar watchlist. + * DELETE /:marketId → eliminar mercado (validate marketIdParam en params). + * + * Todas las rutas requieren autenticacion JWT (router.use(requireAuth)). + */ + import { Router } from 'express'; import { validate } from '../middlewares/validate.js'; import { requireAuth } from '../middlewares/requireAuth.js'; diff --git a/backend/src/watchlist/watchlist.service.js b/backend/src/watchlist/watchlist.service.js index f444fe8feb26bb29c5a6d940dcf0bcc3c127d60e..d16b90a0a5ae1197d9089c19d8da082377c836b8 100644 --- a/backend/src/watchlist/watchlist.service.js +++ b/backend/src/watchlist/watchlist.service.js @@ -1,3 +1,18 @@ +/** + * Logica de negocio del modulo de lista de seguimiento (watchlist). + * + * Responsabilidades: + * - add(userId, { marketId, alertThreshold }) + * → valida que el mercado exista, crea entrada en watchlist. + * → si ya existe (P2002), devuelve 409 ALREADY_IN_WATCHLIST. + * - remove(userId, marketId) → elimina entrada; si no existe devuelve 404. + * - list(userId) → devuelve todas las entradas del usuario. + * + * Consumido por: + * - watchlist.controller.js (API REST). + * - alerts.service.js → processAll() revisa watchlist con alertThreshold. + */ + import { HttpError } from '../utils/apiResponse.js'; import { watchlistRepository } from './watchlist.repository.js'; import { marketsRepository } from '../markets/markets.repository.js'; diff --git a/backend/src/watchlist/watchlist.validators.js b/backend/src/watchlist/watchlist.validators.js index 6ded6df30c7daac565b5b4c38c9b1cede1410a0a..25d0aa0620a7545daed72d37967cfc7f21ef3c5b 100644 --- a/backend/src/watchlist/watchlist.validators.js +++ b/backend/src/watchlist/watchlist.validators.js @@ -1,3 +1,14 @@ +/** + * Esquemas Zod para validar inputs del modulo de watchlist. + * + * Responsabilidades: + * - addBody → marketId (string), alertThreshold opcional (0.0 a 1.0). + * - marketIdParam → string no vacio para el parametro :marketId. + * + * Consumido por: + * - watchlist.routes.js → validate() en POST y DELETE. + */ + import { z } from 'zod'; export const addBody = z.object({ diff --git a/frontend/dist/assets/index-B0wDNpCs.js b/frontend/dist/assets/index-B0wDNpCs.js deleted file mode 100644 index 614e8d07a1ba181a9a6c1db358d04c30e39711ea..0000000000000000000000000000000000000000 --- a/frontend/dist/assets/index-B0wDNpCs.js +++ /dev/null @@ -1,3 +0,0 @@ -(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))s(o);new MutationObserver(o=>{for(const a of o)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&s(l)}).observe(document,{childList:!0,subtree:!0});function e(o){const a={};return o.integrity&&(a.integrity=o.integrity),o.referrerPolicy&&(a.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?a.credentials="include":o.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function s(o){if(o.ep)return;o.ep=!0;const a=e(o);fetch(o.href,a)}})();const se=Object.create(null);se.open="0";se.close="1";se.ping="2";se.pong="3";se.message="4";se.upgrade="5";se.noop="6";const Rn=Object.create(null);Object.keys(se).forEach(i=>{Rn[se[i]]=i});const ro={type:"error",data:"parser error"},Nl=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Fl=typeof ArrayBuffer=="function",Wl=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i&&i.buffer instanceof ArrayBuffer,So=({type:i,data:t},e,s)=>Nl&&t instanceof Blob?e?s(t):ra(t,s):Fl&&(t instanceof ArrayBuffer||Wl(t))?e?s(t):ra(new Blob([t]),s):s(se[i]+(t||"")),ra=(i,t)=>{const e=new FileReader;return e.onload=function(){const s=e.result.split(",")[1];t("b"+(s||""))},e.readAsDataURL(i)};function aa(i){return i instanceof Uint8Array?i:i instanceof ArrayBuffer?new Uint8Array(i):new Uint8Array(i.buffer,i.byteOffset,i.byteLength)}let Zs;function Cu(i,t){if(Nl&&i.data instanceof Blob)return i.data.arrayBuffer().then(aa).then(t);if(Fl&&(i.data instanceof ArrayBuffer||Wl(i.data)))return t(aa(i.data));So(i,!1,e=>{Zs||(Zs=new TextEncoder),t(Zs.encode(e))})}const la="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ri=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let i=0;i{let t=i.length*.75,e=i.length,s,o=0,a,l,h,u;i[i.length-1]==="="&&(t--,i[i.length-2]==="="&&t--);const d=new ArrayBuffer(t),p=new Uint8Array(d);for(s=0;s>4,p[o++]=(l&15)<<4|h>>2,p[o++]=(h&3)<<6|u&63;return d},Eu=typeof ArrayBuffer=="function",Mo=(i,t)=>{if(typeof i!="string")return{type:"message",data:Hl(i,t)};const e=i.charAt(0);return e==="b"?{type:"message",data:Au(i.substring(1),t)}:Rn[e]?i.length>1?{type:Rn[e],data:i.substring(1)}:{type:Rn[e]}:ro},Au=(i,t)=>{if(Eu){const e=Tu(i);return Hl(e,t)}else return{base64:!0,data:i}},Hl=(i,t)=>t==="blob"?i instanceof Blob?i:new Blob([i]):i instanceof ArrayBuffer?i:i.buffer,Zl="",Ou=(i,t)=>{const e=i.length,s=new Array(e);let o=0;i.forEach((a,l)=>{So(a,!1,h=>{s[l]=h,++o===e&&t(s.join(Zl))})})},Du=(i,t)=>{const e=i.split(Zl),s=[];for(let o=0;o{const s=e.length;let o;if(s<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,s);else if(s<65536){o=new Uint8Array(3);const a=new DataView(o.buffer);a.setUint8(0,126),a.setUint16(1,s)}else{o=new Uint8Array(9);const a=new DataView(o.buffer);a.setUint8(0,127),a.setBigUint64(1,BigInt(s))}i.data&&typeof i.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(e)})}})}let Vs;function bn(i){return i.reduce((t,e)=>t+e.length,0)}function xn(i,t){if(i[0].length===t)return i.shift();const e=new Uint8Array(t);let s=0;for(let o=0;oMath.pow(2,21)-1){h.enqueue(ro);break}o=p*Math.pow(2,32)+d.getUint32(4),s=3}else{if(bn(e)i){h.enqueue(ro);break}}}})}const Vl=4;function Lt(i){if(i)return Bu(i)}function Bu(i){for(var t in Lt.prototype)i[t]=Lt.prototype[t];return i}Lt.prototype.on=Lt.prototype.addEventListener=function(i,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+i]=this._callbacks["$"+i]||[]).push(t),this};Lt.prototype.once=function(i,t){function e(){this.off(i,e),t.apply(this,arguments)}return e.fn=t,this.on(i,e),this};Lt.prototype.off=Lt.prototype.removeListener=Lt.prototype.removeAllListeners=Lt.prototype.removeEventListener=function(i,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var e=this._callbacks["$"+i];if(!e)return this;if(arguments.length==1)return delete this._callbacks["$"+i],this;for(var s,o=0;oPromise.resolve().then(t):(t,e)=>e(t,0),qt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),zu="arraybuffer";function jl(i,...t){return t.reduce((e,s)=>(i.hasOwnProperty(s)&&(e[s]=i[s]),e),{})}const Nu=qt.setTimeout,Fu=qt.clearTimeout;function Qn(i,t){t.useNativeTimers?(i.setTimeoutFn=Nu.bind(qt),i.clearTimeoutFn=Fu.bind(qt)):(i.setTimeoutFn=qt.setTimeout.bind(qt),i.clearTimeoutFn=qt.clearTimeout.bind(qt))}const Wu=1.33;function Hu(i){return typeof i=="string"?Zu(i):Math.ceil((i.byteLength||i.size)*Wu)}function Zu(i){let t=0,e=0;for(let s=0,o=i.length;s=57344?e+=3:(s++,e+=4);return e}function ql(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Vu(i){let t="";for(let e in i)i.hasOwnProperty(e)&&(t.length&&(t+="&"),t+=encodeURIComponent(e)+"="+encodeURIComponent(i[e]));return t}function ju(i){let t={},e=i.split("&");for(let s=0,o=e.length;s{this.readyState="paused",t()};if(this._polling||!this.writable){let s=0;this._polling&&(s++,this.once("pollComplete",function(){--s||e()})),this.writable||(s++,this.once("drain",function(){--s||e()}))}else e()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const e=s=>{if(this.readyState==="opening"&&s.type==="open"&&this.onOpen(),s.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(s)};Du(t,this.socket.binaryType).forEach(e),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,Ou(t,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",e=this.query||{};return this.opts.timestampRequests!==!1&&(e[this.opts.timestampParam]=ql()),!this.supportsBinary&&!e.sid&&(e.b64=1),this.createUri(t,e)}}let $l=!1;try{$l=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const Uu=$l;function Yu(){}class Xu extends $u{constructor(t){if(super(t),typeof location<"u"){const e=location.protocol==="https:";let s=location.port;s||(s=e?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||s!==t.port}}doWrite(t,e){const s=this.request({method:"POST",data:t});s.on("success",e),s.on("error",(o,a)=>{this.onError("xhr post error",o,a)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(e,s)=>{this.onError("xhr poll error",e,s)}),this.pollXhr=t}}class ie extends Lt{constructor(t,e,s){super(),this.createRequest=t,Qn(this,s),this._opts=s,this._method=s.method||"GET",this._uri=e,this._data=s.data!==void 0?s.data:null,this._create()}_create(){var t;const e=jl(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this._opts.xd;const s=this._xhr=this.createRequest(e);try{s.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){s.setDisableHeaderCheck&&s.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&s.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{s.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{s.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(s),"withCredentials"in s&&(s.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(s.timeout=this._opts.requestTimeout),s.onreadystatechange=()=>{var o;s.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(s.getResponseHeader("set-cookie"))),s.readyState===4&&(s.status===200||s.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof s.status=="number"?s.status:0)},0))},s.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=ie.requestsCount++,ie.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Yu,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete ie.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}ie.requestsCount=0;ie.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ha);else if(typeof addEventListener=="function"){const i="onpagehide"in qt?"pagehide":"unload";addEventListener(i,ha,!1)}}function ha(){for(let i in ie.requests)ie.requests.hasOwnProperty(i)&&ie.requests[i].abort()}const Ku=(function(){const i=Ul({xdomain:!1});return i&&i.responseType!==null})();class Gu extends Xu{constructor(t){super(t);const e=t&&t.forceBase64;this.supportsBinary=Ku&&!e}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new ie(Ul,this.uri(),t)}}function Ul(i){const t=i.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||Uu))return new XMLHttpRequest}catch{}if(!t)try{return new qt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const Yl=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class Ju extends Lo{get name(){return"websocket"}doOpen(){const t=this.uri(),e=this.opts.protocols,s=Yl?{}:jl(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(s.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,e,s)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let e=0;e{try{this.doWrite(s,a)}catch{}o&&Jn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",e=this.query||{};return this.opts.timestampRequests&&(e[this.opts.timestampParam]=ql()),this.supportsBinary||(e.b64=1),this.createUri(t,e)}}const js=qt.WebSocket||qt.MozWebSocket;class Qu extends Ju{createSocket(t,e,s){return Yl?new js(t,e,s):e?new js(t,e):new js(t)}doWrite(t,e){this.ws.send(e)}}class td extends Lo{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const e=Ru(Number.MAX_SAFE_INTEGER,this.socket.binaryType),s=t.readable.pipeThrough(e).getReader(),o=Iu();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const a=()=>{s.read().then(({done:h,value:u})=>{h||(this.onPacket(u),a())}).catch(h=>{})};a();const l={type:"open"};this.query.sid&&(l.data=`{"sid":"${this.query.sid}"}`),this._writer.write(l).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let e=0;e{o&&Jn(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const ed={websocket:Qu,webtransport:td,polling:Gu},id=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,nd=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function ao(i){if(i.length>8e3)throw"URI too long";const t=i,e=i.indexOf("["),s=i.indexOf("]");e!=-1&&s!=-1&&(i=i.substring(0,e)+i.substring(e,s).replace(/:/g,";")+i.substring(s,i.length));let o=id.exec(i||""),a={},l=14;for(;l--;)a[nd[l]]=o[l]||"";return e!=-1&&s!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a.pathNames=sd(a,a.path),a.queryKey=od(a,a.query),a}function sd(i,t){const e=/\/{2,9}/g,s=t.replace(e,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&s.splice(0,1),t.slice(-1)=="/"&&s.splice(s.length-1,1),s}function od(i,t){const e={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(s,o,a){o&&(e[o]=a)}),e}const lo=typeof addEventListener=="function"&&typeof removeEventListener=="function",Bn=[];lo&&addEventListener("offline",()=>{Bn.forEach(i=>i())},!1);class Se extends Lt{constructor(t,e){if(super(),this.binaryType=zu,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(e=t,t=null),t){const s=ao(t);e.hostname=s.host,e.secure=s.protocol==="https"||s.protocol==="wss",e.port=s.port,s.query&&(e.query=s.query)}else e.host&&(e.hostname=ao(e.host).host);Qn(this,e),this.secure=e.secure!=null?e.secure:typeof location<"u"&&location.protocol==="https:",e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.hostname=e.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=e.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},e.transports.forEach(s=>{const o=s.prototype.name;this.transports.push(o),this._transportsByName[o]=s}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},e),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=ju(this.opts.query)),lo&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Bn.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const e=Object.assign({},this.opts.query);e.EIO=Vl,e.transport=t,this.id&&(e.sid=this.id);const s=Object.assign({},this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](s)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Se.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const e=this.createTransport(t);e.open(),this.setTransport(e)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",Se.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const e=new Error("server error");e.code=t.data,this._onError(e);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let s=0;s0&&e>this._maxPayload)return this.writeBuffer.slice(0,s);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,Jn(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,e,s){return this._sendPacket("message",t,e,s),this}send(t,e,s){return this._sendPacket("message",t,e,s),this}_sendPacket(t,e,s,o){if(typeof e=="function"&&(o=e,e=void 0),typeof s=="function"&&(o=s,s=null),this.readyState==="closing"||this.readyState==="closed")return;s=s||{},s.compress=s.compress!==!1;const a={type:t,data:e,options:s};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},e=()=>{this.off("upgrade",e),this.off("upgradeError",e),t()},s=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?s():t()}):this.upgrading?s():t()),this}_onError(t){if(Se.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),lo&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const s=Bn.indexOf(this._offlineEventListener);s!==-1&&Bn.splice(s,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,e),this.writeBuffer=[],this._prevBufferLen=0}}}Se.protocol=Vl;class rd extends Se{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t{s||(e.send([{type:"ping",data:"probe"}]),e.once("packet",g=>{if(!s)if(g.type==="pong"&&g.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",e),!e)return;Se.priorWebsocketSuccess=e.name==="websocket",this.transport.pause(()=>{s||this.readyState!=="closed"&&(p(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emitReserved("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{const _=new Error("probe error");_.transport=e.name,this.emitReserved("upgradeError",_)}}))};function a(){s||(s=!0,p(),e.close(),e=null)}const l=g=>{const _=new Error("probe error: "+g);_.transport=e.name,a(),this.emitReserved("upgradeError",_)};function h(){l("transport closed")}function u(){l("socket closed")}function d(g){e&&g.name!==e.name&&a()}const p=()=>{e.removeListener("open",o),e.removeListener("error",l),e.removeListener("close",h),this.off("close",u),this.off("upgrading",d)};e.once("open",o),e.once("error",l),e.once("close",h),this.once("close",u),this.once("upgrading",d),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{s||e.open()},200):e.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const e=[];for(let s=0;sed[o]).filter(o=>!!o)),super(t,s)}};function ld(i,t="",e){let s=i;e=e||typeof location<"u"&&location,i==null&&(i=e.protocol+"//"+e.host),typeof i=="string"&&(i.charAt(0)==="/"&&(i.charAt(1)==="/"?i=e.protocol+i:i=e.host+i),/^(https?|wss?):\/\//.test(i)||(typeof e<"u"?i=e.protocol+"//"+i:i="https://"+i),s=ao(i)),s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443")),s.path=s.path||"/";const a=s.host.indexOf(":")!==-1?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+a+":"+s.port+t,s.href=s.protocol+"://"+a+(e&&e.port===s.port?"":":"+s.port),s}const hd=typeof ArrayBuffer=="function",cd=i=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(i):i.buffer instanceof ArrayBuffer,Xl=Object.prototype.toString,ud=typeof Blob=="function"||typeof Blob<"u"&&Xl.call(Blob)==="[object BlobConstructor]",dd=typeof File=="function"||typeof File<"u"&&Xl.call(File)==="[object FileConstructor]";function Co(i){return hd&&(i instanceof ArrayBuffer||cd(i))||ud&&i instanceof Blob||dd&&i instanceof File}function zn(i,t){if(!i||typeof i!="object")return!1;if(Array.isArray(i)){for(let e=0,s=i.length;e=0&&i.numthis.opts.maxAttachments)throw new Error("too many attachments");s.attachments=h}if(t.charAt(e+1)==="/"){const a=e+1;for(;++e&&!(t.charAt(e)===","||e===t.length););s.nsp=t.substring(a,e)}else s.nsp="/";const o=t.charAt(e+1);if(o!==""&&Number(o)==o){const a=e+1;for(;++e;){const l=t.charAt(e);if(l==null||Number(l)!=l){--e;break}if(e===t.length)break}s.id=Number(t.substring(a,e+1))}if(t.charAt(++e)){const a=this.tryParse(t.substr(e));if(To.isPayloadValid(s.type,a))s.data=a;else throw new Error("invalid payload")}return s}tryParse(t){try{return JSON.parse(t,this.opts.reviver)}catch{return!1}}static isPayloadValid(t,e){switch(t){case nt.CONNECT:return ca(e);case nt.DISCONNECT:return e===void 0;case nt.CONNECT_ERROR:return typeof e=="string"||ca(e);case nt.EVENT:case nt.BINARY_EVENT:return Array.isArray(e)&&(typeof e[0]=="number"||typeof e[0]=="string"&&md.indexOf(e[0])===-1);case nt.ACK:case nt.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class _d{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const e=pd(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const yd=Number.isInteger||function(i){return typeof i=="number"&&isFinite(i)&&Math.floor(i)===i};function ca(i){return Object.prototype.toString.call(i)==="[object Object]"}const vd=Object.freeze(Object.defineProperty({__proto__:null,Decoder:To,Encoder:gd,get PacketType(){return nt}},Symbol.toStringTag,{value:"Module"}));function Yt(i,t,e){return i.on(t,e),function(){i.off(t,e)}}const bd=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Kl extends Lt{constructor(t,e,s){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,s&&s.auth&&(this.auth=s.auth),this._opts=Object.assign({},s),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[Yt(t,"open",this.onopen.bind(this)),Yt(t,"packet",this.onpacket.bind(this)),Yt(t,"error",this.onerror.bind(this)),Yt(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){var s,o,a;if(bd.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(e.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(e),this;const l={type:nt.EVENT,data:e};if(l.options={},l.options.compress=this.flags.compress!==!1,typeof e[e.length-1]=="function"){const p=this.ids++,g=e.pop();this._registerAckCallback(p,g),l.id=p}const h=(o=(s=this.io.engine)===null||s===void 0?void 0:s.transport)===null||o===void 0?void 0:o.writable,u=this.connected&&!(!((a=this.io.engine)===null||a===void 0)&&a._hasPingExpired());return this.flags.volatile&&!h||(u?(this.notifyOutgoingListeners(l),this.packet(l)):this.sendBuffer.push(l)),this.flags={},this}_registerAckCallback(t,e){var s;const o=(s=this.flags.timeout)!==null&&s!==void 0?s:this._opts.ackTimeout;if(o===void 0){this.acks[t]=e;return}const a=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let h=0;h{this.io.clearTimeoutFn(a),e.apply(this,h)};l.withError=!0,this.acks[t]=l}emitWithAck(t,...e){return new Promise((s,o)=>{const a=(l,h)=>l?o(l):s(h);a.withError=!0,e.push(a),this.emit(t,...e)})}_addToQueue(t){let e;typeof t[t.length-1]=="function"&&(e=t.pop());const s={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...a)=>(this._queue[0],o!==null?s.tryCount>this._opts.retries&&(this._queue.shift(),e&&e(o)):(this._queue.shift(),e&&e(null,...a)),s.pending=!1,this._drainQueue())),this._queue.push(s),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const e=this._queue[0];e.pending&&!t||(e.pending=!0,e.tryCount++,this.flags=e.flags,this.emit.apply(this,e.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:nt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,e){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,e),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(s=>String(s.id)===t)){const s=this.acks[t];delete this.acks[t],s.withError&&s.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case nt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case nt.EVENT:case nt.BINARY_EVENT:this.onevent(t);break;case nt.ACK:case nt.BINARY_ACK:this.onack(t);break;case nt.DISCONNECT:this.ondisconnect();break;case nt.CONNECT_ERROR:this.destroy();const s=new Error(t.data.message);s.data=t.data.data,this.emitReserved("connect_error",s);break}}onevent(t){const e=t.data||[];t.id!=null&&e.push(this.ack(t.id)),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const s of e)s.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const e=this;let s=!1;return function(...o){s||(s=!0,e.packet({type:nt.ACK,id:t,data:o}))}}onack(t){const e=this.acks[t.id];typeof e=="function"&&(delete this.acks[t.id],e.withError&&t.data.unshift(null),e.apply(this,t.data))}onconnect(t,e){this.id=t,this.recovered=e&&this._pid===e,this._pid=e,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved("connect")}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:nt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let s=0;s0&&i.jitter<=1?i.jitter:0,this.attempts=0}fi.prototype.duration=function(){var i=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),e=Math.floor(t*this.jitter*i);i=(Math.floor(t*10)&1)==0?i-e:i+e}return Math.min(i,this.max)|0};fi.prototype.reset=function(){this.attempts=0};fi.prototype.setMin=function(i){this.ms=i};fi.prototype.setMax=function(i){this.max=i};fi.prototype.setJitter=function(i){this.jitter=i};class uo extends Lt{constructor(t,e){var s;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(e=t,t=void 0),e=e||{},e.path=e.path||"/socket.io",this.opts=e,Qn(this,e),this.reconnection(e.reconnection!==!1),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor((s=e.randomizationFactor)!==null&&s!==void 0?s:.5),this.backoff=new fi({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(e.timeout==null?2e4:e.timeout),this._readyState="closed",this.uri=t;const o=e.parser||vd;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=e.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(e=this.backoff)===null||e===void 0||e.setMin(t),this)}randomizationFactor(t){var e;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(e=this.backoff)===null||e===void 0||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(e=this.backoff)===null||e===void 0||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new ad(this.uri,this.opts);const e=this.engine,s=this;this._readyState="opening",this.skipReconnect=!1;const o=Yt(e,"open",function(){s.onopen(),t&&t()}),a=h=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",h),t?t(h):this.maybeReconnectOnOpen()},l=Yt(e,"error",a);if(this._timeout!==!1){const h=this._timeout,u=this.setTimeoutFn(()=>{o(),a(new Error("timeout")),e.close()},h);this.opts.autoUnref&&u.unref(),this.subs.push(()=>{this.clearTimeoutFn(u)})}return this.subs.push(o),this.subs.push(l),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(Yt(t,"ping",this.onping.bind(this)),Yt(t,"data",this.ondata.bind(this)),Yt(t,"error",this.onerror.bind(this)),Yt(t,"close",this.onclose.bind(this)),Yt(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(e){this.onclose("parse error",e)}}ondecoded(t){Jn(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,e){let s=this.nsps[t];return s?this._autoConnect&&!s.active&&s.connect():(s=new Kl(this,t,e),this.nsps[t]=s),s}_destroy(t){const e=Object.keys(this.nsps);for(const s of e)if(this.nsps[s].active)return;this._close()}_packet(t){const e=this.encoder.encode(t);for(let s=0;st()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,e){var s;this.cleanup(),(s=this.engine)===null||s===void 0||s.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,e),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();this._reconnecting=!0;const s=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},e);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Ci={};function Nn(i,t){typeof i=="object"&&(t=i,i=void 0),t=t||{};const e=ld(i,t.path||"/socket.io"),s=e.source,o=e.id,a=e.path,l=Ci[o]&&a in Ci[o].nsps,h=t.forceNew||t["force new connection"]||t.multiplex===!1||l;let u;return h?u=new uo(s,t):(Ci[o]||(Ci[o]=new uo(s,t)),u=Ci[o]),e.query&&!t.query&&(t.query=e.queryKey),u.socket(e.path,t)}Object.assign(Nn,{Manager:uo,Socket:Kl,io:Nn,connect:Nn});const Ee="/api/v1";async function Ae(i,t={}){const e=await fetch(i,{headers:{"Content-Type":"application/json",...t.headers},...t});if(!e.ok){const s=await e.text().catch(()=>"");throw new Error(`HTTP ${e.status}: ${s}`)}return e.status===204?null:e.json()}async function xd(i={}){const t=new URLSearchParams(i).toString();return Ae(`${Ee}/markets${t?"?"+t:""}`)}async function wd(i){return Ae(`${Ee}/markets/${i}/signal`)}async function Pd(){return Ae(`${Ee}/positions`)}async function kd(i){return Ae(`${Ee}/positions`,{method:"POST",body:JSON.stringify(i)})}async function Sd(i){return Ae(`${Ee}/positions/${i}`,{method:"DELETE"})}async function Md(){return Ae(`${Ee}/watchlist`)}async function Ld(i){return Ae(`${Ee}/watchlist/${i}`,{method:"DELETE"})}async function Cd(){return Ae(`${Ee}/alerts`)}function Ji(i){return i+.5|0}const xe=(i,t,e)=>Math.max(Math.min(i,e),t);function Bi(i){return xe(Ji(i*2.55),0,255)}function Me(i){return xe(Ji(i*255),0,255)}function fe(i){return xe(Ji(i/2.55)/100,0,1)}function ua(i){return xe(Ji(i*100),0,100)}const jt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},fo=[..."0123456789ABCDEF"],Td=i=>fo[i&15],Ed=i=>fo[(i&240)>>4]+fo[i&15],wn=i=>(i&240)>>4===(i&15),Ad=i=>wn(i.r)&&wn(i.g)&&wn(i.b)&&wn(i.a);function Od(i){var t=i.length,e;return i[0]==="#"&&(t===4||t===5?e={r:255&jt[i[1]]*17,g:255&jt[i[2]]*17,b:255&jt[i[3]]*17,a:t===5?jt[i[4]]*17:255}:(t===7||t===9)&&(e={r:jt[i[1]]<<4|jt[i[2]],g:jt[i[3]]<<4|jt[i[4]],b:jt[i[5]]<<4|jt[i[6]],a:t===9?jt[i[7]]<<4|jt[i[8]]:255})),e}const Dd=(i,t)=>i<255?t(i):"";function Id(i){var t=Ad(i)?Td:Ed;return i?"#"+t(i.r)+t(i.g)+t(i.b)+Dd(i.a,t):void 0}const Rd=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Gl(i,t,e){const s=t*Math.min(e,1-e),o=(a,l=(a+i/30)%12)=>e-s*Math.max(Math.min(l-3,9-l,1),-1);return[o(0),o(8),o(4)]}function Bd(i,t,e){const s=(o,a=(o+i/60)%6)=>e-e*t*Math.max(Math.min(a,4-a,1),0);return[s(5),s(3),s(1)]}function zd(i,t,e){const s=Gl(i,1,.5);let o;for(t+e>1&&(o=1/(t+e),t*=o,e*=o),o=0;o<3;o++)s[o]*=1-t-e,s[o]+=t;return s}function Nd(i,t,e,s,o){return i===o?(t-e)/s+(t.5?p/(2-a-l):p/(a+l),u=Nd(e,s,o,p,a),u=u*60+.5),[u|0,d||0,h]}function Ao(i,t,e,s){return(Array.isArray(t)?i(t[0],t[1],t[2]):i(t,e,s)).map(Me)}function Oo(i,t,e){return Ao(Gl,i,t,e)}function Fd(i,t,e){return Ao(zd,i,t,e)}function Wd(i,t,e){return Ao(Bd,i,t,e)}function Jl(i){return(i%360+360)%360}function Hd(i){const t=Rd.exec(i);let e=255,s;if(!t)return;t[5]!==s&&(e=t[6]?Bi(+t[5]):Me(+t[5]));const o=Jl(+t[2]),a=+t[3]/100,l=+t[4]/100;return t[1]==="hwb"?s=Fd(o,a,l):t[1]==="hsv"?s=Wd(o,a,l):s=Oo(o,a,l),{r:s[0],g:s[1],b:s[2],a:e}}function Zd(i,t){var e=Eo(i);e[0]=Jl(e[0]+t),e=Oo(e),i.r=e[0],i.g=e[1],i.b=e[2]}function Vd(i){if(!i)return;const t=Eo(i),e=t[0],s=ua(t[1]),o=ua(t[2]);return i.a<255?`hsla(${e}, ${s}%, ${o}%, ${fe(i.a)})`:`hsl(${e}, ${s}%, ${o}%)`}const da={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},fa={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function jd(){const i={},t=Object.keys(fa),e=Object.keys(da);let s,o,a,l,h;for(s=0;s>16&255,a>>8&255,a&255]}return i}let Pn;function qd(i){Pn||(Pn=jd(),Pn.transparent=[0,0,0,0]);const t=Pn[i.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const $d=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Ud(i){const t=$d.exec(i);let e=255,s,o,a;if(t){if(t[7]!==s){const l=+t[7];e=t[8]?Bi(l):xe(l*255,0,255)}return s=+t[1],o=+t[3],a=+t[5],s=255&(t[2]?Bi(s):xe(s,0,255)),o=255&(t[4]?Bi(o):xe(o,0,255)),a=255&(t[6]?Bi(a):xe(a,0,255)),{r:s,g:o,b:a,a:e}}}function Yd(i){return i&&(i.a<255?`rgba(${i.r}, ${i.g}, ${i.b}, ${fe(i.a)})`:`rgb(${i.r}, ${i.g}, ${i.b})`)}const qs=i=>i<=.0031308?i*12.92:Math.pow(i,1/2.4)*1.055-.055,oi=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function Xd(i,t,e){const s=oi(fe(i.r)),o=oi(fe(i.g)),a=oi(fe(i.b));return{r:Me(qs(s+e*(oi(fe(t.r))-s))),g:Me(qs(o+e*(oi(fe(t.g))-o))),b:Me(qs(a+e*(oi(fe(t.b))-a))),a:i.a+e*(t.a-i.a)}}function kn(i,t,e){if(i){let s=Eo(i);s[t]=Math.max(0,Math.min(s[t]+s[t]*e,t===0?360:1)),s=Oo(s),i.r=s[0],i.g=s[1],i.b=s[2]}}function Ql(i,t){return i&&Object.assign(t||{},i)}function pa(i){var t={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(t={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(t.a=Me(i[3]))):(t=Ql(i,{r:0,g:0,b:0,a:1}),t.a=Me(t.a)),t}function Kd(i){return i.charAt(0)==="r"?Ud(i):Hd(i)}class qi{constructor(t){if(t instanceof qi)return t;const e=typeof t;let s;e==="object"?s=pa(t):e==="string"&&(s=Od(t)||qd(t)||Kd(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=Ql(this._rgb);return t&&(t.a=fe(t.a)),t}set rgb(t){this._rgb=pa(t)}rgbString(){return this._valid?Yd(this._rgb):void 0}hexString(){return this._valid?Id(this._rgb):void 0}hslString(){return this._valid?Vd(this._rgb):void 0}mix(t,e){if(t){const s=this.rgb,o=t.rgb;let a;const l=e===a?.5:e,h=2*l-1,u=s.a-o.a,d=((h*u===-1?h:(h+u)/(1+h*u))+1)/2;a=1-d,s.r=255&d*s.r+a*o.r+.5,s.g=255&d*s.g+a*o.g+.5,s.b=255&d*s.b+a*o.b+.5,s.a=l*s.a+(1-l)*o.a,this.rgb=s}return this}interpolate(t,e){return t&&(this._rgb=Xd(this._rgb,t._rgb,e)),this}clone(){return new qi(this.rgb)}alpha(t){return this._rgb.a=Me(t),this}clearer(t){const e=this._rgb;return e.a*=1-t,this}greyscale(){const t=this._rgb,e=Ji(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=e,this}opaquer(t){const e=this._rgb;return e.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return kn(this._rgb,2,t),this}darken(t){return kn(this._rgb,2,-t),this}saturate(t){return kn(this._rgb,1,t),this}desaturate(t){return kn(this._rgb,1,-t),this}rotate(t){return Zd(this._rgb,t),this}}function ce(){}const Gd=(()=>{let i=0;return()=>i++})();function Q(i){return i==null}function mt(i){if(Array.isArray&&Array.isArray(i))return!0;const t=Object.prototype.toString.call(i);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function et(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function bt(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function Wt(i,t){return bt(i)?i:t}function U(i,t){return typeof i>"u"?t:i}const Jd=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100:+i/t,th=(i,t)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*t:+i;function ft(i,t,e){if(i&&typeof i.call=="function")return i.apply(e,t)}function ht(i,t,e,s){let o,a,l;if(mt(i))for(a=i.length,o=0;oi,x:i=>i.x,y:i=>i.y};function ef(i){const t=i.split("."),e=[];let s="";for(const o of t)s+=o,s.endsWith("\\")?s=s.slice(0,-1)+".":(e.push(s),s="");return e}function nf(i){const t=ef(i);return e=>{for(const s of t){if(s==="")break;e=e&&e[s]}return e}}function Ce(i,t){return(ma[t]||(ma[t]=nf(t)))(i)}function Do(i){return i.charAt(0).toUpperCase()+i.slice(1)}const Ui=i=>typeof i<"u",Te=i=>typeof i=="function",ga=(i,t)=>{if(i.size!==t.size)return!1;for(const e of i)if(!t.has(e))return!1;return!0};function sf(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}const lt=Math.PI,pt=2*lt,of=pt+lt,qn=Number.POSITIVE_INFINITY,rf=lt/180,Pt=lt/2,Fe=lt/4,_a=lt*2/3,we=Math.log10,ne=Math.sign;function Zi(i,t,e){return Math.abs(i-t)o-a).pop(),t}function lf(i){return typeof i=="symbol"||typeof i=="object"&&i!==null&&!(Symbol.toPrimitive in i||"toString"in i||"valueOf"in i)}function ci(i){return!lf(i)&&!isNaN(parseFloat(i))&&isFinite(i)}function hf(i,t){const e=Math.round(i);return e-t<=i&&e+t>=i}function ih(i,t,e){let s,o,a;for(s=0,o=i.length;su&&d=Math.min(t,e)-s&&i<=Math.max(t,e)+s}function Ro(i,t,e){e=e||(l=>i[l]1;)a=o+s>>1,e(a)?o=a:s=a;return{lo:o,hi:s}}const me=(i,t,e,s)=>Ro(i,e,s?o=>{const a=i[o][t];return ai[o][t]Ro(i,e,s=>i[s][t]>=e);function ff(i,t,e){let s=0,o=i.length;for(;ss&&i[o-1]>e;)o--;return s>0||o{const s="_onData"+Do(e),o=i[e];Object.defineProperty(i,e,{configurable:!0,enumerable:!1,value(...a){const l=o.apply(this,a);return i._chartjs.listeners.forEach(h=>{typeof h[s]=="function"&&h[s](...a)}),l}})})}function ba(i,t){const e=i._chartjs;if(!e)return;const s=e.listeners,o=s.indexOf(t);o!==-1&&s.splice(o,1),!(s.length>0)&&(sh.forEach(a=>{delete i[a]}),delete i._chartjs)}function oh(i){const t=new Set(i);return t.size===i.length?i:Array.from(t)}const rh=(function(){return typeof window>"u"?function(i){return i()}:window.requestAnimationFrame})();function ah(i,t){let e=[],s=!1;return function(...o){e=o,s||(s=!0,rh.call(window,()=>{s=!1,i.apply(t,e)}))}}function mf(i,t){let e;return function(...s){return t?(clearTimeout(e),e=setTimeout(i,t,s)):i.apply(this,s),t}}const Bo=i=>i==="start"?"left":i==="end"?"right":"center",Ot=(i,t,e)=>i==="start"?t:i==="end"?e:(t+e)/2,gf=(i,t,e,s)=>i===(s?"left":"right")?e:i==="center"?(t+e)/2:t;function lh(i,t,e){const s=t.length;let o=0,a=s;if(i._sorted){const{iScale:l,vScale:h,_parsed:u}=i,d=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null,p=l.axis,{min:g,max:_,minDefined:v,maxDefined:x}=l.getUserBounds();if(v){if(o=Math.min(me(u,p,g).lo,e?s:me(t,p,l.getPixelForValue(g)).lo),d){const b=u.slice(0,o+1).reverse().findIndex(P=>!Q(P[h.axis]));o-=Math.max(0,b)}o=Et(o,0,s-1)}if(x){let b=Math.max(me(u,l.axis,_,!0).hi+1,e?0:me(t,p,l.getPixelForValue(_),!0).hi+1);if(d){const P=u.slice(b-1).findIndex(k=>!Q(k[h.axis]));b+=Math.max(0,P)}a=Et(b,o,s)-o}else a=s-o}return{start:o,count:a}}function hh(i){const{xScale:t,yScale:e,_scaleRanges:s}=i,o={xmin:t.min,xmax:t.max,ymin:e.min,ymax:e.max};if(!s)return i._scaleRanges=o,!0;const a=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==e.min||s.ymax!==e.max;return Object.assign(s,o),a}const Sn=i=>i===0||i===1,xa=(i,t,e)=>-(Math.pow(2,10*(i-=1))*Math.sin((i-t)*pt/e)),wa=(i,t,e)=>Math.pow(2,-10*i)*Math.sin((i-t)*pt/e)+1,Vi={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>-Math.cos(i*Pt)+1,easeOutSine:i=>Math.sin(i*Pt),easeInOutSine:i=>-.5*(Math.cos(lt*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:-Math.pow(2,-10*i)+1,easeInOutExpo:i=>Sn(i)?i:i<.5?.5*Math.pow(2,10*(i*2-1)):.5*(-Math.pow(2,-10*(i*2-1))+2),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>Sn(i)?i:xa(i,.075,.3),easeOutElastic:i=>Sn(i)?i:wa(i,.075,.3),easeInOutElastic(i){return Sn(i)?i:i<.5?.5*xa(i*2,.1125,.45):.5+.5*wa(i*2-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let t=1.70158;return(i/=.5)<1?.5*(i*i*(((t*=1.525)+1)*i-t)):.5*((i-=2)*i*(((t*=1.525)+1)*i+t)+2)},easeInBounce:i=>1-Vi.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?Vi.easeInBounce(i*2)*.5:Vi.easeOutBounce(i*2-1)*.5+.5};function zo(i){if(i&&typeof i=="object"){const t=i.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Pa(i){return zo(i)?i:new qi(i)}function $s(i){return zo(i)?i:new qi(i).saturate(.5).darken(.1).hexString()}const _f=["x","y","borderWidth","radius","tension"],yf=["color","borderColor","backgroundColor"];function vf(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),i.set("animations",{colors:{type:"color",properties:yf},numbers:{type:"number",properties:_f}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function bf(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const ka=new Map;function xf(i,t){t=t||{};const e=i+JSON.stringify(t);let s=ka.get(e);return s||(s=new Intl.NumberFormat(i,t),ka.set(e,s)),s}function Qi(i,t,e){return xf(t,e).format(i)}const ch={values(i){return mt(i)?i:""+i},numeric(i,t,e){if(i===0)return"0";const s=this.chart.options.locale;let o,a=i;if(e.length>1){const d=Math.max(Math.abs(e[0].value),Math.abs(e[e.length-1].value));(d<1e-4||d>1e15)&&(o="scientific"),a=wf(i,e)}const l=we(Math.abs(a)),h=isNaN(l)?1:Math.max(Math.min(-1*Math.floor(l),20),0),u={notation:o,minimumFractionDigits:h,maximumFractionDigits:h};return Object.assign(u,this.options.ticks.format),Qi(i,s,u)},logarithmic(i,t,e){if(i===0)return"0";const s=e[t].significand||i/Math.pow(10,Math.floor(we(i)));return[1,2,3,5,10,15].includes(s)||t>.8*e.length?ch.numeric.call(this,i,t,e):""}};function wf(i,t){let e=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(e)>=1&&i!==Math.floor(i)&&(e=i-Math.floor(i)),e}var ts={formatters:ch};function Pf(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,e)=>e.lineWidth,tickColor:(t,e)=>e.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:ts.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const Ue=Object.create(null),mo=Object.create(null);function ji(i,t){if(!t)return i;const e=t.split(".");for(let s=0,o=e.length;ss.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(s,o)=>$s(o.backgroundColor),this.hoverBorderColor=(s,o)=>$s(o.borderColor),this.hoverColor=(s,o)=>$s(o.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(e)}set(t,e){return Us(this,t,e)}get(t){return ji(this,t)}describe(t,e){return Us(mo,t,e)}override(t,e){return Us(Ue,t,e)}route(t,e,s,o){const a=ji(this,t),l=ji(this,s),h="_"+e;Object.defineProperties(a,{[h]:{value:a[e],writable:!0},[e]:{enumerable:!0,get(){const u=this[h],d=l[o];return et(u)?Object.assign({},d,u):U(u,d)},set(u){this[h]=u}}})}apply(t){t.forEach(e=>e(this))}}var gt=new kf({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[vf,bf,Pf]);function Sf(i){return!i||Q(i.size)||Q(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function $n(i,t,e,s,o){let a=t[o];return a||(a=t[o]=i.measureText(o).width,e.push(o)),a>s&&(s=a),s}function Mf(i,t,e,s){s=s||{};let o=s.data=s.data||{},a=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(o=s.data={},a=s.garbageCollect=[],s.font=t),i.save(),i.font=t;let l=0;const h=e.length;let u,d,p,g,_;for(u=0;ue.length){for(u=0;u0&&i.stroke()}}function ge(i,t,e){return e=e||.5,!t||i&&i.x>t.left-e&&i.xt.top-e&&i.y0&&a.strokeColor!=="";let u,d;for(i.save(),i.font=o.string,Tf(i,a),u=0;u+i||0;function No(i,t){const e={},s=et(t),o=s?Object.keys(t):t,a=et(i)?s?l=>U(i[l],i[t[l]]):l=>i[l]:()=>i;for(const l of o)e[l]=Rf(a(l));return e}function dh(i){return No(i,{top:"y",right:"x",bottom:"y",left:"x"})}function qe(i){return No(i,["topLeft","topRight","bottomLeft","bottomRight"])}function Rt(i){const t=dh(i);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function Ct(i,t){i=i||{},t=t||gt.font;let e=U(i.size,t.size);typeof e=="string"&&(e=parseInt(e,10));let s=U(i.style,t.style);s&&!(""+s).match(Df)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const o={family:U(i.family,t.family),lineHeight:If(U(i.lineHeight,t.lineHeight),e),size:e,style:s,weight:U(i.weight,t.weight),string:""};return o.string=Sf(o),o}function zi(i,t,e,s){let o,a,l;for(o=0,a=i.length;oe&&h===0?0:h+u;return{min:l(s,-Math.abs(a)),max:l(o,a)}}function Oe(i,t){return Object.assign(Object.create(i),t)}function Fo(i,t=[""],e,s,o=()=>i[0]){const a=e||i;typeof s>"u"&&(s=gh("_fallback",i));const l={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:a,_fallback:s,_getTarget:o,override:h=>Fo([h,...i],t,a,s)};return new Proxy(l,{deleteProperty(h,u){return delete h[u],delete h._keys,delete i[0][u],!0},get(h,u){return ph(h,u,()=>jf(u,t,i,h))},getOwnPropertyDescriptor(h,u){return Reflect.getOwnPropertyDescriptor(h._scopes[0],u)},getPrototypeOf(){return Reflect.getPrototypeOf(i[0])},has(h,u){return La(h).includes(u)},ownKeys(h){return La(h)},set(h,u,d){const p=h._storage||(h._storage=o());return h[u]=p[u]=d,delete h._keys,!0}})}function ui(i,t,e,s){const o={_cacheable:!1,_proxy:i,_context:t,_subProxy:e,_stack:new Set,_descriptors:fh(i,s),setContext:a=>ui(i,a,e,s),override:a=>ui(i.override(a),t,e,s)};return new Proxy(o,{deleteProperty(a,l){return delete a[l],delete i[l],!0},get(a,l,h){return ph(a,l,()=>Nf(a,l,h))},getOwnPropertyDescriptor(a,l){return a._descriptors.allKeys?Reflect.has(i,l)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,l)},getPrototypeOf(){return Reflect.getPrototypeOf(i)},has(a,l){return Reflect.has(i,l)},ownKeys(){return Reflect.ownKeys(i)},set(a,l,h){return i[l]=h,delete a[l],!0}})}function fh(i,t={scriptable:!0,indexable:!0}){const{_scriptable:e=t.scriptable,_indexable:s=t.indexable,_allKeys:o=t.allKeys}=i;return{allKeys:o,scriptable:e,indexable:s,isScriptable:Te(e)?e:()=>e,isIndexable:Te(s)?s:()=>s}}const zf=(i,t)=>i?i+Do(t):t,Wo=(i,t)=>et(t)&&i!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function ph(i,t,e){if(Object.prototype.hasOwnProperty.call(i,t)||t==="constructor")return i[t];const s=e();return i[t]=s,s}function Nf(i,t,e){const{_proxy:s,_context:o,_subProxy:a,_descriptors:l}=i;let h=s[t];return Te(h)&&l.isScriptable(t)&&(h=Ff(t,h,i,e)),mt(h)&&h.length&&(h=Wf(t,h,i,l.isIndexable)),Wo(t,h)&&(h=ui(h,o,a&&a[t],l)),h}function Ff(i,t,e,s){const{_proxy:o,_context:a,_subProxy:l,_stack:h}=e;if(h.has(i))throw new Error("Recursion detected: "+Array.from(h).join("->")+"->"+i);h.add(i);let u=t(a,l||s);return h.delete(i),Wo(i,u)&&(u=Ho(o._scopes,o,i,u)),u}function Wf(i,t,e,s){const{_proxy:o,_context:a,_subProxy:l,_descriptors:h}=e;if(typeof a.index<"u"&&s(i))return t[a.index%t.length];if(et(t[0])){const u=t,d=o._scopes.filter(p=>p!==u);t=[];for(const p of u){const g=Ho(d,o,i,p);t.push(ui(g,a,l&&l[i],h))}}return t}function mh(i,t,e){return Te(i)?i(t,e):i}const Hf=(i,t)=>i===!0?t:typeof i=="string"?Ce(t,i):void 0;function Zf(i,t,e,s,o){for(const a of t){const l=Hf(e,a);if(l){i.add(l);const h=mh(l._fallback,e,o);if(typeof h<"u"&&h!==e&&h!==s)return h}else if(l===!1&&typeof s<"u"&&e!==s)return null}return!1}function Ho(i,t,e,s){const o=t._rootScopes,a=mh(t._fallback,e,s),l=[...i,...o],h=new Set;h.add(s);let u=Ma(h,l,e,a||e,s);return u===null||typeof a<"u"&&a!==e&&(u=Ma(h,l,a,u,s),u===null)?!1:Fo(Array.from(h),[""],o,a,()=>Vf(t,e,s))}function Ma(i,t,e,s,o){for(;e;)e=Zf(i,t,e,s,o);return e}function Vf(i,t,e){const s=i._getTarget();t in s||(s[t]={});const o=s[t];return mt(o)&&et(e)?e:o||{}}function jf(i,t,e,s){let o;for(const a of t)if(o=gh(zf(a,i),e),typeof o<"u")return Wo(i,o)?Ho(e,s,i,o):o}function gh(i,t){for(const e of t){if(!e)continue;const s=e[i];if(typeof s<"u")return s}}function La(i){let t=i._keys;return t||(t=i._keys=qf(i._scopes)),t}function qf(i){const t=new Set;for(const e of i)for(const s of Object.keys(e).filter(o=>!o.startsWith("_")))t.add(s);return Array.from(t)}function _h(i,t,e,s){const{iScale:o}=i,{key:a="r"}=this._parsing,l=new Array(s);let h,u,d,p;for(h=0,u=s;hti==="x"?"y":"x";function Uf(i,t,e,s){const o=i.skip?t:i,a=t,l=e.skip?t:e,h=po(a,o),u=po(l,a);let d=h/(h+u),p=u/(h+u);d=isNaN(d)?0:d,p=isNaN(p)?0:p;const g=s*d,_=s*p;return{previous:{x:a.x-g*(l.x-o.x),y:a.y-g*(l.y-o.y)},next:{x:a.x+_*(l.x-o.x),y:a.y+_*(l.y-o.y)}}}function Yf(i,t,e){const s=i.length;let o,a,l,h,u,d=di(i,0);for(let p=0;p!d.skip)),t.cubicInterpolationMode==="monotone")Kf(i,o);else{let d=s?i[i.length-1]:i[0];for(a=0,l=i.length;ai.ownerDocument.defaultView.getComputedStyle(i,null);function Qf(i,t){return ns(i).getPropertyValue(t)}const tp=["top","right","bottom","left"];function $e(i,t,e){const s={};e=e?"-"+e:"";for(let o=0;o<4;o++){const a=tp[o];s[a]=parseFloat(i[t+"-"+a+e])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const ep=(i,t,e)=>(i>0||t>0)&&(!e||!e.shadowRoot);function ip(i,t){const e=i.touches,s=e&&e.length?e[0]:i,{offsetX:o,offsetY:a}=s;let l=!1,h,u;if(ep(o,a,i.target))h=o,u=a;else{const d=t.getBoundingClientRect();h=s.clientX-d.left,u=s.clientY-d.top,l=!0}return{x:h,y:u,box:l}}function Ve(i,t){if("native"in i)return i;const{canvas:e,currentDevicePixelRatio:s}=t,o=ns(e),a=o.boxSizing==="border-box",l=$e(o,"padding"),h=$e(o,"border","width"),{x:u,y:d,box:p}=ip(i,e),g=l.left+(p&&h.left),_=l.top+(p&&h.top);let{width:v,height:x}=t;return a&&(v-=l.width+h.width,x-=l.height+h.height),{x:Math.round((u-g)/v*e.width/s),y:Math.round((d-_)/x*e.height/s)}}function np(i,t,e){let s,o;if(t===void 0||e===void 0){const a=i&&Vo(i);if(!a)t=i.clientWidth,e=i.clientHeight;else{const l=a.getBoundingClientRect(),h=ns(a),u=$e(h,"border","width"),d=$e(h,"padding");t=l.width-d.width-u.width,e=l.height-d.height-u.height,s=Un(h.maxWidth,a,"clientWidth"),o=Un(h.maxHeight,a,"clientHeight")}}return{width:t,height:e,maxWidth:s||qn,maxHeight:o||qn}}const Pe=i=>Math.round(i*10)/10;function sp(i,t,e,s){const o=ns(i),a=$e(o,"margin"),l=Un(o.maxWidth,i,"clientWidth")||qn,h=Un(o.maxHeight,i,"clientHeight")||qn,u=np(i,t,e);let{width:d,height:p}=u;if(o.boxSizing==="content-box"){const _=$e(o,"border","width"),v=$e(o,"padding");d-=v.width+_.width,p-=v.height+_.height}return d=Math.max(0,d-a.width),p=Math.max(0,s?d/s:p-a.height),d=Pe(Math.min(d,l,u.maxWidth)),p=Pe(Math.min(p,h,u.maxHeight)),d&&!p&&(p=Pe(d/2)),(t!==void 0||e!==void 0)&&s&&u.height&&p>u.height&&(p=u.height,d=Pe(Math.floor(p*s))),{width:d,height:p}}function Ca(i,t,e){const s=t||1,o=Pe(i.height*s),a=Pe(i.width*s);i.height=Pe(i.height),i.width=Pe(i.width);const l=i.canvas;return l.style&&(e||!l.style.height&&!l.style.width)&&(l.style.height=`${i.height}px`,l.style.width=`${i.width}px`),i.currentDevicePixelRatio!==s||l.height!==o||l.width!==a?(i.currentDevicePixelRatio=s,l.height=o,l.width=a,i.ctx.setTransform(s,0,0,s,0,0),!0):!1}const op=(function(){let i=!1;try{const t={get passive(){return i=!0,!1}};Zo()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return i})();function Ta(i,t){const e=Qf(i,t),s=e&&e.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function je(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:i.y+e*(t.y-i.y)}}function rp(i,t,e,s){return{x:i.x+e*(t.x-i.x),y:s==="middle"?e<.5?i.y:t.y:s==="after"?e<1?i.y:t.y:e>0?t.y:i.y}}function ap(i,t,e,s){const o={x:i.cp2x,y:i.cp2y},a={x:t.cp1x,y:t.cp1y},l=je(i,o,e),h=je(o,a,e),u=je(a,t,e),d=je(l,h,e),p=je(h,u,e);return je(d,p,e)}const lp=function(i,t){return{x(e){return i+i+t-e},setWidth(e){t=e},textAlign(e){return e==="center"?e:e==="right"?"left":"right"},xPlus(e,s){return e-s},leftForLtr(e,s){return e-s}}},hp=function(){return{x(i){return i},setWidth(i){},textAlign(i){return i},xPlus(i,t){return i+t},leftForLtr(i,t){return i}}};function li(i,t,e){return i?lp(t,e):hp()}function vh(i,t){let e,s;(t==="ltr"||t==="rtl")&&(e=i.canvas.style,s=[e.getPropertyValue("direction"),e.getPropertyPriority("direction")],e.setProperty("direction",t,"important"),i.prevTextDirection=s)}function bh(i,t){t!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",t[0],t[1]))}function xh(i){return i==="angle"?{between:Yi,compare:cf,normalize:Dt}:{between:pe,compare:(t,e)=>t-e,normalize:t=>t}}function Ea({start:i,end:t,count:e,loop:s,style:o}){return{start:i%e,end:t%e,loop:s&&(t-i+1)%e===0,style:o}}function cp(i,t,e){const{property:s,start:o,end:a}=e,{between:l,normalize:h}=xh(s),u=t.length;let{start:d,end:p,loop:g}=i,_,v;if(g){for(d+=u,p+=u,_=0,v=u;_u(o,E,k)&&h(o,E)!==0,T=()=>h(a,k)===0||u(a,E,k),D=()=>b||A(),R=()=>!b||T();for(let B=p,N=p;B<=g;++B)C=t[B%l],!C.skip&&(k=d(C[s]),k!==E&&(b=u(k,o,a),P===null&&D()&&(P=h(k,o)===0?B:N),P!==null&&R()&&(x.push(Ea({start:P,end:B,loop:_,count:l,style:v})),P=null),N=B,E=k));return P!==null&&x.push(Ea({start:P,end:g,loop:_,count:l,style:v})),x}function Ph(i,t){const e=[],s=i.segments;for(let o=0;oo&&i[a%t].skip;)a--;return a%=t,{start:o,end:a}}function dp(i,t,e,s){const o=i.length,a=[];let l=t,h=i[t],u;for(u=t+1;u<=e;++u){const d=i[u%o];d.skip||d.stop?h.skip||(s=!1,a.push({start:t%o,end:(u-1)%o,loop:s}),t=l=d.stop?u:null):(l=u,h.skip&&(t=u)),h=d}return l!==null&&a.push({start:t%o,end:l%o,loop:s}),a}function fp(i,t){const e=i.points,s=i.options.spanGaps,o=e.length;if(!o)return[];const a=!!i._loop,{start:l,end:h}=up(e,o,a,s);if(s===!0)return Aa(i,[{start:l,end:h,loop:a}],e,t);const u=hh({chart:t,initial:e.initial,numSteps:l,currentStep:Math.min(s-e.start,l)}))}_refresh(){this._request||(this._running=!0,this._request=rh.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let e=0;this._charts.forEach((s,o)=>{if(!s.running||!s.items.length)return;const a=s.items;let l=a.length-1,h=!1,u;for(;l>=0;--l)u=a[l],u._active?(u._total>s.duration&&(s.duration=u._total),u.tick(t),h=!0):(a[l]=a[a.length-1],a.pop());h&&(o.draw(),this._notify(o,s,t,"progress")),a.length||(s.running=!1,this._notify(o,s,t,"complete"),s.initial=!1),e+=a.length}),this._lastDate=t,e===0&&(this._running=!1)}_getAnims(t){const e=this._charts;let s=e.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,s)),s}listen(t,e,s){this._getAnims(t).listeners[e].push(s)}add(t,e){!e||!e.length||this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);e&&(e.running=!0,e.start=Date.now(),e.duration=e.items.reduce((s,o)=>Math.max(s,o._duration),0),this._refresh())}running(t){if(!this._running)return!1;const e=this._charts.get(t);return!(!e||!e.running||!e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const s=e.items;let o=s.length-1;for(;o>=0;--o)s[o].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var ue=new _p;const Da="transparent",yp={boolean(i,t,e){return e>.5?t:i},color(i,t,e){const s=Pa(i||Da),o=s.valid&&Pa(t||Da);return o&&o.valid?o.mix(s,e).hexString():t},number(i,t,e){return i+(t-i)*e}};class vp{constructor(t,e,s,o){const a=e[s];o=zi([t.to,o,a,t.from]);const l=zi([t.from,a,o]);this._active=!0,this._fn=t.fn||yp[t.type||typeof l],this._easing=Vi[t.easing]||Vi.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=e,this._prop=s,this._from=l,this._to=o,this._promises=void 0}active(){return this._active}update(t,e,s){if(this._active){this._notify(!1);const o=this._target[this._prop],a=s-this._start,l=this._duration-a;this._start=s,this._duration=Math.floor(Math.max(l,t.duration)),this._total+=a,this._loop=!!t.loop,this._to=zi([t.to,e,o,t.from]),this._from=zi([t.from,o,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,s=this._duration,o=this._prop,a=this._from,l=this._loop,h=this._to;let u;if(this._active=a!==h&&(l||e1?2-u:u,u=this._easing(Math.min(1,Math.max(0,u))),this._target[o]=this._fn(a,h,u)}wait(){const t=this._promises||(this._promises=[]);return new Promise((e,s)=>{t.push({res:e,rej:s})})}_notify(t){const e=t?"res":"rej",s=this._promises||[];for(let o=0;o{const a=t[o];if(!et(a))return;const l={};for(const h of e)l[h]=a[h];(mt(a.properties)&&a.properties||[o]).forEach(h=>{(h===o||!s.has(h))&&s.set(h,l)})})}_animateOptions(t,e){const s=e.options,o=xp(t,s);if(!o)return[];const a=this._createAnimations(o,s);return s.$shared&&bp(t.options.$animations,s).then(()=>{t.options=s},()=>{}),a}_createAnimations(t,e){const s=this._properties,o=[],a=t.$animations||(t.$animations={}),l=Object.keys(e),h=Date.now();let u;for(u=l.length-1;u>=0;--u){const d=l[u];if(d.charAt(0)==="$")continue;if(d==="options"){o.push(...this._animateOptions(t,e));continue}const p=e[d];let g=a[d];const _=s.get(d);if(g)if(_&&g.active()){g.update(_,p,h);continue}else g.cancel();if(!_||!_.duration){t[d]=p;continue}a[d]=g=new vp(_,t,d,p),o.push(g)}return o}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const s=this._createAnimations(t,e);if(s.length)return ue.add(this._chart,s),!0}}function bp(i,t){const e=[],s=Object.keys(t);for(let o=0;o0||!e&&a<0)return o.index}return null}function za(i,t){const{chart:e,_cachedMeta:s}=i,o=e._stacks||(e._stacks={}),{iScale:a,vScale:l,index:h}=s,u=a.axis,d=l.axis,p=Sp(a,l,s),g=t.length;let _;for(let v=0;ve[s].axis===t).shift()}function Cp(i,t){return Oe(i,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Tp(i,t,e){return Oe(i,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:e,index:t,mode:"default",type:"data"})}function Ti(i,t){const e=i.controller.index,s=i.vScale&&i.vScale.axis;if(s){t=t||i._parsed;for(const o of t){const a=o._stacks;if(!a||a[s]===void 0||a[s][e]===void 0)return;delete a[s][e],a[s]._visualValues!==void 0&&a[s]._visualValues[e]!==void 0&&delete a[s]._visualValues[e]}}}const Ks=i=>i==="reset"||i==="none",Na=(i,t)=>t?i:Object.assign({},i),Ep=(i,t,e)=>i&&!t.hidden&&t._stacked&&{keys:Mh(e,!0),values:null};class De{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t,this._ctx=t.ctx,this.index=e,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=Ys(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&Ti(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,s=this.getDataset(),o=(g,_,v,x)=>g==="x"?_:g==="r"?x:v,a=e.xAxisID=U(s.xAxisID,Xs(t,"x")),l=e.yAxisID=U(s.yAxisID,Xs(t,"y")),h=e.rAxisID=U(s.rAxisID,Xs(t,"r")),u=e.indexAxis,d=e.iAxisID=o(u,a,l,h),p=e.vAxisID=o(u,l,a,h);e.xScale=this.getScaleForId(a),e.yScale=this.getScaleForId(l),e.rScale=this.getScaleForId(h),e.iScale=this.getScaleForId(d),e.vScale=this.getScaleForId(p)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&ba(this._data,this),t._stacked&&Ti(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),s=this._data;if(et(e)){const o=this._cachedMeta;this._data=kp(e,o)}else if(s!==e){if(s){ba(s,this);const o=this._cachedMeta;Ti(o),o._parsed=[]}e&&Object.isExtensible(e)&&pf(e,this),this._syncList=[],this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta,s=this.getDataset();let o=!1;this._dataCheck();const a=e._stacked;e._stacked=Ys(e.vScale,e),e.stack!==s.stack&&(o=!0,Ti(e),e.stack=s.stack),this._resyncElements(t),(o||a!==e._stacked)&&(za(this,e._parsed),e._stacked=Ys(e.vScale,e))}configure(){const t=this.chart.config,e=t.datasetScopeKeys(this._type),s=t.getOptionScopes(this.getDataset(),e,!0);this.options=t.createResolver(s,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:s,_data:o}=this,{iScale:a,_stacked:l}=s,h=a.axis;let u=t===0&&e===o.length?!0:s._sorted,d=t>0&&s._parsed[t-1],p,g,_;if(this._parsing===!1)s._parsed=o,s._sorted=!0,_=o;else{mt(o[t])?_=this.parseArrayData(s,o,t,e):et(o[t])?_=this.parseObjectData(s,o,t,e):_=this.parsePrimitiveData(s,o,t,e);const v=()=>g[h]===null||d&&g[h]b||g=0;--_)if(!x()){this.updateRangeFromParsed(d,t,v,u);break}}return d}getAllParsedValues(t){const e=this._cachedMeta._parsed,s=[];let o,a,l;for(o=0,a=e.length;o=0&&tthis.getContext(s,o,e),b=d.resolveNamedOptions(_,v,x,g);return b.$shared&&(b.$shared=u,a[l]=Object.freeze(Na(b,u))),b}_resolveAnimations(t,e,s){const o=this.chart,a=this._cachedDataOpts,l=`animation-${e}`,h=a[l];if(h)return h;let u;if(o.options.animation!==!1){const p=this.chart.config,g=p.datasetAnimationScopeKeys(this._type,e),_=p.getOptionScopes(this.getDataset(),g);u=p.createResolver(_,this.getContext(t,s,e))}const d=new Sh(o,u&&u.animations);return u&&u._cacheable&&(a[l]=Object.freeze(d)),d}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Ks(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const s=this.resolveDataElementOptions(t,e),o=this._sharedOptions,a=this.getSharedOptions(s),l=this.includeOptions(e,a)||a!==o;return this.updateSharedOptions(a,e,s),{sharedOptions:a,includeOptions:l}}updateElement(t,e,s,o){Ks(o)?Object.assign(t,s):this._resolveAnimations(e,o).update(t,s)}updateSharedOptions(t,e,s){t&&!Ks(e)&&this._resolveAnimations(void 0,e).update(t,s)}_setStyle(t,e,s,o){t.active=o;const a=this.getStyle(e,o);this._resolveAnimations(e,s,o).update(t,{options:!o&&this.getSharedOptions(a)||a})}removeHoverStyle(t,e,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,e,s){this._setStyle(t,s,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const e=this._data,s=this._cachedMeta.data;for(const[h,u,d]of this._syncList)this[h](u,d);this._syncList=[];const o=s.length,a=e.length,l=Math.min(a,o);l&&this.parse(0,l),a>o?this._insertElements(o,a-o,t):a{for(d.length+=e,h=d.length-1;h>=l;h--)d[h]=d[h-e]};for(u(a),h=t;ho-a))}return i._cache.$bar}function Op(i){const t=i.iScale,e=Ap(t,i.type);let s=t._length,o,a,l,h;const u=()=>{l===32767||l===-32768||(Ui(h)&&(s=Math.min(s,Math.abs(l-h)||s)),h=l)};for(o=0,a=e.length;o0?o[i-1]:null,h=iMath.abs(h)&&(u=h,d=l),t[e.axis]=d,t._custom={barStart:u,barEnd:d,start:o,end:a,min:l,max:h}}function Lh(i,t,e,s){return mt(i)?Rp(i,t,e,s):t[e.axis]=e.parse(i,s),t}function Fa(i,t,e,s){const o=i.iScale,a=i.vScale,l=o.getLabels(),h=o===a,u=[];let d,p,g,_;for(d=e,p=e+s;d=e?1:-1)}function zp(i){let t,e,s,o,a;return i.horizontal?(t=i.base>i.x,e="left",s="right"):(t=i.basep.controller.options.grouped),a=s.options.stacked,l=[],h=this._cachedMeta.controller.getParsed(e),u=h&&h[s.axis],d=p=>{const g=p._parsed.find(v=>v[s.axis]===u),_=g&&g[p.vScale.axis];if(Q(_)||isNaN(_))return!0};for(const p of o)if(!(e!==void 0&&d(p))&&((a===!1||l.indexOf(p.stack)===-1||a===void 0&&p.stack===void 0)&&l.push(p.stack),p.index===t))break;return l.length||l.push(void 0),l}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,e=this.chart.options.indexAxis;return Object.keys(t).filter(s=>t[s].axis===e).shift()}_getAxis(){const t={},e=this.getFirstScaleIdForIndexAxis();for(const s of this.chart.data.datasets)t[U(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,e)]=!0;return Object.keys(t)}_getStackIndex(t,e,s){const o=this._getStacks(t,s),a=e!==void 0?o.indexOf(e):-1;return a===-1?o.length-1:a}_getRuler(){const t=this.options,e=this._cachedMeta,s=e.iScale,o=[];let a,l;for(a=0,l=e.data.length;a=0;--s)e=Math.max(e,t[s].size(this.resolveDataElementOptions(s))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,s=this.chart.data.labels||[],{xScale:o,yScale:a}=e,l=this.getParsed(t),h=o.getLabelForValue(l.x),u=a.getLabelForValue(l.y),d=l._custom;return{label:s[t]||"",value:"("+h+", "+u+(d?", "+d:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,s,o){const a=o==="reset",{iScale:l,vScale:h}=this._cachedMeta,{sharedOptions:u,includeOptions:d}=this._getSharedOptions(e,o),p=l.axis,g=h.axis;for(let _=e;_Yi(E,h,u,!0)?1:Math.max(A,A*e,T,T*e),x=(E,A,T)=>Yi(E,h,u,!0)?-1:Math.min(A,A*e,T,T*e),b=v(0,d,g),P=v(Pt,p,_),k=x(lt,d,g),C=x(lt+Pt,p,_);s=(b-k)/2,o=(P-C)/2,a=-(b+k)/2,l=-(P+C)/2}return{ratioX:s,ratioY:o,offsetX:a,offsetY:l}}class jo extends De{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data,{labels:{pointStyle:s,textAlign:o,color:a,useBorderRadius:l,borderRadius:h}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map((u,d)=>{const g=t.getDatasetMeta(0).controller.getStyle(d);return{text:u,fillStyle:g.backgroundColor,fontColor:a,hidden:!t.getDataVisibility(d),lineDash:g.borderDash,lineDashOffset:g.borderDashOffset,lineJoin:g.borderJoinStyle,lineWidth:g.borderWidth,strokeStyle:g.borderColor,textAlign:o,pointStyle:s,borderRadius:l&&(h||g.borderRadius),index:d}}):[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}}};constructor(t,e){super(t,e),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,e){const s=this.getDataset().data,o=this._cachedMeta;if(this._parsing===!1)o._parsed=s;else{let a=u=>+s[u];if(et(s[t])){const{key:u="value"}=this._parsing;a=d=>+Ce(s[d],u)}let l,h;for(l=t,h=t+e;l0&&!isNaN(t)?pt*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,s=this.chart,o=s.data.labels||[],a=Qi(e._parsed[t],s.options.locale);return{label:o[t]||"",value:a}}getMaxBorderWidth(t){let e=0;const s=this.chart;let o,a,l,h,u;if(!t){for(o=0,a=s.data.datasets.length;o0&&this.getParsed(e-1);for(let T=0;T=C){R.skip=!0;continue}const B=this.getParsed(T),N=Q(B[v]),$=R[_]=l.getPixelForValue(B[_],T),W=R[v]=a||N?h.getBasePixel():h.getPixelForValue(u?this.applyStack(h,B,u):B[v],T);R.skip=isNaN($)||isNaN(W)||N,R.stop=T>0&&Math.abs(B[_]-A[_])>P,b&&(R.parsed=B,R.raw=d.data[T]),g&&(R.options=p||this.resolveDataElementOptions(T,D.active?"active":o)),k||this.updateElement(D,T,R,o),A=B}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,s=e.options&&e.options.borderWidth||0,o=t.data||[];if(!o.length)return s;const a=o[0].size(this.resolveDataElementOptions(0)),l=o[o.length-1].size(this.resolveDataElementOptions(o.length-1));return Math.max(s,a,l)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class Ch extends De{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:s,color:o}}=t.legend.options;return e.labels.map((a,l)=>{const u=t.getDatasetMeta(0).controller.getStyle(l);return{text:a,fillStyle:u.backgroundColor,strokeStyle:u.borderColor,fontColor:o,lineWidth:u.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(l),index:l}})}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,e){super(t,e),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta,s=this.chart,o=s.data.labels||[],a=Qi(e._parsed[t].r,s.options.locale);return{label:o[t]||"",value:a}}parseObjectData(t,e,s,o){return _h.bind(this)(t,e,s,o)}update(t){const e=this._cachedMeta.data;this._updateRadius(),this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta,e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((s,o)=>{const a=this.getParsed(o).r;!isNaN(a)&&this.chart.getDataVisibility(o)&&(ae.max&&(e.max=a))}),e}_updateRadius(){const t=this.chart,e=t.chartArea,s=t.options,o=Math.min(e.right-e.left,e.bottom-e.top),a=Math.max(o/2,0),l=Math.max(s.cutoutPercentage?a/100*s.cutoutPercentage:1,0),h=(a-l)/t.getVisibleDatasetCount();this.outerRadius=a-h*this.index,this.innerRadius=this.outerRadius-h}updateElements(t,e,s,o){const a=o==="reset",l=this.chart,u=l.options.animation,d=this._cachedMeta.rScale,p=d.xCenter,g=d.yCenter,_=d.getIndexAngle(0)-.5*lt;let v=_,x;const b=360/this.countVisibleElements();for(x=0;x{!isNaN(this.getParsed(o).r)&&this.chart.getDataVisibility(o)&&e++}),e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?Xt(this.resolveDataElementOptions(t,e).angle||s):0}}class qp extends jo{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class $p extends De{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale,s=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(s[e.axis])}}parseObjectData(t,e,s,o){return _h.bind(this)(t,e,s,o)}update(t){const e=this._cachedMeta,s=e.dataset,o=e.data||[],a=e.iScale.getLabels();if(s.points=o,t!=="resize"){const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0);const h={_loop:!0,_fullLoop:a.length===o.length,options:l};this.updateElement(s,void 0,h,t)}this.updateElements(o,0,o.length,t)}updateElements(t,e,s,o){const a=this._cachedMeta.rScale,l=o==="reset";for(let h=e;h0&&this.getParsed(e-1);for(let A=e;A0&&Math.abs(D[v]-E[v])>k,P&&(R.parsed=D,R.raw=d.data[A]),_&&(R.options=g||this.resolveDataElementOptions(A,T.active?"active":o)),C||this.updateElement(T,A,R,o),E=D}this.updateSharedOptions(g,o,p)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let h=0;for(let u=e.length-1;u>=0;--u)h=Math.max(h,e[u].size(this.resolveDataElementOptions(u))/2);return h>0&&h}const s=t.dataset,o=s.options&&s.options.borderWidth||0;if(!e.length)return o;const a=e[0].size(this.resolveDataElementOptions(0)),l=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(o,a,l)/2}}var Yp=Object.freeze({__proto__:null,BarController:Hp,BubbleController:Zp,DoughnutController:jo,LineController:jp,PieController:qp,PolarAreaController:Ch,RadarController:$p,ScatterController:Up});function He(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class qo{static override(t){Object.assign(qo.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return He()}parse(){return He()}format(){return He()}add(){return He()}diff(){return He()}startOf(){return He()}endOf(){return He()}}var Xp={_date:qo};function Kp(i,t,e,s){const{controller:o,data:a,_sorted:l}=i,h=o._cachedMeta.iScale,u=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null;if(h&&t===h.axis&&t!=="r"&&l&&a.length){const d=h._reversePixels?df:me;if(s){if(o._sharedOptions){const p=a[0],g=typeof p.getRange=="function"&&p.getRange(t);if(g){const _=d(a,t,e-g),v=d(a,t,e+g);return{lo:_.lo,hi:v.hi}}}}else{const p=d(a,t,e);if(u){const{vScale:g}=o._cachedMeta,{_parsed:_}=i,v=_.slice(0,p.lo+1).reverse().findIndex(b=>!Q(b[g.axis]));p.lo-=Math.max(0,v);const x=_.slice(p.hi).findIndex(b=>!Q(b[g.axis]));p.hi+=Math.max(0,x)}return p}}return{lo:0,hi:a.length-1}}function ss(i,t,e,s,o){const a=i.getSortedVisibleDatasetMetas(),l=e[t];for(let h=0,u=a.length;h{u[l]&&u[l](t[e],o)&&(a.push({element:u,datasetIndex:d,index:p}),h=h||u.inRange(t.x,t.y,o))}),s&&!h?[]:a}var tm={modes:{index(i,t,e,s){const o=Ve(t,i),a=e.axis||"x",l=e.includeInvisible||!1,h=e.intersect?Js(i,o,a,s,l):Qs(i,o,a,!1,s,l),u=[];return h.length?(i.getSortedVisibleDatasetMetas().forEach(d=>{const p=h[0].index,g=d.data[p];g&&!g.skip&&u.push({element:g,datasetIndex:d.index,index:p})}),u):[]},dataset(i,t,e,s){const o=Ve(t,i),a=e.axis||"xy",l=e.includeInvisible||!1;let h=e.intersect?Js(i,o,a,s,l):Qs(i,o,a,!1,s,l);if(h.length>0){const u=h[0].datasetIndex,d=i.getDatasetMeta(u).data;h=[];for(let p=0;pe.pos===t)}function Va(i,t){return i.filter(e=>Th.indexOf(e.pos)===-1&&e.box.axis===t)}function Ai(i,t){return i.sort((e,s)=>{const o=t?s:e,a=t?e:s;return o.weight===a.weight?o.index-a.index:o.weight-a.weight})}function em(i){const t=[];let e,s,o,a,l,h;for(e=0,s=(i||[]).length;ed.box.fullSize),!0),s=Ai(Ei(t,"left"),!0),o=Ai(Ei(t,"right")),a=Ai(Ei(t,"top"),!0),l=Ai(Ei(t,"bottom")),h=Va(t,"x"),u=Va(t,"y");return{fullSize:e,leftAndTop:s.concat(a),rightAndBottom:o.concat(u).concat(l).concat(h),chartArea:Ei(t,"chartArea"),vertical:s.concat(o).concat(u),horizontal:a.concat(l).concat(h)}}function ja(i,t,e,s){return Math.max(i[e],t[e])+Math.max(i[s],t[s])}function Eh(i,t){i.top=Math.max(i.top,t.top),i.left=Math.max(i.left,t.left),i.bottom=Math.max(i.bottom,t.bottom),i.right=Math.max(i.right,t.right)}function om(i,t,e,s){const{pos:o,box:a}=e,l=i.maxPadding;if(!et(o)){e.size&&(i[o]-=e.size);const g=s[e.stack]||{size:0,count:1};g.size=Math.max(g.size,e.horizontal?a.height:a.width),e.size=g.size/g.count,i[o]+=e.size}a.getPadding&&Eh(l,a.getPadding());const h=Math.max(0,t.outerWidth-ja(l,i,"left","right")),u=Math.max(0,t.outerHeight-ja(l,i,"top","bottom")),d=h!==i.w,p=u!==i.h;return i.w=h,i.h=u,e.horizontal?{same:d,other:p}:{same:p,other:d}}function rm(i){const t=i.maxPadding;function e(s){const o=Math.max(t[s]-i[s],0);return i[s]+=o,o}i.y+=e("top"),i.x+=e("left"),e("right"),e("bottom")}function am(i,t){const e=t.maxPadding;function s(o){const a={left:0,top:0,right:0,bottom:0};return o.forEach(l=>{a[l]=Math.max(t[l],e[l])}),a}return s(i?["left","right"]:["top","bottom"])}function Ni(i,t,e,s){const o=[];let a,l,h,u,d,p;for(a=0,l=i.length,d=0;a{typeof b.beforeLayout=="function"&&b.beforeLayout()});const p=u.reduce((b,P)=>P.box.options&&P.box.options.display===!1?b:b+1,0)||1,g=Object.freeze({outerWidth:t,outerHeight:e,padding:o,availableWidth:a,availableHeight:l,vBoxMaxWidth:a/2/p,hBoxMaxHeight:l/2}),_=Object.assign({},o);Eh(_,Rt(s));const v=Object.assign({maxPadding:_,w:a,h:l,x:o.left,y:o.top},o),x=nm(u.concat(d),g);Ni(h.fullSize,v,g,x),Ni(u,v,g,x),Ni(d,v,g,x)&&Ni(u,v,g,x),rm(v),qa(h.leftAndTop,v,g,x),v.x+=v.w,v.y+=v.h,qa(h.rightAndBottom,v,g,x),i.chartArea={left:v.left,top:v.top,right:v.left+v.w,bottom:v.top+v.h,height:v.h,width:v.w},ht(h.chartArea,b=>{const P=b.box;Object.assign(P,i.chartArea),P.update(v.w,v.h,{left:0,top:0,right:0,bottom:0})})}};class Ah{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,s){}removeEventListener(t,e,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,s,o){return e=Math.max(0,e||t.width),s=s||t.height,{width:e,height:Math.max(0,o?Math.floor(e/o):s)}}isAttached(t){return!0}updateConfig(t){}}class lm extends Ah{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const Fn="$chartjs",hm={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},$a=i=>i===null||i==="";function cm(i,t){const e=i.style,s=i.getAttribute("height"),o=i.getAttribute("width");if(i[Fn]={initial:{height:s,width:o,style:{display:e.display,height:e.height,width:e.width}}},e.display=e.display||"block",e.boxSizing=e.boxSizing||"border-box",$a(o)){const a=Ta(i,"width");a!==void 0&&(i.width=a)}if($a(s))if(i.style.height==="")i.height=i.width/(t||2);else{const a=Ta(i,"height");a!==void 0&&(i.height=a)}return i}const Oh=op?{passive:!0}:!1;function um(i,t,e){i&&i.addEventListener(t,e,Oh)}function dm(i,t,e){i&&i.canvas&&i.canvas.removeEventListener(t,e,Oh)}function fm(i,t){const e=hm[i.type]||i.type,{x:s,y:o}=Ve(i,t);return{type:e,chart:t,native:i,x:s!==void 0?s:null,y:o!==void 0?o:null}}function Yn(i,t){for(const e of i)if(e===t||e.contains(t))return!0}function pm(i,t,e){const s=i.canvas,o=new MutationObserver(a=>{let l=!1;for(const h of a)l=l||Yn(h.addedNodes,s),l=l&&!Yn(h.removedNodes,s);l&&e()});return o.observe(document,{childList:!0,subtree:!0}),o}function mm(i,t,e){const s=i.canvas,o=new MutationObserver(a=>{let l=!1;for(const h of a)l=l||Yn(h.removedNodes,s),l=l&&!Yn(h.addedNodes,s);l&&e()});return o.observe(document,{childList:!0,subtree:!0}),o}const Ki=new Map;let Ua=0;function Dh(){const i=window.devicePixelRatio;i!==Ua&&(Ua=i,Ki.forEach((t,e)=>{e.currentDevicePixelRatio!==i&&t()}))}function gm(i,t){Ki.size||window.addEventListener("resize",Dh),Ki.set(i,t)}function _m(i){Ki.delete(i),Ki.size||window.removeEventListener("resize",Dh)}function ym(i,t,e){const s=i.canvas,o=s&&Vo(s);if(!o)return;const a=ah((h,u)=>{const d=o.clientWidth;e(h,u),d{const u=h[0],d=u.contentRect.width,p=u.contentRect.height;d===0&&p===0||a(d,p)});return l.observe(o),gm(i,a),l}function to(i,t,e){e&&e.disconnect(),t==="resize"&&_m(i)}function vm(i,t,e){const s=i.canvas,o=ah(a=>{i.ctx!==null&&e(fm(a,i))},i);return um(s,t,o),o}class bm extends Ah{acquireContext(t,e){const s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?(cm(t,e),s):null}releaseContext(t){const e=t.canvas;if(!e[Fn])return!1;const s=e[Fn].initial;["height","width"].forEach(a=>{const l=s[a];Q(l)?e.removeAttribute(a):e.setAttribute(a,l)});const o=s.style||{};return Object.keys(o).forEach(a=>{e.style[a]=o[a]}),e.width=e.width,delete e[Fn],!0}addEventListener(t,e,s){this.removeEventListener(t,e);const o=t.$proxies||(t.$proxies={}),l={attach:pm,detach:mm,resize:ym}[e]||vm;o[e]=l(t,e,s)}removeEventListener(t,e){const s=t.$proxies||(t.$proxies={}),o=s[e];if(!o)return;({attach:to,detach:to,resize:to}[e]||dm)(t,e,o),s[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,o){return sp(t,e,s,o)}isAttached(t){const e=t&&Vo(t);return!!(e&&e.isConnected)}}function xm(i){return!Zo()||typeof OffscreenCanvas<"u"&&i instanceof OffscreenCanvas?lm:bm}let _e=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:e,y:s}=this.getProps(["x","y"],t);return{x:e,y:s}}hasValue(){return ci(this.x)&&ci(this.y)}getProps(t,e){const s=this.$animations;if(!e||!s)return this;const o={};return t.forEach(a=>{o[a]=s[a]&&s[a].active()?s[a]._to:this[a]}),o}};function wm(i,t){const e=i.options.ticks,s=Pm(i),o=Math.min(e.maxTicksLimit||s,s),a=e.major.enabled?Sm(t):[],l=a.length,h=a[0],u=a[l-1],d=[];if(l>o)return Mm(t,d,a,l/o),d;const p=km(a,t,o);if(l>0){let g,_;const v=l>1?Math.round((u-h)/(l-1)):null;for(Tn(t,d,p,Q(v)?0:h-v,h),g=0,_=l-1;g<_;g++)Tn(t,d,p,a[g],a[g+1]);return Tn(t,d,p,u,Q(v)?t.length:u+v),d}return Tn(t,d,p),d}function Pm(i){const t=i.options.offset,e=i._tickSize(),s=i._length/e+(t?0:1),o=i._maxLength/e;return Math.floor(Math.min(s,o))}function km(i,t,e){const s=Lm(i),o=t.length/e;if(!s)return Math.max(o,1);const a=af(s);for(let l=0,h=a.length-1;lo)return u}return Math.max(o,1)}function Sm(i){const t=[];let e,s;for(e=0,s=i.length;ei==="left"?"right":i==="right"?"left":i,Ya=(i,t,e)=>t==="top"||t==="left"?i[t]+e:i[t]-e,Xa=(i,t)=>Math.min(t||i,i);function Ka(i,t){const e=[],s=i.length/t,o=i.length;let a=0;for(;al+h)))return u}function Em(i,t){ht(i,e=>{const s=e.gc,o=s.length/2;let a;if(o>t){for(a=0;as?s:e,s=o&&e>s?e:s,{min:Wt(e,Wt(s,e)),max:Wt(s,Wt(e,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){ft(this.options.beforeUpdate,[this])}update(t,e,s){const{beginAtZero:o,grace:a,ticks:l}=this.options,h=l.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Bf(this,a,o),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const u=h=a||s<=1||!this.isHorizontal()){this.labelRotation=o;return}const p=this._getLabelSizes(),g=p.widest.width,_=p.highest.height,v=Et(this.chart.width-g,0,this.maxWidth);h=t.offset?this.maxWidth/s:v/(s-1),g+6>h&&(h=v/(s-(t.offset?.5:1)),u=this.maxHeight-Oi(t.grid)-e.padding-Ga(t.title,this.chart.options.font),d=Math.sqrt(g*g+_*_),l=Io(Math.min(Math.asin(Et((p.highest.height+6)/h,-1,1)),Math.asin(Et(u/d,-1,1))-Math.asin(Et(_/d,-1,1)))),l=Math.max(o,Math.min(a,l))),this.labelRotation=l}afterCalculateLabelRotation(){ft(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){ft(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:s,title:o,grid:a}}=this,l=this._isVisible(),h=this.isHorizontal();if(l){const u=Ga(o,e.options.font);if(h?(t.width=this.maxWidth,t.height=Oi(a)+u):(t.height=this.maxHeight,t.width=Oi(a)+u),s.display&&this.ticks.length){const{first:d,last:p,widest:g,highest:_}=this._getLabelSizes(),v=s.padding*2,x=Xt(this.labelRotation),b=Math.cos(x),P=Math.sin(x);if(h){const k=s.mirror?0:P*g.width+b*_.height;t.height=Math.min(this.maxHeight,t.height+k+v)}else{const k=s.mirror?0:b*g.width+P*_.height;t.width=Math.min(this.maxWidth,t.width+k+v)}this._calculatePadding(d,p,P,b)}}this._handleMargins(),h?(this.width=this._length=e.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=e.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,e,s,o){const{ticks:{align:a,padding:l},position:h}=this.options,u=this.labelRotation!==0,d=h!=="top"&&this.axis==="x";if(this.isHorizontal()){const p=this.getPixelForTick(0)-this.left,g=this.right-this.getPixelForTick(this.ticks.length-1);let _=0,v=0;u?d?(_=o*t.width,v=s*e.height):(_=s*t.height,v=o*e.width):a==="start"?v=e.width:a==="end"?_=t.width:a!=="inner"&&(_=t.width/2,v=e.width/2),this.paddingLeft=Math.max((_-p+l)*this.width/(this.width-p),0),this.paddingRight=Math.max((v-g+l)*this.width/(this.width-g),0)}else{let p=e.height/2,g=t.height/2;a==="start"?(p=0,g=t.height):a==="end"&&(p=e.height,g=0),this.paddingTop=p+l,this.paddingBottom=g+l}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){ft(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let e,s;for(e=0,s=t.length;e({width:l[N]||0,height:h[N]||0});return{first:B(0),last:B(e-1),widest:B(D),highest:B(R),widths:l,heights:h}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return uf(this._alignToPixels?We(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&th*o?h/s:u/o:u*o0}_computeGridLineItems(t){const e=this.axis,s=this.chart,o=this.options,{grid:a,position:l,border:h}=o,u=a.offset,d=this.isHorizontal(),g=this.ticks.length+(u?1:0),_=Oi(a),v=[],x=h.setContext(this.getContext()),b=x.display?x.width:0,P=b/2,k=function(K){return We(s,K,b)};let C,E,A,T,D,R,B,N,$,W,j,vt;if(l==="top")C=k(this.bottom),R=this.bottom-_,N=C-P,W=k(t.top)+P,vt=t.bottom;else if(l==="bottom")C=k(this.top),W=t.top,vt=k(t.bottom)-P,R=C+P,N=this.top+_;else if(l==="left")C=k(this.right),D=this.right-_,B=C-P,$=k(t.left)+P,j=t.right;else if(l==="right")C=k(this.left),$=t.left,j=k(t.right)-P,D=C+P,B=this.left+_;else if(e==="x"){if(l==="center")C=k((t.top+t.bottom)/2+.5);else if(et(l)){const K=Object.keys(l)[0],tt=l[K];C=k(this.chart.scales[K].getPixelForValue(tt))}W=t.top,vt=t.bottom,R=C+P,N=R+_}else if(e==="y"){if(l==="center")C=k((t.left+t.right)/2);else if(et(l)){const K=Object.keys(l)[0],tt=l[K];C=k(this.chart.scales[K].getPixelForValue(tt))}D=C-P,B=D-_,$=t.left,j=t.right}const ut=U(o.ticks.maxTicksLimit,g),rt=Math.max(1,Math.ceil(g/ut));for(E=0;E0&&(Y-=ct/2);break}it={left:Y,top:st,width:ct+xt.width,height:kt+xt.height,color:rt.backdropColor}}P.push({label:A,font:N,textOffset:j,options:{rotation:b,color:tt,strokeColor:F,strokeWidth:_t,textAlign:Z,textBaseline:vt,translation:[T,D],backdrop:it}})}return P}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-Xt(this.labelRotation))return t==="top"?"left":"right";let o="center";return e.align==="start"?o="left":e.align==="end"?o="right":e.align==="inner"&&(o="inner"),o}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:s,mirror:o,padding:a}}=this.options,l=this._getLabelSizes(),h=t+a,u=l.widest.width;let d,p;return e==="left"?o?(p=this.right+a,s==="near"?d="left":s==="center"?(d="center",p+=u/2):(d="right",p+=u)):(p=this.right-h,s==="near"?d="right":s==="center"?(d="center",p-=u/2):(d="left",p=this.left)):e==="right"?o?(p=this.left+a,s==="near"?d="right":s==="center"?(d="center",p-=u/2):(d="left",p-=u)):(p=this.left+h,s==="near"?d="left":s==="center"?(d="center",p+=u/2):(d="right",p=this.right)):d="right",{textAlign:d,x:p}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;if(e==="left"||e==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(e==="top"||e==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:s,top:o,width:a,height:l}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(s,o,a,l),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const o=this.ticks.findIndex(a=>a.value===t);return o>=0?e.setContext(this.getContext(o)).lineWidth:0}drawGrid(t){const e=this.options.grid,s=this.ctx,o=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let a,l;const h=(u,d,p)=>{!p.width||!p.color||(s.save(),s.lineWidth=p.width,s.strokeStyle=p.color,s.setLineDash(p.borderDash||[]),s.lineDashOffset=p.borderDashOffset,s.beginPath(),s.moveTo(u.x,u.y),s.lineTo(d.x,d.y),s.stroke(),s.restore())};if(e.display)for(a=0,l=o.length;a{this.draw(a)}}]:[{z:s,draw:a=>{this.drawBackground(),this.drawGrid(a),this.drawTitle()}},{z:o,draw:()=>{this.drawBorder()}},{z:e,draw:a=>{this.drawLabels(a)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",o=[];let a,l;for(a=0,l=e.length;a{const s=e.split("."),o=s.pop(),a=[i].concat(s).join("."),l=t[e].split("."),h=l.pop(),u=l.join(".");gt.route(a,o,u,h)})}function zm(i){return"id"in i&&"defaults"in i}class Nm{constructor(){this.controllers=new En(De,"datasets",!0),this.elements=new En(_e,"elements"),this.plugins=new En(Object,"plugins"),this.scales=new En(Xe,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,s){[...e].forEach(o=>{const a=s||this._getRegistryForType(o);s||a.isForType(o)||a===this.plugins&&o.id?this._exec(t,a,o):ht(o,l=>{const h=s||this._getRegistryForType(l);this._exec(t,h,l)})})}_exec(t,e,s){const o=Do(t);ft(s["before"+o],[],s),e[t](s),ft(s["after"+o],[],s)}_getRegistryForType(t){for(let e=0;ea.filter(h=>!l.some(u=>h.plugin.id===u.plugin.id));this._notify(o(e,s),t,"stop"),this._notify(o(s,e),t,"start")}}function Wm(i){const t={},e=[],s=Object.keys(ee.plugins.items);for(let a=0;a1&&Ja(i[0].toLowerCase());if(s)return s}throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function Qa(i,t,e){if(e[t+"AxisID"]===i)return{axis:t}}function Um(i,t){if(t.data&&t.data.datasets){const e=t.data.datasets.filter(s=>s.xAxisID===i||s.yAxisID===i);if(e.length)return Qa(i,"x",e[0])||Qa(i,"y",e[0])}return{}}function Ym(i,t){const e=Ue[i.type]||{scales:{}},s=t.scales||{},o=_o(i.type,t),a=Object.create(null);return Object.keys(s).forEach(l=>{const h=s[l];if(!et(h))return console.error(`Invalid scale configuration for scale: ${l}`);if(h._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${l}`);const u=yo(l,h,Um(l,i),gt.scales[h.type]),d=qm(u,o),p=e.scales||{};a[l]=Hi(Object.create(null),[{axis:u},h,p[u],p[d]])}),i.data.datasets.forEach(l=>{const h=l.type||i.type,u=l.indexAxis||_o(h,t),p=(Ue[h]||{}).scales||{};Object.keys(p).forEach(g=>{const _=jm(g,u),v=l[_+"AxisID"]||_;a[v]=a[v]||Object.create(null),Hi(a[v],[{axis:_},s[v],p[g]])})}),Object.keys(a).forEach(l=>{const h=a[l];Hi(h,[gt.scales[h.type],gt.scale])}),a}function Ih(i){const t=i.options||(i.options={});t.plugins=U(t.plugins,{}),t.scales=Ym(i,t)}function Rh(i){return i=i||{},i.datasets=i.datasets||[],i.labels=i.labels||[],i}function Xm(i){return i=i||{},i.data=Rh(i.data),Ih(i),i}const tl=new Map,Bh=new Set;function An(i,t){let e=tl.get(i);return e||(e=t(),tl.set(i,e),Bh.add(e)),e}const Di=(i,t,e)=>{const s=Ce(t,e);s!==void 0&&i.add(s)};class Km{constructor(t){this._config=Xm(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Rh(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Ih(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return An(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,e){return An(`${t}.transition.${e}`,()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,e){return An(`${t}-${e}`,()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]])}pluginScopeKeys(t){const e=t.id,s=this.type;return An(`${s}-plugin-${e}`,()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,e){const s=this._scopeCache;let o=s.get(t);return(!o||e)&&(o=new Map,s.set(t,o)),o}getOptionScopes(t,e,s){const{options:o,type:a}=this,l=this._cachedScopes(t,s),h=l.get(e);if(h)return h;const u=new Set;e.forEach(p=>{t&&(u.add(t),p.forEach(g=>Di(u,t,g))),p.forEach(g=>Di(u,o,g)),p.forEach(g=>Di(u,Ue[a]||{},g)),p.forEach(g=>Di(u,gt,g)),p.forEach(g=>Di(u,mo,g))});const d=Array.from(u);return d.length===0&&d.push(Object.create(null)),Bh.has(e)&&l.set(e,d),d}chartOptionScopes(){const{options:t,type:e}=this;return[t,Ue[e]||{},gt.datasets[e]||{},{type:e},gt,mo]}resolveNamedOptions(t,e,s,o=[""]){const a={$shared:!0},{resolver:l,subPrefixes:h}=el(this._resolverCache,t,o);let u=l;if(Jm(l,e)){a.$shared=!1,s=Te(s)?s():s;const d=this.createResolver(t,s,h);u=ui(l,s,d)}for(const d of e)a[d]=u[d];return a}createResolver(t,e,s=[""],o){const{resolver:a}=el(this._resolverCache,t,s);return et(e)?ui(a,e,void 0,o):a}}function el(i,t,e){let s=i.get(t);s||(s=new Map,i.set(t,s));const o=e.join();let a=s.get(o);return a||(a={resolver:Fo(t,e),subPrefixes:e.filter(h=>!h.toLowerCase().includes("hover"))},s.set(o,a)),a}const Gm=i=>et(i)&&Object.getOwnPropertyNames(i).some(t=>Te(i[t]));function Jm(i,t){const{isScriptable:e,isIndexable:s}=fh(i);for(const o of t){const a=e(o),l=s(o),h=(l||a)&&i[o];if(a&&(Te(h)||Gm(h))||l&&mt(h))return!0}return!1}var Qm="4.5.1";const tg=["top","bottom","left","right","chartArea"];function il(i,t){return i==="top"||i==="bottom"||tg.indexOf(i)===-1&&t==="x"}function nl(i,t){return function(e,s){return e[i]===s[i]?e[t]-s[t]:e[i]-s[i]}}function sl(i){const t=i.chart,e=t.options.animation;t.notifyPlugins("afterRender"),ft(e&&e.onComplete,[i],t)}function eg(i){const t=i.chart,e=t.options.animation;ft(e&&e.onProgress,[i],t)}function zh(i){return Zo()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}const Wn={},ol=i=>{const t=zh(i);return Object.values(Wn).filter(e=>e.canvas===t).pop()};function ig(i,t,e){const s=Object.keys(i);for(const o of s){const a=+o;if(a>=t){const l=i[o];delete i[o],(e>0||a>t)&&(i[a+e]=l)}}}function ng(i,t,e,s){return!e||i.type==="mouseout"?null:s?t:i}class $o{static defaults=gt;static instances=Wn;static overrides=Ue;static registry=ee;static version=Qm;static getChart=ol;static register(...t){ee.add(...t),rl()}static unregister(...t){ee.remove(...t),rl()}constructor(t,e){const s=this.config=new Km(e),o=zh(t),a=ol(o);if(a)throw new Error("Canvas is already in use. Chart with ID '"+a.id+"' must be destroyed before the canvas with ID '"+a.canvas.id+"' can be reused.");const l=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||xm(o)),this.platform.updateConfig(s);const h=this.platform.acquireContext(o,l.aspectRatio),u=h&&h.canvas,d=u&&u.height,p=u&&u.width;if(this.id=Gd(),this.ctx=h,this.canvas=u,this.width=p,this.height=d,this._options=l,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new Fm,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=mf(g=>this.update(g),l.resizeDelay||0),this._dataChanges=[],Wn[this.id]=this,!h||!u){console.error("Failed to create chart: can't acquire context from the given item");return}ue.listen(this,"complete",sl),ue.listen(this,"progress",eg),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:o,_aspectRatio:a}=this;return Q(t)?e&&a?a:o?s/o:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return ee}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Ca(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Sa(this.canvas,this.ctx),this}stop(){return ue.stop(this),this}resize(t,e){ue.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const s=this.options,o=this.canvas,a=s.maintainAspectRatio&&this.aspectRatio,l=this.platform.getMaximumSize(o,t,e,a),h=s.devicePixelRatio||this.platform.getDevicePixelRatio(),u=this.width?"resize":"attach";this.width=l.width,this.height=l.height,this._aspectRatio=this.aspectRatio,Ca(this,h,!0)&&(this.notifyPlugins("resize",{size:l}),ft(s.onResize,[this,l],this),this.attached&&this._doResize(u)&&this.render())}ensureScalesHaveIDs(){const e=this.options.scales||{};ht(e,(s,o)=>{s.id=o})}buildOrUpdateScales(){const t=this.options,e=t.scales,s=this.scales,o=Object.keys(s).reduce((l,h)=>(l[h]=!1,l),{});let a=[];e&&(a=a.concat(Object.keys(e).map(l=>{const h=e[l],u=yo(l,h),d=u==="r",p=u==="x";return{options:h,dposition:d?"chartArea":p?"bottom":"left",dtype:d?"radialLinear":p?"category":"linear"}}))),ht(a,l=>{const h=l.options,u=h.id,d=yo(u,h),p=U(h.type,l.dtype);(h.position===void 0||il(h.position,d)!==il(l.dposition))&&(h.position=l.dposition),o[u]=!0;let g=null;if(u in s&&s[u].type===p)g=s[u];else{const _=ee.getScale(p);g=new _({id:u,type:p,ctx:this.ctx,chart:this}),s[g.id]=g}g.init(h,t)}),ht(o,(l,h)=>{l||delete s[h]}),ht(s,l=>{It.configure(this,l,l.options),It.addBox(this,l)})}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,s=t.length;if(t.sort((o,a)=>o.index-a.index),s>e){for(let o=e;oe.length&&delete this._stacks,t.forEach((s,o)=>{e.filter(a=>a===s._dataset).length===0&&this._destroyDatasetMeta(o)})}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let s,o;for(this._removeUnreferencedMetasets(),s=0,o=e.length;s{this.getDatasetMeta(e).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const s=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),o=this._animationsDisabled=!s.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let l=0;for(let d=0,p=this.data.datasets.length;d{d.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(nl("z","_idx"));const{_active:h,_lastEvent:u}=this;u?this._eventHandler(u,!0):h.length&&this._updateHoverStyles(h,h,!0),this.render()}_updateScales(){ht(this.scales,t=>{It.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),s=new Set(t.events);(!ga(e,s)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:s,start:o,count:a}of e){const l=s==="_removeElements"?-a:a;ig(t,o,l)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,s=a=>new Set(t.filter(l=>l[0]===a).map((l,h)=>h+","+l.splice(1).join(","))),o=s(0);for(let a=1;aa.split(",")).map(a=>({method:a[1],start:+a[2],count:+a[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;It.update(this,this.width,this.height,t);const e=this.chartArea,s=e.width<=0||e.height<=0;this._layers=[],ht(this.boxes,o=>{s&&o.position==="chartArea"||(o.configure&&o.configure(),this._layers.push(...o._layers()))},this),this._layers.forEach((o,a)=>{o._idx=a}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let e=0,s=this.data.datasets.length;e=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,s={meta:t,index:t.index,cancelable:!0},o=kh(this,t);this.notifyPlugins("beforeDatasetDraw",s)!==!1&&(o&&es(e,o),t.controller.draw(),o&&is(e),s.cancelable=!1,this.notifyPlugins("afterDatasetDraw",s))}isPointInArea(t){return ge(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,o){const a=tm.modes[e];return typeof a=="function"?a(this,t,s,o):[]}getDatasetMeta(t){const e=this.data.datasets[t],s=this._metasets;let o=s.filter(a=>a&&a._dataset===e).pop();return o||(o={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:!1},s.push(o)),o}getContext(){return this.$context||(this.$context=Oe(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!e.hidden}setDatasetVisibility(t,e){const s=this.getDatasetMeta(t);s.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,s){const o=s?"show":"hide",a=this.getDatasetMeta(t),l=a.controller._resolveAnimations(void 0,o);Ui(e)?(a.data[e].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),l.update(a,{visible:s}),this.update(h=>h.datasetIndex===t?o:void 0))}hide(t,e){this._updateVisibility(t,e,!1)}show(t,e){this._updateVisibility(t,e,!0)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy(),delete this._metasets[t]}_stop(){let t,e;for(this.stop(),ue.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,a,l),t[a]=l},o=(a,l,h)=>{a.offsetX=l,a.offsetY=h,this._eventHandler(a)};ht(this.options.events,a=>s(a,o))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,s=(u,d)=>{e.addEventListener(this,u,d),t[u]=d},o=(u,d)=>{t[u]&&(e.removeEventListener(this,u,d),delete t[u])},a=(u,d)=>{this.canvas&&this.resize(u,d)};let l;const h=()=>{o("attach",h),this.attached=!0,this.resize(),s("resize",a),s("detach",l)};l=()=>{this.attached=!1,o("resize",a),this._stop(),this._resize(0,0),s("attach",h)},e.isAttached(this.canvas)?h():l()}unbindEvents(){ht(this._listeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._listeners={},ht(this._responsiveListeners,(t,e)=>{this.platform.removeEventListener(this,e,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,e,s){const o=s?"set":"remove";let a,l,h,u;for(e==="dataset"&&(a=this.getDatasetMeta(t[0].datasetIndex),a.controller["_"+o+"DatasetHoverStyle"]()),h=0,u=t.length;h{const h=this.getDatasetMeta(a);if(!h)throw new Error("No dataset found at index "+a);return{datasetIndex:a,element:h.data[l],index:l}});!Vn(s,e)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,e))}notifyPlugins(t,e,s){return this._plugins.notify(this,t,e,s)}isPluginEnabled(t){return this._plugins._cache.filter(e=>e.plugin.id===t).length===1}_updateHoverStyles(t,e,s){const o=this.options.hover,a=(u,d)=>u.filter(p=>!d.some(g=>p.datasetIndex===g.datasetIndex&&p.index===g.index)),l=a(e,t),h=s?t:a(t,e);l.length&&this.updateHoverStyle(l,o.mode,!1),h.length&&o.mode&&this.updateHoverStyle(h,o.mode,!0)}_eventHandler(t,e){const s={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},o=l=>(l.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,o)===!1)return;const a=this._handleEvent(t,e,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,o),(a||s.changed)&&this.render(),this}_handleEvent(t,e,s){const{_active:o=[],options:a}=this,l=e,h=this._getActiveElements(t,o,s,l),u=sf(t),d=ng(t,this._lastEvent,s,u);s&&(this._lastEvent=null,ft(a.onHover,[t,h,this],this),u&&ft(a.onClick,[t,h,this],this));const p=!Vn(h,o);return(p||e)&&(this._active=h,this._updateHoverStyles(h,o,e)),this._lastEvent=d,p}_getActiveElements(t,e,s,o){if(t.type==="mouseout")return[];if(!s)return e;const a=this.options.hover;return this.getElementsAtEventForMode(t,a.mode,a,o)}}function rl(){return ht($o.instances,i=>i._plugins.invalidate())}function sg(i,t,e){const{startAngle:s,x:o,y:a,outerRadius:l,innerRadius:h,options:u}=t,{borderWidth:d,borderJoinStyle:p}=u,g=Math.min(d/l,Dt(s-e));if(i.beginPath(),i.arc(o,a,l-d/2,s+g/2,e-g/2),h>0){const _=Math.min(d/h,Dt(s-e));i.arc(o,a,h+d/2,e-_/2,s+_/2,!0)}else{const _=Math.min(d/2,l*Dt(s-e));if(p==="round")i.arc(o,a,_,e-lt/2,s+lt/2,!0);else if(p==="bevel"){const v=2*_*_,x=-v*Math.cos(e+lt/2)+o,b=-v*Math.sin(e+lt/2)+a,P=v*Math.cos(s+lt/2)+o,k=v*Math.sin(s+lt/2)+a;i.lineTo(x,b),i.lineTo(P,k)}}i.closePath(),i.moveTo(0,0),i.rect(0,0,i.canvas.width,i.canvas.height),i.clip("evenodd")}function og(i,t,e){const{startAngle:s,pixelMargin:o,x:a,y:l,outerRadius:h,innerRadius:u}=t;let d=o/h;i.beginPath(),i.arc(a,l,h,s-d,e+d),u>o?(d=o/u,i.arc(a,l,u,e+d,s-d,!0)):i.arc(a,l,o,e+Pt,s-Pt),i.closePath(),i.clip()}function rg(i){return No(i,["outerStart","outerEnd","innerStart","innerEnd"])}function ag(i,t,e,s){const o=rg(i.options.borderRadius),a=(e-t)/2,l=Math.min(a,s*t/2),h=u=>{const d=(e-Math.min(a,u))*s/2;return Et(u,0,Math.min(a,d))};return{outerStart:h(o.outerStart),outerEnd:h(o.outerEnd),innerStart:Et(o.innerStart,0,l),innerEnd:Et(o.innerEnd,0,l)}}function ri(i,t,e,s){return{x:e+i*Math.cos(t),y:s+i*Math.sin(t)}}function Xn(i,t,e,s,o,a){const{x:l,y:h,startAngle:u,pixelMargin:d,innerRadius:p}=t,g=Math.max(t.outerRadius+s+e-d,0),_=p>0?p+s+e+d:0;let v=0;const x=o-u;if(s){const rt=p>0?p-s:0,K=g>0?g-s:0,tt=(rt+K)/2,F=tt!==0?x*tt/(tt+s):x;v=(x-F)/2}const b=Math.max(.001,x*g-e/lt)/g,P=(x-b)/2,k=u+P+v,C=o-P-v,{outerStart:E,outerEnd:A,innerStart:T,innerEnd:D}=ag(t,_,g,C-k),R=g-E,B=g-A,N=k+E/R,$=C-A/B,W=_+T,j=_+D,vt=k+T/W,ut=C-D/j;if(i.beginPath(),a){const rt=(N+$)/2;if(i.arc(l,h,g,N,rt),i.arc(l,h,g,rt,$),A>0){const _t=ri(B,$,l,h);i.arc(_t.x,_t.y,A,$,C+Pt)}const K=ri(j,C,l,h);if(i.lineTo(K.x,K.y),D>0){const _t=ri(j,ut,l,h);i.arc(_t.x,_t.y,D,C+Pt,ut+Math.PI)}const tt=(C-D/_+(k+T/_))/2;if(i.arc(l,h,_,C-D/_,tt,!0),i.arc(l,h,_,tt,k+T/_,!0),T>0){const _t=ri(W,vt,l,h);i.arc(_t.x,_t.y,T,vt+Math.PI,k-Pt)}const F=ri(R,k,l,h);if(i.lineTo(F.x,F.y),E>0){const _t=ri(R,N,l,h);i.arc(_t.x,_t.y,E,k-Pt,N)}}else{i.moveTo(l,h);const rt=Math.cos(N)*g+l,K=Math.sin(N)*g+h;i.lineTo(rt,K);const tt=Math.cos($)*g+l,F=Math.sin($)*g+h;i.lineTo(tt,F)}i.closePath()}function lg(i,t,e,s,o){const{fullCircles:a,startAngle:l,circumference:h}=t;let u=t.endAngle;if(a){Xn(i,t,e,s,u,o);for(let d=0;d=lt&&v===0&&p!=="miter"&&sg(i,t,b),a||(Xn(i,t,e,s,b,o),i.stroke())}class cg extends _e{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,e,s){const o=this.getProps(["x","y"],s),{angle:a,distance:l}=nh(o,{x:t,y:e}),{startAngle:h,endAngle:u,innerRadius:d,outerRadius:p,circumference:g}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],s),_=(this.options.spacing+this.options.borderWidth)/2,v=U(g,u-h),x=Yi(a,h,u)&&h!==u,b=v>=pt||x,P=pe(l,d+_,p+_);return b&&P}getCenterPoint(t){const{x:e,y:s,startAngle:o,endAngle:a,innerRadius:l,outerRadius:h}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:u,spacing:d}=this.options,p=(o+a)/2,g=(l+h+d+u)/2;return{x:e+Math.cos(p)*g,y:s+Math.sin(p)*g}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:s}=this,o=(e.offset||0)/4,a=(e.spacing||0)/2,l=e.circular;if(this.pixelMargin=e.borderAlign==="inner"?.33:0,this.fullCircles=s>pt?Math.floor(s/pt):0,s===0||this.innerRadius<0||this.outerRadius<0)return;t.save();const h=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(h)*o,Math.sin(h)*o);const u=1-Math.sin(Math.min(lt,s||0)),d=o*u;t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,lg(t,this,d,a,l),hg(t,this,d,a,l),t.restore()}}function Nh(i,t,e=t){i.lineCap=U(e.borderCapStyle,t.borderCapStyle),i.setLineDash(U(e.borderDash,t.borderDash)),i.lineDashOffset=U(e.borderDashOffset,t.borderDashOffset),i.lineJoin=U(e.borderJoinStyle,t.borderJoinStyle),i.lineWidth=U(e.borderWidth,t.borderWidth),i.strokeStyle=U(e.borderColor,t.borderColor)}function ug(i,t,e){i.lineTo(e.x,e.y)}function dg(i){return i.stepped?Lf:i.tension||i.cubicInterpolationMode==="monotone"?Cf:ug}function Fh(i,t,e={}){const s=i.length,{start:o=0,end:a=s-1}=e,{start:l,end:h}=t,u=Math.max(o,l),d=Math.min(a,h),p=oh&&a>h;return{count:s,start:u,loop:t.loop,ilen:d(l+(d?h-A:A))%a,E=()=>{b!==P&&(i.lineTo(p,P),i.lineTo(p,b),i.lineTo(p,k))};for(u&&(v=o[C(0)],i.moveTo(v.x,v.y)),_=0;_<=h;++_){if(v=o[C(_)],v.skip)continue;const A=v.x,T=v.y,D=A|0;D===x?(TP&&(P=T),p=(g*p+A)/++g):(E(),i.lineTo(A,T),x=D,g=0,b=P=T),k=T}E()}function vo(i){const t=i.options,e=t.borderDash&&t.borderDash.length;return!i._decimated&&!i._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!e?pg:fg}function mg(i){return i.stepped?rp:i.tension||i.cubicInterpolationMode==="monotone"?ap:je}function gg(i,t,e,s){let o=t._path;o||(o=t._path=new Path2D,t.path(o,e,s)&&o.closePath()),Nh(i,t.options),i.stroke(o)}function _g(i,t,e,s){const{segments:o,options:a}=t,l=vo(t);for(const h of o)Nh(i,a,h.style),i.beginPath(),l(i,t,h,{start:e,end:e+s-1})&&i.closePath(),i.stroke()}const yg=typeof Path2D=="function";function vg(i,t,e,s){yg&&!t.options.segment?gg(i,t,e,s):_g(i,t,e,s)}class os extends _e{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,e){const s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){const o=s.spanGaps?this._loop:this._fullLoop;Jf(this._points,s,t,o,e),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=fp(this,this.options.segment))}first(){const t=this.segments,e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments,e=this.points,s=t.length;return s&&e[t[s-1].end]}interpolate(t,e){const s=this.options,o=t[e],a=this.points,l=Ph(this,{property:e,start:o,end:o});if(!l.length)return;const h=[],u=mg(s);let d,p;for(d=0,p=l.length;di.replace("rgb(","rgba(").replace(")",", 0.5)"));function Hh(i){return bo[i%bo.length]}function Zh(i){return ll[i%ll.length]}function Cg(i,t){return i.borderColor=Hh(t),i.backgroundColor=Zh(t),++t}function Tg(i,t){return i.backgroundColor=i.data.map(()=>Hh(t++)),t}function Eg(i,t){return i.backgroundColor=i.data.map(()=>Zh(t++)),t}function Ag(i){let t=0;return(e,s)=>{const o=i.getDatasetMeta(s).controller;o instanceof jo?t=Tg(e,t):o instanceof Ch?t=Eg(e,t):o&&(t=Cg(e,t))}}function hl(i){let t;for(t in i)if(i[t].borderColor||i[t].backgroundColor)return!0;return!1}function Og(i){return i&&(i.borderColor||i.backgroundColor)}function Dg(){return gt.borderColor!=="rgba(0,0,0,0.1)"||gt.backgroundColor!=="rgba(0,0,0,0.1)"}var Ig={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(i,t,e){if(!e.enabled)return;const{data:{datasets:s},options:o}=i.config,{elements:a}=o,l=hl(s)||Og(o)||a&&hl(a)||Dg();if(!e.forceOverride&&l)return;const h=Ag(i);s.forEach(h)}};function Rg(i,t,e,s,o){const a=o.samples||s;if(a>=e)return i.slice(t,t+e);const l=[],h=(e-2)/(a-2);let u=0;const d=t+e-1;let p=t,g,_,v,x,b;for(l[u++]=i[p],g=0;gv&&(v=x,_=i[C],b=C);l[u++]=_,p=b}return l[u++]=i[d],l}function Bg(i,t,e,s){let o=0,a=0,l,h,u,d,p,g,_,v,x,b;const P=[],k=t+e-1,C=i[t].x,A=i[k].x-C;for(l=t;lb&&(b=d,_=l),o=(a*o+h.x)/++a;else{const D=l-1;if(!Q(g)&&!Q(_)){const R=Math.min(g,_),B=Math.max(g,_);R!==v&&R!==D&&P.push({...i[R],x:o}),B!==v&&B!==D&&P.push({...i[B],x:o})}l>0&&D!==v&&P.push(i[D]),P.push(h),p=T,a=0,x=b=d,g=_=v=l}}return P}function Vh(i){if(i._decimated){const t=i._data;delete i._decimated,delete i._data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function cl(i){i.data.datasets.forEach(t=>{Vh(t)})}function zg(i,t){const e=t.length;let s=0,o;const{iScale:a}=i,{min:l,max:h,minDefined:u,maxDefined:d}=a.getUserBounds();return u&&(s=Et(me(t,a.axis,l).lo,0,e-1)),d?o=Et(me(t,a.axis,h).hi+1,s,e)-s:o=e-s,{start:s,count:o}}var Ng={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(i,t,e)=>{if(!e.enabled){cl(i);return}const s=i.width;i.data.datasets.forEach((o,a)=>{const{_data:l,indexAxis:h}=o,u=i.getDatasetMeta(a),d=l||o.data;if(zi([h,i.options.indexAxis])==="y"||!u.controller.supportsDecimation)return;const p=i.scales[u.xAxisID];if(p.type!=="linear"&&p.type!=="time"||i.options.parsing)return;let{start:g,count:_}=zg(u,d);const v=e.threshold||4*s;if(_<=v){Vh(o);return}Q(l)&&(o._data=d,delete o.data,Object.defineProperty(o,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(b){this._data=b}}));let x;switch(e.algorithm){case"lttb":x=Rg(d,g,_,s,e);break;case"min-max":x=Bg(d,g,_,s);break;default:throw new Error(`Unsupported decimation algorithm '${e.algorithm}'`)}o._decimated=x})},destroy(i){cl(i)}};function Fg(i,t,e){const s=i.segments,o=i.points,a=t.points,l=[];for(const h of s){let{start:u,end:d}=h;d=rs(u,d,o);const p=xo(e,o[u],o[d],h.loop);if(!t.segments){l.push({source:h,target:p,start:o[u],end:o[d]});continue}const g=Ph(t,p);for(const _ of g){const v=xo(e,a[_.start],a[_.end],_.loop),x=wh(h,o,v);for(const b of x)l.push({source:b,target:_,start:{[e]:ul(p,v,"start",Math.max)},end:{[e]:ul(p,v,"end",Math.min)}})}}return l}function xo(i,t,e,s){if(s)return;let o=t[i],a=e[i];return i==="angle"&&(o=Dt(o),a=Dt(a)),{property:i,start:o,end:a}}function Wg(i,t){const{x:e=null,y:s=null}=i||{},o=t.points,a=[];return t.segments.forEach(({start:l,end:h})=>{h=rs(l,h,o);const u=o[l],d=o[h];s!==null?(a.push({x:u.x,y:s}),a.push({x:d.x,y:s})):e!==null&&(a.push({x:e,y:u.y}),a.push({x:e,y:d.y}))}),a}function rs(i,t,e){for(;t>i;t--){const s=e[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function ul(i,t,e,s){return i&&t?s(i[e],t[e]):i?i[e]:t?t[e]:0}function jh(i,t){let e=[],s=!1;return mt(i)?(s=!0,e=i):e=Wg(i,t),e.length?new os({points:e,options:{tension:0},_loop:s,_fullLoop:s}):null}function dl(i){return i&&i.fill!==!1}function Hg(i,t,e){let o=i[t].fill;const a=[t];let l;if(!e)return o;for(;o!==!1&&a.indexOf(o)===-1;){if(!bt(o))return o;if(l=i[o],!l)return!1;if(l.visible)return o;a.push(o),o=l.fill}return!1}function Zg(i,t,e){const s=$g(i);if(et(s))return isNaN(s.value)?!1:s;let o=parseFloat(s);return bt(o)&&Math.floor(o)===o?Vg(s[0],t,o,e):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function Vg(i,t,e,s){return(i==="-"||i==="+")&&(e=t+e),e===t||e<0||e>=s?!1:e}function jg(i,t){let e=null;return i==="start"?e=t.bottom:i==="end"?e=t.top:et(i)?e=t.getPixelForValue(i.value):t.getBasePixel&&(e=t.getBasePixel()),e}function qg(i,t,e){let s;return i==="start"?s=e:i==="end"?s=t.options.reverse?t.min:t.max:et(i)?s=i.value:s=t.getBaseValue(),s}function $g(i){const t=i.options,e=t.fill;let s=U(e&&e.target,e);return s===void 0&&(s=!!t.backgroundColor),s===!1||s===null?!1:s===!0?"origin":s}function Ug(i){const{scale:t,index:e,line:s}=i,o=[],a=s.segments,l=s.points,h=Yg(t,e);h.push(jh({x:null,y:t.bottom},s));for(let u=0;u=0;--l){const h=o[l].$filler;h&&(h.line.updateControlPoints(a,h.axis),s&&h.fill&&no(i.ctx,h,a))}},beforeDatasetsDraw(i,t,e){if(e.drawTime!=="beforeDatasetsDraw")return;const s=i.getSortedVisibleDatasetMetas();for(let o=s.length-1;o>=0;--o){const a=s[o].$filler;dl(a)&&no(i.ctx,a,i.chartArea)}},beforeDatasetDraw(i,t,e){const s=t.meta.$filler;!dl(s)||e.drawTime!=="beforeDatasetDraw"||no(i.ctx,s,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const gl=(i,t)=>{let{boxHeight:e=t,boxWidth:s=t}=i;return i.usePointStyle&&(e=Math.min(e,t),s=i.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:e,itemHeight:Math.max(t,e)}},o_=(i,t)=>i!==null&&t!==null&&i.datasetIndex===t.datasetIndex&&i.index===t.index;class _l extends _e{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e,s){this.maxWidth=t,this.maxHeight=e,this._margins=s,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let e=ft(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter(s=>t.filter(s,this.chart.data))),t.sort&&(e=e.sort((s,o)=>t.sort(s,o,this.chart.data))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const s=t.labels,o=Ct(s.font),a=o.size,l=this._computeTitleHeight(),{boxWidth:h,itemHeight:u}=gl(s,a);let d,p;e.font=o.string,this.isHorizontal()?(d=this.maxWidth,p=this._fitRows(l,a,h,u)+10):(p=this.maxHeight,d=this._fitCols(l,o,h,u)+10),this.width=Math.min(d,t.maxWidth||this.maxWidth),this.height=Math.min(p,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,o){const{ctx:a,maxWidth:l,options:{labels:{padding:h}}}=this,u=this.legendHitBoxes=[],d=this.lineWidths=[0],p=o+h;let g=t;a.textAlign="left",a.textBaseline="middle";let _=-1,v=-p;return this.legendItems.forEach((x,b)=>{const P=s+e/2+a.measureText(x.text).width;(b===0||d[d.length-1]+P+2*h>l)&&(g+=p,d[d.length-(b>0?0:1)]=0,v+=p,_++),u[b]={left:0,top:v,row:_,width:P,height:o},d[d.length-1]+=P+h}),g}_fitCols(t,e,s,o){const{ctx:a,maxHeight:l,options:{labels:{padding:h}}}=this,u=this.legendHitBoxes=[],d=this.columnSizes=[],p=l-t;let g=h,_=0,v=0,x=0,b=0;return this.legendItems.forEach((P,k)=>{const{itemWidth:C,itemHeight:E}=r_(s,e,a,P,o);k>0&&v+E+2*h>p&&(g+=_+h,d.push({width:_,height:v}),x+=_+h,b++,_=v=0),u[k]={left:x,top:v,col:b,width:C,height:E},_=Math.max(_,C),v+=E+h}),g+=_,d.push({width:_,height:v}),g}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:s,labels:{padding:o},rtl:a}}=this,l=li(a,this.left,this.width);if(this.isHorizontal()){let h=0,u=Ot(s,this.left+o,this.right-this.lineWidths[h]);for(const d of e)h!==d.row&&(h=d.row,u=Ot(s,this.left+o,this.right-this.lineWidths[h])),d.top+=this.top+t+o,d.left=l.leftForLtr(l.x(u),d.width),u+=d.width+o}else{let h=0,u=Ot(s,this.top+t+o,this.bottom-this.columnSizes[h].height);for(const d of e)d.col!==h&&(h=d.col,u=Ot(s,this.top+t+o,this.bottom-this.columnSizes[h].height)),d.top=u,d.left+=this.left+o,d.left=l.leftForLtr(l.x(d.left),d.width),u+=d.height+o}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;es(t,this),this._draw(),is(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:s,ctx:o}=this,{align:a,labels:l}=t,h=gt.color,u=li(t.rtl,this.left,this.width),d=Ct(l.font),{padding:p}=l,g=d.size,_=g/2;let v;this.drawTitle(),o.textAlign=u.textAlign("left"),o.textBaseline="middle",o.lineWidth=.5,o.font=d.string;const{boxWidth:x,boxHeight:b,itemHeight:P}=gl(l,g),k=function(D,R,B){if(isNaN(x)||x<=0||isNaN(b)||b<0)return;o.save();const N=U(B.lineWidth,1);if(o.fillStyle=U(B.fillStyle,h),o.lineCap=U(B.lineCap,"butt"),o.lineDashOffset=U(B.lineDashOffset,0),o.lineJoin=U(B.lineJoin,"miter"),o.lineWidth=N,o.strokeStyle=U(B.strokeStyle,h),o.setLineDash(U(B.lineDash,[])),l.usePointStyle){const $={radius:b*Math.SQRT2/2,pointStyle:B.pointStyle,rotation:B.rotation,borderWidth:N},W=u.xPlus(D,x/2),j=R+_;uh(o,$,W,j,l.pointStyleWidth&&x)}else{const $=R+Math.max((g-b)/2,0),W=u.leftForLtr(D,x),j=qe(B.borderRadius);o.beginPath(),Object.values(j).some(vt=>vt!==0)?Xi(o,{x:W,y:$,w:x,h:b,radius:j}):o.rect(W,$,x,b),o.fill(),N!==0&&o.stroke()}o.restore()},C=function(D,R,B){Ye(o,B.text,D,R+P/2,d,{strikethrough:B.hidden,textAlign:u.textAlign(B.textAlign)})},E=this.isHorizontal(),A=this._computeTitleHeight();E?v={x:Ot(a,this.left+p,this.right-s[0]),y:this.top+p+A,line:0}:v={x:this.left+p,y:Ot(a,this.top+A+p,this.bottom-e[0].height),line:0},vh(this.ctx,t.textDirection);const T=P+p;this.legendItems.forEach((D,R)=>{o.strokeStyle=D.fontColor,o.fillStyle=D.fontColor;const B=o.measureText(D.text).width,N=u.textAlign(D.textAlign||(D.textAlign=l.textAlign)),$=x+_+B;let W=v.x,j=v.y;u.setWidth(this.width),E?R>0&&W+$+p>this.right&&(j=v.y+=T,v.line++,W=v.x=Ot(a,this.left+p,this.right-s[v.line])):R>0&&j+T>this.bottom&&(W=v.x=W+e[v.line].width+p,v.line++,j=v.y=Ot(a,this.top+A+p,this.bottom-e[v.line].height));const vt=u.x(W);if(k(vt,j,D),W=gf(N,W+x+_,E?W+$:this.right,t.rtl),C(u.x(W),j,D),E)v.x+=$+p;else if(typeof D.text!="string"){const ut=d.lineHeight;v.y+=$h(D,ut)+p}else v.y+=T}),bh(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,s=Ct(e.font),o=Rt(e.padding);if(!e.display)return;const a=li(t.rtl,this.left,this.width),l=this.ctx,h=e.position,u=s.size/2,d=o.top+u;let p,g=this.left,_=this.width;if(this.isHorizontal())_=Math.max(...this.lineWidths),p=this.top+d,g=Ot(t.align,g,this.right-_);else{const x=this.columnSizes.reduce((b,P)=>Math.max(b,P.height),0);p=d+Ot(t.align,this.top,this.bottom-x-t.labels.padding-this._computeTitleHeight())}const v=Ot(h,g,g+_);l.textAlign=a.textAlign(Bo(h)),l.textBaseline="middle",l.strokeStyle=e.color,l.fillStyle=e.color,l.font=s.string,Ye(l,e.text,v,p,s)}_computeTitleHeight(){const t=this.options.title,e=Ct(t.font),s=Rt(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,o,a;if(pe(t,this.left,this.right)&&pe(e,this.top,this.bottom)){for(a=this.legendHitBoxes,s=0;sa.length>l.length?a:l)),t+e.size/2+s.measureText(o).width}function l_(i,t,e){let s=i;return typeof t.text!="string"&&(s=$h(t,e)),s}function $h(i,t){const e=i.text?i.text.length:0;return t*e}function h_(i,t){return!!((i==="mousemove"||i==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(i==="click"||i==="mouseup"))}var c_={id:"legend",_element:_l,start(i,t,e){const s=i.legend=new _l({ctx:i.ctx,options:e,chart:i});It.configure(i,s,e),It.addBox(i,s)},stop(i){It.removeBox(i,i.legend),delete i.legend},beforeUpdate(i,t,e){const s=i.legend;It.configure(i,s,e),s.options=e},afterUpdate(i){const t=i.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(i,t){t.replay||i.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(i,t,e){const s=t.datasetIndex,o=e.chart;o.isDatasetVisible(s)?(o.hide(s),t.hidden=!0):(o.show(s),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:i=>i.chart.options.color,boxWidth:40,padding:10,generateLabels(i){const t=i.data.datasets,{labels:{usePointStyle:e,pointStyle:s,textAlign:o,color:a,useBorderRadius:l,borderRadius:h}}=i.legend.options;return i._getSortedDatasetMetas().map(u=>{const d=u.controller.getStyle(e?0:void 0),p=Rt(d.borderWidth);return{text:t[u.index].label,fillStyle:d.backgroundColor,fontColor:a,hidden:!u.visible,lineCap:d.borderCapStyle,lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:(p.width+p.height)/4,strokeStyle:d.borderColor,pointStyle:s||d.pointStyle,rotation:d.rotation,textAlign:o||d.textAlign,borderRadius:l&&(h||d.borderRadius),datasetIndex:u.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class Uo extends _e{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,e){const s=this.options;if(this.left=0,this.top=0,!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=e;const o=mt(s.text)?s.text.length:1;this._padding=Rt(s.padding);const a=o*Ct(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=a:this.width=a}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:e,left:s,bottom:o,right:a,options:l}=this,h=l.align;let u=0,d,p,g;return this.isHorizontal()?(p=Ot(h,s,a),g=e+t,d=a-s):(l.position==="left"?(p=s+t,g=Ot(h,o,e),u=lt*-.5):(p=a-t,g=Ot(h,e,o),u=lt*.5),d=o-e),{titleX:p,titleY:g,maxWidth:d,rotation:u}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const s=Ct(e.font),a=s.lineHeight/2+this._padding.top,{titleX:l,titleY:h,maxWidth:u,rotation:d}=this._drawArgs(a);Ye(t,e.text,0,0,s,{color:e.color,maxWidth:u,rotation:d,textAlign:Bo(e.align),textBaseline:"middle",translation:[l,h]})}}function u_(i,t){const e=new Uo({ctx:i.ctx,options:t,chart:i});It.configure(i,e,t),It.addBox(i,e),i.titleBlock=e}var d_={id:"title",_element:Uo,start(i,t,e){u_(i,e)},stop(i){const t=i.titleBlock;It.removeBox(i,t),delete i.titleBlock},beforeUpdate(i,t,e){const s=i.titleBlock;It.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const On=new WeakMap;var f_={id:"subtitle",start(i,t,e){const s=new Uo({ctx:i.ctx,options:e,chart:i});It.configure(i,s,e),It.addBox(i,s),On.set(i,s)},stop(i){It.removeBox(i,On.get(i)),On.delete(i)},beforeUpdate(i,t,e){const s=On.get(i);It.configure(i,s,e),s.options=e},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Fi={average(i){if(!i.length)return!1;let t,e,s=new Set,o=0,a=0;for(t=0,e=i.length;th+u)/s.size,y:o/a}},nearest(i,t){if(!i.length)return!1;let e=t.x,s=t.y,o=Number.POSITIVE_INFINITY,a,l,h;for(a=0,l=i.length;a-1?i.split(` -`):i}function p_(i,t){const{element:e,datasetIndex:s,index:o}=t,a=i.getDatasetMeta(s).controller,{label:l,value:h}=a.getLabelAndValue(o);return{chart:i,label:l,parsed:a.getParsed(o),raw:i.data.datasets[s].data[o],formattedValue:h,dataset:a.getDataset(),dataIndex:o,datasetIndex:s,element:e}}function yl(i,t){const e=i.chart.ctx,{body:s,footer:o,title:a}=i,{boxWidth:l,boxHeight:h}=t,u=Ct(t.bodyFont),d=Ct(t.titleFont),p=Ct(t.footerFont),g=a.length,_=o.length,v=s.length,x=Rt(t.padding);let b=x.height,P=0,k=s.reduce((A,T)=>A+T.before.length+T.lines.length+T.after.length,0);if(k+=i.beforeBody.length+i.afterBody.length,g&&(b+=g*d.lineHeight+(g-1)*t.titleSpacing+t.titleMarginBottom),k){const A=t.displayColors?Math.max(h,u.lineHeight):u.lineHeight;b+=v*A+(k-v)*u.lineHeight+(k-1)*t.bodySpacing}_&&(b+=t.footerMarginTop+_*p.lineHeight+(_-1)*t.footerSpacing);let C=0;const E=function(A){P=Math.max(P,e.measureText(A).width+C)};return e.save(),e.font=d.string,ht(i.title,E),e.font=u.string,ht(i.beforeBody.concat(i.afterBody),E),C=t.displayColors?l+2+t.boxPadding:0,ht(s,A=>{ht(A.before,E),ht(A.lines,E),ht(A.after,E)}),C=0,e.font=p.string,ht(i.footer,E),e.restore(),P+=x.width,{width:P,height:b}}function m_(i,t){const{y:e,height:s}=t;return ei.height-s/2?"bottom":"center"}function g_(i,t,e,s){const{x:o,width:a}=s,l=e.caretSize+e.caretPadding;if(i==="left"&&o+a+l>t.width||i==="right"&&o-a-l<0)return!0}function __(i,t,e,s){const{x:o,width:a}=e,{width:l,chartArea:{left:h,right:u}}=i;let d="center";return s==="center"?d=o<=(h+u)/2?"left":"right":o<=a/2?d="left":o>=l-a/2&&(d="right"),g_(d,i,t,e)&&(d="center"),d}function vl(i,t,e){const s=e.yAlign||t.yAlign||m_(i,e);return{xAlign:e.xAlign||t.xAlign||__(i,t,e,s),yAlign:s}}function y_(i,t){let{x:e,width:s}=i;return t==="right"?e-=s:t==="center"&&(e-=s/2),e}function v_(i,t,e){let{y:s,height:o}=i;return t==="top"?s+=e:t==="bottom"?s-=o+e:s-=o/2,s}function bl(i,t,e,s){const{caretSize:o,caretPadding:a,cornerRadius:l}=i,{xAlign:h,yAlign:u}=e,d=o+a,{topLeft:p,topRight:g,bottomLeft:_,bottomRight:v}=qe(l);let x=y_(t,h);const b=v_(t,u,d);return u==="center"?h==="left"?x+=d:h==="right"&&(x-=d):h==="left"?x-=Math.max(p,_)+o:h==="right"&&(x+=Math.max(g,v)+o),{x:Et(x,0,s.width-t.width),y:Et(b,0,s.height-t.height)}}function Dn(i,t,e){const s=Rt(e.padding);return t==="center"?i.x+i.width/2:t==="right"?i.x+i.width-s.right:i.x+s.left}function xl(i){return te([],de(i))}function b_(i,t,e){return Oe(i,{tooltip:t,tooltipItems:e,type:"tooltip"})}function wl(i,t){const e=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return e?i.override(e):i}const Uh={beforeTitle:ce,title(i){if(i.length>0){const t=i[0],e=t.chart.data.labels,s=e?e.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex"u"?Uh[t].call(e,s):o}class Pl extends _e{static positioners=Fi;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const e=this.chart,s=this.options.setContext(this.getContext()),o=s.enabled&&e.options.animation&&s.animations,a=new Sh(this.chart,o);return o._cacheable&&(this._cachedAnimations=Object.freeze(a)),a}getContext(){return this.$context||(this.$context=b_(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,e){const{callbacks:s}=e,o=Nt(s,"beforeTitle",this,t),a=Nt(s,"title",this,t),l=Nt(s,"afterTitle",this,t);let h=[];return h=te(h,de(o)),h=te(h,de(a)),h=te(h,de(l)),h}getBeforeBody(t,e){return xl(Nt(e.callbacks,"beforeBody",this,t))}getBody(t,e){const{callbacks:s}=e,o=[];return ht(t,a=>{const l={before:[],lines:[],after:[]},h=wl(s,a);te(l.before,de(Nt(h,"beforeLabel",this,a))),te(l.lines,Nt(h,"label",this,a)),te(l.after,de(Nt(h,"afterLabel",this,a))),o.push(l)}),o}getAfterBody(t,e){return xl(Nt(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:s}=e,o=Nt(s,"beforeFooter",this,t),a=Nt(s,"footer",this,t),l=Nt(s,"afterFooter",this,t);let h=[];return h=te(h,de(o)),h=te(h,de(a)),h=te(h,de(l)),h}_createItems(t){const e=this._active,s=this.chart.data,o=[],a=[],l=[];let h=[],u,d;for(u=0,d=e.length;ut.filter(p,g,_,s))),t.itemSort&&(h=h.sort((p,g)=>t.itemSort(p,g,s))),ht(h,p=>{const g=wl(t.callbacks,p);o.push(Nt(g,"labelColor",this,p)),a.push(Nt(g,"labelPointStyle",this,p)),l.push(Nt(g,"labelTextColor",this,p))}),this.labelColors=o,this.labelPointStyles=a,this.labelTextColors=l,this.dataPoints=h,h}update(t,e){const s=this.options.setContext(this.getContext()),o=this._active;let a,l=[];if(!o.length)this.opacity!==0&&(a={opacity:0});else{const h=Fi[s.position].call(this,o,this._eventPosition);l=this._createItems(s),this.title=this.getTitle(l,s),this.beforeBody=this.getBeforeBody(l,s),this.body=this.getBody(l,s),this.afterBody=this.getAfterBody(l,s),this.footer=this.getFooter(l,s);const u=this._size=yl(this,s),d=Object.assign({},h,u),p=vl(this.chart,s,d),g=bl(s,d,p,this.chart);this.xAlign=p.xAlign,this.yAlign=p.yAlign,a={opacity:1,x:g.x,y:g.y,width:u.width,height:u.height,caretX:h.x,caretY:h.y}}this._tooltipItems=l,this.$context=void 0,a&&this._resolveAnimations().update(this,a),t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,s,o){const a=this.getCaretPosition(t,s,o);e.lineTo(a.x1,a.y1),e.lineTo(a.x2,a.y2),e.lineTo(a.x3,a.y3)}getCaretPosition(t,e,s){const{xAlign:o,yAlign:a}=this,{caretSize:l,cornerRadius:h}=s,{topLeft:u,topRight:d,bottomLeft:p,bottomRight:g}=qe(h),{x:_,y:v}=t,{width:x,height:b}=e;let P,k,C,E,A,T;return a==="center"?(A=v+b/2,o==="left"?(P=_,k=P-l,E=A+l,T=A-l):(P=_+x,k=P+l,E=A-l,T=A+l),C=P):(o==="left"?k=_+Math.max(u,p)+l:o==="right"?k=_+x-Math.max(d,g)-l:k=this.caretX,a==="top"?(E=v,A=E-l,P=k-l,C=k+l):(E=v+b,A=E+l,P=k+l,C=k-l),T=E),{x1:P,x2:k,x3:C,y1:E,y2:A,y3:T}}drawTitle(t,e,s){const o=this.title,a=o.length;let l,h,u;if(a){const d=li(s.rtl,this.x,this.width);for(t.x=Dn(this,s.titleAlign,s),e.textAlign=d.textAlign(s.titleAlign),e.textBaseline="middle",l=Ct(s.titleFont),h=s.titleSpacing,e.fillStyle=s.titleColor,e.font=l.string,u=0;uC!==0)?(t.beginPath(),t.fillStyle=a.multiKeyBackground,Xi(t,{x:b,y:x,w:d,h:u,radius:k}),t.fill(),t.stroke(),t.fillStyle=l.backgroundColor,t.beginPath(),Xi(t,{x:P,y:x+1,w:d-2,h:u-2,radius:k}),t.fill()):(t.fillStyle=a.multiKeyBackground,t.fillRect(b,x,d,u),t.strokeRect(b,x,d,u),t.fillStyle=l.backgroundColor,t.fillRect(P,x+1,d-2,u-2))}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){const{body:o}=this,{bodySpacing:a,bodyAlign:l,displayColors:h,boxHeight:u,boxWidth:d,boxPadding:p}=s,g=Ct(s.bodyFont);let _=g.lineHeight,v=0;const x=li(s.rtl,this.x,this.width),b=function(B){e.fillText(B,x.x(t.x+v),t.y+_/2),t.y+=_+a},P=x.textAlign(l);let k,C,E,A,T,D,R;for(e.textAlign=l,e.textBaseline="middle",e.font=g.string,t.x=Dn(this,P,s),e.fillStyle=s.bodyColor,ht(this.beforeBody,b),v=h&&P!=="right"?l==="center"?d/2+p:d+2+p:0,A=0,D=o.length;A0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,s=this.$animations,o=s&&s.x,a=s&&s.y;if(o||a){const l=Fi[t.position].call(this,this._active,this._eventPosition);if(!l)return;const h=this._size=yl(this,t),u=Object.assign({},l,this._size),d=vl(e,t,u),p=bl(t,u,d,e);(o._to!==p.x||a._to!==p.y)&&(this.xAlign=d.xAlign,this.yAlign=d.yAlign,this.width=h.width,this.height=h.height,this.caretX=l.x,this.caretY=l.y,this._resolveAnimations().update(this,p))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let s=this.opacity;if(!s)return;this._updateAnimationTarget(e);const o={width:this.width,height:this.height},a={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;const l=Rt(e.padding),h=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&h&&(t.save(),t.globalAlpha=s,this.drawBackground(a,t,o,e),vh(t,e.textDirection),a.y+=l.top,this.drawTitle(a,t,e),this.drawBody(a,t,e),this.drawFooter(a,t,e),bh(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const s=this._active,o=t.map(({datasetIndex:h,index:u})=>{const d=this.chart.getDatasetMeta(h);if(!d)throw new Error("Cannot find a dataset at index "+h);return{datasetIndex:h,element:d.data[u],index:u}}),a=!Vn(s,o),l=this._positionChanged(o,e);(a||l)&&(this._active=o,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,s=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const o=this.options,a=this._active||[],l=this._getActiveElements(t,a,e,s),h=this._positionChanged(l,t),u=e||!Vn(l,a)||h;return u&&(this._active=l,(o.enabled||o.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),u}_getActiveElements(t,e,s,o){const a=this.options;if(t.type==="mouseout")return[];if(!o)return e.filter(h=>this.chart.data.datasets[h.datasetIndex]&&this.chart.getDatasetMeta(h.datasetIndex).controller.getParsed(h.index)!==void 0);const l=this.chart.getElementsAtEventForMode(t,a.mode,a,s);return a.reverse&&l.reverse(),l}_positionChanged(t,e){const{caretX:s,caretY:o,options:a}=this,l=Fi[a.position].call(this,t,e);return l!==!1&&(s!==l.x||o!==l.y)}}var x_={id:"tooltip",_element:Pl,positioners:Fi,afterInit(i,t,e){e&&(i.tooltip=new Pl({chart:i,options:e}))},beforeUpdate(i,t,e){i.tooltip&&i.tooltip.initialize(e)},reset(i,t,e){i.tooltip&&i.tooltip.initialize(e)},afterDraw(i){const t=i.tooltip;if(t&&t._willRender()){const e={tooltip:t};if(i.notifyPlugins("beforeTooltipDraw",{...e,cancelable:!0})===!1)return;t.draw(i.ctx),i.notifyPlugins("afterTooltipDraw",e)}},afterEvent(i,t){if(i.tooltip){const e=t.replay;i.tooltip.handleEvent(t.event,e,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(i,t)=>t.bodyFont.size,boxWidth:(i,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Uh},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:i=>i!=="filter"&&i!=="itemSort"&&i!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},w_=Object.freeze({__proto__:null,Colors:Ig,Decimation:Ng,Filler:s_,Legend:c_,SubTitle:f_,Title:d_,Tooltip:x_});const P_=(i,t,e,s)=>(typeof t=="string"?(e=i.push(t)-1,s.unshift({index:e,label:t})):isNaN(t)&&(e=null),e);function k_(i,t,e,s){const o=i.indexOf(t);if(o===-1)return P_(i,t,e,s);const a=i.lastIndexOf(t);return o!==a?e:o}const S_=(i,t)=>i===null?null:Et(Math.round(i),0,t);function kl(i){const t=this.getLabels();return i>=0&&ie.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function L_(i,t){const e=[],{bounds:o,step:a,min:l,max:h,precision:u,count:d,maxTicks:p,maxDigits:g,includeBounds:_}=i,v=a||1,x=p-1,{min:b,max:P}=t,k=!Q(l),C=!Q(h),E=!Q(d),A=(P-b)/(g+1);let T=ya((P-b)/x/v)*v,D,R,B,N;if(T<1e-14&&!k&&!C)return[{value:b},{value:P}];N=Math.ceil(P/T)-Math.floor(b/T),N>x&&(T=ya(N*T/x/v)*v),Q(u)||(D=Math.pow(10,u),T=Math.ceil(T*D)/D),o==="ticks"?(R=Math.floor(b/T)*T,B=Math.ceil(P/T)*T):(R=b,B=P),k&&C&&a&&hf((h-l)/a,T/1e3)?(N=Math.round(Math.min((h-l)/T,p)),T=(h-l)/N,R=l,B=h):E?(R=k?l:R,B=C?h:B,N=d-1,T=(B-R)/N):(N=(B-R)/T,Zi(N,Math.round(N),T/1e3)?N=Math.round(N):N=Math.ceil(N));const $=Math.max(va(T),va(R));D=Math.pow(10,Q(u)?$:u),R=Math.round(R*D)/D,B=Math.round(B*D)/D;let W=0;for(k&&(_&&R!==l?(e.push({value:l}),Rh)break;e.push({value:j})}return C&&_&&B!==h?e.length&&Zi(e[e.length-1].value,h,Sl(h,A,i))?e[e.length-1].value=h:e.push({value:h}):(!C||B===h)&&e.push({value:B}),e}function Sl(i,t,{horizontal:e,minRotation:s}){const o=Xt(s),a=(e?Math.sin(o):Math.cos(o))||.001,l=.75*t*(""+i).length;return Math.min(t/a,l)}class Kn extends Xe{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,e){return Q(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:e,maxDefined:s}=this.getUserBounds();let{min:o,max:a}=this;const l=u=>o=e?o:u,h=u=>a=s?a:u;if(t){const u=ne(o),d=ne(a);u<0&&d<0?h(0):u>0&&d>0&&l(0)}if(o===a){let u=a===0?1:Math.abs(a*.05);h(a+u),t||l(o-u)}this.min=o,this.max=a}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:s}=t,o;return s?(o=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,o>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${o} ticks. Limiting to 1000.`),o=1e3)):(o=this.computeTickLimit(),e=e||11),e&&(o=Math.min(e,o)),o}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const o={maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==!1},a=this._range||this,l=L_(o,a);return t.bounds==="ticks"&&ih(l,this,"value"),t.reverse?(l.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),l}configure(){const t=this.ticks;let e=this.min,s=this.max;if(super.configure(),this.options.offset&&t.length){const o=(s-e)/Math.max(t.length-1,1)/2;e-=o,s+=o}this._startValue=e,this._endValue=s,this._valueRange=s-e}getLabelForValue(t){return Qi(t,this.chart.options.locale,this.options.ticks.format)}}class C_ extends Kn{static id="linear";static defaults={ticks:{callback:ts.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=bt(t)?t:0,this.max=bt(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,s=Xt(this.options.ticks.minRotation),o=(t?Math.sin(s):Math.cos(s))||.001,a=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,a.lineHeight/o))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Gi=i=>Math.floor(we(i)),Ze=(i,t)=>Math.pow(10,Gi(i)+t);function Ml(i){return i/Math.pow(10,Gi(i))===1}function Ll(i,t,e){const s=Math.pow(10,e),o=Math.floor(i/s);return Math.ceil(t/s)-o}function T_(i,t){const e=t-i;let s=Gi(e);for(;Ll(i,t,s)>10;)s++;for(;Ll(i,t,s)<10;)s--;return Math.min(s,Gi(i))}function E_(i,{min:t,max:e}){t=Wt(i.min,t);const s=[],o=Gi(t);let a=T_(t,e),l=a<0?Math.pow(10,Math.abs(a)):1;const h=Math.pow(10,a),u=o>a?Math.pow(10,o):0,d=Math.round((t-u)*l)/l,p=Math.floor((t-u)/h/10)*h*10;let g=Math.floor((d-p)/Math.pow(10,a)),_=Wt(i.min,Math.round((u+p+g*Math.pow(10,a))*l)/l);for(;_=10?g=g<15?15:20:g++,g>=20&&(a++,g=2,l=a>=0?1:l),_=Math.round((u+p+g*Math.pow(10,a))*l)/l;const v=Wt(i.max,_);return s.push({value:v,major:Ml(v),significand:g}),s}class A_ extends Xe{static id="logarithmic";static defaults={ticks:{callback:ts.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,e){const s=Kn.prototype.parse.apply(this,[t,e]);if(s===0){this._zero=!0;return}return bt(s)&&s>0?s:null}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=bt(t)?Math.max(0,t):null,this.max=bt(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!bt(this._userMin)&&(this.min=t===Ze(this.min,0)?Ze(this.min,-1):Ze(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let s=this.min,o=this.max;const a=h=>s=t?s:h,l=h=>o=e?o:h;s===o&&(s<=0?(a(1),l(10)):(a(Ze(s,-1)),l(Ze(o,1)))),s<=0&&a(Ze(o,-1)),o<=0&&l(Ze(s,1)),this.min=s,this.max=o}buildTicks(){const t=this.options,e={min:this._userMin,max:this._userMax},s=E_(e,this);return t.bounds==="ticks"&&ih(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}getLabelForValue(t){return t===void 0?"0":Qi(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=we(t),this._valueRange=we(this.max)-we(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(we(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function wo(i){const t=i.ticks;if(t.display&&i.display){const e=Rt(t.backdropPadding);return U(t.font&&t.font.size,gt.font.size)+e.height}return 0}function O_(i,t,e){return e=mt(e)?e:[e],{w:Mf(i,t.string,e),h:e.length*t.lineHeight}}function Cl(i,t,e,s,o){return i===s||i===o?{start:t-e/2,end:t+e/2}:io?{start:t-e,end:t}:{start:t,end:t+e}}function D_(i){const t={l:i.left+i._padding.left,r:i.right-i._padding.right,t:i.top+i._padding.top,b:i.bottom-i._padding.bottom},e=Object.assign({},t),s=[],o=[],a=i._pointLabels.length,l=i.options.pointLabels,h=l.centerPointLabels?lt/a:0;for(let u=0;ut.r&&(h=(s.end-t.r)/a,i.r=Math.max(i.r,t.r+h)),o.startt.b&&(u=(o.end-t.b)/l,i.b=Math.max(i.b,t.b+u))}function R_(i,t,e){const s=i.drawingArea,{extra:o,additionalAngle:a,padding:l,size:h}=e,u=i.getPointPosition(t,s+o+l,a),d=Math.round(Io(Dt(u.angle+Pt))),p=W_(u.y,h.h,d),g=N_(d),_=F_(u.x,h.w,g);return{visible:!0,x:u.x,y:p,textAlign:g,left:_,top:p,right:_+h.w,bottom:p+h.h}}function B_(i,t){if(!t)return!0;const{left:e,top:s,right:o,bottom:a}=i;return!(ge({x:e,y:s},t)||ge({x:e,y:a},t)||ge({x:o,y:s},t)||ge({x:o,y:a},t))}function z_(i,t,e){const s=[],o=i._pointLabels.length,a=i.options,{centerPointLabels:l,display:h}=a.pointLabels,u={extra:wo(a)/2,additionalAngle:l?lt/o:0};let d;for(let p=0;p270||e<90)&&(i-=t),i}function H_(i,t,e){const{left:s,top:o,right:a,bottom:l}=e,{backdropColor:h}=t;if(!Q(h)){const u=qe(t.borderRadius),d=Rt(t.backdropPadding);i.fillStyle=h;const p=s-d.left,g=o-d.top,_=a-s+d.width,v=l-o+d.height;Object.values(u).some(x=>x!==0)?(i.beginPath(),Xi(i,{x:p,y:g,w:_,h:v,radius:u}),i.fill()):i.fillRect(p,g,_,v)}}function Z_(i,t){const{ctx:e,options:{pointLabels:s}}=i;for(let o=t-1;o>=0;o--){const a=i._pointLabelItems[o];if(!a.visible)continue;const l=s.setContext(i.getPointLabelContext(o));H_(e,l,a);const h=Ct(l.font),{x:u,y:d,textAlign:p}=a;Ye(e,i._pointLabels[o],u,d+h.lineHeight/2,h,{color:l.color,textAlign:p,textBaseline:"middle"})}}function Yh(i,t,e,s){const{ctx:o}=i;if(e)o.arc(i.xCenter,i.yCenter,t,0,pt);else{let a=i.getPointPosition(0,t);o.moveTo(a.x,a.y);for(let l=1;l{const o=ft(this.options.pointLabels.callback,[e,s],this);return o||o===0?o:""}).filter((e,s)=>this.chart.getDataVisibility(s))}fit(){const t=this.options;t.display&&t.pointLabels.display?D_(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,s,o){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((s-o)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,s,o))}getIndexAngle(t){const e=pt/(this._pointLabels.length||1),s=this.options.startAngle||0;return Dt(t*e+Xt(s))}getDistanceFromCenterForValue(t){if(Q(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(Q(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t{if(g!==0||g===0&&this.min<0){u=this.getDistanceFromCenterForValue(p.value);const _=this.getContext(g),v=o.setContext(_),x=a.setContext(_);V_(this,v,u,l,x)}}),s.display){for(t.save(),h=l-1;h>=0;h--){const p=s.setContext(this.getPointLabelContext(h)),{color:g,lineWidth:_}=p;!_||!g||(t.lineWidth=_,t.strokeStyle=g,t.setLineDash(p.borderDash),t.lineDashOffset=p.borderDashOffset,u=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max),d=this.getPointPosition(h,u),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(d.x,d.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,s=e.ticks;if(!s.display)return;const o=this.getIndexAngle(0);let a,l;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(o),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((h,u)=>{if(u===0&&this.min>=0&&!e.reverse)return;const d=s.setContext(this.getContext(u)),p=Ct(d.font);if(a=this.getDistanceFromCenterForValue(this.ticks[u].value),d.showLabelBackdrop){t.font=p.string,l=t.measureText(h.label).width,t.fillStyle=d.backdropColor;const g=Rt(d.backdropPadding);t.fillRect(-l/2-g.left,-a-p.size/2-g.top,l+g.width,p.size+g.height)}Ye(t,h.label,0,-a,p,{color:d.color,strokeColor:d.textStrokeColor,strokeWidth:d.textStrokeWidth})}),t.restore()}drawTitle(){}}const as={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Ft=Object.keys(as);function Tl(i,t){return i-t}function El(i,t){if(Q(t))return null;const e=i._adapter,{parser:s,round:o,isoWeekday:a}=i._parseOpts;let l=t;return typeof s=="function"&&(l=s(l)),bt(l)||(l=typeof s=="string"?e.parse(l,s):e.parse(l)),l===null?null:(o&&(l=o==="week"&&(ci(a)||a===!0)?e.startOf(l,"isoWeek",a):e.startOf(l,o)),+l)}function Al(i,t,e,s){const o=Ft.length;for(let a=Ft.indexOf(i);a=Ft.indexOf(e);a--){const l=Ft[a];if(as[l].common&&i._adapter.diff(o,s,l)>=t-1)return l}return Ft[e?Ft.indexOf(e):0]}function U_(i){for(let t=Ft.indexOf(i)+1,e=Ft.length;t=t?e[s]:e[o];i[a]=!0}}function Y_(i,t,e,s){const o=i._adapter,a=+o.startOf(t[0].value,s),l=t[t.length-1].value;let h,u;for(h=a;h<=l;h=+o.add(h,1,s))u=e[h],u>=0&&(t[u].major=!0);return t}function Dl(i,t,e){const s=[],o={},a=t.length;let l,h;for(l=0;l+t.value))}initOffsets(t=[]){let e=0,s=0,o,a;this.options.offset&&t.length&&(o=this.getDecimalForValue(t[0]),t.length===1?e=1-o:e=(this.getDecimalForValue(t[1])-o)/2,a=this.getDecimalForValue(t[t.length-1]),t.length===1?s=a:s=(a-this.getDecimalForValue(t[t.length-2]))/2);const l=t.length<3?.5:.25;e=Et(e,0,l),s=Et(s,0,l),this._offsets={start:e,end:s,factor:1/(e+1+s)}}_generate(){const t=this._adapter,e=this.min,s=this.max,o=this.options,a=o.time,l=a.unit||Al(a.minUnit,e,s,this._getLabelCapacity(e)),h=U(o.ticks.stepSize,1),u=l==="week"?a.isoWeekday:!1,d=ci(u)||u===!0,p={};let g=e,_,v;if(d&&(g=+t.startOf(g,"isoWeek",u)),g=+t.startOf(g,d?"day":l),t.diff(s,e,l)>1e5*h)throw new Error(e+" and "+s+" are too far apart with stepSize of "+h+" "+l);const x=o.ticks.source==="data"&&this.getDataTimestamps();for(_=g,v=0;_+b)}getLabelForValue(t){const e=this._adapter,s=this.options.time;return s.tooltipFormat?e.format(t,s.tooltipFormat):e.format(t,s.displayFormats.datetime)}format(t,e){const o=this.options.time.displayFormats,a=this._unit,l=e||o[a];return this._adapter.format(t,l)}_tickFormatFunction(t,e,s,o){const a=this.options,l=a.ticks.callback;if(l)return ft(l,[t,e,s],this);const h=a.time.displayFormats,u=this._unit,d=this._majorUnit,p=u&&h[u],g=d&&h[d],_=s[e],v=d&&g&&_&&_.major;return this._adapter.format(t,o||(v?g:p))}generateTickLabels(t){let e,s,o;for(e=0,s=t.length;e0?h:1}getDataTimestamps(){let t=this._cache.data||[],e,s;if(t.length)return t;const o=this.getMatchingVisibleMetas();if(this._normalized&&o.length)return this._cache.data=o[0].controller.getAllParsedValues(this);for(e=0,s=o.length;e=i[s].pos&&t<=i[o].pos&&({lo:s,hi:o}=me(i,"pos",t)),{pos:a,time:h}=i[s],{pos:l,time:u}=i[o]):(t>=i[s].time&&t<=i[o].time&&({lo:s,hi:o}=me(i,"time",t)),{time:a,pos:h}=i[s],{time:l,pos:u}=i[o]);const d=l-a;return d?h+(u-h)*(t-a)/d:h}class X_ extends Po{static id="timeseries";static defaults=Po.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),e=this._table=this.buildLookupTable(t);this._minPos=In(e,this.min),this._tableRange=In(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:s}=this,o=[],a=[];let l,h,u,d,p;for(l=0,h=t.length;l=e&&d<=s&&o.push(d);if(o.length<2)return[{time:e,pos:0},{time:s,pos:1}];for(l=0,h=o.length;lo-a)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),s=this.getLabelTimestamps();return e.length&&s.length?t=this.normalize(e.concat(s)):t=e.length?e:s,t=this._cache.all=t,t}getDecimalForValue(t){return(In(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,s=this.getDecimalForPixel(t)/e.factor-e.end;return In(this._table,s*this._tableRange+this._minPos,!0)}}var K_=Object.freeze({__proto__:null,CategoryScale:M_,LinearScale:C_,LogarithmicScale:A_,RadialLinearScale:q_,TimeScale:Po,TimeSeriesScale:X_});const G_=[Yp,Lg,w_,K_];$o.register(...G_);let oo=null;function J_(i,t){const e=document.getElementById(i);if(!e)return;oo&&oo.destroy();const s=t*100,o=Array.from({length:8},(l,h)=>{const u=(Math.random()-.5)*8;return Math.max(5,Math.min(95,s-12+h/7*12+u))});o[o.length-1]=s;const a=s>50?"#22d37a":s<40?"#f04040":"#f0a020";oo=new $o(e,{type:"line",data:{labels:["7d","6d","5d","4d","3d","2d","1d","now"],datasets:[{data:o,borderColor:a,borderWidth:1.5,pointRadius:0,fill:!1,tension:.4}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1}},animation:{duration:600}}})}function Il(i,t,e){const s=document.getElementById(i);if(!s)return;s.innerHTML="",s.className="sparkline";const o=t*100;for(let l=0;l<12;l++){const h=Math.max(4,Math.min(24,o/4+(Math.random()-.5)*8)),u=document.createElement("div");u.className="spark-bar",u.style.height=h+"px",u.style.background=e==="yes"?"#0d6e3a":"#7a1a1a",s.appendChild(u)}const a=document.createElement("div");a.className="spark-bar",a.style.height=Math.min(28,o/3.5)+"px",a.style.background=e==="yes"?"#22d37a":"#f04040",s.appendChild(a)}function Q_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Wi={exports:{}};var ty=Wi.exports,Rl;function ey(){return Rl||(Rl=1,(function(i,t){(function(e,s){s(t)})(ty,(function(e){var s="1.9.4";function o(n){var r,c,f,m;for(c=1,f=arguments.length;c"u"||!L||!L.Mixin)){n=E(n)?n:[n];for(var r=0;r0?Math.floor(n):Math.ceil(n)};F.prototype={clone:function(){return new F(this.x,this.y)},add:function(n){return this.clone()._add(Z(n))},_add:function(n){return this.x+=n.x,this.y+=n.y,this},subtract:function(n){return this.clone()._subtract(Z(n))},_subtract:function(n){return this.x-=n.x,this.y-=n.y,this},divideBy:function(n){return this.clone()._divideBy(n)},_divideBy:function(n){return this.x/=n,this.y/=n,this},multiplyBy:function(n){return this.clone()._multiplyBy(n)},_multiplyBy:function(n){return this.x*=n,this.y*=n,this},scaleBy:function(n){return new F(this.x*n.x,this.y*n.y)},unscaleBy:function(n){return new F(this.x/n.x,this.y/n.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=_t(this.x),this.y=_t(this.y),this},distanceTo:function(n){n=Z(n);var r=n.x-this.x,c=n.y-this.y;return Math.sqrt(r*r+c*c)},equals:function(n){return n=Z(n),n.x===this.x&&n.y===this.y},contains:function(n){return n=Z(n),Math.abs(n.x)<=Math.abs(this.x)&&Math.abs(n.y)<=Math.abs(this.y)},toString:function(){return"Point("+_(this.x)+", "+_(this.y)+")"}};function Z(n,r,c){return n instanceof F?n:E(n)?new F(n[0],n[1]):n==null?n:typeof n=="object"&&"x"in n&&"y"in n?new F(n.x,n.y):new F(n,r,c)}function it(n,r){if(n)for(var c=r?[n,r]:n,f=0,m=c.length;f=this.min.x&&c.x<=this.max.x&&r.y>=this.min.y&&c.y<=this.max.y},intersects:function(n){n=xt(n);var r=this.min,c=this.max,f=n.min,m=n.max,y=m.x>=r.x&&f.x<=c.x,w=m.y>=r.y&&f.y<=c.y;return y&&w},overlaps:function(n){n=xt(n);var r=this.min,c=this.max,f=n.min,m=n.max,y=m.x>r.x&&f.xr.y&&f.y=r.lat&&m.lat<=c.lat&&f.lng>=r.lng&&m.lng<=c.lng},intersects:function(n){n=ct(n);var r=this._southWest,c=this._northEast,f=n.getSouthWest(),m=n.getNorthEast(),y=m.lat>=r.lat&&f.lat<=c.lat,w=m.lng>=r.lng&&f.lng<=c.lng;return y&&w},overlaps:function(n){n=ct(n);var r=this._southWest,c=this._northEast,f=n.getSouthWest(),m=n.getNorthEast(),y=m.lat>r.lat&&f.latr.lng&&f.lng1,_c=(function(){var n=!1;try{var r=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("testPassiveEventSupport",g,r),window.removeEventListener("testPassiveEventSupport",g,r)}catch{}return n})(),yc=(function(){return!!document.createElement("canvas").getContext})(),ms=!!(document.createElementNS&&Go("svg").createSVGRect),vc=!!ms&&(function(){var n=document.createElement("div");return n.innerHTML="",(n.firstChild&&n.firstChild.namespaceURI)==="http://www.w3.org/2000/svg"})(),bc=!ms&&(function(){try{var n=document.createElement("div");n.innerHTML='';var r=n.firstChild;return r.style.behavior="url(#default#VML)",r&&typeof r.adj=="object"}catch{return!1}})(),xc=navigator.platform.indexOf("Mac")===0,wc=navigator.platform.indexOf("Linux")===0;function Kt(n){return navigator.userAgent.toLowerCase().indexOf(n)>=0}var H={ie:tn,ielt9:oc,edge:Qo,webkit:ds,android:tr,android23:er,androidStock:ac,opera:fs,chrome:ir,gecko:nr,safari:lc,phantom:sr,opera12:or,win:hc,ie3d:rr,webkit3d:ps,gecko3d:ar,any3d:cc,mobile:mi,mobileWebkit:uc,mobileWebkit3d:dc,msPointer:lr,pointer:hr,touch:fc,touchNative:cr,mobileOpera:pc,mobileGecko:mc,retina:gc,passiveEvents:_c,canvas:yc,svg:ms,vml:bc,inlineSvg:vc,mac:xc,linux:wc},ur=H.msPointer?"MSPointerDown":"pointerdown",dr=H.msPointer?"MSPointerMove":"pointermove",fr=H.msPointer?"MSPointerUp":"pointerup",pr=H.msPointer?"MSPointerCancel":"pointercancel",gs={touchstart:ur,touchmove:dr,touchend:fr,touchcancel:pr},mr={touchstart:Cc,touchmove:en,touchend:en,touchcancel:en},Ke={},gr=!1;function Pc(n,r,c){return r==="touchstart"&&Lc(),mr[r]?(c=mr[r].bind(this,c),n.addEventListener(gs[r],c,!1),c):(console.warn("wrong event specified:",r),g)}function kc(n,r,c){if(!gs[r]){console.warn("wrong event specified:",r);return}n.removeEventListener(gs[r],c,!1)}function Sc(n){Ke[n.pointerId]=n}function Mc(n){Ke[n.pointerId]&&(Ke[n.pointerId]=n)}function _r(n){delete Ke[n.pointerId]}function Lc(){gr||(document.addEventListener(ur,Sc,!0),document.addEventListener(dr,Mc,!0),document.addEventListener(fr,_r,!0),document.addEventListener(pr,_r,!0),gr=!0)}function en(n,r){if(r.pointerType!==(r.MSPOINTER_TYPE_MOUSE||"mouse")){r.touches=[];for(var c in Ke)r.touches.push(Ke[c]);r.changedTouches=[r],n(r)}}function Cc(n,r){r.MSPOINTER_TYPE_TOUCH&&r.pointerType===r.MSPOINTER_TYPE_TOUCH&&At(r),en(n,r)}function Tc(n){var r={},c,f;for(f in n)c=n[f],r[f]=c&&c.bind?c.bind(n):c;return n=r,r.type="dblclick",r.detail=2,r.isTrusted=!1,r._simulated=!0,r}var Ec=200;function Ac(n,r){n.addEventListener("dblclick",r);var c=0,f;function m(y){if(y.detail!==1){f=y.detail;return}if(!(y.pointerType==="mouse"||y.sourceCapabilities&&!y.sourceCapabilities.firesTouchEvents)){var w=wr(y);if(!(w.some(function(M){return M instanceof HTMLLabelElement&&M.attributes.for})&&!w.some(function(M){return M instanceof HTMLInputElement||M instanceof HTMLSelectElement}))){var S=Date.now();S-c<=Ec?(f++,f===2&&r(Tc(y))):f=1,c=S}}}return n.addEventListener("click",m),{dblclick:r,simDblclick:m}}function Oc(n,r){n.removeEventListener("dblclick",r.dblclick),n.removeEventListener("click",r.simDblclick)}var _s=on(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),gi=on(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),yr=gi==="webkitTransition"||gi==="OTransition"?gi+"End":"transitionend";function vr(n){return typeof n=="string"?document.getElementById(n):n}function _i(n,r){var c=n.style[r]||n.currentStyle&&n.currentStyle[r];if((!c||c==="auto")&&document.defaultView){var f=document.defaultView.getComputedStyle(n,null);c=f?f[r]:null}return c==="auto"?null:c}function at(n,r,c){var f=document.createElement(n);return f.className=r||"",c&&c.appendChild(f),f}function yt(n){var r=n.parentNode;r&&r.removeChild(n)}function nn(n){for(;n.firstChild;)n.removeChild(n.firstChild)}function Ge(n){var r=n.parentNode;r&&r.lastChild!==n&&r.appendChild(n)}function Je(n){var r=n.parentNode;r&&r.firstChild!==n&&r.insertBefore(n,r.firstChild)}function ys(n,r){if(n.classList!==void 0)return n.classList.contains(r);var c=sn(n);return c.length>0&&new RegExp("(^|\\s)"+r+"(\\s|$)").test(c)}function G(n,r){if(n.classList!==void 0)for(var c=x(r),f=0,m=c.length;f0?2*window.devicePixelRatio:1;function kr(n){return H.edge?n.wheelDeltaY/2:n.deltaY&&n.deltaMode===0?-n.deltaY/Rc:n.deltaY&&n.deltaMode===1?-n.deltaY*20:n.deltaY&&n.deltaMode===2?-n.deltaY*60:n.deltaX||n.deltaZ?0:n.wheelDelta?(n.wheelDeltaY||n.wheelDelta)/2:n.detail&&Math.abs(n.detail)<32765?-n.detail*20:n.detail?n.detail/-32765*60:0}function Es(n,r){var c=r.relatedTarget;if(!c)return!0;try{for(;c&&c!==n;)c=c.parentNode}catch{return!1}return c!==n}var Bc={__proto__:null,on:X,off:dt,stopPropagation:Be,disableScrollPropagation:Ts,disableClickPropagation:xi,preventDefault:At,stop:ze,getPropagationPath:wr,getMousePosition:Pr,getWheelDelta:kr,isExternalTarget:Es,addListener:X,removeListener:dt},Sr=tt.extend({run:function(n,r,c,f){this.stop(),this._el=n,this._inProgress=!0,this._duration=c||.25,this._easeOutPower=1/Math.max(f||.5,.2),this._startPos=Re(n),this._offset=r.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=W(this._animate,this),this._step()},_step:function(n){var r=+new Date-this._startTime,c=this._duration*1e3;rthis.options.maxZoom)?this.setZoom(n):this},panInsideBounds:function(n,r){this._enforcingBounds=!0;var c=this.getCenter(),f=this._limitCenter(c,this._zoom,ct(n));return c.equals(f)||this.panTo(f,r),this._enforcingBounds=!1,this},panInside:function(n,r){r=r||{};var c=Z(r.paddingTopLeft||r.padding||[0,0]),f=Z(r.paddingBottomRight||r.padding||[0,0]),m=this.project(this.getCenter()),y=this.project(n),w=this.getPixelBounds(),S=xt([w.min.add(c),w.max.subtract(f)]),M=S.getSize();if(!S.contains(y)){this._enforcingBounds=!0;var O=y.subtract(S.getCenter()),z=S.extend(y).getSize().subtract(M);m.x+=O.x<0?-z.x:z.x,m.y+=O.y<0?-z.y:z.y,this.panTo(this.unproject(m),r),this._enforcingBounds=!1}return this},invalidateSize:function(n){if(!this._loaded)return this;n=o({animate:!1,pan:!0},n===!0?{animate:!0}:n);var r=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var c=this.getSize(),f=r.divideBy(2).round(),m=c.divideBy(2).round(),y=f.subtract(m);return!y.x&&!y.y?this:(n.animate&&n.pan?this.panBy(y):(n.pan&&this._rawPanBy(y),this.fire("move"),n.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(l(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:r,newSize:c}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(n){if(n=this._locateOptions=o({timeout:1e4,watch:!1},n),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var r=l(this._handleGeolocationResponse,this),c=l(this._handleGeolocationError,this);return n.watch?this._locationWatchId=navigator.geolocation.watchPosition(r,c,n):navigator.geolocation.getCurrentPosition(r,c,n),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(n){if(this._container._leaflet_id){var r=n.code,c=n.message||(r===1?"permission denied":r===2?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:r,message:"Geolocation error: "+c+"."})}},_handleGeolocationResponse:function(n){if(this._container._leaflet_id){var r=n.coords.latitude,c=n.coords.longitude,f=new st(r,c),m=f.toBounds(n.coords.accuracy*2),y=this._locateOptions;if(y.setView){var w=this.getBoundsZoom(m);this.setView(f,y.maxZoom?Math.min(w,y.maxZoom):w)}var S={latlng:f,bounds:m,timestamp:n.timestamp};for(var M in n.coords)typeof n.coords[M]=="number"&&(S[M]=n.coords[M]);this.fire("locationfound",S)}},addHandler:function(n,r){if(!r)return this;var c=this[n]=new r(this);return this._handlers.push(c),this.options[n]&&c.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),yt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(j(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload");var n;for(n in this._layers)this._layers[n].remove();for(n in this._panes)yt(this._panes[n]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(n,r){var c="leaflet-pane"+(n?" leaflet-"+n.replace("Pane","")+"-pane":""),f=at("div",c,r||this._mapPane);return n&&(this._panes[n]=f),f},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var n=this.getPixelBounds(),r=this.unproject(n.getBottomLeft()),c=this.unproject(n.getTopRight());return new kt(r,c)},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(n,r,c){n=ct(n),c=Z(c||[0,0]);var f=this.getZoom()||0,m=this.getMinZoom(),y=this.getMaxZoom(),w=n.getNorthWest(),S=n.getSouthEast(),M=this.getSize().subtract(c),O=xt(this.project(S,f),this.project(w,f)).getSize(),z=H.any3d?this.options.zoomSnap:1,q=M.x/O.x,J=M.y/O.y,Bt=r?Math.max(q,J):Math.min(q,J);return f=this.getScaleZoom(Bt,f),z&&(f=Math.round(f/(z/100))*(z/100),f=r?Math.ceil(f/z)*z:Math.floor(f/z)*z),Math.max(m,Math.min(y,f))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new F(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(n,r){var c=this._getTopLeftPoint(n,r);return new it(c,c.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(n){return this.options.crs.getProjectedBounds(n===void 0?this.getZoom():n)},getPane:function(n){return typeof n=="string"?this._panes[n]:n},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(n,r){var c=this.options.crs;return r=r===void 0?this._zoom:r,c.scale(n)/c.scale(r)},getScaleZoom:function(n,r){var c=this.options.crs;r=r===void 0?this._zoom:r;var f=c.zoom(n*c.scale(r));return isNaN(f)?1/0:f},project:function(n,r){return r=r===void 0?this._zoom:r,this.options.crs.latLngToPoint(Y(n),r)},unproject:function(n,r){return r=r===void 0?this._zoom:r,this.options.crs.pointToLatLng(Z(n),r)},layerPointToLatLng:function(n){var r=Z(n).add(this.getPixelOrigin());return this.unproject(r)},latLngToLayerPoint:function(n){var r=this.project(Y(n))._round();return r._subtract(this.getPixelOrigin())},wrapLatLng:function(n){return this.options.crs.wrapLatLng(Y(n))},wrapLatLngBounds:function(n){return this.options.crs.wrapLatLngBounds(ct(n))},distance:function(n,r){return this.options.crs.distance(Y(n),Y(r))},containerPointToLayerPoint:function(n){return Z(n).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(n){return Z(n).add(this._getMapPanePos())},containerPointToLatLng:function(n){var r=this.containerPointToLayerPoint(Z(n));return this.layerPointToLatLng(r)},latLngToContainerPoint:function(n){return this.layerPointToContainerPoint(this.latLngToLayerPoint(Y(n)))},mouseEventToContainerPoint:function(n){return Pr(n,this._container)},mouseEventToLayerPoint:function(n){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(n))},mouseEventToLatLng:function(n){return this.layerPointToLatLng(this.mouseEventToLayerPoint(n))},_initContainer:function(n){var r=this._container=vr(n);if(r){if(r._leaflet_id)throw new Error("Map container is already initialized.")}else throw new Error("Map container not found.");X(r,"scroll",this._onScroll,this),this._containerId=u(r)},_initLayout:function(){var n=this._container;this._fadeAnimated=this.options.fadeAnimation&&H.any3d,G(n,"leaflet-container"+(H.touch?" leaflet-touch":"")+(H.retina?" leaflet-retina":"")+(H.ielt9?" leaflet-oldie":"")+(H.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var r=_i(n,"position");r!=="absolute"&&r!=="relative"&&r!=="fixed"&&r!=="sticky"&&(n.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var n=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),St(this._mapPane,new F(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(G(n.markerPane,"leaflet-zoom-hide"),G(n.shadowPane,"leaflet-zoom-hide"))},_resetView:function(n,r,c){St(this._mapPane,new F(0,0));var f=!this._loaded;this._loaded=!0,r=this._limitZoom(r),this.fire("viewprereset");var m=this._zoom!==r;this._moveStart(m,c)._move(n,r)._moveEnd(m),this.fire("viewreset"),f&&this.fire("load")},_moveStart:function(n,r){return n&&this.fire("zoomstart"),r||this.fire("movestart"),this},_move:function(n,r,c,f){r===void 0&&(r=this._zoom);var m=this._zoom!==r;return this._zoom=r,this._lastCenter=n,this._pixelOrigin=this._getNewPixelOrigin(n),f?c&&c.pinch&&this.fire("zoom",c):((m||c&&c.pinch)&&this.fire("zoom",c),this.fire("move",c)),this},_moveEnd:function(n){return n&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return j(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(n){St(this._mapPane,this._getMapPanePos().subtract(n))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(n){this._targets={},this._targets[u(this._container)]=this;var r=n?dt:X;r(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&r(window,"resize",this._onResize,this),H.any3d&&this.options.transform3DLimit&&(n?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){j(this._resizeRequest),this._resizeRequest=W(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var n=this._getMapPanePos();Math.max(Math.abs(n.x),Math.abs(n.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(n,r){for(var c=[],f,m=r==="mouseout"||r==="mouseover",y=n.target||n.srcElement,w=!1;y;){if(f=this._targets[u(y)],f&&(r==="click"||r==="preclick")&&this._draggableMoved(f)){w=!0;break}if(f&&f.listens(r,!0)&&(m&&!Es(y,n)||(c.push(f),m))||y===this._container)break;y=y.parentNode}return!c.length&&!w&&!m&&this.listens(r,!0)&&(c=[this]),c},_isClickDisabled:function(n){for(;n&&n!==this._container;){if(n._leaflet_disable_click)return!0;n=n.parentNode}},_handleDOMEvent:function(n){var r=n.target||n.srcElement;if(!(!this._loaded||r._leaflet_disable_events||n.type==="click"&&this._isClickDisabled(r))){var c=n.type;c==="mousedown"&&ks(r),this._fireDOMEvent(n,c)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(n,r,c){if(n.type==="click"){var f=o({},n);f.type="preclick",this._fireDOMEvent(f,f.type,c)}var m=this._findEventTargets(n,r);if(c){for(var y=[],w=0;w0?Math.round(n-r)/2:Math.max(0,Math.ceil(n))-Math.max(0,Math.floor(r))},_limitZoom:function(n){var r=this.getMinZoom(),c=this.getMaxZoom(),f=H.any3d?this.options.zoomSnap:1;return f&&(n=Math.round(n/f)*f),Math.max(r,Math.min(c,n))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){wt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(n,r){var c=this._getCenterOffset(n)._trunc();return(r&&r.animate)!==!0&&!this.getSize().contains(c)?!1:(this.panBy(c,r),!0)},_createAnimProxy:function(){var n=this._proxy=at("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(n),this.on("zoomanim",function(r){var c=_s,f=this._proxy.style[c];Ie(this._proxy,this.project(r.center,r.zoom),this.getZoomScale(r.zoom,1)),f===this._proxy.style[c]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){yt(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var n=this.getCenter(),r=this.getZoom();Ie(this._proxy,this.project(n,r),this.getZoomScale(r,1))},_catchTransitionEnd:function(n){this._animatingZoom&&n.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(n,r,c){if(this._animatingZoom)return!0;if(c=c||{},!this._zoomAnimated||c.animate===!1||this._nothingToAnimate()||Math.abs(r-this._zoom)>this.options.zoomAnimationThreshold)return!1;var f=this.getZoomScale(r),m=this._getCenterOffset(n)._divideBy(1-1/f);return c.animate!==!0&&!this.getSize().contains(m)?!1:(W(function(){this._moveStart(!0,c.noMoveStart||!1)._animateZoom(n,r,!0)},this),!0)},_animateZoom:function(n,r,c,f){this._mapPane&&(c&&(this._animatingZoom=!0,this._animateToCenter=n,this._animateToZoom=r,G(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:n,zoom:r,noUpdate:f}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(l(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&wt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function zc(n,r){return new ot(n,r)}var $t=ut.extend({options:{position:"topright"},initialize:function(n){b(this,n)},getPosition:function(){return this.options.position},setPosition:function(n){var r=this._map;return r&&r.removeControl(this),this.options.position=n,r&&r.addControl(this),this},getContainer:function(){return this._container},addTo:function(n){this.remove(),this._map=n;var r=this._container=this.onAdd(n),c=this.getPosition(),f=n._controlCorners[c];return G(r,"leaflet-control"),c.indexOf("bottom")!==-1?f.insertBefore(r,f.firstChild):f.appendChild(r),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(yt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(n){this._map&&n&&n.screenX>0&&n.screenY>0&&this._map.getContainer().focus()}}),wi=function(n){return new $t(n)};ot.include({addControl:function(n){return n.addTo(this),this},removeControl:function(n){return n.remove(),this},_initControlPos:function(){var n=this._controlCorners={},r="leaflet-",c=this._controlContainer=at("div",r+"control-container",this._container);function f(m,y){var w=r+m+" "+r+y;n[m+y]=at("div",w,c)}f("top","left"),f("top","right"),f("bottom","left"),f("bottom","right")},_clearControlPos:function(){for(var n in this._controlCorners)yt(this._controlCorners[n]);yt(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var Mr=$t.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(n,r,c,f){return c1,this._baseLayersList.style.display=n?"":"none"),this._separator.style.display=r&&n?"":"none",this},_onLayerChange:function(n){this._handlingClick||this._update();var r=this._getLayer(u(n.target)),c=r.overlay?n.type==="add"?"overlayadd":"overlayremove":n.type==="add"?"baselayerchange":null;c&&this._map.fire(c,r)},_createRadioElement:function(n,r){var c='",f=document.createElement("div");return f.innerHTML=c,f.firstChild},_addItem:function(n){var r=document.createElement("label"),c=this._map.hasLayer(n.layer),f;n.overlay?(f=document.createElement("input"),f.type="checkbox",f.className="leaflet-control-layers-selector",f.defaultChecked=c):f=this._createRadioElement("leaflet-base-layers_"+u(this),c),this._layerControlInputs.push(f),f.layerId=u(n.layer),X(f,"click",this._onInputClick,this);var m=document.createElement("span");m.innerHTML=" "+n.name;var y=document.createElement("span");r.appendChild(y),y.appendChild(f),y.appendChild(m);var w=n.overlay?this._overlaysList:this._baseLayersList;return w.appendChild(r),this._checkDisabledLayers(),r},_onInputClick:function(){if(!this._preventClick){var n=this._layerControlInputs,r,c,f=[],m=[];this._handlingClick=!0;for(var y=n.length-1;y>=0;y--)r=n[y],c=this._getLayer(r.layerId).layer,r.checked?f.push(c):r.checked||m.push(c);for(y=0;y=0;m--)r=n[m],c=this._getLayer(r.layerId).layer,r.disabled=c.options.minZoom!==void 0&&fc.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var n=this._section;this._preventClick=!0,X(n,"click",At),this.expand();var r=this;setTimeout(function(){dt(n,"click",At),r._preventClick=!1})}}),Nc=function(n,r,c){return new Mr(n,r,c)},As=$t.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(n){var r="leaflet-control-zoom",c=at("div",r+" leaflet-bar"),f=this.options;return this._zoomInButton=this._createButton(f.zoomInText,f.zoomInTitle,r+"-in",c,this._zoomIn),this._zoomOutButton=this._createButton(f.zoomOutText,f.zoomOutTitle,r+"-out",c,this._zoomOut),this._updateDisabled(),n.on("zoomend zoomlevelschange",this._updateDisabled,this),c},onRemove:function(n){n.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(n){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(n.shiftKey?3:1))},_createButton:function(n,r,c,f,m){var y=at("a",c,f);return y.innerHTML=n,y.href="#",y.title=r,y.setAttribute("role","button"),y.setAttribute("aria-label",r),xi(y),X(y,"click",ze),X(y,"click",m,this),X(y,"click",this._refocusOnMap,this),y},_updateDisabled:function(){var n=this._map,r="leaflet-disabled";wt(this._zoomInButton,r),wt(this._zoomOutButton,r),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||n._zoom===n.getMinZoom())&&(G(this._zoomOutButton,r),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||n._zoom===n.getMaxZoom())&&(G(this._zoomInButton,r),this._zoomInButton.setAttribute("aria-disabled","true"))}});ot.mergeOptions({zoomControl:!0}),ot.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new As,this.addControl(this.zoomControl))});var Fc=function(n){return new As(n)},Lr=$t.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(n){var r="leaflet-control-scale",c=at("div",r),f=this.options;return this._addScales(f,r+"-line",c),n.on(f.updateWhenIdle?"moveend":"move",this._update,this),n.whenReady(this._update,this),c},onRemove:function(n){n.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(n,r,c){n.metric&&(this._mScale=at("div",r,c)),n.imperial&&(this._iScale=at("div",r,c))},_update:function(){var n=this._map,r=n.getSize().y/2,c=n.distance(n.containerPointToLatLng([0,r]),n.containerPointToLatLng([this.options.maxWidth,r]));this._updateScales(c)},_updateScales:function(n){this.options.metric&&n&&this._updateMetric(n),this.options.imperial&&n&&this._updateImperial(n)},_updateMetric:function(n){var r=this._getRoundNum(n),c=r<1e3?r+" m":r/1e3+" km";this._updateScale(this._mScale,c,r/n)},_updateImperial:function(n){var r=n*3.2808399,c,f,m;r>5280?(c=r/5280,f=this._getRoundNum(c),this._updateScale(this._iScale,f+" mi",f/c)):(m=this._getRoundNum(r),this._updateScale(this._iScale,m+" ft",m/r))},_updateScale:function(n,r,c){n.style.width=Math.round(this.options.maxWidth*c)+"px",n.innerHTML=r},_getRoundNum:function(n){var r=Math.pow(10,(Math.floor(n)+"").length-1),c=n/r;return c=c>=10?10:c>=5?5:c>=3?3:c>=2?2:1,r*c}}),Wc=function(n){return new Lr(n)},Hc='',Os=$t.extend({options:{position:"bottomright",prefix:''+(H.inlineSvg?Hc+" ":"")+"Leaflet"},initialize:function(n){b(this,n),this._attributions={}},onAdd:function(n){n.attributionControl=this,this._container=at("div","leaflet-control-attribution"),xi(this._container);for(var r in n._layers)n._layers[r].getAttribution&&this.addAttribution(n._layers[r].getAttribution());return this._update(),n.on("layeradd",this._addAttribution,this),this._container},onRemove:function(n){n.off("layeradd",this._addAttribution,this)},_addAttribution:function(n){n.layer.getAttribution&&(this.addAttribution(n.layer.getAttribution()),n.layer.once("remove",function(){this.removeAttribution(n.layer.getAttribution())},this))},setPrefix:function(n){return this.options.prefix=n,this._update(),this},addAttribution:function(n){return n?(this._attributions[n]||(this._attributions[n]=0),this._attributions[n]++,this._update(),this):this},removeAttribution:function(n){return n?(this._attributions[n]&&(this._attributions[n]--,this._update()),this):this},_update:function(){if(this._map){var n=[];for(var r in this._attributions)this._attributions[r]&&n.push(r);var c=[];this.options.prefix&&c.push(this.options.prefix),n.length&&c.push(n.join(", ")),this._container.innerHTML=c.join(' ')}}});ot.mergeOptions({attributionControl:!0}),ot.addInitHook(function(){this.options.attributionControl&&new Os().addTo(this)});var Zc=function(n){return new Os(n)};$t.Layers=Mr,$t.Zoom=As,$t.Scale=Lr,$t.Attribution=Os,wi.layers=Nc,wi.zoom=Fc,wi.scale=Wc,wi.attribution=Zc;var Jt=ut.extend({initialize:function(n){this._map=n},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});Jt.addTo=function(n,r){return n.addHandler(r,this),this};var Vc={Events:K},Cr=H.touch?"touchstart mousedown":"mousedown",ve=tt.extend({options:{clickTolerance:3},initialize:function(n,r,c,f){b(this,f),this._element=n,this._dragStartTarget=r||n,this._preventOutline=c},enable:function(){this._enabled||(X(this._dragStartTarget,Cr,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(ve._dragging===this&&this.finishDrag(!0),dt(this._dragStartTarget,Cr,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(n){if(this._enabled&&(this._moved=!1,!ys(this._element,"leaflet-zoom-anim"))){if(n.touches&&n.touches.length!==1){ve._dragging===this&&this.finishDrag();return}if(!(ve._dragging||n.shiftKey||n.which!==1&&n.button!==1&&!n.touches)&&(ve._dragging=this,this._preventOutline&&ks(this._element),xs(),yi(),!this._moving)){this.fire("down");var r=n.touches?n.touches[0]:n,c=br(this._element);this._startPoint=new F(r.clientX,r.clientY),this._startPos=Re(this._element),this._parentScale=Ss(c);var f=n.type==="mousedown";X(document,f?"mousemove":"touchmove",this._onMove,this),X(document,f?"mouseup":"touchend touchcancel",this._onUp,this)}}},_onMove:function(n){if(this._enabled){if(n.touches&&n.touches.length>1){this._moved=!0;return}var r=n.touches&&n.touches.length===1?n.touches[0]:n,c=new F(r.clientX,r.clientY)._subtract(this._startPoint);!c.x&&!c.y||Math.abs(c.x)+Math.abs(c.y)y&&(w=S,y=M);y>c&&(r[w]=1,Is(n,r,c,f,w),Is(n,r,c,w,m))}function Uc(n,r){for(var c=[n[0]],f=1,m=0,y=n.length;fr&&(c.push(n[f]),m=f);return mr.max.x&&(c|=2),n.yr.max.y&&(c|=8),c}function Yc(n,r){var c=r.x-n.x,f=r.y-n.y;return c*c+f*f}function Pi(n,r,c,f){var m=r.x,y=r.y,w=c.x-m,S=c.y-y,M=w*w+S*S,O;return M>0&&(O=((n.x-m)*w+(n.y-y)*S)/M,O>1?(m=c.x,y=c.y):O>0&&(m+=w*O,y+=S*O)),w=n.x-m,S=n.y-y,f?w*w+S*S:new F(m,y)}function Zt(n){return!E(n[0])||typeof n[0][0]!="object"&&typeof n[0][0]<"u"}function Rr(n){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Zt(n)}function Br(n,r){var c,f,m,y,w,S,M,O;if(!n||n.length===0)throw new Error("latlngs not passed");Zt(n)||(console.warn("latlngs are not flat! Only the first ring will be used"),n=n[0]);var z=Y([0,0]),q=ct(n),J=q.getNorthWest().distanceTo(q.getSouthWest())*q.getNorthEast().distanceTo(q.getNorthWest());J<1700&&(z=Ds(n));var Bt=n.length,Tt=[];for(c=0;cf){M=(y-f)/m,O=[S.x-M*(S.x-w.x),S.y-M*(S.y-w.y)];break}var zt=r.unproject(Z(O));return Y([zt.lat+z.lat,zt.lng+z.lng])}var Xc={__proto__:null,simplify:Ar,pointToSegmentDistance:Or,closestPointOnSegment:qc,clipSegment:Ir,_getEdgeIntersection:ln,_getBitCode:Ne,_sqClosestPointOnSegment:Pi,isFlat:Zt,_flat:Rr,polylineCenter:Br},Rs={project:function(n){return new F(n.lng,n.lat)},unproject:function(n){return new st(n.y,n.x)},bounds:new it([-180,-90],[180,90])},Bs={R:6378137,R_MINOR:6356752314245179e-9,bounds:new it([-2003750834279e-5,-1549657073972e-5],[2003750834279e-5,1876465623138e-5]),project:function(n){var r=Math.PI/180,c=this.R,f=n.lat*r,m=this.R_MINOR/c,y=Math.sqrt(1-m*m),w=y*Math.sin(f),S=Math.tan(Math.PI/4-f/2)/Math.pow((1-w)/(1+w),y/2);return f=-c*Math.log(Math.max(S,1e-10)),new F(n.lng*r*c,f)},unproject:function(n){for(var r=180/Math.PI,c=this.R,f=this.R_MINOR/c,m=Math.sqrt(1-f*f),y=Math.exp(-n.y/c),w=Math.PI/2-2*Math.atan(y),S=0,M=.1,O;S<15&&Math.abs(M)>1e-7;S++)O=m*Math.sin(w),O=Math.pow((1-O)/(1+O),m/2),M=Math.PI/2-2*Math.atan(y*O)-w,w+=M;return new st(w*r,n.x*r/c)}},Kc={__proto__:null,LonLat:Rs,Mercator:Bs,SphericalMercator:ls},Gc=o({},ye,{code:"EPSG:3395",projection:Bs,transformation:(function(){var n=.5/(Math.PI*Bs.R);return pi(n,.5,-n,.5)})()}),zr=o({},ye,{code:"EPSG:4326",projection:Rs,transformation:pi(1/180,1,-1/180,.5)}),Jc=o({},oe,{projection:Rs,transformation:pi(1,0,-1,0),scale:function(n){return Math.pow(2,n)},zoom:function(n){return Math.log(n)/Math.LN2},distance:function(n,r){var c=r.lng-n.lng,f=r.lat-n.lat;return Math.sqrt(c*c+f*f)},infinite:!0});oe.Earth=ye,oe.EPSG3395=Gc,oe.EPSG3857=cs,oe.EPSG900913=sc,oe.EPSG4326=zr,oe.Simple=Jc;var Ut=tt.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(n){return n.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(n){return n&&n.removeLayer(this),this},getPane:function(n){return this._map.getPane(n?this.options[n]||n:this.options.pane)},addInteractiveTarget:function(n){return this._map._targets[u(n)]=this,this},removeInteractiveTarget:function(n){return delete this._map._targets[u(n)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(n){var r=n.target;if(r.hasLayer(this)){if(this._map=r,this._zoomAnimated=r._zoomAnimated,this.getEvents){var c=this.getEvents();r.on(c,this),this.once("remove",function(){r.off(c,this)},this)}this.onAdd(r),this.fire("add"),r.fire("layeradd",{layer:this})}}});ot.include({addLayer:function(n){if(!n._layerAdd)throw new Error("The provided object is not a Layer.");var r=u(n);return this._layers[r]?this:(this._layers[r]=n,n._mapToAdd=this,n.beforeAdd&&n.beforeAdd(this),this.whenReady(n._layerAdd,n),this)},removeLayer:function(n){var r=u(n);return this._layers[r]?(this._loaded&&n.onRemove(this),delete this._layers[r],this._loaded&&(this.fire("layerremove",{layer:n}),n.fire("remove")),n._map=n._mapToAdd=null,this):this},hasLayer:function(n){return u(n)in this._layers},eachLayer:function(n,r){for(var c in this._layers)n.call(r,this._layers[c]);return this},_addLayers:function(n){n=n?E(n)?n:[n]:[];for(var r=0,c=n.length;rthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&r[0]instanceof st&&r[0].equals(r[c-1])&&r.pop(),r},_setLatLngs:function(n){ae.prototype._setLatLngs.call(this,n),Zt(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Zt(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var n=this._renderer._bounds,r=this.options.weight,c=new F(r,r);if(n=new it(n.min.subtract(c),n.max.add(c)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(n))){if(this.options.noClip){this._parts=this._rings;return}for(var f=0,m=this._rings.length,y;fn.y!=m.y>n.y&&n.x<(m.x-f.x)*(n.y-f.y)/(m.y-f.y)+f.x&&(r=!r);return r||ae.prototype._containsPoint.call(this,n,!0)}});function ru(n,r){return new ei(n,r)}var le=re.extend({initialize:function(n,r){b(this,r),this._layers={},n&&this.addData(n)},addData:function(n){var r=E(n)?n:n.features,c,f,m;if(r){for(c=0,f=r.length;c0&&m.push(m[0].slice()),m}function ii(n,r){return n.feature?o({},n.feature,{geometry:r}):pn(r)}function pn(n){return n.type==="Feature"||n.type==="FeatureCollection"?n:{type:"Feature",properties:{},geometry:n}}var Ws={toGeoJSON:function(n){return ii(this,{type:"Point",coordinates:Fs(this.getLatLng(),n)})}};hn.include(Ws),zs.include(Ws),cn.include(Ws),ae.include({toGeoJSON:function(n){var r=!Zt(this._latlngs),c=fn(this._latlngs,r?1:0,!1,n);return ii(this,{type:(r?"Multi":"")+"LineString",coordinates:c})}}),ei.include({toGeoJSON:function(n){var r=!Zt(this._latlngs),c=r&&!Zt(this._latlngs[0]),f=fn(this._latlngs,c?2:r?1:0,!0,n);return r||(f=[f]),ii(this,{type:(c?"Multi":"")+"Polygon",coordinates:f})}}),Qe.include({toMultiPoint:function(n){var r=[];return this.eachLayer(function(c){r.push(c.toGeoJSON(n).geometry.coordinates)}),ii(this,{type:"MultiPoint",coordinates:r})},toGeoJSON:function(n){var r=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(r==="MultiPoint")return this.toMultiPoint(n);var c=r==="GeometryCollection",f=[];return this.eachLayer(function(m){if(m.toGeoJSON){var y=m.toGeoJSON(n);if(c)f.push(y.geometry);else{var w=pn(y);w.type==="FeatureCollection"?f.push.apply(f,w.features):f.push(w)}}}),c?ii(this,{geometries:f,type:"GeometryCollection"}):{type:"FeatureCollection",features:f}}});function Wr(n,r){return new le(n,r)}var au=Wr,mn=Ut.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(n,r,c){this._url=n,this._bounds=ct(r),b(this,c)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(G(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){yt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(n){return this.options.opacity=n,this._image&&this._updateOpacity(),this},setStyle:function(n){return n.opacity&&this.setOpacity(n.opacity),this},bringToFront:function(){return this._map&&Ge(this._image),this},bringToBack:function(){return this._map&&Je(this._image),this},setUrl:function(n){return this._url=n,this._image&&(this._image.src=n),this},setBounds:function(n){return this._bounds=ct(n),this._map&&this._reset(),this},getEvents:function(){var n={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(n.zoomanim=this._animateZoom),n},setZIndex:function(n){return this.options.zIndex=n,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var n=this._url.tagName==="IMG",r=this._image=n?this._url:at("img");if(G(r,"leaflet-image-layer"),this._zoomAnimated&&G(r,"leaflet-zoom-animated"),this.options.className&&G(r,this.options.className),r.onselectstart=g,r.onmousemove=g,r.onload=l(this.fire,this,"load"),r.onerror=l(this._overlayOnError,this,"error"),(this.options.crossOrigin||this.options.crossOrigin==="")&&(r.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),n){this._url=r.src;return}r.src=this._url,r.alt=this.options.alt},_animateZoom:function(n){var r=this._map.getZoomScale(n.zoom),c=this._map._latLngBoundsToNewLayerBounds(this._bounds,n.zoom,n.center).min;Ie(this._image,c,r)},_reset:function(){var n=this._image,r=new it(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),c=r.getSize();St(n,r.min),n.style.width=c.x+"px",n.style.height=c.y+"px"},_updateOpacity:function(){Ht(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var n=this.options.errorOverlayUrl;n&&this._url!==n&&(this._url=n,this._image.src=n)},getCenter:function(){return this._bounds.getCenter()}}),lu=function(n,r,c){return new mn(n,r,c)},Hr=mn.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var n=this._url.tagName==="VIDEO",r=this._image=n?this._url:at("video");if(G(r,"leaflet-image-layer"),this._zoomAnimated&&G(r,"leaflet-zoom-animated"),this.options.className&&G(r,this.options.className),r.onselectstart=g,r.onmousemove=g,r.onloadeddata=l(this.fire,this,"load"),n){for(var c=r.getElementsByTagName("source"),f=[],m=0;m0?f:[r.src];return}E(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(r.style,"objectFit")&&(r.style.objectFit="fill"),r.autoplay=!!this.options.autoplay,r.loop=!!this.options.loop,r.muted=!!this.options.muted,r.playsInline=!!this.options.playsInline;for(var y=0;ym?(r.height=m+"px",G(n,y)):wt(n,y),this._containerWidth=this._container.offsetWidth},_animateZoom:function(n){var r=this._map._latLngToNewLayerPoint(this._latlng,n.zoom,n.center),c=this._getAnchor();St(this._container,r.add(c))},_adjustPan:function(){if(this.options.autoPan){if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning){this._autopanning=!1;return}var n=this._map,r=parseInt(_i(this._container,"marginBottom"),10)||0,c=this._container.offsetHeight+r,f=this._containerWidth,m=new F(this._containerLeft,-c-this._containerBottom);m._add(Re(this._container));var y=n.layerPointToContainerPoint(m),w=Z(this.options.autoPanPadding),S=Z(this.options.autoPanPaddingTopLeft||w),M=Z(this.options.autoPanPaddingBottomRight||w),O=n.getSize(),z=0,q=0;y.x+f+M.x>O.x&&(z=y.x+f-O.x+M.x),y.x-z-S.x<0&&(z=y.x-S.x),y.y+c+M.y>O.y&&(q=y.y+c-O.y+M.y),y.y-q-S.y<0&&(q=y.y-S.y),(z||q)&&(this.options.keepInView&&(this._autopanning=!0),n.fire("autopanstart").panBy([z,q]))}},_getAnchor:function(){return Z(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),uu=function(n,r){return new gn(n,r)};ot.mergeOptions({closePopupOnClick:!0}),ot.include({openPopup:function(n,r,c){return this._initOverlay(gn,n,r,c).openOn(this),this},closePopup:function(n){return n=arguments.length?n:this._popup,n&&n.close(),this}}),Ut.include({bindPopup:function(n,r){return this._popup=this._initOverlay(gn,this._popup,n,r),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(n){return this._popup&&(this instanceof re||(this._popup._source=this),this._popup._prepareOpen(n||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return this._popup?this._popup.isOpen():!1},setPopupContent:function(n){return this._popup&&this._popup.setContent(n),this},getPopup:function(){return this._popup},_openPopup:function(n){if(!(!this._popup||!this._map)){ze(n);var r=n.layer||n.target;if(this._popup._source===r&&!(r instanceof be)){this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(n.latlng);return}this._popup._source=r,this.openPopup(n.latlng)}},_movePopup:function(n){this._popup.setLatLng(n.latlng)},_onKeyPress:function(n){n.originalEvent.keyCode===13&&this._openPopup(n)}});var _n=Qt.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(n){Qt.prototype.onAdd.call(this,n),this.setOpacity(this.options.opacity),n.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(n){Qt.prototype.onRemove.call(this,n),n.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var n=Qt.prototype.getEvents.call(this);return this.options.permanent||(n.preclick=this.close),n},_initLayout:function(){var n="leaflet-tooltip",r=n+" "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=at("div",r),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+u(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(n){var r,c,f=this._map,m=this._container,y=f.latLngToContainerPoint(f.getCenter()),w=f.layerPointToContainerPoint(n),S=this.options.direction,M=m.offsetWidth,O=m.offsetHeight,z=Z(this.options.offset),q=this._getAnchor();S==="top"?(r=M/2,c=O):S==="bottom"?(r=M/2,c=0):S==="center"?(r=M/2,c=O/2):S==="right"?(r=0,c=O/2):S==="left"?(r=M,c=O/2):w.xthis.options.maxZoom||cf?this._retainParent(m,y,w,f):!1)},_retainChildren:function(n,r,c,f){for(var m=2*n;m<2*n+2;m++)for(var y=2*r;y<2*r+2;y++){var w=new F(m,y);w.z=c+1;var S=this._tileCoordsToKey(w),M=this._tiles[S];if(M&&M.active){M.retain=!0;continue}else M&&M.loaded&&(M.retain=!0);c+1this.options.maxZoom||this.options.minZoom!==void 0&&m1){this._setView(n,c);return}for(var q=m.min.y;q<=m.max.y;q++)for(var J=m.min.x;J<=m.max.x;J++){var Bt=new F(J,q);if(Bt.z=this._tileZoom,!!this._isValidTile(Bt)){var Tt=this._tiles[this._tileCoordsToKey(Bt)];Tt?Tt.current=!0:w.push(Bt)}}if(w.sort(function(zt,si){return zt.distanceTo(y)-si.distanceTo(y)}),w.length!==0){this._loading||(this._loading=!0,this.fire("loading"));var Vt=document.createDocumentFragment();for(J=0;Jc.max.x)||!r.wrapLat&&(n.yc.max.y))return!1}if(!this.options.bounds)return!0;var f=this._tileCoordsToBounds(n);return ct(this.options.bounds).overlaps(f)},_keyToBounds:function(n){return this._tileCoordsToBounds(this._keyToTileCoords(n))},_tileCoordsToNwSe:function(n){var r=this._map,c=this.getTileSize(),f=n.scaleBy(c),m=f.add(c),y=r.unproject(f,n.z),w=r.unproject(m,n.z);return[y,w]},_tileCoordsToBounds:function(n){var r=this._tileCoordsToNwSe(n),c=new kt(r[0],r[1]);return this.options.noWrap||(c=this._map.wrapLatLngBounds(c)),c},_tileCoordsToKey:function(n){return n.x+":"+n.y+":"+n.z},_keyToTileCoords:function(n){var r=n.split(":"),c=new F(+r[0],+r[1]);return c.z=+r[2],c},_removeTile:function(n){var r=this._tiles[n];r&&(yt(r.el),delete this._tiles[n],this.fire("tileunload",{tile:r.el,coords:this._keyToTileCoords(n)}))},_initTile:function(n){G(n,"leaflet-tile");var r=this.getTileSize();n.style.width=r.x+"px",n.style.height=r.y+"px",n.onselectstart=g,n.onmousemove=g,H.ielt9&&this.options.opacity<1&&Ht(n,this.options.opacity)},_addTile:function(n,r){var c=this._getTilePos(n),f=this._tileCoordsToKey(n),m=this.createTile(this._wrapCoords(n),l(this._tileReady,this,n));this._initTile(m),this.createTile.length<2&&W(l(this._tileReady,this,n,null,m)),St(m,c),this._tiles[f]={el:m,coords:n,current:!0},r.appendChild(m),this.fire("tileloadstart",{tile:m,coords:n})},_tileReady:function(n,r,c){r&&this.fire("tileerror",{error:r,tile:c,coords:n});var f=this._tileCoordsToKey(n);c=this._tiles[f],c&&(c.loaded=+new Date,this._map._fadeAnimated?(Ht(c.el,0),j(this._fadeFrame),this._fadeFrame=W(this._updateOpacity,this)):(c.active=!0,this._pruneTiles()),r||(G(c.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:c.el,coords:n})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),H.ielt9||!this._map._fadeAnimated?W(this._pruneTiles,this):setTimeout(l(this._pruneTiles,this),250)))},_getTilePos:function(n){return n.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(n){var r=new F(this._wrapX?p(n.x,this._wrapX):n.x,this._wrapY?p(n.y,this._wrapY):n.y);return r.z=n.z,r},_pxBoundsToTileRange:function(n){var r=this.getTileSize();return new it(n.min.unscaleBy(r).floor(),n.max.unscaleBy(r).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var n in this._tiles)if(!this._tiles[n].loaded)return!1;return!0}});function pu(n){return new Si(n)}var ni=Si.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(n,r){this._url=n,r=b(this,r),r.detectRetina&&H.retina&&r.maxZoom>0?(r.tileSize=Math.floor(r.tileSize/2),r.zoomReverse?(r.zoomOffset--,r.minZoom=Math.min(r.maxZoom,r.minZoom+1)):(r.zoomOffset++,r.maxZoom=Math.max(r.minZoom,r.maxZoom-1)),r.minZoom=Math.max(0,r.minZoom)):r.zoomReverse?r.minZoom=Math.min(r.maxZoom,r.minZoom):r.maxZoom=Math.max(r.minZoom,r.maxZoom),typeof r.subdomains=="string"&&(r.subdomains=r.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(n,r){return this._url===n&&r===void 0&&(r=!0),this._url=n,r||this.redraw(),this},createTile:function(n,r){var c=document.createElement("img");return X(c,"load",l(this._tileOnLoad,this,r,c)),X(c,"error",l(this._tileOnError,this,r,c)),(this.options.crossOrigin||this.options.crossOrigin==="")&&(c.crossOrigin=this.options.crossOrigin===!0?"":this.options.crossOrigin),typeof this.options.referrerPolicy=="string"&&(c.referrerPolicy=this.options.referrerPolicy),c.alt="",c.src=this.getTileUrl(n),c},getTileUrl:function(n){var r={r:H.retina?"@2x":"",s:this._getSubdomain(n),x:n.x,y:n.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var c=this._globalTileRange.max.y-n.y;this.options.tms&&(r.y=c),r["-y"]=c}return C(this._url,o(r,this.options))},_tileOnLoad:function(n,r){H.ielt9?setTimeout(l(n,this,null,r),0):n(null,r)},_tileOnError:function(n,r,c){var f=this.options.errorTileUrl;f&&r.getAttribute("src")!==f&&(r.src=f),n(c,r)},_onTileRemove:function(n){n.tile.onload=null},_getZoomForUrl:function(){var n=this._tileZoom,r=this.options.maxZoom,c=this.options.zoomReverse,f=this.options.zoomOffset;return c&&(n=r-n),n+f},_getSubdomain:function(n){var r=Math.abs(n.x+n.y)%this.options.subdomains.length;return this.options.subdomains[r]},_abortLoading:function(){var n,r;for(n in this._tiles)if(this._tiles[n].coords.z!==this._tileZoom&&(r=this._tiles[n].el,r.onload=g,r.onerror=g,!r.complete)){r.src=T;var c=this._tiles[n].coords;yt(r),delete this._tiles[n],this.fire("tileabort",{tile:r,coords:c})}},_removeTile:function(n){var r=this._tiles[n];if(r)return r.el.setAttribute("src",T),Si.prototype._removeTile.call(this,n)},_tileReady:function(n,r,c){if(!(!this._map||c&&c.getAttribute("src")===T))return Si.prototype._tileReady.call(this,n,r,c)}});function jr(n,r){return new ni(n,r)}var qr=ni.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(n,r){this._url=n;var c=o({},this.defaultWmsParams);for(var f in r)f in this.options||(c[f]=r[f]);r=b(this,r);var m=r.detectRetina&&H.retina?2:1,y=this.getTileSize();c.width=y.x*m,c.height=y.y*m,this.wmsParams=c},onAdd:function(n){this._crs=this.options.crs||n.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var r=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[r]=this._crs.code,ni.prototype.onAdd.call(this,n)},getTileUrl:function(n){var r=this._tileCoordsToNwSe(n),c=this._crs,f=xt(c.project(r[0]),c.project(r[1])),m=f.min,y=f.max,w=(this._wmsVersion>=1.3&&this._crs===zr?[m.y,m.x,y.y,y.x]:[m.x,m.y,y.x,y.y]).join(","),S=ni.prototype.getTileUrl.call(this,n);return S+P(this.wmsParams,S,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+w},setParams:function(n,r){return o(this.wmsParams,n),r||this.redraw(),this}});function mu(n,r){return new qr(n,r)}ni.WMS=qr,jr.wms=mu;var he=Ut.extend({options:{padding:.1},initialize:function(n){b(this,n),u(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),G(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var n={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(n.zoomanim=this._onAnimZoom),n},_onAnimZoom:function(n){this._updateTransform(n.center,n.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(n,r){var c=this._map.getZoomScale(r,this._zoom),f=this._map.getSize().multiplyBy(.5+this.options.padding),m=this._map.project(this._center,r),y=f.multiplyBy(-c).add(m).subtract(this._map._getNewPixelOrigin(n,r));H.any3d?Ie(this._container,y,c):St(this._container,y)},_reset:function(){this._update(),this._updateTransform(this._center,this._zoom);for(var n in this._layers)this._layers[n]._reset()},_onZoomEnd:function(){for(var n in this._layers)this._layers[n]._project()},_updatePaths:function(){for(var n in this._layers)this._layers[n]._update()},_update:function(){var n=this.options.padding,r=this._map.getSize(),c=this._map.containerPointToLayerPoint(r.multiplyBy(-n)).round();this._bounds=new it(c,c.add(r.multiplyBy(1+n*2)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),$r=he.extend({options:{tolerance:0},getEvents:function(){var n=he.prototype.getEvents.call(this);return n.viewprereset=this._onViewPreReset,n},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){he.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var n=this._container=document.createElement("canvas");X(n,"mousemove",this._onMouseMove,this),X(n,"click dblclick mousedown mouseup contextmenu",this._onClick,this),X(n,"mouseout",this._handleMouseOut,this),n._leaflet_disable_events=!0,this._ctx=n.getContext("2d")},_destroyContainer:function(){j(this._redrawRequest),delete this._ctx,yt(this._container),dt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){var n;this._redrawBounds=null;for(var r in this._layers)n=this._layers[r],n._update();this._redraw()}},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){he.prototype._update.call(this);var n=this._bounds,r=this._container,c=n.getSize(),f=H.retina?2:1;St(r,n.min),r.width=f*c.x,r.height=f*c.y,r.style.width=c.x+"px",r.style.height=c.y+"px",H.retina&&this._ctx.scale(2,2),this._ctx.translate(-n.min.x,-n.min.y),this.fire("update")}},_reset:function(){he.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(n){this._updateDashArray(n),this._layers[u(n)]=n;var r=n._order={layer:n,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=r),this._drawLast=r,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(n){this._requestRedraw(n)},_removePath:function(n){var r=n._order,c=r.next,f=r.prev;c?c.prev=f:this._drawLast=f,f?f.next=c:this._drawFirst=c,delete n._order,delete this._layers[u(n)],this._requestRedraw(n)},_updatePath:function(n){this._extendRedrawBounds(n),n._project(),n._update(),this._requestRedraw(n)},_updateStyle:function(n){this._updateDashArray(n),this._requestRedraw(n)},_updateDashArray:function(n){if(typeof n.options.dashArray=="string"){var r=n.options.dashArray.split(/[, ]+/),c=[],f,m;for(m=0;m')}}catch{}return function(n){return document.createElement("<"+n+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}})(),gu={_initContainer:function(){this._container=at("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(he.prototype._update.call(this),this.fire("update"))},_initPath:function(n){var r=n._container=Mi("shape");G(r,"leaflet-vml-shape "+(this.options.className||"")),r.coordsize="1 1",n._path=Mi("path"),r.appendChild(n._path),this._updateStyle(n),this._layers[u(n)]=n},_addPath:function(n){var r=n._container;this._container.appendChild(r),n.options.interactive&&n.addInteractiveTarget(r)},_removePath:function(n){var r=n._container;yt(r),n.removeInteractiveTarget(r),delete this._layers[u(n)]},_updateStyle:function(n){var r=n._stroke,c=n._fill,f=n.options,m=n._container;m.stroked=!!f.stroke,m.filled=!!f.fill,f.stroke?(r||(r=n._stroke=Mi("stroke")),m.appendChild(r),r.weight=f.weight+"px",r.color=f.color,r.opacity=f.opacity,f.dashArray?r.dashStyle=E(f.dashArray)?f.dashArray.join(" "):f.dashArray.replace(/( *, *)/g," "):r.dashStyle="",r.endcap=f.lineCap.replace("butt","flat"),r.joinstyle=f.lineJoin):r&&(m.removeChild(r),n._stroke=null),f.fill?(c||(c=n._fill=Mi("fill")),m.appendChild(c),c.color=f.fillColor||f.color,c.opacity=f.fillOpacity):c&&(m.removeChild(c),n._fill=null)},_updateCircle:function(n){var r=n._point.round(),c=Math.round(n._radius),f=Math.round(n._radiusY||c);this._setPath(n,n._empty()?"M0 0":"AL "+r.x+","+r.y+" "+c+","+f+" 0,"+65535*360)},_setPath:function(n,r){n._path.v=r},_bringToFront:function(n){Ge(n._container)},_bringToBack:function(n){Je(n._container)}},yn=H.vml?Mi:Go,Li=he.extend({_initContainer:function(){this._container=yn("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=yn("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){yt(this._container),dt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!(this._map._animatingZoom&&this._bounds)){he.prototype._update.call(this);var n=this._bounds,r=n.getSize(),c=this._container;(!this._svgSize||!this._svgSize.equals(r))&&(this._svgSize=r,c.setAttribute("width",r.x),c.setAttribute("height",r.y)),St(c,n.min),c.setAttribute("viewBox",[n.min.x,n.min.y,r.x,r.y].join(" ")),this.fire("update")}},_initPath:function(n){var r=n._path=yn("path");n.options.className&&G(r,n.options.className),n.options.interactive&&G(r,"leaflet-interactive"),this._updateStyle(n),this._layers[u(n)]=n},_addPath:function(n){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(n._path),n.addInteractiveTarget(n._path)},_removePath:function(n){yt(n._path),n.removeInteractiveTarget(n._path),delete this._layers[u(n)]},_updatePath:function(n){n._project(),n._update()},_updateStyle:function(n){var r=n._path,c=n.options;r&&(c.stroke?(r.setAttribute("stroke",c.color),r.setAttribute("stroke-opacity",c.opacity),r.setAttribute("stroke-width",c.weight),r.setAttribute("stroke-linecap",c.lineCap),r.setAttribute("stroke-linejoin",c.lineJoin),c.dashArray?r.setAttribute("stroke-dasharray",c.dashArray):r.removeAttribute("stroke-dasharray"),c.dashOffset?r.setAttribute("stroke-dashoffset",c.dashOffset):r.removeAttribute("stroke-dashoffset")):r.setAttribute("stroke","none"),c.fill?(r.setAttribute("fill",c.fillColor||c.color),r.setAttribute("fill-opacity",c.fillOpacity),r.setAttribute("fill-rule",c.fillRule||"evenodd")):r.setAttribute("fill","none"))},_updatePoly:function(n,r){this._setPath(n,Jo(n._parts,r))},_updateCircle:function(n){var r=n._point,c=Math.max(Math.round(n._radius),1),f=Math.max(Math.round(n._radiusY),1)||c,m="a"+c+","+f+" 0 1,0 ",y=n._empty()?"M0 0":"M"+(r.x-c)+","+r.y+m+c*2+",0 "+m+-c*2+",0 ";this._setPath(n,y)},_setPath:function(n,r){n._path.setAttribute("d",r)},_bringToFront:function(n){Ge(n._path)},_bringToBack:function(n){Je(n._path)}});H.vml&&Li.include(gu);function Yr(n){return H.svg||H.vml?new Li(n):null}ot.include({getRenderer:function(n){var r=n.options.renderer||this._getPaneRenderer(n.options.pane)||this.options.renderer||this._renderer;return r||(r=this._renderer=this._createRenderer()),this.hasLayer(r)||this.addLayer(r),r},_getPaneRenderer:function(n){if(n==="overlayPane"||n===void 0)return!1;var r=this._paneRenderers[n];return r===void 0&&(r=this._createRenderer({pane:n}),this._paneRenderers[n]=r),r},_createRenderer:function(n){return this.options.preferCanvas&&Ur(n)||Yr(n)}});var Xr=ei.extend({initialize:function(n,r){ei.prototype.initialize.call(this,this._boundsToLatLngs(n),r)},setBounds:function(n){return this.setLatLngs(this._boundsToLatLngs(n))},_boundsToLatLngs:function(n){return n=ct(n),[n.getSouthWest(),n.getNorthWest(),n.getNorthEast(),n.getSouthEast()]}});function _u(n,r){return new Xr(n,r)}Li.create=yn,Li.pointsToPath=Jo,le.geometryToLayer=un,le.coordsToLatLng=Ns,le.coordsToLatLngs=dn,le.latLngToCoords=Fs,le.latLngsToCoords=fn,le.getFeature=ii,le.asFeature=pn,ot.mergeOptions({boxZoom:!0});var Kr=Jt.extend({initialize:function(n){this._map=n,this._container=n._container,this._pane=n._panes.overlayPane,this._resetStateTimeout=0,n.on("unload",this._destroy,this)},addHooks:function(){X(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){dt(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){yt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){this._resetStateTimeout!==0&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(n){if(!n.shiftKey||n.which!==1&&n.button!==1)return!1;this._clearDeferredResetState(),this._resetState(),yi(),xs(),this._startPoint=this._map.mouseEventToContainerPoint(n),X(document,{contextmenu:ze,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(n){this._moved||(this._moved=!0,this._box=at("div","leaflet-zoom-box",this._container),G(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(n);var r=new it(this._point,this._startPoint),c=r.getSize();St(this._box,r.min),this._box.style.width=c.x+"px",this._box.style.height=c.y+"px"},_finish:function(){this._moved&&(yt(this._box),wt(this._container,"leaflet-crosshair")),vi(),ws(),dt(document,{contextmenu:ze,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(n){if(!(n.which!==1&&n.button!==1)&&(this._finish(),!!this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(l(this._resetState,this),0);var r=new kt(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(r).fire("boxzoomend",{boxZoomBounds:r})}},_onKeyDown:function(n){n.keyCode===27&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});ot.addInitHook("addHandler","boxZoom",Kr),ot.mergeOptions({doubleClickZoom:!0});var Gr=Jt.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(n){var r=this._map,c=r.getZoom(),f=r.options.zoomDelta,m=n.originalEvent.shiftKey?c-f:c+f;r.options.doubleClickZoom==="center"?r.setZoom(m):r.setZoomAround(n.containerPoint,m)}});ot.addInitHook("addHandler","doubleClickZoom",Gr),ot.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var Jr=Jt.extend({addHooks:function(){if(!this._draggable){var n=this._map;this._draggable=new ve(n._mapPane,n._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),n.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),n.on("zoomend",this._onZoomEnd,this),n.whenReady(this._onZoomEnd,this))}G(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){wt(this._map._container,"leaflet-grab"),wt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var n=this._map;if(n._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var r=ct(this._map.options.maxBounds);this._offsetLimit=xt(this._map.latLngToContainerPoint(r.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(r.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;n.fire("movestart").fire("dragstart"),n.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(n){if(this._map.options.inertia){var r=this._lastTime=+new Date,c=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(c),this._times.push(r),this._prunePositions(r)}this._map.fire("move",n).fire("drag",n)},_prunePositions:function(n){for(;this._positions.length>1&&n-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var n=this._map.getSize().divideBy(2),r=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=r.subtract(n).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(n,r){return n-(n-r)*this._viscosity},_onPreDragLimit:function(){if(!(!this._viscosity||!this._offsetLimit)){var n=this._draggable._newPos.subtract(this._draggable._startPos),r=this._offsetLimit;n.xr.max.x&&(n.x=this._viscousLimit(n.x,r.max.x)),n.y>r.max.y&&(n.y=this._viscousLimit(n.y,r.max.y)),this._draggable._newPos=this._draggable._startPos.add(n)}},_onPreDragWrap:function(){var n=this._worldWidth,r=Math.round(n/2),c=this._initialWorldOffset,f=this._draggable._newPos.x,m=(f-r+c)%n+r-c,y=(f+r+c)%n-r-c,w=Math.abs(m+c)0?y:-y))-r;this._delta=0,this._startTime=null,w&&(n.options.scrollWheelZoom==="center"?n.setZoom(r+w):n.setZoomAround(this._lastMousePos,r+w))}});ot.addInitHook("addHandler","scrollWheelZoom",ta);var yu=600;ot.mergeOptions({tapHold:H.touchNative&&H.safari&&H.mobile,tapTolerance:15});var ea=Jt.extend({addHooks:function(){X(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){dt(this._map._container,"touchstart",this._onDown,this)},_onDown:function(n){if(clearTimeout(this._holdTimeout),n.touches.length===1){var r=n.touches[0];this._startPos=this._newPos=new F(r.clientX,r.clientY),this._holdTimeout=setTimeout(l(function(){this._cancel(),this._isTapValid()&&(X(document,"touchend",At),X(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",r))},this),yu),X(document,"touchend touchcancel contextmenu",this._cancel,this),X(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function n(){dt(document,"touchend",At),dt(document,"touchend touchcancel",n)},_cancel:function(){clearTimeout(this._holdTimeout),dt(document,"touchend touchcancel contextmenu",this._cancel,this),dt(document,"touchmove",this._onMove,this)},_onMove:function(n){var r=n.touches[0];this._newPos=new F(r.clientX,r.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(n,r){var c=new MouseEvent(n,{bubbles:!0,cancelable:!0,view:window,screenX:r.screenX,screenY:r.screenY,clientX:r.clientX,clientY:r.clientY});c._simulated=!0,r.target.dispatchEvent(c)}});ot.addInitHook("addHandler","tapHold",ea),ot.mergeOptions({touchZoom:H.touch,bounceAtZoomLimits:!0});var ia=Jt.extend({addHooks:function(){G(this._map._container,"leaflet-touch-zoom"),X(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){wt(this._map._container,"leaflet-touch-zoom"),dt(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(n){var r=this._map;if(!(!n.touches||n.touches.length!==2||r._animatingZoom||this._zooming)){var c=r.mouseEventToContainerPoint(n.touches[0]),f=r.mouseEventToContainerPoint(n.touches[1]);this._centerPoint=r.getSize()._divideBy(2),this._startLatLng=r.containerPointToLatLng(this._centerPoint),r.options.touchZoom!=="center"&&(this._pinchStartLatLng=r.containerPointToLatLng(c.add(f)._divideBy(2))),this._startDist=c.distanceTo(f),this._startZoom=r.getZoom(),this._moved=!1,this._zooming=!0,r._stop(),X(document,"touchmove",this._onTouchMove,this),X(document,"touchend touchcancel",this._onTouchEnd,this),At(n)}},_onTouchMove:function(n){if(!(!n.touches||n.touches.length!==2||!this._zooming)){var r=this._map,c=r.mouseEventToContainerPoint(n.touches[0]),f=r.mouseEventToContainerPoint(n.touches[1]),m=c.distanceTo(f)/this._startDist;if(this._zoom=r.getScaleZoom(m,this._startZoom),!r.options.bounceAtZoomLimits&&(this._zoomr.getMaxZoom()&&m>1)&&(this._zoom=r._limitZoom(this._zoom)),r.options.touchZoom==="center"){if(this._center=this._startLatLng,m===1)return}else{var y=c._add(f)._divideBy(2)._subtract(this._centerPoint);if(m===1&&y.x===0&&y.y===0)return;this._center=r.unproject(r.project(this._pinchStartLatLng,this._zoom).subtract(y),this._zoom)}this._moved||(r._moveStart(!0,!1),this._moved=!0),j(this._animRequest);var w=l(r._move,r,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=W(w,this,!0),At(n)}},_onTouchEnd:function(){if(!this._moved||!this._zooming){this._zooming=!1;return}this._zooming=!1,j(this._animRequest),dt(document,"touchmove",this._onTouchMove,this),dt(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))}});ot.addInitHook("addHandler","touchZoom",ia),ot.BoxZoom=Kr,ot.DoubleClickZoom=Gr,ot.Drag=Jr,ot.Keyboard=Qr,ot.ScrollWheelZoom=ta,ot.TapHold=ea,ot.TouchZoom=ia,e.Bounds=it,e.Browser=H,e.CRS=oe,e.Canvas=$r,e.Circle=zs,e.CircleMarker=cn,e.Class=ut,e.Control=$t,e.DivIcon=Vr,e.DivOverlay=Qt,e.DomEvent=Bc,e.DomUtil=Ic,e.Draggable=ve,e.Evented=tt,e.FeatureGroup=re,e.GeoJSON=le,e.GridLayer=Si,e.Handler=Jt,e.Icon=ti,e.ImageOverlay=mn,e.LatLng=st,e.LatLngBounds=kt,e.Layer=Ut,e.LayerGroup=Qe,e.LineUtil=Xc,e.Map=ot,e.Marker=hn,e.Mixin=Vc,e.Path=be,e.Point=F,e.PolyUtil=jc,e.Polygon=ei,e.Polyline=ae,e.Popup=gn,e.PosAnimation=Sr,e.Projection=Kc,e.Rectangle=Xr,e.Renderer=he,e.SVG=Li,e.SVGOverlay=Zr,e.TileLayer=ni,e.Tooltip=_n,e.Transformation=hs,e.Util=vt,e.VideoOverlay=Hr,e.bind=l,e.bounds=xt,e.canvas=Ur,e.circle=su,e.circleMarker=nu,e.control=wi,e.divIcon=fu,e.extend=o,e.featureGroup=tu,e.geoJSON=Wr,e.geoJson=au,e.gridLayer=pu,e.icon=eu,e.imageOverlay=lu,e.latLng=Y,e.latLngBounds=ct,e.layerGroup=Qc,e.map=zc,e.marker=iu,e.point=Z,e.polygon=ru,e.polyline=ou,e.popup=uu,e.rectangle=_u,e.setOptions=b,e.stamp=u,e.svg=Yr,e.svgOverlay=cu,e.tileLayer=jr,e.tooltip=du,e.transformation=pi,e.version=s,e.videoOverlay=hu;var vu=window.L;e.noConflict=function(){return window.L=vu,this},window.L=e}))})(Wi,Wi.exports)),Wi.exports}var iy=ey();const ai=Q_(iy),ny={US:[37.09,-95.71],DE:[51.16,10.45],GB:[55.37,-3.43],BR:[-14.23,-51.92],CN:[35.86,104.19],IN:[20.59,78.96],KR:[35.9,127.76],SA:[23.88,45.07],FR:[46.22,2.21],JP:[36.2,138.25],AU:[-25.27,133.77],CA:[56.13,-106.34],RU:[61.52,105.31],MX:[23.63,-102.55],ZA:[-30.55,22.93]};let Ii=null,Gn={};function sy(i){return ny[i?.toUpperCase()]||[20,0]}function oy(i){return i==="bullish"?"#22d37a":i==="bearish"?"#f04040":"#f0a020"}function ry(i){const t=i||0;return t>2e6?18:t>1e6?14:t>5e5?11:t>2e5?8:6}function ay(i,t,e,s){const o=document.getElementById(i);o&&(Ii=ai.map(o,{zoomControl:!1,attributionControl:!1,minZoom:2,maxZoom:6,worldCopyJump:!0}).setView([25,10],2),ai.tileLayer("https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",{attribution:"©OpenStreetMap ©CartoDB",subdomains:"abcd",maxZoom:19}).addTo(Ii),t.forEach(a=>{const l=e.find(A=>A.marketId===a.id)||{signal:"neutral"},h=oy(l.signal),u=sy(a.countryCode),d=ry(a.volumeEur),p=ai.circleMarker(u,{radius:d,fillColor:h,color:h,weight:1.5,opacity:.6,fillOpacity:.22}).addTo(Ii),g=ai.circleMarker(u,{radius:Math.max(3,d*.45),fillColor:h,color:"transparent",fillOpacity:.8}).addTo(Ii),_=document.createElement("span");_.className="map-label-text",_.textContent=a.countryCode||"GL";const v=ai.marker(u,{icon:ai.divIcon({className:"map-label",html:_.outerHTML,iconSize:[40,14],iconAnchor:[20,-d-4]}),interactive:!1}).addTo(Ii),x=document.createElement("div");x.className="map-popup";const b=document.createElement("div");b.className="map-popup-cat",b.textContent=`${a.category||"General"} · ${a.countryCode||"GL"}`;const P=document.createElement("div");P.className="map-popup-q",P.textContent=a.question;const k=document.createElement("div");k.className="map-popup-prices";const C=document.createElement("span");C.className="text-green",C.textContent=`SÍ ${Math.round((a.yesPrice||0)*100)}¢`;const E=document.createElement("span");E.className="text-red",E.textContent=`NO ${Math.round((a.noPrice||0)*100)}¢`,k.append(C,E),x.append(b,P,k),p.bindPopup(x,{closeButton:!1,offset:[0,-4]}),p.on("click",()=>{s(a.id)}),Gn[a.id]={circle:p,inner:g,label:v,color:h}}))}function ly(i,t){const e=Gn[i];if(!e)return;const s=e.circle.getRadius()+(Math.random()>.5?.5:-.5);e.circle.setRadius(Math.max(5,Math.min(22,s)))}function hy(i){Object.values(Gn).forEach(e=>{e.circle.setStyle({weight:1.5,opacity:.6})});const t=Gn[i];t&&(t.circle.setStyle({weight:3,opacity:1,color:"#4a9eff"}),t.circle.openPopup())}let hi=null;function cy(i){hi=i}async function Bl(i,t,e){const s=parseFloat(e);if(!s||s<=0){alert("Introduce una cantidad válida");return}const o=hi.markets.find(h=>h.id===i);if(!o)return;const a=t==="YES"?o.yesPrice:o.noPrice,l={marketId:i,outcome:t,amountEur:s,entryPrice:a};try{const h=await kd(l);hi.positions.push(h)}catch{const u=Date.now();hi.positions.push({id:u,marketId:i,outcome:t,amountEur:s,entryPrice:a,currentPrice:a,pnl:0,kellyFraction:.2,openedAt:new Date().toISOString()})}document.dispatchEvent(new CustomEvent("positions:changed"))}async function uy(i){try{await Sd(i)}catch{console.warn("API closePosition failed, removing locally")}hi.positions=hi.positions.filter(t=>t.id!==i),document.dispatchEvent(new CustomEvent("positions:changed"))}let V={view:"dashboard",activeMarketId:null,markets:[],signals:[],positions:[],watchlist:[],alerts:[],collapsedPanels:new Set,sidebarCollapsed:!1};const zl=[{id:"usa-001",question:"¿Trump firmará la ley fiscal antes de junio de 2026?",category:"política",countryCode:"US",yesPrice:.73,noPrice:.27,volumeEur:124e4,liquidityEur:34e4,status:"active",closesAt:"2026-06-01T00:00:00Z"},{id:"eur-001",question:"¿El BCE recortará tipos en junio de 2026?",category:"economía",countryCode:"DE",yesPrice:.34,noPrice:.66,volumeEur:89e4,liquidityEur:21e4,status:"active",closesAt:"2026-06-12T00:00:00Z"},{id:"chn-001",question:"¿Se alcanzará un acuerdo arancelario EE.UU.-China antes del T3 2026?",category:"comercio",countryCode:"CN",yesPrice:.51,noPrice:.49,volumeEur:21e5,liquidityEur:58e4,status:"active",closesAt:"2026-07-01T00:00:00Z"},{id:"bra-001",question:"¿Bitcoin superará los $120.000 antes de julio de 2026?",category:"cripto",countryCode:"BR",yesPrice:.61,noPrice:.39,volumeEur:34e5,liquidityEur:92e4,status:"active",closesAt:"2026-07-01T00:00:00Z"},{id:"uk-001",question:"¿La inflación del Reino Unido bajará del 2% en 2026?",category:"economía",countryCode:"GB",yesPrice:.45,noPrice:.55,volumeEur:62e4,liquidityEur:18e4,status:"active",closesAt:"2026-09-01T00:00:00Z"},{id:"ind-001",question:"¿El crecimiento del PIB de India superará el 7% en el AF2026?",category:"economía",countryCode:"IN",yesPrice:.68,noPrice:.32,volumeEur:45e4,liquidityEur:12e4,status:"active",closesAt:"2026-03-31T00:00:00Z"}],Yo={"usa-001":{signal:"bullish",confidence:.87,summary:"El liderazgo republicano confirmó 3 de 4 votos de comité asegurados. El sentimiento de noticias de 8 fuentes es positivo (+0,72). La línea temporal del Congreso sugiere que la ventana de firma se abre del 28 al 31 de mayo.",keyRisk:"El proceso de enmiendas en el Senado podría retrasar más allá del 1 de junio."},"eur-001":{signal:"bearish",confidence:.74,summary:"La inflación de la zona euro sorprendió al alza al 2,4% en abril. Las recientes declaraciones de los miembros del consejo de gobierno del BCE señalan que es más probable una pausa.",keyRisk:"La valoración del mercado de bonos implica solo un 22% de probabilidad de recorte en junio."},"chn-001":{signal:"neutral",confidence:.52,summary:"Las negociaciones continúan pero no se ha acordado un marco formal. Los flujos comerciales muestran patrones tempranos de evasión arancelaria, sugiriendo que ambas partes ganan tiempo.",keyRisk:"Demasiadas variables geopolíticas. Se monitorea la declaración del USTR como señal clave."},"bra-001":{signal:"bullish",confidence:.79,summary:"BTC actualmente en $103.400. Las métricas on-chain muestran acumulación de grandes carteras. Entradas en ETF +$820M esta semana. El mercado de opciones implica 68% de probabilidad de $120K a finales de junio.",keyRisk:"Las condiciones de liquidez macro podrían cambiar si la Fed mantiene una postura hawkish."},"uk-001":{signal:"neutral",confidence:.58,summary:"Las previsiones del BoE sugieren una caída gradual pero los shocks externos de precios de energía siguen siendo una incógnita. La inflación de servicios se mantiene en el 5,2%.",keyRisk:"Las interrupciones geopolíticas en la cadena de suministro podrían reavivar la inflación de bienes."},"ind-001":{signal:"bullish",confidence:.71,summary:"Dato del T4 AF25 en 7,1% con expansión del PMI manufacturero. El impulso del gasto público en infraestructura probablemente sostenga el momentum en el S1 AF26.",keyRisk:"El impacto de El Niño en la producción agrícola podría reducir 30-40 pb del dato principal."}},dy=[{id:1,marketId:"usa-001",outcome:"SÍ",amountEur:100,entryPrice:.68,currentPrice:.73,pnl:14.2,kellyFraction:.25,openedAt:"2026-05-10T14:30:00Z"},{id:2,marketId:"eur-001",outcome:"NO",amountEur:80,entryPrice:.62,currentPrice:.66,pnl:-3.8,kellyFraction:.18,openedAt:"2026-05-11T09:15:00Z"}],fy=[{id:1,marketId:"usa-001",type:"cambio_señal",message:"La señal cambió a ALCISTA (87%) en ley fiscal de Trump",sentAt:"2026-05-14T08:23:00Z"},{id:2,marketId:"bra-001",type:"umbral_precio",message:"El mercado BTC $120K SÍ cruzó el umbral de 60¢",sentAt:"2026-05-14T07:45:00Z"}];function ko(i){return i>=1e6?"€"+(i/1e6).toFixed(1)+"M":i>=1e3?"€"+(i/1e3).toFixed(1)+"K":"€"+i.toFixed(0)}function Le(i){return Math.round(i*100)+"¢"}function Xh(i){return new Date(i).toLocaleDateString("es-ES",{month:"short",day:"numeric",year:"numeric"})}function py(i){return i==="bullish"?"green":i==="bearish"?"red":"amber"}function Xo(i){return i==="bullish"?"sig-bull":i==="bearish"?"sig-bear":"sig-neut"}function Kh(i){return i==="bullish"?"ALC":i==="bearish"?"BAJ":"NEUT"}function my(i){return i==="bullish"?"alcista":i==="bearish"?"bajista":"neutral"}function I(i,t,e){const s=document.createElement(i);return t&&(s.className=t),e!==void 0&&(s.textContent=e),s}function Gh(i,t=!1){return I("div",t?"empty-state empty-state-sm":"empty-state",i)}function gy(i){V.view=i,document.querySelectorAll(".view").forEach(t=>t.classList.toggle("active",t.id===`view-${i}`)),document.querySelectorAll(".nav-item").forEach(t=>t.classList.toggle("active",t.dataset.view===i)),i==="positions"&&tc(),i==="watchlist"&&ec(),i==="alerts"&&ic()}function _y(){V.sidebarCollapsed=!V.sidebarCollapsed,document.getElementById("app").classList.toggle("collapsed",V.sidebarCollapsed)}function yy(i){const t=document.getElementById(`panel-${i}`);if(!t)return;t.classList.toggle("collapsed")?V.collapsedPanels.add(i):V.collapsedPanels.delete(i)}function Hn(){const i=document.getElementById("signals-list");i&&(i.replaceChildren(),V.markets.forEach(t=>{const e=V.signals.find(v=>v.marketId===t.id)||Yo[t.id]||{signal:"neutral"},s=py(e.signal),o=I("div",`market-card${V.activeMarketId===t.id?" active":""}`);o.dataset.market=t.id;const a=I("div","market-cat");a.textContent=`${t.category||"General"} · ${t.countryCode||"GL"}`;const l=I("div","market-q");l.textContent=t.question;const h=I("div","market-footer"),u=I("div","prob-bar-wrap"),d=I("div","prob-bar-bg"),p=I("div",`prob-bar-fill bg-${s}`);p.style.setProperty("--prob-width",`${Math.round(t.yesPrice*100)}%`),d.appendChild(p),u.appendChild(d);const g=I("span",`prob-val text-${s}`);g.textContent=Le(t.yesPrice);const _=I("span",`signal-badge ${Xo(e.signal)}`);_.textContent=Kh(e.signal),h.append(u,g,_),o.append(a,l,h),o.addEventListener("click",()=>Qh(o.dataset.market)),i.appendChild(o)}))}function Jh(){const i=document.getElementById("mini-positions");if(!i)return;if(V.positions.length===0){i.replaceChildren(Gh("Aún sin posiciones",!0));return}i.replaceChildren();let t=0;V.positions.forEach(h=>{const u=V.markets.find(x=>x.id===h.marketId)||{question:h.marketId};t+=h.pnl;const d=h.pnl>=0?"green":"red",p=h.pnl>=0?"+":"",g=I("div","flex-between mb-6"),_=I("span","text-sm text-neutral font-mono");_.textContent=`${u.question.substring(0,32)}${u.question.length>32?"…":""} ${h.outcome}`;const v=I("span",`text-base font-semibold text-${d} font-mono`);v.textContent=`${p}€${h.pnl.toFixed(2)}`,g.append(_,v),i.appendChild(g)});const e=t>=0?"green":"red",s=t>=0?"+":"",o=I("div","flex-between"),a=I("span","text-sm text-neutral font-mono","G&P Neto"),l=I("span",`text-lg font-bold text-${e} font-mono`);l.textContent=`${s}€${t.toFixed(2)}`,o.append(a,l),i.append(I("div","divider"),o)}function Zn(){const i=document.getElementById("detail-body");if(!i)return;const t=V.markets.find(it=>it.id===V.activeMarketId);if(!t){i.replaceChildren(Gh("Selecciona un mercado para ver detalles"));return}const e=V.signals.find(it=>it.marketId===t.id)||Yo[t.id]||{signal:"neutral",confidence:.5,summary:"Aún no hay análisis de IA disponible.",keyRisk:""},s=((t.yesPrice-.5)*20).toFixed(1),o=t.yesPrice>.5?"green":"red",a=t.yesPrice>.5?"+":"",l=I("div","detail-tag");l.textContent=`${t.countryCode||"GL"} · ${t.category||"General"} · Polymarket`;const h=I("div","detail-q");h.textContent=t.question;const u=I("div","detail-meta");u.textContent=`Vol: ${ko(t.volumeEur||0)} · Liq: ${ko(t.liquidityEur||0)} · Cierra: ${Xh(t.closesAt)}`;const d=I("div");d.append(l,h,u);const p=I("div",`metric-value text-${o}`);p.textContent=`${a}${s}%`;const g=I("div","metric");g.append(I("div","metric-label","Cambio 24h"),p);const _=I("div","metric-value text-blue");_.textContent=`${Math.round(e.confidence*100)}%`;const v=I("div","metric");v.append(I("div","metric-label","Confianza"),_);const x=I("div","detail-metrics");x.append(g,I("div","metric-sep"),v);const b=I("div","detail-header");b.append(d,x);const P=I("div","sparkline");P.id="spark-yes";const k=I("div","outcome-price");k.textContent=Le(t.yesPrice);const C=I("div","outcome-delta td-green");C.textContent=`▲ ${(t.yesPrice*.05).toFixed(1)}¢`;const E=I("div","outcome-card yes");E.append(I("div","outcome-name","SÍ"),k,C,P);const A=I("div","sparkline");A.id="spark-no";const T=I("div","outcome-price");T.textContent=Le(t.noPrice);const D=I("div","outcome-delta td-red");D.textContent=`▼ ${(t.noPrice*.05).toFixed(1)}¢`;const R=I("div","outcome-card no");R.append(I("div","outcome-name","NO"),T,D,A);const B=I("canvas");B.id="detail-chart";const N=I("div","chart-container");N.append(I("div","chart-label","Historial de precios 7d"),B);const $=I("div","outcomes-row");$.append(E,R,N);const W=I("span",`signal-badge ${Xo(e.signal)}`);W.textContent=`${my(e.signal).toUpperCase()} · ${Math.round(e.confidence*100)}%`;const j=I("span","text-xs text-neutral font-mono ml-auto","actualizado hace 2m"),vt=I("div","flex-row gap-8 mb-4 flex-wrap");vt.append(I("div","ai-label","Análisis IA · HuggingFace Qwen3-8B"),W,j);const ut=I("div","ai-text");if(ut.textContent=e.summary,e.keyRisk){const it=document.createElement("strong");it.textContent="Riesgo clave:",ut.append(" ",it," ",e.keyRisk)}const rt=I("div","flex-1");rt.append(vt,ut);const K=I("div","ai-box");K.append(I("div","ai-icon","◈"),rt);const tt=I("input","sim-input");tt.id="sim-amount",tt.type="number",tt.value="100",tt.min="1",tt.placeholder="€";const F=I("button","sim-btn-yes","COMPRAR SÍ ↗");F.id="sim-yes";const _t=I("button","sim-btn-no","COMPRAR NO");_t.id="sim-no";const Z=I("div","sim-row");Z.append(I("span","sim-label","Simular posición →"),tt,F,_t,I("span","sim-disclaimer","Simulado · sin trading real")),i.replaceChildren(b,$,K,Z),F.addEventListener("click",()=>Bl(t.id,"SÍ",tt.value)),_t.addEventListener("click",()=>Bl(t.id,"NO",tt.value)),J_("detail-chart",t.yesPrice),Il("spark-yes",t.yesPrice,"yes"),Il("spark-no",t.noPrice,"no")}function Qh(i){V.activeMarketId=i,Hn(),Zn(),hy(i)}function tc(){const i=document.querySelector("#positions-table tbody"),t=document.getElementById("positions-empty");if(i){if(V.positions.length===0){i.replaceChildren(),t.classList.remove("hidden");return}t.classList.add("hidden"),i.replaceChildren(),V.positions.forEach(e=>{const s=V.markets.find(k=>k.id===e.marketId)||{question:e.marketId},o=e.pnl>=0?"td-green":"td-red",a=e.pnl>=0?"+":"",l=document.createElement("tr"),h=I("td");h.textContent=`${s.question.substring(0,40)}${s.question.length>40?"…":""}`;const u=I("td",`td-mono ${e.outcome==="SÍ"?"td-green":"td-red"}`);u.textContent=e.outcome;const d=I("td","td-mono");d.textContent=`€${e.amountEur.toFixed(0)}`;const p=I("td","td-mono");p.textContent=Le(e.entryPrice);const g=I("td","td-mono");g.textContent=Le(e.currentPrice);const _=I("td",`td-mono ${o}`);_.textContent=`${a}€${e.pnl.toFixed(2)}`;const v=I("td","td-mono td-blue");v.textContent=`${((e.kellyFraction||0)*100).toFixed(0)}%`;const x=I("td","td-mono");x.textContent=Xh(e.openedAt);const b=I("button","btn-ghost","Cerrar");b.addEventListener("click",()=>vy(e.id));const P=I("td");P.appendChild(b),l.append(h,u,d,p,g,_,v,x,P),i.appendChild(l)})}}async function vy(i){await uy(i),await nc(),tc(),Jh()}function ec(){const i=document.querySelector("#watchlist-table tbody"),t=document.getElementById("watchlist-empty");if(i){if(V.watchlist.length===0){i.replaceChildren(),t.classList.remove("hidden");return}t.classList.add("hidden"),i.replaceChildren(),V.watchlist.forEach(e=>{const s=V.markets.find(P=>P.id===e.marketId)||{question:e.marketId,category:"-",yesPrice:0,noPrice:0,volumeEur:0},o=V.signals.find(P=>P.marketId===e.marketId)||{signal:"neutral"},a=document.createElement("tr"),l=I("td");l.textContent=`${s.question.substring(0,40)}${s.question.length>40?"…":""}`;const h=I("td");h.textContent=s.category||"-";const u=I("td","td-mono td-green");u.textContent=Le(s.yesPrice);const d=I("td","td-mono td-red");d.textContent=Le(s.noPrice);const p=I("span",`signal-badge ${Xo(o.signal)}`);p.textContent=Kh(o.signal);const g=I("td");g.appendChild(p);const _=I("td","td-mono");_.textContent=ko(s.volumeEur||0);const v=I("td","td-mono");v.textContent=e.alertThreshold?Le(e.alertThreshold):"-";const x=I("button","btn-ghost","Eliminar");x.addEventListener("click",()=>by(e.marketId));const b=I("td");b.appendChild(x),a.append(l,h,u,d,g,_,v,b),i.appendChild(a)})}}async function by(i){try{await Ld(i)}catch(t){console.warn(t)}V.watchlist=V.watchlist.filter(t=>t.marketId!==i),ec()}function ic(){const i=document.querySelector("#alerts-table tbody"),t=document.getElementById("alerts-empty");if(i){if(V.alerts.length===0){i.replaceChildren(),t.classList.remove("hidden");return}t.classList.add("hidden"),i.replaceChildren(),V.alerts.forEach(e=>{const s=V.markets.find(p=>p.id===e.marketId)||{question:e.marketId},o=document.createElement("tr"),a=I("td","td-mono");a.textContent=new Date(e.sentAt).toLocaleString("es-ES");const l=I("td");l.textContent=`${s.question.substring(0,35)}${s.question.length>35?"…":""}`;const h=I("span","signal-badge sig-neut");h.textContent=e.type;const u=I("td");u.appendChild(h);const d=I("td");d.textContent=e.message,o.append(a,l,u,d),i.appendChild(o)})}}async function xy(){try{const i=await xd({limit:50});V.markets=i.length?i:zl}catch{console.warn("API mercados no disponible, usando datos de prueba"),V.markets=zl}}async function wy(){try{const i=V.markets.map(e=>wd(e.id).catch(()=>null)),t=await Promise.all(i);V.signals=t.filter(Boolean).map((e,s)=>({...e,marketId:V.markets[s].id}))}catch{console.warn("API señales no disponible, usando datos de prueba"),V.signals=Object.entries(Yo).map(([t,e])=>({...e,marketId:t}))}}async function nc(){try{V.positions=await Pd()}catch{V.positions=dy}}async function Py(){try{V.watchlist=await Md()}catch{V.watchlist=[]}}async function ky(){try{V.alerts=await Cd()}catch{V.alerts=fy}}async function Sy(){document.getElementById("sidebar-toggle")?.addEventListener("click",_y),document.querySelectorAll(".nav-item").forEach(t=>{t.addEventListener("click",()=>gy(t.dataset.view))}),document.querySelectorAll(".panel-header[data-panel]").forEach(t=>{t.addEventListener("click",e=>{e.target.closest("button, input, a")||yy(t.dataset.panel)})}),await xy(),await wy(),await nc(),await Py(),await ky(),ay("map-container",V.markets,V.signals,Qh),cy(V),V.activeMarketId=V.markets[0]?.id||null,Hn(),Zn(),Jh();const i=Nn();i.on("connect",()=>console.log("Socket.io conectado")),i.on("market_update",t=>{const e=V.markets.find(s=>s.id===t.marketId);e&&(typeof t.yesPrice=="number"&&(e.yesPrice=t.yesPrice),typeof t.noPrice=="number"&&(e.noPrice=t.noPrice),typeof t.volumeEur=="number"&&(e.volumeEur=t.volumeEur),typeof t.liquidityEur=="number"&&(e.liquidityEur=t.liquidityEur),V.activeMarketId===t.marketId&&Zn(),Hn(),ly(t.marketId,t.yesPrice))}),i.on("ai_signal",t=>{if(!t?.marketId||typeof t.signal!="string")return;const e=V.signals.findIndex(s=>s.marketId===t.marketId);e>=0?V.signals[e]=t:V.signals.push(t),Hn(),V.activeMarketId===t.marketId&&Zn()}),i.on("price_alert",t=>{!t?.marketId||!t.type||(V.alerts.unshift(t),V.view==="alerts"&&ic())}),setInterval(()=>{const t=document.getElementById("stat-markets");if(t){const s=parseInt(t.textContent.replace(/\./g,""))+Math.floor(Math.random()*3);t.textContent=s.toLocaleString("es-ES")}const e=document.getElementById("stat-signals");e&&Math.random()>.7&&(e.textContent=parseInt(e.textContent)+1)},3e3)}Sy().catch(i=>console.error("Failed to initialize app:",i)); diff --git a/frontend/dist/assets/index-CnesqZ-E.css b/frontend/dist/assets/index-CnesqZ-E.css deleted file mode 100644 index 8076dae6e1f1776b0176155234d924bdde306ddb..0000000000000000000000000000000000000000 --- a/frontend/dist/assets/index-CnesqZ-E.css +++ /dev/null @@ -1 +0,0 @@ -@import"https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@400;500;600;700&display=swap";:root{--bg: #0a0c10;--bg2: #111318;--bg3: #181c24;--bg4: #1e232d;--border: rgba(255,255,255,.08);--border2: rgba(255,255,255,.13);--text: #e8eaf0;--text2: #8b90a0;--text3: #555b6e;--green: #22d37a;--green2: #0d6e3a;--green3: #052a17;--red: #f04040;--red2: #7a1a1a;--red3: #2d0808;--blue: #4a9eff;--blue2: #1a4a80;--blue3: #081830;--amber: #f0a020;--amber2: #7a4e08;--amber3: #2d1c02;--accent: #4a9eff;--sidebar-width: 240px;--sidebar-collapsed: 56px;--topbar-height: 56px;--panel-gap: 16px;--radius: 10px;--radius-sm: 6px;--fs-p: clamp(16px, 1.15vw, 18px);--fs-h1: clamp(28px, 2.8vw, 36px);--fs-h2: clamp(24px, 2.4vw, 30px);--fs-h3: clamp(20px, 1.9vw, 24px);--fs-h4: clamp(18px, 1.6vw, 20px);--fs-h5: clamp(16px, 1.3vw, 18px);--fs-h6: clamp(14px, 1.1vw, 16px)}*{box-sizing:border-box;margin:0;padding:0}html,body,#app{height:100%;width:100%;overflow:hidden}body{background:var(--bg);color:var(--text);font-family:Syne,sans-serif;font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased}p{font-size:var(--fs-p);line-height:1.55}h1{font-size:var(--fs-h1);line-height:1.15;font-weight:700}h2{font-size:var(--fs-h2);line-height:1.2;font-weight:700}h3{font-size:var(--fs-h3);line-height:1.25;font-weight:600}h4{font-size:var(--fs-h4);line-height:1.3;font-weight:600}h5{font-size:var(--fs-h5);line-height:1.35;font-weight:500}h6{font-size:var(--fs-h6);line-height:1.4;font-weight:500}.layout{display:grid;grid-template-areas:"topbar topbar" "sidebar main";grid-template-columns:var(--sidebar-width) 1fr;grid-template-rows:var(--topbar-height) 1fr;height:100vh;width:100vw;transition:grid-template-columns .25s ease}.layout.collapsed{grid-template-columns:var(--sidebar-collapsed) 1fr}.sidebar{grid-area:sidebar;background:var(--bg2);border-right:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden;transition:width .25s ease;position:relative}.sidebar-toggle{position:absolute;top:12px;right:-10px;width:24px;height:24px;border-radius:50%;background:var(--bg3);border:1px solid var(--border2);color:var(--text2);display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:14px;z-index:10;transition:transform .2s}.layout.collapsed .sidebar-toggle{transform:rotate(180deg);right:-10px}.topbar-logo{position:absolute;left:16px;top:0;bottom:0;display:flex;align-items:center;gap:10px}.topbar-logo .logo-dot{width:10px;height:10px;border-radius:50%;background:var(--blue);animation:pulse 2s ease-in-out infinite;flex-shrink:0}.topbar-logo .logo-text{font-size:18px;font-weight:700;color:var(--text);letter-spacing:-.3px;white-space:nowrap}.sidebar-nav{flex:1;padding:14px 8px;display:flex;flex-direction:column;gap:4px;overflow-y:auto}.nav-item{display:flex;align-items:center;gap:14px;padding:14px;border-radius:var(--radius-sm);cursor:pointer;color:var(--text2);font-size:16px;font-weight:500;transition:background .15s,color .15s;white-space:nowrap;overflow:hidden}.nav-item:hover{background:var(--bg3);color:var(--text)}.nav-item.active{background:var(--blue3);color:var(--blue);border:.5px solid var(--blue2)}.nav-icon{font-size:16px;width:20px;text-align:center;flex-shrink:0}.nav-label{opacity:1;transition:opacity .15s}.layout.collapsed .nav-label{opacity:0;width:0}.sidebar-footer{padding:14px;border-top:1px solid var(--border);font-size:14px;color:var(--text3);font-family:DM Mono,monospace;text-align:center;white-space:nowrap;overflow:hidden}.layout.collapsed .sidebar-footer{opacity:0}.topbar{grid-area:topbar;background:var(--bg2);border-bottom:1px solid var(--border);display:flex;align-items:center;padding:0 16px;padding-left:calc(var(--sidebar-width) + var(--panel-gap));gap:16px;overflow:hidden;position:relative;transition:padding-left .25s ease}.layout.collapsed .topbar{padding-left:calc(var(--sidebar-collapsed) + var(--panel-gap))}.live-badge{font-family:DM Mono,monospace;font-size:14px;background:var(--green3);color:var(--green);border:.5px solid var(--green2);padding:6px 12px;border-radius:4px;display:flex;align-items:center;gap:4px;flex-shrink:0}.live-dot{width:8px;height:8px;border-radius:50%;background:var(--green);animation:pulse 1.5s ease-in-out infinite}.topbar-stats{display:flex;align-items:center;gap:20px;flex:1;overflow:hidden}.stat{display:flex;align-items:center;gap:14px;flex-shrink:0}.stat-label{font-size:14px;color:var(--text3);font-family:DM Mono,monospace;text-transform:uppercase;letter-spacing:.06em}.stat-val{font-size:16px;font-weight:600;color:var(--text);font-family:DM Mono,monospace}.stat-delta{font-size:14px;font-family:DM Mono,monospace}.stat-delta.up{color:var(--green)}.stat-delta.dn{color:var(--red)}.stat-delta.neutral{color:var(--text3)}.topbar-actions{margin-left:auto;display:flex;align-items:center;gap:16px;flex-shrink:0}.btn-ghost{font-size:15px;font-weight:500;color:var(--blue);border:.5px solid var(--blue2);background:var(--blue3);padding:8px 16px;border-radius:var(--radius-sm);cursor:pointer;font-family:Syne,sans-serif;transition:opacity .15s}.btn-ghost:hover{opacity:.85}.icon-btn{width:32px;height:32px;border-radius:50%;background:var(--bg3);border:.5px solid var(--border2);color:var(--text2);display:flex;align-items:center;justify-content:center;cursor:pointer;font-size:16px;transition:color .15s,border-color .15s}.icon-btn:hover{color:var(--text);border-color:var(--border2)}.main{grid-area:main;overflow:auto;padding:var(--panel-gap);background:var(--bg)}.view{display:none}.view.active{display:block;height:100%}.dashboard-grid{display:grid;grid-template-columns:1fr 280px;grid-template-rows:1fr minmax(280px,40%);gap:var(--panel-gap);height:100%;min-height:0}.panel{background:var(--bg2);border:.5px solid var(--border);border-radius:var(--radius);display:flex;flex-direction:column;overflow:hidden;min-height:0}.panel-header{display:flex;align-items:center;justify-content:space-between;padding:14px;border-bottom:.5px solid var(--border);cursor:pointer;-webkit-user-select:none;user-select:none;transition:background .15s}.panel-header:hover{background:#ffffff05}.panel-title{font-size:14px;color:var(--text3);font-family:DM Mono,monospace;text-transform:uppercase;letter-spacing:.08em;display:flex;align-items:center;gap:14px}.panel-toggle{font-size:14px;color:var(--text3);transition:transform .2s}.panel.collapsed .panel-toggle{transform:rotate(-90deg)}.panel-body{flex:1;overflow:auto;padding:12px;min-height:0}.panel.collapsed .panel-body{display:none}.panel-subtitle{font-size:14px;color:var(--text3)}.positions-separator{margin-top:10px;padding-top:10px;border-top:.5px solid var(--border)}.panel-title.mb-sm{margin-bottom:8px}.panel.full-height{height:100%}.hidden{display:none}.map-panel{grid-row:1 / 2;grid-column:1 / 2}#map-container{width:100%;height:100%;min-height:300px;background:var(--bg3);border-radius:var(--radius-sm);overflow:hidden}.signals-panel{grid-row:1 / 3;grid-column:2 / 3}.signals-list{display:flex;flex-direction:column;gap:16px}.market-card{background:var(--bg3);border:.5px solid var(--border);border-radius:var(--radius-sm);padding:14px;cursor:pointer;transition:border-color .15s,background .15s}.market-card:hover{border-color:var(--border2)}.market-card.active{border-color:var(--blue2);background:var(--blue3)}.market-cat{font-size:14px;font-family:DM Mono,monospace;color:var(--text3);text-transform:uppercase;letter-spacing:.06em;margin-bottom:4px}.market-q{font-size:15px;color:var(--text);line-height:1.4;font-weight:500;margin-bottom:8px}.market-footer{display:flex;align-items:center;justify-content:space-between;gap:16px}.prob-bar-wrap{flex:1;min-width:0}.prob-bar-bg{height:5px;background:var(--bg4);border-radius:2px;overflow:hidden}.prob-bar-fill{height:100%;border-radius:2px;width:var(--prob-width, 0%);transition:width .8s ease}.prob-val{font-size:15px;font-weight:600;font-family:DM Mono,monospace;flex-shrink:0}.signal-badge{font-size:14px;font-weight:600;padding:2px 6px;border-radius:4px;font-family:DM Mono,monospace;letter-spacing:.04em;flex-shrink:0}.sig-bull{background:var(--green3);color:var(--green);border:.5px solid var(--green2)}.sig-bear{background:var(--red3);color:var(--red);border:.5px solid var(--red2)}.sig-neut{background:var(--bg4);color:var(--text2);border:.5px solid var(--border2)}.detail-panel{grid-row:2 / 3;grid-column:1 / 2;max-height:100%;overflow:hidden}.detail-panel .panel-body{overflow-y:auto}.detail-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:12px;gap:16px}.detail-tag{font-size:14px;color:var(--blue);font-family:DM Mono,monospace;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px}.detail-q{font-size:16px;font-weight:600;color:var(--text);line-height:1.5}.detail-meta{font-size:14px;color:var(--text3);font-family:DM Mono,monospace;margin-top:2px}.detail-metrics{display:flex;gap:16px;align-items:center;flex-shrink:0}.metric{text-align:right}.metric-label{font-size:14px;color:var(--text3);font-family:DM Mono,monospace;margin-bottom:2px}.metric-value{font-size:14px;font-weight:700;font-family:DM Mono,monospace}.metric-sep{width:1px;height:40px;background:var(--border)}.outcomes-row{display:flex;gap:16px;margin-bottom:12px}.outcome-card{flex:1;background:var(--bg3);border:.5px solid var(--border);border-radius:var(--radius-sm);padding:14px;text-align:center}.outcome-name{font-size:14px;color:var(--text2);margin-bottom:4px;font-family:DM Mono,monospace}.outcome-price{font-size:20px;font-weight:700;color:var(--text);font-family:DM Mono,monospace}.outcome-delta{font-size:14px;font-family:DM Mono,monospace;margin-top:2px}.outcome-card.yes .outcome-price{color:var(--green)}.outcome-card.no .outcome-price{color:var(--red)}.chart-container{flex:2;background:var(--bg3);border:.5px solid var(--border);border-radius:var(--radius-sm);padding:14px;min-height:120px;height:160px;max-height:160px;overflow:hidden}.chart-container canvas{max-height:130px}.chart-label{font-size:14px;color:var(--text3);font-family:DM Mono,monospace;margin-bottom:6px}.ai-box{background:var(--bg3);border:.5px solid var(--blue2);border-radius:var(--radius-sm);padding:14px;display:flex;gap:14px;align-items:flex-start;margin-bottom:10px}.ai-icon{width:32px;height:32px;border-radius:6px;background:var(--blue3);display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:14px}.ai-label{font-size:14px;color:var(--blue);font-family:DM Mono,monospace;text-transform:uppercase;letter-spacing:.06em;margin-bottom:3px}.ai-text{font-size:15px;color:var(--text2);line-height:1.5}.sim-row{display:flex;gap:16px;align-items:center;flex-wrap:wrap}.sim-label{font-size:15px;color:var(--text3);font-family:DM Mono,monospace}.sim-input{background:var(--bg3);border:.5px solid var(--border2);border-radius:var(--radius-sm);padding:8px 14px;color:var(--text);font-size:16px;font-family:DM Mono,monospace;width:100px;outline:none}.sim-input:focus{border-color:var(--blue2)}.sim-btn-yes{background:var(--green3);border:.5px solid var(--green2);color:var(--green);font-size:15px;font-weight:600;padding:8px 16px;border-radius:var(--radius-sm);cursor:pointer;font-family:DM Mono,monospace;transition:opacity .15s}.sim-btn-no{background:var(--red3);border:.5px solid var(--red2);color:var(--red);font-size:15px;font-weight:600;padding:8px 16px;border-radius:var(--radius-sm);cursor:pointer;font-family:DM Mono,monospace;transition:opacity .15s}.sim-btn-yes:hover,.sim-btn-no:hover{opacity:.85}.sim-disclaimer{font-size:14px;color:var(--text3);font-family:DM Mono,monospace}.legend{display:flex;gap:16px;align-items:center}.legend-item{display:flex;align-items:center;gap:5px;font-size:14px;color:var(--text3);font-family:DM Mono,monospace}.legend-dot{width:10px;height:10px;border-radius:50%}.legend-dot.green{background:var(--green)}.legend-dot.red{background:var(--red)}.legend-dot.gray{background:var(--text3)}.legend.end{margin-left:auto}.table-wrap{overflow:auto;border:.5px solid var(--border);border-radius:var(--radius-sm);background:var(--bg3)}table{width:100%;border-collapse:collapse;font-size:16px}th,td{padding:14px;text-align:left;border-bottom:.5px solid var(--border)}th{font-family:DM Mono,monospace;font-size:14px;color:var(--text3);text-transform:uppercase;letter-spacing:.06em;font-weight:500;background:var(--bg4);position:sticky;top:0}tr:hover td{background:#ffffff05}td{color:var(--text)}.td-mono{font-family:DM Mono,monospace}.td-green{color:var(--green)}.td-red{color:var(--red)}.td-blue{color:var(--blue)}.empty-state{padding:40px;text-align:center;color:var(--text3);font-size:16px}#app .leaflet-container{background:var(--bg3);font-family:DM Mono,monospace}#app .leaflet-popup-content-wrapper{background:var(--bg2);color:var(--text);border:.5px solid var(--border);border-radius:var(--radius-sm)}#app .leaflet-popup-tip{background:var(--bg2)}.sparkline{display:flex;align-items:flex-end;gap:2px;height:32px;margin-top:6px}.spark-bar{width:3px;border-radius:1px;background:var(--blue2);transition:height .3s}@keyframes pulse{0%,to{opacity:1}50%{opacity:.4}}::-webkit-scrollbar{width:6px;height:6px}::-webkit-scrollbar-track{background:transparent}::-webkit-scrollbar-thumb{background:var(--bg4);border-radius:3px}::-webkit-scrollbar-thumb:hover{background:var(--text3)}.flex-between{display:flex;justify-content:space-between;align-items:center}.flex-start{display:flex;align-items:flex-start;justify-content:space-between}.flex-row{display:flex;align-items:center}.flex-wrap{flex-wrap:wrap}.gap-6{gap:14px}.gap-8{gap:16px}.text-green{color:var(--green)}.text-red{color:var(--red)}.text-blue{color:var(--blue)}.text-amber{color:var(--amber)}.text-neutral{color:var(--text3)}.bg-green{background:var(--green)}.bg-red{background:var(--red)}.bg-amber{background:var(--amber)}.flex-1{flex:1}.font-mono{font-family:DM Mono,monospace}.text-xs,.text-sm{font-size:14px}.text-base{font-size:15px}.text-lg{font-size:16px}.text-xl{font-size:18px}.font-semibold{font-weight:600}.font-bold{font-weight:700}.mb-4{margin-bottom:4px}.mb-6{margin-bottom:6px}.mb-8{margin-bottom:8px}.mt-4{margin-top:4px}.mt-6{margin-top:6px}.ml-auto{margin-left:auto}.divider{height:1px;background:var(--border);margin:8px 0}.empty-state-sm{padding:16px;text-align:center;color:var(--text3);font-size:16px}.map-popup{font-family:Syne,sans-serif;font-size:15px;color:var(--text);max-width:200px}.map-popup-cat{font-size:14px;color:var(--text3);font-family:DM Mono,monospace;margin-bottom:4px;text-transform:uppercase}.map-popup-q{font-weight:600;margin-bottom:4px;line-height:1.3}.map-popup-prices{display:flex;gap:16px;font-family:DM Mono,monospace;font-size:15px}.map-label-text{color:var(--text2);font-family:DM Mono,monospace;font-size:14px;text-shadow:0 1px 2px #000}@media(max-width:1024px){.dashboard-grid{grid-template-columns:1fr;grid-template-rows:auto auto auto}.signals-panel{grid-row:auto;grid-column:auto;max-height:400px}.map-panel{grid-row:auto;grid-column:auto;min-height:300px}.detail-panel{grid-row:auto;grid-column:auto}}@media(max-width:640px){.layout{grid-template-columns:0 1fr}.sidebar,.topbar-stats{display:none}.outcomes-row{flex-direction:column}}.leaflet-pane,.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-tile-container,.leaflet-pane>svg,.leaflet-pane>canvas,.leaflet-zoom-box,.leaflet-image-layer,.leaflet-layer{position:absolute;left:0;top:0}.leaflet-container{overflow:hidden}.leaflet-tile,.leaflet-marker-icon,.leaflet-marker-shadow{-webkit-user-select:none;-moz-user-select:none;user-select:none;-webkit-user-drag:none}.leaflet-tile::selection{background:transparent}.leaflet-safari .leaflet-tile{image-rendering:-webkit-optimize-contrast}.leaflet-safari .leaflet-tile-container{width:1600px;height:1600px;-webkit-transform-origin:0 0}.leaflet-marker-icon,.leaflet-marker-shadow{display:block}.leaflet-container .leaflet-overlay-pane svg{max-width:none!important;max-height:none!important}.leaflet-container .leaflet-marker-pane img,.leaflet-container .leaflet-shadow-pane img,.leaflet-container .leaflet-tile-pane img,.leaflet-container img.leaflet-image-layer,.leaflet-container .leaflet-tile{max-width:none!important;max-height:none!important;width:auto;padding:0}.leaflet-container img.leaflet-tile{mix-blend-mode:plus-lighter}.leaflet-container.leaflet-touch-zoom{-ms-touch-action:pan-x pan-y;touch-action:pan-x pan-y}.leaflet-container.leaflet-touch-drag{-ms-touch-action:pinch-zoom;touch-action:none;touch-action:pinch-zoom}.leaflet-container.leaflet-touch-drag.leaflet-touch-zoom{-ms-touch-action:none;touch-action:none}.leaflet-container{-webkit-tap-highlight-color:transparent}.leaflet-container a{-webkit-tap-highlight-color:rgba(51,181,229,.4)}.leaflet-tile{filter:inherit;visibility:hidden}.leaflet-tile-loaded{visibility:inherit}.leaflet-zoom-box{width:0;height:0;-moz-box-sizing:border-box;box-sizing:border-box;z-index:800}.leaflet-overlay-pane svg{-moz-user-select:none}.leaflet-pane{z-index:400}.leaflet-tile-pane{z-index:200}.leaflet-overlay-pane{z-index:400}.leaflet-shadow-pane{z-index:500}.leaflet-marker-pane{z-index:600}.leaflet-tooltip-pane{z-index:650}.leaflet-popup-pane{z-index:700}.leaflet-map-pane canvas{z-index:100}.leaflet-map-pane svg{z-index:200}.leaflet-vml-shape{width:1px;height:1px}.lvml{behavior:url(#default#VML);display:inline-block;position:absolute}.leaflet-control{position:relative;z-index:800;pointer-events:visiblePainted;pointer-events:auto}.leaflet-top,.leaflet-bottom{position:absolute;z-index:1000;pointer-events:none}.leaflet-top{top:0}.leaflet-right{right:0}.leaflet-bottom{bottom:0}.leaflet-left{left:0}.leaflet-control{float:left;clear:both}.leaflet-right .leaflet-control{float:right}.leaflet-top .leaflet-control{margin-top:10px}.leaflet-bottom .leaflet-control{margin-bottom:10px}.leaflet-left .leaflet-control{margin-left:10px}.leaflet-right .leaflet-control{margin-right:10px}.leaflet-fade-anim .leaflet-popup{opacity:0;-webkit-transition:opacity .2s linear;-moz-transition:opacity .2s linear;transition:opacity .2s linear}.leaflet-fade-anim .leaflet-map-pane .leaflet-popup{opacity:1}.leaflet-zoom-animated{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}svg.leaflet-zoom-animated{will-change:transform}.leaflet-zoom-anim .leaflet-zoom-animated{-webkit-transition:-webkit-transform .25s cubic-bezier(0,0,.25,1);-moz-transition:-moz-transform .25s cubic-bezier(0,0,.25,1);transition:transform .25s cubic-bezier(0,0,.25,1)}.leaflet-zoom-anim .leaflet-tile,.leaflet-pan-anim .leaflet-tile{-webkit-transition:none;-moz-transition:none;transition:none}.leaflet-zoom-anim .leaflet-zoom-hide{visibility:hidden}.leaflet-interactive{cursor:pointer}.leaflet-grab{cursor:-webkit-grab;cursor:-moz-grab;cursor:grab}.leaflet-crosshair,.leaflet-crosshair .leaflet-interactive{cursor:crosshair}.leaflet-popup-pane,.leaflet-control{cursor:auto}.leaflet-dragging .leaflet-grab,.leaflet-dragging .leaflet-grab .leaflet-interactive,.leaflet-dragging .leaflet-marker-draggable{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.leaflet-marker-icon,.leaflet-marker-shadow,.leaflet-image-layer,.leaflet-pane>svg path,.leaflet-tile-container{pointer-events:none}.leaflet-marker-icon.leaflet-interactive,.leaflet-image-layer.leaflet-interactive,.leaflet-pane>svg path.leaflet-interactive,svg.leaflet-image-layer.leaflet-interactive path{pointer-events:visiblePainted;pointer-events:auto}.leaflet-container{background:#ddd;outline-offset:1px}.leaflet-container a{color:#0078a8}.leaflet-zoom-box{border:2px dotted #38f;background:#ffffff80}.leaflet-container{font-family:Helvetica Neue,Arial,Helvetica,sans-serif;font-size:12px;font-size:.75rem;line-height:1.5}.leaflet-bar{box-shadow:0 1px 5px #000000a6;border-radius:4px}.leaflet-bar a{background-color:#fff;border-bottom:1px solid #ccc;width:26px;height:26px;line-height:26px;display:block;text-align:center;text-decoration:none;color:#000}.leaflet-bar a,.leaflet-control-layers-toggle{background-position:50% 50%;background-repeat:no-repeat;display:block}.leaflet-bar a:hover,.leaflet-bar a:focus{background-color:#f4f4f4}.leaflet-bar a:first-child{border-top-left-radius:4px;border-top-right-radius:4px}.leaflet-bar a:last-child{border-bottom-left-radius:4px;border-bottom-right-radius:4px;border-bottom:none}.leaflet-bar a.leaflet-disabled{cursor:default;background-color:#f4f4f4;color:#bbb}.leaflet-touch .leaflet-bar a{width:30px;height:30px;line-height:30px}.leaflet-touch .leaflet-bar a:first-child{border-top-left-radius:2px;border-top-right-radius:2px}.leaflet-touch .leaflet-bar a:last-child{border-bottom-left-radius:2px;border-bottom-right-radius:2px}.leaflet-control-zoom-in,.leaflet-control-zoom-out{font:700 18px Lucida Console,Monaco,monospace;text-indent:1px}.leaflet-touch .leaflet-control-zoom-in,.leaflet-touch .leaflet-control-zoom-out{font-size:22px}.leaflet-control-layers{box-shadow:0 1px 5px #0006;background:#fff;border-radius:5px}.leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAQAAAADQ4RFAAACf0lEQVR4AY1UM3gkARTePdvdoTxXKc+qTl3aU5U6b2Kbkz3Gtq3Zw6ziLGNPzrYx7946Tr6/ee/XeCQ4D3ykPtL5tHno4n0d/h3+xfuWHGLX81cn7r0iTNzjr7LrlxCqPtkbTQEHeqOrTy4Yyt3VCi/IOB0v7rVC7q45Q3Gr5K6jt+3Gl5nCoDD4MtO+j96Wu8atmhGqcNGHObuf8OM/x3AMx38+4Z2sPqzCxRFK2aF2e5Jol56XTLyggAMTL56XOMoS1W4pOyjUcGGQdZxU6qRh7B9Zp+PfpOFlqt0zyDZckPi1ttmIp03jX8gyJ8a/PG2yutpS/Vol7peZIbZcKBAEEheEIAgFbDkz5H6Zrkm2hVWGiXKiF4Ycw0RWKdtC16Q7qe3X4iOMxruonzegJzWaXFrU9utOSsLUmrc0YjeWYjCW4PDMADElpJSSQ0vQvA1Tm6/JlKnqFs1EGyZiFCqnRZTEJJJiKRYzVYzJck2Rm6P4iH+cmSY0YzimYa8l0EtTODFWhcMIMVqdsI2uiTvKmTisIDHJ3od5GILVhBCarCfVRmo4uTjkhrhzkiBV7SsaqS+TzrzM1qpGGUFt28pIySQHR6h7F6KSwGWm97ay+Z+ZqMcEjEWebE7wxCSQwpkhJqoZA5ivCdZDjJepuJ9IQjGGUmuXJdBFUygxVqVsxFsLMbDe8ZbDYVCGKxs+W080max1hFCarCfV+C1KATwcnvE9gRRuMP2prdbWGowm1KB1y+zwMMENkM755cJ2yPDtqhTI6ED1M/82yIDtC/4j4BijjeObflpO9I9MwXTCsSX8jWAFeHr05WoLTJ5G8IQVS/7vwR6ohirYM7f6HzYpogfS3R2OAAAAAElFTkSuQmCC);width:36px;height:36px}.leaflet-retina .leaflet-control-layers-toggle{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAQAAABvcdNgAAAEsklEQVR4AWL4TydIhpZK1kpWOlg0w3ZXP6D2soBtG42jeI6ZmQTHzAxiTbSJsYLjO9HhP+WOmcuhciVnmHVQcJnp7DFvScowZorad/+V/fVzMdMT2g9Cv9guXGv/7pYOrXh2U+RRR3dSd9JRx6bIFc/ekqHI29JC6pJ5ZEh1yWkhkbcFeSjxgx3L2m1cb1C7bceyxA+CNjT/Ifff+/kDk2u/w/33/IeCMOSaWZ4glosqT3DNnNZQ7Cs58/3Ce5HL78iZH/vKVIaYlqzfdLu8Vi7dnvUbEza5Idt36tquZFldl6N5Z/POLof0XLK61mZCmJSWjVF9tEjUluu74IUXvgttuVIHE7YxSkaYhJZam7yiM9Pv82JYfl9nptxZaxMJE4YSPty+vF0+Y2up9d3wwijfjZbabqm/3bZ9ecKHsiGmRflnn1MW4pjHf9oLufyn2z3y1D6n8g8TZhxyzipLNPnAUpsOiuWimg52psrTZYnOWYNDTMuWBWa0tJb4rgq1UvmutpaYEbZlwU3CLJm/ayYjHW5/h7xWLn9Hh1vepDkyf7dE7MtT5LR4e7yYpHrkhOUpEfssBLq2pPhAqoSWKUkk7EDqkmK6RrCEzqDjhNDWNE+XSMvkJRDWlZTmCW0l0PHQGRZY5t1L83kT0Y3l2SItk5JAWHl2dCOBm+fPu3fo5/3v61RMCO9Jx2EEYYhb0rmNQMX/vm7gqOEJLcXTGw3CAuRNeyaPWwjR8PRqKQ1PDA/dpv+on9Shox52WFnx0KY8onHayrJzm87i5h9xGw/tfkev0jGsQizqezUKjk12hBMKJ4kbCqGPVNXudyyrShovGw5CgxsRICxF6aRmSjlBnHRzg7Gx8fKqEubI2rahQYdR1YgDIRQO7JvQyD52hoIQx0mxa0ODtW2Iozn1le2iIRdzwWewedyZzewidueOGqlsn1MvcnQpuVwLGG3/IR1hIKxCjelIDZ8ldqWz25jWAsnldEnK0Zxro19TGVb2ffIZEsIO89EIEDvKMPrzmBOQcKQ+rroye6NgRRxqR4U8EAkz0CL6uSGOm6KQCdWjvjRiSP1BPalCRS5iQYiEIvxuBMJEWgzSoHADcVMuN7IuqqTeyUPq22qFimFtxDyBBJEwNyt6TM88blFHao/6tWWhuuOM4SAK4EI4QmFHA+SEyWlp4EQoJ13cYGzMu7yszEIBOm2rVmHUNqwAIQabISNMRstmdhNWcFLsSm+0tjJH1MdRxO5Nx0WDMhCtgD6OKgZeljJqJKc9po8juskR9XN0Y1lZ3mWjLR9JCO1jRDMd0fpYC2VnvjBSEFg7wBENc0R9HFlb0xvF1+TBEpF68d+DHR6IOWVv2BECtxo46hOFUBd/APU57WIoEwJhIi2CdpyZX0m93BZicktMj1AS9dClteUFAUNUIEygRZCtik5zSxI9MubTBH1GOiHsiLJ3OCoSZkILa9PxiN0EbvhsAo8tdAf9Seepd36lGWHmtNANTv5Jd0z4QYyeo/UEJqxKRpg5LZx6btLPsOaEmdMyxYdlc8LMaJnikDlhclqmPiQnTEpLUIZEwkRagjYkEibQErwhkTAKCLQEbUgkzJQWc/0PstHHcfEdQ+UAAAAASUVORK5CYII=);background-size:26px 26px}.leaflet-touch .leaflet-control-layers-toggle{width:44px;height:44px}.leaflet-control-layers .leaflet-control-layers-list,.leaflet-control-layers-expanded .leaflet-control-layers-toggle{display:none}.leaflet-control-layers-expanded .leaflet-control-layers-list{display:block;position:relative}.leaflet-control-layers-expanded{padding:6px 10px 6px 6px;color:#333;background:#fff}.leaflet-control-layers-scrollbar{overflow-y:scroll;overflow-x:hidden;padding-right:5px}.leaflet-control-layers-selector{margin-top:2px;position:relative;top:1px}.leaflet-control-layers label{display:block;font-size:13px;font-size:1.08333em}.leaflet-control-layers-separator{height:0;border-top:1px solid #ddd;margin:5px -10px 5px -6px}.leaflet-default-icon-path{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=)}.leaflet-container .leaflet-control-attribution{background:#fff;background:#fffc;margin:0}.leaflet-control-attribution,.leaflet-control-scale-line{padding:0 5px;color:#333;line-height:1.4}.leaflet-control-attribution a{text-decoration:none}.leaflet-control-attribution a:hover,.leaflet-control-attribution a:focus{text-decoration:underline}.leaflet-attribution-flag{display:inline!important;vertical-align:baseline!important;width:1em;height:.6669em}.leaflet-left .leaflet-control-scale{margin-left:5px}.leaflet-bottom .leaflet-control-scale{margin-bottom:5px}.leaflet-control-scale-line{border:2px solid #777;border-top:none;line-height:1.1;padding:2px 5px 1px;white-space:nowrap;-moz-box-sizing:border-box;box-sizing:border-box;background:#fffc;text-shadow:1px 1px #fff}.leaflet-control-scale-line:not(:first-child){border-top:2px solid #777;border-bottom:none;margin-top:-2px}.leaflet-control-scale-line:not(:first-child):not(:last-child){border-bottom:2px solid #777}.leaflet-touch .leaflet-control-attribution,.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{box-shadow:none}.leaflet-touch .leaflet-control-layers,.leaflet-touch .leaflet-bar{border:2px solid rgba(0,0,0,.2);background-clip:padding-box}.leaflet-popup{position:absolute;text-align:center;margin-bottom:20px}.leaflet-popup-content-wrapper{padding:1px;text-align:left;border-radius:12px}.leaflet-popup-content{margin:13px 24px 13px 20px;line-height:1.3;font-size:13px;font-size:1.08333em;min-height:1px}.leaflet-popup-content p{margin:1.3em 0}.leaflet-popup-tip-container{width:40px;height:20px;position:absolute;left:50%;margin-top:-1px;margin-left:-20px;overflow:hidden;pointer-events:none}.leaflet-popup-tip{width:17px;height:17px;padding:1px;margin:-10px auto 0;pointer-events:auto;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg)}.leaflet-popup-content-wrapper,.leaflet-popup-tip{background:#fff;color:#333;box-shadow:0 3px 14px #0006}.leaflet-container a.leaflet-popup-close-button{position:absolute;top:0;right:0;border:none;text-align:center;width:24px;height:24px;font:16px/24px Tahoma,Verdana,sans-serif;color:#757575;text-decoration:none;background:transparent}.leaflet-container a.leaflet-popup-close-button:hover,.leaflet-container a.leaflet-popup-close-button:focus{color:#585858}.leaflet-popup-scrolled{overflow:auto}.leaflet-oldie .leaflet-popup-content-wrapper{-ms-zoom:1}.leaflet-oldie .leaflet-popup-tip{width:24px;margin:0 auto;-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";filter:progid:DXImageTransform.Microsoft.Matrix(M11=.70710678,M12=.70710678,M21=-.70710678,M22=.70710678)}.leaflet-oldie .leaflet-control-zoom,.leaflet-oldie .leaflet-control-layers,.leaflet-oldie .leaflet-popup-content-wrapper,.leaflet-oldie .leaflet-popup-tip{border:1px solid #999}.leaflet-div-icon{background:#fff;border:1px solid #666}.leaflet-tooltip{position:absolute;padding:6px;background-color:#fff;border:1px solid #fff;border-radius:3px;color:#222;white-space:nowrap;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;box-shadow:0 1px 3px #0006}.leaflet-tooltip.leaflet-interactive{cursor:pointer;pointer-events:auto}.leaflet-tooltip-top:before,.leaflet-tooltip-bottom:before,.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{position:absolute;pointer-events:none;border:6px solid transparent;background:transparent;content:""}.leaflet-tooltip-bottom{margin-top:6px}.leaflet-tooltip-top{margin-top:-6px}.leaflet-tooltip-bottom:before,.leaflet-tooltip-top:before{left:50%;margin-left:-6px}.leaflet-tooltip-top:before{bottom:0;margin-bottom:-12px;border-top-color:#fff}.leaflet-tooltip-bottom:before{top:0;margin-top:-12px;margin-left:-6px;border-bottom-color:#fff}.leaflet-tooltip-left{margin-left:-6px}.leaflet-tooltip-right{margin-left:6px}.leaflet-tooltip-left:before,.leaflet-tooltip-right:before{top:50%;margin-top:-6px}.leaflet-tooltip-left:before{right:0;margin-right:-12px;border-left-color:#fff}.leaflet-tooltip-right:before{left:0;margin-left:-12px;border-right-color:#fff}@media print{.leaflet-control{-webkit-print-color-adjust:exact;print-color-adjust:exact}} diff --git a/frontend/dist/assets/index-DUFVKRJi.js b/frontend/dist/assets/index-DUFVKRJi.js new file mode 100644 index 0000000000000000000000000000000000000000..871ddaccd2075eb6b063e2e852b433d5fc9fc17e --- /dev/null +++ b/frontend/dist/assets/index-DUFVKRJi.js @@ -0,0 +1,3 @@ +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=Object.create(null);u.open=`0`,u.close=`1`,u.ping=`2`,u.pong=`3`,u.message=`4`,u.upgrade=`5`,u.noop=`6`;var d=Object.create(null);Object.keys(u).forEach(e=>{d[u[e]]=e});var f={type:`error`,data:`parser error`},p=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,m=typeof ArrayBuffer==`function`,h=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,g=({type:e,data:t},n,r)=>p&&t instanceof Blob?n?r(t):_(t,r):m&&(t instanceof ArrayBuffer||h(t))?n?r(t):_(new Blob([t]),r):r(u[e]+(t||``)),_=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function v(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var y;function b(e,t){if(p&&e.data instanceof Blob)return e.data.arrayBuffer().then(v).then(t);if(m&&(e.data instanceof ArrayBuffer||h(e.data)))return t(v(e.data));g(e,!1,e=>{y||=new TextEncoder,t(y.encode(e))})}var x=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,S=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)S[x.charCodeAt(e)]=e;var C=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},w=typeof ArrayBuffer==`function`,T=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:ee(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:E(e.substring(1),t)}:d[n]?e.length>1?{type:d[n],data:e.substring(1)}:{type:d[n]}:f},E=(e,t)=>w?ee(C(e),t):{base64:!0,data:e},ee=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},te=``,ne=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{g(e,!1,e=>{r[a]=e,++i===n&&t(r.join(te))})})},re=(e,t)=>{let n=e.split(te),r=[];for(let e=0;e{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var D;function ae(e){return e.reduce((e,t)=>e+t.length,0)}function O(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i2**21-1){s.enqueue(f);break}i=a*2**32+t.getUint32(4),r=3}else{if(ae(n)e){s.enqueue(f);break}}}})}function A(e){if(e)return oe(e)}function oe(e){for(var t in A.prototype)e[t]=A.prototype[t];return e}A.prototype.on=A.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},A.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},A.prototype.off=A.prototype.removeListener=A.prototype.removeAllListeners=A.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;iPromise.resolve().then(e):(e,t)=>t(e,0),j=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),M=`arraybuffer`;function ce(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var le=j.setTimeout,ue=j.clearTimeout;function de(e,t){t.useNativeTimers?(e.setTimeoutFn=le.bind(j),e.clearTimeoutFn=ue.bind(j)):(e.setTimeoutFn=j.setTimeout.bind(j),e.clearTimeoutFn=j.clearTimeout.bind(j))}var fe=1.33;function pe(e){return typeof e==`string`?me(e):Math.ceil((e.byteLength||e.size)*fe)}function me(e){let t=0,n=0;for(let r=0,i=e.length;r=57344?n+=3:(r++,n+=4);return n}function he(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function ge(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function _e(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){re(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,ne(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=he()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},xe=!1;try{xe=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Se=xe;function Ce(){}var we=class extends be{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},Te=class e extends A{constructor(e,t,n){super(),this.createRequest=e,de(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=ce(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=Ce,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(Te.requestsCount=0,Te.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,Ee);else if(typeof addEventListener==`function`){let e=`onpagehide`in j?`pagehide`:`unload`;addEventListener(e,Ee,!1)}}function Ee(){for(let e in Te.requests)Te.requests.hasOwnProperty(e)&&Te.requests[e].abort()}var De=(function(){let e=ke({xdomain:!1});return e&&e.responseType!==null})(),Oe=class extends we{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=De&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Te(ke,this.uri(),e)}};function ke(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Se))return new XMLHttpRequest}catch{}if(!t)try{return new j[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var Ae=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,je=class extends ye{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Ae?{}:ce(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t{try{this.doWrite(n,e)}catch{}r&&se(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=he()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Me=j.WebSocket||j.MozWebSocket,Ne={websocket:class extends je{createSocket(e,t,n){return Ae?new Me(e,t,n):t?new Me(e,t):new Me(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends ye{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=k(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=ie();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t{r&&se(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Oe},Pe=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Fe=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function Ie(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=Pe.exec(e||``),a={},o=14;for(;o--;)a[Fe[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Le(a,a.path),a.queryKey=Re(a,a.query),a}function Le(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function Re(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var ze=typeof addEventListener==`function`&&typeof removeEventListener==`function`,Be=[];ze&&addEventListener(`offline`,()=>{Be.forEach(e=>e())},!1);var Ve=class e extends A{constructor(e,t){if(super(),this.binaryType=M,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=Ie(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=Ie(t.host).host);de(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=_e(this.opts.query)),ze&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},Be.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,se(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),ze&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=Be.indexOf(this._offlineEventListener);e!==-1&&Be.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};Ve.protocol=4;var He=class extends Ve{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;Ve.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;nNe[e]).filter(e=>!!e)),super(e,n)}};Ue.protocol;function We(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=Ie(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var Ge=typeof ArrayBuffer==`function`,Ke=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,qe=Object.prototype.toString,Je=typeof Blob==`function`||typeof Blob<`u`&&qe.call(Blob)===`[object BlobConstructor]`,Ye=typeof File==`function`||typeof File<`u`&&qe.call(File)===`[object FileConstructor]`;function Xe(e){return Ge&&(e instanceof ArrayBuffer||Ke(e))||Je&&e instanceof Blob||Ye&&e instanceof File}function Ze(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t=0&&e.numit,Encoder:()=>rt,PacketType:()=>P,isPacketValid:()=>dt,protocol:()=>5}),nt=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],P;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(P||={});var rt=class{constructor(e){this.replacer=e}encode(e){return(e.type===P.EVENT||e.type===P.ACK)&&Ze(e)?this.encodeAsBinary({type:e.type===P.EVENT?P.BINARY_EVENT:P.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===P.BINARY_EVENT||e.type===P.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Qe(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},it=class e extends A{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===P.BINARY_EVENT;n||t.type===P.BINARY_ACK?(t.type=n?P.EVENT:P.ACK,this.reconstructor=new at(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(Xe(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(P[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===P.BINARY_EVENT||r.type===P.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!st(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case P.CONNECT:return lt(t);case P.DISCONNECT:return t===void 0;case P.CONNECT_ERROR:return typeof t==`string`||lt(t);case P.EVENT:case P.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&nt.indexOf(t[0])===-1);case P.ACK:case P.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},at=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=et(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function ot(e){return typeof e==`string`}var st=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function ct(e){return e===void 0||st(e)}function lt(e){return Object.prototype.toString.call(e)===`[object Object]`}function ut(e,t){switch(e){case P.CONNECT:return t===void 0||lt(t);case P.DISCONNECT:return t===void 0;case P.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&nt.indexOf(t[0])===-1);case P.ACK:return Array.isArray(t);case P.CONNECT_ERROR:return typeof t==`string`||lt(t);default:return!1}}function dt(e){return ot(e.nsp)&&ct(e.id)&&ut(e.type,e.data)}function ft(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var pt=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),mt=class extends A{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[ft(e,`open`,this.onopen.bind(this)),ft(e,`packet`,this.onpacket.bind(this)),ft(e,`error`,this.onerror.bind(this)),ft(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(pt.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:P.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:P.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case P.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case P.EVENT:case P.BINARY_EVENT:this.onevent(e);break;case P.ACK:case P.BINARY_ACK:this.onack(e);break;case P.DISCONNECT:this.ondisconnect();break;case P.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:P.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:P.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n0&&e.jitter<=1?e.jitter:0,this.attempts=0}ht.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},ht.prototype.reset=function(){this.attempts=0},ht.prototype.setMin=function(e){this.ms=e},ht.prototype.setMax=function(e){this.max=e},ht.prototype.setJitter=function(e){this.jitter=e};var gt=class extends A{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,de(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new ht({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||N;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new Ue(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=ft(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=ft(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(ft(e,`ping`,this.onping.bind(this)),ft(e,`data`,this.ondata.bind(this)),ft(e,`error`,this.onerror.bind(this)),ft(e,`close`,this.onclose.bind(this)),ft(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){se(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new mt(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;ne()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},_t={};function vt(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=We(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=_t[i]&&a in _t[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new gt(r,t):(_t[i]||(_t[i]=new gt(r,t)),c=_t[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(vt,{Manager:gt,Socket:mt,io:vt,connect:vt});var yt=`/api/v1`;async function bt(e,t={}){let n=await fetch(e,{headers:{"Content-Type":`application/json`,...t.headers},...t});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`HTTP ${n.status}: ${e}`)}return n.status===204?null:n.json()}async function xt(e={}){let t=new URLSearchParams(e).toString();return bt(`${yt}/markets${t?`?`+t:``}`)}async function St(e){return bt(`${yt}/markets/${e}/signal`)}async function Ct(){return bt(`${yt}/positions`)}async function wt(e){return bt(`${yt}/positions`,{method:`POST`,body:JSON.stringify(e)})}async function Tt(e){return bt(`${yt}/positions/${e}`,{method:`DELETE`})}async function F(){return bt(`${yt}/watchlist`)}async function I(e){return bt(`${yt}/watchlist/${e}`,{method:`DELETE`})}async function Et(){return bt(`${yt}/alerts`)}function Dt(e){return e+.5|0}var Ot=(e,t,n)=>Math.max(Math.min(e,n),t);function kt(e){return Ot(Dt(e*2.55),0,255)}function R(e){return Ot(Dt(e*255),0,255)}function z(e){return Ot(Dt(e/2.55)/100,0,1)}function At(e){return Ot(Dt(e*100),0,100)}var jt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Mt=[...`0123456789ABCDEF`],Nt=e=>Mt[e&15],Pt=e=>Mt[(e&240)>>4]+Mt[e&15],Ft=e=>(e&240)>>4==(e&15),It=e=>Ft(e.r)&&Ft(e.g)&&Ft(e.b)&&Ft(e.a);function Lt(e){var t=e.length,n;return e[0]===`#`&&(t===4||t===5?n={r:255&jt[e[1]]*17,g:255&jt[e[2]]*17,b:255&jt[e[3]]*17,a:t===5?jt[e[4]]*17:255}:(t===7||t===9)&&(n={r:jt[e[1]]<<4|jt[e[2]],g:jt[e[3]]<<4|jt[e[4]],b:jt[e[5]]<<4|jt[e[6]],a:t===9?jt[e[7]]<<4|jt[e[8]]:255})),n}var Rt=(e,t)=>e<255?t(e):``;function zt(e){var t=It(e)?Nt:Pt;return e?`#`+t(e.r)+t(e.g)+t(e.b)+Rt(e.a,t):void 0}var Bt=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Vt(e,t,n){let r=t*Math.min(n,1-n),i=(t,i=(t+e/30)%12)=>n-r*Math.max(Math.min(i-3,9-i,1),-1);return[i(0),i(8),i(4)]}function Ht(e,t,n){let r=(r,i=(r+e/60)%6)=>n-n*t*Math.max(Math.min(i,4-i,1),0);return[r(5),r(3),r(1)]}function Ut(e,t,n){let r=Vt(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function Wt(e,t,n,r,i){return e===i?(t-n)/r+(t.5?l/(2-i-a):l/(i+a),s=Wt(t,n,r,l,i),s=s*60+.5),[s|0,c||0,o]}function Kt(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(R)}function qt(e,t,n){return Kt(Vt,e,t,n)}function Jt(e,t,n){return Kt(Ut,e,t,n)}function Yt(e,t,n){return Kt(Ht,e,t,n)}function Xt(e){return(e%360+360)%360}function B(e){let t=Bt.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?kt(+t[5]):R(+t[5]));let i=Xt(+t[2]),a=t[3]/100,o=t[4]/100;return r=t[1]===`hwb`?Jt(i,a,o):t[1]===`hsv`?Yt(i,a,o):qt(i,a,o),{r:r[0],g:r[1],b:r[2],a:n}}function Zt(e,t){var n=Gt(e);n[0]=Xt(n[0]+t),n=qt(n),e.r=n[0],e.g=n[1],e.b=n[2]}function V(e){if(!e)return;let t=Gt(e),n=t[0],r=At(t[1]),i=At(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${z(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var Qt={x:`dark`,Z:`light`,Y:`re`,X:`blu`,W:`gr`,V:`medium`,U:`slate`,A:`ee`,T:`ol`,S:`or`,B:`ra`,C:`lateg`,D:`ights`,R:`in`,Q:`turquois`,E:`hi`,P:`ro`,O:`al`,N:`le`,M:`de`,L:`yello`,F:`en`,K:`ch`,G:`arks`,H:`ea`,I:`ightg`,J:`wh`},$t={OiceXe:`f0f8ff`,antiquewEte:`faebd7`,aqua:`ffff`,aquamarRe:`7fffd4`,azuY:`f0ffff`,beige:`f5f5dc`,bisque:`ffe4c4`,black:`0`,blanKedOmond:`ffebcd`,Xe:`ff`,XeviTet:`8a2be2`,bPwn:`a52a2a`,burlywood:`deb887`,caMtXe:`5f9ea0`,KartYuse:`7fff00`,KocTate:`d2691e`,cSO:`ff7f50`,cSnflowerXe:`6495ed`,cSnsilk:`fff8dc`,crimson:`dc143c`,cyan:`ffff`,xXe:`8b`,xcyan:`8b8b`,xgTMnPd:`b8860b`,xWay:`a9a9a9`,xgYF:`6400`,xgYy:`a9a9a9`,xkhaki:`bdb76b`,xmagFta:`8b008b`,xTivegYF:`556b2f`,xSange:`ff8c00`,xScEd:`9932cc`,xYd:`8b0000`,xsOmon:`e9967a`,xsHgYF:`8fbc8f`,xUXe:`483d8b`,xUWay:`2f4f4f`,xUgYy:`2f4f4f`,xQe:`ced1`,xviTet:`9400d3`,dAppRk:`ff1493`,dApskyXe:`bfff`,dimWay:`696969`,dimgYy:`696969`,dodgerXe:`1e90ff`,fiYbrick:`b22222`,flSOwEte:`fffaf0`,foYstWAn:`228b22`,fuKsia:`ff00ff`,gaRsbSo:`dcdcdc`,ghostwEte:`f8f8ff`,gTd:`ffd700`,gTMnPd:`daa520`,Way:`808080`,gYF:`8000`,gYFLw:`adff2f`,gYy:`808080`,honeyMw:`f0fff0`,hotpRk:`ff69b4`,RdianYd:`cd5c5c`,Rdigo:`4b0082`,ivSy:`fffff0`,khaki:`f0e68c`,lavFMr:`e6e6fa`,lavFMrXsh:`fff0f5`,lawngYF:`7cfc00`,NmoncEffon:`fffacd`,ZXe:`add8e6`,ZcSO:`f08080`,Zcyan:`e0ffff`,ZgTMnPdLw:`fafad2`,ZWay:`d3d3d3`,ZgYF:`90ee90`,ZgYy:`d3d3d3`,ZpRk:`ffb6c1`,ZsOmon:`ffa07a`,ZsHgYF:`20b2aa`,ZskyXe:`87cefa`,ZUWay:`778899`,ZUgYy:`778899`,ZstAlXe:`b0c4de`,ZLw:`ffffe0`,lime:`ff00`,limegYF:`32cd32`,lRF:`faf0e6`,magFta:`ff00ff`,maPon:`800000`,VaquamarRe:`66cdaa`,VXe:`cd`,VScEd:`ba55d3`,VpurpN:`9370db`,VsHgYF:`3cb371`,VUXe:`7b68ee`,VsprRggYF:`fa9a`,VQe:`48d1cc`,VviTetYd:`c71585`,midnightXe:`191970`,mRtcYam:`f5fffa`,mistyPse:`ffe4e1`,moccasR:`ffe4b5`,navajowEte:`ffdead`,navy:`80`,Tdlace:`fdf5e6`,Tive:`808000`,TivedBb:`6b8e23`,Sange:`ffa500`,SangeYd:`ff4500`,ScEd:`da70d6`,pOegTMnPd:`eee8aa`,pOegYF:`98fb98`,pOeQe:`afeeee`,pOeviTetYd:`db7093`,papayawEp:`ffefd5`,pHKpuff:`ffdab9`,peru:`cd853f`,pRk:`ffc0cb`,plum:`dda0dd`,powMrXe:`b0e0e6`,purpN:`800080`,YbeccapurpN:`663399`,Yd:`ff0000`,Psybrown:`bc8f8f`,PyOXe:`4169e1`,saddNbPwn:`8b4513`,sOmon:`fa8072`,sandybPwn:`f4a460`,sHgYF:`2e8b57`,sHshell:`fff5ee`,siFna:`a0522d`,silver:`c0c0c0`,skyXe:`87ceeb`,UXe:`6a5acd`,UWay:`708090`,UgYy:`708090`,snow:`fffafa`,sprRggYF:`ff7f`,stAlXe:`4682b4`,tan:`d2b48c`,teO:`8080`,tEstN:`d8bfd8`,tomato:`ff6347`,Qe:`40e0d0`,viTet:`ee82ee`,JHt:`f5deb3`,wEte:`ffffff`,wEtesmoke:`f5f5f5`,Lw:`ffff00`,LwgYF:`9acd32`};function en(){let e={},t=Object.keys($t),n=Object.keys(Qt),r,i,a,o,s;for(r=0;r>16&255,a>>8&255,a&255]}return e}var tn;function nn(e){tn||(tn=en(),tn.transparent=[0,0,0,0]);let t=tn[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var rn=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function an(e){let t=rn.exec(e),n=255,r,i,a;if(t){if(t[7]!==r){let e=+t[7];n=t[8]?kt(e):Ot(e*255,0,255)}return r=+t[1],i=+t[3],a=+t[5],r=255&(t[2]?kt(r):Ot(r,0,255)),i=255&(t[4]?kt(i):Ot(i,0,255)),a=255&(t[6]?kt(a):Ot(a,0,255)),{r,g:i,b:a,a:n}}}function on(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${z(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var sn=e=>e<=.0031308?e*12.92:e**(1/2.4)*1.055-.055,cn=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;function ln(e,t,n){let r=cn(z(e.r)),i=cn(z(e.g)),a=cn(z(e.b));return{r:R(sn(r+n*(cn(z(t.r))-r))),g:R(sn(i+n*(cn(z(t.g))-i))),b:R(sn(a+n*(cn(z(t.b))-a))),a:e.a+n*(t.a-e.a)}}function un(e,t,n){if(e){let r=Gt(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=qt(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function dn(e,t){return e&&Object.assign(t||{},e)}function fn(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=R(e[3]))):(t=dn(e,{r:0,g:0,b:0,a:1}),t.a=R(t.a)),t}function pn(e){return e.charAt(0)===`r`?an(e):B(e)}var mn=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n===`object`?r=fn(t):n===`string`&&(r=Lt(t)||nn(t)||pn(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var e=dn(this._rgb);return e&&(e.a=z(e.a)),e}set rgb(e){this._rgb=fn(e)}rgbString(){return this._valid?on(this._rgb):void 0}hexString(){return this._valid?zt(this._rgb):void 0}hslString(){return this._valid?V(this._rgb):void 0}mix(e,t){if(e){let n=this.rgb,r=e.rgb,i,a=t===i?.5:t,o=2*a-1,s=n.a-r.a,c=((o*s===-1?o:(o+s)/(1+o*s))+1)/2;i=1-c,n.r=255&c*n.r+i*r.r+.5,n.g=255&c*n.g+i*r.g+.5,n.b=255&c*n.b+i*r.b+.5,n.a=a*n.a+(1-a)*r.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=ln(this._rgb,e._rgb,t)),this}clone(){return new e(this.rgb)}alpha(e){return this._rgb.a=R(e),this}clearer(e){let t=this._rgb;return t.a*=1-e,this}greyscale(){let e=this._rgb;return e.r=e.g=e.b=Dt(e.r*.3+e.g*.59+e.b*.11),this}opaquer(e){let t=this._rgb;return t.a*=1+e,this}negate(){let e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return un(this._rgb,2,e),this}darken(e){return un(this._rgb,2,-e),this}saturate(e){return un(this._rgb,1,e),this}desaturate(e){return un(this._rgb,1,-e),this}rotate(e){return Zt(this._rgb,e),this}};function H(){}var hn=(()=>{let e=0;return()=>e++})();function U(e){return e==null}function W(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)===`[object`&&t.slice(-6)===`Array]`}function G(e){return e!==null&&Object.prototype.toString.call(e)===`[object Object]`}function gn(e){return(typeof e==`number`||e instanceof Number)&&isFinite(+e)}function _n(e,t){return gn(e)?e:t}function K(e,t){return e===void 0?t:e}var vn=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100:+e/t,yn=(e,t)=>typeof e==`string`&&e.endsWith(`%`)?parseFloat(e)/100*t:+e;function q(e,t,n){if(e&&typeof e.call==`function`)return e.apply(n,t)}function J(e,t,n,r){let i,a,o;if(W(e))if(a=e.length,r)for(i=a-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;ie,x:e=>e.x,y:e=>e.y};function On(e){let t=e.split(`.`),n=[],r=``;for(let e of t)r+=e,r.endsWith(`\\`)?r=r.slice(0,-1)+`.`:(n.push(r),r=``);return n}function kn(e){let t=On(e);return e=>{for(let n of t){if(n===``)break;e&&=e[n]}return e}}function An(e,t){return(Dn[t]||(Dn[t]=kn(t)))(e)}function jn(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Mn=e=>e!==void 0,Nn=e=>typeof e==`function`,Pn=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function Fn(e){return e.type===`mouseup`||e.type===`click`||e.type===`contextmenu`}var Y=Math.PI,X=2*Y,In=X+Y,Ln=1/0,Rn=Y/180,zn=Y/2,Bn=Y/4,Vn=Y*2/3,Hn=Math.log10,Un=Math.sign;function Wn(e,t,n){return Math.abs(e-t)e-t).pop(),t}function qn(e){return typeof e==`symbol`||typeof e==`object`&&!!e&&!(Symbol.toPrimitive in e||`toString`in e||`valueOf`in e)}function Jn(e){return!qn(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Yn(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function Xn(e,t,n){let r,i,a;for(r=0,i=e.length;rc&&l=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function cr(e,t,n){n||=(n=>e[n]1;)a=i+r>>1,n(a)?i=a:r=a;return{lo:i,hi:r}}var lr=(e,t,n,r)=>cr(e,n,r?r=>{let i=e[r][t];return ie[r][t]cr(e,n,r=>e[r][t]>=n);function dr(e,t,n){let r=0,i=e.length;for(;rr&&e[i-1]>n;)i--;return r>0||i{let n=`_onData`+jn(t),r=e[t];Object.defineProperty(e,t,{configurable:!0,enumerable:!1,value(...t){let i=r.apply(this,t);return e._chartjs.listeners.forEach(e=>{typeof e[n]==`function`&&e[n](...t)}),i}})})}function mr(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(fr.forEach(t=>{delete e[t]}),delete e._chartjs)}function hr(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var gr=function(){return typeof window>`u`?function(e){return e()}:window.requestAnimationFrame}();function _r(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,gr.call(window,()=>{r=!1,e.apply(t,n)}))}}function vr(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var yr=e=>e===`start`?`left`:e===`end`?`right`:`center`,br=(e,t,n)=>e===`start`?t:e===`end`?n:(t+n)/2,xr=(e,t,n,r)=>e===(r?`left`:`right`)?n:e===`center`?(t+n)/2:t;function Sr(e,t,n){let r=t.length,i=0,a=r;if(e._sorted){let{iScale:o,vScale:s,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=o.axis,{min:d,max:f,minDefined:p,maxDefined:m}=o.getUserBounds();if(p){if(i=Math.min(lr(c,u,d).lo,n?r:lr(t,u,o.getPixelForValue(d)).lo),l){let e=c.slice(0,i+1).reverse().findIndex(e=>!U(e[s.axis]));i-=Math.max(0,e)}i=ar(i,0,r-1)}if(m){let e=Math.max(lr(c,o.axis,f,!0).hi+1,n?0:lr(t,u,o.getPixelForValue(f),!0).hi+1);if(l){let t=c.slice(e-1).findIndex(e=>!U(e[s.axis]));e+=Math.max(0,t)}a=ar(e,i,r)-i}else a=r-i}return{start:i,count:a}}function Cr(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let a=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),a}var wr=e=>e===0||e===1,Tr=(e,t,n)=>-(2**(10*--e)*Math.sin((e-t)*X/n)),Er=(e,t,n)=>2**(-10*e)*Math.sin((e-t)*X/n)+1,Dr={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>--e*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-(--e*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>--e*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*zn)+1,easeOutSine:e=>Math.sin(e*zn),easeInOutSine:e=>-.5*(Math.cos(Y*e)-1),easeInExpo:e=>e===0?0:2**(10*(e-1)),easeOutExpo:e=>e===1?1:-(2**(-10*e))+1,easeInOutExpo:e=>wr(e)?e:e<.5?.5*2**(10*(e*2-1)):.5*(-(2**(-10*(e*2-1)))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1- --e*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>wr(e)?e:Tr(e,.075,.3),easeOutElastic:e=>wr(e)?e:Er(e,.075,.3),easeInOutElastic(e){let t=.1125,n=.45;return wr(e)?e:e<.5?.5*Tr(e*2,t,n):.5+.5*Er(e*2-1,t,n)},easeInBack(e){let t=1.70158;return e*e*((t+1)*e-t)},easeOutBack(e){let t=1.70158;return--e*e*((t+1)*e+t)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-Dr.easeOutBounce(1-e),easeOutBounce(e){let t=7.5625,n=2.75;return e<1/n?t*e*e:e<2/n?t*(e-=1.5/n)*e+.75:e<2.5/n?t*(e-=2.25/n)*e+.9375:t*(e-=2.625/n)*e+.984375},easeInOutBounce:e=>e<.5?Dr.easeInBounce(e*2)*.5:Dr.easeOutBounce(e*2-1)*.5+.5};function Or(e){if(e&&typeof e==`object`){let t=e.toString();return t===`[object CanvasPattern]`||t===`[object CanvasGradient]`}return!1}function kr(e){return Or(e)?e:new mn(e)}function Ar(e){return Or(e)?e:new mn(e).saturate(.5).darken(.1).hexString()}var jr=[`x`,`y`,`borderWidth`,`radius`,`tension`],Mr=[`color`,`borderColor`,`backgroundColor`];function Nr(e){e.set(`animation`,{delay:void 0,duration:1e3,easing:`easeOutQuart`,fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe(`animation`,{_fallback:!1,_indexable:!1,_scriptable:e=>e!==`onProgress`&&e!==`onComplete`&&e!==`fn`}),e.set(`animations`,{colors:{type:`color`,properties:Mr},numbers:{type:`number`,properties:jr}}),e.describe(`animations`,{_fallback:`animation`}),e.set(`transitions`,{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:`transparent`},visible:{type:`boolean`,duration:0}}},hide:{animations:{colors:{to:`transparent`},visible:{type:`boolean`,easing:`linear`,fn:e=>e|0}}}})}function Pr(e){e.set(`layout`,{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var Fr=new Map;function Ir(e,t){t||={};let n=e+JSON.stringify(t),r=Fr.get(n);return r||(r=new Intl.NumberFormat(e,t),Fr.set(n,r)),r}function Lr(e,t,n){return Ir(t,n).format(e)}var Rr={values(e){return W(e)?e:``+e},numeric(e,t,n){if(e===0)return`0`;let r=this.chart.options.locale,i,a=e;if(n.length>1){let t=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(t<1e-4||t>0x38d7ea4c68000)&&(i=`scientific`),a=zr(e,n)}let o=Hn(Math.abs(a)),s=isNaN(o)?1:Math.max(Math.min(-1*Math.floor(o),20),0),c={notation:i,minimumFractionDigits:s,maximumFractionDigits:s};return Object.assign(c,this.options.ticks.format),Lr(e,r,c)},logarithmic(e,t,n){if(e===0)return`0`;let r=n[t].significand||e/10**Math.floor(Hn(e));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?Rr.numeric.call(this,e,t,n):``}};function zr(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Br={formatters:Rr};function Vr(e){e.set(`scale`,{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:`ticks`,clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:``,padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:``,padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Br.formatters.values,minor:{},major:{},align:`center`,crossAlign:`near`,showLabelBackdrop:!1,backdropColor:`rgba(255, 255, 255, 0.75)`,backdropPadding:2}}),e.route(`scale.ticks`,`color`,``,`color`),e.route(`scale.grid`,`color`,``,`borderColor`),e.route(`scale.border`,`color`,``,`borderColor`),e.route(`scale.title`,`color`,``,`color`),e.describe(`scale`,{_fallback:!1,_scriptable:e=>!e.startsWith(`before`)&&!e.startsWith(`after`)&&e!==`callback`&&e!==`parser`,_indexable:e=>e!==`borderDash`&&e!==`tickBorderDash`&&e!==`dash`}),e.describe(`scales`,{_fallback:`scale`}),e.describe(`scale.ticks`,{_scriptable:e=>e!==`backdropPadding`&&e!==`callback`,_indexable:e=>e!==`backdropPadding`})}var Hr=Object.create(null),Ur=Object.create(null);function Wr(e,t){if(!t)return e;let n=t.split(`.`);for(let t=0,r=n.length;te.chart.platform.getDevicePixelRatio(),this.elements={},this.events=[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`],this.font={family:`'Helvetica Neue', 'Helvetica', 'Arial', sans-serif`,size:12,style:`normal`,lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(e,t)=>Ar(t.backgroundColor),this.hoverBorderColor=(e,t)=>Ar(t.borderColor),this.hoverColor=(e,t)=>Ar(t.color),this.indexAxis=`x`,this.interaction={mode:`nearest`,intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return Gr(this,e,t)}get(e){return Wr(this,e)}describe(e,t){return Gr(Ur,e,t)}override(e,t){return Gr(Hr,e,t)}route(e,t,n,r){let i=Wr(this,e),a=Wr(this,n),o=`_`+t;Object.defineProperties(i,{[o]:{value:i[t],writable:!0},[t]:{enumerable:!0,get(){let e=this[o],t=a[r];return G(e)?Object.assign({},t,e):K(e,t)},set(e){this[o]=e}}})}apply(e){e.forEach(e=>e(this))}}({_scriptable:e=>!e.startsWith(`on`),_indexable:e=>e!==`events`,hover:{_fallback:`interaction`},interaction:{_scriptable:!1,_indexable:!1}},[Nr,Pr,Vr]);function Kr(e){return!e||U(e.size)||U(e.family)?null:(e.style?e.style+` `:``)+(e.weight?e.weight+` `:``)+e.size+`px `+e.family}function qr(e,t,n,r,i){let a=t[i];return a||(a=t[i]=e.measureText(i).width,n.push(i)),a>r&&(r=a),r}function Jr(e,t,n,r){r||={};let i=r.data=r.data||{},a=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},a=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let o=0,s=n.length,c,l,u,d,f;for(c=0;cn.length){for(c=0;c0&&e.stroke()}}function $r(e,t,n){return n||=.5,!t||e&&e.x>t.left-n&&e.xt.top-n&&e.y0&&a.strokeColor!==``,c,l;for(e.save(),e.font=i.string,ii(e,a),c=0;c+e||0;function pi(e,t){let n={},r=G(t),i=r?Object.keys(t):t,a=G(e)?r?n=>K(e[n],e[t[n]]):t=>e[t]:()=>e;for(let e of i)n[e]=fi(a(e));return n}function mi(e){return pi(e,{top:`y`,right:`x`,bottom:`y`,left:`x`})}function hi(e){return pi(e,[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`])}function gi(e){let t=mi(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function _i(e,t){e||={},t||=Z.font;let n=K(e.size,t.size);typeof n==`string`&&(n=parseInt(n,10));let r=K(e.style,t.style);r&&!(``+r).match(ui)&&(console.warn(`Invalid font style specified: "`+r+`"`),r=void 0);let i={family:K(e.family,t.family),lineHeight:di(K(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:K(e.weight,t.weight),string:``};return i.string=Kr(i),i}function vi(e,t,n,r){let i=!0,a,o,s;for(a=0,o=e.length;an&&e===0?0:e+t;return{min:o(r,-Math.abs(a)),max:o(i,a)}}function bi(e,t){return Object.assign(Object.create(e),t)}function xi(e,t=[``],n,r,i=()=>e[0]){let a=n||e;return r===void 0&&(r=Li(`_fallback`,e)),new Proxy({[Symbol.toStringTag]:`Object`,_cacheable:!0,_scopes:e,_rootScopes:a,_fallback:r,_getTarget:i,override:n=>xi([n,...e],t,a,r)},{deleteProperty(t,n){return delete t[n],delete t._keys,delete e[0][n],!0},get(n,r){return Ei(n,r,()=>Ii(r,t,e,n))},getOwnPropertyDescriptor(e,t){return Reflect.getOwnPropertyDescriptor(e._scopes[0],t)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(e,t){return Ri(e).includes(t)},ownKeys(e){return Ri(e)},set(e,t,n){let r=e._storage||=i();return e[t]=r[t]=n,delete e._keys,!0}})}function Si(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:Ci(e,r),setContext:t=>Si(e,t,n,r),override:i=>Si(e.override(i),t,n,r)};return new Proxy(i,{deleteProperty(t,n){return delete t[n],delete e[n],!0},get(e,t,n){return Ei(e,t,()=>Di(e,t,n))},getOwnPropertyDescriptor(t,n){return t._descriptors.allKeys?Reflect.has(e,n)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,n)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(t,n){return Reflect.has(e,n)},ownKeys(){return Reflect.ownKeys(e)},set(t,n,r){return e[n]=r,delete t[n],!0}})}function Ci(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:Nn(n)?n:()=>n,isIndexable:Nn(r)?r:()=>r}}var wi=(e,t)=>e?e+jn(t):t,Ti=(e,t)=>G(t)&&e!==`adapters`&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function Ei(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t===`constructor`)return e[t];let r=n();return e[t]=r,r}function Di(e,t,n){let{_proxy:r,_context:i,_subProxy:a,_descriptors:o}=e,s=r[t];return Nn(s)&&o.isScriptable(t)&&(s=Oi(t,s,e,n)),W(s)&&s.length&&(s=ki(t,s,e,o.isIndexable)),Ti(t,s)&&(s=Si(s,i,a&&a[t],o)),s}function Oi(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_stack:s}=n;if(s.has(e))throw Error(`Recursion detected: `+Array.from(s).join(`->`)+`->`+e);s.add(e);let c=t(a,o||r);return s.delete(e),Ti(e,c)&&(c=Ni(i._scopes,i,e,c)),c}function ki(e,t,n,r){let{_proxy:i,_context:a,_subProxy:o,_descriptors:s}=n;if(a.index!==void 0&&r(e))return t[a.index%t.length];if(G(t[0])){let n=t,r=i._scopes.filter(e=>e!==n);t=[];for(let c of n){let n=Ni(r,i,e,c);t.push(Si(n,a,o&&o[e],s))}}return t}function Ai(e,t,n){return Nn(e)?e(t,n):e}var ji=(e,t)=>e===!0?t:typeof e==`string`?An(t,e):void 0;function Mi(e,t,n,r,i){for(let a of t){let t=ji(n,a);if(t){e.add(t);let a=Ai(t._fallback,n,i);if(a!==void 0&&a!==n&&a!==r)return a}else if(t===!1&&r!==void 0&&n!==r)return null}return!1}function Ni(e,t,n,r){let i=t._rootScopes,a=Ai(t._fallback,n,r),o=[...e,...i],s=new Set;s.add(r);let c=Pi(s,o,n,a||n,r);return c===null||a!==void 0&&a!==n&&(c=Pi(s,o,a,c,r),c===null)?!1:xi(Array.from(s),[``],i,a,()=>Fi(t,n,r))}function Pi(e,t,n,r,i){for(;n;)n=Mi(e,t,n,r,i);return n}function Fi(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return W(i)&&G(n)?n:i||{}}function Ii(e,t,n,r){let i;for(let a of t)if(i=Li(wi(a,e),n),i!==void 0)return Ti(e,i)?Ni(n,r,e,i):i}function Li(e,t){for(let n of t){if(!n)continue;let t=n[e];if(t!==void 0)return t}}function Ri(e){let t=e._keys;return t||=e._keys=zi(e._scopes),t}function zi(e){let t=new Set;for(let n of e)for(let e of Object.keys(n).filter(e=>!e.startsWith(`_`)))t.add(e);return Array.from(t)}function Bi(e,t,n,r){let{iScale:i}=e,{key:a=`r`}=this._parsing,o=Array(r),s,c,l,u;for(s=0,c=r;ste===`x`?`y`:`x`;function Wi(e,t,n,r){let i=e.skip?t:e,a=t,o=n.skip?t:n,s=tr(a,i),c=tr(o,a),l=s/(s+c),u=c/(s+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;let d=r*l,f=r*u;return{previous:{x:a.x-d*(o.x-i.x),y:a.y-d*(o.y-i.y)},next:{x:a.x+f*(o.x-i.x),y:a.y+f*(o.y-i.y)}}}function Gi(e,t,n){let r=e.length,i,a,o,s,c,l=Hi(e,0);for(let u=0;u!e.skip)),t.cubicInterpolationMode===`monotone`)qi(e,i);else{let n=r?e[e.length-1]:e[0];for(a=0,o=e.length;ae.ownerDocument.defaultView.getComputedStyle(e,null);function ta(e,t){return ea(e).getPropertyValue(t)}var na=[`top`,`right`,`bottom`,`left`];function ra(e,t,n){let r={};n=n?`-`+n:``;for(let i=0;i<4;i++){let a=na[i];r[a]=parseFloat(e[t+`-`+a+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var ia=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function aa(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:a}=r,o=!1,s,c;if(ia(i,a,e.target))s=i,c=a;else{let e=t.getBoundingClientRect();s=r.clientX-e.left,c=r.clientY-e.top,o=!0}return{x:s,y:c,box:o}}function oa(e,t){if(`native`in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=ea(n),a=i.boxSizing===`border-box`,o=ra(i,`padding`),s=ra(i,`border`,`width`),{x:c,y:l,box:u}=aa(e,n),d=o.left+(u&&s.left),f=o.top+(u&&s.top),{width:p,height:m}=t;return a&&(p-=o.width+s.width,m-=o.height+s.height),{x:Math.round((c-d)/p*n.width/r),y:Math.round((l-f)/m*n.height/r)}}function sa(e,t,n){let r,i;if(t===void 0||n===void 0){let a=e&&Qi(e);if(!a)t=e.clientWidth,n=e.clientHeight;else{let e=a.getBoundingClientRect(),o=ea(a),s=ra(o,`border`,`width`),c=ra(o,`padding`);t=e.width-c.width-s.width,n=e.height-c.height-s.height,r=$i(o.maxWidth,a,`clientWidth`),i=$i(o.maxHeight,a,`clientHeight`)}}return{width:t,height:n,maxWidth:r||Ln,maxHeight:i||Ln}}var ca=e=>Math.round(e*10)/10;function la(e,t,n,r){let i=ea(e),a=ra(i,`margin`),o=$i(i.maxWidth,e,`clientWidth`)||Ln,s=$i(i.maxHeight,e,`clientHeight`)||Ln,c=sa(e,t,n),{width:l,height:u}=c;if(i.boxSizing===`content-box`){let e=ra(i,`border`,`width`),t=ra(i,`padding`);l-=t.width+e.width,u-=t.height+e.height}return l=Math.max(0,l-a.width),u=Math.max(0,r?l/r:u-a.height),l=ca(Math.min(l,o,c.maxWidth)),u=ca(Math.min(u,s,c.maxHeight)),l&&!u&&(u=ca(l/2)),(t!==void 0||n!==void 0)&&r&&c.height&&u>c.height&&(u=c.height,l=ca(Math.floor(u*r))),{width:l,height:u}}function ua(e,t,n){let r=t||1,i=ca(e.height*r),a=ca(e.width*r);e.height=ca(e.height),e.width=ca(e.width);let o=e.canvas;return o.style&&(n||!o.style.height&&!o.style.width)&&(o.style.height=`${e.height}px`,o.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||o.height!==i||o.width!==a?(e.currentDevicePixelRatio=r,o.height=i,o.width=a,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var da=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Zi()&&(window.addEventListener(`test`,null,t),window.removeEventListener(`test`,null,t))}catch{}return e}();function fa(e,t){let n=ta(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function pa(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function ma(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r===`middle`?n<.5?e.y:t.y:r===`after`?n<1?e.y:t.y:n>0?t.y:e.y}}function ha(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},a={x:t.cp1x,y:t.cp1y},o=pa(e,i,n),s=pa(i,a,n),c=pa(a,t,n);return pa(pa(o,s,n),pa(s,c,n),n)}var ga=function(e,t){return{x(n){return e+e+t-n},setWidth(e){t=e},textAlign(e){return e===`center`?e:e===`right`?`left`:`right`},xPlus(e,t){return e-t},leftForLtr(e,t){return e-t}}},_a=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function va(e,t,n){return e?ga(t,n):_a()}function ya(e,t){let n,r;(t===`ltr`||t===`rtl`)&&(n=e.canvas.style,r=[n.getPropertyValue(`direction`),n.getPropertyPriority(`direction`)],n.setProperty(`direction`,t,`important`),e.prevTextDirection=r)}function ba(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty(`direction`,t[0],t[1]))}function xa(e){return e===`angle`?{between:ir,compare:nr,normalize:rr}:{between:sr,compare:(e,t)=>e-t,normalize:e=>e}}function Sa({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function Ca(e,t,n){let{property:r,start:i,end:a}=n,{between:o,normalize:s}=xa(r),c=t.length,{start:l,end:u,loop:d}=e,f,p;if(d){for(l+=c,u+=c,f=0,p=c;fc(i,y,_)&&s(i,y)!==0,x=()=>s(a,_)===0||c(a,y,_),S=()=>h||b(),C=()=>!h||x();for(let e=u,n=u;e<=d;++e)v=t[e%o],!v.skip&&(_=l(v[r]),_!==y&&(h=c(_,i,a),g===null&&S()&&(g=s(_,i)===0?e:n),g!==null&&C()&&(m.push(Sa({start:g,end:e,loop:f,count:o,style:p})),g=null),n=e,y=_));return g!==null&&m.push(Sa({start:g,end:d,loop:f,count:o,style:p})),m}function Ta(e,t){let n=[],r=e.segments;for(let i=0;ii&&e[a%t].skip;)a--;return a%=t,{start:i,end:a}}function Da(e,t,n,r){let i=e.length,a=[],o=t,s=e[t],c;for(c=t+1;c<=n;++c){let n=e[c%i];n.skip||n.stop?s.skip||(r=!1,a.push({start:t%i,end:(c-1)%i,loop:r}),t=o=n.stop?c:null):(o=c,s.skip&&(t=c)),s=n}return o!==null&&a.push({start:t%i,end:o%i,loop:r}),a}function Oa(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let a=!!e._loop,{start:o,end:s}=Ea(n,i,a,r);return r===!0?ka(e,[{start:o,end:s,loop:a}],n,t):ka(e,Da(n,o,sr({chart:e,initial:t.initial,numSteps:a,currentStep:Math.min(n-t.start,a)}))}_refresh(){this._request||=(this._running=!0,gr.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;let i=n.items,a=i.length-1,o=!1,s;for(;a>=0;--a)s=i[a],s._active?(s._total>n.duration&&(n.duration=s._total),s.tick(e),o=!0):(i[a]=i[i.length-1],i.pop());o&&(r.draw(),this._notify(r,n,e,`progress`)),i.length||(n.running=!1,this._notify(r,n,e,`complete`),n.initial=!1),t+=i.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){let t=this._charts,n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){let t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((e,t)=>Math.max(e,t._duration),0),this._refresh())}running(e){if(!this._running)return!1;let t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){let t=this._charts.get(e);if(!t||!t.items.length)return;let n=t.items,r=n.length-1;for(;r>=0;--r)n[r].cancel();t.items=[],this._notify(e,t,Date.now(),`complete`)}remove(e){return this._charts.delete(e)}},La=`transparent`,Ra={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=kr(e||La),i=r.valid&&kr(t||La);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},za=class{constructor(e,t,n,r){let i=t[n];r=vi([e.to,r,i,e.from]);let a=vi([e.from,i,r]);this._active=!0,this._fn=e.fn||Ra[e.type||typeof a],this._easing=Dr[e.easing]||Dr.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=a,this._to=r,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);let r=this._target[this._prop],i=n-this._start,a=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(a,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=vi([e.to,t,r,e.from]),this._from=vi([e.from,r,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){let t=e-this._start,n=this._duration,r=this._prop,i=this._from,a=this._loop,o=this._to,s;if(this._active=i!==o&&(a||t1?2-s:s,s=this._easing(Math.min(1,Math.max(0,s))),this._target[r]=this._fn(i,o,s)}wait(){let e=this._promises||=[];return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){let t=e?`res`:`rej`,n=this._promises||[];for(let e=0;e{let i=e[r];if(!G(i))return;let a={};for(let e of t)a[e]=i[e];(W(i.properties)&&i.properties||[r]).forEach(e=>{(e===r||!n.has(e))&&n.set(e,a)})})}_animateOptions(e,t){let n=t.options,r=Ha(e,n);if(!r)return[];let i=this._createAnimations(r,n);return n.$shared&&Va(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,t){let n=this._properties,r=[],i=e.$animations||={},a=Object.keys(t),o=Date.now(),s;for(s=a.length-1;s>=0;--s){let c=a[s];if(c.charAt(0)===`$`)continue;if(c===`options`){r.push(...this._animateOptions(e,t));continue}let l=t[c],u=i[c],d=n.get(c);if(u)if(d&&u.active()){u.update(d,l,o);continue}else u.cancel();if(!d||!d.duration){e[c]=l;continue}i[c]=u=new za(d,e,c,l),r.push(u)}return r}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}let n=this._createAnimations(e,t);if(n.length)return Ia.add(this._chart,n),!0}};function Va(e,t){let n=[],r=Object.keys(t);for(let t=0;t0||!n&&t<0)return i.index}return null}function eo(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||={},{iScale:a,vScale:o,index:s}=r,c=a.axis,l=o.axis,u=Xa(a,o,r),d=t.length,f;for(let e=0;en[e].axis===t).shift()}function no(e,t){return bi(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:`default`,type:`dataset`})}function ro(e,t,n){return bi(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:`default`,type:`data`})}function io(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t||=e._parsed;for(let e of t){let t=e._stacks;if(!t||t[r]===void 0||t[r][n]===void 0)return;delete t[r][n],t[r]._visualValues!==void 0&&t[r]._visualValues[n]!==void 0&&delete t[r]._visualValues[n]}}}var ao=e=>e===`reset`||e===`none`,oo=(e,t)=>t?e:Object.assign({},e),so=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Ka(n,!0),values:null},co=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=Ya(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled(`filler`)&&console.warn(`Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options`)}updateIndex(e){this.index!==e&&io(this._cachedMeta),this.index=e}linkScales(){let e=this.chart,t=this._cachedMeta,n=this.getDataset(),r=(e,t,n,r)=>e===`x`?t:e===`r`?r:n,i=t.xAxisID=K(n.xAxisID,to(e,`x`)),a=t.yAxisID=K(n.yAxisID,to(e,`y`)),o=t.rAxisID=K(n.rAxisID,to(e,`r`)),s=t.indexAxis,c=t.iAxisID=r(s,i,a,o),l=t.vAxisID=r(s,a,i,o);t.xScale=this.getScaleForId(i),t.yScale=this.getScaleForId(a),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(c),t.vScale=this.getScaleForId(l)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){let t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update(`reset`)}_destroy(){let e=this._cachedMeta;this._data&&mr(this._data,this),e._stacked&&io(e)}_dataCheck(){let e=this.getDataset(),t=e.data||=[],n=this._data;if(G(t)){let e=this._cachedMeta;this._data=Ja(t,e)}else if(n!==t){if(n){mr(n,this);let e=this._cachedMeta;io(e),e._parsed=[]}t&&Object.isExtensible(t)&&pr(t,this),this._syncList=[],this._data=t}}addElements(){let e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){let t=this._cachedMeta,n=this.getDataset(),r=!1;this._dataCheck();let i=t._stacked;t._stacked=Ya(t.vScale,t),t.stack!==n.stack&&(r=!0,io(t),t.stack=n.stack),this._resyncElements(e),(r||i!==t._stacked)&&(eo(this,t._parsed),t._stacked=Ya(t.vScale,t))}configure(){let e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){let{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:a}=n,o=i.axis,s=e===0&&t===r.length?!0:n._sorted,c=e>0&&n._parsed[e-1],l,u,d;if(this._parsing===!1)n._parsed=r,n._sorted=!0,d=r;else{d=W(r[e])?this.parseArrayData(n,r,e,t):G(r[e])?this.parseObjectData(n,r,e,t):this.parsePrimitiveData(n,r,e,t);let i=()=>u[o]===null||c&&u[o]t||u=0;--d)if(!p()){this.updateRangeFromParsed(c,e,f,s);break}}return c}getAllParsedValues(e){let t=this._cachedMeta._parsed,n=[],r,i,a;for(r=0,i=t.length;r=0&&ethis.getContext(n,r,t),u);return p.$shared&&(p.$shared=s,i[a]=Object.freeze(oo(p,s))),p}_resolveAnimations(e,t,n){let r=this.chart,i=this._cachedDataOpts,a=`animation-${t}`,o=i[a];if(o)return o;let s;if(r.options.animation!==!1){let r=this.chart.config,i=r.datasetAnimationScopeKeys(this._type,t),a=r.getOptionScopes(this.getDataset(),i);s=r.createResolver(a,this.getContext(e,n,t))}let c=new Ba(r,s&&s.animations);return s&&s._cacheable&&(i[a]=Object.freeze(c)),c}getSharedOptions(e){if(e.$shared)return this._sharedOptions||=Object.assign({},e)}includeOptions(e,t){return!t||ao(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){let n=this.resolveDataElementOptions(e,t),r=this._sharedOptions,i=this.getSharedOptions(n),a=this.includeOptions(t,i)||i!==r;return this.updateSharedOptions(i,t,n),{sharedOptions:i,includeOptions:a}}updateElement(e,t,n,r){ao(r)?Object.assign(e,n):this._resolveAnimations(t,r).update(e,n)}updateSharedOptions(e,t,n){e&&!ao(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,r){e.active=r;let i=this.getStyle(t,r);this._resolveAnimations(t,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,t,n){this._setStyle(e,n,`active`,!1)}setHoverStyle(e,t,n){this._setStyle(e,n,`active`,!0)}_removeDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!1)}_setDatasetHoverStyle(){let e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,`active`,!0)}_resyncElements(e){let t=this._data,n=this._cachedMeta.data;for(let[e,t,n]of this._syncList)this[e](t,n);this._syncList=[];let r=n.length,i=t.length,a=Math.min(i,r);a&&this.parse(0,a),i>r?this._insertElements(r,i-r,e):i{for(e.length+=t,o=e.length-1;o>=a;o--)e[o]=e[o-t]};for(s(i),o=e;oe-t))}return e._cache.$bar}function uo(e){let t=e.iScale,n=lo(t,e.type),r=t._length,i,a,o,s,c=()=>{o===32767||o===-32768||(Mn(s)&&(r=Math.min(r,Math.abs(o-s)||r)),s=o)};for(i=0,a=n.length;i0?i[e-1]:null,s=eMath.abs(s)&&(c=s,l=o),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:i,end:a,min:o,max:s}}function ho(e,t,n,r){return W(e)?mo(e,t,n,r):t[n.axis]=n.parse(e,r),t}function go(e,t,n,r){let i=e.iScale,a=e.vScale,o=i.getLabels(),s=i===a,c=[],l,u,d,f;for(l=n,u=n+r;l=n?1:-1):Un(e)}function yo(e){let t,n,r,i,a;return e.horizontal?(t=e.base>e.x,n=`left`,r=`right`):(t=e.basee.controller.options.grouped),i=n.options.stacked,a=[],o=this._cachedMeta.controller.getParsed(t),s=o&&o[n.axis],c=e=>{let t=e._parsed.find(e=>e[n.axis]===s),r=t&&t[e.vScale.axis];if(U(r)||isNaN(r))return!0};for(let n of r)if(!(t!==void 0&&c(n))&&((i===!1||a.indexOf(n.stack)===-1||i===void 0&&n.stack===void 0)&&a.push(n.stack),n.index===e))break;return a.length||a.push(void 0),a}_getStackCount(e){return this._getStacks(void 0,e).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let e=this.chart.scales,t=this.chart.options.indexAxis;return Object.keys(e).filter(n=>e[n].axis===t).shift()}_getAxis(){let e={},t=this.getFirstScaleIdForIndexAxis();for(let n of this.chart.data.datasets)e[K(this.chart.options.indexAxis===`x`?n.xAxisID:n.yAxisID,t)]=!0;return Object.keys(e)}_getStackIndex(e,t,n){let r=this._getStacks(e,n),i=t===void 0?-1:r.indexOf(t);return i===-1?r.length-1:i}_getRuler(){let e=this.options,t=this._cachedMeta,n=t.iScale,r=[],i,a;for(i=0,a=t.data.length;i=0;--n)t=Math.max(t,e[n].size(this.resolveDataElementOptions(n))/2);return t>0&&t}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart.data.labels||[],{xScale:r,yScale:i}=t,a=this.getParsed(e),o=r.getLabelForValue(a.x),s=i.getLabelForValue(a.y),c=a._custom;return{label:n[e]||``,value:`(`+o+`, `+s+(c?`, `+c:``)+`)`}}update(e){let t=this._cachedMeta.data;this.updateElements(t,0,t.length,e)}updateElements(e,t,n,r){let i=r===`reset`,{iScale:a,vScale:o}=this._cachedMeta,{sharedOptions:s,includeOptions:c}=this._getSharedOptions(t,r),l=a.axis,u=o.axis;for(let d=t;dir(e,s,c,!0)?1:Math.max(t,t*n,r,r*n),m=(e,t,r)=>ir(e,s,c,!0)?-1:Math.min(t,t*n,r,r*n),h=p(0,l,d),g=p(zn,u,f),_=m(Y,l,d),v=m(Y+zn,u,f);r=(h-_)/2,i=(g-v)/2,a=-(h+_)/2,o=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:a,offsetY:o}}var Oo=class extends co{static id=`doughnut`;static defaults={datasetElementType:!1,dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:`number`,properties:[`circumference`,`endAngle`,`innerRadius`,`outerRadius`,`startAngle`,`x`,`y`,`offset`,`borderWidth`,`spacing`]}},cutout:`50%`,rotation:0,circumference:360,radius:`100%`,spacing:0,indexAxis:`r`};static descriptors={_scriptable:e=>e!==`spacing`,_indexable:e=>e!==`spacing`&&!e.startsWith(`borderDash`)&&!e.startsWith(`hoverBorderDash`)};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data,{labels:{pointStyle:n,textAlign:r,color:i,useBorderRadius:a,borderRadius:o}}=e.legend.options;return t.labels.length&&t.datasets.length?t.labels.map((t,s)=>{let c=e.getDatasetMeta(0).controller.getStyle(s);return{text:t,fillStyle:c.backgroundColor,fontColor:i,hidden:!e.getDataVisibility(s),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:r,pointStyle:n,borderRadius:a&&(o||c.borderRadius),index:s}}):[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}}};constructor(e,t){super(e,t),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,t){let n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=e=>+n[e];if(G(n[e])){let{key:e=`value`}=this._parsing;i=t=>+An(n[t],e)}let a,o;for(a=e,o=e+t;a0&&!isNaN(e)?Math.abs(e)/t*X:0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Lr(t._parsed[e],n.options.locale);return{label:r[e]||``,value:i}}getMaxBorderWidth(e){let t=0,n=this.chart,r,i,a,o,s;if(!e){for(r=0,i=n.data.datasets.length;r0&&this.getParsed(t-1);for(let n=0;n=_){v.skip=!0;continue}let b=this.getParsed(n),x=U(b[f]),S=v[d]=a.getPixelForValue(b[d],n),C=v[f]=i||x?o.getBasePixel():o.getPixelForValue(s?this.applyStack(o,b,s):b[f],n);v.skip=isNaN(S)||isNaN(C)||x,v.stop=n>0&&Math.abs(b[d]-y[d])>h,m&&(v.parsed=b,v.raw=c.data[n]),u&&(v.options=l||this.resolveDataElementOptions(n,p.active?`active`:r)),g||this.updateElement(p,n,v,r),y=b}}getMaxOverflow(){let e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,r=e.data||[];if(!r.length)return n;let i=r[0].size(this.resolveDataElementOptions(0)),a=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,a)/2}draw(){let e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}},Ao=class extends co{static id=`polarArea`;static defaults={dataElementType:`arc`,animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:`number`,properties:[`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`]}},indexAxis:`r`,startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){let t=e.data;if(t.labels.length&&t.datasets.length){let{labels:{pointStyle:n,color:r}}=e.legend.options;return t.labels.map((t,i)=>{let a=e.getDatasetMeta(0).controller.getStyle(i);return{text:t,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:r,lineWidth:a.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(i),index:i}})}return[]}},onClick(e,t,n){n.chart.toggleDataVisibility(t.index),n.chart.update()}}},scales:{r:{type:`radialLinear`,angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(e,t){super(e,t),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){let t=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=Lr(t._parsed[e].r,n.options.locale);return{label:r[e]||``,value:i}}parseObjectData(e,t,n,r){return Bi.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta.data;this._updateRadius(),this.updateElements(t,0,t.length,e)}getMinMax(){let e=this._cachedMeta,t={min:1/0,max:-1/0};return e.data.forEach((e,n)=>{let r=this.getParsed(n).r;!isNaN(r)&&this.chart.getDataVisibility(n)&&(rt.max&&(t.max=r))}),t}_updateRadius(){let e=this.chart,t=e.chartArea,n=e.options,r=Math.min(t.right-t.left,t.bottom-t.top),i=Math.max(r/2,0),a=(i-Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0))/e.getVisibleDatasetCount();this.outerRadius=i-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(e,t,n,r){let i=r===`reset`,a=this.chart,o=a.options.animation,s=this._cachedMeta.rScale,c=s.xCenter,l=s.yCenter,u=s.getIndexAngle(0)-.5*Y,d=u,f,p=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(n).r)&&this.chart.getDataVisibility(n)&&t++}),t}_computeAngle(e,t,n){return this.chart.getDataVisibility(e)?Zn(this.resolveDataElementOptions(e,t).angle||n):0}},jo=Object.freeze({__proto__:null,BarController:To,BubbleController:Eo,DoughnutController:Oo,LineController:ko,PieController:class extends Oo{static id=`pie`;static defaults={cutout:0,rotation:0,circumference:360,radius:`100%`}},PolarAreaController:Ao,RadarController:class extends co{static id=`radar`;static defaults={datasetElementType:`line`,dataElementType:`point`,indexAxis:`r`,showLine:!0,elements:{line:{fill:`start`}}};static overrides={aspectRatio:1,scales:{r:{type:`radialLinear`}}};getLabelAndValue(e){let t=this._cachedMeta.vScale,n=this.getParsed(e);return{label:t.getLabels()[e],value:``+t.getLabelForValue(n[t.axis])}}parseObjectData(e,t,n,r){return Bi.bind(this)(e,t,n,r)}update(e){let t=this._cachedMeta,n=t.dataset,r=t.data||[],i=t.iScale.getLabels();if(n.points=r,e!==`resize`){let t=this.resolveDatasetElementOptions(e);this.options.showLine||(t.borderWidth=0);let a={_loop:!0,_fullLoop:i.length===r.length,options:t};this.updateElement(n,void 0,a,e)}this.updateElements(r,0,r.length,e)}updateElements(e,t,n,r){let i=this._cachedMeta.rScale,a=r===`reset`;for(let o=t;o0&&this.getParsed(t-1);for(let l=t;l0&&Math.abs(n[f]-v[f])>g,h&&(m.parsed=n,m.raw=c.data[l]),d&&(m.options=u||this.resolveDataElementOptions(l,t.active?`active`:r)),_||this.updateElement(t,l,m,r),v=n}this.updateSharedOptions(u,r,l)}getMaxOverflow(){let e=this._cachedMeta,t=e.data||[];if(!this.options.showLine){let e=0;for(let n=t.length-1;n>=0;--n)e=Math.max(e,t[n].size(this.resolveDataElementOptions(n))/2);return e>0&&e}let n=e.dataset,r=n.options&&n.options.borderWidth||0;if(!t.length)return r;let i=t[0].size(this.resolveDataElementOptions(0)),a=t[t.length-1].size(this.resolveDataElementOptions(t.length-1));return Math.max(r,i,a)/2}}});function Mo(){throw Error(`This method is not implemented: Check that a complete date adapter is provided.`)}var No={_date:class e{static override(t){Object.assign(e.prototype,t)}options;constructor(e){this.options=e||{}}init(){}formats(){return Mo()}parse(){return Mo()}format(){return Mo()}add(){return Mo()}diff(){return Mo()}startOf(){return Mo()}endOf(){return Mo()}}};function Po(e,t,n,r){let{controller:i,data:a,_sorted:o}=e,s=i._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(s&&t===s.axis&&t!==`r`&&o&&a.length){let o=s._reversePixels?ur:lr;if(!r){let r=o(a,t,n);if(c){let{vScale:t}=i._cachedMeta,{_parsed:n}=e,a=n.slice(0,r.lo+1).reverse().findIndex(e=>!U(e[t.axis]));r.lo-=Math.max(0,a);let o=n.slice(r.hi).findIndex(e=>!U(e[t.axis]));r.hi+=Math.max(0,o)}return r}else if(i._sharedOptions){let e=a[0],r=typeof e.getRange==`function`&&e.getRange(t);if(r){let e=o(a,t,n-r),i=o(a,t,n+r);return{lo:e.lo,hi:i.hi}}}}return{lo:0,hi:a.length-1}}function Fo(e,t,n,r,i){let a=e.getSortedVisibleDatasetMetas(),o=n[t];for(let e=0,n=a.length;e{e[o]&&e[o](t[n],i)&&(a.push({element:e,datasetIndex:r,index:c}),s||=e.inRange(t.x,t.y,i))}),r&&!s?[]:a}var Ho={evaluateInteractionItems:Fo,modes:{index(e,t,n,r){let i=oa(t,e),a=n.axis||`x`,o=n.includeInvisible||!1,s=n.intersect?Lo(e,i,a,r,o):Bo(e,i,a,!1,r,o),c=[];return s.length?(e.getSortedVisibleDatasetMetas().forEach(e=>{let t=s[0].index,n=e.data[t];n&&!n.skip&&c.push({element:n,datasetIndex:e.index,index:t})}),c):[]},dataset(e,t,n,r){let i=oa(t,e),a=n.axis||`xy`,o=n.includeInvisible||!1,s=n.intersect?Lo(e,i,a,r,o):Bo(e,i,a,!1,r,o);if(s.length>0){let t=s[0].datasetIndex,n=e.getDatasetMeta(t).data;s=[];for(let e=0;ee.pos===t)}function Go(e,t){return e.filter(e=>Uo.indexOf(e.pos)===-1&&e.box.axis===t)}function Ko(e,t){return e.sort((e,n)=>{let r=t?n:e,i=t?e:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function qo(e){let t=[],n,r,i,a,o,s;for(n=0,r=(e||[]).length;ne.box.fullSize),!0),r=Ko(Wo(t,`left`),!0),i=Ko(Wo(t,`right`)),a=Ko(Wo(t,`top`),!0),o=Ko(Wo(t,`bottom`)),s=Go(t,`x`),c=Go(t,`y`);return{fullSize:n,leftAndTop:r.concat(a),rightAndBottom:i.concat(c).concat(o).concat(s),chartArea:Wo(t,`chartArea`),vertical:r.concat(i).concat(c),horizontal:a.concat(o).concat(s)}}function Zo(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function Qo(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function $o(e,t,n,r){let{pos:i,box:a}=n,o=e.maxPadding;if(!G(i)){n.size&&(e[i]-=n.size);let t=r[n.stack]||{size:0,count:1};t.size=Math.max(t.size,n.horizontal?a.height:a.width),n.size=t.size/t.count,e[i]+=n.size}a.getPadding&&Qo(o,a.getPadding());let s=Math.max(0,t.outerWidth-Zo(o,e,`left`,`right`)),c=Math.max(0,t.outerHeight-Zo(o,e,`top`,`bottom`)),l=s!==e.w,u=c!==e.h;return e.w=s,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function es(e){let t=e.maxPadding;function n(n){let r=Math.max(t[n]-e[n],0);return e[n]+=r,r}e.y+=n(`top`),e.x+=n(`left`),n(`right`),n(`bottom`)}function ts(e,t){let n=t.maxPadding;function r(e){let r={left:0,top:0,right:0,bottom:0};return e.forEach(e=>{r[e]=Math.max(t[e],n[e])}),r}return r(e?[`left`,`right`]:[`top`,`bottom`])}function ns(e,t,n,r){let i=[],a,o,s,c,l,u;for(a=0,o=e.length,l=0;a{typeof e.beforeLayout==`function`&&e.beforeLayout()});let u=c.reduce((e,t)=>t.box.options&&t.box.options.display===!1?e:e+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:a,availableHeight:o,vBoxMaxWidth:a/2/u,hBoxMaxHeight:o/2}),f=Object.assign({},i);Qo(f,gi(r));let p=Object.assign({maxPadding:f,w:a,h:o,x:i.left,y:i.top},i),m=Yo(c.concat(l),d);ns(s.fullSize,p,d,m),ns(c,p,d,m),ns(l,p,d,m)&&ns(c,p,d,m),es(p),is(s.leftAndTop,p,d,m),p.x+=p.w,p.y+=p.h,is(s.rightAndBottom,p,d,m),e.chartArea={left:p.left,top:p.top,right:p.left+p.w,bottom:p.top+p.h,height:p.h,width:p.w},J(s.chartArea,t=>{let n=t.box;Object.assign(n,e.chartArea),n.update(p.w,p.h,{left:0,top:0,right:0,bottom:0})})}},os=class{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,r){return t=Math.max(0,t||e.width),n||=e.height,{width:t,height:Math.max(0,r?Math.floor(t/r):n)}}isAttached(e){return!0}updateConfig(e){}},ss=class extends os{acquireContext(e){return e&&e.getContext&&e.getContext(`2d`)||null}updateConfig(e){e.options.animation=!1}},cs=`$chartjs`,ls={touchstart:`mousedown`,touchmove:`mousemove`,touchend:`mouseup`,pointerenter:`mouseenter`,pointerdown:`mousedown`,pointermove:`mousemove`,pointerup:`mouseup`,pointerleave:`mouseout`,pointerout:`mouseout`},us=e=>e===null||e===``;function ds(e,t){let n=e.style,r=e.getAttribute(`height`),i=e.getAttribute(`width`);if(e[cs]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||`block`,n.boxSizing=n.boxSizing||`border-box`,us(i)){let t=fa(e,`width`);t!==void 0&&(e.width=t)}if(us(r))if(e.style.height===``)e.height=e.width/(t||2);else{let t=fa(e,`height`);t!==void 0&&(e.height=t)}return e}var fs=da?{passive:!0}:!1;function ps(e,t,n){e&&e.addEventListener(t,n,fs)}function ms(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,fs)}function hs(e,t){let n=ls[e.type]||e.type,{x:r,y:i}=oa(e,t);return{type:n,chart:t,native:e,x:r===void 0?null:r,y:i===void 0?null:i}}function gs(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function _s(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=gs(n.addedNodes,r),t&&=!gs(n.removedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function vs(e,t,n){let r=e.canvas,i=new MutationObserver(e=>{let t=!1;for(let n of e)t||=gs(n.removedNodes,r),t&&=!gs(n.addedNodes,r);t&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var ys=new Map,bs=0;function xs(){let e=window.devicePixelRatio;e!==bs&&(bs=e,ys.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function Ss(e,t){ys.size||window.addEventListener(`resize`,xs),ys.set(e,t)}function Cs(e){ys.delete(e),ys.size||window.removeEventListener(`resize`,xs)}function ws(e,t,n){let r=e.canvas,i=r&&Qi(r);if(!i)return;let a=_r((e,t)=>{let r=i.clientWidth;n(e,t),r{let t=e[0],n=t.contentRect.width,r=t.contentRect.height;n===0&&r===0||a(n,r)});return o.observe(i),Ss(e,a),o}function Ts(e,t,n){n&&n.disconnect(),t===`resize`&&Cs(e)}function Es(e,t,n){let r=e.canvas,i=_r(t=>{e.ctx!==null&&n(hs(t,e))},e);return ps(r,t,i),i}var Ds=class extends os{acquireContext(e,t){let n=e&&e.getContext&&e.getContext(`2d`);return n&&n.canvas===e?(ds(e,t),n):null}releaseContext(e){let t=e.canvas;if(!t[cs])return!1;let n=t[cs].initial;[`height`,`width`].forEach(e=>{let r=n[e];U(r)?t.removeAttribute(e):t.setAttribute(e,r)});let r=n.style||{};return Object.keys(r).forEach(e=>{t.style[e]=r[e]}),t.width=t.width,delete t[cs],!0}addEventListener(e,t,n){this.removeEventListener(e,t);let r=e.$proxies||={};r[t]=({attach:_s,detach:vs,resize:ws}[t]||Es)(e,t,n)}removeEventListener(e,t){let n=e.$proxies||={},r=n[t];r&&(({attach:Ts,detach:Ts,resize:Ts}[t]||ms)(e,t,r),n[t]=void 0)}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,r){return la(e,t,n,r)}isAttached(e){let t=e&&Qi(e);return!!(t&&t.isConnected)}};function Os(e){return!Zi()||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas?ss:Ds}var ks=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(e){let{x:t,y:n}=this.getProps([`x`,`y`],e);return{x:t,y:n}}hasValue(){return Jn(this.x)&&Jn(this.y)}getProps(e,t){let n=this.$animations;if(!t||!n)return this;let r={};return e.forEach(e=>{r[e]=n[e]&&n[e].active()?n[e]._to:this[e]}),r}};function As(e,t){let n=e.options.ticks,r=js(e),i=Math.min(n.maxTicksLimit||r,r),a=n.major.enabled?Ns(t):[],o=a.length,s=a[0],c=a[o-1],l=[];if(o>i)return Ps(t,l,a,o/i),l;let u=Ms(a,t,i);if(o>0){let e,n,r=o>1?Math.round((c-s)/(o-1)):null;for(Fs(t,l,u,U(r)?0:s-r,s),e=0,n=o-1;ei)return t}return Math.max(i,1)}function Ns(e){let t=[],n,r;for(n=0,r=e.length;ne===`left`?`right`:e===`right`?`left`:e,Rs=(e,t,n)=>t===`top`||t===`left`?e[t]+n:e[t]-n,zs=(e,t)=>Math.min(t||e,e);function Bs(e,t){let n=[],r=e.length/t,i=e.length,a=0;for(;ao+s)))return c}function Hs(e,t){J(e,e=>{let n=e.gc,r=n.length/2,i;if(r>t){for(i=0;in?n:t,n=r&&t>n?t:n,{min:_n(t,_n(n,t)),max:_n(n,_n(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||=this._computeLabelItems(e)}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){q(this.options.beforeUpdate,[this])}update(e,t,n){let{beginAtZero:r,grace:i,ticks:a}=this.options,o=a.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||=(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=yi(this,i,r),!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let s=o=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}let l=this._getLabelSizes(),u=l.widest.width,d=l.highest.height,f=ar(this.chart.width-u,0,this.maxWidth);o=e.offset?this.maxWidth/n:f/(n-1),u+6>o&&(o=f/(n-(e.offset?.5:1)),s=this.maxHeight-Us(e.grid)-t.padding-Ws(e.title,this.chart.options.font),c=Math.sqrt(u*u+d*d),a=Qn(Math.min(Math.asin(ar((l.highest.height+6)/o,-1,1)),Math.asin(ar(s/c,-1,1))-Math.asin(ar(d/c,-1,1)))),a=Math.max(r,Math.min(i,a))),this.labelRotation=a}afterCalculateLabelRotation(){q(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){q(this.options.beforeFit,[this])}fit(){let e={width:0,height:0},{chart:t,options:{ticks:n,title:r,grid:i}}=this,a=this._isVisible(),o=this.isHorizontal();if(a){let a=Ws(r,t.options.font);if(o?(e.width=this.maxWidth,e.height=Us(i)+a):(e.height=this.maxHeight,e.width=Us(i)+a),n.display&&this.ticks.length){let{first:t,last:r,widest:i,highest:a}=this._getLabelSizes(),s=n.padding*2,c=Zn(this.labelRotation),l=Math.cos(c),u=Math.sin(c);if(o){let t=n.mirror?0:u*i.width+l*a.height;e.height=Math.min(this.maxHeight,e.height+t+s)}else{let t=n.mirror?0:l*i.width+u*a.height;e.width=Math.min(this.maxWidth,e.width+t+s)}this._calculatePadding(t,r,u,l)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,r){let{ticks:{align:i,padding:a},position:o}=this.options,s=this.labelRotation!==0,c=o!==`top`&&this.axis===`x`;if(this.isHorizontal()){let o=this.getPixelForTick(0)-this.left,l=this.right-this.getPixelForTick(this.ticks.length-1),u=0,d=0;s?c?(u=r*e.width,d=n*t.height):(u=n*e.height,d=r*t.width):i===`start`?d=t.width:i===`end`?u=e.width:i!==`inner`&&(u=e.width/2,d=t.width/2),this.paddingLeft=Math.max((u-o+a)*this.width/(this.width-o),0),this.paddingRight=Math.max((d-l+a)*this.width/(this.width-l),0)}else{let n=t.height/2,r=e.height/2;i===`start`?(n=0,r=e.height):i===`end`&&(n=t.height,r=0),this.paddingTop=n+a,this.paddingBottom=r+a}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){q(this.options.afterFit,[this])}isHorizontal(){let{axis:e,position:t}=this.options;return t===`top`||t===`bottom`||e===`x`}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:a[e]||0,height:o[e]||0});return{first:C(0),last:C(t-1),widest:C(x),highest:C(S),widths:a,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){let t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);let t=this._startPixel+e*this._length;return or(this._alignToPixels?Yr(this.chart,t,0):t)}getDecimalForPixel(e){let t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){let t=this.ticks||[];if(e>=0&&eo*r?o/n:s/r:s*r0:!!e}_computeGridLineItems(e){let t=this.axis,n=this.chart,r=this.options,{grid:i,position:a,border:o}=r,s=i.offset,c=this.isHorizontal(),l=this.ticks.length+ +!!s,u=Us(i),d=[],f=o.setContext(this.getContext()),p=f.display?f.width:0,m=p/2,h=function(e){return Yr(n,e,p)},g,_,v,y,b,x,S,C,w,T,E,ee;if(a===`top`)g=h(this.bottom),x=this.bottom-u,C=g-m,T=h(e.top)+m,ee=e.bottom;else if(a===`bottom`)g=h(this.top),T=e.top,ee=h(e.bottom)-m,x=g+m,C=this.top+u;else if(a===`left`)g=h(this.right),b=this.right-u,S=g-m,w=h(e.left)+m,E=e.right;else if(a===`right`)g=h(this.left),w=e.left,E=h(e.right)-m,b=g+m,S=this.left+u;else if(t===`x`){if(a===`center`)g=h((e.top+e.bottom)/2+.5);else if(G(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}T=e.top,ee=e.bottom,x=g+m,C=x+u}else if(t===`y`){if(a===`center`)g=h((e.left+e.right)/2);else if(G(a)){let e=Object.keys(a)[0],t=a[e];g=h(this.chart.scales[e].getPixelForValue(t))}b=g-m,S=b-u,w=e.left,E=e.right}let te=K(r.ticks.maxTicksLimit,l),ne=Math.max(1,Math.ceil(l/te));for(_=0;_0&&(a-=r/2);break}f={left:a,top:i,width:r+t.width,height:n+t.height,color:e.backdropColor}}h.push({label:y,font:w,textOffset:ee,options:{rotation:m,color:n,strokeColor:s,strokeWidth:l,textAlign:d,textBaseline:te,translation:[b,x],backdrop:f}})}return h}_getXAxisLabelAlignment(){let{position:e,ticks:t}=this.options;if(-Zn(this.labelRotation))return e===`top`?`left`:`right`;let n=`center`;return t.align===`start`?n=`left`:t.align===`end`?n=`right`:t.align===`inner`&&(n=`inner`),n}_getYAxisLabelAlignment(e){let{position:t,ticks:{crossAlign:n,mirror:r,padding:i}}=this.options,a=this._getLabelSizes(),o=e+i,s=a.widest.width,c,l;return t===`left`?r?(l=this.right+i,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l+=s)):(l=this.right-o,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l=this.left)):t===`right`?r?(l=this.left+i,n===`near`?c=`right`:n===`center`?(c=`center`,l-=s/2):(c=`left`,l-=s)):(l=this.left+o,n===`near`?c=`left`:n===`center`?(c=`center`,l+=s/2):(c=`right`,l=this.right)):c=`right`,{textAlign:c,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;let e=this.chart,t=this.options.position;if(t===`left`||t===`right`)return{top:0,left:this.left,bottom:e.height,right:this.right};if(t===`top`||t===`bottom`)return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){let{ctx:e,options:{backgroundColor:t},left:n,top:r,width:i,height:a}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,r,i,a),e.restore())}getLineWidthForValue(e){let t=this.options.grid;if(!this._isVisible()||!t.display)return 0;let n=this.ticks.findIndex(t=>t.value===e);return n>=0?t.setContext(this.getContext(n)).lineWidth:0}drawGrid(e){let t=this.options.grid,n=this.ctx,r=this._gridLineItems||=this._computeGridLineItems(e),i,a,o=(e,t,r)=>{!r.width||!r.color||(n.save(),n.lineWidth=r.width,n.strokeStyle=r.color,n.setLineDash(r.borderDash||[]),n.lineDashOffset=r.borderDashOffset,n.beginPath(),n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.stroke(),n.restore())};if(t.display)for(i=0,a=r.length;i{this.draw(e)}}]:[{z:r,draw:e=>{this.drawBackground(),this.drawGrid(e),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:e=>{this.drawLabels(e)}}]}getMatchingVisibleMetas(e){let t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+`AxisID`,r=[],i,a;for(i=0,a=t.length;i{let r=n.split(`.`),i=r.pop(),a=[e].concat(r).join(`.`),o=t[n].split(`.`),s=o.pop(),c=o.join(`.`);Z.route(a,i,c,s)})}function $s(e){return`id`in e&&`defaults`in e}var ec=new class{constructor(){this.controllers=new Xs(co,`datasets`,!0),this.elements=new Xs(ks,`elements`),this.plugins=new Xs(Object,`plugins`),this.scales=new Xs(Ys,`scales`),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each(`register`,e)}remove(...e){this._each(`unregister`,e)}addControllers(...e){this._each(`register`,e,this.controllers)}addElements(...e){this._each(`register`,e,this.elements)}addPlugins(...e){this._each(`register`,e,this.plugins)}addScales(...e){this._each(`register`,e,this.scales)}getController(e){return this._get(e,this.controllers,`controller`)}getElement(e){return this._get(e,this.elements,`element`)}getPlugin(e){return this._get(e,this.plugins,`plugin`)}getScale(e){return this._get(e,this.scales,`scale`)}removeControllers(...e){this._each(`unregister`,e,this.controllers)}removeElements(...e){this._each(`unregister`,e,this.elements)}removePlugins(...e){this._each(`unregister`,e,this.plugins)}removeScales(...e){this._each(`unregister`,e,this.scales)}_each(e,t,n){[...t].forEach(t=>{let r=n||this._getRegistryForType(t);n||r.isForType(t)||r===this.plugins&&t.id?this._exec(e,r,t):J(t,t=>{let r=n||this._getRegistryForType(t);this._exec(e,r,t)})})}_exec(e,t,n){let r=jn(e);q(n[`before`+r],[],n),t[e](n),q(n[`after`+r],[],n)}_getRegistryForType(e){for(let t=0;te.filter(e=>!t.some(t=>e.plugin.id===t.plugin.id));this._notify(r(t,n),e,`stop`),this._notify(r(n,t),e,`start`)}};function nc(e){let t={},n=[],r=Object.keys(ec.plugins.items);for(let e=0;e1&&lc(e[0].toLowerCase());if(t)return t}throw Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function fc(e,t,n){if(n[t+`AxisID`]===e)return{axis:t}}function pc(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(t=>t.xAxisID===e||t.yAxisID===e);if(n.length)return fc(e,`x`,n[0])||fc(e,`y`,n[0])}return{}}function mc(e,t){let n=Hr[e.type]||{scales:{}},r=t.scales||{},i=oc(e.type,t),a=Object.create(null);return Object.keys(r).forEach(t=>{let o=r[t];if(!G(o))return console.error(`Invalid scale configuration for scale: ${t}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${t}`);let s=dc(t,o,pc(t,e),Z.scales[o.type]),c=cc(s,i),l=n.scales||{};a[t]=Tn(Object.create(null),[{axis:s},o,l[s],l[c]])}),e.data.datasets.forEach(n=>{let i=n.type||e.type,o=n.indexAxis||oc(i,t),s=(Hr[i]||{}).scales||{};Object.keys(s).forEach(e=>{let t=sc(e,o),i=n[t+`AxisID`]||t;a[i]=a[i]||Object.create(null),Tn(a[i],[{axis:t},r[i],s[e]])})}),Object.keys(a).forEach(e=>{let t=a[e];Tn(t,[Z.scales[t.type],Z.scale])}),a}function hc(e){let t=e.options||={};t.plugins=K(t.plugins,{}),t.scales=mc(e,t)}function gc(e){return e||={},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function _c(e){return e||={},e.data=gc(e.data),hc(e),e}var vc=new Map,yc=new Set;function bc(e,t){let n=vc.get(e);return n||(n=t(),vc.set(e,n),yc.add(n)),n}var xc=(e,t,n)=>{let r=An(t,n);r!==void 0&&e.add(r)},Sc=class{constructor(e){this._config=_c(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=gc(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){let e=this._config;this.clearCache(),hc(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return bc(e,()=>[[`datasets.${e}`,``]])}datasetAnimationScopeKeys(e,t){return bc(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,``]])}datasetElementScopeKeys(e,t){return bc(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,``]])}pluginScopeKeys(e){let t=e.id,n=this.type;return bc(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){let n=this._scopeCache,r=n.get(e);return(!r||t)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,t,n){let{options:r,type:i}=this,a=this._cachedScopes(e,n),o=a.get(t);if(o)return o;let s=new Set;t.forEach(t=>{e&&(s.add(e),t.forEach(t=>xc(s,e,t))),t.forEach(e=>xc(s,r,e)),t.forEach(e=>xc(s,Hr[i]||{},e)),t.forEach(e=>xc(s,Z,e)),t.forEach(e=>xc(s,Ur,e))});let c=Array.from(s);return c.length===0&&c.push(Object.create(null)),yc.has(t)&&a.set(t,c),c}chartOptionScopes(){let{options:e,type:t}=this;return[e,Hr[t]||{},Z.datasets[t]||{},{type:t},Z,Ur]}resolveNamedOptions(e,t,n,r=[``]){let i={$shared:!0},{resolver:a,subPrefixes:o}=Cc(this._resolverCache,e,r),s=a;if(Tc(a,t)){i.$shared=!1,n=Nn(n)?n():n;let t=this.createResolver(e,n,o);s=Si(a,n,t)}for(let e of t)i[e]=s[e];return i}createResolver(e,t,n=[``],r){let{resolver:i}=Cc(this._resolverCache,e,n);return G(t)?Si(i,t,void 0,r):i}};function Cc(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),a=r.get(i);return a||(a={resolver:xi(t,n),subPrefixes:n.filter(e=>!e.toLowerCase().includes(`hover`))},r.set(i,a)),a}var wc=e=>G(e)&&Object.getOwnPropertyNames(e).some(t=>Nn(e[t]));function Tc(e,t){let{isScriptable:n,isIndexable:r}=Ci(e);for(let i of t){let t=n(i),a=r(i),o=(a||t)&&e[i];if(t&&(Nn(o)||wc(o))||a&&W(o))return!0}return!1}var Ec=`4.5.1`,Dc=[`top`,`bottom`,`left`,`right`,`chartArea`];function Oc(e,t){return e===`top`||e===`bottom`||Dc.indexOf(e)===-1&&t===`x`}function kc(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function Ac(e){let t=e.chart,n=t.options.animation;t.notifyPlugins(`afterRender`),q(n&&n.onComplete,[e],t)}function jc(e){let t=e.chart,n=t.options.animation;q(n&&n.onProgress,[e],t)}function Mc(e){return Zi()&&typeof e==`string`?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var Nc={},Pc=e=>{let t=Mc(e);return Object.values(Nc).filter(e=>e.canvas===t).pop()};function Fc(e,t,n){let r=Object.keys(e);for(let i of r){let r=+i;if(r>=t){let a=e[i];delete e[i],(n>0||r>t)&&(e[r+n]=a)}}}function Ic(e,t,n,r){return!n||e.type===`mouseout`?null:r?t:e}var Lc=class{static defaults=Z;static instances=Nc;static overrides=Hr;static registry=ec;static version=Ec;static getChart=Pc;static register(...e){ec.add(...e),Rc()}static unregister(...e){ec.remove(...e),Rc()}constructor(e,t){let n=this.config=new Sc(t),r=Mc(e),i=Pc(r);if(i)throw Error(`Canvas is already in use. Chart with ID '`+i.id+`' must be destroyed before the canvas with ID '`+i.canvas.id+`' can be reused.`);let a=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||(Os(r))),this.platform.updateConfig(n);let o=this.platform.acquireContext(r,a.aspectRatio),s=o&&o.canvas,c=s&&s.height,l=s&&s.width;if(this.id=hn(),this.ctx=o,this.canvas=s,this.width=l,this.height=c,this._options=a,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new tc,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=vr(e=>this.update(e),a.resizeDelay||0),this._dataChanges=[],Nc[this.id]=this,!o||!s){console.error(`Failed to create chart: can't acquire context from the given item`);return}Ia.listen(this,`complete`,Ac),Ia.listen(this,`progress`,jc),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:r,_aspectRatio:i}=this;return U(e)?t&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return ec}_initialize(){return this.notifyPlugins(`beforeInit`),this.options.responsive?this.resize():ua(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins(`afterInit`),this}clear(){return Xr(this.canvas,this.ctx),this}stop(){return Ia.stop(this),this}resize(e,t){Ia.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){let n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,a=this.platform.getMaximumSize(r,e,t,i),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),s=this.width?`resize`:`attach`;this.width=a.width,this.height=a.height,this._aspectRatio=this.aspectRatio,ua(this,o,!0)&&(this.notifyPlugins(`resize`,{size:a}),q(n.onResize,[this,a],this),this.attached&&this._doResize(s)&&this.render())}ensureScalesHaveIDs(){J(this.options.scales||{},(e,t)=>{e.id=t})}buildOrUpdateScales(){let e=this.options,t=e.scales,n=this.scales,r=Object.keys(n).reduce((e,t)=>(e[t]=!1,e),{}),i=[];t&&(i=i.concat(Object.keys(t).map(e=>{let n=t[e],r=dc(e,n),i=r===`r`,a=r===`x`;return{options:n,dposition:i?`chartArea`:a?`bottom`:`left`,dtype:i?`radialLinear`:a?`category`:`linear`}}))),J(i,t=>{let i=t.options,a=i.id,o=dc(a,i),s=K(i.type,t.dtype);(i.position===void 0||Oc(i.position,o)!==Oc(t.dposition))&&(i.position=t.dposition),r[a]=!0;let c=null;a in n&&n[a].type===s?c=n[a]:(c=new(ec.getScale(s))({id:a,type:s,ctx:this.ctx,chart:this}),n[c.id]=c),c.init(i,e)}),J(r,(e,t)=>{e||delete n[t]}),J(n,e=>{as.configure(this,e,e.options),as.addBox(this,e)})}_updateMetasets(){let e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((e,t)=>e.index-t.index),n>t){for(let e=t;et.length&&delete this._stacks,e.forEach((e,n)=>{t.filter(t=>t===e._dataset).length===0&&this._destroyDatasetMeta(n)})}buildOrUpdateControllers(){let e=[],t=this.data.datasets,n,r;for(this._removeUnreferencedMetasets(),n=0,r=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins(`reset`)}update(e){let t=this.config;t.update();let n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins(`beforeUpdate`,{mode:e,cancelable:!0})===!1)return;let i=this.buildOrUpdateControllers();this.notifyPlugins(`beforeElementsUpdate`);let a=0;for(let e=0,t=this.data.datasets.length;e{e.reset()}),this._updateDatasets(e),this.notifyPlugins(`afterUpdate`,{mode:e}),this._layers.sort(kc(`z`,`_idx`));let{_active:o,_lastEvent:s}=this;s?this._eventHandler(s,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){J(this.scales,e=>{as.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let e=this.options;(!Pn(new Set(Object.keys(this._listeners)),new Set(e.events))||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(let{method:n,start:r,count:i}of t)Fc(e,r,n===`_removeElements`?-i:i)}_getUniformDataChanges(){let e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];let t=this.data.datasets.length,n=t=>new Set(e.filter(e=>e[0]===t).map((e,t)=>t+`,`+e.splice(1).join(`,`))),r=n(0);for(let e=1;ee.split(`,`)).map(e=>({method:e[1],start:+e[2],count:+e[3]}))}_updateLayout(e){if(this.notifyPlugins(`beforeLayout`,{cancelable:!0})===!1)return;as.update(this,this.width,this.height,e);let t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],J(this.boxes,e=>{n&&e.position===`chartArea`||(e.configure&&e.configure(),this._layers.push(...e._layers()))},this),this._layers.forEach((e,t)=>{e._idx=t}),this.notifyPlugins(`afterLayout`)}_updateDatasets(e){if(this.notifyPlugins(`beforeDatasetsUpdate`,{mode:e,cancelable:!0})!==!1){for(let e=0,t=this.data.datasets.length;e=0;--t)this._drawDataset(e[t]);this.notifyPlugins(`afterDatasetsDraw`)}_drawDataset(e){let t=this.ctx,n={meta:e,index:e.index,cancelable:!0},r=Fa(this,e);this.notifyPlugins(`beforeDatasetDraw`,n)!==!1&&(r&&ei(t,r),e.controller.draw(),r&&ti(t),n.cancelable=!1,this.notifyPlugins(`afterDatasetDraw`,n))}isPointInArea(e){return $r(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,r){let i=Ho.modes[t];return typeof i==`function`?i(this,e,n,r):[]}getDatasetMeta(e){let t=this.data.datasets[e],n=this._metasets,r=n.filter(e=>e&&e._dataset===t).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||=bi(null,{chart:this,type:`chart`})}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){let t=this.data.datasets[e];if(!t)return!1;let n=this.getDatasetMeta(e);return typeof n.hidden==`boolean`?!n.hidden:!t.hidden}setDatasetVisibility(e,t){let n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){let r=n?`show`:`hide`,i=this.getDatasetMeta(e),a=i.controller._resolveAnimations(void 0,r);Mn(t)?(i.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),a.update(i,{visible:n}),this.update(t=>t.datasetIndex===e?r:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){let t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),Ia.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,n,r),e[n]=r},r=(e,t,n)=>{e.offsetX=t,e.offsetY=n,this._eventHandler(e)};J(this.options.events,e=>n(e,r))}bindResponsiveEvents(){this._responsiveListeners||={};let e=this._responsiveListeners,t=this.platform,n=(n,r)=>{t.addEventListener(this,n,r),e[n]=r},r=(n,r)=>{e[n]&&(t.removeEventListener(this,n,r),delete e[n])},i=(e,t)=>{this.canvas&&this.resize(e,t)},a,o=()=>{r(`attach`,o),this.attached=!0,this.resize(),n(`resize`,i),n(`detach`,a)};a=()=>{this.attached=!1,r(`resize`,i),this._stop(),this._resize(0,0),n(`attach`,o)},t.isAttached(this.canvas)?o():a()}unbindEvents(){J(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},J(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){let r=n?`set`:`remove`,i,a,o,s;for(t===`dataset`&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller[`_`+r+`DatasetHoverStyle`]()),o=0,s=e.length;o{let n=this.getDatasetMeta(e);if(!n)throw Error(`No dataset found at index `+e);return{datasetIndex:e,element:n.data[t],index:t}});bn(n,t)||(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){let r=this.options.hover,i=(e,t)=>e.filter(e=>!t.some(t=>e.datasetIndex===t.datasetIndex&&e.index===t.index)),a=i(t,e),o=n?e:i(e,t);a.length&&this.updateHoverStyle(a,r.mode,!1),o.length&&r.mode&&this.updateHoverStyle(o,r.mode,!0)}_eventHandler(e,t){let n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},r=t=>(t.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins(`beforeEvent`,n,r)===!1)return;let i=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins(`afterEvent`,n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,t,n){let{_active:r=[],options:i}=this,a=t,o=this._getActiveElements(e,r,n,a),s=Fn(e),c=Ic(e,this._lastEvent,n,s);n&&(this._lastEvent=null,q(i.onHover,[e,o,this],this),s&&q(i.onClick,[e,o,this],this));let l=!bn(o,r);return(l||t)&&(this._active=o,this._updateHoverStyles(o,r,t)),this._lastEvent=c,l}_getActiveElements(e,t,n,r){if(e.type===`mouseout`)return[];if(!n)return t;let i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}};function Rc(){return J(Lc.instances,e=>e._plugins.invalidate())}function zc(e,t,n){let{startAngle:r,x:i,y:a,outerRadius:o,innerRadius:s,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,d=Math.min(l/o,rr(r-n));if(e.beginPath(),e.arc(i,a,o-l/2,r+d/2,n-d/2),s>0){let t=Math.min(l/s,rr(r-n));e.arc(i,a,s+l/2,n-t/2,r+t/2,!0)}else{let t=Math.min(l/2,o*rr(r-n));if(u===`round`)e.arc(i,a,t,n-Y/2,r+Y/2,!0);else if(u===`bevel`){let o=2*t*t,s=-o*Math.cos(n+Y/2)+i,c=-o*Math.sin(n+Y/2)+a,l=o*Math.cos(r+Y/2)+i,u=o*Math.sin(r+Y/2)+a;e.lineTo(s,c),e.lineTo(l,u)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip(`evenodd`)}function Bc(e,t,n){let{startAngle:r,pixelMargin:i,x:a,y:o,outerRadius:s,innerRadius:c}=t,l=i/s;e.beginPath(),e.arc(a,o,s,r-l,n+l),c>i?(l=i/c,e.arc(a,o,c,n+l,r-l,!0)):e.arc(a,o,i,n+zn,r-zn),e.closePath(),e.clip()}function Vc(e){return pi(e,[`outerStart`,`outerEnd`,`innerStart`,`innerEnd`])}function Hc(e,t,n,r){let i=Vc(e.options.borderRadius),a=(n-t)/2,o=Math.min(a,r*t/2),s=e=>{let t=(n-Math.min(a,e))*r/2;return ar(e,0,Math.min(a,t))};return{outerStart:s(i.outerStart),outerEnd:s(i.outerEnd),innerStart:ar(i.innerStart,0,o),innerEnd:ar(i.innerEnd,0,o)}}function Uc(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function Wc(e,t,n,r,i,a){let{x:o,y:s,startAngle:c,pixelMargin:l,innerRadius:u}=t,d=Math.max(t.outerRadius+r+n-l,0),f=u>0?u+r+n+l:0,p=0,m=i-c;if(r){let e=((u>0?u-r:0)+(d>0?d-r:0))/2;p=(m-(e===0?m:m*e/(e+r)))/2}let h=(m-Math.max(.001,m*d-n/Y)/d)/2,g=c+h+p,_=i-h-p,{outerStart:v,outerEnd:y,innerStart:b,innerEnd:x}=Hc(t,f,d,_-g),S=d-v,C=d-y,w=g+v/S,T=_-y/C,E=f+b,ee=f+x,te=g+b/E,ne=_-x/ee;if(e.beginPath(),a){let t=(w+T)/2;if(e.arc(o,s,d,w,t),e.arc(o,s,d,t,T),y>0){let t=Uc(C,T,o,s);e.arc(t.x,t.y,y,T,_+zn)}let n=Uc(ee,_,o,s);if(e.lineTo(n.x,n.y),x>0){let t=Uc(ee,ne,o,s);e.arc(t.x,t.y,x,_+zn,ne+Math.PI)}let r=(_-x/f+(g+b/f))/2;if(e.arc(o,s,f,_-x/f,r,!0),e.arc(o,s,f,r,g+b/f,!0),b>0){let t=Uc(E,te,o,s);e.arc(t.x,t.y,b,te+Math.PI,g-zn)}let i=Uc(S,g,o,s);if(e.lineTo(i.x,i.y),v>0){let t=Uc(S,w,o,s);e.arc(t.x,t.y,v,g-zn,w)}}else{e.moveTo(o,s);let t=Math.cos(w)*d+o,n=Math.sin(w)*d+s;e.lineTo(t,n);let r=Math.cos(T)*d+o,i=Math.sin(T)*d+s;e.lineTo(r,i)}e.closePath()}function Gc(e,t,n,r,i){let{fullCircles:a,startAngle:o,circumference:s}=t,c=t.endAngle;if(a){Wc(e,t,n,r,c,i);for(let t=0;t=Y&&p===0&&u!==`miter`&&zc(e,t,h),a||(Wc(e,t,n,r,h,i),e.stroke())}var qc=class extends ks{static id=`arc`;static defaults={borderAlign:`center`,borderColor:`#fff`,borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:`backgroundColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(e){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,e&&Object.assign(this,e)}inRange(e,t,n){let{angle:r,distance:i}=er(this.getProps([`x`,`y`],n),{x:e,y:t}),{startAngle:a,endAngle:o,innerRadius:s,outerRadius:c,circumference:l}=this.getProps([`startAngle`,`endAngle`,`innerRadius`,`outerRadius`,`circumference`],n),u=(this.options.spacing+this.options.borderWidth)/2,d=K(l,o-a),f=ir(r,a,o)&&a!==o,p=d>=X||f,m=sr(i,s+u,c+u);return p&&m}getCenterPoint(e){let{x:t,y:n,startAngle:r,endAngle:i,innerRadius:a,outerRadius:o}=this.getProps([`x`,`y`,`startAngle`,`endAngle`,`innerRadius`,`outerRadius`],e),{offset:s,spacing:c}=this.options,l=(r+i)/2,u=(a+o+c+s)/2;return{x:t+Math.cos(l)*u,y:n+Math.sin(l)*u}}tooltipPosition(e){return this.getCenterPoint(e)}draw(e){let{options:t,circumference:n}=this,r=(t.offset||0)/4,i=(t.spacing||0)/2,a=t.circular;if(this.pixelMargin=t.borderAlign===`inner`?.33:0,this.fullCircles=n>X?Math.floor(n/X):0,n===0||this.innerRadius<0||this.outerRadius<0)return;e.save();let o=(this.startAngle+this.endAngle)/2;e.translate(Math.cos(o)*r,Math.sin(o)*r);let s=r*(1-Math.sin(Math.min(Y,n||0)));e.fillStyle=t.backgroundColor,e.strokeStyle=t.borderColor,Gc(e,this,s,i,a),Kc(e,this,s,i,a),e.restore()}};function Jc(e,t,n=t){e.lineCap=K(n.borderCapStyle,t.borderCapStyle),e.setLineDash(K(n.borderDash,t.borderDash)),e.lineDashOffset=K(n.borderDashOffset,t.borderDashOffset),e.lineJoin=K(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=K(n.borderWidth,t.borderWidth),e.strokeStyle=K(n.borderColor,t.borderColor)}function Yc(e,t,n){e.lineTo(n.x,n.y)}function Xc(e){return e.stepped?ni:e.tension||e.cubicInterpolationMode===`monotone`?ri:Yc}function Zc(e,t,n={}){let r=e.length,{start:i=0,end:a=r-1}=n,{start:o,end:s}=t,c=Math.max(i,o),l=Math.min(a,s),u=is&&a>s;return{count:r,start:c,loop:t.loop,ilen:l(o+(l?s-e:e))%a,y=()=>{h!==g&&(e.lineTo(u,g),e.lineTo(u,h),e.lineTo(u,_))};for(c&&(p=i[v(0)],e.moveTo(p.x,p.y)),f=0;f<=s;++f){if(p=i[v(f)],p.skip)continue;let t=p.x,n=p.y,r=t|0;r===m?(ng&&(g=n),u=(d*u+t)/++d):(y(),e.lineTo(t,n),m=r,d=0,h=g=n),_=n}y()}function el(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!==`monotone`&&!t.stepped&&!n?$c:Qc}function tl(e){return e.stepped?ma:e.tension||e.cubicInterpolationMode===`monotone`?ha:pa}function nl(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),Jc(e,t.options),e.stroke(i)}function rl(e,t,n,r){let{segments:i,options:a}=t,o=el(t);for(let s of i)Jc(e,a,s.style),e.beginPath(),o(e,t,s,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var il=typeof Path2D==`function`;function al(e,t,n,r){il&&!t.options.segment?nl(e,t,n,r):rl(e,t,n,r)}var ol=class extends ks{static id=`line`;static defaults={borderCapStyle:`butt`,borderDash:[],borderDashOffset:0,borderJoinStyle:`miter`,borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:`default`,fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:`backgroundColor`,borderColor:`borderColor`};static descriptors={_scriptable:!0,_indexable:e=>e!==`borderDash`&&e!==`fill`};constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){let n=this.options;if((n.tension||n.cubicInterpolationMode===`monotone`)&&!n.stepped&&!this._pointsUpdated){let r=n.spanGaps?this._loop:this._fullLoop;Xi(this._points,n,e,r,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||=Oa(this,this.options.segment)}first(){let e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){let e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){let n=this.options,r=e[t],i=this.points,a=Ta(this,{property:t,start:r,end:r});if(!a.length)return;let o=[],s=tl(n),c,l;for(c=0,l=a.length;ce.replace(`rgb(`,`rgba(`).replace(`)`,`, 0.5)`));function xl(e){return yl[e%yl.length]}function Sl(e){return bl[e%bl.length]}function Cl(e,t){return e.borderColor=xl(t),e.backgroundColor=Sl(t),++t}function wl(e,t){return e.backgroundColor=e.data.map(()=>xl(t++)),t}function Tl(e,t){return e.backgroundColor=e.data.map(()=>Sl(t++)),t}function El(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof Oo?t=wl(n,t):i instanceof Ao?t=Tl(n,t):i&&(t=Cl(n,t))}}function Dl(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function Ol(e){return e&&(e.borderColor||e.backgroundColor)}function kl(){return Z.borderColor!==`rgba(0,0,0,0.1)`||Z.backgroundColor!==`rgba(0,0,0,0.1)`}var Al={id:`colors`,defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:a}=i,o=Dl(r)||Ol(i)||a&&Dl(a)||kl();if(!n.forceOverride&&o)return;let s=El(e);r.forEach(s)}};function jl(e,t,n,r,i){let a=i.samples||r;if(a>=n)return e.slice(t,t+n);let o=[],s=(n-2)/(a-2),c=0,l=t+n-1,u=t,d,f,p,m,h;for(o[c++]=e[u],d=0;dp&&(p=m,f=e[a],h=a);o[c++]=f,u=h}return o[c++]=e[l],o}function Ml(e,t,n,r){let i=0,a=0,o,s,c,l,u,d,f,p,m,h,g=[],_=t+n-1,v=e[t].x,y=e[_].x-v;for(o=t;oh&&(h=l,f=o),i=(a*i+s.x)/++a;else{let n=o-1;if(!U(d)&&!U(f)){let t=Math.min(d,f),r=Math.max(d,f);t!==p&&t!==n&&g.push({...e[t],x:i}),r!==p&&r!==n&&g.push({...e[r],x:i})}o>0&&n!==p&&g.push(e[n]),g.push(s),u=t,a=0,m=h=l,d=f=p=o}}return g}function Nl(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,`data`,{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Pl(e){e.data.datasets.forEach(e=>{Nl(e)})}function Fl(e,t){let n=t.length,r=0,i,{iScale:a}=e,{min:o,max:s,minDefined:c,maxDefined:l}=a.getUserBounds();return c&&(r=ar(lr(t,a.axis,o).lo,0,n-1)),i=l?ar(lr(t,a.axis,s).hi+1,r,n)-r:n-r,{start:r,count:i}}var Il={id:`decimation`,defaults:{algorithm:`min-max`,enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){Pl(e);return}let r=e.width;e.data.datasets.forEach((t,i)=>{let{_data:a,indexAxis:o}=t,s=e.getDatasetMeta(i),c=a||t.data;if(vi([o,e.options.indexAxis])===`y`||!s.controller.supportsDecimation)return;let l=e.scales[s.xAxisID];if(l.type!==`linear`&&l.type!==`time`||e.options.parsing)return;let{start:u,count:d}=Fl(s,c);if(d<=(n.threshold||4*r)){Nl(t);return}U(a)&&(t._data=c,delete t.data,Object.defineProperty(t,`data`,{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(e){this._data=e}}));let f;switch(n.algorithm){case`lttb`:f=jl(c,u,d,r,n);break;case`min-max`:f=Ml(c,u,d,r);break;default:throw Error(`Unsupported decimation algorithm '${n.algorithm}'`)}t._decimated=f})},destroy(e){Pl(e)}};function Ll(e,t,n){let r=e.segments,i=e.points,a=t.points,o=[];for(let e of r){let{start:r,end:s}=e;s=Bl(r,s,i);let c=Rl(n,i[r],i[s],e.loop);if(!t.segments){o.push({source:e,target:c,start:i[r],end:i[s]});continue}let l=Ta(t,c);for(let t of l){let r=Rl(n,a[t.start],a[t.end],t.loop),s=wa(e,i,r);for(let e of s)o.push({source:e,target:t,start:{[n]:Vl(c,r,`start`,Math.max)},end:{[n]:Vl(c,r,`end`,Math.min)}})}}return o}function Rl(e,t,n,r){if(r)return;let i=t[e],a=n[e];return e===`angle`&&(i=rr(i),a=rr(a)),{property:e,start:i,end:a}}function zl(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,a=[];return t.segments.forEach(({start:e,end:t})=>{t=Bl(e,t,i);let o=i[e],s=i[t];r===null?n!==null&&(a.push({x:n,y:o.y}),a.push({x:n,y:s.y})):(a.push({x:o.x,y:r}),a.push({x:s.x,y:r}))}),a}function Bl(e,t,n){for(;t>e;t--){let e=n[t];if(!isNaN(e.x)&&!isNaN(e.y))break}return t}function Vl(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function Hl(e,t){let n=[],r=!1;return W(e)?(r=!0,n=e):n=zl(e,t),n.length?new ol({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function Ul(e){return e&&e.fill!==!1}function Wl(e,t,n){let r=e[t].fill,i=[t],a;if(!n)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!gn(r))return r;if(a=e[r],!a)return!1;if(a.visible)return r;i.push(r),r=a.fill}return!1}function Gl(e,t,n){let r=Yl(e);if(G(r))return isNaN(r.value)?!1:r;let i=parseFloat(r);return gn(i)&&Math.floor(i)===i?Kl(r[0],t,i,n):[`origin`,`start`,`end`,`stack`,`shape`].indexOf(r)>=0&&r}function Kl(e,t,n,r){return(e===`-`||e===`+`)&&(n=t+n),n===t||n<0||n>=r?!1:n}function ql(e,t){let n=null;return e===`start`?n=t.bottom:e===`end`?n=t.top:G(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Jl(e,t,n){let r;return r=e===`start`?n:e===`end`?t.options.reverse?t.min:t.max:G(e)?e.value:t.getBaseValue(),r}function Yl(e){let t=e.options,n=t.fill,r=K(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?`origin`:r}function Xl(e){let{scale:t,index:n,line:r}=e,i=[],a=r.segments,o=r.points,s=Zl(t,n);s.push(Hl({x:null,y:t.bottom},r));for(let e=0;e=0;--t){let n=i[t].$filler;n&&(n.line.updateControlPoints(a,n.axis),r&&n.fill&&ou(e.ctx,n,a))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!==`beforeDatasetsDraw`)return;let r=e.getSortedVisibleDatasetMetas();for(let t=r.length-1;t>=0;--t){let n=r[t].$filler;Ul(n)&&ou(e.ctx,n,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!Ul(r)||n.drawTime!==`beforeDatasetDraw`||ou(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:`beforeDatasetDraw`}},mu=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},hu=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,gu=class extends ks{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let e=this.options.labels||{},t=q(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(t=>e.filter(t,this.chart.data))),e.sort&&(t=t.sort((t,n)=>e.sort(t,n,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){let{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}let n=e.labels,r=_i(n.font),i=r.size,a=this._computeTitleHeight(),{boxWidth:o,itemHeight:s}=mu(n,i),c,l;t.font=r.string,this.isHorizontal()?(c=this.maxWidth,l=this._fitRows(a,i,o,s)+10):(l=this.maxHeight,c=this._fitCols(a,r,o,s)+10),this.width=Math.min(c,e.maxWidth||this.maxWidth),this.height=Math.min(l,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,r){let{ctx:i,maxWidth:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.lineWidths=[0],l=r+o,u=e;i.textAlign=`left`,i.textBaseline=`middle`;let d=-1,f=-l;return this.legendItems.forEach((e,p)=>{let m=n+t/2+i.measureText(e.text).width;(p===0||c[c.length-1]+m+2*o>a)&&(u+=l,c[c.length-(p>0?0:1)]=0,f+=l,d++),s[p]={left:0,top:f,row:d,width:m,height:r},c[c.length-1]+=m+o}),u}_fitCols(e,t,n,r){let{ctx:i,maxHeight:a,options:{labels:{padding:o}}}=this,s=this.legendHitBoxes=[],c=this.columnSizes=[],l=a-e,u=o,d=0,f=0,p=0,m=0;return this.legendItems.forEach((e,a)=>{let{itemWidth:h,itemHeight:g}=_u(n,t,i,e,r);a>0&&f+g+2*o>l&&(u+=d+o,c.push({width:d,height:f}),p+=d+o,m++,d=f=0),s[a]={left:p,top:f,col:m,width:h,height:g},d=Math.max(d,h),f+=g+o}),u+=d,c.push({width:d,height:f}),u}adjustHitBoxes(){if(!this.options.display)return;let e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:r},rtl:i}}=this,a=va(i,this.left,this.width);if(this.isHorizontal()){let i=0,o=br(n,this.left+r,this.right-this.lineWidths[i]);for(let s of t)i!==s.row&&(i=s.row,o=br(n,this.left+r,this.right-this.lineWidths[i])),s.top+=this.top+e+r,s.left=a.leftForLtr(a.x(o),s.width),o+=s.width+r}else{let i=0,o=br(n,this.top+e+r,this.bottom-this.columnSizes[i].height);for(let s of t)s.col!==i&&(i=s.col,o=br(n,this.top+e+r,this.bottom-this.columnSizes[i].height)),s.top=o,s.left+=this.left+r,s.left=a.leftForLtr(a.x(s.left),s.width),o+=s.height+r}}isHorizontal(){return this.options.position===`top`||this.options.position===`bottom`}draw(){if(this.options.display){let e=this.ctx;ei(e,this),this._draw(),ti(e)}}_draw(){let{options:e,columnSizes:t,lineWidths:n,ctx:r}=this,{align:i,labels:a}=e,o=Z.color,s=va(e.rtl,this.left,this.width),c=_i(a.font),{padding:l}=a,u=c.size,d=u/2,f;this.drawTitle(),r.textAlign=s.textAlign(`left`),r.textBaseline=`middle`,r.lineWidth=.5,r.font=c.string;let{boxWidth:p,boxHeight:m,itemHeight:h}=mu(a,u),g=function(e,t,n){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;r.save();let i=K(n.lineWidth,1);if(r.fillStyle=K(n.fillStyle,o),r.lineCap=K(n.lineCap,`butt`),r.lineDashOffset=K(n.lineDashOffset,0),r.lineJoin=K(n.lineJoin,`miter`),r.lineWidth=i,r.strokeStyle=K(n.strokeStyle,o),r.setLineDash(K(n.lineDash,[])),a.usePointStyle)Qr(r,{radius:m*Math.SQRT2/2,pointStyle:n.pointStyle,rotation:n.rotation,borderWidth:i},s.xPlus(e,p/2),t+d,a.pointStyleWidth&&p);else{let a=t+Math.max((u-m)/2,0),o=s.leftForLtr(e,p),c=hi(n.borderRadius);r.beginPath(),Object.values(c).some(e=>e!==0)?ci(r,{x:o,y:a,w:p,h:m,radius:c}):r.rect(o,a,p,m),r.fill(),i!==0&&r.stroke()}r.restore()},_=function(e,t,n){si(r,n.text,e,t+h/2,c,{strikethrough:n.hidden,textAlign:s.textAlign(n.textAlign)})},v=this.isHorizontal(),y=this._computeTitleHeight();f=v?{x:br(i,this.left+l,this.right-n[0]),y:this.top+l+y,line:0}:{x:this.left+l,y:br(i,this.top+y+l,this.bottom-t[0].height),line:0},ya(this.ctx,e.textDirection);let b=h+l;this.legendItems.forEach((o,u)=>{r.strokeStyle=o.fontColor,r.fillStyle=o.fontColor;let m=r.measureText(o.text).width,h=s.textAlign(o.textAlign||=a.textAlign),x=p+d+m,S=f.x,C=f.y;if(s.setWidth(this.width),v?u>0&&S+x+l>this.right&&(C=f.y+=b,f.line++,S=f.x=br(i,this.left+l,this.right-n[f.line])):u>0&&C+b>this.bottom&&(S=f.x=S+t[f.line].width+l,f.line++,C=f.y=br(i,this.top+y+l,this.bottom-t[f.line].height)),g(s.x(S),C,o),S=xr(h,S+p+d,v?S+x:this.right,e.rtl),_(s.x(S),C,o),v)f.x+=x+l;else if(typeof o.text!=`string`){let e=c.lineHeight;f.y+=bu(o,e)+l}else f.y+=b}),ba(this.ctx,e.textDirection)}drawTitle(){let e=this.options,t=e.title,n=_i(t.font),r=gi(t.padding);if(!t.display)return;let i=va(e.rtl,this.left,this.width),a=this.ctx,o=t.position,s=n.size/2,c=r.top+s,l,u=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),l=this.top+c,u=br(e.align,u,this.right-d);else{let t=this.columnSizes.reduce((e,t)=>Math.max(e,t.height),0);l=c+br(e.align,this.top,this.bottom-t-e.labels.padding-this._computeTitleHeight())}let f=br(o,u,u+d);a.textAlign=i.textAlign(yr(o)),a.textBaseline=`middle`,a.strokeStyle=t.color,a.fillStyle=t.color,a.font=n.string,si(a,t.text,f,l,n)}_computeTitleHeight(){let e=this.options.title,t=_i(e.font),n=gi(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,r,i;if(sr(e,this.left,this.right)&&sr(t,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ne.length>t.length?e:t)),t+n.size/2+r.measureText(i).width}function yu(e,t,n){let r=e;return typeof t.text!=`string`&&(r=bu(t,n)),r}function bu(e,t){return t*(e.text?e.text.length:0)}function xu(e,t){return!!((e===`mousemove`||e===`mouseout`)&&(t.onHover||t.onLeave)||t.onClick&&(e===`click`||e===`mouseup`))}var Su={id:`legend`,_element:gu,start(e,t,n){let r=e.legend=new gu({ctx:e.ctx,options:n,chart:e});as.configure(e,r,n),as.addBox(e,r)},stop(e){as.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;as.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:`top`,align:`center`,fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:a,useBorderRadius:o,borderRadius:s}}=e.legend.options;return e._getSortedDatasetMetas().map(e=>{let c=e.controller.getStyle(n?0:void 0),l=gi(c.borderWidth);return{text:t[e.index].label,fillStyle:c.backgroundColor,fontColor:a,hidden:!e.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(l.width+l.height)/4,strokeStyle:c.borderColor,pointStyle:r||c.pointStyle,rotation:c.rotation,textAlign:i||c.textAlign,borderRadius:o&&(s||c.borderRadius),datasetIndex:e.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:`center`,text:``}},descriptors:{_scriptable:e=>!e.startsWith(`on`),labels:{_scriptable:e=>![`generateLabels`,`filter`,`sort`].includes(e)}}},Cu=class extends ks{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){let n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;let r=W(n.text)?n.text.length:1;this._padding=gi(n.padding);let i=r*_i(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=i:this.width=i}isHorizontal(){let e=this.options.position;return e===`top`||e===`bottom`}_drawArgs(e){let{top:t,left:n,bottom:r,right:i,options:a}=this,o=a.align,s=0,c,l,u;return this.isHorizontal()?(l=br(o,n,i),u=t+e,c=i-n):(a.position===`left`?(l=n+e,u=br(o,r,t),s=Y*-.5):(l=i-e,u=br(o,t,r),s=Y*.5),c=r-t),{titleX:l,titleY:u,maxWidth:c,rotation:s}}draw(){let e=this.ctx,t=this.options;if(!t.display)return;let n=_i(t.font),r=n.lineHeight/2+this._padding.top,{titleX:i,titleY:a,maxWidth:o,rotation:s}=this._drawArgs(r);si(e,t.text,0,0,n,{color:t.color,maxWidth:o,rotation:s,textAlign:yr(t.align),textBaseline:`middle`,translation:[i,a]})}};function wu(e,t){let n=new Cu({ctx:e.ctx,options:t,chart:e});as.configure(e,n,t),as.addBox(e,n),e.titleBlock=n}var Tu={id:`title`,_element:Cu,start(e,t,n){wu(e,n)},stop(e){let t=e.titleBlock;as.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;as.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`bold`},fullSize:!0,padding:10,position:`top`,text:``,weight:2e3},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},Eu=new WeakMap,Du={id:`subtitle`,start(e,t,n){let r=new Cu({ctx:e.ctx,options:n,chart:e});as.configure(e,r,n),as.addBox(e,r),Eu.set(e,r)},stop(e){as.removeBox(e,Eu.get(e)),Eu.delete(e)},beforeUpdate(e,t,n){let r=Eu.get(e);as.configure(e,r,n),r.options=n},defaults:{align:`center`,display:!1,font:{weight:`normal`},fullSize:!0,padding:0,position:`top`,text:``,weight:1500},defaultRoutes:{color:`color`},descriptors:{_scriptable:!0,_indexable:!1}},Ou={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,a=0;for(t=0,n=e.length;te+t)/r.size,y:i/a}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=1/0,a,o,s;for(a=0,o=e.length;a-1?e.split(` +`):e}function ju(e,t){let{element:n,datasetIndex:r,index:i}=t,a=e.getDatasetMeta(r).controller,{label:o,value:s}=a.getLabelAndValue(i);return{chart:e,label:o,parsed:a.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:s,dataset:a.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function Mu(e,t){let n=e.chart.ctx,{body:r,footer:i,title:a}=e,{boxWidth:o,boxHeight:s}=t,c=_i(t.bodyFont),l=_i(t.titleFont),u=_i(t.footerFont),d=a.length,f=i.length,p=r.length,m=gi(t.padding),h=m.height,g=0,_=r.reduce((e,t)=>e+t.before.length+t.lines.length+t.after.length,0);if(_+=e.beforeBody.length+e.afterBody.length,d&&(h+=d*l.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),_){let e=t.displayColors?Math.max(s,c.lineHeight):c.lineHeight;h+=p*e+(_-p)*c.lineHeight+(_-1)*t.bodySpacing}f&&(h+=t.footerMarginTop+f*u.lineHeight+(f-1)*t.footerSpacing);let v=0,y=function(e){g=Math.max(g,n.measureText(e).width+v)};return n.save(),n.font=l.string,J(e.title,y),n.font=c.string,J(e.beforeBody.concat(e.afterBody),y),v=t.displayColors?o+2+t.boxPadding:0,J(r,e=>{J(e.before,y),J(e.lines,y),J(e.after,y)}),v=0,n.font=u.string,J(e.footer,y),n.restore(),g+=m.width,{width:g,height:h}}function Nu(e,t){let{y:n,height:r}=t;return ne.height-r/2?`bottom`:`center`}function Pu(e,t,n,r){let{x:i,width:a}=r,o=n.caretSize+n.caretPadding;if(e===`left`&&i+a+o>t.width||e===`right`&&i-a-o<0)return!0}function Fu(e,t,n,r){let{x:i,width:a}=n,{width:o,chartArea:{left:s,right:c}}=e,l=`center`;return r===`center`?l=i<=(s+c)/2?`left`:`right`:i<=a/2?l=`left`:i>=o-a/2&&(l=`right`),Pu(l,e,t,n)&&(l=`center`),l}function Iu(e,t,n){let r=n.yAlign||t.yAlign||Nu(e,n);return{xAlign:n.xAlign||t.xAlign||Fu(e,t,n,r),yAlign:r}}function Lu(e,t){let{x:n,width:r}=e;return t===`right`?n-=r:t===`center`&&(n-=r/2),n}function Ru(e,t,n){let{y:r,height:i}=e;return t===`top`?r+=n:t===`bottom`?r-=i+n:r-=i/2,r}function zu(e,t,n,r){let{caretSize:i,caretPadding:a,cornerRadius:o}=e,{xAlign:s,yAlign:c}=n,l=i+a,{topLeft:u,topRight:d,bottomLeft:f,bottomRight:p}=hi(o),m=Lu(t,s),h=Ru(t,c,l);return c===`center`?s===`left`?m+=l:s===`right`&&(m-=l):s===`left`?m-=Math.max(u,f)+i:s===`right`&&(m+=Math.max(d,p)+i),{x:ar(m,0,r.width-t.width),y:ar(h,0,r.height-t.height)}}function Bu(e,t,n){let r=gi(n.padding);return t===`center`?e.x+e.width/2:t===`right`?e.x+e.width-r.right:e.x+r.left}function Vu(e){return ku([],Au(e))}function Hu(e,t,n){return bi(e,{tooltip:t,tooltipItems:n,type:`tooltip`})}function Uu(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var Wu={beforeTitle:H,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode===`dataset`)return t.dataset.label||``;if(t.label)return t.label;if(r>0&&t.dataIndex{let t={before:[],lines:[],after:[]},i=Uu(n,e);ku(t.before,Au(Gu(i,`beforeLabel`,this,e))),ku(t.lines,Gu(i,`label`,this,e)),ku(t.after,Au(Gu(i,`afterLabel`,this,e))),r.push(t)}),r}getAfterBody(e,t){return Vu(Gu(t.callbacks,`afterBody`,this,e))}getFooter(e,t){let{callbacks:n}=t,r=Gu(n,`beforeFooter`,this,e),i=Gu(n,`footer`,this,e),a=Gu(n,`afterFooter`,this,e),o=[];return o=ku(o,Au(r)),o=ku(o,Au(i)),o=ku(o,Au(a)),o}_createItems(e){let t=this._active,n=this.chart.data,r=[],i=[],a=[],o=[],s,c;for(s=0,c=t.length;se.filter(t,r,i,n))),e.itemSort&&(o=o.sort((t,r)=>e.itemSort(t,r,n))),J(o,t=>{let n=Uu(e.callbacks,t);r.push(Gu(n,`labelColor`,this,t)),i.push(Gu(n,`labelPointStyle`,this,t)),a.push(Gu(n,`labelTextColor`,this,t))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=a,this.dataPoints=o,o}update(e,t){let n=this.options.setContext(this.getContext()),r=this._active,i,a=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{let e=Ou[n.position].call(this,r,this._eventPosition);a=this._createItems(n),this.title=this.getTitle(a,n),this.beforeBody=this.getBeforeBody(a,n),this.body=this.getBody(a,n),this.afterBody=this.getAfterBody(a,n),this.footer=this.getFooter(a,n);let t=this._size=Mu(this,n),o=Object.assign({},e,t),s=Iu(this.chart,n,o),c=zu(n,o,s,this.chart);this.xAlign=s.xAlign,this.yAlign=s.yAlign,i={opacity:1,x:c.x,y:c.y,width:t.width,height:t.height,caretX:e.x,caretY:e.y}}this._tooltipItems=a,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:t})}drawCaret(e,t,n,r){let i=this.getCaretPosition(e,n,r);t.lineTo(i.x1,i.y1),t.lineTo(i.x2,i.y2),t.lineTo(i.x3,i.y3)}getCaretPosition(e,t,n){let{xAlign:r,yAlign:i}=this,{caretSize:a,cornerRadius:o}=n,{topLeft:s,topRight:c,bottomLeft:l,bottomRight:u}=hi(o),{x:d,y:f}=e,{width:p,height:m}=t,h,g,_,v,y,b;return i===`center`?(y=f+m/2,r===`left`?(h=d,g=h-a,v=y+a,b=y-a):(h=d+p,g=h+a,v=y-a,b=y+a),_=h):(g=r===`left`?d+Math.max(s,l)+a:r===`right`?d+p-Math.max(c,u)-a:this.caretX,i===`top`?(v=f,y=v-a,h=g-a,_=g+a):(v=f+m,y=v+a,h=g+a,_=g-a),b=v),{x1:h,x2:g,x3:_,y1:v,y2:y,y3:b}}drawTitle(e,t,n){let r=this.title,i=r.length,a,o,s;if(i){let c=va(n.rtl,this.x,this.width);for(e.x=Bu(this,n.titleAlign,n),t.textAlign=c.textAlign(n.titleAlign),t.textBaseline=`middle`,a=_i(n.titleFont),o=n.titleSpacing,t.fillStyle=n.titleColor,t.font=a.string,s=0;se!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,ci(e,{x:t,y:p,w:c,h:s,radius:o}),e.fill(),e.stroke(),e.fillStyle=a.backgroundColor,e.beginPath(),ci(e,{x:n,y:p+1,w:c-2,h:s-2,radius:o}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(t,p,c,s),e.strokeRect(t,p,c,s),e.fillStyle=a.backgroundColor,e.fillRect(n,p+1,c-2,s-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,t,n){let{body:r}=this,{bodySpacing:i,bodyAlign:a,displayColors:o,boxHeight:s,boxWidth:c,boxPadding:l}=n,u=_i(n.bodyFont),d=u.lineHeight,f=0,p=va(n.rtl,this.x,this.width),m=function(n){t.fillText(n,p.x(e.x+f),e.y+d/2),e.y+=d+i},h=p.textAlign(a),g,_,v,y,b,x,S;for(t.textAlign=a,t.textBaseline=`middle`,t.font=u.string,e.x=Bu(this,h,n),t.fillStyle=n.bodyColor,J(this.beforeBody,m),f=o&&h!==`right`?a===`center`?c/2+l:c+2+l:0,y=0,x=r.length;y0&&t.stroke()}_updateAnimationTarget(e){let t=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){let n=Ou[e.position].call(this,this._active,this._eventPosition);if(!n)return;let a=this._size=Mu(this,e),o=Object.assign({},n,this._size),s=Iu(t,e,o),c=zu(e,o,s,t);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=s.xAlign,this.yAlign=s.yAlign,this.width=a.width,this.height=a.height,this.caretX=n.x,this.caretY=n.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){let t=this.options.setContext(this.getContext()),n=this.opacity;if(!n)return;this._updateAnimationTarget(t);let r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;let a=gi(t.padding),o=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;t.enabled&&o&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,t),ya(e,t.textDirection),i.y+=a.top,this.drawTitle(i,e,t),this.drawBody(i,e,t),this.drawFooter(i,e,t),ba(e,t.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,t){let n=this._active,r=e.map(({datasetIndex:e,index:t})=>{let n=this.chart.getDatasetMeta(e);if(!n)throw Error(`Cannot find a dataset at index `+e);return{datasetIndex:e,element:n.data[t],index:t}}),i=!bn(n,r),a=this._positionChanged(r,t);(i||a)&&(this._active=r,this._eventPosition=t,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,t,n=!0){if(t&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let r=this.options,i=this._active||[],a=this._getActiveElements(e,i,t,n),o=this._positionChanged(a,e),s=t||!bn(a,i)||o;return s&&(this._active=a,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,t))),s}_getActiveElements(e,t,n,r){let i=this.options;if(e.type===`mouseout`)return[];if(!r)return t.filter(e=>this.chart.data.datasets[e.datasetIndex]&&this.chart.getDatasetMeta(e.datasetIndex).controller.getParsed(e.index)!==void 0);let a=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&a.reverse(),a}_positionChanged(e,t){let{caretX:n,caretY:r,options:i}=this,a=Ou[i.position].call(this,e,t);return a!==!1&&(n!==a.x||r!==a.y)}},qu=Object.freeze({__proto__:null,Colors:Al,Decimation:Il,Filler:pu,Legend:Su,SubTitle:Du,Title:Tu,Tooltip:{id:`tooltip`,_element:Ku,positioners:Ou,afterInit(e,t,n){n&&(e.tooltip=new Ku({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins(`beforeTooltipDraw`,{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins(`afterTooltipDraw`,n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:`average`,backgroundColor:`rgba(0,0,0,0.8)`,titleColor:`#fff`,titleFont:{weight:`bold`},titleSpacing:2,titleMarginBottom:6,titleAlign:`left`,bodyColor:`#fff`,bodySpacing:2,bodyFont:{},bodyAlign:`left`,footerColor:`#fff`,footerSpacing:2,footerMarginTop:6,footerFont:{weight:`bold`},footerAlign:`left`,padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:`#fff`,displayColors:!0,boxPadding:0,borderColor:`rgba(0,0,0,0)`,borderWidth:0,animation:{duration:400,easing:`easeOutQuart`},animations:{numbers:{type:`number`,properties:[`x`,`y`,`width`,`height`,`caretX`,`caretY`]},opacity:{easing:`linear`,duration:200}},callbacks:Wu},defaultRoutes:{bodyFont:`font`,footerFont:`font`,titleFont:`font`},descriptors:{_scriptable:e=>e!==`filter`&&e!==`itemSort`&&e!==`external`,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:`animation`}},additionalOptionScopes:[`interaction`]}}),Ju=(e,t,n,r)=>(typeof t==`string`?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Yu(e,t,n,r){let i=e.indexOf(t);return i===-1?Ju(e,t,n,r):i===e.lastIndexOf(t)?i:n}var Xu=(e,t)=>e===null?null:ar(Math.round(e),0,t);function Zu(e){let t=this.getLabels();return e>=0&&et.length-1?null:this.getPixelForValue(t[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}};function $u(e,t){let n=[],{bounds:r,step:i,min:a,max:o,precision:s,count:c,maxTicks:l,maxDigits:u,includeBounds:d}=e,f=i||1,p=l-1,{min:m,max:h}=t,g=!U(a),_=!U(o),v=!U(c),y=(h-m)/(u+1),b=Gn((h-m)/p/f)*f,x,S,C,w;if(b<1e-14&&!g&&!_)return[{value:m},{value:h}];w=Math.ceil(h/b)-Math.floor(m/b),w>p&&(b=Gn(w*b/p/f)*f),U(s)||(x=10**s,b=Math.ceil(b*x)/x),r===`ticks`?(S=Math.floor(m/b)*b,C=Math.ceil(h/b)*b):(S=m,C=h),g&&_&&i&&Yn((o-a)/i,b/1e3)?(w=Math.round(Math.min((o-a)/b,l)),b=(o-a)/w,S=a,C=o):v?(S=g?a:S,C=_?o:C,w=c-1,b=(C-S)/w):(w=(C-S)/b,w=Wn(w,Math.round(w),b/1e3)?Math.round(w):Math.ceil(w));let T=Math.max($n(b),$n(S));x=10**(U(s)?T:s),S=Math.round(S*x)/x,C=Math.round(C*x)/x;let E=0;for(g&&(d&&S!==a?(n.push({value:a}),So)break;n.push({value:e})}return _&&d&&C!==o?n.length&&Wn(n[n.length-1].value,o,ed(o,y,e))?n[n.length-1].value=o:n.push({value:o}):(!_||C===o)&&n.push({value:C}),n}function ed(e,t,{horizontal:n,minRotation:r}){let i=Zn(r),a=(n?Math.sin(i):Math.cos(i))||.001,o=.75*t*(``+e).length;return Math.min(t/a,o)}var td=class extends Ys{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,t){return U(e)||(typeof e==`number`||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){let{beginAtZero:e}=this.options,{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this,a=e=>r=t?r:e,o=e=>i=n?i:e;if(e){let e=Un(r),t=Un(i);e<0&&t<0?o(0):e>0&&t>0&&a(0)}if(r===i){let t=i===0?1:Math.abs(i*.05);o(i+t),e||a(r-t)}this.min=r,this.max=i}getTickLimit(){let{maxTicksLimit:e,stepSize:t}=this.options.ticks,n;return t?(n=Math.ceil(this.max/t)-Math.floor(this.min/t)+1,n>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${t} would result generating up to ${n} ticks. Limiting to 1000.`),n=1e3)):(n=this.computeTickLimit(),e||=11),e&&(n=Math.min(e,n)),n}computeTickLimit(){return 1/0}buildTicks(){let e=this.options,t=e.ticks,n=this.getTickLimit();n=Math.max(2,n);let r=$u({maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:t.precision,step:t.stepSize,count:t.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:t.minRotation||0,includeBounds:t.includeBounds!==!1},this._range||this);return e.bounds===`ticks`&&Xn(r,this,`value`),e.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){let e=this.ticks,t=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){let r=(n-t)/Math.max(e.length-1,1)/2;t-=r,n+=r}this._startValue=t,this._endValue=n,this._valueRange=n-t}getLabelForValue(e){return Lr(e,this.chart.options.locale,this.options.ticks.format)}},nd=class extends td{static id=`linear`;static defaults={ticks:{callback:Br.formatters.numeric}};determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=gn(e)?e:0,this.max=gn(t)?t:1,this.handleTickRangeOptions()}computeTickLimit(){let e=this.isHorizontal(),t=e?this.width:this.height,n=Zn(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(t/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}},rd=e=>Math.floor(Hn(e)),id=(e,t)=>10**(rd(e)+t);function ad(e){return e/10**rd(e)==1}function od(e,t,n){let r=10**n,i=Math.floor(e/r);return Math.ceil(t/r)-i}function sd(e,t){let n=rd(t-e);for(;od(e,t,n)>10;)n++;for(;od(e,t,n)<10;)n--;return Math.min(n,rd(e))}function cd(e,{min:t,max:n}){t=_n(e.min,t);let r=[],i=rd(t),a=sd(t,n),o=a<0?10**Math.abs(a):1,s=10**a,c=i>a?10**i:0,l=Math.round((t-c)*o)/o,u=Math.floor((t-c)/s/10)*s*10,d=Math.floor((l-u)/10**a),f=_n(e.min,Math.round((c+u+d*10**a)*o)/o);for(;f=10?d=d<15?15:20:d++,d>=20&&(a++,d=2,o=a>=0?1:o),f=Math.round((c+u+d*10**a)*o)/o;let p=_n(e.max,f);return r.push({value:p,major:ad(p),significand:d}),r}var ld=class extends Ys{static id=`logarithmic`;static defaults={ticks:{callback:Br.formatters.logarithmic,major:{enabled:!0}}};constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,t){let n=td.prototype.parse.apply(this,[e,t]);if(n===0){this._zero=!0;return}return gn(n)&&n>0?n:null}determineDataLimits(){let{min:e,max:t}=this.getMinMax(!0);this.min=gn(e)?Math.max(0,e):null,this.max=gn(t)?Math.max(0,t):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!gn(this._userMin)&&(this.min=e===id(this.min,0)?id(this.min,-1):id(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:e,maxDefined:t}=this.getUserBounds(),n=this.min,r=this.max,i=t=>n=e?n:t,a=e=>r=t?r:e;n===r&&(n<=0?(i(1),a(10)):(i(id(n,-1)),a(id(r,1)))),n<=0&&i(id(r,-1)),r<=0&&a(id(n,1)),this.min=n,this.max=r}buildTicks(){let e=this.options,t=cd({min:this._userMin,max:this._userMax},this);return e.bounds===`ticks`&&Xn(t,this,`value`),e.reverse?(t.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),t}getLabelForValue(e){return e===void 0?`0`:Lr(e,this.chart.options.locale,this.options.ticks.format)}configure(){let e=this.min;super.configure(),this._startValue=Hn(e),this._valueRange=Hn(this.max)-Hn(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(Hn(e)-this._startValue)/this._valueRange)}getValueForPixel(e){let t=this.getDecimalForPixel(e);return 10**(this._startValue+t*this._valueRange)}};function ud(e){let t=e.ticks;if(t.display&&e.display){let e=gi(t.backdropPadding);return K(t.font&&t.font.size,Z.font.size)+e.height}return 0}function dd(e,t,n){return n=W(n)?n:[n],{w:Jr(e,t.string,n),h:n.length*t.lineHeight}}function fd(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:ei?{start:t-n,end:t}:{start:t,end:t+n}}function pd(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],a=e._pointLabels.length,o=e.options.pointLabels,s=o.centerPointLabels?Y/a:0;for(let c=0;ct.r&&(s=(r.end-t.r)/a,e.r=Math.max(e.r,t.r+s)),i.startt.b&&(c=(i.end-t.b)/o,e.b=Math.max(e.b,t.b+c))}function hd(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:a,padding:o,size:s}=n,c=e.getPointPosition(t,r+i+o,a),l=Math.round(Qn(rr(c.angle+zn))),u=bd(c.y,s.h,l),d=vd(l),f=yd(c.x,s.w,d);return{visible:!0,x:c.x,y:u,textAlign:d,left:f,top:u,right:f+s.w,bottom:u+s.h}}function gd(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:a}=e;return!($r({x:n,y:r},t)||$r({x:n,y:a},t)||$r({x:i,y:r},t)||$r({x:i,y:a},t))}function _d(e,t,n){let r=[],i=e._pointLabels.length,a=e.options,{centerPointLabels:o,display:s}=a.pointLabels,c={extra:ud(a)/2,additionalAngle:o?Y/i:0},l;for(let a=0;a270||n<90)&&(e-=t),e}function xd(e,t,n){let{left:r,top:i,right:a,bottom:o}=n,{backdropColor:s}=t;if(!U(s)){let n=hi(t.borderRadius),c=gi(t.backdropPadding);e.fillStyle=s;let l=r-c.left,u=i-c.top,d=a-r+c.width,f=o-i+c.height;Object.values(n).some(e=>e!==0)?(e.beginPath(),ci(e,{x:l,y:u,w:d,h:f,radius:n}),e.fill()):e.fillRect(l,u,d,f)}}function Sd(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let t=e._pointLabelItems[i];if(!t.visible)continue;let a=r.setContext(e.getPointLabelContext(i));xd(n,a,t);let o=_i(a.font),{x:s,y:c,textAlign:l}=t;si(n,e._pointLabels[i],s,c+o.lineHeight/2,o,{color:a.color,textAlign:l,textBaseline:`middle`})}}function Cd(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,X);else{let n=e.getPointPosition(0,t);i.moveTo(n.x,n.y);for(let a=1;a{let n=q(this.options.pointLabels.callback,[e,t],this);return n||n===0?n:``}).filter((e,t)=>this.chart.getDataVisibility(t))}fit(){let e=this.options;e.display&&e.pointLabels.display?pd(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,t,n,r){this.xCenter+=Math.floor((e-t)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,t,n,r))}getIndexAngle(e){let t=X/(this._pointLabels.length||1),n=this.options.startAngle||0;return rr(e*t+Zn(n))}getDistanceFromCenterForValue(e){if(U(e))return NaN;let t=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*t:(e-this.min)*t}getValueForDistanceFromCenter(e){if(U(e))return NaN;let t=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-t:this.min+t}getPointLabelContext(e){let t=this._pointLabels||[];if(e>=0&&e{if(t!==0||t===0&&this.min<0){s=this.getDistanceFromCenterForValue(e.value);let n=this.getContext(t),o=r.setContext(n),c=i.setContext(n);wd(this,o,s,a,c)}}),n.display){for(e.save(),o=a-1;o>=0;o--){let r=n.setContext(this.getPointLabelContext(o)),{color:i,lineWidth:a}=r;!a||!i||(e.lineWidth=a,e.strokeStyle=i,e.setLineDash(r.borderDash),e.lineDashOffset=r.borderDashOffset,s=this.getDistanceFromCenterForValue(t.reverse?this.min:this.max),c=this.getPointPosition(o,s),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(c.x,c.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){let e=this.ctx,t=this.options,n=t.ticks;if(!n.display)return;let r=this.getIndexAngle(0),i,a;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign=`center`,e.textBaseline=`middle`,this.ticks.forEach((r,o)=>{if(o===0&&this.min>=0&&!t.reverse)return;let s=n.setContext(this.getContext(o)),c=_i(s.font);if(i=this.getDistanceFromCenterForValue(this.ticks[o].value),s.showLabelBackdrop){e.font=c.string,a=e.measureText(r.label).width,e.fillStyle=s.backdropColor;let t=gi(s.backdropPadding);e.fillRect(-a/2-t.left,-i-c.size/2-t.top,a+t.width,c.size+t.height)}si(e,r.label,0,-i,c,{color:s.color,strokeColor:s.textStrokeColor,strokeWidth:s.textStrokeWidth})}),e.restore()}drawTitle(){}},Dd={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Od=Object.keys(Dd);function kd(e,t){return e-t}function Ad(e,t){if(U(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:a}=e._parseOpts,o=t;return typeof r==`function`&&(o=r(o)),gn(o)||(o=typeof r==`string`?n.parse(o,r):n.parse(o)),o===null?null:(i&&(o=i===`week`&&(Jn(a)||a===!0)?n.startOf(o,`isoWeek`,a):n.startOf(o,i)),+o)}function jd(e,t,n,r){let i=Od.length;for(let a=Od.indexOf(e);a=Od.indexOf(n);a--){let n=Od[a];if(Dd[n].common&&e._adapter.diff(i,r,n)>=t-1)return n}return Od[n?Od.indexOf(n):0]}function Nd(e){for(let t=Od.indexOf(e)+1,n=Od.length;t=t?n[r]:n[i];e[a]=!0}}function Fd(e,t,n,r){let i=e._adapter,a=+i.startOf(t[0].value,r),o=t[t.length-1].value,s,c;for(s=a;s<=o;s=+i.add(s,1,r))c=n[s],c>=0&&(t[c].major=!0);return t}function Id(e,t,n){let r=[],i={},a=t.length,o,s;for(o=0;o+e.value))}initOffsets(e=[]){let t=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),t=e.length===1?1-r:(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),n=e.length===1?i:(i-this.getDecimalForValue(e[e.length-2]))/2);let a=e.length<3?.5:.25;t=ar(t,0,a),n=ar(n,0,a),this._offsets={start:t,end:n,factor:1/(t+1+n)}}_generate(){let e=this._adapter,t=this.min,n=this.max,r=this.options,i=r.time,a=i.unit||jd(i.minUnit,t,n,this._getLabelCapacity(t)),o=K(r.ticks.stepSize,1),s=a===`week`?i.isoWeekday:!1,c=Jn(s)||s===!0,l={},u=t,d,f;if(c&&(u=+e.startOf(u,`isoWeek`,s)),u=+e.startOf(u,c?`day`:a),e.diff(n,t,a)>1e5*o)throw Error(t+` and `+n+` are too far apart with stepSize of `+o+` `+a);let p=r.ticks.source===`data`&&this.getDataTimestamps();for(d=u,f=0;d+e)}getLabelForValue(e){let t=this._adapter,n=this.options.time;return n.tooltipFormat?t.format(e,n.tooltipFormat):t.format(e,n.displayFormats.datetime)}format(e,t){let n=this.options.time.displayFormats,r=this._unit,i=t||n[r];return this._adapter.format(e,i)}_tickFormatFunction(e,t,n,r){let i=this.options,a=i.ticks.callback;if(a)return q(a,[e,t,n],this);let o=i.time.displayFormats,s=this._unit,c=this._majorUnit,l=s&&o[s],u=c&&o[c],d=n[t],f=c&&u&&d&&d.major;return this._adapter.format(e,r||(f?u:l))}generateTickLabels(e){let t,n,r;for(t=0,n=e.length;t0?o:1}getDataTimestamps(){let e=this._cache.data||[],t,n;if(e.length)return e;let r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(t=0,n=r.length;t=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=lr(e,`pos`,t)),{pos:a,time:s}=e[r],{pos:o,time:c}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=lr(e,`time`,t)),{time:a,pos:s}=e[r],{time:o,pos:c}=e[i]);let l=o-a;return l?s+(c-s)*(t-a)/l:s}var zd=class extends Ld{static id=`timeseries`;static defaults=Ld.defaults;constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let e=this._getTimestampsForTable(),t=this._table=this.buildLookupTable(e);this._minPos=Rd(t,this.min),this._tableRange=Rd(t,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){let{min:t,max:n}=this,r=[],i=[],a,o,s,c,l;for(a=0,o=e.length;a=t&&c<=n&&r.push(c);if(r.length<2)return[{time:t,pos:0},{time:n,pos:1}];for(a=0,o=r.length;ae-t)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;let t=this.getDataTimestamps(),n=this.getLabelTimestamps();return e=t.length&&n.length?this.normalize(t.concat(n)):t.length?t:n,e=this._cache.all=e,e}getDecimalForValue(e){return(Rd(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){let t=this._offsets,n=this.getDecimalForPixel(e)/t.factor-t.end;return Rd(this._table,n*this._tableRange+this._minPos,!0)}},Bd=[jo,vl,qu,Object.freeze({__proto__:null,CategoryScale:Qu,LinearScale:nd,LogarithmicScale:ld,RadialLinearScale:Ed,TimeScale:Ld,TimeSeriesScale:zd})];Lc.register(...Bd);var Vd=null;function Hd(e,t){let n=document.getElementById(e);if(!n)return;Vd&&Vd.destroy();let r=t*100,i=Array.from({length:8},(e,t)=>{let n=(Math.random()-.5)*8;return Math.max(5,Math.min(95,r-12+t/7*12+n))});i[i.length-1]=r,Vd=new Lc(n,{type:`line`,data:{labels:[`7d`,`6d`,`5d`,`4d`,`3d`,`2d`,`1d`,`now`],datasets:[{data:i,borderColor:r>50?`#22d37a`:r<40?`#f04040`:`#f0a020`,borderWidth:1.5,pointRadius:0,fill:!1,tension:.4}]},options:{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{display:!1},tooltip:{enabled:!1}},scales:{x:{display:!1},y:{display:!1}},animation:{duration:600}}})}function Ud(e,t,n){let r=document.getElementById(e);if(!r)return;r.innerHTML=``,r.className=`sparkline`;let i=t*100;for(let e=0;e<12;e++){let e=Math.max(4,Math.min(24,i/4+(Math.random()-.5)*8)),t=document.createElement(`div`);t.className=`spark-bar`,t.style.height=e+`px`,t.style.background=n===`yes`?`#0d6e3a`:`#7a1a1a`,r.appendChild(t)}let a=document.createElement(`div`);a.className=`spark-bar`,a.style.height=Math.min(28,i/3.5)+`px`,a.style.background=n===`yes`?`#22d37a`:`#f04040`,r.appendChild(a)}var Wd=l(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n.leaflet={}))})(e,(function(e){var t=`1.9.4`;function n(e){var t,n,r,i;for(n=1,r=arguments.length;n`u`||!L||!L.Mixin)){e=_(e)?e:[e];for(var t=0;t0?Math.floor(e):Math.ceil(e)};D.prototype={clone:function(){return new D(this.x,this.y)},add:function(e){return this.clone()._add(O(e))},_add:function(e){return this.x+=e.x,this.y+=e.y,this},subtract:function(e){return this.clone()._subtract(O(e))},_subtract:function(e){return this.x-=e.x,this.y-=e.y,this},divideBy:function(e){return this.clone()._divideBy(e)},_divideBy:function(e){return this.x/=e,this.y/=e,this},multiplyBy:function(e){return this.clone()._multiplyBy(e)},_multiplyBy:function(e){return this.x*=e,this.y*=e,this},scaleBy:function(e){return new D(this.x*e.x,this.y*e.y)},unscaleBy:function(e){return new D(this.x/e.x,this.y/e.y)},round:function(){return this.clone()._round()},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},floor:function(){return this.clone()._floor()},_floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.clone()._ceil()},_ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},trunc:function(){return this.clone()._trunc()},_trunc:function(){return this.x=ae(this.x),this.y=ae(this.y),this},distanceTo:function(e){e=O(e);var t=e.x-this.x,n=e.y-this.y;return Math.sqrt(t*t+n*n)},equals:function(e){return e=O(e),e.x===this.x&&e.y===this.y},contains:function(e){return e=O(e),Math.abs(e.x)<=Math.abs(this.x)&&Math.abs(e.y)<=Math.abs(this.y)},toString:function(){return`Point(`+u(this.x)+`, `+u(this.y)+`)`}};function O(e,t,n){return e instanceof D?e:_(e)?new D(e[0],e[1]):e==null?e:typeof e==`object`&&`x`in e&&`y`in e?new D(e.x,e.y):new D(e,t,n)}function k(e,t){if(e)for(var n=t?[e,t]:e,r=0,i=n.length;r=this.min.x&&n.x<=this.max.x&&t.y>=this.min.y&&n.y<=this.max.y},intersects:function(e){e=A(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>=t.x&&r.x<=n.x,o=i.y>=t.y&&r.y<=n.y;return a&&o},overlaps:function(e){e=A(e);var t=this.min,n=this.max,r=e.min,i=e.max,a=i.x>t.x&&r.xt.y&&r.y=t.lat&&i.lat<=n.lat&&r.lng>=t.lng&&i.lng<=n.lng},intersects:function(e){e=se(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>=t.lat&&r.lat<=n.lat,o=i.lng>=t.lng&&r.lng<=n.lng;return a&&o},overlaps:function(e){e=se(e);var t=this._southWest,n=this._northEast,r=e.getSouthWest(),i=e.getNorthEast(),a=i.lat>t.lat&&r.latt.lng&&r.lng1,Je=function(){var e=!1;try{var t=Object.defineProperty({},`passive`,{get:function(){e=!0}});window.addEventListener(`testPassiveEventSupport`,l,t),window.removeEventListener(`testPassiveEventSupport`,l,t)}catch{}return e}(),Ye=function(){return!!document.createElement(`canvas`).getContext}(),Xe=!!(document.createElementNS&&ge(`svg`).createSVGRect),Ze=!!Xe&&(function(){var e=document.createElement(`div`);return e.innerHTML=``,(e.firstChild&&e.firstChild.namespaceURI)===`http://www.w3.org/2000/svg`})(),Qe=!Xe&&function(){try{var e=document.createElement(`div`);e.innerHTML=``;var t=e.firstChild;return t.style.behavior=`url(#default#VML)`,t&&typeof t.adj==`object`}catch{return!1}}(),$e=navigator.platform.indexOf(`Mac`)===0,et=navigator.platform.indexOf(`Linux`)===0;function tt(e){return navigator.userAgent.toLowerCase().indexOf(e)>=0}var N={ie:ye,ielt9:be,edge:xe,webkit:Se,android:Ce,android23:we,androidStock:Ee,opera:De,chrome:Oe,gecko:ke,safari:Ae,phantom:je,opera12:Me,win:Ne,ie3d:Pe,webkit3d:Fe,gecko3d:Ie,any3d:Le,mobile:Re,mobileWebkit:ze,mobileWebkit3d:Be,msPointer:Ve,pointer:He,touch:We,touchNative:Ue,mobileOpera:Ge,mobileGecko:Ke,retina:qe,passiveEvents:Je,canvas:Ye,svg:Xe,vml:Qe,inlineSvg:Ze,mac:$e,linux:et},nt=N.msPointer?`MSPointerDown`:`pointerdown`,P=N.msPointer?`MSPointerMove`:`pointermove`,rt=N.msPointer?`MSPointerUp`:`pointerup`,it=N.msPointer?`MSPointerCancel`:`pointercancel`,at={touchstart:nt,touchmove:P,touchend:rt,touchcancel:it},ot={touchstart:gt,touchmove:ht,touchend:ht,touchcancel:ht},st={},ct=!1;function lt(e,t,n){return t===`touchstart`&&mt(),ot[t]?(n=ot[t].bind(this,n),e.addEventListener(at[t],n,!1),n):(console.warn(`wrong event specified:`,t),l)}function ut(e,t,n){if(!at[t]){console.warn(`wrong event specified:`,t);return}e.removeEventListener(at[t],n,!1)}function dt(e){st[e.pointerId]=e}function ft(e){st[e.pointerId]&&(st[e.pointerId]=e)}function pt(e){delete st[e.pointerId]}function mt(){ct||=(document.addEventListener(nt,dt,!0),document.addEventListener(P,ft,!0),document.addEventListener(rt,pt,!0),document.addEventListener(it,pt,!0),!0)}function ht(e,t){if(t.pointerType!==(t.MSPOINTER_TYPE_MOUSE||`mouse`)){for(var n in t.touches=[],st)t.touches.push(st[n]);t.changedTouches=[t],e(t)}}function gt(e,t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&on(t),ht(e,t)}function _t(e){var t={},n,r;for(r in e)n=e[r],t[r]=n&&n.bind?n.bind(e):n;return e=t,t.type=`dblclick`,t.detail=2,t.isTrusted=!1,t._simulated=!0,t}var vt=200;function yt(e,t){e.addEventListener(`dblclick`,t);var n=0,r;function i(e){if(e.detail!==1){r=e.detail;return}if(!(e.pointerType===`mouse`||e.sourceCapabilities&&!e.sourceCapabilities.firesTouchEvents)){var i=cn(e);if(!(i.some(function(e){return e instanceof HTMLLabelElement&&e.attributes.for})&&!i.some(function(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement}))){var a=Date.now();a-n<=vt?(r++,r===2&&t(_t(e))):r=1,n=a}}}return e.addEventListener(`click`,i),{dblclick:t,simDblclick:i}}function bt(e,t){e.removeEventListener(`dblclick`,t.dblclick),e.removeEventListener(`click`,t.simDblclick)}var xt=Pt([`transform`,`webkitTransform`,`OTransform`,`MozTransform`,`msTransform`]),St=Pt([`webkitTransition`,`transition`,`OTransition`,`MozTransition`,`msTransition`]),Ct=St===`webkitTransition`||St===`OTransition`?St+`End`:`transitionend`;function wt(e){return typeof e==`string`?document.getElementById(e):e}function Tt(e,t){var n=e.style[t]||e.currentStyle&&e.currentStyle[t];if((!n||n===`auto`)&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);n=r?r[t]:null}return n===`auto`?null:n}function F(e,t,n){var r=document.createElement(e);return r.className=t||``,n&&n.appendChild(r),r}function I(e){var t=e.parentNode;t&&t.removeChild(e)}function Et(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function Dt(e){var t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function Ot(e){var t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function kt(e,t){if(e.classList!==void 0)return e.classList.contains(t);var n=jt(e);return n.length>0&&RegExp(`(^|\\s)`+t+`(\\s|$)`).test(n)}function R(e,t){if(e.classList!==void 0)for(var n=f(t),r=0,i=n.length;r0?2*window.devicePixelRatio:1;function dn(e){return N.edge?e.wheelDeltaY/2:e.deltaY&&e.deltaMode===0?-e.deltaY/un:e.deltaY&&e.deltaMode===1?-e.deltaY*20:e.deltaY&&e.deltaMode===2?-e.deltaY*60:e.deltaX||e.deltaZ?0:e.wheelDelta?(e.wheelDeltaY||e.wheelDelta)/2:e.detail&&Math.abs(e.detail)<32765?-e.detail*20:e.detail?e.detail/-32765*60:0}function fn(e,t){var n=t.relatedTarget;if(!n)return!0;try{for(;n&&n!==e;)n=n.parentNode}catch{return!1}return n!==e}var pn={__proto__:null,on:B,off:V,stopPropagation:nn,disableScrollPropagation:rn,disableClickPropagation:an,preventDefault:on,stop:sn,getPropagationPath:cn,getMousePosition:ln,getWheelDelta:dn,isExternalTarget:fn,addListener:B,removeListener:V},mn=ie.extend({run:function(e,t,n,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=n||.25,this._easeOutPower=1/Math.max(r||.5,.2),this._startPos=Lt(e),this._offset=t.subtract(this._startPos),this._startTime=+new Date,this.fire(`start`),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=T(this._animate,this),this._step()},_step:function(e){var t=+new Date-this._startTime,n=this._duration*1e3;tthis.options.maxZoom)?this.setZoom(e):this},panInsideBounds:function(e,t){this._enforcingBounds=!0;var n=this.getCenter(),r=this._limitCenter(n,this._zoom,se(e));return n.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this},panInside:function(e,t){t||={};var n=O(t.paddingTopLeft||t.padding||[0,0]),r=O(t.paddingBottomRight||t.padding||[0,0]),i=this.project(this.getCenter()),a=this.project(e),o=this.getPixelBounds(),s=A([o.min.add(n),o.max.subtract(r)]),c=s.getSize();if(!s.contains(a)){this._enforcingBounds=!0;var l=a.subtract(s.getCenter()),u=s.extend(a).getSize().subtract(c);i.x+=l.x<0?-u.x:u.x,i.y+=l.y<0?-u.y:u.y,this.panTo(this.unproject(i),t),this._enforcingBounds=!1}return this},invalidateSize:function(e){if(!this._loaded)return this;e=n({animate:!1,pan:!0},e===!0?{animate:!0}:e);var t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),a=t.divideBy(2).round(),o=r.divideBy(2).round(),s=a.subtract(o);return!s.x&&!s.y?this:(e.animate&&e.pan?this.panBy(s):(e.pan&&this._rawPanBy(s),this.fire(`move`),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(i(this.fire,this,`moveend`),200)):this.fire(`moveend`)),this.fire(`resize`,{oldSize:t,newSize:r}))},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire(`viewreset`),this._stop()},locate:function(e){if(e=this._locateOptions=n({timeout:1e4,watch:!1},e),!(`geolocation`in navigator))return this._handleGeolocationError({code:0,message:`Geolocation not supported.`}),this;var t=i(this._handleGeolocationResponse,this),r=i(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,r,e):navigator.geolocation.getCurrentPosition(t,r,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){if(this._container._leaflet_id){var t=e.code,n=e.message||(t===1?`permission denied`:t===2?`position unavailable`:`timeout`);this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire(`locationerror`,{code:t,message:`Geolocation error: `+n+`.`})}},_handleGeolocationResponse:function(e){if(this._container._leaflet_id){var t=e.coords.latitude,n=e.coords.longitude,r=new j(t,n),i=r.toBounds(e.coords.accuracy*2),a=this._locateOptions;if(a.setView){var o=this.getBoundsZoom(i);this.setView(r,a.maxZoom?Math.min(o,a.maxZoom):o)}var s={latlng:r,bounds:i,timestamp:e.timestamp};for(var c in e.coords)typeof e.coords[c]==`number`&&(s[c]=e.coords[c]);this.fire(`locationfound`,s)}},addHandler:function(e,t){if(!t)return this;var n=this[e]=new t(this);return this._handlers.push(n),this.options[e]&&n.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off(`moveend`,this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw Error(`Map container is being reused by another instance`);try{delete this._container._leaflet_id,delete this._containerId}catch{this._container._leaflet_id=void 0,this._containerId=void 0}for(var e in this._locationWatchId!==void 0&&this.stopLocate(),this._stop(),I(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&=(E(this._resizeRequest),null),this._clearHandlers(),this._loaded&&this.fire(`unload`),this._layers)this._layers[e].remove();for(e in this._panes)I(this._panes[e]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,t){var n=F(`div`,`leaflet-pane`+(e?` leaflet-`+e.replace(`Pane`,``)+`-pane`:``),t||this._mapPane);return e&&(this._panes[e]=n),n},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var e=this.getPixelBounds();return new oe(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))},getMinZoom:function(){return this.options.minZoom===void 0?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return this.options.maxZoom===void 0?this._layersMaxZoom===void 0?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,n){e=se(e),n=O(n||[0,0]);var r=this.getZoom()||0,i=this.getMinZoom(),a=this.getMaxZoom(),o=e.getNorthWest(),s=e.getSouthEast(),c=this.getSize().subtract(n),l=A(this.project(s,r),this.project(o,r)).getSize(),u=N.any3d?this.options.zoomSnap:1,d=c.x/l.x,f=c.y/l.y,p=t?Math.max(d,f):Math.min(d,f);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(i,Math.min(a,r))},getSize:function(){return(!this._size||this._sizeChanged)&&(this._size=new D(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,t){var n=this._getTopLeftPoint(e,t);return new k(n,n.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(e){return this.options.crs.getProjectedBounds(e===void 0?this.getZoom():e)},getPane:function(e){return typeof e==`string`?this._panes[e]:e},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,t){var n=this.options.crs;return t=t===void 0?this._zoom:t,n.scale(e)/n.scale(t)},getScaleZoom:function(e,t){var n=this.options.crs;t=t===void 0?this._zoom:t;var r=n.zoom(e*n.scale(t));return isNaN(r)?1/0:r},project:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.latLngToPoint(M(e),t)},unproject:function(e,t){return t=t===void 0?this._zoom:t,this.options.crs.pointToLatLng(O(e),t)},layerPointToLatLng:function(e){var t=O(e).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(e){return this.project(M(e))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(e){return this.options.crs.wrapLatLng(M(e))},wrapLatLngBounds:function(e){return this.options.crs.wrapLatLngBounds(se(e))},distance:function(e,t){return this.options.crs.distance(M(e),M(t))},containerPointToLayerPoint:function(e){return O(e).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(e){return O(e).add(this._getMapPanePos())},containerPointToLatLng:function(e){var t=this.containerPointToLayerPoint(O(e));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(M(e)))},mouseEventToContainerPoint:function(e){return ln(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(e){var t=this._container=wt(e);if(!t)throw Error(`Map container not found.`);if(t._leaflet_id)throw Error(`Map container is already initialized.`);B(t,`scroll`,this._onScroll,this),this._containerId=o(t)},_initLayout:function(){var e=this._container;this._fadeAnimated=this.options.fadeAnimation&&N.any3d,R(e,`leaflet-container`+(N.touch?` leaflet-touch`:``)+(N.retina?` leaflet-retina`:``)+(N.ielt9?` leaflet-oldie`:``)+(N.safari?` leaflet-safari`:``)+(this._fadeAnimated?` leaflet-fade-anim`:``));var t=Tt(e,`position`);t!==`absolute`&&t!==`relative`&&t!==`fixed`&&t!==`sticky`&&(e.style.position=`relative`),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane(`mapPane`,this._container),It(this._mapPane,new D(0,0)),this.createPane(`tilePane`),this.createPane(`overlayPane`),this.createPane(`shadowPane`),this.createPane(`markerPane`),this.createPane(`tooltipPane`),this.createPane(`popupPane`),this.options.markerZoomAnimation||(R(e.markerPane,`leaflet-zoom-hide`),R(e.shadowPane,`leaflet-zoom-hide`))},_resetView:function(e,t,n){It(this._mapPane,new D(0,0));var r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire(`viewprereset`);var i=this._zoom!==t;this._moveStart(i,n)._move(e,t)._moveEnd(i),this.fire(`viewreset`),r&&this.fire(`load`)},_moveStart:function(e,t){return e&&this.fire(`zoomstart`),t||this.fire(`movestart`),this},_move:function(e,t,n,r){t===void 0&&(t=this._zoom);var i=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?n&&n.pinch&&this.fire(`zoom`,n):((i||n&&n.pinch)&&this.fire(`zoom`,n),this.fire(`move`,n)),this},_moveEnd:function(e){return e&&this.fire(`zoomend`),this.fire(`moveend`)},_stop:function(){return E(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(e){It(this._mapPane,this._getMapPanePos().subtract(e))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw Error(`Set map center and zoom first.`)},_initEvents:function(e){this._targets={},this._targets[o(this._container)]=this;var t=e?V:B;t(this._container,`click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup`,this._handleDOMEvent,this),this.options.trackResize&&t(window,`resize`,this._onResize,this),N.any3d&&this.options.transform3DLimit&&(e?this.off:this.on).call(this,`moveend`,this._onMoveEnd)},_onResize:function(){E(this._resizeRequest),this._resizeRequest=T(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,t){for(var n=[],r,i=t===`mouseout`||t===`mouseover`,a=e.target||e.srcElement,s=!1;a;){if(r=this._targets[o(a)],r&&(t===`click`||t===`preclick`)&&this._draggableMoved(r)){s=!0;break}if(r&&r.listens(t,!0)&&(i&&!fn(a,e)||(n.push(r),i))||a===this._container)break;a=a.parentNode}return!n.length&&!s&&!i&&this.listens(t,!0)&&(n=[this]),n},_isClickDisabled:function(e){for(;e&&e!==this._container;){if(e._leaflet_disable_click)return!0;e=e.parentNode}},_handleDOMEvent:function(e){var t=e.target||e.srcElement;if(!(!this._loaded||t._leaflet_disable_events||e.type===`click`&&this._isClickDisabled(t))){var n=e.type;n===`mousedown`&&Kt(t),this._fireDOMEvent(e,n)}},_mouseEvents:[`click`,`dblclick`,`mouseover`,`mouseout`,`contextmenu`],_fireDOMEvent:function(e,t,r){if(e.type===`click`){var i=n({},e);i.type=`preclick`,this._fireDOMEvent(i,i.type,r)}var a=this._findEventTargets(e,t);if(r){for(var o=[],s=0;s0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))},_limitZoom:function(e){var t=this.getMinZoom(),n=this.getMaxZoom(),r=N.any3d?this.options.zoomSnap:1;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(n,e))},_onPanTransitionStep:function(){this.fire(`move`)},_onPanTransitionEnd:function(){z(this._mapPane,`leaflet-pan-anim`),this.fire(`moveend`)},_tryAnimatedPan:function(e,t){var n=this._getCenterOffset(e)._trunc();return(t&&t.animate)!==!0&&!this.getSize().contains(n)?!1:(this.panBy(n,t),!0)},_createAnimProxy:function(){var e=this._proxy=F(`div`,`leaflet-proxy leaflet-zoom-animated`);this._panes.mapPane.appendChild(e),this.on(`zoomanim`,function(e){var t=xt,n=this._proxy.style[t];Ft(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),n===this._proxy.style[t]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on(`load moveend`,this._animMoveEnd,this),this._on(`unload`,this._destroyAnimProxy,this)},_destroyAnimProxy:function(){I(this._proxy),this.off(`load moveend`,this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var e=this.getCenter(),t=this.getZoom();Ft(this._proxy,this.project(e,t),this.getZoomScale(t,1))},_catchTransitionEnd:function(e){this._animatingZoom&&e.propertyName.indexOf(`transform`)>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName(`leaflet-zoom-animated`).length},_tryAnimatedZoom:function(e,t,n){if(this._animatingZoom)return!0;if(n||={},!this._zoomAnimated||n.animate===!1||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;var r=this.getZoomScale(t),i=this._getCenterOffset(e)._divideBy(1-1/r);return n.animate!==!0&&!this.getSize().contains(i)?!1:(T(function(){this._moveStart(!0,n.noMoveStart||!1)._animateZoom(e,t,!0)},this),!0)},_animateZoom:function(e,t,n,r){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,R(this._mapPane,`leaflet-zoom-anim`)),this.fire(`zoomanim`,{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||=this._zoom!==this._animateToZoom,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(i(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&z(this._mapPane,`leaflet-zoom-anim`),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire(`zoom`),delete this._tempFireZoomEvent,this.fire(`move`),this._moveEnd(!0))}});function hn(e,t){return new H(e,t)}var U=te.extend({options:{position:`topright`},initialize:function(e){p(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},getContainer:function(){return this._container},addTo:function(e){this.remove(),this._map=e;var t=this._container=this.onAdd(e),n=this.getPosition(),r=e._controlCorners[n];return R(t,`leaflet-control`),n.indexOf(`bottom`)===-1?r.appendChild(t):r.insertBefore(t,r.firstChild),this._map.on(`unload`,this.remove,this),this},remove:function(){return this._map?(I(this._container),this.onRemove&&this.onRemove(this._map),this._map.off(`unload`,this.remove,this),this._map=null,this):this},_refocusOnMap:function(e){this._map&&e&&e.screenX>0&&e.screenY>0&&this._map.getContainer().focus()}}),W=function(e){return new U(e)};H.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.remove(),this},_initControlPos:function(){var e=this._controlCorners={},t=`leaflet-`,n=this._controlContainer=F(`div`,t+`control-container`,this._container);function r(r,i){var a=t+r+` `+t+i;e[r+i]=F(`div`,a,n)}r(`top`,`left`),r(`top`,`right`),r(`bottom`,`left`),r(`bottom`,`right`)},_clearControlPos:function(){for(var e in this._controlCorners)I(this._controlCorners[e]);I(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var G=U.extend({options:{collapsed:!0,position:`topright`,autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(e,t,n,r){return n1,this._baseLayersList.style.display=e?``:`none`),this._separator.style.display=t&&e?``:`none`,this},_onLayerChange:function(e){this._handlingClick||this._update();var t=this._getLayer(o(e.target)),n=t.overlay?e.type===`add`?`overlayadd`:`overlayremove`:e.type===`add`?`baselayerchange`:null;n&&this._map.fire(n,t)},_createRadioElement:function(e,t){var n=``,r=document.createElement(`div`);return r.innerHTML=n,r.firstChild},_addItem:function(e){var t=document.createElement(`label`),n=this._map.hasLayer(e.layer),r;e.overlay?(r=document.createElement(`input`),r.type=`checkbox`,r.className=`leaflet-control-layers-selector`,r.defaultChecked=n):r=this._createRadioElement(`leaflet-base-layers_`+o(this),n),this._layerControlInputs.push(r),r.layerId=o(e.layer),B(r,`click`,this._onInputClick,this);var i=document.createElement(`span`);i.innerHTML=` `+e.name;var a=document.createElement(`span`);return t.appendChild(a),a.appendChild(r),a.appendChild(i),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(t),this._checkDisabledLayers(),t},_onInputClick:function(){if(!this._preventClick){var e=this._layerControlInputs,t,n,r=[],i=[];this._handlingClick=!0;for(var a=e.length-1;a>=0;a--)t=e[a],n=this._getLayer(t.layerId).layer,t.checked?r.push(n):t.checked||i.push(n);for(a=0;a=0;i--)t=e[i],n=this._getLayer(t.layerId).layer,t.disabled=n.options.minZoom!==void 0&&rn.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var e=this._section;this._preventClick=!0,B(e,`click`,on),this.expand();var t=this;setTimeout(function(){V(e,`click`,on),t._preventClick=!1})}}),gn=function(e,t,n){return new G(e,t,n)},_n=U.extend({options:{position:`topleft`,zoomInText:``,zoomInTitle:`Zoom in`,zoomOutText:``,zoomOutTitle:`Zoom out`},onAdd:function(e){var t=`leaflet-control-zoom`,n=F(`div`,t+` leaflet-bar`),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,r.zoomInTitle,t+`-in`,n,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,r.zoomOutTitle,t+`-out`,n,this._zoomOut),this._updateDisabled(),e.on(`zoomend zoomlevelschange`,this._updateDisabled,this),n},onRemove:function(e){e.off(`zoomend zoomlevelschange`,this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(e){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))},_createButton:function(e,t,n,r,i){var a=F(`a`,n,r);return a.innerHTML=e,a.href=`#`,a.title=t,a.setAttribute(`role`,`button`),a.setAttribute(`aria-label`,t),an(a),B(a,`click`,sn),B(a,`click`,i,this),B(a,`click`,this._refocusOnMap,this),a},_updateDisabled:function(){var e=this._map,t=`leaflet-disabled`;z(this._zoomInButton,t),z(this._zoomOutButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`false`),this._zoomOutButton.setAttribute(`aria-disabled`,`false`),(this._disabled||e._zoom===e.getMinZoom())&&(R(this._zoomOutButton,t),this._zoomOutButton.setAttribute(`aria-disabled`,`true`)),(this._disabled||e._zoom===e.getMaxZoom())&&(R(this._zoomInButton,t),this._zoomInButton.setAttribute(`aria-disabled`,`true`))}});H.mergeOptions({zoomControl:!0}),H.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new _n,this.addControl(this.zoomControl))});var K=function(e){return new _n(e)},vn=U.extend({options:{position:`bottomleft`,maxWidth:100,metric:!0,imperial:!0},onAdd:function(e){var t=`leaflet-control-scale`,n=F(`div`,t),r=this.options;return this._addScales(r,t+`-line`,n),e.on(r.updateWhenIdle?`moveend`:`move`,this._update,this),e.whenReady(this._update,this),n},onRemove:function(e){e.off(this.options.updateWhenIdle?`moveend`:`move`,this._update,this)},_addScales:function(e,t,n){e.metric&&(this._mScale=F(`div`,t,n)),e.imperial&&(this._iScale=F(`div`,t,n))},_update:function(){var e=this._map,t=e.getSize().y/2,n=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(n)},_updateScales:function(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)},_updateMetric:function(e){var t=this._getRoundNum(e),n=t<1e3?t+` m`:t/1e3+` km`;this._updateScale(this._mScale,n,t/e)},_updateImperial:function(e){var t=e*3.2808399,n,r,i;t>5280?(n=t/5280,r=this._getRoundNum(n),this._updateScale(this._iScale,r+` mi`,r/n)):(i=this._getRoundNum(t),this._updateScale(this._iScale,i+` ft`,i/t))},_updateScale:function(e,t,n){e.style.width=Math.round(this.options.maxWidth*n)+`px`,e.innerHTML=t},_getRoundNum:function(e){var t=10**((Math.floor(e)+``).length-1),n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:1,t*n}}),yn=function(e){return new vn(e)},q=U.extend({options:{position:`bottomright`,prefix:``+(N.inlineSvg?` `:``)+`Leaflet`},initialize:function(e){p(this,e),this._attributions={}},onAdd:function(e){for(var t in e.attributionControl=this,this._container=F(`div`,`leaflet-control-attribution`),an(this._container),e._layers)e._layers[t].getAttribution&&this.addAttribution(e._layers[t].getAttribution());return this._update(),e.on(`layeradd`,this._addAttribution,this),this._container},onRemove:function(e){e.off(`layeradd`,this._addAttribution,this)},_addAttribution:function(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once(`remove`,function(){this.removeAttribution(e.layer.getAttribution())},this))},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){return e?(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update(),this):this},removeAttribution:function(e){return e&&this._attributions[e]&&(this._attributions[e]--,this._update()),this},_update:function(){if(this._map){var e=[];for(var t in this._attributions)this._attributions[t]&&e.push(t);var n=[];this.options.prefix&&n.push(this.options.prefix),e.length&&n.push(e.join(`, `)),this._container.innerHTML=n.join(` `)}}});H.mergeOptions({attributionControl:!0}),H.addInitHook(function(){this.options.attributionControl&&new q().addTo(this)}),U.Layers=G,U.Zoom=_n,U.Scale=vn,U.Attribution=q,W.layers=gn,W.zoom=K,W.scale=yn,W.attribution=function(e){return new q(e)};var J=te.extend({initialize:function(e){this._map=e},enable:function(){return this._enabled?this:(this._enabled=!0,this.addHooks(),this)},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});J.addTo=function(e,t){return e.addHandler(t,this),this};var bn={Events:re},xn=N.touch?`touchstart mousedown`:`mousedown`,Sn=ie.extend({options:{clickTolerance:3},initialize:function(e,t,n,r){p(this,r),this._element=e,this._dragStartTarget=t||e,this._preventOutline=n},enable:function(){this._enabled||=(B(this._dragStartTarget,xn,this._onDown,this),!0)},disable:function(){this._enabled&&(Sn._dragging===this&&this.finishDrag(!0),V(this._dragStartTarget,xn,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(this._enabled&&(this._moved=!1,!kt(this._element,`leaflet-zoom-anim`))){if(e.touches&&e.touches.length!==1){Sn._dragging===this&&this.finishDrag();return}if(!(Sn._dragging||e.shiftKey||e.which!==1&&e.button!==1&&!e.touches)&&(Sn._dragging=this,this._preventOutline&&Kt(this._element),Ht(),Rt(),!this._moving)){this.fire(`down`);var t=e.touches?e.touches[0]:e,n=Jt(this._element);this._startPoint=new D(t.clientX,t.clientY),this._startPos=Lt(this._element),this._parentScale=Yt(n);var r=e.type===`mousedown`;B(document,r?`mousemove`:`touchmove`,this._onMove,this),B(document,r?`mouseup`:`touchend touchcancel`,this._onUp,this)}}},_onMove:function(e){if(this._enabled){if(e.touches&&e.touches.length>1){this._moved=!0;return}var t=e.touches&&e.touches.length===1?e.touches[0]:e,n=new D(t.clientX,t.clientY)._subtract(this._startPoint);!n.x&&!n.y||Math.abs(n.x)+Math.abs(n.y)a&&(o=s,a=c);a>n&&(t[o]=1,jn(e,t,n,r,o),jn(e,t,n,o,i))}function Mn(e,t){for(var n=[e[0]],r=1,i=0,a=e.length;rt&&(n.push(e[r]),i=r);return it.max.x&&(n|=2),e.yt.max.y&&(n|=8),n}function X(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function In(e,t,n,r){var i=t.x,a=t.y,o=n.x-i,s=n.y-a,c=o*o+s*s,l;return c>0&&(l=((e.x-i)*o+(e.y-a)*s)/c,l>1?(i=n.x,a=n.y):l>0&&(i+=o*l,a+=s*l)),o=e.x-i,s=e.y-a,r?o*o+s*s:new D(i,a)}function Ln(e){return!_(e[0])||typeof e[0][0]!=`object`&&e[0][0]!==void 0}function Rn(e){return console.warn(`Deprecated use of _flat, please use L.LineUtil.isFlat instead.`),Ln(e)}function zn(e,t){var n,r,i,a,o,s,c,l;if(!e||e.length===0)throw Error(`latlngs not passed`);Ln(e)||(console.warn(`latlngs are not flat! Only the first ring will be used`),e=e[0]);var u=M([0,0]),d=se(e);d.getNorthWest().distanceTo(d.getSouthWest())*d.getNorthEast().distanceTo(d.getNorthWest())<1700&&(u=Tn(e));var f=e.length,p=[];for(n=0;nr){c=(a-r)/i,l=[s.x-c*(s.x-o.x),s.y-c*(s.y-o.y)];break}var h=t.unproject(O(l));return M([h.lat+u.lat,h.lng+u.lng])}var Bn={__proto__:null,simplify:Dn,pointToSegmentDistance:On,closestPointOnSegment:kn,clipSegment:Pn,_getEdgeIntersection:Fn,_getBitCode:Y,_sqClosestPointOnSegment:In,isFlat:Ln,_flat:Rn,polylineCenter:zn},Vn={project:function(e){return new D(e.lng,e.lat)},unproject:function(e){return new j(e.y,e.x)},bounds:new k([-180,-90],[180,90])},Hn={R:6378137,R_MINOR:6356752.314245179,bounds:new k([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(e){var t=Math.PI/180,n=this.R,r=e.lat*t,i=this.R_MINOR/n,a=Math.sqrt(1-i*i),o=a*Math.sin(r),s=Math.tan(Math.PI/4-r/2)/((1-o)/(1+o))**(a/2);return r=-n*Math.log(Math.max(s,1e-10)),new D(e.lng*t*n,r)},unproject:function(e){for(var t=180/Math.PI,n=this.R,r=this.R_MINOR/n,i=Math.sqrt(1-r*r),a=Math.exp(-e.y/n),o=Math.PI/2-2*Math.atan(a),s=0,c=.1,l;s<15&&Math.abs(c)>1e-7;s++)l=i*Math.sin(o),l=((1-l)/(1+l))**(i/2),c=Math.PI/2-2*Math.atan(a*l)-o,o+=c;return new j(o*t,e.x*t/n)}},Un={__proto__:null,LonLat:Vn,Mercator:Hn,SphericalMercator:de},Wn=n({},le,{code:`EPSG:3395`,projection:Hn,transformation:function(){var e=.5/(Math.PI*Hn.R);return pe(e,.5,-e,.5)}()}),Gn=n({},le,{code:`EPSG:4326`,projection:Vn,transformation:pe(1/180,1,-1/180,.5)}),Kn=n({},ce,{projection:Vn,transformation:pe(1,0,-1,0),scale:function(e){return 2**e},zoom:function(e){return Math.log(e)/Math.LN2},distance:function(e,t){var n=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(n*n+r*r)},infinite:!0});ce.Earth=le,ce.EPSG3395=Wn,ce.EPSG3857=me,ce.EPSG900913=he,ce.EPSG4326=Gn,ce.Simple=Kn;var qn=ie.extend({options:{pane:`overlayPane`,attribution:null,bubblingMouseEvents:!0},addTo:function(e){return e.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(e){return e&&e.removeLayer(this),this},getPane:function(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)},addInteractiveTarget:function(e){return this._map._targets[o(e)]=this,this},removeInteractiveTarget:function(e){return delete this._map._targets[o(e)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){var n=this.getEvents();t.on(n,this),this.once(`remove`,function(){t.off(n,this)},this)}this.onAdd(t),this.fire(`add`),t.fire(`layeradd`,{layer:this})}}});H.include({addLayer:function(e){if(!e._layerAdd)throw Error(`The provided object is not a Layer.`);var t=o(e);return this._layers[t]?this:(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e),this)},removeLayer:function(e){var t=o(e);return this._layers[t]?(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire(`layerremove`,{layer:e}),e.fire(`remove`)),e._map=e._mapToAdd=null,this):this},hasLayer:function(e){return o(e)in this._layers},eachLayer:function(e,t){for(var n in this._layers)e.call(t,this._layers[n]);return this},_addLayers:function(e){e=e?_(e)?e:[e]:[];for(var t=0,n=e.length;tthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),this.options.minZoom===void 0&&this._layersMinZoom&&this.getZoom()=2&&t[0]instanceof j&&t[0].equals(t[n-1])&&t.pop(),t},_setLatLngs:function(e){lr.prototype._setLatLngs.call(this,e),Ln(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Ln(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var e=this._renderer._bounds,t=this.options.weight,n=new D(t,t);if(e=new k(e.min.subtract(n),e.max.add(n)),this._parts=[],!(!this._pxBounds||!this._pxBounds.intersects(e))){if(this.options.noClip){this._parts=this._rings;return}for(var r=0,i=this._rings.length,a;re.y!=i.y>e.y&&e.x<(i.x-r.x)*(e.y-r.y)/(i.y-r.y)+r.x&&(t=!t);return t||lr.prototype._containsPoint.call(this,e,!0)}});function fr(e,t){return new dr(e,t)}var pr=Xn.extend({initialize:function(e,t){p(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t=_(e)?e:e.features,n,r,i;if(t){for(n=0,r=t.length;n0&&i.push(i[0].slice()),i}function br(e,t){return e.feature?n({},e.feature,{geometry:t}):xr(t)}function xr(e){return e.type===`Feature`||e.type===`FeatureCollection`?e:{type:`Feature`,properties:{},geometry:e}}var Sr={toGeoJSON:function(e){return br(this,{type:`Point`,coordinates:vr(this.getLatLng(),e)})}};nr.include(Sr),sr.include(Sr),ar.include(Sr),lr.include({toGeoJSON:function(e){var t=!Ln(this._latlngs),n=yr(this._latlngs,+!!t,!1,e);return br(this,{type:(t?`Multi`:``)+`LineString`,coordinates:n})}}),dr.include({toGeoJSON:function(e){var t=!Ln(this._latlngs),n=t&&!Ln(this._latlngs[0]),r=yr(this._latlngs,n?2:+!!t,!0,e);return t||(r=[r]),br(this,{type:(n?`Multi`:``)+`Polygon`,coordinates:r})}}),Jn.include({toMultiPoint:function(e){var t=[];return this.eachLayer(function(n){t.push(n.toGeoJSON(e).geometry.coordinates)}),br(this,{type:`MultiPoint`,coordinates:t})},toGeoJSON:function(e){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if(t===`MultiPoint`)return this.toMultiPoint(e);var n=t===`GeometryCollection`,r=[];return this.eachLayer(function(t){if(t.toGeoJSON){var i=t.toGeoJSON(e);if(n)r.push(i.geometry);else{var a=xr(i);a.type===`FeatureCollection`?r.push.apply(r,a.features):r.push(a)}}}),n?br(this,{geometries:r,type:`GeometryCollection`}):{type:`FeatureCollection`,features:r}}});function Cr(e,t){return new pr(e,t)}var wr=Cr,Tr=qn.extend({options:{opacity:1,alt:``,interactive:!1,crossOrigin:!1,errorOverlayUrl:``,zIndex:1,className:``},initialize:function(e,t,n){this._url=e,this._bounds=se(t),p(this,n)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(R(this._image,`leaflet-interactive`),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){I(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this},setStyle:function(e){return e.opacity&&this.setOpacity(e.opacity),this},bringToFront:function(){return this._map&&Dt(this._image),this},bringToBack:function(){return this._map&&Ot(this._image),this},setUrl:function(e){return this._url=e,this._image&&(this._image.src=e),this},setBounds:function(e){return this._bounds=se(e),this._map&&this._reset(),this},getEvents:function(){var e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var e=this._url.tagName===`IMG`,t=this._image=e?this._url:F(`img`);if(R(t,`leaflet-image-layer`),this._zoomAnimated&&R(t,`leaflet-zoom-animated`),this.options.className&&R(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onload=i(this.fire,this,`load`),t.onerror=i(this._overlayOnError,this,`error`),(this.options.crossOrigin||this.options.crossOrigin===``)&&(t.crossOrigin=this.options.crossOrigin===!0?``:this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),e){this._url=t.src;return}t.src=this._url,t.alt=this.options.alt},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),n=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;Ft(this._image,n,t)},_reset:function(){var e=this._image,t=new k(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),n=t.getSize();It(e,t.min),e.style.width=n.x+`px`,e.style.height=n.y+`px`},_updateOpacity:function(){Mt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&this.options.zIndex!==void 0&&this.options.zIndex!==null&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire(`error`);var e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)},getCenter:function(){return this._bounds.getCenter()}}),Er=function(e,t,n){return new Tr(e,t,n)},Dr=Tr.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var e=this._url.tagName===`VIDEO`,t=this._image=e?this._url:F(`video`);if(R(t,`leaflet-image-layer`),this._zoomAnimated&&R(t,`leaflet-zoom-animated`),this.options.className&&R(t,this.options.className),t.onselectstart=l,t.onmousemove=l,t.onloadeddata=i(this.fire,this,`load`),e){for(var n=t.getElementsByTagName(`source`),r=[],a=0;a0?r:[t.src];return}_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(t.style,`objectFit`)&&(t.style.objectFit=`fill`),t.autoplay=!!this.options.autoplay,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(var o=0;o