@namespace Connected.Components
@using System.Globalization
@inherits UIComponent
@typeparam T

@{
	var width = CalculatePosition().ToString(CultureInfo.InvariantCulture);
}

<div class="@Classname">
	@if (ChildContent != null)
	{
		<MudText Typo="Typo.body1">@ChildContent</MudText>
	}
	<div class="slider-container">
		@if (Variant == Variant.Filled)
		{
			<div class="slider-inner-container">
				<div class="slider-filled" style="@($"width:{width}%;")"></div>
			</div>
		}
		@if (TickMarks == true)
		{
			<div class="slider-inner-container">
				<div class="slider-tickmarks">
					@for (int i = 0; i < _tickMarkCount; i++)
					{
						int current = i;

						<div class="d-flex flex-column relative">
							<span class="slider-track-tick" />
							@if (TickMarkLabels != null && current < TickMarkLabels.Length)
							{
								<MudText Class="slider-track-tick-label" Typo="Typo.body2">@TickMarkLabels[current]</MudText>
							}
						</div>
					}
				</div>
			</div>
		}
		<input class="slider-input" aria-valuenow="@Value" aria-valuemin="@_min" aria-valuemax="@_max" role="slider" @attributes="CustomAttributes" type="range" min="@_min" max="@_max" step="@_step" disabled="@Disabled"
			   @bind-value="@Text" @bind-value:event="@((Immediate == true ? "oninput" : "onchange"))" />
        @if (ValueLabel)
        {
            <div class="slider-value-label" style="@($"left:{width}%;")">
                @Value.ToString()
            </div>
        }
	</div>

</div>