import{b as S,c as h,d as p,s as g,K as d,R as a,L as k,r,i as I,P as T,Q as v,T as E,U as M,V as A,W as m,g as y,X as O,Y as R,Z as b,$ as D,a0 as L,a1 as V}from"./index-gATdONBG.js";const w=()=>{const e=S(),s=h(),n=p(g),c=d(a.Menu),o=d(a.Offline),{disposition:u}=p(k);r.useEffect(()=>{if(!I||!n)return;const f=t=>m.some(i=>t[i]==="on");(()=>{s(T.endpoints.fetchStoreStatus.initiate(v,{forceRefetch:!0})).unwrap().then(({status:t,store:i})=>{if(!f(t)){e(a.Offline);return}if(o&&f(t)){e(a.Menu);return}try{s(E(i)),s(M({pinned:{geometry:{point:i.location.coordinates}}})),!u&&c&&s(A(!0))}catch{}finally{}}).catch(({data:{error:t}})=>{e(a.Error)})})()},[s,c,o,e,u,n])},C=()=>{const e=h(),s=S(),n=p(y),c=p(O),o=r.useCallback(()=>{e(R()).unwrap().then(l=>{}).catch(l=>{s(a.Error)})},[e,s]),u=r.useCallback(()=>{n&&e(b()).catch(l=>{}).finally(()=>{e(D(!0)),s(a.Home),o()})},[e,o,n,s]),f=r.useCallback(()=>{e(L()).unwrap().then(l=>{}).catch(()=>{u()})},[e,u]);r.useEffect(()=>{n||o()},[o,n]),r.useEffect(()=>{const{expiry:t}=c,i=setInterval(()=>{t&&V(t)&&f()},1e4);return()=>{clearInterval(i)}},[f,c])};export{w as a,C as u};