1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3707],{82744:function(e,l,t){var a=t(64529);let i=(0,a.Ue)(e=>({candidateIds:[],updateCandidatesList:l=>e(e=>({candidateIds:e.candidateIds.includes(l)?e.candidateIds.filter(e=>e!==l):[...e.candidateIds,l]})),selectAllCandidates:l=>e(e=>({candidateIds:l})),restoreDefaults:()=>e(e=>({candidateIds:[]}))}));l.Z=i},44984:function(e,l,t){var a=t(64529);let i=(0,a.Ue)(e=>({emailDetails:{candidate:"",name:"",phoneNumber:"",sendTo:"",cc:[],bcc:[],subject:"",body:"",replyTo:"",candidateIds:[],templateUsed:!1,templateValue:"",emailBody:"",access_level:"GROUP"},setEmailDetails:l=>e({emailDetails:l}),setSubject:l=>e(e=>({emailDetails:{...e.emailDetails,subject:l}})),emailTempData:{isTemplateSelected:!1,emailBody:"",subject:""},setEmailTempData:l=>e({emailTempData:l}),resetEmailTempData:()=>e({emailTempData:{isTemplateSelected:!1,emailBody:"",subject:""}}),displayPlaceholderMissingError:!1,setDisplayPlaceholderMissingError:l=>e({displayPlaceholderMissingError:l}),resetEmailDetails:()=>e({emailDetails:{candidate:"",name:"",phoneNumber:"",sendTo:"",cc:[],bcc:[],subject:"",body:"",replyTo:"",candidateIds:[],templateUsed:!1,templateValue:"",emailBody:"",access_level:"GROUP"},text:""})}));l.Z=i},66457:function(e,l,t){var a=t(64529);let i=(0,a.Ue)(e=>({jobIds:[],candidateIds:[],updateCandidatesList:l=>e(e=>({candidateIds:e.candidateIds.includes(l)?e.candidateIds.filter(e=>e!==l):[...e.candidateIds,l]})),selectAllCandidates:l=>e(e=>({candidateIds:l})),updateJobsList:l=>e(e=>({jobIds:e.jobIds.includes(l)?e.jobIds.filter(e=>e!==l):[...e.jobIds,l]})),updateSingleCandidateList:l=>e(e=>({candidateIds:[l]})),updateSingleJobList:l=>e(e=>({jobIds:[l]})),restoreDefaults:()=>e(e=>({jobIds:[],candidateIds:[]}))}));l.Z=i},58225:function(e,l,t){t.d(l,{hR:function(){return AIEmailModifier},yr:function(){return EmailBodyTextArea},dC:function(){return EmailSubjectInput},oz:function(){return SendEmailForm},ZP:function(){return SendEmailForm}});var a=t(85893),i=t(67294),r=t(87536),s=t(63201),n=t(72911),o=t(18373),d=t(55314),u=t(37285),c=t(11163),m=t(87342),p=t(84143),x=t(22105),f=t(29377),h=t(42581),g=t(95332),b=t(44984);let useEmailForm=()=>{let{emailDetails:e,setEmailDetails:l,resetEmailDetails:t,displayPlaceholderMissingError:a,setDisplayPlaceholderMissingError:r}=(0,b.Z)(),s=(0,i.useCallback)(t=>{if(t&&Object.keys(t).length>0){let a=Object.keys(t).some(l=>e[l]!==t[l]);if(!a)return e;l({...e,...t})}},[l]),n=(0,i.useCallback)(()=>{t()},[t]),o=(0,i.useCallback)((e,t)=>{e&&void 0!==t&&l(l=>l[e]===t?l:{...l,[e]:t})},[l]),d=(0,i.useMemo)(()=>({emailFormData:e,updateEmailFormData:s,resetEmailFormData:n,updateEmailField:o,displayPlaceholderMissingError:a,setDisplayPlaceholderMissingError:r}),[e,s,n,o,a,r]);return d},useEmailSubmission=()=>{let[e,{data:l,error:t,isError:a,isSuccess:r,isLoading:s}]=(0,d.T4)(),n=(0,i.useCallback)(async l=>{try{let t=await e(l).unwrap();return t}catch(e){var t;throw(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.message)?(0,x.Z)(e.data.message,"error"):(null==e?void 0:e.message)?(0,x.Z)(e.message,"error"):(0,x.Z)("Failed to send email. Please try again.","error"),e}},[e]),o=(0,i.useCallback)(()=>r&&(!(null==l?void 0:l.failedEmails)||0===l.failedEmails.length),[r,l]),u=(0,i.useCallback)(()=>(null==l?void 0:l.failedEmails)&&l.failedEmails.length>0,[l]),c=(0,i.useCallback)(()=>{var e;return(null==l?void 0:null===(e=l.successEmails)||void 0===e?void 0:e.length)||0},[l]),m=(0,i.useCallback)(()=>{var e;return(null==l?void 0:null===(e=l.failedEmails)||void 0===e?void 0:e.length)||0},[l]),p=(0,i.useCallback)(()=>{},[]);return{sendEmail:n,isLoading:s,isSuccess:r,isError:a,error:t,emailSentResponse:l,isEmailSentSuccessfully:o,hasFailedEmails:u,getSuccessEmailCount:c,getFailedEmailCount:m,resetEmailSubmission:p}};var v=t(67129),y=t(66457),j=t(82744);let useCandidateData=e=>{var l;let{getFilters:t}=(0,v.Z)(),{data:a,isSuccess:i,isLoading:r,error:s}=(0,d.Pn)({candidateId:e,filters:t()},{skip:!e}),{candidateIds:n,restoreDefaults:o}=(0,j.Z)(),{candidateIds:u,restoreDefaults:c}=(0,y.Z)();return{candidateData:{candidate:(null==a?void 0:null===(l=a.data)||void 0===l?void 0:l.candidate)||null,candidateIds:n||[],candidatesListInTalentPool:u||[],restoreDefaults:c,clearAllCandidatesList:o},candidateResult:a,isCandidateDetailsSuccess:i,isCandidateLoading:r,candidateError:s,isBulkOperation:(e,l)=>{var t,a;return e?(null==u?void 0:u.length)>1:(null==l||null===(t=l.query)||void 0===t||!t.candidateId)&&(null==l||null===(a=l.query)||void 0===a||!a.candidate)&&(null==n?void 0:n.length)>1}}};var w=t(2299),N=t(73343),customHook_useEmailStreamGenerator=()=>{var e,l,t;let a=(0,c.useRouter)(),[r,s]=(0,i.useState)(!1),{setEmailDetails:n,emailDetails:o,setSubject:d}=(0,b.Z)(),{candidateIds:u,restoreDefaults:m}=(0,j.Z)(),setEmailBody=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;l&&"function"==typeof l&&l(e)},{candidateIds:p}=(0,y.Z)(),f=a.pathname.includes("talent_pool"),h=a.query.candidateId?[a.query.candidateId]:f?p:(null==a?void 0:null===(e=a.query
1)||void 0===e?void 0:e.candidateId)?[a.query.candidateId]:(null==u?void 0:u.length)>0?u:[],g=null!=a&&null!==(l=a.query)&&void 0!==l&&!!l.candidate;g&&(h=[null==a?void 0:null===(t=a.query)||void 0===t?void 0:t.candidate]);let generateEmailStream=async e=>{let{candidateName:l,jobRole:t,companyName:a,contentInput:i,currentEmailBody:r,current_subject:n,recruiterName:u,emailTone:c="professional",personalized:m,timeoutDuration:p=3e4,isTalentPool:f,isTemplateCreation:g=!1,onEmailBodyUpdate:b,onSubjectUpdate:v}=e;if(!(null==i?void 0:i.trim())&&!m)return(0,x.Z)("Please provide modification input","error"),!1;s(!0);let y="",j="";try{let e={candidate_name:l,job_role:t,company_name:a,content_input:i,current_email_body:r,current_subject:n,isTalentPool:f,candidateIdsList:h};u&&(e.recruiter_name=u),c&&(e.email_tone=c),m&&(e.personalized=m),g&&(e.create_template=!0);let s=new AbortController,C=setTimeout(()=>{s.abort(),(0,x.Z)("Request timed out","error")},p),E=(0,N.$8)(),T={"Content-Type":"application/json",Authorization:`Bearer ${E}`},_=await fetch(`${w.bl}v2/candidates/stream-email`,{method:"POST",headers:T,body:JSON.stringify(e),signal:s.signal});if(clearTimeout(C),!_.ok){let e=await _.json(),l=e.message||"Failed to modify email body";throw Error(`${l||"Failed to modify email body"} (${_.status})`)}let S=_.body.getReader(),k=new TextDecoder,P="";for(;;){let{value:e}=await S.read();P+=k.decode(e,{stream:!0});let l=P.split("\n");for(let e of(P=l.pop(),o.subject||null!=o&&o.emailBody,l))if(""!==e.trim()){if("data: [DONE]"===e)return setEmailBody(y,b),(0,x.Z)("Email body modified successfully","success"),!0;if(e.startsWith("data: "))try{let l=JSON.parse(e.substring(6));l&&(null==l?void 0:l.emailBodyContent)&&(y+=null==l?void 0:l.emailBodyContent,setEmailBody(y,b)),!m&&(null==l?void 0:l.subject)&&(j+=null==l?void 0:l.subject,d(j),v&&"function"==typeof v&&v(j))}catch(e){console.error("Error parsing streaming data:",e);continue}}}}catch(l){console.error("Error modifying email body:",l);let e=l.message||"Failed to modify email body";return(0,x.Z)(e,"error"),!1}finally{s(!1)}};return{generateEmailStream,isStreaming:r}},C=t(86280),E=t(88540);let T={candidate_name:"Candidate Name",job_role:"Job Role",recruiter_name:"Recruiter Name",job_link:"Job Link"},_={scheduling_link:"Scheduling Link",provide_time_slots:"Provide Time Slots",questionnaire_link:"Questionnaire Link",deadline_date:"Deadline Date",event_name:"Event Name",event_date:"Event Date",registration_link:"Registration Link"},S=Object.entries(T).map(e=>{let[l,t]=e;return`@[${t}](${l})`}),k=Object.entries(_).map(e=>{let[l,t]=e;return`#[${t}](${l})`}),findPlaceholdersSecondary=e=>{let l=[];k.filter(e=>!e.includes("@")).forEach(t=>{e.includes(t)&&l.push(t)});let t=l.map(e=>{let l=e.match(/\((.*?)\)/),t=l?l[1].trim():"";return"#"+t});return t},findPlaceholdersPrimary=e=>{let l=[];S.filter(e=>!e.includes("#")).forEach(t=>{e.includes(t)&&l.push(t)});let t=l.map(e=>{let l=e.match(/\((.*?)\)/),t=l?l[1].trim():"";return"@"+t});return{missingPlaceholders:l,missingPlaceholdersTags:t}},utils_checkForTheMissingPlaceholders=e=>k.filter(e=>!(null==e?void 0:e.includes("@"))).some(l=>null==e?void 0:e.includes(l)),replacePlaceholdersAndSanitizeTheEmailBody=e=>{let{missingPlaceholders:l,missingPlaceholdersTags:t}=findPlaceholdersPrimary(e),a=e;return l.forEach((e,l)=>{let i=t[l],r=RegExp(e.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"g");a=a.replace(r,i)}),a},getDefaultEmailTemplates=e=>{let{jobRole:l,companyName:t,candidateName:a,recruiterName:i}=e,r=[{id:1,default:!0,name:"Initial Interest - Scheduling Call",subject:`Excited to discuss ${l} at ${t}`,body:`Hi ${a}, 2 3We really like your profile and believe you'd be a great fit for the ${l} position at ${t}. We'd love to schedule a quick call. 4Looking forward to speaking with you soon! 5 6Warm regards, 7${i}`},{id:4,default:!0,personalized:!0,name:"Cold Outreach Email (AI Personalized)",subject:`Unique opportunity at ${t} tailored for you`,body:""},{id:5,default:!0,name:"Rejection at Screening Level",subject:`Update regarding your application - ${l}`,body:`Hi ${a}, 8 9Thank you for taking the time to apply for the ${l} position. After careful review, we've decided not to proceed further at this stage. We appreciate your interest and encourage you to stay connected for future opportunities. 10 11Best wishes, 12${i}`},{id:6,default:!0,talentPool:!0,name:"Availability for New Opportunities",subject:"Checking in on new career opportunities",body:`Hi ${a}, 13 14I hope you're doing well! We're reaching out to check if you might be open to exploring new career opportunities at this time. We'd love to hear about your current interests and availability. 15Looking forward to your reply, 16 17Warm regards, 18${i}`},{id:8,default:!0,talentPool:!0,personalized:!0,name:"Outreach Email (AI Personalized)",subject:`Unique opportunity at ${a} tailored for you`,body:""}];return{emailTemplates:r}},useTypewriterEffect=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{typingSpeed:a=150,deletingSpeed:r=50,pauseAfterTyping:s=1500,shouldStopAfterCycle:n=!1}=t,[o,d]=(0,i.useState)(""),[u,c]=(0,i.useState)(0),[m,p]=(0,i.useState)(!1),[x,f]=(0,i.useState)(!1),h=(0,i.useRef)(null),g=(0,i.useRef)(null),b=(0,i.useMemo)(()=>
18{if(l&&Array.isArray(l)&&l.length>0)return l;let e=Object.values(T).map(e=>`@${e}`);return e},[l]);return(0,i.useEffect)(()=>{if(!e||0===b.length||n&&x){g.current&&(clearTimeout(g.current),g.current=null),h.current&&(clearTimeout(h.current),h.current=null);return}let l=b[u];if(m){if(o.length>0)g.current=setTimeout(()=>{d(o.substring(0,o.length-1))},r);else{p(!1);let e=(u+1)%b.length;n&&0===e&&0!==u?f(!0):c(e)}}else o.length<l.length?g.current=setTimeout(()=>{d(l.substring(0,o.length+1))},a):h.current=setTimeout(()=>{p(!0)},s);return()=>{g.current&&(clearTimeout(g.current),g.current=null),h.current&&(clearTimeout(h.current),h.current=null)}},[o,u,m,b,e,a,r,s,n,x]),(0,i.useEffect)(()=>{!e&&(d(""),c(0),p(!1),f(!1),g.current&&(clearTimeout(g.current),g.current=null),h.current&&(clearTimeout(h.current),h.current=null))},[e]),{typewriterText:o,hasCompletedCycle:x,isActive:e&&!x}},EmailBodyTextArea=e=>{let{value:l="",onChange:t,placeholder:r="Write your email message here...",className:s="",disabled:n=!1,maxLength:o=1e4}=e,{updateEmailFormData:d}=useEmailForm(),u=(0,i.useRef)(null),c=(0,i.useRef)(null),[m,p]=(0,i.useState)(!1),[x,f]=(0,i.useState)(null),{typewriterText:h}=useTypewriterEffect(m),g=utils_checkForTheMissingPlaceholders(l),b=findPlaceholdersSecondary(l);return(0,i.useEffect)(()=>{let e=setTimeout(()=>{if(c.current&&!x){let e=Math.max(c.current.offsetHeight,200);f(e)}},100);return()=>clearTimeout(e)},[x]),(0,a.jsxs)("div",{className:"flex flex-col w-full gap-2 h-full",children:[m&&(0,a.jsxs)("div",{className:"text-xs text-gray-500 font-normal",children:[(0,a.jsx)("span",{children:"Type @ to insert placeholders. Try: "}),(0,a.jsxs)("span",{className:"font-mono text-lightPurple",children:[h,(0,a.jsx)("span",{className:"animate-pulse",children:"|"})]})]}),(0,a.jsxs)("div",{ref:c,className:"flex flex-col w-full relative",style:{height:x?`${x}px`:"100%",minHeight:"200px"},children:[(0,a.jsx)("p",{className:"absolute -top-2 left-4 z-10 text-xs text-lightPurple font-normal px-1 bg-white",children:"Email Body"}),(0,a.jsx)(E.r,{inputRef:u,className:`w-full h-full text-sm ${s}`,value:l,onChange:e=>{let l=e.target.value;!(l.length>o)&&(d&&d({emailBody:l}),t&&t(l))},onFocus:()=>p(!0),onBlur:()=>p(!1),placeholder:r,disabled:n,style:{control:{backgroundColor:"#fff",fontWeight:"normal",lineHeight:"1.4",height:x?`${x}px`:"100%",minHeight:"200px",border:"1px solid #dddddd",borderRadius:"4px",overflow:"hidden"},highlighter:{height:x?`${x}px`:"100%",minHeight:"200px",padding:"10px 9px",lineHeight:"1.4",fontFamily:"inherit",fontSize:"14px",border:"1px solid transparent",borderRadius:"4px",overflow:"auto",boxSizing:"border-box"},input:{color:"inherit",outline:"none",width:"100%",height:x?`${x}px`:"100%",minHeight:"200px",borderRadius:"4px",border:"1px solid transparent",display:"block",lineHeight:"1.4",padding:"10px",overflow:"auto",resize:"none",fontFamily:"inherit",fontSize:"14px",boxSizing:"border-box",background:"transparent"},suggestions:{list:{maxHeight:200,overflow:"auto",border:"1px solid #c7b4ff",borderRadius:"4px",position:"absolute",whiteSpace:"nowrap",top:"calc(100% + 5px)",color:"#6966A4",zIndex:10}}},children:(0,a.jsx)(E.p,{markup:"@[__display__](__id__)",trigger:"@",data:Object.entries(T).map(e=>{let[l,t]=e;return{id:l,display:t}}),renderSuggestion:(e,l,t,i,r)=>(0,a.jsx)("div",{className:`border-[#C7B4FF] p-2 shadow-[0px_6px_24px_0px_rgba(0,0,0,0.05),0px_0px_0px_1px_rgba(0,0,0,0.08)] ${r?"bg-[#f5f3ff]":"bg-white"}`,children:t}),appendSpaceOnAdd:!0,displayTransform:(e,l)=>`@${e}`,className:"bg-violet-100 rounded-full"})})]}),g&&(0,a.jsxs)("div",{className:"flex items-center justify-start gap-1 text-red-500 font-normal",children:[(0,a.jsx)(C.Q,{size:18}),(0,a.jsxs)("p",{className:"text-xs",children:["Highlighted details are missing from the email body: ",null==b?void 0:b.join(", ")]})]})]})},EmailSubjectInput=e=>{let{control:l,errors:t,disabled:s,placeholder:n="Enter email subject..."}=e,[o,d]=(0,i.useState)(!1),u=(0,i.useRef)(null),{updateEmailFormData:c}=useEmailForm(),{typewriterText:m}=useTypewriterEffect(o),handleSubjectChange=(e,l,t,a)=>{c&&c({subject:l})},renderSuggestion=(e,l,t,i,r)=>(0,a.jsx)("div",{className:`border-[#C7B4FF] p-2 shadow-[0px_6px_24px_0px_rgba(0,0,0,0.05),0px_0px_0px_1px_rgba(0,0,0,0.08)] ${r?"bg-[#f5f3ff]":"bg-white"}`,children:t});return(0,a.jsxs)("div",{className:`flex flex-col w-full gap-2 z-50 ${o||t.subject?"h-auto":"h-[42px]"}`,children:[(0,a.jsx)("div",{className:"relative",children:(0,a.jsx)(r.Qr,{name:"subject",control:l,render:e=>{let{field:l}=e;return(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("label",{className:`absolute left-4 z-10 text-xs font-normal px-1 bg-white transition-all duration-300 cursor-text ${o||l.value?"-top-2 text-lightPurple":"top-3 scale-[120%] text-gray-500"}`,onClick:()=>{var e;return null===(e=u.current)||void 0===e?void 0:e.focus()},children:"Subject"}),(0,a.jsxs)(E.r,{disabled:s,inputRef:u,className:`w-full text-sm ${t.subject?"border-red-500":""}`,value:l.value,onChange:(e,t,a,i)=>{l.onChange(t),handleSubjectChange(e,t,a,i)},onFocus:()=>d(!0),onBlur:()=>d(!1),singleLine:!0,style:{control:{backgroundColor:"#fff",fontWeight:"normal",lineHeight:"1.4",minHeight:"42px",height:"42px",padding:"11px"},input:{color:"inherit",outline:"none",width:"100%",borderRadius:"4px",border:`1px solid ${t.subject?"#ef4444":"#dddddd"}`,display:"block",lineHeight:"1.4",padding:"10px",fontSize:"14px",fontFamily:"inherit",height:"42px"},"&multiLine":{control:{fontFamily:"inherit",minHeight:40},highlighter:{padding:"10px",border:"1px solid transparent"},input:{padding:"10px",border:"1px solid transparent"}},suggestions:{list:{maxHeight:200,overflow:"auto",border:"1px solid #c7b4ff",borderRadius:"4px",position:"absolute",whiteSpace:"nowrap",top:"calc(100% + 5px)",color:"#6966A4",zIndex:50}}},children:[(0,a.jsx)(E.p,{markup:"@[__display__](__id__)",trigger:"@",data:Object.entries(T).map(e=>{let[l,t]=e;
18return{id:l,display:t}}),renderSuggestion:renderSuggestion,appendSpaceOnAdd:!0,displayTransform:(e,l)=>`@${e}`,className:"bg-violet-100 rounded-full"}),(0,a.jsx)(E.p,{markup:"#[__display__](__id__)",trigger:"#",data:Object.entries(_).map(e=>{let[l,t]=e;return{id:l,display:t}}),renderSuggestion:renderSuggestion,appendSpaceOnAdd:!0,displayTransform:(e,l)=>`#${e}`,className:"bg-blue-100 rounded-full"})]})]})}})}),t.subject&&(0,a.jsx)("p",{className:"text-red-500 text-sm",children:t.subject.message}),o&&(0,a.jsxs)("div",{className:"text-xs text-gray-500",children:[(0,a.jsx)("span",{children:"Type @ to insert placeholders. Try: "}),(0,a.jsxs)("span",{className:"font-mono text-lightPurple",children:[m,(0,a.jsx)("span",{className:"animate-pulse",children:"|"})]})]})]})};var P=t(81671),I=t(15889),$=t(93866),B=t(15008);let formatEmailDetailsForSubmission=e=>{var l,t,a;let{formData:i,emailFormData:r,isTalentPoolPage:s,isEmailTriggerFromJobDashboard:n,candidateData:o}=e,d=replacePlaceholdersAndSanitizeTheEmailBody(i.emailBody||r.emailBody||""),u=replacePlaceholdersAndSanitizeTheEmailBody(i.subject||r.subject||""),c={...r,sendTo:i.sendTo,replyTo:i.replyTo,subject:u,emailBody:i.emailBody||r.emailBody,body:d,cc:i.cc||[],bcc:i.bcc||[],emailCopyToSender:i.emailCopyToSender,emailTriggeredFrom:s?"TalentPool":n?"JobDashboard":"Candidate"},m=[];return n&&(null==o?void 0:null===(l=o.candidateIds)||void 0===l?void 0:l.length)>0?m=o.candidateIds:s&&(null==o?void 0:null===(t=o.candidatesListInTalentPool)||void 0===t?void 0:t.length)>0?m=o.candidatesListInTalentPool:(null==r?void 0:r.candidate)?m=[r.candidate]:(null==o?void 0:null===(a=o.candidate)||void 0===a?void 0:a._id)&&(m=[o.candidate._id]),m.length>0&&(c.candidateIds=m),c},processEmailTemplates=e=>{var l;return Array.isArray(e)&&(null==e?void 0:null===(l=e.filter(e=>!e.disabled))||void 0===l?void 0:l.map(e=>{var l;return{id:e._id||e.id,name:e.template_name||e.name,subject:e.email_subject||e.subject,body:e.email_body||e.body,isDeletable:e.isDeletable??!0,personalized:e.personalized??!1,talentPool:e.talentPool??!1,disabled:e.disabled??!1,createdBy:(null===(l=e.userDetails)||void 0===l?void 0:l.first_name)??""}}))||[]},filterEmailTemplates=(e,l)=>Array.isArray(e)?e.filter(e=>!l.isBulk||!e.personalized):[],addEmailToList=(e,l)=>{if(!l||""===l.trim())return{success:!1,message:"Email address is required",emailList:e||[]};let t=e||[];if(t.includes(l))return{success:!1,message:"Email already added",emailList:t};let a=[...t,l];return{success:!0,message:"Email added successfully",emailList:a}},removeEmailFromList=(e,l)=>Array.isArray(e)?e.filter(e=>e!==l):[];var D=t(57),R=t(90433);let EmailTemplatesDropdown=e=>{var l,t;let{isPopup:r,isBulk:s,setValue:n,clearSelectedTemplate:o}=e,m=(0,c.useRouter)(),{candidateIds:p}=(0,j.Z)(),{candidateIds:x}=(0,y.Z)(),{updateEmailFormData:f}=useEmailForm(),h=m.pathname.includes("talent_pool"),b=m.query.candidateId,v=b?m.query.candidateId:(null==p?void 0:p.length)>1?null:null==p?void 0:p[0];h&&(null==x?void 0:x.length)===1&&(v=x[0]);let{data:N}=(0,u.Nf)({}),{data:C}=(0,d.LC)(),{candidateData:E}=useCandidateData(v),{jobResult:T}=(0,D.Z)(),_=(null==T?void 0:T.response)||{applicantInfo:{}},{generateEmailStream:S,isStreaming:k}=customHook_useEmailStreamGenerator(),[z,L]=(0,i.useState)(null),[Z,A]=(0,i.useState)(!1),[F,q]=(0,i.useState)(""),O=(0,i.useRef)(null),U=(0,i.useRef)(null),H=null==E?void 0:E.candidate,V=(null==_?void 0:null===(l=_.role)||void 0===l?void 0:l.trim())||"@[Job Role](job_role)",M=(0,R.BJ)(null==H?void 0:H.name)||"@[Candidate Name](candidate_name)",Y=(null==N?void 0:null===(t=N.company_full_name)||void 0===t?void 0:t.trim())||(null==N?void 0:N.org_name),J=(null==N?void 0:N.name)||(null==N?void 0:N.email)||"@[Recruiter Name](recruiter_name)",{emailTemplates:W}=getDefaultEmailTemplates({jobRole:V,candidateName:M,companyName:Y,recruiterName:J}),G=processEmailTemplates((null==C?void 0:C.data)||[]),Q=[...W,...G],X=filterEmailTemplates(Q,{isBulk:s,isTalentPool:h}).filter(e=>!e.personalized),K=F?X.filter(e=>e.name.toLowerCase().includes(F.toLowerCase())||e.subject&&e.subject.toLowerCase().includes(F.toLowerCase())||e.body&&e.body.toLowerCase().includes(F.toLowerCase())):X,ee=`Unique opportunity at ${Y} tailored for you`,el=!s&&(!F||"personalised outreach email".includes(F.toLowerCase())||ee.toLowerCase().includes(F.toLowerCase())||"personalized".includes(F.toLowerCase())||"personalised".includes(F.toLowerCase())||"ai".includes(F.toLowerCase())||"outreach".includes(F.toLowerCase())),et=(0,i.useCallback)(function(e){let l=arguments.length>1&&void 0!==arguments[1]&&arguments[1],t=fixPlaceholders(e.body),a=fixPlaceholders(e.subject);n&&(n("subject",a,{shouldValidate:!0}),l||n("emailBody",t,{shouldValidate:!0})),f&&f({id:e.id,subject:a,emailBody:l?"":t,templateUsed:!0,templateValue:e.name,candidate:null==H?void 0:H._id,name:(0,R.BJ)(null==H?void 0:H.name),phoneNumber:null==H?void 0:H.phone_number}),L(e),A(!1),q("")},[n,f,H]),fixPlaceholders=e=>{var l;if(!e)return e;let t=null==m?void 0:null===(l=m.query)||void 0===l?void 0:l.jobId,a=`${w.jW}/${N.company_domain}/job/${t}`,i=e;return Object.entries({"@[Candidate Name](candidate_name)":M,"@[Job Role](job_role)":V,"@[Recruiter Name](recruiter_name)":J,"@[Job Link](job_link)":a}
18).forEach(e=>{let[l,t]=e;t&&(i=i.replace(RegExp(l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t))}),i},ea=(0,i.useCallback)(()=>{n&&(n("subject",""),n("emailBody",""),n("cc",[]),n("bcc",[])),f&&f({id:null,subject:"",emailBody:"",templateUsed:!1,templateValue:null,candidate:null==H?void 0:H._id,name:(0,R.BJ)(null==H?void 0:H.name),sendTo:null==H?void 0:H.email,phoneNumber:null==H?void 0:H.phone_number,replyTo:null==N?void 0:N.email}),L(null)},[n,f,H,N]),ei=(0,i.useCallback)(async()=>{if(!k)try{let e=h?{id:8,talentPool:!0,personalized:!0,name:"Personalized outreach email with AI",subject:`Unique opportunity at ${Y} tailored for you`,body:""}:{id:4,personalized:!0,name:"Personalized outreach email with AI",subject:`Unique opportunity at ${Y} tailored for you`,body:""};n&&(n("subject",e.subject,{shouldValidate:!1}),n("emailBody","",{shouldValidate:!1})),L(e),A(!1),q(""),f&&f({id:e.id,subject:e.subject,emailBody:"",templateUsed:!0,templateValue:e.name,candidate:null==H?void 0:H._id,name:(0,R.BJ)(null==H?void 0:H.name),phoneNumber:null==H?void 0:H.phone_number}),await S({candidateName:M,jobRole:V,companyName:Y,contentInput:"",currentEmailBody:"",current_subject:e.subject,recruiterName:J,emailTone:"professional",personalized:!0,isTalentPool:h,isTemplateCreation:!1,onEmailBodyUpdate:e=>{n&&n("emailBody",e,{shouldValidate:!1}),f&&f({emailBody:e})},onSubjectUpdate:e=>{n&&n("subject",e,{shouldValidate:!1}),f&&f({subject:e})}})}catch(e){console.error("Error generating personalized email:",e)}},[k,h,Y,n,f,H,M,V,J,S]);return(0,i.useEffect)(()=>{o&&(o.current=ea)},[ea,o]),(0,i.useEffect)(()=>{if(Z&&O.current){let focusInput=()=>{var e,l;null===(e=O.current)||void 0===e||e.focus(),null===(l=O.current)||void 0===l||l.select()};focusInput(),requestAnimationFrame(focusInput),setTimeout(focusInput,10),setTimeout(focusInput,50)}},[Z]),(0,a.jsx)("div",{className:"w-full flex flex-col gap-2 font-normal",children:(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("label",{className:`absolute left-4 z-[1] text-xs font-normal px-1 bg-white transition-all duration-300 cursor-pointer select-none ${z?"-top-2 text-lightPurple":"top-3 scale-[120%] text-gray-500"}`,onClick:e=>{e.preventDefault(),k||A(!0)},children:z?"Template":"Template (Optional)"}),(0,a.jsx)("div",{className:"relative",children:(0,a.jsxs)(P.h_,{open:Z,onOpenChange:e=>{A(e),e?(requestAnimationFrame(()=>{var e;null===(e=O.current)||void 0===e||e.focus()}),setTimeout(()=>{var e;null===(e=O.current)||void 0===e||e.focus()},0)):q("")},children:[(0,a.jsxs)(P.$F,{className:`w-full h-[40px] px-3 py-2 bg-white border border-gray-300 rounded relative ${k?"cursor-not-allowed opacity-50 hover:bg-white":"hover:bg-transparent"}`,icon:z?null:(0,a.jsx)(I.p,{size:16,className:"text-gray-500"}),disabled:k,children:[(0,a.jsx)("span",{className:"truncate text-sm text-gray-700 pr-8",children:z?z.name:""}),(0,a.jsx)("span",{className:"text-greenText bg-greenText/10 border border-greenText text-xs font-medium px-1 py-0.5 mr-6 rounded absolute right-4",children:"New"})]}),z&&(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),e.preventDefault(),ea()},className:`absolute right-2 top-1/2 transform -translate-y-1/2 p-1 text-gray-500 rounded transition-colors z-10 ${k?"cursor-not-allowed opacity-50":"hover:text-gray-700 hover:bg-gray-100"}`,title:"Clear template",type:"button",disabled:k,children:(0,a.jsx)($.X,{size:16})}),(0,a.jsxs)(P.AW,{ref:U,sideOffset:4,className:"w-full min-w-[var(--radix-dropdown-menu-trigger-width)] max-h-80 overflow-hidden flex flex-col",children:[(0,a.jsx)("div",{className:"p-2 border-b border-gray-100",onPointerDown:e=>e.preventDefault(),children:(0,a.jsx)("input",{ref:O,type:"text",placeholder:"Search templates...",value:F,onChange:e=>{e.stopPropagation(),q(e.target.value)},onKeyDown:e=>{switch(e.stopPropagation(),e.key){case"Escape":A(!1);break;case"ArrowDown":var l;e.preventDefault();let t=null===(l=U.current)||void 0===l?void 0:l.querySelector('[role="menuitem"]');null==t||t.focus();break;case"Enter":e.preventDefault(),K.length>0&&et(K[0])}},onFocus:e=>{e.stopPropagation()},onBlur:e=>{e.stopPropagation()},onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),autoFocus:!0,className:"w-full px-3 py-2 text-sm border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-lightPurple focus:border-lightPurple"})}),(0,a.jsxs)("div",{className:"overflow-y-auto flex-1",children:[(0,a.jsx)(P.Xi,{onClick:()=>{k||window.open("/dashboard/user/templates?create_new_template=true")},className:"border-b border-gray-100 mb-1",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm text-lightPurple font-medium",children:[(0,a.jsx)(B.v,{size:16}),(0,a.jsx)("span",{children:"Create New Template"})]})}),el&&(0,a.jsx)(P.Xi,{onClick:()=>{k||ei()},disabled:k,children:(0,a.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,a.jsx)("div",{className:"flex-1 truncate text-sm text-lightPurple2",children:"Personalised Outreach Email"}),(0,a.jsx)("div",{className:"text-xs px-1.5 py-0.5 rounded-full bg-lightPurple/10 border-lightPurple2/50 text-lightPurple2",children:"AI"})]})}),0!==K.length||el?null==K?void 0:K.map(e=>(0,a.jsxs)(P.Xi,{onClick:()=>{k||et(e)},children:[(0,a.jsx)("div",{className:"flex-1 truncate text-sm text-lightPurple2",children:e.name}),(0,a.jsx)("div",{className:`text-xs px-1.5 py-0.5 rounded-full 19 ${e.createdBy?"bg-lightPurple/10 border-lightPurple2/50 text-lightPurple2":"bg-gray-100 border-gray-300 text-gray-500"} `,children:e.createdBy||"default"})]},e.id)):(0,a.jsx)("div",{className:"text-sm text-lightPurple2 text-center py-4",children:F?"No templates match your search":"No templates available"})]})]})]})}),k&&(0,a.jsxs)("div",{className:"flex items-center gap-1 mt-1 text-sm text-gray-500",children:[(0,a.jsx)(g.Z,{}),(0,a.jsx)("span",{children:"Generating..."})]})]})})};var z=t(76975);let CCBCCManager=e=>{let{errors:l,setValue:t,watch:r,showCcAndBcc:s,expandEmailBody:n}=e,o=r(),[d,u]=(0,i.useState)(""),[c,m]=(0,i.useState)(""),p=(0,i.useCallback)(e=>{if(!e||""===e.trim())return;let l=e.trim();if(!(0,z.oH)(l)){(0,x.Z)("Invalid email format","error");return}let a=addEmailToList(o.cc||[],l);a.success?(t("cc",a.emailList),u(""),(0,x.Z)("Email added to CC","success")):(0,x.Z)(a.message,"error")},[o.cc,t]),f=(0,i.useCallback)(e=>{let l=removeEmailFromList(o.cc||[],e);t("cc",l)},[o.cc,t]),g=(0,i.useCallback)(e=>{if(!e||""===e.trim())return;let l=e.trim();if(!(0,z.oH)(l)){(0,x.Z)("Invalid email format","error");return}let a=addEmailToList(o.bcc||[],l);a.success?(t("bcc",a.emailList),m(""),(0,x.Z)("Email added to BCC","success")):(0,x.Z)(a.message,"error")},[o.bcc,t]),b=(0,i.useCallback)(e=>{let l=removeEmailFromList(o.bcc||[],e);t("bcc",l)},[o.bcc,t]),EmailSuggestion=e=>{let{email:l,onSelect:t}=e;return(0,z.oH)(l)?(0,a.jsx)("div",{className:"absolute w-full z-10 top-[50px] bg-white border border-gray-300 rounded-md shadow-lg cursor-pointer hover:bg-gray-50",onClick:()=>t(l),children:(0,a.jsx)("div",{className:"px-4 py-2 text-sm",children:l})}):null},EmailTag=e=>{let{email:l,onRemove:t,type:i}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-2 text-sm bg-lightPurple/5 text-lightPurple roun
19ded-full w-fit py-1 px-3 border border-lightPurple/20",children:[(0,a.jsx)("span",{className:"text-xs uppercase font-medium",children:i}),(0,a.jsx)("span",{children:l}),(0,a.jsx)("button",{type:"button",onClick:()=>t(l),className:"text-lightPurple hover:text-lightPurple ml-1",children:(0,a.jsx)($.X,{size:14})})]})};return s?(0,a.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,a.jsxs)("div",{className:`relative w-full ${n?"hidden":""}`,children:[(0,a.jsx)(h.Z,{className:"text-sm",onChange:e=>u(e.target.value),type:"text",value:d,id:"cc",label:"cc",onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),p(d))}}),(0,a.jsx)(EmailSuggestion,{email:d,onSelect:p})]}),(0,a.jsx)("div",{className:`w-full flex flex-wrap gap-2 ${0===(o.cc||[]).length||n?"hidden":""}`,children:(o.cc||[]).map((e,l)=>(0,a.jsx)(EmailTag,{email:e,onRemove:f,type:"CC"},l))}),(0,a.jsxs)("div",{className:`relative w-full ${n?"hidden":""}`,children:[(0,a.jsx)(h.Z,{className:"text-sm",onChange:e=>m(e.target.value),type:"text",value:c,id:"bcc",label:"bcc",onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),g(c))}}),(0,a.jsx)(EmailSuggestion,{email:c,onSelect:g})]}),(0,a.jsx)("div",{className:`w-full flex flex-wrap ${0===(o.bcc||[]).length||n?"hidden":""}`,children:(o.bcc||[]).map((e,l)=>(0,a.jsx)(EmailTag,{email:e,onRemove:b,type:"BCC"},l))}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:"Press Enter to add an email address. CC re
19cipients can see each other, BCC recipients cannot."}),l.cc&&(0,a.jsx)("p",{className:"text-red-500 text-sm",children:l.cc.message}),l.bcc&&(0,a.jsx)("p",{className:"text-red-500 text-sm",children:l.bcc.message})]}):null};var L=t(61624),Z=t(87633);let A=["Ask for availability at 5 PM Monday","Ask for graduation documents","Check if open for a new role","Request portfolio or work samples","Inquire about notice period","Ask about salary expectations","Schedule a follow-up interview","Request references from previous employers","Inquire about remote work preferences","Ask about current project details"],AIEmailModifier=e=>{var l;let{setValue:t,clearErrors:r,isTemplateCreation:s=!1,emailFormData:n}=e,{data:o}=(0,u.Nf)({}),d=(0,c.useRouter)(),{jobId:m}=d.query,{data:f}=(0,p.gR)(m,{skip:!m}),{generateEmailStream:b,isStreaming:v}=customHook_useEmailStreamGenerator(),{emailFormData:y,updateEmailFormData:j}=useEmailForm(),[w,N]=(0,i.useState)(""),[C,E]=(0,i.useState)(!1),[T,_]=(0,i.useState)(!1),[S,k]=(0,i.useState)(""),P=(null==f?void 0:null===(l=f.response)||void 0===l?void 0:l.role)||"",I=y.name||"@[Candidate Name](candidate_name)",$=(null==o?void 0:o.company_full_name)||(null==o?void 0:o.org_name)||"",B=(null==o?void 0:o.name)||"@[Recruiter Name](recruiter_name)",D=d.pathname.includes("talent_pool"),{typewriterText:R,hasCompletedCycle:z}=useTypewriterEffect(!T&&!C,A,{typingSpeed:50,deletingSpeed:30,pauseAfterTyping:2e3,shouldStopAfterCycle:!0}),handleModifyEmail=async()=>{if(!w.trim()){(0,x.Z)("Please enter a modification request","error");return}try{r&&r(["subject","emailBody"]);let e=await b({candidateName:I,jobRole:P,companyName:$,contentInput:w,currentEmailBody:(null==n?void 0:n.emailBody)||y.emailBody||"",recruiterName:B,emailTone:"professional",isTalentPool:D,isTemplateCreation:s,current_subject:S||(null==n?void 0:n.subject)||(null==y?void 0:y.subject)||"",onEmailBodyUpdate:e=>{t&&t("emailBody",e),j&&j({emailBody:e})},onSubjectUpdate:e=>{k(e),t&&t("subject",e),j&&j({subject:e})}});e?E(!1):console.log("Failed to modify email","error")}catch(e){(0,x.Z)("Error occurred while modifying email","error")}};return(0,a.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-0 w-full",children:[(0,a.jsxs)("div",{className:"flex-1 relative",children:[(0,a.jsx)("p",{className:"absolute -top-2 left-4 z-10 text-xs text-lightPurple font-normal px-1 bg-white",children:"Write / Modify with AI"}),(0,a.jsx)(h.Z,{onChange:e=>N(e.target.value),type:"text",value:w,alwaysShowLabelOnTheTop:!1,id:"modifyBody",label:"",placeholder:T||C||w?"Describe how you want to modify the email...":z?"Describe how you want to modify the email...":R||"Describe how you want to modify the email...",className:"rounded-r-none text-sm border-r-0 font-normal",onCustomFocus:()=>{E(!0),_(!0)},onBlur:()=>{E(!1)},onKeyDown:e=>{"Enter"===e.key&&!v&&w.trim()&&handleModifyEmail()},disabled:v})]}),(0,a.jsx)(Z.zx,{type:"button",loading:v,disabled:v||!w.trim(),onClick:handleModifyEmail,className:"w-fit h-[40px] flex items-center justify-center rounded-l-none border-l-0",children:(0,a.jsx)(L.g,{size:18})})]}),v&&(0,a.jsxs)("div",{className:"flex items-center gap-1 text-sm text-lightPurple",children:[(0,a.jsx)(g.Z,{}),(0,a.jsx)("span",{children:"AI is generating your email..."})]})]})};var F=t(69258);let EmailStatusDisplay=e=>{var l,t;let{emailSentResponse:i,isEmailTriggerFromJobDashboard:r,isTalentPoolPage:s,onClose:o,isLoading:d}=e,copyToClipboard=e=>{e&&e.length>0&&(navigator.clipboard.writeText(e.join(", ")),(0,x.Z)("Copied to clipboard","success"))},EmailList=e=>{let{emails:l,type:t,bgColor:i,textColor:r,borderColor:s,icon:n}=e;return l&&0!==l.length?(0,a.jsxs)("div",{className:"bg-white rounded-xl shadow-md p-6 flex flex-col justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("p",{className:`text-lg font-semibold ${r}`,children:t}),(0,a.jsx)("button",{onClick:()=>copyToClipboard(l),className:`text-sm ${r} hover:underline`,children:l.length>1?"Copy All":"Copy"})]}),(0,a.jsx)("div",{className:"flex flex-col w-full gap-3 h-40 overflow-y-auto scrollCustom",children:l.map((e,l)=>(0,a.jsxs)("div",{className:`w-fit px-4 py-2 rounded-full border text-sm flex items-center gap-2 ${i} ${s} ${r}`,children:[(0,a.jsx)(n,{size:16}),e]},l))})]}):null};return(0,a.jsxs)("div",{className:"w-full flex flex-col gap-5 p-5 bg-white rounded-lg max-h-[90vh]",children:[(0,a.jsxs)("div",{className:`flex items-center justify-between ${s?"text-textDark text-lg font-semibold":""}`,children:[(0,a.jsx)("p",{children:r?"Failed to send some emails":"Failed to send email"}),s?(0,a.jsx)($.X,{className:"cursor-pointer",size:24,onClick:o}):(0,a.jsx)(n.a,{className:"cursor-pointer",size:24,onClick:o})]}),(0,a.jsxs)("div",{className:`flex flex-col h-full p-6 bg-gray-100 rounded-lg shadow-lg gap-6 ${r?"w-[45vw] 2xl:w-[35vw] min-h-[40vh]":"w-full"}`,children:[r&&(0,a.jsx)("div",{className:"flex justify-between items-center border-b pb-2 mb-4",children:(0,a.jsx)("h1",{className:"text-2xl font-bold text-gray-800",children:"Email Status Report"})}),(0,a.jsxs)("div",{className:`grid grid-cols-1 gap-6 ${r?"md:grid-cols-2":""}`,children:[(0,a.jsx)(EmailList,{emails:null==i?void 0:i.successEmails,type:"Success",bgColor:"bg-green-50",textColor:"text-green-600",borderColor:"border-green-200",icon:F.f}),(0,a.jsx)(EmailList,{emails:null==i?void 0:i.failedEmails,type:"Failed",bgColor:"bg-red-50",textColor:"text-red-600",borderColor:"border-red-200",icon:n.a})]}),r&&(0,a.jsxs)("div",{className:"mt-4 text-center text-sm text-gray-500",children:[(null==i?void 0:null===(l=i.successEmails)||void 0===l?void 0:l.length)||0," emails sent successfully,"," ",(null==i?void 0:null===(t=i.failedEmails)||void 0===t?void 0:t.length)||0," failed."]})]}),(0,a.jsx)(Z.zx,{secondary:!0,loading:d,disabled:d,onClick:o,className:"w-full",children:"Close"})]})};var q=t(49509),O=t(8994);let LimitReachedDisplay=e=>{let{isPopup:l,isLoading:t,onClose:i,user:r,jobId:s,isTalentPool:n,dispatch:o}=e,{setShowContactUsModal:d,setSentUpgradeRequestMail:u}=(0,O.Z)(),handleUpgradeRequest=async()=>{try{i(),o&&o({type:"HIDE_ALL_POPUPS"});{var e;let l=null===(e=window.next)||void 0===e?void 0:e.router;l&&(s?l.replace(`/dashboard/user/candidates?jobId=${s}`,null,{shallow:!0}):n&&l.replace("/dashboard/user/talent_pool",null,{shallow:!0}))}d(!0),await (0,q.V2)(r,{subject:`Request to upgrade plan - Email Limit reached - ${r.email}`,message:"User has requested plan upgrade to send emails to candidates"}),u(!0),(0,x.Z)("Upgrade request sent successfully","success")}catch(e){(0,x.Z)("Failed to send upgrade request","error")}};return(0,a.jsx)("div",{className:`${l?"w-[35vw] 2xl:w-[25vw]":"w-full h-full"} relative flex flex-col items-center justify-center bg-white rounded-lg`,children:(0,a.jsxs)("div",{className:"flex flex-col items-center justify-start p-6 mx-auto",children:[(0,a.jsxs)("div",{className:"flex border p-4 rounded-md border-amber-600 mb-4 gap-2 text-amber-600",children:[(0,a.jsx)(C.Q,{className:"w-5 h-5 mt-[2px]"}),(0,a.jsx)("p",{className:"font-medium text-center",children:"Maximum emails sent in trial. Upgrade to send more"})]}),(0,a.jsxs)("div",{className:"w-full mb-6",children:[(0,a.jsx)("div",{className:"w-full h-2 bg-lightPurple roun
19ded-full animate-pulse"}),(0,a.jsx)("p",{className:"flex items-center justify-end text-gray-600 text-sm mt-1",children:"100% used"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-center gap-3 mt-0",children:[(0,a.jsx)(Z.zx,{secondary:!0,loading:t,disabled:t,onClick:i,children:"Discard"}),(0,a.jsx)(Z.zx,{primary:!0,loading:t,disabled:t,onClick:handleUpgradeRequest,children:"Request Upgrade"})]}),(0,a.jsxs)("div",{className:"mt-4 text-center text-sm text-gray-500",children:[(0,a.jsx)("p",{children:"Upgrade your plan to send unlimited emails"}),(0,a.jsx)("p",{className:"mt-1",children:"Contact support for immediate assistance"})]})]})})};var U=t(45901);let H=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;U.Z_().regex(H,"Please enter a valid email address");let V=U.IX(U.Z_().regex(H,"Invalid email format")).optional().default([]),M=U.Ry({sendTo:U.Z_().min(1,"Email address is required").regex(H,"Please enter a valid email address"),replyTo:U.Z_().min(1,"Reply-to email is required").regex(H,"Please enter a valid reply-to email address"),subject:U.Z_().min(1,"Subject is required").max(1e3,"Subject must be less than 1000 characters").refine(e=>e.trim().length>0,"Subject cannot be empty"),emailBody:U.Z_().min(1,"Email body is required").max(1e4,"Email body must be less than 10000 characters").refine(e=>e.trim().length>0,"Email body cannot be empty"),cc:V,bcc:V,emailCopyToSender:U.O7().default(!0)}),Y=M.extend({sendTo:U.Z_().optional().default("")}),createEmailValidationSchema=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{isTalentPoolPage:l=!1,isEmailTriggerFromJobDashboard:t=!1}=e;return l||t?Y:M};var J=t(75924);function SendEmailForm(e){var l,t,v,y,j,w,N;let{closeHandler:C,candidateId:E,isTalentPoolPage:T,isEmailTriggerFromJobDashboard:_,isPopup:S}=e,{data:k,refetch:P}=(0,u.Nf)({}),I=((null==k?void 0:k.plan)!=="BOOTSTRAP")??!1,$=(0,c.useRouter)(),{dispatch:B}=(0,i.useContext)(m.k),{jobId:D}=$.query,{data:R}=(0,p.gR)(D,{skip:!D}),z=(null==R?void 0:null===(l=R.response)||void 0===l?void 0:l.role)||"",{candidateData:L,isCandidateDetailsSuccess:Z}=useCandidateData(E),{emailFormData:A,updateEmailFormData:F}=useEmailForm(),{sendEmail:q,isLoading:O,emailSentResponse:U,isSuccess:H,isError:V}=useEmailSubmission(),{generateEmailStream:M,isStreaming:Y}=customHook_useEmailStreamGenerator(),{emailDetails:W,resetEmailDetails:G}=(0,b.Z)(),Q=null==k?void 0:null===(t=k.featuresEnabled)||void 0===t?void 0:t.emailTemplates,X=createEmailValidationSchema({isTalentPoolPage:T,isEmailTriggerFromJobDashboard:_}),{control:K,handleSubmit:ee,watch:el,setValue:et,reset:ea,clearErrors:ei,formState:{errors:er,isValid:es}}=(0,r.cI)({resolver:(0,s.F)(X),defaultValues:{sendTo:"",replyTo:"",subject:"",emailBody:"",cc:[],bcc:[],emailCopyToSender:!0},mode:"onChange"}),en=el(),[eo,ed]=(0,i.useState)(!1),[eu,ec]=(0,i.useState)(!1),[em,ep]=(0,i.useState)(!1),ex=(0,i.useRef)(null),ef=$.pathname.includes("talent_pool"),eh=ef?(null==L?void 0:null===(v=L.candidatesListInTalentPool)||void 0===v?void 0:v.length)>1:(null==$||null===(y=$.query)||void 0===y||!y.candidateId)&&(null==$||null===(j=$.query)||void 0===j||!j.candidate)&&(null==L?void 0:null===(w=L.candidateIds)||void 0===w?void 0:w.length)>1,{refetch:eg}=(0,d.Ex)({candidateId:E},{refetchOnMountOrArgChange:!0,skip:!(null==L?void 0:L.candidate)});(0,i.useEffect)(()=>{if(Z&&(null==L?void 0:L.candidate)){let e=L.candidate;et("sendTo",(null==e?void 0:e.email)||""),et("replyTo",(null==k?void 0:k.email)||""),et("subject",""),F({candidate:null==e?void 0:e._id,name:null==e?void 0:e.name,sendTo:null==e?void 0:e.email,phoneNumber:null==e?void 0:e.phone_number,replyTo:null==k?void 0:k.email,subject:""})}else k&&(F({name:null==k?void 0:k.name,phoneNumber:null==k?void 0:k.phone_number,replyTo:null==k?void 0:k.email}),et("replyTo",(null==k?void 0:k.email)||""))},[Z,null==L?void 0:L.candidate,k,z,et]),(0,i.useEffect)(()=>{T&&(null==W?void 0:W.replyTo)&&(null==k?void 0:k.email)&&et("replyTo",W.replyTo)},[T,null==W?void 0:W.replyTo,null==k?void 0:k.email,et]);let onSubmit=async e=>{try{if(!I){(0,x.Z)("You are not allowed to send email","error");return}let l=formatEmailDetailsForSubmission({formData:e,emailFormData:A,isTalentPoolPage:T,isEmailTriggerFromJobDashboard:_,candidateData:L});await q(l)}catch(e){console.log("Error sending email","error")}};(0,i.useEffect)(()=>
19{if(H){var e,l,t;(null==U?void 0:null===(e=U.failedEmails)||void 0===e?void 0:e.length)>0?(0,x.Z)("Failed to send some emails","warning"):((0,x.Z)("Email sent successfully","success"),C(),ea(),E&&!T&&eg()),T&&(null==L||null===(l=L.restoreDefaults)||void 0===l||l.call(L)),_&&(null==L||null===(t=L.clearAllCandidatesList)||void 0===t||t.call(L)),P()}},[H,U,E,T]);let handlePersonalizeEmail=async()=>{try{var e,l;ep(!0),ex.current&&ex.current(),ei(["subject","emailBody"]);let t=null==L?void 0:L.candidate,a=(null==t?void 0:t.name)||"@[Candidate Name](candidate_name)",i=(null==t?void 0:null===(e=t.job)||void 0===e?void 0:e.role)||"@[Job Role](job_role)",r=(null==k?void 0:null===(l=k.company_full_name)||void 0===l?void 0:l.trim())||(null==k?void 0:k.org_name),s=(null==k?void 0:k.name)||"@[Recruiter Name](recruiter_name)",n=ef?{id:8,talentPool:!0,personalized:!0,name:"Personalized outreach email with AI",subject:`Unique opportunity at ${r} tailored for you`,body:""}:{id:4,personalized:!0,name:"Personalized outreach email with AI",subject:`Unique opportunity at ${r} tailored for you`,body:""};et("subject",n.subject,{shouldValidate:!0}),F({id:n.id,subject:n.subject,templateUsed:!0,templateValue:n.name,candidate:null==t?void 0:t._id,name:null==t?void 0:t.name,phoneNumber:null==t?void 0:t.phone_number}),await M({candidateName:a,jobRole:i,companyName:r,contentInput:"",currentEmailBody:"",recruiterName:s,emailTone:"professional",personalized:!0,isTalentPool:n.talentPool,onEmailBodyUpdate:e=>{et("emailBody",e,{shouldValidate:!0}),F({emailBody:e})}})}catch(e){(0,x.Z)("Failed to personalize email with AI","error")}finally{ep(!1)}},handleClose=()=>{C(),ea(),F({}),G()};return(()=>{if(null==k?void 0:k.isLimitedMailUser){let e=(null==k?void 0:k.sentEmails)||0,l=null==k?void 0:k.emailSendingLimit;return e+1>l}return!1})()?(0,a.jsx)(LimitReachedDisplay,{isPopup:S,isLoading:O,onClose:handleClose,user:k,jobId:D,isTalentPool:ef,dispatch:B}):H&&(null==U?void 0:null===(N=U.failedEmails)||void 0===N?void 0:N.length)>0?(0,a.jsx)(EmailStatusDisplay,{emailSentResponse:U,isEmailTriggerFromJobDashboard:_,isTalentPoolPage:T,onClose:handleClose,isLoading:O}):(0,a.jsx)("div",{className:`${S?"w-[60vw]":"w-full"} flex flex-col gap-5 bg-white rounded-lg h-full overflow-auto`,children:(0,a.jsxs)("form",{onSubmit:ee(onSubmit),className:"flex flex-col w-full h-full gap-5 overflow-auto p-5 scrollHide",children:[(0,a.jsxs)("div",{className:`flex items-center justify-between h-fit ${T?"text-textDark text-lg font-semibold":""}`,children:[(0,a.jsx)("p",{children:"Send Email"}),(0,a.jsx)(n.a,{className:"cursor-pointer",size:24,onClick:handleClose})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-5 font-normal h-auto",children:[T||_?(0,a.jsxs)("div",{className:`flex flex-col gap-2 w-full ${eu?"hidden":""}`,children:[(0,a.jsx)(h.Z,{className:"border-gray-300 text-gray-500 hover:cursor-not-allowed text-sm",labelClassName:"text-gray-500",disabled:!0,type:"text",value:"Email will be sent separately to all selected candidates",id:"Send To",label:"Send To",alwaysShowLabelOnTheTop:!0}),(0,a.jsx)("div",{className:`w-full flex items-center justify-end ${eo?"hidden":""}`,children:(0,a.jsx)("div",{className:"text-xs flex items-center justify-end border-0 text-lightPurple cursor-pointer hover:underline",onClick:()=>ed(!0),children:"Add CC and BCC"})})]}):(0,a.jsxs)("div",{className:`flex flex-col gap-2 ${eu?"hidden":""}`,children:[(0,a.jsx)(r.Qr,{name:"sendTo",control:K,render:e=>{let{field:l}=e;return(0,a.jsx)(h.Z,{className:`text-sm ${er.sendTo?"border-red-500":""}`,onChange:l.onChange,type:"text",value:l.value,id:"Send To",label:"Send To",alwaysShowLabelOnTheTop:!0})}}),er.sendTo&&(0,a.jsx)("p",{className:"text-red-500 text-sm",children:er.sendTo.message}),(0,a.jsx)("div",{className:`w-full flex items-center justify-end ${eo?"hidden":""}`,children:(0,a.jsx)("div",{className:"w-fit text-xs flex items-center justify-end border-0 text-lightPurple cursor-pointer hover:underline",onClick:()=>ed(!0),children:"Add CC and BCC"})})]}),(0,a.jsx)(CCBCCManager,{control:K,errors:er,setValue:et,watch:el,showCcAndBcc:eo,expandEmailBody:eu}),(0,a.jsxs)("div",{className:"flex flex-col",children:[(0,a.jsx)(r.Qr,{name:"replyTo",control:K,render:e=>{let{field:l}=e;return(0,a.jsx)(h.Z,{className:`text-sm ${er.replyTo?"border-red-500":""}`,onChange:l.onChange,type:"text",value:l.value,id:"replyTo",label:"Reply to"})}}),er.replyTo&&(0,a.jsx)("p",{className:"text-red-500 text-sm mt-1",children:er.replyTo.message})]}),!eu&&Q&&(0,a.jsx)(EmailTemplatesDropdown,{isPopup:S,isBulk:eh,setValue:et,clearSelectedTemplate:ex}),(0,a.jsx)("div",{className:`w-full flex items-center justify-end -mt-3 ${eh||!Q?"hidden":""}`,children:(0,a.jsx)("div",{className:`w-fit text-xs flex items-center justify-end border-0 cursor-pointer ${O||Y||em?"text-textDark2 cursor-not-allowed opacity-50":"text-lightPurple hover:underline"}`,onClick:O||Y||em?void 0:handlePersonalizeEmail,children:em?(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(g.Z,{}),(0,a.jsx)("span",{children:"Personalizing..."})]}):(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(o.J,{size:12,weight:"duotone"}),"Write personalized outreach email with AI"]})})}),(0,a.jsx)(EmailSubjectInput,{control:K,errors:er})]}),(0,a.jsxs)("div",{className:"flex flex-col h-full w-full gap-1 z-40",children:[(0,a.jsx)(r.Qr,{name:"emailBody",control:K,render:e=>{let{field:l}=e;return(0,a.jsx)(EmailBodyTextArea,{value:l.value,onChange:l.onChange,placeholder:"Enter your email message here...",className:"h-full min-h-[200px]"})}}),er.emailBody&&(0,a.jsx)("p",{className:"text-red-500 text-sm",children:er.emailBody.message})]}),Q?(0,a.jsx)("div",{className:"flex",children:(0,a.jsx)(AIEmailModifier,{setValue:et,clearErrors:ei})}):(0,a.jsx)(a.Fragment,{}),(0,a.jsxs)("div",{className:"flex flex-col w-full h-fit items-start justify-end gap-2",children:[(0,a.jsxs)("div",{className:`flex items-center justify-start gap-2 text-xs font-normal ${eh?"":"hidden"}`,children:[(0,a.jsx)(r.Qr,{name:"emailCopyToSender",control:K,render:e=>{let{field:l}=e;return(0,a.jsx)(f.Z,{checked:!l.value,onCheckedChange:()=>l.onChange(!l.value)})}}),(0,a.jsx)("p",{className:"text-sm text-textDark2",children:"Do not send me a copy of the email"})]}),(0,a.jsx)(J.z,{type:"submit",loading:O,disabled:O||!(()=>{let e=en.replyTo&&en.subject&&en.emailBody;return T||_?e:e&&en.sendTo})(),className:"flex justify-center items-center w-full",children:"Send Email"})]})]})})}},42581:function(e,l,t){var a=t(85893),i=t(67294),r=t(76530),s=t(57851);let n=(0,i.forwardRef)((e,l)=>{let{label:t,icon:n,className:o,labelClassName:d,alwaysShowLabelO
19nTheTop:u,onCustomFocus:c=()=>{},...m}=e,[p,x]=(0,i.useState)(!1),{onBlur:f}=m,h=!!n,g=(0,s.m)("w-full border-[#D9DEE2] border-[1px] focus:border-[#6D5DE7] px-3 py-4 rounded h-[40px] focus:ring-0 border-1 placeholder:text-sm placeholder:font-normal",`${h?"pl-12":""}`,`${p||m.value||u?" text-textDark border-purpleBorder":" "}`,o),b=(0,s.m)("absolute top-4 left-5 text-xs bg-white px-1 duration-300",`${p||m.value||u?"-top-[7px] text-[#6D5DE7]":"top-[12.5px] scale-[120%] text-textDark3"}`,d),v=(0,i.useRef)();return(0,a.jsxs)("div",{className:"relative w-full",children:[(0,a.jsx)("div",{children:(0,a.jsxs)("div",{className:"relative rounded-md text-sm text-textDark items-center",children:[h&&n,(0,a.jsx)("input",{autocomplete:"off",ref:(0,r.l)([v,l]),className:g,...m,onFocus:()=>{x(!0),c()},onBlur:e=>{x(!1),f&&"function"==typeof f&&f(e)}})]})}),!!t&&(0,a.jsx)("label",{className:b,onClick:()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.focus()},children:t})]})});l.Z=n},11292:function(e,l,t){t.d(l,{dT:function(){return u},di:function(){return f},e8:function(){return c},fu:function(){return p},mY:function(){return o},rb:function(){return m},sZ:function(){return d}});var a=t(85893),i=t(67294),r=t(66289),s=t(87764),n=t(57851);let o=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.mY,{ref:l,className:(0,n.m)("flex h-full w-full flex-col overflow-hidden rounded-md bg-white border border-purpleBorder text-lightPurple shadow-md",t),...i})});o.displayName=r.mY.displayName;let d=i.forwardRef((e,l)=>{let{className:t,hideSearchIcon:i,...o}=e;return(0,a.jsxs)("div",{className:"flex items-center border-b border-purpleBorder px-3 bg-violet-50",children:[(0,a.jsx)(s.Z,{className:"mr-2 h-4 w-4 shrink-0 opacity-50 text-lightPurple"}),(0,a.jsx)(r.mY.Input,{ref:l,className:(0,n.m)("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground text-lightPurple disabled:cursor-not-allowed disabled:opacity-50 focus:ring-0 border-0",t),...o})]})});d.displayName=r.mY.Input.displayName;let u=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.mY.Input,{ref:l,className:(0,n.m)("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground text-lightPurple disabled:cursor-not-allowed disabled:opacity-50 focus:ring-0 border-0 focus:outline-none",t),...i})});u.displayName=r.mY.Input.displayName;let c=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.mY.List,{ref:l,className:(0,n.m)("max-h-[300px] overflow-y-auto overflow-x-hidden bg-white text-lightPurple scrollCustom",t),...i})});c.displayName=r.mY.List.displayName;let m=i.forwardRef((e,l)=>(0,a.jsx)(r.mY.Empty,{ref:l,className:"py-6 text-center text-sm text-muted-foreground",...e}));m.displayName=r.mY.Empty.displayName;let p=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.mY.Group,{ref:l,className:(0,n.m)("overflow-hidden p-1 text-lightPurple [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",t),...i})});p.displayName=r.mY.Group.displayName;let x=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.mY.Separator,{ref:l,className:(0,n.m)("-mx-1 h-px bg-muted",t),...i})});x.displayName=r.mY.Separator.displayName;let f=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.mY.Item,{ref:l,className:(0,n.m)("relative flex cursor-pointer gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none hover:bg-violet-50 hover:text-lightPurple2 focus:bg-violet-100 focus:text-lightPurple2 data-[disabled=true]:pointer-events-none data-[selected=true]:bg-violet-100 data-[selected=true]:text-lightPurple2 data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0","outline-none cursor-pointer hover:bg-violet-50 py-1 px-2 rounded truncate flex justify-between items-center min-w-0 text-sm",t),...i})});f.displayName=r.mY.Item.displayName},19798:function(e,l,t){t.d(l,{$N:function(){return p},Be:function(){return x},GG:function(){return u}
19,Vq:function(){return n},cZ:function(){return m},hg:function(){return o}});var a=t(85893),i=t(67294),r=t(71074),s=t(71096);let n=r.fC,o=r.xz,d=r.h_,u=r.x8,c=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.aV,{ref:l,className:(0,s.cn)("fixed inset-0 z-50 bg-transparent/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...i})});c.displayName=r.aV.displayName,r.VY;let m=i.forwardRef((e,l)=>{let{className:t,children:i,...n}=e;return(0,a.jsxs)(d,{children:[(0,a.jsx)(c,{}),(0,a.jsx)(r.VY,{ref:l,className:(0,s.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-2 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...n,children:i})]})});m.displayName=r.VY.displayName;let p=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.Dx,{ref:l,className:(0,s.cn)("text-lg font-semibold leading-none text-textDark",t),...i})});p.displayName=r.Dx.displayName;let x=i.forwardRef((e,l)=>{let{className:t,...i}=e;return(0,a.jsx)(r.dk,{ref:l,className:(0,s.cn)("text-sm text-lightGray",t),...i})});x.displayName=r.dk.displayName}}]);
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.