interview-widget 0.1.3 → 0.1.5

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.
Files changed (29) hide show
  1. package/README.md +69 -28
  2. package/dist/assets/bot-icon.d.ts +1 -0
  3. package/dist/assets/clock-fading-icon.d.ts +1 -0
  4. package/dist/assets/loader-icon.d.ts +1 -0
  5. package/dist/assets/shield-icon.d.ts +2 -0
  6. package/dist/assets/speak-icon.d.ts +1 -0
  7. package/dist/components/interview/answer-area.d.ts +3 -1
  8. package/dist/components/interview/phases/animated-blob.d.ts +13 -0
  9. package/dist/components/interview/phases/answering-phase.d.ts +10 -0
  10. package/dist/components/interview/phases/file-generation-animation.d.ts +1 -0
  11. package/dist/components/interview/phases/interview-completion-modal.d.ts +7 -0
  12. package/dist/components/interview/phases/question-reading-animation.d.ts +5 -0
  13. package/dist/components/interview/phases/thinking-phase.d.ts +8 -0
  14. package/dist/components/interview/phases/transcription-animation.d.ts +6 -0
  15. package/dist/components/interview/question-display.d.ts +1 -0
  16. package/dist/components/media/audio-wave-visualizer.d.ts +14 -0
  17. package/dist/components/timer/circular-timer.d.ts +11 -0
  18. package/dist/components/ui/extended/styled-button.d.ts +7 -0
  19. package/dist/hooks/use-timer.d.ts +1 -0
  20. package/dist/services/stt/stt-service.d.ts +1 -0
  21. package/dist/services/timer/timer-service.d.ts +5 -4
  22. package/dist/services/tts/tts-service.d.ts +1 -0
  23. package/dist/types.d.ts +1 -2
  24. package/dist/utils/constants.d.ts +1 -1
  25. package/dist/utils/helper.d.ts +1 -1
  26. package/dist/widget.css +1 -1
  27. package/dist/widget.es.js +1482 -1056
  28. package/dist/widget.umd.js +107 -2
  29. package/package.json +1 -1
