<commit_before>// @flow

const React     = require('react')
const shiny     = require('shiny')

const r = React.createElement

const ContentImage = (props/*: { src: ?Object, cover: boolean, max_size: ?number }*/) => {
    if (null == props.src || null == props.src.content || null == props.src.content['640']) {
        return null
    }

    const alt_text = props.src.alt_text

    if (props.plain) {
        return r('img', { src: props.src.content['640'] && props.src.content['640'].url })
    }

    const srcset = []

    const src_128     = props.src.content['128'] ? props.src.content['128'].url : null
    const src_640     = props.src.content['640'] ? props.src.content['640'].url : null
    const src_1280    = props.src.content['1280'] ? props.src.content['1280'].url : null
    const src_2560    = props.src.content['2560'] ? props.src.content['2560'].url : null

    if (null != src_128) {
        srcset.unshift(`${ src_128 } 128w`)
    }
    if (null != src_640) {
        srcset.unshift(`${ src_640 } 640w`)
    }
    if (null != src_1280) {
        srcset.unshift(`${ src_1280 } 1280w`)
    }
    if (null != src_2560) {
        srcset.unshift(`${ src_2560 } 2560w`)
    }

    const cx = shiny('ContentImage')
    cx.add('cover', props.cover)
    const sizes = ['100vw']
    if (null == props.max_size || props.max_size >= 640) {
        sizes.unshift(`(min-width: 640px) 640px`)
    }
    
    if (null == props.max_size || props.max_size >= 1280) {
        sizes.unshift(`(min-width: 1280px) 1280px`)
    }

    if (null == props.max_size || props.max_size >= 2560) {
        sizes.unshift(`(min-width: 2560px) 2560px`)
    }

    const style = {}
    if (props.cover && null != props.src && null != props.src.focal_point) {
        style.objectPosition = `${ props.src.focal_point.x * 100 }% ${ props.src.focal_point.y * 100 }%`
    }

    return r('img', {
        className       : cx,
        src             : src_640,
        srcSet          : srcset.join(','),
        sizes           : sizes.join(','),
        alt             : alt_text,
        style           : style,
        'data-src_128'  : src_128,
        'data-src_640'  : src_640,
        'data-src_1280' : src_1280,
        'data-src_2560' : src_2560,
    })
}

ContentImage.defaultProps = {
    plain: false,<commit_msg>Remove unnecessary ContentImage attributes.<commit_after>// @flow

const React     = require('react')
const shiny     = require('shiny')

const r = React.createElement

const ContentImage = (props/*: { src: ?Object, cover: boolean, max_size: ?number }*/) => {
    if (null == props.src || null == props.src.content || null == props.src.content['640']) {
        return null
    }

    const alt_text = props.src.alt_text

    if (props.plain) {
        return r('img', { src: props.src.content['640'] && props.src.content['640'].url })
    }

    const srcset = []

    const src_128     = props.src.content['128'] ? props.src.content['128'].url : null
    const src_640     = props.src.content['640'] ? props.src.content['640'].url : null
    const src_1280    = props.src.content['1280'] ? props.src.content['1280'].url : null
    const src_2560    = props.src.content['2560'] ? props.src.content['2560'].url : null

    if (null != src_128) {
        srcset.unshift(`${ src_128 } 128w`)
    }
    if (null != src_640) {
        srcset.unshift(`${ src_640 } 640w`)
    }
    if (null != src_1280) {
        srcset.unshift(`${ src_1280 } 1280w`)
    }
    if (null != src_2560) {
        srcset.unshift(`${ src_2560 } 2560w`)
    }

    const cx = shiny('ContentImage')
    cx.add('cover', props.cover)
    const sizes = ['100vw']
    if (null == props.max_size || props.max_size >= 640) {
        sizes.unshift(`(min-width: 640px) 640px`)
    }
    
    if (null == props.max_size || props.max_size >= 1280) {
        sizes.unshift(`(min-width: 1280px) 1280px`)
    }

    if (null == props.max_size || props.max_size >= 2560) {
        sizes.unshift(`(min-width: 2560px) 2560px`)
    }

    const style = {}
    if (props.cover && null != props.src && null != props.src.focal_point) {
        style.objectPosition = `${ props.src.focal_point.x * 100 }% ${ props.src.focal_point.y * 100 }%`
    }

    return r('img', {
        className       : cx,
        src             : src_640,
        srcSet          : srcset.join(','),
        sizes           : sizes.join(','),
        alt             : alt_text,
        style           : style,
    })
}

ContentImage.defaultProps = {
    plain: false,
{'fraction_non_alphanumeric': 0.16910460992907803, 'fraction_numerical': 0.0673758865248227, 'mean_word_length': 2.239770279971285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5800508', 'n_tokens_mistral': 1761, 'n_tokens_neox': 1546, 'n_words': 304}