import{a as g}from"./chunk-YO5I7UZC.js";import{a as Ue}from"./chunk-CA55Z7MR.js";import{A as Se,B as Le,C as ge,R as De,a as X,b as Y,c as z,d as G,da as Ee,e as J,f as K,g as N,h as Q,i as Z,ia as Oe,j as _,k as ee,l as te,m as ie,n as re,o as oe,p as se,q as ae,r as ne,s as ce,t as le,u as pe,v as de,w as ue,x as fe,y as me,z as he}from"./chunk-VT3KAENN.js";import{a as F,b as ve,c as ye,g as A,h as xe,i as I,j as Fe,k as D,l as C,m as Ae}from"./chunk-VIRBXNP6.js";import{a as Ce}from"./chunk-PA7GCALF.js";import{b as Ie}from"./chunk-SMNAC7CE.js";import{Da as q,E as p,Ea as B,Ma as k,Na as M,Xa as w,nb as H,vb as V}from"./chunk-73GUXIT2.js";import{n as L}from"./chunk-HRYIRC5N.js";import{b as d,c as W,d as u}from"./chunk-GXS7C5SQ.js";import{o as P}from"./chunk-JJTPXY4D.js";import{A as o,B as j,D as s,E as l,s as b}from"./chunk-ALDBR463.js";import{Ba as x,Da as T,F as $,Ia as R,K as m,Na as c,Z as h,a as t,b as i,ya as S}from"./chunk-V6BPA3D7.js";var Be={searchedFixedLocations:l(),fixedLocation:l(),counties:l(),localities:l(),favoriteOrLastUsedLocation:l(),filterInput:"",countyInput:null,localityInput:null,locationMarker:null,selectedLocation:null,showSkeletons:!1},Xe=j(Be,o(X,(e,{fixedLocationSearchRequestInput:r})=>i(t({},e),{searchedFixedLocations:i(t({},e.searchedFixedLocations),{status:s.loading,request:r})})),o(Y,(e,{searchedFixedLocations:r})=>i(t({},e),{searchedFixedLocations:i(t({},e.searchedFixedLocations),{status:s.success,data:r}),filterInput:""})),o(z,(e,{error:r})=>i(t({},e),{searchedFixedLocations:i(t({},e.searchedFixedLocations),{status:s.error,error:r})})),o(G,(e,{id:r})=>i(t({},e),{fixedLocation:i(t({},e.fixedLocation),{status:s.loading,request:r})})),o(J,(e,{fixedLocation:r})=>i(t({},e),{fixedLocation:i(t({},e.fixedLocation),{status:s.success,data:r})})),o(K,(e,{error:r})=>i(t({},e),{fixedLocation:i(t({},e.fixedLocation),{status:s.error,error:r})})),o(N,e=>i(t({},e),{searchedFixedLocations:i(t({},e.searchedFixedLocations),{status:s.initial,request:void 0,data:void 0})})),o(Q,(e,{filter:r})=>i(t({},e),{filterInput:r})),o(Z,e=>i(t({},e),{filterInput:""})),o(_,(e,{countryCode:r})=>i(t({},e),{counties:i(t({},e.counties),{status:s.loading,request:r})})),o(ee,(e,{counties:r})=>i(t({},e),{counties:i(t({},e.counties),{status:s.success,data:r})})),o(te,(e,{error:r})=>i(t({},e),{counties:i(t({},e.counties),{status:s.error,error:r})})),o(ie,(e,{countyId:r})=>i(t({},e),{localities:i(t({},e.localities),{status:s.loading,request:r})})),o(re,(e,{localities:r})=>i(t({},e),{localities:i(t({},e.localities),{status:s.success,data:r})})),o(oe,(e,{error:r})=>i(t({},e),{localities:i(t({},e.localities),{status:s.error,error:r})})),o(se,e=>i(t({},e),{localities:i(t({},e.localities),{status:s.initial,data:void 0,request:void 0})})),o(ae,(e,{locationMarker:r})=>i(t({},e),{locationMarker:r})),o(ne,ce,(e,{location:r})=>i(t({},e),{selectedLocation:r})),o(le,(e,{showSkeletons:r})=>i(t({},e),{showSkeletons:r})),o(pe,(e,{fixedLocation:r})=>i(t({},e),{favoriteOrLastUsedLocation:i(t({},e.favoriteOrLastUsedLocation),{status:s.loading,request:r})})),o(me,(e,{fixedLocation:r})=>i(t({},e),{favoriteOrLastUsedLocation:i(t({},e.favoriteOrLastUsedLocation),{status:s.success,data:r})})),o(de,(e,{fixedLocation:r})=>i(t({},e),{favoriteOrLastUsedLocation:i(t({},e.favoriteOrLastUsedLocation),{status:s.success,data:i(t(t({},e.favoriteOrLastUsedLocation.data),r),{isFavorite:!0})})})),o(ue,he,(e,{error:r})=>i(t({},e),{favoriteOrLastUsedLocation:i(t({},e.favoriteOrLastUsedLocation),{status:s.error,error:r})})),o(fe,e=>i(t({},e),{favoriteOrLastUsedLocation:i(t({},e.favoriteOrLastUsedLocation),{status:s.loading,request:null})})),o(Se,(e,{countyInput:r})=>i(t({},e),{countyInput:r})),o(Le,(e,{localityInput:r})=>i(t({},e),{localityInput:r})),o(ge,e=>i(t({},e),{countyInput:null,localityInput:null})),o(H,e=>t({},e)));var ke=e=>e.data&&!e.errors?ye():e.errors?ve({errors:e.errors}):L({failedAction:F.type}),Me=e=>e.data&&!e.errors?I():e.errors?xe({errors:e.errors}):L({failedAction:A.type}),we=e=>e.data&&!e.errors?C():e.errors?Ae({errors:e.errors}):L({failedAction:D.type}),yt=(()=>{class e{constructor(E,v,$e,Te,Re,be){this.actions$=E,this.cartApolloClient=v,this.store=$e,this.storeSelector=Te,this.cartDeliveryAddressService=Re,this.portInDeliveryAddressService=be,this.setBilling$=d(()=>this.actions$.pipe(u(F),S(a=>this.cartApolloClient.mutate({mutation:a.billing!==null?B:q,variables:{billing:a.billing}}).pipe(m(ke)).pipe(h(g(a)))))),this.setShipping$=d(()=>this.actions$.pipe(u(A),T(this.store.select(De),this.storeSelector.getWithSelector(V(w.DELIVERY)),this.cartDeliveryAddressService.fixedLocationContactPerson$,this.store.select(Ee)),S(([a,O,n,U,je])=>{let y=null,f=null;if(n&&(n.address&&(y=Ce.toAddressResource(n)),n.party&&(f={name:n.party?.name,phone:n.party?.phone,email:n.party?.email})),y===null&&a.shippingTypeSelection===p.Customer||O===null&&a.shippingTypeSelection===p.FixedLocation)return $(Fe());a.shippingTypeSelection===p.FixedLocation&&(f=Object.keys(U).length?U:null);let qe={address:y,contactPerson:f,shippingType:{fixedLocation:O,selection:a.shippingTypeSelection},shippingAddressSourceSubResource:je};return a.shippingTypeSelection===p.FixedLocation&&!f&&this.cartDeliveryAddressService.setEditMode(!1),a.shippingTypeSelection===p.Customer&&this.cartDeliveryAddressService.setEditMode(!1),this.cartApolloClient.mutate({mutation:M,variables:{shipping:qe}}).pipe(m(Me),h(g(a)))}))),this.deleteShipping$=d(()=>this.actions$.pipe(u(D),S(a=>this.cartApolloClient.mutate({mutation:k}).pipe(m(we),h(g(a)))))),this.setBillingOnSetShippingSuccess$=d(()=>this.actions$.pipe(u(I),x(()=>{this.cartDeliveryAddressService.setDeliveryAddressSuccess$.next("emit")})),{dispatch:!1}),this.deleteShippingSuccess$=d(()=>this.actions$.pipe(u(C),x(()=>{this.portInDeliveryAddressService.setShowAddressToggle(!0)})),{dispatch:!1})}static{this.\u0275fac=function(v){return new(v||e)(c(W),c(Ie),c(b),c(P),c(Oe),c(Ue))}}static{this.\u0275prov=R({token:e,factory:e.\u0275fac})}}return e})();export{Xe as a,Me as b,yt as c};