@file:Suppress("AssignedValueIsNeverRead", "HardCodedStringLiteral", "unused")

package eu.gaudian.translator.view.composable

import androidx.compose.animation.animateContentSize
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.ButtonElevation
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.Checkbox
import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedCard
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch
import androidx.compose.material3.SwitchDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.draw.shadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import eu.gaudian.translator.R
import eu.gaudian.translator.ui.theme.ThemePreviews
import eu.gaudian.translator.ui.theme.semanticColors
import eu.gaudian.translator.view.composable.ComponentDefaults.DefaultElevation
import eu.gaudian.translator.view.hints.Hint
import eu.gaudian.translator.view.hints.HintBottomSheet
import eu.gaudian.translator.view.hints.LocalShowHints


object ComponentDefaults {
    // Sizing
    val DefaultButtonHeight = 48.dp
    val CardPadding = 8.dp

    // Elevation
    val DefaultElevation = 0.dp
    val NoElevation = 0.dp

    // Borders
    val DefaultBorderWidth = 1.dp

    // Shapes
    val DefaultCornerRadius = 16.dp
    val CardClipRadius = 8.dp
    val NoRounding = 0.dp
    val DefaultShape = RoundedCornerShape(DefaultCornerRadius)
    val CardClipShape = RoundedCornerShape(CardClipRadius)
    val CardShape = RoundedCornerShape(DefaultCornerRadius)
    val NoShape = RoundedCornerShape(NoRounding)

    // Opacity Levels
    const val ALPHA_HIGH = 0.6f
    const val ALPHA_MEDIUM = 0.5f
    const val ALPHA_LOW = 0.3f
}



/**
 * A styled card container for displaying content with a consistent floating look.
 *
 * @param modifier The modifier to be applied to the card.
 * @param content The content to be displayed inside the card.
 */
@Composable
fun AppCard(
    modifier: Modifier = Modifier,
    title: String? = null,
    icon: ImageVector? = null,
    text: String? = null,
    expandable: Boolean = false,
    initiallyExpanded: Boolean = false,
    onClick: (() -> Unit)? = null,
    hintContent : Hint? = null,
    content: @Composable ColumnScope.() -> Unit,
) {
    var isExpanded by remember { mutableStateOf(initiallyExpanded) }
    val showHints = LocalShowHints.current

    val rotationState by animateFloatAsState(
        targetValue = if (isExpanded) 180f else 0f,
        label = "Chevron Rotation"
    )

    // Check if we need to render the header row
    // Updated to include icon in the check
    val hasHeader = title != null || text != null || expandable || icon != null
    val canClickHeader = expandable || onClick != null

    var showBottomSheet by remember { mutableStateOf(false) }

    if (showBottomSheet) {
        hintContent?.let {
            HintBottomSheet(
                onDismissRequest = { showBottomSheet = false },
                content = it,
                sheetState = rememberModalBottomSheetState(
                    skipPartiallyExpanded = true
                )
            )
        }
    }

    Surface(
        modifier = modifier
            .fillMaxWidth()
            .shadow(
                DefaultElevation,
                shape = ComponentDefaults.CardShape
            )
            .clip(ComponentDefaults.CardClipShape)
            // Animate height changes when expanding/collapsing
            .animateContentSize(),
        shape = ComponentDefaults.CardShape,
        color = MaterialTheme.colorScheme.surfaceContainer,
    ) {
        Column {
            // --- Header Row ---
            if (hasHeader) {
                Row(
                    modifier = Modifier
                        .fillMaxWidth()
                        .clickable(enabled = canClickHeader) {
                            if (expandable) {
                                isExpanded = !isExpanded
                            }
                            onClick?.invoke()
                        }
                        .padding(ComponentDefaults.CardPadding),
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    // 1. Optional Icon on the left
                    if (icon != null) {
                        Spacer(modifier = Modifier.width(8.dp))
                        Icon(
                            imageVector = icon,
                            contentDescription = null,
                            tint = MaterialTheme.colorScheme.primary,
                            modifier = Modifier.size(24.dp)
                        )
                        Spacer(modifier = Modifier.width(16.dp))
                    }

                    // 2. Title and Text Column
                    Column(modifier = Modifier.weight(1f)) {
                        if (!title.isNullOrBlank()) {
                            Text(
                                text = title,
                                style = MaterialTheme.typography.headlineSmall,
                                color = MaterialTheme.colorScheme.onSurface
                            )
                        }

                        // Only show spacer if both title and text exist
                        if (!title.isNullOrBlank() && !text.isNullOrBlank()) {
                            Spacer(Modifier.size(4.dp))
                        }

                        if (!text.isNullOrBlank()) {
                            Text(
                                text = text,
                                style = MaterialTheme.typography.bodyMedium,
                                color = MaterialTheme.colorScheme.onSurfaceVariant
                            )
                        }
                    }

                    if (showHints && hintContent != null) {
                        IconButton(onClick = { showBottomSheet = true }) {
                            Icon(
                                imageVector = AppIcons.Help,
                                contentDescription = stringResource(R.string.show_hint),
                                tint = MaterialTheme.colorScheme.secondary
                            )
                        }
                    }

                    // 3. Expand Chevron (Far right)
                    if (expandable) {
                        Icon(
                            imageVector = AppIcons.ArrowDropDown,
                            contentDescription = if (isExpanded) "Collapse" else "Expand",
                            modifier = Modifier.rotate(rotationState),
                            tint = MaterialTheme.colorScheme.onSurface
                        )
                    }
                }

            }

            // --- Content Area ---
            if (!expandable || isExpanded) {
                val contentModifier = Modifier
                    .padding(
                        start = ComponentDefaults.CardPadding,
                        end = ComponentDefaults.CardPadding,
                        bottom = ComponentDefaults.CardPadding,
                        // If we have a header, remove the top padding so content sits closer to the title.
                        // If no header (legacy behavior), keep the top padding.
                        top = if (hasHeader) 0.dp else ComponentDefaults.CardPadding
                    )

                if (!hasHeader && onClick != null) {
                    Column(
                        modifier = contentModifier.clickable { onClick() },
                        content = content
                    )
                } else {
                    Column(
                        modifier = contentModifier,
                        content = content
                    )
                }
            }
        }
    }
}

