window.i18njs&&(i18n.t("label_official_shops--TW"),i18n.t("label_official_shops--ID"),i18n.t("label_official_shops--MY"),i18n.t("label_official_shops--PH"),i18n.t("label_official_shops--TH"),i18n.t("label_official_shops--VN"),i18n.t("label_official_shops--SG"));var OfficialShopController=function(){var s,r,f,c,d,p,u,h,m,b,w,v,g,I,A,y,C,S,O,B,N,L,P,x,T,E,k,D,R,F=_.template("OFFICIAL_SHOP_BASE64_<%= cat_id %>"),Y=_.template("OFFICIAL_SHOP_BASE64_WITH_RANGE_<%= limit %>_<%= offset %>_<%= cat_id %>");function G(){g.init(function(e,i){window.BI_ANALYTICS&&BI_ANALYTICS.trackOfficialShopImpressions({shop_infos:i,catid:window.catid,page_type:window.PAGE_TYPE,tab_index:window.tabIndexForBI})},"position"),g.addBatchItem(new ScrollBatchItem(document.querySelector(".official-shop-container"),".official-shop-item",H))}function H(e){"function"==typeof jQuery&&e instanceof jQuery&&(e=e[0]);var i=parseInt(e.getAttribute("data-shopposition"));return isNaN(i)?{}:_.find(b,function(e){return e.position===i})}return{init:function(e){f="home/category/official_shop_item_djangofy.html",c="ratio_4_3_box",d=12,p=4,m="row",b=[],w=[],v=r=s=null,g&&g.destroy(),g=new TrackScrollController,I=2,y=!(A=1),S=!(C={cat_id:null}),O=$(".official-shop-container"),B=$(".official-shop-section"),P=L=N=null,x=i18n.t("label_see_all"),E=null,k=T=!1,D=0,R=$.Deferred().resolve();var i=$(".official-shop-selling-points"),a=i.width()+26,t=i.children().length,o=!0;i.css("display","-webkit-box");for(var n=0;n<2*t;n++){var l=$(".selling-point").map(function(e,i){return $(i).outerWidth(!0)}).toArray().reduce(function(e,i){return e+i},0);a<l-3&&(o||$(".selling-point:last-child").remove(),i.toggleClass("official-shop-selling-points--compact",o),o=!o)}if(i.css("display",""),i.removeClass("visibility-hidden"),e&&(e.display_type&&(m=e.display_type),e.callbackFunc&&(v=e.callbackFunc),e.maxNumberOfRow&&(I=e.maxNumberOfRow),e.minNumberOfRow&&(A=e.minNumberOfRow),e.maxNumberOfItemPerRow&&(d=e.maxNumberOfItemPerRow),e.minNumberOfItemPerRow&&(p=e.minNumberOfItemPerRow),e.reverseOrder&&(S=e.reverseOrder),e.$container&&(O=e.$container),e.$section&&(B=e.$section),e.searchParams&&_.extend(C,e.searchParams),e.seeAllCallback&&(N=e.seeAllCallback),e.wrapperCallback&&(L=e.wrapperCallback),e.seeAllText&&(x=e.seeAllText),e.mastHaveSeeAllItem&&(T=e.mastHaveSeeAllItem),e.toLandingPageOnly&&(k=e.toLandingPageOnly),e.initPosition&&(D=e.initPosition),e.trackingDfd&&(R=e.trackingDfd)),u=I*d,h=A*p,e=$.Deferred(),C)return bridgeInit(function(){var e;e=$.Deferred(),s=$("#official-shop-items").text(),r=$("#official-shop-item").text(),e.resolve();var a,t=$.Deferred();function o(e){var i;b=e.items,E=e.tab_index,b&&(S&&b.reverse(),b.forEach(function(e,i){e.position=i}),w=function(e){var i=[];if("full"==m)i=[e];else{var a,t=e.slice(0,u),o=Math.max(Math.ceil(t.length/d),A);if("full"!=m&&e.length>u&&(y=!0),(y=T?!0:y)&&(t.length==u?((a=t.pop()).is_see_all=!0,a.brand_label=ServerConstants.BrandLabel.None,t.push(a)):t.push({is_see_all:!0})),"compact"==m)for(var n=(o-t.length%o)%o,l=0;l<n;l++)t.push({is_empty_item:!0});for(l=0;l<o;l++){var s=_.select(t,function(e,i){return i%o==l});i.push(s)}e.length<h&&(i=[])}return i}(b),e=$.Deferred(),$.isEmptyObject(w)?B.addClass("hide"):((i={})[f]=r,i=new BJDjangofy(s,{template_subs:i}).render({item_rows:w,ITEM_IMAGE_BASE_URL:ITEM_IMAGE_BASE_URL,ratio_class:c,modifier_cls:m,seeAllText:x,LOCALE:LOCALE,BrandLabel:ServerConstants.BrandLabel}),O.empty().append($(i)),O.removeClass(function(e,i){return(i.match(/(^|\s)row-\S+/g)||[]).join(" ")}).addClass("row-"+w.length).addClass("official-shop-container--"+m),null!=D&&0==E&&setTimeout(function(){O.find(".official-shop-items").scrollLeft(D)},20),B.removeClass("hide"),__ios_didAddOverflow__(),i=O.find(".official-shop-items"),__android_getSwipeables__(i,!0)),e.resolve(),i=O.find(".official-shop-item:not(.official-shop-item--see-all)"),k?i.off().on("tap",function(){N(B,C)}):BJUtil.listenShop(i),i.on("tap",function(e){var i=H($(this));window.BI_ANALYTICS&&window.BI_ANALYTICS.trackOfficialShopClick({shopInfo:i,catid:window.catid,page_type:window.PAGE_TYPE,tab_index:window.tabIndexForBI})}),y?(B.find(".official-shop-header .see-all").removeClass("hide"),B.find(".official-shop-header, .official-shop-item--see-all").off().on("tap",function(e){var i=$(this),e=(N&&(e.stopPropagation(),e.preventDefault(),N(B,C,E)),{catid:window.catid,page_type:window.PAGE_TYPE,tab_index:window.tabIndexForBI,type:"link"});i.hasClass("official-shop-item--see-all")&&(e.type="button"),window.BI_ANALYTICS&&window.BI_ANALYTICS.officialShopClickSeeMore(e)})):B.find(".official-shop-header .see-all").addClass("hide"),L&&B.find(".official-shop-selling-points-wrapper").off().on("tap",function(e){e.stopPropagation(),e.preventDefault(),L()}),loadDelayedBackgroundImages(O.find(".official-shop-items")),runFuncAfterDeferedResolve(G,R)(),v&&v(),t.resolve())}a=(null==C.limit||null==C.offset?F:Y)(C),bridgeCallHandler("load",{key:a,persist:1},function(e){var i="";e.data&&(o(e=JSON.parse(Base64.decode(e.data))),i=e.version);P=getJSON("/official-shop/api/",C,function(e){bridgeInit(function(){bridgeCallHandler("save",{key:a,persist:1,data:Base64.encode(JSON.stringify(e))},null)}),i!=e.version&&o(e)})})}),e.resolve(),e.promise()},destroy:function(){P&&P.abort(),g&&g.destroy()}}},asyncGetBrandListTabs=function(l){return getJSON("/api/v2/content/brand_list_tabs",function(e){if(e&&e.data&&e.data.items)for(var i=e.data.items,a=0;a<i.length;a++){var t=i[a],o={},n={catid:t.catid,catname:t.display_name};o.name=t.display_name,o.url=generateGetUri(location.origin+"/mall/brands/"+t.catid+"/",n),o.catid=t.catid,l.push(o)}})};
//# sourceMappingURL=../../../source_maps/home/category/official_shop_controller.js.map
