<section class="gh-canvas" {{scroll-top}}>
    <div class="gh-dashboard">
        <GhCanvasHeader class="gh-canvas-header sticky">
            <h2 class="gh-canvas-title" data-test-screen-title>
                Dashboard
            </h2>
            {{#unless this.isTotalMembersZero}}
                <div class="gh-dashboard-select">
                    <div {{did-insert this.loadMentions}}>
                        {{#if (feature 'webmentions')}}
                        <GhBasicDropdown @horizontalPosition="right" @verticalPosition="below" @onOpen={{this.markMentionsRead}} as |dropdown|>
                            <dropdown.Trigger class="outline-0 pointer">
                                <button type="button" class="gh-dashboard-mentions-icon">
                                    {{#if this.hasNewMentions}}
                                        {{svg-jar "notification-bell-indicator"}}
                                    {{else}}
                                        {{svg-jar "notification-bell"}}
                                    {{/if}}
                                </button>
                            </dropdown.Trigger>

                            <dropdown.Content class="gh-dashboard-mentions-container">
                                <div class="gh-dashboard-mentions">
                                    {{#if this.mentions}}
                                        <div class="gh-dashboard-mentions-header">
                                            <h2 class="gh-dashboard-mentions-heading">Mentions</h2>
                                            <LinkTo @route="mentions" class="gh-dashboard-mentions-see-all">View all mentions &rarr;</LinkTo>
                                        </div>
                                    {{/if}}
                                    <div>
                                        {{#if this.mentions}}
                                            {{#each this.mentions as |mention|}}
                                                <a href="{{mention.source}}" class="gh-dashboard-mention" rel="noreferrer noopener" target="_blank">
                                                    <div class="gh-dashboard-mention-content">
                                                        <img src="{{mention.sourceFavicon}}" alt="{{mention.sourceSiteTitle}}" class="w5 h5 mr2 flex-shrink-0">
                                                        <span class="gh-dashboard-mention-title">{{or mention.sourceSiteTitle mention.sourceTitle}}</span>
                                                        <div class="gh-mention-link-icon">
                                                            {{svg-jar "twitter-link"}}
                                                        </div>
                                                        {{#if (gt mention.mentions.length 1) }}
                                                            <span class="gh-dashboard-mention-target">{{mention.mentions.length}} links</span>
                                                        {{else}}
                                                            <span class="gh-dashboard-mention-target">{{if mention.resource mention.resource.name mention.target}}</span>
                                                        {{/if}}
                                                        <span class="gh-dashboard-mention-timestamp">{{moment-from-now mention.timestamp}}</span>
                                                    </div>
                                                </a>
                                            {{/each}}
                                        {{else}}
                                            <div class="gh-mentions-list-cta">
                                                {{svg-jar "email-love-letter" class="love-letter"}}
                                                <h4>No mentions yet</h4>
                                                <p>When other sites mention your posts or pages, they'll appear here.</p>
                                            </div>
                                        {{/if}}
                                    </div>
                                </div>
                            </dropdown.Content>
                        </GhBasicDropdown>

                        {{/if}}
                    </div>

                    <PowerSelect
                        @selected={{this.selectedDaysOption}}
                        @options={{this.daysOptions}}
                        @searchEnabled={{false}}
                        @onChange={{this.onDaysChange}}
                        @triggerComponent={{component "gh-power-select/trigger"}}
                        @triggerClass="gh-contentfilter-menu-trigger"
                        @dropdownClass="gh-contentfilter-menu-dropdown is-narrow"
                        @matchTriggerWidth={{false}}
                        @horizontalPosition="right"
                        as |option|
                    >
                        {{#if option.name}}{{option.name}}{{else}}<span class="red">Unknown option</span>{{/if}}
                    </PowerSelect>
                </div>
            {{/unless}}
        </GhCanvasHeader>
        <section class="gh-dashboard-layout">
            {{#if this.isLoading }}
                <GhLoadingSpinner />
            {{else}}
                {{#if this.areMembersEnabled}}
                    {{#if this.hasPaidTiers}}
                        <Dashboard::Charts::Overview />
                    {{/if}}

                    <div class="gh-dashboard-group {{if this.isTotalMembersZero 'is-zero'}}">
                        <Dashboard::Charts::AnchorAttribution />
                        {{#if this.hasPaidTiers}}
                            <section class="gh-dashboard-section">
                                <article class="gh-dashboard-box gh-dashboard-minicharts-attribution">
                                    <Dashboard::Charts::PaidBreakdown />
                                    <Dashboard::Charts::PaidMix />
                                </article>
                            </section>
                        {{/if}}
                        {{#unless this.membersUtils.isMembersInviteOnly}}
                            <Dashboard::Charts::Attribution />
                        {{/unless}}
                        {{#if this.areNewslettersEnabled}}
                            <Dashboard::Charts::Engagement />
                        {{/if}}

                        {{#if this.isTotalMembersZero}}
                            <Dashboard::Parts::Zero />
                        {{/if}}
                    </div>
                {{/if}}

                <div class="gh-dashboard-recents-mentions">
                    <Dashboard::Charts::Recents />
                </div>

                <div class="gh-dashboard-split gh-dashboard-box is-secondary">
                    <Dashboard::Resources::Resources />
                    <Dashboard::Resources::Newsletter />
                </div>

                <Dashboard::Resources::ExploreFeed />

                <div class="gh-dashboard-split gh-dashboard-box no-boarder">
                    <Dashboard::Resources::Community />
                    <Dashboard::Resources::WhatsNew />
                </div>
            {{/if}}
        </section>

        {{#if (enable-developer-experiments)}}
            <Dashboard::Prototype::ControlPanel />
        {{/if}}
    </div>
</section>
