import { Asset } from '../molecules/asset.js'
import { PromoText } from '../molecules/promo-text.js'
import { ValidationError } from '../routing/error-handler.js'
import disableTransparency from '../shared/disable-transparency.js'
import h from '../shared/h.js'

export function PromoBottom ({ _model, ...props }) {
  const { title, text, asset } = _model
  if (!title || !text || !asset.src) {
    throw new ValidationError()
  }

  return h('div', { ...props, className: `relative h-full rounded-2xl overflow-hidden lg:grid lg:grid-cols-2 bg-bga text-txa ${disableTransparency(props._color)}` },
    h('div', { className: 'row-start-1 col-start-1 col-span-2 lg:h-full' },
      h(Asset, { _model, _tall: true })
    ),
    h('div', { className: 'row-start-1 col-start-1 col-span-1 lg:p-6 flex items-end' },
      h('div', { className: 'lg:rounded-xl lg:overflow-hidden w-full relative bg-bga text-txa' },
        h(PromoText, { _model })
      )
    )
  )
}
