@* Static FOCAS address builder: parameter group + parameter ID → axis:5 *@
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Pickers

<div class="row g-3">
    <div class="col-md-4">
        <label class="form-label">Parameter group</label>
        <select class="form-select form-select-sm" @bind="_group" @bind:after="OnChangedAsync">
            <option value="axis">axis</option>
            <option value="spindle">spindle</option>
            <option value="program">program</option>
            <option value="status">status</option>
        </select>
    </div>
    <div class="col-md-3">
        <label class="form-label">Parameter ID</label>
        <input type="number" class="form-control form-control-sm" min="0"
               @bind="_parameterId" @bind:after="OnChangedAsync" />
    </div>
</div>

<div class="mt-3">
    <span class="text-muted small">Result:</span>
    <code class="mono ms-2">@_built</code>
</div>

@code {
    [Parameter] public string CurrentAddress { get; set; } = "";
    [Parameter] public EventCallback<string> CurrentAddressChanged { get; set; }

    private string _group = "axis";
    private int _parameterId = 0;
    private string _built = "";

    protected override void OnInitialized()
    {
        _built = FocasAddressBuilder.Build(_group, _parameterId);
        _ = CurrentAddressChanged.InvokeAsync(_built);
    }

    private async Task OnChangedAsync()
    {
        _built = FocasAddressBuilder.Build(_group, _parameterId);
        await CurrentAddressChanged.InvokeAsync(_built);
    }
}