@Preview
@Composable
fun AppCardPreview() {
    AppCard {
        Text(stringResource(R.string.this_is_the_content_inside_the_card))
        PrimaryButton(onClick = { }, text = stringResource(R.string.label_continue))
    }
}

@Preview(showBackground = true)
@Composable
fun AppCardPreview2() {
    MaterialTheme {
        Column(
            modifier = Modifier
                .padding(16.dp)
                .fillMaxWidth(),
            verticalArrangement = Arrangement.spacedBy(16.dp)
        ) {
            // 1. Expandable Card (Initially Collapsed)
            AppCard(
                title = "Advanced Settings",
                text = "Click to reveal more options",
                expandable = true,
                initiallyExpanded = false
            ) {
                Text("Here are some hidden settings.")
                Text("They are only visible when expanded.")
            }

            // 2. Expandable Card (Initially Expanded)
            AppCard(
                title = "Translation History",
                text = "Recent items",
                expandable = true,
                initiallyExpanded = true
            ) {
                Text("• Hello -> Hallo")
                Text("• World -> Welt")
                Text("• Sun -> Sonne")
            }

            // 3. Static Card (No Title/Expand logic - Legacy behavior)
            AppCard {
                Text("This is a standard card without a header.")
            }
        }
    }
}

/**
 * The primary button for the most important actions.
 *
 * @param onClick The callback to be invoked when the button is clicked.
 * @param modifier The modifier to be applied to the button.
 * @param enabled Controls the enabled state of the button.
 * @param text The text to display on the button.
 * @param icon Optional leading icon for the button.
 */
@Composable
fun PrimaryButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: String,
    icon: ImageVector? = null,
    maxLines: Int = 1
) {
    AppButton(
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        colors = ButtonDefaults.buttonColors(
            containerColor = MaterialTheme.colorScheme.primary,
            contentColor = MaterialTheme.colorScheme.onPrimary
        )
    ) {
        if (icon != null) {
            Icon(
                imageVector = icon,
                contentDescription = null,
                modifier = Modifier.size(ButtonDefaults.IconSize)
            )
            Spacer(Modifier.size(ButtonDefaults.IconSpacing))
        }
        Text(text)
    }
}

