# Profile

- File ID: file:11crtur:profile-razor
- Path: NexusReader.UI.Shared/Pages/Account/Profile.razor
- Role: ui-page
- Layer: frontend

## Purpose

Blazor UI page that displays the authenticated user's profile, AI usage, metrics and account actions (upgrade/logout); fetches profile on init and renders conditional UI based on profile state.

## Key Details

Component fetches profile on init, renders loading vs profile UI, computes AI token usage percent, supports logout via IdentityService and client-side navigation; upgrade action is a TODO placeholder.

## Symbols

- Render (markup): Renders the profile UI, shows loading state when _profile is null, binds profile fields into the UI, and wires button click handlers.
- OnInitializedAsync(): Lifecycle init method: asynchronously requests the current user's profile from IdentityService and updates component state.
- CalculateProgress(): Calculates percentage of AI tokens used and clamps it to a maximum of 100.
- HandleUpgrade(): Placeholder click handler intended to redirect user to billing/upgrade flow (not yet implemented).
- HandleLogout(): Performs logout by calling IdentityService.LogoutAsync and then navigates to the logout form route.

## Dependencies

- imports NexusReader.UI.Shared/Components/Atoms/NexusIcon.razor

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.UI.Shared/Services/IIdentityService.cs
- dependency-target: UserProfileDto (referenced model)
- call-target: self
- call-target: NexusReader.UI.Shared/Components/Atoms/NexusIcon.razor
- call-target: NexusReader.UI.Shared/Components/Atoms/NexusIcon.razor
- call-target: NexusReader.UI.Shared/Components/Atoms/NexusIcon.razor
- call-target: NexusReader.UI.Shared/Components/Atoms/NexusIcon.razor
- call-target: NexusReader.UI.Shared/Components/Atoms/NexusIcon.razor
- call-target: NexusReader.UI.Shared/Services/IIdentityService.cs
- call-target: NexusReader.UI.Shared/Services/IIdentityService.cs
- interaction-target: await IdentityService.GetProfileAsync()
- interaction-target: await IdentityService.LogoutAsync()

## Coverage

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

## Control Flow Fragments

- Render (markup): 23 nodes, 25 edges, 6 jumps, 0 unsupported constructs
- OnInitializedAsync: 14 nodes, 15 edges, 1 jumps, 0 unsupported constructs
- CalculateProgress: 11 nodes, 12 edges, 0 jumps, 0 unsupported constructs
- HandleUpgrade: 3 nodes, 2 edges, 0 jumps, 0 unsupported constructs
- HandleLogout: 6 nodes, 5 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### Profile Neighborhood

```mermaid
flowchart LR
    file_11crtur_profile_razor("Profile")
    method_12nkjhc_handleupgrade[["HandleUpgrade()"]]
    method_1jxczws_handlelogout[["HandleLogout()"]]
    method_hkgxib_render_markup[["Render (markup)"]]
    method_k7fbfq_calculateprogress[["CalculateProgress()"]]
    method_z1n8tn_oninitializedasync[["OnInitializedAsync()"]]
    file_q8opk3_nexusicon_razor[/"NexusIcon"/]
    file_11crtur_profile_razor -->|NexusIcon| file_q8opk3_nexusicon_razor
```

### Profile Execution Overview

