interview-widget 0.1.6 → 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.
@@ -27,6 +27,7 @@ export interface TimerCallbacks {
27
27
  onPhaseChange?: (phase: TimerPhase, state: TimerState) => void;
28
28
  onTick?: (state: TimerState) => void;
29
29
  onInterviewEnd?: () => void;
30
+ onComplete?: () => void;
30
31
  }
31
32
  export declare class TimerService {
32
33
  private config;
package/dist/widget.es.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var ve = Object.defineProperty;
2
2
  var je = (r, i, e) => i in r ? ve(r, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[i] = e;
3
3
  var D = (r, i, e) => je(r, typeof i != "symbol" ? i + "" : i, e);
4
- import le, { createContext as Ne, useContext as Te, useRef as S, useState as k, useEffect as P, useCallback as A, useMemo as J } from "react";
4
+ import de, { createContext as Ne, useContext as Te, useRef as S, useState as k, useEffect as P, useCallback as A, useMemo as X } from "react";
5
5
  import { createPortal as ke } from "react-dom";
6
- var we = { exports: {} }, X = {};
6
+ var ue = { exports: {} }, Z = {};
7
7
  /**
8
8
  * @license React
9
9
  * react-jsx-runtime.production.js
@@ -14,7 +14,7 @@ var we = { exports: {} }, X = {};
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
16
  var Ie = Symbol.for("react.transitional.element"), Ee = Symbol.for("react.fragment");
17
- function ue(r, i, e) {
17
+ function he(r, i, e) {
18
18
  var a = null;
19
19
  if (e !== void 0 && (a = "" + e), i.key !== void 0 && (a = "" + i.key), "key" in i) {
20
20
  e = {};
@@ -29,12 +29,12 @@ function ue(r, i, e) {
29
29
  props: e
30
30
  };
31
31
  }
32
- X.Fragment = Ee;
33
- X.jsx = ue;
34
- X.jsxs = ue;
35
- we.exports = X;
36
- var t = we.exports;
37
- const L = {
32
+ Z.Fragment = Ee;
33
+ Z.jsx = he;
34
+ Z.jsxs = he;
35
+ ue.exports = Z;
36
+ var t = ue.exports;
37
+ const _ = {
38
38
  api: {
39
39
  baseUrl: "/api",
40
40
  retryConfig: {
@@ -62,7 +62,7 @@ const L = {
62
62
  provider: "piper"
63
63
  }
64
64
  }
65
- }, he = Ne(
65
+ }, me = Ne(
66
66
  null
67
67
  );
68
68
  function Re({
@@ -72,38 +72,38 @@ function Re({
72
72
  var a, s, c, o;
73
73
  const e = {
74
74
  api: {
75
- ...L.api,
75
+ ..._.api,
76
76
  ...r.api,
77
77
  retryConfig: {
78
- ...L.api.retryConfig,
78
+ ..._.api.retryConfig,
79
79
  ...(a = r.api) == null ? void 0 : a.retryConfig
80
80
  }
81
81
  },
82
82
  ui: {
83
- ...L.ui,
83
+ ..._.ui,
84
84
  ...r.ui
85
85
  },
86
86
  interview: {
87
- ...L.interview,
87
+ ..._.interview,
88
88
  ...r.interview,
89
89
  timers: {
90
- ...L.interview.timers,
90
+ ..._.interview.timers,
91
91
  ...(s = r.interview) == null ? void 0 : s.timers
92
92
  },
93
93
  stt: {
94
- ...L.interview.stt,
94
+ ..._.interview.stt,
95
95
  ...(c = r.interview) == null ? void 0 : c.stt
96
96
  },
97
97
  tts: {
98
- ...L.interview.tts,
98
+ ..._.interview.tts,
99
99
  ...(o = r.interview) == null ? void 0 : o.tts
100
100
  }
101
101
  }
102
102
  };
103
- return /* @__PURE__ */ t.jsx(he.Provider, { value: e, children: i });
103
+ return /* @__PURE__ */ t.jsx(me.Provider, { value: e, children: i });
104
104
  }
105
- function Z() {
106
- const r = Te(he);
105
+ function K() {
106
+ const r = Te(me);
107
107
  if (!r)
108
108
  throw new Error(
109
109
  "useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>"
@@ -111,15 +111,15 @@ function Z() {
111
111
  return r;
112
112
  }
113
113
  function Se() {
114
- return Z().api || L.api;
114
+ return K().api || _.api;
115
115
  }
116
- function Y() {
117
- return Z().ui || L.ui;
116
+ function V() {
117
+ return K().ui || _.ui;
118
118
  }
119
119
  function Ce() {
120
- return Z().interview || L.interview;
120
+ return K().interview || _.interview;
121
121
  }
122
- const me = ({
122
+ const ge = ({
123
123
  className: r,
124
124
  ...i
125
125
  }) => /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsxs(
@@ -176,7 +176,7 @@ const me = ({
176
176
  disabled: c || s,
177
177
  ...n,
178
178
  children: [
179
- s && /* @__PURE__ */ t.jsx(me, { height: 16, width: 16, style: { marginRight: "3px" } }),
179
+ s && /* @__PURE__ */ t.jsx(ge, { height: 16, width: 16, style: { marginRight: "3px" } }),
180
180
  r
181
181
  ]
182
182
  }
@@ -196,7 +196,7 @@ function Ae(r, i, e) {
196
196
  return s.length === 1 ? "0" + s : s;
197
197
  }).join("");
198
198
  }
199
- function ge(r, i) {
199
+ function fe(r, i) {
200
200
  const e = Me(r);
201
201
  if (!e) return r;
202
202
  const a = e.r + (255 - e.r) * i, s = e.g + (255 - e.g) * i, c = e.b + (255 - e.b) * i;
@@ -204,15 +204,15 @@ function ge(r, i) {
204
204
  }
205
205
  function De(r, i = 0.8) {
206
206
  return {
207
- background: `linear-gradient(to bottom, ${ge(r, i)}, #ffffff)`,
207
+ background: `linear-gradient(to bottom, ${fe(r, i)}, #ffffff)`,
208
208
  color: "#1f2937"
209
209
  };
210
210
  }
211
211
  function Pe(r) {
212
212
  return new Promise((i) => setTimeout(i, r));
213
213
  }
214
- function fe(r) {
215
- return `linear-gradient(to left, ${ge(r, 0.4)}, ${r})`;
214
+ function xe(r) {
215
+ return `linear-gradient(to left, ${fe(r, 0.4)}, ${r})`;
216
216
  }
217
217
  const $e = (r) => /* @__PURE__ */ t.jsxs(
218
218
  "svg",
@@ -245,7 +245,7 @@ const $e = (r) => /* @__PURE__ */ t.jsxs(
245
245
  onClose: e
246
246
  }) => {
247
247
  var I;
248
- const a = S(null), s = S(null), { baseColor: c, borderRadius: o } = Y(), [n, l] = k(!1), [m, w] = k(null), [h, u] = k(!1), g = () => {
248
+ const a = S(null), s = S(null), { baseColor: c, borderRadius: o } = V(), [n, l] = k(!1), [m, w] = k(null), [h, u] = k(!1), g = () => {
249
249
  s.current && (s.current.getTracks().forEach((d) => d.stop()), s.current = null);
250
250
  }, j = async () => {
251
251
  u(!0), w(null);
@@ -328,7 +328,7 @@ const $e = (r) => /* @__PURE__ */ t.jsxs(
328
328
  disabled: !n,
329
329
  size: "sm",
330
330
  style: {
331
- background: fe(c),
331
+ background: xe(c),
332
332
  borderRadius: o
333
333
  },
334
334
  children: "Start Interview"
@@ -422,8 +422,8 @@ class Ue {
422
422
  * Manually complete the interview
423
423
  */
424
424
  completeInterview() {
425
- var i, e;
426
- this.stopGlobalTimer(), this.stopPhaseTimer(), this.state.phase = "completed", (e = (i = this.callbacks).onInterviewEnd) == null || e.call(i), this.notifyChange();
425
+ var i, e, a, s;
426
+ (e = (i = this.callbacks).onComplete) == null || e.call(i), this.stopGlobalTimer(), this.stopPhaseTimer(), this.state.phase = "completed", (s = (a = this.callbacks).onInterviewEnd) == null || s.call(a), this.notifyChange();
427
427
  }
428
428
  /**
429
429
  * Cleanup
@@ -621,7 +621,7 @@ function Be(r) {
621
621
  originalError: r
622
622
  };
623
623
  }
624
- async function ae(r, i = {}, e = {
624
+ async function oe(r, i = {}, e = {
625
625
  attempts: 3,
626
626
  backoff: "exponential",
627
627
  baseDelay: 1e3,
@@ -697,7 +697,7 @@ class Qe {
697
697
  answer: c,
698
698
  answerDuration: o
699
699
  }) {
700
- const n = await ae(
700
+ const n = await oe(
701
701
  `${this.getBaseUrl()}/questions/next`,
702
702
  {
703
703
  method: "POST",
@@ -719,8 +719,8 @@ class Qe {
719
719
  }
720
720
  }
721
721
  function We() {
722
- const r = Z();
723
- return J(() => {
722
+ const r = K();
723
+ return X(() => {
724
724
  const e = r.api || {};
725
725
  return new Qe(e);
726
726
  }, [r.api]);
@@ -878,7 +878,7 @@ class He {
878
878
  type: e.type || "audio/wav"
879
879
  });
880
880
  n.append("file", l), n.append("model", a || "whisper-large-v3-turbo"), n.append("language", s || "en"), n.append("include_timestamps", String(c || !1)), n.append("temperature", String(o || 0));
881
- const m = await ae(
881
+ const m = await oe(
882
882
  `${this.config.baseUrl}/speech/transcribe`,
883
883
  {
884
884
  method: "POST",
@@ -960,13 +960,13 @@ class He {
960
960
  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);
961
961
  }
962
962
  }
963
- const H = new He(), Ye = (r = {}) => {
963
+ const Y = new He(), Ye = (r = {}) => {
964
964
  const [i, e] = k(!1), [a, s] = k(!1), [c, o] = k(null), [n, l] = k(null), [m, w] = k(null);
965
- r.config && H.updateConfig(r.config);
965
+ r.config && Y.updateConfig(r.config);
966
966
  const h = A(async (y) => {
967
967
  var I;
968
968
  try {
969
- l(null), o(null), w(null), await H.startRecording(y, {
969
+ l(null), o(null), w(null), await Y.startRecording(y, {
970
970
  onStart: () => {
971
971
  var d;
972
972
  e(!0), (d = r.onStart) == null || d.call(r);
@@ -976,9 +976,9 @@ const H = new He(), Ye = (r = {}) => {
976
976
  e(!1), (d = r.onStop) == null || d.call(r);
977
977
  },
978
978
  onError: (d) => {
979
- var M;
979
+ var C;
980
980
  const x = d instanceof v ? d : new v(d.message, "RECORDING_ERROR", !0);
981
- l(x), e(!1), (M = r.onError) == null || M.call(r, x);
981
+ l(x), e(!1), (C = r.onError) == null || C.call(r, x);
982
982
  }
983
983
  });
984
984
  } catch (d) {
@@ -992,7 +992,7 @@ const H = new He(), Ye = (r = {}) => {
992
992
  }, []), u = A(async () => {
993
993
  var y, I;
994
994
  try {
995
- const d = await H.stopRecording();
995
+ const d = await Y.stopRecording();
996
996
  return w(d), e(!1), (y = r.onStop) == null || y.call(r), d;
997
997
  } catch (d) {
998
998
  const x = d instanceof v ? d : new v(
@@ -1007,14 +1007,14 @@ const H = new He(), Ye = (r = {}) => {
1007
1007
  var d, x;
1008
1008
  try {
1009
1009
  l(null), s(!0);
1010
- const M = {
1010
+ const C = {
1011
1011
  audioBlob: y,
1012
1012
  ...I
1013
- }, p = await H.transcribe(M);
1013
+ }, p = await Y.transcribe(C);
1014
1014
  return o(p.transcript), s(!1), (d = r.onTranscriptionComplete) == null || d.call(r, p), p;
1015
- } catch (M) {
1016
- const p = M instanceof v ? M : new v(
1017
- M instanceof Error ? M.message : String(M),
1015
+ } catch (C) {
1016
+ const p = C instanceof v ? C : new v(
1017
+ C instanceof Error ? C.message : String(C),
1018
1018
  "TRANSCRIPTION_FAILED",
1019
1019
  !0
1020
1020
  );
@@ -1023,7 +1023,7 @@ const H = new He(), Ye = (r = {}) => {
1023
1023
  },
1024
1024
  []
1025
1025
  ), j = A(() => {
1026
- H.cancelRecording(), e(!1), w(null);
1026
+ Y.cancelRecording(), e(!1), w(null);
1027
1027
  }, []);
1028
1028
  return {
1029
1029
  startRecording: h,
@@ -1065,7 +1065,7 @@ class Ve {
1065
1065
  speed: s = this.config.speed
1066
1066
  } = i, c = new URLSearchParams();
1067
1067
  c.append("text", e), c.append("voice", a || "string"), c.append("speed", (s == null ? void 0 : s.toString()) || "1");
1068
- const o = await ae(
1068
+ const o = await oe(
1069
1069
  `${this.config.baseUrl}/speech/synthesize`,
1070
1070
  {
1071
1071
  method: "POST",
@@ -1148,9 +1148,9 @@ class Ve {
1148
1148
  return this.currentAudio !== null && !this.currentAudio.paused;
1149
1149
  }
1150
1150
  }
1151
- const se = new Ve(), Je = (r = {}) => {
1151
+ const ae = new Ve(), Je = (r = {}) => {
1152
1152
  const [i, e] = k(!1), [a, s] = k(!1), [c, o] = k(null);
1153
- r.config && se.updateConfig(r.config);
1153
+ r.config && ae.updateConfig(r.config);
1154
1154
  const n = A(
1155
1155
  async (m, w = {}) => {
1156
1156
  var h;
@@ -1160,7 +1160,7 @@ const se = new Ve(), Je = (r = {}) => {
1160
1160
  text: m,
1161
1161
  ...w
1162
1162
  };
1163
- await se.speak(u, {
1163
+ await ae.speak(u, {
1164
1164
  onStart: () => {
1165
1165
  var g;
1166
1166
  s(!1), e(!0), (g = r.onStart) == null || g.call(r);
@@ -1181,7 +1181,7 @@ const se = new Ve(), Je = (r = {}) => {
1181
1181
  },
1182
1182
  [r]
1183
1183
  ), l = A(() => {
1184
- se.stop(), e(!1), s(!1);
1184
+ ae.stop(), e(!1), s(!1);
1185
1185
  }, []);
1186
1186
  return {
1187
1187
  speak: n,
@@ -1219,20 +1219,20 @@ const se = new Ve(), Je = (r = {}) => {
1219
1219
  }
1220
1220
  }
1221
1221
  ) });
1222
- }, K = (r) => {
1223
- const { baseColor: i, borderRadius: e } = Y(), { loading: a, children: s, ...c } = r;
1222
+ }, ee = (r) => {
1223
+ const { baseColor: i, borderRadius: e } = V(), { loading: a, children: s, ...c } = r;
1224
1224
  return /* @__PURE__ */ t.jsx(
1225
1225
  ne,
1226
1226
  {
1227
1227
  style: {
1228
- background: fe(i),
1228
+ background: xe(i),
1229
1229
  borderRadius: e
1230
1230
  },
1231
1231
  ...c,
1232
- children: a ? /* @__PURE__ */ t.jsx(me, {}) : s
1232
+ children: a ? /* @__PURE__ */ t.jsx(ge, {}) : s
1233
1233
  }
1234
1234
  );
1235
- }, oe = (r) => /* @__PURE__ */ t.jsxs(
1235
+ }, ce = (r) => /* @__PURE__ */ t.jsxs(
1236
1236
  "svg",
1237
1237
  {
1238
1238
  xmlns: "http://www.w3.org/2000/svg",
@@ -1254,10 +1254,10 @@ const se = new Ve(), Je = (r = {}) => {
1254
1254
  /* @__PURE__ */ t.jsx("path", { d: "M8.644 21.42a10 10 0 0 0 7.631-.38" })
1255
1255
  ]
1256
1256
  }
1257
- ), Ze = (r, i, e) => Math.max(i, Math.min(e, r)), de = (r) => {
1257
+ ), Ze = (r, i, e) => Math.max(i, Math.min(e, r)), we = (r) => {
1258
1258
  const i = Math.max(0, Math.floor(r)), e = Math.floor(i / 60).toString().padStart(2, "0"), a = (i % 60).toString().padStart(2, "0");
1259
1259
  return `${e}:${a}`;
1260
- }, ce = ({
1260
+ }, le = ({
1261
1261
  total: r,
1262
1262
  remaining: i,
1263
1263
  size: e = 64,
@@ -1265,16 +1265,16 @@ const se = new Ve(), Je = (r = {}) => {
1265
1265
  className: s = "",
1266
1266
  showLabel: c = !0
1267
1267
  }) => {
1268
- const o = Math.max(1, r || 1), n = Ze(i / o, 0, 1), { radius: l, circumference: m, dashOffset: w, center: h } = J(() => {
1268
+ const o = Math.max(1, r || 1), n = Ze(i / o, 0, 1), { radius: l, circumference: m, dashOffset: w, center: h } = X(() => {
1269
1269
  const j = (e - a) / 2, y = 2 * Math.PI * j, I = y * (1 - n), d = Math.round(a) % 2 === 1, x = e / 2 + (d ? 0.5 : 0);
1270
1270
  return { radius: j, circumference: y, dashOffset: I, center: x };
1271
- }, [e, a, n]), u = J(() => n <= 0.25 ? "iw-stroke-red-500" : n <= 0.5 ? "iw-stroke-yellow-500" : "iw-stroke-green-500", [n]), g = n <= 0.25 ? "iw-animate-pulse" : "";
1271
+ }, [e, a, n]), u = X(() => n <= 0.25 ? "iw-stroke-red-500" : n <= 0.5 ? "iw-stroke-yellow-500" : "iw-stroke-green-500", [n]), g = n <= 0.25 ? "iw-animate-pulse" : "";
1272
1272
  return /* @__PURE__ */ t.jsxs(
1273
1273
  "div",
1274
1274
  {
1275
1275
  className: `iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${s}`,
1276
1276
  style: { width: e, height: e },
1277
- "aria-label": `Time remaining ${de(i)}`,
1277
+ "aria-label": `Time remaining ${we(i)}`,
1278
1278
  role: "timer",
1279
1279
  "aria-live": "polite",
1280
1280
  children: [
@@ -1325,7 +1325,7 @@ const se = new Ve(), Je = (r = {}) => {
1325
1325
  "span",
1326
1326
  {
1327
1327
  className: `iw-text-[11px] iw-font-semibold iw-tabular-nums ${n <= 0.25 ? "iw-text-red-600" : n <= 0.5 ? "iw-text-yellow-600" : "iw-text-green-600"}`,
1328
- children: de(i)
1328
+ children: we(i)
1329
1329
  }
1330
1330
  ) })
1331
1331
  ]
@@ -1382,11 +1382,11 @@ const se = new Ve(), Je = (r = {}) => {
1382
1382
  /* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Your Answer" }),
1383
1383
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
1384
1384
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
1385
- /* @__PURE__ */ t.jsx(oe, { className: "iw-size-4 iw-text-orange-600" }),
1385
+ /* @__PURE__ */ t.jsx(ce, { className: "iw-size-4 iw-text-orange-600" }),
1386
1386
  /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to edit: " })
1387
1387
  ] }),
1388
1388
  /* @__PURE__ */ t.jsx(
1389
- ce,
1389
+ le,
1390
1390
  {
1391
1391
  total: c,
1392
1392
  remaining: s.currentPhaseTimeRemaining,
@@ -1412,7 +1412,7 @@ const se = new Ve(), Je = (r = {}) => {
1412
1412
  onDragOver: (n) => n.preventDefault()
1413
1413
  }
1414
1414
  ),
1415
- /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1 iw-mt-4", children: /* @__PURE__ */ t.jsx(K, { onClick: e, disabled: a, children: "Submit Answer" }) })
1415
+ /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1 iw-mt-4", children: /* @__PURE__ */ t.jsx(ee, { onClick: e, disabled: a, children: "Submit Answer" }) })
1416
1416
  ] })
1417
1417
  ] });
1418
1418
  }, tt = ({
@@ -1426,14 +1426,14 @@ const se = new Ve(), Je = (r = {}) => {
1426
1426
  mediaStream: n,
1427
1427
  startOnMount: l = !0
1428
1428
  }) => {
1429
- const { baseColor: m } = Y(), w = S(null), h = S(null), u = S(null), g = S(null), j = S(null), y = S(null), I = S(!1), [d, x] = k(null);
1429
+ const { baseColor: m } = V(), w = S(null), h = S(null), u = S(null), g = S(null), j = S(null), y = S(null), I = S(!1), [d, x] = k(null);
1430
1430
  P(() => {
1431
1431
  if (i || !h.current) return;
1432
1432
  const p = h.current, $ = () => {
1433
- const N = w.current;
1434
- if (!N) return;
1435
- const T = p.clientWidth, C = e;
1436
- N.width = Math.max(1, Math.floor(T * window.devicePixelRatio || 1)), N.height = Math.max(1, Math.floor(C * window.devicePixelRatio || 1));
1433
+ const M = w.current;
1434
+ if (!M) return;
1435
+ const N = p.clientWidth, T = e;
1436
+ M.width = Math.max(1, Math.floor(N * window.devicePixelRatio || 1)), M.height = Math.max(1, Math.floor(T * window.devicePixelRatio || 1));
1437
1437
  }, b = new ResizeObserver($);
1438
1438
  return b.observe(p), $(), () => b.disconnect();
1439
1439
  }, [i, e]), P(() => {
@@ -1452,49 +1452,49 @@ const se = new Ve(), Je = (r = {}) => {
1452
1452
  try {
1453
1453
  const b = new (window.AudioContext || window.webkitAudioContext)();
1454
1454
  u.current = b;
1455
- let N = n;
1456
- if (!N) {
1455
+ let M = n;
1456
+ if (!M) {
1457
1457
  if (!l) return;
1458
- N = await navigator.mediaDevices.getUserMedia({
1458
+ M = await navigator.mediaDevices.getUserMedia({
1459
1459
  audio: !0,
1460
1460
  video: !1
1461
1461
  }), I.current = !0;
1462
1462
  }
1463
1463
  if (p) return;
1464
- const T = b.createAnalyser();
1465
- T.fftSize = c, T.smoothingTimeConstant = o, g.current = T;
1466
- const C = b.createMediaStreamSource(N);
1467
- j.current = C, C.connect(T), M();
1464
+ const N = b.createAnalyser();
1465
+ N.fftSize = c, N.smoothingTimeConstant = o, g.current = N;
1466
+ const T = b.createMediaStreamSource(M);
1467
+ j.current = T, T.connect(N), C();
1468
1468
  } catch (b) {
1469
1469
  x((b == null ? void 0 : b.message) || "Failed to initialize microphone");
1470
1470
  }
1471
1471
  })(), () => {
1472
- var b, N, T, C;
1472
+ var b, M, N, T;
1473
1473
  p = !0, y.current && cancelAnimationFrame(y.current);
1474
1474
  try {
1475
1475
  (b = j.current) == null || b.disconnect();
1476
1476
  } catch {
1477
1477
  }
1478
1478
  try {
1479
- (N = g.current) == null || N.disconnect();
1479
+ (M = g.current) == null || M.disconnect();
1480
1480
  } catch {
1481
1481
  }
1482
- I.current && ((C = ((T = j.current) == null ? void 0 : T.mediaStream) || void 0) == null || C.getTracks().forEach((q) => q.stop())), u.current && u.current.state !== "closed" && u.current.close();
1482
+ I.current && ((T = ((N = j.current) == null ? void 0 : N.mediaStream) || void 0) == null || T.getTracks().forEach((q) => q.stop())), u.current && u.current.state !== "closed" && u.current.close();
1483
1483
  };
1484
1484
  }, [n, c, o, l]);
1485
- const M = () => {
1485
+ const C = () => {
1486
1486
  const p = w.current, $ = g.current;
1487
1487
  if (!p || !$) return;
1488
1488
  const b = p.getContext("2d");
1489
1489
  if (!b) return;
1490
- const N = window.devicePixelRatio || 1, T = p.width, C = p.height, q = $.frequencyBinCount, F = new Uint8Array(q), Q = () => {
1491
- y.current = requestAnimationFrame(Q), $.getByteTimeDomainData(F), b.clearRect(0, 0, T, C), b.fillStyle = "rgba(0,0,0,0)", b.fillRect(0, 0, T, C);
1492
- const _ = Math.max(1, Math.floor(a * N)), U = Math.max(1, Math.floor(s * N)), E = _ + U, B = Math.max(8, Math.floor((T + U) / E)), ee = Math.floor(F.length / B);
1493
- for (let z = 0; z < B; z++) {
1494
- const te = Math.min(F.length - 1, z * ee), re = F[te] / 128 - 1, G = Math.abs(re), ie = Math.pow(G, 0.6), W = Math.max(C * 0.06, ie * (C * 0.9)), f = z * E, O = (C - W) / 2, V = 140 - Math.min(140, 140 * G), pe = 85, be = 48 + Math.floor(12 * (1 - G));
1495
- b.fillStyle = `${m}`, b.shadowColor = `hsla(${V}, ${pe}%, ${be}%, ${0.25 * G})`, b.shadowBlur = 8 * G;
1496
- const ye = Math.min(_ / 2, W / 2);
1497
- rt(b, f, O, _, W, ye), b.fill();
1490
+ const M = window.devicePixelRatio || 1, N = p.width, T = p.height, q = $.frequencyBinCount, F = new Uint8Array(q), Q = () => {
1491
+ y.current = requestAnimationFrame(Q), $.getByteTimeDomainData(F), b.clearRect(0, 0, N, T), b.fillStyle = "rgba(0,0,0,0)", b.fillRect(0, 0, N, T);
1492
+ const B = Math.max(1, Math.floor(a * M)), L = Math.max(1, Math.floor(s * M)), U = B + L, E = Math.max(8, Math.floor((N + L) / U)), W = Math.floor(F.length / E);
1493
+ for (let z = 0; z < E; z++) {
1494
+ const te = Math.min(F.length - 1, z * W), re = F[te] / 128 - 1, G = Math.abs(re), ie = Math.pow(G, 0.6), H = Math.max(T * 0.06, ie * (T * 0.9)), se = z * U, f = (T - H) / 2, O = 140 - Math.min(140, 140 * G), J = 85, be = 48 + Math.floor(12 * (1 - G));
1495
+ b.fillStyle = `${m}`, b.shadowColor = `hsla(${O}, ${J}%, ${be}%, ${0.25 * G})`, b.shadowBlur = 8 * G;
1496
+ const ye = Math.min(B / 2, H / 2);
1497
+ rt(b, se, f, B, H, ye), b.fill();
1498
1498
  }
1499
1499
  };
1500
1500
  Q();
@@ -1527,11 +1527,11 @@ const it = ({
1527
1527
  /* @__PURE__ */ 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...." }),
1528
1528
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
1529
1529
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
1530
- /* @__PURE__ */ t.jsx(oe, { className: "iw-size-4 iw-text-orange-600" }),
1530
+ /* @__PURE__ */ t.jsx(ce, { className: "iw-size-4 iw-text-orange-600" }),
1531
1531
  /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to talk: " })
1532
1532
  ] }),
1533
1533
  /* @__PURE__ */ t.jsx(
1534
- ce,
1534
+ le,
1535
1535
  {
1536
1536
  total: i,
1537
1537
  remaining: r.currentPhaseTimeRemaining,
@@ -1551,7 +1551,7 @@ const it = ({
1551
1551
  ] })
1552
1552
  ] }),
1553
1553
  /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1", children: /* @__PURE__ */ t.jsx(
1554
- K,
1554
+ ee,
1555
1555
  {
1556
1556
  onClick: () => {
1557
1557
  e();
@@ -1561,7 +1561,7 @@ const it = ({
1561
1561
  ) })
1562
1562
  ] });
1563
1563
  function st() {
1564
- const [r, i] = k(!0), e = J(
1564
+ const [r, i] = k(!0), e = X(
1565
1565
  () => [0, 1, 2].map((a) => ({ id: a })),
1566
1566
  []
1567
1567
  );
@@ -1598,7 +1598,7 @@ function st() {
1598
1598
  /* @__PURE__ */ t.jsx("div", { className: "iw-text-center", children: /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-500 iw-font-medium", children: "Preparing your question..." }) })
1599
1599
  ] });
1600
1600
  }
1601
- const xe = ({
1601
+ const pe = ({
1602
1602
  isOpen: r,
1603
1603
  onClose: i,
1604
1604
  children: e,
@@ -1677,11 +1677,11 @@ const xe = ({
1677
1677
  )
1678
1678
  ] });
1679
1679
  return ke(m, document.body);
1680
- }, nt = ({
1680
+ }, at = ({
1681
1681
  open: r,
1682
1682
  onClose: i
1683
1683
  }) => /* @__PURE__ */ t.jsx(
1684
- xe,
1684
+ pe,
1685
1685
  {
1686
1686
  isOpen: r,
1687
1687
  onClose: i || (() => {
@@ -1710,7 +1710,7 @@ const xe = ({
1710
1710
  /* @__PURE__ */ 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." })
1711
1711
  ] })
1712
1712
  }
1713
- ), at = ({
1713
+ ), nt = ({
1714
1714
  size: r = "192px",
1715
1715
  className: i,
1716
1716
  colors: e,
@@ -1854,7 +1854,7 @@ const xe = ({
1854
1854
  };
1855
1855
  function ot({ ttsError: r }) {
1856
1856
  return /* @__PURE__ */ 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: [
1857
- /* @__PURE__ */ t.jsx(at, { size: "80px" }),
1857
+ /* @__PURE__ */ t.jsx(nt, { size: "80px" }),
1858
1858
  r && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1859
1859
  "Audio playback failed: ",
1860
1860
  r.message
@@ -1869,11 +1869,11 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
1869
1869
  ] }),
1870
1870
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
1871
1871
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
1872
- /* @__PURE__ */ t.jsx(oe, { className: "iw-size-4 iw-text-orange-600" }),
1872
+ /* @__PURE__ */ t.jsx(ce, { className: "iw-size-4 iw-text-orange-600" }),
1873
1873
  /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to think: " })
1874
1874
  ] }),
1875
1875
  /* @__PURE__ */ t.jsx(
1876
- ce,
1876
+ le,
1877
1877
  {
1878
1878
  total: i,
1879
1879
  remaining: r.currentPhaseTimeRemaining,
@@ -1883,7 +1883,7 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
1883
1883
  )
1884
1884
  ] }),
1885
1885
  /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1", children: /* @__PURE__ */ t.jsx(
1886
- K,
1886
+ ee,
1887
1887
  {
1888
1888
  onClick: () => {
1889
1889
  e();
@@ -1958,7 +1958,7 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
1958
1958
  question: r,
1959
1959
  isLoading: i = !1
1960
1960
  }) => {
1961
- const { baseColor: e } = Y();
1961
+ const { baseColor: e } = V();
1962
1962
  return /* @__PURE__ */ t.jsx(
1963
1963
  "div",
1964
1964
  {
@@ -1986,7 +1986,7 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
1986
1986
  confirmExitInterview: r,
1987
1987
  isOpen: i,
1988
1988
  onClose: e
1989
- }) => /* @__PURE__ */ t.jsx(xe, { isOpen: i, onClose: e, title: "Exit Interview", children: /* @__PURE__ */ t.jsxs("div", { className: "iw-space-y-4", children: [
1989
+ }) => /* @__PURE__ */ t.jsx(pe, { isOpen: i, onClose: e, title: "Exit Interview", children: /* @__PURE__ */ t.jsxs("div", { className: "iw-space-y-4", children: [
1990
1990
  /* @__PURE__ */ 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." }),
1991
1991
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-justify-end iw-space-x-2", children: [
1992
1992
  /* @__PURE__ */ t.jsx(
@@ -2007,7 +2007,7 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2007
2007
  )
2008
2008
  ] })
2009
2009
  ] }) }), ht = ({ title: r, onExit: i }) => {
2010
- const { baseColor: e } = Y(), [a, s] = k(!1);
2010
+ const { baseColor: e } = V(), [a, s] = k(!1);
2011
2011
  return /* @__PURE__ */ t.jsxs("header", { className: "iw-w-full iw-text-gray-900", children: [
2012
2012
  /* @__PURE__ */ t.jsxs("div", { className: "iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-py-3", children: [
2013
2013
  /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
@@ -2053,11 +2053,15 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2053
2053
  thinkingTime: (n == null ? void 0 : n.thinkingDuration) || 30,
2054
2054
  answeringTime: (n == null ? void 0 : n.answeringDuration) || 120,
2055
2055
  editingTime: (n == null ? void 0 : n.editingDuration) || 30
2056
- }, { thinkingTime: d, answeringTime: x, editingTime: M } = I;
2056
+ }, { thinkingTime: d, answeringTime: x, editingTime: C } = I;
2057
2057
  P(() => {
2058
2058
  j.current = u;
2059
2059
  }, [u]);
2060
- const p = S(!1), { speak: $, error: b } = Je({
2060
+ const p = S(!1), {
2061
+ speak: $,
2062
+ stop: b,
2063
+ error: M
2064
+ } = Je({
2061
2065
  config: {
2062
2066
  baseUrl: c,
2063
2067
  provider: m == null ? void 0 : m.provider,
@@ -2070,10 +2074,10 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2070
2074
  p.current || (p.current = !0, E());
2071
2075
  }
2072
2076
  }), N = S(!1), T = S(!1), {
2073
- startRecording: C,
2074
- stopRecording: q,
2075
- transcribe: F,
2076
- error: Q
2077
+ startRecording: q,
2078
+ stopRecording: F,
2079
+ transcribe: Q,
2080
+ error: B
2077
2081
  } = Ye({
2078
2082
  config: {
2079
2083
  baseUrl: c,
@@ -2093,29 +2097,29 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2093
2097
  onError: (f) => {
2094
2098
  console.error("STT Error:", f), N.current || (N.current = !0, E());
2095
2099
  }
2096
- }), { state: _, startQuestion: U, nextPhase: E, completeInterview: B } = Ge({
2100
+ }), { state: L, startQuestion: U, nextPhase: E, completeInterview: W } = Ge({
2097
2101
  config: {
2098
2102
  thinkingDuration: d,
2099
2103
  answeringDuration: x,
2100
- editingDuration: M
2104
+ editingDuration: C
2101
2105
  },
2102
2106
  callbacks: {
2103
2107
  onPhaseChange: (f) => {
2104
2108
  switch (f) {
2105
2109
  case R.FETCHING_QUESTION:
2106
- ee();
2110
+ z();
2107
2111
  break;
2108
2112
  case R.READING_QUESTION:
2109
- re();
2113
+ G();
2110
2114
  break;
2111
2115
  case R.ANSWERING:
2112
- G();
2116
+ ie();
2113
2117
  break;
2114
2118
  case R.TRANSCRIBING:
2115
- ie();
2119
+ H();
2116
2120
  break;
2117
2121
  case R.SUBMITTING:
2118
- te();
2122
+ re();
2119
2123
  break;
2120
2124
  }
2121
2125
  },
@@ -2127,13 +2131,13 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2127
2131
  P(() => {
2128
2132
  U();
2129
2133
  }, []);
2130
- const { execute: ee, loading: z } = qe(
2134
+ const { execute: z, loading: te } = qe(
2131
2135
  async () => {
2132
- var O, V;
2136
+ var O, J;
2133
2137
  const f = await s.generateQuestion({
2134
2138
  interviewId: i,
2135
2139
  question: ((O = y.current) == null ? void 0 : O.question) || "",
2136
- qnaId: ((V = y.current) == null ? void 0 : V.qna_id) || "",
2140
+ qnaId: ((J = y.current) == null ? void 0 : J.qna_id) || "",
2137
2141
  answer: j.current
2138
2142
  });
2139
2143
  return y.current = f.data, f;
@@ -2146,49 +2150,49 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2146
2150
  console.error("Failed to fetch questions:", f);
2147
2151
  }
2148
2152
  }
2149
- ), te = A(async () => {
2153
+ ), re = A(async () => {
2150
2154
  U();
2151
- }, [U]), re = A(async () => {
2155
+ }, [U]), G = A(async () => {
2152
2156
  var f;
2153
2157
  if ((f = y.current) != null && f.question)
2154
2158
  try {
2155
- p.current = !1, await $(y.current.question), y.current.is_interview_done && (await Pe(2e3), B());
2159
+ p.current = !1, await $(y.current.question), y.current.is_interview_done && (await Pe(2e3), W());
2156
2160
  } catch (O) {
2157
2161
  console.error("Failed to speak question:", O);
2158
2162
  }
2159
2163
  else
2160
2164
  E();
2161
- }, [$, E, B]), G = A(async () => {
2165
+ }, [$, E, W]), ie = A(async () => {
2162
2166
  try {
2163
- await C(x);
2167
+ await q(x);
2164
2168
  } catch (f) {
2165
2169
  console.error("Failed to start recording:", f), E();
2166
2170
  }
2167
- }, [C, E]), ie = A(async () => {
2171
+ }, [q, E]), H = A(async () => {
2168
2172
  try {
2169
- const f = await q();
2170
- await F(f);
2173
+ const f = await F();
2174
+ await Q(f);
2171
2175
  } catch (f) {
2172
2176
  console.error("STT processing failed:", f), !N.current && !T.current && (N.current = !0, E());
2173
2177
  }
2174
- }, [q, F, E]), W = () => {
2175
- const { phase: f } = _;
2178
+ }, [F, Q, E]), se = () => {
2179
+ const { phase: f } = L;
2176
2180
  switch (f) {
2177
2181
  case R.IDLE:
2178
2182
  return /* @__PURE__ */ 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: [
2179
2183
  /* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Ready to start the Interview?" }),
2180
2184
  /* @__PURE__ */ 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.` }),
2181
- /* @__PURE__ */ t.jsx(K, { onClick: U, className: "iw-mt-2 iw-w-40", children: "Start Interview" })
2185
+ /* @__PURE__ */ t.jsx(ee, { onClick: U, className: "iw-mt-2 iw-w-40", children: "Start Interview" })
2182
2186
  ] });
2183
2187
  case R.FETCHING_QUESTION:
2184
2188
  return /* @__PURE__ */ t.jsx(st, {});
2185
2189
  case R.READING_QUESTION:
2186
- return /* @__PURE__ */ t.jsx(ot, { ttsError: b });
2190
+ return /* @__PURE__ */ t.jsx(ot, { ttsError: M });
2187
2191
  case R.THINKING:
2188
2192
  return /* @__PURE__ */ t.jsx(
2189
2193
  ct,
2190
2194
  {
2191
- state: _,
2195
+ state: L,
2192
2196
  thinkingTime: d,
2193
2197
  nextPhase: E
2194
2198
  }
@@ -2197,14 +2201,14 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2197
2201
  return /* @__PURE__ */ t.jsx(
2198
2202
  it,
2199
2203
  {
2200
- state: _,
2204
+ state: L,
2201
2205
  answeringTime: x,
2202
2206
  nextPhase: E,
2203
- sttError: Q
2207
+ sttError: B
2204
2208
  }
2205
2209
  );
2206
2210
  case R.TRANSCRIBING:
2207
- return /* @__PURE__ */ t.jsx(lt, { sttError: Q });
2211
+ return /* @__PURE__ */ t.jsx(lt, { sttError: B });
2208
2212
  case R.EDITING:
2209
2213
  case R.SUBMITTING:
2210
2214
  return /* @__PURE__ */ t.jsx("div", { className: "iw-space-y-4 iw-h-full", children: /* @__PURE__ */ t.jsx(
@@ -2213,14 +2217,14 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2213
2217
  value: u,
2214
2218
  onChange: (O) => g(O.target.value),
2215
2219
  onSubmit: () => E(),
2216
- isSubmitDisabled: !u.trim() || z,
2217
- state: _,
2218
- editingTime: M
2220
+ isSubmitDisabled: !u.trim() || te,
2221
+ state: L,
2222
+ editingTime: C
2219
2223
  }
2220
2224
  ) });
2221
2225
  case R.COMPLETED:
2222
2226
  return /* @__PURE__ */ t.jsx("div", { className: "iw-fixed iw-inset-0 iw-bg-white", children: /* @__PURE__ */ t.jsx(
2223
- nt,
2227
+ at,
2224
2228
  {
2225
2229
  open: !0,
2226
2230
  onClose: e || (() => {
@@ -2237,10 +2241,10 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2237
2241
  {
2238
2242
  title: r,
2239
2243
  onExit: async () => {
2240
- (await s.generateQuestion({
2244
+ b(), (await s.generateQuestion({
2241
2245
  interviewId: i,
2242
2246
  isInterviewDone: !0
2243
- })).success && B();
2247
+ })).success && W();
2244
2248
  }
2245
2249
  }
2246
2250
  ),
@@ -2253,12 +2257,12 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2253
2257
  wt,
2254
2258
  {
2255
2259
  question: w,
2256
- isLoading: _.phase === R.FETCHING_QUESTION || _.phase === R.IDLE
2260
+ isLoading: L.phase === R.FETCHING_QUESTION || L.phase === R.IDLE
2257
2261
  }
2258
2262
  ) }) }),
2259
2263
  /* @__PURE__ */ t.jsxs("div", { className: "iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-xl iw-p-4", children: [
2260
2264
  /* @__PURE__ */ t.jsx("div", { className: "iw-min-h-[400px] iw-max-h-[600px]", children: /* @__PURE__ */ t.jsx(Xe, {}) }),
2261
- /* @__PURE__ */ t.jsx("div", { className: "iw-bg-white iw-rounded-lg iw-shadow iw-p-6", children: W() })
2265
+ /* @__PURE__ */ t.jsx("div", { className: "iw-bg-white iw-rounded-lg iw-shadow iw-p-6", children: se() })
2262
2266
  ] })
2263
2267
  ]
2264
2268
  }
@@ -2270,7 +2274,7 @@ const ct = ({ state: r, thinkingTime: i, nextPhase: e }) => /* @__PURE__ */ t.js
2270
2274
  onInterviewEnd: e,
2271
2275
  className: a = ""
2272
2276
  }) => {
2273
- const [s, c] = le.useState(!1), [o, n] = le.useState(!0), l = S(null);
2277
+ const [s, c] = de.useState(!1), [o, n] = de.useState(!0), l = S(null);
2274
2278
  return s ? /* @__PURE__ */ t.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ t.jsx(
2275
2279
  "div",
2276
2280
  {
@@ -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 le={exports:{}},Y={};/**
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 xe=Symbol.for("react.transitional.element"),pe=Symbol.for("react.fragment");function ce(i,r,e){var a=null;if(e!==void 0&&(a=""+e),r.key!==void 0&&(a=""+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:xe,type:i,key:a,ref:r!==void 0?r:null,props:e}}Y.Fragment=pe,Y.jsx=ce,Y.jsxs=ce,le.exports=Y;var t=le.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"}}},de=l.createContext(null);function ue({config:i={},children:r}){var a,s,c,o;const e={api:{...D.api,...i.api,retryConfig:{...D.api.retryConfig,...(a=i.api)==null?void 0:a.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(de.Provider,{value:e,children:r})}function V(){const i=l.useContext(de);if(!i)throw new Error("useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>");return i}function be(){return V().api||D.api}function z(){return V().ui||D.ui}function ye(){return V().interview||D.interview}const we=({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"})]})}),Z=({children:i,variant:r="primary",size:e="md",fullWidth:a=!1,isLoading:s=!1,disabled:c,className:o="",...n})=>{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=a?"iw-w-full":"";return t.jsxs("button",{className:`${d} ${f[r]} ${w[e]} ${h} ${m} ${o}`,disabled:c||s,...n,children:[s&&t.jsx(we,{height:16,width:16,style:{marginRight:"3px"}}),i]})};function ve(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 je(i,r,e){return"#"+[i,r,e].map(a=>{const s=Math.round(a).toString(16);return s.length===1?"0"+s:s}).join("")}function he(i,r){const e=ve(i);if(!e)return i;const a=e.r+(255-e.r)*r,s=e.g+(255-e.g)*r,c=e.b+(255-e.b)*r;return je(a,s,c)}function Te(i,r=.8){return{background:`linear-gradient(to bottom, ${he(i,r)}, #ffffff)`,color:"#1f2937"}}function Ne(i){return new Promise(r=>setTimeout(r,i))}function me(i){return`linear-gradient(to left, ${he(i,.4)}, ${i})`}const ke=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"})]}),Se=["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"],Ee=({isOpen:i,onStart:r,onClose:e})=>{var E;const a=l.useRef(null),s=l.useRef(null),{baseColor:c,borderRadius:o}=z(),[n,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,a.current&&(a.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:a,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(Z,{onClick:T,disabled:m,variant:"outline",size:"sm",style:{borderColor:c,borderRadius:o,color:c},children:n?"Recheck Permissions":"Enable Camera & Mic"}),t.jsx(Z,{onClick:v,disabled:!n,size:"sm",style:{background:me(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(ke,{}),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:Se.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 Ie={thinkingDuration:30,answeringDuration:120,editingDuration:30},Ce={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 Me{constructor(r={},e={}){A(this,"config");A(this,"state");A(this,"phaseIntervalId",null);A(this,"globalIntervalId",null);A(this,"callbacks");this.config={...Ie,...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=Ce[r];if(!e)return;this.stopPhaseTimer(),this.state.phase=e.next;const a=this.getDurationForPhase(e.next);a>0?(this.state.currentPhaseTimeRemaining=a,this.startPhaseTimer()):this.state.currentPhaseTimeRemaining=0,this.notifyChange()}completeInterview(){var r,e;this.stopGlobalTimer(),this.stopPhaseTimer(),this.state.phase="completed",(e=(r=this.callbacks).onInterviewEnd)==null||e.call(r),this.notifyChange()}destroy(){this.stopPhaseTimer(),this.stopGlobalTimer()}getDurationForPhase(r){switch(r){case"thinking":return this.config.thinkingDuration;case"answering":return this.config.answeringDuration;case"editing":return this.config.editingDuration;default:return 0}}startGlobalTimer(){this.globalIntervalId=setInterval(()=>{var r,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 Re(i={}){const{config:r={},callbacks:e={}}=i,a=l.useRef(null);a.current||(a.current=new Me(r,{}));const s=a.current,[c,o]=l.useState(s.getState()),n=l.useCallback(()=>{o(s.getState())},[s]);l.useEffect(()=>{const m={onPhaseChange:(h,g)=>{var T;n(),(T=e.onPhaseChange)==null||T.call(e,h,g)},onTick:h=>{var g;n(),(g=e.onTick)==null||g.call(e,h)},onInterviewEnd:()=>{var h;n(),(h=e.onInterviewEnd)==null||h.call(e)}};s.callbacks=m},[s,e,n]),l.useEffect(()=>()=>{s.destroy()},[s]);const d=l.useCallback(()=>{s.startQuestion(),n()},[s,n]),f=l.useCallback(()=>{s.nextPhase(),n()},[s,n]),w=l.useCallback(()=>{s.completeInterview(),n()},[s,n]);return{state:c,startQuestion:d,nextPhase:f,completeInterview:w,timerService:s}}function Ae(i,r={}){const[e,a]=l.useState({data:null,loading:!1,error:null}),s=l.useCallback(async(...c)=>{var o,n,d,f;a(w=>({...w,loading:!0,error:null}));try{const w=await i(...c);a(m=>({...m,data:w,loading:!1,error:null})),(o=r.onSuccess)==null||o.call(r,w),(n=r.onSettled)==null||n.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};a(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 De(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 K(i,r={},e={attempts:3,backoff:"exponential",baseDelay:1e3,maxDelay:1e4,jitter:!0}){let a;for(let s=1;s<=e.attempts;s++)try{const c=new AbortController,o=setTimeout(()=>c.abort(),6e4),n=await fetch(i,{...r,signal:c.signal});if(clearTimeout(o),n.status>=400&&n.status<500&&n.status!==429)return n;if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);return n}catch(c){a=c;const o=De(c);if(!o.retryable||s===e.attempts)throw o;const n=Pe(s,e);console.warn(`API request failed (attempt ${s}/${e.attempts}), retrying in ${n}ms:`,o.message),await new Promise(d=>setTimeout(d,n))}throw a}function Pe(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:a,question:s,answer:c,answerDuration:o}){const n=await K(`${this.getBaseUrl()}/questions/next`,{method:"POST",headers:this.getHeaders(),body:JSON.stringify({interview_id:r,is_interview_done:e,qna_id:a,question:s,answer:c,answer_duration:o??"00:00:30"})});if(!n.ok)throw new Error(`Failed to get questions: ${n.status}`);return await n.json()}}function _e(){const i=V();return l.useMemo(()=>{const e=i.api||{};return new $e(e)},[i.api])}class j extends Error{constructor(r,e,a=!1){super(r),this.code=e,this.recoverable=a,this.name="STTError"}}class Oe{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 a;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 n;const o=new j(`Recording failed: ${c.error}`,"RECORDING_ERROR",!0);(n=e==null?void 0:e.onError)==null||n.call(e,o),this.cleanup()},this.mediaRecorder.start(100),(a=e==null?void 0:e.onStart)==null||a.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 a=this.mediaRecorder,s=()=>{try{const c=a.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))}};a.addEventListener("stop",s,{once:!0}),a.stop()})}async transcribe(r){const{audioBlob:e,model:a=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 n=new FormData,d=new File([e],"recording.wav",{type:e.type||"audio/wav"});n.append("file",d),n.append("model",a||"whisper-large-v3-turbo"),n.append("language",s||"en"),n.append("include_timestamps",String(c||!1)),n.append("temperature",String(o||0));const f=await K(`${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:n},{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(n){throw n instanceof j?n:new j(`Transcription failed: ${n instanceof Error?n.message:String(n)}`,"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 Oe,Le=(i={})=>{const[r,e]=l.useState(!1),[a,s]=l.useState(!1),[c,o]=l.useState(null),[n,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 R;const p=u instanceof j?u:new j(u.message,"RECORDING_ERROR",!0);d(p),e(!1),(R=i.onError)==null||R.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 R={audioBlob:v,...E},b=await Q.transcribe(R);return o(b.transcript),s(!1),(u=i.onTranscriptionComplete)==null||u.call(i,b),b}catch(R){const b=R instanceof j?R:new j(R instanceof Error?R.message:String(R),"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:a,transcript:c,error:n,audioBlob:f}};class Fe{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:a=this.config.voice,speed:s=this.config.speed}=r,c=new URLSearchParams;c.append("text",e),c.append("voice",a||"string"),c.append("speed",(s==null?void 0:s.toString())||"1");const o=await K(`${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 n=o.headers.get("content-type");if(n&&n.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 a,s;try{this.stop(),(a=e==null?void 0:e.onStart)==null||a.call(e);const c=await this.synthesizeSpeech(r),o=URL.createObjectURL(c);return this.currentAudio=new Audio(o),new Promise((n,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),n()},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 ee=new Fe,Ue=(i={})=>{const[r,e]=l.useState(!1),[a,s]=l.useState(!1),[c,o]=l.useState(null);i.config&&ee.updateConfig(i.config);const n=l.useCallback(async(f,w={})=>{var m;try{o(null),s(!0);const h={text:f,...w};await ee.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(()=>{ee.stop(),e(!1),s(!1)},[]);return{speak:n,stop:d,isPlaying:r,isLoading:a,error:c}},Ge=({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)"}})})},J=i=>{const{baseColor:r,borderRadius:e}=z(),{loading:a,children:s,...c}=i;return t.jsx(Z,{style:{background:me(r),borderRadius:e},...c,children:a?t.jsx(we,{}):s})},te=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"})]}),qe=(i,r,e)=>Math.max(r,Math.min(e,i)),fe=i=>{const r=Math.max(0,Math.floor(i)),e=Math.floor(r/60).toString().padStart(2,"0"),a=(r%60).toString().padStart(2,"0");return`${e}:${a}`},ie=({total:i,remaining:r,size:e=64,strokeWidth:a=6,className:s="",showLabel:c=!0})=>{const o=Math.max(1,i||1),n=qe(r/o,0,1),{radius:d,circumference:f,dashOffset:w,center:m}=l.useMemo(()=>{const T=(e-a)/2,v=2*Math.PI*T,E=v*(1-n),u=Math.round(a)%2===1,p=e/2+(u?.5:0);return{radius:T,circumference:v,dashOffset:E,center:p}},[e,a,n]),h=l.useMemo(()=>n<=.25?"iw-stroke-red-500":n<=.5?"iw-stroke-yellow-500":"iw-stroke-green-500",[n]),g=n<=.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 ${fe(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:a,fill:"none",shapeRendering:"geometricPrecision",vectorEffect:"non-scaling-stroke"}),t.jsx("circle",{cx:m,cy:m,r:d,className:`${h} ${g}`,strokeWidth:a,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 ${n<=.25?"iw-text-red-600":n<=.5?"iw-text-yellow-600":"iw-text-green-600"}`,children:fe(r)})})]})},Be=({label:i,error:r,fullWidth:e=!1,className:a="",id:s,...c})=>{const o=s||`textarea-${Math.random().toString(36).substring(2,9)}`,n="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=a.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:`${n} ${d} ${f} ${w} ${a}`,"aria-invalid":r?"true":"false",...c}),r&&t.jsx("p",{className:"iw-mt-1 iw-text-sm iw-text-red-600",children:r})]})},ze=({value:i,onChange:r,onSubmit:e,isSubmitDisabled:a,state:s,editingTime:c})=>{const o=n=>{n.key==="Enter"&&(n.ctrlKey||n.metaKey)&&!a&&(n.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(te,{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(ie,{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(Be,{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:n=>n.preventDefault(),onCopy:n=>n.preventDefault(),onCut:n=>n.preventDefault(),onDrop:n=>n.preventDefault(),onDragOver:n=>n.preventDefault()}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1 iw-mt-4",children:t.jsx(J,{onClick:e,disabled:a,children:"Submit Answer"})})]})]})},Qe=({className:i="",width:r,height:e=56,barWidth:a=3,gap:s=2,fftSize:c=1024,smoothingTimeConstant:o=.8,mediaStream:n,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 N=w.current;if(!N)return;const k=b.clientWidth,M=e;N.width=Math.max(1,Math.floor(k*window.devicePixelRatio||1)),N.height=Math.max(1,Math.floor(M*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 N=n;if(!N){if(!d)return;N=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),E.current=!0}if(b)return;const k=y.createAnalyser();k.fftSize=c,k.smoothingTimeConstant=o,g.current=k;const M=y.createMediaStreamSource(N);T.current=M,M.connect(k),R()}catch(y){p((y==null?void 0:y.message)||"Failed to initialize microphone")}})(),()=>{var y,N,k,M;b=!0,v.current&&cancelAnimationFrame(v.current);try{(y=T.current)==null||y.disconnect()}catch{}try{(N=g.current)==null||N.disconnect()}catch{}E.current&&((M=((k=T.current)==null?void 0:k.mediaStream)||void 0)==null||M.getTracks().forEach(G=>G.stop())),h.current&&h.current.state!=="closed"&&h.current.close()}},[n,c,o,d]);const R=()=>{const b=w.current,P=g.current;if(!b||!P)return;const y=b.getContext("2d");if(!y)return;const N=window.devicePixelRatio||1,k=b.width,M=b.height,G=P.frequencyBinCount,O=new Uint8Array(G),W=()=>{v.current=requestAnimationFrame(W),P.getByteTimeDomainData(O),y.clearRect(0,0,k,M),y.fillStyle="rgba(0,0,0,0)",y.fillRect(0,0,k,M);const $=Math.max(1,Math.floor(a*N)),L=Math.max(1,Math.floor(s*N)),I=$+L,q=Math.max(8,Math.floor((k+L)/I)),se=Math.floor(O.length/q);for(let B=0;B<q;B++){const ne=Math.min(O.length-1,B*se),ae=O[ne]/128-1,F=Math.abs(ae),oe=Math.pow(F,.6),H=Math.max(M*.06,oe*(M*.9)),x=B*I,_=(M-H)/2,X=140-Math.min(140,140*F),nt=85,at=48+Math.floor(12*(1-F));y.fillStyle=`${f}`,y.shadowColor=`hsla(${X}, ${nt}%, ${at}%, ${.25*F})`,y.shadowBlur=8*F;const ot=Math.min($/2,H/2);We(y,x,_,$,H,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 We(i,r,e,a,s,c){const o=Math.min(c,a/2,s/2);i.beginPath(),i.moveTo(r+o,e),i.lineTo(r+a-o,e),i.quadraticCurveTo(r+a,e,r+a,e+o),i.lineTo(r+a,e+s-o),i.quadraticCurveTo(r+a,e+s,r+a-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 He=({state:i,answeringTime:r,nextPhase:e,sttError:a})=>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(te,{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(ie,{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(Qe,{}),a&&t.jsxs("div",{className:"iw-mt-2 iw-text-xs iw-text-red-600",children:["Recording error: ",a.message]})]}),t.jsx("div",{className:"iw-w-full iw-grid iw-grid-cols-1",children:t.jsx(J,{onClick:()=>{e()},children:"Transcribe My Answer"})})]});function Ye(){const[i,r]=l.useState(!0),e=l.useMemo(()=>[0,1,2].map(a=>({id:a})),[]);return l.useEffect(()=>{const a=setInterval(()=>{r(s=>!s)},1500);return()=>clearInterval(a)},[]),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((a,s)=>{const c=s*50,o=i?c:c+12,n=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:n,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"})]})]})},a.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 ge=({isOpen:i,onClose:r,children:e,title:a,showCloseButton:s=!0,closeOnOverlayClick:c=!0,closeOnEscape:o=!0,className:n=""})=>{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 ${n}`,role:"dialog","aria-modal":"true","aria-labelledby":a?"dialog-title":void 0,children:[(a||s)&&t.jsxs("div",{className:"iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200",children:[a&&t.jsx("h2",{id:"dialog-title",className:"iw-text-lg iw-font-semibold iw-text-gray-900",children:a}),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)},Ve=({open:i,onClose:r})=>t.jsx(ge,{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."})]})}),Je=({size:i="192px",className:r,colors:e,animationDuration:a=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),n=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":`${a}s`,"--blur-amount":`${n}px`,"--contrast-amount":h,"--dot-size":`${f}px`,"--shadow-spread":`${w}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 Xe({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(Je,{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 Ze=({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(te,{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(ie,{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(J,{onClick:()=>{e()},children:"Start Answering"})})]}),Ke=({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)"]})]}),et=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"})]}),tt=({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:Te(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(et,{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})]})})},it=({confirmExitInterview:i,isOpen:r,onClose:e})=>t.jsx(ge,{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"})]})]})}),rt=({title:i,onExit:r})=>{const{baseColor:e}=z(),[a,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(it,{isOpen:a,confirmExitInterview:()=>{r(),s(!1)},onClose:()=>s(!1)})]})},st=({interviewTitle:i,interviewId:r,onComplete:e,className:a=""})=>{const s=_e(),{baseUrl:c,authToken:o}=be(),{timers:n,stt:d,tts:f}=ye(),[w,m]=l.useState(null),[h,g]=l.useState(""),T=l.useRef(""),v=l.useRef(null),E={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:u,answeringTime:p,editingTime:R}=E;l.useEffect(()=>{T.current=h},[h]);const b=l.useRef(!1),{speak:P,error:y}=Ue({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:M,stopRecording:G,transcribe:O,error:W}=Le({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:q}=Re({config:{thinkingDuration:u,answeringDuration:p,editingDuration:R},callbacks:{onPhaseChange:x=>{switch(x){case S.FETCHING_QUESTION:se();break;case S.READING_QUESTION:ae();break;case S.ANSWERING:F();break;case S.TRANSCRIBING:oe();break;case S.SUBMITTING:ne();break}},onInterviewEnd:()=>{e==null||e()}}});l.useEffect(()=>{L()},[]);const{execute:se,loading:B}=Ae(async()=>{var _,X;const x=await s.generateQuestion({interviewId:r,question:((_=v.current)==null?void 0:_.question)||"",qnaId:((X=v.current)==null?void 0:X.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)}}),ne=l.useCallback(async()=>{L()},[L]),ae=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 Ne(2e3),q())}catch(_){console.error("Failed to speak question:",_)}else I()},[P,I,q]),F=l.useCallback(async()=>{try{await M(p)}catch(x){console.error("Failed to start recording:",x),I()}},[M,I]),oe=l.useCallback(async()=>{try{const x=await G();await O(x)}catch(x){console.error("STT processing failed:",x),!N.current&&!k.current&&(N.current=!0,I())}},[G,O,I]),H=()=>{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(J,{onClick:L,className:"iw-mt-2 iw-w-40",children:"Start Interview"})]});case S.FETCHING_QUESTION:return t.jsx(Ye,{});case S.READING_QUESTION:return t.jsx(Xe,{ttsError:y});case S.THINKING:return t.jsx(Ze,{state:$,thinkingTime:u,nextPhase:I});case S.ANSWERING:return t.jsx(He,{state:$,answeringTime:p,nextPhase:I,sttError:W});case S.TRANSCRIBING:return t.jsx(Ke,{sttError:W});case S.EDITING:case S.SUBMITTING:return t.jsx("div",{className:"iw-space-y-4 iw-h-full",children:t.jsx(ze,{value:h,onChange:_=>g(_.target.value),onSubmit:()=>I(),isSubmitDisabled:!h.trim()||B,state:$,editingTime:R})});case S.COMPLETED:return t.jsx("div",{className:"iw-fixed iw-inset-0 iw-bg-white",children:t.jsx(Ve,{open:!0,onClose:e||(()=>{})})});default:return null}};return t.jsxs("div",{className:"interview-widget-container",children:[t.jsx(rt,{title:i,onExit:async()=>{(await s.generateQuestion({interviewId:r,isInterviewDone:!0})).success&&q()}}),t.jsxs("div",{className:`iw-p-4 iw-space-y-4 iw-pb-6 ${a} 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(tt,{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(Ge,{})}),t.jsx("div",{className:"iw-bg-white iw-rounded-lg iw-shadow iw-p-6",children:H()})]})]})]})},re=({title:i,interviewId:r,onInterviewEnd:e,className:a=""})=>{const[s,c]=l.useState(!1),[o,n]=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)] ${a}`,children:t.jsx("div",{className:" iw-h-full iw-flex iw-flex-col",children:t.jsx(st,{interviewTitle:i??"Interview",interviewId:r,className:a,onComplete:e||(()=>{})})})})}):t.jsx("div",{className:"interview-widget-container",children:t.jsx(Ee,{isOpen:o,onStart:()=>{console.log("Permissions granted, starting interview"),c(!0),n(!1)}})})};typeof window<"u"&&(window.InterviewWidget={InterviewWidget:re,InterviewWidgetProvider:ue}),C.InterviewWidget=re,C.InterviewWidgetProvider=ue,C.default=re,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.6",
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",