nav.navbar.navbar-default.navbar-main(
	class={
		'website-redesign-navbar': isWebsiteRedesign,
	}
)
	.container-fluid
		.navbar-header
			if typeof suppressNavbarRight == 'undefined'
				button.navbar-toggle.collapsed(
					type='button'
					data-toggle='collapse'
					data-target='#navbar-main-collapse'
					aria-label='Toggle ' + translate('navigation')
				)
					i.fa.fa-bars(aria-hidden='true')
			- var enableUpgradeButton = projectDashboardReact && usersBestSubscription && (usersBestSubscription.type === 'free' || usersBestSubscription.type === 'standalone-ai-add-on')
			if enableUpgradeButton
				//- prettier-ignore
				a.btn.btn-primary.pull-right.me-2.visible-xs(
					href='/user/subscription/plans'
					event-tracking='upgrade-button-click'
					event-tracking-mb='true'
					event-tracking-label='upgrade'
					event-tracking-trigger='click'
					event-segmentation={
						source: "dashboard-top",
						"project-dashboard-react": "enabled",
						"is-dashboard-sidebar-hidden": "true",
						"is-screen-width-less-than-768px": "true"
					}
				) #{translate("upgrade")}
			if settings.nav.custom_logo
				a.navbar-brand(
					href='/'
					aria-label=settings.appName
					style='background-image:url("' + settings.nav.custom_logo + '")'
				)
			else if nav.title
				a.navbar-title(href='/' aria-label=settings.appName) #{nav.title}
			else
				a.navbar-brand(href='/' aria-label=settings.appName)

		- var canDisplayAdminMenu = hasAdminAccess()
		- var canDisplayAdminRedirect = canRedirectToAdminDomain()
		- var canDisplaySplitTestMenu = hasFeature('saas') && (canDisplayAdminMenu || (getSessionUser() && getSessionUser().staffAccess && (getSessionUser().staffAccess.splitTestMetrics || getSessionUser().staffAccess.splitTestManagement)))
		- var canDisplaySurveyMenu = hasFeature('saas') && canDisplayAdminMenu
		- var canDisplayScriptLogMenu = hasFeature('saas') && canDisplayAdminMenu

		if typeof suppressNavbarRight == 'undefined'
			#navbar-main-collapse.navbar-collapse.collapse
				ul.nav.navbar-nav.navbar-right
					if canDisplayAdminMenu || canDisplayAdminRedirect || canDisplaySplitTestMenu
						li.dropdown.subdued
							a.dropdown-toggle(
								href='#'
								role='button'
								aria-haspopup='true'
								aria-expanded='false'
								data-toggle='dropdown'
								event-tracking='menu-expand'
								event-tracking-mb='true'
								event-tracking-trigger='click'
								event-segmentation={item: 'admin', location: 'top-menu'}
							)
								| Admin
								span.caret
							ul.dropdown-menu
								if canDisplayAdminMenu
									li
										a(href='/admin') Manage Site
									li
										a(href='/admin/user') Manage Users
									li
										a(href='/admin/project') Project URL Lookup
								if canDisplayAdminRedirect
									li
										a(href=settings.adminUrl) Switch to Admin
								if canDisplaySplitTestMenu
									li
										a(href='/admin/split-test') Manage Feature Flags
								if canDisplaySurveyMenu
									li
										a(href='/admin/survey') Manage Surveys
								if canDisplayScriptLogMenu
									li
										a(href='/admin/script-logs') View Script Logs

					// loop over header_extras
					each item in nav.header_extras
						-
							if ((item.only_when_logged_in && getSessionUser())
											|| (item.only_when_logged_out && (!getSessionUser()))
											|| (!item.only_when_logged_out && !item.only_when_logged_in && !item.only_content_pages)
											|| (item.only_content_pages && (typeof(suppressNavContentLinks) == "undefined" || !suppressNavContentLinks))
							){
								var showNavItem = true
							} else {
								var showNavItem = false
							}

						if showNavItem
							if item.dropdown
								li.dropdown(class=item.class)
									a.dropdown-toggle(
										href='#'
										role='button'
										aria-haspopup='true'
										aria-expanded='false'
										data-toggle='dropdown'
										event-tracking='menu-expand'
										event-tracking-mb='true'
										event-tracking-trigger='click'
										event-segmentation={item: item.trackingKey, location: 'top-menu'}
									)
										| !{translate(item.text)}
										span.caret
									ul.dropdown-menu
										each child in item.dropdown
											if child.divider
												li.divider
											else if child.isContactUs
												li
													a(
														data-ol-open-contact-form-modal='contact-us'
														href
														event-tracking='menu-click'
														event-tracking-mb='true'
														event-tracking-trigger='click'
														event-segmentation={item: 'contact', location: 'top-menu'}
													)
														span
															| #{translate("contact_us")}
											else
												li
													if child.url
														a(
															href=child.url
															class=child.class
															event-tracking='menu-click'
															event-tracking-mb='true'
															event-tracking-trigger='click'
															event-segmentation={item: item.trackingKey, location: 'top-menu'}
														) !{translate(child.text)}
													else
														| !{translate(child.text)}
							else
								li(class=item.class)
									if item.url
										a(
											href=item.url
											class=item.class
											event-tracking='menu-click'
											event-tracking-mb='true'
											event-tracking-trigger='click'
											event-segmentation={item: item.trackingKey, location: 'top-menu'}
										) !{translate(item.text)}
									else
										| !{translate(item.text)}

					// logged out
					if !getSessionUser()
						// register link
						if hasFeature('registration-page')
							li.primary
								a(
									href='/register'
									event-tracking='menu-click'
									event-tracking-action='clicked'
									event-tracking-trigger='click'
									event-tracking-mb='true'
									event-segmentation={page: currentUrl, item: 'register', location: 'top-menu'}
								) #{translate('sign_up')}

						// login link
						li
							a(
								href='/login'
								event-tracking='menu-click'
								event-tracking-action='clicked'
								event-tracking-trigger='click'
								event-tracking-mb='true'
								event-segmentation={page: currentUrl, item: 'login', location: 'top-menu'}
							) #{translate('log_in')}

					// projects link and account menu
					if getSessionUser()
						li
							a(href='/project') #{translate('Projects')}
						li.dropdown
							a.dropdown-toggle(
								href='#'
								role='button'
								aria-haspopup='true'
								aria-expanded='false'
								data-toggle='dropdown'
								event-tracking='menu-expand'
								event-tracking-mb='true'
								event-tracking-trigger='click'
								event-segmentation={item: 'account', location: 'top-menu'}
							)
								| #{translate('Account')}
								span.caret
							ul.dropdown-menu
								li
									.subdued #{getSessionUser().email}
								li.divider.hidden-xs.hidden-sm
								li
									a(href='/user/settings') #{translate('account_settings')}
								if nav.showSubscriptionLink
									li
										a(href='/user/subscription') #{translate('subscription')}
								li.divider.hidden-xs.hidden-sm
								li
									form(method='POST' action='/logout')
										input(name='_csrf' type='hidden' value=csrfToken)
										button.btn-link.text-left.dropdown-menu-button #{translate('log_out')}
