# RainbowTerm Configuration
# Context-aware terminal colorizer
# Config version: 0.2.9 (2025-12-17)

# Default profile to use when none is specified
default_profile = "juniper"

# =============================================================================
# COLOR PALETTE
# =============================================================================
[palette]
# Reds
red-bright = "#ff0000"
red-dark = "#cc0000"

# Greens
green-bright = "#00ff00"
green-lime = "#00ff7f"
green-emerald = "#50c878"
green-forest = "#228b22"

# Yellows/Oranges
yellow-bright = "#ffff00"
yellow-gold = "#ffd700"
orange-bright = "#ff8c00"
orange-coral = "#ff7f50"

# Cyans/Blues
cyan-bright = "#00ffff"
cyan-aqua = "#00ced1"
blue-bright = "#0080ff"

# Purples
purple-bright = "#d946ef"
magenta-bright = "#ff00ff"

# Grays
gray-light = "#b0b0b0"
gray-medium = "#808080"
gray-dark = "#5f5f5f"

# Whites
white = "#ffffff"
white-soft = "#f8f9f9"

# Semantic colors
status-critical = "#ff0000"
status-error = "#dc143c"
status-warning = "#ff6600"
status-caution = "#ffbf00"
status-ok = "#228b22"
status-good = "#50c878"
status-excellent = "#00ff00"

# Interface speed colors
iface-ultra = "#00ff00"      # 100G+
iface-high = "#00ff7f"       # 10G
iface-medium = "#00ced1"     # 2.5G
iface-standard = "#ff7f50"   # 1G
iface-low = "#ffbf00"        # <1G

# Magnitude spectrum colors (rainbow progression for large numbers - NEUTRAL)
mag-orange = "#ff8c00"       # Trillions+ (leftmost digits)
mag-yellow = "#ffff00"       # Billions
mag-green = "#00ff7f"        # Millions
mag-blue = "#00bfff"         # Thousands
mag-purple = "#d946ef"       # Hundreds (rightmost 3 digits, 1-999)
mag-pink = "#ff69b4"         # Units (rightmost 3 digits for very large numbers)

# Error/problem spectrum colors (warm colors, increasing severity - BAD)
err-yellow = "#ffd700"       # Tens/Hundreds (minor issue)
err-orange = "#ff8c00"       # Thousands (moderate problem)
err-red = "#ff4500"          # Ten thousands (serious problem)
err-darkred = "#dc143c"      # Hundred thousands (severe problem)
err-crimson = "#b22222"      # Millions (critical problem)
err-magenta = "#ff1493"      # Billions (extremely critical)
err-violet = "#8b008b"       # Trillions+ (catastrophic - darkest/hottest)

# Uptime/stability spectrum (bell curve: short = meh, medium = healthy, too long = concerning)
uptime-seconds = "#808080"   # Seconds only (just rebooted, dark gray)
uptime-minutes = "#9e9e9e"   # Minutes (just started, neutral gray)
uptime-hours = "#90ee90"     # Hours (getting there, light green)
uptime-days = "#50c878"      # Days (stable, good)
uptime-weeks = "#228b22"     # Weeks (healthy - peak)
uptime-months = "#b8d900"    # Months (getting long, greenish-yellow)
uptime-1yr = "#ff8c00"       # ~1 year (concerning - orange)
uptime-2yr = "#ff4500"       # 2+ years (needs maintenance - red)

# Time spectrum - for visual parsing of timestamps
# Hours: 24 distinct colors (one per hour)
time-00 = "#1e1b4b"          # Midnight - deep indigo
time-01 = "#312e81"          # 1am - indigo
time-02 = "#3730a3"          # 2am - violet-indigo
time-03 = "#4338ca"          # 3am - violet
time-04 = "#4f46e5"          # 4am - light violet
time-05 = "#6366f1"          # 5am - lavender
time-06 = "#0891b2"          # 6am - cyan (dawn)
time-07 = "#0d9488"          # 7am - teal
time-08 = "#059669"          # 8am - emerald
time-09 = "#16a34a"          # 9am - green
time-10 = "#65a30d"          # 10am - lime
time-11 = "#a3e635"          # 11am - bright lime
time-12 = "#facc15"          # Noon - yellow (peak)
time-13 = "#fbbf24"          # 1pm - amber
time-14 = "#f59e0b"          # 2pm - orange-amber
time-15 = "#f97316"          # 3pm - orange
time-16 = "#ea580c"          # 4pm - dark orange
time-17 = "#dc2626"          # 5pm - red
time-18 = "#be185d"          # 6pm - pink
time-19 = "#a21caf"          # 7pm - fuchsia
time-20 = "#7c3aed"          # 8pm - purple
time-21 = "#6d28d9"          # 9pm - deep purple
time-22 = "#5b21b6"          # 10pm - dark purple
time-23 = "#4c1d95"          # 11pm - very dark purple

# Minutes/Seconds: 6 intervals (0-9, 10-19, 20-29, 30-39, 40-49, 50-59)
time-0x = "#94a3b8"          # :0X - slate
time-1x = "#a78bfa"          # :1X - purple
time-2x = "#60a5fa"          # :2X - blue
time-3x = "#34d399"          # :3X - emerald
time-4x = "#fbbf24"          # :4X - amber
time-5x = "#f87171"          # :5X - red

# =============================================================================
# BASE PROFILE - Common patterns for all vendors
# =============================================================================
[profiles.base]
description = "Universal patterns: IPs, MACs, dates, generic status"

# IPv4 addresses (simplified without lookbehind)
[[profiles.base.patterns]]
description = "IPv4 addresses"
regex = '''\b(?:(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)(?:/\d+)?\b'''
color = "green-emerald"
priority = 50
exclusive = false
case_insensitive = false

# MAC addresses (simplified without lookbehind/lookahead)
# Priority 150 to override queue counter patterns (145) that could match first 2 hex digits
# NOT exclusive - need to match multiple MACs per line (e.g., "Current address: X, Hardware address: Y")
[[profiles.base.patterns]]
description = "MAC addresses (colon format)"
regex = '''\b(?:[\da-fA-F]{1,2}:){5}[\da-fA-F]{1,2}\b'''
color = "orange-coral"
priority = 150
exclusive = false

[[profiles.base.patterns]]
description = "MAC addresses (dot format)"
regex = '''\b(?:[\da-fA-F]{4}\.){2}[\da-fA-F]{4}\b'''
color = "orange-coral"
priority = 150
exclusive = false

# Dates - informational (cyan)
[[profiles.base.patterns]]
description = "ISO dates (YYYY-MM-DD)"
regex = '''\b(20\d{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]))\b'''
color = "cyan-aqua"
priority = 40
exclusive = false

# Month-based dates (Dec 11)
[[profiles.base.patterns]]
description = "Syslog dates (Mon DD)"
regex = '''\b((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{1,2})\s+(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d\b'''
color = "cyan-aqua"
priority = 40
exclusive = false

# =============================================================================
# TIME SPECTRUM - Visual parsing of HH:MM:SS timestamps
# Hours: 24 distinct colors (one per hour)
# Minutes/Seconds: 6 intervals (0X, 1X, 2X, 3X, 4X, 5X)
# =============================================================================

# Hour 00 (midnight) - deep indigo
[[profiles.base.patterns]]
description = "Timestamp - hour 00"
regex = '''\b(00):[0-5]\d:[0-5]\d\b'''
color = "time-00"
priority = 38
exclusive = false

# Hour 01 - indigo
[[profiles.base.patterns]]
description = "Timestamp - hour 01"
regex = '''\b(01):[0-5]\d:[0-5]\d\b'''
color = "time-01"
priority = 38
exclusive = false

# Hour 02 - violet-indigo
[[profiles.base.patterns]]
description = "Timestamp - hour 02"
regex = '''\b(02):[0-5]\d:[0-5]\d\b'''
color = "time-02"
priority = 38
exclusive = false

# Hour 03 - violet
[[profiles.base.patterns]]
description = "Timestamp - hour 03"
regex = '''\b(03):[0-5]\d:[0-5]\d\b'''
color = "time-03"
priority = 38
exclusive = false

# Hour 04 - light violet
[[profiles.base.patterns]]
description = "Timestamp - hour 04"
regex = '''\b(04):[0-5]\d:[0-5]\d\b'''
color = "time-04"
priority = 38
exclusive = false

# Hour 05 - lavender
[[profiles.base.patterns]]
description = "Timestamp - hour 05"
regex = '''\b(05):[0-5]\d:[0-5]\d\b'''
color = "time-05"
priority = 38
exclusive = false

# Hour 06 (dawn) - cyan
[[profiles.base.patterns]]
description = "Timestamp - hour 06"
regex = '''\b(06):[0-5]\d:[0-5]\d\b'''
color = "time-06"
priority = 38
exclusive = false

# Hour 07 - teal
[[profiles.base.patterns]]
description = "Timestamp - hour 07"
regex = '''\b(07):[0-5]\d:[0-5]\d\b'''
color = "time-07"
priority = 38
exclusive = false

# Hour 08 - emerald
[[profiles.base.patterns]]
description = "Timestamp - hour 08"
regex = '''\b(08):[0-5]\d:[0-5]\d\b'''
color = "time-08"
priority = 38
exclusive = false

# Hour 09 - green
[[profiles.base.patterns]]
description = "Timestamp - hour 09"
regex = '''\b(09):[0-5]\d:[0-5]\d\b'''
color = "time-09"
priority = 38
exclusive = false

# Hour 10 - lime
[[profiles.base.patterns]]
description = "Timestamp - hour 10"
regex = '''\b(10):[0-5]\d:[0-5]\d\b'''
color = "time-10"
priority = 38
exclusive = false

# Hour 11 - bright lime
[[profiles.base.patterns]]
description = "Timestamp - hour 11"
regex = '''\b(11):[0-5]\d:[0-5]\d\b'''
color = "time-11"
priority = 38
exclusive = false

# Hour 12 (noon) - yellow
[[profiles.base.patterns]]
description = "Timestamp - hour 12"
regex = '''\b(12):[0-5]\d:[0-5]\d\b'''
color = "time-12"
priority = 38
exclusive = false

# Hour 13 - amber
[[profiles.base.patterns]]
description = "Timestamp - hour 13"
regex = '''\b(13):[0-5]\d:[0-5]\d\b'''
color = "time-13"
priority = 38
exclusive = false

