import ReactDOM from 'react-dom';
import * as React from 'react';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export const renderTemplate = (template, model, _component) => {
    template(model, model.container);
};
export const hasTemplate = (name, props, _component) => {
    const value = props[name];
    return !!value && typeof value !== 'string';
};
export const getWrapperTemplate = (TemplateProp) => {
    const isComponent = typeof TemplateProp === 'string' || !!(TemplateProp instanceof Element);
    return isComponent ? TemplateProp : (data) => {
        const container = data.container ? data.container : data.item;
        ReactDOM.render(
        /* eslint-disable react/jsx-props-no-spreading */
        React.createElement(TemplateProp, Object.assign({}, data)), container);
    };
};
export const getTemplate = (TemplateProp, RenderProp, ComponentProp) => ((TemplateProp && (TemplateProp.defaultProps ? (props) => React.createElement(TemplateProp, Object.assign({}, props)) : TemplateProp))
    || (RenderProp
        && ((props) => RenderProp(...('data' in props ? [props.data, props.index] : [props]))))
    || (ComponentProp && ((props) => React.createElement(ComponentProp, Object.assign({}, props)))));
