import{d as m,_,o as l,k as u,b,z as p,c as h,a as d,x as j,r as w,ao as L,ap as O,H as C,j as B,l as n,n as o,p as s,y as E,t as v,q as y,F as V}from"./app-DZcRemIr.js";import{c as x,a as q,B as A}from"./index-CA0zsXLm.js";import{I as G}from"./Input-C686KDpn.js";import{c as F,S as P,W as M}from"./SiifIconBC3-DYQKLzWx.js";import{L as D}from"./Label-DFdxTKen.js";/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const z=F("CircleAlertIcon",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
 * @license lucide-vue-next v0.468.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const H=F("LoaderCircleIcon",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]),N=m({__name:"Card",props:{class:{type:[Boolean,null,String,Object,Array],required:!1,skipCheck:!0}},setup(t,{expose:r}){r();const e={props:t,get cn(){return x}};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function T(t,r,a,e,i,c){return l(),u("div",{"data-slot":"card",class:p(e.cn("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",e.props.class))},[b(t.$slots,"default")],2)}const U=_(N,[["render",T],["__file","/var/www/resources/js/components/ui/card/Card.vue"]]),W=m({__name:"CardContent",props:{class:{type:[Boolean,null,String,Object,Array],required:!1,skipCheck:!0}},setup(t,{expose:r}){r();const e={props:t,get cn(){return x}};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function J(t,r,a,e,i,c){return l(),u("div",{"data-slot":"card-content",class:p(e.cn("px-6",e.props.class))},[b(t.$slots,"default")],2)}const K=_(W,[["render",J],["__file","/var/www/resources/js/components/ui/card/CardContent.vue"]]),Q=m({__name:"Field",props:{class:{type:[Boolean,null,String,Object,Array],required:!1,skipCheck:!0},orientation:{type:null,required:!1}},setup(t,{expose:r}){r();const e={props:t,get cn(){return x},get fieldVariants(){return le}};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}}),R=["data-orientation"];function X(t,r,a,e,i,c){return l(),u("div",{role:"group","data-slot":"field","data-orientation":a.orientation,class:p(e.cn(e.fieldVariants({orientation:a.orientation}),e.props.class))},[b(t.$slots,"default")],10,R)}const Y=_(Q,[["render",X],["__file","/var/www/resources/js/components/ui/field/Field.vue"]]),Z=m({__name:"FieldDescription",props:{class:{type:[Boolean,null,String,Object,Array],required:!1,skipCheck:!0}},setup(t,{expose:r}){r();const e={props:t,get cn(){return x}};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function $(t,r,a,e,i,c){return l(),u("p",{"data-slot":"field-description",class:p(e.cn("text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance","last:mt-0 nth-last-2:-mt-1 [[data-variant=legend]+&]:-mt-1.5","[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4",e.props.class))},[b(t.$slots,"default")],2)}const ee=_(Z,[["render",$],["__file","/var/www/resources/js/components/ui/field/FieldDescription.vue"]]),re=m({__name:"FieldGroup",props:{class:{type:[Boolean,null,String,Object,Array],required:!1,skipCheck:!0}},setup(t,{expose:r}){r();const e={props:t,get cn(){return x}};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function te(t,r,a,e,i,c){return l(),u("div",{"data-slot":"field-group",class:p(e.cn("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",e.props.class))},[b(t.$slots,"default")],2)}const ae=_(re,[["render",te],["__file","/var/www/resources/js/components/ui/field/FieldGroup.vue"]]),oe=m({__name:"FieldLabel",props:{class:{type:[Boolean,null,String,Object,Array],required:!1,skipCheck:!0}},setup(t,{expose:r}){r();const e={props:t,get cn(){return x},get Label(){return D}};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}});function se(t,r,a,e,i,c){return l(),h(e.Label,{"data-slot":"field-label",class:p(e.cn("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",e.props.class))},{default:d(()=>[b(t.$slots,"default")]),_:3},8,["class"])}const ne=_(oe,[["render",se],["__file","/var/www/resources/js/components/ui/field/FieldLabel.vue"]]),le=q("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],horizontal:["flex-row items-center","[&>[data-slot=field-label]]:flex-auto","has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"],responsive:["flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto","@md/field-group:[&>[data-slot=field-label]]:flex-auto","@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"]}},defaultVariants:{orientation:"vertical"}}),ie=m({__name:"Login",props:{status:{type:String,required:!1}},setup(t,{expose:r}){r();const a=j({name:"",password:""}),e=w(null),i=w(!1),c=w(!navigator.onLine);window.addEventListener("online",()=>{c.value=!1}),window.addEventListener("offline",()=>{c.value=!0});const g=async()=>{e.value=null,i.value=!0;try{const f=await L(a.name);if(!f.success){e.value=f.error||"Error de autenticacion offline.";return}const I=O(f.user);C().setOfflineSession(I),window.location.href="/tdp"}catch{e.value="Error verificando credenciales localmente."}finally{i.value=!1}},k=()=>{e.value=null,i.value=!0,a.post(route("login"),{onFinish:()=>{a.reset("password"),i.value=!1},onError:f=>{i.value=!1,!f.name&&!f.password&&(e.value="Ha ocurrido un error inesperado. Por favor, inténtalo de nuevo.")},onSuccess:()=>{e.value=null,C().cacheAllOnLogin().catch(()=>{})},preserveScroll:!0})},S={form:a,generalError:e,isSubmitting:i,offlineMode:c,submitOffline:g,submitOnline:k,submit:()=>{c.value?g():k()},clearGeneralError:()=>{e.value=null},get Head(){return B},get LoaderCircle(){return H},get AlertCircle(){return z},get WifiOff(){return M},get Button(){return A},get Input(){return G},get Card(){return U},get CardContent(){return K},get SiifIcon(){return P},get Field(){return Y},get FieldDescription(){return ee},get FieldGroup(){return ae},get FieldLabel(){return ne}};return Object.defineProperty(S,"__isScriptSetup",{enumerable:!1,value:!0}),S}}),de={class:"bg-muted flex min-h-svh flex-col items-center justify-center p-6 md:p-10"},ce={class:"w-full max-w-sm md:max-w-4xl"},ue={class:"flex flex-col gap-6"},fe={key:0,class:"mb-4 p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg"},pe={class:"flex items-center text-sm text-amber-700 dark:text-amber-300"},me={key:1,class:"mb-4 p-3 bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg"},_e={class:"text-sm text-green-700 dark:text-green-300 text-center"},ge={key:2,class:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg"},be={class:"flex items-center"},xe={class:"text-sm text-red-700 dark:text-red-300"},ve={key:0,class:"text-sm text-red-600 dark:text-red-400 mt-1"},ye={class:"flex items-center"},we={key:0,class:"text-sm text-red-600 dark:text-red-400 mt-1"},he={class:"bg-linear-to-br from-blue-600 to-blue-800 relative hidden md:block"},ke={class:"absolute inset-0 flex items-center justify-center p-8"},Se={class:"text-center text-white"},Ce={class:"w-16 h-16 bg-white/60 rounded-full flex items-center justify-center mx-auto mb-4"},Fe=["src"];function Ie(t,r,a,e,i,c){return l(),u(V,null,[n(e.Head,{title:"Log in"}),o("div",de,[o("div",ce,[o("div",ue,[n(e.Card,{class:"overflow-hidden p-0"},{default:d(()=>[n(e.CardContent,{class:"grid p-0 md:grid-cols-2"},{default:d(()=>[s(" Formulario (columna izquierda) "),o("form",{onSubmit:E(e.submit,["prevent"]),class:"p-6 md:p-8"},[n(e.FieldGroup,null,{default:d(()=>[s(" Header del formulario "),r[6]||(r[6]=o("div",{class:"flex flex-col items-center gap-2 text-center mb-6"},[o("h1",{class:"text-2xl font-bold text-gray-900 dark:text-white"}," Bienvenido a SIIF "),o("p",{class:"text-muted-foreground text-balance py-2"}," Introduce tus credenciales para acceder a tu cuenta. ")],-1)),s(" Indicador offline "),e.offlineMode?(l(),u("div",fe,[o("div",pe,[n(e.WifiOff,{class:"h-4 w-4 mr-2 flex-shrink-0"}),r[2]||(r[2]=o("span",null,"Modo offline — se usara la sesion guardada en este dispositivo (no se verifica contraseña).",-1))])])):s("v-if",!0),s(" Mensaje de status "),a.status?(l(),u("div",me,[o("div",_e,v(a.status),1)])):s("v-if",!0),s(" Error general "),e.generalError?(l(),u("div",ge,[o("div",be,[n(e.AlertCircle,{class:"h-4 w-4 text-red-500 mr-2"}),o("div",xe,v(e.generalError),1),o("button",{onClick:e.clearGeneralError,class:"ml-auto text-red-500 hover:text-red-700",type:"button"}," × ")])])):s("v-if",!0),s(" Campo Username "),n(e.Field,null,{default:d(()=>[n(e.FieldLabel,{for:"name",class:"text-gray-700 dark:text-gray-300"},{default:d(()=>[...r[3]||(r[3]=[y(" Usuario ",-1)])]),_:1}),n(e.Input,{id:"name",type:"text",required:"",autofocus:"",autocomplete:"username",modelValue:e.form.name,"onUpdate:modelValue":r[0]||(r[0]=g=>e.form.name=g),placeholder:"Enter your username",onInput:e.clearGeneralError,disabled:e.form.processing||e.isSubmitting,class:p({"border-red-500 dark:border-red-400":e.form.errors.name})},null,8,["modelValue","disabled","class"]),e.form.errors.name?(l(),u("div",ve,v(e.form.errors.name),1)):s("v-if",!0)]),_:1}),s(" Campo Password (no aplica en modo offline: el acceso se valida con el token guardado) "),e.offlineMode?s("v-if",!0):(l(),h(e.Field,{key:3},{default:d(()=>[o("div",ye,[n(e.FieldLabel,{for:"password",class:"text-gray-700 dark:text-gray-300"},{default:d(()=>[...r[4]||(r[4]=[y(" Contraseña ",-1)])]),_:1})]),n(e.Input,{id:"password",type:"password",required:"",autocomplete:"current-password",modelValue:e.form.password,"onUpdate:modelValue":r[1]||(r[1]=g=>e.form.password=g),placeholder:"Enter your password",onInput:e.clearGeneralError,disabled:e.form.processing||e.isSubmitting,class:p({"border-red-500 dark:border-red-400":e.form.errors.password})},null,8,["modelValue","disabled","class"]),e.form.errors.password?(l(),u("div",we,v(e.form.errors.password),1)):s("v-if",!0)]),_:1})),s(" Botón de Login "),n(e.Field,null,{default:d(()=>[n(e.Button,{type:"submit",disabled:e.form.processing||e.isSubmitting},{default:d(()=>[e.form.processing||e.isSubmitting?(l(),h(e.LoaderCircle,{key:0,class:"h-4 w-4 animate-spin mr-2"})):s("v-if",!0),y(" "+v(e.form.processing||e.isSubmitting?"Iniciando sesión...":e.offlineMode?"Iniciar sesión (offline)":"Iniciar sesión"),1)]),_:1},8,["disabled"])]),_:1}),s(" Información adicional "),n(e.FieldDescription,{class:"text-center text-sm text-gray-600 dark:text-gray-400 mt-4"},{default:d(()=>[...r[5]||(r[5]=[y(" ¿No tienes una cuenta? Ponte en contacto con tu administrador. ",-1)])]),_:1})]),_:1})],32),s(" Columna derecha con imagen "),o("div",he,[o("div",ke,[o("div",Se,[o("div",Ce,[o("img",{src:e.SiifIcon,alt:"SIIF Logo"},null,8,Fe)]),r[7]||(r[7]=o("h2",{class:"text-xl font-bold mb-2"},"Sistema SIIF",-1)),r[8]||(r[8]=o("p",{class:"text-blue-100"},"Sales Intelligence & Information Framework",-1))])])])]),_:1})]),_:1}),s(" Footer adicional "),n(e.FieldDescription,{class:"px-6 text-center text-sm text-gray-500 dark:text-gray-400"},{default:d(()=>[...r[9]||(r[9]=[y(" © 2025 Bimodal Technology. Todos los derechos reservados. ",-1)])]),_:1})])])])],64)}const Ge=_(ie,[["render",Ie],["__file","/var/www/resources/js/pages/auth/Login.vue"]]);export{Ge as default};