# Hour 14 - orange-amber
[[profiles.base.patterns]]
description = "Timestamp - hour 14"
regex = '''\b(14):[0-5]\d:[0-5]\d\b'''
color = "time-14"
priority = 38
exclusive = false

# Hour 15 - orange
[[profiles.base.patterns]]
description = "Timestamp - hour 15"
regex = '''\b(15):[0-5]\d:[0-5]\d\b'''
color = "time-15"
priority = 38
exclusive = false

# Hour 16 - dark orange
[[profiles.base.patterns]]
description = "Timestamp - hour 16"
regex = '''\b(16):[0-5]\d:[0-5]\d\b'''
color = "time-16"
priority = 38
exclusive = false

# Hour 17 - red
[[profiles.base.patterns]]
description = "Timestamp - hour 17"
regex = '''\b(17):[0-5]\d:[0-5]\d\b'''
color = "time-17"
priority = 38
exclusive = false

# Hour 18 - pink
[[profiles.base.patterns]]
description = "Timestamp - hour 18"
regex = '''\b(18):[0-5]\d:[0-5]\d\b'''
color = "time-18"
priority = 38
exclusive = false

# Hour 19 - fuchsia
[[profiles.base.patterns]]
description = "Timestamp - hour 19"
regex = '''\b(19):[0-5]\d:[0-5]\d\b'''
color = "time-19"
priority = 38
exclusive = false

# Hour 20 - purple
[[profiles.base.patterns]]
description = "Timestamp - hour 20"
regex = '''\b(20):[0-5]\d:[0-5]\d\b'''
color = "time-20"
priority = 38
exclusive = false

# Hour 21 - deep purple
[[profiles.base.patterns]]
description = "Timestamp - hour 21"
regex = '''\b(21):[0-5]\d:[0-5]\d\b'''
color = "time-21"
priority = 38
exclusive = false

# Hour 22 - dark purple
[[profiles.base.patterns]]
description = "Timestamp - hour 22"
regex = '''\b(22):[0-5]\d:[0-5]\d\b'''
color = "time-22"
priority = 38
exclusive = false

# Hour 23 - very dark purple
[[profiles.base.patterns]]
description = "Timestamp - hour 23"
regex = '''\b(23):[0-5]\d:[0-5]\d\b'''
color = "time-23"
priority = 38
exclusive = false

# Minutes - 0X interval (slate)
[[profiles.base.patterns]]
description = "Timestamp - minutes :0X"
regex = '''\b(?:[01]\d|2[0-3]):(0\d):[0-5]\d\b'''
color = "time-0x"
priority = 37
exclusive = false

# Minutes - 1X interval (purple)
[[profiles.base.patterns]]
description = "Timestamp - minutes :1X"
regex = '''\b(?:[01]\d|2[0-3]):(1\d):[0-5]\d\b'''
color = "time-1x"
priority = 37
exclusive = false

# Minutes - 2X interval (blue)
[[profiles.base.patterns]]
description = "Timestamp - minutes :2X"
regex = '''\b(?:[01]\d|2[0-3]):(2\d):[0-5]\d\b'''
color = "time-2x"
priority = 37
exclusive = false

# Minutes - 3X interval (emerald)
[[profiles.base.patterns]]
description = "Timestamp - minutes :3X"
regex = '''\b(?:[01]\d|2[0-3]):(3\d):[0-5]\d\b'''
color = "time-3x"
priority = 37
exclusive = false

# Minutes - 4X interval (amber)
[[profiles.base.patterns]]
description = "Timestamp - minutes :4X"
regex = '''\b(?:[01]\d|2[0-3]):(4\d):[0-5]\d\b'''
color = "time-4x"
priority = 37
exclusive = false

# Minutes - 5X interval (red)
[[profiles.base.patterns]]
description = "Timestamp - minutes :5X"
regex = '''\b(?:[01]\d|2[0-3]):(5\d):[0-5]\d\b'''
color = "time-5x"
priority = 37
exclusive = false

# Seconds - 0X interval (slate)
[[profiles.base.patterns]]
description = "Timestamp - seconds :0X"
regex = '''\b(?:[01]\d|2[0-3]):[0-5]\d:(0\d)\b'''
color = "time-0x"
priority = 36
exclusive = false

# Seconds - 1X interval (purple)
[[profiles.base.patterns]]
description = "Timestamp - seconds :1X"
regex = '''\b(?:[01]\d|2[0-3]):[0-5]\d:(1\d)\b'''
color = "time-1x"
priority = 36
exclusive = false

# Seconds - 2X interval (blue)
[[profiles.base.patterns]]
description = "Timestamp - seconds :2X"
regex = '''\b(?:[01]\d|2[0-3]):[0-5]\d:(2\d)\b'''
color = "time-2x"
priority = 36
exclusive = false

# Seconds - 3X interval (emerald)
[[profiles.base.patterns]]
description = "Timestamp - seconds :3X"
regex = '''\b(?:[01]\d|2[0-3]):[0-5]\d:(3\d)\b'''
color = "time-3x"
priority = 36
exclusive = false

# Seconds - 4X interval (amber)
[[profiles.base.patterns]]
description = "Timestamp - seconds :4X"
regex = '''\b(?:[01]\d|2[0-3]):[0-5]\d:(4\d)\b'''
color = "time-4x"
priority = 36
exclusive = false

# Seconds - 5X interval (red)
[[profiles.base.patterns]]
description = "Timestamp - seconds :5X"
regex = '''\b(?:[01]\d|2[0-3]):[0-5]\d:(5\d)\b'''
color = "time-5x"
priority = 36
exclusive = false

# Priority 1: Critical Operational Keywords
[[profiles.base.patterns]]
description = "Error keywords"
regex = '''(?i)\b(error|failed|failure|fail)\b'''
color = "status-critical"
priority = 200
exclusive = false

[[profiles.base.patterns]]
description = "Warning prefix"
regex = '''(?i)^(warning:)'''
color = "status-warning"
priority = 200
exclusive = false

[[profiles.base.patterns]]
description = "Warning keywords"
regex = '''(?i)\b(warning|threshold|exceeded)\b'''
color = "status-warning"
priority = 200
exclusive = false

[[profiles.base.patterns]]
description = "No alarms (good status)"
regex = '''(No alarms currently active)'''
color = "status-good"
priority = 210
exclusive = false

[[profiles.base.patterns]]
description = "Success messages"
regex = '''(?i)\b(load complete|commit complete|configuration check succeeds)\b'''
color = "status-good"
priority = 200
exclusive = false

[[profiles.base.patterns]]
description = "Configuration mode entry/exit"
regex = '''(Entering configuration mode|Exiting configuration mode)'''
color = "cyan-bright"
priority = 180
exclusive = false

[[profiles.base.patterns]]
description = "Diff additions (lines starting with +)"
regex = '''^(\+\s+.+)$'''
color = "status-good"
priority = 190
exclusive = false

[[profiles.base.patterns]]
description = "Diff deletions (lines starting with -)"
regex = '''^(-\s+.+)$'''
color = "status-critical"
priority = 190
exclusive = false

[[profiles.base.patterns]]
description = "Diff modifications (lines starting with !)"
regex = '''^(!\s+.+)$'''
color = "yellow-gold"
priority = 190
exclusive = false

[[profiles.base.patterns]]
description = "Alarm severity - Critical/Major"
regex = '''\b(Critical|Major)\b'''
color = "status-critical"
priority = 210
exclusive = false

[[profiles.base.patterns]]
description = "Alarm severity - Minor"
regex = '''\b(Minor)\b'''
color = "status-warning"
priority = 210
exclusive = false

# Priority 2: Link and Device States
[[profiles.base.patterns]]
description = "Physical link is Up"
regex = '''Physical link is (Up)\b'''
color = "status-excellent"
priority = 150
exclusive = false

[[profiles.base.patterns]]
description = "Physical link is Down"
regex = '''Physical link is (Down)\b'''
color = "status-critical"
priority = 150
exclusive = false

[[profiles.base.patterns]]
description = "Device flags - Running"
regex = '''\b(Running)\b'''
color = "status-good"
priority = 140
exclusive = false

[[profiles.base.patterns]]
description = "Device flags - Hardware-Down"
regex = '''\b(Hardware-Down)\b'''
color = "status-critical"
priority = 140
exclusive = false

[[profiles.base.patterns]]
description = "Enabled status"
regex = '''\b(Enabled)\b'''
color = "status-good"
priority = 130
exclusive = false

# Priority 3: Traffic indicators
[[profiles.base.patterns]]
description = "Non-zero traffic rate - bps and pps (active)"
regex = '''\b([1-9]\d*) (bps|pps)'''
color = "status-good"
priority = 100
exclusive = false

[[profiles.base.patterns]]
description = "Zero traffic rate - bps and pps (idle)"
regex = '''\b(0) (bps|pps)'''
color = "gray-medium"
priority = 100
exclusive = false

[[profiles.base.patterns]]
description = "Non-zero packet counters (active)"
regex = '''(?:Input packets|Output packets)\s*:\s*([1-9]\d*)'''
color = "status-good"
priority = 95
exclusive = false

[[profiles.base.patterns]]
description = "Zero packet counters (idle)"
regex = '''(?:Input packets|Output packets)\s*:\s*(0)\b'''
color = "gray-medium"
priority = 95
exclusive = false

# Priority 4: Serial numbers and hardware IDs
[[profiles.base.patterns]]
description = "Serial numbers (alphanumeric)"
regex = '''\b([A-Z]{2}\d{10})\b'''
color = "yellow-gold"
priority = 90
exclusive = false

[[profiles.base.patterns]]
description = "Model numbers"
regex = '''\b(EX\d{4}-[A-Z0-9\-]+|MX\d{3,4}|QFX\d{4}|SRX\d{3,4})\b'''
color = "cyan-aqua"
priority = 90
exclusive = false

# Priority 5: Configuration keywords
[[profiles.base.patterns]]
description = "Set commands in configuration"
regex = '''^\s*(set)\s'''
color = "purple-bright"
priority = 80
exclusive = false

[[profiles.base.patterns]]
description = "Description labels"
regex = '''^\s+Description:\s+(.+)$'''
color = "cyan-aqua"
priority = 70
exclusive = false

# Generic Up status
[[profiles.base.patterns]]
description = "Generic 'up' status words"
regex = '''\b(up|Up|UP|online|Online|ONLINE)\b'''
color = "status-excellent"
priority = 10
exclusive = false
case_insensitive = false

