<?php

namespace App\Filament\Resources\InterstitialAds\Schemas;

use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Schema;

class InterstitialAdForm
{
    public static function configure(Schema $schema): Schema
    {
        return $schema
            ->components([
                Select::make('user_id')
                    ->relationship('user', 'name'),
                Select::make('link_id')
                    ->relationship('link', 'title')
                    ->required(),
                Select::make('ad_type')
                    ->options([
                        'script' => 'Ad script',
                        'direct_link' => 'Direct link ad',
                        'iframe' => 'Iframe URL',
                        'image_link' => 'Image and link',
                        'affiliate' => 'Affiliate',
                        'custom_html' => 'Custom HTML',
                    ])
                    ->required()
                    ->default('custom_html'),
                TextInput::make('title'),
                Textarea::make('body_text')
                    ->columnSpanFull(),
                FileUpload::make('image_path')
                    ->image(),
                TextInput::make('button_text'),
                Textarea::make('button_url')
                    ->columnSpanFull(),
                Textarea::make('iframe_url')
                    ->columnSpanFull(),
                Textarea::make('ad_script')
                    ->columnSpanFull(),
                RichEditor::make('custom_html')
                    ->label('Custom HTML')
                    ->helperText('WYSIWYG HTML editor for the custom interstitial ad block.')
                    ->columnSpanFull(),
                TextInput::make('duration_seconds')
                    ->required()
                    ->numeric()
                    ->default(5),
                TextInput::make('skippable_after')
                    ->numeric(),
                Select::make('status')
                    ->options([
                        'active' => 'Active',
                        'paused' => 'Paused',
                    ])
                    ->required()
                    ->default('active'),
            ]);
    }
}
