try{let e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},a=(new e.Error).stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="976a0e90-3469-4345-8337-577d1a39aaa5",e._sentryDebugIdIdentifier="sentry-dbid-976a0e90-3469-4345-8337-577d1a39aaa5")}catch(S){}import{a as e,I as a,c as s,d as i}from"./UGCService.5ffb0f07.js";import{b as t,q as o,bu as l,T as r}from"./index.73b14df2.js";import{I as d}from"./ImageGalleryTitle.715cb12c.js";import{P as n,o as g,E as m,F as h,Q as u,a as c,aG as p,w as f,Y as y}from"./vendor.4f012c28.js";import k from"./Divider.765819dc.js";import"./vue-scrollto.08f265d2.js";import"./accessibilityUtils.5f4e496a.js";import"./intersection-observer.aa907d4a.js";import"./vue-virtual-scroller.a9984a51.js";import"./ContentfulHeading.d975f451.js";import"./slugify.337d2c9e.js";const x={components:{ImageGallery:e,ImageGalleryMobile:a,ImageGalleryTitle:d,Divider:k},props:{sku:{type:String},similarSkus:{type:Array},mixedSkus:{type:Boolean,default:!1},showDivider:{type:Boolean,default:!0},showTitle:{type:Boolean,default:!0},showNewHeading:{type:Boolean,default:!1},collectionName:{type:String}},emits:["expandedVisible","imagesUpdated"],setup(){const{isMobile:e}=o();return{isMobile:e}},data:()=>({loading:!0,images:[],next:[],pageSize:25,maxRequestsPerPage:4,minPrimarySkuImages:5,showGallery:!1}),watch:{images:{handler(e){this.$emit("imagesUpdated",e)}}},async mounted(){this.next=[{sku:this.sku,page:1},...(this.similarSkus||[]).map((e=>({sku:e,page:this.mixedSkus?2:1})))];const e=await s();e&&e.success&&e.data&&(Array.isArray(e.data)?this.images=e.data:this.images=[e.data]),this.load()},methods:{async load(){this.loading=!0;let e=0;const a=this.maxRequestsPerPage,{pageSize:s}=this,{minPrimarySkuImages:t}=this,o=this.images.length;for(;this.next.length&&e<=a&&this.images.length-o{e.products.forEach((e=>{e.link=this.convertPlaToProductUrl(null==e?void 0:e.link)}))}))),a.sku===this.sku&&o.data&&o.data.length>t&&!this.mixedSkus&&(this.next=[]),o.success&&o.next&&!this.mixedSkus&&this.next.unshift({sku:a.sku,page:a.page+1}),e++}this.images&&!this.images.length&&this.$emit("imagesUpdated",this.images),this.loading=!1},sortProducts(e,a){a.data&&a.data.forEach((a=>{a.products&&(a.products=l(a.products,(a=>a.sku===e)).flat())}))},showExpandedGallery(){this.$refs.showGallery.onCardClicked(1),r.track("PDP_Click_More_UGC")},convertPlaToProductUrl:e=>(null==e?void 0:e.indexOf("/pla/"))>-1?e.replace("/pla/","/product/"):e}},b={class:"product-gallery"},w={key:0,id:"product-ugc",class:"product-gallery-divider"};var v=t(x,[["render",function(e,a,s,i,t,o){const l=n("Divider"),r=n("ImageGalleryTitle"),d=n("ImageGalleryMobile"),k=n("ImageGallery");return g(),m("div",b,[s.showDivider?(g(),m("div",w,[h(l,{"margin-top":"var(--space-10)","margin-bottom":"var(--space-10)"})])):u("",!0),t.images.length?(g(),c(r,{key:1,class:"product-gallery-title","collection-name":s.collectionName,"show-title":s.showTitle},p({_:2},[s.showNewHeading?{name:"subtitle",fn:f((()=>[a[1]||(a[1]=y(" See how real people style their Article furniture. ",-1))])),key:"0"}:void 0]),1032,["collection-name","show-title"])):u("",!0),i.isMobile?(g(),c(d,{key:2,images:t.images,"page-size":t.pageSize,"has-more":t.next&&t.next.length,loading:t.loading,onLoadMore:o.load},null,8,["images","page-size","has-more","loading","onLoadMore"])):(g(),c(k,{key:3,ref:"showGallery",images:t.images,"sku-id":s.sku,"page-size":t.pageSize,"has-more":t.next&&t.next.length,loading:t.loading,"custom-arrow-margin-px":16,onLoadMore:o.load,onExpandedVisible:a[0]||(a[0]=a=>e.$emit("expandedVisible",a))},null,8,["images","sku-id","page-size","has-more","loading","onLoadMore"]))])}]]);export{v as default}; //# sourceMappingURL=ProductUGC.09df1b96.js.map