In this section
- Kuiper Programs render · globalgrid2050 / kuiper-grid/i0083/cartridges/007900000000-kuiper-programs.js lines 701–1400
Kuiper Programs
A JavaScript module in the cartridges folder of GlobalGrid2050 covering cables, solar, substations and transformers, using SHA-256, and uses data from the faraday repository.
renderglobalgrid2050 / kuiper-grid/i0083/cartridges/007900000000-kuiper-programs.js · lines 701–1400 of 3016 (continued from section 1350) · Not reached from any entry point (candidate for review) · pattern GUARD_SAID (shared by 18 files)
- What it does
- It draws cables, solar, substations and transformers. Defines 180 functions or classes, including reFire, closestPair, blackSky, nameInLines, makeBody. Side effects: changes the web page (DOM); reads or writes files; makes network requests.
- Why it exists in the grid workflow
- Domain stage agent_infra (path word 'kuiper'): AI-agent memory, coordination and code audit (the multi-agent journey named in Ventus Ltd's brief). Domain terms in the code: cables, solar, substations, transformers, 400kV.
- Inputs & outputs
- In: data source: faraday data; JSON file current.json. Out: canvas drawing. Voltage levels named: 400kV.
- What it achieves
- It makes body (`makeBody`), sets tag (`setTag`) and merges menu (`mergeMenu`). A cartridge of the Kuiper shell. Its code works with 400 kV, 50 kW and 500 kW. It responds to click, keydown and pointerdown events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- globalgrid2050 · kuiper-grid/i0083/cartridges · JavaScript module
- Uses
- Faraday — Index Page (estate URL), Wafer Development Environment — Proof S0004 Page (estate URL), ./fire.js
- Used by
- none found
- Produces
- reFire, closestPair, blackSky, nameInLines, makeBody, bodyTo, labels, bodyJump, bodyMove, bodyDrawnDiameter, bodyDotPx, sheet
- Defines here
- extraAfter, rowOf0, turned, x0, ptAt, minusPt, minus, inRow, run, ok_, no_, leadTyped, GUARD_SAID, guardTyped, run, loadFireConfig, say, searchCommands, fireKey, dedupeCommands, plainName, curateCommands, chipWords, makeFireBar
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 kuiper-grid/i0083/cartridges/007900000000-kuiper-programs.js:701-1400 · blob b382cf75ec7d2f5a8f8134bd9e9be7c7e9585790 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: dom, filesystem, network · domain stage: agent_infra · users: ai_agent · canonical: unreached_review
const mount = String(c.mounting || 'fixed').toLowerCase();
const high = Math.max(1, Math.min(6, Math.round(c.modules_high)));
const faces = mount === 'east-west' ? 2 : 1, rows = high * faces;
const cols = Math.max(1, Math.ceil(N / rows));
// WHAT STANDS BETWEEN TWO ROWS: nothing on a plain table, the ridge on an east west table, the torque
// tube down the middle of a tracker.
const extraAfter = r => (faces === 2 && r === high - 1) ? c.ridge_gap_m
: (mount === 'tracker' && r === Math.floor(rows / 2) - 1) ? c.tube_gap_m : 0;
const rowY = []; { let yy = 0; for (let r = 0; r < rows; r++) { rowY.push(yy); yy += pitchY + extraAfter(r); } }
// ROUTING is what the old "wiring" input was asking, and it is kept as a name for it.
let routing = String(c.routing || '').toLowerCase();
if (!routing) routing = String(c.wiring).toLowerCase() === 'sequential' ? 'one-after-another' : 'leapfrog';
if (routing === 'along-and-back' || routing === 'sequential-u') routing = 'serpentine';
if (routing === 'sequential') routing = 'one-after-another';
if (routing === 'zigzag' && rows < 2) routing = 'one-after-another';
if (routing === 'serpentine' && rows < 2) routing = 'one-after-another';
c.routing = routing;
const leap = routing === 'leapfrog';
// THE DEFAULT STRING IS A COMPLETE STRING. Nobody builds an array and leaves half its links open;
// a drawing that opens by default is a drawing of a mistake. So unless a lead length is typed, the
// leads are THE PAIR THAT REACHES for the wiring chosen - the longest link plus the slack allowance
// - and the answer says what pair that is, to be ordered against what the module is supplied with.
// Ask for "supplied" instead and you get the factory portrait leads and, with them, the shortfall.
const leadsAre = String(c.leads || 'reach').toLowerCase();
const typedLeads = c.lead_plus_m !== null || c.lead_minus_m !== null;
if (leadsAre === 'supplied' && !typedLeads) { c.lead_plus_m = 0.35; c.lead_minus_m = 0.28; }
const rowOf0 = k => Math.min(rows - 1, Math.floor((k - 1) / cols)), colOf = k => (k - 1) % cols;
const turned = k => (!!c.turn_every_second && k % 2 === 0) !== (!!c.turn_alternate_rows && rowOf0(k) % 2 === 1);
const rowOf = rowOf0;
// WHERE THE ROW BREAKS. A table is so many modules long and then there is a gap in the steel; a link
// that crosses the break has to cross the gap as well. Nothing to declare and nothing to guess: it is
// in the x of every module.
const tlm = Math.max(1, Math.round(+c.table_length_modules || 1)), gTab = +c.gap_table_m || 0;
const x0 = k => colOf(k) * pitch + Math.floor(colOf(k) / tlm) * gTab, y0 = k => rowY[rowOf(k)];
// THE BOXES ARE NOT AT THE MIDDLE OF ANYTHING UNLESS THE CLASS PUTS THEM THERE. Their positions are
// two fractions: ACROSS the module's short axis (u) and ALONG its long axis (v). box_spacing_m is kept
// as the name for the across pair, so every command ever written still means what it said.
const fM0 = c.box_across_frac_minus === null || c.box_across_frac_minus === undefined
? 0.5 - (c.box_spacing_m / 2) / c.width_m : +c.box_across_frac_minus;
const fP0 = c.box_across_frac_plus === null || c.box_across_frac_plus === undefined
? 0.5 + (c.box_spacing_m / 2) / c.width_m : +c.box_across_frac_plus;
const fV0 = Math.min(1, Math.max(0, +c.box_along_frac));
c.box_spacing_m = Math.round(Math.abs(fP0 - fM0) * c.width_m * 1e6) / 1e6;
const ptAt = (k, want, t) => { const u0 = want === '+' ? fP0 : fM0;
const u = t ? 1 - u0 : u0, v = t ? 1 - fV0 : fV0;
return port ? [x0(k) + u * wX, y0(k) + v * wY] : [x0(k) + v * wX, y0(k) + u * wY]; };
const minusPt = k => ptAt(k, '-', turned(k)), plusPt = k => ptAt(k, '+', turned(k));
const minus = k => minusPt(k)[0], plus = k => plusPt(k)[0]; // the drawing reads x from these
// THE ORDER THE STRING IS WIRED IN, over the grid of modules. The modules themselves never move.
const inRow = r => { const out = []; for (let k = 1; k <= N; k++) if (rowOf(k) === r) out.push(k); return out; };
const order = [];
if (routing === 'leapfrog') { for (let r = 0; r < rows; r++) { const q = inRow(r); if (!q.length) continue;
const fwd = r % 2 === 0 ? q : q.slice().reverse();
for (let i = 0; i < fwd.length; i += 2) order.push(fwd[i]);
for (let i = (fwd.length % 2 ? fwd.length - 2 : fwd.length - 1); i >= 1; i -= 2) order.push(fwd[i]); } }
else if (routing === 'serpentine') { for (let r = 0; r < rows; r++) { const q = inRow(r); if (!q.length) continue;
order.push(...(r % 2 === 0 ? q : q.slice().reverse())); } }
else if (routing === 'zigzag') { const a0 = inRow(0), a1 = inRow(1);
for (let i = 0; i < Math.max(a0.length, a1.length); i++) { const up = i % 2 === 0;
if (up) { if (a0[i] !== undefined) order.push(a0[i]); if (a1[i] !== undefined) order.push(a1[i]); }
else { if (a1[i] !== undefined) order.push(a1[i]); if (a0[i] !== undefined) order.push(a0[i]); } }
for (let r = 2; r < rows; r++) { const q = inRow(r); order.push(...(r % 2 === 0 ? q : q.slice().reverse())); } }
else for (let k = 1; k <= N; k++) order.push(k);
// HOW FAR EACH LINK HAS TO REACH IS GEOMETRY, and it does not depend on what lead is fitted: so the
// needs are measured first, and only then is the lead pair settled.
const links = [];
for (let i = 0; i + 1 < order.length; i++) { const from = order[i], to = order[i + 1];
const A = plusPt(from), B = minusPt(to);
// THE ROUTE IS NOT THE DIAGONAL when the cable is clipped: it leaves the box, drops to the clip line
// c.clip_offset_m away, runs along it and climbs back. Plus the gland exit, the bend radii and the
// clip entry, which no polyline draws: c.route_allowance_m. Both are zero by default, which is the
// geometric case this command has always reported; the library's own defaults are -0.120 and 0.080 m.
const routeExtra = 2 * Math.abs(+c.clip_offset_m || 0) + (+c.route_allowance_m || 0);
const need = Math.hypot(A[0] - B[0], A[1] - B[1]) + (+c.slack_m || 0) + routeExtra;
links.push({ from, to, need, back: to < from, cross: rowOf(from) !== rowOf(to),
x_from: A[0], x_to: B[0], y_from: A[1], y_to: B[1] }); }
const longest = links.length ? Math.max(...links.map(l => l.need)) : 0;
if (c.lead_plus_m === null || c.lead_minus_m === null) {
const want = longest + (c.lead_slack_m === undefined ? 0.20 : +c.lead_slack_m);
// the + lead keeps the box spacing it really has and the - lead makes up the rest, which is how
// a module maker quotes an unequal pair
const lpWant = Math.min(want * 0.5, c.box_spacing_m);
if (c.lead_plus_m === null) c.lead_plus_m = Math.round(lpWant * 1000) / 1000;
if (c.lead_minus_m === null) c.lead_minus_m = Math.round((want - c.lead_plus_m) * 1000) / 1000; }
// A MATED PAIR EATS LEAD. What is left of the two leads is what can actually span the route.
const pair = c.lead_plus_m + c.lead_minus_m - (+c.connector_pair_m || 0);
for (const l of links) { l.reaches = pair + 1e-9 >= l.need;
l.jumper = !l.reaches && !!c.jumpers ? l.need - pair : 0; }
const last = order[order.length - 1], row = cols * pitch;
// HOW FAR A FREE END IS FROM THE NEAR CORNER, along the structure: a cable is clipped to steel, it
// does not fly. Both ends land at the near end when the + end is in the near half of the table.
const yBase = rowY[0] + wY / 2;
// WHICH END THE TWO STRING ENDS ARE COLLECTED AT is a decision, not a fact about the table.
const xRef = String(c.home_run_from || 'start').toLowerCase() === 'end' ? (cols - 1) * pitch + Math.floor((cols - 1) / tlm) * gTab : 0;
const run = q => Math.abs(q[0] - xRef) + Math.abs(q[1] - yBase);
const endRun = run(plusPt(last)), bothNear = endRun <= row / 2;
const ret = bothNear ? 0 : endRun;
// conductor_c, when it is given, is the name for both: it sets the lead and the site cable together.
if (c.conductor_c !== null && c.conductor_c !== undefined && c.conductor_c !== '') { c.t_lead_c = +c.conductor_c; c.t_site_c = +c.conductor_c; }
const fLead = 1 + 0.00393 * (c.t_lead_c - 20), fSite = 1 + 0.00393 * (c.t_site_c - 20);
// A JUMPER IS SITE CABLE AND ONE MORE MATED PAIR, at the link it is spliced into.
const jumpers = links.filter(l => l.jumper > 0), jumper_m = jumpers.reduce((t, l) => t + l.jumper, 0);
const lead_m = N * pair, field_m = 2 * c.near_end_m + 4 * (+c.termination_extra_m || 0) + run(minusPt(order[0])) + endRun + jumper_m;
const pairs = links.length + 2 + (bothNear ? 0 : 1) + jumpers.length;
// A SITE MADE END is a connector fitted to a cut cable by a person on the table: the two home runs
// always, and the far end return cable's two, when one is laid.
const siteEnds = 2 + (bothNear ? 0 : 2);
// THE COPPER'S OWN NUMBER IS AN INPUT TOO, and the home run may be a different size from the array's
// own cable: on a long run it is the bigger part of the loss.
const rLead = (c.ohm_per_km_lead === null || c.ohm_per_km_lead === undefined) ? (R20[c.lead_mm2] || 5.09) : +c.ohm_per_km_lead;
const rSite = (c.ohm_per_km_site === null || c.ohm_per_km_site === undefined) ? (R20[c.cable_mm2] || 3.39) : +c.ohm_per_km_site;
const hrSize = (c.home_run_mm2 === null || c.home_run_mm2 === undefined) ? c.cable_mm2 : c.home_run_mm2;
const rHome = (c.ohm_per_km_site === null || c.ohm_per_km_site === undefined) ? (R20[hrSize] || rSite) : rSite;
const home_m = 2 * c.near_end_m + 4 * (+c.termination_extra_m || 0), array_m = field_m - 2 * c.near_end_m;
const ohmLead = rLead * lead_m * fLead / 1000;
const ohmSite = (rHome * home_m + rSite * array_m) * fSite / 1000;
const ohm = ohmLead + ohmSite + pairs * c.contact_milliohm / 1000;
const short = links.filter(l => !l.reaches && !l.jumper), needs = links.map(l => l.need);
// THREE LOOPS, NOT ONE. The array's own loop is what the wiring choice changes; the home run pair is
// its own loop and on a long run it is the larger; a nearby stroke couples into the SUM of them.
const arrayLoop = bothNear ? row * c.lead_gap_m : row * c.return_offset_m;
const sep = (c.home_separation_m === null || c.home_separation_m === undefined || c.home_separation_m === '') ? null : +c.home_separation_m;
const homeLoop = sep === null ? null : c.near_end_m * sep;
const loop = homeLoop === null ? null : arrayLoop + homeLoop;
// A CONDUCTOR OVER ITS RATING IS SAID IN WORDS AND NEVER QUIETLY COSTED.
const hot = [];
if (c.t_lead_c > c.rating_c) hot.push('the module leads at ' + c.t_lead_c + ' C are over the ' + c.rating_c + ' C the cable is rated for');
if (c.t_site_c > c.rating_c) hot.push('the site cable at ' + c.t_site_c + ' C is over the ' + c.rating_c + ' C it is rated for');
// WHAT IS NOT LAID ON SITE, against ONE stated baseline: the same row wired one after another, no
// module turned, with its far end brought home. Closed form, so it can be checked by hand:
// plain leapfrog saves (N-2) pitches; turning every second module saves (N-2) pitches and the box
// spacing as well, because the last module's + box has moved to the near side of its own module.
const baseEnd = Math.abs(ptAt(N, '+', false)[0]) + Math.abs(ptAt(N, '+', false)[1] - yBase);
const baseField = 2 * c.near_end_m + Math.abs(ptAt(1, '-', false)[0]) + Math.abs(ptAt(1, '-', false)[1] - yBase) + baseEnd;
const saved = baseField - field_m;
const smallest = needs.length ? Math.max(...needs) : 0;
// ===== THE ELEVEN SANITY RULES =================================================================
// Copied, words and all, from LIB/solar-params/params.mjs (RULES; its test.mjs asserts them in 89
// assertions). A rule that says no is not a failure: it is the engine refusing to draw something
// stupid, and the words it refuses in ARE the answer. Nothing wrong is ever drawn.
const vocCold = c.module_voc * (1 + (+c.tc_voc_pct_per_k) / 100 * (c.t_min_c - 25));
const stringVocCold = N * vocCold, nMaxCold = Math.floor(c.max_system_voltage_v / Math.max(1e-9, vocCold));
const checks = [];
const ok_ = (n, w) => checks.push({ name: n, ok: true, words: w });
const no_ = (n, w) => checks.push({ name: n, ok: false, words: w });
// 1
(() => { const nb = Math.round(+c.n_boxes);
if (nb !== 1 && nb !== 3) return no_('wiring_is_buildable', 'n_boxes is ' + c.n_boxes + '. A module carries one box or three; nothing else is drawn.');
if (N < 2 && routing !== 'one-after-another') return no_('wiring_is_buildable', 'N = ' + N + ': there is nothing to leapfrog over.');
if ((routing === 'serpentine' || routing === 'zigzag') && rows < 2) return no_('wiring_is_buildable', routing + ' goes out along one tier and back along the one above it, so it needs at least two tiers; modules high is ' + high + '. Use leapfrog on a single tier, or set modules high to 2.');
ok_('wiring_is_buildable', routing + ' is buildable on ' + rows + ' tier(s) with ' + nb + ' box(es) per module'); })();
// 2
(() => { if (Math.round(+c.n_boxes) === 1 && Math.abs(fP0 - fM0) > 1e-6)
return no_('lead_only_from_terminal_box', 'this module has ONE junction box, so both leads leave that box and the box spacing is zero; the + and the − are asked for ' + c.box_spacing_m.toFixed(3) + ' m apart. A module lead can only leave a junction box that carries one.');
if (Math.round(+c.n_boxes) === 3 && Math.abs((fM0 + fP0) / 2 - 0.5) > 0.4)
return no_('lead_only_from_terminal_box', 'the two lead boxes are not the outer pair of the three: the middle box holds a bypass diode and the cross connection only, and no lead leaves it.');
ok_('lead_only_from_terminal_box', 'every lead leaves and lands on a box that carries a terminal'); })();
// 3
(() => { const bad = links.find(l => l.from === l.to);
if (bad) return no_('no_conductor_inside_one_module', 'a link has both ends on module ' + bad.from + '. A module is never wired to itself; that would short its own string.');
ok_('no_conductor_inside_one_module', 'no conductor has both ends on the same module'); })();
// 4
(() => { const count = new Map(); for (let k = 1; k <= N; k++) { count.set('M' + k + '−', 0); count.set('M' + k + '+', 0); }
for (const l of links) { count.set('M' + l.from + '+', (count.get('M' + l.from + '+') || 0) + 1); count.set('M' + l.to + '−', (count.get('M' + l.to + '−') || 0) + 1); }
count.set('M' + order[0] + '−', (count.get('M' + order[0] + '−') || 0) + 1);
count.set('M' + order[order.length - 1] + '+', (count.get('M' + order[order.length - 1] + '+') || 0) + 1);
const unused = [...count].filter(e => e[1] === 0).map(e => e[0]), doubled = [...count].filter(e => e[1] > 1).map(e => e[0] + ' x' + e[1]);
if (unused.length) return no_('every_terminal_used_once', unused.length + ' terminal(s) are wired to nothing: ' + unused.slice(0, 4).join(', ') + (unused.length > 4 ? ' ...' : ''));
if (doubled.length) return no_('every_terminal_used_once', doubled.length + ' terminal(s) are wired more than once: ' + doubled.slice(0, 4).join(', '));
ok_('every_terminal_used_once', 'all ' + count.size + ' terminals are used exactly once'); })();
// 5
(() => { if (order.length !== N) return no_('walk_visits_all_and_ends_at_inverter', 'the walk visits ' + order.length + ' modules but the string has ' + N);
if (new Set(order).size !== N) return no_('walk_visits_all_and_ends_at_inverter', 'the walk visits a module twice: ' + order.join(','));
ok_('walk_visits_all_and_ends_at_inverter', 'the walk visits all ' + N + ' modules once, M' + order[0] + ' first, M' + order[N - 1] + ' last, and both ends reach the inverter'); })();
// 6
(() => { const fr = Math.round(+c.n_boxes) === 1 ? [fM0] : [fM0, 0.5, fP0];
for (const u of fr) { const L = u * c.width_m - c.box_w_m / 2, R = u * c.width_m + c.box_w_m / 2;
const B = fV0 * c.module_height_m - c.box_h_m / 2, T = fV0 * c.module_height_m + c.box_h_m / 2;
if (L < -1e-6 || R > c.width_m + 1e-6 || B < -1e-6 || T > c.module_height_m + 1e-6)
return no_('boxes_inside_module', 'a junction box sticks out of its module: the box spans ' + L.toFixed(3) + '..' + R.toFixed(3) + ' x ' + B.toFixed(3) + '..' + T.toFixed(3) + ' m, the module is 0..' + c.width_m.toFixed(3) + ' x 0..' + c.module_height_m.toFixed(3) + ' m. A junction box is glued to the back glass; it cannot hang over the frame.'); }
ok_('boxes_inside_module', 'all boxes sit inside their module'); })();
// 7
(() => { const keys = ['module_height_m', 'width_m', 'gap_m', 'gap_up_m', 'gap_table_m', 'lead_minus_m', 'lead_plus_m',
'connector_pair_m', 'route_allowance_m', 'slack_m', 'near_end_m', 'termination_extra_m', 'box_w_m', 'box_h_m'];
for (const k of keys) if (typeof c[k] === 'number' && c[k] < 0) return no_('non_negative_lengths_and_gaps', k + ' is ' + c[k] + '. A length or a gap is never negative.');
if (pitch <= 0) return no_('non_negative_lengths_and_gaps', 'the pitch is ' + rnd(pitch, 4) + ' m. Modules would overlap.');
if (pair <= 0) return no_('non_negative_lengths_and_gaps', 'the lead pair left after the connector is ' + rnd(pair, 4) + ' m. A conductor is never shorter than nothing.');
ok_('non_negative_lengths_and_gaps', 'every declared length, gap and conductor is zero or longer'); })();
// 8
(() => { const anyTurn = !!c.turn_every_second || !!c.turn_alternate_rows;
if (!anyTurn) return ok_('rear_turn_needs_boxes_on_the_mid_line', 'no module is turned end for end, so the mid line question does not arise');
if (Math.abs(fV0 - 0.5) > 0.01) return no_('rear_turn_needs_boxes_on_the_mid_line', 'turning a module end for end is refused: the lead boxes sit at ' + fV0.toFixed(3) + ' of the module length, not on the mid line at 0.500. Turn the module and the box line moves from ' + rnd(fV0 * c.module_height_m, 3) + ' m to ' + rnd((1 - fV0) * c.module_height_m, 3) + ' m across the row; the clip line woul … [line shortened here: 527 characters; full line on GitHub]
if (Math.round(+c.n_boxes) > 1 && Math.abs(fM0 + fP0 - 1) > 0.006) return no_('rear_turn_needs_boxes_on_the_mid_line', 'turning is refused: the minus and plus boxes are not symmetric about the module centre (' + fM0.toFixed(4) + ' + ' + fP0.toFixed(4) + ' = ' + (fM0 + fP0).toFixed(4) + ', not 1.0000). Turning alternate modules would then give two different link lengths instead of one, and th … [line shortened here: 450 characters; full line on GitHub]
ok_('rear_turn_needs_boxes_on_the_mid_line', 'the lead boxes are on the mid line and symmetric about the module centre, so the turn is honest'); })();
// 9
(() => { if (stringVocCold > c.max_system_voltage_v)
return no_('cold_voltage_limit', N + ' modules is beyond the cold voltage limit: at ' + c.t_min_c + ' C each module opens to ' + vocCold.toFixed(2) + ' V, so the string stands at ' + stringVocCold.toFixed(0) + ' V against a ' + c.max_system_voltage_v + ' V system. The most this class may take is ' + nMaxCold + '.');
ok_('cold_voltage_limit', N + ' modules stand at ' + stringVocCold.toFixed(0) + ' V cold, inside the ' + c.max_system_voltage_v + ' V limit (the most is ' + nMaxCold + ')'); })();
// 10 - outside the plausible range the engine does not refuse; it asks.
const asks = [];
const leadTyped = k => typed[k] !== undefined || (pre && pre.values[k] !== undefined);
for (const k of Object.keys(PLAUSIBLE)) { const v = +c[k], d = PLAUSIBLE[k];
if ((k === 'lead_minus_m' || k === 'lead_plus_m') && !leadTyped(k)) continue; // a lead this command sized itself is not a typed value to question
if (typeof c[k] !== 'number' || Number.isNaN(v) || (v >= d[0] && v <= d[1])) continue;
let guess = null;
for (const f2 of [[1000, 'you may have typed millimetres'], [100, 'you may have typed centimetres'], [0.001, 'you may have typed metres where this wants millimetres'], [0.01, 'a factor of 100 out']]) {
const g = v / f2[0]; if (g >= d[0] && g <= d[1]) { guess = 'did you mean ' + rnd(g, 6) + ' ' + d[2] + '? (' + f2[1] + ')'; break; } }
if (!guess) guess = 'a real site uses ' + d[0] + ' to ' + d[1] + ' ' + d[2];
asks.push(k + ' = ' + v + ' ' + d[2] + ' is outside the plausible range ' + d[0] + ' to ' + d[1] + ' - ' + guess); }
if (asks.length) no_('values_are_plausible', asks.join('; ')); else ok_('values_are_plausible', 'every value is inside its plausible range');
// 11 - reported, not refused: an open string IS the honest answer about the leads, and it is drawn.
if (short.length) no_('every_link_reaches', short.length + ' of ' + links.length + ' links do not reach with a lead pair of ' + rnd(pair, 3) + ' m. First: M' + short[0].from + '+ to M' + short[0].to + '− needs ' + rnd(short[0].need, 3) + ' m.');
else ok_('every_link_reaches', 'every module to module link is made with the supplied leads, none stretched');
const ASK_ONLY = ['values_are_plausible', 'every_link_reaches'];
const refused = checks.filter(k => !k.ok && ASK_ONLY.indexOf(k.name) < 0);
const asked = checks.filter(k => !k.ok && ASK_ONLY.indexOf(k.name) >= 0);
return { c, N, pitch, pitchY, wX, wY, port, rows, cols, rowY, mount, high, faces, routing, leap, order, links,
checks, refused, asked, vocCold, stringVocCold, nMaxCold, fM0, fP0, fV0, preset: pre ? String(typed.module_class) : '',
row, pair, lead_m, field_m, pairs, siteEnds, ohm, ohmLead, ohmSite, bothNear, endRun, ret,
short, needs, smallest, jumpers, jumper_m, loop, arrayLoop, homeLoop, sep, saved, hot, fLead, fSite,
minusPt, plusPt, minus, plus, rowOf, colOf, x0, y0, turned };
}
// ===== THE GUARD AT THE DOOR ===================================================================
// Before a single coordinate is worked out, every value that was TYPED is read and measured. A
// value that is not a number the engine can hold - nothing, empty, text that is not a number,
// NaN, infinity - or a number outside what that input can mean, is answered in plain words and
// NOTHING IS DRAWN. Same guard, same words, as LIB/solar-params/params.mjs validateAndCoerce.
// Defaults and module-class presets are known good, so only what a person typed is examined.
const GUARD_NUM = {
modules:['modules in the string',1,60,1], n:['modules in the string',1,60,1],
n_boxes:['junction boxes on the module',1,3,1], modules_high:['modules stacked up the table',1,6,1],
cell_cols:['cells across the module',1,24,1], cell_rows:['cells up the module',1,80,1],
cells_across:['cells across the module',1,24,1], cells_up:['cells up the module',1,80,1],
cell_cut:['how many pieces each cell is cut into',1,4,1],
width_m:['the short side of the module',0.2,2.5,0], module_width_m:['the short side of the module',0.2,2.5,0],
module_height_m:['the long side of the module',0.2,4,0], module_length_m:['the long side of the module',0.2,4,0],
box_spacing_m:['the spacing between the two junction boxes',0,2.5,0],
gap_m:['the gap between modules along the row',0,1,0], gap_up_m:['the gap between tiers',0,1,0],
ridge_gap_m:['the gap at the ridge',0,2,0], tube_gap_m:['the gap at the torque tube',0,2,0],
lead_plus_m:['the plus lead',0,5,0], lead_minus_m:['the minus lead',0,5,0],
lead_slack_m:['the slack allowed at a lead',0,2,0], slack_m:['the slack left at each link',0,2,0],
lead_gap_m:['the spacing between the two leads',0,2,0], return_offset_m:['the return cable offset',0,5,0],
lead_mm2:['the module lead cross-section',1,25,0], cable_mm2:['the site cable cross-section',1,400,0],
near_end_m:['the home run',0,2000,0], home_run_m:['the home run',0,2000,0],
home_separation_m:['how far apart the two home runs are laid',0,50,0],
amps:['the string current',0,50,0], module_vmp:['the module voltage at maximum power',5,120,0],
module_voc:['the open-circuit voltage of one module',5,120,0], voc_stc_v:['the open-circuit voltage of one module',5,120,0],
t_lead_c:['the temperature of the module leads',-50,150,0], t_site_c:['the temperature of the site cable',-50,150,0],
rating_c:['the temperature the cable is rated for',-50,150,0], conductor_c:['the conductor temperature',-50,150,0],
t_min_c:['the coldest the site gets',-60,40,0], t_max_c:['the hottest the site gets',-20,70,0],
max_system_voltage_v:['the system voltage',100,2000,0], contact_milliohm:['the resistance of one contact',0,100,0],
tc_voc_pct_per_k:['how the open-circuit voltage moves with temperature',-1,0,0]
};
const GUARD_ENUM = {
orientation:['which way up the module is laid',['portrait','landscape']],
mounting:['how the modules are mounted',['fixed','tracker','east-west']],
routing:['the wiring pattern',['','one-after-another','serpentine','leapfrog','zigzag']],
wiring:['the wiring pattern',['sequential','leapfrog','one-after-another','serpentine','zigzag']]
};
const GUARD_SAID = v => v === undefined ? 'nothing' : v === null ? 'null'
: typeof v === 'number' ? (isFinite(v) ? String(v) : (v !== v ? 'NaN (not a number)' : String(v)))
: typeof v === 'string' ? (v === '' ? 'nothing at all' : 'the text "' + v + '"')
: Array.isArray(v) ? 'a list of ' + v.length : 'a ' + typeof v;
function guardTyped(inp) {
const bad = [];
if (inp !== undefined && inp !== null && (typeof inp !== 'object' || Array.isArray(inp)))
return ['the settings must be given as a set of named values, like {"modules":30}; you typed ' + GUARD_SAID(inp)];
const t = inp || {};
for (const k in t) {
if (!Object.prototype.hasOwnProperty.call(t, k)) continue;
const v = t[k];
if (GUARD_ENUM[k]) {
const e = GUARD_ENUM[k];
if (typeof v !== 'string' || e[1].indexOf(v) < 0)
bad.push(e[0] + ' must be one of ' + e[1].filter(x => x !== '').map(x => '"' + x + '"').join(', ') + '; you typed ' + GUARD_SAID(v));
continue;
}
const d = GUARD_NUM[k];
if (!d) continue;
if (v === null && (k === 'home_separation_m' || k === 'conductor_c' || k === 'lead_plus_m' || k === 'lead_minus_m')) continue;
const x = (typeof v === 'number') ? v : (typeof v === 'string' && v.trim() !== '' ? Number(v) : NaN);
if (!isFinite(x)) { bad.push(d[0] + ' must be a number; you typed ' + GUARD_SAID(v)); continue; }
if (d[3] && Math.round(x) !== x) { bad.push(d[0] + ' must be a whole number from ' + d[1] + ' to ' + d[2] + '; you typed ' + GUARD_SAID(v)); continue; }
if (x < d[1] || x > d[2]) bad.push(d[0] + ' must be ' + (d[3] ? 'a whole number' : 'a number') + ' from ' + d[1] + ' to ' + d[2] + '; you typed ' + GUARD_SAID(v));
}
return bad.slice(0, 6);
}
function run(inp) {
const stopped = guardTyped(inp);
if (stopped.length) {
const words = stopped.join('; ') + '. Nothing is drawn until that is a number the engine can hold.';
return { refused: true, string: null, connections: [],
checks: [{ rule: 'inputs_are_numbers', name: 'inputs_are_numbers', ok: false, words: words }],
numbers: { drawn: 'nothing', rules_broken: stopped.length, rule: 'inputs_are_numbers' },
said: 'NOTHING IS DRAWN. ' + words,
how: 'every value typed into this command is read and measured before a single coordinate is worked out. A value that is not a number, or a number outside what that input can mean, would put a NaN into the drawing, so it is refused in words instead. Change the input named above and fire again.',
inputs_used: Object.assign({}, inp || {}) };
}
const g = build(inp), c = g.c, worst = g.short.length ? Math.max(...g.short.map(l => l.need - g.pair)) : 0;
// A RULE THAT SAYS NO IS THE ANSWER. Nothing wrong is drawn: no string, no links, no numbers - the
// rule's own words, and what to change. (LIB/solar-params RULES, 89 assertions behind them.)
if (g.refused.length) {
return { refused: true, string: null, connections: [], checks: g.checks,
numbers: { drawn: 'nothing', rules_broken: g.refused.length, rule: g.refused[0].name },
said: 'NOTHING IS DRAWN. ' + g.refused.map(k => k.words).join(' ')
+ (g.asked.length ? ' Also: ' + g.asked.map(k => k.words).join('; ') + '.' : ''),
how: 'the eleven sanity rules of the parameter library are checked before anything is drawn, and ' + g.refused.length + ' of them said no. A refusal is not a failure: it is the engine declining to draw something that could not be built. Change the input it names and fire again.',
inputs_used: Object.assign({}, c) };
}
const askWords = g.asked.filter(k => k.name === 'values_are_plausible').map(k => k.words).join('; ');
const name = LAYOUT_WORDS(g) + ', ' + (ROUTE_WORDS[g.routing] || g.routing)
+ (c.turn_every_second ? ', every second module turned end for end' : '');
// A SERIES CIRCUIT IS OPEN OR IT IS NOT. One pair of connectors that does not meet and the whole
// string carries nothing: not a warm link, not a derated string, NOTHING, anywhere in it.
const open = g.short.length > 0, amps = open ? 0 : c.amps;
// AN OPEN STRING IS NOT A DEAD STRING. No current flows, and that is the whole of what "open" means;
// the modules go on making their open circuit voltage, so the full string voltage stands across a
// break, and an open connector under that voltage is exactly where a direct current arc begins.
const voc = g.N * c.module_voc;
const order = g.order.map(k => 'M' + k).join(' → ');
const hotWords = g.hot.length ? ' RATING CHECK FAILED: ' + g.hot.join('; ') + '. ' : '';
const loopWords = g.sep === null
? ' The whole loop needs the home run separation: it moves the answer more than the wiring does, so only the array loop is given.'
: ' Loop ' + g.loop.toFixed(1) + ' m2 in all, of which the home run pair is ' + g.homeLoop.toFixed(1) + ' m2.';
const said = (askWords ? 'CHECK THESE FIRST: ' + askWords + '. ' : '') + hotWords + name + ': ' + g.N + ' modules over ' + g.rows + (g.rows === 1 ? ' row' : ' rows') + ' of ' + g.cols + ', ' + g.links.length + ' links from ' + Math.min(...g.needs).toFixed(2) + ' to ' + Math.max(...g.needs).toFixed(2) + ' m against a lead pair of ' + g.pair.toFixed(2) + ' m; '
+ (g.bothNear ? 'both free ends land at the near end, so no return cable is laid; ' : 'a return cable of ' + g.ret.toFixed(1) + ' m brings the far end home; ')
+ (g.jumpers.length ? g.jumpers.length + (g.jumpers.length === 1 ? ' link is' : ' links are') + ' made up with a jumper spliced in on site, ' + g.jumper_m.toFixed(1) + ' m of cable and ' + g.jumpers.length + ' more mated pairs; ' : '')
+ (open ? 'THE CIRCUIT IS OPEN AND BOTH ENDS ARE LIVE: ' + g.short.length + ' links do not reach (short by up to ' + worst.toFixed(2) + ' m), so no current flows anywhere, but up to '
+ voc.toFixed(0) + ' V stands across a break and an open connector at that voltage is where a direct current arc starts'
: 'every link reaches, so the loop closes and ' + c.amps + ' A flows all the way round it')
+ '; ' + g.lead_m.toFixed(1) + ' m of module lead and ' + g.field_m.toFixed(1) + ' m of cable laid on site; '
+ loopWords + ' '
+ (open ? g.ohm.toFixed(3) + ' ohm IF IT WERE CLOSED, and ' + (c.amps * c.amps * g.ohm).toFixed(0) + ' W lost at ' + c.amps + ' A: nothing is lost in it now because nothing flows in it'
: g.ohm.toFixed(3) + ' ohm, ' + (amps * amps * g.ohm).toFixed(0) + ' W lost at ' + amps + ' A');
// THE CONNECTION LIST, in the order the current runs, terminal by terminal. It is the same walk the
// checks make, so what a reader sees in words is what the drawing was built from.
const connections = [{ from:'INV\u2212', to:'M' + g.order[0] + '\u2212', metres:c.near_end_m, home:true, node:'home-' }];
g.links.forEach((l, i) => connections.push({ node:'L' + i, from:'M' + l.from + '+', to:'M' + l.to + '\u2212',
needed:rnd(l.need, 2), pair:rnd(g.pair, 2), reaches:l.reaches, jumper:rnd(l.jumper || 0, 2) }));
connections.push({ from:'M' + g.order[g.order.length - 1] + '+', to:'INV+', metres:c.near_end_m, home:true, node:'home+' });
return { connections, refused: false, checks: g.checks,
numbers: { circuit: open ? 'OPEN, both ends live' : 'closed', current_a: rnd(amps, 2),
open_circuit_volts_at_25c: rnd(voc, 0), volts_across_a_break: open ? rnd(voc, 0) : 0, links: g.links.length,
shortest_link_m: rnd(Math.min(...g.needs), 3), longest_link_m: rnd(Math.max(...g.needs), 3), lead_pair_m: rnd(g.pair, 3),
links_that_do_not_reach: g.short.length, worst_shortfall_m: rnd(worst, 3), module_lead_m: rnd(g.lead_m, 1), cable_laid_on_site_m: rnd(g.field_m, 1),
total_conductor_m: rnd(g.lead_m + g.field_m, 1), connector_pairs: g.pairs, string_resistance_ohm: rnd(g.ohm, 4), loss_w: rnd(amps * amps * g.ohm, 1),
volt_drop_v: rnd(amps * g.ohm, 2), row_length_m: rnd(g.row, 2), string_volts_at_vmp: rnd(g.N * c.module_vmp, 0),
loss_w_if_it_were_closed: rnd(c.amps * c.amps * g.ohm, 1),
volts_to_earth_each_end: '−' + rnd(g.N * c.module_vmp / 2, 0) + ' to +' + rnd(g.N * c.module_vmp / 2, 0),
routing: g.routing, rows_of_modules: g.rows, columns_of_modules: g.cols,
modules_in_the_last_column: g.N - (g.cols - 1) * g.rows > 0 ? Math.min(g.rows, g.N - (g.cols - 1) * g.rows) : g.rows,
both_ends_at_the_near_end: g.bothNear, return_cable_m: rnd(g.ret, 2),
smallest_lead_pair_that_reaches_m: rnd(g.smallest, 3),
lead_pair_to_order_m: rnd(g.pair, 3),
connectors_fitted_on_site: g.siteEnds + 2 * g.jumpers.length,
jumpers_made_on_site: g.jumpers.length, jumper_cable_m: rnd(g.jumper_m, 2),
array_loop_m2_rough: rnd(g.arrayLoop, 2),
home_run_loop_m2_rough: g.homeLoop === null ? null : rnd(g.homeLoop, 2),
total_loop_m2_rough: g.loop === null ? null : rnd(g.loop, 2),
site_cable_saved_m: rnd(g.saved, 2),
lead_resistance_ohm: rnd(g.ohmLead, 4), site_cable_resistance_ohm: rnd(g.ohmSite, 4),
rating_check: g.hot.length ? 'FAILED: ' + g.hot.join('; ') : 'passed, both conductors at or under ' + c.rating_c + ' C' },
said, electrical_order: order,
how: 'geometry only: module ' + c.width_m + ' m wide by ' + c.module_height_m + ' m tall in portrait, ' + c.cell_cols + ' by ' + c.cell_rows
+ ' half cells, junction boxes ' + c.box_spacing_m + ' m apart at mid height, a link is the distance between the boxes it joins; leads ' + c.lead_mm2 + ' mm2, site cable ' + c.cable_mm2
+ ' mm2, copper, the leads at ' + c.t_lead_c + ' C and the site cable at ' + c.t_site_c + ' C (give conductor_c and both take that figure); near end ' + c.near_end_m + ' m from the inverter. '
+ 'The site cable temperature is an assumption and it matters: buried is about 30 C, clipped along the structure is near the lead temperature; ' + c.t_site_c + ' C was used here. '
+ 'A link has to span the STRAIGHT DISTANCE IN THE PLANE between the two boxes plus the slack allowance, ' + (+c.slack_m || 0) + ' m here. '
+ 'The boxes sit at mid length of the module\u2019s long side, spread along its short axis, so in portrait they are side by side along the table and in landscape one above the other. '
+ 'A cable to a free end is counted along the structure, not across the diagonal. '
+ 'The loop is in two parts, both rough: the ARRAY loop is the row length times a stated gap, and the HOME RUN loop is the run times how far apart the two cables are laid. '
+ 'Bundling the home run pair shrinks the loop more than the wiring choice does, for either wiring. '
+ 'Site cable not laid, against the same row wired one after another with no module turned and its far end brought home: ' + g.saved.toFixed(2) + ' m. '
+ 'Electrical order ' + order + '. Colour is the POTENTIAL RELATIVE TO THE MINUS TERMINAL, not to earth: the array floats, so either terminal may sit at up to half the '
+ 'array voltage with respect to earth, and a black line does not mean an earthed one. The line does not thicken or thin along the string, because a series circuit carries one current. '
+ 'The moving highlight is the INSTANT THE CIRCUIT CLOSES; after that the current is the same all the way round and nothing travels along the wire. An open string carries no current and is NOT safe: up to '
+ rnd(voc, 0) + ' V at 25 C stands across a break, more when it is cold. '
+ 'Every input can be changed. An estimate, not a study.', string: g, inputs_used: Object.assign({}, c) };
}
// WHAT A READER MAY TURN, in plain words with its unit. The window makes a box out of each of these.
const BOXES = [
{ key:'mounting', label:'mounting', kind:'choice', choices:[['fixed', 'fixed tilt'], ['east-west', 'east and west facing'], ['tracker', 'single axis tracker']] },
{ key:'orientation', label:'modules', kind:'choice', choices:[['portrait', 'portrait'], ['landscape', 'landscape']] },
{ key:'modules_high', label:'modules high (each face)', kind:'number', min:1, max:6, step:1 },
{ key:'turn_alternate_rows', label:'return rows turned round', kind:'choice', choices:[[0, 'no'], [1, 'yes']] },
{ key:'jumpers', label:'jumper where leads fall short', kind:'choice', choices:[[0, 'no, say it is open'], [1, 'yes, splice one in']] },
{ key:'view', label:'drawn as', kind:'choice', choices:[['wiring', 'the back, wiring'], ['scale', 'modules to scale']] },
{ key:'sheet', label:'on', kind:'choice', choices:[[0, 'the night sky'], [1, 'a drawing sheet']] },
{ key:'routing', label:'routing', kind:'choice', choices:[
['one-after-another', 'one after another, with a return cable'],
['serpentine', 'along and back, no return cable'],
['leapfrog', 'leapfrog inside each row'],
['zigzag', 'zigzag between two rows']] },
{ key:'turn_every_second', label:'every second module turned', kind:'choice', choices:[[0, 'no'], [1, 'yes']] },
{ key:'modules', label:'modules', kind:'number', min:2, max:40, step:1 },
{ key:'width_m', label:'module width', unit:'m', kind:'number', min:0.4, max:3, step:0.001 },
{ key:'module_height_m', label:'module height', unit:'m', kind:'number', min:0.4, max:4, step:0.001 },
{ key:'gap_m', label:'gap along the table', unit:'m', kind:'number', min:0, max:1, step:0.005 },
{ key:'gap_up_m', label:'gap up the table', unit:'m', kind:'number', min:0, max:1, step:0.005 },
{ key:'ridge_gap_m', label:'gap at the ridge', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'tube_gap_m', label:'gap at the torque tube', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'box_spacing_m', label:'junction boxes apart', unit:'m', kind:'number', min:0.05, max:2, step:0.01 },
{ key:'leads', label:'leads', kind:'choice', choices:[['reach', 'the pair that reaches'], ['supplied', 'as supplied, portrait']] },
{ key:'lead_slack_m', label:'slack in the lead pair', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'lead_plus_m', label:'+ lead', unit:'m', kind:'number', min:0.05, max:8, step:0.01 },
{ key:'lead_minus_m', label:'− lead', unit:'m', kind:'number', min:0.05, max:8, step:0.01 },
{ key:'lead_mm2', label:'lead size', unit:'mm2', kind:'choice', choices:[[2.5, '2.5'], [4, '4'], [6, '6'], [10, '10']] },
{ key:'cable_mm2', label:'site cable', unit:'mm2', kind:'choice', choices:[[4, '4'], [6, '6'], [10, '10']] },
{ key:'near_end_m', label:'near end from the inverter', unit:'m', kind:'number', min:0, max:400, step:1 },
{ key:'amps', label:'current', unit:'A', kind:'number', min:0.1, max:40, step:0.01 },
{ key:'t_lead_c', label:'module lead temperature', unit:'C', kind:'number', min:-25, max:140, step:1 },
{ key:'t_site_c', label:'site cable temperature', unit:'C', kind:'number', min:-25, max:140, step:1,
hint:'buried is about 30, clipped along the structure is near the lead temperature' },
{ key:'rating_c', label:'cable rated for', unit:'C', kind:'number', min:60, max:140, step:5 },
{ key:'home_separation_m', label:'home run cables apart', unit:'m', kind:'number', min:0, max:2, step:0.01,
optional:true, hint:'bundled about 0.02, separate trays about 0.3' },
{ key:'slack_m', label:'slack allowed at each link', unit:'m', kind:'number', min:0, max:2, step:0.01 },
{ key:'module_vmp', label:'module at most power', unit:'V', kind:'number', min:5, max:100, step:0.1 },
{ key:'module_voc', label:'module open circuit', unit:'V', kind:'number', min:5, max:120, step:0.1 },
// ROOM LEFT HERE, deliberately, for inputs already agreed and not yet built: how far apart the two
// home runs are laid (which decides the home run's own loop area separately from the array's), and
// the lead temperature and the site cable temperature as two figures, with the single conductor
// temperature kept as the name for both.
{ key:'cell_cols', label:'cells across', kind:'number', min:1, max:24, step:1, group:'MODULE' },
{ key:'cell_rows', label:'cells up', kind:'number', min:2, max:48, step:2, group:'MODULE' },
// ===== THE REST OF THE MODULE'S OWN CIRCUIT ====================================================
// Every one of these was a constant in this file an hour ago. They come, with their groups, units,
// defaults and limits, from LIB/solar-params (38 parameters, 11 rules, 89 assertions).
{ key:'module_class', label:'module class', kind:'choice', group:'MODULE', choices:[
['', 'whatever is typed below'],
['class-T660', 'T660: 2384 x 1303, 6 x 22 half cut, three boxes'],
['class-W760', 'W760: 2384 x 1303, 6 x 33 third cut, boxes near one end'],
['class-J-650', 'J-650: 2465 x 1134, 6 x 24 half cut, three boxes'],
['small-2011-single-box', '2011 type: 1650 x 990, 60 full cells, ONE box (no datasheet)']] },
{ key:'n_boxes', label:'junction boxes on the module', kind:'choice', group:'MODULE', choices:[[1, 'one, carrying both leads'], [3, 'three, the outer pair carrying the leads']] },
{ key:'half_cut', label:'laminate', kind:'choice', group:'MODULE', choices:[[0, 'whole cells'], [1, 'two parallel halves']] },
{ key:'cell_cut', label:'cells per column strip', kind:'number', group:'MODULE', min:1, max:4, step:1, hint:'1 full, 2 half, 3 third' },
{ key:'box_along_frac', label:'box line along the module', unit:'frac', kind:'number', group:'MODULE', min:0, max:1, step:0.001,
hint:'0.5 is the transverse centre line; a class with its boxes near one end cannot be turned end for end' },
{ key:'box_across_frac_minus', label:'− box across the module', unit:'frac', kind:'number', group:'MODULE', min:0, max:1, step:0.0001, optional:true, hint:'blank takes it from the box spacing' },
{ key:'box_across_frac_plus', label:'+ box across the module', unit:'frac', kind:'number', group:'MODULE', min:0, max:1, step:0.0001, optional:true },
{ key:'box_w_m', label:'box width', unit:'m', kind:'number', group:'MODULE', min:0.005, max:0.3, step:0.001 },
{ key:'box_h_m', label:'box height', unit:'m', kind:'number', group:'MODULE', min:0.005, max:0.3, step:0.001 },
{ key:'connector_pair_m', label:'a mated pair eats', unit:'m', kind:'number', group:'MODULE', min:0, max:0.3, step:0.005, hint:'the library assumes 0.060; zero keeps the geometric case' },
{ key:'tc_voc_pct_per_k', label:'open circuit coefficient', unit:'%/K', kind:'number', group:'MODULE', min:-1, max:0, step:0.01 },
{ key:'max_system_voltage_v', label:'system voltage', unit:'V', kind:'choice', group:'MODULE', choices:[[1000, '1000'], [1500, '1500']] },
{ key:'table_length_modules', label:'table is this many modules long', kind:'number', group:'STRUCTURE', min:1, max:200, step:1 },
{ key:'gap_table_m', label:'gap at the table break', unit:'m', kind:'number', group:'STRUCTURE', min:0, max:20, step:0.01 },
{ key:'clip_offset_m', label:'clip line off the box line', unit:'m', kind:'number', group:'STRUCTURE', min:-2, max:2, step:0.01, hint:'the library assumes −0.120; zero is the straight geometric case' },
{ key:'route_allowance_m', label:'gland, bends and clip entry', unit:'m', kind:'number', group:'STRUCTURE', min:0, max:2, step:0.01, hint:'the library assumes 0.080' },
{ key:'home_run_from', label:'string ends collected at', kind:'choice', group:'HOME RUN', choices:[['start', 'the near end'], ['end', 'the far end']] },
{ key:'home_run_mm2', label:'home run size', unit:'mm2', kind:'choice', group:'HOME RUN', optional:true, choices:[[4, '4'], [6, '6'], [10, '10']] },
{ key:'termination_extra_m', label:'extra at each termination', unit:'m', kind:'number', group:'HOME RUN', min:0, max:20, step:0.1 },
{ key:'ohm_per_km_lead', label:'lead copper at 20 C', unit:'ohm/km', kind:'number', group:'CABLE', min:0.01, max:100, step:0.01, optional:true },
{ key:'ohm_per_km_site', label:'site copper at 20 C', unit:'ohm/km', kind:'number', group:'CABLE', min:0.01, max:100, step:0.01, optional:true },
{ key:'t_min_c', label:'coldest site temperature', unit:'C', kind:'number', group:'SITE', min:-60, max:40, step:1, hint:'it decides the longest string allowed' },
{ key:'t_max_c', label:'hottest site temperature', unit:'C', kind:'number', group:'SITE', min:-20, max:70, step:1 }
];
F.register('string', 'STRINGS', run, BOXES);
F.string = { build, DEF };
})(typeof window !== 'undefined' ? window : globalThis);
// ===== THE COMMAND LIST, READ THE WAY GRIDATLAS READS A COMPOSITION ===============================
// The sentences in the bar are not written into this page: the page fetches them. This is the reader, and it is built the way
// the Atlas reads atlas/current.json - a POINTER fetched with no cache at all, a schema that must be the one we know, a file
// named by the pointer, and the bytes that arrive RE-HASHED here and compared with the hash the pointer declared before one
// sentence is shown. Nothing is trusted because it arrived; it is trusted because it hashes to what was promised.
//
// ON ANY FAULT THE BAR SAYS THE EXACT REASON. A list that quietly falls back to a few built-in sentences teaches a reader
// nothing; "the list hashes to 9c1f6a and the pointer says 4749ae" tells them, and tells us, what actually happened.
//
// WHERE IT READS FROM: the faraday repository's Pages site. That is a DIFFERENT ORIGIN from the one this page is served from,
// for as long as the list is produced there: the fetch depends on that site's Access-Control-Allow-Origin header, which is not
// ours to promise, and a refusal is one of the faults the bar will name. The day the list is copied under this origin, pass
// that base in instead; the pointer, the hash and the checks are the same either way.
async function loadFireConfig(base) {
const say = reason => ({ ok: false, reason: reason });
const at = String(base || '');
if (!at || at.slice(-1) !== '/') return say('the base address must end in a slash; it was "' + at + '"');
if (typeof fetch !== 'function') return say('this browser has no fetch, so the list cannot be read');
const subtle = (typeof crypto !== 'undefined' && crypto && crypto.subtle) ? crypto.subtle : null;
if (!subtle) return say('this page cannot hash what it fetched (crypto.subtle is missing, which is what a page served over plain http gets), so nothing is trusted');
let res;
try { res = await fetch(at + 'current.json', { cache: 'no-store' }); }
catch (e) { return say('the pointer ' + at + 'current.json could not be fetched: ' + (e && e.message ? e.message : e)); }
if (!res.ok) return say('the pointer ' + at + 'current.json answered ' + res.status);
let cur;
try { cur = JSON.parse(await res.text()); }
catch (e) { return say('the pointer is not valid JSON: ' + (e && e.message ? e.message : e)); }
if (!cur || typeof cur !== 'object') return say('the pointer is not an object');
if (cur.schema !== 'faraday.commands.current.v1') return say('the pointer says schema "' + cur.schema + '" and this page reads faraday.commands.current.v1');
if (typeof cur.file !== 'string' || !cur.file) return say('the pointer names no file');
if (typeof cur.sha256 !== 'string' || !/^[0-9a-f]{64}$/.test(cur.sha256)) return say('the pointer carries no sha256 for ' + cur.file);
if (typeof cur.generation !== 'string' || !cur.generation) return say('the pointer carries no generation');
let fres;
try { fres = await fetch(at + cur.file, { cache: 'no-store' }); }
catch (e) { return say('the list ' + cur.file + ' could not be fetched: ' + (e && e.message ? e.message : e)); }
if (!fres.ok) return say('the list ' + cur.file + ' answered ' + fres.status);
const buf = await fres.arrayBuffer();
if (typeof cur.bytes === 'number' && buf.byteLength !== cur.bytes) return say('the list is ' + buf.byteLength + ' bytes and the pointer says ' + cur.bytes);
const digest = await subtle.digest('SHA-256', buf);
let hex = ''; const view = new Uint8Array(digest);
for (let i = 0; i < view.length; i++) hex += view[i].toString(16).padStart(2, '0');
if (hex !== cur.sha256) return say('the list hashes to ' + hex.slice(0, 12) + ' and the pointer says ' + cur.sha256.slice(0, 12) + ': these are not the bytes that were published');
let list;
try { list = JSON.parse(new TextDecoder('utf-8').decode(buf)); }
catch (e) { return say('the list is not valid JSON: ' + (e && e.message ? e.message : e)); }
if (!list || typeof list !== 'object') return say('the list is not an object');
if (list.schema !== 'faraday.commands.v2') return say('the list says schema "' + list.schema + '" and this page reads faraday.commands.v2');
if (list.generation !== cur.generation) return say('the list is generation ' + list.generation + ' and the pointer says ' + cur.generation);
if (!Array.isArray(list.commands)) return say('the list carries no commands');
if (typeof cur.count === 'number' && list.commands.length !== cur.count) return say('the pointer counts ' + cur.count + ' commands and the list holds ' + list.commands.length);
if (!list.commands.length) return say('the list is empty');
for (let i = 0; i < list.commands.length; i++) {
const c = list.commands[i];
if (!c || typeof c !== 'object') return say('command ' + i + ' is not an object');
for (const k of ['family', 'kind', 'sentence', 'command']) if (typeof c[k] !== 'string' || !c[k]) return say('command ' + i + ' has no ' + k);
if (c.seed !== null && c.seed !== undefined && typeof c.seed !== 'number') return say('command ' + i + ' has a seed that is not a number');
if (c.case !== null && c.case !== undefined && typeof c.case !== 'number') return say('command ' + i + ' has a case that is not a number');
}
return { ok: true, generation: list.generation, commands: list.commands };
}
// A THOUSAND SENTENCES NEED A SEARCH BOX. Every word typed must appear somewhere in the family, the kind or the sentence, so
// "chain export 500" narrows to chains that export near a 500 kW limit. Case blind, and never more than fifty at once,
// because a list longer than a screen is a list nobody reads.
function searchCommands(commands, text) {
const words = String(text === undefined || text === null ? '' : text).toLowerCase().split(/\s+/).filter(Boolean);
const out = [];
if (!Array.isArray(commands)) return out;
for (let i = 0; i < commands.length && out.length < 200; i++) {
const c = commands[i];
if (!c) continue;
const hay = ((c.family || '') + ' ' + (c.kind || '') + ' ' + (c.name || '') + ' ' + (c.sentence || '')).toLowerCase();
let all = true;
for (let w = 0; w < words.length; w++) if (hay.indexOf(words[w]) < 0) { all = false; break; }
if (all) out.push(c);
}
return out;
}
// ===== THE WAFER'S OWN BAR AND WINDOW, LIFTED ONTO THE KUIPER ====================================
// Vikram, on seeing the pop-up this replaced: "You've killed the preset wafer lifted popup bar". His
// standing rule is that the wafer development environment page IS the look and every feature evolves
// that renderer; a list pop-up of my own invention is a new look, and it went. What is here is the
// wafer's own component, taken from
// globalgrid2050.com/testcode/wafer-development-environment/202609192215-proof-s0004/ (pilot.mjs), with
// its own ids, its own classes and its own proportions kept, so the two bars are one component:
//
// #pilot one full width typed bar across the very bottom, with #pin in it
// #eg the examples picker just above it on the right: "EXAMPLES: PICK ONE, IT LANDS IN THE BOX,
// PRESS ENTER" over "- choose an example sentence -"
// #presets the preset chips along the top left, the way the wafer carries home, the grid, 400 kV
// #say the window: #saybar with the title and minimise, maximise and close, #saybody under it,
// dragged by its bar, resized from its corner
//
// What the owner asked for on top of the wafer, and what is his and not the wafer's:
// - choosing a preset FIRES it. The bar then shows its plain NAME, never the JSON.
// - the command text is shown only when it is asked for, inside the window, where it can be edited
// and fired again.
// - typing in the bar searches the published thousand by their plain words; the picker becomes the
// list of what matched, and Enter fires the first of them.
// - nothing is offered twice (see fireKey above), and the face carries nothing else at all.
const FIRE_CONFIG = 'https://ventusltd.github.io/faraday/bench/results/commands/';
const FIRE_DRAWS = ['site-pulse', 'network', 'string']; // the commands whose network the dots draw
const CHIPS_SHOWN = 8; // the best few as chips, the way the wafer pins its best few
const PICKER_SHOWN = 100; // the pinned hundred in the picker; the rest by typing
// THE STRING TESTS live in this file: they are geometry, they need no bench run, and they are shown first.
const STRING_TESTS = [
{ family:'STRINGS', pin:-12, name:'A tracker, two in portrait, along and back', chip:'2P along-and-back', sentence:'Single axis tracker, two modules in portrait, out along the lower row and back along the upper: both ends at the near end and no return cable', command:'fire string {"mounting":"tracker","modules_high":2,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35, … [line shortened here: 424 characters; full line on GitHub]
{ family:'STRINGS', pin:-11, name:'A tracker, two in portrait, leapfrog in each row', chip:'2P leapfrog', sentence:'Single axis tracker, two in portrait, every other module on the way out and the rest on the way back inside each row', command:'fire string {"mounting":"tracker","modules_high":2,"routing":"leapfrog","turn_every_second":1,"lead_plus_m":0.84,"lead_minus_m":1.166,"jumpers":1}' },
{ family:'STRINGS', pin:-10, name:'A tracker, two in portrait, one after another', chip:'2P sequential', sentence:'Single axis tracker, two in portrait, each module to the next with a cable to bring the far end home', command:'fire string {"mounting":"tracker","modules_high":2,"routing":"one-after-another","jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-9, name:'Fixed tilt, one in portrait, leapfrog', chip:'1P leapfrog', sentence:'A single row of thirty modules, every other one joined on the way out, the rest on the way back', command:'fire string {"mounting":"fixed","modules_high":1,"routing":"leapfrog"}' },
{ family:'STRINGS', pin:-8, name:'Fixed tilt, one in portrait, one after another', chip:'1P sequential', sentence:'A single row, each module to the next, and one cable the length of the row to bring the far end home', command:'fire string {"mounting":"fixed","modules_high":1,"routing":"one-after-another"}' },
{ family:'STRINGS', pin:-7, name:'Fixed tilt, two in portrait, along and back', chip:'2P fixed U', sentence:'A table two modules high, out along the lower tier and back along the upper: no return cable is laid', command:'fire string {"mounting":"fixed","modules_high":2,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-6, name:'Fixed tilt, three in portrait, along and back', chip:'3P fixed', sentence:'A table three modules high, wired row by row, turning at the end of each', command:'fire string {"mounting":"fixed","modules_high":3,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-5, name:'Fixed tilt, four in portrait, along and back', chip:'4P fixed', sentence:'A table four modules high, wired row by row', command:'fire string {"mounting":"fixed","modules_high":4,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-4, name:'East and west facing, five in portrait each face', chip:'5P east-west', sentence:'Two faces back to back with a ridge between them, five modules in portrait on each, wired row by row', command:'fire string {"mounting":"east-west","modules_high":5,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-3, name:'Fixed tilt landscape, three high', chip:'3L landscape', sentence:'Modules laid on their side, three high: the two junction boxes now sit one above the other', command:'fire string {"mounting":"fixed","orientation":"landscape","modules_high":3,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-2, name:'Fixed tilt landscape, six high', chip:'6L landscape', sentence:'Modules on their side, six high, wired row by row', command:'fire string {"mounting":"fixed","orientation":"landscape","modules_high":6,"routing":"serpentine","turn_alternate_rows":1,"jumpers":1,"lead_plus_m":0.35,"lead_minus_m":0.28}' },
{ family:'STRINGS', pin:-1, name:'Leapfrog turned, every second module end for end', chip:'1P leapfrog turned', sentence:'Turning every second module end for end makes every link the short kind', command:'fire string {"wiring":"leapfrog","turn_every_second":1,"lead_plus_m":0.84,"lead_minus_m":1.166}' },
{ family:'STRINGS', pin:0, name:'A tracker, two in portrait, zigzag between the rows', chip:'2P zigzag', sentence:'Single axis tracker, two in portrait, up one column and along, down the next and along', command:'fire string {"mounting":"tracker","modules_high":2,"routing":"zigzag","jumpers":1,"lead_plus_m":0.84,"lead_minus_m":1.166}' },
];
const FIRE_FALLBACK = [
{ family:'NETWORKS', name:'A chain of substations on full solar', sentence:'A chain of substations, full solar, light load', command:'fire network {"seed":5,"solar":1,"generator":0,"load":0.3}' },
{ family:'NETWORKS', name:'A tree of substations with its generator running', sentence:'A tree of substations, full solar, generator running', command:'fire network {"seed":11,"solar":1,"generator":1,"load":0.3}' },
{ family:'NETWORKS', name:'A factory of seven substations at full load, no solar', sentence:'Sub-boards, seven substations, full load, no solar', command:'fire network {"seed":2026,"solar":0,"generator":0,"load":1}' },
{ family:'NETWORKS', name:'The same factory at the end of a weak grid', sentence:'The same sub-boards on a weak grid', command:'fire network {"seed":2026,"variant":2,"solar":1,"generator":0,"load":0.3}' },
{ family:'NETWORKS', name:'The same factory with every cable three times as long', sentence:'The same sub-boards with every cable three times as long', command:'fire network {"seed":2026,"variant":3,"solar":1,"generator":0,"load":1}' },
{ family:'SITE PULSE', name:'A works with its own solar at full output', sentence:'Site pulse: solar at full output, no generator, load 30%', command:'fire site-pulse {"scenario":3,"load_share":0.3}' },
{ family:'SITE PULSE', name:'The same works with one substation disconnected', sentence:'Site pulse: solar at full output, the tenant substation disconnected', command:'fire site-pulse {"scenario":7,"load_share":0.3}' } ];
// TWO TESTS ARE THE SAME TEST when they draw the same picture and end on the same numbers. The picture is
// the seed and the variant; the numbers are the row the bench recorded when it solved the case. Of the
// 1,000 networks published at 04:06 on 20 September, 102 were another entry word for word in everything a
// reader can see - the same seed at the same solar and the same load, with the generator called on and
// then off, which on those networks moves no dot and no figure - and a list like that reads as nonsense.
// Nothing is offered twice. Where the bench recorded no row, the command itself is the key.
function fireKey(c){
const r = c && c.row, cmd = String((c && c.command) || '');
if (!r || typeof r !== 'object') return cmd;
const seed = /"seed"\s*:\s*(-?\d+)/.exec(cmd), variant = /"variant"\s*:\s*(\d+)/.exec(cmd);
return [seed ? seed[1] : '?', variant ? variant[1] : '0', r.p_kw, r.vmax_pu, r.vmin_pu, r.worst_tx_pct, r.flags].join('|');
}
function dedupeCommands(list){
const seen = new Set(), out = [];
for (const c of (Array.isArray(list) ? list : [])) { const k = fireKey(c); if (seen.has(k)) continue; seen.add(k); out.push(c); }
return out;
}
// A NAME A BANKER CAN READ. The published list carries one; an older list does not, and then the first
// half of the sentence, up to the colon, is the plain name and the whole sentence is the detail under it.
function plainName(c){
if (c && c.name) return String(c.name);
const s = String((c && c.sentence) || (c && c.command) || '');
const at = s.indexOf(':');
return at > 8 ? s.slice(0, at) : s;
}
// WHAT TO PIN WHEN NOTHING IS PINNED. The published list says which hundred are worth showing; if the list
// that arrives is older than that, a set is chosen here that is visibly different: no two the same shape,
// the same size of network and the same thing being tested.
function curateCommands(list, want){
const out = [], taken = new Set();
for (const c of list) {
const m = /^A ([a-z-]+(?: network)?) of (\d+)/.exec(String(c.sentence || ''));
const shape = m ? m[1] : (c.family || 'other'), n = m ? +m[2] : 0;
const band = n <= 3 ? 'small' : (n <= 8 ? 'middling' : 'large');
const key = shape + '|' + band + '|' + (c.kind || c.family || '');
if (taken.has(key)) continue;
taken.add(key); out.push(c);
if (out.length >= want) break;
}
return out;
}
// a chip is a short word, so a chip takes the head of the name and nothing else
function chipWords(c){
if (c && c.chip) return String(c.chip); // a name short enough to tell eight presets apart
const n = plainName(c), at = n.indexOf(',');
const head = at > 4 ? n.slice(0, at) : n;
return head.length > 30 ? head.slice(0, 29) + '…' : head;
}
let fireBarMade = false;
let closeFireMenu = null; // set when the bar is built: an answer always shuts the picker's list
let sayOpen = null; // set when the bar is built: open the window on some words
function makeFireBar(){
if (fireBarMade) return; fireBarMade = true;
if (!document.body) return;
const st = document.createElement('style');
// The wafer's own rules, kept: the bottom of the screen is a stack, not a pile.
st.textContent = ':root{--cmd:56px;--footh:34px;--stack:calc(var(--cmd) + var(--footh) + 8px);--egh:0px;--above:calc(var(--stack) + 8px)}'
// THE BAR IS INSIDE THE SHELL'S OWN FOOT, not fixed on top of it. The wafer's bar is the last thing at
// the bottom of its page, under the one line that says what the page is not, and the Kuiper's shell
// measures its foot to decide how big the disc is and where the work card sits. A bar fixed over the
// foot was a bar the shell could not see: the card checks read the card as off the screen at 390. So
// the same component is built as the last child of #foot, and the picker as its first, and everything
// the shell does about height goes on working.
+ '#pilot{display:flex;gap:8px;margin-top:7px;padding-top:7px;border-top:1px solid #1b2030}'
+ '#pilot input{flex:1;min-width:0;font:12px/1.45 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;background:#11151f;color:#cfe3f2;'
+ 'border:1px solid #1b2030;border-radius:6px;padding:.6rem .9rem}'
+ '#pilot input:focus{outline:1px solid #5ec8f2}'
+ '#pilot input::placeholder{color:#5b6377}'
// THE BAND IS FILLED, NOT SHORTENED. The examples box sat against the right edge and left a wide strip
// of empty dark beside it, between the rule at the top of the foot and the bar. Making the box one line
// shorter closed the strip and ALSO made the foot shorter, and the page's own checks refused that at
// once: the shell measures its foot to decide how big the disc is, where the work card sits and where
// every gathered dot lands, and three checks that had passed all night failed. So the box keeps its
// height to the pixel and is widened to the whole line instead: the strip is the box now.
+ '#eg{margin:0 0 6px;width:auto;max-width:none;background:#0e121b;border:1px solid #1b2030;'
+ 'border-radius:8px;padding:.45rem .7rem;display:flex;flex-direction:column;gap:4px}'
+ '#eg select{align-self:flex-end;width:min(30rem,70vw)}'
+ '#eg label{font:11px ui-monospace,Menlo,Consolas,monospace;letter-spacing:.08em;text-transform:uppercase;color:#8b93a7}'
+ '#eg select{font:12px ui-monospace,Menlo,Consolas,monospace;background:#11151f;color:#cfe3f2;border:1px solid #1b2030;border-radius:6px;padding:.45rem .7rem;max-width:44vw}'
+ '#presets{position:fixed;left:12px;top:12px;z-index:19;display:flex;gap:6px;flex-wrap:wrap;max-width:min(62vw,calc(100% - 24px))}'
+ '#presets button{font:11px/1.6 ui-monospace,Menlo,Consolas,monospace;color:#8b93a7;background:#0b0e14;border:1px solid #232a3a;'
+ 'border-radius:4px;padding:2px 9px;cursor:pointer}'
+ '#presets button:hover,#presets button:focus-visible{color:#e6e9f0;border-color:#4a5573;outline:none}'
+ '#say{position:fixed;left:50%;top:20px;transform:translateX(-50%);width:min(72ch,84vw);'
+ 'max-height:calc(100vh - var(--footh) - 56px);min-width:280px;min-height:64px;background:#0e121bf2;'
+ 'border:1px solid #1b2030;border-radius:8px;padding:0;font:14px/1.5 ui-monospace,Menlo,Consolas,monospace;color:#cfe3f2;'
+ 'z-index:21;resize:both;overflow:hidden;display:none;flex-direction:column}'
+ '#say.open{display:flex}'
+ '#say.max{left:12px;top:12px;right:12px;bottom:calc(var(--footh) + 12px);transform:none;width:auto;max-height:none;height:auto}'
+ '#say.min{height:auto!important;max-height:none;min-height:0;resize:none;width:min(48ch,84vw)} #say.min #saybody{display:none}'
+ '#saybar{display:flex;align-items:center;gap:6px;padding:4px 8px;border-bottom:1px solid #1b2030;background:#11151f;'
+ 'cursor:move;user-select:none;font-size:11px;color:#8b93a7;letter-spacing:.06em;text-transform:uppercase}'
+ '#saybar span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}'
+ '#saybar button{font:12px ui-monospace,Menlo,Consolas,monospace;background:#0e121b;color:#cfe3f2;border:1px solid #1b2030;'
+ 'border-radius:4px;width:24px;height:22px;cursor:pointer;padding:0}'
+ '#saybar button:hover,#saybar button:focus-visible{border-color:#5ec8f2;outline:none}'
+ '#saybody{padding:.8rem 1.1rem;overflow:auto;flex:1}'
+ '#saybody b{color:#5ec8f2;font-weight:600}#saybody i{color:#f2b05e;font-style:normal}'
+ '#saybody p{margin:.45rem 0}#saybody .dimtext{color:#8b93a7;font-size:12px;line-height:1.45}'
+ '#saybody table{border-collapse:collapse;width:100%;margin:.5rem 0}'
+ '#saybody td{padding:2px 0;border-bottom:1px solid #1b2030;font-size:12.5px}#saybody td+td{text-align:right;color:#fff}'
+ '#saybody code{display:block;background:#11151f;border:1px solid #1b2030;border-radius:4px;padding:4px 7px;color:#cfe3f2;'
+ 'margin:6px 0;font-size:11.5px;word-break:break-all}'
+ '#saybody .more,#saybody .edit{background:none;border:0;color:#8b93a7;font:inherit;font-size:11.5px;text-decoration:underline;cursor:pointer;padding:4px 0}'
+ '#saybody .more:hover,#saybody .edit:hover{color:#5ec8f2}'
+ '#saybody #apps{display:flex;flex-wrap:wrap;gap:6px;margin:.4rem 0 .2rem}'
+ '#saybody .viewrow{display:flex;flex-wrap:wrap;gap:6px;margin:.4rem 0 .2rem}'
+ '#saybody .viewrow button{font:11px/1.6 ui-monospace,Menlo,Consolas,monospace;color:#8b93a7;background:#0b0e14;'
+ 'border:1px solid #232a3a;border-radius:4px;padding:3px 9px;cursor:pointer}'
+ '#saybody .boxes{display:grid;grid-template-columns:1fr 1fr;gap:3px 12px;margin:.5rem 0 .2rem;'