PageSourceSearch

https://effervescent-cupcake-210607.netlify.app/assets/AdminStudents-DnpGEbPF.js

js effervescent-cupcake-210607.netlify.app collected 2026-10-03 10:41:19 UTC 178,615 bytes, 333 lines download raw bytes

1import{r as i,j as e,F as lo,s as m}from"./index-bMFZPluE.js";import{s as bt}from"./emailApi-BQfIvn0G.js";import{b as io}from"./siblingDetection-CHQmQ9BJ.js";import{c as ea,b as Gr,d as co,e as po,n as U,f as mo,g as gt}from"./addressFormatting-eDBQ4TmV.js";import{e as Ma}from"./emailHtml-CNLY3Q4b.js";import{e as Hr,f as xo,b as ht,d as uo,c as bo}from"./educationCatalog-pqwMnMBs.js";import{a as go,b as ho,g as Vr,p as fo}from"./classRoster-DcgYT_RM.js";import{e as Yr,a as Jr,n as yo,j as vo,m as jo}from"./pricingEngine-DmHUGCKM.js";import{a as wo,b as No}from"./familyProfileUpdate-DFe0h-LS.js";import{f as ko,t as _o,v as Xr,n as Kr}from"./phoneFormatting-bIoASOCT.js";import{C as Qr,A as So}from"./laborAssignmentControls-PBEP3hIy.js";import{g as Co}from"./holidayCalendar-CjdTLo_H.js";import{b as Zr,c as ft,d as es,e as Ia,j as as,a as ue,f as Ao,h as Eo,i as $o,g as ts}from"./studentProfileSummary-D5cIUZpH.js";import{e as aa,a as ta,s as Po,p as Ro,g as Do,b as Fo,c as To,f as yt,d as Lo,h as rs,i as Io,j as Mo}from"./academicTracking-DV-rV9tC.js";import{A as qo}from"./AcademyRulesContent-CQsXNIN7.js";import{b as ss,r as zo,d as Oo,e as Uo,f as Bo,h as Wo,a as Go,g as ns,c as Ho,i as Vo}from"./familyAgreement-Bm5j7ljB.js";import"./familyReceiptPolicy-egdKJ3_6.js";const Yo=g=>g.replace(/\/+$/,""),os=g=>{const T=String(g||"").trim();return!T||T.includes("127.0.0.1")||T.includes("localhost")?"https://app.profe-en-casa.com":Yo(T)},P=g=>(g||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),cs=g=>(g||"").trim().split(/\s+/).filter(Boolean)[0]||"familia",Jo=g=>`
2  <div style="border: 1px solid #e5e7eb; border-radius: 18px; padding: 16px; margin-bottom: 12px; background: #ffffff;">
3    <div style="display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 12px;">
4      <div>
5        <p style="margin: 0; color: #111827; font-size: 15px; font-weight: 900;">${P(g.weekdayLabel)} ${P(g.dateLabel)}</p>
6        <p style="margin: 4px 0 0 0; color: #6b7280; font-size: 12px; font-weight: 700;">${P(g.timeLabel)}</p>
7      </div>
8      ${g.slotPriceLabel?`<div style="background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; border-radius: 999px; padding: 8px 12px; font-size: 12px; font-weight: 900;">${g.slotPriceLabel}</div>`:""}
9    </div>
10    <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px;">
11      <div style="background: #f8fafc; border-radius: 14px; padding: 12px;">
12        <p style="margin: 0 0 6px 0; color: #6b7280; font-size: 10px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Asignatura y nivel</p>
13        <p style="margin: 0; color: #111827; font-size: 13px; font-weight: 800;">${P(g.subjectLabel)}</p>
14        <p style="margin: 4px 0 0 0; color: #4b5563; font-size: 12px;">${P(g.levelLabel)}</p>
15      </div>
16      <div style="background: #f8fafc; border-radius: 14px; padding: 12px;">
17        <p style="margin: 0 0 6px 0; color: #6b7280; font-size: 10px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Profesorado</p>
18        <p style="margin: 0; color: #111827; font-size: 13px; font-weight: 800;">${P(g.teacherName)}</p>
19        <p style="margin: 4px 0 0 0; color: #4b5563; font-size: 12px;">${P(g.modalityLabel)}</p>
20      </div>
21      ${g.groupLabel||g.participantsLabel?`
22        <div style="background: #f8fafc; border-radius: 14px; padding: 12px; grid-column: 1 / -1;">
23          <p style="margin: 0 0 6px 0; color: #6b7280; font-size: 10px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Grupo previsto</p>
24          ${g.groupLabel?`<p style="margin: 0 0 4px 0; color: #111827; font-size: 13px; font-weight: 800;">${P(g.groupLabel)}</p>`:""}
25          ${g.participantsLabel?`<p style="margin: 0; color: #4b5563; font-size: 12px;">${P(g.participantsLabel)}</p>`:""}
26        </div>
27      `:""}
28    </div>
29  </div>
30`;function Xo({parentName:g,studentName:T,monthName:ae,year:M,tutorName:be,teacherSummary:ge,reservedAmount:Te,sessions:Le,appUrl:te,logoUrl:he,pricingHeadline:V,pricingSupportText:ra,paymentReminderText:r}){const S=Le.map(Jo).join(""),$=cs(g),re=P(T),Y=P(ae),sa=P(be),na=P(ge),oa=P(te),w=he?P(he):"",qa=w?`
31      <div style="margin-bottom: 12px;">
32        <img src="${w}" alt="Profe en Casa" width="84" height="84" style="display: block; width: 84px; height: 84px; object-fit: cover; border-radius: 22px; margin: 0 auto; background: rgba(255,255,255,0.92); padding: 8px; box-shadow: 0 12px 28px rgba(15,23,42,0.22);" />
33      </div>
34    `:`
35      <div style="display: inline-block; margin-bottom: 12px; padding: 14px 18px; border-radius: 22px; background: rgba(255,255,255,0.16); color: #ffffff; font-size: 13px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">
36        Profe en Casa
37      </div>
38    `,q=Te>0?`
39        <div style="background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 18px; padding: 18px; margin: 24px 0;">
40          <p style="margin: 0 0 8px 0; color: #1d4ed8; font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Recibo Profe a 3</p>
41          <p style="margin: 0; color: #111827; font-size: 28px; font-weight: 900;">${Te.toFixed(2)}&euro;</p>
42          ${V?`<p style="margin: 10px 0 0 0; color: #1f2937; font-size: 14px; font-weight: 800;">${V}</p>`:""}
43          <p style="margin: 8px 0 0 0; color: #4b5563; font-size: 13px; line-height: 1.65;">
44            ${ra||`Este importe corresponde al recibo mensual por adelantado de las clases de Academia Profe a 3 reservadas para ${re} durante ${Y} ${M}. Los festivos y cierres conocidos ya se han descontado.`}
45          </p>
46        </div>
47      `:"",la=`
48    <div style="background: #fffbeb; border: 1px solid #fde68a; border-radius: 18px; padding: 16px; margin: 0 0 22px 0;">
49      <p style="margin: 0 0 6px 0; color: #92400e; font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Compromiso de asistencia</p>
50      <p style="margin: 0; color: #78350f; font-size: 14px; line-height: 1.7;">
51        ${r}
52      </p>
53    </div>
54  `;return`
55    <div style="font-family: Arial, sans-serif; max-width: 720px; margin: 0 auto; color: #1f2937; border: 1px solid #e5e7eb; border-radius: 24px; overflow: hidden; box-shadow: 0 10px 30px rgba(15,23,42,0.08);">
56      <div style="background: linear-gradient(135deg, #1c74e9 0%, #4f46e5 100%); padding: 32px 24px; text-align: center;">
57        ${qa}
58        <p style="margin: 0 0 8px 0; color: #dbeafe; font-size: 11px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase;">Profe en Casa</p>
59        <h1 style="margin: 0; color: white; font-size: 28px; font-weight: 900;">Recibo mensual por adelantado</h1>
60        <p style="margin: 10px 0 0 0; color: #dbeafe; font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;">
61          ${Y} ${M}
62        </p>
63      </div>
64
65      <div style="padding: 28px 24px;">
66        <p style="margin: 0 0 16px 0; font-size: 16px; line-height: 1.7;">
67          Hola <strong>${P($)}</strong>,
68        </p>
69        <p style="margin: 0 0 16px 0; font-size: 15px; line-height: 1.7;">
70          Te enviamos el recibo mensual por adelantado de <strong>${re}</strong> en Academia Profe a 3, calculado con las sesiones previstas y reservadas del mes.
71        </p>
72        <p style="margin: 0 0 20px 0; font-size: 15px; line-height: 1.7;">
73          Nuestra prioridad es siempre el alumno: mantener una rutina estable y una plaza reservada ayuda a dar continuidad al trabajo, consolidar habitos y aprovechar mejor los grupos reducidos.
74        </p>
75
76        <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 24px;">
77          <div style="background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 16px; padding: 16px;">
78            <p style="margin: 0 0 8px 0; color: #6b7280; font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Tutor academico</p>
79            <p style="margin: 0; color: #111827; font-size: 16px; font-weight: 900;">${sa}</p>
80          </div>
81          <div style="background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 16px; padding: 16px;">
82            <p style="margin: 0 0 8px 0; color: #6b7280; font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Profesorado previsto</p>
83            <p style="margin: 0; color: #111827; font-size: 16px; font-weight: 900;">${na}</p>
84          </div>
85          <div style="background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 16px; padding: 16px;">
86            <p style="margin: 0 0 8px 0; color: #6b7280; font-size: 11px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Sesiones previstas</p>
87            <p style="margin: 0; color: #111827; font-size: 16px; font-weight: 900;">${Le.length} clases</p>
88          </div>
89        </div>
90
91        ${q}
92        ${la}
93
94        <div style="margin: 24px 0;">
95          <p style="margin: 0 0 12px 0; color: #111827; font-size: 14px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase;">Horario previsto del mes</p>
96          <div>
97            ${S}
98          </div>
99        </div>
100
101        <p style="margin: 0 0 16px 0; color: #4b5563; font-size: 14px; line-height: 1.7;">
102          Si vierais algun detalle que revisar en el horario, o si necesitais comentar una situacion puntual, estamos aqui para ayudaros. El pago se realiza al comenzar el mes, durante la primera semana. Cualquier ajuste posterior se comunicara de forma clara.
103        </p>
104
105        <div style="text-align: center; margin-top: 24px;">
106          <a href="${oa}" style="display: inline-block; background: #eef2ff; color: #3730a3; text-decoration: none; font-weight: 900; font-size: 13px; padding: 12px 20px; border-radius: 12px; border: 1px solid #c7d2fe;">
107            Consultar portal de familias
108          </a>
109        </div>
110
111        <p style="margin: 26px 0 0 0; color: #9ca3af; font-size: 12px; text-align: center;">
112          Equipo de Profe en Casa
113        </p>
114      </div>
115    </div>
116  `}function Ko({parentName:g,studentName:T,monthName:ae,year:M,reservedAmount:be,sessionCount:ge,teacherSummary:Te,appUrl:Le}){const te=cs(g),he=`
117Profesorado previsto: ${Te}`;return`Hola ${te}, soy Francisco de Profe en Casa.
118
119Te enviamos el *recibo mensual por adelantado de Profe a 3* de ${T} para ${ae} ${M}.
120
121Clases previstas: ${ge}
122Importe del mes: ${be.toFixed(2)}EUR${he}
123
124En grupos tan reducidos, el compromiso de asistencia es muy importante: ayuda al alumno a mantener continuidad, cuida el grupo y respeta el tiempo reservado del profesor.
125
126Si una falta esta debidamente justificada, intentaremos ofrecer una recuperacion en otro grupo disponible, aunque no siempre puede garantizarse. Si hay festivos o dias sin clase, esas clases no se cobran.
127
128El pago se realiza al comenzar el mes, durante la primera semana. Cualquier ajuste posterior se comunicara de forma clara.
129
130Puedes revisar el detalle en el email y en el portal:
131${Le}
132
133Si veis algun horario que no cuadre, nos escribis y lo revisamos.`}const ls=(g,T,ae)=>{const M=Ma(g),be=Ma(T),ge=Ma(ae);return{subject:"Ya tienes tutor academico en Profe en Casa",html:`
134      <div style="font-family: sans-serif; max-width: 600px; margin: 0 auto; padding: 30px; border: 1px solid #e5e7eb; border-radius: 20px; text-align: center;">
135        <div style="font-size: 40px; margin-bottom: 20px;">Tutor</div>
136        <h2 style="color: #1c74e9; margin-bottom: 20px;">Buenas noticias, ${M}</h2>
137        <p style="color: #374151; font-size: 16px; line-height: 1.5; text-align: left;">Ya tenemos avances para las clases de <strong>${be}</strong>.</p>
138        <p style="color: #374151; font-size: 16px; line-height: 1.5; text-align: left;">Le hemos asignado a <strong>${ge}</strong> como tutor/a academico/a de referencia.</p>
139
140        <div style="background-color: #f3f4f6; padding: 20px; border-radius: 12px; margin: 30px 0; text-align: left;">
141          <p style="margin: 0 0 10px 0; font-weight: bold; color: #111827;">Siguientes pasos:</p>
142          <ul style="margin: 0; color: #4b5563; padding-left: 20px;">
143            <li style="margin-bottom: 10px;">La clase o grupo concreto se confirmara desde Agenda Centro en cuanto cerremos horario y modalidad.</li>
144            <li>Ya puedes acceder a tu Portal de Familia Privado para ver el progreso y saber quien es tu tutor.</li>
145          </ul>
146        </div>
147
148        <a href="https://app.profe-en-casa.com" style="display: inline-block; background-color: #1c74e9; color: white; padding: 14px 28px; text-decoration: none; border-radius: 12px; font-weight: bold; font-size: 16px;">Ir a mi Portal Privado</a>
149
150        <p style="margin-top: 40px; font-size: 12px; color: #9ca3af;">El equipo de Profe en Casa</p>
151      </div>
152    `}},is=g=>`
153    <div style="font-family: sans-serif; max-width: 640px; margin: 0 auto; color: #1f2937; border: 1px solid #e5e7eb; border-radius: 20px; overflow: hidden;">
154      <div style="background-color: #066591; padding: 28px 24px;">
155        <p style="margin: 0; color: #bae6fd; font-size: 12px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;">Profe en Casa</p>
156        <h1 style="margin: 8px 0 0; color: white; font-size: 24px;">
156Información para la familia</h1>
157      </div>
158      <div style="padding: 28px 24px; font-size: 16px; line-height: 1.65;">
159        ${Ma(g).replace(/\n/g,"<br>")}
160        <div style="text-align: center; margin: 30px 0 10px;">
161          <a href="https://app.profe-en-casa.com" style="display: inline-block; background-color: #1c74e9; color: white; padding: 13px 24px; text-decoration: none; border-radius: 12px; font-weight: 800;">Abrir Portal de Familias</a>
162        </div>
163        <p style="margin-top: 32px; color: #6b7280; font-size: 13px;">Francisco · Profe en Casa</p>
164      </div>
165    </div>
166  `,vl=({onBack:g,onOpenBillingForStudent:T})=>{var jr,wr,Nr,kr,_r,Sr,Cr,Ar,Er,$r,Pr,Rr,Dr,Fr,Tr,Lr,Ir;const[ae,M]=i.useState([]),[be,ge]=i.useState([]),[Te,Le]=i.useState(""),[te,he]=i.useState(""),[V,ra]=i.useState(!0),[r,S]=i.useState(null),[$,re]=i.useState("activos"),[Y,sa]=i.useState([]),[na,oa]=i.useState(!1),[w,qa]=i.useState(null),[q,la]=i.useState(!1),[Ie,za]=i.useState(!1),[ds,ia]=i.useState(!1),[k,Oa]=i.useState({subject:"",body:""}),[Ua,vt]=i.useState(!1),[Ba,jt]=i.useState(!1),[Wa,wt]=i.useState(!1),[Ga,Nt]=i.useState(!1),[ps,kt]=i.useState(!1),[_t,ms]=i.useState(""),[xs,us]=i.useState(""),[Me,St]=i.useState(!1),[qe,Ct]=i.useState(!1),[At,bs]=i.useState([]),[gs,ca]=i.useState(!1),[Et,hs]=i.useState([]),[ze,da]=i.useState(null),[fe,$t]=i.useState(!1),[fs,pa]=i.useState(!1),[ys,Ha]=i.useState(!1),[ma,Va]=i.useState(""),[xa,vs]=i.useState(""),[js,ua]=i.useState(!1),[ws,ba]=i.useState([]),[Ya,Pt]=i.useState(!1),[Ns,ye]=i.useState(!1),[Rt,Oe]=i.useState(!1),[Dt,W]=i.useState(""),[u,L]=i.useState({signerName:"",signerRole:"",signedDate:new Date().toISOString().slice(0,10),receiptMethod:"academy",modality:"",levelAndSubjects:"",weeklyFrequency:"",regularSchedule:"",sessionDuration:"",sessionPrice:"",startDate:"",paperCopyStored:!1}),[J,ks]=i.useState({}),[Ue,_s]=i.useState(!1),[ga,Ss]=i.useState(!1),[Cs,Ft]=i.useState({}),[As,Es]=i.useState({}),[$s,Ps]=i.useState(new Set),[Rs,Ds]=i.useState({}),Fs=[...xo],[Ts,Ja]=i.useState(!1),[Tt,Lt]=i.useState(!1),It={first_name:"",last_name:"",parent_first_name:"",parent_last_name:"",email:"",phone:"+34 ",level:"",modality:"Profe en casa (Domicilio)",location:"",address:"",address_details:"",postal_code:"",province:"Granada",subjects:[],school_name:"",availability:"",notes:"",billing_type:"Post-pago",is_recurring:!0},[c,C]=i.useState(It),[_,X]=i.useState(ea(null)),[v,I]=i.useState({parentFirstName:"",parentLastName:"",email:"",phone:"",birthDate:"",level:"",modality:"",subjects:"",schoolName:"",availability:"",notes:""}),[Xa,Ka]=i.useState(!1),[y,Be]=i.useState(!1),[Qo,Ls]=i.useState(!1),[Zo,el]=i.useState(""),[Mt,Qa]=i.useState(!1),[ha,qt]=i.useState(0),[We,zt]=i.useState(""),[Za,Ge]=i.useState(""),[Is,He]=i.useState(!1),[Ot,fa]=i.useState(!1),[et,ya]=i.useState(!1),[va,ja]=i.useState([]),[ve,je]=i.useState(""),[wa,we]=i.useState(""),[Ut,ie]=i.useState(!1),[Ms,Ne]=i.useState(!1),[qs,ke]=i.useState(!1),[Na,_e]=i.useState(!1),[K,se]=i.useState(aa),[B,ne]=i.useState(ta),ka=gt,_a=a=>!!(a!=null&&a.archived_at),Bt=a=>{if(!a)return"";const t=new Date(a);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("es-ES")},zs=a=>
166{if(!a)return"";const t=new Date(a);return Number.isNaN(t.getTime())?"":t.toLocaleString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"})},Os=(a,t,s)=>{const n=Bt(s)||Yt(),o=t.trim()||"Baja administrativa";return`[BAJA REVERSIBLE ${n}] ${a}. Motivo: ${o}.`},Sa=a=>At.find(t=>ka(t.email)===ka(a)),Ve=a=>(a==null?void 0:a.tutor_email)||(a==null?void 0:a.monitor_email)||"",Ca=a=>Sa(Ve(a)),Wt=()=>{const a=window.location.origin;return a.includes("127.0.0.1")||a.includes("localhost")?"https://app.profe-en-casa.com":a},Gt=a=>{const t=String(a||"").toLowerCase();return t.includes("academia")||t.includes("profe a 3")},at=a=>!!a&&Gt(Ia(a)||(a==null?void 0:a.modality)),Ht=(a,t)=>`${String(a||"").trim()} ${String(t||"").trim()}`.trim(),Vt=a=>String(a||"").trim().split(/\s+/).filter(Boolean).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")||"AL",x=a=>String(a||"").replace(/á/g,"a").replace(/é/g,"e").replace(/í/g,"i").replace(/ó/g,"o").replace(/ú/g,"u").replace(/Á/g,"A").replace(/É/g,"E").replace(/Í/g,"I").replace(/Ó/g,"O").replace(/Ú/g,"U").replace(/ñ/g,"n").replace(/Ñ/g,"N").replace(/¿/g,"¿").replace(/¡/g,"¡").replace(/º/g,"º").replace(/•/g,"-").replace(/·/g,"·").replace(/×/g,"x").replace(/Â/g,""),Yt=()=>new Date().toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit",year:"numeric"}),Us=a=>a!=null&&a.name?As[U(a.name)]||[]:[],tt=a=>Us(a).map(Sa).filter(Boolean),Jt=a=>a&&Cs[a.student_id||a.name]||null,Aa=a=>({parentFirstName:String((a==null?void 0:a.parent_first_name)||"").trim(),parentLastName:String((a==null?void 0:a.parent_last_name)||"").trim(),email:ue(a),phone:ko(a==null?void 0:a.phone),birthDate:$o(a),level:Zr(a),modality:Ia(a),subjects:ft(a),schoolName:as(a),availability:es(a),notes:x((a==null?void 0:a.notes)||(a==null?void 0:a.observations)||"").trim()}),Xt="RESERVA MENSUAL",Kt="RESERVA WHATSAPP",Qt="ACTUALIZACION FICHA FAMILIA",Zt="RECIBO MENSUAL",Bs="RECIBO WHATSAPP",er="ACCESO FAMILIA",Ws="OPCIONES RECUPERACION",Gs="RECUPERACION CERRADA",Hs="RECUPERACION PROGRAMADA",Vs="EXAMEN ACTUALIZADO",Ys="NOTA ACTUALIZADA",Se=a=>(a||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g," ").trim().toLowerCase(),Q=(a,t)=>Se(a).includes(Se(t)),rt=(a,t)=>{const s=t.trim();return!s||a.includes(s)?a:a?`${a} | ${s}`:s},Js=a=>String((a==null?void 0:a.subjects)||"").split(",").map(t=>Se(t)).filter(Boolean),Xs=(a,t)=>{const s=String((t==null?void 0:t.subject)||"").trim();if(!s)return!1;if(bo(s))return!0;const n=Js(a);if(n.length===0)return!0;const o=Se(s);return n.some(d=>d===o||d.includes(o)||o.includes(d))},Ks=a=>a.filter(t=>{const s=`${(t==null?void 0:t.topic)||""} ${(t==null?void 0:t.notes)||""}`.toUpperCase();return s.includes("RESERVA MENSUAL")||s.includes("RESERVA WHATSAPP")||s.includes("RECIBO MENSUAL")||s.includes("RECIBO WHATSAPP")||s.includes("ACCESO FAMILIA")||s.includes("ACTUALIZACION FICHA")}),Qs=a=>a.filter(t=>{const s=String((t==null?void 0:t.topic)||"");return Q(s,"RECUPERACION PENDIENTE")||Q(s,"OPCIONES RECUPERACION")||Q(s,"RECUPERACION CERRADA")||Q(s,"RECUPERACION PROGRAMADA")||Q(s,"RECUPERACION JUSTIFICADA")}),Zs=a=>{const t=`${(a==null?void 0:a.topic)||""} ${(a==null?void 0:a.notes)||""}`.toUpperCase();return t.includes("ACTUALIZACION FICHA")||String((a==null?void 0:a.topic)||"")===Qt?{title:"Solicitud de ficha",badge:"FICHA",cardClass:"bg-amber-50 border-amber-100",titleClass:"text-amber-700",badgeClass:"bg-white text-amber-700 border border-amber-200"}:t.includes("RECIBO WHATSAPP")||String((a==null?void 0:a.topic)||"")===Bs?{title:"Recibo por WhatsApp",badge:"WHATSAPP",cardClass:"bg-green-50 border-green-100",titleClass:"text-green-700",badgeClass:"bg-white text-green-700 border border-green-200"}:t.includes("RECIBO MENSUAL")||String((a==null?void 0:a.topic)||"")===Zt?{title:"Recibo por email",badge:"EMAIL",cardClass:"bg-emerald-50 border-emerald-100",titleClass:"text-emerald-700",badgeClass:"bg-white text-emerald-700 border border-emerald-200"}:t.includes("RESERVA WHATSAPP")||String((a==null?void 0:a.topic)||"")===Kt?{title:"Recibo preparado para WhatsApp",badge:"WHATSAPP",cardClass:"bg-green-50 border-green-100",titleClass:"text-green-700",badgeClass:"bg-white text-green-700 border border-green-200"}:t.includes("ACCESO FAMILIA")||String((a==null?void 0:a.topic)||"")===er?{title:"Acceso al portal",badge:"PORTAL",cardClass:"bg-blue-50 border-blue-100",titleClass:"text-blue-700",badgeClass:"bg-white text-blue-700 border border-blue-200"}:{title:"Recibo mensual",badge:"RECIBO",cardClass:"bg-violet-50 border-violet-100",titleClass:"text-violet-700",badgeClass:"bg-white text-violet-700 border border-violet-200"}},Z=async()=>{ra(!0);const{data:a}=await m.auth.getUser();a.user&&qa(a.user.id);const{data:t}=await m.from("students").select("*").order("created_at",{ascending:!1}),{data:s}=await m.from("teachers").select("*").neq("status","Inactivo"),{data:n}=await m.from("classes").select("student_name, monitor_email, status").gte("class_date",Qr.startDate).lte("class_date",Qr.endDate).is("deleted_at",null),{data:o}=await m.from("academic_group_plans").select("id").eq("academic_year",So).in("status",["preparing","ready","scheduled"]),d=(o||[]).map(b=>String(b.id)),l=d.length>0?await m.from("academic_group_plan_students").select("student_id").in("plan_id",d):{data:[]};t?(M(t),Ft(io(t))):Ft({}),s&&bs(s),Es(co(n||[]));const p=po(n||[]),h=new Map((t||[]).map(b=>[String(b.student_id),U(b.name)]));
166if((l.data||[]).forEach(b=>{const j=h.get(String(b.student_id));j&&p.add(j)}),Ps(p),Ds(mo(n||[])),t){const b=new Date;b.setDate(b.getDate()-30);const{data:j}=await m.from("classes").select("student_name, class_date, status, monitor_notes").gte("class_date",b.toISOString().split("T")[0]).is("deleted_at",null).order("class_date",{ascending:!1}),E={};if(j){const D={};j.forEach(N=>{D[N.student_name]||(D[N.student_name]=[]),D[N.student_name].push(N)}),t.forEach(N=>{const O=D[N.name]||[];let F="ninguno",ee="";if(Ve(N)&&O.length===0)F="media",ee="Ghosting: 30 dias sin dar ni una sola clase.";else if(O.length>0){const me=O[0],Re=me.monitor_notes||"";Re.includes("⭐")&&!Re.includes("⭐⭐⭐")?(F="alta",ee="Frustracion: El profesor ha puntuado su ultima clase con notas muy bajas."):(me.status==="Cancelada"||Re.includes("FALTA INJUSTIFICADA"))&&(F="media",ee="Desconexion: Su ultima sesion fue cancelada o tuvo falta injustificada.")}F!=="ninguno"&&N.student_id&&(E[N.student_id]={level:F,reason:ee})})}ks(E)}ra(!1)};i.useEffect(()=>{Z()},[]);const z=async a=>{oa(!0);const{data:t}=await m.from("parent_logs").select("*").eq("student_name",a).order("created_at",{ascending:!1});t&&sa(t),oa(!1)},ar=(a,t)=>({signerName:ts(a)||"",signerRole:"",signedDate:new Date().toISOString().slice(0,10),receiptMethod:"academy",modality:t.modalityKey==="unknown"?"":Vo(t.modalityKey),levelAndSubjects:t.levelAndSubjects,weeklyFrequency:t.weeklyFrequency,regularSchedule:t.regularSchedule,sessionDuration:t.sessionDuration,sessionPrice:t.sessionPriceValue?String(t.sessionPriceValue):"",startDate:t.startDateValue,paperCopyStored:!1}),en=async a=>{if(!(a!=null&&a.name)){ba([]);return}Pt(!0);const{data:t,error:s}=await m.from("classes").select("class_date, start_time, end_time, subject, level, modality, family_price, family_price_by_student, student_name, status").ilike("student_name",`%${a.name}%`).gte("class_date",Oo).neq("status","Cancelada").is("deleted_at",null).order("class_date",{ascending:!0}).order("start_time",{ascending:!0}).limit(32);if(Pt(!1),s){console.error("No se pudieron preparar las condiciones del acuerdo:",s),ba([]);return}const n=t||[],o=ss(a,n);ba(n),L(ar(a,o))};i.useEffect(()=>{r?(z(r.name),en(r),ca(!1),Ls(!1),Qa(!1),Be(!1),Ge(""),He(!1),fa(!1),ya(!1),ja([]),je(""),we(""),ie(!1),Ne(!1),ke(!1),_e(!1),se(aa),ne(ta),ye(!1),Oe(!1),W(""),X(ea(r)),I(Aa(r))):(sa([]),Be(!1),Ge(""),He(!1),fa(!1),ya(!1),ja([]),je(""),we(""),ie(!1),Ne(!1),ke(!1),_e(!1),se(aa),ne(ta),ba([]),ye(!1),Oe(!1),W(""),X(ea(null)),I(Aa(null)))},[r]);const Ye=a=>{S(a),M(t=>t.map(s=>s.student_id===a.student_id?a:s))},an=async()=>{if(!(r!=null&&r.student_id))return;if(!K.subject.trim()||!K.exam_date){alert("Rellena asignatura y fecha antes de guardar el examen.");return}_e(!0);const a=[...$e,Io(K,"admin")],{error:t}=await m.from("students").update({upcoming_exams:a}).eq("student_id",r.student_id);if(_e(!1),t){alert(`No se pudo guardar el examen: ${t.message}`);return}const s={...r,upcoming_exams:a};Ye(s),se(aa),Ne(!1),await m.from("parent_logs").insert([{student_name:r.name,contact_date:new Date().toISOString().slice(0,10),topic:Vs,notes:`Coordinacion registro un examen de ${K.subject.trim()} para ${yt(K.exam_date)}.`}]),await z(r.name)},tn=async()=>{if(!(r!=null&&r.student_id))return;if(!B.term.trim()||!B.subject.trim()||!B.grade.trim()){alert("Rellena trimestre, asignatura y nota antes de guardar.");return}_e(!0);const a=[...Ke,Mo(B,"admin")],{error:t}=await m.from("students").update({term_grades:a}).eq("student_id",r.student_id);if(_e(!1),t){alert(`No se pudo guardar la nota: ${t.message}`);return}const s={...r,term_grades:a};Ye(s),ne(ta),ke(!1),await m.from("parent_logs").insert([{student_name:r.name,contact_date:new Date().toISOString().slice(0,10),topic:Ys,notes:`Coordinacion registro una nota de ${B.grade.trim()} en ${B.subject.trim()} (${B.term.trim()}).`}]),await z(r.name)},rn=async a=>{if(!(r!=null&&r.student_id))return;const t=$e.filter(n=>n.id!==a),{error:s}=await m.from("students").update({upcoming_exams:t}).eq("student_id",r.student_id);if(s){alert(`No se pudo borrar el examen: ${s.message}`);return}Ye({...r,upcoming_exams:t})},sn=async a=>{if(!(r!=null&&r.student_id))return;const t=Ke.filter(n=>n.id!==a),{error:s}=await m.from("students").update({term_grades:t}).eq("student_id",r.student_id);if(s){alert(`No se pudo borrar la nota: ${s.message}`);return}Ye({...r,term_grades:t})},tr=a=>$s.has(U(a==null?void 0:a.name)),nn=a=>{const t=ka(String(a||""));return!t||t.includes("info.profeencasa+familia-")||t.includes("+familia-")},rr=a=>{const t=gt(a==null?void 0:a.email),s=gt(a==null?void 0:a.parent_email);return!!(t&&s&&t!==s)},Je=a=>{if(!a)return!1;const t=a.family_profile_completed_at?new Date(a.family_profile_completed_at):null;if(a.family_profile_last_source==="legacy_form_import"&&!t)return!0;const n=!nn(ue(a)),o=String(a.phone||"").replace(/\D/g,"").length>=9,d=String(a.address||"").trim().length>=5,l=String(a.location||"").trim().length>=2,p=String(a.province||"").trim().length>=2,h=String(a.parent_name||`${a.parent_first_name||""} ${a.parent_last_name||""}`).trim().length>=3;return t?!1:!n||!o||!d||!l||!p||!h},sr=a=>{const t=Je(a),s=a!=null&&a.family_profile_requested_at?new Date(a.family_profile_requested_at):null,n=a!=null&&a.family_profile_completed_at?new Date(a.family_profile_completed_at):null,o=(a==null?void 0:a.family_profile_last_source)==="legacy_form_import";return n&&(!s||n.getTime()>=s.getTime())?{label:"Ficha al dia",tone:"done"}:o&&!n?{label:"Pendiente revisar",tone:"pending"}:t?s?{label:"Pendiente familia",tone:"pending"}:{label:"Falta completar",tone:"idle"}:{label:"Ficha base ok",tone:"done"}},Ea=ae.filter(a=>!_a(a)),st=ae.filter(_a),Ce=Ea.filter(tr),nt=Ea.filter(a=>!tr(a)),ot=($==="espera"?nt:$==="baja"?st:Ce).filter(a=>{const t=(a.name||"").toLowerCase().includes(te.toLowerCase())||(a.parent_name||"").toLowerCase().includes(te.toLowerCase())||(a.location||"").toLowerCase().includes(te.toLowerCase()),s=$==="activos"&&Ue?a.student_id&&J[a.student_id]!==void 0:!0,n=$!=="baja"&&ga?Je(a):!0;return t&&s&&n}),nr=Ce.filter(a=>a.student_id&&J[a.student_id]).length,ce=Jt(r),on=((jr=ce==null?void 0:ce.reasons)==null?void 0:jr.join(" + "))||"",or=Ks(Y).slice(0,4),lt=Qs(Y),Ae=Math.max(lt.f
166ilter(a=>{const t=String(a.topic||"");return Q(t,"RECUPERACION PENDIENTE")||Q(t,"RECUPERACION JUSTIFICADA")}).length-lt.filter(a=>{const t=String(a.topic||"");return Q(t,"RECUPERACION CERRADA")||Q(t,"RECUPERACION PROGRAMADA")}).length,0),lr=lt.slice(0,4),Ee=new Date,ln=`${Ee.getFullYear()}-${String(Ee.getMonth()+1).padStart(2,"0")}-01`,cn=`${Ee.getFullYear()}-${String(Ee.getMonth()+1).padStart(2,"0")}-${String(new Date(Ee.getFullYear(),Ee.getMonth()+1,0).getDate()).padStart(2,"0")}`,$a=Y.some(a=>`${(a==null?void 0:a.topic)||""} ${(a==null?void 0:a.notes)||""}`.toUpperCase().includes("ACCESO FAMILIA")),Pa=Y.some(a=>{const t=`${(a==null?void 0:a.topic)||""} ${(a==null?void 0:a.notes)||""}`.toUpperCase(),s=String((a==null?void 0:a.contact_date)||"");return(t.includes("RESERVA MENSUAL")||t.includes("RESERVA WHATSAPP")||t.includes("RECIBO MENSUAL")||t.includes("RECIBO WHATSAPP"))&&s>=ln&&s<=cn}),$e=Po(Ro(r==null?void 0:r.upcoming_exams)),Xe=Do($e),ir=new Set(Xe.map(a=>a.id)),de=Xe[0]||null,Ke=Fo(To(r==null?void 0:r.term_grades)),pe=sr(r),cr=x(Zr(r)||"Nivel pendiente"),it=x(ft(r)||"Pendiente de concretar"),ct=x(es(r)||"Pendiente de concretar"),dn=x(Ia(r)||"-"),dt=at(r),pn=x(as(r)||"Pendiente de concretar"),A=ue(r),Qe=rr(r),G=!!A&&!Qe,dr=x(A||"Sin email"),mn=x(Ao(r)||"Pendiente"),pr=Eo(r),xn=pr!==null?`${pr}`:"Pendiente",oe=ss(r,ws),Pe=r?(()=>{if(!r.signature_data)return null;
166try{const a=typeof r.signature_data=="string"?JSON.parse(r.signature_data):r.signature_data;return a&&typeof a=="object"?a:null}catch{return null}})():null,un=(Pe==null?void 0:Pe.agreementDetails)||oe,Ze=Ce.filter(Je),bn=Ze.filter(a=>!!a.family_profile_requested_at),gn=Ce.filter(a=>!Je(a)),Ra=Ea.filter(rr),Da=a=>{if(!a)return 0;const t=new Date(a),n=new Date().getTime()-t.getTime();return Math.floor(n/(1e3*60*60))},le=(a,t)=>{const s=_o(a);if(!s){alert("Este alumno no tiene un telefono valido guardado.");return}window.open(`https://wa.me/${s}?text=${encodeURIComponent(t)}`,"_blank")},hn=()=>{if(!r)return;const a=R(r),t=ue(r)||"Tu correo electronico",s=os(window.location.origin),n=`Hola ${a}. Somos el equipo de Profe en Casa.
167
168Ya tenemos preparado el acceso para ${r.name}.
169
170En el Portal de Familias podras conocer al profesor o profesora asignada, leer y confirmar nuestro acuerdo de funcionamiento y consultar el seguimiento de las clases.
171
172Tus datos de acceso:
173Web: ${s}
174Email: ${t}
175
176Entra, registrate con ese correo y, si algo no queda claro, lo vemos contigo.`;le(r.phone,`${n}
177
178Si es vuestra primera vez:
1791. Entrad en ${s}
1802. Dejad la pestana en Familias
1813. Pulsad Es tu primera vez? Crea tu cuenta
1824. Usad este correo: ${t}
1835. Escribid la contrasena y repetidla dos veces`)},fn=()=>{if(!(r!=null&&r.student_id)){alert("Este alumno no tiene un identificador interno válido.");return}if(!r.phone){alert("Esta familia no tiene un teléfono guardado.");return}if(!r.family_access_token){alert("Esta ficha todavía no tiene un enlace seguro de familia. Revísala antes de preparar el acuerdo.");return}if(!oe.readyToSign){alert(`Antes de preparar el acuerdo falta completar: ${oe.missingFields.join(", ")}.`);return}const a=Uo({baseUrl:os(window.location.origin),studentId:r.student_id,familyToken:r.family_access_token}),t=Bo({parentName:R(r),details:oe,agreementUrl:a});vs(a),Va(t),ua(!1),Ha(!0)},mr=()=>{if(!xa||ma.includes(xa))return ma;const a=`${ma.trim()}
184
185Enlace personal para leer y firmar:
186${xa}`;return Va(a),a},yn=async()=>{const a=mr();try{await navigator.clipboard.writeText(a),ua(!0);return}catch{const t=document.createElement("textarea");t.value=a,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select(),document.execCommand("copy"),document.body.removeChild(t),ua(!0)}},vn=()=>{r!=null&&r.phone&&le(r.phone,mr())},xr=(a,t="send")=>{if(!(a!=null&&a.student_id))return"";const s=t==="preview"?window.location.origin:Wt();return No(s,a.student_id,a.family_access_token)},jn=()=>{if(!(r!=null&&r.student_id)){alert("Este alumno no tiene un identificador interno valido.");return}window.open(xr(r,"preview"),"_blank")},wn=async()=>{if(!(r!=null&&r.student_id)){alert("Este alumno no tiene un identificador interno valido.");return}if(!(r!=null&&r.phone)||r.phone.length<5){alert("Esta familia no tiene un telefono valido guardado para enviarle el formulario por WhatsApp.");return}const a=new Date().toISOString(),t=xr(r,"send"),s=wo({parentName:R(r),studentName:r.name,updateUrl:t});vt(!0);try{const{error:n}=await m.from("students").update({family_profile_requested_at:a,family_profile_request_channel:"WhatsApp"}).eq("student_id",r.student_id);if(n)throw n;const{error:o}=await m.from("parent_logs").insert([{student_name:r.name,topic:Qt,notes:`Solicitud de actualizacion de ficha enviada por WhatsApp a ${R(r)}.`,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);if(o)throw o;S({...r,family_profile_requested_at:a,family_profile_request_channel:"WhatsApp"}),await z(r.name),le(r.phone,s)}catch(n){console.error("Error al preparar la solicitud de actualizacion de ficha:",n),alert("No hemos podido preparar el envio por WhatsApp: "+((n==null?void 0:n.message)||"Error desconocido"))}finally{vt(!1)}},Nn=()=>{if(Qe){alert("Esta ficha tiene dos correos familiares distintos. Revisa y unifica el correo antes de enviar.");return}if(!A){alert("Esta familia no tiene un correo guardado.");return}const a=R(r),t=Ca(r),s=tt(r),n=s.length>0?s.map(b=>b.name||b.email).join(", "):(t==null?void 0:t.name)||"[confirmar profesora]",o=r.
186schedule||"[confirmar horario]",d=r.duration||"[confirmar duración semanal]",l=Ia(r)||"[confirmar modalidad]",p=ft(r)||"[confirmar materias]",h={subject:`Inicio de las clases de ${r.name} con Profe en Casa`,body:`Hola ${a},
187
188Antes de comenzar, queremos dejar por escrito los datos acordados para las clases de ${r.name}:
189
190Alumna: ${r.name}
191Modalidad: ${l}
192Profesora: ${n}
193Materias: ${p}
194Horario: ${o}
195Duración: ${d}
196Fecha de inicio: [confirmar fecha de inicio]
197Precio y condiciones: [confirmar condiciones acordadas]
198
199La ficha familiar está preparada, pero el acuerdo todavía debe revisarse y confirmarse desde el Portal de Familias. Podéis acceder con este correo: ${A}.
200
201Si algún dato no coincide con lo hablado, responded a este correo antes del comienzo y lo corregimos.
202
203Gracias.`};Oa({subject:r.family_start_email_subject||h.subject,body:r.family_start_email_body||h.body}),ia(!0)},kn=async()=>{if(!(r!=null&&r.student_id))return;if(!k.subject.trim()||!k.body.trim()){alert("Completa el asunto y el texto antes de guardar el borrador.");return}za(!0);const a=new Date().toISOString(),t={family_start_email_subject:k.subject.trim(),family_start_email_body:k.body.trim(),family_start_email_prepared_at:a,family_start_email_sent_at:null},{error:s}=await m.from("students").update(t).eq("student_id",r.student_id);if(s){alert(`No se pudo guardar el borrador: ${s.message}`),za(!1);return}S(n=>n&&{...n,...t}),M(n=>n.map(o=>o.student_id===r.student_id?{...o,...t}:o)),za(!1),alert("Borrador guardado. El correo sigue pendiente y no se ha enviado.")},_n=async()=>{if(!(!A||!r)){if(!k.subject.trim()||!k.body.trim()){alert("Completa el asunto y el texto antes de enviar.");return}if(k.body.includes("[confirmar")){alert("Todavia quedan datos marcados como [confirmar]. Revisa el texto antes de enviar.");return}if(window.confirm(`¿Enviar este correo a ${A}?`)){la(!0);try{await bt({to:A,subject:k.subject.trim(),html:is(k.body.trim())}),await m.from("parent_logs").insert([{student_name:r.name,topic:er,notes:`Correo familiar enviado a ${A}. Asunto: ${k.subject.trim()}`,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);const a=new Date().toISOString(),t={family_start_email_subject:k.subject.trim(),family_start_email_body:k.body.trim(),family_start_email_prepared_at:r.family_start_email_prepared_at||a,family_start_email_sent_at:a},{error:s}=await m.from("students").update(t).eq("student_id",r.student_id);if(s)throw s;S(n=>n&&{...n,...t}),M(n=>n.map(o=>o.student_id===r.student_id?{...o,...t}:o)),alert(`Email enviado correctamente a ${A}.`),ia(!1),await z(r.name)}catch(a){console.error("Error al enviar email a la familia:",a),alert("Error al enviar el email familiar: "+((a==null?void 0:a.message)||"Error desconocido"))}finally{la(!1)}}}},Sn=a=>{C(t=>({...t,subjects:t.subjects.includes(a)?t.subjects.filter(s=>s!==a):[...t.subjects,a]}))},Cn=async a=>{if(!(a!=null&&a.student_id)||!(a!=null&&a.name)||!window.confirm(`¿Quieres dar de baja a ${a.name} y moverla a "Dados de baja"?`))return;const t=window.prompt(`Motivo de la baja de ${a.name} (opcional):`,a.archived_reason||"Baja solicitada por la familia");if(t===null)return;const s=new Date().toISOString(),n=String(t||"").trim()||"Baja administrativa",o=Os(a.name,n,s),d=String(a.notes||"").includes(o)?String(a.notes||""):[String(a.notes||"").trim(),o].filter(Boolean).join(`
204`),{error:l}=await m.from("students").update({archived_at:s,archived_reason:n,archived_by:w||"admin",notes:d}).eq("student_id",a.student_id);if(l){alert(`No se pudo archivar la baja: ${l.message}`);return}w&&await m.from("parent_logs").insert({parent_id:w,parent_name:"Jefatura",student_name:a.name,topic:"BAJA ALUMNO",notes:`Alumno dado de baja y archivado para posible reactivacion. Motivo: ${n}.`,contact_date:s.split("T")[0]}),re("baja"),S(null),Z()},An=async a=>{if(!(a!=null&&a.student_id)||!(a!=null&&a.name)||!window.confirm(`¿Quieres reactivar a ${a.name} y devolverla al CRM activo?`))return;const{error:t}=await m.from("students").update({archived_at:null,archived_reason:null,archived_by:null}).eq("student_id",a.student_id);if(t){alert(`No se pudo reactivar la ficha: ${t.message}`);return}w&&await m.from("parent_logs").insert({parent_id:w,parent_name:"Jefatura",student_name:a.name,topic:"REACTIVACION ALUMNO",notes:"Alumno reactivado desde la bandeja de dados de baja.",contact_date:new Date().toISOString().split("T")[0]}),re("activos"),S(null),Z()},En=()=>
204{if(!r)return;const a=`URGENTE: Buscamos Profesor/a en ${x(r.location||"tu zona")} ${r.province?`(${x(r.province)})`:""}
205
206Academia "Profe en Casa" busca docente para impartir clases particulares a DOMICILIO.
207
208Asignaturas: ${x(r.subjects||"Varias asignaturas")}
209Nivel: ${x(r.level||"A convenir")}
210Horario solicitado: ${x(r.availability||"A convenir con la familia")}
211
212REQUISITOS:
213- Experiencia dando clases.
214- Ganas de ensenar y buena actitud.
215- (Valorable vehiculo propio si vives lejos).
216
217COMO INSCRIBIRSE (Solo se aceptan candidaturas por nuestro portal oficial):
218Entra aqui y completa tus datos en 1 minuto:
219https://app.profe-en-casa.com/empleo
220
221Unete a nuestro equipo docente hoy mismo y empieza a dar clases.`;navigator.clipboard.writeText(a).then(()=>{alert(`Anuncio copiado al portapapeles.
222
223Se va a abrir la web de clasificados. Solo tienes que elegir la categoria de 'Clases Particulares', pulsar Ctrl+V (Pegar) en la descripcion y publicar.`),window.open("https://www.milanuncios.com/publicar-anuncios-gratis/form/?c=150","_blank")}).catch(t=>{console.error("Error al copiar:",t),alert(`No se pudo copiar automaticamente. Aqui tienes el texto:
224
225`+a)})},$n=async a=>{if(a.preventDefault(),!c.level){alert("Selecciona el curso exacto del alumno antes de guardar la ficha.");return}if(!c.first_name.trim()||!c.last_name.trim()||!c.parent_first_name.trim()||!c.parent_last_name.trim()){alert("Completa nombre y apellidos del alumno y del tutor para que la ficha enganche bien con familias y emails.");return}const t=Xr(c.phone,"WhatsApp de la familia");if(!t.ok){alert(t.error);return}Lt(!0);const s=`STU-${Date.now()}`,n=new Date().toISOString(),o=Ht(c.first_name,c.last_name),d=Ht(c.parent_first_name,c.parent_last_name),l=`Inicio de las clases de ${o} con Profe en Casa`,p=`Hola ${d},
226
227Antes de comenzar, queremos dejar por escrito los datos acordados para las clases de ${o}:
228
229Alumno/a: ${o}
230Modalidad: ${c.modality||"[confirmar modalidad]"}
231Profesor/a: [confirmar profesor/a]
232Materias: ${c.subjects.join(", ")||"[confirmar materias]"}
233Horario: ${c.availability||"[confirmar horario]"}
234Duracion: [confirmar duracion semanal]
235Fecha de inicio: [confirmar fecha de inicio]
236Precio y condiciones: [confirmar condiciones acordadas]
237
238La ficha familiar esta preparada, pero el acuerdo todavia debe revisarse y confirmarse desde el Portal de Familias.
239
240Si algun dato no coincide con lo hablado, responded a este correo antes del comienzo y lo corregimos.
241
242Gracias.`,h={student_id:s,name:o,first_name:c.first_name.trim(),last_name:c.last_name.trim(),parent_name:d,parent_first_name:c.parent_first_name.trim(),parent_last_name:c.parent_last_name.trim(),email:c.email,parent_email:c.email,phone:Kr(c.phone),address:c.address,address_details:c.address_details,postal_code:c.postal_code,location:c.location,province:c.province,level:c.level,subjects:c.subjects.join(", "),modality:c.modality,school_name:c.school_name.trim(),availability:c.availability,notes:c.notes,billing_type:c.billing_type,is_recurring:c.is_recurring,created_at:n,family_profile_last_source:"admin_manual_enrollment",family_start_email_subject:l,family_start_email_body:p,family_start_email_prepared_at:n,family_start_email_sent_at:null},{error:b}=await m.from("students").insert([h]);b?alert("Error al matricular: "+b.message):(Ja(!1),C(It),Z(),alert("Alumno matriculado y puesto en espera (Buscando Profe). El correo familiar queda guardado como borrador y no se ha enviado.")),Lt(!1)},Pn=async()=>{if(!r)return;const a=r.is_recurring===!1,{error:t}=await m.from("students").update({is_recurring:a}).eq("student_id",r.student_id);t?alert("Error al actualizar la suscripcion: "+t.message):(S({...r,is_recurring:a}),Z())},Rn=async a=>{if(!r)return;const{error:t}=await m.from("students").update({billing_type:a}).eq("student_id",r.student_id);t?alert("Error al actualizar facturacion: "+t.message):(S({...r,billing_type:a}),Z())},Dn=async()=>{var N;if(!(r!=null&&r.student_id))return;Ka(!0);const a=v.email.trim(),t=Xr(v.phone,"WhatsApp de la familia");if(!t.ok){alert(t.error),Ka(!1);return}const s=Kr(v.phone),n=ht(v.level)||v.level.trim(),o=v.subjects.trim(),d=v.schoolName.trim(),l=v.availability.trim(),p=v.notes.trim(),h=v.birthDate.trim(),j={parent_name:`${v.parentFirstName} ${v.parentLastName}`.trim()||null,parent_first_name:v.parentFirstName.trim()||null,parent_last_name:v.parentLastName.trim()||null,email:a||null,parent_email:a||null,phone:s||null,birth_date:h||null,level:n||null,course:n||null,modality:v.modality.trim()||null,subject:((N=o.split(",")[0])==null?void 0:N.trim())||null,subjects:o||null,school_name:d||null,availability:l||null,schedule:l||null,notes:p||null,address:_.address||null,address_details:_.address_details||null,postal_code:_.postal_code||null,location:_.locality||null,province:_.province||null},{error:E}=await m.from("students").update(j).eq("student_id",r.student_id);if(Ka(!1),E){alert("Error al guardar la ubicacion: "+E.message);return}const D={...r,...j};S(D),M(O=>O.map(F=>F.student_id===r.student_id?{...F,...j}:F)),Be(!1),alert("Ubicacion guardada.")},ur=()=>{r&&(X(ea(r)),I(Aa(r)),Be(!0))},br=()=>{X(ea(r)),I(Aa(r)),Be(!1)},gr=async(a,t)=>{if(!r||!w)return alert("Error: falta seleccionar alumno o administrador."),!1;const{error:s}=await m.from("parent_logs").insert([{student_name:r.name,topic:a,notes:t,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);return s?(alert("No se pudo guardar la nota de seguimiento: "+s.message),!1):(await z(r.name),!0)},Fn=async()=>{const a=Za.trim();if(!a){alert("Escribe primero las opciones de horario o grupo que le vas a ofrecer a la fam
242ilia.");return}await gr(Ws,`Opciones de recuperacion ofrecidas o pendientes de revisar: ${a}`)&&(alert("Seguimiento de recuperacion guardado."),Ge(""))},Tn=async()=>{if(Ae<=0){alert("Este alumno no tiene recuperaciones pendientes abiertas.");return}const a=Za.trim();await gr(Gs,a?`Recuperacion cerrada. Detalle final: ${a}`:"Recuperacion cerrada. Ya se ha ofrecido o programado un hueco operativo.")&&(alert("Recuperacion pendiente cerrada."),Ge(""))},Ln=async()=>{var a;if(r){if(!(r.modality||"").includes("Profe a 3")){alert("De momento esta recolocacion guiada solo esta preparada para recuperaciones dentro de grupos de Academia Profe a 3.");return}fa(!0);try{const t=new Date().toISOString().split("T")[0],s=ht(r.level),{data:n,error:o}=await m.from("classes").select("id, class_date, start_time, end_time, subject, level, modality, monitor_email, student_name, status, opening_reason, recovery_students").gte("class_date",t).eq("status","Pendiente").is("deleted_at",null).order("class_date",{ascending:!0}).order("start_time",{ascending:!0});if(o)throw o;const d=(n||[]).filter(l=>String(l.modality||"").includes("Academia")).map(l=>{const p=go(l.student_name),h=ho(l.recovery_students),b=Vr(l.student_name,l.recovery_students),j=b.length,E=b.some(me=>U(me)===U(r.name)),D=s?uo(ht(l.level),s,l.subject):!1,N=Xs(r,l),O=j===3,F=Sa(l.monitor_email),ee=Se(l.subject)===Se(String(r.subjects||"").split(",")[0]||"");return{...l,teacherName:(F==null?void 0:F.name)||l.monitor_email||"Pendiente",baseStudents:p,recoveryStudents:h,allStudents:b,totalCount:j,alreadyContainsStudent:E,levelCompatible:D,subjectCompatible:N,requiresExceptionalFourth:O,exactSubject:ee}}).filter(l=>l.levelCompatible&&l.subjectCompatible&&!l.alreadyContainsStudent&&l.totalCount<4).sort((l,p)=>l.exactSubject!==p.exactSubject?l.exactSubject?-1:1:l.requiresExceptionalFourth!==p.requiresExceptionalFourth?l.requiresExceptionalFourth?1:-1:l.class_date!==p.class_date?l.class_date.localeCompare(p.class_date):String(l.start_time||"").localeCompare(String(p.start_time||"")));ja(d),je(((a=d[0])==null?void 0:a.id)||""),we(""),ie(!1),He(!0)}catch(t){console.error("Error al cargar huecos de recuperacion:",t),alert("No he podido cargar los grupos operativos para recolocar la recuperacion: "+((t==null?void 0:t.message)||"Error desconocido"))}finally{fa(!1)}}},In=async()=>{if(!r||!w)return;if((r.extra_classes_balance||0)<=0){alert("Antes de colocar la recuperacion, anade primero '+1 Recuperacion (Fin Mes)' en el monedero para que luego el profesor pueda canjearla sin cobrar dos veces.");return}const a=va.find(t=>t.id===ve);if(!a){alert("Selecciona primero el grupo o clase donde quieres recolocar esta recuperacion.");return}if(a.requiresExceptionalFourth&&!Ut){alert("Este hueco ya tiene 3 alumnos. Marca antes que permites la 4a plaza excepcional para esta recuperacion.");return}ya(!0);try{const{data:t,error:s}=await m.from("classes").select("id, class_date, start_time, end_time, subject, level, modality, monitor_email, student_name, opening_reason, recovery_students").eq("id",a.id).is("deleted_at",null).maybeSingle();if(s)throw s;if(!t)throw new Error("La clase ya no existe o ha cambiado.");const n=Vr(t.student_name,t.recovery_students);if(n.some(N=>U(N)===U(r.name)))throw new Error("Este alumno ya estaba metido en esa clase.");if(n.length>=4)throw new Error("Ese grupo ya no tiene hueco libre para recolocar otra recuperacion.");const o=fo(t.recovery_students),d=n.length===3,l={student_name:r.name,student_id:r.student_id||null,source:"recovery_justificada",scheduled_by:w,scheduled_at:new Date().toISOString(),note:wa.trim()||null,requires_exceptional_fourth:d};let p=String(t.opening_reason||"").trim();d&&(p=rt(p,"Grupo excepcional de 4 plazas"),p=rt(p,"Motivo: Recuperacion justificada")),p=rt(p,`Recuperacion programada: ${r.name}`);const{error:h}=await m.from("classes").update({recovery_students:[...o,l],opening_reason:p||null}).eq("id",t.id).is("deleted_at",null);if(h)throw h;const b=String(t.class_date||"").split("-").reverse().join("/"),j=`${String(t.start_time||"--:--").slice(0,5)} - ${String(t.end_time||"--:--").slice(0,5)}`,E=[`Recuperacion programada en ${b} (${j})`,`${x(t.subject||"Refuerzo")} · ${x(t.level||"General")}`,`Con ${a.teacherName}`,d?"Ese dia entra como 4 excepcional.":"Se recoloca dentro de un grupo ya operativo.",wa.trim()?`Nota interna: ${wa.trim()}
242`:""].filter(Boolean).join(" "),{error:D}=await m.from("parent_logs").insert([{student_name:r.name,topic:Hs,notes:E,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);D&&console.error("Error al dejar trazada la recuperacion programada:",D),alert(`Recuperacion colocada en ${b} con ${a.teacherName}.`),He(!1),ja([]),je(""),we(""),ie(!1),await z(r.name)}catch(t){console.error("Error al programar la recuperacion:",t),alert("No se ha podido programar la recuperacion en ese grupo: "+((t==null?void 0:t.message)||"Error desconocido"))}finally{ya(!1)}},Fa=async(a,t,s,n)=>{if(!r)return;const o=t==="end_of_month"?"con validez hasta final de mes":`con validez de ${t} mes${t===1?"":"es"}`;window.confirm(`Vas a anadir ${a} bono(s) a ${r.name} (${s}), ${o}.
243
244Esta recarga quedara reflejada en la bitacora.
245
246¿Confirmas la operacion?`)&&await Mn(a,t,n)},Mn=async(a,t,s)=>{if(!r||!w){alert("Error: Faltan credenciales de administrador. Recarga la pagina.");return}let n=new Date;t==="end_of_month"?n=new Date(n.getFullYear(),n.getMonth()+1,0):n.setMonth(n.getMonth()+t);const o=n.toISOString().split("T")[0],d=(r.extra_classes_balance||0)+a,{error:l}=await m.from("students").update({extra_classes_balance:d,bono_expiry_date:o}).eq("student_id",r.student_id);if(l)alert("Error al recargar bonos: "+l.message);else{const p=(s==null?void 0:s.logMessage)||`Anadidos ${a} bonos. Caducidad: ${o.split("-").reverse().join("/")}. Saldo total: ${d}`,{error:h}=await m.from("parent_logs").insert([{student_name:r.name,topic:(s==null?void 0:s.logTopic)||"COMPRA DE BONO",notes:p,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);h?(console.error("Error al escribir en bitacora:",h),alert("Bono guardado, pero fallo la bitacora: "+h.message)):alert(p),S({...r,extra_classes_balance:d,bono_expiry_date:o}),Z(),z(r.name)}},qn=async()=>{if(!r||!w)return;const{error:a}=await m.from("students").update({extra_classes_balance:ha,bono_expiry_date:We||null}).eq("student_id",r.student_id);if(a)alert("Error al ajustar el monedero: "+a.message);else{const t=`Ajuste manual de administrador. Nuevo saldo: ${ha}. Caducidad: ${We?We.split("-").reverse().join("/"):"Sin definir"}`,{error:s}=await m.from("parent_logs").insert([{student_name:r.name,topic:"AJUSTE MANUAL BONOS",notes:t,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);s&&(console.error("Error al escribir en bitacora:",s),alert("Ajuste guardado, pero fallo la bitacora: "+s.message)),S({...r,extra_classes_balance:ha,bono_expiry_date:We}),Qa(!1),Z(),z(r.name)}},zn=()=>{if(!r)return;const a=At.map(t=>{var p;let s=0,n=0;if(r.subjects&&(n+=50,t.subjects)){const h=r.subjects.toLowerCase().split(",").map(j=>j.trim()),b=t.subjects.toLowerCase();h.some(j=>b.includes(j))&&(s+=50)}r.location&&(n+=30,t.location&&t.location.toLowerCase().includes(r.location.toLowerCase())&&(s+=30)),(p=r.modality)!=null&&p.includes("Domicilio")&&(n+=20,t.has_vehicle&&(s+=20));const o=n===0?0:Math.round(s/n*100),d=Rs[ka(t.email)]||0,l=d>=3;return{...t,matchPercentage:o,currentStudents:d,isFull:l}});a.sort((t,s)=>s.matchPercentage-t.matchPercentage),hs(a),ca(!0)},On=(a,t)=>{if(!r||!r.student_id){alert("Error: Este alumno no tiene un ID valido.");return}da({teacherEmail:a,teacherName:t})},hr=async a=>{if(!r||!r.student_id||!ze){alert("Error: Faltan datos para asignar el tutor academico.");return}const{teacherEmail:t,teacherName:s}=ze;$t(!0);const{error:n}=await m.from("students").update({tutor_email:t}).eq("student_id",r.student_id);if(n)alert("Error de BD: "+n.message);else if(S({...r,tutor_email:t}),ca(!1),Z(),a&&G)try{const o=R(r),d=ls(o,r.name,s),{error:l}=await m.functions.invoke("send-email",{body:{to:A,subject:d.subject,html:d.html}}
246);if(l)throw l;alert(`Tutoria guardada y correo enviado a ${A}.`)}catch(o){console.error("Error al enviar el email a la familia:",o),alert("La tutoria se ha guardado, pero el correo a la familia no se ha podido enviar. No lo reenvies sin comprobar antes la bandeja.")}else alert("Tutoria guardada sin enviar correo a la familia.");$t(!1),da(null)},H=a=>{if(!a||!a.signature_data)return null;try{const t=typeof a.signature_data=="string"?JSON.parse(a.signature_data):a.signature_data;return t.image||t.signatureMethod||t.schemaVersion||t.agreementText?t:{image:a.signature_data,date:"Fecha no disponible",legacy:!0}}catch{return{image:a.signature_data,date:"Fecha no disponible",legacy:!0}}},Un=()=>{var s;const a=document.getElementById("printable-student-contract");if(!a)return;const t=window.open("","_blank");t&&(t.document.write(`
247              <html>
248                  <head>
249                      <title>Acuerdo_${(s=r==null?void 0:r.name)==null?void 0:s.replace(/\s+/g,"_")}</title>
250                      <script src="https://cdn.tailwindcss.com"><\/script>
251                      <style>
252                          @page { margin: 20mm; }
253                          body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
254                      </style>
255                  </head>
256                  <body class="bg-white text-black font-sans p-8 max-w-4xl mx-auto">
257                      ${a.innerHTML}
258                  </body>
259              </html>
260          `),t.document.close(),t.focus(),setTimeout(()=>{t.print(),t.close()},1e3))},R=a=>{const t=ts(a);return t||"-"},Bn=()=>{const a=new Date,t=a.getFullYear(),s=a.getMonth(),n=`${t}-${String(s+1).padStart(2,"0")}-01`,o=`${t}-${String(s+1).padStart(2,"0")}-${String(new Date(t,s+1,0).getDate()).padStart(2,"0")}`,d=new Date(t,s,1).toLocaleDateString("es-ES",{month:"long"}),l=d.charAt(0).toUpperCase()+d.slice(1);return{reservationYear:t,reservationMonth:s,monthStart:n,monthEnd:o,monthName:l}},fr=async()=>{const{monthStart:a,monthEnd:t,monthName:s,reservationYear:n}=Bn(),{data:o,error:d}=await m.from("parent_logs").select("student_name, notes").in("topic",[Xt,Zt,"🧾 RECIBO MENSUAL"]).gte("contact_date",a).lte("contact_date",t);if(d)throw d;const l=new Set;return(o||[]).forEach(p=>{String((p==null?void 0:p.notes)||"").includes(`${s} ${n}`)&&(p!=null&&p.student_name)&&l.add(U(p.student_name))}),l},yr=async(a,t,s,n)=>{const{error:o}=await m.from("parent_logs").insert([{student_name:a.name,topic:Xt,notes:`Recibo mensual por adelantado Profe a 3 enviado por email (${s} ${n}) [${t}] a ${ue(a)}. Incluye sesiones reservadas y compromiso de asistencia.`,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);if(o)throw o},Wn=async(a,t,s)=>{const{error:n}=await m.from("parent_logs").insert([{student_name:a.name,topic:Kt,notes:`Recibo mensual por adelantado Profe a 3 preparado para WhatsApp (${t} ${s}) para ${R(a)}. Abrir WhatsApp no confirma el envio.`,contact_date:new Date().toISOString().split("T")[0],coordinator_id:w}]);if(n)throw n},Gn=(a,t)=>{ms(a),us(`
261        <!DOCTYPE html>
262        <html lang="es">
263          <head>
264            <meta charset="UTF-8" />
265            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
266            <title>${a}</title>
267            <style>
268              body {
269                margin: 0;
270                background: #f5f7fa;
271                font-family: Arial, sans-serif;
272              }
273              .preview-shell {
274                max-width: 920px;
275                margin: 0 auto;
276                padding: 24px 16px 48px;
277              }
278              .preview-label {
279                font-size: 12px;
280                font-weight: 700;
281                letter-spacing: 0.12em;
282                text-transform: uppercase;
283                color: #6b7280;
284                margin-bottom: 12px;
285              }
286            </style>
287          </head>
288          <body>
289            <div class="preview-shell">
290              <div class="preview-label">Vista previa del recibo mensual por adelantado</div>
291              ${t}
292            </div>
293          </body>
294        </html>
295      `),kt(!0)},vr=async()=>{const a=await fr(),t={pending:[],alreadySent:[],missingEmail:[],noClasses:[],skippedNonAcademy:[],failed:[]},s=[...Ce].sort((n,o)=>(n.name||"").localeCompare(o.name||""));
295for(const n of s){if(!at(n)){t.skippedNonAcademy.push(n);continue}if(!ue(n)){t.missingEmail.push(n);continue}if(a.has(U(n.name))){t.alreadySent.push(n);continue}try{const o=await Ta(n);t.pending.push({student:n,payload:o})}catch(o){const d=String((o==null?void 0:o.message)||"Error desconocido");d.toLowerCase().includes("todavia no hay clases")?t.noClasses.push(n):t.failed.push({student:n,error:d})}}return t},Hn=async()=>{St(!0);try{const a=await vr();alert(`Resumen de recibos Profe a 3 del mes:
296
297Pendientes de envio: ${a.pending.length}
298Ya enviadas este mes: ${a.alreadySent.length}
299Sin email: ${a.missingEmail.length}
300Sin clases este mes: ${a.noClasses.length}
301Domicilio/online omitidos: ${a.skippedNonAcademy.length}
302Con incidencia: ${a.failed.length}`)}catch(a){alert("Error al preparar el resumen de recibos: "+((a==null?void 0:a.message)||"Error desconocido"))}finally{St(!1)}},Vn=()=>{r&&(L(ar(r,oe)),W(""),ye(!0))},Yn=async()=>{if(!(r!=null&&r.student_id))return;const a=Number(u.sessionPrice.replace(",",".")),t=Wo({studentName:r.name,modality:u.modality,levelAndSubjects:u.levelAndSubjects,weeklyFrequency:u.weeklyFrequency,regularSchedule:u.regularSchedule,sessionDuration:u.sessionDuration,sessionPriceValue:a,startDate:u.startDate});if(!u.signerName.trim()){W("Escribe el nombre de la persona que ha firmado.");return}if(!u.signerRole){W("Indica la relación con el alumno o alumna.");return}if(!u.signedDate){W("Indica la fecha que aparece en la copia firmada.");return}if(!u.paperCopyStored){W("Confirma que la copia firmada está guardada antes de registrar la firma.");return}if(!t.readyToSign){W(`Completa antes: ${t.missingFields.join(", ")}.`);return}const s=new Date(`${u.signedDate}T12:00:00`),n=new Date,o={academy:"Firmado en la academia",whatsapp:"Copia firmada recibida por WhatsApp",email:"Copia firmada recibida por correo electrónico"},d=JSON.stringify({schemaVersion:4,signatureMethod:"paper",signedAt:s.toISOString(),date:s.toLocaleDateString("es-ES"),signerName:u.signerName.trim(),signerRole:u.signerRole,agreementTitle:Ho(t.modalityKey),agreementVersion:ns(t.modalityKey),agreementText:Go(t),agreementDetails:t,paperReceiptMethod:u.receiptMethod,paperReceiptMethodLabel:o[u.receiptMethod],paperCopyStored:!0,recordedAt:n.toISOString(),recordedBy:w,confirmations:{agreementAccepted:!0},source:"admin_paper_copy"});Oe(!0),W("");const{error:l}=await m.from("students").update({contract_signed:!0,signature_data:d}).eq("student_id",r.student_id);if(l){Oe(!1),W(`No se pudo registrar la firma: ${l.message}`);return}const p={...r,contract_signed:!0,signature_data:d};Ye(p),await m.from("parent_logs").insert([{student_name:r.name,contact_date:n.toISOString().slice(0,10),topic:"ACUERDO FAMILIAR",notes:`${o[u.receiptMethod]}. Copia archivada. Versión ${ns(t.modalityKey)}.`,coordinator_id:w}]),Oe(!1),ye(!1),await z(r.name)},Jn=async()=>{Ct(!0);try{const a=await vr();if(a.pending.length===0){alert(`No hay recibos Profe a 3 pendientes para enviar ahora mismo.
303
304Ya enviadas este mes: ${a.alreadySent.length}
305Sin email: ${a.missingEmail.length}
306Domicilio/online omitidos: ${a.skippedNonAcademy.length}
307Sin clases este mes: ${a.noClasses.length}`);return}const t=a.pending.slice(0,6).map(l=>l.student.name).join(", ");if(!window.confirm(`Vas a enviar ${a.pending.length} recibos mensuales por adelantado.
308
309Ya enviadas este mes: ${a.alreadySent.length}
310Sin email: ${a.missingEmail.length}
311Domicilio/online omitidos: ${a.skippedNonAcademy.length}
312Sin clases este mes: ${a.noClasses.length}
313
314Primeras familias: ${t}${a.pending.length>6?"...":""}
315
316¿Continuar con el envio global?`))return;let n=0;const o=[],d=[];for(const l of a.pending){let p=!1;try{await bt({to:l.payload.to,subject:l.payload.subject,html:l.payload.html}),p=!0,await yr(l.student,"global",l.payload.monthName,l.payload.year),n+=1}catch(h){const b=(h==null?void 0:h.message)||"Error desconocido";p?d.push(`${l.student.name}: ${b}`):o.push(`${l.student.name}: ${b}`)}}alert(`Envio global terminado.
317
318Enviadas: ${n}
319Aceptadas sin registro interno: ${d.length}
320Fallidas antes del envio: ${o.length}`+(d.length>0?`
321
322No reenvies estos recibos hasta revisar la trazabilidad:
323- ${d.slice(0,5).join(`
324- `)}`:"")+(o.length>0?`
325
326Incidencias:
327- ${o.slice(0,5).join(`
328- `)}`:""))}catch(a){alert("Error al lanzar el envio global de recibos: "+((a==null?void 0:a.message)||"Error desconocido"))}finally{Ct(!1)}},Xn=async()=>{const{data:a,error:t}=await m.from("global_settings").select("setting_value").eq("id","pricing_rules").maybeSingle();if(t)throw t;return jo(a==null?void 0:a.setting_value)},Ta=async a=>{if(!at(a))throw new Error("Este recibo detallado solo se prepara para familias de Academia Profe a 3. Domicilio y online se gestionan desde el area general de recibos.");const t=ue(a);if(!t)throw new Error("Esta familia no tiene un correo guardado.");const s=new Date,n=s.getFullYear(),o=s.getMonth(),d=`${n}
328-${String(o+1).padStart(2,"0")}-01`,l=`${n}-${String(o+1).padStart(2,"0")}-${String(new Date(n,o+1,0).getDate()).padStart(2,"0")}`,[p,h,b]=await Promise.all([m.from("classes").select("class_date, start_time, end_time, subject, level, modality, monitor_email, family_price, student_name, status").gte("class_date",d).lte("class_date",l).neq("status","Cancelada").is("deleted_at",null).order("class_date",{ascending:!0}).order("start_time",{ascending:!0}),Xn(),m.from("holidays").select("name, start_date, end_date").lte("start_date",l)]),{data:j,error:E}=p,{data:D,error:N}=b;if(E)throw E;if(N)throw new Error(`No se ha podido comprobar el calendario de festivos: ${N.message}`);const O=(D||[]).filter(f=>(f.end_date||f.start_date)>=d),F=U(a.name),ee=(j||[]).filter(f=>Gt(f.modality||a.modality)&&Yr(f.student_name).map(Fe=>U(Fe)).includes(F)),me=ee.filter(f=>!Co(String(f.class_date||""),O));if(me.length===0)throw ee.length>0?new Error("Las clases programadas de este mes coinciden con festivos o cierres y no deben incluirse en el recibo."):new Error("Todavia no hay clases de Academia Profe a 3 programadas este mes para este alumno en Agenda Centro.");const Re=new Date(n,o,1).toLocaleDateString("es-ES",{month:"long"}),De=Re.charAt(0).toUpperCase()+Re.slice(1),pt=Ca(a),mt=Wt(),Mr=me.map(f=>{const Fe=new Date(`${f.class_date}T12:00:00`),Ur=Fe.toLocaleDateString("es-ES",{weekday:"long"}),so=Ur.charAt(0).toUpperCase()+Ur.slice(1),ut=Sa(f.monitor_email),Br=Yr(f.student_name),no=Br.map(oo=>Jr(oo)).filter(Boolean),La=Br.length||1,Wr=yo({storedFamilyPrice:Number(f.family_price)||0,modality:f.modality||a.modality,level:f.level||a.level,participantCount:La,startTime:f.start_time,endTime:f.end_time,pricingRules:h});return{session:{dateLabel:Fe.toLocaleDateString("es-ES",{day:"2-digit",month:"2-digit"}),weekdayLabel:so,timeLabel:`${(f.start_time||"--:--").substring(0,5)} - ${(f.end_time||"--:--").substring(0,5)}`,subjectLabel:f.subject||"Refuerzo general",levelLabel:f.level||a.level||"General",modalityLabel:f.modality||a.modality||"Sin definir",teacherName:(ut==null?void 0:ut.name)||f.monitor_email||"Pendiente de asignar",groupLabel:La>1?`Grupo actual de ${La} alumnos`:"Clase individual",participantsLabel:La>1?vo(no):Jr(a.name),slotPriceLabel:`${Wr.familyPerStudent.toFixed(2)}&euro; por clase`},classShare:Wr.familyPerStudent}}),xe=Mr.map(f=>f.session),xt=Mr.reduce((f,Fe)=>f+Fe.classShare,0),qr=Array.from(new Set(xe.map(f=>f.teacherName))).join(", "),zr=Array.from(new Set(xe.map(f=>f.slotPriceLabel).filter(Boolean))),Or=Array.from(new Set(xe.map(f=>f.participantsLabel).filter(Boolean))),ao=zr.length===1?`${xe.length} clases x ${zr[0]}`:"Importe del recibo segun las sesiones reservadas",to=Or.length===1?`Grupo previsto actualmente: ${Or[0]}. El recibo incluye las plazas reservadas del mes. Si la familia solicita clases extra despues de emitirlo, se gestionaran aparte sin modificar este documento.`:`El recibo se ha calculado con la tarifa vigente y el aforo actual de cada grupo Profe a 3 programado en ${De} ${n}. Si la familia solicita clases extra despues de emitirlo, se gestionaran aparte sin modificar este documento.`,ro=Ko({parentName:R(a),studentName:a.name,monthName:De,year:n,reservedAmount:xt,sessionCount:xe.length,teacherSummary:qr||"Pendiente de definir",appUrl:mt});return{to:t,monthName:De,year:n,reservedAmount:xt,sessionCount:xe.length,html:Xo({parentName:R(a),studentName:a.name,monthName:De,year:n,tutorName:(pt==null?void 0:pt.name)||"Pendiente de confirmar",teacherSummary:qr||"Pendiente de definir",reservedAmount:xt,sessions:xe,appUrl:mt,logoUrl:`${mt}/logo-profe-cuadrado.jpg`,pricingHeadline:ao,pricingSupportText:to,paymentReminderText:"En Profe a 3 trabajamos con grupos muy reducidos. Por eso, asistir con regularidad ayuda al alumno a mantener continuidad, cuida el ritmo del grupo y respeta el tiempo reservado del profesor. Si una ausencia esta debidamente justificada, intentaremos ofrecer una recuperacion en otro grupo disponible, aunque no siempre puede garantizarse. Los festivos o dias en los que no haya clase no se cobran."}
328),subject:`Recibo mensual por adelantado - ${De} ${n} - ${a.name}`,whatsappText:ro}},Kn=async()=>{if(Qe){alert("Esta ficha tiene dos correos familiares distintos. Revisa y unifica el correo antes de enviar.");return}if(!A){alert("Esta familia no tiene un correo guardado.");return}jt(!0);let a=!1;try{if((await fr()).has(U(r.name))){alert("Este alumno ya tiene un recibo mensual registrado para este mes. No se ha enviado de nuevo.");return}const s=await Ta(r);await bt({to:s.to,subject:s.subject,html:s.html}),a=!0,await yr(r,"individual",s.monthName,s.year),await z(r.name),alert(`Recibo mensual enviado correctamente a ${s.to}.`)}catch(t){const s=(t==null?void 0:t.message)||"Error desconocido";console.error("Error al enviar el recibo mensual:",t),alert(a?`El correo ha sido aceptado, pero no se ha podido registrar. No lo reenvies hasta revisar la trazabilidad.
329
330${s}`:`Error al enviar el recibo mensual: ${s}`)}finally{jt(!1)}},Qn=async()=>{if(Qe){alert("Esta ficha tiene dos correos familiares distintos. Revisa y unifica el correo antes de continuar.");return}if(!A){alert("Esta familia no tiene un correo guardado.");return}Nt(!0);try{const a=await Ta(r);Gn(a.subject,a.html)}catch(a){console.error("Error al previsualizar el recibo mensual:",a),alert("Error al preparar la vista previa del recibo: "+((a==null?void 0:a.message)||"Error desconocido"))}finally{Nt(!1)}},Zn=async()=>{if(!(r!=null&&r.phone)||r.phone.length<5){alert("Esta familia no tiene un telefono valido guardado para enviar WhatsApp.");return}wt(!0);try{const a=await Ta(r);await Wn(r,a.monthName,a.year),await z(r.name),le(r.phone,a.whatsappText)}catch(a){console.error("Error al preparar el WhatsApp del recibo mensual:",a),alert("Error al preparar el WhatsApp del recibo mensual: "+((a==null?void 0:a.message)||"Error desconocido"))}finally{wt(!1)}},eo=()=>{const a=ot.find(Je)||Ze[0];if(!a){alert("Ahora mismo no hay familias pendientes de completar ficha.");return}S(a)};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",children:[g&&e.jsxs("button",{onClick:g,className:"text-gray-400 text-[10px] font-black uppercase mb-6 flex items-center gap-2 hover:text-[#1c74e9] transition-colors",children:["<-"," Volver al Panel"]}),e.jsxs("header",{className:"mb-6 flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-black italic text-gray-900 leading-none",children:"Alumnos"}),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 shadow-sm",children:V?"Cargando datos...":`${Ea.length} alumnos activos + ${st.length} archivados`})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>alert(`Enlace de matricula publica:
331
332app.profe-en-casa.com/matricula`),className:"bg-white w-12 h-12 rounded-2xl shadow-sm border border-gray-100 text-[10px] font-black uppercase tracking-widest flex items-center justify-center active:scale-90 transition-transform hover:border-blue-200",title:"Copiar enlace de matricula",children:"Link"}),e.jsx("button",{onClick:()=>Ja(!0),className:"bg-[#1c74e9] text-white w-12 h-12 rounded-2xl shadow-lg shadow-blue-500/30 text-2xl font-black flex items-center justify-center active:scale-90 transition-transform",title:"Alta Manual",children:"+"})]})]}),e.jsxs("div",{className:"mb-6 bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-violet-600 text-[10px] font-black uppercase tracking-widest mb-1",children:"Recibo mensual Profe a 3"}),e.jsx("h2",{className:"text-gray-900 font-black text-lg leading-tight",children:"Envio global a familias"}),e.jsx("p",{className:"text-gray-500 text-xs mt-2 leading-relaxed",children:"Revisa los recibos adelantados de Academia Profe a 3. Este circuito comparte el control de duplicados con el area general de recibos."})]}),e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-violet-50 border border-violet-100 flex items-center justify-center text-[10px] font-black uppercase tracking-widest shrink-0 text-violet-700",children:"Mes"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("button",{onClick:Hn,disabled:Me||qe||V,className:`py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${Me||qe||V?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:Me?"Calculando...":"Resumen Del Mes"}),e.jsx("button",{onClick:Jn,disabled:Me||qe||V,className:`py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${Me||qe||V?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-violet-500 text-white shadow-lg shadow-violet-500/20 hover:bg-violet-600"}`,children:qe?"Enviando...":"Enviar Pendientes"})]})]}),e.jsxs("div",{className:"mb-6 bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-amber-600 text-[10px] font-black uppercase tracking-widest mb-1",children:"Fichas de familia"}),e.jsx("h2",{className:"text-gray-900 font-black text-lg leading-tight",children:"Pendientes de completar"}),e.jsx("p",{className:"text-gray-500 text-xs mt-2 leading-relaxed",children:"Localiza rapido a las familias que todavia deben revisar email, telefono o direccion y abre el siguiente caso sin perder tiempo."})]}),e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-amber-50 border border-amber-100 flex items-center justify-center text-[10px] font-black uppercase tracking-widest shrink-0 text-amber-700",children:"Ficha"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-4",children:[e.jsxs("div",{className:"rounded-2xl border border-orange-100 bg-orange-50 px-3 py-3 text-center",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-orange-700",children:"Pendientes"}),e.jsx("p",{className:"text-xl font-black text-gray-900 mt-1",children:Ze.length})]}),e.jsxs("div",{className:"rounded-2xl border border-amber-100 bg-amber-50 px-3 py-3 text-center",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-amber-700",children:"Solicitadas"}),e.jsx("p",{className:"text-xl font-black text-gray-900 mt-1",children:bn.length})]}),e.jsxs("div",{className:"rounded-2xl border border-emerald-100 bg-emerald-50 px-3 py-3 text-center",children:[e.jsx("p",{className:"text-[8px] font-black uppercase tracking-widest text-emerald-700",children:"Al dia"}),e.jsx("p",{className:"text-xl font-black text-gray-900 mt-1",children:gn.length})]})]}),Ra.length>0&&e.jsxs("button",{type:"button",onClick:()=>S(Ra[0]),className:"mb-4 w-full rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-left text-[10px] font-black uppercase tracking-wide text-red-700 hover:bg-red-100",children:["Revisar correos: ",Ra.length," ficha",Ra.length===1?"":"s"," con dos direcciones distintas"]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("button",{onClick:()=>Ss(!ga),className:`py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${ga?"bg-amber-500 text-white shadow-lg shadow-amber-500/20":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:ga?"Ver todas":"Ver pendientes"}),e.jsx("button",{onClick:eo,disabled:Ze.length===0,className:`py-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all ${Ze.length===0?"bg-gray-200 text-gray-400 cursor-not-allowed":"bg-amber-500 text-white shadow-lg shadow-amber-500/20 hover:bg-amber-600"}`,children:"Abrir siguiente"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-6 bg-gray-200/50 p-1 rounded-xl",children:[e.jsxs("button",{onClick:()=>re("activos"),className:`flex-1 py-3 text-[10px] font-black uppercase tracking-widest rounded-lg transition-all flex items-center justify-center gap-2 ${$==="activos"?"bg-white text-[#1c74e9] shadow-sm border border-blue-100":"text-gray-500 hover:text-gray-700"}`,children:["Activos 26/27 (",Ce.length,")"]}),e.jsxs("button",{onClick:()=>re("espera"),className:`flex-1 py-3 text-[10px] font-black uppercase tracking-widest rounded-lg transition-all flex items-center justify-center gap-2 ${$==="espera"?"bg-white text-orange-600 shadow-sm border border-orange-100":"text-gray-500 hover:text-gray-700"}`,children:["Por confirmar ",nt.length>0&&e.jsx("span",{className:"bg-orange-500 text-white min-w-4 h-4 px-1 flex items-center justify-center rounded-full text-[8px]",children:nt.length})]}),e.jsxs("button",{onClick:()=>re("baja"),className:`flex-1 py-3 text-[10px] font-black uppercase tracking-widest rounded-lg transition-all flex items-center justify-center gap-2 ${$==="baja"?"bg-white text-rose-600 shadow-sm border border-rose-100":"text-gray-500 hover:text-gray-700"}`,children:["Bajas (",st.length,")"]})]}),$==="activos"&&nr>0&&e.jsx("div",{className:"mb-4",children:e.jsxs("button",{onClick:()=>_s(!Ue),className:`w-full flex items-center justify-center gap-2 py-3 rounded-2xl text-[10px] font-black uppercase tracking-widest shadow-sm transition-all ${Ue?"bg-red-500 text-white shadow-red-500/30":"bg-red-50 text-red-600 border border-red-100 hover:bg-red-100"}`,children:[e.jsx("span",{className:Ue?"animate-pulse":"",children:"ALR"}),Ue?"Ver todos los alumnos":`Atencion: ${nr} activos en riesgo de fuga`]})}),e.jsxs("div",{className:"mb-6 relative",children:[e.jsx("input",{type:"text",placeholder:"Buscar alumno, tutor, localidad...",value:te,onChange:a=>he(a.target.value),className:"w-full bg-white border border-gray-100 p-4 pl-12 rounded-[20px] text-sm font-bold outline-none focus:border-[#1c74e9] shadow-sm transition-all"}),e.jsx("span",{className:"absolute left-4 top-4 opacity-40 text-sm font-black uppercase tracking-widest",children:"BUS"})]}),lo,e.jsx("div",{className:"space-y-3",children:V?e.jsx("div",{className:"flex flex-col items-center py-20",children:e.jsx("div",{className:"w-8 h-8 border-4 border-[#1c74e9] border-t-transparent roun
332ded-full animate-spin mb-4"})}):ot.length===0?e.jsxs("div",{className:"bg-white p-10 rounded-[32px] border border-gray-100 text-center shadow-sm",children:[e.jsx("span",{className:"text-2xl block mb-3 opacity-50 font-black uppercase tracking-widest",children:"CRM"}),e.jsx("p",{className:"text-gray-900 font-bold text-sm",children:"No hay alumnos aqui"}),e.jsx("p",{className:"text-gray-400 text-[10px] mt-1",children:"No hay fichas en esta bandeja con el criterio actual."})]}):ot.map(a=>{var N;const t=$==="espera",s=$==="baja",n=!s&&a.student_id?J[a.student_id]:void 0,o=Da(a.created_at),d=Ca(a),p=tt(a).map(O=>O.name||O.email),h=Jt(a),b=sr(a);let j="border-gray-100",E="bg-blue-50 text-blue-600";t&&(o>72?(j="border-red-500 shadow-[0_0_15px_rgba(239,68,68,0.2)]",E="bg-red-500 text-white animate-pulse"):o>48?(j="border-orange-400",E="bg-orange-500 text-white"):(j="border-green-400",E="bg-green-500 text-white"));const D=s?"border-rose-200 bg-rose-50/40":(n==null?void 0:n.level)==="alta"?"border-red-400 bg-red-50/20":(n==null?void 0:n.level)==="media"?"border-orange-400 bg-orange-50/20":j;return e.jsxs("div",{onClick:()=>S(a),className:`bg-white p-5 rounded-[24px] border shadow-[0_4px_15px_rgba(0,0,0,0.02)] flex items-center justify-between cursor-pointer transition-all active:scale-[0.98] group relative overflow-hidden ${D}`,children:[!t&&(n==null?void 0:n.level)==="alta"&&e.jsx("span",{className:"absolute top-2 right-2 text-[8px] font-black uppercase tracking-widest text-red-600 bg-red-50 border border-red-100 rounded-full px-2 py-1",children:"Alerta"}),!t&&(n==null?void 0:n.level)==="media"&&e.jsx("span",{className:"absolute top-2 right-2 text-[8px] font-black uppercase tracking-widest text-orange-600 bg-orange-50 border border-orange-100 rounded-full px-2 py-1",children:"Revisar"}),t&&e.jsxs("div",{className:`absolute top-0 right-0 px-3 py-1 rounded-bl-xl text-[8px] font-black uppercase ${E}`,children:[o,"h Esperando"]}),e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[e.jsx("div",{className:`w-12 h-12 border rounded-2xl flex items-center justify-center text-sm font-black shrink-0 transition-colors relative ${!t&&n?n.level==="alta"?"bg-red-100 border-red-200 text-red-700":"bg-orange-100 border-orange-200 text-orange-700":"bg-blue-50 border-blue-100 text-[#1c74e9] group-hover:bg-[#1c74e9] group-hover:text-white"}`,children:Vt(a.name)}),e.jsxs("div",{className:"min-w-0 pr-2",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("h3",{className:"font-black text-gray-900 text-sm leading-tight truncate",children:a.name}),!s&&!t&&(a.is_recurring!==!1?e.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shadow-[0_0_5px_rgba(34,197,94,0.5)]",title:"Alumno Recurrente"}):e.jsx("span",{className:"w-2 h-2 rounded-full bg-gray-300",title:"Alumno Suelto (No recurrente)"}))]}),e.jsx("p",{className:`text-[10px] font-bold uppercase tracking-tighter truncate ${s?"text-rose-500":n?n.level==="alta"?"text-red-500":"text-orange-500":"text-gray-400"}`,children:n?"Revision necesaria":x(`${a.level||"Nivel no asignado"} - ${a.location||"Sin zona"}`)}),e.jsx("div",{className:"mt-1",children:e.jsx("span",{className:`inline-flex px-2 py-1 rounded-md text-[8px] font-black uppercase tracking-widest ${b.tone==="done"?"bg-emerald-50 text-emerald-700 border border-emerald-100":b.tone==="pending"?"bg-amber-50 text-amber-700 border border-amber-100":"bg-gray-50 text-gray-500 border border-gray-100"}`,children:b.label})}),d&&e.jsxs("p",{className:"text-[9px] font-black uppercase text-amber-600 mt-1",children:["Tutoria: ",x(d.name||d.email)]}),p.length>0&&e.jsxs("p",{className:"text-[9px] font-black uppercase text-blue-600 mt-1",children:["Agenda: ",x(p.join(", "))]}),((N=h==null?void 0:h.siblingNames)==null?void 0:N.length)>0&&e.jsxs("p",{className:"text-[9px] font-black uppercase text-purple-600 mt-1",children:["Posible hermano: ",x(h.siblingNames.join(", "))]})]})]}),e.jsx("span",{className:"text-gray-300 group-hover:text-[#1c74e9] transition-colors text-xl font-black shrink-0",children:">"})]},a.student_id||a.name)})}),r&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm z-[9999] p-4 flex items-center justify-center animate-in fade-in",children:e.jsxs("div",{className:"bg-white w-full max-w-sm rounded-[40px] shadow-2xl relative overflow-hidden flex flex-col max-h-[90vh] animate-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#1c74e9] to-blue-800 p-8 text-center text-white shrink-0 relative",children:[e.jsx("button",{onClick:()=>S(null),className:"absolute top-4 right-4 text-white/50 hover:text-white bg-white/10 w-8 h-8 rounded-full font-bold",children:"X"}),e.jsx("div",{className:"w-20 h-20 bg-white/20 rounded-[24px] mx-auto flex items-center justify-center text-2xl font-black mb-4 backdrop-blur-md shadow-inner border border-white/20",children:Vt(r.name)}),e.jsx("h3",{className:"font-black text-2xl tracking-tight leading-none",children:r.name}),e.jsx("p",{className:"text-blue-200 text-[10px] font-black uppercase tracking-widest mt-2",children:cr})]}),e.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto scrollbar-hide bg-[#F5F7FA]",children:[_a(r)&&e.jsxs("div",{className:"p-4 rounded-[24px] border border-rose-200 bg-rose-50 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-rose-700 mb-2",children:"Alumna dada de baja"}),e.jsxs("p",{className:"text-sm font-bold text-gray-900 leading-tight",children:["Baja archivada el ",Bt(r.archived_at)||"sin fecha","."]}),e.jsx("p",{className:"text-[11px] text-rose-700 mt-2 leading-relaxed",children:x(r.archived_reason||"Sin motivo indicado.")}),e.jsx("p",{className:"text-[10px] text-gray-500 font-bold mt-2",children:"La ficha sigue guardada y puede reactivarse en cualquier momento."})]}),r.student_id&&J[r.student_id]&&$==="activos"&&e.jsxs("div",{className:`p-4 rounded-[24px] border shadow-sm ${J[r.student_id].level==="alta"?"bg-red-50 border-red-200":"bg-orange-50 border-orange-200"}`,children:[e.jsx("p",{className:`text-[10px] font-black uppercase tracking-widest flex items-center gap-1 mb-2 ${J[r.student_id].level==="alta"?"text-red-600":"text-orange-600"}`,children:J[r.student_id].level==="alta"?"Riesgo alto de fuga":"Atencion recomendada"}),e.jsx("p",{className:"text-sm font-bold text-gray-900 leading-tight mb-4",children:x(J[r.student_id].reason)}),e.jsx("button",{onClick:()=>le(r.phone,`Hola ${R(r)}. Soy Francisco de Profe en Casa. Estaba revisando la ficha de ${r.name} y queria preguntarte que tal va todo ultimamente. ¿Teneis un ratito para que hablemos?`),className:`w-full text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl active:scale-95 transition-transform flex items-center justify-center gap-2 shadow-lg ${J[r.student_id].level==="alta"?"bg-red-500 shadow-red-500/30":"bg-orange-500 shadow-orange-500/30"}`,children:"Enviar WhatsApp de rescate"})]}),$==="espera"&&((wr=r.modality)==null?void 0:wr.includes("Domicilio"))&&e.jsxs("div",{className:"p-4 rounded-[24px] border border-blue-200 bg-blue-50 shadow-sm animate-pulse",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest flex items-center gap-1 mb-2 text-blue-600",children:"Reclutamiento express"}),e.jsxs("p",{className:"text-sm font-bold text-gray-900 leading-tight mb-4",children:["¿No hay profes en ",x(r.location),"? Genera un anuncio con los datos de este alumno y publicalo al instante."]}),e.jsx("button",{onClick:En,className:"w-full text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl active:scale-95 transition-transform flex items-center justify-center gap-2 shadow-lg bg-blue-600 shadow-blue-500/30",children:"Copiar anuncio y publicar"})]}),$==="espera"&&Da(r.created_at)>48&&e.jsxs("div",{className:"p-4 rounded-[24px] border border-red-200 bg-red-50 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest flex items-center gap-1 mb-2 text-red-600",children:"Peligro de enfriamiento"}),e.jsxs("p",{className:"text-sm font-bold text-gray-900 leading-tight mb-4",children:["Este alumno lleva mas de ",Da(r.created_at),"h esperando profesor a domicilio. Conviene llamarle para ofrecerle la alternativa online sin cambiar la tarifa acordada."]}),e.jsx("button",{onClick:()=>le(r.phone,`Hola ${R(r)}. Soy Francisco de Direccion de Profe en Casa. Estamos revisando profesores para el domicilio, pero todavía no hemos encontrado un horario compatible. Para no perder mas dias, ¿os interesaria que comprobemos tambien una opcion online mientras seguimos buscando? Antes de confirmar nada os indicaremos horario y precio.`),className:"w-full text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl active:scale-95 transition-transform flex items-center justify-center gap-2 shadow-lg bg-red-500 shadow-red-500/30",children:"WhatsApp de pivote"})]}),((Nr=ce==null?void 0:ce.siblingNames)==null?void 0:Nr.length)>0&&e.jsxs("div",{className:"p-4 rounded-[24px] border border-purple-200 bg-purple-50 shadow-sm",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest flex items-center gap-1 mb-2 text-purple-700",children:"Familia vinculada"}),e.jsxs("p",{className:"text-sm font-bold text-gray-900 leading-tight",children:["Esta ficha coincide con ",e.jsx("span",{className:"text-purple-700",children:x(ce.siblingNames.join(", "))}),"."]}),e.jsxs("p",{className:"text-[10px] text-purple-700 font-bold mt-2 uppercase tracking-widest",children:["Detectado por ",x(on)]}),e.jsx("p",{className:"text-[10px] text-gray-500 font-bold mt-2 leading-relaxed",children:"Usalo como pista rapida para revisar si comparten familia y, cuando corresponda, unificar el acceso familiar sin modificar precios automaticamente."}),T&&e.jsx("button",{onClick:()=>T(r.name),className:"w-full mt-4 bg-purple-600 text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg shadow-purple-500/30 active:scale-95 transition-transform flex items-center justify-center gap-2",children:"Revisar en facturacion"})]}),!1,Xe.length>0&&de&&e.jsx("div",{className:"p-4 rounded-[24px] border border-amber-200 bg-amber-50 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-amber-700 mb-2",children:"Proximo examen"}),e.jsxs("p",{className:"text-sm font-bold text-gray-900 leading-tight",children:[r.name," tiene ",Xe.length===1?"1 examen previsto":`${Xe.length} examenes previstos`," en los proximos 7 dias."]}),e.jsxs("p",{className:"text-[11px] text-amber-800 font-bold mt-3 leading-5",children:[x(de.subject)," · ",yt(de.exam_date)," · ",x(de.urgency_label)]}),de.unit&&e.jsx("p",{className:"text-[10px] text-amber-700 font-bold mt-2 leading-relaxed",children:x(de.unit)})]}),e.jsx("span",{className:"shrink-0 bg-white text-amber-700 border border-amber-200 px-3 py-1 rounded-full text-[9px] font-black uppercase tracking-widest",children:de.urgency_label})]})}),e.jsx("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm relative overflow-hidden",children:(()=>{const a=Ca(r),t=tt(r);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest",children:"Tutor academico"}),Ve(r)?e.jsx("span",{className:"bg-blue-50 text-[#1c74e9] text-[8px] font-black uppercase px-2 py-1 rounded",children:"Asignado"}):e.jsx("span",{className:"bg-orange-50 text-orange-600 text-[8px] font-black uppercase px-2 py-1 rounded animate-pulse",children:"Sin tutor"})]}),Ve(r)?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 bg-blue-50 text-[#1c74e9] rounded-full flex items-center justify-center text-[10px] font-black",children:"TUT"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-black text-gray-900 text-sm",children:(a==null?void 0:a.name)||Ve(r)}),e.jsx("p",{className:"text-[9px] text-gray-500 font-bold mt-1 leading-relaxed",children:"La tutoria acompana al alumno aunque luego pueda tener distintas clases o grupos con otros profes desde Agenda Centro."})]})]}):e.jsxs("div",{className:"text-center py-2",children:[e.jsxs("p",{className:"text-red-500 text-xs font-bold mb-3",children:["Sin tutor asignado (",Da(r.created_at),"h)"]}),e.jsx("button",{onClick:zn,className:"w-full bg-gradient-to-r from-purple-600 to-blue-500 text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg shadow-purple-500/30 flex items-center justify-center gap-2 active:scale-95 transition-transform",children:"Buscar tutor ideal 
332(Smart Match)"})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-100",children:[e.jsx("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest mb-2",children:"Profesorado en Agenda"}),t.length>0?e.jsxs("div",{className:"space-y-2",children:[t.map(s=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 bg-indigo-50 text-indigo-600 rounded-full flex items-center justify-center text-[9px] font-black",children:"AGEN"}),e.jsx("p",{className:"text-sm font-black text-gray-900",children:s.name||s.email})]},s.id||s.email)),e.jsx("p",{className:"text-[9px] text-gray-500 font-bold leading-relaxed",children:"Estos son los profes que ya aparecen vinculados al alumno en clases o grupos creados desde Agenda Centro."})]}):e.jsx("p",{className:"text-[10px] text-gray-500 font-bold leading-relaxed",children:"Todavia no hay grupos o clases activas para este alumno en Agenda Centro."})]})]})})()}),gs&&e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-purple-200 shadow-xl relative animate-in slide-in-from-top-4",children:[e.jsx("div",{className:"absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-purple-500 to-blue-500"}),e.jsxs("div",{className:"flex justify-between items-center mb-4 mt-1",children:[e.jsx("h3",{className:"font-black text-gray-900 text-sm",children:"Top Compatibilidad"}),e.jsx("button",{onClick:()=>ca(!1),className:"text-gray-400 text-xs hover:bg-gray-100 w-6 h-6 rounded-full flex items-center justify-center",children:"X"})]}),e.jsxs("div",{className:"space-y-3",children:[Et.slice(0,3).map((a,t)=>e.jsxs("div",{className:"bg-gray-50 border border-gray-100 rounded-2xl p-3 relative overflow-hidden",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2 relative z-10",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold ${a.isFull?"bg-red-100 text-red-600":"bg-blue-100 text-blue-600"}`,children:t+1}),e.jsxs("div",{children:[e.jsx("p",{className:`font-black text-xs ${a.isFull?"text-red-900":"text-gray-900"}`,children:a.name||a.full_name}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[a.has_vehicle&&e.jsx("span",{className:"text-[8px] bg-gray-200 text-gray-600 px-1.5 py-0.5 rounded font-black",children:"Coche"}),a.location&&e.jsx("span",{className:"text-[8px] bg-gray-200 text-gray-600 px-1.5 py-0.5 rounded font-black truncate max-w-[60px]",children:a.location}),e.jsxs("span",{className:`text-[8px] px-1.5 py-0.5 rounded font-black border ${a.isFull?"bg-red-100 text-red-600 border-red-200":"bg-blue-50 text-blue-600 border-blue-100"}`,children:[a.currentStudents,"/3 alumnos"]})]})]})]}),e.jsxs("span",{className:`text-[10px] font-black px-2 py-1 rounded-lg text-white shadow-sm ${a.matchPercentage>=80?"bg-green-500":a.matchPercentage>=50?"bg-orange-500":"bg-red-500"}`,children:[a.matchPercentage,"%"]})]}),e.jsxs("div",{className:"flex gap-2 mt-3 relative z-10",children:[e.jsx("button",{onClick:()=>le(a.phone,`Hola ${a.name}. Tenemos un nuevo alumno que encaja muy bien con tu perfil en la zona de ${x(r.location)}. Es para ${x(r.subjects)}. ¿Te interesaria cogerlo?`),className:"flex-1 bg-[#25D366] text-white text-[9px] font-black uppercase py-2 rounded-lg hover:bg-green-600 transition-colors flex items-center justify-center gap-1 shadow-sm",children:"Proponer"}),e.jsx("button",{onClick:()=>On(a.email,a.name),className:"flex-1 bg-[#1c74e9] text-white text-[9px] font-black uppercase py-2 rounded-lg hover:bg-blue-600 transition-colors shadow-sm",children:"Asignar tutor"})]})]},a.id)),Et.length===0&&e.jsx("p",{className:"text-xs text-center text-gray-500 font-medium",children:"No hay profes activos disponibles."})]})]}),e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm relative overflow-hidden",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[e.jsx("button",{onClick:hn,className:"bg-gradient-to-r from-blue-600 to-blue-400 text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg shadow-blue-500/30 flex items-center justify-center gap-1.5 active:scale-95 transition-transform",children:"WhatsApp"}),e.jsx("button",{onClick:Nn,disabled:q||!G,className:`font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg flex items-center justify-center gap-1.5 active:scale-95 transition-transform ${q||!G?"bg-gray-200 text-gray-400 shadow-none cursor-not-allowed":"bg-emerald-500 text-white shadow-emerald-500/30"}`,children:q?"Enviando":r.family_start_email_prepared_at&&!r.family_start_email_sent_at?"Email pendiente":"Preparar email"}),e.jsx("button",{onClick:jn,disabled:!r.student_id,className:`font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg flex items-center justify-center gap-1.5 active:scale-95 transition-transform ${r.student_id?"bg-amber-100 text-amber-700 shadow-amber-200/40":"bg-gray-200 text-gray-400 shadow-none cursor-not-allowed"}`,children:"Ver ficha"}),e.jsx("button",{onClick:wn,disabled:Ua||!r.student_id,className:`font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg flex items-center justify-center gap-1.5 active:scale-95 transition-transform ${Ua||!r.student_id?"bg-gray-200 text-gray-400 shadow-none cursor-not-allowed":"bg-amber-500 text-white shadow-amber-500/30"}`,children:Ua?"Preparando":"Completar ficha"}),dt?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Qn,disabled:Ga||!G,className:`font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg flex items-center justify-center gap-1.5 active:scale-95 transition-transform ${Ga||!G?"bg-gray-200 text-gray-400 shadow-none cursor-not-allowed":"bg-violet-100 text-violet-700 shadow-violet-200/40"}`,children:Ga?"Abriendo":"Ver recibo"}),e.jsx("button",{onClick:Kn,disabled:Ba||!G,className:`font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg flex items-center justify-center gap-1.5 active:scale-95 transition-transform ${Ba||!G?"bg-gray-200 text-gray-400 shadow-none cursor-not-allowed":"bg-violet-500 text-white shadow-violet-500/30"}`,children:Ba?"Enviando":"Email recibo"}),e.jsx("button",{onClick:Zn,disabled:Wa||!r.phone,className:`col-span-2 font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg flex items-center justify-center gap-1.5 active:scale-95 transition-transform ${Wa||!r.phone?"bg-gray-200 text-gray-400 shadow-none cursor-not-allowed":"bg-[#25D366] text-white shadow-green-500/30"}`,children:Wa?"Preparando":"WhatsApp recibo"})]}):e.jsx("div",{className:"col-span-2 rounded-2xl border border-gray-100 bg-gray-50 px-4 py-3 text-[10px] font-black uppercase tracking-widest text-gray-400 leading-relaxed",children:"Recibo detallado solo para Academia Profe a 3. Domicilio y online se gestionan desde el area general de recibos."}),G&&e.jsx("button",{onClick:()=>{window.open(`/?portal=family&preview=${encodeURIComponent(A)}`,"_blank")},className:"col-span-2 bg-gray-900 text-white font-black text-[10px] uppercase tracking-widest py-3 rounded-xl shadow-lg shadow-gray-900/30 flex items-center justify-center gap-1.5 active:scale-95 transition-transform",title:"Ver exactamente lo que ve la familia",children:"Espiar"})]}),e.jsxs("div",{className:`grid ${dt?"grid-cols-3":"grid-cols-2"} gap-2 mb-4`,children:[e.jsxs("div",{className:`px-3 py-2 rounded-xl border text-center ${$a?"bg-emerald-50 border-emerald-100":"bg-gray-50 border-gray-100"}`,children:[e.jsx("p",{className:`text-[8px] font-black uppercase tracking-widest ${$a?"text-emerald-700":"text-gray-400"}`,children:"Email"}),e.jsx("p",{className:`text-[10px] font-black mt-1 ${$a?"text-emerald-700":"text-gray-500"}`,children:$a?"Portal enviado":"Portal pendiente"})]}),dt&&e.jsxs("div",{className:`px-3 py-2 rounded-xl border text-center ${Pa?"bg-vi
332olet-50 border-violet-100":"bg-gray-50 border-gray-100"}`,children:[e.jsx("p",{className:`text-[8px] font-black uppercase tracking-widest ${Pa?"text-violet-700":"text-gray-400"}`,children:"Prevision"}),e.jsx("p",{className:`text-[10px] font-black mt-1 ${Pa?"text-violet-700":"text-gray-500"}`,children:Pa?"Enviada este mes":"Pendiente este mes"})]}),e.jsxs("div",{className:`px-3 py-2 rounded-xl border text-center ${pe.tone==="done"?"bg-amber-50 border-amber-100":pe.tone==="pending"?"bg-orange-50 border-orange-100":"bg-gray-50 border-gray-100"}`,children:[e.jsx("p",{className:`text-[8px] font-black uppercase tracking-widest ${pe.tone==="done"?"text-amber-700":pe.tone==="pending"?"text-orange-700":"text-gray-400"}`,children:"Ficha"}),e.jsx("p",{className:`text-[10px] font-black mt-1 ${pe.tone==="done"?"text-amber-700":pe.tone==="pending"?"text-orange-700":"text-gray-500"}`,children:pe.label})]})]}),e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3",children:[e.jsx("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest",children:"Contacto de la Familia"}),r.contract_signed?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded border border-green-100 bg-green-50 px-2 py-1 text-[8px] font-black uppercase tracking-widest text-green-700",children:(Pe==null?void 0:Pe.signatureMethod)==="paper"?"Firmado en papel":"Firmado online"}),e.jsx("button",{onClick:()=>pa(!0),className:"text-green-600 bg-green-50 border border-green-200 px-2 py-1 rounded flex items-center gap-1 hover:bg-green-100 transition-colors text-[9px] font-black uppercase tracking-widest",children:"Ver acuerdo"})]}):e.jsx("span",{className:"text-red-500 bg-red-50 border border-red-100 px-2 py-1 rounded flex items-center gap-1 text-[8px] font-black uppercase tracking-widest",children:"Pendiente firma online"})]}),!r.contract_signed&&e.jsxs("div",{className:"mb-4 rounded-2xl border border-blue-100 bg-blue-50 p-3",children:[e.jsx("p",{className:"text-[10px] font-black text-blue-900",children:"La firma online desde el Portal de Familia es la opcion principal."}),e.jsx("p",{className:"mt-1 text-[9px] font-bold leading-relaxed text-blue-700",children:"Si la familia no puede entrar, abre una copia para imprimir o guardar como PDF. Cuando vuelva firmada, registrala como firma en papel."}),Ya&&e.jsx("p",{className:"mt-2 text-[9px] font-black uppercase tracking-widest text-blue-500",children:"Preparando condiciones..."}),!Ya&&!oe.readyToSign&&e.jsxs("p",{className:"mt-2 rounded-lg border border-amber-200 bg-amber-50 px-2 py-1.5 text-[9px] font-bold text-amber-800",children:["Antes de la firma online falta: ",oe.missingFields.join(", "),"."]}),e.jsx("button",{type:"button",onClick:fn,disabled:Ya||!oe.readyToSign||!r.phone||!r.family_access_token,className:"mt-3 w-full rounded-xl bg-[#25D366] px-3 py-3 text-[9px] font-black uppercase tracking-widest text-white shadow-lg shadow-green-500/20 transition hover:bg-green-600 disabled:cursor-not-allowed disabled:opacity-50",children:"Preparar WhatsApp con acuerdo y firma"}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>pa(!0),className:"rounded-xl border border-blue-200 bg-white px-3 py-2 text-[9px] font-black uppercase tracking-widest text-blue-700 hover:bg-blue-100",children:"Ver / guardar copia"}),e.jsx("button",{type:"button",onClick:Vn,className:"rounded-xl border border-gray-200 bg-white px-3 py-2 text-[9px] font-black uppercase tracking-widest text-gray-700 hover:bg-gray-100",children:"Registrar firma en papel"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center bg-green-50/50 p-3 rounded-2xl border border-green-50",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-gray-400 text-[9px] font-black uppercase",children:"Telefono / WhatsApp"}),e.jsx("span",{className:"text-gray-900 font-black text-sm",children:r.phone&&r.phone.length>4?r.phone:"-"})]}),r.phone&&r.phone.length>4&&e.jsx("button",{onClick:()=>le(r.phone,`Hola. Te escribimos desde Profe en Casa sobre las clases de ${r.name}.`),className:"bg-[#25D366] text-white w-10 h-10 flex items-center justify-center rounded-xl shadow-lg shadow-[#25D366]/30 active:scale-90 transition-transform text-[10px] font-black shrink-0",children:"WA"})]}),e.jsxs("div",{className:"flex justify-between items-center bg-blue-50/50 p-3 rounded-2xl border border-blue-50",children:[e.jsxs("div",{className:"flex flex-col min-w-0 pr-2",children:[e.jsx("span",{className:"text-gray-400 text-[9px] font-black uppercase",children:"Correo electronico"}),e.jsx("span",{className:"text-gray-900 font-black text-sm truncate",children:dr}),e.jsx("span",{className:`mt-1 text-[9px] font-black uppercase tracking-wide ${r.intake_confirmation_email_sent_at?"text-emerald-600":"text-amber-600"}`,children:r.intake_confirmation_email_sent_at?`Acuse enviado · ${zs(r.intake_confirmation_email_sent_at)}`:"Acuse pendiente"})]}),G&&e.jsx("button",{onClick:()=>window.location.href=`mailto:${dr}`,className:"bg-[#1c74e9] text-white w-10 h-10 flex items-center justify-center rounded-xl shadow-lg shadow-blue-500/30 active:scale-90 transition-transform text-[10px] font-black shrink-0",children:"MAIL"})]}),Qe&&e.jsx("div",{role:"alert",className:"rounded-2xl border border-amber-200 bg-amber-50 p-3 text-[10px] font-bold leading-relaxed text-amber-800",children:"Hay dos correos familiares distintos guardados. Revisa y unifica la ficha antes de enviar emails o abrir el portal en modo espia."})]})]}),e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("p",{className:"text-violet-600 text-[9px] font-black uppercase tracking-widest",children:"Ultimos envios"}),e.jsx("span",{className:"bg-violet-50 text-violet-700 text-[8px] font-black px-2 py-1 rounded-md",children:"SEGUIMIENTO"})]}),e.jsx("p",{className:"text-gray-500 text-[10px] font-bold leading-relaxed mb-4",children:"Aqui ves rapido si ya se envio el portal, el recibo mensual, la solicitud de ficha o alguna comunicacion por email o WhatsApp."}),e.jsx("div",{className:"space-y-3",children:na?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"w-5 h-5 border-2 border-violet-500 border-t-transparent roun
332ded-full animate-spin"})}):or.length===0?e.jsx("div",{className:"bg-gray-50 p-4 rounded-xl text-center border border-gray-100",children:e.jsx("p",{className:"text-gray-400 text-[10px] font-bold uppercase",children:"Todavia no hay envios registrados"})}):or.map(a=>{const t=Zs(a);return e.jsx("div",{className:`p-3 rounded-xl border ${t.cardClass}`,children:e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:`text-[10px] font-black uppercase tracking-widest ${t.titleClass}`,children:t.title}),e.jsx("p",{className:"text-[10px] text-gray-500 font-bold mt-1 leading-relaxed",children:x(a.notes)})]}),e.jsxs("div",{className:"shrink-0 text-right space-y-1",children:[e.jsx("span",{className:`block text-[8px] font-black px-2 py-1 rounded-md ${t.badgeClass}`,children:t.badge}),e.jsx("span",{className:"block text-[9px] font-black text-gray-500 bg-white px-2 py-0.5 rounded border border-gray-100",children:a.contact_date.split("-").reverse().join("/")})]})]})},a.id)})})]}),e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsx("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest mb-4",children:"Detalles de matricula"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col bg-rose-50 p-3 rounded-xl border border-rose-100",children:[e.jsx("span",{className:"text-rose-500 text-[9px] font-black uppercase",children:"Fecha de nacimiento"}),e.jsx("span",{className:"text-rose-900 font-bold text-xs",children:mn})]}),e.jsxs("div",{className:"flex flex-col bg-cyan-50 p-3 rounded-xl border border-cyan-100",children:[e.jsx("span",{className:"text-cyan-600 text-[9px] font-black uppercase",children:"Edad"}),e.jsx("span",{className:"text-cyan-900 font-bold text-xs",children:xn})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col bg-gray-50 p-3 rounded-xl border border-gray-100",children:[e.jsx("span",{className:"text-gray-400 text-[9px] font-black uppercase",children:"Curso / nivel"}),e.jsx("span",{className:"text-gray-900 font-bold text-xs",children:cr})]}),e.jsxs("div",{className:"flex flex-col bg-purple-50 p-3 rounded-xl border border-purple-100",children:[e.jsx("span",{className:"text-purple-400 text-[9px] font-black uppercase",children:"Modalidad"}),e.jsx("span",{className:"text-purple-700 font-bold text-[10px] leading-tight",children:dn})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col bg-blue-50 p-3 rounded-xl border border-blue-100",children:[e.jsx("span",{className:"text-blue-500 text-[9px] font-black uppercase",children:"Asignatura / interes"}),e.jsx("span",{className:"text-blue-900 font-bold text-[10px] leading-relaxed",children:it})]}),e.jsxs("div",{className:"flex flex-col bg-amber-50 p-3 rounded-xl border border-amber-100",children:[e.jsx("span",{className:"text-amber-500 text-[9px] font-black uppercase",children:"Disponibilidad y restricciones"}),e.jsx("span",{className:"text-amber-900 font-bold text-[10px] leading-relaxed",children:ct})]})]}),e.jsxs("div",{className:"flex flex-col bg-emerald-50 p-3 rounded-xl border border-emerald-100",children:[e.jsx("span",{className:"text-emerald-600 text-[9px] font-black uppercase",children:"Colegio / instituto"}),e.jsx("span",{className:"text-emerald-900 font-bold text-xs",children:pn})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"flex flex-col bg-gray-50 p-3 rounded-xl border border-gray-100",children:[e.jsx("span",{className:"text-gray-400 text-[9px] font-black uppercase",children:"Tutor / familia"}),e.jsx("span",{className:"text-gray-900 font-bold text-xs",children:R(r)})]}),e.jsxs("div",{className:"flex flex-col bg-gray-50 p-3 rounded-xl border border-gray-100",children:[e.jsx("span",{className:"text-gray-400 text-[9px] font-black uppercase",children:"Localidad"}),e.jsx("span",{className:"text-gray-900 font-bold text-xs",children:r.location||"-"})]})]}),y&&e.jsxs("div",{className:"bg-blue-50/50 p-4 rounded-2xl border border-blue-100 space-y-3",children:[e.jsx("p",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest",children:"Correccion rapida de ficha"}),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 tracking-widest block mb-2",children:"Nombre tutor"}),e.jsx("input",{type:"text",value:v.parentFirstName,onChange:a=>I(t=>({...t,parentFirstName:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"Ej: Carmen"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Apellidos tutor"}),e.jsx("input",{type:"text",value:v.parentLastName,onChange:a=>I(t=>({...t,parentLastName:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"Ej: Ruiz Garrido"})]})]}),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 tracking-widest block mb-2",children:"Email familia"}),e.jsx("input",{type:"email",value:v.email,onChange:a=>I(t=>({...t,email:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"[email protected]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"WhatsApp"}),e.jsx("input",{type:"text",value:v.phone,onChange:a=>I(t=>({...t,phone:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"+34 600000000"})]})]}),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 tracking-widest block mb-2",children:"Curso / nivel"}),e.jsxs("select",{value:v.level,onChange:a=>I(t=>({...t,level:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",children:[e.jsx("option",{value:"",children:"Selecciona nivel"}),Hr.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Modalidad"}),e.jsx("input",{type:"text",value:v.modality,onChange:a=>I(t=>({...t,modality:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"Ej: Academia Profe a 3"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Asignatura / interes principal"}),e.jsx("input",{type:"text",value:v.subjects,onChange:a=>I(t=>({...t,subjects:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"Ej: Matematicas, Ingles"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Colegio / instituto"}),e.jsx("input",{type:"text",value:v.schoolName,onChange:a=>I(t=>({...t,schoolName:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"Ej: IES Trevenque"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Fecha de nacimiento"}),e.jsx("input",{type:"date",value:v.birthDate,onChange:a=>I(t=>({...t,birthDate:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Disponibilidad y restricciones"}),e.jsx("input",{type:"text",value:v.availability,onChange:a=>I(t=>({...t,availability:a.target.value})),className:"w-full p-3 rounded-xl border text-xs font-bold shadow-sm bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]",placeholder:"Ej: No puede lunes ni miercoles"})]})]}),(r.lead_origin||r.lead_id)&&e.jsxs("div",{className:"flex flex-col bg-emerald-50 p-3 rounded-xl border border-emerald-100",children:[e.jsx("span",{className:"text-emerald-700 text-[9px] font-black uppercase",children:"Origen comercial"}),e.jsx("span",{className:"text-emerald-900 font-bold text-xs mt-1",children:x(r.lead_origin||"Lead convert
332ido")}),r.lead_id&&e.jsxs("span",{className:"text-emerald-700 text-[9px] font-bold mt-2 break-all",children:["Lead ID: ",r.lead_id]})]}),Gr({addressLine:_.address,addressDetails:_.address_details,postalCode:_.postal_code,locality:_.locality,province:_.province})&&e.jsxs("div",{className:"flex flex-col bg-gray-50 p-3 rounded-xl border border-gray-100",children:[e.jsx("span",{className:"text-gray-400 text-[9px] font-black uppercase",children:"Ubicacion guardada"}),e.jsx("span",{className:"text-gray-900 font-bold text-xs",children:Gr({addressLine:_.address,addressDetails:_.address_details,postalCode:_.postal_code,locality:_.locality,province:_.province})})]}),e.jsxs("div",{className:"bg-blue-50/40 p-4 rounded-2xl border border-blue-100 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest",children:"Ficha de ubicacion interna"}),e.jsx("p",{className:"text-gray-500 text-[10px] font-bold mt-1 leading-relaxed",children:y?"Estas editando la ficha interna. Guarda o cancela cuando termines.":"La ficha queda en solo lectura hasta que pulses Editar, para evitar cambios por accidente."})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2",children:[y&&e.jsx("button",{type:"button",onClick:br,className:"px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-colors bg-white text-gray-500 border border-gray-200 active:scale-95",children:"Cancelar"}),e.jsx("button",{type:"button",onClick:y?Dn:ur,disabled:Xa,className:`px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-colors ${Xa?"bg-gray-200 text-gray-400 cursor-not-allowed":y?"bg-[#1c74e9] text-white shadow-lg shadow-blue-500/20 active:scale-95":"bg-white text-[#1c74e9] border border-blue-200 active:scale-95"}`,children:Xa?"Guardando":y?"Guardar":"Editar"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Direccion"}),e.jsx("input",{type:"text",value:_.address,onChange:a=>X(t=>({...t,address:a.target.value})),disabled:!y,className:`w-full p-3 rounded-xl border text-xs font-bold shadow-sm ${y?"bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]":"bg-gray-50 text-gray-500 border-gray-200 cursor-not-allowed"}`,placeholder:"Ej: Calle Real 15"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Detalles de direccion"}),e.jsx("input",{type:"text",value:_.address_details,onChange:a=>X(t=>({...t,address_details:a.target.value})),disabled:!y,className:`w-full p-3 rounded-xl border text-xs font-bold shadow-sm ${y?"bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]":"bg-gray-50 text-gray-500 border-gray-200 cursor-not-allowed"}`,placeholder:"Ej: Portal 2, 3ºB, Urbanizacion..."})]}),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 tracking-widest block mb-2",children:"Codigo postal"}),e.jsx("input",{type:"text",value:_.postal_code,onChange:a=>X(t=>({...t,postal_code:a.target.value})),disabled:!y,className:`w-full p-3 rounded-xl border text-xs font-bold shadow-sm ${y?"bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]":"bg-gray-50 text-gray-500 border-gray-200 cursor-not-allowed"}`,placeholder:"Ej: 18140"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Localidad"}),e.jsx("input",{type:"text",value:_.locality,onChange:a=>X(t=>({...t,locality:a.target.value})),disabled:!y,className:`w-full p-3 rounded-xl border text-xs font-bold shadow-sm ${y?"bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]":"bg-gray-50 text-gray-500 border-gray-200 cursor-not-allowed"}`,placeholder:"Ej: La Zubia"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest block mb-2",children:"Provincia"}),e.jsx("input",{type:"text",value:_.province,onChange:a=>X(t=>({...t,province:a.target.value})),disabled:!y,className:`w-full p-3 rounded-xl border text-xs font-bold shadow-sm ${y?"bg-white text-gray-900 border-blue-100 outline-none focus:border-[#1c74e9]":"bg-gray-50 text-gray-500 border-gray-200 cursor-not-allowed"}`,placeholder:"Ej: Granada"})]})]}),ct&&e.jsxs("div",{className:"flex flex-col bg-blue-50 p-3 rounded-xl border border-blue-100",children:[e.jsx("span",{className:"text-blue-400 text-[9px] font-black uppercase",children:"Disponibilidad Horaria"}),e.jsx("span",{className:"text-blue-700 font-bold text-xs",children:ct})]}),(r.notes||r.observations)&&e.jsxs("div",{className:"flex flex-col bg-amber-50 p-3 rounded-xl border border-amber-100",children:[e.jsx("span",{className:"text-amber-500 text-[9px] font-black uppercase",children:"Observaciones"}),e.jsxs("span",{className:"text-amber-700 font-bold text-xs italic",children:['"',x(r.notes||r.observations),'"']})]}),it&&e.jsx("p",{className:"text-gray-600 text-xs text-center font-bold mt-2 bg-gray-50 p-3 rounded-xl border border-gray-100",children:it})]})]}),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 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest",children:"Seguimiento academico"}),e.jsx("h4",{className:"text-gray-900 font-black text-sm mt-1",children:"Proximos examenes y notas"}),e.jsx("p",{className:"text-[10px] text-gray-500 font-bold mt-2 leading-relaxed",children:"La familia, coordinacion y el profesor pueden ir dejando aqui fechas de examen y notas de trimestre para seguir mejor la evolucion."})]}),e.jsxs("div",{className:"flex flex-col gap-2 shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>{Ne(a=>!a),ke(!1)},className:"px-3 py-2 rounded-xl bg-blue-50 text-[#1c74e9] border border-blue-100 text-[10px] font-black uppercase tracking-widest",children:"+ Examen"}),e.jsx("button",{type:"button",onClick:()=>{ke(a=>!a),Ne(!1)},className:"px-3 py-2 rounded-xl bg-emerald-50 text-emerald-700 border border-emerald-100 text-[10px] font-black uppercase tracking-widest",children:"+ Nota"})]})]}),Ms&&e.jsxs("div",{className:"mb-4 bg-blue-50 border border-blue-100 rounded-2xl p-4 space-y-3 animate-in fade-in",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-blue-600 font-black uppercase tracking-widest block mb-1",children:"Asignatura"}),e.jsx("input",{value:K.subject,onChange:a=>se(t=>({...t,subject:a.target.value})),className:"w-full bg-white border border-blue-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none",placeholder:"Ej: Matematicas"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-blue-600 font-black uppercase tracking-widest block mb-1",children:"Fecha"}),e.jsx("input",{type:"date",value:K.exam_date,onChange:a=>se(t=>({...t,exam_date:a.target.value})),className:"w-full bg-white border border-blue-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-blue-600 font-black uppercase tracking-widest block mb-1",children:"Tema o unidad"}),e.jsx("input",{value:K.unit,onChange:a=>se(t=>({...t,unit:a.target.value})),className:"w-full bg-white border border-blue-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none",placeholder:"Ej: Tema 6, comentario de texto..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-blue-600 font-black uppercase tracking-widest block mb-1",children:"Comentario opcional"}),e.jsx("textarea",{value:K.notes,onChange:a=>se(t=>({...t,notes:a.target.value})),rows:2,className:"w-full bg-white border border-blue-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none resize-none",placeholder:"Ej: examen importante para cerrar trimestre"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{Ne(!1),se(aa)},className:"flex-1 py-3 rounded-xl bg-white text-gray-500 border border-gray-200 text-[10px] font-black uppercase tracking-widest",children:"Cancelar"}),e.jsx("button",{type:"button",onClick:an,disabled:Na,className:"flex-[2] py-3 rounded-xl bg-[#1c74e9] text-white text-[10px] font-black uppercase tracking-widest shadow-lg shadow-blue-500/20 disabled:opacity-60",children:Na?"Guardando...":"Guardar examen"})]})]}),qs&&e.jsxs("div",{className:"mb-4 bg-emerald-50 border border-emerald-100 rounded-2xl p-4 space-y-3 animate-in fade-in",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-emerald-700 font-black uppercase tracking-widest block mb-1",children:"Trimestre"}),e.jsx("select",{value:B.term,onChange:a=>ne(t=>({...t,term:a.target.value})),className:"w-full bg-white border border-emerald-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none",children:Lo.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-emerald-700 font-black uppercase tracking-widest block mb-1",children:"Nota"}
332),e.jsx("input",{value:B.grade,onChange:a=>ne(t=>({...t,grade:a.target.value})),className:"w-full bg-white border border-emerald-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none",placeholder:"Ej: 8"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-emerald-700 font-black uppercase tracking-widest block mb-1",children:"Asignatura"}),e.jsx("input",{value:B.subject,onChange:a=>ne(t=>({...t,subject:a.target.value})),className:"w-full bg-white border border-emerald-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none",placeholder:"Ej: Lengua"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] text-emerald-700 font-black uppercase tracking-widest block mb-1",children:"Comentario opcional"}),e.jsx("textarea",{value:B.notes,onChange:a=>ne(t=>({...t,notes:a.target.value})),rows:2,className:"w-full bg-white border border-emerald-100 rounded-xl px-3 py-3 text-sm font-bold text-gray-900 outline-none resize-none",placeholder:"Ej: sube respecto al trimestre anterior"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{ke(!1),ne(ta)},className:"flex-1 py-3 rounded-xl bg-white text-gray-500 border border-gray-200 text-[10px] font-black uppercase tracking-widest",children:"Cancelar"}),e.jsx("button",{type:"button",onClick:tn,disabled:Na,className:"flex-[2] py-3 rounded-xl bg-emerald-500 text-white text-[10px] font-black uppercase tracking-widest shadow-lg shadow-emerald-500/20 disabled:opacity-60",children:Na?"Guardando...":"Guardar nota"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"bg-blue-50/60 border border-blue-100 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsx("p",{className:"text-blue-600 text-[9px] font-black uppercase tracking-widest",children:"Proximos examenes"}),e.jsx("span",{className:"bg-white text-blue-600 border border-blue-100 rounded-full px-3 py-1 text-[9px] font-black uppercase tracking-widest",children:$e.length})]}),e.jsx("div",{className:"space-y-2",children:$e.length===0?e.jsx("p",{className:"text-[11px] text-gray-500 font-bold leading-5",children:"Todavia no hay examenes cargados para este alumno."}):$e.map(a=>e.jsx("div",{className:`rounded-2xl border p-3 ${ir.has(a.id)?"bg-amber-50 border-amber-200":"bg-white border-blue-100"}`,children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-black text-sm text-gray-900",children:x(a.subject)}),e.jsxs("p",{className:`text-[10px] font-black uppercase tracking-widest mt-1 ${ir.has(a.id)?"text-amber-700":"text-blue-600"}`,children:[yt(a.exam_date)," · ",a.status==="done"?"Hecho":"Pendiente"]}),a.unit&&e.jsx("p",{className:"text-[11px] text-gray-600 font-bold mt-2",children:x(a.unit)}),a.notes&&e.jsx("p",{className:"text-[11px] text-gray-500 mt-2 leading-5",children:x(a.notes)}),e.jsxs("p",{className:"text-[9px] text-gray-400 font-black uppercase tracking-widest mt-2",children:["Anadido por ",x(rs(a.source))]})]}),e.jsx("button",{type:"button",onClick:()=>rn(a.id),className:"w-8 h-8 rounded-full bg-red-50 text-red-500 border border-red-100 text-xs font-black shrink-0",title:"Quitar examen",children:"X"})]})},a.id))})]}),e.jsxs("div",{className:"bg-emerald-50/60 border border-emerald-100 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsx("p",{className:"text-emerald-700 text-[9px] font-black uppercase tracking-widest",children:"Notas trimestrales"}),e.jsx("span",{className:"bg-white text-emerald-700 border border-emerald-100 rounded-full px-3 py-1 text-[9px] font-black uppercase tracking-widest",children:Ke.length})]}),e.jsx("div",{className:"space-y-2",children:Ke.length===0?e.jsx("p",{className:"text-[11px] text-gray-500 font-bold leading-5",children:"Todavia no hay notas trimestrales anotadas."}):Ke.map(a=>e.jsx("div",{className:"bg-white rounded-2xl border border-emerald-100 p-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-black text-sm text-gray-900",children:x(a.subject)}),e.jsxs("p",{className:"text-[10px] font-black uppercase tracking-widest text-emerald-700 mt-1",children:[x(a.term)," · Nota ",a.grade]}),a.notes&&e.jsx("p",{className:"text-[11px] text-gray-500 mt-2 leading-5",children:x(a.notes)}),e.jsxs("p",{className:"text-[9px] text-gray-400 font-black uppercase tracking-widest mt-2",children:["Anadido por ",x(rs(a.source))]})]}),e.jsx("button",{type:"button",onClick:()=>sn(a.id),className:"w-8 h-8 rounded-full bg-red-50 text-red-500 border border-red-100 text-xs font-black shrink-0",title:"Quitar nota",children:"X"})]})},a.id))})]})]})]}),$==="activos"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("div",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest",children:"Estado de suscripcion"}),e.jsx("span",{className:`text-[9px] font-black uppercase tracking-widest px-3 py-1 rounded-full ${y?"bg-blue-50 text-[#1c74e9]":"bg-gray-100 text-gray-500"}`,children:y?"Edicion activada":"Solo lectura"})]}),e.jsx("p",{className:"text-gray-400 text-[9px] font-black uppercase tracking-widest mb-4",children:"Estado de suscripcion"}),e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("p",{className:"text-gray-400 text-[9px] font-bold leading-relaxed",children:y?"Ya puedes ajustar recurrencia y modelo de facturacion.":"Pulsa Editar para desbloquear esta parte y evitar cambios accidentales."}),e.jsx("button",{type:"button",onClick:y?br:ur,className:`shrink-0 px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest transition-colors ${y?"bg-white text-gray-500 border border-gray-200 active:scale-95":"bg-white text-[#1c74e9] border border-blue-200 active:scale-95"}`,children:y?"Bloquear":"Editar"})]}),e.jsxs("div",{className:"flex justify-between items-center bg-gray-50 p-3 rounded-xl border border-gray-100 mb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-gray-900 font-bold text-xs",children:"Alumno Recurrente"}),e.jsx("p",{className:"text-gray-400 text-[9px]",children:"Tiene horario fijo semanal."})]}),e.jsx("button",{onClick:Pn,disabled:!y,className:`w-12 h-6 rounded-full transition-colors relative ${r.is_recurring!==!1?"bg-green-500":"bg-gray-300"} ${y?"":"opacity-60 cursor-not-allowed"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-all ${r.is_recurring!==!1?"left-7":"left-1"}`})})]}),e.jsxs("div",{className:"flex flex-col bg-gray-50 p-3 rounded-xl border border-gray-100",children:[e.jsx("label",{className:"text-gray-900 font-bold text-xs mb-1",children:"Modelo de facturacion"}),e.jsx("p",{className:"text-gray-400 text-[9px] mb-2",children:"Solo para Domicilio / Online."}),e.jsxs("select",{value:r.billing_type||"Post-pago",onChange:a=>Rn(a.target.value),disabled:!y,className:`w-full border text-xs font-bold p-2 rounded-lg ${y?"bg-white border-gray-200 text-gray-900 outline-none focus:border-[#1c74e9]":"bg-gray-100 border-gray-200 text-gray-500 cursor-not-allowed"}`,children:[e.jsx("option",{value:"Post-pago",children:"Cobro mensual adelantado según calendario"}),e.jsx("option",{value:"Pack Prepago (4 Clases)",children:"Bono prepago de 4 clases"})]})]})]}),e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("p",{className:"text-purple-500 text-[9px] font-black uppercase tracking-widest flex items-center gap-1",children:"Monedero extra"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{Qa(!Mt),qt(r.extra_classes_balance||0),zt(r.bono_expiry_date||"")},className:"text-gray-400 text-[10px] hover:text-purple-600 transition-colors",children:"Ajustar"}),e.jsxs("div",{className:"text-right ml-2 border-l border-gray-100 pl-3",children:[e.jsx("span",{className:`text-xl font-black ${r.extra_classes_balance>0?"text-purple-600":"text-gray-300"}`,children:r.extra_classes_balance||0}),e.jsx("span",{className:"text-[10px] text-gray-500 font-bold ml-1",children:"Bonos"})]})]})]}),Mt?e.jsxs("div",{className:"bg-purple-50 p-4 rounded-xl border border-purple-100 mb-4 animate-in fade-in",children:[e.jsx("p",{className:"text-purple-700 text-[9px] font-black uppercase tracking-widest mb-3",children:"Ajuste Manual"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-bold text-gray-600 block mb-1",children:"Saldo total"}),e.jsx("input",{type:"number",min:"0",value:ha,onChange:a=>qt(Number(a.target.value)),className:"w-full p-2 text-xs rounded border border-purple-200 outline-none focus:border-purple-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-bold text-gray-600 block mb-1",children:"Caducidad"}),e.jsx("input",{type:"date",value:We,onChange:a=>zt(a.target.value),className:"w-full p-2 text-xs rounded border border-purple-200 outline-none focus:border-purple-500"})]})]}),e.jsx("button",{onClick:qn,className:"w-full bg-purple-600 text-white font-black text-[10px] uppercase py-2 rounded-lg hover:bg-purple-700 active:scale-95 transition-transform",children:"Guardar Cambios"})]}):r.extra_classes_balance>0&&r.bono_expiry_date&&e.jsxs("div",{className:`p-3 rounded-xl border mb-4 text-[10px] font-bold flex justify-between items-center
333                                    ${new Date(r.bono_expiry_date+"T23:59:59")<new Date?"bg-red-50 border-red-200 text-red-600":"bg-green-50 border-green-200 text-green-700"}`,children:[e.jsxs("span",{children:["Caducidad: ",r.bono_expiry_date.split("-").reverse().join("/")]}),new Date(r.bono_expiry_date+"T23:59:59")<new Date?e.jsx("span",{className:"uppercase font-black animate-pulse",children:"Caducado"}):e.jsx("span",{className:"uppercase font-black",children:"Valido"})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 mt-2",children:[e.jsx("p",{className:"text-gray-400 text-[8px] font-black uppercase tracking-widest mb-1 mt-1",children:"Recarga rapida / regalo"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx("button",{onClick:()=>Fa(1,"end_of_month","+1 Recuperacion (Fin Mes)",{logTopic:"RECUPERACION JUSTIFICADA",logMessage:`Anadida 1 recuperacion por falta justificada. Ca
333ducidad: ${new Date(new Date().getFullYear(),new Date().getMonth()+1,0).toISOString().split("T")[0].split("-").reverse().join("/")}. Saldo total: ${(r.extra_classes_balance||0)+1}`}),className:"bg-amber-50 text-amber-700 border border-amber-100 py-2 px-1 rounded-xl text-[9px] font-black uppercase tracking-widest hover:bg-amber-100 transition-colors active:scale-95 text-center col-span-2",children:"+1 Recuperacion (Fin Mes)"}),(((kr=r.modality)==null?void 0:kr.includes("Domicilio"))||((_r=r.modality)==null?void 0:_r.includes("Online")))&&e.jsx("button",{onClick:()=>Fa(1,"end_of_month","+1 Extra (Fin Mes)"),className:"bg-blue-50 text-blue-600 border border-blue-100 py-2 px-1 rounded-xl text-[9px] font-black uppercase tracking-widest hover:bg-blue-100 transition-colors active:scale-95 text-center col-span-2",children:"+1 Extra (Fin Mes)"}),((Sr=r.modality)==null?void 0:Sr.includes("Profe a 3"))&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>Fa(2,1,"+2 Extras Viernes (1 Mes)"),className:"bg-purple-50 text-purple-600 border border-purple-100 py-2 px-1 rounded-xl text-[9px] font-black uppercase tracking-widest hover:bg-purple-100 transition-colors active:scale-95 text-center",children:"+2 Extras Viernes (1 Mes)"}),e.jsx("button",{onClick:()=>Fa(4,2,"+4 Extras Viernes (2 Meses)"),className:"bg-purple-50 text-purple-600 border border-purple-100 py-2 px-1 rounded-xl text-[9px] font-black uppercase tracking-widest hover:bg-purple-100 transition-colors active:scale-95 text-center",children:"+4 Extras Viernes (2 Meses)"})]})]})]}),e.jsxs("div",{className:"mt-4 bg-amber-50 border border-amber-100 rounded-2xl p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-amber-700 text-[9px] font-black uppercase tracking-widest",children:"Seguimiento recuperacion"}),e.jsx("p",{className:"text-[11px] text-amber-900 mt-2",children:"Usa este bloque para apuntar los huecos ofrecidos a la familia y cerrar la recuperacion cuando ya quede recolocada."})]}),e.jsxs("span",{className:`shrink-0 px-3 py-1.5 rounded-full text-[10px] font-black uppercase border ${Ae>0?"bg-white text-amber-700 border-amber-200":"bg-gray-100 text-gray-400 border-gray-200"}`,children:[Ae," pendiente",Ae===1?"":"s"]})]}),e.jsx("textarea",{value:Za,onChange:a=>Ge(a.target.value),rows:3,placeholder:"Ej: Ofrecidas opciones martes 17:30 con Juan o jueves 18:00 con Gabriela. Pendiente de confirmar familia.",className:"w-full rounded-2xl border border-amber-200 bg-white px-4 py-3 text-xs text-gray-700 outline-none focus:border-amber-400 resize-none"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 mt-3",children:[e.jsx("button",{onClick:Fn,className:"bg-white text-amber-700 border border-amber-200 py-2 px-3 rounded-xl text-[10px] font-black uppercase tracking-widest hover:bg-amber-100 transition-colors active:scale-95",children:"Anotar opciones"}),e.jsx("button",{onClick:Tn,disabled:Ae<=0,className:`py-2 px-3 rounded-xl text-[10px] font-black uppercase tracking-widest transition-colors active:scale-95 ${Ae>0?"bg-emerald-600 text-white hover:bg-emerald-700":"bg-gray-100 text-gray-400 cursor-not-allowed"}`,children:"Cerrar una pendiente"})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("button",{onClick:Ln,disabled:Ot||!(r.modality||"").includes("Profe a 3"),className:`w-full py-3 px-4 rounded-xl text-[10px] font-black uppercase tracking-widest transition-colors active:scale-95 ${(r.modality||"").includes("Profe a 3")?"bg-vi
333olet-600 text-white hover:bg-violet-700 shadow-lg shadow-violet-500/20":"bg-gray-100 text-gray-400 cursor-not-allowed border border-gray-200"}`,children:Ot?"Buscando huecos operativos...":"Colocar en grupo ya operativo"}),!(r.modality||"").includes("Profe a 3")&&e.jsx("p",{className:"text-[10px] text-gray-400 font-bold mt-2",children:"Este colocador guiado se ha preparado primero para recuperaciones dentro de grupos de academia."})]}),Is&&e.jsxs("div",{className:"mt-4 bg-white border border-violet-100 rounded-2xl p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-violet-700 text-[9px] font-black uppercase tracking-widest",children:"Recolocar recuperacion"}),e.jsx("p",{className:"text-[11px] text-violet-900 mt-2 leading-relaxed",children:"Elige una clase futura que ya exista. La familia no volvera a pagar esta sesion: el profesor la marcara luego como recuperacion sin cobro."})]}),e.jsx("button",{type:"button",onClick:()=>{He(!1),je(""),we(""),ie(!1)},className:"text-[10px] font-black uppercase tracking-widest text-gray-400 hover:text-gray-700",children:"Cerrar"})]}),(r.extra_classes_balance||0)<=0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-3",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-amber-700 mb-1",children:"Antes de colocarla"}),e.jsxs("p",{className:"text-[11px] text-amber-900 leading-relaxed",children:["Este alumno no tiene ahora mismo saldo de recuperacion. Primero usa ",e.jsx("strong",{children:"+1 Recuperacion (Fin Mes)"})," y luego programa aqui el hueco para que el profesor pueda canjearla bien."]})]}),va.length===0?e.jsx("div",{className:"bg-gray-50 border border-gray-100 rounded-xl p-3 text-[11px] text-gray-500",children:"No he encontrado grupos futuros compatibles ya operativos para este alumno."}):e.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto pr-1",children:va.map(a=>e.jsxs("button",{type:"button",onClick:()=>{je(a.id),a.requiresExceptionalFourth||ie(!1)},className:`w-full text-left border rounded-2xl p-3 transition-colors ${ve===a.id?"bg-violet-50 border-violet-300 shadow-sm":"bg-gray-50 border-gray-100 hover:bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-gray-900 font-black text-sm",children:[String(a.class_date||"").split("-").reverse().join("/")," · ",String(a.start_time||"").slice(0,5)," - ",String(a.end_time||"").slice(0,5)]}),e.jsxs("p",{className:"text-[10px] font-black uppercase tracking-widest text-violet-700 mt-1",children:[x(a.subject)," · ",x(a.level)]}),e.jsx("p",{className:"text-[11px] font-bold text-gray-600 mt-2",children:x(a.teacherName)})]}),e.jsx("span",{className:`text-[9px] font-black uppercase px-2 py-1 rounded-lg border ${a.requiresExceptionalFourth?"bg-amber-50 text-amber-700 border-amber-200":"bg-emerald-50 text-emerald-700 border-emerald-200"}`,children:a.requiresExceptionalFourth?"4 ese dia":`${a.totalCount+1} en clase`})]}),e.jsxs("p",{className:"text-[10px] text-gray-500 font-bold mt-2 leading-relaxed",children:["Base: ",a.baseStudents.join(", ")]}),a.recoveryStudents.length>0&&e.jsxs("p",{className:"text-[10px] text-violet-700 font-bold mt-1 leading-relaxed",children:["Recuperaciones ya metidas: ",a.recoveryStudents.join(", ")]})]},a.id))}),ve&&((Cr=va.find(a=>a.id===ve))==null?void 0:Cr.requiresExceptionalFourth)&&e.jsxs("label",{className:"flex items-start gap-2 bg-amber-50 border border-amber-200 rounded-xl p-3 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:Ut,onChange:a=>ie(a.target.checked),className:"mt-0.5"}),e.jsx("span",{className:"text-[11px] text-amber-900 font-bold leading-relaxed",children:"Permitir que ese dia este grupo pase a 4 alumnos de forma excepcional solo para esta recuperacion."})]}),e.jsx("textarea",{value:wa,onChange:a=>we(a.target.value),rows:2,placeholder:"Ej: Recuperacion acordada con la familia para no abrir un grupo nuevo.",className:"w-full rounded-2xl border border-violet-200 bg-white px-4 py-3 text-xs text-gray-700 outline-none focus:border-violet-400 resize-none"}),e.jsx("button",{onClick:In,disabled:et||!ve,className:`w-full py-3 px-4 roun
333ded-xl text-[10px] font-black uppercase tracking-widest transition-colors active:scale-95 ${et||!ve?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-violet-600 text-white hover:bg-violet-700 shadow-lg shadow-violet-500/20"}`,children:et?"Programando recuperacion...":"Programar en esta clase"})]}),e.jsx("div",{className:"mt-3 space-y-2",children:lr.length===0?e.jsx("div",{className:"bg-white/70 border border-amber-100 rounded-xl p-3 text-[10px] text-amber-700",children:"Todavia no hay recuperaciones anotadas para este alumno."}):lr.map(a=>e.jsxs("div",{className:"bg-white border border-amber-100 rounded-xl p-3",children:[e.jsxs("div",{className:"flex justify-between items-start gap-3 mb-1",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-amber-700",children:a.topic}),e.jsx("span",{className:"text-[9px] font-black text-gray-500",children:String(a.contact_date||"").split("-").reverse().join("/")})]}),e.jsx("p",{className:"text-[11px] text-gray-700 leading-relaxed",children:x(a.notes)})]},a.id))})]})]})]}),e.jsxs("div",{className:"bg-white p-5 rounded-[24px] border border-gray-100 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("p",{className:"text-orange-500 text-[9px] font-black uppercase tracking-widest flex items-center gap-1",children:"Historial llamadas"}),e.jsx("span",{className:"bg-orange-50 text-orange-600 text-[8px] font-black px-2 py-1 rounded-md",children:"BITACORA"})]}),e.jsx("div",{className:"space-y-3",children:na?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx("div",{className:"w-5 h-5 border-2 border-orange-500 border-t-transparent rounded-full animate-spin"})}):Y.length===0?e.jsx("div",{className:"bg-gray-50 p-4 rounded-xl text-center border border-gray-100",children:e.jsx("p",{className:"text-gray-400 text-[10px] font-bold uppercase",children:"Sin registros"})}):Y.map(a=>e.jsxs("div",{className:"bg-orange-50/50 p-3 rounded-xl border border-orange-100 relative",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("span",{className:"text-[10px] font-black text-orange-600 uppercase tracking-tight",children:a.topic}),e.jsx("span",{className:"text-[9px] font-black text-gray-500 bg-white px-2 py-0.5 rounded border border-gray-100",children:a.contact_date.split("-").reverse().join("/")})]}),e.jsx("div",{className:"bg-white p-2.5 rounded-lg border border-orange-50",children:e.jsxs("p",{className:"text-xs text-gray-700 font-medium italic",children:['"',x(a.notes),'"']})})]},a.id))})]})]}),e.jsx("div",{className:"p-5 bg-white border-t border-gray-100 flex gap-3 shrink-0 rounded-b-[40px]",children:_a(r)?e.jsx("button",{onClick:()=>An(r),className:"flex-1 py-4 text-emerald-600 font-black uppercase text-[10px] tracking-widest bg-emerald-50 hover:bg-emerald-500 hover:text-white rounded-2xl transition-colors active:scale-95 border border-emerald-100",children:"Reactivar Alumno"}):e.jsx("button",{onClick:()=>Cn(r),className:"flex-1 py-4 text-red-500 font-black uppercase text-[10px] tracking-widest bg-red-50 hover:bg-red-500 hover:text-white rounded-2xl transition-colors active:scale-95 border border-red-100",children:"Dar de Baja"})})]})}),ds&&r&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/85 backdrop-blur-sm z-[10000] flex items-center justify-center p-3",children:e.jsxs("div",{className:"bg-white w-full max-w-6xl h-[94vh] rounded-[32px] shadow-2xl overflow-hidden flex flex-col border border-gray-100",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100 bg-white flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-emerald-600",children:"Preparar correo familiar"}),e.jsxs("h3",{className:"text-gray-900 font-black text-base",children:["Inicio de ",r.name]}),e.jsxs("p",{className:"mt-1 text-xs font-bold text-gray-500 break-all",children:["Para: ",A]}),r.family_start_email_prepared_at&&!r.family_start_email_sent_at&&e.jsx("span",{className:"mt-2 inline-flex rounded-full bg-amber-100 px-2.5 py-1 text-[9px] font-black uppercase tracking-widest text-amber-700",children:"Borrador pendiente de enviar"})]}),e.jsx("button",{type:"button",onClick:()=>ia(!1),disabled:q||Ie,className:"h-10 w-10 shrink-0 rounded-full bg-gray-100 text-sm font-black text-gray-600 disabled:opacity-60",children:"X"})]}),e.jsxs("div",{className:"border-b border-emerald-200 bg-emerald-50 px-5 py-3",children:[e.jsx("p",{className:"text-xs font-black text-emerald-900",children:"Abrir y editar esta ventana no envia ningun correo."}),e.jsx("p",{className:"mt-1 text-[11px] font-bold leading-relaxed text-emerald-800",children:"Revisa horario, fecha de inicio, profesora y precio. El envio solo se realiza al pulsar el boton final y confirmarlo."})]}),k.body.includes("[confirmar")&&e.jsx("div",{className:"border-b border-amber-200 bg-amber-50 px-5 py-3 text-[11px] font-bold text-amber-900",children:"Quedan datos marcados como [confirmar]. El envio permanecera bloqueado hasta sustituirlos."}),e.jsxs("div",{className:"grid min-h-0 flex-1 lg:grid-cols-[minmax(0,0.9fr)_minmax(0,1.1fr)]",children:[e.jsxs("div",{className:"min-h-0 overflow-y-auto border-b border-gray-100 p-5 lg:border-b-0 lg:border-r",children:[e.jsx("label",{className:"block text-[10px] font-black uppercase tracking-widest text-gray-500",htmlFor:"family-email-subject",children:"Asunto"}),e.jsx("input",{id:"family-email-subject",type:"text",value:k.subject,onChange:a=>Oa(t=>({...t,subject:a.target.value})),disabled:q,className:"mt-2 w-full rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm font-bold text-gray-900 outline-none focus:border-emerald-500 focus:ring-2 focus:ring-emerald-100 disabled:opacity-60"}),e.jsx("label",{className:"mt-5 block text-[10px] font-black uppercase tracking-widest text-gray-500",htmlFor:"family-email-body",children:"Mensaje editable"}),e.jsx("textarea",{id:"family-email-body",value:k.body,onChange:a=>Oa(t=>({...t,body:a.target.value})),disabled:q,className:"mt-2 min-h-[430px] w-full resize-y rounded-2xl border border-gray-200 bg-white px-4 py-3 text-sm leading-relaxed text-gray-800 outline-none focus:border-emerald-500 focus:ring-2 focus:ring-emerald-100 disabled:opacity-60"})]}),e.jsx("div",{className:"min-h-[360px] bg-[#EEF2F7] p-3 md:p-5",children:e.jsx("iframe",{title:"Vista previa del correo fam
333iliar",srcDoc:is(k.body),className:"h-full min-h-[330px] w-full rounded-[24px] border border-gray-200 bg-white shadow-sm"})})]}),e.jsxs("div",{className:"grid gap-2 border-t border-gray-100 bg-white p-4 sm:grid-cols-3",children:[e.jsx("button",{type:"button",onClick:()=>ia(!1),disabled:q||Ie,className:"rounded-2xl border border-gray-200 bg-white py-3 text-[10px] font-black uppercase tracking-widest text-gray-600 disabled:opacity-60",children:"Cancelar sin enviar"}),e.jsx("button",{type:"button",onClick:()=>void kn(),disabled:q||Ie||!k.subject.trim()||!k.body.trim(),className:"rounded-2xl border border-amber-300 bg-amber-50 py-3 text-[10px] font-black uppercase tracking-widest text-amber-800 disabled:cursor-not-allowed disabled:opacity-50",children:Ie?"Guardando...":"Guardar borrador"}),e.jsx("button",{type:"button",onClick:()=>void _n(),disabled:Ie||q||k.body.includes("[confirmar")||!k.subject.trim()||!k.body.trim(),className:"rounded-2xl bg-emerald-600 py-3 text-[10px] font-black uppercase tracking-widest text-white shadow-lg shadow-emerald-500/20 disabled:cursor-not-allowed disabled:opacity-50",children:q?"Enviando...":"Enviar email a la familia"})]})]})}),ze&&r&&(()=>{const a=ls(R(r),r.name,ze.teacherName);return e.jsx("div",{className:"fixed inset-0 bg-gray-900/85 backdrop-blur-sm z-[10000] flex items-center justify-center p-3",children:e.jsxs("div",{className:"bg-white w-full max-w-5xl h-[94vh] rounded-[32px] shadow-2xl overflow-hidden flex flex-col border border-gray-100",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100 bg-white flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-blue-600",children:"Revisar antes de asignar"}),e.jsxs("h3",{className:"text-gray-900 font-black text-base",children:["Tutor academico: ",ze.teacherName]}),e.jsxs("p",{className:"mt-1 text-xs font-bold text-gray-500",children:["Alumno: ",r.name]})]}),e.jsx("button",{type:"button",onClick:()=>da(null),disabled:fe,className:"h-10 w-10 shrink-0 rounded-full bg-gray-100 text-sm font-black text-gray-600 disabled:opacity-60",children:"X"})]}),e.jsxs("div",{className:"border-b border-amber-200 bg-amber-50 px-5 py-3",children:[e.jsx("p",{className:"text-xs font-black text-amber-900",children:"Esta accion solo asigna un tutor academico de referencia."}),e.jsx("p",{className:"mt-1 text-[11px] font-bold leading-relaxed text-amber-800",children:"No crea la clase a domicilio, no fija el horario y no incorpora al profesor en Agenda Centro. El correo inferior comunica exactamente esa tutoria."})]}),e.jsxs("div",{className:"grid gap-2 border-b border-gray-100 px-5 py-3 text-xs sm:grid-cols-2",children:[e.jsxs("p",{className:"break-all",children:[e.jsx("strong",{children:"Para:"})," ",A||"Sin email valido"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Asunto:"})," ",a.subject]})]}),e.jsx("div",{className:"flex-1 bg-[#EEF2F7] p-3 md:p-5 overflow-hidden",children:e.jsx("iframe",{title:"Vista previa del correo de asignacion de tutor",srcDoc:a.html,className:"w-full h-full rounded-[24px] bg-white border border-gray-200 shadow-sm"})}),e.jsxs("div",{className:"grid gap-2 border-t border-gray-100 bg-white p-4 sm:grid-cols-3",children:[e.jsx("button",{type:"button",onClick:()=>da(null),disabled:fe,className:"rounded-2xl border border-gray-200 bg-white py-3 text-[10px] font-black uppercase tracking-widest text-gray-600 disabled:opacity-60",children:"Cancelar"}),e.jsx("button",{type:"button",onClick:()=>void hr(!1),disabled:fe,className:"rounded-2xl border border-blue-200 bg-blue-50 py-3 text-[10px] font-black uppercase tracking-widest text-blue-700 disabled:opacity-60",children:fe?"Guardando...":"Asignar sin enviar"}),e.jsx("button",{type:"button",onClick:()=>void hr(!0),disabled:fe||!G,className:"rounded-2xl bg-blue-600 py-3 text-[10px] font-black uppercase tracking-widest text-white shadow-lg shadow-blue-500/20 disabled:cursor-not-allowed disabled:opacity-50",children:fe?"Procesando...":"Asignar y enviar correo"})]})]})})})(),ps&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/85 backdrop-blur-sm z-[10000] flex items-center justify-center p-3",children:e.jsxs("div",{className:"bg-white w-full max-w-5xl h-[92vh] rounded-[32px] shadow-2xl overflow-hidden flex flex-col border border-gray-100",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-gray-100 bg-white flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-violet-600",children:"Vista previa"}),e.jsx("h3",{className:"text-gray-900 font-black text-base truncate",children:_t||"Recibo mensual"})]}),e.jsx("button",{type:"button",onClick:()=>kt(!1),className:"px-4 py-2 rounded-xl text-[10px] font-black uppercase tracking-widest bg-gray-100 text-gray-600 hover:bg-gray-200 transition-colors shrink-0",children:"Cerrar"})]}),e.jsx("div",{className:"flex-1 bg-[#EEF2F7] p-3 md:p-5 overflow-hidden",children:e.jsx("iframe",{title:_t||"Vista previa del recibo mensual",srcDoc:xs,className:"w-full h-full rounded-[24px] bg-white border border-gray-200 shadow-sm"})})]})}),ys&&r&&e.jsx("div",{className:"fixed inset-0 z-[10020] flex items-center justify-center bg-gray-900/90 p-3 backdrop-blur-md",children:e.jsxs("div",{className:"flex max-h-[94vh] w-full max-w-2xl flex-col overflow-hidden rounded-[32px] bg-white shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-100 bg-gray-50 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-green-600",children:"WhatsApp familiar editable"}),e.jsxs("h3",{className:"mt-1 text-xl font-black text-gray-900",children:["Acuerdo de ",r.n
333ame]}),e.jsx("p",{className:"mt-1 text-[11px] font-bold text-gray-500",children:"Revisa el texto, cámbialo si hace falta y después cópialo o ábrelo en WhatsApp."})]}),e.jsx("button",{type:"button",onClick:()=>Ha(!1),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white text-sm font-black text-gray-600 shadow-sm hover:bg-gray-100",children:"X"})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-5 sm:p-6",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-2 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Mensaje completo"}),e.jsx("textarea",{value:ma,onChange:a=>{Va(a.target.value),ua(!1)},className:"h-[52vh] min-h-[360px] w-full resize-y rounded-2xl border border-gray-200 bg-gray-50 p-4 text-sm font-medium leading-relaxed text-gray-800 outline-none transition focus:border-green-400 focus:bg-white"})]}),e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-blue-600",children:"Enlace personal conectado a la ficha"}),e.jsx("p",{className:"mt-2 break-all text-[11px] font-bold leading-relaxed text-blue-900",children:xa}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-blue-700",children:"No cambies este enlace al editar el mensaje. Abre directamente el acuerdo de esta familia y permite firmarlo con el dedo."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-2 border-t border-gray-100 bg-white p-4 sm:grid-cols-3",children:[e.jsx("button",{type:"button",onClick:()=>Ha(!1),className:"rounded-xl bg-gray-100 px-4 py-3 text-[10px] font-black uppercase tracking-widest text-gray-600 hover:bg-gray-200",children:"Cerrar"}),e.jsx("button",{type:"button",onClick:yn,className:"rounded-xl border border-green-200 bg-green-50 px-4 py-3 text-[10px] font-black uppercase tracking-widest text-green-700 hover:bg-green-100",children:js?"Texto copiado":"Copiar WhatsApp"}),e.jsx("button",{type:"button",onClick:vn,className:"rounded-xl bg-[#25D366] px-4 py-3 text-[10px] font-black uppercase tracking-widest text-white shadow-lg shadow-green-500/20 hover:bg-green-600",children:"Abrir en WhatsApp"})]})]})}),fs&&r&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/90 backdrop-blur-md z-[10000] flex flex-col justify-center items-center p-4 animate-in fade-in",children:e.jsxs("div",{className:"bg-white w-full max-w-md rounded-[32px] shadow-2xl flex flex-col max-h-[90vh] overflow-hidden relative",children:[e.jsx("button",{onClick:()=>pa(!1),className:"absolute top-4 right-4 bg-gray-200 text-gray-800 hover:bg-gray-300 w-8 h-8 rounded-full font-black text-xs z-20 transition-colors",children:"X"}),e.jsxs("div",{id:"printable-student-contract",className:"p-8 overflow-y-auto font-sans text-left text-xs text-gray-800 leading-relaxed",children:[e.jsxs("div",{className:"text-center mb-6 border-b-2 border-black/10 pb-4",children:[e.jsx("h2",{className:"text-xl font-black tracking-tight text-gray-900",children:"Profe en Casa"}),e.jsx("p",{className:"text-[9px] font-bold tracking-widest uppercase text-gray-500 mt-1",children:r.contract_signed?"Acuerdo familiar confirmado":"Copia para revisar antes de firmar"})]}),e.jsx("div",{className:"mb-4 bg-gray-50 p-3 border border-gray-200 rounded-lg text-[10px]",children:e.jsxs("p",{children:[e.jsx("strong",{className:"font-black uppercase tracking-widest text-gray-900 block",children:"Alumno / Tutor:"})," ",r.name," (",R(r),") ",e.jsx("br",{})," ",A]})}),e.jsx("div",{className:"mb-6",children:e.jsx(qo,{details:un,savedAgreement:r.contract_signed?zo(r.signature_data):void 0})}),r.contract_signed?e.jsxs("div",{className:"border-t border-gray-200 pt-4 text-center",children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-500 mb-2",children:"Confirmación guardada"}),e.jsx("div",{className:"w-full max-w-[200px] mx-auto border-b border-gray-300 pb-2 mb-2",children:(Ar=H(r))!=null&&Ar.image?e.jsx("img",{src:(Er=H(r))==null?void 0:Er.image,alt:"Firma familiar",className:"w-full h-auto object-contain max-h-[80px] filter contrast-125"}):e.jsx("p",{className:"py-6 text-center text-[10px] font-bold text-gray-400",children:(($r=H(r))==null?void 0:$r.signatureMethod)==="paper"?"Firmado en papel. Copia guardada por Profe en Casa.":"Firma guardada"})}),e.jsxs("div",{className:"text-[9px] text-gray-600 bg-gray-50 p-3 rounded border border-gray-100 space-y-1",children:[e.jsxs("p",{children:["Forma de firma: ",e.jsx("strong",{className:"text-gray-900",children:((Pr=H(r))==null?void 0:Pr.signatureMethod)==="paper"?"En papel":"Online desde la app"})]}),((Rr=H(r))==null?void 0:Rr.paperReceiptMethodLabel)&&e.jsxs("p",{children:["Recepción: ",e.jsx("strong",{className:"text-gray-900",children:(Dr=H(r))==null?void 0:Dr.paperReceiptMethodLabel})]}),e.jsxs("p",{children:["Confirmado por: ",e.jsx("strong",{className:"text-gray-900",children:((Fr=H(r))==null?void 0:Fr.signerName)||R(r)||"Dato no dis
333ponible"})]}),e.jsxs("p",{children:["Relación: ",e.jsx("strong",{className:"text-gray-900",children:((Tr=H(r))==null?void 0:Tr.signerRole)||"Firma anterior sin este dato"})]}),e.jsxs("p",{children:["Fecha: ",e.jsx("strong",{className:"text-gray-900",children:((Lr=H(r))==null?void 0:Lr.date)||"Fecha no disponible"})]}),e.jsxs("p",{children:["Versión: ",e.jsx("strong",{className:"text-gray-900",children:((Ir=H(r))==null?void 0:Ir.agreementVersion)||"Acuerdo anterior"})]})]})]}):e.jsx("div",{className:"rounded-xl border border-blue-100 bg-blue-50 p-3 text-center text-[10px] font-bold text-blue-800",children:"Copia sin firmar. Puedes imprimirla o guardarla como PDF para entregarla en la academia, enviarla por WhatsApp o enviarla por correo electrónico."})]}),e.jsxs("div",{className:"p-4 bg-gray-50 border-t border-gray-100 flex gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>pa(!1),className:"flex-1 bg-gray-200 text-gray-700 font-black uppercase text-[10px] tracking-widest py-3 rounded-xl hover:bg-gray-300",children:"Cerrar"}),e.jsx("button",{onClick:Un,className:"flex-[2] bg-emerald-500 text-white font-black uppercase text-[10px] tracking-widest py-3 rounded-xl shadow-lg shadow-emerald-500/30 flex items-center justify-center gap-2 active:scale-95 transition-transform",children:"Imprimir copia"})]})]})}),Ns&&r&&e.jsx("div",{className:"fixed inset-0 z-[10010] flex items-center justify-center bg-gray-900/90 p-3 backdrop-blur-md",children:e.jsxs("div",{className:"flex max-h-[94vh] w-full max-w-2xl flex-col overflow-hidden rounded-[32px] bg-white shadow-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-gray-100 bg-gray-50 px-6 py-5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-black uppercase tracking-widest text-gray-400",children:"Alternativa a la firma online"}),e.jsx("h3",{className:"mt-1 text-xl font-black text-gray-900",children:"Registrar firma en papel"}),e.jsxs("p",{className:"mt-1 text-[11px] font-bold text-gray-500",children:["Alumno/a: ",r.name]})]}),e.jsx("button",{type:"button",onClick:()=>ye(!1),className:"flex h-9 w-9 items-center justify-center rounded-full bg-white text-sm font-black text-gray-600 shadow-sm hover:bg-gray-100",children:"X"})]}),e.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto p-6",children:[e.jsx("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4 text-[11px] leading-relaxed text-blue-800",children:"La firma desde el Portal de Familia sigue siendo la opción principal. Usa este registro solo si conservamos una copia firmada en la academia o recibida por WhatsApp o correo electrónico."}),e.jsxs("section",{className:"space-y-3 rounded-2xl border border-gray-200 p-4",children:[e.jsx("h4",{className:"text-xs font-black uppercase tracking-widest text-gray-700",children:"Quién firma y dónde recibimos la copia"}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Nombre y apellidos"}),e.jsx("input",{type:"text",value:u.signerName,onChange:a=>L({...u,signerName:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Relación con el alumno/a"}),e.jsxs("select",{value:u.signerRole,onChange:a=>L({...u,signerRole:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",children:[e.jsx("option",{value:"",children:"Selecciona una opción"}),e.jsx("option",{value:"Madre",children:"Madre"}),e.jsx("option",{value:"Padre",children:"Padre"}),e.jsx("option",{value:"Tutor/a",children:"Tutor/a"}),e.jsx("option",{value:"Alumno/a adulto/a",children:"Alumno/a adulto/a"})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Fecha de firma"}),e.jsx("input",{type:"date",value:u.signedDate,onChange:a=>L({...u,signedDate:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Cómo llega la copia"}),e.jsxs("select",{value:u.receiptMethod,onChange:a=>L({...u,receiptMethod:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",children:[e.jsx("option",{value:"academy",children:"Firmado en la academia"}),e.jsx("option",{value:"whatsapp",children:"Recibido por WhatsApp"}),e.jsx("option",{value:"email",children:"Recibido por correo electrónico"})]})]})]})]}),e.jsxs("section",{className:"space-y-3 rounded-2xl border border-gray-200 p-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-black uppercase tracking-widest text-gray-700",children:"Condiciones concretas del curso 2026/2
333027"}),e.jsx("p",{className:"mt-1 text-[10px] font-bold text-gray-500",children:"Comprueba estos datos con la copia antes de guardar."})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Modalidad"}),e.jsxs("select",{value:u.modality,onChange:a=>L({...u,modality:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",children:[e.jsx("option",{value:"",children:"Selecciona una modalidad"}),e.jsx("option",{value:"Academia Profe a 3",children:"Academia Profe a 3"}),e.jsx("option",{value:"Profesor/a a domicilio",children:"Profesor/a a domicilio"}),e.jsx("option",{value:"Clases online",children:"Clases online"})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Nivel y asignatura"}),e.jsx("input",{type:"text",value:u.levelAndSubjects,onChange:a=>L({...u,levelAndSubjects:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",placeholder:"Ejemplo: 2 ESO - Matemáticas"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Frecuencia semanal"}),e.jsxs("select",{value:u.weeklyFrequency,onChange:a=>L({...u,weeklyFrequency:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",children:[e.jsx("option",{value:"",children:"Selecciona una frecuencia"}),e.jsx("option",{value:"1 día por semana",children:"1 día por semana"}),e.jsx("option",{value:"2 días por semana",children:"2 días por semana"}),e.jsx("option",{value:"3 días por semana",children:"3 días por semana"})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Horario habitual"}),e.jsx("input",{type:"text",value:u.regularSchedule,onChange:a=>L({...u,regularSchedule:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",placeholder:"Ejemplo: martes y jueves 17:30-19:00"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Duración de cada sesión"}),e.jsxs("select",{value:u.sessionDuration,onChange:a=>L({...u,sessionDuration:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",children:[e.jsx("option",{value:"",children:"Selecciona una duración"}),e.jsx("option",{value:"1 hora",children:"1 hora"}),e.jsx("option",{value:"1 hora y 30 minutos",children:"1 hora y 30 minutos"}),e.jsx("option",{value:"2 horas",children:"2 horas"})]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Precio por sesión"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:"number",min:"0",step:"0.01",value:u.sessionPrice,onChange:a=>L({...u,sessionPrice:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 pr-10 text-sm font-bold text-gray-900 outline-none focus:border-blue-500",placeholder:"0,00"}),e.jsx("span",{className:"absolute right-3 top-3 text-sm font-black text-gray-500",children:"€"})]})]}),e.jsxs("label",{className:"block sm:col-span-2",children:[e.jsx("span",{className:"mb-1 block text-[9px] font-black uppercase tracking-widest text-gray-500",children:"Fecha de inicio"}),e.jsx("input",{type:"date",value:u.startDate,onChange:a=>L({...u,startDate:a.target.value}),className:"w-full rounded-xl border border-gray-200 bg-gray-50 px-3 py-3 text-sm font-bold text-gray-900 outline-none focus:border-blue-500"})]})]})]}),e.jsxs("label",{className:"flex cursor-pointer items-start gap-3 rounded-2xl border border-emerald-200 bg-emerald-50 p-4",children:[e.jsx("input",{type:"checkbox",checked:u.paperCopyStored,onChange:a=>L({...u,paperCopyStored:a.target.checked}),className:"mt-0.5 h-5 w-5 accent-emerald-600"}),e.jsx("span",{className:"text-[11px] font-bold leading-relaxed text-emerald-900",children:"Confirmo que Profe en Casa conserva la copia f
333irmada, en papel o como archivo recibido."})]}),Dt&&e.jsx("p",{className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-center text-[11px] font-bold text-red-700",children:Dt})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 border-t border-gray-100 bg-gray-50 p-5",children:[e.jsx("button",{type:"button",onClick:()=>ye(!1),className:"rounded-xl bg-gray-200 py-3 text-[10px] font-black uppercase tracking-widest text-gray-700 hover:bg-gray-300",children:"Cancelar"}),e.jsx("button",{type:"button",onClick:Yn,disabled:Rt,className:"rounded-xl bg-gray-900 py-3 text-[10px] font-black uppercase tracking-widest text-white shadow-lg transition active:scale-95 disabled:opacity-50",children:Rt?"Guardando...":"Registrar firma en papel"})]})]})}),Ts&&e.jsx("div",{className:"fixed inset-0 bg-gray-900/80 backdrop-blur-sm flex justify-center items-start z-[9999] p-4 overflow-y-auto pt-10 pb-20",children:e.jsxs("div",{className:"bg-white w-full max-w-md p-6 rounded-[32px] border border-gray-100 shadow-2xl relative animate-in zoom-in-95 duration-200",children:[e.jsx("h3",{className:"text-gray-900 font-black text-2xl mb-1",children:"Nueva Matricula"}),e.jsx("p",{className:"text-gray-500 text-xs mb-6 font-bold uppercase tracking-widest",children:"Alta manual de alumno"}),e.jsxs("form",{onSubmit:$n,className:"space-y-4",children:[e.jsxs("div",{className:"bg-gray-50 p-5 rounded-[24px] border border-gray-100 space-y-4",children:[e.jsxs("div",{className:"bg-blue-50 border border-blue-100 rounded-2xl p-4",children:[e.jsx("p",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest mb-1",children:"Fecha de alta"}),e.jsx("p",{className:"text-gray-900 text-sm font-black",children:Yt()}),e.jsx("p",{className:"text-[11px] text-blue-700 font-bold mt-1 leading-relaxed",children:"Se guarda automaticamente para tener referencia del dia en que entra la familia."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Nombre alumno/a"}),e.jsx("input",{type:"text",required:!0,value:c.first_name,onChange:a=>C({...c,first_name:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: Laura"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Apellidos alumno/a"}),e.jsx("input",{type:"text",required:!0,value:c.last_name,onChange:a=>C({...c,last_name:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: Garcia Ruiz"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Nombre tutor"}),e.jsx("input",{type:"text",required:!0,value:c.parent_first_name,onChange:a=>C({...c,parent_first_name:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: Carmen"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Apellidos tutor"}),e.jsx("input",{type:"text",required:!0,value:c.parent_last_name,onChange:a=>C({...c,parent_last_name:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: Lopez Martin"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-green-500 text-[9px] font-black uppercase tracking-widest mb-2 flex items-center gap-1",children:"WhatsApp"}),e.jsx("input",{type:"tel",required:!0,value:c.phone,onChange:a=>C({...c,phone:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-green-200 outline-none focus:border-green-500 text-sm font-bold shadow-sm",placeholder:"+34 600 000 000"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Email"}),e.jsx("input",{type:"email",value:c.email,onChange:a=>C({...c,email:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"pt-2 border-t border-gray-200/50",children:[e.jsx("label",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Direccion"}),e.jsx("input",{type:"text",value:c.address,onChange:a=>C({...c,address:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm mb-3",placeholder:"Ej: Calle Gran Via 12"}),e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Detalles de direccion"}),e.jsx("input",{type:"text",value:c.address_details,onChange:a=>C({...c,address_details:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm mb-3",placeholder:"Ej: 3ºB, portal 2, urbanizacion..."}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Codigo postal"}),e.jsx("input",{type:"text",value:c.postal_code,onChange:a=>C({...c,postal_code:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: 18140"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Localidad"}),e.jsx("input",{type:"text",required:!0,value:c.location,onChange:a=>C({...c,location:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: Granada"})]})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 mt-3",children:e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Provincia"}),e.jsx("input",{type:"text",required:!0,value:c.province,onChange:a=>C({...c,province:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm",placeholder:"Ej: Granada"})]})})]}),e.jsxs("div",{className:"pt-2 border-t border-gray-200/50 grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Nivel Educativo"}),e.jsxs("select",{value:c.level,onChange:a=>C({...c,level:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-[#1c74e9] text-sm font-bold shadow-sm cursor-pointer",children:[e.jsx("option",{value:"",children:"Selecciona el curso exacto"}),Hr.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-purple-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Modalidad"}),e.jsxs("select",{value:c.modality,onChange:a=>C({...c,modality:a.target.value}),className:"w-full bg-purple-50 text-purple-700 p-3.5 rounded-xl border border-purple-200 outline-none focus:border-purple-500 text-sm font-black shadow-sm cursor-pointer",children:[e.jsx("option",{value:"Profe en casa (Domicilio)",children:"Profe en casa (Domicilio)"}),e.jsx("option",{value:"Academia Profe a 3",children:"Academia Profe a 3"}),e.jsx("option",{value:"Clases Online",children:"Clases Online"})]})]})]}),e.jsxs("div",{className:"pt-2",children:[e.jsxs("label",{className:"text-emerald-600 text-[9px] font-black uppercase tracking-widest mb-2 block",children:["Colegio / instituto ",e.jsx("span",{className:"text-gray-400",children:"(opcional)"})]}),e.jsx("input",{type:"text",value:c.school_name,onChange:a=>C({...c,school_name:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-emerald-100 outline-none focus:border-emerald-500 text-sm font-bold shadow-sm",placeholder:"Ej: IES Trevenque, Sagrado Corazon..."})]}),e.jsxs("div",{className:"pt-2 border-t border-gray-200/50",children:[e.jsx("label",{className:"text-blue-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Disponibilidad Horaria"}),e.jsx("input",{type:"text",value:c.availability,onChange:a=>C({...c,availability:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-blue-500 text-sm font-bold shadow-sm mb-3",placeholder:"Ej: Lunes y Miercoles tardes..."}),e.jsx("label",{className:"text-amber-500 text-[9px] font-black uppercase tracking-widest mb-2 block",children:"Observaciones / N
333otas"}),e.jsx("textarea",{value:c.notes,onChange:a=>C({...c,notes:a.target.value}),className:"w-full bg-white text-gray-900 p-3.5 rounded-xl border border-gray-200 outline-none focus:border-amber-500 text-sm font-bold shadow-sm",placeholder:"Necesidades especiales, deficit de atencion...",rows:2})]}),e.jsxs("div",{className:"pt-2 border-t border-gray-200/50",children:[e.jsx("label",{className:"text-[#1c74e9] text-[9px] font-black uppercase tracking-widest mb-3 block",children:"Asignaturas Principales"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Fs.map(a=>e.jsxs("button",{type:"button",onClick:()=>Sn(a),className:`px-3 py-2 rounded-xl text-[10px] font-black transition-all border ${c.subjects.includes(a)?"bg-blue-50 border-blue-200 text-[#1c74e9] shadow-sm":"bg-white border-gray-200 text-gray-500 hover:bg-gray-50"}`,children:[c.subjects.includes(a)&&e.jsx("span",{className:"mr-1",children:"OK"}),a]},a))})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t border-gray-100",children:[e.jsx("button",{type:"button",onClick:()=>Ja(!1),className:"flex-1 py-4 rounded-2xl font-black text-[10px] uppercase tracking-widest text-gray-500 bg-gray-100 hover:bg-gray-200 transition-colors",children:"Cancelar"}),e.jsx("button",{type:"submit",disabled:Tt||c.subjects.length===0,className:"flex-[2] py-4 rounded-2xl font-black text-[10px] uppercase tracking-widest text-white bg-[#1c74e9] shadow-lg shadow-blue-500/30 hover:bg-blue-600 transition-all disabled:opacity-50 disabled:bg-gray-300 disabled:shadow-none active:scale-95",children:Tt?"Guardando...":"Matricular Alumno"})]})]})]})})]})};export{vl as AdminStudents};

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.