# IdentityService

- File ID: file:b8uv8h:identityservice-cs
- Path: NexusReader.UI.Shared/Services/IdentityService.cs
- Role: service
- Layer: frontend

## Purpose

Client-side identity helper used by UI layers to register, login, logout, refresh tokens and fetch/cached user profile information; bridges HttpClient, native secure storage and the app authentication state provider.

## Key Details

Implements client auth flows with local secure storage, rate-limited profile fetching, single-flight deduplication for profile requests and ties into a NexusAuthenticationStateProvider via casts to notify/clear state. Non-browser environments skip profile fetching.

## Symbols

- IdentityService: Client-side identity helper used by UI layers to register, login, logout, refresh tokens and fetch/cached user profile information; bridges HttpClient, native secure storage and the app authentication state provider.
- IdentityService(): Constructs the identity service wiring HttpClient, native storage and optional auth state provider.
- RegisterAsync(): Sends registration request to the backend and returns success/failure result.
- LoginAsync(): Performs login against backend, stores tokens, invalidates auth state, fetches profile and persists profile metadata; returns success/failure.
- LogoutAsync(): Clears cached profile and, on browser, erases stored tokens/profile metadata; notifies auth provider and triggers state invalidation.
- GetProfileAsync(): Public cached-profile accessor: returns cached profile, reuses an in-flight profile task if present, otherwise triggers background fetch and returns its result wrapped in Result.
- GetProfileInternalAsync(): Performs the actual HTTP profile fetch with basic rate-limiting, updates cache/storage and notifies auth provider; handles unauthorized by logging out.
- RefreshTokenAsync(): Attempts to refresh access token using stored refresh token, persists new tokens, invalidates auth state and refreshes profile information.
- LoginResponse: Local DTO used to deserialize login/refresh responses (token, expiry, refresh token).

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions.Services (IIdentityService) -> unknown file
- dependency-target: NexusReader.Application.DTOs.User (UserProfileDto) -> unknown file
- dependency-target: NexusReader.Application.Constants (StorageKeys) -> unknown file
- dependency-target: INativeStorageService -> unknown file
- dependency-target: NexusAuthenticationStateProvider -> unknown file
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: self
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: self
- call-target: self
- call-target: unknown
- call-target: unknown
- call-target: unknown
- call-target: unknown
- interaction-target: Calls HttpClient.PostAsJsonAsync to 'identity/register' (framework call omitted from calls list)
- interaction-target: HttpClient.GetAsync('identity/profile') (framework call omitted from calls list)
- interaction-target: Calls HttpClient.PostAsJsonAsync to 'identity/refresh' (framework call omitted from calls list)

## Coverage

- Symbols: 9
- Executable symbols: 7
- Executable symbols with control flow: 7
- Grounded edges: 9
- Unresolved references: 41
- Control-flow fragments: 7
- Unresolved jumps: 29
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 8

## Control Flow Fragments

- IdentityService: 3 nodes, 2 edges, 0 jumps, 0 unsupported constructs
- RegisterAsync: 12 nodes, 12 edges, 0 jumps, 0 unsupported constructs
- LoginAsync: 66 nodes, 73 edges, 9 jumps, 0 unsupported constructs
- LogoutAsync: 32 nodes, 33 edges, 8 jumps, 0 unsupported constructs
- GetProfileAsync: 24 nodes, 27 edges, 1 jumps, 0 unsupported constructs
- GetProfileInternalAsync: 60 nodes, 67 edges, 5 jumps, 0 unsupported constructs
- RefreshTokenAsync: 64 nodes, 71 edges, 10 jumps, 0 unsupported constructs

## Diagrams

### IdentityService Neighborhood

```mermaid
flowchart LR
    class_vgua1e_identityservice("IdentityService")
    file_b8uv8h_identityservice_cs("IdentityService")
    method_1i33wis_logoutasync[["LogoutAsync()"]]
    method_1u6514u_getprofileasync[["GetProfileAsync()"]]
    method_8ggznb_identityservice[["IdentityService()"]]
    method_b6asoe_loginasync[["LoginAsync()"]]
    method_kf6qfg_registerasync[["RegisterAsync()"]]
    method_nb75z9_refreshtokenasync[["RefreshTokenAsync()"]]
    method_nyrl9z_getprofileinternalasync[["GetProfileInternalAsync()"]]
    type_14gvkuy_loginresponse[/"LoginResponse"/]
```

### IdentityService Execution Overview

