import{a as o}from"./chunk-I4OLXHWD.js";import{a as u}from"./chunk-PQ7NYIWJ.js";import{m as n}from"./chunk-SOETE4NY.js";import{a as h}from"./chunk-KFDEPCY3.js";import{f as a}from"./chunk-GYAYEJFB.js";import{L as r,aa as c,ea as s,ka as p}from"./chunk-LEOKSAW2.js";var l=(()=>{class t{constructor(e){this._http=e}createPrice(e){return this._http.post("/api/price",e)}updatePrice(e,i){return this._http.put(`/api/price/${e}`,i)}deletePrice(e){return this._http.delete(`/api/price/${e}`)}getPrices(){return this._http.post("/api/price/all",{})}syncPrice(e=!1){return e?this._http.post("/api/price/sync",{},{headers:h}):this._http.post("/api/price/sync",{})}static{this.\u0275fac=function(i){return new(i||t)(p(a))}}static{this.\u0275prov=s({token:t,factory:t.\u0275fac})}}return t})();var S=(()=>{class t{constructor(e,i){this._priceServiceApi=e,this._store=i}createPrice(e){return this._priceServiceApi.createPrice(this._toUpsertModel(e)).pipe(c(()=>this.getPrices().subscribe()),r(1))}updatePrice(e,i){return this._priceServiceApi.updatePrice(e,this._toUpsertModel(i)).pipe(c(()=>this.getPrices().subscribe()),r(1))}deletePrice(e){return this._priceServiceApi.deletePrice(e).pipe(c(()=>this.getPrices().subscribe()),r(1))}getPrices(){return this._priceServiceApi.getPrices().pipe(c(e=>this._store.dispatch(new u({prices:e}))),r(1))}synPrice(e=!1){return this._priceServiceApi.syncPrice(e).pipe(r(1))}_toUpsertModel(e){return{type:e.type,name:e.name,from:e.period?o(e.period[0]):null,to:e.period?o(e.period[1]):null}}static{this.\u0275fac=function(i){return new(i||t)(p(l),p(n))}}static{this.\u0275prov=s({token:t,factory:t.\u0275fac})}}return t})();export{l as a,S as b};