@Preview
@Composable
fun PrimaryButtonPreview() {
    PrimaryButton(onClick = { }, text = stringResource(R.string.primary_button))
}

@Composable
fun AppButton(
    onClick: () -> Unit,
    modifier: Modifier? = Modifier,
    enabled: Boolean = true,
    shape: Shape? = null,
    colors: ButtonColors = ButtonDefaults.buttonColors(),
    elevation: ButtonElevation? = ButtonDefaults.buttonElevation(),
    border: BorderStroke? = null,
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource? = null,
    content: @Composable RowScope.() -> Unit
) {

    val m = modifier ?: Modifier.height(ComponentDefaults.DefaultButtonHeight)
    val s = shape ?: ComponentDefaults.DefaultShape

    Button(
        onClick = onClick,
        modifier = m,
        enabled = enabled,
        shape = s,
        colors = colors,
        elevation = elevation,
        border = border,
        contentPadding = PaddingValues(
            start = 8.dp, // More horizontal padding
            end = 8.dp,
            top = 8.dp,     // Default vertical padding
            bottom = 8.dp
        ),
        interactionSource = interactionSource
    ) {
        content()
    }
}

@Composable
fun AppOutlinedButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    shape: Shape = ButtonDefaults.outlinedShape,
    elevation: ButtonElevation? = null,
    border: BorderStroke? = ButtonDefaults.outlinedButtonBorder(enabled),
    contentPadding: PaddingValues = ButtonDefaults.ContentPadding,
    interactionSource: MutableInteractionSource? = null,
    borderColor: Color? = null,
    content: @Composable RowScope.() -> Unit,
) {

    val borderr = if(borderColor != null) {
        BorderStroke(ComponentDefaults.DefaultBorderWidth, borderColor)
    } else {
        border
    }

    OutlinedButton(
        onClick = onClick,
        modifier = modifier,
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        elevation = elevation,
        border = borderr,
        contentPadding = contentPadding,
        interactionSource = interactionSource,
        content = content
    )
}

@Preview
@Composable
fun PrimaryButtonWithIconPreview() {
    PrimaryButton(onClick = { }, text = stringResource(R.string.primary_with_icon), icon = AppIcons.Add)
}

/**
 * The secondary button for less prominent actions.
 *
 * @param onClick The callback to be invoked when the button is clicked.
 * @param modifier The modifier to be applied to the button.
 * @param enabled Controls the enabled state of the button.
 * @param text The text to display on the button.
 * @param icon Optional leading icon for the button.
 */
@Composable
fun SecondaryButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: String,
    icon: ImageVector? = null,
    inverse: Boolean = false,
    maxLines: Int= 1
) {
    AppOutlinedButton(
        shape = ComponentDefaults.DefaultShape,
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        borderColor = MaterialTheme.colorScheme.surfaceContainerHighest,
        border = ButtonDefaults.outlinedButtonBorder(enabled = enabled).copy(
            width = ComponentDefaults.DefaultBorderWidth
        ),
        contentPadding = PaddingValues(
            start = 8.dp,
            end = 8.dp,
            top = 0.dp,
            bottom = 0.dp
        )
    ) {
        if (!inverse) Text(text, maxLines = maxLines)
        if (icon != null) {
            Icon(
                imageVector = icon,
                contentDescription = null,
                modifier = Modifier.size(ButtonDefaults.IconSize)
            )
            Spacer(Modifier.size(ButtonDefaults.IconSpacing))
        }
        if (inverse) Text(text, maxLines = maxLines)
    }
}

@Preview
@Composable
fun SecondaryButtonPreview() {
    SecondaryButton(onClick = { }, text = stringResource(R.string.secondary_button))
}

@Preview
@Composable
fun SecondaryButtonWithIconPreview() {
    SecondaryButton(onClick = { }, text = stringResource(R.string.secondary_with_icon), icon = AppIcons.Add)
}

