1import{r as d,j as e,bH as sa,D as De,am as Se,bN as Ss,G as Ve,bO as Ue,n as ue,ap as aa,L as Ie,bJ as ps,M as oe,cH as Oe,bQ as Re,ah as ta,bj as ra,bV as be,cj as Es,_ as ks,o as hs,aX as la,S as na,aY as ia,d as oa,a$ as ca,U as da,cB as ma,X as Ee,c9 as Ts,I as xa,q as ua,ck as pa,c7 as ha,i as $e,eG as ke,a as Ps,cU as Ms,b1 as ga,ej as As,ao as ba,e3 as ja,d3 as fa,E as va,a5 as Na,a7 as ya,d2 as wa,e4 as Ca,e5 as _a,dk as Sa,df as Ea,az as ka,c_ as Ta,Z as Pa,h as Ma,ar as Aa,ai as za,dV as La,dS as Da,ci as Ia,dK as Be,bg as Ra,as as Fa,er as zs}from"./ui-vendor-Nh77zFHh.js";import{C as K,a as Q,b as te,c as ie,d as X}from"./card-IGpSy_k-.js";import{aX as qa,s as Va,d as Oa,a9 as Ua,aY as $a,aZ as gs,a_ as Ba,a$ as Ha,b0 as Ga,B as g,e as O,G as bs,H as js,J as fs,a2 as Ya,K as J,I as p,t as vs,L as o,b2 as Ka,b3 as Qa,b4 as Xa,b5 as Ja,h as P,S as je,i as fe,j as ve,k as Ne,l as L,v as j,T as Ns,a3 as Za,b1 as Wa,b6 as et,b7 as st,b9 as at,bb as tt,bc as rt,bd as lt,bH as nt}from"./index-BCakBLyb.js";import{T as ge}from"./textarea-D6pIDA_a.js";import{S as Z}from"./switch-C1AfXHyZ.js";import{T as it,a as ot,b as pe,c as he}from"./tabs-cH_BY3xJ.js";import{A as ct,a as F,b as q,c as V}from"./accordion-BiGI0_c8.js";import{C as dt,a as mt,b as xt,c as ut,d as pt,e as ht}from"./command-Dnx8Q6Bq.js";import{P as gt,a as bt,b as jt}from"./popover-DJHTinoQ.js";import{b as ft,e as vt,a as Fe,u as Nt,c as yt,t as wt}from"./surveyService-4UyFyr1V.js";import{c as Ct}from"./companyService-gQOppouN.js";import{u as _t}from"./userSmtpService-BceHmB6V.js";import{u as St}from"./userService-Dj3A-iRm.js";import{F as ce,j as ys,h as Et}from"./digitalFormService-D5IdDs0J.js";import{L as kt}from"./LoadingSpinner-CbDDqUpX.js";import{a as Tt,S as Pt}from"./useRealtimeQuery-C5TKHl3O.js";import{T as Mt}from"./TourButton-DHeq7_zB.js";import{a as At,d as zt}from"./react-vendor-B-TOzi2X.js";import"./radix-vendor-8V-X-v15.js";import"./chart-vendor-BHC9f-XT.js";import"./table-vendor-CmSNR_WU.js";import"./index-QOVd9sJl.js";import"./duplicateGuardService-BYo_d16M.js";const Lt=[{element:'[data-tour="create-survey-header"]',popover:{title:"ð§¾ Creador de Encuestas",description:"Define el objetivo y administra tu encuesta.",side:"bottom",align:"start"}},{element:'[data-tour="create-survey-actions"]',popover:{title:"â¡ Acciones",description:"Previsualiza o guarda cambios rápidamente.",side:"bottom",align:"end"}},{element:'[data-tour="create-survey-field-types"]',popover:{title:"ð§© Tipos de Campo",description:"Arrastra o selecciona el tipo de campo que necesitas.",side:"right",align:"start"}},{element:'[data-tour="create-survey-builder"]',popover:{title:"ð ï¸ Constructor",description:"Configura el titulo, tipo y los campos de la encuesta.",side:"left",align:"start"}}],Ls={Type:Be,Mail:oe,Lock:Ue,Hash:Ia,Phone:Es,Link:Da,AlignLeft:La,ChevronDown:za,Circle:Aa,CheckSquare:Ma,Calendar:Pa,Clock:Ss,CalendarClock:Ta,Upload:ka,Sliders:Ea,Palette:ks,ToggleLeft:Sa,Heading:_a,Text:Ca,Minus:wa,MapPin:ya,Navigation:Na,Camera:va,PenTool:fa,Images:ja,Video:ba,Award:As,Star:$e,ThumbsUp:ke,Tag:ga,Table:Ms},Ds=({type:m,className:y})=>{const f=ce.find(S=>S.value===m),n=f&&Ls[f.icon]||Be;return Ps.createElement(n,{className:y})},Dt=({iconKey:m,className:y})=>{const f=Ls[m]||Be;return Ps.createElement(f,{className:y})},qe={email_notifications_enabled:!1,email_notification_recipients:"",email_notification_subject:"Nueva respuesta de encuesta: {{surveyTitle}}",email_from_name:"",email_from_address:"",email_smtp_host:"",email_smtp_port:587,email_smtp_secure:!1,email_smtp_user:"",email_smtp_password:""},It=[{name:"Ãndigo Real",hex:"#4F46E5"},{name:"Azul Corporativo",hex:"#2563EB"},{name:"Esmeralda Pro",hex:"#059669"},{name:"Violeta Moderno",hex:"#7C3AED"},{name:"Ãmbar Cálido",hex:"#D97706"},{name:"Rubà Ejecutivo",hex:"#DC2626"},{name:"Cian Tecnológico",hex:"#0891B2"},{name:"Pizarra Grafito",hex:"#475569"}],Rt=m=>m.split(/[,;\n\r]+/).map(y=>y.trim()).filter(Boolean),ws=m=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m),Cs=[{id:"csat",title:"Satisfacción del Cliente (CSAT & NPS)",description:"Calificación general, recomendación y comentarios",fields:[{id:"f_heading",type:"heading",label:"Encuesta de Satisfacción",name:"heading_1",content:"Tu opinión es muy importante",level:"h2"},{id:"f_name",type:"text",label:"Nombre completo (opcional)",name:"nombre",placeholder:"Tu nombre",required:!1},{id:"f_rating",type:"range",label:"¿Cómo calificarÃas tu experiencia general? (1 a 5)",name:"calificacion_general",min:1,max:5,step:1,required:!0},{id:"f_nps",type:"range",label:"¿Qué tan probable es que nos recomiendes con un amigo o colega? (0 a 10)",name:"nps_score",min:0,max:10,step:1,required:!0},{id:"f_aspects",type:"checkbox",label:"¿Qué aspectos destacarÃas?",n
1ame:"aspectos_destacados",options:[{label:"Atención y amabilidad",value:"atencion"},{label:"Rapidez de respuesta",value:"rapidez"},{label:"Calidad del servicio",value:"calidad"},{label:"Facilidad de uso",value:"facilidad"}],required:!1},{id:"f_comments",type:"textarea",label:"¿Tienes alguna sugerencia o comentario adicional?",name:"comentarios",placeholder:"Escribe tu mensaje...",rows:4,required:!1}]},{id:"clima",title:"Clima Laboral y Compromiso",description:"Ambiente de trabajo, liderazgo y herramientas",fields:[{id:"f_heading_clima",type:"heading",label:"Clima Laboral",name:"heading_clima",content:"Evaluación de Clima Organizacional",level:"h2"},{id:"f_area",type:"select",label:"Ãrea / Departamento",name:"departamento",options:[{label:"Administración y Finanzas",value:"admin"},{label:"Recursos Humanos",value:"rrhh"},{label:"Operaciones",value:"operaciones"},{label:"Comercial / Ventas",value:"ventas"},{label:"TecnologÃa",value:"ti"}],required:!0},{id:"f_ambiente",type:"range",label:"¿Cómo calificas el ambiente laboral en tu equipo?",name:"ambiente_laboral",min:1,max:5,step:1,required:!0},{id:"f_liderazgo",type:"range",label:"¿Sientes que tu lÃder directo apoya tu desarrollo?",name:"apoyo_liderazgo",min:1,max:5,step:1,required:!0},{id:"f_herramientas",type:"switch",label:"¿Cuentas con las herramientas necesarias para tu trabajo?",name:"cuenta_herramientas",required:!0},{id:"f_sugerencias",type:"textarea",label:"¿Qué iniciativas mejorarÃan el ambiente laboral?",name:"sugerencias_mejora",rows:4,required:!1}]},{id:"evento",title:"Evaluación de Capacitación / Evento",description:"Contenido, expositor y organización general",fields:[{id:"f_heading_ev",type:"heading",label:"Evaluación del Evento",name:"heading_evento",content:"Encuesta de Cierre y Retroalimentación",level:"h2"},{id:"f_utilidad",type:"range",label:"¿Qué tan útil fue el contenido aprendido? (1 a 5)",name:"utilidad_contenido",min:1,max:5,step:1,required:!0},{id:"f_expositor",type:"range",label:"¿Cómo evalúas el dominio del tema del expositor? (1 a 5)",name:"evaluacion_expositor",min:1,max:5,step:1,required:!0},{id:"f_claridad",type:"radio",label:"¿La duración del evento fue adecuada?",name:"duracion_adecuada",options:[{label:"Muy corta",value:"corta"},{label:"Adecuada",value:"adecuada"},{label:"Muy extensa",value:"extensa"}],required:!0},{id:"f_temas",type:"textarea",label:"¿Qué otros temas te gustarÃa recibir en el futuro?",name:"temas_futuros",rows:3,required:!1}]},{id:"rapida",title:"Sondeo Rápido de Calidad",description:"Preguntas esenciales para respuestas inmediatas",fields:[{id:"f_heading_rapida",type:"heading",label:"Sondeo de Calidad",name:"heading_rapida",content:"Tu opinión en 1 minuto",level:"h2"},{id:"f_calif",type:"range",label:"Calificación general del servicio",name:"calificacion",min:1,max:5,step:1,required:!0},{id:"f_volveria",type:"switch",label:"¿VolverÃas a utilizar nuestros servicios?",name:"volveria",required:!0},{id:"f_opinion",type:"textarea",label:"¿Alguna observación rápida?",name:"observacion",rows:2,required:!1}]}],Ft=[{value:"public",label:"Pública",description:"Enlace abierto sin necesidad de iniciar sesión",icon:Ve},{value:"private",label:"Privada",description:"Requiere que el usuario esté autenticado en el sistema",icon:Ue},{value:"coustom",label:"Personalizada",description:"Acceso restringido solo a los usuarios seleccionados",icon:ca}],_s=[{name:"Texto y Datos",types:["text","textarea","email","tel","number","password","url","date","time","datetime-local"]},{name:"Opciones y Selección",types:["radio","checkbox","select","switch","yes_no","button_group"]},{name:"Calificaciones y Escalas",types:["range","nps","rating","matrix","color"]},{name:"Multimedia y Captura",types:["file","camera","multi_photo","video","signature","location_picker","my_location"]},{name:"Estructura y TÃtulos",types:["heading","paragraph","divider"]}],qt=({field:m,index:y,onSelect:f,onDelete:n,onDuplicate:S,onWidthChange:h,isSelected:re,brandColor:de})=>{const{attributes:E,listeners:U,setNodeRef:D,transform:R,transition:le,isDragging:
1M}=et({id:m.id}),Y={transform:st.Transform.toString(R),transition:le,opacity:M?.5:1},$=ce.find(u=>u.value===m.type),me=m.width||"100";return e.jsxs("div",{ref:D,style:Y,className:P("p-3.5 rounded-xl border-2 transition-all cursor-pointer bg-card hover:shadow-xs flex flex-col justify-between h-full",re?"border-primary shadow-xs ring-1 ring-primary/20 bg-primary/5":"border-border/80 hover:border-border"),onClick:f,children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("button",{type:"button",className:"cursor-grab active:cursor-grabbing touch-none p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors mt-0.5",...E,...U,title:"Arrastrar para reordenar",children:e.jsx(Ra,{className:"h-4 w-4"})}),e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-bold text-white shadow-xs mt-0.5",style:{backgroundColor:de||"#4f46e5"},children:y+1}),e.jsx("div",{className:"h-8 w-8 rounded-lg bg-muted flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(Ds,{type:m.type,className:"h-4 w-4 text-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[e.jsx("p",{className:"font-semibold text-sm truncate text-foreground",children:m.label||m.content||"Sin etiqueta"}),m.required&&e.jsx(O,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Obligatorio"})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate",children:m.name||m.type}),e.jsx("span",{className:"text-xs text-muted-foreground/60",children:"â¢"}),e.jsx("span",{className:"text-xs text-muted-foreground capitalize",children:($==null?void 0:$.label)||m.type})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(g,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-foreground",onClick:u=>{u.stopPropagation(),S()},title:"Duplicar pregunta",children:e.jsx(Ts,{className:"h-3.5 w-3.5"})}),e.jsx(g,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive/80 hover:text-destructive hover:bg-destructive/10",onClick:u=>{u.stopPropagation(),n()},title:"Eliminar pregunta",children:e.jsx(Fa,{className:"h-3.5 w-3.5"})})]})]}),!["heading","paragraph","divider"].includes(m.type)&&e.jsxs("div",{className:"mt-3 pt-2 border-t border-border/40 flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1 text-[11px]",children:[e.jsx(zs,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{children:"Ancho:"})]}),e.jsx("div",{className:"flex items-center gap-1 bg-muted/70 p-0.5 rounded-md",children:["100","50","33","25"].map(u=>e.jsxs("button",{type:"button",className:P("px-1.5 py-0.5 text-[10px] rounded transition-colors",me===u?"bg-background text-foreground shadow-2xs font-bold":"text-muted-foreground hover:text-foreground"),onClick:A=>{A.stopPropagation(),h==null||h(u)},title:`Ancho ${u}%`,children:[u,"%"]},u))})]})]})},Vt=({field:m,onChange:y,onClose:f})=>{var ne;const[n,S]=d.useState(m);d.useEffect(()=>{S(m)},[m]);const h=(t,i)=>{const x={...n,[t]:i};S(x),y(x)},re=(t,i,x)=>{const _=[...n.options||[]];_[t]={..._[t],[i]:x},h("options",_)},de=()=>{const t=[...n.options||[]],i=t.length+1;t.push({label:`Opción ${i}`,value:`opcion_${i}`}),h("options",t)},E=t=>{const i=[...n.options||[]];i.splice(t,1),h("options",i)},U=Array.isArray(n.matrixRows)?n.matrixRows:Array.isArray(n.rows)?n.rows:[{id:"r1",label:"Calidad del servicio"},{id:"r2",label:"Tiempo de respuesta"}],D=Array.isArray(n.matrixColumns)?n.matrixColumns:Array.isArray(n.columns)?n.columns:[{id:"c1",label:"Malo",value:"1"},{id:"c2",label:"Regular",value:"2"},{id:"c3",label:"Bueno",value:"3"},{id:"c4",label:"Excelente",value:"4"}],R=(t,i)=>{const x=[...U];x[t]={...x[t],label:i};const _={...n,matrixRows:x,rows:x};S(_),y(_)},le=()=>{const t=[...U],i=t.length+1;t.push({id:`r_${Date.now().toString().slice(-4)}`,label:`Criterio ${i}`});const x={...n,matrixRows:t,rows:t};S(x),y(x)},M=t=>{const i=[...U];i.splice(t,1);const x={...n,matrixRows:i,rows:i};S(x),y(x)},Y=(t,i,x)=>{const _=[...D];_[t]={..._[t],[i]:x};const ye={...n,matrixColumns:_,columns:_};S(ye),y(ye)},$=()=>{const t=[...D],i=t.length+1;t.push({id:`c_${Date.now().toString().slice(-4)}`,label:`Nivel ${i}`,value:String(i)});const x={...n,matrixColumns:t,columns:t};S(x),y(x)},me=t=>{const i=[...D];i.splice(t,1);const x={...n,matrixColumns:i,columns:i};S(x),y(x)},u=["heading","paragraph","divider"].includes(m.type),A=["select","radio","checkbox","button_group"].includes(m.type);return e.jsx(at,{open:!0,onOpenChange:()=>f(),children:e.jsxs(tt,{className:"w-full sm:max-w-md overflow-y-auto",children:[e.jsxs(rt,{className:"pb-4 border-b",children:[e.jsxs(lt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Oe,{className:"h-5 w-5 text-primary"}),"Configurar Pregunta"]}),e.jsx(nt,{children:"Ajusta los detalles, validaciones y opciones de esta pregunta"})]}),e.jsx("div",{className:"space-y-6 mt-6",children:e.jsxs(ct,{type:"single",collapsible:!0,defaultValue:"basic",children:[e.jsxs(F,{value:"basic",children:[e.jsx(q,{className:"text-sm font-semibold",children:"Propiedades Principales"}),e.jsx(V,{className:"space-y-4 pt-4",children:u?e.jsxs(e.Fragment,{children:[m.type==="heading"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Texto del Encabezado"}),e.jsx(p,{value:n.content||"",onChange:t=>h("content",t.target.value),placeholder:"Ej: Sección de Opinión General..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Tamaño / Nivel de Encabezado"}),e.jsxs(je,{value:n.level||"h2",onValueChange:t=>h("level",t),children:[e.jsx(fe,{children:e.jsx(ve,{})}),e.jsxs(Ne,{children:[e.jsx(L,{value:"h1",children:"H1 - TÃtulo Principal (Grande)"}),e.jsx(L,{value:"h2",children:"H2 - SubtÃtulo de Sección (Mediano)"}),e.jsx(L,{value:"h3",children:"H3 - Encabezado Secundario"}),e.jsx(L,{value:"h4",children:"H4 - Encabezado Menor"})]})]})]})]}),m.type==="paragraph"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Contenido del Párrafo Explicativo"}),e.jsx(ge,{value:n.content||"",onChange:t=>h("content",t.target.value),placeholder:"Escribe instrucciones o contexto para el encuestado...",rows:4})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Pregunta / Etiqueta Visible"}),e.jsx(p,{value:n.label,onChange:t=>h("label",t.target.value),placeholder:"Ej: ¿Qué tan satisfecho estás con el servicio?"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Identificador / Variable de Datos (Slug)"}),e.jsx(p,{value:n.name,onChange:t=>h("name",t.target.value.replace(/\s+/g,"_").toLowerCase()),placeholder:"nombre_de_variable",className:"font-mono text-xs"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Identificador único que agrupa la respuesta en la base de datos y reportes."})]}),!["switch","checkbox","radio"].includes(m.type)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Texto de Marc
1ador de Posición (Placeholder)"}),e.jsx(p,{value:n.placeholder||"",onChange:t=>h("placeholder",t.target.value),placeholder:"Ej: Escribe tu respuesta aquÃ..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Instrucción o Ayuda Adicional"}),e.jsx(p,{value:n.helpText||"",onChange:t=>h("helpText",t.target.value),placeholder:"Ej: Selecciona la opción más representativa..."})]})]})})]}),!u&&e.jsxs(F,{value:"layout",children:[e.jsx(q,{className:"text-sm font-semibold flex items-center gap-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zs,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Disposición y Columnas (Layout)"})]})}),e.jsxs(V,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Controla el ancho de la tarjeta en el formulario. En pantallas grandes, las preguntas con anchos menores se acomodan en la misma fila automáticamente."}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[{value:"100",label:"100% Completo",desc:"1 por fila"},{value:"50",label:"50% Mitad",desc:"2 por fila"},{value:"33",label:"33% Tercio",desc:"3 por fila"},{value:"25",label:"25% Cuarto",desc:"4 por fila"},{value:"66",label:"66% Dos Tercios",desc:"Asimétrico"},{value:"75",label:"75% Tres Cuartos",desc:"Asimétrico"}].map(t=>e.jsxs("button",{type:"button",className:P("p-2 rounded-lg border text-left transition-all text-xs flex flex-col justify-between gap-1",(n.width||"100")===t.value?"border-primary bg-primary/10 ring-1 ring-primary/30 font-semibold text-primary":"border-border/80 hover:bg-muted/50 text-foreground"),onClick:()=>h("width",t.value),children:[e.jsx("span",{className:"font-bold",children:t.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:t.desc})]},t.value))})]})]}),m.type==="nps"&&e.jsxs(F,{value:"nps_config",children:[e.jsxs(q,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(As,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Configuración Escala NPS (0-10)"})]}),e.jsxs(V,{className:"space-y-3 pt-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Etiqueta Extremo MÃnimo (0)"}),e.jsx(p,{value:n.minLabel||"",onChange:t=>h("minLabel",t.target.value),placeholder:"Ej: Nada probable, Pésimo",className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Etiqueta Extremo Máximo (10)"}),e.jsx(p,{value:n.maxLabel||"",onChange:t=>h("maxLabel",t.target.value),placeholder:"Ej: Totalmente probable, Excelente",className:"h-8 text-xs"})]})]})]}),m.type==="rating"&&e.jsxs(F,{value:"rating_config",children:[e.jsxs(q,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx($e,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{children:"Configuración de Estrellas"})]}),e.jsxs(V,{className:"space-y-3 pt-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Cantidad de Estrellas"}),e.jsxs(je,{value:String(n.maxStars||5),onValueChange:t=>h("maxStars",Number(t)),children:[e.jsx(fe,{className:"h-8 text-xs",children:e.jsx(ve,{})}),e.jsxs(Ne,{children:[e.jsx(L,{value:"3",children:"3 Estrellas"}),e.jsx(L,{value:"5",children:"5 Estrellas (Recomendado)"}),e.jsx(L,{value:"7",children:"7 Estrellas"}),e.jsx(L,{value:"10",children:"10 Estrellas"})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border bg-muted/20",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-xs font-medium",children:"Mostrar Texto de Nivel"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:'Muestra "Malo", "Regular", "Excelente", etc.'})]}),e.jsx(Z,{checked:n.showScoreText!==!1,onCheckedChange:t=>h("showScoreText",t)})]})]})]}),m.type==="yes_no"&&e.jsxs(F,{value:"yes_no_config",children:[e.jsxs(q,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(ke,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Configuración Sà / No"})]}),e.jsx(V,{className:"space-y-3 pt-3",children:e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Texto Opción SÃ"}),e.jsx(p,{value:n.yesLabel||"SÃ",onChange:t=>h("yesLabel",t.target.value),placeholder:"Sà / De acuerdo",className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Texto Opción No"}),e.jsx(p,{value:n.noLabel||"No",onChange:t=>h("noLabel",t.target.value),placeholder:"No / En desacuerdo",className:"h-8 text-xs"})]})]})})]}),m.type==="matrix"&&e.jsxs(F,{value:"matrix_config",children:[e.jsxs(q,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Filas y Columnas de la Matriz"})]}),e.jsxs(V,{className:"space-y-4 pt-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-xs font-bold text-foreground",children:"Criterios a Calificar (Filas)"}),e.jsx("div",{className:"space-y-1.5 max-h-44 overflow-y-auto pr-1",children:U.map((t,i)=>e.jsxs("div",{className:"flex items-center gap-1.5 bg-muted/30 p-1.5 rounded-lg border",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted-foreground w-4 text-center",children:i+1}),e.jsx(p,{value:t.label,onChange:x=>R(i,x.target.value),placeholder:"Aspecto a evaluar",className:"h-7 text-xs flex-1"}),e.jsx(g,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",onClick:()=>M(i),disabled:U.length<=1,children:e.jsx(Ee,{className:"h-3 w-3"})})]},t.id||i))}),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:le,className:"w-full h-7 text-xs gap-1",children:[e.jsx(be,{className:"h-3 w-3"}),"Agregar Fila / Aspecto"]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx(o,{className:"text-xs font-bold text-foreground",children:"Escala de Valoración (Columnas)"}),e.jsx("div",{className:"space-y-1.5 max-h-44 overflow-y-auto pr-1",children:D.map((t,i)=>e.jsxs("div",{className:"flex items-center gap-1.5 bg-muted/30 p-1.5 rounded-lg border",children:[e.jsx("span",{className:"text-[11px] font-bold text-muted-foreground w-4 text-center",children:i+1}),e.jsx(p,{value:t.label,onChange:x=>Y(i,"label",x.target.value),placeholder:"Columna",className:"h-7 text-xs flex-1"}),e.jsx(p,{value:t.value,onChange:x=>Y(i,"value",x.target.value),placeholder:"Valor",className:"h-7 text-xs w-16 font-mono"}),e.jsx(g,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10",onClick:()=>me(i),disabled:D.length<=1,children:e.jsx(Ee,{className:"h-3 w-3"})})]},t.id||i))}),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:$,className:"w-full h-7 text-xs gap-1",children:[e.jsx(be,{className:"h-3 w-3"}),"Agregar Columna de Escala"]})]})]})]}),A&&e.jsxs(F,{value:"options",children:[e.jsx(q,{className:"text-sm font-semibold",children:"Opciones de Respuesta"}),e.jsxs(V,{className:"space-y-4 pt-4",children:[e.jsx("div",{className:"space-y-2 max-h-60 overflow-y-auto pr-1",children:(ne=n.options)==null?void 0:ne.map((t,i)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/30 p-1.5 rounded-lg border",children:[e.jsx("span",{className:"text-xs font-bold text-muted-foreground w-4 text-center",children:i+1}),e.jsx(p,{value:t.label,onChange:x=>
1re(i,"label",x.target.value),placeholder:"Texto de la opción",className:"flex-1 h-8 text-xs"}),e.jsx(p,{value:t.value,onChange:x=>re(i,"value",x.target.value),placeholder:"Valor de reporte",className:"w-28 h-8 text-xs font-mono"}),e.jsx(g,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10",onClick:()=>E(i),disabled:n.options.length<=1,children:e.jsx(Ee,{className:"h-3.5 w-3.5"})})]},i))}),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:de,className:"w-full gap-1.5",children:[e.jsx(be,{className:"h-4 w-4"}),"Agregar Opción"]})]})]}),!u&&e.jsxs(F,{value:"validation",children:[e.jsx(q,{className:"text-sm font-semibold",children:"Reglas y Obligatoriedad"}),e.jsxs(V,{className:"space-y-4 pt-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/20",children:[e.jsxs("div",{children:[e.jsx(o,{className:"font-medium",children:"Respuesta Obligatoria"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"El encuestado no podrá enviar el formulario sin responder."})]}),e.jsx(Z,{checked:n.required||!1,onCheckedChange:t=>h("required",t)})]}),m.type==="range"&&e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(o,{className:"text-xs",children:"MÃnimo"}),e.jsx(p,{type:"number",value:n.min??1,onChange:t=>h("min",Number(t.target.value)),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(o,{className:"text-xs",children:"Máximo"}),e.jsx(p,{type:"number",value:n.max??5,onChange:t=>h("max",Number(t.target.value)),className:"h-8 text-xs"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(o,{className:"text-xs",children:"Paso (Step)"}),e.jsx(p,{type:"number",value:n.step??1,onChange:t=>h("step",Number(t.target.value)),className:"h-8 text-xs"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-muted/20",children:[e.jsxs("div",{children:[e.jsx(o,{className:"font-medium",children:"Deshabilitado"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Campo de solo lectura o temporalmente inactivo."})]}),e.jsx(Z,{checked:n.disabled||!1,onCheckedChange:t=>h("disabled",t)})]})]})]}),m.type==="multi_photo"&&e.jsxs(F,{value:"photo_config",children:[e.jsx(q,{className:"text-sm font-semibold",children:"Configuración de Fotos"}),e.jsx(V,{className:"space-y-3 pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"LÃmite Máximo de FotografÃas"}),e.jsx(p,{type:"number",value:n.maxPhotos??5,onChange:t=>h("maxPhotos",parseInt(t.target.value)||5),min:1,max:20})]})})]}),m.type==="video"&&e.jsxs(F,{value:"video_config",children:[e.jsx(q,{className:"text-sm font-semibold",children:"Configuración de Video"}),e.jsx(V,{className:"space-y-3 pt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{children:"Duración Máxima de Grabación (segundos)"}),e.jsx(p,{type:"number",value:n.maxDuration??60,onChange:t=>h("maxDuration",parseInt(t.target.value)||60),min:5,max:300})]})})]})]})})]})})},xr=()=>{var ms,xs;const m=At(),{documentId:y}=zt(),f=qa(y),n=!!f,{hasPermission:S}=Va();S("api::survey-digital-form.survey-digital-form.create"),S("api::survey-digital-form.survey-digital-form.update");const{startTour:h,hasSeenTour:re}=Oa("create-survey-tour",Lt),[de,E]=d.useState("builder"),[U,D]=d.useState(!0),[R,le]=d.useState(!1),[M,Y]=d.useState(""),[$,me]=d.useState(""),[u,A]=d.useState([]),[ne,t]=d.useState(null),[i,x]=d.useState(""),[_,ye]=d.useState([]),[Ot,He]=d.useState(!1),[W,Ge]=d.useState("none"),[N,xe]=d.useState("#4F46E5"),[we,Is]=d.useState(!0),[Te,Ye]=d.useState(!0),[Pe,Ke]=d.useState("¡Muchas gracias por completar la encuesta!"),[b,Ce]=d.useState(qe),[Me,Qe]=d.useState("saved"),[Ae,Rs]=d.useState([]),[Ut,Xe]=d.useState(!1),[Je,Fs]=d.useState(""),[Ze,We]=d.useState(!1),[_e,es]=d.useState("invitation"),[z,ss]=d.useState("public"),[ee,as]=d.useState([]),[ts,qs]=d.useState([]),[Vs,rs]=d.useState(!1),[Os,Us]=d.useState(!1),[se,ze]=d.useState("desktop"),r=d.useMemo(()=>!W||W==="none"?null:_.find(s=>
1String(s.id||s.documentId)===W)||null,[_,W]),B=d.useMemo(()=>{var l,c;if(!r)return"";const s=(l=r.imagen)==null?void 0:l[0],a=(s==null?void 0:s.url)||((c=s==null?void 0:s.attributes)==null?void 0:c.url)||"";return a?Ua(a):""},[r]),H=d.useMemo(()=>u.filter(s=>!["heading","paragraph","divider","_meta_branding"].includes(s.type)).length,[u]),Le=d.useMemo(()=>Math.max(1,Math.round(H*.5)),[H]),$s=$a(gs(Ga,{activationConstraint:{distance:5}}),gs(Ha,{coordinateGetter:Ba}));d.useEffect(()=>{(async()=>{He(!0);try{const a=await Ct.getCompanies({pageSize:100});a!=null&&a.success&&Array.isArray(a.data)&&ye(a.data)}catch(a){console.error("Error loading companies:",a)}finally{He(!1)}})()},[]),d.useEffect(()=>{(async()=>{Xe(!0);try{const a=await _t.getAll(1,100);a!=null&&a.success&&Array.isArray(a.data)&&Rs(a.data)}catch(a){console.error("Error loading saved SMTP accounts:",a)}finally{Xe(!1)}})()},[]),d.useEffect(()=>{(async()=>{rs(!0);try{const a=await St.getUsers({pageSize:500});a!=null&&a.success&&Array.isArray(a.data)&&qs(a.data)}catch(a){console.error("Error loading users:",a)}finally{rs(!1)}})()},[]);const{data:ae}=Tt(["survey-form",f],()=>ft(f),Pt.SURVEY_FORM,f||"",{enabled:n&&!!f});d.useEffect(()=>{if(!(ae!=null&&ae.data)){n||D(!1);return}const s=ae.data;Y(s.title||""),ss(s.type||"public");const l=(Array.isArray(s.structure)?s.structure:[]).filter(C=>C.type!=="_meta_branding");A(l);const c=vt(s);c&&(c.companyId&&Ge(String(c.companyId)),c.primaryColor&&xe(c.primaryColor),c.customThankYouMessage&&Ke(c.customThankYouMessage),c.applyBrandingToEmail!==void 0&&Ye(c.applyBrandingToEmail)),Ce({...qe,email_notifications_enabled:!!s.email_notifications_enabled,email_notification_recipients:s.email_notification_recipients||"",email_notification_subject:s.email_notification_subject||qe.email_notification_subject,email_from_name:s.email_from_name||"",email_from_address:s.email_from_address||"",email_smtp_host:s.email_smtp_host||"",email_smtp_port:s.email_smtp_port||587,email_smtp_secure:!!s.email_smtp_secure,email_smtp_user:s.email_smtp_user||"",email_smtp_password:""});const k=(s.users||[]).map(C=>String(C.id||C.documentId));as(k),D(!1)},[ae==null?void 0:ae.data,n]),d.useEffect(()=>{n||D(!1)},[n]);const Bs=s=>{if(Ge(s),s==="none")return;const a=_.find(l=>String(l.id||l.documentId)===s);a&&(a.ColorPrimario&&xe(a.ColorPrimario),j.info(`Empresa "${a.Nombre}" seleccionada`))},ls=()=>
1{if(!r){j.error('Selecciona primero una empresa en la pestaña "Empresa y Branding"');return}Ce(s=>({...s,email_notifications_enabled:!0,email_from_name:r.Nombre||s.email_from_name||"Encuestas",email_from_address:r.email||s.email_from_address||"",email_notification_subject:`Nueva respuesta: {{surveyTitle}} - ${r.Nombre}`})),j.success(`Datos de ${r.Nombre} aplicados al remitente SMTP`)},Hs=s=>{Fs(s);const a=Ae.find(l=>String(l.id||l.documentId)===s);a&&(Ce(l=>({...l,email_smtp_host:a.smtp_host||"",email_smtp_port:a.smtp_port||587,email_smtp_user:a.email||"",email_smtp_secure:!!a.use_ssl,email_from_address:l.email_from_address||a.email||"",email_from_name:l.email_from_name||(r==null?void 0:r.Nombre)||"Encuestas Institucionales"})),j.success(`Cuenta SMTP ${a.email} vinculada`))},ns=s=>{const a=Date.now(),l=s.fields.map((c,w)=>({...c,id:`field_${a}_${w}`}));A(c=>[...c,...l]),M.trim()||Y(s.title),j.success(`Plantilla "${s.title}" cargada`)},is=s=>{as(a=>a.includes(s)?a.filter(l=>l!==s):[...a,s])},Gs=s=>{const{active:a,over:l}=s;l&&a.id!==l.id&&A(c=>{const w=c.findIndex(C=>C.id===a.id),k=c.findIndex(C=>C.id===l.id);return Wa(c,w,k)})},G=s=>{const a=Et(s),l=ce.find(C=>C.value===s),c=u.filter(C=>C.type===s).length+1,w=Date.now(),k={...a,id:`field_${w}`,label:a.label||`${(l==null?void 0:l.label)||"Pregunta"} ${c}`,name:a.name||`${s}_${w.toString().slice(-5)}`};A([...u,k]),t(k.id),j.success(`Campo "${(l==null?void 0:l.label)||s}" agregado`)},Ys=s=>{A(u.filter(a=>a.id!==s)),ne===s&&t(null)},Ks=s=>{const a=u.find(l=>l.id===s);if(a){const l=Date.now(),c={...a,id:`field_${l}`,name:`${a.name}_copia_${l.toString().slice(-4)}`,label:`${a.label||"Pregunta"} (Copia)`},w=u.findIndex(C=>C.id===s),k=[...u];k.splice(w+1,0,c),A(k),j.success("Pregunta duplicada")}},Qs=s=>{A(u.map(a=>a.id===s.id?s:a))},Xs=(s,a)=>{A(l=>l.map(c=>c.id===s?{...c,width:a}:c))},I=(s,a)=>{Ce(l=>({...l,[s]:a}))},os=(s={})=>{var l,c,w;if(!b.email_notifications_enabled)return!0;const a=Rt(b.email_notification_recipients||"");return!a.length||a.some(k=>!ws(k))?(j.error("Configura al menos un correo destinatario válido en la pestaña SMTP"),E("smtp"),!1):(l=b.email_smtp_host)!=null&&l.trim()?Number(b.email_smtp_port)?(c=b.email_smtp_user)!=null&&c.trim()?s.requirePassword&&!((w=b.email_smtp_password)!=null&&w.trim())?(j.error("Ingresa la contraseña del servidor SMTP"),E("smtp"),!1):b.email_from_address&&!ws(b.email_from_address)?(j.error("Configura un correo remitente válido"),E("smtp"),!1):!0:(j.error("Configura el usuario SMTP"),E("smtp"),!1):(j.error("Configura un puerto SMTP válido (ej: 587 o 465)"),E("smtp"),!1):(j.error("Configura el servidor SMTP en la pestaña SMTP"),E("smtp"),!1)},Js=async()=>{if(!f){j.info("Guarda la encuesta antes de probar la conexión SMTP remota");return}if(os({requirePassword:!1})){We(!0);try{const s=await wt(f);s.success?j.success(s.message||"Conexión SMTP validada exitosamente"):j.error(s.error||"No se pudo validar la conexión SMTP")}catch(s){console.error("SMTP test error:",s),j.error("Error al probar la conexión SMTP")}finally{We(!1)}}},cs=async()=>{if(!M.trim()){j.error("Por favor ingresa un tÃtulo para la encuesta"),E("builder");return}if(u.length===0){j.error("Agrega al menos una pregunta a la encuesta"),E("builder");return}if(z==="coustom"&&ee.length===0){j.error('Selecciona al menos un usuario en la pestaña "Acceso y Ajustes"'),E("access");return}if(os({requirePassword:!n&&b.email_notifications_enabled&&!Je})){le(!0);try{const s={companyId:W!=="none"?W:void 0,companyName:(r==null?void 0:r.Nombre)||void 0,companySiglas:(r==null?void 0:r.Siglas)||void 0,companyEmail:(r==null?void 0:r.email)||void 0,logoUrl:B||void 0,primaryColor:N,applyBrandingToSurvey:we,applyBrandingToEmail:Te,customThankYouMessage:Pe},a={title:M,structure:u,type:z,users:z==="coustom"?ee:[],branding:s,...b},l=n?await Nt(f,a):await yt(a);l.success?(j.success(l.message||(n?"Encuesta actualizada con éxito":"Encuesta creada con éxito")),m("/surveys")):j.error(l.error||"Error al guardar la encuesta")}catch(s){console.error("Save survey error:",s),j.error("Error inesperado al guardar la encuesta")}finally{le(!1)}}},ds=u.find(s=>
1s.id===ne),Zs=d.useMemo(()=>{if(!i.trim())return _s;const s=i.toLowerCase();return _s.map(a=>({...a,types:a.types.filter(l=>{const c=ce.find(w=>w.value===l);return l.toLowerCase().includes(s)||(c==null?void 0:c.label.toLowerCase().includes(s))})})).filter(a=>a.types.length>0)},[i]);return U?e.jsx(kt,{}):e.jsxs("div",{className:"p-4 md:p-6 space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 border-b pb-4","data-tour":"create-survey-header",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(g,{variant:"ghost",size:"icon",onClick:()=>m("/surveys"),className:"rounded-full",children:e.jsx(sa,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center text-white shadow-xs",style:{backgroundColor:N},children:e.jsx(De,{className:"h-4 w-4"})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground tracking-tight",children:n?"Editar Encuesta":"Diseñador de Encuesta"}),r&&e.jsxs(O,{variant:"outline",className:"gap-1.5 py-0.5 text-xs font-medium border-primary/30 bg-primary/5",children:[e.jsx(Se,{className:"h-3 w-3 text-primary"}),r.Nombre]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap text-xs text-muted-foreground",children:[e.jsx("span",{children:n?"Modificando estructura y canales":"Crea encuestas inteligentes con branding corporativo"}),e.jsx("span",{children:"â¢"}),e.jsxs(O,{variant:"secondary",className:"text-[11px] font-normal",children:[H," ",H===1?"pregunta":"preguntas"]}),e.jsxs(O,{variant:"outline",className:"text-[11px] font-normal gap-1",children:[e.jsx(Ss,{className:"h-3 w-3"}),"~",Le," min"]}),e.jsxs(O,{variant:z==="public"?"default":"secondary",className:"text-[11px] font-normal capitalize gap-1",children:[z==="public"?e.jsx(Ve,{className:"h-3 w-3"}):e.jsx(Ue,{className:"h-3 w-3"}),z==="coustom"?"Personalizada":z]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap","data-tour":"create-survey-actions",children:[e.jsxs(bs,{children:[e.jsx(js,{asChild:!0,children:e.jsxs(g,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(ue,{className:"h-4 w-4 text-amber-500"}),"Plantillas"]})}),e.jsxs(fs,{align:"end",className:"w-80",children:[e.jsx("div",{className:"px-3 py-2 text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Cargar plantilla predefinida"}),e.jsx(Ya,{}),Cs.map(s=>e.jsxs(J,{onClick:()=>ns(s),className:"cursor-pointer flex flex-col items-start py-2.5 px-3",children:[e.jsx("span",{className:"font-semibold text-sm text-foreground",children:s.title}),e.jsx("span",{className:"text-xs text-muted-foreground mt-0.5",children:s.description})]},s.id))]})]}),n&&e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>window.open(Fe(f),"_blank"),className:"gap-1.5",children:[e.jsx(aa,{className:"h-4 w-4"}),"Ver en Vivo"]}),e.jsxs(g,{onClick:cs,disabled:R,className:"gap-2 shadow-sm font-semibold",style:{backgroundColor:N,color:"#ffffff"},children:[R?e.jsx(Ie,{className:"h-4 w-4 animate-spin"}):e.jsx(ps,{className:"h-4 w-4"}),R?"Guardando...":"Guardar Encuesta"]})]})]}),e.jsxs(it,{value:de,onValueChange:s=>E(s),className:"space-y-6",children:[e.jsxs(ot,{className:"grid grid-cols-2 md:grid-cols-5 h-auto p-1 bg-muted/60 rounded-xl gap-1",children:[e.jsxs(pe,{value:"builder",className:"gap-2 py-2.5 data-[state=active]:bg-background data-[state=active]:shadow-xs rounded-lg",children:[e.jsx(De,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium text-xs sm:text-sm",children:["1. Preguntas (",H,")"]})]}),e.jsxs(pe,{value:"branding",className:"gap-2 py-2.5 data-[state=active]:bg-background data-[state=active]:shadow-xs rounded-lg",children:[e.jsx(Se,{className:"h-4 w-4 text-blue-500"}),e.jsx("span",{className:"font-medium text-xs sm:text-sm",children:"2. Empresa & Marca"})]}),e.jsxs(pe,{value:"smtp",className:"gap-2 py-2.5 data-[state=active]:bg-background data-[state=active]:shadow-xs rounded-lg",children:[e.jsx(oe,{className:"h-4 w-4 text-emerald-500"}),e.jsx("span",{className:"font-medium text-xs sm:text-sm",children:"3. EnvÃo SMTP"})]}),e.jsxs(pe,{value:"access",className:"gap-2 py-2.5 data-[state=active]:bg-background data-[state=active]:shadow-xs rounded-lg",children:[e.jsx(Oe,{className:"h-4 w-4 text-amber-500"}),e.jsx("span",{className:"font-medium text-xs sm:text-sm",children:"4. Ajustes"})]}),e.jsxs(pe,{value:"preview",className:"gap-2 py-2.5 data-[state=active]:bg-background data-[state=active]:shadow-xs rounded-lg col-span-2 md:col-span-1",children:[e.jsx(Re,{className:"h-4 w-4 text-violet-500"}),e.jsx("span",{className:"font-medium text-xs sm:text-sm",children:"5. Vista Previa"})]})]}),e.jsx(he,{value:"builder",className:"space-y-6 m-0",children:e.jsxs("div",{className:"grid lg:grid-cols-12 gap-6",children:[e.jsxs(K,{className:"lg:col-span-4 border-border/80 shadow-xs","data-tour":"create-survey-field-types",children:[e.jsxs(Q,{className:"pb-3 border-b bg-muted/20",children:[e.jsxs(te,{className:"text-base flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(ta,{className:"h-4 w-4 text-primary"}),"Catálogo de Preguntas"]}),e.jsxs(O,{variant:"outline",className:"text-xs font-normal",children:[ce.length," tipos"]})]}),e.jsx(ie,{className:"text-xs",children:"Haz clic en cualquier tipo para agregarlo a la encuesta"}),e.jsxs("div",{className:"relative pt-2",children:[e.jsx(ra,{className:"absolute left-2.5 top-4.5 h-3.5 w-3.5 text-muted-foreground"}),e.jsx(p,{placeholder:"Buscar tipo de campo...",value:i,onChange:s=>x(s.target.value),className:"pl-8 h-8 text-xs bg-background"})]})]}),e.jsx(X,{className:"p-3",children:e.jsx(vs,{className:"h-[calc(100vh-360px)] pr-2",children:e.jsx("div",{className:"space-y-4",children:Zs.map(s=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-bold text-muted-foreground uppercase tracking-wider px-1",children:s.name}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:s.types.map(a=>{const l=ce.find(c=>c.value===a);return l?e.jsx(g,{variant:"outline",size:"sm",className:"h-auto py-2.5 px-2 flex-col items-start gap-1 justify-start border-border/70 hover:border-primary/60 hover:bg-primary/5 transition-all text-left group",onClick:()=>G(l.value),children:e.jsxs("div",{className:"flex items-center gap-1.5 w-full",children:[e.jsx("div",{className:"p-1 rounded bg-muted group-hover:bg-primary/10 transition-colors",children:e.jsx(Dt,{iconKey:l.icon,className:"h-3.5 w-3.5 text-foreground group-hover:text-primary transition-colors"})}),e.jsx("span",{className:"text-xs font-medium text-foreground truncate flex-1",children:l.label})]})},l.value):null})})]},s.name))})})})]}),e.jsxs(K,{className:"lg:col-span-8 border-border/80 shadow-xs","data-tour":"create-survey-builder",children:[e.jsxs(Q,{className:"pb-4 border-b bg-muted/10 space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(o,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:["TÃtulo de la Encuesta ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(p,{value:M,onChange:s=>Y(s.target.value),placeholder:"Ej: Encuesta de Satisfacción y Calidad de Servicio 2026",className:"text-lg font-bold h-11 bg-background"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs font-semibold text-muted-foreground",children:"Descripción o Indicaciones para el Encuestado (Opcional)"}),e.jsx(ge,{value:$,onChange:s=>me(s.target.value),placeholder:"Escribe un mensaje de bienvenida o instrucciones generales para quienes respondan...",rows:2,className:"text-xs bg-background resize-none"})]})]}),e.jsxs(X,{className:"p-4 md:p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-semibold text-foreground flex items-center gap-2",children:[e.jsx("span",{children:"Preguntas Formuladas"}),e.jsx(O,{variant:"secondary",className:"text-xs",children:H})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Arrastra las preguntas para ordenar la secuencia del cuestionario."})]}),e.jsxs(bs,{children:[e.jsx(js,{asChild:!0,children:e.jsxs(g,{variant:"outline",size:"sm",className:"gap-1.5 text-xs",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),"Añadir Pregunta"]})}),e.jsxs(fs,{align:"end",className:"w-56 max-h-80 overflow-y-auto",children:[e.jsx("div",{className:"px-2 py-1.5 text-xs font-semibold text-muted-foreground",children:"Tipos recomendados"}),e.jsx(J,{onClick:()=>G("text"),children:"Texto Corto"}),e.jsx(J,{onClick:()=>
1G("textarea"),children:"Párrafo / Comentarios"}),e.jsx(J,{onClick:()=>G("radio"),children:"Opción Múltiple"}),e.jsx(J,{onClick:()=>G("checkbox"),children:"Casillas de Verificación"}),e.jsx(J,{onClick:()=>G("range"),children:"Escala / Calificación"}),e.jsx(J,{onClick:()=>G("switch"),children:"Sà / No (Switch)"}),e.jsx(J,{onClick:()=>G("file"),children:"Subir Archivo"})]})]})]}),e.jsx(vs,{className:"h-[calc(100vh-420px)] pr-2",children:u.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center border-2 border-dashed rounded-xl bg-muted/10 p-6",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-primary/10 flex items-center justify-center text-primary mb-3",children:e.jsx(De,{className:"h-7 w-7"})}),e.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Tu encuesta aún no tiene preguntas"}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-sm mt-1 mb-4",children:"Comienza seleccionando un tipo de campo de la paleta izquierda o carga una plantilla prediseñada."}),e.jsxs("div",{className:"flex gap-2 flex-wrap justify-center",children:[e.jsxs(g,{variant:"outline",size:"sm",onClick:()=>ns(Cs[0]),className:"gap-1 text-xs",children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-amber-500"}),"Cargar Plantilla CSAT"]}),e.jsxs(g,{variant:"default",size:"sm",onClick:()=>G("text"),className:"gap-1 text-xs",children:[e.jsx(be,{className:"h-3.5 w-3.5"}),"Crear Primera Pregunta"]})]})]}):e.jsx(Ka,{sensors:$s,collisionDetection:Qa,onDragEnd:Gs,children:e.jsx(Xa,{items:u.map(s=>s.id),strategy:Ja,children:e.jsx("div",{className:"grid grid-cols-12 gap-3",children:u.map((s,a)=>e.jsx("div",{className:P(["heading","paragraph","divider"].includes(s.type)?"col-span-12":ys(s.width)),children:e.jsx(qt,{field:s,index:a,onSelect:()=>t(s.id),onDelete:()=>Ys(s.id),onDuplicate:()=>Ks(s.id),onWidthChange:l=>Xs(s.id,l),isSelected:ne===s.id,brandColor:N})},s.id))})})})})]})]})]})}),e.jsx(he,{value:"branding",className:"space-y-6 m-0",children:e.jsxs("div",{className:"grid lg:grid-cols-12 gap-6",children:[e.jsxs("div",{className:"lg:col-span-6 space-y-6",children:[e.jsxs(K,{className:"border-border/80 shadow-xs",children:[e.jsxs(Q,{className:"pb-3 border-b bg-muted/20",children:[e.jsxs(te,{className:"text-base flex items-center gap-2",children:[e.jsx(Se,{className:"h-5 w-5 text-primary"}),"Empresa Emisora de la Encuesta"]}),e.jsx(ie,{className:"text-xs",children:"Vincula una empresa registrada para importar su logotipo, nombre y estilo institucional"})]}),e.jsxs(X,{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-sm font-semibold",children:"Seleccionar Empresa"}),e.jsxs(je,{value:W,onValueChange:Bs,children:[e.jsx(fe,{className:"h-11",children:e.jsx(ve,{placeholder:"Selecciona una empresa..."})}),e.jsxs(Ne,{children:[e.jsx(L,{value:"none",children:e.jsx("span",{className:"text-muted-foreground",children:"Sin empresa vinculada (Identidad predeterminada)"})}),_.map(s=>e.jsx(L,{value:String(s.id||s.documentId),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Se,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium",children:s.Nombre}),s.Siglas&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.Siglas,")"]})]})},String(s.id||s.documentId)))]})]})]}),r&&e.jsxs("div",{className:"p-4 rounded-xl border bg-muted/20 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[B?e.jsx("img",{src:B,alt:r.Nombre,className:"h-14 w-14 object-contain rounded-lg border bg-white p-1"}):e.jsx("div",{className:"h-14 w-14 rounded-lg flex items-center justify-center font-bold text-white text-lg shrink-0 shadow-xs",style:{backgroundColor:N},children:(r.Nombre||"E").slice(0,2).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-bold text-base text-foreground truncate",children:r.Nombre}),r.Descripcion&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-0.5",children:r.Descripcion}),e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2 text-xs text-muted-foreground",children:[r.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(oe,{className:"h-3 w-3"})," ",r.email]}),r.celular&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Es,{className:"h-3 w-3"})," ",r.celular]})]})]})]}),e.jsxs(g,{type:"button",variant:"secondary",size:"sm",onClick:ls,className:"w-full gap-1.5 text-xs font-semibold",children:[e.jsx(ue,{className:"h-3.5 w-3.5 text-amber-500"}
1),"Aplicar esta Empresa al Remitente SMTP"]})]})]})]}),e.jsxs(K,{className:"border-border/80 shadow-xs",children:[e.jsxs(Q,{className:"pb-3 border-b bg-muted/20",children:[e.jsxs(te,{className:"text-base flex items-center gap-2",children:[e.jsx(ks,{className:"h-5 w-5 text-primary"}),"Color Primario Institucional"]}),e.jsx(ie,{className:"text-xs",children:"Define el color de los encabezados, botones de llamada a la acción y correos"})]}),e.jsxs(X,{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Paletas Corporativas Rápidas"}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:It.map(s=>{const a=N.toLowerCase()===s.hex.toLowerCase();return e.jsxs("button",{type:"button",onClick:()=>xe(s.hex),className:P("p-2.5 rounded-xl border flex flex-col items-center gap-1.5 transition-all text-center",a?"border-primary ring-2 ring-primary/30 bg-primary/5 shadow-xs":"border-border/80 hover:border-border"),children:[e.jsx("span",{className:"h-6 w-6 rounded-full shadow-xs border flex items-center justify-center",style:{backgroundColor:s.hex},children:a&&e.jsx(hs,{className:"h-3.5 w-3.5 text-white"})}),e.jsx("span",{className:"text-[11px] font-medium text-foreground truncate w-full",children:s.name})]},s.hex)})})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2 border-t",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(o,{className:"text-xs",children:"Color Hexadecimal Personalizado"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:N,onChange:s=>xe(s.target.value),className:"h-9 w-12 rounded cursor-pointer border p-0.5 bg-background"}),e.jsx(p,{value:N,onChange:s=>xe(s.target.value),placeholder:"#4F46E5",className:"font-mono text-xs uppercase"})]})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center p-3 rounded-xl border bg-muted/20",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground mb-1",children:"Muestra"}),e.jsx("div",{className:"h-7 w-16 rounded-md shadow-xs flex items-center justify-center text-[10px] font-bold text-white",style:{backgroundColor:N},children:"Botón"})]})]})]})]})]}),e.jsxs("div",{className:"lg:col-span-6 space-y-6",children:[e.jsxs(K,{className:"border-border/80 shadow-xs",children:[e.jsxs(Q,{className:"pb-3 border-b bg-muted/20",children:[e.jsxs(te,{className:"text-base flex items-center gap-2",children:[e.jsx(Re,{className:"h-5 w-5 text-primary"}),"Preferencias de Visualización de Marca"]}),e.jsx(ie,{className:"text-xs",children:"Controla qué elementos corporativos se exhiben al público"})]}),e.jsxs(X,{className:"p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl border bg-muted/10",children:[e.jsxs("div",{children:[e.jsx(o,{className:"font-semibold text-sm",children:"Mostrar Logotipo en la Encuesta"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Exhibe el logo corporativo centrado en el encabezado público."})]}),e.jsx(Z,{checked:we,onCheckedChange:Is})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl border bg-muted/10",children:[e.jsxs("div",{children:[e.jsx(o,{className:"font-semibold text-sm",children:"Identidad en Plantillas de Correo"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Aplica la cabecera de color y logotipo a los correos SMTP."})]}),e.jsx(Z,{checked:Te,onCheckedChange:Ye})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[e.jsx(o,{className:"font-semibold text-sm",children:"Mensaje de Agradecimiento Final"}),e.jsx(ge,{value:Pe,onChange:s=>Ke(s.target.value),placeholder:"¡Muchas gracias por completar la encuesta! Tus respuestas han sido registradas con éxito.",rows:3,className:"text-xs resize-none"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Mensaje de confirmación que verá el usuario inmediatamente después de enviar sus respuestas."})]})]})]}),e.jsxs("div",{className:"p-5 rounded-2xl border-2 border-dashed bg-card shadow-xs space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Previsualización del Encabezado de Encuesta"}),e.jsx(O,{variant:"outline",className:"text-[11px]",children:"En vivo"})]}),e.jsxs("div",{className:"overflow-hidden rounded-xl border shadow-sm bg-background",children:[e.jsx("div",{className:"h-2 w-full",style:{backgroundColor:N}}),e.jsxs("div",{className:"p-6 text-center space-y-3",children:[B?e.jsx("img",{src:B,alt:"Logo",className:"h-12 w-auto mx-auto object-contain"}):e.jsx("div",{className:"h-10 w-10 mx-auto rounded-lg flex items-center justify-center text-white font-bold",style:{backgroundColor:N},children:((ms=r==null?void 0:r.Nombre)==null?void 0:ms.slice(0,1))||"E"}),e.jsx("h3",{className:"text-lg font-bold text-foreground",children:M||"TÃtulo de la Encuesta"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:r?`Por ${r.Nombre}`:"Encuesta Institucional"})]})]})]})]})]})}),e.jsx(he,{value:"smtp",className:"space-y-6 m-0",children:e.jsxs("div",{className:"grid lg:grid-cols-12 gap-6",children:[e.jsx("div",{className:"lg:col-span-6 space-y-6",children:e.jsxs(K,{className:"border-border/80 shadow-xs",children:[e.jsx(Q,{className:"pb-3 border-b bg-muted/20",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(te,{className:"text-base flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-primary"}),"EnvÃo y Notificaciones por Correo"]}),e.jsx(ie,{className:"text-xs",children:"Despacha invitaciones y recibe alertas estructuradas de cada respuesta"})]}),e.jsx(Z,{checked:!!b.email_notifications_enabled,onCheckedChange:s=>I("email_notifications_enabled",s)})]})}),e.jsx(X,{className:"p-4 space-y-4",children:b.email_notifications_enabled?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{className:"text-xs font-semibold text-muted-foreground uppercase tracking-wider",children:"Origen del Servidor SMTP"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>Qe("saved"),className:P("p-3 rounded-xl border flex flex-col items-start gap-1 text-left transition-all",Me==="saved"?"border-primary ring-2 ring-primary/20 bg-primary/5 font-semibold text-primary":"border-border/80 hover:border-border text-muted-foreground"),children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-bold text-foreground",children:[e.jsx(la,{className:"h-3.5 w-3.5 text-primary"}),"Cuentas Guardadas"]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Usa una cuenta de correo ya vinculada"})]}),e.jsxs("button",{type:"button",onClick:()=>Qe("manual"),className:P("p-3 rounded-xl border flex flex-col items-start gap-1 text-left transition-all",Me==="manual"?"border-primary ring-2 ring-primary/20 bg-primary/5 font-semibold text-primary":"border-border/80 hover:border-border text-muted-foreground"),children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-xs font-bold text-foreground",children:[e.jsx(Oe,{className:"h-3.5 w-3.5 text-primary"}),"Configuración Manual"]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Ingresa host, puerto y contraseña"})]})]})]}),Me==="saved"&&e.jsxs("div",{className:"space-y-2 p-3.5 rounded-xl border bg-muted/20",children:[e.jsx(o,{className:"text-xs font-semibold",children:"Seleccionar Cuenta SMTP Registrada"}),Ae.length===0?e.jsx("div",{className:"text-xs text-muted-foreground p-3 bg-background rounded-lg border",children:"No hay cuentas SMTP registradas en el sistema. Puedes usar la configuración manual."}):e.jsxs(je,{value:Je,onValueChange:Hs,children:[e.jsx(fe,{className:"bg-background",children:e.jsx(ve,{placeholder:"Elige una cuenta de correo..."})}),e.jsx(Ne,{children:Ae.map(s=>e.jsx(L,{value:String(s.id||s.documentId),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"font-medium",children:s.email}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",s.smtp_host,":",s.smtp_port,")"]})]})},String(s.id||s.documentId)))})]})]}),e.jsxs("div",{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(o,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Credenciales del Servidor"}),r&&e.jsxs(g,{type:"button",variant:"ghost",size:"sm",onClick:ls,className:"h-7 text-xs text-primary gap-1",children:[e.jsx(ue,{className:"h-3 w-3"}),"Sincronizar con ",r.Nombre]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Nombre del Remitente"}),e.jsx(p,{value:b.email_from_name||"",onChange:s=>I("email_from_name",s.target.value),placeholder:(r==null?void 0:r.Nombre)||"Encuestas Institucionales",className:"text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Correo Remitente"}),e.jsx(p,{value:b.email_from_address||"",onChange:s=>I("email_from_address",s.target.value),placeholder:"[email protected]",className:"text-xs"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"col-span-2 space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Host SMTP"}),e.jsx(p,{value:b.email_smtp_host||"",onChange:s=>I("email_smtp_host",s.target.value),placeholder:"smtp.dominio.com",className:"text-xs font-mono"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Puerto"}),e.jsx(p,{type:"number",value:b.email_smtp_port||587,onChange:s=>I("email_smtp_port",Number(s.target.value)),placeholder:"587",className:"text-xs font-mono"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Usuario SMTP"}),e.jsx(p,{value:b.email_smtp_user||"",onChange:s=>I("email_smtp_user",s.target.value),placeholder:"[email protected]",className:"text-xs"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Contraseña SMTP"}),e.jsx(p,{type:"password",value:b.email_smtp_password||"",onChange:s=>I("email_smtp_password",s.target.value),placeholder:n?"Conservar contraseña":"â¢â¢â¢â¢â¢â¢â¢â¢",className:"text-xs",autoComplete:"new-password"})]})]}),e.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-lg border bg-muted/10",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-xs font-medium",children:"Usar SSL Directo (Puerto 465)"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"DesactÃvalo para STARTTLS en puerto 587."})]}),e.jsx(Z,{checked:!!b.email_smtp_secure,onCheckedChange:s=>I("email_smtp_secure",s)})]}),e.jsxs("div",{className:"space-y-1.5 pt-2 border-t",children:[e.jsx(o,{className:"text-xs",children:"Asunto del Correo"}),e.jsx(p,{value:b.email_notification_subject||"",onChange:s=>I("email_notification_subject",s.target.value),placeholder:"Nueva respuesta de encuesta: {{surveyTitle}}",className:"text-xs"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Variables permitidas: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"{{surveyTitle}}"}),", ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"{{companyName}}"}),"."]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs",children:"Destinatarios de Alertas Administrativas"}),e.jsx(ge,{value:b.email_notification_recipients||"",onChange:s=>I("email_notification_recipients",s.target.value),placeholder:"[email protected], [email protected]",rows:2,className:"text-xs"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Separa múltiples correos con comas o saltos de lÃnea."})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 p-3 rounded-xl border bg-primary/5 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(na,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Prueba la conexión para verificar autenticación."})]}),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:Js,disabled:!n||Ze,className:"gap-1.5 text-xs",children:[Ze?e.jsx(Ie,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ia,{className:"h-3.5 w-3.5"}),"Probar SMTP"]})]})]})]}):e.jsxs("div",{className:"py-8 text-center space-y-3",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto text-muted-foreground",children:e.jsx(oe,{className:"h-6 w-6"})}),e.jsx("h4",{className:"text-sm font-semibold",children:"Las notificaciones por correo están desactivadas"}),e.jsx("p",{className:"text-xs text-muted-foreground max-w-sm mx-auto",children:"Activa el interruptor superior para habilitar el servidor SMTP, configurar destinatarios y personalizar las plantillas con los colores de tu empresa."}),e.jsx(g,{type:"button",variant:"outline",size:"sm",onClick:()=>I("email_notifications_enabled",!0),children:"Activar Notificaciones"})]})})]})}),e.jsxs("div",{className:"lg:col-span-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-foreground flex items-center gap-2",children:[e.jsx(ue,{className:"h-4 w-4 text-amber-500"}
1),"Simulador del Correo Corporativo"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visualiza exactamente cómo recibirán el correo los destinatarios con el branding de la empresa"})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted p-0.5 rounded-lg",children:[e.jsx(g,{type:"button",variant:_e==="invitation"?"secondary":"ghost",size:"sm",className:"h-7 text-xs px-2.5",onClick:()=>es("invitation"),children:"Invitación"}),e.jsx(g,{type:"button",variant:_e==="response"?"secondary":"ghost",size:"sm",className:"h-7 text-xs px-2.5",onClick:()=>es("response"),children:"Notificación"})]})]}),e.jsxs("div",{className:"border rounded-2xl shadow-md overflow-hidden bg-background",children:[e.jsxs("div",{className:"bg-muted/80 border-b px-4 py-3 flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2 truncate",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-red-400"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-amber-400"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full bg-emerald-400"})]}),e.jsx("span",{className:"font-semibold text-foreground truncate ml-2",children:((xs=b.email_notification_subject)==null?void 0:xs.replace("{{surveyTitle}}",M||"Encuesta"))||"Notificación de Encuesta"})]}),e.jsx(O,{variant:"outline",className:"text-[10px]",children:"HTML Responsive"})]}),e.jsxs("div",{className:"px-6 py-3 border-b bg-muted/10 space-y-1 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground font-semibold w-16",children:"De:"}),e.jsxs("span",{className:"text-foreground font-medium",children:[b.email_from_name||(r==null?void 0:r.Nombre)||"Kinvo Encuestas"," ",e.jsxs("span",{className:"text-muted-foreground font-normal",children:["<",b.email_from_address||(r==null?void 0:r.email)||"[email protected]",">"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-muted-foreground font-semibold w-16",children:"Para:"}),e.jsx("span",{className:"text-foreground",children:_e==="invitation"?"[email protected]":b.email_notification_recipients||"[email protected]"})]})]}),e.jsx("div",{className:"p-6 md:p-8 space-y-6 bg-slate-50 dark:bg-zinc-950",children:e.jsxs("div",{className:"max-w-md mx-auto bg-white dark:bg-zinc-900 rounded-xl shadow-sm border overflow-hidden",children:[e.jsx("div",{className:"h-3 w-full",style:{backgroundColor:N}}),e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsxs("div",{className:"text-center space-y-2 border-b pb-4",children:[Te&&B?e.jsx("img",{src:B,alt:(r==null?void 0:r.Nombre)||"Logo",className:"h-12 w-auto mx-auto object-contain"}):e.jsx("div",{className:"h-10 w-10 mx-auto rounded-xl flex items-center justify-center text-white font-bold shadow-xs",style:{backgroundColor:N},children:((r==null?void 0:r.Nombre)||"E").slice(0,1).toUpperCase()}),e.jsx("h4",{className:"font-bold text-base text-foreground",children:(r==null?void 0:r.Nombre)||"Plataforma de Encuestas"})]}),_e==="invitation"?e.jsxs("div",{className:"space-y-4 text-xs text-foreground/90",children:[e.jsx("p",{className:"font-medium",children:"Hola estimad@,"}),e.jsxs("p",{children:["Te invitamos cordialmente a responder la encuesta ",e.jsxs("strong",{children:['"',M||"Satisfacción del Cliente",'"']}),". Tu opinión es fundamental para la toma de decisiones y mejora continua."]}),e.jsxs("div",{className:"p-3.5 rounded-lg border bg-muted/30 space-y-1.5",children:[e.jsx("p",{className:"font-semibold text-xs text-foreground",children:"Detalles del Cuestionario:"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["⢠Preguntas: ",H]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["⢠Tiempo estimado: ~",Le," minutos"]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["⢠Modalidad: ",z==="public"?"Pública":"Confidencial"]})]}),e.jsx("div",{className:"pt-2 text-center",children:e.jsx("button",{type:"button",className:"px-6 py-2.5 rounded-lg text-xs font-bold text-white shadow-md transition-transform active:scale-95",style:{backgroundColor:N},children:"Responder Encuesta Ahora"})})]}
1):e.jsxs("div",{className:"space-y-4 text-xs text-foreground/90",children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-600 font-semibold",children:[e.jsx(oa,{className:"h-4 w-4"}),e.jsx("span",{children:"Se ha registrado una nueva respuesta"})]}),e.jsxs("p",{children:["Un usuario ha completado el formulario de ",e.jsxs("strong",{children:['"',M||"Encuesta",'"']}),"."]}),e.jsxs("div",{className:"p-3.5 rounded-lg border bg-muted/30 space-y-1 text-[11px]",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"Resumen de captura:"}),e.jsxs("p",{className:"text-muted-foreground",children:["⢠Fecha: ",new Date().toLocaleDateString()]}),e.jsxs("p",{className:"text-muted-foreground",children:["⢠Hora: ",new Date().toLocaleTimeString()]}),e.jsxs("p",{className:"text-muted-foreground",children:["⢠Total de campos respondidos: ",H]})]}),e.jsx("div",{className:"pt-2 text-center",children:e.jsx("button",{type:"button",className:"px-6 py-2.5 rounded-lg text-xs font-bold text-white shadow-md",style:{backgroundColor:N},children:"Ver Respuestas en Panel"})})]}),e.jsxs("div",{className:"pt-4 border-t text-[11px] text-muted-foreground text-center space-y-1",children:[e.jsx("p",{className:"font-medium text-foreground",children:(r==null?void 0:r.Nombre)||"Kinvo Core"}),(r==null?void 0:r.email)&&e.jsxs("p",{children:["Contacto: ",r.email]}),e.jsx("p",{className:"text-[10px] text-muted-foreground/80",children:"Este es un mensaje institucional automatizado. Respuestas confidenciales y protegidas."})]})]})]})})]})]})]})}),e.jsx(he,{value:"access",className:"space-y-6 m-0",children:e.jsxs("div",{className:"grid lg:grid-cols-12 gap-6",children:[e.jsx("div",{className:"lg:col-span-7 space-y-6",children:e.jsxs(K,{className:"border-border/80 shadow-xs",children:[e.jsxs(Q,{className:"pb-3 border-b bg-muted/20",children:[e.jsxs(te,{className:"text-base flex items-center gap-2",children:[e.jsx(Ve,{className:"h-5 w-5 text-primary"}),"PolÃtica de Acceso y Visibilidad"]}),e.jsx(ie,{className:"text-xs",children:"Define quién puede acceder y contestar este cuestionario"})]}),e.jsxs(X,{className:"p-4 space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:Ft.map(s=>{const a=z===s.value;return e.jsxs("button",{type:"button",onClick:()=>ss(s.value),className:P("flex flex-col items-start gap-2 p-4 rounded-xl border-2 transition-all text-left",a?"border-primary bg-primary/5 text-primary shadow-xs":"border-border/80 hover:border-primary/50"),children:[e.jsx("div",{className:P("p-2 rounded-lg",a?"bg-primary text-white":"bg-muted text-foreground"),children:e.jsx(s.icon,{className:"h-5 w-5"})}),e.jsx("span",{className:"font-bold text-sm text-foreground",children:s.label}),e.jsx("span",{className:"text-xs text-muted-foreground leading-snug",children:s.description})]},s.value)})}),z==="coustom"&&e.jsxs("div",{className:"space-y-3 pt-3 border-t",children:[e.jsx(o,{className:"text-sm font-semibold",children:"Usuarios Autorizados"}),e.jsxs(gt,{open:Os,onOpenChange:Us,children:[e.jsx(bt,{asChild:!0,children:e.jsxs(g,{variant:"outline",role:"combobox",className:"w-full justify-between h-11",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(da,{className:"h-4 w-4 text-muted-foreground"}),ee.length>0?`${ee.length} usuario(s) seleccionado(s)`:"Buscar y agregar usuarios..."]}),e.jsx(ma,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(jt,{className:"w-96 p-0",align:"start",children:e.jsxs(dt,{children:[e.jsx(mt,{placeholder:"Buscar por nombre o correo..."}),e.jsxs(xt,{children:[e.jsx(ut,{children:Vs?"Cargando usuarios...":"No se encontraron usuarios."}),e.jsx(pt,{className:"max-h-64 overflow-auto",children:ts.map(s=>{const a=String(s.id),l=ee.includes(a);return e.jsxs(ht,{value:`${s.username||""} ${s.email||""}`,onSelect:()=>is(a),children:[e.jsx("div",{className:P("mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",l?"bg-primary text-primary-foreground":"opacity-50 [&_svg]:invisible"),children:e.jsx(hs,{className:"h-3 w-3"})}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium text-xs text-foreground",children:s.username||"Sin nombre"}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:s.email})]})]},a)})})]})]})})]}),ee.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2 max-h-36 overflow-y-auto p-2 bg-muted/20 rounded-lg border",children:ee.map(s=>{const a=ts.find(l=>String(l.id)===s);return a?e.jsxs(O,{variant:"secondary",className:"gap-1 py-1 px-2 text-xs",children:[a.username||a.email,e.jsx("button",{type:"button",onClick:()=>is(s),className:"ml-1 hover:text-destructive text-muted-foreground",children:e.jsx(Ee,{className:"h-3 w-3"})})]},s):null})})]}),z==="public"&&n&&e.jsxs("div",{className:"p-4 rounded-xl border bg-muted/20 space-y-2",children:[e.jsx(o,{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground",children:"Enlace Público de Respuesta"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{readOnly:!0,value:Fe(f),className:"font-mono text-xs bg-background"}),e.jsxs(g,{type:"button",variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(Fe(f)),j.success("Enlace copiado al portapapeles")},className:"gap-1 text-xs shrink-0",children:[e.jsx(Ts,{className:"h-3.5 w-3.5"}),"Copiar"]})]})]})]})]})}),e.jsx("div",{className:"lg:col-span-5 space-y-6",children:e.jsxs(K,{className:"border-border/80 shadow-xs",children:[e.jsx(Q,{className:"pb-3 border-b bg-muted/20",children:e.jsxs(te,{className:"text-base flex items-center gap-2",children:[e.jsx(xa,{
1className:"h-5 w-5 text-primary"}),"Resumen de Configuración"]})}),e.jsxs(X,{className:"p-4 space-y-3 text-xs",children:[e.jsxs("div",{className:"flex justify-between py-1.5 border-b",children:[e.jsx("span",{className:"text-muted-foreground",children:"Preguntas activas:"}),e.jsx("span",{className:"font-bold text-foreground",children:H})]}),e.jsxs("div",{className:"flex justify-between py-1.5 border-b",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tiempo estimado:"}),e.jsxs("span",{className:"font-bold text-foreground",children:["~",Le," min"]})]}),e.jsxs("div",{className:"flex justify-between py-1.5 border-b",children:[e.jsx("span",{className:"text-muted-foreground",children:"Empresa vinculada:"}),e.jsx("span",{className:"font-bold text-foreground",children:(r==null?void 0:r.Nombre)||"Predeterminada"})]}),e.jsxs("div",{className:"flex justify-between py-1.5 border-b",children:[e.jsx("span",{className:"text-muted-foreground",children:"Notificaciones SMTP:"}),e.jsx("span",{className:"font-bold text-foreground",children:b.email_notifications_enabled?"Habilitadas":"Desactivadas"})]}),e.jsxs("div",{className:"flex justify-between py-1.5 border-b",children:[e.jsx("span",{className:"text-muted-foreground",children:"Tipo de visibilidad:"}),e.jsx("span",{className:"font-bold text-foreground capitalize",children:z})]}),e.jsx("div",{className:"pt-3",children:e.jsxs(g,{type:"button",onClick:cs,disabled:R,className:"w-full gap-2 font-bold",style:{backgroundColor:N,color:"#ffffff"},children:[R?e.jsx(Ie,{className:"h-4 w-4 animate-spin"}):e.jsx(ps,{className:"h-4 w-4"}),R?"Guardando...":"Guardar y Publicar"]})})]})]})})]})}),e.jsxs(he,{value:"preview",className:"space-y-6 m-0",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-bold text-foreground flex items-center gap-2",children:[e.jsx(Re,{className:"h-4 w-4 text-violet-500"}
1),"Simulador en Vivo de la Encuesta"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Prueba interactiva de cómo los usuarios responderán el cuestionario"})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted p-0.5 rounded-lg",children:[e.jsxs(g,{type:"button",variant:se==="desktop"?"secondary":"ghost",size:"sm",className:"h-8 px-2.5 gap-1 text-xs",onClick:()=>ze("desktop"),children:[e.jsx(ua,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Desktop"})]}),e.jsxs(g,{type:"button",variant:se==="tablet"?"secondary":"ghost",size:"sm",className:"h-8 px-2.5 gap-1 text-xs",onClick:()=>ze("tablet"),children:[e.jsx(pa,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Tablet"})]}),e.jsxs(g,{type:"button",variant:se==="mobile"?"secondary":"ghost",size:"sm",className:"h-8 px-2.5 gap-1 text-xs",onClick:()=>ze("mobile"),children:[e.jsx(ha,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Móvil"})]})]})]}),e.jsx("div",{className:"bg-slate-100 dark:bg-zinc-950 p-4 md:p-8 rounded-2xl border flex justify-center overflow-x-auto",children:e.jsxs("div",{className:P("bg-card rounded-2xl shadow-lg border overflow-hidden transition-all duration-300",se==="desktop"&&"w-full max-w-2xl",se==="tablet"&&"w-[640px]",se==="mobile"&&"w-[360px]"),children:[e.jsx("div",{className:"h-2.5 w-full transition-colors",style:{backgroundColor:N}}),e.jsxs("div",{className:"p-6 md:p-8 space-y-6",children:[e.jsxs("div",{className:"text-center space-y-3 pb-4 border-b",children:[we&&B?e.jsx("img",{src:B,alt:"Logo",className:"h-14 w-auto mx-auto object-contain"}):we&&r?e.jsx("div",{className:"h-12 w-12 mx-auto rounded-xl flex items-center justify-center font-bold text-white shadow-xs",style:{backgroundColor:N},children:(r.Nombre||"E").slice(0,1).toUpperCase()}):null,e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-foreground",children:M||"TÃtulo de la Encuesta"}),$?e.jsx("p",{className:"text-xs md:text-sm text-muted-foreground max-w-md mx-auto",children:$}):null,r&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Publicado por ",e.jsx("strong",{children:r.Nombre})]})]}),u.length===0?e.jsx("div",{className:"py-12 text-center text-xs text-muted-foreground",children:"No hay preguntas configuradas todavÃa."}):e.jsx("div",{className:"grid grid-cols-12 gap-x-4 gap-y-5",children:u.map((s,a)=>{var w,k,C,us;const c=["heading","paragraph","divider"].includes(s.type)||se==="mobile"?"col-span-12":ys(s.width);return s.type==="heading"?e.jsxs("div",{className:P("pt-2",c),children:[e.jsx("h3",{className:"text-lg font-bold text-foreground",children:s.content||s.label}),e.jsx(Ns,{className:"mt-1"})]},s.id):s.type==="paragraph"?e.jsx("div",{className:c,children:e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:s.content||s.label})},s.id):s.type==="divider"?e.jsx("div",{className:c,children:e.jsx(Ns,{className:"my-2"})},s.id):e.jsxs("div",{className:P("space-y-2 p-3.5 rounded-xl border bg-muted/10 flex flex-col justify-between",c),children:[e.jsxs(o,{className:"flex items-start gap-2 text-xs md:text-sm font-semibold text-foreground",children:[e.jsxs("span",{className:"text-muted-foreground font-mono text-xs",children:[a+1,"."]}),e.jsxs("span",{className:"flex-1",children:[s.label||"Pregunta",s.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]})]}),["text","email","number","tel","url","password"].includes(s.type)&&e.jsx(p,{placeholder:s.placeholder||"Escribe tu respuesta...",className:"h-9 text-xs"}),s.type==="textarea"&&e.jsx(ge,{placeholder:s.placeholder||"Escribe detalladamente...",rows:3,className:"text-xs resize-none"}),s.type==="radio"&&e.jsx("div",{className:"space-y-1.5 pt-1",children:(w=s.options)==null?void 0:w.map((v,T)=>e.jsxs("label",{className:"flex items-center gap-2 p-2 rounded-lg border bg-background hover:bg-muted/30 cursor-pointer text-xs",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border border-primary/60 flex items-center justify-center"}),e.jsx("span",{children:v.label})]},T))}),s.type==="checkbox"&&e.jsx("div",{className:"space-y-1.5 pt-1",children:(k=s.options)==null?void 0:k.map((v,T)=>e.jsxs("label",{className:"flex items-center gap-2 p-2 rounded-lg border bg-background hover:bg-muted/30 cursor-pointer text-xs",children:[e.jsx(Za,{}),e.jsx("span",{children:v.label})]},T))}),s.type==="select"&&e.jsxs(je,{children:[e.jsx(fe,{className:"h-9 text-xs",children:e.jsx(ve,{placeholder:"Selecciona una opción..."})}),e.jsx(Ne,{children:(C=s.options)==null?void 0:C.map((v,T)=>e.jsx(L,{value:v.value||`opt_${T}`,children:v.label},T))})]}),s.type==="switch"&&e.jsxs("div",{className:"flex items-center justify-between pt-1",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Marcar opción afirmativa"}),e.jsx(Z,{})]}),s.type==="range"&&e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx("input",{type:"range",min:s.min||1,max:s.max||5,step:s.step||1,className:"w-full accent-primary curs
1or-pointer"}),e.jsxs("div",{className:"flex justify-between text-[11px] text-muted-foreground font-semibold",children:[e.jsxs("span",{children:[s.min??1," (MÃnimo)"]}),e.jsxs("span",{children:[s.max??5," (Máximo)"]})]})]}),s.type==="nps"&&e.jsxs("div",{className:"space-y-2 pt-1",children:[e.jsx("div",{className:"flex items-center justify-between gap-1 overflow-x-auto pb-1",children:[0,1,2,3,4,5,6,7,8,9,10].map(v=>e.jsx("button",{type:"button",className:P("h-7 w-7 text-xs font-bold rounded-lg border transition-colors flex items-center justify-center shrink-0",v<=6?"hover:bg-rose-500/10 hover:border-rose-500 text-rose-600 dark:text-rose-400":v<=8?"hover:bg-amber-500/10 hover:border-amber-500 text-amber-600 dark:text-amber-400":"hover:bg-emerald-500/10 hover:border-emerald-500 text-emerald-600 dark:text-emerald-400"),children:v},v))}),e.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground font-medium px-1",children:[e.jsx("span",{children:s.minLabel||"0 = Nada probable"}),e.jsx("span",{children:s.maxLabel||"10 = Totalmente probable"})]})]}),s.type==="rating"&&e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsx("div",{className:"flex items-center gap-1.5",children:Array.from({length:Number(s.maxStars)||5}).map((v,T)=>e.jsx("button",{type:"button",className:"p-1 text-amber-400 hover:scale-110 transition-transform",children:e.jsx($e,{className:"h-6 w-6 fill-amber-400 stroke-amber-500"})},T))}),s.showScoreText!==!1&&e.jsxs("p",{className:"text-xs text-muted-foreground font-medium",children:["5 de ",s.maxStars||5," estrellas"]})]}),s.type==="yes_no"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-1",children:[e.jsxs("button",{type:"button",className:"py-2 px-3 rounded-lg border bg-background hover:bg-emerald-500/10 hover:border-emerald-500 text-xs font-bold text-emerald-600 flex items-center justify-center gap-1.5 transition-colors",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:s.yesLabel||"SÃ"})]}),e.jsxs("button",{type:"button",className:"py-2 px-3 rounded-lg border bg-background hover:bg-rose-500/10 hover:border-rose-500 text-xs font-bold text-rose-600 flex items-center justify-center gap-1.5 transition-colors",children:[e.jsx(ke,{className:"h-3.5 w-3.5 rotate-180"}),e.jsx("span",{children:s.noLabel||"No"})]})]}),s.type==="button_group"&&e.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:(us=s.options)==null?void 0:us.map((v,T)=>e.jsx("button",{type:"button",className:"px-3 py-1.5 rounded-full border text-xs font-medium bg-background hover:border-primary hover:bg-primary/5 transition-all",children:v.label},T))}),s.type==="matrix"&&e.jsx("div",{className:"pt-1 overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/40",children:[e.jsx("th",{className:"py-2 px-2.5 font-semibold text-muted-foreground",children:"Aspecto"}),(Array.isArray(s.matrixColumns)?s.matrixColumns:s.columns||[]).map((v,T)=>e.jsx("th",{className:"py-2 px-2 text-center font-semibold text-muted-foreground whitespace-nowrap",children:v.label},v.id||T))]})}),e.jsx("tbody",{children:(Array.isArray(s.matrixRows)?s.matrixRows:Array.isArray(s.rows)?s.rows:[]).map((v,T)=>e.jsxs("tr",{className:"border-b border-border/40 hover:bg-muted/20",children:[e.jsx("td",{className:"py-2 px-2.5 font-medium text-foreground",children:v.label}),(Array.isArray(s.matrixColumns)?s.matrixColumns:s.columns||[]).map((Ws,ea)=>e.jsx("td",{className:"py-2 px-2 text-center",children:e.jsx("div",{className:"h-4 w-4 mx-auto rounded-full border border-muted-foreground/40 hover:border-primary flex items-center justify-center cursor-pointer"})},Ws.id||ea))]},v.id||T))})]})}),["file","camera","signature","multi_photo","video"].includes(s.type)&&e.jsxs("div",{className:"h-20 rounded-lg border-2 border-dashed border-border/80 flex flex-col items-center justify-center bg-muted/20 text-muted-foreground text-xs gap-1",children:[e.jsx(Ds,{type:s.type,className:"h-5 w-5 text-primary"}),e.jsxs("span",{children:["Captura o subida de ",s.label||s.type]})]}),s.helpText&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:s.helpText})]},s.id)})}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx(g,{type:"button",className:"w-full font-bold h-11 text-sm shadow-md",style:{backgroundColor:N,color:"#ffffff"},children:"Enviar Respuestas"}),e.jsx("p",{className:"text-[10px] text-center text-muted-foreground mt-2",children:Pe})]})]})]})})]})]}),ds&&e.jsx(Vt,{field:ds,onChange:Qs,onClose:()=>t(null)}),e.jsx(Mt,{onClick:h,hasSeenTour:re})]})};export{xr as default};
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.