@corti/dictation-web 0.0.0-test.571.2 → 0.0.0-test.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +25 -39
  2. package/dist/bundle.js +1120 -535
  3. package/dist/components/corti-dictation.d.ts +23 -9
  4. package/dist/components/corti-dictation.js +36 -17
  5. package/dist/components/corti-dictation.js.map +1 -1
  6. package/dist/components/keybinding-input.d.ts +16 -0
  7. package/dist/components/keybinding-input.js +94 -0
  8. package/dist/components/keybinding-input.js.map +1 -0
  9. package/dist/components/keybinding-selector.d.ts +3 -3
  10. package/dist/components/keybinding-selector.js +21 -49
  11. package/dist/components/keybinding-selector.js.map +1 -1
  12. package/dist/components/recording-button.d.ts +5 -3
  13. package/dist/components/recording-button.js +100 -45
  14. package/dist/components/recording-button.js.map +1 -1
  15. package/dist/components/settings-menu.d.ts +0 -1
  16. package/dist/components/settings-menu.js +4 -17
  17. package/dist/components/settings-menu.js.map +1 -1
  18. package/dist/contexts/dictation-context.d.ts +6 -6
  19. package/dist/contexts/dictation-context.js +24 -23
  20. package/dist/contexts/dictation-context.js.map +1 -1
  21. package/dist/controllers/dictation-controller.d.ts +8 -2
  22. package/dist/controllers/dictation-controller.js +151 -45
  23. package/dist/controllers/dictation-controller.js.map +1 -1
  24. package/dist/controllers/keybinding-controller.d.ts +2 -3
  25. package/dist/controllers/keybinding-controller.js +20 -17
  26. package/dist/controllers/keybinding-controller.js.map +1 -1
  27. package/dist/controllers/media-controller.d.ts +2 -1
  28. package/dist/controllers/media-controller.js +14 -3
  29. package/dist/controllers/media-controller.js.map +1 -1
  30. package/dist/index.d.ts +2 -3
  31. package/dist/index.js +0 -5
  32. package/dist/index.js.map +1 -1
  33. package/dist/styles/keybinding-selector.js +10 -4
  34. package/dist/styles/keybinding-selector.js.map +1 -1
  35. package/dist/styles/settings-menu.js +0 -8
  36. package/dist/styles/settings-menu.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/dist/types.d.ts +1 -2
  39. package/dist/types.js.map +1 -1
  40. package/dist/utils/events.d.ts +13 -7
  41. package/dist/utils/events.js +26 -12
  42. package/dist/utils/events.js.map +1 -1
  43. package/package.json +2 -4
  44. package/dist/components/mode-selector.d.ts +0 -14
  45. package/dist/components/mode-selector.js +0 -73
  46. package/dist/components/mode-selector.js.map +0 -1
  47. package/dist/package.json +0 -94
  48. package/dist/styles/mode-selector.d.ts +0 -2
  49. package/dist/styles/mode-selector.js +0 -56
  50. package/dist/styles/mode-selector.js.map +0 -1
package/dist/bundle.js CHANGED
@@ -1016,11 +1016,15 @@ function recordingDevicesChangedEvent(devices, selectedDevice) {
1016
1016
  detail: { devices, selectedDevice }
1017
1017
  });
1018
1018
  }
1019
- function recordingStateChangedEvent(state) {
1019
+ function recordingStateChangedEvent(state, options = {}) {
1020
1020
  return new CustomEvent("recording-state-changed", {
1021
1021
  bubbles: true,
1022
1022
  composed: true,
1023
- detail: { state }
1023
+ detail: {
1024
+ connection: options.connection,
1025
+ processing: options.processing,
1026
+ state
1027
+ }
1024
1028
  });
1025
1029
  }
1026
1030
  function transcriptEvent(detail) {
@@ -1044,8 +1048,21 @@ function usageEvent(detail) {
1044
1048
  detail
1045
1049
  });
1046
1050
  }
