root = Card([header, regionSelector, kpiRow, generationSplit, demandForecast, plantTable, outagesSection, maintenanceSection, alertsSection, curtailmentActions])
header = CardHeader("Power Network Operations Console", "Real-time grid monitoring & control · National Transmission System")
regionSelector = Form("region-focus", regionButtons, [regionField])
regionField = FormControl("Focus Region", regionSelect, "Select a region to filter all views")
regionSelect = Select("region", [rAll, rNorth, rSouth, rEast, rWest, rCentral], "All Regions")
rAll = SelectItem("all", "All Regions")
rNorth = SelectItem("north", "North Region")
rSouth = SelectItem("south", "South Region")
rEast = SelectItem("east", "East Region")
rWest = SelectItem("west", "West Region")
rCentral = SelectItem("central", "Central Region")
regionButtons = Buttons([btnApplyRegion], "row")
btnApplyRegion = Button("Apply Filter", { type: "continue_conversation", context: "Filter all dashboard views to the selected region" }, "primary")
kpiRow = SnippetCardBlock([kpiLoad, kpiCapacity, kpiPrice, kpiEmissions], "grid", true)
kpiLoad = SnippetCardItem("load", kpiLoadLhs, kpiLoadRhs)
kpiLoadLhs = IconText(kpiLoadIcon, "info", "m", "Current Load", "Network demand", false, "horizontal")
kpiLoadIcon = Icon("zap", "weather")
kpiLoadRhs = BoldText("number", "42,850 MW", "+1.2% vs 1h ago", "metric")
kpiCapacity = SnippetCardItem("capacity", kpiCapLhs, kpiCapRhs)
kpiCapLhs = IconText(kpiCapIcon, "warning", "m", "Capacity Utilization", "Load vs available capacity", false, "horizontal")
kpiCapIcon = Icon("gauge", "charts")
kpiCapRhs = BoldText("number", "87.3%", "+2.1% vs 1h ago", "metric")
kpiPrice = SnippetCardItem("price", kpiPriceLhs, kpiPriceRhs)
kpiPriceLhs = IconText(kpiPriceIcon, "neutral", "m", "Current Price", "Wholesale spot price", false, "horizontal")
kpiPriceIcon = Icon("circle-dollar-sign", "finance")
kpiPriceRhs = BoldText("number", "$84.50/MWh", "+$3.20 vs 1h ago", "metric")
kpiEmissions = SnippetCardItem("emissions", kpiEmLhs, kpiEmRhs)
kpiEmLhs = IconText(kpiEmIcon, "success", "m", "CO₂ Emissions", "Today cumulative", false, "horizontal")
kpiEmIcon = Icon("leaf", "nature")
kpiEmRhs = BoldText("number", "18,420 tCO₂", "420 gCO₂/kWh avg", "metric")
generationSplit = SectionBlock([genSection], false)
genSection = SectionItem("generation", "Generation Mix by Source", [genChart, genLegend])
genChart = PieChart(genLabels, genValues, "donut", "circular")
genLabels = ["Natural Gas", "Coal", "Nuclear", "Wind", "Solar", "Hydro", "Biomass", "Imports", "Other"]
genValues = [14200, 9800, 8500, 5600, 3200, 1550, 850, 1200, 350]
genLegend = EntityList(genRows, "default", { left: "Source", right: "Output (MW)", rightVariant: "number" })
genRows = [genR1, genR2, genR3, genR4, genR5, genR6, genR7, genR8, genR9]
genR1 = { left: "Natural Gas", right: "14,200 MW (33.1%)", rightVariant: "text" }
genR2 = { left: "Coal", right: "9,800 MW (22.9%)", rightVariant: "text" }
genR3 = { left: "Nuclear", right: "8,500 MW (19.8%)", rightVariant: "text" }
genR4 = { left: "Wind", right: "5,600 MW (13.1%)", rightVariant: "text" }
genR5 = { left: "Solar", right: "3,200 MW (7.5%)", rightVariant: "text" }
genR6 = { left: "Hydro", right: "1,550 MW (3.6%)", rightVariant: "text" }
genR7 = { left: "Biomass", right: "850 MW (2.0%)", rightVariant: "text" }
genR8 = { left: "Imports", right: "1,200 MW (2.8%)", rightVariant: "text" }
genR9 = { left: "Other", right: "350 MW (0.8%)", rightVariant: "text" }
demandForecast = SectionBlock([fcSection], false)
fcSection = SectionItem("forecast", "Demand Forecast — Next 24 Hours", [fcChart, fcTable])
fcChart = LineChart(fcHours, [fcActual, fcForecast], "natural", "Hour", "Demand (MW)", 300)
fcHours = ["00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00", "23:00"]
fcActual = Series("Actual", [38200, 36800, 35500, 34900, 34600, 35200, 37800, 41200, 43500, 42800, 41900, 41200, 40800, 40500, 40200, 40600, 41800, 43200, 44500, 45800, 45200, 43800, 41500, 39800])
fcForecast = Series("Forecast", [39800, 38200, 36800, 35900, 35400, 36100, 38500, 42100, 44200, 43500, 42800, 42200, 41800, 41400, 41200, 41800, 43200, 44800, 45800, 46500, 45800, 44200, 42100, 40200])
fcTable = Table([fcColHour, fcColForecast, fcColConfidence, fcColPeakFlag])
fcColHour = Col("Hour", fcHours, "string")
fcColForecast = Col("Forecast (MW)", [39800, 38200, 36800, 35900, 35400, 36100, 38500, 42100, 44200, 43500, 42800, 42200, 41800, 41400, 41200, 41800, 43200, 44800, 45800, 46500, 45800, 44200, 42100, 40200], "number")
fcColConfidence = Col("Confidence", ["95%", "94%", "93%", "92%", "91%", "90%", "89%", "88%", "87%", "87%", "88%", "89%", "90%", "91%", "92%", "91%", "90%", "89%", "88%", "87%", "88%", "89%", "91%", "93%"], "string")
fcColPeakFlag = Col("Peak Risk", ["Low", "Low", "Low", "Low", "Low", "Low", "Med", "High", "High", "High", "Med", "Med", "Med", "Med", "Med", "Med", "High", "High", "Critical", "Critical", "High", "Med", "Low", "Low"], "string")
plantTable = SectionBlock([plantSection], false)
plantSection = SectionItem("plants", "Power Plants — Output & Status", [plantsTable])
plantsTable = Table([plColName, plColRegion, plColType, plColOutput, plColCapacity, plColStatus, plColAvail])
plColName = Col("Plant", ["Northridge CCGT", "Blackstone Coal", "Apex Nuclear", "Windmere Farm", "Solaris PV", "Riverbend Hydro", "Greenfield Biomass", "Eastport Import", "Westridge CCGT", "Central Nuclear"], "string")
plColRegion = Col("Region", ["North", "Central", "Central", "East", "South", "West", "Central", "East", "West", "Central"], "string")
plColType = Col("Type", ["Gas", "Coal", "Nuclear", "Wind", "Solar", "Hydro", "Biomass", "Import", "Gas", "Nuclear"], "string")
plColOutput = Col("Output (MW)", [2850, 2200, 2100, 1800, 1200, 850, 420, 600, 1950, 1850], "number")
plColCapacity = Col("Capacity (MW)", [3200, 2400, 2200, 2100, 1500, 950, 500, 800, 2200, 2000], "number")
plColStatus = Col("Status", ["Online", "Online", "Online", "Online", "Online", "Online", "Online", "Online", "Online", "Online"], "string")
plColAvail = Col("Availability", ["98%", "95%", "99%", "87%", "92%", "94%", "96%", "100%", "97%", "99%"], "string")
outagesSection = SectionBlock([outageSection], false)
outageSection = SectionItem("outages", "Active Outages", [outageTable])
outageTable = Table([outColId, outColRegion, outColType, outColAffected, outColSince, outColEta, outColCause])
outColId = Col("ID", ["OUT-2026-0847", "OUT-2026-0852", "OUT-2026-0855"], "string")
outColRegion = Col("Region", ["North", "East", "West"], "string")
outColType = Col("Type", ["Transmission Line", "Substation", "Distribution"], "string")
outColAffected = Col("Customers Affected", [12400, 8700, 3200], "number")
outColSince = Col("Since", ["2026-01-15 06:23", "2026-01-15 08:45", "2026-01-15 10:12"], "string")
outColEta = Col("Est. Restoration", ["2026-01-15 18:00", "2026-01-15 16:30", "2026-01-15 14:00"], "string")
outColCause = Col("Cause", ["Storm damage", "Equipment failure", "Planned maintenance"], "string")
maintenanceSection = SectionBlock([maintSection], false)
maintSection = SectionItem("maintenance", "Planned Maintenance — This Month", [maintTable])
maintTable = Table([mtColId, mtColAsset, mtColRegion, mtColType, mtColStart, mtColEnd, mtColImpact, mtColStatus])
mtColId = Col("ID", ["MAINT-2026-0142", "MAINT-2026-0156", "MAINT-2026-0161", "MAINT-2026-0168", "MAINT-2026-0173"], "string")
mtColAsset = Col("Asset", ["Northridge Unit 3", "Blackstone Stack 2", "Windmere Turbine 12", "Riverbend Transformer", "Central Substation B"], "string")
mtColRegion = Col("Region", ["North", "Central", "East", "West", "Central"], "string")
mtColType = Col("Type", ["Major Overhaul", "Inspection", "Blade Replacement", "Transformer Service", "Switchgear Upgrade"], "string")
mtColStart = Col("Start", ["2026-01-20", "2026-01-22", "2026-01-25", "2026-01-28", "2026-02-03"], "string")
mtColEnd = Col("End", ["2026-01-26", "2026-01-24", "2026-01-29", "2026-01-30", "2026-02-07"], "string")
mtColImpact = Col("Capacity Impact", ["-800 MW", "-600 MW", "-150 MW", "-200 MW", "-400 MW"], "string")
mtColStatus = Col("Status", ["Scheduled", "Scheduled", "Approved", "Pending Approval", "Scheduled"], "string")
alertsSection = SectionBlock([alertSection], false)
alertSection = SectionItem("alerts", "Live Alerts", [alertList])
alertList = ListBlock([al1, al2, al3, al4, al5], "number", "default")
al1 = ListItem("CRITICAL: Northridge CCGT Unit 2 trip", "Lost 850 MW generation · Frequency deviation -0.12 Hz · Automatic reserves deployed", null, "Acknowledge", { type: "continue_conversation", context: "Acknowledge alert OUT-2026-0847 and show recommended actions" })
al2 = ListItem("WARNING: Capacity margin below 15%", "Current margin 12.7% · Forecast peak in 4 hours · Consider demand response activation", null, "Review", { type: "continue_conversation", context: "Show demand response options for current capacity margin" })
al3 = ListItem("INFO: Wind forecast revised downward", "Windmere Farm output revised -400 MW for 14:00-18:00 · Gas peakers ramping", null, "View Details", { type: "continue_conversation", context: "Show updated wind forecast and generation adjustments" })
al4 = ListItem("WARNING: Eastport import limit reduced", "Interconnector capacity reduced to 600 MW (from 800 MW) · Scheduled maintenance", null, "View Details", { type: "continue_conversation", context: "Show interconnector status and alternative import options" })
al5 = ListItem("INFO: Price spike alert — $145/MWh", "Real-time price exceeded $140/MWh threshold · Scarcity pricing in effect", null, "View Market", { type: "continue_conversation", context: "Show current market prices and scarcity pricing details" })
curtailmentActions = SectionBlock([curtailSection], false)
curtailSection = SectionItem("curtailment", "Order Curtailment", [curtailForm])
curtailForm = Form("curtailment-order", curtailButtons, [curtPlant, curtAmount, curtReason, curtDuration])
curtailButtons = Buttons([btnOrderCurtail, btnCancelCurtail], "row")
btnOrderCurtail = Button("Order Curtailment", { type: "continue_conversation", context: "Submit curtailment order with selected parameters for operator approval" }, "primary", "destructive")
btnCancelCurtail = Button("Cancel", { type: "continue_conversation", context: "Cancel curtailment order" }, "secondary")
curtPlant = FormControl("Plant / Asset", curtPlantSelect, "Select the generation asset to curtail")
curtPlantSelect = Select("curtail-plant", [cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10], "Select plant")
cp1 = SelectItem("northridge-ccgt", "Northridge CCGT (Gas, 3,200 MW)")
cp2 = SelectItem("blackstone-coal", "Blackstone Coal (Coal, 2,400 MW)")
cp3 = SelectItem("apex-nuclear", "Apex Nuclear (Nuclear, 2,200 MW)")
cp4 = SelectItem("windmere-wind", "Windmere Farm (Wind, 2,100 MW)")
cp5 = SelectItem("solaris-pv", "Solaris PV (Solar, 1,500 MW)")
cp6 = SelectItem("riverbend-hydro", "Riverbend Hydro (Hydro, 950 MW)")
cp7 = SelectItem("greenfield-bio", "Greenfield Biomass (Biomass, 500 MW)")
cp8 = SelectItem("westridge-ccgt", "Westridge CCGT (Gas, 2,200 MW)")
cp9 = SelectItem("central-nuclear", "Central Nuclear (Nuclear, 2,000 MW)")
cp10 = SelectItem("eastport-import", "Eastport Import (Import, 800 MW)")
curtAmount = FormControl("Curtailment Amount (MW)", curtAmountInput, "Amount to reduce output by")
curtAmountInput = Input("curtail-mw", "e.g. 500", "number", { required: true, min: 1, max: 3200 })
curtReason = FormControl("Reason", curtReasonSelect, "Select curtailment reason")
curtReasonSelect = Select("curtail-reason", [cr1, cr2, cr3, cr4, cr5], "Select reason")
cr1 = SelectItem("emergency", "Emergency — Grid Stability")
cr2 = SelectItem("economic", "Economic — Negative Prices")
cr3 = SelectItem("transmission", "Transmission Constraint")
cr4 = SelectItem("environmental", "Environmental — Emissions Limit")
cr5 = SelectItem("market", "Market Instruction")
curtDuration = FormControl("Duration", curtDurationSelect, "Expected duration of curtailment")
curtDurationSelect = Select("curtail-duration", [cd1, cd2, cd3, cd4], "Select duration")
cd1 = SelectItem("1h", "1 Hour")
cd2 = SelectItem("4h", "4 Hours")
cd3 = SelectItem("8h", "8 Hours")
cd4 = SelectItem("24h", "24 Hours")