mixin current_plan()
	if (usersBestSubscription)
		.text-right.pull-right.current-plan
			case usersBestSubscription.type
				when 'free'
					+free_plan()
				when 'individual'
					if (usersBestSubscription.remainingTrialDays >= 0)
						+individual_plan_trial(usersBestSubscription.subscription, usersBestSubscription.plan, usersBestSubscription.remainingTrialDays)
					else
						+individual_plan_active(usersBestSubscription.subscription, usersBestSubscription.plan)
				when 'group'
					if (usersBestSubscription.remainingTrialDays >= 0)
						+group_plan_trial(usersBestSubscription.subscription, usersBestSubscription.plan, usersBestSubscription.remainingTrialDays)
					else
						+group_plan_active(usersBestSubscription.subscription, usersBestSubscription.plan)
				when 'commons'
					+commons_plan(usersBestSubscription.subscription, usersBestSubscription.plan)

mixin individual_plan_trial(subscription, plan, remainingTrialDays)
	a.current-plan-label(
		tooltip=translate('plan_tooltip', { plan: plan.name }),
		tooltip-placement="bottom"
		href="/learn/how-to/Overleaf_premium_features"
	)
		if (remainingTrialDays === 1)
			| !{translate('trial_last_day')} 
			span.info-badge
		else
			| !{translate('trial_remaining_days', { days: remainingTrialDays })} 
			span.info-badge

mixin individual_plan_active(subscription, plan)
	a.current-plan-label(
		tooltip=translate('plan_tooltip', {plan: plan.name}),
		tooltip-placement="bottom"
		href="/learn/how-to/Overleaf_premium_features"
	)
		| !{translate('premium_plan_label')} 
		span.info-badge

mixin group_plan_trial(subscription, plan, remainingTrialDays)
	a.current-plan-label(
		tooltip=translate(subscription.teamName != null ? 'group_plan_with_name_tooltip' : 'group_plan_tooltip', { plan: plan.name, groupName: subscription.teamName }),
		tooltip-placement="bottom"
		href="/learn/how-to/Overleaf_premium_features"
	)
		if (remainingTrialDays === 1)
			| !{translate('trial_last_day')} 
			span.info-badge
		else
			| !{translate('trial_remaining_days', { days: remainingTrialDays })} 
			span.info-badge

mixin group_plan_active(subscription, plan)
	a.current-plan-label(
		tooltip=translate(subscription.teamName != null ? 'group_plan_with_name_tooltip' : 'group_plan_tooltip', { plan: plan.name, groupName: subscription.teamName }),
		tooltip-placement="bottom"
		href="/learn/how-to/Overleaf_premium_features"
	)
		| !{translate('premium_plan_label')} 
		span.info-badge
		
mixin commons_plan(subscription, plan)
	a.current-plan-label(
		tooltip=translate('commons_plan_tooltip', { plan: plan.name, institution: subscription.name }),
		tooltip-placement="bottom"
		href="/learn/how-to/Overleaf_premium_features"
	)
		| !{translate('premium_plan_label')} 
		span.info-badge

mixin free_plan()
	a.current-plan-label(
		tooltip=translate('free_plan_tooltip'),
		tooltip-placement="bottom"
		href="/learn/how-to/Overleaf_premium_features"
	)
		| !{translate('free_plan_label')} 
		span.info-badge
		|  
	a.btn.btn-primary(
		href="/user/subscription/plans"
		event-tracking="upgrade-button-click"
		event-tracking-mb="true"
		event-tracking-ga="subscription-funnel"
		event-tracking-action="dashboard-top"
		event-tracking-label="upgrade"
		event-tracking-trigger="click"
		event-segmentation='{"source": "dashboard-top"}'
	) Upgrade
