import{s as $,n as z,d as g,r as ee,q as S,h as Q,i as W,b as s,m as K,u as te,a as l,c as d,f as C,g as H,j as E,k as Y,e as c,l as X,t as Z}from"../chunks/DVvjRtkd.js";import{S as se,i as le}from"../chunks/Ca9JqCu1.js";import{g as ae}from"../chunks/BkgRu8QA.js";import{a as ne}from"../chunks/BSu-bEiK.js";function J(u){let n,e;return{c(){n=c("div"),e=Z(u[3]),this.h()},l(t){n=d(t,"DIV",{class:!0});var i=C(n);e=Y(i,u[3]),i.forEach(g),this.h()},h(){l(n,"class","bg-red-50 border-2 border-red-200 rounded-lg p-4 text-red-700 text-sm")},m(t,i){W(t,n,i),s(n,e)},p(t,i){i&8&&Q(e,t[3])},d(t){t&&g(n)}}}function re(u){let n,e,t,i='<div class="text-6xl mb-4">🔑</div> <h1 class="text-3xl font-bold text-slate-900 mb-2">Login</h1> <p class="text-slate-600">Enter your license key and email to access your dashboard</p>',L,a,_,p,w="License Key",h,f,B,k,y,O="Email",N,m,U,V,b,T=u[2]?"Logging in...":"Login",q,j,I,F='<p>Don&#39;t have a license? <a href="/pricing" class="text-primary-600 hover:underline font-semibold">Get one now</a></p>',A,G,r=u[3]&&J(u);return{c(){n=c("div"),e=c("div"),t=c("div"),t.innerHTML=i,L=X(),a=c("form"),_=c("div"),p=c("label"),p.textContent=w,h=X(),f=c("input"),B=X(),k=c("div"),y=c("label"),y.textContent=O,N=X(),m=c("input"),U=X(),r&&r.c(),V=X(),b=c("button"),q=Z(T),j=X(),I=c("div"),I.innerHTML=F,this.h()},l(o){n=d(o,"DIV",{class:!0});var v=C(n);e=d(v,"DIV",{class:!0});var D=C(e);t=d(D,"DIV",{class:!0,"data-svelte-h":!0}),H(t)!=="svelte-v9kgye"&&(t.innerHTML=i),L=E(D),a=d(D,"FORM",{class:!0});var x=C(a);_=d(x,"DIV",{});var M=C(_);p=d(M,"LABEL",{for:!0,class:!0,"data-svelte-h":!0}),H(p)!=="svelte-1qxo15l"&&(p.textContent=w),h=E(M),f=d(M,"INPUT",{id:!0,type:!0,placeholder:!0,class:!0}),M.forEach(g),B=E(x),k=d(x,"DIV",{});var P=C(k);y=d(P,"LABEL",{for:!0,class:!0,"data-svelte-h":!0}),H(y)!=="svelte-xo9lo8"&&(y.textContent=O),N=E(P),m=d(P,"INPUT",{id:!0,type:!0,placeholder:!0,class:!0}),P.forEach(g),U=E(x),r&&r.l(x),V=E(x),b=d(x,"BUTTON",{type:!0,class:!0});var R=C(b);q=Y(R,T),R.forEach(g),x.forEach(g),j=E(D),I=d(D,"DIV",{class:!0,"data-svelte-h":!0}),H(I)!=="svelte-1yuabn"&&(I.innerHTML=F),D.forEach(g),v.forEach(g),this.h()},h(){l(t,"class","text-center mb-8"),l(p,"for","license_key"),l(p,"class","block text-sm font-semibold text-slate-700 mb-2"),l(f,"id","license_key"),l(f,"type","text"),l(f,"placeholder","LIC-XXXXXXXXXXXX"),l(f,"class","input w-full"),f.required=!0,l(y,"for","email"),l(y,"class","block text-sm font-semibold text-slate-700 mb-2"),l(m,"id","email"),l(m,"type","email"),l(m,"placeholder","you@example.com"),l(m,"class","input w-full"),m.required=!0,l(b,"type","submit"),l(b,"class","btn-primary w-full py-3 text-lg font-bold"),b.disabled=u[2],l(a,"class","space-y-6"),l(I,"class","mt-6 text-center text-sm text-slate-600"),l(e,"class","card max-w-md w-full"),l(n,"class","min-h-screen bg-gradient-to-br from-slate-50 to-slate-100 flex items-center justify-center p-6")},m(o,v){W(o,n,v),s(n,e),s(e,t),s(e,L),s(e,a),s(a,_),s(_,p),s(_,h),s(_,f),S(f,u[0]),s(a,B),s(a,k),s(k,y),s(k,N),s(k,m),S(m,u[1]),s(a,U),r&&r.m(a,null),s(a,V),s(a,b),s(b,q),s(e,j),s(e,I),A||(G=[K(f,"input",u[5]),K(m,"input",u[6]),K(a,"submit",te(u[4]))],A=!0)},p(o,[v]){v&1&&f.value!==o[0]&&S(f,o[0]),v&2&&m.value!==o[1]&&S(m,o[1]),o[3]?r?r.p(o,v):(r=J(o),r.c(),r.m(a,V)):r&&(r.d(1),r=null),v&4&&T!==(T=o[2]?"Logging in...":"Login")&&Q(q,T),v&4&&(b.disabled=o[2])},i:z,o:z,d(o){o&&g(n),r&&r.d(),A=!1,ee(G)}}}function ie(u,n,e){let t="",i="",L=!1,a="";async function _(){if(!t||!i){e(3,a="Please enter both license key and email");return}e(2,L=!0),e(3,a="");try{const h=await ne.login(t,i);sessionStorage.setItem("auth_token",h.token),sessionStorage.setItem("user_email",h.email),sessionStorage.setItem("user_tier",h.tier),ae("/dashboard")}catch(h){e(3,a=h instanceof Error?h.message:"Login failed. Please check your credentials.")}finally{e(2,L=!1)}}function p(){t=this.value,e(0,t)}function w(){i=this.value,e(1,i)}return[t,i,L,a,_,p,w]}class fe extends se{constructor(n){super(),le(this,n,ie,re,$,{})}}export{fe as component};
