import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

async function seedLandingPages() {
  try {
    console.log('🌱 Seeding landing pages...')

    // Create Classic Landing Page
    const classicPage = await prisma.landingPage.upsert({
      where: { slug: 'classic' },
      update: {},
      create: {
        name: 'Classic Landing Page',
        slug: 'classic',
        title: 'Sistem Pelayanan Digital - Classic',
        description: 'Classic landing page design with traditional layout and amber color scheme',
        type: 'CLASSIC',
        path: '/landing-pages/classic',
        isActive: true,
        isDefault: true,
        settings: {
          theme: 'amber',
          layout: 'traditional',
          features: ['hero', 'stats', 'features', 'services', 'testimonials', 'cta', 'footer']
        },
        metadata: {
          seo: {
            title: 'Polres Wonosobo - Sistem Pelayanan Digital',
            description: 'Layanan pengajuan dokumen kepolisian secara online yang mudah, cepat, dan terpercaya'
          }
        }
      }
    })

    console.log('✅ Created Classic landing page:', classicPage.name)

    // Create Modern Landing Page
    const modernPage = await prisma.landingPage.upsert({
      where: { slug: 'modern' },
      update: {},
      create: {
        name: 'Modern Landing Page',
        slug: 'modern',
        title: 'Platform Digital Kepolisian - Modern',
        description: 'Modern landing page with dark theme, gradients, and contemporary design elements',
        type: 'MODERN',
        path: '/landing-pages/modern',
        isActive: false,
        isDefault: false,
        settings: {
          theme: 'dark',
          layout: 'contemporary',
          features: ['hero', 'stats', 'features', 'services', 'cta', 'footer'],
          animations: true,
          glassmorphism: true
        },
        metadata: {
          seo: {
            title: 'Polres Wonosobo - Platform Digital Kepolisian Modern',
            description: 'Platform digital kepolisian modern dengan teknologi terkini untuk kemudahan layanan masyarakat'
          }
        }
      }
    })

    console.log('✅ Created Modern landing page:', modernPage.name)

    // Create Minimal Landing Page (placeholder)
    const minimalPage = await prisma.landingPage.upsert({
      where: { slug: 'minimal' },
      update: {},
      create: {
        name: 'Minimal Landing Page',
        slug: 'minimal',
        title: 'Layanan Digital - Minimal',
        description: 'Clean and minimal landing page design with focus on content',
        type: 'MINIMAL',
        path: '/landing-pages/minimal',
        isActive: false,
        isDefault: false,
        settings: {
          theme: 'light',
          layout: 'minimal',
          features: ['hero', 'services', 'footer']
        },
        metadata: {
          seo: {
            title: 'Polres Wonosobo - Layanan Digital Minimal',
            description: 'Layanan kepolisian digital dengan desain minimalis dan fokus pada konten'
          }
        }
      }
    })

    console.log('✅ Created Minimal landing page:', minimalPage.name)

    // Create Corporate Landing Page (placeholder)
    const corporatePage = await prisma.landingPage.upsert({
      where: { slug: 'corporate' },
      update: {},
      create: {
        name: 'Corporate Landing Page',
        slug: 'corporate',
        title: 'Portal Resmi - Corporate',
        description: 'Professional corporate landing page suitable for government institutions',
        type: 'CORPORATE',
        path: '/landing-pages/corporate',
        isActive: false,
        isDefault: false,
        settings: {
          theme: 'corporate',
          layout: 'professional',
          features: ['hero', 'about', 'services', 'stats', 'contact', 'footer']
        },
        metadata: {
          seo: {
            title: 'Polres Wonosobo - Portal Resmi',
            description: 'Portal resmi Kepolisian Resort Wonosobo dengan desain korporat profesional'
          }
        }
      }
    })

    console.log('✅ Created Corporate landing page:', corporatePage.name)

    console.log('🎉 Landing pages seeding completed!')
    
    return {
      classic: classicPage,
      modern: modernPage,
      minimal: minimalPage,
      corporate: corporatePage
    }
  } catch (error) {
    console.error('❌ Error seeding landing pages:', error)
    throw error
  }
}

// Run if called directly
if (require.main === module) {
  seedLandingPages()
    .catch((error) => {
      console.error(error)
      process.exit(1)
    })
    .finally(async () => {
      await prisma.$disconnect()
    })
}

export default seedLandingPages