import{l as M,u as _,i as f,A as B,at as b,c as v,D as C,x as t,G as U,a as d,b as u,w as y,aG as g,af as V,o as c,au as L,s as N,a2 as S}from"./entry-b0c82b4.js";import{b as $,a as A,j as K,i as h,_ as D,c as E,k as F}from"./passwordModalStore-b0c82b4.js";const P=""+new URL("locked_bar-b0c82b4.png",import.meta.url).href,T={"data-id":"page-login",class:"w-full min-h-[calc(100vh-2rem)] flex flex-col items-center justify-center gap-6"},H=M({__name:"login",setup(z){_({title:"🔒 BUSY Bar Virtual LAN",meta:[{name:"description",content:"[Locked] Control your BUSY Bar in the browser"}]});const o=$(),n=A(),s=K(),p=f(!0),a=f(!1);async function m(){if(!a.value){a.value=!0;try{s.apiKey=o.passwordModel.current,n.busyBar.setApiKey(s.apiKey),await n.fetchDeviceName(!0),await g("/")}catch(i){i?.status===403?(s.apiKey=null,o.passwordModel.current="",o.passwordModel.currentWrong=!0):await h(i,"Failed to unlock Virtual LAN")}a.value=!1}}async function l(){try{await n.fetchDeviceName(!0),await g("/")}catch{}setTimeout(()=>{p.value=!1},500)}return B(async()=>{await l(),window.addEventListener("device-reconnected",l)}),b(()=>window.removeEventListener("device-reconnected",l)),(i,e)=>{const w=V,k=E,x=D;return c(),v("div",T,[t(p)?C("",!0):(c(),v(U,{key:0},[e[5]||(e[5]=d("div",{class:"text-xl font-medium"},"Virtual LAN is locked",-1)),e[6]||(e[6]=d("img",{src:P,class:"w-[300px] my-4"},null,-1)),e[7]||(e[7]=d("div",null,"Enter your password to unlock",-1)),u(x,{class:"w-full",error:t(o).currentPasswordValidation},{default:y(()=>[L((c(),N(k,{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]=S(r=>t(a)?null:m(),["enter"]))},{trailing:y(()=>[u(w,{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(F),"##########"]])]),_:1},8,["error"]),u(w,{"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=>m())},null,8,["loading"])],64))])}}});export{H as default};
