import{l as x,u as M,i as w,A as _,ax as f,c as g,D as B,x as t,G as C,a as i,b as u,w as y,af as V,o as d,at as b,s as U,a2 as N}from"./entry-721bede.js";import{b as S,a as $,g as h,h as A,_ as K,c as L,k as D}from"./passwordModalStore-721bede.js";const F=""+new URL("locked_bar-721bede.png",import.meta.url).href,P={"data-id":"page-login",class:"w-full min-h-[calc(100vh-2rem)] flex flex-col items-center justify-center gap-6"},H=x({__name:"login",setup(T){M({title:"🔒 BUSY Bar Virtual LAN",meta:[{name:"description",content:"[Locked] Control your BUSY Bar in the browser"}]});const o=S(),s=$(),n=h(),c=w(!0),a=w(!1);async function p(){if(!a.value){a.value=!0;try{n.apiKey=o.passwordModel.current,s.busyBar.setApiKey(n.apiKey),await s.fetchDeviceName(!0),await f("/")}catch(l){l?.status===403?(n.apiKey=null,o.passwordModel.current="",o.passwordModel.currentWrong=!0):await A(l,"Failed to unlock Virtual LAN")}a.value=!1}}return _(async()=>{try{await s.fetchDeviceName(!0),await f("/")}catch{}setTimeout(()=>{c.value=!1},500)}),(l,e)=>{const m=V,v=L,k=K;return d(),g("div",P,[t(c)?B("",!0):(d(),g(C,{key:0},[e[5]||(e[5]=i("div",{class:"text-xl font-medium"},"Virtual LAN is locked",-1)),e[6]||(e[6]=i("img",{src:F,class:"w-[300px] my-4"},null,-1)),e[7]||(e[7]=i("div",null,"Enter your password to unlock",-1)),u(k,{class:"w-full",error:t(o).currentPasswordValidation},{default:y(()=>[b((d(),U(v,{modelValue:t(o).passwordModel.current,"onUpdate:modelValue":[e[1]||(e[1]=r=>t(o).passwordModel.current=r),e[2]||(e[2]=r=>t(o).passwordModel.currentWrong=!1)],name:"current-password",size:"xl",variant:"soft",type:t(o).passwordModel.showCurrent?"text":"password",placeholder:"Password",onKeyup:e[3]||(e[3]=N(r=>t(a)?null:p(),["enter"]))},{trailing:y(()=>[u(m,{icon:t(o).passwordModel.showCurrent?"i-ri-eye-close-line":"i-ri-eye-line",variant:"ghost",color:"neutral",square:"",class:"rounded-full",ui:{leadingIcon:"size-6 text-muted"},onClick:e[0]||(e[0]=r=>t(o).passwordModel.showCurrent=!t(o).passwordModel.showCurrent)},null,8,["icon"])]),_:1},8,["modelValue","type"])),[[t(D),"##########"]])]),_:1},8,["error"]),u(m,{"data-id":"page-login-unlock-button",label:"Unlock",color:"primary",size:"lg",class:"h-10",block:"",loading:t(a),onClick:e[4]||(e[4]=r=>p())},null,8,["loading"])],64))])}}});export{H as default};
