import{a as ae}from"./chunk-HUICIZ5O.js";import{c as re,f as se,i as oe}from"./chunk-CFHNCEOZ.js";import{A as F,B as Ht,C as x,c as bt,f as Rt,i as Dt,k as Ut,l as kt,o as jt,q as Gt,s as Qt,x as L,y as zt,z as V}from"./chunk-ECXJG4VG.js";import{b as ie}from"./chunk-YICBAQ54.js";import{m as Mt}from"./chunk-S6VYT6EF.js";import{b as z,v as ne}from"./chunk-MOFR7S7Z.js";import{p as Nt}from"./chunk-W7Q3ZR5P.js";import{c as It,i as $t,l as Tt,o as wt,s as Ot}from"./chunk-FTLECNUN.js";import{U as Vt,_ as Ft,ba as xt,i as qt,q as Bt,y as Lt}from"./chunk-GKLBE5HV.js";import{A,d as j,f as Jt,l as Kt,n as Wt,q as Xt,s as Yt,t as Zt,u as _t,v as G,w as Q,x as te,y as h}from"./chunk-UEOXMUTA.js";import{f as Et}from"./chunk-FD3QQVVQ.js";import{o as ee}from"./chunk-JGKGTLYA.js";import{B as ot,C as nt,Ca as ut,D as f,E as S,Ea as mt,Ha as lt,I as pt,Va as ft,Wa as ht,a as I,b as Z,c as _,d as $,e as v,f as tt,fb as B,g as et,h as N,i as rt,j as M,k as b,kb as yt,l as it,lb as Ct,ma as ct,n,o as T,p as w,q as O,s as R,t as D,tb as Pt,u as at,v as U,x as k,xa as dt,xb as St,y as st,z as q}from"./chunk-XS4DMB2U.js";import{b as i,c as vt,d as a}from"./chunk-XA6AU52H.js";import{b as At,s as gt}from"./chunk-YFWLORNM.js";import{s as Y}from"./chunk-VYUKN3XQ.js";import{k as X}from"./chunk-AWMJHCA7.js";import{Da as s,Ga as g,K as u,Na as W,P as o,Sa as l,W as J,_ as K,ca as c,ia as E}from"./chunk-XNQ3RS5P.js";var ue=()=>t=>t.data&&t.data.clearCart&&!t.errors?[tt()]:t.errors?[v({errors:t.errors})]:[v({errors:[new Error("handleClearCartResponse communication error")]}),n({failedAction:$.type})],me=t=>t.data&&!t.errors?M():t.errors?rt({errors:t.errors}):n({failedAction:N.type}),le=t=>{var r,H,y;if((r=t==null?void 0:t.errors)!=null&&r.length)return u(Z({errors:t.errors}));if((H=t==null?void 0:t.data)!=null&&H.cartV2){let C=[_({cart:t.data.cartV2}),Wt({quantity:pt((y=t==null?void 0:t.data)==null?void 0:y.cartV2)})];return u(...C)}return u(n({failedAction:I.type}))},fe=t=>t.data&&t.data.setTelewebInfo&&!t.errors?q():t.errors?st({errors:t.errors}):n({failedAction:k.type}),he=t=>r=>r.data&&r.data.setOtyConsumption&&!r.errors?O({oty:t}):r.errors?w({errors:r.errors}):n({failedAction:T.type}),ye=t=>t.data&&t.data.setPayment&&!t.errors?U():t.errors?at({errors:t.errors}):n({failedAction:D.type}),d=t=>r=>u(n({failedAction:t.type,error:r})),Ce=()=>t=>t.data&&t.data.generateNewAddressOTP&&!t.errors?V({data:t.data}):t.data&&t.errors?zt({errors:t.errors}):n({failedAction:L.type}),Pe=()=>t=>t.data&&t.data.verifyNewAddressOTP&&!t.errors?x({data:t.data}):t.data&&t.errors?Ht({errors:t.errors}):n({failedAction:F.type}),Se=t=>r=>r.data&&r.data.updatePpy2PpdMsisdn&&!r.errors?h.updatePpy2PpdMsisdnSuccess({msisdn:t}):r.data&&r.errors?h.updatePpy2PpdMsisdnError({errors:r.errors}):n({failedAction:h.updatePpy2PpdMsisdn.type}),Ae=t=>r=>r.data&&r.data.updatePpy2PpdMsisdn&&!r.errors?A.updatePpyPrepayMsisdnSuccess({msisdn:t}):r.data&&r.errors?A.updatePpyPrepayMsisdnError({errors:r.errors}):n({failedAction:A.updatePpyPrepayMsisdn.type}),Xe=(()=>{let r=class r{constructor(y,C,pe,ce,de){this.actions$=y,this.cartApolloClient=C,this.router=pe,this.store=ce,this.snackBar=de,this.dismissNotification$=i(()=>this.actions$.pipe(a(N)).pipe(s(e=>this.cartApolloClient.mutate({mutation:ut,variables:{notifications:[{notificationId:e.notification.id,cartItemId:e.notification.itemRef&&e.notification.itemRef.itemId}]}}).pipe(o(me))))),this.eShopCartChange$=i(()=>J(window,"message").pipe(K(e=>e.data==="eShopCartChange")).pipe(E(b()))),this.getCart$=i(()=>this.actions$.pipe(a(I),s(e=>this.cartApolloClient.query({query:mt}).pipe(s(le)).pipe(c(d(e)))))),this.logCommunicationError$=i(()=>this.actions$.pipe(a(n),g(console.error)),{dispatch:!1}),this.reloadCart$=i(()=>this.actions$.pipe(a(j,Nt,bt,se,oe,Dt,re,Rt,M,b,jt,Qt,Xt,O,U,kt,q,gt,Bt,Vt,qt,It,$t,Tt,wt,V,x,f.updateInstallmentPeriodSuccess,f.updateInstallmentPeriodError,G.updateSimOptionSuccess,G.updateSimOptionError,Q.updatePrepayProductTypeSuccess,Q.updatePrepayProductTypeError,te.updateSubscriptionTypeSuccess,h.updatePpy2PpdMsisdnSuccess,Ft,xt,Lt,Ot),s(e=>e.type===j.type&&e.triggerGetCart===!1?[S.getItemIds()]:[I(),Mt()]))),this.updateCartStateFromResponse=i(()=>this.actions$.pipe(a(Zt,Jt,Kt),o(e=>e.cart?_t({cart:e.cart}):ee()))),this.reloadCartFromLocalStore$=i(()=>this.actions$.pipe(a(w,Ut,Yt),o(()=>it()))),this.reloadCartOnProfileChange$=i(()=>this.actions$.pipe(a(At)).pipe(E(et()))),this.resetCart$=i(()=>this.actions$.pipe(a($)).pipe(s(()=>this.cartApolloClient.mutate({mutation:dt}))).pipe(s(ue())).pipe(c(()=>u(n({failedAction:$.type}))))),this.setCartImpersonation$=i(()=>this.actions$.pipe(a(k),s(e=>this.cartApolloClient.mutate({mutation:Pt,variables:{teleweb:{callType:e.callType,userType:e.userType}}}).pipe(o(fe)).pipe(c(d(e)))))),this.updateInstallmentPeriod$=i(()=>this.actions$.pipe(a(f.updateInstallmentPeriod),s(e=>this.cartApolloClient.mutate({mutation:St,variables:{term:e.period}}).pipe(o(p=>p.data?f.updateInstallmentPeriodSuccess():f.updateInstallmentPeriodError()),c(d(e)))))),this.setOtyConsumption$=i(()=>this.actions$.pipe(a(T),s(e=>this.cartApolloClient.mutate({mutation:yt,variables:{value:e.oty,unit:ct.Fix}}).pipe(o(he(e.oty))).pipe(c(d(e)))))),this.setOtyConsumptionError$=i(()=>this.actions$.pipe(a(w),o(e=>e.errors.find(p=>p.message.toLowerCase().trim()==="Value provided for oty consumption thresholds:1 exceeds maximum allowed oty points: 0".toLowerCase().trim())?T({oty:0}):ae()))),this.setOtyConsumptionSuccess$=i(()=>this.actions$.pipe(a(O),g(e=>{(e==null?void 0:e.oty)>=1&&this.store.dispatch(R())})),{dispatch:!1}),this.openShowUseOtyMessageNotification$=i(()=>this.actions$.pipe(a(R),g(()=>{this.snackBar.open("Valoarea punctelor a fost sc\u0103zut\u0103 din totalul de plat\u0103.","x",{horizontalPosition:"center",verticalPosition:"top",duration:5e3})})),{dispatch:!1}),this.setPayment$=i(()=>this.actions$.pipe(a(D),s(e=>this.cartApolloClient.mutate({mutation:Ct,variables:{method:e.method,parameters:e.parameters||[]}}).pipe(o(ye)).pipe(c(d(e)))))),this.setTab$=i(()=>this.actions$.pipe(a(ot,nt),s(e=>u(Gt({shippingTypeSelection:e.shippingTypeSelection}))))),this.generateNewAddressOTP$=i(()=>this.actions$.pipe(a(L),s(e=>this.cartApolloClient.mutate({mutation:ft}).pipe(o(Ce())).pipe(c(d(e)))))),this.verifyNewAddressOTP$=i(()=>this.actions$.pipe(a(F),s(e=>{let p={code:e.code};return e.forced&&(p.forced=e.forced),this.cartApolloClient.mutate({mutation:ht,variables:p}).pipe(o(Pe())).pipe(c(d(e)))}))),this.updatePpy2PpdNotLoggedMsisdn$=i(()=>this.actions$.pipe(a(h.updatePpy2PpdMsisdn),s(e=>this.cartApolloClient.mutate({mutation:B,variables:{msisdn:e.msisdn}}).pipe(o(Se(e.msisdn))).pipe(c(d(e)))))),this.updatePpyPrepayMsisdn$=i(()=>this.actions$.pipe(a(A.updatePpyPrepayMsisdn),s(e=>this.cartApolloClient.mutate({mutation:B,variables:{msisdn:e.msisdn}}).pipe(o(Ae(e.msisdn))).pipe(c(d(e)))))),this.getUnofferedCartItemIds$=i(()=>this.actions$.pipe(a(S.getItemIds,z),s(e=>e.type===z.type&&e.recommendationsRequest.type!==ne.BoughtTogether?u():this.cartApolloClient.query({query:lt}).pipe(o(p=>p.data&&p.data.unofferedCart&&p.data.unofferedCart.__typename!=="EmptyCartResource"?S.getItemIdsSuccess({ids:p.data.unofferedCart.items.filter(m=>{var P;return!!((P=m==null?void 0:m.product)!=null&&P.id)}).map(m=>{var P;return(P=m==null?void 0:m.product)==null?void 0:P.id})}):S.getItemIdsError())))))}};r.\u0275fac=function(C){return new(C||r)(l(vt),l(ie),l(X),l(Y),l(Et))},r.\u0275prov=W({token:r,factory:r.\u0275fac});let t=r;return t})();export{d as a,Xe as b};