<commit_before><#--
* 
* Structural code (grid, tile, etc.) HTML template include, default Cato markup.
*
* Included by htmlTemplate.ftl.
*
* NOTE: May have implicit dependencies on other parts of Cato API.
*
-->

<#--
*************
* Row
************
  * Usage Example *  
    <@row attr="" >
        <@cell attr=""/>
    </@row>              
                    
  * Parameters *
    class           = css classes 
                      supports prefixes:
                        "+": causes the classes to append only, never replace defaults (same logic as empty string "")
                        "=": causes the class to replace non-essential defaults (same as specifying a class name directly)
    alt             = boolean, if true alternate row (odd), if false regular (even)
    selected        = boolean, if true row is marked selected
-->
<#macro row class="" id="" collapse=false norows=false alt="" selected="" openOnly=false closeOnly=false wrapIf=true>
  <#local open = wrapIf && !closeOnly && !norows>
  <#local close = wrapIf && !openOnly && !norows>
  <#if open>
      <#if alt?is_boolean>
        <#local class = addClassArg(class, alt?string(styles.row_alt!, styles.row_reg!))>
      </#if>
      <#if selected?is_boolean && selected == true>
        <#local class = addClassArg(class, styles.row_selected!)>
      </#if>
      <#local class = addClassArg(class, styles.grid_row!)>
      <#if collapse>
        <#local class = addClassArg(class, styles.collapse!)>
      </#if>
  <#else>
    <#-- WARN: has no memory when closeOnly... -->
    <#local classes = "">
  </#if>
  <@row_markup open=open close=close class=class collapse=collapse id=id alt=alt selected=selected><#nested /></@row_markup>
</#macro>

<#-- @row container markup - theme override -->
<#macro row_markup open=true close=true class="" collapse=false id="" alt="" selected="" extraArgs...>
  <#if open>
    <div<@compiledClassAttribStr class=class /><#if id?has_content> id="${id}"</#if>><#rt/>
  </#if>
      <#nested />
  <#if close>
    </div>
  </#if> 
</#macro>

<#-- 
*************
* Cell
************
    Usage examples:  
    <@row attr="" >
        <@cell attr="">
            cell content goes in here!
        </@cell>
    </@row>  
    
    <@row>
        <@cell>
            cell content goes in here!
        </@cell>
    </@row>   
    
    <@row>
        <@cell columns=3>
            cell content goes in here!
        </@cell>
    </@row> 
    
    <@row>
        <@cell columns=3 small=2 class="+my-cell">
            cell content goes in here!
        </@cell>
    </@row>            
                    
  * Parameters *
    class           = css classes (if column sizes specified, adds classes; if no column sizes specified, expected to contain manual column sizes and overrides columns size default)
                      supports prefixes:
                        "+": causes the classes to append only, never replace defaults (same logic as empty string "")
                        "=": causes the class to replace non-essential defaults (same as specifying a class name directly)
    columns         = expected number of columns to be rendered (specify as number, default 12, default only used if class empty and no column sizes specified)
    small           = specific number of small columns (specify as number), overrides small part general columns value above
    large           = specific number of large columns (specify as number), overrides large part of general columns value above
    medium          = specific number of medium columns (specify as number), overrides medium part of general columns value above
    offset          = offset in number of columns
    smallOffset     = specific offset for small columns
    mediumOffset    = specific offset for medium columns
    largeOffset     = specific offset for large columns
    last            = boolean, usually optional, if true indicate last cell in row 
-->
<#macro cell columns=-1 small=-1 medium=-1 large=-1 offset=-1 smallOffset=-1 mediumOffset=-1 largeOffset=-1 class="" id="" collapse=false nocells=false last=false openOnly=false closeOnly=false wrapIf=true>
  <#local open = wrapIf && !closeOnly && !nocells>
  <#local close = wrapIf && !openOnly && !nocells>
  <#if open>
    <#local columns = columns?number>
    <#local small = small?number>
    <#local medium = medium?number>
    <#local large = large?number>
    <#local offset = offset?number>
    <#local smallOffset = smallOffset?number>
    <#local mediumOffset = mediumOffset?number>
    <#local largeOffset = largeOffset?number>
    
    <#local specColsClasses><#if (small > 0)> ${styles.grid_small!}${small}</#if><#if (medium > 0)> ${styles.grid_medium!}${medium}</#if><#if (large > 0)> ${styles.grid_large!}${large}<#elseif (large != 0) && (columns > 0)> ${styles.grid_large!}${columns}</#if></#local>
    <#-- special case: use Replacing so that if spec col classes present, will turn into replacing class string that will prevent next default -->
    <#local class = addClassArgReplacing(class, specColsClasses)>
    <#local class = addClassArgDefault(class, "${styles.grid_cell_default!}")>

    <#local specOffsetClassesStr><#if (smallOffset > 0)> ${styles.grid_small_offset!}${smallOffset}</#if><#if (mediumOffset > 0)> ${styles.grid_medium_offset!}${mediumOffset}</#if><#if (largeOffset > 0)> ${styles.grid_large_offset!}${largeOffset}<#elseif (largeOffset != 0) && (offset > 0)> ${styles.grid_large_offset!}${offset}</#if></#local>
    <#local class = addClassArg(class, specOffsetClassesStr)>
    <#local class = addClassArg(class, styles.grid_cell!)>
    <#if last>
      <#local class = addClassArg(class, styles.grid_end!)>
    </#if>
    <#-- save grid sizes -->
    <#local dummy = saveCurrentContainerSizesFromStyleStr(class)>
  <#else>
    <#-- WARN: has no memory when closeOnly... -->
    <#local class = "">
  </#if>
  <@cell_markup open=open close=close class=class id=id last=last><#nested></@cell_markup>
  <#if close>
    <#-- pop grid sizes -->
    <#local dummy = unsetCurrentContainerSizes()>
  </#if>