# Generic Down status
[[profiles.base.patterns]]
description = "Generic 'down' status words"
regex = '''\b(down|Down|DOWN|offline|Offline|OFFLINE)\b'''
color = "status-critical"
priority = 10
exclusive = false
case_insensitive = false

# =============================================================================
# JUNIPER PROFILE
# =============================================================================
[profiles.juniper]
description = "Juniper JunOS devices (MX, EX, QFX, SRX series)"
inherits = ["base"]

# Auto-detection patterns (optional, used with --auto-detect)
[[profiles.juniper.auto_detect]]
type = "hostname"
pattern = "^(jr|js)"

[[profiles.juniper.auto_detect]]
type = "prompt"
pattern = '''\w+@[\w\-]+[>#]'''

# =============================================================================
# CLI PROMPTS - Visual mode indicators
# =============================================================================

# Juniper Operational Mode: user@hostname>
[[profiles.juniper.patterns]]
description = "CLI Prompt - Operational mode (>)"
regex = '''(\w+)@([\w\-\.]+)(>)'''
color = { "1" = "white", "2" = "blue-bright", "3" = "blue-bright" }
priority = 250
exclusive = true

# Juniper Configuration Mode: user@hostname#
[[profiles.juniper.patterns]]
description = "CLI Prompt - Configuration/Edit mode (#)"
regex = '''(\w+)@([\w\-\.]+)(#)'''
color = { "1" = "white", "2" = "red-bright", "3" = "red-bright" }
priority = 250
exclusive = true

# Virtual Chassis indicator {master:0}
[[profiles.juniper.patterns]]
description = "Virtual chassis role indicator"
regex = '''\{(master|backup|linecard):(\d+)\}'''
color = { "1" = "cyan-bright", "2" = "cyan-aqua" }
priority = 245
exclusive = false

# Juniper Edit Mode with path: [edit ...] context
[[profiles.juniper.patterns]]
description = "Configuration edit path context"
regex = '''\[edit(?:[\w\-\s\.\/]*)\]'''
color = "red-bright"
priority = 240
exclusive = false

# =============================================================================
# INTERFACE TERSE OUTPUT - Semantic coloring based on admin/link state
# Format: <interface>  <admin>  <link>
# =============================================================================

# up down = Admin up but link down - THIS IS A PROBLEM (red)
# Note: Interface names colored by separate speed-based patterns (exclusive = false)
[[profiles.juniper.patterns]]
description = "Interface terse: admin UP, link DOWN (problem)"
regex = '''(?i)^(\S+)\s+(up)\s+(down)\b'''
color = { "2" = "status-good", "3" = "status-critical" }
priority = 220
exclusive = false

# down down = Admin down, link down - INTENTIONAL but notable (yellow)
[[profiles.juniper.patterns]]
description = "Interface terse: admin DOWN, link DOWN (intentional)"
regex = '''(?i)^(\S+)\s+(down)\s+(down)\b'''
color = { "2" = "status-warning", "3" = "status-warning" }
priority = 220
exclusive = false

# up up = Both up - HEALTHY (green)
[[profiles.juniper.patterns]]
description = "Interface terse: admin UP, link UP (healthy)"
regex = '''(?i)^(\S+)\s+(up)\s+(up)\b'''
color = { "2" = "status-good", "3" = "status-good" }
priority = 220
exclusive = false

# Interface patterns by speed
[[profiles.juniper.patterns]]
description = "Ultra-high-speed interfaces (100G+)"
regex = '''(?i)\b(?:et|fte)-\d+(?:/\d+){0,2}(?:\.\d+)?\b'''
color = "iface-ultra"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "High-speed interfaces (10G)"
regex = '''(?i)\b(?:xe)-\d+(?:/\d+){0,2}(?:\.\d+)?\b'''
color = "iface-high"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "Medium-speed interfaces (2.5G)"
regex = '''(?i)\b(?:mge)-\d+(?:/\d+){0,2}(?:\.\d+)?\b'''
color = "iface-medium"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "Standard interfaces (1G)"
regex = '''(?i)\b(?:ge)-\d+(?:/\d+){0,2}(?:\.\d+)?\b'''
color = "iface-standard"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "Low-speed interfaces (<1G)"
regex = '''(?i)\b(?:fe)-\d+(?:/\d+){0,2}(?:\.\d+)?\b'''
color = "iface-low"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "Virtual Chassis Port interfaces"
regex = '''(?i)\b(?:vcp)-\d+(?:/\d+){0,2}(?:\.\d+)?\b'''
color = "cyan-aqua"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "Logical/virtual interfaces"
regex = '''(?i)\b(?:lo|irb|vlan|pfe|pfh|fxp|me|em|ae|reth|bme|jsrv)(?:-?\d+(?:/\d+)*)?(?:\.\d+)?\b'''
color = "purple-bright"
priority = 100
exclusive = true

[[profiles.juniper.patterns]]
description = "Special service interfaces"
regex = '''(?i)\b(?:cbp|dsc|esi|fti|gre|ipip|lsi|mtun|pimd|pime|pip|tap|vme|vtep)(?:\d+)?(?:\.\d+)?\b'''
color = "cyan-aqua"
priority = 100
exclusive = true

# =============================================================================
# MAGNITUDE SPECTRUM - Context-Aware Rainbow Coloring
# =============================================================================
# 
# CORE PHILOSOPHY: "Same number, different meaning, different color"
# 
# RainbowTerm's key differentiator is context-aware coloring. The same number
# should be colored differently (or not at all) depending on its semantic meaning:
#
#   Example: The number "1644910"
#     ✓ "Output packets: 1644910"        → Spectrum colors (traffic counter)
#     ✓ Queue counter table column       → Spectrum colors (statistical data)
#     ✗ "Last flapped: 2025-12-09"       → No color (date component)
#     ✗ "interface ge-0/0/10"            → No color (identifier)
#
#   Example: The number "0"
#     ✓ "Dropped packets: 0"             → Gray (idle/good state)
#     ✓ Queue counter table showing 0    → Gray (no traffic)
#     ✗ "Queue ID: 0"                    → No color (identifier)
#
# MAGNITUDE SPECTRUM PROGRESSION (for counters/statistics only):
#   - Hundreds (1-999):        Purple only
#   - Thousands (1K-999K):     Blue → Purple  
#   - Millions (1M-999M):      Green → Blue → Purple
#   - Billions (1B-999B):      Yellow → Green → Blue → Purple
#   - Trillions (1T+):         Orange → Yellow → Green → Blue → Purple
#
# IMPLEMENTATION STRATEGIES:
#   1. Label-based: Match numbers preceded by specific labels
#      Example: "(?:Input\s+bytes|Output\s+packets)\s*:\s+(\d+)"
#   2. Structural: Match numbers in specific table positions
#      Example: "\s{10,}(\d+)" for counter columns (10+ spaces = data, not ID)
#   3. Negative: Explicitly avoid dates, IDs, config values
#
# This context-awareness is why RainbowTerm exists - to provide semantic meaning
# through color, not just syntax highlighting.
# =============================================================================

# Zero values (special case - grayed out)
[[profiles.juniper.patterns]]
description = "Zero packet/byte/rate counters"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(0)\b'''
color = "gray-medium"
priority = 160
exclusive = false

# =============================================================================
# FILE SIZE MAGNITUDE SPECTRUM (for ls -l, show log, etc.)
# =============================================================================

# File sizes in ls -l output (number followed by month abbreviation)
# Matches format: "123456 Nov" or "123456 Sep"

# Billions range (1GB+)
[[profiles.juniper.patterns]]
description = "File size - Billions (1GB+)"
regex = '''\s+(\d{1,3})(\d{3})(\d{3})(\d{3})\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'''
color = { "1" = "mag-yellow", "2" = "mag-green", "3" = "mag-blue", "4" = "mag-purple" }
priority = 159
exclusive = true

# Millions range (1MB+)
[[profiles.juniper.patterns]]
description = "File size - Millions (1MB+)"
regex = '''\s+(\d{1,3})(\d{3})(\d{3})\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'''
color = { "1" = "mag-green", "2" = "mag-blue", "3" = "mag-purple" }
priority = 158
exclusive = true

# Thousands range (1KB+)
[[profiles.juniper.patterns]]
description = "File size - Thousands (1KB+)"
regex = '''\s+(\d{1,3})(\d{3})\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'''
color = { "1" = "mag-blue", "2" = "mag-purple" }
priority = 157
exclusive = true

# Hundreds range (1-999 bytes)
[[profiles.juniper.patterns]]
description = "File size - Hundreds (bytes)"
regex = '''\s+(\d{1,3})\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'''
color = "mag-purple"
priority = 156
exclusive = true

# Zero size files
[[profiles.juniper.patterns]]
description = "File size - Zero"
regex = '''\s+(0)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'''
color = "gray-medium"
priority = 161
exclusive = true

# Quintillions (19-21 digits): red → orange → yellow → green → blue → purple → pink
[[profiles.juniper.patterns]]
description = "Quintillions range (19-21 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})(\d{3})(\d{3})(\d{3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "status-critical", "2" = "mag-orange", "3" = "mag-yellow", "4" = "mag-green", "5" = "mag-blue", "6" = "mag-purple", "7" = "mag-pink" }
priority = 157
exclusive = true

# Quadrillions (16-18 digits): orange-red → orange → yellow → green → blue → purple
[[profiles.juniper.patterns]]
description = "Quadrillions range (16-18 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})(\d{3})(\d{3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "err-crimson", "2" = "mag-orange", "3" = "mag-yellow", "4" = "mag-green", "5" = "mag-blue", "6" = "mag-purple" }
priority = 156
exclusive = true

# Trillions (13-15 digits): orange → yellow → green → blue → purple
[[profiles.juniper.patterns]]
description = "Trillions range (13-15 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})(\d{3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "mag-orange", "2" = "mag-yellow", "3" = "mag-green", "4" = "mag-blue", "5" = "mag-purple" }
priority = 155
exclusive = true

# Billions (10-12 digits): yellow → green → blue → purple
[[profiles.juniper.patterns]]
description = "Billions range (10-12 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "mag-yellow", "2" = "mag-green", "3" = "mag-blue", "4" = "mag-purple" }
priority = 154
exclusive = true

# Millions (7-9 digits): green → blue → purple
[[profiles.juniper.patterns]]
description = "Millions range (7-9 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})(\d{3})(\d{3})\b'''
color = { "1" = "mag-green", "2" = "mag-blue", "3" = "mag-purple" }
priority = 153
exclusive = true

