/**
 * @since Last modified: 2024/06/11 16:05:47
 * @function getBullitinTpl
 * @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.getBullitinTpl([{cube,label,tips,...}...],{paddingless,multiline,hoverable});
 * <!--return template string-->
 */




'use strict';
import { T_obj } from "../../../types/ax";
import prefix from "../global/prefix";
import getEl from "./getEl";
import isEmpty from "./isEmpty";

const getBullitinTpl = (data: T_obj, global: T_obj = {}): string => {
    if (isEmpty(data)) {
        return '';
    }
    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){ /}}
            <div class="${prefix}bullitin" ${global.paddingless ? 'paddingless' : ''} ${global.hoverable ? 'hoverable' : ''}  ${global.multiline ? 'multiline' : ''}>
                {{this.disk?'<span role="disk"><img src="'+this.disk+'"></span>':''}}
                {{this.cube?'<span role="cube"><img src="'+this.cube+'"></span>':''}}
                <div class="${prefix}bulletin-body">
                    {{if(this.type ==='checkbox'){/}}
                        <ax-checkbox name="{{this.name}}" {{this.checked?'check:"ed"':''}}>{{this.label}}</ax-checkbox>
                    {{}else if (this.type==='radio'){/}}
                        <ax-radio name="{{this.name}}" {{this.checked?'check:"ed"':''}}>{{this.label}}</ax-radio>
                    {{else if(this.href){/}}
                        <a href="{{this.href}}" {{this.target?'target:"+ this.target +"':''}} {{this.rel?'rel:"+ this.rel +"':''}} role="caption">{{this.label}}</a>
                    {{}else{/}}
                        <span role="caption" {{this.checked?'checked':''}>{{this.label}}</span>
                    {{}}}
                </div>
                {{this.badge?'<ax-badge>'+this.badge+'</ax-badge>':''}}
                {{this.tips?'<i role="tips"><img src="'+this.tips+'"></i>':''}}
                {{this.arrow?'<i class="'+this.arrow+'" role="arrow"></i>':''}}
            </div>                
            ${global.divisible ? '<hr>' : ''}
        {{}/}}
    </ul>`;
}
export default getBullitinTpl;
