'use client';
import{splitStyle as l,composeAdvanceStyle as e,makeStyleResponsive as i,getResponsiveValueByScreen as t,getGradientBgrStyleByDevice as a,getStyleBackgroundByDevice as r,makeStyleWithDefault as s,makeWidth as n,cls as o,template as c}from"@gem-sdk/core";import{convertSpecialCharacter as g}from"../common/helpers.js";import{convertUnitToNumber as d}from"../../helpers.js";let m=m=>{let{styles:p,setting:b,className:u,children:f,builderProps:_,advanced:h,style:T}=m??{},{border:y,rounded:$,hasBoxShadow:w,boxShadow:S}=h??{},[k]=l(["pos","top","left","bottom","right","z","d"],T),E=e({border:y,rounded:$,hasBoxShadow:w,boxShadow:S,"spacing-setting":h?.["spacing-setting"]}),v=b?.articleSetting,B=b?.articleOrderBy??"UPDATED_AT_REVERSE",H=v?.articlePickType??"manually",R="manually"===H&&v?.articleHandles?.length?v?.articleHandles:[],x="manually"===H&&v?.articleBlogTitles?.length?v?.articleBlogTitles:[],P=v?.blogHandle??"",A=d(b?.numberOfArticle,4);return c`
    <div
    style="${k}"
    data-id="${_?.uid}"
      items-repeat
    >
      <div style="${{...E,...s("w",n(p?.width),{desktop:"--g-ct-w",tablet:"--g-ct-w",mobile:"--g-ct-w"}),...i("rg",p?.horizontalGutter),...i("cg",p?.verticalGutter),...r(b?.background),...a(b?.background),...i("gtc",{desktop:`repeat(${t(b?.slideToShow,"desktop")}, minmax(0, 1fr))`,tablet:b?.slideToShow?.tablet&&`repeat(${t(b?.slideToShow,"tablet")}, minmax(0, 1fr))`,mobile:b?.slideToShow?.mobile&&`repeat(${t(b?.slideToShow,"mobile")}, minmax(0, 1fr))`})}}"
          class="${o(u,"gp-grid !gp-m-auto gp-w-full",h?.cssClass)}"
        >
        {% liquid
            assign articlePickType = '${H}'
            assign articleHandles = '${R.toString()}'| split: ","
            assign articleBlogTitle = "${g(x.toString())}" | split: ","
            assign limit = "${"manually"===H?v?.articleIds?.length:A}"
            assign blogTitle = ''
            assign all_articles = null | sort

            if articlePickType == 'manually'
              for handle in articleHandles
                assign articleByHandle = articles[handle] | sort
                assign all_articles = all_articles | concat: articleByHandle
              endfor
            else
              assign current_blog_handle = blogs['${P}']
              if gp_enable_custom_dynamic_blog == true
                assign current_blog_handle = blogs[blog.handle]
              endif
              assign all_articles = current_blog_handle.articles | limit: limit | sort: "${B.replace("_REVERSE","").toLowerCase()}" ${B.includes("_REVERSE")?"| reverse":""}
              assign blogTitle = current_blog_handle.title
            endif

        %}
        {% for article in all_articles limit: limit %}
          {% if articlePickType == 'manually' %}
              {% assign blogTitle = articleBlogTitle[forloop.index0] %}
          {% endif %}
          <div>${f??""}</div>
        {% endfor %}
      </div>
    </div>

  `};export{m as default};
