import APIClient
import ComponentLibrary
import Foundation
import Localization
import SwiftUI

struct SuggestionsView: View {
    let items: [String]
    var text: String
    var limit: Int
    var randomAction: () -> Void
    var selectAction: (String) -> Void
    var horizontalPadding: CGFloat = 12

    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            HStack {
                Text(L10n.FeatureCreateClip.suggestionsTitle)
                    .typographyV1(.body3)
                    .foregroundColor(Color.SemanticV1.textBrand)
                Spacer()
                CharCount(text: text, limit: limit, background: Color.SemanticV1.backgroundTertiary)
            }
            .padding(.horizontal, horizontalPadding)

            ScrollView(.horizontal, showsIndicators: false) {
                HStack(spacing: 8) {
                    // Choose random
                    Button(action: randomAction) {
                        Image.Icon.dice
                    }
                    .typographyV1(.body3)
                    .foregroundStyle(Color.SemanticV1.textPrimary)
                    .padding(12)
                    .background(Color.SemanticV1.backgroundTertiary)
                    .cornerRadius(24)

                    ForEach(items, id: \.self) { prompt in
                        Button {
                            selectAction(prompt)
                        } label: {
                            Text(prompt)
                        }
                        .typographyV1(.body3)
                        .foregroundStyle(Color.SemanticV1.textPrimary)
                        .padding(12)
                        .background(Color.SemanticV1.backgroundTertiary)
                        .cornerRadius(24)
                    }
                }
                .padding(.horizontal, horizontalPadding)
            }
            .scrollClipDisabled()
            .scrollBounceBehavior(.basedOnSize)
        }
    }
}
