using WebAssembly.Data; namespace WebAssembly.Services; public class SearchService : ISearchService { private bool _isLoaded; public List SearchPoints { get; set; } = new(); public Dictionary> Searches { get; set; } = new(); public bool IsVisible { get; set; } public void Subscribe(Action action) { OnChange += action; } public void Unsubscribe(Action action) { OnChange += action; } public void Search(string entityId) { } public async Task Load() { Searches.Add("MagicMaterial", []); foreach (var entity in MagicMaterialsData.RawData) { var title = entity.Name; var description = entity.Description ?? ""; var summary = description.Length > 35 ? description[..30].Trim() + "..." : description.Length > 0 ? description : ""; SearchPoints.Add(new SearchPointModel { Title = title, Tags = "Magic Material", PointType = "Entity", Summary = summary, Href = ""// Add a link to the entity page }); Searches["MagicMaterial"].Add(SearchPoints.Last()); } _isLoaded = true; NotifyDataChanged(); } public bool IsLoaded() { return _isLoaded; } public void Show() { IsVisible = true; NotifyDataChanged(); } public void Hide() { IsVisible = false; NotifyDataChanged(); } private event Action OnChange = null!; private void NotifyDataChanged() { OnChange(); } }