'use strict'; // Status-badge composition. Three states the editor cares about: // - red ring : config error (flow bounds invalid) // - yellow ring: sampling but cooldown is gating the next pulse // - green dot : sampling normally // - grey ring : idle // Shape mirrors the legacy nodeClass._updateNodeStatus output verbatim. const { statusBadge } = require('generalFunctions'); const params = require('../parameters/parameters'); function buildStatusBadge(m) { if (m.invalidFlowBounds) { return statusBadge.error(`Config error: nominalFlowMin (${m.nominalFlowMin}) >= flowMax (${m.flowMax})`); } if (m.running) { const levelText = `${m.bucketVol}/${m.maxVolume} L`; const cooldownMs = params.getSampleCooldownMs(m); if (cooldownMs > 0) { return statusBadge.compose([`SAMPLING (${Math.ceil(cooldownMs / 1000)}s)`, levelText], { fill: 'yellow', shape: 'ring' }); } return statusBadge.compose([`AI: RUNNING`, levelText], { fill: 'green', shape: 'dot' }); } return statusBadge.idle('AI: IDLE'); } module.exports = { buildStatusBadge };