import{makeStyle as e,template as t}from"@gem-sdk/core";import{getDynamicSourceLocales as a}from"../../../../helpers.js";import{customClass as r}from"./classes.js";import i from"html-react-parser";import{createClass as s,createStyle as o}from"@gem-sdk/system";import{getCustomStyle as n,getPaginatorStyle as l}from"./styles.js";let renderPaginatorItem=({setting:e,builderProps:t,pageContext:a},r)=>"liquid"===r?renderPaginatorLive({setting:e,builderProps:t,pageContext:a}):renderPaginatorEditor({setting:e,builderProps:t,pageContext:a}),renderPaginatorLive=({setting:e,builderProps:t,pageContext:a})=>{let r=getPreviousTextVal({setting:e,builderProps:t,pageContext:a},"liquid"),i=getNextTextVal({setting:e,builderProps:t,pageContext:a},"liquid"),s=e?.numberOfProducts||a?.numberOfProductOfProductList||0,o=s>0?s:4,n=e=>e?.replace(/"/g,'\\"')??"",l=`"${n(r??"")}"`,m=`"${n(i??"")}"`;return`
    {% paginate collection.products by ${o} %}
      {% assign previousText = ${a?.isPreviewing?l:r||'""'} %}
      {% assign nextText = ${a?.isPreviewing?m:i||'""'} %}

      {{ paginate | default_pagination: previous: previousText, next: nextText }}
    {% endpaginate %}
  `},renderPaginatorEditor=({setting:t,builderProps:a,pageContext:m})=>{let{pageQuantity:p,typo:c,normalColor:g,activeColor:u}=t??{},d=[],x=parseInt(p??"0"),P=6;6>x&&(P=x-1);let y=P>1?P-1:0,f=getPreviousTextVal({setting:t,builderProps:a,pageContext:m},"react"),v=getNextTextVal({setting:t,builderProps:a,pageContext:m},"react"),I=s({...r("prev",g,t)}),T=s({...r("page",g,t)}),h=s({...r("deco",g,t)}),N=e=>s({...r("page",e===y?u:g,t)}),k=s({...r("deco",g,t)}),L=s({...r("page",g,t)}),$=s({...r("next",g,t)}),q=e=>o({...l(e===y,n(t),u)}),w=o({...n(t),...e({w:"auto"})}),z=o({...n(t)}),V=o({...n(t),...e({w:"auto"})});y>0&&d.push(createPaginatorItem({key:"prev",text:c?.attrs?.transform==="capitalize"?f?.toLocaleLowerCase():f,className:I,style:w})),y>2&&d.push(createPaginatorItem({key:1,text:1,className:T,style:z})),y>3&&d.push(createPaginatorItem({key:"deco",text:"...",className:h,style:z}));for(let e=Math.max(0,y-2);e<=Math.min(y+2,x-1);e++)d.push(createPaginatorItem({key:e+1,text:e+1,className:N(e),style:q(e)}));return y<x-4&&d.push(createPaginatorItem({key:"deco-2",text:"...",className:k,style:z})),y<x-3&&d.push(createPaginatorItem({key:x,text:x,className:L,style:z})),y!==x-1&&0!==x&&d.push(createPaginatorItem({key:"next",text:c?.attrs?.transform==="capitalize"?v?.toLocaleLowerCase():v,className:$,style:V})),d.map(e=>i(e))},createPaginatorItem=({key:e,text:a,className:r,style:i})=>t`<span key="${e}" className="${r}" style="${i}"> ${a} </span>`,getPreviousTextVal=({setting:e,builderProps:t,pageContext:r},i)=>{let{previousText:s,typo:o,translate:n}=e??{};return"liquid"===i?a({val:s,uid:t?.uid,settingId:"previousText",pageContext:r,isLiquid:!0,isCapitalize:o?.attrs?.transform==="capitalize",translate:n}).toString():s},getNextTextVal=({setting:e,builderProps:t,pageContext:r},i)=>{let{nextText:s,typo:o,translate:n}=e??{};return"liquid"===i?a({val:s,uid:t?.uid,settingId:"nextText",pageContext:r,isLiquid:!0,isCapitalize:o?.attrs?.transform==="capitalize",translate:n}).toString():s};export{renderPaginatorItem};