# Thousands (4-6 digits): blue → purple
[[profiles.juniper.patterns]]
description = "Thousands range (4-6 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})(\d{3})\b'''
color = { "1" = "mag-blue", "2" = "mag-purple" }
priority = 152
exclusive = true

# Hundreds (1-3 digits): purple only
[[profiles.juniper.patterns]]
description = "Hundreds range (1-3 digits)"
regex = '''(?:Input\s+packets|Output\s+packets|Input\s+bytes|Output\s+bytes|Input\s+rate|Output\s+rate)\s*:\s+(\d{1,3})\b'''
color = "mag-purple"
priority = 151
exclusive = true

# =============================================================================
# QUEUE COUNTER MAGNITUDE SPECTRUM (under "packets" header)
# Matches numbers on lines with 3+ space-separated numbers (counter table rows)
# Format: "    0                          1644910              1644910                    0"
# Note: Patterns match numbers preceded by 10+ spaces (data columns, not queue ID)
# =============================================================================

# =============================================================================
# DROPPED PACKETS COLUMN - Error spectrum (3rd column in queue counter table)
# Match the rightmost number group after two previous number groups
# =============================================================================

# Dropped packets - Zero (green, healthy - no drops!)
[[profiles.juniper.patterns]]
description = "Dropped packets - Zero (healthy)"
regex = '''^\s+\d+\s+\d+\s+\d+\s+(0)\s*$'''
color = "status-good"
priority = 155
exclusive = false

# Dropped packets - Millions: crimson → dark red → yellow
[[profiles.juniper.patterns]]
description = "Dropped packets - Millions"
regex = '''^\s+\d+\s+\d+\s+\d+\s+(\d{1,3})(\d{3})(\d{3})\s*$'''
color = { "1" = "err-crimson", "2" = "err-darkred", "3" = "err-yellow" }
priority = 154
exclusive = false

# Dropped packets - Hundred thousands: dark red → yellow
[[profiles.juniper.patterns]]
description = "Dropped packets - Hundred thousands"
regex = '''^\s+\d+\s+\d+\s+\d+\s+(\d{3})(\d{3})\s*$'''
color = { "1" = "err-darkred", "2" = "err-yellow" }
priority = 153
exclusive = false

# Dropped packets - Ten thousands: red → yellow
[[profiles.juniper.patterns]]
description = "Dropped packets - Ten thousands"
regex = '''^\s+\d+\s+\d+\s+\d+\s+(\d{2})(\d{3})\s*$'''
color = { "1" = "err-red", "2" = "err-yellow" }
priority = 152
exclusive = false

# Dropped packets - Thousands: orange → yellow
[[profiles.juniper.patterns]]
description = "Dropped packets - Thousands"
regex = '''^\s+\d+\s+\d+\s+\d+\s+(\d{1,3})(\d{3})\s*$'''
color = { "1" = "err-orange", "2" = "err-yellow" }
priority = 151
exclusive = false

# Dropped packets - Hundreds: yellow
[[profiles.juniper.patterns]]
description = "Dropped packets - Hundreds"
regex = '''^\s+\d+\s+\d+\s+\d+\s+(\d{1,3})\s*$'''
color = "err-yellow"
priority = 150
exclusive = false

# Queue counter - Zero (gray for idle) - after 10+ spaces
[[profiles.juniper.patterns]]
description = "Queue counter - Zero"
regex = '''\s{10,}(0)\b'''
color = "gray-medium"
priority = 149
exclusive = false

