import{A as Se,D as Me,E as Pe,F as M,j as ae,k as de,m as he,n as ue,o as le,p as pe,q as ve,r as ye,s as me,t as ge,u as Ce,v as fe,w as De,x as Ee}from"./chunk-CWWVHRJU.js";import{H as S}from"./chunk-WZSFHN7K.js";import{Af as q,Ce as F,E as X,Ge as I,J as y,N as R,Ng as K,Og as ne,Pe as Q,Rg as ce,bg as x,da as f,ga as D,hh as E,id as ee,ih as G,jh as _,kh as g,la as v,ma as Y,md as Z,na as j,nf as B,oa as n,od as W,pa as T,pf as N,rh as C,s as p,t as b,td as w,te,tg as ie,u as V,ua as L,uf as m,ug as se,ve as re,wg as oe}from"./chunk-N6B2OJOY.js";import{a as k,b as A}from"./chunk-GHL4OFBQ.js";var U=class{},Te=(()=>{let r=class r{constructor(e){this.adapter=e}createAddress(e,t,i){return this.adapter.createAddress(e,t,i)}setAddress(e,t,i){return this.adapter.setAddress(e,t,i)}clearCheckoutDeliveryAddress(e,t){return this.adapter.clearCheckoutDeliveryAddress(e,t)}};r.\u0275fac=function(t){return new(t||r)(n(U))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),O=class{},we=(()=>{let r=class r{constructor(e){this.adapter=e}setMode(e,t,i){return this.adapter.setMode(e,t,i)}getSupportedModes(e,t){return this.adapter.getSupportedModes(e,t)}clearCheckoutDeliveryMode(e,t){return this.adapter.clearCheckoutDeliveryMode(e,t)}};r.\u0275fac=function(t){return new(t||r)(n(O))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),H=class{},Fe=(()=>{let r=class r{constructor(e){this.adapter=e}createPaymentDetails(e,t,i){return this.adapter.createPaymentDetails(e,t,i)}setPaymentDetails(e,t,i){return this.adapter.setPaymentDetails(e,t,i)}getPaymentCardTypes(){return this.adapter.getPaymentCardTypes()}};r.\u0275fac=function(t){return new(t||r)(n(H))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),$=class{},Ie=(()=>{let r=class r{constructor(e){this.adapter=e}getCheckoutDetails(e,t){return this.adapter.getCheckoutDetails(e,t)}};r.\u0275fac=function(t){return new(t||r)(n($))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),ke=(()=>{let r=class r{constructor(e,t,i,o,c,u){this.activeCartFacade=e,this.userIdService=t,this.eventService=i,this.commandService=o,this.checkoutDeliveryAddressConnector=c,this.checkoutQueryFacade=u,this.createDeliveryAddressCommand=this.commandService.create(l=>this.checkoutPreconditions().pipe(f(([d,a])=>this.checkoutDeliveryAddressConnector.createAddress(d,a,l).pipe(p(h=>(h.titleCode=l.titleCode,l.region?.isocodeShort&&(h.region=A(k({},h.region),{isocodeShort:l.region.isocodeShort})),h)),D(h=>this.eventService.dispatch({userId:d,cartId:a,address:h},he))))),{strategy:E.CancelPrevious}),this.setDeliveryAddressCommand=this.commandService.create(l=>this.checkoutPreconditions().pipe(f(([d,a])=>{let h=l.id;if(!h)throw new Error("Checkout conditions not met");return this.checkoutDeliveryAddressConnector.setAddress(d,a,h).pipe(D(()=>{this.eventService.dispatch({userId:d,cartId:a,address:l},ue)}))})),{strategy:E.CancelPrevious}),this.clearDeliveryAddressCommand=this.commandService.create(()=>this.checkoutPreconditions().pipe(f(([l,d])=>this.checkoutDeliveryAddressConnector.clearCheckoutDeliveryAddress(l,d).pipe(D(()=>{this.eventService.dispatch({userId:l,cartId:d},le)})))),{strategy:E.CancelPrevious})}checkoutPreconditions(){return b([this.userIdService.takeUserId(),this.activeCartFacade.takeActiveCartId(),this.activeCartFacade.isGuestCart()]).pipe(R(1),p(([e,t,i])=>{if(!e||!t||e===F&&!i)throw new Error("Checkout conditions not met");return[e,t]}))}getDeliveryAddressState(){return this.checkoutQueryFacade.getCheckoutDetailsState().pipe(p(e=>A(k({},e),{data:e.data?.deliveryAddress})))}createAndSetAddress(e){return this.createDeliveryAddressCommand.execute(e)}setDeliveryAddress(e){return this.setDeliveryAddressCommand.execute(e)}clearCheckoutDeliveryAddress(){return this.clearDeliveryAddressCommand.execute()}};r.\u0275fac=function(t){return new(t||r)(n(S),n(I),n(q),n(G),n(Te),n(M))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),Ae=(()=>{let r=class r{getCheckoutSupportedDeliveryModesQueryReloadEvents(){return[me]}getCheckoutSupportedDeliveryModesQueryResetEvents(){return[ge]}constructor(e,t,i,o,c,u,l){this.activeCartFacade=e,this.userIdService=t,this.eventService=i,this.queryService=o,this.commandService=c,this.checkoutDeliveryModesConnector=u,this.checkoutQueryFacade=l,this.supportedDeliveryModesQuery=this.queryService.create(()=>this.checkoutPreconditions().pipe(f(([d,a])=>this.checkoutDeliveryModesConnector.getSupportedModes(d,a))),{reloadOn:this.getCheckoutSupportedDeliveryModesQueryReloadEvents(),resetOn:this.getCheckoutSupportedDeliveryModesQueryResetEvents()}),this.setDeliveryModeCommand=this.commandService.create(d=>this.checkoutPreconditions().pipe(f(([a,h])=>this.checkoutDeliveryModesConnector.setMode(a,h,d).pipe(D(()=>{this.eventService.dispatch({userId:a,cartId:h,cartCode:h,deliveryModeCode:d},pe)})))),{strategy:E.CancelPrevious}),this.clearDeliveryModeCommand=this.commandService.create(()=>this.checkoutPreconditions().pipe(f(([d,a])=>this.checkoutDeliveryModesConnector.clearCheckoutDeliveryMode(d,a).pipe(D({next:()=>{this.eventService.dispatch({userId:d,cartId:a,cartCode:a},ve)},error:()=>{this.eventService.dispatch({userId:d,cartId:a,cartCode:a},ye)}})))),{strategy:E.CancelPrevious})}checkoutPreconditions(){return b([this.userIdService.takeUserId(),this.activeCartFacade.takeActiveCartId(),this.activeCartFacade.isGuestCart()]).pipe(R(1),p(([e,t,i])=>{if(!e||!t||e===F&&!i)throw new Error("Checkout conditions not met");return[e,t]}))}getSupportedDeliveryModesState(){return this.supportedDeliveryModesQuery.getState()}getSupportedDeliveryModes(){return this.getSupportedDeliveryModesState().pipe(X(e=>!e.loading),p(e=>e.data??[]))}getSelectedDeliveryModeState(){return this.checkoutQueryFacade.getCheckoutDetailsState().pipe(p(e=>A(k({},e),{data:e.data?.deliveryMode})))}setDeliveryMode(e){return this.setDeliveryModeCommand.execute(e)}clearCheckoutDeliveryMode(){return this.clearDeliveryModeCommand.execute()}};r.\u0275fac=function(t){return new(t||r)(n(S),n(I),n(q),n(_),n(G),n(we),n(M))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),be=(()=>{let r=class r{getCheckoutPaymentCardTypesQueryReloadEvents(){return[De]}getCheckoutPaymentCardTypesQueryResetEvents(){return[Ee]}constructor(e,t,i,o,c,u,l){this.activeCartFacade=e,this.userIdService=t,this.queryService=i,this.commandService=o,this.eventService=c,this.checkoutPaymentConnector=u,this.checkoutQueryFacade=l,this.paymentCardTypesQuery=this.queryService.create(()=>this.checkoutPaymentConnector.getPaymentCardTypes(),{reloadOn:this.getCheckoutPaymentCardTypesQueryReloadEvents(),resetOn:this.getCheckoutPaymentCardTypesQueryResetEvents()}),this.createPaymentMethodCommand=this.commandService.create(d=>this.checkoutPreconditions().pipe(f(([a,h])=>this.checkoutPaymentConnector.createPaymentDetails(a,h,d).pipe(D(P=>this.eventService.dispatch({userId:a,cartId:h,paymentDetails:P},Ce))))),{strategy:E.CancelPrevious}),this.setPaymentMethodCommand=this.commandService.create(d=>this.checkoutPreconditions().pipe(f(([a,h])=>{let P=d?.id;if(!P)throw new Error("Checkout conditions not met");return this.checkoutPaymentConnector.setPaymentDetails(a,h,P).pipe(D(()=>this.eventService.dispatch({userId:a,cartId:h,paymentDetailsId:P},fe)))})),{strategy:E.CancelPrevious})}checkoutPreconditions(){return b([this.userIdService.takeUserId(),this.activeCartFacade.takeActiveCartId(),this.activeCartFacade.isGuestCart()]).pipe(R(1),p(([e,t,i])=>{if(!e||!t||e===F&&!i)throw new Error("Checkout conditions not met");return[e,t]}))}getPaymentCardTypesState(){return this.paymentCardTypesQuery.getState()}getPaymentCardTypes(){return this.getPaymentCardTypesState().pipe(p(e=>e.data??[]))}getPaymentDetailsState(){return this.checkoutQueryFacade.getCheckoutDetailsState().pipe(p(e=>A(k({},e),{data:e.data?.paymentInfo})))}createPaymentDetails(e){return this.createPaymentMethodCommand.execute(e)}setPaymentDetails(e){return this.setPaymentMethodCommand.execute(e)}};r.\u0275fac=function(t){return new(t||r)(n(S),n(I),n(_),n(G),n(q),n(Fe),n(M))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),Re=(()=>{let r=class r{getCheckoutQueryReloadEvents(){return[ae]}getCheckoutQueryResetEvents(){return[de]}constructor(e,t,i,o){this.activeCartFacade=e,this.userIdService=t,this.queryService=i,this.checkoutConnector=o,this.checkoutQuery$=this.queryService.create(()=>this.checkoutPreconditions().pipe(f(([c,u])=>this.checkoutConnector.getCheckoutDetails(c,u))),{reloadOn:this.getCheckoutQueryReloadEvents(),resetOn:this.getCheckoutQueryResetEvents()})}checkoutPreconditions(){return b([this.userIdService.takeUserId(),this.activeCartFacade.takeActiveCartId(),this.activeCartFacade.isGuestCart()]).pipe(R(1),p(([e,t,i])=>{if(!e||!t||e===F&&!i)throw new Error("Checkout conditions not met");return[e,t]}))}getCheckoutDetailsState(){return this.checkoutQuery$.getState()}};r.\u0275fac=function(t){return new(t||r)(n(S),n(I),n(_),n(Ie))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),$e=[ke,{provide:Se,useExisting:ke},Ae,{provide:Me,useExisting:Ae},be,{provide:Pe,useExisting:be},Re,{provide:M,useExisting:Re}],je=(()=>{let r=class r extends K{constructor(e,t,i){super(),this.translationService=e,this.activeCartFacade=t,this.basePageMetaResolver=i,this.pageType=re.CONTENT_PAGE,this.pageTemplate="MultiStepCheckoutSummaryPageTemplate"}resolveTitle(){return this.basePageMetaResolver.resolveTitle()}resolveHeading(){return this.translationService.translate("pageMetaResolver.checkout.title")}resolveDescription(){return this.basePageMetaResolver.resolveDescription()}resolveRobots(){return this.basePageMetaResolver.resolveRobots()}};r.\u0275fac=function(t){return new(t||r)(n(ne),n(S),n(ce))},r.\u0275prov=v({token:r,factory:r.\u0275fac,providedIn:"root"});let s=r;return s})(),tt=(()=>{let r=class r{};r.\u0275fac=function(t){return new(t||r)},r.\u0275mod=L({type:r}),r.\u0275inj=Y({providers:[...$e,Te,we,Fe,Ie,je,{provide:K,useExisting:je,multi:!0}]});let s=r;return s})(),Qe=new j("DeliveryModeNormalizer"),Ne=new j("PaymentDetailsSerializer"),xe=new j("PaymentCardTypeNormalizer"),Ue=new j("CheckoutNormalizer");var Ye=(()=>{let r=class r{constructor(e,t,i){this.http=e,this.occEndpoints=t,this.converter=i,this.logger=T(Q)}createAddress(e,t,i){return i=this.converter.convert(i,se),this.http.post(this.getCreateDeliveryAddressEndpoint(e,t),i,{headers:new Z().set("Content-Type","application/json")}).pipe(y(o=>{throw m(o,this.logger)}),C({shouldRetry:g}),this.converter.pipeable(ie))}getCreateDeliveryAddressEndpoint(e,t){return this.occEndpoints.buildUrl("createDeliveryAddress",{urlParams:{userId:e,cartId:t}})}setAddress(e,t,i){return this.http.put(this.getSetDeliveryAddressEndpoint(e,t,i),{}).pipe(y(o=>{throw m(o,this.logger)}),C({shouldRetry:g}))}getSetDeliveryAddressEndpoint(e,t,i){return this.occEndpoints.buildUrl("setDeliveryAddress",{urlParams:{userId:e,cartId:t},queryParams:{addressId:i}})}clearCheckoutDeliveryAddress(e,t){return this.http.delete(this.getRemoveDeliveryAddressEndpoint(e,t)).pipe(y(i=>{throw m(i,this.logger)}),C({shouldRetry:g}))}getRemoveDeliveryAddressEndpoint(e,t){return this.occEndpoints.buildUrl("removeDeliveryAddress",{urlParams:{userId:e,cartId:t}})}};r.\u0275fac=function(t){return new(t||r)(n(w),n(N),n(x))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),Le=(()=>{let r=class r{constructor(e,t,i){this.http=e,this.occEndpoints=t,this.converter=i,this.logger=T(Q)}setMode(e,t,i){return this.http.put(this.getSetDeliveryModeEndpoint(e,t,i),{}).pipe(y(o=>{throw m(o,this.logger)}),C({shouldRetry:g}))}getSetDeliveryModeEndpoint(e,t,i){return this.occEndpoints.buildUrl("setDeliveryMode",{urlParams:{userId:e,cartId:t},queryParams:{deliveryModeId:i}})}getSupportedModes(e,t){return this.http.get(this.getDeliveryModesEndpoint(e,t)).pipe(y(i=>{throw m(i,this.logger)}),C({shouldRetry:g}),p(i=>i.deliveryModes??[]),this.converter.pipeableMany(Qe))}getDeliveryModesEndpoint(e,t){return this.occEndpoints.buildUrl("deliveryModes",{urlParams:{userId:e,cartId:t}})}clearCheckoutDeliveryMode(e,t){return this.http.delete(this.getClearDeliveryModeEndpoint(e,t)).pipe(y(i=>{throw m(i,this.logger)}),C({shouldRetry:g}))}getClearDeliveryModeEndpoint(e,t){return this.occEndpoints.buildUrl("clearDeliveryMode",{urlParams:{userId:e,cartId:t}})}};r.\u0275fac=function(t){return new(t||r)(n(w),n(N),n(x))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),Ze=(()=>{let r=class r{constructor(e,t,i){this.http=e,this.occEndpoints=t,this.converter=i,this.logger=T(Q),typeof DOMParser<"u"&&(this.domparser=new DOMParser)}createPaymentDetails(e,t,i){return i=this.converter.convert(i,Ne),this.getProviderSubInfo(e,t).pipe(p(o=>{let c=this.convertToMap(o.mappingLabels.entry);return{url:o.postUrl,parameters:this.getParamsForPaymentProvider(i,o.parameters.entry,c),mappingLabels:c}}),V(o=>this.createSubWithProvider(o.url,o.parameters).pipe(p(c=>this.extractPaymentDetailsFromHtml(c)),V(c=>(c.defaultPayment=i.defaultPayment??!1,c.savePaymentInfo=!0,this.createDetailsWithParameters(e,t,c).pipe(y(u=>{throw m(u,this.logger)}),C({shouldRetry:g}),this.converter.pipeable(oe)))))))}setPaymentDetails(e,t,i){return this.http.put(this.getSetPaymentDetailsEndpoint(e,t,i),{}).pipe(y(o=>{throw m(o,this.logger)}),C({shouldRetry:g}))}getSetPaymentDetailsEndpoint(e,t,i){return this.occEndpoints.buildUrl("setCartPaymentDetails",{urlParams:{userId:e,cartId:t},queryParams:{paymentDetailsId:i}})}getPaymentCardTypes(){return this.http.get(this.getPaymentCardTypesEndpoint()).pipe(y(e=>{throw m(e,this.logger)}),C({shouldRetry:g}),p(e=>e.cardTypes??[]),this.converter.pipeableMany(xe))}getPaymentCardTypesEndpoint(){return this.occEndpoints.buildUrl("cardTypes")}getProviderSubInfo(e,t){return this.http.get(this.getPaymentProviderSubInfoEndpoint(e,t)).pipe(y(i=>{throw m(i,this.logger)}),C({shouldRetry:g}))}getPaymentProviderSubInfoEndpoint(e,t){return this.occEndpoints.buildUrl("paymentProviderSubInfo",{urlParams:{userId:e,cartId:t}})}createSubWithProvider(e,t){let i=new Z({"Content-Type":"application/x-www-form-urlencoded",Accept:"text/html"}),o=new W({encoder:new B});return Object.keys(t).forEach(c=>{o=o.append(c,t[c])}),this.http.post(e,o,{headers:i,responseType:"text"}).pipe(y(c=>{throw m(c,this.logger)}),C({shouldRetry:g}))}createDetailsWithParameters(e,t,i){let o=new W({encoder:new B});Object.keys(i).forEach(u=>{o=o.append(u,i[u])});let c=new Z({"Content-Type":"application/x-www-form-urlencoded"});return this.http.post(this.getCreatePaymentDetailsEndpoint(e,t),o,{headers:c}).pipe(y(u=>{throw m(u,this.logger)}),C({shouldRetry:g}))}getCreatePaymentDetailsEndpoint(e,t){return this.occEndpoints.buildUrl("createPaymentDetails",{urlParams:{userId:e,cartId:t}})}getParamsForPaymentProvider(e,t,i){let o=this.convertToMap(t);return o[i.hybris_account_holder_name]=e.accountHolderName,o[i.hybris_card_type]=e.cardType?.code,o[i.hybris_card_number]=e.cardNumber,i.hybris_combined_expiry_date==="true"?o[i.hybris_card_expiry_date]=e.expiryMonth+i.hybris_separator_expiry_date+e.expiryYear:(o[i.hybris_card_expiration_month]=e.expiryMonth,o[i.hybris_card_expiration_year]=e.expiryYear),o[i.hybris_card_cvn]=e.cvn,o[i.hybris_billTo_country]=e.billingAddress?.country?.isocode,o[i.hybris_billTo_firstname]=e.billingAddress?.firstName,o[i.hybris_billTo_lastname]=e.billingAddress?.lastName,o[i.hybris_billTo_street1]=e.billingAddress?.line1+" "+e.billingAddress?.line2,o[i.hybris_billTo_city]=e.billingAddress?.town,e.billingAddress?.region?o[i.hybris_billTo_region]=e.billingAddress.region.isocodeShort:o[i.hybris_billTo_region]="",o[i.hybris_billTo_postalcode]=e.billingAddress?.postalCode,o}extractPaymentDetailsFromHtml(e){let o=this.domparser.parseFromString(e,"text/xml").getElementsByTagName("form")[0].getElementsByTagName("input"),c={};for(let u=0;o[u];u++){let l=o[u],d=l.getAttribute("name"),a=l.getAttribute("value");d&&d!=="{}"&&a&&a!==""&&(c[d]=a)}return c}convertToMap(e){return e.reduce(function(t,i){let o=i.key;return t[o]=i.value,t},{})}};r.\u0275fac=function(t){return new(t||r)(n(w),n(N),n(x))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),qe=(()=>{let r=class r{constructor(e,t,i){this.http=e,this.occEndpoints=t,this.converter=i,this.logger=T(Q)}getCheckoutDetails(e,t){return this.http.get(this.getGetCheckoutDetailsEndpoint(e,t)).pipe(y(i=>{throw m(i,this.logger)}),C({shouldRetry:g}),this.converter.pipeable(Ue))}getGetCheckoutDetailsEndpoint(e,t){return this.occEndpoints.buildUrl("getCheckoutDetails",{urlParams:{userId:e,cartId:t}})}};r.\u0275fac=function(t){return new(t||r)(n(w),n(N),n(x))},r.\u0275prov=v({token:r,factory:r.\u0275fac});let s=r;return s})(),J="users/${userId}/carts/${cartId}/addresses/delivery",z="users/${userId}/carts/${cartId}/deliverymode",Ge={backend:{occ:{endpoints:{setDeliveryAddress:J,cardTypes:"cardtypes",createDeliveryAddress:J,removeDeliveryAddress:J,deliveryMode:z,setDeliveryMode:z,clearDeliveryMode:z,deliveryModes:`${z}s`,setCartPaymentDetails:"users/${userId}/carts/${cartId}/paymentdetails",paymentProviderSubInfo:"users/${userId}/carts/${cartId}/payment/sop/request?responseUrl=sampleUrl",createPaymentDetails:"users/${userId}/carts/${cartId}/payment/sop/response",getCheckoutDetails:"users/${userId}/carts/${cartId}?fields=deliveryAddress(FULL),deliveryMode(FULL),paymentInfo(FULL)"}}}},pt=(()=>{let r=class r{};r.\u0275fac=function(t){return new(t||r)},r.\u0275mod=L({type:r}),r.\u0275inj=Y({providers:[te(Ge),{provide:$,useClass:qe},{provide:U,useClass:Ye},{provide:O,useClass:Le},{provide:H,useClass:Ze}],imports:[ee]});let s=r;return s})();export{U as a,Te as b,O as c,we as d,$ as e,ke as f,Ae as g,je as h,tt as i,Ye as j,Le as k,qe as l,pt as m};