interview-widget 0.1.5 → 0.1.7

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(C,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(C=typeof globalThis<"u"?globalThis:C||self,l(C.InterviewWidget={},C.React,C.ReactDOM))})(this,function(C,l,U){"use strict";var lt=Object.defineProperty;var ct=(C,l,U)=>l in C?lt(C,l,{enumerable:!0,configurable:!0,writable:!0,value:U}):C[l]=U;var A=(C,l,U)=>ct(C,typeof l!="symbol"?l+"":l,U);var oe={exports:{}},W={};/**
1
+ (function(C,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],l):(C=typeof globalThis<"u"?globalThis:C||self,l(C.InterviewWidget={},C.React,C.ReactDOM))})(this,function(C,l,U){"use strict";var lt=Object.defineProperty;var ct=(C,l,U)=>l in C?lt(C,l,{enumerable:!0,configurable:!0,writable:!0,value:U}):C[l]=U;var A=(C,l,U)=>ct(C,typeof l!="symbol"?l+"":l,U);var ce={exports:{}},V={};/**
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 ge=Symbol.for("react.transitional.element"),xe=Symbol.for("react.fragment");function le(r,i,e){var o=null;if(e!==void 0&&(o=""+e),i.key!==void 0&&(o=""+i.key),"key"in i){e={};for(var s in i)s!=="key"&&(e[s]=i[s])}else e=i;return i=e.ref,{$$typeof:ge,type:r,key:o,ref:i!==void 0?i:null,props:e}}W.Fragment=xe,W.jsx=le,W.jsxs=le,oe.exports=W;var t=oe.exports;const D={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"}}},ce=l.createContext(null);function de({config:r={},children:i}){var o,s,c,n;const e={api:{...D.api,...r.api,retryConfig:{...D.api.retryConfig,...(o=r.api)==null?void 0:o.retryConfig}},ui:{...D.ui,...r.ui},interview:{...D.interview,...r.interview,timers:{...D.interview.timers,...(s=r.interview)==null?void 0:s.timers},stt:{...D.interview.stt,...(c=r.interview)==null?void 0:c.stt},tts:{...D.interview.tts,...(n=r.interview)==null?void 0:n.tts}}};return t.jsx(ce.Provider,{value:e,children:i})}function H(){const r=l.useContext(ce);if(!r)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return r}function pe(){return H().api||D.api}function z(){return H().ui||D.ui}function be(){return H().interview||D.interview}const ue=({className:r,...i})=>t.jsx("div",{children:t.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 ${r}`,...i,children:[t.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),t.jsx("path",{d:"M12 6l0 -3"}),t.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),t.jsx("path",{d:"M18 12l3 0"}),t.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),t.jsx("path",{d:"M12 18l0 3"}),t.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),t.jsx("path",{d:"M6 12l-3 0"}),t.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),X=({children:r,variant:i="primary",size:e="md",fullWidth:o=!1,isLoading:s=!1,disabled:c,className:n="",...a})=>{const w="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",f={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"},u={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",h=o?"iw-w-full":"";return t.jsxs("button",{className:`${w} ${f[i]} ${u[e]} ${h} ${m} ${n}`,disabled:c||s,...a,children:[s&&t.jsx(ue,{height:16,width:16,style:{marginRight:"3px"}}),r]})};function ye(r){const i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(r);return i?{r:parseInt(i[1],16),g:parseInt(i[2],16),b:parseInt(i[3],16)}:null}function ve(r,i,e){return"#"+[r,i,e].map(o=>{const s=Math.round(o).toString(16);return s.length===1?"0"+s:s}).join("")}function we(r,i){const e=ye(r);if(!e)return r;const o=e.r+(255-e.r)*i,s=e.g+(255-e.g)*i,c=e.b+(255-e.b)*i;return ve(o,s,c)}function je(r,i=.8){return{background:`linear-gradient(to bottom, ${we(r,i)}, #ffffff)`,color:"#1f2937"}}function Ne(r){return new Promise(i=>setTimeout(i,r))}function he(r){return`linear-gradient(to left, ${we(r,.4)}, ${r})`}const Te=r=>t.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",...r,children:[t.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"}),t.jsx("path",{d:"m9 12 2 2 4-4"})]}),ke=["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","All activities are being recorded, and any violations may result in penalties, including disqualification"],Se=({isOpen:r,onStart:i,onClose:e})=>{var N;const o=l.useRef(null),s=l.useRef(null),{baseColor:c,borderRadius:n}=z(),[a,w]=l.useState(!1),[f,u]=l.useState(null),[m,h]=l.useState(!1),g=()=>{s.current&&(s.current.getTracks().forEach(d=>d.stop()),s.current=null)},v=async()=>{h(!0),u(null);try{const d=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});s.current=d,o.current&&(o.current.srcObject=d),w(!0)}catch(d){console.error("Media permission error:",d);let b="Unable to access camera or microphone.";(d==null?void 0:d.name)==="NotAllowedError"?b="Permissions denied. Please allow access to camera and microphone.":(d==null?void 0:d.name)==="NotFoundError"?b="No camera/microphone found. Please connect a device and retry.":d!=null&&d.message&&(b=d.message),w(!1),u(b)}finally{h(!1)}};if(l.useEffect(()=>{if(!r){g();return}return v(),()=>{g()}},[r]),!r)return null;const S=()=>{i(),g()};return t.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/50 iw-backdrop-blur-sm",children:t.jsxs("div",{className:"iw-bg-white iw-rounded-xl iw-shadow-2xl iw-w-full iw-max-w-[800px] iw-mx-4",children:[t.jsxs("div",{className:"iw-px-5 iw-py-4 iw-border-b iw-border-gray-200 iw-flex iw-items-center iw-justify-between",children:[t.jsx("h2",{className:"iw-text-base iw-font-semibold",children:"Interview Onboarding"}),e&&t.jsx("button",{"aria-label":"Close",className:"iw-text-gray-500 hover:iw-text-gray-700",onClick:()=>{g(),e==null||e()},children:"✕"})]}),t.jsxs("div",{className:"iw-p-4 iw-grid iw-grid-cols-2 iw-gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"iw-border iw-border-gray-200 iw-rounded-lg iw-overflow-hidden iw-bg-gray-900",children:t.jsx("video",{ref:o,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-64 iw-object-cover",style:{transform:"scaleX(-1)"}})}),t.jsxs("div",{className:"iw-grid iw-grid-cols-2 iw-gap-2 iw-mt-3",children:[t.jsx(X,{onClick:v,disabled:m,variant:"outline",size:"sm",style:{borderColor:c,borderRadius:n,color:c},children:a?"Recheck Permissions":"Enable Camera & Mic"}),t.jsx(X,{onClick:S,disabled:!a,size:"sm",style:{background:he(c),borderRadius:n},children:"Start Interview"})]})]}),t.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-3",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-text-gray-800 iw-font-semibold",children:[t.jsx(Te,{}),t.jsx("h3",{children:"Interview Guidelines"})]}),!((N=navigator.mediaDevices)!=null&&N.getUserMedia)&&t.jsx("div",{className:"iw-text-xs iw-text-red-600",children:"Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox."}),f&&t.jsx("div",{className:"iw-text-xs iw-text-red-600",children:f}),t.jsx("ul",{className:"iw-mt-1 iw-text-sm iw-text-gray-500 iw-list-disc iw-pl-4 iw-space-y-1.5",children:ke.map((d,b)=>t.jsx("li",{children:d},b))})]})]})]})})};var k=(r=>(r.IDLE="idle",r.FETCHING_QUESTION="fetching_question",r.READING_QUESTION="reading_question",r.THINKING="thinking",r.ANSWERING="answering",r.TRANSCRIBING="transcribing",r.EDITING="editing",r.SUBMITTING="submitting",r.COMPLETED="completed",r))(k||{});const Ee={thinkingDuration:30,answeringDuration:120,editingDuration:30},Ie={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 Ce{constructor(i={},e={}){A(this,"config");A(this,"state");A(this,"phaseIntervalId",null);A(this,"globalIntervalId",null);A(this,"callbacks");this.config={...Ee,...i},this.callbacks=e,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 i=this.state.phase,e=Ie[i];if(!e)return;this.stopPhaseTimer(),this.state.phase=e.next;const o=this.getDurationForPhase(e.next);o>0?(this.state.currentPhaseTimeRemaining=o,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var i,e;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(e=(i=this.callbacks).onInterviewEnd)==null||e.call(i),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(i){switch(i){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 i,e;this.state.totalTimeElapsed++,(e=(i=this.callbacks).onTick)==null||e.call(i,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 i,e;(e=(i=this.callbacks).onPhaseChange)==null||e.call(i,this.state.phase,this.getState())}}function Me(r={}){const{config:i={},callbacks:e={}}=r,o=l.useRef(null);o.current||(o.current=new Ce(i,{}));const s=o.current,[c,n]=l.useState(s.getState()),a=l.useCallback(()=>{n(s.getState())},[s]);l.useEffect(()=>{const m={onPhaseChange:(h,g)=>{var v;a(),(v=e.onPhaseChange)==null||v.call(e,h,g)},onTick:h=>{var g;a(),(g=e.onTick)==null||g.call(e,h)},onInterviewEnd:()=>{var h;a(),(h=e.onInterviewEnd)==null||h.call(e)}};s.callbacks=m},[s,e,a]),l.useEffect(()=>()=>{s.destroy()},[s]);const w=l.useCallback(()=>{s.startQuestion(),a()},[s,a]),f=l.useCallback(()=>{s.nextPhase(),a()},[s,a]),u=l.useCallback(()=>{s.completeInterview(),a()},[s,a]);return{state:c,startQuestion:w,nextPhase:f,completeInterview:u,timerService:s}}function Re(r,i={}){const[e,o]=l.useState({data:null,loading:!1,error:null}),s=l.useCallback(async(...c)=>{var n,a,w,f;o(u=>({...u,loading:!0,error:null}));try{const u=await r(...c);o(m=>({...m,data:u,loading:!1,error:null})),(n=i.onSuccess)==null||n.call(i,u),(a=i.onSettled)==null||a.call(i,u,null)}catch(u){const m=u.type?u:{type:"unknown",message:u.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:u};o(h=>({...h,loading:!1,error:m})),(w=i.onError)==null||w.call(i,m),(f=i.onSettled)==null||f.call(i,null,m)}},[r,i]);return{...e,execute:s}}function Ae(r){var i;if(!navigator.onLine)return{type:"network",message:"No internet connection",retryable:!0,userMessage:"Please check your internet connection and try again."};if(r.name==="AbortError"||(i=r.message)!=null&&i.includes("timeout"))return{type:"timeout",message:"Request timed out",retryable:!0,userMessage:"The request is taking longer than expected. Please try again."};if(r.status){const{status:e}=r;if(e===401||e===403)return{type:"auth",status:e,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(e===429)return{type:"rate-limit",status:e,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(e>=500)return{type:"server",status:e,message:`Server error: ${e}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(e>=400)return{type:"client",status:e,message:`Client error: ${e}`,retryable:!1,userMessage:"There was an issue with your request. Please check your input."}}return{type:"unknown",message:r.message||"Unknown error occurred",retryable:!0,userMessage:"Something unexpected happened. Please try again.",originalError:r}}async function Z(r,i={},e={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let o;for(let s=1;s<=e.attempts;s++)try{const c=new AbortController,n=setTimeout(()=>c.abort(),6e4),a=await fetch(r,{...i,signal:c.signal});if(clearTimeout(n),a.status>=400&&a.status<500&&a.status!==429)return a;if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);return a}catch(c){o=c;const n=Ae(c);if(!n.retryable||s===e.attempts)throw n;const a=De(s,e);console.warn(`API request failed (attempt ${s}/${e.attempts}), retrying in ${a}ms:`,n.message),await new Promise(w=>setTimeout(w,a))}throw o}function De(r,i){let e;return i.backoff==="exponential"?e=i.baseDelay*Math.pow(2,r-1):e=i.baseDelay,e=Math.min(e,i.maxDelay),i.jitter&&(e=e*(.5+Math.random()*.5)),Math.round(e)}class Pe{constructor(i={}){A(this,"config");this.config=i}updateConfig(i){this.config={...this.config,...i}}getHeaders(){var e;const i={"Content-Type":"application/json","X-Auth-Token":"appkey"};return(e=this.config)!=null&&e.authToken&&(i.Authorization=`Bearer ${this.config.authToken}`),i}getBaseUrl(){var i;return((i=this.config)==null?void 0:i.baseUrl)||"/api"}async generateQuestion({interviewId:i,isInterviewDone:e=!1,qnaId:o,question:s,answer:c,answerDuration:n}){const a=await Z(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:i,is_interview_done:e,qna_id:o,question:s,answer:c,answer_duration:n??"00:00:30"})});if(!a.ok)throw new Error(`Failed to get questions: ${a.status}`);return await a.json()}}function $e(){const r=H();return l.useMemo(()=>{const e=r.api||{};return new Pe(e)},[r.api])}class j extends Error{constructor(i,e,o=!1){super(i),this.code=e,this.recoverable=o,this.name="STTError"}}class _e{constructor(i={}){A(this,"config");A(this,"mediaRecorder",null);A(this,"audioChunks",[]);A(this,"recordingStream",null);A(this,"autoStopTimeoutId",null);this.config={baseUrl:"http://localhost:8000",provider:"groq",model:"whisper-large-v3-turbo",language:"en",includeTimestamps:!1,temperature:0,...i}}updateConfig(i){this.config={...this.config,...i}}isRecordingSupported(){return!!(navigator.mediaDevices&&typeof navigator.mediaDevices.getUserMedia=="function"&&window.MediaRecorder)}async startRecording(i,e){var o;if(!this.isRecordingSupported())throw new j("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new j("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 s=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:s}),this.mediaRecorder.ondataavailable=c=>{var n;c.data.size>0&&(this.audioChunks.push(c.data),(n=e==null?void 0:e.onDataAvailable)==null||n.call(e,c.data))},this.mediaRecorder.onstop=()=>{var c;(c=e==null?void 0:e.onStop)==null||c.call(e)},this.mediaRecorder.onerror=c=>{var a;const n=new j(`Recording failed: ${c.error}`,"RECORDING_ERROR",!0);(a=e==null?void 0:e.onError)==null||a.call(e,n),this.cleanup()},this.mediaRecorder.start(100),(o=e==null?void 0:e.onStart)==null||o.call(e),i&&i>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.isRecording()&&this.stopRecording()},i*1e3))}catch(s){if(this.cleanup(),s instanceof Error){if(s.name==="NotAllowedError"||s.name==="PermissionDeniedError")throw new j("Microphone permission was denied","PERMISSION_DENIED",!1);if(s.name==="NotFoundError")throw new j("No microphone found","NO_MICROPHONE",!1)}throw new j(`Failed to start recording: ${s instanceof Error?s.message:String(s)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording())throw new j("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((i,e)=>{if(!this.mediaRecorder){e(new j("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const o=this.mediaRecorder,s=()=>{try{const c=o.mimeType||"audio/webm",n=new Blob(this.audioChunks,{type:c});this.cleanup(),i(n)}catch(c){e(new j(`Failed to create audio blob: ${c instanceof Error?c.message:String(c)}`,"BLOB_CREATION_FAILED",!1))}};o.addEventListener("stop",s,{once:!0}),o.stop()})}async transcribe(i){const{audioBlob:e,model:o=this.config.model,language:s=this.config.language,includeTimestamps:c=this.config.includeTimestamps,temperature:n=this.config.temperature}=i;if(!e||e.size===0)throw new j("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const a=new FormData,w=new File([e],"recording.wav",{type:e.type||"audio/wav"});a.append("file",w),a.append("model",o||"whisper-large-v3-turbo"),a.append("language",s||"en"),a.append("include_timestamps",String(c||!1)),a.append("temperature",String(n||0));const f=await Z(`${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:a},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!f.ok){const m=await f.text();let h=`STT request failed: ${f.status} ${f.statusText}`;try{const g=JSON.parse(m);h=g.message||g.error||h}catch{h=m||h}throw new j(h,`HTTP_${f.status}`,f.status>=500)}return{transcript:(await f.json()).data.text??""}}catch(a){throw a instanceof j?a:new j(`Transcription failed: ${a instanceof Error?a.message:String(a)}`,"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 i=["audio/webm","audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4","audio/wav"];for(const e of i)if(MediaRecorder.isTypeSupported(e))return e;return"audio/webm"}cleanup(){this.recordingStream&&(this.recordingStream.getTracks().forEach(i=>i.stop()),this.recordingStream=null),this.mediaRecorder=null,this.audioChunks=[],this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null)}}const Q=new _e,Oe=(r={})=>{const[i,e]=l.useState(!1),[o,s]=l.useState(!1),[c,n]=l.useState(null),[a,w]=l.useState(null),[f,u]=l.useState(null);r.config&&Q.updateConfig(r.config);const m=l.useCallback(async S=>{var N;try{w(null),n(null),u(null),await Q.startRecording(S,{onStart:()=>{var d;e(!0),(d=r.onStart)==null||d.call(r)},onStop:()=>{var d;e(!1),(d=r.onStop)==null||d.call(r)},onError:d=>{var E;const b=d instanceof j?d:new j(d.message,"RECORDING_ERROR",!0);w(b),e(!1),(E=r.onError)==null||E.call(r,b)}})}catch(d){const b=d instanceof j?d:new j(d instanceof Error?d.message:String(d),"START_FAILED",!1);throw w(b),e(!1),(N=r.onError)==null||N.call(r,b),b}},[]),h=l.useCallback(async()=>{var S,N;try{const d=await Q.stopRecording();return u(d),e(!1),(S=r.onStop)==null||S.call(r),d}catch(d){const b=d instanceof j?d:new j(d instanceof Error?d.message:String(d),"STOP_FAILED",!1);throw w(b),e(!1),(N=r.onError)==null||N.call(r,b),b}},[]),g=l.useCallback(async(S,N={})=>{var d,b;try{w(null),s(!0);const E={audioBlob:S,...N},y=await Q.transcribe(E);return n(y.transcript),s(!1),(d=r.onTranscriptionComplete)==null||d.call(r,y),y}catch(E){const y=E instanceof j?E:new j(E instanceof Error?E.message:String(E),"TRANSCRIPTION_FAILED",!0);throw w(y),s(!1),(b=r.onError)==null||b.call(r,y),y}},[]),v=l.useCallback(()=>{Q.cancelRecording(),e(!1),u(null)},[]);return{startRecording:m,stopRecording:h,transcribe:g,cancelRecording:v,isRecording:i,isTranscribing:o,transcript:c,error:a,audioBlob:f}};class Le{constructor(i={}){A(this,"config");A(this,"currentAudio",null);this.config={baseUrl:"http://localhost:8000",provider:"piper",voice:"string",speed:1,...i}}updateConfig(i){this.config={...this.config,...i}}async synthesizeSpeech(i){const{text:e,voice:o=this.config.voice,speed:s=this.config.speed}=i,c=new URLSearchParams;c.append("text",e),c.append("voice",o||"string"),c.append("speed",(s==null?void 0:s.toString())||"1");const n=await Z(`${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:c},{attempts:1,backoff:"fixed",baseDelay:1e3,maxDelay:1e3,jitter:!1});if(!n.ok)throw new Error(`TTS request failed: ${n.status} ${n.statusText}`);const a=n.headers.get("content-type");if(a&&a.includes("audio/"))return n.blob();try{const w=await n.json();throw new Error(`TTS Error: ${JSON.stringify(w)}`)}catch{throw new Error("TTS request failed with unknown error")}}async speak(i,e){var o,s;try{this.stop(),(o=e==null?void 0:e.onStart)==null||o.call(e);const c=await this.synthesizeSpeech(i),n=URL.createObjectURL(c);return this.currentAudio=new Audio(n),new Promise((a,w)=>{if(!this.currentAudio){w(new Error("Audio element not created"));return}const f=this.currentAudio;f.onended=()=>{var u;URL.revokeObjectURL(n),this.currentAudio=null,(u=e==null?void 0:e.onEnd)==null||u.call(e),a()},f.onerror=u=>{var h;URL.revokeObjectURL(n),this.currentAudio=null;const m=new Error(`Audio playback failed: ${u}`);(h=e==null?void 0:e.onError)==null||h.call(e,m),w(m)},f.play().catch(u=>{var h;URL.revokeObjectURL(n),this.currentAudio=null;const m=new Error(`Failed to play audio: ${u.message}`);(h=e==null?void 0:e.onError)==null||h.call(e,m),w(m)})})}catch(c){const n=c instanceof Error?c:new Error(`TTS Error: ${String(c)}`);throw(s=e==null?void 0:e.onError)==null||s.call(e,n),n}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const K=new Le,Fe=(r={})=>{const[i,e]=l.useState(!1),[o,s]=l.useState(!1),[c,n]=l.useState(null);r.config&&K.updateConfig(r.config);const a=l.useCallback(async(f,u={})=>{var m;try{n(null),s(!0);const h={text:f,...u};await K.speak(h,{onStart:()=>{var g;s(!1),e(!0),(g=r.onStart)==null||g.call(r)},onEnd:()=>{var g;e(!1),(g=r.onEnd)==null||g.call(r)},onError:g=>{var v;e(!1),s(!1),n(g),(v=r.onError)==null||v.call(r,g)}})}catch(h){const g=h instanceof Error?h:new Error(String(h));throw n(g),e(!1),s(!1),(m=r.onError)==null||m.call(r,g),g}},[r]),w=l.useCallback(()=>{K.stop(),e(!1),s(!1)},[]);return{speak:a,stop:w,isPlaying:i,isLoading:o,error:c}},Ue=({className:r=""})=>{const i=l.useRef(null);return l.useEffect(()=>{let e=null;return(async()=>{try{e=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),i.current&&(i.current.srcObject=e)}catch(s){console.error("Error accessing camera:",s)}})(),()=>{e&&e.getTracks().forEach(s=>s.stop())}},[]),t.jsx("div",{className:`iw-relative ${r}`,children:t.jsx("video",{ref:i,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-md iw-min-h-[400px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}})})},Y=r=>{const{baseColor:i,borderRadius:e}=z(),{loading:o,children:s,...c}=r;return t.jsx(X,{style:{background:he(i),borderRadius:e},...c,children:o?t.jsx(ue,{}):s})},ee=r=>t.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",...r,children:[t.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),t.jsx("path",{d:"M12 6v6l4 2"}),t.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),t.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),t.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),t.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Ge=(r,i,e)=>Math.max(i,Math.min(e,r)),me=r=>{const i=Math.max(0,Math.floor(r)),e=Math.floor(i/60).toString().padStart(2,"0"),o=(i%60).toString().padStart(2,"0");return`${e}:${o}`},te=({total:r,remaining:i,size:e=64,strokeWidth:o=6,className:s="",showLabel:c=!0})=>{const n=Math.max(1,r||1),a=Ge(i/n,0,1),{radius:w,circumference:f,dashOffset:u,center:m}=l.useMemo(()=>{const v=(e-o)/2,S=2*Math.PI*v,N=S*(1-a),d=Math.round(o)%2===1,b=e/2+(d?.5:0);return{radius:v,circumference:S,dashOffset:N,center:b}},[e,o,a]),h=l.useMemo(()=>a<=.25?"iw-stroke-red-500":a<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[a]),g=a<=.25?"iw-animate-pulse":"";return t.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${s}`,style:{width:e,height:e},"aria-label":`Time remaining ${me(i)}`,role:"timer","aria-live":"polite",children:[t.jsx("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,preserveAspectRatio:"xMidYMid meet",children:t.jsxs("g",{transform:`rotate(-90 ${m} ${m})`,children:[t.jsx("circle",{cx:m,cy:m,r:w,className:"iw-stroke-gray-200",strokeWidth:o,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),t.jsx("circle",{cx:m,cy:m,r:w,className:`${h} ${g}`,strokeWidth:o,strokeLinecap:"round",fill:"none",strokeDasharray:f,strokeDashoffset:u,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),c&&t.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:t.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${a<=.25?"iw-text-red-600":a<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:me(i)})})]})},qe=({label:r,error:i,fullWidth:e=!1,className:o="",id:s,...c})=>{const n=s||`textarea-${Math.random().toString(36).substring(2,9)}`,a="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",w=i?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",f=e?"iw-w-full":"",u=o.includes("iw-h-full")||e?"iw-h-full":"";return t.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${e?"iw-w-full":""}`,children:[r&&t.jsx("label",{htmlFor:n,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:r}),t.jsx("textarea",{id:n,className:`${a} ${w} ${f} ${u} ${o}`,"aria-invalid":i?"true":"false",...c}),i&&t.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:i})]})},Be=({value:r,onChange:i,onSubmit:e,isSubmitDisabled:o,state:s,editingTime:c})=>{const n=a=>{a.key==="Enter"&&(a.ctrlKey||a.metaKey)&&!o&&(a.preventDefault(),e())};return t.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[t.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[t.jsx(ee,{className:"iw-size-4 iw-text-orange-600"}),t.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),t.jsx(te,{total:c,remaining:s.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),t.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[t.jsx(qe,{value:r,onChange:i,onKeyDown:n,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:a=>a.preventDefault(),onCopy:a=>a.preventDefault(),onCut:a=>a.preventDefault(),onDrop:a=>a.preventDefault(),onDragOver:a=>a.preventDefault()}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:t.jsx(Y,{onClick:e,disabled:o,children:"Submit Answer"})})]})]})},ze=({className:r="",width:i,height:e=56,barWidth:o=3,gap:s=2,fftSize:c=1024,smoothingTimeConstant:n=.8,mediaStream:a,startOnMount:w=!0})=>{const{baseColor:f}=z(),u=l.useRef(null),m=l.useRef(null),h=l.useRef(null),g=l.useRef(null),v=l.useRef(null),S=l.useRef(null),N=l.useRef(!1),[d,b]=l.useState(null);l.useEffect(()=>{if(i||!m.current)return;const y=m.current,P=()=>{const T=u.current;if(!T)return;const M=y.clientWidth,R=e;T.width=Math.max(1,Math.floor(M*window.devicePixelRatio||1)),T.height=Math.max(1,Math.floor(R*window.devicePixelRatio||1))},p=new ResizeObserver(P);return p.observe(y),P(),()=>p.disconnect()},[i,e]),l.useEffect(()=>{if(!i)return;const y=u.current;y&&(y.width=Math.max(1,Math.floor(i*(window.devicePixelRatio||1))),y.height=Math.max(1,Math.floor(e*(window.devicePixelRatio||1))))},[i,e]),l.useEffect(()=>{let y=!1;return(async()=>{try{const p=new(window.AudioContext||window.webkitAudioContext);h.current=p;let T=a;if(!T){if(!w)return;T=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),N.current=!0}if(y)return;const M=p.createAnalyser();M.fftSize=c,M.smoothingTimeConstant=n,g.current=M;const R=p.createMediaStreamSource(T);v.current=R,R.connect(M),E()}catch(p){b((p==null?void 0:p.message)||"Failed to initialize microphone")}})(),()=>{var p,T,M,R;y=!0,S.current&&cancelAnimationFrame(S.current);try{(p=v.current)==null||p.disconnect()}catch{}try{(T=g.current)==null||T.disconnect()}catch{}N.current&&((R=((M=v.current)==null?void 0:M.mediaStream)||void 0)==null||R.getTracks().forEach(G=>G.stop())),h.current&&h.current.state!=="closed"&&h.current.close()}},[a,c,n,w]);const E=()=>{const y=u.current,P=g.current;if(!y||!P)return;const p=y.getContext("2d");if(!p)return;const T=window.devicePixelRatio||1,M=y.width,R=y.height,G=P.frequencyBinCount,L=new Uint8Array(G),$=()=>{S.current=requestAnimationFrame($),P.getByteTimeDomainData(L),p.clearRect(0,0,M,R),p.fillStyle="rgba(0,0,0,0)",p.fillRect(0,0,M,R);const _=Math.max(1,Math.floor(o*T)),I=Math.max(1,Math.floor(s*T)),q=_+I,V=Math.max(8,Math.floor((M+I)/q)),re=Math.floor(L.length/V);for(let B=0;B<V;B++){const se=Math.min(L.length-1,B*re),ne=L[se]/128-1,F=Math.abs(ne),ae=Math.pow(F,.6),x=Math.max(R*.06,ae*(R*.9)),O=B*q,J=(R-x)/2,st=140-Math.min(140,140*F),nt=85,at=48+Math.floor(12*(1-F));p.fillStyle=`${f}`,p.shadowColor=`hsla(${st}, ${nt}%, ${at}%, ${.25*F})`,p.shadowBlur=8*F;const ot=Math.min(_/2,x/2);Qe(p,O,J,_,x,ot),p.fill()}};$()};return t.jsxs("div",{ref:m,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${r}`,style:{height:e},children:[t.jsx("canvas",{ref:u,className:"iw-w-full iw-h-full"}),d&&t.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:t.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:d})})]})};function Qe(r,i,e,o,s,c){const n=Math.min(c,o/2,s/2);r.beginPath(),r.moveTo(i+n,e),r.lineTo(i+o-n,e),r.quadraticCurveTo(i+o,e,i+o,e+n),r.lineTo(i+o,e+s-n),r.quadraticCurveTo(i+o,e+s,i+o-n,e+s),r.lineTo(i+n,e+s),r.quadraticCurveTo(i,e+s,i,e+s-n),r.lineTo(i,e+n),r.quadraticCurveTo(i,e,i+n,e),r.closePath()}const We=({state:r,answeringTime:i,nextPhase:e,sttError:o})=>t.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[t.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...."}),t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[t.jsx(ee,{className:"iw-size-4 iw-text-orange-600"}),t.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),t.jsx(te,{total:i,remaining:r.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),t.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."})]}),t.jsxs("div",{children:[t.jsx(ze,{}),o&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",o.message]})]}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:t.jsx(Y,{onClick:()=>{e()},children:"Transcribe My Answer"})})]});function He(){const[r,i]=l.useState(!0),e=l.useMemo(()=>[0,1,2].map(o=>({id:o})),[]);return l.useEffect(()=>{const o=setInterval(()=>{i(s=>!s)},1500);return()=>clearInterval(o)},[]),t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[t.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:e.map((o,s)=>{const c=s*50,n=r?c:c+12,a=r?1:.08,w=s*140;return t.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(${n}px)`,opacity:a,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${w}ms, opacity 400ms ease ${w}ms`},children:t.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[t.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),t.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[t.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),t.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},o.id)})}),t.jsx("div",{className:"iw-text-center",children:t.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const fe=({isOpen:r,onClose:i,children:e,title:o,showCloseButton:s=!0,closeOnOverlayClick:c=!0,closeOnEscape:n=!0,className:a=""})=>{if(l.useEffect(()=>{if(!r||!n)return;const u=m=>{m.key==="Escape"&&i()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r,n,i]),l.useEffect(()=>(r?(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")}),[r]),!r)return null;const w=u=>{c&&u.target===u.currentTarget&&i()},f=t.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[t.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:w}),t.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 ${a}`,role:"dialog","aria-modal":"true","aria-labelledby":o?"dialog-title":void 0,children:[(o||s)&&t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[o&&t.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:o}),s&&t.jsx("button",{onClick:i,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:t.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:e})]})]});return U.createPortal(f,document.body)},Ye=({open:r,onClose:i})=>t.jsx(fe,{isOpen:r,onClose:i||(()=>{}),title:"Interview Complete!",className:"",children:t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-text-center iw-py-2",children:[t.jsx("svg",{className:"iw-w-16 iw-h-16 iw-mx-auto iw-mb-4 iw-text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsx("p",{className:"iw-text-gray-600 iw-mb-6",children:"Thank you for your time. Your answers have been recorded and submitted for review."})]})}),Ve=({size:r="192px",className:i,colors:e,animationDuration:o=20})=>{const c={...{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)"},...e},n=parseInt(r.replace("px",""),10),a=n<50?Math.max(n*.008,1):Math.max(n*.015,4),w=n<50?Math.max(n*.004,1.2):Math.max(n*.008,1.5),f=n<50?Math.max(n*.004,.05):Math.max(n*.008,.1),u=n<50?Math.max(n*.004,.5):Math.max(n*.008,2),m=n<30?"0%":n<50?"5%":n<100?"15%":"25%",h=n<30?1.1:n<50?Math.max(w*1.2,1.3):w;return t.jsx("div",{className:`siri-orb ${i}`,style:{width:r,height:r,"--bg":c.bg,"--c1":c.c1,"--c2":c.c2,"--c3":c.c3,"--animation-duration":`${o}s`,"--blur-amount":`${a}px`,"--contrast-amount":h,"--dot-size":`${f}px`,"--shadow-spread":`${u}px`,"--mask-radius":m},children:t.jsx("style",{children:`
9
+ */var pe=Symbol.for("react.transitional.element"),be=Symbol.for("react.fragment");function de(i,r,e){var n=null;if(e!==void 0&&(n=""+e),r.key!==void 0&&(n=""+r.key),"key"in r){e={};for(var s in r)s!=="key"&&(e[s]=r[s])}else e=r;return r=e.ref,{$$typeof:pe,type:i,key:n,ref:r!==void 0?r:null,props:e}}V.Fragment=be,V.jsx=de,V.jsxs=de,ce.exports=V;var t=ce.exports;const D={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"}}},ue=l.createContext(null);function we({config:i={},children:r}){var n,s,c,o;const e={api:{...D.api,...i.api,retryConfig:{...D.api.retryConfig,...(n=i.api)==null?void 0:n.retryConfig}},ui:{...D.ui,...i.ui},interview:{...D.interview,...i.interview,timers:{...D.interview.timers,...(s=i.interview)==null?void 0:s.timers},stt:{...D.interview.stt,...(c=i.interview)==null?void 0:c.stt},tts:{...D.interview.tts,...(o=i.interview)==null?void 0:o.tts}}};return t.jsx(ue.Provider,{value:e,children:r})}function J(){const i=l.useContext(ue);if(!i)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return i}function ye(){return J().api||D.api}function z(){return J().ui||D.ui}function ve(){return J().interview||D.interview}const he=({className:i,...r})=>t.jsx("div",{children:t.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:[t.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),t.jsx("path",{d:"M12 6l0 -3"}),t.jsx("path",{d:"M16.25 7.75l2.15 -2.15"}),t.jsx("path",{d:"M18 12l3 0"}),t.jsx("path",{d:"M16.25 16.25l2.15 2.15"}),t.jsx("path",{d:"M12 18l0 3"}),t.jsx("path",{d:"M7.75 16.25l-2.15 2.15"}),t.jsx("path",{d:"M6 12l-3 0"}),t.jsx("path",{d:"M7.75 7.75l-2.15 -2.15"})]})}),K=({children:i,variant:r="primary",size:e="md",fullWidth:n=!1,isLoading:s=!1,disabled:c,className:o="",...a})=>{const d="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",f={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"},w={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",h=n?"iw-w-full":"";return t.jsxs("button",{className:`${d} ${f[r]} ${w[e]} ${h} ${m} ${o}`,disabled:c||s,...a,children:[s&&t.jsx(he,{height:16,width:16,style:{marginRight:"3px"}}),i]})};function je(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 Te(i,r,e){return"#"+[i,r,e].map(n=>{const s=Math.round(n).toString(16);return s.length===1?"0"+s:s}).join("")}function me(i,r){const e=je(i);if(!e)return i;const n=e.r+(255-e.r)*r,s=e.g+(255-e.g)*r,c=e.b+(255-e.b)*r;return Te(n,s,c)}function Ne(i,r=.8){return{background:`linear-gradient(to bottom, ${me(i,r)}, #ffffff)`,color:"#1f2937"}}function ke(i){return new Promise(r=>setTimeout(r,i))}function fe(i){return`linear-gradient(to left, ${me(i,.4)}, ${i})`}const Se=i=>t.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:[t.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"}),t.jsx("path",{d:"m9 12 2 2 4-4"})]}),Ee=["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","All activities are being recorded, and any violations may result in penalties, including disqualification"],Ie=({isOpen:i,onStart:r,onClose:e})=>{var E;const n=l.useRef(null),s=l.useRef(null),{baseColor:c,borderRadius:o}=z(),[a,d]=l.useState(!1),[f,w]=l.useState(null),[m,h]=l.useState(!1),g=()=>{s.current&&(s.current.getTracks().forEach(u=>u.stop()),s.current=null)},T=async()=>{h(!0),w(null);try{const u=await navigator.mediaDevices.getUserMedia({video:{width:{ideal:1280},height:{ideal:720}},audio:!0});s.current=u,n.current&&(n.current.srcObject=u),d(!0)}catch(u){console.error("Media permission error:",u);let p="Unable to access camera or microphone.";(u==null?void 0:u.name)==="NotAllowedError"?p="Permissions denied. Please allow access to camera and microphone.":(u==null?void 0:u.name)==="NotFoundError"?p="No camera/microphone found. Please connect a device and retry.":u!=null&&u.message&&(p=u.message),d(!1),w(p)}finally{h(!1)}};if(l.useEffect(()=>{if(!i){g();return}return T(),()=>{g()}},[i]),!i)return null;const v=()=>{r(),g()};return t.jsx("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center iw-bg-black/50 iw-backdrop-blur-sm",children:t.jsxs("div",{className:"iw-bg-white iw-rounded-xl iw-shadow-2xl iw-w-full iw-max-w-[800px] iw-mx-4",children:[t.jsxs("div",{className:"iw-px-5 iw-py-4 iw-border-b iw-border-gray-200 iw-flex iw-items-center iw-justify-between",children:[t.jsx("h2",{className:"iw-text-base iw-font-semibold",children:"Interview Onboarding"}),e&&t.jsx("button",{"aria-label":"Close",className:"iw-text-gray-500 hover:iw-text-gray-700",onClick:()=>{g(),e==null||e()},children:"✕"})]}),t.jsxs("div",{className:"iw-p-4 iw-grid iw-grid-cols-2 iw-gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"iw-border iw-border-gray-200 iw-rounded-lg iw-overflow-hidden iw-bg-gray-900",children:t.jsx("video",{ref:n,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-64 iw-object-cover",style:{transform:"scaleX(-1)"}})}),t.jsxs("div",{className:"iw-grid iw-grid-cols-2 iw-gap-2 iw-mt-3",children:[t.jsx(K,{onClick:T,disabled:m,variant:"outline",size:"sm",style:{borderColor:c,borderRadius:o,color:c},children:a?"Recheck Permissions":"Enable Camera & Mic"}),t.jsx(K,{onClick:v,disabled:!a,size:"sm",style:{background:fe(c),borderRadius:o},children:"Start Interview"})]})]}),t.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-3",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-2 iw-text-gray-800 iw-font-semibold",children:[t.jsx(Se,{}),t.jsx("h3",{children:"Interview Guidelines"})]}),!((E=navigator.mediaDevices)!=null&&E.getUserMedia)&&t.jsx("div",{className:"iw-text-xs iw-text-red-600",children:"Your browser does not support media devices. Please use a modern browser like Chrome, Edge, or Firefox."}),f&&t.jsx("div",{className:"iw-text-xs iw-text-red-600",children:f}),t.jsx("ul",{className:"iw-mt-1 iw-text-sm iw-text-gray-500 iw-list-disc iw-pl-4 iw-space-y-1.5",children:Ee.map((u,p)=>t.jsx("li",{children:u},p))})]})]})]})})};var S=(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))(S||{});const Ce={thinkingDuration:30,answeringDuration:120,editingDuration:30},Me={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 Re{constructor(r={},e={}){A(this,"config");A(this,"state");A(this,"phaseIntervalId",null);A(this,"globalIntervalId",null);A(this,"callbacks");this.config={...Ce,...r},this.callbacks=e,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,e=Me[r];if(!e)return;this.stopPhaseTimer(),this.state.phase=e.next;const n=this.getDurationForPhase(e.next);n>0?(this.state.currentPhaseTimeRemaining=n,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var r,e,n,s;(e=(r=this.callbacks).onComplete)==null||e.call(r),this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(s=(n=this.callbacks).onInterviewEnd)==null||s.call(n),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,e;this.state.totalTimeElapsed++,(e=(r=this.callbacks).onTick)==null||e.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,e;(e=(r=this.callbacks).onPhaseChange)==null||e.call(r,this.state.phase,this.getState())}}function Ae(i={}){const{config:r={},callbacks:e={}}=i,n=l.useRef(null);n.current||(n.current=new Re(r,{}));const s=n.current,[c,o]=l.useState(s.getState()),a=l.useCallback(()=>{o(s.getState())},[s]);l.useEffect(()=>{const m={onPhaseChange:(h,g)=>{var T;a(),(T=e.onPhaseChange)==null||T.call(e,h,g)},onTick:h=>{var g;a(),(g=e.onTick)==null||g.call(e,h)},onInterviewEnd:()=>{var h;a(),(h=e.onInterviewEnd)==null||h.call(e)}};s.callbacks=m},[s,e,a]),l.useEffect(()=>()=>{s.destroy()},[s]);const d=l.useCallback(()=>{s.startQuestion(),a()},[s,a]),f=l.useCallback(()=>{s.nextPhase(),a()},[s,a]),w=l.useCallback(()=>{s.completeInterview(),a()},[s,a]);return{state:c,startQuestion:d,nextPhase:f,completeInterview:w,timerService:s}}function De(i,r={}){const[e,n]=l.useState({data:null,loading:!1,error:null}),s=l.useCallback(async(...c)=>{var o,a,d,f;n(w=>({...w,loading:!0,error:null}));try{const w=await i(...c);n(m=>({...m,data:w,loading:!1,error:null})),(o=r.onSuccess)==null||o.call(r,w),(a=r.onSettled)==null||a.call(r,w,null)}catch(w){const m=w.type?w:{type:"unknown",message:w.message||"Unknown error",retryable:!0,userMessage:"Something went wrong. Please try again.",originalError:w};n(h=>({...h,loading:!1,error:m})),(d=r.onError)==null||d.call(r,m),(f=r.onSettled)==null||f.call(r,null,m)}},[i,r]);return{...e,execute:s}}function Pe(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:e}=i;if(e===401||e===403)return{type:"auth",status:e,message:"Authentication failed",retryable:!1,userMessage:"Your session has expired. Please refresh the page."};if(e===429)return{type:"rate-limit",status:e,message:"Too many requests",retryable:!0,userMessage:"Please wait a moment before trying again."};if(e>=500)return{type:"server",status:e,message:`Server error: ${e}`,retryable:!0,userMessage:"Our servers are experiencing issues. Please try again in a few moments."};if(e>=400)return{type:"client",status:e,message:`Client error: ${e}`,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 ee(i,r={},e={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let n;for(let s=1;s<=e.attempts;s++)try{const c=new AbortController,o=setTimeout(()=>c.abort(),6e4),a=await fetch(i,{...r,signal:c.signal});if(clearTimeout(o),a.status>=400&&a.status<500&&a.status!==429)return a;if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);return a}catch(c){n=c;const o=Pe(c);if(!o.retryable||s===e.attempts)throw o;const a=$e(s,e);console.warn(`API request failed (attempt ${s}/${e.attempts}), retrying in ${a}ms:`,o.message),await new Promise(d=>setTimeout(d,a))}throw n}function $e(i,r){let e;return r.backoff==="exponential"?e=r.baseDelay*Math.pow(2,i-1):e=r.baseDelay,e=Math.min(e,r.maxDelay),r.jitter&&(e=e*(.5+Math.random()*.5)),Math.round(e)}class _e{constructor(r={}){A(this,"config");this.config=r}updateConfig(r){this.config={...this.config,...r}}getHeaders(){var e;const r={"Content-Type":"application/json","X-Auth-Token":"appkey"};return(e=this.config)!=null&&e.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:e=!1,qnaId:n,question:s,answer:c,answerDuration:o}){const a=await ee(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:r,is_interview_done:e,qna_id:n,question:s,answer:c,answer_duration:o??"00:00:30"})});if(!a.ok)throw new Error(`Failed to get questions: ${a.status}`);return await a.json()}}function Oe(){const i=J();return l.useMemo(()=>{const e=i.api||{};return new _e(e)},[i.api])}class j extends Error{constructor(r,e,n=!1){super(r),this.code=e,this.recoverable=n,this.name="STTError"}}class Le{constructor(r={}){A(this,"config");A(this,"mediaRecorder",null);A(this,"audioChunks",[]);A(this,"recordingStream",null);A(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,e){var n;if(!this.isRecordingSupported())throw new j("Audio recording is not supported in this browser","RECORDING_NOT_SUPPORTED",!1);if(this.isRecording())throw new j("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 s=this.getSupportedMimeType();this.mediaRecorder=new MediaRecorder(this.recordingStream,{mimeType:s}),this.mediaRecorder.ondataavailable=c=>{var o;c.data.size>0&&(this.audioChunks.push(c.data),(o=e==null?void 0:e.onDataAvailable)==null||o.call(e,c.data))},this.mediaRecorder.onstop=()=>{var c;(c=e==null?void 0:e.onStop)==null||c.call(e)},this.mediaRecorder.onerror=c=>{var a;const o=new j(`Recording failed: ${c.error}`,"RECORDING_ERROR",!0);(a=e==null?void 0:e.onError)==null||a.call(e,o),this.cleanup()},this.mediaRecorder.start(100),(n=e==null?void 0:e.onStart)==null||n.call(e),r&&r>0&&(this.autoStopTimeoutId=setTimeout(()=>{this.isRecording()&&this.stopRecording()},r*1e3))}catch(s){if(this.cleanup(),s instanceof Error){if(s.name==="NotAllowedError"||s.name==="PermissionDeniedError")throw new j("Microphone permission was denied","PERMISSION_DENIED",!1);if(s.name==="NotFoundError")throw new j("No microphone found","NO_MICROPHONE",!1)}throw new j(`Failed to start recording: ${s instanceof Error?s.message:String(s)}`,"START_RECORDING_FAILED",!0)}}async stopRecording(){if(this.autoStopTimeoutId&&(clearTimeout(this.autoStopTimeoutId),this.autoStopTimeoutId=null),!this.mediaRecorder||!this.isRecording())throw new j("No active recording to stop","NO_ACTIVE_RECORDING",!1);return new Promise((r,e)=>{if(!this.mediaRecorder){e(new j("MediaRecorder is null","MEDIARECORDER_NULL",!1));return}const n=this.mediaRecorder,s=()=>{try{const c=n.mimeType||"audio/webm",o=new Blob(this.audioChunks,{type:c});this.cleanup(),r(o)}catch(c){e(new j(`Failed to create audio blob: ${c instanceof Error?c.message:String(c)}`,"BLOB_CREATION_FAILED",!1))}};n.addEventListener("stop",s,{once:!0}),n.stop()})}async transcribe(r){const{audioBlob:e,model:n=this.config.model,language:s=this.config.language,includeTimestamps:c=this.config.includeTimestamps,temperature:o=this.config.temperature}=r;if(!e||e.size===0)throw new j("Audio blob is empty or invalid","INVALID_AUDIO",!1);try{const a=new FormData,d=new File([e],"recording.wav",{type:e.type||"audio/wav"});a.append("file",d),a.append("model",n||"whisper-large-v3-turbo"),a.append("language",s||"en"),a.append("include_timestamps",String(c||!1)),a.append("temperature",String(o||0));const f=await ee(`${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:a},{attempts:1,backoff:"exponential",baseDelay:1e3,maxDelay:3e3,jitter:!0});if(!f.ok){const m=await f.text();let h=`STT request failed: ${f.status} ${f.statusText}`;try{const g=JSON.parse(m);h=g.message||g.error||h}catch{h=m||h}throw new j(h,`HTTP_${f.status}`,f.status>=500)}return{transcript:(await f.json()).data.text??""}}catch(a){throw a instanceof j?a:new j(`Transcription failed: ${a instanceof Error?a.message:String(a)}`,"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 e of r)if(MediaRecorder.isTypeSupported(e))return e;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 Q=new Le,Fe=(i={})=>{const[r,e]=l.useState(!1),[n,s]=l.useState(!1),[c,o]=l.useState(null),[a,d]=l.useState(null),[f,w]=l.useState(null);i.config&&Q.updateConfig(i.config);const m=l.useCallback(async v=>{var E;try{d(null),o(null),w(null),await Q.startRecording(v,{onStart:()=>{var u;e(!0),(u=i.onStart)==null||u.call(i)},onStop:()=>{var u;e(!1),(u=i.onStop)==null||u.call(i)},onError:u=>{var M;const p=u instanceof j?u:new j(u.message,"RECORDING_ERROR",!0);d(p),e(!1),(M=i.onError)==null||M.call(i,p)}})}catch(u){const p=u instanceof j?u:new j(u instanceof Error?u.message:String(u),"START_FAILED",!1);throw d(p),e(!1),(E=i.onError)==null||E.call(i,p),p}},[]),h=l.useCallback(async()=>{var v,E;try{const u=await Q.stopRecording();return w(u),e(!1),(v=i.onStop)==null||v.call(i),u}catch(u){const p=u instanceof j?u:new j(u instanceof Error?u.message:String(u),"STOP_FAILED",!1);throw d(p),e(!1),(E=i.onError)==null||E.call(i,p),p}},[]),g=l.useCallback(async(v,E={})=>{var u,p;try{d(null),s(!0);const M={audioBlob:v,...E},b=await Q.transcribe(M);return o(b.transcript),s(!1),(u=i.onTranscriptionComplete)==null||u.call(i,b),b}catch(M){const b=M instanceof j?M:new j(M instanceof Error?M.message:String(M),"TRANSCRIPTION_FAILED",!0);throw d(b),s(!1),(p=i.onError)==null||p.call(i,b),b}},[]),T=l.useCallback(()=>{Q.cancelRecording(),e(!1),w(null)},[]);return{startRecording:m,stopRecording:h,transcribe:g,cancelRecording:T,isRecording:r,isTranscribing:n,transcript:c,error:a,audioBlob:f}};class Ue{constructor(r={}){A(this,"config");A(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:e,voice:n=this.config.voice,speed:s=this.config.speed}=r,c=new URLSearchParams;c.append("text",e),c.append("voice",n||"string"),c.append("speed",(s==null?void 0:s.toString())||"1");const o=await ee(`${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:c},{attempts:1,backoff:"fixed",baseDelay:1e3,maxDelay:1e3,jitter:!1});if(!o.ok)throw new Error(`TTS request failed: ${o.status} ${o.statusText}`);const a=o.headers.get("content-type");if(a&&a.includes("audio/"))return o.blob();try{const d=await o.json();throw new Error(`TTS Error: ${JSON.stringify(d)}`)}catch{throw new Error("TTS request failed with unknown error")}}async speak(r,e){var n,s;try{this.stop(),(n=e==null?void 0:e.onStart)==null||n.call(e);const c=await this.synthesizeSpeech(r),o=URL.createObjectURL(c);return this.currentAudio=new Audio(o),new Promise((a,d)=>{if(!this.currentAudio){d(new Error("Audio element not created"));return}const f=this.currentAudio;f.onended=()=>{var w;URL.revokeObjectURL(o),this.currentAudio=null,(w=e==null?void 0:e.onEnd)==null||w.call(e),a()},f.onerror=w=>{var h;URL.revokeObjectURL(o),this.currentAudio=null;const m=new Error(`Audio playback failed: ${w}`);(h=e==null?void 0:e.onError)==null||h.call(e,m),d(m)},f.play().catch(w=>{var h;URL.revokeObjectURL(o),this.currentAudio=null;const m=new Error(`Failed to play audio: ${w.message}`);(h=e==null?void 0:e.onError)==null||h.call(e,m),d(m)})})}catch(c){const o=c instanceof Error?c:new Error(`TTS Error: ${String(c)}`);throw(s=e==null?void 0:e.onError)==null||s.call(e,o),o}}stop(){this.currentAudio&&(this.currentAudio.pause(),this.currentAudio.currentTime=0,this.currentAudio=null)}isPlaying(){return this.currentAudio!==null&&!this.currentAudio.paused}}const te=new Ue,Ge=(i={})=>{const[r,e]=l.useState(!1),[n,s]=l.useState(!1),[c,o]=l.useState(null);i.config&&te.updateConfig(i.config);const a=l.useCallback(async(f,w={})=>{var m;try{o(null),s(!0);const h={text:f,...w};await te.speak(h,{onStart:()=>{var g;s(!1),e(!0),(g=i.onStart)==null||g.call(i)},onEnd:()=>{var g;e(!1),(g=i.onEnd)==null||g.call(i)},onError:g=>{var T;e(!1),s(!1),o(g),(T=i.onError)==null||T.call(i,g)}})}catch(h){const g=h instanceof Error?h:new Error(String(h));throw o(g),e(!1),s(!1),(m=i.onError)==null||m.call(i,g),g}},[i]),d=l.useCallback(()=>{te.stop(),e(!1),s(!1)},[]);return{speak:a,stop:d,isPlaying:r,isLoading:n,error:c}},qe=({className:i=""})=>{const r=l.useRef(null);return l.useEffect(()=>{let e=null;return(async()=>{try{e=await navigator.mediaDevices.getUserMedia({video:!0,audio:!1}),r.current&&(r.current.srcObject=e)}catch(s){console.error("Error accessing camera:",s)}})(),()=>{e&&e.getTracks().forEach(s=>s.stop())}},[]),t.jsx("div",{className:`iw-relative ${i}`,children:t.jsx("video",{ref:r,autoPlay:!0,playsInline:!0,muted:!0,className:"iw-w-full iw-h-full iw-object-cover iw-scale-75 iw-rounded-md iw-min-h-[400px] iw-max-h-[600px] iw-aspect-video",style:{transform:"scaleX(-1)"}})})},X=i=>{const{baseColor:r,borderRadius:e}=z(),{loading:n,children:s,...c}=i;return t.jsx(K,{style:{background:fe(r),borderRadius:e},...c,children:n?t.jsx(he,{}):s})},ie=i=>t.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:[t.jsx("path",{d:"M12 2a10 10 0 0 1 7.38 16.75"}),t.jsx("path",{d:"M12 6v6l4 2"}),t.jsx("path",{d:"M2.5 8.875a10 10 0 0 0-.5 3"}),t.jsx("path",{d:"M2.83 16a10 10 0 0 0 2.43 3.4"}),t.jsx("path",{d:"M4.636 5.235a10 10 0 0 1 .891-.857"}),t.jsx("path",{d:"M8.644 21.42a10 10 0 0 0 7.631-.38"})]}),Be=(i,r,e)=>Math.max(r,Math.min(e,i)),ge=i=>{const r=Math.max(0,Math.floor(i)),e=Math.floor(r/60).toString().padStart(2,"0"),n=(r%60).toString().padStart(2,"0");return`${e}:${n}`},re=({total:i,remaining:r,size:e=64,strokeWidth:n=6,className:s="",showLabel:c=!0})=>{const o=Math.max(1,i||1),a=Be(r/o,0,1),{radius:d,circumference:f,dashOffset:w,center:m}=l.useMemo(()=>{const T=(e-n)/2,v=2*Math.PI*T,E=v*(1-a),u=Math.round(n)%2===1,p=e/2+(u?.5:0);return{radius:T,circumference:v,dashOffset:E,center:p}},[e,n,a]),h=l.useMemo(()=>a<=.25?"iw-stroke-red-500":a<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[a]),g=a<=.25?"iw-animate-pulse":"";return t.jsxs("div",{className:`iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${s}`,style:{width:e,height:e},"aria-label":`Time remaining ${ge(r)}`,role:"timer","aria-live":"polite",children:[t.jsx("svg",{width:e,height:e,viewBox:`0 0 ${e} ${e}`,preserveAspectRatio:"xMidYMid meet",children:t.jsxs("g",{transform:`rotate(-90 ${m} ${m})`,children:[t.jsx("circle",{cx:m,cy:m,r:d,className:"iw-stroke-gray-200",strokeWidth:n,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),t.jsx("circle",{cx:m,cy:m,r:d,className:`${h} ${g}`,strokeWidth:n,strokeLinecap:"round",fill:"none",strokeDasharray:f,strokeDashoffset:w,shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke",style:{transition:"stroke-dashoffset 0.3s ease, stroke 0.2s ease"}})]})}),c&&t.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0",children:t.jsx("span",{className:`iw-text-[11px] iw-font-semibold iw-tabular-nums ${a<=.25?"iw-text-red-600":a<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:ge(r)})})]})},ze=({label:i,error:r,fullWidth:e=!1,className:n="",id:s,...c})=>{const o=s||`textarea-${Math.random().toString(36).substring(2,9)}`,a="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",d=r?"iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500":"",f=e?"iw-w-full":"",w=n.includes("iw-h-full")||e?"iw-h-full":"";return t.jsxs("div",{className:`iw-h-full iw-flex iw-flex-col ${e?"iw-w-full":""}`,children:[i&&t.jsx("label",{htmlFor:o,className:"iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",children:i}),t.jsx("textarea",{id:o,className:`${a} ${d} ${f} ${w} ${n}`,"aria-invalid":r?"true":"false",...c}),r&&t.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:r})]})},Qe=({value:i,onChange:r,onSubmit:e,isSubmitDisabled:n,state:s,editingTime:c})=>{const o=a=>{a.key==="Enter"&&(a.ctrlKey||a.metaKey)&&!n&&(a.preventDefault(),e())};return t.jsxs("div",{className:"iw-flex iw-flex-col iw-h-full ",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[t.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Your Answer"}),t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[t.jsx(ie,{className:"iw-size-4 iw-text-orange-600"}),t.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to edit: "})]}),t.jsx(re,{total:c,remaining:s.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),t.jsxs("div",{className:" iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2",children:[t.jsx(ze,{value:i,onChange:r,onKeyDown:o,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:a=>a.preventDefault(),onCopy:a=>a.preventDefault(),onCut:a=>a.preventDefault(),onDrop:a=>a.preventDefault(),onDragOver:a=>a.preventDefault()}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:t.jsx(X,{onClick:e,disabled:n,children:"Submit Answer"})})]})]})},We=({className:i="",width:r,height:e=56,barWidth:n=3,gap:s=2,fftSize:c=1024,smoothingTimeConstant:o=.8,mediaStream:a,startOnMount:d=!0})=>{const{baseColor:f}=z(),w=l.useRef(null),m=l.useRef(null),h=l.useRef(null),g=l.useRef(null),T=l.useRef(null),v=l.useRef(null),E=l.useRef(!1),[u,p]=l.useState(null);l.useEffect(()=>{if(r||!m.current)return;const b=m.current,P=()=>{const R=w.current;if(!R)return;const N=b.clientWidth,k=e;R.width=Math.max(1,Math.floor(N*window.devicePixelRatio||1)),R.height=Math.max(1,Math.floor(k*window.devicePixelRatio||1))},y=new ResizeObserver(P);return y.observe(b),P(),()=>y.disconnect()},[r,e]),l.useEffect(()=>{if(!r)return;const b=w.current;b&&(b.width=Math.max(1,Math.floor(r*(window.devicePixelRatio||1))),b.height=Math.max(1,Math.floor(e*(window.devicePixelRatio||1))))},[r,e]),l.useEffect(()=>{let b=!1;return(async()=>{try{const y=new(window.AudioContext||window.webkitAudioContext);h.current=y;let R=a;if(!R){if(!d)return;R=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),E.current=!0}if(b)return;const N=y.createAnalyser();N.fftSize=c,N.smoothingTimeConstant=o,g.current=N;const k=y.createMediaStreamSource(R);T.current=k,k.connect(N),M()}catch(y){p((y==null?void 0:y.message)||"Failed to initialize microphone")}})(),()=>{var y,R,N,k;b=!0,v.current&&cancelAnimationFrame(v.current);try{(y=T.current)==null||y.disconnect()}catch{}try{(R=g.current)==null||R.disconnect()}catch{}E.current&&((k=((N=T.current)==null?void 0:N.mediaStream)||void 0)==null||k.getTracks().forEach(G=>G.stop())),h.current&&h.current.state!=="closed"&&h.current.close()}},[a,c,o,d]);const M=()=>{const b=w.current,P=g.current;if(!b||!P)return;const y=b.getContext("2d");if(!y)return;const R=window.devicePixelRatio||1,N=b.width,k=b.height,G=P.frequencyBinCount,O=new Uint8Array(G),W=()=>{v.current=requestAnimationFrame(W),P.getByteTimeDomainData(O),y.clearRect(0,0,N,k),y.fillStyle="rgba(0,0,0,0)",y.fillRect(0,0,N,k);const q=Math.max(1,Math.floor(n*R)),$=Math.max(1,Math.floor(s*R)),L=q+$,I=Math.max(8,Math.floor((N+$)/L)),H=Math.floor(O.length/I);for(let B=0;B<I;B++){const ne=Math.min(O.length-1,B*H),ae=O[ne]/128-1,F=Math.abs(ae),oe=Math.pow(F,.6),Y=Math.max(k*.06,oe*(k*.9)),le=B*L,x=(k-Y)/2,_=140-Math.min(140,140*F),Z=85,at=48+Math.floor(12*(1-F));y.fillStyle=`${f}`,y.shadowColor=`hsla(${_}, ${Z}%, ${at}%, ${.25*F})`,y.shadowBlur=8*F;const ot=Math.min(q/2,Y/2);He(y,le,x,q,Y,ot),y.fill()}};W()};return t.jsxs("div",{ref:m,className:`iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${i}`,style:{height:e},children:[t.jsx("canvas",{ref:w,className:"iw-w-full iw-h-full"}),u&&t.jsx("div",{className:"iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center",children:t.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:u})})]})};function He(i,r,e,n,s,c){const o=Math.min(c,n/2,s/2);i.beginPath(),i.moveTo(r+o,e),i.lineTo(r+n-o,e),i.quadraticCurveTo(r+n,e,r+n,e+o),i.lineTo(r+n,e+s-o),i.quadraticCurveTo(r+n,e+s,r+n-o,e+s),i.lineTo(r+o,e+s),i.quadraticCurveTo(r,e+s,r,e+s-o),i.lineTo(r,e+o),i.quadraticCurveTo(r,e,r+o,e),i.closePath()}const Ye=({state:i,answeringTime:r,nextPhase:e,sttError:n})=>t.jsxs("div",{className:"iw-flex iw-flex-col iw-justify-between iw-h-full ",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between",children:[t.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...."}),t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[t.jsx(ie,{className:"iw-size-4 iw-text-orange-600"}),t.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to talk: "})]}),t.jsx(re,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]})]}),t.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."})]}),t.jsxs("div",{children:[t.jsx(We,{}),n&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",n.message]})]}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:t.jsx(X,{onClick:()=>{e()},children:"Transcribe My Answer"})})]});function Ve(){const[i,r]=l.useState(!0),e=l.useMemo(()=>[0,1,2].map(n=>({id:n})),[]);return l.useEffect(()=>{const n=setInterval(()=>{r(s=>!s)},1500);return()=>clearInterval(n)},[]),t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full",children:[t.jsx("div",{className:"iw-relative iw-w-80 iw-h-48 ","aria-hidden":!0,children:e.map((n,s)=>{const c=s*50,o=i?c:c+12,a=i?1:.08,d=s*140;return t.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(${o}px)`,opacity:a,transition:`transform 600ms cubic-bezier(.2,.9,.3,1) ${d}ms, opacity 400ms ease ${d}ms`},children:t.jsxs("div",{className:"iw-flex iw-gap-3 iw-items-center",children:[t.jsx("div",{className:"iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0"}),t.jsxs("div",{className:"iw-flex-1 iw-space-y-2",children:[t.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24"}),t.jsx("div",{className:"iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32"})]})]})},n.id)})}),t.jsx("div",{className:"iw-text-center",children:t.jsx("p",{className:"iw-text-gray-500 iw-font-medium",children:"Preparing your question..."})})]})}const xe=({isOpen:i,onClose:r,children:e,title:n,showCloseButton:s=!0,closeOnOverlayClick:c=!0,closeOnEscape:o=!0,className:a=""})=>{if(l.useEffect(()=>{if(!i||!o)return;const w=m=>{m.key==="Escape"&&r()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[i,o,r]),l.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 d=w=>{c&&w.target===w.currentTarget&&r()},f=t.jsxs("div",{className:"iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center",children:[t.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",onClick:d}),t.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 ${a}`,role:"dialog","aria-modal":"true","aria-labelledby":n?"dialog-title":void 0,children:[(n||s)&&t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[n&&t.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:n}),s&&t.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:t.jsx("svg",{className:"iw-w-5 iw-h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("div",{className:"iw-p-4 iw-overflow-y-auto",children:e})]})]});return U.createPortal(f,document.body)},Je=({open:i,onClose:r})=>t.jsx(xe,{isOpen:i,onClose:r||(()=>{}),title:"Interview Complete!",className:"",children:t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-text-center iw-py-2",children:[t.jsx("svg",{className:"iw-w-16 iw-h-16 iw-mx-auto iw-mb-4 iw-text-green-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsx("p",{className:"iw-text-gray-600 iw-mb-6",children:"Thank you for your time. Your answers have been recorded and submitted for review."})]})}),Xe=({size:i="192px",className:r,colors:e,animationDuration:n=20})=>{const c={...{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)"},...e},o=parseInt(i.replace("px",""),10),a=o<50?Math.max(o*.008,1):Math.max(o*.015,4),d=o<50?Math.max(o*.004,1.2):Math.max(o*.008,1.5),f=o<50?Math.max(o*.004,.05):Math.max(o*.008,.1),w=o<50?Math.max(o*.004,.5):Math.max(o*.008,2),m=o<30?"0%":o<50?"5%":o<100?"15%":"25%",h=o<30?1.1:o<50?Math.max(d*1.2,1.3):d;return t.jsx("div",{className:`siri-orb ${r}`,style:{width:i,height:i,"--bg":c.bg,"--c1":c.c1,"--c2":c.c2,"--c3":c.c3,"--animation-duration":`${n}s`,"--blur-amount":`${a}px`,"--contrast-amount":h,"--dot-size":`${f}px`,"--shadow-spread":`${w}px`,"--mask-radius":m},children:t.jsx("style",{children:`
10
10
  @property --angle {
11
11
  syntax: "<angle>";
12
12
  inherits: false;
@@ -111,4 +111,4 @@
111
111
  animation: none;
112
112
  }
113
113
  }
114
- `})})};function Je({ttsError:r}){return t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[t.jsx(Ve,{size:"80px"}),r&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",r.message]}),t.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const Xe=({state:r,thinkingTime:i,nextPhase:e})=>t.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),t.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."})]}),t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[t.jsx(ee,{className:"iw-size-4 iw-text-orange-600"}),t.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),t.jsx(te,{total:i,remaining:r.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:t.jsx(Y,{onClick:()=>{e()},children:"Start Answering"})})]}),Ze=({sttError:r})=>t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[t.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[t.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),t.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"}),t.jsx("defs",{children:t.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),t.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),t.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"}),t.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."}),r&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",r.message,r.recoverable&&" (attempting to continue)"]})]}),Ke=r=>t.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",...r,children:[t.jsx("path",{d:"M12 8V4H8"}),t.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),t.jsx("path",{d:"M2 14h2"}),t.jsx("path",{d:"M20 14h2"}),t.jsx("path",{d:"M15 13v2"}),t.jsx("path",{d:"M9 13v2"})]}),et=({question:r,isLoading:i=!1})=>{const{baseColor:e}=z();return t.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:je(e,.85),children:t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[t.jsxs("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:[t.jsx("div",{className:"iw-mt-8",children:t.jsx(Ke,{className:"iw-h-12 iw-w-12",style:{stroke:e}})}),t.jsx("div",{className:"iw-absolute iw-bottom-2 iw-translate-x-1/2 iw-flex iw-mt-2",children:t.jsx("div",{className:"iw-text-sm",children:"Novara"})})]}),i?t.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[t.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),t.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):t.jsx("p",{className:"iw-text-lg iw-leading-8",children:r==null?void 0:r.question})]})})},tt=({confirmExitInterview:r,isOpen:i,onClose:e})=>t.jsx(fe,{isOpen:i,onClose:e,title:"Exit Interview",children:t.jsxs("div",{className:"iw-space-y-4",children:[t.jsx("p",{className:"iw-text-base iw-text-gray-700",children:"Are you sure you want to exit the interview? All progress will be lost and you will not be able to resume."}),t.jsxs("div",{className:"iw-flex iw-justify-end iw-space-x-2",children:[t.jsx("button",{className:"iw-px-4 iw-py-2 iw-bg-gray-200 iw-rounded iw-text-gray-700 iw-font-medium",onClick:e,children:"Cancel"}),t.jsx("button",{className:"iw-px-4 iw-py-2 iw-bg-red-600 iw-text-white iw-rounded iw-font-medium",onClick:r,children:"Confirm Exit"})]})]})}),it=({title:r,onExit:i})=>{const{baseColor:e}=z(),[o,s]=l.useState(!1);return t.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[t.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-py-3",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[t.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:e},children:"N"}),t.jsx("p",{className:"iw-text-sm iw-font-medium",children:"Novara"})]}),t.jsx("h1",{className:"iw-text-base iw-font-bold",children:r}),t.jsx("button",{className:"iw-text-sm iw-text-gray-500 hover:iw-text-gray-700",onClick:()=>s(!0),children:"Exit Interview"})]}),t.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),t.jsx(tt,{isOpen:o,confirmExitInterview:()=>{i(),s(!1)},onClose:()=>s(!1)})]})},rt=({interviewId:r,onComplete:i,className:e=""})=>{const o=$e(),{baseUrl:s,authToken:c}=pe(),{timers:n,stt:a,tts:w}=be(),[f,u]=l.useState(null),[m,h]=l.useState(""),g=l.useRef(""),v=l.useRef(null),S={thinkingTime:(n==null?void 0:n.thinkingDuration)||30,answeringTime:(n==null?void 0:n.answeringDuration)||120,editingTime:(n==null?void 0:n.editingDuration)||30},{thinkingTime:N,answeringTime:d,editingTime:b}=S;l.useEffect(()=>{g.current=m},[m]);const E=l.useRef(!1),{speak:y,error:P}=Fe({config:{baseUrl:s,provider:w==null?void 0:w.provider,authToken:c},onEnd:()=>{E.current=!1,I()},onError:()=>{E.current||(E.current=!0,I())}}),p=l.useRef(!1),T=l.useRef(!1),{startRecording:M,stopRecording:R,transcribe:G,error:L}=Oe({config:{baseUrl:s,provider:a==null?void 0:a.provider,model:a==null?void 0:a.model,language:a==null?void 0:a.language,authToken:c},onStart:()=>{p.current=!1,T.current=!1},onStop:()=>{},onTranscriptionComplete:x=>{h(x.transcript),T.current||(T.current=!0,I())},onError:x=>{console.error("STT Error:",x),p.current||(p.current=!0,I())}}),{state:$,startQuestion:_,nextPhase:I,completeInterview:q}=Me({config:{thinkingDuration:N,answeringDuration:d,editingDuration:b},callbacks:{onPhaseChange:x=>{switch(x){case k.FETCHING_QUESTION:V();break;case k.READING_QUESTION:se();break;case k.ANSWERING:ne();break;case k.TRANSCRIBING:F();break;case k.SUBMITTING:B();break}},onInterviewEnd:()=>{i==null||i()}}});l.useEffect(()=>{_()},[]);const{execute:V,loading:re}=Re(async()=>{var O,J;const x=await o.generateQuestion({interviewId:r,question:((O=v.current)==null?void 0:O.question)||"",qnaId:((J=v.current)==null?void 0:J.qna_id)||"",answer:g.current});return v.current=x.data,x},{onSuccess:async x=>{x&&x.data&&(h(""),u(x.data),I())},onError:x=>{console.error("Failed to fetch questions:",x)}}),B=l.useCallback(async()=>{_()},[_]),se=l.useCallback(async()=>{var x;if((x=v.current)!=null&&x.question)try{E.current=!1,await y(v.current.question),v.current.is_interview_done&&(await Ne(2e3),q())}catch(O){console.error("Failed to speak question:",O)}else I()},[y,I,q]),ne=l.useCallback(async()=>{try{await M(d)}catch(x){console.error("Failed to start recording:",x),I()}},[M,I]),F=l.useCallback(async()=>{try{const x=await R();await G(x)}catch(x){console.error("STT processing failed:",x),!p.current&&!T.current&&(p.current=!0,I())}},[R,G,I]),ae=()=>{const{phase:x}=$;switch(x){case k.IDLE:return t.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[t.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),t.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.`}),t.jsx(Y,{onClick:_,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case k.FETCHING_QUESTION:return t.jsx(He,{});case k.READING_QUESTION:return t.jsx(Je,{ttsError:P});case k.THINKING:return t.jsx(Xe,{state:$,thinkingTime:N,nextPhase:I});case k.ANSWERING:return t.jsx(We,{state:$,answeringTime:d,nextPhase:I,sttError:L});case k.TRANSCRIBING:return t.jsx(Ze,{sttError:L});case k.EDITING:case k.SUBMITTING:return t.jsx("div",{className:"iw-space-y-4 iw-h-full",children:t.jsx(Be,{value:m,onChange:O=>h(O.target.value),onSubmit:()=>I(),isSubmitDisabled:!m.trim()||re,state:$,editingTime:b})});case k.COMPLETED:return t.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-white",children:t.jsx(Ye,{open:!0,onClose:i||(()=>{})})});default:return null}};return t.jsxs("div",{className:"interview-widget-container",children:[t.jsx(it,{title:"Interview for Python Developer",onExit:q}),t.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${e} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[t.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:t.jsx("div",{className:"iw-flex-1",children:t.jsx(et,{question:f,isLoading:$.phase===k.FETCHING_QUESTION||$.phase===k.IDLE})})}),t.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-xl iw-p-4",children:[t.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:t.jsx(Ue,{})}),t.jsx("div",{className:"iw-bg-white iw-rounded-lg iw-shadow iw-p-6",children:ae()})]})]})]})},ie=({interviewId:r,onInterviewEnd:i,className:e=""})=>{const[o,s]=l.useState(!1),[c,n]=l.useState(!0),a=l.useRef(null);return o?t.jsx("div",{className:"interview-widget-container",children:t.jsx("div",{ref:a,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${e}`,children:t.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:t.jsx(rt,{interviewId:r,className:e,onComplete:i||(()=>{})})})})}):t.jsx("div",{className:"interview-widget-container",children:t.jsx(Se,{isOpen:c,onStart:()=>{console.log("Permissions granted, starting interview"),s(!0),n(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:ie,InterviewWidgetProvider:de}),C.InterviewWidget=ie,C.InterviewWidgetProvider=de,C.default=ie,Object.defineProperties(C,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
114
+ `})})};function Ze({ttsError:i}){return t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-w-full iw-h-full",children:[t.jsx(Xe,{size:"80px"}),i&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Audio playback failed: ",i.message]}),t.jsx("p",{className:"iw-text- iw-text-gray-700",children:"Your AI interviewer is speaking..."})]})}const Ke=({state:i,thinkingTime:r,nextPhase:e})=>t.jsxs("div",{className:"iw-flex iw-flex-col iw-gap-6 iw-items-center iw-justify-center iw-text-center iw-h-full ",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Get Ready to Answer"}),t.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."})]}),t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-center iw-gap-2",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-1",children:[t.jsx(ie,{className:"iw-size-4 iw-text-orange-600"}),t.jsx("p",{className:"iw-text-gray-700 iw-text-sm",children:"Time to think: "})]}),t.jsx(re,{total:r,remaining:i.currentPhaseTimeRemaining,size:50,strokeWidth:4})]}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:t.jsx(X,{onClick:()=>{e()},children:"Start Answering"})})]}),et=({sttError:i})=>t.jsxs("div",{className:"iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full",children:[t.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 60 60",fill:"none",children:[t.jsx("rect",{width:60,height:60,rx:30,fill:"url(#prefix__paint0_linear_1460_12482)"}),t.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"}),t.jsx("defs",{children:t.jsxs("linearGradient",{id:"prefix__paint0_linear_1460_12482",x1:30,y1:-6.563,x2:77.813,y2:54.375,gradientUnits:"userSpaceOnUse",children:[t.jsx("stop",{offset:.211,stopColor:"#5C92FA"}),t.jsx("stop",{offset:1,stopColor:"#A75FFD"})]})})]}),t.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"}),t.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&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Transcription error: ",i.message,i.recoverable&&" (attempting to continue)"]})]}),tt=i=>t.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:[t.jsx("path",{d:"M12 8V4H8"}),t.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),t.jsx("path",{d:"M2 14h2"}),t.jsx("path",{d:"M20 14h2"}),t.jsx("path",{d:"M15 13v2"}),t.jsx("path",{d:"M9 13v2"})]}),it=({question:i,isLoading:r=!1})=>{const{baseColor:e}=z();return t.jsx("div",{className:"iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",style:Ne(e,.85),children:t.jsxs("div",{className:"iw-flex iw-items-center iw-gap-8",children:[t.jsxs("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:[t.jsx("div",{className:"iw-mt-8",children:t.jsx(tt,{className:"iw-h-12 iw-w-12",style:{stroke:e}})}),t.jsx("div",{className:"iw-absolute iw-bottom-2 iw-translate-x-1/2 iw-flex iw-mt-2",children:t.jsx("div",{className:"iw-text-sm",children:"Novara"})})]}),r?t.jsxs("div",{className:"iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10",children:[t.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full"}),t.jsx("div",{className:"iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4"})]}):t.jsx("p",{className:"iw-text-lg iw-leading-8",children:i==null?void 0:i.question})]})})},rt=({confirmExitInterview:i,isOpen:r,onClose:e})=>t.jsx(xe,{isOpen:r,onClose:e,title:"Exit Interview",children:t.jsxs("div",{className:"iw-space-y-4",children:[t.jsx("p",{className:"iw-text-base iw-text-gray-700",children:"Are you sure you want to exit the interview? All progress will be lost and you will not be able to resume."}),t.jsxs("div",{className:"iw-flex iw-justify-end iw-space-x-2",children:[t.jsx("button",{className:"iw-px-4 iw-py-2 iw-bg-gray-200 iw-rounded iw-text-gray-700 iw-font-medium",onClick:e,children:"Cancel"}),t.jsx("button",{className:"iw-px-4 iw-py-2 iw-bg-red-600 iw-text-white iw-rounded iw-font-medium",onClick:i,children:"Confirm Exit"})]})]})}),st=({title:i,onExit:r})=>{const{baseColor:e}=z(),[n,s]=l.useState(!1);return t.jsxs("header",{className:"iw-w-full iw-text-gray-900",children:[t.jsxs("div",{className:"iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-py-3",children:[t.jsxs("div",{className:"iw-flex iw-items-center iw-space-x-2",children:[t.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:e},children:"N"}),t.jsx("p",{className:"iw-text-sm iw-font-medium",children:"Novara"})]}),t.jsx("h1",{className:"iw-text-base iw-font-bold",children:i}),t.jsx("button",{className:"iw-text-sm iw-text-gray-500 hover:iw-text-gray-700",onClick:()=>s(!0),children:"Exit Interview"})]}),t.jsx("div",{className:"iw-h-px iw-bg-gray-200"}),t.jsx(rt,{isOpen:n,confirmExitInterview:()=>{r(),s(!1)},onClose:()=>s(!1)})]})},nt=({interviewTitle:i,interviewId:r,onComplete:e,className:n=""})=>{const s=Oe(),{baseUrl:c,authToken:o}=ye(),{timers:a,stt:d,tts:f}=ve(),[w,m]=l.useState(null),[h,g]=l.useState(""),T=l.useRef(""),v=l.useRef(null),E={thinkingTime:(a==null?void 0:a.thinkingDuration)||30,answeringTime:(a==null?void 0:a.answeringDuration)||120,editingTime:(a==null?void 0:a.editingDuration)||30},{thinkingTime:u,answeringTime:p,editingTime:M}=E;l.useEffect(()=>{T.current=h},[h]);const b=l.useRef(!1),{speak:P,stop:y,error:R}=Ge({config:{baseUrl:c,provider:f==null?void 0:f.provider,authToken:o},onEnd:()=>{b.current=!1,I()},onError:()=>{b.current||(b.current=!0,I())}}),N=l.useRef(!1),k=l.useRef(!1),{startRecording:G,stopRecording:O,transcribe:W,error:q}=Fe({config:{baseUrl:c,provider:d==null?void 0:d.provider,model:d==null?void 0:d.model,language:d==null?void 0:d.language,authToken:o},onStart:()=>{N.current=!1,k.current=!1},onStop:()=>{},onTranscriptionComplete:x=>{g(x.transcript),k.current||(k.current=!0,I())},onError:x=>{console.error("STT Error:",x),N.current||(N.current=!0,I())}}),{state:$,startQuestion:L,nextPhase:I,completeInterview:H}=Ae({config:{thinkingDuration:u,answeringDuration:p,editingDuration:M},callbacks:{onPhaseChange:x=>{switch(x){case S.FETCHING_QUESTION:B();break;case S.READING_QUESTION:F();break;case S.ANSWERING:oe();break;case S.TRANSCRIBING:Y();break;case S.SUBMITTING:ae();break}},onInterviewEnd:()=>{e==null||e()}}});l.useEffect(()=>{L()},[]);const{execute:B,loading:ne}=De(async()=>{var _,Z;const x=await s.generateQuestion({interviewId:r,question:((_=v.current)==null?void 0:_.question)||"",qnaId:((Z=v.current)==null?void 0:Z.qna_id)||"",answer:T.current});return v.current=x.data,x},{onSuccess:async x=>{x&&x.data&&(g(""),m(x.data),I())},onError:x=>{console.error("Failed to fetch questions:",x)}}),ae=l.useCallback(async()=>{L()},[L]),F=l.useCallback(async()=>{var x;if((x=v.current)!=null&&x.question)try{b.current=!1,await P(v.current.question),v.current.is_interview_done&&(await ke(2e3),H())}catch(_){console.error("Failed to speak question:",_)}else I()},[P,I,H]),oe=l.useCallback(async()=>{try{await G(p)}catch(x){console.error("Failed to start recording:",x),I()}},[G,I]),Y=l.useCallback(async()=>{try{const x=await O();await W(x)}catch(x){console.error("STT processing failed:",x),!N.current&&!k.current&&(N.current=!0,I())}},[O,W,I]),le=()=>{const{phase:x}=$;switch(x){case S.IDLE:return t.jsxs("div",{className:"iw-text-center iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-2 iw-h-full",children:[t.jsx("h3",{className:"iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1",children:"Ready to start the Interview?"}),t.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.`}),t.jsx(X,{onClick:L,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case S.FETCHING_QUESTION:return t.jsx(Ve,{});case S.READING_QUESTION:return t.jsx(Ze,{ttsError:R});case S.THINKING:return t.jsx(Ke,{state:$,thinkingTime:u,nextPhase:I});case S.ANSWERING:return t.jsx(Ye,{state:$,answeringTime:p,nextPhase:I,sttError:q});case S.TRANSCRIBING:return t.jsx(et,{sttError:q});case S.EDITING:case S.SUBMITTING:return t.jsx("div",{className:"iw-space-y-4 iw-h-full",children:t.jsx(Qe,{value:h,onChange:_=>g(_.target.value),onSubmit:()=>I(),isSubmitDisabled:!h.trim()||ne,state:$,editingTime:M})});case S.COMPLETED:return t.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-white",children:t.jsx(Je,{open:!0,onClose:e||(()=>{})})});default:return null}};return t.jsxs("div",{className:"interview-widget-container",children:[t.jsx(st,{title:i,onExit:async()=>{y(),(await s.generateQuestion({interviewId:r,isInterviewDone:!0})).success&&H()}}),t.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${n} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,children:[t.jsx("div",{className:"iw-flex iw-items-start iw-justify-between iw-gap-3",children:t.jsx("div",{className:"iw-flex-1",children:t.jsx(it,{question:w,isLoading:$.phase===S.FETCHING_QUESTION||$.phase===S.IDLE})})}),t.jsxs("div",{className:"iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-xl iw-p-4",children:[t.jsx("div",{className:"iw-min-h-[400px] iw-max-h-[600px]",children:t.jsx(qe,{})}),t.jsx("div",{className:"iw-bg-white iw-rounded-lg iw-shadow iw-p-6",children:le()})]})]})]})},se=({title:i,interviewId:r,onInterviewEnd:e,className:n=""})=>{const[s,c]=l.useState(!1),[o,a]=l.useState(!0),d=l.useRef(null);return s?t.jsx("div",{className:"interview-widget-container",children:t.jsx("div",{ref:d,className:`iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${n}`,children:t.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:t.jsx(nt,{interviewTitle:i??"Interview",interviewId:r,className:n,onComplete:e||(()=>{})})})})}):t.jsx("div",{className:"interview-widget-container",children:t.jsx(Ie,{isOpen:o,onStart:()=>{console.log("Permissions granted, starting interview"),c(!0),a(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:se,InterviewWidgetProvider:we}),C.InterviewWidget=se,C.InterviewWidgetProvider=we,C.default=se,Object.defineProperties(C,{__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": "0.1.5",
4
+ "version": "0.1.7",
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",