1try{!function(){var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="26a98d84-8e34-4fd3-ac6f-bf65d6cb928f",e._sentryDebugIdIdentifier="sentry-dbid-26a98d84-8e34-4fd3-ac6f-bf65d6cb928f")}()}catch(e){}(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4947,1490],{46725:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/hr/[tenant]/hiring/[id]/offers/new",function(){return a(8381)}])},5473:function(e,t,a){"use strict";var r=a(52322),n=a(47477),s=a(59417),i=a(99603),l=a(96577),o=a.n(l),d=a(13980),c=a.n(d),u=a(2784),m=a(24886);let p=e=>e>=70?"Strong Match":e>=50?"Good Match":e>=20?"Moderate Match":"Low Match",g=e=>{var t,a;let{application:l}=e,d=(null==l?void 0:l.owner)||e.applicant,[c,g]=(0,u.useState)("#10B981");return((0,u.useEffect)(()=>{(null==l?void 0:l.owner)&&(null==l?void 0:l.jobpost)&&g((0,n.B9)(l.rating))},[l]),l||d)?(0,r.jsx)("div",{className:"w-full bg-white md:p-4 roun
1ded",children:(0,r.jsxs)("div",{className:"w-full flex flex-col md:flex-row justify-start items-center",children:[(0,r.jsxs)("div",{className:"flex w-full md:w-auto items-center",children:[(0,r.jsxs)("div",{className:"flex justify-center items-center text-center relative avatar bg-no-repeat bg-center bg-blue-50",children:[d.avatar?(0,r.jsx)(o(),{alt:d.name,layout:"fill",objectFit:"cover",src:d.avatar}):null,!d.avatar&&d.name?(0,r.jsx)("p",{className:"font-semibold",children:d.name.substr(0,1)}):null]}),(0,r.jsxs)("div",{className:"flex flex-col justify-start md:border-r border-gray-300 md:pr-4 ml-4",children:[(0,r.jsx)("h3",{className:"text-sm text-gray-500 font-semibold",children:"Name"}),(0,r.jsx)("p",{className:"text-sm text-gray-600 font-medium leading-none mt-1 whitespace-nowrap",children:d.name})]})]}),(0,r.jsxs)("div",{className:"w-full flex flex-col md:flex-row my-4 md:my-0 p-3 border md:border-0 rounded md:rounded-none",children:[(0,r.jsxs)("div",{className:"md:border-r border-gray-300 md:pr-4 md:pl-4 mb-3 md:mb-0",children:[(0,r.jsxs)("h3",{className:"text-sm text-gray-500 font-semibold",children:[(0,r.jsx)(i.G,{className:"hover:text-blue-dark mr-1",icon:s.mSY,size:"sm"}),"Email"]}),(0,r.jsx)("p",{className:"text-sm text-gray-600 font-medium leading-none mt-1",children:d.email?d.email:"unknown"})]}),(0,r.jsxs)("div",{className:"md:pr-4 md:pl-4 mb-3 md:mb-0",children:[(0,r.jsxs)("h3",{className:"text-sm text-gray-500 font-semibold",children:[(0,r.jsx)(i.G,{className:"hover:text-blue-dark mr-1",icon:s.j1w,size:"sm"}),"Phone"]}),(0,r.jsx)("p",{className:"text-sm text-gray-600 font-medium leading-none mt-1",children:d.phone?d.phone:"unknown"})]}),!!l&&(0,r.jsx)("div",{className:"flex w-auto md:ml-auto md:mr-8 my-auto",children:(0,r.jsx)("p",{className:"text-xs text-gray-700 font-medium capitalize leading-none px-3 py-[2px] rounded-full ".concat((0,n.g2)(l)),children:null==l?void 0:l.status})})]}),!!(null==l?void 0:l.rating)&&(0,r.jsxs)("div",{"aria-label":"E-score: ".concat(null==l?void 0:l.rating,"% - ").concat(p(null==l?void 0:l.rating)),className:"ml-auto text-center hidden md:flex flex-col items-center flex-shrink-0",role:"img",children:[(0,r.jsx)("div",{style:{width:60,height:60},children:(0,r.jsx)(m.Ip,{strokeWidth:14,styles:{path:{stroke:c},trail:{stroke:"#F1F6FB"},text:{fontSize:"24px",fill:"#374151",fontWeight:500},background:"#F1F6FB"},text:"".concat(null!==(t=null==l?void 0:l.rating)&&void 0!==t?t:0,"%"),value:null!==(a=l.rating)&&void 0!==a?a:0})}),(0,r.jsx)("span",{className:"text-xs text-gray-500 mt-1 font-medium",children:p(null==l?void 0:l.rating)})]})]})}):null};g.propTypes={application:c().shape({jobpost:c().any,owner:c().shape({avatar:c().any,email:c().any,name:c().shape({substr:c().func}),phone:c().any}),rating:c().any,status:c().any})},t.Z=g},8381:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return te}});var r=a(52322),n=a(16049),s=a(65232),i=a(1973),l=a(77590),o=a(18808),d=a(26790),c=a(44707),u=a(79453),m=a(84475),p=a(36160),g=a.n(p),x=a(13980),h=a.n(x),f=a(2784),y=a(5473),b=a(79337);let E={SET_STEP:"SET_STEP",COMPLETE_STEP:"COMPLETE_STEP",GO_TO_STEP:"GO_TO_STEP",SET_EMAIL_CONTENT_SOURCE:"SET_EMAIL_CONTENT_SOURCE",SET_EMAIL_CONTENT:"SET_EMAIL_CONTENT",SET_EMAIL_PLACEHOLDERS:"SET_EMAIL_PLACEHOLDERS",SET_DOCUMENT_SOURCE:"SET_DOCUMENT_SOURCE",SET_DOCUMENT_ID:"SET_DOCUMENT_ID",SET_DOCUMENT_FILE:"SET_DOCUMENT_FILE",SET_DOCUMENT_URL:"SET_DOCUMENT_URL",SET_DOC_PLACEHOLDERS:"SET_DOC_PLACEHOLDERS",SET_AI_DRAFT_FIELD:"SET_AI_DRAFT_FIELD",SET_AI_DRAFT_CONTENT:"SET_AI_DRAFT_CONTENT",SET_AI_DRAFT_CONTEXT:"SET_AI_DRAFT_CONTEXT",SET_AI_DRAFT_METADATA:"SET_AI_DRAFT_METADATA",SET_GENERATING_AI_DRAFT:"SET_GENERATING_AI_DRAFT",SET_EDITED_CONTENT:"SET_EDITED_CONTENT",SET_GENERATING_PDF:"SET_GENERATING_PDF",SET_SIGNATURE_REQUEST:"SET_SIGNATURE_REQUEST",RESET_AI_DRAFT:"RESET_AI_DRAFT",SET_AI_DRAFT_ID:"SET_AI_DRAFT_ID",SET_AI_DRAFT_STATUS:"SET_AI_DRAFT_STATUS",SET_AI_DRAFT_ERROR:"SET_AI_DRAFT_ERROR",SET_EXPIRY:"SET_EXPIRY",SET_REQUIRE_SIGNATURE:"SET_REQUIRE_SIGNATURE",SET_SIGNER_ROLE_MAPPING:"SET_SIGNER_ROLE_MAPPING",CLEAR_SIGNER_ROLE_MAPPING:"CLEAR_SIGNER_ROLE_MAPPING",SET_SIGNING_ORDER:"SET_SIGNING_ORDER",SET_SIGNATURE_EXPIRY:"SET_SIGNATURE_EXPIRY",SET_SIGNING_PRIORITY:"SET_SIGNING_PRIORITY",SET_SEND_REMINDERS:"SET_SEND_REMINDERS",SET_REMINDER_FREQUENCY:"SET_REMINDER_FREQUENCY",ADD_SIGNATURE_FIELD:"ADD_SIGNATURE_FIELD",UPDATE_SIGNATURE_FIELD:"UPDATE_SIGNATURE_FIELD",REMOVE_SIGNATURE_FIELD:"REMOVE_SIGNATURE_FIELD",SELECT_SIGNATURE_FIELD:"SELECT_SIGNATURE_FIELD",SET_SIGNATURE_FIELDS:"SET_SIGNATURE_FIELDS",SET_TERMS:"SET_TERMS",SET_ERRORS:"SET_ERRORS",CLEAR_ERROR:"CLEAR_ERROR",SET_GENERATING_EMAIL:"SET_GENERATING_EMAIL",SET_GENERATING_DOCUMENT:"SET_GENERATING_DOCUMENT",SET_UPLOADING:"SET_UPLOADING",RESET:"RESET"},v=[{id:"offer-context",label:"Offer Context"},{id:"email-content",label:"Email Content"},{id:"offer-document",label:"Offer Document"},{id:"signature-config",label:"Signature Setup"},{id:"position-fields",label:"Position Fields"},{id:"review",label:"Review & Send"}],N={start_date:"",probation_period:"",benefits:"",reporting_to:"",salary_override:"",tone:"professional",offer_expiry:""},j={currentStep:0,completedSteps:new Set,emailContentSource:"custom",emailContent:"",hasEmailPlaceholders:!1,documentSource:"ai-template",documentId:"",documentFile:null,documentUrl:"",hasDocPlaceholders:!1,aiDraftForm:{...N},aiDraftContent:"",aiDraftContextUsed:null,aiDraftMetadata:null,isGeneratingAiDraft:!1,aiDraftId:null,aiDraftStatus:"idle",aiDraftError:null,editedContent:"",isGeneratingPdf:!1,signatureRequest:null,expiry:"",requireSignature:!1,signerRoles:["candidate","hiring_manager"],signerRoleMappings:{},signingOrder:"parallel",signatureExpiry:"",signingPriority:"normal",sendReminders:!0,reminderFrequency:"weekly",signatureFields:[],selectedSignatureFieldId:null,terms:!1,errors:{},isGeneratingEmail:!1,isGeneratingDocument:!1,isUploading:!1},_=(e,t)=>
1{switch(t.type){case E.SET_STEP:return{...e,currentStep:t.payload};case E.COMPLETE_STEP:{let a=new Set(e.completedSteps);return a.add(t.payload),{...e,completedSteps:a}}case E.GO_TO_STEP:{let a=new Set(e.completedSteps);return t.payload>e.currentStep&&a.add(e.currentStep),{...e,currentStep:t.payload,completedSteps:a}}case E.SET_EMAIL_CONTENT_SOURCE:return{...e,emailContentSource:t.payload};case E.SET_EMAIL_CONTENT:return{...e,emailContent:"string"==typeof t.payload?t.payload:""};case E.SET_EMAIL_PLACEHOLDERS:return{...e,hasEmailPlaceholders:t.payload};case E.SET_DOCUMENT_SOURCE:return{...e,documentSource:t.payload,documentId:"",documentFile:null,documentUrl:""};case E.SET_DOCUMENT_ID:return{...e,documentId:t.payload};case E.SET_DOCUMENT_FILE:return{...e,documentFile:t.payload};case E.SET_DOCUMENT_URL:return{...e,documentUrl:t.payload};case E.SET_DOC_PLACEHOLDERS:return{...e,hasDocPlaceholders:t.payload};case E.SET_AI_DRAFT_FIELD:{let{field:a,value:r}=t.payload;return{...e,aiDraftForm:{...e.aiDraftForm,[a]:r}}}case E.SET_AI_DRAFT_CONTENT:return{...e,aiDraftContent:"string"==typeof t.payload?t.payload:""};case E.SET_AI_DRAFT_CONTEXT:return{...e,aiDraftContextUsed:t.payload};case E.SET_AI_DRAFT_METADATA:return{...e,aiDraftMetadata:t.payload};case E.SET_GENERATING_AI_DRAFT:return{...e,isGeneratingAiDraft:t.payload};case E.SET_AI_DRAFT_ID:return{...e,aiDraftId:t.payload};case E.SET_AI_DRAFT_STATUS:return{...e,aiDraftStatus:t.payload};case E.SET_AI_DRAFT_ERROR:return{...e,aiDraftError:t.payload};case E.SET_EDITED_CONTENT:return{...e,editedContent:"string"==typeof t.payload?t.payload:""};case E.SET_GENERATING_PDF:return{...e,isGeneratingPdf:t.payload};case E.SET_SIGNATURE_REQUEST:return{...e,signatureRequest:t.payload};case E.RESET_AI_DRAFT:return{...e,aiDraftContent:"",aiDraftContextUsed:null,aiDraftMetadata:null,editedContent:"",documentId:"",documentUrl:"",documentFile:null,signatureRequest:null,aiDraftForm:{...N},aiDraftId:null,aiDraftStatus:"idle",aiDraftError:null};case E.SET_EXPIRY:return{...e,expiry:t.payload};case E.SET_REQUIRE_SIGNATURE:return{...e,requireSignature:t.payload,...!1===t.payload&&{signerRoleMappings:{},signatureExpiry:"",signingPriority:"normal"}};case E.SET_SIGNER_ROLE_MAPPING:{let{role:a,signer:r}=t.payload;return{...e,signerRoleMappings:{...e.signerRoleMappings,[a]:r}}}case E.CLEAR_SIGNER_ROLE_MAPPING:{let a={...e.signerRoleMappings};return delete a[t.payload],{...e,signerRoleMappings:a}}case E.SET_SIGNING_ORDER:return{...e,signingOrder:t.payload};case E.SET_SIGNATURE_EXPIRY:return{...e,signatureExpiry:t.payload};case E.SET_SIGNING_PRIORITY:return{...e,signingPriority:t.payload};case E.SET_SEND_REMINDERS:return{...e,sendReminders:t.payload};case E.SET_REMINDER_FREQUENCY:return{...e,reminderFrequency:t.payload};case E.ADD_SIGNATURE_FIELD:return{...e,signatureFields:[...e.signatureFields,t.payload],selectedSignatureFieldId:t.payload.id};case E.UPDATE_SIGNATURE_FIELD:{let{fieldId:a,updates:r}=t.payload;return{...e,signatureFields:e.signatureFields.map(e=>e.id===a?{...e,...r}:e)}}case E.REMOVE_SIGNATURE_FIELD:return{...e,signatureFields:e.signatureFields.filter(e=>e.id!==t.payload),selectedSignatureFieldId:e.selectedSignatureFieldId===t.payload?null:e.selectedSignatureFieldId};case E.SELECT_SIGNATURE_FIELD:return{...e,selectedSignatureFieldId:t.payload};case E.SET_SIGNATURE_FIELDS:return{...e,signatureFields:t.payload};case E.SET_TERMS:return{...e,terms:t.payload};case E.SET_ERRORS:return{...e,errors:t.payload};case E.CLEAR_ERROR:{let a={...e.errors};return delete a[t.payload],{...e,errors:a}}case E.SET_GENERATING_EMAIL:return{...e,isGeneratingEmail:t.payload};case E.SET_GENERATING_DOCUMENT:return{...e,isGeneratingDocument:t.payload};case E.SET_UPLOADING:return{...e,isUploading:t.payload};case E.RESET:return{...j,completedSteps:new Set};default:return e}},S={INTERNAL:"internal",EXTERNAL:"external"},T={candidate:"Candidate",hiring_manager:"Hiring Manager"},R=(0,f.createContext)(null),I=e=>{let{children:t,applicationData:a}=e,[n,s]=(0,f.useReducer)(_,{...j,completedSteps:new Set,signerRoleMappings:a?{candidate:{signer_t
1ype:S.EXTERNAL,id:a.candidate_uid||"",external_name:a.candidate_name||"",external_email:a.candidate_email||""}}:{}}),i=(0,f.useMemo)(()=>({setStep:e=>s({type:E.SET_STEP,payload:e}),completeStep:e=>s({type:E.COMPLETE_STEP,payload:e}),goToStep:e=>s({type:E.GO_TO_STEP,payload:e}),nextStep:()=>{let e=Math.min(n.currentStep+1,v.length-1),t=e;n.requireSignature||3!==e&&4!==e||(t=5),s({type:E.COMPLETE_STEP,payload:n.currentStep}),s({type:E.SET_STEP,payload:t})},prevStep:()=>{let e=Math.max(n.currentStep-1,0),t=e;n.requireSignature||4!==e&&3!==e||(t=2),s({type:E.SET_STEP,payload:t})},setEmailContentSource:e=>s({type:E.SET_EMAIL_CONTENT_SOURCE,payload:e}),setEmailContent:e=>s({type:E.SET_EMAIL_CONTENT,payload:e}),setEmailPlaceholders:e=>s({type:E.SET_EMAIL_PLACEHOLDERS,payload:e}),setDocumentSource:e=>s({type:E.SET_DOCUMENT_SOURCE,payload:e}),setDocumentId:e=>s({type:E.SET_DOCUMENT_ID,payload:e}),setDocumentFile:e=>s({type:E.SET_DOCUMENT_FILE,payload:e}),setDocumentUrl:e=>s({type:E.SET_DOCUMENT_URL,payload:e}),setDocPlaceholders:e=>s({type:E.SET_DOC_PLACEHOLDERS,payload:e}),setAiDraftField:(e,t)=>s({type:E.SET_AI_DRAFT_FIELD,payload:{field:e,value:t}}),setAiDraftContent:e=>s({type:E.SET_AI_DRAFT_CONTENT,payload:e}),setAiDraftContextUsed:e=>s({type:E.SET_AI_DRAFT_CONTEXT,payload:e}),setAiDraftMetadata:e=>s({type:E.SET_AI_DRAFT_METADATA,payload:e}),setGeneratingAiDraft:e=>s({type:E.SET_GENERATING_AI_DRAFT,payload:e}),setEditedContent:e=>s({type:E.SET_EDITED_CONTENT,payload:e}),setGeneratingPdf:e=>s({type:E.SET_GENERATING_PDF,payload:e}),setSignatureRequest:e=>s({type:E.SET_SIGNATURE_REQUEST,payload:e}),resetAiDraft:()=>s({type:E.RESET_AI_DRAFT}),setAiDraftId:e=>s({type:E.SET_AI_DRAFT_ID,payload:e}),setAiDraftStatus:e=>s({type:E.SET_AI_DRAFT_STATUS,payload:e}),setAiDraftError:e=>s({type:E.SET_AI_DRAFT_ERROR,payload:e}),setExpiry:e=>s({type:E.SET_EXPIRY,payload:e}),setRequireSignature:e=>s({type:E.SET_REQUIRE_SIGNATURE,payload:e}),setSignerRoleMapping:(e,t)=>s({type:E.SET_SIGNER_ROLE_MAPPING,payload:{role:e,signer:t}}),clearSignerRoleMapping:e=>s({type:E.CLEAR_SIGNER_ROLE_MAPPING,payload:e}),setSigningOrder:e=>s({type:E.SET_SIGNING_ORDER,payload:e}),setSignatureExpiry:e=>s({type:E.SET_SIGNATURE_EXPIRY,payload:e}),setSigningPriority:e=>s({type:E.SET_SIGNING_PRIORITY,payload:e}),setSendReminders:e=>s({type:E.SET_SEND_REMINDERS,payload:e}),setReminderFrequency:e=>s({type:E.SET_REMINDER_FREQUENCY,payload:e}),addSignatureField:e=>s({type:E.ADD_SIGNATURE_FIELD,payload:e}),updateSignatureField:(e,t)=>s({type:E.UPDATE_SIGNATURE_FIELD,payload:{fieldId:e,updates:t}}),removeSignatureField:e=>s({type:E.REMOVE_SIGNATURE_FIELD,payload:e}),selectSignatureField:e=>s({type:E.SELECT_SIGNATURE_FIELD,payload:e}),setSignatureFields:e=>s({type:E.SET_SIGNATURE_FIELDS,payload:e}),setTerms:e=>s({type:E.SET_TERMS,payload:e}),setErrors:e=>s({type:E.SET_ERRORS,payload:e}),clearError:e=>s({type:E.CLEAR_ERROR,payload:e}),setGeneratingEmail:e=>s({type:E.SET_GENERATING_EMAIL,payload:e}),setGeneratingDocument:e=>s({type:E.SET_GENERATING_DOCUMENT,payload:e}),setUploading:e=>s({type:E.SET_UPLOADING,payload:e}),reset:()=>s({type:E.RESET})}),[n.currentStep,n.requireSignature]),l=(0,f.useCallback)(()=>n.signerRoles.every(e=>n.signerRoleMappings[e]),[n.signerRoles,n.signerRoleMappings]),o=(0,f.useCallback)(()=>n.signerRoles.map((e,t)=>{let a=n.signerRoleMappings[e];if(!a)return null;let r={role:e,signing_order:"sequential"===n.signingOrder?t+1:null,signer_type:a.signer_type||S.INTERNAL};return a.signer_type===S.EXTERNAL?{...r,external_email:a.external_email,external_name:a.external_name}:{...r,user_id:a.id||a.user_id}}).filter(Boolean),[n.signerRoles,n.signerRoleMappings,n.signingOrder]),d=(0,f.useCallback)(e=>({daily:1,weekly:7})[e]||7,[]),c=(0,f.useCallback)(()=>{var e;let t={content:n.emailContent,document_id:n.documentId,expiry:n.expiry,terms:n.terms,require_signature:n.requireSignature,acceptance_deadline:n.expiry};return(null===(e=n.signatureRequest)||void 0===e?void 0:e.srid)&&(t.signature_request_id=n.signatureRequest.srid),n.requireSignature&&(t.signature_settings={signers:o(),signing_order:n.signingOrder,expires_at:n.signatureExpiry||n.expiry,priority:n.signingPriority,send_reminders:n.sendReminders,reminder_frequency_days:d(n.reminderFrequency),signature_fields:n.signatureFields.map(e=>({field_type:e.field_type,semantic_type:e.semantic_type||"generic",field_label:e.field_label,required:!!e.required,signer_role:e.signer_role,page_number:e.page_number,x_position:e.x_position,y_position:e.
1y_position,width:e.width,height:e.height}))}),t},[n,o,d]),u=(0,f.useMemo)(()=>n.requireSignature?v:v.filter(e=>"signature-config"!==e.id&&"position-fields"!==e.id),[n.requireSignature]),m=(0,f.useMemo)(()=>n.requireSignature?n.currentStep:n.currentStep>=5?n.currentStep-2:n.currentStep>=3?n.currentStep-1:n.currentStep,[n.currentStep,n.requireSignature]),p=0===n.currentStep,g=n.currentStep===v.length-1,x=3===n.currentStep||4===n.currentStep,h=(0,f.useMemo)(()=>({state:n,actions:i,steps:v,visibleSteps:u,currentVisibleStepIndex:m,buildOfferData:c,buildSignersFromRoles:o,areAllRolesMapped:l,isFirstStep:p,isLastStep:g,isSignatureStep:x,applicationData:a}),[n,i,u,m,c,o,l,p,g,x,a]);return(0,r.jsx)(R.Provider,{value:h,children:t})};I.propTypes={children:h().node.isRequired,applicationData:h().shape({candidate_uid:h().string,candidate_name:h().string,candidate_email:h().string})};let w=()=>{let e=(0,f.useContext)(R);if(!e)throw Error("useJobOfferWizard must be used within a JobOfferWizardProvider");return e};var C=a(42369),D=a(56914),A=a(88510),F=a(60760),k=a(5632),O=a(62202),P=a(5120);let L=e=>!!e&&e.replace(/<[^>]*>/g,"").replace(/ /g,"").trim().length>0;P.Ryn({start_date:P.Z_8().optional().refine(e=>!e||new Date(e)>new Date,{message:"Start date must be in the future"}),probation_period:P.Z_8().max(100,"Probation period must be 100 characters or less").optional(),benefits:P.Z_8().max(2e3,"Benefits must be 2000 characters or less").optional(),reporting_to:P.Z_8().max(255,"Reporting to must be 255 characters or less").optional(),salary_override:P.Z_8().optional(),tone:P.KmV(["professional","friendly"],{errorMap:()=>({message:"Tone must be either professional or friendly"})}),offer_expiry:P.Z_8().optional()});let G=P.Ryn({emailContentSource:P.KmV(["custom","ai-template"]),emailContent:P.Z_8().refine(L,{message:"Email content is required. Write your message or load a template."})}),M=P.Ryn({documentSource:P.KmV(["upload","ai-template"]),documentId:P.Z_8().optional(),editedContent:P.Z_8().optional()}).refine(e=>"upload"===e.documentSource?!!e.documentId:!!e.documentId||!!e.editedContent&&e.editedContent.replace(/<[^>]*>/g,"").replace(/ /g," ").trim().length>=100,{message:"Please upload or generate an offer document (minimum 100 characters for AI-generated content)",path:["documentId"]}),U=P.Ryn({expiry:P.Z_8().min(1,"Expiry date is required"),requireSignature:P.O72()}
1),q=P.Ryn({signer_type:P.KmV(["internal","external"]),id:P.Z_8().optional(),user_id:P.Z_8().optional(),name:P.Z_8().optional(),email:P.Z_8().email().optional().or(P.i0J("")),external_name:P.Z_8().optional(),external_email:P.Z_8().email().optional().or(P.i0J(""))}),Z=P.Ryn({signerRoleMappings:P.IMB(P.Z_8(),q),signatureExpiry:P.Z_8().min(1,"Signature deadline is required"),signingOrder:P.KmV(["parallel","sequential"]),signingPriority:P.KmV(["low","normal","high","urgent"]),sendReminders:P.O72(),reminderFrequency:P.KmV(["daily","weekly"]).optional()}).refine(e=>Object.keys(e.signerRoleMappings).length>=2,{message:"Please configure both signer roles",path:["signerRoleMappings"]}),z=P.Ryn({terms:P.i0J(!0,{errorMap:()=>({message:"You must agree to the Terms of Service and Privacy Policy."})})}),W=function(e,t){let a,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];switch(e){case 0:a=G;break;case 1:a=M;break;case 2:a=U;break;case 3:if(!r)return{success:!0,errors:{}};a=Z;break;case 4:a=z;break;default:return{success:!0,errors:{}}}try{return a.parse(t),{success:!0,errors:{}}}catch(e){if(e instanceof P.jmq)return{success:!1,errors:(e.issues||e.errors||[]).reduce((e,t)=>(e[t.path.join(".")||"general"]=t.message,e),{})};return{success:!1,errors:{general:"Validation failed"}}}};P.Ryn({emailContent:P.Z_8().refine(L,{message:"Offer content is required. Write your offer letter or load a template."}),documentId:P.Z_8().min(1,"Offer document is required"),expiry:P.Z_8().min(1,"Expiry date is required. The candidate must accept or decline by this date."),terms:P.i0J(!0,{errorMap:()=>({message:"You must agree to the Terms of Service and Privacy Policy."})})});let B="Resolve all placeholders before continuing.",X=(e,t)=>{switch(e){case 0:{let e={};return t.aiDraftForm.start_date||(e.start_date="Proposed start date is required."),t.aiDraftForm.probation_period||(e.probation_period="Probation period is required."),t.aiDraftForm.reporting_to||(e.reporting_to="Reporting manager is required."),t.aiDraftForm.salary_override||(e.salary_override="Salary is required."),t.expiry||(e.expiry="Offer expiry date is required."),e}case 1:{let e=W(0,{emailContentSource:t.emailContentSource,emailContent:t.emailContent}).errors;return t.hasEmailPlaceholders&&(e.emailContent=B),e}case 2:{let e=W(1,{documentSource:t.documentSource,documentId:t.documentId,editedContent:t.editedContent}).errors;return t.hasDocPlaceholders&&(e.documentId=B),e}case 3:if(!t.requireSignature)return{};return W(3,{signerRoleMappings:t.signerRoleMappings,signatureExpiry:t.signatureExpiry||t.expiry,signingOrder:t.signingOrder,signingPriority:t.signingPriority,sendReminders:t.sendReminders,reminderFrequency:t.reminderFrequency},!0).errors;case 4:{if(!t.requireSignature)return{};let e=new Set(t.signatureFields.map(e=>e.signer_role)),a=t.signerRoles.filter(t=>!e.has(t));if(0===a.length)return{};let r=a.map(e=>T[e]||e).join(", ");return{signatureFields:"Add at least one signature field for: ".concat(r,".")}}case 5:return W(4,{terms:t.terms}).errors;default:return{}}};var H=a(57989),Y=a(14010),J=a(87686),V=a(59820),K=a(60418),Q=a(47477),$=a(82036);let ee={IDLE:"idle",PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed",TIMEOUT:"timeout"},et=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"".concat($.JW,"tenant/").concat((0,Q.d_)(),"/").concat(e)},ea=()=>{var e,t;let a=(0,Y.NL)(),[r,n]=(0,f.useState)(null),[s,i]=(0,f.useState)(ee.IDLE),[l,o]=(0,f.useState)(null),[d,c]=(0,f.useState)(null),[u,p]=(0,f.useState)(!1),g=(0,f.useRef)(null),x=(0,f.useRef)(null),h=(0,J.D)({mutationFn:async e=>{let{jobpostId:t,applicationId:a,start_date:r,probation_period:n,benefits:s,reporting_to:i,salary_override:l,tone:o="professional",offer_expiry:d,acceptance_deadline_date:c,signature_required:u}=e;if(!t||!a)throw Error("jobpostId and applicationId are required");let p={...r&&{start_date:r},...n&&{probation_period:n},...s&&{benefits:s},...i&&{reporting_to:i},...l&&{salary_override:l},...o&&{tone:o},...d&&{offer_expiry:d},...c&&{acceptance_deadline_date:c},...void 0!==u&&{signature_required:u}};return(await K.Z.post(et("jobposts/".concat(t,"/applications/").concat(a,"/offers/ai-draft-async")),p,{headers:(0,m.g0)({realm:"hr"})})).data}}),y=null===(e=g.current)||void 0===e?void 0:e.jobpostId,b=null===(t=g.current)||void 0===t?void 0:t.applicationId,E=(0,V.a)({queryKey:["offer-letter-draft-status",y,b,r],queryFn:async()=>{var e;let t=await K.Z.get(et("jobposts/".concat(y,"/applications/").concat(b,"/offers/drafts/").concat(r)),{headers:(0,m.g0)({realm:"hr"})});return(null===(e=t.data)||void 0===e?void 0:e.data)||t.data}
1,enabled:!!r&&!!y&&!!b&&u&&(0,Q.Xu)(),refetchInterval:e=>{var t;let a=null===(t=e.state)||void 0===t?void 0:t.data;return(null==a?void 0:a.status)!=="completed"&&(null==a?void 0:a.status)!=="failed"&&2e3},refetchIntervalInBackground:!1,meta:{expected404:!0}});(0,f.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]),(0,f.useEffect)(()=>{if(!E.data)return;let e=E.data;"completed"===e.status?(i(ee.COMPLETED),c({content:e.content,metadata:e.metadata,context_used:e.context_used}),p(!1),x.current&&clearTimeout(x.current)):"failed"===e.status?(i(ee.FAILED),o(e.error_message||"Draft generation failed"),p(!1),x.current&&clearTimeout(x.current)):"processing"===e.status?i(ee.PROCESSING):"pending"===e.status&&i(ee.PENDING)},[E.data]),(0,f.useEffect)(()=>{if(E.error){var e,t;i(ee.FAILED),o((null===(t=E.error.response)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.message)||"Failed to check draft status"),p(!1),x.current&&clearTimeout(x.current)}},[E.error]);let v=(0,f.useCallback)(async e=>{var t,r,s,l,d,u;n(null),i(ee.PENDING),o(null),c(null),g.current=e;try{let r=await h.mutateAsync(e),s=(null==r?void 0:null===(t=r.data)||void 0===t?void 0:t.odid)||(null==r?void 0:r.odid);if(!s)throw Error("No draft ID returned from server");n(s),p(!0),x.current=setTimeout(()=>{i(ee.TIMEOUT),o("Draft generation timed out. Please try again."),p(!1),a.invalidateQueries({queryKey:["offer-letter-draft-status",e.jobpostId,e.applicationId,s]})},3e5)}catch(t){i(ee.FAILED);let e="Failed to start draft generation";if(null===(s=t.response)||void 0===s?void 0:null===(r=s.data)||void 0===r?void 0:r.message)e=t.response.data.message;else if(null===(d=t.response)||void 0===d?void 0:null===(l=d.data)||void 0===l?void 0:l.errors){let a=t.response.data.errors,r=Object.keys(a)[0];r&&(null===(u=a[r])||void 0===u?void 0:u[0])&&(e=a[r][0])}else t.message&&(e=t.message);o(e)}},[h,a]),N=(0,f.useCallback)(()=>{n(null),i(ee.IDLE),o(null),c(null),p(!1),g.current=null,x.current&&clearTimeout(x.current)},[]),j=(0,f.useCallback)(()=>{g.current&&v(g.current)},[v]);return{generateDraft:v,status:s,data:d,error:l,isPolling:u,draftId:r,reset:N,retry:j,isQueuing:h.isPending,pollQuery:E}};var er=a(31948),en=a(59417),es=a(99603);let ei=e=>{let{value:t,onChange:a,customLabel:n="Write Custom",aiLabel:s="AI Draft",disabled:i=!1}=e,l=[{id:"custom",label:n,icon:en.Yai},{id:"ai-template",label:s,icon:en.Z30}];return(0,r.jsx)("div",{className:"inline-flex rounded-lg border border-gray-200 bg-gray-50 p-1",children:l.map(e=>{let n=t===e.id;return(0,r.jsxs)("button",{className:"\n flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium\n transition-all duration-200\n ".concat(n?"bg-white text-blue-600 shadow-sm":"text-gray-600 hover:text-gray-900","\n ").concat(i?"opacity-50 cursor-not-allowed":"cursor-pointer","\n "),disabled:i,onClick:()=>!i&&a(e.id),type:"button",children:[(0,r.jsx)(es.G,{className:n?"text-blue-500":"text-gray-400",icon:e.icon}),e.label]},e.id)})})};ei.propTypes={value:h().oneOf(["custom","ai-template"]).isRequired,onChange:h().func.isRequired,customLabel:h().string,aiLabel:h().string,disabled:h().bool};var el=(0,f.memo)(ei),eo=()=>{var e;let t=(0,k.useRouter)(),{state:a,actions:n,applicationData:s}=w(),[i,l]=(0,f.useState)(0),{generateDraft:o,status:d,data:c,error:u,reset:m}=ea(),p=d===ee.PENDING||d===ee.PROCESSING;(0,f.useEffect)(()=>{d===ee.COMPLETED&&(null==c?void 0:c.content)?(n.setEmailContent(c.content),l(e=>e+1),O.default.success("Email template loaded successfully!"),n.setGeneratingEmail(!1)):(d===ee.FAILED||d===ee.TIMEOUT)&&(O.default.error(u||"Failed to generate email template."),n.setGeneratingEmail(!1))},[d,c,u,n]),(0,f.useEffect)(()=>{var e;let t=!!(null===(e=a.emailContent)||void 0===e?void 0:e.includes('<span style="color: red;">['));n.setEmailPlaceholders(t)},[a.emailContent,n]);let g=(0,f.useCallback)(e=>{n.setEmailContent(e.target.value)},[n]),x=(0,f.useCallback)(e=>{n.setEmailContentSource(e),"custom"===e&&(n.setEmailContent(""),m())},[n,m]),h=(0,f.useCallback)(()=>{n.setGeneratingEmail(!0),o({jobpostId:t.query.id,applicationId:t.query.application,...a.aiDraftForm,signature_required:a.requireSignature})},[o,t.query,a.aiDraftForm,a.requireSignature,n]);return(0,f.useEffect)(()=>{"ai-template"!==a.emailContentSource||a.emailContent||a.isGeneratingEmail||d!==ee.IDLE||h()},[a.emailContentSource]),(0,r.jsxs)("div",{className:"w-full gap-4 flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Email Content"}),(0,r.jsxs)("p",{className:"text-sm text-gray-500 mt-1",children:["Compose the notification email that will be sent to"," ",(null==s?void 0:s.candidate_name)||"the candidate"]})]}),(0,r.jsx)(el,{aiLabel:"AI Draft",customLabel:"Write Custom",disabled:p,onChange:x,value:a.emailContentSource})]}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(er.ZP,{error:null===(e=a.errors)||void 0===e?void 0:e.emailContent,label:"Email Message",minHeight:300,name:"emailContent",onChange:g,placeholder:"Compose your email message to the candidate...",required:!0,toolbar:"offerLetter",value:a.emailContent},i),!!p&&(0,r.jsx)(C.J,{fixed:!1,message:d===ee.PROCESSING?"AI is generating your email template...":"Queueing email template generation..."})]}),!!a.hasEmailPlaceholders&&(0,r.jsx)(H.Z,{description:"Please review and replace all placeholder content highlighted in red before continuing."})]})]})},ed=a(71818),ec=a(95254),eu=a(62372),em=a(46362),ep=a(60315),eg=a(
17223);let ex=()=>(0,ep.default)((0,eg.default)(new Date,1),"yyyy-MM-dd"),eh=()=>(0,ep.default)(new Date,"yyyy-MM-dd");var ef=()=>{var e,t;let{state:a,actions:n}=w(),s=(0,f.useCallback)(e=>t=>{let a=t.target?t.target.value:t;n.setAiDraftField(e,a)},[n]),i=(0,f.useCallback)(e=>{n.setAiDraftField("start_date",e.target.value)},[n]),l=(0,f.useCallback)(e=>{let t=e.target.value;n.setExpiry(t),n.setAiDraftField("acceptance_deadline_date",t),a.requireSignature&&!a.signatureExpiry&&n.setSignatureExpiry(t)},[n,a.requireSignature,a.signatureExpiry]),o=(0,f.useCallback)(e=>{let t=e.target.value;n.setAiDraftField("probation_period",t?"".concat(t," months"):"")},[n]),d=(0,f.useCallback)(e=>{let t=e.target.value;n.setAiDraftField("salary_override",t?"".concat(t," per month"):"")},[n]),c=(0,f.useCallback)(e=>{n.setRequireSignature(e.target.checked),e.target.checked&&a.expiry&&n.setSignatureExpiry(a.expiry)},[n,a.expiry]),u=(null===(e=a.aiDraftForm.probation_period)||void 0===e?void 0:e.replace(" months",""))||"",m=(null===(t=a.aiDraftForm.salary_override)||void 0===t?void 0:t.replace(" per month",""))||"";return(0,r.jsxs)("div",{className:"gap-4 flex flex-col",children:[(0,r.jsx)(ed.I,{description:"These details will be used to personalize AI-generated content for both the email notification and offer letter.",icon:(0,r.jsx)(es.G,{className:"text-blue-500",icon:en.Z30})}),(0,r.jsxs)("div",{className:"gap-4 flex flex-col",children:[(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(ec.o,{helperText:"When should the candidate start?",label:"Proposed Start Date",min:ex(),name:"start_date",onChange:i,placeholder:"Select a date",required:!0,type:"date",value:a.aiDraftForm.start_date})}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(ec.o,{helperText:"The candidate must respond by this date",label:"Offer Expiry Date",min:eh(),name:"expiry",onChange:l,placeholder:"Select a date",required:!0,type:"date",value:a.expiry})})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsx)("div",{className:"w-full",children:(0,r.jsxs)("div",{className:"flex items-end gap-2",children:[(0,r.jsx)("div",{className:"flex-1",children:(0,r.jsx)(ec.o,{helperText:"Duration of the probation period",label:"Probation Period",max:24,min:1,name:"probation_period",onChange:o,placeholder:"e.g., 3",required:!0,type:"number",value:u})}),(0,r.jsx)("span",{className:"text-gray-600 pb-2 text-sm font-medium",children:"months"})]})}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(ec.o,{helperText:"e.g., John Smith, Engineering Manager",label:"Reporting To",maxLength:255,name:"reporting_to",onChange:s("reporting_to"),placeholder:"Enter manager name and title",required:!0,value:a.aiDraftForm.reporting_to})})]}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(ec.o,{helperText:"The monthly salary to include in the offer letter",label:"Salary (per month)",name:"salary_override",onChange:d,placeholder:"e.g., Ksh 40,000",required:!0,value:m})}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(eu.K,{helperText:"List key benefits like health insurance, PTO, stock options, etc.",label:"Benefits Summary",maxLength:2e3,name:"benefits",onChange:s("benef
1its"),placeholder:"Describe the benefits package...",rows:3,value:a.aiDraftForm.benefits})}),(0,r.jsx)("div",{className:"p-4 bg-gray-50 rounded-lg border border-gray-200",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)(es.G,{className:"text-blue-500 text-lg",icon:en.rxY}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-medium text-gray-900",children:"Require E-Signature"}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Both parties will sign the document electronically"})]})]}),(0,r.jsx)(em.Z,{checked:a.requireSignature,name:"requireSignature",onChange:c})]})})]})]})},ey=()=>(0,r.jsxs)("div",{className:"w-full gap-4 flex flex-col",children:[(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Offer Details"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Configure the details for this job offer. These will be used to personalize the email notification and offer letter."})]}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(ef,{})})]}),eb=a(47023),eE=a(28516),ev=a(67658);let eN=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"".concat($.JW,"tenant/").concat((0,Q.d_)(),"/").concat(e)},ej=()=>(0,J.D)({mutationFn:async e=>{let{jobpostId:t,applicationId:a,content:r,shouldBeSigned:n=!1,signatureFields:s}=e;if(!t||!a)throw Error("jobpostId and applicationId are required");if(!r||r.length<100)throw Error("Content must be at least 100 characters");let i={content:r,should_be_signed:n};return s&&s.length>0&&(i.signature_fields=s),(await K.Z.post(eN("jobposts/".concat(t,"/applications/").concat(a,"/offers/generate-document")),i,{headers:(0,m.g0)({realm:"hr"})})).data}}),e_={IDLE:"idle",PENDING:"pending",PROCESSING:"processing",COMPLETED:"completed",FAILED:"failed",TIMEOUT:"timeout"},eS=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"".concat($.JW,"tenant/").concat((0,Q.d_)(),"/").concat(e)},eT=()=>{var e,t;let a=(0,Y.NL)(),[r,n]=(0,f.useState)(null),[s,i]=(0,f.useState)(e_.IDLE),[l,o]=(0,f.useState)(null),[d,c]=(0,f.useState)(null),[u,p]=(0,f.useState)(!1),g=(0,f.useRef)(null),x=(0,f.useRef)(null),h=(0,J.D)({mutationFn:async e=>{let{jobpostId:t,applicationId:a,start_date:r,probation_period:n,benefits:s,reporting_to:i,salary_override:l,tone:o="professional",offer_expiry:d,acceptance_deadline_date:c}=e;if(!t||!a)throw Error("jobpostId and applicationId are required");let u={...r&&{start_date:r},...n&&{probation_period:n},...s&&{benefits:s},...i&&{reporting_to:i},...l&&{salary_override:l},...o&&{tone:o},...d&&{offer_expiry:d},...c&&{acceptance_deadline_date:c}};return(await K.Z.post(eS("jobposts/".concat(t,"/applications/").concat(a,"/offers/draft-document-async")),u,{headers:(0,m.g0)({realm:"hr"})})).data}}),y=null===(e=g.current)||void 0===e?void 0:e.jobpostId,b=null===(t=g.current)||void 0===t?void 0:t.applicationId,E=(0,V.a)({queryKey:["offer-draft-status",y,b,r],queryFn:async()=>{var e;let t=await K.Z.get(eS("jobposts/".concat(y,"/applications/").concat(b,"/offers/drafts/").concat(r)),{headers:(0,m.g0)({realm:"hr"})});return(null===(e=t.data)||void 0===e?void 0:e.data)||t.data},enabled:!!r&&!!y&&!!b&&u&&(0,Q.Xu)(),refetchInterval:e=>{var t;let a=null===(t=e.state)||void 0===t?void 0:t.data;return(null==a?void 0:a.status)!=="completed"&&(null==a?void 0:a.status)!=="failed"&&2e3},refetchIntervalInBackground:!1,meta:{expected404:!0}});(0,f.useEffect)(()=>()=>{x.current&&clearTimeout(x.current)},[]),(0,f.useEffect)(()=>{if(!E.data)return;let e=E.data;"completed"===e.status?(i(e_.COMPLETED),c({content:e.content,metadata:e.metadata,context_used:e.context_used}),p(!1),x.current&&clearTimeout(x.current)):"failed"===e.status?(i(e_.FAILED),o(e.error_message||"Draft generation failed"),p(!1),x.current&&clearTimeout(x.current)):"processing"===e.status?i(e_.PROCESSING):"pending"===e.status&&i(e_.PENDING)},[E.data]),(0,f.useEffect)(()=>{if(E.error){var e,t;i(e_.FAILED),o((null===(t=E.error.response)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.message)||"Failed to check draft status"),p(!1),x.current&&clearTimeout(x.current)}},[E.error]);let v=(0,f.useCallback)(async e=>{var t,r,s,l,d,u;n(null),i(e_.PENDING),o(null),c(null),g.current=e;try{let r=await h.mutateAsync(e),s=(null==r?void 0:null===(t=r.data)||void 0===t?void 0:t.odid)||
1(null==r?void 0:r.odid);if(!s)throw Error("No draft ID returned from server");n(s),p(!0),x.current=setTimeout(()=>{i(e_.TIMEOUT),o("Draft generation timed out. Please try again."),p(!1),a.invalidateQueries({queryKey:["offer-draft-status",e.jobpostId,e.applicationId,s]})},3e5)}catch(t){i(e_.FAILED);let e="Failed to start draft generation";if(null===(s=t.response)||void 0===s?void 0:null===(r=s.data)||void 0===r?void 0:r.message)e=t.response.data.message;else if(null===(d=t.response)||void 0===d?void 0:null===(l=d.data)||void 0===l?void 0:l.errors){let a=t.response.data.errors,r=Object.keys(a)[0];r&&(null===(u=a[r])||void 0===u?void 0:u[0])&&(e=a[r][0])}else t.message&&(e=t.message);o(e)}},[h,a]),N=(0,f.useCallback)(()=>{n(null),i(e_.IDLE),o(null),c(null),p(!1),g.current=null,x.current&&clearTimeout(x.current)},[]),j=(0,f.useCallback)(()=>{g.current&&v(g.current)},[v]);return{generateDraft:v,status:s,data:d,error:l,isPolling:u,draftId:r,reset:N,retry:j,isQueuing:h.isPending,pollQuery:E}};var eR=a(74618);let eI=e=>{let{file:t,onRemove:a}=e;return t?(0,r.jsx)("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"w-12 h-12 bg-red-100 rounded-lg flex items-center justify-center flex-shrink-0",children:(0,r.jsx)(es.G,{className:"text-red-600",icon:en.gSj,size:"lg"})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-medium text-gray-900 text-sm mb-1",children:t.name||"Offer Document"}),(0,r.jsxs)("div",{className:"flex items-center gap-2 text-xs text-green-600",children:[(0,r.jsx)(es.G,{icon:en.f8k}),(0,r.jsx)("span",{children:"Uploaded successfully"})]})]})]}),(0,r.jsxs)(eb.Z,{"aria-label":"Remove file",design:"secondary",onClick:a,children:[(0,r.jsx)(es.G,{icon:en.$aW}),(0,r.jsx)("span",{className:"ml-2 hidden sm:inline",children:"Remove"})]})]})}):null};eI.propTypes={file:h().shape({name:h().string}),onRemove:h().func.isRequired};var ew=(0,f.memo)(eI);let eC={[e_.PENDING]:"Queueing draft generation...",[e_.PROCESSING]:"AI is generating your offer letter..."};var eD=()=>{var e;let t=(0,k.useRouter)(),{state:a,actions:n}=w(),{mutateAsync:s,isPending:i}=(0,ev.n)(),{generateDraft:l,status:o,data:d,error:c,reset:u,retry:m}=eT(),{mutateAsync:p,isPending:g}=ej(),[x,h]=(0,f.useState)(0);(0,f.useEffect)(()=>{n.setAiDraftStatus(o)},[o,n]),(0,f.useEffect)(()=>{c&&n.setAiDraftError(c)},[c,n]),(0,f.useEffect)(()=>{if(o===e_.COMPLETED&&d){let{content:e,context_used:t,metadata:a}=d;e&&"string"==typeof e?(n.setAiDraftContent(e),n.setEditedContent(e),t&&n.setAiDraftContextUsed(t),a&&n.setAiDraftMetadata(a),h(e=>e+1),O.default.success("AI draft generated! Review and edit below.")):(console.error("Unexpected AI draft response structure:",d),O.default.error("Received invalid content from AI. Please try again."))}},[o,d,n]),(0,f.useEffect)(()=>{o===e_.FAILED&&c?O.default.error(c):o===e_.TIMEOUT&&O.default.error("Draft generation timed out. Please try again.")},[o,c]),(0,f.useEffect)(()=>()=>{u()},[u]);let y=o===e_.PENDING||o===e_.PROCESSING,b=(0,f.useMemo)(()=>(a.aiDraftContent||a.editedContent)&&!a.documentId?"edit":"generate",[a.aiDraftContent,a.editedContent,a.documentId]),E=(0,f.useCallback)(e=>{n.setDocumentSource(e),"upload"===e&&(n.resetAiDraft(),u())},[n,u]),v=(0,f.useCallback)(async e=>{let t=new FormData;t.append("file",e),t.append("document",JSON.stringify({name:e.name}));try{n.setUploading(!0);let a=await s(t);n.setDocumentId(a.did),n.setDocumentFile(e),n.setDocumentUrl(URL.createObjectURL(e)),O.default.success("Document uploaded successfully!")}catch(e){O.default.error("Failed to upload document.")}finally{n.setUploading(!1)}},[s,n]),N=(0,f.useCallback)(()=>{n.resetAiDraft(),u()},[n,u]),j=(0,f.useCallback)(()=>{l({jobpostId:t.query.id,applicationId:t.query.application,...a.aiDraftForm})},[l,t.query,a.aiDraftForm]),_=(0,f.useCallback)(()=>{m()},[m]),S=(0,f.useCallback)(e=>{n.setEditedContent(e.target.value)},[n]),T=(0,f.useCallback)(async()=>{var e,r;if((a.editedContent||"").replace(/<[^>]*>/g,"").trim().length<100){O.default.error("Content must be at least ".concat(100," characters."));return}try{n.setGeneratingPdf(!0);let r=await p({jobpostId:t.query.id,applicationId:t.query.application,content:a.editedContent,shouldBeSigned:a.requireSignature,signatureFields:[]}),s=null==r?void 0:null===(e=r.data)||void 0===e?void 0:e.document;(null==s?void 0:s.did)?(n.setDocumentId(s.did),n.setDocumentUrl(s.url),r.data.signature_request&&n.setSignatureRequest(r.data.signature_request),O.default.success("Offer document generated successfully!")):O.default.error("Document generation did not return a document. Please try again.")}catch(e){(null===(r=e.response)||void 0===r?void 0:r.status)===422?Object.values(e.response.data.errors).flat().forEac
1h(e=>O.default.error(e)):O.default.error("Failed to generate document. Please try again.")}finally{n.setGeneratingPdf(!1)}},[p,t.query,a.editedContent,a.requireSignature,n]),R=(0,f.useCallback)(()=>{n.setAiDraftContent(""),n.setEditedContent(""),n.setAiDraftContextUsed(null),n.setAiDraftMetadata(null),u()},[n,u]),I=!!a.documentId,D=!a.aiDraftContent&&!a.editedContent,A=o===e_.FAILED||o===e_.TIMEOUT,F=(0,f.useMemo)(()=>(a.editedContent||"").replace(/<[^>]*>/g,"").trim().length,[a.editedContent]),P=F<100&&F>0;return(0,r.jsxs)("div",{className:"w-full flex flex-col gap-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"Offer Document"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Upload an existing offer letter PDF or generate one using AI"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-4",children:[!!(!I&&D&&!y&&!A)&&(0,r.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,r.jsxs)("button",{className:"\n relative p-6 rounded-lg border-2 text-left transition-all\n ".concat("upload"===a.documentSource?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300 bg-white","\n "),onClick:()=>E("upload"),type:"button",children:[(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"\n w-12 h-12 rounded-lg flex items-center justify-center\n ".concat("upload"===a.documentSource?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500","\n "),children:(0,r.jsx)(es.G,{className:"text-xl",icon:en.Y9i})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-gray-900",children:"Upload PDF"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Upload your own prepared offer letter document"})]})]}),"upload"===a.documentSource&&(0,r.jsx)("div",{className:"absolute top-3 right-3 w-5 h-5 rounded-full bg-blue-500 flex items-center justify-center",children:(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",fillRule:"evenodd"})})})]}),(0,r.jsxs)("button",{className:"\n relative p-6 rounded-lg border-2 text-left transition-all\n ".concat("ai-template"===a.documentSource?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300 bg-white","\n "),onClick:()=>E("ai-template"),type:"button",children:[(0,r.jsxs)("div",{className:"flex items-start gap-4",children:[(0,r.jsx)("div",{className:"\n w-12 h-12 rounded-lg flex items-center justify-center\n ".concat("ai-template"===a.documentSource?"bg-blue-100 text-blue-600":"bg-gray-100 text-gray-500","\n "),children:(0,r.jsx)(es.G,{className:"text-xl",icon:en.Z30})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-gray-900",children:"AI Draft"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Generate a personalized offer letter using AI"}),(0,r.jsx)("span",{className:"inline-block mt-2 px-2 py-0.5 text-xs font-medium text-blue-700 bg-blue-100 rounded",children:"Recommended"})]})]}),"ai-template"===a.documentSource&&(0,r.jsx)("div",{className:"absolute top-3 right-3 w-5 h-5 rounded-full bg-blue-500 flex items-center justify-center",children:(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{clipRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",fillRule:"evenodd"})})})]})]}),!!("upload"===a.documentSource&&!I)&&(0,r.jsx)(eE.Z,{accept:"application/pdf",description:"Upload an offer document file (PDF only, max 10MB)",error:null===(e=a.errors)||void 0===e?void 0:e.document,isUploading:i||a.isUploading,label:"Offer Document",maxSize:1e7,name:"document",uploadFileHandler:v}),!!("ai-template"===a.documentSource&&!I&&D)&&(0,r.jsxs)(r.Fragment,{children:[o===e_.IDLE&&(0,r.jsxs)("div",{className:"text-center py-8 bg-gray-50 rounded-lg border-2 border-dashed border-gray-200",children:[(0,r.jsx)(es.G,{className:"text-4xl text-blue-500 mb-4",icon:en.Z30}),(0,r.jsx)("p",{className:"text-gray-600 mb-4",children:"Generate a personalized offer letter using the context configured in the previous step."}),(0,r.jsxs)(eb.Z,{design:"primary",onClick:j,size:"lg",children:[(0,r.jsx)(es.G,{className:"mr-2",icon:en.Z30}),"Generate AI Draft"]})]}),!!y&&(()=>{let e=eC[o]||"Starting draft generation...";return(0,r.jsx)("div",{className:"text-center py-8 bg-gray-50 rounded-lg border-2 border-dashed border-gray-200",children:(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsxs)("svg",{className:"animate-spin h-12 w-12 text-blue-500 mb-4",fill:"none",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",fill:"
1currentColor"})]}),(0,r.jsx)("p",{className:"text-gray-700 font-medium mb-2",children:e}),(0,r.jsx)("p",{className:"text-gray-500 text-sm",children:"This may take up to a minute. Please don't close this page."})]})})})(),!!A&&(()=>{let e=o===e_.TIMEOUT;return(0,r.jsx)("div",{className:"text-center py-8 bg-red-50 rounded-lg border-2 border-dashed border-red-200",children:(0,r.jsxs)("div",{className:"flex flex-col items-center",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-full bg-red-100 flex items-center justify-center mb-4",children:(0,r.jsx)(es.G,{className:"text-xl text-red-600",icon:en.eHv})}),(0,r.jsx)("p",{className:"text-red-700 font-medium mb-2",children:e?"Generation Timed Out":"Generation Failed"}),(0,r.jsx)("p",{className:"text-red-600 text-sm mb-4 max-w-md",children:c||"An unexpected error occurred. Please try again."}),(0,r.jsxs)(eb.Z,{design:"primary",onClick:_,children:[(0,r.jsx)(es.G,{className:"mr-2",icon:en.XSV}),"Try Again"]})]})})})()]}),!!("ai-template"===a.documentSource&&!I&&"edit"===b)&&(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(er.ZP,{label:"Offer Letter Content",minHeight:300,name:"editedContent",onChange:S,placeholder:"Your offer letter content...",toolbar:"offerLetter",value:a.editedContent},x),!!(g||a.isGeneratingPdf)&&(0,r.jsx)(C.J,{fixed:!1,message:"Generating PDF document..."})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,r.jsxs)("span",{className:P?"text-orange-600":"text-gray-500",children:[F," / ",100," minimum characters"]}),!!P&&(0,r.jsx)("span",{className:"text-orange-600",children:"Add more content to continue"})]}),(0,r.jsx)(ed.I,{description:"Review and edit the content above, then click 'Generate PDF Document' to create the final offer letter.",flex:"row"}),(0,r.jsxs)("div",{className:"flex gap-3 pt-2 justify-between",children:[(0,r.jsxs)(eb.Z,{design:"secondary",disabled:g||a.isGeneratingPdf,onClick:R,children:[(0,r.jsx)(es.G,{className:"mr-2",icon:en.go9}),"Discard draft"]}),(0,r.jsx)(eb.Z,{design:"primary",disabled:g||a.isGeneratingPdf||F<100,onClick:T,children:g||a.isGeneratingPdf?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",fill:"none",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z",fill:"currentColor"})]}),"Generating PDF..."]}):"Generate PDF Document"})]})]}),!!(I&&a.documentFile)&&(0,r.jsx)(ew,{file:a.documentFile,onRemove:N}),!!(I&&a.documentUrl&&!a.documentFile)&&(0,r.jsxs)("div",{className:"border rounded-lg overflow-hidden",children:[(0,r.jsxs)("div",{className:"bg-gray-50 px-4 py-3 border-b flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm font-medium text-gray-700",children:"Generated Offer Document"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)(eb.Z,{design:"ghost",onClick:()=>{let e=(0,eR.Ld)(a.documentUrl);e&&window.open(e,"_blank")},size:"sm",children:"Open in New Tab"}),(0,r.jsx)(eb.Z,{design:"ghost",onClick:N,size:"sm",children:"Remove"})]})]}),(0,r.jsx)("iframe",{className:"w-full min-h-[50vh]",src:(0,eR.Ld)(a.documentUrl),title:"Offer Document Preview"})]}),!!a.hasDocPlaceholders&&(0,r.jsx)(H.Z,{description:"The generated document contains placeholders that need to be filled in."})]})]})},eA=a(82781),eF=a(26472),ek=a(7325),eO=a(54691),eP=a(60141),eL=a(79735);a(10849),a(14229);var eG=a(21938),eM=a(10661);eO.default.GlobalWorkerOptions.workerSrc="/pdf.worker.min.js";let eU=(0,f.memo)(function(){return(0,r.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,r.jsx)(i.Z,{isLoading:!0,message:"Loading PDF..."})})}),eq=(0,f.memo)(function(e){let{currentPage:t,signerRoles:a,selectedRole:n,onSelectRole:s,onAddField:i}=e,l=(0,f.useCallback)(e=>{n&&i(e,n)},[n,i]);return(0,r.jsxs)("div",{className:"h-full flex flex-col",children:[(0,r.jsxs)("div",{className:"px-4 py-3 border-b bg-gray-50",children:[(0,r.jsx)("h3",{className:"font-medium text-gray-900",children:"Add Fields"}),(0,r.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Select a role, then click a field type to add"})]}),(0,r.jsxs)("div",{className:"px-4 py-3 border-b",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Signer Roles"}),(0,r.jsx)("div",{className:"space-y-1",children:a.map(e=>{let t=(0,eA.h6)(a,e),i=n===e,l=T[e]||e;return(0,r.jsxs)("button",{className:"w-full flex items-center gap-2 p-2 rounded-lg transition-colors text-left ".concat(i?"bg-gray-100 ring-1 ring-gray-300":"hover:bg-gray-50"),onClick:()=>s(e),type:"button",children:[(0,r.jsx)("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:t}}),(0,r.jsx)("span",{className:"text-sm font-medium",children:l})]},e)})})]}),(0,r.jsxs)("div",{className:"flex-1 px-4 py-3 overflow-y-auto",children:[(0,r.jsx)("h4",{className:"text-sm font-medium text-gray-700 mb-2",children:"Field Types"}),!n&&(0,r.jsxs)("div",{className:"text-center py-8 text-gray-500",children:[(0,r.jsx)(es.G,{className:"text-3xl mb-2 text-gray-300",icon:en.Ps7}),(0,r.jsx)("p",{className:"text-sm",children:"Select a signer role above to add fields"})]}),!!n&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("p",{className:"text-xs text-gray-500 mb-2",children:["Adding fields for:"," ",(0,r.jsx)("span",{className:"font-medium",style:{color:(0,eA.h6)(a,n)},children:T[n]||n})]}),eA.Z9.map(e=>(0,r.jsxs)("button",{className:"w-full flex items-center gap-3 p-3 rounded-lg border border-gray-200 hover:border-gray-300 hover:bg-gray-50 transition-colors text-left",onClick:()=>l(e.value),type:"button",children:[(0,r.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{backgroundColor:"".concat(e.color,"20")},children:(0,r.jsx)(es.G,{icon:e.icon,style:{color:e.color}})}),(0,r.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,r.jsx)("p",{className:"font-medium text-gray-900",children:e.label}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:{signature:"Full signature capture",initial:"Quick initials field",text:"Free text input",date:"Date picker field",checkbox:"Yes/No checkbox"}[e.value]||""})]}),(0,r.jsx)(es.G,{className:"text-gray-400",icon:en.r8p,size:"sm"})]},e.value))]})]}),(0,r.jsxs)("div",{className:"px-4 py-2 border-t bg-gray-50 text-center text-xs text-gray-500",children:["Fields will be added to page ",t]})]})});var eZ=(0,f.memo)(()=>{let e=(0,f.useRef)(null),t=(0,f.useRef)(null),a=(0,f.useRef)(null),{state:n,actions:s}=w(),[l,o]=(0,f.useState)(null),[d,c]=(0,f.useState)(1),[u,m]=(0,f.useState)(1),[p,g]=(0,f.useState)(eF.L8),[x,h]=(0,f.useState)(0),[y,b]=(0,f.useState)(0),[E,v]=(0,f.useState)(!1),[N,j]=(0,f.useState)(!1),[_,S]=(0,f.useState)(n.signerRoles[0]||null);(0,f.useEffect)(()=>{let a=e.current,r=t.current;if(!a)return;let n=()=>{let e=a.getBoundingClientRect();if(h(t=>t===e.width?t:e.width),r){let e=r.getBoundingClientRect();b(t=>t===e.height?t:e.height)}};n();let s=new ResizeObserver(n);return s.observe(a),r&&s.observe(r),()=>s.disconnect()},[]);let R=(0,f.useCallback)(e=>{let{numPages:t}=e;o(t),c(1)},[]),I=(0,f.useCallback)(e=>{v(!0);let t=e.getViewport({scale:1});g({width:t.width,height:t.height})},[]);(0,f.useEffect)(()=>
1{if(!E||N||0===y)return;let e=y-32,t=x-300;!(e<=0)&&!(t<=0)&&(m(Math.max(.5,Math.min(2,e/(Math.min(t,612)/p.width*p.height)))),j(!0))},[E,N,y,x,p.width,p.height]);let{renderedWidth:C,renderedHeight:D}=(0,f.useMemo)(()=>{let e=Math.min(x-300,612)*u,t=e/p.width*p.height;return{renderedWidth:e,renderedHeight:t}},[x,u,p.width,p.height]),A=(0,f.useCallback)(()=>{c(e=>Math.max(1,e-1)),s.selectSignatureField(null)},[s]),F=(0,f.useCallback)(()=>{c(e=>Math.min(l||1,e+1)),s.selectSignatureField(null)},[l,s]),k=(0,f.useCallback)(()=>{m(e=>Math.min(2,e+.1))},[]),O=(0,f.useCallback)(()=>{m(e=>Math.max(.5,e-.1))},[]),P=(0,f.useCallback)((e,t)=>{let a=28*n.signatureFields.filter(e=>e.page_number===d).length,r=(0,eA.G7)(e,t,d,{x:72+a,y:600+a});s.addSignatureField(r)},[d,n.signatureFields,s]),L=(0,f.useCallback)((e,t,a)=>{let r=(0,eF.BP)(t,a,C,D,p);s.updateSignatureField(e,{x_position:Math.max(0,r.x),y_position:Math.max(0,r.y)})},[C,D,p,s]),G=(0,f.useCallback)((e,t,a)=>{let r=(0,eF.j0)(t,a,C,D,p);s.updateSignatureField(e,{width:Math.max(20,r.width),height:Math.max(20,r.height)})},[C,D,p,s]),M=(0,f.useMemo)(()=>n.signatureFields.filter(e=>e.page_number===d),[n.signatureFields,d]),U=(0,f.useMemo)(()=>n.signatureFields.find(e=>e.id===n.selectedSignatureFieldId),[n.signatureFields,n.selectedSignatureFieldId]),q=(0,f.useCallback)(()=>s.selectSignatureField(null),[s]),Z=(0,f.useCallback)(()=>{U&&(s.removeSignatureField(U.id),s.selectSignatureField(null))},[U,s]),z=(0,f.useCallback)(e=>{U&&s.updateSignatureField(U.id,e)},[U,s]),W=(0,f.useCallback)(e=>({onClick:()=>s.selectSignatureField(e),onDelete:()=>s.removeSignatureField(e),onMove:(t,a)=>L(e,t,a),onResize:(t,a)=>G(e,t,a)}),[s,L,G]),B=(0,f.useMemo)(()=>M.map(e=>{let t=(0,eF.jt)(e.x_position,e.y_position,C,D,p),a=(0,eF.Ld)(e.width,e.height,C,D,p),r=(0,eA.h6)(n.signerRoles,e.signer_role);return{field:e,screenPos:t,screenSize:a,color:r,isSelected:e.id===n.selectedSignatureFieldId}}),[M,C,D,p,n.signerRoles,n.selectedSignatureFieldId]);return n.documentUrl?(0,r.jsxs)("div",{className:"h-full",children:[(0,r.jsxs)("div",{className:"mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold text-gray-900",children:"Add Signature Fields"}),(0,r.jsx)(ek.Z,{body:(0,r.jsxs)("ul",{className:"text-sm space-y-1.5 py-1 text-white pl-3 list-disc list-outside",children:[(0,r.jsx)("li",{className:"text-inherit",children:"Click a field type in the right panel to add it"}),(0,r.jsx)("li",{className:"text-inherit",children:"Drag fields to reposition them on the document"}),(0,r.jsx)("li",{className:"text-inherit",children:"Click a field to configure its properties"}),(0,r.jsx)("li",{className:"text-inherit",children:"Add at least one signature field for each signer (Hiring Manager and Candidate)"})]}),id:"signature-fields-tips",maxWidth:"320px"})]}),(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:"Position signature fields on the document. Each signer needs at least one signature field."})]}),(0,r.jsxs)("div",{className:"flex h-[70vh] border border-gray-200 rounded-lg overflow-hidden",ref:e,children:[(0,r.jsxs)("div",{className:"flex-1 flex flex-col bg-gray-100 overflow-hidden",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2 bg-white border-b",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{className:"p-1.5 text-gray-600 hover:bg-gray-100 rounded disabled:opacity-50",disabled:d<=1,onClick:A,type:"button",children:(0,r.jsx)(es.G,{icon:en.A35})}),(0,r.jsxs)("span",{className:"text-sm text-gray-600 min-w-[80px] text-center",children:["Page ",d," of ",l||"?"]}),(0,r.jsx)("button",{className:"p-1.5 text-gray-600 hover:bg-gray-100 rounded disabled:opacity-50",disabled:d>=(l||1),onClick:F,type:"button",children:(0,r.jsx)(es.G,{icon:en._tD})})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("button",{className:"p-1.5 text-gray-600 hover:bg-gray-100 rounded disabled:opacity-50",disabled:u<=.5,onClick:O,type:"button",children:(0,r.jsx)(es.G,{icon:en.vsP})}),(0,r.jsxs)("span",{className:"text-sm text-gray-600 min-w-[60px] text-center",children:[Math.round(100*u),"%"]}),(0,r.jsx)("button",{className:"p-1.5 text-gray-600 hover:bg-gray-100 rounded disabled:opacity-50",disabled:u>=2,onClick:k,type:"button",children:(0,r.jsx)(es.G,{icon:en.N7g})})]})]}),(0,r.jsx)("div",{className:"flex-1 overflow-auto p-4",ref:t,children:(0,r.jsxs)("div",{className:"relative mx-auto bg-white shadow-lg",ref:
1a,style:{width:C,height:D},children:[(0,r.jsx)(eP.Z,{file:n.documentUrl,loading:(0,r.jsx)(eU,{}),onLoadSuccess:R,children:(0,r.jsx)(eL.Z,{loading:"",onLoadSuccess:I,pageNumber:d,renderAnnotationLayer:!1,renderTextLayer:!1,width:C})}),!!E&&B.map(e=>{let{field:t,screenPos:a,screenSize:n,color:s,isSelected:i}=e,l=W(t.id);return(0,r.jsx)(eM.Z,{color:s,field:t,height:n.height,isSelected:i,onClick:l.onClick,onDelete:l.onDelete,onMove:l.onMove,onResize:l.onResize,width:n.width,x:a.x,y:a.y},t.id)})]})})]}),(0,r.jsxs)("div",{className:"w-72 border-l bg-white overflow-y-auto",children:[!!U&&(0,r.jsx)(eG.Z,{field:U,onClose:q,onDelete:Z,onUpdate:z,roleLabels:T,signerRoles:n.signerRoles}),!U&&(0,r.jsx)(eq,{currentPage:d,onAddField:P,onSelectRole:S,selectedRole:_,signerRoles:n.signerRoles})]})]})]}):(0,r.jsx)("div",{className:"h-[600px] flex items-center justify-center",children:(0,r.jsx)(i.Z,{description:"Please go back and generate or upload a document first.",design:"wrapped",message:"No document available"})})}),ez=a(72203),eW=a(32128),eB=a(39097),eX=a.n(eB);let eH=e=>{var t;let{documentUrl:a,documentFile:n,onEdit:l,hideHeader:o=!1}=e,d=(0,r.jsxs)(r.Fragment,{children:[!!n&&(0,r.jsx)("div",{className:"bg-gray-50 px-6 py-4 border-b border-gray-200",children:(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-lg bg-red-100 flex items-center justify-center",children:(0,r.jsx)(es.G,{className:"text-red-500",icon:en.cwv})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"font-medium text-gray-900",children:n.name}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:(t=n.size)?t<1024?"".concat(t," B"):t<1048576?"".concat((t/1024).toFixed(1)," KB"):"".concat((t/1048576).toFixed(1)," MB"):""})]})]})}),!!a&&(0,r.jsx)("div",{className:"border-t border-gray-200",children:(0,r.jsx)("iframe",{className:"w-full h-96",src:n?a:(0,eR.Ld)(a),title:"Offer Document Preview"})}),!!(!a&&!n)&&(0,r.jsx)("div",{className:"p-6",children:(0,r.jsx)(i.Z,{design:"wrapped",message:"No document preview available"})})]});return o?(0,r.jsx)("div",{className:"w-full",children:d}):(0,r.jsxs)(s.ZP,{children:[(0,r.jsx)(s.Ol,{children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-gray-900",children:"Offer Document"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"The document that will be sent with the offer"})]}),!!l&&(0,r.jsx)(eb.Z,{design:"ghost",onClick:l,size:"sm",children:"Edit"})]})}),(0,r.jsx)(s.eW,{padding:0,children:d})]})};eH.propTypes={documentFile:h().shape({name:h().string,size:h().number}),documentUrl:h().string,hideHeader:h().bool,onEdit:h().func};var eY=(0,f.memo)(eH),eJ=a(73067);let eV=e=>{let{content:t,onEdit:a,hideHeader:n=!1}=e;return(0,r.jsxs)("div",{className:"w-full",children:[!n&&(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-gray-900",children:"Email Content"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"This is the email that will be sent to the candidate"})]}),!!a&&(0,r.jsx)(eb.Z,{design:"plain",onClick:a,size:"sm",children:(0,r.jsx)(es.G,{icon:en.Xcf})})]}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)("div",{className:"p-4 bg-gray-50 rounded-lg",children:(0,r.jsx)("div",{className:"prose prose-sm max-w-none",children:(0,r.jsx)(eJ.Z,{content:t})})})})]})};eV.propTypes={content:h().string.isRequired,hideHeader:h().bool,onEdit:h().func};var eK=(0,f.memo)(eV),eQ=()=>{var e,t;let{state:a,actions:n,applicationData:s}=w(),i=(0,f.useCallback)(e=>{n.setTerms(e.target.checked)},[n]),l=(0,f.useCallback)(e=>{n.goToStep(e)},[n]),o=e=>e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):"Not set";return(0,r.jsxs)("div",{className:"space-y-6",children:[(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsx)("h3",{className:"text-lg text-gray-700",children:"Offer Summary"})}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-lg bg-blue-100 flex items-center justify-center flex-shrink-0",children:(0,r.jsx)(es.G,{className:"text-blue-500",icon:en.ILF})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Candidate"}),(0,r.jsx)("p",{className:"font-medium text-gray-900",children:(null==s?void 0:s.candidate_name)||"Unknown"}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:(null==s?void 0:s.candidate_email)||""})]})]}),(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-lg bg-orange-100 flex items-center justify-center flex-shrink-0",children:(0,r.jsx)(es.G,{className:"text-orange-500",icon:en.IV4})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Offer Expires"}),(0,r.jsx)("p",{className:"font-medium text-gray-900",children:o(a.expiry)})]})]}),(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center flex-shrink-0 ".concat(a.requireSignature?"bg-green-100":"bg-gray-100"),children:(0,r.jsx)(es.G,{className:a.requireSignature?"text-green-500":"text-gray-400",icon:en.rxY})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm text-gray-500",children:"Electronic Signature"}),(0,r.jsx)("p",{className:"font-medium text-gray-900",children:a.requireSignature?"Required":"Not Required"})]})]})]}),(0,r.jsxs)(ez.Z,{className:"relative",defaultOpen:!1,icon:en.FU$,title:"Email Content",children:[(0,r.jsx)("div",{className:"flex justify-end absolute top-0 right-0",children:(0,r.jsxs)(eb.Z,{design:"plain",onClick:()=>l(1),size:"sm",children:[(0,r.jsx)(es.G,{icon:en.Xcf}),(0,r.jsx)("span",{className:"sr-only",children:"Edit email content"})]})}),(0,r.jsx)(eK,{content:a.emailContent,hideHeader:!0})]}),(0,r.jsxs)(ez.Z,{className:"relative",defaultOpen:!1,icon:en.cwv,title:"Offer Document",children:[(0,r.jsx)("div",{className:"flex justify-end absolute top-0 right-0",children:(0,r.jsxs)(eb.Z,{design:"plain",onClick:()=>l(2),size:"sm",children:[(0,r.jsx)(es.G,{icon:en.Xcf}),(0,r.jsx)("span",{className:"sr-only",children:"Edit offer document"})]})}),(0,r.jsx)(eY,{documentFile:a.documentFile,documentUrl:a.documentUrl,hideHeader:!0})]}),!!a.requireSignature&&(0,r.jsxs)(ez.Z,{className:"relative",defaultOpen:!1,icon:en.rxY,title:"Signature Details",children:[(0,r.jsx)("div",{className:"flex justify-end absolute top-0 right-0",children:(0,r.jsxs)(eb.Z,{design:"plain",onClick:()=>l(3),size:"sm",children:[(0,r.jsx)(es.G,{icon:en.Xcf}),(0,r.jsx)("span",{className:"sr-only",children:"Edit signature details"})]})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{children:[(0,r.jsxs)("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:["Signers (","sequential"===a.signingOrder?"Sequential":"Parallel",")"]}),(0,r.jsx)("div",{className:"space-y-2",children:a.signerRoles.map((e,t)=>{let n=a.signerRoleMappings[e],s=(null==n?void 0:n.external_name)||(null==n?void 0:n.name)||"Not configured",i=(null==n?void 0:n.external_email)||(null==n?void 0:n.email)||"";return(0,r.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-gray-50 rounded-lg",children:["sequential"===a.signingOrder&&(0,r.jsx)("span",{className:"w-6 h-6 rounded-full bg-blue-100 text-blue-700 text-sm flex items-center justify-center font-medium",children:t+1}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("p",{className:"font-medium text-gray-900",children:s}),(0,r.jsxs)("p",{className:"text-sm text-gray-500",children:[T[e]," ",!!i&&"⢠".concat(i)]})]}),(0,r.jsx)(es.G,{className:"text-green-500",icon:en.f8k})]},e)})})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between pt-4 border-t border-gray-200",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Signature Deadline"}),(0,r.jsx)("span",{className:"font-medium text-gray-900",children:o(a.signatureExpiry)})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Priority"}),(0,r.jsx)("span",{className:"px-2 py-1 rounded text-xs font-medium capitalize ".concat("urgent"===(t=a.signingPriority)?"bg-red-100 text-red-700":"high"===t?"bg-orange-100 text-orange-700":"bg-gray-100 text-gray-700"),children:a.signingPriority})]}),(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-sm text-gray-600",children:"Automatic Reminders"}),(0,r.jsx)("span",{className:"font-medium text-gray-900",children:a.sendReminders?"Enabled (".concat(a.reminderFrequency,")"):"Disabled"})]})]})]}),(0,r.jsx)("div",{className:"p-4 bg-gray-50 rounded-lg",children:(0,r.jsx)(eW.J,{checked:a.terms,error:null===(e=a.errors)||void 0===e?void 0:e.terms,label:(0,r.jsxs)("span",{className:"text-sm",children:["Yes, I understand and agree to the Elevolt"," ",(0,r.jsx)("a",{className:"text-blue-600 hover:underline",href:"/terms",rel:"noopener noreferrer",target:"_blank",children:"Terms of Service"})," ","and the"," ",(0,r.jsx)(eX(),{className:"text-blue-600 hover:underline",href:"/privacy",children:"Privacy Policy"})]}),name:"terms",onChange:i})})]})},e$=a(90269),e0=a(45007),e1=a(91516);let e2=e=>
1{let{role:t,currentMapping:a,onUpdate:n,isExternal:s=!1}=e,[i,l]=(0,f.useState)(!a),o=(0,e0.v9)(e=>e.auth.user),d=(0,f.useMemo)(()=>{let e=(null==o?void 0:o.uid)||(null==o?void 0:o.id);return e?{value:e,label:o.name||o.email||"You",user:{uid:e,name:o.name||"",email:o.email||""}}:null},[o]);(0,f.useEffect)(()=>{s||a||!d||n(t,{signer_type:S.INTERNAL,id:d.user.uid,user_id:d.user.uid,name:d.user.name,email:d.user.email})},[s,d]);let c=(0,f.useCallback)(async e=>{if(!e||e.length<2)return[];try{return(await (0,e$.Qu)(e)).map(e=>({value:e.uid,label:"".concat(e.name),user:e}))}catch(e){return console.error("Failed to search users:",e),[]}},[]),u=(0,f.useCallback)(e=>{let{inputValue:t}=e;return t&&t.length>=2?"No matching team members":"Type at least 2 characters to search team members"},[]),m=(0,f.useCallback)(e=>{(null==e?void 0:e.user)&&(n(t,{signer_type:S.INTERNAL,id:e.user.uid,user_id:e.user.uid,name:e.user.name,email:e.user.email}),l(!1))},[t,n]),p=(0,f.useCallback)(e=>{n(t,{...a,signer_type:S.EXTERNAL,external_name:e.target.value})},[t,a,n]),g=(0,f.useCallback)(e=>{n(t,{...a,signer_type:S.EXTERNAL,external_email:e.target.value})},[t,a,n]),x=!!(a&&(a.external_email||a.user_id||a.id));return(0,r.jsx)("div",{className:"w-full flex flex-col",children:(0,r.jsxs)("div",{className:"w-full gap-4 flex flex-col",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"\n w-10 h-10 rounded-lg flex items-center justify-center\n ".concat(x?"bg-green-100 text-green-600":"bg-gray-100 text-gray-500","\n "),children:(0,r.jsx)(es.G,{icon:x?en.LEp:"candidate"===t?en.ILF:"hiring_manager"===t?en.Cv1:en.P88})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"font-medium text-gray-900",children:T[t]||t}),(0,r.jsx)("p",{className:"text-xs text-gray-500",children:s?"External signer":"Internal signer"})]})]}),!!(x&&!i)&&(0,r.jsx)(eb.Z,{design:"plain",onClick:()=>l(!0),size:"sm",children:(0,r.jsx)(es.G,{icon:en.Xcf})})]}),!!(s&&(i||!x))&&(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,r.jsx)(ec.o,{label:"Full Name",name:"".concat(t,"_name"),onChange:p,placeholder:"Enter full name",required:!0,value:(null==a?void 0:a.external_name)||""}),(0,r.jsx)(ec.o,{label:"Email Address",name:"".concat(t,"_email"),onChange:g,placeholder:"Enter email address",required:!0,type:"email",value:(null==a?void 0:a.external_email)||""})]}),!!(s&&x&&!i)&&(0,r.jsxs)("div",{className:"bg-gray-50 rounded-lg p-3",children:[(0,r.jsx)("p",{className:"font-medium text-gray-900",children:a.external_name}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:a.external_email})]}),!!(!s&&(i||!x))&&(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-1",htmlFor:"".concat(t,"_user_select"),children:"Select Company Representative"}),(0,r.jsx)(e1.Z,{className:"c-react-select",classNamePrefix:"crs",defaultOptions:d?[d]:[],inputId:"".concat(t,"_user_select"),isClearable:!0,isSearchable:!0,loadOptions:c,name:"".concat(t,"_user"),noOptionsMessage:u,onChange:m,placeholder:"Search by name or email...",value:(null==a?void 0:a.user_id)?{value:a.user_id,label:"".concat(a.name)}:null})]}),!!(!s&&x&&!i)&&(0,r.jsxs)("div",{className:"bg-gray-50 rounded-lg p-3",children:[(0,r.jsx)("p",{className:"font-medium text-gray-900",children:a.name}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:a.email})]})]})})};e2.propTypes={role:h().string.isRequired,currentMapping:h().shape({signer_type:h().string,external_name:h().string,external_email:h().string,user_id:h().string,id:h().string,name:h().string,email:h().string}),onUpdate:h().func.isRequired,isExternal:h().bool};var e4=(0,f.memo)(e2),e3=()=>{var e,t;let{state:a,actions:n,applicationData:s}=w(),i=(0,f.useCallback)((e,t)=>{n.setSignerRoleMapping(e,t)},[n]);return(0,r.jsxs)("div",{className:"w-full gap-6 flex flex-col",children:[(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg text-gray-700",children:"Candidate"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"The job offer will be sent to this candidate for signature"})]}),(0,r.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4 mt-3",children:[(0,r.jsx)("p",{className:"font-medium text-gray-900",children:(null===(e=a.signerRoleMappings.candidate)||void 0===e?void 0:e.external_name)||(null==s?void 0:s.candidate_name)}),(0,r.jsx)("p",{className:"text-sm text-gray-500",children:(null===(t=a.signerRoleMappings.candidate)||void 0===t?void 0:t.external_email)||(null==s?void 0:s.candidate_email)})]})]}),(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"text-lg text-gray-700",children:"Company Signer"}),(0,r.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Select who will sign on behalf of the company"})]}),(0,r.jsx)("div",{className:"w-full",children:(0,r.jsx)(e4,{currentMapping:a.signerRoleMappings.hiring_manager,isExternal:!1,onUpdate:i,role:"hiring_manager"})})]})]})};let e5=e=>{let{onNext:t,onSubmit:a,isSubmitting:n}=e,{actions:s,isFirstStep:i,isLastStep:l}=w();return(0,r.jsxs)("div",{className:"flex justify-between items-center pt-6 border-t border-gray-200 mt-6",children:[(0,r.jsx)("div",{children:!i&&(0,r.jsx)(eb.Z,{design:"secondary",disabled:n,onClick:()=>{s.setErrors({}),s.prevStep()},type:"button",children:"Back"})}),(0,r.jsxs)("div",{className:"flex gap-3",children:[!l&&(0,r.jsx)(eb.Z,{disabled:n,onClick:t,type:"button",children:"Continue"}),!!l&&(0,r.jsx)(eb.Z,{disabled:n,isLoading:n,onClick:a,type:"button",children:"Send Offer"})]})]})};e5.propTypes={onNext:h().func,onSubmit:h().func,isSubmitting:h().bool};var e8=(0,f.memo)(e5);let e6=e=>{let{tenantName:t,jobpostId:a}=e,n=(0,k.useRouter)(),{state:s,actions:i,visibleSteps:l,currentVisibleStepIndex:o,buildOfferData:d}=w(),{mutateAsync:c,isPending:u}=(0,D.G$)(),m=Object.keys(s.errors).length>0,p=(0,f.useCallback)(()=>{let e=X(s.currentStep,s);if(Object.keys(e).length>0){i.setErrors(e);return}i.setErrors({}),i.nextStep()},[s,i]),g=(0,f.useCallback)(async()=>{let e=X(5,s);if(Object.keys(e).length>0){i.setErrors(e);return}i.setErrors({});try{let e=d();await c({jobpostId:a,applicationId:n.query.application,data:e}),O.default.success("Offer sent successfully!"),n.push("/hr/".concat(t,"/hiring/").concat(a,"/offers"))}catch(t){var r,l,o,u;let e=null==t?void 0:null===(l=t.response)||void 0===l?void 0:null===(r=l.data)||void 0===r?void 0:r.errors;if(e){let a=Object.entries(e).reduce((e,t)=>
1{let[a,r]=t;return e[a]=Array.isArray(r)?r[0]:r,e},{});i.setErrors(a),O.default.error(t.response.data.message||"Please correct the highlighted errors and try again.")}else O.default.error((null==t?void 0:null===(u=t.response)||void 0===u?void 0:null===(o=u.data)||void 0===o?void 0:o.message)||"An error occurred while sending the offer.")}},[s,i,d,c,n,t,a]);return(0,r.jsxs)("div",{className:"w-full mx-auto",children:[!!u&&(0,r.jsx)(C.J,{fixed:!1}),(0,r.jsx)("div",{className:"mb-6 w-full",children:(0,r.jsx)(A.Z,{ariaLabel:"Offer wizard progress",completedSteps:s.completedSteps,currentStep:o,showStepNumbers:!0,steps:l})}),!!m&&(0,r.jsx)(F.Z,{errors:s.errors,title:"Please correct the following before continuing:"}),(0,r.jsx)("div",{className:"mb-6 w-full flex flex-col gap-4",children:(()=>{switch(s.currentStep){case 0:return(0,r.jsx)(ey,{});case 1:return(0,r.jsx)(eo,{});case 2:return(0,r.jsx)(eD,{});case 3:return(0,r.jsx)(e3,{});case 4:return(0,r.jsx)(eZ,{});case 5:return(0,r.jsx)(eQ,{});default:return null}})()}),(0,r.jsx)(e8,{isSubmitting:u,onNext:p,onSubmit:g})]})};e6.propTypes={tenantName:h().string.isRequired,jobpostId:h().string.isRequired};let e7=e=>{let{tenantName:t,jobpostId:a,applicationData:n}=e;return(0,r.jsx)(I,{applicationData:n,children:(0,r.jsx)(e6,{jobpostId:a,tenantName:t})})};e7.propTypes={tenantName:h().string.isRequired,jobpostId:h().string.isRequired,applicationData:h().shape({candidate_name:h().string,candidate_email:h().string})};let e9=e=>{var t,a,m,p,x,h,f;let{applicationId:E,user:v,tenantName:N,jobpostId:j}=e,{data:_,isLoading:S}=(0,d.bL)({applicationId:E}),{data:{data:T}={},isLoading:R,error:I}=(0,c.vl)({id:j,realm:"hr",enabled:!!j}),w=[{href:"/hr/".concat(N,"/hiring/"),name:"Hiring",nodeType:"Link"},{href:"/hr/".concat(N,"/hiring/").concat(null==_?void 0:null===(t=_.jobpost)||void 0===t?void 0:t.jid),name:(0,l.excerpt)(null==_?void 0:null===(a=_.jobpost)||void 0===a?void 0:a.title,40),nodeType:"Link"},{href:"/hr/".concat(N,"/hiring/").concat(null==_?void 0:null===(m=_.jobpost)||void 0===m?void 0:m.jid,"/offers"),name:"Offers",nodeType:"a"},{href:"/hr/".concat(N,"/hiring/").concat(null==_?void 0:null===(p=_.jobpost)||void 0===p?void 0:p.jid,"/offers/new"),name:"Create",nodeType:"a"}];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(b.Z,{title:"".concat((0,l.kC)((0,l.parseUnderScore)(N))," - New Offer")}),(0,r.jsx)("div",{className:"container mx-auto px-6 md:px-8 lg:px-12",children:(0,r.jsx)("div",{className:"w-full flex justify-start",children:(0,r.jsx)(n.Z,{home:"/hr/".concat(N,"/"),links:w})})}),(0,r.jsx)("div",{className:"container mx-auto px-6 md:px-8 lg:px-12",children:(0,r.jsx)(u.Z,{canAccess:o.dg,deniedDescription:"Job offers are available for approved job posts.",deniedMessage:"Offer unavailable",isError:!!I,isLoading:R,post:T,tenantName:N,children:(0,r.jsxs)("div",{className:"w-full mb-2 flex flex-col gap-4",children:[!g()(_)&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(y.Z,{application:_}),(0,r.jsx)(s.ZP,{heading:"Create & Send a Job Offer",children:(0,r.jsx)(s.eW,{children:(0,r.jsx)(e7,{applicationData:{candidate_uid:null==_?void 0:null===(x=_.owner)||void 0===x?void 0:x.uid,candidate_name:null==_?void 0:null===(h=_.owner)||void 0===h?void 0:h.name,candidate_email:null==_?void 0:null===(f=_.owner)||void 0===f?void 0:f.email},authUser:v,jobpostId:j,tenantName:N})})})]}),g()(_)&&(0,r.jsx)("div",{className:"w-full flex flex-col bg-white p-4 rounded",children:(0,r.jsx)("div",{className:"w-full bg-blue-50 p-4 rounded border border-dashed",children:(0,r.jsx)(i.Z,{isLoading:S,message:"Application not found!"})})})]})})})]})};e9.propTypes={applicationId:h().number,jobpostId:h().any,tenantName:h().string,user:h().object},e9.getInitialProps=async e=>{let t=e.query.id,a=e.query.application,r=e.query.tenant;return t&&r&&a||!e.req?{applicationId:a,tenantName:r,jobpostId:t}:{notFound:!0}};var te=(0,m.withAuthSync)(e9)},7223:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return i}});var r=a(4254),n=a(49435),s=a(4895);function i(e,t){(0,s.Z)(2,arguments);var a=(0,n.default)(e),i=(0,r.Z)(t);return isNaN(i)?new Date(NaN):(i&&a.setDate(a.getDate()+i),a)}},72203:function(e,t,a){"use strict";var r=a(52322),n=a(2784),s=a(2369),i=a(92942),l=a(12524),o=a.n(l),d=a(13980),c=a.n(d),u=a(47023),m=a(76467);let p=e=>{let{title:t,icon:a,itemCount:l=0,isEmpty:d=!1,open:c,defaultOpen:p=!1,onToggle:g,onAddClick:x,loading:h=!1,children:f,className:y=""}
1=e,b=(0,n.useId)(),E=void 0!==c,[v,N]=(0,n.useState)(p),j=E?c:v,_=(0,n.useCallback)(()=>{E||N(e=>!e),null==g||g()},[E,g]);return(0,r.jsxs)("div",{className:o()("accordion-section",{"accordion-section--empty":d,"accordion-section--expanded":j},y),children:[(0,r.jsxs)("button",{"aria-controls":"".concat(b,"-content"),"aria-expanded":j,className:o()("accordion-header",{"accordion-header--expanded":j}),id:"".concat(b,"-button"),onClick:_,type:"button",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[(0,r.jsx)(i.FontAwesomeIcon,{className:o()("accordion-chevron text-gray-500",{"accordion-chevron--expanded":j}),icon:s._tD,size:"sm"}),!!a&&(0,r.jsx)(i.FontAwesomeIcon,{className:"text-blue-600",icon:a,size:"sm"}),(0,r.jsx)(m.Z,{className:"!text-base",color:"text-gray-800",variant:"sectionHeader",children:t}),l>0&&(0,r.jsx)("span",{"aria-label":"".concat(l," items"),className:o()("accordion-badge",{"accordion-badge--filled":!d,"accordion-badge--empty":d}),children:l})]}),!!(x&&j)&&(0,r.jsx)("div",{children:(0,r.jsx)(u.Z,{"aria-label":"Add",beforeIcon:(0,r.jsx)(i.FontAwesomeIcon,{className:"text-xs sm:mr-2",icon:s.r8p,size:"xs"}),className:"ml-2",design:"secondary",onClick:e=>{e.stopPropagation(),x()},children:(0,r.jsx)("span",{className:"hidden sm:inline text-sm leading-none",children:"Add"})})})]}),!!j&&(0,r.jsx)("div",{"aria-labelledby":"".concat(b,"-button"),className:"accordion-content",id:"".concat(b,"-content"),role:"region",children:(0,r.jsx)("div",{className:"p-2 sm:p-4 bg-white rounded-b-lg",children:f})})]})};p.propTypes={title:c().string.isRequired,icon:c().object,itemCount:c().number,isEmpty:c().bool,open:c().bool,defaultOpen:c().bool,onToggle:c().func,onAddClick:c().func,loading:c().bool,children:c().node.isRequired,className:c().string},t.Z=p},71818:function(e,t,a){"use strict";a.d(t,{I:function(){return o}});var r=a(52322),n=a(92942),s=a(2369);a(2784);var i=a(13980),l=a.n(i);let o=e=>{let{title:t,description:a,button:i=null,flow:l="y",...o}=e;return(0,r.jsxs)("div",{...o,className:"w-full bg-blue-100 border border-blue-300 p-3 rounded flex flex-col md:flex-row md:justify-between items-center relative",children:[(0,r.jsxs)("div",{className:"flex justify-start flex-col",children:[(0,r.jsx)("span",{className:"absolute -top-2 -left-1",children:(0,r.jsx)(n.FontAwesomeIcon,{className:"text-blue-400 text-lg",icon:s.RLE,size:"1x"})}),!!t&&(0,r.jsx)("h6",{className:"text-center md:text-left font-semibold text-gray-800 md:leading-none mb-2",children:t}),(0,r.jsx)("p",{className:"text-center md:text-left font-normal leading-tight text-gray-800",children:a}),"y"===l&&i?(0,r.jsx)("div",{className:"mt-3",children:i}):null]}),"x"===l&&i?(0,r.jsx)("div",{className:"mt-3 md:mt-auto",children:i}):null]})};o.propTypes={title:l().string,description:l().string,button:l().element,flow:l().string},t.Z=o},57989:function(e,t,a){"use strict";a.d(t,{W:function(){return o}});var r=a(52322),n=a(2369),s=a(92942),i=a(13980),l=a.n(i);a(2784);let o=e=>{let{title:t,description:a,button:i=null,flow:l="y",...o}=e;return(0,r.jsxs)("div",{...o,className:"w-full bg-red-100 border border-red-300 p-3 rounded flex flex-col md:flex-row md:justify-between items-center relative",children:[(0,r.jsxs)("div",{className:"flex justify-start flex-col",children:[(0,r.jsx)("span",{className:"absolute -top-2 -left-1",children:(0,r.jsx)(s.FontAwesomeIcon,{className:"text-red-600 text-lg",icon:n.RLE,size:"1x"})}),!!t&&(0,r.jsx)("h6",{className:"text-center md:text-left font-semibold text-gray-800 md:leading-none mb-2",children:t}),(0,r.jsx)("p",{className:"text-center md:text-left font-normal leading-tight text-gray-800",children:a}),!!("y"===l&&i)&&(0,r.jsx)("div",{className:"mt-3",children:i})]}),!!("x"===l&&i)&&(0,r.jsx)("div",{className:"mt-3 md:ml-2 md:mt-auto",children:i})]})};o.propTypes={title:l().string,description:l().string,button:l().element,flow:l().string},t.Z=o},46362:function(e,t,a){"use strict";a.d(t,{Z:function(){return d}});var r=a(52322),n=a(2784),s=a(13980),i=a.n(s),l=a(12524),o=a.n(l);let d=e=>{let{name:t,checked:a=!1,onChange:s,disabled:i=!1,size:l="md",label:d,labelPosition:c="right",description:u,error:m,className:p,inputClassName:g,labelClassName:x,ariaLabel:h,ariaDescribedBy:f,showIcons:y=!1,checkedIcon:b,uncheckedIcon:E}=e,v=(0,n.useId)(),N=u?"".concat(v,"-description"):void 0,j=m?"".concat(v,"-error"):void 0,_=(0,n.useCallback)(e=>{i||s({...e,target:{...e.target,name:t,checked:!a,type:"checkbox"}})},[i,t,a,s]),S=(0,n.useCallback)(e=>
1{(" "===e.key||"Enter"===e.key)&&(e.preventDefault(),_(e))},[_]),T={xs:{track:"w-7 h-3.5",thumb:"w-3 h-3",thumbTranslate:a?"translate-x-[14px]":"translate-x-0.5",iconSize:"text-[8px]"},sm:{track:"w-9 h-[18px]",thumb:"w-4 h-4",thumbTranslate:a?"translate-x-[18px]":"translate-x-0.5",iconSize:"text-[10px]"},md:{track:"w-11 h-[22px]",thumb:"w-5 h-5",thumbTranslate:a?"translate-x-[22px]":"translate-x-0.5",iconSize:"text-xs"},lg:{track:"w-[52px] h-[26px]",thumb:"w-6 h-6",thumbTranslate:a?"translate-x-[26px]":"translate-x-0.5",iconSize:"text-sm"}},R=T[l]||T.md,I=o()("relative inline-flex items-center rounded-full cursor-pointer","transition-colors duration-200 ease-in-out","focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-300 focus-visible:ring-offset-1",R.track,{"bg-gray-300 hover:bg-gray-400":!a&&!i,"bg-blue hover:bg-blue-dark":a&&!i,"bg-gray-200":!a&&i,"bg-blue-200":a&&i,"cursor-not-allowed opacity-50":i,"ring-1 ring-red-400":m},g),w=o()("absolute bg-white rounded-full shadow-sm border","transition-transform duration-200 ease-in-out",R.thumb,R.thumbTranslate,{"border-gray-200":!a,"border-blue":a&&!i,"border-blue-200":a&&i}),C=o()("text-gray-700 font-medium cursor-pointer select-none",{"text-xs":"xs"===l,"text-sm":"sm"===l||"md"===l,"text-base":"lg"===l,"cursor-not-allowed opacity-50":i},x),D=o()("inline-flex items-center gap-2",{"flex-row-reverse":"left"===c},p);return(0,r.jsxs)("div",{className:"inline-flex flex-col",children:[(0,r.jsxs)("label",{className:D,htmlFor:t,children:[(0,r.jsxs)("button",{"aria-checked":a,"aria-describedby":f||N||j,"aria-disabled":i,"aria-label":h||d,className:I,disabled:i,id:t,name:t,onClick:_,onKeyDown:S,role:"switch",type:"button",children:[!!y&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:o()("absolute left-1 transition-opacity duration-200",R.iconSize,{"opacity-100":a,"opacity-0":!a}),children:b||(0,r.jsx)("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 12 12",children:(0,r.jsx)("path",{d:"M3.707 5.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4a1 1 0 00-1.414-1.414L5 6.586 3.707 5.293z"})})}),(0,r.jsx)("span",{className:o()("absolute right-1 transition-opacity duration-200",R.iconSize,{"opacity-0":a,"opacity-100":!a}),children:E||(0,r.jsx)("svg",{className:"w-3 h-3 text-gray-400",fill:"currentColor",viewBox:"0 0 12 12",children:(0,r.jsx)("path",{d:"M4 4l4 4m0-4l-4 4",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"2"})})})]}),(0,r.jsx)("span",{className:w})]}),!!d&&(0,r.jsx)("span",{className:C,children:d})]}),!!u&&(0,r.jsx)("span",{className:"text-gray-500 text-sm mt-1",id:N,children:u}),!!m&&(0,r.jsx)("span",{className:"text-red-400 text-xs mt-1",id:j,children:m})]})};d.propTypes={name:i().string.isRequired,checked:i().bool,onChange:i().func.isRequired,disabled:i().bool,size:i().oneOf(["xs","sm","md","lg"]),label:i().string,labelPosition:i().oneOf(["left","right"]),description:i().string,error:i().string,className:i().string,inputClassName:i().string,labelClassName:i().string,ariaLabel:i().string,ariaDescribedBy:i().string,showIcons:i().bool,checkedIcon:i().node,uncheckedIcon:i().node}},26790:function(e,t,a){"use strict";a.d(t,{Kr:function(){return u},N:function(){return m},bL:function(){return c}});var r=a(59820),n=a(87686),s=a(60418),i=a(62202),l=a(82036),o=a(84475),d=a(53651);let c=e=>{let{applicationId:t,includeAI:a=!1}=e;return(0,r.a)({enabled:!!t,queryKey:["applications",t,{includeAI:a}],queryFn:async()=>{var e;let r=new URLSearchParams;a&&r.append("include_ai","true");let n="".concat(l.JW,"applications/").concat(t).concat(r.toString()?"?".concat(r.toString()):"");return null===(e=(await s.Z.get(n,{headers:{...(0,o.g0)({realm:"hr"})}})).data)||void 0===e?void 0:e.data}})},u=()=>({updateApplication:(0,n.D)({mutationFn:async e=>{let{id:t,status:a}=e;return(await s.Z.post("".concat(l.JW,"applications/").concat(t),{status:a},{headers:{...(0,o.g0)({realm:"hr"})}})).data}}),createApplication:(0,n.D)({mutationFn:async e=>{let{jobPostId:t,data:a}=e;return(await s.Z.post("".concat(l.JW,"jobposts/").concat(t,"/applications"),a,{headers:{...(0,o.g0)({realm:"hr"})}})).data},onSuccess:()=>{i.default.success("Application created successfully!")},onError:()=>{i.default.error("Failed to create application!")}})}),m=e=>{let{jobPostId:t,enabled:a,query:n,includeAI:i=!1,page:c=1,perPage:u=15,status:m,search:p,messaged:g}=e,x=new URLSearchParams;c>1&&x.append("page",c.toString()),15!==u&&x.append("per_page",u.toString()),m&&x.append("status",m),p&&x.append("search",p),g&&x.append("messaged","true"),i&&x.append("include_ai","true"),(null==n?void 0:n.orderBy)&&x.append("orderBy",n.orderBy),(null==n?void 0:n.direction)&&x.append("direction",n.direction);let h=x.toString();return(0,r.a)({enabled:a,queryKey:["applications",t,{page:c,perPage:u,status:m,search:p,messaged:g,includeAI:i,...n}],placeholderData:(0,d.g)(t),queryFn:async()=>{let e="".concat(l.JW,"jobposts/").concat(t,"/applications").concat(h?"?".concat(h):"");return(await s.Z.get(e,{headers:{...(0,o.g0)({realm:"hr"})}})).data}})}},56914:function(e,t,a){"use strict";a.d(t,{BX:function(){return u},CY:function(){return m},G$:function(){return g},Wf:function(){return x},f3:function(){return p}});var r=a(59820),n=a(87686),s=a(60418),i=a(47477),l=a(82036),o=a(84475),d=a(6387);let c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"".concat(l.JW,"tenant/").concat((0,i.d_)(),"/").concat(e)},u=e=>{let{jobpostId:t,offerId:a,enabled:n=!0,hasTenant:u=!0,pollUntilSettled:m=!1}=e,p=(0,d.s)(),g=(0,r.a)({queryKey:["offer",t,a],queryFn:async()=>{let e=u?c("jobposts/".concat(t,"/offers/").concat(a)):"".concat(l.JW,"user/offers/").concat(a),r=await s.Z.get(e,{headers:(0,o.g0)({realm:"hr"})});if(u){var n;return null===(n=r.data)||void 0===n?void 0:n.data}return r.data},enabled:!!(t||a)&&n&&(!u||(0,i.Xu)())&&p,refetchInterval:e=>{var t;if(!m)return!1;let a=null===(t=e.state.data)||void 0===t?void 0:t.status;return(!a||"new"===a)&&3e3}
1,refetchIntervalInBackground:!1});return{...g,isLoading:g.isLoading||!p&&!!(t||a)&&n}},m=()=>(0,n.D)({mutationFn:async e=>{let{jobpostId:t,offerId:a}=e;return(await s.Z.post(c("jobposts/".concat(t,"/offers/").concat(a)),{status:"withdrawn"},{headers:(0,o.g0)({realm:"hr"})})).data}}),p=()=>(0,n.D)({mutationFn:async e=>{let{jobpostId:t,offerId:a}=e;return(await s.Z.delete(c("jobposts/".concat(t,"/offers/").concat(a)),{headers:(0,o.g0)({realm:"hr"})})).data}}),g=()=>(0,n.D)({mutationFn:async e=>{let{jobpostId:t,applicationId:a,data:r}=e;return(await s.Z.post(c("jobposts/".concat(t,"/applications/").concat(a,"/offers")),r,{headers:(0,o.g0)({realm:"hr"})})).data}}),x=e=>{let{jobpostId:t,enabled:a=!0}=e;return(0,r.a)({queryKey:["offers",t],queryFn:async()=>{var e;return null===(e=(await s.Z.get(c("jobposts/".concat(t,"/offers")),{headers:(0,o.g0)({realm:"hr"})})).data)||void 0===e?void 0:e.data},enabled:!!t&&a&&(0,i.Xu)()})}},73067:function(e,t,a){"use strict";var r=a(52322),n=a(12524),s=a.n(n),i=a(19450),l=a(73199),o=a(13980),d=a.n(o),c=a(2784),u=a(12307);i.Z.isSupported&&(i.Z.removeHooks("afterSanitizeAttributes"),i.Z.addHook("afterSanitizeAttributes",e=>{"A"===e.tagName&&"function"==typeof e.hasAttribute&&e.hasAttribute("target")&&"_self"!==e.getAttribute("target")&&e.setAttribute("rel","noopener noreferrer nofollow")}));let m=e=>{let{content:t="",className:a=null,as:n="div",size:o="sm",...d}=e,u=(0,c.useMemo)(()=>{if(!t)return null;let e=i.Z.sanitize(t,{ALLOWED_TAGS:["p","br","strong","em","u","s","ul","ol","li","a"],ALLOWED_ATTR:["href","target","rel"]});return(0,l.ZP)(e)},[t]);if(!t)return null;let m=s()("html-content","prose prose-".concat(o," prose-gray max-w-none"),a);return(0,r.jsx)(n,{className:m,...d,children:u})};m.propTypes={content:d().string,className:d().string,as:d().elementType},t.Z=e=>(0,r.jsx)(u.Z,{children:(0,r.jsx)(m,{...e})})},79453:function(e,t,a){"use strict";var r=a(52322),n=a(13980),s=a.n(n),i=a(47023),l=a(1973);let o=e=>{let{tenantName:t,post:a,isLoading:n,isError:s,canAccess:o,deniedMessage:d,deniedDescription:c,children:u}=e;return n?(0,r.jsx)("div",{className:"w-full my-8",children:(0,r.jsx)(l.Z,{design:"wrapped",isLoading:!0,message:"Loading job post"})}):s?(0,r.jsx)("div",{className:"w-full my-8",children:(0,r.jsx)(l.Z,{description:"Something went wrong on our end. Please refresh the page to try again.",design:"wrapped",isError:!0,message:"Couldn't load this job post"})}):(null==a?void 0:a.jid)?o(a)?u:(0,r.jsx)("div",{className:"w-full my-8",children:(0,r.jsx)(l.Z,{action:(0,r.jsx)(i.Z,{design:"primary",href:"/hr/".concat(t,"/hiring/").concat(a.jid),children:"Back to job post"}),description:c,design:"wrapped",message:d})}):(0,r.jsx)("div",{className:"w-full my-8",children:(0,r.jsx)(l.Z,{action:(0,r.jsx)(i.Z,{design:"secondary",href:"/hr/".concat(t,"/hiring/"),children:"Back to hiring"}),description:"We couldn't find this job post. It may have been removed, or the link may be incorrect.",design:"wrapped",message:"Job post not found"})})};o.propTypes={tenantName:s().string,post:s().shape({jid:s().string,status:s().string}),isLoading:s().bool.isRequired,isError:s().bool.isRequired,canAccess:s().func.isRequired,deniedMessage:s().string.isRequired,deniedDescription:s().string.isRequired,children:s().node},t.Z=o},60760:function(e,t,a){"use strict";var r=a(52322),n=a(2369),s=a(92942),i=a(13980),l=a.n(i),o=a(2784);let d=e=>{let{errors:t,title:a="Please correct the following:"}=e,i=(0,o.useMemo)(()=>Object.entries(t).filter(e=>{let[,t]=e;return t}),[t]);return 0===i.length?null:(0,r.jsx)("div",{"aria-labelledby":"validation-summary-title",className:"bg-red-50 border border-red-200 rounded-lg p-4 mb-6",role:"alert",children:(0,r.jsxs)("div",{className:"flex items-start gap-3",children:[(0,r.jsx)(s.FontAwesomeIcon,{className:"text-red-500 mt-0.5",icon:n.eHv}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-red-800 m-0 mb-2",id:"validation-summary-title",children:a}),(0,r.jsx)("ul",{className:"list-disc list-inside space-y-1 m-0 p-0",children:i.map(e=>{let[t,a]=e;return(0,r.jsx)("li",{className:"text-sm text-red-700",children:a},t)})})]})]})})};d.propTypes={errors:l().object.isRequired,title:l().string},d.defaultProps={title:"Please correct the following:"},t.Z=d},31948:function(e,t,a){"use strict";var r=a(52322);a(2784);var n=a(25237),s=a.n(n),i=a(13980),l=a.n(i);let o=s()(()=>Promise.all([a.e(4004),a.e(6615),a.e(9450),a.e(8149),a.e(7413)]).then(a.bind(a,27413)),{loadableGenerated:{webpack:()=>[27413]},ssr:!1,loading:()=>(0,r.jsx)("div",{className:"rich-text-editor-loading",children:(0,r.jsx)("div",{className:"animate-pulse bg-gray-200 rounded h-24"})})}),d=e=>(0,r.jsx)(o,{...e});d.propTypes={name:l().string.isRequired,value:l().string,onChange:l().func.isRequired,label:l().string,placeholder:l().string,error:l().string,disabled:l().bool,required:l().bool,toolbar:l().oneOfType([l().oneOf(["minimal","standard","full"]),l().array]),minHeight:l().number,maxHeight:l().number,ariaLabel:l().string,className:l().string},t.ZP=d},88510:function(e,t,a){"use strict";var r=a(52322),n=a(12524),s=a.n(n),i=a(13980),l=a.n(i);a(2784);let o=(e,t,a)=>a.has(e)?"completed":e===t?"active":"inactive",d=e=>e instanceof Set?e:new Set(e),c=(e,t)=>(e+1)/t*100,u=e=>{let{steps:t,currentStep:a,completedSteps:n=new Set,compact:i=!1,showStepNumbers:l=!0,showProgressText:u=!1,ariaLabel:m="Form progress",className:p}=e,g=d(n),x=c(a,t.length);return i?(0,r.jsxs)("div",{className:s()("flex items-center gap-2",p),children:[(0,r.jsx)("div",{className:"flex-1 bg-gray-200 rounded-full h-2 overflow-hidden",children:(0,r.jsx)("div",{"aria-label":"".concat(a+1," of ").concat(t.length," steps completed"),"aria-valuemax":t.length,"aria-valuemin":1,"aria-valuenow":a+1,
1className:"h-full bg-blue-500 rounded-full transition-all duration-300",role:"progressbar",style:{width:"".concat(x,"%")}})}),!!u&&(0,r.jsxs)("span",{className:"text-sm text-gray-600 font-medium whitespace-nowrap",children:[a+1,"/",t.length]})]}):(0,r.jsxs)("nav",{"aria-label":m,className:s()("w-full",p),role:"navigation",children:[(0,r.jsx)("div",{className:"grid gap-4",style:{gridTemplateColumns:"repeat(".concat(t.length,", 1fr)")},children:t.map((e,t)=>{let n=o(t,a,g),i="active"===n,d="completed"===n;return(0,r.jsxs)("div",{"aria-current":t===a?"step":void 0,className:"flex flex-col",children:[(0,r.jsx)("div",{className:s()("w-full rounded-sm transition-all duration-300",{"h-2 bg-blue-300":i,"h-2 bg-blue-600":d,"h-2 bg-gray-200":!i&&!d})}),(0,r.jsx)("div",{className:"mt-1",children:(0,r.jsxs)("span",{className:s()("text-sm font-medium text-left flex flex-col",{"text-gray-500":i,"text-blue-700":d,"text-gray-400":!i&&!d}),children:[!!l&&(0,r.jsxs)("span",{className:"hidden sm:inline text-sm",children:["Step ",t+1]}),e.label]})})]},e.id)})}),!!u&&(0,r.jsxs)("div",{className:"mt-4 text-left text-xs text-gray-500 font-medium",children:["Step ",a+1," of ",t.length]})]})};u.propTypes={steps:l().arrayOf(l().shape({id:l().string.isRequired,label:l().string.isRequired})).isRequired,currentStep:l().number.isRequired,completedSteps:l().oneOfType([l().instanceOf(Set),l().arrayOf(l().number)]),compact:l().bool,showStepNumbers:l().bool,showProgressText:l().bool,className:l().string,ariaLabel:l().string},t.Z=u},7325:function(e,t,a){"use strict";a.d(t,{Z:function(){return h}});var r=a(52322),n=a(2369),s=a(92942),i=a(12524),l=a.n(i),o=a(13980),d=a.n(o),c=a(2784),u=a(28316);let m=function(e,t,a){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:8,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:8,s={width:window.innerWidth,height:window.innerHeight},i=a=>{switch(a){case"top":return{top:e.top-t.height-r,left:e.left+e.width/2-t.width/2};case"bottom":return{top:e.bottom+r,left:e.left+e.width/2-t.width/2};case"left":return{top:e.top+e.height/2-t.height/2,left:e.left-t.width-r};case"right":return{top:e.top+e.height/2-t.height/2,left:e.right+r};default:return{top:0,left:0}}},l=(e,a)=>{let r=e.left+t.width,i=e.top+t.height;switch(a){case"top":return e.top>=n;case"bottom":return i<=s.height-n;case"left":return e.left>=n;case"right":return r<=s.width-n;default:return!0}},o={top:["top","bottom","right","left"],bottom:["bottom","top","right","left"],left:["left","right","top","bottom"],right:["right","left","top","bottom"]}[a]||["top"],d=a,c=i(a);for(let e of o){let t=i(e);if(l(t,e)){d=e,c=t;break}}return c.left=Math.max(n,Math.min(c.left,s.width-t.width-n)),c.top=Math.max(n,Math.min(c.top,s.height-t.height-n)),{...c,actualPlacement:d}},p=function(){let{placement:e="top",clickable:t=!0,showDelay:a=150,hideDelay:r=100}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[n,s]=(0,c.useState)(!1),[i,l]=(0,c.useState)({top:0,left:0,actualPlacement:e}),o=(0,c.useRef)(null),d=(0,c.useRef)(null),u=(0,c.useRef)(null),p=(0,c.useRef)(null),g=(0,c.useCallback)(()=>{u.current&&(clearTimeout(u.current),u.current=null),p.current&&(clearTimeout(p.current),p.current=null)},[]),x=(0,c.useCallback)(()=>{o.current&&d.current&&l(m(o.current.getBoundingClientRect(),d.current.getBoundingClientRect(),e))},[e]),h=(0,c.useCallback)(()=>{g(),u.current=setTimeout(()=>{s(!0)},a)},[g,a]),f=(0,c.useCallback)(()=>{g(),p.current=setTimeout(()=>{s(!1)},r)},[g,r]),y=(0,c.useCallback)(()=>{g(),s(!1)},[g]),b=(0,c.useCallback)(()=>{g(),s(e=>!e)},[g]),E=(0,c.useCallback)(()=>{h()},[h]),v=(0,c.useCallback)(()=>{f()},[f]),N=(0,c.useCallback)(()=>{t&&g()},[t,g]),j=(0,c.useCallback)(()=>{t&&f()},[t,f]),_=(0,c.useCallback)(()=>{h()},[h]),S=(0,c.useCallback)(()=>{f()},[f]),T=(0,c.useCallback)(e=>{e.preventDefault(),b()},[b]);return(0,c.useEffect)(()=>{let e=e=>{"Escape"===e.key&&n&&y()};return n&&document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[n,y]),(0,c.useEffect)(()=>{if(!n)return;let e=requestAnimationFrame(()=>{x()}),t=()=>{x()};return window.addEventListener("scroll",t,!0),window.addEventListener("resize",t),()=>{cancelAnimationFrame(e),window.removeEventListener("scroll",t,!0),window.removeEventListener("resize",t)}},[n,x]),(0,c.useEffect)(()=>()=>{g()}
1,[g]),{isVisible:n,position:i,anchorRef:o,tooltipRef:d,show:h,hide:f,hideImmediate:y,toggle:b,anchorProps:{ref:o,onMouseEnter:E,onMouseLeave:v,onFocus:_,onBlur:S,onClick:T},tooltipProps:{ref:d,onMouseEnter:N,onMouseLeave:j}}};a(18159);let g=()=>{let[e,t]=(0,c.useState)(!1);return(0,c.useEffect)(()=>t(!0),[]),e},x=e=>{let{body:t,maxWidth:a="300px",type:i="info",clickable:o=!0,id:d,className:c="",placement:m="top",icon:x=n.FDd}=e,h=g(),{isVisible:f,position:y,anchorProps:b,tooltipProps:E}=p({placement:m,clickable:o}),v=l()("eux-tooltip",{"eux-tooltip--visible":f,"eux-tooltip--clickable":o,["eux-tooltip--".concat(y.actualPlacement)]:!0}),N=l()("eux-tooltip-content",{"bg-blue-dark text-white":"info"===i}),j=(0,r.jsx)("div",{"aria-hidden":!f,className:v,id:"".concat(d,"-tooltip"),role:"tooltip",style:{top:y.top,left:y.left},...E,children:(0,r.jsxs)("div",{className:N,style:{maxWidth:a},children:[(0,r.jsx)("div",{className:"eux-tooltip-arrow"}),t]})});return(0,r.jsxs)("span",{className:c,children:[(0,r.jsx)("button",{"aria-describedby":f?"".concat(d,"-tooltip"):void 0,className:"appearance-none",id:"".concat(d,"-anchor"),type:"button",...b,children:(0,r.jsx)(s.FontAwesomeIcon,{icon:x,size:"sm"})}),!!h&&(0,u.createPortal)(j,document.body)]})};x.propTypes={body:d().any.isRequired,maxWidth:d().string,type:d().string,clickable:d().bool,id:d().string.isRequired,className:d().string,placement:d().oneOf(["top","bottom","left","right"]),icon:d().any};var h=x},18159:function(){},24886:function(e,t,a){"use strict";a.d(t,{Ip:function(){return i}});var r=a(2784),n=function(e,t){return(n=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a])})(e,t)};function s(e){var t,a,n,s,i,l,o,d=e.className,c=e.counterClockwise,u=e.dashRatio,m=e.pathRadius,p=e.strokeWidth,g=e.style;return(0,r.createElement)("path",{className:d,style:Object.assign({},g,(a=(t={pathRadius:m,dashRatio:u,counterClockwise:c}).counterClockwise,s=(1-t.dashRatio)*(n=2*Math.PI*t.pathRadius),{strokeDasharray:n+"px "+n+"px",strokeDashoffset:(a?-s:s)+"px"})),d:"\n M 50,50\n m 0,-"+(l=(i={pathRadius:m,counterClockwise:c}).pathRadius)+"\n a "+l+","+l+" "+(o=i.counterClockwise?1:0)+" 1 1 0,"+2*l+"\n a "+l+","+l+" "+o+" 1 1 0,-"+2*l+"\n ",strokeWidth:p,fillOpacity:0})}var i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return!function(e,t){function a(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}(t,e),t.prototype.getBackgroundPadding=function(){return this.props.background?this.props.backgroundPadding:0},t.prototype.getPathRadius=function(){return 50-this.props.strokeWidth/2-this.getBackgroundPadding()},t.prototype.getPathRatio=function(){var e=this.props,t=e.value,a=e.minValue,r=e.maxValue;return(Math.min(Math.max(t,a),r)-a)/(r-a)},t.prototype.render=function(){var e=this.props,t=e.circleRatio,a=e.className,n=e.classes,i=e.counterClockwise,l=e.styles,o=e.strokeWidth,d=e.text,c=this.getPathRadius(),u=this.getPathRatio();return(0,r.createElement)("svg",{className:n.root+" "+a,style:l.root,viewBox:"0 0 100 100","data-test-id":"CircularProgressbar"},this.props.background?(0,r.createElement)("circle",{className:n.background,style:l.background,cx:50,cy:50,r:50}):null,(0,r.createElement)(s,{className:n.trail,counterClockwise:i,dashRatio:t,pathRadius:c,strokeWidth:o,style:l.trail}),(0,r.createElement)(s,{className:n.path,counterClockwise:i,dashRatio:u*t,pathRadius:c,strokeWidth:o,style:l.path}),d?(0,r.createElement)("text",{className:n.text,style:l.text,x:50,y:50},d):null)},t.defaultProps={background:!1,backgroundPadding:0,circleRatio:1,classes:{root:"CircularProgressbar",trail:"CircularProgressbar-trail",path:"CircularProgressbar-path",text:"CircularProgressbar-text",background:"CircularProgressbar-background"},counterClockwise:!1,className:"",maxValue:100,minValue:0,strokeWidth:8,styles:{root:{},trail:{},path:{},text:{},background:{}},text:""},t}(r.Component)},91516:function(e,t,a){"use strict";a.d(t,{Z:function(){return p}});var r=a(7896),n=a(2784),s=a(26202),i=a(88137),l=a(56666),o=a(33028),d=a(76854),c=a(59740),u=a(407),m=["defaultOptions","cacheOptions","loadOptions","options","isLoading","onInputChange","filterOption"];a(28316),a(84337);var p=(0,n.forwardRef)(function(e,t){var a,p,g,x,h,f,y,b,E,v,N,j,_,S,T,R,I,w,C,D,A,F,k,O,P,L,G,M,U,q,Z,z,W,B,X,H,Y,J,V,K,Q,$,ee,et,ea,er,en,es,ei,el,eo,ed=(p=void 0!==(a=e.defaultOptions)&&a,x=void 0!==(g=e.cacheOptions)&&g,h=e.loadOptions,e.options,f=e.isLoading,y=e.onInputChange,b=e.filterOption,v=(E=(0,c.Z)(e,m)).inputValue,N=(0,n.useRef)(void 0),j=(0,n.useRef)(!1),_=(0,n.use
1State)(Array.isArray(p)?p:void 0),T=(S=(0,d.Z)(_,2))[0],R=S[1],I=(0,n.useState)(void 0!==v?v:""),C=(w=(0,d.Z)(I,2))[0],D=w[1],A=(0,n.useState)(!0===p),k=(F=(0,d.Z)(A,2))[0],O=F[1],P=(0,n.useState)(void 0),G=(L=(0,d.Z)(P,2))[0],M=L[1],U=(0,n.useState)([]),Z=(q=(0,d.Z)(U,2))[0],z=q[1],W=(0,n.useState)(!1),X=(B=(0,d.Z)(W,2))[0],H=B[1],Y=(0,n.useState)({}),V=(J=(0,d.Z)(Y,2))[0],K=J[1],Q=(0,n.useState)(void 0),ee=($=(0,d.Z)(Q,2))[0],et=$[1],ea=(0,n.useState)(void 0),en=(er=(0,d.Z)(ea,2))[0],es=er[1],x!==en&&(K({}),es(x)),p!==ee&&(R(Array.isArray(p)?p:void 0),et(p)),(0,n.useEffect)(function(){return j.current=!0,function(){j.current=!1}},[]),ei=(0,n.useCallback)(function(e,t){if(!h)return t();var a=h(e,t);a&&"function"==typeof a.then&&a.then(t,function(){return t()})},[h]),(0,n.useEffect)(function(){!0===p&&ei(C,function(e){j.current&&(R(e||[]),O(!!N.current))})},[]),el=(0,n.useCallback)(function(e,t){var a=(0,u.L)(e,t,y);if(!a){N.current=void 0,D(""),M(""),z([]),O(!1),H(!1);return}if(x&&V[a])D(a),M(a),z(V[a]),O(!1),H(!1);else{var r=N.current={};D(a),O(!0),H(!G),ei(a,function(e){j&&r===N.current&&(N.current=void 0,O(!1),M(a),z(e||[]),H(!1),K(e?(0,o.Z)((0,o.Z)({},V),{},(0,l.Z)({},a,e)):V))})}},[x,ei,G,V,y]),eo=X?[]:C&&G?Z:T||[],(0,o.Z)((0,o.Z)({},E),{},{options:eo,isLoading:k||void 0!==f&&f,onInputChange:el,filterOption:void 0===b?null:b})),ec=(0,i.u)(ed);return n.createElement(s.S,(0,r.Z)({ref:t},ec))})}},function(e){e.O(0,[4976,2362,5351,9603,9436,9400,8154,3199,9450,4933,4707,8516,2642,9788,2888,9774,179],function(){return e(e.s=46725)}),_N_E=e.O()}]);
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.