(function($){Vue.component('product-item',{template:'#vc-component-product-item',props:{flag:{type:Boolean,default:!0,},hasHoverImage:{type:Boolean,default:!1,},index:{default:0,},listName:{type:String,default:null,},product:{type:Object,required:!0,},sizes:{type:Boolean,default:!1,},swatches:{default:10,},wishlist:{type:Boolean,default:!0,},slidertype:{type:String,default:'product',},},data(){return{inWishlist:this.product.stylecolour.inwishlist,selectedSize:'',showAltImage:!1,variant:this.product.stylecolour.variant,}},computed:{styleColour(){return this.product.stylecolour},lowestBaseUnitPrice(){return this.getLowestAmount(this.styleColour.variants,'baseunitprice')},lowestUnitPrice(){return this.getLowestAmount(this.styleColour.variants,'unitprice')},colourSwatches(){if(!this.styleColour.attributes||!this.styleColour.attributes.colourswatches)return[];return this.styleColour.attributes.colourswatches},maxColourSwatches(){const self=this;let currentSwatchIndex=0;if(!this.colourSwatches.length)return[];this.colourSwatches.forEach((swatch,index)=>{if(swatch.stylecolourid===self.styleColour.stylecolourid){currentSwatchIndex=index}});const currentSwatch=this.colourSwatches.splice(currentSwatchIndex,1)[0];this.colourSwatches.unshift(currentSwatch);return this.colourSwatches.slice(0,this.swatches)},image(){return this.styleColour.primaryimage},imageAlt(){if(this.styleColour.images&&this.styleColour.images.length>1&&this.showAltImage){return this.styleColour.images.filter((image)=>!image.primary)[0]}
return!1},imageWide(){return this.styleColour.imageswide},gaImpressionData(){const additionalData={};if(this.index){additionalData.position=this.index}
if(this.listName){additionalData.list=this.listName}
return{type:'impressions',data:$.extend(this.styleColour.variant.gadata,additionalData),}},upsell(){return this.styleColour.variant.upsell},variantOptions(){var options=[];this.styleColour.variants.forEach((variant)=>{var item={...variant};if(item.status==='disabled'){item.disabled=!0}
options.push(item)});return options},},methods:{addToCart(barcode,quantity){peppercheckout.globals.$eventbus.$emit('addproducttocart',{variantid:barcode,quantity,})},getLowestAmount(variants,property){let lowest;for(let i=0;i<variants.length;i++){if(i==0){lowest=parseFloat(variants[i][property])}else if(lowest>parseFloat(variants[i][property])){lowest=parseFloat(variants[i][property])}}
return lowest.toFixed(2)},toggleAltImage(){if(this.hasHoverImage){this.showAltImage=!this.showAltImage}},toggleWishlist(){const self=this;peppercheckout.globals.$eventbus.$emit('togglewishlistitem',{stylecolourid:self.styleColour.stylecolourid,},(response)=>{if(response.status){self.inWishlist=!self.inWishlist}else{loadslidein('slide-in--login-register','/slide-in-login-register')}})},trackClick(){$(document).trigger('psevent',['productClick',this.styleColour.variant.gadata])},selectVariant(option){this.variant=option},getStockStatus(option){var statuses={high:{className:'high',label:'In Stock',},limitedstock:{className:'low',label:'Nearly Gone',},disabled:{className:'none',label:'Sold Out',},};return statuses[option.status]||statuses.high},},});Vue.component('product-flag',{template:'#vc-component-product-flag',props:{flag:{type:Object,default:'',},},computed:{classes(){return['s-flag',`s-flag--${this.kebabify(this.flag.text)}`]},},methods:{kebabify(text){return text.toLowerCase().replace(' ','-')},},});Vue.component('product-lifecycle',{template:'#vc-component-product-lifecycle',props:{attributes:{type:[Array,Object],default(){return{}},},},data(){return{sliderOptions:{arrows:!1,autoplay:!0,fade:!0,infinite:!0,speed:4000,},}},computed:{lifecycleAttributes(){const lifecycleAttributes=['OnlineExclusive','Organic','trending',];return Object.keys(this.attributes).filter((attribute)=>lifecycleAttributes.indexOf(attribute)>-1)},},});Vue.component('site-breadcrumbs',{template:'#vc-component-site-breadcrumbs',props:{breadcrumbs:{type:Array,default(){return[]},},},})}(jQuery))