</#macro>

<#-- @cell container markup - theme override -->
<#macro cell_markup open=true close=true class="" id="" last=false extraArgs...>
  <#if open>
    <div<@compiledClassAttribStr class=class /><#if id?has_content> id="${id}"</#if>><#rt>
  </#if>
      <#nested><#t>
  <#if close>
    </div><#lt>
  </#if>
</#macro>

<#-- 
*************
* Container size method overrides
************   
These provide framework-/theme-specific overriding implementations of the placeholder functions of the
saveCurrentContainerSizes and related utilities lib functions.

NOTE: implementation of evalAbsContainerSizeFactors assumes all max sizes for large/medium/small are the
    same.

DEV NOTE: TODO: these should be general enough to work for both foundation and bootstrap, but
    should be confirmed...
-->

<#function parseContainerSizesFromStyleStr style>
  <#if !catoContainerSizesPrefixMap??>
    <#global catoContainerSizesPrefixMap = {
      "${styles.grid_large!}" : "large", "${styles.grid_medium!}" : "medium", "${styles.grid_small!}" : "small"
    }>
  </#if>
  <#return extractPrefixedStyleNamesWithInt(getPlainClassArgNames(style), catoContainerSizesPrefixMap)>
</#function>

<#function evalAbsContainerSizeFactors sizesList maxSizes=0><commit_msg>NoRef make sure have extraArgs for backward compat<commit_after><#--
* 
* Structural code (grid, tile, etc.) HTML template include, default Cato markup.
*
* Included by htmlTemplate.ftl.
*
* NOTE: May have implicit dependencies on other parts of Cato API.
*
-->

<#--
*************
* Row
************
  * Usage Example *  
    <@row attr="" >
        <@cell attr=""/>
    </@row>              
                    
  * Parameters *
    class           = css classes 
                      supports prefixes:
                        "+": causes the classes to append only, never replace defaults (same logic as empty string "")
                        "=": causes the class to replace non-essential defaults (same as specifying a class name directly)
    alt             = boolean, if true alternate row (odd), if false regular (even)
    selected        = boolean, if true row is marked selected
-->
<#macro row class="" id="" collapse=false norows=false alt="" selected="" openOnly=false closeOnly=false wrapIf=true>
  <#local open = wrapIf && !closeOnly && !norows>
  <#local close = wrapIf && !openOnly && !norows>
  <#if open>
      <#if alt?is_boolean>
        <#local class = addClassArg(class, alt?string(styles.row_alt!, styles.row_reg!))>
      </#if>
      <#if selected?is_boolean && selected == true>
        <#local class = addClassArg(class, styles.row_selected!)>
      </#if>
      <#local class = addClassArg(class, styles.grid_row!)>
      <#if collapse>
        <#local class = addClassArg(class, styles.collapse!)>
      </#if>
  <#else>
    <#-- WARN: has no memory when closeOnly... -->
    <#local classes = "">
  </#if>
  <@row_markup open=open close=close class=class collapse=collapse id=id alt=alt selected=selected><#nested /></@row_markup>
</#macro>

<#-- @row container markup - theme override -->
<#macro row_markup open=true close=true class="" collapse=false id="" alt="" selected="" extraArgs...>
  <#if open>
    <div<@compiledClassAttribStr class=class /><#if id?has_content> id="${id}"</#if>><#rt/>
  </#if>
      <#nested />
  <#if close>
    </div>
  </#if> 
</#macro>

