const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DashboardPage-BjR4wXjL.js","assets/_plugin-vue_export-helper-BDNMzG2s.js","assets/index-BKLG6eUi.js","assets/chunk-DK3Fl9T5.js","assets/index-DUUkodzN.css","assets/VTextField-Bs8XQAKI.js","assets/VTextField-9wSyupY2.css","assets/VDataTable-CvpeYUTC.js","assets/VSelect-Dy70bHJm.js","assets/VSelect-Dq2BX-8H.css","assets/VDataTable-DlpDfCoY.css","assets/VDialog-CfMJJXmK.js","assets/VDialog-DP-kc9Gx.css","assets/VRow-ZHldweuW.js","assets/VRow-DIr3-SqU.css","assets/useSnackbar-BFeYjAzp.js","assets/useSnackbar-ku9EbwM-.css","assets/VSkeletonLoader-0xYOvLhE.js","assets/VSkeletonLoader-CkAIsbz1.css","assets/StatCardsRow-Bl1oSURG.js","assets/StatCardsRow-snFLCRnD.css","assets/usePageActivateRefresh-BXQgZGHS.js","assets/auditNormalize-C-_Ftbtx.js","assets/DashboardPage-C6EeEBsS.css"])))=>i.map(i=>d[i]);
import{Cr as e,Er as t,F as n,I as r,Or as i,Qt as a,Rr as o,Sr as s,Tr as c,Vr as l,Xt as u,Yr as d,Yt as f,Zr as p,Zt as m,an as h,br as g,en as _,hi as v,hr as y,ii as b,in as x,mi as S,xr as C,y as w,yr as T,zr as E}from"./index-BKLG6eUi.js";import{t as D}from"./_plugin-vue_export-helper-BDNMzG2s.js";import{_ as O,t as k}from"./VTextField-Bs8XQAKI.js";import{t as A}from"./VForm-RQIF7g9H.js";var j={class:`login-page`},ee={key:0,class:`login-center`},te={key:2,class:`text-center mt-4`},M=D(i({name:`LoginPage`,__name:`LoginPage`,setup(i){let D=x(),M=h(),N=u(),P=b(`checking`),F=b(``),I=b(``),L=b(``),R=b(!1),z=b(!1),B=b(``),V=b(!1),H=b(0),U=b(null),W=b([]),G=b(0),K=null,q=T(()=>P.value===`checking`?{backgroundColor:`#0a0a12`}:W.value.length===0?{backgroundImage:`linear-gradient(135deg, #1a237e 0%, #0d47a1 40%, #1565c0 100%)`}:{backgroundImage:`url(${W.value[G.value]})`});async function J(){try{let e=await _.get(`/settings/bing-wallpapers`);e?.urls?.length&&(W.value=e.urls,G.value=Math.floor(Math.random()*e.urls.length))}catch{}}function Y(){K&&clearInterval(K),!(W.value.length<=1)&&(K=setInterval(()=>{G.value=(G.value+1)%W.value.length},36e5))}async function X(){P.value=`checking`;try{return await _.get(`/auth/login-access`),P.value=`form`,!0}catch{return P.value=`blocked`,!1}}function Z(){P.value===`form`&&f(()=>import(`./DashboardPage-BjR4wXjL.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))}d(P,e=>{e===`form`&&Z()}),o(async()=>{await X(),await J(),Y()}),E(()=>{K&&clearInterval(K),$&&clearInterval($)});let Q=b(Date.now()),$=null,ne=T(()=>{if(!U.value)return 0;let e=new Date(U.value).getTime()-Q.value;return Math.max(0,Math.ceil(e/6e4))});d(U,e=>{$&&=(clearInterval($),null),e&&($=setInterval(()=>{Q.value=Date.now()},3e4))});async function re(){if(!F.value||!I.value){B.value=`请输入用户名和密码`;return}z.value=!0,B.value=``;try{await N.login(F.value,I.value,V.value?L.value:void 0);let e=D.query.redirect||`/`,t=e.startsWith(`/`)&&!e.startsWith(`//`)?e:`/`;await M.replace(t)}catch(e){if(e instanceof a)V.value=!0,B.value=e.message;else if(e instanceof m){if(e.status===403){P.value=`blocked`;return}e.status===429?(U.value=new Date(Date.now()+900*1e3).toISOString(),B.value=`登录尝试过多，账户已锁定 15 分钟`):(H.value++,B.value=e.message)}else B.value=`网络错误，请重试`}finally{z.value=!1}}return(i,a)=>(l(),e(`div`,j,[g(`div`,{class:`wallpaper-bg`,style:S(q.value)},null,4),a[6]||=g(`div`,{class:`wallpaper-overlay`},null,-1),P.value===`form`?(l(),e(`div`,ee,[t(O,{elevation:`0`,rounded:`xl`,class:`login-card pa-10`,border:``},{default:p(()=>[B.value?(l(),C(n,{key:0,type:`error`,density:`compact`,class:`mb-4`,closable:``,"onClick:close":a[0]||=e=>B.value=``,rounded:`lg`,variant:`tonal`},{default:p(()=>[c(v(B.value),1)]),_:1})):s(``,!0),U.value?(l(),C(n,{key:1,type:`warning`,density:`compact`,class:`mb-4`,rounded:`lg`,variant:`tonal`},{default:p(()=>[c(` 账户已锁定，请 `+v(ne.value)+` 分钟后重试 `,1)]),_:1})):s(``,!0),t(A,{onSubmit:y(re,[`prevent`])},{default:p(()=>[t(k,{modelValue:F.value,"onUpdate:modelValue":a[1]||=e=>F.value=e,label:`用户名`,variant:`outlined`,density:`comfortable`,"prepend-inner-icon":`mdi-account-outline`,disabled:z.value,class:`mb-4`,autocomplete:`username`,rounded:`lg`,"hide-details":`auto`},null,8,[`modelValue`,`disabled`]),t(k,{modelValue:I.value,"onUpdate:modelValue":a[2]||=e=>I.value=e,label:`密码`,variant:`outlined`,density:`comfortable`,"prepend-inner-icon":`mdi-lock-outline`,"append-inner-icon":R.value?`mdi-eye`:`mdi-eye-off`,type:R.value?`text`:`password`,"onClick:appendInner":a[3]||=e=>R.value=!R.value,disabled:z.value,class:`mb-4`,autocomplete:`current-password`,rounded:`lg`,"hide-details":`auto`},null,8,[`modelValue`,`append-inner-icon`,`type`,`disabled`]),V.value?(l(),C(k,{key:0,modelValue:L.value,"onUpdate:modelValue":a[4]||=e=>L.value=e,label:`TOTP 验证码`,variant:`outlined`,density:`comfortable`,"prepend-inner-icon":`mdi-shield-key-outline`,disabled:z.value,class:`mb-4`,autocomplete:`one-time-code`,rounded:`lg`,"hide-details":`auto`},null,8,[`modelValue`,`disabled`])):s(``,!0),t(r,{type:`submit`,color:`primary`,variant:`flat`,block:``,size:`large`,loading:z.value,disabled:!!U.value,rounded:`lg`,class:`mt-2`,height:`48`},{default:p(()=>[...a[5]||=[c(` 登录 `,-1)]]),_:1},8,[`loading`,`disabled`])]),_:1}),H.value>0&&!U.value?(l(),e(`div`,te,[t(w,{size:`small`,variant:`tonal`,color:`warning`,label:``},{default:p(()=>[c(` 已失败 `+v(H.value)+` 次 `,1)]),_:1})])):s(``,!0)]),_:1})])):s(``,!0)]))}}),[[`__scopeId`,`data-v-5c1d22f2`]]);export{M as default};