<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">define(['jquery','underscore','Magento_Ui/js/modal/alert','mage/translate','contactUsChat'],function($,_,alertModal,$t,contactUsChat){'use strict';return function(widget){$.widget('mage.compareCategoryItems',widget,{compareList:'.compare-list',compareMobileTabs:'.compare-mobile-title',compareTitleActive:'.compare-title-active',compareActiveTabs:'.category-compare-tabs .data.title.active',_triggerHeader:function(selector){var self=this;if(!isHomePage&amp;&amp;$(window).width()&lt;768){$('.category-compare-list').css('bottom',$('.product-info-tabs-div').height());}else{$('.category-compare-list').css('bottom',0);}
$(selector).off().on('click',function(e){e.preventDefault();if(!isHomePage){self.categoryUrlKey=categoryUrlKey;}
$(e.currentTarget).hasClass(self.switchClass)?$(e.currentTarget).removeClass(self.switchClass):$(e.currentTarget).addClass(self.switchClass);if($('.enable-new-contact').length){let scrollTop=$(window).scrollTop();contactUsChat().adjustSwitchPosition(scrollTop);}
if($(self.compareMobileTabs).length){$(self.compareMobileTabs).hasClass(self.switchClass)?$(self.compareMobileTabs).removeClass(self.switchClass):$(self.compareMobileTabs).addClass(self.switchClass);}
self._removeAllItems(self.options.clearAllSelector);});},_setItemWidth:function(compareActiveTabs){var self=this,itemWidth=$(compareActiveTabs).next('.data.content').find('li').width();$(self.compareList).find('li.empty').height(itemWidth);$(self.compareList).find('li.item').height(itemWidth);},_removeItem:function(selector){var self=this;$(selector).off().on('click',function(e){e.preventDefault();self._closeCompareMessage();var request=$(e.currentTarget).data('post'),formKey=$('input[name="form_key"]').val();var element=$(e.currentTarget);if(request.action&amp;&amp;request.data){$.ajaxSetup({showLoader:true});request.data['category_url_key']=categoryUrlKey;request.data['product_category_url_key']=element.data('category-url-key');request.data['form_key']=formKey;request.data['isAjax']=true;$.post(request.action,request.data).done(function(response){if(response.status==='success'){}});return false;}
return false;});},_showAlertModal:function(title,response){if($('body').hasClass('smartfinder-index-index')){alertModal({title:title,content:response.message,actions:{always:function(){}}});}else{if(typeof response.maximum!=='undefined'){let message=(window.innerWidth&lt;768)?$t("MAXIMUM NUMBER OF ITEMS"):$t("YOU REACHED THE MAXIMUM NUMBER OF PRODUCTS TO COMPARE");let sub=(window.innerWidth&lt;768)?$t("Remove one of the items below to add a different one"):$t("You can remove one of the products below and add a different one");$('.category-compare-list &gt; .compare-message').removeClass('hide').find('.title').text(message).append('&lt;span class="sub"&gt;'+sub+'&lt;/span&gt;');}else{$('.category-compare-list &gt; .compare-message').removeClass('hide').find('.title').text(response.message)}
setTimeout(function(){$('.category-compare-list &gt; .compare-message').addClass('hide');},60000);}
return false;},_activatedCurrentTab:function(){var self=this;$("[id='"+this._getCurrentTabId()+"']").trigger('click');$(self.compareTitleActive).text($('.category-compare-tabs').find('.data.title.active span.name').text());},_closeCompareMessage:function(){$('.category-compare-list &gt; .compare-message').addClass('hide');},_getCurrentTabIdForMb:function(selector){var self=this;$(document).on('click',selector+' li',function(){$(self.compareTitleActive).text($(this).find('span.name').text());$(selector).find('.compare-title-active').attr('aria-selected',false);$(selector).find('ul').attr('aria-selected',true).hide();$('.compare-box').find('.data.title').eq($(this).attr('list-index')).trigger('click');})},_addToCompare:function(selector){if(selector){var self=this;$(selector).off().on('click',function(e){e.preventDefault();self.categoryUrlKey=$(e.currentTarget).data('category-url-key');self.currentTabId=self._getCurrentTabId();self.currentTabTitleId=self._getCurrentTabTitleId();self.currentTabContentId=self._getCurrentTabContentId();self._activatedCurrentTab();self._closeCompareMessage();var request=$(e.currentTarget).data('post'),productId=$(e.currentTarget).data('product-id'),formKey=$('input[name="form_key"]').val(),compareHeaderElement=$(self.options.headerSelector);if(request.action&amp;&amp;request.data){$.ajaxSetup({showLoader:true});request.data['category_url_key']=categoryUrlKey;request.data['product_category_url_key']=self.categoryUrlKey;request.data['form_key']=formKey;request.data['isAjax']=true;$.post(request.action,request.data).done(function(response){if(!compareHeaderElement.hasClass('active')){compareHeaderElement.trigger('click');}
if(response.status!=='success'){$(e.currentTarget).blur();self._showAlertModal(self.options.errorAlertTitle,response);}});return false;}
return false;});}},_removeAllItems:function(selector){var self=this;$(selector).off().on('click',function(e){e.preventDefault();var urlKey=$(e.currentTarget).data('category-url-key');var tabContentId=self._getCurrentTabContentId(urlKey);var request=$(e.currentTarget).data('post'),formKey=$('input[name="form_key"]').val();var currentActivatedCompareUl=$(e.currentTarget).parent().parent('li.compare-action').parent();var products='';var productIds=self._getProductIds(currentActivatedCompareUl);if(productIds){products=productIds.join(',');}
if(request.action&amp;&amp;request.data&amp;&amp;products){$.ajaxSetup({showLoader:true});request.data['form_key']=formKey;request.data['isAjax']=true;request.data['products']=products;$.post(request.action,request.data).done(function(response){if(response.status==='success'){}});}
return false;});},});return $.mage.compareCategoryItems;}});</pre></body></html>