"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7941],{97941:function(e,t,n){n.r(t),n.d(t,{QuickBuyModalPresenter:function(){return eO}});var o,i,r=n(95235),a=n(8529),l=n(2784),s=n(53055),c=n(60418),u=n(80131),d=n(83266),p=n(23122),b=n(97209),v=n(70131),f=n(58880),h=n(95672),g=n(83678),y=n(3990),k=n(14332),O=n(29863),m=n(18422),x=n(78615),T=n(82210),w=n(3635),C=n(76865),S=n(59489),j=n(7328),B=(0,k.zo)(O.a)(i||(i=(0,j.Z)(["\n width: 100%;\n"]))),P=n(52322);function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}var D=((o={}).Size="Size",o.Radio="RADIO",o.Dropdown="DROPDOWN",o.Image="IMAGE",o.Swatch="SWATCH",o),A=function(e){var t,n,o,i,a,s,c,u,d,p,b,v,f=e.option.choices.filter(function(e){return e.colour});switch(e.option.type){case D.Dropdown:return(0,P.jsxs)(l.Fragment,{children:[(0,P.jsx)(B,function(e){for(var t=1;t0||e.index>=0,selected:null===(n=e.selectedOptions)||void 0===n?void 0:n[e.option.key],maxDropdownHeight:e.maxDropdownHeight||"146px",width:e.dropdownWidth},e.option.label===D.Size&&{customErrorMessage:e.customErrorMessage})),f.length>0&&!e.forceDropDowns&&(null===(o=null===(i=e.swatch)||void 0===i?void 0:i.show)||void 0===o||o)?(0,P.jsx)(x.m,{shape:null!==(a=e.swatchShape)&&void 0!==a?a:S.M.SQUARE,colours:f,selectedColour:null===(s=e.selectedOptions)||void 0===s?void 0:s[e.option.key],onColourChange:function(t){var n;e.onOptionChange(e.option.key,t),null===(n=e.onColourSwatchClick)||void 0===n||n.call(e)},i18nText:e.i18nText.swatch,showOnlyTwoRows:e.showOnlyTwoRows,displayColoursAsTextOnly:e.displayColoursAsTextOnly}):null]});case D.Image:return(0,P.jsx)(T.k,{label:e.option.label,labelHidden:e.hideDropDownsLabel||!1,required:!1,ariaLabel:e.option.label,images:f,selectedImage:null===(c=e.selectedOptions)||void 0===c?void 0:c[e.option.key],onImageChange:function(t){var n;e.onOptionChange(e.option.key,t),null===(n=e.onColourSwatchClick)||void 0===n||n.call(e)},i18nText:e.i18nText.imageSwatch,hideOptionalText:!0,displayColoursAsTextOnly:e.displayColoursAsTextOnly,showAllImageSwatches:e.showAllImageSwatches});case D.Swatch:return(0,P.jsxs)(l.Fragment,{children:[(0,P.jsx)(m.N,{required:!0,children:e.option.label}),(0,P.jsx)(x.m,{shape:null!==(u=e.swatchShape)&&void 0!==u?u:S.M.SQUARE,colours:f,selectedColour:null===(d=e.selectedOptions)||void 0===d?void 0:d[e.option.key],onColourChange:function(t){var n;e.onOptionChange(e.option.key,t),null===(n=e.onColourSwatchClick)||void 0===n||n.call(e)},i18nText:e.i18nText.swatch,showOnlyTwoRows:e.showOnlyTwoRows,displayColoursAsTextOnly:e.displayColoursAsTextOnly})]});default:return(0,P.jsx)(w.Ee,{required:null===(p=e.required)||void 0===p||p,label:e.option.label,selectedValue:null===(b=e.selectedOptions)||void 0===b?void 0:b[e.option.key],labelHidden:!1,labelCustomComponent:e.option.attribute?(0,P.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:e.labelCustomComponent}):null,columns:2,getState:function(t){return e.onOptionChange(e.option.key,t)},horizontal:!0,defaultValue:null===(v=e.selectedOptions)||void 0===v?void 0:v[e.option.key],children:e.option.choices.map(function(t,n){return(0,P.jsx)(C.X,{name:e.option.key,title:t.title,value:t.key,disabled:t.disabled,useDisabledStyling:t.useDisabledStyling,borderWidth:"2px"},n)})})}},I=n(41467),q=n(570);function L(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function E(e){for(var t=1;t0&&(0,P.jsx)(Q.oh,{children:(0,P.jsx)(y.$,{tags:o.tags})})]}):null},options:function(e){var t,n,o,i,r=e.product,a=e.quickBuyModalTheme,l=e.inStockComponent,s=e.selectedOptions,c=e.options,u=e.i18nText,d=e.setSelectedOptionsCallback;return(0,P.jsxs)("div",{style:{gridArea:g.p.OPTIONS},children:[(null==r||null===(t=r.subscriptionData)||void 0===t?void 0:t.displaySubscription)&&(0,P.jsx)(v.Y,Z(Z({},r.subscriptionData.subscriptionPurchaseOptions),{},{selectedOptions:s,onOptionChange:d})),!(null!=r&&null!==(n=r.subscriptionData)&&void 0!==n&&n.displaySubscriptionChoicesOnly)&&(0,P.jsx)(V,{options:c,selectedOptions:s,onOptionChange:d,i18nText:u,order:null===(o=a.productOptions)||void 0===o?void 0:o.order,dropdownWidth:null===(i=a.productOptions)||void 0===i||null===(i=i.dropdown)||void 0===i?void 0:i.width,showOnlyTwoRows:a.swatch.showOnlyTwoRows,displayColoursAsTextOnly:a.swatch.displayColoursAsTextOnly}),u.failedToAddToBasketError&&(0,P.jsx)(Q.Vv,{error:u.failedToAddToBasketError,id:"quick-buy-add-to-basket-error-".concat(null==r?void 0:r.sku)}),l&&l]})},pricing:function(e,t,n){var o;return(0,P.jsx)("div",{style:{gridArea:g.p.PRICING},children:(0,P.jsxs)(Q.tw,{flexDirection:e.quickBuyModalTheme.pricing.flexDirection,alignItems:e.quickBuyModalTheme.pricing.alignItems,children:[e.pricing&&(0,P.jsx)(f.t,{pricing:e.pricing,priceDirection:e.quickBuyModalTheme.priceDirection,savings:e.quickBuyModalTheme.pricing.savings,i18nText:{saveLabel:e.i18nText.saveLabel,rrpLabel:e.i18nText.rrpLabel},priceTheme:e.quickBuyModalTheme.pricing.productPrice,discountMessageProps:{text:e.i18nText.subscriptionContractDiscountMessage,textStyle:null===(o=e.quickBuyModalTheme.pricing)||void 0===o||null===(o=o.discountMessage)||void 0===o?void 0:o.textStyle}}),!e.hideQuantitySelector&&(0,P.jsxs)("div",{style:{marginBottom:"".concat((0,k.W0)(2))},children:[(0,P.jsx)(Q.Ds,{children:e.quantitySelector.i18nText.quantityLabel}),(0,P.jsx)(h.c,Z(Z({},e.quantitySelector),{},{quantityChangedCallback:function(e){e&&n(e)},editable:!0,quantity:t}))]})]})})},addToBag:function(e,t){var n,o,i,r,a,l,s=N({selectedQuantity:t,enablePreselectedProductVariant:e.enablePreselectedProductVariant,product:e.product,options:e.options,selectedOptions:e.selectedOptions}),c=(null===(n=e.product)||void 0===n||null===(n=n.subscriptionData)||void 0===n?void 0:n.enableSubscriptionContracts)&&(null===(o=e.product.subscriptionData.subscriptionPurchaseOptions)||void 0===o?void 0:o.activeTabIndex)===1&&!!e.product.subscriptionData.subscriptionPurchaseOptions.subscriptionContracts.length,u=(null===(i=e.product)||void 0===i||null===(i=i.subscriptionData)||void 0===i?void 0:i.enableSubscriptionContracts)&&((null===(r=e.product)||void 0===r||null===(r=r.subscriptionData)||void 0===r?void 0:r.productInBasketWithSubscriptionContract)||(null===(a=e.product)||void 0===a||null===(a=a.subscriptionData)||void 0===a?void 0:a.productInBasketWithoutSubscriptionContract)&&!!(null!==(l=e.product.subscriptionData.subscriptionPurchaseOptions)&&void 0!==l&&l.subscriptionContracts.length));return(0,P.jsx)(F,Z({allowAddToBasket:!!s,allowAddToBasketAsSubscription:!!c,disableAddToBasketSubscriptions:!!u,selectedQuantity:t},e))},availability:function(e){return(0,P.jsx)("div",{style:{gridArea:g.p.AVAILABILITY},children:e.i18nText.availabilityMessage&&(0,P.jsx)(Q.s,{children:e.i18nText.availabilityMessage})})},viewProduct:function(e){return(0,P.jsx)("div",{style:{gridArea:g.p.VIEWPRODUCT},children:e.links&&(0,P.jsx)(Q.bi,{emphasis:"medium",href:e.links.productUrl,renderedAs:"a",onClick:function(){var t;(null===(t=e.callbacks)||void 0===t?void 0:t.viewMoreInformationClicked)&&e.callbacks.viewMoreInformationClicked,e.setOpen&&e.setOpen(!1)},children:e.i18nText.viewMoreInformation})})}},F=function(e){return(0,P.jsx)("div",{style:{gridArea:g.p.ADDTOBAG},children:(0,P.jsx)(Q.l1,{emphasis:"high",disabled:!e.allowAddToBasket||e.quantitySelector.maxValue<1||e.disableAddToBasketSubscriptions,onClick:function(){if(e.allowAddToBasket&&e.selectedQuantity&&e.selectedOptions){if(e.allowAddToBasketAsSubscription){var t;e.callbacks.addToBasketWithContractsCallback&&e.callbacks.addToBasketWithContractsCallback(e.selectedQuantity,null===(t=e.product)||void 0===t||null===(t=t.subscriptionData)||void 0===t||null===(t=t.subscriptionPurchaseOptions)||void 0===t?void 0:t.selectedFrequencyId)}else e.callbacks.addedToBasketClicked(e.selectedOptions,e.selectedQuantity)}},children:e.i18nText.addToBasket})})},U=function(e){var t=(0,R.G)();return(0,P.jsx)(Q.OO,{children:e.components[t].map(function(t){return t?H[t](e.quickBuyModalContentProps,e.selectedQuantity,e.setSelectedQuantity):null})})},_=function(e){var t,n,o,i=(null===(t=e.subscriptionData)||void 0===t?void 0:t.productInBasketWithSubscriptionContract)||(null===(n=e.subscriptionData)||void 0===n?void 0:n.productInBasketWithoutSubscriptionContract)&&!!(null!==(o=e.subscriptionData)&&void 0!==o&&null!==(o=o.subscriptionPurchaseOptions)&&void 0!==o&&o.subscriptionContracts.length);return(0,P.jsxs)(l.Fragment,{children:[i&&(0,P.jsx)(Q.o7,{text:e.i18nText.subscriptionInfoMessageText,type:"info"}),!e.quantitySelectorMaxValue&&(0,P.jsx)(Q.tO,{type:"info",text:e.i18nText.maxQuantityBasketItemMessageText,"data-testid":"quantity-basket-item"})]})},G=function(e){return(0,P.jsxs)(Q.Tc,{ref:e.modalButtonsRef,modalContentScrollable:e.modalContentScrollable,children:[(0,P.jsx)(Q.l1,{emphasis:"high",disabled:!e.allowAddToBasket,onClick:function(){e.allowAddToBasket&&e.selectedQuantity&&e.selectedOptions&&e.callbacks.addedToBasketClicked(e.selectedOptions,e.selectedQuantity)},children:e.i18nText.addToBasket}),e.links&&!e.displayViewMoreInfo&&(0,P.jsx)(Q.bi,{emphasis:"medium",href:e.links.productUrl,renderedAs:"a",onClick:function(){var t;(null===(t=e.callbacks)||void 0===t?void 0:t.viewMoreInformationClicked)&&e.callbacks.viewMoreInformationClicked,e.setOpen&&e.setOpen(!1)},children:e.i18nText.viewMoreInformation})]})},z=function(e){var t,n,o=e.i18nText,i=e.product,r=e.options,s=e.pricing,c=e.links,u=e.quantitySelector,d=e.hideQuantitySelector,p=e.callbacks,v=e.quickBuyModalTheme,f=e.coreTheme,h=e.setOpen,g=e.inStockComponent,y=e.selectedOptions,k=e.setSelectedOptionsCallback,O=e.enablePreselectedProductVariant,m=e.displayViewMoreInfo,x=l.useState(1),T=(0,a.Z)(x,2),w=T[0],C=T[1],S=l.useState(!1),j=(0,a.Z)(S,2),B=j[0],M=j[1],D=l.useRef(null),A=l.useRef(null);if(l.useEffect(function(){var e;if(null!=D&&D.current&&null!=A&&A.current)return(e=new b.Z(function(){var e,t,n=null==D||null===(e=D.current)||void 0===e?void 0:e.getBoundingClientRect(),o=null==A||null===(t=A.current)||void 0===t?void 0:t.getBoundingClientRect();n&&o&&M(n.top+n.height>o.top)})).observe(D.current),function(){e&&e.disconnect()}},[D]),!i)return(0,P.jsx)(Q.eZ,{flashMessageId:"quickBuyModalMissingProduct",message:o.missingProductMessage,type:"error"});var I=N({enablePreselectedProductVariant:O,product:i,selectedQuantity:w,options:r,selectedOptions:y});return(0,P.jsxs)(l.Fragment,{children:[(0,P.jsx)(Q.r6,{children:o.modalTitle}),(0,P.jsx)(_,{i18nText:{subscriptionInfoMessageText:o.subscriptionInfoMessageText,maxQuantityBasketItemMessageText:o.maxQuantityBasketItemMessageText,failedToAddToBasketError:o.failedToAddToBasketError},productSku:i.sku,subscriptionData:i.subscriptionData,quantitySelectorMaxValue:u.maxValue}),(0,P.jsxs)(Q.uE,{ref:D,reducedBottomPadding:v.enableStickyFooterButtons,children:[(0,P.jsx)(Q.W7,{urls:i.images[0],alt:i.title,width:(null===(t=v.product)||void 0===t||null===(t=t.image)||void 0===t?void 0:t.width)||["100%","100%",190,191],height:(null===(n=v.product)||void 0===n||null===(n=n.image)||void 0===n?void 0:n.height)||["","",190,191]}),(0,P.jsx)(U,{quickBuyModalContentProps:{i18nText:o,product:i,pricing:s,links:c,quantitySelector:u,hideQuantitySelector:d,callbacks:p,quickBuyModalTheme:v,coreTheme:f,inStockComponent:g,options:r,selectedOptions:y,setSelectedOptionsCallback:k,setOpen:h,enablePreselectedProductVariant:O,productSku:null==i?void 0:i.sku.toString()},components:v.enabledComponents,selectedQuantity:w,setSelectedQuantity:C})]}),v.enableStickyFooterButtons&&(0,P.jsx)(G,{i18nText:o,modalButtonsRef:A,modalContentScrollable:B,allowAddToBasket:!!I,selectedQuantity:w,selectedOptions:y,callbacks:p,links:c,displayViewMoreInfo:m})]})},Y=n(26203);function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,o)}return n}function J(e){for(var t=1;t1?eE.multipleItemsText:eE.singleItemText,[(null==Q?void 0:Q.maxPerOrder)||5e3,ej]),eR=l.useRef(!1),eQ=l.useRef(),eW=l.useRef(),eZ=l.useRef(),eN=l.useRef();if(x.presentAuroraQuickBuyModal.current=function(e){var t,n=e.sku,o=e.quantity,i=e.fromRecommendations,r=e.onBasketChangeBeacon,a=e.trackingUrl,l=e.initialSelectedOptions,s=e.setSelectedOptionsCallback,u=e.setSelectedVariantCallback,d=e.setOptionsCallback,b=e.fullProductData,v=e.displayNotifyWhenInStock,f=e.enableMobilePDPStickyAddToBasket;if(!l){eP();return}K.current=o,eR.current=null!=i&&i,eW.current=r,eZ.current=a,eQ.current=f,z(l),eN.current={setSelectedOptionsCallback:s,setSelectedVariantCallback:u,setOptionsCallback:d};var h=b?"/e2/operation/product/product-options/".concat(n):"/e2/operation/product-options/".concat(n,"?displayNotifyWhenInStock=").concat(v);l&&c.Z.get(h,{timeout:null!==(t=null==O?void 0:O.PRODUCT_OPTIONS_TIMEOUT)&&void 0!==t?t:5e3,headers:{"Accept-Encoding":"deflate, gzip, br",Host:p,"x-customer-location":k}}).then(function(e){return e.data}).then(function(e){var t=Object.values(l).reduce(function(e,t){return e[t]},e);if(!t){eP();return}W(t.variant),F(t.options),Y.current=e}).catch(function(e){console.trace("Error fetching product options: ".concat(h),e),eP()}),E(!0)},!x.presentAuroraQuickBuyModal)return e.warn("AuroraQuickBuyModalPresenter: Failed to find an initialised BasketContext. Make sure presentAuroraQuickBuyModal ref is defined and it wraps AuroraQuickBuyModalPresenter."),null;if(!L)return null;var eH=S.patterns.quickBuyModal;return(0,P.jsx)(X,ek({enablePreselectedProductVariant:i,loading:!H.length,setOpen:E,options:H,product:Q,quickBuyModalTheme:eH,displayViewMoreInfo:!!eQ,coreTheme:j,rendering:{open:L,onClose:function(){E(!1),eh.t.modalClose()}},i18nText:ek(ek({},eD),{},{maxQuantityBasketItemMessageText:eV,subscriptionInfoMessageText:"",subscriptionContractDiscountMessage:"",failedToAddToBasketError:eO?eI:void 0,availabilityMessage:null==Q?void 0:Q.availabilityMessage}),modal:{i18nText:eq,showHeader:!0,stickyHeader:!0,headerOffset:m,gridColSpan:[12,8,8,6],"data-testid":"quick-buy-modal",animation:S.patterns.quickBuyModal.animation},selectedOptions:G,setSelectedOptionsCallback:function(e,t){if(!Y.current){eP();return}em(!1);var n=(0,ec.WZ)({selectedOptions:G,selectedVariant:Q,optionKey:e,value:t,productOptionsMap:Y.current,setSelectedOptionsCallback:z,setSelectedVariantCallback:W,setOptionsCallback:F}),o=n.updatedSelectedOptions,i=n.updatedProductOptions;eN.current&&o&&i&&(eN.current.setSelectedOptionsCallback&&eN.current.setSelectedOptionsCallback(o),eN.current.setSelectedVariantCallback&&eN.current.setSelectedVariantCallback(i.variant),eN.current.setOptionsCallback&&eN.current.setOptionsCallback(i.options))},pricing:Q?(0,eu.a)(Q,b,v):void 0,links:{productUrl:null==Q?void 0:Q.product.url},callbacks:{addedToBasketClicked:function(e,t){if(x.presentAddedToBasketModal&&Q){if(!Q.enableAddToBasket){em(!0);return}var n=x.presentAddedToBasketModal.current;x.presentAddedToBasketModal.current=function(e,t){x.presentAddedToBasketModal&&(E(!1),em(!1),n(e,t),x.presentAddedToBasketModal.current=n)},ew([{quantity:t,sku:Q.sku.toString()}],{fromRecommendations:eR.current,location:ev.A.PRODUCT_LIST},el.eN.HomeDelivery,void 0,eW.current,eZ.current),eh.t.modalAddToBasket()}},viewMoreInformationClicked:function(){Q&&eh.t.modalInformation(null==Q?void 0:Q.product.sku.toString())},addToBasketWithContractsCallback:function(e,t){eT({variables:{basketId:null==C?void 0:C.id,sku:null==Q?void 0:Q.sku.toString(),quantity:e,contractId:t,settings:{currency:h,shippingDestination:g.code}}}).then(function(){if(x.presentAddedToBasketModal&&Q){var t=x.presentAddedToBasketModal.current;E(!1),t(null==Q?void 0:Q.sku.toString(),e)}})}},quantitySelector:{i18nText:eL,maxValue:eS,quantity:K.current}},n&&o&&{inStockComponent:(0,P.jsx)(d.G,{selectedVariant:Q,url:(null==Q?void 0:Q.product.url)||"",styleOverride:{margin:{top:0,bottom:2}}})}))}},32028:function(e,t,n){n.d(t,{L:function(){return o}});var o="unselected"},70114:function(e,t,n){n.d(t,{WZ:function(){return c},fH:function(){return s}});var o,i=n(8529),r=n(32028),a=function(e){var t=e.selectedOptions,n=e.productOptionsMap;return Object.values(t).reduce(function(e,t){if(!n)return e;if(!e.currentMap){var o=n[t];return e.currentMap=o,null!=o&&o.options&&(e.productOptions=o),e}var i=e.currentMap[t];return e.currentMap&&null!=i&&i.options?e.productOptions=i:e.currentMap=i,e},{productOptions:null,currentMap:null}).productOptions},l=((o=l||{}).THUMBNAIL="THUMBNAIL",o.ORIGINAL="ORIGINAL",o.MAGNIFY="MAGNIFY",o),s=function(e){var t,n=null===(t=e.personalisationData)||void 0===t?void 0:t.personalisationSupportImages;if(n){var o=[];return n.forEach(function(t){var n;null===(n=t.supportImages)||void 0===n||null===(n=n.imagesWithAssetSets)||void 0===n||n.forEach(function(t){var n,i,r,a=t.assetSet,s=t.images,c={url:s.find(function(e){return e.size===l.THUMBNAIL}).url,alt:(null==e?void 0:e.title)||""},u={url:s.find(function(e){return e.size===l.ORIGINAL}).url,alt:(null==e?void 0:e.title)||""},d={url:s.find(function(e){return e.size===l.MAGNIFY}).url,alt:(null==e?void 0:e.title)||""},p=o.find(function(e){return e.key===a}),b=p?o.indexOf(p):0;p||(o.push({key:a,images:[],thumbnails:[],zoom:[]}),b=o.length-1),null===(n=o[b])||void 0===n||n.images.push(u),null===(i=o[b])||void 0===i||i.thumbnails.push(c),null===(r=o[b])||void 0===r||r.zoom.push(d)})}),o}},c=function(e){var t,n=e.productOptionsMap,o=e.selectedOptions,l=e.setSelectedOptionsCallback,s=e.setOptionsCallback,c=e.setSelectedVariantCallback,u=e.selectedVariant,d=e.optionKey,p=e.value;o[d]=p,l(o);var b=a({selectedOptions:o,productOptionsMap:n});if(b)return s(b.options),c(b.variant),{updatedSelectedOptions:o,updatedProductOptions:b};if(null!=u&&null!==(t=u.product)&&void 0!==t&&t.linkedOn){var v=Object.entries(o).reduce(function(e,t){var n,o=(0,i.Z)(t,2),a=o[0],l=o[1];return a===(null===(n=u.product)||void 0===n?void 0:n.linkedOn)?e[a]=l:e[a]=r.L,e},{}),f=a({productOptionsMap:n,selectedOptions:v});if(f)return s(f.options),c(f.variant),{updatedSelectedOptions:v,updatedProductOptions:f}}return{updatedSelectedOptions:null,updatedProductOptions:null}}}}]); //# sourceMappingURL=7941.3539901d51318459.js.map