# Library

- File ID: file:1uhcs2l:library-razor
- Path: NexusReader.UI.Shared/Pages/Library.razor
- Role: ui-page
- Layer: frontend

## Purpose

Blazor UI page that displays the user's library of e-books, loads last-read book summaries from the API, and provides UI to ingest new books or open a selected book.

## Key Details

Component loads /api/library/books (line 526), shows loading/empty/collection UI with loops and conditionals in markup, binds a modal to refresh the list (line 23), and navigates to a book via IReaderNavigationService (line 551).

## Symbols

- Library: Blazor UI page that displays the user's library of e-books, loads last-read book summaries from the API, and provides UI to ingest new books or open a selected book.
- OnAfterRenderAsync(): Lifecycle override that triggers initial load of books on first render.
- LoadBooksAsync(): Loads the list of last-read books from the backend API and updates component state with loading/success/failure handling.
- RefreshLibrary(): Public refresh helper invoked after the ingestion modal closes to reload the library.
- OpenBook(): Navigate to the reader view for the selected book using the injected navigation service.

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.DTOs.User (LastReadBookDto)
- dependency-target: NexusReader.UI.Shared/Services/IReaderNavigationService
- dependency-target: BookIngestionModal component (markup bind at line 23)
- dependency-target: NexusButton component (uses OnClick at line 17)
- call-target: self
- call-target: self
- call-target: NexusReader.UI.Shared/Services/IReaderNavigationService
- interaction-target: await Http.GetFromJsonAsync<List<LastReadBookDto>>("api/library/books");

## Coverage

- Symbols: 5
- Executable symbols: 4
- Executable symbols with control flow: 4
- Grounded edges: 5
- Unresolved references: 8
- Control-flow fragments: 4
- Unresolved jumps: 1
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 5

## Control Flow Fragments

- OnAfterRenderAsync: 12 nodes, 13 edges, 1 jumps, 0 unsupported constructs
- LoadBooksAsync: 15 nodes, 15 edges, 0 jumps, 0 unsupported constructs
- RefreshLibrary: 5 nodes, 4 edges, 1 jumps, 0 unsupported constructs
- OpenBook: 4 nodes, 3 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### Library Neighborhood

```mermaid
flowchart LR
    class_g9nkgg_library("Library")
    file_1uhcs2l_library_razor("Library")
    method_1ffpsuv_refreshlibrary[["RefreshLibrary()"]]
    method_676x78_loadbooksasync[["LoadBooksAsync()"]]
    method_8gksn2_openbook[["OpenBook()"]]
    method_bktx49_onafterrenderasync[["OnAfterRenderAsync()"]]
```

### Library Execution Overview

```mermaid
flowchart TD
    class_g9nkgg_library("Library")
    method_1ffpsuv_refreshlibrary[["RefreshLibrary()"]]
    method_676x78_loadbooksasync[["LoadBooksAsync()"]]
    method_8gksn2_openbook[["OpenBook()"]]
    method_bktx49_onafterrenderasync[["OnAfterRenderAsync()"]]
    unresolved_unresolved_14z0mrx_call_target{"Unresolved: LoadBooksAsync"}
    unresolved_unresolved_1n18eoi_interaction_target{"Unresolved: await Http.GetFromJsonAsync<List<LastReadBookDto>>(\\"api/library/books\\");"}
    unresolved_unresolved_fkkw23_call_target{"Unresolved: LoadBooksAsync"}
    unresolved_unresolved_iaaoqf_call_target{"Unresolved: NavigateToBook"}
    class_g9nkgg_library -->|contains| method_1ffpsuv_refreshlibrary
    class_g9nkgg_library -->|contains| method_676x78_loadbooksasync
    class_g9nkgg_library -->|contains| method_8gksn2_openbook
    class_g9nkgg_library -->|contains| method_bktx49_onafterrenderasync
    class_g9nkgg_library -->|unresolved interaction| unresolved_unresolved_1n18eoi_interaction_target
    method_1ffpsuv_refreshlibrary -->|unresolved call| unresolved_unresolved_14z0mrx_call_target
    method_8gksn2_openbook -->|unresolved call| unresolved_unresolved_iaaoqf_call_target
    method_bktx49_onafterrenderasync -->|unresolved call| unresolved_unresolved_fkkw23_call_target
```

### OnAfterRenderAsync() Control Flow