```mermaid
flowchart TD
    file_11crtur_profile_razor("Profile")
    method_12nkjhc_handleupgrade[["HandleUpgrade()"]]
    method_1jxczws_handlelogout[["HandleLogout()"]]
    method_hkgxib_render_markup[["Render (markup)"]]
    method_k7fbfq_calculateprogress[["CalculateProgress()"]]
    method_z1n8tn_oninitializedasync[["OnInitializedAsync()"]]
    unresolved_unresolved_1ctw7yr_call_target{"Unresolved: CalculateProgress"}
    unresolved_unresolved_1gsymmw_interaction_target{"Unresolved: await IdentityService.GetProfileAsync()"}
    unresolved_unresolved_1il3ph9_interaction_target{"Unresolved: await IdentityService.LogoutAsync()"}
    unresolved_unresolved_1o2g49e_call_target{"Unresolved: NexusIcon"}
    unresolved_unresolved_m82hyv_call_target{"Unresolved: LogoutAsync"}
    unresolved_unresolved_sd5ygw_call_target{"Unresolved: GetProfileAsync"}
    file_11crtur_profile_razor -->|contains| method_12nkjhc_handleupgrade
    file_11crtur_profile_razor -->|contains| method_1jxczws_handlelogout
    file_11crtur_profile_razor -->|contains| method_hkgxib_render_markup
    file_11crtur_profile_razor -->|contains| method_k7fbfq_calculateprogress
    file_11crtur_profile_razor -->|contains| method_z1n8tn_oninitializedasync
    file_11crtur_profile_razor -->|unresolved interaction| unresolved_unresolved_1gsymmw_interaction_target
    file_11crtur_profile_razor -->|unresolved interaction| unresolved_unresolved_1il3ph9_interaction_target
    method_1jxczws_handlelogout -->|unresolved call| unresolved_unresolved_m82hyv_call_target
    method_hkgxib_render_markup -->|unresolved call| unresolved_unresolved_1ctw7yr_call_target
    method_hkgxib_render_markup -->|unresolved call| unresolved_unresolved_1o2g49e_call_target
    method_hkgxib_render_markup -->|unresolved call| unresolved_unresolved_1o2g49e_call_target
    method_hkgxib_render_markup -->|unresolved call| unresolved_unresolved_1o2g49e_call_target
    method_hkgxib_render_markup -->|unresolved call| unresolved_unresolved_1o2g49e_call_target
    method_hkgxib_render_markup -->|unresolved call| unresolved_unresolved_1o2g49e_call_target
    method_z1n8tn_oninitializedasync -->|unresolved call| unresolved_unresolved_sd5ygw_call_target
```

### Render (markup)() Control Flow

