import{a as xt,b as vt,c as yt,d as Fe,g as St,k as At,l as Lt,m as Ot,n as bt,q as It}from"./chunk-HNDR6KRA.js";import{a as Te}from"./chunk-BMJ323XM.js";import{a as Ut}from"./chunk-5XWSR7MO.js";import{d as ct}from"./chunk-CA5IAOZB.js";import{a as Ft}from"./chunk-SFHGDVHZ.js";import{b as Rt}from"./chunk-F3N5PU5V.js";import{b as $t}from"./chunk-GIYE4OKL.js";import{c as pt,d as ut,e as mt}from"./chunk-ZWOB5ADW.js";import{c as ht,e as _t,g as ft,n as gt}from"./chunk-XI2EB733.js";import{Cb as Ie,E as Le,Eb as P,I as Je,Pb as it,Rb as ot,Vb as rt,Xa as le,h as H,ib as Oe,jb as be,nb as Qe,tb as et,u as Ze,ub as tt}from"./chunk-GYYYM227.js";import{E as Mt,F as Bt,c as wt,e as x,h as Pt,i as Et,j as Dt,l as G,n as Vt,r as Nt,t as kt}from"./chunk-IWEPXOJK.js";import{a as st}from"./chunk-VAUNVSZV.js";import{a as nt}from"./chunk-Y77T26QU.js";import{V as lt}from"./chunk-YFWLORNM.js";import{c as Ct,d as Q}from"./chunk-XA6AU52H.js";import{g as ye,i as Se,k as Ye,m as Ae,o as ce}from"./chunk-DAYGRJHR.js";import{h as J,k as pe,n as at,q as dt}from"./chunk-767ZUJWF.js";import{D as O,d as c,e as p,s as Ke,v as m,w as je}from"./chunk-VYUKN3XQ.js";import{c as Xe}from"./chunk-AYHVL37M.js";import{h as de}from"./chunk-KXVCY5JT.js";import{v as He}from"./chunk-VTET4O2Q.js";import{a as Tt}from"./chunk-UF7XRCGB.js";import{Cc as w,Da as te,Ea as ie,Ec as re,Fc as ne,Ga as Be,Gc as se,Hc as g,Ic as h,Jc as We,K as X,Na as oe,Nc as ae,P as S,Q as K,Sa as R,Tb as Ue,Tc as U,Vb as A,Vc as F,Wb as $,Y as ke,Z as ge,_ as D,_a as Re,a as u,b as f,ca as Me,fd as _,ga as W,gc as Ce,hc as Ge,hd as xe,ia as j,id as ve,jb as z,kb as q,ma as B,od as ze,pc as L,sd as qe,t as fe,tb as $e,u as T,v as Ne,vc as Z,wd as V,xd as N,za as Y}from"./chunk-XNQ3RS5P.js";var wi=c("[Locations] Search Fixed Locations",p()),Pi=c("[Locations] Search Fixed Locations [Success]",p()),Ei=c("[Locations] Search Fixed Locations [Error]",p()),Di=c("[Locations] Get Fixed Location",p()),Vi=c("[Locations] Get Fixed Location [Success]",p()),Ni=c("[Locations] Get Fixed Location [Error]",p()),ki=c("[Location] Remove Search Fixed Locations"),Mi=c("[Location] Update Filter Input",p()),Bi=c("[Location] Clear Filter Input"),Gt=c("[Locations] Get Counties",p()),Ri=c("[Locations] Get Counties Success",p()),$i=c("[Locations] Get Counties Error",p()),Ui=c("[Locations] Get Localities",p()),Gi=c("[Locations] Get Localities Success",p()),Wi=c("[Locations] Get Localities Error",p()),zi=c("[Locations] Remove localities"),qi=c("[Locations] Set Location Marker",p()),Hi=c("[Locations] Set Location from map",p()),Xi=c("[Locations] Set Location from cart",p()),Ki=c("[Location] Set Location skeletons",p()),ji=c("[Location] Set favorite Location",p()),Yi=c("[Location] Set favorite Location Success",p()),Zi=c("[Location] Set favorite Location Error",p()),we=c("[Location] Get favorite or last used Location"),Ji=c("[Location] Get favorite or last used Location Success",p()),Qi=c("[Location] Get favorite or last used Location Error",p()),eo=c("[Location] Set County input",p()),to=c("[Location] Set Locality input",p()),io=c("[Location] Clear Address inputs");function Wt(t){let i=u({},t);return delete i.__typename,delete i.allowsDropOff,delete i.supportedPaymentType,delete i.schedule,delete i.restrictions,delete i.isFavorite,at(i)?null:i}var v=je("locations"),mo=m(v,t=>{var i;return(i=t.searchedFixedLocations)==null?void 0:i.data}),ho=m(v,t=>t.searchedFixedLocations.status),_o=m(v,t=>{var i;return(i=t.searchedFixedLocations)==null?void 0:i.request}),fo=m(v,t=>{var i;return(i=t.fixedLocation)==null?void 0:i.data}),go=m(v,t=>t.filterInput),Co=t=>({selector:v,action:()=>Gt({countryCode:t}),map:i=>{var n;return(n=i.counties)==null?void 0:n.data},shouldDispatch:i=>i.counties.status===O.initial}),xo=m(v,t=>{var i;return(i=t.localities)==null?void 0:i.data}),vo=m(v,t=>t.locationMarker),yo=m(v,t=>t==null?void 0:t.selectedLocation),So=m(v,t=>t.showSkeletons),Ao=()=>({selector:m(v,ye,(t,i)=>[t,i]),action:()=>we(),map:([t])=>t.favoriteOrLastUsedLocation,shouldDispatch:([t,i])=>i&&t.favoriteOrLastUsedLocation.status===O.initial}),Lo=()=>({selector:m(v,ye,(t,i)=>[t,i]),action:()=>we(),map:([t])=>{var i;return(i=t.favoriteOrLastUsedLocation)==null?void 0:i.data},shouldDispatch:([t,i])=>i&&t.favoriteOrLastUsedLocation.status===O.initial}),Oo=m(v,t=>t.favoriteOrLastUsedLocation.status),bo=m(v,t=>{var i;return(i=t.favoriteOrLastUsedLocation)==null?void 0:i.data}),Io=m(v,t=>{var i;return!!((i=t.favoriteOrLastUsedLocation)!=null&&i.data||t.selectedLocation)}),Fo=m(v,t=>{var i;return t.selectedLocation?t.selectedLocation:Wt((i=t.favoriteOrLastUsedLocation)==null?void 0:i.data)}),To=m(v,t=>t.selectedLocation||void 0),wo=m(v,t=>t.countyInput),Po=m(v,t=>t.localityInput);var Bo=f(u({},P),{map(t){var i,n,e;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetBilling))}}),Pe=f(u({},P),{map(t){var i,n,e;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetBilling))}}),zt=f(u({},P),{map(t){var i,n,e,o,s;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&(((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetBilling))||((s=(o=t==null?void 0:t.cart)==null?void 0:o.actions)==null?void 0:s.includes(H.SetBillingParty)))}}),Ro=f(u({},P),{map(t){var i,n,e;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((e=(n=t==null?void 0:t.cart)==null?void 0:n.actions)==null?void 0:e.includes(H.SetShipping))}}),ue=f(u({},P),{map:t=>{var i,n;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"?Te.fromCartBillingAddressToAddressRelation((n=t.cart)==null?void 0:n.billing):void 0}}),me=f(u({},P),{map:t=>{var i,n;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=t.cart)!=null&&n.shipping)?Te.fromCartShippingAddressToAddressRelation(t.cart.shipping):void 0},filter:t=>t.status===O.success||t.status===O.error}),$o=f(u({},P),{map:t=>{var i,n;return((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=t.cart.shipping)!=null&&n.shippingType)?t.cart.shipping.shippingType:void 0}}),qt=f(u({},P),{map:t=>t.newClientAcquisition.generateNewAddressOTP}),ee=f(u({},P),{map:t=>t.newClientAcquisition.verifyNewAddressOTP}),Uo=f(u({},P),{map:t=>{var i;return!!(((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&t.cart.isEligibleForLockers)}}),Go=m(Ie,t=>{var i,n;return!(((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource"&&((n=t.cart.shipping)!=null&&n.shippingType.fixedLocation))}),Wo=m(Ie,t=>{var i;if(((i=t.cart)==null?void 0:i.__typename)==="PendingCartResource")return t.shippingAddressSource});var he=function(t){return t[t.CUSTOMER=0]="CUSTOMER",t[t.FIXED_LOCATION=1]="FIXED_LOCATION",t[t.PICKUP_IN_STORE=2]="PICKUP_IN_STORE",t}(he||{}),_e=function(t){return t.CUSTOMER="customer",t.FIXED_LOCATION="fixed-location",t.PICKUP_IN_STORE="pickup-in-store",t}(_e||{}),Ho={[_e.CUSTOMER]:he.CUSTOMER,[_e.FIXED_LOCATION]:he.FIXED_LOCATION,[_e.PICKUP_IN_STORE]:he.PICKUP_IN_STORE},Ee=function(t){return t.validationErrors="validationErrors",t.maxOtpCodesVerificationAttempts="maxOtpCodesVerificationAttempts",t}(Ee||{}),De=function(t){return t.validationErrors="validationErrors",t.maxOtpCodesGenerationAttempts="maxOtpCodesGenerationAttempts",t.invalidOtpCode="invalidOtpCode",t}(De||{});var Xt=(()=>{let i=class i{constructor(e){this.httpClient=e,this.isDev=document.location.href.indexOf("localhost")>-1||document.location.href.indexOf("dev")>-1||document.location.href.indexOf("dev3")>-1,this.toggleUrl=this.isDev?"https://www-dev.orange.ro/webshopportlets/api/trafic-to-eshop":"https://www.orange.ro/webshopportlets/api/trafic-to-eshop"}isTrafficToNewShop(){return this.cache$||(this.cache$=this.httpClient.get(this.toggleUrl).pipe(Y(1))),this.cache$}checkIfIsDev(){return X(this.isDev)}};i.\u0275fac=function(o){return new(o||i)(R(de))},i.\u0275prov=oe({token:i,factory:i.\u0275fac,providedIn:"root"});let t=i;return t})();var ti=(t,i,n)=>({cartStatus:t,generateNewAddressOTP:i,verifyNewAddressOTP:n});function ii(t,i){t&1&&(g(0,"strong"),_(1),h()),t&2&&(A(),xe(" ",i,". "))}function oi(t,i){t&1&&We(0,"oro-skeleton-loader-line",16)}function ri(t,i){if(t&1){let n=ae();g(0,"input",17),U("keyup",function(o){let s=z(n).$implicit,a=F(2);return q(a.switchInput(o,s))}),h()}if(t&2){let n=i.$implicit;Z("formControlName",n)("id",n)}}function ni(t,i){t&1&&_(0," Codul este necesar. ")}function si(t,i){t&1&&_(0," Num\u0103r de caractere invalid. ")}function ai(t,i){if(t&1&&(g(0,"p",9),L(1,ni,1,0)(2,si,1,0),h()),t&2){let n=F(2);A(),w(1,!(n.inputOne==null||n.inputOne.errors==null)&&n.inputOne.errors.required?1:!(n.inputOne==null||n.inputOne.errors==null)&&n.inputOne.errors.minlength||!(n.inputOne==null||n.inputOne.errors==null)&&n.inputOne.errors.maxlength?2:-1)}}function di(t,i){t&1&&_(0),t&2&&xe(" \xEEn [",i,"] secunde ")}function li(t,i){t&1&&(g(0,"oro-alert",18),_(1," A intervenit o problem\u0103 \xEEn generarea codului OTP. Te rug\u0103m \xEEncearc\u0103 mai t\xE2rziu. "),h())}function ci(t,i){t&1&&(g(0,"oro-alert",18),_(1," Ai atins num\u0103rul maxim de coduri generate. "),h())}function pi(t,i){t&1&&(g(0,"oro-alert",18),_(1," Codul introdus este invalid. "),h())}function ui(t,i){if(t&1&&_(0),t&2){let n=F(2).$implicit;ve(" ",n.message,". Error code: ",n.extensions.errorCode," ")}}function mi(t,i){t&1&&_(0," A intervenit o eroare. ")}function hi(t,i){if(t&1&&(g(0,"oro-alert",18),L(1,ui,1,2),V(2,"async"),L(3,mi,1,0),h()),t&2){let n=F(4);A(),w(1,N(2,1,n.isDev$)?1:3)}}function _i(t,i){if(t&1&&L(0,li,2,0)(1,ci,2,0)(2,pi,2,0)(3,hi,4,3),t&2){let n,e=i.$implicit,o=F(3);w(0,(n=e.extensions.errorCode)===o.generateNewClientAcquisitionOTPTypeErrors.validationErrors?0:n===o.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts?1:n===o.generateNewClientAcquisitionOTPTypeErrors.invalidOtpCode?2:3)}}function fi(t,i){t&1&&ne(0,_i,4,1,null,null,re),t&2&&se(i.errors)}function gi(t,i){t&1&&(g(0,"oro-alert",18),_(1," Codul introdus nu coincide cu cel primit prin sms. Te rog s\u0103 reintroduci codul. "),h())}function Ci(t,i){t&1&&(g(0,"oro-alert",18),_(1," Ai atins num\u0103rul maxim de coduri pentru ast\u0103zi. Te rug\u0103m s\u0103 \xEEncerci peste 24h. "),h())}function xi(t,i){if(t&1&&_(0),t&2){let n=F(2).$implicit;ve(" ",n.message,". Error code: ",n.extensions.errorCode," ")}}function vi(t,i){t&1&&_(0," A intervenit o eroare. ")}function yi(t,i){if(t&1&&(g(0,"oro-alert",18),L(1,xi,1,2),V(2,"async"),L(3,vi,1,0),h()),t&2){let n=F(4);A(),w(1,N(2,1,n.isDev$)?1:3)}}function Si(t,i){if(t&1&&L(0,gi,2,0)(1,Ci,2,0)(2,yi,4,3),t&2){let n,e=i.$implicit,o=F(3);w(0,(n=e.extensions.errorCode)===o.validationNumberTypeErrors.validationErrors?0:n===o.validationNumberTypeErrors.maxOtpCodesVerificationAttempts?1:2)}}function Ai(t,i){t&1&&ne(0,Si,3,1,null,null,re),t&2&&se(i.errors)}function Li(t,i){if(t&1){let n=ae();g(0,"button",19),U("click",function(){z(n);let o=F(2);return q(o.forceCheckSMSCode(!0))}),_(1," For\u021Beaz\u0103 validarea "),h()}}function Oi(t,i){if(t&1){let n=ae();g(0,"div",0)(1,"div",1)(2,"h3",2),_(3,"Cod PIN"),h(),g(4,"button",3),U("click",function(){z(n);let o=F();return q(o.cancel())}),g(5,"span",4),_(6,"\xD7"),h()()(),g(7,"div",5)(8,"p",6),_(9," Pentru a continua procesul, introdu codul de validare primit prin SMS la num\u0103rul "),L(10,ii,2,1,"strong"),V(11,"async"),L(12,oi,1,0),h(),g(13,"form",7),ne(14,ri,1,2,"input",8,re),h(),L(16,ai,3,1,"p",9),g(17,"div",10)(18,"p",11),_(19,"Nu ai primit codul PIN?"),h(),g(20,"button",12),U("click",function(){z(n);let o=F();return q(o.sendCodeAgain())}),_(21," Retrimite cod "),L(22,di,1,1),V(23,"async"),h()(),L(24,fi,2,0)(25,Ai,2,0),h(),g(26,"div",13)(27,"button",14),U("click",function(){z(n);let o=F();return q(o.checkSMSCode())}),_(28," Valideaz\u0103 "),h(),L(29,Li,2,0,"button",15),V(30,"async"),h()()}if(t&2){let n,e,o,s,a=i,r=F();A(10),w(10,(n=N(11,9,r.notificationMsisdn$))?10:12,n),A(3),Z("formGroup",r.form),A(),se(r.otpFields),A(2),w(16,r.inputOne!=null&&r.inputOne.touched?16:-1),A(4),Z("disabled",a.cartStatus===r.XhrStatus.loading||r.disableResendButton||!r.countdownCompleted||r.disableValidationButton),A(2),w(22,(e=!r.countdownCompleted&&N(23,11,r.countdown$))?22:-1,e),A(2),w(24,(o=a.generateNewAddressOTP)?24:-1,o),A(),w(25,(s=a.verifyNewAddressOTP)?25:-1,s),A(2),Z("disabled",r.form.invalid||a.cartStatus===r.XhrStatus.loading||r.disableValidationButton),A(2),w(29,N(30,13,r.isImpersonating$)?29:-1)}}var Kt=window;Kt.dataLayer=Kt.dataLayer||[];var jt=(()=>{let i=class i extends nt{constructor(e,o,s,a,r,d){super(),this.dialogRef=e,this.storeSelector=o,this.trafficService=s,this.cartDeliveryAddressService=a,this.elementRef=r,this.data=d,this.otpFields=["one","two","three","four","five","six"],this.XhrStatus=O,this.validationNumberTypeErrors=Ee,this.generateNewClientAcquisitionOTPTypeErrors=De,this.countdownCompleted=!0,this.form=new Dt({one:new G("",[x.required,x.minLength(1),x.maxLength(1)]),two:new G("",[x.required,x.minLength(1),x.maxLength(1)]),three:new G("",[x.required,x.minLength(1),x.maxLength(1)]),four:new G("",[x.required,x.minLength(1),x.maxLength(1)]),five:new G("",[x.required,x.minLength(1),x.maxLength(1)]),six:new G("",[x.required,x.minLength(1),x.maxLength(1)])}),this.isImpersonating$=this.storeSelector.getWithSelector(Ye)}get inputOne(){return this.form.get("one")}get inputTwo(){return this.form.get("two")}get inputThree(){return this.form.get("three")}get inputFour(){return this.form.get("four")}get inputFive(){return this.form.get("five")}get inputSix(){return this.form.get("six")}onClick(e){this.elementRef.nativeElement.contains(e.target)||this.closeAddressForm()}ngOnInit(){this.generateNewAddressOTP$=this.storeSelector.getWithSelector(qt),this.verifyNewAddressOTP$=this.storeSelector.getWithSelector(ee),this.cartStatus$=this.storeSelector.getWithSelector(rt),this.isDev$=this.trafficService.checkIfIsDev(),this.notificationMsisdn$=this.generateNewAddressOTP$.pipe(S(e=>e.msisdn)),this.checkIfNeedToDisableButtons(),this.verifyNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(e=>{e&&e.verified===!0&&(this.data.isCompleteOrder||(this.data.address?this.cartDeliveryAddressService.handleEditDeliveryAddress(this.data.address):this.cartDeliveryAddressService.handleAddDeliveryAddress()),this.dialogRef.close(this.data.isCompleteOrder))}),this.startCountdown()}checkSMSCode(){var e,o,s,a,r,d,l;if(this.form.valid&&((e=this.inputOne)!=null&&e.value)){let C=((o=this.inputOne)==null?void 0:o.value)+((s=this.inputTwo)==null?void 0:s.value)+((a=this.inputThree)==null?void 0:a.value)+((r=this.inputFour)==null?void 0:r.value)+((d=this.inputFive)==null?void 0:d.value)+((l=this.inputSix)==null?void 0:l.value);this.cartDeliveryAddressService.handleVerifyNewAddressOTP(C),this.track("Add Address - Validate PIN")}}forceCheckSMSCode(e){e&&(this.cartDeliveryAddressService.handleVerifyNewAddressOTP("",e),this.track("Add Address - Validate PIN"))}sendCodeAgain(){this.startCountdown(),this.cartDeliveryAddressService.generateNewAddressOTP(),this.track("Add Address - Resend PIN")}switchInput(e,o){var b,y,I,k,M,Ve;let s=document.getElementById("one"),a=document.getElementById("two"),r=document.getElementById("three"),d=document.getElementById("four"),l=document.getElementById("five"),C=document.getElementById("six");if(s.value.length===6){let E=s.value;s.value="",(b=this.inputOne)==null||b.setValue(E[0]),s.value=E[0],(y=this.inputTwo)==null||y.setValue(E[1]),a.value=E[1],(I=this.inputThree)==null||I.setValue(E[2]),r.value=E[2],(k=this.inputFour)==null||k.setValue(E[3]),d.value=E[3],(M=this.inputFive)==null||M.setValue(E[4]),l.value=E[4],(Ve=this.inputSix)==null||Ve.setValue(E[5]),C.value=E[5],C.focus();return}if(s.value&&s.value.length>1){s.value="";return}if(a.value&&a.value.length>1){a.value="";return}if(r.value&&r.value.length>1){r.value="";return}if(d.value&&d.value.length>1){d.value="";return}if(l.value&&l.value.length>1){l.value="";return}if(C.value&&C.value.length>1){C.value="";return}if(o==="one"&&s.value.length===1){a==null||a.focus();return}if(o==="two"&&a.value.length===1){r==null||r.focus();return}if(o==="three"&&r.value.length===1){d==null||d.focus();return}if(o==="four"&&d.value.length===1){l==null||l.focus();return}o==="five"&&l.value.length===1&&(C==null||C.focus()),e.key==="Backspace"&&(o==="six"&&(C.value="",l.focus()),o==="five"&&(l.value="",d.focus()),o==="four"&&(d.value="",r.focus()),o==="three"&&(r.value="",a.focus()),o==="two"&&(a.value="",s.focus()),o==="one"&&(s.value=""))}checkIfNeedToDisableButtons(){this.generateNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(e=>{e.errors?e.errors.forEach(o=>{this.disableResendButton=o.extensions.errorCode===this.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts}):this.disableResendButton=!1}),this.verifyNewAddressOTP$.pipe(ie(this.destroyed$)).subscribe(e=>{e.errors?e.errors.forEach(o=>{this.disableValidationButton=o.extensions.errorCode===this.validationNumberTypeErrors.maxOtpCodesVerificationAttempts}):this.disableValidationButton=!1})}cancel(){this.dialogRef.close(),this.closeAddressForm()}closeAddressForm(){this.cartDeliveryAddressService._newCustomerDeliveryAddress.next({}),this.cartDeliveryAddressService.handleCloseDeliveryAddressForm(),this.track("Cancel Add Address")}track(e){let o={event:ht.MIKRO_USER_CLICK,event_action:_t.CHECKOUT_DELIVERY_OPTIONS,event_category:ft.CHECKOUT,event_label:e,event_value:gt.ZERO};Ft.analyticsPush(o)}startCountdown(){this.countdownCompleted=!1;let e=60;this.countdown$=ke(1e3).pipe(W(e+1),S(o=>e-o),S(o=>(this.countdownCompleted=o===0,o)))}};i.\u0275fac=function(o){return new(o||i)($(pt),$(ce),$(Xt),$(Yt),$($e),$(ut))},i.\u0275cmp=Re({type:i,selectors:[["oro-otp-address-validation"]],hostBindings:function(o,s){o&1&&U("click",function(r){return s.onClick(r)},!1,Ue)},standalone:!0,features:[Ge,ze],decls:4,vars:11,consts:[[1,"otp-modal"],[1,"otp-modal__header"],[1,"otp-modal__tile"],["aria-label","Close",1,"otp-modal__close-button",3,"click"],["aria-hidden","true"],[1,"otp-modal__body"],[1,"otp-modal__description"],[1,"otp-modal__form",3,"formGroup"],["matInput","","type","text",1,"otp-modal__input",3,"formControlName","id"],[1,"otp-modal__error"],[1,"otp-modal__retry"],[1,"otp-modal__retry-text"],[1,"otp-modal__retry-button",3,"click","disabled"],[1,"otp-modal__footer"],[1,"btn","btn-primary",3,"click","disabled"],[1,"btn","btn-danger"],["height","15px","width","99px",2,"display","inline-block"],["matInput","","type","text",1,"otp-modal__input",3,"keyup","formControlName","id"],["type","error",1,"otp-modal__alert"],[1,"btn","btn-danger",3,"click"]],template:function(o,s){if(o&1&&(L(0,Oi,31,15,"div",0),V(1,"async"),V(2,"async"),V(3,"async")),o&2){let a;w(0,(a=qe(7,ti,N(1,1,s.cartStatus$),N(2,3,s.generateNewAddressOTP$),N(3,5,s.verifyNewAddressOTP$)))?0:-1,a)}},dependencies:[Mt,Vt,wt,Pt,Et,Bt,Nt,kt,$t,Rt,He,Tt],styles:[".mat-mdc-dialog-container{border-radius:4px!important;padding:0;margin:1rem} .mat-mdc-dialog-container .mat-mdc-dialog-surface{padding:0} body.modal-open{height:100vh;overflow-y:hidden}.otp-modal__header[_ngcontent-%COMP%]{position:relative;display:flex;align-items:flex-start;justify-content:space-between;padding:16px 40px;border-bottom:1px solid #DDDDDD;border-top-left-radius:0;border-top-right-radius:0}.otp-modal__title[_ngcontent-%COMP%]{font-size:21px;line-height:26px;margin-bottom:0}.otp-modal__close-button[_ngcontent-%COMP%]{position:absolute;right:2.3rem;top:2.3rem;padding:15px;margin:-2rem -2rem -2rem auto;background:none;border:none;font-size:calc(1.275rem + .3vw);cursor:pointer;font-weight:bolder}.otp-modal__body[_ngcontent-%COMP%]{padding:20px 1rem}.otp-modal__description[_ngcontent-%COMP%]{margin-bottom:16px;font-size:1rem;line-height:24px}.otp-modal__form[_ngcontent-%COMP%]{display:flex;flex-direction:row;column-gap:6px}.otp-modal__input[_ngcontent-%COMP%]{width:45px;height:48px;border-radius:6px;outline:none;font-size:40px;line-height:40px;font-weight:700;text-align:center;border:2px solid #979797;caret-color:#ff7900;padding-inline:2px!important}.otp-modal__input[_ngcontent-%COMP%]::-webkit-inner-spin-button, .otp-modal__input[_ngcontent-%COMP%]::-webkit-outer-spin-button{display:none}.otp-modal__error[_ngcontent-%COMP%]{display:block;font-size:14px;line-height:18px;color:#cd3c14;margin:0;margin-top:1rem}.otp-modal__retry[_ngcontent-%COMP%]{display:flex;flex-direction:row;align-items:center;justify-content:center;margin-top:16px}.otp-modal__retry-text[_ngcontent-%COMP%]{font-size:12px;line-height:14px;color:#666;margin-bottom:0;margin-right:1rem}.otp-modal__retry-button[_ngcontent-%COMP%]{display:inline-block;border:none;font-size:12px;line-height:14px;box-shadow:none;background:transparent;padding:0;margin:0;color:#ff7900;cursor:pointer}.otp-modal__retry-button[_ngcontent-%COMP%]:disabled{color:#ccc!important;cursor:not-allowed}.otp-modal__alert[_ngcontent-%COMP%]{margin:1rem 0}.otp-modal__footer[_ngcontent-%COMP%]{display:flex;flex-direction:column;justify-content:center;padding:1.75rem;border-top:1px solid #DDDDDD}.otp-modal__footer[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{max-width:277px;width:100%;height:44px;margin:auto;font-size:1rem;font-weight:700;cursor:pointer;border:none}.otp-modal__footer[_ngcontent-%COMP%] button[_ngcontent-%COMP%]:disabled{cursor:not-allowed}.otp-modal__footer[_ngcontent-%COMP%] button.btn-danger[_ngcontent-%COMP%]{margin-top:1rem}@media screen and (min-width: 768px){.otp-modal__header[_ngcontent-%COMP%]{padding:16px 40px}.otp-modal__body[_ngcontent-%COMP%]{padding:20px 40px}.otp-modal__description[_ngcontent-%COMP%]{font-size:17px;margin-bottom:36px}.otp-modal__input[_ngcontent-%COMP%]{width:60px;height:63px;font-size:51px;line-height:31px}.otp-modal__retry-text[_ngcontent-%COMP%], .otp-modal__retry-button[_ngcontent-%COMP%]{font-size:14px;line-height:18px}.otp-modal__footer[_ngcontent-%COMP%] button[_ngcontent-%COMP%]{max-width:277px;width:100%;height:44px;margin:auto}}"]});let t=i;return t})();var Ii={withCredentials:!0};function Fi(t){return dt((i,n)=>{var e,o;return((e=i.address)==null?void 0:e.addressId)===((o=n.address)==null?void 0:o.addressId)},t)}var Yt=(()=>{let i=class i{constructor(e,o,s,a,r){this.storeSelector=e,this.store=o,this.actions$=s,this.http=a,this.matDialog=r,this._newCustomerDeliveryAddress=new T({}),this.setDeliveryAddressSuccess$=new fe,this.deliveryAddressChanged$=new fe,this._fixedLocationContactPersonSource=new T({}),this.fixedLocationContactPerson$=this._fixedLocationContactPersonSource.asObservable(),this._selectedDeliveryAddressErrorSource=new T(!1),this.selectedDeliveryAddressError$=this._selectedDeliveryAddressErrorSource.asObservable(),this._deliveryAddressDataSource=new T({}),this.deliveryAddressData$=this._deliveryAddressDataSource.asObservable(),this._deliveryAddressFormIsVisibleSource=new T(!1),this.deliveryAddressFormIsVisible$=this._deliveryAddressFormIsVisibleSource.asObservable(),this._billingAddressDataSource=new T({}),this.billingAddressData$=this._billingAddressDataSource.asObservable(),this._billingAddressFormIsVisibleSource=new T(!1),this.billingAddressFormIsVisible$=this._billingAddressFormIsVisibleSource.asObservable(),this._addressFormIsVisibleSource=new T(!1),this.addressFormVisible$=this._addressFormIsVisibleSource.asObservable(),this._addressToggleAriadNextSource=new T(!1),this.addressToggleAriadNext$=this._addressToggleAriadNextSource.asObservable(),this.deliveryFormCompleted$=new Ne,this._preferredNotificationChannelSource=new T(!1),this.preferredNotificationChannel$=this._preferredNotificationChannelSource.asObservable(),this._isBillingAddressEditForm=new T(!1),this.isBillingAddressEditForm$=this._isBillingAddressEditForm.asObservable(),this.deliveryAddressOpenContext=Ce(void 0),this.editModeSubject=new T(null),this.editMode$=this.editModeSubject.asObservable(),this.notificationChannelLoading=Ce(!0)}getSelectedShippingAddress(){return K([this.getShippingAddressList().pipe(B()),this.storeSelector.getWithSelector(me).pipe(B()),this.storeSelector.getWithSelector(Ae).pipe(B()),this.storeSelector.getWithSelector(it()).pipe(B()),this.storeSelector.getWithSelector(ot).pipe(B()),this.storeSelector.getWithSelector(P).pipe(B())]).pipe(D(([e,o,s,a,r,d])=>{var l;return d.status!==O.loading&&((l=d.cart)==null?void 0:l.__typename)==="PendingCartResource"}),S(([e,o,s,a,r,d])=>{var l,C;if(this.isLoggedIn=s,this.selectorCartItemIsOfyOrLoy=a,this.hasAtLeastOneLoyaltyProduct=r,(l=o==null?void 0:o.address)!=null&&l.addressId){let b=e.find(y=>{var I;return o.address.addressId===((I=y.address)==null?void 0:I.addressId)&&J(y.party,o.party)});if(b)return this.checkShippingAddressIsComplete(b),b}else if(s){let b=e.find(({isSelected:I})=>I)||e[0],y=(C=d.cart.shipping)==null?void 0:C.shippingType.selection;return this.checkShippingAddressIsComplete(b),b&&(!y||y===Je.Customer)&&this.store.dispatch(Oe({address:b})),b}})).pipe(D(e=>{var o;return!!((o=e==null?void 0:e.party)!=null&&o.type)||!e})).pipe(Y(1))}getSelectedBillingAddress(){return K([this.getBillingAddressList(),this.storeSelector.getWithSelector(ue),this.storeSelector.getWithSelector(Ae)]).pipe(S(([e,o,s])=>{var a;if((a=o==null?void 0:o.address)!=null&&a.addressId){let r=e.find(d=>{var l,C;return((l=o.address)==null?void 0:l.addressId)===((C=d.address)==null?void 0:C.addressId)&&J(d.party,o.party)});if(r)return r}else if(s){let r=e.find(({isSelected:d})=>d)||e[0];return r&&this.store.dispatch(Oe({address:r})),r}})).pipe(D(e=>{var o;return!!((o=e==null?void 0:e.party)!=null&&o.type)||!e}))}getShippingAddressList(){return this.storeSelector.getWithSelector(Se()).pipe(D(e=>e.status===O.success),S(e=>{var o;return(o=e.me)==null?void 0:o.ssoId}),B(),S(e=>!!e),te(e=>e?this.getLoggedInUserDeliveryAddresses():this.getGuestUserDeliveryAddresses()))}getBillingAddressList(){return this.storeSelector.getWithSelector(Se()).pipe(D(e=>e.status===O.success)).pipe(S(e=>{var o;return!!((o=e.me)!=null&&o.ssoId)})).pipe(te(e=>e?K([this.storeSelector.getWithSelector(lt),this.storeSelector.getWithSelector(zt),this.storeSelector.getWithSelector(Pe),this.storeSelector.getWithSelector(ue),this.storeSelector.getWithSelector(Pe).pipe(te(o=>o?this.storeSelector.getWithSelector(tt()).pipe(D(({status:s})=>s!==O.loading)).pipe(S(({list:s})=>s)):X([])))]).pipe(S(([o,s,a,r,d])=>{var b;if(!a&&r)return[f(u({},r),{isEditable:!1,isSelected:!0})];if(a&&r&&(d==null?void 0:d.length)===0)return[f(u({},r),{isEditable:!0,isSelected:!0})];let l=d?Array.from(d):[];if(r&&((b=r.address)!=null&&b.addressId)){let y=l.find(I=>{var k,M;return((k=I.address)==null?void 0:k.addressId)===((M=r.address)==null?void 0:M.addressId)&&J(r.party,I.party)});if(!y&&(y=l.find(I=>{var k,M;return((k=I.address)==null?void 0:k.addressId)===((M=r.address)==null?void 0:M.addressId)}),y)){let I=l.indexOf(y);l[I]=f(u({},y),{party:r.party})}}if(s||!(r!=null&&r.party))return l;let C=l==null?void 0:l.map(y=>f(u({},y),{party:r.party}));return Fi(C)})):this.storeSelector.getWithSelector(ue).pipe(S(o=>o?[f(u({},o),{isEditable:!0})]:[]))))}getSelectedDeliveryAddressError(){return this.selectedDeliveryAddressError$}deleteShippingAddressFromCart(){return this._deliveryAddressFormIsVisibleSource.next(!1),this._deliveryAddressDataSource.next({}),this.store.dispatch(At()),this._addressFormIsVisibleSource.next(!1),this._addressToggleAriadNextSource.next(!1),ge(this.actions$.pipe(Q(Lt)).pipe(j(!0)),this.actions$.pipe(Q(Ot)).pipe(j(!1)))}deleteBillingAddressFromCart(){return this._billingAddressFormIsVisibleSource.next(!1),this._billingAddressDataSource.next({}),this.store.dispatch(xt({billing:null})),ge(this.actions$.pipe(Q(yt)).pipe(j(!0)),this.actions$.pipe(Q(vt)).pipe(j(!1)))}checkIfAddressIsCorrect(e){var o;e.address&&!e.address.county.name||e.address&&!e.address.locality.name||e.address&&!((o=e.address.street)!=null&&o.name)&&!e.address.streetName||e.party&&!e.party.name?this._selectedDeliveryAddressErrorSource.next(!0):this._selectedDeliveryAddressErrorSource.next(!1)}getDeliveryAddressData(){return this.deliveryAddressData$}getIsDeliveryFormCompleted(){return this.deliveryFormCompleted$}setIsDeliveryFormCompleted(e){return this.deliveryFormCompleted$.next(e)}getDeliveryAddressFormIsVisible(){return this.deliveryAddressFormIsVisible$}handleCloseDeliveryAddressForm(){this._deliveryAddressFormIsVisibleSource.next(!1),this._deliveryAddressDataSource.next({}),this._addressFormIsVisibleSource.next(!1),this._addressToggleAriadNextSource.next(!1)}handleAddDeliveryAddress(){this._deliveryAddressFormIsVisibleSource.next(!0),this._addressFormIsVisibleSource.next(!0),this.deliveryAddressOpenContext.set("Add"),this.handleCloseBillingAddressForm()}handleEditDeliveryAddress(e,o){this._deliveryAddressDataSource.next({deliveryAddress:e,options:o}),this._deliveryAddressFormIsVisibleSource.next(!0),this._addressFormIsVisibleSource.next(!0),this.deliveryAddressOpenContext.set("Edit"),this.handleCloseBillingAddressForm()}getBillingAddressData(){return this.billingAddressData$}getBillingAddressFormIsVisible(){return this.billingAddressFormIsVisible$}handleCloseBillingAddressForm(){this._billingAddressFormIsVisibleSource.next(!1),this._billingAddressDataSource.next({})}handleAddBillingAddress(){this._isBillingAddressEditForm.next(!1),this._billingAddressFormIsVisibleSource.next(!0),this.handleCloseDeliveryAddressForm()}handleActivateEditForCompany(){this._isBillingAddressEditForm.next(!0)}handleEditBillingAddress(e,o){this._isBillingAddressEditForm.next(!0),this._billingAddressDataSource.next({billingAddress:e,options:o}),this._billingAddressFormIsVisibleSource.next(!0),this.handleCloseDeliveryAddressForm()}handleEditBillingAddressForCompany(e,o){this._isBillingAddressEditForm.next(!1),this._billingAddressDataSource.next({billingAddress:e,options:o}),this._billingAddressFormIsVisibleSource.next(!0)}handleSelectAddress(e){var o,s,a;e.type===le.BILLING&&this.store.dispatch(Qe({selection:Le.Customer})),!((o=e.party)!=null&&o.type)||!((s=e.party)!=null&&s.name)?e.type===le.BILLING?this.handleEditBillingAddress(e,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&e&&!e.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(ee).pipe(W(1)).subscribe(r=>{r.verified?this.handleEditDeliveryAddress(e,{autoDirty:!0,emailValueSet:!1}):this.handleGenerateNewAddressOTP(!1,e)}):this.handleEditDeliveryAddress(e,{autoDirty:!0,emailValueSet:!1}):(e==null?void 0:e.type)===le.BILLING&&((a=e.party)==null?void 0:a.type)!==Ze.Person?this.handleEditBillingAddressForCompany(e,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&e&&!e.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(ee).pipe(W(1)).subscribe(r=>{r.verified?(this.store.dispatch(Fe({addressType:null})),this.store.dispatch(be({address:e}))):this.handleGenerateNewAddressOTP()}):(this.store.dispatch(Fe({addressType:null})),this.store.dispatch(be({address:e})))}mapAddressToCommonObject(e,o){var s,a,r,d;return o&&e.address&&(e.address=pe("zipCode",e.address),e.address.locality=pe("zipCode",e.address.locality),e.address.street=pe("zipCode",e.address.street)),e.address=e.address,e.address.apartment=(s=e.address)!=null&&s.apartment?e.address.apartment:"",e.address.building=(a=e.address)!=null&&a.building?e.address.building:"",e.address.streetNo=(r=e.address)!=null&&r.streetNo?e.address.streetNo:"",e.address.staircase=(d=e.address)!=null&&d.staircase?e.address.staircase:"",e}getAddressFormIsVisible(){return this.addressFormVisible$}setAddressToggleAriadNext(e){return this._addressToggleAriadNextSource.next(e)}getAddressToggleAriadNext(){return this.addressToggleAriadNext$}setFixedLocationContactPerson(e,o=!0){this._fixedLocationContactPersonSource.next(e),o&&this.store.dispatch(St({shippingTypeSelection:Le.FixedLocation}))}getNotificationChannelByOCN(){return this.notificationChannelLoading.set(!0),this.http.get("".concat(Xe.getCartV2ApiUrl(),"/consent/notification-channel"),f(u({},Ii),{responseType:"text"})).pipe(Be(()=>this.notificationChannelLoading.set(!1)),Me(e=>(this.notificationChannelLoading.set(!1),X(void 0))),D(st),Y({bufferSize:1,refCount:!0}))}getPreferredNotificationChannel(){return this.preferredNotificationChannel$}setPreferredNotificationChannel(e){return this._preferredNotificationChannelSource.next(e)}selectPreferredNotificationChannel(e){this.storeSelector.getWithSelector(Ut()).pipe(W(1)).subscribe(o=>{let{insuranceTermsAgreed:s,isAbove16:a,hasPaymentCommitment:r,keepIdCard:d,gdprConsents:l}=o;this.store.dispatch(ct({insuranceTermsAgreed:s,isAbove16:a,hasPaymentCommitment:r,keepIdCard:d,gdprConsents:l,notificationChannel:e}))})}generateNewAddressOTP(){this.store.dispatch(bt())}handleGenerateNewAddressOTP(e,o){return this.generateNewAddressOTP(),this.dialogRef=this.matDialog.open(jt,{maxWidth:"500px",data:{isCompleteOrder:e}}),this.dialogRef.afterClosed()}handleVerifyNewAddressOTP(e,o){this.store.dispatch(It({code:e,forced:o}))}setEditMode(e){this.editModeSubject.next(e)}getLoggedInUserDeliveryAddresses(){return K([this.storeSelector.getWithSelector(me),this.storeSelector.getWithSelector(et()).pipe(D(e=>e.status===O.success),S(e=>e.list||[]))]).pipe(S(([e,o])=>this.mergeDeliveryAddresses(o,e)))}getGuestUserDeliveryAddresses(){return this.storeSelector.getWithSelector(me).pipe(S(e=>e?[f(u({},e),{isEditable:!0,shippingAddressSourceSubResource:e.shippingAddressSourceSubResource})]:[]))}mergeDeliveryAddresses(e,o){var r;if(!((r=o==null?void 0:o.address)!=null&&r.addressId))return e;let s=Array.from(e),a=this.findDeliveryAddressInList(o,s);if(a){let d=s.indexOf(a);s[d]=f(u({},a),{party:o.party})}return s}findDeliveryAddressInList(e,o){return o.find(s=>{var a,r;return((a=s.address)==null?void 0:a.addressId)===((r=e.address)==null?void 0:r.addressId)&&J(e.party,s.party)})||o.find(s=>{var a,r;return((a=s.address)==null?void 0:a.addressId)===((r=e.address)==null?void 0:r.addressId)})}checkShippingAddressIsComplete(e){var o,s,a;e!=null&&e.address&&(!(e!=null&&e.party)||!((o=e==null?void 0:e.party)!=null&&o.name)||!((s=e==null?void 0:e.party)!=null&&s.email)||!((a=e==null?void 0:e.party)!=null&&a.phone))&&this.handleEditDeliveryAddress(e)}};i.\u0275fac=function(o){return new(o||i)(R(ce),R(Ke),R(Ct),R(de),R(mt))},i.\u0275prov=oe({token:i,factory:i.\u0275fac,providedIn:"root"});let t=i;return t})();export{wi as a,Pi as b,Ei as c,Di as d,Vi as e,Ni as f,ki as g,Mi as h,Bi as i,Gt as j,Ri as k,$i as l,Ui as m,Gi as n,Wi as o,zi as p,qi as q,Hi as r,Xi as s,Ki as t,ji as u,Yi as v,Zi as w,we as x,Ji as y,Qi as z,eo as A,to as B,io as C,Wt as D,mo as E,ho as F,_o as G,go as H,Co as I,xo as J,vo as K,yo as L,So as M,Ao as N,Lo as O,Oo as P,Io as Q,Fo as R,To as S,wo as T,Po as U,Bo as V,Pe as W,zt as X,Ro as Y,ue as Z,me as _,$o as $,ee as aa,Uo as ba,Go as ca,Wo as da,Xt as ea,he as fa,_e as ga,Ho as ha,Yt as ia};