1051
+ function errorToMessage(error) {
1052
+ if (error instanceof Error) {
1053
+ return error.message;
1054
+ }
1055
+ if (typeof error === "object" && error !== null) {
1056
+ try {
1057
+ return JSON.stringify(error);
1058
+ } catch {
1059
+ return String(error);
1060
+ }
1061
+ }
1062
+ return String(error);
1063
+ }
1047
1064
  function errorEvent(error) {
1048
- const message = error instanceof Error && error.message ? error.message : String(error);
1065
+ const message = errorToMessage(error);
1049
1066
  return new CustomEvent("error", {
1050
1067
  bubbles: false,
1051
1068
  composed: true,
@@ -1079,18 +1096,11 @@ function networkActivityEvent(direction, data) {
1079
1096
  detail: { data, direction }
1080
1097
  });
1081
1098
  }
1082
- function modeChangedEvent(mode) {
1083
- return new CustomEvent("mode-changed", {
1084
- bubbles: true,
1085
- composed: true,
1086
- detail: { mode }
1087
- });
1088
- }
1089
- function keybindingChangedEvent(key, code) {
1099
+ function keybindingChangedEvent(key, code, keybinding, type) {
1090
1100
  return new CustomEvent("keybinding-changed", {
1091
1101
  bubbles: true,
1092
1102
  composed: true,
1093
- detail: { code, key }
1103
+ detail: { code, key, keybinding, type }
1094
1104
  });
1095
1105
  }
1096
1106
  function keybindingActivatedEvent(keyboardEvent) {
@@ -1340,71 +1350,6 @@ async function getInitialToken(config) {
1340
1350
  };
1341
1351
  }
1342
1352
 
1343
- // dist/utils/keybinding.js
1344
- function isMac() {
1345
- if (typeof navigator === "undefined") {
1346
- return false;
1347
- }
1348
- return /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
1349
- }
1350
- function capitalize(str) {
1351
- if (str.length === 0) {
1352
- return str;
1353
- }
1354
- return str.charAt(0).toUpperCase() + str.slice(1);
1355
- }
1356
- function normalizeKeyForKeybinding(key) {
1357
- if (key === " ") {
1358
- return "Space";
1359
- }
1360
- const normalized = key.trim().toLowerCase();
1361
- if (normalized === "control") {
1362
- return "Ctrl";
1363
- }
1364
- if (normalized === "meta" || normalized === "cmd") {
1365
- return isMac() ? "Cmd" : "Meta";
1366
- }
1367
- if (normalized === "alt" || normalized === "opt") {
1368
- return isMac() ? "Opt" : "Alt";
1369
- }
1370
- if (normalized === "space") {
1371
- return "Space";
1372
- }
1373
- return normalized.length > 1 ? capitalize(normalized) : normalized;
1374
- }
1375
- function normalizeKeybinding(keybinding) {
1376
- if (!keybinding) {
1377
- return null;
1378
- }
1379
- const trimmed = keybinding.trim();
1380
- if (trimmed === "") {
1381
- return null;
1382
- }
1383
- return normalizeKeyForKeybinding(trimmed);
1384
- }
1385
- function matchesKeybinding(event, keybinding) {
1386
- const normalizedKeybinding = normalizeKeybinding(keybinding);
1387
- if (!normalizedKeybinding) {
1388
- return false;
1389
- }
1390
- const normalizedKey = normalizeKeyForKeybinding(event.key);
1391
- const normalizedCode = normalizeKeyForKeybinding(event.code);
1392
- return normalizedKey === normalizedKeybinding || normalizedCode === normalizedKeybinding;
1393
- }
1394
- function shouldIgnoreKeybinding(element) {
1395
- if (!element) {
1396
- return false;
1397
- }
1398
- const tagName = element.tagName.toLowerCase();
1399
- if (tagName === "input" || tagName === "textarea") {
1400
- return true;
1401
- }
1402
- if (element instanceof HTMLElement && element.contentEditable === "true") {
1403
- return true;
1404
- }
1405
- return false;
1406
- }
1407
-
1408
1353
  // dist/utils/token.js
1409
1354
  function decodeToken(token) {
1410
1355
  const parts = token.split(".");
@@ -1461,7 +1406,6 @@ var _DictationRoot_handleLanguageChanged;
1461
1406
  var _DictationRoot_handleDeviceChanged;
1462
1407
  var _DictationRoot_handleRecordingStateChanged;
1463
1408
  var _DictationRoot_handleContextRequest;
1464
- var _DictationRoot_handleModeChanged;
1465
1409
  var _DictationRoot_handleKeybindingChanged;
1466
1410
  var regionContext = n7(Symbol("region"));
1467
1411
  var tenantNameContext = n7(Symbol("tenantName"));
@@ -1475,8 +1419,8 @@ var authConfigContext = n7(Symbol("authConfig"));
1475
1419
  var socketUrlContext = n7(Symbol("socketUrl"));
1476
1420
  var socketProxyContext = n7(Symbol("socketProxy"));
1477
1421
  var debugDisplayAudioContext = n7(Symbol("debugDisplayAudio"));
1478
- var modeContext = n7(Symbol("mode"));
1479
- var keybindingContext = n7(Symbol("keybinding"));
1422
+ var pushToTalkKeybindingContext = n7(Symbol("pushToTalkKeybinding"));
1423
+ var toggleToTalkKeybindingContext = n7(Symbol("toggleToTalkKeybinding"));
1480
1424
  var DictationRoot = class DictationRoot2 extends i4 {
1481
1425
  set accessToken(token) {
1482
1426
  this.setAccessToken(token);
@@ -1516,7 +1460,6 @@ var DictationRoot = class DictationRoot2 extends i4 {
1516
1460
  this.recordingState = "stopped";
1517
1461
  _DictationRoot_languagesController.set(this, new LanguagesController(this));
1518
1462
  _DictationRoot_devicesController.set(this, new DevicesController(this));
1519
- this.mode = "toggle-to-talk";
1520
1463
  this.noWrapper = false;
1521
1464
  _DictationRoot_handleLanguageChanged.set(this, (e10) => {
1522
1465
  const event = e10;
@@ -1538,27 +1481,30 @@ var DictationRoot = class DictationRoot2 extends i4 {
1538
1481
  __classPrivateFieldGet3(this, _DictationRoot_languagesController, "f").initialize();
1539
1482
  } else if (e10.context === devicesContext) {
1540
1483
  __classPrivateFieldGet3(this, _DictationRoot_devicesController, "f").initialize();
1541
- } else if (e10.context === keybindingContext && e10.contextTarget.tagName.toLowerCase() === "dictation-keybinding-selector") {
1542
- if (this.keybinding === void 0) {
1543
- this.keybinding = "`";
1544
- this.dispatchEvent(keybindingChangedEvent("`", "Backquote"));
1484
+ } else if (e10.contextTarget.tagName.toLowerCase() === "dictation-keybinding-selector") {
1485
+ if (e10.context === pushToTalkKeybindingContext && this.pushToTalkKeybinding === void 0) {
1486
+ this.pushToTalkKeybinding = "Space";
1487
+ this.dispatchEvent(keybindingChangedEvent(" ", "Space", "Space", "push-to-talk"));
1488
+ }
1489
+ if (e10.context === toggleToTalkKeybindingContext && this.toggleToTalkKeybinding === void 0) {
1490
+ this.toggleToTalkKeybinding = "Enter";
1491
+ this.dispatchEvent(keybindingChangedEvent("Enter", "Enter", "Enter", "toggle-to-talk"));
1545
1492
  }
1546
1493
  }
1547
1494
  });
1548
- _DictationRoot_handleModeChanged.set(this, (e10) => {
1549
- const event = e10;
1550
- this.mode = event.detail.mode;
1551
- });
1552
1495
  _DictationRoot_handleKeybindingChanged.set(this, (e10) => {
1553
1496
  const event = e10;
1554
- const normalizedKeybinding = normalizeKeybinding(event.detail.key);
1555
- this.keybinding = normalizedKeybinding;
1497
+ const keybinding = event.detail.keybinding;
1498
+ if (event.detail.type === "push-to-talk") {
1499
+ this.pushToTalkKeybinding = keybinding;
1500
+ } else if (event.detail.type === "toggle-to-talk") {
1501
+ this.toggleToTalkKeybinding = keybinding;
1502
+ }
1556
1503
  });
1557
1504
  this.addEventListener("languages-changed", __classPrivateFieldGet3(this, _DictationRoot_handleLanguageChanged, "f"));
1558
1505
  this.addEventListener("recording-devices-changed", __classPrivateFieldGet3(this, _DictationRoot_handleDeviceChanged, "f"));
1559
1506
  this.addEventListener("recording-state-changed", __classPrivateFieldGet3(this, _DictationRoot_handleRecordingStateChanged, "f"));
1560
1507
  this.addEventListener("context-request", __classPrivateFieldGet3(this, _DictationRoot_handleContextRequest, "f"));
1561
- this.addEventListener("mode-changed", __classPrivateFieldGet3(this, _DictationRoot_handleModeChanged, "f"));
1562
1508
  this.addEventListener("keybinding-changed", __classPrivateFieldGet3(this, _DictationRoot_handleKeybindingChanged, "f"));
1563
1509
  }
1564
1510
  // ─────────────────────────────────────────────────────────────────────────────
@@ -1634,7 +1580,6 @@ _DictationRoot_handleLanguageChanged = /* @__PURE__ */ new WeakMap();
1634
1580
  _DictationRoot_handleDeviceChanged = /* @__PURE__ */ new WeakMap();
1635
1581
  _DictationRoot_handleRecordingStateChanged = /* @__PURE__ */ new WeakMap();
1636
1582
  _DictationRoot_handleContextRequest = /* @__PURE__ */ new WeakMap();
1637
- _DictationRoot_handleModeChanged = /* @__PURE__ */ new WeakMap();
1638
1583
  _DictationRoot_handleKeybindingChanged = /* @__PURE__ */ new WeakMap();
1639
1584
  DictationRoot.styles = [component_styles_default];
1640
1585
  __decorate([
@@ -1701,13 +1646,13 @@ __decorate([
1701
1646
  n4({ attribute: "debug-display-audio", type: Boolean })
1702
1647
  ], DictationRoot.prototype, "debug_displayAudio", void 0);
1703
1648
  __decorate([
1704
- e9({ context: modeContext }),
1649
+ e9({ context: pushToTalkKeybindingContext }),
1705
1650
  n4({ type: String })
1706
- ], DictationRoot.prototype, "mode", void 0);
1651
+ ], DictationRoot.prototype, "pushToTalkKeybinding", void 0);
1707
1652
  __decorate([
1708
- e9({ context: keybindingContext }),
1653
+ e9({ context: toggleToTalkKeybindingContext }),
1709
1654
  n4({ type: String })
1710
- ], DictationRoot.prototype, "keybinding", void 0);
1655
+ ], DictationRoot.prototype, "toggleToTalkKeybinding", void 0);
1711
1656
  __decorate([
1712
1657
  n4({ type: Boolean })
1713
1658
  ], DictationRoot.prototype, "noWrapper", void 0);
@@ -1833,6 +1778,19 @@ var UnauthorizedError = class _UnauthorizedError extends CortiError {
1833
1778
  }
1834
1779
  };
1835
1780
 
1781
+ // node_modules/@corti/sdk/dist/esm/api/errors/BadGatewayError.mjs
1782
+ var BadGatewayError = class _BadGatewayError extends CortiError {
1783
+ constructor(body, rawResponse) {
1784
+ super({
1785
+ message: "BadGatewayError",
1786
+ statusCode: 502,
1787
+ body,
1788
+ rawResponse
1789
+ });
1790
+ Object.setPrototypeOf(this, _BadGatewayError.prototype);
1791
+ }
1792
+ };
1793
+
1836
1794
  // node_modules/@corti/sdk/dist/esm/core/auth/OAuthTokenProvider.mjs
1837
1795
  var __awaiter = function(thisArg, _arguments, P2, generator) {
1838
1796
  function adopt(value) {
@@ -2451,6 +2409,15 @@ function requestWithRetries(requestFn_1) {
2451
2409
  });
2452
2410
  }
2453
2411
 
2412
+ // node_modules/@corti/sdk/dist/esm/custom/utils/withCredentialsConfig.mjs
2413
+ var defaultWithCredentials = void 0;
2414
+ function getDefaultWithCredentials() {
2415
+ return defaultWithCredentials;
2416
+ }
2417
+ function setDefaultWithCredentials(value) {
2418
+ defaultWithCredentials = value;
2419
+ }
2420
+
2454
2421
  // node_modules/@corti/sdk/dist/esm/core/fetcher/Fetcher.mjs
2455
2422
  var __awaiter9 = function(thisArg, _arguments, P2, generator) {
2456
2423
  function adopt(value) {
@@ -2512,7 +2479,8 @@ function fetcherImpl(args) {
2512
2479
  const fetchFn = yield getFetchFn();
2513
2480
  try {
2514
2481
  const response = yield requestWithRetries(() => __awaiter9(this, void 0, void 0, function* () {
2515
- return makeRequest(fetchFn, url, args.method, yield getHeaders(args), requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
2482
+ var _a;
2483
+ return makeRequest(fetchFn, url, args.method, yield getHeaders(args), requestBody, args.timeoutMs, args.abortSignal, (_a = args.withCredentials) !== null && _a !== void 0 ? _a : getDefaultWithCredentials(), args.duplex);
2516
2484
  }), args.maxRetries);
2517
2485
  if (response.status >= 200 && response.status < 400) {
2518
2486
  return {
@@ -5236,12 +5204,16 @@ var AuthGetTokenRequest = schemas_exports.object({
5236
5204
  var agents_exports = {};
5237
5205
  __export(agents_exports, {
5238
5206
  AgentsCreateAgent: () => AgentsCreateAgent,
5207
+ AgentsCreateAgentAgentType: () => AgentsCreateAgentAgentType,
5239
5208
  AgentsCreateAgentExpertsItem: () => AgentsCreateAgentExpertsItem,
5240
5209
  AgentsMessageSendParams: () => AgentsMessageSendParams,
5241
5210
  AgentsMessageSendResponse: () => AgentsMessageSendResponse,
5242
5211
  list: () => list_exports
5243
5212
  });
5244
5213
 
5214
+ // node_modules/@corti/sdk/dist/esm/serialization/resources/agents/types/AgentsCreateAgentAgentType.mjs
5215
+ var AgentsCreateAgentAgentType = schemas_exports.enum_(["expert", "orchestrator", "interviewing-expert"]);
5216
+
5245
5217
  // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsCreateMcpServerTransportType.mjs
5246
5218
  var AgentsCreateMcpServerTransportType = schemas_exports.enum_(["stdio", "streamable_http", "sse"]);
5247
5219
 
@@ -5254,6 +5226,7 @@ var AgentsCreateMcpServer = schemas_exports.object({
5254
5226
  description: schemas_exports.string().optional(),
5255
5227
  transportType: AgentsCreateMcpServerTransportType,
5256
5228
  authorizationType: AgentsCreateMcpServerAuthorizationType,
5229
+ authorizationScope: schemas_exports.string().optional(),
5257
5230
  url: schemas_exports.string(),
5258
5231
  redirectUrl: schemas_exports.string().optional(),
5259
5232
  token: schemas_exports.string().optional()
@@ -5268,15 +5241,16 @@ var AgentsCreateExpert = schemas_exports.object({
5268
5241
  mcpServers: schemas_exports.list(AgentsCreateMcpServer).optional()
5269
5242
  });
5270
5243
 
5271
- // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsExpertReference.mjs
5272
- var AgentsExpertReference = schemas_exports.object({
5244
+ // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsCreateExpertReference.mjs
5245
+ var AgentsCreateExpertReference = schemas_exports.object({
5273
5246
  type: schemas_exports.stringLiteral("reference"),
5274
5247
  id: schemas_exports.string().optional(),
5275
- name: schemas_exports.string().optional()
5248
+ name: schemas_exports.string().optional(),
5249
+ systemPrompt: schemas_exports.string().optional()
5276
5250
  });
5277
5251
 
5278
5252
  // node_modules/@corti/sdk/dist/esm/serialization/resources/agents/types/AgentsCreateAgentExpertsItem.mjs
5279
- var AgentsCreateAgentExpertsItem = schemas_exports.undiscriminatedUnion([AgentsCreateExpert, AgentsExpertReference]);
5253
+ var AgentsCreateAgentExpertsItem = schemas_exports.undiscriminatedUnion([AgentsCreateExpert, AgentsCreateExpertReference]);
5280
5254
 
5281
5255
  // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsMessageRole.mjs
5282
5256
  var AgentsMessageRole = schemas_exports.enum_(["user", "agent"]);
@@ -5400,6 +5374,7 @@ var AgentsMcpServer = schemas_exports.object({
5400
5374
  name: schemas_exports.string(),
5401
5375
  transportType: AgentsMcpServerTransportType,
5402
5376
  authorizationType: AgentsMcpServerAuthorizationType,
5377
+ authorizationScope: schemas_exports.string().optional(),
5403
5378
  url: schemas_exports.string(),
5404
5379
  redirectUrl: schemas_exports.string().optionalNullable()
5405
5380
  });
@@ -5414,6 +5389,14 @@ var AgentsExpert = schemas_exports.object({
5414
5389
  mcpServers: schemas_exports.list(AgentsMcpServer).optional()
5415
5390
  });
5416
5391
 
5392
+ // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsExpertReference.mjs
5393
+ var AgentsExpertReference = schemas_exports.object({
5394
+ type: schemas_exports.stringLiteral("reference"),
5395
+ id: schemas_exports.string(),
5396
+ name: schemas_exports.string(),
5397
+ systemPrompt: schemas_exports.string().optional()
5398
+ });
5399
+
5417
5400
  // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsAgentExpertsItem.mjs
5418
5401
  var AgentsAgentExpertsItem = schemas_exports.undiscriminatedUnion([AgentsExpert, AgentsExpertReference]);
5419
5402
 
@@ -5442,6 +5425,7 @@ var Response = schemas_exports.list(AgentsAgentResponse);
5442
5425
  // node_modules/@corti/sdk/dist/esm/serialization/resources/agents/client/requests/AgentsCreateAgent.mjs
5443
5426
  var AgentsCreateAgent = schemas_exports.object({
5444
5427
  name: schemas_exports.string(),
5428
+ agentType: AgentsCreateAgentAgentType.optional(),
5445
5429
  systemPrompt: schemas_exports.string().optional(),
5446
5430
  description: schemas_exports.string(),
5447
5431
  experts: schemas_exports.list(AgentsCreateAgentExpertsItem).optional()
@@ -5512,7 +5496,7 @@ var FactsCreateRequest = schemas_exports.object({
5512
5496
 
5513
5497
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsBatchUpdateInput.mjs
5514
5498
  var FactsBatchUpdateInput = schemas_exports.object({
5515
- factId: Uuid,
5499
+ factId: schemas_exports.string(),
5516
5500
  isDiscarded: schemas_exports.boolean().optional(),
5517
5501
  text: schemas_exports.string().optional(),
5518
5502
  group: schemas_exports.string().optional()
@@ -5557,6 +5541,25 @@ var DocumentsUpdateRequest = schemas_exports.object({
5557
5541
  sections: schemas_exports.list(DocumentsSectionInput).optional()
5558
5542
  });
5559
5543
 
5544
+ // node_modules/@corti/sdk/dist/esm/serialization/types/CommonCodingSystemEnum.mjs
5545
+ var CommonCodingSystemEnum = schemas_exports.enum_(["icd10cm", "icd10pcs", "cpt"]);
5546
+
5547
+ // node_modules/@corti/sdk/dist/esm/serialization/types/CommonDocumentIdContext.mjs
5548
+ var CommonDocumentIdContext = schemas_exports.object({
5549
+ type: schemas_exports.stringLiteral("documentId"),
5550
+ documentId: schemas_exports.string()
5551
+ });
5552
+
5553
+ // node_modules/@corti/sdk/dist/esm/serialization/types/CommonAiContext.mjs
5554
+ var CommonAiContext = schemas_exports.undiscriminatedUnion([CommonTextContext, CommonDocumentIdContext]);
5555
+
5556
+ // node_modules/@corti/sdk/dist/esm/serialization/resources/codes/client/requests/CodesGeneralPredictRequest.mjs
5557
+ var CodesGeneralPredictRequest = schemas_exports.object({
5558
+ system: schemas_exports.list(CommonCodingSystemEnum),
5559
+ context: schemas_exports.list(CommonAiContext),
5560
+ maxCandidates: schemas_exports.number().optional()
5561
+ });
5562
+
5560
5563
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsContext.mjs
5561
5564
  var FactsContext = schemas_exports.object({
5562
5565
  text: schemas_exports.string(),
@@ -5609,6 +5612,23 @@ var DocumentsSection = schemas_exports.object({
5609
5612
  updatedAt: schemas_exports.date()
5610
5613
  });
5611
5614
 
5615
+ // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsSectionOverride.mjs
5616
+ var DocumentsSectionOverride = schemas_exports.object({
5617
+ key: schemas_exports.string(),
5618
+ nameOverride: schemas_exports.string().optional(),
5619
+ writingStyleOverride: schemas_exports.string().optional(),
5620
+ formatRuleOverride: schemas_exports.string().optional(),
5621
+ additionalInstructionsOverride: schemas_exports.string().optional(),
5622
+ contentOverride: schemas_exports.string().optional()
5623
+ });
5624
+
5625
+ // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsTemplateWithSections.mjs
5626
+ var DocumentsTemplateWithSections = schemas_exports.object({
5627
+ sections: schemas_exports.list(DocumentsSectionOverride),
5628
+ description: schemas_exports.string().optional(),
5629
+ additionalInstructionsOverride: schemas_exports.string().optional()
5630
+ });
5631
+
5612
5632
  // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsTemplateWithSectionKeys.mjs
5613
5633
  var DocumentsTemplateWithSectionKeys = schemas_exports.object({
5614
5634
  sectionKeys: schemas_exports.list(schemas_exports.string()),
@@ -5617,7 +5637,7 @@ var DocumentsTemplateWithSectionKeys = schemas_exports.object({
5617
5637
  });
5618
5638
 
5619
5639
  // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsTemplate.mjs
5620
- var DocumentsTemplate = DocumentsTemplateWithSectionKeys;
5640
+ var DocumentsTemplate = schemas_exports.undiscriminatedUnion([DocumentsTemplateWithSections, DocumentsTemplateWithSectionKeys]);
5621
5641
 
5622
5642
  // node_modules/@corti/sdk/dist/esm/serialization/types/InteractionsEncounterResponse.mjs
5623
5643
  var InteractionsEncounterResponse = schemas_exports.object({
@@ -5630,12 +5650,11 @@ var InteractionsEncounterResponse = schemas_exports.object({
5630
5650
 
5631
5651
  // node_modules/@corti/sdk/dist/esm/serialization/types/ErrorResponse.mjs
5632
5652
  var ErrorResponse = schemas_exports.object({
5633
- requestid: schemas_exports.string().optional(),
5653
+ requestid: schemas_exports.string(),
5654
+ status: schemas_exports.number(),
5634
5655
  type: schemas_exports.string(),
5635
- status: schemas_exports.number().optional(),
5636
- title: schemas_exports.string().optional(),
5637
- details: schemas_exports.string().optional(),
5638
- instance: schemas_exports.string().optional()
5656
+ detail: schemas_exports.string(),
5657
+ validationErrors: schemas_exports.list(schemas_exports.record(schemas_exports.string(), schemas_exports.string())).optional()
5639
5658
  });
5640
5659
 
5641
5660
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsFactGroupsItemTranslationsItem.mjs
@@ -5652,13 +5671,17 @@ var FactsFactGroupsItem = schemas_exports.object({
5652
5671
  translations: schemas_exports.list(FactsFactGroupsItemTranslationsItem).optional()
5653
5672
  });
5654
5673
 
5674
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesDocumentationModeEnum.mjs
5675
+ var TemplatesDocumentationModeEnum = schemas_exports.enum_(["global_sequential", "routed_parallel"]);
5676
+
5655
5677
  // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsCreateRequestWithTemplateKey.mjs
5656
5678
  var DocumentsCreateRequestWithTemplateKey = schemas_exports.object({
5657
5679
  context: schemas_exports.list(DocumentsContext),
5658
5680
  templateKey: schemas_exports.string(),
5659
5681
  name: schemas_exports.string().optional(),
5660
5682
  outputLanguage: schemas_exports.string(),
5661
- disableGuardrails: schemas_exports.boolean().optional()
5683
+ disableGuardrails: schemas_exports.boolean().optional(),
5684
+ documentationMode: TemplatesDocumentationModeEnum.optional()
5662
5685
  });
5663
5686
 
5664
5687
  // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsCreateRequestWithTemplate.mjs
@@ -5667,7 +5690,8 @@ var DocumentsCreateRequestWithTemplate = schemas_exports.object({
5667
5690
  template: DocumentsTemplate,
5668
5691
  name: schemas_exports.string().optional(),
5669
5692
  outputLanguage: schemas_exports.string(),
5670
- disableGuardrails: schemas_exports.boolean().optional()
5693
+ disableGuardrails: schemas_exports.boolean().optional(),
5694
+ documentationMode: TemplatesDocumentationModeEnum.optional()
5671
5695
  });
5672
5696
 
5673
5697
  // node_modules/@corti/sdk/dist/esm/serialization/types/DocumentsCreateRequest.mjs
@@ -5681,22 +5705,31 @@ var TemplatesWritingStyle = schemas_exports.object({
5681
5705
  name: schemas_exports.string()
5682
5706
  });
5683
5707
 
5708
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesFormatRule.mjs
5709
+ var TemplatesFormatRule = schemas_exports.object({
5710
+ name: schemas_exports.string().optionalNullable()
5711
+ });
5712
+
5684
5713
  // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesSectionTranslation.mjs
5685
5714
  var TemplatesSectionTranslation = schemas_exports.object({
5686
- languagesId: schemas_exports.property("languages_id", schemas_exports.string()),
5715
+ languageId: schemas_exports.string(),
5687
5716
  name: schemas_exports.string().optionalNullable(),
5688
5717
  description: schemas_exports.string().optionalNullable()
5689
5718
  });
5690
5719
 
5691
5720
  // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesSection.mjs
5692
5721
  var TemplatesSection = schemas_exports.object({
5693
- dateUpdated: schemas_exports.property("date_updated", schemas_exports.date().optionalNullable()),
5722
+ updatedAt: schemas_exports.date().optionalNullable(),
5694
5723
  name: schemas_exports.string(),
5695
- alternateNames: schemas_exports.property("alternate_names", schemas_exports.list(schemas_exports.string()).optionalNullable()),
5724
+ alternateName: schemas_exports.string().optional(),
5696
5725
  key: schemas_exports.string(),
5697
5726
  description: schemas_exports.string(),
5698
- defaultWritingStyle: schemas_exports.property("default_writing_style", TemplatesWritingStyle),
5699
- sectionType: schemas_exports.property("section_type", schemas_exports.string()),
5727
+ defaultWritingStyle: TemplatesWritingStyle,
5728
+ defaultFormatRule: TemplatesFormatRule.optional(),
5729
+ additionalInstructions: schemas_exports.string().optional(),
5730
+ content: schemas_exports.string().optional(),
5731
+ documentationMode: TemplatesDocumentationModeEnum.optional(),
5732
+ type: schemas_exports.string(),
5700
5733
  translations: schemas_exports.list(TemplatesSectionTranslation)
5701
5734
  });
5702
5735
 
@@ -5708,24 +5741,26 @@ var TemplatesSectionListResponse = schemas_exports.object({
5708
5741
  // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesSectionSorted.mjs
5709
5742
  var TemplatesSectionSorted = schemas_exports.object({
5710
5743
  sort: schemas_exports.number(),
5711
- sectionsId: schemas_exports.property("sections_id", TemplatesSection)
5744
+ section: TemplatesSection
5712
5745
  });
5713
5746
 
5714
5747
  // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesTranslation.mjs
5715
5748
  var TemplatesTranslation = schemas_exports.object({
5716
- languagesId: schemas_exports.property("languages_id", schemas_exports.string()),
5749
+ languageId: schemas_exports.string(),
5717
5750
  name: schemas_exports.string().optional(),
5718
5751
  description: schemas_exports.string().optional()
5719
5752
  });
5720
5753
 
5721
5754
  // node_modules/@corti/sdk/dist/esm/serialization/types/TemplatesItem.mjs
5722
5755
  var TemplatesItem = schemas_exports.object({
5723
- dateUpdated: schemas_exports.property("date_updated", schemas_exports.date().optionalNullable()),
5756
+ updatedAt: schemas_exports.date().optionalNullable(),
5724
5757
  name: schemas_exports.string(),
5725
5758
  description: schemas_exports.string(),
5759
+ additionalInstructions: schemas_exports.string().optionalNullable(),
5726
5760
  key: schemas_exports.string(),
5727
5761
  status: schemas_exports.string(),
5728
- templateSections: schemas_exports.property("template_sections", schemas_exports.list(TemplatesSectionSorted)),
5762
+ documentationMode: TemplatesDocumentationModeEnum.optional(),
5763
+ templateSections: schemas_exports.list(TemplatesSectionSorted),
5729
5764
  translations: schemas_exports.list(TemplatesTranslation)
5730
5765
  });
5731
5766
 
@@ -5766,7 +5801,7 @@ var FactsEvidence = schemas_exports.object({
5766
5801
 
5767
5802
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsListItem.mjs
5768
5803
  var FactsListItem = schemas_exports.object({
5769
- id: Uuid.optional(),
5804
+ id: schemas_exports.string().optional(),
5770
5805
  text: schemas_exports.string().optional(),
5771
5806
  group: schemas_exports.string().optional(),
5772
5807
  groupId: Uuid.optional(),
@@ -5779,7 +5814,7 @@ var FactsListItem = schemas_exports.object({
5779
5814
 
5780
5815
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsCreateItem.mjs
5781
5816
  var FactsCreateItem = schemas_exports.object({
5782
- id: Uuid.optional(),
5817
+ id: schemas_exports.string().optional(),
5783
5818
  text: schemas_exports.string().optional(),
5784
5819
  group: schemas_exports.string().optional(),
5785
5820
  groupId: Uuid.optional(),
@@ -5795,7 +5830,7 @@ var FactsFactGroupsListResponse = schemas_exports.object({
5795
5830
 
5796
5831
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsUpdateResponse.mjs
5797
5832
  var FactsUpdateResponse = schemas_exports.object({
5798
- id: Uuid,
5833
+ id: schemas_exports.string(),
5799
5834
  text: schemas_exports.string(),
5800
5835
  group: schemas_exports.string(),
5801
5836
  groupId: Uuid,
@@ -5817,7 +5852,7 @@ var FactsListResponse = schemas_exports.object({
5817
5852
 
5818
5853
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsBatchUpdateItem.mjs
5819
5854
  var FactsBatchUpdateItem = schemas_exports.object({
5820
- id: Uuid,
5855
+ id: schemas_exports.string(),
5821
5856
  text: schemas_exports.string(),
5822
5857
  group: schemas_exports.string(),
5823
5858
  groupId: Uuid,
@@ -5832,6 +5867,27 @@ var FactsBatchUpdateResponse = schemas_exports.object({
5832
5867
  facts: schemas_exports.list(FactsBatchUpdateItem)
5833
5868
  });
5834
5869
 
5870
+ // node_modules/@corti/sdk/dist/esm/serialization/types/CodesGeneralReadResponseEvidencesItem.mjs
5871
+ var CodesGeneralReadResponseEvidencesItem = schemas_exports.object({
5872
+ contextIndex: schemas_exports.number().optional(),
5873
+ text: schemas_exports.string().optional()
5874
+ });
5875
+
5876
+ // node_modules/@corti/sdk/dist/esm/serialization/types/CodesGeneralReadResponse.mjs
5877
+ var CodesGeneralReadResponse = schemas_exports.object({
5878
+ system: CommonCodingSystemEnum,
5879
+ code: schemas_exports.string(),
5880
+ display: schemas_exports.string(),
5881
+ evidences: schemas_exports.list(CodesGeneralReadResponseEvidencesItem).optional()
5882
+ });
5883
+
5884
+ // node_modules/@corti/sdk/dist/esm/serialization/types/CodesGeneralResponse.mjs
5885
+ var CodesGeneralResponse = schemas_exports.object({
5886
+ codes: schemas_exports.list(CodesGeneralReadResponse),
5887
+ candidates: schemas_exports.list(CodesGeneralReadResponse),
5888
+ usageInfo: CommonUsageInfo.optional()
5889
+ });
5890
+
5835
5891
  // node_modules/@corti/sdk/dist/esm/serialization/types/FactsExtractResponseFactsItem.mjs
5836
5892
  var FactsExtractResponseFactsItem = schemas_exports.object({
5837
5893
  group: schemas_exports.string(),
@@ -5894,12 +5950,17 @@ var CommonTranscriptResponse = schemas_exports.object({
5894
5950
  end: schemas_exports.number()
5895
5951
  });
5896
5952
 
5953
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscriptsStatusEnum.mjs
5954
+ var TranscriptsStatusEnum = schemas_exports.enum_(["completed", "processing", "failed"]);
5955
+
5897
5956
  // node_modules/@corti/sdk/dist/esm/serialization/types/TranscriptsResponse.mjs
5898
5957
  var TranscriptsResponse = schemas_exports.object({
5899
5958
  id: Uuid,
5900
5959
  metadata: TranscriptsMetadata,
5901
5960
  transcripts: schemas_exports.list(CommonTranscriptResponse).optionalNullable(),
5902
- usageInfo: CommonUsageInfo
5961
+ usageInfo: CommonUsageInfo,
5962
+ recordingId: Uuid,
5963
+ status: TranscriptsStatusEnum
5903
5964
  });
5904
5965
 
5905
5966
  // node_modules/@corti/sdk/dist/esm/serialization/types/TranscriptsData.mjs
@@ -5920,6 +5981,11 @@ var TranscriptsListResponse = schemas_exports.object({
5920
5981
  transcripts: schemas_exports.list(TranscriptsListItem).optionalNullable()
5921
5982
  });
5922
5983
 
5984
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscriptsStatusResponse.mjs
5985
+ var TranscriptsStatusResponse = schemas_exports.object({
5986
+ status: TranscriptsStatusEnum
5987
+ });
5988
+
5923
5989
  // node_modules/@corti/sdk/dist/esm/serialization/types/CommonSortingDirectionEnum.mjs
5924
5990
  var CommonSortingDirectionEnum = schemas_exports.enum_(["asc", "desc"]);
5925
5991
 
@@ -5944,13 +6010,12 @@ var StreamConfigTranscription = schemas_exports.object({
5944
6010
  });
5945
6011
 
5946
6012
  // node_modules/@corti/sdk/dist/esm/serialization/types/StreamConfigModeType.mjs
5947
- var StreamConfigModeType = schemas_exports.enum_(["facts", "transcription", "documentation"]);
6013
+ var StreamConfigModeType = schemas_exports.enum_(["facts", "transcription"]);
5948
6014
 
5949
6015
  // node_modules/@corti/sdk/dist/esm/serialization/types/StreamConfigMode.mjs
5950
6016
  var StreamConfigMode = schemas_exports.object({
5951
6017
  type: StreamConfigModeType,
5952
- outputLocale: StreamSupportedLanguage.optional(),
5953
- templateId: schemas_exports.string().optional()
6018
+ outputLocale: StreamSupportedLanguage.optional()
5954
6019
  });
5955
6020
 
5956
6021
  // node_modules/@corti/sdk/dist/esm/serialization/types/StreamConfig.mjs
@@ -5992,13 +6057,42 @@ var TranscribeCommand = schemas_exports.object({
5992
6057
  variables: schemas_exports.list(TranscribeCommandVariable).optional()
5993
6058
  });
5994
6059
 
6060
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormattingDates.mjs
6061
+ var TranscribeFormattingDates = schemas_exports.enum_(["as_dictated", "eu_slash", "iso_compact", "long_text", "us_slash"]);
6062
+
6063
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormattingTimes.mjs
6064
+ var TranscribeFormattingTimes = schemas_exports.enum_(["as_dictated", "h12", "h24"]);
6065
+
6066
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormattingNumbers.mjs
6067
+ var TranscribeFormattingNumbers = schemas_exports.enum_(["as_dictated", "numerals", "numerals_above_nine"]);
6068
+
6069
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormattingMeasurements.mjs
6070
+ var TranscribeFormattingMeasurements = schemas_exports.enum_(["abbreviated", "as_dictated"]);
6071
+
6072
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormattingNumericRanges.mjs
6073
+ var TranscribeFormattingNumericRanges = schemas_exports.enum_(["as_dictated", "numerals"]);
6074
+
6075
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormattingOrdinals.mjs
6076
+ var TranscribeFormattingOrdinals = schemas_exports.enum_(["as_dictated", "numerals"]);
6077
+
6078
+ // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeFormatting.mjs
6079
+ var TranscribeFormatting = schemas_exports.object({
6080
+ dates: TranscribeFormattingDates.optional(),
6081
+ times: TranscribeFormattingTimes.optional(),
6082
+ numbers: TranscribeFormattingNumbers.optional(),
6083
+ measurements: TranscribeFormattingMeasurements.optional(),
6084
+ numericRanges: TranscribeFormattingNumericRanges.optional(),
6085
+ ordinals: TranscribeFormattingOrdinals.optional()
6086
+ });
6087
+
5995
6088
  // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeConfig.mjs
5996
6089
  var TranscribeConfig = schemas_exports.object({
5997
6090
  primaryLanguage: TranscribeSupportedLanguage,
5998
6091
  interimResults: schemas_exports.boolean().optional(),
5999
6092
  spokenPunctuation: schemas_exports.boolean().optional(),
6000
6093
  automaticPunctuation: schemas_exports.boolean().optional(),
6001
- commands: schemas_exports.list(TranscribeCommand).optional()
6094
+ commands: schemas_exports.list(TranscribeCommand).optional(),
6095
+ formatting: TranscribeFormatting.optional()
6002
6096
  });
6003
6097
 
6004
6098
  // node_modules/@corti/sdk/dist/esm/serialization/types/TranscribeConfigMessage.mjs
@@ -6017,6 +6111,15 @@ var TranscribeFlushMessage = schemas_exports.object({
6017
6111
  type: schemas_exports.stringLiteral("flush")
6018
6112
  });
6019
6113
 
6114
+ // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsRegistryMcpServerAuthorizationType.mjs
6115
+ var AgentsRegistryMcpServerAuthorizationType = schemas_exports.enum_(["none", "bearer", "inherit", "oauth2.0"]);
6116
+
6117
+ // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsRegistryMcpServer.mjs
6118
+ var AgentsRegistryMcpServer = schemas_exports.object({
6119
+ name: schemas_exports.string(),
6120
+ authorizationType: AgentsRegistryMcpServerAuthorizationType
6121
+ });
6122
+
6020
6123
  // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsAgentInterface.mjs
6021
6124
  var AgentsAgentInterface = schemas_exports.object({
6022
6125
  url: schemas_exports.string(),
@@ -6098,7 +6201,8 @@ var AgentsContext = schemas_exports.object({
6098
6201
  // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsRegistryExpert.mjs
6099
6202
  var AgentsRegistryExpert = schemas_exports.object({
6100
6203
  name: schemas_exports.string(),
6101
- description: schemas_exports.string()
6204
+ description: schemas_exports.string(),
6205
+ mcpServers: schemas_exports.list(AgentsRegistryMcpServer).optional()
6102
6206
  });
6103
6207
 
6104
6208
  // node_modules/@corti/sdk/dist/esm/serialization/types/AgentsRegistryExpertsResponse.mjs
@@ -7670,7 +7774,7 @@ var Transcripts = class {
7670
7774
  });
7671
7775
  }
7672
7776
  /**
7673
- * Create a transcript from an audio file attached, via `/recordings` endpoint, to the interaction.<br/><Note>Each interaction may have more than one audio file and transcript associated with it. While audio files up to 60min in total duration, or 150MB in total size, may be attached to an interaction, synchronous processing is only supported for audio files less than ~2min in duration.<br/><br/>If an audio file takes longer to transcribe than the 25sec synchronous processing timeout, then it will continue to process asynchronously. In this scenario, an empty transcript will be returned with a location header that can be used to retrieve the final transcript.<br/><br/>The client can poll the Get Transcript endpoint (`GET /interactions/{id}/transcripts/{transcriptId}/status`) for transcript status changes:<br/>- `200 OK` with status `processing`, `completed`, or `failed`<br/>- `404 Not Found` if the `interactionId` or `transcriptId` are invalid<br/><br/>The completed transcript can be retrieved via the Get Transcript endpoint (`GET /interactions/{id}/transcripts/{transcriptId}/`).</Note>
7777
+ * Create a transcript from an audio file attached, via `/recordings` endpoint, to the interaction.<br/><Note>Each interaction may have more than one audio file and transcript associated with it. While audio files up to 60min in total duration, or 150MB in total size, may be attached to an interaction, synchronous processing is only supported for audio files less than ~2min in duration.<br/><br/>If an audio file takes longer to transcribe than the 25sec synchronous processing timeout, then it will continue to process asynchronously. In this scenario, an incomplete or empty transcript with `status=processing` will be returned with a location header that can be used to retrieve the final transcript.<br/><br/>The client can poll the Get Transcript endpoint (`GET /interactions/{id}/transcripts/{transcriptId}/status`) for transcript status changes:<br/>- `200 OK` with status `processing`, `completed`, or `failed`<br/>- `404 Not Found` if the `interactionId` or `transcriptId` are invalid<br/><br/>The completed transcript can be retrieved via the Get Transcript endpoint (`GET /interactions/{id}/transcripts/{transcriptId}/`).</Note>
7674
7778
  *
7675
7779
  * @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
7676
7780
  * @param {Corti.TranscriptsCreateRequest} request
@@ -7969,6 +8073,76 @@ var Transcripts = class {
7969
8073
  }
7970
8074
  });
7971
8075
  }
8076
+ /**
8077
+ * Poll for transcript creation status.<br/><Note>Status of `completed` indicates the transcript is finalized.<br/>If the transcript is retrieved while status is `processing`, then it will be incomplete.<br/>Status of `failed` indicate the transcript was not created successfully; please retry.</Note>
8078
+ *
8079
+ * @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
8080
+ * @param {Corti.Uuid} transcriptId - The unique identifier of the transcript. Must be a valid UUID.
8081
+ * @param {Transcripts.RequestOptions} requestOptions - Request-specific configuration.
8082
+ *
8083
+ * @throws {@link Corti.NotFoundError}
8084
+ *
8085
+ * @example
8086
+ * await client.transcripts.getStatus("f47ac10b-58cc-4372-a567-0e02b2c3d479", "f47ac10b-58cc-4372-a567-0e02b2c3d479")
8087
+ */
8088
+ getStatus(id, transcriptId, requestOptions) {
8089
+ return HttpResponsePromise.fromPromise(this.__getStatus(id, transcriptId, requestOptions));
8090
+ }
8091
+ __getStatus(id, transcriptId, requestOptions) {
8092
+ return __awaiter19(this, void 0, void 0, function* () {
8093
+ var _a, _b;
8094
+ const _response = yield fetcher({
8095
+ url: url_exports.join((_a = yield Supplier.get(this._options.baseUrl)) !== null && _a !== void 0 ? _a : (yield Supplier.get(this._options.environment)).base, `interactions/${encodeURIComponent(Uuid.jsonOrThrow(id, { omitUndefined: true }))}/transcripts/${encodeURIComponent(Uuid.jsonOrThrow(transcriptId, { omitUndefined: true }))}/status`),
8096
+ method: "GET",
8097
+ headers: mergeHeaders((_b = this._options) === null || _b === void 0 ? void 0 : _b.headers, mergeOnlyDefinedHeaders({
8098
+ Authorization: yield this._getAuthorizationHeader(),
8099
+ "Tenant-Name": requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.tenantName
8100
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
8101
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
8102
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
8103
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal
8104
+ });
8105
+ if (_response.ok) {
8106
+ return {
8107
+ data: TranscriptsStatusResponse.parseOrThrow(_response.body, {
8108
+ unrecognizedObjectKeys: "passthrough",
8109
+ allowUnrecognizedUnionMembers: true,
8110
+ allowUnrecognizedEnumValues: true,
8111
+ skipValidation: true,
8112
+ breadcrumbsPrefix: ["response"]
8113
+ }),
8114
+ rawResponse: _response.rawResponse
8115
+ };
8116
+ }
8117
+ if (_response.error.reason === "status-code") {
8118
+ switch (_response.error.statusCode) {
8119
+ case 404:
8120
+ throw new NotFoundError(_response.error.body, _response.rawResponse);
8121
+ default:
8122
+ throw new CortiError({
8123
+ statusCode: _response.error.statusCode,
8124
+ body: _response.error.body,
8125
+ rawResponse: _response.rawResponse
8126
+ });
8127
+ }
8128
+ }
8129
+ switch (_response.error.reason) {
8130
+ case "non-json":
8131
+ throw new CortiError({
8132
+ statusCode: _response.error.statusCode,
8133
+ body: _response.error.rawBody,
8134
+ rawResponse: _response.rawResponse
8135
+ });
8136
+ case "timeout":
8137
+ throw new CortiTimeoutError("Timeout exceeded when calling GET /interactions/{id}/transcripts/{transcriptId}/status.");
8138
+ case "unknown":
8139
+ throw new CortiError({
8140
+ message: _response.error.errorMessage,
8141
+ rawResponse: _response.rawResponse
8142
+ });
8143
+ }
8144
+ });
8145
+ }
7972
8146
  _getAuthorizationHeader() {
7973
8147
  return __awaiter19(this, void 0, void 0, function* () {
7974
8148
  const bearer = yield Supplier.get(this._options.token);
@@ -8260,7 +8434,7 @@ var Facts = class {
8260
8434
  * @example
8261
8435
  * await client.facts.batchUpdate("f47ac10b-58cc-4372-a567-0e02b2c3d479", {
8262
8436
  * facts: [{
8263
- * factId: "f47ac10b-58cc-4372-a567-0e02b2c3d479"
8437
+ * factId: "3c9d8a12-7f44-4b3e-9e6f-9271c2bbfa08"
8264
8438
  * }]
8265
8439
  * })
8266
8440
  */
@@ -8338,14 +8512,14 @@ var Facts = class {
8338
8512
  * Updates an existing fact associated with a specific interaction.
8339
8513
  *
8340
8514
  * @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
8341
- * @param {Corti.Uuid} factId - The unique identifier of the fact to update. Must be a valid UUID.
8515
+ * @param {string} factId - The unique identifier of the fact to update. Must be a valid UUID.
8342
8516
  * @param {Corti.FactsUpdateRequest} request
8343
8517
  * @param {Facts.RequestOptions} requestOptions - Request-specific configuration.
8344
8518
  *
8345
8519
  * @throws {@link Corti.GatewayTimeoutError}
8346
8520
  *
8347
8521
  * @example
8348
- * await client.facts.update("f47ac10b-58cc-4372-a567-0e02b2c3d479", "f47ac10b-58cc-4372-a567-0e02b2c3d479")
8522
+ * await client.facts.update("f47ac10b-58cc-4372-a567-0e02b2c3d479", "3c9d8a12-7f44-4b3e-9e6f-9271c2bbfa08")
8349
8523
  */
8350
8524
  update(id, factId, request = {}, requestOptions) {
8351
8525
  return HttpResponsePromise.fromPromise(this.__update(id, factId, request, requestOptions));
@@ -8354,7 +8528,7 @@ var Facts = class {
8354
8528
  return __awaiter20(this, arguments, void 0, function* (id, factId, request = {}, requestOptions) {
8355
8529
  var _a, _b;
8356
8530
  const _response = yield fetcher({
8357
- url: url_exports.join((_a = yield Supplier.get(this._options.baseUrl)) !== null && _a !== void 0 ? _a : (yield Supplier.get(this._options.environment)).base, `interactions/${encodeURIComponent(Uuid.jsonOrThrow(id, { omitUndefined: true }))}/facts/${encodeURIComponent(Uuid.jsonOrThrow(factId, { omitUndefined: true }))}`),
8531
+ url: url_exports.join((_a = yield Supplier.get(this._options.baseUrl)) !== null && _a !== void 0 ? _a : (yield Supplier.get(this._options.environment)).base, `interactions/${encodeURIComponent(Uuid.jsonOrThrow(id, { omitUndefined: true }))}/facts/${encodeURIComponent(factId)}`),
8358
8532
  method: "PATCH",
8359
8533
  headers: mergeHeaders((_b = this._options) === null || _b === void 0 ? void 0 : _b.headers, mergeOnlyDefinedHeaders({
8360
8534
  Authorization: yield this._getAuthorizationHeader(),
@@ -8644,7 +8818,7 @@ var Documents = class {
8644
8818
  });
8645
8819
  }
8646
8820
  /**
8647
- * Generate Document.
8821
+ * This endpoint offers different ways to generate a document. Find guides to document generation [here](/textgen/documents-standard).
8648
8822
  *
8649
8823
  * @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
8650
8824
  * @param {Corti.DocumentsCreateRequest} request
@@ -10149,7 +10323,7 @@ var Agents = class {
10149
10323
  });
10150
10324
  }
10151
10325
  /**
10152
- * This endpoint retrieves the experts registry, which contains information about all available experts that can be referenced when creating agents through the AgentsExpertReference schema.
10326
+ * This endpoint retrieves the experts registry, which contains information about all available experts that can be referenced when creating agents through the AgentsCreateExpertReference schema.
10153
10327
  *
10154
10328
  * @param {Corti.AgentsGetRegistryExpertsRequest} request
10155
10329
  * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
@@ -10243,7 +10417,7 @@ var Agents = class {
10243
10417
  }
10244
10418
  };
10245
10419
 
10246
- // node_modules/@corti/sdk/dist/esm/api/resources/stream/client/Socket.mjs
10420
+ // node_modules/@corti/sdk/dist/esm/api/resources/codes/client/Client.mjs
10247
10421
  var __awaiter24 = function(thisArg, _arguments, P2, generator) {
10248
10422
  function adopt(value) {
10249
10423
  return value instanceof P2 ? value : new P2(function(resolve) {
@@ -10271,45 +10445,206 @@ var __awaiter24 = function(thisArg, _arguments, P2, generator) {
10271
10445
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10272
10446
  });
10273
10447
  };
10274
- var StreamSocket = class {
10275
- constructor(args) {
10276
- this.eventHandlers = {};
10277
- this.handleOpen = () => {
10278
- var _a, _b;
10279
- (_b = (_a = this.eventHandlers).open) === null || _b === void 0 ? void 0 : _b.call(_a);
10280
- };
10281
- this.handleMessage = (event) => {
10282
- var _a, _b, _c, _d;
10283
- const data = fromJson(event.data);
10284
- const parsedResponse = StreamSocketResponse.parse(data, {
10285
- unrecognizedObjectKeys: "passthrough",
10286
- allowUnrecognizedUnionMembers: true,
10287
- allowUnrecognizedEnumValues: true,
10288
- skipValidation: true,
10289
- omitUndefined: true
10290
- });
10291
- if (parsedResponse.ok) {
10292
- (_b = (_a = this.eventHandlers).message) === null || _b === void 0 ? void 0 : _b.call(_a, parsedResponse.value);
10293
- } else {
10294
- (_d = (_c = this.eventHandlers).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error("Received unknown message type"));
10295
- }
10296
- };
10297
- this.handleClose = (event) => {
10298
- var _a, _b;
10299
- (_b = (_a = this.eventHandlers).close) === null || _b === void 0 ? void 0 : _b.call(_a, event);
10300
- };
10301
- this.handleError = (event) => {
10302
- var _a, _b;
10303
- const message = event.message;
10304
- (_b = (_a = this.eventHandlers).error) === null || _b === void 0 ? void 0 : _b.call(_a, new Error(message));
10305
- };
10306
- this.socket = args.socket;
10307
- this.socket.addEventListener("open", this.handleOpen);
10308
- this.socket.addEventListener("message", this.handleMessage);
10309
- this.socket.addEventListener("close", this.handleClose);
10310
- this.socket.addEventListener("error", this.handleError);
10448
+ var Codes = class {
10449
+ constructor(_options) {
10450
+ this._options = _options;
10311
10451
  }
10312
- /** The current state of the connection; this is one of the readyState constants. */
10452
+ /**
10453
+ * Predict medical codes from provided context.<br/><Note>This is a stateless endpoint, designed to predict ICD-10-CM, ICD-10-PCS, and CPT codes based on input text string or documentId.<br/><br/>More than one code system may be defined in a single request, and the maximum number of codes to return per system can also be defined.<br/><br/>Code prediction requests have two possible values for context:<br/>- `text`: One set of code prediction results will be returned based on all input text defined.<br/>- `documentId`: Code prediction will be based on that defined document only.<br/><br/>The response includes two sets of results:<br/>- `Codes`: Highest confidence bundle of codes, as selected by the code prediction model<br/>- `Candidates`: Full list of candidate codes as predicted by the model, rank sorted by model confidence with maximum possible value of 50.<br/><br/>All predicted code results are based on input context defined in the request only (not other external data or assets associated with an interaction).</Note>
10454
+ *
10455
+ * @param {Corti.CodesGeneralPredictRequest} request
10456
+ * @param {Codes.RequestOptions} requestOptions - Request-specific configuration.
10457
+ *
10458
+ * @throws {@link Corti.BadRequestError}
10459
+ * @throws {@link Corti.ForbiddenError}
10460
+ * @throws {@link Corti.InternalServerError}
10461
+ * @throws {@link Corti.BadGatewayError}
10462
+ * @throws {@link Corti.GatewayTimeoutError}
10463
+ *
10464
+ * @example
10465
+ * await client.codes.predict({
10466
+ * system: ["icd10cm", "cpt"],
10467
+ * context: [{
10468
+ * type: "text",
10469
+ * text: "Short arm splint applied in ED for pain control."
10470
+ * }],
10471
+ * maxCandidates: 5
10472
+ * })
10473
+ */
10474
+ predict(request, requestOptions) {
10475
+ return HttpResponsePromise.fromPromise(this.__predict(request, requestOptions));
10476
+ }
10477
+ __predict(request, requestOptions) {
10478
+ return __awaiter24(this, void 0, void 0, function* () {
10479
+ var _a, _b;
10480
+ const _response = yield fetcher({
10481
+ url: url_exports.join((_a = yield Supplier.get(this._options.baseUrl)) !== null && _a !== void 0 ? _a : (yield Supplier.get(this._options.environment)).base, "tools/coding/"),
10482
+ method: "POST",
10483
+ headers: mergeHeaders((_b = this._options) === null || _b === void 0 ? void 0 : _b.headers, mergeOnlyDefinedHeaders({
10484
+ Authorization: yield this._getAuthorizationHeader(),
10485
+ "Tenant-Name": requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.tenantName
10486
+ }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
10487
+ contentType: "application/json",
10488
+ requestType: "json",
10489
+ body: CodesGeneralPredictRequest.jsonOrThrow(request, {
10490
+ unrecognizedObjectKeys: "strip",
10491
+ omitUndefined: true
10492
+ }),
10493
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
10494
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
10495
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal
10496
+ });
10497
+ if (_response.ok) {
10498
+ return {
10499
+ data: CodesGeneralResponse.parseOrThrow(_response.body, {
10500
+ unrecognizedObjectKeys: "passthrough",
10501
+ allowUnrecognizedUnionMembers: true,
10502
+ allowUnrecognizedEnumValues: true,
10503
+ skipValidation: true,
10504
+ breadcrumbsPrefix: ["response"]
10505
+ }),
10506
+ rawResponse: _response.rawResponse
10507
+ };
10508
+ }
10509
+ if (_response.error.reason === "status-code") {
10510
+ switch (_response.error.statusCode) {
10511
+ case 400:
10512
+ throw new BadRequestError(_response.error.body, _response.rawResponse);
10513
+ case 403:
10514
+ throw new ForbiddenError(ErrorResponse.parseOrThrow(_response.error.body, {
10515
+ unrecognizedObjectKeys: "passthrough",
10516
+ allowUnrecognizedUnionMembers: true,
10517
+ allowUnrecognizedEnumValues: true,
10518
+ skipValidation: true,
10519
+ breadcrumbsPrefix: ["response"]
10520
+ }), _response.rawResponse);
10521
+ case 500:
10522
+ throw new InternalServerError(ErrorResponse.parseOrThrow(_response.error.body, {
10523
+ unrecognizedObjectKeys: "passthrough",
10524
+ allowUnrecognizedUnionMembers: true,
10525
+ allowUnrecognizedEnumValues: true,
10526
+ skipValidation: true,
10527
+ breadcrumbsPrefix: ["response"]
10528
+ }), _response.rawResponse);
10529
+ case 502:
10530
+ throw new BadGatewayError(ErrorResponse.parseOrThrow(_response.error.body, {
10531
+ unrecognizedObjectKeys: "passthrough",
10532
+ allowUnrecognizedUnionMembers: true,
10533
+ allowUnrecognizedEnumValues: true,
10534
+ skipValidation: true,
10535
+ breadcrumbsPrefix: ["response"]
10536
+ }), _response.rawResponse);
10537
+ case 504:
10538
+ throw new GatewayTimeoutError(ErrorResponse.parseOrThrow(_response.error.body, {
10539
+ unrecognizedObjectKeys: "passthrough",
10540
+ allowUnrecognizedUnionMembers: true,
10541
+ allowUnrecognizedEnumValues: true,
10542
+ skipValidation: true,
10543
+ breadcrumbsPrefix: ["response"]
10544
+ }), _response.rawResponse);
10545
+ default:
10546
+ throw new CortiError({
10547
+ statusCode: _response.error.statusCode,
10548
+ body: _response.error.body,
10549
+ rawResponse: _response.rawResponse
10550
+ });
10551
+ }
10552
+ }
10553
+ switch (_response.error.reason) {
10554
+ case "non-json":
10555
+ throw new CortiError({
10556
+ statusCode: _response.error.statusCode,
10557
+ body: _response.error.rawBody,
10558
+ rawResponse: _response.rawResponse
10559
+ });
10560
+ case "timeout":
10561
+ throw new CortiTimeoutError("Timeout exceeded when calling POST /tools/coding/.");
10562
+ case "unknown":
10563
+ throw new CortiError({
10564
+ message: _response.error.errorMessage,
10565
+ rawResponse: _response.rawResponse
10566
+ });
10567
+ }
10568
+ });
10569
+ }
10570
+ _getAuthorizationHeader() {
10571
+ return __awaiter24(this, void 0, void 0, function* () {
10572
+ const bearer = yield Supplier.get(this._options.token);
10573
+ if (bearer != null) {
10574
+ return `Bearer ${bearer}`;
10575
+ }
10576
+ return void 0;
10577
+ });
10578
+ }
10579
+ };
10580
+
10581
+ // node_modules/@corti/sdk/dist/esm/api/resources/stream/client/Socket.mjs
10582
+ var __awaiter25 = function(thisArg, _arguments, P2, generator) {
10583
+ function adopt(value) {
10584
+ return value instanceof P2 ? value : new P2(function(resolve) {
10585
+ resolve(value);
10586
+ });
10587
+ }
10588
+ return new (P2 || (P2 = Promise))(function(resolve, reject) {
10589
+ function fulfilled(value) {
10590
+ try {
10591
+ step(generator.next(value));
10592
+ } catch (e10) {
10593
+ reject(e10);
10594
+ }
10595
+ }
10596
+ function rejected(value) {
10597
+ try {
10598
+ step(generator["throw"](value));
10599
+ } catch (e10) {
10600
+ reject(e10);
10601
+ }
10602
+ }
10603
+ function step(result) {
10604
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
10605
+ }
10606
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10607
+ });
10608
+ };
10609
+ var StreamSocket = class {
10610
+ constructor(args) {
10611
+ this.eventHandlers = {};
10612
+ this.handleOpen = () => {
10613
+ var _a, _b;
10614
+ (_b = (_a = this.eventHandlers).open) === null || _b === void 0 ? void 0 : _b.call(_a);
10615
+ };
10616
+ this.handleMessage = (event) => {
10617
+ var _a, _b, _c, _d;
10618
+ const data = fromJson(event.data);
10619
+ const parsedResponse = StreamSocketResponse.parse(data, {
10620
+ unrecognizedObjectKeys: "passthrough",
10621
+ allowUnrecognizedUnionMembers: true,
10622
+ allowUnrecognizedEnumValues: true,
10623
+ skipValidation: true,
10624
+ omitUndefined: true
10625
+ });
10626
+ if (parsedResponse.ok) {
10627
+ (_b = (_a = this.eventHandlers).message) === null || _b === void 0 ? void 0 : _b.call(_a, parsedResponse.value);
10628
+ } else {
10629
+ (_d = (_c = this.eventHandlers).error) === null || _d === void 0 ? void 0 : _d.call(_c, new Error("Received unknown message type"));
10630
+ }
10631
+ };
10632
+ this.handleClose = (event) => {
10633
+ var _a, _b;
10634
+ (_b = (_a = this.eventHandlers).close) === null || _b === void 0 ? void 0 : _b.call(_a, event);
10635
+ };
10636
+ this.handleError = (event) => {
10637
+ var _a, _b;
10638
+ const message = event.message;
10639
+ (_b = (_a = this.eventHandlers).error) === null || _b === void 0 ? void 0 : _b.call(_a, new Error(message));
10640
+ };
10641
+ this.socket = args.socket;
10642
+ this.socket.addEventListener("open", this.handleOpen);
10643
+ this.socket.addEventListener("message", this.handleMessage);
10644
+ this.socket.addEventListener("close", this.handleClose);
10645
+ this.socket.addEventListener("error", this.handleError);
10646
+ }
10647
+ /** The current state of the connection; this is one of the readyState constants. */
10313
10648
  get readyState() {
10314
10649
  return this.socket.readyState;
10315
10650
  }
@@ -10390,7 +10725,7 @@ var StreamSocket = class {
10390
10725
  }
10391
10726
  /** Returns a promise that resolves when the websocket is open. */
10392
10727
  waitForOpen() {
10393
- return __awaiter24(this, void 0, void 0, function* () {
10728
+ return __awaiter25(this, void 0, void 0, function* () {
10394
10729
  if (this.socket.readyState === ReconnectingWebSocket.OPEN) {
10395
10730
  return this.socket;
10396
10731
  }
@@ -10420,7 +10755,7 @@ var StreamSocket = class {
10420
10755
  };
10421
10756
 
10422
10757
  // node_modules/@corti/sdk/dist/esm/api/resources/stream/client/Client.mjs
10423
- var __awaiter25 = function(thisArg, _arguments, P2, generator) {
10758
+ var __awaiter26 = function(thisArg, _arguments, P2, generator) {
10424
10759
  function adopt(value) {
10425
10760
  return value instanceof P2 ? value : new P2(function(resolve) {
10426
10761
  resolve(value);
@@ -10452,7 +10787,7 @@ var Stream = class {
10452
10787
  this._options = _options;
10453
10788
  }
10454
10789
  connect(args) {
10455
- return __awaiter25(this, void 0, void 0, function* () {
10790
+ return __awaiter26(this, void 0, void 0, function* () {
10456
10791
  var _a;
10457
10792
  const { id, tenantName, token, headers, debug, reconnectAttempts } = args;
10458
10793
  const _queryParams = {};
@@ -10470,7 +10805,7 @@ var Stream = class {
10470
10805
  });
10471
10806
  }
10472
10807
  _getAuthorizationHeader() {
10473
- return __awaiter25(this, void 0, void 0, function* () {
10808
+ return __awaiter26(this, void 0, void 0, function* () {
10474
10809
  const bearer = yield Supplier.get(this._options.token);
10475
10810
  if (bearer != null) {
10476
10811
  return `Bearer ${bearer}`;
@@ -10516,8 +10851,72 @@ var StreamSocket2 = class extends StreamSocket {
10516
10851
  }
10517
10852
  };
10518
10853
 
10854
+ // node_modules/@corti/sdk/dist/esm/custom/utils/encodeHeadersAsWsProtocols.mjs
10855
+ var __awaiter27 = function(thisArg, _arguments, P2, generator) {
10856
+ function adopt(value) {
10857
+ return value instanceof P2 ? value : new P2(function(resolve) {
10858
+ resolve(value);
10859
+ });
10860
+ }
10861
+ return new (P2 || (P2 = Promise))(function(resolve, reject) {
10862
+ function fulfilled(value) {
10863
+ try {
10864
+ step(generator.next(value));
10865
+ } catch (e10) {
10866
+ reject(e10);
10867
+ }
10868
+ }
10869
+ function rejected(value) {
10870
+ try {
10871
+ step(generator["throw"](value));
10872
+ } catch (e10) {
10873
+ reject(e10);
10874
+ }
10875
+ }
10876
+ function step(result) {
10877
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
10878
+ }
10879
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10880
+ });
10881
+ };
10882
+ var SDK_HEADER_NAMES = /* @__PURE__ */ new Set([
10883
+ "Tenant-Name",
10884
+ "X-Fern-Language",
10885
+ "X-Fern-SDK-Name",
10886
+ "X-Fern-SDK-Version",
10887
+ "User-Agent",
10888
+ "X-Fern-Runtime",
10889
+ "X-Fern-Runtime-Version"
10890
+ ]);
10891
+ function buildProtocolsFromHeaders(headers_1) {
10892
+ return __awaiter27(this, arguments, void 0, function* (headers, filterSdkHeaders = false) {
10893
+ if (!headers || Object.keys(headers).length === 0) {
10894
+ return [];
10895
+ }
10896
+ const protocols = [];
10897
+ for (const [name, valueOrSupplier] of Object.entries(headers)) {
10898
+ if (filterSdkHeaders && SDK_HEADER_NAMES.has(name)) {
10899
+ continue;
10900
+ }
10901
+ const value = yield Supplier.get(valueOrSupplier);
10902
+ if (value != null && value !== "") {
10903
+ protocols.push(name, encodeURIComponent(value));
10904
+ }
10905
+ }
10906
+ return protocols;
10907
+ });
10908
+ }
10909
+ function getWsProtocols(options, proxyProtocols) {
10910
+ return __awaiter27(this, void 0, void 0, function* () {
10911
+ const headerProtocols = options.encodeHeadersAsWsProtocols && options.headers ? yield buildProtocolsFromHeaders(options.headers, true) : [];
10912
+ const resolvedProxy = proxyProtocols == null ? [] : Array.isArray(proxyProtocols) ? proxyProtocols : yield buildProtocolsFromHeaders(proxyProtocols, false);
10913
+ const combined = [...headerProtocols, ...resolvedProxy];
10914
+ return combined.length > 0 ? combined : [];
10915
+ });
10916
+ }
10917
+
10519
10918
  // node_modules/@corti/sdk/dist/esm/custom/CustomStream.mjs
10520
- var __awaiter26 = function(thisArg, _arguments, P2, generator) {
10919
+ var __awaiter28 = function(thisArg, _arguments, P2, generator) {
10521
10920
  function adopt(value) {
10522
10921
  return value instanceof P2 ? value : new P2(function(resolve) {
10523
10922
  resolve(value);
@@ -10556,23 +10955,32 @@ var __rest3 = function(s8, e10) {
10556
10955
  return t7;
10557
10956
  };
10558
10957
  var Stream2 = class extends Stream {
10958
+ /** Patch: constructor accepts extended options so _options is correctly typed. */
10959
+ constructor(_options) {
10960
+ super(_options);
10961
+ this._options = _options;
10962
+ }
10559
10963
  /**
10560
- * Patch: use custom connect method to support passing _options parameters
10561
- * Added optional `proxy` parameter for direct WebSocket connection (proxy scenarios)
10964
+ * Patch: use custom connect method to support passing _options parameters.
10965
+ * Patch: optional proxy parameter for direct WebSocket connection (proxy scenarios).
10966
+ * Patch: use proxy path when proxy is passed or encodeHeadersAsWsProtocols is set.
10967
+ * Patch: protocols from getWsProtocols; queryParameters from proxy or empty.
10562
10968
  */
10563
10969
  connect(_a) {
10564
10970
  const _super = Object.create(null, {
10565
10971
  connect: { get: () => super.connect }
10566
10972
  });
10567
- return __awaiter26(this, void 0, void 0, function* () {
10568
- var _b, _c;
10973
+ return __awaiter28(this, void 0, void 0, function* () {
10974
+ var _b, _c, _d, _e, _f;
10569
10975
  var { configuration, proxy } = _a, args = __rest3(_a, ["configuration", "proxy"]);
10570
- const socket = proxy ? new ReconnectingWebSocket({
10571
- url: proxy.url,
10572
- protocols: proxy.protocols || [],
10573
- queryParameters: proxy.queryParameters || {},
10574
- headers: args.headers || {},
10575
- options: { debug: (_b = args.debug) !== null && _b !== void 0 ? _b : false, maxRetries: (_c = args.reconnectAttempts) !== null && _c !== void 0 ? _c : 30 }
10976
+ const useProxyPath = proxy || this._options.encodeHeadersAsWsProtocols;
10977
+ const protocols = yield getWsProtocols(this._options, proxy === null || proxy === void 0 ? void 0 : proxy.protocols);
10978
+ const socket = useProxyPath ? new ReconnectingWebSocket({
10979
+ url: (proxy === null || proxy === void 0 ? void 0 : proxy.url) || url_exports.join((_b = yield Supplier.get(this._options["baseUrl"])) !== null && _b !== void 0 ? _b : (yield Supplier.get(this._options["environment"])).wss, `/interactions/${encodeURIComponent(args.id)}/streams`),
10980
+ protocols,
10981
+ queryParameters: (_c = proxy === null || proxy === void 0 ? void 0 : proxy.queryParameters) !== null && _c !== void 0 ? _c : {},
10982
+ headers: (_d = args.headers) !== null && _d !== void 0 ? _d : {},
10983
+ options: { debug: (_e = args.debug) !== null && _e !== void 0 ? _e : false, maxRetries: (_f = args.reconnectAttempts) !== null && _f !== void 0 ? _f : 30 }
10576
10984
  }) : (yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield Supplier.get(this._options.tenantName) }))).socket;
10577
10985
  const ws = new StreamSocket2({ socket });
10578
10986
  if (!configuration) {
@@ -10623,7 +11031,7 @@ var Stream2 = class extends Stream {
10623
11031
  };
10624
11032
 
10625
11033
  // node_modules/@corti/sdk/dist/esm/api/resources/transcribe/client/Socket.mjs
10626
- var __awaiter27 = function(thisArg, _arguments, P2, generator) {
11034
+ var __awaiter29 = function(thisArg, _arguments, P2, generator) {
10627
11035
  function adopt(value) {
10628
11036
  return value instanceof P2 ? value : new P2(function(resolve) {
10629
11037
  resolve(value);
@@ -10769,7 +11177,7 @@ var TranscribeSocket = class {
10769
11177
  }
10770
11178
  /** Returns a promise that resolves when the websocket is open. */
10771
11179
  waitForOpen() {
10772
- return __awaiter27(this, void 0, void 0, function* () {
11180
+ return __awaiter29(this, void 0, void 0, function* () {
10773
11181
  if (this.socket.readyState === ReconnectingWebSocket.OPEN) {
10774
11182
  return this.socket;
10775
11183
  }
@@ -10799,7 +11207,7 @@ var TranscribeSocket = class {
10799
11207
  };
10800
11208
 
10801
11209
  // node_modules/@corti/sdk/dist/esm/api/resources/transcribe/client/Client.mjs
10802
- var __awaiter28 = function(thisArg, _arguments, P2, generator) {
11210
+ var __awaiter30 = function(thisArg, _arguments, P2, generator) {
10803
11211
  function adopt(value) {
10804
11212
  return value instanceof P2 ? value : new P2(function(resolve) {
10805
11213
  resolve(value);
@@ -10831,7 +11239,7 @@ var Transcribe = class {
10831
11239
  this._options = _options;
10832
11240
  }
10833
11241
  connect(args) {
10834
- return __awaiter28(this, void 0, void 0, function* () {
11242
+ return __awaiter30(this, void 0, void 0, function* () {
10835
11243
  var _a;
10836
11244
  const { tenantName, token, headers, debug, reconnectAttempts } = args;
10837
11245
  const _queryParams = {};
@@ -10849,7 +11257,7 @@ var Transcribe = class {
10849
11257
  });
10850
11258
  }
10851
11259
  _getAuthorizationHeader() {
10852
- return __awaiter28(this, void 0, void 0, function* () {
11260
+ return __awaiter30(this, void 0, void 0, function* () {
10853
11261
  const bearer = yield Supplier.get(this._options.token);
10854
11262
  if (bearer != null) {
10855
11263
  return `Bearer ${bearer}`;
@@ -10896,7 +11304,7 @@ var TranscribeSocket2 = class extends TranscribeSocket {
10896
11304
  };
10897
11305
 
10898
11306
  // node_modules/@corti/sdk/dist/esm/custom/CustomTranscribe.mjs
10899
- var __awaiter29 = function(thisArg, _arguments, P2, generator) {
11307
+ var __awaiter31 = function(thisArg, _arguments, P2, generator) {
10900
11308
  function adopt(value) {
10901
11309
  return value instanceof P2 ? value : new P2(function(resolve) {
10902
11310
  resolve(value);
@@ -10935,23 +11343,32 @@ var __rest4 = function(s8, e10) {
10935
11343
  return t7;
10936
11344
  };
10937
11345
  var Transcribe2 = class extends Transcribe {
11346
+ /** Patch: constructor accepts extended options so _options is correctly typed. */
11347
+ constructor(_options) {
11348
+ super(_options);
11349
+ this._options = _options;
11350
+ }
10938
11351
  /**
10939
- * Patch: use custom connect method to support passing _options parameters
10940
- * Added optional `proxy` parameter for direct WebSocket connection (proxy scenarios)
11352
+ * Patch: use custom connect method to support passing _options parameters.
11353
+ * Patch: optional proxy parameter for direct WebSocket connection (proxy scenarios).
11354
+ * Patch: use proxy path when proxy is passed or encodeHeadersAsWsProtocols is set.
11355
+ * Patch: protocols from getWsProtocols; queryParameters from proxy or empty.
10941
11356
  */
10942
11357
  connect() {
10943
11358
  const _super = Object.create(null, {
10944
11359
  connect: { get: () => super.connect }
10945
11360
  });
10946
- return __awaiter29(this, arguments, void 0, function* (_a = {}) {
10947
- var _b, _c;
11361
+ return __awaiter31(this, arguments, void 0, function* (_a = {}) {
11362
+ var _b, _c, _d, _e, _f;
10948
11363
  var { configuration, proxy } = _a, args = __rest4(_a, ["configuration", "proxy"]);
10949
- const socket = proxy ? new ReconnectingWebSocket({
10950
- url: proxy.url,
10951
- protocols: proxy.protocols || [],
10952
- queryParameters: proxy.queryParameters || {},
10953
- headers: args.headers || {},
10954
- options: { debug: (_b = args.debug) !== null && _b !== void 0 ? _b : false, maxRetries: (_c = args.reconnectAttempts) !== null && _c !== void 0 ? _c : 30 }
11364
+ const useProxyPath = proxy || this._options.encodeHeadersAsWsProtocols;
11365
+ const protocols = yield getWsProtocols(this._options, proxy === null || proxy === void 0 ? void 0 : proxy.protocols);
11366
+ const socket = useProxyPath ? new ReconnectingWebSocket({
11367
+ url: (proxy === null || proxy === void 0 ? void 0 : proxy.url) || url_exports.join((_b = yield Supplier.get(this._options["baseUrl"])) !== null && _b !== void 0 ? _b : (yield Supplier.get(this._options["environment"])).wss, "/transcribe"),
11368
+ protocols,
11369
+ queryParameters: (_c = proxy === null || proxy === void 0 ? void 0 : proxy.queryParameters) !== null && _c !== void 0 ? _c : {},
11370
+ headers: (_d = args.headers) !== null && _d !== void 0 ? _d : {},
11371
+ options: { debug: (_e = args.debug) !== null && _e !== void 0 ? _e : false, maxRetries: (_f = args.reconnectAttempts) !== null && _f !== void 0 ? _f : 30 }
10955
11372
  }) : (yield _super.connect.call(this, Object.assign(Object.assign({}, args), { token: (yield this._getAuthorizationHeader()) || "", tenantName: yield Supplier.get(this._options.tenantName) }))).socket;
10956
11373
  const ws = new TranscribeSocket2({ socket });
10957
11374
  if (!configuration) {
@@ -11002,10 +11419,10 @@ var Transcribe2 = class extends Transcribe {
11002
11419
  };
11003
11420
 
11004
11421
  // node_modules/@corti/sdk/dist/esm/version.mjs
11005
- var SDK_VERSION = "0.8.0";
11422
+ var SDK_VERSION = "0.10.1";
11006
11423
 
11007
11424
  // node_modules/@corti/sdk/dist/esm/custom/utils/resolveClientOptions.mjs
11008
- var __awaiter30 = function(thisArg, _arguments, P2, generator) {
11425
+ var __awaiter32 = function(thisArg, _arguments, P2, generator) {
11009
11426
  function adopt(value) {
11010
11427
  return value instanceof P2 ? value : new P2(function(resolve) {
11011
11428
  resolve(value);
@@ -11070,7 +11487,7 @@ function resolveClientOptions(options) {
11070
11487
  };
11071
11488
  }
11072
11489
  const auth = options.auth;
11073
- const tokenResponsePromise = (() => __awaiter30(this, void 0, void 0, function* () {
11490
+ const tokenResponsePromise = (() => __awaiter32(this, void 0, void 0, function* () {
11074
11491
  const tokenResponse = yield Supplier.get(auth.refreshAccessToken);
11075
11492
  const decoded = decodeToken2(tokenResponse.accessToken);
11076
11493
  if (!decoded && !options.baseUrl && typeof options.environment !== "object") {
@@ -11095,7 +11512,7 @@ function resolveClientOptions(options) {
11095
11512
  }
11096
11513
 
11097
11514
  // node_modules/@corti/sdk/dist/esm/custom/CortiClient.mjs
11098
- var __awaiter31 = function(thisArg, _arguments, P2, generator) {
11515
+ var __awaiter33 = function(thisArg, _arguments, P2, generator) {
11099
11516
  function adopt(value) {
11100
11517
  return value instanceof P2 ? value : new P2(function(resolve) {
11101
11518
  resolve(value);
@@ -11136,7 +11553,10 @@ var CortiClient = class {
11136
11553
  "User-Agent": `@corti/sdk/${SDK_VERSION}`,
11137
11554
  "X-Fern-Runtime": RUNTIME.type,
11138
11555
  "X-Fern-Runtime-Version": RUNTIME.version
11139
- }, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: _options.auth && "clientId" in _options.auth ? _options.auth.clientId : void 0, clientSecret: _options.auth && "clientSecret" in _options.auth ? _options.auth.clientSecret : void 0, token: _options.auth && "accessToken" in _options.auth ? _options.auth.accessToken : void 0, tenantName, environment: getEnvironment(environment) });
11556
+ }, _options === null || _options === void 0 ? void 0 : _options.headers), clientId: _options.auth && "clientId" in _options.auth ? _options.auth.clientId : void 0, clientSecret: _options.auth && "clientSecret" in _options.auth ? _options.auth.clientSecret : void 0, token: _options.auth && "accessToken" in _options.auth ? _options.auth.accessToken : void 0, tenantName, environment: getEnvironment(environment), withCredentials: _options.withCredentials });
11557
+ if (_options.withCredentials !== void 0) {
11558
+ setDefaultWithCredentials(_options.withCredentials);
11559
+ }
11140
11560
  if (_options.auth) {
11141
11561
  this._oauthTokenProvider = "clientId" in _options.auth ? new OAuthTokenProvider({
11142
11562
  clientId: _options.auth.clientId,
@@ -11150,55 +11570,61 @@ var CortiClient = class {
11150
11570
  }
11151
11571
  get interactions() {
11152
11572
  var _a;
11153
- return (_a = this._interactions) !== null && _a !== void 0 ? _a : this._interactions = new Interactions(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11573
+ return (_a = this._interactions) !== null && _a !== void 0 ? _a : this._interactions = new Interactions(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11154
11574
  return yield this._oauthTokenProvider.getToken();
11155
11575
  }) : void 0 }));
11156
11576
  }
11157
11577
  get recordings() {
11158
11578
  var _a;
11159
- return (_a = this._recordings) !== null && _a !== void 0 ? _a : this._recordings = new Recordings(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11579
+ return (_a = this._recordings) !== null && _a !== void 0 ? _a : this._recordings = new Recordings(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11160
11580
  return yield this._oauthTokenProvider.getToken();
11161
11581
  }) : void 0 }));
11162
11582
  }
11163
11583
  get transcripts() {
11164
11584
  var _a;
11165
- return (_a = this._transcripts) !== null && _a !== void 0 ? _a : this._transcripts = new Transcripts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11585
+ return (_a = this._transcripts) !== null && _a !== void 0 ? _a : this._transcripts = new Transcripts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11166
11586
  return yield this._oauthTokenProvider.getToken();
11167
11587
  }) : void 0 }));
11168
11588
  }
11169
11589
  get facts() {
11170
11590
  var _a;
11171
- return (_a = this._facts) !== null && _a !== void 0 ? _a : this._facts = new Facts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11591
+ return (_a = this._facts) !== null && _a !== void 0 ? _a : this._facts = new Facts(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11172
11592
  return yield this._oauthTokenProvider.getToken();
11173
11593
  }) : void 0 }));
11174
11594
  }
11175
11595
  get documents() {
11176
11596
  var _a;
11177
- return (_a = this._documents) !== null && _a !== void 0 ? _a : this._documents = new Documents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11597
+ return (_a = this._documents) !== null && _a !== void 0 ? _a : this._documents = new Documents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11178
11598
  return yield this._oauthTokenProvider.getToken();
11179
11599
  }) : void 0 }));
11180
11600
  }
11181
11601
  get templates() {
11182
11602
  var _a;
11183
- return (_a = this._templates) !== null && _a !== void 0 ? _a : this._templates = new Templates(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11603
+ return (_a = this._templates) !== null && _a !== void 0 ? _a : this._templates = new Templates(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11184
11604
  return yield this._oauthTokenProvider.getToken();
11185
11605
  }) : void 0 }));
11186
11606
  }
11187
11607
  get agents() {
11188
11608
  var _a;
11189
- return (_a = this._agents) !== null && _a !== void 0 ? _a : this._agents = new Agents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11609
+ return (_a = this._agents) !== null && _a !== void 0 ? _a : this._agents = new Agents(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11190
11610
  return yield this._oauthTokenProvider.getToken();
11191
11611
  }) : void 0 }));
11192
11612
  }
11193
11613
  get stream() {
11194
11614
  var _a;
11195
- return (_a = this._stream) !== null && _a !== void 0 ? _a : this._stream = new Stream2(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11615
+ return (_a = this._stream) !== null && _a !== void 0 ? _a : this._stream = new Stream2(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11196
11616
  return yield this._oauthTokenProvider.getToken();
11197
11617
  }) : void 0 }));
11198
11618
  }
11199
11619
  get transcribe() {
11200
11620
  var _a;
11201
- return (_a = this._transcribe) !== null && _a !== void 0 ? _a : this._transcribe = new Transcribe2(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter31(this, void 0, void 0, function* () {
11621
+ return (_a = this._transcribe) !== null && _a !== void 0 ? _a : this._transcribe = new Transcribe2(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11622
+ return yield this._oauthTokenProvider.getToken();
11623
+ }) : void 0 }));
11624
+ }
11625
+ get codes() {
11626
+ var _a;
11627
+ return (_a = this._codes) !== null && _a !== void 0 ? _a : this._codes = new Codes(Object.assign(Object.assign({}, this._options), { token: this._oauthTokenProvider ? () => __awaiter33(this, void 0, void 0, function* () {
11202
11628
  return yield this._oauthTokenProvider.getToken();
11203
11629
  }) : void 0 }));
11204
11630
  }
@@ -11278,11 +11704,18 @@ var _DictationController_callbacks;
11278
11704
  var _DictationController_lastDictationConfig;
11279
11705
  var _DictationController_lastSocketUrl;
11280
11706
  var _DictationController_lastSocketProxy;
11707
+ var _DictationController_outboundQueue;
11708
+ var _DictationController_socketReady;
11709
+ var _DictationController_connectingPromise;
11710
+ var _DictationController_connectionGeneration;
11711
+ var _DictationController_isConnecting;
11281
11712
  var _DictationController_configHasChanged;
11713
+ var _DictationController_doConnect;
11282
11714
  var _DictationController_connectProxy;
11283
11715
  var _DictationController_connectAuth;
11284
11716
  var _DictationController_setupWebSocketHandlers;
11285
- var _DictationController_setupMediaRecorder;
11717
+ var _DictationController_isSocketOpen;
11718
+ var _DictationController_drain;
11286
11719
  var DictationController = class {
11287
11720
  constructor(host) {
11288
11721
  _DictationController_instances.add(this);
@@ -11293,43 +11726,66 @@ var DictationController = class {
11293
11726
  _DictationController_lastDictationConfig.set(this, null);
11294
11727
  _DictationController_lastSocketUrl.set(this, void 0);
11295
11728
  _DictationController_lastSocketProxy.set(this, void 0);
11729
+ _DictationController_outboundQueue.set(this, []);
11730
+ _DictationController_socketReady.set(this, false);
11731
+ _DictationController_connectingPromise.set(this, null);
11732
+ _DictationController_connectionGeneration.set(this, 0);
11733
+ _DictationController_isConnecting.set(this, false);
11734
+ this.mediaRecorderHandler = (data) => {
11735
+ if (__classPrivateFieldGet4(this, _DictationController_socketReady, "f") && __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_isSocketOpen).call(this)) {
11736
+ __classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.send(data);
11737
+ __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", {
11738
+ size: data.size,
11739
+ type: "audio"
11740
+ });
11741
+ return;
11742
+ }
11743
+ __classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").push(data);
11744
+ };
11296
11745
  this.host = host;
11297
11746
  host.addController(this);
11298
11747
  }
11299
11748
  hostDisconnected() {
11300
11749
  this.cleanup();
11301
11750
  }
11302
- async connect(mediaRecorder, dictationConfig = DEFAULT_DICTATION_CONFIG, callbacks = {}) {
11303
- if (!mediaRecorder) {
11304
- throw new Error("MediaRecorder is required to connect");
11751
+ async connect(dictationConfig = DEFAULT_DICTATION_CONFIG, callbacks = {}) {
11752
+ if (__classPrivateFieldGet4(this, _DictationController_connectingPromise, "f") && !__classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_configHasChanged).call(this)) {
11753
+ return __classPrivateFieldGet4(this, _DictationController_connectingPromise, "f");
11305
11754
  }
11306
- const newConnection = __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_configHasChanged).call(this) || __classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.readyState !== WebSocket.OPEN;
11307
- if (newConnection) {
11308
- this.cleanup();
11309
- if (__classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.readyState === WebSocket.OPEN) {
11310
- throw new Error("Already connected. Disconnect before reconnecting.");
11311
- }
11312
- __classPrivateFieldSet3(this, _DictationController_webSocket, this.host._socketUrl || this.host._socketProxy ? await __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_connectProxy).call(this, dictationConfig) : await __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_connectAuth).call(this, dictationConfig), "f");
11313
- __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", {
11314
- configuration: dictationConfig,
11315
- type: "config"
11316
- });
11317
- __classPrivateFieldSet3(this, _DictationController_lastDictationConfig, this.host._dictationConfig || null, "f");
11318
- __classPrivateFieldSet3(this, _DictationController_lastSocketUrl, this.host._socketUrl, "f");
11319
- __classPrivateFieldSet3(this, _DictationController_lastSocketProxy, this.host._socketProxy, "f");
11755
+ __classPrivateFieldSet3(this, _DictationController_isConnecting, true, "f");
11756
+ __classPrivateFieldSet3(this, _DictationController_connectingPromise, __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_doConnect).call(this, dictationConfig, callbacks).finally(() => {
11757
+ __classPrivateFieldSet3(this, _DictationController_isConnecting, false, "f");
11758
+ __classPrivateFieldSet3(this, _DictationController_connectingPromise, null, "f");
11759
+ }), "f");
11760
+ return __classPrivateFieldGet4(this, _DictationController_connectingPromise, "f");
11761
+ }
11762
+ async pause() {
11763
+ if (__classPrivateFieldGet4(this, _DictationController_socketReady, "f") && __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_isSocketOpen).call(this)) {
11764
+ __classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.send(JSON.stringify({ type: "flush" }));
11765
+ __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", { type: "flush" });
11766
+ return;
11320
11767
  }
11321
- __classPrivateFieldSet3(this, _DictationController_callbacks, callbacks, "f");
11322
- __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_setupMediaRecorder).call(this, mediaRecorder);
11323
- __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_setupWebSocketHandlers).call(this, callbacks);
11324
- return newConnection;
11768
+ __classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").push({ type: "flush" });
11769
+ }
11770
+ isConnectionOpen() {
11771
+ return __classPrivateFieldGet4(this, _DictationController_webSocket, "f") !== null && (__classPrivateFieldGet4(this, _DictationController_webSocket, "f").readyState === WebSocket.OPEN || __classPrivateFieldGet4(this, _DictationController_webSocket, "f").readyState === WebSocket.CONNECTING);
11772
+ }
11773
+ isConnecting() {
11774
+ return __classPrivateFieldGet4(this, _DictationController_isConnecting, "f");
11775
+ }
11776
+ async waitForConnection() {
11777
+ await __classPrivateFieldGet4(this, _DictationController_connectingPromise, "f");
11325
11778
  }
11326
- async disconnect(onClose) {
11779
+ async closeConnection(onClose) {
11327
11780
  await new Promise((resolve, reject) => {
11328
- if (!__classPrivateFieldGet4(this, _DictationController_webSocket, "f") || __classPrivateFieldGet4(this, _DictationController_webSocket, "f").readyState !== WebSocket.OPEN) {
11781
+ const oldSocket = __classPrivateFieldGet4(this, _DictationController_webSocket, "f");
11782
+ __classPrivateFieldSet3(this, _DictationController_webSocket, null, "f");
11783
+ if (!oldSocket || oldSocket.readyState !== WebSocket.OPEN && oldSocket.readyState !== WebSocket.CONNECTING) {
11784
+ __classPrivateFieldSet3(this, _DictationController_socketReady, false, "f");
11329
11785
  resolve();
11330
11786
  return;
11331
11787
  }
11332
- __classPrivateFieldGet4(this, _DictationController_webSocket, "f").on("close", (event) => {
11788
+ oldSocket.on("close", (event) => {
11333
11789
  if (__classPrivateFieldGet4(this, _DictationController_closeTimeout, "f")) {
11334
11790
  clearTimeout(__classPrivateFieldGet4(this, _DictationController_closeTimeout, "f"));
11335
11791
  __classPrivateFieldSet3(this, _DictationController_closeTimeout, void 0, "f");
@@ -11339,12 +11795,19 @@ var DictationController = class {
11339
11795
  }
11340
11796
  resolve();
11341
11797
  });
11342
- __classPrivateFieldGet4(this, _DictationController_webSocket, "f").on("message", (message) => {
11798
+ const wasReady = __classPrivateFieldGet4(this, _DictationController_socketReady, "f");
11799
+ __classPrivateFieldSet3(this, _DictationController_socketReady, false, "f");
11800
+ oldSocket.on("message", (message) => {
11343
11801
  __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("received", message);
11344
11802
  if (__classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onMessage) {
11345
11803
  __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onMessage(message);
11346
11804
  }
11347
- if (message.type === "flushed") {
11805
+ if (!wasReady && message.type === "CONFIG_ACCEPTED") {
11806
+ oldSocket.sendEnd({ type: "end" });
11807
+ __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", { type: "end" });
11808
+ return;
11809
+ }
11810
+ if (message.type === "ended") {
11348
11811
  if (__classPrivateFieldGet4(this, _DictationController_closeTimeout, "f")) {
11349
11812
  clearTimeout(__classPrivateFieldGet4(this, _DictationController_closeTimeout, "f"));
11350
11813
  __classPrivateFieldSet3(this, _DictationController_closeTimeout, void 0, "f");
@@ -11353,33 +11816,68 @@ var DictationController = class {
11353
11816
  return;
11354
11817
  }
11355
11818
  });
11356
- __classPrivateFieldGet4(this, _DictationController_webSocket, "f").sendFlush({ type: "flush" });
11357
- __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", { type: "flush" });
11819
+ if (wasReady) {
11820
+ oldSocket.sendEnd({ type: "end" });
11821
+ __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", { type: "end" });
11822
+ }
11358
11823
  __classPrivateFieldSet3(this, _DictationController_closeTimeout, window.setTimeout(() => {
11359
- reject(new Error("Audio processing timeout"));
11360
- if (__classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.readyState === WebSocket.OPEN) {
11361
- __classPrivateFieldGet4(this, _DictationController_webSocket, "f").close();
11824
+ reject(new Error("Connection close timeout"));
11825
+ if (oldSocket?.readyState === WebSocket.OPEN) {
11826
+ oldSocket.close();
11362
11827
  }
11363
11828
  }, 1e4), "f");
11364
11829
  });
11365
11830
  }
11366
11831
  cleanup() {
11832
+ var _a;
11833
+ __classPrivateFieldSet3(this, _DictationController_connectionGeneration, (_a = __classPrivateFieldGet4(this, _DictationController_connectionGeneration, "f"), _a++, _a), "f");
11834
+ __classPrivateFieldSet3(this, _DictationController_socketReady, false, "f");
11367
11835
  if (__classPrivateFieldGet4(this, _DictationController_closeTimeout, "f")) {
11368
11836
  clearTimeout(__classPrivateFieldGet4(this, _DictationController_closeTimeout, "f"));
11369
11837
  __classPrivateFieldSet3(this, _DictationController_closeTimeout, void 0, "f");
11370
11838
  }
11371
- if (__classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.readyState === WebSocket.OPEN) {
11372
- __classPrivateFieldGet4(this, _DictationController_webSocket, "f").close();
11839
+ if (this.isConnectionOpen()) {
11840
+ __classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.close();
11373
11841
  }
11374
11842
  __classPrivateFieldSet3(this, _DictationController_webSocket, null, "f");
11375
11843
  __classPrivateFieldSet3(this, _DictationController_cortiClient, null, "f");
11376
11844
  __classPrivateFieldSet3(this, _DictationController_lastDictationConfig, null, "f");
11377
11845
  __classPrivateFieldSet3(this, _DictationController_lastSocketUrl, void 0, "f");
11378
11846
  __classPrivateFieldSet3(this, _DictationController_lastSocketProxy, void 0, "f");
11847
+ if (__classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").length > 0) {
11848
+ this.host.dispatchEvent(errorEvent(`${__classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").length} unsent message(s) were discarded because the configuration changed before the connection was closed`));
11849
+ }
11850
+ __classPrivateFieldSet3(this, _DictationController_outboundQueue, [], "f");
11379
11851
  }
11380
11852
  };
11381
- _DictationController_cortiClient = /* @__PURE__ */ new WeakMap(), _DictationController_webSocket = /* @__PURE__ */ new WeakMap(), _DictationController_closeTimeout = /* @__PURE__ */ new WeakMap(), _DictationController_callbacks = /* @__PURE__ */ new WeakMap(), _DictationController_lastDictationConfig = /* @__PURE__ */ new WeakMap(), _DictationController_lastSocketUrl = /* @__PURE__ */ new WeakMap(), _DictationController_lastSocketProxy = /* @__PURE__ */ new WeakMap(), _DictationController_instances = /* @__PURE__ */ new WeakSet(), _DictationController_configHasChanged = function _DictationController_configHasChanged2() {
11853
+ _DictationController_cortiClient = /* @__PURE__ */ new WeakMap(), _DictationController_webSocket = /* @__PURE__ */ new WeakMap(), _DictationController_closeTimeout = /* @__PURE__ */ new WeakMap(), _DictationController_callbacks = /* @__PURE__ */ new WeakMap(), _DictationController_lastDictationConfig = /* @__PURE__ */ new WeakMap(), _DictationController_lastSocketUrl = /* @__PURE__ */ new WeakMap(), _DictationController_lastSocketProxy = /* @__PURE__ */ new WeakMap(), _DictationController_outboundQueue = /* @__PURE__ */ new WeakMap(), _DictationController_socketReady = /* @__PURE__ */ new WeakMap(), _DictationController_connectingPromise = /* @__PURE__ */ new WeakMap(), _DictationController_connectionGeneration = /* @__PURE__ */ new WeakMap(), _DictationController_isConnecting = /* @__PURE__ */ new WeakMap(), _DictationController_instances = /* @__PURE__ */ new WeakSet(), _DictationController_configHasChanged = function _DictationController_configHasChanged2() {
11382
11854
  return JSON.stringify(this.host._dictationConfig) !== JSON.stringify(__classPrivateFieldGet4(this, _DictationController_lastDictationConfig, "f")) || this.host._socketUrl !== __classPrivateFieldGet4(this, _DictationController_lastSocketUrl, "f") || JSON.stringify(this.host._socketProxy) !== JSON.stringify(__classPrivateFieldGet4(this, _DictationController_lastSocketProxy, "f"));
11855
+ }, _DictationController_doConnect = async function _DictationController_doConnect2(dictationConfig, callbacks) {
11856
+ const newConnection = __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_configHasChanged).call(this) || !this.isConnectionOpen();
11857
+ if (newConnection) {
11858
+ this.cleanup();
11859
+ __classPrivateFieldSet3(this, _DictationController_lastDictationConfig, this.host._dictationConfig || null, "f");
11860
+ __classPrivateFieldSet3(this, _DictationController_lastSocketUrl, this.host._socketUrl, "f");
11861
+ __classPrivateFieldSet3(this, _DictationController_lastSocketProxy, this.host._socketProxy, "f");
11862
+ const generation = __classPrivateFieldGet4(this, _DictationController_connectionGeneration, "f");
11863
+ const socket = this.host._socketUrl || this.host._socketProxy ? await __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_connectProxy).call(this, dictationConfig) : await __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_connectAuth).call(this, dictationConfig);
11864
+ if (__classPrivateFieldGet4(this, _DictationController_connectionGeneration, "f") !== generation) {
11865
+ socket.close();
11866
+ return "superseded";
11867
+ }
11868
+ __classPrivateFieldSet3(this, _DictationController_webSocket, socket, "f");
11869
+ __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", {
11870
+ configuration: dictationConfig,
11871
+ type: "config"
11872
+ });
11873
+ }
11874
+ __classPrivateFieldSet3(this, _DictationController_callbacks, callbacks, "f");
11875
+ __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_setupWebSocketHandlers).call(this, callbacks);
11876
+ if (!newConnection && this.isConnectionOpen()) {
11877
+ __classPrivateFieldSet3(this, _DictationController_socketReady, true, "f");
11878
+ __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_drain).call(this);
11879
+ }
11880
+ return newConnection;
11383
11881
  }, _DictationController_connectProxy = async function _DictationController_connectProxy2(dictationConfig) {
11384
11882
  const proxyOptions = this.host._socketProxy || {
11385
11883
  url: this.host._socketUrl || ""
@@ -11414,31 +11912,118 @@ _DictationController_cortiClient = /* @__PURE__ */ new WeakMap(), _DictationCont
11414
11912
  throw new Error("WebSocket not initialized");
11415
11913
  }
11416
11914
  __classPrivateFieldGet4(this, _DictationController_webSocket, "f").on("message", (message) => {
11915
+ if (message.type === "CONFIG_ACCEPTED") {
11916
+ __classPrivateFieldSet3(this, _DictationController_socketReady, true, "f");
11917
+ __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_drain).call(this);
11918
+ }
11417
11919
  callbacks.onNetworkActivity?.("received", message);
11418
11920
  if (callbacks.onMessage) {
11419
11921
  callbacks.onMessage(message);
11420
11922
  }
11421
11923
  });
11422
11924
  __classPrivateFieldGet4(this, _DictationController_webSocket, "f").on("error", (event) => {
11925
+ __classPrivateFieldSet3(this, _DictationController_socketReady, false, "f");
11423
11926
  if (callbacks.onError) {
11424
11927
  callbacks.onError(event);
11425
11928
  }
11426
11929
  });
11427
11930
  __classPrivateFieldGet4(this, _DictationController_webSocket, "f").on("close", (event) => {
11931
+ __classPrivateFieldSet3(this, _DictationController_socketReady, false, "f");
11428
11932
  if (callbacks.onClose) {
11429
11933
  callbacks.onClose(event);
11430
11934
  }
11431
- });
11432
- }, _DictationController_setupMediaRecorder = function _DictationController_setupMediaRecorder2(mediaRecorder) {
11433
- mediaRecorder.ondataavailable = (event) => {
11434
- __classPrivateFieldGet4(this, _DictationController_webSocket, "f")?.sendAudio(event.data);
11935
+ });
11936
+ }, _DictationController_isSocketOpen = function _DictationController_isSocketOpen2() {
11937
+ return __classPrivateFieldGet4(this, _DictationController_webSocket, "f") !== null && __classPrivateFieldGet4(this, _DictationController_webSocket, "f").readyState === WebSocket.OPEN;
11938
+ }, _DictationController_drain = function _DictationController_drain2() {
11939
+ if (!__classPrivateFieldGet4(this, _DictationController_socketReady, "f") || !__classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_isSocketOpen).call(this) || __classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").length === 0) {
11940
+ return;
11941
+ }
11942
+ while (__classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").length > 0 && __classPrivateFieldGet4(this, _DictationController_instances, "m", _DictationController_isSocketOpen).call(this)) {
11943
+ const item = __classPrivateFieldGet4(this, _DictationController_outboundQueue, "f").shift();
11944
+ if (item === void 0) {
11945
+ break;
11946
+ }
11947
+ if (item instanceof Blob) {
11948
+ __classPrivateFieldGet4(this, _DictationController_webSocket, "f").send(item);
11949
+ __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", {
11950
+ size: item.size,
11951
+ type: "audio"
11952
+ });
11953
+ continue;
11954
+ }
11955
+ __classPrivateFieldGet4(this, _DictationController_webSocket, "f").send(JSON.stringify(item));
11435
11956
  __classPrivateFieldGet4(this, _DictationController_callbacks, "f")?.onNetworkActivity?.("sent", {
11436
- size: event.data.size,
11437
- type: "audio"
11957
+ type: item.type
11438
11958
  });
11439
- };
11959
+ }
11440
11960
  };
11441
11961
 
11962
+ // dist/utils/keybinding.js
11963
+ function isMac() {
11964
+ if (typeof navigator === "undefined") {
11965
+ return false;
11966
+ }
11967
+ return /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
11968
+ }
11969
+ function capitalize(str) {
11970
+ if (str.length === 0) {
11971
+ return str;
11972
+ }
11973
+ return str.charAt(0).toUpperCase() + str.slice(1);
11974
+ }
11975
+ function normalizeKeyForKeybinding(key) {
11976
+ if (key === " ") {
11977
+ return "Space";
11978
+ }
11979
+ const normalized = key.trim().toLowerCase();
11980
+ if (normalized === "control") {
11981
+ return "Ctrl";
11982
+ }
11983
+ if (normalized === "meta" || normalized === "cmd") {
11984
+ return isMac() ? "Cmd" : "Meta";
11985
+ }
11986
+ if (normalized === "alt" || normalized === "opt") {
11987
+ return isMac() ? "Opt" : "Alt";
11988
+ }
11989
+ if (normalized === "space") {
11990
+ return "Space";
11991
+ }
11992
+ return normalized.length > 1 ? capitalize(normalized) : normalized;
11993
+ }
11994
+ function normalizeKeybinding(keybinding) {
11995
+ if (!keybinding) {
11996
+ return null;
11997
+ }
11998
+ const trimmed = keybinding.trim();
11999
+ if (trimmed === "") {
12000
+ return null;
12001
+ }
12002
+ return normalizeKeyForKeybinding(trimmed);
12003
+ }
12004
+ function matchesKeybinding(event, keybinding) {
12005
+ const normalizedKeybinding = normalizeKeybinding(keybinding);
12006
+ if (!normalizedKeybinding) {
12007
+ return false;
12008
+ }
12009
+ const normalizedKey = normalizeKeyForKeybinding(event.key);
12010
+ const normalizedCode = normalizeKeyForKeybinding(event.code);
12011
+ return normalizedKey === normalizedKeybinding || normalizedCode === normalizedKeybinding;
12012
+ }
12013
+ function shouldIgnoreKeybinding(element) {
12014
+ if (!element) {
12015
+ return false;
12016
+ }
12017
+ const tagName = element.tagName.toLowerCase();
12018
+ if (tagName === "input" || tagName === "textarea") {
12019
+ return true;
12020
+ }
12021
+ if (element instanceof HTMLElement && element.contentEditable === "true") {
12022
+ return true;
12023
+ }
12024
+ return false;
12025
+ }
12026
+
11442
12027
  // dist/controllers/keybinding-controller.js
11443
12028
  var __classPrivateFieldGet5 = function(receiver, state, kind, f5) {
11444
12029
  if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a getter");
@@ -11455,6 +12040,7 @@ var _KeybindingController_instances;
11455
12040
  var _KeybindingController_keydownHandler;
11456
12041
  var _KeybindingController_keyupHandler;
11457
12042
  var _KeybindingController_blurHandler;
12043
+ var _KeybindingController_isPushToTalkKeyPressed;
11458
12044
  var _KeybindingController_setupListeners;
11459
12045
  var _KeybindingController_removeListeners;
11460
12046
  var KeybindingController = class {
@@ -11463,6 +12049,7 @@ var KeybindingController = class {
11463
12049
  _KeybindingController_keydownHandler.set(this, void 0);
11464
12050
  _KeybindingController_keyupHandler.set(this, void 0);
11465
12051
  _KeybindingController_blurHandler.set(this, void 0);
12052
+ _KeybindingController_isPushToTalkKeyPressed.set(this, false);
11466
12053
  this.host = host;
11467
12054
  host.addController(this);
11468
12055
  }
@@ -11473,40 +12060,39 @@ var KeybindingController = class {
11473
12060
  __classPrivateFieldGet5(this, _KeybindingController_instances, "m", _KeybindingController_removeListeners).call(this);
11474
12061
  }
11475
12062
  };
11476
- _KeybindingController_keydownHandler = /* @__PURE__ */ new WeakMap(), _KeybindingController_keyupHandler = /* @__PURE__ */ new WeakMap(), _KeybindingController_blurHandler = /* @__PURE__ */ new WeakMap(), _KeybindingController_instances = /* @__PURE__ */ new WeakSet(), _KeybindingController_setupListeners = function _KeybindingController_setupListeners2() {
12063
+ _KeybindingController_keydownHandler = /* @__PURE__ */ new WeakMap(), _KeybindingController_keyupHandler = /* @__PURE__ */ new WeakMap(), _KeybindingController_blurHandler = /* @__PURE__ */ new WeakMap(), _KeybindingController_isPushToTalkKeyPressed = /* @__PURE__ */ new WeakMap(), _KeybindingController_instances = /* @__PURE__ */ new WeakSet(), _KeybindingController_setupListeners = function _KeybindingController_setupListeners2() {
11477
12064
  __classPrivateFieldGet5(this, _KeybindingController_instances, "m", _KeybindingController_removeListeners).call(this);
11478
12065
  __classPrivateFieldSet4(this, _KeybindingController_keydownHandler, (event) => {
11479
- if (!this.host._keybinding) {
11480
- return;
11481
- }
11482
12066
  if (shouldIgnoreKeybinding(document.activeElement)) {
11483
12067
  return;
11484
12068
  }
11485
- if (matchesKeybinding(event, this.host._keybinding)) {
12069
+ if (this.host._toggleToTalkKeybinding && matchesKeybinding(event, this.host._toggleToTalkKeybinding) && !__classPrivateFieldGet5(this, _KeybindingController_isPushToTalkKeyPressed, "f")) {
11486
12070
  if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
11487
12071
  return;
11488
12072
  }
11489
- if (this.host._mode === "push-to-talk") {
11490
- this.host.startRecording();
11491
- }
11492
- if (this.host._mode === "toggle-to-talk") {
11493
- this.host.toggleRecording();
12073
+ this.host.toggleRecording();
12074
+ return;
12075
+ }
12076
+ if (this.host._pushToTalkKeybinding && matchesKeybinding(event, this.host._pushToTalkKeybinding)) {
12077
+ if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
12078
+ return;
11494
12079
  }
12080
+ __classPrivateFieldSet4(this, _KeybindingController_isPushToTalkKeyPressed, true, "f");
12081
+ this.host.startRecording();
11495
12082
  }
11496
12083
  }, "f");
11497
12084
  __classPrivateFieldSet4(this, _KeybindingController_keyupHandler, (event) => {
11498
- if (!this.host._keybinding) {
11499
- return;
11500
- }
11501
- if (this.host._mode === "push-to-talk" && matchesKeybinding(event, this.host._keybinding)) {
12085
+ if (this.host._pushToTalkKeybinding && matchesKeybinding(event, this.host._pushToTalkKeybinding)) {
11502
12086
  if (!this.host.dispatchEvent(keybindingActivatedEvent(event))) {
11503
12087
  return;
11504
12088
  }
12089
+ __classPrivateFieldSet4(this, _KeybindingController_isPushToTalkKeyPressed, false, "f");
11505
12090
  this.host.stopRecording();
11506
12091
  }
11507
12092
  }, "f");
11508
12093
  __classPrivateFieldSet4(this, _KeybindingController_blurHandler, () => {
11509
- if (this.host._mode === "push-to-talk") {
12094
+ if (__classPrivateFieldGet5(this, _KeybindingController_isPushToTalkKeyPressed, "f")) {
12095
+ __classPrivateFieldSet4(this, _KeybindingController_isPushToTalkKeyPressed, false, "f");
11510
12096
  this.host.stopRecording();
11511
12097
  }
11512
12098
  }, "f");
@@ -11586,6 +12172,7 @@ var _MediaController_visualiserInterval;
11586
12172
  var _MediaController_audioLevel;
11587
12173
  var _MediaController_onTrackEnded;
11588
12174
  var _MediaController_onAudioLevelChange;
12175
+ var _MediaController_dataHandler;
11589
12176
  var MediaController = class {
11590
12177
  constructor(host) {
11591
12178
  _MediaController_mediaStream.set(this, null);
@@ -11596,15 +12183,17 @@ var MediaController = class {
11596
12183
  _MediaController_audioLevel.set(this, 0);
11597
12184
  _MediaController_onTrackEnded.set(this, void 0);
11598
12185
  _MediaController_onAudioLevelChange.set(this, void 0);
12186
+ _MediaController_dataHandler.set(this, void 0);
11599
12187
  this.host = host;
11600
12188
  host.addController(this);
11601
12189
  }
11602
12190
  hostDisconnected() {
11603
12191
  this.cleanup();
11604
12192
  }
11605
- async initialize(onTrackEnded) {
12193
+ async initialize(onTrackEnded, dataHandler) {
11606
12194
  await this.cleanup();
11607
12195
  __classPrivateFieldSet5(this, _MediaController_onTrackEnded, onTrackEnded, "f");
12196
+ __classPrivateFieldSet5(this, _MediaController_dataHandler, dataHandler, "f");
11608
12197
  __classPrivateFieldSet5(this, _MediaController_mediaStream, await getMediaStream(this.host._selectedDevice?.deviceId, this.host._debug_displayAudio), "f");
11609
12198
  __classPrivateFieldGet6(this, _MediaController_mediaStream, "f").getTracks().forEach((track) => {
11610
12199
  track.addEventListener("ended", () => {
@@ -11617,6 +12206,11 @@ var MediaController = class {
11617
12206
  __classPrivateFieldSet5(this, _MediaController_audioContext, audioContext, "f");
11618
12207
  __classPrivateFieldSet5(this, _MediaController_analyser, analyser, "f");
11619
12208
  __classPrivateFieldSet5(this, _MediaController_mediaRecorder, new MediaRecorder(__classPrivateFieldGet6(this, _MediaController_mediaStream, "f")), "f");
12209
+ __classPrivateFieldGet6(this, _MediaController_mediaRecorder, "f").ondataavailable = (event) => {
12210
+ if (__classPrivateFieldGet6(this, _MediaController_dataHandler, "f")) {
12211
+ __classPrivateFieldGet6(this, _MediaController_dataHandler, "f").call(this, event.data);
12212
+ }
12213
+ };
11620
12214
  }
11621
12215
  getAudioLevel() {
11622
12216
  return __classPrivateFieldGet6(this, _MediaController_analyser, "f") ? calculateAudioLevel(__classPrivateFieldGet6(this, _MediaController_analyser, "f")) : 0;
@@ -11648,6 +12242,9 @@ var MediaController = class {
11648
12242
  if (__classPrivateFieldGet6(this, _MediaController_mediaRecorder, "f")?.state === "recording") {
11649
12243
  __classPrivateFieldGet6(this, _MediaController_mediaRecorder, "f").stop();
11650
12244
  }
12245
+ if (__classPrivateFieldGet6(this, _MediaController_mediaRecorder, "f")) {
12246
+ __classPrivateFieldGet6(this, _MediaController_mediaRecorder, "f").ondataavailable = null;
12247
+ }
11651
12248
  if (__classPrivateFieldGet6(this, _MediaController_mediaStream, "f")) {
11652
12249
  __classPrivateFieldGet6(this, _MediaController_mediaStream, "f").getTracks().forEach((track) => {
11653
12250
  track.stop();
@@ -11662,6 +12259,7 @@ var MediaController = class {
11662
12259
  __classPrivateFieldSet5(this, _MediaController_mediaRecorder, null, "f");
11663
12260
  __classPrivateFieldSet5(this, _MediaController_onTrackEnded, void 0, "f");
11664
12261
  __classPrivateFieldSet5(this, _MediaController_onAudioLevelChange, void 0, "f");
12262
+ __classPrivateFieldSet5(this, _MediaController_dataHandler, void 0, "f");
11665
12263
  }
11666
12264
  /**
11667
12265
  * Stops the media recorder and waits for all buffered data to be flushed.
@@ -11686,7 +12284,7 @@ var MediaController = class {
11686
12284
  return __classPrivateFieldGet6(this, _MediaController_audioLevel, "f");
11687
12285
  }
11688
12286
  };
11689
- _MediaController_mediaStream = /* @__PURE__ */ new WeakMap(), _MediaController_audioContext = /* @__PURE__ */ new WeakMap(), _MediaController_analyser = /* @__PURE__ */ new WeakMap(), _MediaController_mediaRecorder = /* @__PURE__ */ new WeakMap(), _MediaController_visualiserInterval = /* @__PURE__ */ new WeakMap(), _MediaController_audioLevel = /* @__PURE__ */ new WeakMap(), _MediaController_onTrackEnded = /* @__PURE__ */ new WeakMap(), _MediaController_onAudioLevelChange = /* @__PURE__ */ new WeakMap();
12287
+ _MediaController_mediaStream = /* @__PURE__ */ new WeakMap(), _MediaController_audioContext = /* @__PURE__ */ new WeakMap(), _MediaController_analyser = /* @__PURE__ */ new WeakMap(), _MediaController_mediaRecorder = /* @__PURE__ */ new WeakMap(), _MediaController_visualiserInterval = /* @__PURE__ */ new WeakMap(), _MediaController_audioLevel = /* @__PURE__ */ new WeakMap(), _MediaController_onTrackEnded = /* @__PURE__ */ new WeakMap(), _MediaController_onAudioLevelChange = /* @__PURE__ */ new WeakMap(), _MediaController_dataHandler = /* @__PURE__ */ new WeakMap();
11690
12288
 
11691
12289
  // dist/styles/buttons.js
11692
12290
  var ButtonStyles = i`
@@ -12026,12 +12624,13 @@ var _DictationRecordingButton_mediaController;
12026
12624
  var _DictationRecordingButton_dictationController;
12027
12625
  var _DictationRecordingButton_keybindingController;
12028
12626
  var _DictationRecordingButton_closeConnectionOnInit;
12029
- var _DictationRecordingButton_handleMouseDown;
12030
- var _DictationRecordingButton_handleMouseUp;
12031
- var _DictationRecordingButton_handleMouseLeave;
12627
+ var _DictationRecordingButton_processing;
12628
+ var _DictationRecordingButton_connection;
12629
+ var _DictationRecordingButton_handleClick;
12032
12630
  var _DictationRecordingButton_handleWebSocketMessage;
12033
12631
  var _DictationRecordingButton_handleWebSocketError;
12034
12632
  var _DictationRecordingButton_handleWebSocketClose;
12633
+ var _DictationRecordingButton_dispatchRecordingStateChanged;
12035
12634
  var _DictationRecordingButton_handleStart;
12036
12635
  var _DictationRecordingButton_handleStop;
12037
12636
  var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
@@ -12044,15 +12643,10 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12044
12643
  _DictationRecordingButton_dictationController.set(this, new DictationController(this));
12045
12644
  _DictationRecordingButton_keybindingController.set(this, new KeybindingController(this));
12046
12645
  _DictationRecordingButton_closeConnectionOnInit.set(this, false);
12646
+ _DictationRecordingButton_processing.set(this, false);
12647
+ _DictationRecordingButton_connection.set(this, "CLOSED");
12047
12648
  _DictationRecordingButton_handleWebSocketMessage.set(this, (message) => {
12048
12649
  switch (message.type) {
12049
- case "CONFIG_ACCEPTED":
12050
- __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
12051
- __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
12052
- this.dispatchEvent(audioLevelChangedEvent(level));
12053
- });
12054
- this.dispatchEvent(recordingStateChangedEvent("recording"));
12055
- break;
12056
12650
  case "CONFIG_DENIED":
12057
12651
  this.dispatchEvent(errorEvent(`Config denied: ${message.reason ?? "Unknown reason"}`));
12058
12652
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
@@ -12074,14 +12668,28 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12074
12668
  this.dispatchEvent(errorEvent(message.error));
12075
12669
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12076
12670
  break;
12671
+ case "flushed":
12672
+ if (this._recordingState === "stopped" || this._recordingState === "stopping") {
12673
+ __classPrivateFieldSet6(this, _DictationRecordingButton_processing, false, "f");
12674
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
12675
+ }
12676
+ break;
12077
12677
  }
12078
12678
  });
12079
12679
  _DictationRecordingButton_handleWebSocketError.set(this, (error) => {
12080
12680
  this.dispatchEvent(errorEvent("Socket error: " + error.message));
12681
+ __classPrivateFieldSet6(this, _DictationRecordingButton_processing, false, "f");
12682
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CLOSED", "f");
12081
12683
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12082
12684
  });
12083
12685
  _DictationRecordingButton_handleWebSocketClose.set(this, (event) => {
12686
+ if (__classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen() || __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").isConnecting()) {
12687
+ return;
12688
+ }
12689
+ __classPrivateFieldSet6(this, _DictationRecordingButton_processing, false, "f");
12690
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CLOSED", "f");
12084
12691
  this.dispatchEvent(streamClosedEvent(event));
12692
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
12085
12693
  });
12086
12694
  }
12087
12695
  update(changedProperties) {
@@ -12114,14 +12722,57 @@ var DictationRecordingButton = class DictationRecordingButton2 extends i4 {
12114
12722
  this.stopRecording();
12115
12723
  }
12116
12724
  }
12725
+ async openConnection() {
12726
+ if (this._recordingState !== "stopped" || __classPrivateFieldGet7(this, _DictationRecordingButton_processing, "f")) {
12727
+ return;
12728
+ }
12729
+ if (__classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen()) {
12730
+ return;
12731
+ }
12732
+ try {
12733
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CONNECTING", "f");
12734
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
12735
+ await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").connect(this._dictationConfig, {
12736
+ onClose: __classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketClose, "f"),
12737
+ onError: __classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketError, "f"),
12738
+ onMessage: __classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketMessage, "f"),
12739
+ onNetworkActivity: (direction, data) => {
12740
+ this.dispatchEvent(networkActivityEvent(direction, data));
12741
+ }
12742
+ });
12743
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "OPEN", "f");
12744
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
12745
+ } catch (error) {
12746
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CLOSED", "f");
12747
+ this.dispatchEvent(errorEvent(error));
12748
+ }
12749
+ }
12750
+ async closeConnection() {
12751
+ if (this._recordingState !== "stopped" || __classPrivateFieldGet7(this, _DictationRecordingButton_processing, "f")) {
12752
+ return;
12753
+ }
12754
+ if (__classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").isConnecting()) {
12755
+ await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").waitForConnection();
12756
+ }
12757
+ if (!__classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").isConnectionOpen()) {
12758
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CLOSED", "f");
12759
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
12760
+ return;
12761
+ }
12762
+ try {
12763
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CLOSING", "f");
12764
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
12765
+ await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").closeConnection(__classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketClose, "f"));
12766
+ } catch (error) {
12767
+ this.dispatchEvent(errorEvent(error));
12768
+ }
12769
+ }
12117
12770
  render() {
12118
12771
  const isLoading = this._recordingState === "initializing" || this._recordingState === "stopping";
12119
12772
  const isRecording = this._recordingState === "recording";
12120
12773
  return x`
12121
12774
  <button
12122
- @mousedown=${__classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleMouseDown)}
12123
- @mouseup=${__classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleMouseUp)}
12124
- @mouseleave=${__classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleMouseLeave)}
12775
+ @click=${__classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleClick)}
12125
12776
  ?disabled=${isLoading}
12126
12777
  class=${isRecording ? "red" : "accent"}
12127
12778
  aria-label=${isRecording ? "Stop recording" : "Start recording"}
@@ -12140,42 +12791,43 @@ _DictationRecordingButton_mediaController = /* @__PURE__ */ new WeakMap();
12140
12791
  _DictationRecordingButton_dictationController = /* @__PURE__ */ new WeakMap();
12141
12792
  _DictationRecordingButton_keybindingController = /* @__PURE__ */ new WeakMap();
12142
12793
  _DictationRecordingButton_closeConnectionOnInit = /* @__PURE__ */ new WeakMap();
12794
+ _DictationRecordingButton_processing = /* @__PURE__ */ new WeakMap();
12795
+ _DictationRecordingButton_connection = /* @__PURE__ */ new WeakMap();
12143
12796
  _DictationRecordingButton_handleWebSocketMessage = /* @__PURE__ */ new WeakMap();
12144
12797
  _DictationRecordingButton_handleWebSocketError = /* @__PURE__ */ new WeakMap();
12145
12798
  _DictationRecordingButton_handleWebSocketClose = /* @__PURE__ */ new WeakMap();
12146
12799
  _DictationRecordingButton_instances = /* @__PURE__ */ new WeakSet();
12147
- _DictationRecordingButton_handleMouseDown = function _DictationRecordingButton_handleMouseDown2(event) {
12800
+ _DictationRecordingButton_handleClick = function _DictationRecordingButton_handleClick2(event) {
12148
12801
  if (!this.allowButtonFocus) {
12149
12802
  event.preventDefault();
12150
12803
  }
12151
- if (this._mode === "push-to-talk") {
12152
- this.startRecording();
12153
- }
12154
- };
12155
- _DictationRecordingButton_handleMouseUp = function _DictationRecordingButton_handleMouseUp2() {
12156
- if (this._mode === "push-to-talk") {
12157
- this.stopRecording();
12158
- return;
12159
- }
12160
- if (this._mode === "toggle-to-talk") {
12161
- this.toggleRecording();
12162
- }
12804
+ this.toggleRecording();
12163
12805
  };
12164
- _DictationRecordingButton_handleMouseLeave = function _DictationRecordingButton_handleMouseLeave2() {
12165
- if (this._mode === "push-to-talk") {
12166
- this.stopRecording();
12167
- }
12806
+ _DictationRecordingButton_dispatchRecordingStateChanged = function _DictationRecordingButton_dispatchRecordingStateChanged2(state) {
12807
+ this.dispatchEvent(recordingStateChangedEvent(state, {
12808
+ connection: __classPrivateFieldGet7(this, _DictationRecordingButton_connection, "f"),
12809
+ processing: __classPrivateFieldGet7(this, _DictationRecordingButton_processing, "f")
12810
+ }));
12168
12811
  };
12169
12812
  _DictationRecordingButton_handleStart = async function _DictationRecordingButton_handleStart2() {
12170
- this.dispatchEvent(recordingStateChangedEvent("initializing"));
12813
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "initializing");
12171
12814
  try {
12172
12815
  await __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").initialize(() => {
12173
12816
  if (this._recordingState === "recording") {
12174
12817
  this.dispatchEvent(errorEvent("Recording device access was lost."));
12175
12818
  __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12176
12819
  }
12820
+ }, __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").mediaRecorderHandler);
12821
+ __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
12822
+ __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
12823
+ this.dispatchEvent(audioLevelChangedEvent(level));
12177
12824
  });
12178
- const isNewConnection = await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").connect(__classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").mediaRecorder, this._dictationConfig, {
12825
+ __classPrivateFieldSet6(this, _DictationRecordingButton_processing, true, "f");
12826
+ if (__classPrivateFieldGet7(this, _DictationRecordingButton_connection, "f") !== "OPEN") {
12827
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "CONNECTING", "f");
12828
+ }
12829
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "recording");
12830
+ const isNewConnection = await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").connect(this._dictationConfig, {
12179
12831
  onClose: __classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketClose, "f"),
12180
12832
  onError: __classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketError, "f"),
12181
12833
  onMessage: __classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketMessage, "f"),
@@ -12183,29 +12835,27 @@ _DictationRecordingButton_handleStart = async function _DictationRecordingButton
12183
12835
  this.dispatchEvent(networkActivityEvent(direction, data));
12184
12836
  }
12185
12837
  });
12186
- if (!isNewConnection) {
12187
- __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").mediaRecorder?.start(AUDIO_CHUNK_INTERVAL_MS);
12188
- __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").startAudioLevelMonitoring((level) => {
12189
- this.dispatchEvent(audioLevelChangedEvent(level));
12190
- });
12191
- this.dispatchEvent(recordingStateChangedEvent("recording"));
12838
+ if (isNewConnection === "superseded") {
12839
+ return;
12192
12840
  }
12841
+ __classPrivateFieldSet6(this, _DictationRecordingButton_connection, "OPEN", "f");
12842
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, this._recordingState);
12193
12843
  } catch (error) {
12194
12844
  this.dispatchEvent(errorEvent(error));
12195
12845
  await __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_handleStop).call(this);
12196
12846
  }
12197
12847
  };
12198
12848
  _DictationRecordingButton_handleStop = async function _DictationRecordingButton_handleStop2() {
12199
- this.dispatchEvent(recordingStateChangedEvent("stopping"));
12849
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopping");
12200
12850
  try {
12201
12851
  __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").stopAudioLevelMonitoring();
12202
12852
  await __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").stopRecording();
12203
- await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").disconnect(__classPrivateFieldGet7(this, _DictationRecordingButton_handleWebSocketClose, "f"));
12853
+ __classPrivateFieldGet7(this, _DictationRecordingButton_instances, "m", _DictationRecordingButton_dispatchRecordingStateChanged).call(this, "stopped");
12854
+ await __classPrivateFieldGet7(this, _DictationRecordingButton_dictationController, "f").pause();
12204
12855
  await __classPrivateFieldGet7(this, _DictationRecordingButton_mediaController, "f").cleanup();
12205
12856
  } catch (error) {
12206
12857
  this.dispatchEvent(errorEvent(error));
12207
12858
  }
12208
- this.dispatchEvent(recordingStateChangedEvent("stopped"));
12209
12859
  };
12210
12860
  DictationRecordingButton.styles = [recording_button_default, buttons_default];
12211
12861
  __decorate4([
@@ -12249,13 +12899,13 @@ __decorate4([
12249
12899
  r5()
12250
12900
  ], DictationRecordingButton.prototype, "_debug_displayAudio", void 0);
12251
12901
  __decorate4([
12252
- c5({ context: keybindingContext, subscribe: true }),
12902
+ c5({ context: pushToTalkKeybindingContext, subscribe: true }),
12253
12903
  r5()
12254
- ], DictationRecordingButton.prototype, "_keybinding", void 0);
12904
+ ], DictationRecordingButton.prototype, "_pushToTalkKeybinding", void 0);
12255
12905
  __decorate4([
12256
- c5({ context: modeContext, subscribe: true }),
12906
+ c5({ context: toggleToTalkKeybindingContext, subscribe: true }),
12257
12907
  r5()
12258
- ], DictationRecordingButton.prototype, "_mode", void 0);
12908
+ ], DictationRecordingButton.prototype, "_toggleToTalkKeybinding", void 0);
12259
12909
  __decorate4([
12260
12910
  n4({ type: Boolean })
12261
12911
  ], DictationRecordingButton.prototype, "allowButtonFocus", void 0);
@@ -12317,14 +12967,6 @@ var SettingsMenuStyles = i`
12317
12967
  flex-direction: column;
12318
12968
  gap: 16px;
12319
12969
  }
12320
- .settings-group {
12321
- background: var(--muted-background, light-dark(#fafafa, #2a2a2a));
12322
- padding: 12px;
12323
- border-radius: 10px;
12324
- display: flex;
12325
- flex-direction: column;
12326
- gap: 16px;
12327
- }
12328
12970
  `;
12329
12971
  var settings_menu_default = SettingsMenuStyles;
12330
12972
 
@@ -12455,7 +13097,6 @@ var KeybindingSelectorStyles = [
12455
13097
  min-width: 0;
12456
13098
  border: none;
12457
13099
  background: transparent;
12458
- font-size: 14px;
12459
13100
  line-height: 24px;
12460
13101
  color: var(--component-text-color, light-dark(#333, #eee));
12461
13102
  outline: none;
@@ -12480,8 +13121,8 @@ var KeybindingSelectorStyles = [
12480
13121
  border: 1px solid var(--card-border-color, light-dark(#ddd, #555));
12481
13122
  border-radius: var(--card-inner-border-radius, 6px);
12482
13123
  box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));
12483
- font-size: 16px;
12484
- line-height: 28px;
13124
+ font-size: 14px;
13125
+ line-height: 24px;
12485
13126
  color: var(--component-text-color, light-dark(#333, #eee));
12486
13127
  opacity: 0.6;
12487
13128
  text-align: center;
@@ -12494,13 +13135,20 @@ var KeybindingSelectorStyles = [
12494
13135
  opacity: 0.6;
12495
13136
  margin: 0;
12496
13137
  letter-spacing: 0.01px;
12497
- padding-top: 8px;
13138
+ }
13139
+ .settings-group {
13140
+ background: var(--card-background, light-dark(#fafafa, #2a2a2a));
13141
+ padding: 12px;
13142
+ border-radius: 10px;
13143
+ display: flex;
13144
+ flex-direction: column;
13145
+ gap: 8px;
12498
13146
  }
12499
13147
  `
12500
13148
  ];
12501
13149
  var keybinding_selector_default = KeybindingSelectorStyles;
12502
13150
 
12503
- // dist/components/keybinding-selector.js
13151
+ // dist/components/keybinding-input.js
12504
13152
  var __decorate6 = function(decorators, target, key, desc) {
12505
13153
  var c6 = arguments.length, r7 = c6 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
12506
13154
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r7 = Reflect.decorate(decorators, target, key, desc);
@@ -12512,74 +13160,128 @@ var __classPrivateFieldGet9 = function(receiver, state, kind, f5) {
12512
13160
  if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12513
13161
  return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
12514
13162
  };
12515
- var _DictationKeybindingSelector_instances;
12516
- var _DictationKeybindingSelector_handleKeybindingInputFocus;
12517
- var _DictationKeybindingSelector_handleKeybindingInputBlur;
12518
- var _DictationKeybindingSelector_handleKeybindingKeyDown;
12519
- var DictationKeybindingSelector = class DictationKeybindingSelector2 extends i4 {
13163
+ var _DictationKeybindingInput_instances;
13164
+ var _DictationKeybindingInput_handleKeybindingInputFocus;
13165
+ var _DictationKeybindingInput_handleKeybindingInputBlur;
13166
+ var _DictationKeybindingInput_handleKeybindingKeyDown;
13167
+ var DictationKeybindingInput = class DictationKeybindingInput2 extends i4 {
12520
13168
  constructor() {
12521
13169
  super(...arguments);
12522
- _DictationKeybindingSelector_instances.add(this);
13170
+ _DictationKeybindingInput_instances.add(this);
13171
+ this.keybindingType = "toggle-to-talk";
12523
13172
  this.disabled = false;
12524
13173
  this._isCapturingKeybinding = false;
12525
13174
  }
12526
13175
  render() {
13176
+ const keybinding = this.keybindingType === "push-to-talk" ? this._pushToTalkKeybinding : this._toggleToTalkKeybinding;
13177
+ const label = this.keybindingType === "push-to-talk" ? "Push-to-Talk keybinding" : "Toggle-to-Talk keybinding";
12527
13178
  return x`
12528
13179
  <div>
12529
- <label>Keybinding</label>
13180
+ <label>${label}</label>
12530
13181
  <div class="keybinding-selector-wrapper">
12531
- <div class="keybinding-key">${this._keybinding}</div>
13182
+ ${keybinding && x`<div class="keybinding-key">${keybinding}</div>`}
12532
13183
  <input
12533
13184
  type="text"
12534
13185
  class="keybinding-selector-input"
12535
13186
  .value=""
12536
13187
  placeholder="Click and press a key..."
12537
13188
  readonly
12538
- @focusin=${__classPrivateFieldGet9(this, _DictationKeybindingSelector_instances, "m", _DictationKeybindingSelector_handleKeybindingInputFocus)}
12539
- @focusout=${__classPrivateFieldGet9(this, _DictationKeybindingSelector_instances, "m", _DictationKeybindingSelector_handleKeybindingInputBlur)}
12540
- @keydown=${__classPrivateFieldGet9(this, _DictationKeybindingSelector_instances, "m", _DictationKeybindingSelector_handleKeybindingKeyDown)}
13189
+ @focusin=${__classPrivateFieldGet9(this, _DictationKeybindingInput_instances, "m", _DictationKeybindingInput_handleKeybindingInputFocus)}
13190
+ @focusout=${__classPrivateFieldGet9(this, _DictationKeybindingInput_instances, "m", _DictationKeybindingInput_handleKeybindingInputBlur)}
13191
+ @keydown=${__classPrivateFieldGet9(this, _DictationKeybindingInput_instances, "m", _DictationKeybindingInput_handleKeybindingKeyDown)}
12541
13192
  ?disabled=${this.disabled}
12542
13193
  />
12543
13194
  </div>
12544
- <p class="keybinding-help">
12545
- Press ${this._keybinding} to start/stop recording
12546
- </p>
12547
13195
  </div>
12548
13196
  `;
12549
13197
  }
12550
13198
  };
12551
- _DictationKeybindingSelector_instances = /* @__PURE__ */ new WeakSet();
12552
- _DictationKeybindingSelector_handleKeybindingInputFocus = function _DictationKeybindingSelector_handleKeybindingInputFocus2() {
13199
+ _DictationKeybindingInput_instances = /* @__PURE__ */ new WeakSet();
13200
+ _DictationKeybindingInput_handleKeybindingInputFocus = function _DictationKeybindingInput_handleKeybindingInputFocus2() {
12553
13201
  this._isCapturingKeybinding = true;
12554
13202
  };
12555
- _DictationKeybindingSelector_handleKeybindingInputBlur = function _DictationKeybindingSelector_handleKeybindingInputBlur2() {
13203
+ _DictationKeybindingInput_handleKeybindingInputBlur = function _DictationKeybindingInput_handleKeybindingInputBlur2() {
12556
13204
  this._isCapturingKeybinding = false;
12557
13205
  };
12558
- _DictationKeybindingSelector_handleKeybindingKeyDown = function _DictationKeybindingSelector_handleKeybindingKeyDown2(event) {
13206
+ _DictationKeybindingInput_handleKeybindingKeyDown = function _DictationKeybindingInput_handleKeybindingKeyDown2(event) {
12559
13207
  if (!this._isCapturingKeybinding) {
12560
13208
  return;
12561
13209
  }
12562
13210
  event.preventDefault();
12563
13211
  event.stopPropagation();
12564
- this.dispatchEvent(keybindingChangedEvent(event.key, event.code));
13212
+ const keybinding = normalizeKeybinding(event.key);
13213
+ this.dispatchEvent(keybindingChangedEvent(event.key, event.code, keybinding, this.keybindingType));
12565
13214
  };
12566
- DictationKeybindingSelector.styles = keybinding_selector_default;
13215
+ DictationKeybindingInput.styles = keybinding_selector_default;
12567
13216
  __decorate6([
12568
- c5({ context: keybindingContext, subscribe: true }),
13217
+ n4({ type: String })
13218
+ ], DictationKeybindingInput.prototype, "keybindingType", void 0);
13219
+ __decorate6([
13220
+ c5({ context: pushToTalkKeybindingContext, subscribe: true }),
13221
+ r5()
13222
+ ], DictationKeybindingInput.prototype, "_pushToTalkKeybinding", void 0);
13223
+ __decorate6([
13224
+ c5({ context: toggleToTalkKeybindingContext, subscribe: true }),
12569
13225
  r5()
12570
- ], DictationKeybindingSelector.prototype, "_keybinding", void 0);
13226
+ ], DictationKeybindingInput.prototype, "_toggleToTalkKeybinding", void 0);
12571
13227
  __decorate6([
12572
13228
  n4({ type: Boolean })
12573
- ], DictationKeybindingSelector.prototype, "disabled", void 0);
13229
+ ], DictationKeybindingInput.prototype, "disabled", void 0);
12574
13230
  __decorate6([
12575
13231
  r5()
12576
- ], DictationKeybindingSelector.prototype, "_isCapturingKeybinding", void 0);
12577
- DictationKeybindingSelector = __decorate6([
13232
+ ], DictationKeybindingInput.prototype, "_isCapturingKeybinding", void 0);
13233
+ DictationKeybindingInput = __decorate6([
13234
+ t3("dictation-keybinding-input")
13235
+ ], DictationKeybindingInput);
13236
+
13237
+ // dist/components/keybinding-selector.js
13238
+ var __decorate7 = function(decorators, target, key, desc) {
13239
+ var c6 = arguments.length, r7 = c6 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
13240
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r7 = Reflect.decorate(decorators, target, key, desc);
13241
+ else for (var i7 = decorators.length - 1; i7 >= 0; i7--) if (d3 = decorators[i7]) r7 = (c6 < 3 ? d3(r7) : c6 > 3 ? d3(target, key, r7) : d3(target, key)) || r7;
13242
+ return c6 > 3 && r7 && Object.defineProperty(target, key, r7), r7;
13243
+ };
13244
+ var DictationKeybindingSelector = class DictationKeybindingSelector2 extends i4 {
13245
+ constructor() {
13246
+ super(...arguments);
13247
+ this.disabled = false;
13248
+ }
13249
+ render() {
13250
+ return x`
13251
+ <div class="settings-group">
13252
+ <dictation-keybinding-input
13253
+ keybindingType="toggle-to-talk"
13254
+ ?disabled=${this.disabled}
13255
+ ></dictation-keybinding-input>
13256
+ <dictation-keybinding-input
13257
+ keybindingType="push-to-talk"
13258
+ ?disabled=${this.disabled}
13259
+ ></dictation-keybinding-input>
13260
+ ${(this._toggleToTalkKeybinding || this._pushToTalkKeybinding) && x`<p class="keybinding-help">
13261
+ ${x`Press ${[this._toggleToTalkKeybinding, this._pushToTalkKeybinding].join(" or ")} to start/stop recording`}
13262
+ </p>`}
13263
+ </div>
13264
+ `;
13265
+ }
13266
+ };
13267
+ DictationKeybindingSelector.styles = keybinding_selector_default;
13268
+ __decorate7([
13269
+ c5({ context: pushToTalkKeybindingContext, subscribe: true }),
13270
+ r5()
13271
+ ], DictationKeybindingSelector.prototype, "_pushToTalkKeybinding", void 0);
13272
+ __decorate7([
13273
+ c5({ context: toggleToTalkKeybindingContext, subscribe: true }),
13274
+ r5()
13275
+ ], DictationKeybindingSelector.prototype, "_toggleToTalkKeybinding", void 0);
13276
+ __decorate7([
13277
+ n4({ type: Boolean })
13278
+ ], DictationKeybindingSelector.prototype, "disabled", void 0);
13279
+ DictationKeybindingSelector = __decorate7([
12578
13280
  t3("dictation-keybinding-selector")
12579
13281
  ], DictationKeybindingSelector);
12580
13282
 
12581
13283
  // dist/components/language-selector.js
12582
- var __decorate7 = function(decorators, target, key, desc) {
13284
+ var __decorate8 = function(decorators, target, key, desc) {
12583
13285
  var c6 = arguments.length, r7 = c6 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
12584
13286
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r7 = Reflect.decorate(decorators, target, key, desc);
12585
13287
  else for (var i7 = decorators.length - 1; i7 >= 0; i7--) if (d3 = decorators[i7]) r7 = (c6 < 3 ? d3(r7) : c6 > 3 ? d3(target, key, r7) : d3(target, key)) || r7;
@@ -12630,143 +13332,21 @@ _DictationLanguageSelector_handleSelectLanguage = function _DictationLanguageSel
12630
13332
  this.dispatchEvent(languageChangedEvent(language));
12631
13333
  };
12632
13334
  DictationLanguageSelector.styles = select_default;
12633
- __decorate7([
13335
+ __decorate8([
12634
13336
  c5({ context: languagesContext, subscribe: true }),
12635
13337
  r5()
12636
13338
  ], DictationLanguageSelector.prototype, "_languages", void 0);
12637
- __decorate7([
13339
+ __decorate8([
12638
13340
  c5({ context: dictationConfigContext, subscribe: true }),
12639
13341
  r5()
12640
13342
  ], DictationLanguageSelector.prototype, "_dictationConfig", void 0);
12641
- __decorate7([
13343
+ __decorate8([
12642
13344
  n4({ type: Boolean })
12643
13345
  ], DictationLanguageSelector.prototype, "disabled", void 0);
12644
- DictationLanguageSelector = __decorate7([
13346
+ DictationLanguageSelector = __decorate8([
12645
13347
  t3("dictation-language-selector")
12646
13348
  ], DictationLanguageSelector);
12647
13349
 
12648
- // dist/styles/mode-selector.js
12649
- var ModeSelectorStyles = [
12650
- LabelStyles,
12651
- i`
12652
- :host {
12653
- display: block;
12654
- }
12655
- .mode-selector-tabs {
12656
- display: flex;
12657
- background: var(--muted-background, light-dark(#fafafa, #2a2a2a));
12658
- border: 1px solid var(--card-border-color, light-dark(#ddd, #555));
12659
- border-radius: var(--card-inner-border-radius, 6px);
12660
- padding: 0;
12661
- overflow: hidden;
12662
- align-items: center;
12663
- justify-content: center;
12664
- text-wrap: nowrap;
12665
- gap: 2px;
12666
- }
12667
- .mode-selector-tab {
12668
- flex: 1;
12669
- padding: 4px 8px;
12670
- border: 1px solid transparent;
12671
- background: transparent;
12672
- font-size: 14px;
12673
- font-weight: 500;
12674
- line-height: 24px;
12675
- color: var(--component-text-color, light-dark(#333, #eee));
12676
- opacity: 0.6;
12677
- cursor: pointer;
12678
- transition: all 0.2s;
12679
- height: 32px;
12680
- display: flex;
12681
- align-items: center;
12682
- justify-content: center;
12683
- border-radius: var(--card-inner-border-radius, 6px);
12684
- margin: -1px;
12685
- }
12686
- .mode-selector-tab:hover:not(:disabled) {
12687
- opacity: 1;
12688
- }
12689
- .mode-selector-tab.active {
12690
- background: var(--card-background, light-dark(#fff, #333));
12691
- border-color: var(--card-border-color, light-dark(#ddd, #555));
12692
- box-shadow: var(--card-box-shadow, 0 2px 5px rgba(0, 0, 0, 0.1));
12693
- opacity: 1;
12694
- }
12695
- .mode-selector-tab:disabled {
12696
- opacity: 0.5;
12697
- cursor: not-allowed;
12698
- }
12699
- `
12700
- ];
12701
- var mode_selector_default = ModeSelectorStyles;
12702
-
12703
- // dist/components/mode-selector.js
12704
- var __decorate8 = function(decorators, target, key, desc) {
12705
- var c6 = arguments.length, r7 = c6 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
12706
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r7 = Reflect.decorate(decorators, target, key, desc);
12707
- else for (var i7 = decorators.length - 1; i7 >= 0; i7--) if (d3 = decorators[i7]) r7 = (c6 < 3 ? d3(r7) : c6 > 3 ? d3(target, key, r7) : d3(target, key)) || r7;
12708
- return c6 > 3 && r7 && Object.defineProperty(target, key, r7), r7;
12709
- };
12710
- var __classPrivateFieldGet11 = function(receiver, state, kind, f5) {
12711
- if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a getter");
12712
- if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12713
- return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
12714
- };
12715
- var _DictationModeSelector_instances;
12716
- var _DictationModeSelector_handleModeChange;
12717
- var DictationModeSelector = class DictationModeSelector2 extends i4 {
12718
- constructor() {
12719
- super(...arguments);
12720
- _DictationModeSelector_instances.add(this);
12721
- this._mode = "toggle-to-talk";
12722
- this.disabled = false;
12723
- }
12724
- render() {
12725
- return x`
12726
- <div>
12727
- <label>Dictation Mode</label>
12728
- <div class="mode-selector-tabs">
12729
- <button
12730
- class=${e6({
12731
- active: this._mode === "toggle-to-talk",
12732
- "mode-selector-tab": true
12733
- })}
12734
- @click=${() => __classPrivateFieldGet11(this, _DictationModeSelector_instances, "m", _DictationModeSelector_handleModeChange).call(this, "toggle-to-talk")}
12735
- ?disabled=${this.disabled}
12736
- >
12737
- Toggle-to-Talk
12738
- </button>
12739
- <button
12740
- class=${e6({
12741
- active: this._mode === "push-to-talk",
12742
- "mode-selector-tab": true
12743
- })}
12744
- @click=${() => __classPrivateFieldGet11(this, _DictationModeSelector_instances, "m", _DictationModeSelector_handleModeChange).call(this, "push-to-talk")}
12745
- ?disabled=${this.disabled}
12746
- >
12747
- Push-to-Talk
12748
- </button>
12749
- </div>
12750
- </div>
12751
- `;
12752
- }
12753
- };
12754
- _DictationModeSelector_instances = /* @__PURE__ */ new WeakSet();
12755
- _DictationModeSelector_handleModeChange = function _DictationModeSelector_handleModeChange2(mode) {
12756
- this.dispatchEvent(modeChangedEvent(mode));
12757
- };
12758
- DictationModeSelector.styles = mode_selector_default;
12759
- __decorate8([
12760
- c5({ context: modeContext, subscribe: true }),
12761
- r5()
12762
- ], DictationModeSelector.prototype, "_mode", void 0);
12763
- __decorate8([
12764
- n4({ type: Boolean })
12765
- ], DictationModeSelector.prototype, "disabled", void 0);
12766
- DictationModeSelector = __decorate8([
12767
- t3("dictation-mode-selector")
12768
- ], DictationModeSelector);
12769
-
12770
13350
  // dist/components/settings-menu.js
12771
13351
  var __decorate9 = function(decorators, target, key, desc) {
12772
13352
  var c6 = arguments.length, r7 = c6 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
@@ -12787,7 +13367,6 @@ var DictationSettingsMenu = class DictationSettingsMenu2 extends i4 {
12787
13367
  const isRecording = this._recordingState === "recording";
12788
13368
  const showDeviceSelector = this.settingsEnabled.includes("device");
12789
13369
  const showLanguageSelector = this.settingsEnabled.includes("language");
12790
- const showModeSelector = this.settingsEnabled.includes("mode");
12791
13370
  const showKeybinding = this.settingsEnabled.includes("keybinding");
12792
13371
  return x`
12793
13372
  <div class="mic-selector">
@@ -12807,16 +13386,9 @@ var DictationSettingsMenu = class DictationSettingsMenu2 extends i4 {
12807
13386
  ${showLanguageSelector ? x`<dictation-language-selector
12808
13387
  ?disabled=${isRecording}
12809
13388
  />` : E}
12810
- ${showModeSelector || showKeybinding ? x`
12811
- <div class="settings-group">
12812
- ${showModeSelector ? x`<dictation-mode-selector
12813
- ?disabled=${isRecording}
12814
- />` : E}
12815
- ${showKeybinding ? x`<dictation-keybinding-selector
12816
- ?disabled=${isRecording}
12817
- />` : E}
12818
- </div>
12819
- ` : E}
13389
+ ${showKeybinding ? x`<dictation-keybinding-selector
13390
+ ?disabled=${isRecording}
13391
+ />` : E}
12820
13392
  </div>
12821
13393
  </div>
12822
13394
  </div>
@@ -12849,7 +13421,7 @@ var __decorate10 = function(decorators, target, key, desc) {
12849
13421
  else for (var i7 = decorators.length - 1; i7 >= 0; i7--) if (d3 = decorators[i7]) r7 = (c6 < 3 ? d3(r7) : c6 > 3 ? d3(target, key, r7) : d3(target, key)) || r7;
12850
13422
  return c6 > 3 && r7 && Object.defineProperty(target, key, r7), r7;
12851
13423
  };
12852
- var __classPrivateFieldGet12 = function(receiver, state, kind, f5) {
13424
+ var __classPrivateFieldGet11 = function(receiver, state, kind, f5) {
12853
13425
  if (kind === "a" && !f5) throw new TypeError("Private accessor was defined without a getter");
12854
13426
  if (typeof state === "function" ? receiver !== state || !f5 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
12855
13427
  return kind === "m" ? f5 : kind === "a" ? f5.call(receiver) : f5 ? f5.value : state.get(receiver);
@@ -12865,7 +13437,6 @@ var CortiDictation = class CortiDictation2 extends i4 {
12865
13437
  this.allowButtonFocus = false;
12866
13438
  this.debug_displayAudio = false;
12867
13439
  this._dictationConfig = DEFAULT_DICTATION_CONFIG;
12868
- this._mode = "toggle-to-talk";
12869
13440
  }
12870
13441
  /**
12871
13442
  * List of all language codes available for use with the Web Component.
@@ -12875,7 +13446,7 @@ var CortiDictation = class CortiDictation2 extends i4 {
12875
13446
  this._languagesSupported = value;
12876
13447
  }
12877
13448
  get languagesSupported() {
12878
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.languages || this._languagesSupported || [];
13449
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.languages || this._languagesSupported || [];
12879
13450
  }
12880
13451
  /**
12881
13452
  * Configuration settings for dictation
@@ -12884,7 +13455,7 @@ var CortiDictation = class CortiDictation2 extends i4 {
12884
13455
  this._dictationConfig = value;
12885
13456
  }
12886
13457
  get dictationConfig() {
12887
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.dictationConfig || this._dictationConfig;
13458
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.dictationConfig || this._dictationConfig;
12888
13459
  }
12889
13460
  /**
12890
13461
  * List of available recording devices
@@ -12893,7 +13464,7 @@ var CortiDictation = class CortiDictation2 extends i4 {
12893
13464
  this._devices = value;
12894
13465
  }
12895
13466
  get devices() {
12896
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.devices || this._devices || [];
13467
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.devices || this._devices || [];
12897
13468
  }
12898
13469
  /**
12899
13470
  * The selected device used for recording (MediaDeviceInfo).
@@ -12902,33 +13473,37 @@ var CortiDictation = class CortiDictation2 extends i4 {
12902
13473
  this._selectedDevice = value;
12903
13474
  }
12904
13475
  get selectedDevice() {
12905
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.selectedDevice || this._selectedDevice;
13476
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.selectedDevice || this._selectedDevice;
12906
13477
  }
12907
13478
  /**
12908
13479
  * Current state of recording (stopped, recording, initializing and stopping, ).
12909
13480
  */
12910
13481
  get recordingState() {
12911
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.recordingState || "stopped";
13482
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.recordingState || "stopped";
12912
13483
  }
12913
13484
  /**
12914
- * Dictation mode: "toggle-to-talk" or "push-to-talk"
13485
+ * Push-to-talk keybinding for keyboard shortcut. Single key only (e.g., "Space", "k", "meta", "ctrl").
13486
+ * Combinations with "+" are not supported.
13487
+ * Keydown starts recording, keyup stops recording.
13488
+ * Defaults to "Space" if keybinding is in settingsEnabled, otherwise undefined
12915
13489
  */
12916
- set mode(value) {
12917
- this._mode = value;
13490
+ set pushToTalkKeybinding(value) {
13491
+ this._pushToTalkKeybinding = value;
12918
13492
  }
12919
- get mode() {
12920
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.mode || this._mode || "toggle-to-talk";
13493
+ get pushToTalkKeybinding() {
13494
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.pushToTalkKeybinding || this._pushToTalkKeybinding;
12921
13495
  }
12922
13496
  /**
12923
- * Keybinding for keyboard shortcut. Single key only (e.g., "`", "k", "meta", "ctrl").
13497
+ * Toggle-to-talk keybinding for keyboard shortcut. Single key only (e.g., "`", "k", "meta", "ctrl").
12924
13498
  * Combinations with "+" are not supported.
13499
+ * Pressing the key toggles recording on/off.
12925
13500
  * Defaults to "`" if keybinding is in settingsEnabled, otherwise undefined
12926
13501
  */
12927
- set keybinding(value) {
12928
- this._keybinding = value;
13502
+ set toggleToTalkKeybinding(value) {
13503
+ this._toggleToTalkKeybinding = value;
12929
13504
  }
12930
- get keybinding() {
12931
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.keybinding || this._keybinding;
13505
+ get toggleToTalkKeybinding() {
13506
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.toggleToTalkKeybinding || this._toggleToTalkKeybinding;
12932
13507
  }
12933
13508
  // ─────────────────────────────────────────────────────────────────────────────
12934
13509
  // Public methods
@@ -12940,7 +13515,7 @@ var CortiDictation = class CortiDictation2 extends i4 {
12940
13515
  */
12941
13516
  setAccessToken(token) {
12942
13517
  this.accessToken = token;
12943
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.setAccessToken(token) ?? {
13518
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.setAccessToken(token) ?? {
12944
13519
  accessToken: token,
12945
13520
  environment: void 0,
12946
13521
  tenant: void 0
@@ -12953,7 +13528,7 @@ var CortiDictation = class CortiDictation2 extends i4 {
12953
13528
  */
12954
13529
  async setAuthConfig(config) {
12955
13530
  this.authConfig = config;
12956
- return __classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f").value?.setAuthConfig(config) ?? {
13531
+ return __classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f").value?.setAuthConfig(config) ?? {
12957
13532
  accessToken: void 0,
12958
13533
  environment: void 0,
12959
13534
  tenant: void 0
@@ -12963,19 +13538,33 @@ var CortiDictation = class CortiDictation2 extends i4 {
12963
13538
  * Starts a recording.
12964
13539
  */
12965
13540
  startRecording() {
12966
- __classPrivateFieldGet12(this, _CortiDictation_recordingButtonRef, "f").value?.startRecording();
13541
+ __classPrivateFieldGet11(this, _CortiDictation_recordingButtonRef, "f").value?.startRecording();
12967
13542
  }
12968
13543
  /**
12969
13544
  * Stops a recording.
12970
13545
  */
12971
13546
  stopRecording() {
12972
- __classPrivateFieldGet12(this, _CortiDictation_recordingButtonRef, "f").value?.stopRecording();
13547
+ __classPrivateFieldGet11(this, _CortiDictation_recordingButtonRef, "f").value?.stopRecording();
12973
13548
  }
12974
13549
  /**
12975
13550
  * Starts or stops recording. Convenience layer on top of the start/stop methods.
12976
13551
  */
12977
13552
  toggleRecording() {
12978
- __classPrivateFieldGet12(this, _CortiDictation_recordingButtonRef, "f").value?.toggleRecording();
13553
+ __classPrivateFieldGet11(this, _CortiDictation_recordingButtonRef, "f").value?.toggleRecording();
13554
+ }
13555
+ /**
13556
+ * Opens the WebSocket connection without starting recording.
13557
+ * Use this to pre-establish the connection before recording starts.
13558
+ */
13559
+ async openConnection() {
13560
+ await __classPrivateFieldGet11(this, _CortiDictation_recordingButtonRef, "f").value?.openConnection();
13561
+ }
13562
+ /**
13563
+ * Closes the WebSocket connection by sending "end" and waiting for "ended".
13564
+ * Call this to receive "usage" statistics or when done with the connection.
13565
+ */
13566
+ async closeConnection() {
13567
+ await __classPrivateFieldGet11(this, _CortiDictation_recordingButtonRef, "f").value?.closeConnection();
12979
13568
  }
12980
13569
  // ─────────────────────────────────────────────────────────────────────────────
12981
13570
  // Render
@@ -12984,7 +13573,7 @@ var CortiDictation = class CortiDictation2 extends i4 {
12984
13573
  const isHidden = !this.accessToken && !this.authConfig && !this.socketUrl && !this.socketProxy;
12985
13574
  return x`
12986
13575
  <dictation-root
12987
- ${n6(__classPrivateFieldGet12(this, _CortiDictation_contextProviderRef, "f"))}
13576
+ ${n6(__classPrivateFieldGet11(this, _CortiDictation_contextProviderRef, "f"))}
12988
13577
  class=${e6({ hidden: isHidden })}
12989
13578
  .accessToken=${this.accessToken}
12990
13579
  .authConfig=${this.authConfig}
@@ -12995,11 +13584,11 @@ var CortiDictation = class CortiDictation2 extends i4 {
12995
13584
  .devices=${this._devices}
12996
13585
  .selectedDevice=${this._selectedDevice}
12997
13586
  .debug_displayAudio=${this.debug_displayAudio}
12998
- .mode=${this._mode}
12999
- .keybinding=${this._keybinding}
13587
+ .pushToTalkKeybinding=${this._pushToTalkKeybinding}
13588
+ .toggleToTalkKeybinding=${this._toggleToTalkKeybinding}
13000
13589
  >
13001
13590
  <dictation-recording-button
13002
- ${n6(__classPrivateFieldGet12(this, _CortiDictation_recordingButtonRef, "f"))}
13591
+ ${n6(__classPrivateFieldGet11(this, _CortiDictation_recordingButtonRef, "f"))}
13003
13592
  ?allowButtonFocus=${this.allowButtonFocus}
13004
13593
  ></dictation-recording-button>
13005
13594
  ${this.settingsEnabled?.length > 0 ? x`<dictation-settings-menu
@@ -13069,16 +13658,16 @@ __decorate10([
13069
13658
  ], CortiDictation.prototype, "_selectedDevice", void 0);
13070
13659
  __decorate10([
13071
13660
  n4({ type: String })
13072
- ], CortiDictation.prototype, "mode", null);
13661
+ ], CortiDictation.prototype, "pushToTalkKeybinding", null);
13073
13662
  __decorate10([
13074
13663
  r5()
13075
- ], CortiDictation.prototype, "_mode", void 0);
13664
+ ], CortiDictation.prototype, "_pushToTalkKeybinding", void 0);
13076
13665
  __decorate10([
13077
13666
  n4({ type: String })
13078
- ], CortiDictation.prototype, "keybinding", null);
13667
+ ], CortiDictation.prototype, "toggleToTalkKeybinding", null);
13079
13668
  __decorate10([
13080
13669
  r5()
13081
- ], CortiDictation.prototype, "_keybinding", void 0);
13670
+ ], CortiDictation.prototype, "_toggleToTalkKeybinding", void 0);
13082
13671
  CortiDictation = __decorate10([
13083
13672
  t3("corti-dictation")
13084
13673
  ], CortiDictation);
@@ -13096,9 +13685,6 @@ if (!customElements.get("dictation-device-selector")) {
13096
13685
  if (!customElements.get("dictation-language-selector")) {
13097
13686
  customElements.define("dictation-language-selector", DictationLanguageSelector);
13098
13687
  }
13099
- if (!customElements.get("dictation-mode-selector")) {
13100
- customElements.define("dictation-mode-selector", DictationModeSelector);
13101
- }
13102
13688
  if (!customElements.get("dictation-keybinding-selector")) {
13103
13689
  customElements.define("dictation-keybinding-selector", DictationKeybindingSelector);
13104
13690
  }
@@ -13114,7 +13700,6 @@ export {
13114
13700
  DictationDeviceSelector,
13115
13701
  DictationKeybindingSelector,
13116
13702
  DictationLanguageSelector,
13117
- DictationModeSelector,
13118
13703
  DictationRecordingButton,
13119
13704
  DictationRoot,
13120
13705
  DictationSettingsMenu,