import{a as g}from"./chunk-XBPTTTIQ.js";import{a as Ue}from"./chunk-H5GQSNUI.js";import{A as ve,B as ye,C as Fe,R as Ee,a as X,b as Y,c as z,d as J,e as Q,f as Z,g as _,h as ee,ha as $e,i as te,ia as Be,j as ie,ja as Re,k as re,l as oe,m as se,n as ae,o as ne,p as ce,q as le,r as pe,s as de,t as ue,u as me,v as fe,w as he,x as Se,y as Le,z as ge}from"./chunk-BZVEPVRA.js";import{m as x,n as xe,o as Ae,q as A,r as Ie,s as I,t as De,u as D,v as C,w as Ce}from"./chunk-ECXJG4VG.js";import{a as Te}from"./chunk-L3AKYAI7.js";import{b as Oe}from"./chunk-YICBAQ54.js";import{Cb as H,Ub as N,ac as V,ib as M,jb as w,ka as p,n as L,rb as P,sb as G}from"./chunk-XS4DMB2U.js";import{b as d,c as W,d as u}from"./chunk-XA6AU52H.js";import{o as K}from"./chunk-DAYGRJHR.js";import{A as o,B as k,D as s,E as l,s as q}from"./chunk-VYUKN3XQ.js";import{Da as S,Ga as F,Ia as b,K as R,Na as j,P as f,Sa as c,a as i,b as r,ca as h}from"./chunk-XNQ3RS5P.js";var Pe={searchedFixedLocations:l(),fixedLocation:l(),counties:l(),localities:l(),favoriteOrLastUsedLocation:l(),filterInput:"",countyInput:null,localityInput:null,locationMarker:null,selectedLocation:null,showSkeletons:!1},Ye=k(Pe,o(X,(e,{fixedLocationSearchRequestInput:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.loading,request:t})})),o(Y,(e,{searchedFixedLocations:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.success,data:t}),filterInput:""})),o(z,(e,{error:t})=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.error,error:t})})),o(J,(e,{id:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.loading,request:t})})),o(Q,(e,{fixedLocation:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.success,data:t})})),o(Z,(e,{error:t})=>r(i({},e),{fixedLocation:r(i({},e.fixedLocation),{status:s.error,error:t})})),o(_,e=>r(i({},e),{searchedFixedLocations:r(i({},e.searchedFixedLocations),{status:s.initial,request:void 0,data:void 0})})),o(ee,(e,{filter:t})=>r(i({},e),{filterInput:t})),o(te,e=>r(i({},e),{filterInput:""})),o(ie,(e,{countryCode:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.loading,request:t})})),o(re,(e,{counties:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.success,data:t})})),o(oe,(e,{error:t})=>r(i({},e),{counties:r(i({},e.counties),{status:s.error,error:t})})),o(se,(e,{countyId:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.loading,request:t})})),o(ae,(e,{localities:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.success,data:t})})),o(ne,(e,{error:t})=>r(i({},e),{localities:r(i({},e.localities),{status:s.error,error:t})})),o(ce,e=>r(i({},e),{localities:r(i({},e.localities),{status:s.initial,data:void 0,request:void 0})})),o(le,(e,{locationMarker:t})=>r(i({},e),{locationMarker:t})),o(pe,de,(e,{location:t})=>r(i({},e),{selectedLocation:t})),o(ue,(e,{showSkeletons:t})=>r(i({},e),{showSkeletons:t})),o(me,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.loading,request:t})})),o(Le,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.success,data:t})})),o(fe,(e,{fixedLocation:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.success,data:r(i(i({},e.favoriteOrLastUsedLocation.data),t),{isFavorite:!0})})})),o(he,ge,(e,{error:t})=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.error,error:t})})),o(Se,e=>r(i({},e),{favoriteOrLastUsedLocation:r(i({},e.favoriteOrLastUsedLocation),{status:s.loading,request:null})})),o(ve,(e,{countyInput:t})=>r(i({},e),{countyInput:t})),o(ye,(e,{localityInput:t})=>r(i({},e),{localityInput:t})),o(Fe,e=>r(i({},e),{countyInput:null,localityInput:null})),o(N,e=>i({},e)));var Ge=e=>e.data&&!e.errors?Ae():e.errors?xe({errors:e.errors}):L({failedAction:x.type}),He=e=>e.data&&!e.errors?I():e.errors?Ie({errors:e.errors}):L({failedAction:A.type}),Ke=e=>e.data&&!e.errors?C():e.errors?Ce({errors:e.errors}):L({failedAction:D.type}),At=(()=>{let t=class t{constructor(O,v,be,je,qe,ke){this.actions$=O,this.cartApolloClient=v,this.store=be,this.storeSelector=je,this.cartDeliveryAddressService=qe,this.portInDeliveryAddressService=ke,this.setBilling$=d(()=>this.actions$.pipe(u(x),S(a=>this.cartApolloClient.mutate({mutation:a.billing!==null?w:M,variables:{billing:a.billing}}).pipe(f(Ge)).pipe(h(g(a)))))),this.setShipping$=d(()=>this.actions$.pipe(u(A),b(this.store.select(Ee),this.storeSelector.getWithSelector(V(H.DELIVERY)),this.cartDeliveryAddressService.fixedLocationContactPerson$,this.store.select($e)),S(([a,E,n,U,Me])=>{var T,$,B;let y=null,m=null;if(n&&(n.address&&(y=Te.toAddressResource(n)),n.party&&(m={name:(T=n.party)==null?void 0:T.name,phone:($=n.party)==null?void 0:$.phone,email:(B=n.party)==null?void 0:B.email})),y===null&&a.shippingTypeSelection===p.Customer||E===null&&a.shippingTypeSelection===p.FixedLocation)return R(De());a.shippingTypeSelection===p.FixedLocation&&(m=Object.keys(U).length?U:null);let we={address:y,contactPerson:m,shippingType:{fixedLocation:E,selection:a.shippingTypeSelection},isKeepBillingDataToggled:Me===Re.BILLING};return a.shippingTypeSelection===p.FixedLocation&&!m&&this.cartDeliveryAddressService.setEditMode(!1),a.shippingTypeSelection===p.Customer&&this.cartDeliveryAddressService.setEditMode(!1),this.cartApolloClient.mutate({mutation:G,variables:{shipping:we}}).pipe(f(He),h(g(a)))}))),this.deleteShipping$=d(()=>this.actions$.pipe(u(D),S(a=>this.cartApolloClient.mutate({mutation:P}).pipe(f(Ke),h(g(a)))))),this.setBillingOnSetShippingSuccess$=d(()=>this.actions$.pipe(u(I),F(()=>{this.cartDeliveryAddressService.setDeliveryAddressSuccess$.next("emit")})),{dispatch:!1}),this.deleteShippingSuccess$=d(()=>this.actions$.pipe(u(C),F(()=>{this.portInDeliveryAddressService.setShowAddressToggle(!0)})),{dispatch:!1})}};t.\u0275fac=function(v){return new(v||t)(c(W),c(Oe),c(q),c(K),c(Be),c(Ue))},t.\u0275prov=j({token:t,factory:t.\u0275fac});let e=t;return e})();export{Ye as a,He as b,At as c};