import{a as w,b as y,c as _,d as E,e as j,g as A}from"./chunk-5GJ7UEF2.js";import{a as O,b as F}from"./chunk-CC7H2Q52.js";import{b as N}from"./chunk-TTT4O4HK.js";import{a as L}from"./chunk-P5W63KSA.js";import{n as x,p as D}from"./chunk-YICJB6GR.js";import{a as C}from"./chunk-T73IHJYP.js";import{c as I}from"./chunk-VJXA7ZH3.js";import{b}from"./chunk-5D53DDSO.js";import{o as T,p as l,q as u,r as n}from"./chunk-GW2OL5S3.js";import{C as g,ea as m,ja as S,x as d}from"./chunk-DYUFV4HF.js";import{d as t,n as v}from"./chunk-INB5GR2I.js";import{a as h,b as k}from"./chunk-B7YGBANW.js";v();v();var s,c=(s=class{static suppliers(e){return e.suppliers}setCharacteristics(e,o){e.setState({suppliers:[...o.suppliers]})}clearCharacteristics(e){e.setState({suppliers:[]})}},s.\u0275fac=function(o){return new(o||s)},s.\u0275prov=m({token:s,factory:s.\u0275fac}),s);t([l(O)],c.prototype,"setCharacteristics",null);t([l(F)],c.prototype,"clearCharacteristics",null);t([n()],c,"suppliers",null);c=t([u({name:"suppliers",defaults:{suppliers:[]}})],c);var f,r,a=(r=class{constructor(e,o){this._localStorageService=e,this._store=o,d(window,"storage").pipe(g(i=>i.key==="authState"&&i.newValue!==null)).subscribe(i=>{let p=JSON.parse(i.newValue);this._store.reset(k(h({},this._store.snapshot()),{auth:p}))})}static tokens(e){return e.tokens}static accessToken(e){return e.tokens.accessToken}static accessTokenExpiration(e){return new Date(e.tokenExpiration)}static isAuthenticated(e){return e.tokens.accessToken!==""&&e.tokens.refreshToken!==""}static userName(e){return e.name}static userId(e){return e.userId}setTokens(e,o){let i=E(o.tokens.accessToken),p={name:i.name,phone:i.sub,tokens:o.tokens,userId:i.unique_name,tokenExpiration:new Date(i.exp*1e3).toString()};e.setState(p),this._localStorageService.set("authState",p)}logout(e){e.dispatch(new j(f,x,I,A,_,b,D,C,N,c)).subscribe(()=>{this._localStorageService.remove("selectedCashboxId"),this._localStorageService.remove("shiftOpenDate"),this._localStorageService.remove("paymentMethods"),this._localStorageService.remove("cart"),this._localStorageService.remove("sellPrice"),this._localStorageService.remove("sellDetails"),this._localStorageService.remove("authState")})}},f=r,r.\u0275fac=function(o){return new(o||r)(S(L),S(T))},r.\u0275prov=m({token:r,factory:r.\u0275fac}),r);t([l(w)],a.prototype,"setTokens",null);t([l(y)],a.prototype,"logout",null);t([n()],a,"tokens",null);t([n()],a,"accessToken",null);t([n()],a,"accessTokenExpiration",null);t([n()],a,"isAuthenticated",null);t([n()],a,"userName",null);t([n()],a,"userId",null);a=f=t([u({name:"auth",defaults:{phone:"",name:"",userId:"",tokens:{accessToken:"",refreshToken:""},tokenExpiration:""}})],a);export{c as a,a as b};
//# sourceMappingURL=chunk-VS2SSE5T.js.map
