{#if loading}

Loading...

{:else if profile}
{profile.username[0].toUpperCase()}

{profile.username}

{#if !profile.email_verified} {/if}

Member since {new Date(profile.created_at).toLocaleDateString('en-GB', { year: 'numeric', month: 'long', day: 'numeric' })}

Change password
{profile.shards} Shards shatter cards

Stats

Wins {profile.wins}
Losses {profile.losses}
Games Played {profile.wins + profile.losses}
Win Rate = 50} class:bad-wr={profile.win_rate !== null && profile.win_rate < 50}> {profile.win_rate !== null ? `${profile.win_rate}%` : '-'}

Trade Wishlist

Cards or types you're looking to trade for. Visible on your public profile.

{#if wishlistSaved}Saved ✓{/if}

{wishlistError}

Highlights

Most Played Deck {#if profile.most_played_deck} {profile.most_played_deck.name} {profile.most_played_deck.times_played} games {:else} No games played yet {/if}
Most Played Card {#if profile.most_played_card}
{#if profile.most_played_card.image_link} {profile.most_played_card.name} {/if}
{profile.most_played_card.name} {profile.most_played_card.times_played} times played {profile.most_played_card.card_type} · {profile.most_played_card.card_rarity}
{:else} No cards played yet {/if}

Friends

{#if friends.length === 0}

No friends yet.

{:else} {/if}

Trade Proposals

{#if proposals.length === 0}

No trade proposals.

{:else} {@const incoming = proposals.filter((p: any) => p.direction === 'incoming' && p.status === 'pending')} {@const outgoing = proposals.filter((p: any) => p.direction === 'outgoing' && p.status === 'pending')} {@const resolved = proposals.filter((p: any) => p.status !== 'pending')} {#if incoming.length > 0}

Incoming

{#each incoming as p (p.id)}
{p.proposer_username} Pending {formatExpiry(p.expires_at)}

{#if p.requested_cards.length > 0}Wants: {p.requested_cards.map((c: any) => c.name).join(', ')}
{/if} {#if p.offered_cards.length > 0}Offering: {p.offered_cards.map((c: any) => c.name).join(', ')}{/if}

See Proposal
{/each} {/if} {#if outgoing.length > 0}

Outgoing

{#each outgoing as p (p.id)}
To: {p.recipient_username} Pending {formatExpiry(p.expires_at)}

{#if p.requested_cards.length > 0}Requesting: {p.requested_cards.map((c: any) => c.name).join(', ')}
{/if} {#if p.offered_cards.length > 0}Offering: {p.offered_cards.map((c: any) => c.name).join(', ')}{/if}

See Proposal
{/each} {/if} {#if resolved.length > 0}

History

{#each resolved as p (p.id)}
{p.direction === 'incoming' ? `From: ${p.proposer_username}` : `To: ${p.recipient_username}`} {p.status}

{p.requested_cards.length} requested · {p.offered_cards.length} offered

See Proposal
{/each} {/if} {/if} {#if challenges.length > 0}

Game Challenges

{@const pendingOut = challenges.filter((c: any) => c.direction === 'outgoing' && c.status === 'pending')} {@const pendingIn = challenges.filter((c: any) => c.direction === 'incoming' && c.status === 'pending')} {@const resolvedC = challenges.filter((c: any) => c.status !== 'pending')} {#if pendingOut.length > 0}

Sent

{#each pendingOut as c (c.id)}
To: {c.challenged_username} Awaiting response {formatChallengeExpiry(c.expires_at, tick)}

Deck: {c.deck_name}

{#if confirmingWithdraw.has(c.id)} Withdraw challenge? {:else} {/if}
{/each} {/if} {#if pendingIn.length > 0}

Incoming

{#each pendingIn as c (c.id)}
{c.challenger_username} Pending {formatChallengeExpiry(c.expires_at, tick)}

Their deck: {c.deck_name}

Check your notification bell to accept.

{/each} {/if} {#if resolvedC.length > 0}

History

{#each resolvedC as c (c.id)}
{c.direction === 'outgoing' ? `To: ${c.challenged_username}` : `From: ${c.challenger_username}`} {c.status}
{/each} {/if} {/if}
{/if}