1"use strict";(globalThis["__LOADABLE_LOADED_CHUNKS__"]||=[]).push([[9456],{9045(e,t,s){s.d(t,{A:()=>r});var i=s(19777),n=s(1939);const o=(e,t)=>{const s=e?`${e}.`:"",o=t||i.g3[i.cf][e];return(0,n.A)(o??[],`${i.cf}.${s}`)},r=()=>o("presentation")},54637(e,t,s){s.r(t),s.d(t,{default:()=>Ze});var i=s(24842),n=s(88821),o=s(19134),r=s(39620),a=s(88467),l=s(49937),d=s(14218),c=s(96540),p=s(71468),h=s(55567),u=s(87130),m=s(11309),x=s(86128),g=s(55679),f=s(74848);const b=(0,l.styled)(d.EY.H2,{base:{marginTop:"xs",marginBottom:"2xs"}},{defaultProps:{size:"xs"}}),j=()=>{const e=(0,h.A)(),t=(0,p.d4)(u.f5),s=(0,p.d4)(u.ms),n=(0,p.d4)(u.nr),o=(0,p.d4)(u.V_),{t:r}=(0,i.A)("checkout.ondemand"),a=Math.min(o,t),l=(0,c.useCallback)(()=>{e((0,g.hl)(!n))},[e,n]);if(!(t&&0!==o||n))return null;const m=n&&0===o?s:a;return(0,f.jsxs)(d.aP,{gap:"2xs",children:[(0,f.jsx)(b,{children:r(e=>e.customerAccountBalance.balanceHeading,{amount:(0,x.up)(t)})}),(0,f.jsx)(d.Sc,{checked:n,label:r(e=>e.customerAccountBalance.useBalanceCheckboxLabel,{amount:(0,x.up)(m)}),onChange:l})]})};var k=s(17644),S=s(86231);const M=(0,l.styled)(d.EY.H2,{base:{marginTop:"m",marginBottom:"2xs"}},{defaultProps:{size:"xs"}}),y=({title:e,ctfPaymentMethods:t,customerGroup:s})=>{const i=(0,p.d4)(k.J0),n=(0,p.d4)(u.Wp),o=(0,c.useMemo)(()=>(t??[]).reduce((e,t)=>{const s=n.find(({id:e})=>e===t?.fields.paymentMethod?.fields.id);return t&&s?[...e,[t,s]]:e},[]),[t,n]);return i&&"business"!==s||!i&&"consumer"!==s||0===o.length?null:(0,f.jsxs)("div",{children:[(0,f.jsx)(M,{children:e}),(0,f.jsx)(S.A,{paymentMethodTuples:o})]})},v=(0,l.styled)(d.Eg,{base:{marginBlock:"xs",marginInline:"none"}},{defaultProps:{appearance:"info"},shouldForwardProp:e=>"appearance"===e}),C=({mainContent:e})=>{const t=(0,h.A)(),s=(0,p.d4)(u.m1),i=(0,p.d4)(u.wO),n=s?.customerAccountBalanceUsed??0,o=i+n<(s?.orderTotalPrice??0),a=(0,c.useMemo)(()=>{const e=(s?.orderOpenPrice??0)<=0,t=(s?.selectedVouchers??[]).length>0;return e?t&&n?"Tilaukseen liitetyt lahjakortit ja asiakastililtä käytettävät varat kattavat koko tilauksen loppusumman.":t?"Tilaukseen liitetyt lahjakortit kattavat koko tilauksen loppusumman.":n?"Asiakastililtä käytettävät varat kattavat koko tilauksen loppusumman.":null:null},[n,s?.orderOpenPrice,s?.selectedVouchers]);return(0,c.useEffect)(()=>{e&&t((0,m.V)(e))},[t,e]),(0,f.jsxs)(f.Fragment,{children:[a&&(0,f.jsx)(v,{children:(0,f.jsx)(d.Eg.Paragraph,{children:a})}),(0,f.jsx)(j,{}),o&&e?.map((e,t)=>{const s=`${e?.sys.contentType.sys.id}-${t}`;if(e&&(0,r.$H)(e))return(0,f.jsx)(y,{ctfPaymentMethods:e.fields.paymentMethodInformations,customerGroup:e.fields.customerGroup,title:e.fields.title},s)})]})};var P=s(8034),I=s(43631);const A=()=>(0,I.A)("shipping");var w=s(86055),$=s(68592),T=s(99044),E=s(76308),B=s(81267),L=s(39951),z=s(98148);const N=(0,l.styled)(d.fs,{base:{marginTop:"xs","& textarea":{height:"xl"}}}),D=1e3,X=250,F=({shipmentMethodId:e})=>{const{t}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints"}),s=(0,h.A)(),n=(0,p.d4)(u.Z3),[o,r]=(0,c.useState)(n??""),[a]=(0,z.A)(()=>s((0,g.fV)()),D),[l]=(0,z.A)(e=>s((0,g.k5)(e)),X),d=(0,c.useCallback)(e=>{r(e.target.value),l(e.target.value),a()},[a,l]),m=(0,c.useCallback)(e=>e.preventDefault(),[]);return(0,f.jsx)("form",{onSubmit:m,children:(0,f.jsx)(N,{id:`customer-comment-for-courier-${e}`,label:t(e=>e.commentForCourier),name:"customerComment",value:o,onChange:d})})};var G=s(61311),Y=s(14181),O=s(6596);const U=(0,O["default"])(d.pd).withConfig({componentId:"sc-1qhd2sh-0"})({marginTop:Y.space.XS,maxWidth:"400px"}),_=1e3,H=250,q=()=>{const{t:e}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints"}),t=(0,h.A)(),s=(0,p.d4)(u.Lx),[n,o]=(0,c.useState)(s??""),[r,a]=(0,c.useState)(Boolean(s)),[l]=(0,z.A)(()=>t((0,g.zN)()),_),[m]=(0,z.A)(e=>t((0,g.gQ)(e)),H),x=(0,c.useCallback)(e=>{o(e.target.value),m(e.target.value),l()},[l,m]),b=(0,c.useCallback)(()=>{a(!r)},[r]),j=(0,c.useCallback)(e=>e.preventDefault(),[]);return(0,c.useEffect)(()=>{!r&&n&&(o(""),m(null),l())},[l,m,r,n]),(0,f.jsxs)("form",{onSubmit:j,children:[(0,f.jsx)(d.L$,{className:(0,G.css)({marginTop:"xs"}),checked:r,label:e(e=>e.otherPickupPerson.switchLabel),size:"XS",onClick:b}),r&&(0,f.jsx)(U,{id:"pickupPerson",label:e(e=>e.otherPickupPerson.inputLabel),name:"pickupPerson",size:"M",value:n,onChange:x})]})};var R=s(17277),W=s(7286),K=s(47124),V=s(92228),J=s(8563);const Q=O["default"].form.withConfig({componentId:"sc-1rh7siq-0"})({display:"flex",flexDirection:"column",gap:Y.space.XS,marginTop:Y.space.XS,[R.breakpoint.min.M]:{flexDirection:"row"}}),Z=({timeSlots:e})=>{const{t}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints.timeSlotDelivery"}),s=(0,h.A)(),n=(0,p.d4)(u.tv)??"",o=(0,p.d4)(u.SE),r=(0,p.d4)(J.md),a=(0,c.useMemo)(()=>e?.slice(0).sort((e,t)=>
1{const{start:s}=(0,V.Yh)(e.slot),{start:i}=(0,V.Yh)(t.slot);return s.valueOf()-i.valueOf()})??null,[e]),l=(0,c.useMemo)(()=>(e=>{if(e&&0!==e?.length)return e.reduce((e,t)=>{const{start:s}=(0,V.Yh)(t.slot),i=s.toISODate()??"";return e[i]?{...e,[i]:[...e[i],t]}:{...e,[i]:[t]}},{})})(a),[a]),m=(0,c.useMemo)(()=>o&&a?.find(e=>e.slot===o)?(0,V.I4)(o):l&&l[n]?n:a&&a?.length>0?(0,V.I4)(a[0].slot):"",[n,o,a,l]),x=(0,c.useCallback)(e=>e.preventDefault(),[]),b=(0,c.useCallback)(e=>{s((0,g.Iq)(null)),s((0,g.kD)(e.target.value))},[s]),j=(0,c.useCallback)(t=>{if(!e)return;const i=e.find(e=>e.slot===t.target.value);s((0,g.Iq)(i||null))},[e,s]);return l?(0,f.jsxs)(Q,{onSubmit:x,children:[(0,f.jsx)(d.l6,{id:"selected-day",label:t(e=>e.selectDay),name:"day",value:m??"",required:!0,onChange:b,children:Object.keys(l).sort().map(e=>(0,f.jsx)("option",{value:e,children:(0,W.Ur)(e,(0,K.MI)(r))},e))}),(0,f.jsxs)(d.l6,{id:"selected-time-slot",label:t(e=>e.selectTimeSlot),name:"timeSlot",value:o??"",required:!0,onChange:j,children:[(0,f.jsx)("option",{value:"",children:t(e=>e.selectPlaceholder)}),m&&l[m]?.map(({slot:e})=>(0,f.jsx)("option",{value:e,children:(0,V.fA)(e)},e))]})]}):null},ee=({description:e,shipmentMethodId:t,timeSlots:s})=>(0,f.jsxs)(f.Fragment,{children:[e?(0,f.jsx)(d.s7,{small:!0,children:(0,L.Ay)(e)}):null,$.hu.includes(t)&&(0,f.jsx)(q,{}),$.uR.includes(t)&&(0,f.jsx)(Z,{timeSlots:s}),$.LX.includes(t)&&(0,f.jsx)(F,{shipmentMethodId:t})]}),te=(0,l.styled)(d.Q3,{},{defaultProps:{size:(0,P.S)("sizes.s")}}),se=({className:e,icon:t})=>{const{t:s}=(0,i.A)("common");switch(t){case"Verkkokauppa.com":return(0,f.jsx)(te,{className:e});case"Posti":return(0,f.jsx)(d.gu.Posti,{className:e});case"Matkahuolto":return(0,f.jsx)(d.gu.MatkahuoltoRound,{className:e});case"Shipment":return(0,f.jsx)(d.gu.WhiteLabelShipment,{ariaLabel:s(e=>e.logo.whiteLabelShipment),className:e});case"Hakonen":return(0,f.jsx)(d.gu.Hakonen,{className:e});case"Pikatoimitus":return(0,f.jsx)(d.gu.Pikatoimitus,{ariaLabel:s(e=>e.logo.fastDelivery),className:e});case"Fetch My Stuff":return(0,f.jsx)(d.gu.FetchMyStuff,{className:e});case"Wolt":return(0,f.jsx)(d.gu.Wolt,{className:e});default:return null}},ie=(0,l.styled)(d.EY.UI,{base:{marginLeft:"3xs",minWidth:"l",textAlign:"right"}},{defaultProps:{weight:"semiBold",appearance:"secondary"},shouldForwardProp:e=>"appearance"===e}),ne=({icon:e,price:t})=>(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(se,{icon:e}),(0,f.jsx)(ie,{children:(0,x.$g)(t??0)})]}),oe="DepartmentStore",re=(e,t)=>{const s=(0,$.Kk)(e.id)?.businessId,i=s?(0,E.m)(s):null;return i?(0,E.lv)(i,t):""},ae=({cartOrderShipmentMethods:e,shipmentMethodTuples:t,selectedParentGroup:s,onParentChangeMethod:n})=>{const o=(0,p.d4)(u.m1),r=(0,h.A)(),{t:a}=(0,i.A)("stores"),[l,m]=(0,c.useState)(!1);(0,c.useEffect)(()=>{m(!1),setTimeout(()=>m(!0),110)},[o?.selectedShipmentMethodId]);const[{departmentStorePickupTitle:x,departmentStorePickupDescription:b,parcelLockerPickupTitle:j,parcelLockerPickupDescription:k}]=A(),S=(0,c.useCallback)(([e,t])=>{const s=(0,$.Kk)(t.id)?.["@type"]!==oe;return{id:`disabled-shipment-method-${t.id}`,header:s?x:j,description:s?b:k,descriptionChildren:(0,f.jsx)(ne,{icon:e.fields.icon,price:t.price}),disabled:!0,wrapDescriptionChildren:!1}},[b,x,k,j]),M=(0,c.useCallback)(([e,t])=>{const s=(0,$.Kk)(t.id)?.["@type"]===oe,i=(0,$.mk)(e,"short");return{id:`${t.id}`,header:i||t.name,description:s?b:k,children:(0,f.jsx)(ee,{description:e.fields.description,shipmentMethodId:t.id,timeSlots:t.timeSlots}),descriptionChildren:(0,f.jsx)(ne,{icon:e.fields.icon,price:t.price}),disabled:t.isDisabled,wrapDescriptionChildren:!0}},[b,k]),y=(0,c.useCallback)(t=>{const s=e.find(({id:e})=>e===(0,B.YR)(t.target.value)),i=o?.selectedShipmentMethodId;s&&r((0,g.m4)({shipmentMethod:s,previousShipmentMethodId:i}))},[e,o,r]),v=(0,c.useCallback)(e=>{const[t]=e,[s,i]=t,n=(0,$.Kk)(i.id);if(1===e.length&&27===i.id)return{id:"pak",header:i.name,description:`${n?.streetAddressLine1}, ${n?.postalCode} ${n?.addressLocality}`,children:(0,f.jsx)(ee,{description:s.fields.description,shipmentMethodId:i.id,timeSlots:i.timeSlots}),descriptionChildren:(0,f.jsx)(ne,{icon:s.fields.icon,price:i.price}),disabled:i.isDisabled,wrapDescriptionChildren:!0};const r=e.map(M);1===r.length&&r.push(S(t));const[,c]=t;return{id:n?.parentIds?.[0]||n?.businessId||"unknown",header:re(c,a),description:`${n?.streetAddressLine1}, ${n?.postalCode} ${n?.addressLocality}
1`,children:(0,f.jsx)(d.gA,{groupName:"child-shipment-methods",items:r,selectedItemId:l?o?.selectedShipmentMethodId?.toString():void 0,onChange:y}),descriptionChildren:(0,f.jsx)(ne,{icon:s.fields.icon,price:i.price}),wrapDescriptionChildren:!1,noActiveBackground:!0}},[M,l,o?.selectedShipmentMethodId,y,S,a]),C=(0,c.useMemo)(()=>t.map(v),[v,t]);return 0===C.length?null:(0,f.jsx)(d.gA,{groupName:"shipmentMethod",items:C,selectedItemId:s,onChange:n})},le=([e,t])=>{const s=(0,$.mk)(e,"default");return{id:`${t.id}`,header:s||t.name,children:(0,f.jsx)(ee,{description:e.fields.description,shipmentMethodId:t.id,timeSlots:t.timeSlots}),descriptionChildren:(0,f.jsx)(ne,{icon:e.fields.icon,price:t.price}),disabled:t.isDisabled,wrapDescriptionChildren:!1}},de=({cartOrderShipmentMethods:e,shipmentMethodTuples:t})=>{const s=(0,p.d4)(u.uJ),i=(0,h.A)(),n=(0,c.useCallback)(t=>{const n=e.find(({id:e})=>e===(0,B.YR)(t.target.value));n&&i((0,g.m4)({shipmentMethod:n,previousShipmentMethodId:s?.id}))},[e,s?.id,i]),o=(0,c.useMemo)(()=>t.map(le),[t]);return(0,f.jsx)(d.gA,{groupName:"shipmentMethod",items:o,selectedItemId:s?.id.toString(),onChange:n})},ce=O["default"].div.withConfig({componentId:"sc-11eo422-0"})({marginTop:Y.space.XXS,marginBottom:Y.space.XXS,display:"flex",justifyContent:"center"}),pe=({selectedShipmentPointId:e,shipmentPoints:t,onSetShipmentPointId:s})=>{const{t:n}=(0,i.A)(["common","checkout.ondemand"]),o=(0,p.d4)(u.rC),r=(0,h.A)(),a=(0,c.useCallback)(()=>r((0,g.E_)(!0)),[r]),l=(0,c.useCallback)(()=>r((0,g.E_)(!1)),[r]);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ce,{children:(0,f.jsx)(d.vx,{"aria-haspopup":"dialog",onClick:a,children:n(e=>e.shipmentPoints.showMore,{ns:"checkout.ondemand"})})}),(0,f.jsx)(d.lG,{closeButtonLabel:n(e=>e.dialog.closeButtonLabel,{ns:"common"}),isOpen:o,size:"L",title:n(e=>e.shipmentPoints.selectPickupPoint,{ns:"checkout.ondemand"}),onClose:l,children:(0,f.jsx)(d.JI,{maxHeight:"calc(100vh - 10rem)",children:(0,f.jsx)(d.gA,{groupName:"shipmentPoint",items:t,selectedItemId:e?.toString(),onChange:s})})})]})};var he=s(85663),ue=s(29252),me=s.n(ue),xe=s(47169),ge=s(41366),fe=s(2829),be=s(42684);const je=({isUsingGeolocation:e,setIsUsingGeolocation:t})=>{const{t:s}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints.geolocate"}),[n,o]=(0,c.useState)(!1),r=(0,p.wA)(),a=(0,h.A)(),l=(0,c.useCallback)(()=>{o(!0),(0,fe.jB)().then(({coords:{latitude:e,longitude:s}})=>{t(!0),a((0,g.c3)({latitude:e,longitude:s}))}).catch(()=>{t(!1),r((0,be.tj)({message:s(e=>e.errorMessage),appearance:"alert"}))}).finally(()=>{o(!1)})},[a,r,t,s]),u=(0,c.useMemo)(()=>n?(0,f.jsx)(d.y$,{size:"xs",isInline:!0}):e?(0,f.jsx)(d.In,{iconName:"FaLocationLight",size:"xs",isInline:!0}):null,[n,e]);return(0,f.jsxs)(d.EY.UI,{children:[(0,f.jsx)(d.vx,{"aria-label":s(e=>e.ariaLabel),type:"button",onClick:l,children:s(e=>e.linkText)}),u]})},ke=({initialPostalCode:e,setIsUsingGeolocation:t})=>{const{t:s}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints"}),n=(0,h.A)(),[o]=(0,z.A)(e=>{t(!1),n((0,g.c3)({postalcode:e}))},250),r=(0,c.useCallback)(e=>{"Enter"===e.key&&(e.preventDefault(),e.currentTarget.validity.valid&&o(e.currentTarget.value))},[o]),a=(0,c.useCallback)(e=>{e.currentTarget.validity.valid&&o(e.currentTarget.value)},[o]);return(0,f.jsx)(d.pd,{"aria-label":s(e=>e.postalCodeInput),autoComplete:"off",css:{width:"4.5rem","& input":{textAlign:"center"}},defaultValue:e,id:"postalcode",inputMode:"numeric",label:s(e=>e.postalCodeInput),maxLength:5,name:"postalcode",pattern:"^\\d{5}$",size:"M",type:"search",hideLabel:!0,onChange:a,onKeyDown:r})},Se=(0,O["default"])(se).withConfig({componentId:"sc-1fi0hig-0"})({width:Y.size.S,marginRight:Y.space.XXXS,lineHeight:"inherit",alignSelf:"center"}),Me=(0,l.styled)(d.EY.UI,{base:{display:"flex",alignItems:"center",marginRight:"xs"}},{defaultProps:{size:"small"}}),ye=({className:e,id:t,name:s,icon:i})=>{const n=(0,p.d4)(u.oi),o=(0,h.A)(),r=(0,c.useCallback)(e=>{const{checked:s}=e.target,i=n.shipmentMethodId??[],r=(s?i.concat([t]).filter($.xr):i.filter(e=>e!==t)).sort();o((0,g.c3)({shipmentMethodId:r}))},[o,n,t]),a=!(n.shipmentMethodId&&n.shipmentMethodId.length>0)||n.shipmentMethodId.includes(t),l=1===n?.shipmentMethodId?.length&&n.shipmentMethodId.includes(t);return(0,f.jsxs)(d.JU,{className:e,children:[(0,f.jsx)(d.Sc,{defaultChecked:a,disabled:l,name:"shipmentMethodId",value:t,onChange:r}),(0,f.jsxs)(Me,{children:[(0,f.jsx)(Se,{icon:i}),s]})]})};ye.displayName="ShipmentMethodCheckbox";const ve=(0,O["default"])(ye).withConfig({componentId:"sc-1fi0hig-1"})({display:"flex",gap:Y.space.XXXS,cursor:"pointer"}),Ce=()=>{const{t:e}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints"}),t=(0,p.d4)(u.oi),s=(0,h.A)(),n=(0,c.useCallback)(e=>{const{checked:t}=e.target;s((0,g.c3)({showPrivate:t}))},[s]);return(0,f.jsx)(d.g5,{defaultChecked:t?.showPrivate??!1,label:e(e=>
1e.showPrivate),name:"showPrivate",size:"XS",value:"true",onChange:n})},Pe=O["default"].form.withConfig({componentId:"sc-lehjt1-0"})({display:"flex",flexDirection:"column",marginBottom:Y.space.XXS,border:`1px solid ${Y.color.border.primary}`}),Ie=O["default"].div.withConfig({componentId:"sc-lehjt1-1"})({display:"flex",flexWrap:"wrap",alignItems:"center",gap:Y.space.XXS,marginBottom:Y.space.XS,"&:last-child":{marginBottom:0}}),Ae=({shipmentMethodTuples:e})=>{const{t}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints"}),s=(0,h.A)(),n=(0,c.useRef)(null),o=(0,p.d4)(u.G5),r=(0,p.d4)((0,ge.Qs)(o)),a=(0,p.d4)(u.oi),[l,m]=(0,c.useState)(!1),[x,b]=(0,c.useState)(!1),[j,k]=(0,c.useState)(!1),S="postalcode"in a&&a.postalcode?a?.postalcode:r?.postCode??"",M=Boolean(S),y=(0,c.useMemo)(()=>e.map(([,{id:e}])=>e).sort(),[e]),v=(0,c.useMemo)(()=>e.reduce((e,[,{validShipmentPointTypes:t=[]}])=>e.concat(t),[]).sort(),[e]),C=(0,xe.A)(y),P=(0,xe.A)(v);(0,c.useEffect)(()=>{b(e=>e||M)},[M]),(0,c.useEffect)(()=>{j&&!me()(y,C??[])&&s((0,g.c3)({shipmentMethodId:y}))},[s,C,j,y]),(0,c.useEffect)(()=>{j&&!me()(v,P??[])&&s((0,g.c3)({validShipmentPointTypes:v}))},[s,j,v,P]),(0,c.useEffect)(()=>{x&&!j&&(s((0,g.c3)({postalcode:S,showPrivate:!1,shipmentMethodId:y})),k(!0))},[s,j,S,x,y]);const I=(0,c.useCallback)(e=>e.preventDefault(),[]);return(0,f.jsxs)(Pe,{ref:n,className:(0,he.boxRecipe)({appearance:"secondary",radius:"XXS"}),onSubmit:I,children:[(0,f.jsxs)(Ie,{children:[(0,f.jsx)(d.EY.UI,{children:t(e=>e.searchByPostalCode)}),(0,f.jsx)(ke,{initialPostalCode:S,setIsUsingGeolocation:m}),(0,f.jsxs)(d.EY.UI,{children:[t(e=>e.or)," "]}),(0,f.jsx)(je,{isUsingGeolocation:l,setIsUsingGeolocation:m}),(0,f.jsx)(Ce,{})]}),(0,f.jsx)(Ie,{children:e.map(([{fields:{icon:e}},{id:t,name:s}])=>(0,f.jsx)(ve,{icon:e,id:t,name:s},t))})]})},we=5,$e=(0,l.styled)(d.EY.UI,{base:{display:"block",textAlign:"center"}}),Te=({shipmentMethodTuples:e})=>{const{t}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentPoints"}),s=(0,h.A)(),n=(0,p.d4)(u.xW),o=(0,p.d4)(u.qs),r=(0,p.d4)(u.vn),a=(0,p.d4)(u.uJ),l=(0,c.useMemo)(()=>e.reduce((e,t)=>({...e,[t[1].id]:t}),{}),[e]),m=(0,c.useMemo)(()=>n.reduce((e,s)=>{const i=l[s.shipmentMethodId];if(!i)return e;const[n,o]=i;if(!n||!o)return e;const r=o.shipmentPointTypes?.find(({typeId:e})=>e===s.type)?.price,a=r??o.price;return a||0===a?e.concat({id:String(s.id),header:`${s.name}${s.isPrivate?` - ${t(e=>e.privateLabel)}`:""}`,description:`${s.address}, ${s.postalCode} ${s.city}`,children:(0,f.jsxs)(f.Fragment,{children:[s.isPrivate&&(0,f.jsx)(d.EY.P,{size:"small",children:t(e=>e.privateNotice)}),(0,f.jsx)(ee,{description:n.fields.description,shipmentMethodId:o.id})]}),descriptionChildren:(0,f.jsx)(ne,{icon:n.fields.icon,price:a}),shipmentPointId:s.id,wrapDescriptionChildren:!1}):e},[]),[l,n,t]),x=(0,c.useMemo)(()=>{const e=m.findIndex(({shipmentPointId:e})=>o===e),t=(0,B.qE)(e-Math.floor(we/2),0,m.length-we);return m.slice(t,t+we)},[m,o]),b=(0,c.useCallback)(e=>{const t=(0,B.YR)(e.target.value),i=n.find(e=>e.id===t);i&&(s((0,g.BA)({shipmentPoint:i,previousShipmentMethodId:a?.id})),s((0,g.E_)(!1)))},[a?.id,s,n]);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Ae,{shipmentMethodTuples:e}),!r&&0===n.length&&(0,f.jsx)(d.az,{appearance:"secondary",children:(0,f.jsx)($e,{children:t(e=>e.noResults)})}),r?(0,f.jsx)($e,{children:(0,f.jsx)(d.y$,{})}):x.length>0&&(0,f.jsx)(d.gA,{groupName:"initialShipmentPoint",items:x,selectedItemId:o?.toString(),onChange:b}),!r&&x.length<n.length&&(0,f.jsx)(pe,{selectedShipmentPointId:o,shipmentPoints:m,onSetShipmentPointId:b})]})},Ee=(0,c.memo)(Te),Be=(0,l.styled)(d.EY.H2,{base:{marginTop:"m",marginBottom:"2xs"}},{defaultProps:{size:"xs"}}),Le=(0,l.styled)(d.EY.UI,{base:{marginTop:"m",marginBottom:"2xs"}},{defaultProps:{size:"small",weight:"semiBold",role:"heading"}}),ze=({title:e})=>{const t=(0,p.d4)(u.Qv),s=w.KV?void 0:"group-title";return t?(0,f.jsx)("div",{"data-testid":s,style:{margin:(0,P.S)("spacing.xs")}}):(0,f.jsx)(Be,{"data-testid":s,children:e})},Ne=({combinedPostLockerMethod:e,shipmentMethods:t,title:s,fallback:i})=>{const n=(0,p.d4)(u.uW),[{preferredStore:o,otherStores:r,allStoresTitle:a}]=A(),l=(0,p.d4)(u.uJ),d=(0,h.A)(),m=(0,c.useMemo)(()=>(t??[]).reduce((e,t)=>
1{const s=n.find(({id:e})=>e===t?.fields.shipmentMethod?.fields.id);return t&&s?[...e,[t,s]]:e},[]),[t,n]),x=(0,c.useMemo)(()=>(e=>e.reduce((e,t)=>{const[,s]=t,i=(0,$.Kk)(s.id);if(!i)return e;const[n]=i.parentIds,o=n??i.businessId;return e[o]||(e[o]=[]),e[o].push(t),e},{}))(m),[m]),b=(0,p.d4)(T.WB),j=(0,$.tg)(m[0]?.[1].id),k=(0,c.useMemo)(()=>Object.keys(x).find(e=>x[e].some(([,e])=>e.id===l?.id))??"",[l,x]),S=(0,c.useCallback)(e=>{const t=e.target.value,s=x[t]?.[0];if(s){const[,e]=s;d((0,g.m4)({shipmentMethod:e,previousShipmentMethodId:l?.id}))}},[x,d,l?.id]),M=(0,c.useMemo)(()=>j&&x[b]?x[b]:null,[x,j,b]);(0,c.useEffect)(()=>{if(l||!M)return;const e=M[0][1];e&&d((0,g.m4)({shipmentMethod:e}))},[l,M,d]);const y=Object.keys(x).filter(e=>e!==b).map(e=>x[e]);return m?.length?(0,f.jsx)(f.Fragment,{children:e?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ze,{title:s}),(0,f.jsx)(Ee,{shipmentMethodTuples:m})]}):j&&!i?(0,f.jsxs)(f.Fragment,{children:[M&&(0,f.jsx)(Le,{children:o}),(0,f.jsx)(ae,{cartOrderShipmentMethods:n,selectedParentGroup:k,shipmentMethodTuples:M?[M]:[],onParentChangeMethod:S}),(0,f.jsx)(Le,{children:M?r:a}),(0,f.jsx)(ae,{cartOrderShipmentMethods:n,selectedParentGroup:k,shipmentMethodTuples:y,onParentChangeMethod:S})]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ze,{title:s}),(0,f.jsx)(de,{cartOrderShipmentMethods:n,shipmentMethodTuples:m})]})}):null};var De=s(87617),Xe=s(90368),Fe=s(82947),Ge=s(8551),Ye=s(9045);const Oe=O["default"].div.withConfig({componentId:"sc-1qsyo39-0"})({overflow:"visible",position:"relative",height:"100%",minWidth:"10rem",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:Y.border.radius.XXS,cursor:"pointer",boxShadow:Y.input.outline.default,textAlign:"center",padding:Y.space.XXS,paddingBottom:Y.space.XS,boxSizing:"border-box",userSelect:"none","input:hover + &":{backgroundColor:Y.color.fundaments.greys[100],boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.border.highlight.secondary} inset`},"input:checked + &":{backgroundColor:Y.color.fundaments.blues[100],boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.fundaments.blues[200]} inset`},"input:checked:hover + &":{backgroundColor:Y.color.fundaments.blues[100],boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.border.highlight.secondary} inset`},"@supports selector(:focus-visible)":{"input:focus-visible + &":{boxShadow:`0px 0px 0px ${Y.border.size.M} ${Y.color.border.highlight.secondary} inset`},"input:checked:focus-visible + &":{backgroundColor:Y.color.fundaments.blues[100],boxShadow:`0px 0px 0px ${Y.border.size.M} ${Y.color.border.highlight.secondary} inset`}},"@supports not selector(:focus-visible)":{"input:hover + &":{backgroundColor:Y.color.fundaments.greys[100],boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.border.highlight.secondary} inset`},"input:focus + &":{boxShadow:`0px 0px 0px ${Y.border.size.M} ${Y.color.border.highlight.secondary} inset`},"input:checked:focus + &":{boxShadow:`0px 0px 0px ${Y.border.size.M} ${Y.color.border.highlight.secondary} inset`}}},({$disabled:e})=>e&&{cursor:"not-allowed",color:Y.color.text.disabled,background:"transparent",boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.text.inverted.secondary} inset`,"& .stm-icon":{color:Y.color.text.disabled},"input:hover + &":{backgroundColor:"transparent",boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.border.highlight.secondary} inset`},"@supports selector(:focus-visible)":{".inactive input:hover + &":{backgroundColor:"transparent",boxShadow:`0px 0px 0px ${Y.border.size.S} ${Y.color.border.highlight.secondary} inset`}}}),Ue=O["default"].span.withConfig({componentId:"sc-1qsyo39-1"})({display:"none",position:"absolute",left:"50%",bottom:"-10px",transform:"translateX(-50%)",borderRadius:"50%"},({$visible:e})=>e&&{display:"block"}),_e={"hand-holding-box-solid":"FaHandHoldingBoxSolid","truck-solid":"FaTruckSolid"},He=({disabled:e=!1,text:t=""})=>{const[s,{loading:i}]=(0,Ye.A)(),n=i?s.loading:s.notAvailable,o=e?n:t;return(0,f.jsx)(d.EY.UI,{size:"small",children:o})},qe=({className:e,icon:t,inputId:s,labelText:i,subLabelText:n,disabled:o,checked:r,...a})=>{const l=t?_e[t]:void 0;return(0,f.jsxs)("label",{"aria-disabled":o,className:[e,o?"inactive":""].join(" "),htmlFor:s,children:[(0,f.jsx)("input",{checked:r,className:(0,G.css)({srOnly:!0}),id:s,type:"radio",...a}),(0,f.jsx)(Oe,{$disabled:o,role:"presentation",children:(0,f.jsxs)(d.aP,{align:"center",alignInline:"center",gap:"none",children:[(0,f.jsx)(d.ob,{alignBlock:"center",gap:"none",children:l&&(0,f.jsx)(d.In,{iconName:l,size:"lg"})}),(0,f.jsxs)(d.aP,{gap:"3xs",children:[(0,f.jsx)(d.EY.H6,{children:i}),(0,f.jsx)(He,{disabled:Boolean(o),text:n}),(0,f.jsx)(Ue,{$visible:r,children:(0,f.jsx)(d.In,{iconName:"FaCircleSolid",css:{color:"white"}})}),(0,f.jsx)(Ue,{$visible:r,children:(0,f.jsx)(d.In,{iconName:"FaCircleCheckSolid",css:{color:"blue.400"}})})]})]})})]})};qe.displayName="ShipmentGroupButton";const Re=(0,O["default"])(qe).withConfig({componentId:"sc-1qsyo39-2"})({width:"100%",minWidth:"6rem",display:"block"}),We=(0,O["default"])("fieldset").withConfig({componentId:"sc-1nzb2fx-0"})({width:"100%",padding:Y.space.none,border:"none",margin:Y.space.none,marginTop:Y.space.S,display:"flex",alignItems:"center",justifyContent:"center"}),Ke=(0,l.styled)(d.EY.H2,{base:{marginTop:"s",marginBottom:"-xs"}},{defaultProps:{size:"s"}}),Ve=(0,l.styled)("div",{base:{marginTop:"m","& .NotificationTitle":{width:"100%",display:"block",paddingBottom:"2xs"},"& .NotificationParagraph":{width:"100%",paddingBottom:"xs",_last:{paddingBottom:"none"}}}}),Je=({groups:e})=>{const[t]=(0,De.A)("checkout"),s=(0,p.d4)(u.Ct),{t:n}=(0,i.A)("checkout.ondemand",{keyPrefix:"shipmentGroups.noAvailableMethods"}),{translateError:o}=(0,Xe.A)(),r=(0,h.A)(),a=(0,p.d4)(u.qM),l=(0,p.d4)(u.Cc),m=(0,p.d4)(T.Gc),x=(0,p.d4)(u.dX),b=(0,p.d4)(u.SZ),j=(0,p.d4)(u.hf),k=e.find(e=>e.fields?.type===l)?.fields?.subTitle;(0,c.useEffect)(()=>{l&&r((0,g.a6)(l))},[r,l]);const S=(0,c.useCallback)(e=>{a&&x[e.target.value]?(r((0,Fe.BE)({newMode:e.target.value,preselectedMode:m?.preferredShoppingMode})),r((0,g.a6)(e.target.value))):e.preventDefault()},[x,r,a,m?.preferredShoppingMode]);return(0,f.jsxs)(d.aP,{gap:"none",children:[!b&&(0,f.jsx)(We,{role:"radiogroup",children:(0,f.jsx)(d.ob,{className:"shipment-group-selector",gap:"xs",wrap:!1,children:e.map(({fields:e},t)=>{const{type:s=Ge.Q,icon:i="truck",title:n="",description:o=""}=e||{};return(0,f.jsx)(Re,{checked:a&&s===l,disabled:!x[s],icon:i,inputId:`${s}-shipment-group-button`,labelText:n,name:`shipment-group`,subLabelText:o,value:s,onChange:S},t)})})}),j&&!b&&(0,f.jsx)(Ve,{css:{marginBottom:"none"},children:(0,f.jsx)(d.Eg,{appearance:"info",children:(0,f.jsx)(d.Eg.Paragraph,{children:t.emailDeliveryNotification})})}),(!b||!a)&&k&&(0,f.jsx)(Ke,{children:k}),!a&&(0,f.jsx)(Ve,{children:(0,f.jsxs)(d.Eg,{appearance:"alert",children:[(0,f.jsx)(d.Eg.Title,{children:n(e=>e.title)}),s?(0,f.jsx)(d.Eg.Paragraph,{children:o(s)}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(d.Eg.Paragraph,{children:n(e=>e.fallbackErrorMessage.paragraph1)}),(0,f.jsxs)(d.Eg.Paragraph,{children:[n(e=>e.fallbackErrorMessage.paragraph2.intro),(0,f.jsxs)("ul",{children:[(0,f.jsxs)("li",{children:[n(e=>e.fallbackErrorMessage.paragraph2.listitem1),(0,f.jsx)("br",{}),n(e=>e.fallbackErrorMessage.paragraph2.or)]}),(0,f.jsx)("li",{children:n(e=>e.fallbackErrorMessage.paragraph2.listitem2)}),(0,f.jsx)("li",{children:n(e=>e.fallbackErrorMessage.paragraph2.listitem3)})]})]})]})]})})]})},Qe=({shipmentMethodGroups:e})=>{const t=(0,p.d4)(u.A0);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Je,{groups:e}),e?.filter(e=>e.fields.type===t).map(e=>(e.fields.shipmentMethodGroups||[]).map((t,s)=>t?(0,f.jsx)(c.Fragment,{children:(0,f.jsx)(Ne,{combinedPostLockerMethod:t.fields.combinedPostLockerMethod,shipmentMethods:t.fields.shipmentMethods,title:t.fields.title})},`${e.sys.id}-${s}`):null))]})},Ze=({checkoutStep:e,mainContent:t})=>{const{t:s}=(0,i.A)("common"),l=(e=>(0,n._C)(e)?o.TQ:(0,n.Kd)(e)?o.F_:"cart")(e),d=t?.filter(e=>void 0!==e&&(0,r.uC)(e))||[],c=!Array.isArray(d)||!d.length;return(0,f.jsxs)(a.A,{main:!1,step:l,title:s(e=>e.cartSteps.title,{context:l}),children:[l===o.F_&&(0,f.jsx)(C,{mainContent:t}),l!==o.F_&&c&&t?.map((e,t)=>{const s=`${e?.sys.contentType.sys.id}-${t}`;if(e&&(0,r.wm)(e))return(0,f.jsx)(Ne,{combinedPostLockerMethod:e.f
1ields.combinedPostLockerMethod,fallback:!0,shipmentMethods:e.fields.shipmentMethods,title:e.fields.title},s)}),l!==o.F_&&!c&&(0,f.jsx)(Qe,{shipmentMethodGroups:d})]})}}}]); 2//# sourceMappingURL=/assets/maps/9456.ba39d458ec.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.