1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8629,4300],{59994:function(e,a,t){t.r(a),t.d(a,{default:function(){return tY}});var s=t(57437),i=t(2265),n=t(61396),r=t.n(n),l=t(21458),o=t(32448),c=t(70581),d=t(71784),u=t(67024),m=t(54131),p=t(12899);function x(e){if(!Array.isArray(e))return[];let a=[];for(let t=0;t<e.length;t++){let s=e[t];if(!s||"object"!=typeof s)continue;let i="string"==typeof s.prompt?s.prompt.trim():"";if(!i)continue;let n="string"==typeof s.id&&s.id.trim()?s.id.trim():"q_".concat(t+1,"_").concat((0,m.randomBytes)(4).toString("hex")),r="number"==typeof s.sort_order?s.sort_order:t,l=!!s.killer,o="text";l||"boolean"===s.answer_type?o="boolean":"salary"===s.answer_type&&(o="salary");let c=null;l&&"boolean"===o&&(c="boolean"==typeof s.killer_expected?s.killer_expected:"true"===s.killer_expected||!0===s.killer_expected||"false"!==s.killer_expected&&!1!==s.killer_expected),a.push({id:n,prompt:i,sort_order:r,answer_type:o,killer:l,killer_expected:l?c:null})}return a.sort((e,a)=>e.sort_order-a.sort_order)}var h=t(14396),g=t(27992),b=t(14937),f=t(12290),v=t(94223),j=t(23611),y=t(70708),N=t(49598),_=t(13008),w=t(56224),k=t(53711),C=t(85790),S=t(83523),A=t(9224),E=t(25750),I=t(6141),z=t(82104),Z=t(29764),P=t(76020),T=t(41827);function q(e){let{selected:a,interactive:t,onClick:i,ariaLabel:n,children:r}=e,l=a?"ring-2 ring-blue-500 ring-offset-2 ring-offset-white":"";return t?(0,s.jsx)(N.Zb,{className:"".concat(l," transition-shadow"),children:(0,s.jsx)("button",{type:"button",onClick:i,"aria-label":n,"aria-pressed":a,className:"w-full text-left rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2",children:(0,s.jsx)(N.aY,{className:"p-6 hover:bg-gray-50/90 transition-colors rounded-lg cursor-pointer",children:r})})}):(0,s.jsx)(N.Zb,{className:l,children:(0,s.jsx)(N.aY,{className:"p-6",children:r})})}function L(e){var a,t,n,r,l,o;let{positionId:c,publicUrl:d,activeSummaryBucket:u=null,onSummaryBucketChange:m,portalClientCounts:p=null,originCounts:x=null,activeOriginFilters:h=[],onOriginFilterToggle:g}=e,[b,f]=(0,i.useState)(null),[v,y]=(0,i.useState)(!0),[L,O]=(0,i.useState)(!1),[R,D]=(0,i.useState)(!0);(0,i.useEffect)(()=>{F()},[c]);let F=async()=>{try{let e=await fetch("/api/positions/".concat(c,"/stats")),a=await e.json();a.success&&f(a.data)}catch(e){console.error("Error loading stats:",e)}finally{y(!1)}},M=async e=>{try{await navigator.clipboard.writeText(e),O(!0),setTimeout(()=>O(!1),2e3)}catch(e){console.error("Error copying to clipboard:",e)}};if(v)return(0,s.jsx)(N.Zb,{children:(0,s.jsx)(N.aY,{className:"p-6",children:(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto"}),(0,s.jsx)("p",{className:"mt-2 text-gray-600",children:"Cargando estad\xedsticas..."})]})})});if(!b)return(0,s.jsx)(N.Zb,{children:(0,s.jsx)(N.aY,{className:"p-6",children:(0,s.jsx)("p",{className:"text-gray-600",children:"No se pudieron cargar las estad\xedsticas"})})});let V=null!==(t=null!==(a=null==p?void 0:p.shared_with_client)&&void 0!==a?a:b.shared_with_client_applications)&&void 0!==t?t:0,B=null!==(r=null!==(n=null==p?void 0:p.preapproved_not_sent)&&void 0!==n?n:b.preapproved_not_sent_applications)&&void 0!==r?r:0,U=x&&x.length>0?x:Array.isArray(b.origin_stats)?b.origin_stats:[];return(0,s.jsxs)("div",{className:"space-y-6",children:[d?(0,s.jsx)(N.Zb,{children:(0,s.jsx)(N.Ol,{className:"pb-3",children:(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)(N.ll,{className:"text-base font-medium text-gray-800",children:"Enlace p\xfablico"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(j.z,{variant:"outline",size:"sm",onClick:()=>M(d),children:[L?(0,s.jsx)(_.Z,{className:"h-4 w-4"}):(0,s.jsx)(w.Z,{className:"h-4 w-4"}),L?"Copiado":"Copiar link"]}),(0,s.jsxs)(j.z,{variant:"outline",size:"sm",onClick:()=>window.open(d,"_blank"),children:[(0,s.jsx)(k.Z,{className:"h-4 w-4 mr-2"}),"Ver p\xe1gina p\xfablica"]})]})]})})}):null,(0,s.jsxs)(N.Zb,{className:"overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>D(!R),className:"w-full flex items-start justify-between gap-3 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!R,children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsxs)(N.ll,{className:"text-base font-semibold flex items-center gap-2",children:[(0,s.jsx)(C.Z,{className:"h-5 w-5 text-blue-600 shrink-0"}),"Resumen de postulaciones"]}),R?(0,s.jsxs)("p",{className:"text-xs text-gray-500",children:[b.total_applications," postulaci\xf3n",1===b.total_applications?""
1:"es",U.length>0?" \xb7 ".concat(U.slice(0,3).map(e=>"".concat(e.label," ").concat(e.count)).join(" \xb7 ")).concat(U.length>3?"â¦":""):""," ","\xb7 pulsa para ver detalle"]}):null]}),R?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"})]}),!R&&(0,s.jsxs)(N.aY,{className:"pt-0 pb-6 px-6 space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,s.jsx)(q,{interactive:!!m,selected:!1,onClick:()=>null==m?void 0:m(null),ariaLabel:"Mostrar todos los candidatos",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(E.Z,{className:"h-8 w-8 text-blue-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:b.total_applications}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Total postulaciones"})]})]})}),(0,s.jsx)(q,{interactive:!!m,selected:"pending_unseen"===u,onClick:()=>null==m?void 0:m("pending_unseen"===u?null:"pending_unseen"),ariaLabel:"Filtrar pendientes sin ver",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(I.Z,{className:"h-8 w-8 text-yellow-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:b.pending_applications}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Pendientes (sin ver)"})]})]})}),(0,s.jsx)(q,{interactive:!!m,selected:"accepted"===u,onClick:()=>null==m?void 0:m("accepted"===u?null:"accepted"),ariaLabel:"Filtrar aceptadas o pre-aprobadas",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(_.Z,{className:"h-8 w-8 text-green-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:b.accepted_applications}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Aceptadas / pre-aprob."})]})]})}),(0,s.jsx)(q,{interactive:!!m,selected:"rejected"===u,onClick:()=>null==m?void 0:m("rejected"===u?null:"rejected"),ariaLabel:"Filtrar descartadas por reclutador",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(z.Z,{className:"h-8 w-8 text-red-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:b.rejected_applications}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Descartadas"})]})]})})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,s.jsx)(q,{interactive:!!m,selected:"shared_with_client"===u,onClick:()=>null==m?void 0:m("shared_with_client"===u?null:"shared_with_client"),ariaLabel:"Filtrar enviados al portal del cliente",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(Z.Z,{className:"h-8 w-8 text-emerald-700 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:V}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Enviados al cliente"})]})]})}),(0,s.jsx)(q,{interactive:!!m,selected:"preapproved_not_sent"===u,onClick:()=>null==m?void 0:m("preapproved_not_sent"===u?null:"preapproved_not_sent"),ariaLabel:"Filtrar pre-aprobados a\xfan no enviados al portal",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(P.Z,{className:"h-8 w-8 text-indigo-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:B}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"A\xfan no enviados"})]})]})}),(0,s.jsx)(q,{interactive:!!m,selected:"client_approved"===u,onClick:()=>null==m?void 0:m("client_approved"===u?null:"client_approved"),ariaLabel:"Filtrar aprobadas por cliente",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(_.Z,{className:"h-8 w-8 text-emerald-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:null!==(l=b.client_approved_applications)&&void 0!==l?l:0}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Aprobadas por cliente"})]})]})}),(0,s.jsx)(q,{interactive:!!m,selected:"client_rejected"===u,onClick:()=>null==m?void 0:m("client_rejected"===u?null:"client_rejected"),ariaLabel:"Filtrar descartadas por cliente",children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(z.Z,{className:"h-8 w-8 text-rose-600 shrink-0"}),(0,s.jsxs)("div",{className:"ml-4 min-w-0",children:[(0,s.jsx)("p",{className:"text-2xl font-bold",children:null!==(o=b.client_rejected_applications)&&void 0!==o?o:0}),(0,s.jsx)("p",{className:"text-sm text-gray-600",children:"Descartadas por cliente"})]})]})})]}),U.length>0?(0,s.jsxs)("div",{className:"rounded-lg border border-slate-200 bg-slate-50/70 px-4 py-3",children:[(0,s.jsxs)("p",{className:"mb-2 flex items-center gap-1.5 text-sm font-medium text-slate-800",children:[(0,s.jsx)(T.Z,{className:"h-4 w-4 text-slate-500"}),"Or\xedgenes"]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:U.map(e=>{let a=h.includes(e.origin),t=!!g,i="inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-sm ".concat(a?"border-teal-300 bg-teal-50 text-teal-900 ring-1 ring-teal-600 ring-offset-1":"border-slate-200 bg-white text-slate-700"," ").concat(t?"cursor-pointer hover:bg-slate-50":""),n=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"font-semibold tabular-nums",children:e.count}),(0,s.jsx)("span",{className:"text-slate-600",children:e.label})]});return t?(0,s.jsx)("button",{type:"button",onClick:()=>null==g?void 0:g(e.origin),"aria-pressed":a,"aria-label":"Filtrar origen ".concat(e.label),className:"".concat(i," focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500"),children:n},e.origin):(0,s.jsx)("span",{className:i,children:n},e.origin)})})]}):null]})]})]})}var O=t(64647);let R=new Set(["accepted","shortlisted","offered"]),D=new Set(["accepted","shortlisted","offered","rejected"]);function F(e){if(!0===e||1===e)return!0;
1if(!1===e||0===e||null==e)return!1;if("string"==typeof e){let a=e.trim().toLowerCase();return"true"===a||"t"===a||"1"===a}return!!e}function M(e,a){let t=String(e.status||"").toLowerCase(),s=String(e.client_decision||"").toLowerCase(),i=0===Number(e.profile_view_count||0),n=F(e.pre_selected_for_client),r=F(e.shared_with_client);switch(a){case"pending_unseen":return i&&!D.has(t);case"accepted":return R.has(t);case"rejected":return"rejected"===t;case"client_approved":return"approved"===s;case"client_rejected":return"rejected"===s;case"shared_with_client":return r;case"preapproved_not_sent":return n&&!r;default:return!1}}var V=t(59481),B=t(35831),U=t(61465),X=t(20453),G=t(86264),J=t(58246),$=t(67972),Y=t(38782),W=t(98253),H=t(41310),K=t(1295);let Q=[{bit:1,label:"L"},{bit:2,label:"M"},{bit:3,label:"X"},{bit:4,label:"J"},{bit:5,label:"V"},{bit:6,label:"S"},{bit:0,label:"D"}];function ee(){return{weekdays:[1,2,3,4,5],start:"09:00",end:"11:00"}}function ea(e){let a=e.weekdays.slice().sort((e,a)=>e-a).map(e=>{var a,t;return null!==(t=null===(a=Q.find(a=>a.bit===e))||void 0===a?void 0:a.label)&&void 0!==t?t:String(e)}).join(", ");return"".concat(a," \xb7 ").concat(e.start,"â").concat(e.end)}function et(e){let a=e.split(/[\n,;]+/).map(e=>e.trim().toLowerCase()).filter(Boolean).filter(e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e));return Array.from(new Set(a))}function es(e){let{positionId:a,isEditable:t,onNotify:n,onScrollToCandidates:r}=e,[l,o]=(0,i.useState)(!0),[c,d]=(0,i.useState)(!1),[u,m]=(0,i.useState)(!1),[p,x]=(0,i.useState)(!1),[h,g]=(0,i.useState)("America/Mexico_City"),[b,f]=(0,i.useState)(30),[v,y]=(0,i.useState)(30),[_,C]=(0,i.useState)(21),[E,I]=(0,i.useState)(""),[z,Z]=(0,i.useState)([]),[P,T]=(0,i.useState)(!1),[q,L]=(0,i.useState)([ee()]),[O,R]=(0,i.useState)(null),[D,F]=(0,i.useState)(null),[M,V]=(0,i.useState)(!1),[es,ei]=(0,i.useState)(null),[en,er]=(0,i.useState)([]),[el,eo]=(0,i.useState)(!1),[ec,ed]=(0,i.useState)([]),[eu,em]=(0,i.useState)(""),[ep,ex]=(0,i.useState)(!0),eh=(0,i.useRef)(n);eh.current=n;let eg=(0,i.useCallback)(async()=>{var e,t,s,i,n,r,l,c;if(a){o(!0);try{let o=await fetch("/api/positions/".concat(a,"/interview-settings"),{credentials:"include"}),c=await o.json().catch(()=>({}));if(!o.ok||!c.success){null===(e=eh.current)||void 0===e||e.call(eh,"error","Error",c.error||"No se pudo cargar la agenda");return}let d=c.data;x(!!d.calendar_connected),R(null!==(t=d.booking_url)&&void 0!==t?t:null),F(null!==(s=d.client_availability_url)&&void 0!==s?s:null),ed(Array.isArray(d.pipeline_stages)?d.pipeline_stages:[]);let u=d.settings;if(u){g(u.timezone||"America/Mexico_City"),f(null!==(i=u.slot_duration_minutes)&&void 0!==i?i:30),y(null!==(n=u.slot_interval_minutes)&&void 0!==n?n:30),C(null!==(r=u.advance_booking_days)&&void 0!==r?r:21);let e=Array.isArray(u.client_attendee_emails)?u.client_attendee_emails:[];I(e.map(e=>String(e).trim().toLowerCase()).filter(Boolean).join(", ")),T(!!u.is_enabled),V(!!u.require_client_availability_first),ei(null!==(l=u.client_availability_submitted_at)&&void 0!==l?l:null),er(function(e){if(!Array.isArray(e))return[];let a=[];for(let t of e){if(!t||"object"!=typeof t)continue;let e=t.weekdays,s=t.start,i=t.end;if(!Array.isArray(e)||"string"!=typeof s||"string"!=typeof i)continue;let n=e.filter(e=>"number"==typeof e&&e>=0&&e<=6);0!==n.length&&a.push({weekdays:n,start:s,end:i})}return a}(u.client_weekly_rules)),eo(!!(u.invite_client_as_attendee||u.require_client_availability_first||e.length>0)),em("string"==typeof u.client_interview_stage_id?u.client_interview_stage_id:"");let a=Array.isArray(u.weekly_rules)&&u.weekly_rules.length?u.weekly_rules:[ee()];L(a)}else L([ee()]),I(""),V(!1),ei(null),er([]),eo(!1),em("");Z(Array.isArray(d.client_contacts)?d.client_contacts:[])}catch(e){null===(c=eh.current)||void 0===c||c.call(eh,"error","Error","Sin conexi\xf3n")}finally{o(!1)}}},[a]);(0,i.useEffect)(()=>{eg()},[eg]);let eb=(e,a)=>{L(t=>t.map((t,s)=>{if(s!==e)return t;let i=new Set(t.weekdays);return i.has(a)?i.delete(a):i.add(a),{...t,weekdays:Array.from(i).sort((e,a)=>e-a)}}))},ef=(e,a)=>{L(t=>t.map((t,s)=>s===e?{...t,...a}:t))},ev=async()=>
1{if(a){d(!0);try{var e,t,s,i,r;let l=await fetch("/api/positions/".concat(a,"/interview-settings"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({timezone:h,slot_duration_minutes:b,slot_interval_minutes:v,advance_booking_days:_,weekly_rules:q,client_participates_in_interviews:el,client_attendee_emails:el?et(E):[],is_enabled:P,require_client_availability_first:!!el&&M,client_interview_stage_id:eu||null})}),o=await l.json().catch(()=>({}));if(!l.ok||!o.success){null==n||n("error","No se guard\xf3",o.error||"Error");return}R(null!==(i=null===(e=o.data)||void 0===e?void 0:e.booking_url)&&void 0!==i?i:null),F(null!==(r=null===(t=o.data)||void 0===t?void 0:t.client_availability_url)&&void 0!==r?r:null),x(!!(null===(s=o.data)||void 0===s?void 0:s.calendar_connected)),null==n||n("success","Agenda guardada",P?"Ya puedes generar y compartir enlaces a candidatos.":"Configuraci\xf3n guardada.")}catch(e){null==n||n("error","Error","Sin conexi\xf3n")}finally{d(!1)}}},ej=async()=>{if(a&&D&&P){m(!0);try{let e=await fetch("/api/positions/".concat(a,"/send-client-availability-link"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({emails:et(E)})}),t=await e.json().catch(()=>({}));if(!e.ok||!t.success){null==n||n("error","No se envi\xf3 el correo","string"==typeof t.error?t.error:"Error");return}let s=t.failed;if(Array.isArray(s)&&s.length>0&&(!t.sent||0===t.sent)){null==n||n("error","Error al enviar",s.map(e=>"".concat(e.to,": ").concat(e.reason)).join(" \xb7 "));return}if(Array.isArray(s)&&s.length>0){null==n||n("error","Env\xedo parcial","Enviados: ".concat(t.sent,". Fallidos: ").concat(s.map(e=>e.to).join(", ")));return}null==n||n("success","string"==typeof t.message?t.message:"Correo enviado al cliente")}catch(e){null==n||n("error","Error","Sin conexi\xf3n")}finally{m(!1)}}},ey=(0,i.useMemo)(()=>et(E),[E]),eN=new Set(ey),e_=e=>{let a=e.trim().toLowerCase();a&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)&&I(e=>{let t=et(e);return t.includes(a)?t.join(", "):[...t,a].join(", ")})};return l?(0,s.jsx)(N.Zb,{children:(0,s.jsx)(N.aY,{className:"py-8 flex justify-center",children:(0,s.jsx)(G.Z,{className:"w-6 h-6 animate-spin text-gray-400"})})}):t?(0,s.jsxs)(N.Zb,{className:"overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>ex(!ep),className:"w-full flex items-start justify-between gap-3 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!ep,children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsxs)(N.ll,{className:"flex items-center gap-2 text-base",children:[(0,s.jsx)(J.Z,{className:"w-5 h-5 text-violet-600 shrink-0"}),"Agenda de entrevistas"]}),ep?(0,s.jsxs)("p",{className:"text-xs text-gray-500",children:[P?"Activa":"Inactiva",p?" \xb7 Google conectado":" \xb7 sin Google",el?" \xb7 con cliente":""]}):null]}),ep?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"})]}),!ep&&(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)(N.aY,{className:"space-y-5 pt-0 pb-6",children:[!p&&(0,s.jsxs)("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Para que los candidatos reserven huecos en tu Google Calendar, con\xe9ctalo en"," ",(0,s.jsx)("a",{href:"/dashboard/profile",className:"underline font-medium",children:"Perfil â Agenda"}),"."]}),(0,s.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,s.jsxs)("div",{className:"rounded-xl border border-blue-200/90 bg-blue-50/50 p-4 space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold text-blue-950 flex items-center gap-2",children:[(0,s.jsx)($.Z,{className:"w-4 h-4 shrink-0","aria-hidden":!0}),"Tu disponibilidad (t\xfa y candidatos)"]}),(0,s.jsx)("p",{className:"text-xs text-blue-900/85 mt-1 leading-snug",children:"Ventanas en las que puedes coordinar entrevistas. Los candidatos eligen dentro de estos horarios cuando usan tu enlace de reserva."})]}),q.length>0&&(0,s.jsxs)("div",{className:"rounded-md border border-blue-200 bg-white/95 p-3 space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-blue-950",children:"Resumen"}),(0,s.jsx)("ul",{className:"text-sm text-blue-950 space-y-1 list-disc list-inside leading-snug",children:q.map((e,a)=>(0,s.jsx)("li",{children:ea(e)},a))})]}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{children:"Zona horaria (IANA)"}),(0,s.jsx)(B.I,{value:h,onChange:e=>g(e.target.value),placeholder:"America/Mexico_City"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{children:"D\xedas de anticipaci\xf3n m\xe1x."}
1),(0,s.jsx)(B.I,{type:"number",min:1,max:90,value:_,onChange:e=>C(Number(e.target.value)||21)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{children:"Duraci\xf3n entrevista (min)"}),(0,s.jsx)(B.I,{type:"number",min:15,max:180,value:b,onChange:e=>f(Number(e.target.value)||30)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{children:"Intervalo entre huecos (min)"}),(0,s.jsx)(B.I,{type:"number",min:15,max:120,value:v,onChange:e=>y(Number(e.target.value)||30)})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(U._,{children:"Horarios semanales"}),q.map((e,a)=>(0,s.jsxs)("div",{className:"rounded-lg border border-blue-100 bg-white/80 p-3 space-y-2",children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:Q.map(t=>{let{bit:i,label:n}=t;return(0,s.jsx)("button",{type:"button",onClick:()=>eb(a,i),className:"w-8 h-8 rounded text-xs font-medium border ".concat(e.weekdays.includes(i)?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-500 border-gray-200"),children:n},i)})}),(0,s.jsxs)("div",{className:"flex gap-2 items-center flex-wrap",children:[(0,s.jsx)(B.I,{type:"time",className:"w-36",value:e.start,onChange:e=>ef(a,{start:e.target.value})}),(0,s.jsx)("span",{className:"text-gray-400",children:"â"}),(0,s.jsx)(B.I,{type:"time",className:"w-36",value:e.end,onChange:e=>ef(a,{end:e.target.value})}),q.length>1&&(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",onClick:()=>L(e=>e.filter((e,t)=>t!==a)),children:"Quitar"})]})]},a)),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",onClick:()=>L(e=>[...e,ee()]),children:"A\xf1adir ventana"})]})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-violet-200/90 bg-violet-50/40 p-4 space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold text-violet-950 flex items-center gap-2",children:[(0,s.jsx)(Y.Z,{className:"w-4 h-4 shrink-0","aria-hidden":!0}),"Enlaces de reserva (dos tipos)"]}),(0,s.jsx)("p",{className:"text-xs text-violet-900/85 mt-1 leading-snug",children:"Cada candidato recibe un enlace personal. Hay dos flujos distintos; no uses el mismo enlace para ambos."})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-violet-100 bg-white/70 px-3 py-2",children:[(0,s.jsx)("div",{children:(0,s.jsx)(U._,{children:"Activar reserva de entrevistas"})}),(0,s.jsx)(X.r,{checked:P,onCheckedChange:T,disabled:!p})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-violet-100 bg-white/70 px-3 py-2 space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"interview-stage-select",children:"Etapa del funnel al pedir entrevista"}),(0,s.jsx)("p",{className:"text-xs text-violet-900/80 leading-snug",children:"Cuando el cliente solicita entrevista desde el informe, el candidato se mueve a esta etapa del pipeline."}),(0,s.jsxs)("select",{id:"interview-stage-select",value:eu,onChange:e=>em(e.target.value),className:"w-full rounded-md border border-violet-200 bg-white px-2.5 py-2 text-sm text-gray-900 focus:outline-none focus:ring-2 focus:ring-violet-300",children:[(0,s.jsx)("option",{value:"",children:"Autom\xe1tica (detectar âEntrevistaâ)"}),ec.map(e=>(0,s.jsx)("option",{value:e.id,children:e.label},e.id))]})]}),O&&P&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"rounded-md border border-blue-200 bg-blue-50/90 p-3 space-y-2",children:[(0,s.jsxs)("p",{className:"text-sm font-semibold text-blue-950 flex items-center gap-2",children:[(0,s.jsx)($.Z,{className:"w-4 h-4 shrink-0","aria-hidden":!0}),"1. Entrevista con el reclutador"]}),(0,s.jsxs)("p",{className:"text-xs text-blue-900/90 leading-snug",children:["Horarios seg\xfan ",(0,s.jsx)("strong",{children:"tu disponibilidad"})," arriba. Env\xedalo desde la tabla de candidatos (icono calendario â \xabEntrevista contigo\xbb) o por email masivo."]}),(0,s.jsxs)("p",{className:"text-[11px] font-mono text-blue-800/80 break-all bg-white/80 border border-blue-100 rounded px-2 py-1.5",children:[O,"?application=â¦&cal=recruiter"]})]}),(0,s.jsxs)("div",{className:"rounded-md border border-violet-200 bg-vi
1olet-50/90 p-3 space-y-2",children:[(0,s.jsxs)("p",{className:"text-sm font-semibold text-violet-950 flex items-center gap-2",children:[(0,s.jsx)(W.Z,{className:"w-4 h-4 shrink-0","aria-hidden":!0}),"2. Entrevista con el cliente"]}),(0,s.jsxs)("p",{className:"text-xs text-violet-900/90 leading-snug",children:["Solo huecos dentro de la ",(0,s.jsx)("strong",{children:"franja que el cliente indic\xf3"})," en el informe (cruzada con tu agenda). Comp\xe1rtelo desde la ficha del candidato o calendario â \xabEntrevista con el cliente\xbb."]}),(0,s.jsxs)("p",{className:"text-[11px] font-mono text-violet-800/80 break-all bg-white/80 border border-violet-100 rounded px-2 py-1.5",children:[O,"?application=â¦&cal=client"]})]}),(0,s.jsxs)("div",{className:"rounded-md border border-gray-200 bg-white/90 p-3 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[(0,s.jsx)(H.Z,{className:"w-4 h-4"}),"URL base de la vacante"]}),(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,s.jsx)(B.I,{readOnly:!0,className:"font-mono text-xs flex-1 min-w-0",value:O}),(0,s.jsxs)(j.z,{type:"button",variant:"secondary",size:"sm",onClick:e=>{null==e||e.preventDefault(),null==e||e.stopPropagation(),O&&(navigator.clipboard.writeText(O),null==n||n("success","Enlace copiado"))},children:[(0,s.jsx)(w.Z,{className:"w-4 h-4 mr-1"}),"Copiar base"]}),(0,s.jsx)(j.z,{variant:"outline",size:"sm",asChild:!0,children:(0,s.jsxs)("a",{href:O,target:"_blank",rel:"noopener noreferrer",children:[(0,s.jsx)(k.Z,{className:"w-4 h-4 mr-1"}),"Abrir"]})})]})]})]}),r&&P&&O&&(0,s.jsxs)("div",{className:"rounded-lg border border-emerald-200 bg-emerald-50/90 p-3 space-y-2",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-emerald-950",children:"Enviar enlaces a candidatos"}),(0,s.jsx)("p",{className:"text-xs text-emerald-900/90",children:"En la tabla elige el tipo de entrevista. Con franja del cliente, usa la ficha del candidato para WhatsApp / correo."}),(0,s.jsx)(j.z,{type:"button",variant:"default",size:"sm",className:"bg-emerald-700 hover:bg-emerald-800",onClick:r,children:"Ir a candidatos"})]})]}),(0,s.jsxs)("div",{className:"rounded-xl border border-amber-200/90 bg-amber-50/50 p-4 space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold text-amber-950 flex items-center gap-2",children:[(0,s.jsx)(W.Z,{className:"w-4 h-4 shrink-0","aria-hidden":!0}),"Opcional: cliente en la videollamada"]}),(0,s.jsx)("p",{className:"text-xs text-amber-900/85 mt-1 leading-snug",children:"Si el cliente participar\xe1 en la reuni\xf3n, a\xf1ade su correo para invitarlo al evento de Google. Las franjas por candidato siguen viniendo del informe; esto no sustituye ese paso."})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-amber-100 bg-white/70 px-3 py-2",children:[(0,s.jsx)("div",{children:(0,s.jsx)(U._,{children:"El cliente entrevista al candidato"})}),(0,s.jsx)(X.r,{checked:el,onCheckedChange:e=>{eo(e),e||(V(!1),I(""))}})]}),el&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{children:"Correos del cliente"}),(0,s.jsx)("p",{className:"text-xs text-gray-600",children:"Para invitarlo al evento en tu calendario."})]}),z.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:z.filter(e=>!!e.email).map(e=>{let a=String(e.email).trim().toLowerCase(),t=eN.has(a);return(0,s.jsx)("button",{type:"button",onClick:()=>e_(a),className:"rounded-full border px-2 py-1 text-xs ".concat(t?"border-amber-400 bg-amber-100 text-amber-900":"border-gray-200 bg-white text-gray-700 hover:bg-gray-50"),title:e.full_name||a,children:e.full_name?"".concat(e.full_name," \xb7 ").concat(a):a},e.id)})}),(0,s.jsx)(B.I,{value:E,onChange:e=>I(e.target.value),onBlur:()=>{I(e=>{let a=et(e);return a.join(", ")})},placeholder:"[email protected], [email protected]"})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-amber-100 bg-white/70 p-3 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-amber-950",children:"Exigir disponibilidad semanal antes de reservar"}),(0,s.jsx)("p",{className:"text-xs text-amber-900/80 mt-1 leading-snug",children:"Flujo alternativo al informe: el cliente rellena un formulario semanal y el candidato solo agenda despu\xe9s. Normalmente basta con las franjas por candidato en el informe."})]}),(0,s.jsx)(X.r,{checked:M,onCheckedChange:V,disabled:!p})]}),es&&(0,s.jsxs)("p",{className:"text-xs text-emerald-800 bg-emerald-50 border border-emerald-100 rounded px-2 py-1.5",children:["Cliente envi\xf3 disponibilidad el"," ",new Date(es).toLocaleStr
1ing("es-MX",{dateStyle:"medium",timeStyle:"short"})]}),en.length>0&&(0,s.jsxs)("div",{className:"rounded-md border border-amber-200 bg-white/95 p-3 space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-amber-950",children:"Ventana que indic\xf3 el cliente"}),(0,s.jsx)("ul",{className:"text-sm text-amber-950 space-y-1 list-disc list-inside leading-snug",children:en.map((e,a)=>(0,s.jsx)("li",{children:ea(e)},a))})]}),M&&!es&&P&&(0,s.jsx)("p",{className:"text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded px-2 py-1.5",children:"Esperando franjas del cliente."}),D&&P&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-amber-950",children:"Enlace de disponibilidad (cliente)"}),(0,s.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,s.jsx)(B.I,{readOnly:!0,className:"font-mono text-xs flex-1 min-w-0 bg-white",value:D}),(0,s.jsxs)(j.z,{type:"button",variant:"secondary",size:"sm",onClick:e=>{null==e||e.preventDefault(),null==e||e.stopPropagation(),D&&(navigator.clipboard.writeText(D),null==n||n("success","Enlace para cliente copiado"))},children:[(0,s.jsx)(w.Z,{className:"w-4 h-4 mr-1"}),"Copiar"]}),(0,s.jsxs)(j.z,{type:"button",variant:"default",size:"sm",className:"bg-amber-700 hover:bg-amber-800",disabled:u,onClick:()=>void ej(),children:[u?(0,s.jsx)(G.Z,{className:"w-4 h-4 animate-spin mr-1"}):(0,s.jsx)(K.Z,{className:"w-4 h-4 mr-1"}),"Enviar enlace por correo"]})]})]}),P&&!D&&(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Guarda la agenda una vez para generar el enlace al cliente."})]})]})]})]}),(0,s.jsxs)(j.z,{type:"button",onClick:ev,disabled:c,children:[c?(0,s.jsx)(G.Z,{className:"w-4 h-4 animate-spin mr-2"}):null,"Guardar agenda"]})]})})]}):(0,s.jsxs)(N.Zb,{className:"overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>ex(!ep),className:"w-full flex items-start justify-between gap-3 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!ep,children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsxs)(N.ll,{className:"flex items-center gap-2 text-base",children:[(0,s.jsx)(J.Z,{className:"w-5 h-5 text-violet-600 shrink-0"}),"Agenda de entrevistas"]}),ep?(0,s.jsxs)("p",{className:"text-xs text-gray-500",children:[P?"Activa":"Inactiva",p?" \xb7 Google conectado":" \xb7 sin Google",el?" \xb7 con cliente":""]}):null]}),ep?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0 mt-0.5"})]}),!ep&&(0,s.jsxs)(N.aY,{className:"space-y-3 pt-0 pb-6",children:[(0,s.jsx)("div",{className:"text-sm text-gray-600 space-y-1",children:(0,s.jsxs)("p",{children:[P?"Agenda activa":"Agenda inactiva"," \xb7"," ",p?"Google conectado":"Sin Google",el?" \xb7 con cliente":""]})}),(0,s.jsxs)("div",{className:"text-sm text-gray-600",children:["Zona horaria: ",(0,s.jsx)("span",{className:"font-medium text-gray-800",children:h})," \xb7 Duraci\xf3n: ",b," min \xb7 Intervalo: ",v," min"]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(U._,{children:"Ventanas configuradas"}),0===q.length?(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"No hay ventanas definidas."}):(0,s.jsx)("div",{className:"space-y-1",children:q.map((e,a)=>(0,s.jsxs)("p",{className:"text-sm text-gray-700",children:[(e.weekdays||[]).map(e=>{var a;return(null===(a=Q.find(a=>a.bit===e))||void 0===a?void 0:a.label)||String(e)}).join(", ")," ","\xb7 ",e.start," - ",e.end]},a))})]}),ey.length>0&&(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(U._,{children:"Correos invitados del cliente"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1.5",children:ey.map(e=>(0,s.jsx)("span",{className:"inline-flex items-center rounded bg-violet-100 px-2 py-0.5 text-xs text-violet-800",children:e},e))})]})]})]})}var ei=t(43149),en=t(54887),er=t(39684),el=t(89859),eo=t(41082),ec=t(94041),ed=t(55625),eu=t(6306),em=t(82800),ep=t(25646),ex=t(45487),eh=t(21654),eg=t(55340),eb=t(54972),ef=t(3021),ev=t(55646),ej=t(99670),ey=t(28203),eN=t(6907);let e_=new Set(["public_portal","talent_pool_public","recruiterflow"]);function ew(e){var a,t;let s=String(e.application_source||""),i=e_.has(s)?null!==(a=e.applied_at)&&void 0!==a?a:e.created_at:null!==(t=e.created_at)&&void 0!==t?t:e.applied_at,n=i?new Date(String(i)).getTime():0;return Number.isNaN(n)?0:n}function ek(e,a){let t="number"==typeof e.match_percent?e.match_percent:-1,s="number"==typeof a.match_percent?a.match_percent:-1;return s!==t?s-t:ew(a)-ew(e)}function eC(e){let a=String(null!=e?e:"");return a.startsWith("app:")&&a.slice(4)||null}let eS="relative inline-flex !h-[30px] !w-full items-center justify-center rounded-[7px] border-0 bg-transparent text-[#6b7c93] hover:bg-white hover:text-[#0a2540] hover:shadow-[0_1px_2px_rgba(15,34,67,0.08)] disabled:pointer-events-none disabled:opacity-[0.28] disabled:hover:bg-transparent disabled:hover:shadow-none";function eA(e){let{label:a,children:t}=e;return(0,s.jsxs)(ep.u,{children:[(0,s.jsx)(ep.aJ,{asChild:!0,children:(0,s.jsx)("span",{className:"inline-flex min-w-0 flex-1 items-center justify-center",children:t})}),(0,s.jsx)(ep._v,{side:"top",className:"z-[140] max-w-[240px] text-center text-xs leading-snug",children:a})]})}function eE(e){return"discarded"===e?"border-red-200 bg-red-50/40":"hired"===e?"border-emerald-200 bg-emerald-50/35":"border-gray-200 bg-gray-50/80"}
1function eI(e){let{stage:a,count:t}=e;return(0,s.jsx)("div",{className:"min-w-[272px] max-w-[272px] flex-shrink-0 rounded-t-xl border-2 border-b-0 shadow-sm ".concat(eE(a.id)),children:(0,s.jsxs)("div",{className:"rounded-t-[10px] border-b border-black/5 bg-white/90 px-3 py-2 backdrop-blur-sm",children:[(0,s.jsx)("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-gray-600 leading-tight",children:a.label}),(0,s.jsx)("p",{className:"text-xs text-gray-400",children:t})]})})}function ez(e){var a;let{stage:t,children:i}=e,{setNodeRef:n,isOver:r}=(0,er.Zj)({id:(a=t.id,"col:".concat(a))});return(0,s.jsx)("div",{ref:n,className:"flex min-h-[min(70vh,520px)] min-w-[272px] max-w-[272px] flex-shrink-0 flex-col rounded-b-xl border-2 border-t-0 shadow-sm transition-colors ".concat(eE(t.id)," ").concat(r?"ring-2 ring-blue-400 ring-offset-2":""),children:(0,s.jsx)("div",{className:"flex flex-1 flex-col gap-2 overflow-y-auto overflow-x-hidden p-2",children:i})})}function eZ(e){var a,t,i,n;let{app:l,disabled:o,cardSlots:c}=e,d=String(null!==(t=l.id)&&void 0!==t?t:""),{attributes:u,listeners:m,setNodeRef:p,isDragging:x}=(0,er.O1)({id:"app:".concat(d),disabled:o,data:{applicationId:d}}),h=String(l.candidate_name||"Sin nombre"),g=!!l.screening_pending||"pending"===l.screening_status,b="completed"===l.screening_status,{dateStr:v}=(0,eN.eb)(l),y="number"==typeof l.match_percent?l.match_percent:null,N=function(e){let a=String(e.client_decision||"").toLowerCase();return"approved"===a||"rejected"===a||"hired"===a?a:"pending"}(l),w="hired"===N,C=("number"==typeof l.profile_view_count?l.profile_view_count:0)>0,S=(0,eo.YM)(null!==(i=l.client_interview_feedbacks)&&void 0!==i?i:l.client_interview_feedback),A=null!==(n=S[0])&&void 0!==n?n:null,E=!0===l.has_interview||S.length>0,I=c.reanalyzingIds.has(d)||c.reExtractingIds.has(d),z=(0,em.eo)({match_calculating_at:l.match_calculating_at,match_completeness:l.match_completeness,match_percent:y,match_reason:l.match_reason,match_model:l.match_model,ai_profile:l.ai_profile,screening_status:l.screening_status,cv_url:l.cv_url},{forceBusy:I}),P="h-[15px] w-[15px]";return(0,s.jsxs)("div",{ref:p,className:"rounded-xl border border-[#e3e8ee] bg-white px-3 pb-2.5 pt-3 shadow-[0_1px_2px_rgba(15,34,67,0.04)] transition-shadow ".concat(x?"opacity-30":"hover:border-[#d6dee8] hover:shadow-[0_4px_12px_rgba(15,34,67,0.06)]"),children:[(0,s.jsxs)("div",{className:"grid grid-cols-[14px_minmax(0,1fr)_44px] items-start gap-2.5",children:[(0,s.jsx)("button",{type:"button",className:"mt-1.5 flex h-4 w-3.5 cursor-grab touch-none items-center justify-center text-[#c9d3de] hover:text-gray-500 active:cursor-grabbing",...m,...u,disabled:o,"aria-label":"Arrastrar para cambiar etapa",children:(0,s.jsx)(eh.Z,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)(r(),{href:"/dashboard/candidates/".concat(d),className:"line-clamp-2 text-[13.5px] font-semibold leading-snug tracking-tight text-[#0a2540] hover:text-[#635bff]",target:"_blank",rel:"noopener noreferrer",children:h}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-[#6b7c93]",children:[(0,s.jsx)("span",{className:"inline-block h-1.5 w-1.5 rounded-full ".concat(C?"bg-[#7ab8ff]":"bg-[#d6dee8]"),title:C?"Perfil visto":"Perfil no visto"}),(0,s.jsx)("span",{children:v}),(0,s.jsx)(f.o,{application:l,variant:"meta",showCampaign:!1})]})]}),z?(0,s.jsx)(eu.Ag,{size:"sm"}):(0,em.MS)({match_percent:y,match_completeness:l.match_completeness,match_reason:l.match_reason})?(0,s.jsx)("div",{title:"El % se edita en la ficha del candidato",children:(0,s.jsx)(eu.rB,{percent:y,size:"sm"})}):(0,s.jsx)("span",{})]}),(0,s.jsxs)("div",{className:"ml-6",children:[(0,s.jsxs)("div",{className:"mt-2.5 flex flex-wrap items-center gap-1",children:[E?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#f5f3ff] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#6d28d9]",title:"Tiene al menos una entrevista ya finalizada (video, tel\xe9fono, presencial, cliente o IA)",children:"Entrevistado"}):null,g?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#fff7ed] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#c2410c]",children:"Evaluaci\xf3n pendiente"}):null,b?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#f0fdf9] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#0d9488]",children:"Evaluaci\xf3n lista"}):null,(0,s.jsx)(ed.i,{app:l,onlyPending:!0})]}),w||"approved"===N?(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[w?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#fffbeb] px-[7
1px] py-1 text-[10.5px] font-medium leading-none text-[#92400e]",children:"Contratado"}):null,"approved"===N?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#ecfdf5] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#047857]",children:"Elegido por cliente"}):null]}):null,S.length>1?(0,s.jsxs)("p",{className:"mt-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-[10px] leading-snug text-blue-900",children:[S.length," entrevistas valoradas"]}):null,A?(0,s.jsx)("p",{className:"mt-2 flex items-center gap-1 rounded-md border px-2 py-1 text-[10px] leading-snug ".concat("reject"===A.outcome?"border-red-200 bg-red-50 text-red-900":"border-blue-200 bg-blue-50 text-blue-900"),children:"proceed"===A.outcome&&A.rating?(0,s.jsxs)(s.Fragment,{children:[Array.from({length:A.rating}).map((e,a)=>(0,s.jsx)(eg.Z,{className:"h-3 w-3 fill-amber-400 text-amber-400"},a)),(0,s.jsx)("span",{children:"post-entrevista"})]}):(0,s.jsx)("span",{children:"Descartado tras entrevista"})}):null,(0,s.jsx)(ec.q,{flags:l.match_flags,variant:"line",className:"mt-2"}),(0,s.jsxs)("div",{className:"mt-3 flex items-center gap-0.5 rounded-[10px] border border-[#edf1f5] bg-[#f7f9fc] p-[3px]",children:[l.cv_url?(0,s.jsx)(eA,{label:"Abrir CV",children:(0,s.jsx)("a",{href:String(l.cv_url),target:"_blank",rel:"noopener noreferrer",className:eS,"aria-label":"Abrir CV",children:(0,s.jsx)(k.Z,{className:P})})}):(0,s.jsx)(eA,{label:"Sin CV",children:(0,s.jsx)("button",{type:"button",className:eS,disabled:!0,"aria-label":"Sin CV",children:(0,s.jsx)(k.Z,{className:P})})}),(0,s.jsx)(eA,{label:I?"Re-analizandoâ¦":"Re-analizar",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:eS,disabled:o||I,onClick:()=>c.onReanalyze(d),"aria-label":"Re-analizar",children:I?(0,s.jsx)(G.Z,{className:"".concat(P," animate-spin")}):(0,s.jsx)(eb.Z,{className:P})})}),(0,s.jsx)(eA,{label:"Compartir informe",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:eS,disabled:o,onClick:()=>c.onShareReport(d),"aria-label":"Compartir informe",children:(0,s.jsx)(Z.Z,{className:P})})}),(0,s.jsx)(eA,{label:"Recordatorios y seguimientos",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:eS,disabled:o,onClick:()=>c.onOpenReminders(d),"aria-label":"Recordatorios y seguimientos",children:(0,s.jsx)(ef.Z,{className:P})})}),(0,s.jsx)(eA,{label:b?"Ya respondi\xf3 las preguntas":"Enviar preguntas de la posici\xf3n",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:eS,disabled:o||!(g&&!b),onClick:()=>c.onResendScreening(d),"aria-label":b?"Ya respondi\xf3 las preguntas":"Evaluaci\xf3n",children:(0,s.jsx)(ev.Z,{className:P})})}),(0,s.jsx)(eA,{label:"Ver respuestas",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:eS,disabled:o||!b,onClick:()=>c.onViewScreeningAnswers(d),"aria-label":"Ver respuestas",children:(0,s.jsx)(ej.Z,{className:P})})}),(0,s.jsxs)(ex.h_,{children:[(0,s.jsxs)(ep.u,{children:[(0,s.jsx)(ep.aJ,{asChild:!0,children:(0,s.jsx)("span",{className:"inline-flex min-w-0 flex-1 items-center justify-center",children:(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:eS,disabled:o||c.sendingInterviewEmails,"aria-label":"Entrevista",children:(0,s.jsx)(ey.Z,{className:P})})})})}),(0,s.jsx)(ep._v,{side:"top",className:"z-[140] max-w-[260px] text-center text-xs leading-snug",children:"Entrevista"})]}),(0,s.jsxs)(ex.AW,{align:"end",className:"z-[130] w-[min(100vw-2rem,18rem)]",children:[(0,s.jsx)(ex.Xi,{onClick:()=>c.sendInterviewLinks([d],"recruiter"),className:"text-sm",children:"Entrevista contigo (reclutador)"}),(0,s.jsx)(ex.Xi,{onClick:()=>c.inviteCamila([d]),className:"text-sm",children:"Entrevista con Camila"}),(0,s.jsx)(ex.Xi,{onClick:()=>c.sendInterviewLinks([d],"client"),disabled:!(0,ei.KK)(l,!!(null===(a=c.interviewAvailabilityMeta)||void 0===a?void 0:a.clientAvailabilitySubmitted)),className:"text-sm",children:"Entrevista con el cliente"}),"pending"===l.cv_collection_status?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),l.cv_reminders_enabled?(0,s.jsx)(ex.Xi,{className:"text-sm",onClick:()=>c.onToggleCvReminders(d,"stop"),children:"Detener recordatorios de CV"}):(0,s.jsx)(ex.Xi,{className:"text-sm",onClick:()=>c.onToggleCvReminders(d,"resume"),children:"Reactivar recordatorios de CV"})]}):null,g&&!b?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),!1===l.screening_reminders_enabled?(0,s.jsx)(ex.Xi,{className:"text-sm",onClick:()=>c.onToggleScreeningReminders(d,"resume"),children:"Reactivar recordatorios de preguntas"}):(0,s.jsx)(ex.Xi,{className:"text-sm",onClick:()=>c.onToggleScreeningReminders(d,"stop"),children:"Detener recordatorios de preguntas"})]}):null]})]}),(0,s.jsx)(eA,{label:l.pre_selected_for_client?"Quitar pre-aprobaci\xf3n para el cliente":"Pre-aprobar para el cliente",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:"".concat(eS," ").concat(l.pre_selected_for_client?"bg-white text-[#0a2540] shadow-[0_1px_2px_rgba(15,34,67,0.08)]":""),disabled:o,onClick:()=>c.togglePreSelectedForClient(d,!!l.pre_selected_for_client),"aria-label":l.pre_selected_for_client?"Quitar preselecci\xf3n":"Preseleccionar",children:(0,s.jsx)(_.Z,{className:P})})})]})]})]})}function eP(e){let{pipeline:a,applications:t,disabled:n,onMoveApplication:r,cardSlots:l,hideEmptyColumns:o}=e,c=(0,er.Dy)((0,er.VT)(er.we,{activationConstraint:{distance:6}})),[d,u]=(0,i.useState)(null),m=(0,i.useMemo)(()=>{let e=new Map;
1for(let t of a)e.set(t.id,[]);for(let i of t){var s;let t=String(null!==(s=i.id)&&void 0!==s?s:"");if(!t)continue;let n=(0,el.H5)(i.recruitment_stage,a);e.has(n)||e.set(n,[]),e.get(n).push(i)}for(let[,a]of Array.from(e.entries()))a.sort(ek);return e},[t,a]),p=(0,i.useMemo)(()=>{if(!o)return a;let e=a.filter(e=>{var a;return(null!==(a=m.get(e.id))&&void 0!==a?a:[]).length>0});return e.length>0?e:a},[o,a,m]),x=(0,i.useMemo)(()=>{if(!d)return null;let e=t.find(e=>String(e.id)===d);return null!=e?e:null},[d,t]);async function h(e){var s;let i=eC(e.active.id),n=function(e){let a=String(null!=e?e:"");return a.startsWith("col:")&&a.slice(4)||null}(null===(s=e.over)||void 0===s?void 0:s.id);if(u(null),!i||!n)return;let l=t.find(e=>String(e.id)===i);if(!l)return;let o=(0,el.H5)(l.recruitment_stage,a);o!==n&&await r(i,n)}let g=(0,i.useRef)(null),b=(0,i.useRef)(null),f=e=>a=>{let t=a.currentTarget,s="header"===e?g.current:b.current;s&&s.scrollLeft!==t.scrollLeft&&(s.scrollLeft=t.scrollLeft)};return(0,s.jsx)(ep.pn,{delayDuration:300,children:(0,s.jsxs)(er.LB,{sensors:c,collisionDetection:er.ey,onDragStart:function(e){let a=eC(e.active.id);u(a)},onDragEnd:e=>void h(e),children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"sticky top-0 z-10 -mx-6 bg-white/95 px-6 shadow-sm backdrop-blur-sm supports-[backdrop-filter]:bg-white/90",children:(0,s.jsx)("div",{ref:b,onScroll:f("header"),className:"flex gap-3 overflow-x-auto pb-0 pt-1 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",children:p.map(e=>{var a;let t=null!==(a=m.get(e.id))&&void 0!==a?a:[];return(0,s.jsx)(eI,{stage:e,count:t.length},e.id)})})}),(0,s.jsx)("div",{ref:g,onScroll:f("body"),className:"-mx-6 flex gap-3 overflow-x-auto px-6 pb-2",children:p.map(e=>{var a;let t=null!==(a=m.get(e.id))&&void 0!==a?a:[];return(0,s.jsx)(ez,{stage:e,count:t.length,children:t.map(e=>(0,s.jsx)(eZ,{app:e,disabled:n,cardSlots:l},String(e.id)))},e.id)})})]}),"undefined"!=typeof document?(0,en.createPortal)((0,s.jsx)(er.y9,{dropAnimation:null,zIndex:200,children:x?(0,s.jsxs)("div",{className:"w-[248px] cursor-grabbing rounded-lg border-2 border-blue-300 bg-white p-2 shadow-xl opacity-95",children:[(0,s.jsx)("p",{className:"truncate text-sm font-semibold text-gray-900",children:String(x.candidate_name||"")}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Moviendoâ¦"})]}):null}),document.body):null]})})}var eT=t(38339),eq=t(74522),eL=t(77216),eO=t(17619),eR=t(39130),eD=t(1351),eF=t(62442),eM=t(81628),eV=t(57419),eB=t(77370);let eU=new Set(["public_portal","talent_pool_public","recruiterflow"]),eX=[{id:"today",label:"Hoy"},{id:"yesterday",label:"Ayer"},{id:"week",label:"Esta semana"},{id:"month",label:"Este mes"},{id:"older30",label:"+30 d\xedas"}],eG=["interview","underqualified","strongMatch","unseen","preselected","screeningPending","cvPending"];function eJ(e,a){switch(a){case"interview":return!0===e.has_interview;case"underqualified":{let a=(0,eB.V6)(e.match_flags);if(a.includes("underqualified"))return!0;return"number"==typeof e.match_percent&&e.match_percent<50}case"strongMatch":return"number"==typeof e.match_percent&&e.match_percent>=70;case"unseen":return 0===Number(e.profile_view_count||0)&&!(0,eV.E)(e);case"preselected":return!0===e.pre_selected_for_client;case"screeningPending":return!0===e.screening_pending||"pending"===e.screening_status;case"cvPending":return"pending"===e.cv_collection_status;default:return!1}}function e$(e){return eG.some(a=>e[a])}let eY=[{key:"interview",label:"Con entrevista",title:"Entrevista ya finalizada (Camila o reclutador)",icon:eT.Z},{key:"underqualified",label:"Sub-calificados",title:"Flag de sub-calificaci\xf3n o apego menor a 50%",icon:eq.Z},{key:"strongMatch",label:"Alto apego",title:"Apego 70% o m\xe1s",icon:C.Z},{key:"unseen",label:"Sin ver",title:"Perfil a\xfan no abierto",icon:eL.Z},{key:"preselected",label:"Preseleccionados",title:"Pre-aprobados para el cliente",icon:_.Z},{key:"screeningPending",label:"Screening pendiente",title:"Cuestionario sin completar",icon:eO.Z},{key:"cvPending",label:"CV pendiente",title:"A\xfan no suben el CV",icon:eR.Z}],eW="z-[220]";function eH(e){return(0,eM.cn)("h-9 gap-1.5 border font-medium",e?"border-slate-300 bg-slate-900 text-white hover:bg-slate-800 hover:text-white":"border-gray-200 bg-white text-gray-700 hover:bg-gray-50")}function eK(e){var a,t;let{applications:i,datePreset:n,onDatePreset:r,quickFilters:l,onToggleQu
1ick:o}=e,c=null!==(t=null===(a=eX.find(e=>e.id===n))||void 0===a?void 0:a.label)&&void 0!==t?t:"Fecha",d=eY.filter(e=>l[e.key]),u=e$(l),m=0===d.length?"Ver":1===d.length?d[0].label:"Ver \xb7 ".concat(d.length);return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsxs)(ex.h_,{children:[(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsxs)(j.z,{type:"button",variant:"outline",size:"sm",className:eH(!!n),children:[(0,s.jsx)(eD.Z,{className:"h-3.5 w-3.5 shrink-0 opacity-80","aria-hidden":!0}),c,(0,s.jsx)(S.Z,{className:"h-3.5 w-3.5 shrink-0 opacity-70","aria-hidden":!0})]})}),(0,s.jsxs)(ex.AW,{align:"start",className:"".concat(eW," w-52"),children:[(0,s.jsx)(ex.Ju,{className:"text-xs font-normal text-muted-foreground",children:"Fecha de postulaci\xf3n"}),eX.map(e=>(0,s.jsxs)(ex.Xi,{onClick:()=>r(n===e.id?null:e.id),className:"justify-between",children:[e.label,n===e.id?(0,s.jsx)(eF.Z,{className:"h-4 w-4 text-slate-900","aria-hidden":!0}):null]},e.id)),n?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),(0,s.jsx)(ex.Xi,{onClick:()=>r(null),className:"text-muted-foreground",children:"Quitar fecha"})]}):null]})]}),(0,s.jsxs)(ex.h_,{children:[(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsxs)(j.z,{type:"button",variant:"outline",size:"sm",className:eH(u),children:[(0,s.jsx)(ej.Z,{className:"h-3.5 w-3.5 shrink-0 opacity-80","aria-hidden":!0}),m,(0,s.jsx)(S.Z,{className:"h-3.5 w-3.5 shrink-0 opacity-70","aria-hidden":!0})]})}),(0,s.jsxs)(ex.AW,{align:"start",className:"".concat(eW," w-64"),children:[(0,s.jsx)(ex.Ju,{className:"text-xs font-normal text-muted-foreground",children:"Filtrar candidatos"}),eY.map(e=>{let{key:a,label:t,title:n,icon:r}=e,c=i.filter(e=>eJ(e,a)).length,d=!!l[a];return(0,s.jsxs)(ex.bO,{checked:d,disabled:0===c&&!d,title:n,onSelect:e=>e.preventDefault(),onCheckedChange:()=>o(a),children:[(0,s.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,s.jsx)(r,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground","aria-hidden":!0}),(0,s.jsx)("span",{className:"truncate",children:t})]}),(0,s.jsx)("span",{className:"ml-auto tabular-nums text-xs text-muted-foreground",children:c})]},a)}),u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),(0,s.jsx)(ex.Xi,{className:"text-muted-foreground",onClick:()=>{for(let e of d)o(e.key)},children:"Quitar filtros de vista"})]}):null]})]})]})}var eQ=t(52947),e0=t(99509),e1=t(44827),e5=t(67369),e2=t(76688);function e4(e){return"pipeline-stage-".concat(e)}function e3(e){let a=String(e).match(/^pipeline-stage-(\d+)$/);if(!a)return null;let t=Number(a[1]);return Number.isFinite(t)?t:null}function e6(e){let{idx:a,row:t,disabled:i,canRemove:n,onLabelChange:r,onIdChange:l,onRemove:o}=e,{attributes:c,listeners:d,setNodeRef:u,transform:m,transition:p,isDragging:x}=(0,e5.nB)({id:e4(a),disabled:i}),h={transform:e2.ux.Transform.toString(m),transition:p,zIndex:x?10:void 0};return(0,s.jsxs)("div",{ref:u,style:h,className:"flex flex-wrap items-start gap-2 rounded-lg border border-gray-200 bg-white p-2 ".concat(x?"opacity-60 shadow-md ring-2 ring-blue-200":""),children:[(0,s.jsx)("button",{type:"button",className:"mt-6 flex h-9 w-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-md border border-transparent text-gray-400 hover:bg-gray-100 hover:text-gray-700 active:cursor-grabbing disabled:cursor-not-allowed disabled:opacity-40",...c,...d,disabled:i,"aria-label":"Arrastrar para reordenar ".concat(t.label||t.id),title:"Arrastrar para reordenar",children:(0,s.jsx)(eh.Z,{className:"h-4 w-4"})}),(0,s.jsxs)("div",{className:"flex-1 min-w-[140px] space-y-1",children:[(0,s.jsx)(U._,{className:"text-xs text-gray-600",children:"Nombre visible"}),(0,s.jsx)(B.I,{value:t.label,onChange:e=>r(e.target.value),className:"h-9 text-sm",disabled:i})]}),(0,s.jsxs)("div",{className:"w-36 space-y-1",children:[(0,s.jsx)(U._,{className:"text-xs text-gray-600",children:"Id"}),(0,s.jsx)(B.I,{value:t.id,onChange:e=>l(e.target.value.trim().toLowerCase().replace(/[^a-z0-9_]/g,"")),className:"h-9 text-xs font-mono",disabled:i,spellCheck:!1})]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",className:"h-9 text-destructive hover:text-destructive shrink-0 mt-5",disabled:i||!n,onClick:o,children:"Qu
1itar"})]})}function e9(e){let{stages:a,disabled:t=!1,onChange:i}=e,n=(0,er.Dy)((0,er.VT)(er.we,{activationConstraint:{distance:6}})),r=a.map((e,a)=>e4(a));return(0,s.jsx)(er.LB,{sensors:n,collisionDetection:er.pE,onDragEnd:e=>{let{active:t,over:s}=e;if(!s||t.id===s.id)return;let n=e3(t.id),r=e3(s.id);null!=n&&null!=r&&i((0,e5.Rp)(a,n,r))},children:(0,s.jsx)(e5.Fo,{items:r,strategy:e5.qw,children:(0,s.jsx)("div",{className:"space-y-2",children:a.map((e,n)=>(0,s.jsx)(e6,{idx:n,row:e,disabled:t,canRemove:a.length>2,onLabelChange:e=>i(a.map((a,t)=>t===n?{...a,label:e}:a)),onIdChange:e=>i(a.map((a,t)=>t===n?{...a,id:e}:a)),onRemove:()=>i(a.filter((e,a)=>a!==n))},e4(n)))})})})}var e8=t(71609),e7=t(72894),ae=t(82549),aa=t(90890),at=t(93995);function as(e){let{isOpen:a,onClose:t,onConfirm:i,position:n,loading:r=!1}=e;return a&&n?(0,s.jsx)(at.H,{children:(0,s.jsx)("div",{className:"fixed inset-0 z-[200] overflow-y-auto",children:(0,s.jsxs)("div",{className:"flex items-center justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0",children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity",onClick:t}),(0,s.jsx)("div",{className:"inline-block align-bottom bg-white rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full",children:(0,s.jsxs)(N.Zb,{className:"border-0 shadow-none",children:[(0,s.jsx)(N.Ol,{className:"pb-3",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-orange-100 rounded-full flex items-center justify-center",children:(0,s.jsx)(e7.Z,{className:"w-5 h-5 text-orange-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)(N.ll,{className:"text-lg font-semibold text-gray-900",children:"Cerrar Posici\xf3n"}),(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Esta acci\xf3n no se puede deshacer"})]})]}),(0,s.jsx)(j.z,{variant:"ghost",size:"icon",onClick:t,className:"hover:bg-gray-100",disabled:r,children:(0,s.jsx)(ae.Z,{className:"w-4 h-4"})})]})}),(0,s.jsx)(N.aY,{className:"pt-0",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"bg-gray-50 p-4 rounded-lg",children:[(0,s.jsx)("h3",{className:"font-medium text-gray-900 mb-2",children:n.title}),(0,s.jsxs)("div",{className:"flex items-center space-x-4 text-sm text-gray-600",children:[(0,s.jsxs)("span",{children:["\uD83D\uDCCD ",n.location]}),(0,s.jsxs)("span",{children:["\uD83D\uDCB0 $",n.salary_min.toLocaleString()," - $",n.salary_max.toLocaleString()]})]})]}),(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-start space-x-3 p-3 bg-yellow-50 border border-yellow-200 rounded-lg",children:[(0,s.jsx)(e7.Z,{className:"w-5 h-5 text-yellow-600 mt-0.5 flex-shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-yellow-800",children:"\xbfEst\xe1s seguro?"}),(0,s.jsx)("p",{className:"text-sm text-yellow-700 mt-1",children:'Al cerrar esta posici\xf3n, los candidatos ya no podr\xe1n aplicar y la posici\xf3n se mover\xe1 a la secci\xf3n de "Cerradas".'})]})]}),(0,s.jsxs)("div",{className:"flex items-start space-x-3 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:[(0,s.jsx)(aa.Z,{className:"w-5 h-5 text-blue-600 mt-0.5 flex-shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-blue-800",children:"\xbfQu\xe9 pasar\xe1?"}),(0,s.jsxs)("ul",{className:"text-sm text-blue-700 mt-1 space-y-1",children:[(0,s.jsx)("li",{children:'⢠La posici\xf3n se marcar\xe1 como "Cerrada"'}),(0,s.jsx)("li",{children:"⢠Se detendr\xe1n las nuevas aplicaciones"}),(0,s.jsx)("li",{children:'⢠Podr\xe1s verla en la secci\xf3n "Cerradas"'}),(0,s.jsx)("li",{children:'⢠Podr\xe1s copiarla a "Borradores" si necesitas reabrirla'})]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-end space-x-3 pt-4 border-t",children:[(0,s.jsx)(j.z,{variant:"outline",onClick:t,disabled:r,className:"hover:bg-gray-50",children:"Cancelar"}),(0,s.jsx)(j.z,{onClick:i,disabled:r,className:"bg-orange-600 hover:bg-orange-700 text-white",children:r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Cerrando..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(aa.Z,{className:"w-4 h-4 mr-2"}),"Cerrar Posici\xf3n"]})})]})]})})]})})]})})}):null}var ai=t(40623),an=t(45367);function ar(e){let{isOpen:a,onClose:t,onConfirm:i,positionTitle:n,isDeleting:r=!1}=e;return a?(0,s.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,s.jsxs)(N.Zb,{className:"w-full max-w-md mx-4",children:[(0,s.jsxs)(N.Ol,{children:[(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-red-600",children:[(0,s.jsx)(e7.Z,{className:"w-5 h-5"}),(0,s.jsx)("span",{children:"Confirmar Eliminaci\xf3n"})]}),(0,s.jsx)(N.SZ,{children:"Esta acci\xf3n no se puede deshacer"})]}),(0,s.jsxs)(N.aY,{className:"space-y-4",children:[r?(0,s.jsxs)("div",{className:"rounded-lg border border-dashed border-red-200 bg-red-50/60 p-4 space-y-3","aria-busy":"true","aria-live":"polite",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-red-800",children:[(0,s.jsx)(G.Z,{className:"h-4 w-4 animate-spin","aria-hidden":!0}),(0,s.jsx)("p",{className:"text-sm font-semibold",children:"Eliminando posici\xf3nâ¦"})]}),(0,s.jsx)("p",{className:"text-sm font-medium text-gray-900 truncate",children:n}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(ai.O,{className:"h-3 w-3/4"}),(0,s.jsx)(ai.O,{className:"h-3 w-1/2"}),(0,s.jsx)(ai.O,{className:"h-8 w-full rounded-md"})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,s.jsx)(an.Z,{className:"w-5 h-5 text-red-600 mt-0.5 flex-shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-red-800",children:"\xbfEst\xe1s seguro que deseas eliminar esta posici\xf3n?"}),(0,s.jsxs)("p",{className:"text-sm text-red-700 mt-1",children:[(0,s.jsxs)("strong",{children:['"',n,'"']})," ser\xe1 eliminada permanentemente."]})]})]})}),(0,s.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:(0,s.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,s.jsx)(e7.Z,{className:"w-5 h-5 text-yellow-600 mt-0.5 flex-shrink-0"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-yellow-800",children:"Advertencia"}),(0,s.jsx)("p",{className:"text-sm text-yellow-700 mt-1",children:"Esta acci\xf3n no se puede deshacer. Todos los datos asociados a esta posici\xf3n se perder\xe1n."})]})]})})]}),(0,s.jsxs)("div",{className:"flex justify-end space-x-3 pt-4",children:[(0,s.jsx)(j.z,{variant:"outline",onClick:t,disabled:r,children:"Cancelar"}),(0,s.jsx)(j.z,{variant:"destructive",onClick:i,disabled:r,className:"bg-red-600 hover:bg-red-700",children:r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Eliminandoâ¦"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(an.Z,{className:"w-4 h-4 mr-2"}),"Eliminar Definitivamente"]})})]})]})]})}):null}var al=t(58743),ao=t(13457),ac=t(64071),ad=t(43276),au=t(33520),am=t(22241),ap=t(89416);function ax(e){return Number.isFinite(e)?"".concat(e,"%"):"â"}function ah(e){var a;let{open:t,onOpenChange:n,positionId:r,positionTitle:l}=e,[o,c]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),[m,p]=(0,i.useState)(""),[x,h]=(0,i.useState)(null);if((0,i.useEffect)(()=>{c(!0)},[]),(0,i.useEffect)(()=>
1{if(!t||!r)return;let e=!1;return u(!0),p(""),(async()=>{try{let a=await fetch("/api/positions/".concat(encodeURIComponent(r),"/views"),{credentials:"include"}),t=await a.json().catch(()=>({}));if(e)return;if(!a.ok||!t.success){p("string"==typeof(null==t?void 0:t.error)?t.error:"No se pudieron cargar las vistas"),h(null);return}h(t)}catch(a){e||(p("Error de conexi\xf3n"),h(null))}finally{e||u(!1)}})(),()=>{e=!0}},[t,r]),(0,i.useEffect)(()=>{if(!t)return;let e=e=>{"Escape"===e.key&&n(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,n]),!o||!t)return null;let g=function(e){if(!e)return null;let a=new Date(e);return Number.isFinite(a.getTime())?a.toLocaleDateString("es-MX",{day:"numeric",month:"short",year:"numeric"}):null}(null!==(a=null==x?void 0:x.tracking_since)&&void 0!==a?a:null);return(0,en.createPortal)((0,s.jsxs)("div",{className:"fixed inset-0 z-[150] flex items-center justify-center p-4",children:[(0,s.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/50","aria-label":"Cerrar",onClick:()=>n(!1)}),(0,s.jsxs)("div",{role:"dialog","aria-modal":"true",className:"relative z-[151] w-full max-w-2xl max-h-[85vh] overflow-y-auto rounded-xl border bg-white p-5 shadow-xl",children:[(0,s.jsxs)("div",{className:"mb-4 flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsxs)("h2",{className:"flex items-center gap-2 text-lg font-semibold text-slate-900",children:[(0,s.jsx)(ap.Z,{className:"h-5 w-5 shrink-0 text-blue-700"}),"Vistas y campa\xf1as"]}),(0,s.jsxs)("p",{className:"text-sm text-slate-500",children:[l||"Vacante"," \xb7 cruce de visualizaciones vs postulaciones"]})]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>n(!1),"aria-label":"Cerrar",children:(0,s.jsx)(ae.Z,{className:"h-4 w-4"})})]}),d?(0,s.jsxs)("div",{className:"flex items-center justify-center py-12 text-slate-500",children:[(0,s.jsx)(G.Z,{className:"mr-2 h-5 w-5 animate-spin"}),"Cargandoâ¦"]}):m?(0,s.jsx)("p",{className:"py-8 text-center text-sm text-red-700",children:m}):x?(0,s.jsxs)("div",{className:"space-y-5",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[(0,s.jsx)(ag,{label:"Vistas",value:String(x.views)}),(0,s.jsx)(ag,{label:"Visitantes",value:String(x.unique_visitors)}),(0,s.jsx)(ag,{label:"Postulaciones",value:String(x.applications)}),(0,s.jsx)(ag,{label:"Conversi\xf3n",value:ax(x.conversion_rate)})]}),(0,s.jsxs)("p",{className:"text-xs text-slate-500",children:[x.paid_views>0?"".concat(x.paid_views," vistas con UTM de campa\xf1a paga \xb7 ").concat(x.organic_views," org\xe1nicas / sin UTM paga."):"Si el enlace lleva utm_source (fb, ig, whatsapp, indeedâ¦) y utm_campaign, aqu\xed se separan los canales."," ",g?"Vistas registradas desde ".concat(g,"."):"Las vistas se cuentan desde ahora; las postulaciones anteriores s\xed aparecen."]}),(0,s.jsxs)("section",{children:[(0,s.jsx)("h3",{className:"mb-2 text-sm font-semibold text-slate-800",children:"Por canal"}),0===x.by_origin.length?(0,s.jsx)("p",{className:"text-sm text-slate-500",children:"Todav\xeda no hay vistas ni postulaciones con origen."}):(0,s.jsx)("div",{className:"overflow-x-auto rounded-lg border",children:(0,s.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,s.jsx)("thead",{className:"bg-slate-50 text-xs text-slate-600",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-3 py-2 font-medium",children:"Canal"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Vistas"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"\xdanicos"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Postulaciones"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Conv."})]})}),(0,s.jsx)("tbody",{children:x.by_origin.map(e=>(0,s.jsxs)("tr",{className:"border-t",children:[(0,s.jsx)("td",{className:"px-3 py-2",children:e.label}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.views}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.unique_visitors}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.applications}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.views>0?ax(e.conversion_rate):"â"})]},e.origin))})]})})]}),x.by_campaign.length>0?(0,s.jsxs)("section",{children:[(0,s.jsx)("h3",{className:"mb-2 text-sm font-semibold text-slate-800",children:"Por campa\xf1a (utm_campaign)"}),(0,s.jsx)("div",{className:"overflow-x-auto rounded-lg border",children:(0,s.jsxs)("table",{className:"w-full text-left text-sm",children:[(0,s.jsx)("thead",{className:"bg-slate-50 text-xs text-slate-600",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-3 py-2 font-medium",children:"Campa\xf1a"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium",children:"Canal"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium",children:"Tipo"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Vistas"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Postulaciones"}),(0,s.jsx)("th",{className:"px-3 py-2 font-medium text-right",children:"Conv."})]})}),(0,s.jsx)("tbody",{children:x.by_campaign.map(e=>(0,s.jsxs)("tr",{className:"border-t",children:[(0,s.jsx)("td",{className:"max-w-[12rem] truncate px-3 py-2",title:e.campaign,children:e.campaign}),(0,s.jsx)("td",{className:"px-3 py-2",children:e.label}),(0,s.jsx)("td",{className:"px-3 py-2",children:e.paid?"Paga":"Org\xe1nica"}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.views}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.applications}),(0,s.jsx)("td",{className:"px-3 py-2 text-right tabular-nums",children:e.views>0?ax(e.conversion_rate):"â"})]},"".concat(e.origin,"-").concat(e.campaign)))})]})})]}):null,(0,s.jsxs)("p",{className:"text-[11px] leading-relaxed text-slate-400",children:["Talentgoo / org\xe1nico = entrada directa o sin UTM. Para atribuir una campa\xf1a, us\xe1 la URL corta con ",(0,s.jsx)("span",{className:"font-mono",children:"?utm_source=facebook&utm_medium=cpc&utm_campaign=marzo"}),".",v.Z7.job_board?" Portales tipo Indeed o Computrabajo aparecen como portal de empleo.":""]})]}):null]})]}),document.body)}function ag(e){let{label:a,value:t}=e;return(0,s.jsxs)("div",{className:"rounded-lg border bg-slate-50 px-3 py-2.5",children:[(0,s.jsx)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-slate-500",children:a}),(0,s.jsx)("p",{className:"mt-0.5 text-xl font-semibold tabular-nums text-slate-900",children:t})]})}let ab=[{id:"all",label:"Todo"},{id:"vacante",label:"Vacante"},{id:"candidato",label:"Candidatos"},{id:"entrevista",label:"Entrevistas"},{id:"visitas",label:"Visitas"}];function af(e){let{open:a,onOpenChange:t,positionId:n,positionTitle:r}=e,[l,o]=(0,i.useState)(!1),[c,d]=(0,i.useState)(!1),[u,m]=(0,i.useState)(""),[p,x]=(0,i.useState)([]),[h,g]=(0,i.useState)("all");(0,i.useEffect)(()=>{o(!0)},[]),(0,i.useEffect)(()=>
1{if(!a||!n)return;let e=!1;return d(!0),m(""),(async()=>{try{let a=await fetch("/api/positions/".concat(encodeURIComponent(n),"/audit"),{credentials:"include"}),t=await a.json().catch(()=>({}));if(e)return;if(!a.ok||!t.success){m("string"==typeof(null==t?void 0:t.error)?t.error:"No se pudo cargar la auditor\xeda"),x([]);return}x(Array.isArray(t.items)?t.items:[])}catch(a){e||(m("Error de conexi\xf3n"),x([]))}finally{e||d(!1)}})(),()=>{e=!0}},[a,n]);let b=(0,i.useMemo)(()=>"all"===h?p:p.filter(e=>e.category===h),[p,h]);return l&&a?(0,en.createPortal)((0,s.jsxs)("div",{className:"fixed inset-0 z-[120] flex items-end justify-center sm:items-center sm:p-4",children:[(0,s.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/40","aria-label":"Cerrar",onClick:()=>t(!1)}),(0,s.jsxs)("div",{className:"relative flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-t-2xl bg-white shadow-xl sm:rounded-2xl",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b px-5 py-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs uppercase tracking-wide text-slate-500",children:"Auditor\xeda"}),(0,s.jsx)("h2",{className:"truncate text-lg font-semibold text-slate-900",children:r||"Vacante"})]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"icon",onClick:()=>t(!1),"aria-label":"Cerrar",children:(0,s.jsx)(ae.Z,{className:"h-5 w-5"})})]}),(0,s.jsx)("div",{className:"flex flex-wrap gap-1 border-b px-5 py-2",children:ab.map(e=>(0,s.jsx)("button",{type:"button",className:"rounded-full px-2.5 py-1 text-xs font-medium ".concat(h===e.id?"bg-slate-900 text-white":"bg-slate-100 text-slate-600 hover:bg-slate-200"),onClick:()=>g(e.id),children:e.label},e.id))}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 py-4",children:c?(0,s.jsx)("div",{className:"flex justify-center py-12",children:(0,s.jsx)(G.Z,{className:"h-6 w-6 animate-spin text-slate-400"})}):u?(0,s.jsx)("p",{className:"text-sm text-red-600",children:u}):0===b.length?(0,s.jsx)("p",{className:"text-sm text-slate-500",children:"A\xfan no hay eventos en este filtro."}):(0,s.jsx)("ol",{className:"divide-y divide-slate-100 text-[13px] leading-snug",children:b.map(e=>{var a;let t=[e.detail,e.actor].filter(Boolean).join(" \xb7 ");return(0,s.jsxs)("li",{className:"flex gap-3 py-1.5",children:[(0,s.jsx)("span",{className:"w-[7.25rem] shrink-0 whitespace-nowrap tabular-nums text-slate-400",children:function(e){let a=new Date(e);return Number.isFinite(a.getTime())?a.toLocaleString("es-MX",{timeZone:"America/Mexico_City",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",hour12:!1}):e}(e.at)}),(0,s.jsx)("span",{className:"mt-0.5 h-1.5 w-1.5 shrink-0 rounded-full ".concat("vacante"===e.category?"bg-slate-400":"candidato"===e.category?"bg-sky-500":"entrevista"===e.category?"bg-violet-500":"bg-amber-500"),title:"vacante"===(a=e.category)?"Vacante":"candidato"===a?"Candidato":"entrevista"===a?"Entrevista":"Visitas"}),(0,s.jsxs)("p",{className:"min-w-0 flex-1 text-slate-800",children:[(0,s.jsx)("span",{className:"text-slate-900",children:e.title}),t?(0,s.jsxs)("span",{className:"text-slate-500",children:[" \xb7 ",t]}):null]})]},e.id)})})})]})]}),document.body):null}var av=t(11799),aj=t(57999),ay=t(92851),aN=t(22147),a_=t(78644);function aw(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:60,t=e.filter(e=>{var t;return(null!==(t=e.matchPercent)&&void 0!==t?t:0)>=a});return t.length>0?t.map(e=>e.id):e.slice(0,Math.min(5,e.length)).map(e=>e.id)}function ak(){return(0,s.jsxs)("div",{className:"space-y-4","aria-busy":"true","aria-label":"Generando criterios de b\xfasqueda",children:[(0,s.jsx)("div",{className:"h-12 animate-pulse rounded-md bg-slate-100"}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"h-3 w-48 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-20 animate-pulse rounded-md bg-slate-100"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"h-3 w-40 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-16 animate-pulse rounded-md bg-slate-100"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"h-3 w-52 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-10 animate-pulse rounded-md bg-slate-100"})]})]})}
1function aC(e){let{count:a=6}=e;return(0,s.jsx)("div",{className:"space-y-2","aria-busy":"true","aria-label":"Buscando candidatos",children:Array.from({length:a}).map((e,a)=>(0,s.jsxs)("div",{className:"flex gap-3 rounded-lg border border-gray-200 p-3",children:[(0,s.jsx)("div",{className:"mt-0.5 h-4 w-4 shrink-0 animate-pulse rounded bg-slate-200"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,s.jsx)("div",{className:"h-4 w-2/3 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-3 w-full animate-pulse rounded bg-slate-100"}),(0,s.jsx)("div",{className:"h-3 w-1/2 animate-pulse rounded bg-slate-100"})]})]},a))})}function aS(e){let{open:a,onOpenChange:t,positionId:n,positionTitle:r="",positionLocation:l="",fuente2Ready:o,onCompleted:c}=e,d=(0,ac.p)(),[u,m]=(0,i.useState)("filters"),[p,x]=(0,i.useState)(!0),[h,g]=(0,i.useState)(!1),[b,f]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[N,_]=(0,i.useState)(""),[w,C]=(0,i.useState)(""),[S,A]=(0,i.useState)(""),[E,I]=(0,i.useState)(""),[z,Z]=(0,i.useState)(null),[P,T]=(0,i.useState)(null),[q,L]=(0,i.useState)([]),[O,R]=(0,i.useState)(new Set),[D,F]=(0,i.useState)(0),[M,V]=(0,i.useState)(0),[X,J]=(0,i.useState)(!1),[$,Y]=(0,i.useState)(20),[W,H]=(0,i.useState)(null),[K,Q]=(0,i.useState)(!1),[ee,ea]=(0,i.useState)(!1),et=(0,i.useRef)(r),es=(0,i.useRef)(l);et.current=r,es.current=l;let ei=(0,i.useCallback)(()=>{m("filters"),_(""),C(""),A(""),I(""),Z(null),x(!0),g(!1),f(!1),y(!1),T(null),L([]),R(new Set),F(0),V(0),J(!1),Y(20),H(null),Q(!1),ea(!1)},[]),en=(0,i.useCallback)(e=>{var a;let t=Array.isArray(e.pending_candidates)?e.pending_candidates:[];L(t),F(Number(e.skipped_duplicates)||0),V(Number(null!==(a=e.totalFound)&&void 0!==a?a:e.total_found)||t.length),J(!0===e.has_more);let s=e.id||e.jobId;s&&T(s),R(new Set(aw(t))),m("review"),Z(null)},[]),er=(0,i.useCallback)(e=>{let a=(e.currentJobTitles||[]).map(e=>e.trim()).filter(Boolean),t=(e.locations||[]).map(e=>e.trim()).filter(Boolean);_(a.join("\n")||r),C(t.join("\n")||l),A(e.keywords||""),I(e.rationale||"")},[r,l]),el=(0,i.useCallback)(async()=>{x(!0),Z("Armando criterios de b\xfasquedaâ¦");try{let e=await (0,a_.U)("/api/positions/".concat(n,"/coresignal-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"preview"})}),a=await e.json();if(!e.ok||!a.success)throw Error(a.error||"No se pudo generar la b\xfasqueda");er(a.data.query),Z(null)}catch(a){let e=a instanceof Error?a.message:"Error al generar b\xfasqueda";d.error("Obtener candidatos",e),_(e=>e||r),C(e=>e||l),Z(null)}finally{x(!1)}},[n,d,er,r,l]);(0,i.useLayoutEffect)(()=>{a&&(m("filters"),x(!0),Z("Armando criterios de b\xfasquedaâ¦"),et.current&&_(et.current),es.current&&C(es.current))},[a,n]),(0,i.useEffect)(()=>{if(!a){ei();return}let e=!1;return(async()=>{try{var a,t;let s=await (0,a_.U)("/api/positions/".concat(n,"/coresignal-sourcing"),{method:"GET",cache:"no-store"}),i=await s.json().catch(()=>({}));if(e)return;let o=null==i?void 0:null===(a=i.data)||void 0===a?void 0:a.job,c=Array.isArray(null==o?void 0:o.pending_candidates)?o.pending_candidates:[];if((null==o?void 0:o.id)&&c.length>0){o.query&&er(o.query),en({jobId:o.id,pending_candidates:c,skipped_duplicates:o.skipped_duplicates,totalFound:o.total_found,has_more:o.has_more}),ea(!0),x(!1),Z(null);return}let d=await (0,a_.U)("/api/positions/".concat(n,"/coresignal-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"preview"})}),u=await d.json();if(e)return;d.ok&&u.success&&(null===(t=u.data)||void 0===t?void 0:t.query)?er(u.data.query):(_(e=>e||r),C(e=>e||l))}catch(a){e||(_(e=>e||r),C(e=>e||l))}finally{e||(x(!1),Z(null))}})(),()=>{e=!0}},[a,n,r,l,ei,er,en]);let eo=()=>({currentJobTitles:N.split("\n").map(e=>e.trim()).filter(Boolean).slice(0,3),locations:w.split("\n").map(e=>e.trim()).filter(Boolean).slice(0,2),keywords:S.trim()||void 0,rationale:E.trim()||void 0}),ec=async()=>{let e=eo();if(0===e.currentJobTitles.length){d.error("Obtener candidatos","Indica al menos un t\xedtulo");return}g(!0),m("searching"),Z("Buscando candidatosâ¦"),H(null);try{let a=await (0,a_.U)("/api/positions/".concat(n,"/coresignal-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start",query:e,maxResults:$})}),t=await a.json();if(!a.ok||!t.success)throw Error(t.error||"No se pudo iniciar la b\xfasqueda");let s=Array.isArray(t.data.pending_candidates)?t.data.pending_candidates:[];if(0===s.length&&0===Number(t.data.totalFound)){let e="No hay candidatos con esos filtros. Prueba con menos t\xedtulos o una sola ubicaci\xf3n.";H(e),d.error("Obtener candidatos",e),m("filters");return}en({jobId:t.data.jobId,pending_candidates:s,skipped_duplicates:t.data.skipped_duplicates,totalFound:t.data.totalFound,has_more:t.data.has_more}),t.data.query&&er(t.data.query),Q(!0===t.data.relaxed),ea(!1)}catch(a){let e=a instanceof Error?a.message:"Error al buscar";H(e),d.error("Obtener candidatos",e),m("filters"),Z(null)}finally{g(!1)}},ed=async()=>
1{if(P){f(!0);try{let e=await (0,a_.U)("/api/positions/".concat(n,"/coresignal-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"load_more",jobId:P,maxResults:20})}),a=await e.json();if(!e.ok||!a.success)throw Error(a.error||"No se pudieron cargar m\xe1s candidatos");let t=Array.isArray(a.data.pending_candidates)?a.data.pending_candidates:[];L(t),F(Number(a.data.skipped_duplicates)||0),V(Number(a.data.totalFound)||t.length),J(!0===a.data.has_more),R(e=>{let a=new Set(e);for(let e of aw(t))a.add(e);return a})}catch(a){let e=a instanceof Error?a.message:"Error al cargar m\xe1s";d.error("Obtener candidatos",e)}finally{f(!1)}}},em=e=>{R(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},ep=async()=>{if(!P||0===O.size){d.error("Obtener candidatos","Selecciona al menos un candidato para extraer");return}y(!0);try{let e=await (0,a_.U)("/api/coresignal-sourcing-jobs/".concat(P,"/accept"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidateIds:Array.from(O)})}),a=await e.json();if(!e.ok||!a.success)throw Error(a.error||"No se pudieron extraer los candidatos");let s=Number(a.data.imported_count)||0,i=Number(a.data.without_email_count)||0,n=Array.isArray(a.data.pending_candidates)?a.data.pending_candidates:q.filter(e=>!O.has(e.id));if(d.success("Candidatos extra\xeddos","".concat(s," en Identificado (no en Postul\xf3).").concat(i>0?" ".concat(i," sin correo: \xe1brelos en LinkedIn o usa la lupa en la ficha."):""," Luego puedes invitarlos a postularse. ").concat(n.length>0||X?"Puedes seguir eligiendo m\xe1s de la lista.":"")),c(s),n.length>0){L(n),R(new Set(aw(n)));return}if(X){L([]),R(new Set),await ed();return}t(!1)}catch(a){let e=a instanceof Error?a.message:"Error al extraer";d.error("Obtener candidatos",e)}finally{y(!1)}},ex=p||h||v||b||"searching"===u;if(!a)return null;let eh="review"===u?"Hay ".concat(M.toLocaleString()," candidato").concat(1===M?"":"s"):"Obtener candidatos";return(0,s.jsx)(at.H,{children:(0,s.jsxs)("div",{className:"fixed inset-0 z-[120]",children:[(0,s.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/40","aria-label":"Cerrar",disabled:ex,onClick:()=>!ex&&t(!1)}),(0,s.jsxs)("aside",{className:"absolute right-0 top-0 flex h-full w-full max-w-xl flex-col bg-white shadow-xl",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b px-4 py-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-slate-900",children:eh}),(0,s.jsx)("p",{className:"text-xs text-slate-500",children:"review"===u?"Ordenados por encaje estimado. Marca y extrae: el % no es el match del CV.":p?"La IA est\xe1 armando una propuesta de b\xfasquedaâ¦":"Revisa, edita, agrega o quita lo que quieras. Buscar cuando est\xe9 lista."})]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",disabled:ex,onClick:()=>t(!1),children:(0,s.jsx)(ae.Z,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:["filters"===u&&(0,s.jsx)(s.Fragment,{children:p?(0,s.jsx)(ak,{}):(0,s.jsxs)("div",{className:"space-y-4",children:[o?null:(0,s.jsx)("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-3 text-sm text-amber-900",children:"La b\xfasqueda no est\xe1 disponible ahora. Intenta m\xe1s tarde."}),W?(0,s.jsx)("p",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-sm text-red-800",children:W}):null,E?(0,s.jsxs)("p",{className:"rounded-md border bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:["Propuesta de la IA (puedes ignorarla): ",E]}):null,(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"oc-titles",children:"T\xedtulos actuales (uno por l\xednea, m\xe1x. 3)"}),(0,s.jsx)(aN.g,{id:"oc-titles",rows:3,value:N,onChange:e=>_(e.target.value),disabled:ex,placeholder:"Supply Chain Manager\nLogistics Manager"}),(0,s.jsx)("p",{className:"text-[11px] text-slate-500",children:"Agrega o borra l\xedneas. Estos t\xedtulos son los que tendr\xeda el candidato hoy."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"oc-locs",children:"Ubicaciones (preferible 1)"}),(0,s.jsx)(aN.g,{id:"oc-locs",rows:2,value:w,onChange:e=>C(e.target.value),disabled:ex,placeholder:"Mexico City"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"oc-kw",children:"Palabras clave (opcional, cortas)"}),(0,s.jsx)(B.I,{id:"oc-kw",value:S,onChange:e=>A(e.target.value),disabled:ex,placeholder:"SAP"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"oc-max",children:"M\xednimo a buscar"}),(0,s.jsxs)("select",{id:"oc-max",value:$,disabled:ex,onChange:e=>Y(Number(e.target.value)),className:"flex h-10 w-32 rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[(0,s.jsx)("option",{value:20,children:"20"}),(0,s.jsx)("option",{value:30,children:"30"}),(0,s.jsx)("option",{value:40,children:"40"}),(0,s.jsx)("option",{value:50,children:"50"})]})]})]})}),"searching"===u&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"rounded-md border border-teal-200 bg-teal-50/70 px-3 py-2",children:(0,s.jsx)("p",{className:"text-sm font-medium text-teal-900",children:z||"Buscando candidatosâ¦"})}),(0,s.jsx)(aC,{})]}),"review"===u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"rounded-md border border-teal-200 bg-teal-50/70 px-3 py-2 text-sm",children:[(0,s.jsxs)("p",{className:"font-semibold text-teal-900",children:["Hay ",M.toLocaleString()," candidato",1===M?"":"s",q.length<M?" \xb7 mostrando ".concat(q.length):""]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[D>0?"".concat(D," ya estaban en esta vacante. "):"","Ordenados por t\xedtulo, ubicaci\xf3n y seniority. El % es estimado (sin CV). Marcamos los de"," ",60,"% o m\xe1s.",ee?" Este listado ya se pag\xf3: no se volvi\xf3 a buscar.":" Extraer cobra la ficha completa."]}),ee?(0,s.jsx)("p",{className:"mt-1 text-xs text-teal-800",children:"Es la b\xfasqueda anterior de esta vacante. Extrae o vuelve a filtros si quieres buscar de nuevo (eso s\xed cobra)."}):null,K?(0,s.jsx)("p",{className:"mt-1 text-xs text-teal-800",children:"Ampliamos los filtros porque con los primeros no hab\xeda perfiles. Revisa t\xedtulos y ubicaci\xf3n arriba si quieres afinar."}):null]}),q.length>0?(0,s.jsxs)("label",{className:"mt-3 flex cursor-pointer items-center gap-2 text-xs text-slate-600",children:[(0,s.jsx)("input",{type:"checkbox",checked:O.size===q.length&&q.length>0,onChange:()=>{if(O.size===q.length){R(new Set);return}R(new Set(q.map(e=>e.id)))},className:"h-4 w-4 rounded border-slate-300"}),"Seleccionar los ",q.length," visibles"]}):null,(0,s.jsx)("div",{className:"mt-2 space-y-2",children:q.map(e=>{let a="pdl"==("pdl"===e.source||e.id.startsWith("pdl_")?"pdl":"coresignal"),t="number"==typeof e.matchPercent?Math.round(e.matchPercent):null,i=null!=t?(0,eu.HZ)(t):null;return(0,s.jsxs)("label",{className:"flex cursor-pointer gap-3 rounded-lg border p-3 ".concat(O.has(e.id)?"border-teal-400 bg-teal-50/50":"border-gray-200 hover:border-slate-300"),children:[(0,s.jsx)("input",{type:"checkbox",checked:O.has(e.id),onChange:()=>em(e.id),className:"mt-0.5 h-4 w-4 shrink-0 rounded border-slate-300"}),(0,s.jsx)("span",{className:"mt-1.5 h-2.5 w-2.5 shrink-0 rounded-full ".concat(a?"bg-red-500":"bg-emerald-500"),title:a?"Fuente cara":"Fuente est\xe1ndar","aria-label":a?"Fuente cara":"Fuente est\xe1ndar"}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-gray-900",children:e.fullName}),null!=t&&i?(0,s.jsxs)("span",{className:"inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-semibold ".concat(i.badge),title:e.matchReason||"Encaje estimado con el preview, sin CV",children:[t,"% est."]}):null,e.linkedinUrl?(0,s.jsxs)("a",{href:e.linkedinUrl,target:"_blank",rel:"noopener noreferrer",onClick:e=>e.stopPropagation(),className:"inline-flex items-center gap-0.5 text-[11px] text-blue-700 hover:underline",children:["Perfil ",(0,s.jsx)(k.Z,{className:"h-3 w-3"})]}):null]}),(0,s.jsx)("span",{className:"mt-0.5 block line-clamp-2 text-xs text-gray-600",children:[e.currentTitle,e.currentCompany].filter(Boolean).join(" \xb7 ")||e.headline||"â"}),(0,s.jsxs)("span",{className:"mt-0.5 block text-[11px] text-gray-500",children:[[e.location,e.country,e.companyIndustry].filter(Boolean).join(" \xb7 ")||null,null!=e.experienceCount?" \xb7 ".concat(e.experienceCount," exp."):"",null!=e.connectionsCount?" \xb7 ".concat(e.connectionsCount.toLocaleString()," conn."):""]}),e.matchReason?(0,s.jsx)("span",{className:"mt-0.5 block text-[11px] text-slate-500",children:e.matchReason}):null]})]},e.id)})}),X||b?(0,s.jsxs)("div",{className:"mt-4",children:[b?(0,s.jsx)(aC,{count:3}):null,X&&!b?(0,s.jsx)("div",{className:"flex justify-center",children:(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",onClick:()=>void ed(),children:"Ver m\xe1s candidatos"})}):null]}):null]})]}),("filters"===u||"review"===u)&&!p&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2 border-t px-4 py-3",children:["filters"===u?(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsxs)(j.z,{type:"button",variant:"outline",onClick:()=>void el(),disabled:ex,children:[(0,s.jsx)(ay.Z,{className:"mr-1.5 h-4 w-4"}),"Regenerar con IA"]}),(0,s.jsx)(j.z,{type:"button",onClick:()=>void ec(),disabled:ex||!o||!N.trim(),children:"Buscar"})]}):null,"review"===u?(0,s.jsxs)("div",{className:"flex w-full items-center justify-between gap-2",children:[(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",disabled:ex,onClick:()=>m("filters"),children:"Volver a filtros"}),(0,s.jsxs)(j.z,{type:"button",disabled:v||0===O.size,onClick:()=>void ep(),children:[v&&(0,s.jsx)(G.Z,{className:"mr-1.5 h-4 w-4 animate-spin"}),"Extraer seleccionados",O.size>0?" (".concat(O.size,")"):""]})]}):null]})]})]})})}var aA=t(5589);let aE=[{id:"INTERNSHIP",label:"En formaci\xf3n / Intern"},{id:"ENTRY_LEVEL",label:"Entry level"},{id:"ASSOCIATE",label:"Associate"},{id:"MID_SENIOR_LEVEL",label:"Mid-Senior"},{id:"DIRECTOR",label:"Director"},{id:"EXECUTIVE",label:"Executive"}];function aI(e){let a=String(e||"").trim().toUpperCase().replace(/\s+/g,"_");return a?"DISTANCE_1"===a||"FIRST_DEGREE"===a||"1"===a?"1.er grado":"DISTANCE_2"===a||"SECOND_DEGREE"===a||"2"===a?"2.\xba grado":"DISTANCE_3"===a||"THIRD_DEGREE"===a||"3"===a?"3.er grado":"OUT_OF_NETWORK"===a||"DISTANCE_OUT"===a||a.includes("OUT")?"Fuera de red":"SELF"===a?"T\xfa":null:null}function az(){return(0,s.jsxs)("div",{className:"space-y-4","aria-busy":"true","aria-label":"Generando criterios de b\xfasqueda",children:[(0,s.jsx)("div",{className:"h-12 animate-pulse rounded-md bg-slate-100"}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"h-3 w-48 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-20 animate-pulse rounded-md bg-slate-100"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"h-3 w-40 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-16 animate-pulse rounded-md bg-slate-100"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"h-3 w-52 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-10 animate-pulse rounded-md bg-slate-100"})]})]})}
1function aZ(e){let{count:a=6}=e;return(0,s.jsx)("div",{className:"space-y-2","aria-busy":"true","aria-label":"Buscando candidatos",children:Array.from({length:a}).map((e,a)=>(0,s.jsxs)("div",{className:"flex gap-3 rounded-lg border border-gray-200 p-3",children:[(0,s.jsx)("div",{className:"mt-0.5 h-4 w-4 shrink-0 animate-pulse rounded bg-slate-200"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,s.jsx)("div",{className:"h-4 w-2/3 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-3 w-full animate-pulse rounded bg-slate-100"}),(0,s.jsx)("div",{className:"h-3 w-1/2 animate-pulse rounded bg-slate-100"})]})]},a))})}function aP(e){let{open:a,onOpenChange:t,positionId:n,positionTitle:r="",positionLocation:l="",onCompleted:o,locked:c=!1,lockReason:d=null}=e,u=(0,ac.p)(),[m,p]=(0,i.useState)("filters"),[x,h]=(0,i.useState)(!0),[g,b]=(0,i.useState)(!1),[f,v]=(0,i.useState)(!1),[y,N]=(0,i.useState)(""),[_,w]=(0,i.useState)(""),[C,A]=(0,i.useState)(""),[E,I]=(0,i.useState)(""),[z,Z]=(0,i.useState)(""),[P,T]=(0,i.useState)(""),[q,L]=(0,i.useState)(null),[O,R]=(0,i.useState)(null),[D,F]=(0,i.useState)([]),[M,V]=(0,i.useState)(new Set),[X,J]=(0,i.useState)(0),[$,Y]=(0,i.useState)(0),[W,H]=(0,i.useState)(20),[K,Q]=(0,i.useState)(null),[ee,ea]=(0,i.useState)(!1),[et,es]=(0,i.useState)(!1),[ei,en]=(0,i.useState)(!1),[er,el]=(0,i.useState)([]),[eo,ec]=(0,i.useState)(""),[ed,em]=(0,i.useState)([]),ep=(0,i.useRef)(r),ex=(0,i.useRef)(l);ep.current=r,ex.current=l;let eh=(0,i.useCallback)(()=>{p("filters"),N(""),w(""),A(""),I(""),Z(""),T(""),L(null),h(!0),b(!1),v(!1),R(null),F([]),V(new Set),J(0),Y(0),H(20),Q(null),ea(!1),es(!1),en(!1),el([]),ec(""),em([])},[]),eg=(0,i.useCallback)(e=>{let a=Array.isArray(e.pending_candidates)?e.pending_candidates:[];F(a),J(Number(e.skipped_duplicates)||0),Y(Number(e.totalFound)||a.length),e.jobId&&R(e.jobId),V(new Set(aw(a))),p("review"),L(null),en(!1)},[]),eb=(0,i.useCallback)(e=>{let a=(e.currentJobTitles||[]).map(e=>e.trim()).filter(Boolean),t=(e.locations||[]).map(e=>e.trim()).filter(Boolean);N(a.join("\n")||r),w(t.join("\n")||l),A(e.keywords||""),I((e.industries||[]).join("\n")),Z((e.companies||[]).join("\n")),T(e.rationale||"")},[r,l]);(0,i.useLayoutEffect)(()=>{a&&(p("filters"),h(!0),L("Armando criterios de b\xfasquedaâ¦"),ep.current&&N(ep.current),ex.current&&w(ex.current))},[a,n]),(0,i.useEffect)(()=>{if(!a){eh();return}let e=!1;return(async()=>{try{var a,t,s;let i=await (0,a_.U)("/api/positions/".concat(n,"/unipile-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"preview"})}),o=await i.json();if(e)return;i.ok&&o.success&&(null===(a=o.data)||void 0===a?void 0:a.query)?(eb(o.data.query),es(!!(null===(s=o.data)||void 0===s?void 0:null===(t=s.capabilities)||void 0===t?void 0:t.hasRecruiter)),Q(null)):(N(e=>e||r),w(e=>e||l),!i.ok&&o.error&&Q(String(o.error)))}catch(a){e||(N(e=>e||r),w(e=>e||l))}finally{e||(h(!1),L(null))}})(),()=>{e=!0}},[a,n,r,l,eh,eb]);let ef=()=>({currentJobTitles:y.split("\n").map(e=>e.trim()).filter(Boolean).slice(0,3),locations:_.split("\n").map(e=>e.trim()).filter(Boolean).slice(0,2),keywords:C.trim()||void 0,industries:E.split("\n").map(e=>e.trim()).filter(Boolean).slice(0,3),companies:z.split("\n").map(e=>e.trim()).filter(Boolean).slice(0,5),rationale:P.trim()||void 0}),ev=()=>({seniority:et&&er.length?er:void 0,tenureMinYears:et&&""!==eo?Number(eo):null,profileLanguages:ed.length?ed:void 0}),ej=e=>{et&&el(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},ey=e=>{em(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e])},eN=async()=>{if(c){u.info("B\xfasqueda bloqueada",d||"Talentgoo est\xe1 buscando candidatos. Espere o cancele esa b\xfasqueda.");return}let e=ef();if(0===e.currentJobTitles.length){u.error("Buscar en LinkedIn","Indica al menos un t\xedtulo");return}b(!0),p("searching"),L("Buscando en LinkedIn con tu cuentaâ¦"),Q(null);try{let a=await (0,a_.U)("/api/positions/".concat(n,"/unipile-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start",query:e,maxResults:W,advanced:ev()})}
1),t=await a.json();if(!a.ok||!t.success)throw Error(t.error||"No se pudo iniciar la b\xfasqueda");let s=Array.isArray(t.data.pending_candidates)?t.data.pending_candidates:[];if(0===s.length&&0===Number(t.data.totalFound)){let e="No hay candidatos con esos filtros. Prueba con menos t\xedtulos o una sola ubicaci\xf3n.";Q(e),u.error("Buscar en LinkedIn",e),p("filters");return}eg({jobId:t.data.jobId,pending_candidates:s,skipped_duplicates:t.data.skipped_duplicates,totalFound:t.data.totalFound}),t.data.query&&eb(t.data.query)}catch(a){let e=a instanceof Error?a.message:"Error al buscar";Q(e),u.error("Buscar en LinkedIn",e),p("filters"),L(null)}finally{b(!1)}},e_=e=>{V(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},ew=async()=>{if(!O||0===M.size){u.error("Buscar en LinkedIn","Selecciona al menos un candidato");return}v(!0);try{let e=await (0,a_.U)("/api/positions/".concat(n,"/unipile-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"accept",jobId:O,candidateIds:Array.from(M),alsoConnect:ee})}),a=await e.json();if(!e.ok||!a.success)throw Error(a.error||"No se pudieron agregar los candidatos");let s=Number(a.data.imported_count)||0,i=Array.isArray(a.data.pending_candidates)?a.data.pending_candidates:D.filter(e=>!M.has(e.id)),r=Array.isArray(a.data.connect_results)?a.data.connect_results.filter(e=>!e.ok).length:0;if(u.success("Candidatos agregados","".concat(s," en Identificado.").concat(ee?r>0?" ".concat(s-r," invitaciones de conexi\xf3n enviadas; ").concat(r," no se pudieron."):" Invitaciones de conexi\xf3n enviadas.":" Puedes invitarlos a conectar o a postularse desde Acciones.").concat(i.length>0?" Puedes seguir eligiendo de la lista.":"")),o(s),i.length>0){F(i),V(new Set(aw(i)));return}t(!1)}catch(a){let e=a instanceof Error?a.message:"Error al agregar";u.error("Buscar en LinkedIn",e)}finally{v(!1)}},ek=x||g||f||"searching"===m,eC=!et;if(!a)return null;let eS="review"===m?"".concat(D.length," perfil").concat(1===D.length?"":"es"," para revisar"):"Buscar en LinkedIn";return(0,s.jsx)(at.H,{children:(0,s.jsxs)("div",{className:"fixed inset-0 z-[120]",children:[(0,s.jsx)("button",{type:"button",className:"absolute inset-0 bg-black/40","aria-label":"Cerrar",disabled:ek,onClick:()=>!ek&&t(!1)}),(0,s.jsxs)("aside",{className:"absolute right-0 top-0 flex h-full w-full max-w-xl flex-col bg-white shadow-xl",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b px-4 py-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-semibold text-slate-900",children:eS}),(0,s.jsx)("p",{className:"text-xs text-slate-500",children:"review"===m?"Ajust\xe1 filtros y volv\xe9 a buscar, o marc\xe1 a qui\xe9n agregar. El % es estimado (sin CV).":x?"La IA est\xe1 armando una propuestaâ¦":"Revis\xe1 el plan abajo. LinkedIn solo busca cuando das a Buscar."})]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",disabled:ek,onClick:()=>t(!1),children:(0,s.jsx)(ae.Z,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:[c?(0,s.jsx)("div",{className:"mb-4 rounded-md border border-amber-200 bg-amber-50 px-3 py-3 text-sm text-amber-950",children:d||"Talentgoo est\xe1 buscando candidatos en LinkedIn. La b\xfasqueda manual est\xe1 pausada hasta que termine o la cancele."}):null,"filters"===m&&(0,s.jsx)(s.Fragment,{children:x?(0,s.jsx)(az,{}):(0,s.jsxs)("div",{className:"space-y-4",children:[K?(0,s.jsx)("p",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-3 text-sm text-red-800",children:K}):null,P?(0,s.jsxs)("p",{className:"rounded-md border bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:["Propuesta de la IA (puedes ignorarla): ",P]}):null,(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-titles",children:"Cargo / t\xedtulo actual (uno por l\xednea, m\xe1x. 3)"}),(0,s.jsx)(aN.g,{id:"li-titles",rows:3,value:y,onChange:e=>N(e.target.value),disabled:ek,placeholder:"Business Development Manager\nAccount Executive"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-locs",children:"Ubicaciones (preferible 1)"}
1),(0,s.jsx)(aN.g,{id:"li-locs",rows:2,value:_,onChange:e=>w(e.target.value),disabled:ek,placeholder:"Mexico City"})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-industries",children:"Sectores (filtro LinkedIn)"}),(0,s.jsx)(aN.g,{id:"li-industries",rows:2,value:E,onChange:e=>I(e.target.value),disabled:ek,placeholder:"Furniture\nWholesale\nOil and Gas"}),(0,s.jsx)("p",{className:"text-[11px] text-slate-500",children:"Igual que \xabSectores\xbb en LinkedIn. Uno por l\xednea. Se resuelven a IDs de industria (Furniture, Chemicals, Constructionâ¦)."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-companies",children:"Empresas actuales (opcional)"}),(0,s.jsx)(aN.g,{id:"li-companies",rows:2,value:z,onChange:e=>Z(e.target.value),disabled:ek,placeholder:"Microsoft\nAmazon"}),(0,s.jsx)("p",{className:"text-[11px] text-slate-500",children:"Como \xabEmpresas actuales\xbb en LinkedIn. Uno por l\xednea."})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-kw",children:"Palabras clave (herramientas / productos)"}),(0,s.jsx)(B.I,{id:"li-kw",value:C,onChange:e=>A(e.target.value),disabled:ek,placeholder:"CET, AutoCAD, SAP"}),(0,s.jsx)("p",{className:"text-[11px] text-slate-500",children:"Texto libre en el perfil (OR por coma). No uses esto para el sector: us\xe1 Sectores arriba."})]}),(0,s.jsxs)("fieldset",{disabled:ek,className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-slate-700",children:"Idiomas del perfil"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:[{code:"es",label:"Espa\xf1ol"},{code:"en",label:"Ingl\xe9s"},{code:"pt",label:"Portugu\xe9s"},{code:"fr",label:"Franc\xe9s"}].map(e=>(0,s.jsxs)("label",{className:"inline-flex cursor-pointer items-center gap-1.5 rounded-md border px-2 py-1 text-xs ".concat(ed.includes(e.code)?"border-sky-400 bg-sky-50 text-sky-900":"border-slate-200 bg-white text-slate-700"),children:[(0,s.jsx)("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-slate-300",checked:ed.includes(e.code),onChange:()=>ey(e.code),disabled:ek}),e.label]},e.code))})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-max",children:"Cantidad a buscar"}),(0,s.jsxs)("select",{id:"li-max",value:W,disabled:ek,onChange:e=>H(Number(e.target.value)),className:"flex h-10 w-32 rounded-md border border-input bg-background px-3 py-2 text-sm",children:[(0,s.jsx)("option",{value:10,children:"10"}),(0,s.jsx)("option",{value:20,children:"20"}),(0,s.jsx)("option",{value:30,children:"30"}),(0,s.jsx)("option",{value:40,children:"40"})]})]}),(0,s.jsxs)("div",{className:"rounded-md border border-slate-200",children:[(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between gap-2 px-3 py-2.5 text-left text-sm font-medium text-slate-800",onClick:()=>en(e=>!e),"aria-expanded":ei,children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-2",children:["M\xe1s filtros (Recruiter)",eC?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] font-medium text-amber-800",children:[(0,s.jsx)(aA.Z,{className:"h-3 w-3"}),"Requiere Recruiter"]}):(0,s.jsx)("span",{className:"rounded bg-emerald-50 px-1.5 py-0.5 text-[10px] font-medium text-emerald-800",children:"Disponibles"})]}),(0,s.jsx)(S.Z,{className:"h-4 w-4 shrink-0 text-slate-500 transition-transform ".concat(ei?"rotate-180":"")})]}),ei?(0,s.jsxs)("div",{className:"space-y-4 border-t border-slate-200 px-3 py-3 ".concat(eC?"opacity-60":""),children:[eC?(0,s.jsx)("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:"Seniority y a\xf1os de experiencia requieren LinkedIn Recruiter. Sectores, red e idiomas ya funcionan con LinkedIn Classic."}):null,(0,s.jsxs)("fieldset",{disabled:eC||ek,className:"space-y-2",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-slate-700",children:"Seniority"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:aE.map(e=>(0,s.jsxs)("label",{className:"inline-flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs ".concat(er.includes(e.id)?"border-sky-400 bg-sky-50 text-sky-900":"border-slate-200 bg-white text-slate-700"," ").concat(eC?"cursor-not-allowed":"cursor-pointer"),children:[(0,s.jsx)("input",{type:"checkbox",className:"h-3.5 w-3.5 rounded border-slate-300",checked:er.includes(e.id),onChange:()=>ej(e.id),disabled:eC||ek}),e.label]},e.id))})]}),(0,s.jsxs)("fieldset",{disabled:eC||ek,className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-tenure",className:"text-xs font-medium text-slate-700",children:"A\xf1os de experiencia (m\xedn.)"}),(0,s.jsxs)("select",{id:"li-tenure",value:""===eo?"":String(eo),disabled:eC||ek,onChange:e=>ec(""===e.target.value?"":Number(e.target.value)),className:"flex h-9 w-40 rounded-md border border-input bg-background px-3 py-1 text-sm disabled:cursor-not-allowed",children:[(0,s.jsx)("option",{value:"",children:"Sin m\xednimo"}),(0,s.jsx)("option",{value:1,children:"1+"}),(0,s.jsx)("option",{value:3,children:"3+"}),(0,s.jsx)("option",{value:5,children:"5+"}),(0,s.jsx)("option",{value:8,children:"8+"}),(0,s.jsx)("option",{value:10,children:"10+"}),(0,s.jsx)("option",{value:15,children:"15+"})]})]}),(0,s.jsx)("p",{className:"text-[11px] text-slate-500",children:"A\xfan no: instituciones educativas, empresas anteriores, contactos de, categor\xedas de servicios (LinkedIn Premium / l\xedmites de API)."})]}):null]})]})}),"searching"===m&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"rounded-md border border-sky-200 bg-sky-50/70 px-3 py-2",children:(0,s.jsx)("p",{className:"text-sm font-medium text-sky-900",children:q||"Buscando en LinkedInâ¦"})}),(0,s.jsx)(aZ,{})]}),"review"===m&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mb-3 rounded-md border border-slate-200 bg-white",children:[(0,s.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between gap-2 px-3 py-2.5 text-left text-sm font-medium text-slate-800",onClick:()=>en(e=>!e),"aria-expanded":ei,children:[(0,s.jsx)("span",{children:"Ajustar filtros y volver a buscar"}),(0,s.jsx)(S.Z,{className:"h-4 w-4 shrink-0 text-slate-500 transition-transform ".concat(ei?"rotate-180":"")})]}),ei?(0,s.jsxs)("div",{className:"space-y-3 border-t border-slate-200 px-3 py-3",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-titles-r",children:"T\xedtulos (uno por l\xednea)"}),(0,s.jsx)(aN.g,{id:"li-titles-r",rows:2,value:y,onChange:e=>N(e.target.value),disabled:ek})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-locs-r",children:"Ubicaciones"}
1),(0,s.jsx)(aN.g,{id:"li-locs-r",rows:2,value:_,onChange:e=>w(e.target.value),disabled:ek})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-industries-r",children:"Sectores"}),(0,s.jsx)(aN.g,{id:"li-industries-r",rows:2,value:E,onChange:e=>I(e.target.value),disabled:ek})]}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"li-kw-r",children:"Palabras clave (OR)"}),(0,s.jsx)(B.I,{id:"li-kw-r",value:C,onChange:e=>A(e.target.value),disabled:ek})]}),(0,s.jsx)(j.z,{type:"button",size:"sm",className:"w-full",disabled:ek,onClick:()=>void eN(),children:g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Buscandoâ¦"]}):"Actualizar b\xfasqueda"})]}):null]}),(0,s.jsxs)("div",{className:"rounded-md border border-sky-200 bg-sky-50/70 px-3 py-2 text-sm",children:[(0,s.jsxs)("p",{className:"font-semibold text-sky-900",children:[D.length.toLocaleString()," perfil",1===D.length?"":"es",$>D.length?" \xb7 LinkedIn report\xf3 ~".concat($.toLocaleString()):""]}),(0,s.jsxs)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[X>0?"".concat(X," ya estaban en esta vacante. "):"","Ordenados por encaje estimado. Marcamos los de ",60,"% o m\xe1s. Los que matchean keywords van primero."]})]}),D.length>0?(0,s.jsxs)("label",{className:"mt-3 flex cursor-pointer items-center gap-2 text-xs text-slate-600",children:[(0,s.jsx)("input",{type:"checkbox",checked:M.size===D.length&&D.length>0,onChange:()=>{if(M.size===D.length){V(new Set);return}V(new Set(D.map(e=>e.id)))},className:"h-4 w-4 rounded border-slate-300"}),"Seleccionar los ",D.length," visibles"]}):null,(0,s.jsx)("div",{className:"mt-2 space-y-2",children:D.map(e=>{let a="number"==typeof e.matchPercent?Math.round(e.matchPercent):null,t=null!=a?(0,eu.HZ)(a):null;return(0,s.jsxs)("label",{className:"flex cursor-pointer gap-3 rounded-lg border p-3 ".concat(M.has(e.id)?"border-sky-300 bg-sky-50/50":"border-gray-200 hover:border-gray-300"),children:[(0,s.jsx)("input",{type:"checkbox",checked:M.has(e.id),onChange:()=>e_(e.id),className:"mt-1 h-4 w-4 shrink-0 rounded border-slate-300"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium text-slate-900",children:e.fullName}),null!=a&&t?(0,s.jsxs)("span",{className:"inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-semibold ".concat(t.badge),title:e.matchReason||"Encaje estimado sin CV",children:[a,"% est."]}):null,aI(e.networkDistance)?(0,s.jsx)("span",{className:"text-[10px] text-slate-500",title:"Qu\xe9 tan cerca est\xe1 de tu red en LinkedIn",children:aI(e.networkDistance)}):null]}),(0,s.jsx)("p",{className:"mt-0.5 line-clamp-2 text-xs text-slate-600",children:[e.currentTitle,e.currentCompany].filter(Boolean).join(" \xb7 ")||e.headline||"â"}),e.location?(0,s.jsx)("p",{className:"mt-0.5 text-[11px] text-slate-500",children:e.location}):null,e.linkedinUrl?(0,s.jsxs)("a",{href:e.linkedinUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[11px] text-sky-700 hover:underline",onClick:e=>e.stopPropagation(),children:["Ver en LinkedIn",(0,s.jsx)(k.Z,{className:"h-3 w-3"})]}):null]})]},e.id)})}),(0,s.jsxs)("label",{className:"mt-4 flex cursor-pointer items-start gap-2 rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-700",children:[(0,s.jsx)("input",{type:"checkbox",checked:ee,onChange:e=>ea(e.target.checked),disabled:ek,className:"mt-0.5 h-4 w-4 rounded border-slate-300"}),(0,s.jsx)("span",{children:"Al agregar, enviar tambi\xe9n invitaci\xf3n de conexi\xf3n en LinkedIn (\xfatil si a\xfan no son contacto de 1.er grado)."})]})]})]}),(0,s.jsx)("div",{className:"flex items-center justify-between gap-2 border-t px-4 py-3",children:"review"===m?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",disabled:ek,onClick:()=>{p("filters"),Q(null),en(!0)},children:"Ver filtros"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",disabled:ek,onClick:()=>void eN(),children:g?(0,s.jsx)(G.Z,{className:"h-4 w-4 animate-spin"}):"Rebuscar"}),(0,s.jsx)(j.z,{type:"button",size:"sm",disabled:ek||0===M.size,onClick:()=>void ew(),children:f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Agregandoâ¦"]}):"Agregar ".concat(M.size||"")})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",disabled:ek,onClick:()=>t(!1),children:"Cancelar"}),(0,s.jsx)(j.z,{type:"button",size:"sm",disabled:ek||x||c,onClick:()=>void eN(),children:g?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Buscandoâ¦"]}):"Buscar en LinkedIn"})]})})]})]})})}function aT(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"No se pudo completar la b\xfasqueda",t=e instanceof Error?e.message:a;return/coresignal|apify|peopledatalabs|people data labs|\bpdl\b|apollo|harvest|orbitpeople|\borbit\b/i.test(t)?"No se pudo completar la b\xfasqueda. Intenta de nuevo en unos minutos.":t||a}let aq={"mexico city":"Ciudad de M\xe9xico","ciudad de mexico":"Ciudad de M\xe9xico",cdmx:"CDMX","
1new york":"Nueva York","united states":"Estados Unidos",usa:"EE. UU.","united kingdom":"Reino Unido","latin america":"Latinoam\xe9rica","south america":"Sudam\xe9rica"},aL={english:"Ingl\xe9s",spanish:"Espa\xf1ol",portuguese:"Portugu\xe9s",french:"Franc\xe9s",german:"Alem\xe1n",italian:"Italiano",chinese:"Chino"},aO={advanced:"avanzado",intermediate:"intermedio",basic:"b\xe1sico",fluent:"fluido",native:"nativo",bilingual:"biling\xfce",elementary:"b\xe1sico",professional:"profesional"},aR=[[/^has at most (\d+) years? of experience$/i,e=>"M\xe1x. ".concat(e," a\xf1os de experiencia")],[/^has at least (\d+) years? of experience$/i,e=>"M\xedn. ".concat(e," a\xf1os de experiencia")],[/^has more than (\d+) years? of experience$/i,e=>"M\xe1s de ".concat(e," a\xf1os de experiencia")],[/^has fewer than (\d+) years? of experience$/i,e=>"Menos de ".concat(e," a\xf1os de experiencia")],[/^has (\d+)\+ years? of experience$/i,e=>"".concat(e,"+ a\xf1os de experiencia")],[/^has (\d+) years? of experience$/i,e=>"".concat(e," a\xf1os de experiencia")],[/^located in (.+)$/i,e=>aB(e)],[/^based in (.+)$/i,e=>aB(e)],[/^lives in (.+)$/i,e=>aB(e)],[/^current(?:ly)?(?: job)? title is (.+)$/i,e=>e.trim()],[/^job title is (.+)$/i,e=>e.trim()],[/^current(?:ly)? works? (?:at|for) (.+)$/i,e=>e.trim()],[/^currently employed at (.+)$/i,e=>e.trim()],[/^has experience (?:in|with) (.+)$/i,e=>aU(e)],[/^experience (?:in|with) (.+)$/i,e=>aU(e)],[/^has (advanced|intermediate|basic|fluent|native|bilingual|elementary|professional) (\w+) proficiency$/i,(e,a)=>aM(a,e)],[/^has (.+) proficiency$/i,e=>aU(e)],[/^(\w+) proficiency$/i,e=>aU(e)],[/^speaks?\s*\((.+)\)$/i,e=>aU(e)],[/^speaks? (.+)$/i,e=>aU(e)],[/^fluent in (.+)$/i,e=>aM(e,"fluent")],[/^native (?:in|speaker of) (.+)$/i,e=>aM(e,"native")],[/^open to (.+)$/i,e=>aU(e)],[/^willing to relocate$/i,()=>"Reubicaci\xf3n"],[/^willing to relocate to (.+)$/i,e=>"Reubicaci\xf3n a ".concat(aB(e))],[/^must have (.+)$/i,e=>aU(e)],[/^requires? (.+)$/i,e=>aU(e)],[/^industry is (.+)$/i,e=>aU(e)],[/^works? remotely$/i,()=>"Remoto"],[/^remote(?: work)?$/i,()=>"Remoto"],[/^hybrid(?: work)?$/i,()=>"H\xedbrido"],[/^on[- ]site$/i,()=>"Presencial"]],aD=[[/\bfull professional\b/gi,"profesional completo"],[/\bnative or bilingual\b/gi,"nativo o biling\xfce"],[/\bbilingual\b/gi,"biling\xfce"],[/\bnative\b/gi,"nativo"],[/\bprofessional\b/gi,"profesional"],[/\blimited working\b/gi,"profesional limitado"],[/\belementary\b/gi,"b\xe1sico"],[/\byears? of experience\b/gi,"a\xf1os de experiencia"],[/\bat most\b/gi,"como m\xe1ximo"],[/\bat least\b/gi,"al menos"],[/\bcurrent job title\b/gi,"puesto actual"],[/\blocated in\b/gi,"ubicado en"],[/\bbased in\b/gi,"con sede en"],[/\bhas experience in\b/gi,"tiene experiencia en"],[/\bexperience in\b/gi,"experiencia en"],[/\bspeaks\b/gi,"habla"],[/\bfluent in\b/gi,"dominio de"],[/\bwilling to relocate\b/gi,"dispuesto a reubicarse"],[/\bopen to\b/gi,"abierto a"],[/\bmust have\b/gi,"debe tener"],[/\bremote\b/gi,"remoto"],[/\bhybrid\b/gi,"h\xedbrido"],[/\bon[- ]site\b/gi,"presencial"],[/\bfull[- ]time\b/gi,"tiempo completo"],[/\bpart[- ]time\b/gi,"medio tiempo"],[/\bbachelor'?s?(?: degree)?\b/gi,"licenciatura"],[/\bmaster'?s?(?: degree)?\b/gi,"maestr\xeda"],[/\bphd\b/gi,"doctorado"],[/\bindustry\b/gi,"industria"],[/\b \bor\b /gi," o "],[/\b \band\b /gi," y "]];function aF(e){return/[áéÃóúñü¿¡]/i.test(e)||/\b(años|experiencia|ubicado|puesto|habla|máx\.|mÃn\.|inglés|español)\b/i.test(e)}function aM(e,a){let t=aL[e.trim().toLowerCase()]||aV(e.trim()),s=aO[a.trim().toLowerCase()]||a.trim().toLowerCase();return"".concat(t," ").concat(s)}function aV(e){return e?e.charAt(0).toUpperCase()+e.slice(1):e}function aB(e){let a=e.trim(),t=a.toLowerCase().replace(/\s+/g," ");return aq[t]||a}function aU(e){let a=e.trim(),t=aB(a);if(t!==a)return t;for(let[e,t]of aD)a=a.replace(e,t);return a.replace(/\s+/g," ").trim()}function aX(e){return e.replace(/^como máximo\s+/i,"M\xe1x. ").replace(/^al menos\s+/i,"M\xedn. ").replace(/^ubicado en\s+/i,"").replace(/^con sede en\s+/i,"").replace(/^vive en\s+/i,"").replace(/^puesto actual:\s*/i,"").replace(/^tiene experiencia en\s+/i,"").replace(/^experiencia en\s+/i,"").trim()}function aG(e){for(let[a,t]of aR){let s=e.match(a);if(s)return t(...s.slice(1))}let a=e.match(/^(advanced|intermediate|basic|fluent|native|bilingual|elementary|professional)\s+(\w+)(?:\s+proficiency)?$/i);return a?aM(a[2],a[1]):null}function aJ(e){let a=String(e||"").replace(/^(sÃ|si|no|·)\s+/i,"").replace(/\s+/g," ").trim();if(!a)return a;
1if(aF(a))return aX(a);let t=aG(a);if(t)return t;let s=a.replace(/^(has|have|is|must have|requires?)\s+/i,"").trim();if(s!==a){let e=aG(s);if(e)return e;if(aF(s))return aX(s)}return aV(aU(s))}function a$(){return(0,s.jsxs)("div",{className:"space-y-3","aria-busy":"true","aria-label":"Generando brief",children:[(0,s.jsx)("div",{className:"h-3 w-40 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-48 animate-pulse rounded-md bg-slate-100"}),(0,s.jsx)("div",{className:"h-3 w-3/4 animate-pulse rounded bg-slate-100"})]})}function aY(e){let{text:a}=e;return(null==a?void 0:a.trim())?(0,s.jsxs)("details",{className:"rounded-lg border border-slate-200 bg-slate-50 text-left",children:[(0,s.jsx)("summary",{className:"cursor-pointer px-3 py-2 text-sm font-medium text-slate-700",children:"Prompt enviado a buscar"}),(0,s.jsx)("pre",{className:"max-h-64 overflow-y-auto whitespace-pre-wrap border-t border-slate-200 px-3 py-2 text-xs text-slate-600",children:a})]}):null}function aW(e){let{count:a=5}=e;return(0,s.jsx)("div",{className:"space-y-2","aria-busy":"true","aria-label":"Buscando candidatos",children:Array.from({length:a}).map((e,a)=>(0,s.jsxs)("div",{className:"flex gap-3 rounded-lg border border-gray-200 p-3",children:[(0,s.jsx)("div",{className:"mt-0.5 h-4 w-4 shrink-0 animate-pulse rounded bg-slate-200"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,s.jsx)("div",{className:"h-4 w-2/3 animate-pulse rounded bg-slate-200"}),(0,s.jsx)("div",{className:"h-3 w-full animate-pulse rounded bg-slate-100"})]})]},a))})}function aH(e){let{open:a,onOpenChange:t,positionId:n,positionTitle:r="",onCompleted:l}=e,o=(0,ac.p)(),[c,d]=(0,i.useState)("brief"),[u,m]=(0,i.useState)(!0),[p,x]=(0,i.useState)(""),[h,g]=(0,i.useState)(null),[b,f]=(0,i.useState)(!1),[v,y]=(0,i.useState)(!1),[N,_]=(0,i.useState)(null),[w,C]=(0,i.useState)([]),[S,A]=(0,i.useState)(new Set),[E,I]=(0,i.useState)(null),[z,Z]=(0,i.useState)(null),[P,T]=(0,i.useState)(0),q=(0,i.useRef)(null),L=(0,i.useRef)(null),O=(0,i.useCallback)(()=>{q.current&&(clearInterval(q.current),q.current=null)},[]),R=(0,i.useCallback)(e=>{if(e){if(_(e.id),I(e.progress_label),Z(e.error_summary),T(e.total_found),"string"==typeof e.brief&&e.brief.trim()&&x(e.brief),"string"==typeof e.sent_brief&&e.sent_brief.trim()&&g(e.sent_brief),"awaiting_review"===e.status){let a=[...Array.isArray(e.pending_candidates)?e.pending_candidates:[]].sort((e,a)=>{var t,s;return(null!==(t=a.matchPercent)&&void 0!==t?t:-1)-(null!==(s=e.matchPercent)&&void 0!==s?s:-1)});C(a),A(new Set(a.filter(e=>e.starred).map(e=>e.id))),0===a.length&&A(new Set),d("review");return}if("running"===e.status||"queued"===e.status){d("searching");return}if("failed"===e.status){d("failed");return}}},[]),D=(0,i.useCallback)(e=>{O();let a=async()=>{try{var a;let t=await (0,a_.U)("/api/positions/".concat(n,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"status",jobId:e,tick:!0})}),s=await t.json().catch(()=>({}));if(!t.ok||!s.success)return;let i=null===(a=s.data)||void 0===a?void 0:a.job;R(i),i&&("awaiting_review"===i.status||"failed"===i.status||"cancelled"===i.status||"completed"===i.status)&&O()}catch(e){}};a(),q.current=setInterval(()=>void a(),4500)},[R,n,O]),F=(0,i.useCallback)(async()=>{m(!0),Z(null);try{var e,a;let t=await (0,a_.U)("/api/positions/".concat(n,"/deep-search-sourcing")),s=await t.json().catch(()=>({})),i=null==s?void 0:null===(e=s.data)||void 0===e?void 0:e.job;if(i&&("running"===i.status||"queued"===i.status||"awaiting_review"===i.status)){R(i),("running"===i.status||"queued"===i.status)&&D(i.id);return}if((null==i?void 0:i.status)==="failed"&&i.brief){x(i.brief),Z(i.error_summary),_(i.id),d("failed");return}let r=await (0,a_.U)("/api/positions/".concat(n,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"preview"})}),l=await r.json().catch(()=>({}));if(!r.ok||!l.success)throw Error(l.error||"No se pudo generar el brief");x(String((null===(a=l.data)||void 0===a?void 0:a.brief)||"")),d("brief"),_(null),C([]),A(new Set)}catch(e){Z(aT(e)),d("brief")}finally{m(!1)}},[R,n,D]);(0,i.useEffect)(()=>
1{if(!a){O(),L.current=null;return}L.current!==n&&(L.current=n,F())},[a,n,F,O]),(0,i.useEffect)(()=>()=>O(),[O]);let M=()=>{O(),t(!1)},V=async()=>{let e=p.trim();if(e.length<40){o.error("Brief incompleto","A\xf1ade m\xe1s detalle sobre el perfil que buscas.");return}f(!0),Z(null);try{var a,t;let s=await (0,a_.U)("/api/positions/".concat(n,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"start",brief:e})}),i=await s.json().catch(()=>({}));if(!s.ok||!i.success)throw Error(i.error||"No se pudo iniciar la b\xfasqueda");let r=String((null===(a=i.data)||void 0===a?void 0:a.jobId)||"");_(r),d("searching"),I((null===(t=i.data)||void 0===t?void 0:t.progress_label)||"Buscando perfilesâ¦"),C([]),A(new Set),o.info("B\xfasqueda profunda en curso","Puede tardar varios minutos. Te notificaremos cuando est\xe9 lista."),r&&D(r)}catch(a){let e=aT(a);Z(e),o.error("No se pudo iniciar",e)}finally{f(!1)}},B=async()=>{if(!N){M();return}try{await (0,a_.U)("/api/positions/".concat(n,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"cancel",jobId:N})})}catch(e){}O(),d("brief"),I(null)},X=e=>{A(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},J=async()=>{if(N&&0!==S.size){y(!0);try{var e,a;let t=await (0,a_.U)("/api/positions/".concat(n,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"accept",jobId:N,candidateIds:[...S]})}),s=await t.json().catch(()=>({}));if(!t.ok||!s.success)throw Error(s.error||"No se pudo importar");let i=Number(null===(e=s.data)||void 0===e?void 0:e.imported_count)||0,r=Array.isArray(null===(a=s.data)||void 0===a?void 0:a.pending_candidates)?s.data.pending_candidates:[];o.success(i>0?"Candidatos importados":"Sin importaciones",i>0?"".concat(i," en Identificado."):"No se import\xf3 ninguno (posibles duplicados)."),l(i),0===r.length?M():(C(r),A(new Set),T(r.length))}catch(e){o.error("Error al importar",aT(e))}finally{y(!1)}}};if(!a)return null;let $=(r||"esta vacante").trim();return(0,s.jsx)(at.H,{children:(0,s.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/40 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"deep-search-title",children:(0,s.jsxs)("div",{className:"relative flex max-h-[90vh] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-slate-200 bg-white shadow-xl",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 border-b border-slate-100 px-5 py-4",children:[(0,s.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-indigo-50 text-indigo-700",children:(0,s.jsx)(ay.Z,{className:"h-5 w-5"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("h2",{id:"deep-search-title",className:"text-lg font-semibold text-slate-900",children:"B\xfasqueda profunda"}),(0,s.jsxs)("p",{className:"mt-0.5 text-sm text-slate-600",children:["Perfiles completos para \xab",$,"\xbb. Puede tardar varios minutos; te notificaremos cuando est\xe9 lista."]})]}),(0,s.jsx)("button",{type:"button",className:"rounded-md p-1 text-slate-400 hover:bg-slate-100 hover:text-slate-700",onClick:M,"aria-label":"Cerrar",children:(0,s.jsx)(ae.Z,{className:"h-4 w-4"})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:["brief"===c||"failed"===c?u?(0,s.jsx)(a$,{}):(0,s.jsxs)("div",{className:"space-y-3",children:[("failed"===c||z)&&(0,s.jsx)("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:z||"La b\xfasqueda no se complet\xf3. Edita el brief e intenta de nuevo."}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(U._,{htmlFor:"deep-search-brief",children:"Brief del perfil buscado"}),(0,s.jsx)(aN.g,{id:"deep-search-brief",value:p,onChange:e=>x(e.target.value),rows:14,className:"min-h-[220px] text-sm",placeholder:"Describe rol, seniority, ubicaci\xf3n, skills, exclusionesâ¦"}),(0,s.jsxs)("p",{className:"text-xs text-slate-500",children:["Al lanzar se env\xeda este brief junto con el t\xedtulo, rubro de la empresa/cliente y descripci\xf3n de \xab",$,"\xbb. Si el rubro no es tecnolog\xeda, no deber\xeda traer perfiles de sistemas."]})]})]}
1):null,"searching"===c?(0,s.jsxs)("div",{className:"space-y-4 py-6 text-center",children:[(0,s.jsx)(G.Z,{className:"mx-auto h-8 w-8 animate-spin text-indigo-600"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-slate-900",children:E||"Buscando perfilesâ¦"}),(0,s.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"Puedes cerrar esta ventana; te notificaremos cuando est\xe9 lista."})]}),(0,s.jsx)(aW,{}),(0,s.jsx)(aY,{text:h})]}):null,"review"===c?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(aY,{text:h}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsxs)("p",{className:"text-sm text-slate-600",children:[P||w.length," perfil(es) para revisar",S.size>0?" \xb7 ".concat(S.size," seleccionados"):""]}),(0,s.jsx)("button",{type:"button",className:"text-sm font-medium text-indigo-700 hover:underline",onClick:()=>{S.size===w.length?A(new Set):A(new Set(w.map(e=>e.id)))},children:S.size===w.length?"Quitar todos":"Seleccionar todos"})]}),0===w.length?(0,s.jsx)("p",{className:"rounded-md border border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-600",children:"No hubo perfiles. Edita el brief y lanza de nuevo."}):(0,s.jsx)("ul",{className:"space-y-2",children:w.map(e=>{let a="number"==typeof e.matchPercent?Math.round(e.matchPercent):null,t=null!=a?(0,eu.HZ)(a):null;return(0,s.jsx)("li",{children:(0,s.jsxs)("label",{className:"flex cursor-pointer gap-3 rounded-lg border border-gray-200 p-3 hover:bg-slate-50",children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-1",checked:S.has(e.id),onChange:()=>X(e.id)}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-slate-900",children:e.fullName}),null!=a&&t?(0,s.jsxs)("span",{className:"inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-semibold ".concat(t.badge),title:e.matchReason||"Encaje estimado seg\xfan criterios de la b\xfasqueda",children:[a,"% est."]}):null,e.starred?(0,s.jsx)("span",{className:"rounded bg-indigo-50 px-1.5 py-0.5 text-[10px] font-medium text-indigo-700",children:"Destacado"}):null,e.linkedinUrl?(0,s.jsxs)("a",{href:e.linkedinUrl,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-0.5 text-xs text-indigo-700 hover:underline",onClick:e=>e.stopPropagation(),children:["LinkedIn ",(0,s.jsx)(k.Z,{className:"h-3 w-3"})]}):null]}),(0,s.jsx)("p",{className:"mt-0.5 text-sm text-slate-600",children:[e.title,e.company].filter(Boolean).join(" \xb7 ")||"Sin t\xedtulo"}),e.location?(0,s.jsx)("p",{className:"text-xs text-slate-500",children:e.location}):null,(e.primaryEmail||e.primaryPhone)&&(0,s.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:[e.primaryEmail,e.primaryPhone].filter(Boolean).join(" \xb7 ")}),Array.isArray(e.criteria)&&e.criteria.length>0?(0,s.jsx)("ul",{className:"mt-2 flex flex-wrap gap-1",children:e.criteria.map(e=>(0,s.jsx)("li",{title:e.detail?aJ(e.detail):void 0,className:"rounded-full border px-1.5 py-0.5 text-[10px] font-medium ".concat(!0===e.pass?"border-emerald-200 bg-emerald-50 text-emerald-800":!1===e.pass?"border-rose-200 bg-rose-50 text-rose-800":"border-slate-200 bg-slate-50 text-slate-600"),children:aJ(e.label)},e.label))}):e.matchReason?(0,s.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:e.matchReason}):null]})]})},e.id)})})]}):null]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-2 border-t border-slate-100 bg-slate-50 px-5 py-3",children:["searching"===c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",onClick:M,children:"Cerrar (sigue en curs
1o)"}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",onClick:()=>void B(),children:"Cancelar b\xfasqueda"})]}):null,"brief"!==c&&"failed"!==c||u?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",onClick:M,children:"Cerrar"}),(0,s.jsx)(j.z,{type:"button",onClick:()=>void V(),disabled:b,children:b?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Iniciandoâ¦"]}):"Lanzar b\xfasqueda"})]}),"review"===c?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",onClick:()=>{O(),d("brief"),C([]),A(new Set),Z(null),I(null)},children:"Editar brief y buscar de nuevo"}),(0,s.jsx)(j.z,{type:"button",onClick:()=>void J(),disabled:v||0===S.size,children:v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Importandoâ¦"]}):"Importar a Identificado (".concat(S.size,")")})]}):null]})]})})})}var aK=t(16257);function aQ(e){let{positionId:a,onImported:t,className:n}=e,[r,l]=(0,i.useState)(null),[o,c]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1),m=(0,i.useRef)(null),p=(0,i.useCallback)(async()=>{try{var e,s;let i=await (0,a_.U)("/api/positions/".concat(a,"/unipile-sourcing?tick=1")),n=await i.json().catch(()=>({}));if(!i.ok||!n.success)return;let r=null===(e=n.data)||void 0===e?void 0:e.lock;c(!!((null==r?void 0:r.locked)&&(null==r?void 0:r.mode)==="auto_tg"));let o=null===(s=n.data)||void 0===s?void 0:s.autoJob;
1if(o&&(o.id||o.status)){let e={id:o.id,status:o.status,progress_label:o.progress_label||null,query_index:Number(o.query_index)||0,query_total:Number(o.query_total)||0,imported_count:Number(o.imported_count)||0,done:!!o.done||["completed","partial","failed","cancelled"].includes(o.status)};l(e),e.done&&e.id&&m.current!==e.id&&("completed"===e.status||"partial"===e.status)&&(m.current=e.id,null==t||t(e.imported_count)),e.done&&(null==r||r.locked)}else(null==r?void 0:r.locked)||l(null)}catch(e){}},[a,t]);(0,i.useEffect)(()=>{let e=!1,t=null,s=async()=>{!e&&(await p(),e||(t=setTimeout(s,3500)))};return(async()=>{try{var t,i;let n=await (0,a_.U)("/api/positions/".concat(a,"/unipile-sourcing")),r=await n.json().catch(()=>({}));if(e||!r.success)return;let o=null===(t=r.data)||void 0===t?void 0:t.lock;c(!!((null==o?void 0:o.locked)&&(null==o?void 0:o.mode)==="auto_tg"));let d=null===(i=r.data)||void 0===i?void 0:i.autoJob;(null==d?void 0:d.id)&&(l({id:d.id,status:d.status,progress_label:d.progress_label||null,query_index:Number(d.query_index)||0,query_total:Number(d.query_total)||0,imported_count:Number(d.imported_count)||0}),s())}catch(e){}})(),()=>{e=!0,t&&clearTimeout(t)}},[a,p]),(0,i.useEffect)(()=>{if(!o&&!(null==r?void 0:r.id)||(null==r?void 0:r.done))return;let e=!1,a=null,t=async()=>{!e&&(await p(),e||(a=setTimeout(t,3500)))};return a=setTimeout(t,500),()=>{e=!0,a&&clearTimeout(a)}},[o,null==r?void 0:r.id,null==r?void 0:r.done,p]);let x=async()=>{if(null==r?void 0:r.id){u(!0);try{await (0,a_.U)("/api/positions/".concat(a,"/unipile-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"auto_cancel",jobId:r.id})}),await p()}finally{u(!1)}}};if(!o&&!r||(null==r?void 0:r.done)&&!o&&!r.imported_count&&"completed"!==r.status&&"partial"!==r.status)return null;let h=o||r&&!r.done;return(0,s.jsxs)("div",{className:n||"mb-3 flex flex-wrap items-center gap-3 rounded-lg border border-[#0A66C2]/25 bg-[#0A66C2]/5 px-3 py-2.5 text-sm text-slate-800",role:"status",children:[h?(0,s.jsx)(G.Z,{className:"h-4 w-4 shrink-0 animate-spin text-[#0A66C2]","aria-hidden":!0}):(0,s.jsx)(T.Z,{className:"h-4 w-4 shrink-0 text-[#0A66C2]","aria-hidden":!0}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-medium",children:h?(null==r?void 0:r.progress_label)||"Talentgoo est\xe1 buscando candidatos en LinkedInâ¦":(null==r?void 0:r.imported_count)?"".concat(r.imported_count," candidatos en Identificado"):(null==r?void 0:r.progress_label)||"B\xfasqueda TG finalizada"}),h&&r&&r.query_total>0?(0,s.jsxs)("p",{className:"text-xs text-slate-500",children:["Criterio ",Math.min(r.query_index+("importing"===r.status?0:1),r.query_total)," de"," ",r.query_total]}):null]}),h&&(null==r?void 0:r.id)?(0,s.jsxs)(j.z,{type:"button",variant:"outline",size:"sm",onClick:()=>void x(),disabled:d,className:"shrink-0",children:[d?(0,s.jsx)(G.Z,{className:"h-3.5 w-3.5 animate-spin"}):(0,s.jsx)(ae.Z,{className:"h-3.5 w-3.5"}),(0,s.jsx)("span",{className:"ml-1",children:"Cancelar"})]}):null]})}var a0=t(57520);function a1(e){let{positionId:a,onReadyToReview:t,className:n}=e,[r,l]=(0,i.useState)(null),[o,c]=(0,i.useState)(!1),d=(0,i.useCallback)(async()=>{try{var e,t;let s=await (0,a_.U)("/api/positions/".concat(a,"/deep-search-sourcing")),i=await s.json().catch(()=>({}));if(!s.ok||!i.success)return;let n=null===(e=i.data)||void 0===e?void 0:e.job;if(!(null==n?void 0:n.id)){l(null);return}let r=String(n.status||""),o=n.progress_label||null,c=Number(n.total_found)||0;if("running"===r||"queued"===r){let e=await (0,a_.U)("/api/positions/".concat(a,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"status",jobId:n.id,tick:!0})}),s=await e.json().catch(()=>({})),i=null==s?void 0:null===(t=s.data)||void 0===t?void 0:t.job;i&&(r=String(i.status||r),o=i.progress_label||o,c=Number(i.total_found)||c)}let d=["awaiting_review","completed","failed","cancelled"].includes(r),u={id:n.id,status:r,progress_label:o,total_found:c,done:d};l(u)}catch(e){}},[a]);(0,i.useEffect)(()=>{let e=!1,a=null,t=async()=>{!e&&(await d(),e||(a=setTimeout(t,4e3)))};return t(),()=>{e=!0,a&&clearTimeout(a)}},[d]);let u=async()=>
1{if((null==r?void 0:r.id)&&!o){c(!0);try{await (0,a_.U)("/api/positions/".concat(a,"/deep-search-sourcing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"cancel",jobId:r.id})}),await d()}finally{c(!1)}}};return r&&"completed"!==r.status&&"cancelled"!==r.status?"failed"===r.status?(0,s.jsxs)("div",{className:"mb-3 flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2.5 text-sm text-amber-950 ".concat(n||""),children:[(0,s.jsx)(a0.Z,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-700"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-medium",children:"B\xfasqueda profunda no completada"}),(0,s.jsx)("p",{className:"text-xs text-amber-800/90",children:r.progress_label||"Puedes editar el brief e intentar de nuevo desde Acciones."})]}),(0,s.jsx)("button",{type:"button",className:"rounded p-1 text-amber-700 hover:bg-amber-100",onClick:()=>l(null),"aria-label":"Cerrar",children:(0,s.jsx)(ae.Z,{className:"h-4 w-4"})})]}):"awaiting_review"===r.status?(0,s.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-3 rounded-lg border border-indigo-200 bg-indigo-50 px-3 py-2.5 text-sm text-indigo-950 ".concat(n||""),children:[(0,s.jsx)(a0.Z,{className:"h-4 w-4 shrink-0 text-indigo-700"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-medium",children:"B\xfasqueda profunda lista"}),(0,s.jsx)("p",{className:"text-xs text-indigo-800/90",children:r.total_found>0?"".concat(r.total_found," perfil(es) para revisar e importar a Identificado."):"Sin perfiles. Edita el brief y lanza de nuevo."})]}),(0,s.jsx)(j.z,{type:"button",size:"sm",className:"h-8",onClick:()=>r.id&&(null==t?void 0:t(r.id,r.total_found)),children:"Revisar"})]}):(0,s.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-3 rounded-lg border border-indigo-200 bg-indigo-50 px-3 py-2.5 text-sm text-indigo-950 ".concat(n||""),children:[(0,s.jsx)(G.Z,{className:"h-4 w-4 shrink-0 animate-spin text-indigo-700"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsx)("p",{className:"font-medium",children:"B\xfasqueda profunda en curso"}),(0,s.jsxs)("p",{className:"text-xs text-indigo-800/90",children:[r.progress_label||"Buscando perfiles (puede tardar varios minutos)â¦"," Te notificaremos cuando est\xe9 lista."]})]}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",className:"h-8",disabled:o,onClick:()=>void u(),children:o?"Cancelandoâ¦":"Cancelar"})]}):null}var a5=t(69263),a2=t(55117),a4=t(14196),a3=t(66654),a6=t(53905),a9=t(38244),a8=t(70290),a7=t(35817),te=t(35430),ta=t(49617),tt=t(92295),ts=t(51841),ti=t(95099),tn=t(96142),tr=t(41298),tl=t(47562),to=t(76637),tc=t(28956),td=t(60272),tu=t(34811),tm=t(45435),tp=t(5505),tx=t(74527),th=t(27461),tg=t(33673),tb=t(32176),tf=t(17158),tv=t(74056),tj=t(31541),ty=t(93167),tN=t(7532),t_=t(50534),tw=t(3140),tk=t(79618),tC=t(2250),tS=t(24300),tA=t(61397),tE=t(85485),tI=t(52232);let tz={queued:"En cola",registering_files:"Registrando archivos",extracting:"Extrayendo texto del CV",matching:"Calculando apego con la vacante",saving:"Guardando candidato",reanalyze_match:"Re-analizando apego",done:"Finalizado",completed:"Completado",partial:"Completado con errores",failed:"Fallido",cancelled:"Cancelado",canceled:"Cancelado"};function tZ(e){let a=String(e||"").trim();if(!a)return"Procesando";let t=a.toLowerCase();return tz[t]?tz[t]:t.startsWith("queued")?t.includes("sin worker local")?"En cola \xb7 sin worker local (npm run worker:cv-batch)":t.includes("cola sin procesar")?"En cola \xb7 sin procesar (revisa el servicio Worker)":"En cola":/[áéÃóúñ¿¡]/i.test(a)||/\b(desde|subiendo|procesando|descargando)\b/i.test(a)?a:a.replace(/_/g," ")}function tP(e,a){return new Promise((t,s)=>{if(null==a?void 0:a.aborted){s(new DOMException("Aborted","AbortError"));return}let i=setTimeout(t,e);null==a||a.addEventListener("abort",()=>{clearTimeout(i),s(new DOMException("Aborted","AbortError"))},{once:!0})})}async function tT(e,a,t){let s=null==t?void 0:t.signal,i=null,n=[],r=0,l=0;for(let t=0;t<600;t++){var o,c;if(null==s?void 0:s.aborted)return null;let t=await fetch("/api/applications/with-cvs-batch/jobs/".concat(encodeURIComponent(e)),{credentials:"include",cache:"no-store"}),d=await t.json().catch(()=>({}));
1if(!t.ok||!(null==d?void 0:d.success)){if(++r>=8)return null;try{await tP(1500,s)}catch(e){return null}continue}r=0;let u=null==d?void 0:null===(o=d.data)||void 0===o?void 0:o.job,m=Array.isArray(null==d?void 0:null===(c=d.data)||void 0===c?void 0:c.items)?d.data.items:[];if(!u){if(++r>=8)return null;try{await tP(1500,s)}catch(e){return null}continue}let p=Number(u.processed_files||0),x=Number(u.total_files||0),h=String(u.status||""),g=String(u.current_step||u.status||"procesando");if("queued"===h){if(++l>=30){let e="localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname;g=e?"queued \xb7 sin worker local (npm run worker:cv-batch o CV_BATCH_USE_WORKER=0)":"queued \xb7 cola sin procesar (revisa el servicio Worker en Railway: Online y mismas env que la web)"}}else l=0;if(null==a||a(p,x,tZ(g)),["completed","partial","failed"].includes(h)){i=u,n=m;break}try{await tP(1500,s)}catch(e){return null}}return i?{job:i,items:n}:null}function tq(e){return String(e||"").trim().toLowerCase()}function tL(e,a,t){if("overwrite"===t||"merge"===t)return{wouldImportCount:e.length,wouldSkipAsDuplicateCount:0,skippedDuplicateDisplayNames:[]};let s=new Set(a.map(e=>tq(e))),i=e.filter(e=>s.has(tq(e)));return{wouldImportCount:e.length-i.length,wouldSkipAsDuplicateCount:i.length,skippedDuplicateDisplayNames:i.slice(0,35)}}var tO=t(86165);function tR(e){return/\.(csv|tsv|txt)$/i.test(String(e||"").trim())}function tD(e){return/\.(xlsx|xls)$/i.test(String(e||"").trim())}let tF=t_.wP;function tM(e){var a;let t=String(null!==(a=null==e?void 0:e.error_summary)&&void 0!==a?a:"").trim();if(!t)return"No se pudo completar el re-an\xe1lisis. Revisa que los candidatos tengan perfil IA.";let s=t.length>500?"".concat(t.slice(0,497),"â¦"):t;return"No se pudo completar el re-an\xe1lisis. ".concat(s)}let tV="No se pudo conectar con el servidor. Comprueba que Next est\xe9 en marcha en el mismo puerto que esta pesta\xf1a (por defecto 3000; npm run dev o npm run dev:pro). Si la terminal muestra errores de cach\xe9, para el servidor, borra .next y vuelve a arrancar.",tB=new Set(["public_portal","talent_pool_public","recruiterflow"]);function tU(e){var a,t;let s=String(e.application_source||""),i=tB.has(s)?null!==(a=e.applied_at)&&void 0!==a?a:e.created_at:null!==(t=e.created_at)&&void 0!==t?t:e.applied_at,n=i?new Date(String(i)).getTime():0;return Number.isNaN(n)?0:n}function tX(e){let a=e.trim(),t=a.normalize("NFD").replace(/[\u0300-\u036f]/g,""),s=t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,64);return s||"etapa"}function tG(e){let a=(e.candidate_email||"").trim().toLowerCase();return a?"email:".concat(a):"solo:".concat(e.id)}function tJ(e,a){return e.applications.some(e=>e.position_id===a)}function t$(e){let{label:a,sortKey:t,currentKey:i,currentDir:n,onClick:r,thClassName:l="",buttonClassName:o="",icon:c,title:d}=e,u=i===t;return(0,s.jsx)("th",{className:l,title:d,children:(0,s.jsxs)("button",{type:"button",onClick:()=>r(t),className:"inline-flex items-center gap-1.5 font-medium text-gray-700 hover:text-gray-900 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/40 rounded px-0.5 -mx-0.5 "+o,children:[c,(0,s.jsx)("span",{children:a}),u?"desc"===n?(0,s.jsx)(a5.Z,{className:"h-3.5 w-3.5 shrink-0 text-blue-600","aria-hidden":!0}):(0,s.jsx)(a2.Z,{className:"h-3.5 w-3.5 shrink-0 text-blue-600","aria-hidden":!0}):(0,s.jsx)(a4.Z,{className:"h-3.5 w-3.5 shrink-0 text-gray-400","aria-hidden":!0})]})})}function tY(e){var a,t,n,m,C,z,q,R,D,F,J,Y,W,Q,ee,ea,et,er,eo,ep,eh,eg,eb,ev,e_,ew,ek,eC,eS,eA;let{isOpen:eE,onClose:eI,position:ez,onEdit:eZ,onClosePosition:eT,onCopyToDraft:eq,onShare:eO,onDownload:eR,onDelete:eD,onSave:eF,isEditable:eM=!1,allowVacancyFieldEdit:eB}=e,eX=void 0!==eB?eB:eM,[eY,eW]=(0,i.useState)(!1),eH=(0,i.useRef)(!1),[e5,e2]=(0,i.useState)(!1),[e4,e3]=(0,i.useState)(!1),[e6,aa]=(0,i.useState)(!1),[at,ai]=(0,i.useState)(!1),[ax,ag]=(0,i.useState)(!1),[ab,aN]=(0,i.useState)([]),[aw,ak]=(0,i.useState)(!1),aC=ab.length>0,aA=eX&&(!aC||aw),[aE,aI]=(0,i.useState)(!1),[az,aZ]=(0,i.useState)(null),[aT,aq]=(0,i.useState)(!1),[aL,aO]=(0,i.useState)(!1),[aR,aD]=(0,i.useState)(!0),[aF,aM]=(0,i.useState)(!1),[aV,aB]=(0,i.useState)(!1),[aU,aX]=(0,i.useState)(!1),[aG,aJ]=(0,i.useState)(!1),a$=function(e){let[a,t]=(0,i.useState)({locked:!1,progressLabel:null,mode:null});return(0,i.useEffect)(()=>
1{if(!e)return;let a=!1,s=async()=>{try{var s;let i=await (0,a_.U)("/api/positions/".concat(e,"/unipile-sourcing")),n=await i.json().catch(()=>({}));if(a||!n.success)return;let r=null===(s=n.data)||void 0===s?void 0:s.lock;t({locked:!!(null==r?void 0:r.locked),progressLabel:(null==r?void 0:r.progressLabel)||null,mode:(null==r?void 0:r.mode)||null})}catch(e){}};s();let i=setInterval(s,5e3);return()=>{a=!0,clearInterval(i)}},[e]),a}(null==ez?void 0:ez.id),[aY,aW]=(0,i.useState)(!1),[a5,a2]=(0,i.useState)([]),[a4,tz]=(0,i.useState)(null),[tP,tq]=(0,i.useState)(!1),[tB,tY]=(0,i.useState)(null),[tW,tH]=(0,i.useState)(!1),[tK,tQ]=(0,i.useState)(!1),[t0,t1]=(0,i.useState)(null),[t5,t2]=(0,i.useState)(null),[t4,t3]=(0,i.useState)(null),[t6,t9]=(0,i.useState)("ask"),[t8,t7]=(0,i.useState)(""),[se,sa]=(0,i.useState)(!1),[st,ss]=(0,i.useState)(!1),[si,sn]=(0,i.useState)(!1),[sr,sl]=(0,i.useState)(null),so=(0,i.useMemo)(()=>{var e,a;if(!(null==sr?void 0:null===(e=sr.eligible)||void 0===e?void 0:e.length))return null;let t=sr.eligible.map(e=>e.name),s=null!==(a=sr.alreadyProcessedVacancyBatchNames)&&void 0!==a?a:[];return tL(t,s,t6)},[sr,t6]),sc=(0,i.useRef)("files"),sd=(0,i.useRef)(null),su=(0,i.useRef)(null),sm=(0,i.useRef)(!1),sp=(0,i.useRef)(!1),[sx,sh]=(0,i.useState)(!0),[sg,sb]=(0,i.useState)(!0),[sf,sv]=(0,i.useState)(!1),[sj,sy]=(0,i.useState)(!0),[sN,s_]=(0,i.useState)(!0),[sw,sk]=(0,i.useState)(!1),[sC,sS]=(0,i.useState)(!0),[sA,sE]=(0,i.useState)(!0),[sI,sz]=(0,i.useState)(!0),[sZ,sP]=(0,i.useState)(!0),[sT,sq]=(0,i.useState)(!1),[sL,sO]=(0,i.useState)(new Set),[sR,sD]=(0,i.useState)(!1),[sF,sM]=(0,i.useState)(new Set),[sV,sB]=(0,i.useState)(!1),[sU,sX]=(0,i.useState)(!1),[sG,sJ]=(0,i.useState)(""),[s$,sY]=(0,i.useState)(null),[sW,sH]=(0,i.useState)(!1),[sK,sQ]=(0,i.useState)("select"),[s0,s1]=(0,i.useState)(()=>new Set),[s5,s2]=(0,i.useState)(!1),[s4,s3]=(0,i.useState)(!1),[s6,s9]=(0,i.useState)(!1),[s8,s7]=(0,i.useState)([]),[ie,ia]=(0,i.useState)(null),[it,is]=(0,i.useState)({}),[ii,ir]=(0,i.useState)([]),[il,io]=(0,i.useState)([]),[ic,id]=(0,i.useState)(""),[iu,im]=(0,i.useState)(null),[ip,ix]=(0,i.useState)("match"),[ih,ig]=(0,i.useState)("desc"),[ib,iv]=(0,i.useState)(!1),[ij,iy]=(0,i.useState)("kanban"),[iN,i_]=(0,i.useState)(!1),[iw,ik]=(0,i.useState)([]),[iC,iS]=(0,i.useState)(!1),[iA,iE]=(0,i.useState)(!1),iI=(0,ac.p)(),{promptHirePlacement:iz,hirePlacementModal:iZ}=(0,aj.i)(),iP=(0,ad.z)(iI),[iT,iq]=(0,i.useState)(null),[iL,iO]=(0,i.useState)(null),[iR,iD]=(0,i.useState)(!1),[iF,iM]=(0,i.useState)(!1),[iV,iB]=(0,i.useState)(!1),{openDialog:iU,isOpen:iX,dialogProps:iG,closeDialog:iJ}=(0,au.i)(),i$=(0,i.useRef)(null),[iY,iW]=(0,i.useState)(!1),[iH,iK]=(0,i.useState)(!1),[iQ,i0]=(0,i.useState)(!0),[i1,i5]=(0,i.useState)(!0),[i2,i4]=(0,i.useState)(!1),[i3,i6]=(0,i.useState)(!0),[i9,i8]=(0,i.useState)(!1),[i7,ne]=(0,i.useState)(null),[na,nt]=(0,i.useState)(!0),[ns,ni]=(0,i.useState)(!1),[nn,nr]=(0,i.useState)(""),[nl,no]=(0,i.useState)([]),[nc,nd]=(0,i.useState)(!1),[nu,nm]=(0,i.useState)([]),[np,nx]=(0,i.useState)(!1),[nh,ng]=(0,i.useState)(null),nb=(0,i.useRef)(!1),[nf,nv]=(0,i.useState)(new Set),[nj,ny]=(0,i.useState)(!1),[nN,n_]=(0,i.useState)(!1),[nw,nk]=(0,i.useState)(null),[nC,nS]=(0,i.useState)(!1),[nA,nE]=(0,i.useState)(!1),[nI,nz]=(0,i.useState)(!1),nZ=(0,i.useRef)(null),[nP,nT]=(0,i.useState)(!1);(0,i.useEffect)(()=>{nT(!0)},[]),(0,i.useEffect)(()=>{eE&&iv(!1)},[eE]),(0,i.useEffect)(()=>{sm.current=tW},[tW]),(0,i.useEffect)(()=>{sp.current=tK},[tK]),(0,i.useEffect)(()=>{var e;if(eE)return;null===(e=sd.current)||void 0===e||e.abort(),sd.current=null,su.current=null;let a=sm.current||sp.current;tH(!1),tY(null),tQ(!1),t2(null),a&&iI.info("Importaci\xf3n en segundo plano","El worker sigue procesando la cola. Revisa el progreso en Importaciones del men\xfa lateral.")},[eE,iI]),(0,i.useEffect)(()=>{if(!eE)return;let e=!1,a=async()=>{let a=await (0,a_.U)("/api/recruiter/position-edit-bypass",{cache:"no-store"}),t=await a.json().catch(()=>({}));e||ak(!!(null==t?void 0:t.canEditPositionWithApplications))};return a(),()=>{e=!0}},[eE]),(0,i.useEffect)(()=>
1{if(!eE)return;let e=!1;return(0,a_.U)("/api/recruiter/me",{cache:"no-store"}).then(e=>e.json()).then(a=>{var t,s,i;e||(aO(!!((null==a?void 0:null===(t=a.data)||void 0===t?void 0:t.linkedin_sourcing_enabled)||(null==a?void 0:null===(s=a.data)||void 0===s?void 0:s.candidate_sourcing_enabled))),aD(!!(null==a?void 0:null===(i=a.data)||void 0===i?void 0:i.sourcing_fuente_2_ready)))}).catch(()=>{e||(aO(!1),aD(!1))}),()=>{e=!0}},[eE]),(0,i.useEffect)(()=>{if(!eE)return;let e=!1,a=async()=>{try{let t=await (0,a_.U)("/api/recruiter/calendar-link",{cache:"no-store"}),s=await t.json().catch(()=>({}));if(e)return;if(t.ok&&(null==s?void 0:s.success)){var a;sa(!!(null===(a=s.data)||void 0===a?void 0:a.google_drive_oauth_connected))}else sa(!1)}catch(a){e||sa(!1)}};a();let t=()=>{e||a()};return window.addEventListener("talentgoo-recruiter-profile-updated",t),()=>{e=!0,window.removeEventListener("talentgoo-recruiter-profile-updated",t)}},[eE,aT]);let nq=ez?function(e){if(!e)return null;let a=new Date(e);return Number.isNaN(a.getTime())?null:a.toLocaleString("es-MX",{dateStyle:"medium",timeStyle:"short"})}(ez.updated_at||ez.created_at):null,[nL,nO]=(0,i.useState)([]),[nR,nD]=(0,i.useState)(!1),[nF,nM]=(0,i.useState)(""),[nV,nB]=(0,i.useState)(()=>new Set),[nU,nX]=(0,i.useState)(!1);(0,i.useEffect)(()=>{(null==ez?void 0:ez.id)&&(aA&&(nd(!0),fetch("/api/clients").then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.clients)&&no(e.clients)}).catch(()=>{}).finally(()=>nd(!1))),fetch("/api/position-categories").then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.categories)&&nm(e.categories)}).catch(()=>{}))},[aA,null==ez?void 0:ez.id]);let[nG,nJ]=(0,i.useState)({title:"",description:"",location:"",final_client_id:"",salary_min:0,salary_max:0,status:"active",value_proposition:"",linkedin_content:"",outreach_email:"",deadline_date:"",vacancies_count:1,candidate_invitation_message:"",ai_executive_summary:"",ai_ideal_candidate_profile:"",ai_key_competencies_str:"",ai_value_proposition:"",ai_recruitment_strategy:"",ai_linkedin_content:"",ai_colleagues_email:"",ai_match_criteria:"",mx_location_id:null,country_code:"MX",simplify_application:!1,simplified_hidden_fields:[],ask_candidate_p
1hone:!0,screening_questions_enabled:!1,screening_questions:[],ai_interview_auto_enabled:!1,ai_interview_auto_match_min:70,cv_requirement:"required",public_description:"",requirements:"",responsibilities:"",benefits_str:"",category_id:""}),[n$,nY]=(0,i.useState)(""),nW=(0,i.useMemo)(()=>null!=ez&&!!ez.id&&function(e){var a,t;let s={title:(e.title||"").trim(),description:(e.description||"").trim(),public_description:(e.public_description||"").trim(),value_proposition:(e.value_proposition||"").trim(),linkedin_content:(e.linkedin_content||"").trim(),requirements:(e.requirements||"").trim(),responsibilities:(e.responsibilities||"").trim(),benefits_str:(e.benefits_str||"").trim(),location:(e.location||"").trim(),mx_location_id:null!==(a=e.mx_location_id)&&void 0!==a?a:null,final_client_id:String(e.final_client_id||"").trim(),salary_min:Number(e.salary_min)||0,salary_max:Number(e.salary_max)||0,deadline_date:(e.deadline_date||"").trim(),vacancies_count:null!==(t=e.vacancies_count)&&void 0!==t?t:1,candidate_invitation_message:(e.candidate_invitation_message||"").trim(),ai_match_criteria:(e.ai_match_criteria||"").trim(),ai_key_competencies_str:(e.ai_key_competencies_str||"").trim(),outreach_email:(e.outreach_email||"").trim()};return JSON.stringify(s)}(nG)!==function(e){var a,t,s;let i=Array.isArray(e.benefits)?e.benefits.filter(Boolean).join("\n"):"",n=Array.isArray(e.ai_key_competencies)?e.ai_key_competencies.map(e=>String(e).trim()).filter(Boolean).join("\n"):"",r={title:(e.title||"").trim(),description:(e.description||"").trim(),public_description:(e.public_description||"").trim(),value_proposition:(e.value_proposition||"").trim(),linkedin_content:(e.linkedin_content||"").trim(),requirements:(e.requirements||"").trim(),responsibilities:(e.responsibilities||"").trim(),benefits_str:i,location:(e.location||"").trim(),mx_location_id:null!==(a=e.mx_location_id)&&void 0!==a?a:null,final_client_id:String(null!==(t=e.final_client_id)&&void 0!==t?t:"").trim(),salary_min:Number(e.salary_min)||0,salary_max:Number(e.salary_max)||0,deadline_date:(e.deadline_date||"").trim(),vacancies_count:null!==(s=e.vacancies_count)&&void 0!==s?s:1,candidate_invitation_message:(e.candidate_invitation_message||"").trim(),ai_match_criteria:(e.ai_match_criteria||"").trim(),ai_key_competencies_str:n,outreach_email:(e.outreach_email||"").trim()};return JSON.stringify(r)}(ez),[ez,nG]),nH=(0,i.useMemo)(()=>{let e=[nG.ai_executive_summary,nG.ai_ideal_candidate_profile,nG.ai_key_competencies_str,nG.ai_value_proposition,nG.ai_recruitment_strategy,nG.ai_linkedin_content,nG.ai_colleagues_email];return e.some(e=>String(e||"").trim().length>0)},[nG]),nK=(0,i.useMemo)(()=>null!=ez&&!!ez.id&&(nG.description||"").trim()!==(ez.description||"").trim(),[null==ez?void 0:ez.id,null==ez?void 0:ez.description,nG.description]),nQ=aA&&(nH||nW),n0=aA&&!!n$&&JSON.stringify(nG)!==n$,[n1,n5]=(0,i.useState)({}),n2=(0,d.$D)(nG.country_code,"MX"),n4=(0,i.useMemo)(()=>Object.keys(n1).length>0?n1:"VE"===n2?(0,u.OU)(u.Y7):"AR"===n2?(0,u.OU)(u.pJ):"CL"===n2?(0,u.OU)(u.w1):c.ZF,[n1,n2]),n3=d.FA[n2],n6=(0,d.Tp)(n2),[n9,n8]=(0,i.useState)({}),[n7,re]=(0,i.useState)({}),[ra,rt]=(0,i.useState)(""),[rs,ri]=(0,i.useState)(""),[rn,rr]=(0,i.useState)(""),[rl,ro]=(0,i.useState)("");(0,i.useEffect)(()=>{if(ez){var e,a;let t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:30,a=new Date;a.setDate(a.getDate()+e);let t=a.getFullYear(),s=String(a.getMonth()+1).padStart(2,"0"),i=String(a.getDate()).padStart(2,"0");return"".concat(t,"-").concat(s,"-").concat(i)}(30),s=ez.ai_key_competencies&&Array.isArray(ez.ai_key_competencies)?ez.ai_key_competencies:[],i={title:ez.title||"",description:ez.description||"",location:ez.location||"",final_client_id:(()=>{var e,a,t;let s=String(null!==(t=null!==(a=ez.final_client_id)&&void 0!==a?a:null===(e=ez.final_client)||void 0===e?void 0:e.id)&&void 0!==t?t:"").trim();return s&&s!==tA.gD?s:""})(),salary_min:ez.salary_min||0,salary_max:ez.salary_max||0,status:ez.status||"active",value_proposition:ez.value_proposition||"",linkedin_content:ez.linkedin_content||"",outreach_email:ez.outreach_email||"",deadline_date:ez.deadline_date||t,vacancies_count:ez.vacancies_count||1,candidate_invitation_message:ez.candidate_invitation_message||"",ai_executive_summary:ez.ai_executive_summary||"",ai_ideal_candidate_profile:ez.ai_ideal_candidate_profile||"",ai_key_competencies_str:s.join("\n"),ai_value_proposition:ez.ai_value_proposition||"",ai_recruitment_strategy:ez.ai_recruitment_strategy||"",ai_linkedin_content:ez.ai_linkedin_content||"",ai_colleagues_email:ez.ai_colleagues_email||"",ai_match_criteria:ez.ai_match_criteria||"",mx_location_id:null!=ez.mx_location_id?Number(ez.mx_location_id):null,country_code:(0,d.$D)(ez.country_code,"MX"),simplify_application:!!ez.simplify_application,simplified_hidden_fields:(0,b.cH)(ez.simplified_hidden_fields),ask_candidate_p
1hone:!1!==ez.ask_candidate_phone,screening_questions_enabled:!!ez.screening_questions_enabled,screening_questions:x(ez.screening_questions),ai_interview_auto_enabled:!!ez.ai_interview_auto_enabled,ai_interview_auto_match_min:(0,h.gh)(ez.ai_interview_auto_match_min),cv_requirement:"optional"===ez.cv_requirement||"not_required"===ez.cv_requirement?ez.cv_requirement:"required",public_description:ez.public_description||"",requirements:ez.requirements||"",responsibilities:ez.responsibilities||"",benefits_str:Array.isArray(ez.benefits)?ez.benefits.filter(Boolean).join("\n"):"",category_id:String(ez.category_id||"").trim()};nJ(i),nY(JSON.stringify(i));let n=null==(e=ez.mx_locations_catalog)?null:Array.isArray(e)?null!==(a=e[0])&&void 0!==a?a:null:e;if(n&&(n.state||n.city)){let e=null!=n.postal_code?String(n.postal_code).trim():"";rt((n.state||"").trim()),ri((n.city||"").trim()),rr(/^\d{5}$/.test(e)?e:""),ro("")}else rt(""),ri(""),rr(""),ro("")}},[ez]),(0,i.useEffect)(()=>{eE&&(null==ez?void 0:ez.id)&&sz(!0)},[eE,null==ez?void 0:ez.id]),(0,i.useEffect)(()=>{ez&&(iK(!!ez.is_public),nr(String(ez.public_slug||ez.public_link||"").trim()),i0(!1!==ez.portal_listed),i6(!1!==ez.publish_google_jobs),nt(!1!==ez.accept_foreign_candidates),i5(!1!==ez.show_salary_public))},[null==ez?void 0:ez.id,null==ez?void 0:ez.is_public,null==ez?void 0:ez.public_slug,null==ez?void 0:ez.public_link,null==ez?void 0:ez.portal_listed,null==ez?void 0:ez.publish_google_jobs,null==ez?void 0:ez.accept_foreign_candidates,null==ez?void 0:ez.show_salary_public]);let rc=(0,i.useCallback)(async()=>{if(null==ez?void 0:ez.id)try{let e=await fetch("/api/positions/".concat(ez.id,"/google-jobs"),{credentials:"include",cache:"no-store"}),a=await e.json().catch(()=>({}));if(!e.ok||!(null==a?void 0:a.success)){ne(null);return}ne({rich_results_url:"string"==typeof a.rich_results_url?a.rich_results_url:null,google_jobs_search_url:"string"==typeof a.google_jobs_search_url?a.google_jobs_search_url:null})}catch(e){ne(null)}},[null==ez?void 0:ez.id]);(0,i.useEffect)(()=>{eE&&!sZ&&(null==ez?void 0:ez.id)&&rc()},[eE,sZ,null==ez?void 0:ez.id,i3,iH,rc]);let rd=(0,i.useCallback)(async()=>{if(null==ez?void 0:ez.id){aI(!0);try{let e=await fetch("/api/applications?positionId=".concat(ez.id)),a=await e.json();a.success&&Array.isArray(a.data)&&aN(a.data)}finally{aI(!1)}}},[null==ez?void 0:ez.id]),ru=(0,i.useMemo)(()=>ab.filter(e=>"string"==typeof e.match_calculating_at&&String(e.match_calculating_at||"").trim()).map(e=>String(e.id)).sort().join(","),[ab]);(0,i.useEffect)(()=>{if(!ru||!(null==ez?void 0:ez.id))return;let e=!1,a=async()=>{if(!e)try{let a=await fetch("/api/applications?positionId=".concat(ez.id)),t=await a.json().catch(()=>({}));!e&&t.success&&Array.isArray(t.data)&&aN(t.data)}catch(e){}},t=window.setInterval(()=>void a(),3e3);return()=>{e=!0,window.clearInterval(t)}},[ru,null==ez?void 0:ez.id]);let rm=(0,i.useRef)(async()=>{}),rp=(0,i.useRef)(async()=>{}),rx=(0,i.useCallback)(async()=>{let e=t8.trim();if(!e){iI.error("URL requerida","Pega el enlace de la carpeta de Google Drive.");return}ss(!0),sl(null);try{let a=await fetch("/api/integrations/google-drive/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folderUrl:e,...(null==ez?void 0:ez.id)?{positionId:ez.id}:{}})}),t=await a.json().catch(()=>({}));if(!a.ok||!t.success){let e="string"==typeof t.message&&t.message||"string"==typeof t.error&&t.error||"No se pudo listar la carpeta";iI.error("Google Drive",e);return}sl({totalInFolder:Number(t.totalInFolder)||0,eligibleCount:Number(t.eligibleCount)||0,skippedCount:Number(t.skippedCount)||0,eligible:Array.isArray(t.eligible)?t.eligible:[],skipped:Array.isArray(t.skipped)?t.skipped:[],alreadyProcessedVacancyBatchNames:Array.isArray(t.alreadyProcessedVacancyBatchNames)?t.alreadyProcessedVacancyBatchNames:[]})}finally{ss(!1)}},[t8,iI,null==ez?void 0:ez.id]),rh=(0,i.useCallback)(async e=>{var a,t,s;if(!(null==ez?void 0:ez.id))return;let i=t8.trim();if(!i){iI.error("Carpeta requerida","Pega la URL de la carpeta de Google Drive.");return}if(!sr||0===sr.eligibleCount){iI.error("Vista previa","Primero revisa la carpeta con \xabVista previa\xbb.");return}let n=null!==(a=sr.alreadyProcessedVacancyBatchNames)&&void 0!==a?a:[],r=tL(sr.eligible.map(e=>e.name),n,e);if(0===r.wouldImportCount&&("ask"===e||"skip"===e)){iI.error("Nada que importar","Todos los archivos importables de la carpeta ya constan en lotes previos de esta vacante. Elige \xabSobrescribir\xbb o \xabFusionar\xbb en la opci\xf3n de duplicados, o usa otra carpeta.");return}sc.current="drive",t3(null),sn(!0);let l=r.wouldImportCount;aq(!1),tH(!0),tY({processed:0,total:l,step:"Descargando desde Drive..."}),iI.success("Importaci\xf3n iniciada","Encolando ".concat(l," CV(s) desde Drive."));try{let a=await fetch("/api/integrations/google-drive/import-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({folderUrl:i,positionId:ez.id,duplicateAction:e})}),n=await a.json().catch(()=>({}));if(!a.ok||!n.success){let e="string"==typeof n.message&&n.message||"string"==typeof n.error&&n.error||(500===a.status?"Error al importar desde Drive":"No se pudo importar");iI.error("Error al importar",e),tH(!1);return}let r=Array.isArray(n.alreadyProcessedNames)?n.alreadyProcessedNames:[];if(r.length>0&&Number(n.totalRequested||0)>0&&iI.info("Archivos omitidos","".concat(r.length," nombre(s) ya estaban en lotes previos de esta vacante y no se volvieron a encolar (usa \xabSobrescribir\xbb o \xabFusionar\xbb para
1incluirlos).")),n.queued&&n.jobId){let a=String(n.jobId);sn(!1),tY({processed:0,total:Number(n.totalRequested||l),step:"queued"}),null===(t=sd.current)||void 0===t||t.abort(),sd.current=new AbortController,su.current=a;let i=null;try{i=await tT(a,(e,a,t)=>{tY({processed:e,total:a,step:t})},{signal:sd.current.signal})}finally{su.current=null}let r=null==i?void 0:i.job,o=null!==(s=null==i?void 0:i.items)&&void 0!==s?s:[];if(!r){iI.error("Error","Tiempo de espera agotado al consultar el lote de importaci\xf3n."),tH(!1);return}let{okN:c,failN:d,okNames:u,failLines:m}=(0,tO.sh)(r,o),p=(0,tO.ri)(o,r),x=p?(0,tO.$8)(p):null;if(t3({ok:c,failed:d,names:u.slice(0,8),hint:x||(0===c&&m?m:null)||(d>0&&c>0&&m?"Algunos fallaron: ".concat(m):null)}),"ask"===e&&d>0&&p){tH(!1),iI.warning("Candidato ya en esta vacante","Confirma en la ventana emergente si quieres sobrescribir con el CV nuevo."),iU({title:"\xbfSobrescribir postulaci\xf3n existente?",message:"Uno o m\xe1s CVs corresponden a candidatos que ya se postularon a esta vacante y tienen an\xe1lisis. \xbfDeseas sustituir su postulaci\xf3n por el nuevo CV y volver a analizar? (\xdatil si el CV est\xe1 actualizado o corregido.)",type:"warning",confirmText:"S\xed, sobrescribir",cancelText:"No",onConfirm:()=>{("drive"===sc.current?rp:rm).current("overwrite")},onCancel:()=>{c>0?(rd(),iI.success(d>0?"Importaci\xf3n parcial":"Listo",d>0?"Se importaron ".concat(c," candidato(s). Fallaron ").concat(d,".").concat(u.length?" OK: ".concat(u.slice(0,5).join(", "),"."):"").concat(m?" ".concat(m):""):"Se importaron ".concat(c," candidato(s).").concat(u.length?" ".concat(u.slice(0,5).join(", "),"."):""))):iI.error("No se import\xf3 ning\xfan candidato",x||m||"El lote fall\xf3 en procesamiento.")}});return}if(0===c){iI.error("No se import\xf3 ning\xfan candidato",x||m||"El lote fall\xf3 en procesamiento."),tH(!1);return}await rd(),iI.success(d>0?"Importaci\xf3n parcial":"Listo",d>0?"Se importaron ".concat(c," candidato(s). Fallaron ").concat(d,".").concat(u.length?" OK: ".concat(u.slice(0,5).join(", "),"."):"").concat(m?" ".concat(m):""):"Se importaron ".concat(c," candidato(s).").concat(u.length?" ".concat(u.slice(0,5).join(", "),"."):"")),tH(!1)}}catch(e){tH(!1),iI.error("Error",tV)}finally{sn(!1)}},[null==ez?void 0:ez.id,t8,sr,iI,iU,rd]),rg=(0,i.useCallback)(async e=>{if(!(null==ez?void 0:ez.id))return;sc.current="files";let a=a5.length>0,t=!!a4;if(!a&&!t){iI.error("Archivo requerido","Selecciona CVs o un CSV de contactos.");return}if(t&&a4){if(tD(a4.name)){iI.error("Formato no soportado","Guarda la hoja como CSV (UTF-8) e imp\xf3rtala de nuevo.");return}t3(null),aW(!0),aq(!1),tH(!0),tY({processed:0,total:1,step:"Importando contactos..."}),iI.success("Importaci\xf3n iniciada","Procesando hoja de contactosâ¦");try{let t=new FormData;t.append("positionId",ez.id),t.append("duplicateAction",e),t.append("file",a4);let s=await fetch("/api/applications/import-contacts-sheet",{method:"POST",body:t}),i=await s.json().catch(()=>({})),n=Array.isArray(i.imported)?i.imported:[],r=Array.isArray(i.failed)?i.failed:[],l=Array.isArray(i.skipped)?i.skipped:[],o=n.length,c=r.length+("ask"===e?0:l.length),d=n.map(e=>String(e.name||"")).filter(Boolean),u="string"==typeof i.duplicateRequired?i.duplicateRequired:"string"==typeof i.message&&i.message.startsWith("DUPLICATE_REQUIRED|")?i.message:null,m=u?(0,tO.$8)(u):null;if("ask"===e&&("duplicate_required"===i.error||u)&&0===o){tH(!1),aW(!1),iU({title:"\xbfSobrescribir postulaci\xf3n existente?",message:"Uno o m\xe1s contactos y
1a est\xe1n en esta vacante. \xbfDeseas actualizar su perfil con los datos de la hoja?",type:"warning",confirmText:"S\xed, sobrescribir",cancelText:"No",onConfirm:()=>{rm.current("overwrite")},onCancel:()=>{iI.error("No se import\xf3 ning\xfan candidato",m||"Hab\xeda duplicados y no se sobrescribi\xf3.")}});return}if(!s.ok&&0===o){iI.error("Error al importar",("string"==typeof i.error&&"duplicate_required"!==i.error?i.error:null)||m||"No se pudo importar la hoja de contactos."),tH(!1);return}if(t3({ok:o,failed:c+l.length,names:d.slice(0,8),hint:m||(i.truncated?"Se alcanz\xf3 el l\xedmite de filas por importaci\xf3n; vuelve a importar el resto.":null)||(l.length>0?"Omitidos: ".concat(l.length,"."):null)}),0===o&&!a){iI.error("No se import\xf3 ning\xfan candidato",m||("string"==typeof i.error?i.error:null)||"Revisa el CSV e intenta de nuevo."),tH(!1);return}if(o>0){await rd();let e=n.some(e=>"boolean"==typeof e.linkedin),t=n.filter(a=>!!a.id&&(!e||!0===a.linkedin)).map(e=>e.id);if(t.length>0&&!a){tY({processed:0,total:t.length,step:"Completando perfiles LinkedInâ¦"}),iI.success("Importados","".concat(o," contacto(s). Completando LinkedIn y calculando %â¦"));try{let e=await fetch("/api/applications/enrich-linkedin-profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applicationIds:t})}),a=await e.json().catch(()=>({}));await rd();let s=Number(a.ok||0),i=Number(a.failed||0);e.ok&&s>0?iI.success("Perfiles listos","".concat(s," con match estimado.").concat(i?" ".concat(i," sin LinkedIn usable."):"")):(i>0||!e.ok)&&iI.warning("Importaci\xf3n OK",a.error||"Algunos perfiles no se pudieron completar desde LinkedIn. Reintenta desde la ficha.")}catch(e){await rd(),iI.warning("Importaci\xf3n OK","No se pudo completar LinkedIn ahora. Los candidatos ya est\xe1n en Identificado.")}}else iI.success(c>0||l.length>0?"Importaci\xf3n parcial":"Listo","Se importaron ".concat(o," contacto(s) desde la hoja.").concat(l.length?" Omitidos ".concat(l.length,"."):"").concat(r.length?" Fallaron ".concat(r.length,"."):""))}if(tz(null),!a){tH(!1);return}}catch(e){tH(!1),iI.error("Error",tV);return}finally{a||aW(!1)}}if(!a)return;t3(null),aW(!0);let s=a5.length;aq(!1),tH(!0),tY({processed:0,total:s,step:"Subiendo archivos..."}),iI.success("Importaci\xf3n iniciada","Subiendo ".concat(s," CV(s). Sigue el avance en la tarjeta inferior derecha."));try{let a=new FormData;a.append("positionId",ez.id),a.append("duplicateAction",e),a5.forEach((e,t)=>{a.append("cv".concat(t+1),e)});let t=await fetch("/api/applications/with-cvs-batch",{method:"POST",body:a}),r=await t.json().catch(()=>({}));if(!t.ok||!r.success){let e="string"==typeof r.message&&r.message||"string"==typeof r.error&&r.error||(500===t.status?"Error al procesar los CVs":"No se pudo procesar");iI.error("Error al importar",e),tH(!1);return}let l=Array.isArray(r.alreadyProcessedNames)?r.alreadyProcessedNames:[];if(l.length>0&&Number(r.totalRequested||0)>0&&iI.info("Archivos omitidos","".concat(l.length," nombre(s) ya estaban en lotes previos y no se volvieron a encolar (usa \xabSobrescribir\xbb o \xabFusionar\xbb para incluirlos).")),r.queued&&r.jobId){var i,n;let a=String(r.jobId);aW(!1),tY({processed:0,total:Number(r.totalRequested||s),step:"queued"}),null===(i=sd.current)||void 0===i||i.abort(),sd.current=new AbortController,su.current=a;let t=null;try{t=await tT(a,(e,a,t)=>{tY({processed:e,total:a,step:t})},{signal:sd.current.signal})}finally{su.current=null}let l=null==t?void 0:t.job,o=null!==(n=null==t?void 0:t.items)&&void 0!==n?n:[];if(!l){iI.error("Error","Tiempo de espera agotado al consultar el lote de importaci\xf3n."),tH(!1);return}let{okN:c,failN:d,okNames:u,failLines:m}=(0,tO.sh)(l,o),p=(0,tO.ri)(o,l),x=p?(0,tO.$8)(p):null;if(t3({ok:c,failed:d,names:u.slice(0,8),hint:x||(0===c&&m?m:null)||(d>0&&c>0&&m?"Algunos fallaron: ".concat(m):null)}),"ask"===e&&d>0&&p){tH(!1),iI.warning("Candidato ya en esta vacante","Confirma en la ventana emergente si quieres sobrescribir con el CV nuevo."),iU({title:"\xbfSobrescribir postulaci\xf3n existente?",message:"Uno o m\xe1s CVs corresponden a candidatos que ya se postularon a esta vacante y tienen an\xe1lisis. \xbfDeseas sustituir su postulaci\xf3n por el nuevo CV y volver a analizar? (\xdatil si el CV est\xe1 actualizado o corregido.)",type:"warning",confirmText:"S\xed, sobrescribir",cancelText:"No",onConfirm:()=>{("drive"===sc.current?rp:rm).current("overwrite")},onCancel:()=>{c>0?(rd(),iI.success(d>0?"Importaci\xf3n parcial":"Listo",d>
10?"Se importaron ".concat(c," candidato(s). Fallaron ").concat(d,".").concat(u.length?" OK: ".concat(u.slice(0,5).join(", "),"."):"").concat(m?" ".concat(m):""):"Se importaron ".concat(c," candidato(s).").concat(u.length?" ".concat(u.slice(0,5).join(", "),"."):"")),aq(!1)):iI.error("No se import\xf3 ning\xfan candidato",x||m||"El lote fall\xf3 en procesamiento.")}});return}if(0===c){iI.error("No se import\xf3 ning\xfan candidato",x||m||"El lote fall\xf3 en procesamiento."),tH(!1);return}await rd(),iI.success(d>0?"Importaci\xf3n parcial":"Listo",d>0?"Se importaron ".concat(c," candidato(s). Fallaron ").concat(d,".").concat(u.length?" OK: ".concat(u.slice(0,5).join(", "),"."):"").concat(m?" ".concat(m):""):"Se importaron ".concat(c," candidato(s).").concat(u.length?" ".concat(u.slice(0,5).join(", "),"."):"")),tH(!1);return}let o=Array.isArray(r.data)?r.data:[],c=Array.isArray(r.failures)?r.failures:[],d=Number(r.successCount||0),u=Number(r.failedCount||0),m=c.slice(0,3).map(e=>{var a;return"CV ".concat((null!==(a=e.idx)&&void 0!==a?a:0)+1,": ").concat(e.error||"error")}).join(" "),p=(0,tO.MI)(c),x=p?(0,tO.$8)(p):null,h=o.map(e=>String((null==e?void 0:e.candidate_name)||"").trim()).filter(Boolean);if(t3({ok:d,failed:u,names:h.slice(0,8),hint:x||(0===d&&m?m:null)||(u>0&&d>0&&m?"Algunos fallaron: ".concat(m):null)}),p&&"ask"===e){iI.warning("Candidato ya en esta vacante","Confirma en la ventana emergente si quieres sobrescribir con el CV nuevo."),iU({title:"\xbfSobrescribir postulaci\xf3n existente?",message:"Uno o m\xe1s CVs corresponden a candidatos que ya se postularon a esta vacante y tienen an\xe1lisis. \xbfDeseas sustituir su postulaci\xf3n por el nuevo CV y volver a analizar? (\xdatil si el CV est\xe1 actualizado o corregido.)",type:"warning",confirmText:"S\xed, sobrescribir",cancelText:"No",onConfirm:()=>{("drive"===sc.current?rp:rm).current("overwrite")},onCancel:()=>{d>0?(o.length&&aN(e=>[...o,...e]),rd(),iI.success(u>0?"Importaci\xf3n parcial":"Listo","Se importaron ".concat(d," candidato(s).").concat(u?" Fallaron ".concat(u,"."):"").concat(m?" ".concat(m):"")),aq(!1)):iI.error("No se import\xf3 ning\xfan candidato",m||"Revisa los CVs e intenta de nuevo.")}});return}if(o.length&&aN(e=>[...o,...e]),0===d){iI.error("No se import\xf3 ning\xfan candidato",m||"Revisa los CVs e intenta de nuevo.");return}iI.success("Listo","Se importaron ".concat(d," candidato(s).").concat(u?" Fallaron ".concat(u,"."):"").concat(m?" ".concat(m):"")),aq(!1)}catch(e){tH(!1),iI.error("Error",tV)}finally{aW(!1)}},[null==ez?void 0:ez.id,a5,a4,iI,iU,rd]);(0,i.useEffect)(()=>{rm.current=rg},[rg]),(0,i.useEffect)(()=>{rp.current=rh},[rh]),(0,i.useEffect)(()=>{if(!(null==ez?void 0:ez.id)){aN([]);return}rd()},[null==ez?void 0:ez.id,rd]),(0,i.useEffect)(()=>{if(eE&&(null==ez?void 0:ez.id))return(0,e0.aT)(e=>{e.positionId===ez.id&&aN(a=>a.map(a=>a.id===e.applicationId?{...a,recruitment_stage:e.recruitment_stage,...void 0!==e.stage_history?{stage_history:e.stage_history}:{},...void 0!==e.status?{status:e.status}:{},...void 0!==e.pre_selected_for_client?{pre_selected_for_client:e.pre_selected_for_client}:{},...void 0!==e.client_decision?{client_decision:e.client_decision}:{},...void 0!==e.shared_with_client?{shared_with_client:e.shared_with_client}:{}}:a))})},[eE,null==ez?void 0:ez.id]),(0,i.useEffect)(()=>{if(!(null==ez?void 0:ez.id)){aZ(null);return}let e=!1;return fetch("/api/positions/".concat(ez.id,"/interview-settings"),{credentials:"include"}).then(e=>e.json()).then(a=>{var t;if(e||!(null==a?void 0:a.success))return;let s=null===(t=a.data)||void 0===t?void 0:t.settings;aZ({clientAvailabilitySubmitted:!!(null==s?void 0:s.client_availability_submitted_at)})}).catch(()=>{}),()=>{e=!0}},[null==ez?void 0:ez.id]),(0,i.useEffect)(()=>{if(!eE||!(null==ez?void 0:ez.id)||aA||sA){(!eE||sA)&&(nO([]),nB(new Set),nM(""));return}let e=!1;return nD(!0),(0,a_.U)("/api/applications?lite=1").then(e=>e.json()).then(a=>{e||(a.success&&Array.isArray(a.data)?nO(a.data):nO([]))}).catch(()=>{e||nO([])}).finally(()=>{e||nD(!1)}),()=>{e=!0}},[eE,null==ez?void 0:ez.id,aA,sA]);let rb=(0,i.useMemo)(()=>(function(e){let a=new Map;for(let t of e){let e=tG(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let t=[];for(let[,e]of a){var s,i,n,r;e.sort((e,a)=>{var t,s;let i=null!==(t=e.match_percent)&&void 0!==t?t:-1,n=null!==(s=a.match_percent)&&void 0!==s?s:-1;return n!==i?n-i:new Date(a.created_at).getTime()-new Date(e.created_at).getTime()}),t.push({key:tG(e[0]),candidate_name:null!==(n=null===(s=e[0])||void 0===s?void 0:s.candidate_name)&&void 0!==n?n:null,candidate_email:null!==(r=null===(i=e[0])||void 0===i?void 0:i.candidate_email)&&void 0!==r?r:null,applications:e})}return t.sort((e,a)=>{let t=Math.max(...e.applications.map(e=>{var a;return null!==(a=e.match_percent)&&void 0!==a?a:-1})),s=Math.max(...a.applications.map(e=>{var a;return null!==(a=e.match_percent)&&void 0!==a?a:-1}));return s!==t?s-t:new Date(a.applications[0].created_at).getTime()-new Date(e.applications[0].created_at).getTime()}),t})(nL),[nL]),rf=(0,i.useMemo)(()=>{let e=nF.trim().toLowerCase();return e?rb.filter(a=>
1{let t=[a.candidate_name,a.candidate_email].filter(Boolean).join(" ").toLowerCase();return t.includes(e)}):rb},[rb,nF]),rv=(0,i.useCallback)(e=>{nB(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},[]),rj=(0,i.useCallback)(async()=>{if(!(null==ez?void 0:ez.id))return;let e=ez.id,a=rb.filter(e=>nV.has(e.key)),t=a.filter(a=>!tJ(a,e));if(0===t.length){iI.error("Sin selecci\xf3n v\xe1lida","Elige uno o varios candidatos que a\xfan no tengan postulaci\xf3n en esta vacante.");return}nX(!0);let s=0,i=[];try{for(let a of t){var n;let t=null===(n=a.applications[0])||void 0===n?void 0:n.id;if(!t)continue;let r=await fetch("/api/applications",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:e,sourceApplicationId:t})}),l=await r.json().catch(()=>({}));r.ok&&l.success?s++:i.push("string"==typeof l.error?l.error:"Error (".concat(r.status,")"))}if(s>0){iI.success("A\xf1adidos a la vacante","".concat(s," ").concat(1===s?"candidato":"candidatos"," copiado(s) a esta vacante.")),nB(new Set),await rd();let e=await fetch("/api/applications"),a=await e.json().catch(()=>({}));a.success&&Array.isArray(a.data)&&nO(a.data)}i.length&&0===s?iI.error("Error",i[0]||"No se pudo a\xf1adir a la vacante."):i.length&&s>0&&iI.success("A\xf1adidos con avisos","Se a\xf1adieron ".concat(s,". Algunos fallaron: ").concat(i.slice(0,2).join("; ")))}finally{nX(!1)}},[null==ez?void 0:ez.id,nV,rb,iI,rd]);(0,i.useEffect)(()=>{fetch("/api/labels").then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.data)&&ir(e.data)}).catch(()=>{})},[null==ez?void 0:ez.id]),(0,i.useEffect)(()=>{let e=e=>{i$.current&&!i$.current.contains(e.target)&&eW(!1)};return eY&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[eY]);let ry=(e,a)=>{(null==ez?void 0:ez.id)&&("requirements"===e||"responsibilities"===e||"benefits_str"===e)&&(0,tk.Hf)(ez.id),nJ(t=>({...t,[e]:a}))};(0,i.useEffect)(()=>{if(!aA)return;let e=(0,d.$D)(nG.country_code,"MX");n5({}),n8({}),re({}),fetch("/api/catalog/mx-locations?country=".concat(encodeURIComponent(e))).then(e=>e.json()).then(e=>{e.success&&e.locations&&n5(e.locations),e.success&&e.locations_nested&&n8(e.locations_nested),e.success&&e.locations_nested_ids&&re(e.locations_nested_ids)}).catch(()=>{})},[aA,nG.country_code]);let rN=(0,i.useCallback)((e,a,t,s)=>{let i=(0,d.$D)(nG.country_code,"MX"),n=e===tF?s.trim():(0,d.Tp)(i)?[a.trim(),e.trim(),t?"CP ".concat(t):""].filter(Boolean).join(", "):e.trim();ry("location",n);let r=(0,t_.rm)(n7,n9,e,(0,d.Tp)(i)?a:e,(0,d.Tp)(i)?t:"",tF);ry("mx_location_id",r)},[n7,n9,nG.country_code]),r_=(0,i.useMemo)(()=>{var e;if(!ra||ra===tF||!rs)return[];let a=(null===(e=n9[ra])||void 0===e?void 0:e[rs])||[],t=new Set(a);return rn&&/^\d{5}$/.test(rn)&&t.add(rn),Array.from(t).sort((e,a)=>e.localeCompare(a,"es",{numeric:!0}))},[n9,ra,rs,rn]),rw=(0,i.useMemo)(()=>Object.keys(n4).sort((e,a)=>e.localeCompare(a,"es")),[n4]),rk=(0,i.useMemo)(()=>ra&&ra!==tF?[...n4[ra]||[]]:[],[n4,ra]),rC=(0,i.useCallback)(async()=>{let e=String(rn).trim();if(!/^\d{5}$/.test(e)){iI.error("C\xf3digo postal","Ingresa 5 d\xedgitos (formato SEPOMEX).");return}try{let a=await fetch("/api/catalog/mx-locations/lookup?cp=".concat(encodeURIComponent(e))),t=await a.json();if(!a.ok||!t.success){iI.error("Cat\xe1logo","string"==typeof t.error?t.error:"No se pudo buscar.");return}let s=Array.isArray(t.rows)?t.rows:[];if(0===s.length){iI.error("Cat\xe1logo MX","Ese CP no est\xe1 en tu base. Ejecuta el seed SEPOMEX del cat\xe1logo MX o a\xf1ade la fila en mapeos.");return}let i=s[0];rt(i.state),ri(i.city);let n=String(i.postal_code||e).trim();rr(n),rN(i.state,i.city,n,""),s.length>1?iI.success("CP","".concat(s.length," asentamientos comparten este CP; se aplic\xf3 la primera fila (").concat(i.city,"). Ajusta ciudad si corresponde.")):iI.success("CP","Ubicaci\xf3n alineada con tu cat\xe1logo MX (origen SEPOMEX al hacer seed).")}catch(e){iI.error("Error","No se pudo consultar el cat\xe1logo.")}},[rn,rN,iI]);(0,i.useEffect)(()=>{if(!aA||0===Object.keys(n7).length||!ra||ra===tF)return;let e=(0,t_.rm)(n7,n9,ra,rs,rn,tF);nJ(a=>a.mx_location_id===e?a:{...a,mx_location_id:e})},[aA,n7,ra,rs,rn,n9]);let rS=(0,i.useRef)(null);(0,i.useEffect)(()=>
1{if(!aA||!(null==ez?void 0:ez.id))return;let e=null!=nG.mx_location_id?Number(nG.mx_location_id):null;if(null==e||!Number.isFinite(e)){rS.current=null;return}if(0===Object.keys(n7).length)return;let a=rS.current;if(a&&a.positionId===ez.id&&a.mxId===e)return;let t=(0,t_.d)(n7,e);if(!t)return;rS.current={positionId:ez.id,mxId:e};let s=t.postal&&/^\d{5}$/.test(t.postal)?t.postal:"";rt(t.state),ri(t.city),rr(s)},[aA,null==ez?void 0:ez.id,nG.mx_location_id,n7]),(0,i.useEffect)(()=>{if(!aA||!(null==ez?void 0:ez.id)||0===Object.keys(n4).length||ra)return;let e=null!=nG.mx_location_id?Number(nG.mx_location_id):null;if(null!=e&&Number.isFinite(e)&&0===Object.keys(n7).length)return;if(null!=e&&Number.isFinite(e)&&Object.keys(n7).length>0){let a=(0,t_.d)(n7,e);if(a)return}let a=(0,t_.OQ)(nG.location,n4);a&&(rt(a.state),ri(a.city),a.cp&&rr(a.cp))},[aA,null==ez?void 0:ez.id,n4,n7,nG.mx_location_id,nG.location,ra]);let rA=(0,i.useCallback)(async()=>{if(null==ez?void 0:ez.id){sB(!0);try{let e={positionName:nG.title,jobDescription:nG.description,currency:ez.currency||"MXN",salaryMin:nG.salary_min,salaryMax:nG.salary_max,location:nG.location,workMode:ez.work_mode||"presencial",experienceLevel:ez.experience_level||"mid",employmentType:ez.employment_type||"full_time",vacancies_count:nG.vacancies_count,deadline_date:nG.deadline_date||"",companyName:ez.company_name||"",companyDescription:ez.company_description||"",companyWebsite:ez.company_website||"",companySize:ez.company_size||"",companyIndustry:ez.company_industry||"",contactName:ez.contact_name||"",contactEmail:ez.contact_email||"",contactPhone:ez.contact_phone||"",contactTitle:ez.contact_title||"",requirements:nG.requirements||"",responsibilities:nG.responsibilities||"",benefitsLine:(nG.benefits_str||"").split("\n").map(e=>e.trim()).filter(Boolean).join(", "),hiringManagerComments:ez.hiring_manager_comments||"",ai_match_criteria:nG.ai_match_criteria||"",fileUrls:[]},a=(0,tw.aL)(e),t=await fetch("/api/ai/analyze-position",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:a,analysisContext:e,fileUrls:[]})}),s=await t.json().catch(()=>({}));if(!t.ok){let e=402===t.status?"string"==typeof s.error&&s.error.trim()?s.error:"No tienes cr\xe9ditos IA suficientes. Regenerar con IA consume 1 cr\xe9dito.":"string"==typeof s.error&&s.error.trim()?s.error:"Error del servidor (".concat(t.status,"). Revisa la consola o la clave de IA.");iI.error(402===t.status?"Cr\xe9ditos IA":"IA",e);return}if(!s.success){iI.error("IA","string"==typeof s.error?s.error:"No se pudo regenerar el borrador.");return}let i=s.analysis,n=String(i.web_description||"").trim(),r=String(i.linkedin_content||"").trim(),l=(n||r||"").trim(),o=i.benefits_list,c=null;Array.isArray(o)?c=o.map(e=>String(e).trim()).filter(Boolean):"string"==typeof o&&String(o).trim()&&(c=String(o).split(/[,;\n]/).map(e=>e.trim()).filter(Boolean));let d=String(i.requirements||"").trim()||nG.requirements||"",u=String(i.responsibilities||"").trim()||nG.responsibilities||"",m=c&&c.length>0?c:(nG.benefits_str||"").split("\n").map(e=>e.trim()).filter(Boolean),p=m.join("\n"),x=(0,tk.OW)({requirements:d,responsibilities:u,benefitsLines:p}),h=!!String(i.requirements||"").trim()||!!String(i.responsibilities||"").trim()||!!(c&&c.length>0);h&&(0,tk.d0)(String(ez.id),x);let g=Array.isArray(i.key_competencies)?i.key_competencies.map(e=>String(e).trim()).filter(Boolean):[];nJ(e=>({...e,public_description:l||e.public_description||"",linkedin_content:l||e.linkedin_content||"",requirements:d,responsibilities:u,benefits_str:p,value_proposition:String(i.value_proposition||"").trim()||e.value_proposition||"",outreach_email:String(i.colleagues_email||i.recruiter_outreach_email||i.outreach_email||"")||e.outreach_email||"",candidate_invitation_message:String(i.candidate_invitation_message||"")||e.candidate_invitation_message||"",ai_executive_summary:String(i.executive_summary||"")||e.ai_executive_summary,ai_ideal_candidate_profile:String(i.ideal_candidate_profile||"")||e.ai_ideal_candidate_profile,ai_key_competencies_str:g.length>0?g.join("\n"):e.ai_key_competencies_str,ai_value_proposition:String(i.value_proposition||"")||e.ai_value_proposition,ai_recruitment_strategy:String(i.recruitment_strategy||"")||e.ai_recruitment_strategy,ai_linkedin_content:l||e.ai_linkedin_content||"",ai_colleagues_email:String(i.colleagues_email||i.recruiter_outreach_email||i.outreach_email||"")||e.ai_colleagues_email||""})),iI.success("Borrador IA","Texto actualizado en el panel. Guarda la vacante para persistir en el servidor.")}catch(e){console.error(e),iI.error("IA","Error al regenerar el borrador.")}finally{sB(!1)}}},[ez,nG,iI]),rE=(0,i.useCallback)(async()=>{(null==ez?void 0:ez.id)&&nK&&iU({title:"Regenerar borrador con IA",message:"Se regenerar\xe1 el borrador con IA (texto p\xfablico, requisitos, responsabilidades, beneficios y res\xfamenes) usando el prompt inicial actual y el resto de datos de la vacante.\n\nConsume 1 cr\xe9dito IA de la empresa. No se guarda en el servidor hasta que pulses Guardar.\n\n\xbfContinuar?",type:"info",confirmText:"Continuar",cancelText:"Cancelar",onConfirm:()=>{rA()},onCancel:()=>{}})},[null==ez?void 0:ez.id,nK,rA,iU]),rI=(0,i.useCallback)(async()=>
1{if((null==ez?void 0:ez.id)&&aA){if(!(nG.description||"").trim()){iI.error("Prompt vac\xedo","A\xf1ade o conserva un prompt inicial antes de regenerar el contenido p\xfablico.");return}iU({title:"Regenerar contenido p\xfablico con IA",message:"La IA generar\xe1 el anuncio para candidatos (texto principal, redes, requisitos, responsabilidades, beneficios, propuesta de valor si viene en la respuesta, y borradores de apoyo).\nConsume 1 cr\xe9dito IA de la empresa.\nEl prompt interno no se borra.\nNada se guarda en el servidor hasta que pulses Guardar.\n\n\xbfContinuar con el primer paso?",type:"info",confirmText:"Continuar",cancelText:"Cancelar",onConfirm:()=>{let e=!!(nG.public_description||"").trim()||!!(nG.requirements||"").trim()||!!(nG.responsibilities||"").trim()||!!(nG.benefits_str||"").trim()||!!(nG.value_proposition||"").trim();setTimeout(()=>{iU({title:"Segunda confirmaci\xf3n",message:e?"Si ya hab\xeda texto en los campos p\xfablicos, la IA lo sustituir\xe1 por el nuevo borrador (puedes revisar antes de Guardar).\n\n\xbfConfirmas?":"\xbfLanzar la generaci\xf3n ahora?",type:"warning",confirmText:"S\xed, generar",cancelText:"Cancelar",onConfirm:()=>{rA()},onCancel:()=>{}})},260)},onCancel:()=>{}})}},[null==ez?void 0:ez.id,aA,nG,rA,iI,iU]),rz=(0,i.useCallback)(()=>{let{benefits_str:e,ai_key_competencies_str:a,...t}=nG;return{...t,ai_key_competencies:(a||"").split("\n").map(e=>e.trim()).filter(Boolean),benefits:(e||"").split("\n").map(e=>e.trim()).filter(Boolean)}},[nG]),rZ=function(){var e;let a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{ai_key_competencies_str:t,benefits_str:s,outreach_email:i,...n}=nG,r=(t||"").split("\n").map(e=>e.trim()).filter(Boolean),l=(s||"").split("\n").map(e=>e.trim()).filter(Boolean);return{...n,public_description:""===(nG.public_description||"").trim()?null:nG.public_description,requirements:""===(nG.requirements||"").trim()?null:nG.requirements,responsibilities:""===(nG.responsibilities||"").trim()?null:nG.responsibilities,benefits:l,deadline_date:nG.deadline_date||null,ai_key_competencies:r,mx_location_id:null!==(e=nG.mx_location_id)&&void 0!==e?e:null,country_code:(0,d.$D)(nG.country_code,"MX"),simplify_application:!!nG.simplify_application,simplified_hidden_fields:(0,b.cH)(nG.simplified_hidden_fields),ask_candidate_p
1hone:!1!==nG.ask_candidate_phone,screening_questions_enabled:!!nG.screening_questions_enabled,screening_questions:x(nG.screening_questions),ai_interview_auto_enabled:!!nG.ai_interview_auto_enabled,ai_interview_auto_match_min:(0,h.gh)(nG.ai_interview_auto_match_min),...a}},rP=(0,i.useCallback)(async()=>{var e;let a=(0,p.createClient)(),{data:t}=await a.auth.getSession(),s=null===(e=t.session)||void 0===e?void 0:e.access_token,i={"Content-Type":"application/json"};return s&&(i.Authorization="Bearer ".concat(s)),i},[]),rT=(0,i.useCallback)(async()=>{if(!(null==ez?void 0:ez.id)||i2)return;let e=!i1;i4(!0),i5(e);try{let a=await fetch("/api/positions/".concat(ez.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({show_salary_public:e})}),t=await a.json().catch(()=>({}));if(!a.ok||!t.success){i5(!e),iI.error("Error",t.error||"No se pudo actualizar la visibilidad del salario.");return}eF&&eF({...ez,show_salary_public:e}),iI.success(e?"Salario visible":"Salario oculto",e?"El rango se muestra en la web p\xfablica.":"No aparece en la web p\xfablica. El monto se conserva para forecast y m\xe9tricas.")}catch(a){i5(!e),iI.error("Error","No se pudo actualizar la visibilidad del salario.")}finally{i4(!1)}},[ez,i1,i2,eF,iI]),rq=(0,i.useCallback)(async e=>{if(null==ez?void 0:ez.id){iW(!0);try{if(e){if(iH&&!1!==ez.is_public){let e=await fetch("/api/positions/".concat(ez.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({portal_listed:!0})}),a=await e.json().catch(()=>({}));a.success?(i0(!0),eF&&eF({...ez,portal_listed:!0}),iI.success("En /jobs","Vuelve a salir en el directorio y el buscador.")):iI.error("Error",a.error||"No se pudo actualizar.")}else{var a;let e=await fetch("/api/positions/".concat(ez.id,"/make-public"),{method:"POST"}),t=await e.json().catch(()=>({}));if(t.success&&(null===(a=t.data)||void 0===a?void 0:a.slug)){iK(!0),i0(!0),nr(t.data.slug);let e={...ez,is_public:!0,public_slug:t.data.slug,public_link:t.data.slug,portal_listed:!0};eF&&eF(e),iI.success("En /jobs","La vacante sale en el directorio. Eso no cambia si est\xe1 activa o en borrador.")}else iI.error("Error",t.error||"No se pudo publicar.")}}else{let e=await fetch("/api/positions/".concat(ez.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({portal_listed:!1})}),a=await e.json().catch(()=>({}));a.success?(i0(!1),eF&&eF({...ez,portal_listed:!1}),iI.success("Solo por enlace","La vacante ya no aparece en /jobs; el enlace de abajo sigue v\xe1lido.")):iI.error("Error",a.error||"No se pudo actualizar.")}}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{iW(!1)}}},[ez,iH,eF,iI]),rL=(0,i.useMemo)(()=>{let e=[],a=(nG.public_description||"").trim(),t=(nG.description||"").trim();a||t||e.push("Texto principal o prompt inicial (descripci\xf3n interna)"),(nG.responsibilities||"").trim()||e.push("Responsabilidades"),(nG.requirements||"").trim()||e.push("Requisitos");let s=(nG.benefits_str||"").split("\n").map(e=>e.trim()).filter(Boolean);return 0===s.length&&e.push("Beneficios"),(nG.value_proposition||"").trim()||e.push("Propuesta de valor"),e},[nG]),rO=e=>{iU({title:"Revisa el contenido de la IA",message:tk.Qz,type:"warning",confirmText:"Aceptar",cancelText:"Cancelar",onConfirm:e,onCancel:()=>{}})},rR=async()=>{if(null==ez?void 0:ez.id){if(!nb.current&&"draft"===ez.status&&"active"===nG.status&&rL.length>0){eW(!1),nx(!0),ng("save_active");return}if(!eH.current){eH.current=!0,e2(!0),eW(!1),nb.current=!1;try{let e=await fetch("/api/positions/".concat(ez.id),{method:"PUT",headers:await rP(),body:JSON.stringify(rZ())}),a=await e.json();if(a.success){(0,tk.Hf)(ez.id);let e={...ez,...rz()};eF&&eF(e),iI.success("Guardado","Los cambios se guardaron correctamente."),nY(JSON.stringify(nG))}else iI.error("Error",a.error||"No se pudieron guardar los cambios.")}catch(e){iI.error("Error","No se pudieron guardar los cambios.")}finally{eH.current=!1,e2(!1)}}}},rD=async()=>{if(eW(!1),!(null==ez?void 0:ez.id)||eH.current)return;if(!aA){eX&&iI.error("Vacante bloqueada","Ya hay candidatos postulados;
1 no se pueden cambiar los datos de la vacante.");return}let e=(nG.requirements||"").trim(),a=(nG.responsibilities||"").trim(),t=(nG.benefits_str||"").trim();if((0,tk.An)(ez.id,{requirements:e,responsibilities:a,benefitsLines:t})){rO(()=>{rR()});return}await rR()},rF=async()=>{if(ez){if(!nb.current&&rL.length>0){eW(!1),nx(!0),ng("menu");return}if(!eH.current){eH.current=!0,e2(!0),eW(!1),nb.current=!1;try{let e=await fetch("/api/positions/".concat(ez.id),{method:"PUT",headers:await rP(),body:JSON.stringify(rZ({status:"active"}))}),a=await e.json();if(a.success){(0,tk.Hf)(ez.id);let e={...ez,...rz(),status:"active",id:ez.id};eF&&eF(e),iI.success("Posici\xf3n Publicada","La posici\xf3n ha sido publicada exitosamente"),eI()}else iI.error("Error","No se pudo publicar la posici\xf3n. Por favor intenta de nuevo.")}catch(e){iI.error("Error","No se pudo publicar la posici\xf3n. Por favor intenta de nuevo.")}finally{eH.current=!1,e2(!1)}}}},rM=async()=>{if(eW(!1),!ez||eH.current)return;if(!aA){eX&&iI.error("Vacante bloqueada","Ya hay candidatos postulados; no se pueden cambiar los datos de la vacante.");return}let e=(nG.requirements||"").trim(),a=(nG.responsibilities||"").trim(),t=(nG.benefits_str||"").trim();if((0,tk.An)(ez.id,{requirements:e,responsibilities:a,benefitsLines:t})){rO(()=>{rF()});return}await rF()},rV=()=>{nb.current=!0,nx(!1),ng(null),"menu"===nh?rM():"save_active"===nh&&rD()},rB=async()=>{if(eW(!1),ez&&!eH.current){if(!aA){eX&&iI.error("Vacante bloqueada","Ya hay candidatos postulados; no se pueden cambiar los datos de la vacante.");return}eH.current=!0,e2(!0);try{let e=await fetch("/api/positions/".concat(ez.id),{method:"PUT",headers:await rP(),body:JSON.stringify(rZ({status:"draft"}))}),a=await e.json();if(a.success){let e={...ez,...rz(),status:"draft",id:ez.id};eF&&eF(e),iI.success("Posici\xf3n Despublicada","La posici\xf3n ha sido movida a borradores"),eI()}else iI.error("Error","No se pudo despublicar la posici\xf3n. Por favor intenta de nuevo.")}catch(e){iI.error("Error","No se pudo despublicar la posici\xf3n. Por favor intenta de nuevo.")}finally{eH.current=!1,e2(!1)}}},rU=()=>{eW(!1),ez&&eZ(ez)},rX=async()=>{if(eD&&ez){ag(!0);try{await eD(ez),ai(!1),eI()}catch(e){console.error("Error deleting position:",e)}finally{ag(!1)}}},rG=async()=>{if(ez){aa(!0);try{await eT(ez),e3(!1),eI(),iI.success("Posici\xf3n Cerrada",'La posici\xf3n "'.concat(ez.title,'" ha sido cerrada exitosamente'))}catch(e){iI.error("Error","No se pudo cerrar la posici\xf3n. Por favor intenta de nuevo.")}finally{aa(!1)}}},rJ=e=>{if(!e||aY)return;let a=Array.from(e);if(0===a.length)return;let t=a.filter(e=>tR(e.name)||tD(e.name)),s=a.filter(e=>!tR(e.name)&&!tD(e.name));if(t.length>0){let e=t.find(e=>tD(e.name));if(e&&!t.some(e=>tR(e.name)))iI.error("Formato no soportado","Guarda la hoja como CSV (UTF-8) e imp\xf3rtala. Los archivos .xlsx no se pueden leer aqu\xed.");else{let e=t.find(e=>tR(e.name))||t[0];tz(e)}}0!==s.length&&a2(e=>{let a=[...e,...s],t=new Set,i=[];for(let e of a){let a="".concat(e.name,"|").concat(e.size,"|").concat(e.lastModified);t.has(a)||(t.add(a),i.push(e))}return i})},r$=e=>{a2(a=>a.filter((a,t)=>t!==e))},rY=(0,i.useCallback)((e,a)=>{aN(t=>t.map(t=>t.id===e?{...t,...a}:t))},[]),rW=async e=>{if(!e)return;let a=ab.find(a=>a.id===e),t=!!(null==a?void 0:a.ai_profile);if(!t&&(null==a?void 0:a.cv_url)){await rH(e);return}if(!t){iI.error("Sin perfil IA","Sube un CV nuevo a esta postulaci\xf3n para generar el perfil con IA; luego podr\xe1s recalcular el % de apego.");return}sO(a=>new Set(a).add(e));try{let a=await fetch("/api/applications/".concat(e,"/reanalyze"),{method:"POST"}),t=await a.json();if(!a.ok){let e=t.error||"No se pudo recalcular el apego.",a=t.modelUsed?" Modelo intentado: ".concat(t.modelUsed,"."):"";iI.error("Error al calcular apego",e+a);return}let s=t.data;aN(a=>a.map(a=>{var t,i,n,r,l;return a.id===e?{...a,match_percent:s.match_percent,match_percent_ml:null!==(t=s.match_percent_ml)&&void 0!==t?t:a.match_percent_ml,match_percent_manual_at:null!==(i=s.match_percent_manual_at)&&void 0!==i?i:a.match_percent_manual_at,match_percent_manual_reason:null!==(n=s.match_percent_manual_reason)&&void 0!==n?n:a.match_percent_manual_reason,match_percent_manual_by_name:null!==(r=s.match_percent_manual_by_name)&&void 0!==r?r:a.match_percent_manual_by_name,match_reason:s.match_reason,match_model:s.match_model,match_flags:null!==(l=s.match_flags)&&void 0!==l?l:a.match_flags}:a})),iI.success("Apego actualizado","Se recalcul\xf3 el apego con varias IAs.")}catch(e){iI.error("Error","No se pudo conectar con la IA o hubo un error. Intenta de nuevo.")}finally{sO(a=>
1{let t=new Set(a);return t.delete(e),t})}},rH=async e=>{if(e){sM(a=>new Set(a).add(e));try{let a=await fetch("/api/applications/".concat(e,"/re-extract-profile"),{method:"POST"}),t=await a.json();if(!a.ok){iI.error("Error al re-extraer perfil",t.error||"No se pudo extraer el perfil desde el CV.");return}aN(a=>a.map(a=>{var s,i,n,r,l;return a.id===e?{...a,match_percent:a.match_percent_manual_at?a.match_percent:null!==(s=t.matchPercent)&&void 0!==s?s:a.match_percent,match_percent_ml:null!==(i=t.matchPercent)&&void 0!==i?i:a.match_percent_ml,match_reason:null!==(n=t.matchReason)&&void 0!==n?n:a.match_reason,match_model:null!==(r=t.modelUsed)&&void 0!==r?r:a.match_model,match_flags:null!==(l=t.matchFlags)&&void 0!==l?l:a.match_flags,...t.analysisMeta?{analysisMeta:t.analysisMeta}:{}}:a}));let s=null!=t.matchPercent?" Apego recalculado: ".concat(t.matchPercent,"%."):"";iI.success("Perfil re-extra\xeddo","Se analiz\xf3 el CV con varias IAs y se actualiz\xf3 el perfil.".concat(s))}catch(e){iI.error("Error",tV)}finally{sM(a=>{let t=new Set(a);return t.delete(e),t})}}},rK=e=>{try{let a=new URL(e),t=window.location.origin;if(a.origin!==t)return"".concat(t).concat(a.pathname).concat(a.search).concat(a.hash)}catch(e){}return e},rQ=()=>{if(!(null==ez?void 0:ez.id))return;let e=ab.filter(e=>e.pre_selected_for_client);if(0===e.length){iI.error("Sin pre-aprobados","Marca al menos un candidato como pre-aprobado para cliente (columna con â).");return}let a=e.some(e=>e.shared_with_client),t=new Set;a?e.forEach(e=>{e.shared_with_client&&t.add(e.id)}):e.forEach(e=>t.add(e.id)),s1(t),sQ("select"),sJ(""),sY(null),sX(!0)},r0=e=>{s1(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},r1=async()=>{if(null==ez?void 0:ez.id){sH(!0);try{let e=Array.from(s0),a=await fetch("/api/positions/".concat(ez.id,"/client-portal-candidates"),{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({applicationIds:e})}),t=await a.json().catch(()=>({}));if(!a.ok||!t.success){iI.error("Error","string"==typeof t.error?t.error:"No se pudo guardar la selecci\xf3n.");return}let s=t.preApprovedPortalSnapshot;if(Array.isArray(s)){let e=new Map(s.map(e=>[e.id,e]));aN(a=>a.map(a=>{let t=e.get(a.id);return t?{...a,shared_with_client:t.shared_with_client,shared_with_client_at:t.shared_with_client_at}:a}))}let i=await fetch("/api/positions/".concat(ez.id,"/client-share"),{method:"POST",credentials:"include"}),n=await i.json().catch(()=>({}));if(i.ok&&(null==n?void 0:n.url)){let a="string"==typeof n.url?n.url:"",t=rK(a);a&&t!==a&&iI.success("Enlace corregido","Se ajust\xf3 el dominio del enlace al de este panel (evita enlaces a localhost en producci\xf3n)."),sJ(t),(null==n?void 0:n.pin)&&sY(n.pin),sQ("link"),0===e.length&&iI.success("Selecci\xf3n guardada","El portal no mostrar\xe1 candidatos hasta que incluyas al menos uno en la lista.")}else iI.error("Error",(null==n?void 0:n.error)||"No se pudo generar el enlace.")}catch(e){iI.error("Error","No se pudo completar.")}finally{sH(!1)}}},r5=async(e,a)=>{try{let i=await fetch("/api/applications/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({pre_selected_for_client:!a})}),n=await i.json().catch(()=>({}));if(i.ok&&(null==n?void 0:n.data)){var t,s;let i=n.data;aN(a=>a.map(a=>a.id===e?{...a,...i}:a)),a?(0,e0.SA)((0,e0.U_)({applicationId:e,positionId:null!==(s=null==ez?void 0:ez.id)&&void 0!==s?s:i.position_id,recruitment_stage:String(i.recruitment_stage||""),row:i,pre_selected_for_client:!1})):(0,e0.SA)((0,e0.U_)({applicationId:e,positionId:null!==(t=null==ez?void 0:ez.id)&&void 0!==t?t:i.position_id,recruitment_stage:String(i.recruitment_stage||"client_submission"),row:i,pre_selected_for_client:!0}))}else iI.error("Error",(null==n?void 0:n.error)||"No se pudo actualizar.")}catch(e){iI.error("Error","No se pudo actualizar.")}},r2=(0,i.useMemo)(()=>(0,el.VU)(null==ez?void 0:ez.pipeline_stages),[null==ez?void 0:ez.pipeline_stages]),r4=(0,i.useCallback)(async(e,a)=>{var t,s,i;let n;let r=ab.find(a=>a.id===e),l=null!==(t=null==r?void 0:r.recruitment_stage)&&void 0!==t?t:null;if((0,e1.Dp)(l,a)){let e=await iz({candidateName:String((null==r?void 0:r.candidate_name)||"este candidato"),positionId:null!==(s=null==ez?void 0:ez.id)&&void 0!==s?s:null,defaultClientId:nG.final_client_id||(null==ez?void 0:ez.final_client_id),defaultSalary:Number(nG.salary_max)||Number(nG.salary_min)||0});if(!e)return;n=(0,e1.az)(e)}aN(t=>t.map(t=>
1t.id===e?{...t,recruitment_stage:a}:t));try{let t=await fetch("/api/applications/".concat(e),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({recruitment_stage:a,...n?{placement:n}:{}})}),s=await t.json().catch(()=>({}));if(t.ok&&(null==s?void 0:s.data)){let t=s.data;aN(a=>a.map(a=>a.id===e?{...a,...t}:a)),(0,e0.SA)((0,e0.U_)({applicationId:e,positionId:null!==(i=null==ez?void 0:ez.id)&&void 0!==i?i:t.position_id,recruitment_stage:a,row:t}))}else aN(a=>a.map(a=>a.id===e?{...a,recruitment_stage:l}:a)),iI.error("Error",(null==s?void 0:s.error)||"No se pudo mover de etapa.")}catch(a){aN(a=>a.map(a=>a.id===e?{...a,recruitment_stage:l}:a)),iI.error("Error","No se pudo mover de etapa.")}},[ab,iI,null==ez?void 0:ez.id,null==ez?void 0:ez.final_client_id,nG.final_client_id,nG.salary_max,nG.salary_min,iz]),r3=(0,i.useCallback)(()=>{ik(r2.map(e=>({...e}))),i_(!0)},[r2]),r6=(0,i.useCallback)(async()=>{if(null==ez?void 0:ez.id){iS(!0);try{let a=await fetch("/api/positions/".concat(ez.id,"/pipeline-stages"),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({pipeline_stages:iw})}),t=await a.json().catch(()=>({}));if(a.ok&&(null==t?void 0:t.success)){var e;let a=(0,el.VU)(null===(e=t.data)||void 0===e?void 0:e.pipeline_stages);eF&&eF({...ez,pipeline_stages:a}),i_(!1),iI.success("Etapas actualizadas","El tablero usar\xe1 las nuevas columnas.")}else iI.error("Error",(null==t?void 0:t.error)||"No se pudo guardar.")}catch(e){iI.error("Error","No se pudo guardar.")}finally{iS(!1)}}},[ez,iw,eF,iI]),r9=(0,i.useMemo)(()=>{let e=ab;if(iu&&(e=e.filter(e=>M(e,iu))),ic.trim()){let a=ic.trim().toLowerCase(),t=a.replace(/\D/g,"");e=e.filter(e=>{let s=(e.candidate_name||"").toLowerCase(),i=(e.candidate_email||"").toLowerCase(),n=String(e.candidate_p
1hone||"").toLowerCase();return!!(s.includes(a)||i.includes(a)||n.includes(a))||t.length>=3&&n.replace(/\D/g,"").includes(t)})}for(let a of(il.length>0&&(e=e.filter(e=>{let a=e.labels||[],t=a.map(e=>e.id);return il.some(e=>t.includes(e))})),(s5||s4)&&(e=e.filter(e=>{let a=String(e.application_source||""),t=(0,v.WY)(e);return"linkedin_auto"!==t&&"deep_search"!==t&&("linkedin_sourcing"===a||"linkedin_unipile"===a||"coresignal_sourcing"===a||"pdl_sourcing"===a||"contacts_sheet"===a||"linkedin_sourcing"===t||"coresignal"===t)})),s6&&(e=e.filter(e=>{let a=String(e.application_source||""),t=(0,v.WY)(e);return"deep_search"===a||"deep_search"===t})),s8.length>0&&(e=e.filter(e=>{let a=(0,v.WY)(e);return null!=a&&s8.includes(a)})),ie&&(e=e.filter(e=>(function(e,a){if(!a)return!0;let t=function(e){var a,t;let s=String(e.application_source||""),i=eU.has(s)?null!==(a=e.applied_at)&&void 0!==a?a:e.created_at:null!==(t=e.created_at)&&void 0!==t?t:e.applied_at,n=i?new Date(String(i)).getTime():0;return Number.isNaN(n)?0:n}(e);if(!t)return!1;let s=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return new Date(e.getFullYear(),e.getMonth(),e.getDate())}(),i=s.getTime(),n=new Date(s);n.setDate(n.getDate()-6);let r=new Date(s.getFullYear(),s.getMonth(),1).getTime();switch(a){case"today":return t>=i;case"yesterday":return t>=i-864e5&&t<i;case"week":return t>=n.getTime();case"month":return t>=r;case"older30":return t<i-2592e6;default:return!0}})(e,ie))),eG))it[a]&&(e=e.filter(e=>eJ(e,a)));return e},[ab,ic,il,iu,s5,s4,s6,s8,ie,it]),r8=(0,i.useMemo)(()=>ab.filter(e=>{let a=(0,v.WY)(e);if("linkedin_auto"===a)return!1;let t=String(e.application_source||"");return"linkedin_sourcing"===t||"linkedin_unipile"===t||"linkedin_sourcing"===a}).length,[ab]),r7=(0,i.useMemo)(()=>ab.filter(e=>{let a=String(e.application_source||""),t=(0,v.WY)(e);return"coresignal_sourcing"===a||"pdl_sourcing"===a||"contacts_sheet"===a||"coresignal"===t}).length,[ab]),le=(0,i.useMemo)(()=>ab.filter(e=>{let a=String(e.application_source||""),t=(0,v.WY)(e);return"deep_search"===a||"deep_search"===t}).length,[ab]),la=(0,i.useMemo)(()=>{let e=new Set;for(let a of ab){let t=a.labels||[];for(let a of t)(null==a?void 0:a.id)&&e.add(a.id)}return e},[ab]);(0,i.useEffect)(()=>{io(e=>{let a=e.filter(e=>la.has(e));return a.length===e.length?e:a})},[la]);let lt=(0,i.useMemo)(()=>{let e=new Map;for(let a of ab){let t=(0,v.WY)(a);t&&e.set(t,(e.get(t)||0)+1)}return Array.from(e.entries()).filter(e=>{let[a]=e;return"linkedin_sourcing"!==a&&"coresignal"!==a&&"deep_search"!==a}).map(e=>{let[a,t]=e;return{origin:a,count:t,label:v.Z7[a]}}).sort((e,a)=>a.count-e.count)},[ab]),ls=(0,i.useMemo)(()=>{let e=new Map;for(let a of ab){let t=(0,v.WY)(a);t&&e.set(t,(e.get(t)||0)+1)}return Array.from(e.entries()).map(e=>{let[a,t]=e;return{origin:a,count:t,label:v.Z7[a]}}).sort((e,a)=>a.count-e.count||e.label.localeCompare(a.label,"es"))},[ab]),li=(0,i.useMemo)(()=>{let e=0,a=0;for(let t of ab)M(t,"shared_with_client")&&e++,M(t,"preapproved_not_sent")&&a++;return{shared_with_client:e,preapproved_not_sent:a}},[ab]);(0,i.useEffect)(()=>{nv(new Set)},[null==ez?void 0:ez.id,ic,il,iu,s5,s4,s6,s8,ie,it]),(0,i.useEffect)(()=>{ix("match"),ig("desc")},[null==ez?void 0:ez.id]),(0,i.useEffect)(()=>{im(null),s7([]),s2(!1),s3(!1),s9(!1),ia(null),is({})},[null==ez?void 0:ez.id]);let ln=(0,i.useCallback)(e=>{ip===e?ig(e=>"asc"===e?"desc":"asc"):(ix(e),ig("name"===e?"asc":"desc"))},[ip]),lr=(0,i.useMemo)(()=>{let e=[...r9];return e.sort((e,a)=>{let t=function(e,a,t,s){let i="asc"===s?1:-1;switch(t){case"name":{let t=String(e.candidate_name||"").toLowerCase(),s=String(a.candidate_name||"").toLowerCase();return t.localeCompare(s,"es",{sensitivity:"base"})*i}case"date":return(tU(e)-tU(a))*i;case"match":{let t="number"==typeof e.match_percent?e.match_percent:-1,s="number"==typeof a.match_percent?a.match_percent:-1;return(t-s)*i}case"cv":{let t=e.cv_url?1:0,s=a.cv_url?1:0;return(t-s)*i}case"client":{let t=(e.shared_with_client?2:0)+(e.pre_selected_for_client?1:0),s=(a.shared_with_client?2:0)+(a.pre_selected_for_client?1:0);return(t-s)*i}default:return 0}}(e,a,ip,ih);if(0!==t)return t;let s="number"==typeof e.match_percent?e.match_percent:-1,i="number"==typeof a.match_percent?a.match_percent:-1;return i!==s?i-s:String(e.candidate_name||"").localeCompare(String(a.candidate_name||""),"es",{sensitivity:"base"})}),e},[r9,ip,ih]),ll=(0,i.useMemo)(()=>r9.map(e=>e.id),[r9]),lo=(0,i.useMemo)(()=>r9.filter(e=>nf.has(e.id)).length,[r9,nf]),lc=r9.length>0&&lo===r9.length,ld=lo>0&&!lc;(0,i.useEffect)(()=>{let e=nZ.current;e&&(e.indeterminate=ld)},[ld]);let lu=(0,i.useCallback)(async()=>{try{var e,a;let t=(0,p.createClient)(),{data:s}=await t.auth.getSession();return null!==(a=null===(e=s.session)||void 0===e?void 0:e.access_token)&&void 0!==a?a:null}catch(e){return null}},[]),lm=(0,i.useMemo)(()=>ab.filter(e=>nf.has(e.id)).map(e=>{var a;
1return{id:e.id,candidate_name:e.candidate_name,candidate_phone:e.candidate_phone,position_id:null!==(a=null==ez?void 0:ez.id)&&void 0!==a?a:e.position_id}}),[ab,nf,null==ez?void 0:ez.id]);if(!eE||!ez)return null;let lp=async()=>{if(ab.length&&(null==ez?void 0:ez.id)&&!sR){sD(!0),t1(ez.id);try{let a=ab.map(e=>e.id),t=await fetch("/api/applications/reanalyze-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,applicationIds:a})}),s=await t.json().catch(()=>({}));if(!t.ok||!s.success){iI.error("Error",(null==s?void 0:s.error)||"No se pudo encolar el re-an\xe1lisis de apego.");return}if(s.queued&&s.jobId){var e;tQ(!0),t2({processed:0,total:Number(s.totalRequested||a.length),step:"queued"});let t=String(s.jobId);null===(e=sd.current)||void 0===e||e.abort(),sd.current=new AbortController,su.current=t;let i=null;try{i=await tT(t,(e,a,t)=>{t2({processed:e,total:a,step:t})},{signal:sd.current.signal})}finally{su.current=null}if(tQ(!1),t2(null),!(null==i?void 0:i.job)){iI.error("Error","Tiempo de espera agotado al consultar el lote de re-an\xe1lisis.");return}let n=Number(i.job.success_files||0);n>0?(await rd(),iI.success("Listo","Se recalcul\xf3 el apego de ".concat(n," candidato(s)."))):iI.error("Error",tM(i.job));return}await rd(),iI.success("Listo","Re-an\xe1lisis de apego completado.")}catch(e){iI.error("Error",tV)}finally{sD(!1),t1(null)}}},lx=e=>{nv(a=>{let t=new Set(a);return t.has(e)?t.delete(e):t.add(e),t})},lh=()=>nv(new Set),lg=async()=>{if((null==ez?void 0:ez.id)&&0!==nf.size){ny(!0);try{let a=await fetch("/api/applications/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,action:"delete",applicationIds:Array.from(nf)})}),t=await a.json().catch(()=>({}));if(a.ok&&t.success){var e;let a=new Set(nf);aN(e=>e.filter(e=>!a.has(e.id))),nv(new Set),nE(!1),iI.success("Eliminados","".concat(null!==(e=t.deleted)&&void 0!==e?e:a.size," candidato(s) quitados de la vacante."))}else iI.error("Error",(null==t?void 0:t.error)||"No se pudo eliminar.")}catch(e){iI.error("Error","No se pudo eliminar.")}finally{ny(!1)}}},lb=async e=>{if((null==ez?void 0:ez.id)&&0!==nf.size){ny(!0);try{let a=Array.from(nf),t=await fetch("/api/applications/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,action:"update",applicationIds:a,updates:{pre_selected_for_client:e}})}),s=await t.json().catch(()=>({}));if(t.ok&&s.success){let t=new Set(a),i=Array.isArray(s.data)?s.data:[],n=new Map(i.map(e=>[e.id,e]));if(aN(a=>a.map(a=>{if(!t.has(a.id))return a;let s=n.get(a.id);return s?{...a,...s}:{...a,pre_selected_for_client:e,...e?{}:{shared_with_client:!1,shared_with_client_at:null}}})),e)for(let e of a){let a=n.get(e);a&&(0,e0.SA)((0,e0.U_)({applicationId:e,positionId:ez.id,recruitment_stage:String(a.recruitment_stage||"client_submission"),row:a,pre_selected_for_client:!0}))}iI.success("Actualizado","Pre-selecci\xf3n cliente ".concat(e?"activada":"quitada"," en ").concat(a.length," candidato(s)."))}else iI.error("Error",(null==s?void 0:s.error)||"No se pudo actualizar.")}catch(e){iI.error("Error","No se pudo actualizar.")}finally{ny(!1)}}},lf=async function(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"recruiter";if((null==ez?void 0:ez.id)&&0!==e.length){nk("Enviando enlaces de entrevista por correoâ¦"),n_(!0);try{let t=await fetch("/api/positions/".concat(ez.id,"/send-interview-links"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({applicationIds:e,mode:a})}),s=await t.json().catch(()=>({}));if(t.ok&&s.success){let e=[];"number"==typeof s.sent&&e.push("".concat(s.sent," enviado(s)"));let a=s.skipped,t=s.failed;(null==a?void 0:a.length)&&e.push("".concat(a.length," sin email o no v\xe1lidos")),(null==t?void 0:t.length)&&e.push("".concat(t.length," error(es) al enviar")),iI.success("Enlace de entrevista",e.join(" \xb7 ")||s.message||"Listo.")}else{let e=(null==s?void 0:s.code)==="no_calendar"?"Conecta tu Google Calendar en tu perfil antes de enviar enlaces de entrevista.":(null==s?void 0:s.error)||"Error desconocido.";iI.error("No se pudo enviar",e)}}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{n_(!1),nk(null)}}},lv=async e=>{if(!(null==ez?void 0:ez.id)||0===e.length)return;let a=e.slice(0,20),t=a.filter(e=>{let a=ab.find(a=>a.id===e);return!!String((null==a?void 0:a.candidate_email)||"").trim()}),s=a.length-t.length;if(0===t.length){iI.error("Invitar a postularse","Ninguno de los seleccionados tiene correo. Extrae la ficha completa o usa WhatsApp si hay tel\xe9fono.");return}let i=e.length>20?"\n\nSolo se env\xedan los primeros ".concat(20," para no spamear."):"";iU({title:"Invitar a postularse",message:["Se env\xeda un correo a ".concat(t.length," candidato").concat(1===t.length?"":"s"," con el enlace de la vacante."),"Siguen en Identificado hasta que ellos se postulen (entonces pasan a Postul\xf3).",s>0?"\n".concat(s," sin correo se omiten."):"",i,"","\xbfEnviar las invitaciones?"].filter(e=>""!==e).join("\n"),type:"info",confirmText:1===t.length?"S\xed, enviar":"S\xed, enviar ".concat(t.length),c
1ancelText:"Cancelar",onConfirm:()=>{(async()=>{nk("Enviando invitaciones a postularseâ¦"),n_(!0);try{let e=await (0,a_.U)("/api/positions/".concat(ez.id,"/invite-to-apply"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applicationIds:t})}),a=await e.json().catch(()=>({}));if(e.ok&&a.success){let e=[];"number"==typeof a.sent&&e.push("".concat(a.sent," enviado(s)"));let t=a.skipped,s=a.failed;(null==t?void 0:t.length)&&e.push("".concat(t.length," sin correo")),(null==s?void 0:s.length)&&e.push("".concat(s.length," error(es)")),iI.success("Invitar a postularse",e.join(" \xb7 ")||a.message||"Listo.")}else iI.error("No se pudo enviar",(null==a?void 0:a.error)||"Error desconocido.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{n_(!1),nk(null)}})()}})},lj=async e=>{if(!(null==ez?void 0:ez.id)||0===e.length)return;let a=e.slice(0,20),t=a.filter(e=>{let a=ab.find(a=>a.id===e);return!!String((null==a?void 0:a.candidate_linkedin)||"").trim()}),s=a.length-t.length;if(0===t.length){iI.error("Invitar por LinkedIn","Ninguno de los seleccionados tiene URL de LinkedIn.");return}let i=e.length>20?"\n\nSolo se env\xedan los primeros ".concat(20,"."):"";async function n(e){nk("Enviando invitaciones por LinkedInâ¦"),n_(!0);try{let a=await (0,a_.U)("/api/positions/".concat(ez.id,"/invite-linkedin"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applicationIds:t,autoSequence:e})}),s=await a.json().catch(()=>({}));if(a.ok&&s.success){let a=[];"number"==typeof s.sent&&a.push("".concat(s.sent," enviado(s)"));let t=s.skipped,i=s.failed;if((null==t?void 0:t.length)&&a.push("".concat(t.length," omitido(s)")),(null==i?void 0:i.length)&&a.push("".concat(i.length," error(es)")),e&&a.push("seguimiento ON"),iI.success("LinkedIn",a.join(" \xb7 ")||s.message||"Listo."),null==i?void 0:i.length){let e=i[0];iI.error("Algunos fallaron",(null==e?void 0:e.reason)||"Revisa l\xedmites de LinkedIn.")}}else iI.error("No se pudo enviar",(null==s?void 0:s.error)||"Error desconocido.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{n_(!1),nk(null)}}iU({title:"Invitar por LinkedIn",message:["Se env\xeda desde tu LinkedIn a ".concat(t.length," candidato").concat(1===t.length?"":"s","."),"Si ya son conexi\xf3n â mensaje con el enlace. Si no â invitaci\xf3n de conexi\xf3n con nota corta.",s>0?"\n".concat(s," sin LinkedIn se omiten."):"",i,"","\xbfActivar seguimiento autom\xe1tico? (presentaci\xf3n â postular â follow-up)"].filter(e=>""!==e).join("\n"),type:"info",confirmText:"Con seguimiento",altConfirmText:"Solo invitar",cancelText:"Cancelar",onConfirm:()=>{n(!0)},onAltConfirm:()=>{n(!1)}})},ly=async e=>{if(!(null==ez?void 0:ez.id)||0===e.length)return;let a=e.slice(0,20),t=a.filter(e=>{let a=ab.find(a=>a.id===e);return!!String((null==a?void 0:a.candidate_linkedin)||"").trim()}),s=a.length-t.length;if(0===t.length){iI.error("Invitar a conectar","Ninguno de los seleccionados tiene URL de LinkedIn.");return}let i=e.length>20?"\n\nSolo se env\xedan los primeros ".concat(20,"."):"";async function n(e){nk("Enviando invitaciones a conectar por LinkedInâ¦"),n_(!0);try{let a=await (0,a_.U)("/api/positions/".concat(ez.id,"/invite-linkedin"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({applicationIds:t,mode:"connect",autoSequence:e})}),s=await a.json().catch(()=>({}));if(a.ok&&s.success){let a=[];"number"==typeof s.sent&&a.push("".concat(s.sent," enviado(s)"));let t=s.skipped,i=s.failed;if((null==t?void 0:t.length)&&a.push("".concat(t.length," omitido(s)")),(null==i?void 0:i.length)&&a.push("".concat(i.length," error(es)")),e&&a.push("seguimiento ON"),iI.success("LinkedIn",a.join(" \xb7 ")||s.message||"Listo."),null==i?void 0:i.length){let e=i[0];iI.error("Algunos fallaron",(null==e?void 0:e.reason)||"Revisa l\xedmites de LinkedIn.")}}else iI.error("No se pudo enviar",(null==s?void 0:s.error)||"Error desconocido.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{n_(!1),nk(null)}}iU({title:"Invitar a conectar (LinkedIn)",message:["Se enviar\xe1 invitaci\xf3n de conexi\xf3n a ".concat(t.length," candidato").concat(1===t.length?"":"s","."),"Si ya son conexi\xf3n, se omiten (o arranca el seguimiento desde presentaci\xf3n).",s>0?"\n".concat(s," sin LinkedIn se omiten."):"",i,"","\xbfActivar seguimiento autom\xe1tico? (presentaci\xf3n â postular â follow-up)"].filter(e=>""!==e).join("\n"),type:"info",confirmText:"Con seguimiento",altConfirmText:"Solo conectar",cancelText:"Cancelar",onConfirm:()=>{n(!0)},onAltConfirm:()=>{n(!1)}})},lN=async e=>{if(0===e.length)return;let a=[],t=[];for(let s of e){let e=ab.find(e=>e.id===s);(0,V.z)(null==e?void 0:e.candidate_name)?a.push(s):t.push(s)}if(0===a.length){iI.error("Falta el nombre",1===t.length?"Abre la ficha del candidato y pon su nombre antes de invitar a Camila.":"Ninguno de los seleccionados tiene nombre. Compl\xe9talo en la ficha antes de invitar a Camila.");return}let s=a.length;iU({title:"Entrevista IA con Camila",message:["Se env\xeda correo y WhatsApp a ".concat(s," candidato").concat(1===s?"":"s"," con el enlace de Camila, igual que una invitaci\xf3n individual."),t.length?"\nSe omiten ".concat(t.length," sin nombre (compl\xe9talo en la ficha)."):"","","\xbfEnviar las invitaciones?"].filter(
1Boolean).join("\n"),type:"info",confirmText:1===s?"S\xed, enviar":"S\xed, enviar ".concat(s),cancelText:"Cancelar",onConfirm:()=>{(async()=>{nk("Enviando invitaciones de Camilaâ¦"),n_(!0);let e=0,s=[];try{for(let t of a){let a=ab.find(e=>e.id===t),i=await fetch("/api/applications/".concat(encodeURIComponent(t),"/ai-interview"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({candidateName:String((null==a?void 0:a.candidate_name)||"").trim()||void 0})}),n=await i.json().catch(()=>({}));i.ok&&n.success?e+=1:s.push("string"==typeof n.error?n.error:"Error")}let i=[];e&&i.push("".concat(e," invitaci\xf3n(es)")),s.length&&i.push("".concat(s.length," no se pudo")),t.length&&i.push("".concat(t.length," sin nombre omitido(s)")),e?iI.success("Entrevista IA",i.join(" \xb7 ")||"Invitaciones enviadas."):iI.error("Entrevista IA",s[0]||"No se pudo enviar. Revisa que Camila est\xe9 activa para esta empresa.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{n_(!1),nk(null)}})()},onCancel:()=>{}})},l_=async(e,a)=>{try{let t=await fetch("/api/applications/".concat(e,"/cv-reminders"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a})}),s=await t.json().catch(()=>({}));if(!t.ok||!s.success){iI.error("Recordatorios de CV","string"==typeof s.error?s.error:"No se pudo actualizar.");return}aN(t=>t.map(t=>t.id===e?{...t,cv_reminders_enabled:"resume"===a}:t)),iI.success("Recordatorios de CV","stop"===a?"Se detuvieron los recordatorios de esta postulaci\xf3n.":"Se reactivaron los recordatorios.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}},lw=async(e,a)=>{try{let t=await fetch("/api/applications/".concat(e,"/screening-reminders"),{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:a})}),s=await t.json().catch(()=>({}));if(!t.ok||!s.success){iI.error("Recordatorios de preguntas","string"==typeof s.error?s.error:"No se pudo actualizar.");return}aN(t=>t.map(t=>t.id===e?{...t,screening_reminders_enabled:"resume"===a}:t)),iI.success("Recordatorios de preguntas","stop"===a?"Se detuvieron los recordatorios de esta postulaci\xf3n.":"Se reactivaron los recordatorios.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}},lk=async e=>{if(!e)return;let a=ab.find(a=>a.id===e),t=((null==a?void 0:a.candidate_name)||"este candidato").trim()||"este candidato",s=((null==ez?void 0:ez.title)||"esta vacante").trim()||"esta vacante";iU({title:"Enviar preguntas de la posici\xf3n",message:"Se enviar\xe1 un correo a ".concat(t," con el enlace para responder las preguntas de ").concat(s,".\n\n\xbfConfirm\xe1s el env\xedo?"),type:"info",confirmText:"Enviar",cancelText:"Cancelar",onConfirm:()=>{(async()=>{try{let a=await fetch("/api/applications/".concat(e,"/screening/resend"),{method:"POST",credentials:"include"}),t=await a.json().catch(()=>({}));a.ok&&t.success?iI.success("Preguntas enviadas",t.message||"Correo enviado al candidato."):iI.error("No se pudo enviar","string"==typeof(null==t?void 0:t.error)?t.error:"Intenta de nuevo.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}})()},onCancel:()=>{}})},lC=async()=>{if((null==ez?void 0:ez.id)&&aA&&!sw){sk(!0);try{let e=await fetch("/api/ai/generate-screening-questions",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,apply:!1})}),a=await e.json().catch(()=>({}));if(!e.ok||!a.success){iI.error(402===e.status?"Sin cr\xe9ditos IA":"No se pudieron generar","string"==typeof(null==a?void 0:a.error)?a.error:"Intenta de nuevo.");return}let t=x(a.questions);if(0===t.length){iI.error("Sin preguntas","La IA no devolvi\xf3 preguntas \xfatiles.");return}ry("screening_questions_enabled",!0),ry("screening_questions",t),s_(!1),iI.success("Preguntas generadas","".concat(t.length," preguntas listas. Revisa cu\xe1les quieres marcar como eliminatorias y guarda la vacante. (1 cr\xe9dito IA)"))}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{sk(!1)}}},lS=async e=>{if((null==ez?void 0:ez.id)&&0!==nf.size){ny(!0);try{let a=Array.from(nf),t=await fetch("/api/applications/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,action:"add_labels",applicationIds:a,labelIds:[e.id]})}),s=await t.json().catch(()=>({}));
1if(t.ok&&s.success){let t=new Set(a);aN(a=>a.map(a=>{if(!t.has(a.id))return a;let s=Array.isArray(a.labels)?a.labels:[];return s.some(a=>a.id===e.id)?a:{...a,labels:[...s,e]}})),iI.success("Etiqueta aplicada","\xab".concat(e.name,"\xbb en ").concat(a.length," candidato(s)."))}else iI.error("Error",(null==s?void 0:s.error)||"No se pudo aplicar la etiqueta.")}catch(e){iI.error("Error","No se pudo aplicar la etiqueta.")}finally{ny(!1)}}},lA=async e=>{if((null==ez?void 0:ez.id)&&0!==nf.size){ny(!0);try{let a=Array.from(nf),t=await fetch("/api/applications/bulk",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,action:"update",applicationIds:a,updates:{status:e}})}),s=await t.json().catch(()=>({}));if(t.ok&&s.success){let t=new Set(a);aN(a=>a.map(a=>t.has(a.id)?{...a,status:e}:a)),iI.success("Estado actualizado","".concat(a.length," candidato(s) actualizados."))}else iI.error("Error",(null==s?void 0:s.error)||"No se pudo actualizar el estado.")}catch(e){iI.error("Error","No se pudo actualizar el estado.")}finally{ny(!1)}}},lE=async()=>{if(!nf.size||!(null==ez?void 0:ez.id)||nC||sR)return;let e=Array.from(nf);nS(!0),t1(ez.id);try{let t=await fetch("/api/applications/reanalyze-batch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({positionId:ez.id,applicationIds:e})}),s=await t.json().catch(()=>({}));if(!t.ok||!s.success){iI.error("Error",(null==s?void 0:s.error)||"No se pudo encolar el re-an\xe1lisis de apego.");return}if(s.queued&&s.jobId){var a;tQ(!0),t2({processed:0,total:Number(s.totalRequested||e.length),step:"queued"});let t=String(s.jobId);null===(a=sd.current)||void 0===a||a.abort(),sd.current=new AbortController,su.current=t;let i=null;try{i=await tT(t,(e,a,t)=>{t2({processed:e,total:a,step:t})},{signal:sd.current.signal})}finally{su.current=null}if(tQ(!1),t2(null),!(null==i?void 0:i.job)){iI.error("Error","Tiempo de espera agotado al consultar el lote de re-an\xe1lisis.");return}let n=Number(i.job.success_files||0);n>0?(await rd(),iI.success("Listo","Se recalcul\xf3 el apego de ".concat(n," candidato(s) seleccionado(s)."))):iI.error("Error",tM(i.job));return}await rd(),iI.success("Listo","Re-an\xe1lisis de apego completado.");return}catch(e){iI.error("Error",tV)}finally{nS(!1),t1(null)}};if(!ez)return null;let lI=t0===ez.id&&(sR||nC||tK),lz=iH&&nn?(0,o.hM)("/jobs/".concat(nn)):null,lZ=ez.public_code?(0,o.hM)("/p/".concat(ez.public_code)):null,lP=String(ez.public_slug||ez.public_link||nn||"").trim();return(0,s.jsxs)("div",{className:"fixed inset-0 z-[100] overflow-hidden",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-black bg-opacity-50 transition-opacity",onClick:eI}),(0,s.jsx)("div",{className:"absolute right-0 top-0 h-full bg-white shadow-xl transition-[width]",style:{width:ib?"100%":"min(100%, max(58vw, 48rem))",maxWidth:ib?"100%":"72rem"},children:(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 border-b px-4 py-4 sm:px-6 sm:py-5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start gap-3",children:[(0,s.jsx)("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-blue-100",children:(0,s.jsx)(a3.Z,{className:"h-5 w-5 text-blue-600"})}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[aA?(0,s.jsx)("input",{type:"text",value:nG.title,onChange:e=>ry("title",e.target.value),className:"w-full min-w-0 bg-transparent text-lg font-semibold text-gray-900 border-b border-gray-300 focus:border-blue-500 focus:outline-none sm:text-xl"}):(0,s.jsx)("h2",{className:"break-words text-lg font-semibold text-gray-900 sm:text-xl",children:null!==(Y=null==ez?void 0:ez.title)&&void 0!==Y?Y:""}),(0,s.jsxs)("div",{className:"flex items-center flex-wrap gap-x-2 gap-y-1",children:[(0,s.jsxs)("p",{className:"text-sm text-gray-500",children:["Codigo: ",(0,tC.N8)(ez),ez.public_code?(0,s.jsx)("span",{className:"ml-2 font-mono tracking-wide text-gray-700",children:ez.public_code}):null]}),(null==ez?void 0:ez.status)&&(0,s.jsx)(y.C,{variant:"published"===ez.status?"default":"draft"===ez.status?"secondary":"outline",className:"text-xs",children:"active"===ez.status?"Activa":"draft"===ez.status?"Borrador":"Cerrada"}),(0,s.jsx)(tI.O,{position:{status:ez.status,is_public:iH,portal_listed:iQ},onDraftPublish:"draft"===ez.status?()=>{if(ez&&"draft"===ez.status){if(!aA){eX&&iI.error("Vacante bloqueada","Ya hay candidatos postulados;
1 no se pueden cambiar los datos de la vacante.");return}iU({title:"Publicar posici\xf3n",message:"\xbfDeseas publicar esta vacante? Dejar\xe1 de ser un borrador y podr\xe1 verse seg\xfan la visibilidad configurada.",type:"info",confirmText:"Publicar",cancelText:"Cancelar",onConfirm:()=>{rM()},onCancel:()=>{}})}}:void 0,draftPublishDisabled:e5})]})]}),(0,s.jsx)(j.z,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:eI,"aria-label":"Cerrar",children:(0,s.jsx)(ae.Z,{className:"h-5 w-5"})})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[ez&&!eX&&(!aC||aw)&&(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:rU,title:"Editar ficha de la vacante","aria-label":"Editar ficha de la vacante",children:(0,s.jsx)(a6.Z,{className:"h-4 w-4","aria-hidden":!0})}),aA&&(nK||!!(nG.description||"").trim()&&!(nG.public_description||"").trim())&&(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",disabled:sV,className:"h-9 w-9 shrink-0 border-violet-200 bg-violet-50/60 text-violet-900 hover:bg-violet-100/90 disabled:opacity-50",onClick:e=>{e.stopPropagation(),nK?rE():rI()},title:nK?"Prompt modificado: una confirmaci\xf3n y regenera borrador p\xfablico con IA (Guardar para persistir).":"Texto p\xfablico vac\xedo: doble confirmaci\xf3n y regenera desde el prompt (Guardar para persistir).","aria-label":"Regenerar borrador con IA",children:sV?(0,s.jsx)(G.Z,{className:"h-4 w-4 shrink-0 animate-spin","aria-hidden":!0}):(0,s.jsx)(ay.Z,{className:"h-4 w-4 shrink-0","aria-hidden":!0})}),(0,s.jsxs)(ex.h_,{children:[(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsxs)(j.z,{type:"button",variant:"outline",className:"h-9 shrink-0 gap-1.5",title:"Compartir","aria-label":"Compartir",children:[(0,s.jsx)(Z.Z,{className:"h-4 w-4","aria-hidden":!0}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Compartir"}),(0,s.jsx)(S.Z,{className:"h-4 w-4 opacity-70","aria-hidden":!0})]})}),(0,s.jsxs)(ex.AW,{align:"end",className:"z-[110] w-56",children:[(0,s.jsxs)(ex.Xi,{disabled:!lP,onClick:()=>{if(!lP)return;let e="/dashboard/jobs-preview/".concat(encodeURIComponent(lP)),a="/jobs/".concat(encodeURIComponent(lP)),t="draft"===ez.status||!iH||"active"!==ez.status,s=t?"".concat(window.location.origin).concat(e):(0,o.hM)(a);window.open(s,"_blank","noopener,noreferrer")},children:[(0,s.jsx)(ej.Z,{className:"w-4 h-4 mr-2","aria-hidden":!0}),"Ver vacante"]}),lZ?(0,s.jsxs)(ex.Xi,{onClick:()=>{navigator.clipboard&&(navigator.clipboard.writeText(lZ),iI.success("URL corta copiada",lZ.replace(/^https?:\/\//,"")),(0,tS.L9)("position_short_url_copied",{position_id:ez.id,public_code:ez.public_code||"",source:"drawer"}))},children:[(0,s.jsx)(H.Z,{className:"w-4 h-4 mr-2","aria-hidden":!0}),"Copiar URL"]}):lz?(0,s.jsxs)(ex.Xi,{onClick:()=>{navigator.clipboard&&(navigator.clipboard.writeText(lz),iI.success("Copiado","URL p\xfablica copiada al portapapeles."))},children:[(0,s.jsx)(w.Z,{className:"w-4 h-4 mr-2","aria-hidden":!0}),"URL p\xfablica"]}):null,(0,s.jsxs)(ex.Xi,{onClick:()=>{eW(!1),ez&&(null==eO||eO(ez)),rQ()},children:[(0,s.jsx)(P.Z,{className:"w-4 h-4 mr-2","aria-hidden":!0}),"URL para cliente"]}),lZ||lz?(0,s.jsxs)(ex.Xi,{onClick:()=>{let e=lZ||lz;if(!e)return;let a="https://wa.me/?text=".concat(encodeURIComponent("Te comparto esta vacante: ".concat(e)));window.open(a,"_blank","noopener,noreferrer")},children:[(0,s.jsx)(Z.Z,{className:"w-4 h-4 mr-2","aria-hidden":!0}),"WhatsApp"]}):null]})]}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>iM(!0),title:"Vistas y campa\xf1as","aria-label":"Vistas y campa\xf1as",children:(0,s.jsx)(ap.Z,{className:"h-4 w-4","aria-hidden":!0})}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>iB(!0),title:"Auditor\xeda de la vacante","aria-label":"Auditor\xeda de la vacante",children:(0,s.jsx)(a9.Z,{className:"h-4 w-4","aria-hidden":!0})}),(0,s.jsxs)("div",{className:"relative shrink-0",ref:i$,children:[(0,s.jsxs)(j.z,{type:"button",variant:"outline",onClick:()=>eW(!eY),disabled:e5,className:"h-9 shrink-0 hover:bg-gray-100","aria-expanded":eY,"aria-haspopup":"menu","aria-label":"Acciones",children:[e5?(0,s.jsx)(G.Z,{className:"h-4 w-4 sm:mr-2 animate-spin","aria-hidden":!0}):(0,s.jsx)(a8.Z,{className:"h-4 w-4 sm:mr-2","aria-hidden":!0}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Acciones"})]}),eY&&(0,s.jsx)("div",{className:"absolute right-0 top-full mt-2 w-52 bg-white border rounded-lg shadow-lg z-50",children:(0,s.jsxs)("div",{className:"py-1",children:[(0,s.jsxs)("button",{onClick:()=>{ez&&eR(ez),eW(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100",children:[(0,s.jsx)(a7.Z,{className:"w-4 h-4 mr-3"}),"Descargar"]}),(0,s.jsxs)("button",{type:"button",onClick:()=>{eW(!1),iD(!0)},className:"flex items-center w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100",children:[(0,s.jsx)(ef.Z,{className:"w-4 h-4 mr-3"}),"Recordatorios"]}),nf.size>0?(0,s.jsxs)("button",{type:"button",onClick:()=>{eW(!1),lN(Array.from(nf))},disabled:nN||nj,className:"flex items-center w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 disabled:opacity-50",children:[(0,s.jsx)(ay.Z,{className:"w-4 h-4 mr-3 text-teal-700"}),"Entrevista IA (",nf.size,")"]}):null,(0,s.jsxs)("button",{onClick:()=>{ez&&eq(ez),eW(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100",children:[(0,s.jsx)(te.Z,{className:"w-4 h-4 mr-3","aria-hidden":!0}),"closed"===ez.status?"Duplicar a borrador":"Duplicar"]}),aA?null:!eX&&(!aC||aw)&&(0,s.jsxs)("button",{type:"button",onClick:rU,className:"flex items-center w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100",children:[(0,s.jsx)(ta.Z,{className:"w-4 h-4 mr-3"}),"Editar ficha"]}),"active"===ez.status&&aA&&(0,s.jsxs)("button",{type:"button",onClick:()=>void rB(),disabled:e5,className:"flex items-center w-full px-4 py-2 text-sm text-orange-600 hover:bg-orange-50 disabled:opacity-50 disabled:pointer-events-none",children:[(0,s.jsx)(ej.Z,{className:"w-4 h-4 mr-3"}),"Pausar publicaci\xf3n"]}),"draft"===ez.status&&(null!==(W=ez.applications_count)&&void 0!==W?W:0)===0&&eD&&(0,s.jsxs)("button",{onClick:()=>{ai(!0),eW(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-red-600 hover:bg-red-50",children:[(0,s.jsx)(an.Z,{className:"w-4 h-4 mr-3"}),"Eliminar borrador"]}),"closed"!==ez.status&&(0,s.jsxs)("button",{onClick:()=>{e3(!0),eW(!1)},className:"flex items-center w-full px-4 py-2 text-sm text-orange-600 hover:bg-orange-50",children:[(0,s.jsx)(ae.Z,{className:"w-4 h-4 mr-3"}),"Cerrar Posici\xf3n"]})]})})]}),aA&&(n0||e5)?(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",className:"h-9 w-9 shrink-0 text-green-700 border-green-200 hover:bg-green-50",onClick:()=>void rD(),disabled:e5,title:e5?"Guardandoâ¦":"Guardar cambios","aria-label":e5?"Guardando":"Guardar cambios",children:e5?(0,s.jsx)(G.Z,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):(0,s.jsx)(tt.Z,{className:"h-4 w-4","aria-hidden":!0})}):null,(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",className:"hidden h-9 w-9 shrink-0 sm:inline-flex",onClick:()=>iv(e=>!e),title:ib?"Reducir ancho del panel":"Ancho completo (Kanban)","aria-label":ib?"Reducir ancho del panel":"Ancho completo",children:ib?(0,s.jsx)(ts.Z,{className:"h-4 w-4","aria-hidden":!0}):(0,s.jsx)(ti.Z,{className:"h-4 w-4","aria-hidden":!0})})]})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[(0,s.jsxs)(N.Zb,{className:"overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>sb(!sg),className:"w-full flex items-center justify-between gap-2 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!sg,"aria-controls":"position-drawer-basic-info",children:[(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base font-semibold",children:[(0,s.jsx)(E.Z,{className:"w-5 h-5 shrink-0"}),(0,s.jsx)("span",{children:"Informaci\xf3n B\xe1sica"})]}),sg?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]}),!sg&&(0,s.jsxs)(N.aY,{id:"position-drawer-basic-info",className:"space-y-4 pt-0",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{className:"col-span-2",children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500 flex items-center gap-1 mb-1",children:[(0,s.jsx)(tn.Z,{className:"w-4 h-4"})," Ubicaci\xf3n"]}),aA?Object.keys(n4).length>0?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-xs text-gray-500 mb-1 block",children:"Pa\xeds"}),(0,s.jsxs)(tN.Ph,{value:n2,onValueChange:e=>{let a=(0,d.$D)(e,"MX");ry("country_code",a),rt(""),ri(""),rr(""),ro(""),ry("location",""),ry("mx_location_id",null)},children:[(0,s.jsx)(tN.i4,{className:"text-sm h-9",children:(0,s.jsx)(tN.ki,{placeholder:"Pa\xeds"})}),(0,s.jsx)(tN.Bw,{children:d.mb.map(e=>(0,s.jsx)(tN.Ql,{value:e,children:d.ZN[e]},e))})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-xs text-gray-500 mb-1 block",children:n3}),(0,s.jsx)(tE.V,{value:ra,onValueChange:e=>{rt(e),ro(""),n6?(ri(""),rr(""),rN(e,"","","")):(ri(e),rr(""),rN(e,e,"",""))},options:rw,placeholder:"Selecciona ".concat(n3.toLowerCase()),"aria-label":"".concat(n3," (").concat(d.ZN[n2],")"),searchPlaceholder:"Buscar ".concat(n3.toLowerCase(),"â¦"),className:"text-sm"})]})]}),n6&&ra&&ra!==tF&&(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[(0,s.jsx)(tE.V,{value:rs,onValueChange:e=>{ri(e),rr(""),rN(ra,e,"","")},options:rk,placeholder:"Ciudad","aria-label":"Ciudad",searchPlaceholder:"Buscar ciudadâ¦",emptyText:"Sin ciudades en cat\xe1logo para este estado",className:"text-sm"}),rs?r_.length>0?(0,s.jsx)(tE.V,{value:rn,onValueChange:e=>{rr(e),rN(ra,rs,e,"")},options:r_,placeholder:"C\xf3digo postal","aria-label":"C\xf3digo postal",searchPlaceholder:"Buscar CPâ¦",className:"text-sm"}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(B.I,{value:rn,onChange:e=>{let a=e.target.value.replace(/\D/g,"").slice(0,5);rr(a),rN(ra,rs,a,"")},placeholder:"5 d\xedgitos (SEPOMEX)",maxLength:5,inputMode:"numeric",autoComplete:"postal-code",className:"text-sm","aria-label":"C\xf3digo postal (SEPOMEX)"}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:()=>void rC(),children:"Buscar CP en cat\xe1logo MX"})]}):null]}),(0,s.jsxs)("p",{className:"text-xs text-gray-500",children:["Pa\xeds: ",d.ZN[n2]," \xb7 Texto guardado:"," ",nG.location||"â",null!=nG.mx_location_id&&(0,s.jsxs)("span",{className:"ml-2",children:["\xb7 Cat\xe1logo #",nG.mx_location_id]})]})]}):(0,s.jsx)("input",{type:"text",value:nG.location,onChange:e=>{ry("location",e.target.value),ry("mx_location_id",null)},placeholder:"Ciudad, Pa\xeds",className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full"}):(0,s.jsxs)("span",{className:"text-sm font-medium",children:[d.ZN[(0,d.$D)(ez.country_code,"MX")],ez.location?" \xb7 ".concat(ez.location):""]})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500 flex w-full items-center gap-1 mb-1",children:[(0,s.jsx)(tr.Z,{className:"w-4 h-4"})," Salario (min - max)",(0,s.jsx)("button",{type:"button",className:"ml-auto inline-flex h-7 w-7 items-center justify-center rounded-md text-gray-500 hover:bg-gray-100 hover:text-gray-800 disabled:opacity-50",disabled:i2||!(null==ez?void 0:ez.id),"aria-busy":i2,"aria-pressed":i1,"aria-label":i2?"Guardando visibilidad del salario":i1?"Ocultar salario en la web p\xfablica":"Mostrar salario en la web p\xfablica",title:i1?"Visible en la web p\xfablica. Clic para ocultarlo.":"Oculto en la web p\xfablica. Clic para mostrarlo.",onClick:()=>void rT(),children:i2?(0,s.jsx)(G.Z,{className:"h-4 w-4 animate-spin","aria-hidden":!0}):i1?(0,s.jsx)(ej.Z,{className:"h-4 w-4"}):(0,s.jsx)(eL.Z,{className:"h-4 w-4"})})]}),aA?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"text",inputMode:"numeric",autoComplete:"off",value:(0,l.o)(nG.salary_min),onChange:e=>ry("salary_min",(0,l.e)(e.target.value)),placeholder:"M\xedn",className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full"}),(0,s.jsx)("span",{className:"text-gray-400",children:"-"}),(0,s.jsx)("input",{type:"text",inputMode:"numeric",autoComplete:"off",value:(0,l.o)(nG.salary_max),onChange:e=>ry("salary_max",(0,l.e)(e.target.value)),placeholder:"M\xe1x",className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full"})]}):(0,s.jsx)("span",{className:"text-sm font-medium",children:null!=ez.salary_min||null!=ez.salary_max?"$".concat((null!==(Q=ez.salary_min)&&void 0!==Q?Q:0).toLocaleStr
1ing("es-MX")," - $").concat((null!==(ee=ez.salary_max)&&void 0!==ee?ee:0).toLocaleString("es-MX")):"â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500 flex items-center gap-1 mb-1",children:[(0,s.jsx)(I.Z,{className:"w-4 h-4"})," Fecha de cierre"]}),aA?(0,s.jsx)("input",{type:"date",value:nG.deadline_date,onChange:e=>ry("deadline_date",e.target.value),className:"text-sm text-gray-600 bg-white border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full"}):(0,s.jsx)("span",{className:"text-sm font-medium",children:ez.deadline_date?new Date(ez.deadline_date+"T12:00:00").toLocaleDateString("es-MX"):"â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500 flex items-center gap-1 mb-1",children:[(0,s.jsx)(tl.Z,{className:"w-4 h-4"})," Vacantes"]}),aA?(0,s.jsx)("input",{type:"number",min:1,value:nG.vacancies_count,onChange:e=>ry("vacancies_count",parseInt(e.target.value,10)||1),className:"text-sm text-gray-600 bg-white border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full"}):(0,s.jsx)("span",{className:"text-sm font-medium",children:null!==(ea=ez.vacancies_count)&&void 0!==ea?ea:1})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500 flex items-center gap-1 mb-1",children:[(0,s.jsx)($.Z,{className:"w-4 h-4"})," Cliente"]}),aA?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("select",{value:nG.final_client_id,onChange:e=>ry("final_client_id",e.target.value),className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full bg-white",disabled:nc,"aria-label":"Cliente final",children:nc?(0,s.jsx)("option",{value:"",children:"Cargandoâ¦"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("option",{value:"",children:"Ninguno"}),nl.filter(e=>!!(null==e?void 0:e.id)).map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]})}),(0,s.jsx)("div",{className:"mt-2 text-xs",children:(0,s.jsx)(r(),{href:"/dashboard/clients",className:"text-blue-600 hover:underline",children:"Gestionar clientes"})})]}):(0,s.jsx)("span",{className:"text-sm font-medium",children:ez.final_client_id===tA.gD?"Ninguno":null!==(et=null===(a=ez.final_client)||void 0===a?void 0:a.name)&&void 0!==et?et:"â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"text-sm text-gray-500 mb-1 block",children:"Categor\xeda"}),aA?(0,s.jsxs)("select",{value:nG.category_id,onChange:e=>ry("category_id",e.target.value),className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full bg-white","aria-label":"Categor\xeda opcional",children:[(0,s.jsx)("option",{value:"",children:"Opcional"}),nu.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))]}):(0,s.jsx)("span",{className:"text-sm font-medium",children:(null===(t=nu.find(e=>e.id===ez.category_id))||void 0===t?void 0:t.name)||"â"}),(0,s.jsx)("p",{className:"mt-1 text-[11px] text-gray-400",children:"No bloquea la publicaci\xf3n."})]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-sm text-gray-500 flex items-center gap-1 mb-1",children:[(0,s.jsx)(_.Z,{className:"w-4 h-4"})," Estado"]}),aA?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("select",{value:nG.status,onChange:e=>ry("status",e.target.value),className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full bg-white",children:[(0,s.jsx)("option",{value:"draft",children:"Borrador"}),(0,s.jsx)("option",{value:"active",children:"Activa"}),(0,s.jsx)("option",{value:"closed",children:"Cerrada"})]}),(0,s.jsx)("p",{className:"text-[11px] text-slate-500 mt-1",children:"Activa = la vacante est\xe1 abierta. Si sale o no en /jobs se controla en Visibilidad."})]}):(0,s.jsx)(y.C,{variant:"default",className:"bg-green-100 text-green-800 text-xs",children:"active"===ez.status?"Activa":"draft"===ez.status?"Borrador":"Cerrada"})]})]}),(0,s.jsx)("div",{className:"rounded-md border border-gray-100 bg-gray-50/50 overflow-hidden",children:aA?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"py-2 px-3",children:(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900",children:"Prompt inicial"})}),(0,s.jsxs)("div",{className:"px-3 pb-2 space-y-2",children:[(0,s.jsxs)("div",{className:"rounded-md border border-dashed border-gray-200 bg-gray-50/90 p-3",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-x-3 gap-y-1 mb-1",children:[(0,s.jsx)("p",{className:"text-xs font-medium text-gray-700",children:"Prompt original (solo informativo)"}),nq?(0,s.jsxs)("span",{className:"text-[11px] text-gray-500 flex items-center gap-1 shrink-0",children:[(0,s.jsx)(I.Z,{className:"w-3.5 h-3.5 opacity-70","aria-hidden":!0}),(0,s.jsxs)("span",{children:["\xdaltima modificaci\xf3n del puesto: ",nq]})]}):null]}),(0,s.jsx)("p",{className:"text-[11px] text-gray-500 mb-2",children:"Referencia de lo guardado en servidor."}),(0,s.jsx)("div",{className:"rounded-md border border-gray-200/80 bg-white p-2 min-h-[72px] max-h-[200px] overflow-y-auto",children:(null===(n=ez.description)||void 0===n?void 0:n.trim())?(0,s.jsx)(e8.Z,{text:ez.description,className:"text-sm text-gray-700"}):(0,s.jsx)("p",{className:"text-sm text-gray-400",children:"Sin prompt guardado a\xfan."})})]}),(0,s.jsx)("textarea",{value:nG.description,onChange:e=>ry("description",e.target.value),placeholder:"Al guardar se sustituye el prompt en servidor.",className:"text-sm text-gray-700 border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full min-h-[120px] resize-y bg-white","aria-label":"Prompt editable para guardar en servidor"})]})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",onClick:()=>sh(!sx),className:"w-full flex items-center justify-between gap-2 py-2 px-3 text-left hover:bg-gray-100/80 transition-colors",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-gray-900",children:"Prompt inicial (hist\xf3rico)"}),sx?(0,s.jsx)(S.Z,{className:"w-4 h-4 text-gray-500 shrink-0"}):(0,s.jsx)(A.Z,{className:"w-4 h-4 text-gray-500 shrink-0"})]}),(0,s.jsx)("div",{className:"px-3 pb-3",children:sx?(0,s.jsx)("div",{className:"line-clamp-3",children:(0,s.jsx)(e8.Z,{text:ez.description,className:"text-sm text-gray-600"})}):(0,s.jsx)(e8.Z,{text:ez.description,className:"text-sm text-gray-600"})})]})})]})]}),ez&&(()=>
1{let e=!!nG.simplify_application,a=!1!==nG.ask_candidate_phone,t=(Array.isArray(nG.simplified_hidden_fields)?nG.simplified_hidden_fields.length:0)+(a?0:1);return(0,s.jsxs)(N.Zb,{className:"overflow-hidden scroll-mt-4",id:"position-drawer-simplify-card",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>sy(e=>!e),className:"w-full flex items-center justify-between gap-2 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!sj,"aria-controls":"position-drawer-simplify",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base font-semibold",children:[(0,s.jsx)(eL.Z,{className:"w-5 h-5 shrink-0 text-slate-600"}),(0,s.jsx)("span",{children:"Registro simplificado"}),e?(0,s.jsxs)(y.C,{variant:"secondary",className:"font-normal",children:["Activo \xb7 ",t," campo",1===t?"":"s"]}):(0,s.jsx)(y.C,{variant:"outline",className:"font-normal text-slate-500",children:"Desactivado"})]})}),sj?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]}),!sj&&(0,s.jsxs)(N.aY,{id:"position-drawer-simplify",className:"space-y-4 pt-0",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{htmlFor:"drawer-simplify-enabled",children:"Ocultar campos en el portal"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1 max-w-xl",children:"Reduce el formulario de postulaci\xf3n en /jobs. El candidato no ver\xe1 los campos que marques."})]}),(0,s.jsx)(X.r,{id:"drawer-simplify-enabled",checked:e,disabled:!aA,onCheckedChange:e=>ry("simplify_application",e)})]}),e?(0,s.jsxs)("div",{className:"space-y-2 pl-1",children:[(0,s.jsx)("p",{className:"text-sm font-medium",children:"Campos a ocultar"}),(0,s.jsxs)("div",{className:"divide-y divide-border/70 rounded-lg border border-border/80 bg-background",children:[(0,s.jsxs)("label",{className:"flex items-center justify-between gap-3 px-3 py-2.5 text-sm",children:[(0,s.jsx)("span",{children:"Tel\xe9fono / WhatsApp"}),(0,s.jsx)(X.r,{size:"sm",checked:!a,disabled:!aA,onCheckedChange:e=>
1ry("ask_candidate_phone",!e),"aria-label":"Ocultar tel\xe9fono / WhatsApp"})]}),b.nt.map(e=>{let a=nG.simplified_hidden_fields.includes(e);return(0,s.jsxs)("label",{className:"flex items-center justify-between gap-3 px-3 py-2.5 text-sm",children:[(0,s.jsx)("span",{children:b.OI[e]}),(0,s.jsx)(X.r,{size:"sm",checked:a,disabled:!aA,onCheckedChange:a=>{let t=a?[...nG.simplified_hidden_fields,e]:nG.simplified_hidden_fields.filter(a=>a!==e);ry("simplified_hidden_fields",(0,b.cH)(t))},"aria-label":"Ocultar ".concat(b.OI[e])})]},e)})]}),aA?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Encendido = el candidato no ve ese campo. Guarda la vacante para aplicar."}):null]}):null]})]})})(),ez&&(0,s.jsxs)(N.Zb,{className:"overflow-hidden scroll-mt-4",id:"position-drawer-cv-requirement-card",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>sS(e=>!e),className:"flex w-full items-center justify-between gap-2 px-6 py-4 text-left transition-colors hover:bg-gray-50/80","aria-expanded":!sC,"aria-controls":"position-drawer-cv-requirement",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base font-semibold",children:[(0,s.jsx)(to.Z,{className:"h-5 w-5 shrink-0 text-slate-600"}),(0,s.jsx)("span",{children:"CV en el portal p\xfablico"}),(0,s.jsx)(y.C,{variant:"secondary",className:"font-normal",children:"optional"===nG.cv_requirement?"Opcional":"not_required"===nG.cv_requirement?"No requerido":"Obligatorio"})]})}),sC?(0,s.jsx)(S.Z,{className:"h-5 w-5 shrink-0 text-gray-500","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"h-5 w-5 shrink-0 text-gray-500","aria-hidden":!0})]}),!sC&&(0,s.jsxs)(N.aY,{id:"position-drawer-cv-requirement",className:"space-y-3 pt-0",children:[(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Define si quien postula a esta vacante debe adjuntar CV. Si pasas a \xabNo requerido\xbb, se detienen los recordatorios de postulaciones pendientes."}),[["required","Obligatorio"],["optional","Opcional (puede postular ahora y subir el CV despu\xe9s)"],["not_required","No requerido"]].map(e=>{let[a,t]=e;return(0,s.jsxs)("label",{className:"flex items-start gap-2 text-sm",children:[(0,s.jsx)("input",{type:"radio",className:"mt-1 h-4 w-4 accent-primary",name:"drawer-cv-requirement",checked:nG.cv_requirement===a,disabled:!aA,onChange:()=>ry("cv_requirement",a)}),(0,s.jsx)("span",{children:t})]},a)})]})]}),ez&&(()=>{let e=Array.isArray(nG.screening_questions)?nG.screening_questions:[],a=!!nG.screening_questions_enabled&&e.some(e=>String(e.prompt||"").trim().length>0);return aA||a?(0,s.jsxs)(N.Zb,{className:"overflow-hidden scroll-mt-4",id:"position-drawer-screening-card",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>s_(e=>!e),className:"w-full flex items-center justify-between gap-2 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!sN,"aria-controls":"position-drawer-screening",children:[(0,s.jsx)("div",{className:"min-w-0 flex-1",children:(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base font-semibold",children:[(0,s.jsx)(P.Z,{className:"w-5 h-5 shrink-0 text-indigo-600"}),(0,s.jsx)("span",{children:"Preguntas post-postulaci\xf3n"}),a?(0,s.jsxs)(y.C,{variant:"secondary",className:"font-normal",children:["Activas \xb7 ",e.filter(e=>String(e.prompt||"").trim()).length]}):(0,s.jsx)(y.C,{variant:"outline",className:"font-normal text-slate-500",children:"Sin preguntas"})]})}),sN?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]}),!sN&&(0,s.jsxs)(N.aY,{id:"position-drawer-screening",className:"space-y-4 pt-0",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{htmlFor:"drawer-screening-enabled",children:"Enviar preguntas por email y WhatsApp tras postular"}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1 max-w-xl",children:"Qu
1ienes se postulen en /jobs reciben un link \xfanico por email y WhatsApp. Hasta que respondan ver\xe1s \xabEvaluaci\xf3n pendiente\xbb y el match espera."})]}),(0,s.jsx)(X.r,{id:"drawer-screening-enabled",checked:!!nG.screening_questions_enabled,disabled:!aA,onCheckedChange:e=>ry("screening_questions_enabled",e)})]}),nG.screening_questions_enabled?(0,s.jsxs)("div",{className:"space-y-3",children:[aA?(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",disabled:sw,onClick:()=>void lC(),children:sw?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Generandoâ¦"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ay.Z,{className:"h-4 w-4 mr-1.5 text-indigo-600"}),"Generar con IA"]})}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"Arma preguntas seg\xfan la vacante \xb7 1 cr\xe9dito IA. T\xfa decides cu\xe1les son eliminatorias."})]}):null,e.map((a,t)=>(0,s.jsx)(g.G,{question:a,index:t,disabled:!aA,removeIcon:"trash",onChange:t=>ry("screening_questions",e.map(e=>e.id===a.id?t:e)),onRemove:aA?()=>ry("screening_questions",e.filter(e=>e.id!==a.id)):void 0},a.id)),aA&&e.length<15&&(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",onClick:()=>{ry("screening_questions",[...e,(0,g.p)(e.length)])},children:"Agregar pregunta"}),aA?(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:"Guarda la vacante para aplicar los cambios."}):null]}):aA?(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",disabled:sw,onClick:()=>void lC(),children:sw?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"h-4 w-4 mr-1.5 animate-spin"}),"Generandoâ¦"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ay.Z,{className:"h-4 w-4 mr-1.5 text-indigo-600"}),"Generar con IA"]})}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"Activa el switch o genera con IA (1 cr\xe9dito) para armar las preguntas."})]}):null]})]}):(0,s.jsx)("div",{id:"position-drawer-screening-card",className:"rounded-lg border border-dashed border-slate-200 bg-slate-50/80 px-6 py-3 scroll-mt-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-slate-400",children:[(0,s.jsx)(P.Z,{className:"w-4 h-4 shrink-0 opacity-60","aria-hidden":!0}),(0,s.jsx)("span",{className:"font-medium",children:"Preguntas post-postulaci\xf3n"}),(0,s.jsx)("span",{className:"text-xs font-normal",children:"\xb7 Sin configurar"})]})})})(),ez?(0,s.jsx)(N.Zb,{id:"position-drawer-ai-interview-card",className:"overflow-hidden scroll-mt-4",children:(0,s.jsx)(N.aY,{className:"space-y-3 p-4 sm:p-6",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-muted/30 p-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)(U._,{htmlFor:"drawer-ai-interview-auto",className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)(ay.Z,{className:"h-4 w-4 text-teal-700"}),"Entrevista IA autom\xe1tica (Camila)"]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1 max-w-xl",children:"Si el match alcanza el m\xednimo, se env\xeda WhatsApp y correo con el enlace. Si hay preguntas post-postulaci\xf3n, espera a que las respondan."}),(0,s.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[(0,s.jsx)(U._,{htmlFor:"drawer-ai-interview-match-min",className:"text-xs font-medium text-foreground",children:"Match m\xednimo"}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(B.I,{id:"drawer
1-ai-interview-match-min",type:"number",min:1,max:100,step:1,className:"h-8 w-16 text-sm",value:(0,h.gh)(nG.ai_interview_auto_match_min),disabled:!aA,onChange:e=>{let a=Number(e.target.value);Number.isFinite(a)&&ry("ai_interview_auto_match_min",Math.min(100,Math.max(1,Math.round(a))))}}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"%"})]}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:"(por defecto 70)"})]})]}),(0,s.jsx)(X.r,{id:"drawer-ai-interview-auto",checked:!!nG.ai_interview_auto_enabled,disabled:!aA,onCheckedChange:e=>ry("ai_interview_auto_enabled",e)})]})})}):null,eM&&ez&&(0,s.jsxs)(N.Zb,{id:"position-drawer-portal-card",className:"overflow-hidden scroll-mt-4",children:[(0,s.jsx)("div",{className:"flex flex-row flex-wrap items-center justify-between gap-3 py-4 px-6",children:(0,s.jsxs)("button",{type:"button",onClick:()=>sz(!sI),className:"min-w-0 flex-1 flex items-center justify-between gap-2 text-left hover:bg-gray-50/80 transition-colors rounded-md -ml-2 pl-2 pr-2 py-1","aria-expanded":!sI,"aria-controls":"position-drawer-portal-public-fields",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)(N.ll,{className:"flex items-center gap-2 text-base font-semibold",children:[(0,s.jsx)(to.Z,{className:"w-5 h-5 text-emerald-700 shrink-0"}),"Anuncio para candidatos"]}),(0,s.jsx)("p",{className:"text-xs font-normal text-slate-500 mt-1 pr-2",children:"El texto del anuncio. No controla si la vacante est\xe1 activa ni si sale en /jobs."}),!aA&&aC&&!aw&&(0,s.jsx)("p",{className:"text-xs font-normal text-slate-600 mt-1 pr-2",children:"Solo lectura: con postulaciones, aqu\xed trabajas candidatos abajo; la vacante no se edita."}),!aA&&aC&&aw&&(0,s.jsxs)("p",{className:"text-xs font-normal text-emerald-900 mt-1 pr-2",children:["Cuenta interna: con el ",(0,s.jsx)("strong",{children:"l\xe1piz"})," puedes editar la ficha aunque haya postulaciones."]}),!aA&&!aC&&(0,s.jsxs)("p",{className:"text-xs font-normal text-amber-800 mt-1 pr-2",children:["Vista sin edici\xf3n: usa el ",(0,s.jsx)("strong",{children:"l\xe1piz"})," en la cabecera para regenerar el anuncio."]})]}),sI?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]})}),!aA&&(0,s.jsx)("div",{className:"px-6 pb-3 border-b border-violet-100 bg-gradient-to-r from-violet-50/90 to-white",children:(0,s.jsxs)("div",{className:"flex gap-2.5 items-start",children:[(0,s.jsx)(ay.Z,{className:"w-4 h-4 text-violet-600 shrink-0 mt-0.5","aria-hidden":!0}),(0,s.jsx)("div",{className:"text-xs text-violet-950 leading-snug space-y-1.5 min-w-0 pt-2",children:aC&&aw?(0,s.jsxs)("p",{children:["En ",(0,s.jsx)("strong",{children:"cuenta interna"})," puedes editar aunque haya postulaciones: pulsa el"," ",(0,s.jsx)("strong",{children:"l\xe1piz"})," arriba y ver\xe1s ⨠y la regeneraci\xf3n del portal. El"," ",(0,s.jsx)("strong",{children:"% de match"})," sigue basado en el ",(0,s.jsx)("strong",{children:"prompt inicial"})," guardado."]}):aC?(0,s.jsxs)("p",{children:["Con ",(0,s.jsx)("strong",{children:"candidatos ya postulados"})," la ficha no se puede editar (incluida la regeneraci\xf3n del texto p\xfablico con IA). El ",(0,s.jsx)("strong",{children:"% de match"})," sigue usando el"," ",(0,s.jsx)("strong",{children:"prompt inicial"})," y los datos guardados de la vacante."]}):(0,s.jsxs)("p",{children:["Tienes la vacante en ",(0,s.jsx)("strong",{children:"modo solo lectura"}),". Pulsa el icono del"," ",(0,s.jsx)("strong",{children:"l\xe1piz"})," arriba a la derecha para pasar a edici\xf3n; si no hay postulaciones, ver\xe1s el bot\xf3n ",(0,s.jsx)("strong",{className:"inline-flex items-center gap-0.5",children:"â¨"})," en la cabecera y el bloque violeta aqu\xed dentro para regenerar el portal."]})})]})}),!sI&&(0,s.jsxs)(N.aY,{id:"position-drawer-portal-public-fields",className:"space-y-4 pt-0",children:[!aA&&aC&&!aw&&(0,s.jsxs)("div",{className:"rounded-md border border-slate-200 bg-slate-50 px-3 py-2.5 text-sm text-slate-800",role:"status",children:[(0,s.jsx)("p",{className:"font-medium",children:"Referencia del portal (no editable)"}),(0,s.jsx)("p",{className:"text-xs mt-1 leading-snug text-slate-700",children:"Esta vacante tiene candidatos: la edici\xf3n de sueldo, ubicaci\xf3n y textos est\xe1 bloqueada. Usa la tabla de candidatos para el trabajo operativo; lo de abajo es solo para ver qu\xe9 ven en /jobs."})]}),aA&&"draft"===nG.status&&rL.length>0&&(0,s.jsxs)("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-sm text-amber-950 flex gap-2",children:[(0,s.jsx)(e7.Z,{className:"w-4 h-4 shrink-0 mt-0.5","aria-hidden":!0}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium",children:"Borrador: revisa el contenido p\xfablico"}),(0,s.jsxs)("p",{className:"text-xs mt-1 leading-snug",children:["A\xfan vac\xedo o incompleto: ",rL.join(" \xb7 "),". Puedes seguir guardando el borrador y completar despu\xe9s. Al publicar te avisaremos si sigue incompleto."]})]})]}),aA&&!(nG.public_description||"").trim()&&!!(nG.description||"").trim()&&(0,s.jsxs)("div",{className:"rounded-md border border-emerald-200 bg-emerald-50/90 px-3 py-2.5 text-sm text-emerald-950 space-y-2",children:[(0,s.jsxs)("p",{className:"text-xs leading-snug",children:[(0,s.jsx)("span",{className:"font-medium",children:"Texto p\xfablico vac\xedo."})," El match con CVs ya usa el"," ",(0,s.jsx)("strong",{children:"prompt inicial"})," (descripci\xf3n interna). En /jobs, si no hay texto aqu\xed, la p\xe1gina puede mostrar ese mismo prompt como respaldo. Usa el bot\xf3n para copiarlo y pulirlo antes de publicar."]}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",className:"h-8 text-xs",onClick:()=>{let e=(nG.description||"").trim();if(!e){iI.error("Sin contenido","El prompt inicial est\xe1 vac\xedo.");return}let a=!!(nG.public_description||"").trim();if(a){iU({title:"Reemplazar texto p\xfablico",message:"\xabTexto principal (p\xfablico)\xbb ya tiene contenido.\n\n\xbfReemplazarlo por una copia del prompt inicial?",type:"warning",confirmText:"Reemplazar",cancelText:"Cancelar",onConfirm:()=>{nJ(a=>({...a,public_description:e,...(a.linkedin_content||"").trim()?{}:{linkedin_content:e}})),iI.success("Copiado","Prompt copiado al texto p\xfablico (y a redes si estaba vac\xedo). Guarda para persistir.")},onCancel:()=>{}});return}nJ(a=>({...a,public_description:e,...(a.linkedin_content||"").trim()?{}:{linkedin_content:e}})),iI.success("Copiado","Prompt copiado al texto p\xfablico (y a redes si estaba vac\xedo). Guarda para persistir.")},children:"Copiar prompt inicial â texto p\xfablico"})]}),!aA&&!(nG.public_description||"").trim()&&!!(nG.description||"").trim()&&(0,s.jsxs)("div",{className:"rounded-md border border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-700 leading-snug",children:["Sin texto p\xfablico guardado: en /jobs puede mostrarse el ",(0,s.jsx)("strong",{children:"prompt inicial"})," como respaldo. El an\xe1lisis de match usa tambi\xe9n ese prompt interno."]}),aA&&!!(nG.description||"").trim()&&(0,s.jsxs)("div",{className:"rounded-md border border-violet-200 bg-vi
1olet-50/80 px-3 py-2.5 text-sm text-violet-950 space-y-2",children:[(0,s.jsxs)("p",{className:"text-xs leading-snug",children:[(0,s.jsx)("span",{className:"font-medium",children:"Publicar m\xe1s adelante."})," Aunque la uses solo por enlace o internamente, puedes generar con IA el borrador de lo que ver\xe1n en /jobs. Pide"," ",(0,s.jsx)("strong",{children:"dos confirmaciones"})," para evitar pisar texto sin querer; luego revisa y"," ",(0,s.jsx)("strong",{children:"Guarda"}),"."]}),(0,s.jsxs)(j.z,{type:"button",variant:"secondary",size:"sm",className:"h-8 text-xs border-violet-300 bg-white text-violet-900 hover:bg-violet-100/80",disabled:sV,onClick:()=>void rI(),children:[sV?(0,s.jsx)(G.Z,{className:"w-3.5 h-3.5 animate-spin mr-2","aria-hidden":!0}):(0,s.jsx)(ay.Z,{className:"w-3.5 h-3.5 mr-2","aria-hidden":!0}),"Regenerar borrador p\xfablico con IA"]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-1",children:"Texto principal (p\xfablico)"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:aA?(0,s.jsx)(s.Fragment,{children:"Tiene prioridad sobre la descripci\xf3n del formulario anterior. \xdasalo para el mensaje definitivo hacia candidatos."}):(0,s.jsx)(s.Fragment,{children:"Texto que ven los candidatos en /jobs (referencia)."})}),(0,s.jsx)("textarea",{readOnly:!aA,value:nG.public_description,onChange:e=>ry("public_description",e.target.value),placeholder:"Ejemplo:\nBuscamos un/a [rol] para [objetivo breve]. Ofrecemos [1â2 bullets de ambiente o impacto].",className:"text-sm text-gray-800 border border-gray-300 rounded-md p-2 w-full min-h-[100px] resize-y "+(aA?"bg-white focus:border-emerald-600 focus:outline-none":"bg-slate-50 cursor-default")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-1",children:"Propuesta de valor"}),(0,s.jsx)("textarea",{readOnly:!aA,value:nG.value_proposition,onChange:e=>ry("value_proposition",e.target.value),placeholder:"Ejemplo:\nEmpresa en crecimiento, equipo cercano, flexibilidad horaria y posibilidad de home office h\xedbrido.",className:"text-sm text-gray-800 border border-gray-300 rounded-md p-2 w-full min-h-[72px] resize-y "+(aA?"bg-white focus:border-emerald-600 focus:outline-none":"bg-slate-50 cursor-default")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-1",children:"Texto para redes / alternativo"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"El portal puede usarlo si no hay texto principal. Tambi\xe9n sirve para publicar en LinkedIn."}),(0,s.jsx)("textarea",{readOnly:!aA,value:nG.linkedin_content,onChange:e=>ry("linkedin_content",e.target.value),placeholder:"Ejemplo:\nEstamos contratando [rol] en [ciudad]. M\xe1s detalles en el enlace. #empleo",className:"text-sm text-gray-800 border border-gray-300 rounded-md p-2 w-full min-h-[72px] resize-y "+(aA?"bg-white focus:border-emerald-600 focus:outline-none":"bg-slate-50 cursor-default")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-1",children:"Responsabilidades"}),(0,s.jsx)("textarea",{readOnly:!aA,value:nG.responsibilities,onChange:e=>ry("responsibilities",e.target.value),placeholder:"Ejemplo:\n⢠Definir y ejecutar la estrategia de [\xe1rea]\n⢠Coordinar con [equipos internos/externos]\n⢠Presentar reportes peri\xf3dicos a direcci\xf3n",className:"text-sm text-gray-800 border border-gray-300 rounded-md p-2 w-full min-h-[80px] resize-y "+(aA?"bg-white focus:border-emerald-600 focus:outline-none":"bg-slate-50 cursor-default")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-1",children:"Requisitos"}),(0,s.jsx)("textarea",{readOnly:!aA,value:nG.requirements,onChange:e=>ry("requirements",e.target.value),placeholder:"Ejemplo:\n⢠[X] a\xf1os de experiencia en [\xe1rea]\n⢠Licenciatura en [carrera] o af\xedn\n⢠Herramientas: [ej. Excel avanzado, CRM, ingl\xe9s B2+]",className:"text-sm text-gray-800 border border-gray-300 rounded-md p-2 w-full min-h-[80px] resize-y "+(aA?"bg-white focus:border-emerald-600 focus:outline-none":"bg-slate-50 cursor-default")})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-1",children:"Beneficios"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Un beneficio por l\xednea (aparecen como lista en el portal)."}),(0,s.jsx)("textarea",{readOnly:!aA,value:nG.benefits_str,onChange:e=>ry("benefits_str",e.target.value),placeholder:"Ejemplo (una l\xednea por beneficio):\nSeguro de gastos m\xe9dicos mayores\nVacaciones superiores a ley\nHome office flexible\nCapacitaci\xf3n continua",className:"text-sm text-gray-800 border border-gray-300 rounded-md p-2 w-full min-h-[88px] resize-y font-mono "+(aA?"bg-white focus:border-emerald-600 focus:outline-none":"bg-slate-50 cursor-default")})]})]})]}),eM&&(null==ez?void 0:ez.id)&&(0,s.jsxs)(N.Zb,{children:[(0,s.jsxs)(N.Ol,{className:"flex flex-row flex-wrap items-center justify-between gap-3 space-y-0 ".concat(sZ?"pb-6":"pb-3"),children:[(0,s.jsxs)("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 rounded-md py-1 pl-2 pr-2 text-left -ml-2 hover:bg-gray-50/80 transition-colors",onClick:()=>sP(e=>!e),"aria-expanded":!sZ,"aria-controls":"position-drawer-portal-jobs-visibility",children:[sZ?(0,s.jsx)(S.Z,{className:"w-5 h-5 shrink-0 text-gray-500","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 shrink-0 text-gray-500","aria-hidden":!0}),(0,s.jsx)(tc.Z,{className:"w-5 h-5 shrink-0 text-emerald-600","aria-hidden":!0}),(0,s.jsx)("span",{className:"min-w-0",children:(0,s.jsx)("span",{className:"block text-base font-semibold leading-tight",children:"Visibilidad"})})]}),(0,s.jsx)("div",{className:"shrink-0 flex items-center gap-2",onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:(0,s.jsx)(X.r,{id:"portal-visible-jobs","aria-label":"Salir en el directorio de /jobs",title:"Si est\xe1 apagado, no sale en el listado; el enlace directo sigue valiendo",checked:iH&&iQ,disabled:iY||!(null==ez?void 0:ez.id),onCheckedChange:e=>void rq(e)})})]}),!sZ&&(0,s.jsxs)(N.aY,{id:"position-drawer-portal-jobs-visibility",className:"space-y-4 pt-0",children:[(0,s.jsx)("p",{className:"text-xs text-gray-500 max-w-xl",children:iH&&iQ?(0,s.jsx)(s.Fragment,{children:"Sale en el directorio y el buscador de /jobs. Apaga el interruptor para dejarla solo por enlace."}):iH?(0,s.jsx)(s.Fragment,{children:"No sale en el directorio: solo quien tenga el enlace. Activa el interruptor para listarla."}
1):(0,s.jsx)(s.Fragment,{children:"Todav\xeda no tiene p\xe1gina p\xfablica. Activa el interruptor para publicarla en /jobs."})}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-gray-200 bg-gray-50/80 p-3",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-sm text-gray-800",children:"Google Jobs"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 max-w-md",children:"Si la vacante est\xe1 activa, Google puede indexar la URL del anuncio. Ap\xe1galo si no quieres que salga en la b\xfasqueda de empleo."})]}),(0,s.jsx)(X.r,{checked:i3,disabled:!(null==ez?void 0:ez.id)||i9||iY,"aria-label":"Publicar esta vacante en Google Jobs",onCheckedChange:async e=>{if(null==ez?void 0:ez.id){i8(!0);try{let a=await fetch("/api/positions/".concat(ez.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({publish_google_jobs:e})}),t=await a.json().catch(()=>({}));t.success?(i6(e),eF&&eF({...ez,publish_google_jobs:e}),iI.success(e?"Google Jobs activo":"Google Jobs desactivado",e?"Se enviar\xe1 a Google si la vacante est\xe1 activa.":"Esta vacante ya no se indexa en Google Jobs."),rc()):iI.error("Error",t.error||"No se pudo actualizar.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{i8(!1)}}}})]}),iQ&&((null==i7?void 0:i7.rich_results_url)||(null==i7?void 0:i7.google_jobs_search_url))?(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-3 gap-y-1 text-xs",children:[(null==i7?void 0:i7.rich_results_url)?(0,s.jsxs)("a",{href:i7.rich_results_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-blue-700 hover:underline",children:["Comprobar ficha en Google",(0,s.jsx)(k.Z,{className:"w-3 h-3"})]}):null,(null==i7?void 0:i7.google_jobs_search_url)?(0,s.jsxs)("a",{href:i7.google_jobs_search_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-blue-700 hover:underline",children:["Buscar en Google Jobs",(0,s.jsx)(k.Z,{className:"w-3 h-3"})]}):null]}):null]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between rounded-lg border border-gray-200 bg-gray-50/80 p-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-sm text-gray-800",children:"Candidatos en el extranjero"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-0.5 max-w-md",children:"Permite que en la postulaci\xf3n elijan \xabVivo en el extranjero\xbb. Si lo desactivas, solo podr\xe1n indicar ubicaci\xf3n en M\xe9xico (estado y ciudad)."})]}),(0,s.jsx)(X.r,{checked:na,disabled:!(null==ez?void 0:ez.id)||ns||iY,"aria-label":"Aceptar candidatos en el extranjero",onCheckedChange:async e=>{if(null==ez?void 0:ez.id){ni(!0);try{let a=await fetch("/api/positions/".concat(ez.id),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({accept_foreign_candidates:e})}),t=await a.json().catch(()=>({}));t.success?(nt(e),eF&&eF({...ez,accept_foreign_candidates:e}),iI.success(e?"Extranjero permitido":"Solo M\xe9xico",e?"Los candidatos pueden indicar que viven fuera de M\xe9xico.":"Solo se aceptar\xe1 ubicaci\xf3n con estado y ciudad en M\xe9xico.")):iI.error("Error",t.error||"No se pudo actualizar.")}catch(e){iI.error("Error","Sin conexi\xf3n.")}finally{ni(!1)}}}})]}),iH&&nn&&(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-xs text-gray-500",children:"URL para candidatos"}),(0,s.jsxs)("div",{className:"mt-1 flex gap-2 flex-wrap items-center",children:[(0,s.jsx)(B.I,{readOnly:!0,className:"font-mono text-xs flex-1 min-w-0",value:(0,o.hM)("/jobs/".concat(nn))}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",title:"Ver vacante en portal",onClick:()=>{let e=(0,o.hM)("/jobs/".concat(nn));window.open(e,"_blank","noopener,noreferrer")},children:(0,s.jsx)(ej.Z,{className:"w-4 h-4"})}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",title:"Copiar enlace",onClick:()=>{let e=(0,o.hM)("/jobs/".concat(nn));navigator.clipboard&&(navigator.clipboard.writeText(e),iI.success("Copiado","Enlace copiado al portapapeles."))},children:(0,s.jsx)(w.Z,{className:"w-4 h-4"})})]})]})]})]}),aA&&(0,s.jsxs)(N.Zb,{children:[(0,s.jsxs)(N.Ol,{children:[(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base",children:[(0,s.jsx)(td.Z,{className:"w-5 h-5 text-blue-600"}),(0,s.jsx)("span",{children:"An\xe1lisis de CVs y % de apego (solo match)"})]}),(0,s.jsxs)("div",{className:"mt-2 rounded-md border border-sky-200 bg-sky-50/90 px-3 py-2.5 text-sm text-sky-950 leading-snug space-y-1.5",children:[(0,s.jsxs)("p",{children:[(0,s.jsx)("strong",{className:"text-sky-950",children:"El anuncio"})," (texto para candidatos, m\xe1s arriba)"," ",(0,s.jsx)("strong",{children:"no es lo mismo"})," que"," ",(0,s.jsx)("strong",{className:"text-sky-950",children:"filtrar u ordenar candidatos"})," seg\xfan el perfil."]}),(0,s.jsxs)("p",{className:"text-xs text-sky-900/95",children:["Este bloque se usa ",(0,s.jsx)("strong",{children:"\xfanicamente"})," para priorizar la IA al ",(0,s.jsx)("strong",{children:"analizar CVs"})," ","y calcular el ",(0,s.jsx)("strong",{children:"% de apego"})," frente a la vacante (qui\xe9n encaja m\xe1s o menos). No define el texto p\xfablico ni la oferta para postularse."]})]}),(0,s.jsxs)("p",{className:"text-sm text-gray-500 mt-3",children:["Ejemplos: i
1diomas, a\xf1os de experiencia en X, certificaciones, disponibilidad. Si cambias la vacante o este texto y hay cambios sin guardar, puede aparecer ",(0,s.jsx)("strong",{children:"Regenerar con IA"})," en la cabecera para alinear borradores; guarda antes si quieres persistir."]})]}),(0,s.jsx)(N.aY,{children:(0,s.jsx)("textarea",{value:nG.ai_match_criteria,onChange:e=>ry("ai_match_criteria",e.target.value),placeholder:"Solo criterios para evaluar CVs y % de apego (ej. ingl\xe9s C1, 3+ a\xf1os en retailâ¦). No es la descripci\xf3n p\xfablica de la vacante.",className:"text-sm border border-gray-300 rounded-md p-2 focus:border-blue-500 focus:outline-none w-full min-h-[80px] resize-y"})})]}),nQ&&(0,s.jsxs)(N.Zb,{children:[(0,s.jsx)(N.Ol,{className:"flex flex-row items-center justify-between space-y-0 p-0",children:(0,s.jsxs)("button",{type:"button",onClick:()=>sq(!sT),className:"flex w-full items-center justify-between gap-3 p-6 text-left hover:bg-muted/50 rounded-t-lg transition-colors","aria-expanded":sT,"aria-controls":"position-drawer-ai-analysis-content",id:"position-drawer-ai-analysis-trigger",children:[(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base font-semibold leading-tight",children:[(0,s.jsx)(td.Z,{className:"w-5 h-5 text-purple-600 shrink-0"}),(0,s.jsx)("span",{children:"Borrador IA (sugerencias internas)"})]}),sT?(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]})}),sT&&(0,s.jsxs)(N.aY,{id:"position-drawer-ai-analysis-content",className:"space-y-4",role:"region","aria-labelledby":"position-drawer-ai-analysis-trigger",children:[(0,s.jsxs)("div",{className:"rounded-md border border-violet-200 bg-violet-50/60 px-3 py-3 text-sm text-violet-950 space-y-2",children:[(0,s.jsxs)("p",{children:["Esto ",(0,s.jsx)("strong",{children:"no"}),' es el anuncio: el texto para candidatos se edita arriba en "Anuncio para candidatos". Aqu\xed ves el \xfaltimo borrador generado por IA.']}),aA?(0,s.jsx)("p",{className:"text-xs text-violet-900 leading-snug",children:nK?(0,s.jsxs)(s.Fragment,{children:["Pulsa ",(0,s.jsx)("strong",{children:"Regenerar con IA"})," en la cabecera para generar de nuevo el borrador con el"," ",(0,s.jsx)("strong",{children:"prompt inicial"})," actual. Luego ",(0,s.jsx)("strong",{children:"Guarda"})," la vacante para persistir."]}):(0,s.jsxs)(s.Fragment,{children:["El bot\xf3n ",(0,s.jsx)("strong",{children:"Regenerar con IA"})," solo aparece cuando modificas el"," ",(0,s.jsx)("strong",{children:"prompt inicial"})," respecto al texto guardado en servidor."," ",(0,s.jsx)("strong",{children:"An\xe1lisis de CVs"})," es aparte (match de postulaciones)."]})}):(0,s.jsx)("p",{className:"text-xs text-violet-800 leading-snug",children:"Abre la vacante desde Posiciones con permiso de edici\xf3n para regenerar el borrador con IA."})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Resumen Ejecutivo"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem]",children:(nG.ai_executive_summary||"").trim()||"â Sin contenido â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Perfil Ideal del Candidato"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem]",children:(nG.ai_ideal_candidate_profile||"").trim()||"â Sin contenido â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Competencias Clave (una por l\xednea)"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem] font-mono text-xs",children:(nG.ai_key_competencies_str||"").trim()||"â Sin contenido â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Propuesta de Valor (IA)"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem]",children:(nG.ai_value_proposition||"").trim()||"â Sin contenido â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Estrategia de Reclutamiento"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem]",children:(nG.ai_recruitment_strategy||"").trim()||"â Sin contenido â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Contenido para LinkedIn (IA)"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem]",children:(nG.ai_linkedin_content||"").trim()||"â Sin contenido â"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Email para Colegas (IA)"}),(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap bg-gray-50 border border-gray-100 rounded-md p-3 min-h-[3rem]",children:(nG.ai_colleagues_email||"").trim()||"â Sin contenido â"})]})]})]}),(null==ez?void 0:ez.id)?(0,s.jsx)(es,{positionId:ez.id,isEditable:!1!==eM,onNotify:(e,a,t)=>{"success"===e?iI.success(a,t||""):iI.error(a,t||"")},onScrollToCandidates:()=>{var e;null===(e=document.getElementById("position-drawer-candidates"))||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})}}):null,(0,s.jsx)(L,{positionId:ez.id,portalClientCounts:li,originCounts:ls,activeOriginFilters:s8,onOriginFilterToggle:e=>{s7(a=>a.includes(e)?a.filter(a=>a!==e):[...a,e]),requestAnimationFrame(()=>{var e;null===(e=document.getElementById("position-drawer-candidates"))||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})})},activeSummaryBucket:iu,onSummaryBucketChange:e=>{im(e),requestAnimationFrame(()=>{var e;null===(e=document.getElementById("position-drawer-candidates"))||void 0===e||e.scrollIntoView({behavior:"smooth",block:"start"})})}}),(0,s.jsxs)(N.Zb,{id:"position-drawer-candidates",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3 px-6 py-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>sv(e=>!e),className:"flex items-center gap-2 text-left hover:opacity-80 transition-opacity min-w-0","aria-expanded":!sf,"aria-controls":"position-drawer-candidates-content",children:[(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2",children:[(0,s.jsx)(E.Z,{className:"w-5 h-5 text-blue-600 shrink-0"}),(0,s.jsx)("span",{children:"Candidatos"}),ab.length>0?(0,s.jsx)(y.C,{variant:"secondary",className:"font-normal",children:ab.length}):null]}),sf?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]}),sf?null:(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2 sm:justify-end",children:[(0,s.jsxs)("div",{className:"inline-flex rounded-md border border-gray-200 bg-muted/40 p-0.5",children:[(0,s.jsxs)(j.z,{type:"button",variant:"kanban"===ij?"secondary":"ghost",size:"sm",className:"h-8 gap-1.5",onClick:()=>iy("kanban"),children:[(0,s.jsx)(tu.Z,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Tablero"]}),(0,s.jsxs)(j.z,{type:"button",variant:"table"===ij?"secondary":"ghost",size:"sm",className:"h-8 gap-1.5",onClick:()=>iy("table"),children:[(0,s.jsx)(tm.Z,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Tabla"]})]}),(0,s.jsxs)(j.z,{type:"button",variant:"outline",size:"sm",className:"h-9 gap-1.5",onClick:r3,title:"Columnas del proceso (Kanban)",children:[(0,s.jsx)(tp.Z,{className:"h-4 w-4 shrink-0","aria-hidden":!0}),"Etapas"]}),(0,s.jsxs)(ex.h_,{children:[(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsxs)(j.z,{variant:"outline",size:"sm",className:"h-9 gap-1.5",children:[(0,s.jsx)("span",{children:"Acciones"}),(0,s.jsx)(S.Z,{className:"w-4 h-4 opacity-70"})]})}),(0,s.jsxs)(ex.AW,{align:"end",className:"z-[110] w-56",children:[ab.some(e=>e.pre_selected_for_client)&&(0,s.jsxs)(ex.Xi,{onClick:rQ,className:"text-green-700 focus:text-green-700",children:[(0,s.jsx)(P.Z,{className:"w-4 h-4 mr-2"}),"Compartir con cliente (elegir candidatos)"]}),ab.length>0&&(0,s.jsxs)(ex.Xi,{onClick:lp,disabled:lI,children:[lI&&sR?(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 shrink-0 animate-spin"}):(0,s.jsx)(td.Z,{className:"w-4 h-4 mr-2 shrink-0"}),lI&&sR?"Re-analizando...":"Re-analizar todos"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>{a2([]),tz(null),tq(!1),tY(null),t3(null),tH(!1),t9("ask"),t7(""),sl(null),ss(!1),sn(!1),aq(!0)},children:[(0,s.jsx)(tx.Z,{className:"w-4 h-4 mr-2"}),"Agregar candidato(s)"]}),aL&&(0,s.jsxs)(ex.Xi,{onClick:()=>aM(!0),children:[(0,s.jsx)(T.Z,{className:"w-4 h-4 mr-2"}),"Obtener candidatos"]}),aL&&(0,s.jsxs)(ex.Xi,{onClick:()=>aX(!0),children:[(0,s.jsx)(a0.Z,{className:"w-4 h-4 mr-2"}),"B\xfasqueda profunda"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>
1{if(a$.locked){iI.info("B\xfasqueda en curso",a$.progressLabel||"Talentgoo est\xe1 buscando candidatos. Espere o cancele desde el aviso de arriba.");return}aJ(!0)},disabled:a$.locked,children:[(0,s.jsx)(ay.Z,{className:"w-4 h-4 mr-2"}),"B\xfasqueda autom\xe1tica"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>{if(a$.locked){iI.info("B\xfasqueda en curso",a$.progressLabel||"Espere a que termine la b\xfasqueda autom\xe1tica de Talentgoo.");return}aB(!0)},disabled:a$.locked,children:[(0,s.jsx)(th.Z,{className:"w-4 h-4 mr-2"}),"Buscar en LinkedIn"]})]})]})]})]}),sf?null:(0,s.jsxs)(N.aY,{id:"position-drawer-candidates-content",children:[(null==ez?void 0:ez.id)?(0,s.jsx)(aQ,{positionId:ez.id,onImported:e=>{e>0&&(rd(),iI.success("Candidatos listos","".concat(e," en Identificado. Rev\xedselos e inv\xedtelos a postularse.")))}}):null,(null==ez?void 0:ez.id)?(0,s.jsx)(a1,{positionId:ez.id,onReadyToReview:()=>{aX(!0),iI.info("B\xfasqueda profunda lista","Revisa los perfiles e importa a Identificado.")}}):null,aE?(0,s.jsxs)("div",{className:"flex items-center justify-center py-8 text-gray-500",children:[(0,s.jsx)(G.Z,{className:"w-6 h-6 animate-spin mr-2"}),"Cargando candidatos..."]}):0===ab.length?(0,s.jsxs)("p",{className:"text-sm text-gray-500 py-4",children:["A\xfan no hay candidatos. Usa ",(0,s.jsx)("strong",{children:"Acciones â Agregar candidato(s)"})," para subir uno o varios CVs; la IA extrae el perfil y calcula el apego a la vacante."]}):(0,s.jsxs)("div",{className:"relative min-h-[12rem]",children:[(nj||nN||lI)&&(0,s.jsxs)("div",{className:"absolute inset-0 z-[25] flex flex-col items-center justify-start pt-10 sm:pt-16 px-4 bg-white/90 backdrop-blur-[2px] rounded-lg border border-blue-100/80 shadow-sm",role:"status","aria-live":"polite","aria-busy":"true",children:[(0,s.jsx)(G.Z,{className:"w-10 h-10 text-blue-600 animate-spin shrink-0","aria-hidden":!0}),(0,s.jsx)("p",{className:"mt-4 text-sm font-semibold text-blue-950 text-center max-w-md",children:nj?"Procesando acci\xf3n masivaâ¦":nN?nw||"Enviando invitacionesâ¦":lI?sR?"Recalculando el % de apego de todos los candidatos con IA⦠Puede tardar varios minutos.":nC?"Recalculando el % de apego de los candidatos seleccionadosâ¦":"Re-an\xe1lisis de apego en colaâ¦":"Procesandoâ¦"})]}),(0,s.jsxs)("div",{className:nj||nN||lI?"pointer-events-none select-none opacity-55 transition-opacity":"",children:[(0,s.jsxs)("div",{className:"relative z-30 flex flex-wrap items-center gap-3 mb-4",children:[(0,s.jsx)(B.I,{placeholder:"Buscar por nombre, email o tel\xe9fono...",value:ic,onChange:e=>id(e.target.value),className:"max-w-xs h-9 text-sm"}),(0,s.jsx)(eK,{applications:ab,datePreset:ie,onDatePreset:ia,quickFilters:it,onToggleQuick:e=>is(a=>({...a,[e]:!a[e]}))}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[ii.filter(e=>{if(!la.has(e.id)||(0,v.$o)(e.name))return!1;let a=e.name.trim().toLowerCase();return"extracci\xf3n tg"!==a&&"busqueda profunda"!==a&&"b\xfasqueda profunda"!==a}).map(e=>(0,s.jsx)("button",{type:"button",onClick:()=>io(a=>a.includes(e.id)?a.filter(a=>a!==e.id):[...a,e.id]),className:"inline-flex items-center px-2 py-1 rounded text-xs font-medium border ".concat(il.includes(e.id)?"ring-1 ring-offset-1 ring-blue-500 bg-blue-50 border-blue-200 text-blue-800":"bg-gray-50 border-gray-200 text-gray-700 hover:bg-gray-100"),style:il.includes(e.id)?void 0:{borderLeftColor:e.color,borderLeftWidth:"3px"},children:e.name},e.id)),r8+r7>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>{let e=!(s5||s4);s2(e),s3(e),e&&s9(!1)},className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ".concat(s5||s4?"ring-1 ring-offset-1 ring-teal-700 bg-teal-50 border-teal-200 text-teal-900":"bg-gray-50 border-gray-200 text-gray-700 hover:bg-gray-100"),title:"Solo candidatos de Extracci\xf3n TG (LinkedIn / bases TG)",children:[(0,s.jsx)(T.Z,{className:"w-3 h-3"}),"Extracci\xf3n TG (",r8+r7,")"]}),le>0&&(0,s.jsxs)("button",{type:"button",onClick:()=>{s9(e=>{let a=!e;return a&&(s2(!1),s3(!1)),a})},className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ".concat(s6?"ring-1 ring-offset-1 ring-indigo-600 bg-indigo-50 border-indigo-200 text-indigo-900":"bg-gray-50 border-gray-200 text-gray-700 hover:bg-gray-100"),title:"Solo candidatos de B\xfasqueda profunda",children:[(0,s.jsx)(a0.Z,{className:"w-3 h-3"}),"B\xfasqueda profunda (",le,")"]}),lt.map(e=>{let{origin:a,count:t,label:i}=e;return(0,s.jsxs)("button",{type:"button",onClick:e=>{e.preventDefault(),e.stopPropagation(),s7(e=>e.includes(a)?e.filter(e=>e!==a):[...e,a])},className:"inline-flex items-center gap-1 px-2 py-1 rounded text-xs font-medium border ".concat(s8.includes(a)?"ring-1 ring-offset-1 ring-teal-600 bg-teal-50 border-teal-200 text-teal-900":"bg-gray-50 border-gray-200 text-gray-700 hover:bg-gray-100"),title:"Filtrar origen: ".concat(i),"aria-pressed":s8.includes(a),children:[i," (",t,")"]},a)}),(0,s.jsxs)(j.z,{variant:"outline",size:"sm",onClick:()=>iE(!0),className:"h-8",children:[(0,s.jsx)(tg.Z,{className:"w-4 h-4 mr-1"}),"Gestionar etiquetas"]}),(ic||il.length>0||null!=iu||s8.length>0||s5||s4||s6||null!=ie||e$(it))&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"text-xs text-gray-500",children:[r9.length," de ",ab.length]}),(0,s.jsx)(j.z,{variant:"ghost",size:"sm",onClick:()=>{id(""),io([]),im(null),s2(!1),s3(!1),s9(!1),s7([]),ia(null),is({})},className:"h-8 text-gray-600",children:"Limpiar filtros"})]})]})]}),"table"===ij&&nf.size>0&&(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 mb-3 p-3 rounded-lg border border-blue-200 bg-blue-50/90 text-sm",children:[(0,s.jsxs)("span",{className:"font-medium text-blue-900",children:[nf.size," seleccionado(s)"]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"icon",className:"h-8 w-8 shrink-0 border-[#25D366]/60 bg-[#25D366]/10 text-[#075e54] hover:bg-[#25D366]/20 hover:text-[#075e54]",title:"Enviar WhatsApp a seleccionados","aria-label":"Enviar WhatsApp a candidatos seleccionados",disabled:nj||nN||lI,onClick:()=>nz(!0),children:(0,s.jsx)(tb.Z,{className:"w-4 h-4"})}),(0,s.jsxs)(ex.h_,{children:[(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsxs)(j.z,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 bg-white border-blue-200 text-blue-900 hover:bg-blue-100/80",children:["Acciones",(0,s.jsx)(S.Z,{className:"w-4 h-4 opacity-70","aria-hidden":!0})]})}),(0,s.jsxs)(ex.AW,{align:"end",className:"z-[110] w-56",children:[(0,s.jsx)(ex.Ju,{className:"text-xs font-normal text-muted-foreground",children:"Candidatos seleccionados"}),(0,s.jsx)(ex.Xi,{onClick:lh,disabled:nj||nN||lI,children:"Limpiar selecci\xf3n"}),(0,s.jsx)(ex.VD,{}),(0,s.jsxs)(ex.Xi,{onClick:lE,disabled:nj||nN||lI,className:"gap-2",children:[lI&&nC?(0,s.jsx)(G.Z,{className:"w-4 h-4 shrink-0 animate-spin text-blue-600"}):(0,s.jsx)(td.Z,{className:"w-4 h-4 shrink-0 text-blue-600"}),"Re-analizar apego"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>lb(!0),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(_.Z,{className:"w-4 h-4 shrink-0 text-indigo-600"}),"Pre-seleccionar cliente"]}),(0,s.jsx)(ex.Xi,{onClick:()=>
1lb(!1),disabled:nj||nN||lI,children:"Quitar pre-selecci\xf3n"}),(0,s.jsxs)(ex.Xi,{onClick:()=>void lv(Array.from(nf)),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(K.Z,{className:"w-4 h-4 shrink-0 text-teal-700"}),"Invitar a postularse (m\xe1x. ",20,")"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>void lj(Array.from(nf)),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(th.Z,{className:"w-4 h-4 shrink-0 text-[#0A66C2]"}),"Invitar por LinkedIn (m\xe1x. ",20,")"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>void ly(Array.from(nf)),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(tx.Z,{className:"w-4 h-4 shrink-0 text-[#0A66C2]"}),"Invitar a conectar (m\xe1x. ",20,")"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>nz(!0),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(tb.Z,{className:"w-4 h-4 shrink-0 text-[#25D366]"}),"WhatsApp a seleccionadosâ¦"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>lf(Array.from(nf),"recruiter"),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(ey.Z,{className:"w-4 h-4 shrink-0 text-blue-600"}),"Entrevista contigo (reclutador)"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>lN(Array.from(nf)),disabled:nj||nN||lI,className:"gap-2",children:[(0,s.jsx)(ay.Z,{className:"w-4 h-4 shrink-0 text-teal-700"}),"Entrevista IA (Camila)"]}),(0,s.jsxs)(ex.Xi,{onClick:()=>lf(Array.from(nf),"client"),disabled:nj||nN||lI||!Array.from(nf).every(e=>(0,ei.KK)(ab.find(a=>a.id===e),!!(null==az?void 0:az.clientAvailabilitySubmitted))),className:"gap-2",title:"Solo si el cliente indic\xf3 franja en el informe o disponibilidad semanal en la vacante.",children:[(0,s.jsx)(ey.Z,{className:"w-4 h-4 shrink-0 text-violet-600"}),"Entrevista con el cliente"]}),(0,s.jsxs)(ex.Ph,{children:[(0,s.jsxs)(ex.kt,{disabled:nj||nN||lI,className:"gap-2 [&>svg:last-child]:ml-auto",children:[(0,s.jsx)(tg.Z,{className:"w-4 h-4 shrink-0 text-gray-600"}),"Aplicar etiqueta",(0,s.jsx)(tf.Z,{className:"w-4 h-4 opacity-60","aria-hidden":!0})]}),(0,s.jsx)(ex.TG,{className:"z-[110] w-56 max-h-72 overflow-y-auto",children:0===ii.filter(e=>!(0,v.$o)(e.name)).length?(0,s.jsx)(ex.Xi,{disabled:!0,children:"No hay etiquetas. Crea una con \xabGestionar etiquetas\xbb."}):ii.filter(e=>!(0,v.$o)(e.name)).map(e=>(0,s.jsxs)(ex.Xi,{className:"gap-2",onClick:()=>void lS(e),children:[(0,s.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:e.color}}),e.name]},e.id))})]}),(0,s.jsxs)(ex.Ph,{children:[(0,s.jsxs)(ex.kt,{disabled:nj||nN||lI,className:"gap-2 [&>svg:last-child]:ml-auto",children:["Marcar estado",(0,s.jsx)(tf.Z,{className:"w-4 h-4 opacity-60","aria-hidden":!0})]}),(0,s.jsxs)(ex.TG,{className:"z-[110] w-56",children:[(0,s.jsx)(ex.Xi,{onClick:()=>lA("pending"),children:"Pendiente"}),(0,s.jsx)(ex.Xi,{onClick:()=>lA("reviewed"),children:"Revisado"}),(0,s.jsx)(ex.Xi,{onClick:()=>lA("shortlisted"),children:"Aprobado / lista corta"}),(0,s.jsx)(ex.Xi,{onClick:()=>lA("rejected"),children:"Descartado"}),(0,s.jsx)(ex.Xi,{onClick:()=>lA("applied"),children:"Postulado"}),(0,s.jsx)(ex.Xi,{onClick:()=>lA("reviewing"),children:"En revisi\xf3n"})]})]}),(0,s.jsx)(ex.VD,{}),(0,s.jsxs)(ex.Xi,{onClick:()=>nE(!0),disabled:nj||nN||lI,className:"gap-2 text-destructive focus:bg-destructive/10 focus:text-destructive",children:[(0,s.jsx)(an.Z,{className:"w-4 h-4 shrink-0"}),"Quitar de la vacante"]})]})]})]})]}),"kanban"===ij?(0,s.jsx)(eP,{pipeline:r2,applications:r9,hideEmptyColumns:s8.length>0||s5||s4||s6||il.length>0||!!ic.trim()||null!=iu||null!=ie||e$(it),disabled:nj||nN||lI,onMoveApplication:r4,cardSlots:{interviewAvailabilityMeta:az,reanalyzingIds:sL,reExtractingIds:sF,sendingInterviewEmails:nN,onReanalyze:rW,onShareReport:iP.openShareReport,sendInterviewLinks:lf,inviteCamila:lN,togglePreSelectedForClient:r5,onResendScreening:lk,onViewScreeningAnswers:e=>iq(e),onPatchMatchPercent:rY,onToggleCvReminders:l_,onToggleScreeningReminders:lw,onOpenReminders:iO}}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full text-sm",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b text-left text-gray-600",children:[(0,s.jsx)("th",{className:"py-2 pr-2 w-10 font-medium align-middle",children:(0,s.jsx)("input",{ref:nZ,type:"checkbox",className:"rounded border-gray-300",checked:lc,onChange:()=>{lc?nv(e=>{let a=new Set(e);
1return ll.forEach(e=>a.delete(e)),a}):nv(e=>{let a=new Set(e);return ll.forEach(e=>a.add(e)),a})},title:lc?"Desmarcar todos (filtrados)":"Seleccionar todos (filtrados)",disabled:0===r9.length||nj||nN||lI})}),(0,s.jsx)(t$,{label:"Nombre",sortKey:"name",currentKey:ip,currentDir:ih,onClick:ln,thClassName:"py-2 pr-2 font-medium",icon:(0,s.jsx)($.Z,{className:"w-4 h-4 text-gray-500 shrink-0","aria-hidden":!0}),title:"Nombre del candidato"}),(0,s.jsx)(t$,{label:"Fecha",sortKey:"date",currentKey:ip,currentDir:ih,onClick:ln,thClassName:"py-2 pr-2 font-medium w-32",icon:(0,s.jsx)(I.Z,{className:"w-4 h-4 text-gray-500 shrink-0","aria-hidden":!0}),title:"Fecha de postulaci\xf3n (portal/RF) o de alta manual"}),(0,s.jsx)(t$,{label:"Apego",sortKey:"match",currentKey:ip,currentDir:ih,onClick:ln,thClassName:"py-2 pr-2 font-medium w-40 text-left",buttonClassName:"w-full justify-start",icon:(0,s.jsx)(a3.Z,{className:"w-4 h-4 text-gray-500 shrink-0","aria-hidden":!0}),title:"Porcentaje de apego a la vacante (IA)"}),(0,s.jsx)(t$,{label:"CV",sortKey:"cv",currentKey:ip,currentDir:ih,onClick:ln,thClassName:"py-2 pr-2 font-medium w-20 text-center",buttonClassName:"w-full justify-center",icon:(0,s.jsx)(k.Z,{className:"w-4 h-4 text-gray-500 shrink-0","aria-hidden":!0}),title:"Ordenar por si tiene CV adjunto"}),(0,s.jsx)("th",{className:"py-2 pr-2 font-medium w-28 text-center",children:(0,s.jsxs)("span",{className:"inline-flex items-center justify-center gap-1.5 w-full",title:"Recalcular % de apego con IA. Si a\xfan no hay perfil y hay CV, se extrae del archivo actual.",children:[(0,s.jsx)(td.Z,{className:"w-4 h-4 text-gray-500"}),"An\xe1lisis"]})}),(0,s.jsx)("th",{className:"py-2 pr-2 font-medium w-20 text-center",children:(0,s.jsxs)("span",{className:"inline-flex items-center justify-center gap-1.5 w-full",title:"Recordatorios y seguimientos (CV, preguntas, LinkedIn)",children:[(0,s.jsx)(ef.Z,{className:"w-4 h-4 text-gray-500"}),"Rec."]})}),(0,s.jsx)("th",{className:"py-2 pr-2 font-medium w-20 text-center",children:(0,s.jsxs)("span",{className:"inline-flex items-center justify-center gap-1.5 w-full",title:"Compartir informe del candidato (URL + PIN)",children:[(0,s.jsx)(Z.Z,{className:"w-4 h-4 text-gray-500"}),"Compartir"]})}),(0,s.jsx)("th",{className:"py-2 pr-2 font-medium w-20 text-center",children:(0,s.jsxs)("span",{className:"inline-flex items-center justify-center gap-1.5 w-full",title:"Enviar por email el enlace para agendar entrevista (vacante)",children:[(0,s.jsx)(ey.Z,{className:"w-4 h-4 text-gray-500"}),"Entrevista"]})}),(0,s.jsx)(t$,{label:"Cliente",sortKey:"client",currentKey:ip,currentDir:ih,onClick:ln,thClassName:"py-2 pr-2 font-medium w-24 text-center",buttonClassName:"w-full justify-center",icon:(0,s.jsx)(_.Z,{className:"w-4 h-4 text-gray-500 shrink-0","aria-hidden":!0}),title:"Pre-aprobado para cliente (pool interno) y visible en portal si est\xe1 compartido"})]})}),(0,s.jsx)("tbody",{children:lr.map(e=>{var a,t,i;return(0,s.jsxs)("tr",{className:"border-b border-gray-100 hover:bg-[#fbfcfe]",children:[(0,s.jsx)("td",{className:"py-2 pr-2 align-middle w-10",children:(0,s.jsx)("input",{type:"checkbox",className:"rounded border-gray-300",checked:nf.has(e.id),onChange:()=>lx(e.id),disabled:nj||nN,"aria-label":"Seleccionar ".concat(e.candidate_name||"candidato")})}),(0,s.jsx)("td",{className:"py-2 pr-3 align-top",children:(0,s.jsxs)("div",{className:"min-w-[11.5rem] max-w-[20rem]",children:[(0,s.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,s.jsx)("span",{className:"mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full ".concat((null!==(a=e.profile_view_count)&&void 0!==a?a:0)>0?"bg-[#7ab8ff]":"bg-[#d6dee8]"),title:(null!==(t=e.profile_view_count)&&void 0!==t?t:0)>0?"Perfil visto":"Perfil no visto"}),(0,s.jsx)(r(),{href:"/dashboard/candidates/".concat(e.id),className:"line-clamp-2 text-[13.5px] font-semibold leading-snug tracking-tight text-[#0a2540] hover:text-[#635bff]",target:"_blank",rel:"noopener noreferrer",children:e.candidate_name})]}),(0,s.jsxs)("div",{className:"ml-3 mt-1.5 flex flex-wrap items-center gap-1",children:[(e.screening_pending||"pending"===e.screening_status)&&"completed"!==e.screening_status?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#fff7ed] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#c2410c]",children:"Evaluaci\xf3n pendiente"}):null,"completed"===e.screening_status?(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#f0fdf9] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#0d9488]",children:"Evaluaci\xf3n lista"}):null,(0,s.jsx)(ed.i,{app:e,onlyPending:!0}),"shortlisted"===e.status&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-indigo-50 px-[7px] py-1 text-[10.5px] font-medium leading-none text-indigo-800",title:"Pre-aprobado por reclutador",children:"Pre-aprobado"}),(0,eV.E)(e)&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-red-50 px-[7px] py-1 text-[10.5px] font-medium leading-none text-red-800",title:"Descartado",children:"Descartado"}),e.pre_selected_for_client&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-indigo-50 px-[7px] py-1 text-[10.5px] font-medium leading-none text-indigo-800",title:"Pre-aprobado para cliente",children:"Preseleccionado"}),e.shared_with_client&&"approved"===e.client_decision&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#ecfdf5] px-[7px] py-1 text-[10.5px] font-medium leading-none text-[#047857]",children:"Elegido por cliente"}),e.shared_with_client&&"hired"===e.client_decision&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-[#fffbeb] px-[7
1px] py-1 text-[10.5px] font-medium leading-none text-[#92400e]",children:"Contratado"}),e.shared_with_client&&"rejected"===e.client_decision&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-red-50 px-[7px] py-1 text-[10.5px] font-medium leading-none text-red-800",children:"Descartado por cliente"}),e.shared_with_client&&"approved"!==e.client_decision&&"rejected"!==e.client_decision&&"hired"!==e.client_decision&&(0,s.jsx)("span",{className:"inline-flex items-center rounded-full bg-amber-50 px-[7px] py-1 text-[10.5px] font-medium leading-none text-amber-900",children:"En portal"}),(0,s.jsx)(f.o,{application:e,variant:"meta",showCampaign:!1})]})]})}),(0,s.jsx)("td",{className:"py-2 pr-2 align-top text-gray-600",children:(()=>{let{dateStr:a,kind:t}=(0,eN.eb)(e);return(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"whitespace-nowrap text-sm",children:a}),(0,s.jsx)("span",{className:"text-[10px] text-gray-400 leading-tight",children:t})]})})()}),(0,s.jsx)("td",{className:"py-2 pr-3 text-left align-top",children:(0,s.jsxs)("div",{className:"flex min-w-[9rem] max-w-[12.5rem] flex-col items-start gap-1",children:[(0,em.eo)({match_calculating_at:e.match_calculating_at,match_completeness:e.match_completeness,match_percent:e.match_percent,match_reason:e.match_reason,match_model:e.match_model,ai_profile:e.ai_profile,screening_status:e.screening_status,cv_url:e.cv_url},{forceBusy:sL.has(e.id)||sF.has(e.id)})?(0,s.jsx)(eu.Ag,{size:"sm"}):null!=e.match_percent&&"none"!==e.match_completeness?(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(ao.X,{applicationId:e.id,positionId:null!==(i=e.position_id)&&void 0!==i?i:ez.id,matchPercent:e.match_percent,matchPercentMl:e.match_percent_ml,matchPercentManualAt:e.match_percent_manual_at,matchPercentManualReason:e.match_percent_manual_reason,matchPercentManualByName:e.match_percent_manual_by_name,disabled:nj||nN||lI,variant:"badge",onUpdated:a=>rY(e.id,a)}),e.match_reason?(0,s.jsx)("span",{className:"inline-flex h-5 w-5 items-center justify-center rounded-full text-gray-400 hover:bg-blue-50 hover:text-blue-600",title:e.match_reason,children:(0,s.jsx)(tv.Z,{className:"h-3.5 w-3.5"})}):null]}):null,e.match_completeness&&"complete"!==e.match_completeness&&!(0,em.eo)({match_calculating_at:e.match_calculating_at,match_completeness:e.match_completeness,match_percent:e.match_percent,match_reason:e.match_reason,match_model:e.match_model,ai_profile:e.ai_profile,screening_status:e.screening_status,cv_url:e.cv_url})?(0,s.jsx)(ed.C,{app:e}):null,(0,s.jsx)(ec.q,{flags:e.match_flags,variant:"line"})]})}),(0,s.jsx)("td",{className:"py-2 pr-2 text-center",children:e.cv_url?(0,s.jsx)("a",{href:e.cv_url,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 hover:underline inline-flex items-center justify-center",title:"Abrir CV en nueva pesta\xf1a",children:(0,s.jsx)(k.Z,{className:"w-4 h-4"})}):e.candidate_profile_version_id?(0,s.jsx)("span",{className:"text-[10px] font-medium text-slate-600",title:"Perfil CV guardado",children:"Perfil CV"}):(0,s.jsx)(ed.i,{app:e})}),(0,s.jsx)("td",{className:"py-2 pr-2 text-center",children:(0,s.jsx)("div",{className:"inline-flex items-center justify-center gap-0.5",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",onClick:a=>{a.stopPropagation(),rW(e.id)},disabled:sL.has(e.id)||sF.has(e.id),className:"hover:bg-blue-50",title:sF.has(e.id)?"Re-extraiendo perfil...":sL.has(e.id)?"Re-analizando...":"Re-calcular % de apego con IA (clic)",children:sL.has(e.id)||sF.has(e.id)?(0,s.jsx)(G.Z,{className:"w-4 h-4 animate-spin text-blue-600"}):(0,s.jsx)(td.Z,{className:"w-4 h-4 text-blue-600"})})})}),(0,s.jsx)("td",{className:"py-2 pr-2 text-center",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",onClick:()=>iO(e.id),className:"hover:bg-amber-50",title:"Recordatorios y seguimientos","aria-label":"Recordatorios y seguimientos",children:(0,s.jsx)(ef.Z,{className:"w-4 h-4 text-amber-700"})})}),(0,s.jsx)("td",{className:"py-2 pr-2 text-center",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",onClick:()=>void iP.openShareReport(e.id),className:"hover:bg-green-50",title:"Compartir informe (URL + PIN)",children:(0,s.jsx)(Z.Z,{className:"w-4 h-4 text-green-600"})})}),(0,s.jsx)("td",{className:"py-2 pr-2 text-center",children:(0,s.jsxs)(ex.h_,{children:[(0,s.jsx)(ex.$F,{asChild:!0,children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",disabled:nj||nN,className:"hover:bg-violet-50",title:"Enviar por email el enlace para agendar entrevista","aria-label":"Enviar enlace de entrevista",children:(0,s.jsx)(ey.Z,{className:"w-4 h-4 text-violet-600"})})}),(0,s.jsxs)(ex.AW,{align:"end",className:"z-[110] w-[min(100vw-2rem,18rem)]",children:[(0,s.jsx)(ex.Xi,{onClick:()=>lf([e.id],"recruiter"),className:"text-sm",children:"Entrevista contigo (reclutador)"}),(0,s.jsx)(ex.Xi,{onClick:()=>lN([e.id]),className:"text-sm",children:"Entrevista con Camila"}),(0,s.jsx)(ex.Xi,{onClick:()=>lf([e.id],"client"),disabled:!(0,ei.KK)(e,!!(null==az?void 0:az.clientAvailabilitySubmitted)),className:"text-sm",title:(0,ei.KK)(e,!!(null==az?void 0:az.clientAvailabilitySubmitted))?"Huecos dentro de la franja del cliente en el informe.":"El cliente debe indicar franja en el informe o disponibilidad en la vacante.",children:"Entrevista con el cliente"}),(e.screening_pending||"pending"===e.screening_status)&&"completed"!==e.screening_status?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),(0,s.jsx)(ex.Xi,{onClick:()=>void lk(e.id),className:"text-sm",children:"Enviar preguntas de la posici\xf3n"}),!1===e.screening_reminders_enabled?(0,s.jsx)(ex.Xi,{onClick:()=>void lw(e.id,"resume"),className:"text-sm",children:"Reactivar recordatorios de preguntas"}):(0,s.jsx)(ex.Xi,{onClick:()=>void lw(e.id,"stop"),className:"text-sm",children:"Detener recordatorios de preguntas"})]}):null,"completed"===e.screening_status?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),(0,s.jsx)(ex.Xi,{onClick:()=>iq(e.id),className:"text-sm",children:"Ver respuestas"})]}):null,"pending"===e.cv_collection_status?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ex.VD,{}),e.cv_reminders_enabled?(0,s.jsx)(ex.Xi,{onClick:()=>void l_(e.id,"stop"),className:"text-sm",children:"Detener recordatorios de CV"}):(0,s.jsx)(ex.Xi,{onClick:()=>void l_(e.id,"resume"),className:"text-sm",children:"Reactivar recordatorios de CV"})]}):null]})]})}),(0,s.jsx)("td",{className:"py-2 pr-2 text-center",children:(0,s.jsx)(j.z,{variant:"ghost",size:"icon",onClick:()=>r5(e.id,!!e.pre_selected_for_client),className:e.pre_selected_for_client?"bg-indigo-50 text-indigo-700 hover:bg-indigo-100":"hover:bg-gray-100",title:e.pre_selected_for_client?"Quitar pre-aprobaci\xf3n para cliente (sale del pool y del portal)":"Pre-aprobar para cliente (pool interno; comparte el subset en \xabCompartir pre-seleccionados\xbb)",children:(0,s.jsx)(_.Z,{className:"w-4 h-4 ".concat(e.pre_selected_for_client?"text-indigo-600":"text-gray-400")})})})]},e.id)})})]})})]})]})]})]}),(null==ez?void 0:ez.id)&&(!eX||aC)&&(0,s.jsxs)(N.Zb,{className:"overflow-hidden",children:[(0,s.jsxs)("button",{type:"button",onClick:()=>sE(!sA),className:"w-full flex items-center justify-between gap-2 py-4 px-6 text-left hover:bg-gray-50/80 transition-colors","aria-expanded":!sA,"aria-controls":"position-drawer-invite-talentos",children:[(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)(N.ll,{className:"flex items-center space-x-2 text-base font-semibold",children:[(0,s.jsx)(a3.Z,{className:"w-5 h-5 text-blue-600 shrink-0"}),(0,s.jsx)("span",{children:"Invitar a talentos"})]}),(0,s.jsx)("p",{className:"text-sm text-gray-500 mt-1 font-normal",children:"Mensaje de invitaci\xf3n (definido en el asistente) y alta desde tu base global."})]}),sA?(0,s.jsx)(S.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0}):(0,s.jsx)(A.Z,{className:"w-5 h-5 text-gray-500 shrink-0","aria-hidden":!0})]}),!sA&&(0,s.jsxs)(N.aY,{id:"position-drawer-invite-talentos",className:"space-y-4 pt-0",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900 mb-2",children:"Mensaje de invitaci\xf3n a candidatos"}),(ez.candidate_invitation_message||"").trim()?(0,s.jsx)("p",{className:"text-sm text-gray-700 whitespace-pre-wrap rounded-md border border-gray-100 bg-gray-50/80 p-3",children:ez.candidate_invitation_message}):(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"A\xfan no hay mensaje guardado. Edita la posici\xf3n en el asistente para a\xf1adir uno."})]}),(0,s.jsxs)("div",{className:"border-t border-gray-100 pt-4 space-y-3",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-gray-900",children:"A\xf1adir candidatos de tu base"}),(0,s.jsx)("p",{className:"text-xs text-gray-500",children:"Selecciona uno o varios candidatos (agrupados por email). Se crea una postulaci\xf3n en esta vacante copiando el perfil des
1de su ficha, igual que en Candidatos â Asignar a vacante."}),(0,s.jsx)(B.I,{type:"search",value:nF,onChange:e=>nM(e.target.value),placeholder:"Buscar por nombre o emailâ¦",className:"text-sm","aria-label":"Filtrar candidatos"}),(0,s.jsx)("div",{className:"max-h-56 overflow-y-auto rounded-md border border-gray-200 divide-y divide-gray-100",children:nR?(0,s.jsxs)("div",{className:"flex items-center gap-2 p-4 text-sm text-gray-500",children:[(0,s.jsx)(G.Z,{className:"h-4 w-4 animate-spin shrink-0","aria-hidden":!0}),"Cargando candidatosâ¦"]}):0===rf.length?(0,s.jsx)("p",{className:"p-4 text-sm text-gray-500",children:nF.trim()?"Ning\xfan candidato coincide con la b\xfasqueda.":"A\xfan no hay candidatos en tu base. Agr\xe9galos desde Candidatos."}):rf.map(e=>{let a=tJ(e,ez.id),t=nV.has(e.key),i=(e.candidate_name||"").trim()||(e.candidate_email||"").trim()||"Sin nombre",n=(e.candidate_email||"").trim();return(0,s.jsxs)("label",{className:"flex items-start gap-3 p-3 cursor-pointer hover:bg-gray-50/90 "+(a?"opacity-60":""),children:[(0,s.jsx)("input",{type:"checkbox",className:"mt-1 h-4 w-4 rounded border-gray-300",checked:t,disabled:a,onChange:()=>!a&&rv(e.key),"aria-label":"Seleccionar ".concat(i)}),(0,s.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-gray-900 block truncate",children:i}),n?(0,s.jsx)("span",{className:"text-xs text-gray-500 block truncate",children:n}):null,a?(0,s.jsx)("span",{className:"text-xs text-amber-700 mt-1 inline-block",children:"Ya en esta vacante"}):null]})]},e.key)})}),(0,s.jsx)(j.z,{type:"button",className:"w-full sm:w-auto bg-blue-600 hover:bg-blue-700",disabled:nU||nR||0===nV.size||[...nV].every(e=>{let a=rb.find(a=>a.key===e);return!a||tJ(a,ez.id)}),onClick:()=>void rj(),children:nU?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin","aria-hidden":!0}),"A\xf1adiendoâ¦"]}):"A\xf1adir seleccionados a esta vacante"})]})]})]})]})]})}),np&&(0,s.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/50",role:"dialog","aria-modal":"true","aria-labelledby":"publish-portal-incomplete-title",onClick:()=>{nx(!1),ng(null),nb.current=!1},children:(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full p-6",onClick:e=>e.stopPropagation(),children:[(0,s.jsx)("h3",{id:"publish-portal-incomplete-title",className:"text-lg font-semibold text-gray-900",children:"Contenido para candidatos incompleto"}),(0,s.jsxs)("p",{className:"text-sm text-gray-600 mt-2 leading-relaxed",children:["Siguen sin texto (o incompletas) estas partes:"," ",(0,s.jsx)("strong",{className:"text-gray-800",children:rL.join(" \xb7 ")}),". El portal puede usar la descripci\xf3n interna u otros textos, pero conviene revisarlas."]}),(0,s.jsx)("p",{className:"text-sm text-gray-700 mt-3",children:"save_active"===nh?"\xbfGuardar como activa de todos modos o volver al borrador para completar?":"\xbfPublicar de todos modos o seguir editando?"}),(0,s.jsxs)("div",{className:"flex flex-col-reverse sm:flex-row sm:justify-end gap-2 mt-6",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",onClick:()=>{nx(!1),ng(null),nb.current=!1},children:"Seguir editando"}),(0,s.jsx)(j.z,{type:"button",onClick:()=>rV(),children:"save_active"===nh?"Guardar activa igual":"Publicar igual"})]})]})}),aT&&(0,s.jsx)("div",{className:"fixed inset-0 z-[60] overflow-y-auto bg-black/50",role:"dialog","aria-modal":"true","aria-labelledby":"add-batch-candidates-title",children:(0,s.jsx)("div",{className:"flex min-h-full items-center justify-center p-4 py-8",children:(0,s.jsxs)("div",{className:"relative w-full max-w-2xl max-h-[min(88dvh,calc(100dvh-2rem))] overflow-y-auto overscroll-y-contain rounded-lg bg-white p-6 shadow-xl",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h3",{id:"add-batch-candidates-title",className:"text-lg font-semibold",children:"Agregar candidato(s)"}),(0,s.jsx)("button",{onClick:()=>aq(!1),className:"text-gray-500 hover:text-gray-700",children:(0,s.jsx)(ae.Z,{className:"w-5 h-5"})})]}),(0,s.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"Uno o varios CVs (PDF, imagen o Word), o una hoja CSV de contactos. Por cada CV se crea un perfil y se calcula el % de apego. Con CSV se importan a Identificado (Extracci\xf3n TG) y, si hay LinkedIn, se completa el perfil y un % estimado (ver\xe1s el reloj \xabCalculando\xbb mientras corre)."}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)(U._,{className:"text-xs text-gray-600",children:"Si hay candidatos duplicados en esta vacante"}),(0,s.jsxs)("select",{className:"mt-1 h-9 w-full rounded-md border border-gray-300 bg-white px-2 text-sm",value:t6,onChange:e=>t9(e.target.value),disabled:aY,children:[(0,s.jsx)("option",{value:"ask",children:"Preguntar si ya hay postulaci\xf3n en esta vacante (recomendado)"}),(0,s.jsx)("option",{value:"merge",children:"Fusionar (mantener mejor info)"}),(0,s.jsx)("option",{value:"overwrite",children:"Sobrescribir (actualizar existente)"}),(0,s.jsx)("option",{value:"skip",children:"Pasar por alto (omitir duplicado)"})]})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"rounded-lg border-2 border-dashed p-6 text-center transition-colors ".concat(tP?"border-blue-400 bg-blue-50":"border-gray-300 bg-gray-50/70"),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),aY||tq(!0)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),aY||tq(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),aY||tq(!1)},onDrop:e=>{e.preventDefault(),e.stopPropagation(),aY||(tq(!1),rJ(e.dataTransfer.files))},children:[(0,s.jsx)(tj.Z,{className:"w-8 h-8 mx-auto text-gray-500 mb-2"}),(0,s.jsx)("p",{className:"text-sm text-gray-700",children:"Arrastra CVs o un CSV de contactos aqu\xed"}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-1",children:"Formatos: PDF, imagen, DOC, DOCX, CSV."}),(0,s.jsx)(B.I,{type:"file",multiple:!0,accept:".pdf,image/jpeg,image/png,image/webp,image/gif,.doc,.docx,.csv,.tsv,text/csv",className:"mt-4 text-sm",disabled:aY,onChange:e=>{rJ(e.target.files),e.currentTarget.value=""}})]}),(0,s.jsxs)("div",{className:"rounded-lg border border-gray-200 bg-gray-50/50 p-4 space-y-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-900",children:[(0,s.jsx)(ty.Z,{className:"w-4 h-4 shrink-0 text-blue-600","aria-hidden":!0}),"Importar desde Google Drive"]}),(0,s.jsx)("p",{className:"text-xs text-gray-600",children:se?(0,s.jsx)(s.Fragment,{children:"Pega el enlace de la carpeta de Google Drive. Solo se importan archivos en la ra\xedz de esa carpeta (no subcarpetas)."}):(0,s.jsxs)(s.Fragment,{children:["Conecta Drive en"," ",(0,s.jsx)(r(),{href:"/dashboard/profile",className:"text-blue-600 underline",children:"tu perfil"}),". Luego pega el enlace de la carpeta (solo archivos en la ra\xedz de esa carpeta)."]})}),!se&&(0,s.jsx)("p",{className:"text-xs text-amber-800 bg-amber-50 border border-amber-100 rounded px-2 py-1.5",children:"A\xfan no hay permiso de Drive para tu cuenta. Usa \xabConectar Google Drive\xbb en tu perfil."}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,s.jsx)(B.I,{type:"url",placeholder:"https://drive.google.com/drive/folders/...",value:t8,onChange:e=>{t7(e.target.value),sl(null)},disabled:aY||st||si,className:"text-sm flex-1"}),(0,s.jsx)(j.z,{type:"button",variant:"outline",disabled:!se||aY||st||si||!t8.trim(),onClick:()=>void rx(),children:st?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Revisandoâ¦"]}):"Vista previa"})]}),sr&&(0,s.jsxs)("div",{className:"text-xs space-y-2 border-t border-gray-200 pt-3",children:[(0,s.jsxs)("p",{className:"text-gray-700",children:["En carpeta: ",(0,s.jsx)("strong",{children:sr.totalInFolder})," \xb7 Elegibles por formato/tama\xf1o:"," ",(0,s.jsx)("strong",{className:"text-emerald-700",children:sr.eligibleCount})," \xb7 Excluidos por Drive: ",(0,s.jsx)("strong",{className:"text-amber-800",children:sr.skippedCount})]}),so&&(null==ez?void 0:ez.id)?(0,s.jsx)("div",{className:"rounded-md border border-slate-200 bg-white px-2.5 py-2 text-gray-800 space-y-1.5",children:"overwrite"===t6||"merge"===t6?(0,s.jsxs)("p",{children:["Con ",(0,s.jsx)("strong",{children:"overwrite"===t6?"Sobrescribir":"Fusionar"})," se encolar\xe1n ",(0,s.jsx)("strong",{children:so.wouldImportCount})," archivo(s) elegible(s); no se excluyen por haber estado ya en un lote de esta vacante."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{children:["Respecto a ",(0,s.jsx)("strong",{children:"esta vacante"})," (nombres ya en lotes previos o en curso):"," ",(0,s.jsx)("strong",{className:"text-emerald-800",children:so.wouldImportCount})," ","nuevo(s) a importar \xb7"," ",(0,s.jsx)("strong",{className:"text-amber-900",children:so.wouldSkipAsDuplicateCount})," ","se omitir\xe1n con \xabPreguntar\xbb o \xabPasar por alto\xbb."]}),so.wouldSkipAsDuplicateCount>0&&so.skippedDuplicateDisplayNames.length>0&&(0,s.jsxs)("ul",{className:"max-h-20 overflow-y-auto text-amber-950 list-disc pl-4 space-y-0.5 text-[11px]",children:[so.skippedDuplicateDisplayNames.map((e,a)=>(0,s.jsx)("li",{children:e},"".concat(a,"-").concat(e))),so.wouldSkipAsDuplicateCount>so.skippedDuplicateDisplayNames.length?(0,s.jsx)("li",{className:"list-none text-gray-500",children:"⦠y m\xe1s"}):null]})]})}
1):null,sr.skipped.length>0&&(0,s.jsxs)("ul",{className:"max-h-24 overflow-y-auto text-amber-900 list-disc pl-4 space-y-0.5",children:[sr.skipped.slice(0,12).map(e=>(0,s.jsxs)("li",{children:[e.name," â ",e.reason]},e.id)),sr.skipped.length>12?(0,s.jsx)("li",{className:"list-none text-gray-500",children:"⦠y m\xe1s"}):null]}),(0,s.jsx)(j.z,{type:"button",className:"w-full sm:w-auto bg-blue-600 hover:bg-blue-700",disabled:0===sr.eligibleCount||aY||si||st||null!==so&&0===so.wouldImportCount&&("ask"===t6||"skip"===t6),onClick:()=>void rh(t6),children:si?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Importando desde Driveâ¦"]}):"Importar ".concat(null!==(er=null==so?void 0:so.wouldImportCount)&&void 0!==er?er:sr.eligibleCount," CV(s) desde Drive")})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("p",{className:"text-sm font-medium text-gray-800",children:["Archivos listos (",a5.length+(a4?1:0),")"]}),tB&&tW&&(0,s.jsxs)("p",{className:"flex items-center gap-2 text-xs text-blue-700",children:[(0,s.jsx)(G.Z,{className:"w-3.5 h-3.5 animate-spin shrink-0","aria-hidden":!0}),(0,s.jsxs)("span",{children:["Procesando ",tB.processed,"/",tB.total," \xb7"," ",tZ(tB.step)]})]}),0!==a5.length||a4?(0,s.jsxs)("div",{className:"space-y-2",children:[a4?(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 border rounded-md bg-white px-3 py-2",children:[(0,s.jsxs)("p",{className:"text-sm text-gray-700 truncate",children:["CSV contactos: ",a4.name]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-gray-500 hover:text-red-600",disabled:aY,onClick:()=>tz(null),children:(0,s.jsx)(ae.Z,{className:"w-4 h-4"})})]}):null,a5.map((e,a)=>(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 border rounded-md bg-white px-3 py-2",children:[(0,s.jsxs)("p",{className:"text-sm text-gray-700 truncate",children:[a+1,". ",e.name]}),(0,s.jsx)(j.z,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-gray-500 hover:text-red-600",disabled:aY,onClick:()=>r$(a),children:(0,s.jsx)(ae.Z,{className:"w-4 h-4"})})]},"".concat(e.name,"-").concat(e.size,"-").concat(e.lastModified)))]}):(0,s.jsx)("p",{className:"text-sm text-gray-500",children:"Aun no has agregado archivos."}),t4&&(0,s.jsxs)("div",{className:0===t4.failed?"rounded-md border border-emerald-200 bg-emerald-50 px-3 py-2":"rounded-md border border-amber-200 bg-amber-50 px-3 py-2",children:[(0,s.jsxs)("p",{className:0===t4.failed?"text-sm font-medium text-emerald-900":"text-sm font-medium text-amber-950",children:["Resumen: importados ",t4.ok," \xb7 con error ",t4.failed]}),t4.names.length>0&&(0,s.jsxs)("p",{className:0===t4.failed?"text-xs text-emerald-800 mt-1":"text-xs text-amber-900 mt-1",children:["Importados: ",t4.names.join(", ")]}),t4.hint?(0,s.jsx)("p",{className:"text-xs text-amber-950 mt-2 leading-snug",children:t4.hint}):null]})]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 mt-6",children:[(0,s.jsx)(j.z,{variant:"outline",onClick:()=>aq(!1),children:"Cancelar"}),(0,s.jsx)(j.z,{onClick:()=>void rg(t6),disabled:aY,children:aY?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Analizando y guardando..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(to.Z,{className:"w-4 h-4 mr-2"}),"Importar y analizar"]})})]})]})})}),iN&&(0,s.jsx)("div",{className:"fixed inset-0 z-[130] flex items-center justify-center p-4 bg-black/50",role:"dialog","aria-modal":"true","aria-labelledby":"pipeline-modal-title",onClick:()=>!iC&&i_(!1),children:(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-lg w-full max-h-[min(90vh,560px)] flex flex-col p-6",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3 shrink-0",children:[(0,s.jsx)("h3",{id:"pipeline-modal-title",className:"text-lg font-semibold",children:"Etapas del proceso"}),(0,s.jsx)("button",{type:"button",className:"text-gray-500 hover:text-gray-700 disabled:opacity-50",disabled:iC,onClick:()=>i_(!1),"aria-label":"Cerrar",children:(0,s.jsx)(ae.Z,{className:"w-5 h-5"})})]}),(0,s.jsxs)("p",{className:"text-sm text-gray-600 mb-4 shrink-0",children:["Define las columnas del tablero y su orden (de izquierda a derecha en el Kanban). El ",(0,s.jsx)("strong",{children:"id"})," es t\xe9cnico (sin espacios); arrastra con el control de la izquierda para reordenar etapas."]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto min-h-0 pr-1 mb
1-4",children:(0,s.jsx)(e9,{stages:iw,disabled:iC,onChange:ik})}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 shrink-0 mb-4",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",disabled:iC,onClick:()=>{let e="Nueva etapa",a=tX(e),t=2;for(;iw.some(e=>e.id===a);)a="".concat(tX(e),"_").concat(t),t+=1;ik(t=>[...t,{id:a,label:e}])},children:"A\xf1adir etapa"}),(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",disabled:iC,onClick:()=>ik(el.lN.map(e=>({...e}))),children:"Restaurar default"})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 shrink-0",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",disabled:iC,onClick:()=>i_(!1),children:"Cancelar"}),(0,s.jsx)(j.z,{type:"button",disabled:iC,onClick:()=>{let e=iw.map(e=>e.id);if(new Set(e).size!==e.length){iI.error("Validaci\xf3n","Hay ids duplicados.");return}for(let e of iw)if(!(0,el.YE)(e.id)||!String(e.label||"").trim()){iI.error("Validaci\xf3n","Cada etapa necesita id v\xe1lido (letra min\xfascula + n\xfameros/guiones bajos) y nombre.");return}r6()},children:iC?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Guardandoâ¦"]}):"Guardar"})]})]})}),(0,s.jsx)(ad.T,{open:!!iP.modal,url:null!==(eo=null===(m=iP.modal)||void 0===m?void 0:m.url)&&void 0!==eo?eo:"",pin:null!==(ep=null===(C=iP.modal)||void 0===C?void 0:C.pin)&&void 0!==ep?ep:null,pinLegacyOnly:null===(z=iP.modal)||void 0===z?void 0:z.pinLegacyOnly,loading:iP.isOpening,actionLoading:iP.actionLoading,attachmentsSaving:iP.attachmentsSaving,attachments:null===(q=iP.modal)||void 0===q?void 0:q.attachments,sharedAttachmentIds:null===(R=iP.modal)||void 0===R?void 0:R.sharedAttachmentIds,appId:null===(D=iP.modal)||void 0===D?void 0:D.appId,onClose:iP.closeShareReport,onRegeneratePin:()=>void iP.regeneratePin(),onCopyUrl:iP.copyUrl,onCopyPin:iP.copyPin,onCopyLinkAndPin:iP.copyLinkAndPin,onSaveSharedAttachments:e=>{var a;return(null===(a=iP.modal)||void 0===a?void 0:a.appId)?iP.saveSharedAttachments(iP.modal.appId,e):void 0}}),sU&&(0,s.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/50",children:(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full p-6",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,s.jsx)("h3",{className:"text-lg font-semibold",children:"Compartir vacante con cliente"}),(0,s.jsx)("button",{type:"button",onClick:()=>{sX(!1),sQ("select")},className:"text-gray-500 hover:text-gray-700",children:(0,s.jsx)(ae.Z,{className:"w-5 h-5"})})]}),(0,s.jsx)("p",{className:"text-sm text-gray-600 mb-4",children:"select"===sK?"Elige qu\xe9 candidatos pre-aprobados ver\xe1 el cliente en el portal (puedes tener m\xe1s pre-aprobados internos y compartir solo una parte). Luego obtendr\xe1s el enlace y el PIN.":"Comparta el enlace y el PIN. El cliente ver\xe1 la vacante y \xfanicamente los candidatos que marcaste abajo. Si ten\xe9is agenda activa, desde el mismo portal puede indicar disponibilidad."}),"select"===sK?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-xs text-gray-500",children:"Visibles en el portal para el cliente"}),(0,s.jsx)("div",{className:"mt-2 max-h-56 overflow-y-auto rounded-md border border-gray-200 divide-y divide-gray-100",children:ab.filter(e=>e.pre_selected_for_client).map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-3 px-3 py-2.5 text-sm cursor-pointer hover:bg-gray-50",children:[(0,s.jsx)("input",{type:"checkbox",className:"rounded border-gray-300 shrink-0",checked:s0.has(e.id),onChange:()=>r0(e.id)}),(0,s.jsx)("span",{className:"min-w-0 flex-1 font-medium text-gray-900 truncate",children:e.candidate_name||"Sin nombre"}),e.shared_with_client?(0,s.jsx)("span",{className:"text-[10px] text-emerald-700 shrink-0",children:"ya compartido"}):null]},e.id))}),(0,s.jsx)("p",{className:"text-xs text-gray-500 mt-2",children:"Si no marcas a nadie, el portal mostrar\xe1 la vacante sin lista de candidatos hasta que vuelvas a abrir este flujo."})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2 justify-end",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",size:"sm",disabled:sW,onClick:()=>sX(!1),children:"Cancelar"}),(0,s.jsx)(j.z,{type:"button",size:"sm",disabled:sW,onClick:()=>void r1(),children:sW?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Guardandoâ¦"]}):"Continuar y obtener enlace"})]})]}):sW&&!sG?(0,s.jsxs)("div",{className:"flex items-center gap-2 text-gray-500 py-4",children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 animate-spin"}),(0,s.jsx)("span",{children:"Generando enlace..."})]}):sG?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)(j.z,{type:"button",variant:"link",size:"sm",className:"h-auto p-0 text-blue-700",onClick:()=>sQ("select"),children:"â Cambiar candidatos visibles para el cliente"}),(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-xs text-gray-500",children:"Enlace"}),(0,s.jsxs)("div",{className:"flex gap-2 items-center mt-1",children:[(0,s.jsx)(B.I,{readOnly:!0,value:sG,className:"font-mono text-xs flex-1 min-w-0"}),(0,s.jsx)("button",{type:"button",onClick:()=>{sG&&navigator.clipboard&&(navigator.clipboard.writeText(sG),iI.success("Enlace copiado","Enlace copiado al portapapeles."))},className:"shrink-0 p-2 rounded-md text-gray-500 hover:bg-gray-100 hover:text-gray-700",title:"Copiar enlace",children:(0,s.jsx)(w.Z,{className:"w-4 h-4"})})]})]}),s$&&(0,s.jsxs)("div",{children:[(0,s.jsx)(U._,{className:"text-xs text-gray-500",children:"PIN (el cliente lo pedir\xe1 al entrar)"}),(0,s.jsxs)("div",{className:"flex gap-2 items-center mt-1",children:[(0,s.jsx)("span",{className:"flex-1 font-mono text-lg font-semibold tracking-widest py-2 px-3 bg-gray-50 rounded-md border",children:s$}),(0,s.jsx)("button",{type:"button",onClick:()=>{s$&&navigator.clipboard&&(navigator.clipboard.writeText(s$),iI.success("PIN copiado","PIN copiado al portapapeles."))},className:"shrink-0 p-2 rounded-md text-gray-500 hover:bg-gray-100 hover:text-gray-700",title:"Copiar PIN",children:(0,s.jsx)(w.Z,{className:"w-4 h-4"})})]})]})]}):null,(0,s.jsx)("div",{className:"mt-4 flex justify-end",children:(0,s.jsx)(j.z,{variant:"ghost",size:"sm",onClick:()=>{sX(!1),sQ("select")},children:"Cerrar"})})]})}),(null==ez?void 0:ez.id)&&(0,s.jsx)(aS,{open:aF,onOpenChange:aM,positionId:ez.id,positionTitle:ez.title||"",positionLocation:ez.location||"",fuente2Ready:aR,onCompleted:()=>{rd(),fetch("/api/labels").then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.data)&&ir(e.data)}).catch(()=>{}),s2(!0),s3(!0),iy("kanban")}}),(null==ez?void 0:ez.id)&&(0,s.jsx)(aH,{open:aU,onOpenChange:aX,positionId:ez.id,positionTitle:ez.title||"",onCompleted:()=>{rd(),fetch("/api/labels").then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.data)&&ir(e.data)}).catch(()=>{}),s9(!0),s2(!1),s3(!1),iy("kanban")}}),(null==ez?void 0:ez.id)&&(0,s.jsx)(aP,{open:aV,onOpenChange:aB,positionId:ez.id,positionTitle:ez.title||"",positionLocation:ez.location||"",locked:a$.locked,lockReason:a$.progressLabel,onCompleted:()=>{rd(),fetch("/api/labels").then(e=>e.json()).then(e=>{e.success&&Array.isArray(e.data)&&ir(e.data)}).catch(()=>{}),s2(!0),iy("kanban")}}),(null==ez?void 0:ez.id)&&aG?(0,s.jsx)(aK.Y,{open:aG,onOpenChange:aJ,positionId:ez.id,positionTitle:ez.title||"",onFinished:e=>{aJ(!1),e&&iI.info("B\xfasqueda autom\xe1tica en curso","Varias b\xfasquedas en LinkedIn est\xe1n en curso. Le avisaremos cuando est\xe9n en Identificado.")}}):null,(0,s.jsx)(O.P,{open:iA,onClose:()=>iE(!1),onCatalogRefresh:e=>ir(e),onLabelDeleted:e=>{aN(a=>a.map(a=>({...a,labels:(a.labels||[]).filter(a=>a.id!==e)}))),io(a=>a.filter(a=>a!==e))},onLabelUpdated:e=>{aN(a=>a.map(a=>({...a,labels:(a.labels||[]).map(a=>a.id===e.id?{...a,name:e.name,color:e.color}:a)})))},notifySuccess:(e,a)=>iI.success(e,a||""),notifyError:(e,a)=>iI.error(e,a||"")}),iZ,(0,s.jsx)(av.P,{open:nI,onOpenChange:nz,applications:lm,getAuthToken:lu,positionId:ez.id,onSent:()=>{iI.success("WhatsApp en cola","Los mensajes se enviar\xe1n desde tu WhatsApp conectado en los pr\xf3ximos minutos."),lh()}}),nA&&(0,s.jsx)("div",{className:"fixed inset-0 z-[60] flex items-center justify-center p-4 bg-black/50",children:(0,s.jsxs)("div",{className:"bg-white rounded-lg shadow-xl max-w-md w-full p-6",onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bulk-delete-candidates-title",children:[(0,s.jsxs)("div",{className:"flex items-start gap-3 mb-4",children:[(0,s.jsx)("div",{className:"rounded-full bg-red-100 p-2 shrink-0",children:(0,s.jsx)(e7.Z,{className:"w-5 h-5 text-red-600"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{id:"bulk-delete-candidates-title",className:"text-lg font-semibold text-gray-900",children:"Qu
1itar candidatos de la vacante"}),(0,s.jsxs)("p",{className:"text-sm text-gray-600 mt-2",children:["Se eliminar\xe1n ",(0,s.jsx)("strong",{children:nf.size})," postulaci\xf3n(es) de"," ",(0,s.jsx)("strong",{children:null!==(eh=null==ez?void 0:ez.title)&&void 0!==eh?eh:"esta vacante"}),". No se puede deshacer."]})]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,s.jsx)(j.z,{type:"button",variant:"outline",onClick:()=>nE(!1),disabled:nj,children:"Cancelar"}),(0,s.jsx)(j.z,{type:"button",variant:"destructive",onClick:lg,disabled:nj,className:"bg-red-600 hover:bg-red-700",children:nj?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 mr-2 animate-spin"}),"Eliminando..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(an.Z,{className:"w-4 h-4 mr-2"}),"Confirmar"]})})]})]})}),(0,s.jsx)(as,{isOpen:e4,onClose:()=>{e3(!1)},onConfirm:rG,position:ez,loading:e6}),(0,s.jsx)(ar,{isOpen:at,onClose:()=>{ai(!1)},onConfirm:rX,positionTitle:(null==ez?void 0:ez.title)||"",isDeleting:ax}),(0,s.jsx)(au.a,{isOpen:iX,onClose:iJ,...iG,title:null!==(eg=iG.title)&&void 0!==eg?eg:"",message:null!==(eb=iG.message)&&void 0!==eb?eb:""}),(0,s.jsx)(am.x,{open:!!iT,onOpenChange:e=>{e||iq(null)},applicationId:iT,candidateName:null!==(ev=null===(F=ab.find(e=>e.id===iT))||void 0===F?void 0:F.candidate_name)&&void 0!==ev?ev:null,positionTitle:null!==(e_=null==ez?void 0:ez.title)&&void 0!==e_?e_:null}),iL?(0,s.jsx)(eQ.z,{applicationId:iL,candidateName:null!==(ew=null===(J=ab.find(e=>e.id===iL))||void 0===J?void 0:J.candidate_name)&&void 0!==ew?ew:null,onClose:()=>iO(null)}):null,iR&&(null==ez?void 0:ez.id)?(0,s.jsx)(eQ.z,{positionId:ez.id,positionTitle:ez.title,onClose:()=>iD(!1),initialTab:"email"}):null,(0,s.jsx)(ah,{open:iF,onOpenChange:iM,positionId:null!==(ek=null==ez?void 0:ez.id)&&void 0!==ek?ek:null,positionTitle:null!==(eC=null==ez?void 0:ez.title)&&void 0!==eC?eC:null}),(0,s.jsx)(af,{open:iV,onOpenChange:iB,positionId:null!==(eS=null==ez?void 0:ez.id)&&void 0!==eS?eS:null,positionTitle:null!==(eA=null==ez?void 0:ez.title)&&void 0!==eA?eA:null}),(0,s.jsxs)("div",{className:"fixed bottom-4 right-4 z-[70] flex max-w-[min(100vw-2rem,18rem)] flex-col gap-2 items-end pointer-events-none",children:[tW&&tB&&(0,s.jsx)("div",{className:"pointer-events-auto w-full rounded-lg border border-blue-200 bg-white px-3 py-2 shadow-lg",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 text-blue-600 shrink-0 mt-0.5 animate-spin","aria-hidden":!0}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-blue-900",children:"Importaci\xf3n en progreso"}),(0,s.jsxs)("p",{className:"text-xs text-blue-700",children:[tB.processed,"/",tB.total," \xb7 ",tZ(tB.step)]})]})]})}),tK&&t5&&t0===ez.id&&(0,s.jsx)("div",{className:"pointer-events-auto w-full rounded-lg border border-violet-200 bg-violet-50/90 px-3 py-2 shadow-lg",children:(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)(G.Z,{className:"w-4 h-4 text-violet-700 shrink-0 mt-0.5 animate-spin","aria-hidden":!0}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("p",{className:"text-xs font-semibold text-violet-900",children:"Re-an\xe1lisis de apego (lote)"}),(0,s.jsxs)("p",{className:"text-xs text-violet-800",children:[t5.processed,"/",t5.total," \xb7 ",tZ(t5.step)]}),(0,s.jsx)("p",{className:"text-[11px] text-violet-700/90 mt-1 leading-snug",children:"Procesado en cola"})]})]})})]}),nP&&(0,en.createPortal)((0,s.jsx)(al.Q,{open:sF.size>0||sL.size>0||sV,title:sV?"Generando borrador con IA":void 0,subtitle:sV?"Rellenando texto p\xfablico, requisitos, responsabilidades y beneficios. Suele tardar 20â90 s.":void 0,footerHint:sV?null:void 0}),document.body)]})}},85485:function(e,a,t){t.d(a,{V:function(){return u}});var s=t(57437),i=t(2265),n=t(39957),r=t(62442),l=t(98266),o=t(23611),c=t(35831),d=t(81628);function u(e){let{value:a,onValueChange:t,options:u,placeholder:m,emptyText:p="Sin resultados",searchPlaceholder:x="Buscarâ¦",disabled:h,className:g,"aria-label":b}=e,[f,v]=i.useState(!1),[j,y]=i.useState(""),N=i.useId(),_=i.useRef(null),w=i.useRef(null),[k,C]=i.useState(void 0),S=i.useMemo(()=>{let e=j.trim().toLowerCase();return e?u.filter(a=>a.toLowerCase().includes(e)):[...u]},[u,j]);return i.useEffect(()=>{if(f){let e=requestAnimationFrame(()=>{var e;return null===(e=w.current)||void 0===e?void 0:e.focus()});return()=>cancelAnimationFrame(e)}y("")},[f]),(0,s.jsxs)(l.J2,{open:f,onOpenChange:e=>{v(e),e&&_.current&&C(_.current.getBoundingClientRect().width)},children:[(0,s.jsx)(l.xo,{asChild:!0,children:(0,s.jsxs)(o.z,{ref:_,type:"button",variant:"outline",role:"combobox","aria-expanded":f,"aria-controls":N,"aria-label":b,disabled:h,className:(0,d.cn)("h-10 w-full justify-between px-3 py-2 font-normal text-sm",!a&&"text-muted-foreground",g),children:[(0,s.jsx)("span",{className:"truncate text-left",children:a||m}),(0,s.jsx)(n.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50","aria-hidden":!0})]})}),(0,s.jsxs)(l.yk,{className:"max-w-[min(100vw-2rem,24rem)] p-0",style:null!=k?{width:k}:void 0,align:"start",children:[(0,s.jsx)(c.I,{ref:w,placeholder:x,value:j,onChange:e=>y(e.target.value),className:"rounded-none border-0 border-b px-3 py-2 text-sm focus-visible:ring-0 focus-visible:ring-offset-0",autoComplete:"off"}),(0,s.jsx)("div",{id:N,className:"max-h-[min(50vh,280px)] overflow-y-auto p-1",role:"listbox","aria-label":b,children:0===S.length?(0,s.jsx)("p",{className:"px-2 py-3 text-sm text-muted-foreground",children:p}):S.map(e=>(0,s.jsxs)("button",{type:"button",role:"option","aria-selected":a===e,className:(0,d.cn)("flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground",a===e&&"bg-accent"),onClick:()=>{t(e),v(!1)},children:[(0,s.jsx)(r.Z,{className:(0,d.cn)("h-4 w-4 shrink-0 text-primary",a===e?"opacity-100":"opacity-0"),"aria-hidden":!0}),(0,s.jsx)("span",{className:"min-w-0 flex-1 truncate",children:e})]},e))})]})]})}},24300:function(e,a,t){t.d(a,{ng:function(){return o},In:function(){return l},JK:function(){return P},dJ:function(){return f},jd:function(){return j},y:function(){return T},Pj:function(){return v},MI:function(){return y},Zf:function(){return N},Ap:function(){return g},N:function(){return L},WI:function(){return R},r_:function(){return F},L9:function(){return A},GB:function(){return D},no:function(){return w},Ix:function(){return O},B1:function(){return q},EX:function(){return I},X3:function(){return z},Z0:function(){return S},je:function(){return E}});var s=t(68205);let i="b2b_demo",n="job_application";var r=t(62601);let l=r.env.NEXT_PUBLIC_GA_MEASUREMENT_ID||"G-7NJ3SN0EV4",o=r.env.NEXT_PUBLIC_FB_PIXEL_ID||"1770818484239042",c=[],d=!1,u=[],m=!1;function p(e){switch(e){case"candidate":return"candidate";case"recruiter":case"company_admin":return"recruiter";case"super_admin":return"admin";default:return"visitor"}}function x(){try{let e=window.localStorage.getItem(s.j3);if(!e)return!1;let a=(0,s.au)(JSON.parse(e));return!!(a.updatedAt&&a.marketing)}catch(e){return!1}}function h(){return"function"==typeof window.gtag?window.gtag:null}function g(){d=!0,function(){for(;c.length>0;){let e=c.shift();null==e||e()}}()}function b(){return"function"==typeof window.fbq?window.fbq:null}function f(){let e=h();e&&e("consent","update",{analytics_storage:"granted"})}function v(){let e=h();e&&e("consent","update",{analytics_storage:"denied"})}function j(){var e;let a=h();a&&a("consent","update",{ad_storage:"granted",ad_user_data:"granted",ad_personalization:"granted"}),null===(e=b())||void 0===e||e("consent","grant")}function y(){var e;let a=h();a&&a("consent","update",{ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied"}),null===(e=b())||void 0===e||e("consent","revoke")}function N(){for(m=!0;u.length>0;){let e=u.shift();null==e||e()}}function _(e){if(!m){u.push(e);return}e()}function w(e,a){x()&&_(()=>{let t=b();t&&t("track",e,a)})}function k(e,a){x()&&_(()=>{let t=b();t&&t(...a?["track","Lead",e,{eventID:a}]:["track","Lead",e])})}function C(e,a,t){(function(){try{let e=window.localStorage.getItem(s.j3);if(!e)return!1;let a=(0,s.au)(JSON.parse(e));return!!(a.updatedAt&&a.analytics)}catch(e){return!1}})()&&function(e){if(!d){c.push(e);return}e()}(()=>{let s=h();s&&s(e,a,t)})}function S(e,a){let t=a?"".concat(e,"?").concat(a):e;C("event","page_view",{page_path:t,page_location:window.location.href,page_title:"undefined"!=typeof document?document.title:void 0,app_section:/^\/(dashboard|reclutador)/.test(e)?"recruiter":/^\/admin/.test(e)?"admin":/^\/(candidate|career-boost|extension)/.test(e)?"candidate":/^\/(jobs|position|career-site|p)\b/.test(e)?"public_jobs":/^\/entrevista-ia(\/|$)/.test(e)?"ai_interview":/^\/(cliente|disponibilidad-cliente|informe|entrevista)(\/|$)/.test(e)?"client":/^\/auth/.test(e)?"auth":"marketing"})}function A(e,a){C("event",e,a)}function E(e,a){A("sign_up",{method:e,user_role:p(a)})}function I(e,a){A("login",{method:e,user_role:p(a)})}function z(e){A("login_start",{method:e})}let Z="tg_landing_fbclid";function P(){try{var e,a;let t=(null===(e=new URLSearchParams(window.location.search).get("fbclid"))||void 0===e?void 0:e.trim())||"";if(t)return sessionStorage.setItem(Z,t),t;return(null===(a=sessionStorage.getItem(Z))||void 0===a?void 0:a.trim())||null}catch(e){return null}}function T(){return window.location.origin+window.location.pathname+window.location.search+window.location.hash}function q(e){A("generate_lead",{form_name:e}),w("Lead",{content_name:e})}function L(e){e.eventId&&(A("generate_lead",{form_name:e.contentName,lead_type:i}),k({content_name:e.contentName,content_category:i,lead_type:i},e.eventId))}function O(e){var a;if(A("job_application",{position_id:e.positionId,job_slug:e.slug,application_source:e.source,talentpool_mode:null!==(a=e.talentpool)&&void 0!==a&&a}),!(!e.talentpool&&!e.alreadyApplied))return;let t={content_name:e.slug||e.positionId,content_category:n,lead_type:n};e.positionId&&(t.content_ids=[e.positionId]),k(t,e.eventId)}function R(e,a){A(e,{interview_product:"camila",interview_variant:null==a?void 0:a.variant,status:null==a?void 0:a.status})}function D(e){A("extension_store_click",{click_source:e})}function F(e,a){e&&A("cookie_consent",{analytics_granted:e,marketing_granted:a})}},41082:function(e,a,t){t.d(a,{Rr:function(){return r},YM:function(){return n}});var s=t(54131);function i(e){if(!e||"object"!=typeof e)return null;let a=String(e.outcome||"").toLowerCase();if("proceed"!==a&&"reject"!==a)return null;let t="string"==typeof e.submitted_at?e.submitted_at:"";if(!t)return null;let i=null;if(null!=e.rating){let a=Number(e.rating);Number.isFinite(a)&&a>=1&&a<=5&&(i=Math.round(a))}return{id:"string"==typeof e.id&&e.id?e.id:(0,s.randomUUID)(),booking_id:"string"==typeof e.booking_id?e.booking_id:null,interview_at:"string"==typeof e.interview_at?e.interview_at:null,rating:i,outcome:a,note:"string"==typeof e.note&&e.note.trim()||null,submitted_at:t}}function n(e){if(Array.isArray(e))return e.map(i).filter(e=>null!=e);let a=i(e);return a?[a]:[]}function r(e){return null!=e.rating?"".concat(e.rating,"/5"):"reject"===e.outcome?"Descartado":"Sin puntuaci\xf3n"}t(12899)},60496:function(e,a,t){function s(e){let a=new Date("".concat(e,"T12:00:00"));return Number.isNaN(a.getTime())?e:a.toLocaleDateString("es-MX",{weekday:"short",day:"numeric",month:"short"})}function i(e){if(!e||"object"!=typeof e)return null;let a=Array.isArray(e.dates)?e.dates.filter(e=>"string"==typeof e&&/^\d{4}-\d{2}-\d{2}$/.test(e)):[],t="string"==typeof e.start?e.start.trim():"",s="string"==typeof e.end?e.end.trim():"",i="string"==typeof e.timezone&&e.timezone.trim()?e.timezone.trim():"America/Mexico_City";
1return 0!==a.length&&t&&s?{dates:[...new Set(a)].sort(),start:t,end:s,timezone:i,note:"string"==typeof e.note&&e.note.trim()||null,submitted_at:"string"==typeof e.submitted_at?e.submitted_at:void 0}:null}function n(e){let a=e.dates.map(s).join(", ");return"".concat(a," \xb7 ").concat(e.start,"â").concat(e.end)}function r(e){let a=["Fechas: ".concat(e.dates.map(s).join(", ")),"Horario: ".concat(e.start,"â").concat(e.end," (").concat(e.timezone,")")];return e.note&&a.push("Nota: ".concat(e.note)),a.join("\n")}t.d(a,{Mk:function(){return i},N3:function(){return r},XR:function(){return n}})},68205:function(e,a,t){t.d(a,{Ys:function(){return i},au:function(){return n},j3:function(){return s}});let s="talentgoo_cookie_consent_v1",i={essential:!0,analytics:!1,marketing:!1,updatedAt:""};function n(e){return e&&"object"==typeof e?{essential:!0,analytics:!!e.analytics,marketing:!!e.marketing,updatedAt:"string"==typeof e.updatedAt?e.updatedAt:""}:{...i}}},2250:function(e,a,t){function s(e){if(!e)return"";let a=String(e.id||"").replace(/[^a-zA-Z0-9]/g,"").toUpperCase();if(a.length>=6)return"".concat(a.slice(0,3),"-").concat(a.slice(3,6));let t=String(e.title||"POSICION").replace(/[^a-zA-Z0-9]/g,"").toUpperCase().padEnd(6,"X");return"".concat(t.slice(0,3),"-").concat(t.slice(3,6))}function i(e){let a=s({id:e.id,title:e.title});return a?"[".concat(a,"]"):""}t.d(a,{AW:function(){return i},N8:function(){return s}})},67024:function(e,a,t){t.d(a,{OU:function(){return r},Y7:function(){return s},pJ:function(){return i},w1:function(){return n}});let s=["Amazonas","Anzo\xe1tegui","Apure","Aragua","Barinas","Bol\xedvar","Carabobo","Cojedes","Delta Amacuro","Distrito Capital","Falc\xf3n","Gu\xe1rico","La Guaira","Lara","M\xe9rida","Miranda","Monagas","Nueva Esparta","Portuguesa","Sucre","T\xe1chira","Trujillo","Yaracuy","Zulia"],i=["Ciudad Aut\xf3noma de Buenos Aires","Buenos Aires","Catamarca","Chaco","Chubut","C\xf3rdoba","Corrientes","Entre R\xedos","Formosa","Jujuy","La Pampa","La Rioja","Mendoza","Misiones","Neuqu\xe9n","R\xedo Negro","Salta","San Juan","San Luis","Santa Cruz","Santa Fe","Santiago del Estero","Tierra del Fuego","Tucum\xe1n"],n=["Arica y Parinacota","Tarapac\xe1","Antofagasta","Atacama","Coquimbo","Valpara\xedso","Metropolitana de Santiago","Libertador General Bernardo O'Higgins","Maule","\xd1uble","Biob\xedo","La Araucan\xeda","Los R\xedos","Los Lagos","Ays\xe9n del General Carlos Ib\xe1\xf1ez del Campo","Magallanes y de la Ant\xe1rtica Chilena"];function r(e){return e.reduce((e,a)=>(e[a]=[a],e),{})}}}]);
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.