interview-widget 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(A,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],o):(A=typeof globalThis<"u"?globalThis:A||self,o(A.InterviewWidget={},A.React,A.ReactDOM))})(this,function(A,o,B){"use strict";var Kt=Object.defineProperty;var Jt=(A,o,B)=>o in A?Kt(A,o,{enumerable:!0,configurable:!0,writable:!0,value:B}):A[o]=B;var _=(A,o,B)=>Jt(A,typeof o!="symbol"?o+"":o,B);var ae=typeof document<"u"?document.currentScript:null,ve={exports:{}},ee={};/**
1
+ (function(A,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],o):(A=typeof globalThis<"u"?globalThis:A||self,o(A.InterviewWidget={},A.React,A.ReactDOM))})(this,function(A,o,B){"use strict";var Jt=Object.defineProperty;var Xt=(A,o,B)=>o in A?Jt(A,o,{enumerable:!0,configurable:!0,writable:!0,value:B}):A[o]=B;var R=(A,o,B)=>Xt(A,typeof o!="symbol"?o+"":o,B);var oe=typeof document<"u"?document.currentScript:null,je={exports:{}},ee={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Oe=Symbol.for("react.transitional.element"),Ue=Symbol.for("react.fragment");function je(i,r,t){var s=null;if(t!==void 0&&(s=""+t),r.key!==void 0&&(s=""+r.key),"key"in r){t={};for(var n in r)n!=="key"&&(t[n]=r[n])}else t=r;return r=t.ref,{$$typeof:Oe,type:i,key:s,ref:r!==void 0?r:null,props:t}}ee.Fragment=Ue,ee.jsx=je,ee.jsxs=je,ve.exports=ee;var e=ve.exports;const oe={},F={api:{baseUrl:"/api",retryConfig:{attempts:3,backoff:"exponential",baseDelay:1e3}},ui:{baseColor:"#3B82F6",borderRadius:"8px"},interview:{timers:{thinkingDuration:30,answeringDuration:120,editingDuration:30},stt:{provider:"groq",model:"whisper-large-v3-turbo",language:"en"},tts:{provider:"piper"},proctoring:{enabled:!0}}},le="iw-storage";function qe(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ae&&ae.tagName.toUpperCase()==="SCRIPT"&&ae.src||new URL("widget.umd.js",document.baseURI).href}<"u"&&(oe!=null&&oe.VITE_IW_SECRET)))return typeof process<"u"&&process.env.NEXT_PUBLIC_IW_SECRET?process.env.NEXT_PUBLIC_IW_SECRET:typeof window<"u"&&window.__IW_SECRET__?window.__IW_SECRET__:"proctoring-data-seed"}const ke=qe(),ce="AES-GCM",de=12;async function Ne(i){const t=new TextEncoder().encode(i),s=await crypto.subtle.digest("SHA-256",t);return crypto.subtle.importKey("raw",s,ce,!1,["encrypt","decrypt"])}function We(){return crypto.getRandomValues(new Uint8Array(de))}async function Be(i,r="default-seed"){try{const t=typeof i=="string"?i:JSON.stringify(i),n=new TextEncoder().encode(t),l=await Ne(r),a=We(),c=await crypto.subtle.encrypt({name:ce,iv:a},l,n),u=new Uint8Array(a.length+c.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(u)))}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt data")}}async function Ge(i,r="default-seed"){try{const t=atob(i),s=new Uint8Array(t.length);for(let w=0;w<t.length;w++)s[w]=t.charCodeAt(w);const n=s.slice(0,de),l=s.slice(de),a=await Ne(r),c=await crypto.subtle.decrypt({name:ce,iv:n},a,l);return new TextDecoder().decode(c)}catch(t){throw console.error("Decryption failed:",t),new Error("Failed to decrypt data")}}async function Ve(i,r="default-seed"){return Be(i,r)}async function ze(i,r="default-seed"){const t=await Ge(i,r);try{return JSON.parse(t)}catch{return t}}const te=o.createContext(null),He=async()=>{var i,r;try{const t=sessionStorage.getItem(le);if(t){const s=await ze(t,ke);return{logViolations:((i=s.state)==null?void 0:i.logViolations)||[],totalViolations:((r=s.state)==null?void 0:r.totalViolations)||0}}}catch(t){console.error("Failed to load proctoring data from session storage:",t)}return{logViolations:[],totalViolations:0}},Ee=async i=>{try{const r=await Ve({state:i,version:0},ke);sessionStorage.setItem(le,r)}catch(r){console.error("Failed to save proctoring data to session storage:",r)}},Ye=({children:i})=>{const r=o.useRef({logViolations:[],totalViolations:0}),t=o.useRef(new Set);o.useEffect(()=>{He().then(w=>{r.current=w,s()})},[]);const s=o.useCallback(()=>{t.current.forEach(w=>w())},[]),n=o.useCallback(w=>(t.current.add(w),()=>{t.current.delete(w)}),[]),l=o.useCallback(()=>r.current,[]),a=o.useCallback(w=>{r.current={logViolations:[...r.current.logViolations,w],totalViolations:r.current.totalViolations+1},Ee(r.current),s()},[s]),c=o.useCallback(()=>{r.current={logViolations:[],totalViolations:0},Ee(r.current),s()},[s]),u=o.useMemo(()=>({getState:l,addViolation:a,clearViolations:c,subscribe:n}),[l,a,c,n]);return e.jsx(te.Provider,{value:u,children:i})},Qe=()=>{const i=o.useContext(te);if(!i)throw new Error("useViolations must be used within a ProctoringProvider");return o.useSyncExternalStore(i.subscribe,()=>i.getState().logViolations,()=>i.getState().logViolations)},Ke=()=>{const i=o.useContext(te);if(!i)throw new Error("useTotalViolations must be used within a ProctoringProvider");return o.useSyncExternalStore(i.subscribe,()=>i.getState().totalViolations,()=>i.getState().totalViolations)},Je=()=>{const i=o.useContext(te);if(!i)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:i.addViolation,clearViolations:i.clearViolations}},Ce=o.createContext(null);function Se({config:i={},children:r}){var s,n,l,a;const t={api:{...F.api,...i.api,retryConfig:{...F.api.retryConfig,...(s=i.api)==null?void 0:s.retryConfig}},ui:{...F.ui,...i.ui},interview:{...F.interview,...i.interview,timers:{...F.interview.timers,...(n=i.interview)==null?void 0:n.timers},stt:{...F.interview.stt,...(l=i.interview)==null?void 0:l.stt},tts:{...F.interview.tts,...(a=i.interview)==null?void 0:a.tts}}};return e.jsx(Ce.Provider,{value:t,children:e.jsx(Ye,{children:r})})}function ie(){const i=o.useContext(Ce);if(!i)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return i}function Te(){return ie().api||F.api}function V(){return ie().ui||F.ui}function Xe(){return ie().interview||F.interview}const Ie=({className:i,...r})=>e.jsx("div",{children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`iw-animate-spin ${i}`,...r,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M12 6l0 -3"}),e.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),e.jsx("path",{d:"M18 12l3 0"}),e.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),e.jsx("path",{d:"M12 18l0 3"}),e.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),e.jsx("path",{d:"M6 12l-3 0"}),e.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),Me=({children:i,variant:r="primary",size:t="md",fullWidth:s=!1,isLoading:n=!1,disabled:l,className:a="",...c})=>{const u="iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2",w={primary:"iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",secondary:"iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",outline:"iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",text:"iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",gradient:"iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"},h={sm:"iw-px-3 iw-py-1.5 iw-text-sm",md:"iw-px-4 iw-py-2.5 iw-text-sm",lg:"iw-px-5 iw-py-3 iw-text-base"},m="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",f=s?"iw-w-full":"";return e.jsxs("button",{className:`${u} ${w[r]} ${h[t]} ${f} ${m} ${a}`,disabled:l||n,...c,children:[n&&e.jsx(Ie,{height:16,width:16,style:{marginRight:"3px"}}),i]})};function Ze(i){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function et(i,r,t){return"#"+[i,r,t].map(s=>{const n=Math.round(s).toString(16);return n.length===1?"0"+n:n}).join("")}function Ae(i,r){const t=Ze(i);if(!t)return i;const s=t.r+(255-t.r)*r,n=t.g+(255-t.g)*r,l=t.b+(255-t.b)*r;return et(s,n,l)}function tt(i,r=.8){return{background:`linear-gradient(to bottom, ${Ae(i,r)}, #ffffff)`,color:"#1f2937"}}function it(i){return new Promise(r=>setTimeout(r,i))}function De(i){return`linear-gradient(to left, ${Ae(i,.4)}, ${i})`}const rt=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function st(i){try{const r=i.split(".");if(r.length!==3||!r[1])throw new Error("Invalid JWT token");const s=r[1].replace(/-/g,"+").replace(/_/g,"/"),n=s.padEnd(s.length+(4-s.length%4)%4,"="),l=atob(n);return JSON.parse(l)}catch(r){return console.error("Error decoding JWT:",r),null}}const Re=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}),_e=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),nt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M15 8a5 5 0 0 1 0 8"}),e.jsx("path",{d:"M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a.8 .8 0 0 1 1.5 .5v14a.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"})]}),G=i=>{const{baseColor:r,borderRadius:t}=V(),{loading:s,children:n,...l}=i;return e.jsx(Me,{style:{background:De(r),borderRadius:t},...l,children:s?e.jsx(Ie,{}):n})},at=["Do not refresh or reload the page during your assessment","Refrain from switching tabs or opening other applications while the session is in progress","Ensure your face remains clearly visible on camera at all times","Avoid frequent distractions or leaving your seat during the session","Do not disable or interfere with audio/video monitoring"],ot=({isOpen:i,onStart:r,onClose:t})=>{var T;const s=o.useRef(null),n=o.useRef(null),{baseColor:l,borderRadius:a}=V(),[c,u]=o.useState(!1),[w,h]=o.useState(null),[m,f]=o.useState(!1),d=l??"#2563eb",p=De(d),y=a??18,k=(x,M)=>x.startsWith("#")&&x.length===7?`${x}${M}`:x,g=[`radial-gradient(120% 85% at 50% 125%, ${k(d,"34")} 0%, transparent 70%)`,`radial-gradient(90% 70% at 10% 130%, ${k(d,"24")} 0%, transparent 72%)`,`radial-gradient(90% 70% at 90% 130%, ${k(d,"24")} 0%, transparent 72%)`,`repeating-linear-gradient(135deg, ${k(d,"14")} 0, ${k(d,"14")} 16px, transparent 16px, transparent 32px)`].join(", "),j=c?{label:"Camera & microphone ready",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-emerald-400"}:m?{label:"Checking device access…",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-amber-300"}:{label:"Allow access to continue",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-rose-300"},C=c?{badge:"Ready",toneClass:"iw-bg-emerald-50 iw-text-emerald-600",cameraCopy:"Framing looks good for identity verification.",micCopy:"We can hear you clearly for your responses."}:m?{badge:"Checking",toneClass:"iw-bg-amber-50 iw-text-amber-600",cameraCopy:"Hang tight while we confirm camera access.",micCopy:"Listening for microphone permission from your browser."}:{badge:"Action needed",toneClass:"iw-bg-rose-50 iw-text-rose-600",cameraCopy:"Grant camera access to continue with the interview.",micCopy:"Enable microphone access so we can capture your answers."},N=[{label:"Camera feed",description:C.cameraCopy,status:C.badge,toneClass:C.toneClass,Icon:_e},{label:"Microphone input",description:C.micCopy,status:C.badge,toneClass:C.toneClass,Icon:nt}],D=()=>{n.current&&(n.current.getTracks().forEach(x=>x.stop()),n.current=null)},v=async()=>{f(!0),h(null);try{const x=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});n.current=x,s.current&&(s.current.srcObject=x),u(!0)}catch(x){console.error("Media permission error:",x);let M="Unable to access camera or microphone.";(x==null?void 0:x.name)==="NotAllowedError"?M="Permissions denied. Please allow access to camera and microphone.":(x==null?void 0:x.name)==="NotFoundError"?M="No camera/microphone found. Please connect a device and retry.":x!=null&&x.message&&(M=x.message),u(!1),h(M)}finally{f(!1)}};if(o.useEffect(()=>{if(!i){D();return}return v(),()=>{D()}},[i]),!i)return null;const S=()=>{r(),D()};return e.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/25 iw-backdrop-blur-md iw-p-4",children:e.jsxs("div",{className:" iw-w-full iw-max-w-[920px] iw-max-h-[96vh] iw-overflow-auto iw-rounded-3xl iw-bg-white iw-shadow-[0_40px_80px_-28px_rgba(15,23,42,0.25)]",children:[e.jsxs("div",{className:"iw-relative iw-overflow-hidden",style:{background:p},children:[e.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{top:-90,right:-100,width:240,height:240,background:"radial-gradient(circle, rgba(255,255,255,0.6), transparent 70%)",filter:"blur(12px)"}}),e.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{bottom:-110,left:-60,width:220,height:220,background:"radial-gradient(circle, rgba(255,255,255,0.35), transparent 70%)",filter:"blur(14px)"}}),e.jsxs("div",{className:"iw-relative iw-grid md:iw-grid-cols-[minmax(0,1fr)_auto] iw-items-start iw-gap-6 iw-px-6 iw-py-7",children:[e.jsx("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-text-white",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-white/15 iw-shadow-inner",children:e.jsx(Re,{className:"iw-h-6 iw-w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-white/70",children:"Pre-interview checklist"}),e.jsx("h2",{className:"iw-mt-1 iw-text-xl iw-font-semibold iw-leading-tight",children:"Final checks before you go live"}),e.jsx("p",{className:"iw-mt-2 iw-text-sm iw-text-white/80",children:"Align your space, confirm device access, and step confidently into your secure session."})]})]})}),e.jsx("div",{className:"iw-flex iw-items-start iw-justify-end",children:e.jsxs("div",{className:`iw-inline-flex iw-items-center iw-gap-2 iw-rounded-full iw-bg-white/10 iw-px-4 iw-py-1.5 iw-text-xs iw-font-medium iw-text-white/85 iw-backdrop-blur-sm ${j.toneClass}`,children:[e.jsx("span",{className:`iw-inline-flex iw-h-2 iw-w-2 iw-rounded-full ${j.dotClass}`}),j.label]})}),t&&e.jsx("button",{"aria-label":"Close",className:"iw-absolute iw-top-5 iw-right-5 iw-text-white/70 transition-colors hover:iw-text-white",onClick:()=>{D(),t==null||t()},children:"✕"})]})]}),e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-px-6 iw-pb-8 iw-pt-6",children:[e.jsxs("div",{className:"iw-grid xl:iw-grid-cols-[0.95fr_1.05fr] iw-gap-6",children:[e.jsx("section",{className:"iw-flex iw-flex-col iw-gap-5",children:e.jsxs("div",{className:"iw-rounded-2xl iw-border iw-border-slate-100 iw-bg-white iw-p-5 iw-shadow-sm",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-sm iw-font-semibold iw-text-slate-900",children:"Proctoring guidelines"}),e.jsx("span",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-slate-400",children:"Required"})]}),e.jsx("ul",{className:"iw-mt-5 iw-flex iw-flex-col iw-gap-4",children:at.map((x,M)=>e.jsx("li",{className:"iw-group iw-overflow-hidden iw-rounded-xl iw-border iw-border-slate-100 iw-bg-slate-50/60 iw-p-4 iw-transition-all hover:iw-border-slate-200 hover:iw-bg-white",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.jsx("span",{className:"iw-flex iw-h-8 iw-w-8 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-text-sm iw-font-semibold iw-text-white",style:{background:p},children:M+1}),e.jsx("span",{className:"iw-text-sm iw-text-slate-600",children:x})]})},x))})]})}),e.jsxs("section",{className:"iw-flex iw-flex-col iw-gap-5",children:[e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-overflow-hidden iw-rounded-3xl iw-bg-white ",style:{borderRadius:y},children:[e.jsx("div",{className:"iw-relative iw-z-10 iw-rounded-2xl iw-border iw-border-slate-200 iw-bg-slate-50/80 iw-p-3",children:e.jsx("video",{ref:s,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-h-64 iw-w-full iw-rounded-2xl iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:y}})}),e.jsxs("div",{className:"iw-relative iw-grid iw-grid-cols-2 iw-gap-4 iw-px-1",children:[e.jsx(Me,{onClick:v,disabled:m,variant:"outline",size:"sm",className:"iw-font-medium",style:{borderColor:d,borderRadius:y,color:d},children:c?"Recheck permissions":"Enable camera & mic"}),e.jsx(G,{onClick:S,disabled:!c,className:"iw-h-10 iw-px-6 iw-text-sm",style:{backgroundColor:d},children:"Proceed"})]})]}),e.jsx("ul",{className:"iw-grid sm:iw-grid-cols-1 iw-gap-3",children:N.map(({Icon:x,label:M,description:P,status:L,toneClass:O})=>e.jsx("li",{className:"iw-rounded-2xl iw-border iw-border-slate-200/65 iw-bg-white iw-p-4 iw-shadow-sm iw-transition-all hover:iw-border-slate-200",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-xl iw-bg-slate-100",children:e.jsx(x,{className:"iw-h-5 iw-w-5 iw-text-slate-600"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-gap-3",children:[e.jsx("p",{className:"iw-text-sm iw-font-medium iw-text-slate-800",children:M}),e.jsx("span",{className:`iw-rounded-full iw-px-3 iw-py-1 iw-text-[11px] iw-font-semibold ${O}`,children:L})]}),e.jsx("p",{className:"iw-mt-1.5 iw-text-xs iw-text-slate-500",children:P})]})]})},M))}),w&&e.jsx("div",{className:"iw-rounded-lg iw-border iw-border-rose-200 iw-bg-rose-50 iw-px-3 iw-py-2 iw-text-xs iw-text-rose-600",children:w}),!((T=navigator.mediaDevices)!=null&&T.getUserMedia)&&e.jsx("div",{className:"iw-rounded-lg iw-border iw-border-amber-200 iw-bg-amber-50 iw-px-3 iw-py-2 iw-text-xs iw-text-amber-700",children:"Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox."})]})]}),e.jsx("div",{className:" iw-rounded-2xl iw-border iw-border-dashed iw-border-slate-200 iw-bg-slate-50/85 iw-px-5 iw-py-4 iw-text-center",children:e.jsx("div",{className:"iw-text-xs iw-text-slate-500",children:"Your session is monitored to protect exam integrity. Continuing confirms you have reviewed and accept these safeguards."})}),e.jsx("div",{"aria-hidden":!0,className:"iw-pointer-events-none iw-absolute iw-inset-x-0 iw-bottom-1 iw-h-20",style:{backgroundImage:g,backgroundSize:"100% 120%, 100% 120%, 100% 120%, 32px 32px",backgroundPosition:"center bottom, left 95% bottom, right 95% bottom, center bottom",backgroundRepeat:"no-repeat, no-repeat, no-repeat, repeat",opacity:.9,transform:"translateY(4px)",maskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)",WebkitMaskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)"}})]})]})})};var I=(i=>(i.IDLE="idle",i.FETCHING_QUESTION="fetching_question",i.READING_QUESTION="reading_question",i.THINKING="thinking",i.ANSWERING="answering",i.TRANSCRIBING="transcribing",i.EDITING="editing",i.SUBMITTING="submitting",i.COMPLETED="completed",i))(I||{});const lt={thinkingDuration:30,answeringDuration:120,editingDuration:30},ct={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"thinking"},thinking:{next:"answering",duration:30},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class dt{constructor(r={},t={}){_(this,"config");_(this,"state");_(this,"phaseIntervalId",null);_(this,"globalIntervalId",null);_(this,"callbacks");this.config={...lt,...r},this.callbacks=t,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}getState(){return{...this.state}}startQuestion(){this.state.currentQuestionNumber===0&&this.startGlobalTimer(),this.state.currentQuestionNumber=this.state.currentQuestionNumber+1,this.state.phase="fetching_question",this.notifyChange()}nextPhase(){const r=this.state.phase,t=ct[r];if(!t)return;this.stopPhaseTimer(),this.state.phase=t.next;const s=this.getDurationForPhase(t.next);s>0?(this.state.currentPhaseTimeRemaining=s,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var r,t;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(t=(r=this.callbacks).onInterviewEnd)==null||t.call(r),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(r){switch(r){case"thinking":return this.config.thinkingDuration;case"answering":return this.config.answeringDuration;case"editing":return this.config.editingDuration;default:return 0}}startGlobalTimer(){this.globalIntervalId=setInterval(()=>{var r,t;this.state.totalTimeElapsed++,(t=(r=this.callbacks).onTick)==null||t.call(r,this.getState())},1e3)}stopGlobalTimer(){this.globalIntervalId&&(clearInterval(this.globalIntervalId),this.globalIntervalId=null)}startPhaseTimer(){this.phaseIntervalId=setInterval(()=>{this.state.currentPhaseTimeRemaining--,this.state.currentPhaseTimeRemaining<=0&&this.nextPhase()},1e3)}stopPhaseTimer(){this.phaseIntervalId&&(clearInterval(this.phaseIntervalId),this.phaseIntervalId=null)}notifyChange(){var r,t;(t=(r=this.callbacks).onPhaseChange)==null||t.call(r,this.state.phase,this.getState())}}function wt(i={}){const{config:r={},callbacks:t={}}=i,s=o.useRef(null);s.current||(s.current=new dt(r,{}));const n=s.current,[l,a]=o.useState(n.getState()),c=o.useCallback(()=>{a(n.getState())},[n]);o.useEffect(()=>{const m={onPhaseChange:(f,d)=>{var p;c(),(p=t.onPhaseChange)==null||p.call(t,f,d)},onTick:f=>{var d;c(),(d=t.onTick)==null||d.call(t,f)},onInterviewEnd:()=>{var f;c(),(f=t.onInterviewEnd)==null||f.call(t)}};n.callbacks=m},[n,t,c]),o.useEffect(()=>()=>{n.destroy()},[n]);const u=o.useCallback(()=>{n.startQuestion(),c()},[n,c]),w=o.useCallback(()=>{n.nextPhase(),c()},[n,c]),h=o.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:l,startQuestion:u,nextPhase:w,completeInterview:h,timerService:n}}function ut(i,r={}){const[t,s]=o.useState({data:null,loading:!1,error:null}),n=o.useCallback(async(...l)=>{var a,c,u,w;s(h=>({...h,loading:!0,error:null}));try{const h=await i(...l);s(m=>({...m,data:h,loading:!1,error:null})),(a=r.onSuccess)==null||a.call(r,h),(c=r.onSettled)==null||c.call(r,h,null)}catch(h){const m=h.type?h:{type:"unknown",message:h.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:h};s(f=>({...f,loading:!1,error:m})),(u=r.onError)==null||u.call(r,m),(w=r.onSettled)==null||w.call(r,null,m)}},[i,r]);return{...t,execute:n}}const ht=i=>{const[r,t]=o.useState(null),[s,n]=o.useState(!1),l=document,a=()=>!!(l.fullscreenEnabled||l.webkitFullscreenEnabled||l.mozFullScreenEnabled||l.msFullscreenEnabled),c=()=>l.fullscreenElement||l.webkitFullscreenElement||l.mozFullScreenElement||l.msFullscreenElement,u=async d=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");d.requestFullscreen?await d.requestFullscreen():d.webkitRequestFullscreen?await d.webkitRequestFullscreen():d.mozRequestFullScreen?await d.mozRequestFullScreen():d.msRequestFullscreen&&await d.msRequestFullscreen()}catch(y){const k={name:"FullscreenError",message:y instanceof Error?y.message:"Failed to enter fullscreen"};t(k),(p=i==null?void 0:i.onError)==null||p.call(i,k)}},w=async()=>{var d;try{l.exitFullscreen?await l.exitFullscreen():l.webkitExitFullscreen?await l.webkitExitFullscreen():l.mozCancelFullScreen?await l.mozCancelFullScreen():l.msExitFullscreen&&await l.msExitFullscreen()}catch(p){const y={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};t(y),(d=i==null?void 0:i.onError)==null||d.call(i,y)}},h=o.useCallback(()=>{var p;const d=!!c();n(d),(p=i==null?void 0:i.onFullScreenChange)==null||p.call(i,d)},[i]);o.useEffect(()=>{const d=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return d.forEach(p=>{document.addEventListener(p,h)}),()=>{d.forEach(p=>{document.removeEventListener(p,h)})}},[h]);const m=async d=>{t(null);const p=d??document.documentElement;await u(p)};return{isFullScreen:s,toggleFullScreen:async d=>{s?await w():await m(d)},enterFullScreen:m,exitFullScreen:w,error:r}};function mt(i){var r;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(i.name==="AbortError"||(r=i.message)!=null&&r.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(i.status){const{status:t}=i;if(t===401||t===403)return{type:"auth",status:t,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(t===429)return{type:"rate-limit",status:t,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(t>=500)return{type:"server",status:t,message:`Server error: ${t}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(t>=400)return{type:"client",status:t,message:`Client error: ${t}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:i.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:i}}async function we(i,r={},t={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let s;for(let n=1;n<=t.attempts;n++)try{const l=new AbortController,a=setTimeout(()=>l.abort(),6e4),c=await fetch(i,{...r,signal:l.signal});if(clearTimeout(a),c.status>=400&&c.status<500&&c.status!==429)return c;if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);return c}catch(l){s=l;const a=mt(l);if(!a.retryable||n===t.attempts)throw a;const c=ft(n,t);console.warn(`API request failed (attempt ${n}/${t.attempts}), retrying in ${c}ms:`,a.message),await new Promise(u=>setTimeout(u,c))}throw s}function ft(i,r){let t;return r.backoff==="exponential"?t=r.baseDelay*Math.pow(2,i-1):t=r.baseDelay,t=Math.min(t,r.maxDelay),r.jitter&&(t=t*(.5+Math.random()*.5)),Math.round(t)}class gt{constructor(r={}){_(this,"config");this.config=r}updateConfig(r){this.config={...this.config,...r}}getHeaders(){var t;const r={"Content-Type":"application/json"};return(t=this.config)!=null&&t.authToken&&(r.Authorization=`Bearer ${this.config.authToken}`),r}getBaseUrl(){var r;return((r=this.config)==null?void 0:r.baseUrl)||"/api"}async generateQuestion({interviewId:r,isInterviewDone:t=!1,qnaId:s,question:n,answer:l,answerDuration:a}){const c=await we(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:r,is_interview_done:t,qna_id:s,question:n,answer:l,answer_duration:a??"00:00:30"})});if(!c.ok)throw new Error(`Failed to get questions: ${c.status}`);return await c.json()}}function xt(){const i=ie();return o.useMemo(()=>{const t=i.api||{};return new gt(t)},[i.api])}const pt=i=>{o.useEffect(()=>{const r=s=>{(s.ctrlKey||s.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(s.key.toLowerCase())&&(s.preventDefault(),i({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${s.key}`}})),s.key.startsWith("F")&&s.key.length<=3&&(s.preventDefault(),i({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${s.key}`}})),s.altKey&&s.key==="Tab"&&(s.preventDefault(),i({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},t=s=>{s.preventDefault(),i({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",r),document.addEventListener("contextmenu",t),()=>{document.removeEventListener("keydown",r),document.removeEventListener("contextmenu",t)}},[i])};class E extends Error{constructor(r,t,s=!1){super(r),this.code=t,this.recoverable=s,this.name="STTError"}}class bt{constructor(r={}){_(this,"config");_(this,"mediaRecorder",null);_(this,"audioChunks",[]);_(this,"recordingStream",null);_(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...r}}updateConfig(r){this.config={...this.config,...r}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(r,t){var s;if(!this.isRecordingSupported())throw new E("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new E("Recording is already in progress","ALREADY_RECORDING",!0);try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:44100}}),this.audioChunks=[];const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.ondataavailable=l=>{var a;l.data.size>0&&(this.audioChunks.push(l.data),(a=t==null?void 0:t.onDataAvailable)==null||a.call(t,l.data))},this.mediaRecorder.onstop=()=>{var l;(l=t==null?void 0:t.onStop)==null||l.call(t)},this.mediaRecorder.onerror=l=>{var c;const a=new E(`Recording failed: ${l.error}`,"RECORDING_ERROR",!0);(c=t==null?void 0:t.onError)==null||c.call(t,a),this.cleanup()},this.mediaRecorder.start(100),(s=t==null?void 0:t.onStart)==null||s.call(t),r&&r>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.isRecording()&&this.stopRecording()},r*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new E("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new E("No microphone found","NO_MICROPHONE",!1)}throw new E(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording())throw new E("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((r,t)=>{if(!this.mediaRecorder){t(new E("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const s=this.mediaRecorder,n=()=>{try{const l=s.mimeType||"audio/webm",a=new Blob(this.audioChunks,{type:l});this.cleanup(),r(a)}catch(l){t(new E(`Failed to create audio blob: ${l instanceof Error?l.message:String(l)}`,"BLOB_CREATION_FAILED",!1))}};s.addEventListener("stop",n,{once:!0}),s.stop()})}async transcribe(r){const{audioBlob:t,model:s=this.config.model,language:n=this.config.language,includeTimestamps:l=this.config.includeTimestamps,temperature:a=this.config.temperature}=r;if(!t||t.size===0)throw new E("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const c=new FormData,u=new File([t],"recording.wav",{type:t.type||"audio/wav"});c.append("file",u),c.append("model",s||"whisper-large-v3-turbo"),c.append("language",n||"en"),c.append("include_timestamps",String(l||!1)),c.append("temperature",String(a||0));const w=await we(`${this.config.baseUrl}/speech/transcribe`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:c},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!w.ok){const m=await w.text();let f=`STT request failed: ${w.status} ${w.statusText}`;try{const d=JSON.parse(m);f=d.message||d.error||f}catch{f=m||f}throw new E(f,`HTTP_${w.status}`,w.status>=500)}return{transcript:(await w.json()).data.text??""}}catch(c){throw c instanceof E?c:new E(`Transcription failed: ${c instanceof Error?c.message:String(c)}`,"TRANSCRIPTION_FAILED",!0)}}cancelRecording(){this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),this.mediaRecorder&&this.isRecording()&&this.mediaRecorder.stop(),this.cleanup()}isRecording(){return this.mediaRecorder!==null&&this.mediaRecorder.state==="recording"}getSupportedMimeType(){const r=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const t of r)if(MediaRecorder.isTypeSupported(t))return t;return"audio/webm"}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(r=>r.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const z=new bt,yt=(i={})=>{const[r,t]=o.useState(!1),[s,n]=o.useState(!1),[l,a]=o.useState(null),[c,u]=o.useState(null),[w,h]=o.useState(null);i.config&&z.updateConfig(i.config);const m=o.useCallback(async y=>{var k;try{u(null),a(null),h(null),await z.startRecording(y,{onStart:()=>{var g;t(!0),(g=i.onStart)==null||g.call(i)},onStop:()=>{var g;t(!1),(g=i.onStop)==null||g.call(i)},onError:g=>{var C;const j=g instanceof E?g:new E(g.message,"RECORDING_ERROR",!0);u(j),t(!1),(C=i.onError)==null||C.call(i,j)}})}catch(g){const j=g instanceof E?g:new E(g instanceof Error?g.message:String(g),"START_FAILED",!1);throw u(j),t(!1),(k=i.onError)==null||k.call(i,j),j}},[]),f=o.useCallback(async()=>{var y,k;try{const g=await z.stopRecording();return h(g),t(!1),(y=i.onStop)==null||y.call(i),g}catch(g){const j=g instanceof E?g:new E(g instanceof Error?g.message:String(g),"STOP_FAILED",!1);throw u(j),t(!1),(k=i.onError)==null||k.call(i,j),j}},[]),d=o.useCallback(async(y,k={})=>{var g,j;try{u(null),n(!0);const C={audioBlob:y,...k},N=await z.transcribe(C);return a(N.transcript),n(!1),(g=i.onTranscriptionComplete)==null||g.call(i,N),N}catch(C){const N=C instanceof E?C:new E(C instanceof Error?C.message:String(C),"TRANSCRIPTION_FAILED",!0);throw u(N),n(!1),(j=i.onError)==null||j.call(i,N),N}},[]),p=o.useCallback(()=>{z.cancelRecording(),t(!1),h(null)},[]);return{startRecording:m,stopRecording:f,transcribe:d,cancelRecording:p,isRecording:r,isTranscribing:s,transcript:l,error:c,audioBlob:w}},vt=i=>{const r=o.useRef(null),t=o.useRef(!1);o.useEffect(()=>{const s=()=>{document.hidden&&(t.current=!0,r.current&&(clearTimeout(r.current),r.current=null),i({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{t.current=!1},100))},n=()=>{t.current||(r.current=setTimeout(()=>{t.current||i({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),r.current=null},50))};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",n),r.current&&clearTimeout(r.current)}},[i])},jt=()=>{o.useEffect(()=>{const i=document.createElement("style");return i.textContent=`
9
+ */var qe=Symbol.for("react.transitional.element"),Ue=Symbol.for("react.fragment");function ke(i,r,t){var s=null;if(t!==void 0&&(s=""+t),r.key!==void 0&&(s=""+r.key),"key"in r){t={};for(var n in r)n!=="key"&&(t[n]=r[n])}else t=r;return r=t.ref,{$$typeof:qe,type:i,key:s,ref:r!==void 0?r:null,props:t}}ee.Fragment=Ue,ee.jsx=ke,ee.jsxs=ke,je.exports=ee;var e=je.exports;const le={},F={api:{baseUrl:"/api",retryConfig:{attempts:3,backoff:"exponential",baseDelay:1e3}},ui:{baseColor:"#3B82F6",borderRadius:"8px"},interview:{timers:{thinkingDuration:30,answeringDuration:120,editingDuration:30},stt:{provider:"groq",model:"whisper-large-v3-turbo",language:"en"},tts:{provider:"piper"},proctoring:{enabled:!0}}},ce="iw-storage";function We(){if(!(typeof{url:typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:oe&&oe.tagName.toUpperCase()==="SCRIPT"&&oe.src||new URL("widget.umd.js",document.baseURI).href}<"u"&&(le!=null&&le.VITE_IW_SECRET)))return typeof process<"u"&&process.env.NEXT_PUBLIC_IW_SECRET?process.env.NEXT_PUBLIC_IW_SECRET:typeof window<"u"&&window.__IW_SECRET__?window.__IW_SECRET__:"proctoring-data-seed"}const Ne=We(),de="AES-GCM",we=12;async function Ee(i){const t=new TextEncoder().encode(i),s=await crypto.subtle.digest("SHA-256",t);return crypto.subtle.importKey("raw",s,de,!1,["encrypt","decrypt"])}function Be(){return crypto.getRandomValues(new Uint8Array(we))}async function Ge(i,r="default-seed"){try{const t=typeof i=="string"?i:JSON.stringify(i),n=new TextEncoder().encode(t),l=await Ee(r),a=Be(),c=await crypto.subtle.encrypt({name:de,iv:a},l,n),u=new Uint8Array(a.length+c.byteLength);return u.set(new Uint8Array(a),0),u.set(new Uint8Array(c),a.length),btoa(String.fromCharCode(...Array.from(u)))}catch(t){throw console.error("Encryption failed:",t),new Error("Failed to encrypt data")}}async function Ve(i,r="default-seed"){try{const t=atob(i),s=new Uint8Array(t.length);for(let w=0;w<t.length;w++)s[w]=t.charCodeAt(w);const n=s.slice(0,we),l=s.slice(we),a=await Ee(r),c=await crypto.subtle.decrypt({name:de,iv:n},a,l);return new TextDecoder().decode(c)}catch(t){throw console.error("Decryption failed:",t),new Error("Failed to decrypt data")}}async function ze(i,r="default-seed"){return Ge(i,r)}async function He(i,r="default-seed"){const t=await Ve(i,r);try{return JSON.parse(t)}catch{return t}}const te=o.createContext(null),Ye=async()=>{var i,r;try{const t=sessionStorage.getItem(ce);if(t){const s=await He(t,Ne);return{logViolations:((i=s.state)==null?void 0:i.logViolations)||[],totalViolations:((r=s.state)==null?void 0:r.totalViolations)||0}}}catch(t){console.error("Failed to load proctoring data from session storage:",t)}return{logViolations:[],totalViolations:0}},Ce=async i=>{try{const r=await ze({state:i,version:0},Ne);sessionStorage.setItem(ce,r)}catch(r){console.error("Failed to save proctoring data to session storage:",r)}},Qe=({children:i})=>{const r=o.useRef({logViolations:[],totalViolations:0}),t=o.useRef(new Set);o.useEffect(()=>{Ye().then(w=>{r.current=w,s()})},[]);const s=o.useCallback(()=>{t.current.forEach(w=>w())},[]),n=o.useCallback(w=>(t.current.add(w),()=>{t.current.delete(w)}),[]),l=o.useCallback(()=>r.current,[]),a=o.useCallback(w=>{r.current={logViolations:[...r.current.logViolations,w],totalViolations:r.current.totalViolations+1},Ce(r.current),s()},[s]),c=o.useCallback(()=>{r.current={logViolations:[],totalViolations:0},Ce(r.current),s()},[s]),u=o.useMemo(()=>({getState:l,addViolation:a,clearViolations:c,subscribe:n}),[l,a,c,n]);return e.jsx(te.Provider,{value:u,children:i})},Ke=()=>{const i=o.useContext(te);if(!i)throw new Error("useViolations must be used within a ProctoringProvider");return o.useSyncExternalStore(i.subscribe,()=>i.getState().logViolations,()=>i.getState().logViolations)},Je=()=>{const i=o.useContext(te);if(!i)throw new Error("useTotalViolations must be used within a ProctoringProvider");return o.useSyncExternalStore(i.subscribe,()=>i.getState().totalViolations,()=>i.getState().totalViolations)},Xe=()=>{const i=o.useContext(te);if(!i)throw new Error("useProctoringActions must be used within a ProctoringProvider");return{addViolation:i.addViolation,clearViolations:i.clearViolations}},Se=o.createContext(null);function Te({config:i={},children:r}){var s,n,l,a;const t={api:{...F.api,...i.api,retryConfig:{...F.api.retryConfig,...(s=i.api)==null?void 0:s.retryConfig}},ui:{...F.ui,...i.ui},interview:{...F.interview,...i.interview,timers:{...F.interview.timers,...(n=i.interview)==null?void 0:n.timers},stt:{...F.interview.stt,...(l=i.interview)==null?void 0:l.stt},tts:{...F.interview.tts,...(a=i.interview)==null?void 0:a.tts}}};return e.jsx(Se.Provider,{value:t,children:e.jsx(Qe,{children:r})})}function ie(){const i=o.useContext(Se);if(!i)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return i}function Ie(){return ie().api||F.api}function V(){return ie().ui||F.ui}function Ze(){return ie().interview||F.interview}const Me=({className:i,...r})=>e.jsx("div",{children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`iw-animate-spin ${i}`,...r,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M12 6l0 -3"}),e.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),e.jsx("path",{d:"M18 12l3 0"}),e.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),e.jsx("path",{d:"M12 18l0 3"}),e.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),e.jsx("path",{d:"M6 12l-3 0"}),e.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),Ae=({children:i,variant:r="primary",size:t="md",fullWidth:s=!1,isLoading:n=!1,disabled:l,className:a="",...c})=>{const u="iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2",w={primary:"iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",secondary:"iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",outline:"iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",text:"iw-bg-transparent iw-text-primary-600 iw-hover:bg-primary-50 iw-border iw-border-transparent",gradient:"iw-text-white iw-border iw-border-transparent iw-bg-gradient-to-r iw-from-purple-500 iw-to-indigo-500 hover:iw-from-purple-600 hover:iw-to-indigo-600"},h={sm:"iw-px-3 iw-py-1.5 iw-text-sm",md:"iw-px-4 iw-py-2.5 iw-text-sm",lg:"iw-px-5 iw-py-3 iw-text-base"},m="iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none",f=s?"iw-w-full":"";return e.jsxs("button",{className:`${u} ${w[r]} ${h[t]} ${f} ${m} ${a}`,disabled:l||n,...c,children:[n&&e.jsx(Me,{height:16,width:16,style:{marginRight:"3px"}}),i]})};function et(i){const r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function tt(i,r,t){return"#"+[i,r,t].map(s=>{const n=Math.round(s).toString(16);return n.length===1?"0"+n:n}).join("")}function De(i,r){const t=et(i);if(!t)return i;const s=t.r+(255-t.r)*r,n=t.g+(255-t.g)*r,l=t.b+(255-t.b)*r;return tt(s,n,l)}function it(i,r=.8){return{background:`linear-gradient(to bottom, ${De(i,r)}, #ffffff)`,color:"#1f2937"}}function rt(i){return new Promise(r=>setTimeout(r,i))}function _e(i){return`linear-gradient(to left, ${De(i,.4)}, ${i})`}const st=()=>Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15);function nt(i){try{const r=i.split(".");if(r.length!==3||!r[1])throw new Error("Invalid JWT token");const s=r[1].replace(/-/g,"+").replace(/_/g,"/"),n=s.padEnd(s.length+(4-s.length%4)%4,"="),l=atob(n);return JSON.parse(l)}catch(r){return console.error("Error decoding JWT:",r),null}}const Re=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"}),e.jsx("path",{d:"m9 12 2 2 4-4"})]}),Pe=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("rect",{width:"20",height:"14",x:"2",y:"3",rx:"2"}),e.jsx("line",{x1:"8",x2:"16",y1:"21",y2:"21"}),e.jsx("line",{x1:"12",x2:"12",y1:"17",y2:"21"})]}),at=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("path",{d:"M15 8a5 5 0 0 1 0 8"}),e.jsx("path",{d:"M6 15h-2a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1h2l3.5 -4.5a.8 .8 0 0 1 1.5 .5v14a.8 .8 0 0 1 -1.5 .5l-3.5 -4.5"})]}),G=i=>{const{baseColor:r,borderRadius:t}=V(),{loading:s,children:n,...l}=i;return e.jsx(Ae,{style:{background:_e(r),borderRadius:t},...l,children:s?e.jsx(Me,{}):n})},ot=["Do not refresh or reload the page during your assessment","Refrain from switching tabs or opening other applications while the session is in progress","Ensure your face remains clearly visible on camera at all times","Avoid frequent distractions or leaving your seat during the session","Do not disable or interfere with audio/video monitoring"],lt=({isOpen:i,onStart:r,onClose:t})=>{var T;const s=o.useRef(null),n=o.useRef(null),{baseColor:l,borderRadius:a}=V(),[c,u]=o.useState(!1),[w,h]=o.useState(null),[m,f]=o.useState(!1),d=l??"#2563eb",p=_e(d),b=a??18,k=(x,M)=>x.startsWith("#")&&x.length===7?`${x}${M}`:x,g=[`radial-gradient(120% 85% at 50% 125%, ${k(d,"34")} 0%, transparent 70%)`,`radial-gradient(90% 70% at 10% 130%, ${k(d,"24")} 0%, transparent 72%)`,`radial-gradient(90% 70% at 90% 130%, ${k(d,"24")} 0%, transparent 72%)`,`repeating-linear-gradient(135deg, ${k(d,"14")} 0, ${k(d,"14")} 16px, transparent 16px, transparent 32px)`].join(", "),v=c?{label:"Camera & microphone ready",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-emerald-400"}:m?{label:"Checking device access…",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-amber-300"}:{label:"Allow access to continue",toneClass:"iw-bg-white/15 iw-text-white",dotClass:"iw-bg-rose-300"},C=c?{badge:"Ready",toneClass:"iw-bg-emerald-50 iw-text-emerald-600",cameraCopy:"Framing looks good for identity verification.",micCopy:"We can hear you clearly for your responses."}:m?{badge:"Checking",toneClass:"iw-bg-amber-50 iw-text-amber-600",cameraCopy:"Hang tight while we confirm camera access.",micCopy:"Listening for microphone permission from your browser."}:{badge:"Action needed",toneClass:"iw-bg-rose-50 iw-text-rose-600",cameraCopy:"Grant camera access to continue with the interview.",micCopy:"Enable microphone access so we can capture your answers."},N=[{label:"Camera feed",description:C.cameraCopy,status:C.badge,toneClass:C.toneClass,Icon:Pe},{label:"Microphone input",description:C.micCopy,status:C.badge,toneClass:C.toneClass,Icon:at}],D=()=>{n.current&&(n.current.getTracks().forEach(x=>x.stop()),n.current=null)},j=async()=>{f(!0),h(null);try{const x=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});n.current=x,s.current&&(s.current.srcObject=x),u(!0)}catch(x){console.error("Media permission error:",x);let M="Unable to access camera or microphone.";(x==null?void 0:x.name)==="NotAllowedError"?M="Permissions denied. Please allow access to camera and microphone.":(x==null?void 0:x.name)==="NotFoundError"?M="No camera/microphone found. Please connect a device and retry.":x!=null&&x.message&&(M=x.message),u(!1),h(M)}finally{f(!1)}};if(o.useEffect(()=>{if(!i){D();return}return j(),()=>{D()}},[i]),!i)return null;const S=()=>{r(),D()};return e.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-gray-900/25 iw-backdrop-blur-md iw-p-4",children:e.jsxs("div",{className:" iw-w-full iw-max-w-[920px] iw-max-h-[96vh] iw-overflow-auto iw-rounded-3xl iw-bg-white iw-shadow-[0_40px_80px_-28px_rgba(15,23,42,0.25)]",children:[e.jsxs("div",{className:"iw-relative iw-overflow-hidden",style:{background:p},children:[e.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{top:-90,right:-100,width:240,height:240,background:"radial-gradient(circle, rgba(255,255,255,0.6), transparent 70%)",filter:"blur(12px)"}}),e.jsx("div",{"aria-hidden":!0,className:"iw-absolute iw-pointer-events-none",style:{bottom:-110,left:-60,width:220,height:220,background:"radial-gradient(circle, rgba(255,255,255,0.35), transparent 70%)",filter:"blur(14px)"}}),e.jsxs("div",{className:"iw-relative iw-grid md:iw-grid-cols-[minmax(0,1fr)_auto] iw-items-start iw-gap-6 iw-px-6 iw-py-7",children:[e.jsx("div",{className:"iw-flex iw-flex-col iw-gap-4 iw-text-white",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-white/15 iw-shadow-inner",children:e.jsx(Re,{className:"iw-h-6 iw-w-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-white/70",children:"Pre-interview checklist"}),e.jsx("h2",{className:"iw-mt-1 iw-text-xl iw-font-semibold iw-leading-tight",children:"Final checks before you go live"}),e.jsx("p",{className:"iw-mt-2 iw-text-sm iw-text-white/80",children:"Align your space, confirm device access, and step confidently into your secure session."})]})]})}),e.jsx("div",{className:"iw-flex iw-items-start iw-justify-end",children:e.jsxs("div",{className:`iw-inline-flex iw-items-center iw-gap-2 iw-rounded-full iw-bg-white/10 iw-px-4 iw-py-1.5 iw-text-xs iw-font-medium iw-text-white/85 iw-backdrop-blur-sm ${v.toneClass}`,children:[e.jsx("span",{className:`iw-inline-flex iw-h-2 iw-w-2 iw-rounded-full ${v.dotClass}`}),v.label]})}),t&&e.jsx("button",{"aria-label":"Close",className:"iw-absolute iw-top-5 iw-right-5 iw-text-white/70 transition-colors hover:iw-text-white",onClick:()=>{D(),t==null||t()},children:"✕"})]})]}),e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-px-6 iw-pb-8 iw-pt-6",children:[e.jsxs("div",{className:"iw-grid xl:iw-grid-cols-[0.95fr_1.05fr] iw-gap-6",children:[e.jsx("section",{className:"iw-flex iw-flex-col iw-gap-5",children:e.jsxs("div",{className:"iw-rounded-2xl iw-border iw-border-slate-100 iw-bg-white iw-p-5 iw-shadow-sm",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-sm iw-font-semibold iw-text-slate-900",children:"Proctoring guidelines"}),e.jsx("span",{className:"iw-text-[11px] iw-font-medium iw-uppercase iw-tracking-wide iw-text-slate-400",children:"Required"})]}),e.jsx("ul",{className:"iw-mt-5 iw-flex iw-flex-col iw-gap-4",children:ot.map((x,M)=>e.jsx("li",{className:"iw-group iw-overflow-hidden iw-rounded-xl iw-border iw-border-slate-100 iw-bg-slate-50/60 iw-p-4 iw-transition-all hover:iw-border-slate-200 hover:iw-bg-white",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.jsx("span",{className:"iw-flex iw-h-8 iw-w-8 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-text-sm iw-font-semibold iw-text-white",style:{background:p},children:M+1}),e.jsx("span",{className:"iw-text-sm iw-text-slate-600",children:x})]})},x))})]})}),e.jsxs("section",{className:"iw-flex iw-flex-col iw-gap-5",children:[e.jsxs("div",{className:"iw-relative iw-flex iw-flex-col iw-gap-6 iw-overflow-hidden iw-rounded-3xl iw-bg-white ",style:{borderRadius:b},children:[e.jsx("div",{className:"iw-relative iw-z-10 iw-rounded-2xl iw-border iw-border-slate-200 iw-bg-slate-50/80 iw-p-3",children:e.jsx("video",{ref:s,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-h-64 iw-w-full iw-rounded-2xl iw-object-cover",style:{transform:"scaleX(-1)",borderRadius:b}})}),e.jsxs("div",{className:"iw-relative iw-grid iw-grid-cols-2 iw-gap-4 iw-px-1",children:[e.jsx(Ae,{onClick:j,disabled:m,variant:"outline",size:"sm",className:"iw-font-medium",style:{borderColor:d,borderRadius:b,color:d},children:c?"Recheck permissions":"Enable camera & mic"}),e.jsx(G,{onClick:S,disabled:!c,className:"iw-h-10 iw-px-6 iw-text-sm",style:{backgroundColor:d},children:"Proceed"})]})]}),e.jsx("ul",{className:"iw-grid sm:iw-grid-cols-1 iw-gap-3",children:N.map(({Icon:x,label:M,description:P,status:L,toneClass:O})=>e.jsx("li",{className:"iw-rounded-2xl iw-border iw-border-slate-200/65 iw-bg-white iw-p-4 iw-shadow-sm iw-transition-all hover:iw-border-slate-200",children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3",children:[e.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-xl iw-bg-slate-100",children:e.jsx(x,{className:"iw-h-5 iw-w-5 iw-text-slate-600"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-gap-3",children:[e.jsx("p",{className:"iw-text-sm iw-font-medium iw-text-slate-800",children:M}),e.jsx("span",{className:`iw-rounded-full iw-px-3 iw-py-1 iw-text-[11px] iw-font-semibold ${O}`,children:L})]}),e.jsx("p",{className:"iw-mt-1.5 iw-text-xs iw-text-slate-500",children:P})]})]})},M))}),w&&e.jsx("div",{className:"iw-rounded-lg iw-border iw-border-rose-200 iw-bg-rose-50 iw-px-3 iw-py-2 iw-text-xs iw-text-rose-600",children:w}),!((T=navigator.mediaDevices)!=null&&T.getUserMedia)&&e.jsx("div",{className:"iw-rounded-lg iw-border iw-border-amber-200 iw-bg-amber-50 iw-px-3 iw-py-2 iw-text-xs iw-text-amber-700",children:"Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox."})]})]}),e.jsx("div",{className:" iw-rounded-2xl iw-border iw-border-dashed iw-border-slate-200 iw-bg-slate-50/85 iw-px-5 iw-py-4 iw-text-center",children:e.jsx("div",{className:"iw-text-xs iw-text-slate-500",children:"Your session is monitored to protect exam integrity. Continuing confirms you have reviewed and accept these safeguards."})}),e.jsx("div",{"aria-hidden":!0,className:"iw-pointer-events-none iw-absolute iw-inset-x-0 iw-bottom-1 iw-h-20",style:{backgroundImage:g,backgroundSize:"100% 120%, 100% 120%, 100% 120%, 32px 32px",backgroundPosition:"center bottom, left 95% bottom, right 95% bottom, center bottom",backgroundRepeat:"no-repeat, no-repeat, no-repeat, repeat",opacity:.9,transform:"translateY(4px)",maskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)",WebkitMaskImage:"linear-gradient(to top, rgba(0,0,0,0.92), transparent)"}})]})]})})};var I=(i=>(i.IDLE="idle",i.FETCHING_QUESTION="fetching_question",i.READING_QUESTION="reading_question",i.THINKING="thinking",i.ANSWERING="answering",i.TRANSCRIBING="transcribing",i.EDITING="editing",i.SUBMITTING="submitting",i.COMPLETED="completed",i))(I||{});const ct={thinkingDuration:30,answeringDuration:120,editingDuration:30},dt={idle:{next:"fetching_question"},fetching_question:{next:"reading_question"},reading_question:{next:"thinking"},thinking:{next:"answering",duration:30},answering:{next:"transcribing",duration:120},transcribing:{next:"editing"},editing:{next:"submitting",duration:30},submitting:{next:"completed"},completed:{next:"completed"}};class wt{constructor(r={},t={}){R(this,"config");R(this,"state");R(this,"phaseIntervalId",null);R(this,"globalIntervalId",null);R(this,"callbacks");this.config={...ct,...r},this.callbacks=t,this.state={phase:"idle",currentPhaseTimeRemaining:0,totalTimeElapsed:0,currentQuestionNumber:0}}getState(){return{...this.state}}startQuestion(){this.state.currentQuestionNumber===0&&this.startGlobalTimer(),this.state.currentQuestionNumber=this.state.currentQuestionNumber+1,this.state.phase="fetching_question",this.notifyChange()}nextPhase(){const r=this.state.phase,t=dt[r];if(!t)return;this.stopPhaseTimer(),this.state.phase=t.next;const s=this.getDurationForPhase(t.next);s>0?(this.state.currentPhaseTimeRemaining=s,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var r,t;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(t=(r=this.callbacks).onInterviewEnd)==null||t.call(r),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(r){switch(r){case"thinking":return this.config.thinkingDuration;case"answering":return this.config.answeringDuration;case"editing":return this.config.editingDuration;default:return 0}}startGlobalTimer(){this.globalIntervalId=setInterval(()=>{var r,t;this.state.totalTimeElapsed++,(t=(r=this.callbacks).onTick)==null||t.call(r,this.getState())},1e3)}stopGlobalTimer(){this.globalIntervalId&&(clearInterval(this.globalIntervalId),this.globalIntervalId=null)}startPhaseTimer(){this.phaseIntervalId=setInterval(()=>{this.state.currentPhaseTimeRemaining--,this.state.currentPhaseTimeRemaining<=0&&this.nextPhase()},1e3)}stopPhaseTimer(){this.phaseIntervalId&&(clearInterval(this.phaseIntervalId),this.phaseIntervalId=null)}notifyChange(){var r,t;(t=(r=this.callbacks).onPhaseChange)==null||t.call(r,this.state.phase,this.getState())}}function ut(i={}){const{config:r={},callbacks:t={}}=i,s=o.useRef(null);s.current||(s.current=new wt(r,{}));const n=s.current,[l,a]=o.useState(n.getState()),c=o.useCallback(()=>{a(n.getState())},[n]);o.useEffect(()=>{const m={onPhaseChange:(f,d)=>{var p;c(),(p=t.onPhaseChange)==null||p.call(t,f,d)},onTick:f=>{var d;c(),(d=t.onTick)==null||d.call(t,f)},onInterviewEnd:()=>{var f;c(),(f=t.onInterviewEnd)==null||f.call(t)}};n.callbacks=m},[n,t,c]),o.useEffect(()=>()=>{n.destroy()},[n]);const u=o.useCallback(()=>{n.startQuestion(),c()},[n,c]),w=o.useCallback(()=>{n.nextPhase(),c()},[n,c]),h=o.useCallback(()=>{n.completeInterview(),c()},[n,c]);return{state:l,startQuestion:u,nextPhase:w,completeInterview:h,timerService:n}}function ht(i,r={}){const[t,s]=o.useState({data:null,loading:!1,error:null}),n=o.useCallback(async(...l)=>{var a,c,u,w;s(h=>({...h,loading:!0,error:null}));try{const h=await i(...l);s(m=>({...m,data:h,loading:!1,error:null})),(a=r.onSuccess)==null||a.call(r,h),(c=r.onSettled)==null||c.call(r,h,null)}catch(h){const m=h.type?h:{type:"unknown",message:h.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:h};s(f=>({...f,loading:!1,error:m})),(u=r.onError)==null||u.call(r,m),(w=r.onSettled)==null||w.call(r,null,m)}},[i,r]);return{...t,execute:n}}const mt=i=>{const[r,t]=o.useState(null),[s,n]=o.useState(!1),l=document,a=()=>!!(l.fullscreenEnabled||l.webkitFullscreenEnabled||l.mozFullScreenEnabled||l.msFullscreenEnabled),c=()=>l.fullscreenElement||l.webkitFullscreenElement||l.mozFullScreenElement||l.msFullscreenElement,u=async d=>{var p;try{if(!a())throw new Error("Fullscreen is not supported in this environment");d.requestFullscreen?await d.requestFullscreen():d.webkitRequestFullscreen?await d.webkitRequestFullscreen():d.mozRequestFullScreen?await d.mozRequestFullScreen():d.msRequestFullscreen&&await d.msRequestFullscreen()}catch(b){const k={name:"FullscreenError",message:b instanceof Error?b.message:"Failed to enter fullscreen"};t(k),(p=i==null?void 0:i.onError)==null||p.call(i,k)}},w=async()=>{var d;try{l.exitFullscreen?await l.exitFullscreen():l.webkitExitFullscreen?await l.webkitExitFullscreen():l.mozCancelFullScreen?await l.mozCancelFullScreen():l.msExitFullscreen&&await l.msExitFullscreen()}catch(p){const b={name:"FullscreenError",message:p instanceof Error?p.message:"Failed to exit fullscreen"};t(b),(d=i==null?void 0:i.onError)==null||d.call(i,b)}},h=o.useCallback(()=>{var p;const d=!!c();n(d),(p=i==null?void 0:i.onFullScreenChange)==null||p.call(i,d)},[i]);o.useEffect(()=>{const d=["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"];return d.forEach(p=>{document.addEventListener(p,h)}),()=>{d.forEach(p=>{document.removeEventListener(p,h)})}},[h]);const m=async d=>{t(null);const p=d??document.documentElement;await u(p)};return{isFullScreen:s,toggleFullScreen:async d=>{s?await w():await m(d)},enterFullScreen:m,exitFullScreen:w,error:r}};function ft(i){var r;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(i.name==="AbortError"||(r=i.message)!=null&&r.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(i.status){const{status:t}=i;if(t===401||t===403)return{type:"auth",status:t,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(t===429)return{type:"rate-limit",status:t,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(t>=500)return{type:"server",status:t,message:`Server error: ${t}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(t>=400)return{type:"client",status:t,message:`Client error: ${t}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:i.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:i}}async function ue(i,r={},t={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let s;for(let n=1;n<=t.attempts;n++)try{const l=new AbortController,a=setTimeout(()=>l.abort(),6e4),c=await fetch(i,{...r,signal:l.signal});if(clearTimeout(a),c.status>=400&&c.status<500&&c.status!==429)return c;if(!c.ok)throw new Error(`HTTP ${c.status}: ${c.statusText}`);return c}catch(l){s=l;const a=ft(l);if(!a.retryable||n===t.attempts)throw a;const c=gt(n,t);console.warn(`API request failed (attempt ${n}/${t.attempts}), retrying in ${c}ms:`,a.message),await new Promise(u=>setTimeout(u,c))}throw s}function gt(i,r){let t;return r.backoff==="exponential"?t=r.baseDelay*Math.pow(2,i-1):t=r.baseDelay,t=Math.min(t,r.maxDelay),r.jitter&&(t=t*(.5+Math.random()*.5)),Math.round(t)}class xt{constructor(r={}){R(this,"config");this.config=r}updateConfig(r){this.config={...this.config,...r}}getHeaders(){var t;const r={"Content-Type":"application/json"};return(t=this.config)!=null&&t.authToken&&(r.Authorization=`Bearer ${this.config.authToken}`),r}getBaseUrl(){var r;return((r=this.config)==null?void 0:r.baseUrl)||"/api"}async generateQuestion({interviewId:r,isInterviewDone:t=!1,qnaId:s,question:n,answer:l,answerDuration:a}){const c=await ue(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:r,is_interview_done:t,qna_id:s,question:n,answer:l,answer_duration:a??"00:00:30"})});if(!c.ok)throw new Error(`Failed to get questions: ${c.status}`);return await c.json()}}function pt(){const i=ie();return o.useMemo(()=>{const t=i.api||{};return new xt(t)},[i.api])}const bt=i=>{o.useEffect(()=>{const r=s=>{(s.ctrlKey||s.metaKey)&&["c","v","a","t","n","w","r","s","p"].includes(s.key.toLowerCase())&&(s.preventDefault(),i({type:"blocked_shortcut",severity:"low",details:{action:"shortcut_pressed",reason:`Attempted to use a blocked keyboard shortcut: Ctrl + ${s.key}`}})),s.key.startsWith("F")&&s.key.length<=3&&(s.preventDefault(),i({type:"blocked_function_key",severity:"low",details:{action:"function_key_pressed",reason:`Attempted to use a blocked function key: ${s.key}`}})),s.altKey&&s.key==="Tab"&&(s.preventDefault(),i({type:"alt_tab_attempt",severity:"medium",details:{action:"alt_tab",reason:"Attempted to use the Alt + Tab shortcut"}}))},t=s=>{s.preventDefault(),i({type:"right_click_attempt",severity:"low",details:{action:"right_click",reason:"Attempted to use the right click"}})};return document.addEventListener("keydown",r),document.addEventListener("contextmenu",t),()=>{document.removeEventListener("keydown",r),document.removeEventListener("contextmenu",t)}},[i])};class E extends Error{constructor(r,t,s=!1){super(r),this.code=t,this.recoverable=s,this.name="STTError"}}class yt{constructor(r={}){R(this,"config");R(this,"mediaRecorder",null);R(this,"audioChunks",[]);R(this,"recordingStream",null);R(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...r}}updateConfig(r){this.config={...this.config,...r}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(r,t){var s;if(!this.isRecordingSupported())throw new E("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new E("Recording is already in progress","ALREADY_RECORDING",!0);try{this.recordingStream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:44100}}),this.audioChunks=[];const n=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:n}),this.mediaRecorder.ondataavailable=l=>{var a;l.data.size>0&&(this.audioChunks.push(l.data),(a=t==null?void 0:t.onDataAvailable)==null||a.call(t,l.data))},this.mediaRecorder.onstop=()=>{var l;(l=t==null?void 0:t.onStop)==null||l.call(t)},this.mediaRecorder.onerror=l=>{var c;const a=new E(`Recording failed: ${l.error}`,"RECORDING_ERROR",!0);(c=t==null?void 0:t.onError)==null||c.call(t,a),this.cleanup()},this.mediaRecorder.start(100),(s=t==null?void 0:t.onStart)==null||s.call(t),r&&r>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.isRecording()&&this.stopRecording()},r*1e3))}catch(n){if(this.cleanup(),n instanceof Error){if(n.name==="NotAllowedError"||n.name==="PermissionDeniedError")throw new E("Microphone permission was denied","PERMISSION_DENIED",!1);if(n.name==="NotFoundError")throw new E("No microphone found","NO_MICROPHONE",!1)}throw new E(`Failed to start recording: ${n instanceof Error?n.message:String(n)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording())throw new E("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((r,t)=>{if(!this.mediaRecorder){t(new E("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const s=this.mediaRecorder,n=()=>{try{const l=s.mimeType||"audio/webm",a=new Blob(this.audioChunks,{type:l});this.cleanup(),r(a)}catch(l){t(new E(`Failed to create audio blob: ${l instanceof Error?l.message:String(l)}`,"BLOB_CREATION_FAILED",!1))}};s.addEventListener("stop",n,{once:!0}),s.stop()})}async transcribe(r){const{audioBlob:t,model:s=this.config.model,language:n=this.config.language,includeTimestamps:l=this.config.includeTimestamps,temperature:a=this.config.temperature}=r;if(!t||t.size===0)throw new E("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const c=new FormData,u=new File([t],"recording.wav",{type:t.type||"audio/wav"});c.append("file",u),c.append("model",s||"whisper-large-v3-turbo"),c.append("language",n||"en"),c.append("include_timestamps",String(l||!1)),c.append("temperature",String(a||0)),c.append("qna_id",this.config.qnaId||"");const w=await ue(`${this.config.baseUrl}/speech/transcribe`,{method:"POST",headers:{accept:"application/json","X-STT-Provider":this.config.provider||"groq",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:c},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!w.ok){const m=await w.text();let f=`STT request failed: ${w.status} ${w.statusText}`;try{const d=JSON.parse(m);f=d.message||d.error||f}catch{f=m||f}throw new E(f,`HTTP_${w.status}`,w.status>=500)}return{transcript:(await w.json()).data.text??""}}catch(c){throw c instanceof E?c:new E(`Transcription failed: ${c instanceof Error?c.message:String(c)}`,"TRANSCRIPTION_FAILED",!0)}}cancelRecording(){this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),this.mediaRecorder&&this.isRecording()&&this.mediaRecorder.stop(),this.cleanup()}isRecording(){return this.mediaRecorder!==null&&this.mediaRecorder.state==="recording"}getSupportedMimeType(){const r=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const t of r)if(MediaRecorder.isTypeSupported(t))return t;return"audio/webm"}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(r=>r.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const z=new yt,vt=(i={})=>{const[r,t]=o.useState(!1),[s,n]=o.useState(!1),[l,a]=o.useState(null),[c,u]=o.useState(null),[w,h]=o.useState(null);i.config&&z.updateConfig(i.config);const m=o.useCallback(async b=>{var k;try{u(null),a(null),h(null),await z.startRecording(b,{onStart:()=>{var g;t(!0),(g=i.onStart)==null||g.call(i)},onStop:()=>{var g;t(!1),(g=i.onStop)==null||g.call(i)},onError:g=>{var C;const v=g instanceof E?g:new E(g.message,"RECORDING_ERROR",!0);u(v),t(!1),(C=i.onError)==null||C.call(i,v)}})}catch(g){const v=g instanceof E?g:new E(g instanceof Error?g.message:String(g),"START_FAILED",!1);throw u(v),t(!1),(k=i.onError)==null||k.call(i,v),v}},[]),f=o.useCallback(async()=>{var b,k;try{const g=await z.stopRecording();return h(g),t(!1),(b=i.onStop)==null||b.call(i),g}catch(g){const v=g instanceof E?g:new E(g instanceof Error?g.message:String(g),"STOP_FAILED",!1);throw u(v),t(!1),(k=i.onError)==null||k.call(i,v),v}},[]),d=o.useCallback(async(b,k={})=>{var g,v;try{u(null),n(!0);const C={audioBlob:b,...k},N=await z.transcribe(C);return a(N.transcript),n(!1),(g=i.onTranscriptionComplete)==null||g.call(i,N),N}catch(C){const N=C instanceof E?C:new E(C instanceof Error?C.message:String(C),"TRANSCRIPTION_FAILED",!0);throw u(N),n(!1),(v=i.onError)==null||v.call(i,N),N}},[]),p=o.useCallback(()=>{z.cancelRecording(),t(!1),h(null)},[]);return{startRecording:m,stopRecording:f,transcribe:d,cancelRecording:p,isRecording:r,isTranscribing:s,transcript:l,error:c,audioBlob:w}},jt=i=>{const r=o.useRef(null),t=o.useRef(!1);o.useEffect(()=>{const s=()=>{document.hidden&&(t.current=!0,r.current&&(clearTimeout(r.current),r.current=null),i({type:"tab_switch",severity:"high",details:{action:"tab_hidden",reason:"Attempted to switch tabs or applications"}}),setTimeout(()=>{t.current=!1},100))},n=()=>{t.current||(r.current=setTimeout(()=>{t.current||i({type:"focus_loss",severity:"medium",details:{action:"window_blur",reason:"Focus lost from the interview window"}}),r.current=null},50))};return document.addEventListener("visibilitychange",s),window.addEventListener("blur",n),()=>{document.removeEventListener("visibilitychange",s),window.removeEventListener("blur",n),r.current&&clearTimeout(r.current)}},[i])},kt=()=>{o.useEffect(()=>{const i=document.createElement("style");return i.textContent=`
10
10
  * {
11
11
  -webkit-user-select: none !important;
12
12
  -moz-user-select: none !important;
@@ -19,7 +19,7 @@
19
19
  -ms-user-select: text !important;
20
20
  user-select: text !important;
21
21
  }
22
- `,document.head.appendChild(i),()=>{document.head.removeChild(i)}},[])};class kt{constructor(r={}){_(this,"config");_(this,"currentAudio",null);this.config={baseUrl:"http://localhost:8000",provider:"piper",voice:"string",speed:1,...r}}updateConfig(r){this.config={...this.config,...r}}async synthesizeSpeech(r){const{text:t,voice:s=this.config.voice,speed:n=this.config.speed}=r,l=new URLSearchParams;l.append("text",t),l.append("voice",s||"string"),l.append("speed",(n==null?void 0:n.toString())||"1");const a=await we(`${this.config.baseUrl}/speech/synthesize`,{method:"POST",headers:{accept:"application/json","X-TTS-Provider":this.config.provider||"piper","Content-Type":"application/x-www-form-urlencoded",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:l},{attempts:1,backoff:"fixed",baseDelay:1e3,maxDelay:1e3,jitter:!1});if(!a.ok)throw new Error(`TTS request failed: ${a.status} ${a.statusText}`);const c=a.headers.get("content-type");if(c&&c.includes("audio/"))return a.blob();try{const u=await a.json();throw new Error(`TTS Error: ${JSON.stringify(u)}`)}catch{throw new Error("TTS request failed with unknown error")}}async speak(r,t){var s,n;try{this.stop(),(s=t==null?void 0:t.onStart)==null||s.call(t);const l=await this.synthesizeSpeech(r),a=URL.createObjectURL(l);return this.currentAudio=new Audio(a),new Promise((c,u)=>{if(!this.currentAudio){u(new Error("Audio element not created"));return}const w=this.currentAudio;w.onended=()=>{var h;URL.revokeObjectURL(a),this.currentAudio=null,(h=t==null?void 0:t.onEnd)==null||h.call(t),c()},w.onerror=h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Audio playback failed: ${h}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),u(m)},w.play().catch(h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Failed to play audio: ${h.message}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),u(m)})})}catch(l){const a=l instanceof Error?l:new Error(`TTS Error: ${String(l)}`);throw(n=t==null?void 0:t.onError)==null||n.call(t,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const ue=new kt,Nt=(i={})=>{const[r,t]=o.useState(!1),[s,n]=o.useState(!1),[l,a]=o.useState(null);i.config&&ue.updateConfig(i.config);const c=o.useCallback(async(w,h={})=>{var m;try{a(null),n(!0);const f={text:w,...h};await ue.speak(f,{onStart:()=>{var d;n(!1),t(!0),(d=i.onStart)==null||d.call(i)},onEnd:()=>{var d;t(!1),(d=i.onEnd)==null||d.call(i)},onError:d=>{var p;t(!1),n(!1),a(d),(p=i.onError)==null||p.call(i,d)}})}catch(f){const d=f instanceof Error?f:new Error(String(f));throw a(d),t(!1),n(!1),(m=i.onError)==null||m.call(i,d),d}},[i]),u=o.useCallback(()=>{ue.stop(),t(!1),n(!1)},[]);return{speak:c,stop:u,isPlaying:r,isLoading:s,error:l}},Et=({onViolation:i,onEnd:r,maxViolations:t=5})=>{const{addViolation:s}=Je(),n=Qe(),l=Ke(),a=o.useRef(l);o.useEffect(()=>{a.current=l},[l]);const c=o.useCallback(w=>{r&&r(w,a.current)},[r]);return{logViolation:o.useCallback(({type:w,severity:h,details:m})=>{const f={id:rt(),type:w,severity:h,details:m,timestamp:Date.now()};s(f);const d=a.current+1;i&&i(f,d),d>=t&&c("excessive_violations")},[s,i,t,c]),onInterviewEnd:c,violationCount:l,logList:n}},Ct=()=>{o.useEffect(()=>{function i(){console.clear(),console.log(`
22
+ `,document.head.appendChild(i),()=>{document.head.removeChild(i)}},[])};class Nt{constructor(r={}){R(this,"config");R(this,"currentAudio",null);this.config={baseUrl:"http://localhost:8000",provider:"piper",voice:"string",speed:1,...r}}updateConfig(r){this.config={...this.config,...r}}async synthesizeSpeech(r){const{text:t,voice:s=this.config.voice,speed:n=this.config.speed}=r,l=new URLSearchParams;l.append("text",t),l.append("voice",s||"string"),l.append("speed",(n==null?void 0:n.toString())||"1");const a=await ue(`${this.config.baseUrl}/speech/synthesize`,{method:"POST",headers:{accept:"application/json","X-TTS-Provider":this.config.provider||"piper","Content-Type":"application/x-www-form-urlencoded",...this.config.authToken&&{Authorization:`Bearer ${this.config.authToken}`}},body:l},{attempts:1,backoff:"fixed",baseDelay:1e3,maxDelay:1e3,jitter:!1});if(!a.ok)throw new Error(`TTS request failed: ${a.status} ${a.statusText}`);const c=a.headers.get("content-type");if(c&&c.includes("audio/"))return a.blob();try{const u=await a.json();throw new Error(`TTS Error: ${JSON.stringify(u)}`)}catch{throw new Error("TTS request failed with unknown error")}}async speak(r,t){var s,n;try{this.stop(),(s=t==null?void 0:t.onStart)==null||s.call(t);const l=await this.synthesizeSpeech(r),a=URL.createObjectURL(l);return this.currentAudio=new Audio(a),new Promise((c,u)=>{if(!this.currentAudio){u(new Error("Audio element not created"));return}const w=this.currentAudio;w.onended=()=>{var h;URL.revokeObjectURL(a),this.currentAudio=null,(h=t==null?void 0:t.onEnd)==null||h.call(t),c()},w.onerror=h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Audio playback failed: ${h}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),u(m)},w.play().catch(h=>{var f;URL.revokeObjectURL(a),this.currentAudio=null;const m=new Error(`Failed to play audio: ${h.message}`);(f=t==null?void 0:t.onError)==null||f.call(t,m),u(m)})})}catch(l){const a=l instanceof Error?l:new Error(`TTS Error: ${String(l)}`);throw(n=t==null?void 0:t.onError)==null||n.call(t,a),a}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const he=new Nt,Et=(i={})=>{const[r,t]=o.useState(!1),[s,n]=o.useState(!1),[l,a]=o.useState(null);i.config&&he.updateConfig(i.config);const c=o.useCallback(async(w,h={})=>{var m;try{a(null),n(!0);const f={text:w,...h};await he.speak(f,{onStart:()=>{var d;n(!1),t(!0),(d=i.onStart)==null||d.call(i)},onEnd:()=>{var d;t(!1),(d=i.onEnd)==null||d.call(i)},onError:d=>{var p;t(!1),n(!1),a(d),(p=i.onError)==null||p.call(i,d)}})}catch(f){const d=f instanceof Error?f:new Error(String(f));throw a(d),t(!1),n(!1),(m=i.onError)==null||m.call(i,d),d}},[i]),u=o.useCallback(()=>{he.stop(),t(!1),n(!1)},[]);return{speak:c,stop:u,isPlaying:r,isLoading:s,error:l}},Ct=({onViolation:i,onEnd:r,maxViolations:t=5})=>{const{addViolation:s}=Xe(),n=Ke(),l=Je(),a=o.useRef(l);o.useEffect(()=>{a.current=l},[l]);const c=o.useCallback(w=>{r&&r(w,a.current)},[r]);return{logViolation:o.useCallback(({type:w,severity:h,details:m})=>{const f={id:st(),type:w,severity:h,details:m,timestamp:Date.now()};s(f);const d=a.current+1;i&&i(f,d),d>=t&&c("excessive_violations")},[s,i,t,c]),onInterviewEnd:c,violationCount:l,logList:n}},St=()=>{o.useEffect(()=>{function i(){console.clear(),console.log(`
23
23
  %c
24
24
  ╔═══════════════════════════════════════════════════════════════════════╗
25
25
  ║ ║
@@ -65,7 +65,7 @@
65
65
  │ │
66
66
  │ 💡 IMMEDIATE ACTION REQUIRED: │
67
67
  │ Close developer tools to continue interview │
68
- └─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const r={open:!1,orientation:null},t=160,s=setInterval(()=>{window.outerHeight-window.innerHeight>t||window.outerWidth-window.innerWidth>t?r.open||(r.open=!0,r.orientation=window.outerWidth-window.innerWidth>t?"vertical":"horizontal",i()):r.open&&(r.open=!1,console.log("%c🌟 Developer tools closed. Interview continues smoothly! ✨","color: #4ecdc4; font-weight: bold; text-shadow: 0 0 10px #4ecdc4;"))},500),n=a=>{if(a.keyCode===123||a.ctrlKey&&a.shiftKey&&(a.keyCode===73||a.keyCode===74)||a.ctrlKey&&a.keyCode===85)return a.preventDefault(),console.log("%c🎭 Nice try! Keyboard shortcuts are disabled during interviews ✨","color: #ffd93d; font-weight: bold; text-shadow: 0 0 10px #ffd93d;"),!1},l=a=>(a.preventDefault(),console.log("%c🌈 Right-click menu disabled for interview integrity! 🎪","color: #ff9ff3; font-weight: bold; text-shadow: 0 0 10px #ff9ff3;"),!1);return document.addEventListener("keydown",n),document.addEventListener("contextmenu",l),()=>{clearInterval(s),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",l),delete window.showStats,delete window.interviewTips}},[])},he=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),e.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),e.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),e.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),St=(i,r,t)=>Math.max(r,Math.min(t,i)),Pe=i=>{const r=Math.max(0,Math.floor(i)),t=Math.floor(r/60).toString().padStart(2,"0"),s=(r%60).toString().padStart(2,"0");return`${t}:${s}`},me=({total:i,remaining:r,size:t=64,strokeWidth:s=6,className:n="",showLabel:l=!0})=>{const a=Math.max(1,i||1),c=St(r/a,0,1),{radius:u,circumference:w,dashOffset:h,center:m}=o.useMemo(()=>{const p=(t-s)/2,y=2*Math.PI*p,k=y*(1-c),g=Math.round(s)%2===1,j=t/2+(g?.5:0);return{radius:p,circumference:y,dashOffset:k,center:j}},[t,s,c]),f=o.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),d=c<=.25?"iw-animate-pulse":"";return e.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:t,height:t},"aria-label":`Time remaining ${Pe(r)}`,role:"timer","aria-live":"polite",children:[e.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,preserveAspectRatio:"xMidYMid meet",children:e.jsxs("g",{transform:`rotate(-90 ${m} ${m})`,children:[e.jsx("circle",{cx:m,cy:m,r:u,className:"iw-stroke-gray-200",strokeWidth:s,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),e.jsx("circle",{cx:m,cy:m,r:u,className:`${f} ${d}`,strokeWidth:s,strokeLinecap:"round",fill:"none",strokeDasharray:w,strokeDashoffset:h,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),l&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:e.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${c<=.25?"iw-text-red-600":c<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:Pe(r)})})]})},Tt=({label:i,error:r,fullWidth:t=!1,className:s="",id:n,...l})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,c="iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all",u=r?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",w=t?"iw-w-full":"",h=s.includes("iw-h-full")||t?"iw-h-full":"";return e.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${t?"iw-w-full":""}`,children:[i&&e.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:i}),e.jsx("textarea",{id:a,className:`${c} ${u} ${w} ${h} ${s}`,"aria-invalid":r?"true":"false",...l}),r&&e.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:r})]})},It=({value:i,onChange:r,onSubmit:t,isSubmitDisabled:s,state:n,editingTime:l})=>{const a=c=>{c.key==="Enter"&&(c.ctrlKey||c.metaKey)&&!s&&(c.preventDefault(),t())};return e.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(he,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),e.jsx(me,{total:l,remaining:n.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[e.jsx(Tt,{value:i,onChange:r,onKeyDown:a,placeholder:"Type your answer here...",className:" iw-w-full iw-h-full iw-flex-1 iw-resize-none !iw-p-4 iw-bg-transparent iw-min-h-full focus-visible:iw-outline-0",onPaste:c=>c.preventDefault(),onCopy:c=>c.preventDefault(),onCut:c=>c.preventDefault(),onDrop:c=>c.preventDefault(),onDragOver:c=>c.preventDefault()}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:e.jsx(G,{onClick:t,disabled:s,children:"Submit Answer"})})]})]})},Mt=({className:i=""})=>{var n;const{authToken:r}=Te(),t=r?st(r):null,s=o.useRef(null);return o.useEffect(()=>{let l=null;return(async()=>{try{l=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),s.current&&(s.current.srcObject=l)}catch(c){console.error("Error accessing camera:",c)}})(),()=>{l&&l.getTracks().forEach(c=>c.stop())}},[]),e.jsxs("div",{className:`iw-relative ${i}`,children:[e.jsx("video",{ref:s,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-r-xl iw-min-h-[400px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}}),e.jsxs("div",{className:"iw-absolute iw-top-4 iw-left-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-black/40 iw-px-4 iw-py-2 iw-backdrop-blur-md",children:[e.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),e.jsx("span",{className:"iw-font-medium iw-text-white",children:"Recording"})]}),((n=t==null?void 0:t.data)==null?void 0:n.user_name)&&e.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-black/40 iw-px-4 iw-py-2 iw-backdrop-blur-md",children:e.jsx("span",{className:"iw-font-medium iw-text-white",children:t.data.user_name})})]})},At=({question:i,isLoading:r=!1})=>{const{baseColor:t}=V();return e.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:tt(t,.85),children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[e.jsx("div",{className:"iw-flex iw-flex-col iw-items-center iw-relative iw-h-32 iw-w-32 iw-shrink-0 iw-shadow iw-rounded-lg iw-bg-white",children:e.jsx("div",{className:"iw-mt-2",children:e.jsx("img",{src:"https://duf9q5sx7u.ufs.sh/f/va7H6eSeKAux755zByRN5Nq9LZurgIoJGYX6c0CEdRSDm8y2",alt:"brand_logo",className:"iw-h-28 iw-w-28"})})}),r?e.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):e.jsx("p",{className:"iw-text-lg iw-leading-8",children:i==null?void 0:i.question})]})})},Fe=({currentQuestion:i,phase:r,className:t="",children:s})=>e.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${t} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[e.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:e.jsx("div",{className:"iw-flex-1",children:e.jsx(At,{question:i,isLoading:r===I.FETCHING_QUESTION||r===I.IDLE})})}),e.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-[14px] iw-p-6",children:[e.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:e.jsx(Mt,{})}),e.jsx("div",{className:"iw-bg-white iw-rounded-r-xl iw-shadow iw-p-6",children:s})]})]}),Le=({isOpen:i,onClose:r,children:t,title:s,showCloseButton:n=!0,closeOnOverlayClick:l=!0,closeOnEscape:a=!0,className:c=""})=>{if(o.useEffect(()=>{if(!i||!a)return;const h=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i,a,r]),o.useEffect(()=>(i?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[i]),!i)return null;const u=h=>{l&&h.target===h.currentTarget&&r()},w=e.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[e.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:u}),e.jsxs("div",{className:`iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${c}`,role:"dialog","aria-modal":"true","aria-labelledby":s?"dialog-title":void 0,children:[(s||n)&&e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[s&&e.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:s}),n&&e.jsx("button",{onClick:r,className:"iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100","aria-label":"Close dialog",children:e.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:t})]})]});return B.createPortal(w,document.body)},Dt=({confirmExitInterview:i,isOpen:r,onClose:t})=>e.jsx(Le,{isOpen:r,onClose:t,title:"Exit Interview",closeOnOverlayClick:!1,children:e.jsxs("div",{className:"iw-space-y-5",children:[e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-rounded-xl iw-p-2",children:[e.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-bg-rose-100 iw-text-rose-600",children:"!"}),e.jsxs("div",{className:"iw-space-y-2",children:[e.jsx("p",{className:"iw-text-sm iw-font-semibold iw-text-rose-600",children:"Leaving now will end your interview !"}),e.jsx("p",{className:"iw-text-sm iw-text-slate-500",children:"Are you sure you want to exit? All progress will be lost and you will not be able to resume."})]})]}),e.jsxs("div",{className:"iw-flex iw-flex-col-reverse iw-gap-2 sm:iw-flex-row sm:iw-items-center sm:iw-justify-end iw-pb-1",children:[e.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-border iw-border-slate-200 iw-bg-white iw-px-4 iw-py-2 iw-text-sm iw-font-medium iw-text-slate-600 iw-shadow-sm iw-transition hover:iw-bg-slate-50",onClick:t,children:"Stay in interview"}),e.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-px-4 iw-py-2 iw-text-sm iw-font-semibold iw-text-white iw-transition hover:iw-brightness-110",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))",boxShadow:"0 12px 30px -16px rgba(244, 63, 94, 0.65)"},onClick:i,children:"Confirm exit"})]})]})}),$e=({title:i,onExit:r})=>{const{baseColor:t}=V(),[s,n]=o.useState(!1);return e.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[e.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-pb-4 iw-pt-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[e.jsx("div",{className:"iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",style:{backgroundColor:t},children:"N"}),e.jsx("p",{className:"iw-text-sm iw-font-medium",children:"Novara"})]}),e.jsx("h1",{className:"iw-text-base iw-font-bold",children:i}),e.jsx("button",{className:"iw-text-sm iw-text-white iw-px-4 iw-py-2 iw-rounded-md",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))"},onClick:()=>n(!0),children:"Exit Interview"})]}),e.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),e.jsx(Dt,{isOpen:s,confirmExitInterview:()=>{r(),n(!1)},onClose:()=>n(!1)})]})},Rt=({className:i="",width:r,height:t=56,barWidth:s=3,gap:n=2,fftSize:l=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:u=!0})=>{const{baseColor:w}=V(),h=o.useRef(null),m=o.useRef(null),f=o.useRef(null),d=o.useRef(null),p=o.useRef(null),y=o.useRef(null),k=o.useRef(!1),[g,j]=o.useState(null);o.useEffect(()=>{if(r||!m.current)return;const N=m.current,D=()=>{const S=h.current;if(!S)return;const T=N.clientWidth,x=t;S.width=Math.max(1,Math.floor(T*window.devicePixelRatio||1)),S.height=Math.max(1,Math.floor(x*window.devicePixelRatio||1))},v=new ResizeObserver(D);return v.observe(N),D(),()=>v.disconnect()},[r,t]),o.useEffect(()=>{if(!r)return;const N=h.current;N&&(N.width=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))),N.height=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))))},[r,t]),o.useEffect(()=>{let N=!1;return(async()=>{try{const v=new(window.AudioContext||window.webkitAudioContext);f.current=v;let S=c;if(!S){if(!u)return;S=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),k.current=!0}if(N)return;const T=v.createAnalyser();T.fftSize=l,T.smoothingTimeConstant=a,d.current=T;const x=v.createMediaStreamSource(S);p.current=x,x.connect(T),C()}catch(v){j((v==null?void 0:v.message)||"Failed to initialize microphone")}})(),()=>{var v,S,T,x;N=!0,y.current&&cancelAnimationFrame(y.current);try{(v=p.current)==null||v.disconnect()}catch{}try{(S=d.current)==null||S.disconnect()}catch{}k.current&&((x=((T=p.current)==null?void 0:T.mediaStream)||void 0)==null||x.getTracks().forEach(M=>M.stop())),f.current&&f.current.state!=="closed"&&f.current.close()}},[c,l,a,u]);const C=()=>{const N=h.current,D=d.current;if(!N||!D)return;const v=N.getContext("2d");if(!v)return;const S=window.devicePixelRatio||1,T=N.width,x=N.height,M=D.frequencyBinCount,P=new Uint8Array(M),L=()=>{y.current=requestAnimationFrame(L),D.getByteTimeDomainData(P),v.clearRect(0,0,T,x),v.fillStyle="rgba(0,0,0,0)",v.fillRect(0,0,T,x);const O=Math.max(1,Math.floor(s*S)),H=Math.max(1,Math.floor(n*S)),Y=O+H,Q=Math.max(8,Math.floor((T+H)/Y)),U=Math.floor(P.length/Q);for(let $=0;$<Q;$++){const R=Math.min(P.length-1,$*U),K=P[R]/128-1,q=Math.abs(K),xe=Math.pow(q,.6),J=Math.max(x*.06,xe*(x*.9)),pe=$*Y,be=(x-J)/2,ye=140-Math.min(140,140*q),X=85,ne=48+Math.floor(12*(1-q));v.fillStyle=`${w}`,v.shadowColor=`hsla(${ye}, ${X}%, ${ne}%, ${.25*q})`,v.shadowBlur=8*q;const b=Math.min(O/2,J/2);_t(v,pe,be,O,J,b),v.fill()}};L()};return e.jsxs("div",{ref:m,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${i}`,style:{height:t},children:[e.jsx("canvas",{ref:h,className:"iw-w-full iw-h-full"}),g&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:e.jsx("span",{className:"iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded",children:g})})]})};function _t(i,r,t,s,n,l){const a=Math.min(l,s/2,n/2);i.beginPath(),i.moveTo(r+a,t),i.lineTo(r+s-a,t),i.quadraticCurveTo(r+s,t,r+s,t+a),i.lineTo(r+s,t+n-a),i.quadraticCurveTo(r+s,t+n,r+s-a,t+n),i.lineTo(r+a,t+n),i.quadraticCurveTo(r,t+n,r,t+n-a),i.lineTo(r,t+a),i.quadraticCurveTo(r,t,r+a,t),i.closePath()}const Pt=({state:i,answeringTime:r,nextPhase:t,sttError:s})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"You may start speaking now. We're listening...."}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(he,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),e.jsx(me,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"Done talking? Click the button to review your answer."})]}),e.jsxs("div",{children:[e.jsx(Rt,{}),s&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",s.message]})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(G,{onClick:()=>{t()},children:"Transcribe My Answer"})})]});function Ft(){const[i,r]=o.useState(!0),t=o.useMemo(()=>[0,1,2].map(s=>({id:s})),[]);return o.useEffect(()=>{const s=setInterval(()=>{r(n=>!n)},1500);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[e.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:t.map((s,n)=>{const l=n*50,a=i?l:l+12,c=i?1:.08,u=n*140;return e.jsx("div",{role:"presentation",className:"iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",style:{top:0,transform:`translateY(${a}px)`,opacity:c,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${u}ms, opacity 400ms ease ${u}ms`},children:e.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[e.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),e.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},s.id)})}),e.jsx("div",{className:"iw-text-center",children:e.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const Lt=({size:i="192px",className:r,colors:t,animationDuration:s=20})=>{const l={...{bg:"oklch(95% 0.02 264.695)",c1:"oklch(75% 0.15 350)",c2:"oklch(80% 0.12 200)",c3:"oklch(78% 0.14 280)"},...t},a=parseInt(i.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),u=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),w=a<50?Math.max(a*.004,.05):Math.max(a*.008,.1),h=a<50?Math.max(a*.004,.5):Math.max(a*.008,2),m=a<30?"0%":a<50?"5%":a<100?"15%":"25%",f=a<30?1.1:a<50?Math.max(u*1.2,1.3):u;return e.jsx("div",{className:`siri-orb ${r}`,style:{width:i,height:i,"--bg":l.bg,"--c1":l.c1,"--c2":l.c2,"--c3":l.c3,"--animation-duration":`${s}s`,"--blur-amount":`${c}px`,"--contrast-amount":f,"--dot-size":`${w}px`,"--shadow-spread":`${h}px`,"--mask-radius":m},children:e.jsx("style",{children:`
68
+ └─────────────────────────────────────────────────────────────┘`,"color: #ffd93d; font-size: 14px; font-family: monospace; background: rgba(255, 217, 61, 0.1); padding: 10px;")}const r={open:!1,orientation:null},t=160,s=setInterval(()=>{window.outerHeight-window.innerHeight>t||window.outerWidth-window.innerWidth>t?r.open||(r.open=!0,r.orientation=window.outerWidth-window.innerWidth>t?"vertical":"horizontal",i()):r.open&&(r.open=!1,console.log("%c🌟 Developer tools closed. Interview continues smoothly! ✨","color: #4ecdc4; font-weight: bold; text-shadow: 0 0 10px #4ecdc4;"))},500),n=a=>{if(a.keyCode===123||a.ctrlKey&&a.shiftKey&&(a.keyCode===73||a.keyCode===74)||a.ctrlKey&&a.keyCode===85)return a.preventDefault(),console.log("%c🎭 Nice try! Keyboard shortcuts are disabled during interviews ✨","color: #ffd93d; font-weight: bold; text-shadow: 0 0 10px #ffd93d;"),!1},l=a=>(a.preventDefault(),console.log("%c🌈 Right-click menu disabled for interview integrity! 🎪","color: #ff9ff3; font-weight: bold; text-shadow: 0 0 10px #ff9ff3;"),!1);return document.addEventListener("keydown",n),document.addEventListener("contextmenu",l),()=>{clearInterval(s),document.removeEventListener("keydown",n),document.removeEventListener("contextmenu",l),delete window.showStats,delete window.interviewTips}},[])},me=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),e.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),e.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),e.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Tt=(i,r,t)=>Math.max(r,Math.min(t,i)),Fe=i=>{const r=Math.max(0,Math.floor(i)),t=Math.floor(r/60).toString().padStart(2,"0"),s=(r%60).toString().padStart(2,"0");return`${t}:${s}`},fe=({total:i,remaining:r,size:t=64,strokeWidth:s=6,className:n="",showLabel:l=!0})=>{const a=Math.max(1,i||1),c=Tt(r/a,0,1),{radius:u,circumference:w,dashOffset:h,center:m}=o.useMemo(()=>{const p=(t-s)/2,b=2*Math.PI*p,k=b*(1-c),g=Math.round(s)%2===1,v=t/2+(g?.5:0);return{radius:p,circumference:b,dashOffset:k,center:v}},[t,s,c]),f=o.useMemo(()=>c<=.25?"iw-stroke-red-500":c<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[c]),d=c<=.25?"iw-animate-pulse":"";return e.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${n}`,style:{width:t,height:t},"aria-label":`Time remaining ${Fe(r)}`,role:"timer","aria-live":"polite",children:[e.jsx("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,preserveAspectRatio:"xMidYMid meet",children:e.jsxs("g",{transform:`rotate(-90 ${m} ${m})`,children:[e.jsx("circle",{cx:m,cy:m,r:u,className:"iw-stroke-gray-200",strokeWidth:s,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),e.jsx("circle",{cx:m,cy:m,r:u,className:`${f} ${d}`,strokeWidth:s,strokeLinecap:"round",fill:"none",strokeDasharray:w,strokeDashoffset:h,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),l&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:e.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${c<=.25?"iw-text-red-600":c<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:Fe(r)})})]})},It=({label:i,error:r,fullWidth:t=!1,className:s="",id:n,...l})=>{const a=n||`textarea-${Math.random().toString(36).substring(2,9)}`,c="iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-transition-all",u=r?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",w=t?"iw-w-full":"",h=s.includes("iw-h-full")||t?"iw-h-full":"";return e.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${t?"iw-w-full":""}`,children:[i&&e.jsx("label",{htmlFor:a,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:i}),e.jsx("textarea",{id:a,className:`${c} ${u} ${w} ${h} ${s}`,"aria-invalid":r?"true":"false",...l}),r&&e.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:r})]})},Mt=({value:i,onChange:r,onSubmit:t,isSubmitDisabled:s,state:n,editingTime:l})=>{const a=c=>{c.key==="Enter"&&(c.ctrlKey||c.metaKey)&&!s&&(c.preventDefault(),t())};return e.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(me,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),e.jsx(fe,{total:l,remaining:n.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[e.jsx(It,{value:i,onChange:r,onKeyDown:a,placeholder:"Type your answer here...",className:" iw-w-full iw-h-full iw-flex-1 iw-resize-none !iw-p-4 iw-bg-transparent iw-min-h-full focus-visible:iw-outline-0",onPaste:c=>c.preventDefault(),onCopy:c=>c.preventDefault(),onCut:c=>c.preventDefault(),onDrop:c=>c.preventDefault(),onDragOver:c=>c.preventDefault()}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:e.jsx(G,{onClick:t,disabled:s,children:"Submit Answer"})})]})]})},At=({className:i=""})=>{var n;const{authToken:r}=Ie(),t=r?nt(r):null,s=o.useRef(null);return o.useEffect(()=>{let l=null;return(async()=>{try{l=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),s.current&&(s.current.srcObject=l)}catch(c){console.error("Error accessing camera:",c)}})(),()=>{l&&l.getTracks().forEach(c=>c.stop())}},[]),e.jsxs("div",{className:`iw-relative ${i}`,children:[e.jsx("video",{ref:s,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-r-xl iw-min-h-[400px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}}),e.jsxs("div",{className:"iw-absolute iw-top-4 iw-left-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-black/40 iw-px-4 iw-py-2 iw-backdrop-blur-md",children:[e.jsx("div",{className:"iw-size-2 iw-animate-pulse iw-rounded-full iw-bg-red-500"}),e.jsx("span",{className:"iw-font-medium iw-text-white",children:"Recording"})]}),((n=t==null?void 0:t.data)==null?void 0:n.user_name)&&e.jsx("div",{className:"iw-absolute iw-bottom-4 iw-right-4 iw-inline-flex iw-items-center iw-gap-2 iw-rounded-lg iw-border iw-border-white/10 iw-bg-black/40 iw-px-4 iw-py-2 iw-backdrop-blur-md",children:e.jsx("span",{className:"iw-font-medium iw-text-white",children:t.data.user_name})})]})},Dt=({question:i,isLoading:r=!1})=>{const{baseColor:t}=V();return e.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:it(t,.85),children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[e.jsx("div",{className:"iw-flex iw-flex-col iw-items-center iw-relative iw-h-32 iw-w-32 iw-shrink-0 iw-shadow iw-rounded-lg iw-bg-white",children:e.jsx("div",{className:"iw-mt-2",children:e.jsx("img",{src:"https://duf9q5sx7u.ufs.sh/f/va7H6eSeKAux755zByRN5Nq9LZurgIoJGYX6c0CEdRSDm8y2",alt:"brand_logo",className:"iw-h-28 iw-w-28"})})}),r?e.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),e.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):e.jsx("p",{className:"iw-text-lg iw-leading-8",children:i==null?void 0:i.question})]})})},Le=({currentQuestion:i,phase:r,className:t="",children:s})=>e.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${t} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[e.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:e.jsx("div",{className:"iw-flex-1",children:e.jsx(Dt,{question:i,isLoading:r===I.FETCHING_QUESTION||r===I.IDLE})})}),e.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-[14px] iw-p-6",children:[e.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:e.jsx(At,{})}),e.jsx("div",{className:"iw-bg-white iw-rounded-r-xl iw-shadow iw-p-6",children:s})]})]}),$e=({isOpen:i,onClose:r,children:t,title:s,showCloseButton:n=!0,closeOnOverlayClick:l=!0,closeOnEscape:a=!0,className:c=""})=>{if(o.useEffect(()=>{if(!i||!a)return;const h=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[i,a,r]),o.useEffect(()=>(i?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[i]),!i)return null;const u=h=>{l&&h.target===h.currentTarget&&r()},w=e.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[e.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:u}),e.jsxs("div",{className:`iw-relative iw-bg-white iw-rounded-lg iw-shadow-xl iw-max-w-md iw-w-full iw-mx-4 iw-max-h-[90vh] iw-overflow-hidden ${c}`,role:"dialog","aria-modal":"true","aria-labelledby":s?"dialog-title":void 0,children:[(s||n)&&e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[s&&e.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:s}),n&&e.jsx("button",{onClick:r,className:"iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100","aria-label":"Close dialog",children:e.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:t})]})]});return B.createPortal(w,document.body)},_t=({confirmExitInterview:i,isOpen:r,onClose:t})=>e.jsx($e,{isOpen:r,onClose:t,title:"Exit Interview",closeOnOverlayClick:!1,children:e.jsxs("div",{className:"iw-space-y-5",children:[e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-3 iw-rounded-xl iw-p-2",children:[e.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-flex-none iw-items-center iw-justify-center iw-rounded-full iw-bg-rose-100 iw-text-rose-600",children:"!"}),e.jsxs("div",{className:"iw-space-y-2",children:[e.jsx("p",{className:"iw-text-sm iw-font-semibold iw-text-rose-600",children:"Leaving now will end your interview !"}),e.jsx("p",{className:"iw-text-sm iw-text-slate-500",children:"Are you sure you want to exit? All progress will be lost and you will not be able to resume."})]})]}),e.jsxs("div",{className:"iw-flex iw-flex-col-reverse iw-gap-2 sm:iw-flex-row sm:iw-items-center sm:iw-justify-end iw-pb-1",children:[e.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-border iw-border-slate-200 iw-bg-white iw-px-4 iw-py-2 iw-text-sm iw-font-medium iw-text-slate-600 iw-shadow-sm iw-transition hover:iw-bg-slate-50",onClick:t,children:"Stay in interview"}),e.jsx("button",{className:"iw-inline-flex iw-items-center iw-justify-center iw-rounded-lg iw-px-4 iw-py-2 iw-text-sm iw-font-semibold iw-text-white iw-transition hover:iw-brightness-110",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))",boxShadow:"0 12px 30px -16px rgba(244, 63, 94, 0.65)"},onClick:i,children:"Confirm exit"})]})]})}),Oe=({title:i,onExit:r})=>{const{baseColor:t}=V(),[s,n]=o.useState(!1);return e.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[e.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-pb-4 iw-pt-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[e.jsx("div",{className:"iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",style:{backgroundColor:t},children:"N"}),e.jsx("p",{className:"iw-text-sm iw-font-medium",children:"Novara"})]}),e.jsx("h1",{className:"iw-text-base iw-font-bold",children:i}),e.jsx("button",{className:"iw-text-sm iw-text-white iw-px-4 iw-py-2 iw-rounded-md",style:{background:"linear-gradient(to right, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8))"},onClick:()=>n(!0),children:"Exit Interview"})]}),e.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),e.jsx(_t,{isOpen:s,confirmExitInterview:()=>{r(),n(!1)},onClose:()=>n(!1)})]})},Rt=({className:i="",width:r,height:t=56,barWidth:s=3,gap:n=2,fftSize:l=1024,smoothingTimeConstant:a=.8,mediaStream:c,startOnMount:u=!0})=>{const{baseColor:w}=V(),h=o.useRef(null),m=o.useRef(null),f=o.useRef(null),d=o.useRef(null),p=o.useRef(null),b=o.useRef(null),k=o.useRef(!1),[g,v]=o.useState(null);o.useEffect(()=>{if(r||!m.current)return;const N=m.current,D=()=>{const S=h.current;if(!S)return;const T=N.clientWidth,x=t;S.width=Math.max(1,Math.floor(T*window.devicePixelRatio||1)),S.height=Math.max(1,Math.floor(x*window.devicePixelRatio||1))},j=new ResizeObserver(D);return j.observe(N),D(),()=>j.disconnect()},[r,t]),o.useEffect(()=>{if(!r)return;const N=h.current;N&&(N.width=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))),N.height=Math.max(1,Math.floor(t*(window.devicePixelRatio||1))))},[r,t]),o.useEffect(()=>{let N=!1;return(async()=>{try{const j=new(window.AudioContext||window.webkitAudioContext);f.current=j;let S=c;if(!S){if(!u)return;S=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),k.current=!0}if(N)return;const T=j.createAnalyser();T.fftSize=l,T.smoothingTimeConstant=a,d.current=T;const x=j.createMediaStreamSource(S);p.current=x,x.connect(T),C()}catch(j){v((j==null?void 0:j.message)||"Failed to initialize microphone")}})(),()=>{var j,S,T,x;N=!0,b.current&&cancelAnimationFrame(b.current);try{(j=p.current)==null||j.disconnect()}catch{}try{(S=d.current)==null||S.disconnect()}catch{}k.current&&((x=((T=p.current)==null?void 0:T.mediaStream)||void 0)==null||x.getTracks().forEach(M=>M.stop())),f.current&&f.current.state!=="closed"&&f.current.close()}},[c,l,a,u]);const C=()=>{const N=h.current,D=d.current;if(!N||!D)return;const j=N.getContext("2d");if(!j)return;const S=window.devicePixelRatio||1,T=N.width,x=N.height,M=D.frequencyBinCount,P=new Uint8Array(M),L=()=>{b.current=requestAnimationFrame(L),D.getByteTimeDomainData(P),j.clearRect(0,0,T,x),j.fillStyle="rgba(0,0,0,0)",j.fillRect(0,0,T,x);const O=Math.max(1,Math.floor(s*S)),H=Math.max(1,Math.floor(n*S)),Y=O+H,Q=Math.max(8,Math.floor((T+H)/Y)),q=Math.floor(P.length/Q);for(let $=0;$<Q;$++){const _=Math.min(P.length-1,$*q),K=P[_]/128-1,U=Math.abs(K),pe=Math.pow(U,.6),J=Math.max(x*.06,pe*(x*.9)),be=$*Y,ye=(x-J)/2,ve=140-Math.min(140,140*U),X=85,ne=48+Math.floor(12*(1-U));j.fillStyle=`${w}`,j.shadowColor=`hsla(${ve}, ${X}%, ${ne}%, ${.25*U})`,j.shadowBlur=8*U;const ae=Math.min(O/2,J/2);Pt(j,be,ye,O,J,ae),j.fill()}};L()};return e.jsxs("div",{ref:m,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${i}`,style:{height:t},children:[e.jsx("canvas",{ref:h,className:"iw-w-full iw-h-full"}),g&&e.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:e.jsx("span",{className:"iw-text-xs iw-text-red-600 iw-bg-red-50 iw-border iw-border-red-200 iw-px-2 iw-py-1 iw-rounded",children:g})})]})};function Pt(i,r,t,s,n,l){const a=Math.min(l,s/2,n/2);i.beginPath(),i.moveTo(r+a,t),i.lineTo(r+s-a,t),i.quadraticCurveTo(r+s,t,r+s,t+a),i.lineTo(r+s,t+n-a),i.quadraticCurveTo(r+s,t+n,r+s-a,t+n),i.lineTo(r+a,t+n),i.quadraticCurveTo(r,t+n,r,t+n-a),i.lineTo(r,t+a),i.quadraticCurveTo(r,t,r+a,t),i.closePath()}const Ft=({state:i,answeringTime:r,nextPhase:t,sttError:s})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"You may start speaking now. We're listening...."}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(me,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),e.jsx(fe,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"Done talking? Click the button to review your answer."})]}),e.jsxs("div",{children:[e.jsx(Rt,{}),s&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",s.message]})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(G,{onClick:()=>{t()},children:"Transcribe My Answer"})})]});function Lt(){const[i,r]=o.useState(!0),t=o.useMemo(()=>[0,1,2].map(s=>({id:s})),[]);return o.useEffect(()=>{const s=setInterval(()=>{r(n=>!n)},1500);return()=>clearInterval(s)},[]),e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[e.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:t.map((s,n)=>{const l=n*50,a=i?l:l+12,c=i?1:.08,u=n*140;return e.jsx("div",{role:"presentation",className:"iw-absolute iw-w-full iw-rounded-lg iw-p-4 iw-shadow-md iw-bg-gradient-to-b iw-from-gray-50 iw-to-gray-100 iw-overflow-hidden",style:{top:0,transform:`translateY(${a}px)`,opacity:c,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${u}ms, opacity 400ms ease ${u}ms`},children:e.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[e.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),e.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),e.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},s.id)})}),e.jsx("div",{className:"iw-text-center",children:e.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const $t=({size:i="192px",className:r,colors:t,animationDuration:s=20})=>{const l={...{bg:"oklch(95% 0.02 264.695)",c1:"oklch(75% 0.15 350)",c2:"oklch(80% 0.12 200)",c3:"oklch(78% 0.14 280)"},...t},a=parseInt(i.replace("px",""),10),c=a<50?Math.max(a*.008,1):Math.max(a*.015,4),u=a<50?Math.max(a*.004,1.2):Math.max(a*.008,1.5),w=a<50?Math.max(a*.004,.05):Math.max(a*.008,.1),h=a<50?Math.max(a*.004,.5):Math.max(a*.008,2),m=a<30?"0%":a<50?"5%":a<100?"15%":"25%",f=a<30?1.1:a<50?Math.max(u*1.2,1.3):u;return e.jsx("div",{className:`siri-orb ${r}`,style:{width:i,height:i,"--bg":l.bg,"--c1":l.c1,"--c2":l.c2,"--c3":l.c3,"--animation-duration":`${s}s`,"--blur-amount":`${c}px`,"--contrast-amount":f,"--dot-size":`${w}px`,"--shadow-spread":`${h}px`,"--mask-radius":m},children:e.jsx("style",{children:`
69
69
  @property --angle {
70
70
  syntax: "<angle>";
71
71
  inherits: false;
@@ -170,4 +170,4 @@
170
170
  animation: none;
171
171
  }
172
172
  }
173
- `})})};function $t({ttsError:i}){return e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[e.jsx(Lt,{size:"80px"}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",i.message]}),e.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const Ot=({state:i,thinkingTime:r,nextPhase:t})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below."})]}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(he,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),e.jsx(me,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(G,{onClick:()=>{t()},children:"Start Answering"})})]}),Ut=({sttError:i})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[e.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),e.jsx("path",{d:"M28.127 14c.276 7.685 6.442 13.851 14.127 14.127-7.684.276-13.85 6.442-14.127 14.127-.275-7.685-6.442-13.851-14.126-14.127 7.684-.276 13.85-6.442 14.126-14.127zM38.937 31.873A7.331 7.331 0 0046 38.937 7.331 7.331 0 0038.937 46a7.331 7.331 0 00-7.064-7.063 7.331 7.331 0 007.064-7.064z",fill:"#fff"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),e.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3",children:"Just a moment... We're analyzing your response"}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After transcription, you'll have 45 sec to review your answer."}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",i.message,i.recoverable&&" (attempting to continue)"]})]}),re=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("path",{d:"M12 17h.01"})]}),qt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Wt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Bt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),fe=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),Gt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),se=5;function Vt({isOpen:i,onClose:r,warningCount:t,violationType:s,onDisqualify:n}){const[l,a]=o.useState(10),c=o.useRef(r);if(o.useEffect(()=>{c.current=r},[r]),o.useEffect(()=>{if(!i)return;const f=setInterval(()=>{a(d=>d<=1?(c.current(),10):d-1)},1e3);return()=>clearInterval(f)},[i]),o.useEffect(()=>{i&&a(10)},[i]),o.useEffect(()=>(i?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[i]),!i)return null;const w=(()=>{switch(s){case"tab_switch":return{title:"Tab Switch Detected",description:"You attempted to switch to another tab or reload application.",icon:e.jsx(Wt,{className:"iw-h-5 iw-w-5"})};case"fullscreen_exit":return{title:"Full Screen Exit Detected",description:"You attempted to exit full screen mode.",icon:e.jsx(_e,{className:"iw-h-5 iw-w-5"})};case"focus_loss":return{title:"Focus Loss Detected",description:"You lost focus from the interview window.",icon:e.jsx(Bt,{className:"iw-h-5 iw-w-5"})};case"blocked_shortcut":return{title:"Keyboard Shortcut Blocked",description:"You attempted to use a blocked keyboard shortcut.",icon:e.jsx(fe,{className:"iw-h-5 iw-w-5"})};case"right_click_attempt":return{title:"Right Click Attempted",description:"You attempted to use the right click.",icon:e.jsx(Gt,{className:"iw-h-5 iw-w-5"})};case"alt_tab_attempt":return{title:"Alt + Tab Attempted",description:"You attempted to use the Alt + Tab shortcut.",icon:e.jsx(fe,{className:"iw-h-5 iw-w-5"})};case"blocked_function_key":return{title:"Function Key Blocked",description:"You attempted to use a blocked function key.",icon:e.jsx(fe,{className:"iw-h-5 iw-w-5"})};default:return{title:"Violation Detected",description:"You attempted to perform an action that is not allowed.",icon:e.jsx(re,{className:"iw-h-5 iw-w-5"})}}})(),h=se-t,m=()=>{t+1>se?n():r()};return e.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/60 iw-p-4 iw-backdrop-blur-sm",children:e.jsxs("div",{className:"iw-w-full iw-max-w-md iw-rounded-2xl iw-border iw-border-gray-100 iw-bg-white iw-shadow-xl",children:[e.jsxs("div",{className:"iw-p-6 iw-pb-0",children:[e.jsxs("div",{className:"iw-mb-6 iw-flex iw-items-start iw-gap-4",children:[e.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-red-50",children:e.jsx(re,{className:"iw-h-6 iw-w-6 iw-text-red-500"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h2",{className:"iw-mb-1 iw-text-xl iw-font-semibold iw-text-gray-900",children:"Security Violation"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx("span",{className:"iw-text-sm iw-text-gray-500",children:"Warning"}),e.jsx("div",{className:"iw-flex iw-gap-1",children:Array.from({length:se}).map((f,d)=>e.jsx("div",{className:`iw-h-2 iw-w-2 iw-rounded-full ${d<=t-1?"iw-bg-red-500":"iw-bg-gray-200"}`},d))}),e.jsxs("span",{className:"iw-text-sm iw-text-gray-500",children:["(",t,"/",se,")"]})]})]})]}),e.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-border iw-border-red-100 iw-p-5",style:{background:"linear-gradient(to right, rgb(254, 242, 242), rgb(254, 245, 235))",borderColor:"rgb(254, 226, 226)"},children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-xl iw-bg-white iw-shadow-sm",children:w.icon}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h3",{className:"iw-mb-2 iw-font-semibold iw-text-gray-900",children:w.title}),e.jsx("p",{className:"iw-text-sm iw-leading-relaxed iw-text-gray-700",children:w.description}),e.jsxs("div",{className:"iw-mt-3 iw-flex iw-items-center iw-gap-2 iw-text-xs iw-text-red-600",children:[e.jsx(Re,{className:"iw-h-3 iw-w-3"}),e.jsx("span",{children:"This action is monitored for interview integrity"})]})]})]})}),e.jsxs("div",{className:"iw-mb-5 iw-grid iw-grid-cols-2 iw-gap-3",children:[e.jsx("div",{className:"iw-rounded-xl iw-border iw-border-amber-200 iw-bg-amber-50 iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsx("div",{className:"iw-mb-1 iw-text-2xl iw-font-bold iw-text-amber-600",children:h}),e.jsx("div",{className:"iw-text-xs iw-font-medium iw-text-amber-700",children:"Warnings Left"})]})}),e.jsx("div",{className:"iw-border-primary-100 iw-bg-primary-50 iw-rounded-xl iw-border iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsxs("div",{className:"iw-mb-1 iw-flex iw-items-center iw-justify-center iw-gap-1.5",children:[e.jsx(qt,{className:"iw-text-primary-600 iw-h-4 iw-w-4"}),e.jsx("span",{className:"iw-text-primary-600 iw-text-2xl iw-font-bold",children:l})]}),e.jsx("div",{className:"iw-text-primary-700 iw-text-xs iw-font-medium",children:"Auto Close"})]})})]}),h===1&&e.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-p-4 iw-text-white",style:{background:"linear-gradient(to right, rgba(220, 38, 38, 0.9), rgba(239, 68, 68, 0.9))"},children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[e.jsx("div",{className:"iw-flex iw-h-8 iw-w-8 iw-items-center iw-justify-center iw-rounded-full iw-bg-white/20",children:e.jsx(re,{className:"iw-h-4 iw-w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"iw-text-sm iw-font-semibold",children:"Final Warning"}),e.jsx("div",{className:"iw-text-xs iw-text-red-100",children:"Next violation will disqualify you from this interview"})]})]})})]}),e.jsxs("div",{className:"iw-p-6 iw-pt-0",children:[e.jsx(G,{onClick:m,className:"iw-h-12 iw-w-full iw-rounded-xl iw-bg-gray-800 iw-text-sm iw-font-medium iw-text-white iw-hover:bg-gray-800",children:"I Understand - Continue Interview"}),e.jsx("p",{className:"iw-text-gray-500 iw-mt-3 iw-text-center iw-text-xs",children:"Please maintain focus and avoid switching tabs, exiting fullscreen, using shortcuts or right-clicking."})]})]})})}const zt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Ht=({showHardReloadWarning:i,onContinue:r})=>{const t=()=>{r()};return e.jsxs(Le,{isOpen:i,onClose:t,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[e.jsx("div",{className:"iw-absolute iw-inset-x-0 iw-top-0 iw-h-1 iw-bg-gradient-to-r iw-from-red-500 iw-to-red-600"}),e.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx(re,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),e.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),e.jsx("div",{className:"iw-pt-4 iw-pb-6",children:e.jsx("p",{className:"iw-text-center iw-text-sm iw-leading-relaxed iw-text-gray-500/90",children:"Exiting full screen mode or reloading this page during the session is strictly prohibited. Any attempt to do so will be recorded and may lead to penalties."})}),e.jsx("div",{className:"iw-pt-2 iw-pb-4",children:e.jsxs("button",{onClick:t,className:"iw-w-full iw-flex iw-items-center iw-justify-center iw-gap-2 iw-px-4 iw-py-3 iw-bg-gray-100 iw-text-gray-600 iw-rounded-md iw-font-medium iw-transition-colors hover:iw-bg-gray-200 focus:iw-outline-none focus:iw-ring-2 focus:iw-ring-gray-400 focus:iw-ring-offset-2",children:[e.jsx(zt,{className:"iw-size-4"}),"Continue Session"]})})]})},Yt=o.forwardRef(({children:i,onDisqualify:r},t)=>{const[s,n]=o.useState(!1),[l,a]=o.useState(!1),[c,u]=o.useState(!1),[w,h]=o.useState("fullscreen_exit"),{logViolation:m,violationCount:f}=Et({maxViolations:5,onViolation:g=>{l||(n(!0),h(g.type))}}),{enterFullScreen:d,isFullScreen:p,exitFullScreen:y}=ht({onFullScreenChange(g){!g&&!l&&!c&&(n(!0),m({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),g&&u(!1)}});o.useEffect(()=>{d()},[]),o.useImperativeHandle(t,()=>({exitFullScreenIntentionally:async()=>{u(!0),n(!1),a(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(g){console.error("Failed to exit fullscreen:",g)}}}),[]),vt(m),pt(m),jt(),Ct();const k=()=>{a(!0),y(),n(!1),r==null||r()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:i}),e.jsx(Vt,{warningCount:f,isOpen:s,violationType:w,onClose:()=>{n(!1),d()},onDisqualify:k}),!s&&f>0&&!l&&!c&&e.jsx(Ht,{showHardReloadWarning:!p,logViolation:m,onContinue:d})]})}),Qt=({interviewTitle:i,interviewId:r,onComplete:t,onDisqualify:s,className:n=""})=>{const l=xt(),{baseUrl:a,authToken:c}=Te(),{timers:u,stt:w,tts:h,proctoring:m}=Xe(),f=o.useRef(null),[d,p]=o.useState(null),[y,k]=o.useState(""),g=o.useRef(""),j=o.useRef(null),C={thinkingTime:(u==null?void 0:u.thinkingDuration)||30,answeringTime:(u==null?void 0:u.answeringDuration)||120,editingTime:(u==null?void 0:u.editingDuration)||30},{thinkingTime:N,answeringTime:D,editingTime:v}=C;o.useEffect(()=>{g.current=y},[y]);const S=o.useRef(!1),{speak:T,stop:x,error:M}=Nt({config:{baseUrl:a,provider:h==null?void 0:h.provider,authToken:c},onEnd:()=>{S.current=!1,R()},onError:()=>{S.current||(S.current=!0,R())}}),P=o.useRef(!1),L=o.useRef(!1),{startRecording:O,stopRecording:H,transcribe:Y,error:Q}=yt({config:{baseUrl:a,provider:w==null?void 0:w.provider,model:w==null?void 0:w.model,language:w==null?void 0:w.language,authToken:c},onStart:()=>{P.current=!1,L.current=!1},onStop:()=>{},onTranscriptionComplete:b=>{k(b.transcript),L.current||(L.current=!0,R())},onError:b=>{console.error("STT Error:",b),P.current||(P.current=!0,R())}}),{state:U,startQuestion:$,nextPhase:R,completeInterview:K}=wt({config:{thinkingDuration:N,answeringDuration:D,editingDuration:v},callbacks:{onPhaseChange:b=>{switch(b){case I.FETCHING_QUESTION:q();break;case I.READING_QUESTION:pe();break;case I.ANSWERING:be();break;case I.TRANSCRIBING:ye();break;case I.SUBMITTING:J();break}},onInterviewEnd:()=>{t==null||t()}}});o.useEffect(()=>{$()},[]);const{execute:q,loading:xe}=ut(async()=>{var W,Z;const b=await l.generateQuestion({interviewId:r,question:((W=j.current)==null?void 0:W.question)||"",qnaId:((Z=j.current)==null?void 0:Z.qna_id)||"",answer:g.current});return j.current=b.data,b},{onSuccess:async b=>{b&&b.data&&(k(""),p(b.data),R())},onError:b=>{console.error("Failed to fetch questions:",b)}}),J=o.useCallback(async()=>{$()},[$]),pe=o.useCallback(async()=>{var b;if((b=j.current)!=null&&b.question)try{S.current=!1,await T(j.current.question),j.current.is_interview_done&&(await it(2e3),K())}catch(W){console.error("Failed to speak question:",W)}else R()},[T,R,K]),be=o.useCallback(async()=>{try{await O(D)}catch(b){console.error("Failed to start recording:",b),R()}},[O,R]),ye=o.useCallback(async()=>{try{const b=await H();await Y(b)}catch(b){console.error("STT processing failed:",b),!P.current&&!L.current&&(P.current=!0,R())}},[H,Y,R]),X=o.useCallback(async b=>{var Z;x(),await((Z=f.current)==null?void 0:Z.exitFullScreenIntentionally()),(await l.generateQuestion({interviewId:r,isInterviewDone:!0})).success&&(b==null||b(),K(),sessionStorage.removeItem(le))},[r,x,l]),ne=()=>{const{phase:b}=U;switch(b){case I.IDLE:return e.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),e.jsx("p",{className:"iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:`You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.`}),e.jsx(G,{onClick:$,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case I.FETCHING_QUESTION:return e.jsx(Ft,{});case I.READING_QUESTION:return e.jsx($t,{ttsError:M});case I.THINKING:return e.jsx(Ot,{state:U,thinkingTime:N,nextPhase:R});case I.ANSWERING:return e.jsx(Pt,{state:U,answeringTime:D,nextPhase:R,sttError:Q});case I.TRANSCRIBING:return e.jsx(Ut,{sttError:Q});case I.EDITING:case I.SUBMITTING:return e.jsx("div",{className:"iw-space-y-4 iw-h-full",children:e.jsx(It,{value:y,onChange:W=>k(W.target.value),onSubmit:()=>R(),isSubmitDisabled:!y.trim()||xe,state:U,editingTime:v})});case I.COMPLETED:return null;default:return null}};return e.jsx(e.Fragment,{children:m!=null&&m.enabled?e.jsxs(Yt,{ref:f,onDisqualify:()=>X(s),children:[e.jsx($e,{title:i,onExit:()=>X()}),e.jsx(Fe,{currentQuestion:d,phase:U.phase,className:n,children:ne()})]}):e.jsxs(e.Fragment,{children:[e.jsx($e,{title:i,onExit:()=>X()}),e.jsx(Fe,{currentQuestion:d,phase:U.phase,className:n,children:ne()})]})})},ge=({title:i,interviewId:r,onInterviewEnd:t,onInterviewDisqualify:s,className:n=""})=>{const[l,a]=o.useState(!1),[c,u]=o.useState(!0),w=o.useRef(null);return l?e.jsx("div",{className:"interview-widget-container",children:e.jsx("div",{ref:w,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${n}`,children:e.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:e.jsx(Qt,{interviewTitle:i??"Interview",interviewId:r,className:n,onComplete:t||(()=>{}),onDisqualify:s})})})}):e.jsx("div",{className:"interview-widget-container",children:e.jsx(ot,{isOpen:c,onStart:()=>{a(!0),u(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:ge,InterviewWidgetProvider:Se}),A.InterviewWidget=ge,A.InterviewWidgetProvider=Se,A.default=ge,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
173
+ `})})};function Ot({ttsError:i}){return e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[e.jsx($t,{size:"80px"}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",i.message]}),e.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const qt=({state:i,thinkingTime:r,nextPhase:t})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After 30-seconds thinking time, recording will start automatically, or you can begin recording early by clicking the button below."})]}),e.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[e.jsx(me,{className:"iw-size-4 iw-text-orange-600"}),e.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),e.jsx(fe,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),e.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:e.jsx(G,{onClick:()=>{t()},children:"Start Answering"})})]}),Ut=({sttError:i})=>e.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[e.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[e.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),e.jsx("path",{d:"M28.127 14c.276 7.685 6.442 13.851 14.127 14.127-7.684.276-13.85 6.442-14.127 14.127-.275-7.685-6.442-13.851-14.126-14.127 7.684-.276 13.85-6.442 14.126-14.127zM38.937 31.873A7.331 7.331 0 0046 38.937 7.331 7.331 0 0038.937 46a7.331 7.331 0 00-7.064-7.063 7.331 7.331 0 007.064-7.064z",fill:"#fff"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),e.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1 iw-mt-3",children:"Just a moment... We're analyzing your response"}),e.jsx("p",{className:"iw-max-w-lg iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:"After transcription, you'll have 45 sec to review your answer."}),i&&e.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",i.message,i.recoverable&&" (attempting to continue)"]})]}),re=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),e.jsx("path",{d:"M12 9v4"}),e.jsx("path",{d:"M12 17h.01"})]}),Wt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M12 6v6l4 2"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Bt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),e.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),Gt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),ge=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),Vt=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M3 7V5a2 2 0 0 1 2-2h2"}),e.jsx("path",{d:"M17 3h2a2 2 0 0 1 2 2v2"}),e.jsx("path",{d:"M21 17v2a2 2 0 0 1-2 2h-2"}),e.jsx("path",{d:"M7 21H5a2 2 0 0 1-2-2v-2"})]}),se=5;function zt({isOpen:i,onClose:r,warningCount:t,violationType:s,onDisqualify:n}){const[l,a]=o.useState(10),c=o.useRef(r);if(o.useEffect(()=>{c.current=r},[r]),o.useEffect(()=>{if(!i)return;const f=setInterval(()=>{a(d=>d<=1?(c.current(),10):d-1)},1e3);return()=>clearInterval(f)},[i]),o.useEffect(()=>{i&&a(10)},[i]),o.useEffect(()=>(i?(document.body.style.overflow="hidden",document.body.classList.add("interview-widget-container")):(document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")),()=>{document.body.style.overflow="unset",document.body.classList.remove("interview-widget-container")}),[i]),!i)return null;const w=(()=>{switch(s){case"tab_switch":return{title:"Tab Switch Detected",description:"You attempted to switch to another tab or reload application.",icon:e.jsx(Bt,{className:"iw-h-5 iw-w-5"})};case"fullscreen_exit":return{title:"Full Screen Exit Detected",description:"You attempted to exit full screen mode.",icon:e.jsx(Pe,{className:"iw-h-5 iw-w-5"})};case"focus_loss":return{title:"Focus Loss Detected",description:"You lost focus from the interview window.",icon:e.jsx(Gt,{className:"iw-h-5 iw-w-5"})};case"blocked_shortcut":return{title:"Keyboard Shortcut Blocked",description:"You attempted to use a blocked keyboard shortcut.",icon:e.jsx(ge,{className:"iw-h-5 iw-w-5"})};case"right_click_attempt":return{title:"Right Click Attempted",description:"You attempted to use the right click.",icon:e.jsx(Vt,{className:"iw-h-5 iw-w-5"})};case"alt_tab_attempt":return{title:"Alt + Tab Attempted",description:"You attempted to use the Alt + Tab shortcut.",icon:e.jsx(ge,{className:"iw-h-5 iw-w-5"})};case"blocked_function_key":return{title:"Function Key Blocked",description:"You attempted to use a blocked function key.",icon:e.jsx(ge,{className:"iw-h-5 iw-w-5"})};default:return{title:"Violation Detected",description:"You attempted to perform an action that is not allowed.",icon:e.jsx(re,{className:"iw-h-5 iw-w-5"})}}})(),h=se-t,m=()=>{t+1>se?n():r()};return e.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/60 iw-p-4 iw-backdrop-blur-sm",children:e.jsxs("div",{className:"iw-w-full iw-max-w-md iw-rounded-2xl iw-border iw-border-gray-100 iw-bg-white iw-shadow-xl",children:[e.jsxs("div",{className:"iw-p-6 iw-pb-0",children:[e.jsxs("div",{className:"iw-mb-6 iw-flex iw-items-start iw-gap-4",children:[e.jsx("div",{className:"iw-flex iw-h-12 iw-w-12 iw-flex-shrink-0 iw-items-center iw-justify-center iw-rounded-2xl iw-bg-red-50",children:e.jsx(re,{className:"iw-h-6 iw-w-6 iw-text-red-500"})}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h2",{className:"iw-mb-1 iw-text-xl iw-font-semibold iw-text-gray-900",children:"Security Violation"}),e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx("span",{className:"iw-text-sm iw-text-gray-500",children:"Warning"}),e.jsx("div",{className:"iw-flex iw-gap-1",children:Array.from({length:se}).map((f,d)=>e.jsx("div",{className:`iw-h-2 iw-w-2 iw-rounded-full ${d<=t-1?"iw-bg-red-500":"iw-bg-gray-200"}`},d))}),e.jsxs("span",{className:"iw-text-sm iw-text-gray-500",children:["(",t,"/",se,")"]})]})]})]}),e.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-border iw-border-red-100 iw-p-5",style:{background:"linear-gradient(to right, rgb(254, 242, 242), rgb(254, 245, 235))",borderColor:"rgb(254, 226, 226)"},children:e.jsxs("div",{className:"iw-flex iw-items-start iw-gap-4",children:[e.jsx("div",{className:"iw-flex iw-h-10 iw-w-10 iw-items-center iw-justify-center iw-rounded-xl iw-bg-white iw-shadow-sm",children:w.icon}),e.jsxs("div",{className:"iw-flex-1",children:[e.jsx("h3",{className:"iw-mb-2 iw-font-semibold iw-text-gray-900",children:w.title}),e.jsx("p",{className:"iw-text-sm iw-leading-relaxed iw-text-gray-700",children:w.description}),e.jsxs("div",{className:"iw-mt-3 iw-flex iw-items-center iw-gap-2 iw-text-xs iw-text-red-600",children:[e.jsx(Re,{className:"iw-h-3 iw-w-3"}),e.jsx("span",{children:"This action is monitored for interview integrity"})]})]})]})}),e.jsxs("div",{className:"iw-mb-5 iw-grid iw-grid-cols-2 iw-gap-3",children:[e.jsx("div",{className:"iw-rounded-xl iw-border iw-border-amber-200 iw-bg-amber-50 iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsx("div",{className:"iw-mb-1 iw-text-2xl iw-font-bold iw-text-amber-600",children:h}),e.jsx("div",{className:"iw-text-xs iw-font-medium iw-text-amber-700",children:"Warnings Left"})]})}),e.jsx("div",{className:"iw-border-primary-100 iw-bg-primary-50 iw-rounded-xl iw-border iw-p-4",children:e.jsxs("div",{className:"iw-text-center",children:[e.jsxs("div",{className:"iw-mb-1 iw-flex iw-items-center iw-justify-center iw-gap-1.5",children:[e.jsx(Wt,{className:"iw-text-primary-600 iw-h-4 iw-w-4"}),e.jsx("span",{className:"iw-text-primary-600 iw-text-2xl iw-font-bold",children:l})]}),e.jsx("div",{className:"iw-text-primary-700 iw-text-xs iw-font-medium",children:"Auto Close"})]})})]}),h===1&&e.jsx("div",{className:"iw-mb-5 iw-rounded-2xl iw-p-4 iw-text-white",style:{background:"linear-gradient(to right, rgba(220, 38, 38, 0.9), rgba(239, 68, 68, 0.9))"},children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-3",children:[e.jsx("div",{className:"iw-flex iw-h-8 iw-w-8 iw-items-center iw-justify-center iw-rounded-full iw-bg-white/20",children:e.jsx(re,{className:"iw-h-4 iw-w-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"iw-text-sm iw-font-semibold",children:"Final Warning"}),e.jsx("div",{className:"iw-text-xs iw-text-red-100",children:"Next violation will disqualify you from this interview"})]})]})})]}),e.jsxs("div",{className:"iw-p-6 iw-pt-0",children:[e.jsx(G,{onClick:m,className:"iw-h-12 iw-w-full iw-rounded-xl iw-bg-gray-800 iw-text-sm iw-font-medium iw-text-white iw-hover:bg-gray-800",children:"I Understand - Continue Interview"}),e.jsx("p",{className:"iw-text-gray-500 iw-mt-3 iw-text-center iw-text-xs",children:"Please maintain focus and avoid switching tabs, exiting fullscreen, using shortcuts or right-clicking."})]})]})})}const Ht=i=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...i,children:[e.jsx("path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z"}),e.jsx("circle",{cx:"12",cy:"12",r:"10"})]}),Yt=({showHardReloadWarning:i,onContinue:r})=>{const t=()=>{r()};return e.jsxs($e,{isOpen:i,onClose:t,closeOnOverlayClick:!1,closeOnEscape:!1,showCloseButton:!1,className:"iw-max-w-lg iw-px-2 iw-rounded-xl",children:[e.jsx("div",{className:"iw-absolute iw-inset-x-0 iw-top-0 iw-h-1 iw-bg-gradient-to-r iw-from-red-500 iw-to-red-600"}),e.jsx("div",{className:"iw-space-y-1 iw-pb-2 iw-pt-3",children:e.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2",children:[e.jsx(re,{className:"iw-w-5 iw-h-5 iw-text-red-500"}),e.jsx("h3",{className:"iw-text-xl iw-font-semibold iw-text-red-500",children:"Full Screen Exit Detected"})]})}),e.jsx("div",{className:"iw-pt-4 iw-pb-6",children:e.jsx("p",{className:"iw-text-center iw-text-sm iw-leading-relaxed iw-text-gray-500/90",children:"Exiting full screen mode or reloading this page during the session is strictly prohibited. Any attempt to do so will be recorded and may lead to penalties."})}),e.jsx("div",{className:"iw-pt-2 iw-pb-4",children:e.jsxs("button",{onClick:t,className:"iw-w-full iw-flex iw-items-center iw-justify-center iw-gap-2 iw-px-4 iw-py-3 iw-bg-gray-100 iw-text-gray-600 iw-rounded-md iw-font-medium iw-transition-colors hover:iw-bg-gray-200 focus:iw-outline-none focus:iw-ring-2 focus:iw-ring-gray-400 focus:iw-ring-offset-2",children:[e.jsx(Ht,{className:"iw-size-4"}),"Continue Session"]})})]})},Qt=o.forwardRef(({children:i,onDisqualify:r},t)=>{const[s,n]=o.useState(!1),[l,a]=o.useState(!1),[c,u]=o.useState(!1),[w,h]=o.useState("fullscreen_exit"),{logViolation:m,violationCount:f}=Ct({maxViolations:5,onViolation:g=>{l||(n(!0),h(g.type))}}),{enterFullScreen:d,isFullScreen:p,exitFullScreen:b}=mt({onFullScreenChange(g){!g&&!l&&!c&&(n(!0),m({type:"fullscreen_exit",severity:"high",details:{action:"fullscreen_exit",reason:"Attempted to exit full screen mode"}})),g&&u(!1)}});o.useEffect(()=>{d()},[]),o.useImperativeHandle(t,()=>({exitFullScreenIntentionally:async()=>{u(!0),n(!1),a(!1);try{document.fullscreenElement&&await document.exitFullscreen()}catch(g){console.error("Failed to exit fullscreen:",g)}}}),[]),jt(m),bt(m),kt(),St();const k=()=>{a(!0),b(),n(!1),r==null||r()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"iw-relative iw-h-full iw-w-full",children:i}),e.jsx(zt,{warningCount:f,isOpen:s,violationType:w,onClose:()=>{n(!1),d()},onDisqualify:k}),!s&&f>0&&!l&&!c&&e.jsx(Yt,{showHardReloadWarning:!p,logViolation:m,onContinue:d})]})}),Kt=({interviewTitle:i,interviewId:r,onComplete:t,onDisqualify:s,className:n=""})=>{var ae;const l=pt(),{baseUrl:a,authToken:c}=Ie(),{timers:u,stt:w,tts:h,proctoring:m}=Ze(),f=o.useRef(null),[d,p]=o.useState(null),[b,k]=o.useState(""),g=o.useRef(""),v=o.useRef(null),C={thinkingTime:(u==null?void 0:u.thinkingDuration)||30,answeringTime:(u==null?void 0:u.answeringDuration)||120,editingTime:(u==null?void 0:u.editingDuration)||30},{thinkingTime:N,answeringTime:D,editingTime:j}=C;o.useEffect(()=>{g.current=b},[b]);const S=o.useRef(!1),{speak:T,stop:x,error:M}=Et({config:{baseUrl:a,provider:h==null?void 0:h.provider,authToken:c},onEnd:()=>{S.current=!1,_()},onError:()=>{S.current||(S.current=!0,_())}}),P=o.useRef(!1),L=o.useRef(!1),{startRecording:O,stopRecording:H,transcribe:Y,error:Q}=vt({config:{baseUrl:a,provider:w==null?void 0:w.provider,model:w==null?void 0:w.model,language:w==null?void 0:w.language,authToken:c,qnaId:((ae=v.current)==null?void 0:ae.qna_id)||""},onStart:()=>{P.current=!1,L.current=!1},onStop:()=>{},onTranscriptionComplete:y=>{k(y.transcript),L.current||(L.current=!0,_())},onError:y=>{console.error("STT Error:",y),P.current||(P.current=!0,_())}}),{state:q,startQuestion:$,nextPhase:_,completeInterview:K}=ut({config:{thinkingDuration:N,answeringDuration:D,editingDuration:j},callbacks:{onPhaseChange:y=>{switch(y){case I.FETCHING_QUESTION:U();break;case I.READING_QUESTION:be();break;case I.ANSWERING:ye();break;case I.TRANSCRIBING:ve();break;case I.SUBMITTING:J();break}},onInterviewEnd:()=>{t==null||t()}}});o.useEffect(()=>{$()},[]);const{execute:U,loading:pe}=ht(async()=>{var W,Z;const y=await l.generateQuestion({interviewId:r,question:((W=v.current)==null?void 0:W.question)||"",qnaId:((Z=v.current)==null?void 0:Z.qna_id)||"",answer:g.current});return v.current=y.data,y},{onSuccess:async y=>{y&&y.data&&(k(""),p(y.data),_())},onError:y=>{console.error("Failed to fetch questions:",y)}}),J=o.useCallback(async()=>{$()},[$]),be=o.useCallback(async()=>{var y;if((y=v.current)!=null&&y.question)try{S.current=!1,await T(v.current.question),v.current.is_interview_done&&(await rt(2e3),K())}catch(W){console.error("Failed to speak question:",W)}else _()},[T,_,K]),ye=o.useCallback(async()=>{try{await O(D)}catch(y){console.error("Failed to start recording:",y),_()}},[O,_]),ve=o.useCallback(async()=>{try{const y=await H();await Y(y)}catch(y){console.error("STT processing failed:",y),!P.current&&!L.current&&(P.current=!0,_())}},[H,Y,_]),X=o.useCallback(async y=>{var Z;x(),await((Z=f.current)==null?void 0:Z.exitFullScreenIntentionally()),(await l.generateQuestion({interviewId:r,isInterviewDone:!0})).success&&(y==null||y(),K(),sessionStorage.removeItem(ce))},[r,x,l]),ne=()=>{const{phase:y}=q;switch(y){case I.IDLE:return e.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[e.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),e.jsx("p",{className:"iw-max-w-xl iw-text-gray-500 iw-text-xs iw-leading-[21px]",children:`You will be asked a series of behavioral and technical questions. For each one you'll get a short thinking period, then a timed recording window. We'll transcribe your response so you can review and edit it before submitting. Click "Start Interview" when you're ready.`}),e.jsx(G,{onClick:$,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case I.FETCHING_QUESTION:return e.jsx(Lt,{});case I.READING_QUESTION:return e.jsx(Ot,{ttsError:M});case I.THINKING:return e.jsx(qt,{state:q,thinkingTime:N,nextPhase:_});case I.ANSWERING:return e.jsx(Ft,{state:q,answeringTime:D,nextPhase:_,sttError:Q});case I.TRANSCRIBING:return e.jsx(Ut,{sttError:Q});case I.EDITING:case I.SUBMITTING:return e.jsx("div",{className:"iw-space-y-4 iw-h-full",children:e.jsx(Mt,{value:b,onChange:W=>k(W.target.value),onSubmit:()=>_(),isSubmitDisabled:!b.trim()||pe,state:q,editingTime:j})});case I.COMPLETED:return null;default:return null}};return e.jsx(e.Fragment,{children:m!=null&&m.enabled?e.jsxs(Qt,{ref:f,onDisqualify:()=>X(s),children:[e.jsx(Oe,{title:i,onExit:()=>X()}),e.jsx(Le,{currentQuestion:d,phase:q.phase,className:n,children:ne()})]}):e.jsxs(e.Fragment,{children:[e.jsx(Oe,{title:i,onExit:()=>X()}),e.jsx(Le,{currentQuestion:d,phase:q.phase,className:n,children:ne()})]})})},xe=({title:i,interviewId:r,onInterviewEnd:t,onInterviewDisqualify:s,className:n=""})=>{const[l,a]=o.useState(!1),[c,u]=o.useState(!0),w=o.useRef(null);return l?e.jsx("div",{className:"interview-widget-container",children:e.jsx("div",{ref:w,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${n}`,children:e.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:e.jsx(Kt,{interviewTitle:i??"Interview",interviewId:r,className:n,onComplete:t||(()=>{}),onDisqualify:s})})})}):e.jsx("div",{className:"interview-widget-container",children:e.jsx(lt,{isOpen:c,onStart:()=>{a(!0),u(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:xe,InterviewWidgetProvider:Te}),A.InterviewWidget=xe,A.InterviewWidgetProvider=Te,A.default=xe,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "interview-widget",
3
3
  "type": "module",
4
- "version": "1.0.6",
4
+ "version": "1.0.8",
5
5
  "description": "Advanced React interview widget with STT, TTS, camera access, and ML-powered analysis",
6
6
  "main": "dist/widget.umd.js",
7
7
  "module": "dist/widget.es.js",