PageSourceSearch

https://effervescent-cupcake-210607.netlify.app/assets/CoordinatorPanel-BMsRMtOY.js

js effervescent-cupcake-210607.netlify.app collected 2026-10-03 10:41:22 UTC 163,136 bytes, 125 lines download raw bytes

1import{r as i,j as e,s as A,P as se}from"./index-bMFZPluE.js";import{a as ct,L as Qe}from"./laborCostReference-CzuQcRj4.js";import{g as pt}from"./pricingEngine-DmHUGCKM.js";import{b as ut}from"./siblingDetection-CHQmQ9BJ.js";import{n as pe,d as xt,e as mt,a as bt,g as gt,b as ht}from"./addressFormatting-eDBQ4TmV.js";import{c as Fe,d as ma,e as ba,f as Pa,h as Da,s as ft,i as yt,A as Ta,a as jt,l as vt,j as wt,r as Nt,k as kt,v as _t,C as ga}from"./laborAssignmentControls-PBEP3hIy.js";import{a as Ct,b as At,c as St}from"./leadProvisionalFamily-DVBYHIU0.js";import{t as Et}from"./phoneFormatting-bIoASOCT.js";import{T as Pt,b as ha}from"./TeacherAvailabilityEditor-CzOirxAn.js";import{H as Dt,g as Tt,b as Lt,f as fa,h as Rt}from"./homeTutoringProposal-BrGXMNR5.js";import{e as qt,r as Ft,f as $t,n as Bt}from"./educationCatalog-pqwMnMBs.js";import{p as ya,a as It,c as zt}from"./candidateAvailability-DgcALE0v.js";import"./familyAgreement-Bm5j7ljB.js";import"./familyReceiptPolicy-egdKJ3_6.js";const fe="w-full rounded-xl border border-[#16A0EB33] bg-white px-3 py-2.5 text-xs font-bold text-gray-800 outline-none transition focus:border-[#16A0EB] focus:ring-2 focus:ring-[#16A0EB24]",Ot=[{id:"primary",label:"Primaria",activeClass:"bg-[#066591] text-white shadow-sm"},{id:"eso",label:"ESO",activeClass:"bg-[#16A0EB] text-white shadow-sm"},{id:"bach",label:"Bach / PAU",activeClass:"bg-[#FC9A05] text-white shadow-sm"}],Mt=async d=>{var v;if((v=navigator.clipboard)!=null&&v.writeText){await navigator.clipboard.writeText(d);return}const n=document.createElement("textarea");n.value=d,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)},Gt=({coordinatorName:d,onOpenLeads:n})=>{const[v,b]=i.useState(Dt),[G,H]=i.useState("primary"),[l,u]=i.useState(""),[N,D]=i.useState(""),[q,Y]=i.useState(""),[p,F]=i.useState(""),[S,x]=i.useState(""),[E,M]=i.useState(""),[B,k]=i.useState(["continuity","essential","concentrated"]),[V,K]=i.useState(""),[_,U]=i.useState(!1);i.useEffect(()=>{(async()=>{const{data:C}=await A.from("global_settings").select("setting_value").eq("id","pricing_rules").maybeSingle(),I=C==null?void 0:C.setting_value,J=I&&typeof I=="object"&&!Array.isArray(I)?I:{};b(Rt(J))})()},[]);const T=`${String(d||"").trim().split(/\s+/)[0]||"Gabriela"} · Coordinacion Profe en Casa`,Z=Tt(v,G),s=B.map(y=>Z.find(C=>C.id===y)).filter(y=>!!y),h=Lt({familyName:l,studentName:N,course:q,subject:p,locality:S,availability:E,signature:T,quotes:s}),R=y=>{if(U(!1),K(""),B.includes(y)){if(B.length===1){K("Debe quedar al menos una opcion.");return}k(B.filter(C=>C!==y));return}if(B.length>=3){K("Elige un maximo de 3 opciones para que el mensaje sea facil de leer.");return}k([...B,y])},L=async()=>{await Mt(h),U(!0)};return e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"overflow-hidden rounded-[24px] border border-[#16A0EB33] bg-white shadow-sm",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#066591] via-[#16A0EB] to-[#FC9A05] p-5 text-white",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-white/85",children:"Curso 2026/27"}),e.jsx("h3",{className:"mt-1 text-xl font-black",children:"Propuesta domicilio"}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-white/90",children:"Prepara y copia el mensaje familiar. Esta herramienta no envia WhatsApp ni permite cambiar tarifas."})]}),e.jsxs("div",{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Familia"}),e.jsx("input",{className:fe,value:l,onChange:y=>u(y.target.value),placeholder:"Ej. Maria"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Alumno/a"}),e.jsx("input",{className:fe,value:N,onChange:y=>D(y.target.value),placeholder:"Opcional"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Curso"}),e.jsx("input",{className:fe,value:q,onChange:y=>Y(y.target.value),placeholder:"Ej. 1 ESO"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Asignatura"}),e.jsx("input",{className:fe,value:p,onChange:y=>F(y.target.value),placeholder:"Ej. Matematicas"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Localidad"}),e.jsx("input",{className:fe,value:S,onChange:y=>x(y.target.value),placeholder:"Ej. La Zubia"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Tardes que no puede"}),e.jsx("input",{className:fe,value:E,onChange:y=>M(y.target.value),placeholder:"Ej. no puede lunes"})]})]}),e.jsx("div",{className:"flex rounded-xl border border-[#16A0EB33] bg-[#16A0EB0D] p-1",children:Ot.map(y=>e.jsx("button",{type:"button",onClick:()=>{H(y.id),U(!1)},className:`flex-1 rounded-lg px-2 py-2 text-[9px] font-black uppercase tracking-wider ${G===y.id?y.activeClass:"text-[#066591]"}`,children:y.label},y.id))}),e.jsx("div",{className:"space-y-2",children:Z.map(y=>{const C=B.includes(y.id);return e.jsx("button",{type:"button",onClick:()=>R(y.id),className:`w-full rounded-2xl border p-3 text-left transition ${C?"border-[#16A0EB] bg-[#16A0EB12]":"border-gray-200 bg-white hover:border-[#FC9A05]"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"text-xs font-black text-[#066591]",children:y.name}),y.recommended&&e.jsx("span",{className:"rounded-full bg-[#FC9A05] px-2 py-0.5 text-[7px] font-black uppercase text-white",children:"Recomendada"})]}),e.jsx("p",{className:"mt-1 text-[9px] font-bold text-gray-500",children:y.summary}),e.jsxs("p",{className:"mt-2 text-[10px] font-black text-gray-900",children:[fa(y.sessionPrice)," / sesion · ",fa(y.fourWeekEstimate)," / 4 semanas"]})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border text-[9px] font-black ${C?"border-[#16A0EB] bg-[#16A0EB] text-white":"border-gray-300 text-transparent"}`,children:"OK"})]})},y.id)})}),V&&e.jsx("p",{className:"text-[9px] font-bold text-[#D86C00]",children:V}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[8px] font-black uppercase tracking-wider text-gray-500",children:"Mensaje para revisar"}),e.jsx("textarea",{readOnly:!0,value:h,className:"min-h-[420px] w-full resize-y rounded-2xl border border-[#16A0EB33] bg-[#16A0EB0D] p-3 text-[10px] font-medium leading-relaxed text-gray-700 outline-none"})]}),e.jsx("button",{type:"button",onClick:L,className:"w-full rounded-xl bg-[#16A0EB] px-4 py-3 text-[10px] font-black uppercase tracking-wider text-white shadow-lg shadow-[#16A0EB33] transition hover:bg-[#066591] active:scale-95",children:_?"Mensaje copiado":"Copiar mensaje para WhatsApp"}),_&&e.jsx("p",{className:"rounded-xl border border-[#59D5254D] bg-[#59D5251A] px-3 py-2 text-center text-[9px] font-bold text-[#35B01A]",children:"Copiado. Abre la conversacion de la familia en WhatsApp, pega el texto y revisalo antes de enviarlo."}),e.jsxs("div",{className:"rounded-2xl border border-[#FC9A054D] bg-[#FC9A0514] p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.16em] text-[#D86C00]",children:"Si la fam
1ilia dice que si"}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-gray-700",children:"1. Comprueba profesor, horario y fecha posible. 2. Abre Atencion y deja el lead en Pendiente ficha familia. 3. Activa su ficha provisional y envia el enlace seguro individual para completar datos y aceptar el acuerdo. 4. Cuando el profesor acepte, Direccion valida su alta o ampliacion de horas antes de la primera clase."}),e.jsx("p",{className:"mt-2 text-[9px] font-bold leading-relaxed text-gray-500",children:"La activacion provisional no crea cobros ni confirma clases. La plaza solo puede empezar con el acuerdo familiar y la situacion laboral comprobados."}),n&&e.jsx("button",{type:"button",onClick:n,className:"mt-3 w-full rounded-xl border border-[#FC9A05] bg-white px-3 py-2.5 text-[9px] font-black uppercase tracking-wider text-[#D86C00] transition hover:bg-[#FC9A050F]",children:"Ir a Atencion / leads"})]}),e.jsxs("div",{className:"rounded-2xl border-2 border-[#FC9A05] bg-[#066591] p-4 text-white shadow-sm",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.16em] text-[#FC9A05]",children:"Control laboral obligatorio 2026/27"}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-white",children:"No agendar ni confirmar la primera clase a domicilio hasta que Direccion marque como comprobada el alta del nuevo profesor o la ampliacion de horas del profesor actual."}),e.jsx("p",{className:"mt-2 text-[9px] font-bold leading-relaxed text-white/80",children:"Las tarifas antiguas de domicilio se conservan solo como historico y no deben usarse para una plaza nueva."})]})]})]})})},Ut=["Por confirmar",...qt,...Ft],Ht=["Por confirmar",...$t],ja=(d="Profe 1",n=3,v="17:30",b="19:00")=>({academic_year:Ta,level:"",subject:"",classroom:d,weekday:n,start_time:v,end_time:b,teacher_email:"",notes:"",student_ids:[],pending_student_names:[]}),Ye=d=>d.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim(),va=d=>d.course||d.level||"Curso por revisar",Wt=(d,n)=>{var v;return((v=d.find(b=>b.email===String(n||"").toLowerCase()))==null?void 0:v.name)||n||"Profesor pendiente"},Se=d=>d.replace(/^Profe\s+/,"Aula "),Qt=d=>{const n=new Set;return d.split(/[\n,;]+/).map(v=>v.trim()).filter(v=>{const b=Ye(v);return!b||n.has(b)?!1:(n.add(b),!0)})},Yt=async d=>{var b;if((b=navigator.clipboard)!=null&&b.writeText)try{return await navigator.clipboard.writeText(d),!0}catch{}const n=document.createElement("textarea");n.value=d,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.focus(),n.select();const v=document.execCommand("copy");return document.body.removeChild(n),v},Vt=({onOpenLaborControls:d})=>{const[n,v]=i.useState([]),[b,G]=i.useState([]),[H,l]=i.useState([]),[u,N]=i.useState(null),[D,q]=i.useState("Profe 1"),[Y,p]=i.useState(1),[F,S]=i.useState(""),[x,E]=i.useState(""),[M,B]=i.useState(!1),k=i.useDeferredValue(F),[V,K]=i.useState(!0),[_,U]=i.useState(!1),[W,T]=i.useState(""),[Z,s]=i.useState(""),h=async()=>{T("");try{const t=await Da();i.startTransition(()=>{v(t.plans),G(t.students),l(t.teachers)})}catch(t){T(t instanceof Error?t.message:"No se pudo cargar el plan de grupos.")}finally{K(!1)}};i.useEffect(()=>{h()},[]);const R=u?u.student_ids.map(t=>b.find(m=>m.student_id===t)).filter(t=>!!t):[],L=Qt(x),y=((u==null?void 0:u.student_ids.length)||0)+L.length,C=Ye(k),I=b.filter(t=>C?Ye([t.name,t.level,t.course].filter(Boolean).join(" ")).includes(C):!0).slice(0,C?30:18),J=()=>{T(""),s(""),S(""),E(""),N(ja(D,Y))},ee=(t,m,c,P)=>{T(""),s(""),S(""),E(""),q(t),p(m),N(ja(t,m,c,P))},ue=t=>{T(""),s(""),S(""),E(t.pending_student_names.join(`
2`)),q(t.classroom),p(t.weekday),N({id:t.id,academic_year:t.academic_year,level:t.level,subject:t.subject,classroom:t.classroom,weekday:t.weekday,start_time:t.start_time,end_time:t.end_time,teacher_email:t.teacher_email||"",notes:t.notes||"",student_ids:t.students.map(m=>m.student_id),pending_student_names:t.pending_student_names})},re=t=>{if(!u)return;const m=u.student_ids.includes(t.student_id);if(!m&&u.student_ids.length+L.length>=3){T("Profe a 3 admite un maximo de tres alumnos por grupo.");return}const c=m?u.student_ids.filter(z=>z!==t.student_id):[...u.student_ids,t.student_id],P=Bt(t.course||t.level);T(""),N({...u,student_ids:c,level:u.level||P})},ye=(t,m)=>{u&&N({...u,start_time:t,end_time:m})},ne=async t=>{if(t.preventDefault(),!!u){if(y===0){T("Selecciona un alumno o anota al menos un nombre pendiente de fic
2ha.");return}if(y>3){T("Profe a 3 admite un maximo de tres alumnos, incluidos los pendientes de ficha.");return}if(!u.level||!u.subject){T("Selecciona el nivel y la asignatura del grupo.");return}U(!0),T(""),s("");try{await ft({...u,pending_student_names:L}),N(null),S(""),E(""),s(u.teacher_email?"Grupo guardado con profesor propuesto.":"Grupo guardado como Profesor pendiente."),await h()}catch(m){T(m instanceof Error?m.message:"No se pudo guardar el grupo.")}finally{U(!1)}}},me=async()=>{if(!await Yt(se.familyInquiry)){window.prompt("Copia este enlace para la familia:",se.familyInquiry);return}B(!0),window.setTimeout(()=>B(!1),1800)},je=async t=>{if(window.confirm("El grupo dejara de aparecer en la planificacion. No se borran alumnos ni clases. Quieres archivarlo?")){U(!0),T(""),s("");try{await yt(t.id),s("Grupo archivado. Los alumnos y la agenda no se han modificado."),await h()}catch(c){T(c instanceof Error?c.message:"No se pudo archivar el grupo.")}finally{U(!1)}}},r=n.filter(t=>!t.teacher_email).length,g=n.reduce((t,m)=>t+m.pending_student_names.length,0),$=t=>t.students.length+t.pending_student_names.length,oe=n.reduce((t,m)=>t+Math.max(0,3-$(m)),0),ve=n.filter(t=>t.classroom===D),be=new Map(n.map(t=>[`${t.classroom}-${t.weekday}-${t.start_time}`,t])),we=t=>n.filter(m=>m.classroom===t).length,Ne=Fe.find(t=>t.value===Y)||Fe[0],de=t=>n.filter(m=>m.classroom===D&&m.weekday===t).length;return V?e.jsx("div",{className:"rounded-[28px] border border-sky-100 bg-white p-8 text-center shadow-sm",children:e.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-[#066591]",children:"Cargando plan de grupos..."})}):e.jsxs("section",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"overflow-hidden rounded-[30px] border border-sky-100 bg-white shadow-sm",children:[e.jsx("div",{className:"bg-gradient-to-br from-[#066591] to-[#16A0EB] p-5 text-white",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.22em] text-sky-100",children:"Curso 2026/27"}),e.jsx("h3",{className:"mt-1 text-2xl font-black",children:"Plan de grupos"}),e.jsx("p",{className:"mt-2 max-w-xs text-xs font-bold leading-relaxed text-sky-50",children:"Organiza las cuatro aulas y deja el profesor pendiente. El grupo no entra en cobros ni asistencia hasta confirmarlo en Agenda Centro."})]}),e.jsx("button",{type:"button",onClick:J,className:"shrink-0 rounded-2xl bg-[#FC9A05] px-4 py-3 text-[10px] font-black uppercase tracking-wider text-white shadow-lg active:scale-95",children:"+ Nuevo"})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 p-4 sm:grid-cols-4",children:[e.jsxs("div",{className:"rounded-2xl bg-sky-50 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-black text-[#066591]",children:n.length}),e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-sky-700",children:"Grupos"})]}),e.jsxs("div",{className:"rounded-2xl bg-orange-50 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-black text-[#D86C00]",children:r}),e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-orange-700",children:"Sin profe"})]}),e.jsxs("div",{className:"rounded-2xl bg-amber-50 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-black text-amber-700",children:g}),e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-amber-700",children:"Faltan fichas"})]}),e.jsxs("div",{className:"rounded-2xl bg-emerald-50 p-3 text-center",children:[e.jsx("p",{className:"text-2xl font-black text-emerald-700",children:oe}),e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-emerald-700",children:"Huecos"})]})]})]}),W&&e.jsx("div",{className:"rounded-2xl border border-red-200 bg-red-50 p-4 text-xs font-bold leading-relaxed text-red-700",children:W}),Z&&e.jsx("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 p-4 text-xs font-bold leading-relaxed text-emerald-800",children:Z}),!u&&e.jsxs("div",{className:"rounded-[30px] border border-sky-100 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-[#D86C00]",children:"Vista de trabajo diaria"}),e.jsx("h4",{className:"mt-1 text-xl font-black text-slate-900",children:"Cuadrante de aulas"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-slate-500",children:"1. Elige aula. 2. Elige dia. 3. Toca una hora y anade hasta tres alumnos."})]}),e.jsx("span",{className:"rounded-2xl bg-sky-50 px-3 py-2 text-[9px] font-black uppercase text-[#066591]",children:"4 aulas"})]}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-2 sm:grid-cols-4",children:ma.map(t=>{const m=t===D;return e.jsxs("button",{type:"button",onClick:()=>q(t),className:`rounded-2xl border px-3 py-3 text-left transition-colors ${m?"border-[#16A0EB] bg-[#066591] text-white shadow-md":"border-sky-100 bg-sky-50 text-[#066591]"}`,children:[e.jsx("span",{className:"block text-xs font-black",children:Se(t)}),e.jsxs("span",{className:`mt-1 block text-[8px] font-black uppercase ${m?"text-sky-100":"text-sky-600"}`,children:[we(t)," grupo",we(t)===1?"":"s"]})]},t)})}),e.jsxs("div",{className:"mt-5",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500",children:"2. Elige el dia"}
2),e.jsx("div",{className:"mt-2 grid grid-cols-5 gap-1.5",children:Fe.map(t=>{const m=t.value===Y;return e.jsxs("button",{type:"button",onClick:()=>p(t.value),"aria-pressed":m,className:`rounded-xl border px-1 py-2 text-center transition-colors ${m?"border-[#16A0EB] bg-[#066591] text-white shadow-sm":"border-sky-100 bg-sky-50 text-[#066591]"}`,children:[e.jsx("span",{className:"block text-[9px] font-black uppercase",children:t.label.slice(0,3)}),e.jsxs("span",{className:`mt-1 block text-[7px] font-black uppercase ${m?"text-sky-100":"text-sky-600"}`,children:[de(t.value)," grupo",de(t.value)===1?"":"s"]})]},t.value)})}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500",children:"3. Elige la hora"}),e.jsxs("span",{className:"rounded-full bg-sky-50 px-3 py-1 text-[8px] font-black uppercase text-[#066591]",children:[Ne.label," · ",Se(D)]})]}),e.jsx("div",{className:"mt-2 space-y-2",children:ba.map(t=>{const m=be.get(`${D}-${Y}-${t.start}`),c=m?$(m):0,P=c===3;return e.jsxs("div",{className:"grid grid-cols-[72px_minmax(0,1fr)] gap-2",children:[e.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center rounded-2xl bg-slate-50 p-2 text-center text-[9px] font-black text-slate-600",children:[e.jsx("span",{children:t.start}),e.jsx("span",{className:"my-1 text-slate-300",children:"a"}),e.jsx("span",{children:t.end})]}),e.jsx("button",{type:"button",onClick:()=>m?ue(m):ee(D,Y,t.start,t.end),className:`min-h-24 rounded-2xl border p-3 text-left transition-colors ${m?"border-orange-200 bg-orange-50 hover:border-[#FC9A05]":"border-dashed border-sky-200 bg-white text-sky-600 hover:bg-sky-50"}`,children:m?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-[11px] font-black leading-tight text-slate-900",children:m.subject}),e.jsx("span",{className:"mt-1 block text-[9px] font-bold text-slate-500",children:m.level}),e.jsx("span",{className:`mt-2 block text-[8px] font-black uppercase ${P?"text-[#066591]":"text-[#D86C00]"}`,children:P?`Completo · ${m.teacher_email?"profe propuesto":"sin profe"}`:`No iniciar · ${c}/3 · faltan ${3-c}`})]}):e.jsx("span",{className:"flex h-full items-center justify-center text-center text-[9px] font-black uppercase",children:"+ Preparar grupo"})})]},t.start)})})]}),e.jsx("p",{className:"mt-2 text-[9px] font-bold leading-relaxed text-slate-500",children:"Los huecos vacios no son clases. Un grupo guardado aqui solo confirma su planificacion y puede seguir sin profesor."})]}),u&&e.jsxs("form",{onSubmit:ne,className:"space-y-5 rounded-[30px] border border-sky-100 bg-white p-5 shadow-lg",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-[#D86C00]",children:u.id?"Editar grupo":"Preparar grupo"}),e.jsx("h4",{className:"mt-1 text-xl font-black text-slate-900",children:u.teacher_email?"Con profesor propuesto":"Profesor pendiente"})]}),e.jsx("button",{type:"button",onClick:()=>N(null),className:"rounded-xl border border-slate-200 px-3 py-2 text-[9px] font-black uppercase text-slate-500",children:"Cerrar"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:["1. Alumnos del grupo (",y,"/3)"]}),R.length>0&&e.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:R.map(t=>e.jsxs("button",{type:"button",onClick:()=>re(t),className:"rounded-xl bg-[#066591] px-3 py-2 text-left text-[10px] font-black text-white",title:"Quitar alumno",children:[t.name," x"]},t.student_id))}),e.jsx("input",{type:"search",value:F,onChange:t=>S(t.target.value),placeholder:"Buscar alumno por nombre o curso",className:"w-full rounded-2xl border border-slate-200 bg-slate-50 p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"}),e.jsx("div",{className:"mt-2 max-h-56 space-y-2 overflow-y-auto pr-1",children:I.map(t=>{const m=u.student_ids.includes(t.student_id);return e.jsxs("button",{type:"button",onClick:()=>re(t),className:`flex w-full items-center justify-between gap-3 rounded-2xl border p-3 text-left transition-colors ${m?"border-[#16A0EB] bg-sky-50":"border-slate-100 bg-white hover:border-sky-200"}`,children:[e.jsxs("span",{children:[e.jsx("span",{className:"block text-xs font-black text-slate-900",children:t.name}),e.jsx("span",{className:"mt-1 block text-[9px] font-bold uppercase text-slate-500",children:va(t)})]}),e.jsx("span",{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-black ${m?"bg-[#16A0EB] text-white":"bg-slate-100 text-slate-400"}`,children:m?"OK":"+"})]},t.student_id)})}),e.jsxs("div",{className:"mt-4 rounded-2xl border border-amber-200 bg-amber-50 p-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-amber-800",children:"No aparece en la lista: pen
2diente de ficha"}),e.jsx("textarea",{value:x,onChange:t=>E(t.target.value),rows:Math.max(2,Math.min(3,L.length||2)),placeholder:`Un nombre por linea. Ej.:
3Lorenzo`,className:"mt-2 w-full resize-none rounded-2xl border border-amber-200 bg-white p-3 text-sm font-bold outline-none focus:border-[#FC9A05]"})]}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-amber-900",children:"El nombre reserva plaza, pero no crea una ficha falsa. Cuando la familia se registre, edita el grupo y sustituye el nombre por el alumno real."}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>void me(),className:"rounded-xl bg-[#FC9A05] py-3 text-[9px] font-black uppercase tracking-wider text-white",children:M?"Enlace copiado":"Copiar formulario"}),e.jsx("button",{type:"button",onClick:()=>window.open(se.familyInquiry,"_blank","noopener,noreferrer"),className:"rounded-xl border border-amber-200 bg-white py-3 text-[9px] font-black uppercase tracking-wider text-amber-800",children:"Abrir formulario"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[10px] font-black uppercase tracking-widest text-slate-500",children:"2. Aula"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ma.map(t=>e.jsx("button",{type:"button",onClick:()=>{q(t),N({...u,classroom:t})},className:`rounded-2xl border px-4 py-3 text-sm font-black ${u.classroom===t?"border-[#16A0EB] bg-sky-50 text-[#066591]":"border-slate-200 bg-white text-slate-500"}`,children:Se(t)},t))})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"3. Nivel"}),e.jsxs("select",{required:!0,value:u.level,onChange:t=>N({...u,level:t.target.value}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]",children:[e.jsx("option",{value:"",children:"Seleccionar nivel"}),Ut.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"4. Asignatura"}),e.jsxs("select",{required:!0,value:u.subject,onChange:t=>N({...u,subject:t.target.value}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]",children:[e.jsx("option",{value:"",children:"Seleccionar asignatura"}),Ht.map(t=>e.jsx("option",{value:t,children:t},t))]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[10px] font-black uppercase tracking-widest text-slate-500",children:"5. Dia"}),e.jsx("div",{className:"grid grid-cols-5 gap-1",children:Fe.map(t=>e.jsx("button",{type:"button",onClick:()=>N({...u,weekday:t.value}),className:`rounded-xl px-1 py-3 text-[8px] font-black uppercase ${u.weekday===t.value?"bg-[#066591] text-white":"border border-slate-200 bg-white text-slate-500"}`,children:t.label.slice(0,3)},t.value))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[10px] font-black uppercase tracking-widest text-slate-500",children:"6. Franja de 90 minutos"}),e.jsx("div",{className:"grid grid-cols-1 gap-2",children:ba.map(t=>{const m=u.start_time===t.start&&u.end_time===t.end;return e.jsx("button",{type:"button",onClick:()=>ye(t.start,t.end),className:`rounded-2xl border px-4 py-3 text-sm font-black ${m?"border-[#FC9A05] bg-orange-50 text-[#D86C00]":"border-slate-200 bg-white text-slate-600"}`,children:t.label},t.start)})})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"7. Profesor"}),e.jsxs("select",{value:u.teacher_email,onChange:t=>N({...u,teacher_email:t.target.value}),className:`w-full rounded-2xl border p-4 text-sm font-black outline-none ${u.teacher_email?"border-emerald-200 bg-emerald-50 text-emerald-800":"border-orange-200 bg-orange-50 text-[#D86C00]"}`,children:[e.jsx("option",{value:"",children:"Profesor pendiente"}),H.map(t=>e.jsx("option",{value:t.email,children:t.name},t.id))]}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-slate-500",children:"Puedes guardarlo pendiente y asignar el profesor cuando confirme disponibilidad."})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Nota interna opcional"}),e.jsx("textarea",{value:u.notes,onChange:t=>N({...u,notes:t.target.value}),rows:3,placeholder:"Ej.: familia pendiente de confirmar martes o miercoles",className:"w-full resize-none rounded-2xl border border-slate-200 bg-slate-50 p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-100 bg-sky-50 p-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#066591]",children:"Que ocurrira al guardar"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-sky-900",children:"Se compartira el plan entre Direccion y Coordinacion. No crea clases, no cobra a la fam
3ilia y no genera pago de profesor."})]}),e.jsx("button",{type:"submit",disabled:_,className:"w-full rounded-2xl bg-[#16A0EB] py-4 text-xs font-black uppercase tracking-widest text-white shadow-lg shadow-sky-200 disabled:opacity-50",children:_?"Guardando...":u.teacher_email?"Guardar grupo preparado":"Guardar con profesor pendiente"})]}),!u&&n.length===0&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-sky-200 bg-sky-50 p-7 text-center",children:[e.jsx("p",{className:"text-lg font-black text-[#066591]",children:"Todavia no hay grupos preparados"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-sky-800",children:"Empieza con las familias que ya han confirmado interes. Podras completar el profesor despues."}),e.jsx("button",{type:"button",onClick:J,className:"mt-4 rounded-2xl bg-[#FC9A05] px-5 py-3 text-[10px] font-black uppercase tracking-wider text-white",children:"Preparar primer grupo"})]}),!u&&ve.length>0&&e.jsxs("div",{className:"flex items-center justify-between px-1 pt-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-[#D86C00]",children:"Detalle editable"}),e.jsxs("h4",{className:"mt-1 text-lg font-black text-slate-900",children:["Grupos de ",Se(D)]})]}),e.jsx("span",{className:"rounded-xl bg-sky-50 px-3 py-2 text-[9px] font-black text-[#066591]",children:ve.length})]}),!u&&ve.map(t=>{const m=!t.teacher_email;return e.jsxs("article",{className:"rounded-[28px] border border-slate-100 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:`rounded-full px-3 py-1 text-[8px] font-black uppercase tracking-wider ${m?"bg-orange-50 text-[#D86C00]":"bg-emerald-50 text-emerald-700"}`,children:m?"Profesor pendiente":"Profesor propuesto"}),e.jsxs("span",{className:"rounded-full bg-sky-50 px-3 py-1 text-[8px] font-black uppercase text-[#066591]",children:[$(t),"/3 alumnos"]}),e.jsx("span",{className:"rounded-full bg-slate-100 px-3 py-1 text-[8px] font-black uppercase text-slate-600",children:Se(t.classroom)})]}),e.jsx("h4",{className:"mt-3 text-lg font-black text-slate-900",children:t.subject}),e.jsx("p",{className:"mt-1 text-xs font-bold text-slate-500",children:t.level})]}),e.jsx("button",{type:"button",onClick:()=>ue(t),className:"rounded-xl border border-sky-100 bg-sky-50 px-3 py-2 text-[9px] font-black uppercase text-[#066591]",children:"Editar"})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-2xl bg-slate-50 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-slate-400",children:"Horario"}),e.jsx("p",{className:"mt-1 text-xs font-black text-slate-800",children:Pa(t.weekday)}),e.jsxs("p",{className:"mt-1 text-xs font-bold text-slate-600",children:[t.start_time," - ",t.end_time]})]}),e.jsxs("div",{className:`rounded-2xl p-3 ${m?"bg-orange-50":"bg-emerald-50"}`,children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-slate-400",children:"Profesor"}),e.jsx("p",{className:`mt-1 text-xs font-black ${m?"text-[#D86C00]":"text-emerald-800"}`,children:Wt(H,t.teacher_email)})]})]}),e.jsxs("div",{className:"mt-4 rounded-2xl border border-slate-100 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-slate-400",children:"Alumnos"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[t.students.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[e.jsx("span",{className:"font-black text-slate-800",children:c.name}),e.jsx("span",{className:"shrink-0 font-bold text-slate-400",children:va(c)})]},c.student_id)),t.pending_student_names.map(c=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-amber-50 px-3 py-2 text-xs",children:[e.jsx("span",{className:"font-black text-amber-900",children:c}),e.jsx("span",{className:"shrink-0 text-[8px] font-black uppercase text-amber-700",children:"Falta ficha"})]},`pending-${c}`))]}),$(t)<3&&e.jsxs("p",{className:"mt-3 border-t border-slate-100 pt-3 text-[9px] font-black uppercase text-emerald-700",children:[3-$(t)," plaza",3-$
3(t)===1?"":"s"," disponible",3-$(t)===1?"":"s"]})]}),t.notes&&e.jsx("p",{className:"mt-3 rounded-2xl bg-amber-50 p-3 text-[10px] font-bold leading-relaxed text-amber-900",children:t.notes}),!m&&e.jsxs("div",{className:"mt-3 rounded-2xl border border-orange-100 bg-orange-50 p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-[#D86C00]",children:"Siguiente paso antes de Agenda"}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-orange-900",children:"Prepara la comprobacion del alta o de la ampliacion de horas. Asignar profesor aqui todavia no activa clases ni genera cobros."}),d&&e.jsx("button",{type:"button",onClick:d,className:"mt-3 w-full rounded-xl bg-[#FC9A05] py-3 text-[9px] font-black uppercase tracking-wider text-white",children:"Ir a Alta y horas"})]}),e.jsx("button",{type:"button",disabled:_,onClick:()=>void je(t),className:"mt-4 w-full rounded-xl border border-slate-200 py-2.5 text-[9px] font-black uppercase tracking-wider text-slate-400 hover:border-red-200 hover:text-red-600 disabled:opacity-50",children:"Archivar plan"})]},t.id)})]})},wa=()=>({modality:"academy",academic_group_plan_id:null,student_ids:[],teacher_email:"",assignment_summary:"",planned_start_date:"",weekly_hours:1.5,internal_notes:""}),Kt=d=>({labor_action:"new_registration",previous_weekly_hours:"0",resulting_weekly_hours:String(d.weekly_hours),verification_reference:"",internal_notes:d.internal_notes||"",confirmed:!1}),Zt=(d,n)=>{const[v,b]=d.split(":").map(Number),[G,H]=n.split(":").map(Number);return Math.max(.5,(G*60+H-(v*60+b))/60)},Jt=d=>d?new Date(`${d}T12:00:00`).toLocaleDateString("es-ES"):"Sin fecha",Na=d=>`${d.subject} · ${d.level} · ${Pa(d.weekday)} ${d.start_time}-${d.end_time}`,ka=(d,n)=>{var v;return((v=d.find(b=>b.email===n.toLowerCase()))==null?void 0:v.name)||n},Xt=({canAuthorize:d})=>{const[n,v]=i.useState([]),[b,G]=i.useState([]),[H,l]=i.useState([]),[u,N]=i.useState([]),[D,q]=i.useState(null),[Y,p]=i.useState(!0),[F,S]=i.useState(!1),[x,E]=i.useState(null),[M,B]=i.useState(null),[k,V]=i.useState(null),[K,_]=i.useState(""),[U,W]=i.useState(""),T=async()=>{_("");try{const[r,g]=await Promise.all([vt({statuses:["pending","verified"]}),Da()]);i.startTransition(()=>{q(r.schemaReady),v(r.controls),G(g.plans),l(g.students),N(g.teachers)})}catch(r){_(r instanceof Error?r.message:"No se pudo cargar el control de altas y horas.")}finally{p(!1)}};i.useEffect(()=>{T()},[]);const Z=b.filter(r=>!!r.teacher_email),s=x!=null&&x.academic_group_plan_id&&b.find(r=>r.id===x.academic_group_plan_id)||null,h=r=>r.map(g=>{var $;return($=H.find(oe=>oe.student_id===g))==null?void 0:$.name}).filter(Boolean).join(", "),R=()=>{_(""),W(""),E(wa())},L=r=>{r.status==="pending"&&(_(""),W(""),E({id:r.id,modality:r.modality,academic_group_plan_id:r.academic_group_plan_id,student_ids:r.student_ids,teacher_email:r.teacher_email,assignment_summary:r.assignment_summary,planned_start_date:r.planned_start_date,weekly_hours:r.weekly_hours,internal_notes:r.internal_notes||""}))},y=r=>{if(!x)return;const g=b.find($=>$.id===r);if(!g){E({...x,academic_group_plan_id:null,student_ids:[],teacher_email:"",assignment_summary:""});return}E({...x,academic_group_plan_id:g.id,student_ids:g.students.map($=>$.student_id),teacher_email:g.teacher_email||"",assignment_summary:Na(g),weekly_hours:Zt(g.start_time,g.end_time)})},C=r=>{x&&E({...wa(),id:x.id,modality:r,planned_start_date:x.planned_start_date,internal_notes:x.internal_notes})},I=r=>{if(!x||x.modality==="academy")return;const g=x.student_ids.includes(r);if(!g&&x.student_ids.length>=3){_("Puedes agrupar como máximo tres alumnos en un mismo control laboral.");return}_(""),E({...x,student_ids:g?x.student_ids.filter($=>$!==r):[...x.student_ids,r]})},J=async r=>{if(r.preventDefault(),!!x){if(!D){_("El control esta preparado en local, pero falta activar su migracion segura en Supabase. No se ha guardado nada.");return}if(x.modality==="academy"&&!x.academic_group_plan_id){_("Selecciona primero un grupo con profesor propuesto.");return}if(x.modality!=="academy"&&(x.student_ids.length<1||x.student_ids.length>3)){_(`Selecciona entre uno y tres alumnos para la asignacion ${x.modality==="online"?"online":"a domicilio"}.`);return}if(!x.teacher_email||!x.assignment_summary.trim()||!x.planned_start_date||x.weekly_hours<=0){_("Completa profesor, horario, fecha de inicio y horas docentes semanales.");return}S(!0),_(""),W("");try{await wt(x),E(null),W("Asignacion preparada. Ya puede vincularse en Agenda; Direccion confirmara despues el alta o las horas."),await T()}catch(g){_(g instanceof Error?g.message:"No se pudo preparar la asignacion.")}finally{S(!1)}}},ee=r=>{_(""),W(""),B(r),V(Kt(r))},ue=r=>{if(!M||!k)return;const g=r==="new_registration"?0:Number(k.previous_weekly_hours)||0,$=r==="hours_increase"?g+M.weekly_hours:r==="new_registration"?M.weekly_hours:Math.max(g,M.weekly_hours);V({...k,labor_action:r,previous_weekly_hours:String(g),resulting_weekly_hours:String($),confirmed:!1})},re=async r=>{if(r.preventDefault(),!M||!k)return;const g=Number(k.previous_weekly_hours),$=Number(k.resulting_weekly_hours);if(!Number.isFinite(g)||g<0||!Number.isFinite($)||$<0){_("Revisa las horas anteriores y resultantes.");return}if(!k.verification_reference.trim()||!k.confirmed){_("Falta la referencia interna y la confirmacion final de Direccion.");return}S(!0),_(""),W("");try{await _t({id:M.id,labor_action:k.labor_action,previous_weekly_hours:g,resulting_weekly_hours:$,verification_reference:k.verification_reference,internal_notes:k.internal_notes,confirmed:k.confirmed}),B(null),V(null),W("Alta y horas confirmadas. La asignacion ya estaba operativa y ahora queda tambien verificada."),await T()}catch(oe){_(oe instanceof Error?oe.message:"No se pudo verificar la asignacion.")}finally{S(!1)}},ye=async r=>{if(window.confirm("La comprobacion volvera a quedar pendiente, pero las clases seguiran operativas. Continuar?")){S(!0),_("");try{await Nt(r.id),W("Comprobacion reabierta. La asignacion vuelve a estar pendiente."),await T()}catch(g){_(g instanceof Error?g.message:"No se pudo reabrir la comprobacion.")}finally{S(!1)}}},ne=async r=>{if(window.confirm("Se archivara esta preparacion pendiente. No se borran alumnos, profesores ni clases. Continuar?")){S(!0),_("");try{await kt(r.id),W("Preparacion archivada sin modificar alumnos ni Agenda."),await T()}catch(g){_(g instanceof Error?g.message:"No se pudo archivar la preparacion.")}finally{S(!1)}}},me=n.filter(r=>r.status==="pending").length,je=n.filter(r=>r.status==="verified").length;return Y?e.jsx("div",{className:"rounded-[28px] border border-sky-100 bg-white p-8 text-center shadow-sm",children:e.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-[#066591]",children:"Cargando altas y horas..."})}):e.jsxs("section",{className:"space-y-4 animate-in fade-in",children:[e.jsx("div",{className:"overflow-hidden rounded-[30px] border border-sky-100 bg-white shadow-sm",children:e.jsxs("div",{className:"bg-gradient-to-br from-[#066591] to-[#16A0EB] p-5 text-white",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.22em] text-sky-100",children:"Seguimiento laboral"}),e.jsx("h3",{className:"mt-1 text-2xl font-black",children:"Alta y horas"}),e.jsx("p",{className:"mt-2 max-w-xs text-xs font-bold leading-relaxed text-sky-50",children:"Coordinacion prepara la asignacion y Direccion confirma el alta o la ampliacion. Una confirmacion pendiente no bloquea la actividad."})]}),e.jsx("button",{type:"button",onClick:R,className:"shrink-0 rounded-2xl bg-[#FC9A05] px-4 py-3 text-[10px] font-black uppercase tracking-wider text-white shadow-lg active:scale-95",children:"+ Preparar"})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-2xl bg-white/10 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-sky-100",children:"Pendientes"}),e.jsx("p",{className:"mt-1 text-2xl font-black",children:me})]}),e.jsxs("div",{className:"rounded-2xl bg-white/10 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-sky-100",children:"Verificadas"}),e.jsx("p",{className:"mt-1 text-2xl font-black",children:je})]})]})]})}),D===!1&&e.jsxs("div",{className:"rounded-[24px] border border-orange-200 bg-orange-50 p-5",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#D86C00]",children:"Pendiente de activacion tecnica"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-orange-900",children:"La pantalla aun no puede guardar seguimientos laborales, pero la Agenda permanece operativa. Direccion debera revisar estas tareas despues."})]}),K&&e.jsx("div",{className:"rounded-2xl border border-red-200 bg-red-50 p-4 text-xs font-bold text-red-700",children:K}),U&&e.jsx("div",{className:"rounded-2xl border border-emerald-200 bg-emerald-50 p-4 text-xs font-bold text-emerald-800",children:U}),x&&e.jsxs("form",{onSubmit:J,className:"space-y-4 rounded-[28px] border border-sky-100 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-[#D86C00]",children:"Preparacion compartida"}),e.jsx("h4",{className:"mt-1 text-xl font-black text-slate-900",children:"Nueva asignacion"})]}),e.jsx("button",{type:"button",onClick:()=>E(null),className:"rounded-xl border border-slate-200 px-3 py-2 text-[9px] font-black uppercase text-slate-500",children:"Cerrar"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 rounded-2xl bg-slate-50 p-1.5",children:[e.jsx("button",{type:"button",onClick:()=>C("academy"),className:`rounded-xl px-3 py-3 text-[9px] font-black uppercase ${x.modality==="academy"?"bg-[#066591] text-white":"text-slate-500"}`,children:"Academia"}),e.jsx("button",{type:"button",onClick:()=>C("home"),className:`rounded-xl px-3 py-3 text-[9px] font-black uppercase ${x.modality==="home"?"bg-[#066591] text-white":"text-slate-500"}`,children:"Domicilio"}),e.jsx("button",{type:"button",onClick:()=>C("online"),className:`rounded-xl px-3 py-3 text-[9px] font-black uppercase ${x.modality==="online"?"bg-[#066591] text-white":"text-slate-500"}`,children:"Online"})]}),x.modality==="academy"?e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Grupo preparado"}),e.jsxs("select",{required:!0,value:x.academic_group_plan_id||"",onChange:r=>y(r.target.value),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]",children:[e.jsx("option",{value:"",children:"Seleccionar grupo con profesor"}),Z.map(r=>
3e.jsx("option",{value:r.id,children:Na(r)},r.id))]}),Z.length===0&&e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-orange-700",children:"Primero asigna un profesor desde Plan de grupos."})]}):e.jsxs("fieldset",{className:"block",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[e.jsx("legend",{className:"text-[10px] font-black uppercase tracking-widest text-slate-500",children:x.modality==="online"?"Alumnos online":"Alumnos a domicilio"}),e.jsxs("span",{className:"rounded-full bg-sky-50 px-2 py-1 text-[9px] font-black text-[#066591]",children:[x.student_ids.length,"/3"]})]}),e.jsx("p",{className:"mb-3 text-[10px] font-bold leading-relaxed text-slate-500",children:x.modality==="online"?"Selecciona el alumnado de esta asignacion. La situacion profesional queda como recordatorio y no bloquea la Agenda.":"Agrupa aqui las familias que forman parte de la misma alta o ampliacion de horas del profesor."}),e.jsx("div",{className:"max-h-56 space-y-2 overflow-y-auto rounded-2xl border border-slate-200 bg-slate-50 p-3",children:H.map(r=>{const g=x.student_ids.includes(r.student_id);return e.jsxs("label",{className:`flex cursor-pointer items-center gap-3 rounded-xl border p-3 transition-colors ${g?"border-sky-300 bg-sky-50":"border-slate-100 bg-white"}`,children:[e.jsx("input",{type:"checkbox",checked:g,onChange:()=>I(r.student_id),className:"h-5 w-5 accent-[#16A0EB]"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-xs font-black text-slate-900",children:r.name}),e.jsx("span",{className:"block text-[9px] font-bold text-slate-500",children:r.level||r.course||"Nivel pendiente"})]})]},r.student_id)})})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Profesor propuesto"}),e.jsxs("select",{required:!0,disabled:x.modality==="academy",value:x.teacher_email,onChange:r=>E({...x,teacher_email:r.target.value}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none disabled:bg-slate-100 disabled:text-slate-500",children:[e.jsx("option",{value:"",children:"Seleccionar profesor"}),u.map(r=>e.jsx("option",{value:r.email,children:r.name},r.id))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Asignacion y horario"}),e.jsx("input",{required:!0,value:x.assignment_summary,onChange:r=>E({...x,assignment_summary:r.target.value}),placeholder:"Ej.: Matematicas 1 ESO · martes y jueves 17:30-18:30",className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Primera clase"}),e.jsx("input",{type:"date",required:!0,value:x.planned_start_date,onChange:r=>E({...x,planned_start_date:r.target.value}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Horas docentes/semana"}),e.jsx("input",{type:"number",min:"0.5",max:"40",step:"0.5",required:!0,value:x.weekly_hours,onChange:r=>E({...x,weekly_hours:Number(r.target.value)}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"}),e.jsx("p",{className:"mt-2 text-[9px] font-bold leading-relaxed text-slate-500",children:"Suma real de clases asignadas. Las horas de alta se indican aparte al verificar."})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Nota operativa opcional"}),e.jsx("textarea",{rows:3,value:x.internal_notes,onChange:r=>E({...x,internal_notes:r.target.value}
3),placeholder:"Solo datos de coordinacion. No adjuntar DNI, nominas ni documentos laborales.",className:"w-full resize-none rounded-2xl border border-slate-200 bg-slate-50 p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"})]}),s&&e.jsxs("div",{className:"rounded-2xl border border-sky-100 bg-sky-50 p-4 text-xs font-bold leading-relaxed text-sky-900",children:[e.jsx("strong",{children:"Alumnos:"})," ",s.students.map(r=>r.name).join(", "),".",e.jsx("br",{}),e.jsx("strong",{children:"Profesor:"})," ",ka(u,s.teacher_email||""),"."]}),e.jsxs("div",{className:"rounded-2xl border border-orange-100 bg-orange-50 p-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#D86C00]",children:"Seguimiento, no bloqueo"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-orange-900",children:"Guardar deja la tarea laboral preparada. Agenda, cobros y acceso del profesor siguen operativos mientras Direccion la confirma."})]}),e.jsx("button",{type:"submit",disabled:F||D===!1,className:"w-full rounded-2xl bg-[#16A0EB] py-4 text-xs font-black uppercase tracking-widest text-white shadow-lg shadow-sky-200 disabled:opacity-50",children:F?"Guardando...":"Dejar pendiente de Direccion"})]}),!x&&n.length===0&&e.jsxs("div",{className:"rounded-[28px] border border-dashed border-sky-200 bg-sky-50 p-7 text-center",children:[e.jsx("p",{className:"text-lg font-black text-[#066591]",children:"No hay asignaciones preparadas"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-sky-800",children:"Empieza por un grupo con profesor propuesto o por una familia de clases a domicilio."})]}),!x&&n.map(r=>{const g=r.status==="verified";return e.jsxs("article",{className:"rounded-[28px] border border-slate-100 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:`inline-flex rounded-full px-3 py-1 text-[8px] font-black uppercase tracking-wider ${g?"bg-emerald-50 text-emerald-700":"bg-orange-50 text-[#D86C00]"}`,children:g?"Alta confirmada":"Alta pendiente · Agenda operativa"}),e.jsx("h4",{className:"mt-3 text-lg font-black text-slate-900",children:r.assignment_summary}),e.jsx("p",{className:"mt-1 text-xs font-bold text-slate-500",children:h(r.student_ids)})]}),r.status==="pending"&&e.jsx("button",{type:"button",onClick:()=>L(r),className:"rounded-xl border border-sky-100 bg-sky-50 px-3 py-2 text-[9px] font-black uppercase text-[#066591]",children:"Editar"})]}),e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"rounded-2xl bg-slate-50 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-slate-400",children:"Profesor"}),e.jsx("p",{className:"mt-1 text-xs font-black text-slate-800",children:ka(u,r.teacher_email)})]}),e.jsxs("div",{className:"rounded-2xl bg-slate-50 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-wider text-slate-400",children:"Inicio y horas"}),e.jsx("p",{className:"mt-1 text-xs font-black text-slate-800",children:Jt(r.planned_start_date)}),e.jsxs("p",{className:"mt-1 text-[10px] font-bold text-slate-500",children:[r.weekly_hours," h docentes/semana"]})]})]}),e.jsxs("div",{className:`mt-3 rounded-2xl border p-4 ${g?"border-emerald-100 bg-emerald-50":"border-orange-100 bg-orange-50"}`,children:[e.jsx("p",{className:`text-[9px] font-black uppercase tracking-widest ${g?"text-emerald-700":"text-[#D86C00]"}`,children:g?jt(r.labor_action):r.modality==="online"?"Situacion profesional pendiente de revisar · no bloquea":"Falta decidir alta nueva o ampliacion de horas"}),g&&e.jsxs("p",{className:"mt-2 text-xs font-bold leading-relaxed text-emerald-900",children:["Alta anterior: ",r.previous_weekly_hours??0," h · Alta verificada: ",r.resulting_weekly_hours??0," h/semana"]})]}),r.internal_notes&&e.jsx("p",{className:"mt-3 rounded-2xl bg-slate-50 p-3 text-[10px] font-bold leading-relaxed text-slate-600",children:r.internal_notes}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[!g&&d&&r.modality!=="online"&&e.jsx("button",{type:"button",disabled:F,onClick:()=>ee(r),className:"flex-1 rounded-xl bg-[#FC9A05] px-3 py-3 text-[9px] font-black uppercase tracking-wider text-white disabled:opacity-50",children:"Comprobar y autorizar"}),!g&&(!d||r.modality==="online")&&e.jsx("div",{className:"flex-1 rounded-xl border border-orange-200 bg-orange-50 px-3 py-3 text-center text-[9px] font-black uppercase tracking-wider text-[#D86C00]",children:r.modality==="online"?"Recordatorio pendiente":"Esperando a Direccion"}),g&&d&&e.jsx("button",{type:"button",disabled:F,onClick:()=>void ye(r),className:"flex-1 rounded-xl border border-orange-200 bg-white px-3 py-3 text-[9px] font-black uppercase tracking-wider text-[#D86C00] disabled:opacity-50",children:"Reabrir comprobacion"}),!g&&e.jsx("button",{type:"button",disabled:F,onClick:()=>void ne(r),className:"rounded-xl border border-slate-200 px-3 py-3 text-[9px] font-black uppercase tracking-wider text-slate-400 disabled:opacity-50",children:"Archivar"})]})]},r.id)}),M&&k&&e.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-slate-950/70 p-4 backdrop-blur-sm",children:e.jsxs("form",{onSubmit:re,className:"max-h-[92vh] w-full max-w-md 
3space-y-4 overflow-y-auto rounded-[30px] bg-white p-6 shadow-2xl",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-[#D86C00]",children:"Solo Direccion"}),e.jsx("h4",{className:"mt-1 text-xl font-black text-slate-900",children:"Comprobar antes de empezar"}),e.jsx("p",{className:"mt-2 text-xs font-bold leading-relaxed text-slate-500",children:M.assignment_summary})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Situacion comprobada"}),e.jsxs("select",{value:k.labor_action,onChange:r=>ue(r.target.value),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]",children:[e.jsx("option",{value:"new_registration",children:"Alta nueva realizada"}),e.jsx("option",{value:"hours_increase",children:"Ampliacion de horas realizada"}),e.jsx("option",{value:"covered_by_current_registration",children:"Ya cubierto por alta y horas vigentes"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Horas de alta anteriores"}),e.jsx("input",{type:"number",min:"0",step:"0.5",required:!0,disabled:k.labor_action==="new_registration",value:k.previous_weekly_hours,onChange:r=>V({...k,previous_weekly_hours:r.target.value,confirmed:!1}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none disabled:bg-slate-100"})]}),e.jsxs("label",{children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Horas de alta verificadas"}),e.jsx("input",{type:"number",min:"0.5",step:"0.5",required:!0,value:k.resulting_weekly_hours,onChange:r=>V({...k,resulting_weekly_hours:r.target.value,confirmed:!1}),className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-sky-200 bg-sky-50 p-4 text-xs font-bold leading-relaxed text-sky-900",children:["Esta asignación suma ",e.jsxs("strong",{children:[M.weekly_hours," horas docentes semanales"]}),". La cifra de alta puede ser distinta; se registra aquí de forma separada y las diferencias reales se regularizan en nómina según el control de jornada."]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[10px] font-black uppercase tracking-widest text-slate-500",children:"Referencia interna"}),e.jsx("input",{required:!0,value:k.verification_reference,onChange:r=>V({...k,verification_reference:r.target.value,confirmed:!1}),placeholder:"Ej.: alta comprobada 10/09/2026",className:"w-full rounded-2xl border border-slate-200 bg-white p-4 text-sm font-bold outline-none focus:border-[#16A0EB]"}),e.jsx("p",{className:"mt-2 text-[9px] font-bold leading-relaxed text-slate-500",children:"No escribas DNI, numero de afiliacion ni adjuntes documentos aqui."})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-2xl border border-orange-200 bg-orange-50 p-4",children:[e.jsx("input",{type:"checkbox",checked:k.confirmed,onChange:r=>V({...k,confirmed:r.target.checked}),className:"mt-0.5 h-5 w-5 accent-[#FC9A05]"}),e.jsx("span",{className:"text-xs font-black leading-relaxed text-orange-900",children:"Confirmo que la situacion laboral esta comprobada y cubre esta asignacion antes de su primera clase."})]}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>{B(null),V(null)},className:"flex-1 rounded-xl border border-slate-200 py-4 text-[10px] font-black uppercase text-slate-500",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:F,className:"flex-[2] rounded-xl bg-[#FC9A05] py-4 text-[10px] font-black uppercase tracking-widest text-white shadow-lg disabled:opacity-50",children:F?"Comprobando...":"Autorizar para Agenda"})]})]})})]})},es=[{id:"candidate-whatsapp",title:"Candidato nuevo de WhatsApp",description:"Para quien nos escribe directamente y todavía debe completar su perfil, CV y disponibilidad.",url:se.candidateWhatsApp,tone:"border-emerald-100 bg-emerald-50/70"},{id:"candidate-advertisement",title:"Candidato de anuncio",description:"Para Milanuncios, publicaciones y otras campañas de captación de profesores.",url:se.candidateApplication,tone:"border-orange-100 bg-orange-50/70"},{id:"family",title:"Familia pide información",description:"Para consultas por WhatsApp, llamada, web o recomendación. No es el formulario de la puerta.",url:se.familyInquiry,tone:"border-blue-100 bg-blue-50/70"},{id:"door",title:"Formulario puerta academia",description:"Para fam
3ilias que llegan a la academia cuando no podemos atenderlas.",url:se.academyDoor,tone:"border-emerald-100 bg-emerald-50/70"},{id:"visit",title:"Registro rápido de visita",description:"Para que un profesor anote una consulta presencial y Coordinación continúe el seguimiento.",url:se.internalVisit,tone:"border-sky-100 bg-sky-50/70"}],as=async d=>{var b;if((b=navigator.clipboard)!=null&&b.writeText)try{return await navigator.clipboard.writeText(d),!0}catch{}const n=document.createElement("textarea");n.value=d,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.focus(),n.select();const v=document.execCommand("copy");return document.body.removeChild(n),v},ts=()=>{const[d,n]=i.useState(""),v=async(b,G)=>{if(!await as(G)){window.prompt("Copia este enlace:",G);return}n(b),window.setTimeout(()=>n(""),1800)};return e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"bg-emerald-50 border border-emerald-100 rounded-[24px] p-4 shadow-sm",children:[e.jsx("p",{className:"text-[9px] font-black text-emerald-700 uppercase tracking-widest",children:"Siempre Producción"}),e.jsx("h3",{className:"text-gray-950 font-black text-base mt-2",children:"Enlaces listos para enviar"}),e.jsx("p",{className:"text-[11px] font-bold text-gray-600 leading-relaxed mt-2",children:"Todos abren app.profe-en-casa.com. Aquí nunca se generan enlaces localhost ni accesos personales con token."})]}),es.map(b=>e.jsxs("div",{className:`border rounded-[24px] p-4 shadow-sm ${b.tone}`,children:[e.jsx("h3",{className:"text-sm font-black text-gray-950",children:b.title}),e.jsx("p",{className:"text-[10px] font-bold text-gray-600 leading-relaxed mt-2",children:b.description}),e.jsx("p",{className:"text-[9px] font-bold text-gray-500 break-all leading-relaxed mt-3 bg-white/80 border border-white rounded-xl p-3",children:b.url}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-3",children:[e.jsx("button",{type:"button",onClick:()=>v(b.id,b.url),className:"bg-[#16A0EB] text-white py-3 rounded-xl text-[9px] font-black uppercase tracking-widest shadow-sm active:scale-95 transition-all",children:d===b.id?"Copiado":"Copiar enlace"}),e.jsx("button",{type:"button",onClick:()=>window.open(b.url,"_blank","noopener,noreferrer"),className:"bg-white border border-gray-100 text-gray-700 py-3 rounded-xl text-[9px] font-black uppercase tracking-widest active:scale-95 transition-all",children:"Abrir"})]})]},b.id))]})},ss=[{id:"all",label:"Todos"},{id:"essential",label:"Primera tanda"},{id:"families",label:"Familias"},{id:"academy",label:"Profe a 3"},{id:"home",label:"Domicilio / online"},{id:"candidates",label:"Candidatos"}],_a=[{id:"family-first-contact",shortcut:"/familia",title:"Primera respuesta a una familia",description:"Pide solo los datos imprescindibles para orientar la consulta.",category:"families",essential:!0,message:`Hola, gracias por escribir a Profe en Casa.
4
5Para orientarte bien sin hacerte perder tiempo, dime por favor:
61. curso del alumno/a;
72. asignatura o asignaturas;
83. si buscas academia Profe a 3 en La Zubia, clases a domicilio u online.
9
10Con eso revisamos la opción que mejor puede encajar.
11
12Equipo Profe en Casa`},{id:"family-data-form",shortcut:"/datosfamilia",title:"Formulario para recoger datos",description:"Para una familia que ya ha pedido información por WhatsApp, llamada o recomendación.",category:"families",essential:!0,message:`Para que Coordinación pueda revisar bien el curso, las asignaturas y los horarios, puedes dejarnos aquí los datos básicos:
13
14${se.familyInquiry}
15
16Tardarás solo unos minutos. Este formulario no confirma una plaza ni genera ningún cobro; nos permite estudiar el hueco correcto y responderte con una opción concreta.`},{id:"academy-explanation",shortcut:"/profea3",title:"Cómo funciona Profe a 3",description:"Explicación breve del grupo, duración y compatibilidad.",category:"academy",essential:!0,message:`En Profe a 3 trabajamos en la academia de La Zubia con grupos habituales de 3 alumnos de cursos y nivel compatibles para una misma asignatura.
17
18Cada sesión dura 90 minutos y mantiene un horario estable durante el curso. Ca
18da asignatura se organiza en una clase diferente para que el profesor pueda centrarse de verdad en esa materia.
19
20El grupo comienza cuando están confirmados los 3 alumnos, el profesor y el horario. Solo para una recuperación justificada, un cuarto alumno puede incorporarse de forma excepcional a una sesión concreta.`},{id:"academy-price-primary-eso",shortcut:"/precioeso",title:"Precio Profe a 3 Primaria y ESO",description:"Tarifa con el grupo de tres alumnos completo.",category:"academy",essential:!0,message:`Para Primaria y ESO, Profe a 3 cuesta 12 EUR por alumno y sesión de 90 minutos cuando el grupo de 3 está completo.
21
22Una asignatura una vez por semana supondría unos 48 EUR en un mes con 4 sesiones. La cantidad real se calcula con las clases previstas en el calendario de cada mes.
23
24Antes de confirmarlo comprobamos que existan otros dos alumnos compatibles, profesor y horario.`},{id:"academy-price-bach",shortcut:"/preciobach",title:"Precio Profe a 3 Bachillerato",description:"Tarifa con el grupo de tres alumnos completo.",category:"academy",essential:!0,message:`Para Bachillerato, Profe a 3 cuesta 15 EUR por alumno y sesión de 90 minutos cuando el grupo de 3 está completo.
25
26Una asignatura una vez por semana supondría unos 60 EUR en un mes con 4 sesiones. La cantidad real se calcula con las clases previstas en el calendario de cada mes.
27
28Antes de confirmarlo comprobamos que existan otros dos alumnos compatibles, profesor y horario.`},{id:"academy-multiple-subjects",shortcut:"/dosasignaturas",title:"Dos asignaturas diferentes",description:"Aclara que cada materia necesita una sesión y un grupo distintos.",category:"academy",essential:!0,message:`Cada asignatura necesita su propia clase de 90 minutos y un grupo compatible. No dividimos una misma sesión entre dos materias porque el apoyo perdería eficacia.
29
30En Bachillerato, dos asignaturas con una sesión semanal de cada una son 30 EUR por semana y aproximadamente 120 EUR en un mes con 4 sesiones de cada materia.
31
32Podemos comprobar las dos asignaturas, aunque es posible que cada grupo tenga un día, horario o profesor diferente.`},{id:"academy-group-pending",shortcut:"/grupopendiente",title:"Grupo todavía pendiente",description:"Registra el interés sin prometer plaza antes de completar el grupo.",category:"academy",essential:!0,message:`Ya hemos anotado vuestro interés en [ASIGNATURA] para [CURSO].
33
34Todavía no queremos prometer una plaza que no esté cerrada: Profe a 3 comienza cuando confirmamos 3 alumnos compatibles, profesor y horario.
35
36Os dejamos en preparación de grupo y os contactaremos en cuanto podamos ofrecer una opción real. Mientras tanto, decidnos qué tardes os vienen mejor y cuáles no podéis.`},{id:"academy-slot-proposal",shortcut:"/huecopropuesto",title:"Proponer un hueco real",description:"Plantilla para confirmar el interés antes de cerrar la plaza.",category:"academy",message:`Tenemos una posible opción para [ALUMNO/A]:
37
38Asignatura: [ASIGNATURA]
39Curso/nivel: [CURSO]
40Día y hora: [DÍA, DE HORA A HORA]
41Inicio previsto: [FECHA]
42Precio: [PRECIO] EUR por sesión de 90 minutos
43
44Si os encaja, respondednos con un SÍ y dejamos registrada vuestra intención mientras cerramos profesor y grupo.`},{id:"family-accepts",shortcut:"/familiasi",title:"La familia quiere avanzar",description:"Se usa solo con el enlace personal generado desde el lead.",category:"families",essential:!0,message:`Perfecto. Dejamos registrada vuestra intención de incorporaros a [ASIGNATURA / MODALIDAD].
45
46El siguiente paso es completar o revisar la ficha familiar mediante vuestro enlace personal:
47
48[PEGAR AQUI EL ENLACE SEGURO GENERADO DESDE EL LEAD]
49
50Este enlace es individual. Cuando tengamos confirmados grupo, profesor, horario y fecha de inicio os enviaremos el resumen definitivo antes de comenzar.`},{id:"family-payment",shortcut:"/pago",title:"Pago y calendario mensual",description:"Explica recibo, plazo y cálculo según sesiones previstas.",category:"families",message:`El importe de cada mes se calcula con las sesiones que aparecen realmente previstas en el calendario.
51
52El día 1 enviamos el recibo por WhatsApp y correo electrónico. Se abona durante la primera semana del mes.
53
54Los festivos y cierres conocidos se tienen en cuenta antes de preparar el recibo y no se cobran como clases impartidas.`},{id:"family-absence",shortcut:"/ausencias",title:"Ausencias y recuperaciones",description:"Resumen sencillo para grupos de academia.",category:"families",message:`Cada sesión mantiene reservados el profesor, el horario y la plaza del alumno en su grupo.
55
56Si existe una ausencia justificada y se avisa correctamente, intentaremos ofrecer una recuperación en otro grupo con contenido compatible. De forma excepcional, el alumno puede ocupar una cuarta plaza solo durante esa sesión. Una falta sin justificar no genera recuperación.
57
58Si la clase se cancela por parte de Profe en Casa, se recupera o se refleja el ajuste correspondiente.`},{id:"family-appointment",shortcut:"/cita",title:"Concertar una cita",description:"Confirma una atención presencial y prepara la información necesaria.",category:"families",message:`Podemos atenderos en la academia el [DÍA] a las [HORA].
59
60Para aprovechar la cita, traed o decidnos antes el curso, las asignaturas, las últimas dificultades y las tardes disponibles. Así podremos revisar grupos y opciones concretas.
61
62Confirmadnos por favor si os viene bien.`},{id:"family-follow-up",shortcut:"/seguimiento",title:"Seguimiento si no responde",description:"Recordatorio amable antes de cerrar o mantener la oportunidad.",category:"families",message:`Hola. Te escribimos para saber si seguís interesados en el apoyo para [ALUMNO/A / CURSO / ASIGNATURA].
63
64Estamos organizando grupos y profesores y preferimos confirmar vuestra situación antes de cerrar opciones. Si ya no lo necesitáis, decidnoslo sin problema; y si queréis continuar, revisamos los horarios disponibles.`},{id:"home-information",shortcut:"/domicilio",title:"Primera información a domicilio",description:"Recoge los datos necesarios antes de proponer profesor y horario.",category:"home",message:`En las clases a domicilio organizamos un profesor estable para el curso, con el horario y la frecuencia acordados. Antes de la primera clase comprobamos su alta o, si ya trabaja con nosotros, la ampliación de horas correspondiente.
65
66Buscamos continuidad durante el curso. Si el profesor no pudiera continuar, Coordinación se ocuparía de buscar una sustitución compatible.
67
68Para prepararte una propuesta necesito: curso, asignatura, localidad o zona, días disponibles y si preferís sesiones de 60, 90 o 120 minutos.`}
68,{id:"home-price-primary",shortcut:"/domprimaria",title:"Precio domicilio Primaria",description:"Precios por sesión para el curso 2026/27.",category:"home",message:`Para Primaria a domicilio, las sesiones cuestan 19 EUR por 60 minutos, 29 EUR por 90 minutos o 38 EUR por 120 minutos.
69
70Podemos organizar una o dos sesiones semanales. Antes de confirmar comprobamos zona, profesor, horario y fecha de inicio.`},{id:"home-price-eso",shortcut:"/domeso",title:"Precio domicilio ESO",description:"Precios por sesión para el curso 2026/27.",category:"home",message:`Para ESO a domicilio, las sesiones cuestan 20 EUR por 60 minutos, 30 EUR por 90 minutos o 40 EUR por 120 minutos.
71
72Podemos organizar una o dos sesiones semanales. Antes de confirmar comprobamos zona, profesor, horario y fecha de inicio.`},{id:"home-price-bach",shortcut:"/dombach",title:"Precio domicilio Bachillerato",description:"Precios por sesión para el curso 2026/27.",category:"home",message:`Para Bachillerato a domicilio, las sesiones cuestan 22 EUR por 60 minutos, 33 EUR por 90 minutos o 44 EUR por 120 minutos.
73
74Podemos organizar una o dos sesiones semanales. Antes de confirmar comprobamos zona, profesor, horario y fecha de inicio.`},{id:"online-information",shortcut:"/online",title:"Primera información online",description:"No promete precio hasta comprobar especialista y horario.",category:"home",message:`También podemos estudiar una opción online. Para buscar un profesor especialista necesitamos saber curso, asignatura, objetivo, días disponibles y frecuencia semanal.
75
76Cuando comprobemos el profesional y el horario os enviaremos una propuesta concreta antes de confirmar. No queremos daros un precio o prometer una plaza sin revisar primero ese encaje.`},{id:"candidate-first-contact",shortcut:"/candidato",title:"Primera respuesta a un candidato",description:"Envía el formulario correcto y explica la reserva recomendada de tardes.",category:"candidates",essential:!0,message:`Hola, gracias por tu interés en colaborar con Profe en Casa.
77
78Estamos organizando el equipo del curso. Para conocerte y valorar materias, niveles, desplazamiento y disponibilidad, completa por favor este formulario:
79
80${se.candidateWhatsApp}
81
82En academia y domicilio trabajamos mediante alta laboral. Lo recomendable es poder reservar dos tardes completas de 16:00 a 20:30, que iremos intentando completar de forma progresiva.
83
84Equipo Profe en Casa`},{id:"candidate-received",shortcut:"/candidatook",title:"Candidatura recibida",description:"Confirma recepción sin prometer incorporación ni horas.",category:"candidates",essential:!0,message:`Hola, [NOMBRE]. Hemos recibido correctamente tu candidatura.
85
86Ahora revisaremos titulación, materias, niveles, localidad, desplazamiento y tardes disponibles. Si vemos un encaje posible, te escribiremos para una entrevista.
87
88Recibir la candidatura no supone todavía una incorporación ni un número de horas confirmado. Gracias por interesarte en el proyecto.`},{id:"candidate-missing-data",shortcut:"/faltacandidato",title:"Faltan datos del candidato",description:"Pide materias, nivel, dos tardes y desplazamiento.",category:"candidates",message:`Hola, [NOMBRE]. Para valorar bien tu candidatura necesitamos concretar dos cosas:
89
901. asignaturas y nivel máximo que puedes impartir con seguridad;
912. dos tardes completas que podrías reservar de 16:00 a 20:30.
92
93Indícanos también si tienes vehículo o hasta qué zonas puedes desplazarte.`},{id:"candidate-interview",shortcut:"/entrevista",title:"Proponer entrevista",description:"Plantilla para una entrevista presencial, telefónica u online.",category:"candidates",essential:!0,message:`Hola, [NOMBRE]. Hemos revisado tu perfil y nos gustaría conocerte mejor para valorar posibles grupos o alumnos.
94
95Te proponemos una entrevista [PRESENCIAL / TELEFÓNICA / ONLINE] el [DÍA] a las [HORA]. Durará aproximadamente [DURACIÓN].
96
97Confírmame por favor si puedes asistir y, si no, qué alternativa cercana te viene bien.`},{id:"candidate-available",shortcut:"/profedisponible",title:"Pasar a profesor disponible",description:"Confirma las tardes sin prometer horas antes de una asignación.",category:"candidates",message:`Hola, [NOMBRE]. Tras la entrevista queremos contar contigo como profesor/a disponible para posibles asignaciones.
98
99Las tardes que dejamos inicialmente reservadas son [DÍAS], de 16:00 a 20:30. Procuraremos completarlas progresivamente con grupos o familias compatibles.
100
101Esto todavía no significa que exista una incorporación ni horas garantizadas. Antes de cada comienzo confirmaremos alumno o grupo, horario, condiciones y alta o ampliación correspondiente.`},{id:"candidate-waiting-list",shortcut:"/candidatoespera",title:"Perfil en reserva",description:"Mantiene una candidatura interesante sin inventar un hueco.",category:"candidates",essential:!0,message:`Hola, [NOMBRE]. Tu perfil nos parece interesante, aunque ahora mismo no tenemos una asignación concreta que encaje con tus materias y disponibilidad.
102
103Con tu permiso, mantenemos la candidatura en nuestra bolsa para contactarte cuando aparezca un grupo, sustitución o familia compatible. Si cambia tu disponibilidad, puedes avisarnos para actualizarla.`},{id:"candidate-online",shortcut:"/candidatoonline",title:"Candidato exclusivamente online",description:"Pregunta por facturación sin dar por válida la situación profesional.",category:"candidates",message:`Para las colaboraciones exclusivamente online necesitamos revisar también la forma profesional de facturación.
104
105Indícanos si actualmente eres autónomo/a o si puedes emitir facturas legalmente de forma regular. Esta respuesta no confirma por sí sola la colaboración; revisaremos el encaje completo antes de proponerte clases.`},{id:"candidate-cv-failure",shortcut:"/cvfallo",title:"Fallo al subir el CV",description:"Permite recibir el archivo sin perder los datos estructurados del formulario.",category:"candidates",message:`Gracias por avisarnos. Si el formulario no te permite subir el CV, puedes enviarlo temporalmente por este WhatsApp.
106
107Aun así, necesitamos que completes el resto del formulario para que materias, niveles, disponibilidad y zona queden bien registrados:
108
109${se.candidateWhatsApp}`},{id:"teacher-availability-update",shortcut:"/horarioprofe",title:"Actualizar horario del profesor",description:"Pide al equipo que confirme sus bloques reales del curso 2026/27.",category:"candidates",essential:!0,message:`Hola, [NOMBRE]. Estamos organizando los grupos y horarios del curso 2026/27.
110
111Por favor, entra en ${se.login} y abre Mi perfil > Disponibilidad real. Marca los bloques en los que puedes dar clase y guarda los cambios.
112
113Cuando lo tengas actualizado, avísanos por aquí para poder asignarte solo clases que encajen de verdad con tu horario. Gracias.`}],rs=async d=>{var b;if((b=navigator.clipboard)!=null&&b.writeText)try{return await navigator.clipboard.writeText(d),!0}catch{}const n=document.createElement("textarea");n.value=d,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.focus(),n.select();const v=document.execCommand("copy");return document.body.removeChild(n),v},Ca=d=>d.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),ns=()=>{const[d,n]=i.useState("essential"),[v,b]=i.useState(""),[G,H]=i.useState(null),[l,u]=i.useState(""),N=i.useDeferredValue(v),D=Ca(N.trim()),q=_a.filter(p=>d==="essential"&&!p.essential||d!=="all"&&d!=="essential"&&p.category!==d?!1:D?Ca(`${p.shortcut} ${p.title} ${p.description} ${p.message}`).includes(D):!0),Y=async(p,F)=>{if(!await rs(p)){window.prompt("Copia este texto:",p);return}u(F),window.setTimeout(()=>u(""),1800)};return e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"bg-gradient-to-br from-blue-50 to-orange-50 border border-blue-100 rounded-[28px] p-5 shadow-sm",children:[e.jsx("p",{className:"text-[9px] font-black text-[#066591] uppercase tracking-widest",children:"Respuestas rápidas"}),e.jsx("h2",{className:"text-2xl font-black text-gray-950 leading-tight mt-2",children:"Mensajes para WhatsApp"}),e.jsxs("p",{className:"text-[11px] font-bold text-gray-600 leading-relaxed mt-3",children:["Copia el mensaje y guárdalo una sola vez en las respuestas rápidas de WhatsApp Business con el atajo indicado. Después podrás escribir ",e.jsx("strong",{children:"/"})," para localizarlo."]}),e.jsxs("div",{className:"bg-[#066591] text-white rounded-2xl p-4 mt-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-blue-100",children:"Cuenta de trabajo"}),e.jsx("p",{className:"text-sm font-black mt-1",children:"WhatsApp Business · 958 89 10 92"}),e.jsx("p",{className:"text-[10px] font-bold text-blue-50 leading-relaxed mt-2",children:"Es la cuenta compartida por Francisco y Gabriela. El número 958 59 94 50 pertenece al circuito Meta / Globy y se mantiene separado."})]}),e.jsxs("div",{className:"bg-white/90 border border-white rounded-2xl p-4 mt-4 space-y-2",children:[e.jsx("p",{className:"text-[9px] font-black text-[#FC9A05] uppercase tracking-widest",children:"Configuración una sola vez"}),e.jsxs("p",{className:"text-[10px] font-bold text-gray-700 leading-relaxed",children:["1. Pulsa ",e.jsx("strong",{children:"Copiar mensaje"}),"."]}),e.jsx("p",{className:"text-[10px] font-bold text-gray-700 leading-relaxed",children:"2. Crea una respuesta rápida en WhatsApp Business y pega el texto."}),e.jsx("p",{className:"text-[10px] font-bold text-gray-700 leading-relaxed",children:"3. Usa el atajo mostrado. Si WhatsApp ya pone la barra, escribe solo la palabra."}),e.jsxs("p",{className:"text-[10px] font-bold text-gray-700 leading-relaxed",children:["4. Guárdalo y prueba escribiendo ",e.jsx("strong",{children:"/"})," en una conversación sin enviarlo."]})]}),e.jsxs("p",{className:"text-[9px] font-bold text-gray-500 leading-relaxed mt-3",children:["La app solo copia. No envía mensajes, no abre conversaciones y no modifica datos de familias o candidatos. Hay ",_a.length," respuestas preparadas de un máximo de 50 permitido por WhatsApp Business."]})]}),e.jsxs("div",{className:"bg-white border border-gray-100 rounded-[24px] p-4 shadow-sm space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[8px] font-black text-gray-400 uppercase tracking-widest",children:"Buscar mensaje"}
113),e.jsx("input",{type:"search",value:v,onChange:p=>b(p.target.value),placeholder:"Ej.: Bachillerato, candidato, pago...",className:"w-full mt-2 bg-gray-50 border border-gray-200 rounded-xl px-4 py-3 text-xs font-bold text-gray-900 outline-none focus:border-[#16A0EB]"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:ss.map(p=>e.jsx("button",{type:"button",onClick:()=>n(p.id),className:`px-3 py-2 rounded-xl text-[8px] font-black uppercase tracking-widest transition-all ${d===p.id?"bg-[#16A0EB] text-white shadow-sm":"bg-gray-50 border border-gray-100 text-gray-500"}`,children:p.label},p.id))})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 px-1",children:[e.jsxs("p",{className:"text-[10px] font-black text-gray-500",children:[q.length," ",q.length===1?"mensaje":"mensajes"]}),e.jsx("p",{className:"text-[9px] font-bold text-gray-400",children:"Revisa los textos entre [corchetes]"})]}),q.length===0&&e.jsxs("div",{className:"bg-white border border-gray-100 rounded-[24px] p-6 text-center shadow-sm",children:[e.jsx("p",{className:"text-sm font-black text-gray-700",children:"No hay mensajes con esa búsqueda."}),e.jsx("button",{type:"button",onClick:()=>{b(""),n("all")},className:"mt-3 text-[9px] font-black uppercase tracking-widest text-[#16A0EB]",children:"Mostrar todos"})]}),q.map(p=>{const F=G===p.id,S=`message-${p.id}`,x=`shortcut-${p.id}`,E=/\[[^\]]+\]/.test(p.message);return e.jsxs("article",{className:"bg-white border border-gray-100 rounded-[24px] p-4 shadow-sm",children:[e.jsx("div",{className:"flex items-start justify-between gap-3",children:e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{type:"button",onClick:()=>Y(p.shortcut,x),className:"bg-[#066591] text-white rounded-full px-3 py-1.5 text-[9px] font-black tracking-wide active:scale-95 transition-all",title:"Copiar atajo",children:l===x?"Copiado":p.shortcut}),p.essential&&e.jsx("span",{className:"bg-orange-50 border border-orange-100 text-[#c96d00] rounded-full px-2 py-1 text-[7px] font-black uppercase tracking-widest",children:"Primera tanda"}),E&&e.jsx("span",{className:"bg-amber-50 border border-amber-100 text-amber-700 rounded-full px-2 py-1 text-[7px] font-black uppercase tracking-widest",children:"Revisar antes"})]}),e.jsx("h3",{className:"text-sm font-black text-gray-950 leading-tight mt-3",children:p.title}),e.jsx("p",{className:"text-[10px] font-bold text-gray-500 leading-relaxed mt-1",children:p.description})]})}),F&&e.jsx("div",{className:"mt-4 bg-slate-50 border border-slate-100 rounded-2xl p-4",children:e.jsx("p",{className:"whitespace-pre-wrap text-[11px] font-medium text-gray-800 leading-relaxed",children:p.message})}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[e.jsx("button",{type:"button",onClick:()=>Y(p.message,S),className:"bg-[#16A0EB] text-white py-3 rounded-xl text-[9px] font-black uppercase tracking-widest shadow-sm active:scale-95 transition-all",children:l===S?"Mensaje copiado":"Copiar mensaje"}),e.jsx("button",{type:"button",onClick:()=>H(F?null:p.id),className:"bg-white border border-blue-100 text-[#066591] py-3 rounded-xl text-[9px] font-black uppercase tracking-widest active:scale-95 transition-all",children:F?"Ocultar":"Ver mensaje"})]})]},p.id)})]})},os={puerta_academia:"Puerta academia",qr_profesor:"Registro de profesor",anuncio_familias:"Anuncio familias",anuncio_candidatos:"Candidato por WhatsApp",selectividad:"Selectividad",web:"Web",referido:"Recomendación",whatsapp_manual:"WhatsApp directo"},Aa={family_lead:"Familia interesada",family:"Familia",candidate:"Candidato",unknown:"Por clasificar"},is=async d=>{var b;if((b=navigator.clipboard)!=null&&b.writeText)try{return await navigator.clipboard.writeText(d),!0}catch{}const n=document.createElement("textarea");n.value=d,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.focus(),n.select();const v=document.execCommand("copy");return document.body.removeChild(n),v},$e=d=>{if(!d)return"Sin fecha";const n=new Date(d);
113return Number.isNaN(n.getTime())?"Sin fecha":new Intl.DateTimeFormat("es-ES",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}).format(n)},Sa=d=>{const n=String(d||"").replace(/\D/g,"");return n.startsWith("34")&&n.length===11?`+34 ${n.slice(2,5)} ${n.slice(5,8)} ${n.slice(8)}`:d||"Teléfono no disponible"},ls=()=>{const[d,n]=i.useState("pending"),[v,b]=i.useState([]),[G,H]=i.useState(!0),[l,u]=i.useState(""),[N,D]=i.useState(""),[q,Y]=i.useState(""),[p,F]=i.useState(""),[S,x]=i.useState({}),[E,M]=i.useState(!1),[B,k]=i.useState(!1),[V,K]=i.useState(0);i.useEffect(()=>{let s=!1;return(async()=>{H(!0),u("");let{data:R,error:L}=await A.rpc("get_globy_v2_supervised_queue",{p_limit:40,p_scope:d});if(!!(L&&(L.code==="PGRST202"||String(L.message||"").includes("get_globy_v2_supervised_queue")))){const C=await A.rpc("get_globy_v2_draft_queue",{p_limit:40,p_scope:d});R=C.data,L=C.error,s||(M(!1),k(!1))}else if(!L&&!s){const{data:C,error:I}=await A.rpc("get_globy_v2_outbound_control");s||(M(!I),k(!I&&!!(C!=null&&C.enabled)))}if(!s){if(L)b([]),u(L.message||"No se ha podido abrir la bandeja.");else{const C=R||[];b(C),x(I=>{const J={};
113return C.forEach(ee=>{J[ee.draft_id]=I[ee.draft_id]??ee.approved_reply_text??ee.reply_text}),J})}H(!1)}})(),()=>{s=!0}},[d,V]);const _=async s=>{if(!await is(s.reply_text)){window.prompt("Copia este borrador:",s.reply_text);return}Y(s.draft_id),window.setTimeout(()=>Y(""),1800)},U=s=>{const h=String(s||"").replace(/\D/g,"");h&&window.open(`https://wa.me/${h}`,"_blank","noopener,noreferrer")},W=async s=>{const h=String(S[s.draft_id]||"").trim();if(!B){u("La salida supervisada está deshabilitada. Mientras siga así, ninguna respuesta puede quedar aprobada para enviar.");return}if(!h||h.length>4096){u("La respuesta debe tener entre 1 y 4096 caracteres.");return}D(s.draft_id),u("");const{error:R}=await A.rpc("approve_globy_v2_draft",{p_draft_id:s.draft_id,p_reply_text:h});R?u(R.message||"No se ha podido aprobar la respuesta."):(F(""),K(L=>L+1)),D("")},T=async s=>{if(!window.confirm("¿Retirar la aprobación antes de que se envíe?"))return;D(s.draft_id),u("");const{error:h}=await A.rpc("withdraw_globy_v2_approval",{p_draft_id:s.draft_id});h?u(h.message||"No se ha podido retirar la aprobación."):K(R=>R+1),D("")},Z=async(s,h)=>{if(h==="discarded"&&!window.confirm("¿Archivar este borrador? Podrás recuperarlo desde Atendidos."))return;D(s.draft_id),u("");const{error:R}=await A.rpc("review_globy_v2_draft",{p_draft_id:s.draft_id,p_action:h});R?u(R.message||"No se ha podido actualizar el borrador."):K(L=>L+1),D("")};return e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsx("section",{className:"rounded-[26px] border border-sky-100 bg-gradient-to-br from-sky-50 via-white to-orange-50 p-4 shadow-sm",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-[0.2em] text-[#066591]",children:"Revisión humana obligatoria"}),e.jsx("h3",{className:"mt-2 text-lg font-black text-[#17324D]",children:"Bandeja Globy"}),e.jsx("p",{className:"mt-2 text-[11px] font-bold leading-relaxed text-slate-600",children:"Globy prepara la información. Francisco o Gabriela revisan y corrigen el texto antes de autorizar cualquier salida."})]}),e.jsxs("div",{className:"shrink-0 rounded-2xl border border-orange-100 bg-white px-3 py-2 text-center shadow-sm",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-orange-500",children:"Nunca"}),e.jsx("p",{className:"mt-1 text-sm font-black text-[#066591]",children:"Automático"})]})]})}),e.jsxs("section",{className:`rounded-2xl border p-3 ${B?"border-sky-100 bg-sky-50":"border-amber-200 bg-amber-50"}`,children:[e.jsx("p",{className:`text-[9px] font-black uppercase tracking-widest ${B?"text-[#066591]":"text-amber-700"}`,children:B?"Aprobación supervisada disponible":E?"Salida supervisada instalada y apagada":"Aprobación supervisada pendiente de instalar"}),e.jsx("p",{className:"mt-1 text-[10px] font-bold leading-relaxed text-slate-600",children:B?"Editar y aprobar deja la respuesta firmada por la persona responsable. Solo el workflow de salida autorizado puede recogerla.":E?"La bandeja funciona en modo copiar y responder manualmente. El seguro central impide aprobar o enviar como 958 59 94 50 hasta la activación final.":"La bandeja actual sigue funcionando en modo copiar y responder manualmente. Ningún botón puede enviar todavía como 958 59 94 50."})]}),e.jsxs("section",{className:"rounded-2xl border border-slate-200 bg-white p-3",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-slate-500",children:"Qué aparece en esta bandeja"}),e.jsxs("div",{className:"mt-2 grid gap-2 text-[10px] font-bold leading-relaxed text-slate-600 sm:grid-cols-2",children:[e.jsxs("p",{className:"rounded-xl bg-slate-50 p-3",children:[e.jsx("strong",{className:"text-[#17324D]",children:"WhatsApp técnico:"})," aquí verás lo que escribió la persona y, debajo, la respuesta que propone Globy."]}),e.jsxs("p",{className:"rounded-xl bg-emerald-50 p-3",children:[e.jsx("strong",{className:"text-emerald-800",children:"Formulario del anuncio:"})," las candidaturas enviadas desde Milanuncios aparecen en Candidatos, no en esta bandeja."]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>n("pending"),className:`rounded-2xl px-3 py-3 text-[9px] font-black uppercase tracking-widest transition-all ${d==="pending"?"bg-[#066591] text-white shadow-md":"border border-sky-100 bg-white text-[#066591]"}`,children:"Pendientes"}),e.jsx("button",{type:"button",onClick:()=>n("handled"),className:`rounded-2xl px-3 py-3 text-[9px] font-black uppercase tracking-widest transition-all ${d==="handled"?"bg-[#FC9A05] text-white shadow-md":"border border-orange-100 bg-white text-orange-600"}`,children:"Atendidos"})]}),e.jsx("button",{type:"button",onClick:()=>K(s=>s+1),disabled:G,className:"w-full rounded-xl border border-slate-100 bg-white py-2.5 text-[9px] font-black uppercase tracking-widest text-slate-500 disabled:opacity-50",children:G?"Actualizando...":"Actualizar bandeja"}),l&&e.jsx("div",{role:"alert",className:"rounded-2xl border border-red-100 bg-red-50 p-4 text-[11px] font-bold leading-relaxed text-red-700",children:l}),!G&&!l&&v.length===0&&e.jsxs("div",{className:"rounded-[24px] border border-dashed border-sky-200 bg-white p-6 text-center",children:[e.jsx("p",{className:"text-sm font-black text-[#17324D]",children:d==="pending"?"No hay consultas pendientes":"Todavía no hay consultas atendidas"}),e.jsx("p",{className:"mt-2 text-[10px] font-bold leading-relaxed text-slate-500",children:"Los mensajes enviados al número técnico de Meta aparecerán aquí para revisión humana. Las personas que completen el formulario de empleo se consultan en Candidatos; Globy no responde automáticamente."})]}),v.map(s=>{const h=s.status==="draft"||s.status==="failed",R=s.status==="approved",
113L=s.status==="sending",y=h||R||L,C=s.approved_reply_text||s.reply_text;return e.jsxs("article",{className:"rounded-[26px] border border-sky-100 bg-white p-4 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:"rounded-full bg-sky-50 px-2.5 py-1 text-[8px] font-black uppercase tracking-widest text-[#066591]",children:Aa[s.contact_type]||Aa.unknown}),e.jsx("span",{className:"rounded-full bg-orange-50 px-2.5 py-1 text-[8px] font-black uppercase tracking-widest text-orange-600",children:os[s.source_key]||s.source_key})]}),e.jsx("h4",{className:"mt-3 truncate text-base font-black text-[#17324D]",children:s.display_name||"Contacto WhatsApp"}),e.jsxs("p",{className:"mt-1 text-[10px] font-bold text-slate-500",children:[Sa(s.phone_e164)," · ",$e(s.provider_timestamp||s.created_at)]})]}),e.jsx("span",{className:`shrink-0 rounded-xl px-2.5 py-1.5 text-[8px] font-black uppercase tracking-widest ${y?"bg-orange-500 text-white":"bg-sky-100 text-[#066591]"}`,children:s.status==="approved"?"Aprobado":s.status==="sending"?"Enviando":s.status==="failed"?"Revisar error":s.status==="draft"?"Pendiente":s.status==="handled"?"Atendido":s.status==="discarded"?"Archivado":"Enviado"})]}),e.jsxs("div",{className:"mt-4 rounded-2xl border border-slate-100 bg-slate-50 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-slate-500",children:"Lo que escribió la persona"}),e.jsx("p",{className:"mt-2 text-[11px] font-bold leading-relaxed text-slate-700",children:s.message_preview||"Sin texto disponible"})]}),h?e.jsxs("div",{className:"mt-3 rounded-2xl border border-sky-100 bg-sky-50/70 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-[#066591]",children:"Respuesta propuesta por Globy · revisar antes de usar"}),e.jsxs("span",{className:"text-[8px] font-black text-slate-400",children:[(S[s.draft_id]||"").length,"/4096"]})]}),e.jsx("textarea",{value:S[s.draft_id]??s.reply_text,onChange:I=>x(J=>({...J,[s.draft_id]:I.target.value})),maxLength:4096,rows:7,className:"mt-2 w-full resize-y rounded-xl border border-sky-100 bg-white p-3 text-[11px] font-bold leading-relaxed text-[#17324D] outline-none transition focus:border-[#16A0EB] focus:ring-2 focus:ring-sky-100"})]}):e.jsxs("div",{className:"mt-3 rounded-2xl border border-sky-100 bg-sky-50/70 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-[#066591]",children:s.status==="sent"?"Respuesta enviada":"Respuesta aprobada"}),e.jsx("p",{className:"mt-2 whitespace-pre-wrap text-[11px] font-bold leading-relaxed text-[#17324D]",children:C})]}),s.status==="failed"&&s.send_error_message&&e.jsxs("div",{className:"mt-3 rounded-2xl border border-red-100 bg-red-50 p-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-red-600",children:"Envío no confirmado"}),e.jsx("p",{className:"mt-1 text-[10px] font-bold leading-relaxed text-red-700",children:s.send_error_message}),e.jsx("p",{className:"mt-1 text-[9px] font-bold text-red-600",children:"No vuelvas a aprobarlo sin comprobar antes que el destinatario no lo recibió."})]}),(R||L||s.status==="sent")&&s.approved_at&&e.jsxs("p",{className:"mt-3 text-[9px] font-bold text-slate-400",children:["Aprobado ",$e(s.approved_at),s.approved_by_email?` por ${s.approved_by_email}`:"",s.status==="sent"&&s.sent_at?` · enviado ${$e(s.sent_at)}`:""]}),s.next_action&&e.jsxs("p",{className:"mt-3 text-[9px] font-black uppercase tracking-widest text-orange-600",children:["Siguiente paso: ",s.next_action.replace(/_/g," ")]}),h?e.jsxs("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>_({...s,reply_text:S[s.draft_id]??s.reply_text}),className:"rounded-xl bg-[#16A0EB] py-3 text-[9px] font-black uppercase tracking-widest text-white shadow-sm active:scale-95",children:q===s.draft_id?"Copiado":"Copiar borrador"}),e.jsx("button",{type:"button",onClick:()=>U(s.phone_e164),disabled:!s.phone_e164,className:"rounded-xl border border-sky-100 bg-white py-3 text-[9px] font-black uppercase tracking-widest text-[#066591] disabled:opacity-40",children:"Abrir WhatsApp"}),e.jsx("button",{type:"button",onClick:()=>F(s.draft_id),disabled:!B||N===s.draft_id||!(S[s.draft_id]||"").trim(),className:"col-span-2 rounded-xl bg-[#FC9A05] py-3 text-[9px] font-black uppercase tracking-widest text-white shadow-sm disabled:cursor-not-allowed disabled:opacity-40",children:"Revisar y aprobar respuesta"}),e.jsx("button",{type:"button",onClick:()=>Z(s,"handled"),disabled:N===s.draft_id,className:"rounded-xl bg-[#066591] py-3 text-[9px] font-black uppercase tracking-widest text-white disabled:opacity-50",children:"Ya respondido por otra vía"}),e.jsx("button",{type:"button",onClick:()=>Z(s,"discarded"),disabled:N===s.draft_id,className:"rounded-xl border border-orange-100 bg-orange-50 py-3 text-[9px] font-black uppercase tracking-widest text-orange-700 disabled:opacity-50",children:"Archivar"}),p===s.draft_id&&e.jsxs("div",{className:"col-span-2 rounded-2xl border-2 border-orange-300 bg-orange-50 p-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-orange-700",children:"Confirmación obligatoria"}),e.jsxs("p",{className:"mt-2 text-[11px] font-bold leading-relaxed text-slate-700",children:["Vas a autorizar una respuesta a ",e.jsx("strong",{children:Sa(s.phone_e164)})," desde el número Meta 958 59 94 50. Cuando el workflow de salida esté activo, no habrá otra confirmación."]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>F(""),disabled:N===s.draft_id,className:"rounded-xl border border-orange-200 bg-white py-3 text-[9px] font-black uppercase tracking-widest text-orange-700 disabled:opacity-50",children:"Volver a revisar"}),e.jsx("button",{type:"button",onClick:()=>W(s),disabled:N===s.draft_id,className:"rounded-xl bg-[#FC9A05] py-3 text-[9px] font-black uppercase tracking-widest text-white disabled:opacity-50",children:N===s.draft_id?"Aprobando...":"Sí, aprobar para enviar"})]})]})]}):R?e.jsx("button",{type:"button",onClick:()=>T(s),disabled:N===s.draft_id,className:"mt-4 w-full rounded-xl border border-orange-200 bg-orange-50 py-3 text-[9px] font-black uppercase tracking-widest text-orange-700 disabled:opacity-50",children:N===s.draft_id?"Retirando...":"Retirar aprobación antes del envío"}):L?e.jsx("div",{className:"mt-4 rounded-xl border border-sky-100 bg-sky-50 p-3 text-center text-[9px] font-black uppercase tracking-widest text-[#066591]",children:"Envío re
113clamado · esperando confirmación de Meta"}):e.jsxs("div",{className:"mt-4 space-y-2",children:[s.reviewed_at&&e.jsxs("p",{className:"text-[9px] font-bold text-slate-400",children:["Revisado ",$e(s.reviewed_at),s.reviewed_by_email?` por ${s.reviewed_by_email}`:""]}),(s.status==="handled"||s.status==="discarded")&&e.jsx("button",{type:"button",onClick:()=>Z(s,"reopen"),disabled:N===s.draft_id,className:"w-full rounded-xl border border-sky-100 bg-white py-3 text-[9px] font-black uppercase tracking-widest text-[#066591] disabled:opacity-50",children:"Volver a pendientes"})]})]},s.draft_id)})]})},ds=["Híbrido (Presencial y Online)","Solo Online (Nacional/Intl.)","Solo Presencial (Local)"],Ee=d=>{var v;const n=(v=(d||"").split("@")[0])==null?void 0:v.replace(/[._-]+/g," ").trim();return n?n.split(" ").filter(Boolean).map(b=>b.charAt(0).toUpperCase()+b.slice(1)).join(" "):"Coordinación Profe en Casa"},Ea=(d,n)=>({name:(n||"").trim()||Ee(d),phone:"",location:"",address_line:"",address_details:"",postal_code:"",province:"Granada",studies:"",specialty:"",subjects:"",work_modality:"Solo Presencial (Local)",availability_notes:"",winter_schedule:"",summer_schedule:"",weekly_availability:{},summer_availability:{},availability_state:"Disponible ahora",availability_update_notes:"",availability_last_confirmed_at:null,has_vehicle:!1,has_metro:!1,wants_academy:!1,dni:"",iban:""}),Cs=({onBack:d,adminView:n=!1,onOpenAdminCalendar:v,initialTab:b="leads"})=>{const[G,H]=i.useState(!0),[l,u]=i.useState(null),[N,D]=i.useState(!1),[q,Y]=i.useState({can_validate_classes:!1,can_use_bitacora:!1,can_view_team:!1,can_view_finances:!1,can_view_students:!1,can_assign_students:!1,can_manage_calendar:!1}),p={can_validate_classes:n||q.can_validate_classes,can_use_bitacora:n||q.can_use_bitacora,can_view_team:n||q.can_view_team,can_view_finances:n,can_view_students:n||q.can_view_students,can_assign_students:n||q.can_assign_students,can_manage_calendar:n||q.can_manage_calendar},[F,S]=i.useState(0),[x,E]=i.useState(0),[M,B]=i.useState(0),[k,V]=i.useState([]),[K,_]=i.useState({revenue:0,expenses:0,profit:0}),[U,W]=i.useState([]),[T,Z]=i.useState(null),[s,h]=i.useState(b),[R,L]=i.useState([]),[y,C]=i.useState([]),[I,J]=i.useState(0),[ee,ue]=i.useState([]),[re,ye]=i.useState(new Set),[ne,me]=i.useState("current"),[je,r]=i.useState({}),[g,$]=i.useState({}),[oe,ve]=i.useState(""),[be,we]=i.useState([]),[Ne,de]=i.useState(null),[t,m]=i.useState(null),[c,P]=i.useState(()=>Ea()),[z,Be]=i.useState(!1),[Pe,Ie]=i.useState(!1),[Ve,Ke]=i.useState(!1),[Ze,Je]=i.useState(!1),[La,ze]=i.useState(!1),[Xe,ea]=i.useState(!1),[ie,De]=i.useState({date:new Date().toISOString().split("T")[0],duration:1,description:""}),[Ra,Oe]=i.useState(!1),ge=gt,Me=a=>R.find(o=>ge(o.email)===ge(a)),aa=a=>(a==null?void 0:a.tutor_email)||(a==null?void 0:a.monitor_email)||"",qa=a=>a!=null&&a.name?g[pe(a.name)]||[]:[],Fa=a=>qa(a).map(Me).filter(Boolean),$a=a=>a&&je[a.student_id||a.name]||null,[ta,sa]=i.useState(!1),[te,ke]=i.useState({student_name:"",contact_date:new Date().toISOString().split("T")[0],topic:"Información General",notes:""}),ra=Qe.netHourly,Ba=Qe.companyCostHourly,he=["leads","proposal","messages","links"],_e=`${typeof window<"u"&&(window.location.origin.includes("localhost")||window.location.origin.includes("127.0.0.1"))?"https://app.profe-en-casa.com":typeof window<"u"?window.location.origin:"https://app.profe-en-casa.com"}/registrar-visita`,Ia=`https://api.qrserver.com/v1/create-qr-code/?size=220x220&data=${encodeURIComponent(_e)}`;p.can_validate_classes&&he.push("validations"),p.can_view_finances&&he.push("finances"),p.can_view_team&&he.push("team"),(p.can_view_students||p.can_assign_students)&&he.push("students"),p.can_manage_calendar&&he.push("globy","group_plans","labor_controls");const za=()=>"leads",Ce=(a,o,w)=>{const j=Ea(o,w),f=bt(a);P({...j,name:(a==null?void 0:a.name)||j.name,phone:(a==null?void 0:a.phone)||"",location:f.locality,address_line:f.address_line,address_details:f.address_details,postal_code:f.postal_code,province:f.province||j.province,studies:(a==null?void 0:a.studies)||"",specialty:(a==null?void 0:a.specialty)||"",subjects:(a==null?void 0:a.subjects)||"",work_modality:(a==null?void 0:a.work_modality)||j.work_modality,availability_notes:(a==null?void 0:a.availability_notes)||"",winter_schedule:(a==null?void 0:a.winter_schedule)||"",summer_schedule:(a==null?void 0:a.summer_schedule)||"",weekly_availability:ya(a==null?void 0:a.weekly_availability),summer_availability:ya(a==null?void 0:a.summer_availability),availability_state:(a==null?void 0:a.availability_state)||"Disponible ahora",availability_update_notes:(a==null?void 0:a.availability_update_notes)||"",availability_last_confirmed_at:(a==null?void 0:a.availability_last_confirmed_at)||null,has_vehicle:(a==null?void 0:a.has_vehicle)||!1,has_metro:(a==null?void 0:a.has_metro)||!1,wants_academy:(a==null?void 0:a.wants_academy)||!1,dni:(a==null?void 0:a.dni)||"",iban:(a==null?void 0:a.iban)||""})},Oa=(a,o,w)=>{P(j=>({...j,[a]:{...j[a],[o]:w}}))},na=a=>{a!=null&&a.email&&L(o=>[...o.some(f=>f.id&&a.id&&f.id===a.id||ge(f.email)===ge(a.email))?o.map(f=>f.id&&a.id&&f.id===a.id||ge(f.email)===ge(a.email)?{...f,...a}:f):[...o,a]].sort((f,O)=>(f.name||"").localeCompare(O.name||"","es")))},Ma=()=>{const a=c.weekly_availability||{},o=c.summer_availability||{};return{name:c.name.trim()||(l==null?void 0:l.name)||Ee(l==null?void 0:l.email),email:l==null?void 0:l.email,phone:c.phone||null,location:c.location||null,province:c.province||null,address_line:c.address_line||null,address_details:c.address_details||null,postal_code:c.postal_code||null,postal_address:ht({addressLine:c.address_line,addressDetail
113s:c.address_details,postalCode:c.postal_code,locality:c.location,province:c.province})||null,studies:c.studies||null,specialty:c.specialty||null,subjects:c.subjects||null,work_modality:c.work_modality||null,availability_notes:c.availability_notes||null,winter_schedule:ha(a,zt)||c.winter_schedule||"",summer_schedule:ha(o,It)||c.summer_schedule||"",weekly_availability:a,summer_availability:o,availability_state:c.availability_state||"Disponible ahora",availability_update_notes:c.availability_update_notes||null,availability_last_confirmed_at:new Date().toISOString(),has_vehicle:c.has_vehicle,has_metro:c.has_metro,wants_academy:c.wants_academy}},Ga=()=>({name:c.name.trim()||(l==null?void 0:l.name)||Ee(l==null?void 0:l.email),email:l==null?void 0:l.email,dni:c.dni||null,iban:c.iban||null}),oa=async a=>{const o={...a,name:a.name||(l==null?void 0:l.name)||Ee(l==null?void 0:l.email),email:l==null?void 0:l.email};return t!=null&&t.id?await A.from("teachers").update(o).eq("id",t.id).select("*").maybeSingle():await A.from("teachers").insert([{status:"Activo",...o}]).select("*").maybeSingle()},Ua=async()=>{const a=new Date;a.setDate(a.getDate()+I*7);const o=a.toISOString().split("T")[0],w=new Date(a);w.setDate(a.getDate()+6);const j=w.toISOString().split("T")[0],{data:f}=await A.from("classes").select("*").gte("class_date",o).lte("class_date",j).is("deleted_at",null).order("class_date",{ascending:!0}).order("start_time",{ascending:!0});f&&C(f)};i.useEffect(()=>{Ua()},[I]);const Te=async()=>{var o,w;H(!0);const{data:a}=await A.auth.getUser();if(a!=null&&a.user){const j=a.user.email,{data:f}=await A.from("teachers").select("*").ilike("email",j||"").limit(1).maybeSingle(),O=(f==null?void 0:f.name)||((o=a.user.user_metadata)==null?void 0:o.full_name)||((w=a.user.user_metadata)==null?void 0:w.name)||Ee(j),Q=n?a.user.id:(f==null?void 0:f.id)||a.user.id;u({id:Q,auth_id:a.user.id,email:j,name:O}),m(f||null),Ce(f,j,O);const Le=new Date,Re=new Date(Le.getFullYear(),Le.getMonth(),1).toISOString().split("T")[0],rt=new Date(Le.getFullYear(),Le.getMonth()+1,0).toISOString().split("T")[0],{data:ce}=await A.from("coordinator_permissions").select("*").eq("coordinator_id",Q).maybeSingle();ce&&Y({can_validate_classes:!!ce.can_validate_classes,can_use_bitacora:!!ce.can_use_bitacora,can_view_team:!!ce.can_view_team,can_view_finances:!!ce.can_view_finances,can_view_students:!!ce.can_view_students,can_assign_students:!!ce.can_assign_students,can_manage_calendar:!!ce.can_manage_calendar});const{data:Ge}=await A.from("leads").select("*").eq("status","Pendiente").order("created_at",{ascending:!1});Ge&&(we(Ge),Ge.length===0&&h("agenda"));const{data:Ue}=await A.from("office_hours").select("*").eq("coordinator_id",Q).gte("date",Re).order("created_at",{ascending:!1});let He=0;Ue&&(He=Ue.reduce((X,ae)=>X+Number(ae.duration),0),B(He),V(Ue));const{data:da}=await A.from("classes").select("duration, monitor_price, status").eq("monitor_email",j).gte("class_date",Re).is("deleted_at",null);if(da){let X=0,ae=0;da.forEach(le=>{(le.status==="Completada"||le.status==="Falta Injustificada")&&(X+=1,ae+=Number(le.monitor_price||0))}),S(X),E(ae)}if(n){const{data:X}=await A.from("classes").select("family_price, monitor_price, class_date, start_time, end_time, modality").in("status",["Completada","Falta Injustificada"]).gte("class_date",Re).lte("class_date",rt).is("deleted_at",null);if(X){const ae=X.reduce((We,xe)=>We+(Number(xe.family_price)||0),0),Ae=X.reduce((We,xe)=>{const dt=String(xe.class_date||"")>="2026-09-01"&&!String(xe.modality||"").toLowerCase().includes("online")?pt(xe.start_time,xe.end_time)*Qe.companyCostHourly:Number(xe.monitor_price)||0;return We+dt},0)+He*Ba;_({revenue:ae,expenses:Ae,profit:ae-Ae})}}const{data:ca}=await A.from("classes").select("*").gte("class_date",Re).is("deleted_at",null).order("class_date",{ascending:!1});if(ca){const X=ca.filter(ae=>(ae.status==="Completada"||ae.status==="Falta Injustificada")&&ae.validated!==!0);W(X)}const{data:pa}=await A.from("teachers").select("*").order("name",{ascending:!0});pa&&L(pa);const{data:qe}
113=await A.from("students").select("*").is("archived_at",null).order("name",{ascending:!0});qe?(ue(qe),r(ut(qe))):r({});const[nt,ot,it]=await Promise.all([A.from("classes").select("student_name, monitor_email, status").is("deleted_at",null),A.from("classes").select("student_name").gte("class_date",ga.startDate).lte("class_date",ga.endDate).is("deleted_at",null),A.from("academic_group_plans").select("id").eq("academic_year",Ta).in("status",["preparing","ready","scheduled"])]),lt=nt.data||[];$(xt(lt||[]));const ua=mt(ot.data||[]),xa=(it.data||[]).map(X=>String(X.id));if(xa.length>0){const{data:X}=await A.from("academic_group_plan_students").select("student_id").in("plan_id",xa),ae=new Map((qe||[]).map(le=>[String(le.student_id),pe(le.name)]));(X||[]).forEach(le=>{const Ae=ae.get(String(le.student_id));Ae&&ua.add(Ae)})}ye(ua)}H(!1)};i.useEffect(()=>{Te()},[]),i.useEffect(()=>{s==="finances"&&!p.can_view_finances&&h("agenda"),s==="team"&&!p.can_view_team&&h("agenda"),s==="students"&&!p.can_view_students&&!p.can_assign_students&&h("agenda"),s==="validations"&&!p.can_validate_classes&&h("agenda")},[s,q,n]),i.useEffect(()=>{n&&(he.includes(s)||h(za()))},[n,s,q]);const Ha=async(a,o)=>{if(!a)return;const w=o===""?null:o,j=Me(w),{error:f}=await A.from("students").update({tutor_email:w}).eq("student_id",a);f?alert("🚨 Error: "+f.message):(ue(O=>O.map(Q=>Q.student_id===a?{...Q,tutor_email:w}:Q)),alert(j?`✅ Tutoría guardada. ${j.name||"El tutor"} ya queda asignado como tutor académico.`:"✅ Tutoría borrada. El alumno vuelve a quedar sin tutor académico."))},Wa=async a=>{Z(a);const{error:o}=await A.from("classes").update({validated:!0}).eq("id",a).is("deleted_at",null);o?alert("Error al validar: "+o.message):W(w=>w.filter(j=>j.id!==a)),Z(null)},Qa=async a=>{const o=window.prompt(`Añadir nota de seguimiento para ${a.parent_name}:
114(Ej: Llamada de prueba, no contesta)`);if(!o||o.trim()==="")return;const j=`
115
116[${new Date().toLocaleString("es-ES",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"})} - Coord] ✍️ ${o.trim()}`,f=(a.notes||"")+j,{error:O}=await A.from("leads").update({notes:f}).eq("id",a.id);O?alert("Error al guardar la nota: "+O.message):Te()},Ya=async(a,o)=>{de(a);const w=new Date().toISOString();let j={status:o,assigned_to:l==null?void 0:l.email,last_contact_date:w};{const O=window.prompt(`¿Motivo por el que no ha cerrado?
117(Ej: Precio, Horario, Busca otra zona...)`);if(!O){de(null);return}j.lost_reason=O}const{error:f}=await A.from("leads").update(j).eq("id",a);f?alert("Error al actualizar lead: "+f.message):we(O=>O.filter(Q=>Q.id!==a)),de(null)},Va=async a=>{if(!(a!=null&&a.public_access_token)){alert("Este lead no tiene enlace seguro. Revísalo desde Radar Leads antes de continuar.");return}if(window.confirm(`La familia ha confirmado que quiere continuar.
118
119Se creará una ficha provisional para que ${a.student_name||"el alumno"} aparezca en Alumnos y Agenda. La familia podrá completar después sus datos mediante el enlace seguro.
120
121Esto no registra ningún cobro ni confirma todavía el horario.
122
123¿Quieres continuar?`)){de(a.id);try{const o=await Ct({lead:a,actor:"coordinator"}),w=window.location.origin.includes("127.0.0.1")||window.location.origin.includes("localhost")?"https://app.profe-en-casa.com":window.location.origin,j=At({baseUrl:w,leadId:a.id,leadToken:a.public_access_token}),f=Et(a.phone);if(f){const O=St({parentName:a.parent_name,studentName:o.studentName,activationUrl:j});window.open(`https://wa.me/${f}?text=${encodeURIComponent(O)}`,"_blank"),alert("Familia provisional creada. El alumno ya está disponible en Agenda y se ha preparado el WhatsApp para completar los datos.")}else alert(`Familia provisional creada y disponible en Agenda. Envía este enlace seguro para completar los datos:
124
125${j}`);await Te()}catch(o){alert(`No he podido crear la familia provisional: ${o.message}`)}finally{de(null)}}},Ka=async a=>{if(a.preventDefault(),!(l!=null&&l.id))return;ea(!0);const{error:o}=await A.from("office_hours").insert([{coordinator_id:l.id,date:ie.date,duration:ie.duration,description:ie.description}]);ea(!1),o?alert("Error al guardar: "+o.message):(alert("✅ Horas de oficina registradas."),ze(!1),De({date:new Date().toISOString().split("T")[0],duration:1,description:""}),Te())},Za=async a=>{if(a.preventDefault(),!(l!=null&&l.id))return;sa(!0);const{error:o}=await A.from("parent_logs").insert([{coordinator_id:l.id,student_name:te.student_name,contact_date:te.contact_date,topic:te.topic,notes:te.notes}]);sa(!1),o?alert("Error al guardar: "+o.message):(alert("✅ Registro guardado en la Bitácora."),Oe(!1),ke({student_name:"",contact_date:new Date().toISOString().split("T")[0],topic:"Información General",notes:""}))},ia=async()=>{const{error:a}=await A.auth.signOut();a?alert("Error al cerrar sesión: "+a.message):d()},Ja=()=>{Ce(t,l==null?void 0:l.email,l==null?void 0:l.name),Be(!1)},Xa=()=>{Ce(t,l==null?void 0:l.email,l==null?void 0:l.name),Ie(!1)},et=async a=>{if(a.preventDefault(),!(l!=null&&l.email))return;Ke(!0);const{data:o,error:w}=await oa(Ma());if(Ke(!1),w){alert("Error al guardar tu ficha docente: "+w.message);return}o&&(m(o),Ce(o,l==null?void 0:l.email,o.name||(l==null?void 0:l.name)),na(o),u(j=>j&&{...j,name:o.name||j.name})),Be(!1),alert("✅ Tu ficha docente ya está guardada. Desde ahora podrás salir como tutor académico en Alumnos.")},at=async a=>{if(a.preventDefault(),!(l!=null&&l.email))return;Je(!0);const{data:o,error:w}=await oa(Ga());if(Je(!1),w){alert("Error al guardar DNI e IBAN: "+w.message);return}o&&(m(o),Ce(o,l==null?void 0:l.email,o.name||(l==null?void 0:l.name)),na(o),u(j=>j&&{...j,name:o.name||j.name})),Ie(!1),alert("✅ DNI/NIE e IBAN guardados en tu ficha.")},tt=()=>{window.open(_e,"_blank","noopener,noreferrer")},st=async()=>{try{await navigator.clipboard.writeText(_e),D(!0),window.setTimeout(()=>D(!1),1800)}
125catch{window.prompt("Copia este enlace interno:",_e)}},la=R.filter(a=>a.status!=="Inactivo"&&!a.access_paused);return e.jsxs("div",{className:"max-w-md mx-auto w-full min-h-screen bg-[#F5F7FA] p-6 text-left pb-24 overflow-y-auto font-sans relative animate-in fade-in duration-300",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsxs("button",{onClick:d,className:"text-gray-400 text-[10px] font-black uppercase hover:text-[#1c74e9] transition-colors",children:["← ",n?"Volver a Dirección":"Volver"]}),n?e.jsxs("div",{className:"bg-red-50 px-3 py-1 rounded-full border border-red-100 flex items-center gap-2 cursor-pointer",children:[e.jsx("span",{className:"text-xs",children:"🚨"}),e.jsx("span",{className:"text-red-600 text-[9px] font-black uppercase",children:"Dirección"})]}):e.jsx("button",{onClick:ia,className:"bg-gray-900 text-white px-3 py-2 rounded-full text-[9px] font-black uppercase tracking-widest hover:bg-gray-800 transition-colors",children:"Salir"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-black italic text-gray-900 leading-none",children:"Coordinación"}),e.jsx("p",{className:"text-[#1c74e9] text-[10px] font-black uppercase tracking-widest mt-2 bg-blue-50 inline-block px-3 py-1 rounded-full border border-blue-100",children:"Gestión de Centro"}),n&&e.jsxs("div",{className:"mt-3 bg-white border border-gray-100 rounded-2xl p-4 shadow-sm space-y-3",children:[e.jsx("p",{className:"text-[10px] text-gray-600 font-bold leading-relaxed",children:"Tu cuenta reúne Dirección, gerencia y coordinación completa. Puedes realizar toda la gestión del centro sin necesitar una ficha profesional de profesor ni mezclar sueldo, fichajes o disponibilidad docente personal."}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-gray-50 text-gray-500 border border-gray-100 px-2 py-1 rounded-lg",children:"Dirección y gerencia"}),e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-gray-50 text-gray-500 border border-gray-100 px-2 py-1 rounded-lg",children:"Coordinación completa"}),e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-gray-50 text-gray-500 border border-gray-100 px-2 py-1 rounded-lg",children:"Sin ficha docente"}),e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-blue-50 text-[#1c74e9] border border-blue-100 px-2 py-1 rounded-lg",children:"Acceso total"})]})]})]}),G?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 border-[#1c74e9] border-t-transparent rounded-full animate-spin"})}):e.jsxs(e.Fragment,{children:[!n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 p-6 rounded-[32px] text-white shadow-xl mb-6 relative overflow-hidden border border-white/10",children:[e.jsxs("div",{className:"flex justify-between items-start mb-6 relative z-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-400 text-[10px] font-black uppercase tracking-widest mb-1",children:"Prevision liquida (mes actual)"}),e.jsxs("h2",{className:"text-4xl font-black italic tracking-tight",children:[(x+M*ra).toFixed(2),"€"]})]}),e.jsx("div",{className:"w-10 h-10 bg-white/10 rounded-xl flex items-center justify-center text-xl shadow-inner border border-white/20",children:"💼"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 relative z-10",children:[e.jsxs("div",{className:"bg-white/5 p-3 rounded-2xl border border-white/10",children:[e.jsx("p",{className:"text-gray-400 text-[8px] uppercase font-black mb-1",children:"Sesiones"}),e.jsx("p",{className:"text-lg font-black",children:F}),e.jsxs("p",{className:"text-[9px] text-green-400 font-bold mt-1",children:["+",x.toFixed(2),"€"]})]}),e.jsxs("div",{className:"bg-white/5 p-3 rounded-2xl border border-white/10",children:[e.jsx("p",{className:"text-gray-400 text-[8px] uppercase font-black mb-1",children:"Coordinacion"}),e.jsxs("p",{className:"text-lg font-black",children:[M.toFixed(1),"h"]}),e.jsxs("p",{className:"text-[9px] text-green-400 font-bold mt-1",children:["+",(M*ra).toFixed(2),"€"]})]})]}),e.jsxs("p",{className:"mt-3 text-[8px] font-bold leading-relaxed text-gray-400 relative z-10",children:["Referencia: ",ct.netHourly.toFixed(2)," EUR liquidos por hora. La nomina definitiva la emite el programa de nominas y puede variar."]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 mb-6",children:e.jsxs("button",{onClick:()=>ze(!0),className:"bg-[#1c74e9] hover:bg-blue-600 text-white p-4 rounded-3xl shadow-lg shadow-blue-500/20 flex flex-col items-start gap-3 transition-all active:scale-95 group border border-blue-400",children:[e.jsx("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center text-xl group-hover:scale-110 transition-transform shadow-inner",children:"⏱️"}),e.jsx("div",{className:"text-left",children:e.jsx("span",{className:"block font-black text-[10px] uppercase tracking-tight",children:"Fichar Oficina"})})]})})]}),e.jsxs("div",{className:"bg-white p-3 rounded-[32px] border border-gray-100 shadow-sm relative",children:[e.jsxs("div",{className:"mb-3 space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-[0.25em] text-gray-400 text-center",children:"Módulos de Coordinación"}),n&&e.jsx("p",{className:"text-center text-[8px] font-bold text-gray-400 mt-2 leading-relaxed",children:"Dirección tiene acceso completo. Los interruptores de Permisos se aplican solo a las cuentas del equipo."}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 mt-2",children:[e.jsxs("button",{onClick:()=>h("leads"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all relative ${s==="leads"?"bg-orange-500 text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:["Atención 📞",e.jsx("span",{className:`ml-1 inline-flex items-center rounded-full px-1.5 py-0.5 text-[7px] font-black uppercase tracking-widest ${s==="leads"?"bg-white/20 text-white":"bg-orange-50 text-orange-500 border border-orange-100"}`,children:"base"}),be.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-500 text-white text-[7px] w-4 h-4 flex items-center justify-center rounded-full animate-bounce",children:be.length})]}),e.jsx("button",{onClick:()=>h("proposal"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="proposal"?"bg-[#16A0EB] text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Propuesta domicilio"}),e.jsx("button",{onClick:()=>h("messages"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="messages"?"bg-[#16A0EB] text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Mensajes WhatsApp"}),e.jsx("button",{onClick:()=>h("links"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="links"?"bg-[#066591] text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Enlaces"}),p.can_manage_calendar&&e.jsx("button",{onClick:()=>h("globy"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="globy"?"bg-[#066591] text-white shadow-md":"text-[#066591] bg-sky-50 border border-sky-100 hover:bg-sky-100"}`,children:"Bandeja Globy"}),p.can_manage_calendar&&e.jsx("button",{onClick:()=>h("group_plans"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="group_plans"?"bg-[#066591] text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Plan de grupos"}),p.can_manage_calendar&&e.jsx("button",{onClick:()=>h("labor_controls"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="labor_controls"?"bg-[#FC9A05] text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Alta y horas"}),p.can_use_bitacora&&e.jsx("button",{onClick:()=>Oe(!0),className:"px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100",children:"Bitácora 📓"}),p.can_validate_classes&&e.jsxs("button",{onClick:()=>h("validations"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all relative ${s==="validations"?"bg-amber-500 text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:["Validar ✔️",U.length>0&&e.jsx("span",{className:"absolute -top-1 -right-1 bg-red-500 text-white text-[7px] w-4 h-4 flex items-center justify-center rounded-full animate-bounce",children:U.length})]}),p.can_view_finances&&e.jsx("button",{onClick:()=>h("finances"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="finances"?"bg-green-600 text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Finanzas 📈"}),p.can_view_team&&e.jsx("button",{onClick:()=>h("team"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="team"?"bg-[#1c74e9] text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Equipo"}),(p.can_view_students||p.can_assign_students)&&e.jsx("button",{onClick:()=>h("students"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="students"?"bg-purple-600 text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Alumnos 📚"}),p.can_manage_calendar&&v&&e.jsx("button",{onClick:v,className:"px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100",children:"Agenda Centro 📅"})]})]}),!n&&e.jsxs("div",{className:"border-t border-gray-100 pt-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-[0.25em] text-gray-400 text-center",children:"Zona Personal"}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2 mt-2",children:[e.jsx("button",{onClick:()=>h("agenda"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="agenda"?"bg-gray-800 text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Mi Agenda"}),e.jsx("button",{onClick:()=>h("profile"),className:`px-3 py-2 rounded-xl text-[9px] font-black uppercase transition-all ${s==="profile"?"bg-slate-700 text-white shadow-md":"text-gray-500 bg-gray-50 border border-gray-100 hover:bg-gray-100"}`,children:"Mi Perfil"})]})]})]}),e.jsxs("div",{className:"p-1 min-h-[200px]",children:[s==="proposal"&&e.jsx(Gt,{coordinatorName:l==null?void 0:l.name,onOpenLeads:()=>h("leads")}),s==="links"&&e.jsx(ts,{}),s==="messages"&&e.jsx(ns,{}),s==="globy"&&p.can_manage_calendar&&e.jsx(ls,{}),s==="group_plans"&&p.can_manage_calendar&&e.jsx(Vt,{onOpenLaborControls:()=>h("labor_controls")}),s==="labor_controls"&&p.can_manage_calendar&&e.jsx(Xt,{canAuthorize:n}),s==="leads"&&e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"bg-violet-50 border border-violet-100 rounded-[24px] p-4 shadow-sm",children:[e.jsx("p",{className:"text-violet-700 text-[9px] font-black uppercase tracking-widest",children:"Registro rápido en academia"}),e.jsx("h3",{className:"text-gray-900 font-black text-base mt-2",children:"Familia interesada"}),e.jsx("p",{className:"text-violet-900/80 text-[11px] font-bold leading-relaxed mt-2",children:"Úsalo cuando una familia entra en la academia a pedir información y queréis de
125jar sus datos guardados en menos de un minuto."}),e.jsx("p",{className:"text-violet-700 text-[10px] font-bold leading-relaxed mt-2",children:"El admin puede activar este uso a cualquier profesor desde su ficha. Desde aquí también tienes el enlace y el QR interno para abrirlo al instante."}),e.jsxs("div",{className:"mt-4 grid grid-cols-[96px_1fr] gap-4 items-center",children:[e.jsx("div",{className:"bg-white border border-violet-100 rounded-2xl p-2 shadow-sm",children:e.jsx("img",{src:Ia,alt:"QR registro rápido academia",className:"w-full h-auto rounded-xl"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-white border border-violet-100 rounded-2xl px-3 py-3",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-violet-700 mb-1",children:"Enlace interno"}),e.jsx("p",{className:"text-[10px] font-bold text-gray-700 break-all leading-relaxed",children:_e})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:tt,className:"px-4 py-3 rounded-xl bg-violet-500 text-white text-[10px] font-black uppercase tracking-widest shadow-lg shadow-violet-500/20",children:"Abrir registro"}),e.jsx("button",{onClick:st,className:"px-4 py-3 rounded-xl bg-white border border-violet-100 text-violet-700 text-[10px] font-black uppercase tracking-widest",children:N?"Copiado":"Copiar enlace"})]})]})]})]}),e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("h3",{className:"text-gray-900 font-black text-sm",children:"Bandeja de Entrada"}),e.jsx("span",{className:"text-[9px] font-bold text-gray-400 uppercase",children:"Derivados por Jefatura"})]}),be.length===0?e.jsxs("div",{className:"text-center py-10 bg-gray-50 rounded-2xl border border-gray-100",children:[e.jsx("span",{className:"text-4xl block mb-2 opacity-50",children:"☕"}),e.jsx("p",{className:"text-gray-500 text-[10px] uppercase font-bold",children:"Sin contactos pendientes"})]}):be.map(a=>{var o;return e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border shadow-sm relative transition-all border-l-4 border-l-blue-500 mb-4",children:[e.jsx("div",{className:"absolute top-0 right-0 px-3 py-1.5 rounded-bl-xl text-[8px] font-black uppercase border-b border-l bg-blue-100 text-blue-600 border-blue-200",children:a.status}),e.jsxs("div",{className:"mb-4 pr-20",children:[e.jsxs("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest mb-1",children:[new Date(a.created_at).toLocaleDateString("es-ES",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})," • ",a.origin]}),e.jsx("h3",{className:"font-black text-gray-900 text-lg leading-tight",children:a.parent_name}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[a.subject_needed&&e.jsxs("span",{className:"text-[#1c74e9] bg-blue-50 border border-blue-100 text-[9px] font-black px-2 py-1 rounded-lg",children:["📚 ",a.subject_needed]}),a.modality&&e.jsxs("span",{className:"text-purple-600 bg-purple-50 border border-purple-100 text-[9px] font-black px-2 py-1 rounded-lg",children:["⚡ ",a.modality]})]}),e.jsxs("div",{className:"mt-3 space-y-1 border-t border-gray-50 pt-3 text-[10px] text-gray-600 font-bold",children:[a.locality&&e.jsxs("p",{children:["📍 ",a.locality," ",a.province?`(${a.province})`:""]}),a.email&&e.jsxs("p",{children:["✉️ ",a.email]}),a.phone&&e.jsxs("p",{children:["📞 ",a.phone]})]})]}),a.notes&&e.jsxs("div",{className:"bg-gray-50 p-3 rounded-xl border border-gray-100 mb-4 text-xs font-medium text-gray-700 whitespace-pre-wrap italic",children:['"',a.notes,'"']}),e.jsx("div",{className:"flex flex-col gap-2 mb-4",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("a",{href:`https://wa.me/${(o=a.phone)==null?void 0:o.replace(/\D/g,"")}`,target:"_blank",rel:"noreferrer",className:"flex-[2] bg-[#25D366] text-white flex items-center justify-center gap-1.5 font-black uppercase text-[10px] py-3 rounded-xl shadow-sm hover:scale-[1.02] transition-transform",children:[e.jsx("span",{children:"💬"})," WhatsApp"]}),e.jsxs("button",{onClick:()=>Qa(a),className:"flex-[3] bg-blue-50 text-[#1c74e9] border border-blue-200 flex items-center justify-center gap-1.5 font-black uppercase text-[10px] py-3 rounded-xl shadow-sm hover:bg-blue-100 transition-colors",children:[e.jsx("span",{children:"📝"})," Añadir Nota"]})]})}),e.jsxs("div",{className:"flex gap-1 border-t border-gray-100 pt-3",children:[e.jsx("button",{onClick:()=>Va(a),disabled:Ne===a.id,className:"flex-1 bg-green-50 text-green-600 border border-green-100 text-[9px] font-black uppercase py-2 rounded-lg shadow-sm hover:bg-green-100 transition-colors",children:Ne===a.id?"Creando...":"Confirmar familia y Agenda"}),e.jsx("button",{onClick:()=>Ya(a.id,"No Cierra"),disabled:Ne===a.id,className:"flex-1 bg-red-50 text-red-600 border border-red-100 text-[9px] font-black uppercase py-2 rounded-lg hover:bg-red-100 transition-colors",children:"❌ No Cierra"})]})]},a.id)})]}),s==="validations"&&p.can_validate_classes&&e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("h3",{className:"text-gray-900 font-black text-sm",children:"Validaciones Pendientes"}),e.jsxs("span",{className:"bg-orange-100 text-orange-600 text-[9px] font-black px-2 py-1 rounded-lg uppercase border border-orange-200",children:[U.length," Pendientes"]})]}),U.length===0?e.jsxs("div",{className:"text-center py-10 bg-gray-50 rounded-2xl border border-gray-100",children:[e.jsx("span",{className:"text-4xl block mb-2 opacity-50",children:"🏆"}),e.jsx("p",{className:"text-gray-500 text-[10px] uppercase font-bold",children:"Todo validado"})]}):e.jsx("div",{className:"space-y-2 max-h-48 overflow-y-auto pr-1 scrollbar-hide",children:U.map(a=>{var o;return e.jsxs("div",{className:"bg-white p-3 rounded-2xl flex justify-between items-center shadow-sm border border-orange-50",children:[e.jsxs("div",{className:"min-w-0 pr-2",children:[e.jsx("p",{className:"text-[11px] font-black text-gray-900 truncate",children:a.student_name||"Sin alumno"}),e.jsxs("p",{className:"text-[9px] font-bold text-gray-400 uppercase mt-1",children:[(o=a.class_date)==null?void 0:o.split("-").reverse().join("/")," • ",a.status==="Falta Injustificada"?"F. INJUSTIFICADA":"COMPLETADA"]})]}),e.jsx("button",{onClick:()=>Wa(a.id),disabled:T===a.id,className:"bg-green-500 hover:bg-green-600 text-white w-8 h-8 rounded-xl flex items-center justify-center text-xs transition-all active:scale-90 shrink-0 shadow-md shadow-green-500/20",children:T===a.id?e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
125ded-full animate-spin"}):"✔️"})]},a.id)})})]}),s==="finances"&&p.can_view_finances&&e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("p",{className:"text-gray-400 text-[10px] font-black uppercase tracking-widest mb-1",children:"Balance General"}),e.jsx("p",{className:"text-xs font-bold text-gray-900 uppercase",children:new Date().toLocaleString("es-ES",{month:"long",year:"numeric"})})]}),e.jsxs("div",{className:"bg-blue-50 p-4 rounded-2xl border border-blue-100 flex justify-between items-center shadow-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-blue-500 text-[9px] font-black uppercase tracking-widest",children:"Ingresos Familias"}),e.jsxs("p",{className:"text-blue-900 font-black text-xl",children:[K.revenue.toFixed(2),"€"]})]}),e.jsx("div",{className:"w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center text-xs",children:"📈"})]}),e.jsxs("div",{className:"bg-red-50 p-4 rounded-2xl border border-red-100 flex justify-between items-center shadow-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-red-500 text-[9px] font-black uppercase tracking-widest",children:"Coste laboral total"}),e.jsxs("p",{className:"text-red-900 font-black text-xl",children:["-",K.expenses.toFixed(2),"€"]})]}),e.jsx("div",{className:"w-8 h-8 bg-red-100 rounded-full flex items-center justify-center text-xs",children:"📉"})]}),e.jsxs("div",{className:"bg-gray-900 p-5 rounded-[24px] border border-gray-800 flex justify-between items-center shadow-lg mt-2 relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-[-20px] right-[-10px] text-6xl opacity-10",children:"💎"}),e.jsxs("div",{className:"relative z-10",children:[e.jsx("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest",children:"Margen directo estimado"}),e.jsxs("p",{className:"text-white font-black text-3xl tracking-tight",children:[K.profit.toFixed(2),"€"]})]})]})]}),s==="team"&&p.can_view_team&&e.jsx("div",{className:"grid grid-cols-1 gap-2 animate-in fade-in",children:la.length===0?e.jsx("p",{className:"text-center text-gray-400 text-[10px] py-10 uppercase font-bold",children:"No hay equipo operativo disponible"}):la.map(a=>e.jsxs("div",{className:"bg-gray-50 p-3 rounded-2xl flex items-center gap-3 border border-gray-100 hover:border-blue-200 transition-colors",children:[e.jsx("div",{className:"w-8 h-8 bg-blue-100 text-blue-600 rounded-full flex items-center justify-center text-xs border border-blue-200",children:"👨‍🏫"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[11px] font-black text-gray-900 truncate",children:a.name||"Profesor"}),e.jsx("p",{className:"text-[8px] font-bold text-gray-400 uppercase truncate",children:a.email}),a.availability_state==="Solo sustituciones"&&e.jsx("p",{className:"mt-1 text-[8px] font-black uppercase tracking-widest text-[#D86C00]",children:"Solo sustituciones"})]}),a.phone&&e.jsx("a",{href:`https://wa.me/${a.phone.replace(/\D/g,"")}`,target:"_blank",rel:"noreferrer",className:"bg-[#25D366] w-8 h-8 rounded-xl flex items-center justify-center text-white text-sm hover:scale-105 transition-transform shadow-sm",children:"💬"})]},a.id))}),s==="students"&&(p.can_view_students||p.can_assign_students)&&e.jsxs("div",{className:"flex flex-col space-y-3 animate-in fade-in",children:[e.jsxs("div",{className:"rounded-2xl border border-sky-100 bg-sky-50 p-3",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-[#066591]",children:"Alumnado del curso 2026/27"}),e.jsx("p",{className:"mt-1 text-[10px] font-bold leading-relaxed text-sky-900",children:"Activos incluye a quienes ya estan en un grupo preparado o tienen clases este curso. El resto se conserva para poder reactivarlo."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 rounded-2xl bg-gray-100 p-1.5",children:[e.jsxs("button",{type:"button",onClick:()=>me("current"),className:`rounded-xl px-3 py-3 text-[9px] font-black uppercase tracking-wider ${ne==="current"?"bg-[#066591] text-white shadow-sm":"bg-white text-gray-500"}`,children:["Activos 26/27 (",ee.filter(a=>re.has(pe(a.name))).length,")"]}),e.jsxs("button",{type:"button",onClick:()=>me("pending"),className:`rounded-xl px-3 py-3 text-[9px] font-black uppercase tracking-wider ${ne==="pending"?"bg-[#FC9A05] text-white shadow-sm":"bg-white text-gray-500"}`,children:["Por confirmar (",ee.filter(a=>!re.has(pe(a.name))).length,")"]})]}
125),e.jsx("input",{type:"text",placeholder:"🔍 Buscar alumno por nombre...",className:"w-full bg-gray-50 p-3 rounded-xl border border-gray-200 text-xs font-bold outline-none focus:border-[#1c74e9] transition-colors",value:oe,onChange:a=>ve(a.target.value)}),e.jsx("div",{className:"grid grid-cols-1 gap-2 max-h-[300px] overflow-y-auto pr-1 scrollbar-hide",children:ee.filter(a=>ne==="current"?re.has(pe(a.name)):!re.has(pe(a.name))).filter(a=>(a.name||"").toLowerCase().includes(oe.toLowerCase())).length===0?e.jsx("p",{className:"text-center text-gray-400 text-[10px] py-10 uppercase font-bold",children:"No se encontraron alumnos"}):ee.filter(a=>ne==="current"?re.has(pe(a.name)):!re.has(pe(a.name))).filter(a=>(a.name||"").toLowerCase().includes(oe.toLowerCase())).map(a=>{var O;const o=Me(aa(a)),j=Fa(a).map(Q=>Q.name||Q.email),f=$a(a);return e.jsxs("div",{className:"bg-gray-50 p-3 rounded-2xl border border-gray-100 flex flex-col gap-2 relative hover:border-purple-200 transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"flex-1 min-w-0 pr-2",children:[e.jsx("p",{className:"text-[11px] font-black text-gray-900 truncate",children:a.name}),e.jsx("p",{className:`mt-1 inline-flex rounded-full px-2 py-1 text-[7px] font-black uppercase ${ne==="current"?"bg-sky-100 text-[#066591]":"bg-orange-100 text-orange-700"}`,children:ne==="current"?"En plan 26/27":"Pendiente de confirmar"}),e.jsxs("p",{className:"text-[8px] font-bold text-gray-400 uppercase mt-0.5",children:[a.level||"Sin curso"," ",a.subject?`• ${a.subject}`:""]}),o&&e.jsxs("p",{className:"text-[8px] font-black uppercase text-amber-700 mt-1",children:["Tutoría: ",o.name||o.email]}),j.length>0&&e.jsxs("p",{className:"text-[8px] font-black uppercase text-blue-600 mt-1",children:["Agenda: ",j.join(", ")]}),((O=f==null?void 0:f.siblingNames)==null?void 0:O.length)>0&&e.jsxs("p",{className:"text-[8px] font-black uppercase text-purple-600 mt-1",children:["Posible hermano: ",f.siblingNames.join(", ")]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:a.phone&&e.jsx("a",{href:`https://wa.me/${a.phone.replace(/\D/g,"")}`,target:"_blank",rel:"noreferrer",className:"bg-[#25D366] text-white w-7 h-7 rounded-lg flex items-center justify-center text-xs shadow-sm active:scale-95 transition-transform shrink-0",children:"💬"})})]}),p.can_assign_students?e.jsxs("div",{className:"pt-2 border-t border-gray-200 mt-1",children:[e.jsx("p",{className:"text-[8px] font-black uppercase text-gray-400 mb-2",children:"Tutor académico"}),e.jsxs("select",{className:"w-full bg-white p-2 rounded-lg text-[10px] font-black text-gray-700 outline-none focus:border-[#1c74e9] border border-gray-200 shadow-sm transition-all",value:aa(a),onChange:Q=>Ha(a.student_id,Q.target.value),children:[e.jsx("option",{value:"",children:"(Sin tutor asignado)"}),R.map(Q=>e.jsx("option",{value:Q.email,children:Q.name||"Tutor"},Q.id))]}),e.jsx("p",{className:"text-[8px] text-gray-500 font-bold mt-2 leading-relaxed",children:"La tutoría académica acompaña al alumno. El profesor real de cada grupo o clase se decide y se ve desde Agenda Centro."})]}):e.jsxs("div",{className:"pt-2 border-t border-gray-200 flex items-center gap-1.5 mt-1",children:[e.jsx("span",{className:"text-[10px]",children:"👨‍🏫"}),e.jsxs("p",{className:"text-[8px] font-black text-gray-500 uppercase truncate",children:["Tutoría: ",o?`${o.name}`:"Sin asignar"]})]})]},a.student_id)})})]}),s==="agenda"&&e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4 bg-gray-50 p-2 rounded-2xl border border-gray-100 shadow-sm",children:[e.jsx("button",{onClick:()=>J(a=>a-1),className:"px-4 py-2 bg-white text-gray-600 rounded-xl font-black text-[10px] uppercase hover:bg-gray-100 transition-colors shadow-sm border border-gray-200 active:scale-95",children:"‹ Ant"}),e.jsx("span",{className:"text-[9px] font-black text-[#1c74e9] uppercase tracking-widest bg-blue-50 px-3 py-1.5 rounded-lg border border-blue-100",children:I===0?"Esta Semana":I===1?"Próxima Semana":I===-1?"Semana Pasada":`Semana ${I>0?"+":""}${I}`}),e.jsx("button",{onClick:()=>J(a=>a+1),className:"px-4 py-2 bg-white text-gray-600 rounded-xl font-black text-[10px] uppercase hover:bg-gray-100 transition-colors shadow-sm border border-gray-200 active:scale-95",children:"Sig ›"})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto pr-1 space-y-4",children:y.length===0?e.jsxs("div",{className:"text-center py-10",children:[e.jsx("span",{className:"text-4xl block mb-2",children:"🏖️"}),e.jsx("p",{className:"text-gray-400 text-[10px] uppercase font-bold",children:"Agenda despejada"})]}):Object.entries(y.reduce((a,o)=>(a[o.class_date]||(a[o.class_date]=[]),a[o.class_date].push(o),a),{})).map(([a,o])=>e.jsxs("div",{className:"mb-4 last:mb-0",children:[e.jsx("div",{className:"bg-orange-50/80 border border-orange-100 px-3 py-1.5 rounded-lg mb-2 inline-block",children:e.jsx("p",{className:"text-orange-600 text-[10px] font-black uppercase tracking-widest",children:new Date(a).toLocaleDateString("es-ES",{weekday:"long",day:"2-digit",month:"short"})})}),e.jsx("div",{className:"divide-y divide-gray-50 bg-white rounded-2xl border border-gray-100 px-3 shadow-sm",children:o.map(w=>{var f;const j=R.find(O=>O.email===w.monitor_email);return e.jsxs("div",{className:"py-3 flex justify-between items-center",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[10px] font-black bg-gray-50 text-gray-600 border border-gray-100 p-1.5 rounded-lg",children:w.start_time?w.start_time.slice(0,5):"N/A"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-black text-gray-900",children:w.student_name||"Alumno sin nombre"}),e.jsxs("p",{className:"text-[8px] font-bold text-gray-400 uppercase mt-0.5",children:[((f=w.modality)==null?void 0:f.split(" ")[0])||"PRESENCIAL"," ",e.jsx("span",{className:"text-gray-300 mx-1",children:"•"})," ",e.jsxs("span",{className:"text-[#1c74e9]",children:["👨‍🏫 ",j?j.name:"Profe"]})]})]})]}),e.jsx("span",{className:`text-[7px] font-black px-2 py-1 rounded-md uppercase tracking-widest ${w.status==="Completada"?"bg-green-50 text-green-600 border border-green-100":w.status==="Falta Injustificada"?"bg-red-50 text-red-600 border border-red-100":"bg-orange-50 text-orange-600 border border-orange-100"}`,children:w.status==="Falta Injustificada"?"F. INJ.":w.status||"Pend."})]},w.id)})})]},a))})]}),s==="profile"&&n&&e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#1c74e9]",children:"Mi ficha tutor"}),e.jsx("h3",{className:"font-black text-gray-900 text-base mt-1 truncate",children:c.name||(l==null?void 0:l.name)||"Tu ficha docente"}),e.jsx("p",{className:"text-[10px] font-bold text-gray-400 mt-1 break-all",children:l==null?void 0:l.email})]}),e.jsx("span",{className:`text-[8px] font-black uppercase tracking-widest px-2 py-1 rounded-lg border ${t?"bg-green-50 text-green-700 border-green-100":"bg-amber-50 text-amber-700 border-amber-100"}`,children:t?"Activa":"Pendiente"})]}),e.jsx("p",{className:"text-[10px] text-gray-500 font-bold leading-relaxed mt-3",children:"Desde aquí puedes quedar como tutor académico y profe puntual de informática o domicilio, con tus huecos reales del curso y del verano."}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-3",children:[e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-blue-50 text-[#1c74e9] border border-blue-100 px-2 py-1 rounded-lg",children:"Tutor académico"}),e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-violet-50 text-violet-600 border border-violet-100 px-2 py-1 rounded-lg",children:"Profesor puntual"}),c.wants_academy&&e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-indigo-50 text-indigo-600 border border-indigo-100 px-2 py-1 rounded-lg",children:"Academia"})]})]}),e.jsxs("form",{onSubmit:et,className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#1c74e9]",children:"Perfil profesional"}),e.jsx("p",{className:"text-[10px] text-gray-400 font-bold mt-1",children:"Este bloque te conecta como tutor y profe puntual sin tocar tus permisos de admin."})]}),z?e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-amber-50 text-amber-700 border border-amber-100 px-2 py-1 rounded-lg",children:"Editando"}):e.jsx("button",{type:"button",onClick:()=>Be(!0),className:"px-4 py-2 rounded-xl bg-blue-50 text-[#1c74e9] border border-blue-100 text-[9px] font-black uppercase tracking-widest",children:"Editar"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Nombre"}),e.jsx("input",{type:"text",value:c.name,onChange:a=>P(o=>({...o,name:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: Francisco Torralba"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Teléfono (WhatsApp)"}),e.jsx("input",{type:"text",value:c.phone,onChange:a=>P(o=>({...o,phone:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"+34..."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Modalidad de trabajo"}),e.jsx("select",{value:c.work_modality,onChange:a=>P(o=>({...o,work_modality:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",children:ds.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Estudios / perfil"}),e.jsx("input",{type:"text",value:c.studies,onChange:a=>P(o=>({...o,studies:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: Informática, coordinación, tutoría"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Especialidad"}),e.jsx("input",{type:"text",value:c.specialty,onChange:a=>P(o=>({...o,specialty:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: Tutoría académica e informática"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Asignaturas / foco"}),e.jsx("input",{type:"text",value:c.subjects,onChange:a=>P(o=>({...o,subjects:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: Informática, apoyo académico"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Dirección base"}),e.jsx("input",{type:"text",value:c.address_line,onChange:a=>P(o=>({...o,address_line:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: Calle..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Detalles dirección"}),e.jsx("input",{type:"text",value:c.address_details,onChange:a=>P(o=>({...o,address_details:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Portal, piso, referencia..."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Código postal"}),e.jsx("input",{type:"text",value:c.postal_code,onChange:a=>P(o=>({...o,postal_code:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Localidad"}),e.jsx("input",{type:"text",value:c.location,onChange:a=>P(o=>({...o,location:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Provincia"}),e.jsx("input",{type:"text",value:c.province,onChange:a=>P(o=>({...o,province:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"Nota general"}),e.jsx("textarea",{value:c.availability_notes,onChange:a=>P(o=>({...o,availability_notes:a.target.value})),disabled:!z,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400 resize-none h-20",placeholder:"Ej: Tutoría académica y clases puntuales de informática a domicilio."})]}),e.jsx(Pt,{weeklyAvailability:c.weekly_availability,summerAvailability:c.summer_availability,availabilityState:c.availability_state,availabilityNotes:c.availability_update_notes,availabilityLastConfirmedAt:c.availability_last_confirmed_at,disabled:!z,notesLabel:"Cambios o matices",notesPlaceholder:"Ej: solo cojo domicilio algunos días o cambia en verano.",stateLabel:"Disponibilidad actual",onStateChange:a=>P(o=>({...o,availability_state:a})),onNotesChange:a=>P(o=>({...o,availability_update_notes:a})),onChangeValue:Oa}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>z&&P(a=>({...a,has_vehicle:!a.has_vehicle})),className:`w-full flex items-center justify-between px-4 py-3 rounded-2xl border ${c.has_vehicle?"bg-green-50 border-green-100 text-green-700":"bg-gray-50 border-gray-100 text-gray-500"}
125 ${z?"":"opacity-70 cursor-default"}`,children:[e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest",children:"Vehículo"}),e.jsx("span",{className:"text-[8px] font-black uppercase",children:c.has_vehicle?"Sí":"No"})]}),e.jsxs("button",{type:"button",onClick:()=>z&&P(a=>({...a,has_metro:!a.has_metro})),className:`w-full flex items-center justify-between px-4 py-3 rounded-2xl border ${c.has_metro?"bg-blue-50 border-blue-100 text-[#1c74e9]":"bg-gray-50 border-gray-100 text-gray-500"} ${z?"":"opacity-70 cursor-default"}`,children:[e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest",children:"Metro"}),e.jsx("span",{className:"text-[8px] font-black uppercase",children:c.has_metro?"Sí":"No"})]}),e.jsxs("button",{type:"button",onClick:()=>z&&P(a=>({...a,wants_academy:!a.wants_academy})),className:`w-full flex items-center justify-between px-4 py-3 rounded-2xl border ${c.wants_academy?"bg-violet-50 border-violet-100 text-violet-700":"bg-gray-50 border-gray-100 text-gray-500"}
125 ${z?"":"opacity-70 cursor-default"}`,children:[e.jsx("span",{className:"text-[9px] font-black uppercase tracking-widest",children:"Academia"}),e.jsx("span",{className:"text-[8px] font-black uppercase",children:c.wants_academy?"Sí":"No"})]})]}),z&&e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-gray-100",children:[e.jsx("button",{type:"button",onClick:Ja,className:"flex-1 py-3 rounded-2xl border border-gray-200 text-gray-500 font-black text-[10px] uppercase tracking-widest",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:Ve,className:"flex-[1.4] py-3 rounded-2xl bg-[#1c74e9] text-white font-black text-[10px] uppercase tracking-widest shadow-lg shadow-blue-500/20 disabled:opacity-70",children:Ve?"Guardando...":"Guardar perfil"})]})]}),e.jsxs("form",{onSubmit:at,className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-[#1c74e9]",children:"Datos de cobro"}),e.jsx("p",{className:"text-[10px] text-gray-400 font-bold mt-1",children:"Este bloque solo guarda DNI/NIE e IBAN para pagos y facturación."})]}),Pe?e.jsx("span",{className:"text-[8px] font-black uppercase tracking-widest bg-amber-50 text-amber-700 border border-amber-100 px-2 py-1 rounded-lg",children:"Editando"}):e.jsx("button",{type:"button",onClick:()=>Ie(!0),className:"px-4 py-2 rounded-xl bg-blue-50 text-[#1c74e9] border border-blue-100 text-[9px] font-black uppercase tracking-widest",children:"Editar"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"DNI / NIE"}),e.jsx("input",{type:"text",value:c.dni,onChange:a=>P(o=>({...o,dni:a.target.value.toUpperCase()})),disabled:!Pe,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: 12345678A"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-black text-gray-400 uppercase tracking-widest block mb-1",children:"IBAN"}),e.jsx("input",{type:"text",value:c.iban,onChange:a=>P(o=>({...o,iban:a.target.value.toUpperCase().replace(/\s/g,"")})),disabled:!Pe,className:"w-full bg-gray-50 border border-gray-100 p-3 rounded-xl text-xs font-bold text-gray-900 outline-none focus:border-[#1c74e9] disabled:bg-gray-100 disabled:text-gray-400",placeholder:"Ej: ES12..."})]})]}),Pe&&e.jsxs("div",{className:"flex gap-3 pt-2 border-t border-gray-100",children:[e.jsx("button",{type:"button",onClick:Xa,className:"flex-1 py-3 rounded-2xl border border-gray-200 text-gray-500 font-black text-[10px] uppercase tracking-widest",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:Ze,className:"flex-[1.4] py-3 rounded-2xl bg-[#1c74e9] text-white font-black text-[10px] uppercase tracking-widest shadow-lg shadow-blue-500/20 disabled:opacity-70",children:Ze?"Guardando...":"Guardar cobro"})]})]})]}),s==="profile"&&!n&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"bg-white p-6 rounded-[24px] border border-gray-100 text-center shadow-sm",children:[e.jsx("div",{className:"w-16 h-16 bg-slate-50 border border-slate-100 rounded-full flex items-center justify-center text-3xl mx-auto mb-3 shadow-inner",children:"👤"}),e.jsx("h3",{className:"font-black text-gray-900 text-sm truncate px-4",children:l==null?void 0:l.email}),e.jsx("p",{className:"text-[10px] font-bold text-[#1c74e9] uppercase mt-1 tracking-widest bg-blue-50 inline-block px-3 py-1 rounded-full border border-blue-100",children:"Coordinación"}),e.jsx("div",{className:"mt-8 border-t border-gray-50 pt-6",children:e.jsx("button",{onClick:ia,className:"w-full py-4 bg-red-50 text-red-600 font-black text-[10px] tracking-widest uppercase rounded-2xl border border-red-100 hover:bg-red-100 transition-colors shadow-sm active:scale-95",children:"Desconectar y Salir"})})]})})]})]})]}),La&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-[9999] p-4 flex justify-center items-end sm:items-center",children:e.jsx("div",{className:"bg-white w-full max-w-sm rounded-[32px] shadow-2xl animate-in slide-in-from-bottom-10",children:e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("div",{className:"w-16 h-1.5 bg-gray-200 rounded-full mx-auto mb-6"}),e.jsx("h3",{className:"text-2xl font-black italic text-gray-900 mb-1",children:"Nueva Sesión"}),e.jsx("p",{className:"text-[10px] text-[#1c74e9] font-black uppercase tracking-widest mb-8",children:"Registro de horas de coordinacion"}),e.jsxs("form",{onSubmit:Ka,className:"space-y-5 text-left",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"Fecha"}),e.jsx("input",{type:"date",required:!0,className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-[#1c74e9]",value:ie.date,onChange:a=>De({...ie,date:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"Duración"}),e.jsxs("select",{className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-[#1c74e9]",value:ie.duration,onChange:a=>De({...ie,duration:Number(a.target.value)}),children:[e.jsx("option",{value:.5,children:"30 Min (0.5h)"}),e.jsx("option",{value:1,children:"1 Hora"}),e.jsx("option",{value:1.5,children:"1h 30min (1.5h)"}),e.jsx("option",{value:2,children:"2 Horas"}),e.jsx("option",{value:3,children:"3 Horas"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"¿Qué tareas has realizado?"}),e.jsx("textarea",{required:!0,placeholder:"Ej: Llamadas a deudores, revisión cuadrantes...",className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-[#1c74e9] resize-none h-24",value:ie.description,onChange:a=>De({...ie,description:a.target.value})})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-gray-50",children:[e.jsx("button",{type:"button",onClick:()=>ze(!1),className:"flex-1 py-4 font-black text-[10px] uppercase text-gray-500 border border-gray-200 rounded-2xl hover:bg-gray-50 transition-colors",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:Xe,className:"flex-[2] py-4 bg-[#1c74e9] hover:bg-blue-600 text-white font-black rounded-2xl shadow-lg shadow-blue-500/30 uppercase text-[10px] tracking-widest transition-all",children:Xe?"Guardando...":"Fichar Oficina"})]})]})]})})}),Ra&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-[9999] p-4 flex justify-center items-end sm:items-center",children:e.jsx("div",{className:"bg-white w-full max-w-sm rounded-[32px] shadow-2xl animate-in slide-in-from-bottom-10",children:e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("div",{className:"w-16 h-1.5 bg-gray-200 rounded-full mx-auto mb-6"}),e.jsx("div",{className:"w-12 h-12 bg-orange-50 border border-orange-100 rounded-2xl flex items-center justify-center text-2xl mx-auto mb-3 shadow-inner",children:"📞"}),e.jsx("h3",{className:"text-2xl font-black italic text-gray-900 mb-1",children:"Bitácora Padres"}),e.jsx("p",{className:"text-[10px] text-gray-400 font-black uppercase tracking-widest mb-6",children:"Registro de Comunicaciones"}),e.jsxs("form",{onSubmit:Za,className:"space-y-4 text-left",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"Alumno / Familia"}),e.jsx("input",{type:"text",required:!0,placeholder:"Ej: Familia de Hugo García",className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-orange-500",value:te.student_name,onChange:a=>ke({...te,student_name:a.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"Fecha"}),e.jsx("input",{type:"date",required:!0,className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-orange-500",value:te.contact_date,onChange:a=>ke({...te,contact_date:a.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"Motivo"}),e.jsxs("select",{className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-orange-500",value:te.topic,onChange:a=>ke({...te,topic:a.target.value}),children:[e.jsx("option",{value:"Información General",children:"Info General"}),e.jsx("option",{value:"Cambio de Horario",children:"Horario"}),e.jsx("option",{value:"Rendimiento Académico",children:"Rendimiento"}),e.jsx("option",{value:"Falta de Asistencia",children:"Asistencia"}),e.jsx("option",{value:"Cobros / Recibos",children:"Cobros"}),e.jsx("option",{value:"Otro",children:"Otro"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase pl-1 tracking-widest",children:"Notas de la conversación"}),e.jsx("textarea",{required:!0,placeholder:"Anota los puntos clave de la llamada o acuerdo...",className:"w-full bg-gray-50 p-4 rounded-2xl border border-gray-100 font-bold text-sm outline-none mt-1 focus:border-orange-500 resize-none h-24",value:te.notes,onChange:a=>ke({...te,notes:a.target.value})})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-gray-50",children:[e.jsx("button",{type:"button",onClick:()=>Oe(!1),className:"flex-1 py-4 font-black text-[10px] uppercase text-gray-500 border border-gray-200 rounded-2xl hover:bg-gray-50 transition-colors",children:"Cancelar"}
125),e.jsx("button",{type:"submit",disabled:ta,className:"flex-[2] py-4 bg-orange-500 hover:bg-orange-600 text-white font-black rounded-2xl shadow-lg shadow-orange-500/30 uppercase text-[10px] tracking-widest transition-all",children:ta?"Guardando...":"Guardar Registro"})]})]})]})})})]})};export{Cs as CoordinatorPanel};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.