PageSourceSearch

https://www.hktvmall.com/_ui/uilibrary/yui/cache/2ff763001813d380215148fa83c5b7e4.js?1790204624128

js hktvmall.com collected 2026-09-24 08:44:26 UTC 59,992 bytes, 1 lines download raw bytes

1var __assign=(this&&this.__assign)||Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++){s=arguments[i];for(var p in s){if(Object.prototype.hasOwnProperty.call(s,p)){t[p]=s[p];}}}return t;};var AlgoliaSearchAdapter=(function(){function AlgoliaSearchAdapter(){}AlgoliaSearchAdapter.isMainlandSkuExposureEnabled=function(){return !!(hktvCommon.env&&hktvCommon.env.enableMainlandSkuExposure);};AlgoliaSearchAdapter.getNowDateHour=function(){var currentDate=new Date(Date.now());var dd=currentDate.getDate()<10?"0"+currentDate.getDate().toString():currentDate.getDate().toString();var hh=currentDate.getHours()<10?"0"+currentDate.getHours().toString():currentDate.getHours().toString();return dd+hh;};AlgoliaSearchAdapter.parseCategoryFacetKey=function(key){try{return JSON.parse(key);}catch(error){var message_1=error&&error.message?error.message:error;console.warn("Algolia category facet JSON parse error",key.substring(0,120),message_1);return null;}};AlgoliaSearchAdapter.sendRequest=function(searchJson){var sortIndex="hktvProduct";if(searchJson["sort"]){sortIndex=searchJson["sort"];}var queries=[{indexName:sortIndex,query:searchJson.keyword||"",params:{filters:this.constructSearchFiltersString(searchJson),facets:[],attributesToRetrieve:["*"],page:searchJson.page||0,hitsPerPage:(searchJson.productsPerPage?searchJson.productsPerPage:0),maxValuesPerFacet:this.maxValuesPerFacet}}];return algoliaClient.search(queries);};AlgoliaSearchAdapter.sendSuggestRequest=function(keyword){var _this=this;var lKeyword=keyword||"";var sortIndex="hktvProduct";var storeIndex="hktvBusinessDirectory";var keywordSuggestionIndex="hktvProduct_query_suggestions";var suggestionQueries=[{indexName:sortIndex,query:lKeyword,params:{filters:"",facets:["categoryStructureLevel1Display"],attributesToRetrieve:["*"],hitsPerPage:1,maxValuesPerFacet:this.maxValuesPerSuggestCategory1Facet}},{indexName:storeIndex,query:lKeyword,params:{optionalFilters:["affiliateWord.name:"+lKeyword],facetingAfterDistinct:true,attributesToHighlight:[],attributesToRetrieve:["*"],hitsPerPage:8}}];if(lKeyword!=""){var productSearchKeyword=lKeyword.replace(/\"/g,'\\"');suggestionQueries.push({indexName:sortIndex,query:"",params:{filters:'allProductSearchCode:"'+productSearchKeyword+'"',facets:[""],attributesToRetrieve:["*"],hitsPerPage:this.hitsPerPage,maxValuesPerFacet:this.maxValuesPerFacet}});suggestionQueries.push({indexName:keywordSuggestionIndex,query:lKeyword,params:{filters:"",facets:[""],attributesToRetrieve:["*"],hitsPerPage:4,maxValuesPerFacet:this.maxValuesPerFacet}});}return algoliaClient.search(suggestionQueries).then(function(onFulfilled){return _this.parseSuggestionResponse(onFulfilled);}).caught(function(){return{"keyword":"","categoryDepth1s":[],"stores":[],"products":[],"suggestKeywords":[]};});};AlgoliaSearchAdapter.addPromotionBannerSearch=function(categoryCode,searchQueries){searchQueries.push({indexName:"hktvPromotionBanners",query:"",params:{filters:"category:"+categoryCode,facets:[],attributesToRetrieve:["*"],page:0,hitsPerPage:1,maxValuesPerFacet:this.maxValuesPerFacet}});};AlgoliaSearchAdapter.addMainlandSKUSearch=function(searchQueries,sortIndex,keyword,filterString,pageNo){if(!this.isMainlandSkuExposureEnabled()){return;}if(hktvCommon.env&&hktvCommon.env.hideMainlandProducts){return;}if(pageNo<3){var mainlandFilter=filterString.length>0?filterString+" AND ":"";mainlandFilter+="isMainlandSamePrice: true ";searchQueries.push({indexName:sortIndex,query:keyword,params:{filters:mainlandFilter,facets:["isMainlandSamePrice"],attributesToRetrieve:["*"],page:0,hitsPerPage:this.hitsPerPage*3,maxValuesPerFacet:this.maxValuesPerFacet,facetingAfterDistinct:true,userToken:hktvCommon.env.advertisingKey||ALGOLIA_INSIGHTS_TOKEN||"",clickAnalytics:true}});}};AlgoliaSearchAdapter.addPriorSKUSearch=function(searchJson,withPriorSKUSearch,searchQueries,thirdPartyLogisticIndex,keyword,filterString,pageNo,mabsData){if(searchJson.priorSKUListSearchSize>0){var hitsPerPage=searchJson.priorSKUListSearchSize?searchJson.priorSKUListSearchSize:this.hitsPerPage;var priorFilter=filterString.length>0?filterString+" AND ":"";priorFilter+="isPriorSKU: true ";if(mabsData){priorFilter+="AND NOT";var index=1;for(var key in mabsData){if(index<Object.keys(mabsData).length){priorFilter+=" objectID:"+mabsData[key].objectId+" AND NOT";}else{priorFilter+=" objectID:"+mabsData[key].objectId;}index++;}}searchQueries.push({indexName:thirdPartyLogisticIndex,query:keyword,params:{filters:priorFilter,facets:["isPriorSKU"],attributesToRetrieve:["*"],page:pageNo,hitsPerPage:hitsPerPage,maxValuesPerFacet:this.maxValuesPerFacet,facetingAfterDistinct:true,userToken:hktvCommon.env.advertisingKey||ALGOLIA_INSIGHTS_TOKEN||"",clickAnalytics:true}});var thirdPartyFilter=filterString.length>0?filterString+" AND ":"";thirdPartyFilter+="isThirdPartyLogisticsWarehouse: true ";searchQueries.push({indexName:thirdPartyLogisticIndex,query:keyword,params:{filters:thirdPartyFilter,facets:["isThirdPartyLogisticsWarehouse"],attributesToRetrieve:["*"],page:pageNo,hitsPerPage:hitsPerPage,maxValuesPerFacet:this.maxValuesPerFacet,facetingAfterDistinct:true,userToken:hktvCommon.env.advertisingKey||ALGOLIA_INSIGHTS_TOKEN||"",clickAnalytics:true}});}};AlgoliaSearchAdapter.primCatForPromotionBanner=function(normalProduct,mabsData){var categoryCounts={};for(var _i=0,normalProduct_1=normalProduct;_i<normalProduct_1.length;_i++){var product=normalProduct_1[_i];var hasInvalidPrice=product.priceList.some(function(price){return price.value<=0;});if(!hasInvalidPrice){var categoryCode=product.primaryCatCode?product.primaryCatCode.slice(0,6):null;if(!mabsData||(mabsData&&!mabsData[product.objectID])&&categoryCode){categoryCounts[categoryCode]=(categoryCounts[categoryCode]||0)+1;}}}var mostCommonCategory="";var highestCount=0;
1for(var category in categoryCounts){if(categoryCounts[category]>highestCount){mostCommonCategory=category;highestCount=categoryCounts[category];}}return mostCommonCategory?mostCommonCategory+"0000000":"";};AlgoliaSearchAdapter.sendSearchRequest=function(searchJson){var _this=this;var keyword=searchJson.keyword||"";var sortIndex="hktvProduct";if(searchJson["sort"]){sortIndex=searchJson["sort"];}var filterString=this.constructSearchFiltersString(searchJson);var exposureOn=this.isMainlandSkuExposureEnabled();var pageNo=exposureOn?0:(searchJson.page||0);if(exposureOn&&searchJson.page!=null&&searchJson.page>=3){pageNo=searchJson.page;}var pageSize=exposureOn&&pageNo<3?this.hitsPerPage*3:this.hitsPerPage;var searchQueries=new Array();var withProductIdSearch=false;var withPurchasedListSearch=false;var withPriorSKUSearch=false;var recentlyViewIndex="";var purchasedIndex="";var thirdPartyLogisticIndex="";if(indices){for(var i in indices){if(indices[i].indice==="recentlyViewedIndices"){recentlyViewIndex=indices[i].indexName;}else{if(indices[i].indice==="purchasedIndices"){purchasedIndex=indices[i].indexName;}else{if(indices[i].indice==="thirdPartyLogisticIndices"){thirdPartyLogisticIndex=indices[i].indexName;}}}}}searchQueries.push({indexName:sortIndex,query:keyword,params:{filters:filterString,facets:["*"],attributesToRetrieve:["*"],page:pageNo,hitsPerPage:pageSize,maxValuesPerFacet:this.maxValuesPerFacet,facetingAfterDistinct:true,userToken:hktvCommon.env.advertisingKey||ALGOLIA_INSIGHTS_TOKEN||"",clickAnalytics:true}});if(Array.isArray(searchJson.productIdList)&&searchJson.productIdList.length>0&&recentlyViewIndex){withProductIdSearch=true;searchQueries.push({indexName:recentlyViewIndex,query:keyword,params:{filters:this.constructSearchFiltersString(searchJson,null,true),facets:[],attributesToRetrieve:["*"],page:0,hitsPerPage:(searchJson.productIdSearchSize?searchJson.productIdSearchSize:this.hitsPerRecentSearch),maxValuesPerFacet:this.maxValuesPerFacet,facetingAfterDistinct:true,userToken:hktvCommon.env.advertisingKey||ALGOLIA_INSIGHTS_TOKEN||"",clickAnalytics:true}});}if(Array.isArray(searchJson.purchasedList)&&searchJson.purchasedList.length>0&&purchasedIndex){withPurchasedListSearch=true;searchQueries.push({indexName:purchasedIndex,query:keyword,params:{filters:this.constructSearchFiltersString(searchJson,null,false,true),facets:[],attributesToRetrieve:["*"],page:0,hitsPerPage:(searchJson.purchasedListSearchSize?searchJson.purchasedListSearchSize:this.hitsPerPurchasedListSearch),maxValuesPerFacet:this.maxValuesPerFacet,facetingAfterDistinct:true,userToken:hktvCommon.env.advertisingKey||ALGOLIA_INSIGHTS_TOKEN||"",clickAnalytics:true}});}if(this.constructSearchFiltersString(searchJson,"category").length>0){var escapeFacets={"brand":searchJson.brand||[],"countryOfOrigin":searchJson.countryOfOrigin||[],"color":searchJson.color||[],"deliverableRegion":searchJson.deliverableRegion||[],"price":searchJson.price||""};for(var key in escapeFacets){if(searchJson[key]&&searchJson[key].length>0){searchQueries.push({indexName:sortIndex,query:keyword,params:{filters:this.constructSearchFiltersString(searchJson,key),facets:["brandDisplay","countryOfOriginDisplay","colorDisplay","deliverableRegions.deliverableRegionDisplay","sellingPriceRange"],attributesToRetrieve:["*"],hitsPerPage:1,maxValuesPerFacet:this.maxValuesPerFacet}});}}}if(searchJson.category){var category=searchJson.category;this.addPromotionBannerSearch(category,searchQueries);}else{var requestBody=[{indexName:sortIndex,query:keyword,params:{filters:filterString,facets:["categoryStructureLevel1Display"],attributesToRetrieve:["*"],hitsPerPage:1,maxValuesPerFacet:this.maxValuesPerFacet}},{indexName:sortIndex,query:keyword,params:{filters:ValueUtils.getWetmarketSearchFilterExpression(),facets:[],attributesToRetrieve:["*"],page:0,hitsPerPage:3,maxValuesPerFacet:this.maxValuesPerFacet}}];return algoliaClient.search(requestBody).then(function(onFulfilled){var self=_this;var facets=null,catLevel1Displays=null;if(onFulfilled.results.length>0){facets=onFulfilled.results[0].facets;catLevel1Displays=facets.categoryStructureLevel1Display||{};}var catLevel1FurtherSearch=[];for(var key in catLevel1Displays){var catLevel1Display=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!catLevel1Display){continue;}var catLevel0="",catLevel1="";if(catLevel1Display.length>=2){catLevel0=catLevel1Display[0].code||"";catLevel1=catLevel1Display[1].code||"";}var count=catLevel1Display[key];if(!catLevel1FurtherSearch[catLevel0]){catLevel1FurtherSearch[catLevel0]={"code":catLevel1,"count":count};}else{if(count>catLevel1FurtherSearch[catLevel0].count){catLevel1FurtherSearch[catLevel0]={"code":catLevel1,"count":count};}}}for(var key in catLevel1FurtherSearch){searchQueries.push({indexName:sortIndex,query:keyword,params:{filters:"category:"+catLevel1FurtherSearch[key].code+(filterString.length>0?" AND "+filterString:""),facets:["categoryStructureDisplay"],attributesToRetrieve:["*"],hitsPerPage:1,maxValuesPerFacet:self.maxValuesPerFacet}});}var mabsData=onFulfilled.results[0].userData&&onFulfilled.results[0].userData[0].mabsData?onFulfilled.results[0].userData[0].mabsData:null;if(onFulfilled.results[1].hits&&onFulfilled.results[1].hits.length>0){var primCatForPromotionBanner=self.primCatForPromotionBanner(onFulfilled.results[1].hits,mabsData)||"";if(primCatForPromotionBanner&&primCatForPromotionBanner!=""){self.addPromotionBannerSearch(primCatForPromotionBanner,searchQueries);hktvCommon.updateLastSeenCategory(primCatForPromotionBanner);}}if(searchJson.bannerCategory){var bannerCategory=searchJson.bannerCategory;self.addPromotionBannerSearch(bannerCategory,searchQueries);}AlgoliaSearchAdapter.addMainlandSKUSearch(searchQueries,sortIndex,keyword,filterString,pageNo);if(searchJson.priorSKUListSearchSize>0&&thirdPartyLogisticIndex&&typeof thirdPartyLogisticIndex!=="undefined"){withPriorSKUSearch=true;AlgoliaSearchAdapter.addPriorSKUSearch(searchJson,withPriorSKUSearch,searchQueries,thirdPartyLogisticIndex,keyword,filterString,pageNo,mabsData);}return algoliaClient.search(searchQueries);}).then(function(onFulfilled){if(withProductIdSearch){onFulfilled=__assign({},onFulfilled,{withProductIdSearch:withProductIdSearch});}if(withPurchasedListSearch){onFulfilled=__assign({},onFulfilled,{withPurchasedListSearch:withPurchasedListSearch});}if(withPriorSKUSearch){onFulfilled=__assign({},onFulfilled,{withPriorSKUSearch:withPriorSKUSearch});}return _this.parseSearchResponse(onFulfilled,searchJson);});}if(this.isZoneCategory(searchJson.category)){return algoliaClient.search([{indexName:sortIndex,query:keyword,params:{filters:filterString,facets:["categoryStructureLevel1Display"],attributesToRetrieve:["*"],hitsPerPage:1,maxValuesPerFacet:this.maxValuesPerFacet}}]).then(function(onFulfilled){var facets=null,catLevel1Displays=null,searchFilters=null;if(onFulfilled.results.length>0){facets=onFulfilled.results[0].facets;catLevel1Displays=facets.categoryStructureLevel1Display||{};searchFilters=_this.decodeAlgoliaParamsFilter(onFulfilled.results[0].params);}var searchFilterCategory=searchFilters.category||"";var catLevel1FurtherSearch={};for(var key in catLevel1Displays){var catLevel1Display=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!catLevel1Display){continue;}var catLevel0="",catLevel1="";if(catLevel1Display.length>=2){catLevel0=catLevel1Display[0].code||"";catLevel1=catLevel1Display[1].code||"";}var count=catLevel1Display[key];if(catLevel0==searchFilters.category){if(!catLevel1FurtherSearch.code){catLevel1FurtherSearch={"code":catLevel1,"count":count};}else{if(count>catLevel1FurtherSearch.count){catLevel1FurtherSearch={"code":catLevel1,"count":count};}}}}searchQueries.push({indexName:sortIndex,query:keyword,params:{filters:"category:"+catLevel1FurtherSearch.code+(_this.constructSearchFiltersString(searchJson,"category").length>0?" AND "+_this.constructSearchFiltersString(searchJson,"category"):""),facets:["categoryStructureDisplay"],attributesToRetrieve:["*"],hitsPerPage:1,maxValuesPerFacet:_this.maxValuesPerFacet}});var mabsData=onFulfilled.results[0].userData&&onFulfilled.results[0].userData[0].mabsData?onFulfilled.results[0].userData[0].mabsData:null;AlgoliaSearchAdapter.addMainlandSKUSearch(searchQueries,sortIndex,keyword,filterString,pageNo);if(searchJson.priorSKUListSearchSize>0){withPriorSKUSearch=true;AlgoliaSearchAdapter.addPriorSKUSearch(searchJson,withPriorSKUSearch,searchQueries,thirdPartyLogisticIndex,keyword,filterString,pageNo,mabsData);}return algoliaClient.search(searchQueries);}).then(function(onFulfilled){if(withProductIdSearch){onFulfilled=__assign({},onFulfilled,{withProductIdSearch:withProductIdSearch});}if(withPurchasedListSearch){onFulfilled=__assign({},onFulfilled,{withPurchasedListSearch:withPurchasedListSearch});}if(withPriorSKUSearch){onFulfilled=__assign({},onFulfilled,{withPriorSKUSearch:withPriorSKUSearch});}return _this.parseSearchResponse(onFulfilled,searchJson);});}AlgoliaSearchAdapter.addMainlandSKUSearch(searchQueries,sortIndex,keyword,filterString,pageNo);if(searchJson.priorSKUListSearchSize>0&&thirdPartyLogisticIndex){withPriorSKUSearch=true;AlgoliaSearchAdapter.addPriorSKUSearch(searchJson,withPriorSKUSearch,searchQueries,thirdPartyLogisticIndex,keyword,filterString,pageNo);}return algoliaClient.search(searchQueries).then(function(onFulfilled){if(withProductIdSearch){onFulfilled=__assign({},onFulfilled,{withProductIdSearch:withProductIdSearch});}if(withPurchasedListSearch){onFulfilled=__assign({},onFulfilled,{withPurchasedListSearch:withPurchasedListSearch});}if(withPriorSKUSearch){onFulfilled=__assign({},onFulfilled,{withPriorSKUSearch:withPriorSKUSearch});}return _this.parseSearchResponse(onFulfilled,searchJson);});};AlgoliaSearchAdapter.parseSuggestionResponse=function(responseData){var keyword;var suggestCategories=new Array();var suggestStores=new Array();var suggestProducts=new Array();var suggestKeywords=new Array();if(!responseData.results){return{"keyword":"","categoryDepth1s":[],"stores":[],"products":[],"suggestKeywords":[]};}var suggestCategoriesReponse=responseData.results[0]||{};var suggestStoresReponse=responseData.results[1]||{};var suggestProductsReponse=responseData.results[2]||{};var suggestKeywordsReponse=responseData.results[3]||{};var suggestCategoriesFacet=suggestCategoriesReponse.facets||{};keyword=suggestCategoriesReponse.query||"";for(var key in suggestCategoriesFacet.categoryStructureLevel1Display){var catLevel1Display=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!catLevel1Display){continue;}var catLevel0=catLevel1Display[0].code;var catLevel1=catLevel1Display[1].code;var count=suggestCategoriesFacet.categoryStructureLevel1Display[key]||0;suggestCategories.push({"parentCode":catLevel0||"","code":catLevel1||"","nameZh":decodeURIComponent(catLevel1Display[1].nameZh)||"","nameEn":decodeURIComponent(catLevel1Display[1].nameEn)||"","count":count});}for(var key in suggestStoresReponse.hits){var hit=suggestStoresReponse.hits[key];var links=hit.links||[];var primaryLink=links.find(function(l){return l.type==="hktvmall";})||links[0];if(!primaryLink){continue;}suggestStores.push({"code":primaryLink.storeCode||hit.objectID||"","nameZh":hit.nameZh||"","nameEn":hit.nameEn||"","imageUrl":hit.logo||hit.squareLogo||"","linkZh":primaryLink.urlZh||"","linkEn":primaryLink.urlEn||""});}for(var key in suggestProductsReponse.hits){suggestProducts.push({"code":suggestProductsReponse.hits[key].code||"","nameZh":decodeURIComponent(suggestProductsReponse.hits[key].nameZh)||"","nameEn":decodeURIComponent(suggestProductsReponse.hits[key].nameEn)||""});}suggestKeywords=suggestKeywordsReponse.hits.filter(function(hit){return hit.query!==keyword;}).slice(0,3).map(function(hit){return{code:hit.query};});return{"keyword":keyword,"categoryDepth1s":suggestCategories,"stores":suggestStores,"products":suggestProducts,"suggestKeywords":suggestKeywords};};AlgoliaSearchAdapter.getMabsRefId=function(objectId,mabsData){return(objectId in mabsData?(mabsData[objectId].mabsRefId||""):"");};AlgoliaSearchAdapter.getMabsAdPosition=function(objectId,mabsData){return(objectId in mabsData?(mabsData[objectId].position||""):"");};AlgoliaSearchAdapter.parseProductResponse=function(product,queryID,mabsData,additionalLabel,additionalLabelForPurchasedList,
1sourceId,isPriorSKU){return{"code":product.code,"objectID":product.objectID,"queryID":queryID,"baseProduct":product.baseProduct,"primaryCatCode":product.primaryCatCode,"nameZh":product.nameZh,"nameEn":product.nameEn,"nameZhCN":product.nameZhCN,"brand":product.brand,"brandEn":product.brandEn,"brandZh":product.brandZh,"brandZhCN":product.brandZhCN,"descriptionEn":product.descriptionEn,"descriptionZh":product.descriptionZh,"descriptionZhCN":product.descriptionZhCN,"storeCode":product.storeCode,"storeCodeOrig":product.storeCodeOriginal,"storeNameEn":product.storeNameEn,"storeNameZh":product.storeNameZh,"storeNameZhCN":product.storeNameZhCN,"storeType":product.storeType,"storeTypeDisplayEn":product.storeTypeDisplayEn,"storeTypeDisplayZh":product.storeTypeDisplayZh,"storeTypeDisplayZhCN":product.storeTypeDisplayZhCN,"storeRating":product.storeRating,"averageRating":product.averageRating,"numberOfReviews":product.numberOfReviews,"thresholdPromotionEn":product.thresholdPromotionEn,"thresholdPromotionZh":product.thresholdPromotionZh,"thresholdPromotionZhCN":product.thresholdPromotionZhCN,"multiCategoryPromotionEn":product.multiCategoryPromotionEn,"multiCategoryPromotionZh":product.multiCategoryPromotionZh,"multiCategoryPromotionZhCN":product.multiCategoryPromotionZhCN,"buyMoreSaveMoreEn":product.buyMoreSaveMoreEn,"buyMoreSaveMoreZh":product.buyMoreSaveMoreZh,"buyMoreSaveMoreZhCN":product.buyMoreSaveMoreZhCN,"perfectPartnerPromotionEn":product.perfectPartnerPromotionEn,"perfectPartnerPromotionZh":product.perfectPartnerPromotionZh,"perfectPartnerPromotionZhCN":product.perfectPartnerPromotionZhCN,"bundlePromotionEn":product.bundlePromotionEn,"bundlePromotionZh":product.bundlePromotionZh,"bundlePromotionZhCN":product.bundlePromotionZhCN,"promotionStyle":product.promotionStyle,"promotionTextEn":product.promotionTextEn,"promotionTextZh":product.promotionTextZh,"promotionTextZhCN":product.promotionTextZhCN,"priceList":product.priceList,"mainlandPriceList":product.mainlandPriceList,"savedPrice":product.savedPrice,"priceUpdatedDate":product.priceUpdatedDate,"images":product.images,"videos":product.videos,"labels":product.labels,"stock":product.stock,"hasStock":product.hasStock,"hasVariantInStock":product.hasVariantInStock,"invisible":product.invisible,"isPrimaryVariant":product.isPrimaryVariant,"numberOfVariants":product.numberOfVariants,"purchaseOption":product.purchaseOption,"packingSpecEn":product.packingSpecEn,"packingSpecZh":product.packingSpecZh,"packingSpecZhCN":product.packingSpecZhCN,"urlEn":product.urlEn,"urlZh":product.urlZh,"urlZhCN":product.urlZhCN,"deliveryLabelCode":product.deliveryLabelCode,"deliveryLabelScheduleCode":product.deliveryLabelScheduleCode,"deliverableRegions":product.deliverableRegion,"salesNumberStringZh":product.salesNumberStringZh,"salesNumberStringEn":product.salesNumberStringEn,"salesNumberStringZhCN":product.salesNumberStringZhCN,"mabsRefId":this.getMabsRefId(product.objectID,mabsData),"mabsAdPosition":this.getMabsAdPosition(product.objectID,mabsData),"marketingLabelUids":product.marketingLabelUids,"additionalLabel":additionalLabel||"","inStorePickUpCheckoutLink":product.inStorePickUpCheckoutLink,"externalAffiliateRedirectLink":product.externalAffiliateRedirectLink||"","displayStoreSquareLogoUrl":product.displayStoreSquareLogoUrl||"","officialWebsiteAffiliateUrl":product.officialWebsiteAffiliateUrl||"","additionalLabelForPurchasedList":additionalLabelForPurchasedList||"","sourceId":sourceId||"","overseasRegionCodes":product.overseasRegionCodes,"isThirdPartyLogisticsWarehouse":product.isThirdPartyLogisticsWarehouse?"is3PLProduct":"","isPriorSKU":product.isPriorSKU?"isPriorSKU":"","pickLabelUids":product.pickLabelUids||[],"eCoinsRebateSchedule":product.eCoinsRebateSchedule||[],"isMainlandSamePrice":product.isMainlandSamePrice,"warehouseStateZh":product.warehouseStateZh,"warehouseStateEn":product.warehouseStateEn,"warehouseStateZhCN":product.warehouseStateZhCN,"warehouseCityZh":product.warehouseCityZh,"warehouseCityEn":product.warehouseCityEn,"warehouseCityZhCN":product.warehouseCityZhCN,"deliveryModeCode":product.deliveryModeCode,"isGreenLab":product.isGreenLab,"expiryDate":product.expiryDate,"expiryDateTs":product.expiryDateTs,"kaPriceList":product.kaPriceList,"serviceDealOption":product.
1serviceDealOption||{},"isExpressDeliverableSku":product.isExpressDeliverableSku,"isMerchantWetmarketWarehouse":product.isMerchantWetmarketWarehouse,"wetmarketCodeList":product.wetmarketCodeList||[]};};AlgoliaSearchAdapter.filterOOSProducts=function(productsResponseData){return productsResponseData.filter(function(el){var numberOfVariants=el.numberOfVariants,purchaseOption=el.purchaseOption,stockLevelStatus=el.stock.stockLevelStatus;var code;if(numberOfVariants>1){return purchaseOption!=1&&purchaseOption!=2;}else{if(stockLevelStatus){code=stockLevelStatus.code;}}return code!=="stockNotifiable"&&code!=="outOfStock";});};AlgoliaSearchAdapter.isAvailablePinnedProduct=function(product){return product.storeClosedStatus!==1&&AlgoliaSearchAdapter.filterOOSProducts([product]).length>0;};AlgoliaSearchAdapter.filterSubCat2Products=function(productsResponseData,cat2SkuMap){return productsResponseData.filter(function(el){if(el.primaryCatCode){var subCat2=el.primaryCatCode.substring(0,8);return cat2SkuMap[subCat2];}return false;});};AlgoliaSearchAdapter.parseSearchResponse=function(responseData,searchJson){var _this=this;var sourceId=searchJson&&searchJson.sourceId||"";var searchFilters={};var productsResponseData;var responseDataBatches;var recentProductsResponseData=[];var purchasedProductsResponseData=[];var priorProductsResponseData=[];var thirdPartyLogisticResponseData=[];var mainlandProductsResponseData=[];var productsUserData=[];var mabsData={};var keyword="";var queryID="";var products_recent=new Array();var products_purchased=new Array();var products_mabs=new Array();var products_prior=new Array();var products_3PL=new Array();var products_mainland=new Array();var products_orig=new Array();var products=new Array();var pagination;var catgoryTree;var filterBreadcrumb=new Array();var facetCategoryDepth0s=new Array();var facetCategoryDepth1s=new Array();var facetCategoryLeaves=new Array();var facetBrand=new Array();var facetCountryOfOrigin=new Array();var facetColor=new Array();var facetDeliverableRegion=new Array();var facetPrice=new Array();var promotionBanner=this.parsePromotionBanner({});var keywordBanner=this.parseKeywordBanner({});var userData;var facetDeliverySchedules={};var exactTimeDeliverySchedules=new Array();var facetMainlandProducts=new Array();var facetStoreType={};var productsByPage={};var productsByPageIsMainlandSamePrice={};var results=responseData.results;var pageNo=Number(searchJson.page)||0;var exposureOn=this.isMainlandSkuExposureEnabled();var len=results.length;function getHits(index){if(index!==null&&index<len&&results[index]&&results[index].hits){return results[index].hits;}return[];}var resultIndexMap={MAIN:0,recent:responseData.withProductIdSearch?1:null,purchased:null,prior:null,thirdParty:null,mainland:null};if(responseData.withPurchasedListSearch){if(responseData.withProductIdSearch){resultIndexMap.purchased=2;}else{resultIndexMap.purchased=1;}}if(responseData.withPriorSKUSearch){resultIndexMap.thirdParty=len-1;resultIndexMap.prior=len-2;}if(exposureOn&&pageNo<3){resultIndexMap.mainland=responseData.withPriorSKUSearch?len-3:len-1;}productsResponseData=getHits(resultIndexMap.MAIN);recentProductsResponseData=getHits(resultIndexMap.recent);purchasedProductsResponseData=getHits(resultIndexMap.purchased);priorProductsResponseData=getHits(resultIndexMap.prior);thirdPartyLogisticResponseData=getHits(resultIndexMap.thirdParty);mainlandProductsResponseData=getHits(resultIndexMap.mainland);if(responseData.results){keyword=responseData.results[resultIndexMap.MAIN].query||"";queryID=responseData.results[resultIndexMap.MAIN].queryID||"";searchFilters=this.decodeAlgoliaParamsFilter(responseData.results[resultIndexMap.MAIN].params);responseDataBatches=responseData.results||[];productsUserData=responseData.results[resultIndexMap.MAIN].userData||[];userData=productsUserData;if(productsUserData.length>0){productsUserData.forEach(function(el){if(typeof(el)==="object"&&"mabsData" in el){var rawMabsData=el["mabsData"];for(var key in rawMabsData){if(rawMabsData[key].mabsRefId!==undefined){mabsData[key]=__assign({},rawMabsData[key]);}}}});}var totalProductCount=responseData.results[resultIndexMap.MAIN].nbHits;var totalPageNo=this.hitsPerPage>0?Math.ceil(totalProductCount/this.hitsPerPage):0;pagination={"totalProductCount":totalProductCount,"totalPageNo":totalPageNo,"pageNo":pageNo||0,"productPerPage":this.hitsPerPage||0};}else{productsResponseData=[];responseDataBatches=[];pagination={"totalProductCount":0,"totalPageNo":0,"pageNo":0,"productPerPage":0};}var mabsSkuMap=[];var cat2SkuMap={};var unavailablePinnedProductObjectIDs={};for(var _i=0,_a=productsResponseData.slice(0,20);_i<_a.length;_i++){var product=_a[_i];if(product.primaryCatCode){var subCat2=product.primaryCatCode.substring(0,8);cat2SkuMap[subCat2]=true;}}for(var _b=0,productsResponseData_1=productsResponseData;_b<productsResponseData_1.length;_b++){var product=productsResponseData_1[_b];var parsedProduct=this.parseProductResponse(product,queryID,mabsData);if(parsedProduct.mabsAdPosition&&results[resultIndexMap.MAIN].page==0){if(AlgoliaSearchAdapter.isAvailablePinnedProduct(product)){products_mabs.push(parsedProduct);mabsSkuMap.push(parseInt(parsedProduct.mabsAdPosition));}else{if(parsedProduct.objectID){unavailablePinnedProductObjectIDs[parsedProduct.objectID]=true;}}}}var recentLabel=searchResultMessage?searchResultMessage.recentLabel:"";recentProductsResponseData=this.filterSubCat2Products(recentProductsResponseData,cat2SkuMap);purchasedProductsResponseData=this.filterSubCat2Products(purchasedProductsResponseData,cat2SkuMap);priorProductsResponseData=this.filterSubCat2Products(priorProductsResponseData,cat2SkuMap);thirdPartyLogisticResponseData=this.filterSubCat2Products(thirdPartyLogisticResponseData,cat2SkuMap);mainlandProductsResponseData=this.filterSubCat2Products(mainlandProductsResponseData,cat2SkuMap);
1products_recent.push.apply(products_recent,this.filterOOSProducts(recentProductsResponseData).map(function(product){return _this.parseProductResponse(product,queryID,mabsData,recentLabel);}));products_purchased.push.apply(products_purchased,this.filterOOSProducts(purchasedProductsResponseData).map(function(product){return _this.parseProductResponse(product,queryID,mabsData,"",recentLabel,sourceId);}));products_prior.push.apply(products_prior,this.filterOOSProducts(priorProductsResponseData).map(function(product){return _this.parseProductResponse(product,queryID,mabsData,"","","",true);}));products_3PL.push.apply(products_3PL,this.filterOOSProducts(thirdPartyLogisticResponseData).map(function(product){return _this.parseProductResponse(product,queryID,mabsData,"","","",true);}));products_orig.push.apply(products_orig,productsResponseData.filter(function(product){return !unavailablePinnedProductObjectIDs[product.objectID];}).map(function(product){return _this.parseProductResponse(product,queryID,mabsData);}));products_mainland.push.apply(products_mainland,this.filterOOSProducts(mainlandProductsResponseData).map(function(product){return _this.parseProductResponse(product,queryID,mabsData,"","","",true);}));var recentNpurchased=products_purchased?products_purchased.length:0;if(recentNpurchased<2&&products_recent.length>0){recentNpurchased+=(recentNpurchased<1)?products_recent.length:1;}var threePartyLogisticCount=products_3PL&&pageNo==0?Math.min(products_3PL.length,4):0;var priorSKUCount=products_prior&&pageNo==0?Math.min(products_prior.length,4):0;var mabsSKUCount=products_mabs&&pageNo==0?products_mabs.length:0;var origSKUCount=products_orig?Math.min(products_orig.length,60):0;var count=mabsSKUCount+origSKUCount+recentNpurchased+priorSKUCount+threePartyLogisticCount;var recentMainlandSeen=products_recent.filter(function(product){return product.isMainlandSamePrice;});var purchasedMainlandSeen=products_purchased.filter(function(product){return product.isMainlandSamePrice;});var priorMainlandCountSeen=products_prior.slice(0,4).filter(function(product){return product.isMainlandSamePrice;});var threePLMainlandCountSeen=products_3PL.slice(0,4).filter(function(product){return product.isMainlandSamePrice;});var mabsMainlandSeen=products_mabs.filter(function(product){return product.isMainlandSamePrice;});var specialSkuMainlandSeen=new Array();specialSkuMainlandSeen=specialSkuMainlandSeen.concat(recentMainlandSeen,purchasedMainlandSeen,priorMainlandCountSeen,threePLMainlandCountSeen,mabsMainlandSeen);var allSpecialSkuCodes={};products_recent.forEach(function(p){return allSpecialSkuCodes[p.code]=true;});products_purchased.forEach(function(p){return allSpecialSkuCodes[p.code]=true;});products_prior.slice(0,4).forEach(function(p){return allSpecialSkuCodes[p.code]=true;});products_3PL.slice(0,4).forEach(function(p){return allSpecialSkuCodes[p.code]=true;});products_mabs.forEach(function(p){return allSpecialSkuCodes[p.code]=true;});if(exposureOn&&pageNo<3){var origProductPagination={0:products_orig.slice(0,this.hitsPerPage).length>=this.hitsPerPage?this.hitsPerPage:products_orig.length,1:products_orig.slice(this.hitsPerPage,this.hitsPerPage*2).length>=this.hitsPerPage?this.hitsPerPage:products_orig.length>=this.hitsPerPage*2?this.hitsPerPage:Math.max(0,products_orig.length-this.hitsPerPage),2:products_orig.slice(this.hitsPerPage*2,this.hitsPerPage*3).length>=this.hitsPerPage?this.hitsPerPage:products_orig.length>=this.hitsPerPage*3?this.hitsPerPage:Math.max(0,products_orig.length-this.hitsPerPage*2)};var mainlandProductByPage={0:[],1:[],2:[]};var mainlandPoolIndex=0;var usedMainlandSkuCodes={};var borrowedMainlandSkuCodesByPage={0:{},1:{},2:{}};var origProductByPage={0:products_orig.slice(0,origProductPagination[0]),1:products_orig.slice(origProductPagination[0],origProductPagination[0]+origProductPagination[1]),2:products_orig.slice(origProductPagination[0]+origProductPagination[1],origProductPagination[0]+origProductPagination[1]+origProductPagination[2])};var allBorrowedMainlandSkuCodes_1={};var shownSkuCodesAcrossPages_1={};for(var code in allSpecialSkuCodes){if(allSpecialSkuCodes.hasOwnProperty(code)){shownSkuCodesAcrossPages_1[code]=true;}}var _loop_1=function(page){var origPagePool=origProductByPage[page];origPagePool=origPagePool.filter(function(product){return !shownSkuCodesAcrossPages_1[product.code];});if(page>0){origPagePool=origPagePool.filter(function(product){return !allBorrowedMainlandSkuCodes_1[product.code];});}var origMainlandInPage=origPagePool.filter(function(product){return product.isMainlandSamePrice&&!allSpecialSkuCodes[product.code];});var mainlandNeeded=Math.max(0,this_1.numberOfMainlandExposure-origMainlandInPage.length);var origPageSkuCodes={};origPagePool.forEach(function(p){return origPageSkuCodes[p.code]=true;});var mainlandForPage=[];while(mainlandForPage.length<mainlandNeeded&&mainlandPoolIndex<products_mainland.length){var candidate=products_mainland[mainlandPoolIndex];mainlandPoolIndex++;
1if(allSpecialSkuCodes[candidate.code]){continue;}if(shownSkuCodesAcrossPages_1[candidate.code]){continue;}if(origPageSkuCodes[candidate.code]){continue;}if(!usedMainlandSkuCodes[candidate.code]){mainlandForPage.push(candidate);usedMainlandSkuCodes[candidate.code]=true;borrowedMainlandSkuCodesByPage[page][candidate.code]=true;allBorrowedMainlandSkuCodes_1[candidate.code]=true;}}origPagePool.forEach(function(p){return shownSkuCodesAcrossPages_1[p.code]=true;});mainlandForPage.forEach(function(p){return shownSkuCodesAcrossPages_1[p.code]=true;});mainlandProductByPage[page]=mainlandForPage;origProductByPage[page]=origPagePool;};var this_1=this;for(var page=0;page<3;page++){_loop_1(page);}products_orig=origProductByPage[pageNo];products_mainland=mainlandProductByPage[pageNo];}if(pageNo!=0){count=count-mabsSKUCount-recentNpurchased-priorSKUCount-threePartyLogisticCount;products_recent=[];products_purchased=[];products_prior=[];products_3PL=[];products_mabs=[];}pagination.totalProductCount+=recentNpurchased+priorSKUCount+threePartyLogisticCount;var numOfDuplicated=0;if(count<=0){$('meta[name="robots"]').attr("content","noindex,nofollow");}if(mabsSkuMap&&products_mabs.length>0){for(var pos in mabsSkuMap){products[mabsSkuMap[pos]-1]=products_mabs.shift();}}for(var i=0;i<count;i++){var popProduct=void 0;var isDuplicated;if(products_purchased.length>0){isDuplicated=products.filter(function(product){return product.code==products_purchased[0].code;});if(isDuplicated.length==0||typeof isDuplicated==="undefined"){if(typeof products[i]=="undefined"){popProduct=products_purchased.shift();recentNpurchased--;}}else{products_purchased.shift();++numOfDuplicated;recentNpurchased--;i--;continue;}}else{if(products_recent.length>0&&recentNpurchased>0){isDuplicated=products.filter(function(product){return product.code==products_recent[0].code;});if(isDuplicated.length==0||typeof isDuplicated==="undefined"){if(typeof products[i]=="undefined"){popProduct=products_recent.shift();recentNpurchased--;}}else{products_recent.shift();recentNpurchased--;++numOfDuplicated;i--;continue;}}else{if(products_3PL.length>0&&threePartyLogisticCount>0){isDuplicated=products.filter(function(product){return product.code==products_3PL[0].code;});if(isDuplicated.length==0||typeof isDuplicated==="undefined"){if(typeof products[i]=="undefined"){popProduct=products_3PL.shift();threePartyLogisticCount--;}}else{products_3PL.shift();++numOfDuplicated;i--;continue;}}else{if(products_prior.length>0&&priorSKUCount>0){isDuplicated=products.filter(function(product){return product.code==products_prior[0].code;});if(isDuplicated.length==0||typeof isDuplicated==="undefined"){if(typeof products[i]=="undefined"){popProduct=products_prior.shift();priorSKUCount--;}}else{products_prior.shift();++numOfDuplicated;i--;continue;}}else{if((i==count-1)&&products_mainland.length>0){isDuplicated=products.filter(function(product){return product.code==products_mainland[0].code;});if(isDuplicated.length==0||typeof isDuplicated==="undefined"){if(typeof products[i]=="undefined"){popProduct=products_mainland.shift();if(products_mainland.length>0){count++;}}}else{products_mainland.shift();++numOfDuplicated;i--;continue;}}else{if(products_orig.length>0){isDuplicated=products.filter(function(product){return product.code==products_orig[0].code;});if(isDuplicated.length==0||typeof isDuplicated==="undefined"){if(typeof products[i]=="undefined"){popProduct=products_orig.shift();}}else{products_orig.shift();++numOfDuplicated;i--;continue;}}}}}}}if(typeof popProduct!=="undefined"&&typeof products[i]=="undefined"){products[i]=popProduct;}}pagination.totalProductCount-=numOfDuplicated;pagination.totalProductCount=Math.min(pagination.totalProductCount,1000);pagination.totalPageNo=this.hitsPerPage>0?Math.ceil(pagination.totalProductCount/this.hitsPerPage):0;for(var index in responseDataBatches){var filtersResponse=this.decodeAlgoliaParamsFilter(responseDataBatches[index].params);var facetsResponse=responseDataBatches[index].facets||{};if(index=="0"){if(searchFilters.category&&!this.isZoneCategory(searchFilters.category)){catgoryTree=this.constructCategoryTree(facetsResponse,filtersResponse.category);}else{if(searchFilters.category){catgoryTree=this.constructCategoryTreeRoots(facetsResponse,filtersResponse.category);}else{catgoryTree=this.constructCategoryTreeRoots(facetsResponse);}}filterBreadcrumb=this.getCategoryBreadcrumbFromTree(catgoryTree);facetBrand=this.getBrandFacetFromResponse(facetsResponse);facetCountryOfOrigin=this.getCountryOfOriginFacetFromResponse(facetsResponse);facetColor=this.getColorFacetFromResponse(facetsResponse);facetDeliverableRegion=this.getDeliverableRegionFacetFromResponse(facetsResponse);facetPrice=this.getPriceFacetFromResponse(facetsResponse);facetDeliverySchedules=this.getFacetDeliverySchedulesResponse(facetsResponse);exactTimeDeliverySchedules=this.getExactTimeDeliverySchedulesResponse(facetsResponse);facetMainlandProducts=this.getMainlandProductsFacetResponse(facetsResponse);if(responseDataBatches[index].index==="hktvProduct"&&responseDataBatches[index].userData&&responseDataBatches[index].userData[0].keywordBannerData){keywordBanner=this.parseKeywordBanner(responseDataBatches[index]);}}else{if(promotionBanner.imageUrl===""&&responseDataBatches[index].index==="hktvPromotionBanners"&&responseDataBatches[index].hits.length>0){promotionBanner=this.parsePromotionBanner(responseDataBatches[index]);}else{if(searchFilters.brand&&!filtersResponse.brand&&facetsResponse.brandDisplay){facetBrand=this.getBrandFacetFromResponse(facetsResponse);}if(searchFilters.countryOfOrigin&&!filtersResponse.countryOfOrigin&&facetsResponse.countryOfOriginDisplay){facetCountryOfOrigin=this.getCountryOfOriginFacetFromResponse(facetsResponse);}if(searchFilters.color&&!filtersResponse.color&&facetsResponse.colorDisplay){facetColor=this.getColorFacetFromResponse(facetsResponse);}if(searchFilters.deliverableRegion&&!filtersResponse.deliverableRegion&&facetsResponse.deliverableRegions.deliverableRegionDisplay){facetDeliverableRegion=this.getDeliverableRegionFacetFromResponse(facetsResponse);}if(searchFilters.sellingPrice&&!filtersResponse.sellingPrice&&facetsResponse.sellingPriceRange){facetPrice=this.getPriceFacetFromResponse(facetsResponse);}if(searchFilters.deliverySchedules&&!filtersResponse.deliverySchedules&&facetsResponse.deliverySchedules){facetDeliverySchedules=this.getFacetDeliverySchedulesResponse(facetsResponse);}if(searchFilters.mainlandProducts&&!filtersResponse.mainlandProducts&&facetsResponse.mainlandProducts){facetMainlandProducts=this.getMainlandProductsFacetResponse(facetsResponse);}}}}return{"products":products,"pagination":pagination,"keyword":keyword,"categoryTree":catgoryTree,"filterBreadcrumb":filterBreadcrumb,"brands":facetBrand,"countryOfOrigins":facetCountryOfOrigin,"colors":facetColor,"deliverableRegions":facetDeliverableRegion,"prices":facetPrice,"promotionBanner":promotionBanner,"keywordBanner":keywordBanner,"userData":userData,"deliverySchedules":facetDeliverySchedules,"exactTimeDeliverySchedules":exactTimeDeliverySchedules,"mainlandProducts":facetMainlandProducts,"storeType":facetStoreType};};AlgoliaSearchAdapter.parsePromotionBanner=function(result){var banner={alt:"",category:"",url:"",imageUrl:"",backgroundColor:"",promoDetails:"",promoTitle:"",tandCLink:"",mabsRefId:""};if(Array.isArray(result.hits)&&result.hits.length>0){var hit=result.hits[0];banner.alt=this.getCurrentLanguageDisplay(hit,"alt")||"";banner.category=hit.category||"";banner.url=this.getCurrentLanguageDisplay(hit,"bannerUrl")||"";banner.imageUrl=this.getCurrentLanguageDisplay(hit,"imageUrlWeb")||"";banner.backgroundColor=hit.backgroundColor||"";banner.promoDetails=this.getCurrentLanguageDisplay(hit,"promoDetails")||"";banner.promoTitle=this.getCurrentLanguageDisplay(hit,"promoTitle")||"";banner.tandCLink=this.getCurrentLanguageDisplay(hit,"tandCLink")||"";banner.mabsRefId=hit.mabsRefId||"";}return banner;};AlgoliaSearchAdapter.parseKeywordBanner=function(result){var banner={alt:"",backgroundColor:"",bannerUrl:"",imageUrlWeb:"",category:"",promoDetails:"",promoTitle:"",tandCLink:"",mabsRefId:""};if(Array.isArray(result.userData)&&result.userData.length>0){var userData=result.userData[0];var hit=userData.keywordBannerData;if(hit){banner.alt=this.getCurrentLanguageDisplay(hit,"alt")||"";banner.backgroundColor=hit.backgroundColor||"";banner.bannerUrl=this.getCurrentLanguageDisplay(hit,"bannerUrl")||"";banner.imageUrlWeb=this.getCurrentLanguageDisplay(hit,"imageUrlWeb")||"";banner.category=hit.category||"";banner.promoDetails=this.getCurrentLanguageDisplay(hit,"promoDetails")||"";banner.promoTitle=this.getCurrentLanguageDisplay(hit,"promoTitle")||"";banner.tandCLink=this.getCurrentLanguageDisplay(hit,"tandCLink")||"";banner.mabsRefId=hit.mabsRefId||"";}}return banner;};AlgoliaSearchAdapter.isZoneCategory=function(categoryCode){var code=categoryCode||"";switch(code){case"supermarket":case"personalcarenhealth":case"beautynhealth":case"mothernbaby":case"pets":case"homenfamily":case"housewares":case"deals":case"sportsntravel":case"toysnbooks":case"fashion":case"disney":case"thirteenlandmarks":case"gadgetsandelectronics":case"finance":return true;default:return false;}};AlgoliaSearchAdapter.getMainCategoryOrder=function(categoryCode){var code=categoryCode||"";switch(code){case"thirteenlandmarks":return 0;case"supermarket":return 1;case"personalcarenhealth":return 2;case"beautynhealth":return 3;case"mothernbaby":return 4;case"pets":return 5;case"gadgetsandelectronics":return 6;case"homenfamily":return 7;case"housewares":return 8;case"deals":return 9;
1case"sportsntravel":return 10;case"toysnbooks":return 11;case"fashion":return 12;case"finance":return 13;default:return 14;}};AlgoliaSearchAdapter.getCategoryBreadcrumbFromTree=function(tree){var breadcrumb=new Array();var depth=tree["filterDepth"]||0;var ptr=tree["categories"];for(var index=0;index<depth;index++){breadcrumb.push({"code":ptr[0]["code"]||"","name":ptr[0]["name"]||""});ptr=ptr[0]["child"];}return breadcrumb;};AlgoliaSearchAdapter.constructCategoryTree=function(facetsResponse,filtersCategory){var treeRef=new Array();var filterDepth=0;var ptr=treeRef;var endPtr;var parentTreeParsed=false;var leafCatList=[];for(var key in facetsResponse.categoryStructureDisplay){var categoryStructureDisplay=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryStructureDisplay){continue;}for(var index in categoryStructureDisplay){if(categoryStructureDisplay[index].code==filtersCategory){if(!parentTreeParsed){filterDepth=parseInt(index)+1;for(var i=0;i<=parseInt(index);i++){ptr.push({"code":categoryStructureDisplay[i].code||"","name":this.getCurrentLanguageDisplay(categoryStructureDisplay[i],"name"),"count":0,"child":new Array()});endPtr=ptr[0];ptr=ptr[0]["child"];}parentTreeParsed=true;}var catleaf=_.last(categoryStructureDisplay);if(catleaf["code"]!=filtersCategory){leafCatList.push({"code":catleaf["code"]||"","name":this.getCurrentLanguageDisplay(catleaf,"name"),"count":facetsResponse.categoryStructureDisplay[key]||0,"child":new Array()});}}}}if(parentTreeParsed){endPtr["child"]=leafCatList;}return{"filterDepth":filterDepth,"categories":treeRef};};AlgoliaSearchAdapter.constructCategoryTreeLeaves=function(treeRef,facetsResponse,filtersCategory){var cat0;var cat1=filtersCategory;if(treeRef["categories"].length==0){return;}for(var key in facetsResponse.categoryStructureDisplay){if(key.indexOf(filtersCategory)>=0){var categoryStructureDisplay=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryStructureDisplay){continue;}cat0=categoryStructureDisplay[0].code;break;}}var cat1Json;for(var index in treeRef["categories"]){if(treeRef["categories"][index].code==cat0){cat1Json=treeRef["categories"][index].child[0];break;}}if(cat1Json){var catLeafList=cat1Json.child;for(var key in facetsResponse.categoryStructureDisplay){var categoryStructureDisplay=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryStructureDisplay){continue;}var catleaf=_.last(categoryStructureDisplay);if(categoryStructureDisplay[1]){if(categoryStructureDisplay[1].code==cat1){catLeafList.push({"code":catleaf["code"]||"","name":this.getCurrentLanguageDisplay(catleaf,"name"),"count":facetsResponse.categoryStructureDisplay[key]||0,"child":new Array()});}}}}};AlgoliaSearchAdapter.constructCategoryTreeRoots=function(facetsResponse,filtersCategory){var _this=this;var treeRef=[];var catArray=new Array();if(filtersCategory){if(this.isZoneCategory(filtersCategory)){for(var key in facetsResponse.categoryStructureLevel0Display){var categoryLevel0=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryLevel0){continue;}if(categoryLevel0[0].code==filtersCategory){treeRef.push({"code":categoryLevel0[0].code||"","name":this.getCurrentLanguageDisplay(categoryLevel0[0],"name"),"count":facetsResponse.categoryStructureLevel0Display[key]||0,"child":new Array()});break;}}for(var key in facetsResponse.categoryStructureLevel1Display){var categoryLevel1=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryLevel1){continue;}if(categoryLevel1[0].code==filtersCategory){treeRef[0].child.push({"code":categoryLevel1[1].code||"","name":this.getCurrentLanguageDisplay(categoryLevel1[1],"name"),"count":facetsResponse.categoryStructureLevel1Display[key]||0,"child":new Array()});}}if(treeRef.length>0){treeRef[0].child.sort(function(a,b){return b.count-a.count;});return{"filterDepth":1,"categories":treeRef};}else{return{"filterDepth":0,"categories":[]};}}else{return{"filterDepth":0,"categories":[]};}}else{for(var key in facetsResponse.categoryStructureLevel0Display){var categoryLevel0=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryLevel0){continue;}
1catArray.push({"code":categoryLevel0[0].code||"","name":this.getCurrentLanguageDisplay(categoryLevel0[0],"name"),"count":facetsResponse.categoryStructureLevel0Display[key]||0,"child":new Array()});}catArray.sort(function(a,b){var priorityA=_this.getMainCategoryOrder(a.code);var priorityB=_this.getMainCategoryOrder(b.code);return priorityA-priorityB;});treeRef=catArray;for(var key in facetsResponse.categoryStructureLevel1Display){var categoryLevel1=AlgoliaSearchAdapter.parseCategoryFacetKey(key);if(!categoryLevel1){continue;}for(var index in treeRef){if(treeRef[index].code==categoryLevel1[0].code){treeRef[index]["child"].push({"code":categoryLevel1[1].code||"","name":this.getCurrentLanguageDisplay(categoryLevel1[1],"name"),"count":facetsResponse.categoryStructureLevel1Display[key]||0,"child":new Array()});}}}for(var index in treeRef){treeRef[index]["child"].sort(function(a,b){return b.count-a.count;});}return{"filterDepth":0,"categories":treeRef};}};AlgoliaSearchAdapter.getBrandFacetFromResponse=function(facetsResponse){var brands=new Array();for(var key in facetsResponse.brandDisplay){try{var brandResponse=JSON.parse(key);var brand={"code":brandResponse.code||"","name":this.getCurrentLanguageDisplay(brandResponse,"name")||"","priority":brandResponse.priority||0,"count":facetsResponse.brandDisplay[key]||0};brands.push(brand);}catch(error){Logger.error("Algolia brand facet","Json parse error");}}brands.sort(function(a,b){if(a.priority==b.priority){return b.count-a.count;}else{return b.priority-a.priority;}});return brands;};AlgoliaSearchAdapter.getCountryOfOriginFacetFromResponse=function(facetsResponse){var countryOfOrigins=new Array();for(var key in facetsResponse.countryOfOriginDisplay){try{var countryOfOriginResponse=JSON.parse(key);var countryOfOrigin={"code":countryOfOriginResponse.code||"","name":this.getCurrentLanguageDisplay(countryOfOriginResponse,"name")||"","count":facetsResponse.countryOfOriginDisplay[key]||0};countryOfOrigins.push(countryOfOrigin);}catch(error){Logger.error("Algolia countryOfOrigin facet","Json parse error");}}return countryOfOrigins;};AlgoliaSearchAdapter.getColorFacetFromResponse=function(facetsResponse){var colors=new Array();for(var key in facetsResponse.colorDisplay){try{var colorResponse=JSON.parse(key);var color={"code":colorResponse.code||"","name":this.getCurrentLanguageDisplay(colorResponse,"name")||"","imageUrl":colorResponse.imageUrl||"","count":facetsResponse.colorDisplay[key]||0};colors.push(color);}catch(error){Logger.error("Algolia color facet","Json parse error");}}return colors;};AlgoliaSearchAdapter.getDeliverableRegionFacetFromResponse=function(facetsResponse){var deliverableRegions=new Array();for(var key in facetsResponse["deliverableRegions.deliverableRegionDisplay"]){try{var deliverableRegionResponse=JSON.parse(key);var deliverableRegion={"code":deliverableRegionResponse.code||"","name":this.getCurrentLanguageDisplay(deliverableRegionResponse,"name")||"","count":facetsResponse["deliverableRegions.deliverableRegionDisplay"][key]||0};deliverableRegions.push(deliverableRegion);}catch(error){Logger.error("Algolia deliverableRegion facet","Json parse error");}}return deliverableRegions;};AlgoliaSearchAdapter.getFacetDeliverySchedulesResponse=function(facetsResponse){var ddhh=AlgoliaSearchAdapter.getNowDateHour();var deliverySchedules=new Array();if(facetsResponse["standardExpressHour"]!=null&&facetsResponse["standardExpressHour"].hasOwnProperty(ddhh)){var deliveryLabel=deliveryLabelExplanations.find(function(deliveryLabel){return deliveryLabel.deliveryMode==="standard-express";});var standardExpressHour={code:"standardExpressHour",name:deliveryLabel.name,count:facetsResponse["standardExpressHour"][ddhh]||0};deliverySchedules.push(standardExpressHour);}var deliveryTimeResponse=facetsResponse["deliveryTime.code"];if(deliveryTimeResponse!=null){var _loop_2=function(deliveryTimeCode){var deliveryLabel=deliveryLabelExplanations.find(function(deliveryLabel){return deliveryLabel.deliveryMode===deliveryTimeCode;});var deliveryTime={code:deliveryTimeCode,name:deliveryLabel.name,count:deliveryTimeResponse[deliveryTimeCode]};deliverySchedules.push(deliveryTime);};for(var deliveryTimeCode in deliveryTimeResponse){_loop_2(deliveryTimeCode);}}return deliverySchedules;};AlgoliaSearchAdapter.getExactTimeDeliverySchedulesResponse=function(facetsResponse){if(!facetsResponse||!Object.prototype.hasOwnProperty.call(facetsResponse,"endEarliestTsList")||!Object.prototype.hasOwnProperty.call(facetsResponse,"endEarliestExpressTsList")||typeof hktvCommon.getExactTimeDeliveryFacetOptions!=="function"){return[];}return hktvCommon.getExactTimeDeliveryFacetOptions(facetsResponse.endEarliestTsList,facetsResponse.endEarliestExpressTsList)||[];};AlgoliaSearchAdapter.getMainlandProductsFacetResponse=function(facetsResponse){var mainlandProducts=new Array();if(facetsResponse["isMainlandSamePrice"]!=null&&facetsResponse["isMainlandSamePrice"]["true"]!=null){var hasMainlandSamePriceText=typeof mainlandSamePriceText!=="undefined"&&mainlandSamePriceText!==null&&mainlandSamePriceText!=="";var isMainlandSamePrice={code:"isMainlandSamePrice",name:hasMainlandSamePriceText?mainlandSamePriceText:"",count:facetsResponse["isMainlandSamePrice"]["true"]||0};mainlandProducts.push(isMainlandSamePrice);}return mainlandProducts;};AlgoliaSearchAdapter.getPriceFacetFromResponse=function(facetsResponse){var prices=new Array();for(var key in facetsResponse.sellingPriceRange){var price={"price":key||"","count":facetsResponse.sellingPriceRange[key]||0};prices.push(price);}prices.sort(function(a,b){if(a.price.indexOf("<")>-1||b.price.indexOf(">")>-1){return -1;}else{if(a.price.indexOf(">")>-1||b.price.indexOf("<")>-1){return 1;}else{return Number(a.price.split("-")[0])-Number(b.price.split("-")[0]);}}});return prices;};AlgoliaSearchAdapter.constructSearchFiltersString=function(searchJson,facetDisabled,useProductIdList,usePurchasedList){var category=searchJson.category||"";var brand=searchJson.brand||[];var countryOfOrigin=searchJson.countryOfOrigin||[];var color=searchJson.color||[];var deliverableRegion=searchJson.deliverableRegion||[];var price=searchJson.price||"";var deliveryTime=searchJson.deliveryTime||[];var endEarliestTsList=searchJson.endEarliestTsList||[];var endEarliestExpressTsList=searchJson.endEarliestExpressTsList||[];var mainlandProducts=searchJson.mainlandProducts||[];var salesChannel=searchJson.salesChannel||[];var storeType=searchJson.storeType||[];var filterString="";var isStringEmpty;if(category!=""&&facetDisabled!="category"){filterString+="category:"+category;}if(useProductIdList&&Array.isArray(searchJson.productIdList)&&searchJson.productIdList.length>0){if(filterString.length>0){filterString+=" AND ";}filterString+="(";searchJson.productIdList.forEach(function(element,index){if(index==0){filterString=filterString+'co
1de:"'+element+'"';}else{filterString=filterString+' OR code:"'+element+'"';}});filterString+=")";}if(usePurchasedList&&Array.isArray(searchJson.purchasedList)&&searchJson.purchasedList.length>0){if(filterString.length>0){filterString+=" AND ";}filterString+="(";searchJson.purchasedList.forEach(function(element,index){if(index==0){filterString=filterString+'code:"'+element+'"';}else{filterString=filterString+' OR code:"'+element+'"';}});filterString+=")";}if(brand.length>0&&facetDisabled!="brand"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in brand){var str='"'+brand[index]+'"';if(index=="0"){filterString+="brand:"+str;}else{filterString+=" OR brand:"+str;}}filterString+=")";}if(countryOfOrigin.length>0&&facetDisabled!="countryOfOrigin"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in countryOfOrigin){var str='"'+countryOfOrigin[index]+'"';if(index=="0"){filterString+="countryOfOrigin:"+str;}else{filterString+=" OR countryOfOrigin:"+str;}}filterString+=")";}if(color.length>0&&facetDisabled!="color"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in color){var str='"'+color[index]+'"';if(index=="0"){filterString+="color:"+str;}else{filterString+=" OR color:"+str;}}filterString+=")";}if(deliverableRegion.length>0&&facetDisabled!="deliverableRegion"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in deliverableRegion){var str='"'+deliverableRegion[index]+'"';if(index=="0"){filterString+="deliverableRegions.deliverableRegion:"+str;}else{filterString+=" OR deliverableRegions.deliverableRegion:"+str;}}filterString+=")";}if(price!=""&&facetDisabled!="price"){if(filterString.length>0){filterString+=" AND ";}if(price.indexOf(">")>-1){filterString+="sellingPrice > "+price.replace(">","");}else{if(price.indexOf("<")>-1){filterString+="sellingPrice < "+price.replace("<","");}else{filterString+="sellingPrice:"+price.split("-")[0]+" TO "+price.split("-")[1];}}}if(deliveryTime.length>0&&facetDisabled!="deliveryTime"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in deliveryTime){var schedule=deliveryTime[index];var scheduleCode=schedule==="standardExpressHour"?"standardExpressHour":"deliveryTime.code";var scheduleValue=schedule==="standardExpressHour"?AlgoliaSearchAdapter.getNowDateHour():schedule;if(index==="0"){filterString+=scheduleCode+":"+scheduleValue;}else{filterString+=" OR "+scheduleCode+":"+scheduleValue;}}filterString+=")";}if(endEarliestTsList.length>0){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in endEarliestTsList){if(index!=="0"){filterString+=" OR ";}filterString+="endEarliestTsList:"+JSON.stringify(endEarliestTsList[index]);}filterString+=")";}if(endEarliestExpressTsList.length>0){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in endEarliestExpressTsList){if(index!=="0"){filterString+=" OR ";}filterString+="endEarliestExpressTsList:"+JSON.stringify(endEarliestExpressTsList[index]);}filterString+=")";}if(mainlandProducts.length>0&&facetDisabled!="mainlandProducts"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in mainlandProducts){var productType=mainlandProducts[index];var productTypeCode=mainlandProducts[index];var productTypeValue=productType==="isMainlandSamePrice";if(index==="0"){filterString+=productTypeCode+":"+productTypeValue;}else{filterString+=" OR "+productTypeCode+":"+productTypeValue;}}filterString+=")";}if(salesChannel.length>0&&facetDisabled!="salesChannel"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in salesChannel){var str='"'+salesChannel[index]+'"';if(index=="0"){filterString+="salesChannel:"+str;}else{filterString+=" OR salesChannel:"+str;}}filterString+=")";}if(storeType.length>0&&facetDisabled!="storeType"){if(filterString.length>0){filterString+=" AND ";}filterString+="(";for(var index in storeType){var str='"'+storeType[index]+'"';if(index=="0"){filterString+="storeType:"+str;}else{filterString+=" OR storeType:"+str;}}filterString+=")";}if(hktvCommon.env&&hktvCommon.env.hideMainlandProducts){if(filterString.length>0){filterString+=" AND ";}filterString+="isMainlandProduct:false";}return ValueUtils.getWetmarketSearchFilterExpression(filterString);};AlgoliaSearchAdapter.decodeAlgoliaParamsFilter=function(params){var paramJson={};if(!params){return paramJson;}var filtersString=JsonUtils.stringToJson(params)["filters"];if(filtersString&&filtersString.length>0){var filters=decodeURIComponent(filtersString).replace(/[()]/g,"").split(/ AND | OR /);for(var key in filters){var type=void 0,value=void 0;if(filters[key].indexOf(":")<0&&filters[key].match(/[<>]/g)){type=filters[key].replace(/ /g,"").split(/[<>]/)[0];var sep=(filters[key].indexOf("<")>-1?"<":">");value=sep+filters[key].replace(/ /g,"").split(/[<>]/)[1];}else{type=filters[key].split(":")[0];value=filters[key].split(":")[1];if(value.match(/ TO /g)){value=value.replace(/ TO /g,"-");}}if(paramJson[type]){if(paramJson[type] instanceof Array){paramJson[type].push(value);}else{paramJson[type]=[paramJson[type],value];}}else{paramJson[type]=value;}}}return paramJson;};AlgoliaSearchAdapter.getCurrentLanguageDisplay=function(langObj,field){var safeDecode=function(v){if(v===undefined||v===null){return"";}try{return decodeURIComponent(v);}catch(error){return"";}};var safeDecodeField=function(suffix){return safeDecode(langObj?langOb
1j[field+suffix]:undefined);};if(hktvCommon.env.currentLanguage==="en"){return safeDecodeField("En")||safeDecodeField("Zh");}else{if(hktvCommon.env.currentLanguage==="zh_CN"){return safeDecodeField("ZhCN")||safeDecodeField("Zh");}else{if(hktvCommon.env.currentLanguage==="zh"){return safeDecodeField("Zh");}}}};return AlgoliaSearchAdapter;}());AlgoliaSearchAdapter.hitsPerPage=60;AlgoliaSearchAdapter.hitsPerRecentSearch=2;AlgoliaSearchAdapter.hitsPerPurchasedListSearch=2;AlgoliaSearchAdapter.maxValuesPerFacet=1000;AlgoliaSearchAdapter.maxValuesPerSuggestCategory1Facet=5;AlgoliaSearchAdapter.numberOfMainlandExposure=6;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.