<nav id="navbar" aria-label="{{ctx.Locale.Tr "aria.navbar"}}">
	<div class="navbar-left">
		<!-- logo links to bocken.org -->
		<a class="item" id="navbar-logo" href="https://bocken.org" aria-label="Bocken">
			<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
		</a>

		<!-- mobile right menu, it must be here because in mobile view, each item is a flex column, the first item is a full row column -->
		<div class="ui secondary menu navbar-mobile-right only-mobile">
			{{template "base/head_navbar_icons" dict "PageGlobalData" .PageGlobalData}}
			<button class="item ui icon mini button tw-m-0" id="navbar-expand-toggle" aria-label="{{ctx.Locale.Tr "home.nav_menu"}}">{{svg "octicon-three-bars"}}</button>
		</div>

		<!-- navbar links non-mobile -->
		{{if and .IsSigned .MustChangePassword}}
			{{/* No links */}}
		{{else if .IsSigned}}
			<a class="item{{if .PageIsDashboard}} active{{end}}" href="{{AppSubUrl}}/">{{svg "octicon-home"}}<span class="nav-label">Home</span></a>
			{{if not ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled}}
				<a class="item{{if .PageIsIssues}} active{{end}}" href="{{AppSubUrl}}/issues">{{svg "octicon-issue-opened"}}<span class="nav-label">{{ctx.Locale.Tr "issues"}}</span></a>
			{{end}}
			{{if not ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled}}
				<a class="item{{if .PageIsPulls}} active{{end}}" href="{{AppSubUrl}}/pulls">{{svg "octicon-git-pull-request"}}<span class="nav-label">{{ctx.Locale.Tr "pull_requests"}}</span></a>
			{{end}}
			{{if not (and ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled)}}
				{{if .ShowMilestonesDashboardPage}}
					<a class="item{{if .PageIsMilestonesDashboard}} active{{end}}" href="{{AppSubUrl}}/milestones">{{svg "octicon-milestone"}}<span class="nav-label">{{ctx.Locale.Tr "milestones"}}</span></a>
				{{end}}
			{{end}}
		{{else if .IsLandingPageOrganizations}}
			<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{svg "octicon-telescope"}}<span class="nav-label">Explore</span></a>
		{{else}}
			<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{svg "octicon-telescope"}}<span class="nav-label">Explore</span></a>
		{{end}}

		{{template "custom/extra_links" .}}
	</div>

	<!-- the full dropdown menus -->
	<div class="navbar-right">
		<!-- theme toggle (before other right-side items) -->
		<button class="item" id="theme-toggle" aria-label="Toggle theme" title="Toggle theme">
			<svg id="theme-icon-sun" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:none"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
			<svg id="theme-icon-moon" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:none"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
			<svg id="theme-icon-system" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display:none"><path d="M12 2v2"></path><path d="M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715"></path><path d="M16 12a4 4 0 0 0-4-4"></path><path d="m19 5-1.256 1.256"></path><path d="M20 12h2"></path></svg>
		</button>
		<script>
		(function() {
			var modes = ['system', 'light', 'dark'];
			var current = localStorage.getItem('bocken-theme') || 'system';
			function apply(theme) {
				current = theme;
				localStorage.setItem('bocken-theme', theme);
				if (theme === 'system') {
					document.documentElement.removeAttribute('data-bocken-theme');
				} else {
					document.documentElement.setAttribute('data-bocken-theme', theme);
				}
				document.getElementById('theme-icon-sun').style.display = theme === 'light' ? '' : 'none';
				document.getElementById('theme-icon-moon').style.display = theme === 'dark' ? '' : 'none';
				document.getElementById('theme-icon-system').style.display = theme === 'system' ? '' : 'none';
				var btn = document.getElementById('theme-toggle');
				if (btn) btn.title = 'Theme: ' + theme;
			}
			apply(current);
			document.getElementById('theme-toggle').addEventListener('click', function() {
				var i = (modes.indexOf(current) + 1) % modes.length;
				apply(modes[i]);
			});
		})();
		</script>
		{{if and .IsSigned .MustChangePassword}}
			<div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "user_profile_and_more"}}">
				<span class="text">
					{{ctx.AvatarUtils.Avatar .SignedUser 24 "tw-mr-1"}}
					<span class="only-mobile">{{.SignedUser.Name}}</span>
					<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
				</span>
				<div class="menu user-menu">
					<div class="header">
						{{ctx.Locale.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
					</div>

					<div class="divider"></div>
					<a class="item" href="{{AppSubUrl}}/user/logout">
						{{svg "octicon-sign-out"}}
						{{ctx.Locale.Tr "sign_out"}}
					</a>
				</div><!-- end content avatar menu -->
			</div><!-- end dropdown avatar menu -->
		{{else if .IsSigned}}
			{{template "base/head_navbar_icons" dict "ItemExtraClass" "not-mobile" "PageGlobalData" .PageGlobalData}}
			<div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "create_new"}}">
				<span class="text">
					{{svg "octicon-plus"}}
					<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
					<span class="only-mobile">{{ctx.Locale.Tr "create_new"}}</span>
				</span>
				<div class="menu">
					<a class="item" href="{{AppSubUrl}}/repo/create">
						{{svg "octicon-plus"}} {{ctx.Locale.Tr "new_repo"}}
					</a>
					{{if not .DisableMigrations}}
						<a class="item" href="{{AppSubUrl}}/repo/migrate">
							{{svg "octicon-repo-push"}} {{ctx.Locale.Tr "new_migrate"}}
						</a>
					{{end}}
					{{if .SignedUser.CanCreateOrganization}}
					<a class="item" href="{{AppSubUrl}}/org/create">
						{{svg "octicon-organization"}} {{ctx.Locale.Tr "new_org"}}
					</a>
					{{end}}
				</div><!-- end content create new menu -->
			</div><!-- end dropdown menu create new -->

			<div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "user_profile_and_more"}}">
				<span class="text tw-flex tw-items-center">
					<span class="navbar-avatar">
						{{ctx.AvatarUtils.Avatar .SignedUser 24 "tw-mr-2"}}
						{{if .IsAdmin}}{{svg "octicon-shield-check" 16 "navbar-admin-badge"}}{{end}}
					</span>
					<span class="only-mobile">{{.SignedUser.Name}}</span>
					<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
				</span>
				<div class="menu user-menu">
					<div class="header">
						{{ctx.Locale.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
					</div>

					<div class="divider"></div>
					<a class="item" href="{{.SignedUser.HomeLink}}">
						{{svg "octicon-person"}}
						{{ctx.Locale.Tr "your_profile"}}
					</a>
					{{if not .DisableStars}}
						<a class="item" href="{{.SignedUser.HomeLink}}?tab=stars">
							{{svg "octicon-star"}}
							{{ctx.Locale.Tr "your_starred"}}
						</a>
					{{end}}
					<a class="item" href="{{AppSubUrl}}/notifications/subscriptions">
						{{svg "octicon-bell"}}
						{{ctx.Locale.Tr "notification.subscriptions"}}
					</a>
					<a class="{{if .PageIsUserSettings}}active {{end}}item" href="{{AppSubUrl}}/user/settings">
						{{svg "octicon-tools"}}
						{{ctx.Locale.Tr "your_settings"}}
					</a>
					{{if .IsAdmin}}
					<div class="divider"></div>
					<a class="{{if .PageIsAdmin}}active {{end}}item" href="{{AppSubUrl}}/-/admin">
						{{svg "octicon-server"}}
						{{ctx.Locale.Tr "admin_panel"}}
					</a>
					{{end}}
					<div class="divider"></div>
					<a class="item" href="{{AppSubUrl}}/user/logout">
						{{svg "octicon-sign-out"}}
						{{ctx.Locale.Tr "sign_out"}}
					</a>
				</div><!-- end content avatar menu -->
			</div><!-- end dropdown avatar menu -->
		{{else}}
			{{if .ShowRegistrationButton}}
				<a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
					{{svg "octicon-person"}}
					<span class="tw-ml-1">{{ctx.Locale.Tr "register"}}</span>
				</a>
			{{end}}
			<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/oauth2/OIDC">
				{{svg "octicon-sign-in"}}
				<span class="tw-ml-1">{{ctx.Locale.Tr "sign_in"}}</span>
			</a>
		{{end}}
	</div><!-- end full right menu -->

	{{$activeStopwatch := and .PageGlobalData (call .PageGlobalData.GetActiveStopwatch)}}
	{{if $activeStopwatch}}
		<div class="active-stopwatch-popup tippy-target">
			<div class="flex-text-block tw-p-3">
				<a class="stopwatch-link flex-text-block muted" href="{{$activeStopwatch.IssueLink}}">
					{{svg "octicon-issue-opened" 16}}
					<span class="stopwatch-issue">{{$activeStopwatch.RepoSlug}}#{{$activeStopwatch.IssueIndex}}</span>
				</a>
				<div class="tw-flex tw-gap-1">
					<form class="stopwatch-commit form-fetch-action" method="post" action="{{$activeStopwatch.IssueLink}}/times/stopwatch/stop">
						<button
							type="submit"
							class="ui button mini compact basic icon tw-mr-0"
							data-tooltip-content="{{ctx.Locale.Tr "repo.issues.stop_tracking"}}"
						>{{svg "octicon-square-fill"}}</button>
					</form>
					<form class="stopwatch-cancel form-fetch-action" method="post" action="{{$activeStopwatch.IssueLink}}/times/stopwatch/cancel">
						<button
							type="submit"
							class="ui button mini compact basic icon tw-mr-0"
							data-tooltip-content="{{ctx.Locale.Tr "repo.issues.cancel_tracking"}}"
						>{{svg "octicon-trash"}}</button>
					</form>
				</div>
			</div>
		</div>
	{{end}}
</nav>