@Preview
@Composable
fun SecondaryButtonInversePreview() {
    SecondaryButton(onClick = { }, text = stringResource(R.string.secondary_inverse), icon = AppIcons.Add, inverse = true)
}






@Composable
fun AppSwitch(
    checked: Boolean,
    onCheckedChange: ((Boolean) -> Unit)?,
    modifier: Modifier = Modifier,
    enabled: Boolean = true
) {
    Switch(
        checked = checked,
        onCheckedChange = onCheckedChange,
        modifier = modifier,
        colors = SwitchDefaults.colors(
            checkedThumbColor = MaterialTheme.colorScheme.primary,
            checkedTrackColor = MaterialTheme.colorScheme.primary.copy(alpha = ComponentDefaults.ALPHA_MEDIUM),
            uncheckedThumbColor = MaterialTheme.colorScheme.onSurface,
            uncheckedTrackColor = MaterialTheme.colorScheme.onSurface.copy(alpha = ComponentDefaults.ALPHA_LOW)
        ),
        enabled = enabled
    )
}

@Preview
@Composable
fun AppSwitchPreview() {
    var checked by remember { mutableStateOf(false) }
    AppSwitch(
        checked = checked,
        onCheckedChange = { checked = it }
    )
}

/**
 * An option row with a title, an optional description below it, and a trailing AppSwitch.
 * The whole row is tappable to toggle the switch (if enabled).
 */



/**
 * A styled checkbox for selecting an option.
 *
 * @param checked The current state of the checkbox.
 * @param onCheckedChange The callback invoked when the checkbox is toggled.
 * @param modifier The modifier to be applied to the checkbox.
 */
@Composable
fun AppCheckbox(
    checked: Boolean,
    onCheckedChange: (Boolean) -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true
) {
    Checkbox(
        checked = checked,
        onCheckedChange = onCheckedChange,
        modifier = modifier,
        colors = CheckboxDefaults.colors(
            checkedColor = MaterialTheme.colorScheme.primary,
            uncheckedColor = MaterialTheme.colorScheme.onSurface.copy(alpha = ComponentDefaults.ALPHA_HIGH),
            checkmarkColor = MaterialTheme.colorScheme.onPrimary
        ),
        enabled = enabled
    )
}

@Preview
@Composable
fun AppCheckboxPreview() {
    var checked by remember { mutableStateOf(false) }
    AppCheckbox(
        checked = checked,
        onCheckedChange = { checked = it }
    )
}

@Composable
fun DialogButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    isPrimary: Boolean = false,
    text: String? = null,
    maxLines: Int? = 1,
    content: (@Composable () -> Unit)? = null,
) {
    TextButton(
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        colors = ButtonDefaults.buttonColors(
            containerColor = if (isPrimary) MaterialTheme.colorScheme.primary else Color.Transparent,
            contentColor = if (isPrimary) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.primary,
        )
    ) {
        if (text != null) {
            Text(text, maxLines = maxLines ?: 1)
        }
        if (content != null) {
            content()
        }
    }
}

@Preview
@Composable
fun DialogButtonPreview() {
    DialogButton(
        onClick = { },
        text = stringResource(R.string.label_confirm)
    )
}

@Preview
@Composable
fun PrimaryDialogButtonPreview() {
    DialogButton(
        onClick = { },
        text = stringResource(R.string.label_confirm),
        isPrimary = true,
        content = { Text(stringResource(R.string.label_confirm)) }
    )
}

@ThemePreviews
@Composable
fun AppOutlinedCardPreview() {
    AppOutlinedCard {
        Column {
            @Suppress("HardCodedStringLiteral")
            Text("This is a debug card")
        }
    }
}

@ThemePreviews
@Composable
fun WrongOutlinedButtonPreview(){
    WrongOutlinedButton(onClick = { }, text = stringResource(R.string.label_continue))
}

@Composable
fun AppOutlinedCard(
    modifier: Modifier = Modifier,
    content: @Composable ColumnScope.() -> Unit
) {
    val debug = false
    OutlinedCard(
        modifier = modifier
            .fillMaxWidth()
            .padding(ComponentDefaults.NoElevation),
        shape = ComponentDefaults.NoShape,
        elevation = CardDefaults.cardElevation(defaultElevation = ComponentDefaults.NoElevation),
        border = BorderStroke(
            ComponentDefaults.DefaultBorderWidth,
            if (debug) Color.Magenta else Color.Transparent
        ),
        content = content
    )
}


