/**
 * @since Last modified: 2024-09-11 09:49:37
 * @function getBulletinsTpl
 * @description Determine whether the two nodes contain or equal relationships.
 * @param  {object[]} data - List data.
 * @param  {object} [global={}] - Global paramsters.
 * @returns {boolean} Return template string.
 * @see {@link https://codepen.io/axui/pen/bGzQOYP|demo @ codepen}
 * @example
 * ax.getBulletinsTpl([{cube,label,tips,...}...],{paddingless,multiline,hoverable});
 * <!--return template string-->
 */
'use strict';
import alias from "../global/alias";
import prefix from "../global/prefix";
const getBulletinsTpl = (global = {}) => {
    let grid = '';
    if (global.cols > 0) {
        grid = global.fence ? `${prefix}grid ${prefix}fence` : `${prefix}grid`;
    }
    return `
    <ul class="${prefix}reset ${grid}">
        {{for(let k of this){
            let check = k.checked && (!['checkboxes','radios'].includes('${global.type}') && !['checkbox','radio'].includes(k.type)) ?'checked':'',
                value = k.value?'value="+ k.value +"':'',
                selected=k.selected?'selected':'',
                active=k.active?'active':'',
                disabled=k.disabled?'disabled':''; 
        /}}
            <li>
                <div class="${prefix}bulletin" ${global.paddingless ? 'paddingless' : ''} ${global.hoverable ? 'hoverable' : ''}  ${global.multiline ? 'multiline' : ''}  {{selected}} {{active}} {{check}}  {{disabled}}>
                {{k.disk?'<span ${alias}="disk"><img src="'+k.disk+'"></span>':''}}
                {{k.cube?'<span ${alias}="cube"><img src="'+k.cube+'"></span>':''}}
                <div class="${prefix}bulletin-body">
                    {{if('${global.type}' ==='checkboxes' || k.type ==='checkbox'){/}}
                        <ax-checkbox name="{{k.name}}" {{k.checked?'check="ed"':''}} {{value}}>{{k.label}}</ax-checkbox>
                    {{}else if ('${global.type}' ==='radios' || k.type==='radio'){/}}
                        <ax-radio name="{{k.name}}" {{k.checked?'check="ed"':''}} {{value}}>{{k.label}}</ax-radio>
                    {{}else if(k.href){/}}
                        <a ${alias}="caption" href="{{k.href}}" {{k.target?'target="+ k.target +"':''}} {{k.rel?'rel="+ k.rel +"':''}}  {{value}}>{{k.label}}</a>
                    {{}else{/}}
                        <span ${alias}="caption" {{value}}>{{k.label}}</span>
                    {{}/}}
                </div>
                {{k.badge?'<ax-badge>'+k.badge+'</ax-badge>':''}}
                {{k.tips?'<i ${alias}="tips"><img src="'+k.tips+'"></i>':''}}
                {{k.arrow?'<i class="'+k.arrow+'" ${alias}="arrow"></i>':''}}
                </div>
                ${global.divisible ? '<hr>' : ''}
            </li>
        {{}/}}
    </ul>`;
};
export default getBulletinsTpl;
