(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,18566,(e,a,t)=>{a.exports=e.r(76562)},20572,e=>{"use strict";var a=e.i(43476),t=e.i(71645),s=e.i(18566);function r(){let e=(0,s.useRouter)(),r=(0,s.useSearchParams)(),[l,i]=(0,t.useState)(null),[n,c]=(0,t.useState)({front:null,back:null}),[o,d]=(0,t.useState)({front:"",back:""}),[m,x]=(0,t.useState)(!1),[u,p]=(0,t.useState)("");(0,t.useEffect)(()=>{let e=r.get("id"),a=localStorage.getItem("last_militant_id");e?i(e):a&&i(a)},[r]);let h=(e,a)=>{let t=e.target.files?.[0];t&&(c(e=>({...e,[a]:t})),d(e=>({...e,[a]:URL.createObjectURL(t)})))},b=async a=>{if(a.preventDefault(),!l)return void alert("Error: No se encontró el ID del militante. Por favor, intenta el registro nuevamente.");x(!0);let t=new FormData;t.append("militant_id",l),n.front&&t.append("front",n.front),n.back&&t.append("back",n.back);try{let a=await fetch("/api/militants/upload-ine",{method:"POST",body:t});if(!a.ok){let e=await a.json();throw Error(e.error||"Error al subir las imágenes")}p("✅ Registro completado exitosamente."),localStorage.removeItem("last_militant_id"),setTimeout(()=>e.push("/admin/dashboard"),1500)}catch(e){p(`❌ ${e.message}`)}finally{x(!1)}},g="flex flex-col items-center justify-center w-full h-56 border-2 border-dashed border-gray-800 rounded-3xl bg-[#0a0a0a] hover:bg-[#121212] cursor-pointer transition-all overflow-hidden group";return(0,a.jsxs)("div",{className:"p-8 max-w-4xl mx-auto bg-black min-h-screen text-white text-center",children:[(0,a.jsxs)("header",{className:"mb-10",children:[(0,a.jsx)("h1",{className:"text-3xl font-black uppercase tracking-tighter",children:"Paso Final: Identificación"}),(0,a.jsx)("p",{className:"text-gray-500 mt-2 italic",children:l?`Cargando documentos para el militante #${l}`:"Carga de INE (Opcional)"})]}),(0,a.jsxs)("form",{onSubmit:b,className:"space-y-8",children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("span",{className:"text-[10px] font-black text-blue-500 uppercase tracking-widest",children:"Vista Frontal"}),(0,a.jsxs)("label",{className:g,children:[o.front?(0,a.jsx)("img",{src:o.front,className:"w-full h-full object-cover",alt:"Preview Front"}):(0,a.jsxs)("div",{className:"text-center p-4",children:[(0,a.jsx)("div",{className:"text-3xl mb-2 group-hover:scale-110 transition-transform",children:"🪪"}),(0,a.jsx)("p",{className:"text-xs text-gray-500",children:"Haz clic para subir el frente"})]}),(0,a.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:e=>h(e,"front")})]})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("span",{className:"text-[10px] font-black text-blue-500 uppercase tracking-widest",children:"Vista Posterior"}),(0,a.jsxs)("label",{className:g,children:[o.back?(0,a.jsx)("img",{src:o.back,className:"w-full h-full object-cover",alt:"Preview Back"}):(0,a.jsxs)("div",{className:"text-center p-4",children:[(0,a.jsx)("div",{className:"text-3xl mb-2 group-hover:scale-110 transition-transform",children:"🔄"}),(0,a.jsx)("p",{className:"text-xs text-gray-500",children:"Haz clic para subir el reverso"})]}),(0,a.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:e=>h(e,"back")})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 pt-10",children:[(0,a.jsx)("button",{type:"button",onClick:()=>{localStorage.removeItem("last_militant_id"),e.push("/admin/dashboard")},className:"w-full p-5 rounded-2xl border border-gray-900 text-gray-500 font-bold hover:bg-gray-900 transition-all uppercase text-xs",children:"Omitir y terminar"}),(0,a.jsx)("button",{type:"submit",disabled:m||!l,className:"w-full p-5 rounded-2xl bg-white text-black font-black hover:bg-gray-200 transition-all shadow-xl uppercase text-xs disabled:bg-gray-700",children:m?"Subiendo...":"Finalizar Registro"})]})]}),u&&(0,a.jsx)("div",{className:"mt-10 p-4 rounded-2xl bg-[#111] border border-gray-800 text-sm font-medium animate-pulse",children:u})]})}e.s(["default",0,function(){return(0,a.jsx)(t.Suspense,{fallback:(0,a.jsx)("div",{className:"p-8 text-white",children:"Cargando sistema de archivos..."}),children:(0,a.jsx)(r,{})})}])}]);