<#-- 
*************
* Cell
************
    Usage examples:  
    <@row attr="" >
        <@cell attr="">
            cell content goes in here!
        </@cell>
    </@row>  
    
    <@row>
        <@cell>
            cell content goes in here!
        </@cell>
    </@row>   
    
    <@row>
        <@cell columns=3>
            cell content goes in here!
        </@cell>
    </@row> 
    
    <@row>
        <@cell columns=3 small=2 class="+my-cell">
            cell content goes in here!
        </@cell>
    </@row>            
                    
  * Parameters *
    class           = css classes (if column sizes specified, adds classes; if no column sizes specified, expected to contain manual column sizes and overrides columns size default)
                      supports prefixes:
                        "+": causes the classes to append only, never replace defaults (same logic as empty string "")
                        "=": causes the class to replace non-essential defaults (same as specifying a class name directly)
    columns         = expected number of columns to be rendered (specify as number, default 12, default only used if class empty and no column sizes specified)
    small           = specific number of small columns (specify as number), overrides small part general columns value above
    large           = specific number of large columns (specify as number), overrides large part of general columns value above
    medium          = specific number of medium columns (specify as number), overrides medium part of general columns value above
    offset          = offset in number of columns
    smallOffset     = specific offset for small columns
    mediumOffset    = specific offset for medium columns
    largeOffset     = specific offset for large columns
    last            = boolean, usually optional, if true indicate last cell in row 
-->
<#macro cell columns=-1 small=-1 medium=-1 large=-1 offset=-1 smallOffset=-1 mediumOffset=-1 largeOffset=-1 class="" id="" collapse=false nocells=false last=false openOnly=false closeOnly=false wrapIf=true>
  <#local open = wrapIf && !closeOnly && !nocells>
  <#local close = wrapIf && !openOnly && !nocells>
  <#if open>
    <#local columns = columns?number>
    <#local small = small?number>
    <#local medium = medium?number>
    <#local large = large?number>
    <#local offset = offset?number>
    <#local smallOffset = smallOffset?number>
    <#local mediumOffset = mediumOffset?number>
    <#local largeOffset = largeOffset?number>
    
    <#local specColsClasses><#if (small > 0)> ${styles.grid_small!}${small}</#if><#if (medium > 0)> ${styles.grid_medium!}${medium}</#if><#if (large > 0)> ${styles.grid_large!}${large}<#elseif (large != 0) && (columns > 0)> ${styles.grid_large!}${columns}</#if></#local>
    <#-- special case: use Replacing so that if spec col classes present, will turn into replacing class string that will prevent next default -->
    <#local class = addClassArgReplacing(class, specColsClasses)>
    <#local class = addClassArgDefault(class, "${styles.grid_cell_default!}")>

    <#local specOffsetClassesStr><#if (smallOffset > 0)> ${styles.grid_small_offset!}${smallOffset}</#if><#if (mediumOffset > 0)> ${styles.grid_medium_offset!}${mediumOffset}</#if><#if (largeOffset > 0)> ${styles.grid_large_offset!}${largeOffset}<#elseif (largeOffset != 0) && (offset > 0)> ${styles.grid_large_offset!}${offset}</#if></#local>
    <#local class = addClassArg(class, specOffsetClassesStr)>
    <#local class = addClassArg(class, styles.grid_cell!)>
    <#if last>
      <#local class = addClassArg(class, styles.grid_end!)>
    </#if>
    <#-- save grid sizes -->
    <#local dummy = saveCurrentContainerSizesFromStyleStr(class)>
  <#else>
    <#-- WARN: has no memory when closeOnly... -->
    <#local class = "">
  </#if>
  <@cell_markup open=open close=close class=class id=id last=last><#nested></@cell_markup>
  <#if close>
    <#-- pop grid sizes -->
    <#local dummy = unsetCurrentContainerSizes()>
  </#if>
</#macro>

<#-- @cell container markup - theme override -->
<#macro cell_markup open=true close=true class="" id="" last=false extraArgs...>
  <#if open>
    <div<@compiledClassAttribStr class=class /><#if id?has_content> id="${id}"</#if>><#rt>
  </#if>
      <#nested><#t>
  <#if close>
    </div><#lt>
  </#if>
</#macro>

<#-- 
*************
* Container size method overrides
************   
These provide framework-/theme-specific overriding implementations of the placeholder functions of the
saveCurrentContainerSizes and related utilities lib functions.

NOTE: implementation of evalAbsContainerSizeFactors assumes all max sizes for large/medium/small are the
    same.
NOTE: extraArgs is in case of interface changes.

DEV NOTE: TODO: these should be general enough to work for both foundation and bootstrap, but
    should be confirmed...
-->

<#function parseContainerSizesFromStyleStr style extraArgs...>
  <#if !catoContainerSizesPrefixMap??>
    <#global catoContainerSizesPrefixMap = {
      "${styles.grid_large!}" : "large", "${styles.grid_medium!}" : "medium", "${styles.grid_small!}" : "small"
    }>
  </#if>
  <#return extractPrefixedStyleNamesWithInt(getPlainClassArgNames(style), catoContainerSizesPrefixMap)>
</#function>

<#function evalAbsContainerSizeFactors sizesList maxSizes=0 extraArgs...>
{'fraction_non_alphanumeric': 0.14779789246149688, 'fraction_numerical': 0.0032423669278573357, 'mean_word_length': 3.1067961165048543, 'pattern_counts': {'":': 8, '<': 271, '<?xml version=': 0, '>': 287, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1464743', 'n_tokens_mistral': 4390, 'n_tokens_neox': 4308, 'n_words': 1340}