import{p as k,h as e,q as x,a as I,K as M,r as f,L as N,m as q,b as p,e as D,O as v,Q as b,S as w,E as y,T as H,U as O,x as l,R as U,V,k as $,l as B,j as Q}from"./entry.e097670d.js";const j=""+new URL("Login.bb43092d.svg",import.meta.url).href,z=k({props:{width:{type:[Number,String],default:750},height:{type:[Number,String],default:500}},setup(t){return()=>e("img",{src:j,width:t.width,height:t.height,style:{maxWidth:"100%"}})}}),K=()=>x().$ilingo,L=(t,d)=>K().getSync(`validation.${t}`,d,"en"),F=I({setup(){const t=M({name:"",password:"",realm_id:""}),d=f("RealmList"),C=f("IdentityProviderList"),c=N({name:{required:v,minLength:b(3),maxLength:w(255)},password:{required:v,minLength:b(3),maxLength:w(255)},realm_id:{}},t),h=q(),R=p(!1),A=D(()=>t.realm_id?{filters:{realm_id:t.realm_id}}:{}),i=p(null),g=async()=>{try{console.log(t),await h.login({name:t.name,password:t.password,realmId:t.realm_id});const n=$(),{redirect:o,...u}=n.query;B({path:o||"/",query:u})}catch(n){n instanceof Error&&Q().warning(n.message)}},P=x();Promise.resolve().then(h.logout);const _=()=>{const n=y({validationResult:c.value.name,validationTranslator:L,labelContent:"Name",value:t.name,onChange(a){t.name=a}}),o=y({validationResult:c.value.password,validationTranslator:L,labelContent:"Password",value:t.password,onChange(a){t.password=a},props:{type:"password"}}),u=H({validationResult:c.value,createText:"Login",createButtonClass:{value:"btn btn-sm btn-dark btn-block",presets:{[O.BOOTSTRAP_V5]:!1}},createIconClass:"fa-solid fa-right-to-bracket",submit:g,busy:R}),T=[e(d,{withHeader:!0},{[l.HEADER]:()=>e("h6",["Realms"]),[l.ITEM_ACTIONS]:a=>{const s=!(a.data.name===U&&!t.realm_id)&&t.realm_id!==a.data.id;return s?e("button",{class:{"btn btn-xs btn-primary":s,"btn btn-xs btn-danger":!s},onClick(r){r.preventDefault(),t.realm_id=a.data.id,i.value&&typeof i.value.load=="function"&&i.value.load()}},[e("i",{class:{"fa fa-check":s,"fa fa-times":!s}})]):e("span",{class:"badge bg-success"},["active"])}})],E=[e(C,{withHeader:!0,withSearch:!1,query:A,ref:i},{[l.HEADER]:()=>e("h6",["Identity Providers"]),[l.ITEMS]:a=>{const m=[],s=V();for(let r=0;r<a.data.length;r++){const S=[e("div",[e("a",{href:s.identityProvider.getAuthorizeUri(P.$config.public.apiUrl,a.data[r].id),class:"btn btn-primary btn-xs"},[a.data[r].name])])];m.push(S)}return e("div",{class:"d-flex flex-row"},m)}})];return e("div",{class:"container"},[e("h4",[e("i",{class:"fa-solid fa-arrow-right-to-bracket pe-2"}),"Login"]),e("div",{class:"text-center"},[e(z,{height:320})]),e("form",{onSubmit(a){return a.preventDefault(),g.call(null)}},[e("div",{class:"row"},[e("div",{class:"col-8"},[n,o,u,e("hr"),E]),e("div",{class:"col-4"},[T])])])])};return()=>_()}});export{F as default};
