PageSourceSearch

https://app.prepin.ai/assets/SystemDesignInterview-BUgh30he.js

js prepin.ai collected 2026-10-02 00:05:09 UTC 44,537 bytes, 50 lines download raw bytes

1import{u as Xt,b as Qt,by as en,r,cY as sn,j as e,F as B,V as L,T as m,g as _,B as S,t as D,S as I,x as tn,bk as Fe,hw as nn,hx as rn,ce as ut,y as ks,cN as an,al as on,am as cn,an as dt,c0 as ln,cE as un,cF as gt,ai as Ts,a4 as dn,fW as gn,fZ as fn,aO as Is,d5 as mn,d6 as hn,bx as ft,M as mt,i as ht,k as xt,l as pt,m as xn,n as bt,a5 as pn}from"./vendor-BCRspNgZ.js";import{b as bn,T as yn,r as Sn}from"./pages-DE9jEnKg.js";import{u as wn,a as Re,I as vn,V as jn}from"./components-Bl_54C1A.js";import{S as j,s as Rn,e as kn,a as Tn}from"./screeningPracticePrivacy-ydbSy2WH.js";const G="https://api.prepin.ai",Ms="system-design-medium-v1",Cs=2,zs=.5,Es=5,Qe=.2,yt=[{code:"en",label:"English"},{code:"cs",label:"Czech"},{code:"da",label:"Danish"},{code:"nl",label:"Dutch"},{code:"fi",label:"Finnish"},{code:"fr",label:"French"},{code:"de",label:"German"},{code:"el",label:"Greek"},{code:"it",label:"Italian"},{code:"no",label:"Norwegian"},{code:"pl",label:"Polish"},{code:"pt",label:"Portuguese"},{code:"ro",label:"Romanian"},{code:"es",label:"Spanish"},{code:"sv",label:"Swedish"},{code:"uk",label:"Ukrainian"}],In=(n="en")=>{const u=String(n||"").toLowerCase();return yt.find(f=>f.code===u)||yt[0]},_s=(n,u="en")=>{const f=Sn(n,u);return f?{text:f,isLocalized:!0}:{text:String((n==null?void 0:n.first_message)||"").trim(),isLocalized:!1}},Mn=[{id:"system-design-url-shortener",title:"Design a URL Shortener",prompt:"Design a URL shortening service (like bit.ly). Describe the API, data model, key components, and how you handle scale.",requirements:["Support short link creation and redirection","Prevent collisions and handle custom aliases","Handle high read traffic with caching","Store analytics (click counts, timestamps)"],difficulty:"medium",estimated_minutes:10,first_message:"Hi! We’ll start with designing a URL shortener. Please restate the problem and outline your high-level approach before drawing."},{id:"system-design-chat-system",title:"Design a Chat System",prompt:"Design a real-time chat system with 1:1 and group messaging. Cover APIs, data storage, real-time delivery, and scaling.",requirements:["Support message send, receive, and delivery receipts","Handle online/offline users and message ordering","Scale via pub/sub or message queues","Store messages and metadata"],difficulty:"medium",estimated_minutes:10,first_message:"Next task is a chat system. Please restate the problem and describe your architecture before drawing."},{id:"system-design-rate-limiter",title:"Design a Rate Limiter",prompt:"Design a distributed rate limiter for an API gateway. Discuss algorithms, data store choices, and failure handling.",requirements:["Support per-user or per-IP limits","Handle distributed deployments","Explain consistency vs availability tradeoffs","Provide a fallback strategy on store failure"],difficulty:"medium",estimated_minutes:10,first_message:"Final task: a rate limiter. Please restate the requirements and outline your design choices."}],St="systemDesignInterview",Cn=(n={},u=0)=>{var $,Te;const f=String((n==null?void 0:n.id)||`system-design-task-${u+1}`),p=String((n==null?void 0:n.title)||`System Design Task ${u+1}`).trim(),w=String((n==null?void 0:n.prompt)||"").trim(),g=Array.isArray(n==null?void 0:n.requirements)?n.requirements.map(x=>String(x||"").trim()).filter(Boolean):[],X=String((n==null?void 0:n.first_message)||"").trim(),z=String((n==null?void 0:n.initial_diagram_svg)||(($=n==null?void 0:n.diagram)==null?void 0:$.primary_svg)||"").trim(),M=Array.isArray(n==null?void 0:n.initial_diagram_elements)?n.initial_diagram_elements:Array.isArray((Te=n==null?void 0:n.diagram)==null?void 0:Te.extracted_excalidraw_elements)?n.diagram.extracted_excalidraw_elements:[];return{...n,id:f,title:p,prompt:w,requirements:g,difficulty:String((n==null?void 0:n.difficulty)||"medium").toLowerCase(),estimated_minutes:Number(n==null?void 0:n.estimated_minutes)>0?Number(n.estimated_minutes):10,first_message:X||`Let's design ${p}. Start with requirements and a high-level architecture.`,initial_diagram_svg:z||null,initial_diagram_elements:M}},ke=()=>({elements:[],appState:{},files:{}}),_n=(n=[],u="",f=!1)=>
1{const p=Array.isArray(n)?n.filter(Boolean):[],w=String(u||"").trim();if(f){if(w){const M=p.find($=>String(($==null?void 0:$.id)||"")===w);if(M)return[M]}return p.slice(0,1)}if(p.length<=Cs)return p;if(!w)return p.slice(0,Cs);const g=p.findIndex(M=>String((M==null?void 0:M.id)||"")===w);if(g<0)return p.slice(0,Cs);const X=p[g],z=p[g+1]||p[g-1]||p.find((M,$)=>$!==g);return z?[X,z]:[X]},wt=(n={},u=null)=>{const f=Array.isArray(n==null?void 0:n.initial_diagram_elements)?n.initial_diagram_elements:[],p=Array.isArray(u==null?void 0:u.elements)?u.elements:[];return f.length>0&&p.length===f.length&&JSON.stringify(p)===JSON.stringify(f)||!u?ke():{elements:Array.isArray(u==null?void 0:u.elements)?u.elements:[],appState:(u==null?void 0:u.appState)||{},files:(u==null?void 0:u.files)||{}}},Dn=(n="")=>{const u=String(n||"").trim();return u?/^data:image\/svg\+xml/i.test(u)?u:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(u)}`:""},Ds=n=>Math.min(Es,Math.max(zs,n)),zn=n=>{var f,p;const u=(n==null?void 0:n.event)||(n==null?void 0:n.type)||(n==null?void 0:n.name)||((f=n==null?void 0:n.message)==null?void 0:f.event)||((p=n==null?void 0:n.message)==null?void 0:p.type)||"";return String(u||"").toLowerCase()},Rt=n=>n?typeof n=="string"?n:typeof(n==null?void 0:n.text)=="string"?n.text:typeof(n==null?void 0:n.content)=="string"?n.content:typeof(n==null?void 0:n.transcript)=="string"?n.transcript:n!=null&&n.message?Rt(n.message):"":"",En=n=>{var p;let u=(n==null?void 0:n.role)||(n==null?void 0:n.source)||(n==null?void 0:n.speaker);if(!u&&((p=n==null?void 0:n.message)!=null&&p.role)&&(u=n.message.role),typeof u!="string")return"agent";const f=u.toLowerCase();return["assistant","agent","ai"].includes(f)?"agent":["user","human","candidate"].includes(f)?"user":"agent"},vt=(n=[])=>{const u=[],f=[],p=[];return n.forEach(w=>{var X,z;if(w.isDeleted)return;const g={id:w.id,type:w.type,x:Math.round(w.x),y:Math.round(w.y),w:Math.round(w.width||0),h:Math.round(w.height||0)};if(w.type==="text"){f.push({...g,text:w.text||""});return}if(w.type==="arrow"||w.type==="line"){p.push({id:w.id,from:((X=w.startBinding)==null?void 0:X.elementId)||null,to:((z=w.endBinding)==null?void 0:z.elementId)||null,label:w.text||""});return}u.push({...g,label:w.text||""})}),{nodes:u,labels:f,edges:p}},jt=n=>{try{return JSON.stringify(n)}catch{return`${Date.now()}`}};function Ln(){var it,at,ot,ct,lt;const n=Xt(),u=Qt(),{sessionId:f}=en(),{user:p}=wn(),w=new URLSearchParams(u.search),g=w.get("screening")==="1",z=(g?w.get("definitionId"):null)||((it=u==null?void 0:u.state)==null?void 0:it.interviewId)||Ms,M=((at=u==null?void 0:u.state)==null?void 0:at.initialTaskId)||"",$=!!((ot=u==null?void 0:u.state)!=null&&ot.singleTaskMode),Te=((ct=u==null?void 0:u.state)==null?void 0:ct.interviewLanguageCode)||(g?null:localStorage.getItem("codingInterviewSelectedVoiceLanguage"))||"en",x=r.useMemo(()=>In(Te),[Te]),[b,es]=r.useState([]),[Be,kt]=r.useState(z),[As,Tt]=r.useState("System Design Interview"),[It,Le]=r.useState(!0),[$s,ss]=r.useState(""),[y,Ne]=r.useState(1),[de,ge]=r.useState({}),[fe,We]=r.useState({}),[Q,ts]=r.useState({}),[Ie,ns]=r.useState({}),[v,rs]=r.useState(null),[Pe,Fs]=r.useState(!1),[Bs,me]=r.useState(""),[Mt,Me]=r.useState(!1),[V,N]=r.useState(j.IDLE),[is,Ls]=r.useState(!1),[as,Ue]=r.useState(!1),[Ns,Ws]=r.useState(""),[Ct,_t]=r.useState(!1),[W,Dt]=r.useState(!0),[Ce,he]=r.useState("idle"),[se,xe]=r.useState(null),[ee,Ps]=r.useState(!1),[zt,Et]=r.useState(()=>Math.floor(Date.now()/1e3)),[At,te]=r.useState(!1),[qe,os]=r.useState(!1),[$t,cs]=r.useState(!1),[P,_e]=r.useState(1),Ft=r.useRef(0),[ls,He]=r.useState([]),[Bt,Ge]=r.useState({}),[Lt,Ve]=r.useState({}),[pe,us]=r.useState({}),Ye=r.useRef([]),C=r.useRef(null),ds=r.useRef(""),ne=r.useRef(null),De=r.useRef(null),gs=r.useRef(""),fs=r.useRef(Date.now()),ms=r.useRef(!1),re=r.useRef(!1),be=r.useRef(!1),hs=r.useRef(""),ie=r.useRef(null),ye=r.useRef({elements:[],appState:{},files:{}}),xs=r.useRef(""),ps=r.useRef(""),ze=r.useRef({}),E=r.useRef({}),bs=r.useRef(null),Ee=r.useRef(null),Ae=r.useRef(""),Ke=r.useRef(""),ys=r.useRef(!1),Us=r.useRef(0),U=r.useRef(""),Ze=r.useRef(null),qs=r.useRef({}),Ss=r.useRef(null),ws=r.useRef(!0);r.useEffect(()=>{g||localStorage.setItem("codingInterviewSelectedVoiceLanguage",x.code)},[x.code,g]),r.useEffect(()=>{qs.current=fe},[fe]),r.useEffect(()=>{let s=!1;return(async()=>{var d;Le(!0),ss("");let i=null;try{if(g&&!f)throw new Error("Screening session is missing.");const o=g?`${G}/api/interview-sessions/${encodeURIComponent(f)}/definition`:`${G}/api/system-design-interviews/${encodeURIComponent(z)}`,T=await fetch(o,{credentials:"include"});if(T.ok)i=await T.json();else if(g)throw new Error("Screening definition is unavailable.")}catch{if(g){if(s)return;es([]),ss("We could not load this assessment securely. Please try again."),Le(!1);return}}if(!i&&!g)try{const o=await fetch(`${G}/api/system-design-interviews/current`,{credentials:"include"});o.ok&&(i=await o.json())}catch{}if(g&&!((d=i==null?void 0:i.tasks)!=null&&d.length)){if(s)return;es([]),ss("We could not load this assessment securely. Please try again."),Le(!1);return}const l=(Array.isArray(i==null?void 0:i.tasks)&&i.tasks.length?i.tasks:Mn).map((o,T)=>Cn(o,T)),h=_n(l,M,$);s||(es(h),Tt(String((i==null?void 0:i.label)||"System Design Interview")),kt(String((i==null?void 0:i.id)||z)),Ne(o=>{if(!h.length)return 1;if(M){const T=h.findIndex(J=>(J==null?void 0:J.id)===M);if(T>=0)return T+1}return o<1?1:Math.min(o,h.length)}),Le(!1))})(),()=>{s=!0}},[z,M,$,g,f]);const Je=r.useMemo(()=>f?`${St}:${f}`:`${St}:local`,[f]),c=b[y-1]||b[0]||null,k=c==null?void 0:c.id,Y=b.length,ae=r.useMemo(()=>Dn((c==null?void 0:c.initial_diagram_svg)||""),[c==null?void 0:c.initial_diagram_svg]);r.useEffect(()=>{_e(1),cs(!1)},[k]);const Hs=r.useCallback(()=>{ae&&cs(!0)},[ae]),Nt=r.useCallback(()=>{cs(!1)},[]),Gs=r.useCallback(()=>{_e(s=>Ds(s+Qe))},[]),Vs=r.useCallback(()=>{_e(s=>Ds(s-Qe))},[]),Ys=r.useCallback(()=>{_e(1)},[]),Wt=r.useCallback(s=>{!s.ctrlKey&&!s.metaKey||(s.preventDefault(),_e(t=>{const i=t+(s.deltaY<0?Qe:-Qe);return Ds(i)}))},[]),Pt=r.useMemo(()=>({companyName:"System Design",interviewType:"Architecture",customPosition:(c==null?void 0:c.title)||As||"System Design Interview"}),[c,As]),Ut=(p==null?void 0:p.username)||((lt=p==null?void 0:p.email)==null?void 0:lt.split("@")[0])||"You",qt=Ct||p==null?void 0:p.avatar,Ht=r.useCallback(s=>{const t=Math.max(0,Math.floor(s||0)),i=String(Math.floor(t/60)).padStart(2,"0"),l=String(t%60).padStart(2,"0");return`${i}:${l}`},[]),A=r.useCallback(s=>Array.isArray(s)?s.map(t=>
1String(t||"").trim()).filter(Boolean):[],[]),Se=r.useMemo(()=>{const s=Math.max(60,((c==null?void 0:c.estimated_minutes)||10)*60),t=Math.max(0,Math.floor((Q==null?void 0:Q[k])||0)),i=Math.max(0,Math.floor(Date.now()/1e3-Math.floor(fs.current/1e3)));return Math.max(0,s-t-i)},[c,k,Q,zt]),K=r.useCallback((s,t,i)=>{const l=i||hs.current;if(!l)return;const h={id:`${Date.now()}-${Math.random().toString(36).slice(2)}`,role:s,text:t};ge(d=>({...d,[l]:[...d[l]||[],h]})),We(d=>({...d,[l]:[...d[l]||[],{role:s,text:t}]}))},[]);r.useEffect(()=>{hs.current=k||""},[k]);const Ks=r.useCallback(s=>{s&&(ze.current[s]={oneMinute:!1,threeSeconds:!1,timeUp:!1})},[]),Zs=Ce==="active"?se==="listening"?"Listening":se==="thinking"?"Thinking":se==="talking"?"Speaking":"Active":Ce==="connecting"?"Connecting":"Idle",Gt=Ce==="active"?"#22C55E":"#94A3B8",Vt=At&&!qe,Yt=W&&se==="listening",oe=r.useCallback(()=>{C.current=null,re.current=!1,xe(null),he("error")},[]),vs=r.useCallback(s=>{const t=C.current;if(t)try{if(typeof t.setMicMuted=="function"){t.setMicMuted(s);return}typeof t.setMicrophoneMuted=="function"&&t.setMicrophoneMuted(s)}catch{}},[]),R=r.useCallback(s=>{const t=C.current;if(t!=null&&t.sendContextualUpdate)try{t.sendContextualUpdate(s)}catch{oe()}},[oe]),F=r.useCallback((s={})=>{var d;const t=vt(Ye.current),i=_s(c,x.code),l=i.text?x.code==="en"||i.isLocalized?`First message for this task: ${i.text}`:`First message intent (translate to ${x.label}): ${i.text}`:null;return[s!=null&&s.reason?`Update: ${s.reason}`:null,`Task ${y} of ${b.length}`,`Title: ${(c==null?void 0:c.title)||""}`,`Prompt: ${(c==null?void 0:c.prompt)||""}`,l,`Interview language: ${x.label} (${x.code})`,(d=c==null?void 0:c.requirements)!=null&&d.length?`Requirements: ${c.requirements.join("; ")}`:null,`Diagram summary: ${JSON.stringify(t)}`,s!=null&&s.note?`Note: ${s.note}`:null].filter(Boolean).join(`
2`)},[c,y,b.length,x.code,x.label]),Js=r.useCallback(s=>{const t=typeof s=="string"?s:(s==null?void 0:s.mode)||(s==null?void 0:s.state)||"",i=String(t||"").toLowerCase();if(i.includes("listen")){xe("listening"),te(!1),R(F({reason:"user_speaking"}));return}if(i.includes("think")){xe("thinking"),te(!0);return}if(i.includes("speak")||i.includes("talk")){xe("talking"),he("active"),te(!1);return}xe(null),te(!1),os(!1)},[]),q=r.useCallback(()=>{Ze.current&&(clearTimeout(Ze.current),Ze.current=null)},[]),Z=r.useCallback(()=>{bs.current&&(clearInterval(bs.current),bs.current=null);const s=Ee.current,t=Ae.current,i=Ke.current;s&&t&&i&&(ge(l=>({...l,[t]:(l[t]||[]).map(h=>h.id===s?{...h,text:i}:h)})),We(l=>{const h=l[t]||[],d=h[h.length-1];return(d==null?void 0:d.role)==="agent"&&(d==null?void 0:d.text)===i?l:{...l,[t]:[...h,{role:"agent",text:i}]}})),Ee.current=null,Ae.current="",Ke.current="",ys.current=!1,Us.current=0,te(!1),os(!1)},[]),Oe=r.useCallback((s,t={})=>{const i=(s||"").trim();if(!i||/^[.\u2026]+$/.test(i))return;const l=(t==null?void 0:t.final)===!0,h=hs.current;if(h)if(gs.current=i,Us.current=Date.now(),Ee.current)Ke.current=i,ge(d=>({...d,[Ae.current]:(d[Ae.current]||[]).map(o=>o.id===Ee.current?{...o,text:i}:o)})),l&&(ys.current=!0,Z());else{te(!1),os(!0);const d=`${Date.now()}-${Math.random().toString(36).slice(2)}`;Ee.current=d,Ae.current=h,Ke.current=i,ys.current=l,ge(o=>({...o,[h]:[...o[h]||[],{id:d,role:"agent",text:i}]})),l&&Z()}},[Z]),Os=r.useCallback(s=>{const t=zn(s),i=En(s),l=Rt(s),h=l==null?void 0:l.trim();if(!h||/^[.\u2026]+$/.test(h))return;if(i!=="agent"){K("user",h);return}if(h===gs.current)return;if(t.includes("agent_chat_response_part")){xe("talking"),qe||te(!0),U.current=h,q(),Ze.current=setTimeout(()=>{U.current&&Oe(U.current,{final:!1})},800);return}if(t.includes("agent_chat_response")||t.includes("agent_response")||t.includes("chat_response")){const o=h||U.current;U.current="",q(),o&&Oe(o,{final:!0});return}const d=h||U.current;U.current="",q(),d&&Oe(d,{final:!0})},[K,q,Oe,qe]),Xs=r.useCallback(async()=>{const s=g?`${G}/api/interview-sessions/${encodeURIComponent(f)}/conversation-token`:`${G}/api/elevenlabs/conversation-token`,t=g?{method:"POST",credentials:"include"}:{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({agentId:"agent_5801kfh3bcs4fs188z03esnvten4"})},i=await fetch(s,t),l=await i.json();if(!i.ok)throw new Error((l==null?void 0:l.error)||"Failed to start conversation");return l},[g,f]),Qs=r.useCallback(async()=>{var s;if(!(C.current||re.current)){re.current=!0,he("connecting");try{const t=await Xs(),i=_s(c,x.code),l=x.code==="en",h=bn({languageCode:x.code,taskNumber:y,taskTotal:b.length||1,taskTitle:(c==null?void 0:c.title)||"System design task"}),d=l||i.isLocalized?i.text:h||i.text,o=await sn.startSession({signedUrl:t.signed_url,agentId:t.agentId,connectionType:"websocket",dynamicVariables:{first_message:d,interview_language:x.label,interview_language_code:x.code},onConnect:()=>{he("active")},onDisconnect:()=>{oe()},onError:()=>{oe()},onMessage:Os,onModeChange:Js});C.current=o,vs(!W),R(F({reason:"task_start"})),R(`SYSTEM: Conduct this system design interview in ${x.label} (${x.code}) unless the candidate asks to switch language.`),(((s=qs.current)==null?void 0:s[(c==null?void 0:c.id)||""])||[]).length===0&&i.text&&(l?R(`Greeting should follow this first message: ${i.text}`):i.isLocalized?R(`Greeting must be in ${x.label} (${x.code}), not English. Start with this kickoff message: ${i.text}`):R(`Greeting must be in ${x.label} (${x.code}), not English. Translate and deliver this kickoff intent naturally in ${x.label}: ${i.text}`));const J=xs.current.trim();if(J&&(o!=null&&o.sendUserMessage))try{o.sendUserMessage(J),xs.current=""}catch{oe()}re.current=!1}catch{he("error"),re.current=!1}}},[Xs,Os,Js,F,R,c,oe,vs,W,x.code,x.label]),Xe=r.useCallback(async()=>{var s;if(re.current=!1,q(),U.current="",Z(),(s=C.current)!=null&&s.endSession)try{await C.current.endSession()}catch{}C.current=null,he("idle")},[q,Z]),et=()=>{var t,i;const s=Ns.trim();if(s){if(K("user",s),Ws(""),(t=C.current)!=null&&t.sendUserMessage){try{R(F({reason:"user_message",note:s})),C.current.sendUserMessage(s)}catch{oe()}return}xs.current=s,(i=ie.current)==null||i.call(ie),K("agent","AI interviewer is reconnecting. Please wait a moment.")}};r.useEffect(()=>{_t(!1)},[p==null?void 0:p.avatar]);const Kt=()=>{Dt(s=>{const t=!s;return vs(!t),t})},ce=r.useCallback(s=>{if(!s)return E.current;const t=Date.now(),i=Math.max(0,Math.round((t-fs.current)/1e3)),l={...E.current,[s]:(E.current[s]||0)+i};return E.current=l,fs.current=t,ts(l),l},[]),we=r.useCallback((s,t={})=>{const{skipFinalizeCurrent:i=!1}=t||{},l=Math.min(Math.max(s,1),b.length),h=b[y-1];!i&&(h!=null&&h.id)&&ce(h.id),Ne(l);const d=b[l-1];Ks(d==null?void 0:d.id);const o=pe[d==null?void 0:d.id]||ke();if(ye.current={elements:(o==null?void 0:o.elements)||[],appState:(o==null?void 0:o.appState)||{},files:(o==null?void 0:o.files)||{}},Ye.current=(o==null?void 0:o.elements)||[],He((o==null?void 0:o.elements)||[]),Ge((o==null?void 0:o.appState)||{}),Ve((o==null?void 0:o.files)||{}
2),ps.current="",ds.current="",gs.current="",q(),U.current="",Z(),C.current){R(F({reason:"task_switch",note:d==null?void 0:d.title}));const T=_s(d,x.code);T.text&&(x.code==="en"||T.isLocalized?R(`Greeting should follow this first message: ${T.text}`):R(`Greeting must be in ${x.label} (${x.code}), not English. Translate and deliver this kickoff intent naturally in ${x.label}: ${T.text}`)),y<b.length&&R(`Task handoff: move to task ${l}/${b.length}. Ask one short kickoff question, then wait for candidate.`)}},[b,y,pe,ce,R,F,Ks,q,Z,x.code,x.label]),Zt=()=>{y<b.length&&we(y+1)},Jt=()=>{y>1&&we(y-1)},st=r.useCallback(async({force:s=!0}={})=>{if(f&&!(ms.current&&!s)){ms.current=!0,Fs(!0),me(""),g?(N(j.FINALIZING),Me(!1)):Me(!0);try{const t=await fetch(`${G}/api/interview-feedback/evaluate`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({sessionId:f,force:s})}),i=await t.json();if(!t.ok)throw new Error((i==null?void 0:i.error)||"Failed to generate feedback");if(g){if(!Rn(i))throw new Error("The screening submission is not complete yet.");N(j.SUBMITTED)}else ns(i.feedbackByTask||{}),rs(i.feedbackOverall||null);return{feedbackByTask:i.feedbackByTask||{},feedbackOverall:i.feedbackOverall||null}}catch(t){throw ms.current=!1,me(g?"We could not finalize this submission. Please try again.":(t==null?void 0:t.message)||"Failed to generate feedback"),g&&N(j.ERROR),t}finally{Fs(!1)}}},[f,g]),ve=r.useCallback(async(s={})=>{f&&await fetch(`${G}/api/interview-sessions/${f}/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({sessionId:f,interviewId:Be||Ms,currentTask:y,taskDurations:E.current,messagesByTask:de,transcriptsByTask:fe,systemDesignStateByTask:pe,interviewLanguageCode:x.code,interviewLanguageLabel:x.label,...s})}).catch(()=>{})},[Be,y,de,f,pe,fe,x.code,x.label]),je=r.useCallback(async({auto:s=!1,forceFinalize:t=!1}={})=>{if(!be.current&&b.length){be.current=!0,Ue(!0),me("");try{const i=b[y-1],l=y>=b.length;if(!(t||l)){i!=null&&i.id&&ce(i.id),await ve({currentTask:y,taskDurations:E.current});const o=y+1;we(o,{skipFinalizeCurrent:!0}),s||Re("Task submitted","success",`Moved to task ${o}/${Y}.`);return}i!=null&&i.id&&ce(i.id),g&&N(j.FINALIZING),await ve({currentTask:y,taskDurations:E.current}),await Xe();const d=await st({force:!0});await ve({currentTask:y,taskDurations:E.current,feedbackByTask:(d==null?void 0:d.feedbackByTask)||{},feedbackOverall:(d==null?void 0:d.feedbackOverall)||null}),s&&Re("Interview submitted","info",g?"Time is up. Your response was sent for recruiter review.":"Time is up. Final feedback is ready.")}catch(i){const l=g?"We could not finalize this submission. Please try again.":(i==null?void 0:i.message)||"Failed to submit task.";me(l),g&&N(j.ERROR),s||Re("Submit failed","error",l)}finally{be.current=!1,Ue(!1)}}},[y,st,ce,g,ve,Xe,we,b,Y]),tt=r.useCallback(async()=>{if(!g){await je({forceFinalize:!0});return}if(!be.current){be.current=!0,Ue(!0),me(""),Ls(!0),N(j.FINALIZING);try{const s=b[y-1];s!=null&&s.id&&ce(s.id),await ve({currentTask:y,taskStatus:"ended",taskDurations:E.current}),await Xe(),await kn({apiBaseUrl:G||"",sessionId:f}),N(j.SUBMITTED),Me(!1)}catch{me("We could not confirm that the interview ended. Your work is still saved."),N(j.ERROR)}finally{be.current=!1,Ue(!1)}}},[y,ce,je,g,ve,f,Xe,b]);r.useEffect(()=>{if(!b.length){Ps(!1);return}(async()=>{var i,l,h,d,o,T,J;let t=!1;if(f)try{const le=await fetch(`${G}/api/interview-sessions/${f}`,{credentials:"include"});if(le.ok){const a=await le.json();if(a!=null&&a.systemDesignStateByTask){us(a.systemDesignStateByTask);const O=a!=null&&a.currentTask?(i=b[a.currentTask-1])==null?void 0:i.id:(l=b[0])==null?void 0:l.id,$e=b.find(ue=>(ue==null?void 0:ue.id)===O)||b[0],Rs=((h=a.systemDesignStateByTask)==null?void 0:h[O])||ke($e),H=wt($e,Rs);ye.current=H,Ye.current=H.elements||[],He(H.elements||[]),Ge(H.appState||{}),Ve(H.files||{}),t=!0}if(a!=null&&a.currentTask){const O=Number(a.currentTask)||1;Ne(Math.max(1,Math.min(O,b.length)))}a!=null&&a.messagesByTask&&ge(a.messagesByTask),a!=null&&a.transcriptsByTask&&We(a.transcriptsByTask),a!=null&&a.taskDurations&&ts(a.taskDurations),E.current=(a==null?void 0:a.taskDurations)||{},!g&&(a!=null&&a.feedbackByTask)&&ns(a.feedbackByTask),!g&&(a!=null&&a.feedbackOverall)&&rs(a.feedbackOverall),g&&(a==null?void 0:a.screeningEndedEarly)===!0?(Ls(!0),N(j.SUBMITTED)):g&&(a==null?void 0:a.screeningSubmissionComplete)===!0&&N(j.SUBMITTED)}}catch{}if(!t&&!g){const le=localStorage.getItem(Je);if(le)try{const a=JSON.parse(le);if(a!=null&&a.systemDesignStateByTask){us(a.systemDesignStateByTask);const O=a!=null&&a.currentTask?(d=b[a.currentTask-1])==null?void 0:d.id:(o=b[0])==null?void 0:o.id,$e=b.find(ue=>(ue==null?void 0:ue.id)===O)||b[0],Rs=((T=a.systemDesignStateByTask)==null?void 0:T[O])||ke($e),H=wt($e,Rs);ye.current=H,He(H.elements||[]),Ge(H.appState||{}),Ve(H.files||{})}
2if(a!=null&&a.currentTask){const O=Number(a.currentTask)||1;Ne(Math.max(1,Math.min(O,b.length)))}a!=null&&a.messagesByTask&&ge(a.messagesByTask),a!=null&&a.transcriptsByTask&&We(a.transcriptsByTask),a!=null&&a.taskDurations&&ts(a.taskDurations),E.current=(a==null?void 0:a.taskDurations)||{},a!=null&&a.feedbackByTask&&ns(a.feedbackByTask),a!=null&&a.feedbackOverall&&rs(a.feedbackOverall)}catch{}}(J=ye.current)!=null&&J.elements||(ye.current=ke(b[0])),Ps(!0)})()},[f,Je,b,g]),r.useEffect(()=>{E.current=Q||{}},[Q]),r.useEffect(()=>{ie.current=Qs},[Qs]),r.useEffect(()=>{if(!ee)return;De.current&&clearTimeout(De.current);const s={interviewId:Be||Ms,currentTask:y,messagesByTask:de,transcriptsByTask:fe,taskDurations:Q,feedbackByTask:Ie,feedbackOverall:v,systemDesignStateByTask:pe,interviewLanguageCode:x.code,interviewLanguageLabel:x.label};g||localStorage.setItem(Je,JSON.stringify(s)),f&&(De.current=setTimeout(()=>{fetch(`${G}/api/interview-sessions/${f}/save`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({sessionId:f,...s})}).catch(()=>{})},600))},[ls,Bt,Lt,pe,de,fe,Q,Ie,v,Je,f,ee,y,Be,x.code,x.label,g]),r.useEffect(()=>{if(!C.current||!ee)return;ne.current&&clearTimeout(ne.current);const s=vt(ls),t=jt(s);return ne.current=setTimeout(()=>{t!==ds.current&&(ds.current=t,R(F({reason:"diagram_update"})))},4e3),()=>{ne.current&&clearTimeout(ne.current)}},[ls,ee,R,F]),r.useEffect(()=>{if(!ee||!Y)return;const s=setTimeout(()=>{var t;(t=ie.current)==null||t.call(ie)},2e3);return()=>clearTimeout(s)},[ee,Y]),r.useEffect(()=>{if(!ee||!k)return;const s=ze.current[k]||{oneMinute:!1,threeSeconds:!1,timeUp:!1};Se<=60&&Se>0&&!s.oneMinute&&(s.oneMinute=!0,ze.current[k]=s,K("system","1 minute left on this task. Please wrap up your design."),R(F({reason:"time_warning",note:"1 minute left. Ask candidate for final tradeoffs and bottlenecks."})),Re("1 minute left","warning","Wrap up this task with final tradeoffs.")),Se===3&&!s.threeSeconds&&(s.threeSeconds=!0,ze.current[k]=s,K("system","3 seconds left. Auto-advancing shortly."),R(F({reason:"time_warning",note:"3 seconds left. Give a very short wrap-up prompt."})),Re("3 seconds left","warning","Auto-advancing to the next task.")),Se<=0&&!s.timeUp&&(s.timeUp=!0,ze.current[k]=s,y<Y?(K("system",`Time is up. Moving to Task ${y+1}/${Y}.`),Re("Time is up","info",`Moving to task ${y+1}.`),we(y+1)):(K("system","Time is up. Submitting your final result."),je({auto:!0})))},[K,F,y,k,je,ee,R,we,Se,Y]),r.useEffect(()=>()=>{var s;re.current=!1,q(),U.current="",Z(),ne.current&&clearTimeout(ne.current),De.current&&clearTimeout(De.current),(s=C.current)!=null&&s.endSession&&C.current.endSession().catch(()=>{})},[q,Z]),r.useEffect(()=>{const s=setInterval(()=>{Et(Math.floor(Date.now()/1e3))},1e3);return()=>clearInterval(s)},[]);const nt=r.useMemo(()=>de[k]||[],[de,k]),js=r.useRef(!1),Ot=()=>{if(js.current)return;const s=Ss.current;if(!s)return;const t=s.scrollHeight-s.scrollTop-s.clientHeight;ws.current=t<60},rt=()=>{const s=Ss.current;s&&(js.current=!0,s.scrollTop=s.scrollHeight,requestAnimationFrame(()=>{js.current=!1}))};return r.useEffect(()=>{if(!ws.current)return;rt();const s=setInterval(()=>{if(!ws.current){clearInterval(s);return}rt()},100),t=setTimeout(()=>clearInterval(s),5e3);return()=>{clearInterval(s),clearTimeout(t)}},[nt,qe]),$s?e.jsx(B,{h:"100vh",align:"center",justify:"center",bg:"#ffffff",p:6,children:e.jsxs(L,{spacing:4,textAlign:"center",maxW:"440px",children:[e.jsx(m,{fontSize:"xl",fontWeight:"700",children:"Assessment unavailable"}),e.jsx(m,{color:"gray.600",children:$s}),e.jsx(_,{onClick:()=>window.location.reload(),children:"Try again"})]})}):It||!c?e.jsxs(B,{direction:"column",h:"100vh",bg:"#ffffff",position:"relative",children:[e.jsxs(S,{position:"relative",h:"64px",bg:"#ffffff",children:[e.jsx(B,{h:"100%",align:"center",justify:"center",children:e.jsxs(D,{spacing:3,children:[e.jsx(I,{h:"34px",w:"72px",borderRadius:"10px"}),e.jsx(I,{h:"34px",w:"124px",borderRadius:"9999px"})]})}),e.jsxs(D,{position:"absolute",top:"0",right:"16px",h:"64px",spacing:3,children:[e.jsx(I,{h:"34px",w:"120px",borderRadius:"10px"}),e.jsx(I,{h:"20px",w:"70px",borderRadius:"8px"})]})]}),e.jsxs(B,{flex:"1",minH:0,pt:"6px",px:3,pb:3,gap:3,children:[e.jsx(S,{flex:{base:"1",xl:"1"},minW:{base:0,xl:"380px"}
2,maxW:{base:"100%",xl:"560px"},border:"1px solid",borderColor:"gray.200",borderRadius:"20px",p:4,bg:"white",children:e.jsxs(L,{align:"stretch",spacing:4,children:[e.jsxs(D,{spacing:3,children:[e.jsx(I,{h:"30px",w:"120px",borderRadius:"8px"}),e.jsx(I,{h:"30px",w:"110px",borderRadius:"8px"})]}),e.jsx(I,{h:"28px",w:"72%",borderRadius:"8px"}),e.jsx(I,{h:"18px",w:"94%",borderRadius:"8px"}),e.jsx(I,{h:"18px",w:"86%",borderRadius:"8px"}),e.jsx(I,{h:"14px",w:"120px",borderRadius:"6px"}),e.jsx(I,{h:"120px",w:"100%",borderRadius:"14px"}),e.jsx(I,{h:"160px",w:"100%",borderRadius:"14px"})]})}),e.jsx(S,{flex:"2",border:"1px solid",borderColor:"gray.200",borderRadius:"20px",overflow:"hidden",minH:"70vh",bg:"white",p:4,children:e.jsxs(L,{align:"stretch",spacing:3,h:"100%",children:[e.jsx(I,{h:"36px",w:"240px",borderRadius:"8px"}),e.jsx(I,{h:"20px",w:"160px",borderRadius:"8px"}),e.jsx(I,{flex:"1",minH:"520px",borderRadius:"14px"})]})})]})]}):e.jsxs(B,{direction:"column",h:"100vh",bg:"#ffffff",position:"relative",children:[e.jsxs(S,{position:"relative",h:"64px",bg:"#ffffff",children:[e.jsx(vn,{interviewData:Pt,callStatus:"inactive",showCopilotButton:!1,position:"absolute",top:"8px",left:"14px"}),e.jsx(B,{h:"100%",align:"center",justify:"center",children:e.jsxs(D,{spacing:3,children:[e.jsx(_,{size:"sm",variant:"outline",leftIcon:e.jsx(tn,{}),borderRadius:"9999px",borderColor:"gray.300",color:"gray.700",bg:"white",_hover:{bg:"gray.50",borderColor:"gray.400"},onClick:()=>n("/coding-interviews"),children:"Interviews"}),e.jsx(Fe,{"aria-label":"Previous task",icon:e.jsx(nn,{}),size:"sm",variant:"ghost",onClick:Jt,isDisabled:y===1}),e.jsx(S,{px:4,py:1.5,borderRadius:"9999px",bg:"white",border:"1px solid #d1d5db",children:e.jsxs(m,{fontSize:"sm",fontWeight:"700",color:"#1f2937",children:["Task ",y,"/",Y]})}),e.jsx(Fe,{"aria-label":"Next task",icon:e.jsx(rn,{}),size:"sm",variant:"ghost",onClick:Zt,isDisabled:y===Y})]})}),e.jsxs(D,{position:"absolute",top:"0",right:"16px",h:"64px",spacing:3,color:"gray.700",children:[e.jsx(_,{size:"sm",leftIcon:e.jsx(ut,{}),bg:"#111827",color:"white",_hover:{bg:"#1f2937"},borderRadius:"10px",onClick:()=>je(),isLoading:as||Pe,isDisabled:as||Pe,children:"Submit"}),e.jsx(ks,{as:an}),e.jsx(m,{fontWeight:"600",children:Ht(Se)})]})]}),e.jsxs(B,{gap:6,align:"stretch",px:{base:4,md:8},py:4,flex:"1",minH:0,children:[e.jsx(S,{flex:"1",minW:"320px",maxW:"420p
2x",minH:0,display:"flex",flexDirection:"column",children:e.jsx(S,{borderRadius:"16px",p:4,flex:"1",minH:0,children:e.jsxs(on,{variant:"unstyled",display:"flex",flexDirection:"column",h:"100%",defaultIndex:0,children:[e.jsxs(cn,{px:1,pb:2,display:"flex",alignItems:"center",children:[e.jsxs(D,{spacing:6,children:[e.jsx(dt,{fontSize:"sm",fontWeight:"semibold",color:"gray.500",_selected:{color:"gray.900",borderBottom:"2px solid",borderColor:"gray.900"},pb:2,children:"Conversation"}),e.jsx(dt,{fontSize:"sm",fontWeight:"semibold",color:"gray.500",_selected:{color:"gray.900",borderBottom:"2px solid",borderColor:"gray.900"},pb:2,children:"Description"})]}),e.jsx(ln,{})]}),e.jsxs(un,{flex:"1",overflow:"hidden",children:[e.jsx(gt,{p:0,h:"100%",children:e.jsxs(B,{h:"100%",direction:"column",gap:3,children:[e.jsx(S,{ref:Ss,flex:"1",overflowY:"auto",pr:1,onScroll:Ot,sx:{"&::-webkit-scrollbar":{display:"none"},scrollbarWidth:"none",msOverflowStyle:"none"},children:e.jsxs(L,{align:"stretch",spacing:3,children:[e.jsxs(S,{bg:"#F3F4F6",borderRadius:"xl",p:4,border:"1px solid",borderColor:"#E5E7EB",w:"100%",maxW:"100%",alignSelf:"stretch",boxShadow:"sm",children:[e.jsxs(D,{justify:"space-between",mb:2,children:[e.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:"gray.800",children:"Problem Statement"}),e.jsx(m,{fontSize:"xs",color:"gray.500",children:"This message will be auto‑pinned"})]}),e.jsx(m,{fontSize:"sm",color:"gray.700",lineHeight:"tall",children:c==null?void 0:c.prompt}),e.jsx(m,{fontSize:"sm",color:"gray.800",fontWeight:"semibold",mt:3,children:"Requirements"}),e.jsx(L,{align:"start",spacing:2,mt:2,children:((c==null?void 0:c.requirements)||[]).map(s=>e.jsxs(m,{fontSize:"sm",color:"gray.700",children:["• ",s]},s))})]}),e.jsx(yn,{messages:nt,isTyping:Vt,isUserSpeaking:Yt,userAvatar:qt,userName:Ut}),Ce==="connecting"&&e.jsxs(D,{spacing:2,children:[e.jsx(Ts,{size:"sm"}),e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Preparing the AI interviewer…"})]}),Bs&&e.jsx(m,{fontSize:"xs",color:"red.500",children:Bs})]})}),e.jsx(S,{mt:1,children:e.jsxs(S,{bg:"#FFFFFF",borderRadius:"2xl",px:4,py:3,border:"1px solid",borderColor:"#E5E7EB",_focusWithin:{borderColor:"#D1D5DB",boxShadow:"0 0 0 1px rgba(0,0,0,0.03)"},display:"flex",alignItems:"center",gap:3,children:[e.jsx(dn,{value:Ns,onChange:s=>Ws(s.target.value),onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),et())},placeholder:"Ask the interviewer…",variant:"unstyled",resize:"none",rows:2,fontSize:"sm",bg:"transparent",color:"gray.900",_placeholder:{color:"#9CA3AF"},flex:"1"}),e.jsx(Fe,{"aria-label":"Send",icon:e.jsx(gn,{}),onClick:et,size:"sm",borderRadius:"full",bg:"#A1A1AA",color:"white",_hover:{bg:"#6B7280"}})]})})]})}),e.jsx(gt,{p:0,h:"100%",children:e.jsxs(L,{h:"100%",overflowY:"auto",align:"stretch",spacing:4,pr:1,children:[e.jsxs(S,{children:[e.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:"gray.900",mb:2,children:c==null?void 0:c.title}),e.jsx(m,{fontSize:"sm",color:"gray.700",lineHeight:"tall",children:c==null?void 0:c.prompt})]}),e.jsxs(S,{children:[e.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:"gray.900",mb:2,children:"Requirements"}),e.jsx(L,{align:"stretch",spacing:2,children:((c==null?void 0:c.requirements)||[]).map(s=>e.jsxs(m,{fontSize:"sm",color:"gray.700",children:["• ",s]},s))})]}),e.jsxs(S,{children:[e.jsxs(m,{fontSize:"sm",color:"gray.600",children:["Difficulty: ",(c==null?void 0:c.difficulty)||"medium"]}),e.jsxs(m,{fontSize:"sm",color:"gray.600",mt:1,children:["Estimated time: ",(c==null?void 0:c.estimated_minutes)||10," min"]})]}),e.jsxs(S,{children:[e.jsxs(D,{justify:"space-between",align:"center",mb:2,children:[e.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:"gray.900",children:"Reference Diagram (SVG)"}),ae?e.jsxs(D,{spacing:2,children:[e.jsx(_,{size:"xs",variant:"outline",borderColor:"gray.300",onClick:Vs,isDisabled:P<=zs,children:"-"}),e.jsxs(_,{size:"xs",variant:"outline",borderColor:"gray.300",onClick:Ys,children:[Math.round(P*100),"%"]}),e.jsx(_,{size:"xs",variant:"outline",borderColor:"gray.300",onClick:Gs,isDisabled:P>=Es,children:"+"}),e.jsx(_,{size:"xs",variant:"outline",borderColor:"gray.300",onClick:Hs,children:"Open full diagram"})]}):null]}),ae?e.jsxs(S,{border:"1px solid",borderColor:"gray.200",borderRadius:"lg",p:2,bg:"white",children:[e.jsx(m,{fontSize:"xs",color:"gray.500",mb:2,children:"Tip: click diagram to open full view."}),e.jsx(S,{as:"img",src:ae,alt:`${(c==null?void 0:c.title)||"System design"} source diagram`,maxW:"none",minW:`${Math.round(P*100)}%`,w:`${Math.round(P*100)}%`,h:"auto",borderRadius:"md",cursor:"zoom-in",onClick:Hs})]}):e.jsx(m,{fontSize:"sm",color:"gray.500",children:"No source SVG found for this task."})]})]})})]})]})})}),e.jsxs(S,{className:"system-design-excalidraw",flex:"2",border:"1px solid",borderColor:"gray.200",borderRadius:"20px",overflow:"hidden",minH:"70vh",children:[e.jsx("style",{children:`
3            .system-design-excalidraw .excalidraw {
4              --color-primary: #e5e7eb !important;
5              --color-primary-darker: #cbd5e1 !important;
6              --color-primary-light: #f3f4f6 !important;
7              --color-primary-contrast-offset: #111827 !important;
8            }
9
10            .system-design-excalidraw .main-menu-trigger,
11            .system-design-excalidraw .ToolIcon__lock,
12            .system-design-excalidraw .library-menu-trigger,
13            .system-design-excalidraw .help-icon,
14            .system-design-excalidraw .App-toolbar__divider,
15            .system-design-excalidraw [aria-label="Menu"],
16            .system-design-excalidraw [title="Menu"],
17            .system-design-excalidraw [aria-label="Keep selected tool active after drawing"],
18            .system-design-excalidraw [title="Keep selected tool active after drawing"],
19            .system-design-excalidraw [aria-label="Insert image"],
20            .system-design-excalidraw [title="Insert image"],
21            .system-design-excalidraw [aria-label="More tools"],
22            .system-design-excalidraw [title="More tools"],
23            .system-design-excalidraw [aria-label="Library"],
24            .system-design-excalidraw [title="Library"],
25            .system-design-excalidraw [aria-label="Help"],
26            .system-design-excalidraw [title="Help"],
27            .system-design-excalidraw [aria-keyshortcuts="?"] {
28              display: none !important;
29            }
30
31            .system-design-excalidraw .ToolIcon_type_button.is-selected,
32            .system-design-excalidraw .ToolIcon_type_button:has(input:checked),
33            .system-design-excalidraw .ToolIcon_type_button[aria-pressed="true"] {
34              background: #e5e7eb !important;
35              color: #111827 !important;
36            }
37
38            .system-design-excalidraw .layer-ui__wrapper__footer {
39              display: flex !important;
40              justify-content: flex-end !important;
41              align-items: flex-end !important;
42              padding: 0 16px 14px !important;
43              box-sizing: border-box !important;
44            }
45
46            .system-design-excalidraw .layer-ui__wrapper__footer .layer-ui__wrapper__footer-left {
47              margin-left: auto !important;
48              transform: none !important;
49            }
50          `}),e.jsx(fn.Excalidraw,{UIOptions:{tools:{image:!1},canvasActions:{clearCanvas:!1,loadScene:!1,saveToActiveFile:!1,saveAsImage:!1,export:!1,toggleTheme:!1,changeViewBackgroun
50dColor:!1}},initialData:ye.current,onChange:(s,t,i)=>{var d;const l={elements:(s||[]).map(o=>({id:o.id,type:o.type,x:Math.round(o.x||0),y:Math.round(o.y||0),w:Math.round(o.width||0),h:Math.round(o.height||0),deleted:!!o.isDeleted,text:o.text||"",v:o.version||0})),zoom:((d=t==null?void 0:t.zoom)==null?void 0:d.value)||(t==null?void 0:t.zoom)||1,files:Object.keys(i||{})},h=jt(l);h!==ps.current&&(ps.current=h,Ye.current=s||[],He(s),Ge(t),Ve(i||{}),k&&us(o=>({...o,[k]:{elements:s||[],appState:t||{},files:i||{}}})))}},k)]})]}),e.jsx(S,{position:"fixed",left:"50%",bottom:"24px",transform:"translateX(-50%)",zIndex:"1000",children:e.jsxs(D,{bg:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(20px)",borderRadius:"full",p:2,spacing:5,boxShadow:"0 20px 40px -10px rgba(0,0,0,0.15)",border:"1px solid",borderColor:"gray.200",pr:4,children:[e.jsx(S,{w:"48px",h:"52px",display:"flex",alignItems:"center",justifyContent:"center",position:"relative",children:e.jsx(jn,{agent:"screening",status:Ce,voiceState:se,size:40})}),e.jsxs(L,{align:"flex-start",spacing:0,pr:2,children:[e.jsx(m,{fontWeight:"bold",fontSize:"sm",color:"gray.800",children:"Voice Chat"}),e.jsx(Is,{label:Zs,bg:"black",color:"white",hasArrow:!0,children:e.jsxs(D,{spacing:1,children:[e.jsx(S,{w:"6px",h:"6px",borderRadius:"full",bg:Gt}),e.jsx(m,{fontSize:"xs",color:"gray.500",fontWeight:"medium",children:Zs}),e.jsx(D,{spacing:"2px",ml:2,children:[.2,.5,.8].map((s,t)=>e.jsx(S,{w:"3px",h:W&&se==="listening"&&Ft.current>s?"10px":"6px",borderRadius:"full",bg:W&&se==="listening"?"blue.500":"gray.300",transition:"all 120ms ease"},`mic-${t}`))})]})})]}),e.jsx(S,{h:"24px",w:"1px",bg:"gray.200"}),e.jsx(Is,{label:W?"Mute Microphone":"Unmute Microphone",bg:"black",color:"white",hasArrow:!0,children:e.jsx(Fe,{icon:W?e.jsx(mn,{size:"20px"}):e.jsx(hn,{size:"20px"}),onClick:Kt,borderRadius:"full",color:W?"gray.700":"red.500",bg:W?"transparent":"red.50",_hover:{bg:W?"gray.100":"red.100"},variant:"ghost","aria-label":"Toggle Mic",size:"md"})}),e.jsx(Is,{label:"End Interview",bg:"red.500",color:"white",hasArrow:!0,children:e.jsx(Fe,{icon:e.jsx(ft,{size:"20px"}),onClick:tt,borderRadius:"full",bg:"red.50",color:"red.500",_hover:{bg:"red.500",color:"white"},variant:"ghost","aria-label":"End Interview",size:"md",isDisabled:as||Pe})})]})}),e.jsxs(mt,{isOpen:$t,onClose:Nt,size:"full",children:[e.jsx(ht,{bg:"whiteAlpha.900"}),e.jsxs(xt,{bg:"white",children:[e.jsx(pt,{pr:12,children:"Reference Diagram"}),e.jsx(xn,{}),e.jsx(bt,{pb:6,children:ae?e.jsxs(L,{align:"stretch",spacing:3,children:[e.jsxs(B,{align:"center",justify:"space-between",gap:3,flexWrap:"wrap",children:[e.jsx(m,{fontSize:"sm",color:"gray.600",children:"Hold Ctrl/Cmd and scroll to zoom."}),e.jsxs(D,{spacing:2,children:[e.jsx(_,{size:"sm",variant:"outline",borderColor:"gray.300",onClick:Vs,isDisabled:P<=zs,children:"-"}),e.jsxs(_,{size:"sm",variant:"outline",borderColor:"gray.300",onClick:Ys,children:[Math.round(P*100),"%"]}),e.jsx(_,{size:"sm",variant:"outline",borderColor:"gray.300",onClick:Gs,isDisabled:P>=Es,children:"+"})]})]}),e.jsx(S,{border:"1px solid",borderColor:"gray.200",borderRadius:"12px",h:"calc(100vh - 180px)",overflow:"auto",onWheel:Wt,p:2,children:e.jsx(S,{as:"img",src:ae,alt:`${(c==null?void 0:c.title)||"System design"} source diagram`,h:"auto",borderRadius:"8px",maxW:"none",minW:`${Math.round(P*100)}%`,w:`${Math.round(P*100)}%`})})]}):e.jsx(m,{fontSize:"sm",color:"gray.500",children:"No source SVG found for this task."})})]})]}),g&&V!==j.IDLE?e.jsx(B,{position:"absolute",inset:0,zIndex:2e3,bg:"rgba(248, 250, 252, 0.92)",backdropFilter:"blur(8px)",align:"center",justify:"center",p:6,children:e.jsxs(L,{spacing:4,bg:"white",border:"1px solid",borderColor:"gray.200",borderRadius:"xl",boxShadow:"2xl",maxW:"480px",w:"100%",p:8,textAlign:"center",children:[V===j.SUBMITTED?e.jsx(ks,{as:ut,boxSize:10,color:"green.500"}):V===j.ERROR?e.jsx(ks,{as:ft,boxSize:10,color:"red.500"}):e.jsx(Ts,{size:"md"}),e.jsx(m,{fontSize:"xl",fontWeight:"700",children:V===j.SUBMITTED?is?"Interview ended":"Round submitted":V===j.ERROR?"Submission needs another try":"Finalizing submission"}),e.jsx(m,{color:"gray.600",fontSize:"sm",children:V===j.SUBMITTED?is?"Your saved work was sent to the recruiter. They will follow up with 
50next steps.":"Your response was submitted for recruiter review. Results are not shown during a screening assessment.":V===j.ERROR?"We could not confirm the final submission. Your work is still saved.":"Please keep this tab open while we securely finish the round."}),V===j.ERROR?e.jsx(_,{onClick:()=>is?tt():je({forceFinalize:!0}),children:"Try again"}):null,V===j.SUBMITTED?e.jsx(_,{bg:"#111827",color:"white",_hover:{bg:"#1f2937"},onClick:()=>Tn(window),children:"Return to assessment"}):null,e.jsx(m,{color:"gray.500",fontSize:"xs",children:"If this tab does not close automatically, close it and return to the assessment tab."})]})}):null,e.jsxs(mt,{isOpen:!g&&Mt,onClose:()=>Me(!1),size:"lg",isCentered:!0,children:[e.jsx(ht,{}),e.jsxs(xt,{borderRadius:"xl",children:[e.jsx(pt,{fontSize:"md",children:"System Design Interview Summary"}),e.jsx(bt,{children:Pe?e.jsxs(B,{align:"center",gap:2,children:[e.jsx(Ts,{size:"sm"}),e.jsx(m,{fontSize:"sm",children:"Generating feedback…"})]}):e.jsxs(L,{align:"stretch",spacing:4,children:[b.map(s=>{const t=Ie==null?void 0:Ie[s.id];return e.jsxs(S,{border:"1px solid",borderColor:"gray.200",borderRadius:"lg",p:3,children:[e.jsx(m,{fontWeight:"semibold",fontSize:"sm",children:s.title}),e.jsx(m,{fontSize:"xs",color:"gray.500",mt:1,children:(t==null?void 0:t.summary)||"No feedback yet."}),A(t==null?void 0:t.strengths).length>0&&e.jsxs(S,{mt:2,children:[e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Strengths"}),A(t==null?void 0:t.strengths).map((i,l)=>e.jsxs(m,{fontSize:"xs",children:["• ",i]},`${s.id}-s-${l}`))]}),A(t==null?void 0:t.weaknesses).length>0&&e.jsxs(S,{mt:2,children:[e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Weaknesses"}),A(t==null?void 0:t.weaknesses).map((i,l)=>e.jsxs(m,{fontSize:"xs",children:["• ",i]},`${s.id}-w-${l}`))]}),A(t==null?void 0:t.recommendations).length>0&&e.jsxs(S,{mt:2,children:[e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Recommendations"}),A(t==null?void 0:t.recommendations).map((i,l)=>e.jsxs(m,{fontSize:"xs",children:["• ",i]},`${s.id}-r-${l}`))]})]},s.id)}),(v==null?void 0:v.summary)&&e.jsxs(S,{border:"1px solid",borderColor:"gray.200",borderRadius:"lg",p:3,children:[e.jsx(m,{fontWeight:"semibold",fontSize:"sm",children:"Overall Feedback"}),e.jsx(m,{fontSize:"xs",color:"gray.600",mt:1,children:v.summary}),A(v==null?void 0:v.strengths).length>0&&e.jsxs(S,{mt:2,children:[e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Strengths"}),A(v==null?void 0:v.strengths).map((s,t)=>e.jsxs(m,{fontSize:"xs",children:["• ",s]},`overall-s-${t}`))]}),A(v==null?void 0:v.weaknesses).length>0&&e.jsxs(S,{mt:2,children:[e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Weaknesses"}),A(v==null?void 0:v.weaknesses).map((s,t)=>e.jsxs(m,{fontSize:"xs",children:["• ",s]},`overall-w-${t}`))]}),A(v==null?void 0:v.recommendations).length>0&&e.jsxs(S,{mt:2,children:[e.jsx(m,{fontSize:"xs",color:"gray.500",children:"Recommendations"}),A(v==null?void 0:v.recommendations).map((s,t)=>e.jsxs(m,{fontSize:"xs",children:["• ",s]},`overall-r-${t}`))]})]})]})}),e.jsxs(pn,{children:[e.jsx(_,{variant:"outline",size:"sm",mr:2,onClick:()=>n("/coding-interviews"),children:"Back to Coding Interviews"}),e.jsx(_,{variant:"ghost",size:"sm",onClick:()=>Me(!1),children:"Close"})]})]})]})]})}export{Ln 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.