@page "/tracks/{EntryKey}"
@using DeepDrftPublic.Client.Services
@inject IReleaseDataService ReleaseData
@inject NavigationManager Navigation

@* Addressable deep-link fallback for a bare release EntryKey (Phase 11 §2, shape iii). Unlike the
   player bar / Archive / AlbumsView call sites, an external /tracks/{entryKey} link carries only the
   key, so this page fetches the release to discover its medium, then forwards through the same
   ReleaseRoutes resolver — one medium→route table, no second source. replace:true keeps the router
   out of history so Back skips this hop. Capture EntryKey before the await per the InteractiveAuto
   route-param convention. *@

@code {
    [Parameter] public string EntryKey { get; set; } = string.Empty;

    protected override async Task OnParametersSetAsync()
    {
        var entryKey = EntryKey;
        var result = await ReleaseData.GetByEntryKey(entryKey);

        var target = result is { Success: true, Value: { } release }
            ? ReleaseRoutes.DetailHref(release)
            : "/cuts"; // Unknown key: fall back to the Cuts gallery rather than 404.

        Navigation.NavigateTo(target, forceLoad: false, replace: true);
    }
}
