"use strict";var core=require("@gem-sdk/core"),helpers=require("../../../../helpers.js"),classes=require("./classes.js"),parse=require("html-react-parser"),system=require("@gem-sdk/system"),styles=require("./styles.js"),translate=require("../../../settings/collection-paginator/configs/translate.js");const renderPaginatorItem=({setting:e,builderProps:t,pageContext:s},a)=>"liquid"===a?renderPaginatorLive({setting:e,builderProps:t,pageContext:s}):renderPaginatorEditor({setting:e,builderProps:t,pageContext:s}),renderPaginatorLive=({setting:e,builderProps:t,pageContext:s})=>{let a=getPreviousTextVal({setting:e,builderProps:t,pageContext:s},"liquid"),r=getNextTextVal({setting:e,builderProps:t,pageContext:s},"liquid"),l=e?.numberOfProducts||s?.numberOfProductOfProductList||0,i=l>0?l:4,o=e=>e?.replace(/"/g,'\\"')??"",c=`"${o(a??"")}"`,n=`"${o(r??"")}"`;return`
    {% paginate collection.products by ${i} %}
      {% assign previousText = ${s?.isPreviewing?c:a||'""'} %}
      {% assign nextText = ${s?.isPreviewing?n:r||'""'} %}

      {{ paginate | default_pagination: previous: previousText, next: nextText }}
    {% endpaginate %}
  `},renderPaginatorEditor=({setting:e,builderProps:t,pageContext:s})=>{let{pageQuantity:a,typo:r,normalColor:l,activeColor:i}=e??{},o=[],c=parseInt(a??"0"),n=6;6>c&&(n=c-1);let m=n>1?n-1:0,u=getPreviousTextVal({setting:e,builderProps:t,pageContext:s},"react"),g=getNextTextVal({setting:e,builderProps:t,pageContext:s},"react"),y=system.createClass({...classes.customClass("prev",l,e)}),p=system.createClass({...classes.customClass("page",l,e)}),d=system.createClass({...classes.customClass("deco",l,e)}),x=t=>system.createClass({...classes.customClass("page",t===m?i:l,e)}),C=system.createClass({...classes.customClass("deco",l,e)}),P=system.createClass({...classes.customClass("page",l,e)}),S=system.createClass({...classes.customClass("next",l,e)}),h=t=>system.createStyle({...styles.getPaginatorStyle(t===m,styles.getCustomStyle(e),i)}),v=system.createStyle({...styles.getCustomStyle(e),...core.makeStyle({w:"auto"})}),I=system.createStyle({...styles.getCustomStyle(e)}),q=system.createStyle({...styles.getCustomStyle(e),...core.makeStyle({w:"auto"})});m>0&&o.push(createPaginatorItem({key:"prev",text:r?.attrs?.transform==="capitalize"?u?.toLocaleLowerCase():u,className:y,style:v})),m>2&&o.push(createPaginatorItem({key:1,text:1,className:p,style:I})),m>3&&o.push(createPaginatorItem({key:"deco",text:"...",className:d,style:I}));for(let e=Math.max(0,m-2);e<=Math.min(m+2,c-1);e++)o.push(createPaginatorItem({key:e+1,text:e+1,className:x(e),style:h(e)}));return m<c-4&&o.push(createPaginatorItem({key:"deco-2",text:"...",className:C,style:I})),m<c-3&&o.push(createPaginatorItem({key:c,text:c,className:P,style:I})),m!==c-1&&0!==c&&o.push(createPaginatorItem({key:"next",text:r?.attrs?.transform==="capitalize"?g?.toLocaleLowerCase():g,className:S,style:q})),o.map(e=>parse(e))},createPaginatorItem=({key:e,text:t,className:s,style:a})=>core.template`<span key="${e}" className="${s}" style="${a}"> ${t} </span>`,getPreviousTextVal=({setting:e,builderProps:t,pageContext:s},a)=>{let{previousText:r,typo:l}=e??{};return"liquid"===a?helpers.getDynamicSourceLocales({val:r,uid:t?.uid,settingId:helpers.createSettingId({id:translate.CollectionPaginator?.previousText?.id}),pageContext:s??{},isLiquid:!0,isCapitalize:l?.attrs?.transform==="capitalize"}).toString():r},getNextTextVal=({setting:e,builderProps:t,pageContext:s},a)=>{let{nextText:r,typo:l}=e??{};return"liquid"===a?helpers.getDynamicSourceLocales({val:r,uid:t?.uid,settingId:helpers.createSettingId({id:translate.CollectionPaginator?.nextText?.id}),pageContext:s??{},isLiquid:!0,isCapitalize:l?.attrs?.transform==="capitalize"}).toString():r};exports.renderPaginatorItem=renderPaginatorItem;
