In this section
- Standalone geodesy · stars / library/standalone.mjs lines 4740–5439
Standalone
A JavaScript module in the library folder of Stars that maps Renewable Energy Planning Database (REPD) master and heavy emitters UK, using SHA-256, and uses data from the GridAtlas repository.
Set aside from the main view: A comment at the top of the file says a tool wrote it. (noise-generated, proposed by noise.py). All set-aside files, with reasons. Nothing was deleted.
Evidence
- line 2 comment: // Generated by the modular star 2026-12-05T23:26:43.596Z. Each export is one family's earliest-seen copy, unchanged; the comment links its source.
geodesystars / library/standalone.mjs · lines 4740–5439 of 12585 (continued from section 1562) · Entry point · pattern segmentConductors (shared by 2 files)
- What it does
- It maps REPD master, heavy emitters UK, notice and substations. Defines 1111 functions or classes, including f1586_invariant, f8767_representativePoint, f8768_voltagesKv, f8772_voltageOf, f8773_ratingsOf. Side effects: changes the web page (DOM); reads or writes files; makes network requests; uses storage (browser storage, DuckDB or Parquet).
- Why it exists in the grid workflow
- Domain terms in the code: substations, 750kV, 400kV, 275kV, 132kV, 66kV.
- Inputs & outputs
- In: data source: gridatlas data; JSON file repd_master.json; JSON file heavy_emitters_uk.json; JSON file notice.json; form fields (user input). Out: canvas drawing. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326. Voltage levels named: 750kV, 400kV, 275kV, 132kV, 66kV, 33kV, 1.5kV, 1500V.
- Downstream impact
- Used directly by 4 files: Code (stars, https://ventusltd.github.io/stars/code.html); Proof (stars); Modular Star Workflow (stars); Testcode — Code Record Page (globalgrid2050, https://globalgrid2050.com/testcode/202609141754/code-record/). Reached from 383 other entry points, including Code Generator — Index Page (code-generator, https://ventusltd.github.io/code-generator/); Generate (code-generator, https://ventusltd.github.io/code-generator/); 404 (galaxies-wafers, https://ventusltd.github.io/galaxies-wafers/404.html).
- What it achieves
- It snaps coordinate (`snapCoordinate`), paints cursor (`paintCursor`) and sets plan (`setPlan`). Compiled library of self-contained JavaScript functions that appear in two or more places across Ventusltd code. Its code works with 33 kV, 132 kV and 275 kV. It responds to abort events.
- Why it matters
- Loaded by the Code page at https://ventusltd.github.io/stars/code.html and 1 other page. Run by Proof and Modular Star Workflow.
- Application
- stars · library · JavaScript module
- VEDIC
- MEASURE (GG2050-VEDIC-000001): GridAtlas / Geodesy · Mathematics / Spherical geometry. coordinate_pair, coordinate_pair → distance_km
- VEDIC
- REPRESENT (GG2050-VEDIC-000002): GridAtlas / Geodesy · Computer science / Geometry processing. geojson_geometry → coordinate_pair_or_null
- VEDIC
- VOLTAGE (GG2050-VEDIC-000003): GridAtlas / Geodesy · Computer science / Data normalisation. voltage_properties → kilovolt_list
- Uses
- GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL), Declared Connections (estate URL)
- Used by
- named by URL in Code (estate URL), run by Proof (script call), run by Modular Star Workflow (workflow run), named by URL in Testcode — Code Record Page (estate URL)
- Produces
- f1586_invariant, f8767_representativePoint, f8768_voltagesKv, f8772_voltageOf, f8773_ratingsOf, f8775_parametersOf, f5168_escapeHTML, f8321_suppliedArrivalFields, f8850__anonymous_, f8786_crossing, f8788_legality, f8789_startNodes
- Defines here
- f150797_clip, f150798_wcsUrl, f150800_cellSha256, f150808_synthTiff, f150817_gridRef, pad, f150825_kindOf, f150826_provOf, f150827_labelOf, f150829_hull, f150832_kvText, f5330_snapLines, f150888_summary, f150906_keptSay, f150923_clearance, f150928_edgesOf, f150929_hull, cr, f150931_holesOf, f150940_partial, f150949_rowsLine, f151379_rowAxis, f151380_stripStep, f151388_routeEnds, alone, f151390_outlineLines, f151392_dashed, f19065_bindFocusBoundary, items, handle
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- stars@030ebc202d35959fecd162327892f671d1d9a0cc library/standalone.mjs:4740-5439 · blob fc3d8c8b93e14d4a56b8a26da47071d60bc5bc4d · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network, storage · domain stage: unknown · users: none · canonical: unknown
// Family #150797 · element #150797 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/lidar-stream/r5.mjs#L35-L39
export const f150797_clip = function clip(t, env) {
const e0 = Math.max(t.e0, Math.ceil(env.e0)), n0 = Math.max(t.n0, Math.ceil(env.n0));
const e1 = Math.min(t.e1, Math.floor(env.e1)), n1 = Math.min(t.n1, Math.floor(env.n1));
return e1 > e0 && n1 > n0 ? { e0, n0, e1, n1 } : null;
};
// Family #150798 · element #150798 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/lidar-stream/r5.mjs#L40-L43
export const f150798_wcsUrl = function wcsUrl(src, b) {
return `${src.url}?service=WCS&version=2.0.1&request=GetCoverage&CoverageId=${src.coverage}` +
`&subset=E(${b.e0},${b.e1})&subset=N(${b.n0},${b.n1})&format=image/tiff`;
};
// Family #150800 · element #150800 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/lidar-stream/r5.mjs#L67-L72
export const f150800_cellSha256 = async function cellSha256(data, subtle) {
const u = new Uint8Array(data.length * 4), dv = new DataView(u.buffer);
for (let i = 0; i < data.length; i++) dv.setFloat32(i * 4, data[i], true);
const d = await subtle.digest('SHA-256', u);
return [...new Uint8Array(d)].map(x => x.toString(16).padStart(2, '0')).join('');
};
// Family #150808 · element #150808 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/lidar-stream/r5.mjs#L167-L186
export const f150808_synthTiff = function synthTiff(west, north, w, h, fn, nodata = '-3.4028234663852886E38') {
const nd = nodata == null ? null : nodata + '\0';
const tags = [[256, 4, [w]], [257, 4, [h]], [258, 3, [32]], [259, 3, [1]], [262, 3, [1]], [273, 4, [0]], [277, 3, [1]],
[278, 4, [h]], [279, 4, [w * h * 4]], [339, 3, [3]], [33550, 12, [1, 1, 0]], [33922, 12, [0, 0, 0, west, north, 0]]];
if (nd) tags.push([42113, 2, [...nd].map(c => c.charCodeAt(0))]);
const sz = { 2: 1, 3: 2, 4: 4, 12: 8 }, ifdAt = 8, ifdLen = 2 + tags.length * 12 + 4;
let extra = ifdAt + ifdLen;
const ext = tags.map(([, t, v]) => { const n = sz[t] * v.length; if (n <= 4) return -1; const a = extra; extra += n; return a; });
const pix = extra, buf = new ArrayBuffer(pix + w * h * 4), dv = new DataView(buf);
dv.setUint8(0, 0x4d); dv.setUint8(1, 0x4d); dv.setUint16(2, 42); dv.setUint32(4, ifdAt); dv.setUint16(ifdAt, tags.length);
tags.forEach(([tag, t, v], k) => {
const p = ifdAt + 2 + k * 12, vals = tag === 273 ? [pix] : v;
dv.setUint16(p, tag); dv.setUint16(p + 2, t); dv.setUint32(p + 4, vals.length);
let at = ext[k] < 0 ? p + 8 : ext[k];
if (ext[k] >= 0) dv.setUint32(p + 8, at);
for (const x of vals) { if (t === 2) dv.setUint8(at, x); else if (t === 3) dv.setUint16(at, x); else if (t === 4) dv.setUint32(at, x); else dv.setFloat64(at, x); at += sz[t]; }
});
for (let j = 0; j < h; j++) for (let i = 0; i < w; i++) dv.setFloat32(pix + (j * w + i) * 4, fn(i, j));
return new Uint8Array(buf);
};
// Family #150817 · element #150817 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/menu-bar.js#L253-L260
export const f150817_gridRef = function gridRef(e, n) {
const e1 = Math.floor(e / 1e5), n1 = Math.floor(n / 1e5);
if (e1 < 0 || e1 > 6 || n1 < 0 || n1 > 12) return '';
let l1 = (19 - n1) - (19 - n1) % 5 + Math.floor((e1 + 10) / 5), l2 = (19 - n1) * 5 % 25 + e1 % 5;
if (l1 > 7) l1++; if (l2 > 7) l2++;
const pad = v => String(Math.floor((v % 1e5) / 10)).padStart(4, '0');
return String.fromCharCode(65 + l1, 65 + l2) + ' ' + pad(e) + ' ' + pad(n);
};
// Family #150825 · element #150825 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/plan-view.js#L39-L41
export const f150825_kindOf = b => b.scannerRows ? (b.registerPoint ? 'register-point' : 'scanner-rows') : b.gpuRows ? 'gpu-rows' : b.rowsGeometry ? 'rows-geometry'
: b.procedural ? 'procedural' : b.pylonsReal ? 'pylons' : b.substation !== undefined ? 'substation' : b.lidarStream ? 'lidar-stream'
: b.trench || b.kind === 'trench' ? 'trench' : b.plant ? 'plant' : 'other';
// Family #150826 · element #150826 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/plan-view.js#L45-L51
export const f150826_provOf = function provOf(b) {
const p = typeof b.prov === 'string' ? b.prov : '';
if (b.registerPoint) return 'documented';
if (/measur/i.test(p) || b.lidar || b.lidarStream) return 'measured';
if (b.est || b.procedural || b.sat || b.gpuRows || b.scannerRows || b.designPlant || b.built || /estimat|assum|derived/i.test(p)) return 'estimated';
return 'documented';
};
// Family #150827 · element #150827 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/plan-view.js#L52-L65
export const f150827_labelOf = function labelOf(b) {
if (b.designPlant) return 'design ' + b.designPlant + ' (imagined)';
if (b.built) return 'block (imagined)';
if (b.scannerRows && b.registerPoint) return b.scannerRows + ' register point';
if (b.scannerRows) return 'rows, scanner (estimated)';
if (b.procedural) return 'procedural ' + b.procedural + ' (estimated)';
if (b.gpuRows) return 'rows, GPU (estimated)';
if (b.rowsGeometry) return 'rows (estimated)';
if (b.substation !== undefined) return ''; // substations are labelled from their mapped points
if (b.bund) return 'bund ' + b.bund;
if (b.trench || b.kind === 'trench') return 'trench';
if (b.plant) return 'solar plant outline (mapped)';
return '';
};
// Family #150829 · element #150829 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/plan-view.js#L98-L104
export const f150829_hull = function hull(P) { // monotone chain, closed ring
const p = P.slice().sort((a, b) => a[0] - b[0] || a[1] - b[1]), cr = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
const lo = [], up = [];
for (const q of p) { while (lo.length > 1 && cr(lo[lo.length - 2], lo[lo.length - 1], q) <= 0) lo.pop(); lo.push(q); }
for (let i = p.length - 1; i >= 0; i--) { const q = p[i]; while (up.length > 1 && cr(up[up.length - 2], up[up.length - 1], q) <= 0) up.pop(); up.push(q); }
const r = lo.slice(0, -1).concat(up.slice(0, -1)); r.push(r[0]); return r;
};
// Family #150832 · element #150832 · 11 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/plan-view.js#L174-L177
export const f150832_kvText = function kvText(v) {
const l = String(v || '').split(/[;,]/).map(s => Math.round(+s / 1000)).filter(x => x > 0).sort((a, b) => b - a);
return l.length ? Array.from(new Set(l)).join('/') + ' kV' : '';
};
// Family #5330 · element #5330 · 10 places in 2 repositories · https://github.com/Ventusltd/code-generator/blob/3897d83efcd0259d21dce87704b0c33118fe2c2e/apps/substation-finder/Si/index.html#L1766-L1787
export const f5330_snapLines = function snapLines(features, subs) {
if (!subs || !subs.length) return features;
const tol = 0.05, rad = Math.PI / 180;
features.forEach(f => {
const c = f.geometry && f.geometry.coordinates;
if (!c || c.length < 2) return;
[0, c.length - 1].forEach(i => {
let best = c[i], min = Infinity;
const latCos = Math.cos(c[i][1] * rad);
subs.forEach(s => {
const sc = s.geometry && s.geometry.coordinates;
if (!sc) return;
const dx = (c[i][0] - sc[0]) * latCos;
const dy = (c[i][1] - sc[1]);
const d = (dx * dx) + (dy * dy);
if (d < min && d < tol * tol) { min = d; best = sc; }
});
c[i] = best;
});
});
return features;
};
// Family #150888 · element #150888 · 10 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/lidar-stream.js#L36-L41
export const f150888_summary = function summary(t) {
if (!t) return 'measured ground: arrive somewhere to stream its tile';
const at = `tile ${t.tile.e0}/${t.tile.n0}`, d = t.dtm;
if (d && d.sha) return `measured ground: EA LiDAR 1 m, ${at}, receipt ${d.sha.slice(0, 8)}${t.dsm && t.dsm.sha ? '' : t.status && t.status !== 'complete' ? ` (${t.status})` : ''}`;
return `measured ground: ${at}, ${t.status || (d && d.none) || 'waiting'}`;
};
// Family #150906 · element #150906 · 10 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/procedural.js#L15-L19
export const f150906_keptSay = function keptSay(kept, inZones) {
const z = Number(inZones || 0).toLocaleString('en-GB');
if (!(kept > 0)) return `no tables lost to the line (the ${z} positions inside the line zones were placed on free ground in the box; illustrative)`;
return `${kept.toLocaleString('en-GB')} fewer tables drawn than without the line (${z} positions inside the line zones left empty, the rest placed on free ground in the box; illustrative)`;
};
// Family #150923 · element #150923 · 9 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/ac-trenches.js#L22-L26
export const f150923_clearance = function clearance(D, d) { // mm; triangular (J < 2.5): Southwire eq. 7-24; cradled: bottom cable at the invert, two on the wall touching it
const J = D / d;
if (J < 2.5) { const x = d / (D - d); return D / 2 - 1.366 * d + (D - d) / 2 * Math.sqrt(Math.max(0, 1 - x * x)); }
const a = D / 2 - d / 2, y = (d * d - 2 * a * a) / (2 * a); return D / 2 - (y + d / 2);
};
// Family #150928 · element #150928 · 9 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/ac-trenches.js#L59-L61
export const f150928_edgesOf = function edgesOf(d, c) {
return c.edges.map(r => { const V = []; for (let k = 6; k < r.length; k += 2) V.push([r[k], r[k + 1]]); return { si: r[0], kind: r[1], n: r[2], avail: r[3], L0: r[4], fault0: !!(r[5] & 1), rowx: !!(r[5] & 2), V }; });
};
// Family #150929 · element #150929 · 9 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/ac-trenches.js#L62-L68
export const f150929_hull = function hull(pts) {
const Pp = pts.slice().sort((p, q) => p[0] - q[0] || p[1] - q[1]); if (Pp.length < 3) return Pp;
const cr = (o, a, b) => (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]), lo = [], up = [];
for (const p of Pp) { while (lo.length >= 2 && cr(lo[lo.length - 2], lo[lo.length - 1], p) <= 0) lo.pop(); lo.push(p); }
for (let i = Pp.length - 1; i >= 0; i--) { const p = Pp[i]; while (up.length >= 2 && cr(up[up.length - 2], up[up.length - 1], p) <= 0) up.pop(); up.push(p); }
return lo.slice(0, -1).concat(up.slice(0, -1));
};
// Family #150931 · element #150931 · 9 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/ac-trenches.js#L85-L92
export const f150931_holesOf = function holesOf(d, c) { // hole / port positions for a case: evenly spread along the wall (or over its clear stretches, ports.t), one per duct (A) or circuit (B)
const out = [];
for (const p of c.ports) {
const B = d.bunds[p.si], w = B.walls.find(x => x.side === p.side); if (!w) continue;
for (let h = 0; h < p.nh; h++) { const t = p.t && p.t[h] != null ? p.t[h] : (h + 0.5) / p.nh; out.push({ si: p.si, side: p.side, i: h + 1, nh: p.nh, en: [w.p0[0] + (w.p1[0] - w.p0[0]) * t, w.p0[1] + (w.p1[1] - w.p0[1]) * t], out: w.out, clear: p.clear[h] }); }
}
return out;
};
// Family #150940 · element #150940 · 9 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/ac-trenches.js#L224-L230
export const f150940_partial = function partial(V, f) { // leading fraction f of polyline V (by length)
if (f >= 1) return V; if (f <= 0) return [V[0]];
let tot = 0; const L = []; for (let k = 1; k < V.length; k++) { const l = Math.hypot(V[k][0] - V[k - 1][0], V[k][1] - V[k - 1][1]); L.push(l); tot += l; }
let rem = tot * f; const out = [V[0]];
for (let k = 1; k < V.length; k++) { if (rem >= L[k - 1]) { out.push(V[k]); rem -= L[k - 1]; } else { const t = rem / L[k - 1]; out.push([V[k - 1][0] + (V[k][0] - V[k - 1][0]) * t, V[k - 1][1] + (V[k][1] - V[k - 1][1]) * t]); break; } }
return out;
};
// Family #150949 · element #150949 · 9 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/ac-trenches.js#L362-L372
export const f150949_rowsLine = function rowsLine(T) { // shown whenever it is not 0 (closed table mask: rows, table-end blobs and the seams between them)
const a = [];
if (T.rows_crossed) a.push(`${T.rows_crossed} trench chains (${T.rows_crossed_m} m) at ${T.rows_crossed_stations} stations`);
if (T.rows_crossed_entry) a.push(`${T.rows_crossed_entry} entry legs (${T.rows_crossed_entry_m} m) at ${T.entry_crossed_stations} stations`);
if (T.seam_img_runs) a.push(`${T.seam_img_runs} chain runs (${T.seam_img_m} m) 1.5 m or more inside visible panel`);
const b = []; // fix round 2: chain runs on imagery that looks like panel but is not in the table mask (not proven clear)
if (T.panel_runs) b.push(`${T.panel_runs} chain runs of 2 m or more (${T.panel_m} m) on unmasked panel-coloured ground at ${T.panel_stations} stations`);
if (T.dark_runs) b.push(`${T.dark_runs} chain runs over 1 m (${T.dark_m} m) on unmasked dark non-green ground at ${T.dark_stations} stations`);
return (a.length ? `ROWS CROSSED: ${a.join('; ')} (magenta). ` : 'Rows crossed: 0 (closed table mask). ') +
(b.length ? `NOT PROVEN CLEAR: ${b.join('; ')} (magenta). ` : 'Chain runs on unmasked panel-coloured or dark ground: 0. ');
};
// Family #151379 · element #151379 · 8 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/tables.js#L39-L43
export const f151379_rowAxis = function rowAxis(runs) { // mean run direction, radians east of north (axial)
let sx = 0, sy = 0;
for (const [ax, ay, bx, by] of runs) { let dx = bx - ax, dy = by - ay; const l = Math.hypot(dx, dy); if (!(l > 0)) continue; if (dy < 0) { dx = -dx; dy = -dy; } sx += dx / l; sy += dy / l; }
return Math.atan2(sx, sy);
};
// Family #151380 · element #151380 · 8 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/tables.js#L46-L49
export const f151380_stripStep = function stripStep(us) { // the sampling step across the rows: median positive gap between distinct u
const s = us.slice().sort((a, b) => a - b), g = []; for (let i = 1; i < s.length; i++) { const d = s[i] - s[i - 1]; if (d > 0.3) g.push(d); }
g.sort((a, b) => a - b); return g.length ? g[g.length >> 1] : 2.2383;
};
// Family #151388 · element #151388 · 8 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/tables.js#L154-L162
export const f151388_routeEnds = function routeEnds(doc, caseKey = 'A4', tol = 0.3) {
const c = doc.cases[caseKey]; if (!c) return []; const ends = [];
for (const r of c.edges) { const V = []; for (let i = 6; i < r.length; i += 2) V.push([r[i], r[i + 1]]); if (V.length) ends.push({ p: V[0], r }, { p: V[V.length - 1], r }); }
const bins = new Map(), key = (x, y) => Math.floor(x) + ',' + Math.floor(y);
for (const e of ends) { const k = key(e.p[0], e.p[1]); (bins.get(k) || bins.set(k, []).get(k)).push(e); }
const alone = e => { const fx = Math.floor(e.p[0]), fy = Math.floor(e.p[1]);
for (let i = -1; i <= 1; i++) for (let j = -1; j <= 1; j++) { const b = bins.get((fx + i) + ',' + (fy + j)); if (b) for (const o of b) if (o !== e && Math.hypot(o.p[0] - e.p[0], o.p[1] - e.p[1]) < tol) return false; } return true; };
return ends.filter(e => e.r[1] === 'c' && e.r[2] === 1 && alone(e)).map(e => e.p);
};
// Family #151390 · element #151390 · 8 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/tables.js#L175-L180
export const f151390_outlineLines = function outlineLines(shape, s) {
const { depth, ridge, halfRidgeGap: g } = shape, L = [], span = shape.span;
for (const side of [-1, 1]) { const xl = side * (g + depth), xr = side * g;
L.push([xl, 0, s.height, xl, span, s.height], [xr, 0, ridge, xr, span, ridge], [xl, 0, s.height, xr, 0, ridge], [xl, span, s.height, xr, span, ridge]); }
return L;
};
// Family #151392 · element #151392 · 8 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/tables.js#L189-L192
export const f151392_dashed = function dashed(L, a, b, dash) { // an assumed member drawn as short dashes (the ghost of a single-colour wire)
const d = Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]), n = Math.max(1, Math.round(d / dash));
for (let k = 0; k < n; k += 2) { const t0 = k / n, t1 = Math.min(1, (k + 1) / n); L.push([a[0] + (b[0] - a[0]) * t0, a[1] + (b[1] - a[1]) * t0, a[2] + (b[2] - a[2]) * t0, a[0] + (b[0] - a[0]) * t1, a[1] + (b[1] - a[1]) * t1, a[2] + (b[2] - a[2]) * t1]); }
};
// Family #19065 · element #19065 · 6 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609051936/tool-layers/focus-boundary.js#L2-L21
export const f19065_bindFocusBoundary = function bindFocusBoundary(layer, frame, close) {
let child;
const items = () => [...(child?.querySelectorAll('a[href],button,input,select,textarea,[tabindex]') || [])]
.filter(node => !node.disabled && node.tabIndex >= 0 && !node.closest('[inert]') && node.getClientRects().length && child.defaultView.getComputedStyle(node).visibility !== 'hidden');
const handle = event => {
if(event.key !== 'Tab' || event.defaultPrevented || layer.style.display === 'none' || !child) return;
const nodes=items(), first=nodes[0], last=nodes.at(-1);
let target;
if(event.target===close) target=event.shiftKey ? last : first;
else if(event.shiftKey && event.target===first || !event.shiftKey && event.target===last) target=close;
if(event.target===close && !target) target=close;
if(target) {event.preventDefault();target.focus();}
};
const loaded = () => {
child?.removeEventListener('keydown',handle); child=undefined;
try {child=frame.contentDocument;child?.addEventListener('keydown',handle);} catch { /* Parent close remains keyboard accessible after cross-origin navigation. */ }
};
layer.addEventListener('keydown',handle);frame.addEventListener('load',loaded);
return () => {child?.removeEventListener('keydown',handle);layer.removeEventListener('keydown',handle);frame.removeEventListener('load',loaded);};
};
// Family #19445 · element #19445 · 6 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609051940/tool-layers/readiness.js#L2-L22
export const f19445_inspectToolReadiness = function inspectToolReadiness(id, doc) {
if(!doc || doc.readyState !== 'complete') return {interface:'loading',drawing:'pending',label:'Loading tool'};
if(id==='module-layout') {
const ready=doc.querySelector('#ml_status')?.textContent.includes('Ready. Draw at map centre or pick a site.');
return {interface:'loaded',drawing:ready?'ready':'pending',label:ready?'Map ready':'Loading map'};
}
if(id==='cable-geometry-visualiser') {
const canvases=[...doc.querySelectorAll('canvas')];
const expected=['formation_canvas','trench_canvas','bend_canvas'];
const ready=canvases.length===3 && expected.every(id=>canvases.some(c=>c.id===id)) && canvases.every(canvas=>{
try {const bytes=canvas.getContext('2d').getImageData(0,0,canvas.width,canvas.height).data;
let opaque=0;const colors=new Set();
for(let i=0;i<bytes.length;i+=64) if(bytes[i+3]) {opaque++;colors.add(bytes[i]+','+bytes[i+1]+','+bytes[i+2]);}
return opaque>=8 && colors.size>=2;
} catch {return false;} return false;
});
return {interface:'loaded',drawing:ready?'ready':'pending',label:ready?'Drawings ready':'Loading drawings'};
}
if(id==='gis-sld-financial-sandbox' && doc.querySelector('#btn_draw')) return {interface:'loaded',drawing:'unreported',label:'Interface loaded'};
return {interface:'unrecognised',drawing:'unreported',label:'Tool interface not recognised'};
};
// Family #145455 · element #145455 · 5 places in 2 repositories · https://github.com/Ventusltd/graphics-engines-open-source/blob/79e0bd8ee33844835e553fc84d552b6aa1521152/web/versions/202609262227-site-world/world/trench.mjs#L299-L311
export const f145455_composeGround = function composeGround(groundAt, trenches) {
const list = [...trenches];
return function heightAt(x, y) {
let z = groundAt(x, y);
for (const t of list) {
const b = t.bbox;
if (x < b.minX || x > b.maxX || y < b.minY || y > b.maxY) continue;
const c = t.cutHeight(x, y, groundAt);
if (c < z) z = c;
}
return z;
};
};
// Family #145457 · element #145457 · 5 places in 2 repositories · https://github.com/Ventusltd/graphics-engines-open-source/blob/79e0bd8ee33844835e553fc84d552b6aa1521152/web/versions/202609262227-site-world/world/trench.mjs#L316-L343
export const f145457_spoilStrips = function spoilStrips(path, width, depth, g, { nt = 6, du = 0.25 } = {}) {
const p = [];
for (const q of path) { const l = p[p.length - 1]; if (!l || Math.hypot(q[0] - l[0], q[1] - l[1]) > 1e-6) p.push([+q[0], +q[1]]); }
const segs = [];
for (let i = 0; i < p.length - 1; i++) {
const len = Math.hypot(p[i + 1][0] - p[i][0], p[i + 1][1] - p[i][1]);
segs.push({ a: p[i], dx: (p[i + 1][0] - p[i][0]) / len, dy: (p[i + 1][1] - p[i][1]) / len, len });
}
const bis = (s, t) => { const x = s.dx + t.dx, y = s.dy + t.dy, l = Math.hypot(x, y); return l < 1e-6 ? [s.dx, s.dy] : [x / l, y / l]; };
let vol = 0;
segs.forEach((s, i) => {
const nx = -s.dy, ny = s.dx;
const mS = i === 0 ? null : bis(segs[i - 1], s), mE = i === segs.length - 1 ? null : bis(s, segs[i + 1]);
for (let k = 0; k < nt; k++) {
const t = ((k + 0.5) / nt - 0.5) * width;
const u0 = mS ? -t * (nx * mS[0] + ny * mS[1]) / (s.dx * mS[0] + s.dy * mS[1]) : 0;
const u1 = mE ? s.len - t * (nx * mE[0] + ny * mE[1]) / (s.dx * mE[0] + s.dy * mE[1]) : s.len;
const m = Math.max(1, Math.ceil((u1 - u0) / du)), h = (u1 - u0) / m;
for (let j = 0; j < m; j++) {
const u = u0 + (j + 0.5) * h, uc = Math.min(Math.max(u, 0), s.len);
const x = s.a[0] + s.dx * u + nx * t, y = s.a[1] + s.dy * u + ny * t;
const floor = g(s.a[0] + s.dx * uc, s.a[1] + s.dy * uc) - depth;
vol += Math.max(0, g(x, y) - floor) * h;
}
}
});
return vol * width / nt;
};
// Family #151384 · element #151384 · 5 places in 2 repositories · https://github.com/Ventusltd/energy-transition-simulator/blob/a165ce6d56cb22271828874d68d570e8fa5e428a/prototype/mod/tables.js#L112-L118
export const f151384_coverage = function coverage(t, raster, halfW) {
const { occ, step, CELL, colU } = raster, a = Math.floor(t.v0 / CELL), b = Math.ceil((t.v0 + t.span) / CELL) - 1; let sum = 0, n = 0;
for (let vi = a; vi <= b; vi++) { const w = Math.min(t.v0 + t.span, (vi + 1) * CELL) - Math.max(t.v0, vi * CELL); if (w <= 0) continue; n += w; const set = occ.get(vi); if (!set) continue; let cov = 0;
for (const c of set) { const uc = colU(c), o = Math.min(uc + step / 2, t.u + halfW) - Math.max(uc - step / 2, t.u - halfW); if (o > 0) cov += o; }
sum += w * Math.min(1, cov / (2 * halfW)); }
return n ? sum / n : 0;
};
// Family #1803 · element #1803 · 3 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/pipelinenews_intelligence/202608311530/assets/202608311530-grid-proximity.mjs#L238-L242
export const f1803_value = (r, k) => (
k === "_ckm" ? (r.circuit ? r.circuit.km : Infinity)
: k === "_ckv" ? (r.circuit ? r.circuit.kv : -1)
: k === "_skm" ? (r.substation ? r.substation.km : Infinity)
: r[k]);
// Family #130065 · element #130065 · 3 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/build_state.mjs#L59-L70
export const f130065_mapLimit = async function mapLimit(items, limit, fn) {
const out = new Array(items.length);
let next = 0;
async function worker() {
while (next < items.length) {
const i = next++;
out[i] = await fn(items[i], i);
}
}
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
return out;
};
// Family #130066 · element #130066 · 3 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/build_state.mjs#L75-L86
export const f130066_parseConductionBand = function parseConductionBand(md) {
const start = md.indexOf('\n## Conduction band');
if (start < 0) return [];
const end = md.indexOf('\n## ', start + 1);
const section = md.slice(start, end < 0 ? undefined : end);
const out = [];
for (const line of section.split('\n')) {
const m = /^- \*\*#(\d+) (.+?)\*\*/.exec(line);
if (m) out.push({ n: +m[1], name: m[2] });
}
return out;
};
// Family #752 · element #752 · 2 places in 2 repositories · https://github.com/Ventusltd/cvaa/blob/d26ebbad634c20a98e05716873d84fabd87a742a/inoculate.mjs#L25-L31
export const f752_frontMatter = function frontMatter(text) {
const m = text.match(/^---\n([\s\S]*?)\n---/);
if (!m) return null;
const meta = {};
for (const line of m[1].split('\n')) { const k = line.match(/^(\w+):\s*"?([^"#]*?)"?\s*(#.*)?$/); if (k) meta[k[1]] = k[2].trim(); }
return meta;
};
// Family #1289 · element #76402 · 2 places in 2 repositories · https://github.com/Ventusltd/reports/blob/08aad9448481aabd2d8fd7373059bf829b29528f/studio/report-evidence.js#L83-L90
export const f1289_escapeHtml = function escapeHtml(value) {
return String(value)
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('"', '"')
.replaceAll("'", ''');
};
// Family #3937 · element #3937 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/pipelinenews_intelligence/202609021945/assets/202609021945-wider-fleet.mjs#L49-L51
export const f3937__anonymous_ = (character) => ({
"&": "&", "<": "<", ">": ">", '"': """,
}[character]);
// Family #3938 · element #3938 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/pipelinenews_intelligence/202609021945/assets/202609021945-wider-fleet.mjs#L48-L52
export const f3938_esc = function esc(value) {
return String(value == null ? "" : value).replace(/[&<>"]/g, (character) => ({
"&": "&", "<": "<", ">": ">", '"': """,
}[character]));
};
// Family #3939 · element #3939 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/pipelinenews_intelligence/202609021945/assets/202609021945-wider-fleet.mjs#L54-L56
export const f3939_num = function num(value) {
return value.toLocaleString("en-GB", { maximumFractionDigits: 2 });
};
// Family #5513 · element #5513 · 2 places in 2 repositories · https://github.com/Ventusltd/code-generator/blob/3897d83efcd0259d21dce87704b0c33118fe2c2e/apps/substation-finder/Si/index.html#L4856-L4875
export const f5513_snapLines = function snapLines(features, subs) {
if (!subs || !subs.length) return features;
const tol = 0.05, rad = Math.PI / 180;
features.forEach(f => {
const c = f.geometry && f.geometry.coordinates;
if (!c || c.length < 2) return;
[0, c.length - 1].forEach(i => {
let best = c[i], min = Infinity;
const latCos = Math.cos(c[i][1] * rad);
subs.forEach(s => {
const sc = s.geometry.coordinates;
const dx = (c[i][0] - sc[0]) * latCos, dy = (c[i][1] - sc[1]);
const d = (dx * dx) + (dy * dy);
if (d < min && d < tol * tol) { min = d; best = sc; }
});
c[i] = best;
});
});
return features;
};
// Family #32217 · element #32217 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/uk_renewables_pipeline/dashboard.html#L665-L669
export const f32217_csvEscape = function csvEscape(value) {
if (value === null || value === undefined) return '""';
const text = String(value).replace(/"/g, '""');
return `"${text}"`;
};
// Family #32226 · element #32226 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/uk_renewables_pipeline/dashboard.html#L738-L740
export const f32226__anonymous_ = function(word) {
return (word.charAt(0).toUpperCase() + word.slice(1));
};
// Family #32227 · element #32227 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/uk_renewables_pipeline/dashboard.html#L736-L741
export const f32227_titleCase = function titleCase(str) {
if (!str) return '';
return str.toLowerCase().split(' ').map(function(word) {
return (word.charAt(0).toUpperCase() + word.slice(1));
}).join(' ');
};
// Family #32281 · element #32281 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/uk_renewables_pipeline/v7/scripts/plugins/projects.js#L6-L12
export const f32281_category = function category(properties) {
const rawTechnology = String(properties.raw_tech || "").toLowerCase();
if (properties.tech === "solar" || properties.tech === "solar_roof") return "Solar";
if (properties.tech === "bess") return "Battery Storage";
if (properties.tech === "wind") return rawTechnology.includes("offshore") ? "Offshore Wind" : "Onshore Wind";
return "Other";
};
// Family #32762 · element #32762 · 2 places in 2 repositories · https://github.com/Ventusltd/grid-distance-maths/blob/8e91b07d8312acca5bcaef43e839f06a3b1d642a/src/geodesy.mjs#L219-L224
export const f32762_circleApproximationError = function circleApproximationError(vertices) {
return {
radialFraction: 1 - Math.cos(Math.PI / vertices),
areaShortFraction: 1 - (vertices / (2 * Math.PI)) * Math.sin((2 * Math.PI) / vertices),
};
};
// Family #32764 · element #32764 · 2 places in 2 repositories · https://github.com/Ventusltd/grid-distance-maths/blob/8e91b07d8312acca5bcaef43e839f06a3b1d642a/src/geodesy.mjs#L241-L250
export const f32764_areaUnits = function areaUnits(areaKm2) {
const m2 = areaKm2 * 1e6;
return {
km2: areaKm2,
hectares: m2 / 1e4,
acres: m2 / 4046.85642,
squareMiles: areaKm2 * 0.386102,
squareMetres: m2,
};
};
// Family #71488 · element #71488 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/tools/pdf-export.browser.mjs#L95-L99
export const f71488__anonymous_ = (node) => {
const title = node.querySelector('.gm-title');
const panel = node.querySelector('.gm-panel');
return { open: node.classList.contains('gm-open'), expanded: title && title.getAttribute('aria-expanded'), hidden: panel && panel.hidden };
};
// Family #72282 · element #72282 · 2 places in 2 repositories · https://github.com/Ventusltd/pipelinenews/blob/45c944c8640a9d7ae65edb51d66032ba204f3f46/archive/202608261547-pipelinenews/objects/js/sha256/8e4a229d0e059a498cafb70648f2bcb5d44c7bc4d114cf98ddcf97d108731b04.mjs#L30-L32
export const f72282_invariant = (condition, message) => {
if (!condition) throw new Error(message);
};
// Family #130085 · element #130085 · 2 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/quantum.js#L18-L22
export const f130085_hash32 = function hash32(str) { // FNV-1a
let h = 0x811c9dc5 >>> 0;
for (let i = 0; i < str.length; i++) { h ^= str.charCodeAt(i); h = Math.imul(h, 0x01000193) >>> 0; }
return h >>> 0;
};
// Family #130086 · element #130086 · 2 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/quantum.js#L23-L25
export const f130086_mulberry32 = function mulberry32(a) {
return function () { a |= 0; a = a + 0x6D2B79F5 | 0; let t = Math.imul(a ^ a >>> 15, 1 | a); t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t; return ((t ^ t >>> 14) >>> 0) / 4294967296; };
};
// Family #130087 · element #130087 · 2 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/quantum.js#L164-L171
export const f130087_makeProgram = function makeProgram(gl, vs, fs) {
const sh = (t, s) => { const o = gl.createShader(t); gl.shaderSource(o, s); gl.compileShader(o); if (!gl.getShaderParameter(o, gl.COMPILE_STATUS)) throw new Error('shader: ' + gl.getShaderInfoLog(o)); return o; };
const p = gl.createProgram(); gl.attachShader(p, sh(gl.VERTEX_SHADER, vs)); gl.attachShader(p, sh(gl.FRAGMENT_SHADER, fs)); gl.linkProgram(p);
if (!gl.getProgramParameter(p, gl.LINK_STATUS)) throw new Error('link: ' + gl.getProgramInfoLog(p));
const U = {}; const n = gl.getProgramParameter(p, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < n; i++) { const u = gl.getActiveUniform(p, i); U[u.name.replace(/\[0\]$/, '')] = gl.getUniformLocation(p, u.name); }
return { p, U };
};
// Family #130180 · element #130180 · 2 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/quantum.js#L31-L69
export const f130180_SEA_VS = (NC, texMask, texShift) => `#version 300 es
precision highp float; precision highp int;
layout(location=0) in uint a_key; layout(location=1) in uint a_family; layout(location=2) in uint a_idx;
layout(location=3) in uint a_block; layout(location=4) in uint a_cat; layout(location=5) in uint a_seed;
uniform highp sampler2D u_fam;
uniform vec2 u_res; uniform float u_dpr; uniform float u_time;
uniform vec2 u_c0; uniform vec2 u_c1; uniform float u_R; uniform vec3 u_view; uniform float u_spiral;
uniform uint u_focusKey; uniform uint u_focusFamily; uniform uint u_twinKey; uniform uint u_twinFamily;
uniform int u_focusBlock; uniform int u_focusCat; uniform float u_collapseT; uniform float u_size; uniform float u_alpha;
uniform vec3 u_pal[${NC + 1}]; uniform int u_pick;
out vec4 v_col; flat out uint v_key; flat out uint v_fam; flat out uint v_inst;
const float PI=3.14159265358979;
void main(){
vec4 t = texelFetch(u_fam, ivec2(int(a_family & ${texMask}u), int(a_family >> ${texShift}u)), 0);
float ang = t.x;
float fi = float(a_idx);
vec2 p = vec2(cos(ang), sin(ang))*t.y + u_spiral*sqrt(fi)*vec2(cos(fi*2.39996323), sin(fi*2.39996323));
if (gl_InstanceID==1) p = -p; // the twin: every point reflected through the centre (angle + PI, same radius, spiral offset reflected too)
vec2 c = gl_InstanceID==1 ? u_c1 : u_c0;
vec2 px = c + p*u_R*u_view.z + u_view.xy;
float br = u_time + float(a_seed)*0.1;
px += 0.6*u_dpr*vec2(sin(br), cos(br));
gl_Position = vec4(px.x/u_res.x*2.0-1.0, 1.0-px.y/u_res.y*2.0, 0.0, 1.0);
float size = u_size*u_dpr; float alpha = u_alpha*clamp(sqrt(40.0/max(t.w, 1.0)), 0.12, 1.0); // large families drawn fainter so a 6,518-entry family does not white out its neighbours
bool focused = (u_focusBlock >= 0) || (u_focusCat >= 0);
if (focused) { alpha *= 0.2; if (int(a_block)==u_focusBlock || int(a_cat)==u_focusCat) alpha = 0.8; }
if (a_family == u_focusFamily) { size = 3.0*u_dpr; alpha = 0.9; }
if (a_key == u_focusKey) { size = 6.0*u_dpr; alpha = 1.0; }
if (u_collapseT > 0.0 && a_family != u_focusFamily && a_key != u_focusKey) alpha *= mix(1.0, 0.55, u_collapseT);
if (gl_InstanceID == 1) {
alpha *= 0.4;
if (a_family == u_twinFamily) { size = 3.0*u_dpr; alpha = 0.9; }
if (a_key == u_twinKey && u_twinKey != 0u) { size = 6.0*u_dpr; alpha = 1.0; }
}
if (u_pick == 1) size = max(size, 4.0*u_dpr);
gl_PointSize = size;
vec3 col = u_pal[int(min(a_cat, ${NC}u))];
v_col = vec4(col, alpha); v_key = a_key; v_fam = a_family; v_inst = uint(gl_InstanceID);
}`;
// Family #130181 · element #130181 · 2 places in 2 repositories · https://github.com/Ventusltd/star-quantum-twin/blob/598f89ae75475b1bb37bba8cadcabe70f9e28a2d/quantum.js#L73-L98
export const f130181_UNIQ_VS = (NC, texMask, texShift) => `#version 300 es
precision highp float; precision highp int;
layout(location=0) in uint a_key; layout(location=1) in uint a_fam; layout(location=2) in uint a_flag; layout(location=3) in uint a_cat;
uniform highp sampler2D u_fam; uniform vec2 u_res; uniform float u_dpr; uniform float u_time;
uniform vec2 u_c0; uniform vec2 u_c1; uniform float u_R; uniform vec3 u_view; uniform float u_n; uniform float u_alpha;
uniform uint u_focusKey; uniform uint u_focusFamily; uniform float u_collapseT; uniform vec3 u_pal[${NC + 1}];
out vec4 v_col;
const float PI=3.14159265358979;
void main(){
bool inFam = (a_flag & 1u) == 1u;
uint hh = (a_key * 2654435761u) ^ (a_key >> 13u); float h = float((hh >> 8u) & 1023u) / 1023.0;
float ang, rad, alpha, size = 1.0*u_dpr; vec3 col;
if (inFam) { vec4 t = texelFetch(u_fam, ivec2(int(a_fam & ${texMask}u), int(a_fam >> ${texShift}u)), 0); ang = t.x + (h-0.5)*t.z*0.8; rad = 1.155 + h*0.03; col = u_pal[int(min(a_cat, ${NC}u))]; alpha = u_alpha*0.45; }
else { ang = -PI/2.0 + 2.0*PI*float(gl_VertexID)/u_n; rad = 1.20 + h*0.05; col = u_pal[${NC}]; alpha = u_alpha*0.7; }
vec2 p = vec2(cos(ang), sin(ang))*rad;
if (gl_InstanceID==1) p = -p;
vec2 c = gl_InstanceID==1 ? u_c1 : u_c0;
vec2 px = c + p*u_R*u_view.z + u_view.xy;
float br = u_time*0.7 + h*6.2831853; px += 0.4*u_dpr*vec2(sin(br), cos(br));
gl_Position = vec4(px.x/u_res.x*2.0-1.0, 1.0-px.y/u_res.y*2.0, 0.0, 1.0);
if (inFam && a_fam == u_focusFamily) { size = 2.5*u_dpr; alpha = 0.9; }
if (a_key == u_focusKey) { size = 7.0*u_dpr; alpha = 1.0; col = vec3(1.0); }
if (u_collapseT > 0.0 && a_key != u_focusKey) alpha *= mix(1.0, 0.55, u_collapseT);
if (gl_InstanceID == 1) alpha *= 0.4;
gl_PointSize = size; v_col = vec4(col, alpha);
}`;
// Family #132131 · element #132131 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151815-galaxy-bond/model.mjs#L23-L26
export const f132131_filterRows = function filterRows(rows, query = '', status = '') {
const q = query.trim().toLowerCase();
return rows.filter(r => (!status || r.status === status) && (!q || `${r.layer_id} ${r.claim_text || ''}`.toLowerCase().includes(q)));
};
// Family #132132 · element #132132 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151815-galaxy-bond/model.mjs#L28-L33
export const f132132__anonymous_ = (s,r) => {
s.layers++; s.statuses[r.status]++;
s.statements += r.not_evaluated.length; s.gapRecords += r.disclosed.length;
for (const p of r.predicates) { s.checked += p.checked; s.total += p.total; }
return s;
};
// Family #132134 · element #132134 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151815-galaxy-bond/model.mjs#L35-L41
export const f132134_selectionFromHash = function selectionFromHash(hash, rows) {
const q = new URLSearchParams(hash.replace(/^#/,'')), values = q.getAll('layer');
if (!values.length) return {row:null,why:''};
if (values.length !== 1) return {row:null,why:'The link names more than one layer. No selection inferred.'};
const row = rows.find(r=>r.layer_id === values[0]);
return row ? {row,why:''} : {row:null,why:'The linked layer is absent from this snapshot. No selection inferred.'};
};
// Family #132244 · element #132244 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151852-galaxy-visibility/model.mjs#L3-L12
export const f132244_validateCatalog = function validateCatalog(c){
if(c?.schema!=='code.visibility-catalog.v1'||c.substrate!=='wafer.v1'||!Array.isArray(c.layers))throw Error('Catalogue contract refused');
const ids=new Set();let total=0,empty=0;
for(const l of c.layers){
if(!/^[\w-]+$/.test(l.id)||ids.has(l.id)||!/^#[0-9a-f]{6}$/i.test(l.colour)||!Number.isSafeInteger(l.features)||l.features<0||l.file!==`geometry/${l.id}.json`||!Number.isSafeInteger(l.bytes)||l.bytes<0||!/^[a-f0-9]{64}$/.test(l.sha256))throw Error('Layer metadata refused');
ids.add(l.id);total+=l.features;empty+=Number(l.features===0);
}
if(c.counts?.layers!==ids.size||c.counts.features!==total||c.counts.empty_layers!==empty)throw Error('Catalogue count mismatch');
return c;
};
// Family #132248 · element #132248 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151852-galaxy-visibility/model.mjs#L27-L32
export const f132248_cameraFor = function cameraFor(mode,geometry,width,height,maxKey){
if(mode==='home'||!geometry?.keys.length)return{x:0,y:0,zoom:Math.min(width,height)/(Math.sqrt(maxKey)*2.15)};
if(mode==='near'){const p=geometry.keys[0];return{x:p.x,y:p.y,zoom:9};}
if(mode!=='fit')throw Error('Unknown camera');
const b=geometry.bounds;return{x:(b.minX+b.maxX)/2,y:(b.minY+b.maxY)/2,zoom:Math.min(20,(width-36)/Math.max(1,b.maxX-b.minX),(height-36)/Math.max(1,b.maxY-b.minY))};
};
// Family #132249 · element #132249 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151852-galaxy-visibility/visibility-style.mjs#L8-L11
export const f132249_finite = function finite(value, label) {
if (typeof value !== 'number' || !Number.isFinite(value)) throw new TypeError(`${label} must be finite`);
return value;
};
// Family #132267 · element #132267 · 2 places in 2 repositories · https://github.com/Ventusltd/testcode/blob/a8a215982b13d6e2f6019b40bf0bef5755719773/sandbox/202609151910-galaxy-demand/model.mjs#L3-L6
export const f132267_numberInput = function numberInput(text) {
if (typeof text !== 'string') throw new TypeError('Interface input must be text');
return text.trim() === '' ? undefined : Number(text);
};
// Family #144036 · element #144036 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/homepage-shell/assets/versioned-homepage.js#L43-L48
export const f144036_safeUrl = function safeUrl(value) {
if (typeof value !== 'string') throw new Error('Missing URL');
const url = new URL(value);
if (url.protocol !== 'https:' || url.username || url.password) throw new Error('Unsafe URL');
return value;
};
// Family #144145 · element #144145 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/homepage-shell/assets/versioned-homepage.js#L26-L36
export const f144145_onDemand = function onDemand(details, populate) {
let ready = false;
const hydrate = () => {
if (ready) return;
populate();
ready = true;
};
details.querySelector('summary').addEventListener('click', hydrate);
details.addEventListener('toggle', () => { if (details.open) hydrate(); });
return hydrate;
};
// Family #144152 · element #144152 · 2 places in 2 repositories · https://github.com/Ventusltd/globalgrid2050/blob/32ae2ded87b626ab573efa6887547f2128c55304/homepage-shell/assets/versioned-homepage.js#L108-L115
export const f144152_validatePresentation = function validatePresentation(config, byId) {
if (!config || config.schema_version !== 1 || !Number.isInteger(config.page_size) || config.page_size < 1 || config.page_size > 100 || !Array.isArray(config.highlights) || config.highlights.length > 4) throw new Error('Invalid presentation settings');
const seen = new Set();
for (const item of config.highlights) {
if (!byId.has(item.entity_id) || seen.has(item.entity_id) || typeof item.label !== 'string' || !item.label.trim() || item.label.length > 40) throw new Error('Invalid highlight');
seen.add(item.entity_id);
}
};
// Family #156746 · element #156746 · 2 places in 2 repositories · https://github.com/Ventusltd/gridatlas/blob/f944f8dcbc09cd09c0895f0126682ec241cd576f/atlas/labs/lightning-grid/feed-contract.mjs#L88-L101
export const f156746_describeOpticalFeedEvidence = function describeOpticalFeedEvidence(e){
const last=e.latest_detection_utc?e.latest_detection_utc.replace('T',' ').replace('Z',' UTC')
:'not recorded';
const query=e.query_end_utc?e.query_end_utc.replace('T',' ').replace('Z',' UTC')
:'UNKNOWN';
const freshness=e.query_freshness==='STALE_QUERY'?'STALE COLLECTOR QUERY'
:e.query_freshness==='QUERY_TIME_UNKNOWN'?'QUERY FRESHNESS UNKNOWN'
:'recent collector query (not complete coverage)';
return 'Authentic optical observations: '+e.accepted+' accepted of '+e.raw_records+
' source records. Latest optical detection: '+last+'. Latest collector query ended: '+
query+' ('+freshness+'). Seven-day retention is not a verified seven-day search: '+
'unsearched hours and older history UNKNOWN, not zero.'+
(e.warnings.length?' SOURCE WARNINGS: '+e.warnings.join('; ')+'.':'');
};
// Family #175881 · element #175881 · 2 places in 2 repositories · https://github.com/Ventusltd/gridatlas/blob/f944f8dcbc09cd09c0895f0126682ec241cd576f/atlas/modules/202611172355-grid-journey-preview.js#L4-L326
export const f175881__anonymous_ = () => {
/**
* Module: network-topology
*
* PROMOTED from sources/v9-extracts/network-topology.mjs (itself extracted
* verbatim from the LATER of two committed gridatlas versions,
* atlas/modules/202609012245-network-topology.js, 384 lines — a strict
* superset of 202609012145-network-topology.js, 279 lines: at() is
* byte-identical between the two; 202609012245 adds physicalUnits() and
* graph() so electrical-distance.js and rating-envelope.js (both of which
* require 'gridatlas.module.network-topology.graph.v1') have something to
* consume). Not one of the six named extraction targets, but promoted
* because both electrical-distance and rating-envelope are inert without it.
*
* What the network operator publishes about ONE site: its nodes, the
* circuits that land on them, the transformers between them, the changes
* it has published for future years, and which other sites those circuits
* reach. Appendix B of the Electricity Ten Year Statement, read as a
* node/branch model and reported as facts.
*
* Depends on: nothing. Topology is not geometry — this module never
* measures a distance and never touches a coordinate.
*
* CHANGED FROM THE SOURCE: the IIFE and `window.__GRIDATLAS_MODULES__`