# Queue counter - Billions (10-12 digits): yellow → green → blue → purple
[[profiles.juniper.patterns]]
description = "Queue counter - Billions (10-12 digits)"
regex = '''\s{10,}(\d{1,3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "mag-yellow", "2" = "mag-green", "3" = "mag-blue", "4" = "mag-purple" }
priority = 148
exclusive = false

# Queue counter - Millions (7-9 digits): green → blue → purple
[[profiles.juniper.patterns]]
description = "Queue counter - Millions (7-9 digits)"
regex = '''\s{10,}(\d{1,3})(\d{3})(\d{3})\b'''
color = { "1" = "mag-green", "2" = "mag-blue", "3" = "mag-purple" }
priority = 147
exclusive = false

# Queue counter - Thousands (4-6 digits): blue → purple
[[profiles.juniper.patterns]]
description = "Queue counter - Thousands (4-6 digits)"
regex = '''\s{10,}(\d{1,3})(\d{3})\b'''
color = { "1" = "mag-blue", "2" = "mag-purple" }
priority = 146
exclusive = false

# Queue counter - Hundreds (1-3 digits): purple only
[[profiles.juniper.patterns]]
description = "Queue counter - Hundreds (1-3 digits)"
regex = '''\s{10,}([1-9]\d{0,2})\b'''
color = "mag-purple"
priority = 145
exclusive = false

# =============================================================================
# ERROR/PROBLEM SPECTRUM - Warm colors for bad counters (errors, drops, etc.)
# =============================================================================
# These patterns match error/drop/problem counters with magnitude-based severity coloring.
# Each group of 3 digits gets progressively warmer colors (yellow → orange → red → magenta)
# as you move left (increasing magnitude), indicating escalating problem severity.
#
# Pattern mirrors neutral spectrum but with warm colors:
#   - Hundreds (1-999):               Yellow (rightmost, minor issue)
#   - Thousands (1K-999K):            Orange → Yellow (moderate)
#   - Ten thousands (10K-99K):        Red → Orange → Yellow (serious)
#   - Hundred thousands (100K-999K):  Dark Red → Red → Orange → Yellow (severe)
#   - Millions+ (1M+):                Magenta → Dark Red → Red → Orange → Yellow (critical)
#
# Zero values remain gray (good state, no problems).
#
# Covered error types:
#   - Input/Output Errors, Drops, Framing errors, CRC errors
#   - Runts, Giants, Collisions, Resource errors, FIFO errors
#   - MTU errors, Policed discards, Aged packets
# =============================================================================

# =============================================================================
# OLDER ERROR COUNTER PATTERNS - DISABLED in favor of semantic patterns
# The semantic patterns (priority 172-175) handle error counters with proper
# label coloring (gray when 0, red when >0) plus magnitude spectrum for numbers.
# These older patterns only colored numbers, not labels.
# =============================================================================
# # Error counter - Zero (green, healthy state - no errors is GOOD!)
# [[profiles.juniper.patterns]]
# description = "Error counter - Zero (no problems)"
# regex = '''(?i)(?:Input errors|...):\s*:\s+(0)\b'''
# color = "status-good"
# priority = 168
#
# [Trillions through Hundreds patterns removed - replaced by semantic patterns]

# Speed patterns
[[profiles.juniper.patterns]]
description = "100G+ speeds"
regex = '''(?i)\b(100|200|400|800)(Gbps)\b'''
color = "iface-ultra"
priority = 80
exclusive = true

[[profiles.juniper.patterns]]
description = "10G speeds"
regex = '''(?i)\b(10)(Gbps|gbps)\b'''
color = "iface-high"
priority = 80
exclusive = true

[[profiles.juniper.patterns]]
description = "1G speeds"
regex = '''(?i)\b(1)(Gbps|gbps)\b'''
color = "iface-standard"
priority = 80
exclusive = true

[[profiles.juniper.patterns]]
description = "10G in mbps"
regex = '''(?i)\b(10000)(mbps)\b'''
color = "iface-high"
priority = 80
exclusive = true

[[profiles.juniper.patterns]]
description = "1G in mbps"
regex = '''(?i)\b(1000)(mbps)\b'''
color = "iface-standard"
priority = 80
exclusive = true

# =============================================================================
# BGP STATES - Semantic coloring based on peer state
# =============================================================================

# Established = Peer is up and exchanging routes - HEALTHY
# Note: Juniper truncates to "Establ" in some outputs
[[profiles.juniper.patterns]]
description = "BGP Established state (healthy)"
regex = '''\b(Established|Establ)\b'''
color = "status-excellent"
priority = 90
exclusive = true

# Idle = Peer is down/not trying - PROBLEM (usually)
[[profiles.juniper.patterns]]
description = "BGP Idle state (down)"
regex = '''\b(Idle)\b'''
color = "status-critical"
priority = 90
exclusive = true

# Active/Connect = Peer is trying to connect - WARNING (not up yet)
# Note: "Active alarms/defects" patterns at priority 155-156 run first and
# block this from coloring "Active" in those contexts via exclusive matching
[[profiles.juniper.patterns]]
description = "BGP Active state (trying to connect)"
regex = '''\b(Active)\b'''
color = "status-warning"
priority = 90
exclusive = true

[[profiles.juniper.patterns]]
description = "BGP Connect state (trying to connect)"
regex = '''\b(Connect)\b'''
color = "status-warning"
priority = 90
exclusive = true

# OpenSent/OpenConfirm = Negotiating - WARNING (almost there)
[[profiles.juniper.patterns]]
description = "BGP OpenSent state (negotiating)"
regex = '''\b(OpenSent)\b'''
color = "status-warning"
priority = 90
exclusive = true

[[profiles.juniper.patterns]]
description = "BGP OpenConfirm state (negotiating)"
regex = '''\b(OpenConfirm)\b'''
color = "status-warning"
priority = 90
exclusive = true

# Down peers count - highlight if non-zero
[[profiles.juniper.patterns]]
description = "BGP Down peers count (non-zero is concerning)"
regex = '''Down peers:\s*([1-9]\d*)'''
color = { "1" = "status-critical" }
priority = 95
exclusive = false

# OSPF States
[[profiles.juniper.patterns]]
description = "OSPF Full state"
regex = '''\b(Full)\b'''
color = "status-excellent"
priority = 90
exclusive = false

# Spanning Tree Protocol (STP) States
[[profiles.juniper.patterns]]
description = "STP Forwarding state"
regex = '''\b(FWD)\b'''
color = "status-excellent"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Blocking state"
regex = '''\b(BLK)\b'''
color = "status-warning"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Designated role"
regex = '''\b(DESG)\b'''
color = "cyan-bright"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Disabled/Discarding role"
regex = '''\b(DIS)\b'''
color = "gray-medium"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Root role (special - this port leads to root bridge)"
regex = '''\b(ROOT)\b'''
color = "yellow-gold"
priority = 86
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Alternate/Backup role"
regex = '''\b(ALT|ALTN|BKP|BKUP)\b'''
color = "status-caution"
priority = 85
exclusive = false

# STP Port Costs (lower = better path)
[[profiles.juniper.patterns]]
description = "STP Cost - Excellent (1000-2000, typically 10G+)"
regex = '''\b([12]000)\b'''
color = "status-excellent"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Cost - Good (5000, typically 2.5G)"
regex = '''\b(5000)\b'''
color = "status-good"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Cost - Standard (20000, typically 1G)"
regex = '''\b(20000)\b'''
color = "orange-bright"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "STP Cost - Poor (200000+, 100M or slower)"
regex = '''\b(200000|2000000|20000000|100000000|200000000)\b'''
color = "status-critical"
priority = 85
exclusive = false

# Ethernet Switching States (show ethernet-switching interfaces)
[[profiles.juniper.patterns]]
description = "Ethernet Switching - Unblocked (forwarding traffic)"
regex = '''\b(unblocked)\b'''
color = "status-good"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "Ethernet Switching - Blocked (not forwarding)"
regex = '''\b(blocked)\b'''
color = "status-warning"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "Ethernet Switching - Tagged VLAN"
regex = '''\b(tagged)\b'''
color = "cyan-bright"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "Ethernet Switching - Untagged/Native VLAN"
regex = '''\b(untagged)\b'''
color = "gray-light"
priority = 85
exclusive = false

# =============================================================================
# OPERATIONAL HEALTH MONITORING
# =============================================================================

# LACP/LAG Status Patterns
[[profiles.juniper.patterns]]
description = "LACP State - Collecting/Distributing (active)"
regex = '''\b(Collecting|Distributing)\b'''
color = "status-excellent"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "LACP State - Standby/Waiting (standby)"
regex = '''\b(Standby|Waiting|Defaulted)\b'''
color = "status-caution"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "LACP State - Detached/Down (problem)"
regex = '''\b(Detached)\b'''
color = "status-critical"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "LACP Role - Actor/Partner"
regex = '''\b(Actor|Partner)\b'''
color = "cyan-bright"
priority = 85
exclusive = false

# CPU Usage Thresholds (for show system processes, top output)
[[profiles.juniper.patterns]]
description = "CPU Usage - Critical (90-100%)"
regex = '''\s+(9[0-9]|100)(\.\d+)?%'''
color = "status-critical"
priority = 95
exclusive = false

[[profiles.juniper.patterns]]
description = "CPU Usage - High (70-89%)"
regex = '''\s+(7[0-9]|8[0-9])(\.\d+)?%'''
color = "status-warning"
priority = 95
exclusive = false

[[profiles.juniper.patterns]]
description = "CPU Usage - Medium (50-69%)"
regex = '''\s+(5[0-9]|6[0-9])(\.\d+)?%'''
color = "status-caution"
priority = 95
exclusive = false

# Temperature Monitoring (show chassis environment)
[[profiles.juniper.patterns]]
description = "Temperature - Critical (>70C)"
regex = '''(7[0-9]|8[0-9]|9[0-9]|1[0-9]{2})\s+(degrees\s+)?C\b'''
color = "status-critical"
priority = 94
exclusive = false

[[profiles.juniper.patterns]]
description = "Temperature - Warning (60-69C)"
regex = '''(6[0-9])\s+(degrees\s+)?C\b'''
color = "status-warning"
priority = 94
exclusive = false

[[profiles.juniper.patterns]]
description = "Temperature - Normal (<60C)"
regex = '''([0-5][0-9])\s+(degrees\s+)?C\b'''
color = "status-good"
priority = 94
exclusive = false

# =============================================================================
# OPTICS DIAGNOSTICS (show interfaces diagnostics optics)
# =============================================================================

# Optical Power Levels (dBm) - Rx and Tx power thresholds
# Note: dBm is logarithmic, -10 dBm = 0.1 mW, -20 dBm = 0.01 mW
# Higher (less negative) is stronger signal

# Critical: Signal too weak (< -25 dBm) - likely link failure imminent
[[profiles.juniper.patterns]]
description = "Optical Power - Critical (< -25 dBm)"
regex = '''(-(?:2[5-9]|[3-9][0-9])\.?\d*)\s*dBm'''
color = "status-critical"
priority = 97
exclusive = false

# Warning: Signal weak (-20 to -24.99 dBm) - degraded but functional
[[profiles.juniper.patterns]]
description = "Optical Power - Warning (-20 to -25 dBm)"
regex = '''(-(?:2[0-4])\.?\d*)\s*dBm'''
color = "status-warning"
priority = 97
exclusive = false

# Caution: Signal marginal (-15 to -19.99 dBm)
[[profiles.juniper.patterns]]
description = "Optical Power - Marginal (-15 to -20 dBm)"
regex = '''(-(?:1[5-9])\.?\d*)\s*dBm'''
color = "status-caution"
priority = 97
exclusive = false

# Good: Normal signal (-10 to -14.99 dBm)
[[profiles.juniper.patterns]]
description = "Optical Power - Good (-10 to -15 dBm)"
regex = '''(-(?:1[0-4])\.?\d*)\s*dBm'''
color = "status-good"
priority = 97
exclusive = false

# Excellent: Strong signal (> -10 dBm, including positive values)
[[profiles.juniper.patterns]]
description = "Optical Power - Excellent (> -10 dBm)"
regex = '''(-[0-9]\.?\d*|\+?\d+\.?\d*)\s*dBm'''
color = "status-excellent"
priority = 96
exclusive = false

# SFP Module Voltage (normal range 3.1-3.5V for most SFPs)
[[profiles.juniper.patterns]]
description = "SFP Voltage - Normal (3.1-3.5V)"
regex = '''(3\.[1-5]\d*)\s*V\b'''
color = "status-good"
priority = 93
exclusive = false

[[profiles.juniper.patterns]]
description = "SFP Voltage - Warning (outside normal range)"
regex = '''([0-2]\.\d+|3\.[06-9]\d*|[4-9]\.\d+)\s*V\b'''
color = "status-warning"
priority = 93
exclusive = false

# Laser Bias Current (typical range 5-15 mA, varies by optic type)
[[profiles.juniper.patterns]]
description = "Laser Bias - Normal (2-20 mA)"
regex = '''([2-9]|1[0-9]|20)\.?\d*\s*mA\b'''
color = "status-good"
priority = 92
exclusive = false

[[profiles.juniper.patterns]]
description = "Laser Bias - High (>20 mA, aging laser)"
regex = '''(2[1-9]|[3-9][0-9]|[1-9][0-9]{2})\.?\d*\s*mA\b'''
color = "status-warning"
priority = 92
exclusive = false

[[profiles.juniper.patterns]]
description = "Laser Bias - Low (<2 mA, possibly failing)"
regex = '''([01]\.?\d*)\s*mA\b'''
color = "status-caution"
priority = 92
exclusive = false

# Storage/Disk Capacity Warnings (show system storage)
[[profiles.juniper.patterns]]
description = "Storage Capacity - Critical (96-100%)"
regex = '''\s+(9[6-9]|100)%\s+'''
color = "status-critical"
priority = 96
exclusive = false

[[profiles.juniper.patterns]]
description = "Storage Capacity - Very High (86-95%)"
regex = '''\s+(8[6-9]|9[0-5])%\s+'''
color = "status-error"
priority = 96
exclusive = false

[[profiles.juniper.patterns]]
description = "Storage Capacity - High (71-85%)"
regex = '''\s+(7[1-9]|8[0-5])%\s+'''
color = "status-warning"
priority = 96
exclusive = false

[[profiles.juniper.patterns]]
description = "Storage Capacity - Medium (51-70%)"
regex = '''\s+(5[1-9]|6[0-9]|70)%\s+'''
color = "status-caution"
priority = 96
exclusive = false

[[profiles.juniper.patterns]]
description = "Storage Capacity - Low (0-50%)"
regex = '''\s+([0-9]|[1-4][0-9]|50)%\s+'''
color = "status-good"
priority = 96
exclusive = false

# Memory Usage - Context-aware (Free memory LOW is bad, opposite of storage)
[[profiles.juniper.patterns]]
description = "Free memory - Critical (0-5%)"
regex = '''Free memory.*?(\(\s*[0-5]%\s*\))'''
color = "status-critical"
priority = 97
exclusive = true

[[profiles.juniper.patterns]]
description = "Free memory - Warning (6-15%)"
regex = '''Free memory.*?(\(\s*(?:[6-9]|1[0-5])%\s*\))'''
color = "status-warning"
priority = 97
exclusive = true

[[profiles.juniper.patterns]]
description = "Free memory - Caution (16-25%)"
regex = '''Free memory.*?(\(\s*(?:1[6-9]|2[0-5])%\s*\))'''
color = "status-caution"
priority = 97
exclusive = true

[[profiles.juniper.patterns]]
description = "Free memory - Good (26%+)"
regex = '''Free memory.*?(\(\s*(?:2[6-9]|[3-9][0-9]|100)%\s*\))'''
color = "status-good"
priority = 97
exclusive = true

# Memory type labels (prevent BGP "Active" false positive)
# "Active memory", "Inactive memory", "Wired memory", etc. should be neutral
[[profiles.juniper.patterns]]
description = "Memory type labels (neutral)"
regex = '''(?:Active|Inactive|Wired|Cache|Buffer|Free)\s+memory'''
color = "gray-medium"
priority = 98
exclusive = true

# =============================================================================
# FALSE POSITIVE BLOCKERS - Prevent BGP/STP patterns from matching wrong context
# =============================================================================

# "Active Internet connections" - system connections output, not BGP state
[[profiles.juniper.patterns]]
description = "Active Internet connections (not BGP)"
regex = '''(Active) Internet connections'''
color = "gray-medium"
priority = 98
exclusive = true

# "Active key ID" in OSPF auth context - not BGP state
[[profiles.juniper.patterns]]
description = "Active key ID (OSPF auth, not BGP)"
regex = '''(Active) key ID'''
color = "gray-medium"
priority = 98
exclusive = true

# CPU Idle percentage - not BGP Idle state
# Matches "X.XX% Idle" or "X% Idle" in CPU stats
[[profiles.juniper.patterns]]
description = "CPU Idle percentage (not BGP)"
regex = '''\d+(?:\.\d+)?%\s+(Idle)'''
color = "gray-medium"
priority = 98
exclusive = true

# OSPF SPF delay values - not STP costs
# SPF delay: 0.200000 sec, SPF holddown: 5 sec, SPF rapid runs: 3
[[profiles.juniper.patterns]]
description = "OSPF SPF delay value (not STP cost)"
regex = '''SPF (?:delay|holddown):\s*(\d+(?:\.\d+)?)'''
color = "cyan-aqua"
priority = 98
exclusive = true

# Generic parenthesized percentages (neutral/informational)
[[profiles.juniper.patterns]]
description = "Percentage in parentheses (informational)"
regex = '''\(\s*\d{1,3}(?:\.\d+)?%?\s*\)'''
color = "gray-medium"
priority = 50
exclusive = false

# Process States (for show system processes)
[[profiles.juniper.patterns]]
description = "Process State - Running"
regex = '''\b(RUN|R)\b'''
color = "status-excellent"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "Process State - Sleeping"
regex = '''\b(SLEEP|S)\b'''
color = "status-good"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "Process State - Zombie/Dead"
regex = '''\b(ZOMBIE|Z|DEAD)\b'''
color = "status-critical"
priority = 85
exclusive = false

# Environment Component Status (show chassis environment)
[[profiles.juniper.patterns]]
description = "Component Status - OK/Online/Present"
regex = '''\b(OK|Online|Present)\b'''
color = "status-excellent"
priority = 88
exclusive = false

[[profiles.juniper.patterns]]
description = "Component Status - Failed/Offline/Absent"
regex = '''\b(Failed|Offline|Absent|Check)\b'''
color = "status-critical"
priority = 88
exclusive = false

[[profiles.juniper.patterns]]
description = "Component Status - Testing/Spinning"
regex = '''\b(Testing|Spinning up)\b'''
color = "status-caution"
priority = 88
exclusive = false

# Routing table markers
[[profiles.juniper.patterns]]
description = "Active route marker"
regex = '''(\*)\['''
color = "status-good"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "Best route next-hop marker"
regex = '''^\s+(>)\s+(?:to|via)'''
color = "status-good"
priority = 85
exclusive = false

# Log message patterns
[[profiles.juniper.patterns]]
description = "Log severity - Critical/Emergency"
regex = '''(%\w+-[0-3]-\w+):'''
color = "status-critical"
priority = 100
exclusive = false

[[profiles.juniper.patterns]]
description = "Log severity - Warning"
regex = '''(%\w+-[4-4]-\w+):'''
color = "status-warning"
priority = 100
exclusive = false

[[profiles.juniper.patterns]]
description = "Log severity - Notice/Info"
regex = '''(%\w+-[5-7]-\w+):'''
color = "cyan-bright"
priority = 100
exclusive = false

[[profiles.juniper.patterns]]
description = "Repeated log messages"
regex = '''(last message repeated \d+ times?)'''
color = "gray-medium"
priority = 95
exclusive = false

# Process exit status codes
[[profiles.juniper.patterns]]
description = "Exit status - Success (0)"
regex = '''\b(exited with status=0|status=0)\b'''
color = "status-good"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "Exit status - Error (non-zero)"
regex = '''\bexited with (status=[1-9]\d*)'''
color = "status-critical"
priority = 91
exclusive = false

# Management daemon (mgd) events
[[profiles.juniper.patterns]]
description = "Child process signals (mgd)"
regex = '''\b(UI_CHILD_SIGNALED|UI_CHILD_EXITED|UI_CHILD_START|UI_CHILD_STATUS):'''
color = "gray-light"
priority = 76
exclusive = false

# System error messages
[[profiles.juniper.patterns]]
description = "File/access errors"
regex = '''\b(can not access|cannot access|No such file or directory|Permission denied|not found)\b'''
color = "status-critical"
priority = 92
exclusive = false

[[profiles.juniper.patterns]]
description = "Service thrashing/crash"
regex = '''\b(thrashing|not restarted|crashed|core dumped)\b'''
color = "status-critical"
priority = 92
exclusive = false

[[profiles.juniper.patterns]]
description = "Network/DNS errors"
regex = '''(Couldn't resolve host|Connection refused|Connection timed out|Network unreachable)'''
color = "status-critical"
priority = 92
exclusive = false

# Boot and hardware events
[[profiles.juniper.patterns]]
description = "Device boot/reboot marker"
regex = '''(---<<BOOT>>---|---\s*\[BOOT\]\s*---)'''
color = "cyan-bright"
priority = 200
exclusive = false

[[profiles.juniper.patterns]]
description = "POE errors and failures"
regex = '''(?i)\b(poe\s+(?:reset\s+)?failed|poe\s+error|poe\s+fault)\b'''
color = "status-critical"
priority = 95
exclusive = false

[[profiles.juniper.patterns]]
description = "USB device attached"
regex = '''\b(ugen\d+\.\d+:|umass\d+:|usbus\d+:)'''
color = "yellow-gold"
priority = 88
exclusive = false

[[profiles.juniper.patterns]]
description = "Hardware initialization failures"
regex = '''(?i)\b(cannot allocate IRQ|not using interrupt|initialization failed)\b'''
color = "status-warning"
priority = 93
exclusive = false

[[profiles.juniper.patterns]]
description = "Kernel module issues"
regex = '''(?i)\b(module .+ already present|symbol .+ undefined|module load failed)\b'''
color = "status-warning"
priority = 93
exclusive = false

# Juniper Task Library (JTASK) errors
[[profiles.juniper.patterns]]
description = "JTASK connection failures"
regex = '''\b(JTASK_IO_CONNECT_FAILED|JTASK_SNMP_CONN_RETRY):'''
color = "status-warning"
priority = 94
exclusive = false

# Line Card Management Daemon (LCMD) errors
[[profiles.juniper.patterns]]
description = "LCMD hardware component errors"
regex = '''\b(LCMD_FAN_TRAY_MISS|LCMD_DEV_LIST_EMPTY|LCMD_CNCTN_TIME_OUT):'''
color = "status-critical"
priority = 96
exclusive = false

# Virtual Chassis operational events
[[profiles.juniper.patterns]]
description = "Virtual chassis mastership changes"
regex = '''\b(DEVRT_MASTERSHIP_CHANGE|mastership: routing engine \d+ becoming master)\b'''
color = "cyan-bright"
priority = 89
exclusive = false

[[profiles.juniper.patterns]]
description = "Virtual chassis membership changes"
regex = '''\b(DEVRT_MEMBER_CHANGE|DEVRT_LOCAL_MEMBER_CHANGE|CHASSISD_VCHASSIS_MEMBER_UPDATE_NOTICE):'''
color = "cyan-aqua"
priority = 88
exclusive = false

# SNMP trap messages
[[profiles.juniper.patterns]]
description = "SNMP trap - Link up"
regex = '''\b(SNMP_TRAP_LINK_UP):'''
color = "status-good"
priority = 90
exclusive = false

[[profiles.juniper.patterns]]
description = "SNMP trap - Link down"
regex = '''\b(SNMP_TRAP_LINK_DOWN):'''
color = "status-critical"
priority = 90
exclusive = false

# CHASSISD operational events (informational)
[[profiles.juniper.patterns]]
description = "CHASSISD FPC/interface operations"
regex = '''\b(CHASSISD_IFDEV_DETACH_FPC|CHASSISD_IFDEV_CREATE_NOTICE|CHASSISD_IFDEV_DETACH_ALL_PSEUDO):'''
color = "gray-light"
priority = 75
exclusive = false

# Noisy/repeated debug messages (gray them out)
[[profiles.juniper.patterns]]
description = "Noisy debug messages"
regex = '''\b(tvp_check_status_led_change: No instance found|Ukern event counter .* init delayed)\b'''
color = "gray-dark"
priority = 60
exclusive = false

# Juniper UI/Configuration events
[[profiles.juniper.patterns]]
description = "Commit operations"
regex = '''\b(UI_COMMIT|UI_COMMIT_COMPLETED|commit complete|commit check|commit confirmed)\b'''
color = "status-good"
priority = 88
exclusive = false

[[profiles.juniper.patterns]]
description = "Configuration mode changes"
regex = '''\b(UI_DBASE_LOGIN_EVENT|UI_DBASE_LOGOUT_EVENT|entering configuration mode|exiting configuration mode)\b'''
color = "cyan-bright"
priority = 88
exclusive = false

[[profiles.juniper.patterns]]
description = "Configuration load/rollback operations"
regex = '''\b(UI_LOAD_EVENT|rollback|rollback rescue)\b'''
color = "orange-bright"
priority = 88
exclusive = false

# Authentication and user events
[[profiles.juniper.patterns]]
description = "Authentication threshold exceeded (brute force)"
regex = '''\b(SSHD_LOGIN_ATTEMPTS_THRESHOLD|Too many (?:password|authentication) failures)\b'''
color = "status-critical"
priority = 98
exclusive = false

[[profiles.juniper.patterns]]
description = "SSH login failures"
regex = '''\b(SSHD_LOGIN_FAILED):'''
color = "status-error"
priority = 97
exclusive = false

[[profiles.juniper.patterns]]
description = "PAM authentication errors"
regex = '''\bPAM: (Authentication error|authentication failure)\b'''
color = "status-error"
priority = 96
exclusive = false

[[profiles.juniper.patterns]]
description = "Successful SSH authentication"
regex = '''\b(Accepted (?:keyboard-interactive|password|publickey)(?:/pam)?|authentication success)\b'''
color = "status-good"
priority = 89
exclusive = false

[[profiles.juniper.patterns]]
description = "User/username in logs"
regex = '''User '([^']+)'|for (\w+) from'''
color = "blue-bright"
priority = 87
exclusive = false

[[profiles.juniper.patterns]]
description = "SSH routine disconnects (noise reduction)"
regex = '''\b(Received disconnect from|Disconnected from user|disconnected by user)\b'''
color = "gray-dark"
priority = 65
exclusive = false

[[profiles.juniper.patterns]]
description = "SSH exit status messages (noise reduction)"
regex = '''/usr/sbin/sshd\[\d+\]: exited, status \d+'''
color = "gray-dark"
priority = 65
exclusive = false

[[profiles.juniper.patterns]]
description = "Process names with PIDs"
regex = '''\b([a-z][-a-z0-9]+)\[(\d+)\]:'''
color = { "1" = "gray-medium", "2" = "gray-dark" }
priority = 80
exclusive = false

# Juniper-specific operational patterns
[[profiles.juniper.patterns]]
description = "JUNOS version strings"
regex = '''\b(JUNOS [^\s]+|Junos: \S+)'''
color = "cyan-bright"
priority = 85
exclusive = false

[[profiles.juniper.patterns]]
description = "Router ID"
regex = '''Router ID: (\d+\.\d+\.\d+\.\d+)'''
color = "green-emerald"
priority = 85
exclusive = false

# Active alarms/defects - color entire match to block BGP "Active" pattern
# Priority 155+ ensures these run first; covers the whole "Active ..." span
[[profiles.juniper.patterns]]
description = "No active alarms (good)"
regex = '''Active alarms\s+:\s+None\b'''
color = "status-good"
priority = 156
exclusive = true

[[profiles.juniper.patterns]]
description = "No active defects (good)"
regex = '''Active defects\s+:\s+None\b'''
color = "status-good"
priority = 156
exclusive = true

[[profiles.juniper.patterns]]
description = "Active alarms (problem exists)"
regex = '''Active alarms\s+:\s+\w+'''
color = "status-critical"
priority = 155
exclusive = true

[[profiles.juniper.patterns]]
description = "Active defects (problem exists)"
regex = '''Active defects\s+:\s+\w+'''
color = "status-critical"
priority = 155
exclusive = true

# =============================================================================
# SEMANTIC ERROR STATES - "Error: None" = healthy
# =============================================================================

# Any "X Error: None" pattern indicates healthy state (e.g., BPDU Error: None)
[[profiles.juniper.patterns]]
description = "Error: None (healthy)"
regex = '''(?i)([\w-]+\s+Error):\s+(None)\b'''
color = { "1" = "status-good", "2" = "status-good" }
priority = 205
exclusive = false

# Feature flags that are disabled/none (neutral state)
[[profiles.juniper.patterns]]
description = "Feature disabled (neutral)"
regex = '''(?i)(Loopback|Source filtering|Flow control):\s+(Disabled|None)\b'''
color = { "1" = "gray-medium", "2" = "gray-medium" }
priority = 205
exclusive = false

# =============================================================================
# ERROR COUNTERS - Semantic coloring with magnitude spectrum
# Label: gray when 0 (healthy), red when >0 (problem)
# Number: green when 0, error spectrum when >0
# =============================================================================

# All error types list for reference:
# Input errors, Output errors, Errors, Drops, Framing errors, Runts, Giants,
# Collisions, CRC errors, FIFO errors, MTU errors, Resource errors,
# Policed discards, Aged packets, L2 channel errors, L2 mismatch timeouts,
# L3 incompletes, HS link CRC errors, Carrier transitions

# Error counter: 0 (healthy) - gray label + green 0
[[profiles.juniper.patterns]]
description = "Error counter: 0 (healthy)"
regex = '''(?i)(Input errors|Output errors|Errors|Drops|Framing errors|Runts|Giants|Collisions|CRC errors|FIFO errors|MTU errors|Resource errors|Policed discards|Aged packets|L2 channel errors|L2 mismatch timeouts|L3 incompletes|HS link CRC errors|Carrier transitions):\s+(0)\b'''
color = { "1" = "gray-medium", "2" = "status-good" }
priority = 178
exclusive = false

# Error counter - trillions (13-15 digits): red label + error spectrum
[[profiles.juniper.patterns]]
description = "Error counter - trillions (catastrophic)"
regex = '''(?i)(Input errors|Output errors|Errors|Drops|Framing errors|Runts|Giants|Collisions|CRC errors|FIFO errors|MTU errors|Resource errors|Policed discards|Aged packets|L2 channel errors|L2 mismatch timeouts|L3 incompletes|HS link CRC errors|Carrier transitions):\s+(\d{1,3})(\d{3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "status-critical", "2" = "err-violet", "3" = "err-magenta", "4" = "err-crimson", "5" = "err-darkred", "6" = "err-red" }
priority = 177
exclusive = false

# Error counter - billions (10-12 digits): red label + error spectrum
[[profiles.juniper.patterns]]
description = "Error counter - billions (severe)"
regex = '''(?i)(Input errors|Output errors|Errors|Drops|Framing errors|Runts|Giants|Collisions|CRC errors|FIFO errors|MTU errors|Resource errors|Policed discards|Aged packets|L2 channel errors|L2 mismatch timeouts|L3 incompletes|HS link CRC errors|Carrier transitions):\s+(\d{1,3})(\d{3})(\d{3})(\d{3})\b'''
color = { "1" = "status-critical", "2" = "err-magenta", "3" = "err-crimson", "4" = "err-darkred", "5" = "err-red" }
priority = 176
exclusive = false

# Error counter - millions (7-9 digits): red label + magnitude spectrum
[[profiles.juniper.patterns]]
description = "Error counter - millions (critical)"
regex = '''(?i)(Input errors|Output errors|Errors|Drops|Framing errors|Runts|Giants|Collisions|CRC errors|FIFO errors|MTU errors|Resource errors|Policed discards|Aged packets|L2 channel errors|L2 mismatch timeouts|L3 incompletes|HS link CRC errors|Carrier transitions):\s+(\d{1,3})(\d{3})(\d{3})\b'''
color = { "1" = "status-critical", "2" = "err-crimson", "3" = "err-red", "4" = "err-orange" }
priority = 174
exclusive = false

# Error counter - thousands (4-6 digits): red label + magnitude spectrum
[[profiles.juniper.patterns]]
description = "Error counter - thousands (moderate)"
regex = '''(?i)(Input errors|Output errors|Errors|Drops|Framing errors|Runts|Giants|Collisions|CRC errors|FIFO errors|MTU errors|Resource errors|Policed discards|Aged packets|L2 channel errors|L2 mismatch timeouts|L3 incompletes|HS link CRC errors|Carrier transitions):\s+(\d{1,3})(\d{3})\b'''
color = { "1" = "status-critical", "2" = "err-orange", "3" = "err-yellow" }
priority = 173
exclusive = false

# Error counter - hundreds (1-3 digits): red label + yellow number
[[profiles.juniper.patterns]]
description = "Error counter - hundreds (minor)"
regex = '''(?i)(Input errors|Output errors|Errors|Drops|Framing errors|Runts|Giants|Collisions|CRC errors|FIFO errors|MTU errors|Resource errors|Policed discards|Aged packets|L2 channel errors|L2 mismatch timeouts|L3 incompletes|HS link CRC errors|Carrier transitions):\s+([1-9]\d{0,2})\b'''
color = { "1" = "status-critical", "2" = "err-yellow" }
priority = 172
exclusive = false

[[profiles.juniper.patterns]]
description = "Interface present/running"
regex = '''\b(Present)\b'''
color = "status-good"
priority = 135
exclusive = false

# =============================================================================
# CONTEXT-AWARE RULES - Juniper Interface Blocks
# =============================================================================
[[profiles.juniper.contexts]]
name = "interface_block"
description = "Track interface state for context-aware coloring"
start = '''(?i)^Physical interface:\s+([a-z0-9\-/\.]+)'''

# State variables to track
[[profiles.juniper.contexts.track]]
name = "physical_link"
pattern = '''(?i)Physical link is\s+(Up|Down)'''
capture_group = 1

[[profiles.juniper.contexts.track]]
name = "admin_status"
pattern = '''(?i)Device flags\s*:\s*.*?\s+(Up|Down)\b'''
capture_group = 1

# Context-aware rules
[[profiles.juniper.contexts.rules]]
pattern = '''(?i)Half-Duplex'''
state_key = "physical_link"
priority = 200

[[profiles.juniper.contexts.rules.colors]]
value = "Up"
color = "status-critical"

[[profiles.juniper.contexts.rules.colors]]
value = "Down"
color = "gray-medium"

default_color = "gray-medium"

[[profiles.juniper.contexts.rules]]
pattern = '''(?i)Full-Duplex'''
priority = 200

# No state_key means always apply the first color
[[profiles.juniper.contexts.rules.colors]]
value = "always"
color = "status-good"

default_color = "status-good"

# =============================================================================
# ERROR COUNTERS - Context-aware (UP interface = RED, DOWN interface = YELLOW)
# Non-zero errors on UP interface are active problems
# Non-zero errors on DOWN interface are historical (less urgent)
# =============================================================================

# =============================================================================
# ERROR COUNTERS - Context rules DISABLED in favor of magnitude spectrum patterns
# The semantic error counter patterns (priority 172-175) handle error counters
# with proper color gradients: red label + magnitude spectrum for the number.
# Context rules would override these and color the entire line in one color.
# =============================================================================

# Input errors with non-zero count - DISABLED
# [[profiles.juniper.contexts.rules]]
# pattern = '''(?i)Input errors:\s*([1-9]\d*)'''
# state_key = "physical_link"
# priority = 195
# [[profiles.juniper.contexts.rules.colors]]
# value = "Up"
# color = "status-critical"
# [[profiles.juniper.contexts.rules.colors]]
# value = "Down"
# color = "status-warning"
# default_color = "status-warning"

# Output errors with non-zero count - DISABLED
# [[profiles.juniper.contexts.rules]]
# pattern = '''(?i)Output errors:\s*([1-9]\d*)'''
# state_key = "physical_link"
# priority = 195
# [[profiles.juniper.contexts.rules.colors]]
# value = "Up"
# color = "status-critical"
# [[profiles.juniper.contexts.rules.colors]]
# value = "Down"
# color = "status-warning"
# default_color = "status-warning"

# CRC errors with non-zero count - DISABLED
# [[profiles.juniper.contexts.rules]]
# pattern = '''(?i)CRC(?:\s+errors)?:\s*([1-9]\d*)'''
# state_key = "physical_link"
# priority = 195
# [[profiles.juniper.contexts.rules.colors]]
# value = "Up"
# color = "status-critical"
# [[profiles.juniper.contexts.rules.colors]]
# value = "Down"
# color = "status-warning"
# default_color = "status-warning"

# Framing errors with non-zero count - DISABLED
# [[profiles.juniper.contexts.rules]]
# pattern = '''(?i)Framing errors:\s*([1-9]\d*)'''
# state_key = "physical_link"
# priority = 195
# [[profiles.juniper.contexts.rules.colors]]
# value = "Up"
# color = "status-critical"
# [[profiles.juniper.contexts.rules.colors]]
# value = "Down"
# color = "status-warning"
# default_color = "status-warning"

# Drops with non-zero count - DISABLED in favor of magnitude spectrum patterns
# The magnitude spectrum patterns (priority 167-170) handle Drops with proper
# color gradients based on count size. Context rules would override these.
# [[profiles.juniper.contexts.rules]]
# pattern = '''(?i)(?:Input|Output)?\s*Drops:\s*([1-9]\d*)'''
# state_key = "physical_link"
# priority = 195

# =============================================================================
# ZERO TRAFFIC - Context-aware (UP interface = suspicious, DOWN = expected)
# Zero traffic on UP interface might indicate misconfiguration
# Zero traffic on DOWN interface is expected
# =============================================================================

# Zero input bytes on interface
[[profiles.juniper.contexts.rules]]
pattern = '''(?i)Input\s+bytes\s*:\s*(0)\s'''
state_key = "physical_link"
priority = 190

[[profiles.juniper.contexts.rules.colors]]
value = "Up"
color = "status-warning"

[[profiles.juniper.contexts.rules.colors]]
value = "Down"
color = "gray-medium"

default_color = "gray-medium"

# Zero output bytes on interface
[[profiles.juniper.contexts.rules]]
pattern = '''(?i)Output\s+bytes\s*:\s*(0)\s'''
state_key = "physical_link"
priority = 190

[[profiles.juniper.contexts.rules.colors]]
value = "Up"
color = "status-warning"

[[profiles.juniper.contexts.rules.colors]]
value = "Down"
color = "gray-medium"

default_color = "gray-medium"

# Zero input packets
[[profiles.juniper.contexts.rules]]
pattern = '''(?i)Input\s+packets\s*:\s*(0)\s'''
state_key = "physical_link"
priority = 190

[[profiles.juniper.contexts.rules.colors]]
value = "Up"
color = "status-warning"

[[profiles.juniper.contexts.rules.colors]]
value = "Down"
color = "gray-medium"

default_color = "gray-medium"

# Zero output packets
[[profiles.juniper.contexts.rules]]
pattern = '''(?i)Output\s+packets\s*:\s*(0)\s'''
state_key = "physical_link"
priority = 190

[[profiles.juniper.contexts.rules.colors]]
value = "Up"
color = "status-warning"

[[profiles.juniper.contexts.rules.colors]]
value = "Down"
color = "gray-medium"

default_color = "gray-medium"

# =============================================================================
# UPTIME/STABILITY - Bell curve spectrum
# Short = neutral, Medium = healthy (green), Too long = concerning (needs maintenance)
# JunOS formats: (3w6d 02:06 ago), (00:23:15 ago), 2:15:23
# =============================================================================

# 2+ years (104+ weeks) - RED - definitely needs maintenance/security patches
[[profiles.juniper.patterns]]
description = "Uptime - 2+ years (needs maintenance)"
regex = '''\((\d{3,}w\d+d\s+\d{2}:\d{2})\s+ago\)'''
color = "uptime-2yr"
priority = 180
exclusive = true

# ~1 year (52-103 weeks) - ORANGE - concerning
[[profiles.juniper.patterns]]
description = "Uptime - ~1 year (concerning)"
regex = '''\(([5-9]\dw\d+d\s+\d{2}:\d{2})\s+ago\)'''
color = "uptime-1yr"
priority = 179
exclusive = true

# Months (5-51 weeks) - GREENISH-YELLOW - getting long
[[profiles.juniper.patterns]]
description = "Uptime - months (5-51 weeks)"
regex = '''\(((?:[5-9]|[1-4]\d)w\d+d\s+\d{2}:\d{2})\s+ago\)'''
color = "uptime-months"
priority = 178
exclusive = true

# Weeks (1-4 weeks) - DEEP GREEN - healthy (peak)
[[profiles.juniper.patterns]]
description = "Uptime - weeks (healthy)"
regex = '''\(([1-4]w\d+d\s+\d{2}:\d{2})\s+ago\)'''
color = "uptime-weeks"
priority = 177
exclusive = true

# Days (no weeks, just Xd) - GREEN - stable
[[profiles.juniper.patterns]]
description = "Uptime - days (stable)"
regex = '''\((\d+d\s+\d{2}:\d{2})\s+ago\)'''
color = "uptime-days"
priority = 176
exclusive = true

# Hours (01-23:XX:XX ago) - LIGHT GREEN - getting there
[[profiles.juniper.patterns]]
description = "Uptime - hours (1-23h)"
regex = '''\(((?:0[1-9]|1\d|2[0-3]):\d{2}:\d{2})\s+ago\)'''
color = "uptime-hours"
priority = 175
exclusive = true

# Minutes only (00:01-59:XX ago) - GRAY - just started
[[profiles.juniper.patterns]]
description = "Uptime - minutes only"
regex = '''\((00:(?:0[1-9]|[1-5]\d):\d{2})\s+ago\)'''
color = "uptime-minutes"
priority = 175
exclusive = true

# Seconds only (00:00:XX ago) - DARK GRAY - just rebooted
[[profiles.juniper.patterns]]
description = "Uptime - seconds only"
regex = '''\((00:00:\d{2})\s+ago\)'''
color = "uptime-seconds"
priority = 175
exclusive = true

# BGP Last Up/Dwn - hours:minutes:seconds format (various uptimes)
# Format like "2:15:23" means 2 hours, 15 minutes, 23 seconds
[[profiles.juniper.patterns]]
description = "BGP uptime - hours"
regex = '''\s+(\d{1,2}:\d{2}:\d{2})\s+(?:Establ|Active|Connect|OpenSent|OpenConfirm|Idle)'''
color = "uptime-hours"
priority = 174
exclusive = false

# "never" in BGP uptime = problem
[[profiles.juniper.patterns]]
description = "BGP uptime - never (problem)"
regex = '''\s+(never)\s+(?:Establ|Active|Connect|OpenSent|OpenConfirm|Idle)'''
color = "status-critical"
priority = 174
exclusive = false

# =============================================================================
# CISCO PROFILE
# =============================================================================

[profiles.cisco]
description = "Cisco IOS/IOS-XE/NX-OS devices"
inherits = ["base"]

# =============================================================================
# CISCO INTERFACE NAMES
# =============================================================================

[[profiles.cisco.patterns]]
description = "Gigabit Ethernet interfaces"
regex = '''\b(GigabitEthernet\d+(?:/\d+)*)\b'''
color = "orange-bright"
priority = 100

[[profiles.cisco.patterns]]
description = "Ten Gigabit Ethernet interfaces"
regex = '''\b(TenGigabitEthernet\d+(?:/\d+)*)\b'''
color = "green-lime"
priority = 100

[[profiles.cisco.patterns]]
description = "Fast Ethernet interfaces"
regex = '''\b(FastEthernet\d+(?:/\d+)*)\b'''
color = "orange-coral"
priority = 100

[[profiles.cisco.patterns]]
description = "Port-channel interfaces"
regex = '''\b(Port-channel\d+)\b'''
color = "purple-bright"
priority = 100

[[profiles.cisco.patterns]]
description = "Vlan interfaces"
regex = '''\b(Vlan\d+)\b'''
color = "cyan-aqua"
priority = 100

[[profiles.cisco.patterns]]
description = "Loopback interfaces"
regex = '''\b(Loopback\d+)\b'''
color = "purple-bright"
priority = 100

# Short form interface names
[[profiles.cisco.patterns]]
description = "Gigabit short form (Gi)"
regex = '''\b(Gi\d+(?:/\d+)*)\b'''
color = "orange-bright"
priority = 100

[[profiles.cisco.patterns]]
description = "TenGig short form (Te)"
regex = '''\b(Te\d+(?:/\d+)*)\b'''
color = "green-lime"
priority = 100

[[profiles.cisco.patterns]]
description = "FastEth short form (Fa)"
regex = '''\b(Fa\d+(?:/\d+)*)\b'''
color = "orange-coral"
priority = 100

# =============================================================================
# CISCO LINK STATUS
# =============================================================================

[[profiles.cisco.patterns]]
description = "Interface up status"
regex = '''\b(up)\b'''
color = "status-good"
priority = 90

[[profiles.cisco.patterns]]
description = "Interface down status"
regex = '''\b(down|administratively down)\b'''
color = "status-critical"
priority = 90

[[profiles.cisco.patterns]]
description = "Line protocol status"
regex = '''line protocol is (up)'''
[profiles.cisco.patterns.groups]
1 = "status-good"

[[profiles.cisco.patterns]]
description = "Line protocol down"
regex = '''line protocol is (down)'''
[profiles.cisco.patterns.groups]
1 = "status-critical"

# =============================================================================
# CISCO BGP STATES
# =============================================================================

[[profiles.cisco.patterns]]
description = "BGP Established state"
regex = '''\b(Established)\b'''
color = "status-good"
priority = 90

[[profiles.cisco.patterns]]
description = "BGP down states"
regex = '''\b(Idle|Active|Connect|OpenSent|OpenConfirm)\b'''
color = "status-critical"
priority = 90

# =============================================================================
# CISCO SPANNING TREE
# =============================================================================

[[profiles.cisco.patterns]]
description = "STP Forwarding state"
regex = '''\b(FWD|forwarding)\b'''
color = "status-good"
priority = 90

[[profiles.cisco.patterns]]
description = "STP Blocking/Discarding"
regex = '''\b(BLK|blocking|discarding)\b'''
color = "status-warning"
priority = 90

[[profiles.cisco.patterns]]
description = "STP Root/Designated"
regex = '''\b(Root|Desg|designated)\b'''
color = "cyan-bright"
priority = 85

# =============================================================================
# CISCO OSPF
# =============================================================================

[[profiles.cisco.patterns]]
description = "OSPF Full state"
regex = '''\b(FULL)\b'''
color = "status-good"
priority = 90

[[profiles.cisco.patterns]]
description = "OSPF down states"
regex = '''\b(DOWN|INIT|2WAY|EXSTART|EXCHANGE|LOADING)\b'''
color = "status-critical"
priority = 90

# =============================================================================
# CISCO VTP/VLAN
# =============================================================================

[[profiles.cisco.patterns]]
description = "VTP mode"
regex = '''\b(Server|Client|Transparent)\b'''
color = "cyan-aqua"
priority = 80

[[profiles.cisco.patterns]]
description = "VLAN active"
regex = '''\bactive\b'''
color = "status-good"
priority = 80

[[profiles.cisco.patterns]]
description = "Trunk encapsulation"
regex = '''\b(dot1q|isl|negotiate)\b'''
color = "blue-bright"
priority = 80
