1import{j as e}from"./data-vendor-Dm-g84yT.js";import{j as me,u as xe,l as ue,a as l}from"./react-vendor-D4WbZ5lj.js";import{a as he,b as ge}from"./recruitmentApi-B5Q2UTSf.js";import{s as pe,c as be}from"./careerRoutes-Bkfj82sq.js";const y=({label:x,required:b,children:f,hint:i,error:d})=>e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:[x," ",b&&e.jsx("span",{className:"text-red-500",children:"*"})]}),f,i&&!d&&e.jsx("p",{className:"mt-1 text-xs text-gray-400",children:i}),d&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:d})]}),E="w-full border border-gray-300 rounded-lg px-3.5 py-2.5 text-sm text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-[#4884f0]/30 focus:border-[#4884f0] transition",fe=e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16a4 4 0 01-.88-7.9 5 5 0 019.9-1A4.5 4.5 0 0117 16M12 12v6m0-6l-2.5 2.5M12 12l2.5 2.5"})}),je=({label:x,required:b,placeholder:f,accept:i,hint:d,file:c,onFile:N,error:p})=>{const v=l.useRef(null);return e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:[x," ",b&&e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("button",{type:"button",onClick:()=>v.current?.click(),className:`w-full h-40 flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed px-4 text-center transition-colors ${c?"border-[#4884f0] bg-blue-50/60":"border-gray-300 bg-gray-50 hover:border-[#4884f0] hover:bg-blue-50/40"}`,children:[e.jsx("span",{className:`flex items-center justify-center w-11 h-11 rounded-full ${c?"bg-[#4884f0] text-white":"bg-white text-[#4884f0] border border-gray-200"}`,children:c?e.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}):fe}),c?e.jsx("span",{className:"text-xs font-medium text-[#03152c] break-all line-clamp-2",children:c.name}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-sm font-semibold text-gray-700",children:f}),e.jsx("span",{className:"text-[11px] text-gray-400",children:"Click to browse"})]})]}),e.jsx("input",{ref:v,type:"file",accept:i,className:"hidden",onChange:u=>N(u.target.files?.[0]||null)}),i&&e.jsx("p",{className:"mt-1.5 text-[11px] text-gray-400",children:d||`Accepted: ${i}`}),c&&e.jsx("button",{type:"button",onClick:()=>N(null),className:"mt-1 text-xs text-red-500 hover:underline",children:"Remove"}),p&&e.jsx("p",{className:"mt-1 text-xs text-red-500",children:p})]})},ye=x=>({email:"email",phone:"tel",number:"number",url:"url",date:"date"})[x]||"text";function Se({jobTitle:x,department:b,onBack:f,onSubmitOverride:i}){const d=me(),c=xe(),{country:N,jobId:p}=ue(),v=pe(N),u=c.state?.job||null,D=c.state?.branding||null,w=u?.screeningQuestions||[],I=x||u?.title||"this Position",M=b||(u?.category&&u.category!=="Other"?u.category:"")||"",J=f||(()=>d(be.jobDetail(v,p))),[k,_]=l.useState(null),[O,A]=l.useState(!0),[B,q]=l.useState(null),[Y,G]=l.useState(0),[h,H]=l.useState({}),[S,X]=l.useState({}),[L,Z]=l.useState({}),[$,ee]=l.useState({}),[R,T]=l.useState(!1),[te,se]=l.useState(!1),[K,W]=l.useState(null);l.useEffect(()=>{const t=new AbortController;return A(!0),q(null),he(t.signal).then(_).catch(s=>{s.name!=="AbortError"&&q("Unable to load the application form. Please try again.")}).finally(()=>A(!1)),()=>t.abort()},[Y]);const C=l.useMemo(()=>(k?.fields||[]).slice().sort((t,s)=>(t.order||0)-(s.order||0)),[k]),P=C.filter(t=>t.type==="file"),U=C.filter(t=>t.type!=="file"),V=k?.labels||D?.labels||{},re=V.submitButtonText||"Submit Application",ne=V.successMessage||"Application successfully submitted!",F=t=>s=>H(r=>({...r,[t]:s.target.value})),le=t=>s=>X(r=>({...r,[t]:s})),z=t=>s=>Z(r=>({...r,[t]:s})),ae=()=>{const t={};
1return C.forEach(s=>{const{name:r,type:o,required:a,label:n}=s;if(o==="file"){const m=S[r];if(a&&!m)t[r]=`${n} is required.`;else if(m){const g=s.allowedFileExtensions||[];g.length&&!g.some(de=>m.name.toLowerCase().endsWith(de.toLowerCase()))&&(t[r]=`Allowed file types: ${g.join(", ")}.`);const Q=s.maxFileSizeMb||5;m.size>Q*1024*1024&&(t[r]=`Max size ${Q} MB.`)}return}const j=(h[r]||"").trim();a&&!j?t[r]=`${n} is required.`:j&&o==="email"&&!/^\S+@\S+\.\S+$/.test(j)&&(t[r]="Enter a valid email.")}),w.forEach((s,r)=>{const o=`screening_${r}`,a=(L[r]??"").toString().trim();s.required&&!a&&(t[o]=`${s.question} is required.`)}),ee(t),Object.keys(t).length===0},oe=async()=>{if(W(null),!ae()){window.scrollTo({top:0,behavior:"smooth"});return}const t=w.map((s,r)=>({question:s.question,type:s.type,answer:(L[r]??"").toString()}));if(i){i({jobId:p,values:h,files:S,screeningAnswers:t});return}T(!0);try{await ge({jobId:p,config:k,values:h,files:S,screeningAnswers:t}),se(!0),window.scrollTo({top:0,behavior:"smooth"})}catch(s){W(s.message||"Something went wrong. Please try again.")}finally{T(!1)}},ie=t=>{const{name:s,label:r,type:o,required:a,options:n,autocomplete:j}=t,m=$[s];return n&&n.length>0?e.jsx(y,{label:r,required:a,error:m,children:e.jsxs("div",{className:"relative",children:[e.jsxs("select",{value:h[s]||"",onChange:F(s),className:`${E} appearance-none pr-9 ${h[s]?"text-gray-900":"text-gray-400"}`,children:[e.jsx("option",{value:"",children:"No Selection"}),n.map(g=>e.jsx("option",{value:g,children:g},g))]}),e.jsx("svg",{className:"w-4 h-4 text-gray-400 absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]})},s):o==="textarea"?e.jsx(y,{label:r,required:a,error:m,children:e.jsx("textarea",{rows:4,value:h[s]||"",onChange:F(s),className:E})},s):e.jsx(y,{label:r,required:a,error:m,children:e.jsx("input",{type:ye(o),value:h[s]||"",onChange:F(s),autoComplete:j,className:E})},s)},ce=(t,s)=>{const r=`screening_${s}`,o=$[r],a=L[s]??"";return t.type==="yesno"?e.jsx(y,{label:t.question,required:t.required,error:o,children:e.jsx("div",{className:"flex items-center gap-6",children:["yes","no"].map(n=>e.jsxs("label",{className:"flex items-center gap-2 text-sm text-gray-700 cursor-pointer",children:[e.jsx("input",{type:"radio",name:`screening-${s}`,value:n,checked:a===n,onChange:()=>z(s)(n),className:"w-4 h-4 text-[#4884f0] focus:ring-[#4884f0]"}),n==="yes"?"Yes":"No"]},n))})},r):e.jsx(y,{label:t.question,required:t.required,error:o,children:e.jsx("input",{type:t.type==="number"?"number":"text",value:a,onChange:n=>z(s)(n.target.value),className:E})},r)};return te?e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-gray-50 to-white font-sans flex items-center justify-center px-4 py-24",children:e.jsxs("div",{className:"max-w-md w-full bg-white rounded-2xl border border-gray-100 shadow-sm p-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 mx-auto mb-5 rounded-full bg-green-50 flex items-center justify-center",children:e.jsx("svg",{className:"w-8 h-8 text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),e.jsx("h1",{className:"text-2xl font-bold text-[#03152c] mb-2",children:"Thank you!"}),e.jsx("p",{className:"text-gray-600 mb-6",children:ne}),e.jsx("button",{onClick:()=>d("/careers"),className:"bg-[#4884f0] hover:bg-blue-600 text-white font-semibold text-sm px-8 py-3 rounded-full transition-colors",children:"Back to Careers"})]})}):e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-gray-50 to-white font-sans text-gray-900",children:e.jsxs("main",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-10 sm:py-12 pt-28 sm:pt-32",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("button",{onClick:J,className:"flex items-center gap-2 text-sm font-semibold text-gray-600 hover:text-[#03152c] transition-colors",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})}),"Back to Job Details"]}
1),e.jsx("button",{className:"text-[#4884f0] text-sm hover:underline",children:"English UK (English UK)"})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-6 sm:p-8 mb-8",children:[e.jsx("span",{className:"inline-block text-xs font-semibold tracking-wide uppercase text-[#4884f0] bg-blue-50 px-3 py-1 rounded-full mb-3",children:"Application"}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-[#03152c] mb-2",children:"Apply for this Position"}),e.jsxs("p",{className:"text-base sm:text-lg text-gray-700",children:[e.jsx("span",{className:"font-bold text-[#03152c]",children:I}),M?` · ${M} Department`:""]})]}),K&&e.jsx("div",{className:"mb-6 rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-600",children:K}),O?e.jsxs("div",{className:"space-y-5",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-5",children:[0,1,2].map(t=>e.jsx("div",{className:"h-40 rounded-xl bg-gray-100 animate-pulse"},t))}),e.jsx("div",{className:"bg-white rounded-2xl border border-gray-100 p-6 sm:p-8 space-y-4",children:[0,1,2,3].map(t=>e.jsx("div",{className:"h-11 rounded-lg bg-gray-100 animate-pulse"},t))})]}):B?e.jsxs("div",{className:"bg-white border border-red-100 rounded-2xl p-12 text-center text-gray-600 shadow-sm",children:[e.jsx("p",{className:"text-lg font-semibold text-red-600 mb-1",children:B}),e.jsx("p",{className:"text-sm mb-5",children:"The application form could not be loaded."}),e.jsx("button",{onClick:()=>G(t=>t+1),className:"bg-[#4884f0] hover:bg-blue-600 text-white text-sm font-medium px-6 py-2.5 rounded-full transition-colors",children:"Retry"})]}):C.length===0?e.jsx("div",{className:"bg-white border border-gray-100 rounded-2xl p-12 text-center text-gray-500 shadow-sm",children:"No application fields are configured for this position yet."}):e.jsxs(e.Fragment,{children:[P.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-5 mb-8",children:P.map(t=>e.jsx(je,{label:t.label,required:t.required,placeholder:`Upload ${t.label}`,accept:(t.allowedFileExtensions||[]).join(","),hint:(t.allowedFileExtensions||[]).length?`${t.allowedFileExtensions.join(", ")} · max ${t.maxFileSizeMb||5} MB`:null,file:S[t.name]||null,onFile:le(t.name),error:$[t.name]},t.name))}),U.length>0&&e.jsx("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-6 sm:p-8",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-5",children:U.map(ie)})}),w.length>0&&e.jsxs("div",{className:"bg-white rounded-2xl border border-gray-100 shadow-sm p-6 sm:p-8 mt-8",children:[e.jsx("h2",{className:"text-lg font-semibold text-[#03152c] mb-4",children:"Screening Questions"}),e.jsx("div",{className:"space-y-5",children:w.map(ce)})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 pt-8",children:[e.jsx("button",{onClick:oe,disabled:R,className:"w-full sm:w-auto bg-[#4884f0] hover:bg-blue-600 disabled:opacity-60 disabled:cursor-not-allowed text-white font-semibold text-sm px-12 py-3 rounded-full transition-colors shadow-md",children:R?"Submittingâ¦":re}),e.jsx("p",{className:"text-center text-xs text-gray-400",children:"By applying you agree to our terms and privacy policy."})]})]})]})})}export{Se as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.