{"version":3,"sources":["components/product/detail/images/_std/product-detail-images.js"],"names":["tagsNames","ProductDetailImages","Component","constructor","el","mainSwiperEl","$find","thumbsSwiperEl","dicountLabels","$findAll","mainSwiper","thumbsSwiper","mainSwiperConfig","slidesPerView","navigation","nextEl","prevEl","lazy","loadPrevNext","elementClass","watchOverflow","tags","forEach","name","init","constructMainSwiper","Swiper","constructThumbSwiper","spaceBetween","freeMode","watchSlidesVisibility","watchSlidesProgress","breakpoints","thumbs","swiper","goToVariantImage","id","slideIndex","Array","from","slides","findIndex","slide","dataset","variant","slideTo","updateTags","classList","add","tag","remove","updateVariantDiscountLabel","label","discountedVariant","onVariantChanged","EventBus","getInstance","addEventListener","e","detail"],"mappings":"aAAA,KAAMA,CAAAA,SAAS,CAAG,CAAC,gBAAD,CAAmB,YAAnB,CAAiC,QAAjC,CAA2C,SAA3C,CAAsD,SAAtD,CAAiE,WAAjE,CAA8E,oBAA9E,CAAoG,iBAApG,CAAlB,CACA,KAAMC,CAAAA,mBAAN,QAAkCC,CAAAA,SAAU,CAC3CC,WAAW,CAACC,EAAD,CAAK,CACf,MAAMA,EAAN,EACA,KAAKC,YAAL,CAAoB,KAAKC,KAAL,CAAW,oBAAX,CAApB,CACA,KAAKC,cAAL,CAAsB,KAAKD,KAAL,CAAW,qBAAX,CAAtB,CACA,KAAKE,aAAL,CAAqB,KAAKC,QAAL,CAAc,2BAAd,CAArB,CACA,KAAKC,UAAL,CAAkB,IAAlB,CACA,KAAKC,YAAL,CAAoB,IAApB,CACA,KAAKC,gBAAL,CAAwB,CACvBC,aAAa,CAAE,CADQ,CAEvBC,UAAU,CAAE,CACXC,MAAM,CAAE,2BADG,CAEXC,MAAM,CAAE,2BAFG,CAFW,CAMvBC,IAAI,CAAE,CACLC,YAAY,CAAE,IADT,CAELC,YAAY,CAAE,MAFT,CANiB,CAUvBC,aAAa,CAAE,IAVQ,CAAxB,CAYA,KAAKC,IAAL,CAAY,EAAZ,CACArB,SAAS,CAACsB,OAAV,CA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AJ,OAAO,CAACvB,IAAR,CAAaC,OAAb,CAAqB2B,GAAG,EAAI,CAC1B,GAAI,KAAK5B,IAAL,CAAU4B,GAAV,CAAJ,CAAoB,CACnB,KAAK5B,IAAL,CAAU4B,GAAV,EAAeF,SAAf,CAAyBG,MAAzB,CAAgC,UAAhC,CACA,CACD,CAJF,CAMA,CAEDC,0BAA0B,CAAC,CAACf,EAAD,CAAD,CAAO,CAChC,KAAK5B,aAAL,CAAmBc,OAAnB,CAA2B8B,KAAK,EAAI,CACnCA,KAAK,CAACL,SAAN,CAAgB,CAACK,KAAK,CAACT,OAAN,CAAcU,iBAAf,GAAqC,CAACjB,EAAtC,CAA2C,QAA3C,CAAsD,KAAtE,EAA6E,UAA7E,CACA,CAFD,CAGA,CAEDkB,gBAAgB,CAACV,OAAD,CAAU,CACzB,KAAKE,UAAL,CAAgBF,OAAhB,EACA,KAAKT,gBAAL,CAAsBS,OAAtB,EACA,KAAKO,0BAAL,CAAgCP,OAAhC,CACA,CAEDpB,IAAI,EAAG,CACN,KAAKjB,cAAL,EAAuB,KAAKoB,oBAAL,EAAvB,CACA,KAAKtB,YAAL,EAAqB,KAAKoB,mBAAL,EAArB,CACA8B,QAAQ,CAACC,WAAT,GAAuBC,gBAAvB,CAAwC,uBAAxC,CAAiEC,CAAC,EAAI,KAAKJ,gBAAL,CAAsBI,CAAC,CAACC,MAAxB,CAAtE,CACA,CApF0C","sourcesContent":["const tagsNames = ['tagRecommended', 'discounted', 'tagNew', 'tagSale', 'tagUsed', 'tagAction', 'tagFreeStorePickup', 'tagFreeDelivery'];\r\nclass ProductDetailImages extends Component {\r\n\tconstructor(el) {\r\n\t\tsuper(el);\r\n\t\tthis.mainSwiperEl = this.$find('[data-swiper-main]');\r\n\t\tthis.thumbsSwiperEl = this.$find('[data-swiper-thumb]');\r\n\t\tthis.dicountLabels = this.$findAll('[data-discounted-variant]');\r\n\t\tthis.mainSwiper = null;\r\n\t\tthis.thumbsSwiper = null;\r\n\t\tthis.mainSwiperConfig = {\r\n\t\t\tslidesPerView: 1,\r\n\t\t\tnavigation: {\r\n\t\t\t\tnextEl: '.ProductDetailImages-next',\r\n\t\t\t\tprevEl: '.ProductDetailImages-prev'\r\n\t\t\t},\r\n\t\t\tlazy: {\r\n\t\t\t\tloadPrevNext: true,\r\n\t\t\t\telementClass: 'lazy'\r\n\t\t\t},\r\n\t\t\twatchOverflow: true\r\n\t\t};\r\n\t\tthis.tags = {};\r\n\t\ttagsNames.forEach(name => {\r\n\t\t\tthis.tags[name] = this.$find('.is-' + name);\r\n\t\t});\r\n\t\tthis.init();\r\n\t}\r\n\r\n\tconstructMainSwiper() {\r\n\t\tthis.mainSwiper = new Swiper(this.mainSwiperEl, this.mainSwiperConfig);\r\n\t}\r\n\r\n\tconstructThumbSwiper() {\r\n\t\tthis.thumbsSwiper = new Swiper(this.thumbsSwiperEl, {\r\n\t\t\tspaceBetween: 10,\r\n\t\t\tslidesPerView: 3,\r\n\t\t\tfreeMode: true,\r\n\t\t\twatchSlidesVisibility: true,\r\n\t\t\twatchSlidesProgress: true,\r\n\t\t\tbreakpoints: {\r\n\t\t\t\t500: {\r\n\t\t\t\t\tslidesPerView: 4,\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\t\tthis.mainSwiperConfig.thumbs = {\r\n\t\t\tswiper: this.thumbsSwiper\r\n\t\t}\r\n\t}\r\n\r\n\tgoToVariantImage({id}) {\r\n\t\tconst slideIndex = Array.from(this.mainSwiper.slides).findIndex(slide => +slide.dataset.variant === +id);\r\n\t\tthis.mainSwiper.slideTo(slideIndex === -1 ? 0 : slideIndex);\r\n\t}\r\n\r\n\tupdateTags(variant) {\r\n\t\ttagsNames.forEach(name => {\r\n\t\t\tif (this.tags[name]) {\r\n\t\t\t\tthis.tags[name].classList.add('u-hidden');\r\n\t\t\t}\r\n\t\t});\r\n\t\tvariant.tags.forEach(tag => {\r\n\t\t\t\tif (this.tags[tag]) {\r\n\t\t\t\t\tthis.tags[tag].classList.remove('u-hidden');\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t);\r\n\t}\r\n\r\n\tupdateVariantDiscountLabel({id}) {\r\n\t\tthis.dicountLabels.forEach(label => {\r\n\t\t\tlabel.classList[+label.dataset.discountedVariant === +id ? 'remove' : 'add']('u-hidden');\r\n\t\t});\r\n\t}\r\n\r\n\tonVariantChanged(variant) {\r\n\t\tthis.updateTags(variant);\r\n\t\tthis.goToVariantImage(variant);\r\n\t\tthis.updateVariantDiscountLabel(variant);\r\n\t}\r\n\r\n\tinit() {\r\n\t\tthis.thumbsSwiperEl && this.constructThumbSwiper();\r\n\t\tthis.mainSwiperEl && this.constructMainSwiper();\r\n\t\tEventBus.getInstance().addEventListener('productVariantChanged', e => this.onVariantChanged(e.detail));\r\n\t}\r\n}\r\n"],"file":"product-detail-images.min.js"}