{{#each matrices ~}}
{{#each this ~}} {{! matrix }}
{{#each this ~}} {{! column }}
{{#if this ~}} {{! viewmodel }}
    {{#fi this.top '<' @root.renderLimitIdx ~}}
    <div data-id="{{stamp model}}"
         class="{{CSS_PREFIX}}weekday-schedule-block
                {{CSS_PREFIX}}weekday-schedule-block-{{stamp model}}
            {{#if exceedLeft}} {{CSS_PREFIX}}weekday-exceed-left{{/if}}
            {{#if exceedRight}} {{CSS_PREFIX}}weekday-exceed-right{{/if}}"
         style="{{month-scheduleBlock this @root.dates @root.scheduleBlockHeight @root.gridHeaderHeight}};
                margin-top:{{@root.scheduleBlockGutter}}px">
        {{#fi model.isAllDay '||' hasMultiDates}}
        <div data-schedule-id="{{model.id}}" data-calendar-id="{{model.calendarId}}" class="{{CSS_PREFIX}}weekday-schedule {{#if model.isFocused}}{{CSS_PREFIX}}weekday-schedule-focused {{/if}}"
             style="height:{{@root.scheduleHeight}}px; line-height:{{@root.scheduleHeight}}px; border-radius: {{@root.styles.borderRadius}};
                {{#unless exceedLeft}}
                    margin-left: {{@root.styles.marginLeft}};
                {{/unless}}
                {{#unless exceedRight}}
                    margin-right: {{@root.styles.marginRight}};
                {{/unless}}
                {{#if model.isFocused}}
                    color: #ffffff; background-color:{{model.color}}; border-color:{{model.color}};
                {{else}}
                    color:{{model.color}}; background-color:{{model.bgColor}}; border-color:{{model.borderColor}};
                {{/if}}
                    {{model.customStyle}}">
            <span class="{{CSS_PREFIX}}weekday-schedule-title"
                  data-title="{{model.title}}">{{{allday-tmpl model}}}</span>
            {{#unless (or @root.isReadOnly model.isReadOnly)}}<span class="{{CSS_PREFIX}}weekday-resize-handle handle-y" style="line-height: {{@root.scheduleHeight}}px;">&nbsp;</span>{{/unless}}
        </div>
        {{else ~}}
            {{#fi model.category '===' 'time'}}
                <div data-schedule-id="{{model.id}}" data-calendar-id="{{model.calendarId}}" class="{{CSS_PREFIX}}weekday-schedule {{CSS_PREFIX}}weekday-schedule-time"
                    style="height:{{@root.scheduleHeight}}px; line-height:{{@root.scheduleHeight}}px; {{model.customStyle}}">
                    <span class="{{CSS_PREFIX}}weekday-schedule-bullet"
                        style="top: {{@root.styles.scheduleBulletTop}}px;
                            {{#if model.isFocused}}
                                background: #ffffff
                            {{else}}
                                background:{{model.borderColor}}
                            {{/if}}
                            "
                    ></span>
                    <span class="{{CSS_PREFIX}}weekday-schedule-title"
                        style="
                            {{#if model.isFocused}}
                                color: #ffffff;
                                background-color: {{model.color}}
                            {{else}}
                                color:#333;
                            {{/if}}
                            "
                        data-title="{{model.title}}">{{{time-tmpl model}}}</span>
                </div>
            {{else ~}}
                <div data-schedule-id="{{model.id}}" data-calendar-id="{{model.calendarId}}" class="{{CSS_PREFIX}}weekday-schedule {{#if model.isFocused}}{{CSS_PREFIX}}weekday-schedule-focused {{/if}}"
                    style="height:{{@root.scheduleHeight}}px; line-height:{{@root.scheduleHeight}}px; border-radius: {{@root.styles.borderRadius}};
                    {{#unless exceedLeft}}
                        margin-left: {{@root.styles.marginLeft}};
                    {{/unless}}
                    {{#unless exceedRight}}
                        margin-right: {{@root.styles.marginRight}};
                    {{/unless}}
                    {{#if model.isFocused}}
                        color: #ffffff; background-color:{{model.color}}; border-color:{{model.color}};
                    {{else}}
                        color:{{model.color}}; background-color:{{model.bgColor}}; border-color:{{model.borderColor}};
                    {{/if}}
                        {{model.customStyle}}">
                    <span class="{{CSS_PREFIX}}weekday-schedule-title"
                                    data-title="{{model.title}}">{{{schedule-tmpl model}}}</span>
                </div>
            {{/fi}}
        {{/fi}}
    </div>
    {{/fi ~}}
{{/if ~}}
{{/each ~}}
{{/each ~}}
{{/each ~}}
