var __gh = require("react").createElement, __gf = require("react").Fragment; var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var stdin_exports={};__export(stdin_exports,{default:()=>stdin_default,featureConfig:()=>featureConfig});module.exports=__toCommonJS(stdin_exports);var dataSources=[{key:"contratos",table:"pms__contratos",access:["public:read"],sensitive:["codigo","alojamiento_id","inquilino_id","tipo","fecha_inicio","fecha_fin","mensualidad","fianza","fianza_estado","dia_cobro","suministros_cubiertos","renovacion","estado","notas","firma_estado","firma_token","firmado_por","firmado_email","firmado_at","pdf_url","contrato_html","firma_cliente","firma_fecha","firma_ip","firma_completada","pdf_contrato","ocupantes","num_trabajadores","firma_token_arrendatario","firma_token_arrendador","inmueble_id","firma_arrendador","firma_arrendador_fecha","firma_arrendador_ip","firma_arrendador_nombre","alojamiento_id__display","inquilino_id__display","inmueble_id__display","estado__display","firma_estado__display","fianza_estado__display","renovacion__display","tipo__display","arrendatarios","avalistas","campos_valores","cobro_beneficiario","tipo_arrendatario","tipo_arrendatario__display","facturacion_modo","facturacion_modo__display","importe_iva_incluido","importe_iva_incluido__display","iva_modo","iva_modo__display","iva_pct","suministros_modo","suministros_modo__display","factura_inicio_at","factura_inicio_numero","fianza_cargo_at","fianza_cargo_numero","fianza_email_at"]},{key:"inquilinos",table:"pms__inquilinos",access:["public:read"],sensitive:["nombre","email","telefono","dni","empresa","idioma","estado","notas","clave_portal","empresa_nif","empresa_direccion","cargo","estado__display","idioma__display","direccion","tratamiento","tratamiento__display"]}];var featureConfig={dataSources,seedData:[],meta:{name:"Firma de contrato (p\xFAblico)",version:"1.0.0"}};var import_react=require("react"),import_framer_motion=require("framer-motion"),import_lucide_react=require("lucide-react"),COMPANY_ID=751,API_BASE=typeof window<"u"&&window.location.hostname==="localhost"?"http://localhost:3000":"",ACCENT="#EA682D",LOGO_HOSTWORKERS="https://gufi.dev/api/files/serve?path=company_751%2F7a175dd1-2a43-4850-8180-eb965b48035f_Negativo.png",EASE=[.4,0,.2,1],CONTACTO="hola@hostworkers.es";function textoDeclaracion(nombre,esArrendador){let quien=String(nombre||"").trim(),papel=esArrendador?"estar autorizada a firmar este documento en nombre de la parte arrendadora":"ser la persona que debe firmar este documento";return quien?`Declaro ser ${quien} y ${papel}.`:`Declaro ser la persona a la que va dirigido este enlace y ${papel}.`}function fechaEnPalabras(ymd){let m=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(ymd||""));if(!m)return"";try{return new Date(Number(m[1]),Number(m[2])-1,Number(m[3]),12,0,0).toLocaleDateString("es-ES",{day:"numeric",month:"long",year:"numeric"})}catch{return""}}function mensajeBloqueado(min,comoVolver="vuelve a abrir el enlace"){return`Esta conexi\xF3n ha acumulado demasiados intentos fallidos, as\xED que queda bloqueada durante ${min&&min>0?`unos ${min} minutos`:"unos minutos"}. El bloqueo es de la conexi\xF3n, no de tu enlace, y puede haberlo provocado otra persona de la misma red: mientras dure, aqu\xED no abrir\xE1 ning\xFAn enlace de firma, tampoco uno correcto. Si tienes prisa, prueba desde los datos del m\xF3vil en vez del wifi; si no, espera ese rato y ${comoVolver}. Seguir probando ahora no alarga la espera, pero tampoco la acorta. Si sigue sin abrir, escribe a ${CONTACTO}.`}function mensajeAlAbrir(motivo,datos,generico){switch(String(motivo||"")){case"enlace_sustituido":{let cuando=fechaEnPalabras(datos?.sustituido_el);return`Este enlace qued\xF3 anulado${cuando?` el ${cuando}`:""}: el contrato se volvi\xF3 a enviar a firmar y eso emite enlaces nuevos. Abre el \xDALTIMO correo de firma que hayas recibido y entra desde ah\xED \u2014 los de los correos anteriores ya no sirven. Si no lo encuentras, pide a quien te lo envi\xF3 que te reenv\xEDe el enlace actual.`}case"contrato_retirado":return"Este contrato se ha retirado y ya no se puede firmar. No es cosa tuya ni de tu enlace: quien te lo envi\xF3 lo ha dado de baja o lo ha rehecho. P\xEDdele el contrato nuevo.";case"firma_rechazada":return"Rechazaste este contrato, as\xED que su enlace ya no permite firmarlo. Si has cambiado de opini\xF3n, o si el rechazo es un error, d\xEDselo a quien te lo envi\xF3: tiene que volver a envi\xE1rtelo a firmar.";case"firma_caducada":return"Este enlace ha caducado: quien te lo envi\xF3 lo ha dado por vencido, as\xED que ya no permite firmar. Si todav\xEDa quieres firmar el contrato, p\xEDdele uno nuevo.";case"adenda_retirada":return"Este anexo se ha retirado y ya no se puede firmar. No es cosa tuya ni de tu enlace: quien te lo envi\xF3 lo ha dado de baja o lo ha rehecho. P\xEDdele el documento nuevo.";case"adenda_sin_documento":return"Este anexo todav\xEDa no tiene documento que firmar: quien te lo envi\xF3 lo ha dejado a medias. Av\xEDsale y te mandar\xE1 el enlace cuando est\xE9 listo.";case"contract_not_ready":return"Este contrato todav\xEDa no tiene documento que firmar: quien te lo envi\xF3 lo ha dejado a medias. Av\xEDsale y te mandar\xE1 el enlace cuando est\xE9 listo.";case"enlace_no_es_credencial":return"Este enlace no sirve para firmar: o apunta a m\xE1s de una persona, o es un enlace de solo lectura del gestor. Pide a quien te lo envi\xF3 que te mande el tuyo.";case"enlace_incompleto":return"Este enlace est\xE1 incompleto: no trae ni el contrato ni tu credencial de firma. Vuelve a abrirlo desde el correo, pulsando sobre el enlace entero.";case"falta_dni":return"Este contrato pide tu DNI/NIF para abrirse. Escr\xEDbelo y vuelve a intentarlo.";case"too_many_attempts":return mensajeBloqueado(datos?.espera_min);default:{let eco=datos&&datos.eco,esperado=Number(eco&&eco.esperado||0),limpio=eco&&eco.n_limpio!=null?Number(eco.n_limpio):null,llegado=eco&&eco.n!=null?Number(eco.n):null;return esperado>0&&limpio!=null&&limpio0?`El enlace ha llegado incompleto: le falta el final (han llegado ${limpio} caracteres de ${esperado}). Casi siempre es que se ha copiado a mano, o que WhatsApp o el correo lo han partido en dos l\xEDneas. Vuelve al mensaje donde te lo enviaron y \xE1brelo pulsando sobre el enlace, sin copiarlo ni escribirlo. Si aun as\xED no abre, pide que te lo reenv\xEDen: ${CONTACTO}.`:generico||"No hemos podido validar este enlace. Vuelve a intentarlo en un momento y, si sigue sin abrir, pide a quien te lo envi\xF3 el \xFAltimo correo de firma."}}}function mensajeAlFirmar(motivo,datos){switch(String(motivo||"")){case"contrato_retirado":return"Este contrato se ha retirado mientras lo ten\xEDas abierto, as\xED que tu firma no se ha registrado. No es cosa tuya ni de tu enlace: quien te lo envi\xF3 lo ha dado de baja o lo ha rehecho. P\xEDdele el contrato nuevo.";case"enlace_sustituido":{let cuando=fechaEnPalabras(datos?.sustituido_el);return`El contrato se volvi\xF3 a enviar a firmar${cuando?` el ${cuando}`:""} mientras lo ten\xEDas abierto, as\xED que este enlace qued\xF3 anulado y tu firma NO se ha registrado. Abre el \xDALTIMO correo de firma que hayas recibido y f\xEDrmalo desde ah\xED.`}case"firma_rechazada":return"Este contrato est\xE1 marcado como rechazado, as\xED que tu firma NO se ha registrado. Si lo rechazaste y has cambiado de opini\xF3n, o si el rechazo es un error, d\xEDselo a quien te lo envi\xF3: tiene que volver a envi\xE1rtelo a firmar.";case"firma_caducada":return"Este enlace ha caducado, as\xED que tu firma NO se ha registrado. Si todav\xEDa quieres firmar el contrato, pide a quien te lo envi\xF3 un enlace nuevo.";case"enlace_no_es_credencial":return"Este enlace no sirve para firmar: o apunta a m\xE1s de una persona, o es un enlace de solo lectura del gestor. Tu firma no se ha registrado. Pide a quien te lo envi\xF3 que te mande el tuyo.";case"already_signed":return"Tu firma ya estaba registrada, as\xED que no se ha vuelto a guardar. No tienes que hacer nada m\xE1s: si necesitas el documento firmado, p\xEDdeselo a quien te envi\xF3 el enlace.";case"pdf_failed":return"No hemos podido generar el PDF, as\xED que tu firma NO se ha guardado y no queda a medias. Vuelve a pulsar \xABFirmar contrato\xBB en un momento.";case"missing_code":return`Este enlace no trae el documento que hay que firmar, as\xED que tu firma NO se ha registrado. Suele pasar cuando se pegan dos enlaces juntos o se recorta el de un mensaje. Vuelve al mensaje original y \xE1brelo pulsando sobre el enlace entero, o pide que te lo reenv\xEDen: ${CONTACTO}.`;case"missing_dni":return"Este contrato necesita tu DNI/NIF para firmarse y no nos ha llegado, as\xED que tu firma NO se ha registrado. Vuelve a abrir el enlace desde el mensaje en que lo recibiste y escr\xEDbelo cuando te lo pida.";case"missing_declaracion":return"Marca la casilla en la que declaras ser quien firma y vuelve a intentarlo.";case"invalid_signature":return"No nos ha llegado tu firma. Dib\xFAjala otra vez en el recuadro y vuelve a intentarlo.";case"too_many_attempts":return mensajeBloqueado(datos?.espera_min,"vuelve a pulsar \xABFirmar contrato\xBB");case"invalid":return"Este enlace no vale para firmar, as\xED que tu firma NO se ha registrado. Reintentar no lo va a arreglar: o el enlace lleg\xF3 incompleto, o el contrato se ha vuelto a enviar y \xE9ste qued\xF3 anulado. Abre el \xDALTIMO correo de firma que hayas recibido y entra desde ah\xED; si sigue sin funcionar, pide a quien te lo envi\xF3 que te lo reenv\xEDe.";default:return"No se ha podido registrar la firma, as\xED que no ha quedado guardada. Vuelve a intentarlo en un momento y, si sigue sin salir, avisa a quien te envi\xF3 el enlace."}}function readUrlParams(){if(typeof window>"u")return{code:"",dni:"",previewToken:"",role:"arrendatario",token:"",codigoCorto:""};let segments=window.location.pathname.split("/").filter(Boolean),search=new URLSearchParams(window.location.search),codigoCorto=search.get("k")||"";!codigoCorto&&segments.length===2&&segments[0].toLowerCase()==="f"&&(codigoCorto=segments[1]);let code=search.get("c")||search.get("code")||"";code||(segments.length===2&&segments[0].toLowerCase()==="sign"?code=segments[1]:segments.length===1&&segments[0].toLowerCase()!=="sign"&&(code=segments[0]));let r=(search.get("r")||search.get("rol")||search.get("role")||"").trim().toLowerCase(),role=r==="arrendador"||r==="propietario"?"arrendador":"arrendatario";return{code:code.trim(),dni:(search.get("dni")||"").trim(),previewToken:(search.get("preview")||"").trim(),role,token:(search.get("t")||search.get("token")||"").trim(),codigoCorto:codigoCorto.trim()}}function formatLongDate(d){if(!d)return"";try{return new Date(d).toLocaleDateString("es-ES",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}}function downloadPdfFromBase64(base64,filename){let byteChars=atob(base64),byteNumbers=new Array(byteChars.length);for(let i=0;iURL.revokeObjectURL(url),1e3)}async function callPublicAutomation(name,body){let res=await fetch(`${API_BASE}/api/public/${COMPANY_ID}/automation/${name}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(body)}),json=await res.json().catch(()=>({}));if(!res.ok){let err=new Error(json&&(json.error||json.message)||"Request failed");throw err.status=res.status,err.body=json,err}if(json&&json.success===!1){let err=new Error(json.error||json.message||"Automation failed");throw err.status=res.status,err.body=json,err}return json&&typeof json=="object"&&"result"in json?json.result:json}function FirmaContratoRumar({id,gufi}){let[params]=(0,import_react.useState)(()=>readUrlParams()),role=params.role,esArrendador=role==="arrendador",token=params.token,codigoCorto=params.codigoCorto,[step,setStep]=(0,import_react.useState)("verify"),[data,setData]=(0,import_react.useState)(null),[dni,setDni]=(0,import_react.useState)(params.dni),[error,setError]=(0,import_react.useState)(null),[loadingVerify,setLoadingVerify]=(0,import_react.useState)(!1),[loadingSign,setLoadingSign]=(0,import_react.useState)(!1),[pdfBase64,setPdfBase64]=(0,import_react.useState)(null),[pdfFilename,setPdfFilename]=(0,import_react.useState)(null),[emailSent,setEmailSent]=(0,import_react.useState)(!1),[clientEmail,setClientEmail]=(0,import_react.useState)(null),[accepted,setAccepted]=(0,import_react.useState)(!1),[declarado,setDeclarado]=(0,import_react.useState)(!1),[hasSignature,setHasSignature]=(0,import_react.useState)(!1),[completo,setCompleto]=(0,import_react.useState)(null),[firmantesTrasFirmar,setFirmantesTrasFirmar]=(0,import_react.useState)(null),canvasRef=(0,import_react.useRef)(null),drawingRef=(0,import_react.useRef)(!1),lastPointRef=(0,import_react.useRef)(null),hasSignatureRef=(0,import_react.useRef)(!1),rolServidor=String(data?.rol||data?.role||"").trim(),esArrendadorReal=rolServidor?rolServidor.toLowerCase()==="arrendador":esArrendador,esOtraParte=!!rolServidor&&!/^(arrendador|arrendatario)$/i.test(rolServidor),code=params.code,enlaceVacio=!code&&!token&&!codigoCorto,previewToken=params.previewToken,previewMode=!!previewToken,initCanvas=(0,import_react.useCallback)(()=>{let canvas=canvasRef.current;if(!canvas)return;let rect=canvas.getBoundingClientRect();if(rect.width===0)return;let ratio=Math.max(window.devicePixelRatio||1,1);canvas.width=rect.width*ratio,canvas.height=rect.height*ratio;let ctx=canvas.getContext("2d");ctx&&(ctx.scale(ratio,ratio),ctx.fillStyle="#ffffff",ctx.fillRect(0,0,rect.width,rect.height),ctx.lineCap="round",ctx.lineJoin="round",ctx.strokeStyle="#111827",ctx.lineWidth=2.4,hasSignatureRef.current=!1,setHasSignature(!1))},[]);(0,import_react.useEffect)(()=>{if(step!=="sign"||previewMode)return;let raf=requestAnimationFrame(()=>initCanvas());return()=>cancelAnimationFrame(raf)},[step,previewMode,initCanvas]),(0,import_react.useEffect)(()=>{if(step!=="sign"||previewMode)return;let t,onResize=()=>{hasSignatureRef.current||(clearTimeout(t),t=setTimeout(initCanvas,150))};return window.addEventListener("resize",onResize),()=>{window.removeEventListener("resize",onResize),clearTimeout(t)}},[step,previewMode,initCanvas]);let pointerPos=e=>{let rect=canvasRef.current.getBoundingClientRect();return{x:e.clientX-rect.left,y:e.clientY-rect.top}},onPointerDown=e=>{e.preventDefault(),drawingRef.current=!0,lastPointRef.current=pointerPos(e.nativeEvent),canvasRef.current?.setPointerCapture(e.pointerId)},onPointerMove=e=>{if(!drawingRef.current)return;let canvas=canvasRef.current;if(!canvas)return;let ctx=canvas.getContext("2d");if(!ctx)return;let p=pointerPos(e.nativeEvent),last=lastPointRef.current||p;ctx.beginPath(),ctx.moveTo(last.x,last.y),ctx.lineTo(p.x,p.y),ctx.stroke(),lastPointRef.current=p,hasSignatureRef.current||(hasSignatureRef.current=!0,setHasSignature(!0),setError(null))},onPointerUp=e=>{drawingRef.current=!1,lastPointRef.current=null,canvasRef.current?.releasePointerCapture(e.pointerId)},clearSignature=()=>{initCanvas()},sinCredencialDeEnlace=!token&&!codigoCorto,verifyDni=async e=>{if(e?.preventDefault(),!dni.trim()){setError("Introduce tu DNI/NIF");return}setLoadingVerify(!0),setError(null);try{let result=await callPublicAutomation("sign_verify_dni",{contract_code:code,dni:dni.trim(),role,token,k:codigoCorto});if(!result||!result.ok){setError(mensajeAlAbrir(result?.reason,result,"No hemos podido validar este enlace con ese DNI/NIF. Comprueba que es el del firmante al que va dirigido (sin puntos ni guiones) y, si sigue sin abrir, pide a quien te lo envi\xF3 el \xFAltimo correo de firma."));return}if(setData(result),result.firmado){setStep("success");return}setStep("sign")}catch(err){let status=err&&err.status;setError(status===429?mensajeBloqueado(null,"vuelve a intentarlo"):"Verificaci\xF3n fallida. Revisa tu DNI/NIF e int\xE9ntalo de nuevo.")}finally{setLoadingVerify(!1)}},abreSolo=!previewMode&&!sinCredencialDeEnlace;(0,import_react.useEffect)(()=>{if(!abreSolo)return;let cancelado=!1;return(async()=>{setLoadingVerify(!0),setError(null);try{let result=await callPublicAutomation("sign_verify_dni",{contract_code:code,role,token,k:codigoCorto});if(cancelado)return;if(!result||!result.ok){setError(mensajeAlAbrir(result?.reason,result,codigoCorto&&!token?`Ese c\xF3digo no nos vale. Compru\xE9balo car\xE1cter a car\xE1cter con quien te lo dio: son 8 y no llevan nunca ceros ni unos, ni las letras I, L u O. Da igual que lo escribas con el guion o sin \xE9l, en may\xFAsculas o en min\xFAsculas. Si lo has copiado bien y sigue sin abrir, p\xEDdele el enlace completo o escribe a ${CONTACTO}.`:"No hemos podido validar este enlace. Lo que suele pasar es que llegue cortado: algunos correos lo parten en dos l\xEDneas y entonces le falta el final. \xC1brelo pulsando sobre el enlace del correo, no copi\xE1ndolo a mano, y si sigue sin abrir pide a quien te lo envi\xF3 el \xFAltimo correo de firma."));return}setData(result),setStep(result.firmado?"success":"sign")}catch(err){if(cancelado)return;setError((err&&err.status)===429?mensajeBloqueado():"No hemos podido abrir el contrato. Vuelve a intentarlo en un momento.")}finally{cancelado||setLoadingVerify(!1)}})(),()=>{cancelado=!0}},[abreSolo]),(0,import_react.useEffect)(()=>{if(!previewMode||!code)return;let cancelled=!1;return(async()=>{setLoadingVerify(!0),setError(null);try{let result=await callPublicAutomation("sign_verify_dni",{contract_code:code,preview_token:previewToken,role,token});if(cancelled)return;if(!result||!result.ok){setError("No se pudo cargar la previsualizaci\xF3n. El enlace puede no ser v\xE1lido.");return}setData(result),setStep("sign")}catch{cancelled||setError("No se pudo cargar la previsualizaci\xF3n.")}finally{cancelled||setLoadingVerify(!1)}})(),()=>{cancelled=!0}},[previewMode,code,previewToken]);let submitSignature=async()=>{if(!canvasRef.current||!hasSignatureRef.current){setError("Dibuja tu firma antes de continuar.");return}if(!accepted){setError("Acepta las condiciones del contrato para continuar.");return}let declaracion=textoDeclaracion(data?.firmante,esArrendadorReal);if(abreSolo&&!declarado){setError("Marca la casilla en la que declaras ser quien firma.");return}setLoadingSign(!0),setError(null);try{let signatureBase64=canvasRef.current.toDataURL("image/png"),result=await callPublicAutomation("sign_submit",{contract_code:code,dni:dni.trim(),declaracion:abreSolo?declaracion:"",signature_base64:signatureBase64,user_agent:navigator.userAgent,role,token,k:codigoCorto});if(!result||!result.ok){setError(mensajeAlFirmar(result?.reason,result));return}if(setPdfBase64(result.pdf_base64||null),setPdfFilename(result.pdf_filename||null),setEmailSent(!!result.hasEmail),setCompleto(typeof result.completo=="boolean"?result.completo:null),Array.isArray(result.firmantes)&&result.firmantes.length)setFirmantesTrasFirmar(result.firmantes.map(f=>({nombre:f.nombre||"",rol:f.rol||"",firmado:!!f.firmado,orden:null})));else if(Array.isArray(data?.firmantes)&&data.firmantes.length){let yo=String(data?.firmante||"").trim().toLowerCase(),miRol=String(rolServidor||role||"").trim().toLowerCase();setFirmantesTrasFirmar(data.firmantes.map(f=>({...f,firmado:f.firmado||!!yo&&String(f.nombre||"").trim().toLowerCase()===yo||!yo&&!!miRol&&String(f.rol||"").trim().toLowerCase()===miRol})))}setClientEmail(result.client_email||(data?.inquilino?.email??null)),setStep("success")}catch(err){let status=err&&err.status;status!==429&&console.error("[firma] error registrando la firma",err),setError(status===429?"Tu firma NO se ha registrado. "+mensajeBloqueado(null,"vuelve a pulsar \xABFirmar contrato\xBB"):mensajeAlFirmar(void 0,null))}finally{setLoadingSign(!1)}};return enlaceVacio?__gh(ErrorScreen,{title:"Enlace inv\xE1lido",message:"Este enlace no trae ni el contrato ni tu credencial de firma. Vuelve a abrirlo desde el mensaje en que lo recibiste, pulsando sobre el enlace entero."}):__gh(Layout,null,__gh(import_framer_motion.AnimatePresence,{mode:"wait",initial:!1},step==="verify"&&!previewMode&&__gh(import_framer_motion.motion.div,{key:"verify",initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.35,ease:EASE},className:"w-full"},abreSolo?error?__gh(AvisoTarjeta,{title:"No hemos podido abrir el contrato",message:error}):__gh(AbriendoScreen,null):__gh(VerifyScreen,{dni,setDni,error,setError,loading:loadingVerify,onSubmit:verifyDni,esArrendador})),step==="verify"&&previewMode&&__gh(import_framer_motion.motion.div,{key:"preview-loading",initial:{opacity:0},animate:{opacity:1},className:"w-full"},error?__gh(ErrorScreen,{title:"No se pudo previsualizar",message:error}):__gh("div",{className:"max-w-md mx-auto text-center py-24 text-zinc-500","data-gufi-src":"page.tsx:887"},__gh(import_lucide_react.Loader2,{className:"w-7 h-7 animate-spin mx-auto mb-4",style:{color:ACCENT}}),"Cargando previsualizaci\xF3n del contrato\u2026")),step==="sign"&&data&&__gh(import_framer_motion.motion.div,{key:"sign",initial:{opacity:0,y:16},animate:{opacity:1,y:0},exit:{opacity:0,y:-12},transition:{duration:.4,ease:EASE},className:"w-full"},__gh(SignScreen,{data,previewMode,esArrendador:esArrendadorReal,rol:rolServidor,esOtraParte,canvasRef,onPointerDown,onPointerMove,onPointerUp,onClearSignature:clearSignature,hasSignature,accepted,setAccepted,pideDeclaracion:abreSolo,declarado,setDeclarado,error,loading:loadingSign,onSubmit:submitSignature})),step==="success"&&__gh(import_framer_motion.motion.div,{key:"success",initial:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.96},transition:{duration:.45,ease:EASE},className:"w-full"},__gh(SuccessScreen,{data,emailSent,clientEmail,pdfBase64,pdfFilename,completo,esArrendador:esArrendadorReal,firmantes:firmantesTrasFirmar}))))}function VerifyScreen({dni,setDni,error,setError,loading,onSubmit,esArrendador}){return __gh("div",{className:"bg-white rounded-3xl shadow-xl border border-zinc-100 p-8 max-w-md w-full mx-auto","data-gufi-src":"page.tsx:944"},__gh(BrandMark,null),__gh("div",{className:"text-center mb-8","data-gufi-src":"page.tsx:946"},__gh("h1",{className:"text-2xl font-bold text-zinc-900 mb-2","data-gufi-src":"page.tsx:947"},"Verificaci\xF3n de identidad"),__gh("p",{className:"text-zinc-500","data-gufi-src":"page.tsx:948"},esArrendador?"Firmas como parte arrendadora. Introduce el DNI del firmante autorizado para acceder al contrato.":"Introduce tu DNI/NIF para acceder a tu contrato y firmarlo.")),__gh("form",{onSubmit,className:"space-y-4","data-gufi-src":"page.tsx:955"},__gh("div",{"data-gufi-src":"page.tsx:956"},__gh("label",{className:"block text-sm font-medium text-zinc-700 mb-2","data-gufi-src":"page.tsx:957"},"DNI / NIF"),__gh("div",{className:"relative","data-gufi-src":"page.tsx:958"},__gh(import_lucide_react.IdCard,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-zinc-400"}),__gh("input",{type:"text",value:dni,onChange:e=>{setDni(e.target.value.toUpperCase()),setError(null)},placeholder:"12345678X",className:"rm-input w-full pl-12 pr-4 py-4 rounded-xl border border-zinc-200 text-lg font-medium tracking-wide uppercase outline-none transition-all duration-200",autoFocus:!0,autoComplete:"off","data-gufi-src":"page.tsx:960"})),error&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:-5},animate:{opacity:1,y:0},transition:{duration:.2,ease:EASE},className:"text-sm text-rose-600 mt-2 flex items-center gap-1"},__gh(import_lucide_react.AlertCircle,{className:"w-4 h-4"})," ",error)),__gh(import_framer_motion.motion.button,{type:"submit",disabled:loading||!dni.trim(),whileHover:{scale:dni.trim()&&!loading?1.01:1},whileTap:{scale:dni.trim()&&!loading?.99:1},transition:{duration:.15,ease:EASE},className:"rm-grad w-full py-4 rounded-xl text-white font-semibold shadow-lg hover:shadow-xl disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 transition-shadow"},loading?__gh(__gf,null,__gh(import_lucide_react.Loader2,{className:"w-5 h-5 animate-spin"})," Verificando\u2026"):__gh(__gf,null,__gh(import_lucide_react.ShieldCheck,{className:"w-5 h-5"})," Verificar y continuar"))),__gh("p",{className:"text-center text-[11px] text-zinc-400 mt-6 leading-relaxed","data-gufi-src":"page.tsx:994"},"Tratamos tu DNI/NIF \xFAnicamente para verificar tu identidad como ",esArrendador?"firmante autorizado por la propiedad":"titular del contrato","(RGPD Art. 6.1.b \u2014 ejecuci\xF3n de contrato). No se almacena ni se comparte con terceros."))}function SignScreen({data,previewMode,esArrendador,rol,esOtraParte,canvasRef,onPointerDown,onPointerMove,onPointerUp,onClearSignature,hasSignature,accepted,setAccepted,pideDeclaracion,declarado,setDeclarado,error,loading,onSubmit}){let faltaDeclarar=pideDeclaracion&&!declarado,canSubmit=accepted&&hasSignature&&!faltaDeclarar,rotuloRol=rol?`como ${String(rol).toLowerCase()}`:esArrendador?"por el arrendador":"por el arrendatario",blocker=faltaDeclarar?"Marca la casilla en la que declaras ser quien firma":accepted?hasSignature?"":"Firma en el recuadro para continuar":"Acepta las condiciones para continuar";return __gh("div",{className:"max-w-3xl mx-auto","data-gufi-src":"page.tsx:1048"},__gh(BrandMark,{heading:data.documento_titulo||`Contrato ${data.contrato.codigo}`}),__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:18},animate:{opacity:1,y:0},transition:{duration:.45,ease:EASE,delay:.05},className:"bg-white rounded-3xl shadow-2xl border border-zinc-100 overflow-hidden"},previewMode&&__gh("div",{className:"text-center text-[13px] font-semibold px-4 py-2.5",style:{background:"#fff8e1",borderBottom:"1px solid #f3d98a",color:"#8a6d0f"},"data-gufi-src":"page.tsx:1057"},"Previsualizaci\xF3n \xB7 este contrato todav\xEDa no est\xE1 firmado"),__gh("div",{className:"rm-doc-scroll bg-zinc-50/60 px-4 sm:px-8 py-6","data-gufi-src":"page.tsx:1064"},__gh("div",{className:"contract-html bg-white rounded-2xl shadow-sm border border-zinc-100 p-6 sm:p-9 mx-auto",style:{maxWidth:720},dangerouslySetInnerHTML:{__html:data.contrato.contrato_html},"data-gufi-src":"page.tsx:1065"}),__gh("div",{className:"mx-auto mt-4",style:{maxWidth:720},"data-gufi-src":"page.tsx:1072"},previewMode?__gh("div",{style:{border:"1.5px dashed #cfc9ff",borderRadius:12,padding:22,textAlign:"center",color:"#6d63d6",fontSize:11,fontWeight:800,letterSpacing:1.5,textTransform:"uppercase",background:"#faf9ff"},"data-gufi-src":"page.tsx:1074"},"Pendiente de firma"):__gh("div",{className:"bg-white rounded-2xl border border-zinc-100 shadow-sm p-5","data-gufi-src":"page.tsx:1082"},__gh("div",{className:"text-[11px] font-extrabold tracking-[0.12em] uppercase mb-3",style:{color:ACCENT},"data-gufi-src":"page.tsx:1083"},"Firma aqu\xED \xB7 ",rotuloRol),__gh(SignatureCanvas,{canvasRef,hasSignature,onPointerDown,onPointerMove,onPointerUp,onClear:onClearSignature})))),!previewMode&&__gh(__gf,null,esOtraParte&&Array.isArray(data.firmantes)&&data.firmantes.length>0&&(()=>{let faltan=data.firmantes.filter(f=>!f.firmado&&String(f.rol||"").toLowerCase()!==String(rol||"").toLowerCase()),todas=data.firmantes.filter(f=>!f.firmado).length===0;return __gh("div",{className:"px-6 sm:px-8 pt-5","data-gufi-src":"page.tsx:1108"},__gh("div",{className:"rounded-xl px-4 py-3 text-[12.5px] leading-snug flex items-start gap-2",style:todas?{background:"#ecfdf5",color:"#065f46",border:"1px solid #a7f3d0"}:{background:"#fff8e1",color:"#8a6d0f",border:"1px solid #f3d98a"},"data-gufi-src":"page.tsx:1109"},todas?__gh(import_lucide_react.CheckCircle2,{className:"w-4 h-4 mt-[1px] shrink-0"}):__gh(import_lucide_react.AlertCircle,{className:"w-4 h-4 mt-[1px] shrink-0"}),__gh("span",{"data-gufi-src":"page.tsx:1116"},faltan.length===0?"Las dem\xE1s partes ya han firmado. Con tu firma el documento queda completo.":`Todav\xEDa ${faltan.length===1?"falta la firma de":"faltan las firmas de"} ${faltan.map(f=>f.nombre||f.rol).join(", ")}. Tu firma queda registrada y el contrato se completar\xE1 cuando firmen.`)))})(),!esOtraParte&&(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)!==void 0&&__gh("div",{className:"px-6 sm:px-8 pt-5","data-gufi-src":"page.tsx:1128"},__gh("div",{className:"rounded-xl px-4 py-3 text-[12.5px] leading-snug flex items-start gap-2",style:(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)?{background:"#ecfdf5",color:"#065f46",border:"1px solid #a7f3d0"}:{background:"#fff8e1",color:"#8a6d0f",border:"1px solid #f3d98a"},"data-gufi-src":"page.tsx:1129"},(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)?__gh(import_lucide_react.CheckCircle2,{className:"w-4 h-4 mt-[1px] shrink-0"}):__gh(import_lucide_react.AlertCircle,{className:"w-4 h-4 mt-[1px] shrink-0"}),__gh("span",{"data-gufi-src":"page.tsx:1136"},(esArrendador?data.firmado_arrendatario:data.firmado_arrendador)?esArrendador?"El arrendatario ya ha firmado. Con tu firma el contrato queda completo.":"El arrendador ya ha firmado. Con tu firma el contrato queda completo.":esArrendador?"El arrendatario todav\xEDa no ha firmado. Tu firma queda registrada y el contrato se completar\xE1 cuando firme la otra parte.":"La parte arrendadora todav\xEDa no ha firmado. Tu firma queda registrada y el contrato se completar\xE1 cuando firme."))),pideDeclaracion&&__gh("div",{className:"px-6 sm:px-8 py-5 border-t border-zinc-100","data-gufi-src":"page.tsx:1153"},__gh(AppleCheckbox,{checked:declarado,onChange:v=>setDeclarado(v),label:textoDeclaracion(data.firmante,esArrendador)})),__gh("div",{className:"px-6 sm:px-8 py-5 border-t border-zinc-100","data-gufi-src":"page.tsx:1161"},__gh(AppleCheckbox,{checked:accepted,onChange:v=>setAccepted(v),label:esArrendador?"He le\xEDdo y acepto las condiciones del contrato, y firmo en representaci\xF3n de la parte arrendadora.":esOtraParte?`He le\xEDdo y acepto las condiciones del contrato de arrendamiento, y firmo como ${String(rol).toLowerCase()}.`:"He le\xEDdo y acepto las condiciones del contrato de arrendamiento."})),__gh("div",{className:"px-6 sm:px-8 py-5 border-t border-zinc-100 bg-gradient-to-b from-white to-zinc-50/60 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3","data-gufi-src":"page.tsx:1179"},__gh("div",{className:"text-xs text-zinc-500 sm:max-w-sm leading-relaxed","data-gufi-src":"page.tsx:1180"},"Tu firma digital tiene la misma validez legal que una manuscrita (Reglamento eIDAS UE 910/2014, Ley 6/2020)."),__gh("div",{className:"flex flex-col items-stretch sm:items-end gap-1.5","data-gufi-src":"page.tsx:1184"},__gh(SignButton,{onClick:onSubmit,disabled:!canSubmit,loading}),error&&__gh("p",{className:"text-xs text-rose-600 flex items-center gap-1 sm:justify-end","data-gufi-src":"page.tsx:1187"},__gh(import_lucide_react.AlertCircle,{className:"w-3.5 h-3.5"})," ",error),!canSubmit&&!loading&&!error&&__gh("p",{className:"text-[11px] text-zinc-500 sm:text-right","data-gufi-src":"page.tsx:1192"},blocker)))),previewMode&&__gh("div",{className:"px-6 sm:px-8 py-4 border-t border-zinc-100 text-center text-xs text-zinc-500","data-gufi-src":"page.tsx:1199"},"Esto es una previsualizaci\xF3n. La firma se realiza desde el enlace que recibe el inquilino.")),__gh("p",{className:"text-center text-[11px] text-zinc-400 mt-5","data-gufi-src":"page.tsx:1205"},"Powered by Gufi"))}function SignatureCanvas({canvasRef,hasSignature,onPointerDown,onPointerMove,onPointerUp,onClear}){return __gh("div",{className:`relative w-full rounded-xl overflow-hidden border ${hasSignature?"border-zinc-200":"rm-sig-pulse border-zinc-200"}`,"data-gufi-src":"page.tsx:1221"},__gh("canvas",{ref:canvasRef,className:"w-full h-[130px] bg-white touch-none cursor-crosshair block",onPointerDown,onPointerMove,onPointerUp,onPointerCancel:onPointerUp,"data-gufi-src":"page.tsx:1222"}),__gh(import_framer_motion.AnimatePresence,null,!hasSignature&&__gh(import_framer_motion.motion.div,{key:"hint",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.25,ease:EASE},className:"absolute inset-0 flex items-center justify-center pointer-events-none"},__gh("span",{className:"text-[11px] uppercase tracking-[0.18em] font-semibold select-none text-zinc-400","data-gufi-src":"page.tsx:1238"},"Dibuja tu firma con el dedo o el rat\xF3n"))),__gh(import_framer_motion.AnimatePresence,null,hasSignature&&__gh(import_framer_motion.motion.button,{type:"button",onClick:onClear,initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:EASE},className:"absolute top-2 right-2 p-1.5 rounded-lg bg-white/95 border border-zinc-200 hover:bg-zinc-50 transition-colors flex items-center gap-1 text-[11px] font-medium text-zinc-600","aria-label":"Limpiar firma"},__gh(import_lucide_react.RefreshCw,{className:"w-3.5 h-3.5"})," Repetir")))}function AppleCheckbox({checked,onChange,label}){return __gh("div",{role:"checkbox","aria-checked":checked,tabIndex:0,onClick:()=>onChange(!checked),onKeyDown:e=>{(e.key===" "||e.key==="Enter")&&(e.preventDefault(),onChange(!checked))},className:"flex items-center gap-3 cursor-pointer select-none group focus:outline-none rounded-md py-1","data-gufi-src":"page.tsx:1265"},__gh("div",{className:"relative flex-none w-6 h-6 rounded-md border-2 flex items-center justify-center transition-all duration-200",style:checked?{background:ACCENT,borderColor:ACCENT}:{background:"#fff",borderColor:"#d4d4d8"},"data-gufi-src":"page.tsx:1271"},__gh(import_framer_motion.AnimatePresence,null,checked&&__gh(import_framer_motion.motion.span,{key:"check",initial:{scale:0,opacity:0},animate:{scale:1,opacity:1},exit:{scale:0,opacity:0},transition:{duration:.18,ease:EASE},className:"flex items-center justify-center"},__gh(import_lucide_react.Check,{className:"w-4 h-4 text-white",strokeWidth:3.5})))),__gh("span",{className:`text-sm leading-relaxed transition-colors duration-200 ${checked?"text-zinc-900":"text-zinc-700"}`,"data-gufi-src":"page.tsx:1288"},label))}function SignButton({onClick,disabled,loading}){let isActive=!disabled&&!loading;return __gh(import_framer_motion.motion.button,{onClick,disabled:disabled||loading,whileHover:isActive?{y:-1}:void 0,whileTap:isActive?{scale:.98}:void 0,transition:{duration:.15,ease:EASE},className:`relative px-7 py-3.5 rounded-xl font-semibold inline-flex items-center justify-center gap-2 overflow-hidden transition-all duration-300 ${isActive?"text-white shadow-lg hover:shadow-xl":"text-zinc-400 bg-zinc-200 cursor-not-allowed"}`},__gh("span",{"aria-hidden":!0,className:`absolute inset-0 transition-opacity duration-300 ${isActive?"opacity-100":"opacity-0"}`,style:{background:ACCENT},"data-gufi-src":"page.tsx:1309"}),__gh("span",{className:"relative z-10 inline-flex items-center gap-2","data-gufi-src":"page.tsx:1314"},loading?__gh(__gf,null,__gh(import_lucide_react.Loader2,{className:"w-5 h-5 animate-spin"})," Firmando\u2026"):__gh(__gf,null,__gh(import_lucide_react.CheckCircle2,{className:"w-5 h-5"})," Firmar contrato")))}function SuccessScreen({data,emailSent,clientEmail,pdfBase64,pdfFilename,completo,esArrendador,firmantes:firmantesAlDia}){let wasAlreadySigned=data?.firmado&&!pdfBase64,emailToShow=clientEmail||(data?.inquilino?.email??null),rotulo=data?.documento_tipo==="adenda"?"Anexo":"Contrato",firmantes=Array.isArray(firmantesAlDia)&&firmantesAlDia.length?firmantesAlDia:Array.isArray(data?.firmantes)?data.firmantes:[],pendiente=completo===!1;return __gh("div",{className:"bg-white rounded-2xl p-7 sm:p-8 max-w-md w-full mx-auto text-center border border-zinc-200/80",style:{boxShadow:"0 1px 2px rgba(10,37,64,.04), 0 12px 32px -12px rgba(10,37,64,.18)"},"data-gufi-src":"page.tsx:1361"},__gh("img",{src:LOGO_HOSTWORKERS,alt:"HostWorkers",width:123,height:40,className:"mx-auto mb-6",style:{height:40,width:"auto",maxWidth:"58%",display:"block"},"data-gufi-src":"page.tsx:1365"}),__gh(import_framer_motion.motion.div,{initial:{scale:.86,opacity:0},animate:{scale:1,opacity:1},transition:{duration:.3,ease:EASE},className:"w-11 h-11 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"#E3F5EC"}},__gh(import_lucide_react.Check,{className:"w-[22px] h-[22px]",style:{color:"#0E7A54"},strokeWidth:2.6})),__gh(import_framer_motion.motion.h1,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3,ease:EASE,delay:.08},className:"text-[21px] font-bold tracking-[-0.02em] text-zinc-900"},wasAlreadySigned?`${rotulo} ya firmado`:pendiente?"Firma registrada":"Firma completada"),data?.contrato&&__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3,ease:EASE,delay:.13},className:"mt-1.5"},__gh("div",{className:"font-mono text-[15px] font-semibold text-zinc-800 tracking-tight","data-gufi-src":"page.tsx:1397"},data.contrato.codigo),data.contrato.firma_fecha&&__gh("div",{className:"text-[12.5px] text-zinc-400 mt-0.5","data-gufi-src":"page.tsx:1399"},"Firmado el ",formatLongDate(data.contrato.firma_fecha))),!wasAlreadySigned&&pendiente&&__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3,ease:EASE,delay:.18},className:"mt-5 rounded-xl border border-zinc-200/80 text-left overflow-hidden"},__gh("div",{className:"px-4 pt-3 pb-2 text-[10px] font-semibold uppercase tracking-[0.14em] text-zinc-400","data-gufi-src":"page.tsx:1412"},"Estado de las firmas"),firmantes.length>0?__gh("ul",{className:"px-4 pb-3 space-y-2","data-gufi-src":"page.tsx:1416"},firmantes.map((f,i)=>__gh("li",{key:`${f.nombre}-${i}`,className:"flex items-center gap-2.5","data-gufi-src":"page.tsx:1418"},f.firmado?__gh("span",{className:"w-[18px] h-[18px] rounded-full flex items-center justify-center shrink-0",style:{background:"#E3F5EC"},"data-gufi-src":"page.tsx:1420"},__gh(import_lucide_react.Check,{className:"w-[11px] h-[11px]",style:{color:"#0E7A54"},strokeWidth:3})):__gh("span",{className:"w-[18px] h-[18px] rounded-full shrink-0",style:{border:"1.5px solid #D4D4D8",background:"#fff"},"data-gufi-src":"page.tsx:1424"}),__gh("span",{className:"min-w-0 flex-1 text-[13px] text-zinc-700 truncate","data-gufi-src":"page.tsx:1426"},f.nombre||f.rol),__gh("span",{className:"text-[11.5px] text-zinc-400 shrink-0","data-gufi-src":"page.tsx:1427"},f.firmado?"Firmado":"Pendiente")))):__gh("div",{className:"px-4 pb-3 text-[13px] text-zinc-600 leading-snug","data-gufi-src":"page.tsx:1432"},"Falta la firma de ",esArrendador?"el arrendatario":"la parte arrendadora","."),__gh("div",{className:"px-4 py-2.5 border-t border-zinc-100 text-[12px] text-zinc-500 leading-snug",style:{background:"#FAFAFA"},"data-gufi-src":"page.tsx:1436"},"Recibir\xE1s el PDF definitivo cuando est\xE9n todas.")),!wasAlreadySigned&&emailSent&&emailToShow&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3,ease:EASE,delay:.24},className:"text-[13px] text-zinc-500 leading-relaxed mt-5"},"Te hemos mandado el ",rotulo.toLowerCase()," firmado a ",__gh("span",{className:"text-zinc-700 font-medium","data-gufi-src":"page.tsx:1448"},emailToShow),", con el PDF adjunto."),!wasAlreadySigned&&!emailSent&&__gh(import_framer_motion.motion.p,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3,ease:EASE,delay:.24},className:"text-[13px] text-zinc-500 mt-5"},"Descarga aqu\xED tu copia firmada."),pdfBase64?__gh(import_framer_motion.motion.button,{type:"button",onClick:()=>downloadPdfFromBase64(pdfBase64,pdfFilename||"contrato.pdf"),initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.3,ease:EASE,delay:.3},whileTap:{scale:.985},className:"mt-6 inline-flex items-center justify-center gap-2 h-11 px-5 rounded-xl text-white text-[14px] font-semibold transition-colors",style:{background:ACCENT,boxShadow:"0 1px 2px rgba(234,104,45,.3)"}},__gh(import_lucide_react.Download,{className:"w-[17px] h-[17px]"})," Descargar PDF"):wasAlreadySigned?__gh("p",{className:"text-[12px] text-zinc-400 mt-5","data-gufi-src":"page.tsx:1474"},"Pide a HostWorkers el PDF firmado si lo necesitas."):null,__gh("div",{className:"mt-7 pt-4 border-t border-zinc-100 text-[11px] text-zinc-300","data-gufi-src":"page.tsx:1477"},"Powered by ",__gh("a",{href:"https://gufi.dev",className:"font-semibold text-zinc-400 no-underline","data-gufi-src":"page.tsx:1478"},"Gufi")))}function BrandMark({heading}){return __gh(import_framer_motion.motion.div,{initial:{opacity:0,y:-12},animate:{opacity:1,y:0},transition:{duration:.4,ease:EASE},className:"text-center mb-6"},__gh("img",{src:LOGO_HOSTWORKERS,alt:"HostWorkers",width:154,height:50,className:"mx-auto mb-3",style:{height:50,width:"auto",maxWidth:"72%",display:"block"},"data-gufi-src":"page.tsx:1500"}),__gh("p",{className:"text-zinc-500 mt-1 text-sm","data-gufi-src":"page.tsx:1508"},heading||"Firma de contrato de arrendamiento"))}function AbriendoScreen(){return __gh("div",{className:"bg-white rounded-3xl shadow-xl border border-zinc-100 p-8 max-w-md w-full mx-auto text-center","data-gufi-src":"page.tsx:1519"},__gh(BrandMark,null),__gh("div",{className:"w-12 h-12 rounded-2xl bg-zinc-100 flex items-center justify-center mx-auto mb-4","data-gufi-src":"page.tsx:1521"},__gh(import_lucide_react.Loader2,{className:"w-6 h-6 animate-spin text-zinc-500"})),__gh("h1",{className:"text-xl font-bold text-zinc-900 mb-1.5","data-gufi-src":"page.tsx:1524"},"Abriendo tu contrato"),__gh("p",{className:"text-zinc-500 text-[14px]","data-gufi-src":"page.tsx:1525"},"Un segundo, estamos cargando el documento."))}function SalidaSiempre(){return __gh("p",{className:"text-[12.5px] text-zinc-400 mt-5 leading-relaxed","data-gufi-src":"page.tsx:1543"},"\xBFSigue sin abrir? Escribe a"," ",__gh("a",{href:`mailto:${CONTACTO}?subject=${encodeURIComponent("No puedo firmar mi contrato")}`,className:"font-medium underline",style:{color:ACCENT},"data-gufi-src":"page.tsx:1545"},CONTACTO)," ","y te mandan el enlace otra vez.")}function AvisoTarjeta({title,message}){return __gh("div",{className:"bg-white rounded-3xl shadow-xl border border-rose-100 p-8 max-w-md w-full mx-auto text-center","data-gufi-src":"page.tsx:1559"},__gh(BrandMark,null),__gh("div",{className:"w-12 h-12 rounded-2xl bg-rose-100 flex items-center justify-center mx-auto mb-4","data-gufi-src":"page.tsx:1561"},__gh(import_lucide_react.AlertCircle,{className:"w-6 h-6 text-rose-600"})),__gh("h1",{className:"text-xl font-bold text-zinc-900 mb-1.5","data-gufi-src":"page.tsx:1564"},title),__gh("p",{className:"text-zinc-500 text-[14px] leading-relaxed","data-gufi-src":"page.tsx:1565"},message),__gh(SalidaSiempre,null))}function ErrorScreen({title,message}){return __gh("div",{className:"min-h-[100dvh] bg-gradient-to-br from-rose-50 via-white to-orange-50 flex items-center justify-center p-4","data-gufi-src":"page.tsx:1573"},__gh(import_framer_motion.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.4,ease:EASE},className:"bg-white rounded-3xl shadow-xl border border-rose-100 p-8 max-w-md w-full text-center"},__gh("div",{className:"w-16 h-16 rounded-2xl bg-rose-100 flex items-center justify-center mx-auto mb-4","data-gufi-src":"page.tsx:1579"},__gh(import_lucide_react.AlertCircle,{className:"w-8 h-8 text-rose-600"})),__gh("h1",{className:"text-xl font-bold text-zinc-900 mb-2","data-gufi-src":"page.tsx:1582"},title),__gh("p",{className:"text-zinc-500","data-gufi-src":"page.tsx:1583"},message),__gh(SalidaSiempre,null)))}function Layout({children}){return __gh(__gf,null,__gh("style",{"data-gufi-src":"page.tsx:1593"},` @keyframes rm-sig-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(234, 104, 45, 0.0); } 50% { box-shadow: 0 0 0 4px rgba(234, 104, 45, 0.14); } } .rm-sig-pulse { animation: rm-sig-pulse 2.2s ease-in-out infinite; } .rm-grad { background: #EA682D; } .rm-input:focus { border-color: #EA682D; box-shadow: 0 0 0 3px rgba(234, 104, 45, 0.18); } .rm-page-bg { background: linear-gradient(135deg, #f6f5ff 0%, #ffffff 45%, #f3f1ff 100%); } .rm-doc-scroll { max-height: 66vh; overflow-y: auto; scroll-behavior: smooth; } /* Estilos del contrato_html renderizado (clases que emite el ERP) */ .contract-html { color: #1a1a2e; font-size: 14px; line-height: 1.6; } .contract-html .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 18px; border-bottom: 2px solid #ece9ff; margin-bottom: 8px; } .contract-html .brand { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; color: #1a1a2e; } .contract-html .brand span { color: #EA682D; } .contract-html .muted { color: #6b7280; font-size: 12.5px; line-height: 1.5; } .contract-html h1 { font-size: 18px; font-weight: 700; color: #1a1a2e; margin: 0; } .contract-html h3 { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #EA682D; margin: 22px 0 8px; } .contract-html p { margin: 10px 0; } /* EL BLOQUE DE FIRMAS NO CABIA EN NINGUN MOVIL (medido 23-oct-2026). El pie del contrato es una tabla de dos celdas al 50 % y dentro de cada una hay una linea de 44 PUNTOS seguidos para firmar encima. Un punto no es sitio por donde partir, asi que esa linea es indivisible: la tabla pedia 400 px y el hueco del documento son 366 px a 390 de pantalla, 351 a 375 y 336 a 360. Desbordaba a los TRES anchos, no solo en el mas estrecho. No se ve como un desastre porque rm-doc-scroll tiene overflow-y y eso convierte overflow-x en auto: la pagina no se mueve, pero el documento si, y lo ULTIMO que se lee antes de firmar (quien firma cada lado) habia que arrastrarlo de lado a lado. table-layout fixed obliga a respetar el 50/50 en vez de dejar que el contenido estire la columna, y overflow-wrap anywhere permite partir la fila de puntos (y de paso un IBAN o una referencia catastral, que son igual de indivisibles). Comprobado con el pie REAL de CTR-2026-009 a 390, 375 y 360: sin desbordamiento en ninguno de los tres. */ .contract-html table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px; table-layout: fixed; } .contract-html td, .contract-html th { overflow-wrap: anywhere; } .contract-html th { text-align: left; background: #f5f3ff; color: #4c3fd8; font-weight: 700; padding: 9px 12px; border: 1px solid #ece9ff; } .contract-html td { padding: 9px 12px; border: 1px solid #eef0f4; vertical-align: top; } .contract-html .tot { font-weight: 800; color: #1a1a2e; } .contract-html strong { color: #1a1a2e; } `),__gh("div",{className:"min-h-[100dvh] rm-page-bg py-6 sm:py-10 px-3 sm:px-4 flex items-start justify-center","data-gufi-src":"page.tsx:1637"},__gh("div",{className:"w-full","data-gufi-src":"page.tsx:1638"},children)))}var stdin_default=FirmaContratoRumar;