1import{r as n,j as e,a as v}from"./index.CMes7NSj.js";import{L as Q}from"./Layout.C71eM22T.js";import"./useTheme.BfVecHYw.js";import"./createLucideIcon.BIPH4Qyf.js";import"./loader-circle.Bi7q0UmI.js";import"./shield.D67KeQV5.js";import"./x.CTBTNLmV.js";import"./mail.CwKlJeun.js";import"./calendar.BpDkqKTL.js";import"./gift.BqHmzo-y.js";import"./check.BNCofhee.js";import"./copy.DhcUi1QA.js";import"./lock.DT1CA5IT.js";import"./circle-alert.CPUTNIMj.js";import"./eye-off.w0-4f_JF.js";import"./eye.DXTTr_Ft.js";import"./calendar-clock.CS3VChkK.js";import"./message-square.DvgMIpvb.js";import"./user-plus.vYWnvW7b.js";import"./newspaper.C8N7UTGz.js";import"./clipboard-list.0WZHK3yk.js";import"./calendar-check.BzAPdruy.js";import"./circle-check.TQ-UR8j1.js";import"./star.Cj_rqQAr.js";import"./users-round.CAV0qVaX.js";import"./zap.BJddcI11.js";import"./users.BA7_fJ_p.js";import"./briefcase.CCBGcyc1.js";import"./layers.DgnA_cYT.js";import"./upload.CgbGIhr1.js";import"./folder-open.ewln6EAy.js";import"./target.BRdav6nX.js";import"./file-text.Din2KaI_.js";import"./trending-up.C0wFoeA-.js";import"./layout-dashboard.DFPBaI_A.js";import"./building-2.COgzt34u.js";import"./chart-column.D2lO_iiz.js";import"./activity.Bld1vZ8d.js";import"./megaphone.D6EkCnjX.js";import"./wallet.CW5CW5Oc.js";import"./trash-2._q1IJ7V4.js";import"./sun.AYU8lJGG.js";import"./log-out.DdKQLPwm.js";import"./menu.BFOkls43.js";import"./chevron-right.Ce9jvXfU.js";import"./chevron-left.CMXh4DxZ.js";import"./layout-template.E4XSTnuE.js";import"./file-check.UhbWq35z.js";import"./search.CkxbqJzX.js";import"./settings.CY7BgCwr.js";import"./image.B558kRj9.js";const Ve=()=>{const[x,R]=n.useState([]),[b,L]=n.useState([]),[m,f]=n.useState([]),[h,I]=n.useState(""),[w,U]=n.useState(null),[j,S]=n.useState(!1),[k,c]=n.useState(""),[J,A]=n.useState(!0),[_,$]=n.useState(1),[D,P]=n.useState(!1),[E,F]=n.useState(!0),M=50,C=async(s=1)=>{var r,o,d,p,g,l,a;try{P(!0);const t=await v.get(`/api/get-resumes?page=${s}&limit=${M}`);console.log(`Resumes API response for page ${s}:`,t);let i;return(r=t.data)!=null&&r.data?i=t.data.data:Array.isArray(t.data)?i=t.data:(o=t.data)!=null&&o.success&&Array.isArray((d=t.data)==null?void 0:d.data)?i=t.data.data:(console.warn("Unexpected resume response format:",t.data),i=[]),(!i.length||i.length<M)&&F(!1),R(s===1?Array.isArray(i)?i:[]:u=>[...u,...Array.isArray(i)?i:[]]),i}catch(t){console.error("Error fetching resumes:",t);const i=((g=(p=t.response)==null?void 0:p.data)==null?void 0:g.message)||((a=(l=t.response)==null?void 0:l.data)==null?void 0:a.error)||t.message||"Unknown error";return c(`Failed to load resumes: ${i}`),[]}finally{P(!1)}},T=async()=>{var s,r,o,d,p,g,l;try{const a=await v.get("/api/jd/extractions");console.log("Job Descriptions API full response:",a);let t;(s=a.data)!=null&&s.data?t=a.data.data:Array.isArray(a.data)?t=a.data:(r=a.data)!=null&&r.success&&Array.isArray((o=a.data)==null?void 0:o.data)?t=a.data.data:(console.warn("Unexpected JD response format:",a.data),t=[]),console.log("Final processed job descriptions data:",t),L(Array.isArray(t)?t:[])}catch(a){console.error("Error fetching job descriptions:",a);const t=((p=(d=a.response)==null?void 0:d.data)==null?void 0:p.message)||((l=(g=a.response)==null?void 0:g.data)==null?void 0:l.error)||a.message||"Unknown error";c(`Failed to load job descriptions: ${t}`)}};n.useEffect(()=>{(async()=>{A(!0),c("");try{await Promise.all([C(1),T()])}catch(r){console.error("Error fetching initial data:",r)}finally{A(!1)}})()},[]);const H=s=>{f(r=>r.includes(s)?r.filter(o=>o!==s):[...r,s])},z=s=>{I(s.target.value)},q=()=>{if(!D&&E){const s=_+1;$(s),C(s)}},B=s=>{const{scrollTop:r,scrollHeight:o,clientHeight:d}=s.target;o-r-d<50&&q()},G=async s=>{var r,o,d,p,g;if(s.preventDefault(),m.length===0){c("Please select at least one resume");return}if(!h){c("Please select a job description");return}S(!0),c("");try{if(!localStorage.getItem("token")){c("Authentication token not found. Please login again.");return}const a=[],t=[];m.forEach(y=>{const N=x.find(K=>K._id===y);N&&(N.resumeType==="demo"||N.isDemo)?a.push(y):t.push(y)});const i={jobDescriptionId:h};a.length>0&&(i.demoResumeIds=a),t.length>
10&&(i.userResumeIds=t),console.log("Submitting match request with:",i);const{data:u}=await v.post("/api/matching/match-resumes",i,{headers:{"Content-Type":"application/json"}});u&&u.results?(U(u.results),window.scrollTo(0,document.body.scrollHeight)):c("Received unexpected response format from the matching API")}catch(l){console.error("Error matching resumes:",l),console.error("Response data:",(r=l.response)==null?void 0:r.data),c(((d=(o=l.response)==null?void 0:o.data)==null?void 0:d.error)||((g=(p=l.response)==null?void 0:p.data)==null?void 0:g.message)||"Failed to match resumes. Please try again.")}finally{S(!1)}},O=()=>{const s=x.map(r=>r._id);f(s)},V=s=>s>=80?"bg-emerald-600":s>=60?"bg-blue-600":s>=40?"bg-amber-500":"bg-red-600";return e.jsx(Q,{children:e.jsxs("div",{className:"container mx-auto px-4 py-8 bg-gray-900 text-gray-100",children:[e.jsx("h2",{className:"text-2xl font-bold mb-6 text-indigo-300",children:"Resume Matching Tool"}),k&&e.jsx("div",{className:"bg-red-900 border border-red-700 text-red-100 px-4 py-3 rounded mb-4",children:k}),J?e.jsxs("div",{className:"text-center my-12",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-4 border-indigo-400 border-t-transparent"}),e.jsx("p",{className:"mt-3 text-gray-300",children:"Loading resumes and job descriptions..."})]}):e.jsxs("form",{onSubmit:G,children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-8",children:[e.jsxs("div",{className:"border border-gray-700 rounded-lg shadow-lg bg-gray-800",children:[e.jsx("div",{className:"bg-gray-800 px-4 py-3 border-b border-gray-700 rounded-t-lg",children:e.jsxs("h5",{className:"font-semibold text-indigo-300",children:["Select Resumes (",x.length,")"]})}),e.jsx("div",{className:"p-4 max-h-96 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-600 scrollbar-track-gray-900",onScroll:B,children:x.length===0?e.jsx("p",{className:"text-gray-400",children:"No resumes available"}):e.jsxs(e.Fragment,{children:[x.map(s=>e.jsx("div",{className:"mb-2",children:e.jsxs("label",{className:"flex items-start cursor-pointer hover:bg-gray-700 p-2 rounded",children:[e.jsx("input",{type:"checkbox",className:"mt-1 mr-2 accent-indigo-500",checked:m.includes(s._id),onChange:()=>H(s._id)}),e.jsxs("span",{className:"text-gray-300",children:[s.name||"Unnamed"," (",s.email||"No email",s.folderName&&` - ${s.folderName}`,")"]})]})},s._id)),D&&e.jsxs("div",{className:"text-center py-2",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-4 w-4 border-2 border-indigo-400 border-t-transparent"}),e.jsx("span",{className:"ml-2 text-gray-400",children:"Loading more..."})]}),!E&&x.length>0&&e.jsx("div",{className:"text-center py-2 text-gray-500",children:"â End of resumes â"})]})}),e.jsx("div",{className:"px-4 py-3 border-t border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-gray-400",children:["Selected: ",m.length]}),e.jsxs("div",{className:"space-x-2",children:[e.jsx("button",{type:"button",className:"px-3 py-1 text-sm rounded bg-indigo-700 text-gray-200 hover:bg-indigo-600 border border-indigo-600",onClick:O,children:"Select All"}),e.jsx("button",{type:"button",className:`px-3 py-1 text-sm rounded ${m.length===0?"bg-gray-700 text-gray-500 cursor-not-allowed":"bg-gray-700 text-gray-300 hover:bg-gray-600 border border-gray-600"}`,onClick:()=>f([]),disabled:m.length===0,children:"Clear"})]})]})})]}),e.jsxs("div",{className:"border border-gray-700 rounded-lg shadow-lg bg-gray-800",children:[e.jsx("div",{className:"bg-gray-800 px-4 py-3 border-b border-gray-700 rounded-t-lg",children:e.jsxs("h5",{className:"font-semibold text-indigo-300",children:["Select Job Description (",b.length,")"]})}),e.jsxs("div",{className:"p-4",children:[e.jsx("div",{className:"mb-4",children:e.jsxs("select",{value:h,onChange:z,className:"w-full border border-gray-700 rounded px-3 py-2 bg-gray-700 text-gray-200",children:[e.jsx("option",{value:"",children:"-- Select a Job Description --"}),b.map(s=>e.jsxs("option",{value:s._id,children:[s.title||"Untitled"," at"," ",s.company||"Unknown Company"]},s._id))]})}),h&&b.length>0&&e.jsx("div",{className:"mt-4",children:(()=>{const s=b.find(r=>r._id===h);return s?e.jsxs("div",{className:"text-gray-300",children:[e.jsx("h6",{className:"font-semibold text-lg text-indigo-300",children:s.title||"Untitled Position"}),e.jsxs("p",{className:"mb-2",children:[e.jsx("strong",{className:"text-gray-200",children:"Company:"})," ",s.company||"Unknown Company"]}),e.jsxs("p",{className:"mb-2",children:[e.jsx("strong",{className:"text-gray-200",children:"Location:"})," ",s.location||"Not specified"]}),e.jsxs("p",{className:"mb-2",children:[e.jsx("strong",{className:"text-gray-200",children:"Experience:"})," ",s.yearsOfExperience||"Not specified"]}),e.jsxs("div",{className:"mb-2",children:[e.jsx("strong",{className:"text-gray-200",children:"Skills:"}),e.jsxs("div",{className:"mt-1",children:[s.skills&&Array.isArray(s.skills.hard)&&s.skills.hard.map((r,o)=>e.jsx("span",{className:"inline-block bg-indigo-900 text-indigo-200 text-xs px-2 py-1 rounded mr-1 mb-1",children:r},o)),s.skills&&Array.isArray(s.skills.soft)&&s.skills.soft.map((r,o)=>e.jsx("span",{className:"inline-block bg-gray-700 text-gray-300 text-xs px-2 py-1 rounded mr-1 mb-1",children:r},o))]})]})]}):null})()})]})]})]}),e.jsx("div",{className:"flex justify-center mb-12",children:e.jsx("button",{type:"submit",className:`px-6 py-3 text-lg font-medium rounded-md ${j||m.length===0||!h?"bg-indigo-800 text-gray-400 cursor-not-allowed":"bg-indigo-600 hover:bg-indigo-700 text-white"}`,disabled:j||m.length===0||!h,children:j?e.jsxs("span",{className:"flex items-center",children:[e.jsx("span",{className:"inline-block animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent mr-2"}),"Analyzing Resumes..."]}):"Match Resumes to Job Description"})})]}),w&&e.jsxs("div",{className:"mt-8",children:[e.jsx("h3",{className:"text-xl font-bold mb-4 text-indigo-300",children:"Match Results"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:w.map(s=>e.jsxs("div",{className:"border border-gray-700 rounded-lg shadow-lg bg-gray-800",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-gray-700 flex justify-between items-center",children:[e.jsx("h5",{className:"font-semibold text-indigo-300",children:s.candidateName||"Unknown Candidate"}),e.jsxs("span",{className:`${V(s.score||0)} text-white flex items-center justify-center h-8 w-12 rounded-md font-semibold`,children:[s.score||0,"%"]})]}),e.jsxs("div",{className:"p-4 text-gray-300",children:[e.jsx("h6",{className:"font-semibold mb-2 text-gray-200",children:"Match Analysis:"}),e.jsx("ul",{className:"space-y-2",children:Array.isArray(s.keyPoints)&&s.keyPoints.map((r,o)=>e.jsxs("li",{className:"flex",children:[e.jsx("svg",{className:"h-5 w-5 text-emerald-400 mr-2 mt-0.5 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),e.jsx("span",{children:r})]},o))})]}),e.jsx("div",{className:"px-4 py-3 border-t border-gray-700",children:e.jsx("button",{type:"button",className:"px-4 py-2 text-sm border border-indigo-500 text-indigo-300 rounded hover:bg-indigo-900 transition-colors duration-200",children:"View Resume Details"})})]},s.resumeId))})]})]})})};export{Ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.