```mermaid
flowchart TD
    method_bktx49_onafterrenderasync__call_515_LoadBooksAsync[["LoadBooksAsync"]]
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__condition{"firstRender == true"}
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__false("no-op")
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__merge("merge")
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__true("load invoked")
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__condition{"firstRender"}
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__false("false")
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__merge("merge")
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__true("true")
    method_bktx49_onafterrenderasync__action_515_onafterrenderasync_await_515_1__await[["Waits for async work"]]
    method_bktx49_onafterrenderasync__entry(["OnAfterRenderAsync entry"])
    method_bktx49_onafterrenderasync__implicit_return(["return"])
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__condition -->|no-op| method_bktx49_onafterrenderasync__action_513_guard_clause_513__false
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__condition -->|load invoked| method_bktx49_onafterrenderasync__action_513_guard_clause_513__true
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__false -->|next| method_bktx49_onafterrenderasync__action_513_guard_clause_513__merge
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__merge -->|next| method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__condition
    method_bktx49_onafterrenderasync__action_513_guard_clause_513__true -->|next| method_bktx49_onafterrenderasync__action_513_guard_clause_513__merge
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__condition -->|false| method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__false
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__condition -->|true| method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__true
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__false -->|next| method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__merge
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__merge -->|next| method_bktx49_onafterrenderasync__action_515_onafterrenderasync_await_515_1__await
    method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__true -->|next| method_bktx49_onafterrenderasync__action_513_onafterrenderasync_branch_513_0__merge
    method_bktx49_onafterrenderasync__action_515_onafterrenderasync_await_515_1__await -->|none| method_bktx49_onafterrenderasync__call_515_LoadBooksAsync
    method_bktx49_onafterrenderasync__call_515_LoadBooksAsync -->|return| method_bktx49_onafterrenderasync__implicit_return
    method_bktx49_onafterrenderasync__entry -->|next| method_bktx49_onafterrenderasync__action_513_guard_clause_513__condition
```

### LoadBooksAsync() Control Flow

```mermaid
flowchart TD
    method_676x78_loadbooksasync__action_521_state_change_521__linear("Set loading indicator true")
    method_676x78_loadbooksasync__action_524_loadbooksasync_try_524_0__try("Begins protected execution")
    method_676x78_loadbooksasync__action_524_try_catch_finally_524__linear("Exception handling and fallback for browser environment")
    method_676x78_loadbooksasync__action_526_loadbooksasync_await_526_1__await[["Waits for async work"]]
    method_676x78_loadbooksasync__action_527_state_change_527__linear("Store loaded books and clear loading flag")
    method_676x78_loadbooksasync__action_529_loadbooksasync_catch_529_2__catch("catch Exception ex")
    method_676x78_loadbooksasync__action_531_log_531__linear("Log load failure to console")
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__condition{"OperatingSystem.IsBrowser()"}
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__false("false")
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__merge("merge")
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__true("true")
    method_676x78_loadbooksasync__action_537_loadbooksasync_finally_537_4__finally("Runs cleanup or finalization")
    method_676x78_loadbooksasync__entry(["LoadBooksAsync entry"])
    method_676x78_loadbooksasync__action_526_external_call_526__linear("Fetch books from API endpoint")
    method_676x78_loadbooksasync__implicit_return(["return"])
    method_676x78_loadbooksasync__action_521_state_change_521__linear -->|next| method_676x78_loadbooksasync__action_524_try_catch_finally_524__linear
    method_676x78_loadbooksasync__action_524_loadbooksasync_try_524_0__try -->|next| method_676x78_loadbooksasync__action_526_loadbooksasync_await_526_1__await
    method_676x78_loadbooksasync__action_524_try_catch_finally_524__linear -->|next| method_676x78_loadbooksasync__action_524_loadbooksasync_try_524_0__try
    method_676x78_loadbooksasync__action_526_external_call_526__linear -->|next| method_676x78_loadbooksasync__action_527_state_change_527__linear
    method_676x78_loadbooksasync__action_526_loadbooksasync_await_526_1__await -->|next| method_676x78_loadbooksasync__action_526_external_call_526__linear
    method_676x78_loadbooksasync__action_527_state_change_527__linear -->|exception| method_676x78_loadbooksasync__action_529_loadbooksasync_catch_529_2__catch
    method_676x78_loadbooksasync__action_529_loadbooksasync_catch_529_2__catch -->|next| method_676x78_loadbooksasync__action_531_log_531__linear
    method_676x78_loadbooksasync__action_531_log_531__linear -->|next| method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__condition
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__condition -->|false| method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__false
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__condition -->|true| method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__true
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__false -->|next| method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__merge
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__merge -->|next| method_676x78_loadbooksasync__action_537_loadbooksasync_finally_537_4__finally
    method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__true -->|next| method_676x78_loadbooksasync__action_532_loadbooksasync_branch_532_3__merge
    method_676x78_loadbooksasync__action_537_loadbooksasync_finally_537_4__finally -->|return| method_676x78_loadbooksasync__implicit_return
    method_676x78_loadbooksasync__entry -->|next| method_676x78_loadbooksasync__action_521_state_change_521__linear
```

### OpenBook() Control Flow

```mermaid
flowchart TD
    method_8gksn2_openbook__call_551_NavigateToBook[["NavigateToBook"]]
    method_8gksn2_openbook__action_77_invoked_from_markup_77__linear("Invoked by book card click")
    method_8gksn2_openbook__entry(["OpenBook entry"])
    method_8gksn2_openbook__implicit_return(["return"])
    method_8gksn2_openbook__action_77_invoked_from_markup_77__linear -->|bookId Guid| method_8gksn2_openbook__call_551_NavigateToBook
    method_8gksn2_openbook__call_551_NavigateToBook -->|return| method_8gksn2_openbook__implicit_return
    method_8gksn2_openbook__entry -->|next| method_8gksn2_openbook__action_77_invoked_from_markup_77__linear
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 1 unresolved jumps.
