define(['jquery','mage/translate'],function($,$t){'use strict';const toolbarAmount=function(){const getContainer=function(){const toolbar=$('.columns .main .toolbar.toolbar-products').first();return toolbar.find('#toolbar-amount.toolbar-amount');};const getElements=function(){return getContainer().find('.toolbar-number');};const isString=value=>typeof value==='string'||value instanceof String;const getNumber=(text)=>{if(!isString(text)){return 0;}
const a2e=s=>s.replace(/[٠-٩]/g,d=>'٠١٢٣٤٥٦٧٨٩'.indexOf(d));text=a2e(text);return parseInt(text);};return{getLength:function(){return $('.main .products li.item.product.product-item').length;},getStart:function(){const elements=getElements();if(elements.length<2){return 1;}
return getNumber($(elements.get(0)).text());},getEnd:function(){const elements=getElements();const index=elements.length>1?1:0;return getNumber($(elements.get(index)).text());},getTotal:function(){const elements=getElements();const index=elements.length>1?2:0;return getNumber($(elements.get(index)).text());},getPaggerLimit:function(){const toolbar=$('.columns .main .toolbar.toolbar-products').last();return getNumber(toolbar.find('.limiter #limiter').last().val());},getStartPageNumber:function(){return Math.ceil(this.getStart()/ this.getPaggerLimit());},getEndPageNumber:function(){return Math.ceil(this.getEnd()/ this.getPaggerLimit());},setEnd:function(value){$(getElements()[1]).text(value);return this;},refresh:function(){const elements=getElements();if(elements.length!==3){return;}
const length=this.getLength();if(typeof elements[1]!=='undefined'){this.setEnd(this.getStart()+length-1);}
const total=this.getTotal();if(typeof elements[2]!=='undefined'&&length===total){getContainer().html($t('%d Items').replace('%d','<span class="toolbar-number">'+total+'</span>'));}}}}();$(document).on('swissup:ajaxlayerednavigation:reload:after',function(event,{navigation}){if(!navigation.config.isMoreProductsButton&&!navigation.config.isInfiniteScroll){return;}
toolbarAmount.refresh();});if($.breezemap){$.breezemap['Swissup_Ajaxlayerednavigation/js/navigation/toolbar/toolbar-amount']=toolbarAmount;}
return toolbarAmount;});