import{j as e,P as t,y as n,Q as a,O as o,G as r,H as u,B as i,z as s}from"./index-Bu3F9tAw.js";const d="mingdao_guide_phone_change_state";function c(){const e=s(a)||null;return e&&e.expiresAt&&Number(e.expiresAt)<=Date.now()?(f(),null):e}function h(){const e=c();return Boolean(e&&e.token)}function m({phone:o,code:r}){return o&&r?e({url:"/guide/auth/login",method:"POST",authenticated:!1,data:{phone:o,code:r}}).then(e=>{const r=e.user||{},u=Number(e.expiresIn);f();const i={token:e.token,expiresIn:e.expiresIn,expiresAt:Number.isFinite(u)&&u>0?Date.now()+1e3*u:null,guide:{...t,id:r.id,name:r.realName||r.username||t.name,phone:r.mobile||o,avatar:r.avatar||t.avatar,rating:Number(r.rating||0),orderCount:r.acceptedOrderCount||0,auditStatus:(s=r.status,1===s?"approved":2===s?"pending":0===s?"disabled":"pending"),onlineStatus:"offline",groupName:r.teamName||("个人"===r.teamType?"个人导游":t.groupName)}};var s;return n(a,i),Promise.resolve(!1),i}):Promise.reject(new Error("请输入手机号和验证码"))}function l(t){return e({url:"/guide/auth/sms-code",method:"POST",authenticated:!1,data:{phone:t,scene:"login"}})}function p(){const t=c();return t&&t.token?e({url:"/guide/push-device",method:"DELETE"}).catch(()=>{}).then(()=>e({url:"/guide/auth/logout",method:"POST"})).finally(()=>f()):(f(),Promise.resolve())}function g(){return e({url:"/guide/push-device",method:"DELETE"}).catch(()=>{}).then(()=>e({url:"/guide/auth/account",method:"DELETE"})).then(e=>(f(),e))}function f(){[a,o,r,u,d].forEach(e=>i(e))}export{g as a,p as b,f as c,c as g,h as i,m as l,l as s};