In this section
- 09 Card transform · gridatlas / tools/lightning/src/09-card.js lines 1–99
- 10 Neon render · gridatlas / tools/lightning/src/10-neon.js lines 1–177
- 11 Renewable Energy Planning Database (REPD) Map energy-data · gridatlas / tools/lightning/src/11-repd-map.js lines 1–61
- 11b Renewable Energy Planning Database (REPD) Records energy-data · gridatlas / tools/lightning/src/11b-repd-records.js lines 1–73
- 12 Renewable Energy Planning Database (REPD) energy-data · gridatlas / tools/lightning/src/12-repd.js lines 1–209
09 Card
A JavaScript file in the lightning folder of GridAtlas that works with the Renewable Energy Planning Database (REPD) register.
transformgridatlas / tools/lightning/src/09-card.js · lines 1–99 of 99 · Not reached from any entry point (candidate for review)
- What it does
- It calculates the REPD register. Defines T.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register.
- Inputs & outputs
- Coordinate systems named: WGS84 / EPSG:4326.
- What it achieves
- The docked card (flash, cell or REPD project), the cell card and the short flash ID. It responds to click and toggle events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · tools/lightning/src · script
- Uses
- none found
- Used by
- none found
- Produces
- T
- Defines here
- T
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/lightning/src/09-card.js:1-99 · blob 56eee6691deef7d652147c31bcee4a9ad31c4946 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: transform · effects: none found · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/// 09 card: the docked card (flash, cell or REPD project), the cell card and the short flash ID.
///
/// cd: the card. lb aria label, ti title, su summary, de detail, wh what was tapped ("optical flash" | "cell centre" |
/// "project"); o: np (no REPD list: the project view), open, foot, back [label, action], g (dots: the site to draw).
/// c.re re-opens the same card (for "◀ back"); the title wraps (LR-layout). M2R-layout F3: re-frame on expand, collapse and
/// minimise. M2R-a11y MAJOR-1: one visually hidden polite status region per card, outside the closed <details>.
/// M6 (owner, iPhone 03:05 UTC: "the list is not there"): the list was rendered but inside the collapsed <details>.
/// The card now opens by default (o.open===0 keeps it closed) as a half-height panel (cpos: max 45 % of the map) that
/// scrolls inside; the "−" minimise is replaced by a toggle that says what it does and reflects the real state
/// ("▾ Hide list" / "▸ Show 10 sites"; c.n is the number of listed sites, set by RpR). T: one handler for the button
/// and the details toggle event; it reframes only when the open state really changed (c.dO), so the default open
/// never adds a camera move to the arrival.
cd=(m,x,y,lb,ti,su,de,wh,o={})=>{///
let c=el('div','position:absolute;left:8px;right:8px;z-index:21;max-width:480px;margin:0 auto;box-sizing:border-box;background:#000;color:#e8f4f5;border:1px solid #2f6f75;border-radius:4px;box-shadow:0 0 14px rgba(95,189,194,.25);font:11px/1.45 monospace;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain'),
bar=el('div','display:flex;align-items:center;gap:6px;padding-left:8px;background:#0a1a1d;border-bottom:1px solid #1d3238'),bd=el('div',///
'padding:0 8px 6px'),d=el('details'),rf=()=>{cpos();///
if(S.pp===c)ck(1)},
B=(t,a,f)=>{///
let e=el('button','flex:none;width:44px;height:44px;background:#050a0d;border:1px solid #2f6f75;border-radius:3px;color:#5fbdc2;font:14px/1 monospace;cursor:pointer',t);///
e.type='button';///
e.setAttribute('aria-label',a);///
e.addEventListener('click',f);///
ap(bar,e);///
return e///
};
c.dataset.lightningCard='';///
c.setAttribute('role','dialog');///
c.setAttribute('aria-label',lb);///
c.wh=wh;///
c.o=o;///
c.re=open=>cd(m,x,y,lb,ti,su,de,wh,{...o,open});
ap(bar,el('span','flex:1;min-width:0;color:#5fbdc2;font-weight:bold',ti));
let T=()=>{///
c.u();///
if(d.open!=c.dO){c.dO=d.open;///
rf()}///
},mn=B('','',()=>{///
d.open=!d.open;///
T()///
});///
mn.style.width='auto';///
mn.style.padding='0 8px';///
mn.style.fontSize='12px';///
c.u=(t=d.open?'▾ Hide '+(o.np?'details':'list'):'▸ Show '+(c.n?pl(c.n,'site'):o.np?'details':'list'))=>{///
mn.textContent=t;///
mn.setAttribute('aria-label',t.slice(2));///
mn.setAttribute('aria-expanded',d.open)///
};///
d.addEventListener('toggle',T);///
B('×','Close',///
///#if dots
pc);
///#else
()=>{pc();///
Ry()});
///#endif
c.sm=el('summary','padding:14px 0 13px;line-height:17px;cursor:pointer;color:#bfe9ee',su);ap(d,c.sm);
c.out=el('div','margin-top:4px;color:#9fb3ba');///
ap(d,c.out);///
ap(d,el('div','color:#8b9aa1;font-size:11px;overflow-wrap:anywhere',de));///
if(o.back){///
let k=ap(bd,el('button','display:block;width:100%;min-height:44px;margin:8px 0 2px;background:#050a0d;border:1px solid #2f6f75;border-radius:3px;color:#5fbdc2;font:12px/1 monospace;text-align:left;padding:0 10px;cursor:pointer',o.back[0]));///
k.type='button';///
k.dataset.lightningBack='';///
k.setAttribute('aria-label',o.back[0].slice(2));///
k.addEventListener('click',o.back[1])///
}ap(bd,d);///
c.dO=d.open=o.open!==0;///
c.u();
ap(bd,el('div','color:#8b9aa1;font-size:11px',o.foot||'EUMETSAT MTG Lightning Imager · optical flash, not necessarily a ground strike.'));
ap(c,bar);///
ap(c,bd);///
c.lv=ap(c,el('div','position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)'));///
c.lv.setAttribute('role','status');///
S.pp=c;///
ap(m.getContainer(),c);///
cpos();///
nf(m,c,x,y,15)///
},
/// cb: a cell's south-west corner, only for a well-formed cell of the drawn result (LR-security S2: safe-integer n).
/// cc: the cell card (LR-words W3; M5 V-geometry G3-G4b: "N optical flashes in this 0.1° cell", and the real cell size at
/// this latitude: E–W = 11.156·cos(lat) km (WGS84, max error 2.3 m over the UK rows), N–S ≈ 11.1 km).
cb=p=>{///
let c=p.cell,w=-11+c%140/10,s=49.5+(c-c%140)/1400;///
return c>>>0===c&&c<16800&&Number.isSafeInteger(p.n)&&p.n>0&&p.lon>w&&p.lon<w+.1&&p.lat>s&&p.lat<s+.1&&S.res&&(p.s==null||p.s===S.res.s)?[w,s]:null///
},
cc=(m,p)=>{///
let[w,s]=cb(p),W=S.res.w,r=a=>a.toFixed(2)+'–'+(a+.1).toFixed(2),///
x=11.156*Math.cos(p.lat*Math.PI/180);///
cd(m,p.lon,p.lat,'Lightning cell',pl(p.n,'optical flash','es')+' in this 0.1° cell',///
`${ymd(W.s)} to ${ymd(MX(W.s,W.e-1))} UTC · centre lat ${p.lat.toFixed(3)}, lon ${p.lon.toFixed(3)}`,///
`Cell lat ${r(s)}, lon ${r(w)}: 0.1°, ≈${x.toFixed(1)} km E–W × 11.1 km N–S, ≈${x*11.13+.5|0} km² here; the centre is not a flash location · searched UTC days only; unsearched days ${U}`,'cell centre')///
},
/// sid: short ID = product sensing window + flash index (W_XX-..._<start>_<end>_N__..._0000:<index>); the full ID stays
/// in the detail line.
sid=s=>{///
let r=/_\d{8}(\d\d)(\d\d)\d\d_\d{8}(\d\d)(\d\d)\d\d_N_.*:(\d+)$/.exec(s);///
return r?`${r[1]}:${r[2]}–${r[3]}:${r[4]} #${r[5]}`:s.length>24?s.slice(0,12)+'…'+s.slice(-8):s///
},10 Neon
A JavaScript file in the lightning folder of GridAtlas that maps substations and the Renewable Energy Planning Database (REPD) register.
rendergridatlas / tools/lightning/src/10-neon.js · lines 1–177 of 177 · Not reached from any entry point (candidate for review)
- What it does
- It maps substations and the REPD register. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: substations, the REPD register, 33kV.
- Inputs & outputs
- Voltage levels named: 33kV.
- What it achieves
- 10 nearest substations and the camera: the original's own measure drawn as its neon arrival in Lightning-owned layers, and the framing rules (M2R-layout F1-F3, M2R-camera fix C, M2R-taps T1). Its code works with 33 kV.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · tools/lightning/src · script
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/lightning/src/10-neon.js:1-177 · blob 5b050ea12bfaa4d81a17c93adcc8a5047a5ec304 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/// 10 nearest substations and the camera: the original's own measure drawn as its neon arrival in Lightning-owned layers,
/// and the framing rules (M2R-layout F1-F3, M2R-camera fix C, M2R-taps T1).
///
/// The neon layer and source ids; the REPD ones (p-*) join the set so close, period, LATEST and OFF remove them too (build-M
/// B1; dots adds p-glow, p-dot and the pdots source).
NP='gridatlas-lightning-neon',///
NI=['glow','core','flow','flow-b','node-ring','node','label','pin-halo','pin','p-core','p-node',///
///#if dots
'p-label','p-glow','p-dot'].map(s=>NP+'-'+s),///
///#else
'p-label'].map(s=>NP+'-'+s),///
///#endif
NSR=[NP+'-links',NP+'-nodes',NP+'-pin',NP+'-plinks',///
///#if dots
NP+'-pnodes',NP+'-pdots'],
///#else
NP+'-pnodes'],
///#endif
nc=()=>{///
let m=mh();///
if(S.raf){cancelAnimationFrame(S.raf);///
S.raf=null}if(m)try{///
for(let l of[...NI].reverse())if(m.getLayer(l))m.removeLayer(l);///
for(let s of NSR)if(m.getSource(s))m.removeSource(s)///
}catch(e){note(e)}///
},
/// nr: nearest substations: the original's own measure (__GRIDATLAS_NEON_LINKS__.measure.nearestSubstations: >= 33 kV,
/// <= 40 km, 5 links) drawn as its neon arrival (glow, core, two flow layers, teal nodes, labels, pale origin ring; kv-neon)
/// in Lightning-owned layers, in the technology colour #d8c96a. link.selectAt is not used: it treats its origin as a project
/// (stale project reference, cancelled arrivals, a false arrival record; kv-arrival-api). S.fk: the points to frame.
nr=(m,c,x,y)=>{///
let L=window.__GRIDATLAS_NEON_LINKS__||{},M=L.measure||{},subs=Object.hasOwn(L,'substations')?L.substations:null,say=s=>ap(c.out,el('div','',s));///
c.out.textContent='';///
nc();
if(!AI(subs)||!subs.length||typeof M.nearestSubstations!=='function')return say('Substation data not loaded yet; trying again.'),0;
let k=c.k=M.nearestSubstations(x,y,subs),o=[x,y],TC='#d8c96a',TL='#5fbdc2',FL='#bfe9ee',Z=(a,///
b,h=12)=>['interpolate',['linear'],['zoom'],6,a,h,b],RJ={'line-cap':'round','line-join':'round'},
A=(i,type,source,paint,layout)=>m.addLayer(Object.assign({id:NI[i],type,source,paint},layout?{layout}:{}));///
S.fk=[o,...k.map(a=>a.at)];///
say(c.o.np?'Screening · nearest substations, straight line. Not its declared connection or capacity.':`Screening · nearest substations to this ${c.wh}, straight line. Proximity, not exposure or a current path; not evidence any asset was struck.`);
if(!k.length){///
let b=k.beyondRadiusNearest;///
say(`No substation within ${k.radiusKm||40} km`+(b?` (nearest: ${cs(b.name||'unnamed substation')}, ${(+b.km).toFixed(2)} km)`:''))///
}
for(let a of k)say(`${(+a.km).toFixed(2)} km · ${a.kv[0]} kV · ${cs(a.name||'unnamed substation')}`);
/// The REPD list runs for lightning cards only, never in the project view (build-M2 nr-repd).
if(!c.o.np)Rp(m,c,x,y,M);///
///#if dots
else if(c.o.g)RpD(m,[c.o.g]);if(!k.length)return k;
///#else
if(!k.length)return k;
///#endif
m.addSource(NSR[0],{///
type:'geojson',data:FC(k.map((a,i)=>({///
type:'Feature',properties:{colour:TC,strength:MX(.2,.62-i*.1)},geometry:{type:'LineString',coordinates:[o,a.at]}///
})))///
});
m.addSource(NSR[1],{///
type:'geojson',data:FC(k.map(a=>({///
type:'Feature',properties:{label:`${(+a.km).toFixed(2)} km · ${a.kv[0]} kV`},geometry:{type:'Point',coordinates:a.at}///
})))///
});
A(0,'line',NSR[0],{///
'line-color':['get','colour'],'line-width':Z(5,12),'line-opacity':.1,'line-blur':Z(3,8)///
},RJ);
A(1,'line',NSR[0],{///
'line-color':['get','colour'],'line-width':Z(.9,1.8),'line-opacity':['get','strength']///
},RJ);
A(2,'line',NSR[0],{///
'line-color':FL,'line-width':Z(1.2,2.4),'line-opacity':.8,'line-dasharray':[.2,3.2]///
},{'line-cap':'round'});
A(3,'line',NSR[0],{///
'line-color':FL,'line-width':Z(.9,1.8),'line-opacity':.45,'line-dasharray':[.2,3.2]///
},{'line-cap':'round'});
A(4,'circle',NSR[1],{///
'circle-radius':Z(6,13),'circle-color':'rgba(0,0,0,0)','circle-stroke-color':TL,'circle-stroke-width':1,'circle-stroke-opacity':.4///
});
A(5,'circle',NSR[1],{'circle-radius':Z(2.2,4),'circle-color':TL,'circle-opacity':.8});
try{///
A(6,'symbol',NSR[1],{///
'text-color':'#a9c4c9','text-halo-color':'#000c10','text-halo-width':1.5,'text-opacity':.9///
},{///
'text-field':['get','label'],'text-size':10,'text-offset':[0,-1.5],'text-anchor':'bottom','text-allow-overlap':false,'text-font':sf(m)///
})///
}catch(e){note('neon labels: '+msg(e))}
m.addSource(NSR[2],{///
type:'geojson',data:FC([{///
type:'Feature',properties:{},geometry:{type:'Point',coordinates:o}///
}])///
});
A(7,'circle',NSR[2],{///
'circle-radius':Z(11,26,14),'circle-color':'rgba(0,0,0,0)','circle-stroke-color':TC,'circle-stroke-width':6,'circle-stroke-opacity':.13,'circle-blur':.4///
});
A(8,'circle',NSR[2],{///
'circle-radius':Z(11,26,14),'circle-color':'rgba(0,0,0,0)','circle-stroke-color':'#cfe9ed','circle-stroke-width':1.6,'circle-stroke-opacity':.85///
});
/// Flow: the cartridge's own 24 frozen dash patterns (measure.flowDash) when present; off under reduced motion.
let rm=false;try{rm=matchMedia('(prefers-reduced-motion: reduce)').matches===true}catch(_){}
if(rm){///
m.setPaintProperty(NI[2],'line-opacity',0);///
m.setPaintProperty(NI[3],'line-opacity',0)///
}else if(typeof requestAnimationFrame=='function'){///
let ph=0;///
let fd=typeof M.flowDash=='function'?M.flowDash:p=>{///
let s=Math.floor(p/1.5*24)%24/24*1.5;///
return[.001,MX(.001,s),.42,MX(.001,1.5-s)]///
},mo={},
set=(i,p)=>{///
let d=fd(p),j=d.join();///
if(mo[i]!==j){///
mo[i]=j;///
m.setPaintProperty(NI[i],'line-dasharray',d)///
}///
},st=()=>{///
ph=(ph+.055)%1.5;///
try{set(2,ph);///
set(3,(ph+.75)%1.5)}catch(_){S.raf=null;///
return}S.raf=requestAnimationFrame(st)///
};///
S.raf=requestAnimationFrame(st)///
}
return k},
/// nf: fired on the tap; retried every 2 s (15 times) while the same card is open if the substation list is not loaded yet.
/// The project view always flies to the project, even with no substation within 40 km (build-M2 nf-fly).
nf=(m,c,x,y,n)=>{///
if(S.pp!==c)return;///
let k;///
try{k=nr(m,c,x,y)}catch(e){///
note('nearest: '+msg(e));///
nc();///
c.out.textContent='Substation data unavailable.';///
return cpos()///
}cpos();
if(AI(k)){///
c.sm.textContent+=k.length?` · ${k.length} nearest substations`:` · no substation within ${k.radiusKm||40} km`;///
if(k.length||c.o.np)nz(m,x,y);///
return///
}if(n)setTimeout(()=>nf(m,c,x,y,n-1),2e3)///
},
/// M4 (M2R-taps MAJOR T1): MapLibre 3.6.2's stop() fires moveend synchronously, so a pending once('moveend', ck) ran its
/// fitBounds nested inside the next camera move, left an orphan render frame and froze redraws after fast row/back cycles.
/// cw: the pending framing runs in a microtask after the stop that fired it, only when the map is then not moving.
/// cm: every module camera move first drops the module's pending framing (nz, ck, RpR, the cluster zoom, the fit button).
cw=()=>Promise.resolve().then(()=>{let m=mh();///
m&&!(m.isMoving&&m.isMoving())&&ck()}),///
cm=m=>m.off&&m.off('moveend',cw),
/// nz: the original arrival's flyTo (zoom 12, 1200 ms), then frame at moveend.
nz=(m,x,y)=>{///
try{///
cm(m);///
m.flyTo({center:[x,y],zoom:12,duration:1200,essential:true});///
typeof m.once=='function'?m.once('moveend',cw):ck()///
}catch(e){note('camera: '+msg(e))}///
},
/// ck: frame S.fk when an end is outside the free area (screen pixels: x 20..W-R+20, y T-20..H-B), or always with f === 1
/// (M2R-layout F2). Padding: top 150, sides 40, bottom card + 24 capped at H-270 only when L3's fit is impossible
/// (M2R-diff MD1); docked card (c.sd, fix C): top 60, right card width + 32, bottom 100.
ck=f=>{///
try{///
let m=mh(),c=S.pp,k=S.fk,C=m&&m.getContainer(),H=C&&C.clientHeight||1e4,d=c&&c.sd,B=d?100:c&&(c.bb+c.offsetHeight||196)+24,R=d?c.offsetWidth+32:40,T=d?60:150;///
if(!c||!k||f!==1&&k.every(a=>{///
let p=m.project(a);///
return p.x>=20&&p.x<=(C.clientWidth||1e4)-R+20&&p.y>=T-20&&p.y<=H-B///
}))return;///
let[w,s]=k[0],[e,n]=k[0];///
for(let[a,o]of k){w=MN(w,a);///
e=MX(e,a);///
s=MN(s,o);///
n=MX(n,o)}
cm(m);///
m.fitBounds([[w,s],[e,n]],{///
padding:{///
top:T,left:40,right:R,bottom:d?B:H-150>B?B:MX(0,H-270)///
},maxZoom:12,duration:900///
})///
}catch(e){note('camera: '+msg(e))}///
},11 Renewable Energy Planning Database (REPD) Map
A JavaScript file in the lightning folder of GridAtlas that maps the REPD register, solar, wind and battery storage (BESS).
energy-datagridatlas / tools/lightning/src/11-repd-map.js · lines 1–61 of 61 · Not reached from any entry point (candidate for review)
- What it does
- It maps the REPD register, solar, wind and battery storage (BESS). Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register, solar, wind, battery storage (BESS).
- What it achieves
- M4b: the listed REPD sites, drawn in the original REPD style ---------------------------------------------------- One dot per listed project at its site, with the engine's own paint (`ventus-corev8engine.js`:1305-1337).
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · tools/lightning/src · script
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/lightning/src/11-repd-map.js:1-61 · blob ba4c916a1475544713ffe1bb160b357857a3b20f · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/// 11 REPD on the map, per variant: "layers" switches the listed technologies' own REPD layers on through their Layers
/// checkboxes (M3/M4); "dots" draws only the listed sites as REPD-styled dots and never touches a Layers control (M4b).
///
///#if dots
/* ---- M4b: the listed REPD sites, drawn in the original REPD style ----------------------------------------------------
One dot per listed project at its site, with the engine's own paint (ventus-corev8engine.js:1305-1337): the solar and
rooftop-solar glow by capacity, the capacity-graded core, and each other technology's own layer colour; stacked in the
engine's REPD layer order. Only the sites on the card are drawn; the reader's Layers are never changed. A dot tap opens
that site's project view, as its row does. */
RpO='solar solar_operational solar_roof wind wind_onshore_operational wind_offshore_operational bess bess_operational biomass tidal hydrogen hydro flywheel act geothermal caes'.split(' '),
RpD=(m,P)=>{///
let d=FC(P.flatMap((g,k)=>g.parts.map(p=>({///
type:'Feature',properties:{///
t:p.tech,c:+p.capacity>0?+p.capacity:0,k,o:RpO.indexOf(p.tech)///
},geometry:{type:'Point',coordinates:g.a}///
})))),
T=['get','t'],I=(...a)=>['interpolate',['linear'],['get','c'],...a],R=(r,o)=>['match',T,'solar_roof',r,o];
if(m.getSource(NSR[5]))return m.getSource(NSR[5]).setData(d);m.addSource(NSR[5],{type:'geojson',data:d});
m.addLayer({///
id:NI[12],type:'circle',source:NSR[5],filter:['any',['all',['==',T,'solar'],['>=',['get','c'],4]],['all',['==',T,'solar_roof'],['>=',['get','c'],1]]],
paint:{///
'circle-color':R(I(1,'#ff8c00',5,'#ff6600',10,'#ff4400'),I(4,'#ffff00',20,'#ffaa00',50,'#ff4400',200,'#ff0000')),'circle-radius':R(I(1,26,2,30,5,36,10,44),///
I(4,22,20,32,50,44,200,60,500,80)),
'circle-opacity':R(.15,I(4,.12,20,.18,50,.25,200,.35)),'circle-blur':1,'circle-stroke-width':0}});
m.addLayer({id:NI[13],type:'circle',source:NSR[5],layout:{'circle-sort-key':['get','o']},
paint:{///
'circle-color':['match',T,'solar_roof',I(0,'#ffcc00',.99,'#ffcc00',1,'#ff8c00',5,'#ff6600',10,'#ff4400'),///
'solar',I(0,'#ffff00',20,'#ffcc00',50,'#ffaa00',200,'#ff6600',500,'#ff2200'),
'wind','#00ffff','bess','#ffae00','biomass','#39ff14','tidal','#00bfff','hydrogen','#ffffff','hydro','#00aaff','flywheel','#ff69b4','act','#ff6600','geothermal','#ff3300','caes','#88aaff','#888888'],
'circle-radius':R(I(0,7,.5,7,.99,8,1,16,2,18,5,22,10,28),///
I(0,8,10,10,50,13,200,17,500,22,1000,28)),'circle-stroke-width':R(I(0,1,.99,1,1,2),///
1.5),'circle-stroke-color':'#000','circle-opacity':R(.9,.85)///
}///
})///
},
///#else
/* ---- M3: the REPD map layers of the listed projects ---------------------------------------------------------------
The owner (28 Oct 2026, 21:39 UTC): "auto activate the REPD layers of the targeted 10 nearest projects". Each register
tech is the id of the original's own REPD layer (solar, solar_roof, wind, bess, biomass, …; engine config "REPD (GeoJSON)").
A layer is switched exactly as a tap on its Layers checkbox would: the original #scada-ui-container input is ticked and
a bubbling "change" is dispatched, so the engine's own delegated listener syncs the fullscreen-curtain copy and runs
its handleLayerToggle (visibility + hydration), and the menu bar's document listener syncs its proxy. S.ly holds only
the layers M3 itself switched on; a layer the user already had on is never touched, and a layer the user ticks or
unticks while M3 holds it becomes the user's (bt below). */
RL='solar solar_roof wind bess biomass tidal hydrogen hydro flywheel act geothermal caes'.split(' '),
Ly=(id,on)=>{///
let h=Q('scada-ui-container'),b=h&&h.querySelector(`input[data-layer-id="${id}"]`);///
if(!b||b.disabled||!!b.checked===on)return 0;
S.lyx=1;///
try{///
b.checked=on;///
b.dispatchEvent(new Event('change',{bubbles:true}))///
}catch(e){note('REPD layer '+id+': '+msg(e))}finally{S.lyx=0}return 1///
},
// switch on the layers `need` names that are off, and off every layer M3 switched on that `need` no longer names
Ry=(need=[])=>{///
let o=S.ly||(S.ly=new Set);///
for(let id of[...o])if(!need.includes(id)){o.delete(id);///
Ly(id,false)}
for(let id of need)if(RL.includes(id)&&!o.has(id)&&Ly(id,true))o.add(id)},
///#endif11b Renewable Energy Planning Database (REPD) Records
A JavaScript file in the lightning folder of GridAtlas that reads REPD projects, the REPD register, postcodes and substations, using SHA-256.
energy-datagridatlas / tools/lightning/src/11b-repd-records.js · lines 1–73 of 73 · Not reached from any entry point (candidate for review)
- What it does
- It loads REPD projects, the REPD register, postcodes and substations. Side effects: changes the web page (DOM); uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register, postcodes, substations, 400kV.
- Inputs & outputs
- In: Parquet file repd_projects_202608290716.parquet; JSON file repd_v9_manifest_202608290716.json; DuckDB queries. Voltage levels named: 400kV.
- What it achieves
- 11b M5: the full REPD record of a listed project (owner, 29 Oct 2026 02:21 UTC: "list all 10 sites, their names and distances and full addresses as per REPD following the pattern from the grid engine"). Its code works with 400 kV. It responds to click events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · tools/lightning/src · script
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/lightning/src/11b-repd-records.js:1-73 · blob 110486de6940404e02074140f9778fd2f2e6a9b2 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, storage · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/// 11b M5: the full REPD record of a listed project (owner, 29 Oct 2026 02:21 UTC: "list all 10 sites, their names and
/// distances and full addresses as per REPD following the pattern from the grid engine").
///
/// Source: the SAME file, read the SAME way, as the engine's own project search (atlas/cartridges/
/// 202609071213-place-global-search-v9-5.js:14-17 and :280-310, whose popup at :413-416 is the card pattern:
/// name, technology, MW, "<address> · <postcode> · <county>", "REPD <ref> · <status>"): the pinned
/// data/repd_projects_202608290716.parquet (REPD July 2026 / Q2 extract, DESNZ, published 3 Aug 2026, OGL v3.0;
/// 11,069 rows, one per REPD ref), queried through the page's shared DuckDB runtime (window.__GRIDATLAS_DUCKDB_RUNTIME__,
/// built by the streaming-parquet bridge, prewarmed after 400 kV), only after the pinned manifest's SHA-256 and its
/// parquet identity check out. Only the listed points are queried, on a tap, with the module's 15 s timeout (TMO);
/// rows are cached per point for the page (S.rc), so a filter press or a re-tap reads the cache.
///
/// The join: the map register (src-repd, April 2026) carries no REPD ref and no address. A register part gets a record
/// only when EXACTLY ONE record has: the same point (each axis within 1e-6°), the same name after whitespace collapse,
/// NFC and the cp1252 C1 repair only, the same MW (both <=0/absent = not stated) and the same REPD technology string.
/// Otherwise the card says "address not in register". A ref or an address is never inferred. Over the whole register
/// this joins 10,503 of 10,784 rows and never gives one record to two rows (suite M5-3; evidence/M5-build).
///
/// Reusable (the offtakers overlay): window.__GRIDATLAS_MODULES__.repdRecords = {source, manifest, records, join, block}:
/// records(points [[lon,lat]]) -> Promise<Map "lon,lat" -> record rows at that point>
/// join(registerProps, point, map) -> record | null (no exact single match) | undefined (not loaded yet)
/// block(registerProps, point, map, error) -> the card block (data-tier="record")
RU='https://ventusltd.github.io/gridatlas/data/repd_projects_202608290716.parquet',RM='https://ventusltd.github.io/gridatlas/data/repd_v9_manifest_202608290716.json',RpE=1.000001e-6,RpP=new WeakMap,
/// RpQ: fetch the record rows at the given points (uncached ones only); the SQL holds only numbers from the register.
/// R() keeps its own timer (R-otsec ORS8): with one shared timer, R(R(runtime).then(connect)) cleared the outer timer
/// when the runtime resolved, so a hung connect() never timed out.
RpQ=async pts=>{let C=S.rc||(S.rc=new Map),ks=RpU(pts.filter(a=>a&&a[0]===+a[0]&&a[1]===+a[1]&&!C.has(a+'')),a=>a+''),k;
if(ks.length){let w=window.__GRIDATLAS_DUCKDB_RUNTIME__,R=p=>{let t;return Promise.race([p,new Promise((_,j)=>t=setTimeout(()=>j(new Error(TOE)),TMO))]).finally(()=>clearTimeout(t))};
if(!w)E('the map search runtime has not started; reload the page');
await R(S.rv||(S.rv=gj(RM,'no-store',1).then(async b=>{let o,h=[...new Uint8Array(await window.crypto.subtle.digest('SHA-256',b))].map(x=>(x|256).toString(16).slice(1)).join('');
if(h!='8850567ff9f1d2b6996b4e0d9707320030f3466a0b821cdcfc5325322b8be8c8'||(o=JSON.parse(new TextDecoder().decode(b))).parquet.sha256!='174040c37f3d63742d6fdd7af722a8cfdf3fb53de3ff85ff1142d22fdac4866b')E('REPD manifest is not the pinned one')}).catch(e=>{S.rv=0;throw e})));
k=await R(R(w.promise).then(d=>d.database.connect()));
try{let r=(await R(k.query(`SELECT * FROM read_parquet('${RU}') WHERE ${ks.map(a=>a.split(',')).map(([x,y])=>`(abs(longitude-(${x}))<=${RpE} AND abs(latitude-(${y}))<=${RpE})`).join(' OR ')}`))).toArray().map(o=>o.toJSON?o.toJSON():o);
for(let a of ks){let[x,y]=a.split(',');C.set(a,r.filter(o=>Math.abs(o.longitude-x)<=RpE&&Math.abs(o.latitude-y)<=RpE))}}finally{try{k.close()?.catch?.(()=>0)}catch(_){}}}
return C},
/// RpZ: the name normalisation of the join (whitespace, NFC, cp1252 C1 characters); nothing else.
RpZ=s=>((s||'')+'').replace(/[\x80-\x9f]/g,c=>new TextDecoder('windows-1252').decode(Uint8Array.of(c.charCodeAt()))).normalize('NFC').split(/\s+/).filter(Boolean).join(' '),
/// RpJ: the exact join (see above).
RpJ=(p,a,C)=>{let c=a&&C&&C.get&&C.get(a+''),n=v=>v>0?+v:0;if(!c)return;c=c.filter(o=>RpZ(o.name)==RpZ(p.name)&&Math.abs(n(o.capacity_mw)-n(p.capacity))<1e-6&&o.repd_technology===p.raw_tech);return c.length==1?c[0]:null},
/// RpB: one project's record block in the engine card pattern; missing fields are said, never filled; an operator the
/// record marks as possibly a person (applicant_publication_state != REPD_AS_PUBLISHED) is not shown.
/// M6: a record already cached shows even when a later fetch fails; the failure line is a retry button (RpH).
RpB=(q,a,C,e)=>{let o=RpJ(q,a,C),b=el('div','padding:2px 0 10px 12px;font-size:11px;color:#9fb3ba;overflow-wrap:anywhere'),L=(s,c)=>ap(b,el('div',c,cs(s)));b.dataset.tier='record';
if(o===void 0)L(e?`REPD record unavailable — tap to retry (${msg(e)})`:'loading REPD record…');else if(!o)L('Record · address not in register (no exact REPD match; no ref shown)');
else{L([o.repd_address_display||'address not stated',o.repd_postcode||'no postcode',o.county,o.region].filter(Boolean).join(' · '),'color:#c9d6da');
L(`Record · REPD ${o.repd_ref} · ${o.status}`+(o.status!=q.status?` (map register: ${q.status})`:''));
L('Operator: '+(o.applicant_publication_state=='REPD_AS_PUBLISHED'&&o.repd_operator_or_applicant||'not shown (may name a person) or not stated'));
L([o.planning_authority||'planning authority not stated',o.planning_application_reference,o.source_record_updated&&'record updated '+o.source_record_updated].filter(Boolean).join(' · '))}
return b},
/// RpX: export once, frozen.
RpX=NS.repdRecords||(NS.repdRecords=Object.freeze({source:RU,manifest:RM,records:RpQ,join:RpJ,block:RpB})),
// fill record slots [[div, props]] now from the cache, then again when the rows at their points have arrived
/// M6: the rows never wait: each slot shows "loading REPD record…" at once, then the record, or within 15 s in all
/// (one deadline over manifest, runtime, connect and query) "REPD record unavailable — tap to retry"; a tap retries.
RpH=(c,sl)=>{let t,F=(C,e)=>{clearTimeout(t);///
if(S.pp==c)for(let[s,q]of sl){s.textContent='';///
let b=ap(s,RpB(q,RpP.get(q),C,e));///
if(/^REPD record u/.test(b.textContent)){b.style.cursor='pointer';///
b.setAttribute('role','button');///
b.addEventListener('click',()=>RpH(c,sl))}}///
};F(S.rc);///
Promise.race([RpQ(sl.map(v=>RpP.get(v[1]))),new Promise((_,j)=>t=setTimeout(()=>j(Error(TOE)),TMO))]).then(F,e=>F(S.rc,e))},
// Area summary (Screening): every row within 40 km, all statuses and technologies, by technology and by status class
/// RpY: the Area summary (V-tiers Screening): every register row within 40 km (all statuses and technologies; the
/// list's filters do not apply), counted and its stated MW summed per technology class and per status class at 10 and
/// 40 km (repeated records of one scheme once; * = some capacities not stated); then the nearest substation per voltage
/// among the card's own 5 (c.k from nr). Counts and distances only.
RpY=(c,box)=>{let h=ap(box,el('div','margin-top:8px;color:#5fbdc2','Area summary · Screening · straight line; all statuses and technologies')),g=ap(box,el('div','display:grid;grid-template-columns:auto auto auto;gap:2px 10px;font-size:11px;color:#c9d6da')),C=s=>ap(g,el('span','',s)),u=0,V=new Map;
h.dataset.tier=g.dataset.tier='screening';['','≤10 km','≤40 km'].map(C);
for(let[v,n]of[...RpF.te,...RpF.st])if(v!='all'){let K=d=>{let r=c.rpAll.filter(q=>q.km<=d&&(RpT(q.p.tech)==v||RpS(q.p.status)==v)),w=RpW(r.map(q=>q.p)),z=r.some(q=>!(q.p.capacity>0));u|=z;return r.length+(w>0?' · '+N(w)+' MW':'')+(z?'*':'')},a=K(40);if(a!='0'){C(n);C(K(10));C(a)}}
for(let s of c.k||[])V.has(s.kv[0])||V.set(s.kv[0],s);
if(V.size)ap(box,el('div','margin-top:4px;color:#c9d6da;font-size:11px','Nearest per voltage, of the substations above: '+[...V].sort((a,b)=>b[0]-a[0]).map(([v,s])=>`${v} kV ${(+s.km).toFixed(2)} km`).join(' · ')));
ap(box,el('div','color:#8b9aa1;font-size:11px',(u?'* some capacities not stated: unknown, not zero. ':'')+'Counts and distances only: not capacity, connection feasibility or exposure.'))},12 Renewable Energy Planning Database (REPD)
A JavaScript file in the lightning folder of GridAtlas that maps REPD master, the REPD register, solar and wind.
energy-datagridatlas / tools/lightning/src/12-repd.js · lines 1–209 of 209 · Not reached from any entry point (candidate for review)
- What it does
- It maps REPD master, the REPD register, solar and wind. Side effects: changes the web page (DOM).
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'repd'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register, solar, wind.
- Inputs & outputs
- In: JSON file repd_master.json; DuckDB queries.
- What it achieves
- REPD projects near a tap (M2, M3) -------------------------------------------------------------------------------- The register the map already holds (the engine's src-REPD data when a REPD layer has loaded it, else the engine URL `/dist/repd_master.json` through the untouched bridge). Its code works with 0 MW. It responds to click events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- gridatlas · tools/lightning/src · script
- Uses
- none found
- Used by
- none found
- Produces
- none declared
- Defines here
- none
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- gridatlas@98b5004c5eda9f2ed915fb6fca4b9bbcaa426ca5 tools/lightning/src/12-repd.js:1-209 · blob 1b13855a6f13d9b28937e0e99be4c8d0b4ebcdfc · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
/// 12 REPD projects near a tap (M, M2, M3): the register, the filter chips, the list, the links and the project view.
///
/* ---- REPD projects near a tap (M2, M3) --------------------------------------------------------------------------------
The register the map already holds (the engine's src-repd data when a REPD layer has loaded it, else the engine URL
/dist/repd_master.json through the untouched bridge): REPD, DESNZ, April 2026 (Q1) extract, OGL v3.0. Measured by
straight-line distance from the flash or the cell centre with the original link.measure.distanceKm. Nearest by distance
only: never a claim that a project was struck or affected. */
RG=(m,M)=>S.rg||(S.rg=(async()=>{
let f;try{f=m.getSource('src-repd').serialize().data.features}catch(_){}
// gj: the module's fetch helper (15 s timeout that also covers the body, redirect refusal, "HTTP n")
if(!(f&&f.length))f=(await gj('/dist/repd_master.json')).features;
// a malformed row is skipped, never the whole register; numeric coordinates only; the search registry's Scilly
// placeholder point is dropped should a register ever carry it (0 rows today)
let o=f.map(x=>{///
try{///
let a=M.representativePoint(x.geometry);///
if(a[0]===+a[0]&&a[1]===+a[1]&&!(a[0]==-7.55716&&a[1]==49.766807))return[a,x.properties||{}]///
}catch(_){}return[]///
}).filter(([a,p])=>a&&M.isProjectTech(p.tech));
return o.length?o:E('register empty')})().catch(e=>{S.rg=null;throw e})),
// filter chips: status classes (operational | under or awaiting construction | application submitted) and technology
RpF={st:[['all','All'],['op','Operational'],['cc','Consented'],['pl','Planning']],
te:[['all','All'],['solar','Solar'],['wind','Wind'],['bess','BESS'],['other','Other']]},
// an explicit table: a status the pinned register does not carry (refused, withdrawn, decommissioned…) is in no class
RpS=s=>({///
operational:'op','under construction':'cc','awaiting construction':'cc','application submitted':'pl'///
})[String(s||'').toLowerCase()]||'?',
RpT=t=>/^solar/.test(t)?'solar':/^wind/.test(t)?'wind':/^bess/.test(t)?'bess':'other',
RpN=p=>({solar:'Solar',solar_roof:'Rooftop solar'})[p.tech]||cs(p.raw_tech),
// stated capacity of the parts at one point; repeated records of one scheme (same name, technology and capacity; only
// status or operator differ) count once. A capacity of 0 means "not stated".
RpW=ps=>RpU(ps,p=>p.name+'|'+p.raw_tech+'|'+(p.capacity>0?+p.capacity:0)).reduce((s,k)=>s+ +k.split('|').pop(),0),
RpMW=v=>v>0?` ${N(v)} MW`:'',
RpC=ps=>RpW(ps)>0?'':' · capacity not stated',
RpU=(ps,f)=>[...new Set(ps.map(f))],
// one label per site: projects at one point (e.g. solar + battery) share one link, one node and one label
RpG=g=>`${g.km.toFixed(2)} km · ${RpU(g.parts,RpN).sort().join(' + ')}${RpMW(RpW(g.parts))}`,
// the card's polite status region (outside the closed <details>): one 99 ms delay keeps the messages in order
Ra=(c,s)=>setTimeout(()=>{if(c.lv)c.lv.textContent=s},99),
/// Rp: the REPD list of a lightning card: every register row is measured once (all 10,784 rows), then RpR renders it.
Rp=(m,c,x,y,M)=>{
/// M6: the sites come first in the open card (above the substations); the Area summary and the chips go below (c.b2).
let pd=el('div','','REPD projects: loading…'),box=el('div'),o=c.out;o.insertBefore(box,o.insertBefore(pd,o.children[0]).nextSibling);c.b2=ap(o,el('div'));Ra(c,pd.textContent);
RG(m,M).then(G=>{
if(S.pp!==c||!c.out.contains(pd))return;
// every register row is measured once; exact duplicate rows (same point, same properties) count once
let all=[],seen=new Set;
for(let[a,p]of G){///
let km=M.distanceKm(x,y,...a);///
if(km<=40){///
let k=a+JSON.stringify(p);///
if(!seen.has(k)){seen.add(k);RpP.set(p,a);///
all.push({a,p,km})}///
}///
}
c.rpAll=all;c.fk0=S.fk.slice();c.smb=c.sm.textContent;RpR(m,c,pd,box)
}).catch(e=>{
if(S.pp!==c)return;///
///#if dots
S.rgf=(S.rgf||0)+1;
///#else
Ry();S.rgf=(S.rgf||0)+1;
///#endif
// the bridge keeps a failed DuckDB/manifest start for the page lifetime, so a retry can fail at once: say so
pd.textContent=`REPD projects unavailable: ${msg(e)}. `+(S.rgf>1?'Switch on a REPD layer or reload the page, then tap again.':`Tap the ${c.wh=='cell centre'?'cell':'flash'} again to retry.`);
c.sm.textContent+=' · REPD unavailable';Ra(c,pd.textContent)})},
/// RpR: render the list for the current filter (MR3: ties with the 10th site are kept), the summary, the chips, the rows,
/// the links and the camera. Every filter press re-renders it.
RpR=(m,c,pd,box)=>{
let f=S.rf||(S.rf={st:'all',te:'all'}),o=c.fk0[0],
sel=c.rpAll.filter(r=>(f.st==='all'||RpS(r.p.status)===f.st)&&(f.te==='all'||RpT(r.p.tech)===f.te)),groups=new Map;
// one site per registered point: a row within about 10 m (2e-4° lon, 1e-4° lat) of a nearer row joins its site
for(let r of[...sel].sort((a,b)=>a.km-b.km)){///
let g=[...groups.values()].find(g=>Math.abs(g.a[0]-r.a[0])<2e-4&&Math.abs(g.a[1]-r.a[1])<1e-4);///
if(!g)groups.set(r.a.join(),g={a:r.a,km:r.km,parts:[]});///
g.parts.push(r.p)///
}
// the nearest 10 sites within the filter, plus any site at exactly the 10th site's distance
let P=[...groups.values()].sort((a,b)=>a.km-b.km).filter((g,i,a)=>i<10||g.km==a[9].km),parts=P.reduce((s,g)=>s+g.parts.length,0),
nm=v=>(RpF.st.find(q=>q[0]===v)||RpF.te.find(q=>q[0]===v))[1],all=f.st==='all'&&f.te==='all',
fa=all?'all statuses':[f.st,f.te].filter(v=>v!=='all').map(nm).join(' · '),
n10=sel.filter(r=>r.km<=10),nc10=n10.filter(r=>!(r.p.capacity>0)).length,W=[...groups.values()].reduce((s,g)=>s+(g.km<=10?RpW(g.parts):0),0);
pd.textContent=`Screening · ${P.length?pl(P.length,'nearest REPD site')+(parts>P.length?` (${N(parts)} projects; those at one point grouped)`:''):'No REPD site'} within 40 km of this ${c.wh}, straight line${all?'':` (${fa})`}. Proximity only, not impact; not evidence any project was struck.`;
/// M6: box holds the rows (first, right under the heading), b2 the 10 km line, the Area summary and the chips.
let b2=c.b2;box.textContent=b2.textContent='';
let ol=P.length&&P.length<10?ap(box,el('div','',`Only ${pl(P.length,'site')} within the 40 km search radius${all?'':' for this filter'}.`)).textContent:'';
// unknown is not zero: a project without a stated capacity is never summed as 0 MW
if(sel.length)ap(b2,el('div','margin-top:8px;color:#ffc48a',`Within 10 km: ${pl(n10.length,'project')}${n10.length?' · '+(W>0?`${N(W)} MW stated, ${all?'mixed statuses':fa}`+(nc10?`, ${N(nc10)} not stated`:''):'capacity not stated'):''} · within 40 km: ${pl(sel.length,'project')}`));RpY(c,b2);
for(let[k,defs,lb]of[['st',RpF.st,'Status'],['te',RpF.te,'Tech']]){
let row=ap(b2,el('div','display:flex;flex-wrap:wrap;align-items:center;gap:4px;margin:6px 0 2px'));///
row.setAttribute('role','group');///
row.setAttribute('aria-label','REPD '+lb.toLowerCase()+' filter');
ap(row,el('span','color:#8b9aa1;font-size:11px;min-width:40px',lb));
for(let[v,t]of defs){///
let on=f[k]===v,b=ap(row,el('button',`min-height:44px;padding:0 10px;background:${on?'#2f6f75':'#050a0d'};border:1px solid #2f6f75;border-radius:3px;color:${on?'#e8f4f5':'#5fbdc2'};font:11px/1 monospace;cursor:pointer`,t));
// a press re-renders the chips: focus returns to the chip just pressed
b.type='button';///
b.dataset.lightningRepdFilter=k+':'+v;///
b.setAttribute('aria-pressed',on);///
b.addEventListener('click',()=>{///
if(f[k]!==v&&S.pp===c){///
f[k]=v;///
RpR(m,c,pd,box);///
b2.querySelector(`[data-lightning-repd-filter="${k}:${v}"]`)?.focus?.()///
}///
})///
}}
/// M5: sl collects one record slot per listed project (grouped sites expanded), filled by RpH below.
let sl=[];for(let g of P){
let p=g.parts[0],one=g.parts.length===1,
b=ap(box,el('a','display:block;padding:14px 0 13px;border-top:1px solid #1d3238;color:#ffb27a',`${RpG(g)}${RpC(g.parts)} · ${one?cs(p.status)+' · '+cs(p.name):g.parts.length+' projects at this point:'}`));
// the href keeps the original coordinate deep link (open in a new tab); a plain tap stays in this page
b.href=location.pathname+'?'+new URLSearchParams({///
longitude:g.a[0],latitude:g.a[1],technology:p.tech,project:p.name,capacity_mw:p.capacity,status:p.status///
});
b.addEventListener('click',e=>{///
if(e.ctrlKey||e.metaKey||e.shiftKey||e.button)return;///
if(e.preventDefault)e.preventDefault();///
RpV(m,c,g)///
});
for(let q of g.parts){one||ap(box,el('div','padding:0 0 2px 12px;color:#c9a27e;font-size:11px',`${RpN(q)}${RpMW(+q.capacity)}${RpC([q])} · ${cs(q.status)} · ${cs(q.name)}`));sl.push([ap(box,el('div')),q])}}
/// M5: the Record source line (V-tiers R3 with the two extracts named), then fill the record slots.
ap(box,el('div','margin-top:6px;color:#8b9aa1;font-size:11px','Record · REPD (DESNZ, OGL v3.0): the map register is the Apr 2026 extract; address, ref, operator and planning fields are from the Jul 2026 extract the map\'s project search reads, shown only on an exact point, name, MW and type match. Status as registered, not as built.')).dataset.tier='record';RpH(c,sl);
c.n=P.length;c.u();c.sm.textContent=c.smb+' · '+(P.length?pl(P.length,'nearest REPD site'):'no REPD site within 40 km')+(all?'':` (${fa})`);///
Ra(c,pd.textContent+' '+ol);
///#if dots
/// dots (M4b): keep the drawn list for dot taps and say what the map shows.
c.ps=P;///
if(P.length)ap(box,///
///#else
// M3: the original REPD layers of the listed technologies (within the filter) are on while this list is shown
/// layers (M3): switch on the listed technologies' layers (Ry), name them on the card.
let lt=RpU(P.flatMap(g=>g.parts),q=>q.tech).filter(t=>RL.includes(t)),h=Q('scada-ui-container');///
Ry(lt);///
lt=lt.filter(t=>{///
let b=h&&h.querySelector(`input[data-layer-id="${t}"]`);///
return b&&b.checked///
});
if(lt.length)ap(box,///
///#endif
el('div','margin-top:6px;color:#8b9aa1;font-size:11px',///
///#if dots
'Map: only these sites are drawn, in the REPD layer style; tap a dot for its project view. Your Layers are unchanged.'));
///#else
`REPD map layers on for this list: ${lt.map(t=>{let q=Q('lbl-'+t);return q&&q.getAttribute('data-base-label')||t}).join(', ')}${S.ly.size?' (those switched on here go off when this card closes)':''}`));
///#endif
let C=['interpolate',['linear'],['get','mw'],0,'#ffaa00',50,'#ff4400',200,'#f00'],Z=(a,b)=>['interpolate',['linear'],['zoom'],6,a,12,b],
F=geo=>FC(P.map(g=>({type:'Feature',properties:{mw:RpW(g.parts),label:RpG(g)},geometry:geo(g)}))),
A=(i,type,source,paint,layout)=>m.addLayer(Object.assign({id:NI[i],type,source,paint},layout?{layout}:{})),
ln=F(g=>({type:'LineString',coordinates:[o,g.a]})),nd=F(g=>({type:'Point',coordinates:g.a}));
// a map error while drawing is noted (not shown as a register failure); a half-built set is rebuilt on the next render
try{if(m.getLayer(NI[10])){m.getSource(NSR[3]).setData(ln);m.getSource(NSR[4]).setData(///
///#if dots
nd);RpD(m,P)}
///#else
nd)}
///#endif
else{///
for(let l of NI.slice(9))m.getLayer(l)&&m.removeLayer(l);///
for(let q of NSR.slice(3))m.getSource(q)&&m.removeSource(q);
m.addSource(NSR[3],{type:'geojson',data:ln});m.addSource(NSR[4],{type:'geojson',data:nd});
A(9,'line',NSR[3],{///
'line-color':C,'line-width':Z(1,2),'line-opacity':.8,'line-dasharray':[2,2]///
});///
///#if dots
RpD(m,P);///
A(10,///
///#else
A(10,///
///#endif
'circle',NSR[4],{///
'circle-radius':Z(3,5),'circle-color':C,'circle-stroke-width':1///
});
try{///
A(11,'symbol',NSR[4],{///
'text-color':'#ffc48a','text-halo-color':'#000c10','text-halo-width':1.5///
},{///
'text-field':['get','label'],'text-size':10,'text-offset':[0,1],'text-anchor':'top','text-font':sf(m)///
})///
}catch(e){note('neon labels: '+msg(e))}///
}///
}catch(e){note('project lines: '+msg(e))}
// frame origin, substations and the listed sites; a register that lands mid-move is framed when that move ends
cpos();S.fk=[...c.fk0,...P.map(g=>g.a)];m.isMoving&&m.isMoving()?(cm(m),m.once('moveend',cw)):ck()},
// a row tap stays in this page: fly to the site and draw the original engine's nearest-substation links from it
// (link.measure.nearestSubstations, as for a flash); "◀ back" restores the lightning card as at its tap (collapsed, so the
// camera can frame it), its links and the filter. Both cards arrive collapsed so the neon links stay visible. Focus moves to
///#if dots
// "◀ back" on the project card, and to the restored card's summary after back. The project view draws its own site in the REPD style.
///#else
// "◀ back" on the project card, and to the restored card's summary after back. The REPD layers M3 switched on stay on.
///#endif
/// RpV: the project view of one site (a row or, with dots, a dot tap).
RpV=(m,c,g)=>{
let back=c.re,src=c.wh==='cell centre'?'cell':'flash',[x,y]=g.a,ps=g.parts;
pc();
cd(m,x,y,'REPD project',`REPD · ${RpU(ps,RpN).sort().join(' + ')}${RpMW(RpW(ps))}`,
ps.length>1?`${ps.length} projects at this point · ${RpU(ps,q=>cs(q.name)).join(' / ')}`:`${cs(ps[0].name)} · ${cs(ps[0].status)}`,
ps.map(q=>`${RpN(q)}${RpMW(+q.capacity)}${RpC([q])} · ${cs(q.status)} · ${cs(q.name)}`).join('; ')+` · lat ${y.toFixed(3)}, lon ${x.toFixed(3)} · ${g.km.toFixed(2)} km from the ${c.wh} (straight-line)`,
'project',{///
np:1,///
///#if dots
g,///
///#else
///#endif
foot:'Record · REPD (DESNZ, Apr 2026, OGL v3.0). Status as registered, not as built. Lightning: optical flashes, not ground strikes; not evidence the project was struck.',
back:['◀ back to lightning '+src,()=>{pc();back();S.pp&&S.pp.sm.focus?.()}]});
/// M5: the project view shows each part's record above the substation list (from the cache, or when it arrives).
let o=S.pp.out;RpH(S.pp,ps.map(q=>[o.parentNode.insertBefore(el('div'),o),q]));S.pp.querySelector('[data-lightning-back]')?.focus?.()},