import '../nui-icon/nui-icon.js'; import { html, nothing, type TemplateResult } from 'lit'; import type { NuiType } from '../../types/nui-type.js'; import type { MeterItem } from './types.js'; export interface NuiMeterGroupViewState { value: MeterItem[]; min: number; max: number; orientation: 'horizontal' | 'vertical'; labelPosition: 'start' | 'end' | 'none'; labelOrientation: 'horizontal' | 'vertical'; unstyled: boolean; nuiType: NuiType; meterGroupClass: string; } function getMeterGroupClass(state: NuiMeterGroupViewState): string { return ['nui-meter-group', state.meterGroupClass].filter(Boolean).join(' '); } export function renderMeterGroup( state: NuiMeterGroupViewState, ): TemplateResult { const min = state.min; const max = state.max; const range = max - min > 0 ? max - min : 100; const items = state.value || []; // Calculate percentages const calculatedItems = items.map((item) => { const percent = Math.max(0, (item.value / range) * 100); return { ...item, percent, }; }); const renderMeters = () => html`