diff --git a/httpd.py b/httpd.py index 330bb73..f5f74ad 100644 --- a/httpd.py +++ b/httpd.py @@ -9,9 +9,44 @@ import threading import time import os import gc +import sys import mysqlite from misc import _log +# Static directories (relative to this file) +_STATIC_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static') +_STATIC_LIB_DIR = os.path.join(_STATIC_DIR, 'lib') + +# Content type mapping for static files +_CONTENT_TYPES = { + '.js': 'application/javascript; charset=utf-8', + '.css': 'text/css; charset=utf-8', + '.json': 'application/json; charset=utf-8', + '.png': 'image/png', + '.svg': 'image/svg+xml', + '.woff': 'font/woff', + '.woff2': 'font/woff2', +} + +# Cache for static library files (loaded once at startup) +_LIB_CACHE = {} + +# Cache for dashboard static files (HTML, CSS, JS) +_STATIC_CACHE = {} + +# Optional memory profiling (installed via requirements.txt) +try: + import objgraph + _has_objgraph = True +except ImportError: + _has_objgraph = False + +try: + from pympler import muppy, summary + _has_pympler = True +except ImportError: + _has_pympler = False + # Memory tracking for leak detection _memory_samples = [] _memory_sample_max = 60 # Keep last 60 samples (5 min at 5s intervals) @@ -188,14 +223,78 @@ except ImportError: if GEVENT_PATCHED: from gevent.pywsgi import WSGIServer -# Theme colors - modern dark palette + +def load_static_libs(): + """Load static library files into cache at startup.""" + global _LIB_CACHE + if not os.path.isdir(_STATIC_LIB_DIR): + _log('static/lib directory not found: %s' % _STATIC_LIB_DIR, 'warn') + return + for fname in os.listdir(_STATIC_LIB_DIR): + fpath = os.path.join(_STATIC_LIB_DIR, fname) + if os.path.isfile(fpath): + try: + with open(fpath, 'rb') as f: + _LIB_CACHE[fname] = f.read() + _log('loaded static lib: %s (%d bytes)' % (fname, len(_LIB_CACHE[fname])), 'debug') + except IOError as e: + _log('failed to load %s: %s' % (fname, e), 'warn') + _log('loaded %d static library files' % len(_LIB_CACHE), 'info') + + +def get_static_lib(filename): + """Get a cached static library file.""" + return _LIB_CACHE.get(filename) + + +def load_static_files(theme): + """Load dashboard static files into cache at startup. + + Args: + theme: dict of color name -> color value for CSS variable substitution + """ + global _STATIC_CACHE + files = { + 'dashboard.html': 'static/dashboard.html', + 'map.html': 'static/map.html', + 'mitm.html': 'static/mitm.html', + 'style.css': 'static/style.css', + 'dashboard.js': 'static/dashboard.js', + 'map.js': 'static/map.js', + 'mitm.js': 'static/mitm.js', + } + for key, relpath in files.items(): + fpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), relpath) + if os.path.isfile(fpath): + try: + with open(fpath, 'rb') as f: + content = f.read() + # Apply theme substitution to CSS + if key == 'style.css' and theme: + for name, val in theme.items(): + content = content.replace('{' + name + '}', val) + _STATIC_CACHE[key] = content + _log('loaded static file: %s (%d bytes)' % (key, len(content)), 'debug') + except IOError as e: + _log('failed to load %s: %s' % (fpath, e), 'warn') + else: + _log('static file not found: %s' % fpath, 'warn') + _log('loaded %d dashboard static files' % len(_STATIC_CACHE), 'info') + + +def get_static_file(filename): + """Get a cached dashboard static file.""" + return _STATIC_CACHE.get(filename) + + +# Theme colors - dark tiles on lighter background THEME = { - 'bg': '#0d1117', - 'card': '#161b22', - 'card_alt': '#1c2128', - 'border': '#30363d', - 'text': '#e6edf3', - 'dim': '#7d8590', + 'bg': '#1e2738', + 'card': '#181f2a', + 'card_alt': '#212a36', + 'border': '#3a4858', + 'text': '#e8eef5', + 'dim': '#8b929b', 'green': '#3fb950', 'red': '#f85149', 'yellow': '#d29922', @@ -204,870 +303,9 @@ THEME = { 'cyan': '#39c5cf', 'orange': '#db6d28', 'pink': '#db61a2', + 'map_bg': '#1e2738', # Match dashboard background } -DASHBOARD_CSS = ''' -:root { - --bg: {bg}; --card: {card}; --card-alt: {card_alt}; --border: {border}; - --text: {text}; --dim: {dim}; --green: {green}; --red: {red}; - --yellow: {yellow}; --blue: {blue}; --purple: {purple}; - --cyan: {cyan}; --orange: {orange}; --pink: {pink}; -} -* { box-sizing: border-box; margin: 0; padding: 0; } -body { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; - font-size: 13px; background: var(--bg); color: var(--text); - padding: 16px; min-height: 100vh; line-height: 1.4; -} -a { color: var(--blue); text-decoration: none; } -a:hover { text-decoration: underline; } -h1 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 16px; } -h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; } -h3 { font-size: 13px; font-weight: 600; color: var(--dim); margin-bottom: 8px; } -.container { max-width: 1400px; margin: 0 auto; } - -/* Header */ -.hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); } -.hdr h1 { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; } -.hdr h1::before { content: ""; width: 10px; height: 10px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); } -.status { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--dim); } -.status-item { display: flex; align-items: center; gap: 4px; } -.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; } -.dot.err { background: var(--red); animation: none; } -@keyframes pulse { 50% { opacity: 0.5; } } -.mode-badge { padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; } -.mode-ssl { background: rgba(63,185,80,0.2); color: var(--green); border: 1px solid var(--green); } -.mode-profile { background: rgba(255,165,0,0.2); color: #ffa500; border: 1px solid #ffa500; margin-left: 6px; } -.mode-judges { background: rgba(88,166,255,0.2); color: var(--blue); border: 1px solid var(--blue); } -.mode-http { background: rgba(210,153,34,0.2); color: var(--yellow); border: 1px solid var(--yellow); } -.mode-irc { background: rgba(163,113,247,0.2); color: var(--purple); border: 1px solid var(--purple); } - -/* System monitor bar */ -.sysbar { display: flex; gap: 16px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; font-size: 11px; } -.sysbar-item { display: flex; align-items: center; gap: 6px; } -.sysbar-lbl { color: var(--dim); } -.sysbar-val { font-weight: 600; font-feature-settings: "tnum"; } -.sysbar-bar { width: 50px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; } -.sysbar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; } - -/* Grid */ -.g { display: grid; gap: 12px; margin-bottom: 16px; } -.g2 { grid-template-columns: repeat(2, 1fr); } -.g3 { grid-template-columns: repeat(3, 1fr); } -.g4 { grid-template-columns: repeat(4, 1fr); } -.g5 { grid-template-columns: repeat(5, 1fr); } -.g6 { grid-template-columns: repeat(6, 1fr); } -@media (max-width: 1200px) { .g5, .g6 { grid-template-columns: repeat(4, 1fr); } } -@media (max-width: 900px) { .g3, .g4, .g5, .g6 { grid-template-columns: repeat(2, 1fr); } } -@media (max-width: 600px) { .g2, .g3, .g4, .g5, .g6 { grid-template-columns: 1fr; } } - -/* Cards */ -.c { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 14px; } -.c-lg { padding: 16px 18px; } -.c-sm { padding: 10px 12px; } -.lbl { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; font-weight: 500; } -.val { font-size: 26px; font-weight: 700; font-feature-settings: "tnum"; letter-spacing: -0.5px; } -.val-md { font-size: 20px; } -.val-sm { font-size: 16px; } -.sub { font-size: 11px; color: var(--dim); margin-top: 4px; } -.grn { color: var(--green); } .red { color: var(--red); } .yel { color: var(--yellow); } -.blu { color: var(--blue); } .pur { color: var(--purple); } .cyn { color: var(--cyan); } -.org { color: var(--orange); } .pnk { color: var(--pink); } - -/* Section headers */ -.sec { margin-bottom: 16px; } -.sec-hdr { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; } -.sec-hdr::before { content: ""; width: 3px; height: 12px; background: var(--blue); border-radius: 2px; } - -/* Progress bars */ -.bar-wrap { height: 6px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; } -.bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; } -.bar.grn { background: linear-gradient(90deg, #238636, #3fb950); } -.bar.red { background: linear-gradient(90deg, #da3633, #f85149); } -.bar.yel { background: linear-gradient(90deg, #9e6a03, #d29922); } -.bar.blu { background: linear-gradient(90deg, #1f6feb, #58a6ff); } - -/* Charts */ -.chart { width: 100%; height: 80px; margin-top: 8px; } -.chart-lg { height: 120px; } -.chart svg { width: 100%; height: 100%; } -.chart-line { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; } -.chart-area { opacity: 0.15; } -.chart-grid { stroke: var(--border); stroke-width: 0.5; } -.chart-label { font-size: 9px; fill: var(--dim); } - -/* Histogram bars */ -.histo { display: flex; align-items: flex-end; gap: 2px; height: 60px; margin-top: 8px; } -.histo-bar { flex: 1; background: var(--blue); border-radius: 2px 2px 0 0; min-height: 2px; transition: height 0.3s; position: relative; } -.histo-bar:hover { opacity: 0.8; } -.histo-bar::after { content: attr(data-label); position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-size: 8px; color: var(--dim); white-space: nowrap; } -.histo-labels { display: flex; justify-content: space-between; margin-top: 20px; font-size: 9px; color: var(--dim); } - -/* Stat rows */ -.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 12px; } -.stat-row + .stat-row { border-top: 1px solid rgba(48,54,61,0.5); } -.stat-lbl { color: var(--dim); display: flex; align-items: center; gap: 6px; } -.stat-val { font-weight: 600; font-feature-settings: "tnum"; } -.stat-bar { width: 60px; height: 4px; background: var(--border); border-radius: 2px; margin-left: 8px; overflow: hidden; } -.stat-bar-fill { height: 100%; border-radius: 2px; } - -/* Leaderboard */ -.lb { font-size: 12px; } -.lb-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; } -.lb-item + .lb-item { border-top: 1px solid rgba(48,54,61,0.3); } -.lb-rank { width: 18px; height: 18px; border-radius: 4px; background: var(--card-alt); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: var(--dim); } -.lb-rank.top { background: var(--yellow); color: var(--bg); } -.lb-name { flex: 1; font-family: ui-monospace, monospace; color: var(--text); } -.lb-val { font-weight: 600; font-feature-settings: "tnum"; } - -/* Tags */ -.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; font-size: 10px; font-weight: 600; } -.tag-ok { background: rgba(63,185,80,0.15); color: var(--green); } -.tag-err { background: rgba(248,81,73,0.15); color: var(--red); } -.tag-warn { background: rgba(210,153,34,0.15); color: var(--yellow); } -.tag-info { background: rgba(88,166,255,0.15); color: var(--blue); } - -/* Mini stats */ -.mini { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; } -.mini-item { display: flex; align-items: baseline; gap: 4px; } -.mini-val { font-size: 14px; font-weight: 600; font-feature-settings: "tnum"; } -.mini-lbl { font-size: 10px; color: var(--dim); } - -/* Proto cards */ -.proto-card { text-align: center; } -.proto-icon { font-size: 20px; margin-bottom: 4px; } -.proto-name { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; } -.proto-val { font-size: 18px; font-weight: 700; margin: 4px 0; } -.proto-rate { font-size: 11px; padding: 2px 6px; border-radius: 3px; display: inline-block; } - -/* Pie charts */ -.pie-wrap { display: flex; gap: 16px; align-items: center; } -.pie { width: 90px; height: 90px; border-radius: 50%; flex-shrink: 0; } -.legend { flex: 1; } -.legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; } -.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; } -.legend-name { flex: 1; color: var(--dim); } -.legend-val { font-weight: 600; font-feature-settings: "tnum"; } - -/* Tor/Judge cards */ -.host-card { display: flex; justify-content: space-between; align-items: center; } -.host-addr { font-family: ui-monospace, monospace; font-size: 12px; } -.host-stats { font-size: 11px; color: var(--dim); } - -.judge-item { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 11px; } -.judge-item + .judge-item { border-top: 1px solid rgba(48,54,61,0.3); } -.judge-name { font-family: ui-monospace, monospace; color: var(--dim); flex: 1; } -.judge-stats { display: flex; gap: 12px; } - -/* Percentile badges */ -.pct-badges { display: flex; gap: 8px; margin-top: 8px; } -.pct-badge { flex: 1; text-align: center; padding: 8px; background: var(--card-alt); border-radius: 6px; } -.pct-label { font-size: 10px; color: var(--dim); text-transform: uppercase; } -.pct-value { font-size: 16px; font-weight: 700; margin-top: 2px; } - -/* Map page */ -.nav { margin-bottom: 16px; font-size: 12px; } -.map-stats { margin-bottom: 16px; color: var(--dim); font-size: 12px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; } -.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; } -.country { padding: 12px 8px; border-radius: 6px; text-align: center; background: var(--card); border: 1px solid var(--border); transition: transform 0.15s, box-shadow 0.15s; } -.country:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); } -.country .code { font-weight: bold; font-size: 1.1em; letter-spacing: 0.5px; } -.country .count { font-size: 0.85em; color: var(--dim); margin-top: 4px; font-feature-settings: "tnum"; } -.country.t1 { background: #0d4429; border-color: #238636; } -.country.t1 .code { color: #7ee787; } -.country.t2 { background: #1a3d2e; border-color: #2ea043; } -.country.t2 .code { color: #7ee787; } -.country.t3 { background: #1f3d2a; border-color: #3fb950; } -.country.t3 .code { color: #56d364; } -.country.t4 { background: #2a4a35; border-color: #56d364; } -.country.t4 .code { color: #3fb950; } -.country.t5 { background: #35573f; border-color: #7ee787; } -.country.t5 .code { color: #3fb950; } -.map-legend { display: flex; gap: 16px; margin-top: 20px; flex-wrap: wrap; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; } -.map-legend .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); } -.map-legend .legend-dot { width: 12px; height: 12px; border-radius: 3px; } - -/* Footer */ -.ftr { text-align: center; font-size: 11px; color: var(--dim); padding: 16px 0; margin-top: 8px; border-top: 1px solid var(--border); } -''' - -DASHBOARD_JS = ''' -var $ = function(id) { return document.getElementById(id); }; -var fmt = function(n) { return n == null ? '-' : n.toLocaleString(); }; -var fmtDec = function(n, d) { return n == null ? '-' : n.toFixed(d || 1); }; -var pct = function(n, t) { return t > 0 ? ((n / t) * 100).toFixed(1) : '0.0'; }; - -function fmtBytes(b) { - if (!b || b <= 0) return '-'; - var units = ['B', 'KB', 'MB', 'GB', 'TB']; - var i = 0; - while (b >= 1024 && i < units.length - 1) { b /= 1024; i++; } - return b.toFixed(i > 0 ? 1 : 0) + ' ' + units[i]; -} - -function fmtTime(s) { - if (!s) return '-'; - var d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600), m = Math.floor((s % 3600) / 60); - if (d > 0) return d + 'd ' + h + 'h'; - if (h > 0) return h + 'h ' + m + 'm'; - return m + 'm ' + Math.floor(s % 60) + 's'; -} - -function setBarColor(el, pct) { - if (pct > 90) return 'background:var(--red)'; - if (pct > 70) return 'background:var(--yellow)'; - return 'background:var(--green)'; -} - -function fmtMs(ms) { - if (!ms || ms <= 0) return '-'; - if (ms < 1000) return Math.round(ms) + 'ms'; - return (ms / 1000).toFixed(1) + 's'; -} - -function setBar(id, val, max, cls) { - var el = $(id); - if (el) { el.style.width = Math.min(val / max * 100, 100) + '%'; el.className = 'bar ' + (cls || 'grn'); } -} - -function conicGrad(segs) { - var parts = [], deg = 0; - segs.forEach(function(s) { parts.push(s.c + ' ' + deg + 'deg ' + (deg + s.d) + 'deg'); deg += s.d; }); - return 'conic-gradient(' + parts.join(', ') + ')'; -} - -function renderLineChart(id, data, color, maxVal) { - var el = $(id); if (!el || !data || data.length < 2) return; - var w = el.clientWidth || 300, h = el.clientHeight || 80; - var max = maxVal || Math.max.apply(null, data) || 1; - var padY = 5, padX = 2; - var points = data.map(function(v, i) { - var x = padX + (i / (data.length - 1)) * (w - 2 * padX); - var y = h - padY - ((v / max) * (h - 2 * padY)); - return x + ',' + y; - }); - var areaPoints = padX + ',' + (h - padY) + ' ' + points.join(' ') + ' ' + (w - padX) + ',' + (h - padY); - el.innerHTML = '' + - '' + - ''; -} - -function renderHistogram(id, data) { - var el = $(id); if (!el || !data || !data.length) return; - var max = Math.max.apply(null, data.map(function(d) { return d.pct; })) || 1; - var colors = ['#3fb950', '#3fb950', '#58a6ff', '#58a6ff', '#d29922', '#f85149', '#f85149']; - var html = ''; - data.forEach(function(d, i) { - var h = Math.max(4, (d.pct / max) * 100); - var c = colors[Math.min(i, colors.length - 1)]; - html += '
'; - }); - el.innerHTML = html; -} - -function renderLeaderboard(id, data, nameKey, valKey, limit) { - var el = $(id); if (!el) return; - limit = limit || 8; - if (!data || !data.length) { el.innerHTML = '
No data
'; return; } - var html = ''; - data.slice(0, limit).forEach(function(item, i) { - var name = Array.isArray(item) ? item[0] : item[nameKey]; - var val = Array.isArray(item) ? item[1] : item[valKey]; - html += '
' + (i + 1) + '
'; - html += '' + name + '' + fmt(val) + '
'; - }); - el.innerHTML = html; -} - -function update(d) { - $('dot').className = 'dot'; $('statusTxt').textContent = 'Live'; - - // Check type badge (prominent display) - var ct = d.checktype || 'unknown'; - var ctBadge = $('checktypeBadge'); - if (ctBadge) { - ctBadge.textContent = ct.toUpperCase(); - ctBadge.className = 'mode-badge mode-' + ct; - } - // Profiling badge - var profBadge = $('profileBadge'); - if (profBadge) { - profBadge.style.display = d.profiling ? 'inline-block' : 'none'; - } - - // System monitor bar - var sys = d.system || {}; - $('sysLoad').textContent = (sys.load_1m || 0) + ' / ' + (sys.cpu_count || 1); - $('sysMemVal').textContent = fmtBytes(sys.mem_used) + ' / ' + fmtBytes(sys.mem_total); - $('sysMemPct').textContent = (sys.mem_pct || 0) + '%'; - var memFill = $('sysMemFill'); - if (memFill) { memFill.style.width = (sys.mem_pct || 0) + '%'; memFill.style.cssText = 'width:' + (sys.mem_pct || 0) + '%;' + setBarColor(memFill, sys.mem_pct || 0); } - $('sysDiskVal').textContent = fmtBytes(sys.disk_used) + ' / ' + fmtBytes(sys.disk_total); - $('sysDiskPct').textContent = (sys.disk_pct || 0) + '%'; - var diskFill = $('sysDiskFill'); - if (diskFill) { diskFill.style.width = (sys.disk_pct || 0) + '%'; diskFill.style.cssText = 'width:' + (sys.disk_pct || 0) + '%;' + setBarColor(diskFill, sys.disk_pct || 0); } - var memGrowth = sys.proc_rss_growth || 0; - var memGrowthStr = memGrowth > 0 ? ' (+' + fmtBytes(memGrowth) + ')' : ''; - $('sysProcMem').textContent = fmtBytes(sys.proc_rss) + memGrowthStr; - - // Main stats - db stats are nested under d.db - var db = d.db || {}; - $('working').textContent = fmt(db.working); - $('total').textContent = fmt(db.total); - $('tested').textContent = fmt(d.tested); - $('passed').textContent = fmt(d.passed); - $('failed').textContent = fmt(d.failed); - - // Success rate - var sr = d.success_rate || 0; - $('successRate').textContent = fmtDec(sr, 1) + '%'; - $('successRate').className = 'val-md ' + (sr < 20 ? 'red' : sr < 50 ? 'yel' : 'grn'); - setBar('srBar', sr, 100, sr < 20 ? 'red' : sr < 50 ? 'yel' : 'grn'); - - var rsr = d.recent_success_rate || 0; - $('recentSuccessRate').textContent = fmtDec(rsr, 1) + '%'; - $('recentSuccessRate').className = 'stat-val ' + (rsr < 20 ? 'red' : rsr < 50 ? 'yel' : 'grn'); - - // Rates - $('rate').textContent = fmtDec(d.rate, 2); - $('recentRate').textContent = fmtDec(d.recent_rate, 2); - $('peakRate').textContent = fmtDec(d.peak_rate, 2); - $('passRate').textContent = fmtDec(d.pass_rate, 3); - - // Latency - var lat = d.avg_latency || 0; - $('avgLatency').textContent = fmtMs(lat); - $('minLatency').textContent = fmtMs(d.min_latency); - $('maxLatency').textContent = fmtMs(d.max_latency); - - var pctl = d.latency_percentiles || {}; - $('p50').textContent = fmtMs(pctl.p50); - $('p90').textContent = fmtMs(pctl.p90); - $('p99').textContent = fmtMs(pctl.p99); - - // System - $('threads').textContent = d.threads + '/' + d.max_threads; - setBar('threadBar', d.threads, d.max_threads, 'blu'); - $('queue').textContent = fmt(d.queue_size); - $('uptime').textContent = fmtTime(d.uptime_seconds); - - // Charts - renderLineChart('rateChart', d.rate_history, '#58a6ff', d.peak_rate * 1.1); - renderLineChart('srChart', d.success_rate_history, '#3fb950', 100); - renderHistogram('latencyHisto', d.latency_histogram); - - // Protocol breakdown - var ps = d.proto_stats || {}; - ['http', 'socks4', 'socks5'].forEach(function(p) { - var s = ps[p] || {passed: 0, tested: 0, success_rate: 0}; - $(p + 'Passed').textContent = fmt(s.passed); - $(p + 'Tested').textContent = fmt(s.tested); - var rateEl = $(p + 'Rate'); - rateEl.textContent = fmtDec(s.success_rate, 0) + '%'; - rateEl.className = 'proto-rate ' + (s.success_rate < 20 ? 'tag-err' : s.success_rate < 50 ? 'tag-warn' : 'tag-ok'); - }); - - // Results pie - var passed = d.passed || 0, failed = d.failed || 0, total = passed + failed; - if (total > 0) { - var passedDeg = (passed / total) * 360; - $('resultsPie').style.background = conicGrad([{c:'#3fb950',d:passedDeg},{c:'#f85149',d:360-passedDeg}]); - } - $('passedLeg').textContent = fmt(passed); - $('passedPct').textContent = pct(passed, total) + '%'; - $('failedLeg').textContent = fmt(failed); - $('failedPct').textContent = pct(failed, total) + '%'; - - // Failures breakdown - var fhtml = '', colors = ['#f85149','#db6d28','#d29922','#58a6ff','#a371f7','#39c5cf','#db61a2','#7d8590']; - if (d.failures && Object.keys(d.failures).length > 0) { - var cats = Object.keys(d.failures).sort(function(a,b) { return d.failures[b] - d.failures[a]; }); - var failTotal = cats.reduce(function(s, c) { return s + d.failures[c]; }, 0); - var segs = []; - cats.forEach(function(cat, i) { - var n = d.failures[cat], col = colors[i % colors.length]; - segs.push({c: col, d: (n / failTotal) * 360}); - fhtml += '
'; - fhtml += '' + cat + '' + n + '
'; - }); - $('failPie').style.background = conicGrad(segs); - } else { - $('failPie').style.background = 'var(--border)'; - fhtml = '
No failures yet
'; - } - $('failLegend').innerHTML = fhtml; - - // Leaderboards (session data) - renderLeaderboard('topAsns', d.top_asns_session, 'asn', 'count'); - - // Country pie chart (database data) - var countryColors = ['#58a6ff','#3fb950','#d29922','#f85149','#a371f7','#39c5cf','#db61a2','#db6d28','#7ee787','#7d8590']; - if (d.db && d.db.top_countries && d.db.top_countries.length > 0) { - var countries = d.db.top_countries.slice(0, 8); - var countryTotal = countries.reduce(function(s, c) { return s + (c.count || c[1] || 0); }, 0); - var segs = [], chtml = ''; - countries.forEach(function(c, i) { - var code = c.code || c[0], cnt = c.count || c[1] || 0; - var col = countryColors[i % countryColors.length]; - var pctVal = countryTotal > 0 ? ((cnt / countryTotal) * 100).toFixed(1) : '0'; - segs.push({c: col, d: (cnt / countryTotal) * 360}); - chtml += '
'; - chtml += '' + code + '' + fmt(cnt) + ''; - chtml += '' + pctVal + '%
'; - }); - $('countryPie').style.background = conicGrad(segs); - $('countryLegend').innerHTML = chtml; - } else { - $('countryPie').style.background = 'var(--border)'; - $('countryLegend').innerHTML = '
No data
'; - } - - // Tor pool - var thtml = ''; - if (d.tor_pool && d.tor_pool.hosts) { - d.tor_pool.hosts.forEach(function(h) { - // Status: OK only if available AND has successes, WARN if available but 0%, DOWN if in backoff - var statusCls = !h.healthy ? 'tag-err' : (h.success_rate > 0 ? 'tag-ok' : 'tag-warn'); - var statusTxt = !h.healthy ? 'DOWN' : (h.success_rate > 0 ? 'OK' : 'IDLE'); - thtml += '
'; - thtml += '' + h.address + ''; - thtml += '' + statusTxt + ''; - thtml += '
' + fmtMs(h.latency_ms) + ' / ' + fmtDec(h.success_rate, 0) + '% success
'; - }); - } - $('torPool').innerHTML = thtml || '
No Tor hosts
'; - - // Judges - if (d.judges) { - $('judgesAvail').textContent = d.judges.available + '/' + d.judges.total; - $('judgesCooldown').textContent = d.judges.in_cooldown; - var jhtml = ''; - if (d.judges.top_judges) { - d.judges.top_judges.slice(0, 6).forEach(function(j) { - jhtml += '
' + j.judge + ''; - jhtml += '
' + j.success + '/' + j.tests + ''; - jhtml += '' + fmtDec(j.rate, 0) + '%
'; - }); - } - $('topJudges').innerHTML = jhtml || '
No data
'; - } - - // Database stats - if (d.db) { - var dbs = d.db; - $('dbByProto').innerHTML = ['http', 'socks4', 'socks5'].map(function(p) { - var c = dbs.by_proto && dbs.by_proto[p] || 0; - return '
' + p.toUpperCase() + '' + fmt(c) + '
'; - }).join(''); - - } - - // Scraper/Engine stats - $('engAvail').textContent = fmt(d.engines_available); - $('engBackoff').textContent = fmt(d.engines_backoff); - $('engTotal').textContent = fmt(d.engines_total); - if (d.scraper && d.scraper.engines) { - var ehtml = ''; - d.scraper.engines.slice(0, 5).forEach(function(e, i) { - var statusCls = e.available ? 'tag-ok' : 'tag-warn'; - var statusTxt = e.available ? 'OK' : (e.backoff_remaining > 0 ? e.backoff_remaining + 's' : 'OFF'); - ehtml += '
' + (i + 1) + '
'; - ehtml += '' + e.name + ''; - ehtml += '' + statusTxt + ''; - ehtml += '' + fmt(e.successes) + '
'; - }); - $('topEngines').innerHTML = ehtml || '
No engines
'; - } else { - $('topEngines').innerHTML = '
Scraper disabled
'; - } - - // SSL/TLS stats - if (d.ssl) { - var ssl = d.ssl; - $('sslTested').textContent = fmt(ssl.tested); - $('sslPassed').textContent = fmt(ssl.passed); - $('sslFailed').textContent = fmt(ssl.failed); - var sslRate = ssl.success_rate || 0; - setBar('sslBar', sslRate, 100, sslRate < 50 ? 'red' : sslRate < 80 ? 'yel' : 'grn'); - $('mitmDetected').textContent = fmt(ssl.mitm_detected); - $('mitmDetected').className = 'stat-val ' + (ssl.mitm_detected > 0 ? 'red' : 'grn'); - $('certErrors').textContent = fmt(ssl.cert_errors); - $('certErrors').className = 'stat-val ' + (ssl.cert_errors > 0 ? 'yel' : 'grn'); - } - - // Anonymity breakdown - var dbh = d.db_health || {}; - if (dbh.anonymity) { - var anonHtml = ''; - var anonColors = {elite: 'grn', anonymous: 'blu', transparent: 'yel', unknown: 'dim'}; - var anonOrder = ['elite', 'anonymous', 'transparent', 'unknown']; - anonOrder.forEach(function(level) { - var count = dbh.anonymity[level] || 0; - if (count > 0) { - anonHtml += '
' + level.charAt(0).toUpperCase() + level.slice(1) + ''; - anonHtml += '' + fmt(count) + '
'; - } - }); - $('anonBreakdown').innerHTML = anonHtml || '
No data
'; - } - - // Database health - if (dbh.db_size) { - $('dbSize').textContent = fmtBytes(dbh.db_size); - $('dbTestedHour').textContent = fmt(dbh.tested_last_hour); - $('dbAddedDay').textContent = fmt(dbh.added_last_day); - $('dbDead').textContent = fmt(dbh.dead_count); - $('dbFailing').textContent = fmt(dbh.failing_count); - $('dbFreelist').textContent = fmt(dbh.freelist_count); - $('dbAvgLat').textContent = fmtMs(dbh.db_avg_latency); - $('dbMinLat').textContent = fmtMs(dbh.db_min_latency); - $('dbMaxLat').textContent = fmtMs(dbh.db_max_latency); - } - - // Tor pool enhanced stats - if (d.tor_pool) { - var tp = d.tor_pool; - $('torTotal').textContent = fmt(tp.total_requests || 0); - $('torSuccess').textContent = fmtDec(tp.success_rate || 0, 1) + '%'; - $('torHealthy').textContent = (tp.healthy_count || 0) + '/' + (tp.total_count || 0); - if (tp.avg_latency) { - $('torLatency').textContent = fmtMs(tp.avg_latency); - } - } - - $('lastUpdate').textContent = new Date().toLocaleTimeString(); -} - -function fetchStats() { - fetch('/api/stats') - .then(function(r) { return r.json(); }) - .then(update) - .catch(function(e) { $('dot').className = 'dot err'; $('statusTxt').textContent = 'Error'; }); -} - -fetchStats(); -setInterval(fetchStats, 3000); -''' - -MAP_HTML = ''' - - - - PPF Proxy Map - - - - -
- -

Proxy Distribution by Country

-
Loading...
-
-
-
1000+
-
500-999
-
100-499
-
10-99
-
1-9
-
-
PPF Python Proxy Finder
-
- - - -''' - -DASHBOARD_HTML = ''' - - - - PPF Dashboard - - - - -
-
-

PPF Dashboard Map →

-
- - - -
Connecting
-
Updated: -
-
-
- - -
-
Load:-
-
Memory:- -
- -
-
Disk:- -
- -
-
Process:-
-
- - -
-
-
Working Proxies
-
-
-
of - in database
-
-
-
Tests (Cumulative)
-
-
-
- passed / - failed
-
-
-
Success Rate
-
-
-
-
-
-
Test Rate
-
-
-
tests/sec average
-
-
-
Uptime
-
-
-
session duration
-
-
- - -
-
-
Test Rate History (10 min)
-
-
-current
-
-peak
-
-pass/s
-
-
-
-
-
Success Rate History
-
-
-recent
-
-
-
-
- - -
-
Latency Analysis
-
-
-
Average-
-
Min-
-
Max-
-
-
P50
-
-
P90
-
-
P99
-
-
-
-
-
Response Time Distribution
-
-
-
-
- - -
-
Protocol Performance
-
-
-
🌐
-
HTTP
-
-
-
of - tested
-
-
-
-
-
🔌
-
SOCKS4
-
-
-
of - tested
-
-
-
-
-
🔒
-
SOCKS5
-
-
-
of - tested
-
-
-
-
-
- - -
-
-
Test Results
-
-
-
-
Passed--
-
Failed--
-
-
-
-
-
Failure Breakdown
-
-
-
-
-
-
- - -
-
Geographic Distribution View Map →
-
-
-
Proxies by Country (Database)
-
-
-
-
-
-
-
Top ASNs (Session)
-
-
-
-
- - -
-
-
Worker Pool
-
Active Threads-
-
-
Job Queue-
-
-
-
Judge Services
-
Available-
-
In Cooldown-
-
Top Performers
-
-
-
- - -
-
-
Tor Pool
-
Total Requests-
-
Success Rate-
-
Healthy Nodes-
-
Avg Latency-
-
Exit Nodes
-
-
-
-
Anonymity Levels
-
-
Elite = no headers, Anonymous = adds headers, Transparent = reveals IP
-
-
- - -
-
-
Search Engines
-
Available-
-
In Backoff-
-
Total-
-
Top Engines
-
-
-
-
SSL/TLS Security
-
SSL Tests-
-
Passed-
-
Failed-
-
-
MITM Detected-
-
Cert Errors-
-
-
- - -
-
Database Overview
-
-
-
Database Size
-
-
-
-
-
Tested (1h)
-
-
-
-
-
Added (24h)
-
-
-
-
-
Dead Proxies
-
-
-
-
-
-
-
Working by Protocol
-
-
-
-
Latency Stats
-
Average-
-
Min-
-
Max-
-
-
-
Activity
-
Failing-
-
Freelist-
-
-
-
- -
PPF Python Proxy Finder
-
- - -''' - class ProxyAPIHandler(BaseHTTPServer.BaseHTTPRequestHandler): """HTTP request handler for proxy API.""" @@ -1291,6 +529,10 @@ class ProxyAPIServer(threading.Thread): self.daemon = True self.server = None self._stop_event = threading.Event() if not GEVENT_PATCHED else None + # Load static library files into cache + load_static_libs() + # Load dashboard static files (HTML, CSS, JS) with theme substitution + load_static_files(THEME) def _wsgi_app(self, environ, start_response): """WSGI application wrapper for gevent.""" @@ -1329,7 +571,9 @@ class ProxyAPIServer(threading.Thread): 'endpoints': { '/dashboard': 'web dashboard (HTML)', '/map': 'proxy distribution by country (HTML)', + '/mitm': 'MITM certificate search (HTML)', '/api/stats': 'runtime statistics (JSON)', + '/api/mitm': 'MITM certificate statistics (JSON)', '/api/countries': 'proxy counts by country (JSON)', '/proxies': 'list working proxies (params: limit, proto, country, asn)', '/proxies/count': 'count working proxies', @@ -1338,17 +582,49 @@ class ProxyAPIServer(threading.Thread): }, indent=2) return body, 'application/json', 200 elif path == '/dashboard': - return DASHBOARD_HTML, 'text/html; charset=utf-8', 200 + content = get_static_file('dashboard.html') + if content: + return content, 'text/html; charset=utf-8', 200 + return '{"error": "dashboard.html not loaded"}', 'application/json', 500 elif path == '/map': - return MAP_HTML, 'text/html; charset=utf-8', 200 + content = get_static_file('map.html') + if content: + return content, 'text/html; charset=utf-8', 200 + return '{"error": "map.html not loaded"}', 'application/json', 500 + elif path == '/mitm': + content = get_static_file('mitm.html') + if content: + return content, 'text/html; charset=utf-8', 200 + return '{"error": "mitm.html not loaded"}', 'application/json', 500 elif path == '/static/style.css': - # Use str.format() instead of % to avoid issues with % escaping - css = DASHBOARD_CSS - for key, val in THEME.items(): - css = css.replace('{' + key + '}', val) - return css, 'text/css; charset=utf-8', 200 + content = get_static_file('style.css') + if content: + return content, 'text/css; charset=utf-8', 200 + return '{"error": "style.css not loaded"}', 'application/json', 500 elif path == '/static/dashboard.js': - return DASHBOARD_JS, 'application/javascript; charset=utf-8', 200 + content = get_static_file('dashboard.js') + if content: + return content, 'application/javascript; charset=utf-8', 200 + return '{"error": "dashboard.js not loaded"}', 'application/json', 500 + elif path == '/static/map.js': + content = get_static_file('map.js') + if content: + return content, 'application/javascript; charset=utf-8', 200 + return '{"error": "map.js not loaded"}', 'application/json', 500 + elif path == '/static/mitm.js': + content = get_static_file('mitm.js') + if content: + return content, 'application/javascript; charset=utf-8', 200 + return '{"error": "mitm.js not loaded"}', 'application/json', 500 + elif path.startswith('/static/lib/'): + # Serve static library files from cache + filename = path.split('/')[-1] + content = get_static_lib(filename) + if content: + ext = os.path.splitext(filename)[1] + content_type = _CONTENT_TYPES.get(ext, 'application/octet-stream') + return content, content_type, 200 + return '{"error": "not found"}', 'application/json', 404 elif path == '/api/stats': stats = {} if self.stats_provider: @@ -1363,6 +639,16 @@ class ProxyAPIServer(threading.Thread): except Exception: pass return json.dumps(stats, indent=2), 'application/json', 200 + elif path == '/api/mitm': + # MITM certificate statistics + if self.stats_provider: + try: + stats = self.stats_provider() + mitm = stats.get('mitm', {}) + return json.dumps(mitm, indent=2), 'application/json', 200 + except Exception as e: + return json.dumps({'error': str(e)}), 'application/json', 500 + return json.dumps({'error': 'stats not available'}), 'application/json', 500 elif path == '/api/countries': try: db = mysqlite.mysqlite(self.database, str) @@ -1374,6 +660,20 @@ class ProxyAPIServer(threading.Thread): return json.dumps({'countries': countries}, indent=2), 'application/json', 200 except Exception as e: return json.dumps({'error': str(e)}), 'application/json', 500 + elif path == '/api/locations': + # Return proxy locations aggregated by lat/lon grid (0.5 degree cells) + try: + db = mysqlite.mysqlite(self.database, str) + rows = db.execute( + 'SELECT ROUND(latitude, 1) as lat, ROUND(longitude, 1) as lon, ' + 'country, anonymity, COUNT(*) as c FROM proxylist ' + 'WHERE failed=0 AND latitude IS NOT NULL AND longitude IS NOT NULL ' + 'GROUP BY lat, lon, country, anonymity ORDER BY c DESC' + ).fetchall() + locations = [{'lat': r[0], 'lon': r[1], 'country': r[2], 'anon': r[3] or 'unknown', 'count': r[4]} for r in rows] + return json.dumps({'locations': locations}, indent=2), 'application/json', 200 + except Exception as e: + return json.dumps({'error': str(e)}), 'application/json', 500 elif path == '/proxies': try: db = mysqlite.mysqlite(self.database, str) @@ -1391,6 +691,74 @@ class ProxyAPIServer(threading.Thread): return json.dumps({'count': row[0] if row else 0}), 'application/json', 200 except Exception as e: return json.dumps({'error': str(e)}), 'application/json', 500 + elif path == '/api/memory': + # Memory profiling endpoint + try: + mem = {} + + # Process memory from /proc/self/status + try: + with open('/proc/self/status', 'r') as f: + for line in f: + if line.startswith('Vm'): + parts = line.split() + key = parts[0].rstrip(':') + mem[key] = int(parts[1]) * 1024 # Convert to bytes + except IOError: + pass + + # GC stats + gc_stats = { + 'collections': gc.get_count(), + 'threshold': gc.get_threshold(), + 'objects': len(gc.get_objects()), + } + + # Object type counts (top 20) + type_counts = {} + for obj in gc.get_objects(): + t = type(obj).__name__ + type_counts[t] = type_counts.get(t, 0) + 1 + top_types = sorted(type_counts.items(), key=lambda x: -x[1])[:20] + + # Memory samples history + samples = [] + for ts, rss in _memory_samples[-30:]: + samples.append({'time': int(ts), 'rss': rss}) + + result = { + 'process': mem, + 'gc': gc_stats, + 'top_types': [{'type': t, 'count': c} for t, c in top_types], + 'samples': samples, + 'peak_rss': _peak_rss, + 'start_rss': _start_rss, + 'has_objgraph': _has_objgraph, + 'has_pympler': _has_pympler, + } + + # Objgraph most common types (if available) + if _has_objgraph: + try: + result['objgraph_common'] = objgraph.most_common_types(limit=15) + except Exception: + pass + + # Pympler summary (if available) + if _has_pympler: + try: + all_objects = muppy.get_objects() + sum_table = summary.summarize(all_objects) + result['pympler_summary'] = [ + {'type': row[0], 'count': row[1], 'size': row[2]} + for row in sum_table[:20] + ] + except Exception as e: + result['pympler_error'] = str(e) + + return json.dumps(result, indent=2), 'application/json', 200 + except Exception as e: + return json.dumps({'error': str(e)}), 'application/json', 500 elif path == '/health': return json.dumps({'status': 'ok', 'timestamp': int(time.time())}), 'application/json', 200 else: diff --git a/static/dashboard.html b/static/dashboard.html new file mode 100644 index 0000000..70b0feb --- /dev/null +++ b/static/dashboard.html @@ -0,0 +1,431 @@ + + + + + PPF Dashboard + + + + + +
+
+

PPF Dashboard Map MITM Search

+
+ + - + +
Connecting
+
Updated: -
+ +
+
+ + +
+
Load:-
+
Memory:- +
+ -
+
Disk:- +
+ -
+
Process:-
+
Scrape:--
+
Proxy:--
+
+ + +
+
+
Working Proxies
+
-
+
of - in database
+
+
+
Tests (Cumulative)
+
-
+
- passed / - failed
+
+
+
Success Rate
+
-
+
+
+
+
Test Rate
+
-
+
tests/sec (60s)
+
+
+
Uptime
+
-
+
session duration
+
+
+ + +
+
+
Worker Pool
+
+
Active Threads-
+
+
Job Queue-
+
+
+
+
Tor Pool
+
+
Total Requests-
+
Success Rate-
+
Healthy Nodes-
+
Avg Latency-
+
+
+
+ + +
+
+ + + + + + +
+
+ + +
+ +
+
+
Test Rate History (10 min)
+
+
-current
+
-peak
+
-pass/s
+
+
+
+
+
+
+
Success Rate History
+
+
-recent
+
+
+
+
+
+
+ + +
+
Latency Analysis
+
+
+
+
Average-
+
Min-
+
Max-
+
+
+
P50
-
+
P90
-
+
P99
-
+
+
+
+
Response Time Distribution
+
+
+
+
+
+
+ +
+ + +
+ +
+
Protocol Performance
+
+
+
🌐
+
HTTP
+
-
+
of - tested
+
-
+
+
+
🔌
+
SOCKS4
+
-
+
of - tested
+
-
+
+
+
🔒
+
SOCKS5
+
-
+
of - tested
+
-
+
+
+
+ + +
+
+
Test Results
+
+
+
+
Passed--
+
Failed--
+
+
+
+
+
Failure Breakdown
+
+
+
+
+
+
+ +
+ + +
+ +
+
Geographic Distribution View Map →
+
+
+
Proxies by Country (Database)
+
+
+
+
+
+
+
Top ASNs (Session)
+
+
+
+
+
+
+ +
+ + +
+ +
+
+
Judge Services
+
+
Available-
+
In Cooldown-
+
+
Top Performers
+
+
+
+
+
+
Anonymity Levels
+
+
+
+
Elite = no headers, Anonymous = adds headers, Transparent = reveals IP
+
+
+ + +
+
Tor Exit Nodes
+
+
+ + +
+
Network Usage
+
+
+
Total RX
+
-
+
+
+
Total TX
+
-
+
+
+
Total
+
-
+
+
+
+
+
By Category
+
+
Proxy Testing-
+
Scraping-
+
+
+
+
Rates (avg)
+
+
RX Rate-
+
TX Rate-
+
+
+
+
Per Tor Node
+
+
+ + +
+
+
Search Engines
+
+
Available-
+
In Backoff-
+
Total-
+
+
Top Engines
+
+
+
+
+
+
SSL/TLS Security
+
+
SSL Tests-
+
Passed-
+
Failed-
+
+
MITM Detected-
+
Cert Errors-
+
+
+
+ +
+ + +
+ +
+
MITM Detection Summary
+
+
+
Total Detections
+
-
+
+
+
Unique Certs
+
-
+
+
+
Unique Proxies
+
-
+
+
+
SSL Tests
+
-
+
+
+
+
+
+
Top Organizations
+
+
+
+
+
+
Top Issuers
+
+
+
+
+
+
+
Certificate Details
+
+
+
+
Recent Detections
+
+
+
+ + +
+ +
+
Database Overview
+
+
+
Database Size
+
-
+
+
+
Tested (1h)
+
-
+
+
+
Added (24h)
+
-
+
+
+
Dead Proxies
+
-
+
+
+
+
+
Working by Protocol
+
+
+
+
+
+
Latency Stats
+
+
Average-
+
Min-
+
Max-
+
+
+
+
Activity
+
+
Failing-
+
Freelist-
+
+
+
+
+
+ +
PPF Python Proxy Finder
+
+ + + + + diff --git a/static/dashboard.js b/static/dashboard.js new file mode 100644 index 0000000..ecbc1ae --- /dev/null +++ b/static/dashboard.js @@ -0,0 +1,651 @@ +/* PPF Dashboard JavaScript */ +var $ = function(id) { return document.getElementById(id); }; +var $$ = function(sel) { return document.querySelectorAll(sel); }; +var fmt = function(n) { return n == null ? '-' : n.toLocaleString(); }; + +// uPlot chart instances (persistent) +var uplotCharts = {}; + +// Chart.js instances (persistent) +var chartJsInstances = {}; + +// Network rate tracking (for real-time speed calculation) +var prevNet = null; +var prevNetTime = null; + +// Tab switching +function initTabs() { + $$('.tab-btn').forEach(function(btn) { + btn.addEventListener('click', function() { + var tabId = this.dataset.tab; + // Update buttons + $$('.tab-btn').forEach(function(b) { b.classList.remove('active'); }); + this.classList.add('active'); + // Update content + $$('.tab-content').forEach(function(c) { c.classList.remove('active'); }); + var content = $('tab-' + tabId); + if (content) content.classList.add('active'); + // Save preference + try { localStorage.setItem('ppf-tab', tabId); } catch(e) {} + }); + }); + // Restore saved tab + try { + var saved = localStorage.getItem('ppf-tab'); + if (saved) { + var btn = document.querySelector('.tab-btn[data-tab="' + saved + '"]'); + if (btn) btn.click(); + } + } catch(e) {} +} +document.addEventListener('DOMContentLoaded', initTabs); + +// Theme toggle (cycles: dark -> muted-dark -> light -> dark) +var themes = ['dark', 'muted-dark', 'light']; +function getTheme() { + if (document.documentElement.classList.contains('light')) return 'light'; + if (document.documentElement.classList.contains('muted-dark')) return 'muted-dark'; + return 'dark'; +} +function setTheme(theme) { + document.documentElement.classList.remove('light', 'muted-dark'); + if (theme === 'light') document.documentElement.classList.add('light'); + else if (theme === 'muted-dark') document.documentElement.classList.add('muted-dark'); + try { localStorage.setItem('ppf-theme', theme); } catch(e) {} +} +function initTheme() { + // Check saved preference or system preference + var saved = null; + try { saved = localStorage.getItem('ppf-theme'); } catch(e) {} + if (saved && themes.indexOf(saved) !== -1) { + setTheme(saved); + } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { + setTheme('light'); + } + // Setup toggle button + var btn = document.getElementById('themeToggle'); + if (btn) { + btn.addEventListener('click', function() { + var current = getTheme(); + var idx = themes.indexOf(current); + var next = themes[(idx + 1) % themes.length]; + setTheme(next); + }); + } +} +document.addEventListener('DOMContentLoaded', initTheme); + +var fmtDec = function(n, d) { return n == null ? '-' : n.toFixed(d || 1); }; +var pct = function(n, t) { return t > 0 ? ((n / t) * 100).toFixed(1) : '0.0'; }; + +function fmtBytes(b) { + if (!b || b <= 0) return '-'; + var units = ['B', 'KB', 'MB', 'GB', 'TB']; + var i = 0; + while (b >= 1024 && i < units.length - 1) { b /= 1024; i++; } + return b.toFixed(i > 0 ? 1 : 0) + ' ' + units[i]; +} + +function fmtRate(bps) { + if (bps < 1) return '0'; + if (bps < 1024) return bps.toFixed(0) + 'B'; + if (bps < 1024 * 1024) return (bps / 1024).toFixed(1) + 'K'; + return (bps / (1024 * 1024)).toFixed(1) + 'M'; +} + +function fmtTime(s) { + if (!s) return '-'; + var d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600), m = Math.floor((s % 3600) / 60); + if (d > 0) return d + 'd ' + h + 'h'; + if (h > 0) return h + 'h ' + m + 'm'; + return m + 'm ' + Math.floor(s % 60) + 's'; +} + +function setBarColor(el, pct) { + if (pct > 90) return 'background:var(--red)'; + if (pct > 70) return 'background:var(--yellow)'; + return 'background:var(--green)'; +} + +function fmtMs(ms) { + if (!ms || ms <= 0) return '-'; + if (ms < 1000) return Math.round(ms) + 'ms'; + return (ms / 1000).toFixed(1) + 's'; +} + +function setBar(id, val, max, cls) { + var el = $(id); + if (el) { el.style.width = Math.min(val / max * 100, 100) + '%'; el.className = 'bar ' + (cls || 'grn'); } +} + +// uPlot-based line chart with electric cyan theme +function renderLineChart(id, data, color, maxVal) { + var el = $(id); if (!el || !data || data.length < 2) return; + var w = el.clientWidth || 300, h = el.clientHeight || 80; + var max = maxVal || Math.max.apply(null, data) || 1; + + // Generate time indices (mock timestamps, 3s apart) + var now = Date.now() / 1000; + var times = data.map(function(_, i) { return now - (data.length - 1 - i) * 3; }); + + var opts = { + width: w, + height: h, + padding: [4, 4, 4, 4], + cursor: { show: false }, + legend: { show: false }, + axes: [ + { show: false }, // x-axis hidden + { show: false } // y-axis hidden + ], + scales: { + x: { time: false }, + y: { range: [0, max * 1.1] } + }, + series: [ + {}, // x series (timestamps) + { + stroke: color, + width: 2, + fill: function(u, seriesIdx) { + var grad = u.ctx.createLinearGradient(0, 0, 0, h); + grad.addColorStop(0, color.replace(')', ',0.4)').replace('rgb', 'rgba')); + grad.addColorStop(1, color.replace(')', ',0.05)').replace('rgb', 'rgba')); + return grad; + } + } + ] + }; + + // Destroy existing chart if any + if (uplotCharts[id]) { + uplotCharts[id].destroy(); + } + el.innerHTML = ''; + uplotCharts[id] = new uPlot(opts, [times, data], el); +} + +// Chart.js doughnut chart with electric cyan theme +function renderDoughnutChart(id, labels, values, colors, cutout) { + var el = $(id); if (!el) return; + cutout = cutout || '65%'; + + // Convert div to canvas if needed + var canvas; + if (el.tagName !== 'CANVAS') { + canvas = el.querySelector('canvas'); + if (!canvas) { + canvas = document.createElement('canvas'); + el.innerHTML = ''; + el.appendChild(canvas); + } + } else { + canvas = el; + } + + var ctx = canvas.getContext('2d'); + var total = values.reduce(function(a, b) { return a + b; }, 0); + if (total === 0) return; + + // Destroy existing chart + if (chartJsInstances[id]) { + chartJsInstances[id].destroy(); + } + + chartJsInstances[id] = new Chart(ctx, { + type: 'doughnut', + data: { + labels: labels, + datasets: [{ + data: values, + backgroundColor: colors, + borderColor: 'rgba(24,31,42,0.8)', + borderWidth: 2, + hoverBorderColor: '#38bdf8', + hoverBorderWidth: 3 + }] + }, + options: { + responsive: true, + maintainAspectRatio: true, + cutout: cutout, + plugins: { + legend: { display: false }, + tooltip: { + backgroundColor: 'rgba(24,31,42,0.95)', + titleColor: '#38bdf8', + bodyColor: '#e6edf3', + borderColor: 'rgba(56,189,248,0.3)', + borderWidth: 1, + padding: 12, + displayColors: true, + callbacks: { + label: function(ctx) { + var pct = ((ctx.raw / total) * 100).toFixed(1); + return ctx.label + ': ' + fmt(ctx.raw) + ' (' + pct + '%)'; + } + } + } + }, + animation: { duration: 400, easing: 'easeOutQuart' } + } + }); +} + +function renderHistogram(id, data) { + var el = $(id); if (!el || !data || !data.length) return; + var max = Math.max.apply(null, data.map(function(d) { return d.pct; })) || 1; + var colors = ['#3fb950', '#3fb950', '#58a6ff', '#58a6ff', '#d29922', '#f85149', '#f85149']; + var html = ''; + data.forEach(function(d, i) { + var h = Math.max(4, (d.pct / max) * 100); + var c = colors[Math.min(i, colors.length - 1)]; + html += '
'; + }); + el.innerHTML = html; +} + +function renderLeaderboard(id, data, nameKey, valKey, limit) { + var el = $(id); if (!el) return; + limit = limit || 8; + if (!data || !data.length) { el.innerHTML = '
No data
'; return; } + var html = ''; + data.slice(0, limit).forEach(function(item, i) { + var name = Array.isArray(item) ? item[0] : item[nameKey]; + var val = Array.isArray(item) ? item[1] : item[valKey]; + html += '
' + (i + 1) + '
'; + html += '' + name + '' + fmt(val) + '
'; + }); + el.innerHTML = html; +} + +function update(d) { + $('dot').className = 'dot'; $('statusTxt').textContent = 'Live'; + + // SSL badge (main test mode when enabled) + var sslBadge = $('sslBadge'); + if (sslBadge) { + sslBadge.style.display = d.use_ssl ? 'inline-block' : 'none'; + } + // Check type badge (fallback/secondary indicator) + var ct = d.checktype || 'unknown'; + var ctBadge = $('checktypeBadge'); + if (ctBadge) { + ctBadge.textContent = ct.toUpperCase(); + ctBadge.className = 'mode-badge mode-' + ct; + } + // Profiling badge + var profBadge = $('profileBadge'); + if (profBadge) { + profBadge.style.display = d.profiling ? 'inline-block' : 'none'; + } + + // System monitor bar + var sys = d.system || {}; + $('sysLoad').textContent = (sys.load_1m || 0) + ' / ' + (sys.cpu_count || 1); + $('sysMemVal').textContent = fmtBytes(sys.mem_used) + ' / ' + fmtBytes(sys.mem_total); + $('sysMemPct').textContent = (sys.mem_pct || 0) + '%'; + var memFill = $('sysMemFill'); + if (memFill) { memFill.style.width = (sys.mem_pct || 0) + '%'; memFill.style.cssText = 'width:' + (sys.mem_pct || 0) + '%;' + setBarColor(memFill, sys.mem_pct || 0); } + $('sysDiskVal').textContent = fmtBytes(sys.disk_used) + ' / ' + fmtBytes(sys.disk_total); + $('sysDiskPct').textContent = (sys.disk_pct || 0) + '%'; + var diskFill = $('sysDiskFill'); + if (diskFill) { diskFill.style.width = (sys.disk_pct || 0) + '%'; diskFill.style.cssText = 'width:' + (sys.disk_pct || 0) + '%;' + setBarColor(diskFill, sys.disk_pct || 0); } + var memGrowth = sys.proc_rss_growth || 0; + var memGrowthStr = memGrowth > 0 ? ' (+' + fmtBytes(memGrowth) + ')' : ''; + $('sysProcMem').textContent = fmtBytes(sys.proc_rss) + memGrowthStr; + + // Network speed (current rate, not average) + var net = d.network || {}; + var now = Date.now(); + if (prevNet && prevNetTime) { + var dt = (now - prevNetTime) / 1000; + if (dt > 0) { + var s = net.scraper || {}, ps = prevNet.scraper || {}; + var p = net.proxy || {}, pp = prevNet.proxy || {}; + $('netScrapeTx').textContent = fmtRate((s.bytes_tx - (ps.bytes_tx || 0)) / dt); + $('netScrapeRx').textContent = fmtRate((s.bytes_rx - (ps.bytes_rx || 0)) / dt); + $('netProxyTx').textContent = fmtRate((p.bytes_tx - (pp.bytes_tx || 0)) / dt); + $('netProxyRx').textContent = fmtRate((p.bytes_rx - (pp.bytes_rx || 0)) / dt); + } + } + prevNet = net; + prevNetTime = now; + + // Main stats - db stats are nested under d.db + var db = d.db || {}; + $('working').textContent = fmt(db.working); + $('total').textContent = fmt(db.total); + $('tested').textContent = fmt(d.tested); + $('passed').textContent = fmt(d.passed); + $('failed').textContent = fmt(d.failed); + + // Success rate + var sr = d.success_rate || 0; + $('successRate').textContent = fmtDec(sr, 1) + '%'; + $('successRate').className = 'val-md ' + (sr < 20 ? 'red' : sr < 50 ? 'yel' : 'grn'); + setBar('srBar', sr, 100, sr < 20 ? 'red' : sr < 50 ? 'yel' : 'grn'); + + var rsr = d.recent_success_rate || 0; + $('recentSuccessRate').textContent = fmtDec(rsr, 1) + '%'; + $('recentSuccessRate').className = 'stat-val ' + (rsr < 20 ? 'red' : rsr < 50 ? 'yel' : 'grn'); + + // Rates + $('rate').textContent = fmtDec(d.recent_rate, 2); + $('recentRate').textContent = fmtDec(d.recent_rate, 2) + '/s'; + $('peakRate').textContent = fmtDec(d.peak_rate, 2) + '/s'; + $('passRate').textContent = fmtDec(d.pass_rate, 3); + + // Latency + var lat = d.avg_latency || 0; + $('avgLatency').textContent = fmtMs(lat); + $('minLatency').textContent = fmtMs(d.min_latency); + $('maxLatency').textContent = fmtMs(d.max_latency); + + var pctl = d.latency_percentiles || {}; + $('p50').textContent = fmtMs(pctl.p50); + $('p90').textContent = fmtMs(pctl.p90); + $('p99').textContent = fmtMs(pctl.p99); + + // System + $('threads').textContent = d.threads + '/' + d.max_threads; + setBar('threadBar', d.threads, d.max_threads, 'blu'); + $('queue').textContent = fmt(d.queue_size); + $('uptime').textContent = fmtTime(d.uptime_seconds); + + // Charts + renderLineChart('rateChart', d.rate_history, '#58a6ff', d.peak_rate * 1.1); + renderLineChart('srChart', d.success_rate_history, '#3fb950', 100); + renderHistogram('latencyHisto', d.latency_histogram); + + // Protocol breakdown + var ps = d.proto_stats || {}; + ['http', 'socks4', 'socks5'].forEach(function(p) { + var s = ps[p] || {passed: 0, tested: 0, success_rate: 0}; + $(p + 'Passed').textContent = fmt(s.passed); + $(p + 'Tested').textContent = fmt(s.tested); + var rateEl = $(p + 'Rate'); + rateEl.textContent = fmtDec(s.success_rate, 0) + '%'; + rateEl.className = 'proto-rate ' + (s.success_rate < 20 ? 'tag-err' : s.success_rate < 50 ? 'tag-warn' : 'tag-ok'); + }); + + // Results pie (Chart.js doughnut) + var passed = d.passed || 0, failed = d.failed || 0, total = passed + failed; + if (total > 0) { + renderDoughnutChart('resultsPie', ['Passed', 'Failed'], [passed, failed], ['#3fb950', '#f85149']); + } + $('passedLeg').textContent = fmt(passed); + $('passedPct').textContent = pct(passed, total) + '%'; + $('failedLeg').textContent = fmt(failed); + $('failedPct').textContent = pct(failed, total) + '%'; + + // Failures breakdown (Chart.js doughnut) + var fhtml = '', failColors = ['#f85149','#db6d28','#d29922','#58a6ff','#a371f7','#39c5cf','#db61a2','#7d8590']; + if (d.failures && Object.keys(d.failures).length > 0) { + var cats = Object.keys(d.failures).sort(function(a,b) { return d.failures[b] - d.failures[a]; }); + var failVals = cats.map(function(c) { return d.failures[c]; }); + var failCols = cats.map(function(_, i) { return failColors[i % failColors.length]; }); + renderDoughnutChart('failPie', cats, failVals, failCols); + cats.forEach(function(cat, i) { + var n = d.failures[cat], col = failColors[i % failColors.length]; + fhtml += '
'; + fhtml += '' + cat + '' + n + '
'; + }); + } else { + fhtml = '
No failures yet
'; + } + $('failLegend').innerHTML = fhtml; + + // Leaderboards (session data) + renderLeaderboard('topAsns', d.top_asns_session, 'asn', 'count'); + + // Country pie chart (Chart.js doughnut) + var countryColors = ['#58a6ff','#3fb950','#d29922','#f85149','#a371f7','#39c5cf','#db61a2','#db6d28','#7ee787','#7d8590']; + if (d.db && d.db.top_countries && d.db.top_countries.length > 0) { + var countries = d.db.top_countries.slice(0, 8); + var countryTotal = countries.reduce(function(s, c) { return s + (c.count || c[1] || 0); }, 0); + var cLabels = [], cValues = [], cColors = [], chtml = ''; + countries.forEach(function(c, i) { + var code = c.code || c[0], cnt = c.count || c[1] || 0; + var col = countryColors[i % countryColors.length]; + var pctVal = countryTotal > 0 ? ((cnt / countryTotal) * 100).toFixed(1) : '0'; + cLabels.push(code); + cValues.push(cnt); + cColors.push(col); + chtml += '
'; + chtml += '' + code + '' + fmt(cnt) + ''; + chtml += '' + pctVal + '%
'; + }); + renderDoughnutChart('countryPie', cLabels, cValues, cColors); + $('countryLegend').innerHTML = chtml; + } else { + $('countryLegend').innerHTML = '
No data
'; + } + + // Tor pool + var thtml = ''; + if (d.tor_pool && d.tor_pool.hosts) { + d.tor_pool.hosts.forEach(function(h) { + // Status: OK only if available AND has successes, WARN if available but 0%, DOWN if in backoff + var statusCls = !h.healthy ? 'tag-err' : (h.success_rate > 0 ? 'tag-ok' : 'tag-warn'); + var statusTxt = !h.healthy ? 'DOWN' : (h.success_rate > 0 ? 'OK' : 'IDLE'); + thtml += '
'; + thtml += '' + h.address + ''; + thtml += '' + statusTxt + ''; + thtml += '
' + fmtMs(h.latency_ms) + ' / ' + fmtDec(h.success_rate, 0) + '% success
'; + }); + } + $('torPool').innerHTML = thtml || '
No Tor hosts
'; + + // Judges + if (d.judges) { + $('judgesAvail').textContent = d.judges.available + '/' + d.judges.total; + $('judgesCooldown').textContent = d.judges.in_cooldown; + var jhtml = ''; + if (d.judges.top_judges) { + d.judges.top_judges.slice(0, 6).forEach(function(j) { + jhtml += '
' + j.judge + ''; + jhtml += '
' + j.success + '/' + j.tests + ''; + jhtml += '' + fmtDec(j.rate, 0) + '%
'; + }); + } + $('topJudges').innerHTML = jhtml || '
No data
'; + } + + // Database stats + if (d.db) { + var dbs = d.db; + $('dbByProto').innerHTML = ['http', 'socks4', 'socks5'].map(function(p) { + var c = dbs.by_proto && dbs.by_proto[p] || 0; + return '
' + p.toUpperCase() + '' + fmt(c) + '
'; + }).join(''); + + } + + // Scraper/Engine stats + $('engAvail').textContent = fmt(d.engines_available); + $('engBackoff').textContent = fmt(d.engines_backoff); + $('engTotal').textContent = fmt(d.engines_total); + if (d.scraper && d.scraper.engines) { + var ehtml = ''; + d.scraper.engines.slice(0, 5).forEach(function(e, i) { + var statusCls = e.available ? 'tag-ok' : 'tag-warn'; + var statusTxt = e.available ? 'OK' : (e.backoff_remaining > 0 ? e.backoff_remaining + 's' : 'OFF'); + ehtml += '
' + (i + 1) + '
'; + ehtml += '' + e.name + ''; + ehtml += '' + statusTxt + ''; + ehtml += '' + fmt(e.successes) + '
'; + }); + $('topEngines').innerHTML = ehtml || '
No engines
'; + } else { + $('topEngines').innerHTML = '
Scraper disabled
'; + } + + // SSL/TLS stats + if (d.ssl) { + var ssl = d.ssl; + $('sslTested').textContent = fmt(ssl.tested); + $('sslPassed').textContent = fmt(ssl.passed); + $('sslFailed').textContent = fmt(ssl.failed); + var sslRate = ssl.success_rate || 0; + setBar('sslBar', sslRate, 100, sslRate < 50 ? 'red' : sslRate < 80 ? 'yel' : 'grn'); + $('mitmDetected').textContent = fmt(ssl.mitm_detected); + $('mitmDetected').className = 'stat-val ' + (ssl.mitm_detected > 0 ? 'red' : 'grn'); + $('certErrors').textContent = fmt(ssl.cert_errors); + $('certErrors').className = 'stat-val ' + (ssl.cert_errors > 0 ? 'yel' : 'grn'); + } + + // Anonymity breakdown + var dbh = d.db_health || {}; + if (dbh.anonymity) { + var anonHtml = ''; + var anonColors = {elite: 'grn', anonymous: 'blu', transparent: 'yel', unknown: 'dim'}; + var anonOrder = ['elite', 'anonymous', 'transparent', 'unknown']; + anonOrder.forEach(function(level) { + var count = dbh.anonymity[level] || 0; + if (count > 0) { + anonHtml += '
' + level.charAt(0).toUpperCase() + level.slice(1) + ''; + anonHtml += '' + fmt(count) + '
'; + } + }); + $('anonBreakdown').innerHTML = anonHtml || '
No data
'; + } + + // Database health + if (dbh.db_size) { + $('dbSize').textContent = fmtBytes(dbh.db_size); + $('dbTestedHour').textContent = fmt(dbh.tested_last_hour); + $('dbAddedDay').textContent = fmt(dbh.added_last_day); + $('dbDead').textContent = fmt(dbh.dead_count); + $('dbFailing').textContent = fmt(dbh.failing_count); + $('dbFreelist').textContent = fmt(dbh.freelist_count); + $('dbAvgLat').textContent = fmtMs(dbh.db_avg_latency); + $('dbMinLat').textContent = fmtMs(dbh.db_min_latency); + $('dbMaxLat').textContent = fmtMs(dbh.db_max_latency); + } + + // Tor pool enhanced stats + if (d.tor_pool) { + var tp = d.tor_pool; + $('torTotal').textContent = fmt(tp.total_requests || 0); + $('torSuccess').textContent = fmtDec(tp.success_rate || 0, 1) + '%'; + $('torHealthy').textContent = (tp.healthy_count || 0) + '/' + (tp.total_count || 0); + if (tp.avg_latency) { + $('torLatency').textContent = fmtMs(tp.avg_latency); + } + } + + // MITM certificate stats + if (d.mitm) { + var mitm = d.mitm; + $('mitmTotal').textContent = fmt(mitm.total_detections || 0); + $('mitmUniqueCerts').textContent = fmt(mitm.unique_certs || 0); + $('mitmUniqueProxies').textContent = fmt(mitm.unique_proxies || 0); + $('mitmSslTests').textContent = d.ssl ? fmt(d.ssl.tested || 0) : '-'; + + // Top organizations + var orgsHtml = ''; + if (mitm.top_organizations && mitm.top_organizations.length > 0) { + mitm.top_organizations.slice(0, 8).forEach(function(org, i) { + orgsHtml += '
' + (i + 1) + '
'; + orgsHtml += '' + (org.name || 'Unknown') + ''; + orgsHtml += '' + fmt(org.count) + '
'; + }); + } else { + orgsHtml = '
No MITM certs detected
'; + } + $('mitmOrgs').innerHTML = orgsHtml; + + // Top issuers + var issHtml = ''; + if (mitm.top_issuers && mitm.top_issuers.length > 0) { + mitm.top_issuers.slice(0, 8).forEach(function(iss, i) { + issHtml += '
' + (i + 1) + '
'; + issHtml += '' + (iss.name || 'Unknown') + ''; + issHtml += '' + fmt(iss.count) + '
'; + }); + } else { + issHtml = '
No MITM certs detected
'; + } + $('mitmIssuers').innerHTML = issHtml; + + // Certificate details + var certHtml = ''; + if (mitm.certificates && mitm.certificates.length > 0) { + mitm.certificates.slice(0, 10).forEach(function(cert) { + certHtml += '
'; + certHtml += '
'; + certHtml += 'CN: ' + (cert.subject_cn || '-') + ''; + certHtml += '
'; + certHtml += '
Org: ' + (cert.subject_o || '-') + '
'; + certHtml += '
Issuer: ' + (cert.issuer_cn || '-') + '
'; + certHtml += '
Count: ' + fmt(cert.count || 1) + '
'; + certHtml += '
Proxies: ' + (cert.proxies ? cert.proxies.length : 0) + '
'; + certHtml += '
FP: ' + (cert.fingerprint || '-') + '
'; + certHtml += '
'; + }); + } else { + certHtml = '
No MITM certificates captured yet
'; + } + $('mitmCerts').innerHTML = certHtml; + + // Recent detections + var recentHtml = ''; + if (mitm.recent && mitm.recent.length > 0) { + mitm.recent.slice(-10).reverse().forEach(function(r) { + var ts = r.timestamp ? new Date(r.timestamp * 1000).toLocaleTimeString() : '-'; + recentHtml += '
'; + recentHtml += '' + ts + ''; + recentHtml += '' + (r.proxy || '-') + ''; + recentHtml += '' + (r.subject_cn || '-') + ''; + recentHtml += '
'; + }); + } else { + recentHtml = '
No recent MITM detections
'; + } + $('mitmRecent').innerHTML = recentHtml; + } + + // Network usage stats + if (d.network) { + var net = d.network; + $('netRx').textContent = fmtBytes(net.bytes_rx || 0); + $('netTx').textContent = fmtBytes(net.bytes_tx || 0); + $('netTotal').textContent = fmtBytes(net.bytes_total || 0); + $('netRxRate').textContent = fmtBytes(net.rx_rate || 0) + '/s'; + $('netTxRate').textContent = fmtBytes(net.tx_rate || 0) + '/s'; + if (net.proxy) { + $('netProxy').textContent = fmtBytes(net.proxy.bytes_total || 0); + } + if (net.scraper) { + $('netScraper').textContent = fmtBytes(net.scraper.bytes_total || 0); + } + // Per-tor-node stats + var torContainer = $('netTorNodes'); + if (torContainer && net.tor_nodes) { + var html = ''; + var nodes = Object.keys(net.tor_nodes).sort(); + nodes.forEach(function(node) { + var s = net.tor_nodes[node]; + html += '
'; + html += '
' + node + '
'; + html += '
' + fmtBytes(s.rx + s.tx) + '
'; + html += '
' + fmt(s.requests || 0) + ' req
'; + html += '
'; + }); + torContainer.innerHTML = html; + } + } + + $('lastUpdate').textContent = new Date().toLocaleTimeString(); +} + +function fetchStats() { + fetch('/api/stats') + .then(function(r) { return r.json(); }) + .then(update) + .catch(function(e) { $('dot').className = 'dot err'; $('statusTxt').textContent = 'Error'; }); +} + +fetchStats(); +setInterval(fetchStats, 3000); diff --git a/static/lib/MarkerCluster.Default.css b/static/lib/MarkerCluster.Default.css new file mode 100644 index 0000000..bbc8c9f --- /dev/null +++ b/static/lib/MarkerCluster.Default.css @@ -0,0 +1,60 @@ +.marker-cluster-small { + background-color: rgba(181, 226, 140, 0.6); + } +.marker-cluster-small div { + background-color: rgba(110, 204, 57, 0.6); + } + +.marker-cluster-medium { + background-color: rgba(241, 211, 87, 0.6); + } +.marker-cluster-medium div { + background-color: rgba(240, 194, 12, 0.6); + } + +.marker-cluster-large { + background-color: rgba(253, 156, 115, 0.6); + } +.marker-cluster-large div { + background-color: rgba(241, 128, 23, 0.6); + } + + /* IE 6-8 fallback colors */ +.leaflet-oldie .marker-cluster-small { + background-color: rgb(181, 226, 140); + } +.leaflet-oldie .marker-cluster-small div { + background-color: rgb(110, 204, 57); + } + +.leaflet-oldie .marker-cluster-medium { + background-color: rgb(241, 211, 87); + } +.leaflet-oldie .marker-cluster-medium div { + background-color: rgb(240, 194, 12); + } + +.leaflet-oldie .marker-cluster-large { + background-color: rgb(253, 156, 115); + } +.leaflet-oldie .marker-cluster-large div { + background-color: rgb(241, 128, 23); +} + +.marker-cluster { + background-clip: padding-box; + border-radius: 20px; + } +.marker-cluster div { + width: 30px; + height: 30px; + margin-left: 5px; + margin-top: 5px; + + text-align: center; + border-radius: 15px; + font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif; + } +.marker-cluster span { + line-height: 30px; + } \ No newline at end of file diff --git a/static/lib/MarkerCluster.css b/static/lib/MarkerCluster.css new file mode 100644 index 0000000..c60d71b --- /dev/null +++ b/static/lib/MarkerCluster.css @@ -0,0 +1,14 @@ +.leaflet-cluster-anim .leaflet-marker-icon, .leaflet-cluster-anim .leaflet-marker-shadow { + -webkit-transition: -webkit-transform 0.3s ease-out, opacity 0.3s ease-in; + -moz-transition: -moz-transform 0.3s ease-out, opacity 0.3s ease-in; + -o-transition: -o-transform 0.3s ease-out, opacity 0.3s ease-in; + transition: transform 0.3s ease-out, opacity 0.3s ease-in; +} + +.leaflet-cluster-spider-leg { + /* stroke-dashoffset (duration and function) should match with leaflet-marker-icon transform in order to track it exactly */ + -webkit-transition: -webkit-stroke-dashoffset 0.3s ease-out, -webkit-stroke-opacity 0.3s ease-in; + -moz-transition: -moz-stroke-dashoffset 0.3s ease-out, -moz-stroke-opacity 0.3s ease-in; + -o-transition: -o-stroke-dashoffset 0.3s ease-out, -o-stroke-opacity 0.3s ease-in; + transition: stroke-dashoffset 0.3s ease-out, stroke-opacity 0.3s ease-in; +} diff --git a/static/lib/chart.min.js b/static/lib/chart.min.js new file mode 100644 index 0000000..78c4e5d --- /dev/null +++ b/static/lib/chart.min.js @@ -0,0 +1,20 @@ +/** + * Skipped minification because the original files appears to be already minified. + * Original file: /npm/chart.js@4.4.1/dist/chart.umd.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +/*! + * Chart.js v4.4.1 + * https://www.chartjs.org + * (c) 2023 Chart.js Contributors + * Released under the MIT License + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Chart=e()}(this,(function(){"use strict";var t=Object.freeze({__proto__:null,get Colors(){return Go},get Decimation(){return Qo},get Filler(){return ma},get Legend(){return ya},get SubTitle(){return ka},get Title(){return Ma},get Tooltip(){return Ba}});function e(){}const i=(()=>{let t=0;return()=>t++})();function s(t){return null==t}function n(t){if(Array.isArray&&Array.isArray(t))return!0;const e=Object.prototype.toString.call(t);return"[object"===e.slice(0,7)&&"Array]"===e.slice(-6)}function o(t){return null!==t&&"[object Object]"===Object.prototype.toString.call(t)}function a(t){return("number"==typeof t||t instanceof Number)&&isFinite(+t)}function r(t,e){return a(t)?t:e}function l(t,e){return void 0===t?e:t}const h=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100:+t/e,c=(t,e)=>"string"==typeof t&&t.endsWith("%")?parseFloat(t)/100*e:+t;function d(t,e,i){if(t&&"function"==typeof t.call)return t.apply(i,e)}function u(t,e,i,s){let a,r,l;if(n(t))if(r=t.length,s)for(a=r-1;a>=0;a--)e.call(i,t[a],a);else for(a=0;at,x:t=>t.x,y:t=>t.y};function v(t){const e=t.split("."),i=[];let s="";for(const t of e)s+=t,s.endsWith("\\")?s=s.slice(0,-1)+".":(i.push(s),s="");return i}function M(t,e){const i=y[e]||(y[e]=function(t){const e=v(t);return t=>{for(const i of e){if(""===i)break;t=t&&t[i]}return t}}(e));return i(t)}function w(t){return t.charAt(0).toUpperCase()+t.slice(1)}const k=t=>void 0!==t,S=t=>"function"==typeof t,P=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0};function D(t){return"mouseup"===t.type||"click"===t.type||"contextmenu"===t.type}const C=Math.PI,O=2*C,A=O+C,T=Number.POSITIVE_INFINITY,L=C/180,E=C/2,R=C/4,I=2*C/3,z=Math.log10,F=Math.sign;function V(t,e,i){return Math.abs(t-e)t-e)).pop(),e}function N(t){return!isNaN(parseFloat(t))&&isFinite(t)}function H(t,e){const i=Math.round(t);return i-e<=t&&i+e>=t}function j(t,e,i){let s,n,o;for(s=0,n=t.length;sl&&h=Math.min(e,i)-s&&t<=Math.max(e,i)+s}function et(t,e,i){i=i||(i=>t[i]1;)s=o+n>>1,i(s)?o=s:n=s;return{lo:o,hi:n}}const it=(t,e,i,s)=>et(t,i,s?s=>{const n=t[s][e];return nt[s][e]et(t,i,(s=>t[s][e]>=i));function nt(t,e,i){let s=0,n=t.length;for(;ss&&t[n-1]>i;)n--;return s>0||n{const i="_onData"+w(e),s=t[e];Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value(...e){const n=s.apply(this,e);return t._chartjs.listeners.forEach((t=>{"function"==typeof t[i]&&t[i](...e)})),n}})})))}function rt(t,e){const i=t._chartjs;if(!i)return;const s=i.listeners,n=s.indexOf(e);-1!==n&&s.splice(n,1),s.length>0||(ot.forEach((e=>{delete t[e]})),delete t._chartjs)}function lt(t){const e=new Set(t);return e.size===t.length?t:Array.from(e)}const ht="undefined"==typeof window?function(t){return t()}:window.requestAnimationFrame;function ct(t,e){let i=[],s=!1;return function(...n){i=n,s||(s=!0,ht.call(window,(()=>{s=!1,t.apply(e,i)})))}}function dt(t,e){let i;return function(...s){return e?(clearTimeout(i),i=setTimeout(t,e,s)):t.apply(this,s),e}}const ut=t=>"start"===t?"left":"end"===t?"right":"center",ft=(t,e,i)=>"start"===t?e:"end"===t?i:(e+i)/2,gt=(t,e,i,s)=>t===(s?"left":"right")?i:"center"===t?(e+i)/2:e;function pt(t,e,i){const s=e.length;let n=0,o=s;if(t._sorted){const{iScale:a,_parsed:r}=t,l=a.axis,{min:h,max:c,minDefined:d,maxDefined:u}=a.getUserBounds();d&&(n=J(Math.min(it(r,l,h).lo,i?s:it(e,l,a.getPixelForValue(h)).lo),0,s-1)),o=u?J(Math.max(it(r,a.axis,c,!0).hi+1,i?0:it(e,l,a.getPixelForValue(c),!0).hi+1),n,s)-n:s-n}return{start:n,count:o}}function mt(t){const{xScale:e,yScale:i,_scaleRanges:s}=t,n={xmin:e.min,xmax:e.max,ymin:i.min,ymax:i.max};if(!s)return t._scaleRanges=n,!0;const o=s.xmin!==e.min||s.xmax!==e.max||s.ymin!==i.min||s.ymax!==i.max;return Object.assign(s,n),o}class bt{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,e,i,s){const n=e.listeners[s],o=e.duration;n.forEach((s=>s({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(i-e.start,o)})))}_refresh(){this._request||(this._running=!0,this._request=ht.call(window,(()=>{this._update(),this._request=null,this._running&&this._refresh()})))}_update(t=Date.now()){let e=0;this._charts.forEach(((i,s)=>{if(!i.running||!i.items.length)return;const n=i.items;let o,a=n.length-1,r=!1;for(;a>=0;--a)o=n[a],o._active?(o._total>i.duration&&(i.duration=o._total),o.tick(t),r=!0):(n[a]=n[n.length-1],n.pop());r&&(s.draw(),this._notify(s,i,t,"progress")),n.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),e+=n.length})),this._lastDate=t,0===e&&(this._running=!1)}_getAnims(t){const e=this._charts;let i=e.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},e.set(t,i)),i}listen(t,e,i){this._getAnims(t).listeners[e].push(i)}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(((t,e)=>Math.max(t,e._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 i=e.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();e.items=[],this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var xt=new bt; +/*! + * @kurkle/color v0.3.2 + * https://github.com/kurkle/color#readme + * (c) 2023 Jukka Kurkela + * Released under the MIT License + */function _t(t){return t+.5|0}const yt=(t,e,i)=>Math.max(Math.min(t,i),e);function vt(t){return yt(_t(2.55*t),0,255)}function Mt(t){return yt(_t(255*t),0,255)}function wt(t){return yt(_t(t/2.55)/100,0,1)}function kt(t){return yt(_t(100*t),0,100)}const St={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},Pt=[..."0123456789ABCDEF"],Dt=t=>Pt[15&t],Ct=t=>Pt[(240&t)>>4]+Pt[15&t],Ot=t=>(240&t)>>4==(15&t);function At(t){var e=(t=>Ot(t.r)&&Ot(t.g)&&Ot(t.b)&&Ot(t.a))(t)?Dt:Ct;return t?"#"+e(t.r)+e(t.g)+e(t.b)+((t,e)=>t<255?e(t):"")(t.a,e):void 0}const Tt=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Lt(t,e,i){const s=e*Math.min(i,1-i),n=(e,n=(e+t/30)%12)=>i-s*Math.max(Math.min(n-3,9-n,1),-1);return[n(0),n(8),n(4)]}function Et(t,e,i){const s=(s,n=(s+t/60)%6)=>i-i*e*Math.max(Math.min(n,4-n,1),0);return[s(5),s(3),s(1)]}function Rt(t,e,i){const s=Lt(t,1,.5);let n;for(e+i>1&&(n=1/(e+i),e*=n,i*=n),n=0;n<3;n++)s[n]*=1-e-i,s[n]+=e;return s}function It(t){const e=t.r/255,i=t.g/255,s=t.b/255,n=Math.max(e,i,s),o=Math.min(e,i,s),a=(n+o)/2;let r,l,h;return n!==o&&(h=n-o,l=a>.5?h/(2-n-o):h/(n+o),r=function(t,e,i,s,n){return t===n?(e-i)/s+(e>16&255,o>>8&255,255&o]}return t}(),Ht.transparent=[0,0,0,0]);const e=Ht[t.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:4===e.length?e[3]:255}}const $t=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;const Yt=t=>t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055,Ut=t=>t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4);function Xt(t,e,i){if(t){let s=It(t);s[e]=Math.max(0,Math.min(s[e]+s[e]*i,0===e?360:1)),s=Ft(s),t.r=s[0],t.g=s[1],t.b=s[2]}}function qt(t,e){return t?Object.assign(e||{},t):t}function Kt(t){var e={r:0,g:0,b:0,a:255};return Array.isArray(t)?t.length>=3&&(e={r:t[0],g:t[1],b:t[2],a:255},t.length>3&&(e.a=Mt(t[3]))):(e=qt(t,{r:0,g:0,b:0,a:1})).a=Mt(e.a),e}function Gt(t){return"r"===t.charAt(0)?function(t){const e=$t.exec(t);let i,s,n,o=255;if(e){if(e[7]!==i){const t=+e[7];o=e[8]?vt(t):yt(255*t,0,255)}return i=+e[1],s=+e[3],n=+e[5],i=255&(e[2]?vt(i):yt(i,0,255)),s=255&(e[4]?vt(s):yt(s,0,255)),n=255&(e[6]?vt(n):yt(n,0,255)),{r:i,g:s,b:n,a:o}}}(t):Bt(t)}class Zt{constructor(t){if(t instanceof Zt)return t;const e=typeof t;let i;var s,n,o;"object"===e?i=Kt(t):"string"===e&&(o=(s=t).length,"#"===s[0]&&(4===o||5===o?n={r:255&17*St[s[1]],g:255&17*St[s[2]],b:255&17*St[s[3]],a:5===o?17*St[s[4]]:255}:7!==o&&9!==o||(n={r:St[s[1]]<<4|St[s[2]],g:St[s[3]]<<4|St[s[4]],b:St[s[5]]<<4|St[s[6]],a:9===o?St[s[7]]<<4|St[s[8]]:255})),i=n||jt(t)||Gt(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=qt(this._rgb);return t&&(t.a=wt(t.a)),t}set rgb(t){this._rgb=Kt(t)}rgbString(){return this._valid?(t=this._rgb)&&(t.a<255?`rgba(${t.r}, ${t.g}, ${t.b}, ${wt(t.a)})`:`rgb(${t.r}, ${t.g}, ${t.b})`):void 0;var t}hexString(){return this._valid?At(this._rgb):void 0}hslString(){return this._valid?function(t){if(!t)return;const e=It(t),i=e[0],s=kt(e[1]),n=kt(e[2]);return t.a<255?`hsla(${i}, ${s}%, ${n}%, ${wt(t.a)})`:`hsl(${i}, ${s}%, ${n}%)`}(this._rgb):void 0}mix(t,e){if(t){const i=this.rgb,s=t.rgb;let n;const o=e===n?.5:e,a=2*o-1,r=i.a-s.a,l=((a*r==-1?a:(a+r)/(1+a*r))+1)/2;n=1-l,i.r=255&l*i.r+n*s.r+.5,i.g=255&l*i.g+n*s.g+.5,i.b=255&l*i.b+n*s.b+.5,i.a=o*i.a+(1-o)*s.a,this.rgb=i}return this}interpolate(t,e){return t&&(this._rgb=function(t,e,i){const s=Ut(wt(t.r)),n=Ut(wt(t.g)),o=Ut(wt(t.b));return{r:Mt(Yt(s+i*(Ut(wt(e.r))-s))),g:Mt(Yt(n+i*(Ut(wt(e.g))-n))),b:Mt(Yt(o+i*(Ut(wt(e.b))-o))),a:t.a+i*(e.a-t.a)}}(this._rgb,t._rgb,e)),this}clone(){return new Zt(this.rgb)}alpha(t){return this._rgb.a=Mt(t),this}clearer(t){return this._rgb.a*=1-t,this}greyscale(){const t=this._rgb,e=_t(.3*t.r+.59*t.g+.11*t.b);return t.r=t.g=t.b=e,this}opaquer(t){return this._rgb.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 Xt(this._rgb,2,t),this}darken(t){return Xt(this._rgb,2,-t),this}saturate(t){return Xt(this._rgb,1,t),this}desaturate(t){return Xt(this._rgb,1,-t),this}rotate(t){return function(t,e){var i=It(t);i[0]=Vt(i[0]+e),i=Ft(i),t.r=i[0],t.g=i[1],t.b=i[2]}(this._rgb,t),this}}function Jt(t){if(t&&"object"==typeof t){const e=t.toString();return"[object CanvasPattern]"===e||"[object CanvasGradient]"===e}return!1}function Qt(t){return Jt(t)?t:new Zt(t)}function te(t){return Jt(t)?t:new Zt(t).saturate(.5).darken(.1).hexString()}const ee=["x","y","borderWidth","radius","tension"],ie=["color","borderColor","backgroundColor"];const se=new Map;function ne(t,e,i){return function(t,e){e=e||{};const i=t+JSON.stringify(e);let s=se.get(i);return s||(s=new Intl.NumberFormat(t,e),se.set(i,s)),s}(e,i).format(t)}const oe={values:t=>n(t)?t:""+t,numeric(t,e,i){if(0===t)return"0";const s=this.chart.options.locale;let n,o=t;if(i.length>1){const e=Math.max(Math.abs(i[0].value),Math.abs(i[i.length-1].value));(e<1e-4||e>1e15)&&(n="scientific"),o=function(t,e){let i=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;Math.abs(i)>=1&&t!==Math.floor(t)&&(i=t-Math.floor(t));return i}(t,i)}const a=z(Math.abs(o)),r=isNaN(a)?1:Math.max(Math.min(-1*Math.floor(a),20),0),l={notation:n,minimumFractionDigits:r,maximumFractionDigits:r};return Object.assign(l,this.options.ticks.format),ne(t,s,l)},logarithmic(t,e,i){if(0===t)return"0";const s=i[e].significand||t/Math.pow(10,Math.floor(z(t)));return[1,2,3,5,10,15].includes(s)||e>.8*i.length?oe.numeric.call(this,t,e,i):""}};var ae={formatters:oe};const re=Object.create(null),le=Object.create(null);function he(t,e){if(!e)return t;const i=e.split(".");for(let e=0,s=i.length;et.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=(t,e)=>te(e.backgroundColor),this.hoverBorderColor=(t,e)=>te(e.borderColor),this.hoverColor=(t,e)=>te(e.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 ce(this,t,e)}get(t){return he(this,t)}describe(t,e){return ce(le,t,e)}override(t,e){return ce(re,t,e)}route(t,e,i,s){const n=he(this,t),a=he(this,i),r="_"+e;Object.defineProperties(n,{[r]:{value:n[e],writable:!0},[e]:{enumerable:!0,get(){const t=this[r],e=a[s];return o(t)?Object.assign({},e,t):l(t,e)},set(t){this[r]=t}}})}apply(t){t.forEach((t=>t(this)))}}var ue=new de({_scriptable:t=>!t.startsWith("on"),_indexable:t=>"events"!==t,hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[function(t){t.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),t.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>"onProgress"!==t&&"onComplete"!==t&&"fn"!==t}),t.set("animations",{colors:{type:"color",properties:ie},numbers:{type:"number",properties:ee}}),t.describe("animations",{_fallback:"animation"}),t.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=>0|t}}}})},function(t){t.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})},function(t){t.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:ae.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),t.route("scale.ticks","color","","color"),t.route("scale.grid","color","","borderColor"),t.route("scale.border","color","","borderColor"),t.route("scale.title","color","","color"),t.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&"callback"!==t&&"parser"!==t,_indexable:t=>"borderDash"!==t&&"tickBorderDash"!==t&&"dash"!==t}),t.describe("scales",{_fallback:"scale"}),t.describe("scale.ticks",{_scriptable:t=>"backdropPadding"!==t&&"callback"!==t,_indexable:t=>"backdropPadding"!==t})}]);function fe(){return"undefined"!=typeof window&&"undefined"!=typeof document}function ge(t){let e=t.parentNode;return e&&"[object ShadowRoot]"===e.toString()&&(e=e.host),e}function pe(t,e,i){let s;return"string"==typeof t?(s=parseInt(t,10),-1!==t.indexOf("%")&&(s=s/100*e.parentNode[i])):s=t,s}const me=t=>t.ownerDocument.defaultView.getComputedStyle(t,null);function be(t,e){return me(t).getPropertyValue(e)}const xe=["top","right","bottom","left"];function _e(t,e,i){const s={};i=i?"-"+i:"";for(let n=0;n<4;n++){const o=xe[n];s[o]=parseFloat(t[e+"-"+o+i])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const ye=(t,e,i)=>(t>0||e>0)&&(!i||!i.shadowRoot);function ve(t,e){if("native"in t)return t;const{canvas:i,currentDevicePixelRatio:s}=e,n=me(i),o="border-box"===n.boxSizing,a=_e(n,"padding"),r=_e(n,"border","width"),{x:l,y:h,box:c}=function(t,e){const i=t.touches,s=i&&i.length?i[0]:t,{offsetX:n,offsetY:o}=s;let a,r,l=!1;if(ye(n,o,t.target))a=n,r=o;else{const t=e.getBoundingClientRect();a=s.clientX-t.left,r=s.clientY-t.top,l=!0}return{x:a,y:r,box:l}}(t,i),d=a.left+(c&&r.left),u=a.top+(c&&r.top);let{width:f,height:g}=e;return o&&(f-=a.width+r.width,g-=a.height+r.height),{x:Math.round((l-d)/f*i.width/s),y:Math.round((h-u)/g*i.height/s)}}const Me=t=>Math.round(10*t)/10;function we(t,e,i,s){const n=me(t),o=_e(n,"margin"),a=pe(n.maxWidth,t,"clientWidth")||T,r=pe(n.maxHeight,t,"clientHeight")||T,l=function(t,e,i){let s,n;if(void 0===e||void 0===i){const o=ge(t);if(o){const t=o.getBoundingClientRect(),a=me(o),r=_e(a,"border","width"),l=_e(a,"padding");e=t.width-l.width-r.width,i=t.height-l.height-r.height,s=pe(a.maxWidth,o,"clientWidth"),n=pe(a.maxHeight,o,"clientHeight")}else e=t.clientWidth,i=t.clientHeight}return{width:e,height:i,maxWidth:s||T,maxHeight:n||T}}(t,e,i);let{width:h,height:c}=l;if("content-box"===n.boxSizing){const t=_e(n,"border","width"),e=_e(n,"padding");h-=e.width+t.width,c-=e.height+t.height}h=Math.max(0,h-o.width),c=Math.max(0,s?h/s:c-o.height),h=Me(Math.min(h,a,l.maxWidth)),c=Me(Math.min(c,r,l.maxHeight)),h&&!c&&(c=Me(h/2));return(void 0!==e||void 0!==i)&&s&&l.height&&c>l.height&&(c=l.height,h=Me(Math.floor(c*s))),{width:h,height:c}}function ke(t,e,i){const s=e||1,n=Math.floor(t.height*s),o=Math.floor(t.width*s);t.height=Math.floor(t.height),t.width=Math.floor(t.width);const a=t.canvas;return a.style&&(i||!a.style.height&&!a.style.width)&&(a.style.height=`${t.height}px`,a.style.width=`${t.width}px`),(t.currentDevicePixelRatio!==s||a.height!==n||a.width!==o)&&(t.currentDevicePixelRatio=s,a.height=n,a.width=o,t.ctx.setTransform(s,0,0,s,0,0),!0)}const Se=function(){let t=!1;try{const e={get passive(){return t=!0,!1}};fe()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch(t){}return t}();function Pe(t,e){const i=be(t,e),s=i&&i.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function De(t){return!t||s(t.size)||s(t.family)?null:(t.style?t.style+" ":"")+(t.weight?t.weight+" ":"")+t.size+"px "+t.family}function Ce(t,e,i,s,n){let o=e[n];return o||(o=e[n]=t.measureText(n).width,i.push(n)),o>s&&(s=o),s}function Oe(t,e,i,s){let o=(s=s||{}).data=s.data||{},a=s.garbageCollect=s.garbageCollect||[];s.font!==e&&(o=s.data={},a=s.garbageCollect=[],s.font=e),t.save(),t.font=e;let r=0;const l=i.length;let h,c,d,u,f;for(h=0;hi.length){for(h=0;h0&&t.stroke()}}function Re(t,e,i){return i=i||.5,!e||t&&t.x>e.left-i&&t.xe.top-i&&t.y0&&""!==r.strokeColor;let c,d;for(t.save(),t.font=a.string,function(t,e){e.translation&&t.translate(e.translation[0],e.translation[1]),s(e.rotation)||t.rotate(e.rotation),e.color&&(t.fillStyle=e.color),e.textAlign&&(t.textAlign=e.textAlign),e.textBaseline&&(t.textBaseline=e.textBaseline)}(t,r),c=0;ct[0])){const o=i||t;void 0===s&&(s=ti("_fallback",t));const a={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:t,_rootScopes:o,_fallback:s,_getTarget:n,override:i=>je([i,...t],e,o,s)};return new Proxy(a,{deleteProperty:(e,i)=>(delete e[i],delete e._keys,delete t[0][i],!0),get:(i,s)=>qe(i,s,(()=>function(t,e,i,s){let n;for(const o of e)if(n=ti(Ue(o,t),i),void 0!==n)return Xe(t,n)?Je(i,s,t,n):n}(s,e,t,i))),getOwnPropertyDescriptor:(t,e)=>Reflect.getOwnPropertyDescriptor(t._scopes[0],e),getPrototypeOf:()=>Reflect.getPrototypeOf(t[0]),has:(t,e)=>ei(t).includes(e),ownKeys:t=>ei(t),set(t,e,i){const s=t._storage||(t._storage=n());return t[e]=s[e]=i,delete t._keys,!0}})}function $e(t,e,i,s){const a={_cacheable:!1,_proxy:t,_context:e,_subProxy:i,_stack:new Set,_descriptors:Ye(t,s),setContext:e=>$e(t,e,i,s),override:n=>$e(t.override(n),e,i,s)};return new Proxy(a,{deleteProperty:(e,i)=>(delete e[i],delete t[i],!0),get:(t,e,i)=>qe(t,e,(()=>function(t,e,i){const{_proxy:s,_context:a,_subProxy:r,_descriptors:l}=t;let h=s[e];S(h)&&l.isScriptable(e)&&(h=function(t,e,i,s){const{_proxy:n,_context:o,_subProxy:a,_stack:r}=i;if(r.has(t))throw new Error("Recursion detected: "+Array.from(r).join("->")+"->"+t);r.add(t);let l=e(o,a||s);r.delete(t),Xe(t,l)&&(l=Je(n._scopes,n,t,l));return l}(e,h,t,i));n(h)&&h.length&&(h=function(t,e,i,s){const{_proxy:n,_context:a,_subProxy:r,_descriptors:l}=i;if(void 0!==a.index&&s(t))return e[a.index%e.length];if(o(e[0])){const i=e,s=n._scopes.filter((t=>t!==i));e=[];for(const o of i){const i=Je(s,n,t,o);e.push($e(i,a,r&&r[t],l))}}return e}(e,h,t,l.isIndexable));Xe(e,h)&&(h=$e(h,a,r&&r[e],l));return h}(t,e,i))),getOwnPropertyDescriptor:(e,i)=>e._descriptors.allKeys?Reflect.has(t,i)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(t,i),getPrototypeOf:()=>Reflect.getPrototypeOf(t),has:(e,i)=>Reflect.has(t,i),ownKeys:()=>Reflect.ownKeys(t),set:(e,i,s)=>(t[i]=s,delete e[i],!0)})}function Ye(t,e={scriptable:!0,indexable:!0}){const{_scriptable:i=e.scriptable,_indexable:s=e.indexable,_allKeys:n=e.allKeys}=t;return{allKeys:n,scriptable:i,indexable:s,isScriptable:S(i)?i:()=>i,isIndexable:S(s)?s:()=>s}}const Ue=(t,e)=>t?t+w(e):e,Xe=(t,e)=>o(e)&&"adapters"!==t&&(null===Object.getPrototypeOf(e)||e.constructor===Object);function qe(t,e,i){if(Object.prototype.hasOwnProperty.call(t,e))return t[e];const s=i();return t[e]=s,s}function Ke(t,e,i){return S(t)?t(e,i):t}const Ge=(t,e)=>!0===t?e:"string"==typeof t?M(e,t):void 0;function Ze(t,e,i,s,n){for(const o of e){const e=Ge(i,o);if(e){t.add(e);const o=Ke(e._fallback,i,n);if(void 0!==o&&o!==i&&o!==s)return o}else if(!1===e&&void 0!==s&&i!==s)return null}return!1}function Je(t,e,i,s){const a=e._rootScopes,r=Ke(e._fallback,i,s),l=[...t,...a],h=new Set;h.add(s);let c=Qe(h,l,i,r||i,s);return null!==c&&((void 0===r||r===i||(c=Qe(h,l,r,c,s),null!==c))&&je(Array.from(h),[""],a,r,(()=>function(t,e,i){const s=t._getTarget();e in s||(s[e]={});const a=s[e];if(n(a)&&o(i))return i;return a||{}}(e,i,s))))}function Qe(t,e,i,s,n){for(;i;)i=Ze(t,e,i,s,n);return i}function ti(t,e){for(const i of e){if(!i)continue;const e=i[t];if(void 0!==e)return e}}function ei(t){let e=t._keys;return e||(e=t._keys=function(t){const e=new Set;for(const i of t)for(const t of Object.keys(i).filter((t=>!t.startsWith("_"))))e.add(t);return Array.from(e)}(t._scopes)),e}function ii(t,e,i,s){const{iScale:n}=t,{key:o="r"}=this._parsing,a=new Array(s);let r,l,h,c;for(r=0,l=s;re"x"===t?"y":"x";function ai(t,e,i,s){const n=t.skip?e:t,o=e,a=i.skip?e:i,r=q(o,n),l=q(a,o);let h=r/(r+l),c=l/(r+l);h=isNaN(h)?0:h,c=isNaN(c)?0:c;const d=s*h,u=s*c;return{previous:{x:o.x-d*(a.x-n.x),y:o.y-d*(a.y-n.y)},next:{x:o.x+u*(a.x-n.x),y:o.y+u*(a.y-n.y)}}}function ri(t,e="x"){const i=oi(e),s=t.length,n=Array(s).fill(0),o=Array(s);let a,r,l,h=ni(t,0);for(a=0;a!t.skip))),"monotone"===e.cubicInterpolationMode)ri(t,n);else{let i=s?t[t.length-1]:t[0];for(o=0,a=t.length;o0===t||1===t,di=(t,e,i)=>-Math.pow(2,10*(t-=1))*Math.sin((t-e)*O/i),ui=(t,e,i)=>Math.pow(2,-10*t)*Math.sin((t-e)*O/i)+1,fi={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>-t*(t-2),easeInOutQuad:t=>(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1),easeInCubic:t=>t*t*t,easeOutCubic:t=>(t-=1)*t*t+1,easeInOutCubic:t=>(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2),easeInQuart:t=>t*t*t*t,easeOutQuart:t=>-((t-=1)*t*t*t-1),easeInOutQuart:t=>(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2),easeInQuint:t=>t*t*t*t*t,easeOutQuint:t=>(t-=1)*t*t*t*t+1,easeInOutQuint:t=>(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2),easeInSine:t=>1-Math.cos(t*E),easeOutSine:t=>Math.sin(t*E),easeInOutSine:t=>-.5*(Math.cos(C*t)-1),easeInExpo:t=>0===t?0:Math.pow(2,10*(t-1)),easeOutExpo:t=>1===t?1:1-Math.pow(2,-10*t),easeInOutExpo:t=>ci(t)?t:t<.5?.5*Math.pow(2,10*(2*t-1)):.5*(2-Math.pow(2,-10*(2*t-1))),easeInCirc:t=>t>=1?t:-(Math.sqrt(1-t*t)-1),easeOutCirc:t=>Math.sqrt(1-(t-=1)*t),easeInOutCirc:t=>(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1),easeInElastic:t=>ci(t)?t:di(t,.075,.3),easeOutElastic:t=>ci(t)?t:ui(t,.075,.3),easeInOutElastic(t){const e=.1125;return ci(t)?t:t<.5?.5*di(2*t,e,.45):.5+.5*ui(2*t-1,e,.45)},easeInBack(t){const e=1.70158;return t*t*((e+1)*t-e)},easeOutBack(t){const e=1.70158;return(t-=1)*t*((e+1)*t+e)+1},easeInOutBack(t){let e=1.70158;return(t/=.5)<1?t*t*((1+(e*=1.525))*t-e)*.5:.5*((t-=2)*t*((1+(e*=1.525))*t+e)+2)},easeInBounce:t=>1-fi.easeOutBounce(1-t),easeOutBounce(t){const e=7.5625,i=2.75;return t<1/i?e*t*t:t<2/i?e*(t-=1.5/i)*t+.75:t<2.5/i?e*(t-=2.25/i)*t+.9375:e*(t-=2.625/i)*t+.984375},easeInOutBounce:t=>t<.5?.5*fi.easeInBounce(2*t):.5*fi.easeOutBounce(2*t-1)+.5};function gi(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}function pi(t,e,i,s){return{x:t.x+i*(e.x-t.x),y:"middle"===s?i<.5?t.y:e.y:"after"===s?i<1?t.y:e.y:i>0?e.y:t.y}}function mi(t,e,i,s){const n={x:t.cp2x,y:t.cp2y},o={x:e.cp1x,y:e.cp1y},a=gi(t,n,i),r=gi(n,o,i),l=gi(o,e,i),h=gi(a,r,i),c=gi(r,l,i);return gi(h,c,i)}const bi=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,xi=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function _i(t,e){const i=(""+t).match(bi);if(!i||"normal"===i[1])return 1.2*e;switch(t=+i[2],i[3]){case"px":return t;case"%":t/=100}return e*t}const yi=t=>+t||0;function vi(t,e){const i={},s=o(e),n=s?Object.keys(e):e,a=o(t)?s?i=>l(t[i],t[e[i]]):e=>t[e]:()=>t;for(const t of n)i[t]=yi(a(t));return i}function Mi(t){return vi(t,{top:"y",right:"x",bottom:"y",left:"x"})}function wi(t){return vi(t,["topLeft","topRight","bottomLeft","bottomRight"])}function ki(t){const e=Mi(t);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function Si(t,e){t=t||{},e=e||ue.font;let i=l(t.size,e.size);"string"==typeof i&&(i=parseInt(i,10));let s=l(t.style,e.style);s&&!(""+s).match(xi)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const n={family:l(t.family,e.family),lineHeight:_i(l(t.lineHeight,e.lineHeight),i),size:i,style:s,weight:l(t.weight,e.weight),string:""};return n.string=De(n),n}function Pi(t,e,i,s){let o,a,r,l=!0;for(o=0,a=t.length;oi&&0===t?0:t+e;return{min:a(s,-Math.abs(o)),max:a(n,o)}}function Ci(t,e){return Object.assign(Object.create(t),e)}function Oi(t,e,i){return t?function(t,e){return{x:i=>t+t+e-i,setWidth(t){e=t},textAlign:t=>"center"===t?t:"right"===t?"left":"right",xPlus:(t,e)=>t-e,leftForLtr:(t,e)=>t-e}}(e,i):{x:t=>t,setWidth(t){},textAlign:t=>t,xPlus:(t,e)=>t+e,leftForLtr:(t,e)=>t}}function Ai(t,e){let i,s;"ltr"!==e&&"rtl"!==e||(i=t.canvas.style,s=[i.getPropertyValue("direction"),i.getPropertyPriority("direction")],i.setProperty("direction",e,"important"),t.prevTextDirection=s)}function Ti(t,e){void 0!==e&&(delete t.prevTextDirection,t.canvas.style.setProperty("direction",e[0],e[1]))}function Li(t){return"angle"===t?{between:Z,compare:K,normalize:G}:{between:tt,compare:(t,e)=>t-e,normalize:t=>t}}function Ei({start:t,end:e,count:i,loop:s,style:n}){return{start:t%i,end:e%i,loop:s&&(e-t+1)%i==0,style:n}}function Ri(t,e,i){if(!i)return[t];const{property:s,start:n,end:o}=i,a=e.length,{compare:r,between:l,normalize:h}=Li(s),{start:c,end:d,loop:u,style:f}=function(t,e,i){const{property:s,start:n,end:o}=i,{between:a,normalize:r}=Li(s),l=e.length;let h,c,{start:d,end:u,loop:f}=t;if(f){for(d+=l,u+=l,h=0,c=l;hx||l(n,b,p)&&0!==r(n,b),v=()=>!x||0===r(o,p)||l(o,b,p);for(let t=c,i=c;t<=d;++t)m=e[t%a],m.skip||(p=h(m[s]),p!==b&&(x=l(p,n,o),null===_&&y()&&(_=0===r(p,n)?t:i),null!==_&&v()&&(g.push(Ei({start:_,end:t,loop:u,count:a,style:f})),_=null),i=t,b=p));return null!==_&&g.push(Ei({start:_,end:d,loop:u,count:a,style:f})),g}function Ii(t,e){const i=[],s=t.segments;for(let n=0;nn&&t[o%e].skip;)o--;return o%=e,{start:n,end:o}}(i,n,o,s);if(!0===s)return Fi(t,[{start:a,end:r,loop:o}],i,e);return Fi(t,function(t,e,i,s){const n=t.length,o=[];let a,r=e,l=t[e];for(a=e+1;a<=i;++a){const i=t[a%n];i.skip||i.stop?l.skip||(s=!1,o.push({start:e%n,end:(a-1)%n,loop:s}),e=r=i.stop?a:null):(r=a,l.skip&&(e=a)),l=i}return null!==r&&o.push({start:e%n,end:r%n,loop:s}),o}(i,a,r{t[a](e[i],n)&&(o.push({element:t,datasetIndex:s,index:l}),r=r||t.inRange(e.x,e.y,n))})),s&&!r?[]:o}var Xi={evaluateInteractionItems:Hi,modes:{index(t,e,i,s){const n=ve(e,t),o=i.axis||"x",a=i.includeInvisible||!1,r=i.intersect?ji(t,n,o,s,a):Yi(t,n,o,!1,s,a),l=[];return r.length?(t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index,i=t.data[e];i&&!i.skip&&l.push({element:i,datasetIndex:t.index,index:e})})),l):[]},dataset(t,e,i,s){const n=ve(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;let r=i.intersect?ji(t,n,o,s,a):Yi(t,n,o,!1,s,a);if(r.length>0){const e=r[0].datasetIndex,i=t.getDatasetMeta(e).data;r=[];for(let t=0;tji(t,ve(e,t),i.axis||"xy",s,i.includeInvisible||!1),nearest(t,e,i,s){const n=ve(e,t),o=i.axis||"xy",a=i.includeInvisible||!1;return Yi(t,n,o,i.intersect,s,a)},x:(t,e,i,s)=>Ui(t,ve(e,t),"x",i.intersect,s),y:(t,e,i,s)=>Ui(t,ve(e,t),"y",i.intersect,s)}};const qi=["left","top","right","bottom"];function Ki(t,e){return t.filter((t=>t.pos===e))}function Gi(t,e){return t.filter((t=>-1===qi.indexOf(t.pos)&&t.box.axis===e))}function Zi(t,e){return t.sort(((t,i)=>{const s=e?i:t,n=e?t:i;return s.weight===n.weight?s.index-n.index:s.weight-n.weight}))}function Ji(t,e){const i=function(t){const e={};for(const i of t){const{stack:t,pos:s,stackWeight:n}=i;if(!t||!qi.includes(s))continue;const o=e[t]||(e[t]={count:0,placed:0,weight:0,size:0});o.count++,o.weight+=n}return e}(t),{vBoxMaxWidth:s,hBoxMaxHeight:n}=e;let o,a,r;for(o=0,a=t.length;o{s[t]=Math.max(e[t],i[t])})),s}return s(t?["left","right"]:["top","bottom"])}function ss(t,e,i,s){const n=[];let o,a,r,l,h,c;for(o=0,a=t.length,h=0;ot.box.fullSize)),!0),s=Zi(Ki(e,"left"),!0),n=Zi(Ki(e,"right")),o=Zi(Ki(e,"top"),!0),a=Zi(Ki(e,"bottom")),r=Gi(e,"x"),l=Gi(e,"y");return{fullSize:i,leftAndTop:s.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:Ki(e,"chartArea"),vertical:s.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}(t.boxes),l=r.vertical,h=r.horizontal;u(t.boxes,(t=>{"function"==typeof t.beforeLayout&&t.beforeLayout()}));const c=l.reduce(((t,e)=>e.box.options&&!1===e.box.options.display?t:t+1),0)||1,d=Object.freeze({outerWidth:e,outerHeight:i,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/c,hBoxMaxHeight:a/2}),f=Object.assign({},n);ts(f,ki(s));const g=Object.assign({maxPadding:f,w:o,h:a,x:n.left,y:n.top},n),p=Ji(l.concat(h),d);ss(r.fullSize,g,d,p),ss(l,g,d,p),ss(h,g,d,p)&&ss(l,g,d,p),function(t){const e=t.maxPadding;function i(i){const s=Math.max(e[i]-t[i],0);return t[i]+=s,s}t.y+=i("top"),t.x+=i("left"),i("right"),i("bottom")}(g),os(r.leftAndTop,g,d,p),g.x+=g.w,g.y+=g.h,os(r.rightAndBottom,g,d,p),t.chartArea={left:g.left,top:g.top,right:g.left+g.w,bottom:g.top+g.h,height:g.h,width:g.w},u(r.chartArea,(e=>{const i=e.box;Object.assign(i,t.chartArea),i.update(g.w,g.h,{left:0,top:0,right:0,bottom:0})}))}};class rs{acquireContext(t,e){}releaseContext(t){return!1}addEventListener(t,e,i){}removeEventListener(t,e,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,i,s){return e=Math.max(0,e||t.width),i=i||t.height,{width:e,height:Math.max(0,s?Math.floor(e/s):i)}}isAttached(t){return!0}updateConfig(t){}}class ls extends rs{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const hs="$chartjs",cs={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},ds=t=>null===t||""===t;const us=!!Se&&{passive:!0};function fs(t,e,i){t.canvas.removeEventListener(e,i,us)}function gs(t,e){for(const i of t)if(i===e||i.contains(e))return!0}function ps(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||gs(i.addedNodes,s),e=e&&!gs(i.removedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}function ms(t,e,i){const s=t.canvas,n=new MutationObserver((t=>{let e=!1;for(const i of t)e=e||gs(i.removedNodes,s),e=e&&!gs(i.addedNodes,s);e&&i()}));return n.observe(document,{childList:!0,subtree:!0}),n}const bs=new Map;let xs=0;function _s(){const t=window.devicePixelRatio;t!==xs&&(xs=t,bs.forEach(((e,i)=>{i.currentDevicePixelRatio!==t&&e()})))}function ys(t,e,i){const s=t.canvas,n=s&&ge(s);if(!n)return;const o=ct(((t,e)=>{const s=n.clientWidth;i(t,e),s{const e=t[0],i=e.contentRect.width,s=e.contentRect.height;0===i&&0===s||o(i,s)}));return a.observe(n),function(t,e){bs.size||window.addEventListener("resize",_s),bs.set(t,e)}(t,o),a}function vs(t,e,i){i&&i.disconnect(),"resize"===e&&function(t){bs.delete(t),bs.size||window.removeEventListener("resize",_s)}(t)}function Ms(t,e,i){const s=t.canvas,n=ct((e=>{null!==t.ctx&&i(function(t,e){const i=cs[t.type]||t.type,{x:s,y:n}=ve(t,e);return{type:i,chart:e,native:t,x:void 0!==s?s:null,y:void 0!==n?n:null}}(e,t))}),t);return function(t,e,i){t.addEventListener(e,i,us)}(s,e,n),n}class ws extends rs{acquireContext(t,e){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(function(t,e){const i=t.style,s=t.getAttribute("height"),n=t.getAttribute("width");if(t[hs]={initial:{height:s,width:n,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",i.boxSizing=i.boxSizing||"border-box",ds(n)){const e=Pe(t,"width");void 0!==e&&(t.width=e)}if(ds(s))if(""===t.style.height)t.height=t.width/(e||2);else{const e=Pe(t,"height");void 0!==e&&(t.height=e)}}(t,e),i):null}releaseContext(t){const e=t.canvas;if(!e[hs])return!1;const i=e[hs].initial;["height","width"].forEach((t=>{const n=i[t];s(n)?e.removeAttribute(t):e.setAttribute(t,n)}));const n=i.style||{};return Object.keys(n).forEach((t=>{e.style[t]=n[t]})),e.width=e.width,delete e[hs],!0}addEventListener(t,e,i){this.removeEventListener(t,e);const s=t.$proxies||(t.$proxies={}),n={attach:ps,detach:ms,resize:ys}[e]||Ms;s[e]=n(t,e,i)}removeEventListener(t,e){const i=t.$proxies||(t.$proxies={}),s=i[e];if(!s)return;({attach:vs,detach:vs,resize:vs}[e]||fs)(t,e,s),i[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,i,s){return we(t,e,i,s)}isAttached(t){const e=ge(t);return!(!e||!e.isConnected)}}function ks(t){return!fe()||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas?ls:ws}var Ss=Object.freeze({__proto__:null,BasePlatform:rs,BasicPlatform:ls,DomPlatform:ws,_detectPlatform:ks});const Ps="transparent",Ds={boolean:(t,e,i)=>i>.5?e:t,color(t,e,i){const s=Qt(t||Ps),n=s.valid&&Qt(e||Ps);return n&&n.valid?n.mix(s,i).hexString():e},number:(t,e,i)=>t+(e-t)*i};class Cs{constructor(t,e,i,s){const n=e[i];s=Pi([t.to,s,n,t.from]);const o=Pi([t.from,n,s]);this._active=!0,this._fn=t.fn||Ds[t.type||typeof o],this._easing=fi[t.easing]||fi.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=i,this._from=o,this._to=s,this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(!1);const s=this._target[this._prop],n=i-this._start,o=this._duration-n;this._start=i,this._duration=Math.floor(Math.max(o,t.duration)),this._total+=n,this._loop=!!t.loop,this._to=Pi([t.to,e,s,t.from]),this._from=Pi([t.from,s,e])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const e=t-this._start,i=this._duration,s=this._prop,n=this._from,o=this._loop,a=this._to;let r;if(this._active=n!==a&&(o||e1?2-r:r,r=this._easing(Math.min(1,Math.max(0,r))),this._target[s]=this._fn(n,a,r))}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,i)=>{t.push({res:e,rej:i})}))}_notify(t){const e=t?"res":"rej",i=this._promises||[];for(let t=0;t{const a=t[s];if(!o(a))return;const r={};for(const t of e)r[t]=a[t];(n(a.properties)&&a.properties||[s]).forEach((t=>{t!==s&&i.has(t)||i.set(t,r)}))}))}_animateOptions(t,e){const i=e.options,s=function(t,e){if(!e)return;let i=t.options;if(!i)return void(t.options=e);i.$shared&&(t.options=i=Object.assign({},i,{$shared:!1,$animations:{}}));return i}(t,i);if(!s)return[];const n=this._createAnimations(s,i);return i.$shared&&function(t,e){const i=[],s=Object.keys(e);for(let e=0;e{t.options=i}),(()=>{})),n}_createAnimations(t,e){const i=this._properties,s=[],n=t.$animations||(t.$animations={}),o=Object.keys(e),a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if("$"===l.charAt(0))continue;if("options"===l){s.push(...this._animateOptions(t,e));continue}const h=e[l];let c=n[l];const d=i.get(l);if(c){if(d&&c.active()){c.update(d,h,a);continue}c.cancel()}d&&d.duration?(n[l]=c=new Cs(d,t,l,h),s.push(c)):t[l]=h}return s}update(t,e){if(0===this._properties.size)return void Object.assign(t,e);const i=this._createAnimations(t,e);return i.length?(xt.add(this._chart,i),!0):void 0}}function As(t,e){const i=t&&t.options||{},s=i.reverse,n=void 0===i.min?e:0,o=void 0===i.max?e:0;return{start:s?o:n,end:s?n:o}}function Ts(t,e){const i=[],s=t._getSortedDatasetMetas(e);let n,o;for(n=0,o=s.length;n0||!i&&e<0)return n.index}return null}function zs(t,e){const{chart:i,_cachedMeta:s}=t,n=i._stacks||(i._stacks={}),{iScale:o,vScale:a,index:r}=s,l=o.axis,h=a.axis,c=function(t,e,i){return`${t.id}.${e.id}.${i.stack||i.type}`}(o,a,s),d=e.length;let u;for(let t=0;ti[t].axis===e)).shift()}function Vs(t,e){const i=t.controller.index,s=t.vScale&&t.vScale.axis;if(s){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||void 0===e[s]||void 0===e[s][i])return;delete e[s][i],void 0!==e[s]._visualValues&&void 0!==e[s]._visualValues[i]&&delete e[s]._visualValues[i]}}}const Bs=t=>"reset"===t||"none"===t,Ws=(t,e)=>e?t:Object.assign({},t);class Ns{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=Es(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&&Vs(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,e=this._cachedMeta,i=this.getDataset(),s=(t,e,i,s)=>"x"===t?e:"r"===t?s:i,n=e.xAxisID=l(i.xAxisID,Fs(t,"x")),o=e.yAxisID=l(i.yAxisID,Fs(t,"y")),a=e.rAxisID=l(i.rAxisID,Fs(t,"r")),r=e.indexAxis,h=e.iAxisID=s(r,n,o,a),c=e.vAxisID=s(r,o,n,a);e.xScale=this.getScaleForId(n),e.yScale=this.getScaleForId(o),e.rScale=this.getScaleForId(a),e.iScale=this.getScaleForId(h),e.vScale=this.getScaleForId(c)}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&&rt(this._data,this),t._stacked&&Vs(t)}_dataCheck(){const t=this.getDataset(),e=t.data||(t.data=[]),i=this._data;if(o(e))this._data=function(t){const e=Object.keys(t),i=new Array(e.length);let s,n,o;for(s=0,n=e.length;s0&&i._parsed[t-1];if(!1===this._parsing)i._parsed=s,i._sorted=!0,d=s;else{d=n(s[t])?this.parseArrayData(i,s,t,e):o(s[t])?this.parseObjectData(i,s,t,e):this.parsePrimitiveData(i,s,t,e);const a=()=>null===c[l]||f&&c[l]t&&!e.hidden&&e._stacked&&{keys:Ts(i,!0),values:null})(e,i,this.chart),h={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:d}=function(t){const{min:e,max:i,minDefined:s,maxDefined:n}=t.getUserBounds();return{min:s?e:Number.NEGATIVE_INFINITY,max:n?i:Number.POSITIVE_INFINITY}}(r);let u,f;function g(){f=s[u];const e=f[r.axis];return!a(f[t.axis])||c>e||d=0;--u)if(!g()){this.updateRangeFromParsed(h,t,f,l);break}return h}getAllParsedValues(t){const e=this._cachedMeta._parsed,i=[];let s,n,o;for(s=0,n=e.length;s=0&&tthis.getContext(i,s,e)),c);return f.$shared&&(f.$shared=r,n[o]=Object.freeze(Ws(f,r))),f}_resolveAnimations(t,e,i){const s=this.chart,n=this._cachedDataOpts,o=`animation-${e}`,a=n[o];if(a)return a;let r;if(!1!==s.options.animation){const s=this.chart.config,n=s.datasetAnimationScopeKeys(this._type,e),o=s.getOptionScopes(this.getDataset(),n);r=s.createResolver(o,this.getContext(t,i,e))}const l=new Os(s,r&&r.animations);return r&&r._cacheable&&(n[o]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||Bs(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const i=this.resolveDataElementOptions(t,e),s=this._sharedOptions,n=this.getSharedOptions(i),o=this.includeOptions(e,n)||n!==s;return this.updateSharedOptions(n,e,i),{sharedOptions:n,includeOptions:o}}updateElement(t,e,i,s){Bs(s)?Object.assign(t,i):this._resolveAnimations(e,s).update(t,i)}updateSharedOptions(t,e,i){t&&!Bs(e)&&this._resolveAnimations(void 0,e).update(t,i)}_setStyle(t,e,i,s){t.active=s;const n=this.getStyle(e,s);this._resolveAnimations(e,i,s).update(t,{options:!s&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,e,i){this._setStyle(t,i,"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,i=this._cachedMeta.data;for(const[t,e,i]of this._syncList)this[t](e,i);this._syncList=[];const s=i.length,n=e.length,o=Math.min(n,s);o&&this.parse(0,o),n>s?this._insertElements(s,n-s,t):n{for(t.length+=e,a=t.length-1;a>=o;a--)t[a]=t[a-e]};for(r(n),a=t;a{s[t]=i[t]&&i[t].active()?i[t]._to:this[t]})),s}}function js(t,e){const i=t.options.ticks,n=function(t){const e=t.options.offset,i=t._tickSize(),s=t._length/i+(e?0:1),n=t._maxLength/i;return Math.floor(Math.min(s,n))}(t),o=Math.min(i.maxTicksLimit||n,n),a=i.major.enabled?function(t){const e=[];let i,s;for(i=0,s=t.length;io)return function(t,e,i,s){let n,o=0,a=i[0];for(s=Math.ceil(s),n=0;nn)return e}return Math.max(n,1)}(a,e,o);if(r>0){let t,i;const n=r>1?Math.round((h-l)/(r-1)):null;for($s(e,c,d,s(n)?0:l-n,l),t=0,i=r-1;t"top"===e||"left"===e?t[e]+i:t[e]-i,Us=(t,e)=>Math.min(e||t,t);function Xs(t,e){const i=[],s=t.length/e,n=t.length;let o=0;for(;oa+r)))return h}function Ks(t){return t.drawTicks?t.tickLength:0}function Gs(t,e){if(!t.display)return 0;const i=Si(t.font,e),s=ki(t.padding);return(n(t.text)?t.text.length:1)*i.lineHeight+s.height}function Zs(t,e,i){let s=ut(t);return(i&&"right"!==e||!i&&"right"===e)&&(s=(t=>"left"===t?"right":"right"===t?"left":t)(s)),s}class Js extends Hs{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,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._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,e){return t}getUserBounds(){let{_userMin:t,_userMax:e,_suggestedMin:i,_suggestedMax:s}=this;return t=r(t,Number.POSITIVE_INFINITY),e=r(e,Number.NEGATIVE_INFINITY),i=r(i,Number.POSITIVE_INFINITY),s=r(s,Number.NEGATIVE_INFINITY),{min:r(t,i),max:r(e,s),minDefined:a(t),maxDefined:a(e)}}getMinMax(t){let e,{min:i,max:s,minDefined:n,maxDefined:o}=this.getUserBounds();if(n&&o)return{min:i,max:s};const a=this.getMatchingVisibleMetas();for(let r=0,l=a.length;rs?s:i,s=n&&i>s?i:s,{min:r(i,r(s,i)),max:r(s,r(i,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(){d(this.options.beforeUpdate,[this])}update(t,e,i){const{beginAtZero:s,grace:n,ticks:o}=this.options,a=o.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=e,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Di(this,n,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const r=a=n||i<=1||!this.isHorizontal())return void(this.labelRotation=s);const h=this._getLabelSizes(),c=h.widest.width,d=h.highest.height,u=J(this.chart.width-c,0,this.maxWidth);o=t.offset?this.maxWidth/i:u/(i-1),c+6>o&&(o=u/(i-(t.offset?.5:1)),a=this.maxHeight-Ks(t.grid)-e.padding-Gs(t.title,this.chart.options.font),r=Math.sqrt(c*c+d*d),l=Y(Math.min(Math.asin(J((h.highest.height+6)/o,-1,1)),Math.asin(J(a/r,-1,1))-Math.asin(J(d/r,-1,1)))),l=Math.max(s,Math.min(n,l))),this.labelRotation=l}afterCalculateLabelRotation(){d(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){d(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:e,options:{ticks:i,title:s,grid:n}}=this,o=this._isVisible(),a=this.isHorizontal();if(o){const o=Gs(s,e.options.font);if(a?(t.width=this.maxWidth,t.height=Ks(n)+o):(t.height=this.maxHeight,t.width=Ks(n)+o),i.display&&this.ticks.length){const{first:e,last:s,widest:n,highest:o}=this._getLabelSizes(),r=2*i.padding,l=$(this.labelRotation),h=Math.cos(l),c=Math.sin(l);if(a){const e=i.mirror?0:c*n.width+h*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=i.mirror?0:h*n.width+c*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,s,c,h)}}this._handleMargins(),a?(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,i,s){const{ticks:{align:n,padding:o},position:a}=this.options,r=0!==this.labelRotation,l="top"!==a&&"x"===this.axis;if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let c=0,d=0;r?l?(c=s*t.width,d=i*e.height):(c=i*t.height,d=s*e.width):"start"===n?d=e.width:"end"===n?c=t.width:"inner"!==n&&(c=t.width/2,d=e.width/2),this.paddingLeft=Math.max((c-a+o)*this.width/(this.width-a),0),this.paddingRight=Math.max((d-h+o)*this.width/(this.width-h),0)}else{let i=e.height/2,s=t.height/2;"start"===n?(i=0,s=t.height):"end"===n&&(i=e.height,s=0),this.paddingTop=i+o,this.paddingBottom=s+o}}_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(){d(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return"top"===e||"bottom"===e||"x"===t}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){let e,i;for(this.beforeTickToLabelConversion(),this.generateTickLabels(t),e=0,i=t.length;e{const i=t.gc,s=i.length/2;let n;if(s>e){for(n=0;n({width:r[t]||0,height:l[t]||0});return{first:P(0),last:P(e-1),widest:P(k),highest:P(S),widths:r,heights:l}}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 Q(this._alignToPixels?Ae(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&&ta*s?a/i:r/s:r*s0}_computeGridLineItems(t){const e=this.axis,i=this.chart,s=this.options,{grid:n,position:a,border:r}=s,h=n.offset,c=this.isHorizontal(),d=this.ticks.length+(h?1:0),u=Ks(n),f=[],g=r.setContext(this.getContext()),p=g.display?g.width:0,m=p/2,b=function(t){return Ae(i,t,p)};let x,_,y,v,M,w,k,S,P,D,C,O;if("top"===a)x=b(this.bottom),w=this.bottom-u,S=x-m,D=b(t.top)+m,O=t.bottom;else if("bottom"===a)x=b(this.top),D=t.top,O=b(t.bottom)-m,w=x+m,S=this.top+u;else if("left"===a)x=b(this.right),M=this.right-u,k=x-m,P=b(t.left)+m,C=t.right;else if("right"===a)x=b(this.left),P=t.left,C=b(t.right)-m,M=x+m,k=this.left+u;else if("x"===e){if("center"===a)x=b((t.top+t.bottom)/2+.5);else if(o(a)){const t=Object.keys(a)[0],e=a[t];x=b(this.chart.scales[t].getPixelForValue(e))}D=t.top,O=t.bottom,w=x+m,S=w+u}else if("y"===e){if("center"===a)x=b((t.left+t.right)/2);else if(o(a)){const t=Object.keys(a)[0],e=a[t];x=b(this.chart.scales[t].getPixelForValue(e))}M=x-m,k=M-u,P=t.left,C=t.right}const A=l(s.ticks.maxTicksLimit,d),T=Math.max(1,Math.ceil(d/A));for(_=0;_0&&(o-=s/2)}d={left:o,top:n,width:s+e.width,height:i+e.height,color:t.backdropColor}}b.push({label:v,font:P,textOffset:O,options:{rotation:m,color:i,strokeColor:o,strokeWidth:h,textAlign:f,textBaseline:A,translation:[M,w],backdrop:d}})}return b}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;if(-$(this.labelRotation))return"top"===t?"left":"right";let i="center";return"start"===e.align?i="left":"end"===e.align?i="right":"inner"===e.align&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:i,mirror:s,padding:n}}=this.options,o=t+n,a=this._getLabelSizes().widest.width;let r,l;return"left"===e?s?(l=this.right+n,"near"===i?r="left":"center"===i?(r="center",l+=a/2):(r="right",l+=a)):(l=this.right-o,"near"===i?r="right":"center"===i?(r="center",l-=a/2):(r="left",l=this.left)):"right"===e?s?(l=this.left+n,"near"===i?r="right":"center"===i?(r="center",l-=a/2):(r="left",l-=a)):(l=this.left+o,"near"===i?r="left":"center"===i?(r="center",l+=a/2):(r="right",l=this.right)):r="right",{textAlign:r,x:l}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,e=this.options.position;return"left"===e||"right"===e?{top:0,left:this.left,bottom:t.height,right:this.right}:"top"===e||"bottom"===e?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:i,top:s,width:n,height:o}=this;e&&(t.save(),t.fillStyle=e,t.fillRect(i,s,n,o),t.restore())}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const i=this.ticks.findIndex((e=>e.value===t));if(i>=0){return e.setContext(this.getContext(i)).lineWidth}return 0}drawGrid(t){const e=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,s)=>{s.width&&s.color&&(i.save(),i.lineWidth=s.width,i.strokeStyle=s.color,i.setLineDash(s.borderDash||[]),i.lineDashOffset=s.borderDashOffset,i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke(),i.restore())};if(e.display)for(n=0,o=s.length;n{this.drawBackground(),this.drawGrid(t),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let n,o;for(n=0,o=e.length;n{const s=i.split("."),n=s.pop(),o=[t].concat(s).join("."),a=e[i].split("."),r=a.pop(),l=a.join(".");ue.route(o,n,l,r)}))}(e,t.defaultRoutes);t.descriptors&&ue.describe(e,t.descriptors)}(t,o,i),this.override&&ue.override(t.id,t.overrides)),o}get(t){return this.items[t]}unregister(t){const e=this.items,i=t.id,s=this.scope;i in e&&delete e[i],s&&i in ue[s]&&(delete ue[s][i],this.override&&delete re[i])}}class tn{constructor(){this.controllers=new Qs(Ns,"datasets",!0),this.elements=new Qs(Hs,"elements"),this.plugins=new Qs(Object,"plugins"),this.scales=new Qs(Js,"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,i){[...e].forEach((e=>{const s=i||this._getRegistryForType(e);i||s.isForType(e)||s===this.plugins&&e.id?this._exec(t,s,e):u(e,(e=>{const s=i||this._getRegistryForType(e);this._exec(t,s,e)}))}))}_exec(t,e,i){const s=w(t);d(i["before"+s],[],i),e[t](i),d(i["after"+s],[],i)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(s(e,i),t,"stop"),this._notify(s(i,e),t,"start")}}function nn(t,e){return e||!1!==t?!0===t?{}:t:null}function on(t,{plugin:e,local:i},s,n){const o=t.pluginScopeKeys(e),a=t.getOptionScopes(s,o);return i&&e.defaults&&a.push(e.defaults),t.createResolver(a,n,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function an(t,e){const i=ue.datasets[t]||{};return((e.datasets||{})[t]||{}).indexAxis||e.indexAxis||i.indexAxis||"x"}function rn(t){if("x"===t||"y"===t||"r"===t)return t}function ln(t,...e){if(rn(t))return t;for(const s of e){const e=s.axis||("top"===(i=s.position)||"bottom"===i?"x":"left"===i||"right"===i?"y":void 0)||t.length>1&&rn(t[0].toLowerCase());if(e)return e}var i;throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function hn(t,e,i){if(i[e+"AxisID"]===t)return{axis:e}}function cn(t,e){const i=re[t.type]||{scales:{}},s=e.scales||{},n=an(t.type,e),a=Object.create(null);return Object.keys(s).forEach((e=>{const r=s[e];if(!o(r))return console.error(`Invalid scale configuration for scale: ${e}`);if(r._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${e}`);const l=ln(e,r,function(t,e){if(e.data&&e.data.datasets){const i=e.data.datasets.filter((e=>e.xAxisID===t||e.yAxisID===t));if(i.length)return hn(t,"x",i[0])||hn(t,"y",i[0])}return{}}(e,t),ue.scales[r.type]),h=function(t,e){return t===e?"_index_":"_value_"}(l,n),c=i.scales||{};a[e]=x(Object.create(null),[{axis:l},r,c[l],c[h]])})),t.data.datasets.forEach((i=>{const n=i.type||t.type,o=i.indexAxis||an(n,e),r=(re[n]||{}).scales||{};Object.keys(r).forEach((t=>{const e=function(t,e){let i=t;return"_index_"===t?i=e:"_value_"===t&&(i="x"===e?"y":"x"),i}(t,o),n=i[e+"AxisID"]||e;a[n]=a[n]||Object.create(null),x(a[n],[{axis:e},s[n],r[t]])}))})),Object.keys(a).forEach((t=>{const e=a[t];x(e,[ue.scales[e.type],ue.scale])})),a}function dn(t){const e=t.options||(t.options={});e.plugins=l(e.plugins,{}),e.scales=cn(t,e)}function un(t){return(t=t||{}).datasets=t.datasets||[],t.labels=t.labels||[],t}const fn=new Map,gn=new Set;function pn(t,e){let i=fn.get(t);return i||(i=e(),fn.set(t,i),gn.add(i)),i}const mn=(t,e,i)=>{const s=M(e,i);void 0!==s&&t.add(s)};class bn{constructor(t){this._config=function(t){return(t=t||{}).data=un(t.data),dn(t),t}(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=un(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(),dn(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return pn(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return pn(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return pn(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;return pn(`${this.type}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const i=this._scopeCache;let s=i.get(t);return s&&!e||(s=new Map,i.set(t,s)),s}getOptionScopes(t,e,i){const{options:s,type:n}=this,o=this._cachedScopes(t,i),a=o.get(e);if(a)return a;const r=new Set;e.forEach((e=>{t&&(r.add(t),e.forEach((e=>mn(r,t,e)))),e.forEach((t=>mn(r,s,t))),e.forEach((t=>mn(r,re[n]||{},t))),e.forEach((t=>mn(r,ue,t))),e.forEach((t=>mn(r,le,t)))}));const l=Array.from(r);return 0===l.length&&l.push(Object.create(null)),gn.has(e)&&o.set(e,l),l}chartOptionScopes(){const{options:t,type:e}=this;return[t,re[e]||{},ue.datasets[e]||{},{type:e},ue,le]}resolveNamedOptions(t,e,i,s=[""]){const o={$shared:!0},{resolver:a,subPrefixes:r}=xn(this._resolverCache,t,s);let l=a;if(function(t,e){const{isScriptable:i,isIndexable:s}=Ye(t);for(const o of e){const e=i(o),a=s(o),r=(a||e)&&t[o];if(e&&(S(r)||_n(r))||a&&n(r))return!0}return!1}(a,e)){o.$shared=!1;l=$e(a,i=S(i)?i():i,this.createResolver(t,i,r))}for(const t of e)o[t]=l[t];return o}createResolver(t,e,i=[""],s){const{resolver:n}=xn(this._resolverCache,t,i);return o(e)?$e(n,e,void 0,s):n}}function xn(t,e,i){let s=t.get(e);s||(s=new Map,t.set(e,s));const n=i.join();let o=s.get(n);if(!o){o={resolver:je(e,i),subPrefixes:i.filter((t=>!t.toLowerCase().includes("hover")))},s.set(n,o)}return o}const _n=t=>o(t)&&Object.getOwnPropertyNames(t).some((e=>S(t[e])));const yn=["top","bottom","left","right","chartArea"];function vn(t,e){return"top"===t||"bottom"===t||-1===yn.indexOf(t)&&"x"===e}function Mn(t,e){return function(i,s){return i[t]===s[t]?i[e]-s[e]:i[t]-s[t]}}function wn(t){const e=t.chart,i=e.options.animation;e.notifyPlugins("afterRender"),d(i&&i.onComplete,[t],e)}function kn(t){const e=t.chart,i=e.options.animation;d(i&&i.onProgress,[t],e)}function Sn(t){return fe()&&"string"==typeof t?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const Pn={},Dn=t=>{const e=Sn(t);return Object.values(Pn).filter((t=>t.canvas===e)).pop()};function Cn(t,e,i){const s=Object.keys(t);for(const n of s){const s=+n;if(s>=e){const o=t[n];delete t[n],(i>0||s>e)&&(t[s+i]=o)}}}function On(t,e,i){return t.options.clip?t[i]:e[i]}class An{static defaults=ue;static instances=Pn;static overrides=re;static registry=en;static version="4.4.1";static getChart=Dn;static register(...t){en.add(...t),Tn()}static unregister(...t){en.remove(...t),Tn()}constructor(t,e){const s=this.config=new bn(e),n=Sn(t),o=Dn(n);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const a=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||ks(n)),this.platform.updateConfig(s);const r=this.platform.acquireContext(n,a.aspectRatio),l=r&&r.canvas,h=l&&l.height,c=l&&l.width;this.id=i(),this.ctx=r,this.canvas=l,this.width=c,this.height=h,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 sn,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=dt((t=>this.update(t)),a.resizeDelay||0),this._dataChanges=[],Pn[this.id]=this,r&&l?(xt.listen(this,"complete",wn),xt.listen(this,"progress",kn),this._initialize(),this.attached&&this.update()):console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:i,height:n,_aspectRatio:o}=this;return s(t)?e&&o?o:n?i/n: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 en}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():ke(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Te(this.canvas,this.ctx),this}stop(){return xt.stop(this),this}resize(t,e){xt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const i=this.options,s=this.canvas,n=i.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(s,t,e,n),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),r=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,ke(this,a,!0)&&(this.notifyPlugins("resize",{size:o}),d(i.onResize,[this,o],this),this.attached&&this._doResize(r)&&this.render())}ensureScalesHaveIDs(){u(this.options.scales||{},((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options,e=t.scales,i=this.scales,s=Object.keys(i).reduce(((t,e)=>(t[e]=!1,t)),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const i=e[t],s=ln(t,i),n="r"===s,o="x"===s;return{options:i,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}})))),u(n,(e=>{const n=e.options,o=n.id,a=ln(o,n),r=l(n.type,e.dtype);void 0!==n.position&&vn(n.position,a)===vn(e.dposition)||(n.position=e.dposition),s[o]=!0;let h=null;if(o in i&&i[o].type===r)h=i[o];else{h=new(en.getScale(r))({id:o,type:r,ctx:this.ctx,chart:this}),i[h.id]=h}h.init(n,t)})),u(s,((t,e)=>{t||delete i[e]})),u(i,(t=>{as.configure(this,t,t.options),as.addBox(this,t)}))}_updateMetasets(){const t=this._metasets,e=this.data.datasets.length,i=t.length;if(t.sort(((t,e)=>t.index-e.index)),i>e){for(let t=e;te.length&&delete this._stacks,t.forEach(((t,i)=>{0===e.filter((e=>e===t._dataset)).length&&this._destroyDatasetMeta(i)}))}buildOrUpdateControllers(){const t=[],e=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=e.length;i{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const i=this._options=e.createResolver(e.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),!1===this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0}))return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()})),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Mn("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){u(this.scales,(t=>{as.removeBox(this,t)})),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,e=new Set(Object.keys(this._listeners)),i=new Set(t.events);P(e,i)&&!!this._responsiveListeners===t.responsive||(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,e=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:n}of e){Cn(t,s,"_removeElements"===i?-n:n)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length,i=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(",")))),s=i(0);for(let t=1;tt.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(!1===this.notifyPlugins("beforeLayout",{cancelable:!0}))return;as.update(this,this.width,this.height,t);const e=this.chartArea,i=e.width<=0||e.height<=0;this._layers=[],u(this.boxes,(t=>{i&&"chartArea"===t.position||(t.configure&&t.configure(),this._layers.push(...t._layers()))}),this),this._layers.forEach(((t,e)=>{t._idx=e})),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(!1!==this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx,i=t._clip,s=!i.disabled,n=function(t,e){const{xScale:i,yScale:s}=t;return i&&s?{left:On(i,e,"left"),right:On(i,e,"right"),top:On(s,e,"top"),bottom:On(s,e,"bottom")}:e}(t,this.chartArea),o={meta:t,index:t.index,cancelable:!0};!1!==this.notifyPlugins("beforeDatasetDraw",o)&&(s&&Ie(e,{left:!1===i.left?0:n.left-i.left,right:!1===i.right?this.width:n.right+i.right,top:!1===i.top?0:n.top-i.top,bottom:!1===i.bottom?this.height:n.bottom+i.bottom}),t.controller.draw(),s&&ze(e),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(t){return Re(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,i,s){const n=Xi.modes[e];return"function"==typeof n?n(this,t,i,s):[]}getDatasetMeta(t){const e=this.data.datasets[t],i=this._metasets;let s=i.filter((t=>t&&t._dataset===e)).pop();return s||(s={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},i.push(s)),s}getContext(){return this.$context||(this.$context=Ci(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return!1;const i=this.getDatasetMeta(t);return"boolean"==typeof i.hidden?!i.hidden:!e.hidden}setDatasetVisibility(t,e){this.getDatasetMeta(t).hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,i){const s=i?"show":"hide",n=this.getDatasetMeta(t),o=n.controller._resolveAnimations(void 0,s);k(e)?(n.data[e].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),o.update(n,{visible:i}),this.update((e=>e.datasetIndex===t?s: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(),xt.remove(this),t=0,e=this.data.datasets.length;t{e.addEventListener(this,i,s),t[i]=s},s=(t,e,i)=>{t.offsetX=e,t.offsetY=i,this._eventHandler(t)};u(this.options.events,(t=>i(t,s)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,e=this.platform,i=(i,s)=>{e.addEventListener(this,i,s),t[i]=s},s=(i,s)=>{t[i]&&(e.removeEventListener(this,i,s),delete t[i])},n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",n),i("detach",o)};o=()=>{this.attached=!1,s("resize",n),this._stop(),this._resize(0,0),i("attach",a)},e.isAttached(this.canvas)?a():o()}unbindEvents(){u(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._listeners={},u(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)})),this._responsiveListeners=void 0}updateHoverStyle(t,e,i){const s=i?"set":"remove";let n,o,a,r;for("dataset"===e&&(n=this.getDatasetMeta(t[0].datasetIndex),n.controller["_"+s+"DatasetHoverStyle"]()),a=0,r=t.length;a{const i=this.getDatasetMeta(t);if(!i)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:i.data[e],index:e}}));!f(i,e)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,e))}notifyPlugins(t,e,i){return this._plugins.notify(this,t,e,i)}isPluginEnabled(t){return 1===this._plugins._cache.filter((e=>e.plugin.id===t)).length}_updateHoverStyles(t,e,i){const s=this.options.hover,n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index)))),o=n(e,t),a=i?t:n(t,e);o.length&&this.updateHoverStyle(o,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,e){const i={event:t,replay:e,cancelable:!0,inChartArea:this.isPointInArea(t)},s=e=>(e.options.events||this.options.events).includes(t.native.type);if(!1===this.notifyPlugins("beforeEvent",i,s))return;const n=this._handleEvent(t,e,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(n||i.changed)&&this.render(),this}_handleEvent(t,e,i){const{_active:s=[],options:n}=this,o=e,a=this._getActiveElements(t,s,i,o),r=D(t),l=function(t,e,i,s){return i&&"mouseout"!==t.type?s?e:t:null}(t,this._lastEvent,i,r);i&&(this._lastEvent=null,d(n.onHover,[t,a,this],this),r&&d(n.onClick,[t,a,this],this));const h=!f(a,s);return(h||e)&&(this._active=a,this._updateHoverStyles(a,s,e)),this._lastEvent=l,h}_getActiveElements(t,e,i,s){if("mouseout"===t.type)return[];if(!i)return e;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,s)}}function Tn(){return u(An.instances,(t=>t._plugins.invalidate()))}function Ln(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class En{static override(t){Object.assign(En.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Ln()}parse(){return Ln()}format(){return Ln()}add(){return Ln()}diff(){return Ln()}startOf(){return Ln()}endOf(){return Ln()}}var Rn={_date:En};function In(t){const e=t.iScale,i=function(t,e){if(!t._cache.$bar){const i=t.getMatchingVisibleMetas(e);let s=[];for(let e=0,n=i.length;et-e)))}return t._cache.$bar}(e,t.type);let s,n,o,a,r=e._length;const l=()=>{32767!==o&&-32768!==o&&(k(a)&&(r=Math.min(r,Math.abs(o-a)||r)),a=o)};for(s=0,n=i.length;sMath.abs(r)&&(l=r,h=a),e[i.axis]=h,e._custom={barStart:l,barEnd:h,start:n,end:o,min:a,max:r}}(t,e,i,s):e[i.axis]=i.parse(t,s),e}function Fn(t,e,i,s){const n=t.iScale,o=t.vScale,a=n.getLabels(),r=n===o,l=[];let h,c,d,u;for(h=i,c=i+s;ht.x,i="left",s="right"):(e=t.base"spacing"!==t,_indexable:t=>"spacing"!==t&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:s,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.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 i=this.getDataset().data,s=this._cachedMeta;if(!1===this._parsing)s._parsed=i;else{let n,a,r=t=>+i[t];if(o(i[t])){const{key:t="value"}=this._parsing;r=e=>+M(i[e],t)}for(n=t,a=t+e;nZ(t,r,l,!0)?1:Math.max(e,e*i,s,s*i),g=(t,e,s)=>Z(t,r,l,!0)?-1:Math.min(e,e*i,s,s*i),p=f(0,h,d),m=f(E,c,u),b=g(C,h,d),x=g(C+E,c,u);s=(p-b)/2,n=(m-x)/2,o=-(p+b)/2,a=-(m+x)/2}return{ratioX:s,ratioY:n,offsetX:o,offsetY:a}}(u,d,r),b=(i.width-o)/f,x=(i.height-o)/g,_=Math.max(Math.min(b,x)/2,0),y=c(this.options.radius,_),v=(y-Math.max(y*r,0))/this._getVisibleDatasetWeightTotal();this.offsetX=p*y,this.offsetY=m*y,s.total=this.calculateTotal(),this.outerRadius=y-v*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-v*l,0),this.updateElements(n,0,n.length,t)}_circumference(t,e){const i=this.options,s=this._cachedMeta,n=this._getCircumference();return e&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||null===s._parsed[t]||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*n/O)}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.chartArea,r=o.options.animation,l=(a.left+a.right)/2,h=(a.top+a.bottom)/2,c=n&&r.animateScale,d=c?0:this.innerRadius,u=c?0:this.outerRadius,{sharedOptions:f,includeOptions:g}=this._getSharedOptions(e,s);let p,m=this._getRotation();for(p=0;p0&&!isNaN(t)?O*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart,s=i.data.labels||[],n=ne(e._parsed[t],i.options.locale);return{label:s[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const i=this.chart;let s,n,o,a,r;if(!t)for(s=0,n=i.data.datasets.length;s{const o=t.getDatasetMeta(0).controller.getStyle(n);return{text:e,fillStyle:o.backgroundColor,strokeStyle:o.borderColor,fontColor:s,lineWidth:o.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,i){i.chart.toggleDataVisibility(e.index),i.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,i=this.chart,s=i.data.labels||[],n=ne(e._parsed[t].r,i.options.locale);return{label:s[t]||"",value:n}}parseObjectData(t,e,i,s){return ii.bind(this)(t,e,i,s)}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(((t,i)=>{const s=this.getParsed(i).r;!isNaN(s)&&this.chart.getDataVisibility(i)&&(se.max&&(e.max=s))})),e}_updateRadius(){const t=this.chart,e=t.chartArea,i=t.options,s=Math.min(e.right-e.left,e.bottom-e.top),n=Math.max(s/2,0),o=(n-Math.max(i.cutoutPercentage?n/100*i.cutoutPercentage:1,0))/t.getVisibleDatasetCount();this.outerRadius=n-o*this.index,this.innerRadius=this.outerRadius-o}updateElements(t,e,i,s){const n="reset"===s,o=this.chart,a=o.options.animation,r=this._cachedMeta.rScale,l=r.xCenter,h=r.yCenter,c=r.getIndexAngle(0)-.5*C;let d,u=c;const f=360/this.countVisibleElements();for(d=0;d{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&e++})),e}_computeAngle(t,e,i){return this.chart.getDataVisibility(t)?$(this.resolveDataElementOptions(t,e).angle||i):0}}var Yn=Object.freeze({__proto__:null,BarController:class extends Ns{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,e,i,s){return Fn(t,e,i,s)}parseArrayData(t,e,i,s){return Fn(t,e,i,s)}parseObjectData(t,e,i,s){const{iScale:n,vScale:o}=t,{xAxisKey:a="x",yAxisKey:r="y"}=this._parsing,l="x"===n.axis?a:r,h="x"===o.axis?a:r,c=[];let d,u,f,g;for(d=i,u=i+s;dt.controller.options.grouped)),o=i.options.stacked,a=[],r=t=>{const i=t.controller.getParsed(e),n=i&&i[t.vScale.axis];if(s(n)||isNaN(n))return!0};for(const i of n)if((void 0===e||!r(i))&&((!1===o||-1===a.indexOf(i.stack)||void 0===o&&void 0===i.stack)&&a.push(i.stack),i.index===t))break;return a.length||a.push(void 0),a}_getStackCount(t){return this._getStacks(void 0,t).length}_getStackIndex(t,e,i){const s=this._getStacks(t,i),n=void 0!==e?s.indexOf(e):-1;return-1===n?s.length-1:n}_getRuler(){const t=this.options,e=this._cachedMeta,i=e.iScale,s=[];let n,o;for(n=0,o=e.data.length;n=i?1:-1)}(u,e,r)*a,f===r&&(b-=u/2);const t=e.getPixelForDecimal(0),s=e.getPixelForDecimal(1),o=Math.min(t,s),h=Math.max(t,s);b=Math.max(Math.min(b,h),o),d=b+u,i&&!c&&(l._stacks[e.axis]._visualValues[n]=e.getValueForPixel(d)-e.getValueForPixel(b))}if(b===e.getPixelForValue(r)){const t=F(u)*e.getLineWidthForValue(r)/2;b+=t,u-=t}return{size:u,base:b,head:d,center:d+u/2}}_calculateBarIndexPixels(t,e){const i=e.scale,n=this.options,o=n.skipNull,a=l(n.maxBarThickness,1/0);let r,h;if(e.grouped){const i=o?this._getStackCount(t):e.stackCount,l="flex"===n.barThickness?function(t,e,i,s){const n=e.pixels,o=n[t];let a=t>0?n[t-1]:null,r=t=0;--i)e=Math.max(e,t[i].size(this.resolveDataElementOptions(i))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:n}=e,o=this.getParsed(t),a=s.getLabelForValue(o.x),r=n.getLabelForValue(o.y),l=o._custom;return{label:i[t]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,i,s){const n="reset"===s,{iScale:o,vScale:a}=this._cachedMeta,{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,s),h=o.axis,c=a.axis;for(let d=e;d0&&this.getParsed(e-1);for(let i=0;i<_;++i){const g=t[i],_=b?g:{};if(i=x){_.skip=!0;continue}const v=this.getParsed(i),M=s(v[f]),w=_[u]=a.getPixelForValue(v[u],i),k=_[f]=o||M?r.getBasePixel():r.getPixelForValue(l?this.applyStack(r,v,l):v[f],i);_.skip=isNaN(w)||isNaN(k)||M,_.stop=i>0&&Math.abs(v[u]-y[u])>m,p&&(_.parsed=v,_.raw=h.data[i]),d&&(_.options=c||this.resolveDataElementOptions(i,g.active?"active":n)),b||this.updateElement(g,i,_,n),y=v}}getMaxOverflow(){const t=this._cachedMeta,e=t.dataset,i=e.options&&e.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const n=s[0].size(this.resolveDataElementOptions(0)),o=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}},PieController:class extends jn{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},PolarAreaController:$n,RadarController:class extends Ns{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,i=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(i[e.axis])}}parseObjectData(t,e,i,s){return ii.bind(this)(t,e,i,s)}update(t){const e=this._cachedMeta,i=e.dataset,s=e.data||[],n=e.iScale.getLabels();if(i.points=s,"resize"!==t){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:!0,_fullLoop:n.length===s.length,options:e};this.updateElement(i,void 0,o,t)}this.updateElements(s,0,s.length,t)}updateElements(t,e,i,s){const n=this._cachedMeta.rScale,o="reset"===s;for(let a=e;a0&&this.getParsed(e-1);for(let c=e;c0&&Math.abs(i[f]-_[f])>b,m&&(p.parsed=i,p.raw=h.data[c]),u&&(p.options=d||this.resolveDataElementOptions(c,e.active?"active":n)),x||this.updateElement(e,c,p,n),_=i}this.updateSharedOptions(d,n,c)}getMaxOverflow(){const t=this._cachedMeta,e=t.data||[];if(!this.options.showLine){let t=0;for(let i=e.length-1;i>=0;--i)t=Math.max(t,e[i].size(this.resolveDataElementOptions(i))/2);return t>0&&t}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!e.length)return s;const n=e[0].size(this.resolveDataElementOptions(0)),o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(s,n,o)/2}}});function Un(t,e,i,s){const n=vi(t.options.borderRadius,["outerStart","outerEnd","innerStart","innerEnd"]);const o=(i-e)/2,a=Math.min(o,s*e/2),r=t=>{const e=(i-Math.min(o,t))*s/2;return J(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:J(n.innerStart,0,a),innerEnd:J(n.innerEnd,0,a)}}function Xn(t,e,i,s){return{x:i+t*Math.cos(e),y:s+t*Math.sin(e)}}function qn(t,e,i,s,n,o){const{x:a,y:r,startAngle:l,pixelMargin:h,innerRadius:c}=e,d=Math.max(e.outerRadius+s+i-h,0),u=c>0?c+s+i+h:0;let f=0;const g=n-l;if(s){const t=((c>0?c-s:0)+(d>0?d-s:0))/2;f=(g-(0!==t?g*t/(t+s):g))/2}const p=(g-Math.max(.001,g*d-i/C)/d)/2,m=l+p+f,b=n-p-f,{outerStart:x,outerEnd:_,innerStart:y,innerEnd:v}=Un(e,u,d,b-m),M=d-x,w=d-_,k=m+x/M,S=b-_/w,P=u+y,D=u+v,O=m+y/P,A=b-v/D;if(t.beginPath(),o){const e=(k+S)/2;if(t.arc(a,r,d,k,e),t.arc(a,r,d,e,S),_>0){const e=Xn(w,S,a,r);t.arc(e.x,e.y,_,S,b+E)}const i=Xn(D,b,a,r);if(t.lineTo(i.x,i.y),v>0){const e=Xn(D,A,a,r);t.arc(e.x,e.y,v,b+E,A+Math.PI)}const s=(b-v/u+(m+y/u))/2;if(t.arc(a,r,u,b-v/u,s,!0),t.arc(a,r,u,s,m+y/u,!0),y>0){const e=Xn(P,O,a,r);t.arc(e.x,e.y,y,O+Math.PI,m-E)}const n=Xn(M,m,a,r);if(t.lineTo(n.x,n.y),x>0){const e=Xn(M,k,a,r);t.arc(e.x,e.y,x,m-E,k)}}else{t.moveTo(a,r);const e=Math.cos(k)*d+a,i=Math.sin(k)*d+r;t.lineTo(e,i);const s=Math.cos(S)*d+a,n=Math.sin(S)*d+r;t.lineTo(s,n)}t.closePath()}function Kn(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r,options:l}=e,{borderWidth:h,borderJoinStyle:c,borderDash:d,borderDashOffset:u}=l,f="inner"===l.borderAlign;if(!h)return;t.setLineDash(d||[]),t.lineDashOffset=u,f?(t.lineWidth=2*h,t.lineJoin=c||"round"):(t.lineWidth=h,t.lineJoin=c||"bevel");let g=e.endAngle;if(o){qn(t,e,i,s,g,n);for(let e=0;en?(h=n/l,t.arc(o,a,l,i+h,s-h,!0)):t.arc(o,a,n,i+E,s-E),t.closePath(),t.clip()}(t,e,g),o||(qn(t,e,i,s,g,n),t.stroke())}function Gn(t,e,i=e){t.lineCap=l(i.borderCapStyle,e.borderCapStyle),t.setLineDash(l(i.borderDash,e.borderDash)),t.lineDashOffset=l(i.borderDashOffset,e.borderDashOffset),t.lineJoin=l(i.borderJoinStyle,e.borderJoinStyle),t.lineWidth=l(i.borderWidth,e.borderWidth),t.strokeStyle=l(i.borderColor,e.borderColor)}function Zn(t,e,i){t.lineTo(i.x,i.y)}function Jn(t,e,i={}){const s=t.length,{start:n=0,end:o=s-1}=i,{start:a,end:r}=e,l=Math.max(n,a),h=Math.min(o,r),c=nr&&o>r;return{count:s,start:l,loop:e.loop,ilen:h(a+(h?r-t:t))%o,_=()=>{f!==g&&(t.lineTo(m,g),t.lineTo(m,f),t.lineTo(m,p))};for(l&&(d=n[x(0)],t.moveTo(d.x,d.y)),c=0;c<=r;++c){if(d=n[x(c)],d.skip)continue;const e=d.x,i=d.y,s=0|e;s===u?(ig&&(g=i),m=(b*m+e)/++b):(_(),t.lineTo(e,i),u=s,b=0,f=g=i),p=i}_()}function eo(t){const e=t.options,i=e.borderDash&&e.borderDash.length;return!(t._decimated||t._loop||e.tension||"monotone"===e.cubicInterpolationMode||e.stepped||i)?to:Qn}const io="function"==typeof Path2D;function so(t,e,i,s){io&&!e.options.segment?function(t,e,i,s){let n=e._path;n||(n=e._path=new Path2D,e.path(n,i,s)&&n.closePath()),Gn(t,e.options),t.stroke(n)}(t,e,i,s):function(t,e,i,s){const{segments:n,options:o}=e,a=eo(e);for(const r of n)Gn(t,o,r.style),t.beginPath(),a(t,e,r,{start:i,end:i+s-1})&&t.closePath(),t.stroke()}(t,e,i,s)}class no extends Hs{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=>"borderDash"!==t&&"fill"!==t};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 i=this.options;if((i.tension||"monotone"===i.cubicInterpolationMode)&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;hi(this._points,i,t,s,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=zi(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,i=t.length;return i&&e[t[i-1].end]}interpolate(t,e){const i=this.options,s=t[e],n=this.points,o=Ii(this,{property:e,start:s,end:s});if(!o.length)return;const a=[],r=function(t){return t.stepped?pi:t.tension||"monotone"===t.cubicInterpolationMode?mi:gi}(i);let l,h;for(l=0,h=o.length;l"borderDash"!==t};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,i){const s=this.getProps(["x","y"],i),{angle:n,distance:o}=X(s,{x:t,y:e}),{startAngle:a,endAngle:r,innerRadius:h,outerRadius:c,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),u=(this.options.spacing+this.options.borderWidth)/2,f=l(d,r-a)>=O||Z(n,a,r),g=tt(o,h+u,c+u);return f&&g}getCenterPoint(t){const{x:e,y:i,startAngle:s,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:r,spacing:l}=this.options,h=(s+n)/2,c=(o+a+l+r)/2;return{x:e+Math.cos(h)*c,y:i+Math.sin(h)*c}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:i}=this,s=(e.offset||0)/4,n=(e.spacing||0)/2,o=e.circular;if(this.pixelMargin="inner"===e.borderAlign?.33:0,this.fullCircles=i>O?Math.floor(i/O):0,0===i||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*s,Math.sin(a)*s);const r=s*(1-Math.sin(Math.min(C,i||0)));t.fillStyle=e.backgroundColor,t.strokeStyle=e.borderColor,function(t,e,i,s,n){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){qn(t,e,i,s,l,n);for(let e=0;e("string"==typeof e?(i=t.push(e)-1,s.unshift({index:i,label:e})):isNaN(e)&&(i=null),i))(t,e,i,s);return n!==t.lastIndexOf(e)?i:n}function po(t){const e=this.getLabels();return t>=0&&ts=e?s:t,a=t=>n=i?n:t;if(t){const t=F(s),e=F(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(s===n){let e=0===n?1:Math.abs(.05*n);a(n+e),t||o(s-e)}this.min=s,this.max=n}getTickLimit(){const t=this.options.ticks;let e,{maxTicksLimit:i,stepSize:s}=t;return s?(e=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,e>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${e} ticks. Limiting to 1000.`),e=1e3)):(e=this.computeTickLimit(),i=i||11),i&&(e=Math.min(i,e)),e}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,e=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const n=function(t,e){const i=[],{bounds:n,step:o,min:a,max:r,precision:l,count:h,maxTicks:c,maxDigits:d,includeBounds:u}=t,f=o||1,g=c-1,{min:p,max:m}=e,b=!s(a),x=!s(r),_=!s(h),y=(m-p)/(d+1);let v,M,w,k,S=B((m-p)/g/f)*f;if(S<1e-14&&!b&&!x)return[{value:p},{value:m}];k=Math.ceil(m/S)-Math.floor(p/S),k>g&&(S=B(k*S/g/f)*f),s(l)||(v=Math.pow(10,l),S=Math.ceil(S*v)/v),"ticks"===n?(M=Math.floor(p/S)*S,w=Math.ceil(m/S)*S):(M=p,w=m),b&&x&&o&&H((r-a)/o,S/1e3)?(k=Math.round(Math.min((r-a)/S,c)),S=(r-a)/k,M=a,w=r):_?(M=b?a:M,w=x?r:w,k=h-1,S=(w-M)/k):(k=(w-M)/S,k=V(k,Math.round(k),S/1e3)?Math.round(k):Math.ceil(k));const P=Math.max(U(S),U(M));v=Math.pow(10,s(l)?P:l),M=Math.round(M*v)/v,w=Math.round(w*v)/v;let D=0;for(b&&(u&&M!==a?(i.push({value:a}),Mr)break;i.push({value:t})}return x&&u&&w!==r?i.length&&V(i[i.length-1].value,r,mo(r,y,t))?i[i.length-1].value=r:i.push({value:r}):x&&w!==r||i.push({value:w}),i}({maxTicks:i,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:!1!==e.includeBounds},this._range||this);return"ticks"===t.bounds&&j(n,this,"value"),t.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}configure(){const t=this.ticks;let e=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-e)/Math.max(t.length-1,1)/2;e-=s,i+=s}this._startValue=e,this._endValue=i,this._valueRange=i-e}getLabelForValue(t){return ne(t,this.chart.options.locale,this.options.ticks.format)}}class xo extends bo{static id="linear";static defaults={ticks:{callback:ae.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=a(t)?t:0,this.max=a(e)?e:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),e=t?this.width:this.height,i=$(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,n=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,n.lineHeight/s))}getPixelForValue(t){return null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const _o=t=>Math.floor(z(t)),yo=(t,e)=>Math.pow(10,_o(t)+e);function vo(t){return 1===t/Math.pow(10,_o(t))}function Mo(t,e,i){const s=Math.pow(10,i),n=Math.floor(t/s);return Math.ceil(e/s)-n}function wo(t,{min:e,max:i}){e=r(t.min,e);const s=[],n=_o(e);let o=function(t,e){let i=_o(e-t);for(;Mo(t,e,i)>10;)i++;for(;Mo(t,e,i)<10;)i--;return Math.min(i,_o(t))}(e,i),a=o<0?Math.pow(10,Math.abs(o)):1;const l=Math.pow(10,o),h=n>o?Math.pow(10,n):0,c=Math.round((e-h)*a)/a,d=Math.floor((e-h)/l/10)*l*10;let u=Math.floor((c-d)/Math.pow(10,o)),f=r(t.min,Math.round((h+d+u*Math.pow(10,o))*a)/a);for(;f=10?u=u<15?15:20:u++,u>=20&&(o++,u=2,a=o>=0?1:a),f=Math.round((h+d+u*Math.pow(10,o))*a)/a;const g=r(t.max,f);return s.push({value:g,major:vo(g),significand:u}),s}class ko extends Js{static id="logarithmic";static defaults={ticks:{callback:ae.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 i=bo.prototype.parse.apply(this,[t,e]);if(0!==i)return a(i)&&i>0?i:null;this._zero=!0}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!0);this.min=a(t)?Math.max(0,t):null,this.max=a(e)?Math.max(0,e):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!a(this._userMin)&&(this.min=t===yo(this.min,0)?yo(this.min,-1):yo(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let i=this.min,s=this.max;const n=e=>i=t?i:e,o=t=>s=e?s:t;i===s&&(i<=0?(n(1),o(10)):(n(yo(i,-1)),o(yo(s,1)))),i<=0&&n(yo(s,-1)),s<=0&&o(yo(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,e=wo({min:this._userMin,max:this._userMax},this);return"ticks"===t.bounds&&j(e,this,"value"),t.reverse?(e.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),e}getLabelForValue(t){return void 0===t?"0":ne(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=z(t),this._valueRange=z(this.max)-z(t)}getPixelForValue(t){return void 0!==t&&0!==t||(t=this.min),null===t||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(z(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function So(t){const e=t.ticks;if(e.display&&t.display){const t=ki(e.backdropPadding);return l(e.font&&e.font.size,ue.font.size)+t.height}return 0}function Po(t,e,i,s,n){return t===s||t===n?{start:e-i/2,end:e+i/2}:tn?{start:e-i,end:e}:{start:e,end:e+i}}function Do(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},i=Object.assign({},e),s=[],o=[],a=t._pointLabels.length,r=t.options.pointLabels,l=r.centerPointLabels?C/a:0;for(let u=0;ue.r&&(r=(s.end-e.r)/o,t.r=Math.max(t.r,e.r+r)),n.starte.b&&(l=(n.end-e.b)/a,t.b=Math.max(t.b,e.b+l))}function Oo(t,e,i){const s=t.drawingArea,{extra:n,additionalAngle:o,padding:a,size:r}=i,l=t.getPointPosition(e,s+n+a,o),h=Math.round(Y(G(l.angle+E))),c=function(t,e,i){90===i||270===i?t-=e/2:(i>270||i<90)&&(t-=e);return t}(l.y,r.h,h),d=function(t){if(0===t||180===t)return"center";if(t<180)return"left";return"right"}(h),u=function(t,e,i){"right"===i?t-=e:"center"===i&&(t-=e/2);return t}(l.x,r.w,d);return{visible:!0,x:l.x,y:c,textAlign:d,left:u,top:c,right:u+r.w,bottom:c+r.h}}function Ao(t,e){if(!e)return!0;const{left:i,top:s,right:n,bottom:o}=t;return!(Re({x:i,y:s},e)||Re({x:i,y:o},e)||Re({x:n,y:s},e)||Re({x:n,y:o},e))}function To(t,e,i){const{left:n,top:o,right:a,bottom:r}=i,{backdropColor:l}=e;if(!s(l)){const i=wi(e.borderRadius),s=ki(e.backdropPadding);t.fillStyle=l;const h=n-s.left,c=o-s.top,d=a-n+s.width,u=r-o+s.height;Object.values(i).some((t=>0!==t))?(t.beginPath(),He(t,{x:h,y:c,w:d,h:u,radius:i}),t.fill()):t.fillRect(h,c,d,u)}}function Lo(t,e,i,s){const{ctx:n}=t;if(i)n.arc(t.xCenter,t.yCenter,e,0,O);else{let i=t.getPointPosition(0,e);n.moveTo(i.x,i.y);for(let o=1;ot,padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=ki(So(this.options)/2),e=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+e/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(e,i)/2)}determineDataLimits(){const{min:t,max:e}=this.getMinMax(!1);this.min=a(t)&&!isNaN(t)?t:0,this.max=a(e)&&!isNaN(e)?e:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/So(this.options))}generateTickLabels(t){bo.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map(((t,e)=>{const i=d(this.options.pointLabels.callback,[t,e],this);return i||0===i?i:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?Do(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,i,s){this.xCenter+=Math.floor((t-e)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,i,s))}getIndexAngle(t){return G(t*(O/(this._pointLabels.length||1))+$(this.options.startAngle||0))}getDistanceFromCenterForValue(t){if(s(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(s(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=0;n--){const e=t._pointLabelItems[n];if(!e.visible)continue;const o=s.setContext(t.getPointLabelContext(n));To(i,o,e);const a=Si(o.font),{x:r,y:l,textAlign:h}=e;Ne(i,t._pointLabels[n],r,l+a.lineHeight/2,a,{color:o.color,textAlign:h,textBaseline:"middle"})}}(this,o),s.display&&this.ticks.forEach(((t,e)=>{if(0!==e){r=this.getDistanceFromCenterForValue(t.value);const i=this.getContext(e),a=s.setContext(i),l=n.setContext(i);!function(t,e,i,s,n){const o=t.ctx,a=e.circular,{color:r,lineWidth:l}=e;!a&&!s||!r||!l||i<0||(o.save(),o.strokeStyle=r,o.lineWidth=l,o.setLineDash(n.dash),o.lineDashOffset=n.dashOffset,o.beginPath(),Lo(t,i,a,s),o.closePath(),o.stroke(),o.restore())}(this,a,r,o,l)}})),i.display){for(t.save(),a=o-1;a>=0;a--){const s=i.setContext(this.getPointLabelContext(a)),{color:n,lineWidth:o}=s;o&&n&&(t.lineWidth=o,t.strokeStyle=n,t.setLineDash(s.borderDash),t.lineDashOffset=s.borderDashOffset,r=this.getDistanceFromCenterForValue(e.ticks.reverse?this.min:this.max),l=this.getPointPosition(a,r),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(l.x,l.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,e=this.options,i=e.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let n,o;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach(((s,a)=>{if(0===a&&!e.reverse)return;const r=i.setContext(this.getContext(a)),l=Si(r.font);if(n=this.getDistanceFromCenterForValue(this.ticks[a].value),r.showLabelBackdrop){t.font=l.string,o=t.measureText(s.label).width,t.fillStyle=r.backdropColor;const e=ki(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}Ne(t,s.label,0,-n,l,{color:r.color,strokeColor:r.textStrokeColor,strokeWidth:r.textStrokeWidth})})),t.restore()}drawTitle(){}}const Ro={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}},Io=Object.keys(Ro);function zo(t,e){return t-e}function Fo(t,e){if(s(e))return null;const i=t._adapter,{parser:n,round:o,isoWeekday:r}=t._parseOpts;let l=e;return"function"==typeof n&&(l=n(l)),a(l)||(l="string"==typeof n?i.parse(l,n):i.parse(l)),null===l?null:(o&&(l="week"!==o||!N(r)&&!0!==r?i.startOf(l,o):i.startOf(l,"isoWeek",r)),+l)}function Vo(t,e,i,s){const n=Io.length;for(let o=Io.indexOf(t);o=e?i[s]:i[n]]=!0}}else t[e]=!0}function Wo(t,e,i){const s=[],n={},o=e.length;let a,r;for(a=0;a=0&&(e[l].major=!0);return e}(t,s,n,i):s}class No extends Js{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,e={}){const i=t.time||(t.time={}),s=this._adapter=new Rn._date(t.adapters.date);s.init(e),x(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=e.normalized}parse(t,e){return void 0===t?null:Fo(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,e=this._adapter,i=t.time.unit||"day";let{min:s,max:n,minDefined:o,maxDefined:r}=this.getUserBounds();function l(t){o||isNaN(t.min)||(s=Math.min(s,t.min)),r||isNaN(t.max)||(n=Math.max(n,t.max))}o&&r||(l(this._getLabelBounds()),"ticks"===t.bounds&&"labels"===t.ticks.source||l(this.getMinMax(!1))),s=a(s)&&!isNaN(s)?s:+e.startOf(Date.now(),i),n=a(n)&&!isNaN(n)?n:+e.endOf(Date.now(),i)+1,this.min=Math.min(s,n-1),this.max=Math.max(s+1,n)}_getLabelBounds(){const t=this.getLabelTimestamps();let e=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(e=t[0],i=t[t.length-1]),{min:e,max:i}}buildTicks(){const t=this.options,e=t.time,i=t.ticks,s="labels"===i.source?this.getLabelTimestamps():this._generate();"ticks"===t.bounds&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const n=this.min,o=nt(s,n,this.max);return this._unit=e.unit||(i.autoSkip?Vo(e.minUnit,this.min,this.max,this._getLabelCapacity(n)):function(t,e,i,s,n){for(let o=Io.length-1;o>=Io.indexOf(i);o--){const i=Io[o];if(Ro[i].common&&t._adapter.diff(n,s,i)>=e-1)return i}return Io[i?Io.indexOf(i):0]}(this,o.length,e.minUnit,this.min,this.max)),this._majorUnit=i.major.enabled&&"year"!==this._unit?function(t){for(let e=Io.indexOf(t)+1,i=Io.length;e+t.value)))}initOffsets(t=[]){let e,i,s=0,n=0;this.options.offset&&t.length&&(e=this.getDecimalForValue(t[0]),s=1===t.length?1-e:(this.getDecimalForValue(t[1])-e)/2,i=this.getDecimalForValue(t[t.length-1]),n=1===t.length?i:(i-this.getDecimalForValue(t[t.length-2]))/2);const o=t.length<3?.5:.25;s=J(s,0,o),n=J(n,0,o),this._offsets={start:s,end:n,factor:1/(s+1+n)}}_generate(){const t=this._adapter,e=this.min,i=this.max,s=this.options,n=s.time,o=n.unit||Vo(n.minUnit,e,i,this._getLabelCapacity(e)),a=l(s.ticks.stepSize,1),r="week"===o&&n.isoWeekday,h=N(r)||!0===r,c={};let d,u,f=e;if(h&&(f=+t.startOf(f,"isoWeek",r)),f=+t.startOf(f,h?"day":o),t.diff(i,e,o)>1e5*a)throw new Error(e+" and "+i+" are too far apart with stepSize of "+a+" "+o);const g="data"===s.ticks.source&&this.getDataTimestamps();for(d=f,u=0;d+t))}getLabelForValue(t){const e=this._adapter,i=this.options.time;return i.tooltipFormat?e.format(t,i.tooltipFormat):e.format(t,i.displayFormats.datetime)}format(t,e){const i=this.options.time.displayFormats,s=this._unit,n=e||i[s];return this._adapter.format(t,n)}_tickFormatFunction(t,e,i,s){const n=this.options,o=n.ticks.callback;if(o)return d(o,[t,e,i],this);const a=n.time.displayFormats,r=this._unit,l=this._majorUnit,h=r&&a[r],c=l&&a[l],u=i[e],f=l&&c&&u&&u.major;return this._adapter.format(t,s||(f?c:h))}generateTickLabels(t){let e,i,s;for(e=0,i=t.length;e0?a:1}getDataTimestamps(){let t,e,i=this._cache.data||[];if(i.length)return i;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(t=0,e=s.length;t=t[r].pos&&e<=t[l].pos&&({lo:r,hi:l}=it(t,"pos",e)),({pos:s,time:o}=t[r]),({pos:n,time:a}=t[l])):(e>=t[r].time&&e<=t[l].time&&({lo:r,hi:l}=it(t,"time",e)),({time:s,pos:o}=t[r]),({time:n,pos:a}=t[l]));const h=n-s;return h?o+(a-o)*(e-s)/h:o}var jo=Object.freeze({__proto__:null,CategoryScale:class extends Js{static id="category";static defaults={ticks:{callback:po}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const e=this._addedLabels;if(e.length){const t=this.getLabels();for(const{index:i,label:s}of e)t[i]===s&&t.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,e){if(s(t))return null;const i=this.getLabels();return((t,e)=>null===t?null:J(Math.round(t),0,e))(e=isFinite(e)&&i[e]===t?e:go(i,t,l(e,t),this._addedLabels),i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);"ticks"===this.options.bounds&&(t||(i=0),e||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,e=this.max,i=this.options.offset,s=[];let n=this.getLabels();n=0===t&&e===n.length-1?n:n.slice(t,e+1),this._valueRange=Math.max(n.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let i=t;i<=e;i++)s.push({value:i});return s}getLabelForValue(t){return po.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return"number"!=typeof t&&(t=this.parse(t)),null===t?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}},LinearScale:xo,LogarithmicScale:ko,RadialLinearScale:Eo,TimeScale:No,TimeSeriesScale:class extends No{static id="timeseries";static defaults=No.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=Ho(e,this.min),this._tableRange=Ho(e,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:e,max:i}=this,s=[],n=[];let o,a,r,l,h;for(o=0,a=t.length;o=e&&l<=i&&s.push(l);if(s.length<2)return[{time:e,pos:0},{time:i,pos:1}];for(o=0,a=s.length;ot-e))}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps(),i=this.getLabelTimestamps();return t=e.length&&i.length?this.normalize(e.concat(i)):e.length?e:i,t=this._cache.all=t,t}getDecimalForValue(t){return(Ho(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets,i=this.getDecimalForPixel(t)/e.factor-e.end;return Ho(this._table,i*this._tableRange+this._minPos,!0)}}});const $o=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],Yo=$o.map((t=>t.replace("rgb(","rgba(").replace(")",", 0.5)")));function Uo(t){return $o[t%$o.length]}function Xo(t){return Yo[t%Yo.length]}function qo(t){let e=0;return(i,s)=>{const n=t.getDatasetMeta(s).controller;n instanceof jn?e=function(t,e){return t.backgroundColor=t.data.map((()=>Uo(e++))),e}(i,e):n instanceof $n?e=function(t,e){return t.backgroundColor=t.data.map((()=>Xo(e++))),e}(i,e):n&&(e=function(t,e){return t.borderColor=Uo(e),t.backgroundColor=Xo(e),++e}(i,e))}}function Ko(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}var Go={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,i){if(!i.enabled)return;const{data:{datasets:s},options:n}=t.config,{elements:o}=n;if(!i.forceOverride&&(Ko(s)||(a=n)&&(a.borderColor||a.backgroundColor)||o&&Ko(o)))return;var a;const r=qo(t);s.forEach(r)}};function Zo(t){if(t._decimated){const e=t._data;delete t._decimated,delete t._data,Object.defineProperty(t,"data",{configurable:!0,enumerable:!0,writable:!0,value:e})}}function Jo(t){t.data.datasets.forEach((t=>{Zo(t)}))}var Qo={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled)return void Jo(t);const n=t.width;t.data.datasets.forEach(((e,o)=>{const{_data:a,indexAxis:r}=e,l=t.getDatasetMeta(o),h=a||e.data;if("y"===Pi([r,t.options.indexAxis]))return;if(!l.controller.supportsDecimation)return;const c=t.scales[l.xAxisID];if("linear"!==c.type&&"time"!==c.type)return;if(t.options.parsing)return;let{start:d,count:u}=function(t,e){const i=e.length;let s,n=0;const{iScale:o}=t,{min:a,max:r,minDefined:l,maxDefined:h}=o.getUserBounds();return l&&(n=J(it(e,o.axis,a).lo,0,i-1)),s=h?J(it(e,o.axis,r).hi+1,n,i)-n:i-n,{start:n,count:s}}(l,h);if(u<=(i.threshold||4*n))return void Zo(e);let f;switch(s(a)&&(e._data=h,delete e.data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(t){this._data=t}})),i.algorithm){case"lttb":f=function(t,e,i,s,n){const o=n.samples||s;if(o>=i)return t.slice(e,e+i);const a=[],r=(i-2)/(o-2);let l=0;const h=e+i-1;let c,d,u,f,g,p=e;for(a[l++]=t[p],c=0;cu&&(u=f,d=t[s],g=s);a[l++]=d,p=g}return a[l++]=t[h],a}(h,d,u,n,i);break;case"min-max":f=function(t,e,i,n){let o,a,r,l,h,c,d,u,f,g,p=0,m=0;const b=[],x=e+i-1,_=t[e].x,y=t[x].x-_;for(o=e;og&&(g=l,d=o),p=(m*p+a.x)/++m;else{const i=o-1;if(!s(c)&&!s(d)){const e=Math.min(c,d),s=Math.max(c,d);e!==u&&e!==i&&b.push({...t[e],x:p}),s!==u&&s!==i&&b.push({...t[s],x:p})}o>0&&i!==u&&b.push(t[i]),b.push(a),h=e,m=0,f=g=l,c=d=u=o}}return b}(h,d,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=f}))},destroy(t){Jo(t)}};function ta(t,e,i,s){if(s)return;let n=e[t],o=i[t];return"angle"===t&&(n=G(n),o=G(o)),{property:t,start:n,end:o}}function ea(t,e,i){for(;e>t;e--){const t=i[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function ia(t,e,i,s){return t&&e?s(t[i],e[i]):t?t[i]:e?e[i]:0}function sa(t,e){let i=[],s=!1;return n(t)?(s=!0,i=t):i=function(t,e){const{x:i=null,y:s=null}=t||{},n=e.points,o=[];return e.segments.forEach((({start:t,end:e})=>{e=ea(t,e,n);const a=n[t],r=n[e];null!==s?(o.push({x:a.x,y:s}),o.push({x:r.x,y:s})):null!==i&&(o.push({x:i,y:a.y}),o.push({x:i,y:r.y}))})),o}(t,e),i.length?new no({points:i,options:{tension:0},_loop:s,_fullLoop:s}):null}function na(t){return t&&!1!==t.fill}function oa(t,e,i){let s=t[e].fill;const n=[e];let o;if(!i)return s;for(;!1!==s&&-1===n.indexOf(s);){if(!a(s))return s;if(o=t[s],!o)return!1;if(o.visible)return s;n.push(s),s=o.fill}return!1}function aa(t,e,i){const s=function(t){const e=t.options,i=e.fill;let s=l(i&&i.target,i);void 0===s&&(s=!!e.backgroundColor);if(!1===s||null===s)return!1;if(!0===s)return"origin";return s}(t);if(o(s))return!isNaN(s.value)&&s;let n=parseFloat(s);return a(n)&&Math.floor(n)===n?function(t,e,i,s){"-"!==t&&"+"!==t||(i=e+i);if(i===e||i<0||i>=s)return!1;return i}(s[0],e,n,i):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function ra(t,e,i){const s=[];for(let n=0;n=0;--e){const i=n[e].$filler;i&&(i.line.updateControlPoints(o,i.axis),s&&i.fill&&da(t.ctx,i,o))}},beforeDatasetsDraw(t,e,i){if("beforeDatasetsDraw"!==i.drawTime)return;const s=t.getSortedVisibleDatasetMetas();for(let e=s.length-1;e>=0;--e){const i=s[e].$filler;na(i)&&da(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,i){const s=e.meta.$filler;na(s)&&"beforeDatasetDraw"===i.drawTime&&da(t.ctx,s,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const ba=(t,e)=>{let{boxHeight:i=e,boxWidth:s=e}=t;return t.usePointStyle&&(i=Math.min(i,e),s=t.pointStyleWidth||Math.min(s,e)),{boxWidth:s,boxHeight:i,itemHeight:Math.max(e,i)}};class xa extends Hs{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,i){this.maxWidth=t,this.maxHeight=e,this._margins=i,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=d(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data)))),t.sort&&(e=e.sort(((e,i)=>t.sort(e,i,this.chart.data)))),this.options.reverse&&e.reverse(),this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display)return void(this.width=this.height=0);const i=t.labels,s=Si(i.font),n=s.size,o=this._computeTitleHeight(),{boxWidth:a,itemHeight:r}=ba(i,n);let l,h;e.font=s.string,this.isHorizontal()?(l=this.maxWidth,h=this._fitRows(o,n,a,r)+10):(h=this.maxHeight,l=this._fitCols(o,s,a,r)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(h,t.maxHeight||this.maxHeight)}_fitRows(t,e,i,s){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.lineWidths=[0],h=s+a;let c=t;n.textAlign="left",n.textBaseline="middle";let d=-1,u=-h;return this.legendItems.forEach(((t,f)=>{const g=i+e/2+n.measureText(t.text).width;(0===f||l[l.length-1]+g+2*a>o)&&(c+=h,l[l.length-(f>0?0:1)]=0,u+=h,d++),r[f]={left:0,top:u,row:d,width:g,height:s},l[l.length-1]+=g+a})),c}_fitCols(t,e,i,s){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this,r=this.legendHitBoxes=[],l=this.columnSizes=[],h=o-t;let c=a,d=0,u=0,f=0,g=0;return this.legendItems.forEach(((t,o)=>{const{itemWidth:p,itemHeight:m}=function(t,e,i,s,n){const o=function(t,e,i,s){let n=t.text;n&&"string"!=typeof n&&(n=n.reduce(((t,e)=>t.length>e.length?t:e)));return e+i.size/2+s.measureText(n).width}(s,t,e,i),a=function(t,e,i){let s=t;"string"!=typeof e.text&&(s=_a(e,i));return s}(n,s,e.lineHeight);return{itemWidth:o,itemHeight:a}}(i,e,n,t,s);o>0&&u+m+2*a>h&&(c+=d+a,l.push({width:d,height:u}),f+=d+a,g++,d=u=0),r[o]={left:f,top:u,col:g,width:p,height:m},d=Math.max(d,p),u+=m+a})),c+=d,l.push({width:d,height:u}),c}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:e,options:{align:i,labels:{padding:s},rtl:n}}=this,o=Oi(n,this.left,this.width);if(this.isHorizontal()){let n=0,a=ft(i,this.left+s,this.right-this.lineWidths[n]);for(const r of e)n!==r.row&&(n=r.row,a=ft(i,this.left+s,this.right-this.lineWidths[n])),r.top+=this.top+t+s,r.left=o.leftForLtr(o.x(a),r.width),a+=r.width+s}else{let n=0,a=ft(i,this.top+t+s,this.bottom-this.columnSizes[n].height);for(const r of e)r.col!==n&&(n=r.col,a=ft(i,this.top+t+s,this.bottom-this.columnSizes[n].height)),r.top=a,r.left+=this.left+s,r.left=o.leftForLtr(o.x(r.left),r.width),a+=r.height+s}}isHorizontal(){return"top"===this.options.position||"bottom"===this.options.position}draw(){if(this.options.display){const t=this.ctx;Ie(t,this),this._draw(),ze(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:i,ctx:s}=this,{align:n,labels:o}=t,a=ue.color,r=Oi(t.rtl,this.left,this.width),h=Si(o.font),{padding:c}=o,d=h.size,u=d/2;let f;this.drawTitle(),s.textAlign=r.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=h.string;const{boxWidth:g,boxHeight:p,itemHeight:m}=ba(o,d),b=this.isHorizontal(),x=this._computeTitleHeight();f=b?{x:ft(n,this.left+c,this.right-i[0]),y:this.top+c+x,line:0}:{x:this.left+c,y:ft(n,this.top+x+c,this.bottom-e[0].height),line:0},Ai(this.ctx,t.textDirection);const _=m+c;this.legendItems.forEach(((y,v)=>{s.strokeStyle=y.fontColor,s.fillStyle=y.fontColor;const M=s.measureText(y.text).width,w=r.textAlign(y.textAlign||(y.textAlign=o.textAlign)),k=g+u+M;let S=f.x,P=f.y;r.setWidth(this.width),b?v>0&&S+k+c>this.right&&(P=f.y+=_,f.line++,S=f.x=ft(n,this.left+c,this.right-i[f.line])):v>0&&P+_>this.bottom&&(S=f.x=S+e[f.line].width+c,f.line++,P=f.y=ft(n,this.top+x+c,this.bottom-e[f.line].height));if(function(t,e,i){if(isNaN(g)||g<=0||isNaN(p)||p<0)return;s.save();const n=l(i.lineWidth,1);if(s.fillStyle=l(i.fillStyle,a),s.lineCap=l(i.lineCap,"butt"),s.lineDashOffset=l(i.lineDashOffset,0),s.lineJoin=l(i.lineJoin,"miter"),s.lineWidth=n,s.strokeStyle=l(i.strokeStyle,a),s.setLineDash(l(i.lineDash,[])),o.usePointStyle){const a={radius:p*Math.SQRT2/2,pointStyle:i.pointStyle,rotation:i.rotation,borderWidth:n},l=r.xPlus(t,g/2);Ee(s,a,l,e+u,o.pointStyleWidth&&g)}else{const o=e+Math.max((d-p)/2,0),a=r.leftForLtr(t,g),l=wi(i.borderRadius);s.beginPath(),Object.values(l).some((t=>0!==t))?He(s,{x:a,y:o,w:g,h:p,radius:l}):s.rect(a,o,g,p),s.fill(),0!==n&&s.stroke()}s.restore()}(r.x(S),P,y),S=gt(w,S+g+u,b?S+k:this.right,t.rtl),function(t,e,i){Ne(s,i.text,t,e+m/2,h,{strikethrough:i.hidden,textAlign:r.textAlign(i.textAlign)})}(r.x(S),P,y),b)f.x+=k+c;else if("string"!=typeof y.text){const t=h.lineHeight;f.y+=_a(y,t)+c}else f.y+=_})),Ti(this.ctx,t.textDirection)}drawTitle(){const t=this.options,e=t.title,i=Si(e.font),s=ki(e.padding);if(!e.display)return;const n=Oi(t.rtl,this.left,this.width),o=this.ctx,a=e.position,r=i.size/2,l=s.top+r;let h,c=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),h=this.top+l,c=ft(t.align,c,this.right-d);else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);h=l+ft(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=ft(a,c,c+d);o.textAlign=n.textAlign(ut(a)),o.textBaseline="middle",o.strokeStyle=e.color,o.fillStyle=e.color,o.font=i.string,Ne(o,e.text,u,h,i)}_computeTitleHeight(){const t=this.options.title,e=Si(t.font),i=ki(t.padding);return t.display?e.lineHeight+i.height:0}_getLegendItemAt(t,e){let i,s,n;if(tt(t,this.left,this.right)&&tt(e,this.top,this.bottom))for(n=this.legendHitBoxes,i=0;it.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:i,pointStyle:s,textAlign:n,color:o,useBorderRadius:a,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(i?0:void 0),h=ki(l.borderWidth);return{text:e[t.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:l.borderColor,pointStyle:s||l.pointStyle,rotation:l.rotation,textAlign:n||l.textAlign,borderRadius:a&&(r||l.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class va extends Hs{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 i=this.options;if(this.left=0,this.top=0,!i.display)return void(this.width=this.height=this.right=this.bottom=0);this.width=this.right=t,this.height=this.bottom=e;const s=n(i.text)?i.text.length:1;this._padding=ki(i.padding);const o=s*Si(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return"top"===t||"bottom"===t}_drawArgs(t){const{top:e,left:i,bottom:s,right:n,options:o}=this,a=o.align;let r,l,h,c=0;return this.isHorizontal()?(l=ft(a,i,n),h=e+t,r=n-i):("left"===o.position?(l=i+t,h=ft(a,s,e),c=-.5*C):(l=n-t,h=ft(a,e,s),c=.5*C),r=s-e),{titleX:l,titleY:h,maxWidth:r,rotation:c}}draw(){const t=this.ctx,e=this.options;if(!e.display)return;const i=Si(e.font),s=i.lineHeight/2+this._padding.top,{titleX:n,titleY:o,maxWidth:a,rotation:r}=this._drawArgs(s);Ne(t,e.text,0,0,i,{color:e.color,maxWidth:a,rotation:r,textAlign:ut(e.align),textBaseline:"middle",translation:[n,o]})}}var Ma={id:"title",_element:va,start(t,e,i){!function(t,e){const i=new va({ctx:t.ctx,options:e,chart:t});as.configure(t,i,e),as.addBox(t,i),t.titleBlock=i}(t,i)},stop(t){const e=t.titleBlock;as.removeBox(t,e),delete t.titleBlock},beforeUpdate(t,e,i){const s=t.titleBlock;as.configure(t,s,i),s.options=i},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 wa=new WeakMap;var ka={id:"subtitle",start(t,e,i){const s=new va({ctx:t.ctx,options:i,chart:t});as.configure(t,s,i),as.addBox(t,s),wa.set(t,s)},stop(t){as.removeBox(t,wa.get(t)),wa.delete(t)},beforeUpdate(t,e,i){const s=wa.get(t);as.configure(t,s,i),s.options=i},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 Sa={average(t){if(!t.length)return!1;let e,i,s=0,n=0,o=0;for(e=0,i=t.length;e-1?t.split("\n"):t}function Ca(t,e){const{element:i,datasetIndex:s,index:n}=e,o=t.getDatasetMeta(s).controller,{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[s].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:s,element:i}}function Oa(t,e){const i=t.chart.ctx,{body:s,footer:n,title:o}=t,{boxWidth:a,boxHeight:r}=e,l=Si(e.bodyFont),h=Si(e.titleFont),c=Si(e.footerFont),d=o.length,f=n.length,g=s.length,p=ki(e.padding);let m=p.height,b=0,x=s.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);if(x+=t.beforeBody.length+t.afterBody.length,d&&(m+=d*h.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),x){m+=g*(e.displayColors?Math.max(r,l.lineHeight):l.lineHeight)+(x-g)*l.lineHeight+(x-1)*e.bodySpacing}f&&(m+=e.footerMarginTop+f*c.lineHeight+(f-1)*e.footerSpacing);let _=0;const y=function(t){b=Math.max(b,i.measureText(t).width+_)};return i.save(),i.font=h.string,u(t.title,y),i.font=l.string,u(t.beforeBody.concat(t.afterBody),y),_=e.displayColors?a+2+e.boxPadding:0,u(s,(t=>{u(t.before,y),u(t.lines,y),u(t.after,y)})),_=0,i.font=c.string,u(t.footer,y),i.restore(),b+=p.width,{width:b,height:m}}function Aa(t,e,i,s){const{x:n,width:o}=i,{width:a,chartArea:{left:r,right:l}}=t;let h="center";return"center"===s?h=n<=(r+l)/2?"left":"right":n<=o/2?h="left":n>=a-o/2&&(h="right"),function(t,e,i,s){const{x:n,width:o}=s,a=i.caretSize+i.caretPadding;return"left"===t&&n+o+a>e.width||"right"===t&&n-o-a<0||void 0}(h,t,e,i)&&(h="center"),h}function Ta(t,e,i){const s=i.yAlign||e.yAlign||function(t,e){const{y:i,height:s}=e;return it.height-s/2?"bottom":"center"}(t,i);return{xAlign:i.xAlign||e.xAlign||Aa(t,e,i,s),yAlign:s}}function La(t,e,i,s){const{caretSize:n,caretPadding:o,cornerRadius:a}=t,{xAlign:r,yAlign:l}=i,h=n+o,{topLeft:c,topRight:d,bottomLeft:u,bottomRight:f}=wi(a);let g=function(t,e){let{x:i,width:s}=t;return"right"===e?i-=s:"center"===e&&(i-=s/2),i}(e,r);const p=function(t,e,i){let{y:s,height:n}=t;return"top"===e?s+=i:s-="bottom"===e?n+i:n/2,s}(e,l,h);return"center"===l?"left"===r?g+=h:"right"===r&&(g-=h):"left"===r?g-=Math.max(c,u)+n:"right"===r&&(g+=Math.max(d,f)+n),{x:J(g,0,s.width-e.width),y:J(p,0,s.height-e.height)}}function Ea(t,e,i){const s=ki(i.padding);return"center"===e?t.x+t.width/2:"right"===e?t.x+t.width-s.right:t.x+s.left}function Ra(t){return Pa([],Da(t))}function Ia(t,e){const i=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return i?t.override(i):t}const za={beforeTitle:e,title(t){if(t.length>0){const e=t[0],i=e.chart.data.labels,s=i?i.length:0;if(this&&this.options&&"dataset"===this.options.mode)return e.dataset.label||"";if(e.label)return e.label;if(s>0&&e.dataIndex{const e={before:[],lines:[],after:[]},n=Ia(i,t);Pa(e.before,Da(Fa(n,"beforeLabel",this,t))),Pa(e.lines,Fa(n,"label",this,t)),Pa(e.after,Da(Fa(n,"afterLabel",this,t))),s.push(e)})),s}getAfterBody(t,e){return Ra(Fa(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:i}=e,s=Fa(i,"beforeFooter",this,t),n=Fa(i,"footer",this,t),o=Fa(i,"afterFooter",this,t);let a=[];return a=Pa(a,Da(s)),a=Pa(a,Da(n)),a=Pa(a,Da(o)),a}_createItems(t){const e=this._active,i=this.chart.data,s=[],n=[],o=[];let a,r,l=[];for(a=0,r=e.length;at.filter(e,s,n,i)))),t.itemSort&&(l=l.sort(((e,s)=>t.itemSort(e,s,i)))),u(l,(e=>{const i=Ia(t.callbacks,e);s.push(Fa(i,"labelColor",this,e)),n.push(Fa(i,"labelPointStyle",this,e)),o.push(Fa(i,"labelTextColor",this,e))})),this.labelColors=s,this.labelPointStyles=n,this.labelTextColors=o,this.dataPoints=l,l}update(t,e){const i=this.options.setContext(this.getContext()),s=this._active;let n,o=[];if(s.length){const t=Sa[i.position].call(this,s,this._eventPosition);o=this._createItems(i),this.title=this.getTitle(o,i),this.beforeBody=this.getBeforeBody(o,i),this.body=this.getBody(o,i),this.afterBody=this.getAfterBody(o,i),this.footer=this.getFooter(o,i);const e=this._size=Oa(this,i),a=Object.assign({},t,e),r=Ta(this.chart,i,a),l=La(i,a,r,this.chart);this.xAlign=r.xAlign,this.yAlign=r.yAlign,n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else 0!==this.opacity&&(n={opacity:0});this._tooltipItems=o,this.$context=void 0,n&&this._resolveAnimations().update(this,n),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,i,s){const n=this.getCaretPosition(t,i,s);e.lineTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,i){const{xAlign:s,yAlign:n}=this,{caretSize:o,cornerRadius:a}=i,{topLeft:r,topRight:l,bottomLeft:h,bottomRight:c}=wi(a),{x:d,y:u}=t,{width:f,height:g}=e;let p,m,b,x,_,y;return"center"===n?(_=u+g/2,"left"===s?(p=d,m=p-o,x=_+o,y=_-o):(p=d+f,m=p+o,x=_-o,y=_+o),b=p):(m="left"===s?d+Math.max(r,h)+o:"right"===s?d+f-Math.max(l,c)-o:this.caretX,"top"===n?(x=u,_=x-o,p=m-o,b=m+o):(x=u+g,_=x+o,p=m+o,b=m-o),y=x),{x1:p,x2:m,x3:b,y1:x,y2:_,y3:y}}drawTitle(t,e,i){const s=this.title,n=s.length;let o,a,r;if(n){const l=Oi(i.rtl,this.x,this.width);for(t.x=Ea(this,i.titleAlign,i),e.textAlign=l.textAlign(i.titleAlign),e.textBaseline="middle",o=Si(i.titleFont),a=i.titleSpacing,e.fillStyle=i.titleColor,e.font=o.string,r=0;r0!==t))?(t.beginPath(),t.fillStyle=n.multiKeyBackground,He(t,{x:e,y:g,w:h,h:l,radius:r}),t.fill(),t.stroke(),t.fillStyle=a.backgroundColor,t.beginPath(),He(t,{x:i,y:g+1,w:h-2,h:l-2,radius:r}),t.fill()):(t.fillStyle=n.multiKeyBackground,t.fillRect(e,g,h,l),t.strokeRect(e,g,h,l),t.fillStyle=a.backgroundColor,t.fillRect(i,g+1,h-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,e,i){const{body:s}=this,{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:h}=i,c=Si(i.bodyFont);let d=c.lineHeight,f=0;const g=Oi(i.rtl,this.x,this.width),p=function(i){e.fillText(i,g.x(t.x+f),t.y+d/2),t.y+=d+n},m=g.textAlign(o);let b,x,_,y,v,M,w;for(e.textAlign=o,e.textBaseline="middle",e.font=c.string,t.x=Ea(this,m,i),e.fillStyle=i.bodyColor,u(this.beforeBody,p),f=a&&"right"!==m?"center"===o?l/2+h:l+2+h:0,y=0,M=s.length;y0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart,i=this.$animations,s=i&&i.x,n=i&&i.y;if(s||n){const i=Sa[t.position].call(this,this._active,this._eventPosition);if(!i)return;const o=this._size=Oa(this,t),a=Object.assign({},i,this._size),r=Ta(e,t,a),l=La(t,a,r,e);s._to===l.x&&n._to===l.y||(this.xAlign=r.xAlign,this.yAlign=r.yAlign,this.width=o.width,this.height=o.height,this.caretX=i.x,this.caretY=i.y,this._resolveAnimations().update(this,l))}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(e);const s={width:this.width,height:this.height},n={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const o=ki(e.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;e.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(n,t,s,e),Ai(t,e.textDirection),n.y+=o.top,this.drawTitle(n,t,e),this.drawBody(n,t,e),this.drawFooter(n,t,e),Ti(t,e.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,e){const i=this._active,s=t.map((({datasetIndex:t,index:e})=>{const i=this.chart.getDatasetMeta(t);if(!i)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:i.data[e],index:e}})),n=!f(i,s),o=this._positionChanged(s,e);(n||o)&&(this._active=s,this._eventPosition=e,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,e,i=!0){if(e&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,n=this._active||[],o=this._getActiveElements(t,n,e,i),a=this._positionChanged(o,t),r=e||!f(o,n)||a;return r&&(this._active=o,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,e))),r}_getActiveElements(t,e,i,s){const n=this.options;if("mouseout"===t.type)return[];if(!s)return e.filter((t=>this.chart.data.datasets[t.datasetIndex]&&void 0!==this.chart.getDatasetMeta(t.datasetIndex).controller.getParsed(t.index)));const o=this.chart.getElementsAtEventForMode(t,n.mode,n,i);return n.reverse&&o.reverse(),o}_positionChanged(t,e){const{caretX:i,caretY:s,options:n}=this,o=Sa[n.position].call(this,t,e);return!1!==o&&(i!==o.x||s!==o.y)}}var Ba={id:"tooltip",_element:Va,positioners:Sa,afterInit(t,e,i){i&&(t.tooltip=new Va({chart:t,options:i}))},beforeUpdate(t,e,i){t.tooltip&&t.tooltip.initialize(i)},reset(t,e,i){t.tooltip&&t.tooltip.initialize(i)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const i={tooltip:e};if(!1===t.notifyPlugins("beforeTooltipDraw",{...i,cancelable:!0}))return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",i)}},afterEvent(t,e){if(t.tooltip){const i=e.replay;t.tooltip.handleEvent(e.event,i,e.inChartArea)&&(e.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:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.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:za},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>"filter"!==t&&"itemSort"!==t&&"external"!==t,_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};return An.register(Yn,jo,fo,t),An.helpers={...Wi},An._adapters=Rn,An.Animation=Cs,An.Animations=Os,An.animator=xt,An.controllers=en.controllers.items,An.DatasetController=Ns,An.Element=Hs,An.elements=fo,An.Interaction=Xi,An.layouts=as,An.platforms=Ss,An.Scale=Js,An.Ticks=ae,Object.assign(An,Yn,jo,fo,t,Ss),An.Chart=An,"undefined"!=typeof window&&(window.Chart=An),An})); +//# sourceMappingURL=chart.umd.js.map diff --git a/static/lib/leaflet-heat.js b/static/lib/leaflet-heat.js new file mode 100644 index 0000000..aa8031a --- /dev/null +++ b/static/lib/leaflet-heat.js @@ -0,0 +1,11 @@ +/* + (c) 2014, Vladimir Agafonkin + simpleheat, a tiny JavaScript library for drawing heatmaps with Canvas + https://github.com/mourner/simpleheat +*/ +!function(){"use strict";function t(i){return this instanceof t?(this._canvas=i="string"==typeof i?document.getElementById(i):i,this._ctx=i.getContext("2d"),this._width=i.width,this._height=i.height,this._max=1,void this.clear()):new t(i)}t.prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t,i){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,i){i=i||15;var a=this._circle=document.createElement("canvas"),s=a.getContext("2d"),e=this._r=t+i;return a.width=a.height=2*e,s.shadowOffsetX=s.shadowOffsetY=200,s.shadowBlur=i,s.shadowColor="black",s.beginPath(),s.arc(e-200,e-200,t,0,2*Math.PI,!0),s.closePath(),s.fill(),this},gradient:function(t){var i=document.createElement("canvas"),a=i.getContext("2d"),s=a.createLinearGradient(0,0,0,256);i.width=1,i.height=256;for(var e in t)s.addColorStop(e,t[e]);return a.fillStyle=s,a.fillRect(0,0,1,256),this._grad=a.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var i=this._ctx;i.clearRect(0,0,this._width,this._height);for(var a,s=0,e=this._data.length;e>s;s++)a=this._data[s],i.globalAlpha=Math.max(a[2]/this._max,t||.05),i.drawImage(this._circle,a[0]-this._r,a[1]-this._r);var n=i.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),i.putImageData(n,0,0),this},_colorize:function(t,i){for(var a,s=3,e=t.length;e>s;s+=4)a=4*t[s],a&&(t[s-3]=i[a],t[s-2]=i[a+1],t[s-1]=i[a+2])}},window.simpleheat=t}(),/* + (c) 2014, Vladimir Agafonkin + Leaflet.heat, a tiny and fast heatmap plugin for Leaflet. + https://github.com/Leaflet/Leaflet.heat +*/ +L.HeatLayer=(L.Layer?L.Layer:L.Class).extend({initialize:function(t,i){this._latlngs=t,L.setOptions(this,i)},setLatLngs:function(t){return this._latlngs=t,this.redraw()},addLatLng:function(t){return this._latlngs.push(t),this.redraw()},setOptions:function(t){return L.setOptions(this,t),this._heat&&this._updateOptions(),this.redraw()},redraw:function(){return!this._heat||this._frame||this._map._animating||(this._frame=L.Util.requestAnimFrame(this._redraw,this)),this},onAdd:function(t){this._map=t,this._canvas||this._initCanvas(),t._panes.overlayPane.appendChild(this._canvas),t.on("moveend",this._reset,this),t.options.zoomAnimation&&L.Browser.any3d&&t.on("zoomanim",this._animateZoom,this),this._reset()},onRemove:function(t){t.getPanes().overlayPane.removeChild(this._canvas),t.off("moveend",this._reset,this),t.options.zoomAnimation&&t.off("zoomanim",this._animateZoom,this)},addTo:function(t){return t.addLayer(this),this},_initCanvas:function(){var t=this._canvas=L.DomUtil.create("canvas","leaflet-heatmap-layer leaflet-layer"),i=L.DomUtil.testProp(["transformOrigin","WebkitTransformOrigin","msTransformOrigin"]);t.style[i]="50% 50%";var a=this._map.getSize();t.width=a.x,t.height=a.y;var s=this._map.options.zoomAnimation&&L.Browser.any3d;L.DomUtil.addClass(t,"leaflet-zoom-"+(s?"animated":"hide")),this._heat=simpleheat(t),this._updateOptions()},_updateOptions:function(){this._heat.radius(this.options.radius||this._heat.defaultRadius,this.options.blur),this.options.gradient&&this._heat.gradient(this.options.gradient),this.options.max&&this._heat.max(this.options.max)},_reset:function(){var t=this._map.containerPointToLayerPoint([0,0]);L.DomUtil.setPosition(this._canvas,t);var i=this._map.getSize();this._heat._width!==i.x&&(this._canvas.width=this._heat._width=i.x),this._heat._height!==i.y&&(this._canvas.height=this._heat._height=i.y),this._redraw()},_redraw:function(){var t,i,a,s,e,n,h,o,r,d=[],_=this._heat._r,l=this._map.getSize(),m=new L.Bounds(L.point([-_,-_]),l.add([_,_])),c=void 0===this.options.max?1:this.options.max,u=void 0===this.options.maxZoom?this._map.getMaxZoom():this.options.maxZoom,f=1/Math.pow(2,Math.max(0,Math.min(u-this._map.getZoom(),12))),g=_/2,p=[],v=this._map._getMapPanePos(),w=v.x%g,y=v.y%g;for(t=0,i=this._latlngs.length;i>t;t++)if(a=this._map.latLngToContainerPoint(this._latlngs[t]),m.contains(a)){e=Math.floor((a.x-w)/g)+2,n=Math.floor((a.y-y)/g)+2;var x=void 0!==this._latlngs[t].alt?this._latlngs[t].alt:void 0!==this._latlngs[t][2]?+this._latlngs[t][2]:1;r=x*f,p[n]=p[n]||[],s=p[n][e],s?(s[0]=(s[0]*s[2]+a.x*r)/(s[2]+r),s[1]=(s[1]*s[2]+a.y*r)/(s[2]+r),s[2]+=r):p[n][e]=[a.x,a.y,r]}for(t=0,i=p.length;i>t;t++)if(p[t])for(h=0,o=p[t].length;o>h;h++)s=p[t][h],s&&d.push([Math.round(s[0]),Math.round(s[1]),Math.min(s[2],c)]);this._heat.data(d).draw(this.options.minOpacity),this._frame=null},_animateZoom:function(t){var i=this._map.getZoomScale(t.zoom),a=this._map._getCenterOffset(t.center)._multiplyBy(-i).subtract(this._map._getMapPanePos());L.DomUtil.setTransform?L.DomUtil.setTransform(this._canvas,a,i):this._canvas.style[L.DomUtil.TRANSFORM]=L.DomUtil.getTranslateString(a)+" scale("+i+")"}}),L.heatLayer=function(t,i){return new L.HeatLayer(t,i)}; \ No newline at end of file diff --git a/static/lib/leaflet.css b/static/lib/leaflet.css new file mode 100644 index 0000000..9ade8dc --- /dev/null +++ b/static/lib/leaflet.css @@ -0,0 +1,661 @@ +/* required styles */ + +.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; + } +/* Prevents IE11 from highlighting tiles in blue */ +.leaflet-tile::selection { + background: transparent; +} +/* Safari renders non-retina tile on retina better with this, but Chrome is worse */ +.leaflet-safari .leaflet-tile { + image-rendering: -webkit-optimize-contrast; + } +/* hack that prevents hw layers "stretching" when loading new tiles */ +.leaflet-safari .leaflet-tile-container { + width: 1600px; + height: 1600px; + -webkit-transform-origin: 0 0; + } +.leaflet-marker-icon, +.leaflet-marker-shadow { + display: block; + } +/* .leaflet-container svg: reset svg max-width decleration shipped in Joomla! (joomla.org) 3.x */ +/* .leaflet-container img: map is broken in FF if you have max-width: 100% on tiles */ +.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 { + /* See: https://bugs.chromium.org/p/chromium/issues/detail?id=600120 */ + 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; + /* Fallback for FF which doesn't support 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, 0.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; + } +/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */ +.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; + } + + +/* control positioning */ + +.leaflet-control { + position: relative; + z-index: 800; + pointer-events: visiblePainted; /* IE 9-10 doesn't have auto */ + 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; + } + + +/* zoom and fade animations */ + +.leaflet-fade-anim .leaflet-popup { + opacity: 0; + -webkit-transition: opacity 0.2s linear; + -moz-transition: opacity 0.2s linear; + transition: opacity 0.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 0.25s cubic-bezier(0,0,0.25,1); + -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1); + transition: transform 0.25s cubic-bezier(0,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; + } + + +/* cursors */ + +.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; + } + +/* marker & overlays interactivity */ +.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; /* IE 9-10 doesn't have auto */ + pointer-events: auto; + } + +/* visual tweaks */ + +.leaflet-container { + background: #ddd; + outline-offset: 1px; + } +.leaflet-container a { + color: #0078A8; + } +.leaflet-zoom-box { + border: 2px dotted #38f; + background: rgba(255,255,255,0.5); + } + + +/* general typography */ +.leaflet-container { + font-family: "Helvetica Neue", Arial, Helvetica, sans-serif; + font-size: 12px; + font-size: 0.75rem; + line-height: 1.5; + } + + +/* general toolbar styles */ + +.leaflet-bar { + box-shadow: 0 1px 5px rgba(0,0,0,0.65); + 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: black; + } +.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; + } + +/* zoom control */ + +.leaflet-control-zoom-in, +.leaflet-control-zoom-out { + font: bold 18px 'Lucida Console', Monaco, monospace; + text-indent: 1px; + } + +.leaflet-touch .leaflet-control-zoom-in, .leaflet-touch .leaflet-control-zoom-out { + font-size: 22px; + } + + +/* layers control */ + +.leaflet-control-layers { + box-shadow: 0 1px 5px rgba(0,0,0,0.4); + background: #fff; + border-radius: 5px; + } +.leaflet-control-layers-toggle { + background-image: url(images/layers.png); + width: 36px; + height: 36px; + } +.leaflet-retina .leaflet-control-layers-toggle { + background-image: url(images/layers-2x.png); + 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; + } + +/* Default icon URLs */ +.leaflet-default-icon-path { /* used only in path-guessing heuristic, see L.Icon.Default */ + background-image: url(images/marker-icon.png); + } + + +/* attribution and scale controls */ + +.leaflet-container .leaflet-control-attribution { + background: #fff; + background: rgba(255, 255, 255, 0.8); + 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: 0.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: rgba(255, 255, 255, 0.8); + 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,0.2); + background-clip: padding-box; + } + + +/* popup */ + +.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: 17px 0; + 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: white; + color: #333; + box-shadow: 0 3px 14px rgba(0,0,0,0.4); + } +.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=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.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; + } + + +/* div icon */ + +.leaflet-div-icon { + background: #fff; + border: 1px solid #666; + } + + +/* Tooltip */ +/* Base styles for the element that has a tooltip */ +.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 rgba(0,0,0,0.4); + } +.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: ""; + } + +/* Directions */ + +.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; + } + +/* Printing */ + +@media print { + /* Prevent printers from removing background-images of controls. */ + .leaflet-control { + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + } diff --git a/static/lib/leaflet.js b/static/lib/leaflet.js new file mode 100644 index 0000000..a3bf693 --- /dev/null +++ b/static/lib/leaflet.js @@ -0,0 +1,6 @@ +/* @preserve + * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com + * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var e,i,n=1,o=arguments.length;n=this.min.x&&i.x<=this.max.x&&e.y>=this.min.y&&i.y<=this.max.y},intersects:function(t){t=_(t);var e=this.min,i=this.max,n=t.min,t=t.max,o=t.x>=e.x&&n.x<=i.x,t=t.y>=e.y&&n.y<=i.y;return o&&t},overlaps:function(t){t=_(t);var e=this.min,i=this.max,n=t.min,t=t.max,o=t.x>e.x&&n.xe.y&&n.y=n.lat&&i.lat<=o.lat&&e.lng>=n.lng&&i.lng<=o.lng},intersects:function(t){t=g(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),t=t.getNorthEast(),o=t.lat>=e.lat&&n.lat<=i.lat,t=t.lng>=e.lng&&n.lng<=i.lng;return o&&t},overlaps:function(t){t=g(t);var e=this._southWest,i=this._northEast,n=t.getSouthWest(),t=t.getNorthEast(),o=t.lat>e.lat&&n.late.lng&&n.lng","http://www.w3.org/2000/svg"===(Wt.firstChild&&Wt.firstChild.namespaceURI));function y(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var b={ie:pt,ielt9:mt,edge:n,webkit:ft,android:gt,android23:vt,androidStock:yt,opera:xt,chrome:wt,gecko:bt,safari:Pt,phantom:Lt,opera12:o,win:Tt,ie3d:Mt,webkit3d:zt,gecko3d:_t,any3d:Ct,mobile:Zt,mobileWebkit:St,mobileWebkit3d:Et,msPointer:kt,pointer:Ot,touch:Bt,touchNative:At,mobileOpera:It,mobileGecko:Rt,retina:Nt,passiveEvents:Dt,canvas:jt,svg:Ht,vml:!Ht&&function(){try{var t=document.createElement("div"),e=(t.innerHTML='',t.firstChild);return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(t){return!1}}(),inlineSvg:Wt,mac:0===navigator.platform.indexOf("Mac"),linux:0===navigator.platform.indexOf("Linux")},Ft=b.msPointer?"MSPointerDown":"pointerdown",Ut=b.msPointer?"MSPointerMove":"pointermove",Vt=b.msPointer?"MSPointerUp":"pointerup",qt=b.msPointer?"MSPointerCancel":"pointercancel",Gt={touchstart:Ft,touchmove:Ut,touchend:Vt,touchcancel:qt},Kt={touchstart:function(t,e){e.MSPOINTER_TYPE_TOUCH&&e.pointerType===e.MSPOINTER_TYPE_TOUCH&&O(e);ee(t,e)},touchmove:ee,touchend:ee,touchcancel:ee},Yt={},Xt=!1;function Jt(t,e,i){return"touchstart"!==e||Xt||(document.addEventListener(Ft,$t,!0),document.addEventListener(Ut,Qt,!0),document.addEventListener(Vt,te,!0),document.addEventListener(qt,te,!0),Xt=!0),Kt[e]?(i=Kt[e].bind(this,i),t.addEventListener(Gt[e],i,!1),i):(console.warn("wrong event specified:",e),u)}function $t(t){Yt[t.pointerId]=t}function Qt(t){Yt[t.pointerId]&&(Yt[t.pointerId]=t)}function te(t){delete Yt[t.pointerId]}function ee(t,e){if(e.pointerType!==(e.MSPOINTER_TYPE_MOUSE||"mouse")){for(var i in e.touches=[],Yt)e.touches.push(Yt[i]);e.changedTouches=[e],t(e)}}var ie=200;function ne(t,i){t.addEventListener("dblclick",i);var n,o=0;function e(t){var e;1!==t.detail?n=t.detail:"mouse"===t.pointerType||t.sourceCapabilities&&!t.sourceCapabilities.firesTouchEvents||((e=Ne(t)).some(function(t){return t instanceof HTMLLabelElement&&t.attributes.for})&&!e.some(function(t){return t instanceof HTMLInputElement||t instanceof HTMLSelectElement})||((e=Date.now())-o<=ie?2===++n&&i(function(t){var e,i,n={};for(i in t)e=t[i],n[i]=e&&e.bind?e.bind(t):e;return(t=n).type="dblclick",n.detail=2,n.isTrusted=!1,n._simulated=!0,n}(t)):n=1,o=e))}return t.addEventListener("click",e),{dblclick:i,simDblclick:e}}var oe,se,re,ae,he,le,ue=we(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ce=we(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),de="webkitTransition"===ce||"OTransition"===ce?ce+"End":"transitionend";function _e(t){return"string"==typeof t?document.getElementById(t):t}function pe(t,e){var i=t.style[e]||t.currentStyle&&t.currentStyle[e];return"auto"===(i=i&&"auto"!==i||!document.defaultView?i:(t=document.defaultView.getComputedStyle(t,null))?t[e]:null)?null:i}function P(t,e,i){t=document.createElement(t);return t.className=e||"",i&&i.appendChild(t),t}function T(t){var e=t.parentNode;e&&e.removeChild(t)}function me(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function fe(t){var e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)}function ge(t){var e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)}function ve(t,e){return void 0!==t.classList?t.classList.contains(e):0<(t=xe(t)).length&&new RegExp("(^|\\s)"+e+"(\\s|$)").test(t)}function M(t,e){var i;if(void 0!==t.classList)for(var n=F(e),o=0,s=n.length;othis.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var i=this.getCenter(),t=this._limitCenter(i,this._zoom,g(t));return i.equals(t)||this.panTo(t,e),this._enforcingBounds=!1,this},panInside:function(t,e){var i=m((e=e||{}).paddingTopLeft||e.padding||[0,0]),n=m(e.paddingBottomRight||e.padding||[0,0]),o=this.project(this.getCenter()),t=this.project(t),s=this.getPixelBounds(),i=_([s.min.add(i),s.max.subtract(n)]),s=i.getSize();return i.contains(t)||(this._enforcingBounds=!0,n=t.subtract(i.getCenter()),i=i.extend(t).getSize().subtract(s),o.x+=n.x<0?-i.x:i.x,o.y+=n.y<0?-i.y:i.y,this.panTo(this.unproject(o),e),this._enforcingBounds=!1),this},invalidateSize:function(t){if(!this._loaded)return this;t=l({animate:!1,pan:!0},!0===t?{animate:!0}:t);var e=this.getSize(),i=(this._sizeChanged=!0,this._lastCenter=null,this.getSize()),n=e.divideBy(2).round(),o=i.divideBy(2).round(),n=n.subtract(o);return n.x||n.y?(t.animate&&t.pan?this.panBy(n):(t.pan&&this._rawPanBy(n),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(a(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:e,newSize:i})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){var e,i;return t=this._locateOptions=l({timeout:1e4,watch:!1},t),"geolocation"in navigator?(e=a(this._handleGeolocationResponse,this),i=a(this._handleGeolocationError,this),t.watch?this._locationWatchId=navigator.geolocation.watchPosition(e,i,t):navigator.geolocation.getCurrentPosition(e,i,t)):this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var e;this._container._leaflet_id&&(e=t.code,t=t.message||(1===e?"permission denied":2===e?"position unavailable":"timeout"),this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:e,message:"Geolocation error: "+t+"."}))},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var e,i,n=new v(t.coords.latitude,t.coords.longitude),o=n.toBounds(2*t.coords.accuracy),s=this._locateOptions,r=(s.setView&&(e=this.getBoundsZoom(o),this.setView(n,s.maxZoom?Math.min(e,s.maxZoom):e)),{latlng:n,bounds:o,timestamp:t.timestamp});for(i in t.coords)"number"==typeof t.coords[i]&&(r[i]=t.coords[i]);this.fire("locationfound",r)}},addHandler:function(t,e){return e&&(e=this[t]=new e(this),this._handlers.push(e),this.options[t]&&e.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(t){this._container._leaflet_id=void 0,this._containerId=void 0}for(var t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),T(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(r(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)T(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,e){e=P("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),e||this._mapPane);return t&&(this._panes[t]=e),e},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new s(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,e,i){t=g(t),i=m(i||[0,0]);var n=this.getZoom()||0,o=this.getMinZoom(),s=this.getMaxZoom(),r=t.getNorthWest(),t=t.getSouthEast(),i=this.getSize().subtract(i),t=_(this.project(t,n),this.project(r,n)).getSize(),r=b.any3d?this.options.zoomSnap:1,a=i.x/t.x,i=i.y/t.y,t=e?Math.max(a,i):Math.min(a,i),n=this.getScaleZoom(t,n);return r&&(n=Math.round(n/(r/100))*(r/100),n=e?Math.ceil(n/r)*r:Math.floor(n/r)*r),Math.max(o,Math.min(s,n))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new p(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,e){t=this._getTopLeftPoint(t,e);return new f(t,t.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,e){var i=this.options.crs;return e=void 0===e?this._zoom:e,i.scale(t)/i.scale(e)},getScaleZoom:function(t,e){var i=this.options.crs,t=(e=void 0===e?this._zoom:e,i.zoom(t*i.scale(e)));return isNaN(t)?1/0:t},project:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.latLngToPoint(w(t),e)},unproject:function(t,e){return e=void 0===e?this._zoom:e,this.options.crs.pointToLatLng(m(t),e)},layerPointToLatLng:function(t){t=m(t).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(t){return this.project(w(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(w(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(g(t))},distance:function(t,e){return this.options.crs.distance(w(t),w(e))},containerPointToLayerPoint:function(t){return m(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return m(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){t=this.containerPointToLayerPoint(m(t));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(w(t)))},mouseEventToContainerPoint:function(t){return De(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){t=this._container=_e(t);if(!t)throw new Error("Map container not found.");if(t._leaflet_id)throw new Error("Map container is already initialized.");S(t,"scroll",this._onScroll,this),this._containerId=h(t)},_initLayout:function(){var t=this._container,e=(this._fadeAnimated=this.options.fadeAnimation&&b.any3d,M(t,"leaflet-container"+(b.touch?" leaflet-touch":"")+(b.retina?" leaflet-retina":"")+(b.ielt9?" leaflet-oldie":"")+(b.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":"")),pe(t,"position"));"absolute"!==e&&"relative"!==e&&"fixed"!==e&&"sticky"!==e&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),Z(this._mapPane,new p(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(M(t.markerPane,"leaflet-zoom-hide"),M(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,e,i){Z(this._mapPane,new p(0,0));var n=!this._loaded,o=(this._loaded=!0,e=this._limitZoom(e),this.fire("viewprereset"),this._zoom!==e);this._moveStart(o,i)._move(t,e)._moveEnd(o),this.fire("viewreset"),n&&this.fire("load")},_moveStart:function(t,e){return t&&this.fire("zoomstart"),e||this.fire("movestart"),this},_move:function(t,e,i,n){void 0===e&&(e=this._zoom);var o=this._zoom!==e;return this._zoom=e,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),n?i&&i.pinch&&this.fire("zoom",i):((o||i&&i.pinch)&&this.fire("zoom",i),this.fire("move",i)),this},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return r(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){Z(this._mapPane,this._getMapPanePos().subtract(t))},_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(t){this._targets={};var e=t?k:S;e((this._targets[h(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&e(window,"resize",this._onResize,this),b.any3d&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){r(this._resizeRequest),this._resizeRequest=x(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var i,n=[],o="mouseout"===e||"mouseover"===e,s=t.target||t.srcElement,r=!1;s;){if((i=this._targets[h(s)])&&("click"===e||"preclick"===e)&&this._draggableMoved(i)){r=!0;break}if(i&&i.listens(e,!0)){if(o&&!We(s,t))break;if(n.push(i),o)break}if(s===this._container)break;s=s.parentNode}return n=n.length||r||o||!this.listens(e,!0)?n:[this]},_isClickDisabled:function(t){for(;t&&t!==this._container;){if(t._leaflet_disable_click)return!0;t=t.parentNode}},_handleDOMEvent:function(t){var e,i=t.target||t.srcElement;!this._loaded||i._leaflet_disable_events||"click"===t.type&&this._isClickDisabled(i)||("mousedown"===(e=t.type)&&Me(i),this._fireDOMEvent(t,e))},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,e,i){"click"===t.type&&((a=l({},t)).type="preclick",this._fireDOMEvent(a,a.type,i));var n=this._findEventTargets(t,e);if(i){for(var o=[],s=0;sthis.options.zoomAnimationThreshold)return!1;var n=this.getZoomScale(e),n=this._getCenterOffset(t)._divideBy(1-1/n);if(!0!==i.animate&&!this.getSize().contains(n))return!1;x(function(){this._moveStart(!0,i.noMoveStart||!1)._animateZoom(t,e,!0)},this)}return!0},_animateZoom:function(t,e,i,n){this._mapPane&&(i&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,M(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:n}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(a(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 Ue(t){return new B(t)}var B=et.extend({options:{position:"topright"},initialize:function(t){c(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var e=this._container=this.onAdd(t),i=this.getPosition(),t=t._controlCorners[i];return M(e,"leaflet-control"),-1!==i.indexOf("bottom")?t.insertBefore(e,t.firstChild):t.appendChild(e),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(T(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",e=document.createElement("div");return e.innerHTML=t,e.firstChild},_addItem:function(t){var e,i=document.createElement("label"),n=this._map.hasLayer(t.layer),n=(t.overlay?((e=document.createElement("input")).type="checkbox",e.className="leaflet-control-layers-selector",e.defaultChecked=n):e=this._createRadioElement("leaflet-base-layers_"+h(this),n),this._layerControlInputs.push(e),e.layerId=h(t.layer),S(e,"click",this._onInputClick,this),document.createElement("span")),o=(n.innerHTML=" "+t.name,document.createElement("span"));return i.appendChild(o),o.appendChild(e),o.appendChild(n),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(i),this._checkDisabledLayers(),i},_onInputClick:function(){if(!this._preventClick){var t,e,i=this._layerControlInputs,n=[],o=[];this._handlingClick=!0;for(var s=i.length-1;0<=s;s--)t=i[s],e=this._getLayer(t.layerId).layer,t.checked?n.push(e):t.checked||o.push(e);for(s=0;se.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var t=this._section,e=(this._preventClick=!0,S(t,"click",O),this.expand(),this);setTimeout(function(){k(t,"click",O),e._preventClick=!1})}})),qe=B.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",i=P("div",e+" leaflet-bar"),n=this.options;return this._zoomInButton=this._createButton(n.zoomInText,n.zoomInTitle,e+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(n.zoomOutText,n.zoomOutTitle,e+"-out",i,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(t){t.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(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,i,n,o){i=P("a",i,n);return i.innerHTML=t,i.href="#",i.title=e,i.setAttribute("role","button"),i.setAttribute("aria-label",e),Ie(i),S(i,"click",Re),S(i,"click",o,this),S(i,"click",this._refocusOnMap,this),i},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";z(this._zoomInButton,e),z(this._zoomOutButton,e),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),!this._disabled&&t._zoom!==t.getMinZoom()||(M(this._zoomOutButton,e),this._zoomOutButton.setAttribute("aria-disabled","true")),!this._disabled&&t._zoom!==t.getMaxZoom()||(M(this._zoomInButton,e),this._zoomInButton.setAttribute("aria-disabled","true"))}}),Ge=(A.mergeOptions({zoomControl:!0}),A.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new qe,this.addControl(this.zoomControl))}),B.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",i=P("div",e),n=this.options;return this._addScales(n,e+"-line",i),t.on(n.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),i},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,i){t.metric&&(this._mScale=P("div",e,i)),t.imperial&&(this._iScale=P("div",e,i))},_update:function(){var t=this._map,e=t.getSize().y/2,t=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(t)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t);this._updateScale(this._mScale,e<1e3?e+" m":e/1e3+" km",e/t)},_updateImperial:function(t){var e,i,t=3.2808399*t;5280'+(b.inlineSvg?' ':"")+"Leaflet"},initialize:function(t){c(this,t),this._attributions={}},onAdd:function(t){for(var e in(t.attributionControl=this)._container=P("div","leaflet-control-attribution"),Ie(this._container),t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container},onRemove:function(t){t.off("layeradd",this._addAttribution,this)},_addAttribution:function(t){t.layer.getAttribution&&(this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",function(){this.removeAttribution(t.layer.getAttribution())},this))},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t,e=[];for(t in this._attributions)this._attributions[t]&&e.push(t);var i=[];this.options.prefix&&i.push(this.options.prefix),e.length&&i.push(e.join(", ")),this._container.innerHTML=i.join(' ')}}}),n=(A.mergeOptions({attributionControl:!0}),A.addInitHook(function(){this.options.attributionControl&&(new Ke).addTo(this)}),B.Layers=Ve,B.Zoom=qe,B.Scale=Ge,B.Attribution=Ke,Ue.layers=function(t,e,i){return new Ve(t,e,i)},Ue.zoom=function(t){return new qe(t)},Ue.scale=function(t){return new Ge(t)},Ue.attribution=function(t){return new Ke(t)},et.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}})),ft=(n.addTo=function(t,e){return t.addHandler(e,this),this},{Events:e}),Ye=b.touch?"touchstart mousedown":"mousedown",Xe=it.extend({options:{clickTolerance:3},initialize:function(t,e,i,n){c(this,n),this._element=t,this._dragStartTarget=e||t,this._preventOutline=i},enable:function(){this._enabled||(S(this._dragStartTarget,Ye,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Xe._dragging===this&&this.finishDrag(!0),k(this._dragStartTarget,Ye,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){var e,i;this._enabled&&(this._moved=!1,ve(this._element,"leaflet-zoom-anim")||(t.touches&&1!==t.touches.length?Xe._dragging===this&&this.finishDrag():Xe._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((Xe._dragging=this)._preventOutline&&Me(this._element),Le(),re(),this._moving||(this.fire("down"),i=t.touches?t.touches[0]:t,e=Ce(this._element),this._startPoint=new p(i.clientX,i.clientY),this._startPos=Pe(this._element),this._parentScale=Ze(e),i="mousedown"===t.type,S(document,i?"mousemove":"touchmove",this._onMove,this),S(document,i?"mouseup":"touchend touchcancel",this._onUp,this)))))},_onMove:function(t){var e;this._enabled&&(t.touches&&1e&&(i.push(t[n]),o=n);oe.max.x&&(i|=2),t.ye.max.y&&(i|=8),i}function ri(t,e,i,n){var o=e.x,e=e.y,s=i.x-o,r=i.y-e,a=s*s+r*r;return 0this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()t.y!=n.y>t.y&&t.x<(n.x-i.x)*(t.y-i.y)/(n.y-i.y)+i.x&&(l=!l);return l||yi.prototype._containsPoint.call(this,t,!0)}});var wi=ci.extend({initialize:function(t,e){c(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,i,n,o=d(t)?t:t.features;if(o){for(e=0,i=o.length;es.x&&(r=i.x+a-s.x+o.x),i.x-r-n.x<(a=0)&&(r=i.x-n.x),i.y+e+o.y>s.y&&(a=i.y+e-s.y+o.y),i.y-a-n.y<0&&(a=i.y-n.y),(r||a)&&(this.options.keepInView&&(this._autopanning=!0),t.fire("autopanstart").panBy([r,a]))))},_getAnchor:function(){return m(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}})),Ii=(A.mergeOptions({closePopupOnClick:!0}),A.include({openPopup:function(t,e,i){return this._initOverlay(Bi,t,e,i).openOn(this),this},closePopup:function(t){return(t=arguments.length?t:this._popup)&&t.close(),this}}),o.include({bindPopup:function(t,e){return this._popup=this._initOverlay(Bi,this._popup,t,e),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(t){return this._popup&&(this instanceof ci||(this._popup._source=this),this._popup._prepareOpen(t||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()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var e;this._popup&&this._map&&(Re(t),e=t.layer||t.target,this._popup._source!==e||e instanceof fi?(this._popup._source=e,this.openPopup(t.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}}),Ai.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(t){Ai.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(t){Ai.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var t=Ai.prototype.getEvents.call(this);return this.options.permanent||(t.preclick=this.close),t},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=P("div",t),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+h(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e,i=this._map,n=this._container,o=i.latLngToContainerPoint(i.getCenter()),i=i.layerPointToContainerPoint(t),s=this.options.direction,r=n.offsetWidth,a=n.offsetHeight,h=m(this.options.offset),l=this._getAnchor(),i="top"===s?(e=r/2,a):"bottom"===s?(e=r/2,0):(e="center"===s?r/2:"right"===s?0:"left"===s?r:i.xthis.options.maxZoom||nthis.options.maxZoom||void 0!==this.options.minZoom&&oi.max.x)||!e.wrapLat&&(t.yi.max.y))return!1}return!this.options.bounds||(e=this._tileCoordsToBounds(t),g(this.options.bounds).overlaps(e))},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,i=this.getTileSize(),n=t.scaleBy(i),i=n.add(i);return[e.unproject(n,t.z),e.unproject(i,t.z)]},_tileCoordsToBounds:function(t){t=this._tileCoordsToNwSe(t),t=new s(t[0],t[1]);return t=this.options.noWrap?t:this._map.wrapLatLngBounds(t)},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var t=t.split(":"),e=new p(+t[0],+t[1]);return e.z=+t[2],e},_removeTile:function(t){var e=this._tiles[t];e&&(T(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){M(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=u,t.onmousemove=u,b.ielt9&&this.options.opacity<1&&C(t,this.options.opacity)},_addTile:function(t,e){var i=this._getTilePos(t),n=this._tileCoordsToKey(t),o=this.createTile(this._wrapCoords(t),a(this._tileReady,this,t));this._initTile(o),this.createTile.length<2&&x(a(this._tileReady,this,t,null,o)),Z(o,i),this._tiles[n]={el:o,coords:t,current:!0},e.appendChild(o),this.fire("tileloadstart",{tile:o,coords:t})},_tileReady:function(t,e,i){e&&this.fire("tileerror",{error:e,tile:i,coords:t});var n=this._tileCoordsToKey(t);(i=this._tiles[n])&&(i.loaded=+new Date,this._map._fadeAnimated?(C(i.el,0),r(this._fadeFrame),this._fadeFrame=x(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),e||(M(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),b.ielt9||!this._map._fadeAnimated?x(this._pruneTiles,this):setTimeout(a(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new p(this._wrapX?H(t.x,this._wrapX):t.x,this._wrapY?H(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new f(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var Di=Ni.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(t,e){this._url=t,(e=c(this,e)).detectRetina&&b.retina&&0')}}catch(t){}return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),zt={_initContainer:function(){this._container=P("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Wi.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=Vi("shape");M(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=Vi("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;T(e),t.removeInteractiveTarget(e),delete this._layers[h(t)]},_updateStyle:function(t){var e=t._stroke,i=t._fill,n=t.options,o=t._container;o.stroked=!!n.stroke,o.filled=!!n.fill,n.stroke?(e=e||(t._stroke=Vi("stroke")),o.appendChild(e),e.weight=n.weight+"px",e.color=n.color,e.opacity=n.opacity,n.dashArray?e.dashStyle=d(n.dashArray)?n.dashArray.join(" "):n.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=n.lineCap.replace("butt","flat"),e.joinstyle=n.lineJoin):e&&(o.removeChild(e),t._stroke=null),n.fill?(i=i||(t._fill=Vi("fill")),o.appendChild(i),i.color=n.fillColor||n.color,i.opacity=n.fillOpacity):i&&(o.removeChild(i),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),i=Math.round(t._radius),n=Math.round(t._radiusY||i);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+i+","+n+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){fe(t._container)},_bringToBack:function(t){ge(t._container)}},qi=b.vml?Vi:ct,Gi=Wi.extend({_initContainer:function(){this._container=qi("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=qi("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){T(this._container),k(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){var t,e,i;this._map._animatingZoom&&this._bounds||(Wi.prototype._update.call(this),e=(t=this._bounds).getSize(),i=this._container,this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,i.setAttribute("width",e.x),i.setAttribute("height",e.y)),Z(i,t.min),i.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update"))},_initPath:function(t){var e=t._path=qi("path");t.options.className&&M(e,t.options.className),t.options.interactive&&M(e,"leaflet-interactive"),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){T(t._path),t.removeInteractiveTarget(t._path),delete this._layers[h(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,t=t.options;e&&(t.stroke?(e.setAttribute("stroke",t.color),e.setAttribute("stroke-opacity",t.opacity),e.setAttribute("stroke-width",t.weight),e.setAttribute("stroke-linecap",t.lineCap),e.setAttribute("stroke-linejoin",t.lineJoin),t.dashArray?e.setAttribute("stroke-dasharray",t.dashArray):e.removeAttribute("stroke-dasharray"),t.dashOffset?e.setAttribute("stroke-dashoffset",t.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),t.fill?(e.setAttribute("fill",t.fillColor||t.color),e.setAttribute("fill-opacity",t.fillOpacity),e.setAttribute("fill-rule",t.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,dt(t._parts,e))},_updateCircle:function(t){var e=t._point,i=Math.max(Math.round(t._radius),1),n="a"+i+","+(Math.max(Math.round(t._radiusY),1)||i)+" 0 1,0 ",e=t._empty()?"M0 0":"M"+(e.x-i)+","+e.y+n+2*i+",0 "+n+2*-i+",0 ";this._setPath(t,e)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){fe(t._path)},_bringToBack:function(t){ge(t._path)}});function Ki(t){return b.svg||b.vml?new Gi(t):null}b.vml&&Gi.include(zt),A.include({getRenderer:function(t){t=(t=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer)||(this._renderer=this._createRenderer());return this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(t){var e;return"overlayPane"!==t&&void 0!==t&&(void 0===(e=this._paneRenderers[t])&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e)},_createRenderer:function(t){return this.options.preferCanvas&&Ui(t)||Ki(t)}});var Yi=xi.extend({initialize:function(t,e){xi.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=g(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});Gi.create=qi,Gi.pointsToPath=dt,wi.geometryToLayer=bi,wi.coordsToLatLng=Li,wi.coordsToLatLngs=Ti,wi.latLngToCoords=Mi,wi.latLngsToCoords=zi,wi.getFeature=Ci,wi.asFeature=Zi,A.mergeOptions({boxZoom:!0});var _t=n.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){S(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){k(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){T(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),re(),Le(),this._startPoint=this._map.mouseEventToContainerPoint(t),S(document,{contextmenu:Re,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=P("div","leaflet-zoom-box",this._container),M(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var t=new f(this._point,this._startPoint),e=t.getSize();Z(this._box,t.min),this._box.style.width=e.x+"px",this._box.style.height=e.y+"px"},_finish:function(){this._moved&&(T(this._box),z(this._container,"leaflet-crosshair")),ae(),Te(),k(document,{contextmenu:Re,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){1!==t.which&&1!==t.button||(this._finish(),this._moved&&(this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(a(this._resetState,this),0),t=new s(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point)),this._map.fitBounds(t).fire("boxzoomend",{boxZoomBounds:t})))},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}}),Ct=(A.addInitHook("addHandler","boxZoom",_t),A.mergeOptions({doubleClickZoom:!0}),n.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,i=e.getZoom(),n=e.options.zoomDelta,i=t.originalEvent.shiftKey?i-n:i+n;"center"===e.options.doubleClickZoom?e.setZoom(i):e.setZoomAround(t.containerPoint,i)}})),Zt=(A.addInitHook("addHandler","doubleClickZoom",Ct),A.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0}),n.extend({addHooks:function(){var t;this._draggable||(t=this._map,this._draggable=new Xe(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))),M(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){z(this._map._container,"leaflet-grab"),z(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 t,e=this._map;e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity?(t=g(this._map.options.maxBounds),this._offsetLimit=_(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))):this._offsetLimit=null,e.fire("movestart").fire("dragstart"),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){var e,i;this._map.options.inertia&&(e=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos,this._positions.push(i),this._times.push(e),this._prunePositions(e)),this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1e.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t))},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),i=this._initialWorldOffset,n=this._draggable._newPos.x,o=(n-e+i)%t+e-i,n=(n+e+i)%t-e-i,t=Math.abs(o+i)e.getMaxZoom()&&1=i;)t=t.__parent;return this._currentShownBounds.contains(t.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(e,t):this._animationAddLayerNonAnimated(e,t)),this},removeLayer:function(e){return e instanceof L.LayerGroup?this.removeLayers([e]):(e.getLatLng?this._map?e.__parent&&(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(e)),this._removeLayer(e,!0),this.fire("layerremove",{layer:e}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),e.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(e)&&(this._featureGroup.removeLayer(e),e.clusterShow&&e.clusterShow())):(!this._arraySplice(this._needsClustering,e)&&this.hasLayer(e)&&this._needsRemoving.push({layer:e,latlng:e._latlng}),this.fire("layerremove",{layer:e})):(this._nonPointGroup.removeLayer(e),this.fire("layerremove",{layer:e})),this)},addLayers:function(n,s){if(!L.Util.isArray(n))return this.addLayer(n);var o,a=this._featureGroup,h=this._nonPointGroup,l=this.options.chunkedLoading,u=this.options.chunkInterval,_=this.options.chunkProgress,d=n.length,p=0,c=!0;if(this._map){var f=(new Date).getTime(),m=L.bind(function(){var e=(new Date).getTime();for(this._map&&this._unspiderfy&&this._unspiderfy();p"+t+"",className:"marker-cluster"+i,iconSize:new L.Point(40,40)})},_bindEvents:function(){var e=this._map,t=this.options.spiderfyOnMaxZoom,i=this.options.showCoverageOnHover,r=this.options.zoomToBoundsOnClick,n=this.options.spiderfyOnEveryZoom;(t||r||n)&&this.on("clusterclick clusterkeypress",this._zoomOrSpiderfy,this),i&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),e.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(e){var t=e.layer,i=t;if("clusterkeypress"!==e.type||!e.originalEvent||13===e.originalEvent.keyCode){for(;1===i._childClusters.length;)i=i._childClusters[0];i._zoom===this._maxZoom&&i._childCount===t._childCount&&this.options.spiderfyOnMaxZoom?t.spiderfy():this.options.zoomToBoundsOnClick&&t.zoomToBounds(),this.options.spiderfyOnEveryZoom&&t.spiderfy(),e.originalEvent&&13===e.originalEvent.keyCode&&this._map._container.focus()}},_showCoverage:function(e){var t=this._map;this._inZoomAnimation||(this._shownPolygon&&t.removeLayer(this._shownPolygon),2h._zoom;r--)u=new this._markerCluster(this,r,u),n[r].addObject(u,this._map.project(a.getLatLng(),r));return h._addChild(u),void this._removeFromGridUnclustered(a,t)}s[t].addObject(e,i)}this._topClusterLevel._addChild(e),e.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(e){e instanceof L.MarkerCluster&&e._iconNeedsUpdate&&e._updateIcon()})},_enqueue:function(e){this._queue.push(e),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var e=0;ee?(this._animationStart(),this._animationZoomOut(this._zoom,e)):this._moveEnd()},_getExpandedVisibleBounds:function(){return this.options.removeOutsideVisibleBounds?L.Browser.mobile?this._checkBoundsMaxLat(this._map.getBounds()):this._checkBoundsMaxLat(this._map.getBounds().pad(1)):this._mapBoundsInfinite},_checkBoundsMaxLat:function(e){var t=this._maxLat;return void 0!==t&&(e.getNorth()>=t&&(e._northEast.lat=1/0),e.getSouth()<=-t&&(e._southWest.lat=-1/0)),e},_animationAddLayerNonAnimated:function(e,t){if(t===e)this._featureGroup.addLayer(e);else if(2===t._childCount){t._addToMap();var i=t.getAllChildMarkers();this._featureGroup.removeLayer(i[0]),this._featureGroup.removeLayer(i[1])}else t._updateIcon()},_extractNonGroupLayers:function(e,t){var i,r=e.getLayers(),n=0;for(t=t||[];ni)&&(i=(o=d).lat),(!1===r||d.latn)&&(n=(h=d).lng),(!1===s||d.lng=this._circleSpiralSwitchover?this._generatePointsSpiral(t.length,i):(i.y+=10,this._generatePointsCircle(t.length,i)),this._animationSpiderfy(t,e)}},unspiderfy:function(e){this._group._inZoomAnimation||(this._animationUnspiderfy(e),this._group._spiderfied=null)},_generatePointsCircle:function(e,t){var i,r,n=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+e)/this._2PI,s=this._2PI/e,o=[];for(n=Math.max(n,35),o.length=e,i=0;i * {vertical-align: middle;display: inline-block;}.u-legend .u-marker {width: 1em;height: 1em;margin-right: 4px;background-clip: padding-box !important;}.u-inline.u-live th::after {content: ":";vertical-align: middle;}.u-inline:not(.u-live) .u-value {display: none;}.u-series > * {padding: 4px;}.u-series th {cursor: pointer;}.u-legend .u-off > * {opacity: 0.3;}.u-select {background: rgba(0,0,0,0.07);position: absolute;pointer-events: none;}.u-cursor-x, .u-cursor-y {position: absolute;left: 0;top: 0;pointer-events: none;will-change: transform;}.u-hz .u-cursor-x, .u-vt .u-cursor-y {height: 100%;border-right: 1px dashed #607D8B;}.u-hz .u-cursor-y, .u-vt .u-cursor-x {width: 100%;border-bottom: 1px dashed #607D8B;}.u-cursor-pt {position: absolute;top: 0;left: 0;border-radius: 50%;border: 0 solid;pointer-events: none;will-change: transform;/*this has to be !important since we set inline "background" shorthand */background-clip: padding-box !important;}.u-axis.u-off, .u-select.u-off, .u-cursor-x.u-off, .u-cursor-y.u-off, .u-cursor-pt.u-off {display: none;} \ No newline at end of file diff --git a/static/lib/uPlot.min.js b/static/lib/uPlot.min.js new file mode 100644 index 0000000..172c74e --- /dev/null +++ b/static/lib/uPlot.min.js @@ -0,0 +1,2 @@ +/*! https://github.com/leeoniya/uPlot (v1.6.30) */ +var uPlot=function(){"use strict";const l="u-off",e="u-label",t="width",n="height",i="top",o="bottom",s="left",r="right",u="#000",a=u+"0",f="mousemove",c="mousedown",h="mouseup",d="mouseenter",p="mouseleave",m="dblclick",g="change",x="dppxchange",w="--",_="undefined"!=typeof window,b=_?document:null,v=_?window:null,k=_?navigator:null;let y,M;function S(l,e){if(null!=e){let t=l.classList;!t.contains(e)&&t.add(e)}}function E(l,e){let t=l.classList;t.contains(e)&&t.remove(e)}function T(l,e,t){l.style[e]=t+"px"}function z(l,e,t,n){let i=b.createElement(l);return null!=e&&S(i,e),null!=t&&t.insertBefore(i,n),i}function D(l,e){return z("div",l,e)}const P=new WeakMap;function A(e,t,n,i,o){let s="translate("+t+"px,"+n+"px)";s!=P.get(e)&&(e.style.transform=s,P.set(e,s),0>t||0>n||t>i||n>o?S(e,l):E(e,l))}const W=new WeakMap;function Y(l,e,t){let n=e+t;n!=W.get(l)&&(W.set(l,n),l.style.background=e,l.style.borderColor=t)}const C=new WeakMap;function F(l,e,t,n){let i=e+""+t;i!=C.get(l)&&(C.set(l,i),l.style.height=t+"px",l.style.width=e+"px",l.style.marginLeft=n?-e/2+"px":0,l.style.marginTop=n?-t/2+"px":0)}const H={passive:!0},R={...H,capture:!0};function G(l,e,t,n){e.addEventListener(l,t,n?R:H)}function I(l,e,t,n){e.removeEventListener(l,t,n?R:H)}function L(l,e,t,n){let i;t=t||0;let o=2147483647>=(n=n||e.length-1);for(;n-t>1;)i=o?t+n>>1:tl((t+n)/2),l>e[i]?t=i:n=i;return l-e[t]>e[n]-l?n:t}function O(l,e,t,n){for(let i=1==n?e:t;i>=e&&t>=i;i+=n)if(null!=l[i])return i;return-1}function N(l,e,t,n){let i=ul(l),o=ul(e);l==e&&(-1==i?(l*=t,e/=t):(l/=t,e*=t));let s=10==t?al:fl,r=1==o?il:tl,u=(1==i?tl:il)(s(el(l))),a=r(s(el(e))),f=rl(t,u),c=rl(t,a);return 10==t&&(0>u&&(f=Sl(f,-u)),0>a&&(c=Sl(c,-a))),n||2==t?(l=f*i,e=c*o):(l=Ml(l,f),e=yl(e,c)),[l,e]}function j(l,e,t,n){let i=N(l,e,t,n);return 0==l&&(i[0]=0),0==e&&(i[1]=0),i}_&&function l(){let e=devicePixelRatio;y!=e&&(y=e,M&&I(g,M,l),M=matchMedia(`(min-resolution: ${y-.001}dppx) and (max-resolution: ${y+.001}dppx)`),G(g,M,l),v.dispatchEvent(new CustomEvent(x)))}();const U=.1,B={mode:3,pad:U},V={pad:0,soft:null,mode:0},J={min:V,max:V};function q(l,e,t,n){return Fl(t)?X(l,e,t):(V.pad=t,V.soft=n?0:null,V.mode=n?3:0,X(l,e,J))}function K(l,e){return null==l?e:l}function X(l,e,t){let n=t.min,i=t.max,o=K(n.pad,0),s=K(i.pad,0),r=K(n.hard,-hl),u=K(i.hard,hl),a=K(n.soft,hl),f=K(i.soft,-hl),c=K(n.mode,0),h=K(i.mode,0),d=e-l,p=al(d),m=sl(el(l),el(e)),g=al(m),x=el(g-p);(1e-9>d||x>10)&&(d=0,0!=l&&0!=e||(d=1e-9,2==c&&a!=hl&&(o=0),2==h&&f!=-hl&&(s=0)));let w=d||m||1e3,_=al(w),b=rl(10,tl(_)),v=Sl(Ml(l-w*(0==d?0==l?.1:1:o),b/10),9),k=a>l||1!=c&&(3!=c||v>a)&&(2!=c||a>v)?hl:a,y=sl(r,k>v&&l>=k?k:ol(k,v)),M=Sl(yl(e+w*(0==d?0==e?.1:1:s),b/10),9),S=e>f||1!=h&&(3!=h||f>M)&&(2!=h||M>f)?-hl:f,E=ol(u,M>S&&S>=e?S:sl(S,M));return y==E&&0==y&&(E=100),[y,E]}const Z=new Intl.NumberFormat(_?k.language:"en-US"),$=l=>Z.format(l),Q=Math,ll=Q.PI,el=Q.abs,tl=Q.floor,nl=Q.round,il=Q.ceil,ol=Q.min,sl=Q.max,rl=Q.pow,ul=Q.sign,al=Q.log10,fl=Q.log2,cl=(l,e=1)=>Q.asinh(l/e),hl=1/0;function dl(l){return 1+(0|al((l^l>>31)-(l>>31)))}function pl(l,e,t){return ol(sl(l,e),t)}function ml(l){return"function"==typeof l?l:()=>l}const gl=l=>l,xl=(l,e)=>e,wl=()=>null,_l=()=>!0,bl=(l,e)=>l==e,vl=l=>Sl(l,14);function kl(l,e){return vl(Sl(vl(l/e))*e)}function yl(l,e){return vl(il(vl(l/e))*e)}function Ml(l,e){return vl(tl(vl(l/e))*e)}function Sl(l,e=0){if(Yl(l))return l;let t=10**e;return nl(l*t*(1+Number.EPSILON))/t}const El=new Map;function Tl(l){return((""+l).split(".")[1]||"").length}function zl(l,e,t,n){let i=[],o=n.map(Tl);for(let s=e;t>s;s++){let e=el(s),t=Sl(rl(l,s),e);for(let l=0;n.length>l;l++){let r=n[l]*t,u=(0>r||0>s?e:0)+(o[l]>s?o[l]:0),a=Sl(r,u);i.push(a),El.set(a,u)}}return i}const Dl={},Pl=[],Al=[null,null],Wl=Array.isArray,Yl=Number.isInteger;function Cl(l){return"string"==typeof l}function Fl(l){let e=!1;if(null!=l){let t=l.constructor;e=null==t||t==Object}return e}function Hl(l){return null!=l&&"object"==typeof l}const Rl=Object.getPrototypeOf(Uint8Array);function Gl(l,e=Fl){let t;if(Wl(l)){let n=l.find((l=>null!=l));if(Wl(n)||e(n)){t=Array(l.length);for(let n=0;l.length>n;n++)t[n]=Gl(l[n],e)}else t=l.slice()}else if(l instanceof Rl)t=l.slice();else if(e(l)){t={};for(let n in l)t[n]=Gl(l[n],e)}else t=l;return t}function Il(l){let e=arguments;for(let t=1;e.length>t;t++){let n=e[t];for(let e in n)Fl(l[e])?Il(l[e],Gl(n[e])):l[e]=Gl(n[e])}return l}function Ll(l,e,t){for(let n,i=0,o=-1;e.length>i;i++){let s=e[i];if(s>o){for(n=s-1;n>=0&&null==l[n];)l[n--]=null;for(n=s+1;t>n&&null==l[n];)l[o=n++]=null}}}const Ol="undefined"==typeof queueMicrotask?l=>Promise.resolve().then(l):queueMicrotask,Nl=["January","February","March","April","May","June","July","August","September","October","November","December"],jl=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ul(l){return l.slice(0,3)}const Bl=jl.map(Ul),Vl=Nl.map(Ul),Jl={MMMM:Nl,MMM:Vl,WWWW:jl,WWW:Bl};function ql(l){return(10>l?"0":"")+l}const Kl={YYYY:l=>l.getFullYear(),YY:l=>(l.getFullYear()+"").slice(2),MMMM:(l,e)=>e.MMMM[l.getMonth()],MMM:(l,e)=>e.MMM[l.getMonth()],MM:l=>ql(l.getMonth()+1),M:l=>l.getMonth()+1,DD:l=>ql(l.getDate()),D:l=>l.getDate(),WWWW:(l,e)=>e.WWWW[l.getDay()],WWW:(l,e)=>e.WWW[l.getDay()],HH:l=>ql(l.getHours()),H:l=>l.getHours(),h:l=>{let e=l.getHours();return 0==e?12:e>12?e-12:e},AA:l=>12>l.getHours()?"AM":"PM",aa:l=>12>l.getHours()?"am":"pm",a:l=>12>l.getHours()?"a":"p",mm:l=>ql(l.getMinutes()),m:l=>l.getMinutes(),ss:l=>ql(l.getSeconds()),s:l=>l.getSeconds(),fff:l=>function(l){return(10>l?"00":100>l?"0":"")+l}(l.getMilliseconds())};function Xl(l,e){e=e||Jl;let t,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;t=i.exec(l);)n.push("{"==t[0][0]?Kl[t[1]]:t[0]);return l=>{let t="";for(let i=0;n.length>i;i++)t+="string"==typeof n[i]?n[i]:n[i](l,e);return t}}const Zl=(new Intl.DateTimeFormat).resolvedOptions().timeZone,$l=l=>l%1==0,Ql=[1,2,2.5,5],le=zl(10,-16,0,Ql),ee=zl(10,0,16,Ql),te=ee.filter($l),ne=le.concat(ee),ie="{YYYY}",oe="\n"+ie,se="{M}/{D}",re="\n"+se,ue=re+"/{YY}",ae="{aa}",fe="{h}:{mm}"+ae,ce="\n"+fe,he=":{ss}",de=null;function pe(l){let e=1e3*l,t=60*e,n=60*t,i=24*n,o=30*i,s=365*i;return[(1==l?zl(10,0,3,Ql).filter($l):zl(10,-3,0,Ql)).concat([e,5*e,10*e,15*e,30*e,t,5*t,10*t,15*t,30*t,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,s,2*s,5*s,10*s,25*s,50*s,100*s]),[[s,ie,de,de,de,de,de,de,1],[28*i,"{MMM}",oe,de,de,de,de,de,1],[i,se,oe,de,de,de,de,de,1],[n,"{h}"+ae,ue,de,re,de,de,de,1],[t,fe,ue,de,re,de,de,de,1],[e,he,ue+" "+fe,de,re+" "+fe,de,ce,de,1],[l,he+".{fff}",ue+" "+fe,de,re+" "+fe,de,ce,de,1]],function(e){return(r,u,a,f,c,h)=>{let d=[],p=c>=s,m=c>=o&&s>c,g=e(a),x=Sl(g*l,3),w=ye(g.getFullYear(),p?0:g.getMonth(),m||p?1:g.getDate()),_=Sl(w*l,3);if(m||p){let t=m?c/o:0,n=p?c/s:0,i=x==_?x:Sl(ye(w.getFullYear()+n,w.getMonth()+t,1)*l,3),r=new Date(nl(i/l)),u=r.getFullYear(),a=r.getMonth();for(let o=0;f>=i;o++){let s=ye(u+n*o,a+t*o,1),r=s-e(Sl(s*l,3));i=Sl((+s+r)*l,3),i>f||d.push(i)}}else{let o=i>c?c:i,s=_+(tl(a)-tl(x))+yl(x-_,o);d.push(s);let p=e(s),m=p.getHours()+p.getMinutes()/t+p.getSeconds()/n,g=c/n,w=h/r.axes[u]._space;for(;s=Sl(s+c,1==l?0:3),f>=s;)if(g>1){let l=tl(Sl(m+g,6))%24,t=e(s).getHours()-l;t>1&&(t=-1),s-=t*n,m=(m+g)%24,.7>Sl((s-d[d.length-1])/c,3)*w||d.push(s)}else d.push(s)}return d}}]}const[me,ge,xe]=pe(1),[we,_e,be]=pe(.001);function ve(l,e){return l.map((l=>l.map(((t,n)=>0==n||8==n||null==t?t:e(1==n||0==l[8]?t:l[1]+t)))))}function ke(l,e){return(t,n,i,o,s)=>{let r,u,a,f,c,h,d=e.find((l=>s>=l[0]))||e[e.length-1];return n.map((e=>{let t=l(e),n=t.getFullYear(),i=t.getMonth(),o=t.getDate(),s=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),g=n!=r&&d[2]||i!=u&&d[3]||o!=a&&d[4]||s!=f&&d[5]||p!=c&&d[6]||m!=h&&d[7]||d[1];return r=n,u=i,a=o,f=s,c=p,h=m,g(t)}))}}function ye(l,e,t){return new Date(l,e,t)}function Me(l,e){return e(l)}function Se(l,e){return(t,n,i,o)=>null==o?w:e(l(n))}zl(2,-53,53,[1]);const Ee={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(l,e){let t=l.series[e];return t.width?t.stroke(l,e):t.points.width?t.points.stroke(l,e):null},fill:function(l,e){return l.series[e].fill(l,e)},dash:"solid"},idx:null,idxs:null,values:[]},Te=[0,0];function ze(l,e,t,n=!0){return l=>{0==l.button&&(!n||l.target==e)&&t(l)}}function De(l,e,t,n=!0){return l=>{(!n||l.target==e)&&t(l)}}const Pe={show:!0,x:!0,y:!0,lock:!1,move:function(l,e,t){return Te[0]=e,Te[1]=t,Te},points:{show:function(l,e){let i=l.cursor.points,o=D(),s=i.size(l,e);T(o,t,s),T(o,n,s);let r=s/-2;T(o,"marginLeft",r),T(o,"marginTop",r);let u=i.width(l,e,s);return u&&T(o,"borderWidth",u),o},size:function(l,e){return l.series[e].points.size},width:0,stroke:function(l,e){let t=l.series[e].points;return t._stroke||t._fill},fill:function(l,e){let t=l.series[e].points;return t._fill||t._stroke}},bind:{mousedown:ze,mouseup:ze,click:ze,dblclick:ze,mousemove:De,mouseleave:De,mouseenter:De},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(l,e)=>{e.stopPropagation(),e.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(l,e,t,n,i)=>n-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},Ae={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},We=Il({},Ae,{filter:xl}),Ye=Il({},We,{size:10}),Ce=Il({},Ae,{show:!1}),Fe='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',He="bold "+Fe,Re={show:!0,scale:"x",stroke:u,space:50,gap:5,size:50,labelGap:0,labelSize:30,labelFont:He,side:2,grid:We,ticks:Ye,border:Ce,font:Fe,lineGap:1.5,rotate:0},Ge={show:!0,scale:"x",auto:!1,sorted:1,min:hl,max:-hl,idxs:[]};function Ie(l,e){return e.map((l=>null==l?"":$(l)))}function Le(l,e,t,n,i,o,s){let r=[],u=El.get(i)||0;for(let l=t=s?t:Sl(yl(t,i),u);n>=l;l=Sl(l+i,u))r.push(Object.is(l,-0)?0:l);return r}function Oe(l,e,t,n,i){const o=[],s=l.scales[l.axes[e].scale].log,r=tl((10==s?al:fl)(t));i=rl(s,r),10==s&&0>r&&(i=Sl(i,-r));let u=t;do{o.push(u),u+=i,10==s&&(u=Sl(u,El.get(i))),i*s>u||(i=u)}while(n>=u);return o}function Ne(l,e,t,n,i){let o=l.scales[l.axes[e].scale].asinh,s=n>o?Oe(l,e,sl(o,t),n,i):[o],r=0>n||t>0?[]:[0];return(-o>t?Oe(l,e,sl(o,-n),-t,i):[o]).reverse().map((l=>-l)).concat(r,s)}const je=/./,Ue=/[12357]/,Be=/[125]/,Ve=/1/,Je=(l,e,t,n)=>l.map(((l,i)=>4==e&&0==l||i%n==0&&t.test(l.toExponential()[0>l?1:0])?l:null));function qe(l,e,t){let n=l.axes[t],i=n.scale,o=l.scales[i],s=l.valToPos,r=n._space,u=s(10,i),a=s(9,i)-ul)return Je(e.slice().reverse(),o.distr,a,il(r/l)).reverse()}return Je(e,o.distr,a,1)}function Ke(l,e,t){let n=l.axes[t],i=n.scale,o=n._space,s=l.valToPos,r=el(s(1,i)-s(2,i));return o>r?Je(e.slice().reverse(),3,je,il(o/r)).reverse():e}function Xe(l,e,t,n){return null==n?w:null==e?"":$(e)}const Ze={show:!0,scale:"y",stroke:u,space:30,gap:5,size:50,labelGap:0,labelSize:30,labelFont:He,side:3,grid:We,ticks:Ye,border:Ce,font:Fe,lineGap:1.5,rotate:0},$e={scale:null,auto:!0,sorted:0,min:hl,max:-hl},Qe=(l,e,t,n,i)=>i,lt={show:!0,auto:!0,sorted:0,gaps:Qe,alpha:1,facets:[Il({},$e,{scale:"x"}),Il({},$e,{scale:"y"})]},et={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:Qe,alpha:1,points:{show:function(l,e){let{scale:t,idxs:n}=l.series[0],i=l._data[0],o=l.valToPos(i[n[0]],t,!0),s=l.valToPos(i[n[1]],t,!0);return el(s-o)/(l.series[e].points.space*y)>=n[1]-n[0]},filter:null},values:null,min:hl,max:-hl,idxs:[],path:null,clip:null};function tt(l,e,t){return t/10}const nt={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},it=Il({},nt,{time:!1,ori:1}),ot={};function st(l){let e=ot[l];return e||(e={key:l,plots:[],sub(l){e.plots.push(l)},unsub(l){e.plots=e.plots.filter((e=>e!=l))},pub(l,t,n,i,o,s,r){for(let u=0;e.plots.length>u;u++)e.plots[u]!=t&&e.plots[u].pub(l,t,n,i,o,s,r)}},null!=l&&(ot[l]=e)),e}function rt(l,e,t){const n=l.mode,i=l.series[e],o=2==n?l._data[e]:l._data,s=l.scales,r=l.bbox;let u=o[0],a=2==n?o[1]:o[e],f=2==n?s[i.facets[0].scale]:s[l.series[0].scale],c=2==n?s[i.facets[1].scale]:s[i.scale],h=r.left,d=r.top,p=r.width,m=r.height,g=l.valToPosH,x=l.valToPosV;return 0==f.ori?t(i,u,a,f,c,g,x,h,d,p,m,mt,xt,_t,vt,yt):t(i,u,a,f,c,x,g,d,h,m,p,gt,wt,bt,kt,Mt)}function ut(l,e){let t=0,n=0,i=K(l.bands,Pl);for(let l=0;i.length>l;l++){let o=i[l];o.series[0]==e?t=o.dir:o.series[1]==e&&(n|=1==o.dir?1:2)}return[t,1==n?-1:2==n?1:3==n?2:0]}function at(l,e,t,n,i){let o=l.series[e],s=l.scales[2==l.mode?o.facets[1].scale:o.scale];return-1==i?s.min:1==i?s.max:3==s.distr?1==s.dir?s.min:s.max:0}function ft(l,e,t,n,i,o){return rt(l,e,((l,e,s,r,u,a,f,c,h,d,p)=>{let m=l.pxRound;const g=0==r.ori?xt:wt;let x,w;1==r.dir*(0==r.ori?1:-1)?(x=t,w=n):(x=n,w=t);let _=m(a(e[x],r,d,c)),b=m(f(s[x],u,p,h)),v=m(a(e[w],r,d,c)),k=m(f(1==o?u.max:u.min,u,p,h)),y=new Path2D(i);return g(y,v,k),g(y,_,k),g(y,_,b),y}))}function ct(l,e,t,n,i,o){let s=null;if(l.length>0){s=new Path2D;const r=0==e?_t:bt;let u=t;for(let e=0;l.length>e;e++){let t=l[e];if(t[1]>t[0]){let l=t[0]-u;l>0&&r(s,u,n,l,n+o),u=t[1]}}let a=t+i-u,f=10;a>0&&r(s,u,n-f/2,a,n+o+f)}return s}function ht(l,e,t,n,i,o,s){let r=[],u=l.length;for(let a=1==i?t:n;a>=t&&n>=a;a+=i)if(null===e[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===e[a];)c=a;else for(;--a>=t&&null===e[a];)c=a;let h=o(l[f]),d=c==f?h:o(l[c]),p=f-i;h=s>0||0>p||p>=u?h:o(l[p]);let m=c+i;d=0>s||0>m||m>=u?d:o(l[m]),h>d||r.push([h,d])}return r}function dt(l){return 0==l?gl:1==l?nl:e=>kl(e,l)}function pt(l){let e=0==l?mt:gt,t=0==l?(l,e,t,n,i,o)=>{l.arcTo(e,t,n,i,o)}:(l,e,t,n,i,o)=>{l.arcTo(t,e,i,n,o)},n=0==l?(l,e,t,n,i)=>{l.rect(e,t,n,i)}:(l,e,t,n,i)=>{l.rect(t,e,i,n)};return(l,i,o,s,r,u=0,a=0)=>{0==u&&0==a?n(l,i,o,s,r):(u=ol(u,s/2,r/2),a=ol(a,s/2,r/2),e(l,i+u,o),t(l,i+s,o,i+s,o+r,u),t(l,i+s,o+r,i,o+r,a),t(l,i,o+r,i,o,a),t(l,i,o,i+s,o,u),l.closePath())}}const mt=(l,e,t)=>{l.moveTo(e,t)},gt=(l,e,t)=>{l.moveTo(t,e)},xt=(l,e,t)=>{l.lineTo(e,t)},wt=(l,e,t)=>{l.lineTo(t,e)},_t=pt(0),bt=pt(1),vt=(l,e,t,n,i,o)=>{l.arc(e,t,n,i,o)},kt=(l,e,t,n,i,o)=>{l.arc(t,e,n,i,o)},yt=(l,e,t,n,i,o,s)=>{l.bezierCurveTo(e,t,n,i,o,s)},Mt=(l,e,t,n,i,o,s)=>{l.bezierCurveTo(t,e,i,n,s,o)};function St(){return(l,e,t,n,i)=>rt(l,e,((e,o,s,r,u,a,f,c,h,d,p)=>{let m,g,{pxRound:x,points:w}=e;0==r.ori?(m=mt,g=vt):(m=gt,g=kt);const _=Sl(w.width*y,3);let b=(w.size-w.width)/2*y,v=Sl(2*b,3),k=new Path2D,M=new Path2D,{left:S,top:E,width:T,height:z}=l.bbox;_t(M,S-v,E-v,T+2*v,z+2*v);const D=l=>{if(null!=s[l]){let e=x(a(o[l],r,d,c)),t=x(f(s[l],u,p,h));m(k,e+b,t),g(k,e,t,b,0,2*ll)}};if(i)i.forEach(D);else for(let l=t;n>=l;l++)D(l);return{stroke:_>0?k:null,fill:k,clip:M,flags:3}}))}function Et(l){return(e,t,n,i,o,s)=>{n!=i&&(o!=n&&s!=n&&l(e,t,n),o!=i&&s!=i&&l(e,t,i),l(e,t,s))}}const Tt=Et(xt),zt=Et(wt);function Dt(l){const e=K(l?.alignGaps,0);return(l,t,n,i)=>rt(l,t,((o,s,r,u,a,f,c,h,d,p,m)=>{let g,x,w=o.pxRound,_=l=>w(f(l,u,p,h)),b=l=>w(c(l,a,m,d));0==u.ori?(g=xt,x=Tt):(g=wt,x=zt);const v=u.dir*(0==u.ori?1:-1),k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},y=k.stroke;let M,S,E,T=hl,z=-hl,D=_(s[1==v?n:i]),P=O(r,n,i,1*v),A=O(r,n,i,-1*v),W=_(s[P]),Y=_(s[A]),C=!1;for(let l=1==v?n:i;l>=n&&i>=l;l+=v){let e=_(s[l]),t=r[l];e==D?null!=t?(S=b(t),T==hl&&(g(y,e,S),M=S),T=ol(S,T),z=sl(S,z)):null===t&&(C=!0):(T!=hl&&(x(y,D,T,z,M,S),E=D),null!=t?(S=b(t),g(y,e,S),T=z=M=S):(T=hl,z=-hl,null===t&&(C=!0)),D=e)}T!=hl&&T!=z&&E!=D&&x(y,D,T,z,M,S);let[F,H]=ut(l,t);if(null!=o.fill||0!=F){let e=k.fill=new Path2D(y),n=b(o.fillTo(l,t,o.min,o.max,F));g(e,Y,n),g(e,W,n)}if(!o.spanGaps){let a=[];C&&a.push(...ht(s,r,n,i,v,_,e)),k.gaps=a=o.gaps(l,t,n,i,a),k.clip=ct(a,u.ori,h,d,p,m)}return 0!=H&&(k.band=2==H?[ft(l,t,n,i,y,-1),ft(l,t,n,i,y,1)]:ft(l,t,n,i,y,H)),k}))}function Pt(l,e,t,n,i,o,s=hl){if(l.length>1){let r=null;for(let u=0,a=1/0;l.length>u;u++)if(void 0!==e[u]){if(null!=r){let e=el(l[u]-l[r]);a>e&&(a=e,s=el(t(l[u],n,i,o)-t(l[r],n,i,o)))}r=u}}return s}function At(l,e,t,n,i){const o=l.length;if(2>o)return null;const s=new Path2D;if(t(s,l[0],e[0]),2==o)n(s,l[1],e[1]);else{let t=Array(o),n=Array(o-1),r=Array(o-1),u=Array(o-1);for(let t=0;o-1>t;t++)r[t]=e[t+1]-e[t],u[t]=l[t+1]-l[t],n[t]=r[t]/u[t];t[0]=n[0];for(let l=1;o-1>l;l++)0===n[l]||0===n[l-1]||n[l-1]>0!=n[l]>0?t[l]=0:(t[l]=3*(u[l-1]+u[l])/((2*u[l]+u[l-1])/n[l-1]+(u[l]+2*u[l-1])/n[l]),isFinite(t[l])||(t[l]=0));t[o-1]=n[o-2];for(let n=0;o-1>n;n++)i(s,l[n]+u[n]/3,e[n]+t[n]*u[n]/3,l[n+1]-u[n]/3,e[n+1]-t[n+1]*u[n]/3,l[n+1],e[n+1])}return s}const Wt=new Set;function Yt(){for(let l of Wt)l.syncRect(!0)}_&&(G("resize",v,Yt),G("scroll",v,Yt,!0),G(x,v,(()=>{qt.pxRatio=y})));const Ct=Dt(),Ft=St();function Ht(l,e,t,n){return(n?[l[0],l[1]].concat(l.slice(2)):[l[0]].concat(l.slice(1))).map(((l,n)=>Rt(l,n,e,t)))}function Rt(l,e,t,n){return Il({},0==e?t:n,l)}function Gt(l,e,t){return null==e?Al:[e,t]}const It=Gt;function Lt(l,e,t){return null==e?Al:q(e,t,U,!0)}function Ot(l,e,t,n){return null==e?Al:N(e,t,l.scales[n].log,!1)}const Nt=Ot;function jt(l,e,t,n){return null==e?Al:j(e,t,l.scales[n].log,!1)}const Ut=jt;function Bt(l,e,t,n,i){let o=sl(dl(l),dl(e)),s=e-l,r=L(i/n*s,t);do{let l=t[r],e=n*l/s;if(e>=i&&17>=o+(5>l?El.get(l):0))return[l,e]}while(++r(e=nl((t=+n)*y))+"px")),e,t]}function Jt(l){l.show&&[l.font,l.labelFont].forEach((l=>{let e=Sl(l[2]*y,1);l[0]=l[0].replace(/[0-9.]+px/,e+"px"),l[1]=e}))}function qt(u,g,_){const k={mode:K(u.mode,1)},M=k.mode;function P(l,e){return((3==e.distr?al(l>0?l:e.clamp(k,l,e.min,e.max,e.key)):4==e.distr?cl(l,e.asinh):l)-e._min)/(e._max-e._min)}function W(l,e,t,n){let i=P(l,e);return n+t*(-1==e.dir?1-i:i)}function C(l,e,t,n){let i=P(l,e);return n+t*(-1==e.dir?i:1-i)}function H(l,e,t,n){return 0==e.ori?W(l,e,t,n):C(l,e,t,n)}k.valToPosH=W,k.valToPosV=C;let R=!1;k.status=0;const O=k.root=D("uplot");null!=u.id&&(O.id=u.id),S(O,u.class),u.title&&(D("u-title",O).textContent=u.title);const V=z("canvas"),J=k.ctx=V.getContext("2d"),X=D("u-wrap",O);G("click",X,(l=>{l.target===$&&(Fn!=An||Hn!=Wn)&&Bn.click(k,l)}),!0);const Z=k.under=D("u-under",X);X.appendChild(V);const $=k.over=D("u-over",X),tl=+K((u=Gl(u)).pxAlign,1),ul=dt(tl);(u.plugins||[]).forEach((l=>{l.opts&&(u=l.opts(k,u)||u)}));const fl=u.ms||.001,dl=k.series=1==M?Ht(u.series||[],Ge,et,!1):function(l,e){return l.map(((l,t)=>0==t?null:Il({},e,l)))}(u.series||[null],lt),gl=k.axes=Ht(u.axes||[],Re,Ze,!0),vl=k.scales={},Ml=k.bands=u.bands||[];Ml.forEach((l=>{l.fill=ml(l.fill||null),l.dir=K(l.dir,-1)}));const zl=2==M?dl[1].facets[0].scale:dl[0].scale,Yl={axes:function(){for(let l=0;gl.length>l;l++){let e=gl[l];if(!e.show||!e._show)continue;let t,n,u=e.side,a=u%2,f=e.stroke(k,l),c=0==u||3==u?-1:1;if(e.label){let l=nl((e._lpos+e.labelGap*c)*y);hn(e.labelFont[0],f,"center",2==u?i:o),J.save(),1==a?(t=n=0,J.translate(l,nl($e+ot/2)),J.rotate((3==u?-ll:ll)/2)):(t=nl(Je+Qe/2),n=l),J.fillText(e.label,t,n),J.restore()}let[h,d]=e._found;if(0==d)continue;let p=vl[e.scale],m=0==a?Qe:ot,g=0==a?Je:$e,x=nl(e.gap*y),w=e._splits,_=2==p.distr?w.map((l=>rn[l])):w,b=2==p.distr?rn[w[1]]-rn[w[0]]:h,v=e.ticks,M=e.border,S=v.show?nl(v.size*y):0,E=e._rotate*-ll/180,T=ul(e._pos*y),z=T+(S+x)*c;n=0==a?z:0,t=1==a?z:0,hn(e.font[0],f,1==e.align?s:2==e.align?r:E>0?s:0>E?r:0==a?"center":3==u?r:s,E||1==a?"middle":2==u?i:o);let D=e.font[1]*e.lineGap,P=w.map((l=>ul(H(l,p,m,g)))),A=e._values;for(let l=0;A.length>l;l++){let e=A[l];if(null!=e){0==a?t=P[l]:n=P[l],e=""+e;let i=-1==e.indexOf("\n")?[e]:e.split(/\n/gm);for(let l=0;i.length>l;l++){let e=i[l];E?(J.save(),J.translate(t,n+l*D),J.rotate(E),J.fillText(e,0,0),J.restore()):J.fillText(e,t,n+l*D)}}}v.show&&vn(P,v.filter(k,_,l,d,b),a,u,T,S,Sl(v.width*y,3),v.stroke(k,l),v.dash,v.cap);let W=e.grid;W.show&&vn(P,W.filter(k,_,l,d,b),a,0==a?2:1,0==a?$e:Je,0==a?ot:Qe,Sl(W.width*y,3),W.stroke(k,l),W.dash,W.cap),M.show&&vn([T],[1],0==a?1:0,0==a?1:2,1==a?$e:Je,1==a?ot:Qe,Sl(M.width*y,3),M.stroke(k,l),M.dash,M.cap)}Ti("drawAxes")},series:function(){At>0&&(dl.forEach(((l,e)=>{if(e>0&&l.show&&(mn(e,!1),mn(e,!0),null==l._paths)){sn!=l.alpha&&(J.globalAlpha=sn=l.alpha);let t=2==M?[0,g[e][0].length-1]:function(l){let e=pl(Yt-1,0,At-1),t=pl(qt+1,0,At-1);for(;null==l[e]&&e>0;)e--;for(;null==l[t]&&At-1>t;)t++;return[e,t]}(g[e]);l._paths=l.paths(k,e,t[0],t[1]),1!=sn&&(J.globalAlpha=sn=1)}})),dl.forEach(((l,e)=>{if(e>0&&l.show){sn!=l.alpha&&(J.globalAlpha=sn=l.alpha),null!=l._paths&&gn(e,!1);{let t=null!=l._paths?l._paths.gaps:null,n=l.points.show(k,e,Yt,qt,t),i=l.points.filter(k,e,n,t);(n||i)&&(l.points._paths=l.points.paths(k,e,Yt,qt,i),gn(e,!0))}1!=sn&&(J.globalAlpha=sn=1),Ti("drawSeries",e)}})))}},Rl=(u.drawOrder||["axes","series"]).map((l=>Yl[l]));function Ll(l){let e=vl[l];if(null==e){let t=(u.scales||Dl)[l]||Dl;if(null!=t.from)Ll(t.from),vl[l]=Il({},vl[t.from],t,{key:l});else{e=vl[l]=Il({},l==zl?nt:it,t),e.key=l;let n=e.time,i=e.range,o=Wl(i);if((l!=zl||2==M&&!n)&&(!o||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?B:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?B:{mode:1,hard:i[1],soft:i[1]}},o=!1),!o&&Fl(i))){let l=i;i=(e,t,n)=>null==t?Al:q(t,n,l)}e.range=ml(i||(n?It:l==zl?3==e.distr?Nt:4==e.distr?Ut:Gt:3==e.distr?Ot:4==e.distr?jt:Lt)),e.auto=ml(!o&&e.auto),e.clamp=ml(e.clamp||tt),e._min=e._max=null}}}Ll("x"),Ll("y"),1==M&&dl.forEach((l=>{Ll(l.scale)})),gl.forEach((l=>{Ll(l.scale)}));for(let l in u.scales)Ll(l);const Nl=vl[zl],jl=Nl.distr;let Ul,Bl;0==Nl.ori?(S(O,"u-hz"),Ul=W,Bl=C):(S(O,"u-vt"),Ul=C,Bl=W);const Vl={};for(let l in vl){let e=vl[l];null==e.min&&null==e.max||(Vl[l]={min:e.min,max:e.max},e.min=e.max=null)}const Jl=u.tzDate||(l=>new Date(nl(l/fl))),ql=u.fmtDate||Xl,Kl=1==fl?xe(Jl):be(Jl),Zl=ke(Jl,ve(1==fl?ge:_e,ql)),$l=Se(Jl,Me("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",ql)),Ql=[],le=k.legend=Il({},Ee,u.legend),ee=le.show,ie=le.markers;let oe,se,re;le.idxs=Ql,ie.width=ml(ie.width),ie.dash=ml(ie.dash),ie.stroke=ml(ie.stroke),ie.fill=ml(ie.fill);let ue,ae=[],fe=[],ce=!1,he={};if(le.live){const l=dl[1]?dl[1].values:null;ce=null!=l,ue=ce?l(k,1,0):{_:0};for(let l in ue)he[l]=w}if(ee)if(oe=z("table","u-legend",O),re=z("tbody",null,oe),le.mount(k,oe),ce){se=z("thead",null,oe,re);let l=z("tr",null,se);for(var de in z("th",null,l),ue)z("th",e,l).textContent=de}else S(oe,"u-inline"),le.live&&S(oe,"u-live");const pe={show:!0},ye={show:!1},Te=new Map;function ze(l,e,t,n=!0){const i=Te.get(e)||{},o=wt.bind[l](k,e,t,n);o&&(G(l,e,i[l]=o),Te.set(e,i))}function De(l,e){const t=Te.get(e)||{};for(let n in t)null!=l&&n!=l||(I(n,e,t[n]),delete t[n]);null==l&&Te.delete(e)}let Ae=0,We=0,Ye=0,Ce=0,Fe=0,He=0,je=Fe,Ue=He,Be=Ye,Ve=Ce,Je=0,$e=0,Qe=0,ot=0;k.bbox={};let rt=!1,ut=!1,ft=!1,ct=!1,ht=!1,pt=!1;function mt(l,e,t){(t||l!=k.width||e!=k.height)&>(l,e),Mn(!1),ft=!0,ut=!0,On()}function gt(l,e){k.width=Ae=Ye=l,k.height=We=Ce=e,Fe=He=0,function(){let l=!1,e=!1,t=!1,n=!1;gl.forEach((i=>{if(i.show&&i._show){let{side:o,_size:s}=i,r=s+(null!=i.label?i.labelSize:0);r>0&&(o%2?(Ye-=r,3==o?(Fe+=r,n=!0):t=!0):(Ce-=r,0==o?(He+=r,l=!0):e=!0))}})),Tt[0]=l,Tt[1]=t,Tt[2]=e,Tt[3]=n,Ye-=Pt[1]+Pt[3],Fe+=Pt[3],Ce-=Pt[2]+Pt[0],He+=Pt[0]}(),function(){let l=Fe+Ye,e=He+Ce,t=Fe,n=He;function i(i,o){switch(i){case 1:return l+=o,l-o;case 2:return e+=o,e-o;case 3:return t-=o,t+o;case 0:return n-=o,n+o}}gl.forEach((l=>{if(l.show&&l._show){let e=l.side;l._pos=i(e,l._size),null!=l.label&&(l._lpos=i(e,l.labelSize))}}))}();let t=k.bbox;Je=t.left=kl(Fe*y,.5),$e=t.top=kl(He*y,.5),Qe=t.width=kl(Ye*y,.5),ot=t.height=kl(Ce*y,.5)}const xt=3;k.setSize=function({width:l,height:e}){mt(l,e)};const wt=k.cursor=Il({},Pe,{drag:{y:2==M}},u.cursor);if(null==wt.dataIdx){let l=wt.hover,e=l.skip=new Set(l.skip??[]);e.add(void 0);let t=l.prox=ml(l.prox),n=l.bias??=0;wt.dataIdx=(l,i,o,s)=>{if(0==i)return o;let r=o,u=t(l,i,o,s)??hl,a=u>=0&&hl>u,f=0==Nl.ori?Ye:Ce,c=wt.left,h=g[0],d=g[i];if(e.has(d[o])){r=null;let l,t=null,i=null;if(0==n||-1==n)for(l=o;null==t&&l-- >0;)e.has(d[l])||(t=l);if(0==n||1==n)for(l=o;null==i&&l++e?e>u||(r=i):l>u||(r=t)}else r=null==i?t:null==t||o-t>i-o?i:t}else a&&el(c-Ul(h[o],Nl,f,0))>u&&(r=null);return r}}const _t=l=>{wt.event=l};wt.idxs=Ql,wt._lock=!1;let bt=wt.points;bt.show=ml(bt.show),bt.size=ml(bt.size),bt.stroke=ml(bt.stroke),bt.width=ml(bt.width),bt.fill=ml(bt.fill);const vt=k.focus=Il({},u.focus||{alpha:.3},wt.focus),kt=vt.prox>=0;let yt=[null],Mt=[null],St=[null];function Et(t,n){if(1==M||n>0){let l=1==M&&vl[t.scale].time,e=t.value;t.value=l?Cl(e)?Se(Jl,Me(e,ql)):e||$l:e||Xe,t.label=t.label||(l?"Time":"Value")}if(n>0){t.width=null==t.width?1:t.width,t.paths=t.paths||Ct||wl,t.fillTo=ml(t.fillTo||at),t.pxAlign=+K(t.pxAlign,tl),t.pxRound=dt(t.pxAlign),t.stroke=ml(t.stroke||null),t.fill=ml(t.fill||null),t._stroke=t._fill=t._paths=t._focus=null;let l=function(l){return Sl(1*(3+2*(l||1)),3)}(sl(1,t.width)),e=t.points=Il({},{size:l,width:sl(1,.2*l),stroke:t.stroke,space:2*l,paths:Ft,_stroke:null,_fill:null},t.points);e.show=ml(e.show),e.filter=ml(e.filter),e.fill=ml(e.fill),e.stroke=ml(e.stroke),e.paths=ml(e.paths),e.pxAlign=t.pxAlign}if(ee){let i=function(t,n){if(0==n&&(ce||!le.live||2==M))return Al;let i=[],o=z("tr","u-series",re,re.childNodes[n]);S(o,t.class),t.show||S(o,l);let s=z("th",null,o);if(ie.show){let l=D("u-marker",s);if(n>0){let e=ie.width(k,n);e&&(l.style.border=e+"px "+ie.dash(k,n)+" "+ie.stroke(k,n)),l.style.background=ie.fill(k,n)}}let r=D(e,s);for(var u in r.textContent=t.label,n>0&&(ie.show||(r.style.color=t.width>0?ie.stroke(k,n):ie.fill(k,n)),ze("click",s,(l=>{if(wt._lock)return;_t(l);let e=dl.indexOf(t);if((l.ctrlKey||l.metaKey)!=le.isolate){let l=dl.some(((l,t)=>t>0&&t!=e&&l.show));dl.forEach(((t,n)=>{n>0&&$n(n,l?n==e?pe:ye:pe,!0,Di.setSeries)}))}else $n(e,{show:!t.show},!0,Di.setSeries)}),!1),kt&&ze(d,s,(l=>{wt._lock||(_t(l),$n(dl.indexOf(t),ti,!0,Di.setSeries))}),!1)),ue){let l=z("td","u-value",o);l.textContent="--",i.push(l)}return[o,i]}(t,n);ae.splice(n,0,i[0]),fe.splice(n,0,i[1]),le.values.push(null)}if(wt.show){Ql.splice(n,0,null);let l=function(l,e){if(e>0){let t=wt.points.show(k,e);if(t)return S(t,"u-cursor-pt"),S(t,l.class),A(t,-10,-10,Ye,Ce),$.insertBefore(t,yt[e]),t}}(t,n);null!=l&&(yt.splice(n,0,l),Mt.splice(n,0,0),St.splice(n,0,0))}Ti("addSeries",n)}k.addSeries=function(l,e){e=null==e?dl.length:e,l=1==M?Rt(l,e,Ge,et):Rt(l,e,null,lt),dl.splice(e,0,l),Et(dl[e],e)},k.delSeries=function(l){if(dl.splice(l,1),ee){le.values.splice(l,1),fe.splice(l,1);let e=ae.splice(l,1)[0];De(null,e.firstChild),e.remove()}wt.show&&(Ql.splice(l,1),yt.length>1&&(yt.splice(l,1)[0].remove(),Mt.splice(l,1),St.splice(l,1))),Ti("delSeries",l)};const Tt=[!1,!1,!1,!1];function zt(l,e,t){let[n,i,o,s]=t,r=e%2,u=0;return 0==r&&(s||i)&&(u=0==e&&!n||2==e&&!o?nl(Re.size/3):0),1==r&&(n||o)&&(u=1==e&&!i||3==e&&!s?nl(Ze.size/2):0),u}const Dt=k.padding=(u.padding||[zt,zt,zt,zt]).map((l=>ml(K(l,zt)))),Pt=k._padding=Dt.map(((l,e)=>l(k,e,Tt,0)));let At,Yt=null,qt=null;const Kt=1==M?dl[0].idxs:null;let Xt,Zt,$t,Qt,ln,en,tn,nn,on,sn,rn=null,un=!1;function an(l,e){if(k.data=k._data=g=null==l?[]:l,2==M){At=0;for(let l=1;dl.length>l;l++)At+=g[l][0].length}else{0==g.length&&(k.data=k._data=g=[[]]),rn=g[0],At=rn.length;let l=g;if(2==jl){l=g.slice();let e=l[0]=Array(At);for(let l=0;At>l;l++)e[l]=l}k._data=g=l}if(Mn(!0),Ti("setData"),2==jl&&(ft=!0),!1!==e){let l=Nl;l.auto(k,un)?fn():Zn(zl,l.min,l.max),ct=ct||wt.left>=0,pt=!0,On()}}function fn(){let l,e;un=!0,1==M&&(At>0?(Yt=Kt[0]=0,qt=Kt[1]=At-1,l=g[0][Yt],e=g[0][qt],2==jl?(l=Yt,e=qt):l==e&&(3==jl?[l,e]=N(l,l,Nl.log,!1):4==jl?[l,e]=j(l,l,Nl.log,!1):Nl.time?e=l+nl(86400/fl):[l,e]=q(l,e,U,!0))):(Yt=Kt[0]=l=null,qt=Kt[1]=e=null)),Zn(zl,l,e)}function cn(l,e,t,n,i,o){l??=a,t??=Pl,n??="butt",i??=a,o??="round",l!=Xt&&(J.strokeStyle=Xt=l),i!=Zt&&(J.fillStyle=Zt=i),e!=$t&&(J.lineWidth=$t=e),o!=ln&&(J.lineJoin=ln=o),n!=en&&(J.lineCap=en=n),t!=Qt&&J.setLineDash(Qt=t)}function hn(l,e,t,n){e!=Zt&&(J.fillStyle=Zt=e),l!=tn&&(J.font=tn=l),t!=nn&&(J.textAlign=nn=t),n!=on&&(J.textBaseline=on=n)}function dn(l,e,t,n,i=0){if(n.length>0&&l.auto(k,un)&&(null==e||null==e.min)){let e=K(Yt,0),o=K(qt,n.length-1),s=null==t.min?3==l.distr?function(l,e,t){let n=hl,i=-hl;for(let o=e;t>=o;o++){let e=l[o];null!=e&&e>0&&(n>e&&(n=e),e>i&&(i=e))}return[n,i]}(n,e,o):function(l,e,t,n){let i=hl,o=-hl;if(1==n)i=l[e],o=l[t];else if(-1==n)i=l[t],o=l[e];else for(let n=e;t>=n;n++){let e=l[n];null!=e&&(i>e&&(i=e),e>o&&(o=e))}return[i,o]}(n,e,o,i):[t.min,t.max];l.min=ol(l.min,t.min=s[0]),l.max=sl(l.max,t.max=s[1])}}k.setData=an;const pn={min:null,max:null};function mn(l,e){let t=e?dl[l].points:dl[l];t._stroke=t.stroke(k,l),t._fill=t.fill(k,l)}function gn(l,e){let t=e?dl[l].points:dl[l],{stroke:n,fill:i,clip:o,flags:s,_stroke:r=t._stroke,_fill:u=t._fill,_width:a=t.width}=t._paths;a=Sl(a*y,3);let f=null,c=a%2/2;e&&null==u&&(u=a>0?"#fff":r);let h=1==t.pxAlign&&c>0;if(h&&J.translate(c,c),!e){let l=Je-a/2,e=$e-a/2,t=Qe+a,n=ot+a;f=new Path2D,f.rect(l,e,t,n)}e?wn(r,a,t.dash,t.cap,u,n,i,s,o):function(l,e,t,n,i,o,s,r,u,a,f){let c=!1;0!=u&&Ml.forEach(((h,d)=>{if(h.series[0]==l){let l,p=dl[h.series[1]],m=g[h.series[1]],x=(p._paths||Dl).band;Wl(x)&&(x=1==h.dir?x[0]:x[1]);let w=null;p.show&&x&&function(l,e,t){for(e=K(e,0),t=K(t,l.length-1);t>=e;){if(null!=l[e])return!0;e++}return!1}(m,Yt,qt)?(w=h.fill(k,d)||o,l=p._paths.clip):x=null,wn(e,t,n,i,w,s,r,u,a,f,l,x),c=!0}})),c||wn(e,t,n,i,o,s,r,u,a,f)}(l,r,a,t.dash,t.cap,u,n,i,s,f,o),h&&J.translate(-c,-c)}const xn=3;function wn(l,e,t,n,i,o,s,r,u,a,f,c){cn(l,e,t,n,i),(u||a||c)&&(J.save(),u&&J.clip(u),a&&J.clip(a)),c?(r&xn)==xn?(J.clip(c),f&&J.clip(f),bn(i,s),_n(l,o,e)):2&r?(bn(i,s),J.clip(c),_n(l,o,e)):1&r&&(J.save(),J.clip(c),f&&J.clip(f),bn(i,s),J.restore(),_n(l,o,e)):(bn(i,s),_n(l,o,e)),(u||a||c)&&J.restore()}function _n(l,e,t){t>0&&(e instanceof Map?e.forEach(((l,e)=>{J.strokeStyle=Xt=e,J.stroke(l)})):null!=e&&l&&J.stroke(e))}function bn(l,e){e instanceof Map?e.forEach(((l,e)=>{J.fillStyle=Zt=e,J.fill(l)})):null!=e&&l&&J.fill(e)}function vn(l,e,t,n,i,o,s,r,u,a){let f=s%2/2;1==tl&&J.translate(f,f),cn(r,s,u,a,r),J.beginPath();let c,h,d,p,m=i+(0==n||3==n?-o:o);0==t?(h=i,p=m):(c=i,d=m);for(let n=0;l.length>n;n++)null!=e[n]&&(0==t?c=d=l[n]:h=p=l[n],J.moveTo(c,h),J.lineTo(d,p));J.stroke(),1==tl&&J.translate(-f,-f)}function kn(l){let e=!0;return gl.forEach(((t,n)=>{if(!t.show)return;let i=vl[t.scale];if(null==i.min)return void(t._show&&(e=!1,t._show=!1,Mn(!1)));t._show||(e=!1,t._show=!0,Mn(!1));let o=t.side,s=o%2,{min:r,max:u}=i,[a,f]=function(l,e,t,n){let i,o=gl[l];if(n>0){let s=o._space=o.space(k,l,e,t,n);i=Bt(e,t,o._incrs=o.incrs(k,l,e,t,n,s),n,s)}else i=[0,0];return o._found=i}(n,r,u,0==s?Ye:Ce);if(0==f)return;let c=t._splits=t.splits(k,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map((l=>rn[l])):c,d=2==i.distr?rn[c[1]]-rn[c[0]]:a,p=t._values=t.values(k,t.filter(k,h,n,f,d),n,f,d);t._rotate=2==o?t.rotate(k,p,n,f):0;let m=t._size;t._size=il(t.size(k,p,n,l)),null!=m&&t._size!=m&&(e=!1)})),e}function yn(l){let e=!0;return Dt.forEach(((t,n)=>{let i=t(k,n,Tt,l);i!=Pt[n]&&(e=!1),Pt[n]=i})),e}function Mn(l){dl.forEach(((e,t)=>{t>0&&(e._paths=null,l&&(1==M?(e.min=null,e.max=null):e.facets.forEach((l=>{l.min=null,l.max=null}))))}))}let Sn,En,Tn,zn,Dn,Pn,An,Wn,Yn,Cn,Fn,Hn,Rn=!1,Gn=!1,In=[];function Ln(){Gn=!1;for(let l=0;In.length>l;l++)Ti(...In[l]);In.length=0}function On(){Rn||(Ol(Nn),Rn=!0)}function Nn(){if(rt&&(function(){for(let l in vl){let e=vl[l];null==Vl[l]&&(null==e.min||null!=Vl[zl]&&e.auto(k,un))&&(Vl[l]=pn)}for(let l in vl){let e=vl[l];null==Vl[l]&&null!=e.from&&null!=Vl[e.from]&&(Vl[l]=pn)}null!=Vl[zl]&&Mn(!0);let l={};for(let e in Vl){let t=Vl[e];if(null!=t){let n=l[e]=Gl(vl[e],Hl);if(null!=t.min)Il(n,t);else if(e!=zl||2==M)if(0==At&&null==n.from){let l=n.range(k,null,null,e);n.min=l[0],n.max=l[1]}else n.min=hl,n.max=-hl}}if(At>0){dl.forEach(((e,t)=>{if(1==M){let n=e.scale,i=Vl[n];if(null==i)return;let o=l[n];if(0==t){let l=o.range(k,o.min,o.max,n);o.min=l[0],o.max=l[1],Yt=L(o.min,g[0]),qt=L(o.max,g[0]),qt-Yt>1&&(o.min>g[0][Yt]&&Yt++,g[0][qt]>o.max&&qt--),e.min=rn[Yt],e.max=rn[qt]}else e.show&&e.auto&&dn(o,i,e,g[t],e.sorted);e.idxs[0]=Yt,e.idxs[1]=qt}else if(t>0&&e.show&&e.auto){let[n,i]=e.facets,o=n.scale,s=i.scale,[r,u]=g[t],a=l[o],f=l[s];null!=a&&dn(a,Vl[o],n,r,n.sorted),null!=f&&dn(f,Vl[s],i,u,i.sorted),e.min=i.min,e.max=i.max}}));for(let e in l){let t=l[e],n=Vl[e];if(null==t.from&&(null==n||null==n.min)){let l=t.range(k,t.min==hl?null:t.min,t.max==-hl?null:t.max,e);t.min=l[0],t.max=l[1]}}}for(let e in l){let t=l[e];if(null!=t.from){let n=l[t.from];if(null==n.min)t.min=t.max=null;else{let l=t.range(k,n.min,n.max,e);t.min=l[0],t.max=l[1]}}}let e={},t=!1;for(let n in l){let i=l[n],o=vl[n];if(o.min!=i.min||o.max!=i.max){o.min=i.min,o.max=i.max;let l=o.distr;o._min=3==l?al(o.min):4==l?cl(o.min,o.asinh):o.min,o._max=3==l?al(o.max):4==l?cl(o.max,o.asinh):o.max,e[n]=t=!0}}if(t){dl.forEach(((l,t)=>{2==M?t>0&&e.y&&(l._paths=null):e[l.scale]&&(l._paths=null)}));for(let l in e)ft=!0,Ti("setScale",l);wt.show&&wt.left>=0&&(ct=pt=!0)}for(let l in Vl)Vl[l]=null}(),rt=!1),ft&&(function(){let l=!1,e=0;for(;!l;){e++;let t=kn(e),n=yn(e);l=e==xt||t&&n,l||(gt(k.width,k.height),ut=!0)}}(),ft=!1),ut){if(T(Z,s,Fe),T(Z,i,He),T(Z,t,Ye),T(Z,n,Ce),T($,s,Fe),T($,i,He),T($,t,Ye),T($,n,Ce),T(X,t,Ae),T(X,n,We),V.width=nl(Ae*y),V.height=nl(We*y),gl.forEach((({_el:e,_show:t,_size:n,_pos:i,side:o})=>{if(null!=e)if(t){let t=o%2==1;T(e,t?"left":"top",i-(3===o||0===o?n:0)),T(e,t?"width":"height",n),T(e,t?"top":"left",t?He:Fe),T(e,t?"height":"width",t?Ce:Ye),E(e,l)}else S(e,l)})),Xt=Zt=$t=ln=en=tn=nn=on=Qt=null,sn=1,hi(!0),Fe!=je||He!=Ue||Ye!=Be||Ce!=Ve){Mn(!1);let l=Ye/Be,e=Ce/Ve;if(wt.show&&!ct&&wt.left>=0){wt.left*=l,wt.top*=e,Tn&&A(Tn,nl(wt.left),0,Ye,Ce),zn&&A(zn,0,nl(wt.top),Ye,Ce);for(let t=1;yt.length>t;t++)Mt[t]*=l,St[t]*=e,A(yt[t],yl(Mt[t],1),yl(St[t],1),Ye,Ce)}if(qn.show&&!ht&&qn.left>=0&&qn.width>0){qn.left*=l,qn.width*=l,qn.top*=e,qn.height*=e;for(let l in mi)T(Kn,l,qn[l])}je=Fe,Ue=He,Be=Ye,Ve=Ce}Ti("setSize"),ut=!1}Ae>0&&We>0&&(J.clearRect(0,0,V.width,V.height),Ti("drawClear"),Rl.forEach((l=>l())),Ti("draw")),qn.show&&ht&&(Xn(qn),ht=!1),wt.show&&ct&&(fi(null,!0,!1),ct=!1),le.show&&le.live&&pt&&(ui(),pt=!1),R||(R=!0,k.status=1,Ti("ready")),un=!1,Rn=!1}function jn(l,e){let t=vl[l];if(null==t.from){if(0==At){let n=t.range(k,e.min,e.max,l);e.min=n[0],e.max=n[1]}if(e.min>e.max){let l=e.min;e.min=e.max,e.max=l}if(At>1&&null!=e.min&&null!=e.max&&1e-16>e.max-e.min)return;l==zl&&2==t.distr&&At>0&&(e.min=L(e.min,g[0]),e.max=L(e.max,g[0]),e.min==e.max&&e.max++),Vl[l]=e,rt=!0,On()}}k.batch=function(l,e=!1){Rn=!0,Gn=e,l(k),Nn(),e&&In.length>0&&queueMicrotask(Ln)},k.redraw=(l,e)=>{ft=e||!1,!1!==l?Zn(zl,Nl.min,Nl.max):On()},k.setScale=jn;let Un=!1;const Bn=wt.drag;let Vn=Bn.x,Jn=Bn.y;wt.show&&(wt.x&&(Sn=D("u-cursor-x",$)),wt.y&&(En=D("u-cursor-y",$)),0==Nl.ori?(Tn=Sn,zn=En):(Tn=En,zn=Sn),Fn=wt.left,Hn=wt.top);const qn=k.select=Il({show:!0,over:!0,left:0,width:0,top:0,height:0},u.select),Kn=qn.show?D("u-select",qn.over?$:Z):null;function Xn(l,e){if(qn.show){for(let e in l)qn[e]=l[e],e in mi&&T(Kn,e,l[e]);!1!==e&&Ti("setSelect")}}function Zn(l,e,t){jn(l,{min:e,max:t})}function $n(e,t,n,i){null!=t.focus&&function(l){if(l!=ei){let e=null==l,t=1!=vt.alpha;dl.forEach(((n,i)=>{if(1==M||i>0){let o=e||0==i||i==l;n._focus=e?null:o,t&&function(l,e){dl[l].alpha=e,wt.show&&yt[l]&&(yt[l].style.opacity=e),ee&&ae[l]&&(ae[l].style.opacity=e)}(i,o?1:vt.alpha)}})),ei=l,t&&On()}}(e),null!=t.show&&dl.forEach(((n,i)=>{0>=i||e!=i&&null!=e||(n.show=t.show,function(e){let t=ee?ae[e]:null;dl[e].show?t&&E(t,l):(t&&S(t,l),yt.length>1&&A(yt[e],-10,-10,Ye,Ce))}(i),2==M?(Zn(n.facets[0].scale,null,null),Zn(n.facets[1].scale,null,null)):Zn(n.scale,null,null),On())})),!1!==n&&Ti("setSeries",e,t),i&&Wi("setSeries",k,e,t)}let Qn,li,ei;k.setSelect=Xn,k.setSeries=$n,k.addBand=function(l,e){l.fill=ml(l.fill||null),l.dir=K(l.dir,-1),Ml.splice(e=null==e?Ml.length:e,0,l)},k.setBand=function(l,e){Il(Ml[l],e)},k.delBand=function(l){null==l?Ml.length=0:Ml.splice(l,1)};const ti={focus:!0};function ni(l,e,t){let n=vl[e];t&&(l=l/y-(1==n.ori?He:Fe));let i=Ye;1==n.ori&&(i=Ce,l=i-l),-1==n.dir&&(l=i-l);let o=n._min,s=o+l/i*(n._max-o),r=n.distr;return 3==r?rl(10,s):4==r?((l,e=1)=>Q.sinh(l)*e)(s,n.asinh):s}function ii(l,e){T(Kn,s,qn.left=l),T(Kn,t,qn.width=e)}function oi(l,e){T(Kn,i,qn.top=l),T(Kn,n,qn.height=e)}ee&&kt&&ze(p,oe,(l=>{wt._lock||(_t(l),null!=ei&&$n(null,ti,!0,Di.setSeries))})),k.valToIdx=l=>L(l,g[0]),k.posToIdx=function(l,e){return L(ni(l,zl,e),g[0],Yt,qt)},k.posToVal=ni,k.valToPos=(l,e,t)=>0==vl[e].ori?W(l,vl[e],t?Qe:Ye,t?Je:0):C(l,vl[e],t?ot:Ce,t?$e:0),k.setCursor=(l,e,t)=>{Fn=l.left,Hn=l.top,fi(null,e,t)};let si=0==Nl.ori?ii:oi,ri=1==Nl.ori?ii:oi;function ui(l,e){null!=l&&(l.idxs?l.idxs.forEach(((l,e)=>{Ql[e]=l})):(l=>void 0===l)(l.idx)||Ql.fill(l.idx),le.idx=Ql[0]);for(let l=0;dl.length>l;l++)(l>0||1==M&&!ce)&&ai(l,Ql[l]);ee&&le.live&&function(){if(ee&&le.live)for(let l=2==M?1:0;dl.length>l;l++){if(0==l&&ce)continue;let e=le.values[l],t=0;for(let n in e)fe[l][t++].firstChild.nodeValue=e[n]}}(),pt=!1,!1!==e&&Ti("setLegend")}function ai(l,e){let t,n=dl[l],i=0==l&&2==jl?rn:g[l];ce?t=n.values(k,l,e)??he:(t=n.value(k,null==e?null:i[e],l,e),t=null==t?he:{_:t}),le.values[l]=t}function fi(l,e,t){let n;Yn=Fn,Cn=Hn,[Fn,Hn]=wt.move(k,Fn,Hn),wt.left=Fn,wt.top=Hn,wt.show&&(Tn&&A(Tn,nl(Fn),0,Ye,Ce),zn&&A(zn,0,nl(Hn),Ye,Ce)),Qn=hl;let i=0==Nl.ori?Ye:Ce,o=1==Nl.ori?Ye:Ce;if(0>Fn||0==At||Yt>qt){n=wt.idx=null;for(let l=0;dl.length>l;l++)l>0&&yt.length>1&&A(yt[l],-10,-10,Ye,Ce);kt&&$n(null,ti,!0,null==l&&Di.setSeries),le.live&&(Ql.fill(n),pt=!0)}else{let l,e,t;1==M&&(l=0==Nl.ori?Fn:Hn,e=ni(l,zl),n=wt.idx=L(e,g[0],Yt,qt),t=Ul(g[0][n],Nl,i,0));for(let l=2==M?1:0;dl.length>l;l++){let s=dl[l],r=Ql[l],u=null==r?null:1==M?g[l][r]:g[l][1][r],a=wt.dataIdx(k,l,n,e),f=null==a?null:1==M?g[l][a]:g[l][1][a];pt=pt||f!=u||a!=r,Ql[l]=a;let c=a==n?t:Ul(1==M?g[0][a]:g[l][0][a],Nl,i,0);if(l>0&&s.show){let e,t,n=null==f?-10:Bl(f,1==M?vl[s.scale]:vl[s.facets[1].scale],o,0);if(kt&&null!=f){let e=1==Nl.ori?Fn:Hn,t=el(vt.dist(k,l,a,n,e));if(Qn>t){let n=vt.bias;if(0!=n){let i=ni(e,s.scale),o=0>i?-1:1;o!=(0>f?-1:1)||(1==o?1==n?i>f:f>i:1==n?f>i:i>f)||(Qn=t,li=l)}else Qn=t,li=l}}if(0==Nl.ori?(e=c,t=n):(e=n,t=c),pt&&yt.length>1){Y(yt[l],wt.points.fill(k,l),wt.points.stroke(k,l));let n,i,o,s,r=!0,u=wt.points.bbox;if(null!=u){r=!1;let e=u(k,l);o=e.left,s=e.top,n=e.width,i=e.height}else o=e,s=t,n=i=wt.points.size(k,l);F(yt[l],n,i,r),Mt[l]=o,St[l]=s,A(yt[l],yl(o,1),yl(s,1),Ye,Ce)}}}}if(qn.show&&Un)if(null!=l){let[e,t]=Di.scales,[n,s]=Di.match,[r,u]=l.cursor.sync.scales,a=l.cursor.drag;if(Vn=a._x,Jn=a._y,Vn||Jn){let a,f,c,h,d,{left:p,top:m,width:g,height:x}=l.select,w=l.scales[e].ori,_=l.posToVal,b=null!=e&&n(e,r),v=null!=t&&s(t,u);b&&Vn?(0==w?(a=p,f=g):(a=m,f=x),c=vl[e],h=Ul(_(a,r),c,i,0),d=Ul(_(a+f,r),c,i,0),si(ol(h,d),el(d-h))):si(0,i),v&&Jn?(1==w?(a=p,f=g):(a=m,f=x),c=vl[t],h=Bl(_(a,u),c,o,0),d=Bl(_(a+f,u),c,o,0),ri(ol(h,d),el(d-h))):ri(0,o)}else gi()}else{let l=el(Yn-Dn),e=el(Cn-Pn);if(1==Nl.ori){let t=l;l=e,e=t}Vn=Bn.x&&l>=Bn.dist,Jn=Bn.y&&e>=Bn.dist;let t,n,s=Bn.uni;null!=s?Vn&&Jn&&(Vn=l>=s,Jn=e>=s,Vn||Jn||(e>l?Jn=!0:Vn=!0)):Bn.x&&Bn.y&&(Vn||Jn)&&(Vn=Jn=!0),Vn&&(0==Nl.ori?(t=An,n=Fn):(t=Wn,n=Hn),si(ol(t,n),el(n-t)),Jn||ri(0,o)),Jn&&(1==Nl.ori?(t=An,n=Fn):(t=Wn,n=Hn),ri(ol(t,n),el(n-t)),Vn||si(0,i)),Vn||Jn||(si(0,0),ri(0,0))}if(Bn._x=Vn,Bn._y=Jn,null==l){if(t){if(null!=Pi){let[l,e]=Di.scales;Di.values[0]=null!=l?ni(0==Nl.ori?Fn:Hn,l):null,Di.values[1]=null!=e?ni(1==Nl.ori?Fn:Hn,e):null}Wi(f,k,Fn,Hn,Ye,Ce,n)}if(kt){let l=t&&Di.setSeries,e=vt.prox;null==ei?Qn>e||$n(li,ti,!0,l):Qn>e?$n(null,ti,!0,l):li!=ei&&$n(li,ti,!0,l)}}pt&&(le.idx=n,ui()),!1!==e&&Ti("setCursor")}k.setLegend=ui;let ci=null;function hi(l=!1){l?ci=null:(ci=$.getBoundingClientRect(),Ti("syncRect",ci))}function di(l,e,t,n,i,o){wt._lock||Un&&null!=l&&0==l.movementX&&0==l.movementY||(pi(l,e,t,n,i,o,0,!1,null!=l),null!=l?fi(null,!0,!0):fi(e,!0,!1))}function pi(l,e,t,n,i,o,s,r,u){if(null==ci&&hi(!1),_t(l),null!=l)t=l.clientX-ci.left,n=l.clientY-ci.top;else{if(0>t||0>n)return Fn=-10,void(Hn=-10);let[l,s]=Di.scales,r=e.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,d]=Di.match,p=e.axes[0].side%2==1,m=0==Nl.ori?Ye:Ce,g=1==Nl.ori?Ye:Ce,x=p?o:i,w=p?i:o,_=p?n:t,b=p?t:n;if(t=null!=f?h(l,f)?H(u,vl[l],m,0):-10:m*(_/x),n=null!=c?d(s,c)?H(a,vl[s],g,0):-10:g*(b/w),1==Nl.ori){let l=t;t=n,n=l}}u&&(t>1&&Ye-1>t||(t=kl(t,Ye)),n>1&&Ce-1>n||(n=kl(n,Ce))),r?(Dn=t,Pn=n,[An,Wn]=wt.move(k,t,n)):(Fn=t,Hn=n)}Object.defineProperty(k,"rect",{get:()=>(null==ci&&hi(!1),ci)});const mi={width:0,height:0,left:0,top:0};function gi(){Xn(mi,!1)}let xi,wi,_i,bi;function vi(l,e,t,n,i,o){Un=!0,Vn=Jn=Bn._x=Bn._y=!1,pi(l,e,t,n,i,o,0,!0,!1),null!=l&&(ze(h,b,ki,!1),Wi(c,k,An,Wn,Ye,Ce,null));let{left:s,top:r,width:u,height:a}=qn;xi=s,wi=r,_i=u,bi=a,gi()}function ki(l,e,t,n,i,o){Un=Bn._x=Bn._y=!1,pi(l,e,t,n,i,o,0,!1,!0);let{left:s,top:r,width:u,height:a}=qn,f=u>0||a>0,c=xi!=s||wi!=r||_i!=u||bi!=a;if(f&&c&&Xn(qn),Bn.setScale&&f&&c){let l=s,e=u,t=r,n=a;if(1==Nl.ori&&(l=r,e=a,t=s,n=u),Vn&&Zn(zl,ni(l,zl),ni(l+e,zl)),Jn)for(let l in vl){let e=vl[l];l!=zl&&null==e.from&&e.min!=hl&&Zn(l,ni(t+n,l),ni(t,l))}gi()}else wt.lock&&(wt._lock=!wt._lock,wt._lock||fi(null,!0,!1));null!=l&&(De(h,b),Wi(h,k,Fn,Hn,Ye,Ce,null))}function yi(l){wt._lock||(_t(l),fn(),gi(),null!=l&&Wi(m,k,Fn,Hn,Ye,Ce,null))}function Mi(){gl.forEach(Jt),mt(k.width,k.height,!0)}G(x,v,Mi);const Si={};Si.mousedown=vi,Si.mousemove=di,Si.mouseup=ki,Si.dblclick=yi,Si.setSeries=(l,e,t,n)=>{-1!=(t=(0,Di.match[2])(k,e,t))&&$n(t,n,!0,!1)},wt.show&&(ze(c,$,vi),ze(f,$,di),ze(d,$,(l=>{_t(l),hi(!1)})),ze(p,$,(function(l){if(wt._lock)return;_t(l);let e=Un;if(Un){let l,e,t=!0,n=!0,i=10;0==Nl.ori?(l=Vn,e=Jn):(l=Jn,e=Vn),l&&e&&(t=i>=Fn||Fn>=Ye-i,n=i>=Hn||Hn>=Ce-i),l&&t&&(Fn=An>Fn?0:Ye),e&&n&&(Hn=Wn>Hn?0:Ce),fi(null,!0,!0),Un=!1}Fn=-10,Hn=-10,fi(null,!0,!0),e&&(Un=e)})),ze(m,$,yi),Wt.add(k),k.syncRect=hi);const Ei=k.hooks=u.hooks||{};function Ti(l,e,t){Gn?In.push([l,e,t]):l in Ei&&Ei[l].forEach((l=>{l.call(null,k,e,t)}))}(u.plugins||[]).forEach((l=>{for(let e in l.hooks)Ei[e]=(Ei[e]||[]).concat(l.hooks[e])}));const zi=(l,e,t)=>t,Di=Il({key:null,setSeries:!1,filters:{pub:_l,sub:_l},scales:[zl,dl[1]?dl[1].scale:null],match:[bl,bl,zi],values:[null,null]},wt.sync);2==Di.match.length&&Di.match.push(zi),wt.sync=Di;const Pi=Di.key,Ai=st(Pi);function Wi(l,e,t,n,i,o,s){Di.filters.pub(l,e,t,n,i,o,s)&&Ai.pub(l,e,t,n,i,o,s)}function Yi(){Ti("init",u,g),an(g||u.data,!1),Vl[zl]?jn(zl,Vl[zl]):fn(),ht=qn.show&&(qn.width>0||qn.height>0),ct=pt=!0,mt(u.width,u.height)}return Ai.sub(k),k.pub=function(l,e,t,n,i,o,s){Di.filters.sub(l,e,t,n,i,o,s)&&Si[l](null,e,t,n,i,o,s)},k.destroy=function(){Ai.unsub(k),Wt.delete(k),Te.clear(),I(x,v,Mi),O.remove(),oe?.remove(),Ti("destroy")},dl.forEach(Et),gl.forEach((function(l,e){if(l._show=l.show,l.show){let t=vl[l.scale];null==t&&(l.scale=l.side%2?dl[1].scale:zl,t=vl[l.scale]);let n=t.time;l.size=ml(l.size),l.space=ml(l.space),l.rotate=ml(l.rotate),Wl(l.incrs)&&l.incrs.forEach((l=>{!El.has(l)&&El.set(l,Tl(l))})),l.incrs=ml(l.incrs||(2==t.distr?te:n?1==fl?me:we:ne)),l.splits=ml(l.splits||(n&&1==t.distr?Kl:3==t.distr?Oe:4==t.distr?Ne:Le)),l.stroke=ml(l.stroke),l.grid.stroke=ml(l.grid.stroke),l.ticks.stroke=ml(l.ticks.stroke),l.border.stroke=ml(l.border.stroke);let i=l.values;l.values=Wl(i)&&!Wl(i[0])?ml(i):n?Wl(i)?ke(Jl,ve(i,ql)):Cl(i)?function(l,e){let t=Xl(e);return(e,n)=>n.map((e=>t(l(e))))}(Jl,i):i||Zl:i||Ie,l.filter=ml(l.filter||(3>t.distr||10!=t.log?3==t.distr&&2==t.log?Ke:xl:qe)),l.font=Vt(l.font),l.labelFont=Vt(l.labelFont),l._size=l.size(k,null,e,0),l._space=l._rotate=l._incrs=l._found=l._splits=l._values=null,l._size>0&&(Tt[e]=!0,l._el=D("u-axis",X))}})),_?_ instanceof HTMLElement?(_.appendChild(O),Yi()):_(k,Yi):Yi(),k}qt.assign=Il,qt.fmtNum=$,qt.rangeNum=q,qt.rangeLog=N,qt.rangeAsinh=j,qt.orient=rt,qt.pxRatio=y,qt.join=function(l,e){if(function(l){let e=l[0][0],t=e.length;for(let n=1;l.length>n;n++){let i=l[n][0];if(i.length!=t)return!1;if(i!=e)for(let l=0;t>l;l++)if(i[l]!=e[l])return!1}return!0}(l)){let e=l[0].slice();for(let t=1;l.length>t;t++)e.push(...l[t].slice(1));return function(l,e=100){const t=l.length;if(1>=t)return!0;let n=0,i=t-1;for(;i>=n&&null==l[n];)n++;for(;i>=n&&null==l[i];)i--;if(n>=i)return!0;const o=sl(1,tl((i-n+1)/e));for(let e=l[n],t=n+o;i>=t;t+=o){const n=l[t];if(null!=n){if(e>=n)return!1;e=n}}return!0}(e[0])||(e=function(l){let e=l[0],t=e.length,n=Array(t);for(let l=0;n.length>l;l++)n[l]=l;n.sort(((l,t)=>e[l]-e[t]));let i=[];for(let e=0;l.length>e;e++){let o=l[e],s=Array(t);for(let l=0;t>l;l++)s[l]=o[n[l]];i.push(s)}return i}(e)),e}let t=new Set;for(let e=0;l.length>e;e++){let n=l[e][0],i=n.length;for(let l=0;i>l;l++)t.add(n[l])}let n=[Array.from(t).sort(((l,e)=>l-e))],i=n[0].length,o=new Map;for(let l=0;i>l;l++)o.set(n[0][l],l);for(let t=0;l.length>t;t++){let s=l[t],r=s[0];for(let l=1;s.length>l;l++){let u=s[l],a=Array(i).fill(void 0),f=e?e[t][l]:1,c=[];for(let l=0;u.length>l;l++){let e=u[l],t=o.get(r[l]);null===e?0!=f&&(a[t]=e,2==f&&c.push(t)):a[t]=e}Ll(a,c,i),n.push(a)}}return n},qt.fmtDate=Xl,qt.tzDate=function(l,e){let t;return"UTC"==e||"Etc/UTC"==e?t=new Date(+l+6e4*l.getTimezoneOffset()):e==Zl?t=l:(t=new Date(l.toLocaleString("en-US",{timeZone:e})),t.setMilliseconds(l.getMilliseconds())),t},qt.sync=st;{qt.addGap=function(l,e,t){let n=l[l.length-1];n&&n[0]==e?n[1]=t:l.push([e,t])},qt.clipGaps=ct;let l=qt.paths={points:St};l.linear=Dt,l.stepped=function(l){const e=K(l.align,1),t=K(l.ascDesc,!1),n=K(l.alignGaps,0),i=K(l.extend,!1);return(l,o,s,r)=>rt(l,o,((u,a,f,c,h,d,p,m,g,x,w)=>{let _=u.pxRound,{left:b,width:v}=l.bbox,k=l=>_(d(l,c,x,m)),M=l=>_(p(l,h,w,g)),S=0==c.ori?xt:wt;const E={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},T=E.stroke,z=c.dir*(0==c.ori?1:-1);s=O(f,s,r,1),r=O(f,s,r,-1);let D=M(f[1==z?s:r]),P=k(a[1==z?s:r]),A=P,W=P;i&&-1==e&&(W=b,S(T,W,D)),S(T,P,D);for(let l=1==z?s:r;l>=s&&r>=l;l+=z){let t=f[l];if(null==t)continue;let n=k(a[l]),i=M(t);1==e?S(T,n,D):S(T,A,i),S(T,n,i),D=i,A=n}let Y=A;i&&1==e&&(Y=b+v,S(T,Y,D));let[C,F]=ut(l,o);if(null!=u.fill||0!=C){let e=E.fill=new Path2D(T),t=M(u.fillTo(l,o,u.min,u.max,C));S(e,Y,t),S(e,W,t)}if(!u.spanGaps){let i=[];i.push(...ht(a,f,s,r,z,k,n));let h=u.width*y/2,d=t||1==e?h:-h,p=t||-1==e?-h:h;i.forEach((l=>{l[0]+=d,l[1]+=p})),E.gaps=i=u.gaps(l,o,s,r,i),E.clip=ct(i,c.ori,m,g,x,w)}return 0!=F&&(E.band=2==F?[ft(l,o,s,r,T,-1),ft(l,o,s,r,T,1)]:ft(l,o,s,r,T,F)),E}))},l.bars=function(l){const e=K((l=l||Dl).size,[.6,hl,1]),t=l.align||0,n=l.gap||0;let i=l.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const o=ml(i),s=1-e[0],r=K(e[1],hl),u=K(e[2],1),a=K(l.disp,Dl),f=K(l.each,(()=>{})),{fill:c,stroke:h}=a;return(l,e,i,d)=>rt(l,e,((p,m,g,x,w,_,b,v,k,M,S)=>{let E,T,z=p.pxRound,D=t,P=n*y,A=r*y,W=u*y;0==x.ori?[E,T]=o(l,e):[T,E]=o(l,e);const Y=x.dir*(0==x.ori?1:-1);let C,F,H,R=0==x.ori?_t:bt,G=0==x.ori?f:(l,e,t,n,i,o,s)=>{f(l,e,t,i,n,s,o)},I=K(l.bands,Pl).find((l=>l.series[0]==e)),L=p.fillTo(l,e,p.min,p.max,null!=I?I.dir:0),O=z(b(L,w,S,k)),N=M,j=z(p.width*y),U=!1,B=null,V=null,J=null,q=null;null==c||0!=j&&null==h||(U=!0,B=c.values(l,e,i,d),V=new Map,new Set(B).forEach((l=>{null!=l&&V.set(l,new Path2D)})),j>0&&(J=h.values(l,e,i,d),q=new Map,new Set(J).forEach((l=>{null!=l&&q.set(l,new Path2D)}))));let{x0:X,size:Z}=a;if(null!=X&&null!=Z){D=1,m=X.values(l,e,i,d),2==X.unit&&(m=m.map((e=>l.posToVal(v+e*M,x.key,!0))));let t=Z.values(l,e,i,d);F=2==Z.unit?t[0]*M:_(t[0],x,M,v)-_(0,x,M,v),N=Pt(m,g,_,x,M,v,N),H=N-F+P}else N=Pt(m,g,_,x,M,v,N),H=N*s+P,F=N-H;1>H&&(H=0),F/2>j||(j=0),5>H&&(z=gl);let $=H>0;F=z(pl(N-H-($?j:0),W,A)),C=(0==D?F/2:D==Y?0:F)-D*Y*((0==D?P/2:0)+($?j/2:0));const Q={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},ll=U?null:new Path2D;let el=null;if(null!=I)el=l.data[I.series[1]];else{let{y0:t,y1:n}=a;null!=t&&null!=n&&(g=n.values(l,e,i,d),el=t.values(l,e,i,d))}let nl=E*F,il=T*F;for(let t=1==Y?i:d;t>=i&&d>=t;t+=Y){let n=g[t];if(null==n)continue;if(null!=el){let l=el[t]??0;if(n-l==0)continue;O=b(l,w,S,k)}let i=_(2!=x.distr||null!=a?m[t]:t,x,M,v),o=b(K(n,L),w,S,k),s=z(i-C),r=z(sl(o,O)),u=z(ol(o,O)),f=r-u;if(null!=n){let i=0>n?il:nl,o=0>n?nl:il;U?(j>0&&null!=J[t]&&R(q.get(J[t]),s,u+tl(j/2),F,sl(0,f-j),i,o),null!=B[t]&&R(V.get(B[t]),s,u+tl(j/2),F,sl(0,f-j),i,o)):R(ll,s,u+tl(j/2),F,sl(0,f-j),i,o),G(l,e,t,s-j/2,u,F+j,f)}}return j>0?Q.stroke=U?q:ll:U||(Q._fill=0==p.width?p._fill:p._stroke??p._fill,Q.width=0),Q.fill=U?V:ll,Q}))},l.spline=function(l){return function(l,e){const t=K(e?.alignGaps,0);return(e,n,i,o)=>rt(e,n,((s,r,u,a,f,c,h,d,p,m,g)=>{let x,w,_,b=s.pxRound,v=l=>b(c(l,a,m,d)),k=l=>b(h(l,f,g,p));0==a.ori?(x=mt,_=xt,w=yt):(x=gt,_=wt,w=Mt);const y=a.dir*(0==a.ori?1:-1);i=O(u,i,o,1),o=O(u,i,o,-1);let M=v(r[1==y?i:o]),S=M,E=[],T=[];for(let l=1==y?i:o;l>=i&&o>=l;l+=y)if(null!=u[l]){let e=v(r[l]);E.push(S=e),T.push(k(u[l]))}const z={stroke:l(E,T,x,_,w,b),fill:null,clip:null,band:null,gaps:null,flags:1},D=z.stroke;let[P,A]=ut(e,n);if(null!=s.fill||0!=P){let l=z.fill=new Path2D(D),t=k(s.fillTo(e,n,s.min,s.max,P));_(l,S,t),_(l,M,t)}if(!s.spanGaps){let l=[];l.push(...ht(r,u,i,o,y,v,t)),z.gaps=l=s.gaps(e,n,i,o,l),z.clip=ct(l,a.ori,d,p,m,g)}return 0!=A&&(z.band=2==A?[ft(e,n,i,o,D,-1),ft(e,n,i,o,D,1)]:ft(e,n,i,o,D,A)),z}))}(At,l)}}return qt}(); diff --git a/static/map.html b/static/map.html new file mode 100644 index 0000000..5c8a946 --- /dev/null +++ b/static/map.html @@ -0,0 +1,31 @@ + + + + + PPF Proxy Map + + + + + + + + +
+
-Countries
+
-Proxies
+
+
+
+
Anonymity Level
+
Elite
+
Anonymous
+
Transparent
+
+ + + + + + + diff --git a/static/map.js b/static/map.js new file mode 100644 index 0000000..fc89354 --- /dev/null +++ b/static/map.js @@ -0,0 +1,406 @@ +/** + * PPF Proxy Map - Interactive visualization + */ +(function() { + 'use strict'; + + // Theme toggle (shared with dashboard) + var themes = ['dark', 'muted-dark', 'light']; + function getTheme() { + if (document.documentElement.classList.contains('light')) return 'light'; + if (document.documentElement.classList.contains('muted-dark')) return 'muted-dark'; + return 'dark'; + } + function setTheme(theme) { + document.documentElement.classList.remove('light', 'muted-dark'); + if (theme === 'light') document.documentElement.classList.add('light'); + else if (theme === 'muted-dark') document.documentElement.classList.add('muted-dark'); + try { localStorage.setItem('ppf-theme', theme); } catch(e) {} + } + function initTheme() { + var saved = null; + try { saved = localStorage.getItem('ppf-theme'); } catch(e) {} + if (saved && themes.indexOf(saved) !== -1) { + setTheme(saved); + } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { + setTheme('light'); + } + var btn = document.getElementById('themeToggle'); + if (btn) { + btn.addEventListener('click', function() { + var current = getTheme(); + var idx = themes.indexOf(current); + var next = themes[(idx + 1) % themes.length]; + setTheme(next); + }); + } + } + document.addEventListener('DOMContentLoaded', initTheme); + + // Country coordinates (ISO 3166-1 alpha-2 -> [lat, lon]) + var COORDS = { + "AD":[42.5,1.5],"AE":[24,54],"AF":[33,65],"AG":[17.05,-61.8],"AL":[41,20], + "AM":[40,45],"AO":[-12.5,18.5],"AR":[-34,-64],"AT":[47.33,13.33],"AU":[-27,133], + "AZ":[40.5,47.5],"BA":[44,18],"BB":[13.17,-59.53],"BD":[24,90],"BE":[50.83,4], + "BF":[13,-2],"BG":[43,25],"BH":[26,50.55],"BI":[-3.5,30],"BJ":[9.5,2.25], + "BN":[4.5,114.67],"BO":[-17,-65],"BR":[-10,-55],"BS":[24.25,-76],"BT":[27.5,90.5], + "BW":[-22,24],"BY":[53,28],"BZ":[17.25,-88.75],"CA":[60,-95],"CD":[-2.5,23.5], + "CF":[7,21],"CG":[-1,15],"CH":[47,8],"CI":[8,-5],"CL":[-30,-71],"CM":[6,12], + "CN":[35,105],"CO":[4,-72],"CR":[10,-84],"CU":[21.5,-80],"CV":[16,-24], + "CY":[35,33],"CZ":[49.75,15.5],"DE":[51,9],"DJ":[11.5,43],"DK":[56,10], + "DO":[19,-70],"DZ":[28,3],"EC":[-2,-77.5],"EE":[59,26],"EG":[27,30], + "ER":[15,39],"ES":[40,-4],"ET":[8,38],"FI":[64,26],"FJ":[-18,175],"FR":[46,2], + "GA":[-1,11.75],"GB":[54,-2],"GE":[42,43.5],"GH":[8,-2],"GM":[13.47,-16.57], + "GN":[11,-10],"GQ":[2,10],"GR":[39,22],"GT":[15.5,-90.25],"GW":[12,-15], + "GY":[5,-59],"HK":[22.25,114.17],"HN":[15,-86.5],"HR":[45.17,15.5], + "HT":[19,-72.42],"HU":[47,20],"ID":[-5,120],"IE":[53,-8],"IL":[31.5,34.75], + "IN":[20,77],"IQ":[33,44],"IR":[32,53],"IS":[65,-18],"IT":[42.83,12.83], + "JM":[18.25,-77.5],"JO":[31,36],"JP":[36,138],"KE":[-1,38],"KG":[41,75], + "KH":[13,105],"KM":[-12.17,44.25],"KP":[40,127],"KR":[37,127.5],"KW":[29.5,45.75], + "KZ":[48,68],"LA":[18,105],"LB":[33.83,35.83],"LK":[7,81],"LR":[6.5,-9.5], + "LS":[-29.5,28.5],"LT":[56,24],"LU":[49.75,6.17],"LV":[57,25],"LY":[25,17], + "MA":[32,-5],"MC":[43.73,7.42],"MD":[47,29],"ME":[42.5,19.3],"MG":[-20,47], + "MK":[41.83,22],"ML":[17,-4],"MM":[22,98],"MN":[46,105],"MO":[22.17,113.55], + "MR":[20,-12],"MT":[35.83,14.58],"MU":[-20.28,57.55],"MV":[3.25,73], + "MW":[-13.5,34],"MX":[23,-102],"MY":[2.5,112.5],"MZ":[-18.25,35],"NA":[-22,17], + "NE":[16,8],"NG":[10,8],"NI":[13,-85],"NL":[52.5,5.75],"NO":[62,10], + "NP":[28,84],"NZ":[-41,174],"OM":[21,57],"PA":[9,-80],"PE":[-10,-76], + "PG":[-6,147],"PH":[13,122],"PK":[30,70],"PL":[52,20],"PR":[18.25,-66.5], + "PS":[32,35.25],"PT":[39.5,-8],"PY":[-23,-58],"QA":[25.5,51.25],"RO":[46,25], + "RS":[44,21],"RU":[60,100],"RW":[-2,30],"SA":[25,45],"SC":[-4.58,55.67], + "SD":[15,30],"SE":[62,15],"SG":[1.37,103.8],"SI":[46.12,14.82],"SK":[48.67,19.5], + "SL":[8.5,-11.5],"SN":[14,-14],"SO":[10,49],"SR":[4,-56],"SS":[7,30], + "SV":[13.83,-88.92],"SY":[35,38],"SZ":[-26.5,31.5],"TD":[15,19],"TG":[8,1.17], + "TH":[15,100],"TJ":[39,71],"TM":[40,60],"TN":[34,9],"TO":[-20,-175], + "TR":[39,35],"TT":[11,-61],"TW":[23.5,121],"TZ":[-6,35],"UA":[49,32], + "UG":[1,32],"US":[38,-97],"UY":[-33,-56],"UZ":[41,64],"VE":[8,-66], + "VN":[16,106],"YE":[15,48],"ZA":[-29,24],"ZM":[-15,30],"ZW":[-20,30],"XK":[42.6,20.9] + }; + + // Country names + var NAMES = { + "AD":"Andorra","AE":"UAE","AF":"Afghanistan","AG":"Antigua","AL":"Albania", + "AM":"Armenia","AO":"Angola","AR":"Argentina","AT":"Austria","AU":"Australia", + "AZ":"Azerbaijan","BA":"Bosnia","BB":"Barbados","BD":"Bangladesh","BE":"Belgium", + "BF":"Burkina Faso","BG":"Bulgaria","BH":"Bahrain","BI":"Burundi","BJ":"Benin", + "BN":"Brunei","BO":"Bolivia","BR":"Brazil","BS":"Bahamas","BT":"Bhutan", + "BW":"Botswana","BY":"Belarus","BZ":"Belize","CA":"Canada","CD":"DR Congo", + "CF":"C. African Rep.","CG":"Congo","CH":"Switzerland","CI":"Ivory Coast", + "CL":"Chile","CM":"Cameroon","CN":"China","CO":"Colombia","CR":"Costa Rica", + "CU":"Cuba","CV":"Cape Verde","CY":"Cyprus","CZ":"Czechia","DE":"Germany", + "DJ":"Djibouti","DK":"Denmark","DO":"Dominican Rep.","DZ":"Algeria","EC":"Ecuador", + "EE":"Estonia","EG":"Egypt","ER":"Eritrea","ES":"Spain","ET":"Ethiopia", + "FI":"Finland","FJ":"Fiji","FR":"France","GA":"Gabon","GB":"United Kingdom", + "GE":"Georgia","GH":"Ghana","GM":"Gambia","GN":"Guinea","GQ":"Eq. Guinea", + "GR":"Greece","GT":"Guatemala","GW":"Guinea-Bissau","GY":"Guyana","HK":"Hong Kong", + "HN":"Honduras","HR":"Croatia","HT":"Haiti","HU":"Hungary","ID":"Indonesia", + "IE":"Ireland","IL":"Israel","IN":"India","IQ":"Iraq","IR":"Iran","IS":"Iceland", + "IT":"Italy","JM":"Jamaica","JO":"Jordan","JP":"Japan","KE":"Kenya", + "KG":"Kyrgyzstan","KH":"Cambodia","KM":"Comoros","KP":"North Korea", + "KR":"South Korea","KW":"Kuwait","KZ":"Kazakhstan","LA":"Laos","LB":"Lebanon", + "LK":"Sri Lanka","LR":"Liberia","LS":"Lesotho","LT":"Lithuania","LU":"Luxembourg", + "LV":"Latvia","LY":"Libya","MA":"Morocco","MC":"Monaco","MD":"Moldova", + "ME":"Montenegro","MG":"Madagascar","MK":"N. Macedonia","ML":"Mali","MM":"Myanmar", + "MN":"Mongolia","MO":"Macau","MR":"Mauritania","MT":"Malta","MU":"Mauritius", + "MV":"Maldives","MW":"Malawi","MX":"Mexico","MY":"Malaysia","MZ":"Mozambique", + "NA":"Namibia","NE":"Niger","NG":"Nigeria","NI":"Nicaragua","NL":"Netherlands", + "NO":"Norway","NP":"Nepal","NZ":"New Zealand","OM":"Oman","PA":"Panama", + "PE":"Peru","PG":"Papua New Guinea","PH":"Philippines","PK":"Pakistan", + "PL":"Poland","PR":"Puerto Rico","PS":"Palestine","PT":"Portugal","PY":"Paraguay", + "QA":"Qatar","RO":"Romania","RS":"Serbia","RU":"Russia","RW":"Rwanda", + "SA":"Saudi Arabia","SC":"Seychelles","SD":"Sudan","SE":"Sweden","SG":"Singapore", + "SI":"Slovenia","SK":"Slovakia","SL":"Sierra Leone","SN":"Senegal","SO":"Somalia", + "SR":"Suriname","SS":"South Sudan","SV":"El Salvador","SY":"Syria","SZ":"Eswatini", + "TD":"Chad","TG":"Togo","TH":"Thailand","TJ":"Tajikistan","TM":"Turkmenistan", + "TN":"Tunisia","TO":"Tonga","TR":"Turkey","TT":"Trinidad","TW":"Taiwan", + "TZ":"Tanzania","UA":"Ukraine","UG":"Uganda","US":"United States","UY":"Uruguay", + "UZ":"Uzbekistan","VE":"Venezuela","VN":"Vietnam","YE":"Yemen","ZA":"South Africa", + "ZM":"Zambia","ZW":"Zimbabwe","XK":"Kosovo" + }; + + // Anonymity color mapping (matches CSS variables) + var ANON_COLORS = { + elite: {fill: '#50c878', stroke: '#2d8a4e'}, + anonymous: {fill: '#38bdf8', stroke: '#1d8acf'}, + transparent: {fill: '#f97316', stroke: '#c2410c'}, + unknown: {fill: '#6b7280', stroke: '#4b5563'} + }; + + // Heatmap gradient + var HEAT_GRADIENT = { + 0.0: '#181f2a', + 0.3: '#1d4e89', + 0.5: '#38bdf8', + 0.7: '#50c878', + 1.0: '#7ee787' + }; + + // Map configuration + var MAP_CONFIG = { + center: [30, 10], + zoom: 2, + minZoom: 2, + maxZoom: 8, + tileUrl: 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', + tileAttribution: '© OSM © CARTO' + }; + + // Cluster configuration + var CLUSTER_CONFIG = { + showCoverageOnHover: false, + spiderfyOnMaxZoom: true, + disableClusteringAtZoom: 7, + maxClusterRadius: 50 + }; + + // DOM element references + var $countryCount, $proxyCount, map, clusterGroup; + + /** + * Initialize the map + */ + function init() { + $countryCount = document.getElementById('countryCount'); + $proxyCount = document.getElementById('proxyCount'); + + // Set loading state + $countryCount.classList.add('loading'); + $proxyCount.classList.add('loading'); + + // Create map + map = L.map('map', { + center: MAP_CONFIG.center, + zoom: MAP_CONFIG.zoom, + minZoom: MAP_CONFIG.minZoom, + maxZoom: MAP_CONFIG.maxZoom, + zoomControl: true, + worldCopyJump: true + }); + + // Add tile layer + L.tileLayer(MAP_CONFIG.tileUrl, { + attribution: MAP_CONFIG.tileAttribution, + subdomains: 'abcd', + maxZoom: 19 + }).addTo(map); + + // Create cluster group + clusterGroup = L.markerClusterGroup({ + showCoverageOnHover: CLUSTER_CONFIG.showCoverageOnHover, + spiderfyOnMaxZoom: CLUSTER_CONFIG.spiderfyOnMaxZoom, + disableClusteringAtZoom: CLUSTER_CONFIG.disableClusteringAtZoom, + maxClusterRadius: CLUSTER_CONFIG.maxClusterRadius, + iconCreateFunction: createClusterIcon + }); + + // Load data + loadData(); + } + + /** + * Create cluster icon + */ + function createClusterIcon(cluster) { + var count = cluster.getChildCount(); + var size = count >= 100 ? 'lg' : count >= 10 ? 'md' : 'sm'; + var sizeMap = {sm: 32, md: 40, lg: 50}; + return L.divIcon({ + html: '
' + count + '
', + className: 'cluster-wrapper', + iconSize: L.point(sizeMap[size], sizeMap[size]) + }); + } + + /** + * Calculate brightness based on count (logarithmic scale) + */ + function calcBrightness(count, maxCount, minBrightness, maxBrightness) { + minBrightness = minBrightness || 0.3; + maxBrightness = maxBrightness || 1.0; + var range = maxBrightness - minBrightness; + return minBrightness + range * (Math.log(count + 1) / Math.log(maxCount + 1)); + } + + /** + * Calculate radius based on count + */ + function calcRadius(count, baseRadius, maxExtra, divisor) { + baseRadius = baseRadius || 3; + maxExtra = maxExtra || 7; + divisor = divisor || 5; + return baseRadius + Math.min(maxExtra, Math.sqrt(count / divisor)); + } + + /** + * Create popup content + */ + function createPopup(code, count, anon, lat, lon, isApprox) { + var name = NAMES[code] || code; + var anonLabel = anon ? anon.charAt(0).toUpperCase() + anon.slice(1) : ''; + var coords = isApprox ? 'approx. location' : + (anonLabel ? anonLabel + ' • ' : '') + lat.toFixed(1) + ', ' + lon.toFixed(1); + + return '' + + '' + + ''; + } + + /** + * Load and render map data + */ + function loadData() { + Promise.all([ + fetch('/api/locations').then(function(r) { return r.json(); }).catch(function() { return {locations: []}; }), + fetch('/api/countries').then(function(r) { return r.json(); }) + ]).then(function(results) { + var locations = results[0].locations || []; + var countries = results[1].countries || {}; + + renderData(locations, countries); + }).catch(function() { + $proxyCount.textContent = 'Error'; + $proxyCount.style.color = '#ef4444'; + }); + } + + /** + * Render map data + */ + function renderData(locations, countries) { + var entries = Object.entries(countries).sort(function(a, b) { return b[1] - a[1]; }); + var total = entries.reduce(function(s, e) { return s + e[1]; }, 0); + + // Update stats + $countryCount.textContent = entries.length; + $proxyCount.textContent = total.toLocaleString(); + $countryCount.classList.remove('loading'); + $proxyCount.classList.remove('loading'); + + // Track countries with precise locations + var countriesWithPrecise = {}; + locations.forEach(function(l) { + countriesWithPrecise[l.country] = (countriesWithPrecise[l.country] || 0) + l.count; + }); + + // Add heatmap layer + renderHeatmap(locations); + + // Add precise location markers + renderPreciseLocations(locations); + + // Add country centroid markers + renderCountryCentroids(entries, countriesWithPrecise); + } + + /** + * Render heatmap layer + */ + function renderHeatmap(locations) { + if (locations.length === 0) return; + + var heatData = locations.map(function(l) { + var intensity = Math.min(l.count / 50, 1.0); + return [l.lat, l.lon, intensity]; + }); + + L.heatLayer(heatData, { + radius: 25, + blur: 20, + maxZoom: 6, + max: 1.0, + minOpacity: 0.3, + gradient: HEAT_GRADIENT + }).addTo(map); + } + + /** + * Render precise location markers + */ + function renderPreciseLocations(locations) { + if (locations.length === 0) return; + + var maxCount = Math.max.apply(null, locations.map(function(l) { return l.count; })) || 1; + + locations.forEach(function(l) { + var brightness = calcBrightness(l.count, maxCount); + var radius = calcRadius(l.count); + var colors = ANON_COLORS[l.anon] || ANON_COLORS.unknown; + + var marker = L.circleMarker([l.lat, l.lon], { + radius: radius, + fillColor: colors.fill, + color: colors.stroke, + weight: 1, + opacity: brightness, + fillOpacity: brightness * 0.85 + }); + + marker.bindPopup(createPopup(l.country, l.count, l.anon, l.lat, l.lon, false)); + + // Hover effects + marker.on('mouseover', function() { + this.setStyle({fillOpacity: 0.95, opacity: 1, weight: 2}); + }); + marker.on('mouseout', function() { + this.setStyle({fillOpacity: brightness * 0.85, opacity: brightness, weight: 1}); + }); + + clusterGroup.addLayer(marker); + }); + + map.addLayer(clusterGroup); + } + + /** + * Render country centroid markers (for proxies without precise coords) + */ + function renderCountryCentroids(entries, countriesWithPrecise) { + // Find max remaining for normalization + var maxRemaining = 1; + entries.forEach(function(e) { + var remaining = e[1] - (countriesWithPrecise[e[0]] || 0); + if (remaining > maxRemaining) maxRemaining = remaining; + }); + + entries.forEach(function(e) { + var code = e[0], count = e[1], coords = COORDS[code]; + if (!coords) return; + + var preciseInCountry = countriesWithPrecise[code] || 0; + var remaining = count - preciseInCountry; + if (remaining <= 0) return; + + var brightness = calcBrightness(remaining, maxRemaining, 0.25, 0.9); + var radius = calcRadius(remaining, 4, 10, 10); + + var circle = L.circleMarker([coords[0], coords[1]], { + radius: radius, + fillColor: '#38bdf8', + color: '#1d8acf', + weight: 1, + opacity: brightness, + fillOpacity: brightness * 0.7 + }).addTo(map); + + circle.bindPopup(createPopup(code, remaining, null, coords[0], coords[1], true)); + + // Hover effects + circle.on('mouseover', function() { + this.setStyle({fillOpacity: 0.9, opacity: 1}); + }); + circle.on('mouseout', function() { + this.setStyle({fillOpacity: brightness * 0.7, opacity: brightness}); + }); + }); + } + + // Initialize when DOM is ready + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); diff --git a/static/mitm.html b/static/mitm.html new file mode 100644 index 0000000..d5e3b6a --- /dev/null +++ b/static/mitm.html @@ -0,0 +1,117 @@ + + + + + MITM Certificate Search + + + + +
+ +
+

MITM Certificate Search

+
+ ← Dashboard + +
+
+ + +
+
+
Total Detections
+
-
+
+
+
Unique Certificates
+
-
+
+
+
Unique Organizations
+
-
+
+
+
Affected Proxies
+
-
+
+
+ + + + + +
+
+
Search Syntax Help
+ +
+
+
+
Field Filters
+
+
org:Cloudflare organization name
+
issuer:DigiCert certificate issuer
+
cn:*.example.com common name
+
proxy:192.168.1 proxy IP address
+
fp:a1b2c3 fingerprint prefix
+
serial:12345 serial number
+
+
+
+
Date Filters
+
+
expires:2024 expiration year
+
expired:yes show expired certs
+
+
+
+
General Search
+
+
cloudflare search all fields
+
"security proxy" exact phrase
+
+
+
+
+ + +
+
+
🔒
+
Start typing to search MITM certificates
+
Use field filters like org: or proxy: for precise results
+
+ + +
+ + + +
+ + + + diff --git a/static/mitm.js b/static/mitm.js new file mode 100644 index 0000000..5653611 --- /dev/null +++ b/static/mitm.js @@ -0,0 +1,703 @@ +/** + * MITM Certificate Search Interface + * Provides search functionality for SSL MITM certificate data + */ +(function() { + 'use strict'; + + // Theme toggle (shared with dashboard) + var themes = ['dark', 'muted-dark', 'light']; + function getTheme() { + if (document.documentElement.classList.contains('light')) return 'light'; + if (document.documentElement.classList.contains('muted-dark')) return 'muted-dark'; + return 'dark'; + } + function setTheme(theme) { + document.documentElement.classList.remove('light', 'muted-dark'); + if (theme === 'light') document.documentElement.classList.add('light'); + else if (theme === 'muted-dark') document.documentElement.classList.add('muted-dark'); + try { localStorage.setItem('ppf-theme', theme); } catch(e) {} + } + function initTheme() { + var saved = null; + try { saved = localStorage.getItem('ppf-theme'); } catch(e) {} + if (saved && themes.indexOf(saved) !== -1) { + setTheme(saved); + } else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) { + setTheme('light'); + } + var btn = document.getElementById('themeToggle'); + if (btn) { + btn.addEventListener('click', function() { + var current = getTheme(); + var idx = themes.indexOf(current); + var next = themes[(idx + 1) % themes.length]; + setTheme(next); + }); + } + } + document.addEventListener('DOMContentLoaded', initTheme); + + // DOM elements + var searchInput = document.getElementById('searchInput'); + var searchClear = document.getElementById('searchClear'); + var suggestions = document.getElementById('suggestions'); + var resultsContainer = document.getElementById('resultsContainer'); + var resultsEmpty = document.getElementById('resultsEmpty'); + var resultsLoading = document.getElementById('resultsLoading'); + var resultsList = document.getElementById('resultsList'); + var resultsContent = document.getElementById('resultsContent'); + var resultsCount = document.getElementById('resultsCount'); + var noDataState = document.getElementById('noDataState'); + + // Stats elements + var totalDetections = document.getElementById('totalDetections'); + var uniqueCerts = document.getElementById('uniqueCerts'); + var uniqueOrgs = document.getElementById('uniqueOrgs'); + var uniqueProxies = document.getElementById('uniqueProxies'); + + // State + var searchTimeout = null; + var currentData = null; + var suggestionIndex = -1; + + // Search field definitions for autocomplete + var searchFields = [ + { prefix: 'org:', desc: 'organization name', icon: '🏢' }, + { prefix: 'issuer:', desc: 'certificate issuer', icon: '📄' }, + { prefix: 'cn:', desc: 'common name', icon: '🔗' }, + { prefix: 'proxy:', desc: 'proxy IP address', icon: '🖥' }, + { prefix: 'fp:', desc: 'fingerprint', icon: '🔑' }, + { prefix: 'serial:', desc: 'serial number', icon: '🔢' }, + { prefix: 'expires:', desc: 'expiration year', icon: '📅' }, + { prefix: 'expired:', desc: 'yes/no', icon: '⚠' } + ]; + + /** + * Escape HTML to prevent XSS + */ + function escapeHtml(str) { + if (str === null || str === undefined) return ''; + var div = document.createElement('div'); + div.textContent = String(str); + return div.innerHTML; + } + + /** + * Sanitize search query - remove potentially dangerous characters + */ + function sanitizeQuery(query) { + if (!query) return ''; + // Allow alphanumeric, spaces, common punctuation for searches + // Remove control characters and dangerous patterns + return String(query) + .replace(/[\x00-\x1f\x7f]/g, '') // Control characters + .replace(/<[^>]*>/g, '') // HTML tags + .trim() + .substring(0, 200); // Limit length + } + + /** + * Format number with comma separators + */ + function formatNumber(n) { + if (n === null || n === undefined || n === '-') return '-'; + return String(n).replace(/\B(?=(\d{3})+(?!\d))/g, ','); + } + + /** + * Format timestamp to readable date + */ + function formatDate(ts) { + if (!ts) return '-'; + // Handle ASN.1 time format (YYYYMMDDhhmmssZ) + if (typeof ts === 'string' && ts.length >= 14) { + var y = ts.substring(0, 4); + var m = ts.substring(4, 6); + var d = ts.substring(6, 8); + return y + '-' + m + '-' + d; + } + // Handle Unix timestamp + if (typeof ts === 'number') { + var date = new Date(ts * 1000); + return date.toISOString().split('T')[0]; + } + return String(ts); + } + + /** + * Check if certificate is expired + */ + function isExpired(notAfter) { + if (!notAfter || notAfter.length < 14) return false; + var expDate = new Date( + parseInt(notAfter.substring(0, 4)), + parseInt(notAfter.substring(4, 6)) - 1, + parseInt(notAfter.substring(6, 8)) + ); + return expDate < new Date(); + } + + /** + * Load initial stats + */ + function loadStats() { + fetch('/api/mitm') + .then(function(r) { return r.json(); }) + .then(function(data) { + currentData = data; + + // Update summary stats + totalDetections.textContent = formatNumber(data.total_detections || 0); + uniqueCerts.textContent = formatNumber(data.unique_certs || 0); + uniqueProxies.textContent = formatNumber(data.unique_proxies || 0); + + // Count unique orgs from top_organizations + var orgCount = (data.top_organizations || []).length; + uniqueOrgs.textContent = formatNumber(orgCount); + + // Show no data state if empty + if (!data.certificates || data.certificates.length === 0) { + document.getElementById('statsSummary').style.display = 'none'; + document.querySelector('.search-box').style.display = 'none'; + document.getElementById('helpBox').style.display = 'none'; + resultsContainer.style.display = 'none'; + noDataState.style.display = 'block'; + } + }) + .catch(function(err) { + console.error('Failed to load MITM stats:', err); + }); + } + + /** + * Parse search query into structured filters + */ + function parseQuery(query) { + var filters = { + org: null, + issuer: null, + cn: null, + proxy: null, + fp: null, + serial: null, + expires: null, + expired: null, + text: [] + }; + + if (!query) return filters; + + // Match field:value patterns and quoted strings + var parts = query.match(/(\w+:"[^"]+"|"[^"]+"|[\w:.]+)/g) || []; + + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + var colonIdx = part.indexOf(':'); + + if (colonIdx > 0 && colonIdx < part.length - 1) { + var field = part.substring(0, colonIdx).toLowerCase(); + var value = part.substring(colonIdx + 1).replace(/^"|"$/g, ''); + + if (filters.hasOwnProperty(field)) { + filters[field] = value; + } else { + filters.text.push(part); + } + } else { + // Plain text search + filters.text.push(part.replace(/^"|"$/g, '')); + } + } + + return filters; + } + + /** + * Check if certificate matches filters + */ + function matchesCert(cert, filters) { + // Organization filter + if (filters.org) { + var org = (cert.subject_o || '').toLowerCase(); + if (org.indexOf(filters.org.toLowerCase()) === -1) return false; + } + + // Issuer filter + if (filters.issuer) { + var issuer = (cert.issuer_cn || cert.issuer_o || '').toLowerCase(); + if (issuer.indexOf(filters.issuer.toLowerCase()) === -1) return false; + } + + // Common name filter + if (filters.cn) { + var cn = (cert.subject_cn || '').toLowerCase(); + if (cn.indexOf(filters.cn.toLowerCase()) === -1) return false; + } + + // Proxy filter + if (filters.proxy) { + var proxies = cert.proxies || []; + var found = false; + for (var i = 0; i < proxies.length; i++) { + if (proxies[i].indexOf(filters.proxy) !== -1) { + found = true; + break; + } + } + if (!found) return false; + } + + // Fingerprint filter + if (filters.fp) { + var fp = (cert.fingerprint || cert.fingerprint_full || '').toLowerCase(); + if (fp.indexOf(filters.fp.toLowerCase()) === -1) return false; + } + + // Serial filter + if (filters.serial) { + var serial = (cert.serial || '').toLowerCase(); + if (serial.indexOf(filters.serial.toLowerCase()) === -1) return false; + } + + // Expiration year filter + if (filters.expires) { + var notAfter = cert.not_after || ''; + if (notAfter.indexOf(filters.expires) === -1) return false; + } + + // Expired filter + if (filters.expired) { + var wantExpired = filters.expired.toLowerCase() === 'yes'; + var certExpired = isExpired(cert.not_after); + if (wantExpired !== certExpired) return false; + } + + // Text search (searches all fields) + if (filters.text.length > 0) { + var searchable = [ + cert.subject_cn || '', + cert.subject_o || '', + cert.issuer_cn || '', + cert.issuer_o || '', + cert.fingerprint || '', + cert.serial || '' + ].join(' ').toLowerCase(); + + for (var j = 0; j < filters.text.length; j++) { + if (searchable.indexOf(filters.text[j].toLowerCase()) === -1) { + return false; + } + } + } + + return true; + } + + /** + * Perform search on current data + */ + function performSearch(query) { + query = sanitizeQuery(query); + + if (!query) { + showEmpty(); + return; + } + + if (!currentData || !currentData.certificates) { + showEmpty(); + return; + } + + showLoading(); + + // Use setTimeout to not block UI + setTimeout(function() { + var filters = parseQuery(query); + var results = []; + + var certs = currentData.certificates || []; + for (var i = 0; i < certs.length; i++) { + if (matchesCert(certs[i], filters)) { + results.push(certs[i]); + } + } + + showResults(results, query); + }, 50); + } + + /** + * Show empty state + */ + function showEmpty() { + resultsEmpty.style.display = 'block'; + resultsLoading.style.display = 'none'; + resultsList.style.display = 'none'; + } + + /** + * Show loading state + */ + function showLoading() { + resultsEmpty.style.display = 'none'; + resultsLoading.style.display = 'block'; + resultsList.style.display = 'none'; + } + + /** + * Render search results + */ + function showResults(results, query) { + resultsEmpty.style.display = 'none'; + resultsLoading.style.display = 'none'; + resultsList.style.display = 'block'; + + resultsCount.textContent = formatNumber(results.length); + + if (results.length === 0) { + resultsContent.innerHTML = + '
' + + '
🔍
' + + '
No certificates match your search
' + + '
Try adjusting your filters or search terms
' + + '
'; + return; + } + + var html = ''; + for (var i = 0; i < results.length; i++) { + html += renderCertCard(results[i]); + } + resultsContent.innerHTML = html; + } + + /** + * Render a single certificate card + */ + function renderCertCard(cert) { + var expired = isExpired(cert.not_after); + var proxies = cert.proxies || []; + + var html = '
'; + html += '
'; + html += '
'; + html += 'Certificate'; + html += escapeHtml(cert.subject_cn || cert.subject_o || 'Unknown'); + html += '
'; + html += '
'; + if (expired) { + html += 'Expired · '; + } + html += 'Seen ' + escapeHtml(String(cert.count || 1)) + ' time(s)'; + html += '
'; + html += '
'; + + html += '
'; + + // Subject + html += '
'; + html += '
Subject (CN)
'; + html += '
' + escapeHtml(cert.subject_cn || '-') + '
'; + html += '
'; + + // Organization + html += '
'; + html += '
Organization
'; + html += '
' + escapeHtml(cert.subject_o || '-') + '
'; + html += '
'; + + // Issuer + html += '
'; + html += '
Issuer (CN)
'; + html += '
' + escapeHtml(cert.issuer_cn || '-') + '
'; + html += '
'; + + // Issuer Org + html += '
'; + html += '
Issuer Org
'; + html += '
' + escapeHtml(cert.issuer_o || '-') + '
'; + html += '
'; + + // Fingerprint + html += '
'; + html += '
Fingerprint
'; + html += '
' + escapeHtml(cert.fingerprint || cert.fingerprint_full || '-') + '
'; + html += '
'; + + // Serial + html += '
'; + html += '
Serial
'; + html += '
' + escapeHtml(cert.serial || '-') + '
'; + html += '
'; + + // Valid From + html += '
'; + html += '
Valid From
'; + html += '
' + escapeHtml(formatDate(cert.not_before)) + '
'; + html += '
'; + + // Valid Until + html += '
'; + html += '
Valid Until
'; + html += '
' + escapeHtml(formatDate(cert.not_after)) + '
'; + html += '
'; + + html += '
'; + + // Proxies list + if (proxies.length > 0) { + html += '
'; + html += '
Proxies using this certificate (' + proxies.length + ')
'; + html += '
'; + for (var i = 0; i < Math.min(proxies.length, 10); i++) { + html += '' + escapeHtml(proxies[i]) + ''; + } + if (proxies.length > 10) { + html += '+' + (proxies.length - 10) + ' more'; + } + html += '
'; + html += '
'; + } + + html += '
'; + return html; + } + + /** + * Show autocomplete suggestions + */ + function showSuggestions(query) { + query = sanitizeQuery(query); + + if (!query) { + hideSuggestions(); + return; + } + + var html = ''; + + // Check if user is typing a field prefix + var lastWord = query.split(/\s+/).pop() || ''; + var colonIdx = lastWord.indexOf(':'); + + if (colonIdx === -1) { + // Show matching field suggestions + var matchingFields = []; + for (var i = 0; i < searchFields.length; i++) { + if (searchFields[i].prefix.toLowerCase().indexOf(lastWord.toLowerCase()) === 0) { + matchingFields.push(searchFields[i]); + } + } + + if (matchingFields.length > 0) { + html += '
'; + html += '
Field Filters
'; + for (var j = 0; j < matchingFields.length; j++) { + var field = matchingFields[j]; + html += '
'; + html += '' + field.icon + ''; + html += '' + escapeHtml(field.prefix) + ''; + html += '' + escapeHtml(field.desc) + ''; + html += '
'; + } + html += '
'; + } + } + + // Add quick value suggestions from data + if (currentData && colonIdx > 0) { + var fieldName = lastWord.substring(0, colonIdx); + var valuePart = lastWord.substring(colonIdx + 1).toLowerCase(); + + var valueSuggestions = getValueSuggestions(fieldName, valuePart); + if (valueSuggestions.length > 0) { + html += '
'; + html += '
Matching Values
'; + for (var k = 0; k < Math.min(valueSuggestions.length, 5); k++) { + var val = valueSuggestions[k]; + html += '
'; + html += ''; + html += '' + escapeHtml(val) + ''; + html += '
'; + } + html += '
'; + } + } + + if (html) { + suggestions.innerHTML = html; + suggestions.classList.add('visible'); + suggestionIndex = -1; + } else { + hideSuggestions(); + } + } + + /** + * Get value suggestions for a field + */ + function getValueSuggestions(field, partial) { + if (!currentData) return []; + + var values = []; + field = field.toLowerCase(); + + if (field === 'org') { + var orgs = currentData.top_organizations || []; + for (var i = 0; i < orgs.length; i++) { + var orgName = orgs[i].name || ''; + if (partial === '' || orgName.toLowerCase().indexOf(partial) !== -1) { + values.push(orgName); + } + } + } else if (field === 'issuer') { + var issuers = currentData.top_issuers || []; + for (var j = 0; j < issuers.length; j++) { + var issuerName = issuers[j].name || ''; + if (partial === '' || issuerName.toLowerCase().indexOf(partial) !== -1) { + values.push(issuerName); + } + } + } else if (field === 'expired') { + values = ['yes', 'no']; + } + + return values; + } + + /** + * Hide suggestions dropdown + */ + function hideSuggestions() { + suggestions.classList.remove('visible'); + suggestionIndex = -1; + } + + /** + * Apply suggestion to search input + */ + function applySuggestion(value) { + var query = searchInput.value; + var parts = query.split(/\s+/); + parts[parts.length - 1] = value; + searchInput.value = parts.join(' '); + searchInput.focus(); + hideSuggestions(); + + // Trigger search if value is complete + if (value.indexOf(':') !== -1) { + handleSearch(); + } + } + + /** + * Handle search input + */ + function handleSearch() { + var query = searchInput.value; + + // Show/hide clear button + if (query) { + searchClear.classList.add('visible'); + } else { + searchClear.classList.remove('visible'); + } + + // Debounce search + if (searchTimeout) { + clearTimeout(searchTimeout); + } + + searchTimeout = setTimeout(function() { + performSearch(query); + }, 200); + + // Show suggestions immediately + showSuggestions(query); + } + + /** + * Clear search + */ + function clearSearch() { + searchInput.value = ''; + searchClear.classList.remove('visible'); + hideSuggestions(); + showEmpty(); + searchInput.focus(); + } + + /** + * Toggle help box + */ + window.toggleHelp = function() { + var helpBox = document.getElementById('helpBox'); + helpBox.classList.toggle('collapsed'); + }; + + /** + * Keyboard navigation for suggestions + */ + function handleKeydown(e) { + var items = suggestions.querySelectorAll('.suggestion-item'); + if (!items.length) return; + + if (e.key === 'ArrowDown') { + e.preventDefault(); + suggestionIndex = Math.min(suggestionIndex + 1, items.length - 1); + updateSuggestionHighlight(items); + } else if (e.key === 'ArrowUp') { + e.preventDefault(); + suggestionIndex = Math.max(suggestionIndex - 1, 0); + updateSuggestionHighlight(items); + } else if (e.key === 'Enter' && suggestionIndex >= 0) { + e.preventDefault(); + var value = items[suggestionIndex].getAttribute('data-value'); + if (value) applySuggestion(value); + } else if (e.key === 'Escape') { + hideSuggestions(); + } + } + + /** + * Update suggestion highlight + */ + function updateSuggestionHighlight(items) { + for (var i = 0; i < items.length; i++) { + if (i === suggestionIndex) { + items[i].classList.add('active'); + } else { + items[i].classList.remove('active'); + } + } + } + + // Event listeners + searchInput.addEventListener('input', handleSearch); + searchInput.addEventListener('keydown', handleKeydown); + searchInput.addEventListener('focus', function() { + if (searchInput.value) showSuggestions(searchInput.value); + }); + searchClear.addEventListener('click', clearSearch); + + // Click on suggestion + suggestions.addEventListener('click', function(e) { + var item = e.target.closest('.suggestion-item'); + if (item) { + var value = item.getAttribute('data-value'); + if (value) applySuggestion(value); + } + }); + + // Click outside to hide suggestions + document.addEventListener('click', function(e) { + if (!e.target.closest('.search-box')) { + hideSuggestions(); + } + }); + + // Initialize + loadStats(); +})(); diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..d557eff --- /dev/null +++ b/static/style.css @@ -0,0 +1,815 @@ +/* PPF Dashboard Styles - Electric Cyan Theme */ +/* Theme variables are substituted at runtime by httpd.py */ + +:root { + --bg: {bg}; --card: {card}; --card-alt: {card_alt}; --border: {border}; + --text: {text}; --dim: {dim}; --green: {green}; --red: {red}; + --yellow: {yellow}; --blue: {blue}; --purple: {purple}; + --cyan: {cyan}; --orange: {orange}; --pink: {pink}; --map-bg: {map_bg}; + --shadow-sm: 0 1px 2px rgba(0,0,0,0.2); + --shadow-md: 0 4px 12px rgba(0,0,0,0.25); + --shadow-lg: 0 8px 24px rgba(0,0,0,0.3); + --glow-green: 0 0 12px rgba(63,185,80,0.4); + --glow-blue: 0 0 12px rgba(88,166,255,0.4); + --glow-red: 0 0 12px rgba(248,81,73,0.4); + --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1); +} + +/* Muted dark theme - desaturated/softer dark colors */ +html.muted-dark { + --bg: #1a1c20; + --card: #22252a; + --card-alt: #282c32; + --border: #3a3f47; + --text: #c8ccd4; + --dim: #7a7f88; + --green: #5a9a66; + --red: #c06060; + --yellow: #b39540; + --blue: #6090b8; + --purple: #8a6aa8; + --cyan: #5a9098; + --orange: #b87850; + --pink: #a86080; + --map-bg: #1a1c20; + --shadow-sm: 0 1px 2px rgba(0,0,0,0.25); + --shadow-md: 0 4px 12px rgba(0,0,0,0.3); + --shadow-lg: 0 8px 24px rgba(0,0,0,0.35); + --glow-green: 0 0 10px rgba(90,154,102,0.3); + --glow-blue: 0 0 10px rgba(96,144,184,0.3); + --glow-red: 0 0 10px rgba(192,96,96,0.3); +} + +/* Light theme - muted/broken colors (not pure white) */ +html.light { + --bg: #e8e4df; + --card: #f5f2ed; + --card-alt: #ebe7e2; + --border: #c5c0b8; + --text: #2c2a26; + --dim: #6b6860; + --green: #2a7d3f; + --red: #c53030; + --yellow: #a67c00; + --blue: #2563a8; + --purple: #7c3aad; + --cyan: #1a7a7f; + --orange: #c05621; + --pink: #b5366b; + --map-bg: #e8e4df; + --shadow-sm: 0 1px 3px rgba(0,0,0,0.08); + --shadow-md: 0 4px 12px rgba(0,0,0,0.1); + --shadow-lg: 0 8px 24px rgba(0,0,0,0.12); + --glow-green: 0 0 8px rgba(42,125,63,0.25); + --glow-blue: 0 0 8px rgba(37,99,168,0.25); + --glow-red: 0 0 8px rgba(197,48,48,0.25); +} +* { box-sizing: border-box; margin: 0; padding: 0; } +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; + font-size: 13px; background: var(--bg); color: var(--text); + padding: 16px; min-height: 100vh; line-height: 1.5; + -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; +} +a { color: var(--blue); text-decoration: none; transition: color var(--transition); } +a:hover { color: var(--cyan); } +h1 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 16px; } +h2 { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; } +h3 { font-size: 13px; font-weight: 600; color: var(--dim); margin-bottom: 8px; } +.container { max-width: 1400px; margin: 0 auto; } + +/* Header */ +.hdr { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); } +.hdr h1 { font-size: 18px; font-weight: 600; display: flex; align-items: center; gap: 10px; } +.hdr h1::before { content: ""; width: 10px; height: 10px; background: var(--green); border-radius: 50%; box-shadow: 0 0 8px var(--green); } +.status { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--dim); } +.status-item { display: flex; align-items: center; gap: 4px; } +.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; } +.dot.err { background: var(--red); animation: none; } +@keyframes pulse { 50% { opacity: 0.5; } } +.mode-badge { padding: 4px 10px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; } +.mode-ssl { background: rgba(63,185,80,0.2); color: var(--green); border: 1px solid var(--green); } +.mode-profile { background: rgba(255,165,0,0.2); color: #ffa500; border: 1px solid #ffa500; margin-left: 6px; } +.mode-judges { background: rgba(88,166,255,0.2); color: var(--blue); border: 1px solid var(--blue); } +.mode-head { background: rgba(210,153,34,0.2); color: var(--yellow); border: 1px solid var(--yellow); } +.mode-irc { background: rgba(163,113,247,0.2); color: var(--purple); border: 1px solid var(--purple); } + +/* System monitor bar */ +.sysbar { display: flex; gap: 16px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; font-size: 11px; } +.sysbar-item { display: flex; align-items: center; gap: 6px; } +.sysbar-lbl { color: var(--dim); } +.sysbar-val { font-weight: 600; font-feature-settings: "tnum"; } +.sysbar-bar { width: 50px; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; } +.sysbar-fill { height: 100%; border-radius: 2px; transition: width 0.3s; } +.sysbar-net .net-tx::before { content: '↑'; opacity: 0.5; margin-right: 1px; } +.sysbar-net .net-rx::before { content: '↓'; opacity: 0.5; margin-right: 1px; } +.sysbar-net .sysbar-val { min-width: 42px; } + +/* Grid */ +.g { display: grid; gap: 12px; margin-bottom: 16px; } +.g2 { grid-template-columns: repeat(2, 1fr); } +.g3 { grid-template-columns: repeat(3, 1fr); } +.g4 { grid-template-columns: repeat(4, 1fr); } +.g5 { grid-template-columns: repeat(5, 1fr); } +.g6 { grid-template-columns: repeat(6, 1fr); } +@media (max-width: 1200px) { .g5, .g6 { grid-template-columns: repeat(4, 1fr); } } +@media (max-width: 900px) { .g3, .g4, .g5, .g6 { grid-template-columns: repeat(2, 1fr); } } +@media (max-width: 600px) { .g2, .g3, .g4, .g5, .g6 { grid-template-columns: 1fr; } } + +/* Cards */ +.c { + background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px; + box-shadow: var(--shadow-sm); transition: transform var(--transition), box-shadow var(--transition); +} +.c:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); } +.c-lg { padding: 16px 18px; } +.c-sm { padding: 10px 12px; } +.c-glow { box-shadow: var(--shadow-md), var(--glow-blue); } +.lbl { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; font-weight: 500; } +.val { font-size: 26px; font-weight: 700; font-feature-settings: "tnum"; letter-spacing: -0.5px; line-height: 1.2; } +.val-md { font-size: 20px; font-weight: 600; } +.val-sm { font-size: 16px; font-weight: 600; } +.sub { font-size: 11px; color: var(--dim); margin-top: 4px; } +.grn { color: var(--green); } .red { color: var(--red); } .yel { color: var(--yellow); } +.blu { color: var(--blue); } .pur { color: var(--purple); } .cyn { color: var(--cyan); } +.org { color: var(--orange); } .pnk { color: var(--pink); } + +/* Section headers */ +.sec { margin-bottom: 16px; } +.sec-hdr { font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; } +.sec-hdr::before { content: ""; width: 3px; height: 12px; background: var(--blue); border-radius: 2px; } + +/* Progress bars */ +.bar-wrap { height: 6px; background: var(--border); border-radius: 3px; margin-top: 8px; overflow: hidden; position: relative; } +.bar { height: 100%; border-radius: 3px; transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1); position: relative; } +.bar::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); } +.bar.grn { background: linear-gradient(90deg, #238636, #3fb950); box-shadow: 0 0 8px rgba(63,185,80,0.3); } +.bar.red { background: linear-gradient(90deg, #da3633, #f85149); box-shadow: 0 0 8px rgba(248,81,73,0.3); } +.bar.yel { background: linear-gradient(90deg, #9e6a03, #d29922); box-shadow: 0 0 8px rgba(210,153,34,0.3); } +.bar.blu { background: linear-gradient(90deg, #1f6feb, #58a6ff); box-shadow: 0 0 8px rgba(88,166,255,0.3); } + +/* Charts */ +.chart-wrap { + background: linear-gradient(145deg, rgba(24,31,42,0.65), rgba(18,24,34,0.75)); + border: 1px solid rgba(56,189,248,0.35); border-radius: 10px; padding: 12px 14px; margin-top: 8px; + box-shadow: 0 0 28px rgba(56,189,248,0.12), 0 0 1px rgba(56,189,248,0.4), var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.08); + position: relative; overflow: hidden; backdrop-filter: blur(8px); +} +.chart-wrap::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.06) 0%, transparent 40%); + pointer-events: none; +} +.chart { width: 100%; height: 80px; position: relative; } +.chart-lg { height: 120px; } +.chart svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); } +.chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 4px currentColor); } +.chart-area { opacity: 0.25; } +.chart-grid { stroke: var(--border); stroke-width: 0.5; stroke-dasharray: 2 4; } +.chart-label { font-size: 9px; fill: var(--dim); } + +/* Histogram bars */ +.histo-wrap { + background: linear-gradient(145deg, rgba(24,31,42,0.65), rgba(18,24,34,0.75)); + border: 1px solid rgba(56,189,248,0.35); border-radius: 10px; padding: 14px 16px 26px; + box-shadow: 0 0 28px rgba(56,189,248,0.12), 0 0 1px rgba(56,189,248,0.4), var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.08); + position: relative; overflow: hidden; backdrop-filter: blur(8px); +} +.histo-wrap::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.06) 0%, transparent 40%); + pointer-events: none; +} +.histo { display: flex; align-items: flex-end; gap: 3px; height: 70px; padding: 0 2px; position: relative; z-index: 1; } +.histo-bar { + flex: 1; border-radius: 4px 4px 0 0; min-height: 3px; position: relative; + transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); + background: linear-gradient(180deg, var(--cyan), rgba(88,166,255,0.6)); + box-shadow: 0 0 10px rgba(56,189,248,0.4), inset 0 1px 0 rgba(255,255,255,0.15); +} +.histo-bar:hover { transform: scaleY(1.1) translateY(-1px); filter: brightness(1.35); box-shadow: 0 0 16px rgba(56,189,248,0.6); } +.histo-bar::after { content: attr(data-label); position: absolute; bottom: -16px; left: 50%; transform: translateX(-50%); font-size: 8px; color: var(--dim); white-space: nowrap; opacity: 0.8; } +.histo-labels { display: flex; justify-content: space-between; margin-top: 20px; font-size: 9px; color: var(--dim); position: relative; z-index: 1; } + +/* Stat rows */ +.stats-wrap { + background: linear-gradient(145deg, rgba(24,31,42,0.7), rgba(18,24,34,0.8)); + border: 1px solid rgba(56,189,248,0.28); border-radius: 10px; padding: 14px 16px; + box-shadow: 0 0 24px rgba(56,189,248,0.1), 0 0 1px rgba(56,189,248,0.35), var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.06); + position: relative; overflow: hidden; backdrop-filter: blur(6px); +} +.stats-wrap::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.05) 0%, transparent 45%); + pointer-events: none; +} +.stat-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; font-size: 12px; } +.stat-row + .stat-row { border-top: 1px solid rgba(58,68,80,0.4); } +.stat-lbl { color: var(--dim); display: flex; align-items: center; gap: 6px; } +.stat-val { font-weight: 600; font-feature-settings: "tnum"; } +.stat-bar { width: 60px; height: 4px; background: var(--border); border-radius: 2px; margin-left: 8px; overflow: hidden; } +.stat-bar-fill { height: 100%; border-radius: 2px; } + +/* Leaderboard */ +.lb-wrap { + background: linear-gradient(145deg, rgba(24,31,42,0.7), rgba(18,24,34,0.8)); + border: 1px solid rgba(56,189,248,0.28); border-radius: 10px; padding: 14px 16px; + box-shadow: 0 0 24px rgba(56,189,248,0.1), 0 0 1px rgba(56,189,248,0.35), var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.06); + position: relative; overflow: hidden; backdrop-filter: blur(6px); +} +.lb-wrap::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.05) 0%, transparent 45%); + pointer-events: none; +} +.lb { font-size: 12px; } +.lb-item { display: flex; align-items: center; gap: 8px; padding: 5px 0; } +.lb-item + .lb-item { border-top: 1px solid rgba(58,68,80,0.3); } +.lb-rank { width: 18px; height: 18px; border-radius: 4px; background: var(--card-alt); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; color: var(--dim); } +.lb-rank.top { background: var(--yellow); color: var(--bg); } +.lb-name { flex: 1; font-family: ui-monospace, monospace; color: var(--text); } +.lb-val { font-weight: 600; font-feature-settings: "tnum"; } + +/* Tags */ +.tag { + display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; + border-radius: 4px; font-size: 10px; font-weight: 600; + transition: all var(--transition); backdrop-filter: blur(4px); +} +.tag-ok { background: rgba(63,185,80,0.15); color: var(--green); border: 1px solid rgba(63,185,80,0.3); } +.tag-ok:hover { background: rgba(63,185,80,0.25); box-shadow: 0 0 8px rgba(63,185,80,0.2); } +.tag-err { background: rgba(248,81,73,0.15); color: var(--red); border: 1px solid rgba(248,81,73,0.3); } +.tag-err:hover { background: rgba(248,81,73,0.25); box-shadow: 0 0 8px rgba(248,81,73,0.2); } +.tag-warn { background: rgba(210,153,34,0.15); color: var(--yellow); border: 1px solid rgba(210,153,34,0.3); } +.tag-warn:hover { background: rgba(210,153,34,0.25); box-shadow: 0 0 8px rgba(210,153,34,0.2); } +.tag-info { background: rgba(88,166,255,0.15); color: var(--blue); border: 1px solid rgba(88,166,255,0.3); } +.tag-info:hover { background: rgba(88,166,255,0.25); box-shadow: 0 0 8px rgba(88,166,255,0.2); } + +/* Mini stats */ +.mini { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; } +.mini-item { display: flex; flex-direction: column; align-items: center; gap: 2px; } +.mini-val { font-size: 14px; font-weight: 600; font-feature-settings: "tnum"; } +.mini-lbl { font-size: 10px; color: var(--dim); } + +/* Proto cards */ +.proto-card { text-align: center; transition: transform var(--transition); } +.proto-card:hover { transform: translateY(-2px); } +.proto-icon { font-size: 24px; margin-bottom: 6px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); } +.proto-name { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; } +.proto-val { font-size: 20px; font-weight: 700; margin: 6px 0; } +.proto-rate { font-size: 11px; padding: 3px 8px; border-radius: 4px; display: inline-block; } + +/* Pie charts */ +.pie-wrap { + display: flex; gap: 20px; align-items: center; + background: linear-gradient(145deg, rgba(24,31,42,0.65), rgba(18,24,34,0.75)); + border: 1px solid rgba(56,189,248,0.35); border-radius: 10px; padding: 16px; + box-shadow: 0 0 28px rgba(56,189,248,0.12), 0 0 1px rgba(56,189,248,0.4), var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.08); + position: relative; overflow: hidden; backdrop-filter: blur(8px); +} +.pie-wrap::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.06) 0%, transparent 40%); + pointer-events: none; +} +.pie { + width: 100px; height: 100px; border-radius: 50%; flex-shrink: 0; + box-shadow: var(--shadow-md), inset 0 0 20px rgba(0,0,0,0.3); + position: relative; transition: transform var(--transition); +} +.pie:hover { transform: scale(1.02); } +.legend { flex: 1; } +.legend-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; transition: opacity var(--transition); } +.legend-item:hover { opacity: 0.8; } +.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; box-shadow: 0 0 4px currentColor; } +.legend-name { flex: 1; color: var(--dim); } +.legend-val { font-weight: 600; font-feature-settings: "tnum"; } + +/* Tor/Host cards */ +.tor-card { + background: linear-gradient(145deg, rgba(24,31,42,0.7), rgba(18,24,34,0.8)); + border: 1px solid rgba(56,189,248,0.28); border-radius: 10px; padding: 12px 14px; + box-shadow: 0 0 24px rgba(56,189,248,0.1), 0 0 1px rgba(56,189,248,0.35), var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.06); + position: relative; overflow: hidden; transition: all 0.2s ease; backdrop-filter: blur(6px); +} +.tor-card::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.05) 0%, transparent 45%); + pointer-events: none; +} +.tor-card:hover { transform: translateY(-2px); box-shadow: 0 0 36px rgba(56,189,248,0.15), 0 0 2px rgba(56,189,248,0.5), var(--shadow-lg); } +.host-card { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; } +.host-addr { font-family: ui-monospace, monospace; font-size: 12px; font-weight: 500; } +.host-stats { font-size: 11px; color: var(--dim); margin-top: 6px; position: relative; z-index: 1; } + +.judge-item { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 11px; } +.judge-item + .judge-item { border-top: 1px solid rgba(58,68,80,0.3); } +.judge-name { font-family: ui-monospace, monospace; color: var(--dim); flex: 1; } +.judge-stats { display: flex; gap: 12px; } + +/* Percentile badges */ +.pct-badges { + display: flex; gap: 8px; margin-top: 10px; + background: linear-gradient(135deg, rgba(28,35,45,0.85), rgba(18,25,33,0.95)); + border: 1px solid var(--border); border-radius: 8px; padding: 10px; + box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.04); +} +.pct-badge { + flex: 1; text-align: center; padding: 8px 6px; + background: linear-gradient(180deg, rgba(36,44,56,0.6), rgba(28,35,45,0.8)); + border: 1px solid rgba(58,68,80,0.5); border-radius: 6px; + transition: all var(--transition); +} +.pct-badge:hover { background: linear-gradient(180deg, rgba(42,52,64,0.7), rgba(32,40,50,0.9)); transform: translateY(-1px); } +.pct-label { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.3px; } +.pct-value { font-size: 16px; font-weight: 700; margin-top: 3px; } + +/* Map page */ +.nav { margin-bottom: 16px; font-size: 12px; } +.map-stats { margin-bottom: 16px; color: var(--dim); font-size: 12px; padding: 8px 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; } +.country-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; } +.country { padding: 12px 8px; border-radius: 6px; text-align: center; background: var(--card); border: 1px solid var(--border); transition: transform 0.15s, box-shadow 0.15s; } +.country:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); } +.country .code { font-weight: bold; font-size: 1.1em; letter-spacing: 0.5px; } +.country .count { font-size: 0.85em; color: var(--dim); margin-top: 4px; font-feature-settings: "tnum"; } +.country.t1 { background: #0d4429; border-color: #238636; } +.country.t1 .code { color: #7ee787; } +.country.t2 { background: #1a3d2e; border-color: #2ea043; } +.country.t2 .code { color: #7ee787; } +.country.t3 { background: #1f3d2a; border-color: #3fb950; } +.country.t3 .code { color: #56d364; } +.country.t4 { background: #2a4a35; border-color: #56d364; } +.country.t4 .code { color: #3fb950; } +.country.t5 { background: #35573f; border-color: #7ee787; } +.country.t5 .code { color: #3fb950; } +.map-legend { display: flex; gap: 16px; margin-top: 20px; flex-wrap: wrap; padding: 12px; background: var(--card); border: 1px solid var(--border); border-radius: 6px; } +.map-legend .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--dim); } +.map-legend .legend-dot { width: 12px; height: 12px; border-radius: 3px; } + +/* Footer */ +.ftr { text-align: center; font-size: 11px; color: var(--dim); padding: 16px 0; margin-top: 8px; border-top: 1px solid var(--border); } + +/* Tabs */ +.tabs { margin-bottom: 16px; } +.tab-nav { + display: flex; gap: 4px; padding: 4px; background: var(--card); + border: 1px solid var(--border); border-radius: 10px; + overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; +} +.tab-nav::-webkit-scrollbar { display: none; } +.tab-btn { + padding: 8px 16px; border: none; background: transparent; color: var(--dim); + font-size: 12px; font-weight: 500; border-radius: 6px; cursor: pointer; + transition: all var(--transition); white-space: nowrap; + font-family: inherit; +} +.tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); } +.tab-btn.active { + background: var(--blue); color: #fff; box-shadow: var(--shadow-sm), var(--glow-blue); +} +.tab-content { display: none; animation: fadeIn 0.3s ease; } +.tab-content.active { display: block; } +@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } } + +/* Responsive tabs */ +@media (max-width: 768px) { + .tab-nav { padding: 3px; gap: 2px; } + .tab-btn { padding: 6px 12px; font-size: 11px; } +} + +/* ========================================================================== + Map Page Styles + ========================================================================== */ + +/* Glass panel effect - reusable */ +.glass { + background: linear-gradient(145deg, rgba(24,31,42,0.65), rgba(18,24,34,0.75)); + backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); + border: 1px solid rgba(56,189,248,0.35); border-radius: 10px; + box-shadow: 0 0 28px rgba(56,189,248,0.12), 0 0 1px rgba(56,189,248,0.4), + var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.08); + position: relative; overflow: hidden; +} +.glass::before { + content: ''; position: absolute; inset: 0; border-radius: 10px; + background: linear-gradient(180deg, rgba(56,189,248,0.06) 0%, transparent 40%); + pointer-events: none; +} + +/* Map container */ +.map-page { padding: 0; overflow: hidden; background: var(--map-bg); } +.map-page #map { width: 100%; height: 100vh; } + +/* Map navigation */ +.map-nav { position: fixed; top: 20px; left: 20px; z-index: 1000; padding: 12px 20px; } +.map-nav a { + color: var(--text); text-decoration: none; font-size: 13px; + font-weight: 500; letter-spacing: 0.3px; transition: color var(--transition); + position: relative; z-index: 1; +} +.map-nav a:hover { color: var(--cyan); } + +/* Map stats panel */ +.map-stats-panel { + position: fixed; top: 20px; right: 20px; z-index: 1000; + padding: 16px 24px; display: flex; gap: 28px; +} +.map-stat { display: flex; flex-direction: column; align-items: flex-end; position: relative; z-index: 1; } +.map-stat-val { + font-size: 26px; font-weight: 600; color: var(--cyan); line-height: 1.1; + font-feature-settings: "tnum"; letter-spacing: -0.5px; + text-shadow: 0 0 20px rgba(56,189,248,0.4); +} +.map-stat-lbl { + font-size: 10px; color: rgba(56,189,248,0.6); text-transform: uppercase; + letter-spacing: 1px; margin-top: 4px; +} + +/* Map legend panel */ +.map-legend-panel { position: fixed; bottom: 24px; left: 20px; z-index: 1000; padding: 16px 20px; } +.map-legend-title { + font-size: 10px; text-transform: uppercase; letter-spacing: 1px; + color: rgba(56,189,248,0.5); margin-bottom: 12px; position: relative; z-index: 1; +} +.map-legend-row { + display: flex; align-items: center; gap: 12px; margin: 8px 0; + font-size: 12px; color: rgba(230,237,243,0.7); position: relative; z-index: 1; +} +.map-legend-dot { width: 12px; height: 12px; border-radius: 50%; } +.map-legend-dot.elite { background: var(--green); box-shadow: 0 0 12px rgba(80,200,120,0.5); } +.map-legend-dot.anonymous { background: var(--cyan); box-shadow: 0 0 12px rgba(56,189,248,0.5); } +.map-legend-dot.transparent { background: var(--orange); box-shadow: 0 0 12px rgba(249,115,22,0.5); } +.map-legend-dot.unknown { background: var(--dim); box-shadow: 0 0 12px rgba(107,114,128,0.5); } + +/* Map footer */ +.map-footer { + position: fixed; bottom: 20px; right: 20px; z-index: 1000; + font-size: 11px; color: rgba(56,189,248,0.4); +} +.map-footer a { color: rgba(56,189,248,0.5); text-decoration: none; transition: color var(--transition); } +.map-footer a:hover { color: var(--cyan); } + +/* Leaflet overrides for map page */ +.map-page .leaflet-container { background: var(--map-bg); font-family: inherit; } +.map-page .leaflet-control-zoom { border: none !important; margin: 20px !important; } +.map-page .leaflet-control-zoom a { + background: linear-gradient(145deg, rgba(24,31,42,0.85), rgba(18,24,34,0.9)) !important; + backdrop-filter: blur(12px); color: rgba(56,189,248,0.8) !important; + border: 1px solid rgba(56,189,248,0.25) !important; + width: 36px; height: 36px; line-height: 36px !important; + font-size: 18px; font-weight: 300; transition: all var(--transition); +} +.map-page .leaflet-control-zoom a:first-child { border-radius: 8px 8px 0 0 !important; } +.map-page .leaflet-control-zoom a:last-child { border-radius: 0 0 8px 8px !important; border-top: none !important; } +.map-page .leaflet-control-zoom a:hover { + background: rgba(56,189,248,0.15) !important; color: var(--cyan) !important; + box-shadow: 0 0 16px rgba(56,189,248,0.3); +} +.map-page .leaflet-control-attribution { + background: transparent !important; color: rgba(56,189,248,0.3) !important; + font-size: 10px; padding: 4px 8px !important; +} +.map-page .leaflet-control-attribution a { color: rgba(56,189,248,0.4) !important; } + +/* Map popups */ +.map-page .leaflet-popup-content-wrapper { + background: linear-gradient(145deg, rgba(24,31,42,0.95), rgba(18,24,34,0.97)); + backdrop-filter: blur(20px); color: var(--text); border-radius: 10px; + border: 1px solid rgba(56,189,248,0.3); + box-shadow: 0 0 32px rgba(56,189,248,0.15), 0 8px 32px rgba(0,0,0,0.5); +} +.map-page .leaflet-popup-tip { background: rgba(24,31,42,0.95); border: 1px solid rgba(56,189,248,0.2); } +.map-page .leaflet-popup-content { margin: 16px 20px; } +.popup-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; } +.popup-code { font-size: 24px; font-weight: 600; letter-spacing: -0.5px; color: var(--cyan); text-shadow: 0 0 16px rgba(56,189,248,0.4); } +.popup-name { font-size: 12px; color: rgba(230,237,243,0.5); } +.popup-count { font-size: 16px; font-weight: 500; color: var(--green); } +.popup-coords { font-size: 11px; color: rgba(56,189,248,0.5); margin-top: 6px; font-family: ui-monospace, monospace; } +.map-page .leaflet-popup-close-button { + color: rgba(56,189,248,0.5) !important; font-size: 22px !important; + padding: 8px 12px !important; font-weight: 300; +} +.map-page .leaflet-popup-close-button:hover { color: var(--cyan) !important; } + +/* Map cluster styles */ +.cluster-wrapper { background: transparent !important; border: none !important; } +.cluster-icon { + display: flex; align-items: center; justify-content: center; + border-radius: 50%; font-weight: 600; font-size: 12px; + background: linear-gradient(145deg, rgba(80,200,120,0.9), rgba(56,189,248,0.9)); + border: 2px solid rgba(56,189,248,0.6); color: #fff; + box-shadow: 0 0 16px rgba(56,189,248,0.5), var(--shadow-md); + text-shadow: 0 1px 2px rgba(0,0,0,0.3); +} +.cluster-sm { width: 32px; height: 32px; font-size: 11px; } +.cluster-md { width: 40px; height: 40px; font-size: 13px; } +.cluster-lg { width: 50px; height: 50px; font-size: 15px; } +.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background: transparent !important; } +.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background: transparent !important; } + +/* Loading animation */ +@keyframes loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } } +.loading { animation: loading-pulse 1.8s ease-in-out infinite; } + +/* ========================================================================== + MITM Search Page Styles + ========================================================================== */ + +.search-container { max-width: 900px; margin: 0 auto; } + +/* Search Header */ +.search-header { + display: flex; justify-content: space-between; align-items: center; + margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--border); +} +.search-header h1 { + font-size: 18px; font-weight: 600; + display: flex; align-items: center; gap: 10px; +} +.search-header h1::before { + content: ""; width: 10px; height: 10px; + background: var(--red); border-radius: 50%; box-shadow: 0 0 8px var(--red); +} +.back-link { font-size: 12px; color: var(--dim); } +.back-link:hover { color: var(--cyan); } + +/* Search Box */ +.search-box { position: relative; margin-bottom: 20px; } +.search-input { + width: 100%; padding: 14px 16px 14px 44px; font-size: 15px; font-family: inherit; + background: var(--card); border: 2px solid var(--border); border-radius: 10px; + color: var(--text); outline: none; transition: border-color 0.2s, box-shadow 0.2s; +} +.search-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15); } +.search-input::placeholder { color: var(--dim); } +.search-icon { + position: absolute; left: 16px; top: 50%; transform: translateY(-50%); + color: var(--dim); font-size: 16px; pointer-events: none; +} +.search-clear { + position: absolute; right: 14px; top: 50%; transform: translateY(-50%); + background: var(--border); border: none; border-radius: 50%; + width: 22px; height: 22px; cursor: pointer; color: var(--dim); font-size: 14px; + display: none; align-items: center; justify-content: center; transition: background 0.2s, color 0.2s; +} +.search-clear:hover { background: var(--red); color: var(--text); } +.search-clear.visible { display: flex; } + +/* Suggestions Dropdown */ +.suggestions { + position: absolute; top: 100%; left: 0; right: 0; + background: var(--card); border: 1px solid var(--border); border-radius: 8px; + margin-top: 4px; box-shadow: var(--shadow-lg); z-index: 100; + display: none; max-height: 300px; overflow-y: auto; +} +.suggestions.visible { display: block; } +.suggestion-group { padding: 8px 0; border-bottom: 1px solid var(--border); } +.suggestion-group:last-child { border-bottom: none; } +.suggestion-header { + font-size: 10px; font-weight: 600; text-transform: uppercase; + letter-spacing: 0.5px; color: var(--dim); padding: 4px 14px; +} +.suggestion-item { + padding: 8px 14px; cursor: pointer; + display: flex; align-items: center; gap: 10px; transition: background 0.15s; +} +.suggestion-item:hover, .suggestion-item.active { background: rgba(88, 166, 255, 0.1); } +.suggestion-icon { font-size: 12px; color: var(--dim); width: 20px; text-align: center; } +.suggestion-text { flex: 1; font-size: 13px; } +.suggestion-text code { + background: var(--card-alt); padding: 2px 6px; border-radius: 4px; + font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; color: var(--cyan); +} +.suggestion-desc { font-size: 11px; color: var(--dim); } + +/* Help Box */ +.help-box { + background: var(--card); border: 1px solid var(--border); + border-radius: 10px; padding: 16px; margin-bottom: 20px; +} +.help-box.collapsed .help-content { display: none; } +.help-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; } +.help-title { + font-size: 13px; font-weight: 600; color: var(--text); + display: flex; align-items: center; gap: 8px; +} +.help-title::before { + content: "?"; display: flex; align-items: center; justify-content: center; + width: 18px; height: 18px; background: var(--blue); color: var(--bg); + border-radius: 50%; font-size: 11px; font-weight: 700; +} +.help-toggle { font-size: 12px; color: var(--dim); transition: transform 0.2s; } +.help-box.collapsed .help-toggle { transform: rotate(-90deg); } +.help-content { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); } +.help-section { margin-bottom: 14px; } +.help-section:last-child { margin-bottom: 0; } +.help-section-title { + font-size: 11px; font-weight: 600; text-transform: uppercase; + letter-spacing: 0.5px; color: var(--dim); margin-bottom: 8px; +} +.help-examples { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; } +@media (max-width: 600px) { .help-examples { grid-template-columns: 1fr; } } +.help-example { + background: var(--card-alt); padding: 8px 12px; border-radius: 6px; font-size: 12px; +} +.help-example code { color: var(--cyan); font-family: "SFMono-Regular", Consolas, monospace; } +.help-example span { color: var(--dim); margin-left: 6px; } + +/* Stats Summary */ +.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; } +@media (max-width: 700px) { .stats-summary { grid-template-columns: repeat(2, 1fr); } } +.stat-card { + background: var(--card); border: 1px solid var(--border); + border-radius: 8px; padding: 12px; text-align: center; +} +.stat-card .lbl { font-size: 10px; margin-bottom: 4px; } +.stat-card .val { font-size: 22px; font-weight: 700; } + +/* Results Area */ +.results-container { min-height: 200px; } +.results-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; } +.results-count { font-size: 12px; color: var(--dim); } +.results-count strong { color: var(--text); } +.results-empty { text-align: center; padding: 60px 20px; color: var(--dim); } +.results-empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; } +.results-empty-text { font-size: 14px; margin-bottom: 8px; } +.results-empty-hint { font-size: 12px; } +.results-empty-hint code { + background: var(--card-alt); padding: 2px 6px; border-radius: 4px; + font-family: "SFMono-Regular", Consolas, monospace; color: var(--cyan); +} + +/* Result Cards */ +.result-card { + background: var(--card); border: 1px solid var(--border); border-radius: 10px; + padding: 16px; margin-bottom: 12px; transition: transform 0.2s, box-shadow 0.2s; +} +.result-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); } +.result-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; } +.result-title { + font-size: 14px; font-weight: 600; color: var(--text); + display: flex; align-items: center; gap: 8px; +} +.result-badge { + font-size: 10px; padding: 3px 8px; border-radius: 4px; + font-weight: 600; text-transform: uppercase; +} +.result-badge.cert { background: rgba(248, 81, 73, 0.2); color: var(--red); } +.result-badge.proxy { background: rgba(88, 166, 255, 0.2); color: var(--blue); } +.result-badge.org { background: rgba(163, 113, 247, 0.2); color: var(--purple); } +.result-meta { font-size: 11px; color: var(--dim); } +.result-body { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; } +@media (max-width: 600px) { .result-body { grid-template-columns: 1fr; } } +.result-field { display: flex; flex-direction: column; gap: 2px; } +.result-field-label { + font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.5px; +} +.result-field-value { + font-size: 13px; font-family: "SFMono-Regular", Consolas, monospace; + color: var(--text); word-break: break-all; +} +.result-field-value.highlight { color: var(--cyan); } +.result-proxies { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); } +.result-proxies-title { + font-size: 10px; color: var(--dim); text-transform: uppercase; + letter-spacing: 0.5px; margin-bottom: 8px; +} +.proxy-tags { display: flex; flex-wrap: wrap; gap: 6px; } +.proxy-tag { + font-size: 11px; font-family: "SFMono-Regular", Consolas, monospace; + background: var(--card-alt); padding: 4px 8px; border-radius: 4px; color: var(--blue); +} + +/* Loading State */ +.results-loading { text-align: center; padding: 40px; color: var(--dim); } +.results-loading::after { + content: ""; display: inline-block; width: 20px; height: 20px; + border: 2px solid var(--border); border-top-color: var(--cyan); border-radius: 50%; + animation: spin 0.8s linear infinite; margin-left: 10px; vertical-align: middle; +} +@keyframes spin { to { transform: rotate(360deg); } } + +/* No Data State */ +.no-data { text-align: center; padding: 80px 20px; } +.no-data-icon { font-size: 64px; margin-bottom: 20px; opacity: 0.3; } +.no-data-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; } +.no-data-text { font-size: 13px; color: var(--dim); max-width: 400px; margin: 0 auto; } + +/* ========================================================================== + Theme Toggle + ========================================================================== */ + +.theme-toggle { + background: var(--card-alt); + border: 1px solid var(--border); + border-radius: 20px; + padding: 4px 10px; + cursor: pointer; + display: flex; + align-items: center; + gap: 6px; + font-size: 12px; + color: var(--dim); + transition: all var(--transition); + margin-left: 12px; +} +.theme-toggle:hover { + background: var(--border); + color: var(--text); +} +.theme-toggle-icon { + font-size: 14px; + transition: transform 0.3s ease; +} +html.muted-dark .theme-toggle-icon { + transform: rotate(90deg); +} +html.light .theme-toggle-icon { + transform: rotate(180deg); +} +/* Muted dark theme specific overrides */ +html.muted-dark .chart-wrap, +html.muted-dark .histo-wrap, +html.muted-dark .stats-wrap, +html.muted-dark .lb-wrap, +html.muted-dark .tor-card, +html.muted-dark .pie-wrap { + background: linear-gradient(145deg, rgba(34,37,42,0.85), rgba(26,28,32,0.9)); + border-color: var(--border); + box-shadow: var(--shadow-md); +} +html.muted-dark .chart-wrap::before, +html.muted-dark .histo-wrap::before, +html.muted-dark .stats-wrap::before, +html.muted-dark .lb-wrap::before, +html.muted-dark .tor-card::before, +html.muted-dark .pie-wrap::before { + background: linear-gradient(180deg, rgba(90,144,152,0.04) 0%, transparent 40%); +} +html.muted-dark .histo-bar { + background: linear-gradient(180deg, var(--cyan), rgba(90,144,152,0.5)); + box-shadow: 0 0 8px rgba(90,144,152,0.35); +} +html.muted-dark .glass { + background: linear-gradient(145deg, rgba(34,37,42,0.85), rgba(26,28,32,0.9)); + border-color: var(--border); +} +/* Light theme specific overrides */ +html.light .chart-wrap, +html.light .histo-wrap, +html.light .stats-wrap, +html.light .lb-wrap, +html.light .tor-card, +html.light .pie-wrap { + background: linear-gradient(145deg, rgba(245,242,237,0.9), rgba(235,231,226,0.95)); + border-color: var(--border); + box-shadow: var(--shadow-md); +} +html.light .chart-wrap::before, +html.light .histo-wrap::before, +html.light .stats-wrap::before, +html.light .lb-wrap::before, +html.light .tor-card::before, +html.light .pie-wrap::before { + background: linear-gradient(180deg, rgba(200,195,188,0.1) 0%, transparent 40%); +} +html.light .histo-bar { + background: linear-gradient(180deg, var(--cyan), rgba(26,122,127,0.6)); + box-shadow: 0 0 8px rgba(26,122,127,0.3); +} +html.light .glass { + background: linear-gradient(145deg, rgba(245,242,237,0.9), rgba(235,231,226,0.95)); + border-color: var(--border); +} +html.light .pct-badges { + background: linear-gradient(135deg, rgba(245,242,237,0.95), rgba(235,231,226,0.98)); +} +html.light .pct-badge { + background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(245,242,237,0.8)); + border-color: var(--border); +} +html.light .map-stat-val { + color: var(--cyan); + text-shadow: none; +} +html.light .map-stat-lbl { + color: var(--dim); +} +html.light .map-legend-title { + color: var(--dim); +} +html.light .map-legend-row { + color: var(--text); +} +html.light .leaflet-popup-content-wrapper { + background: rgba(245,242,237,0.98); + border-color: var(--border); +} +html.light .leaflet-popup-tip { + background: rgba(245,242,237,0.98); + border-color: var(--border); +} +html.light .popup-code { + color: var(--cyan); + text-shadow: none; +}