_Warnings: diagram method_hkgxib_render_markup__fragment_diagram exceeds preferred complexity thresholds (23 nodes, 25 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_hkgxib_render_markup__call_44_NexusIcon[["NexusIcon"]]
    method_hkgxib_render_markup__call_55_CalculateProgress[["CalculateProgress"]]
    method_hkgxib_render_markup__call_65_NexusIcon[["NexusIcon"]]
    method_hkgxib_render_markup__call_74_NexusIcon[["NexusIcon"]]
    method_hkgxib_render_markup__call_83_NexusIcon[["NexusIcon"]]
    method_hkgxib_render_markup__call_94_NexusIcon[["NexusIcon"]]
    method_hkgxib_render_markup__action_14_guard_clause_14__condition{"_profile == null"}
    method_hkgxib_render_markup__action_14_guard_clause_14__false("render-profile")
    method_hkgxib_render_markup__action_14_guard_clause_14__merge("merge")
    method_hkgxib_render_markup__action_14_guard_clause_14__true("render-loading")
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__condition{"_profile == null"}
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__false("false")
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__merge("merge")
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__true("true")
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__condition{"Falls back to alternate path"}
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__false("otherwise")
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__merge("merge")
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__true("fallback")
    method_hkgxib_render_markup__action_29_data_binding_29__linear("Bind profile fields into UI")
    method_hkgxib_render_markup__action_44_component_usage_44__linear("Uses NexusIcon components to render icons")
    method_hkgxib_render_markup__action_92_event_handler_attachment_92__linear("Hook UI buttons to component handlers")
    method_hkgxib_render_markup__entry(["Render (markup) entry"])
    method_hkgxib_render_markup__implicit_return(["return"])
    method_hkgxib_render_markup__action_14_guard_clause_14__condition -->|render-profile| method_hkgxib_render_markup__action_14_guard_clause_14__false
    method_hkgxib_render_markup__action_14_guard_clause_14__condition -->|render-loading| method_hkgxib_render_markup__action_14_guard_clause_14__true
    method_hkgxib_render_markup__action_14_guard_clause_14__false -->|next| method_hkgxib_render_markup__action_14_guard_clause_14__merge
    method_hkgxib_render_markup__action_14_guard_clause_14__merge -->|fallback| method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__condition
    method_hkgxib_render_markup__action_14_guard_clause_14__true -->|next| method_hkgxib_render_markup__action_14_guard_clause_14__merge
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__condition -->|false| method_hkgxib_render_markup__action_14_render_markup_branch_14_0__false
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__condition -->|true| method_hkgxib_render_markup__action_14_render_markup_branch_14_0__true
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__false -->|next| method_hkgxib_render_markup__action_14_render_markup_branch_14_0__merge
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__merge -->|next| method_hkgxib_render_markup__action_14_guard_clause_14__condition
    method_hkgxib_render_markup__action_14_render_markup_branch_14_0__true -->|next| method_hkgxib_render_markup__action_14_render_markup_branch_14_0__merge
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__condition -->|otherwise| method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__false
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__condition -->|fallback| method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__true
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__false -->|next| method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__merge
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__merge -->|next| method_hkgxib_render_markup__action_29_data_binding_29__linear
    method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__true -->|next| method_hkgxib_render_markup__action_21_render_markup_fallback_21_1__merge
    method_hkgxib_render_markup__action_29_data_binding_29__linear -->|next| method_hkgxib_render_markup__action_44_component_usage_44__linear
    method_hkgxib_render_markup__action_44_component_usage_44__linear -->|Name= robot , Size=24, Color=var --nexus-neon| method_hkgxib_render_markup__call_44_NexusIcon
    method_hkgxib_render_markup__action_92_event_handler_attachment_92__linear -->|Name= log-out , Size=18| method_hkgxib_render_markup__call_94_NexusIcon
    method_hkgxib_render_markup__call_44_NexusIcon -->|none| method_hkgxib_render_markup__call_55_CalculateProgress
    method_hkgxib_render_markup__call_55_CalculateProgress -->|Name= activity , Size=24, Color=var --nexus-neon| method_hkgxib_render_markup__call_65_NexusIcon
    method_hkgxib_render_markup__call_65_NexusIcon -->|Name= book-open , Size=14| method_hkgxib_render_markup__call_74_NexusIcon
    method_hkgxib_render_markup__call_74_NexusIcon -->|Name= shield , Size=24, Color=var --nexus-neon| method_hkgxib_render_markup__call_83_NexusIcon
    method_hkgxib_render_markup__call_83_NexusIcon -->|next| method_hkgxib_render_markup__action_92_event_handler_attachment_92__linear
    method_hkgxib_render_markup__call_94_NexusIcon -->|return| method_hkgxib_render_markup__implicit_return
    method_hkgxib_render_markup__entry -->|next| method_hkgxib_render_markup__action_14_render_markup_branch_14_0__condition
```

### OnInitializedAsync() Control Flow

```mermaid
flowchart TD
    method_z1n8tn_oninitializedasync__call_113_GetProfileAsync[["GetProfileAsync"]]
    method_z1n8tn_oninitializedasync__action_113_oninitializedasync_await_113_0__await[["Waits for async work"]]
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__condition{"result.IsSuccess"}
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__false("no-op")
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__merge("merge")
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__true("assign-_profile")
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__condition{"result.IsSuccess"}
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__false("false")
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__merge("merge")
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__true("true")
    method_z1n8tn_oninitializedasync__action_118_state_change_118__linear("Trigger UI refresh")
    method_z1n8tn_oninitializedasync__entry(["OnInitializedAsync entry"])
    method_z1n8tn_oninitializedasync__action_113_external_call_113__linear("Fetch profile from identity service")
    method_z1n8tn_oninitializedasync__implicit_return(["return"])
    method_z1n8tn_oninitializedasync__action_113_external_call_113__linear -->|none| method_z1n8tn_oninitializedasync__call_113_GetProfileAsync
    method_z1n8tn_oninitializedasync__action_113_oninitializedasync_await_113_0__await -->|next| method_z1n8tn_oninitializedasync__action_113_external_call_113__linear
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__condition -->|no-op| method_z1n8tn_oninitializedasync__action_114_guard_clause_114__false
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__condition -->|assign-_profile| method_z1n8tn_oninitializedasync__action_114_guard_clause_114__true
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__false -->|next| method_z1n8tn_oninitializedasync__action_114_guard_clause_114__merge
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__merge -->|next| method_z1n8tn_oninitializedasync__action_118_state_change_118__linear
    method_z1n8tn_oninitializedasync__action_114_guard_clause_114__true -->|next| method_z1n8tn_oninitializedasync__action_114_guard_clause_114__merge
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__condition -->|false| method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__false
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__condition -->|true| method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__true
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__false -->|next| method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__merge
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__merge -->|next| method_z1n8tn_oninitializedasync__action_114_guard_clause_114__condition
    method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__true -->|next| method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__merge
    method_z1n8tn_oninitializedasync__action_118_state_change_118__linear -->|return| method_z1n8tn_oninitializedasync__implicit_return
    method_z1n8tn_oninitializedasync__call_113_GetProfileAsync -->|next| method_z1n8tn_oninitializedasync__action_114_oninitializedasync_branch_114_1__condition
    method_z1n8tn_oninitializedasync__entry -->|next| method_z1n8tn_oninitializedasync__action_113_oninitializedasync_await_113_0__await
```

### CalculateProgress() Control Flow

```mermaid
flowchart TD
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__condition{"_profile == null || _profile.AITokenLimit == 0"}
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__false("continue")
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__merge("merge")
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__true("exit")
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__condition{"_profile == null || _profile.AITokenLimit == 0"}
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__false("compute-percent")
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__merge("merge")
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__true("return-0")
    method_k7fbfq_calculateprogress__action_124_calculation_124__linear("Compute percentage and cap")
    method_k7fbfq_calculateprogress__entry(["CalculateProgress entry"])
    method_k7fbfq_calculateprogress__action_125_calculateprogress_return_125_1__return(["Returns result"])
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__condition -->|continue| method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__false
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__condition -->|exit| method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__true
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__false -->|next| method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__merge
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__merge -->|next| method_k7fbfq_calculateprogress__action_123_guard_clause_123__condition
    method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__true -->|next| method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__merge
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__condition -->|compute-percent| method_k7fbfq_calculateprogress__action_123_guard_clause_123__false
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__condition -->|return-0| method_k7fbfq_calculateprogress__action_123_guard_clause_123__true
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__false -->|next| method_k7fbfq_calculateprogress__action_123_guard_clause_123__merge
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__merge -->|next| method_k7fbfq_calculateprogress__action_124_calculation_124__linear
    method_k7fbfq_calculateprogress__action_123_guard_clause_123__true -->|next| method_k7fbfq_calculateprogress__action_123_guard_clause_123__merge
    method_k7fbfq_calculateprogress__action_124_calculation_124__linear -->|return| method_k7fbfq_calculateprogress__action_125_calculateprogress_return_125_1__return
    method_k7fbfq_calculateprogress__entry -->|next| method_k7fbfq_calculateprogress__action_123_calculateprogress_guard_clause_123_0__condition
```

### HandleLogout() Control Flow

```mermaid
flowchart TD
    method_1jxczws_handlelogout__call_135_LogoutAsync[["LogoutAsync"]]
    method_1jxczws_handlelogout__action_135_handlelogout_await_135_0__await[["Waits for async work"]]
    method_1jxczws_handlelogout__action_136_navigation_136__linear("Redirect to logout route")
    method_1jxczws_handlelogout__entry(["HandleLogout entry"])
    method_1jxczws_handlelogout__action_135_external_call_135__linear("Invoke logout on identity service")
    method_1jxczws_handlelogout__implicit_return(["return"])
    method_1jxczws_handlelogout__action_135_external_call_135__linear -->|none| method_1jxczws_handlelogout__call_135_LogoutAsync
    method_1jxczws_handlelogout__action_135_handlelogout_await_135_0__await -->|next| method_1jxczws_handlelogout__action_135_external_call_135__linear
    method_1jxczws_handlelogout__action_136_navigation_136__linear -->|return| method_1jxczws_handlelogout__implicit_return
    method_1jxczws_handlelogout__call_135_LogoutAsync -->|next| method_1jxczws_handlelogout__action_136_navigation_136__linear
    method_1jxczws_handlelogout__entry -->|next| method_1jxczws_handlelogout__action_135_handlelogout_await_135_0__await
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 7 unresolved jumps.
- Warning: control-flow: diagram method_hkgxib_render_markup__fragment_diagram exceeds preferred complexity thresholds (23 nodes, 25 edges).
