import Icon from '../icon';
import Button from '../button';
import Intact from 'intact';

const normalize = Intact.normalize;

let {
    type, content, hideIcon, 
    hideFooter, showClose, _title
} = self.get();

if (normalize) {
    content = normalize(content);
}

<t:parent class={{ {[`k-${type}`]: true, 'k-alert-dialog': true, 'k-with-title': _title} }}
    hideClose={{ !showClose }}
>
    <b:body>
        <div class="k-tip-icon">
            <Icon class={{ {
                "ion-ios-checkmark": type === 'success',
                "ion-ios-information": type === 'warning',
                "ion-ios-close": type === 'error',
                "ion-ios-help": type === 'confirm',
            } }} v-if={{ !hideIcon }} />
        </div>
        <div class="k-content-wrapper">
            <div class="k-title" v-if={{ _title }}>{{ _title }}</div>
            {{ content }}
        </div>
    </b:body>
    <b:footer>
        <Button class="k-cancel" ev-click={{ self.cancel }}
            v-if={{ type === 'confirm' && !hideFooter }}
        >{{ self.get('cancelText') }}</Button>
        <Button class="k-ok" type="primary" ev-click={{ self.ok }} 
            loading={{ self.get('loading') }}
            disabled={{ self.get('disabledOk') }}
            v-if={{ !hideFooter }}
        >{{ self.get('okText') }}</Button>
    </b:footer>
</t:parent>