_Warnings: diagram file_b8uv8h_identityservice_cs_execution_view exceeds preferred complexity thresholds (30 nodes, 43 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    class_vgua1e_identityservice("IdentityService")
    method_1i33wis_logoutasync[["LogoutAsync()"]]
    method_1u6514u_getprofileasync[["GetProfileAsync()"]]
    method_8ggznb_identityservice[["IdentityService()"]]
    method_b6asoe_loginasync[["LoginAsync()"]]
    method_kf6qfg_registerasync[["RegisterAsync()"]]
    method_nb75z9_refreshtokenasync[["RefreshTokenAsync()"]]
    method_nyrl9z_getprofileinternalasync[["GetProfileInternalAsync()"]]
    unresolved_unresolved_10fc8rp_call_target{"Unresolved: INativeStorageService.GetSecureString"}
    unresolved_unresolved_159kzo2_interaction_target{"Unresolved: Calls HttpClient.PostAsJsonAsync to 'identity/register' (framework call omitted from calls list)"}
    unresolved_unresolved_19pszpm_call_target{"Unresolved: INativeStorageService.SaveSecureString"}
    unresolved_unresolved_1atdq4u_call_target{"Unresolved: OnStateInvalidated.Invoke"}
    unresolved_unresolved_1e40o4e_call_target{"Unresolved: NexusAuthenticationStateProvider.NotifyUserAuthentication"}
    unresolved_unresolved_1gkugkk_call_target{"Unresolved: OnStateInvalidated.Invoke"}
    unresolved_unresolved_1gvn8f0_call_target{"Unresolved: NexusAuthenticationStateProvider.NotifyUserAuthentication"}
    unresolved_unresolved_1h591k0_call_target{"Unresolved: NexusAuthenticationStateProvider.NotifyUserLogout"}
    unresolved_unresolved_1qta35c_interaction_target{"Unresolved: Calls HttpClient.PostAsJsonAsync to 'identity/refresh' (framework call omitted from calls list)"}
    unresolved_unresolved_1u6whi4_call_target{"Unresolved: INativeStorageService.SaveSecureString"}
    unresolved_unresolved_1v3p4g4_call_target{"Unresolved: GetProfileAsync"}
    unresolved_unresolved_1wraerh_call_target{"Unresolved: NexusAuthenticationStateProvider.NotifyUserAuthentication"}
    unresolved_unresolved_7bj2q1_call_target{"Unresolved: NexusAuthenticationStateProvider.ClearCache"}
    unresolved_unresolved_7cdvii_call_target{"Unresolved: OnStateInvalidated.Invoke"}
    unresolved_unresolved_iwmd6s_call_target{"Unresolved: GetProfileInternalAsync"}
    unresolved_unresolved_kf4wfl_call_target{"Unresolved: INativeStorageService.SaveSecureString"}
    unresolved_unresolved_qhvr5q_call_target{"Unresolved: GetProfileAsync"}
    unresolved_unresolved_r45bnc_call_target{"Unresolved: INativeStorageService.SaveSecureString"}
    unresolved_unresolved_sdsrv_interaction_target{"Unresolved: HttpClient.GetAsync('identity/profile') (framework call omitted from calls list)"}
    unresolved_unresolved_wkcuys_call_target{"Unresolved: LogoutAsync"}
    unresolved_unresolved_wlkdyl_call_target{"Unresolved: NexusAuthenticationStateProvider.ClearCache"}
    unresolved_unresolved_y9kokj_call_target{"Unresolved: NexusAuthenticationStateProvider.ClearCache"}
    class_vgua1e_identityservice -->|contains| method_1i33wis_logoutasync
    class_vgua1e_identityservice -->|contains| method_1u6514u_getprofileasync
    class_vgua1e_identityservice -->|contains| method_8ggznb_identityservice
    class_vgua1e_identityservice -->|contains| method_b6asoe_loginasync
    class_vgua1e_identityservice -->|contains| method_kf6qfg_registerasync
    class_vgua1e_identityservice -->|contains| method_nb75z9_refreshtokenasync
    class_vgua1e_identityservice -->|contains| method_nyrl9z_getprofileinternalasync
    class_vgua1e_identityservice -->|unresolved interaction| unresolved_unresolved_159kzo2_interaction_target
    class_vgua1e_identityservice -->|unresolved interaction| unresolved_unresolved_1qta35c_interaction_target
    class_vgua1e_identityservice -->|unresolved interaction| unresolved_unresolved_sdsrv_interaction_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_1h591k0_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_7cdvii_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_r45bnc_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_r45bnc_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_r45bnc_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_r45bnc_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_r45bnc_call_target
    method_1i33wis_logoutasync -->|unresolved call| unresolved_unresolved_wlkdyl_call_target
    method_1u6514u_getprofileasync -->|unresolved call| unresolved_unresolved_iwmd6s_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1atdq4u_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1e40o4e_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1u6whi4_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1u6whi4_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1u6whi4_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1u6whi4_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1u6whi4_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_1v3p4g4_call_target
    method_b6asoe_loginasync -->|unresolved call| unresolved_unresolved_7bj2q1_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_10fc8rp_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_19pszpm_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_19pszpm_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_19pszpm_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_19pszpm_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_19pszpm_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_1gkugkk_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_1gvn8f0_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_qhvr5q_call_target
    method_nb75z9_refreshtokenasync -->|unresolved call| unresolved_unresolved_y9kokj_call_target
    method_nyrl9z_getprofileinternalasync -->|unresolved call| unresolved_unresolved_1wraerh_call_target
    method_nyrl9z_getprofileinternalasync -->|unresolved call| unresolved_unresolved_kf4wfl_call_target
    method_nyrl9z_getprofileinternalasync -->|unresolved call| unresolved_unresolved_kf4wfl_call_target
    method_nyrl9z_getprofileinternalasync -->|unresolved call| unresolved_unresolved_kf4wfl_call_target
    method_nyrl9z_getprofileinternalasync -->|unresolved call| unresolved_unresolved_wkcuys_call_target
```

### RegisterAsync() Control Flow

```mermaid
flowchart TD
    method_kf6qfg_registerasync__action_35_registerasync_try_35_0__try("Begins protected execution")
    method_kf6qfg_registerasync__action_35_try_catch_35__linear("Network exception handling")
    method_kf6qfg_registerasync__action_37_registerasync_await_37_1__await[["Waits for async work"]]
    method_kf6qfg_registerasync__action_38_branch_38__condition{"response.IsSuccessStatusCode"}
    method_kf6qfg_registerasync__action_38_branch_38__false("fail")
    method_kf6qfg_registerasync__action_38_branch_38__merge("merge")
    method_kf6qfg_registerasync__action_38_branch_38__true("ok")
    method_kf6qfg_registerasync__action_40_registerasync_catch_40_3__catch("catch Exception ex")
    method_kf6qfg_registerasync__entry(["RegisterAsync entry"])
    method_kf6qfg_registerasync__action_37_external_call_37__linear("POST register")
    method_kf6qfg_registerasync__action_38_registerasync_return_38_2__return(["Returns result"])
    method_kf6qfg_registerasync__action_42_registerasync_return_42_4__return(["Returns result"])
    method_kf6qfg_registerasync__action_35_registerasync_try_35_0__try -->|next| method_kf6qfg_registerasync__action_37_registerasync_await_37_1__await
    method_kf6qfg_registerasync__action_35_try_catch_35__linear -->|next| method_kf6qfg_registerasync__action_35_registerasync_try_35_0__try
    method_kf6qfg_registerasync__action_37_external_call_37__linear -->|return| method_kf6qfg_registerasync__action_38_registerasync_return_38_2__return
    method_kf6qfg_registerasync__action_37_registerasync_await_37_1__await -->|next| method_kf6qfg_registerasync__action_37_external_call_37__linear
    method_kf6qfg_registerasync__action_38_branch_38__condition -->|fail| method_kf6qfg_registerasync__action_38_branch_38__false
    method_kf6qfg_registerasync__action_38_branch_38__condition -->|ok| method_kf6qfg_registerasync__action_38_branch_38__true
    method_kf6qfg_registerasync__action_38_branch_38__false -->|next| method_kf6qfg_registerasync__action_38_branch_38__merge
    method_kf6qfg_registerasync__action_38_branch_38__merge -->|exception| method_kf6qfg_registerasync__action_40_registerasync_catch_40_3__catch
    method_kf6qfg_registerasync__action_38_branch_38__true -->|next| method_kf6qfg_registerasync__action_38_branch_38__merge
    method_kf6qfg_registerasync__action_38_registerasync_return_38_2__return -->|next| method_kf6qfg_registerasync__action_38_branch_38__condition
    method_kf6qfg_registerasync__action_40_registerasync_catch_40_3__catch -->|return| method_kf6qfg_registerasync__action_42_registerasync_return_42_4__return
    method_kf6qfg_registerasync__entry -->|next| method_kf6qfg_registerasync__action_35_try_catch_35__linear
```

### LoginAsync() Control Flow

_Warnings: diagram method_b6asoe_loginasync__fragment_diagram exceeds preferred complexity thresholds (66 nodes, 73 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_b6asoe_loginasync__call_67_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_b6asoe_loginasync__call_70_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_b6asoe_loginasync__call_74_NexusAuthenticationStateProvider_ClearCache[["NexusAuthenticationStateProvider.ClearCache"]]
    method_b6asoe_loginasync__call_75_OnStateInvalidated_Invoke[["OnStateInvalidated.Invoke"]]
    method_b6asoe_loginasync__call_77_GetProfileAsync[["GetProfileAsync"]]
    method_b6asoe_loginasync__call_81_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_b6asoe_loginasync__call_82_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_b6asoe_loginasync__call_85_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_b6asoe_loginasync__call_87_NexusAuthenticationStateProvider_NotifyUserAuthentication[["NexusAuthenticationStateProvider.NotifyUserAuthentication"]]
    method_b6asoe_loginasync__action_48_loginasync_try_48_0__try("Begins protected execution")
    method_b6asoe_loginasync__action_48_try_catch_48__linear("Entire login flow guarded")
    method_b6asoe_loginasync__action_50_loginasync_await_50_1__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_52_branch_52__condition{"response.IsSuccessStatusCode"}
    method_b6asoe_loginasync__action_52_branch_52__false("return invalid credentials")
    method_b6asoe_loginasync__action_52_branch_52__merge("merge")
    method_b6asoe_loginasync__action_52_branch_52__true("process tokens and profile")
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__condition{"response.IsSuccessStatusCode"}
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__false("false")
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__merge("merge")
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__true("true")
    method_b6asoe_loginasync__action_56_loginasync_try_56_3__try("Begins protected execution")
    method_b6asoe_loginasync__action_56_try_catch_56__linear("Parse JSON response")
    method_b6asoe_loginasync__action_58_loginasync_await_58_4__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_60_loginasync_catch_60_5__catch("catch System.Text.Json.JsonException ex")
    method_b6asoe_loginasync__action_65_guard_clause_65__condition{"result != null && !string.IsNullOrEmpty(result.AccessToken)"}
    method_b6asoe_loginasync__action_65_guard_clause_65__false("skip token persistence")
    method_b6asoe_loginasync__action_65_guard_clause_65__merge("merge")
    method_b6asoe_loginasync__action_65_guard_clause_65__true("save tokens")
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__condition{"result != null && !string.IsNullOrEmpty(result.AccessToken)"}
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__false("false")
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__merge("merge")
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__true("true")
    method_b6asoe_loginasync__action_67_loginasync_await_67_8__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__condition{"!string.IsNullOrEmpty(result.RefreshToken)"}
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__false("false")
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__merge("merge")
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__true("true")
    method_b6asoe_loginasync__action_70_loginasync_await_70_10__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_74_state_change_74__linear("Invalidate auth state and notify listeners")
    method_b6asoe_loginasync__action_75_loginasync_await_75_12__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__condition{"OnStateInvalidated != null) await OnStateInvalidated.Invoke("}
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__false("false")
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__merge("merge")
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__true("true")
    method_b6asoe_loginasync__action_77_loginasync_await_77_13__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_77_orchestration_77__linear("Fetch and persist profile after login")
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__condition{"profileResult.IsSuccess"}
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__false("false")
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__merge("merge")
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__true("true")
    method_b6asoe_loginasync__action_81_loginasync_await_81_15__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_82_loginasync_await_82_16__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_85_loginasync_await_85_17__await[["Waits for async work"]]
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__condition{"Falls back to alternate path"}
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__false("otherwise")
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__merge("merge")
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__true("fallback")
    method_b6asoe_loginasync__action_98_loginasync_catch_98_23__catch("catch Exception ex")
    method_b6asoe_loginasync__entry(["LoginAsync entry"])
    method_b6asoe_loginasync__action_87_loginasync_notification_87_18__linear[/"Sends notification"/]
    method_b6asoe_loginasync__action_91_loginasync_notification_91_20__linear[/"Sends notification"/]
    method_b6asoe_loginasync__action_100_loginasync_return_100_24__return(["Returns result"])
    method_b6asoe_loginasync__action_62_loginasync_return_62_6__return(["Returns result"])
    method_b6asoe_loginasync__action_94_loginasync_return_94_21__return(["Returns result"])
    method_b6asoe_loginasync__action_94_return_94__return(["Return success/failure"])
    method_b6asoe_loginasync__action_96_loginasync_return_96_22__return(["Returns result"])
    method_b6asoe_loginasync__action_48_loginasync_try_48_0__try -->|next| method_b6asoe_loginasync__action_50_loginasync_await_50_1__await
    method_b6asoe_loginasync__action_48_try_catch_48__linear -->|next| method_b6asoe_loginasync__action_48_loginasync_try_48_0__try
    method_b6asoe_loginasync__action_50_loginasync_await_50_1__await -->|next| method_b6asoe_loginasync__action_52_loginasync_branch_52_2__condition
    method_b6asoe_loginasync__action_52_branch_52__condition -->|return invalid credentials| method_b6asoe_loginasync__action_52_branch_52__false
    method_b6asoe_loginasync__action_52_branch_52__condition -->|process tokens and profile| method_b6asoe_loginasync__action_52_branch_52__true
    method_b6asoe_loginasync__action_52_branch_52__false -->|next| method_b6asoe_loginasync__action_52_branch_52__merge
    method_b6asoe_loginasync__action_52_branch_52__merge -->|next| method_b6asoe_loginasync__action_56_try_catch_56__linear
    method_b6asoe_loginasync__action_52_branch_52__true -->|next| method_b6asoe_loginasync__action_52_branch_52__merge
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__condition -->|false| method_b6asoe_loginasync__action_52_loginasync_branch_52_2__false
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__condition -->|true| method_b6asoe_loginasync__action_52_loginasync_branch_52_2__true
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__false -->|next| method_b6asoe_loginasync__action_52_loginasync_branch_52_2__merge
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__merge -->|next| method_b6asoe_loginasync__action_52_branch_52__condition
    method_b6asoe_loginasync__action_52_loginasync_branch_52_2__true -->|next| method_b6asoe_loginasync__action_52_loginasync_branch_52_2__merge
    method_b6asoe_loginasync__action_56_loginasync_try_56_3__try -->|next| method_b6asoe_loginasync__action_58_loginasync_await_58_4__await
    method_b6asoe_loginasync__action_56_try_catch_56__linear -->|next| method_b6asoe_loginasync__action_56_loginasync_try_56_3__try
    method_b6asoe_loginasync__action_58_loginasync_await_58_4__await -->|exception| method_b6asoe_loginasync__action_60_loginasync_catch_60_5__catch
    method_b6asoe_loginasync__action_60_loginasync_catch_60_5__catch -->|return| method_b6asoe_loginasync__action_62_loginasync_return_62_6__return
    method_b6asoe_loginasync__action_62_loginasync_return_62_6__return -->|next| method_b6asoe_loginasync__action_65_guard_clause_65__condition
    method_b6asoe_loginasync__action_65_guard_clause_65__condition -->|skip token persistence| method_b6asoe_loginasync__action_65_guard_clause_65__false
    method_b6asoe_loginasync__action_65_guard_clause_65__condition -->|save tokens| method_b6asoe_loginasync__action_65_guard_clause_65__true
    method_b6asoe_loginasync__action_65_guard_clause_65__false -->|next| method_b6asoe_loginasync__action_65_guard_clause_65__merge
    method_b6asoe_loginasync__action_65_guard_clause_65__merge -->|next| method_b6asoe_loginasync__action_65_loginasync_branch_65_7__condition
    method_b6asoe_loginasync__action_65_guard_clause_65__true -->|next| method_b6asoe_loginasync__action_65_guard_clause_65__merge
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__condition -->|false| method_b6asoe_loginasync__action_65_loginasync_branch_65_7__false
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__condition -->|true| method_b6asoe_loginasync__action_65_loginasync_branch_65_7__true
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__false -->|next| method_b6asoe_loginasync__action_65_loginasync_branch_65_7__merge
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__merge -->|next| method_b6asoe_loginasync__action_67_loginasync_await_67_8__await
    method_b6asoe_loginasync__action_65_loginasync_branch_65_7__true -->|next| method_b6asoe_loginasync__action_65_loginasync_branch_65_7__merge
    method_b6asoe_loginasync__action_67_loginasync_await_67_8__await -->|TokenKey, result.AccessToken| method_b6asoe_loginasync__call_67_INativeStorageService_SaveSecureString
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__condition -->|false| method_b6asoe_loginasync__action_68_loginasync_branch_68_9__false
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__condition -->|true| method_b6asoe_loginasync__action_68_loginasync_branch_68_9__true
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__false -->|next| method_b6asoe_loginasync__action_68_loginasync_branch_68_9__merge
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__merge -->|next| method_b6asoe_loginasync__action_70_loginasync_await_70_10__await
    method_b6asoe_loginasync__action_68_loginasync_branch_68_9__true -->|next| method_b6asoe_loginasync__action_68_loginasync_branch_68_9__merge
    method_b6asoe_loginasync__action_70_loginasync_await_70_10__await -->|RefreshTokenKey, result.RefreshToken| method_b6asoe_loginasync__call_70_INativeStorageService_SaveSecureString
    method_b6asoe_loginasync__action_74_state_change_74__linear -->|cast _authStateProvider and call ClearCache| method_b6asoe_loginasync__call_74_NexusAuthenticationStateProvider_ClearCache
    method_b6asoe_loginasync__action_75_loginasync_await_75_12__await -->|next| method_b6asoe_loginasync__action_75_loginasync_branch_75_11__condition
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__condition -->|false| method_b6asoe_loginasync__action_75_loginasync_branch_75_11__false
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__condition -->|true| method_b6asoe_loginasync__action_75_loginasync_branch_75_11__true
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__false -->|next| method_b6asoe_loginasync__action_75_loginasync_branch_75_11__merge
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__merge -->|invoke event if not null| method_b6asoe_loginasync__call_75_OnStateInvalidated_Invoke
    method_b6asoe_loginasync__action_75_loginasync_branch_75_11__true -->|next| method_b6asoe_loginasync__action_75_loginasync_branch_75_11__merge
    method_b6asoe_loginasync__action_77_loginasync_await_77_13__await -->|next| method_b6asoe_loginasync__action_77_orchestration_77__linear
    method_b6asoe_loginasync__action_77_orchestration_77__linear -->|no parameters| method_b6asoe_loginasync__call_77_GetProfileAsync
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__condition -->|false| method_b6asoe_loginasync__action_78_loginasync_branch_78_14__false
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__condition -->|true| method_b6asoe_loginasync__action_78_loginasync_branch_78_14__true
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__false -->|next| method_b6asoe_loginasync__action_78_loginasync_branch_78_14__merge
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__merge -->|next| method_b6asoe_loginasync__action_81_loginasync_await_81_15__await
    method_b6asoe_loginasync__action_78_loginasync_branch_78_14__true -->|next| method_b6asoe_loginasync__action_78_loginasync_branch_78_14__merge
    method_b6asoe_loginasync__action_81_loginasync_await_81_15__await -->|StorageKeys.UserEmail, profile.Email| method_b6asoe_loginasync__call_81_INativeStorageService_SaveSecureString
    method_b6asoe_loginasync__action_82_loginasync_await_82_16__await -->|StorageKeys.UserTenant, profile.TenantId.ToString| method_b6asoe_loginasync__call_82_INativeStorageService_SaveSecureString
    method_b6asoe_loginasync__action_85_loginasync_await_85_17__await -->|StorageKeys.UserRoles, rolesStr| method_b6asoe_loginasync__call_85_INativeStorageService_SaveSecureString
    method_b6asoe_loginasync__action_87_loginasync_notification_87_18__linear -->|profile.Email, profile.TenantId.ToString , rolesStr or fallback email / unknown| method_b6asoe_loginasync__call_87_NexusAuthenticationStateProvider_NotifyUserAuthentication
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__condition -->|otherwise| method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__false
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__condition -->|fallback| method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__true
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__false -->|next| method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__merge
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__merge -->|next| method_b6asoe_loginasync__action_91_loginasync_notification_91_20__linear
    method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__true -->|next| method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__merge
    method_b6asoe_loginasync__action_91_loginasync_notification_91_20__linear -->|return| method_b6asoe_loginasync__action_94_loginasync_return_94_21__return
    method_b6asoe_loginasync__action_94_loginasync_return_94_21__return -->|return| method_b6asoe_loginasync__action_94_return_94__return
    method_b6asoe_loginasync__action_94_return_94__return -->|return| method_b6asoe_loginasync__action_96_loginasync_return_96_22__return
    method_b6asoe_loginasync__action_96_loginasync_return_96_22__return -->|exception| method_b6asoe_loginasync__action_98_loginasync_catch_98_23__catch
    method_b6asoe_loginasync__action_98_loginasync_catch_98_23__catch -->|return| method_b6asoe_loginasync__action_100_loginasync_return_100_24__return
    method_b6asoe_loginasync__call_67_INativeStorageService_SaveSecureString -->|next| method_b6asoe_loginasync__action_68_loginasync_branch_68_9__condition
    method_b6asoe_loginasync__call_70_INativeStorageService_SaveSecureString -->|next| method_b6asoe_loginasync__action_74_state_change_74__linear
    method_b6asoe_loginasync__call_74_NexusAuthenticationStateProvider_ClearCache -->|next| method_b6asoe_loginasync__action_75_loginasync_await_75_12__await
    method_b6asoe_loginasync__call_75_OnStateInvalidated_Invoke -->|next| method_b6asoe_loginasync__action_77_loginasync_await_77_13__await
    method_b6asoe_loginasync__call_77_GetProfileAsync -->|next| method_b6asoe_loginasync__action_78_loginasync_branch_78_14__condition
    method_b6asoe_loginasync__call_81_INativeStorageService_SaveSecureString -->|next| method_b6asoe_loginasync__action_82_loginasync_await_82_16__await
    method_b6asoe_loginasync__call_82_INativeStorageService_SaveSecureString -->|next| method_b6asoe_loginasync__action_85_loginasync_await_85_17__await
    method_b6asoe_loginasync__call_85_INativeStorageService_SaveSecureString -->|next| method_b6asoe_loginasync__action_87_loginasync_notification_87_18__linear
    method_b6asoe_loginasync__call_87_NexusAuthenticationStateProvider_NotifyUserAuthentication -->|fallback| method_b6asoe_loginasync__action_89_loginasync_fallback_89_19__condition
    method_b6asoe_loginasync__entry -->|next| method_b6asoe_loginasync__action_48_try_catch_48__linear
```

### LogoutAsync() Control Flow

_Warnings: diagram method_1i33wis_logoutasync__fragment_diagram exceeds preferred complexity thresholds (32 nodes, 33 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_1i33wis_logoutasync__call_111_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_1i33wis_logoutasync__call_112_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_1i33wis_logoutasync__call_113_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_1i33wis_logoutasync__call_114_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_1i33wis_logoutasync__call_115_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_1i33wis_logoutasync__call_118_OnStateInvalidated_Invoke[["OnStateInvalidated.Invoke"]]
    method_1i33wis_logoutasync__call_119_NexusAuthenticationStateProvider_ClearCache[["NexusAuthenticationStateProvider.ClearCache"]]
    method_1i33wis_logoutasync__call_120_NexusAuthenticationStateProvider_NotifyUserLogout[["NexusAuthenticationStateProvider.NotifyUserLogout"]]
    method_1i33wis_logoutasync__action_106_logoutasync_try_106_0__try("Begins protected execution")
    method_1i33wis_logoutasync__action_106_try_catch_106__linear("Logout guarded")
    method_1i33wis_logoutasync__action_108_state_change_108__linear("Clear cached profile and storage keys")
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__condition{"System.OperatingSystem.IsBrowser()"}
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__false("false")
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__merge("merge")
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__true("true")
    method_1i33wis_logoutasync__action_111_logoutasync_await_111_2__await[["Waits for async work"]]
    method_1i33wis_logoutasync__action_112_logoutasync_await_112_3__await[["Waits for async work"]]
    method_1i33wis_logoutasync__action_113_logoutasync_await_113_4__await[["Waits for async work"]]
    method_1i33wis_logoutasync__action_114_logoutasync_await_114_5__await[["Waits for async work"]]
    method_1i33wis_logoutasync__action_115_logoutasync_await_115_6__await[["Waits for async work"]]
    method_1i33wis_logoutasync__action_118_logoutasync_await_118_8__await[["Waits for async work"]]
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__condition{"OnStateInvalidated != null) await OnStateInvalidated.Invoke("}
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__false("false")
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__merge("merge")
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__true("true")
    method_1i33wis_logoutasync__action_118_notify_118__linear("Notify auth provider and listeners")
    method_1i33wis_logoutasync__action_124_logoutasync_catch_124_11__catch("catch Exception ex")
    method_1i33wis_logoutasync__entry(["LogoutAsync entry"])
    method_1i33wis_logoutasync__action_120_logoutasync_notification_120_9__linear[/"Sends notification"/]
    method_1i33wis_logoutasync__action_122_logoutasync_return_122_10__return(["Returns result"])
    method_1i33wis_logoutasync__action_122_return_122__return(["Return success"])
    method_1i33wis_logoutasync__action_126_logoutasync_return_126_12__return(["Returns result"])
    method_1i33wis_logoutasync__action_106_logoutasync_try_106_0__try -->|next| method_1i33wis_logoutasync__action_108_state_change_108__linear
    method_1i33wis_logoutasync__action_106_try_catch_106__linear -->|next| method_1i33wis_logoutasync__action_106_logoutasync_try_106_0__try
    method_1i33wis_logoutasync__action_108_state_change_108__linear -->|next| method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__condition
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__condition -->|false| method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__false
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__condition -->|true| method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__true
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__false -->|next| method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__merge
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__merge -->|next| method_1i33wis_logoutasync__action_111_logoutasync_await_111_2__await
    method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__true -->|next| method_1i33wis_logoutasync__action_109_logoutasync_branch_109_1__merge
    method_1i33wis_logoutasync__action_111_logoutasync_await_111_2__await -->|TokenKey, empty string| method_1i33wis_logoutasync__call_111_INativeStorageService_SaveSecureString
    method_1i33wis_logoutasync__action_112_logoutasync_await_112_3__await -->|RefreshTokenKey, empty string| method_1i33wis_logoutasync__call_112_INativeStorageService_SaveSecureString
    method_1i33wis_logoutasync__action_113_logoutasync_await_113_4__await -->|StorageKeys.UserEmail, empty string| method_1i33wis_logoutasync__call_113_INativeStorageService_SaveSecureString
    method_1i33wis_logoutasync__action_114_logoutasync_await_114_5__await -->|StorageKeys.UserTenant, empty string| method_1i33wis_logoutasync__call_114_INativeStorageService_SaveSecureString
    method_1i33wis_logoutasync__action_115_logoutasync_await_115_6__await -->|StorageKeys.UserRoles, empty string| method_1i33wis_logoutasync__call_115_INativeStorageService_SaveSecureString
    method_1i33wis_logoutasync__action_118_logoutasync_await_118_8__await -->|next| method_1i33wis_logoutasync__action_118_notify_118__linear
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__condition -->|false| method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__false
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__condition -->|true| method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__true
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__false -->|next| method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__merge
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__merge -->|invoke event if not null| method_1i33wis_logoutasync__call_118_OnStateInvalidated_Invoke
    method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__true -->|next| method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__merge
    method_1i33wis_logoutasync__action_118_notify_118__linear -->|next| method_1i33wis_logoutasync__action_118_logoutasync_branch_118_7__condition
    method_1i33wis_logoutasync__action_120_logoutasync_notification_120_9__linear -->|cast _authStateProvider and call NotifyUserLogout| method_1i33wis_logoutasync__call_120_NexusAuthenticationStateProvider_NotifyUserLogout
    method_1i33wis_logoutasync__action_122_logoutasync_return_122_10__return -->|return| method_1i33wis_logoutasync__action_122_return_122__return
    method_1i33wis_logoutasync__action_122_return_122__return -->|exception| method_1i33wis_logoutasync__action_124_logoutasync_catch_124_11__catch
    method_1i33wis_logoutasync__action_124_logoutasync_catch_124_11__catch -->|return| method_1i33wis_logoutasync__action_126_logoutasync_return_126_12__return
    method_1i33wis_logoutasync__call_111_INativeStorageService_SaveSecureString -->|next| method_1i33wis_logoutasync__action_112_logoutasync_await_112_3__await
    method_1i33wis_logoutasync__call_112_INativeStorageService_SaveSecureString -->|next| method_1i33wis_logoutasync__action_113_logoutasync_await_113_4__await
    method_1i33wis_logoutasync__call_113_INativeStorageService_SaveSecureString -->|next| method_1i33wis_logoutasync__action_114_logoutasync_await_114_5__await
    method_1i33wis_logoutasync__call_114_INativeStorageService_SaveSecureString -->|next| method_1i33wis_logoutasync__action_115_logoutasync_await_115_6__await
    method_1i33wis_logoutasync__call_115_INativeStorageService_SaveSecureString -->|next| method_1i33wis_logoutasync__action_118_logoutasync_await_118_8__await
    method_1i33wis_logoutasync__call_118_OnStateInvalidated_Invoke -->|cast _authStateProvider and call ClearCache| method_1i33wis_logoutasync__call_119_NexusAuthenticationStateProvider_ClearCache
    method_1i33wis_logoutasync__call_119_NexusAuthenticationStateProvider_ClearCache -->|next| method_1i33wis_logoutasync__action_120_logoutasync_notification_120_9__linear
    method_1i33wis_logoutasync__call_120_NexusAuthenticationStateProvider_NotifyUserLogout -->|return| method_1i33wis_logoutasync__action_122_logoutasync_return_122_10__return
    method_1i33wis_logoutasync__entry -->|next| method_1i33wis_logoutasync__action_106_try_catch_106__linear
```

### GetProfileAsync() Control Flow

_Warnings: diagram method_1u6514u_getprofileasync__fragment_diagram exceeds preferred complexity thresholds (24 nodes, 27 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_1u6514u_getprofileasync__call_143_GetProfileInternalAsync[["GetProfileInternalAsync"]]
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__condition{"_cachedProfile != null"}
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__false("false")
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__merge("merge")
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__true("true")
    method_1u6514u_getprofileasync__action_132_guard_clause_132__condition{"_cachedProfile != null"}
    method_1u6514u_getprofileasync__action_132_guard_clause_132__false("continue")
    method_1u6514u_getprofileasync__action_132_guard_clause_132__merge("merge")
    method_1u6514u_getprofileasync__action_132_guard_clause_132__true("return cached")
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__condition{"_profileTask != null"}
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__false("false")
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__merge("merge")
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__true("true")
    method_1u6514u_getprofileasync__action_137_guard_clause_137__condition{"_profileTask != null"}
    method_1u6514u_getprofileasync__action_137_guard_clause_137__false("start new fetch")
    method_1u6514u_getprofileasync__action_137_guard_clause_137__merge("merge")
    method_1u6514u_getprofileasync__action_137_guard_clause_137__true("await existing task")
    method_1u6514u_getprofileasync__action_139_getprofileasync_await_139_3__await[["Waits for async work"]]
    method_1u6514u_getprofileasync__action_143_orchestration_143__linear("Start internal profile fetch")
    method_1u6514u_getprofileasync__action_144_getprofileasync_await_144_5__await[["Waits for async work"]]
    method_1u6514u_getprofileasync__entry(["GetProfileAsync entry"])
    method_1u6514u_getprofileasync__action_134_getprofileasync_return_134_1__return(["Returns result"])
    method_1u6514u_getprofileasync__action_140_getprofileasync_return_140_4__return(["Returns result"])
    method_1u6514u_getprofileasync__action_145_getprofileasync_return_145_6__return(["Returns result"])
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__condition -->|false| method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__false
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__condition -->|true| method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__true
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__false -->|next| method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__merge
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__merge -->|return| method_1u6514u_getprofileasync__action_134_getprofileasync_return_134_1__return
    method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__true -->|next| method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__merge
    method_1u6514u_getprofileasync__action_132_guard_clause_132__condition -->|continue| method_1u6514u_getprofileasync__action_132_guard_clause_132__false
    method_1u6514u_getprofileasync__action_132_guard_clause_132__condition -->|return cached| method_1u6514u_getprofileasync__action_132_guard_clause_132__true
    method_1u6514u_getprofileasync__action_132_guard_clause_132__false -->|next| method_1u6514u_getprofileasync__action_132_guard_clause_132__merge
    method_1u6514u_getprofileasync__action_132_guard_clause_132__merge -->|next| method_1u6514u_getprofileasync__action_132_getprofileasync_branch_132_0__condition
    method_1u6514u_getprofileasync__action_132_guard_clause_132__true -->|next| method_1u6514u_getprofileasync__action_132_guard_clause_132__merge
    method_1u6514u_getprofileasync__action_134_getprofileasync_return_134_1__return -->|next| method_1u6514u_getprofileasync__action_137_guard_clause_137__condition
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__condition -->|false| method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__false
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__condition -->|true| method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__true
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__false -->|next| method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__merge
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__merge -->|next| method_1u6514u_getprofileasync__action_139_getprofileasync_await_139_3__await
    method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__true -->|next| method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__merge
    method_1u6514u_getprofileasync__action_137_guard_clause_137__condition -->|start new fetch| method_1u6514u_getprofileasync__action_137_guard_clause_137__false
    method_1u6514u_getprofileasync__action_137_guard_clause_137__condition -->|await existing task| method_1u6514u_getprofileasync__action_137_guard_clause_137__true
    method_1u6514u_getprofileasync__action_137_guard_clause_137__false -->|next| method_1u6514u_getprofileasync__action_137_guard_clause_137__merge
    method_1u6514u_getprofileasync__action_137_guard_clause_137__merge -->|next| method_1u6514u_getprofileasync__action_137_getprofileasync_branch_137_2__condition
    method_1u6514u_getprofileasync__action_137_guard_clause_137__true -->|next| method_1u6514u_getprofileasync__action_137_guard_clause_137__merge
    method_1u6514u_getprofileasync__action_139_getprofileasync_await_139_3__await -->|return| method_1u6514u_getprofileasync__action_140_getprofileasync_return_140_4__return
    method_1u6514u_getprofileasync__action_140_getprofileasync_return_140_4__return -->|next| method_1u6514u_getprofileasync__action_143_orchestration_143__linear
    method_1u6514u_getprofileasync__action_143_orchestration_143__linear -->|no parameters starts internal fetch task| method_1u6514u_getprofileasync__call_143_GetProfileInternalAsync
    method_1u6514u_getprofileasync__action_144_getprofileasync_await_144_5__await -->|return| method_1u6514u_getprofileasync__action_145_getprofileasync_return_145_6__return
    method_1u6514u_getprofileasync__call_143_GetProfileInternalAsync -->|next| method_1u6514u_getprofileasync__action_144_getprofileasync_await_144_5__await
    method_1u6514u_getprofileasync__entry -->|next| method_1u6514u_getprofileasync__action_132_guard_clause_132__condition
```

### GetProfileInternalAsync() Control Flow

_Warnings: diagram method_nyrl9z_getprofileinternalasync__fragment_diagram exceeds preferred complexity thresholds (60 nodes, 67 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_nyrl9z_getprofileinternalasync__call_169_LogoutAsync[["LogoutAsync"]]
    method_nyrl9z_getprofileinternalasync__call_179_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nyrl9z_getprofileinternalasync__call_180_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nyrl9z_getprofileinternalasync__call_183_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nyrl9z_getprofileinternalasync__call_185_NexusAuthenticationStateProvider_NotifyUserAuthentication[["NexusAuthenticationStateProvider.NotifyUserAuthentication"]]
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__condition{"!System.OperatingSystem.IsBrowser()"}
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__false("false")
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__true("true")
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__condition{"System.OperatingSystem.IsBrowser()"}
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__false("continue")
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__true("return null")
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__condition{"DateTime.UtcNow - _lastFetchAttempt < TimeSpan.FromSeconds(5)"}
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__false("false")
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__true("true")
    method_nyrl9z_getprofileinternalasync__action_157_rate_limit_157__linear("Throttle repeated fetches")
    method_nyrl9z_getprofileinternalasync__action_162_state_change_162__linear("Update last fetch timestamp")
    method_nyrl9z_getprofileinternalasync__action_163_getprofileinternalasync_try_163_4__try("Begins protected execution")
    method_nyrl9z_getprofileinternalasync__action_165_getprofileinternalasync_await_165_5__await[["Waits for async work"]]
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__condition{"response.StatusCode == Unauthorized"}
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__false("continue")
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__true("logout and return null")
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__condition{"response.StatusCode == System.Net.HttpStatusCode.Unauthorized"}
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__false("false")
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__true("true")
    method_nyrl9z_getprofileinternalasync__action_169_getprofileinternalasync_await_169_7__await[["Waits for async work"]]
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__condition{"response.IsSuccessStatusCode"}
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__false("false")
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__true("true")
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__condition{"response.IsSuccessStatusCode"}
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__false("false")
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__true("true")
    method_nyrl9z_getprofileinternalasync__action_175_getprofileinternalasync_await_175_10__await[["Waits for async work"]]
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__condition{"profile != null"}
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__false("false")
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__merge("merge")
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__true("true")
    method_nyrl9z_getprofileinternalasync__action_179_getprofileinternalasync_await_179_12__await[["Waits for async work"]]
    method_nyrl9z_getprofileinternalasync__action_180_getprofileinternalasync_await_180_13__await[["Waits for async work"]]
    method_nyrl9z_getprofileinternalasync__action_183_getprofileinternalasync_await_183_14__await[["Waits for async work"]]
    method_nyrl9z_getprofileinternalasync__action_192_getprofileinternalasync_catch_192_18__catch("Handles exception path")
    method_nyrl9z_getprofileinternalasync__action_192_try_catch_192__linear("Swallow fetch/parsing errors")
    method_nyrl9z_getprofileinternalasync__action_196_getprofileinternalasync_finally_196_20__finally("Runs cleanup or finalization")
    method_nyrl9z_getprofileinternalasync__action_198_finally_198__finally("Reset in-flight task marker")
    method_nyrl9z_getprofileinternalasync__entry(["GetProfileInternalAsync entry"])
    method_nyrl9z_getprofileinternalasync__action_165_external_call_165__linear("GET profile")
    method_nyrl9z_getprofileinternalasync__action_185_getprofileinternalasync_notification_185_15__linear[/"Sends notification"/]
    method_nyrl9z_getprofileinternalasync__action_154_getprofileinternalasync_return_154_1__return(["Returns result"])
    method_nyrl9z_getprofileinternalasync__action_159_getprofileinternalasync_return_159_3__return(["Returns result"])
    method_nyrl9z_getprofileinternalasync__action_170_getprofileinternalasync_return_170_8__return(["Returns result"])
    method_nyrl9z_getprofileinternalasync__action_187_getprofileinternalasync_return_187_16__return(["Returns result"])
    method_nyrl9z_getprofileinternalasync__action_190_getprofileinternalasync_return_190_17__return(["Returns result"])
    method_nyrl9z_getprofileinternalasync__action_194_getprofileinternalasync_return_194_19__return(["Returns result"])
    method_nyrl9z_getprofileinternalasync__implicit_return(["return"])
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__condition -->|false| method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__false
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__condition -->|true| method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__true
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__false -->|next| method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__merge
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__merge -->|return| method_nyrl9z_getprofileinternalasync__action_154_getprofileinternalasync_return_154_1__return
    method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__true -->|next| method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__merge
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__condition -->|continue| method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__false
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__condition -->|return null| method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__true
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__false -->|next| method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__merge
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__merge -->|next| method_nyrl9z_getprofileinternalasync__action_152_getprofileinternalasync_branch_152_0__condition
    method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__true -->|next| method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__merge
    method_nyrl9z_getprofileinternalasync__action_154_getprofileinternalasync_return_154_1__return -->|next| method_nyrl9z_getprofileinternalasync__action_157_rate_limit_157__linear
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__condition -->|false| method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__false
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__condition -->|true| method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__true
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__false -->|next| method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__merge
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__merge -->|return| method_nyrl9z_getprofileinternalasync__action_159_getprofileinternalasync_return_159_3__return
    method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__true -->|next| method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__merge
    method_nyrl9z_getprofileinternalasync__action_157_rate_limit_157__linear -->|next| method_nyrl9z_getprofileinternalasync__action_157_getprofileinternalasync_branch_157_2__condition
    method_nyrl9z_getprofileinternalasync__action_159_getprofileinternalasync_return_159_3__return -->|next| method_nyrl9z_getprofileinternalasync__action_162_state_change_162__linear
    method_nyrl9z_getprofileinternalasync__action_162_state_change_162__linear -->|next| method_nyrl9z_getprofileinternalasync__action_163_getprofileinternalasync_try_163_4__try
    method_nyrl9z_getprofileinternalasync__action_163_getprofileinternalasync_try_163_4__try -->|next| method_nyrl9z_getprofileinternalasync__action_165_getprofileinternalasync_await_165_5__await
    method_nyrl9z_getprofileinternalasync__action_165_external_call_165__linear -->|next| method_nyrl9z_getprofileinternalasync__action_167_branch_167__condition
    method_nyrl9z_getprofileinternalasync__action_165_getprofileinternalasync_await_165_5__await -->|next| method_nyrl9z_getprofileinternalasync__action_165_external_call_165__linear
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__condition -->|continue| method_nyrl9z_getprofileinternalasync__action_167_branch_167__false
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__condition -->|logout and return null| method_nyrl9z_getprofileinternalasync__action_167_branch_167__true
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__false -->|next| method_nyrl9z_getprofileinternalasync__action_167_branch_167__merge
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__merge -->|next| method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__condition
    method_nyrl9z_getprofileinternalasync__action_167_branch_167__true -->|next| method_nyrl9z_getprofileinternalasync__action_167_branch_167__merge
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__condition -->|false| method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__false
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__condition -->|true| method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__true
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__false -->|next| method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__merge
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__merge -->|next| method_nyrl9z_getprofileinternalasync__action_169_getprofileinternalasync_await_169_7__await
    method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__true -->|next| method_nyrl9z_getprofileinternalasync__action_167_getprofileinternalasync_branch_167_6__merge
    method_nyrl9z_getprofileinternalasync__action_169_getprofileinternalasync_await_169_7__await -->|no parameters called on 401| method_nyrl9z_getprofileinternalasync__call_169_LogoutAsync
    method_nyrl9z_getprofileinternalasync__action_170_getprofileinternalasync_return_170_8__return -->|next| method_nyrl9z_getprofileinternalasync__action_173_branch_173__condition
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__condition -->|false| method_nyrl9z_getprofileinternalasync__action_173_branch_173__false
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__condition -->|true| method_nyrl9z_getprofileinternalasync__action_173_branch_173__true
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__false -->|next| method_nyrl9z_getprofileinternalasync__action_173_branch_173__merge
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__merge -->|next| method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__condition
    method_nyrl9z_getprofileinternalasync__action_173_branch_173__true -->|next| method_nyrl9z_getprofileinternalasync__action_173_branch_173__merge
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__condition -->|false| method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__false
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__condition -->|true| method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__true
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__false -->|next| method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__merge
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__merge -->|next| method_nyrl9z_getprofileinternalasync__action_175_getprofileinternalasync_await_175_10__await
    method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__true -->|next| method_nyrl9z_getprofileinternalasync__action_173_getprofileinternalasync_branch_173_9__merge
    method_nyrl9z_getprofileinternalasync__action_175_getprofileinternalasync_await_175_10__await -->|next| method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__condition
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__condition -->|false| method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__false
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__condition -->|true| method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__true
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__false -->|next| method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__merge
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__merge -->|next| method_nyrl9z_getprofileinternalasync__action_179_getprofileinternalasync_await_179_12__await
    method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__true -->|next| method_nyrl9z_getprofileinternalasync__action_176_getprofileinternalasync_branch_176_11__merge
    method_nyrl9z_getprofileinternalasync__action_179_getprofileinternalasync_await_179_12__await -->|StorageKeys.UserEmail, profile.Email| method_nyrl9z_getprofileinternalasync__call_179_INativeStorageService_SaveSecureString
    method_nyrl9z_getprofileinternalasync__action_180_getprofileinternalasync_await_180_13__await -->|StorageKeys.UserTenant, profile.TenantId.ToString| method_nyrl9z_getprofileinternalasync__call_180_INativeStorageService_SaveSecureString
    method_nyrl9z_getprofileinternalasync__action_183_getprofileinternalasync_await_183_14__await -->|StorageKeys.UserRoles, rolesStr| method_nyrl9z_getprofileinternalasync__call_183_INativeStorageService_SaveSecureString
    method_nyrl9z_getprofileinternalasync__action_185_getprofileinternalasync_notification_185_15__linear -->|profile.Email, profile.TenantId.ToString , rolesStr| method_nyrl9z_getprofileinternalasync__call_185_NexusAuthenticationStateProvider_NotifyUserAuthentication
    method_nyrl9z_getprofileinternalasync__action_187_getprofileinternalasync_return_187_16__return -->|return| method_nyrl9z_getprofileinternalasync__action_190_getprofileinternalasync_return_190_17__return
    method_nyrl9z_getprofileinternalasync__action_190_getprofileinternalasync_return_190_17__return -->|next| method_nyrl9z_getprofileinternalasync__action_192_try_catch_192__linear
    method_nyrl9z_getprofileinternalasync__action_192_getprofileinternalasync_catch_192_18__catch -->|return| method_nyrl9z_getprofileinternalasync__action_194_getprofileinternalasync_return_194_19__return
    method_nyrl9z_getprofileinternalasync__action_192_try_catch_192__linear -->|exception| method_nyrl9z_getprofileinternalasync__action_192_getprofileinternalasync_catch_192_18__catch
    method_nyrl9z_getprofileinternalasync__action_194_getprofileinternalasync_return_194_19__return -->|next| method_nyrl9z_getprofileinternalasync__action_196_getprofileinternalasync_finally_196_20__finally
    method_nyrl9z_getprofileinternalasync__action_196_getprofileinternalasync_finally_196_20__finally -->|next| method_nyrl9z_getprofileinternalasync__action_198_finally_198__finally
    method_nyrl9z_getprofileinternalasync__action_198_finally_198__finally -->|return| method_nyrl9z_getprofileinternalasync__implicit_return
    method_nyrl9z_getprofileinternalasync__call_169_LogoutAsync -->|return| method_nyrl9z_getprofileinternalasync__action_170_getprofileinternalasync_return_170_8__return
    method_nyrl9z_getprofileinternalasync__call_179_INativeStorageService_SaveSecureString -->|next| method_nyrl9z_getprofileinternalasync__action_180_getprofileinternalasync_await_180_13__await
    method_nyrl9z_getprofileinternalasync__call_180_INativeStorageService_SaveSecureString -->|next| method_nyrl9z_getprofileinternalasync__action_183_getprofileinternalasync_await_183_14__await
    method_nyrl9z_getprofileinternalasync__call_183_INativeStorageService_SaveSecureString -->|next| method_nyrl9z_getprofileinternalasync__action_185_getprofileinternalasync_notification_185_15__linear
    method_nyrl9z_getprofileinternalasync__call_185_NexusAuthenticationStateProvider_NotifyUserAuthentication -->|return| method_nyrl9z_getprofileinternalasync__action_187_getprofileinternalasync_return_187_16__return
    method_nyrl9z_getprofileinternalasync__entry -->|next| method_nyrl9z_getprofileinternalasync__action_152_guard_clause_152__condition
```

### RefreshTokenAsync() Control Flow

_Warnings: diagram method_nb75z9_refreshtokenasync__fragment_diagram exceeds preferred complexity thresholds (64 nodes, 71 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_nb75z9_refreshtokenasync__call_206_INativeStorageService_GetSecureString[["INativeStorageService.GetSecureString"]]
    method_nb75z9_refreshtokenasync__call_218_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nb75z9_refreshtokenasync__call_221_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nb75z9_refreshtokenasync__call_225_NexusAuthenticationStateProvider_ClearCache[["NexusAuthenticationStateProvider.ClearCache"]]
    method_nb75z9_refreshtokenasync__call_226_OnStateInvalidated_Invoke[["OnStateInvalidated.Invoke"]]
    method_nb75z9_refreshtokenasync__call_228_GetProfileAsync[["GetProfileAsync"]]
    method_nb75z9_refreshtokenasync__call_232_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nb75z9_refreshtokenasync__call_233_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nb75z9_refreshtokenasync__call_236_INativeStorageService_SaveSecureString[["INativeStorageService.SaveSecureString"]]
    method_nb75z9_refreshtokenasync__call_238_NexusAuthenticationStateProvider_NotifyUserAuthentication[["NexusAuthenticationStateProvider.NotifyUserAuthentication"]]
    method_nb75z9_refreshtokenasync__action_204_refreshtokenasync_try_204_0__try("Begins protected execution")
    method_nb75z9_refreshtokenasync__action_204_try_catch_204__linear("Refresh guarded")
    method_nb75z9_refreshtokenasync__action_206_refreshtokenasync_await_206_1__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__condition{"string.IsNullOrEmpty(refreshToken)"}
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__false("continue")
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__merge("merge")
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__true("fail")
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__condition{"string.IsNullOrEmpty(refreshToken)) return Result.Fail(\\"Brak tokena odświeżania.\\""}
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__false("continue")
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__merge("merge")
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__true("exit")
    method_nb75z9_refreshtokenasync__action_211_refreshtokenasync_await_211_3__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_213_branch_213__condition{"response.IsSuccessStatusCode and loginResult.AccessToken present"}
    method_nb75z9_refreshtokenasync__action_213_branch_213__false("return session expired")
    method_nb75z9_refreshtokenasync__action_213_branch_213__merge("merge")
    method_nb75z9_refreshtokenasync__action_213_branch_213__true("persist tokens and refresh profile")
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__condition{"response.IsSuccessStatusCode"}
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__false("false")
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__merge("merge")
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__true("true")
    method_nb75z9_refreshtokenasync__action_215_refreshtokenasync_await_215_5__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__condition{"loginResult != null && !string.IsNullOrEmpty(loginResult.AccessToken)"}
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__false("false")
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__merge("merge")
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__true("true")
    method_nb75z9_refreshtokenasync__action_218_refreshtokenasync_await_218_7__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_218_state_change_218__linear("Persist new tokens and invalidate state")
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__condition{"!string.IsNullOrEmpty(loginResult.RefreshToken)"}
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__false("false")
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__merge("merge")
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__true("true")
    method_nb75z9_refreshtokenasync__action_221_refreshtokenasync_await_221_9__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_await_226_11__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__condition{"OnStateInvalidated != null) await OnStateInvalidated.Invoke("}
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__false("false")
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__merge("merge")
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__true("true")
    method_nb75z9_refreshtokenasync__action_228_orchestration_228__linear("Refresh profile after token renewal")
    method_nb75z9_refreshtokenasync__action_228_refreshtokenasync_await_228_12__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__condition{"profileResult.IsSuccess"}
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__false("false")
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__merge("merge")
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__true("true")
    method_nb75z9_refreshtokenasync__action_232_refreshtokenasync_await_232_14__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_233_refreshtokenasync_await_233_15__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_236_refreshtokenasync_await_236_16__await[["Waits for async work"]]
    method_nb75z9_refreshtokenasync__action_246_refreshtokenasync_catch_246_20__catch("catch Exception ex")
    method_nb75z9_refreshtokenasync__entry(["RefreshTokenAsync entry"])
    method_nb75z9_refreshtokenasync__action_211_external_call_211__linear("POST refresh")
    method_nb75z9_refreshtokenasync__action_238_refreshtokenasync_notification_238_17__linear[/"Sends notification"/]
    method_nb75z9_refreshtokenasync__action_241_refreshtokenasync_return_241_18__return(["Returns result"])
    method_nb75z9_refreshtokenasync__action_241_return_241__return(["Return final result"])
    method_nb75z9_refreshtokenasync__action_244_refreshtokenasync_return_244_19__return(["Returns result"])
    method_nb75z9_refreshtokenasync__action_248_refreshtokenasync_return_248_21__return(["Returns result"])
    method_nb75z9_refreshtokenasync__action_204_refreshtokenasync_try_204_0__try -->|next| method_nb75z9_refreshtokenasync__action_206_refreshtokenasync_await_206_1__await
    method_nb75z9_refreshtokenasync__action_204_try_catch_204__linear -->|next| method_nb75z9_refreshtokenasync__action_204_refreshtokenasync_try_204_0__try
    method_nb75z9_refreshtokenasync__action_206_refreshtokenasync_await_206_1__await -->|RefreshTokenKey| method_nb75z9_refreshtokenasync__call_206_INativeStorageService_GetSecureString
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__condition -->|continue| method_nb75z9_refreshtokenasync__action_209_guard_clause_209__false
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__condition -->|fail| method_nb75z9_refreshtokenasync__action_209_guard_clause_209__true
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__false -->|next| method_nb75z9_refreshtokenasync__action_209_guard_clause_209__merge
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__merge -->|next| method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__condition
    method_nb75z9_refreshtokenasync__action_209_guard_clause_209__true -->|next| method_nb75z9_refreshtokenasync__action_209_guard_clause_209__merge
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__condition -->|continue| method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__false
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__condition -->|exit| method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__true
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__false -->|next| method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__merge
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__merge -->|next| method_nb75z9_refreshtokenasync__action_211_refreshtokenasync_await_211_3__await
    method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__true -->|next| method_nb75z9_refreshtokenasync__action_209_refreshtokenasync_guard_clause_209_2__merge
    method_nb75z9_refreshtokenasync__action_211_external_call_211__linear -->|next| method_nb75z9_refreshtokenasync__action_213_branch_213__condition
    method_nb75z9_refreshtokenasync__action_211_refreshtokenasync_await_211_3__await -->|next| method_nb75z9_refreshtokenasync__action_211_external_call_211__linear
    method_nb75z9_refreshtokenasync__action_213_branch_213__condition -->|return session expired| method_nb75z9_refreshtokenasync__action_213_branch_213__false
    method_nb75z9_refreshtokenasync__action_213_branch_213__condition -->|persist tokens and refresh profile| method_nb75z9_refreshtokenasync__action_213_branch_213__true
    method_nb75z9_refreshtokenasync__action_213_branch_213__false -->|next| method_nb75z9_refreshtokenasync__action_213_branch_213__merge
    method_nb75z9_refreshtokenasync__action_213_branch_213__merge -->|next| method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__condition
    method_nb75z9_refreshtokenasync__action_213_branch_213__true -->|next| method_nb75z9_refreshtokenasync__action_213_branch_213__merge
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__condition -->|false| method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__false
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__condition -->|true| method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__true
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__false -->|next| method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__merge
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__merge -->|next| method_nb75z9_refreshtokenasync__action_215_refreshtokenasync_await_215_5__await
    method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__true -->|next| method_nb75z9_refreshtokenasync__action_213_refreshtokenasync_branch_213_4__merge
    method_nb75z9_refreshtokenasync__action_215_refreshtokenasync_await_215_5__await -->|next| method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__condition
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__condition -->|false| method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__false
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__condition -->|true| method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__true
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__false -->|next| method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__merge
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__merge -->|next| method_nb75z9_refreshtokenasync__action_218_refreshtokenasync_await_218_7__await
    method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__true -->|next| method_nb75z9_refreshtokenasync__action_216_refreshtokenasync_branch_216_6__merge
    method_nb75z9_refreshtokenasync__action_218_refreshtokenasync_await_218_7__await -->|next| method_nb75z9_refreshtokenasync__action_218_state_change_218__linear
    method_nb75z9_refreshtokenasync__action_218_state_change_218__linear -->|TokenKey, loginResult.AccessToken| method_nb75z9_refreshtokenasync__call_218_INativeStorageService_SaveSecureString
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__condition -->|false| method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__false
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__condition -->|true| method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__true
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__false -->|next| method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__merge
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__merge -->|next| method_nb75z9_refreshtokenasync__action_221_refreshtokenasync_await_221_9__await
    method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__true -->|next| method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__merge
    method_nb75z9_refreshtokenasync__action_221_refreshtokenasync_await_221_9__await -->|RefreshTokenKey, loginResult.RefreshToken| method_nb75z9_refreshtokenasync__call_221_INativeStorageService_SaveSecureString
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_await_226_11__await -->|next| method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__condition
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__condition -->|false| method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__false
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__condition -->|true| method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__true
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__false -->|next| method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__merge
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__merge -->|invoke event if not null| method_nb75z9_refreshtokenasync__call_226_OnStateInvalidated_Invoke
    method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__true -->|next| method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_branch_226_10__merge
    method_nb75z9_refreshtokenasync__action_228_orchestration_228__linear -->|no parameters| method_nb75z9_refreshtokenasync__call_228_GetProfileAsync
    method_nb75z9_refreshtokenasync__action_228_refreshtokenasync_await_228_12__await -->|next| method_nb75z9_refreshtokenasync__action_228_orchestration_228__linear
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__condition -->|false| method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__false
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__condition -->|true| method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__true
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__false -->|next| method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__merge
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__merge -->|next| method_nb75z9_refreshtokenasync__action_232_refreshtokenasync_await_232_14__await
    method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__true -->|next| method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__merge
    method_nb75z9_refreshtokenasync__action_232_refreshtokenasync_await_232_14__await -->|StorageKeys.UserEmail, profile.Email| method_nb75z9_refreshtokenasync__call_232_INativeStorageService_SaveSecureString
    method_nb75z9_refreshtokenasync__action_233_refreshtokenasync_await_233_15__await -->|StorageKeys.UserTenant, profile.TenantId.ToString| method_nb75z9_refreshtokenasync__call_233_INativeStorageService_SaveSecureString
    method_nb75z9_refreshtokenasync__action_236_refreshtokenasync_await_236_16__await -->|StorageKeys.UserRoles, rolesStr| method_nb75z9_refreshtokenasync__call_236_INativeStorageService_SaveSecureString
    method_nb75z9_refreshtokenasync__action_238_refreshtokenasync_notification_238_17__linear -->|profile.Email, profile.TenantId.ToString , rolesStr| method_nb75z9_refreshtokenasync__call_238_NexusAuthenticationStateProvider_NotifyUserAuthentication
    method_nb75z9_refreshtokenasync__action_241_refreshtokenasync_return_241_18__return -->|return| method_nb75z9_refreshtokenasync__action_241_return_241__return
    method_nb75z9_refreshtokenasync__action_241_return_241__return -->|return| method_nb75z9_refreshtokenasync__action_244_refreshtokenasync_return_244_19__return
    method_nb75z9_refreshtokenasync__action_244_refreshtokenasync_return_244_19__return -->|exception| method_nb75z9_refreshtokenasync__action_246_refreshtokenasync_catch_246_20__catch
    method_nb75z9_refreshtokenasync__action_246_refreshtokenasync_catch_246_20__catch -->|return| method_nb75z9_refreshtokenasync__action_248_refreshtokenasync_return_248_21__return
    method_nb75z9_refreshtokenasync__call_206_INativeStorageService_GetSecureString -->|next| method_nb75z9_refreshtokenasync__action_209_guard_clause_209__condition
    method_nb75z9_refreshtokenasync__call_218_INativeStorageService_SaveSecureString -->|next| method_nb75z9_refreshtokenasync__action_219_refreshtokenasync_branch_219_8__condition
    method_nb75z9_refreshtokenasync__call_221_INativeStorageService_SaveSecureString -->|cast _authStateProvider and call ClearCache| method_nb75z9_refreshtokenasync__call_225_NexusAuthenticationStateProvider_ClearCache
    method_nb75z9_refreshtokenasync__call_225_NexusAuthenticationStateProvider_ClearCache -->|next| method_nb75z9_refreshtokenasync__action_226_refreshtokenasync_await_226_11__await
    method_nb75z9_refreshtokenasync__call_226_OnStateInvalidated_Invoke -->|next| method_nb75z9_refreshtokenasync__action_228_refreshtokenasync_await_228_12__await
    method_nb75z9_refreshtokenasync__call_228_GetProfileAsync -->|next| method_nb75z9_refreshtokenasync__action_229_refreshtokenasync_branch_229_13__condition
    method_nb75z9_refreshtokenasync__call_232_INativeStorageService_SaveSecureString -->|next| method_nb75z9_refreshtokenasync__action_233_refreshtokenasync_await_233_15__await
    method_nb75z9_refreshtokenasync__call_233_INativeStorageService_SaveSecureString -->|next| method_nb75z9_refreshtokenasync__action_236_refreshtokenasync_await_236_16__await
    method_nb75z9_refreshtokenasync__call_236_INativeStorageService_SaveSecureString -->|next| method_nb75z9_refreshtokenasync__action_238_refreshtokenasync_notification_238_17__linear
    method_nb75z9_refreshtokenasync__call_238_NexusAuthenticationStateProvider_NotifyUserAuthentication -->|return| method_nb75z9_refreshtokenasync__action_241_refreshtokenasync_return_241_18__return
    method_nb75z9_refreshtokenasync__entry -->|next| method_nb75z9_refreshtokenasync__action_204_try_catch_204__linear
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 29 unresolved jumps.
- Warning: execution-overview: diagram file_b8uv8h_identityservice_cs_execution_view exceeds preferred complexity thresholds (30 nodes, 43 edges).
- Warning: control-flow: diagram method_b6asoe_loginasync__fragment_diagram exceeds preferred complexity thresholds (66 nodes, 73 edges).
- Warning: control-flow: diagram method_1i33wis_logoutasync__fragment_diagram exceeds preferred complexity thresholds (32 nodes, 33 edges).
- Warning: control-flow: diagram method_1u6514u_getprofileasync__fragment_diagram exceeds preferred complexity thresholds (24 nodes, 27 edges).
- Warning: control-flow: diagram method_nyrl9z_getprofileinternalasync__fragment_diagram exceeds preferred complexity thresholds (60 nodes, 67 edges).
- Warning: control-flow: diagram method_nb75z9_refreshtokenasync__fragment_diagram exceeds preferred complexity thresholds (64 nodes, 71 edges).
