1import{r as c,j as e,s as F}from"./index-bMFZPluE.js";import{e as L,f as O}from"./educationCatalog-pqwMnMBs.js";import{v as R,n as I}from"./phoneFormatting-bIoASOCT.js";import{f as $,P as y}from"./PrivacyPolicy-B2143qp5.js";import{C as M}from"./CompactPrivacyNotice-Dx4_VTkN.js";const D=[...L],v=["Academia Profe a 3","Profe en casa (Domicilio)","Clases Online","Por definir"],T=["WhatsApp","Llamada","WhatsApp o llamada"],W=new Set(["puerta_academia","consulta_familia","qr_profesor","web","anuncio_familias","selectividad","referido","whatsapp_manual"]),j=(o,l)=>`${String(o||"").trim()} ${String(l||"").trim()}`.trim(),z=()=>{if(typeof window>"u")return"";const l=(new URLSearchParams(window.location.search).get("source")||"").trim().toLowerCase();return W.has(l)?l:""},G=(o,l)=>o==="puerta_academia"?"Puerta academia":o==="consulta_familia"?"Consulta familia":o==="qr_profesor"?"QR profesor":o==="web"?"Web":o==="anuncio_familias"?"Anuncio familias":o==="selectividad"?"Selectividad":o==="referido"?"Recomendacion":o==="whatsapp_manual"?"WhatsApp":l==="door"?"Puerta academia":l==="public_family"?"Consulta familia":"Visita personal en la academia",H=o=>o==="puerta_academia"?"Puerta academia":o==="consulta_familia"?"Consulta familia":o==="qr_profesor"?"QR profesor":o==="web"?"Web":o==="anuncio_familias"?"Anuncio familias":o==="selectividad"?"Selectividad":o==="referido"?"Referido":o==="whatsapp_manual"?"WhatsApp manual":"",Q=o=>{const l=String(o||"").toLowerCase();return l.includes("bach")?["Matematicas Bach Ciencias","Matematicas Bach Sociales","Fisica","Quimica","Lengua","Ingles","Economia"]:l.includes("3")&&l.includes("eso")||l.includes("4")&&l.includes("eso")?["Matematicas","Fisica","Quimica","Lengua","Ingles","Geografia e Historia","Apoyo general / Deberes"]:l.includes("1")&&l.includes("eso")||l.includes("2")&&l.includes("eso")?["Matematicas","Lengua","Ingles","Ciencias","Apoyo general / Deberes"]:[...O]},w=(o,l="")=>({attended_by:"",origin:G(l,o),contact_preference:"WhatsApp",parent_first_name:"",parent_last_name:"",student_first_name:"",student_last_name:"",phone:"+34 ",email:"",locality:"",province:"Granada",level:"",modality:"Academia Profe a 3",subjects:"",school_name:"",availability:"",notes:"",door_mode:o==="door"}),X=()=>{const o=typeof window<"u"&&["localhost","127.0.0.1"].includes(window.location.hostname),l=typeof window<"u"?window.location.pathname.toLowerCase():"",i=z(),d=i==="puerta_academia"||l.includes("/puerta-academia"),u=!d&&(i==="consulta_familia"||l.includes("/familia-interesada")||l.includes("/contacto-academia")||l.includes("/lead")),s=d?"door":u?"public_family":"internal",r=s!=="internal",[g,p]=c.useState(!1),[_,b]=c.useState(!1),[m,x]=c.useState(!1),[a,n]=c.useState(w(s,i)),N=c.useMemo(()=>Q(a.level),[a.level]),k=async t=>{t.preventDefault();const C=!a.parent_first_name.trim()||!a.student_first_name.trim()||!a.phone.trim()||!a.level.trim()||!a.subjects.trim(),E=r&&(!a.parent_last_name.trim()||!a.student_last_name.trim()||!a.locality.trim()),S=s==="internal"&&!a.attended_by.trim();if(C||E||S){alert(r?"Completa al menos nombre y apellidos del tutor y del alumno, telefono, localidad, curso exacto y asignatura principal.":"Completa quien atiende, nombre del tutor y del alumno, telefono, curso exacto y asignatura principal.");return}if(r&&!m){alert("Antes de enviar la solicitud, necesitamos que confirmes que has leido la informacion de privacidad.");return}const f=R(a.phone,"telefono de WhatsApp");if(!f.ok){alert(f.error);return}p(!0);const q=j(a.parent_first_name,a.parent_last_name),P=j(a.student_first_name,a.student_last_name),B=[s==="door"?"Formulario abierto desde el QR de la puerta de la academia.":s==="public_family"?"Formulario general enviado a una familia que ha pedido informacion.":"Registro rapido interno de academia.",i?`[Origen automatizacion] ${i}`:null,i?`[Origen enlace] ${H(i)}`:null,s==="internal"&&a.attended_by.trim()?a.origin==="Visita personal en la academia"?`Atendida en academia por ${a.attended_by.trim()}.`:`Registrada por ${a.attended_by.trim()}.`:null,`[Tutor nombre] ${a.parent_first_name.trim()}`,`[Tutor apellidos] ${a.parent_last_name.trim()}`,`[Alumno nombre] ${a.student_first_name.trim()}`,`[Alumno apellidos] ${a.student_last_name.trim()}`,a.school_name.trim()?`[Centro educativo] ${a.school_name.trim()}`:null,a.contact_preference.trim()?`Preferencia de contacto: ${a.contact_preference.trim()}`:null,a.availability.trim()?`Horario comentado: ${a.availability.trim()}`:null,a.notes.trim()?`Observaciones: ${a.notes.trim()}`:null,r?`[Privacidad] Informacion aceptada · version ${y} · ${new Date().toISOString()}
1`:null].filter(Boolean);if(o){p(!1),b(!0);return}const{error:h}=await F.rpc("submit_public_lead",{payload:{parent_name:q,student_name:P,email:a.email.trim(),locality:a.locality.trim(),province:a.province.trim()||"Granada",phone:I(a.phone),origin:a.origin,level:a.level,modality:a.modality,subjects:a.subjects.trim(),subject_needed:a.subjects.trim(),school_name:a.school_name.trim(),availability:a.availability.trim(),notes:B.join(` 2`),privacy_confirmed:r?m:!1,privacy_version:r?y:"",collection_context:r?"public":"staff_assisted"}});if(p(!1),h){console.error("Error guardando la familia interesada:",h),alert("No hemos podido guardar la solicitud. Tus datos siguen escritos para que puedas volver a intentarlo dentro de unos instantes.");return}b(!0)},A=()=>{b(!1),x(!1),n(w(s,i))};return _?e.jsx("div",{className:"min-h-full bg-[#F5F7FA] p-5",children:e.jsxs("div",{className:"bg-white rounded-[32px] border border-gray-100 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#16A0EB] to-[#0C6FAE] p-8 text-white text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-white/15 rounded-2xl mx-auto flex items-center justify-center text-3xl mb-4 border border-white/20",children:"ð«"}),e.jsx("h1",{className:"text-2xl font-black leading-tight",children:o?"Prueba local completada":r?"Solicitud enviada":"Familia registrada"}),e.jsx("p",{className:"text-blue-100 text-[11px] font-bold uppercase tracking-widest mt-2",children:r?"Gracias por contactar":"Seguimiento comercial"})]}),e.jsxs("div",{className:"p-6 text-center space-y-4",children:[e.jsx("p",{className:"text-gray-700 font-bold leading-relaxed",children:o?"No se han guardado datos ni enviado comunicaciones.":r?"Hemos recibido tus datos. En cuanto podamos, nos pondremos en contacto contigo.":"La familia interesada ya ha entrado en el seguimiento de la academia para que coordinacion pueda continuar el proceso."}),e.jsx("button",{type:"button",onClick:A,className:"w-full py-4 bg-[#FC9A05] text-white rounded-2xl font-black text-[11px] uppercase tracking-widest shadow-lg shadow-orange-500/20",children:r?"Enviar otra solicitud":"Registrar otra visita"})]})]})}):e.jsx("div",{className:"min-h-full bg-[#F5F7FA] p-4 sm:p-6",children:e.jsxs("div",{className:"bg-white rounded-[32px] border border-gray-100 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"bg-gradient-to-br from-[#16A0EB] to-[#0C6FAE] p-7 text-white text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-white/15 rounded-2xl mx-auto flex items-center justify-center text-3xl mb-4 border border-white/20",children:r?"ð±":"ð"}),e.jsx("h1",{className:"text-2xl font-black leading-tight",children:d?"Familia interesada":u?"Solicitud de informacion":"Registrar visita"}),e.jsx("p",{className:"text-blue-100 text-[11px] font-bold uppercase tracking-widest mt-2",children:d?"Solicitud desde la puerta de la academia":u?"Cuéntanos qué apoyo necesitáis":"Registro interno de profes y coordinación"})]}),e.jsxs("form",{onSubmit:k,className:"p-6 space-y-5",children:[e.jsxs("div",{className:"rounded-2xl border border-blue-100 bg-blue-50 p-4",children:[e.jsx("p",{className:"text-[#0C6FAE] text-[10px] font-black uppercase tracking-widest",children:"Uso rapido"}),e.jsx("p",{className:"text-blue-950 text-sm font-bold mt-2 leading-relaxed",children:d?"Si has pasado por la academia y ahora mismo no estamos, dejanos aqui tus datos. Asi podremos atenderte mejor y ponernos en contacto contigo cuanto antes.":u?"Dejanos los datos basicos del alumno y el apoyo que necesitais. Coordinacion revisara las opciones disponibles y se pondra en contacto contigo.":"Anota solo estos datos imprescindibles. La consulta entrara en Radar Leads y coordinacion continuara el seguimiento."})]}),r?e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Como prefieres que te contactemos"}),e.jsx("select",{"aria-label":"Forma de contacto preferida",value:a.contact_preference,onChange:t=>n({...a,contact_preference:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",children:T.map(t=>e.jsx("option",{value:t,children:t},t))})]}):e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Profesor/a que registra *"}),e.jsx("input",{required:!0,value:a.attended_by,onChange:t=>n({...a,attended_by:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Tu nombre"})]}),e.jsxs("div",{className:r?"grid grid-cols-1 sm:grid-cols-2 gap-4":"",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:r?"Nombre padre, madre o tutor legal *":"Nombre tutor *"}),e.jsx("input",{required:!0,value:a.parent_first_name,onChange:t=>n({...a,parent_first_name:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:r?"Ej: MarÃa":"Nombre tutor"})]}),r&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:["Apellidos tutor ",r?"*":"(opcional)"]}),e.jsx("input",{required:r,value:a.parent_last_name,onChange:t=>n({...a,parent_last_name:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Ej: GarcÃa López"})]})]}),e.jsxs("div",{className:r?"grid grid-cols-1 sm:grid-cols-2 gap-4":"",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:r?"Nombre del alumno/a *":"Nombre alumno *"}),e.jsx("input",{required:!0,value:a.student_first_name,onChange:t=>n({...a,student_first_name:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Ej: Javier"})]}),r&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:["Apellidos alumno ",r?"*":"(opcional)"]}),e.jsx("input",{required:r,value:a.student_last_name,onChange:t=>n({...a,student_last_name:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Ej: Moreno Ruiz"})]})]}),e.jsxs("div",{className:r?"grid grid-cols-1 sm:grid-cols-2 gap-4":"",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Telefono *"}
2),e.jsx("input",{required:!0,value:a.phone,onChange:t=>n({...a,phone:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"+34 600 000 000"})]}),r&&e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Email"}),e.jsx("input",{type:"email",value:a.email,onChange:t=>n({...a,email:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Opcional"})]})]}),r&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:["Localidad ",r?"*":"(opcional)"]}),e.jsx("input",{required:r,value:a.locality,onChange:t=>n({...a,locality:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"La Zubia"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Provincia"}),e.jsx("input",{value:a.province,onChange:t=>n({...a,province:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Granada"})]})]}),e.jsxs("div",{className:r?"grid grid-cols-1 sm:grid-cols-2 gap-4":"",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Curso exacto *"}),e.jsxs("select",{"aria-label":"Curso exacto del alumno",required:!0,value:a.level,onChange:t=>n({...a,level:t.target.value,subjects:""}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",children:[e.jsx("option",{value:"",children:"Selecciona curso exacto"}),D.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),r&&e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:r?"Tipo de clases que os interesa":"Modalidad"}),e.jsx("select",{"aria-label":"Tipo de clases",value:a.modality,onChange:t=>n({...a,modality:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",children:v.map(t=>e.jsx("option",{value:t,children:t},t))})]})]}),r&&e.jsxs("div",{children:[e.jsxs("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:["Colegio / instituto ",e.jsx("span",{className:"text-gray-400",children:"(opcional)"})]}),e.jsx("input",{value:a.school_name,onChange:t=>n({...a,school_name:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:"Ej: IES Trevenque, Sagrado Corazon..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:"Asignatura principal *"}),e.jsxs("select",{"aria-label":"Asignatura principal",required:!0,value:a.subjects,onChange:t=>n({...a,subjects:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",children:[e.jsx("option",{value:"",children:"Selecciona asignatura"}),N.map(t=>e.jsx("option",{value:t,children:t},t))]})]}),r&&e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:r?"Tardes en las que no puede asistir":"Horario comentado"}),e.jsx("p",{className:"mb-2 text-[11px] leading-relaxed text-gray-500",children:"Esta informacion nos ayuda a buscar grupo, pero no confirma todavia un horario."}),e.jsx("input",{value:a.availability,onChange:t=>n({...a,availability:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors",placeholder:r?"Ej: No puede lunes ni miercoles":"Ej: martes y jueves 17:30"})]}),!r&&e.jsxs("details",{className:"rounded-2xl border border-gray-200 bg-gray-50 p-4",children:[e.jsx("summary",{className:"cursor-pointer text-[10px] font-black uppercase tracking-widest text-gray-600",children:"Añadir informacion opcional"}),e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("input",{value:a.parent_last_name,onChange:t=>n({...a,parent_last_name:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",placeholder:"Apellidos del adulto"}),e.jsx("input",{value:a.student_last_name,onChange:t=>n({...a,student_last_name:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",placeholder:"Apellidos del alumno/a"})]}),e.jsx("input",{type:"email",value:a.email,onChange:t=>n({...a,email:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",placeholder:"Correo electronico"}),e.jsx("input",{value:a.school_name,onChange:t=>n({...a,school_name:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",placeholder:"Colegi
2o o instituto"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx("input",{value:a.locality,onChange:t=>n({...a,locality:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",placeholder:"Localidad"}),e.jsx("select",{"aria-label":"Modalidad",value:a.modality,onChange:t=>n({...a,modality:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",children:v.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx("input",{value:a.availability,onChange:t=>n({...a,availability:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB]",placeholder:"Tardes en las que no puede asistir"}),e.jsx("textarea",{rows:3,value:a.notes,onChange:t=>n({...a,notes:t.target.value}),className:"w-full bg-white text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] resize-none",placeholder:"Observacion importante"})]})]}),r&&e.jsxs("div",{children:[e.jsx("label",{className:"text-gray-500 text-[10px] font-black uppercase tracking-widest mb-2 block",children:r?"Algo importante que debamos saber":"Observacion rapida"}),e.jsx("textarea",{rows:3,value:a.notes,onChange:t=>n({...a,notes:t.target.value}),className:"w-full bg-gray-50 text-gray-900 p-4 rounded-xl border border-gray-200 text-sm font-bold outline-none focus:border-[#16A0EB] transition-colors resize-none",placeholder:r?"Por ejemplo: varios hermanos, urgencia o si preferis academia u online":"Algo importante que haya contado la familia"})]}),r&&e.jsx(M,{summary:$,accepted:m,onChange:x,consentText:"He leido la informacion de privacidad y acepto que Profe en Casa use estos datos para atender esta solicitud y ponerse en contacto conmigo.",footnote:"Puedes abrir la politica completa sin perder los datos escritos en el formulario.",compactHeightClass:"max-h-28"}),e.jsx("button",{type:"submit",disabled:g||r&&!m,className:"w-full py-4 bg-[#FC9A05] text-white rounded-2xl font-black text-[11px] uppercase tracking-widest shadow-lg shadow-orange-500/20 disabled:opacity-60 disabled:cursor-not-allowed disabled:bg-gray-400 disabled:shadow-none",children:g?"Guardando...":r?"Enviar solicitud":"Registrar consulta"})]})]})})};export{X as PublicWalkInLeadForm};
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.