"use strict";(self.heliuxModules=self.heliuxModules||[]).push([[9354],{35978:(t,e,r)=>{r.d(e,{S:()=>n});var a=r(50783),s=r(81);const n=async({modalId:t,errorItems:e,successItems:r,successLabel:n,errorLabel:i,outOfStockLabel:o,experienceFragment:c,closeIcon:d,checkmarkIcon:l,customizationclass:u,sizeDefinedByDialog:m})=>{const h=r?.reduce(((t,{quantity:e})=>t+Number(e)),0),p=e?.reduce(((t,{quantity:e})=>t+Number(e)),0),g=r?.length&&(({items:t,successLabel:e,checkmarkIcon:r})=>`\n    <section class='addalltocart__modal__section addalltocart__modal__sectionSuccess'>\n      <div class='addalltocart__modal__label'>${r||""} ${e||""}</div>\n      ${t.map((t=>`\n        <div class='addalltocart__modal__product'>\n          <span>${t.quantity||""}x</span>\n          <span>${t.productName||t?.product?.name||""}</span>\n          <span>${t.price||""}</span>\n        </div>\n      `)).join("")}\n    </section>\n  `)({items:r,successLabel:n.replace("{number}",h),checkmarkIcon:l?.innerHTML}),y=e?.length&&(({items:t,errorLabel:e,outOfStockLabel:r,closeIcon:a})=>`\n    <section class='addalltocart__modal__section addalltocart__modal__sectionError'>\n      <div class='addalltocart__modal__label'>${a||""} ${e||""}</div>\n      ${t.map((t=>`\n        <div class='addalltocart__modal__product'>\n          <span>${t.quantity||""}x</span>\n          <span>${t.productName||t?.product?.name||""}</span>\n          <span>${r||""}</span>\n        </div>\n      `)).join("")}\n    </section>\n  `)({items:e,errorLabel:i.replace("{number}",p),outOfStockLabel:o,closeIcon:d?.innerHTML}),I=c&&await(0,a.BU)(c),b=(({content:t,id:e,closeIcon:r,customizationClass:a,sizeDefinedByDialog:s})=>`\n  <style type="text/css">\n      #${e} {\n        --scope-modal-content-padding: 0 20px 20px 20px;\n        ${s?"":"\n          --modal-grid-area-start: 5;\n          --modal-grid-area-size: 4;\n        "}\n      }\n  </style>\n    <div class="modal">\n      <div class="modal__base addalltocart__modal ${a}"\n        id="${e}"\n        data-components="Modal">\n        <div class="modal__overlay"></div>\n        <div class="modal__container"\n          role="dialog"\n          aria-labelledby="${e}"\n          aria-modal="true">\n            <button class="modal__closeBtn" title="modal close button">\n              ${r||""}\n            </button>\n            <div class="modal__content" aria-label="Add all to cart summary">\n              ${t}\n            </div>\n        </div>\n      </div>`)({id:t,content:`${g||""} ${y||""} ${I?.fragmentString||""}`,closeIcon:d?.innerHTML,customizationClass:u||"",sizeDefinedByDialog:m}),C=(0,s.ME)(b);document.body.appendChild(C),document.body.classList.add("noScroll")}},33411:(t,e,r)=>{r.d(e,{lp:()=>I,IZ:()=>g,rO:()=>y});var a=r(58480),s=r(30082),n=r(63319),i=r(7873),o=r(37252);const c=t=>({addedTime:(new Date).toISOString(),baseName:t.baseProductName,currency:t.currency,imageUrl:t.imageUrl,listPrice:t.regularPrice,name:t.productName||t.baseProductName,price:t.price,product_id:t.baseProductId,productCategory:t.productCategory,quantity:t.quantity,saleAttributes:t.saleAttributes,seller_id:t.storeCode,seller_name:t.storeName,size:t.size,skuCode:t.itemId}),d=t=>({itemId:t.skuCode,storeCode:t.seller_id,storeName:t.seller_name,quantity:t.quantity}),l={storeKeyName:"raqn.cart",publishes:{raqnCartHasUpdated:"raqn:cart:hasUpdated"}};class u{constructor(){this.config=l,this.logger=new o.V(this.name),this.api=this.getApi(),this.listeners(),this.api.isUserLoggedIn()&&this.cartItems.length&&this.syncCartWithApi()}get name(){return"Local Ecommerce Cart"}getApi(){return(0,n.$)()}getLocalCartItemMapper(t){return c(t)}filterSyncResults(t,e,r={}){const{publishes:s}=this.config;t.filter(((t,a)=>{if(t.reason)return this.errorNotification(t.reason,r.title,r.description),null;const s=e[a];return this.remove(s),s})).length>0&&(0,a.publish)(s.raqnCartHasUpdated,{},{usePostMessage:!0})}syncCartWithApi(){const t=[...this.cartItems],e=t.map((t=>this.api.addToCart(d(t))));Promise.allSettled(e).then((e=>{this.filterSyncResults(e,t,{title:"cart.sync_cart_error-title",description:"cart.sync_cart_error-description"})}))}errorNotification(t,e,r){this.logger.error("Error while cart sync",t),(0,s.rG)({title:e||"",description:r||"",forceRender:!0})}listeners(){(0,a.subscribe)(i.v.userLoggedIn,this.syncCartWithApi.bind(this))}get storeKeyName(){const{storeKeyName:t}=this.config;return t}get cartItems(){const t=window.localStorage.getItem(this.storeKeyName)||"";return(t&&JSON.parse(t)||{}).items||[]}set cartItems(t){window.localStorage.setItem(this.storeKeyName,JSON.stringify({items:t}))}compareItems(t,e){return t.product_id===e.product_id}async add(t){const e=this.getLocalCartItemMapper(t),r=this.cartItems.find((t=>this.compareItems(t,e)));return this.cartItems=r?this.cartItems.map((t=>this.compareItems(t,e)?{...t,quantity:t.quantity+e.quantity}:t)):[...this.cartItems,e],Promise.resolve(this.cartItems)}async quantityInCartFor(t){const e=this.getLocalCartItemMapper(t),r=this.cartItems.find((t=>this.compareItems(t,e)));return r?r.quantity:0}remove(t){this.cartItems=this.cartItems.filter((e=>!this.compareItems(e,t)))}async quantity({countDistinctProducts:t}={}){return t?Promise.resolve(this.cartItems.length,0):Promise.resolve(this.cartItems.reduce(((t,e)=>t+e.quantity),0))}items(){return this.cartItems}clear(){window.localStorage.removeItem(this.storeKeyName)}}var m=r(50432);class h extends u{get name(){return"Local Marketplace Cart"}getApi(){return(0,m.q)()}syncCartWithApi(){const t=[...this.cartItems],e=t.map((t=>{const e=d(t);return this.api.getCartItem({...e,price:t.price})}));Promise.allSettled(e).then((e=>{const r=e.map((async(e,r)=>{const a=t[r],s=e.value,n=d(a);return s&&void 0!==s.product.maxOrderQty&&Number(s.quantity)+Number(n.quantity)>s.product.maxOrderQty&&(n.quantity=s.product.maxOrderQty-s.quantity,this.errorNotification(`Product quantity fixed: ${s}`,`Quantity of "${s.product.name}" has been adjusted`)),s&&Number(s.quantity)+Number(n.quantity)>s.product.saleableQty&&(n.quantity=s.product.saleableQty-s.quantity,this.errorNotification(`Product quantity fixed: ${s}`,`Quantity of "${s.product.name}" has been adjusted`)),n.quantity?this.api.addToCart(n):a}));Promise.allSettled(r).then((e=>{this.filterSyncResults(e,t)}))}))}compareItems(t,e){return t.product_id===e.product_id&&t.skuCode===e.skuCode&&t.seller_id===e.seller_id&&t.price===e.price&&t.currency===e.currency}}class p extends u{get name(){return"Local D2C Cart"}getApi(){return{isUserLoggedIn:()=>!1}}getLocalCartItemMapper(t){return(t=>({...c(t),bundleProductDiscountAmount:Number(t.bundleProductDiscountAmount)?t.bundleProductDiscountAmount:void 0,bundleProducts:t.bundleProducts,isBundle:!!t.bundleProducts.length,componentSkuTotalAmount:Number(t.componentSkuTotalAmount)||void 0,bundleSaleableQty:Number(t.bundleSaleableQty)||void 0,saleableQty:Number(t.saleableQty)||void 0}))(t)}compareItems(t,e){return t.product_id===e.product_id&&t.skuCode===e.skuCode}}const g=()=>(window.raqnCommerceCart=window.raqnCommerceCart||new u,window.raqnCommerceCart),y=()=>(window.raqnCommerceCart=window.raqnCommerceCart||new h,window.raqnCommerceCart),I=()=>(window.raqnCommerceCart=window.raqnCommerceCart||new p,window.raqnCommerceCart)},63319:(t,e,r)=>{r.d(e,{$:()=>o,J:()=>i});var a=r(11896),s=r(36606),n=r(15273);class i extends a.f{constructor(t={}){super({...(0,n.y)(t),storeName:"commerceFetchApi"})}get name(){return"ECommerceFetchApi"}_sameCallQueue(t,e){this.sameCallQueue=this.sameCallQueue||{},this.sameCallQueue[t]=this.sameCallQueue[t]||{promises:[],inProgress:!1};const r=this.sameCallQueue[t];return r.inProgress?new Promise(((t,e)=>{r.promises.push({resolve:t,reject:e})})):(r.inProgress=!0,e().then((t=>{for(;r.promises.length;)r.promises.shift().resolve(t);return r.inProgress=!1,t})))}async addToCart(t){return this.logger.log("Adding product to cart: ",t),this.post("/cart/items",null,t,{noDataReturned:!0})}async addItemsToCart(t){return this.post("/cart/items:batchAddAll",null,{items:t},{})}async getCart(){return this.logger.log("Getting cart items"),this._sameCallQueue("getCart",(()=>this.get("/cart/mine")))}async getCartQuantity({countDistinctProducts:t}={}){return this.logger.log("Getting cart quantity"),this.getCart().then((e=>e&&e.items?t?e.items.length:e.items.reduce(((t,e)=>t+e.quantity),0):e))}async getCartItem(t){return{cartItemData:(await this.getCart()).items.find((e=>e.product.id===t.itemId))}}async deleteCartItem(t){return t}async changeQuantity(t,e){const r={quantity:e};return await this.post(`/cart/items/${t}:changeQuantity`,{},r,{returnResponse:!0})}async getPrice(t){return await this.get(`/products/${t}`)}async getInventory(t){return await this.get(`/inventory/${t}`)}async querySalesOrders(t){return await this.get("/order/salesOrders:search",t)}async orderDetails(t,e){let r;return r=e?await this.orderDetailsGuest(t,e):await this.get(`/order/salesOrders/${t}`),r&&Array.isArray(r.items)&&(r.items=r.items.map(((t,e)=>({...t,index:e+1})))),r}async orderDetailsGuest(t,e){return await this.get(`/order/salesOrders/anonymous?orderNumber=${t}&email=${e}`)}}const o=()=>(0,s.R)({ECommerceFetchApi:i})},40912:(t,e,r)=>{r.d(e,{O:()=>c});var a=r(63319),s=r(36606),n=r(51553),i=r(25520);class o extends a.J{constructor(t={}){const e=((t={})=>({serviceURL:t.endpoint,headers:{"Ocp-Apim-Subscription-Key":t.subscriptionKey},cacheTime:10,errorFormatter:(t={})=>({name:t.status,message:t.title||t.message,details:t.source?t.source.info:t})}))(t);super({...t,...e})}get name(){return"FavoritesFetchApi"}async listFavorites(){return await this.get("/users/favorites")}async getSize(){const t=await this.listFavorites();return t?.length||0}async mapFavoriteProducts(t,e){this.config=t;try{let t;t=e||await this.listFavorites();const r=(await Promise.allSettled(t.map((async t=>{const[e,r]=t.uri.split("spu-")[1].split("-sku-");return{baseProductId:e,variantIdh:r}})))).filter((({status:t})=>"fulfilled"===t)).map((({value:t})=>t));return(await this.cleanProductDataFromSearch(r)).items}catch(t){return console.error("Error mapping favorites:",t),[]}}async addFavoritesItem(t){this.logger.log("Adding product to favorites: ",t);try{const e=await this.post("/resources/favorite",{},t);return this.logger.log("Favorite added successfully:",e),e}catch(t){throw this.logger.error("Failed to add product to favorites:",t),t}}async removeFavoritesItem(t){try{const e=t.uri;return await this.delete(`/resources/favorite?uri=${e}`,{},{noDataReturned:!0})}catch(t){throw console.error("Error during deletion:",t),t}}async cleanProductDataFromSearch(t){try{return this.pdhIds="",this.pdhIds=t.map((t=>t.variantIdh?`${t.baseProductId}#${t.variantIdh}`:`${t.baseProductId}`)),await this.getProductDataFromSearch(this.pdhIds)}catch(t){return console.error("Error fetching or cleaning product data:",t),[]}}getProductDataFromSearch(t){this.searchData=new n.L(this.config.searchApi);const{pdhConfig:e}=this.config,r={pdhCatalog:e?.catalog||"",pdhLang:e?.lang||"",pdhIds:t||[]},a={pdhFilter:r||!1,size:1e3},s={pdhFilter:r};return this.searchData.getData((0,i.b)(s),a)}}const c=t=>(0,s.R)({FavoritesFetchApi:o},t)},15273:(t,e,r)=>{r.d(e,{y:()=>n});const a=t=>{const e=t&&t.error?t.error:t;if("string"==typeof e)return{name:t.error,type:t.status,message:t.path,details:t};if("object"==typeof e){const{code:t,message:r,status:a,details:s}=e;return{code:t,type:a,message:r,name:a,details:s}}return e};var s=r(83038);const n=t=>{const e=t.errorFormatter||a;return{...(0,s.q)(),...t,errorFormatter:e}}},83038:(t,e,r)=>{r.d(e,{q:()=>a});const a=()=>{const t=(window.raqnAPI||{}).commerce||{},{serviceURL:e,headers:r}=t;return{...e&&{serviceURL:e},...r&&{headers:r}}}}}]);