import{F as i}from"./form.js";import{m as s,R as r,S as a,t as l,T as u,Q as m}from"./common.js";import{i as d}from"./i18n.js";let o=null;window.onload=async()=>{s("permission")||await r(),d(),c(),a(),f()};function c(){s("token")&&window.open("/index.html","_self")}function f(){const n=[{label:i18n.t("userInfo.login.account"),name:"account",key:"Account",value:"admin",element:"input",rules:[{required:!0}],rules:[{required:!0}]},{label:i18n.t("userInfo.login.password"),name:"password",key:"Password",value:"123456",element:"password",rules:[{required:!0}],formatter:/[a-zA-Z0-9`.!"#$%&')(*+,-./:;<=>?@[\\\]^_`{|}~]/g,rules:[{required:!0},{min:6,message:i18n.t("userInfo.password.passwordMinLength")}],formatter:/[a-zA-Z0-9`.!"#$%&')(*+,-./:;<=>?@[\\\]^_`{|}~]/g}];o=new i(n,{id:"login-form",label:i18n.t("userInfo.login.title")},!1);const e=o.handleCreateForm(),t=l({name:i18n.t("userInfo.login.loginBtn"),dataset:{type:"primary"},classList:["button","login-btn"]});t.addEventListener("click",g),e.querySelector(".form__btn").appendChild(t),document.querySelector(".login-box").appendChild(e)}async function g(){const n=o.submit();if(n){const e=await u(n);e!=null&&e.success?(m("token","token"),window.open("/index.html","_self")):alert(i18n.t("userInfo.login.passwordError"))}}
