1import{x as L,Y as ee,r,j as e,U as A,C as S,B as R,m as D,I as se,a8 as te}from"./index-deD-MQWq.js";import{C,c as F}from"./card-CFCMs6dP.js";import{T as ae}from"./textarea-BF0wr0B1.js";import{s as I}from"./screeningService-CTPSh1NL.js";import{C as O}from"./chevron-right-DQoYBjlL.js";const re=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],z=L("mic",re);const ne=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],le=L("rotate-ccw",ne);const ce=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ie=L("send",ce);const oe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],G=L("square",oe),Y=180;function V({organisationLogoUrl:i}){return i?e.jsx("nav",{className:"border-b border-slate-700 bg-slate-900",children:e.jsx("div",{className:"container mx-auto px-4 sm:px-6 lg:px-8",children:e.jsx("div",{className:"flex justify-between items-center h-16",children:e.jsx(te,{to:"/",className:"flex items-center",children:e.jsx("img",{className:"h-8 max-w-[200px] object-contain",src:i,alt:"Organisation Logo"})})})})}):null}function de({src:i}){const l=r.useRef(null),[o,a]=r.useState(!1),[y,N]=r.useState(0),[c,j]=r.useState(0),b=()=>{l.current&&(o?l.current.pause():l.current.play(),a(!o))},x=d=>{if(!l.current||!c)return;const p=d.currentTarget.getBoundingClientRect(),g=Math.max(0,Math.min(1,(d.clientX-p.left)/p.width));l.current.currentTime=g*c},u=d=>{const p=Math.floor(d/60).toString().padStart(2,"0"),g=Math.floor(d%60).toString().padStart(2,"0");return`${p}:${g}`};return e.jsxs("div",{className:"rounded-base bg-slate-800 border border-slate-700 p-4 space-y-3",children:[e.jsx("audio",{ref:l,src:i,onTimeUpdate:()=>N(l.current?.currentTime??0),onLoadedMetadata:()=>j(l.current?.duration??0),onEnded:()=>a(!1)}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:b,className:"flex items-center justify-center w-10 h-10 rounded-full bg-primary text-white hover:opacity-90 transition-opacity shrink-0",children:o?e.jsx(G,{className:"h-4 w-4 fill-current"}):e.jsx("svg",{viewBox:"0 0 24 24",className:"h-4 w-4 fill-current ml-0.5",children:e.jsx("polygon",{points:"5,3 19,12 5,21"})})}),e.jsx("span",{className:"text-xs text-slate-300 font-mono w-10 shrink-0",children:u(y)}),e.jsx("div",{className:"flex-1 h-2 bg-slate-700 rounded-full cursor-pointer",onClick:x,children:e.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:c?`${y/c*100}%`:"0%"}})}),e.jsx("span",{className:"text-xs text-slate-300 font-mono w-10 shrink-0 text-right",children:u(c)})]})]})}function ge(){const{token:i}=ee(),[l,o]=r.useState("loading"),[a,y]=r.useState(null),[N,c]=r.useState(""),[j,b]=r.useState(!1),[x,u]=r.useState({}),[d,p]=r.useState(!1),[g,M]=r.useState(0),[T,_]=r.useState(null),[v,P]=r.useState(null),E=r.useRef(null),U=r.useRef([]),h=r.useRef(null),w=r.useRef(0);r.useEffect(()=>(i&&J(i),()=>{h.current&&clearInterval(h.current)}),[i]);const J=async t=>{try{const s=await I.getInviteByToken(t);y(s),s.status==="Pending"&&await I.acceptInvite(t),s.status==="Completed"||s.hasAudio?o("complete"):s.formSchema&&!s.hasFormResponse?o("welcome"):o("record")}catch(s){const n=s?.response?.data?.error||s?.response?.data?.detail||"Invalid or expired invitation link.";c(n),o("error")}},Q=async()=>{if(i){c(""),b(!0);try{await I.submitForm(i,JSON.stringify(x)),o("record")}catch{c("Failed to submit form. Please try again.")}finally{b(!1)}}},W=async()=>{c("");try{const t=await navigator.mediaDevices.getUserMedia({audio:!0}),s=new MediaRecorder(t,{mimeType:"audio/webm;codecs=opus"});E.current=s,U.current=[],s.ondataavailable=n=>{n.data.size>0&&U.current.push(n.data)},s.onstop=()=>{const n=new Blob(U.current,{type:"audio/webm"});_(n),P(URL.createObjectURL(n)),t.getTracks().forEach(f=>f.stop()),h.current&&clearInterval(h.current)},s.start(),p(!0),M(0),w.current=0,h.current=setInterval(()=>{w.current+=1,M(w.current),w.current>=Y&&B()},1e3)}catch{c("Could not access microphone. Please check permissions.")}},B=()=>{E.current?.stop(),p(!1),h.current&&(clearInterval(h.current),h.current=null)},X=()=>{v&&URL.revokeObjectURL(v),_(null),P(null),M(0)},H=async()=>
1{if(!(!i||!T)){c(""),b(!0);try{await I.uploadAudio(i,T),o("complete")}catch{c("Failed to upload audio. Please try again.")}finally{b(!1)}}},q=t=>{const s=Math.floor(t/60).toString().padStart(2,"0"),n=(t%60).toString().padStart(2,"0");return`${s}:${n}`},K=(t,s)=>{const n=t.label||`field_${s}`,f=x[n]||"",$=e.jsxs(D,{className:"text-slate-200",children:[t.label,t.required&&e.jsx("span",{className:"text-red-400 ml-1",children:"*"})]});switch(t.type){case"text":return e.jsxs("div",{className:"space-y-2",children:[$,e.jsx(se,{type:"text",value:f,onChange:m=>u({...x,[n]:m.target.value}),placeholder:t.placeholder,required:t.required,className:"bg-slate-700 border-slate-600 text-white placeholder:text-slate-400"})]},s);case"textarea":return e.jsxs("div",{className:"space-y-2",children:[$,e.jsx(ae,{value:f,onChange:m=>u({...x,[n]:m.target.value}),placeholder:t.placeholder,required:t.required,rows:4,className:"bg-slate-700 border-slate-600 text-white placeholder:text-slate-400"})]},s);case"select":return e.jsxs("div",{className:"space-y-2",children:[$,e.jsxs("select",{className:"flex h-10 w-full rounded-base border border-slate-600 bg-slate-700 px-3 py-2 text-sm text-white focus:outline-none focus:ring-1 focus:ring-primary",value:f,onChange:m=>u({...x,[n]:m.target.value}),required:t.required,children:[e.jsx("option",{value:"",children:"Select an option..."}),t.options?.map(m=>e.jsx("option",{value:m,children:m},m))]})]},s);case"checkbox":return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",id:`field-${s}`,checked:f==="true",onChange:m=>u({...x,[n]:m.target.checked?"true":"false"}),className:"h-4 w-4 shrink-0 rounded border-slate-600"}),e.jsx(D,{htmlFor:`field-${s}`,className:"text-slate-200 mb-0",children:t.label})]},s);default:return null}},k=a?.formSchema?JSON.parse(a.formSchema):[],Z=k.every((t,s)=>{if(!t.required)return!0;const n=t.label||`field_${s}`;return(x[n]||"").trim()!==""});return l==="loading"?e.jsx("div",{className:"min-h-screen bg-slate-900",children:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsx(A,{className:"h-8 w-8 animate-spin text-primary"})})}):l==="error"?e.jsxs("div",{className:"min-h-screen bg-slate-900",children:[e.jsx(V,{organisationLogoUrl:a?.organisationLogoUrl}),e.jsx("main",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-12",children:e.jsx("div",{className:"flex items-center justify-center min-h-[60vh]",children:e.jsx(S,{type:"error",dark:!0,title:"Unable to proceed",message:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("span",{children:N}),e.jsx("span",{children:"Please contact the hiring team for assistance."})]})})})})]}):e.jsxs("div",{className:"min-h-screen bg-slate-900",children:[e.jsx(V,{organisationLogoUrl:a?.organisationLogoUrl}),e.jsx("main",{className:"container mx-auto px-4 sm:px-6 lg:px-8 py-12",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-8",children:[l==="welcome"&&a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center space-y-4 flex items-center flex-col",children:[a.organisationLogoUrl&&e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsx("img",{src:a.organisationLogoUrl,className:"h-10",alt:""}),e.jsx("div",{className:"w-1 h-10 border-l border-slate-600"}),e.jsx("span",{className:"text-2xl font-bold text-white",children:"Application"})]}),!a.organisationLogoUrl&&e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Application"})]}),e.jsx(C,{className:"border-slate-700 bg-slate-800",children:e.jsxs(F,{className:"space-y-6 pt-4 pb-4",children:[e.jsxs("p",{className:"text-lg text-center text-slate-200",children:[a.candidateName&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"capitalize",children:a.candidateName}),", "]}),a.organisationName?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-semibold text-white",children:a.organisationName})," ","would like to learn more about you for the role of"," "]}):e.jsxs(e.Fragment,{children:["You've been invited to apply for the role of"," "]}),e.jsx("span",{className:"font-semibold text-primary",children:a.screeningTitle})]}),a.screeningDescription&&e.jsx("p",{className:"text-sm text-slate-300 text-center",children:a.screeningDescription}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-slate-700",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-200",children:[e.jsx("img",{src:"/icons/items/book/book-red-outline.svg",className:"h-4 w-4 brightness-200",alt:""}),e.jsx("span",{children:"Your Details"})]}),e.jsxs("p",{className:"font-semibold text-white",children:[k.length," field",k.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-slate-200",children:[e.jsx(z,{className:"h-4 w-4"}),e.jsx("span",{children:"Audio Response"})]}),e.jsx("p",{className:"font-semibold text-white",children:"1 question"})]})]}),e.jsx(S,{type:"info",dark:!0,title:"What to expect",message:"You'll fill out a short application form and then record a brief audio response to a question. The whole process only takes a few minutes."}),e.jsxs(R,{onClick:()=>o("form"),size:"lg",className:"w-full text-lg h-14",children:["Get Started",e.jsx(O,{className:"h-5 w-5 ml-2"})]})]})})]}),l==="form"&&a?.formSchema&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-slate-400 uppercase tracking-wider font-medium",children:"Step 1 of 2"}),e.jsx("h2",{className:"text-2xl font-bold text-white mt-1",children:"Your Details"}),e.jsx("p",{className:"text-slate-300 mt-2",children:"Please complete the form below before recording your response."})]}),e.jsx(C,{className:"border-slate-700 bg-slate-800",children:e.jsxs(F,{className:"space-y-5 pt-6 pb-6",children:[k.map((t,s)=>K(t,s)),e.jsxs(R,{onClick:Q,disabled:j||!Z,className:"w-full h-12 text-base",size:"lg",children:[j&&e.jsx(A,{className:"mr-2 h-4 w-4 animate-spin"}),"Continue to Audio Recording",e.jsx(O,{className:"h-5 w-5 ml-2"})]})]})})]}),l==="record"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-center",children:[a?.formSchema&&e.jsx("p",{className:"text-sm text-slate-400 uppercase tracking-wider font-medium",children:"Step 2 of 2"}),e.jsx("h2",{className:"text-2xl font-bold text-white mt-1",children:a?.formSchema?"One last thing":"Audio Response"}),e.jsx("p",{className:"text-slate-300 mt-2",children:"Answer the question below by recording a short audio response."})]}),e.jsx(C,{className:"border-slate-700 bg-slate-800",children:e.jsxs(F,{className:"space-y-6 pt-6 pb-6",children:[e.jsxs("div",{className:"border-l-3 border-primary bg-slate-700/50 rounded-r-base p-4",children:[e.jsx("p",{className:"text-xs font-semibold text-primary uppercase tracking-wider mb-2",children:"Your Question"}),e.jsx("p",{className:"text-base text-slate-200 leading-relaxed",children:a?.screeningQuestion})]}),e.jsx("div",{className:"flex flex-col items-center gap-5",children:T?e.jsxs("div",{className:"w-full space-y-4",children:[v&&e.jsx(de,{src:v}),e.jsxs("p",{className:"text-xs text-slate-400 text-center",children:["Recording length: ",q(g)]}),e.jsxs("div",{className:"flex gap-3 justify-center",children:[e.jsxs(R,{variant:"outline",onClick:X,size:"lg",className:"border-slate-500 bg-slate-700 text-white hover:bg-slate-600",children:[e.jsx(le,{className:"mr-2 h-4 w-4"}),"Re-record"]}),e.jsxs(R,{onClick:H,disabled:j,size:"lg",className:"min-w-[160px]",children:[j?e.jsx(A,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(ie,{className:"mr-2 h-4 w-4"}),"Submit Response"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:d?B:W,className:`rounded-full w-20 h-20 flex items-center justify-center transition-all cursor-pointer ${d?"bg-red-500 hover:bg-red-600 shadow-lg shadow-red-500/30":"bg-primary hover:opacity-90 shadow-lg shadow-primary/30"} text-white`,children:d?e.jsx(G,{className:"h-7 w-7 fill-current"}):e.jsx(z,{className:"h-7 w-7"})}),d&&e.jsxs("span",{className:"absolute -top-1 -right-1 flex h-3 w-3",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-red-500"})]})]}),e.jsx("div",{className:"text-center",children:d?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-lg font-mono font-semibold text-red-400",children:q(g)}),e.jsxs("p",{className:"text-sm text-slate-400 mt-1",children:["Recording â ",q(Y-g)," remaining"]})]}):e.jsx("p",{className:"text-sm text-slate-400",children:"Click the mic button to start recording (up to 3 minutes) â don't worry, you can playback and re-record as many times as you like before submitting!"})})]})})]})})]}),l==="complete"&&e.jsx(C,{className:"border-slate-700 bg-slate-800",children:e.jsx(F,{children:e.jsxs("div",{className:"text-center space-y-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex gap-4 items-center justify-center",children:[e.jsx("img",{src:"/icons/ui/check-mark/check-mark-outline.svg",className:"h-8 brightness-200",alt:""}),e.jsx("h3",{className:"text-3xl font-bold text-white",children:a?.candidateName?`Thank y
1ou, ${a.candidateName}!`:"Submission Received!"})]}),e.jsx("p",{className:"text-slate-300 mt-4 text-lg",children:"Your response has been submitted successfully."})]}),e.jsx(S,{type:"info",dark:!0,title:"What happens next?",message:"The hiring team will review your application and audio response. If you've been selected to proceed, they will contact you directly."})]})})}),N&&e.jsx(S,{type:"error",dark:!0,message:N})]})})]})}export{ge 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.