import{t as d,a as c}from"../chunks/CUaqldoV.js";import{p as Z,a as $,s,c as h,g as o,K as u,r as _,n as k,M as t}from"../chunks/BSRAYoh9.js";import{e as A}from"../chunks/Dvr0EhCJ.js";import{i as v}from"../chunks/Db5XNeQO.js";import{r as w}from"../chunks/DFaclXwQ.js";import{b as y}from"../chunks/BEmMrY3m.js";import{i as C,g as D}from"../chunks/BsXgvxaw.js";var H=d('<p class="alert alert--danger svelte-1pov77a">Zły login lub hasło</p>'),J=d('<form class="form-group"><input type="text" name="username" placeholder="Login" class="form-control"> <input type="password" name="password" placeholder="Hasło" class="form-control"> <div class="place-end"><button type="submit" class="btn">Zaloguj</button></div></form>'),K=d('<section class="login-container svelte-1pov77a"><h1>Logowanie</h1> <!> <!> <!></section>');function F(j,x){Z(x,!0);let r=u(""),n=u(""),i=u(null);async function L(a){a.preventDefault(),t(i,null),(await(await fetch("/mgr/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:o(r),password:o(n)})})).json()).success?(await C(),D("/mgr")):t(i,!0)}var l=K(),f=s(h(l),2);{var O=a=>{var e=H();c(a,e)};v(f,a=>{o(i)&&a(O)})}var g=s(f,2);{var S=a=>{var e=J(),p=h(e);w(p);var b=s(p,2);w(b),k(2),_(e),A("submit",e,L),y(p,()=>o(r),m=>t(r,m)),y(b,()=>o(n),m=>t(n,m)),c(a,e)};v(g,a=>{a(S)})}var T=s(g,2);v(T,a=>{}),_(l),c(j,l),$()}export{F as component};
