import{c as Ie}from"./chunk-XPGU7UGG.js";import{Q as It}from"./chunk-JRMHPUBR.js";import{a as _t}from"./chunk-77WMUU2O.js";import{b as At}from"./chunk-7VCMYDLB.js";import{b as yt}from"./chunk-PFLJI4YQ.js";import{c as nt,d as st,e as at}from"./chunk-S3R7OBRS.js";import{c as lt,e as ct,g as pt,n as ut}from"./chunk-UBPC4FNO.js";import{Lb as Ae,Mb as ye,P as b,Qb as Xe,Wb as je,Xb as Ze,aa as ze,dc as ce,fc as D,ja as Oe,ma as Ye,qc as Je,sc as Qe,wc as et,yb as de}from"./chunk-U45OJP77.js";import{E as vt,F as Ot,c as ht,e as C,h as gt,i as ft,j as St,l as M,n as Ct,r as xt,t as Et}from"./chunk-MILTB5EA.js";import{a as tt}from"./chunk-2QDNDRJH.js";import{c as dt,d as j}from"./chunk-VN6PXZL4.js";import{U as rt}from"./chunk-HMS3LRP2.js";import{g as xe,h as Ee,j as qe,l as ve,n as le}from"./chunk-MGYJOL7Z.js";import{h as X,k as pe,n as it,q as ot}from"./chunk-767ZUJWF.js";import{D as I,d as r,e as s,s as We,v as c,w as Ke}from"./chunk-QYQ7WNYU.js";import{b as He}from"./chunk-W73LR43Y.js";import{h as ae}from"./chunk-6MZAHXNO.js";import{v as $e}from"./chunk-GR55BOSQ.js";import{a as mt}from"./chunk-2POMSYDU.js";import{Ac as P,Ba as ee,Ca as te,Cc as oe,Dc as re,Ec as ne,Fc as S,Gc as h,Hc as Me,J,La as ie,Lc as se,O as v,P as K,Qa as N,Rb as Ve,Rc as k,Tb as A,Tc as T,Ub as B,X as Re,Y as fe,Ya as Fe,Z as w,a as _,b as f,dd as g,ec as Be,fa as q,fc as ke,fd as Se,gd as Ce,ha as z,hb as H,ib as W,la as V,md as Ue,nc as y,qd as Ge,rb as we,s as ge,t as L,tc as Y,td as R,u as Ne,ud as F,xa as Q}from"./chunk-HC2G7LSI.js";var Ii=r("[Locations] Search Fixed Locations",s()),Li=r("[Locations] Search Fixed Locations [Success]",s()),Ti=r("[Locations] Search Fixed Locations [Error]",s()),Pi=r("[Locations] Get Fixed Location",s()),Di=r("[Locations] Get Fixed Location [Success]",s()),bi=r("[Locations] Get Fixed Location [Error]",s()),Ni=r("[Location] Remove Search Fixed Locations"),Ri=r("[Location] Update Filter Input",s()),Fi=r("[Location] Clear Filter Input"),Lt=r("[Locations] Get Counties",s()),wi=r("[Locations] Get Counties Success",s()),Vi=r("[Locations] Get Counties Error",s()),Bi=r("[Locations] Get Localities",s()),ki=r("[Locations] Get Localities Success",s()),Mi=r("[Locations] Get Localities Error",s()),Ui=r("[Locations] Remove localities"),Gi=r("[Locations] Set Location Marker",s()),$i=r("[Locations] Set Location from map",s()),Hi=r("[Locations] Set Location from cart",s()),Wi=r("[Location] Set Location skeletons",s()),Ki=r("[Location] Set favorite Location",s()),qi=r("[Location] Set favorite Location Success",s()),zi=r("[Location] Set favorite Location Error",s()),Le=r("[Location] Get favorite or last used Location"),Yi=r("[Location] Get favorite or last used Location Success",s()),Xi=r("[Location] Get favorite or last used Location Error",s()),ji=r("[Location] Set County input",s()),Zi=r("[Location] Set Locality input",s()),Ji=r("[Location] Clear Address inputs");var E=function(e){return e.SET_BILLING="[Cart] Set billing",e.SET_BILLING_ERROR="[Cart] Set billing [Error]",e.SET_BILLING_SUCCESS="[Cart] Set billing [Success]",e.TOGGLE_IS_KEEP_BILLING_DATA="[Cart] Toggle is keep billing data",e.SET_SHIPPING="[Cart] Set shipping",e.SET_SHIPPING_ERROR="[Cart] Set shipping [Error]",e.SET_SHIPPING_SUCCESS="[Cart] Set shipping [Success]",e.CANCEL_SET_SHIPPING="[Cart] Cancel set shipping",e.DELETE_SHIPPING="[Cart] Delete shipping",e.DELETE_SHIPPING_ERROR="[Cart] Delete shipping [Error]",e.DELETE_SHIPPING_SUCCESS="[Cart] Delete shipping [Success]",e.GENERATE_NEW_ADDRESS_OTP="[Cart] Generate new address OTP",e.GENERATE_NEW_ADDRESS_OTP_ERROR="[Cart] Generate new address OTP [Error]",e.GENERATE_NEW_ADDRESS_OTP_SUCCESS="[Cart] Generate new address OTP [Success]",e.VERIFY_NEW_ADDRESS_OTP="[Cart] Verify new address OTP",e.VERIFY_NEW_ADDRESS_OTP_ERROR="[Cart] Verify new address OTP [Error]",e.VERIFY_NEW_ADDRESS_OTP_SUCCESS="[Cart] Verify new address OTP [Success]",e}(E||{}),Tt=r(E.SET_BILLING,s()),Pt=r(E.SET_BILLING_ERROR,s()),Dt=r(E.SET_BILLING_SUCCESS),Te=r(E.TOGGLE_IS_KEEP_BILLING_DATA,s()),bt=r(E.SET_SHIPPING,s()),to=r(E.SET_SHIPPING_ERROR,s()),io=r(E.SET_SHIPPING_SUCCESS),oo=r(E.CANCEL_SET_SHIPPING),Nt=r(E.DELETE_SHIPPING),Rt=r(E.DELETE_SHIPPING_SUCCESS),Ft=r(E.DELETE_SHIPPING_ERROR,s()),wt=r(E.GENERATE_NEW_ADDRESS_OTP),ro=r(E.GENERATE_NEW_ADDRESS_OTP_ERROR,s()),no=r(E.GENERATE_NEW_ADDRESS_OTP_SUCCESS,s()),Vt=r(E.VERIFY_NEW_ADDRESS_OTP,s()),so=r(E.VERIFY_NEW_ADDRESS_OTP_ERROR,s()),ao=r(E.VERIFY_NEW_ADDRESS_OTP_SUCCESS,s());function Bt(e){let o=_({},e);return delete o.__typename,delete o.allowsDropOff,delete o.supportedPaymentType,delete o.schedule,delete o.restrictions,delete o.isFavorite,it(o)?null:o}var x=Ke("locations"),So=c(x,e=>e.searchedFixedLocations?.data),Co=c(x,e=>e.searchedFixedLocations.status),xo=c(x,e=>e.searchedFixedLocations?.request),Eo=c(x,e=>e.fixedLocation?.data),vo=c(x,e=>e.filterInput),Oo=e=>({selector:x,action:()=>Lt({countryCode:e}),map:o=>o.counties?.data,shouldDispatch:o=>o.counties.status===I.initial}),Ao=c(x,e=>e.localities?.data),yo=c(x,e=>e.locationMarker),Io=c(x,e=>e?.selectedLocation),Lo=c(x,e=>e.showSkeletons),To=()=>({selector:c(x,xe,(e,o)=>[e,o]),action:()=>Le(),map:([e])=>e.favoriteOrLastUsedLocation,shouldDispatch:([e,o])=>o&&e.favoriteOrLastUsedLocation.status===I.initial}),Po=()=>({selector:c(x,xe,(e,o)=>[e,o]),action:()=>Le(),map:([e])=>e.favoriteOrLastUsedLocation?.data,shouldDispatch:([e,o])=>o&&e.favoriteOrLastUsedLocation.status===I.initial}),Do=c(x,e=>e.favoriteOrLastUsedLocation.status),bo=c(x,e=>e.favoriteOrLastUsedLocation?.data),No=c(x,e=>!!(e.favoriteOrLastUsedLocation?.data||e.selectedLocation)),Ro=c(x,e=>e.selectedLocation?e.selectedLocation:Bt(e.favoriteOrLastUsedLocation?.data)),Fo=c(x,e=>e.selectedLocation||void 0),wo=c(x,e=>e.countyInput),Vo=c(x,e=>e.localityInput);var Ho=f(_({},D),{map(e){return e.cart?.__typename==="PendingCartResource"&&e?.cart?.actions?.includes(b.SetBilling)}}),Pe=f(_({},D),{map(e){return e.cart?.__typename==="PendingCartResource"&&(e?.cart?.actions?.includes(b.SetBilling)||e?.cart?.actions?.includes(b.SetBillingAddress))}}),kt=f(_({},D),{map(e){return e.cart?.__typename==="PendingCartResource"&&(e?.cart?.actions?.includes(b.SetBilling)||e?.cart?.actions?.includes(b.SetBillingParty))}}),Wo=f(_({},D),{map(e){return e.cart?.__typename==="PendingCartResource"&&e?.cart?.actions?.includes(b.SetShipping)}}),ue=f(_({},D),{map:e=>e.cart?.__typename==="PendingCartResource"?Ie.fromCartBillingAddressToAddressRelation(e.cart?.billing):void 0}),_e=f(_({},D),{map:e=>e.cart?.__typename==="PendingCartResource"&&e.cart?.shipping?Ie.fromCartShippingAddressToAddressRelation(e.cart.shipping):void 0,filter:e=>e.status===I.success||e.status===I.error}),Ko=f(_({},D),{map:e=>e.cart?.__typename==="PendingCartResource"&&e.cart.shipping?.shippingType?e.cart.shipping.shippingType:void 0}),Mt=f(_({},D),{map:e=>e.newClientAcquisition.generateNewAddressOTP}),Z=f(_({},D),{map:e=>e.newClientAcquisition.verifyNewAddressOTP}),qo=f(_({},D),{map:e=>!!(e.cart?.__typename==="PendingCartResource"&&e.cart.isEligibleForLockers)}),zo=c(ce,e=>!(e.cart?.__typename==="PendingCartResource"&&e.cart.shipping?.shippingType.fixedLocation)),Yo=c(ce,e=>e.cart?.__typename==="PendingCartResource"&&e.isKeepBillingDataToggled),Ut=c(ce,e=>{if(e.cart?.__typename==="PendingCartResource")return e.cart.actions}),qt=c(Ut,e=>{if(!e)return;let o=[b.IsFastOrder,b.HasSimoLoyOnly,b.IsESimPrePayFlow];return!e.find(a=>a&&o.includes(a))}),Xo=c(Ut,qt,(e,o)=>{if(e)return o&&!e.includes(b.IsShortFlow)});var me=function(e){return e[e.CUSTOMER=0]="CUSTOMER",e[e.FIXED_LOCATION=1]="FIXED_LOCATION",e[e.PICKUP_IN_STORE=2]="PICKUP_IN_STORE",e}(me||{}),he=function(e){return e.CUSTOMER="customer",e.FIXED_LOCATION="fixed-location",e.PICKUP_IN_STORE="pickup-in-store",e}(he||{}),Jo={[he.CUSTOMER]:me.CUSTOMER,[he.FIXED_LOCATION]:me.FIXED_LOCATION,[he.PICKUP_IN_STORE]:me.PICKUP_IN_STORE},De=function(e){return e.validationErrors="validationErrors",e.maxOtpCodesVerificationAttempts="maxOtpCodesVerificationAttempts",e}(De||{}),be=function(e){return e.validationErrors="validationErrors",e.maxOtpCodesGenerationAttempts="maxOtpCodesGenerationAttempts",e.invalidOtpCode="invalidOtpCode",e}(be||{});var $t=(()=>{let o=class o{constructor(t){this.httpClient=t,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(Q(1))),this.cache$}checkIfIsDev(){return J(this.isDev)}};o.\u0275fac=function(i){return new(i||o)(N(ae))},o.\u0275prov=ie({token:o,factory:o.\u0275fac,providedIn:"root"});let e=o;return e})();var Zt=(e,o,a)=>({cartStatus:e,generateNewAddressOTP:o,verifyNewAddressOTP:a});function Jt(e,o){e&1&&(S(0,"strong"),g(1),h()),e&2&&(A(),Se(" ",o,". "))}function Qt(e,o){e&1&&Me(0,"oro-skeleton-loader-line",16)}function ei(e,o){if(e&1){let a=se();S(0,"input",17),k("keyup",function(i){let d=H(a).$implicit,l=T(2);return W(l.switchInput(i,d))}),h()}if(e&2){let a=o.$implicit;Y("formControlName",a)("id",a)}}function ti(e,o){e&1&&g(0," Codul este necesar. ")}function ii(e,o){e&1&&g(0," Num\u0103r de caractere invalid. ")}function oi(e,o){if(e&1&&(S(0,"p",9),y(1,ti,1,0)(2,ii,1,0),h()),e&2){let a=T(2);A(),P(1,!(a.inputOne==null||a.inputOne.errors==null)&&a.inputOne.errors.required?1:!(a.inputOne==null||a.inputOne.errors==null)&&a.inputOne.errors.minlength||!(a.inputOne==null||a.inputOne.errors==null)&&a.inputOne.errors.maxlength?2:-1)}}function ri(e,o){e&1&&g(0),e&2&&Se(" \xEEn [",o,"] secunde ")}function ni(e,o){e&1&&(S(0,"oro-alert",18),g(1," A intervenit o problem\u0103 \xEEn generarea codului OTP. Te rug\u0103m \xEEncearc\u0103 mai t\xE2rziu. "),h())}function si(e,o){e&1&&(S(0,"oro-alert",18),g(1," Ai atins num\u0103rul maxim de coduri generate. "),h())}function ai(e,o){e&1&&(S(0,"oro-alert",18),g(1," Codul introdus este invalid. "),h())}function di(e,o){if(e&1&&g(0),e&2){let a=T(2).$implicit;Ce(" ",a.message,". Error code: ",a.extensions.errorCode," ")}}function li(e,o){e&1&&g(0," A intervenit o eroare. ")}function ci(e,o){if(e&1&&(S(0,"oro-alert",18),y(1,di,1,2),R(2,"async"),y(3,li,1,0),h()),e&2){let a=T(4);A(),P(1,F(2,1,a.isDev$)?1:3)}}function pi(e,o){if(e&1&&y(0,ni,2,0)(1,si,2,0)(2,ai,2,0)(3,ci,4,3),e&2){let a,t=o.$implicit,i=T(3);P(0,(a=t.extensions.errorCode)===i.generateNewClientAcquisitionOTPTypeErrors.validationErrors?0:a===i.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts?1:a===i.generateNewClientAcquisitionOTPTypeErrors.invalidOtpCode?2:3)}}function ui(e,o){e&1&&re(0,pi,4,1,null,null,oe),e&2&&ne(o.errors)}function _i(e,o){e&1&&(S(0,"oro-alert",18),g(1," Codul introdus nu coincide cu cel primit prin sms. Te rog s\u0103 reintroduci codul. "),h())}function mi(e,o){e&1&&(S(0,"oro-alert",18),g(1," Ai atins num\u0103rul maxim de coduri pentru ast\u0103zi. Te rug\u0103m s\u0103 \xEEncerci peste 24h. "),h())}function hi(e,o){if(e&1&&g(0),e&2){let a=T(2).$implicit;Ce(" ",a.message,". Error code: ",a.extensions.errorCode," ")}}function gi(e,o){e&1&&g(0," A intervenit o eroare. ")}function fi(e,o){if(e&1&&(S(0,"oro-alert",18),y(1,hi,1,2),R(2,"async"),y(3,gi,1,0),h()),e&2){let a=T(4);A(),P(1,F(2,1,a.isDev$)?1:3)}}function Si(e,o){if(e&1&&y(0,_i,2,0)(1,mi,2,0)(2,fi,4,3),e&2){let a,t=o.$implicit,i=T(3);P(0,(a=t.extensions.errorCode)===i.validationNumberTypeErrors.validationErrors?0:a===i.validationNumberTypeErrors.maxOtpCodesVerificationAttempts?1:2)}}function Ci(e,o){e&1&&re(0,Si,3,1,null,null,oe),e&2&&ne(o.errors)}function xi(e,o){if(e&1){let a=se();S(0,"button",19),k("click",function(){H(a);let i=T(2);return W(i.forceCheckSMSCode(!0))}),g(1," For\u021Beaz\u0103 validarea "),h()}}function Ei(e,o){if(e&1){let a=se();S(0,"div",0)(1,"div",1)(2,"h3",2),g(3,"Cod PIN"),h(),S(4,"button",3),k("click",function(){H(a);let i=T();return W(i.cancel())}),S(5,"span",4),g(6,"\xD7"),h()()(),S(7,"div",5)(8,"p",6),g(9," Pentru a continua procesul, introdu codul de validare primit prin SMS la num\u0103rul "),y(10,Jt,2,1,"strong"),R(11,"async"),y(12,Qt,1,0),h(),S(13,"form",7),re(14,ei,1,2,"input",8,oe),h(),y(16,oi,3,1,"p",9),S(17,"div",10)(18,"p",11),g(19,"Nu ai primit codul PIN?"),h(),S(20,"button",12),k("click",function(){H(a);let i=T();return W(i.sendCodeAgain())}),g(21," Retrimite cod "),y(22,ri,1,1),R(23,"async"),h()(),y(24,ui,2,0)(25,Ci,2,0),h(),S(26,"div",13)(27,"button",14),k("click",function(){H(a);let i=T();return W(i.checkSMSCode())}),g(28," Valideaz\u0103 "),h(),y(29,xi,2,0,"button",15),R(30,"async"),h()()}if(e&2){let a,t,i,d,l=o,n=T();A(10),P(10,(a=F(11,9,n.notificationMsisdn$))?10:12,a),A(3),Y("formGroup",n.form),A(),ne(n.otpFields),A(2),P(16,n.inputOne!=null&&n.inputOne.touched?16:-1),A(4),Y("disabled",l.cartStatus===n.XhrStatus.loading||n.disableResendButton||!n.countdownCompleted||n.disableValidationButton),A(2),P(22,(t=!n.countdownCompleted&&F(23,11,n.countdown$))?22:-1,t),A(2),P(24,(i=l.generateNewAddressOTP)?24:-1,i),A(),P(25,(d=l.verifyNewAddressOTP)?25:-1,d),A(2),Y("disabled",n.form.invalid||l.cartStatus===n.XhrStatus.loading||n.disableValidationButton),A(2),P(29,F(30,13,n.isImpersonating$)?29:-1)}}var Ht=window;Ht.dataLayer=Ht.dataLayer||[];var Wt=(()=>{let o=class o extends tt{constructor(t,i,d,l,n,m){super(),this.dialogRef=t,this.storeSelector=i,this.trafficService=d,this.cartDeliveryAddressService=l,this.elementRef=n,this.data=m,this.otpFields=["one","two","three","four","five","six"],this.XhrStatus=I,this.validationNumberTypeErrors=De,this.generateNewClientAcquisitionOTPTypeErrors=be,this.countdownCompleted=!0,this.form=new St({one:new M("",[C.required,C.minLength(1),C.maxLength(1)]),two:new M("",[C.required,C.minLength(1),C.maxLength(1)]),three:new M("",[C.required,C.minLength(1),C.maxLength(1)]),four:new M("",[C.required,C.minLength(1),C.maxLength(1)]),five:new M("",[C.required,C.minLength(1),C.maxLength(1)]),six:new M("",[C.required,C.minLength(1),C.maxLength(1)])}),this.isImpersonating$=this.storeSelector.getWithSelector(qe)}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(t){this.elementRef.nativeElement.contains(t.target)||this.closeAddressForm()}ngOnInit(){this.generateNewAddressOTP$=this.storeSelector.getWithSelector(Mt),this.verifyNewAddressOTP$=this.storeSelector.getWithSelector(Z),this.cartStatus$=this.storeSelector.getWithSelector(et),this.isDev$=this.trafficService.checkIfIsDev(),this.notificationMsisdn$=this.generateNewAddressOTP$.pipe(v(t=>t.msisdn)),this.checkIfNeedToDisableButtons(),this.verifyNewAddressOTP$.pipe(te(this.destroyed$)).subscribe(t=>{t&&t.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(){if(this.form.valid&&this.inputOne?.value){let t=this.inputOne?.value+this.inputTwo?.value+this.inputThree?.value+this.inputFour?.value+this.inputFive?.value+this.inputSix?.value;this.cartDeliveryAddressService.handleVerifyNewAddressOTP(t),this.track("Add Address - Validate PIN")}}forceCheckSMSCode(t){t&&(this.cartDeliveryAddressService.handleVerifyNewAddressOTP("",t),this.track("Add Address - Validate PIN"))}sendCodeAgain(){this.startCountdown(),this.cartDeliveryAddressService.generateNewAddressOTP(),this.track("Add Address - Resend PIN")}switchInput(t,i){let d=document.getElementById("one"),l=document.getElementById("two"),n=document.getElementById("three"),m=document.getElementById("four"),p=document.getElementById("five"),O=document.getElementById("six");if(d.value.length===6){let u=d.value;d.value="",this.inputOne?.setValue(u[0]),d.value=u[0],this.inputTwo?.setValue(u[1]),l.value=u[1],this.inputThree?.setValue(u[2]),n.value=u[2],this.inputFour?.setValue(u[3]),m.value=u[3],this.inputFive?.setValue(u[4]),p.value=u[4],this.inputSix?.setValue(u[5]),O.value=u[5],O.focus();return}if(d.value&&d.value.length>1){d.value="";return}if(l.value&&l.value.length>1){l.value="";return}if(n.value&&n.value.length>1){n.value="";return}if(m.value&&m.value.length>1){m.value="";return}if(p.value&&p.value.length>1){p.value="";return}if(O.value&&O.value.length>1){O.value="";return}if(i==="one"&&d.value.length===1){l?.focus();return}if(i==="two"&&l.value.length===1){n?.focus();return}if(i==="three"&&n.value.length===1){m?.focus();return}if(i==="four"&&m.value.length===1){p?.focus();return}i==="five"&&p.value.length===1&&O?.focus(),t.key==="Backspace"&&(i==="six"&&(O.value="",p.focus()),i==="five"&&(p.value="",m.focus()),i==="four"&&(m.value="",n.focus()),i==="three"&&(n.value="",l.focus()),i==="two"&&(l.value="",d.focus()),i==="one"&&(d.value=""))}checkIfNeedToDisableButtons(){this.generateNewAddressOTP$.pipe(te(this.destroyed$)).subscribe(t=>{t.errors?t.errors.forEach(i=>{this.disableResendButton=i.extensions.errorCode===this.generateNewClientAcquisitionOTPTypeErrors.maxOtpCodesGenerationAttempts}):this.disableResendButton=!1}),this.verifyNewAddressOTP$.pipe(te(this.destroyed$)).subscribe(t=>{t.errors?t.errors.forEach(i=>{this.disableValidationButton=i.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(t){let i={event:lt.MIKRO_USER_CLICK,event_action:ct.CHECKOUT_DELIVERY_OPTIONS,event_category:pt.CHECKOUT,event_label:t,event_value:ut.ZERO};_t.analyticsPush(i)}startCountdown(){this.countdownCompleted=!1;let t=60;this.countdown$=Re(1e3).pipe(q(t+1),v(i=>t-i),v(i=>(this.countdownCompleted=i===0,i)))}};o.\u0275fac=function(i){return new(i||o)(B(nt),B(le),B($t),B(Kt),B(we),B(st))},o.\u0275cmp=Fe({type:o,selectors:[["oro-otp-address-validation"]],hostBindings:function(i,d){i&1&&k("click",function(n){return d.onClick(n)},!1,Ve)},standalone:!0,features:[ke,Ue],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(i,d){if(i&1&&(y(0,Ei,31,15,"div",0),R(1,"async"),R(2,"async"),R(3,"async")),i&2){let l;P(0,(l=Ge(7,Zt,F(1,1,d.cartStatus$),F(2,3,d.generateNewAddressOTP$),F(3,5,d.verifyNewAddressOTP$)))?0:-1,l)}},dependencies:[vt,Ct,ht,gt,ft,Ot,xt,Et,yt,At,$e,mt],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 e=o;return e})();var Oi={withCredentials:!0};function Ai(e){return ot((o,a)=>o.address?.addressId===a.address?.addressId,e)}var Kt=(()=>{let o=class o{constructor(t,i,d,l,n,m){this.storeSelector=t,this.store=i,this.actions$=d,this.http=l,this.matDialog=n,this.relatedProductsService=m,this._newCustomerDeliveryAddress=new L({}),this.setDeliveryAddressSuccess$=new ge,this.deliveryAddressChanged$=new ge,this._fixedLocationContactPersonSource=new L({}),this.fixedLocationContactPerson$=this._fixedLocationContactPersonSource.asObservable(),this._selectedDeliveryAddressErrorSource=new L(!1),this.selectedDeliveryAddressError$=this._selectedDeliveryAddressErrorSource.asObservable(),this._deliveryAddressDataSource=new L({}),this.deliveryAddressData$=this._deliveryAddressDataSource.asObservable(),this._deliveryAddressFormIsVisibleSource=new L(!1),this.deliveryAddressFormIsVisible$=this._deliveryAddressFormIsVisibleSource.asObservable(),this._billingAddressDataSource=new L({}),this.billingAddressData$=this._billingAddressDataSource.asObservable(),this._billingAddressFormIsVisibleSource=new L(!1),this.billingAddressFormIsVisible$=this._billingAddressFormIsVisibleSource.asObservable(),this._addressFormIsVisibleSource=new L(!1),this.addressFormVisible$=this._addressFormIsVisibleSource.asObservable(),this._addressToggleAriadNextSource=new L(!1),this.addressToggleAriadNext$=this._addressToggleAriadNextSource.asObservable(),this.deliveryFormCompleted$=new Ne,this._preferredNotificationChannelSource=new L(!1),this.preferredNotificationChannel$=this._preferredNotificationChannelSource.asObservable(),this._isBillingAddressEditForm=new L(!1),this.isBillingAddressEditForm$=this._isBillingAddressEditForm.asObservable(),this.deliveryAddressOpenContext=Be(void 0),this.toggleAddressSubject=new L(!1),this.toggleAddress$=this.toggleAddressSubject.asObservable(),this.editModeSubject=new L(null),this.editMode$=this.editModeSubject.asObservable()}getSelectedShippingAddress(){return K([this.getShippingAddressList().pipe(V()),this.storeSelector.getWithSelector(_e).pipe(V()),this.storeSelector.getWithSelector(ve).pipe(V()),this.storeSelector.getWithSelector(Je()).pipe(V()),this.storeSelector.getWithSelector(Qe).pipe(V()),this.storeSelector.getWithSelector(D).pipe(V())]).pipe(w(([t,i,d,l,n,m])=>m.status!==I.loading&&m.cart?.__typename==="PendingCartResource"),v(([t,i,d,l,n,m])=>{if(this.isLoggedIn=d,this.selectorCartItemIsOfyOrLoy=l,this.hasAtLeastOneLoyaltyProduct=n,i?.address?.addressId){let p=t.find(O=>i.address.addressId===O.address?.addressId&&X(O.party,i.party));if(p)return this.checkShippingAddressIsComplete(p),p}else if(d){let p=t.find(({isSelected:u})=>u)||t[0],O=m.cart.shipping?.shippingType.selection;return this.checkShippingAddressIsComplete(p),p&&(!O||O===Ye.Customer)&&this.store.dispatch(Ae({address:p})),p}})).pipe(w(t=>!!t?.party?.type||!t)).pipe(Q(1))}getSelectedBillingAddress(){return K([this.getBillingAddressList(),this.storeSelector.getWithSelector(ue),this.storeSelector.getWithSelector(ve)]).pipe(v(([t,i,d])=>{if(i?.address?.addressId){let l=t.find(n=>i.address?.addressId===n.address?.addressId&&X(n.party,i.party));if(l)return l}else if(d){let l=t.find(({isSelected:n})=>n)||t[0];return l&&this.store.dispatch(Ae({address:l})),l}})).pipe(w(t=>!!t?.party?.type||!t))}getShippingAddressList(){return this.storeSelector.getWithSelector(Ee()).pipe(w(t=>t.status===I.success),v(t=>t.me?.ssoId),V(),v(t=>!!t),ee(t=>t?this.getLoggedInUserDeliveryAddresses():this.getGuestUserDeliveryAddresses()))}getBillingAddressList(){return this.storeSelector.getWithSelector(Ee()).pipe(w(t=>t.status===I.success)).pipe(v(t=>!!t.me?.ssoId)).pipe(ee(t=>t?K([this.storeSelector.getWithSelector(rt),this.storeSelector.getWithSelector(kt),this.storeSelector.getWithSelector(Pe),this.storeSelector.getWithSelector(ue),this.storeSelector.getWithSelector(Pe).pipe(ee(i=>i?this.storeSelector.getWithSelector(Ze()).pipe(w(({status:d})=>d!==I.loading)).pipe(v(({list:d})=>d)):J([])))]).pipe(v(([i,d,l,n,m])=>{if(!l&&n)return[f(_({},n),{isEditable:!1,isSelected:!0})];if(l&&n&&m?.length===0)return[f(_({},n),{isEditable:!0,isSelected:!0})];let p=m?Array.from(m):[];if(n&&n.address?.addressId){let u=p.find($=>$.address?.addressId===n.address?.addressId&&X(n.party,$.party));if(!u&&(u=p.find($=>$.address?.addressId===n.address?.addressId),u)){let $=p.indexOf(u);p[$]=f(_({},u),{party:n.party})}}if(d||!n?.party)return p;let O=p?.map(u=>f(_({},u),{party:n.party}));return Ai(O)})):this.storeSelector.getWithSelector(ue).pipe(v(i=>i?[f(_({},i),{isEditable:!0})]:[]))))}getSelectedDeliveryAddressError(){return this.selectedDeliveryAddressError$}deleteShippingAddressFromCart(){return this._deliveryAddressFormIsVisibleSource.next(!1),this._deliveryAddressDataSource.next({}),this.store.dispatch(Nt()),this._addressFormIsVisibleSource.next(!1),this._addressToggleAriadNextSource.next(!1),fe(this.actions$.pipe(j(Rt)).pipe(z(!0)),this.actions$.pipe(j(Ft)).pipe(z(!1)))}deleteBillingAddressFromCart(){return this._billingAddressFormIsVisibleSource.next(!1),this._billingAddressDataSource.next({}),this.store.dispatch(Tt({billing:null})),fe(this.actions$.pipe(j(Dt)).pipe(z(!0)),this.actions$.pipe(j(Pt)).pipe(z(!1)))}checkIfAddressIsCorrect(t){t.address&&!t.address.county.name||t.address&&!t.address.locality.name||t.address&&!t.address.street?.name&&!t.address.streetName||t.party&&!t.party.name?this._selectedDeliveryAddressErrorSource.next(!0):this._selectedDeliveryAddressErrorSource.next(!1)}getDeliveryAddressData(){return this.deliveryAddressData$}getIsDeliveryFormCompleted(){return this.deliveryFormCompleted$}setIsDeliveryFormCompleted(t){return this.deliveryFormCompleted$.next(t)}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(t,i){this._deliveryAddressDataSource.next({deliveryAddress:t,options:i}),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(t,i){this._isBillingAddressEditForm.next(!0),this._billingAddressDataSource.next({billingAddress:t,options:i}),this._billingAddressFormIsVisibleSource.next(!0),this.handleCloseDeliveryAddressForm()}handleEditBillingAddressForCompany(t,i){this._isBillingAddressEditForm.next(!1),this._billingAddressDataSource.next({billingAddress:t,options:i}),this._billingAddressFormIsVisibleSource.next(!0)}handleSelectAddress(t){t.type===de.BILLING&&this.store.dispatch(Xe({selection:Oe.Customer})),!t.party?.type||!t.party?.name?t.type===de.BILLING?this.handleEditBillingAddress(t,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&t&&!t.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(Z).pipe(q(1)).subscribe(i=>{i.verified?this.handleEditDeliveryAddress(t,{autoDirty:!0,emailValueSet:!1}):this.handleGenerateNewAddressOTP(!1,t)}):this.handleEditDeliveryAddress(t,{autoDirty:!0,emailValueSet:!1}):t?.type===de.BILLING&&t.party?.type!==ze.Person?this.handleEditBillingAddressForCompany(t,{autoDirty:!0}):(this.selectorCartItemIsOfyOrLoy||this.hasAtLeastOneLoyaltyProduct)&&t&&!t.otpValidated&&this.isLoggedIn?this.storeSelector.getWithSelector(Z).pipe(q(1)).subscribe(i=>{i.verified?(this.store.dispatch(Te({isKeepBillingDataToggled:!1})),this.store.dispatch(ye({address:t}))):this.handleGenerateNewAddressOTP()}):(this.store.dispatch(Te({isKeepBillingDataToggled:!1})),this.store.dispatch(ye({address:t})))}mapAddressToCommonObject(t,i){return i&&t.address&&(t.address=pe("zipCode",t.address),t.address.locality=pe("zipCode",t.address.locality),t.address.street=pe("zipCode",t.address.street)),t.address=t.address,t.address.apartment=t.address?.apartment?t.address.apartment:"",t.address.building=t.address?.building?t.address.building:"",t.address.streetNo=t.address?.streetNo?t.address.streetNo:"",t.address.staircase=t.address?.staircase?t.address.staircase:"",t}getAddressFormIsVisible(){return this.addressFormVisible$}setAddressToggleAriadNext(t){return this._addressToggleAriadNextSource.next(t)}getAddressToggleAriadNext(){return this.addressToggleAriadNext$}setFixedLocationContactPerson(t,i=!0){this._fixedLocationContactPersonSource.next(t),i&&this.store.dispatch(bt({shippingTypeSelection:Oe.FixedLocation}))}getNotificationChannelByOCN(){return this.http.get(`${He.getCartV2ApiUrl()}/consent/notification-channel`,f(_({},Oi),{responseType:"text"}))}getPreferredNotificationChannel(){return this.preferredNotificationChannel$}setPreferredNotificationChannel(t){return this._preferredNotificationChannelSource.next(t)}generateNewAddressOTP(){this.store.dispatch(wt())}handleGenerateNewAddressOTP(t,i){return this.generateNewAddressOTP(),this.dialogRef=this.matDialog.open(Wt,{maxWidth:"500px",data:{isCompleteOrder:t}}),this.dialogRef.afterClosed()}handleVerifyNewAddressOTP(t,i){this.store.dispatch(Vt({code:t,forced:i}))}toggleAddressUsage(t){this.toggleAddressSubject.next(t)}setEditMode(t){this.editModeSubject.next(t)}getLoggedInUserDeliveryAddresses(){return K([this.storeSelector.getWithSelector(_e),this.storeSelector.getWithSelector(je()).pipe(w(t=>t.status===I.success),v(t=>t.list||[]))]).pipe(v(([t,i])=>this.mergeDeliveryAddresses(i,t)))}getGuestUserDeliveryAddresses(){return this.storeSelector.getWithSelector(_e).pipe(v(t=>t?[f(_({},t),{isEditable:!0,isKeepBillingDataToggled:t.isKeepBillingDataToggled})]:[]))}mergeDeliveryAddresses(t,i){if(!i?.address?.addressId)return t;let d=Array.from(t),l=this.findDeliveryAddressInList(i,d);if(l){let n=d.indexOf(l);d[n]=f(_({},l),{party:i.party})}return d}findDeliveryAddressInList(t,i){return i.find(d=>d.address?.addressId===t.address?.addressId&&X(t.party,d.party))||i.find(d=>d.address?.addressId===t.address?.addressId)}checkShippingAddressIsComplete(t){t?.address&&(!t?.party||!t?.party?.name||!t?.party?.email||!t?.party?.phone)&&this.handleEditDeliveryAddress(t)}};o.\u0275fac=function(i){return new(i||o)(N(le),N(We),N(dt),N(ae),N(at),N(It))},o.\u0275prov=ie({token:o,factory:o.\u0275fac,providedIn:"root"});let e=o;return e})();var U=function(e){return e.ADD_VOUCHER="[Cart] Add voucher",e.ADD_VOUCHER_ERROR="[Cart] Add voucher [Error]",e.ADD_VOUCHER_SUCCESS="[Cart] Add voucher [Success]",e.DELETE_VOUCHER="[Cart] Delete voucher",e.DELETE_VOUCHER_ERROR="[Cart] Delete voucher [Error]",e.DELETE_VOUCHER_SUCCESS="[Cart] Delete voucher [Success]",e}(U||{}),Jr=r(U.ADD_VOUCHER,s()),Qr=r(U.ADD_VOUCHER_ERROR,s()),en=r(U.ADD_VOUCHER_SUCCESS,s()),tn=r(U.DELETE_VOUCHER,s()),on=r(U.DELETE_VOUCHER_ERROR,s()),rn=r(U.DELETE_VOUCHER_SUCCESS,s());var G=function(e){return e.APPLY_NCA_PHONE_CREDIT="[Cart] Apply nca phone credit",e.APPLY_NCA_PHONE_CREDIT_ERROR="[Cart] Apply nca phone credit [Error]",e.APPLY_NCA_PHONE_CREDIT_SUCCESS="[Cart] Apply nca phone credit [Success]",e.SET_PHONE_CREDIT_CONSUMPTION="[Cart] Set phone credit consumption",e.SET_PHONE_CREDIT_CONSUMPTION_ERROR="[Cart] Set phone credit consumption [Error]",e.SET_PHONE_CREDIT_CONSUMPTION_SUCCESS="[Cart] Set phone credit consumption [Success]",e}(G||{}),an=r(G.APPLY_NCA_PHONE_CREDIT,s()),dn=r(G.APPLY_NCA_PHONE_CREDIT_ERROR,s()),ln=r(G.APPLY_NCA_PHONE_CREDIT_SUCCESS,s()),cn=r(G.SET_PHONE_CREDIT_CONSUMPTION,s()),pn=r(G.SET_PHONE_CREDIT_CONSUMPTION_ERROR,s()),un=r(G.SET_PHONE_CREDIT_CONSUMPTION_SUCCESS,s());export{Ii as a,Li as b,Ti as c,Pi as d,Di as e,bi as f,Ni as g,Ri as h,Fi as i,Lt as j,wi as k,Vi as l,Bi as m,ki as n,Mi as o,Ui as p,Gi as q,$i as r,Hi as s,Wi as t,Ki as u,qi as v,zi as w,Le as x,Yi as y,Xi as z,ji as A,Zi as B,Ji as C,Jr as D,Qr as E,en as F,tn as G,on as H,rn as I,an as J,dn as K,ln as L,cn as M,pn as N,un as O,Tt as P,Pt as Q,Dt as R,Te as S,bt as T,to as U,io as V,oo as W,Nt as X,Rt as Y,Ft as Z,wt as _,ro as $,no as aa,Vt as ba,so as ca,ao as da,Bt as ea,So as fa,Co as ga,xo as ha,vo as ia,Oo as ja,Ao as ka,yo as la,Io as ma,Lo as na,To as oa,Po as pa,Do as qa,No as ra,Ro as sa,Fo as ta,wo as ua,Vo as va,Ho as wa,Pe as xa,kt as ya,Wo as za,ue as Aa,_e as Ba,Ko as Ca,Z as Da,qo as Ea,zo as Fa,Yo as Ga,qt as Ha,Xo as Ia,$t as Ja,me as Ka,he as La,Jo as Ma,Kt as Na};