@vanira/sdk 0.0.85 → 0.0.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  var H = Object.defineProperty;
2
2
  var G = (a, e, t) => e in a ? H(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var l = (a, e, t) => G(a, typeof e != "symbol" ? e + "" : e, t);
3
+ var d = (a, e, t) => G(a, typeof e != "symbol" ? e + "" : e, t);
4
4
  class z {
5
5
  pause() {
6
6
  }
@@ -41,8 +41,8 @@ class Z {
41
41
  }
42
42
  if (i.data instanceof ArrayBuffer) {
43
43
  try {
44
- const n = new TextDecoder().decode(i.data), s = JSON.parse(n);
45
- (s == null ? void 0 : s.event) === "client_tool_call" && t.onMessage({ text: n });
44
+ const n = new TextDecoder().decode(i.data), r = JSON.parse(n);
45
+ (r == null ? void 0 : r.event) === "client_tool_call" && t.onMessage({ text: n });
46
46
  } catch {
47
47
  }
48
48
  return;
@@ -60,7 +60,7 @@ class Z {
60
60
  };
61
61
  }
62
62
  }
63
- const Q = "https://api.vanira.io", u = {
63
+ const Q = "https://api.vanira.io", c = {
64
64
  Form: "vanira_form",
65
65
  Calendar: "vanira_calendar",
66
66
  Navigate: "vanira_navigate",
@@ -82,8 +82,11 @@ const Q = "https://api.vanira.io", u = {
82
82
  PointAt: "vanira_point_at",
83
83
  DrawOnScreen: "vanira_draw_on_screen",
84
84
  ClearScreenDraw: "vanira_clear_screen_draw",
85
- HighlightOnScreen: "vanira_highlight_on_screen"
86
- }, F = Object.values(u), ee = new Set(F);
85
+ HighlightOnScreen: "vanira_highlight_on_screen",
86
+ KycDocumentCapture: "vanira_kyc_document_capture",
87
+ KycSelfieCapture: "vanira_kyc_selfie_capture",
88
+ KycSignatureCapture: "vanira_kyc_signature_capture"
89
+ }, F = Object.values(c), ee = new Set(F);
87
90
  function V(a) {
88
91
  return !!a && ee.has(a);
89
92
  }
@@ -97,45 +100,60 @@ function j(a) {
97
100
  return a && typeof a == "object" ? a : {};
98
101
  }
99
102
  const N = {
100
- type_on_whiteboard: u.TypeText,
101
- write_on_whiteboard: u.TypeText,
102
- write_on_white_board: u.TypeText,
103
- dom_typing_simulation: u.TypeText,
104
- write_latex_text: u.WriteLatexText,
105
- write_latex_on_board: u.WriteLatexText,
106
- latex_on_whiteboard: u.WriteLatexText,
107
- erase_text: u.EraseText,
108
- dom_erase: u.EraseText,
109
- open_live_camera: u.LiveVision,
110
- live_vision: u.LiveVision,
111
- close_live_camera: u.CloseLiveCamera,
112
- stop_live_camera: u.CloseLiveCamera,
113
- open_live_screen: u.LiveScreen,
114
- close_live_screen: u.CloseLiveScreen,
115
- screen_vision: u.ScreenVision,
116
- capture_screen_vision: u.ScreenVision,
117
- capture_screen: u.ScreenVision,
118
- tab_screenshot: u.ScreenVision,
119
- capture_tab: u.ScreenVision,
120
- capture_tab_screenshot: u.ScreenVision,
121
- screenshot_tab: u.ScreenVision,
122
- point_at: u.PointAt,
123
- point_at_screen: u.PointAt,
124
- draw_on_screen: u.DrawOnScreen,
125
- screen_draw: u.DrawOnScreen,
126
- clear_screen_draw: u.ClearScreenDraw,
127
- clear_screen_annotations: u.ClearScreenDraw,
128
- highlight_on_screen: u.HighlightOnScreen,
129
- highlight_element_on_screen: u.HighlightOnScreen,
130
- highlight_screen_element: u.HighlightOnScreen
131
- }, B = {
132
- vanira_tab_screenshot: u.ScreenVision
103
+ type_on_whiteboard: c.TypeText,
104
+ write_on_whiteboard: c.TypeText,
105
+ write_on_white_board: c.TypeText,
106
+ dom_typing_simulation: c.TypeText,
107
+ write_latex_text: c.WriteLatexText,
108
+ write_latex_on_board: c.WriteLatexText,
109
+ latex_on_whiteboard: c.WriteLatexText,
110
+ erase_text: c.EraseText,
111
+ dom_erase: c.EraseText,
112
+ open_live_camera: c.LiveVision,
113
+ live_vision: c.LiveVision,
114
+ close_live_camera: c.CloseLiveCamera,
115
+ stop_live_camera: c.CloseLiveCamera,
116
+ open_live_screen: c.LiveScreen,
117
+ close_live_screen: c.CloseLiveScreen,
118
+ screen_vision: c.ScreenVision,
119
+ capture_screen_vision: c.ScreenVision,
120
+ capture_screen: c.ScreenVision,
121
+ tab_screenshot: c.ScreenVision,
122
+ capture_tab: c.ScreenVision,
123
+ capture_tab_screenshot: c.ScreenVision,
124
+ screenshot_tab: c.ScreenVision,
125
+ point_at: c.PointAt,
126
+ point_at_screen: c.PointAt,
127
+ draw_on_screen: c.DrawOnScreen,
128
+ screen_draw: c.DrawOnScreen,
129
+ clear_screen_draw: c.ClearScreenDraw,
130
+ clear_screen_annotations: c.ClearScreenDraw,
131
+ highlight_on_screen: c.HighlightOnScreen,
132
+ highlight_element_on_screen: c.HighlightOnScreen,
133
+ highlight_screen_element: c.HighlightOnScreen,
134
+ kyc_document_capture: c.KycDocumentCapture,
135
+ capture_id_document: c.KycDocumentCapture,
136
+ document_capture: c.KycDocumentCapture,
137
+ capture_kyc_document: c.KycDocumentCapture,
138
+ kyc_selfie_capture: c.KycSelfieCapture,
139
+ capture_selfie: c.KycSelfieCapture,
140
+ selfie_capture: c.KycSelfieCapture,
141
+ capture_kyc_selfie: c.KycSelfieCapture,
142
+ kyc_signature_capture: c.KycSignatureCapture,
143
+ capture_kyc_signature: c.KycSignatureCapture,
144
+ signature_capture: c.KycSignatureCapture
145
+ }, D = {
146
+ vanira_tab_screenshot: c.ScreenVision,
147
+ vanira_document_capture: c.KycDocumentCapture,
148
+ vanira_selfie_capture: c.KycSelfieCapture,
149
+ vanira_signature_capture: c.KycSignatureCapture,
150
+ vanira_kyc_signature: c.KycSignatureCapture
133
151
  };
134
152
  function te(a, e) {
135
153
  const t = a.latex_text ?? (e == null ? void 0 : e.latex_text);
136
154
  return typeof t == "string" && t.trim().length > 0;
137
155
  }
138
- function D(a, e) {
156
+ function K(a, e) {
139
157
  const t = a.text_to_type ?? (e == null ? void 0 : e.text_to_type) ?? a.text ?? (e == null ? void 0 : e.text) ?? a.value ?? (e == null ? void 0 : e.value);
140
158
  return typeof t == "string" && t.trim().length > 0;
141
159
  }
@@ -147,31 +165,31 @@ function ne(a, e) {
147
165
  const t = a == null ? void 0 : a.preset_id;
148
166
  if (typeof t == "string") {
149
167
  if (V(t)) return t;
150
- const s = B[t];
151
- if (s) return s;
168
+ const r = D[t];
169
+ if (r) return r;
152
170
  }
153
171
  const n = j(e).preset_id;
154
172
  if (typeof n == "string") {
155
173
  if (V(n)) return n;
156
- const s = B[n];
157
- if (s) return s;
174
+ const r = D[n];
175
+ if (r) return r;
158
176
  }
159
177
  }
160
178
  function ae(a, e, t) {
161
179
  const i = j(e);
162
180
  let n = ne(a, i);
163
- if (n === u.Form && D(i, a) && !ie(i, a))
164
- return u.TypeText;
181
+ if (n === c.Form && K(i, a) && !ie(i, a))
182
+ return c.TypeText;
165
183
  if (n) return n;
166
- const s = String(t ?? "").trim().toLowerCase();
167
- if (s && N[s])
168
- return N[s];
184
+ const r = String(t ?? "").trim().toLowerCase();
185
+ if (r && N[r])
186
+ return N[r];
169
187
  if (te(i, a))
170
- return u.WriteLatexText;
171
- if (D(i, a))
172
- return u.TypeText;
188
+ return c.WriteLatexText;
189
+ if (K(i, a))
190
+ return c.TypeText;
173
191
  }
174
- const g = "vanira_latest_call_id", R = "vanira_prospect_id";
192
+ const g = "vanira_latest_call_id", k = "vanira_prospect_id";
175
193
  function C(a) {
176
194
  return `vanira_latest_call_id_${a}`;
177
195
  }
@@ -181,7 +199,7 @@ function I(a) {
181
199
  function W(a) {
182
200
  return `vanira_call_meta_${a}`;
183
201
  }
184
- function S(a, e) {
202
+ function w(a, e) {
185
203
  if (!a) return null;
186
204
  try {
187
205
  return a.getItem(e);
@@ -189,38 +207,38 @@ function S(a, e) {
189
207
  return null;
190
208
  }
191
209
  }
192
- function $(a) {
210
+ function B(a) {
193
211
  if (typeof window > "u" || !a) return null;
194
- const e = [], t = S(window.localStorage, W(a));
212
+ const e = [], t = w(window.localStorage, W(a));
195
213
  if (t)
196
214
  try {
197
- const d = JSON.parse(t);
198
- d != null && d.callId && e.push({
199
- callId: d.callId,
200
- prospectId: d.prospectId,
201
- updatedAt: d.updatedAt || 0
215
+ const h = JSON.parse(t);
216
+ h != null && h.callId && e.push({
217
+ callId: h.callId,
218
+ prospectId: h.prospectId,
219
+ updatedAt: h.updatedAt || 0
202
220
  });
203
221
  } catch {
204
222
  }
205
- const i = (d, r, h) => {
206
- d && e.push({
207
- callId: d,
208
- prospectId: r || void 0,
209
- updatedAt: h
223
+ const i = (h, s, u) => {
224
+ h && e.push({
225
+ callId: h,
226
+ prospectId: s || void 0,
227
+ updatedAt: u
210
228
  });
211
- }, n = S(window.localStorage, I(a)), s = S(window.sessionStorage, I(a)), o = S(window.localStorage, R);
229
+ }, n = w(window.localStorage, I(a)), r = w(window.sessionStorage, I(a)), o = w(window.localStorage, k);
212
230
  return i(
213
- S(window.localStorage, C(a)),
231
+ w(window.localStorage, C(a)),
214
232
  n || o,
215
233
  2
216
234
  ), i(
217
- S(window.sessionStorage, C(a)),
218
- s || o,
235
+ w(window.sessionStorage, C(a)),
236
+ r || o,
219
237
  1
220
- ), i(S(window.localStorage, g), o, 0), i(S(window.sessionStorage, g), o, 0), e.length ? (e.sort((d, r) => r.updatedAt - d.updatedAt), e[0]) : null;
238
+ ), i(w(window.localStorage, g), o, 0), i(w(window.sessionStorage, g), o, 0), e.length ? (e.sort((h, s) => s.updatedAt - h.updatedAt), e[0]) : null;
221
239
  }
222
- function se(a, e, t) {
223
- var n, s, o, d, r, h, p, c, _;
240
+ function re(a, e, t) {
241
+ var n, r, o, h, s, u, p, l, _;
224
242
  if (typeof window > "u" || !a || !e) return;
225
243
  const i = {
226
244
  callId: e,
@@ -228,11 +246,11 @@ function se(a, e, t) {
228
246
  updatedAt: Date.now()
229
247
  };
230
248
  try {
231
- (n = window.localStorage) == null || n.setItem(W(a), JSON.stringify(i)), (s = window.localStorage) == null || s.setItem(C(a), e), (o = window.sessionStorage) == null || o.setItem(C(a), e), t && ((d = window.localStorage) == null || d.setItem(I(a), t), (r = window.sessionStorage) == null || r.setItem(I(a), t)), (h = window.localStorage) == null || h.setItem(g, e), (p = window.sessionStorage) == null || p.setItem(g, e), t && ((c = window.localStorage) == null || c.setItem(R, t), (_ = window.sessionStorage) == null || _.setItem(R, t));
249
+ (n = window.localStorage) == null || n.setItem(W(a), JSON.stringify(i)), (r = window.localStorage) == null || r.setItem(C(a), e), (o = window.sessionStorage) == null || o.setItem(C(a), e), t && ((h = window.localStorage) == null || h.setItem(I(a), t), (s = window.sessionStorage) == null || s.setItem(I(a), t)), (u = window.localStorage) == null || u.setItem(g, e), (p = window.sessionStorage) == null || p.setItem(g, e), t && ((l = window.localStorage) == null || l.setItem(k, t), (_ = window.sessionStorage) == null || _.setItem(k, t));
232
250
  } catch {
233
251
  }
234
252
  }
235
- const re = /* @__PURE__ */ new Set([
253
+ const se = /* @__PURE__ */ new Set([
236
254
  "client_tool_call",
237
255
  "clearAudio",
238
256
  "client_tool_cancel"
@@ -240,7 +258,7 @@ const re = /* @__PURE__ */ new Set([
240
258
  function oe(a) {
241
259
  if (!a || typeof a != "object") return !1;
242
260
  const e = a.event;
243
- return typeof e == "string" && re.has(e);
261
+ return typeof e == "string" && se.has(e);
244
262
  }
245
263
  const T = 16 * 1024, ce = 256 * 1024;
246
264
  function E(a, e) {
@@ -263,7 +281,7 @@ async function de(a, e, t = 8e3) {
263
281
  }
264
282
  return E(a, e);
265
283
  }
266
- async function K(a) {
284
+ async function $(a) {
267
285
  for (; a.bufferedAmount > ce; )
268
286
  await new Promise((e) => setTimeout(e, 10));
269
287
  }
@@ -273,42 +291,42 @@ async function he(a) {
273
291
  filename: t,
274
292
  contentType: i,
275
293
  reason: n,
276
- message: s,
294
+ message: r,
277
295
  callId: o,
278
- mediaBytesChannel: d,
279
- sendControlEvent: r,
280
- uploadId: h = crypto.randomUUID(),
296
+ mediaBytesChannel: h,
297
+ sendControlEvent: s,
298
+ uploadId: u = crypto.randomUUID(),
281
299
  uploadKind: p = "media"
282
- } = a, c = e.byteLength, _ = c === 0 ? 0 : Math.ceil(c / T);
283
- r("client_media_upload_start", {
300
+ } = a, l = e.byteLength, _ = l === 0 ? 0 : Math.ceil(l / T);
301
+ s("client_media_upload_start", {
284
302
  data: {
285
- upload_id: h,
303
+ upload_id: u,
286
304
  call_id: o,
287
305
  reason: n,
288
- message: s,
306
+ message: r,
289
307
  filename: t,
290
308
  content_type: i,
291
- size: c,
309
+ size: l,
292
310
  chunk_count: _,
293
311
  upload_kind: p
294
312
  }
295
313
  });
296
314
  const m = new Uint8Array(e);
297
- for (let f = 0; f < c; f += T) {
298
- await K(d);
299
- const v = Math.min(f + T, c);
300
- d.send(m.subarray(f, v));
315
+ for (let f = 0; f < l; f += T) {
316
+ await $(h);
317
+ const S = Math.min(f + T, l);
318
+ h.send(m.subarray(f, S));
301
319
  }
302
- return await K(d), r("client_media_upload_complete", {
320
+ return await $(h), s("client_media_upload_complete", {
303
321
  data: {
304
- upload_id: h,
322
+ upload_id: u,
305
323
  call_id: o,
306
324
  reason: n,
307
- message: s,
325
+ message: r,
308
326
  chunk_count: _,
309
327
  upload_kind: p
310
328
  }
311
- }), { media_id: h, url: "", content_type: i };
329
+ }), { media_id: u, url: "", content_type: i };
312
330
  }
313
331
  async function ue(a) {
314
332
  return typeof a.arrayBuffer == "function" ? a.arrayBuffer() : new Response(a).arrayBuffer();
@@ -316,25 +334,25 @@ async function ue(a) {
316
334
  function pe(a) {
317
335
  return null;
318
336
  }
319
- function y() {
337
+ function v() {
320
338
  return typeof window > "u" ? "/" : `${window.location.pathname}${window.location.search}${window.location.hash}` || "/";
321
339
  }
322
340
  class _e {
323
341
  constructor(e) {
324
- l(this, "active", !1);
325
- l(this, "initialSent", !1);
326
- l(this, "lastRoute", "");
327
- l(this, "sendContext");
328
- l(this, "isReady");
329
- l(this, "cleanupFns", []);
330
- l(this, "initialRetryTimer", null);
331
- l(this, "routePollTimer", null);
332
- l(this, "originalPushState", null);
333
- l(this, "originalReplaceState", null);
342
+ d(this, "active", !1);
343
+ d(this, "initialSent", !1);
344
+ d(this, "lastRoute", "");
345
+ d(this, "sendContext");
346
+ d(this, "isReady");
347
+ d(this, "cleanupFns", []);
348
+ d(this, "initialRetryTimer", null);
349
+ d(this, "routePollTimer", null);
350
+ d(this, "originalPushState", null);
351
+ d(this, "originalReplaceState", null);
334
352
  this.sendContext = e.sendContext, this.isReady = e.isReady ?? (() => !0);
335
353
  }
336
354
  start() {
337
- typeof window > "u" || this.active || (this.active = !0, this.initialSent = !1, this.lastRoute = y(), this.attachListeners(), this.scheduleInitialContextSend());
355
+ typeof window > "u" || this.active || (this.active = !0, this.initialSent = !1, this.lastRoute = v(), this.attachListeners(), this.scheduleInitialContextSend());
338
356
  }
339
357
  stop() {
340
358
  if (!(!this.active && this.cleanupFns.length === 0)) {
@@ -364,14 +382,14 @@ class _e {
364
382
  }
365
383
  }
366
384
  attachListeners() {
367
- const e = (s, o = 0) => {
368
- const d = () => {
369
- const r = y();
370
- r !== this.lastRoute && this.handleRouteChange(r, s);
385
+ const e = (r, o = 0) => {
386
+ const h = () => {
387
+ const s = v();
388
+ s !== this.lastRoute && this.handleRouteChange(s, r);
371
389
  };
372
- o > 0 ? window.setTimeout(d, o) : queueMicrotask(d);
373
- }, t = () => e("popstate"), i = () => e("hashchange"), n = (s) => {
374
- const o = s.detail;
390
+ o > 0 ? window.setTimeout(h, o) : queueMicrotask(h);
391
+ }, t = () => e("popstate"), i = () => e("hashchange"), n = (r) => {
392
+ const o = r.detail;
375
393
  if ((o == null ? void 0 : o.initiated_by) === "agent") {
376
394
  e("vanira_navigate_agent", 120);
377
395
  return;
@@ -382,14 +400,14 @@ class _e {
382
400
  () => window.removeEventListener("popstate", t),
383
401
  () => window.removeEventListener("hashchange", i),
384
402
  () => window.removeEventListener("vanira:navigate", n)
385
- ), this.originalPushState = history.pushState.bind(history), this.originalReplaceState = history.replaceState.bind(history), history.pushState = (...s) => {
386
- this.originalPushState(...s), e("pushState");
387
- }, history.replaceState = (...s) => {
388
- this.originalReplaceState(...s), e("replaceState");
403
+ ), this.originalPushState = history.pushState.bind(history), this.originalReplaceState = history.replaceState.bind(history), history.pushState = (...r) => {
404
+ this.originalPushState(...r), e("pushState");
405
+ }, history.replaceState = (...r) => {
406
+ this.originalReplaceState(...r), e("replaceState");
389
407
  }, this.routePollTimer = window.setInterval(() => {
390
408
  if (!this.active) return;
391
- const s = y();
392
- s !== this.lastRoute && this.handleRouteChange(s, "location_poll");
409
+ const r = v();
410
+ r !== this.lastRoute && this.handleRouteChange(r, "location_poll");
393
411
  }, 1e3);
394
412
  }
395
413
  handleRouteChange(e, t) {
@@ -403,63 +421,63 @@ class _e {
403
421
  !this.isReady() || pe() || this.sendRouteContext("route_changed", i, t, "user");
404
422
  }
405
423
  sendRouteContext(e, t, i, n = "user") {
406
- const s = y();
407
- this.lastRoute = s;
424
+ const r = v();
425
+ this.lastRoute = r;
408
426
  const o = {
409
427
  ui_state: "page_navigation",
410
428
  navigation_led_by: n,
411
- current_route: s,
412
- current_page: s,
429
+ current_route: r,
430
+ current_page: r,
413
431
  user_action: e === "call_started" ? "call_started_on_page" : "user_navigated"
414
432
  };
415
- e === "call_started" ? o.message = `User started the call while viewing ${s}.` : (o.previous_route = t ?? "", o.message = `User navigated from ${t || "(unknown)"} to ${s}.`, i && (o.navigation_source = i));
433
+ e === "call_started" ? o.message = `User started the call while viewing ${r}.` : (o.previous_route = t ?? "", o.message = `User navigated from ${t || "(unknown)"} to ${r}.`, i && (o.navigation_source = i));
416
434
  try {
417
435
  this.sendContext(o);
418
436
  } catch {
419
437
  }
420
438
  }
421
439
  }
422
- const w = class w {
440
+ const y = class y {
423
441
  constructor(e) {
424
- l(this, "serverUrl");
425
- l(this, "agentId");
426
- l(this, "callId");
427
- l(this, "prospectId");
428
- l(this, "apiKey");
429
- l(this, "backendUrl");
430
- l(this, "token");
431
- l(this, "onConnected");
432
- l(this, "onDisconnected");
433
- l(this, "onError");
434
- l(this, "onTranscription");
435
- l(this, "onLocalStream");
442
+ d(this, "serverUrl");
443
+ d(this, "agentId");
444
+ d(this, "callId");
445
+ d(this, "prospectId");
446
+ d(this, "apiKey");
447
+ d(this, "backendUrl");
448
+ d(this, "token");
449
+ d(this, "onConnected");
450
+ d(this, "onDisconnected");
451
+ d(this, "onError");
452
+ d(this, "onTranscription");
453
+ d(this, "onLocalStream");
436
454
  // @ts-ignore
437
- l(this, "onRemoteTrack");
438
- l(this, "onClientToolCall");
439
- l(this, "onSessionStarted");
440
- l(this, "sessionStartedEmitted", !1);
441
- l(this, "pc", null);
442
- l(this, "dataChannel", null);
443
- l(this, "mediaBytesChannel", null);
444
- l(this, "audioElement", null);
445
- l(this, "localStream", null);
446
- l(this, "micMuted", !1);
447
- l(this, "connected", !1);
448
- l(this, "icePollInterval", null);
449
- l(this, "appliedRemoteCandidates", /* @__PURE__ */ new Set());
450
- l(this, "iceServers");
451
- l(this, "callSessionLoaded", !1);
452
- l(this, "connectGeneration", 0);
453
- l(this, "runtime");
454
- l(this, "sessionBehavior");
455
- l(this, "routeTracker", null);
456
- l(this, "_status", "idle");
457
- l(this, "listeners", /* @__PURE__ */ new Map());
455
+ d(this, "onRemoteTrack");
456
+ d(this, "onClientToolCall");
457
+ d(this, "onSessionStarted");
458
+ d(this, "sessionStartedEmitted", !1);
459
+ d(this, "pc", null);
460
+ d(this, "dataChannel", null);
461
+ d(this, "mediaBytesChannel", null);
462
+ d(this, "audioElement", null);
463
+ d(this, "localStream", null);
464
+ d(this, "micMuted", !1);
465
+ d(this, "connected", !1);
466
+ d(this, "icePollInterval", null);
467
+ d(this, "appliedRemoteCandidates", /* @__PURE__ */ new Set());
468
+ d(this, "iceServers");
469
+ d(this, "callSessionLoaded", !1);
470
+ d(this, "connectGeneration", 0);
471
+ d(this, "runtime");
472
+ d(this, "sessionBehavior");
473
+ d(this, "routeTracker", null);
474
+ d(this, "_status", "idle");
475
+ d(this, "listeners", /* @__PURE__ */ new Map());
458
476
  /** Live vision config — auto-starts camera on connect when scope is full_call. */
459
- l(this, "liveVision");
460
- l(this, "liveVisionAutoStarted", !1);
477
+ d(this, "liveVision");
478
+ d(this, "liveVisionAutoStarted", !1);
461
479
  if (!e.agentId) throw new Error("agentId is required");
462
- const t = !!(e.apiKey || e.token), i = !!(e.serverUrl && e.callId), n = w.normalizeIceServers(
480
+ const t = !!(e.apiKey || e.token), i = !!(e.serverUrl && e.callId), n = y.normalizeIceServers(
463
481
  e.iceServers
464
482
  );
465
483
  if (!t && !i)
@@ -467,57 +485,57 @@ const w = class w {
467
485
  "apiKey or token is required — or pass serverUrl and callId from a prior POST /calls/create"
468
486
  );
469
487
  this.agentId = e.agentId, this.sessionBehavior = e.sessionBehavior, this.serverUrl = (e.serverUrl || "").replace(/\/$/, ""), this.apiKey = e.apiKey, this.token = e.token, this.backendUrl = (e.backendUrl || Q).replace(/\/$/, ""), n.length && (this.iceServers = n), i && (this.callSessionLoaded = !0);
470
- const s = typeof window < "u";
488
+ const r = typeof window < "u";
471
489
  this.prospectId = e.prospectId;
472
490
  const o = e.sessionBehavior === "continue";
473
- if (o && s && !e.callId) {
474
- const r = $(this.agentId);
475
- r && (e.callId || (this.callId = r.callId), !this.prospectId && r.prospectId && (this.prospectId = r.prospectId));
491
+ if (o && r && !e.callId) {
492
+ const s = B(this.agentId);
493
+ s && (e.callId || (this.callId = s.callId), !this.prospectId && s.prospectId && (this.prospectId = s.prospectId));
476
494
  }
477
- if (!this.prospectId && s)
495
+ if (!this.prospectId && r)
478
496
  try {
479
- const r = $(this.agentId);
480
- this.prospectId = (r == null ? void 0 : r.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
497
+ const s = B(this.agentId);
498
+ this.prospectId = (s == null ? void 0 : s.prospectId) || window.sessionStorage && window.sessionStorage.getItem("vanira_prospect_id") || window.localStorage && window.localStorage.getItem("vanira_prospect_id") || void 0;
481
499
  } catch {
482
500
  }
483
501
  e.callId ? this.callId = e.callId : o || (this.callId = void 0);
484
- const d = e.onSessionStarted;
485
- this.onSessionStarted = (r) => {
486
- d == null || d(r), this.emit("session_started", r);
502
+ const h = e.onSessionStarted;
503
+ this.onSessionStarted = (s) => {
504
+ h == null || h(s), this.emit("session_started", s);
487
505
  }, this.liveVision = e.liveVision, this.onConnected = () => {
488
- var r;
489
- this._status = "connected", (r = e.onConnected) == null || r.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
506
+ var s;
507
+ this._status = "connected", (s = e.onConnected) == null || s.call(e), this.emit("connected"), this.maybeAutoStartLiveCamera();
490
508
  }, this.onDisconnected = () => {
491
- var r;
492
- this._status = "disconnected", (r = e.onDisconnected) == null || r.call(e), this.emit("disconnected");
493
- }, this.onError = (r) => {
509
+ var s;
510
+ this._status = "disconnected", (s = e.onDisconnected) == null || s.call(e), this.emit("disconnected");
511
+ }, this.onError = (s) => {
494
512
  var p;
495
513
  this._status = "error";
496
- const h = typeof r == "string" ? r : (r == null ? void 0 : r.message) || "Connection error";
497
- (p = e.onError) == null || p.call(e, r), this.emit("error", h);
498
- }, this.onTranscription = (r, h) => {
514
+ const u = typeof s == "string" ? s : (s == null ? void 0 : s.message) || "Connection error";
515
+ (p = e.onError) == null || p.call(e, s), this.emit("error", u);
516
+ }, this.onTranscription = (s, u) => {
499
517
  var p;
500
- (p = e.onTranscription) == null || p.call(e, r, h), this.emit("transcription", { text: r, isFinal: h });
518
+ (p = e.onTranscription) == null || p.call(e, s, u), this.emit("transcription", { text: s, isFinal: u });
501
519
  }, this.onLocalStream = e.onLocalStream || (() => {
502
- }), this.onRemoteTrack = (r, h) => {
520
+ }), this.onRemoteTrack = (s, u) => {
503
521
  var p;
504
- (p = e.onRemoteTrack) == null || p.call(e, r, h), this.emit("track", { track: r, stream: h });
505
- }, this.onClientToolCall = (r) => {
506
- var c;
507
- (c = e.onClientToolCall) == null || c.call(e, r);
508
- const h = (r == null ? void 0 : r.data) || r, p = {
509
- name: String(h.name || h.tool_name || ""),
510
- arguments: h.arguments || h.args || {},
511
- tool_call_id: String(h.tool_call_id || h.call_id || ""),
512
- execution_mode: h.execution_mode === "blocking" ? "blocking" : "fire_and_forget",
513
- client_fields: h.client_fields || {}
522
+ (p = e.onRemoteTrack) == null || p.call(e, s, u), this.emit("track", { track: s, stream: u });
523
+ }, this.onClientToolCall = (s) => {
524
+ var l;
525
+ (l = e.onClientToolCall) == null || l.call(e, s);
526
+ const u = (s == null ? void 0 : s.data) || s, p = {
527
+ name: String(u.name || u.tool_name || ""),
528
+ arguments: u.arguments || u.args || {},
529
+ tool_call_id: String(u.tool_call_id || u.call_id || ""),
530
+ execution_mode: u.execution_mode === "blocking" ? "blocking" : "fire_and_forget",
531
+ client_fields: u.client_fields || {}
514
532
  };
515
533
  p.name && p.tool_call_id && this.emit("tool_call", p);
516
534
  }, this.runtime = e.runtime, typeof window < "u" && e.trackRouteContext !== !1 && (this.routeTracker = new _e({
517
- sendContext: (r) => this.sendContextUpdate(r),
535
+ sendContext: (s) => this.sendContextUpdate(s),
518
536
  isReady: () => {
519
- var r;
520
- return ((r = this.dataChannel) == null ? void 0 : r.readyState) === "open";
537
+ var s;
538
+ return ((s = this.dataChannel) == null ? void 0 : s.readyState) === "open";
521
539
  }
522
540
  }));
523
541
  }
@@ -569,41 +587,41 @@ const w = class w {
569
587
  channelCount: 1
570
588
  }
571
589
  });
572
- } catch (c) {
573
- if (c.name === "NotAllowedError" || c.name === "PermissionDeniedError" || (t = c.message) != null && t.includes("Permission denied")) {
590
+ } catch (l) {
591
+ if (l.name === "NotAllowedError" || l.name === "PermissionDeniedError" || (t = l.message) != null && t.includes("Permission denied")) {
574
592
  const _ = navigator.userAgent, m = /iPad|iPhone|iPod/.test(_) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1;
575
593
  let f = "Microphone access denied. Please allow microphone access in your browser settings.";
576
594
  m && (_.includes("CriOS") ? f = "Microphone access blocked. Please enable it in iOS Settings > Chrome > Microphone, then reload the page." : _.includes("FxiOS") ? f = "Microphone access blocked. Please enable it in iOS Settings > Firefox > Microphone, then reload the page." : f = "Microphone access blocked. Please enable it in iOS Settings > Safari > Microphone (or tap 'aA' > Website Settings > Allow Microphone).");
577
- const v = new Error(f);
578
- throw v.name = c.name, v;
595
+ const S = new Error(f);
596
+ throw S.name = l.name, S;
579
597
  }
580
- throw c;
598
+ throw l;
581
599
  }
582
600
  if (this.isConnectCancelled(e)) {
583
- n.getTracks().forEach((c) => c.stop());
601
+ n.getTracks().forEach((l) => l.stop());
584
602
  return;
585
603
  }
586
604
  if (this.localStream = n, !this.pc || this.isConnectCancelled(e)) {
587
- n.getTracks().forEach((c) => c.stop());
605
+ n.getTracks().forEach((l) => l.stop());
588
606
  return;
589
607
  }
590
- if (this.onLocalStream(n), n.getTracks().forEach((c) => {
608
+ if (this.onLocalStream(n), n.getTracks().forEach((l) => {
591
609
  var _;
592
- (_ = this.pc) == null || _.addTrack(c, n);
610
+ (_ = this.pc) == null || _.addTrack(l, n);
593
611
  }), !this.pc)
594
612
  throw new Error("RTCPeerConnection was closed unexpectedly");
595
613
  this.dataChannel = this.pc.createDataChannel("control"), this.dataChannel.onopen = () => {
596
- var c;
597
- (c = this.routeTracker) == null || c.onChannelReady();
598
- }, this.dataChannel.onmessage = (c) => {
599
- if (typeof c.data == "string")
614
+ var l;
615
+ (l = this.routeTracker) == null || l.onChannelReady();
616
+ }, this.dataChannel.onmessage = (l) => {
617
+ if (typeof l.data == "string")
600
618
  try {
601
- this.handleControlEvent(JSON.parse(c.data));
619
+ this.handleControlEvent(JSON.parse(l.data));
602
620
  } catch {
603
621
  }
604
- else if (c.data instanceof ArrayBuffer)
622
+ else if (l.data instanceof ArrayBuffer)
605
623
  try {
606
- const _ = new TextDecoder().decode(c.data);
624
+ const _ = new TextDecoder().decode(l.data);
607
625
  try {
608
626
  const m = JSON.parse(_);
609
627
  oe(m) && this.handleControlEvent(m);
@@ -611,40 +629,40 @@ const w = class w {
611
629
  }
612
630
  } catch {
613
631
  }
614
- else c.data instanceof Blob && c.data.text().then((_) => {
632
+ else l.data instanceof Blob && l.data.text().then((_) => {
615
633
  try {
616
634
  this.handleControlEvent(JSON.parse(_));
617
635
  } catch {
618
636
  }
619
637
  });
620
- }, this.dataChannel.onerror = (c) => {
638
+ }, this.dataChannel.onerror = (l) => {
621
639
  }, this.mediaBytesChannel = this.pc.createDataChannel("media-bytes", { ordered: !0 }), this.mediaBytesChannel.binaryType = "arraybuffer", this.mediaBytesChannel.onopen = () => {
622
- }, this.mediaBytesChannel.onerror = (c) => {
623
- }, this.pc.ontrack = (c) => {
624
- const _ = c.track, m = c.streams[0];
640
+ }, this.mediaBytesChannel.onerror = (l) => {
641
+ }, this.pc.ontrack = (l) => {
642
+ const _ = l.track, m = l.streams[0];
625
643
  _.kind === "audio" ? (this.audioElement = new Audio(), this.audioElement.srcObject = m, this.audioElement.play().catch((f) => {
626
644
  }), this.audioElement.onended = () => {
627
645
  this.sendEvent("playedStream"), typeof window < "u" && window.dispatchEvent(new CustomEvent("vanira:agent-playback-ended"));
628
646
  }, this.onRemoteTrack(_, m)) : _.kind === "video" && this.onRemoteTrack(_, m);
629
647
  };
630
- const s = () => {
631
- var m, f, v, b, x, A, P, U, L, M, O;
632
- const c = ((m = this.pc) == null ? void 0 : m.connectionState) === "connected" || ((f = this.pc) == null ? void 0 : f.iceConnectionState) === "connected" || ((v = this.pc) == null ? void 0 : v.iceConnectionState) === "completed", _ = ((b = this.pc) == null ? void 0 : b.connectionState) === "failed" || ((x = this.pc) == null ? void 0 : x.iceConnectionState) === "failed" || ((A = this.pc) == null ? void 0 : A.connectionState) === "closed" || ((P = this.pc) == null ? void 0 : P.iceConnectionState) === "closed" || ((U = this.pc) == null ? void 0 : U.connectionState) === "disconnected" || ((L = this.pc) == null ? void 0 : L.iceConnectionState) === "disconnected";
633
- ((M = this.pc) == null ? void 0 : M.connectionState) === "connected" && this.stopRemoteIcePolling(), c && !this.connected ? (this.connected = !0, (O = this.routeTracker) == null || O.start(), this.onConnected()) : _ && this.connected && (this.connected = !1, this.liveVisionAutoStarted = !1, this.onDisconnected());
648
+ const r = () => {
649
+ var m, f, S, b, x, A, P, U, L, M, O;
650
+ const l = ((m = this.pc) == null ? void 0 : m.connectionState) === "connected" || ((f = this.pc) == null ? void 0 : f.iceConnectionState) === "connected" || ((S = this.pc) == null ? void 0 : S.iceConnectionState) === "completed", _ = ((b = this.pc) == null ? void 0 : b.connectionState) === "failed" || ((x = this.pc) == null ? void 0 : x.iceConnectionState) === "failed" || ((A = this.pc) == null ? void 0 : A.connectionState) === "closed" || ((P = this.pc) == null ? void 0 : P.iceConnectionState) === "closed" || ((U = this.pc) == null ? void 0 : U.connectionState) === "disconnected" || ((L = this.pc) == null ? void 0 : L.iceConnectionState) === "disconnected";
651
+ ((M = this.pc) == null ? void 0 : M.connectionState) === "connected" && this.stopRemoteIcePolling(), l && !this.connected ? (this.connected = !0, (O = this.routeTracker) == null || O.start(), this.onConnected()) : _ && this.connected && (this.connected = !1, this.liveVisionAutoStarted = !1, this.onDisconnected());
634
652
  };
635
- this.pc.onconnectionstatechange = s, this.pc.oniceconnectionstatechange = s;
653
+ this.pc.onconnectionstatechange = r, this.pc.oniceconnectionstatechange = r;
636
654
  const o = this.getIceTrickleUrl();
637
- this.pc.onicecandidate = (c) => {
638
- c.candidate && fetch(o, {
655
+ this.pc.onicecandidate = (l) => {
656
+ l.candidate && fetch(o, {
639
657
  method: "POST",
640
658
  headers: { "Content-Type": "application/json" },
641
- body: JSON.stringify({ candidate: c.candidate.toJSON() })
659
+ body: JSON.stringify({ candidate: l.candidate.toJSON() })
642
660
  }).catch((_) => {
643
661
  });
644
662
  };
645
- const d = await this.pc.createOffer();
646
- if (this.isConnectCancelled(e) || (await this.pc.setLocalDescription(d), this.isConnectCancelled(e))) return;
647
- const r = this.serverUrl.includes("?") ? this.serverUrl : `${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`, h = await fetch(r, {
663
+ const h = await this.pc.createOffer();
664
+ if (this.isConnectCancelled(e) || (await this.pc.setLocalDescription(h), this.isConnectCancelled(e))) return;
665
+ const s = this.serverUrl.includes("?") ? this.serverUrl : `${this.serverUrl}/webrtc?agent=${this.agentId}_${this.callId}`, u = await fetch(s, {
648
666
  method: "POST",
649
667
  headers: { "Content-Type": "application/json" },
650
668
  body: JSON.stringify({
@@ -654,11 +672,11 @@ const w = class w {
654
672
  })
655
673
  });
656
674
  if (this.isConnectCancelled(e)) return;
657
- if (!h.ok) {
658
- const c = await h.json();
659
- throw new Error(c.error || `HTTP ${h.status}`);
675
+ if (!u.ok) {
676
+ const l = await u.json();
677
+ throw new Error(l.error || `HTTP ${u.status}`);
660
678
  }
661
- const { answer: p } = await h.json();
679
+ const { answer: p } = await u.json();
662
680
  if (this.isConnectCancelled(e) || !this.pc || (await this.pc.setRemoteDescription(p), this.isConnectCancelled(e))) return;
663
681
  this.startRemoteIcePolling(o);
664
682
  } catch (i) {
@@ -679,38 +697,38 @@ const w = class w {
679
697
  ].join("|");
680
698
  }
681
699
  async postCreateCall(e, t, i) {
682
- var d, r, h;
700
+ var h, s, u;
683
701
  const n = await fetch(`${this.backendUrl}/calls/create`, {
684
702
  method: "POST",
685
703
  headers: e,
686
704
  body: JSON.stringify({
687
705
  agent_id: this.agentId,
688
- type: ((d = this.runtime) == null ? void 0 : d.callType) || "web",
706
+ type: ((h = this.runtime) == null ? void 0 : h.callType) || "web",
689
707
  mode: t,
690
- ...(r = this.runtime) != null && r.runtimeName ? { runtime: this.runtime.runtimeName } : {},
708
+ ...(s = this.runtime) != null && s.runtimeName ? { runtime: this.runtime.runtimeName } : {},
691
709
  prospect_id: this.prospectId,
692
710
  ...i ? { call_id: i } : {}
693
711
  })
694
712
  });
695
713
  if (!n.ok) {
696
714
  const p = await n.json().catch(() => ({}));
697
- throw new Error(`[VaniraClient] createCall failed (${n.status}): ${((h = p == null ? void 0 : p.detail) == null ? void 0 : h.message) || (p == null ? void 0 : p.message) || n.statusText}`);
715
+ throw new Error(`[VaniraClient] createCall failed (${n.status}): ${((u = p == null ? void 0 : p.detail) == null ? void 0 : u.message) || (p == null ? void 0 : p.message) || n.statusText}`);
698
716
  }
699
- const s = await n.json();
700
- if (!s.call_id || !s.worker_url)
717
+ const r = await n.json();
718
+ if (!r.call_id || !r.worker_url)
701
719
  throw new Error("[VaniraClient] /calls/create response missing call_id or worker_url");
702
- const o = w.normalizeIceServers(s.ice_servers);
720
+ const o = y.normalizeIceServers(r.ice_servers);
703
721
  if (!o.length)
704
722
  throw new Error("[VaniraClient] /calls/create response missing ice_servers");
705
723
  return {
706
- callId: s.call_id,
707
- prospectId: s.prospect_id || this.prospectId,
708
- serverUrl: s.worker_url.replace(/\/$/, ""),
724
+ callId: r.call_id,
725
+ prospectId: r.prospect_id || this.prospectId,
726
+ serverUrl: r.worker_url.replace(/\/$/, ""),
709
727
  iceServers: o
710
728
  };
711
729
  }
712
730
  applyCreateCallSession(e) {
713
- if (this.callId = e.callId, this.prospectId = e.prospectId || this.prospectId, this.serverUrl = e.serverUrl, this.iceServers = e.iceServers, this.callSessionLoaded = !0, se(this.agentId, this.callId || "", this.prospectId), this.onSessionStarted && this.prospectId && this.callId && !this.sessionStartedEmitted)
731
+ if (this.callId = e.callId, this.prospectId = e.prospectId || this.prospectId, this.serverUrl = e.serverUrl, this.iceServers = e.iceServers, this.callSessionLoaded = !0, re(this.agentId, this.callId || "", this.prospectId), this.onSessionStarted && this.prospectId && this.callId && !this.sessionStartedEmitted)
714
732
  try {
715
733
  this.onSessionStarted({ prospectId: this.prospectId, callId: this.callId, serverUrl: this.serverUrl }), this.sessionStartedEmitted = !0;
716
734
  } catch {
@@ -727,11 +745,11 @@ const w = class w {
727
745
  const e = { "Content-Type": "application/json" };
728
746
  this.apiKey ? e["X-API-Key"] = this.apiKey : this.token && (e.Authorization = this.token.startsWith("Bearer ") ? this.token : `Bearer ${this.token}`);
729
747
  const t = this.sessionBehavior === "continue" ? this.callId : void 0, i = this.sessionBehavior === "continue" ? "continue" : "new", n = this.createCallCacheKey(i, t);
730
- let s = w.inflightCreates.get(n);
731
- s || (s = this.postCreateCall(e, i, t), w.inflightCreates.set(n, s), s.finally(() => {
732
- w.inflightCreates.get(n) === s && w.inflightCreates.delete(n);
748
+ let r = y.inflightCreates.get(n);
749
+ r || (r = this.postCreateCall(e, i, t), y.inflightCreates.set(n, r), r.finally(() => {
750
+ y.inflightCreates.get(n) === r && y.inflightCreates.delete(n);
733
751
  }));
734
- const o = await s;
752
+ const o = await r;
735
753
  this.applyCreateCallSession(o);
736
754
  }
737
755
  getIceServers() {
@@ -743,10 +761,10 @@ const w = class w {
743
761
  if (!Array.isArray(e)) return [];
744
762
  const t = [];
745
763
  for (const i of e) {
746
- const n = i == null ? void 0 : i.urls, s = Array.isArray(n) ? n.filter(Boolean) : typeof n == "string" && n.trim() ? [n.trim()] : [];
747
- if (!s.length) continue;
748
- const o = { urls: s.length === 1 ? s[0] : s }, d = i.username, r = i.credential;
749
- d && (o.username = d), r && (o.credential = r), t.push(o);
764
+ const n = i == null ? void 0 : i.urls, r = Array.isArray(n) ? n.filter(Boolean) : typeof n == "string" && n.trim() ? [n.trim()] : [];
765
+ if (!r.length) continue;
766
+ const o = { urls: r.length === 1 ? r[0] : r }, h = i.username, s = i.credential;
767
+ h && (o.username = h), s && (o.credential = s), t.push(o);
750
768
  }
751
769
  return t;
752
770
  }
@@ -786,9 +804,9 @@ const w = class w {
786
804
  if (!t.ok) return;
787
805
  const { candidates: i } = await t.json();
788
806
  for (const n of i || []) {
789
- const s = JSON.stringify(n);
790
- if (!this.appliedRemoteCandidates.has(s)) {
791
- this.appliedRemoteCandidates.add(s);
807
+ const r = JSON.stringify(n);
808
+ if (!this.appliedRemoteCandidates.has(r)) {
809
+ this.appliedRemoteCandidates.add(r);
792
810
  try {
793
811
  await this.pc.addIceCandidate(n);
794
812
  } catch {
@@ -814,10 +832,10 @@ const w = class w {
814
832
  }
815
833
  /** Wait for control DataChannel, then send (live vision lifecycle events). */
816
834
  async sendEventWhenReady(e, t = {}, i = 1e4) {
817
- var s;
835
+ var r;
818
836
  const n = Date.now() + i;
819
837
  for (; Date.now() < n; ) {
820
- if (((s = this.dataChannel) == null ? void 0 : s.readyState) === "open")
838
+ if (((r = this.dataChannel) == null ? void 0 : r.readyState) === "open")
821
839
  return this.sendEvent(e, t), !0;
822
840
  await new Promise((o) => setTimeout(o, 50));
823
841
  }
@@ -834,7 +852,7 @@ const w = class w {
834
852
  name: "open_live_camera",
835
853
  tool_call_id: `lv_${crypto.randomUUID()}`,
836
854
  execution_mode: "fire_and_forget",
837
- client_fields: { preset_id: u.LiveVision },
855
+ client_fields: { preset_id: c.LiveVision },
838
856
  arguments: {
839
857
  mode: "live",
840
858
  scope: t,
@@ -876,15 +894,15 @@ const w = class w {
876
894
  event: "client_tool_ack",
877
895
  data: { tool_call_id: n }
878
896
  }));
879
- const s = (i == null ? void 0 : i.arguments) || (i == null ? void 0 : i.args) || {}, o = (i == null ? void 0 : i.client_fields) || {}, d = (i == null ? void 0 : i.name) || (i == null ? void 0 : i.tool_name) || "", r = ae(o, s, d);
880
- if (d === "end_call") {
897
+ const r = (i == null ? void 0 : i.arguments) || (i == null ? void 0 : i.args) || {}, o = (i == null ? void 0 : i.client_fields) || {}, h = (i == null ? void 0 : i.name) || (i == null ? void 0 : i.tool_name) || "", s = ae(o, r, h);
898
+ if (h === "end_call") {
881
899
  n && this.sendToolResult(n, {
882
900
  status: "client_ack_end_call",
883
901
  message: "Ending call."
884
902
  }), window.setTimeout(() => this.disconnect(), 120);
885
903
  break;
886
904
  }
887
- if (r) {
905
+ if (s) {
888
906
  window.dispatchEvent(new CustomEvent("vanira:preset", {
889
907
  detail: { toolCall: i, client: this }
890
908
  })), this.onClientToolCall(i);
@@ -918,8 +936,8 @@ const w = class w {
918
936
  this.micMuted = e, (t = this.localStream) == null || t.getAudioTracks().forEach((n) => {
919
937
  n.enabled = !e;
920
938
  }), (i = this.pc) == null || i.getSenders().forEach((n) => {
921
- var s;
922
- ((s = n.track) == null ? void 0 : s.kind) === "audio" && (n.track.enabled = !e);
939
+ var r;
940
+ ((r = n.track) == null ? void 0 : r.kind) === "audio" && (n.track.enabled = !e);
923
941
  });
924
942
  }
925
943
  isMicrophoneMuted() {
@@ -1034,25 +1052,25 @@ const w = class w {
1034
1052
  * the server adds client_media_upload_ready ack — use HTTP for frame JPEGs until then.
1035
1053
  */
1036
1054
  async uploadMediaFrame(e, t = "camera_capture", i) {
1037
- const n = i && !(e instanceof File) ? new File([e], i, { type: e.type || "image/jpeg" }) : e, { media_id: s, url: o, contentType: d } = await this._postMediaUpload(n, t, !0);
1038
- if (!s || !o)
1055
+ const n = i && !(e instanceof File) ? new File([e], i, { type: e.type || "image/jpeg" }) : e, { media_id: r, url: o, contentType: h } = await this._postMediaUpload(n, t, !0);
1056
+ if (!r || !o)
1039
1057
  throw new Error("Frame upload failed: server response missing media_id or url");
1040
- return { media_id: s, url: o, content_type: d };
1058
+ return { media_id: r, url: o, content_type: h };
1041
1059
  }
1042
1060
  /** WebRTC media-bytes path (control start/complete + binary chunks). */
1043
- async _uploadBytesViaDataChannel(e, t, i, n, s) {
1061
+ async _uploadBytesViaDataChannel(e, t, i, n, r) {
1044
1062
  if (!this.callId || !this.mediaBytesChannel)
1045
1063
  throw new Error("Upload failed: call not ready for WebRTC media upload.");
1046
- const o = s || (e instanceof File ? e.name : n === "frame" ? "frame.jpg" : "upload.bin"), d = e.type || (n === "frame" ? "image/jpeg" : "application/octet-stream"), r = await ue(e);
1064
+ const o = r || (e instanceof File ? e.name : n === "frame" ? "frame.jpg" : "upload.bin"), h = e.type || (n === "frame" ? "image/jpeg" : "application/octet-stream"), s = await ue(e);
1047
1065
  return he({
1048
- bytes: r,
1066
+ bytes: s,
1049
1067
  filename: o,
1050
- contentType: d,
1068
+ contentType: h,
1051
1069
  reason: t,
1052
1070
  message: i,
1053
1071
  callId: this.callId,
1054
1072
  mediaBytesChannel: this.mediaBytesChannel,
1055
- sendControlEvent: (h, p) => this.sendEvent(h, p),
1073
+ sendControlEvent: (u, p) => this.sendEvent(u, p),
1056
1074
  uploadKind: n
1057
1075
  });
1058
1076
  }
@@ -1062,14 +1080,14 @@ const w = class w {
1062
1080
  }
1063
1081
  /** HTTP fallback — original uploadMedia behavior (unchanged). */
1064
1082
  async _uploadMediaViaHTTP(e, t = "general", i = "") {
1065
- const { media_id: n, url: s, contentType: o } = await this._postMediaUpload(e, t, !0);
1083
+ const { media_id: n, url: r, contentType: o } = await this._postMediaUpload(e, t, !0);
1066
1084
  return this.sendMediaUpdate({
1067
1085
  media_id: n,
1068
- media_url: s,
1086
+ media_url: r,
1069
1087
  content_type: o,
1070
1088
  reason: t,
1071
1089
  message: i
1072
- }), { media_id: n, url: s };
1090
+ }), { media_id: n, url: r };
1073
1091
  }
1074
1092
  async _postMediaUpload(e, t, i = !1) {
1075
1093
  if (!this.serverUrl)
@@ -1081,24 +1099,24 @@ const w = class w {
1081
1099
  throw new Error(
1082
1100
  "Upload failed: worker_url is not set. Connect the call before uploading media."
1083
1101
  );
1084
- const s = `${n}/media/upload`, o = new FormData();
1102
+ const r = `${n}/media/upload`, o = new FormData();
1085
1103
  o.append("file", e), o.append("call_id", this.callId), o.append("reason", t);
1086
- const d = await fetch(s, {
1104
+ const h = await fetch(r, {
1087
1105
  method: "POST",
1088
1106
  body: o
1089
1107
  });
1090
- if (!d.ok) {
1091
- let _ = `HTTP ${d.status}`;
1108
+ if (!h.ok) {
1109
+ let _ = `HTTP ${h.status}`;
1092
1110
  try {
1093
- _ = (await d.json()).error || _;
1111
+ _ = (await h.json()).error || _;
1094
1112
  } catch {
1095
1113
  }
1096
1114
  throw new Error(`Upload failed: ${_}`);
1097
1115
  }
1098
- const r = await d.json(), h = r.media_id, p = r.url, c = r.content_type || e.type;
1099
- if (!h || !p)
1116
+ const s = await h.json(), u = s.media_id, p = s.url, l = s.content_type || e.type;
1117
+ if (!u || !p)
1100
1118
  throw new Error("Upload failed: server response missing media_id or url");
1101
- return i ? { media_id: h, url: p, contentType: c } : { media_id: h, url: p, contentType: c };
1119
+ return i ? { media_id: u, url: p, contentType: l } : { media_id: u, url: p, contentType: l };
1102
1120
  }
1103
1121
  // ─── Event emitter (replaces retired VaniraAI) ───────────────────────────
1104
1122
  get status() {
@@ -1146,8 +1164,8 @@ const w = class w {
1146
1164
  }
1147
1165
  };
1148
1166
  /** Dedupes concurrent POST /calls/create (e.g. React StrictMode double-mount). */
1149
- l(w, "inflightCreates", /* @__PURE__ */ new Map());
1150
- let k = w;
1167
+ d(y, "inflightCreates", /* @__PURE__ */ new Map());
1168
+ let R = y;
1151
1169
  const me = {
1152
1170
  supportsAudioEndedEvent: !1,
1153
1171
  supportsScreenShare: !1,
@@ -1168,28 +1186,28 @@ const me = {
1168
1186
  dataChannel: new Z()
1169
1187
  };
1170
1188
  function J(a) {
1171
- return new k({
1189
+ return new R({
1172
1190
  ...a,
1173
1191
  runtime: fe
1174
1192
  });
1175
1193
  }
1176
- const ve = J;
1177
- function we(a) {
1194
+ const Se = J;
1195
+ function ye(a) {
1178
1196
  return J(a);
1179
1197
  }
1180
- const ye = we;
1198
+ const ve = ye;
1181
1199
  export {
1182
1200
  Y as RNAudioAdapter,
1183
1201
  Z as RNDataChannelAdapter,
1184
1202
  q as RNMediaAdapter,
1185
1203
  X as RNPeerAdapter,
1186
- k as VaniraAI,
1187
- k as VaniraClient,
1188
- k as WebRTCClient,
1189
- ve as createReactNativeAI,
1204
+ R as VaniraAI,
1205
+ R as VaniraClient,
1206
+ R as WebRTCClient,
1207
+ Se as createReactNativeAI,
1190
1208
  J as createReactNativeClient,
1191
- ye as createVaniraAI,
1192
- we as createVaniraClient,
1209
+ ve as createVaniraAI,
1210
+ ye as createVaniraClient,
1193
1211
  me as reactNativeCapabilities,
1194
1212
  fe as reactNativeRuntime
1195
1213
  };