@Composable
fun CorrectButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: String? = null,
    leadingIcon: ImageVector? = null,
    trailingIcon: ImageVector? = null,
    content: (@Composable RowScope.() -> Unit)? = null,
) {
    AppButton(
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        colors = ButtonDefaults.buttonColors(
            containerColor = MaterialTheme.semanticColors.success,
            contentColor = MaterialTheme.semanticColors.onSuccess
        )
    ) {
        if (content != null) {
            content()
        } else {
            if (leadingIcon != null) {
                Icon(leadingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
                Spacer(Modifier.size(ButtonDefaults.IconSpacing))
            }
            if (text != null) Text(text)
            if (trailingIcon != null) {
                Spacer(Modifier.size(ButtonDefaults.IconSpacing))
                Icon(trailingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
            }
        }
    }
}

@Composable
fun WrongButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: String? = null,
    leadingIcon: ImageVector? = null,
    trailingIcon: ImageVector? = null,
    content: (@Composable RowScope.() -> Unit)? = null,
) {
    AppButton(
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        colors = ButtonDefaults.buttonColors(
            containerColor = MaterialTheme.semanticColors.wrong,
            contentColor = MaterialTheme.semanticColors.onWrong
        )
    ) {
        if (content != null) {
            content()
        } else {
            if (leadingIcon != null) {
                Icon(leadingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
                Spacer(Modifier.size(ButtonDefaults.IconSpacing))
            }
            if (text != null) Text(text)
            if (trailingIcon != null) {
                Spacer(Modifier.size(ButtonDefaults.IconSpacing))
                Icon(trailingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
            }
        }
    }
}

@Preview
@Composable
fun CorrectButtonPreview() {
    CorrectButton(onClick = { }, text = stringResource(R.string.label_continue))
}

@Preview
@Composable
fun WrongButtonPreview() {
    WrongButton(onClick = { }, text = stringResource(R.string.label_continue))
}

@Suppress("unused", "HardCodedStringLiteral")
@Composable
fun CorrectOutlinedButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: String? = null,
    leadingIcon: ImageVector? = null,
    trailingIcon: ImageVector? = null,
) {
    AppOutlinedButton(
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        borderColor = MaterialTheme.semanticColors.onSuccessContainer,
        border = BorderStroke(ComponentDefaults.DefaultBorderWidth, MaterialTheme.semanticColors.onSuccessContainer)
    ) {
        if (leadingIcon != null) {
            Icon(leadingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
            Spacer(Modifier.size(ButtonDefaults.IconSpacing))
        }
        if (text != null) Text(text)
        if (trailingIcon != null) {
            Spacer(Modifier.size(ButtonDefaults.IconSpacing))
            Icon(trailingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
        }
    }
}

@Composable
fun WrongOutlinedButton(
    onClick: () -> Unit,
    modifier: Modifier = Modifier,
    enabled: Boolean = true,
    text: String? = null,
    leadingIcon: ImageVector? = null,
    trailingIcon: ImageVector? = null,
) {
    AppOutlinedButton(
        onClick = onClick,
        modifier = modifier.height(ComponentDefaults.DefaultButtonHeight),
        enabled = enabled,
        shape = ComponentDefaults.DefaultShape,
        borderColor = MaterialTheme.semanticColors.wrongContainer,
        border = BorderStroke(ComponentDefaults.DefaultBorderWidth, MaterialTheme.semanticColors.onWrongContainer)
    ) {
        if (leadingIcon != null) {
            Icon(leadingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
            Spacer(Modifier.size(ButtonDefaults.IconSpacing))
        }
        if (text != null) Text(text)
        if (trailingIcon != null) {
            Spacer(Modifier.size(ButtonDefaults.IconSpacing))
            Icon(trailingIcon, contentDescription = null, modifier = Modifier.size(ButtonDefaults.IconSize))
        }
    }
}