package/dist/widget.es.js CHANGED
@@ -1,9 +1,9 @@
1
- var me = Object.defineProperty;
2
- var ge = (i, t, e) => t in i ? me(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
3
- var I = (i, t, e) => ge(i, typeof t != "symbol" ? t + "" : t, e);
4
- import { createContext as he, useContext as fe, useEffect as A, useState as y, useRef as D, useCallback as v, useMemo as xe } from "react";
5
- import { createPortal as pe } from "react-dom";
6
- var X = { exports: {} }, U = {};
1
+ var ve = Object.defineProperty;
2
+ var je = (i, r, e) => r in i ? ve(i, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[r] = e;
3
+ var D = (i, r, e) => je(i, typeof r != "symbol" ? r + "" : r, e);
4
+ import ce, { createContext as Ne, useContext as Te, useRef as S, useState as T, useEffect as P, useCallback as A, useMemo as V } from "react";
5
+ import { createPortal as ke } from "react-dom";
6
+ var de = { exports: {} }, J = {};
7
7
  /**
8
8
  * @license React
9
9
  * react-jsx-runtime.production.js
@@ -13,28 +13,28 @@ var X = { exports: {} }, U = {};
13
13
  * This source code is licensed under the MIT license found in the
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
- var be = Symbol.for("react.transitional.element"), ye = Symbol.for("react.fragment");
17
- function Z(i, t, e) {
18
- var a = null;
19
- if (e !== void 0 && (a = "" + e), t.key !== void 0 && (a = "" + t.key), "key" in t) {
16
+ var Ie = Symbol.for("react.transitional.element"), Ee = Symbol.for("react.fragment");
17
+ function we(i, r, e) {
18
+ var o = null;
19
+ if (e !== void 0 && (o = "" + e), r.key !== void 0 && (o = "" + r.key), "key" in r) {
20
20
  e = {};
21
- for (var s in t)
22
- s !== "key" && (e[s] = t[s]);
23
- } else e = t;
24
- return t = e.ref, {
25
- $$typeof: be,
21
+ for (var s in r)
22
+ s !== "key" && (e[s] = r[s]);
23
+ } else e = r;
24
+ return r = e.ref, {
25
+ $$typeof: Ie,
26
26
  type: i,
27
- key: a,
28
- ref: t !== void 0 ? t : null,
27
+ key: o,
28
+ ref: r !== void 0 ? r : null,
29
29
  props: e
30
30
  };
31
31
  }
32
- U.Fragment = ye;
33
- U.jsx = Z;
34
- U.jsxs = Z;
35
- X.exports = U;
36
- var r = X.exports;
37
- const C = {
32
+ J.Fragment = Ee;
33
+ J.jsx = we;
34
+ J.jsxs = we;
35
+ de.exports = J;
36
+ var t = de.exports;
37
+ const $ = {
38
38
  api: {
39
39
  baseUrl: "/api",
40
40
  retryConfig: {
@@ -62,214 +62,103 @@ const C = {
62
62
  provider: "piper"
63
63
  }
64
64
  }
65
- }, ee = he(
65
+ }, ue = Ne(
66
66
  null
67
67
  );
68
- function Ne({
68
+ function Re({
69
69
  config: i = {},
70
- children: t
70
+ children: r
71
71
  }) {
72
- var a, s, c, n;
72
+ var o, s, c, a;
73
73
  const e = {
74
74
  api: {
75
- ...C.api,
75
+ ...$.api,
76
76
  ...i.api,
77
77
  retryConfig: {
78
- ...C.api.retryConfig,
79
- ...(a = i.api) == null ? void 0 : a.retryConfig
78
+ ...$.api.retryConfig,
79
+ ...(o = i.api) == null ? void 0 : o.retryConfig
80
80
  }
81
81
  },
82
82
  ui: {
83
- ...C.ui,
83
+ ...$.ui,
84
84
  ...i.ui
85
85
  },
86
86
  interview: {
87
- ...C.interview,
87
+ ...$.interview,
88
88
  ...i.interview,
89
89
  timers: {
90
- ...C.interview.timers,
90
+ ...$.interview.timers,
91
91
  ...(s = i.interview) == null ? void 0 : s.timers
92
92
  },
93
93
  stt: {
94
- ...C.interview.stt,
94
+ ...$.interview.stt,
95
95
  ...(c = i.interview) == null ? void 0 : c.stt
96
96
  },
97
97
  tts: {
98
- ...C.interview.tts,
99
- ...(n = i.interview) == null ? void 0 : n.tts
98
+ ...$.interview.tts,
99
+ ...(a = i.interview) == null ? void 0 : a.tts
100
100
  }
101
101
  }
102
102
  };
103
- return /* @__PURE__ */ r.jsx(ee.Provider, { value: e, children: t });
103
+ return /* @__PURE__ */ t.jsx(ue.Provider, { value: e, children: r });
104
104
  }
105
- function q() {
106
- const i = fe(ee);
105
+ function X() {
106
+ const i = Te(ue);
107
107
  if (!i)
108
108
  throw new Error(
109
109
  "useInterviewConfig must be used within an InterviewWidgetProvider. Wrap your component tree with <InterviewWidgetProvider config={...}>"
110
110
  );
111
111
  return i;
112
112
  }
113
- function Te() {
114
- return q().api || C.api;
113
+ function Se() {
114
+ return X().api || $.api;
115
115
  }
116
- function F() {
117
- return q().ui || C.ui;
116
+ function W() {
117
+ return X().ui || $.ui;
118
118
  }
119
- function Ie() {
120
- return q().interview || C.interview;
119
+ function Ce() {
120
+ return X().interview || $.interview;
121
121
  }
122
- const ve = ({
123
- isOpen: i,
124
- onClose: t,
125
- children: e,
126
- title: a,
127
- showCloseButton: s = !0,
128
- closeOnOverlayClick: c = !0,
129
- closeOnEscape: n = !0,
130
- className: o = ""
131
- }) => {
132
- if (A(() => {
133
- if (!i || !n) return;
134
- const d = (u) => {
135
- u.key === "Escape" && t();
136
- };
137
- return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
138
- }, [i, n, t]), A(() => (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")), () => {
139
- document.body.style.overflow = "unset", document.body.classList.remove("interview-widget-container");
140
- }), [i]), !i) return null;
141
- const m = (d) => {
142
- c && d.target === d.currentTarget && t();
143
- }, g = /* @__PURE__ */ r.jsxs("div", { className: "iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center", children: [
144
- /* @__PURE__ */ r.jsx(
145
- "div",
146
- {
147
- className: "iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",
148
- onClick: m
149
- }
150
- ),
151
- /* @__PURE__ */ r.jsxs(
152
- "div",
153
- {
154
- 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 ${o}`,
155
- role: "dialog",
156
- "aria-modal": "true",
157
- "aria-labelledby": a ? "dialog-title" : void 0,
158
- children: [
159
- (a || s) && /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200", children: [
160
- a && /* @__PURE__ */ r.jsx(
161
- "h2",
162
- {
163
- id: "dialog-title",
164
- className: "iw-text-lg iw-font-semibold iw-text-gray-900",
165
- children: a
166
- }
167
- ),
168
- s && /* @__PURE__ */ r.jsx(
169
- "button",
170
- {
171
- onClick: t,
172
- className: "iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100",
173
- "aria-label": "Close dialog",
174
- children: /* @__PURE__ */ r.jsx(
175
- "svg",
176
- {
177
- className: "iw-w-5 iw-h-5",
178
- fill: "none",
179
- stroke: "currentColor",
180
- viewBox: "0 0 24 24",
181
- children: /* @__PURE__ */ r.jsx(
182
- "path",
183
- {
184
- strokeLinecap: "round",
185
- strokeLinejoin: "round",
186
- strokeWidth: 2,
187
- d: "M6 18L18 6M6 6l12 12"
188
- }
189
- )
190
- }
191
- )
192
- }
193
- )
194
- ] }),
195
- /* @__PURE__ */ r.jsx("div", { className: "iw-p-4 iw-overflow-y-auto", children: e })
196
- ]
197
- }
198
- )
199
- ] });
200
- return pe(g, document.body);
201
- }, Ee = ({
202
- confirmExitInterview: i,
203
- isOpen: t,
204
- onClose: e
205
- }) => /* @__PURE__ */ r.jsx(ve, { isOpen: t, onClose: e, title: "Exit Interview", children: /* @__PURE__ */ r.jsxs("div", { className: "iw-space-y-4", children: [
206
- /* @__PURE__ */ r.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." }),
207
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-justify-end iw-space-x-2", children: [
208
- /* @__PURE__ */ r.jsx(
209
- "button",
210
- {
211
- className: "iw-px-4 iw-py-2 iw-bg-gray-200 iw-rounded iw-text-gray-700 iw-font-medium",
212
- onClick: e,
213
- children: "Cancel"
214
- }
215
- ),
216
- /* @__PURE__ */ r.jsx(
217
- "button",
218
- {
219
- className: "iw-px-4 iw-py-2 iw-bg-red-600 iw-text-white iw-rounded iw-font-medium",
220
- onClick: i,
221
- children: "Confirm Exit"
222
- }
223
- )
224
- ] })
225
- ] }) }), je = ({ title: i, onExit: t }) => {
226
- const { baseColor: e } = F(), [a, s] = y(!1);
227
- return /* @__PURE__ */ r.jsxs("header", { className: "iw-w-full iw-text-gray-900", children: [
228
- /* @__PURE__ */ r.jsxs("div", { className: "iw-mx-auto iw-flex iw-items-center iw-justify-between iw-px-4 iw-py-3", children: [
229
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
230
- /* @__PURE__ */ r.jsx(
231
- "div",
232
- {
233
- className: "iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",
234
- style: { backgroundColor: e },
235
- children: "N"
236
- }
237
- ),
238
- /* @__PURE__ */ r.jsx("p", { className: "iw-text-sm iw-font-medium", children: "Novara" })
239
- ] }),
240
- /* @__PURE__ */ r.jsx("h1", { className: "iw-text-base iw-font-medium", children: i }),
241
- /* @__PURE__ */ r.jsx(
242
- "button",
243
- {
244
- className: "iw-text-sm iw-text-gray-500 hover:iw-text-gray-700",
245
- onClick: () => s(!0),
246
- children: "Exit Interview"
247
- }
248
- )
249
- ] }),
250
- /* @__PURE__ */ r.jsx("div", { className: "iw-h-px iw-bg-gray-200" }),
251
- /* @__PURE__ */ r.jsx(
252
- Ee,
253
- {
254
- isOpen: a,
255
- confirmExitInterview: () => {
256
- t(), s(!1);
257
- },
258
- onClose: () => s(!1)
259
- }
260
- )
261
- ] });
262
- }, $ = ({
122
+ const he = ({
123
+ className: i,
124
+ ...r
125
+ }) => /* @__PURE__ */ t.jsx("div", { children: /* @__PURE__ */ t.jsxs(
126
+ "svg",
127
+ {
128
+ xmlns: "http://www.w3.org/2000/svg",
129
+ width: "20",
130
+ height: "20",
131
+ viewBox: "0 0 24 24",
132
+ fill: "none",
133
+ stroke: "currentColor",
134
+ strokeWidth: "2",
135
+ strokeLinecap: "round",
136
+ strokeLinejoin: "round",
137
+ className: `iw-animate-spin ${i}`,
138
+ ...r,
139
+ children: [
140
+ /* @__PURE__ */ t.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
141
+ /* @__PURE__ */ t.jsx("path", { d: "M12 6l0 -3" }),
142
+ /* @__PURE__ */ t.jsx("path", { d: "M16.25 7.75l2.15 -2.15" }),
143
+ /* @__PURE__ */ t.jsx("path", { d: "M18 12l3 0" }),
144
+ /* @__PURE__ */ t.jsx("path", { d: "M16.25 16.25l2.15 2.15" }),
145
+ /* @__PURE__ */ t.jsx("path", { d: "M12 18l0 3" }),
146
+ /* @__PURE__ */ t.jsx("path", { d: "M7.75 16.25l-2.15 2.15" }),
147
+ /* @__PURE__ */ t.jsx("path", { d: "M6 12l-3 0" }),
148
+ /* @__PURE__ */ t.jsx("path", { d: "M7.75 7.75l-2.15 -2.15" })
149
+ ]
150
+ }
151
+ ) }), se = ({
263
152
  children: i,
264
- variant: t = "primary",
153
+ variant: r = "primary",
265
154
  size: e = "md",
266
- fullWidth: a = !1,
155
+ fullWidth: o = !1,
267
156
  isLoading: s = !1,
268
157
  disabled: c,
269
- className: n = "",
270
- ...o
158
+ className: a = "",
159
+ ...n
271
160
  }) => {
272
- const m = "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", g = {
161
+ const w = "iw-inline-flex iw-items-center iw-justify-center iw-rounded-md iw-font-medium iw-transition-colors iw-focus:outline-none iw-focus:ring-2 iw-focus:ring-primary-500 iw-focus:ring-offset-2", m = {
273
162
  primary: "iw-bg-primary-600 iw-text-white iw-hover:bg-primary-700 iw-border iw-border-transparent",
274
163
  secondary: "iw-bg-primary-100 iw-text-primary-700 iw-hover:bg-primary-200 iw-border iw-border-transparent",
275
164
  outline: "iw-bg-transparent iw-text-primary-700 iw-border iw-border-primary-500 iw-hover:bg-primary-50",
@@ -277,159 +166,194 @@ const ve = ({
277
166
  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"
278
167
  }, d = {
279
168
  sm: "iw-px-3 iw-py-1.5 iw-text-sm",
280
- md: "iw-px-4 iw-py-2 iw-text-sm",
281
- lg: "iw-px-5 iw-py-2.5 iw-text-base"
282
- }, u = "iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none", h = a ? "iw-w-full" : "";
283
- return /* @__PURE__ */ r.jsxs(
169
+ md: "iw-px-4 iw-py-2.5 iw-text-sm",
170
+ lg: "iw-px-5 iw-py-3 iw-text-base"
171
+ }, h = "iw-disabled:opacity-50 iw-disabled:cursor-not-allowed iw-disabled:pointer-events-none", u = o ? "iw-w-full" : "";
172
+ return /* @__PURE__ */ t.jsxs(
284
173
  "button",
285
174
  {
286
- className: `${m} ${g[t]} ${d[e]} ${h} ${u} ${n}`,
175
+ className: `${w} ${m[r]} ${d[e]} ${u} ${h} ${a}`,
287
176
  disabled: c || s,
288
- ...o,
177
+ ...n,
289
178
  children: [
290
- s && /* @__PURE__ */ r.jsxs(
291
- "svg",
292
- {
293
- className: "iw-animate-spin iw-mr-2 iw-h-4 iw-w-4 iw-text-white",
294
- xmlns: "http://www.w3.org/2000/svg",
295
- fill: "none",
296
- viewBox: "0 0 24 24",
297
- children: [
298
- /* @__PURE__ */ r.jsx(
299
- "circle",
300
- {
301
- className: "iw-opacity-25",
302
- cx: "12",
303
- cy: "12",
304
- r: "10",
305
- stroke: "currentColor",
306
- strokeWidth: "4"
307
- }
308
- ),
309
- /* @__PURE__ */ r.jsx(
310
- "path",
311
- {
312
- className: "iw-opacity-75",
313
- fill: "currentColor",
314
- d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
315
- }
316
- )
317
- ]
318
- }
319
- ),
179
+ s && /* @__PURE__ */ t.jsx(he, { height: 16, width: 16, style: { marginRight: "3px" } }),
320
180
  i
321
181
  ]
322
182
  }
323
183
  );
324
- }, Se = ({
184
+ };
185
+ function Me(i) {
186
+ const r = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);
187
+ return r ? {
188
+ r: parseInt(r[1], 16),
189
+ g: parseInt(r[2], 16),
190
+ b: parseInt(r[3], 16)
191
+ } : null;
192
+ }
193
+ function Ae(i, r, e) {
194
+ return "#" + [i, r, e].map((o) => {
195
+ const s = Math.round(o).toString(16);
196
+ return s.length === 1 ? "0" + s : s;
197
+ }).join("");
198
+ }
199
+ function me(i, r) {
200
+ const e = Me(i);
201
+ if (!e) return i;
202
+ const o = e.r + (255 - e.r) * r, s = e.g + (255 - e.g) * r, c = e.b + (255 - e.b) * r;
203
+ return Ae(o, s, c);
204
+ }
205
+ function De(i, r = 0.8) {
206
+ return {
207
+ background: `linear-gradient(to bottom, ${me(i, r)}, #ffffff)`,
208
+ color: "#1f2937"
209
+ };
210
+ }
211
+ function Pe(i) {
212
+ return new Promise((r) => setTimeout(r, i));
213
+ }
214
+ function ge(i) {
215
+ return `linear-gradient(to left, ${me(i, 0.4)}, ${i})`;
216
+ }
217
+ const $e = (i) => /* @__PURE__ */ t.jsxs(
218
+ "svg",
219
+ {
220
+ xmlns: "http://www.w3.org/2000/svg",
221
+ width: "24",
222
+ height: "24",
223
+ viewBox: "0 0 24 24",
224
+ fill: "none",
225
+ stroke: "currentColor",
226
+ strokeWidth: "2",
227
+ strokeLinecap: "round",
228
+ strokeLinejoin: "round",
229
+ ...i,
230
+ children: [
231
+ /* @__PURE__ */ 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" }),
232
+ /* @__PURE__ */ t.jsx("path", { d: "m9 12 2 2 4-4" })
233
+ ]
234
+ }
235
+ ), _e = [
236
+ "Do not refresh or reload the page during your assessment",
237
+ "Refrain from switching tabs or opening other applications while the session is in progress",
238
+ "Ensure your face remains clearly visible on camera at all times",
239
+ "Avoid frequent distractions or leaving your seat during the session",
240
+ "Do not disable or interfere with audio/video monitoring",
241
+ "All activities are being recorded, and any violations may result in penalties, including disqualification"
242
+ ], Le = ({
325
243
  isOpen: i,
326
- onStart: t,
244
+ onStart: r,
327
245
  onClose: e
328
246
  }) => {
329
- var N;
330
- const a = D(null), s = D(null), { baseColor: c, borderRadius: n } = F(), [o, m] = y(!1), [g, d] = y(null), [u, h] = y(!1), x = () => {
331
- s.current && (s.current.getTracks().forEach((w) => w.stop()), s.current = null);
332
- }, k = async () => {
333
- h(!0), d(null);
247
+ var j;
248
+ const o = S(null), s = S(null), { baseColor: c, borderRadius: a } = W(), [n, w] = T(!1), [m, d] = T(null), [h, u] = T(!1), g = () => {
249
+ s.current && (s.current.getTracks().forEach((l) => l.stop()), s.current = null);
250
+ }, y = async () => {
251
+ u(!0), d(null);
334
252
  try {
335
- const w = await navigator.mediaDevices.getUserMedia({
253
+ const l = await navigator.mediaDevices.getUserMedia({
336
254
  video: { width: { ideal: 1280 }, height: { ideal: 720 } },
337
255
  audio: !0
338
256
  });
339
- s.current = w, a.current && (a.current.srcObject = w), m(!0);
340
- } catch (w) {
341
- console.error("Media permission error:", w);
257
+ s.current = l, o.current && (o.current.srcObject = l), w(!0);
258
+ } catch (l) {
259
+ console.error("Media permission error:", l);
342
260
  let p = "Unable to access camera or microphone.";
343
- (w == null ? void 0 : w.name) === "NotAllowedError" ? p = "Permissions denied. Please allow access to camera and microphone." : (w == null ? void 0 : w.name) === "NotFoundError" ? p = "No camera/microphone found. Please connect a device and retry." : w != null && w.message && (p = w.message), m(!1), d(p);
261
+ (l == null ? void 0 : l.name) === "NotAllowedError" ? p = "Permissions denied. Please allow access to camera and microphone." : (l == null ? void 0 : l.name) === "NotFoundError" ? p = "No camera/microphone found. Please connect a device and retry." : l != null && l.message && (p = l.message), w(!1), d(p);
344
262
  } finally {
345
- h(!1);
263
+ u(!1);
346
264
  }
347
265
  };
348
- if (A(() => {
266
+ if (P(() => {
349
267
  if (!i) {
350
- x();
268
+ g();
351
269
  return;
352
270
  }
353
- return k(), () => {
354
- x();
271
+ return y(), () => {
272
+ g();
355
273
  };
356
274
  }, [i]), !i) return null;
357
- const j = () => {
358
- t(), x();
275
+ const k = () => {
276
+ r(), g();
359
277
  };
360
- return /* @__PURE__ */ r.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: /* @__PURE__ */ r.jsxs("div", { className: "iw-bg-white iw-rounded-xl iw-shadow-2xl iw-w-full iw-max-w-3xl iw-mx-4", children: [
361
- /* @__PURE__ */ r.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: [
362
- /* @__PURE__ */ r.jsx("h2", { className: "iw-text-base iw-font-semibold", children: "Camera & Microphone Check" }),
363
- e && /* @__PURE__ */ r.jsx(
278
+ return /* @__PURE__ */ 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: /* @__PURE__ */ t.jsxs("div", { className: "iw-bg-white iw-rounded-xl iw-shadow-2xl iw-w-full iw-max-w-[800px] iw-mx-4", children: [
279
+ /* @__PURE__ */ 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: [
280
+ /* @__PURE__ */ t.jsx("h2", { className: "iw-text-base iw-font-semibold", children: "Interview Onboarding" }),
281
+ e && /* @__PURE__ */ t.jsx(
364
282
  "button",
365
283
  {
366
284
  "aria-label": "Close",
367
285
  className: "iw-text-gray-500 hover:iw-text-gray-700",
368
286
  onClick: () => {
369
- x(), e == null || e();
287
+ g(), e == null || e();
370
288
  },
371
289
  children: "✕"
372
290
  }
373
291
  )
374
292
  ] }),
375
- /* @__PURE__ */ r.jsxs("div", { className: "iw-p-4 iw-grid iw-grid-cols-2 iw-gap-4", children: [
376
- /* @__PURE__ */ r.jsx("div", { className: "iw-border iw-border-gray-200 iw-rounded-lg iw-overflow-hidden iw-bg-gray-900", children: /* @__PURE__ */ r.jsx(
377
- "video",
378
- {
379
- ref: a,
380
- autoPlay: !0,
381
- playsInline: !0,
382
- muted: !0,
383
- className: "iw-w-full iw-h-64 iw-object-cover"
384
- }
385
- ) }),
386
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-flex-col iw-gap-3", children: [
387
- /* @__PURE__ */ r.jsx("p", { className: "iw-text-sm iw-text-gray-700", children: "We will need access to your camera and microphone. Grant permission to preview your setup and to enable the Start Interview button." }),
388
- !((N = navigator.mediaDevices) != null && N.getUserMedia) && /* @__PURE__ */ r.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." }),
389
- g && /* @__PURE__ */ r.jsx("div", { className: "iw-text-xs iw-text-red-600", children: g }),
390
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-gap-2", children: [
391
- /* @__PURE__ */ r.jsx(
392
- $,
293
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-p-4 iw-grid iw-grid-cols-2 iw-gap-4", children: [
294
+ /* @__PURE__ */ t.jsxs("div", { children: [
295
+ /* @__PURE__ */ t.jsx("div", { className: "iw-border iw-border-gray-200 iw-rounded-lg iw-overflow-hidden iw-bg-gray-900", children: /* @__PURE__ */ t.jsx(
296
+ "video",
297
+ {
298
+ ref: o,
299
+ autoPlay: !0,
300
+ playsInline: !0,
301
+ muted: !0,
302
+ className: "iw-w-full iw-h-64 iw-object-cover",
303
+ style: {
304
+ transform: "scaleX(-1)"
305
+ }
306
+ }
307
+ ) }),
308
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-grid iw-grid-cols-2 iw-gap-2 iw-mt-3", children: [
309
+ /* @__PURE__ */ t.jsx(
310
+ se,
393
311
  {
394
- onClick: k,
395
- isLoading: u,
312
+ onClick: y,
313
+ disabled: h,
396
314
  variant: "outline",
397
315
  size: "sm",
398
316
  style: {
399
317
  borderColor: c,
400
- borderRadius: n,
318
+ borderRadius: a,
401
319
  color: c
402
320
  },
403
- children: o ? "Recheck Permissions" : "Enable Camera & Mic"
321
+ children: n ? "Recheck Permissions" : "Enable Camera & Mic"
404
322
  }
405
323
  ),
406
- /* @__PURE__ */ r.jsx(
407
- $,
324
+ /* @__PURE__ */ t.jsx(
325
+ se,
408
326
  {
409
- onClick: j,
410
- disabled: !o,
327
+ onClick: k,
328
+ disabled: !n,
411
329
  size: "sm",
412
- style: { backgroundColor: c, borderRadius: n },
413
- children: "Proceed"
330
+ style: {
331
+ background: ge(c),
332
+ borderRadius: a
333
+ },
334
+ children: "Start Interview"
414
335
  }
415
336
  )
416
- ] }),
417
- /* @__PURE__ */ r.jsxs("ul", { className: "iw-text-xs iw-text-gray-500 iw-pt-2 iw-list-disc iw-pl-4", children: [
418
- /* @__PURE__ */ r.jsx("li", { children: "Your preview is muted to avoid echo." }),
419
- /* @__PURE__ */ r.jsx("li", { children: "You can change devices from your browser’s site settings." })
420
337
  ] })
338
+ ] }),
339
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-gap-3", children: [
340
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-2 iw-text-gray-800 iw-font-semibold", children: [
341
+ /* @__PURE__ */ t.jsx($e, {}),
342
+ /* @__PURE__ */ t.jsx("h3", { children: "Interview Guidelines" })
343
+ ] }),
344
+ !((j = navigator.mediaDevices) != null && j.getUserMedia) && /* @__PURE__ */ 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." }),
345
+ m && /* @__PURE__ */ t.jsx("div", { className: "iw-text-xs iw-text-red-600", children: m }),
346
+ /* @__PURE__ */ 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: _e.map((l, p) => /* @__PURE__ */ t.jsx("li", { children: l }, p)) })
421
347
  ] })
422
348
  ] })
423
349
  ] }) });
424
350
  };
425
- var l = /* @__PURE__ */ ((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))(l || {});
426
- const Re = {
351
+ var R = /* @__PURE__ */ ((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))(R || {});
352
+ const Oe = {
427
353
  thinkingDuration: 30,
428
354
  answeringDuration: 120,
429
- editingDuration: 30,
430
- totalInterviewDuration: 600,
431
- minimumTimeForNextQuestion: 120
432
- }, Ce = {
355
+ editingDuration: 30
356
+ }, Fe = {
433
357
  idle: {
434
358
  next: "fetching_question"
435
359
  /* FETCHING_QUESTION */
@@ -458,17 +382,16 @@ const Re = {
458
382
  /* COMPLETED */
459
383
  }
460
384
  };
461
- class ke {
462
- constructor(t = {}, e = {}) {
463
- I(this, "config");
464
- I(this, "state");
465
- I(this, "phaseIntervalId", null);
466
- I(this, "globalIntervalId", null);
467
- I(this, "callbacks");
468
- this.config = { ...Re, ...t }, this.callbacks = e, this.state = {
385
+ class Ue {
386
+ constructor(r = {}, e = {}) {
387
+ D(this, "config");
388
+ D(this, "state");
389
+ D(this, "phaseIntervalId", null);
390
+ D(this, "globalIntervalId", null);
391
+ D(this, "callbacks");
392
+ this.config = { ...Oe, ...r }, this.callbacks = e, this.state = {
469
393
  phase: "idle",
470
394
  currentPhaseTimeRemaining: 0,
471
- totalTimeRemaining: this.config.totalInterviewDuration,
472
395
  totalTimeElapsed: 0,
473
396
  currentQuestionNumber: 0
474
397
  };
@@ -483,22 +406,24 @@ class ke {
483
406
  * Start a new question cycle
484
407
  */
485
408
  startQuestion() {
486
- var t, e;
487
- if (this.state.totalTimeRemaining < this.config.minimumTimeForNextQuestion) {
488
- this.state.phase = "completed", this.stopGlobalTimer(), this.stopPhaseTimer(), (e = (t = this.callbacks).onInterviewEnd) == null || e.call(t), this.notifyChange();
489
- return;
490
- }
491
409
  this.state.currentQuestionNumber === 0 && this.startGlobalTimer(), this.state.currentQuestionNumber = this.state.currentQuestionNumber + 1, this.state.phase = "fetching_question", this.notifyChange();
492
410
  }
493
411
  /**
494
412
  * Move to next phase
495
413
  */
496
414
  nextPhase() {
497
- const t = this.state.phase, e = Ce[t];
415
+ const r = this.state.phase, e = Fe[r];
498
416
  if (!e) return;
499
417
  this.stopPhaseTimer(), this.state.phase = e.next;
500
- const a = this.getDurationForPhase(e.next);
501
- a > 0 ? (this.state.currentPhaseTimeRemaining = a, this.startPhaseTimer()) : this.state.currentPhaseTimeRemaining = 0, this.notifyChange();
418
+ const o = this.getDurationForPhase(e.next);
419
+ o > 0 ? (this.state.currentPhaseTimeRemaining = o, this.startPhaseTimer()) : this.state.currentPhaseTimeRemaining = 0, this.notifyChange();
420
+ }
421
+ /**
422
+ * Manually complete the interview
423
+ */
424
+ completeInterview() {
425
+ var r, e;
426
+ this.stopGlobalTimer(), this.stopPhaseTimer(), this.state.phase = "completed", (e = (r = this.callbacks).onInterviewEnd) == null || e.call(r), this.notifyChange();
502
427
  }
503
428
  /**
504
429
  * Cleanup
@@ -509,8 +434,8 @@ class ke {
509
434
  /**
510
435
  * Get duration for a phase
511
436
  */
512
- getDurationForPhase(t) {
513
- switch (t) {
437
+ getDurationForPhase(r) {
438
+ switch (r) {
514
439
  case "thinking":
515
440
  return this.config.thinkingDuration;
516
441
  case "answering":
@@ -522,12 +447,12 @@ class ke {
522
447
  }
523
448
  }
524
449
  /**
525
- * Start global timer (runs continuously during entire interview)
450
+ * Start global timer (runs continuously during entire interview for tracking)
526
451
  */
527
452
  startGlobalTimer() {
528
453
  this.globalIntervalId = setInterval(() => {
529
- var t, e, a, s;
530
- this.state.totalTimeRemaining--, this.state.totalTimeElapsed++, (e = (t = this.callbacks).onTick) == null || e.call(t, this.getState()), this.state.totalTimeRemaining <= 0 && (this.stopGlobalTimer(), this.stopPhaseTimer(), this.state.phase = "completed", (s = (a = this.callbacks).onInterviewEnd) == null || s.call(a), this.notifyChange());
454
+ var r, e;
455
+ this.state.totalTimeElapsed++, (e = (r = this.callbacks).onTick) == null || e.call(r, this.getState());
531
456
  }, 1e3);
532
457
  }
533
458
  /**
@@ -554,88 +479,91 @@ class ke {
554
479
  * Notify phase change
555
480
  */
556
481
  notifyChange() {
557
- var t, e;
558
- (e = (t = this.callbacks).onPhaseChange) == null || e.call(t, this.state.phase, this.getState());
482
+ var r, e;
483
+ (e = (r = this.callbacks).onPhaseChange) == null || e.call(r, this.state.phase, this.getState());
559
484
  }
560
485
  }
561
- function De(i = {}) {
562
- const { config: t = {}, callbacks: e = {} } = i, a = D(null);
563
- a.current || (a.current = new ke(t, {}));
564
- const s = a.current, [c, n] = y(s.getState()), o = v(() => {
565
- n(s.getState());
486
+ function Ge(i = {}) {
487
+ const { config: r = {}, callbacks: e = {} } = i, o = S(null);
488
+ o.current || (o.current = new Ue(r, {}));
489
+ const s = o.current, [c, a] = T(s.getState()), n = A(() => {
490
+ a(s.getState());
566
491
  }, [s]);
567
- A(() => {
568
- const d = {
569
- onPhaseChange: (u, h) => {
570
- var x;
571
- o(), (x = e.onPhaseChange) == null || x.call(e, u, h);
492
+ P(() => {
493
+ const h = {
494
+ onPhaseChange: (u, g) => {
495
+ var y;
496
+ n(), (y = e.onPhaseChange) == null || y.call(e, u, g);
572
497
  },
573
498
  onTick: (u) => {
574
- var h;
575
- o(), (h = e.onTick) == null || h.call(e, u);
499
+ var g;
500
+ n(), (g = e.onTick) == null || g.call(e, u);
576
501
  },
577
502
  onInterviewEnd: () => {
578
503
  var u;
579
- o(), (u = e.onInterviewEnd) == null || u.call(e);
504
+ n(), (u = e.onInterviewEnd) == null || u.call(e);
580
505
  }
581
506
  };
582
- s.callbacks = d;
583
- }, [s, e, o]), A(() => () => {
507
+ s.callbacks = h;
508
+ }, [s, e, n]), P(() => () => {
584
509
  s.destroy();
585
510
  }, [s]);
586
- const m = v(() => {
587
- s.startQuestion(), o();
588
- }, [s, o]), g = v(() => {
589
- s.nextPhase(), o();
590
- }, [s, o]);
511
+ const w = A(() => {
512
+ s.startQuestion(), n();
513
+ }, [s, n]), m = A(() => {
514
+ s.nextPhase(), n();
515
+ }, [s, n]), d = A(() => {
516
+ s.completeInterview(), n();
517
+ }, [s, n]);
591
518
  return {
592
519
  state: c,
593
- startQuestion: m,
594
- nextPhase: g,
520
+ startQuestion: w,
521
+ nextPhase: m,
522
+ completeInterview: d,
595
523
  timerService: s
596
524
  };
597
525
  }
598
- function Pe(i, t = {}) {
599
- const [e, a] = y({
526
+ function qe(i, r = {}) {
527
+ const [e, o] = T({
600
528
  data: null,
601
529
  loading: !1,
602
530
  error: null
603
- }), s = v(
531
+ }), s = A(
604
532
  async (...c) => {
605
- var n, o, m, g;
606
- a((d) => ({ ...d, loading: !0, error: null }));
533
+ var a, n, w, m;
534
+ o((d) => ({ ...d, loading: !0, error: null }));
607
535
  try {
608
536
  const d = await i(...c);
609
- a((u) => ({
610
- ...u,
537
+ o((h) => ({
538
+ ...h,
611
539
  data: d,
612
540
  loading: !1,
613
541
  error: null
614
- })), (n = t.onSuccess) == null || n.call(t, d), (o = t.onSettled) == null || o.call(t, d, null);
542
+ })), (a = r.onSuccess) == null || a.call(r, d), (n = r.onSettled) == null || n.call(r, d, null);
615
543
  } catch (d) {
616
- const u = d.type ? d : {
544
+ const h = d.type ? d : {
617
545
  type: "unknown",
618
546
  message: d.message || "Unknown error",
619
547
  retryable: !0,
620
548
  userMessage: "Something went wrong. Please try again.",
621
549
  originalError: d
622
550
  };
623
- a((h) => ({
624
- ...h,
551
+ o((u) => ({
552
+ ...u,
625
553
  loading: !1,
626
- error: u
627
- })), (m = t.onError) == null || m.call(t, u), (g = t.onSettled) == null || g.call(t, null, u);
554
+ error: h
555
+ })), (w = r.onError) == null || w.call(r, h), (m = r.onSettled) == null || m.call(r, null, h);
628
556
  }
629
557
  },
630
- [i, t]
558
+ [i, r]
631
559
  );
632
560
  return {
633
561
  ...e,
634
562
  execute: s
635
563
  };
636
564
  }
637
- function Ae(i) {
638
- var t;
565
+ function Be(i) {
566
+ var r;
639
567
  if (!navigator.onLine)
640
568
  return {
641
569
  type: "network",
@@ -643,7 +571,7 @@ function Ae(i) {
643
571
  retryable: !0,
644
572
  userMessage: "Please check your internet connection and try again."
645
573
  };
646
- if (i.name === "AbortError" || (t = i.message) != null && t.includes("timeout"))
574
+ if (i.name === "AbortError" || (r = i.message) != null && r.includes("timeout"))
647
575
  return {
648
576
  type: "timeout",
649
577
  message: "Request timed out",
@@ -693,122 +621,122 @@ function Ae(i) {
693
621
  originalError: i
694
622
  };
695
623
  }
696
- async function H(i, t = {}, e = {
624
+ async function ae(i, r = {}, e = {
697
625
  attempts: 3,
698
626
  backoff: "exponential",
699
627
  baseDelay: 1e3,
700
628
  maxDelay: 1e4,
701
629
  jitter: !0
702
630
  }) {
703
- let a;
631
+ let o;
704
632
  for (let s = 1; s <= e.attempts; s++)
705
633
  try {
706
- const c = new AbortController(), n = setTimeout(() => c.abort(), 6e4), o = await fetch(i, {
707
- ...t,
634
+ const c = new AbortController(), a = setTimeout(() => c.abort(), 6e4), n = await fetch(i, {
635
+ ...r,
708
636
  signal: c.signal
709
637
  });
710
- if (clearTimeout(n), o.status >= 400 && o.status < 500 && o.status !== 429)
711
- return o;
712
- if (!o.ok)
713
- throw new Error(`HTTP ${o.status}: ${o.statusText}`);
714
- return o;
638
+ if (clearTimeout(a), n.status >= 400 && n.status < 500 && n.status !== 429)
639
+ return n;
640
+ if (!n.ok)
641
+ throw new Error(`HTTP ${n.status}: ${n.statusText}`);
642
+ return n;
715
643
  } catch (c) {
716
- a = c;
717
- const n = Ae(c);
718
- if (!n.retryable || s === e.attempts)
719
- throw n;
720
- const o = Ge(s, e);
644
+ o = c;
645
+ const a = Be(c);
646
+ if (!a.retryable || s === e.attempts)
647
+ throw a;
648
+ const n = ze(s, e);
721
649
  console.warn(
722
- `API request failed (attempt ${s}/${e.attempts}), retrying in ${o}ms:`,
723
- n.message
724
- ), await new Promise((m) => setTimeout(m, o));
650
+ `API request failed (attempt ${s}/${e.attempts}), retrying in ${n}ms:`,
651
+ a.message
652
+ ), await new Promise((w) => setTimeout(w, n));
725
653
  }
726
- throw a;
654
+ throw o;
727
655
  }
728
- function Ge(i, t) {
656
+ function ze(i, r) {
729
657
  let e;
730
- return t.backoff === "exponential" ? e = t.baseDelay * Math.pow(2, i - 1) : e = t.baseDelay, e = Math.min(e, t.maxDelay), t.jitter && (e = e * (0.5 + Math.random() * 0.5)), Math.round(e);
658
+ 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 * (0.5 + Math.random() * 0.5)), Math.round(e);
731
659
  }
732
- class Me {
733
- constructor(t = {}) {
734
- I(this, "config");
735
- this.config = t;
660
+ class Qe {
661
+ constructor(r = {}) {
662
+ D(this, "config");
663
+ this.config = r;
736
664
  }
737
665
  /**
738
666
  * Update configuration
739
667
  */
740
- updateConfig(t) {
741
- this.config = { ...this.config, ...t };
668
+ updateConfig(r) {
669
+ this.config = { ...this.config, ...r };
742
670
  }
743
671
  /**
744
672
  * Get default headers for API requests
745
673
  */
746
674
  getHeaders() {
747
675
  var e;
748
- const t = {
676
+ const r = {
749
677
  "Content-Type": "application/json",
750
678
  "X-Auth-Token": "appkey"
751
679
  };
752
- return (e = this.config) != null && e.authToken && (t.Authorization = `Bearer ${this.config.authToken}`), t;
680
+ return (e = this.config) != null && e.authToken && (r.Authorization = `Bearer ${this.config.authToken}`), r;
753
681
  }
754
682
  /**
755
683
  * Get base URL from config with fallback
756
684
  */
757
685
  getBaseUrl() {
758
- var t;
759
- return ((t = this.config) == null ? void 0 : t.baseUrl) || "/api";
686
+ var r;
687
+ return ((r = this.config) == null ? void 0 : r.baseUrl) || "/api";
760
688
  }
761
689
  /**
762
690
  * Get questions for an interview
763
691
  */
764
692
  async generateQuestion({
765
- interviewId: t,
693
+ interviewId: r,
766
694
  isInterviewDone: e = !1,
767
- qnaId: a,
695
+ qnaId: o,
768
696
  question: s,
769
697
  answer: c,
770
- answerDuration: n
698
+ answerDuration: a
771
699
  }) {
772
- const o = await H(
773
- `${this.getBaseUrl()}/interview/generate-question`,
700
+ const n = await ae(
701
+ `${this.getBaseUrl()}/questions/next`,
774
702
  {
775
703
  method: "POST",
776
704
  headers: this.getHeaders(),
777
705
  body: JSON.stringify({
778
- interview_id: t,
706
+ interview_id: r,
779
707
  is_interview_done: e,
780
- qna_id: a,
708
+ qna_id: o,
781
709
  question: s,
782
710
  answer: c,
783
711
  // TODO: Hardcoded for now, will be dynamic later
784
- answer_duration: n ?? "00:00:30"
712
+ answer_duration: a ?? "00:00:30"
785
713
  })
786
714
  }
787
715
  );
788
- if (!o.ok)
789
- throw new Error(`Failed to get questions: ${o.status}`);
790
- return await o.json();
716
+ if (!n.ok)
717
+ throw new Error(`Failed to get questions: ${n.status}`);
718
+ return await n.json();
791
719
  }
792
720
  }
793
- function Oe() {
794
- const i = q();
795
- return xe(() => {
721
+ function We() {
722
+ const i = X();
723
+ return V(() => {
796
724
  const e = i.api || {};
797
- return new Me(e);
725
+ return new Qe(e);
798
726
  }, [i.api]);
799
727
  }
800
- class b extends Error {
801
- constructor(t, e, a = !1) {
802
- super(t), this.code = e, this.recoverable = a, this.name = "STTError";
728
+ class v extends Error {
729
+ constructor(r, e, o = !1) {
730
+ super(r), this.code = e, this.recoverable = o, this.name = "STTError";
803
731
  }
804
732
  }
805
- class $e {
806
- constructor(t = {}) {
807
- I(this, "config");
808
- I(this, "mediaRecorder", null);
809
- I(this, "audioChunks", []);
810
- I(this, "recordingStream", null);
811
- I(this, "autoStopTimeoutId", null);
733
+ class He {
734
+ constructor(r = {}) {
735
+ D(this, "config");
736
+ D(this, "mediaRecorder", null);
737
+ D(this, "audioChunks", []);
738
+ D(this, "recordingStream", null);
739
+ D(this, "autoStopTimeoutId", null);
812
740
  this.config = {
813
741
  baseUrl: "http://localhost:8000",
814
742
  provider: "groq",
@@ -816,14 +744,14 @@ class $e {
816
744
  language: "en",
817
745
  includeTimestamps: !1,
818
746
  temperature: 0,
819
- ...t
747
+ ...r
820
748
  };
821
749
  }
822
750
  /**
823
751
  * Update STT configuration
824
752
  */
825
- updateConfig(t) {
826
- this.config = { ...this.config, ...t };
753
+ updateConfig(r) {
754
+ this.config = { ...this.config, ...r };
827
755
  }
828
756
  /**
829
757
  * Check if browser supports audio recording
@@ -834,16 +762,16 @@ class $e {
834
762
  /**
835
763
  * Start recording audio from user's microphone
836
764
  */
837
- async startRecording(t, e) {
838
- var a;
765
+ async startRecording(r, e) {
766
+ var o;
839
767
  if (!this.isRecordingSupported())
840
- throw new b(
768
+ throw new v(
841
769
  "Audio recording is not supported in this browser",
842
770
  "RECORDING_NOT_SUPPORTED",
843
771
  !1
844
772
  );
845
773
  if (this.isRecording())
846
- throw new b(
774
+ throw new v(
847
775
  "Recording is already in progress",
848
776
  "ALREADY_RECORDING",
849
777
  !0
@@ -860,34 +788,34 @@ class $e {
860
788
  this.mediaRecorder = new MediaRecorder(this.recordingStream, {
861
789
  mimeType: s
862
790
  }), this.mediaRecorder.ondataavailable = (c) => {
863
- var n;
864
- c.data.size > 0 && (this.audioChunks.push(c.data), (n = e == null ? void 0 : e.onDataAvailable) == null || n.call(e, c.data));
791
+ var a;
792
+ c.data.size > 0 && (this.audioChunks.push(c.data), (a = e == null ? void 0 : e.onDataAvailable) == null || a.call(e, c.data));
865
793
  }, this.mediaRecorder.onstop = () => {
866
794
  var c;
867
795
  (c = e == null ? void 0 : e.onStop) == null || c.call(e);
868
796
  }, this.mediaRecorder.onerror = (c) => {
869
- var o;
870
- const n = new b(
797
+ var n;
798
+ const a = new v(
871
799
  `Recording failed: ${c.error}`,
872
800
  "RECORDING_ERROR",
873
801
  !0
874
802
  );
875
- (o = e == null ? void 0 : e.onError) == null || o.call(e, n), this.cleanup();
876
- }, this.mediaRecorder.start(100), (a = e == null ? void 0 : e.onStart) == null || a.call(e), t && t > 0 && (this.autoStopTimeoutId = setTimeout(() => {
803
+ (n = e == null ? void 0 : e.onError) == null || n.call(e, a), this.cleanup();
804
+ }, this.mediaRecorder.start(100), (o = e == null ? void 0 : e.onStart) == null || o.call(e), r && r > 0 && (this.autoStopTimeoutId = setTimeout(() => {
877
805
  this.isRecording() && this.stopRecording();
878
- }, t * 1e3));
806
+ }, r * 1e3));
879
807
  } catch (s) {
880
808
  if (this.cleanup(), s instanceof Error) {
881
809
  if (s.name === "NotAllowedError" || s.name === "PermissionDeniedError")
882
- throw new b(
810
+ throw new v(
883
811
  "Microphone permission was denied",
884
812
  "PERMISSION_DENIED",
885
813
  !1
886
814
  );
887
815
  if (s.name === "NotFoundError")
888
- throw new b("No microphone found", "NO_MICROPHONE", !1);
816
+ throw new v("No microphone found", "NO_MICROPHONE", !1);
889
817
  }
890
- throw new b(
818
+ throw new v(
891
819
  `Failed to start recording: ${s instanceof Error ? s.message : String(s)}`,
892
820
  "START_RECORDING_FAILED",
893
821
  !0
@@ -899,25 +827,25 @@ class $e {
899
827
  */
900
828
  async stopRecording() {
901
829
  if (this.autoStopTimeoutId && (clearTimeout(this.autoStopTimeoutId), this.autoStopTimeoutId = null), !this.mediaRecorder || !this.isRecording())
902
- throw new b(
830
+ throw new v(
903
831
  "No active recording to stop",
904
832
  "NO_ACTIVE_RECORDING",
905
833
  !1
906
834
  );
907
- return new Promise((t, e) => {
835
+ return new Promise((r, e) => {
908
836
  if (!this.mediaRecorder) {
909
837
  e(
910
- new b("MediaRecorder is null", "MEDIARECORDER_NULL", !1)
838
+ new v("MediaRecorder is null", "MEDIARECORDER_NULL", !1)
911
839
  );
912
840
  return;
913
841
  }
914
- const a = this.mediaRecorder, s = () => {
842
+ const o = this.mediaRecorder, s = () => {
915
843
  try {
916
- const c = a.mimeType || "audio/webm", n = new Blob(this.audioChunks, { type: c });
917
- this.cleanup(), t(n);
844
+ const c = o.mimeType || "audio/webm", a = new Blob(this.audioChunks, { type: c });
845
+ this.cleanup(), r(a);
918
846
  } catch (c) {
919
847
  e(
920
- new b(
848
+ new v(
921
849
  `Failed to create audio blob: ${c instanceof Error ? c.message : String(c)}`,
922
850
  "BLOB_CREATION_FAILED",
923
851
  !1
@@ -925,40 +853,43 @@ class $e {
925
853
  );
926
854
  }
927
855
  };
928
- a.addEventListener("stop", s, { once: !0 }), a.stop();
856
+ o.addEventListener("stop", s, { once: !0 }), o.stop();
929
857
  });
930
858
  }
931
859
  /**
932
860
  * Transcribe audio blob using the STT API
933
861
  */
934
- async transcribe(t) {
862
+ async transcribe(r) {
935
863
  const {
936
864
  audioBlob: e,
937
- model: a = this.config.model,
865
+ model: o = this.config.model,
938
866
  language: s = this.config.language,
939
867
  includeTimestamps: c = this.config.includeTimestamps,
940
- temperature: n = this.config.temperature
941
- } = t;
868
+ temperature: a = this.config.temperature
869
+ } = r;
942
870
  if (!e || e.size === 0)
943
- throw new b(
871
+ throw new v(
944
872
  "Audio blob is empty or invalid",
945
873
  "INVALID_AUDIO",
946
874
  !1
947
875
  );
948
876
  try {
949
- const o = new FormData(), m = new File([e], "recording.wav", {
877
+ const n = new FormData(), w = new File([e], "recording.wav", {
950
878
  type: e.type || "audio/wav"
951
879
  });
952
- o.append("file", m), o.append("model", a || "whisper-large-v3-turbo"), o.append("language", s || "en"), o.append("include_timestamps", String(c || !1)), o.append("temperature", String(n || 0));
953
- const g = await H(
880
+ n.append("file", w), n.append("model", o || "whisper-large-v3-turbo"), n.append("language", s || "en"), n.append("include_timestamps", String(c || !1)), n.append("temperature", String(a || 0));
881
+ const m = await ae(
954
882
  `${this.config.baseUrl}/speech/transcribe`,
955
883
  {
956
884
  method: "POST",
957
885
  headers: {
958
886
  accept: "application/json",
959
- "X-STT-Provider": this.config.provider || "groq"
887
+ "X-STT-Provider": this.config.provider || "groq",
888
+ ...this.config.authToken && {
889
+ Authorization: `Bearer ${this.config.authToken}`
890
+ }
960
891
  },
961
- body: o
892
+ body: n
962
893
  },
963
894
  {
964
895
  attempts: 1,
@@ -968,27 +899,27 @@ class $e {
968
899
  jitter: !0
969
900
  }
970
901
  );
971
- if (!g.ok) {
972
- const u = await g.text();
973
- let h = `STT request failed: ${g.status} ${g.statusText}`;
902
+ if (!m.ok) {
903
+ const h = await m.text();
904
+ let u = `STT request failed: ${m.status} ${m.statusText}`;
974
905
  try {
975
- const x = JSON.parse(u);
976
- h = x.message || x.error || h;
906
+ const g = JSON.parse(h);
907
+ u = g.message || g.error || u;
977
908
  } catch {
978
- h = u || h;
909
+ u = h || u;
979
910
  }
980
- throw new b(
981
- h,
982
- `HTTP_${g.status}`,
983
- g.status >= 500
911
+ throw new v(
912
+ u,
913
+ `HTTP_${m.status}`,
914
+ m.status >= 500
984
915
  );
985
916
  }
986
917
  return {
987
- transcript: (await g.json()).data.text ?? ""
918
+ transcript: (await m.json()).data.text ?? ""
988
919
  };
989
- } catch (o) {
990
- throw o instanceof b ? o : new b(
991
- `Transcription failed: ${o instanceof Error ? o.message : String(o)}`,
920
+ } catch (n) {
921
+ throw n instanceof v ? n : new v(
922
+ `Transcription failed: ${n instanceof Error ? n.message : String(n)}`,
992
923
  "TRANSCRIPTION_FAILED",
993
924
  !0
994
925
  );
@@ -1010,14 +941,14 @@ class $e {
1010
941
  * Get supported MIME type for recording
1011
942
  */
1012
943
  getSupportedMimeType() {
1013
- const t = [
944
+ const r = [
1014
945
  "audio/webm",
1015
946
  "audio/webm;codecs=opus",
1016
947
  "audio/ogg;codecs=opus",
1017
948
  "audio/mp4",
1018
949
  "audio/wav"
1019
950
  ];
1020
- for (const e of t)
951
+ for (const e of r)
1021
952
  if (MediaRecorder.isTypeSupported(e))
1022
953
  return e;
1023
954
  return "audio/webm";
@@ -1026,122 +957,125 @@ class $e {
1026
957
  * Clean up recording resources
1027
958
  */
1028
959
  cleanup() {
1029
- this.recordingStream && (this.recordingStream.getTracks().forEach((t) => t.stop()), this.recordingStream = null), this.mediaRecorder = null, this.audioChunks = [], this.autoStopTimeoutId && (clearTimeout(this.autoStopTimeoutId), this.autoStopTimeoutId = null);
960
+ 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);
1030
961
  }
1031
962
  }
1032
- const O = new $e(), _e = (i = {}) => {
1033
- const [t, e] = y(!1), [a, s] = y(!1), [c, n] = y(null), [o, m] = y(null), [g, d] = y(null);
1034
- i.config && O.updateConfig(i.config);
1035
- const u = v(async (j) => {
1036
- var N;
963
+ const Q = new He(), Ye = (i = {}) => {
964
+ const [r, e] = T(!1), [o, s] = T(!1), [c, a] = T(null), [n, w] = T(null), [m, d] = T(null);
965
+ i.config && Q.updateConfig(i.config);
966
+ const h = A(async (k) => {
967
+ var j;
1037
968
  try {
1038
- m(null), n(null), d(null), await O.startRecording(j, {
969
+ w(null), a(null), d(null), await Q.startRecording(k, {
1039
970
  onStart: () => {
1040
- var w;
1041
- e(!0), (w = i.onStart) == null || w.call(i);
971
+ var l;
972
+ e(!0), (l = i.onStart) == null || l.call(i);
1042
973
  },
1043
974
  onStop: () => {
1044
- var w;
1045
- e(!1), (w = i.onStop) == null || w.call(i);
975
+ var l;
976
+ e(!1), (l = i.onStop) == null || l.call(i);
1046
977
  },
1047
- onError: (w) => {
1048
- var T;
1049
- const p = w instanceof b ? w : new b(w.message, "RECORDING_ERROR", !0);
1050
- m(p), e(!1), (T = i.onError) == null || T.call(i, p);
978
+ onError: (l) => {
979
+ var I;
980
+ const p = l instanceof v ? l : new v(l.message, "RECORDING_ERROR", !0);
981
+ w(p), e(!1), (I = i.onError) == null || I.call(i, p);
1051
982
  }
1052
983
  });
1053
- } catch (w) {
1054
- const p = w instanceof b ? w : new b(
1055
- w instanceof Error ? w.message : String(w),
984
+ } catch (l) {
985
+ const p = l instanceof v ? l : new v(
986
+ l instanceof Error ? l.message : String(l),
1056
987
  "START_FAILED",
1057
988
  !1
1058
989
  );
1059
- throw m(p), e(!1), (N = i.onError) == null || N.call(i, p), p;
990
+ throw w(p), e(!1), (j = i.onError) == null || j.call(i, p), p;
1060
991
  }
1061
- }, []), h = v(async () => {
1062
- var j, N;
992
+ }, []), u = A(async () => {
993
+ var k, j;
1063
994
  try {
1064
- const w = await O.stopRecording();
1065
- return d(w), e(!1), (j = i.onStop) == null || j.call(i), w;
1066
- } catch (w) {
1067
- const p = w instanceof b ? w : new b(
1068
- w instanceof Error ? w.message : String(w),
995
+ const l = await Q.stopRecording();
996
+ return d(l), e(!1), (k = i.onStop) == null || k.call(i), l;
997
+ } catch (l) {
998
+ const p = l instanceof v ? l : new v(
999
+ l instanceof Error ? l.message : String(l),
1069
1000
  "STOP_FAILED",
1070
1001
  !1
1071
1002
  );
1072
- throw m(p), e(!1), (N = i.onError) == null || N.call(i, p), p;
1003
+ throw w(p), e(!1), (j = i.onError) == null || j.call(i, p), p;
1073
1004
  }
1074
- }, []), x = v(
1075
- async (j, N = {}) => {
1076
- var w, p;
1005
+ }, []), g = A(
1006
+ async (k, j = {}) => {
1007
+ var l, p;
1077
1008
  try {
1078
- m(null), s(!0);
1079
- const T = {
1080
- audioBlob: j,
1081
- ...N
1082
- }, S = await O.transcribe(T);
1083
- return n(S.transcript), s(!1), (w = i.onTranscriptionComplete) == null || w.call(i, S), S;
1084
- } catch (T) {
1085
- const S = T instanceof b ? T : new b(
1086
- T instanceof Error ? T.message : String(T),
1009
+ w(null), s(!0);
1010
+ const I = {
1011
+ audioBlob: k,
1012
+ ...j
1013
+ }, b = await Q.transcribe(I);
1014
+ return a(b.transcript), s(!1), (l = i.onTranscriptionComplete) == null || l.call(i, b), b;
1015
+ } catch (I) {
1016
+ const b = I instanceof v ? I : new v(
1017
+ I instanceof Error ? I.message : String(I),
1087
1018
  "TRANSCRIPTION_FAILED",
1088
1019
  !0
1089
1020
  );
1090
- throw m(S), s(!1), (p = i.onError) == null || p.call(i, S), S;
1021
+ throw w(b), s(!1), (p = i.onError) == null || p.call(i, b), b;
1091
1022
  }
1092
1023
  },
1093
1024
  []
1094
- ), k = v(() => {
1095
- O.cancelRecording(), e(!1), d(null);
1025
+ ), y = A(() => {
1026
+ Q.cancelRecording(), e(!1), d(null);
1096
1027
  }, []);
1097
1028
  return {
1098
- startRecording: u,
1099
- stopRecording: h,
1100
- transcribe: x,
1101
- cancelRecording: k,
1102
- isRecording: t,
1103
- isTranscribing: a,
1029
+ startRecording: h,
1030
+ stopRecording: u,
1031
+ transcribe: g,
1032
+ cancelRecording: y,
1033
+ isRecording: r,
1034
+ isTranscribing: o,
1104
1035
  transcript: c,
1105
- error: o,
1106
- audioBlob: g
1036
+ error: n,
1037
+ audioBlob: m
1107
1038
  };
1108
1039
  };
1109
- class Le {
1110
- constructor(t = {}) {
1111
- I(this, "config");
1112
- I(this, "currentAudio", null);
1040
+ class Ve {
1041
+ constructor(r = {}) {
1042
+ D(this, "config");
1043
+ D(this, "currentAudio", null);
1113
1044
  this.config = {
1114
1045
  baseUrl: "http://localhost:8000",
1115
1046
  provider: "piper",
1116
1047
  voice: "string",
1117
1048
  speed: 1,
1118
- ...t
1049
+ ...r
1119
1050
  };
1120
1051
  }
1121
1052
  /**
1122
1053
  * Update TTS configuration
1123
1054
  */
1124
- updateConfig(t) {
1125
- this.config = { ...this.config, ...t };
1055
+ updateConfig(r) {
1056
+ this.config = { ...this.config, ...r };
1126
1057
  }
1127
1058
  /**
1128
1059
  * Get TTS audio from the API and return as blob
1129
1060
  */
1130
- async synthesizeSpeech(t) {
1061
+ async synthesizeSpeech(r) {
1131
1062
  const {
1132
1063
  text: e,
1133
- voice: a = this.config.voice,
1064
+ voice: o = this.config.voice,
1134
1065
  speed: s = this.config.speed
1135
- } = t, c = new URLSearchParams();
1136
- c.append("text", e), c.append("voice", a || "string"), c.append("speed", (s == null ? void 0 : s.toString()) || "1");
1137
- const n = await H(
1066
+ } = r, c = new URLSearchParams();
1067
+ c.append("text", e), c.append("voice", o || "string"), c.append("speed", (s == null ? void 0 : s.toString()) || "1");
1068
+ const a = await ae(
1138
1069
  `${this.config.baseUrl}/speech/synthesize`,
1139
1070
  {
1140
1071
  method: "POST",
1141
1072
  headers: {
1142
1073
  accept: "application/json",
1143
1074
  "X-TTS-Provider": this.config.provider || "piper",
1144
- "Content-Type": "application/x-www-form-urlencoded"
1075
+ "Content-Type": "application/x-www-form-urlencoded",
1076
+ ...this.config.authToken && {
1077
+ Authorization: `Bearer ${this.config.authToken}`
1078
+ }
1145
1079
  },
1146
1080
  body: c
1147
1081
  },
@@ -1153,16 +1087,16 @@ class Le {
1153
1087
  jitter: !1
1154
1088
  }
1155
1089
  );
1156
- if (!n.ok)
1090
+ if (!a.ok)
1157
1091
  throw new Error(
1158
- `TTS request failed: ${n.status} ${n.statusText}`
1092
+ `TTS request failed: ${a.status} ${a.statusText}`
1159
1093
  );
1160
- const o = n.headers.get("content-type");
1161
- if (o && o.includes("audio/"))
1162
- return n.blob();
1094
+ const n = a.headers.get("content-type");
1095
+ if (n && n.includes("audio/"))
1096
+ return a.blob();
1163
1097
  try {
1164
- const m = await n.json();
1165
- throw new Error(`TTS Error: ${JSON.stringify(m)}`);
1098
+ const w = await a.json();
1099
+ throw new Error(`TTS Error: ${JSON.stringify(w)}`);
1166
1100
  } catch {
1167
1101
  throw new Error("TTS request failed with unknown error");
1168
1102
  }
@@ -1170,35 +1104,35 @@ class Le {
1170
1104
  /**
1171
1105
  * Speak text and return a promise that resolves when playback completes
1172
1106
  */
1173
- async speak(t, e) {
1174
- var a, s;
1107
+ async speak(r, e) {
1108
+ var o, s;
1175
1109
  try {
1176
- this.stop(), (a = e == null ? void 0 : e.onStart) == null || a.call(e);
1177
- const c = await this.synthesizeSpeech(t), n = URL.createObjectURL(c);
1178
- return this.currentAudio = new Audio(n), new Promise((o, m) => {
1110
+ this.stop(), (o = e == null ? void 0 : e.onStart) == null || o.call(e);
1111
+ const c = await this.synthesizeSpeech(r), a = URL.createObjectURL(c);
1112
+ return this.currentAudio = new Audio(a), new Promise((n, w) => {
1179
1113
  if (!this.currentAudio) {
1180
- m(new Error("Audio element not created"));
1114
+ w(new Error("Audio element not created"));
1181
1115
  return;
1182
1116
  }
1183
- const g = this.currentAudio;
1184
- g.onended = () => {
1117
+ const m = this.currentAudio;
1118
+ m.onended = () => {
1185
1119
  var d;
1186
- URL.revokeObjectURL(n), this.currentAudio = null, (d = e == null ? void 0 : e.onEnd) == null || d.call(e), o();
1187
- }, g.onerror = (d) => {
1188
- var h;
1189
- URL.revokeObjectURL(n), this.currentAudio = null;
1190
- const u = new Error(`Audio playback failed: ${d}`);
1191
- (h = e == null ? void 0 : e.onError) == null || h.call(e, u), m(u);
1192
- }, g.play().catch((d) => {
1193
- var h;
1194
- URL.revokeObjectURL(n), this.currentAudio = null;
1195
- const u = new Error(`Failed to play audio: ${d.message}`);
1196
- (h = e == null ? void 0 : e.onError) == null || h.call(e, u), m(u);
1120
+ URL.revokeObjectURL(a), this.currentAudio = null, (d = e == null ? void 0 : e.onEnd) == null || d.call(e), n();
1121
+ }, m.onerror = (d) => {
1122
+ var u;
1123
+ URL.revokeObjectURL(a), this.currentAudio = null;
1124
+ const h = new Error(`Audio playback failed: ${d}`);
1125
+ (u = e == null ? void 0 : e.onError) == null || u.call(e, h), w(h);
1126
+ }, m.play().catch((d) => {
1127
+ var u;
1128
+ URL.revokeObjectURL(a), this.currentAudio = null;
1129
+ const h = new Error(`Failed to play audio: ${d.message}`);
1130
+ (u = e == null ? void 0 : e.onError) == null || u.call(e, h), w(h);
1197
1131
  });
1198
1132
  });
1199
1133
  } catch (c) {
1200
- const n = c instanceof Error ? c : new Error(`TTS Error: ${String(c)}`);
1201
- throw (s = e == null ? void 0 : e.onError) == null || s.call(e, n), n;
1134
+ const a = c instanceof Error ? c : new Error(`TTS Error: ${String(c)}`);
1135
+ throw (s = e == null ? void 0 : e.onError) == null || s.call(e, a), a;
1202
1136
  }
1203
1137
  }
1204
1138
  /**
@@ -1214,661 +1148,1153 @@ class Le {
1214
1148
  return this.currentAudio !== null && !this.currentAudio.paused;
1215
1149
  }
1216
1150
  }
1217
- const B = new Le(), Ue = (i = {}) => {
1218
- const [t, e] = y(!1), [a, s] = y(!1), [c, n] = y(null);
1219
- i.config && B.updateConfig(i.config);
1220
- const o = v(
1221
- async (g, d = {}) => {
1222
- var u;
1151
+ const ie = new Ve(), Je = (i = {}) => {
1152
+ const [r, e] = T(!1), [o, s] = T(!1), [c, a] = T(null);
1153
+ i.config && ie.updateConfig(i.config);
1154
+ const n = A(
1155
+ async (m, d = {}) => {
1156
+ var h;
1223
1157
  try {
1224
- n(null), s(!0);
1225
- const h = {
1226
- text: g,
1158
+ a(null), s(!0);
1159
+ const u = {
1160
+ text: m,
1227
1161
  ...d
1228
1162
  };
1229
- await B.speak(h, {
1163
+ await ie.speak(u, {
1230
1164
  onStart: () => {
1231
- var x;
1232
- s(!1), e(!0), (x = i.onStart) == null || x.call(i);
1165
+ var g;
1166
+ s(!1), e(!0), (g = i.onStart) == null || g.call(i);
1233
1167
  },
1234
1168
  onEnd: () => {
1235
- var x;
1236
- e(!1), (x = i.onEnd) == null || x.call(i);
1169
+ var g;
1170
+ e(!1), (g = i.onEnd) == null || g.call(i);
1237
1171
  },
1238
- onError: (x) => {
1239
- var k;
1240
- e(!1), s(!1), n(x), (k = i.onError) == null || k.call(i, x);
1172
+ onError: (g) => {
1173
+ var y;
1174
+ e(!1), s(!1), a(g), (y = i.onError) == null || y.call(i, g);
1241
1175
  }
1242
1176
  });
1243
- } catch (h) {
1244
- const x = h instanceof Error ? h : new Error(String(h));
1245
- throw n(x), e(!1), s(!1), (u = i.onError) == null || u.call(i, x), x;
1177
+ } catch (u) {
1178
+ const g = u instanceof Error ? u : new Error(String(u));
1179
+ throw a(g), e(!1), s(!1), (h = i.onError) == null || h.call(i, g), g;
1246
1180
  }
1247
1181
  },
1248
1182
  [i]
1249
- ), m = v(() => {
1250
- B.stop(), e(!1), s(!1);
1183
+ ), w = A(() => {
1184
+ ie.stop(), e(!1), s(!1);
1251
1185
  }, []);
1252
1186
  return {
1253
- speak: o,
1254
- stop: m,
1255
- isPlaying: t,
1256
- isLoading: a,
1187
+ speak: n,
1188
+ stop: w,
1189
+ isPlaying: r,
1190
+ isLoading: o,
1257
1191
  error: c
1258
1192
  };
1259
- };
1260
- function qe(i) {
1261
- const t = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(i);
1262
- return t ? {
1263
- r: parseInt(t[1], 16),
1264
- g: parseInt(t[2], 16),
1265
- b: parseInt(t[3], 16)
1266
- } : null;
1267
- }
1268
- function Fe(i, t, e) {
1269
- return "#" + [i, t, e].map((a) => {
1270
- const s = Math.round(a).toString(16);
1271
- return s.length === 1 ? "0" + s : s;
1272
- }).join("");
1273
- }
1274
- function V(i, t) {
1275
- const e = qe(i);
1276
- if (!e) return i;
1277
- const a = e.r + (255 - e.r) * t, s = e.g + (255 - e.g) * t, c = e.b + (255 - e.b) * t;
1278
- return Fe(a, s, c);
1279
- }
1280
- function Qe(i, t = 0.8) {
1281
- const e = V(i, t), a = V(i, 0.7);
1282
- return {
1283
- background: `linear-gradient(to bottom, ${e}, #ffffff)`,
1284
- border: `1px solid ${a}`,
1285
- color: "#1f2937"
1286
- };
1287
- }
1288
- function Be(i) {
1289
- return new Promise((t) => setTimeout(t, i));
1290
- }
1291
- const He = ({
1292
- state: i,
1293
- className: t = "",
1294
- defaultTimers: e = { thinking: 30, answering: 120, editing: 30 }
1295
- }) => {
1296
- const a = (d) => {
1297
- const u = Math.floor(d / 60), h = d % 60;
1298
- return `${u.toString().padStart(2, "0")}:${h.toString().padStart(2, "0")}`;
1299
- }, s = (d) => ({
1300
- [l.IDLE]: "Ready",
1301
- [l.FETCHING_QUESTION]: "Loading Question...",
1302
- [l.READING_QUESTION]: "Reading Question...",
1303
- [l.THINKING]: "Preparation Time",
1304
- [l.ANSWERING]: "Recording Answer",
1305
- [l.TRANSCRIBING]: "Processing Speech...",
1306
- [l.EDITING]: "Edit Your Answer",
1307
- [l.SUBMITTING]: "Submitting...",
1308
- [l.COMPLETED]: "Interview Complete"
1309
- })[d] || d, c = (d) => ({
1310
- [l.IDLE]: "iw-bg-gray-500",
1311
- [l.FETCHING_QUESTION]: "iw-bg-blue-500",
1312
- [l.READING_QUESTION]: "iw-bg-indigo-500",
1313
- [l.THINKING]: "iw-bg-yellow-500",
1314
- [l.ANSWERING]: "iw-bg-red-500",
1315
- [l.TRANSCRIBING]: "iw-bg-purple-500",
1316
- [l.EDITING]: "iw-bg-orange-500",
1317
- [l.SUBMITTING]: "iw-bg-green-500",
1318
- [l.COMPLETED]: "iw-bg-green-600"
1319
- })[d] || "iw-bg-gray-500", n = (d) => ({
1320
- [l.IDLE]: "iw-bg-gray-100 iw-text-gray-800",
1321
- [l.FETCHING_QUESTION]: "iw-bg-blue-100 iw-text-blue-800",
1322
- [l.READING_QUESTION]: "iw-bg-indigo-100 iw-text-indigo-800",
1323
- [l.THINKING]: "iw-bg-yellow-100 iw-text-yellow-800",
1324
- [l.ANSWERING]: "iw-bg-red-100 iw-text-red-800",
1325
- [l.TRANSCRIBING]: "iw-bg-purple-100 iw-text-purple-800",
1326
- [l.EDITING]: "iw-bg-orange-100 iw-text-orange-800",
1327
- [l.SUBMITTING]: "iw-bg-green-100 iw-text-green-800",
1328
- [l.COMPLETED]: "iw-bg-green-200 iw-text-green-900"
1329
- })[d] || "iw-bg-gray-100 iw-text-gray-800", o = (d) => ({
1330
- [l.IDLE]: "Ready to start next question.",
1331
- [l.FETCHING_QUESTION]: "Please wait while we load the next question...",
1332
- [l.READING_QUESTION]: "Listening to the question...",
1333
- [l.THINKING]: "Take time to think about your answer.",
1334
- [l.ANSWERING]: "Speak clearly into your microphone.",
1335
- [l.TRANSCRIBING]: "Converting your speech to text...",
1336
- [l.EDITING]: "Review and edit your answer.",
1337
- [l.SUBMITTING]: "Submitting your answer...",
1338
- [l.COMPLETED]: "Thank you for completing the interview!"
1339
- })[d] || "";
1340
- function m(d) {
1341
- return {
1342
- [l.THINKING]: e.thinking || 30,
1343
- [l.ANSWERING]: e.answering || 120,
1344
- [l.EDITING]: e.editing || 30
1345
- }[d] || 1;
1193
+ }, Xe = ({ className: i = "" }) => {
1194
+ const r = S(null);
1195
+ return P(() => {
1196
+ let e = null;
1197
+ return (async () => {
1198
+ try {
1199
+ e = await navigator.mediaDevices.getUserMedia({
1200
+ video: !0,
1201
+ audio: !1
1202
+ }), r.current && (r.current.srcObject = e);
1203
+ } catch (s) {
1204
+ console.error("Error accessing camera:", s);
1205
+ }
1206
+ })(), () => {
1207
+ e && e.getTracks().forEach((s) => s.stop());
1208
+ };
1209
+ }, []), /* @__PURE__ */ t.jsx("div", { className: `iw-relative ${i}`, children: /* @__PURE__ */ t.jsx(
1210
+ "video",
1211
+ {
1212
+ ref: r,
1213
+ autoPlay: !0,
1214
+ playsInline: !0,
1215
+ muted: !0,
1216
+ 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",
1217
+ style: {
1218
+ transform: "scaleX(-1)"
1219
+ }
1220
+ }
1221
+ ) });
1222
+ }, Z = (i) => {
1223
+ const { baseColor: r, borderRadius: e } = W(), { loading: o, children: s, ...c } = i;
1224
+ return /* @__PURE__ */ t.jsx(
1225
+ se,
1226
+ {
1227
+ style: {
1228
+ background: ge(r),
1229
+ borderRadius: e
1230
+ },
1231
+ ...c,
1232
+ children: o ? /* @__PURE__ */ t.jsx(he, {}) : s
1233
+ }
1234
+ );
1235
+ }, ne = (i) => /* @__PURE__ */ t.jsxs(
1236
+ "svg",
1237
+ {
1238
+ xmlns: "http://www.w3.org/2000/svg",
1239
+ width: "24",
1240
+ height: "24",
1241
+ viewBox: "0 0 24 24",
1242
+ fill: "none",
1243
+ stroke: "currentColor",
1244
+ strokeWidth: "2",
1245
+ strokeLinecap: "round",
1246
+ strokeLinejoin: "round",
1247
+ ...i,
1248
+ children: [
1249
+ /* @__PURE__ */ t.jsx("path", { d: "M12 2a10 10 0 0 1 7.38 16.75" }),
1250
+ /* @__PURE__ */ t.jsx("path", { d: "M12 6v6l4 2" }),
1251
+ /* @__PURE__ */ t.jsx("path", { d: "M2.5 8.875a10 10 0 0 0-.5 3" }),
1252
+ /* @__PURE__ */ t.jsx("path", { d: "M2.83 16a10 10 0 0 0 2.43 3.4" }),
1253
+ /* @__PURE__ */ t.jsx("path", { d: "M4.636 5.235a10 10 0 0 1 .891-.857" }),
1254
+ /* @__PURE__ */ t.jsx("path", { d: "M8.644 21.42a10 10 0 0 0 7.631-.38" })
1255
+ ]
1346
1256
  }
1347
- const g = i.currentPhaseTimeRemaining > 0;
1348
- return /* @__PURE__ */ r.jsxs(
1257
+ ), Ze = (i, r, e) => Math.max(r, Math.min(e, i)), le = (i) => {
1258
+ const r = Math.max(0, Math.floor(i)), e = Math.floor(r / 60).toString().padStart(2, "0"), o = (r % 60).toString().padStart(2, "0");
1259
+ return `${e}:${o}`;
1260
+ }, oe = ({
1261
+ total: i,
1262
+ remaining: r,
1263
+ size: e = 64,
1264
+ strokeWidth: o = 6,
1265
+ className: s = "",
1266
+ showLabel: c = !0
1267
+ }) => {
1268
+ const a = Math.max(1, i || 1), n = Ze(r / a, 0, 1), { radius: w, circumference: m, dashOffset: d, center: h } = V(() => {
1269
+ const y = (e - o) / 2, k = 2 * Math.PI * y, j = k * (1 - n), l = Math.round(o) % 2 === 1, p = e / 2 + (l ? 0.5 : 0);
1270
+ return { radius: y, circumference: k, dashOffset: j, center: p };
1271
+ }, [e, o, n]), u = V(() => 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
+ return /* @__PURE__ */ t.jsxs(
1349
1273
  "div",
1350
1274
  {
1351
- className: `iw-iw-bg-white iw-rounded-lg iw-shadow-md iw-p-4 iw-border iw-border-gray-200 ${t}`,
1275
+ className: `iw-relative iw-inline-flex iw-items-center iw-justify-center iw-rounded-full iw-bg-white ${s}`,
1276
+ style: { width: e, height: e },
1277
+ "aria-label": `Time remaining ${le(r)}`,
1278
+ role: "timer",
1279
+ "aria-live": "polite",
1352
1280
  children: [
1353
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-justify-between iw-items-center iw-mb-4", children: [
1354
- /* @__PURE__ */ r.jsxs("div", { children: [
1355
- /* @__PURE__ */ r.jsx("h3", { className: "iw-text-sm iw-font-semibold iw-text-gray-700", children: "Interview Timer" }),
1356
- /* @__PURE__ */ r.jsxs("p", { className: "iw-text-xs iw-text-gray-700 iw-my-3 iw-font-mono", children: [
1357
- "Phase",
1358
- " ",
1359
- /* @__PURE__ */ r.jsx(
1360
- "span",
1281
+ /* @__PURE__ */ t.jsx(
1282
+ "svg",
1283
+ {
1284
+ width: e,
1285
+ height: e,
1286
+ viewBox: `0 0 ${e} ${e}`,
1287
+ preserveAspectRatio: "xMidYMid meet",
1288
+ children: /* @__PURE__ */ t.jsxs("g", { transform: `rotate(-90 ${h} ${h})`, children: [
1289
+ /* @__PURE__ */ t.jsx(
1290
+ "circle",
1361
1291
  {
1362
- className: `iw-px-3 iw-py-1.5 iw-rounded-md iw-font-medium ${n(
1363
- i.phase
1364
- )}`,
1365
- children: i.phase
1292
+ cx: h,
1293
+ cy: h,
1294
+ r: w,
1295
+ className: "iw-stroke-gray-200",
1296
+ strokeWidth: o,
1297
+ fill: "none",
1298
+ shapeRendering: "geometricPrecision",
1299
+ vectorEffect: "non-scaling-stroke"
1300
+ }
1301
+ ),
1302
+ /* @__PURE__ */ t.jsx(
1303
+ "circle",
1304
+ {
1305
+ cx: h,
1306
+ cy: h,
1307
+ r: w,
1308
+ className: `${u} ${g}`,
1309
+ strokeWidth: o,
1310
+ strokeLinecap: "round",
1311
+ fill: "none",
1312
+ strokeDasharray: m,
1313
+ strokeDashoffset: d,
1314
+ shapeRendering: "geometricPrecision",
1315
+ vectorEffect: "non-scaling-stroke",
1316
+ style: {
1317
+ transition: "stroke-dashoffset 0.3s ease, stroke 0.2s ease"
1318
+ }
1366
1319
  }
1367
1320
  )
1368
- ] }),
1369
- /* @__PURE__ */ r.jsxs("p", { className: "iw-text-xs iw-text-gray-700 iw-font-mono", children: [
1370
- "Question ",
1371
- i.currentQuestionNumber
1372
1321
  ] })
1373
- ] }),
1374
- /* @__PURE__ */ r.jsxs("div", { className: "iw-text-right", children: [
1375
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-2xl iw-font-bold iw-text-gray-900", children: a(i.totalTimeRemaining) }),
1376
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-xs iw-text-gray-500", children: "Total Time Left" })
1377
- ] })
1378
- ] }),
1379
- /* @__PURE__ */ r.jsx("div", { className: "iw-mb-4", children: /* @__PURE__ */ r.jsx("div", { className: "iw-w-full iw-h-2 iw-iw-bg-gray-200 iw-rounded-full iw-overflow-hidden", children: /* @__PURE__ */ r.jsx(
1380
- "div",
1322
+ }
1323
+ ),
1324
+ c && /* @__PURE__ */ t.jsx("div", { className: "iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center iw-rotate-0", children: /* @__PURE__ */ t.jsx(
1325
+ "span",
1381
1326
  {
1382
- className: "iw-h-full iw-iw-bg-gradient-to-r iw-from-blue-500 iw-to-purple-500 iw-transition-all iw-duration-300",
1383
- style: {
1384
- width: `${i.totalTimeElapsed / (i.totalTimeElapsed + i.totalTimeRemaining) * 100}%`
1385
- }
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: le(r)
1386
1329
  }
1387
- ) }) }),
1388
- /* @__PURE__ */ r.jsxs("div", { className: "iw-mb-4", children: [
1389
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between iw-mb-2", children: [
1390
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
1391
- /* @__PURE__ */ r.jsx(
1392
- "div",
1393
- {
1394
- className: `iw-w-3 iw-h-3 iw-rounded-full ${c(
1395
- i.phase
1396
- )} ${g ? "iw-animate-pulse" : ""}`
1397
- }
1398
- ),
1399
- /* @__PURE__ */ r.jsx("span", { className: "iw-text-sm iw-font-medium iw-text-gray-700", children: s(i.phase) })
1400
- ] }),
1401
- g && /* @__PURE__ */ r.jsx("span", { className: "iw-text-lg iw-font-bold iw-text-gray-900", children: a(i.currentPhaseTimeRemaining) })
1402
- ] }),
1403
- g && /* @__PURE__ */ r.jsx("div", { className: "iw-w-full iw-h-1.5 iw-iw-bg-gray-200 iw-rounded-full iw-overflow-hidden", children: /* @__PURE__ */ r.jsx(
1404
- "div",
1405
- {
1406
- className: `iw-h-full ${c(
1407
- i.phase
1408
- )} iw-transition-all iw-duration-300`,
1409
- style: {
1410
- width: `${i.currentPhaseTimeRemaining / m(i.phase) * 100}%`
1411
- }
1412
- }
1413
- ) })
1414
- ] }),
1415
- /* @__PURE__ */ r.jsx("div", { className: "iw-mt-3 iw-pt-3 iw-border-t iw-border-gray-200", children: /* @__PURE__ */ r.jsx("p", { className: "iw-text-xs iw-text-gray-600", children: o(i.phase) }) })
1330
+ ) })
1416
1331
  ]
1417
1332
  }
1418
1333
  );
1419
- }, We = ({
1334
+ }, Ke = ({
1420
1335
  label: i,
1421
- error: t,
1336
+ error: r,
1422
1337
  fullWidth: e = !1,
1423
- className: a = "",
1338
+ className: o = "",
1424
1339
  id: s,
1425
1340
  ...c
1426
1341
  }) => {
1427
- const n = s || `textarea-${Math.random().toString(36).substring(2, 9)}`, o = "iw-block iw-rounded-md iw-border iw-border-gray-300 iw-shadow-sm iw-px-4 iw-py-2 iw-text-sm iw-focus:border-primary-500 iw-focus:ring-primary-500 iw-focus:outline-none iw-transition-all", m = t ? "iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500" : "", g = e ? "iw-w-full" : "", d = a.includes("iw-h-full") ? "iw-h-full" : "";
1428
- return /* @__PURE__ */ r.jsxs(
1342
+ const a = 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", w = r ? "iw-border-red-500 iw-focus:border-red-500 iw-focus:ring-red-500" : "", m = e ? "iw-w-full" : "", d = o.includes("iw-h-full") || e ? "iw-h-full" : "";
1343
+ return /* @__PURE__ */ t.jsxs(
1429
1344
  "div",
1430
1345
  {
1431
- className: `${e ? "iw-w-full iw-h-full" : ""} ${d ? "iw-flex iw-flex-col" : ""}`,
1346
+ className: `iw-h-full iw-flex iw-flex-col ${e ? "iw-w-full" : ""}`,
1432
1347
  children: [
1433
- i && /* @__PURE__ */ r.jsx(
1348
+ i && /* @__PURE__ */ t.jsx(
1434
1349
  "label",
1435
1350
  {
1436
- htmlFor: n,
1351
+ htmlFor: a,
1437
1352
  className: "iw-block iw-text-sm iw-font-medium iw-text-gray-700 iw-mb-1",
1438
1353
  children: i
1439
1354
  }
1440
1355
  ),
1441
- /* @__PURE__ */ r.jsx(
1356
+ /* @__PURE__ */ t.jsx(
1442
1357
  "textarea",
1443
1358
  {
1444
- id: n,
1445
- className: `${o} ${m} ${g} ${d} ${a}`,
1446
- "aria-invalid": t ? "true" : "false",
1359
+ id: a,
1360
+ className: `${n} ${w} ${m} ${d} ${o}`,
1361
+ "aria-invalid": r ? "true" : "false",
1447
1362
  ...c
1448
1363
  }
1449
1364
  ),
1450
- t && /* @__PURE__ */ r.jsx("p", { className: "iw-mt-1 iw-text-sm iw-text-red-600", children: t })
1365
+ r && /* @__PURE__ */ t.jsx("p", { className: "iw-mt-1 iw-text-sm iw-text-red-600", children: r })
1451
1366
  ]
1452
1367
  }
1453
1368
  );
1454
- }, ze = ({
1369
+ }, et = ({
1455
1370
  value: i,
1456
- onChange: t,
1371
+ onChange: r,
1457
1372
  onSubmit: e,
1458
- isSubmitDisabled: a,
1459
- remainingTimeText: s
1373
+ isSubmitDisabled: o,
1374
+ state: s,
1375
+ editingTime: c
1460
1376
  }) => {
1461
- const c = (n) => {
1462
- n.key === "Enter" && (n.ctrlKey || n.metaKey) && !a && (n.preventDefault(), e());
1377
+ const a = (n) => {
1378
+ n.key === "Enter" && (n.ctrlKey || n.metaKey) && !o && (n.preventDefault(), e());
1463
1379
  };
1464
- return /* @__PURE__ */ r.jsx("div", { className: "iw-mt-auto", children: /* @__PURE__ */ r.jsxs("div", { className: "iw-rounded-xl iw-overflow-hidden iw-border iw-border-gray-200", children: [
1465
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between iw-px-3 iw-py-2 iw-bg-gray-50 iw-border-b iw-border-gray-200", children: [
1466
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-sm iw-font-medium", children: "Your answer" }),
1467
- s && /* @__PURE__ */ r.jsx("div", { className: "iw-text-xs iw-text-gray-500", children: s })
1380
+ return /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-h-full ", children: [
1381
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between", children: [
1382
+ /* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Your Answer" }),
1383
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
1384
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
1385
+ /* @__PURE__ */ t.jsx(ne, { className: "iw-size-4 iw-text-orange-600" }),
1386
+ /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to edit: " })
1387
+ ] }),
1388
+ /* @__PURE__ */ t.jsx(
1389
+ oe,
1390
+ {
1391
+ total: c,
1392
+ remaining: s.currentPhaseTimeRemaining,
1393
+ size: 50,
1394
+ strokeWidth: 4
1395
+ }
1396
+ )
1397
+ ] })
1468
1398
  ] }),
1469
- /* @__PURE__ */ r.jsx(
1470
- We,
1399
+ /* @__PURE__ */ t.jsxs("div", { className: " iw-overflow-hidden iw-flex iw-flex-col iw-h-full iw-mt-2", children: [
1400
+ /* @__PURE__ */ t.jsx(
1401
+ Ke,
1402
+ {
1403
+ value: i,
1404
+ onChange: r,
1405
+ onKeyDown: a,
1406
+ placeholder: "Type your answer here...",
1407
+ 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",
1408
+ onPaste: (n) => n.preventDefault(),
1409
+ onCopy: (n) => n.preventDefault(),
1410
+ onCut: (n) => n.preventDefault(),
1411
+ onDrop: (n) => n.preventDefault(),
1412
+ onDragOver: (n) => n.preventDefault()
1413
+ }
1414
+ ),
1415
+ /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1 iw-mt-4", children: /* @__PURE__ */ t.jsx(Z, { onClick: e, disabled: o, children: "Submit Answer" }) })
1416
+ ] })
1417
+ ] });
1418
+ }, tt = ({
1419
+ className: i = "",
1420
+ width: r,
1421
+ height: e = 56,
1422
+ barWidth: o = 3,
1423
+ gap: s = 2,
1424
+ fftSize: c = 1024,
1425
+ smoothingTimeConstant: a = 0.8,
1426
+ mediaStream: n,
1427
+ startOnMount: w = !0
1428
+ }) => {
1429
+ const { baseColor: m } = W(), d = S(null), h = S(null), u = S(null), g = S(null), y = S(null), k = S(null), j = S(!1), [l, p] = T(null);
1430
+ P(() => {
1431
+ if (r || !h.current) return;
1432
+ const b = h.current, _ = () => {
1433
+ const N = d.current;
1434
+ if (!N) return;
1435
+ const C = b.clientWidth, M = e;
1436
+ N.width = Math.max(1, Math.floor(C * window.devicePixelRatio || 1)), N.height = Math.max(1, Math.floor(M * window.devicePixelRatio || 1));
1437
+ }, x = new ResizeObserver(_);
1438
+ return x.observe(b), _(), () => x.disconnect();
1439
+ }, [r, e]), P(() => {
1440
+ if (!r) return;
1441
+ const b = d.current;
1442
+ b && (b.width = Math.max(
1443
+ 1,
1444
+ Math.floor(r * (window.devicePixelRatio || 1))
1445
+ ), b.height = Math.max(
1446
+ 1,
1447
+ Math.floor(e * (window.devicePixelRatio || 1))
1448
+ ));
1449
+ }, [r, e]), P(() => {
1450
+ let b = !1;
1451
+ return (async () => {
1452
+ try {
1453
+ const x = new (window.AudioContext || window.webkitAudioContext)();
1454
+ u.current = x;
1455
+ let N = n;
1456
+ if (!N) {
1457
+ if (!w) return;
1458
+ N = await navigator.mediaDevices.getUserMedia({
1459
+ audio: !0,
1460
+ video: !1
1461
+ }), j.current = !0;
1462
+ }
1463
+ if (b) return;
1464
+ const C = x.createAnalyser();
1465
+ C.fftSize = c, C.smoothingTimeConstant = a, g.current = C;
1466
+ const M = x.createMediaStreamSource(N);
1467
+ y.current = M, M.connect(C), I();
1468
+ } catch (x) {
1469
+ p((x == null ? void 0 : x.message) || "Failed to initialize microphone");
1470
+ }
1471
+ })(), () => {
1472
+ var x, N, C, M;
1473
+ b = !0, k.current && cancelAnimationFrame(k.current);
1474
+ try {
1475
+ (x = y.current) == null || x.disconnect();
1476
+ } catch {
1477
+ }
1478
+ try {
1479
+ (N = g.current) == null || N.disconnect();
1480
+ } catch {
1481
+ }
1482
+ j.current && ((M = ((C = y.current) == null ? void 0 : C.mediaStream) || void 0) == null || M.getTracks().forEach((q) => q.stop())), u.current && u.current.state !== "closed" && u.current.close();
1483
+ };
1484
+ }, [n, c, a, w]);
1485
+ const I = () => {
1486
+ const b = d.current, _ = g.current;
1487
+ if (!b || !_) return;
1488
+ const x = b.getContext("2d");
1489
+ if (!x) return;
1490
+ const N = window.devicePixelRatio || 1, C = b.width, M = b.height, q = _.frequencyBinCount, U = new Uint8Array(q), L = () => {
1491
+ k.current = requestAnimationFrame(L), _.getByteTimeDomainData(U), x.clearRect(0, 0, C, M), x.fillStyle = "rgba(0,0,0,0)", x.fillRect(0, 0, C, M);
1492
+ const O = Math.max(1, Math.floor(o * N)), E = Math.max(1, Math.floor(s * N)), B = O + E, H = Math.max(8, Math.floor((C + E) / B)), K = Math.floor(U.length / H);
1493
+ for (let z = 0; z < H; z++) {
1494
+ const ee = Math.min(U.length - 1, z * K), te = U[ee] / 128 - 1, G = Math.abs(te), re = Math.pow(G, 0.6), f = Math.max(M * 0.06, re * (M * 0.9)), F = z * B, Y = (M - f) / 2, xe = 140 - Math.min(140, 140 * G), pe = 85, be = 48 + Math.floor(12 * (1 - G));
1495
+ x.fillStyle = `${m}`, x.shadowColor = `hsla(${xe}, ${pe}%, ${be}%, ${0.25 * G})`, x.shadowBlur = 8 * G;
1496
+ const ye = Math.min(O / 2, f / 2);
1497
+ rt(x, F, Y, O, f, ye), x.fill();
1498
+ }
1499
+ };
1500
+ L();
1501
+ };
1502
+ return /* @__PURE__ */ t.jsxs(
1503
+ "div",
1504
+ {
1505
+ ref: h,
1506
+ className: `iw-relative iw-w-full iw-overflow-hidden iw-rounded-md iw-bg-gray-50 ${i}`,
1507
+ style: { height: e },
1508
+ children: [
1509
+ /* @__PURE__ */ t.jsx("canvas", { ref: d, className: "iw-w-full iw-h-full" }),
1510
+ l && /* @__PURE__ */ t.jsx("div", { className: "iw-absolute iw-inset-0 iw-flex iw-items-center iw-justify-center", children: /* @__PURE__ */ 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: l }) })
1511
+ ]
1512
+ }
1513
+ );
1514
+ };
1515
+ function rt(i, r, e, o, s, c) {
1516
+ const a = Math.min(c, o / 2, s / 2);
1517
+ i.beginPath(), i.moveTo(r + a, e), i.lineTo(r + o - a, e), i.quadraticCurveTo(r + o, e, r + o, e + a), i.lineTo(r + o, e + s - a), i.quadraticCurveTo(r + o, e + s, r + o - a, e + s), i.lineTo(r + a, e + s), i.quadraticCurveTo(r, e + s, r, e + s - a), i.lineTo(r, e + a), i.quadraticCurveTo(r, e, r + a, e), i.closePath();
1518
+ }
1519
+ const it = ({
1520
+ state: i,
1521
+ answeringTime: r,
1522
+ nextPhase: e,
1523
+ sttError: o
1524
+ }) => /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-justify-between iw-h-full ", children: [
1525
+ /* @__PURE__ */ t.jsxs("div", { children: [
1526
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between", children: [
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
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
1529
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
1530
+ /* @__PURE__ */ t.jsx(ne, { className: "iw-size-4 iw-text-orange-600" }),
1531
+ /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to talk: " })
1532
+ ] }),
1533
+ /* @__PURE__ */ t.jsx(
1534
+ oe,
1535
+ {
1536
+ total: r,
1537
+ remaining: i.currentPhaseTimeRemaining,
1538
+ size: 50,
1539
+ strokeWidth: 4
1540
+ }
1541
+ )
1542
+ ] })
1543
+ ] }),
1544
+ /* @__PURE__ */ 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." })
1545
+ ] }),
1546
+ /* @__PURE__ */ t.jsxs("div", { children: [
1547
+ /* @__PURE__ */ t.jsx(tt, {}),
1548
+ o && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1549
+ "Recording error: ",
1550
+ o.message
1551
+ ] })
1552
+ ] }),
1553
+ /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1", children: /* @__PURE__ */ t.jsx(
1554
+ Z,
1555
+ {
1556
+ onClick: () => {
1557
+ e();
1558
+ },
1559
+ children: "Transcribe My Answer"
1560
+ }
1561
+ ) })
1562
+ ] });
1563
+ function st() {
1564
+ const [i, r] = T(!0), e = V(
1565
+ () => [0, 1, 2].map((o) => ({ id: o })),
1566
+ []
1567
+ );
1568
+ return P(() => {
1569
+ const o = setInterval(() => {
1570
+ r((s) => !s);
1571
+ }, 1500);
1572
+ return () => clearInterval(o);
1573
+ }, []), /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-items-center iw-justify-center iw-gap-8 iw-h-full", children: [
1574
+ /* @__PURE__ */ t.jsx("div", { className: "iw-relative iw-w-80 iw-h-48 ", "aria-hidden": !0, children: e.map((o, s) => {
1575
+ const c = s * 50, a = i ? c : c + 12, n = i ? 1 : 0.08, w = s * 140;
1576
+ return /* @__PURE__ */ t.jsx(
1577
+ "div",
1578
+ {
1579
+ role: "presentation",
1580
+ 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",
1581
+ style: {
1582
+ top: 0,
1583
+ transform: `translateY(${a}px)`,
1584
+ opacity: n,
1585
+ transition: `transform 600ms cubic-bezier(.2,.9,.3,1) ${w}ms, opacity 400ms ease ${w}ms`
1586
+ },
1587
+ children: /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-gap-3 iw-items-center", children: [
1588
+ /* @__PURE__ */ t.jsx("div", { className: "iw-w-10 iw-h-10 iw-bg-gray-300 iw-rounded iw-flex-shrink-0" }),
1589
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex-1 iw-space-y-2", children: [
1590
+ /* @__PURE__ */ t.jsx("div", { className: "iw-h-2 iw-bg-gray-300 iw-rounded iw-w-24" }),
1591
+ /* @__PURE__ */ t.jsx("div", { className: "iw-h-2 iw-bg-gray-300 iw-rounded iw-w-32" })
1592
+ ] })
1593
+ ] })
1594
+ },
1595
+ o.id
1596
+ );
1597
+ }) }),
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
+ ] });
1600
+ }
1601
+ const fe = ({
1602
+ isOpen: i,
1603
+ onClose: r,
1604
+ children: e,
1605
+ title: o,
1606
+ showCloseButton: s = !0,
1607
+ closeOnOverlayClick: c = !0,
1608
+ closeOnEscape: a = !0,
1609
+ className: n = ""
1610
+ }) => {
1611
+ if (P(() => {
1612
+ if (!i || !a) return;
1613
+ const d = (h) => {
1614
+ h.key === "Escape" && r();
1615
+ };
1616
+ return document.addEventListener("keydown", d), () => document.removeEventListener("keydown", d);
1617
+ }, [i, a, r]), P(() => (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")), () => {
1618
+ document.body.style.overflow = "unset", document.body.classList.remove("interview-widget-container");
1619
+ }), [i]), !i) return null;
1620
+ const w = (d) => {
1621
+ c && d.target === d.currentTarget && r();
1622
+ }, m = /* @__PURE__ */ t.jsxs("div", { className: "iw-fixed iw-inset-0 iw-z-50 iw-flex iw-items-center iw-justify-center", children: [
1623
+ /* @__PURE__ */ t.jsx(
1624
+ "div",
1471
1625
  {
1472
- value: i,
1473
- onChange: t,
1474
- onKeyDown: c,
1475
- placeholder: "Type your answer here...",
1476
- className: "iw-bg-gray-50 iw-w-full iw-resize-none iw-focus:outline-none iw-bg-transparent iw-min-h-[112px]",
1477
- rows: 5,
1478
- fullWidth: !0
1626
+ className: "iw-fixed iw-inset-0 iw-bg-black iw-bg-opacity-50 iw-transition-opacity",
1627
+ onClick: w
1479
1628
  }
1480
1629
  ),
1481
- /* @__PURE__ */ r.jsxs("div", { className: "iw-p-2 iw-flex iw-justify-between iw-items-center iw-bg-gray-50", children: [
1482
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-xs iw-text-gray-500", children: /* @__PURE__ */ r.jsx("kbd", { children: " Press Ctrl+Enter to submit" }) }),
1483
- /* @__PURE__ */ r.jsx(
1484
- $,
1630
+ /* @__PURE__ */ t.jsxs(
1631
+ "div",
1632
+ {
1633
+ 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}`,
1634
+ role: "dialog",
1635
+ "aria-modal": "true",
1636
+ "aria-labelledby": o ? "dialog-title" : void 0,
1637
+ children: [
1638
+ (o || s) && /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-between iw-p-4 iw-border-b iw-border-gray-200", children: [
1639
+ o && /* @__PURE__ */ t.jsx(
1640
+ "h2",
1641
+ {
1642
+ id: "dialog-title",
1643
+ className: "iw-text-lg iw-font-semibold iw-text-gray-900",
1644
+ children: o
1645
+ }
1646
+ ),
1647
+ s && /* @__PURE__ */ t.jsx(
1648
+ "button",
1649
+ {
1650
+ onClick: r,
1651
+ className: "iw-p-1 iw-text-gray-400 iw-hover:text-gray-600 iw-transition-colors iw-rounded iw-hover:bg-gray-100",
1652
+ "aria-label": "Close dialog",
1653
+ children: /* @__PURE__ */ t.jsx(
1654
+ "svg",
1655
+ {
1656
+ className: "iw-w-5 iw-h-5",
1657
+ fill: "none",
1658
+ stroke: "currentColor",
1659
+ viewBox: "0 0 24 24",
1660
+ children: /* @__PURE__ */ t.jsx(
1661
+ "path",
1662
+ {
1663
+ strokeLinecap: "round",
1664
+ strokeLinejoin: "round",
1665
+ strokeWidth: 2,
1666
+ d: "M6 18L18 6M6 6l12 12"
1667
+ }
1668
+ )
1669
+ }
1670
+ )
1671
+ }
1672
+ )
1673
+ ] }),
1674
+ /* @__PURE__ */ t.jsx("div", { className: "iw-p-4 iw-overflow-y-auto", children: e })
1675
+ ]
1676
+ }
1677
+ )
1678
+ ] });
1679
+ return ke(m, document.body);
1680
+ }, at = ({
1681
+ open: i,
1682
+ onClose: r
1683
+ }) => /* @__PURE__ */ t.jsx(
1684
+ fe,
1685
+ {
1686
+ isOpen: i,
1687
+ onClose: r || (() => {
1688
+ }),
1689
+ title: "Interview Complete!",
1690
+ className: "",
1691
+ children: /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-items-center iw-justify-center iw-text-center iw-py-2", children: [
1692
+ /* @__PURE__ */ t.jsx(
1693
+ "svg",
1485
1694
  {
1486
- onClick: e,
1487
- disabled: a,
1488
- size: "sm",
1489
- variant: "gradient",
1490
- children: "Submit Answer"
1695
+ className: "iw-w-16 iw-h-16 iw-mx-auto iw-mb-4 iw-text-green-500",
1696
+ fill: "none",
1697
+ stroke: "currentColor",
1698
+ viewBox: "0 0 24 24",
1699
+ children: /* @__PURE__ */ t.jsx(
1700
+ "path",
1701
+ {
1702
+ strokeLinecap: "round",
1703
+ strokeLinejoin: "round",
1704
+ strokeWidth: 2,
1705
+ d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
1706
+ }
1707
+ )
1491
1708
  }
1492
- )
1709
+ ),
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." })
1493
1711
  ] })
1494
- ] }) });
1495
- }, Ye = ({
1496
- question: i,
1497
- isLoading: t = !1
1712
+ }
1713
+ ), nt = ({
1714
+ size: i = "192px",
1715
+ className: r,
1716
+ colors: e,
1717
+ animationDuration: o = 20
1498
1718
  }) => {
1499
- const { baseColor: e } = F();
1500
- return t ? /* @__PURE__ */ r.jsxs(
1719
+ const c = { ...{
1720
+ bg: "oklch(95% 0.02 264.695)",
1721
+ c1: "oklch(75% 0.15 350)",
1722
+ // Pastel pink
1723
+ c2: "oklch(80% 0.12 200)",
1724
+ // Pastel blue
1725
+ c3: "oklch(78% 0.14 280)"
1726
+ // Pastel purple/lavender
1727
+ }, ...e }, a = parseInt(i.replace("px", ""), 10), n = a < 50 ? Math.max(a * 8e-3, 1) : Math.max(a * 0.015, 4), w = a < 50 ? Math.max(a * 4e-3, 1.2) : Math.max(a * 8e-3, 1.5), m = a < 50 ? Math.max(a * 4e-3, 0.05) : Math.max(a * 8e-3, 0.1), d = a < 50 ? Math.max(a * 4e-3, 0.5) : Math.max(a * 8e-3, 2), h = a < 30 ? "0%" : a < 50 ? "5%" : a < 100 ? "15%" : "25%", u = a < 30 ? 1.1 : a < 50 ? Math.max(w * 1.2, 1.3) : w;
1728
+ return /* @__PURE__ */ t.jsx(
1501
1729
  "div",
1502
1730
  {
1503
- className: "iw-rounded-xl iw-mb-4 iw-p-5",
1731
+ className: `siri-orb ${r}`,
1504
1732
  style: {
1505
- background: "linear-gradient(to bottom, #eef2ff, #ffffff)",
1506
- border: "1px solid #e0e7ff",
1507
- color: "#1f2937"
1733
+ width: i,
1734
+ height: i,
1735
+ "--bg": c.bg,
1736
+ "--c1": c.c1,
1737
+ "--c2": c.c2,
1738
+ "--c3": c.c3,
1739
+ "--animation-duration": `${o}s`,
1740
+ "--blur-amount": `${n}px`,
1741
+ "--contrast-amount": u,
1742
+ "--dot-size": `${m}px`,
1743
+ "--shadow-spread": `${d}px`,
1744
+ "--mask-radius": h
1508
1745
  },
1509
- children: [
1510
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-3 iw-mb-3", children: [
1511
- /* @__PURE__ */ r.jsx(
1512
- "div",
1513
- {
1514
- className: "iw-h-12 iw-w-12 iw-rounded-lg iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold iw-animate-pulse",
1515
- style: { backgroundColor: e },
1516
- children: "N"
1517
- }
1518
- ),
1519
- /* @__PURE__ */ r.jsxs("div", { children: [
1520
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-sm iw-font-semibold", children: "Novara" }),
1521
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-xs iw-text-gray-500", children: "Assistant" })
1522
- ] })
1523
- ] }),
1524
- /* @__PURE__ */ r.jsxs("div", { className: "iw-animate-pulse", children: [
1525
- /* @__PURE__ */ r.jsx("div", { className: "iw-h-4 iw-bg-gray-200 iw-rounded iw-w-3/4 iw-mb-2" }),
1526
- /* @__PURE__ */ r.jsx("div", { className: "iw-h-4 iw-bg-gray-200 iw-rounded iw-w-full" })
1527
- ] })
1528
- ]
1746
+ children: /* @__PURE__ */ t.jsx("style", { children: `
1747
+ @property --angle {
1748
+ syntax: "<angle>";
1749
+ inherits: false;
1750
+ initial-value: 0deg;
1751
+ }
1752
+
1753
+ .siri-orb {
1754
+ display: grid;
1755
+ grid-template-areas: "stack";
1756
+ overflow: hidden;
1757
+ border-radius: 50%;
1758
+ position: relative;
1759
+ transform: scale(1.1);
1760
+ }
1761
+
1762
+ .siri-orb::before,
1763
+ .siri-orb::after {
1764
+ content: "";
1765
+ display: block;
1766
+ grid-area: stack;
1767
+ width: 100%;
1768
+ height: 100%;
1769
+ border-radius: 50%;
1770
+ transform: translateZ(0);
1771
+ }
1772
+
1773
+ .siri-orb::before {
1774
+ background: conic-gradient(
1775
+ from calc(var(--angle) * 2) at 25% 70%,
1776
+ var(--c3),
1777
+ transparent 20% 80%,
1778
+ var(--c3)
1779
+ ),
1780
+ conic-gradient(
1781
+ from calc(var(--angle) * 2) at 45% 75%,
1782
+ var(--c2),
1783
+ transparent 30% 60%,
1784
+ var(--c2)
1785
+ ),
1786
+ conic-gradient(
1787
+ from calc(var(--angle) * -3) at 80% 20%,
1788
+ var(--c1),
1789
+ transparent 40% 60%,
1790
+ var(--c1)
1791
+ ),
1792
+ conic-gradient(
1793
+ from calc(var(--angle) * 2) at 15% 5%,
1794
+ var(--c2),
1795
+ transparent 10% 90%,
1796
+ var(--c2)
1797
+ ),
1798
+ conic-gradient(
1799
+ from calc(var(--angle) * 1) at 20% 80%,
1800
+ var(--c1),
1801
+ transparent 10% 90%,
1802
+ var(--c1)
1803
+ ),
1804
+ conic-gradient(
1805
+ from calc(var(--angle) * -2) at 85% 10%,
1806
+ var(--c3),
1807
+ transparent 20% 80%,
1808
+ var(--c3)
1809
+ );
1810
+ box-shadow: inset var(--bg) 0 0 var(--shadow-spread)
1811
+ calc(var(--shadow-spread) * 0.2);
1812
+ filter: blur(var(--blur-amount)) contrast(var(--contrast-amount));
1813
+ animation: rotate var(--animation-duration) linear infinite;
1814
+ }
1815
+
1816
+ .siri-orb::after {
1817
+ background-image: radial-gradient(
1818
+ circle at center,
1819
+ var(--bg) var(--dot-size),
1820
+ transparent var(--dot-size)
1821
+ );
1822
+ background-size: calc(var(--dot-size) * 2) calc(var(--dot-size) * 2);
1823
+ backdrop-filter: blur(calc(var(--blur-amount) * 2))
1824
+ contrast(calc(var(--contrast-amount) * 2));
1825
+ mix-blend-mode: overlay;
1826
+ }
1827
+
1828
+ /* Apply mask only when radius is greater than 0 */
1829
+ .siri-orb[style*="--mask-radius: 0%"]::after {
1830
+ mask-image: none;
1831
+ }
1832
+
1833
+ .siri-orb:not([style*="--mask-radius: 0%"])::after {
1834
+ mask-image: radial-gradient(
1835
+ black var(--mask-radius),
1836
+ transparent 75%
1837
+ );
1838
+ }
1839
+
1840
+ @keyframes rotate {
1841
+ to {
1842
+ --angle: 360deg;
1843
+ }
1844
+ }
1845
+
1846
+ @media (prefers-reduced-motion: reduce) {
1847
+ .siri-orb::before {
1848
+ animation: none;
1849
+ }
1850
+ }
1851
+ ` })
1852
+ }
1853
+ );
1854
+ };
1855
+ function ot({ ttsError: i }) {
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(nt, { size: "80px" }),
1858
+ i && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1859
+ "Audio playback failed: ",
1860
+ i.message
1861
+ ] }),
1862
+ /* @__PURE__ */ t.jsx("p", { className: "iw-text- iw-text-gray-700", children: "Your AI interviewer is speaking..." })
1863
+ ] });
1864
+ }
1865
+ const ct = ({ state: i, thinkingTime: r, nextPhase: e }) => /* @__PURE__ */ 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: [
1866
+ /* @__PURE__ */ t.jsxs("div", { children: [
1867
+ /* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Get Ready to Answer" }),
1868
+ /* @__PURE__ */ 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." })
1869
+ ] }),
1870
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-justify-center iw-gap-2", children: [
1871
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-1", children: [
1872
+ /* @__PURE__ */ t.jsx(ne, { className: "iw-size-4 iw-text-orange-600" }),
1873
+ /* @__PURE__ */ t.jsx("p", { className: "iw-text-gray-700 iw-text-sm", children: "Time to think: " })
1874
+ ] }),
1875
+ /* @__PURE__ */ t.jsx(
1876
+ oe,
1877
+ {
1878
+ total: r,
1879
+ remaining: i.currentPhaseTimeRemaining,
1880
+ size: 50,
1881
+ strokeWidth: 4
1882
+ }
1883
+ )
1884
+ ] }),
1885
+ /* @__PURE__ */ t.jsx("div", { className: "iw-w-full iw-grid iw-grid-cols-1", children: /* @__PURE__ */ t.jsx(
1886
+ Z,
1887
+ {
1888
+ onClick: () => {
1889
+ e();
1890
+ },
1891
+ children: "Start Answering"
1529
1892
  }
1530
- ) : i ? /* @__PURE__ */ r.jsxs(
1893
+ ) })
1894
+ ] }), lt = ({ sttError: i }) => /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-flex-col iw-items-center iw-justify-center iw-h-full", children: [
1895
+ /* @__PURE__ */ t.jsxs("svg", { width: "48", height: "48", viewBox: "0 0 60 60", fill: "none", children: [
1896
+ /* @__PURE__ */ t.jsx(
1897
+ "rect",
1898
+ {
1899
+ width: 60,
1900
+ height: 60,
1901
+ rx: 30,
1902
+ fill: "url(#prefix__paint0_linear_1460_12482)"
1903
+ }
1904
+ ),
1905
+ /* @__PURE__ */ t.jsx(
1906
+ "path",
1907
+ {
1908
+ 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",
1909
+ fill: "#fff"
1910
+ }
1911
+ ),
1912
+ /* @__PURE__ */ t.jsx("defs", { children: /* @__PURE__ */ t.jsxs(
1913
+ "linearGradient",
1914
+ {
1915
+ id: "prefix__paint0_linear_1460_12482",
1916
+ x1: 30,
1917
+ y1: -6.563,
1918
+ x2: 77.813,
1919
+ y2: 54.375,
1920
+ gradientUnits: "userSpaceOnUse",
1921
+ children: [
1922
+ /* @__PURE__ */ t.jsx("stop", { offset: 0.211, stopColor: "#5C92FA" }),
1923
+ /* @__PURE__ */ t.jsx("stop", { offset: 1, stopColor: "#A75FFD" })
1924
+ ]
1925
+ }
1926
+ ) })
1927
+ ] }),
1928
+ /* @__PURE__ */ 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" }),
1929
+ /* @__PURE__ */ 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." }),
1930
+ i && /* @__PURE__ */ t.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1931
+ "Transcription error: ",
1932
+ i.message,
1933
+ i.recoverable && " (attempting to continue)"
1934
+ ] })
1935
+ ] }), dt = (i) => /* @__PURE__ */ t.jsxs(
1936
+ "svg",
1937
+ {
1938
+ xmlns: "http://www.w3.org/2000/svg",
1939
+ width: "24",
1940
+ height: "24",
1941
+ viewBox: "0 0 24 24",
1942
+ fill: "none",
1943
+ stroke: "currentColor",
1944
+ strokeWidth: "2",
1945
+ strokeLinecap: "round",
1946
+ strokeLinejoin: "round",
1947
+ ...i,
1948
+ children: [
1949
+ /* @__PURE__ */ t.jsx("path", { d: "M12 8V4H8" }),
1950
+ /* @__PURE__ */ t.jsx("rect", { width: "16", height: "12", x: "4", y: "8", rx: "2" }),
1951
+ /* @__PURE__ */ t.jsx("path", { d: "M2 14h2" }),
1952
+ /* @__PURE__ */ t.jsx("path", { d: "M20 14h2" }),
1953
+ /* @__PURE__ */ t.jsx("path", { d: "M15 13v2" }),
1954
+ /* @__PURE__ */ t.jsx("path", { d: "M9 13v2" })
1955
+ ]
1956
+ }
1957
+ ), wt = ({
1958
+ question: i,
1959
+ isLoading: r = !1
1960
+ }) => {
1961
+ const { baseColor: e } = W();
1962
+ return /* @__PURE__ */ t.jsx(
1531
1963
  "div",
1532
1964
  {
1533
- className: "iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-border iw-border-indigo-100 iw-p-5",
1534
- style: Qe(e ?? "#8C75FB", 0.85),
1535
- children: [
1536
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-3 iw-mb-3", children: [
1537
- /* @__PURE__ */ r.jsx(
1538
- "div",
1965
+ className: "iw-rounded-xl iw-mb-4 message-animation iw-text-gray-800 iw-p-6 ",
1966
+ style: De(e, 0.85),
1967
+ children: /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-gap-8", children: [
1968
+ /* @__PURE__ */ 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: [
1969
+ /* @__PURE__ */ t.jsx("div", { className: "iw-mt-8", children: /* @__PURE__ */ t.jsx(
1970
+ dt,
1539
1971
  {
1540
- className: "iw-h-12 iw-w-12 iw-rounded-lg iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",
1541
- style: { backgroundColor: e },
1542
- children: "N"
1972
+ className: "iw-h-12 iw-w-12",
1973
+ style: { stroke: e }
1543
1974
  }
1544
- ),
1545
- /* @__PURE__ */ r.jsxs("div", { children: [
1546
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-sm iw-font-semibold", children: "Novara" }),
1547
- /* @__PURE__ */ r.jsx("div", { className: "iw-text-xs iw-text-gray-500", children: "Assistant" })
1548
- ] })
1975
+ ) }),
1976
+ /* @__PURE__ */ t.jsx("div", { className: "iw-absolute iw-bottom-2 iw-translate-x-1/2 iw-flex iw-mt-2", children: /* @__PURE__ */ t.jsx("div", { className: "iw-text-sm", children: "Novara" }) })
1549
1977
  ] }),
1550
- /* @__PURE__ */ r.jsx("p", { className: "iw-text-[15px] iw-leading-6", children: i.question })
1551
- ]
1552
- }
1553
- ) : /* @__PURE__ */ r.jsx(
1554
- "div",
1555
- {
1556
- className: "iw-rounded-xl iw-mb-4 iw-bg-gray-50 iw-text-gray-500 iw-border iw-border-gray-200 iw-p-5 iw-text-center",
1557
- children: /* @__PURE__ */ r.jsx("p", { className: "iw-text-sm", children: "No question available" })
1978
+ r ? /* @__PURE__ */ t.jsxs("div", { className: "iw-animate-pulse iw-w-full iw-space-y-3 iw-mr-10", children: [
1979
+ /* @__PURE__ */ t.jsx("div", { className: "iw-h-5 iw-bg-gray-200 iw-rounded iw-w-full" }),
1980
+ /* @__PURE__ */ t.jsx("div", { className: "iw-h-5 iw-bg-gray-200 iw-rounded iw-w-3/4" })
1981
+ ] }) : /* @__PURE__ */ t.jsx("p", { className: "iw-text-lg iw-leading-8", children: i == null ? void 0 : i.question })
1982
+ ] })
1558
1983
  }
1559
1984
  );
1560
- }, Ke = ({
1985
+ }, ut = ({
1986
+ confirmExitInterview: i,
1987
+ isOpen: r,
1988
+ onClose: e
1989
+ }) => /* @__PURE__ */ t.jsx(fe, { isOpen: r, onClose: e, title: "Exit Interview", children: /* @__PURE__ */ t.jsxs("div", { className: "iw-space-y-4", children: [
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
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-justify-end iw-space-x-2", children: [
1992
+ /* @__PURE__ */ t.jsx(
1993
+ "button",
1994
+ {
1995
+ className: "iw-px-4 iw-py-2 iw-bg-gray-200 iw-rounded iw-text-gray-700 iw-font-medium",
1996
+ onClick: e,
1997
+ children: "Cancel"
1998
+ }
1999
+ ),
2000
+ /* @__PURE__ */ t.jsx(
2001
+ "button",
2002
+ {
2003
+ className: "iw-px-4 iw-py-2 iw-bg-red-600 iw-text-white iw-rounded iw-font-medium",
2004
+ onClick: i,
2005
+ children: "Confirm Exit"
2006
+ }
2007
+ )
2008
+ ] })
2009
+ ] }) }), ht = ({ title: i, onExit: r }) => {
2010
+ const { baseColor: e } = W(), [o, s] = T(!1);
2011
+ return /* @__PURE__ */ t.jsxs("header", { className: "iw-w-full iw-text-gray-900", children: [
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
+ /* @__PURE__ */ t.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
2014
+ /* @__PURE__ */ t.jsx(
2015
+ "div",
2016
+ {
2017
+ className: "iw-h-7 iw-w-7 iw-rounded-md iw-flex iw-items-center iw-justify-center iw-text-white iw-font-semibold",
2018
+ style: { backgroundColor: e },
2019
+ children: "N"
2020
+ }
2021
+ ),
2022
+ /* @__PURE__ */ t.jsx("p", { className: "iw-text-sm iw-font-medium", children: "Novara" })
2023
+ ] }),
2024
+ /* @__PURE__ */ t.jsx("h1", { className: "iw-text-base iw-font-bold", children: i }),
2025
+ /* @__PURE__ */ t.jsx(
2026
+ "button",
2027
+ {
2028
+ className: "iw-text-sm iw-text-gray-500 hover:iw-text-gray-700",
2029
+ onClick: () => s(!0),
2030
+ children: "Exit Interview"
2031
+ }
2032
+ )
2033
+ ] }),
2034
+ /* @__PURE__ */ t.jsx("div", { className: "iw-h-px iw-bg-gray-200" }),
2035
+ /* @__PURE__ */ t.jsx(
2036
+ ut,
2037
+ {
2038
+ isOpen: o,
2039
+ confirmExitInterview: () => {
2040
+ r(), s(!1);
2041
+ },
2042
+ onClose: () => s(!1)
2043
+ }
2044
+ )
2045
+ ] });
2046
+ }, mt = ({
1561
2047
  interviewId: i,
1562
- onComplete: t,
2048
+ onComplete: r,
1563
2049
  className: e = ""
1564
2050
  }) => {
1565
- const a = Oe(), { baseColor: s } = F(), { baseUrl: c } = Te(), { timers: n, stt: o, tts: m } = Ie(), [g, d] = y(null), [u, h] = y(""), [x, k] = y(!1), j = D(""), N = D(null), w = {
1566
- thinkingTime: (n == null ? void 0 : n.thinkingDuration) || 30,
1567
- answeringTime: (n == null ? void 0 : n.answeringDuration) || 120,
1568
- editingTime: (n == null ? void 0 : n.editingDuration) || 30,
1569
- totalTime: (n == null ? void 0 : n.totalInterviewDuration) || 600,
1570
- minimumBufferTime: (n == null ? void 0 : n.minimumTimeForNextQuestion) || 120
1571
- }, {
1572
- thinkingTime: p,
1573
- answeringTime: T,
1574
- editingTime: S,
1575
- totalTime: ie,
1576
- minimumBufferTime: re
1577
- } = w;
1578
- A(() => {
1579
- j.current = u;
1580
- }, [u]);
1581
- const _ = D(!1), {
1582
- speak: te,
1583
- isPlaying: se,
1584
- error: W
1585
- } = Ue({
2051
+ const o = We(), { baseUrl: s, authToken: c } = Se(), { timers: a, stt: n, tts: w } = Ce(), [m, d] = T(null), [h, u] = T(""), g = S(""), y = S(null), k = {
2052
+ thinkingTime: (a == null ? void 0 : a.thinkingDuration) || 30,
2053
+ answeringTime: (a == null ? void 0 : a.answeringDuration) || 120,
2054
+ editingTime: (a == null ? void 0 : a.editingDuration) || 30
2055
+ }, { thinkingTime: j, answeringTime: l, editingTime: p } = k;
2056
+ P(() => {
2057
+ g.current = h;
2058
+ }, [h]);
2059
+ const I = S(!1), { speak: b, error: _ } = Je({
1586
2060
  config: {
1587
- baseUrl: c,
1588
- provider: m == null ? void 0 : m.provider
2061
+ baseUrl: s,
2062
+ provider: w == null ? void 0 : w.provider,
2063
+ authToken: c
1589
2064
  },
1590
2065
  onEnd: () => {
1591
- console.log("TTS playback completed"), _.current = !1, E();
2066
+ I.current = !1, E();
1592
2067
  },
1593
- onError: (f) => {
1594
- console.error("TTS Error:", f), _.current || (_.current = !0, E());
2068
+ onError: () => {
2069
+ I.current || (I.current = !0, E());
1595
2070
  }
1596
- }), G = D(!1), L = D(!1), {
1597
- startRecording: z,
1598
- stopRecording: Y,
1599
- transcribe: K,
1600
- isRecording: ne,
1601
- isTranscribing: ae,
1602
- error: M
1603
- } = _e({
2071
+ }), x = S(!1), N = S(!1), {
2072
+ startRecording: C,
2073
+ stopRecording: M,
2074
+ transcribe: q,
2075
+ error: U
2076
+ } = Ye({
1604
2077
  config: {
1605
- baseUrl: c,
1606
- provider: o == null ? void 0 : o.provider,
1607
- model: o == null ? void 0 : o.model,
1608
- language: o == null ? void 0 : o.language
2078
+ baseUrl: s,
2079
+ provider: n == null ? void 0 : n.provider,
2080
+ model: n == null ? void 0 : n.model,
2081
+ language: n == null ? void 0 : n.language,
2082
+ authToken: c
1609
2083
  },
1610
2084
  onStart: () => {
1611
- console.log("STT recording started"), G.current = !1, L.current = !1;
2085
+ x.current = !1, N.current = !1;
1612
2086
  },
1613
2087
  onStop: () => {
1614
- console.log("STT recording stopped");
1615
2088
  },
1616
2089
  onTranscriptionComplete: (f) => {
1617
- console.log("Transcription completed:", f), h(f.transcript), L.current || (L.current = !0, E());
2090
+ u(f.transcript), N.current || (N.current = !0, E());
1618
2091
  },
1619
2092
  onError: (f) => {
1620
- console.error("STT Error:", f), G.current || (G.current = !0, E());
2093
+ console.error("STT Error:", f), x.current || (x.current = !0, E());
1621
2094
  }
1622
- }), { state: R, startQuestion: Q, nextPhase: E } = De({
2095
+ }), { state: L, startQuestion: O, nextPhase: E, completeInterview: B } = Ge({
1623
2096
  config: {
1624
- thinkingDuration: p,
1625
- answeringDuration: T,
1626
- editingDuration: S,
1627
- totalInterviewDuration: ie,
1628
- minimumTimeForNextQuestion: re
2097
+ thinkingDuration: j,
2098
+ answeringDuration: l,
2099
+ editingDuration: p
1629
2100
  },
1630
2101
  callbacks: {
1631
2102
  onPhaseChange: (f) => {
1632
- switch (console.log("Phase changed:", f), f) {
1633
- case l.FETCHING_QUESTION:
1634
- oe();
2103
+ switch (f) {
2104
+ case R.FETCHING_QUESTION:
2105
+ H();
1635
2106
  break;
1636
- case l.READING_QUESTION:
1637
- le();
2107
+ case R.READING_QUESTION:
2108
+ ee();
1638
2109
  break;
1639
- case l.ANSWERING:
1640
- de();
2110
+ case R.ANSWERING:
2111
+ te();
1641
2112
  break;
1642
- case l.TRANSCRIBING:
1643
- we();
2113
+ case R.TRANSCRIBING:
2114
+ G();
1644
2115
  break;
1645
- case l.SUBMITTING:
1646
- ce();
2116
+ case R.SUBMITTING:
2117
+ z();
1647
2118
  break;
1648
2119
  }
1649
2120
  },
1650
2121
  onInterviewEnd: () => {
1651
- t == null || t();
2122
+ r == null || r();
1652
2123
  }
1653
2124
  }
1654
- }), { execute: oe } = Pe(
2125
+ });
2126
+ P(() => {
2127
+ O();
2128
+ }, []);
2129
+ const { execute: H, loading: K } = qe(
1655
2130
  async () => {
1656
- var P, J;
1657
- const f = await a.generateQuestion({
2131
+ var F, Y;
2132
+ const f = await o.generateQuestion({
1658
2133
  interviewId: i,
1659
- isInterviewDone: R.totalTimeRemaining < 120,
1660
- question: ((P = N.current) == null ? void 0 : P.question) || "",
1661
- qnaId: ((J = N.current) == null ? void 0 : J.qna_id) || "",
1662
- answer: j.current
2134
+ question: ((F = y.current) == null ? void 0 : F.question) || "",
2135
+ qnaId: ((Y = y.current) == null ? void 0 : Y.qna_id) || "",
2136
+ answer: g.current
1663
2137
  });
1664
- return N.current = f.data, f;
2138
+ return y.current = f.data, f;
1665
2139
  },
1666
2140
  {
1667
2141
  onSuccess: async (f) => {
1668
- console.log("Questions fetched successfully", f), f && f.data && (h(""), d(f.data), E());
2142
+ f && f.data && (u(""), d(f.data), E());
1669
2143
  },
1670
2144
  onError: (f) => {
1671
2145
  console.error("Failed to fetch questions:", f);
1672
2146
  }
1673
2147
  }
1674
- ), ce = v(async () => {
1675
- console.log("Answer submitted successfully"), await Be(1500), Q();
1676
- }, [Q]), le = v(async () => {
2148
+ ), z = A(async () => {
2149
+ O();
2150
+ }, [O]), ee = A(async () => {
1677
2151
  var f;
1678
- if ((f = N.current) != null && f.question)
2152
+ if ((f = y.current) != null && f.question)
1679
2153
  try {
1680
- _.current = !1, console.log("Starting TTS for question"), await te(N.current.question);
1681
- } catch (P) {
1682
- console.error("Failed to speak question:", P);
2154
+ I.current = !1, await b(y.current.question), y.current.is_interview_done && (await Pe(2e3), B());
2155
+ } catch (F) {
2156
+ console.error("Failed to speak question:", F);
1683
2157
  }
1684
2158
  else
1685
2159
  E();
1686
- }, []), de = v(async () => {
1687
- console.log("Starting recording...");
2160
+ }, [b, E, B]), te = A(async () => {
1688
2161
  try {
1689
- const f = T;
1690
- console.log("🚀 ~ maxDuration:", f), await z(f);
2162
+ await C(l);
1691
2163
  } catch (f) {
1692
2164
  console.error("Failed to start recording:", f), E();
1693
2165
  }
1694
- }, [z, E]), we = v(async () => {
1695
- console.log("Stopping recording and processing STT...");
2166
+ }, [C, E]), G = A(async () => {
1696
2167
  try {
1697
- const f = await Y();
1698
- console.log("Recording stopped, audio blob size:", f.size), await K(f);
2168
+ const f = await M();
2169
+ await q(f);
1699
2170
  } catch (f) {
1700
- console.error("STT processing failed:", f), !G.current && !L.current && (G.current = !0, E());
2171
+ console.error("STT processing failed:", f), !x.current && !N.current && (x.current = !0, E());
1701
2172
  }
1702
- }, [Y, K, E]), ue = () => {
1703
- const { phase: f } = R;
2173
+ }, [M, q, E]), re = () => {
2174
+ const { phase: f } = L;
1704
2175
  switch (f) {
1705
- case l.IDLE:
1706
- return /* @__PURE__ */ r.jsx("div", { className: "iw-text-center iw-py-8", children: /* @__PURE__ */ r.jsx("p", { className: "iw-text-gray-600", children: "Ready to start..." }) });
1707
- case l.FETCHING_QUESTION:
1708
- return /* @__PURE__ */ r.jsx("div", { className: "iw-space-y-4" });
1709
- case l.READING_QUESTION:
1710
- return /* @__PURE__ */ r.jsx("div", { className: "iw-space-y-4", children: /* @__PURE__ */ r.jsxs("div", { className: "iw-p-4 iw-bg-indigo-50 iw-border iw-border-indigo-200 iw-rounded-lg", children: [
1711
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
1712
- /* @__PURE__ */ r.jsx("div", { className: "iw-w-3 iw-h-3 iw-bg-indigo-500 iw-rounded-full iw-animate-pulse" }),
1713
- /* @__PURE__ */ r.jsx("span", { className: "iw-text-sm iw-font-medium iw-text-indigo-700", children: se ? "Playing question audio..." : "Reading the question..." })
1714
- ] }),
1715
- W && /* @__PURE__ */ r.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1716
- "Audio playback failed: ",
1717
- W.message
1718
- ] })
1719
- ] }) });
1720
- case l.THINKING:
1721
- case l.ANSWERING:
1722
- return /* @__PURE__ */ r.jsx("div", { className: "iw-space-y-4", children: f === l.ANSWERING && /* @__PURE__ */ r.jsxs("div", { className: "iw-p-4 iw-bg-red-50 iw-border iw-border-red-200 iw-rounded-lg", children: [
1723
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
1724
- /* @__PURE__ */ r.jsx("div", { className: "iw-w-3 iw-h-3 iw-bg-red-500 iw-rounded-full iw-animate-pulse" }),
1725
- /* @__PURE__ */ r.jsx("span", { className: "iw-text-sm iw-font-medium iw-text-red-700", children: ne ? "Recording in progress..." : "Preparing to record..." })
1726
- ] }),
1727
- M && /* @__PURE__ */ r.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1728
- "Recording error: ",
1729
- M.message
1730
- ] })
1731
- ] }) });
1732
- case l.TRANSCRIBING:
1733
- return /* @__PURE__ */ r.jsx("div", { className: "iw-space-y-4", children: /* @__PURE__ */ r.jsxs("div", { className: "iw-p-4 iw-bg-purple-50 iw-border iw-border-purple-200 iw-rounded-lg", children: [
1734
- /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
1735
- /* @__PURE__ */ r.jsx("div", { className: "iw-animate-spin iw-h-4 iw-w-4 iw-border-2 iw-border-purple-500 iw-border-t-transparent iw-rounded-full" }),
1736
- /* @__PURE__ */ r.jsx("span", { className: "iw-text-sm iw-font-medium iw-text-purple-700", children: ae ? "Transcribing your speech..." : "Processing audio..." })
1737
- ] }),
1738
- M && /* @__PURE__ */ r.jsxs("div", { className: "iw-mt-2 iw-text-xs iw-text-red-600", children: [
1739
- "Transcription error: ",
1740
- M.message,
1741
- M.recoverable && " (attempting to continue)"
1742
- ] })
1743
- ] }) });
1744
- case l.EDITING:
1745
- return /* @__PURE__ */ r.jsx("div", { className: "iw-space-y-4", children: /* @__PURE__ */ r.jsx(
1746
- ze,
2176
+ case R.IDLE:
2177
+ 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: [
2178
+ /* @__PURE__ */ t.jsx("h3", { className: "iw-text-lg iw-font-semibold iw-text-gray-900 iw-mb-1", children: "Ready to start the Interview?" }),
2179
+ /* @__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.` }),
2180
+ /* @__PURE__ */ t.jsx(Z, { onClick: O, className: "iw-mt-2 iw-w-40", children: "Start Interview" })
2181
+ ] });
2182
+ case R.FETCHING_QUESTION:
2183
+ return /* @__PURE__ */ t.jsx(st, {});
2184
+ case R.READING_QUESTION:
2185
+ return /* @__PURE__ */ t.jsx(ot, { ttsError: _ });
2186
+ case R.THINKING:
2187
+ return /* @__PURE__ */ t.jsx(
2188
+ ct,
1747
2189
  {
1748
- value: u,
1749
- onChange: (P) => h(P.target.value),
1750
- onSubmit: () => E(),
1751
- isSubmitDisabled: !u.trim(),
1752
- remainingTimeText: `${R.currentPhaseTimeRemaining}s remaining`
2190
+ state: L,
2191
+ thinkingTime: j,
2192
+ nextPhase: E
1753
2193
  }
1754
- ) });
1755
- case l.SUBMITTING:
1756
- return /* @__PURE__ */ r.jsx("div", { className: "iw-space-y-4", children: /* @__PURE__ */ r.jsx("div", { className: "iw-p-4 iw-bg-green-50 iw-border iw-border-green-200 iw-rounded-lg", children: /* @__PURE__ */ r.jsxs("div", { className: "iw-flex iw-items-center iw-space-x-2", children: [
1757
- /* @__PURE__ */ r.jsx("div", { className: "iw-animate-spin iw-h-4 iw-w-4 iw-border-2 iw-border-green-500 iw-border-t-transparent iw-rounded-full" }),
1758
- /* @__PURE__ */ r.jsx("span", { className: "iw-text-sm iw-font-medium iw-text-green-700", children: "Submitting your answer..." })
1759
- ] }) }) });
1760
- case l.COMPLETED:
1761
- return /* @__PURE__ */ r.jsxs("div", { className: "iw-text-center iw-py-8", children: [
1762
- /* @__PURE__ */ r.jsx("div", { className: "iw-mb-4", children: /* @__PURE__ */ r.jsx(
1763
- "svg",
1764
- {
1765
- className: "iw-w-16 iw-h-16 iw-mx-auto iw-text-green-500",
1766
- fill: "none",
1767
- stroke: "currentColor",
1768
- viewBox: "0 0 24 24",
1769
- children: /* @__PURE__ */ r.jsx(
1770
- "path",
1771
- {
1772
- strokeLinecap: "round",
1773
- strokeLinejoin: "round",
1774
- strokeWidth: 2,
1775
- d: "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
1776
- }
1777
- )
1778
- }
1779
- ) }),
1780
- /* @__PURE__ */ r.jsx("h3", { className: "iw-text-xl iw-font-bold iw-text-gray-900 iw-mb-2", children: "Interview Complete!" }),
1781
- /* @__PURE__ */ r.jsx("p", { className: "iw-text-gray-600", children: "Thank you for your time. Your answers have been recorded." })
1782
- ] });
1783
- default:
1784
- return null;
1785
- }
1786
- };
1787
- return /* @__PURE__ */ r.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ r.jsxs(
1788
- "div",
1789
- {
1790
- className: ` iw-max-w-3xl iw-mx-auto iw-space-y-4 iw-py-8 ${e}`,
1791
- children: [
1792
- R.phase !== l.IDLE && R.phase !== l.COMPLETED && /* @__PURE__ */ r.jsx(
1793
- Ye,
2194
+ );
2195
+ case R.ANSWERING:
2196
+ return /* @__PURE__ */ t.jsx(
2197
+ it,
1794
2198
  {
1795
- question: g,
1796
- isLoading: R.phase === l.FETCHING_QUESTION
2199
+ state: L,
2200
+ answeringTime: l,
2201
+ nextPhase: E,
2202
+ sttError: U
1797
2203
  }
1798
- ),
1799
- /* @__PURE__ */ r.jsx("div", { className: "iw-bg-white iw-rounded-lg iw-shadow-md iw-p-6", children: ue() }),
1800
- /* @__PURE__ */ r.jsx(
1801
- He,
2204
+ );
2205
+ case R.TRANSCRIBING:
2206
+ return /* @__PURE__ */ t.jsx(lt, { sttError: U });
2207
+ case R.EDITING:
2208
+ case R.SUBMITTING:
2209
+ return /* @__PURE__ */ t.jsx("div", { className: "iw-space-y-4 iw-h-full", children: /* @__PURE__ */ t.jsx(
2210
+ et,
1802
2211
  {
1803
- state: R,
1804
- defaultTimers: {
1805
- thinking: p,
1806
- answering: T,
1807
- editing: S
1808
- }
2212
+ value: h,
2213
+ onChange: (F) => u(F.target.value),
2214
+ onSubmit: () => E(),
2215
+ isSubmitDisabled: !h.trim() || K,
2216
+ state: L,
2217
+ editingTime: p
1809
2218
  }
1810
- ),
1811
- x && (R.phase === l.THINKING || R.phase === l.ANSWERING || R.phase === l.EDITING) && /* @__PURE__ */ r.jsx($, { onClick: E, children: "Next Phase" }),
1812
- !x && /* @__PURE__ */ r.jsx("div", { className: "iw-text-center iw-py-12 w-full", children: /* @__PURE__ */ r.jsx(
1813
- $,
2219
+ ) });
2220
+ case R.COMPLETED:
2221
+ return /* @__PURE__ */ t.jsx("div", { className: "iw-fixed iw-inset-0 iw-bg-white", children: /* @__PURE__ */ t.jsx(
2222
+ at,
1814
2223
  {
1815
- className: "w-full",
1816
- style: { backgroundColor: s },
1817
- onClick: () => {
1818
- Q(), k(!0);
1819
- },
1820
- children: "Start Interview"
2224
+ open: !0,
2225
+ onClose: r || (() => {
2226
+ })
1821
2227
  }
1822
- ) })
1823
- ]
2228
+ ) });
2229
+ default:
2230
+ return null;
1824
2231
  }
1825
- ) });
1826
- }, Je = ({
1827
- interviewId: i,
1828
- title: t = "Interview",
1829
- onInterviewEnd: e,
1830
- className: a = ""
1831
- }) => {
1832
- const [s, c] = y(!1), [n, o] = y(!0), m = D(null);
1833
- if (!s)
1834
- return /* @__PURE__ */ r.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ r.jsx(
1835
- Se,
2232
+ };
2233
+ return /* @__PURE__ */ t.jsxs("div", { className: "interview-widget-container", children: [
2234
+ /* @__PURE__ */ t.jsx(
2235
+ ht,
1836
2236
  {
1837
- isOpen: n,
1838
- onStart: () => {
1839
- console.log("Permissions granted, starting interview"), c(!0), o(!1);
1840
- }
2237
+ title: "Interview for Python Developer",
2238
+ onExit: B
1841
2239
  }
1842
- ) });
1843
- const g = () => {
1844
- e == null || e();
1845
- };
1846
- return /* @__PURE__ */ r.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ r.jsx(
2240
+ ),
2241
+ /* @__PURE__ */ t.jsxs(
2242
+ "div",
2243
+ {
2244
+ className: `iw-p-4 iw-space-y-4 iw-pb-6 ${e} iw-min-h-[calc(100vh_-_3.8rem)] iw-flex iw-flex-col iw-justify-between`,
2245
+ children: [
2246
+ /* @__PURE__ */ t.jsx("div", { className: "iw-flex iw-items-start iw-justify-between iw-gap-3", children: /* @__PURE__ */ t.jsx("div", { className: "iw-flex-1", children: /* @__PURE__ */ t.jsx(
2247
+ wt,
2248
+ {
2249
+ question: m,
2250
+ isLoading: L.phase === R.FETCHING_QUESTION || L.phase === R.IDLE
2251
+ }
2252
+ ) }) }),
2253
+ /* @__PURE__ */ t.jsxs("div", { className: "iw iw-bg-[#F6F6F6] iw-grid iw-grid-cols-2 iw-rounded-xl iw-p-4", children: [
2254
+ /* @__PURE__ */ t.jsx("div", { className: "iw-min-h-[400px] iw-max-h-[600px]", children: /* @__PURE__ */ t.jsx(Xe, {}) }),
2255
+ /* @__PURE__ */ t.jsx("div", { className: "iw-bg-white iw-rounded-lg iw-shadow iw-p-6", children: re() })
2256
+ ] })
2257
+ ]
2258
+ }
2259
+ )
2260
+ ] });
2261
+ }, gt = ({
2262
+ interviewId: i,
2263
+ onInterviewEnd: r,
2264
+ className: e = ""
2265
+ }) => {
2266
+ const [o, s] = ce.useState(!1), [c, a] = ce.useState(!0), n = S(null);
2267
+ return o ? /* @__PURE__ */ t.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ t.jsx(
1847
2268
  "div",
1848
2269
  {
1849
- ref: m,
1850
- className: `iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${a}`,
1851
- children: /* @__PURE__ */ r.jsxs("div", { className: " iw-h-full iw-flex iw-flex-col", children: [
1852
- /* @__PURE__ */ r.jsx(je, { title: t, onExit: g }),
1853
- /* @__PURE__ */ r.jsx(
1854
- Ke,
1855
- {
1856
- interviewId: i,
1857
- className: a,
1858
- onComplete: e || (() => {
1859
- })
1860
- }
1861
- )
1862
- ] })
2270
+ ref: n,
2271
+ className: `iw-flex iw-flex-col iw-rounded-xl iw-shadow-lg iw-overflow-hidden iw-h-[calc(100vh-1rem)] ${e}`,
2272
+ children: /* @__PURE__ */ t.jsx("div", { className: " iw-h-full iw-flex iw-flex-col", children: /* @__PURE__ */ t.jsx(
2273
+ mt,
2274
+ {
2275
+ interviewId: i,
2276
+ className: e,
2277
+ onComplete: r || (() => {
2278
+ })
2279
+ }
2280
+ ) })
2281
+ }
2282
+ ) }) : /* @__PURE__ */ t.jsx("div", { className: "interview-widget-container", children: /* @__PURE__ */ t.jsx(
2283
+ Le,
2284
+ {
2285
+ isOpen: c,
2286
+ onStart: () => {
2287
+ console.log("Permissions granted, starting interview"), s(!0), a(!1);
2288
+ }
1863
2289
  }
1864
2290
  ) });
1865
2291
  };
1866
2292
  typeof window < "u" && (window.InterviewWidget = {
1867
- InterviewWidget: Je,
1868
- InterviewWidgetProvider: Ne
2293
+ InterviewWidget: gt,
2294
+ InterviewWidgetProvider: Re
1869
2295
  });
1870
2296
  export {
1871
- Je as InterviewWidget,
1872
- Ne as InterviewWidgetProvider,
1873
- Je as default
2297
+ gt as InterviewWidget,
2298
+ Re as InterviewWidgetProvider,
2299
+ gt as default
1874
2300
  };