@deepgram/sdk 3.0.0-beta.2 → 3.0.0-beta.4
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.
- package/dist/main/lib/helpers.d.ts +1 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +3 -1
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/packages/LiveClient.d.ts.map +1 -1
- package/dist/main/packages/LiveClient.js +6 -10
- package/dist/main/packages/LiveClient.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +1 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +1 -0
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/packages/LiveClient.d.ts.map +1 -1
- package/dist/module/packages/LiveClient.js +6 -10
- package/dist/module/packages/LiveClient.js.map +1 -1
- package/dist/umd/deepgram.js +1 -1
- package/package.json +4 -4
- package/src/lib/helpers.ts +1 -0
- package/src/lib/version.ts +1 -1
- package/src/packages/LiveClient.ts +5 -10
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DeepgramClientOptions, FileSource, PrerecordedSource, UrlSource } from "./types";
|
|
2
2
|
export declare function stripTrailingSlash(url: string): string;
|
|
3
3
|
export declare const isBrowser: () => boolean;
|
|
4
|
+
export declare const isServer: () => boolean;
|
|
4
5
|
export declare function applySettingDefaults(options: DeepgramClientOptions, defaults: DeepgramClientOptions): DeepgramClientOptions;
|
|
5
6
|
export declare function appendSearchParams(searchParams: URLSearchParams, options: Record<string, unknown>): void;
|
|
6
7
|
export declare const resolveHeadersConstructor: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OA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,mBAAoB,iBAAiB,gCAI5D,CAAC;AAEF,eAAO,MAAM,YAAY,mBAAoB,iBAAiB,iCAI7D,CAAC;AAcF,qBAAa,WAAY,SAAQ,GAAG;IAClC,OAAO,CAAC,WAAW,CAAQ;CAC5B"}
|
package/dist/main/lib/helpers.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.CallbackUrl = exports.isFileSource = exports.isUrlSource = exports.resolveHeadersConstructor = exports.appendSearchParams = exports.applySettingDefaults = exports.isBrowser = exports.stripTrailingSlash = void 0;
|
|
6
|
+
exports.CallbackUrl = exports.isFileSource = exports.isUrlSource = exports.resolveHeadersConstructor = exports.appendSearchParams = exports.applySettingDefaults = exports.isServer = exports.isBrowser = exports.stripTrailingSlash = void 0;
|
|
7
7
|
const cross_fetch_1 = require("cross-fetch");
|
|
8
8
|
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
9
9
|
function stripTrailingSlash(url) {
|
|
@@ -12,6 +12,8 @@ function stripTrailingSlash(url) {
|
|
|
12
12
|
exports.stripTrailingSlash = stripTrailingSlash;
|
|
13
13
|
const isBrowser = () => typeof window !== "undefined";
|
|
14
14
|
exports.isBrowser = isBrowser;
|
|
15
|
+
const isServer = () => typeof process !== "undefined";
|
|
16
|
+
exports.isServer = isServer;
|
|
15
17
|
function applySettingDefaults(options, defaults) {
|
|
16
18
|
return (0, deepmerge_1.default)(defaults, options);
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,6CAA2D;AAG3D,0DAA8B;AAE9B,SAAgB,kBAAkB,CAAC,GAAW;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK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AAM,kBAAkB,GAAG,CAAC,cAAiC,EAA8B,EAAE;IAC3F,IAAI,cAA0B;QAAE,OAAO,IAAI,CAAC;IAE5C,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAa,WAAY,SAAQ,GAAG;IAApC;;QACU,gBAAW,GAAG,IAAI,CAAC;IAC7B,CAAC;CAAA;AAFD,kCAEC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "3.0.0-beta.
|
|
1
|
+
export declare const version = "3.0.0-beta.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/main/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveClient.d.ts","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AAG5E,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAGjB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,qBAAa,UAAW,SAAQ,gBAAgB;IAI5C,SAAS,CAAC,GAAG,EAAE,MAAM;IACrB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS;IACpD,OAAO,CAAC,oBAAoB;IAL9B,OAAO,CAAC,OAAO,CAAY;gBAGf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,qBAAqB,GAAG,SAA2B,EAC9D,oBAAoB,GAAE,UAAe,EAC7C,QAAQ,SAAc;IA+DjB,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAS1C,SAAS,IAAI,IAAI;IAQjB,aAAa,IAAI,mBAAmB;IAI3C;;;;;;;OAOG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,IAAI;IAuBxD;;;OAGG;IACI,MAAM,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"LiveClient.d.ts","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AAG5E,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAGjB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,qBAAa,UAAW,SAAQ,gBAAgB;IAI5C,SAAS,CAAC,GAAG,EAAE,MAAM;IACrB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS;IACpD,OAAO,CAAC,oBAAoB;IAL9B,OAAO,CAAC,OAAO,CAAY;gBAGf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,qBAAqB,GAAG,SAA2B,EAC9D,oBAAoB,GAAE,UAAe,EAC7C,QAAQ,SAAc;IA+DjB,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAS1C,SAAS,IAAI,IAAI;IAQjB,aAAa,IAAI,mBAAmB;IAI3C;;;;;;;OAOG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,IAAI;IAuBxD;;;OAGG;IACI,MAAM,IAAI,IAAI;CAQtB"}
|
|
@@ -9,7 +9,7 @@ const helpers_1 = require("../lib/helpers");
|
|
|
9
9
|
const errors_1 = require("../lib/errors");
|
|
10
10
|
const constants_1 = require("../lib/constants");
|
|
11
11
|
const enums_1 = require("../lib/enums");
|
|
12
|
-
const
|
|
12
|
+
const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
|
|
13
13
|
class LiveClient extends AbstractWsClient_1.AbstractWsClient {
|
|
14
14
|
constructor(key, options = constants_1.DEFAULT_OPTIONS, transcriptionOptions = {}, endpoint = "v1/listen") {
|
|
15
15
|
var _a, _b;
|
|
@@ -20,14 +20,14 @@ class LiveClient extends AbstractWsClient_1.AbstractWsClient {
|
|
|
20
20
|
const url = new URL(endpoint, this.baseUrl);
|
|
21
21
|
url.protocol = url.protocol.toLowerCase().replace(/(http)(s)?/gi, "ws$2");
|
|
22
22
|
(0, helpers_1.appendSearchParams)(url.searchParams, this.transcriptionOptions);
|
|
23
|
-
if ((0, helpers_1.
|
|
24
|
-
this._socket = new
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this._socket = new modern_isomorphic_ws_1.default(url.toString(), {
|
|
23
|
+
if ((0, helpers_1.isServer)()) {
|
|
24
|
+
this._socket = new isomorphic_ws_1.default(url.toString(), {
|
|
28
25
|
headers: Object.assign({ Authorization: `token ${this.key}` }, (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.global) === null || _b === void 0 ? void 0 : _b.headers),
|
|
29
26
|
});
|
|
30
27
|
}
|
|
28
|
+
else {
|
|
29
|
+
this._socket = new isomorphic_ws_1.default(url.toString(), ["token", this.key]);
|
|
30
|
+
}
|
|
31
31
|
this._socket.onopen = () => {
|
|
32
32
|
this.emit(enums_1.LiveTranscriptionEvents.Open, this);
|
|
33
33
|
};
|
|
@@ -118,10 +118,6 @@ class LiveClient extends AbstractWsClient_1.AbstractWsClient {
|
|
|
118
118
|
this._socket.send(JSON.stringify({
|
|
119
119
|
type: "CloseStream",
|
|
120
120
|
}));
|
|
121
|
-
// close the socket from the client end
|
|
122
|
-
if (this._socket.readyState === enums_1.LiveConnectionState.OPEN) {
|
|
123
|
-
this._socket.close();
|
|
124
|
-
}
|
|
125
121
|
}
|
|
126
122
|
}
|
|
127
123
|
exports.LiveClient = LiveClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveClient.js","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"LiveClient.js","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAsD;AACtD,4CAA8D;AAC9D,0CAA8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;YACb,IAAI,EAAE,aAAa;SACpB,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AAtID,gCAsIC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DeepgramClientOptions, FileSource, PrerecordedSource, UrlSource } from "./types";
|
|
2
2
|
export declare function stripTrailingSlash(url: string): string;
|
|
3
3
|
export declare const isBrowser: () => boolean;
|
|
4
|
+
export declare const isServer: () => boolean;
|
|
4
5
|
export declare function applySettingDefaults(options: DeepgramClientOptions, defaults: DeepgramClientOptions): DeepgramClientOptions;
|
|
5
6
|
export declare function appendSearchParams(searchParams: URLSearchParams, options: Record<string, unknown>): void;
|
|
6
7
|
export declare const resolveHeadersConstructor: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAI1F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,eAAO,MAAM,SAAS,eAAsC,CAAC;AAE7D,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,EAAE,qBAAqB,GAC9B,qBAAqB,CAEvB;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,eAAe,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAWN;AAED,eAAO,MAAM,yBAAyB;;;CAMrC,CAAC;AAEF,eAAO,MAAM,WAAW,mBAAoB,iBAAiB,gCAI5D,CAAC;AAEF,eAAO,MAAM,YAAY,mBAAoB,iBAAiB,iCAI7D,CAAC;AAcF,qBAAa,WAAY,SAAQ,GAAG;IAClC,OAAO,CAAC,WAAW,CAAQ;CAC5B"}
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAI1F,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,eAAO,MAAM,SAAS,eAAsC,CAAC;AAC7D,eAAO,MAAM,QAAQ,eAAuC,CAAC;AAE7D,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAC9B,QAAQ,EAAE,qBAAqB,GAC9B,qBAAqB,CAEvB;AAED,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,eAAe,EAC7B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CAWN;AAED,eAAO,MAAM,yBAAyB;;;CAMrC,CAAC;AAEF,eAAO,MAAM,WAAW,mBAAoB,iBAAiB,gCAI5D,CAAC;AAEF,eAAO,MAAM,YAAY,mBAAoB,iBAAiB,iCAI7D,CAAC;AAcF,qBAAa,WAAY,SAAQ,GAAG;IAClC,OAAO,CAAC,WAAW,CAAQ;CAC5B"}
|
|
@@ -4,6 +4,7 @@ export function stripTrailingSlash(url) {
|
|
|
4
4
|
return url.replace(/\/$/, "");
|
|
5
5
|
}
|
|
6
6
|
export const isBrowser = () => typeof window !== "undefined";
|
|
7
|
+
export const isServer = () => typeof process !== "undefined";
|
|
7
8
|
export function applySettingDefaults(options, defaults) {
|
|
8
9
|
return merge(defaults, options);
|
|
9
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG3D,OAAO,KAAK,MAAM,WAAW,CAAC;AAE9B,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,KAA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M,OAAO,WAAY,SAAQ,GAAG;IAApC;;QACU,gBAAW,GAAG,IAAI,CAAC;IAC7B,CAAC;CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "3.0.0-beta.
|
|
1
|
+
export declare const version = "3.0.0-beta.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = "3.0.0-beta.
|
|
1
|
+
export const version = "3.0.0-beta.4";
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveClient.d.ts","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AAG5E,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAGjB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,qBAAa,UAAW,SAAQ,gBAAgB;IAI5C,SAAS,CAAC,GAAG,EAAE,MAAM;IACrB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS;IACpD,OAAO,CAAC,oBAAoB;IAL9B,OAAO,CAAC,OAAO,CAAY;gBAGf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,qBAAqB,GAAG,SAA2B,EAC9D,oBAAoB,GAAE,UAAe,EAC7C,QAAQ,SAAc;IA+DjB,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAS1C,SAAS,IAAI,IAAI;IAQjB,aAAa,IAAI,mBAAmB;IAI3C;;;;;;;OAOG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,IAAI;IAuBxD;;;OAGG;IACI,MAAM,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"LiveClient.d.ts","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,mBAAmB,EAA2B,MAAM,cAAc,CAAC;AAG5E,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAGjB,qBAAqB,EACtB,MAAM,cAAc,CAAC;AAEtB,qBAAa,UAAW,SAAQ,gBAAgB;IAI5C,SAAS,CAAC,GAAG,EAAE,MAAM;IACrB,SAAS,CAAC,OAAO,EAAE,qBAAqB,GAAG,SAAS;IACpD,OAAO,CAAC,oBAAoB;IAL9B,OAAO,CAAC,OAAO,CAAY;gBAGf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,qBAAqB,GAAG,SAA2B,EAC9D,oBAAoB,GAAE,UAAe,EAC7C,QAAQ,SAAc;IA+DjB,SAAS,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAS1C,SAAS,IAAI,IAAI;IAQjB,aAAa,IAAI,mBAAmB;IAI3C;;;;;;;OAOG;IACI,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,GAAG,IAAI;IAuBxD;;;OAGG;IACI,MAAM,IAAI,IAAI;CAQtB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AbstractWsClient } from "./AbstractWsClient";
|
|
2
|
-
import { appendSearchParams,
|
|
2
|
+
import { appendSearchParams, isServer } from "../lib/helpers";
|
|
3
3
|
import { DeepgramError } from "../lib/errors";
|
|
4
4
|
import { DEFAULT_OPTIONS } from "../lib/constants";
|
|
5
5
|
import { LiveConnectionState, LiveTranscriptionEvents } from "../lib/enums";
|
|
6
|
-
import WebSocket from "
|
|
6
|
+
import WebSocket from "isomorphic-ws";
|
|
7
7
|
export class LiveClient extends AbstractWsClient {
|
|
8
8
|
constructor(key, options = DEFAULT_OPTIONS, transcriptionOptions = {}, endpoint = "v1/listen") {
|
|
9
9
|
var _a, _b;
|
|
@@ -14,14 +14,14 @@ export class LiveClient extends AbstractWsClient {
|
|
|
14
14
|
const url = new URL(endpoint, this.baseUrl);
|
|
15
15
|
url.protocol = url.protocol.toLowerCase().replace(/(http)(s)?/gi, "ws$2");
|
|
16
16
|
appendSearchParams(url.searchParams, this.transcriptionOptions);
|
|
17
|
-
if (
|
|
18
|
-
this._socket = new WebSocket(url.toString(), ["token", this.key]);
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
17
|
+
if (isServer()) {
|
|
21
18
|
this._socket = new WebSocket(url.toString(), {
|
|
22
19
|
headers: Object.assign({ Authorization: `token ${this.key}` }, (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.global) === null || _b === void 0 ? void 0 : _b.headers),
|
|
23
20
|
});
|
|
24
21
|
}
|
|
22
|
+
else {
|
|
23
|
+
this._socket = new WebSocket(url.toString(), ["token", this.key]);
|
|
24
|
+
}
|
|
25
25
|
this._socket.onopen = () => {
|
|
26
26
|
this.emit(LiveTranscriptionEvents.Open, this);
|
|
27
27
|
};
|
|
@@ -112,10 +112,6 @@ export class LiveClient extends AbstractWsClient {
|
|
|
112
112
|
this._socket.send(JSON.stringify({
|
|
113
113
|
type: "CloseStream",
|
|
114
114
|
}));
|
|
115
|
-
// close the socket from the client end
|
|
116
|
-
if (this._socket.readyState === LiveConnectionState.OPEN) {
|
|
117
|
-
this._socket.close();
|
|
118
|
-
}
|
|
119
115
|
}
|
|
120
116
|
}
|
|
121
117
|
//# sourceMappingURL=LiveClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LiveClient.js","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"LiveClient.js","sourceRoot":"","sources":["../../../src/packages/LiveClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;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qFAAqF,CACtF,CAAC;iBACH;aACF;SACF;aAAM;YACL,MAAM,IAAI,aAAa,CAAC,sCAAsC,CAAC,CAAC;SACjE;IACH,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,sCAAsC;QACtC,IAAI,CAAC,OAAO,CAAC,IAAI,CACf,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,aAAa;SACpB,CAAC,CACH,CAAC;IACJ,CAAC;CACF"}
|
package/dist/umd/deepgram.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepgram=t():e.deepgram=t()}(self,(()=>(()=>{var e={993:(e,t,r)=>{"use strict";function n(e){return"transcriptionData"in e}r.r(t),r.d(t,{AssemblyAiConverter:()=>d,DeepgramConverter:()=>l,chunkArray:()=>c,isConverter:()=>n,secondsToTimestamp:()=>u,srt:()=>v,webvtt:()=>p});var i=r(484),s=r.n(i),o=r(576),a=r.n(o);function u(e,t="HH:mm:ss.SSS"){return s()(1e3*e).utc().format(t)}function c(e,t){const r=[];for(let n=0;n<e.length;n+=t){const i=e.slice(n,n+t);r.push(i)}return r}s().extend(a());class l{constructor(e){this.transcriptionData=e}getLines(e=8){const{results:t}=this.transcriptionData;let r=[];return t.utterances?t.utterances.forEach((t=>{t.words.length>e?r.push(...c(t.words,e)):r.push(t.words)})):r.push(...c(t.channels[0].alternatives[0].words,e)),r}getHeaders(){var e,t,r,n,i,s,o,a;const u=[];return u.push("NOTE"),u.push("Transcription provided by Deepgram"),(null===(e=this.transcriptionData.metadata)||void 0===e?void 0:e.request_id)&&u.push(`Request Id: ${null===(t=this.transcriptionData.metadata)||void 0===t?void 0:t.request_id}`),(null===(r=this.transcriptionData.metadata)||void 0===r?void 0:r.created)&&u.push(`Created: ${null===(n=this.transcriptionData.metadata)||void 0===n?void 0:n.created}`),(null===(i=this.transcriptionData.metadata)||void 0===i?void 0:i.duration)&&u.push(`Duration: ${null===(s=this.transcriptionData.metadata)||void 0===s?void 0:s.duration}`),(null===(o=this.transcriptionData.metadata)||void 0===o?void 0:o.channels)&&u.push(`Channels: ${null===(a=this.transcriptionData.metadata)||void 0===a?void 0:a.channels}`),u}}const h=e=>({word:e.text,start:e.start,end:e.end,confidence:e.confidence,punctuated_word:e.text,speaker:e.speaker});class d{constructor(e){this.transcriptionData=e}getLines(e=8){const t=this.transcriptionData;let r=[];return t.utterances?t.utterances.forEach((t=>{t.words.length>e?r.push(...c(t.words.map((e=>h(e))),e)):r.push(t.words.map((e=>h(e))))})):r.push(...c(t.words.map((e=>h(e))),e)),r}getHeaders(){const e=[];return e.push("NOTE"),e.push("Transcription provided by Assembly AI"),this.transcriptionData.id&&e.push(`Id: ${this.transcriptionData.id}`),this.transcriptionData.audio_duration&&e.push(`Duration: ${this.transcriptionData.audio_duration}`),e}}const f=e=>n(e)?e:new l(e),p=(e,t=8)=>{const r=[];let n=f(e);return r.push("WEBVTT"),r.push(""),n.getHeaders&&r.push(n.getHeaders().join("\n")),n.getHeaders&&r.push(""),n.getLines(t).forEach((e=>{const t=e[0],n=e[e.length-1];r.push(`${u(t.start)} --\x3e ${u(n.end)}`),r.push(e.map((e=>{var t;return null!==(t=e.punctuated_word)&&void 0!==t?t:e.word})).join(" ")),r.push("")})),r.join("\n")},v=(e,t=8)=>{const r=[],n=f(e).getLines(t);let i=1;return n.forEach((e=>{r.push((i++).toString());const t=e[0],n=e[e.length-1];r.push(`${u(t.start,"HH:mm:ss,SSS")} --\x3e ${u(n.end,"HH:mm:ss,SSS")}`),r.push(e.map((e=>{var t;return null!==(t=e.punctuated_word)&&void 0!==t?t:e.word})).join(" ")),r.push("")})),r.join("\n")}},98:function(e,t){var r="undefined"!=typeof self?self:this,n=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,i="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&i&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=p(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=c(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[c(e)]},d.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},d.prototype.set=function(e,t){this.map[c(e)]=l(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),h(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),h(e)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(e,t){var r,n,i=(t=t||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),b.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},m.call(g.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var O=[301,302,303,307,308];_.redirect=function(e,t){if(-1===O.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function j(e,r){return new Promise((function(n,s){var o=new g(e,r);if(o.signal&&o.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new _(i,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",u)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}j.polyfill=!0,e.fetch||(e.fetch=j,e.Headers=d,e.Request=g,e.Response=_),t.Headers=d,t.Request=g,t.Response=_,t.fetch=j,Object.defineProperty(t,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(t=i.fetch).default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,e.exports=t},484:function(e){e.exports=function(){"use strict";var e=6e4,t=36e5,r="millisecond",n="second",i="minute",s="hour",o="day",a="week",u="month",c="quarter",l="year",h="date",d="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],r=e%100;return"["+e+(t[(r-20)%10]||t[r]||t[0])+"]"}},y=function(e,t,r){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(r)+e},m={s:y,z:function(e){var t=-e.utcOffset(),r=Math.abs(t),n=Math.floor(r/60),i=r%60;return(t<=0?"+":"-")+y(n,2,"0")+":"+y(i,2,"0")},m:function e(t,r){if(t.date()<r.date())return-e(r,t);var n=12*(r.year()-t.year())+(r.month()-t.month()),i=t.clone().add(n,u),s=r-i<0,o=t.clone().add(n+(s?-1:1),u);return+(-(n+(r-i)/(s?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:u,y:l,w:a,d:o,D:h,h:s,m:i,s:n,ms:r,Q:c}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},b="en",g={};g[b]=v;var w="$isDayjsObject",_=function(e){return e instanceof D||!(!e||!e[w])},O=function e(t,r,n){var i;if(!t)return b;if("string"==typeof t){var s=t.toLowerCase();g[s]&&(i=s),r&&(g[s]=r,i=s);var o=t.split("-");if(!i&&o.length>1)return e(o[0])}else{var a=t.name;g[a]=t,i=a}return!n&&i&&(b=i),i||!n&&b},j=function(e,t){if(_(e))return e.clone();var r="object"==typeof t?t:{};return r.date=e,r.args=arguments,new D(r)},E=m;E.l=O,E.i=_,E.w=function(e,t){return j(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var D=function(){function v(e){this.$L=O(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var y=v.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,r=e.utc;if(null===t)return new Date(NaN);if(E.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var n=t.match(f);if(n){var i=n[2]-1||0,s=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,s)):new Date(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,s)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return E},y.isValid=function(){return!(this.$d.toString()===d)},y.isSame=function(e,t){var r=j(e);return this.startOf(t)<=r&&r<=this.endOf(t)},y.isAfter=function(e,t){return j(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<j(e)},y.$g=function(e,t,r){return E.u(e)?this[t]:this.set(r,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var r=this,c=!!E.u(t)||t,d=E.p(e),f=function(e,t){var n=E.w(r.$u?Date.UTC(r.$y,t,e):new Date(r.$y,t,e),r);return c?n:n.endOf(o)},p=function(e,t){return E.w(r.toDate()[e].apply(r.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(t)),r)},v=this.$W,y=this.$M,m=this.$D,b="set"+(this.$u?"UTC":"");switch(d){case l:return c?f(1,0):f(31,11);case u:return c?f(1,y):f(0,y+1);case a:var g=this.$locale().weekStart||0,w=(v<g?v+7:v)-g;return f(c?m-w:m+(6-w),y);case o:case h:return p(b+"Hours",0);case s:return p(b+"Minutes",1);case i:return p(b+"Seconds",2);case n:return p(b+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var a,c=E.p(e),d="set"+(this.$u?"UTC":""),f=(a={},a[o]=d+"Date",a[h]=d+"Date",a[u]=d+"Month",a[l]=d+"FullYear",a[s]=d+"Hours",a[i]=d+"Minutes",a[n]=d+"Seconds",a[r]=d+"Milliseconds",a)[c],p=c===o?this.$D+(t-this.$W):t;if(c===u||c===l){var v=this.clone().set(h,1);v.$d[f](p),v.init(),this.$d=v.set(h,Math.min(this.$D,v.daysInMonth())).$d}else f&&this.$d[f](p);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[E.p(e)]()},y.add=function(r,c){var h,d=this;r=Number(r);var f=E.p(c),p=function(e){var t=j(d);return E.w(t.date(t.date()+Math.round(e*r)),d)};if(f===u)return this.set(u,this.$M+r);if(f===l)return this.set(l,this.$y+r);if(f===o)return p(1);if(f===a)return p(7);var v=(h={},h[i]=e,h[s]=t,h[n]=1e3,h)[f]||1,y=this.$d.getTime()+r*v;return E.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return r.invalidDate||d;var n=e||"YYYY-MM-DDTHH:mm:ssZ",i=E.z(this),s=this.$H,o=this.$m,a=this.$M,u=r.weekdays,c=r.months,l=r.meridiem,h=function(e,r,i,s){return e&&(e[r]||e(t,n))||i[r].slice(0,s)},f=function(e){return E.s(s%12||12,e,"0")},v=l||function(e,t,r){var n=e<12?"AM":"PM";return r?n.toLowerCase():n};return n.replace(p,(function(e,n){return n||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return E.s(t.$y,4,"0");case"M":return a+1;case"MM":return E.s(a+1,2,"0");case"MMM":return h(r.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return t.$D;case"DD":return E.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(r.weekdaysMin,t.$W,u,2);case"ddd":return h(r.weekdaysShort,t.$W,u,3);case"dddd":return u[t.$W];case"H":return String(s);case"HH":return E.s(s,2,"0");case"h":return f(1);case"hh":return f(2);case"a":return v(s,o,!0);case"A":return v(s,o,!1);case"m":return String(o);case"mm":return E.s(o,2,"0");case"s":return String(t.$s);case"ss":return E.s(t.$s,2,"0");case"SSS":return E.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")}))},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(r,h,d){var f,p=this,v=E.p(h),y=j(r),m=(y.utcOffset()-this.utcOffset())*e,b=this-y,g=function(){return E.m(p,y)};switch(v){case l:f=g()/12;break;case u:f=g();break;case c:f=g()/3;break;case a:f=(b-m)/6048e5;break;case o:f=(b-m)/864e5;break;case s:f=b/t;break;case i:f=b/e;break;case n:f=b/1e3;break;default:f=b}return d?f:E.a(f)},y.daysInMonth=function(){return this.endOf(u).$D},y.$locale=function(){return g[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var r=this.clone(),n=O(e,t,!0);return n&&(r.$L=n),r},y.clone=function(){return E.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},v}(),P=D.prototype;return j.prototype=P,[["$ms",r],["$s",n],["$m",i],["$H",s],["$W",o],["$M",u],["$y",l],["$D",h]].forEach((function(e){P[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),j.extend=function(e,t){return e.$i||(e(t,D,j),e.$i=!0),j},j.locale=O,j.isDayjs=_,j.unix=function(e){return j(1e3*e)},j.en=g[b],j.Ls=g,j.p={},j}()},576:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,i,s){var o=i.prototype;s.utc=function(e){return new i({date:e,utc:!0,args:arguments})},o.utc=function(t){var r=s(this.toDate(),{locale:this.$L,utc:!0});return t?r.add(this.utcOffset(),e):r},o.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),a.call(this,e)};var u=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else u.call(this)};var c=o.utcOffset;o.utcOffset=function(n,i){var s=this.$utils().u;if(s(n))return this.$u?0:s(this.$offset)?c.call(this):this.$offset;if("string"==typeof n&&(n=function(e){void 0===e&&(e="");var n=e.match(t);if(!n)return null;var i=(""+n[0]).match(r)||["-",0,0],s=i[0],o=60*+i[1]+ +i[2];return 0===o?0:"+"===s?o:-o}(n),null===n))return this;var o=Math.abs(n)<=16?60*n:n,a=this;if(i)return a.$offset=o,a.$u=0===n,a;if(0!==n){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(o+u,e)).$offset=o,a.$x.$localOffset=u}else a=this.utc();return a};var l=o.format;o.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var h=o.toDate;o.toDate=function(e){return"s"===e&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=o.diff;o.diff=function(e,t,r){if(e&&this.$u===e.$u)return d.call(this,e,t,r);var n=this.local(),i=s(e).local();return d.call(n,i,t,r)}}}()},996:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===r}(e)}(e)},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((r=e,Array.isArray(r)?[]:{}),e,t):e;var r}function i(e,t,r){return e.concat(t).map((function(e){return n(e,r)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,r,u){(u=u||{}).arrayMerge=u.arrayMerge||i,u.isMergeableObject=u.isMergeableObject||t,u.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(r);return c===Array.isArray(e)?c?u.arrayMerge(e,r,u):function(e,t,r){var i={};return r.isMergeableObject(e)&&s(e).forEach((function(t){i[t]=n(e[t],r)})),s(t).forEach((function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&r.isMergeableObject(t[s])?i[s]=function(e,t){if(!t.customMerge)return a;var r=t.customMerge(e);return"function"==typeof r?r:a}(s,r)(e[s],t[s],r):i[s]=n(t[s],r))})),i}(e,r,u):n(r,u)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,r){return a(e,r,t)}),{})};var u=a;e.exports=u},187:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}v(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&v(e,"error",t,{once:!0})}(e,i)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function c(e,t,r,n){var i,s,o,c;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=u(e))>0&&o.length>i&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,c=l,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function v(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){n.once&&e.removeEventListener(t,i),r(s)}))}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=s[e];if(void 0===u)return!1;if("function"==typeof u)n(u,this,t);else{var c=u.length,l=p(u,c);for(r=0;r<c;++r)n(l[r],this,t)}return!0},s.prototype.addListener=function(e,t){return c(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return c(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,i,s,o;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},198:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>n});const n=WebSocket},274:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(910),i=r(685),s=r(412),o=r(581);class a extends n.AbstractClient{get listen(){return new i.ListenClient(this.key,this.options)}get manage(){return new s.ManageClient(this.key,this.options)}get onprem(){return new o.OnPremClient(this.key,this.options)}}t.default=a},341:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.srt=t.webvtt=t.DeepgramClient=t.createClient=void 0;const o=s(r(274));t.DeepgramClient=o.default,t.createClient=(e,t={})=>new o.default(e,t),i(r(458),t),i(r(475),t),i(r(57),t),i(r(678),t),i(r(752),t);var a=r(993);Object.defineProperty(t,"webvtt",{enumerable:!0,get:function(){return a.webvtt}}),Object.defineProperty(t,"srt",{enumerable:!0,get:function(){return a.srt}})},678:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_OPTIONS=t.DEFAULT_FETCH_OPTIONS=t.DEFAULT_GLOBAL_OPTIONS=t.DEFAULT_URL=t.DEFAULT_HEADERS=void 0;const n=r(610),i=r(506);t.DEFAULT_HEADERS={"Content-Type":"application/json","X-Client-Info":`@deepgram/sdk; ${(0,n.isBrowser)()?"browser":"server"}; v${i.version}`,"User-Agent":`@deepgram/sdk/${i.version}`},t.DEFAULT_URL="api.deepgram.com",t.DEFAULT_GLOBAL_OPTIONS={url:t.DEFAULT_URL},t.DEFAULT_FETCH_OPTIONS={headers:t.DEFAULT_HEADERS},t.DEFAULT_OPTIONS={global:t.DEFAULT_GLOBAL_OPTIONS,fetch:t.DEFAULT_FETCH_OPTIONS}},615:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveConnectionState=void 0,(r=t.LiveConnectionState||(t.LiveConnectionState={}))[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSING=2]="CLOSING",r[r.CLOSED=3]="CLOSED"},178:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=void 0,(r=t.LiveTranscriptionEvents||(t.LiveTranscriptionEvents={})).Open="open",r.Close="close",r.Transcript="Results",r.Metadata="Metadata",r.Error="error",r.Warning="warning"},57:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=t.LiveConnectionState=void 0;var n=r(615);Object.defineProperty(t,"LiveConnectionState",{enumerable:!0,get:function(){return n.LiveConnectionState}});var i=r(178);Object.defineProperty(t,"LiveTranscriptionEvents",{enumerable:!0,get:function(){return i.LiveTranscriptionEvents}})},752:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramUnknownError=t.DeepgramApiError=t.isDeepgramError=t.DeepgramError=void 0;class r extends Error{constructor(e){super(e),this.__dgError=!0,this.name="DeepgramError"}}t.DeepgramError=r,t.isDeepgramError=function(e){return"object"==typeof e&&null!==e&&"__dgError"in e},t.DeepgramApiError=class extends r{constructor(e,t){super(e),this.name="DeepgramApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},t.DeepgramUnknownError=class extends r{constructor(e,t){super(e),this.name="DeepgramUnknownError",this.originalError=t}}},716:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveResponse=t.fetchWithAuth=t.resolveFetch=void 0;const u=a(r(98)),c=r(610);t.resolveFetch=()=>{let e;return e="undefined"==typeof fetch?u.default:fetch,(...t)=>e(...t)},t.fetchWithAuth=e=>{const r=(0,t.resolveFetch)(),n=(0,c.resolveHeadersConstructor)();return(t,i)=>o(void 0,void 0,void 0,(function*(){let s=new n(null==i?void 0:i.headers);return s.has("Authorization")||s.set("Authorization",`Token ${e}`),r(t,Object.assign(Object.assign({},i),{headers:s}))}))},t.resolveResponse=()=>o(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then((()=>s(r(98))))).Response:Response}))},610:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackUrl=t.isFileSource=t.isUrlSource=t.resolveHeadersConstructor=t.appendSearchParams=t.applySettingDefaults=t.isBrowser=t.stripTrailingSlash=void 0;const i=r(98),s=n(r(996));t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.applySettingDefaults=function(e,t){return(0,s.default)(t,e)},t.appendSearchParams=function(e,t){Object.keys(t).forEach((r=>{Array.isArray(t[r])?t[r].forEach((t=>{e.append(r,String(t))})):e.append(r,String(t[r]))}))},t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?i.Headers:Headers,t.isUrlSource=e=>!!e.url,t.isFileSource=e=>!(!a(e)&&!o(e));const o=e=>!!e,a=e=>!!e;class u extends URL{constructor(){super(...arguments),this.callbackUrl=!0}}t.CallbackUrl=u},475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="0.0.0-automated"},910:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractClient=void 0;const n=r(678),i=r(610);t.AbstractClient=class{constructor(e,t){var r,s;if(this.key=e,this.options=t,this.key=e,e||(this.key=process.env.DEEPGRAM_API_KEY),!this.key)throw new Error("A deepgram API key is required");if(this.options=(0,i.applySettingDefaults)(t,n.DEFAULT_OPTIONS),!(null===(r=this.options.global)||void 0===r?void 0:r.url))throw new Error(`An API URL is required. It should be set to ${n.DEFAULT_URL} by default. No idea what happened!`);this.willProxy()?(this.baseUrl=this.resolveBaseUrl(null===(s=this.options.restProxy)||void 0===s?void 0:s.url),this.options.global.headers&&(this.options.global.headers["X-Deepgram-Proxy"]=this.options.global.url)):this.baseUrl=this.resolveBaseUrl(this.options.global.url)}resolveBaseUrl(e){return/^https?:\/\//i.test(e)||(e="https://"+e),new URL((0,i.stripTrailingSlash)(e))}willProxy(){var e;return!!(null===(e=this.options.restProxy)||void 0===e?void 0:e.url)}}},207:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractRestfulClient=void 0;const i=r(752),s=r(716),o=r(910),a=r(610);class u extends o.AbstractClient{constructor(e,t){if(super(e,t),this.key=e,this.options=t,(0,a.isBrowser)()&&!this.willProxy())throw new i.DeepgramError("Due to CORS we are unable to support REST-based API calls to our API from the browser. Please consider using a proxy, and including a `restProxy: { url: ''}` in your Deepgram client options.");this.fetch=(0,s.fetchWithAuth)(this.key)}_getErrorMessage(e){return e.msg||e.message||e.error_description||e.error||JSON.stringify(e)}handleError(e,t){return n(this,void 0,void 0,(function*(){const r=yield(0,s.resolveResponse)();e instanceof r?e.json().then((r=>{t(new i.DeepgramApiError(this._getErrorMessage(r),e.status||500))})).catch((e=>{t(new i.DeepgramUnknownError(this._getErrorMessage(e),e))})):t(new i.DeepgramUnknownError(this._getErrorMessage(e),e))}))}_getRequestParams(e,t,r,n){var i,s,o;const a=Object.assign(Object.assign({},null===(i=this.options)||void 0===i?void 0:i.fetch),{method:e,headers:Object.assign(Object.assign({},null===(o=null===(s=this.options)||void 0===s?void 0:s.fetch)||void 0===o?void 0:o.headers),t)||{}});return"GET"===e?a:(a.body=n,a.duplex="half",Object.assign(Object.assign({},a),r))}_handleRequest(e,t,r,i,s,o){return n(this,void 0,void 0,(function*(){return new Promise(((n,a)=>{e(r,this._getRequestParams(t,i,s,o)).then((e=>{if(!e.ok)throw e;return e.json()})).then((e=>n(e))).catch((e=>this.handleError(e,a)))}))}))}get(e,t,r,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"GET",t,r,i)}))}post(e,t,r,i,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"POST",t,i,s,r)}))}put(e,t,r,i,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PUT",t,i,s,r)}))}patch(e,t,r,i,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PATCH",t,i,s,r)}))}delete(e,t,r,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"DELETE",t,r,i)}))}}t.AbstractRestfulClient=u},898:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractWsClient=void 0;const n=r(187),i=r(678),s=r(610);class o extends n.EventEmitter{constructor(e,t=i.DEFAULT_OPTIONS){var r;if(super(),this.key=e,this.options=t,this.key=e,e||(this.key=process.env.DEEPGRAM_API_KEY),!this.key)throw new Error("A deepgram API key is required");if(this.options=(0,s.applySettingDefaults)(t,i.DEFAULT_OPTIONS),!(null===(r=this.options.global)||void 0===r?void 0:r.url))throw new Error(`An API URL is required. It should be set to ${i.DEFAULT_URL} by default. No idea what happened!`);let n=this.options.global.url;/^https?:\/\//i.test(n)||(n="https://"+n),this.baseUrl=new URL((0,s.stripTrailingSlash)(n)),this.baseUrl.protocol=this.baseUrl.protocol.toLowerCase().replace(/(http)(s)?/gi,"ws$2")}}t.AbstractWsClient=o},685:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListenClient=void 0;const n=r(910),i=r(118),s=r(524);class o extends n.AbstractClient{get prerecorded(){return new s.PrerecordedClient(this.key,this.options)}live(e,t="v1/listen"){return new i.LiveClient(this.key,this.options,e,t)}}t.ListenClient=o},118:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LiveClient=void 0;const i=r(898),s=r(610),o=r(752),a=r(678),u=r(57),c=n(r(198));class l extends i.AbstractWsClient{constructor(e,t=a.DEFAULT_OPTIONS,r={},n="v1/listen"){var i,o;super(e,t),this.key=e,this.options=t,this.transcriptionOptions=r;const l=new URL(n,this.baseUrl);l.protocol=l.protocol.toLowerCase().replace(/(http)(s)?/gi,"ws$2"),(0,s.appendSearchParams)(l.searchParams,this.transcriptionOptions),(0,s.isBrowser)()?this._socket=new c.default(l.toString(),["token",this.key]):this._socket=new c.default(l.toString(),{headers:Object.assign({Authorization:`token ${this.key}`},null===(o=null===(i=this.options)||void 0===i?void 0:i.global)||void 0===o?void 0:o.headers)}),this._socket.onopen=()=>{this.emit(u.LiveTranscriptionEvents.Open,this)},this._socket.onclose=e=>{const t=e.target;if(t._req){const r=t._req.res.rawHeaders.indexOf("dg-error");e.reason=t._req.res.rawHeaders[r+1]}this.emit(u.LiveTranscriptionEvents.Close,e)},this._socket.onerror=e=>{this.emit(u.LiveTranscriptionEvents.Error,e)},this._socket.onmessage=e=>{try{const t=JSON.parse(e.data.toString());t.type===u.LiveTranscriptionEvents.Metadata&&this.emit(u.LiveTranscriptionEvents.Metadata,t),t.type===u.LiveTranscriptionEvents.Transcript&&this.emit(u.LiveTranscriptionEvents.Transcript,t)}catch(t){this.emit(u.LiveTranscriptionEvents.Error,{event:e,message:"Unable to parse `data` as JSON.",error:t})}}}configure(e){this._socket.send(JSON.stringify({type:"Configure",processors:e}))}keepAlive(){this._socket.send(JSON.stringify({type:"KeepAlive"}))}getReadyState(){return this._socket.readyState}send(e){if(this._socket.readyState!==u.LiveConnectionState.OPEN)throw new o.DeepgramError("Could not send. Connection not open.");if("string"==typeof e)this._socket.send(e);else if(e instanceof Blob)this._socket.send(e);else{const t=e;t.byteLength>0?this._socket.send(t):this.emit(u.LiveTranscriptionEvents.Warning,"Zero-byte detected, skipping. Send `CloseStream` if trying to close the connection.")}}finish(){this._socket.send(JSON.stringify({type:"CloseStream"})),this._socket.readyState===u.LiveConnectionState.OPEN&&this._socket.close()}}t.LiveClient=l},412:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ManageClient=void 0;const i=r(207),s=r(752),o=r(610);class a extends i.AbstractRestfulClient{getProjects(e="v1/projects"){return n(this,void 0,void 0,(function*(){try{const t=new URL(this.baseUrl);return t.pathname=e,{result:yield this.get(this.fetch,t),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProject(e,t,r="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.patch(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),yield this.delete(this.fetch,r),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}getProjectKeys(e,t="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createProjectKey(e,t,r="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.post(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),yield this.delete(this.fetch,n),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMembers(e,t="v1/projects/:projectId/members"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}removeProjectMember(e,t,r="v1/projects/:projectId/members/:memberId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),yield this.delete(this.fetch,n),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMemberScopes(e,t,r="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProjectMemberScope(e,t,r,i="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=i.replace(/:projectId/,e).replace(/:memberId/,t);const s=JSON.stringify(r);return{result:yield this.put(this.fetch,n,s),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectInvites(e,t="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}sendProjectInvite(e,t,r="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.post(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectInvite(e,t,r="v1/projects/:projectId/invites/:email"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:email/,t),yield this.delete(this.fetch,n),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}leaveProject(e,t="v1/projects/:projectId/leave"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.delete(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequests(e,t,r="v1/projects/:projectId/requests"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequest(e,t,r="v1/projects/:projectId/requests/:requestId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:requestId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageSummary(e,t,r="v1/projects/:projectId/usage"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageFields(e,t,r="v1/projects/:projectId/usage/fields"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalances(e,t="v1/projects/:projectId/balances"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalance(e,t,r="v1/projects/:projectId/balances/:balanceId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:balanceId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.ManageClient=a},581:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OnPremClient=void 0;const i=r(207),s=r(752);class o extends i.AbstractRestfulClient{listCredentials(e,t="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.post(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.delete(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.OnPremClient=o},524:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PrerecordedClient=void 0;const i=r(207),s=r(610),o=r(752);class a extends i.AbstractRestfulClient{transcribeUrl(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=JSON.stringify(e),void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const i=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,s.appendSearchParams)(a.searchParams,i),{result:yield this.post(this.fetch,a,n),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFile(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=e,void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const i=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,s.appendSearchParams)(a.searchParams,i),{result:yield this.post(this.fetch,a,n,{"Content-Type":"deepgram/audio+video"}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeUrlCallback(e,t,r,i="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=JSON.stringify(e);const a=Object.assign(Object.assign({},r),{callback:t.toString()}),u=new URL(i,this.baseUrl);return(0,s.appendSearchParams)(u.searchParams,a),{result:yield this.post(this.fetch,u,n),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFileCallback(e,t,r,i="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=e;const a=Object.assign(Object.assign({},r),{callback:t.toString()}),u=new URL(i,this.baseUrl);return(0,s.appendSearchParams)(u.searchParams,a),{result:yield this.post(this.fetch,u,n,{"Content-Type":"deepgram/audio+video"}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.PrerecordedClient=a},458:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PrerecordedClient=t.OnPremClient=t.ManageClient=t.LiveClient=t.ListenClient=t.AbstractWsClient=t.AbstractRestfulClient=t.AbstractClient=void 0;var n=r(910);Object.defineProperty(t,"AbstractClient",{enumerable:!0,get:function(){return n.AbstractClient}});var i=r(207);Object.defineProperty(t,"AbstractRestfulClient",{enumerable:!0,get:function(){return i.AbstractRestfulClient}});var s=r(898);Object.defineProperty(t,"AbstractWsClient",{enumerable:!0,get:function(){return s.AbstractWsClient}});var o=r(685);Object.defineProperty(t,"ListenClient",{enumerable:!0,get:function(){return o.ListenClient}});var a=r(118);Object.defineProperty(t,"LiveClient",{enumerable:!0,get:function(){return a.LiveClient}});var u=r(412);Object.defineProperty(t,"ManageClient",{enumerable:!0,get:function(){return u.ManageClient}});var c=r(581);Object.defineProperty(t,"OnPremClient",{enumerable:!0,get:function(){return c.OnPremClient}});var l=r(524);Object.defineProperty(t,"PrerecordedClient",{enumerable:!0,get:function(){return l.PrerecordedClient}})}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}return r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(341)})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.deepgram=t():e.deepgram=t()}(self,(()=>(()=>{var e={993:(e,t,r)=>{"use strict";function n(e){return"transcriptionData"in e}r.r(t),r.d(t,{AssemblyAiConverter:()=>d,DeepgramConverter:()=>l,chunkArray:()=>c,isConverter:()=>n,secondsToTimestamp:()=>u,srt:()=>v,webvtt:()=>p});var i=r(484),s=r.n(i),o=r(576),a=r.n(o);function u(e,t="HH:mm:ss.SSS"){return s()(1e3*e).utc().format(t)}function c(e,t){const r=[];for(let n=0;n<e.length;n+=t){const i=e.slice(n,n+t);r.push(i)}return r}s().extend(a());class l{constructor(e){this.transcriptionData=e}getLines(e=8){const{results:t}=this.transcriptionData;let r=[];return t.utterances?t.utterances.forEach((t=>{t.words.length>e?r.push(...c(t.words,e)):r.push(t.words)})):r.push(...c(t.channels[0].alternatives[0].words,e)),r}getHeaders(){var e,t,r,n,i,s,o,a;const u=[];return u.push("NOTE"),u.push("Transcription provided by Deepgram"),(null===(e=this.transcriptionData.metadata)||void 0===e?void 0:e.request_id)&&u.push(`Request Id: ${null===(t=this.transcriptionData.metadata)||void 0===t?void 0:t.request_id}`),(null===(r=this.transcriptionData.metadata)||void 0===r?void 0:r.created)&&u.push(`Created: ${null===(n=this.transcriptionData.metadata)||void 0===n?void 0:n.created}`),(null===(i=this.transcriptionData.metadata)||void 0===i?void 0:i.duration)&&u.push(`Duration: ${null===(s=this.transcriptionData.metadata)||void 0===s?void 0:s.duration}`),(null===(o=this.transcriptionData.metadata)||void 0===o?void 0:o.channels)&&u.push(`Channels: ${null===(a=this.transcriptionData.metadata)||void 0===a?void 0:a.channels}`),u}}const h=e=>({word:e.text,start:e.start,end:e.end,confidence:e.confidence,punctuated_word:e.text,speaker:e.speaker});class d{constructor(e){this.transcriptionData=e}getLines(e=8){const t=this.transcriptionData;let r=[];return t.utterances?t.utterances.forEach((t=>{t.words.length>e?r.push(...c(t.words.map((e=>h(e))),e)):r.push(t.words.map((e=>h(e))))})):r.push(...c(t.words.map((e=>h(e))),e)),r}getHeaders(){const e=[];return e.push("NOTE"),e.push("Transcription provided by Assembly AI"),this.transcriptionData.id&&e.push(`Id: ${this.transcriptionData.id}`),this.transcriptionData.audio_duration&&e.push(`Duration: ${this.transcriptionData.audio_duration}`),e}}const f=e=>n(e)?e:new l(e),p=(e,t=8)=>{const r=[];let n=f(e);return r.push("WEBVTT"),r.push(""),n.getHeaders&&r.push(n.getHeaders().join("\n")),n.getHeaders&&r.push(""),n.getLines(t).forEach((e=>{const t=e[0],n=e[e.length-1];r.push(`${u(t.start)} --\x3e ${u(n.end)}`),r.push(e.map((e=>{var t;return null!==(t=e.punctuated_word)&&void 0!==t?t:e.word})).join(" ")),r.push("")})),r.join("\n")},v=(e,t=8)=>{const r=[],n=f(e).getLines(t);let i=1;return n.forEach((e=>{r.push((i++).toString());const t=e[0],n=e[e.length-1];r.push(`${u(t.start,"HH:mm:ss,SSS")} --\x3e ${u(n.end,"HH:mm:ss,SSS")}`),r.push(e.map((e=>{var t;return null!==(t=e.punctuated_word)&&void 0!==t?t:e.word})).join(" ")),r.push("")})),r.join("\n")}},98:function(e,t){var r="undefined"!=typeof self?self:this,n=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var r="URLSearchParams"in e,n="Symbol"in e&&"iterator"in Symbol,i="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in e,o="ArrayBuffer"in e;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(e){return e&&a.indexOf(Object.prototype.toString.call(e))>-1};function c(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function h(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function d(e){this.map={},e instanceof d?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function v(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():o&&i&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,r=p(t=new FileReader),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n<t.length;n++)r[n]=String.fromCharCode(t[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(e,t){e=c(e),t=l(t);var r=this.map[e];this.map[e]=r?r+", "+t:t},d.prototype.delete=function(e){delete this.map[c(e)]},d.prototype.get=function(e){return e=c(e),this.has(e)?this.map[e]:null},d.prototype.has=function(e){return this.map.hasOwnProperty(c(e))},d.prototype.set=function(e,t){this.map[c(e)]=l(t)},d.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},d.prototype.keys=function(){var e=[];return this.forEach((function(t,r){e.push(r)})),h(e)},d.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),h(e)},d.prototype.entries=function(){var e=[];return this.forEach((function(t,r){e.push([r,t])})),h(e)},n&&(d.prototype[Symbol.iterator]=d.prototype.entries);var b=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function g(e,t){var r,n,i=(t=t||{}).body;if(e instanceof g){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new d(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new d(t.headers)),this.method=(n=(r=t.method||this.method||"GET").toUpperCase(),b.indexOf(n)>-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new d(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},m.call(g.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var O=[301,302,303,307,308];_.redirect=function(e,t){if(-1===O.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function j(e,r){return new Promise((function(n,s){var o=new g(e,r);if(o.signal&&o.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new d,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;n(new _(i,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new t.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),o.headers.forEach((function(e,t){a.setRequestHeader(t,e)})),o.signal&&(o.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",u)}),a.send(void 0===o._bodyInit?null:o._bodyInit)}))}j.polyfill=!0,e.fetch||(e.fetch=j,e.Headers=d,e.Request=g,e.Response=_),t.Headers=d,t.Request=g,t.Response=_,t.fetch=j,Object.defineProperty(t,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(t=i.fetch).default=i.fetch,t.fetch=i.fetch,t.Headers=i.Headers,t.Request=i.Request,t.Response=i.Response,e.exports=t},484:function(e){e.exports=function(){"use strict";var e=6e4,t=36e5,r="millisecond",n="second",i="minute",s="hour",o="day",a="week",u="month",c="quarter",l="year",h="date",d="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,p=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],r=e%100;return"["+e+(t[(r-20)%10]||t[r]||t[0])+"]"}},y=function(e,t,r){var n=String(e);return!n||n.length>=t?e:""+Array(t+1-n.length).join(r)+e},m={s:y,z:function(e){var t=-e.utcOffset(),r=Math.abs(t),n=Math.floor(r/60),i=r%60;return(t<=0?"+":"-")+y(n,2,"0")+":"+y(i,2,"0")},m:function e(t,r){if(t.date()<r.date())return-e(r,t);var n=12*(r.year()-t.year())+(r.month()-t.month()),i=t.clone().add(n,u),s=r-i<0,o=t.clone().add(n+(s?-1:1),u);return+(-(n+(r-i)/(s?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:u,y:l,w:a,d:o,D:h,h:s,m:i,s:n,ms:r,Q:c}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},b="en",g={};g[b]=v;var w="$isDayjsObject",_=function(e){return e instanceof D||!(!e||!e[w])},O=function e(t,r,n){var i;if(!t)return b;if("string"==typeof t){var s=t.toLowerCase();g[s]&&(i=s),r&&(g[s]=r,i=s);var o=t.split("-");if(!i&&o.length>1)return e(o[0])}else{var a=t.name;g[a]=t,i=a}return!n&&i&&(b=i),i||!n&&b},j=function(e,t){if(_(e))return e.clone();var r="object"==typeof t?t:{};return r.date=e,r.args=arguments,new D(r)},E=m;E.l=O,E.i=_,E.w=function(e,t){return j(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var D=function(){function v(e){this.$L=O(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var y=v.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,r=e.utc;if(null===t)return new Date(NaN);if(E.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var n=t.match(f);if(n){var i=n[2]-1||0,s=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,s)):new Date(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,s)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return E},y.isValid=function(){return!(this.$d.toString()===d)},y.isSame=function(e,t){var r=j(e);return this.startOf(t)<=r&&r<=this.endOf(t)},y.isAfter=function(e,t){return j(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<j(e)},y.$g=function(e,t,r){return E.u(e)?this[t]:this.set(r,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var r=this,c=!!E.u(t)||t,d=E.p(e),f=function(e,t){var n=E.w(r.$u?Date.UTC(r.$y,t,e):new Date(r.$y,t,e),r);return c?n:n.endOf(o)},p=function(e,t){return E.w(r.toDate()[e].apply(r.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(t)),r)},v=this.$W,y=this.$M,m=this.$D,b="set"+(this.$u?"UTC":"");switch(d){case l:return c?f(1,0):f(31,11);case u:return c?f(1,y):f(0,y+1);case a:var g=this.$locale().weekStart||0,w=(v<g?v+7:v)-g;return f(c?m-w:m+(6-w),y);case o:case h:return p(b+"Hours",0);case s:return p(b+"Minutes",1);case i:return p(b+"Seconds",2);case n:return p(b+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var a,c=E.p(e),d="set"+(this.$u?"UTC":""),f=(a={},a[o]=d+"Date",a[h]=d+"Date",a[u]=d+"Month",a[l]=d+"FullYear",a[s]=d+"Hours",a[i]=d+"Minutes",a[n]=d+"Seconds",a[r]=d+"Milliseconds",a)[c],p=c===o?this.$D+(t-this.$W):t;if(c===u||c===l){var v=this.clone().set(h,1);v.$d[f](p),v.init(),this.$d=v.set(h,Math.min(this.$D,v.daysInMonth())).$d}else f&&this.$d[f](p);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[E.p(e)]()},y.add=function(r,c){var h,d=this;r=Number(r);var f=E.p(c),p=function(e){var t=j(d);return E.w(t.date(t.date()+Math.round(e*r)),d)};if(f===u)return this.set(u,this.$M+r);if(f===l)return this.set(l,this.$y+r);if(f===o)return p(1);if(f===a)return p(7);var v=(h={},h[i]=e,h[s]=t,h[n]=1e3,h)[f]||1,y=this.$d.getTime()+r*v;return E.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return r.invalidDate||d;var n=e||"YYYY-MM-DDTHH:mm:ssZ",i=E.z(this),s=this.$H,o=this.$m,a=this.$M,u=r.weekdays,c=r.months,l=r.meridiem,h=function(e,r,i,s){return e&&(e[r]||e(t,n))||i[r].slice(0,s)},f=function(e){return E.s(s%12||12,e,"0")},v=l||function(e,t,r){var n=e<12?"AM":"PM";return r?n.toLowerCase():n};return n.replace(p,(function(e,n){return n||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return E.s(t.$y,4,"0");case"M":return a+1;case"MM":return E.s(a+1,2,"0");case"MMM":return h(r.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return t.$D;case"DD":return E.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(r.weekdaysMin,t.$W,u,2);case"ddd":return h(r.weekdaysShort,t.$W,u,3);case"dddd":return u[t.$W];case"H":return String(s);case"HH":return E.s(s,2,"0");case"h":return f(1);case"hh":return f(2);case"a":return v(s,o,!0);case"A":return v(s,o,!1);case"m":return String(o);case"mm":return E.s(o,2,"0");case"s":return String(t.$s);case"ss":return E.s(t.$s,2,"0");case"SSS":return E.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")}))},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(r,h,d){var f,p=this,v=E.p(h),y=j(r),m=(y.utcOffset()-this.utcOffset())*e,b=this-y,g=function(){return E.m(p,y)};switch(v){case l:f=g()/12;break;case u:f=g();break;case c:f=g()/3;break;case a:f=(b-m)/6048e5;break;case o:f=(b-m)/864e5;break;case s:f=b/t;break;case i:f=b/e;break;case n:f=b/1e3;break;default:f=b}return d?f:E.a(f)},y.daysInMonth=function(){return this.endOf(u).$D},y.$locale=function(){return g[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var r=this.clone(),n=O(e,t,!0);return n&&(r.$L=n),r},y.clone=function(){return E.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},v}(),S=D.prototype;return j.prototype=S,[["$ms",r],["$s",n],["$m",i],["$H",s],["$W",o],["$M",u],["$y",l],["$D",h]].forEach((function(e){S[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),j.extend=function(e,t){return e.$i||(e(t,D,j),e.$i=!0),j},j.locale=O,j.isDayjs=_,j.unix=function(e){return j(1e3*e)},j.en=g[b],j.Ls=g,j.p={},j}()},576:function(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,r=/([+-]|\d\d)/g;return function(n,i,s){var o=i.prototype;s.utc=function(e){return new i({date:e,utc:!0,args:arguments})},o.utc=function(t){var r=s(this.toDate(),{locale:this.$L,utc:!0});return t?r.add(this.utcOffset(),e):r},o.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),a.call(this,e)};var u=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else u.call(this)};var c=o.utcOffset;o.utcOffset=function(n,i){var s=this.$utils().u;if(s(n))return this.$u?0:s(this.$offset)?c.call(this):this.$offset;if("string"==typeof n&&(n=function(e){void 0===e&&(e="");var n=e.match(t);if(!n)return null;var i=(""+n[0]).match(r)||["-",0,0],s=i[0],o=60*+i[1]+ +i[2];return 0===o?0:"+"===s?o:-o}(n),null===n))return this;var o=Math.abs(n)<=16?60*n:n,a=this;if(i)return a.$offset=o,a.$u=0===n,a;if(0!==n){var u=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(a=this.local().add(o+u,e)).$offset=o,a.$x.$localOffset=u}else a=this.utc();return a};var l=o.format;o.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var h=o.toDate;o.toDate=function(e){return"s"===e&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=o.diff;o.diff=function(e,t,r){if(e&&this.$u===e.$u)return d.call(this,e,t,r);var n=this.local(),i=s(e).local();return d.call(n,i,t,r)}}}()},996:e=>{"use strict";var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===r}(e)}(e)},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((r=e,Array.isArray(r)?[]:{}),e,t):e;var r}function i(e,t,r){return e.concat(t).map((function(e){return n(e,r)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,r,u){(u=u||{}).arrayMerge=u.arrayMerge||i,u.isMergeableObject=u.isMergeableObject||t,u.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(r);return c===Array.isArray(e)?c?u.arrayMerge(e,r,u):function(e,t,r){var i={};return r.isMergeableObject(e)&&s(e).forEach((function(t){i[t]=n(e[t],r)})),s(t).forEach((function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&r.isMergeableObject(t[s])?i[s]=function(e,t){if(!t.customMerge)return a;var r=t.customMerge(e);return"function"==typeof r?r:a}(s,r)(e[s],t[s],r):i[s]=n(t[s],r))})),i}(e,r,u):n(r,u)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,r){return a(e,r,t)}),{})};var u=a;e.exports=u},187:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}v(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"==typeof e.on&&v(e,"error",t,{once:!0})}(e,i)}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function u(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function c(e,t,r,n){var i,s,o,c;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"==typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=u(e))>0&&o.length>i&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=o.length,c=l,console&&console.warn&&console.warn(c)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function f(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function v(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(s){n.once&&e.removeEventListener(t,i),r(s)}))}}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");o=e}}),s.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},s.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,s=this._events;if(void 0!==s)i=i&&void 0===s.error;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=s[e];if(void 0===u)return!1;if("function"==typeof u)n(u,this,t);else{var c=u.length,l=p(u,c);for(r=0;r<c;++r)n(l[r],this,t)}return!0},s.prototype.addListener=function(e,t){return c(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return c(this,e,t,!0)},s.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},s.prototype.removeListener=function(e,t){var r,n,i,s,o;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,s=r.length-1;s>=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,s=Object.keys(r);for(n=0;n<s.length;++n)"removeListener"!==(i=s[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},792:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>i});var n=null;"undefined"!=typeof WebSocket?n=WebSocket:"undefined"!=typeof MozWebSocket?n=MozWebSocket:void 0!==r.g?n=r.g.WebSocket||r.g.MozWebSocket:"undefined"!=typeof window?n=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(n=self.WebSocket||self.MozWebSocket);const i=n},274:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(910),i=r(685),s=r(412),o=r(581);class a extends n.AbstractClient{get listen(){return new i.ListenClient(this.key,this.options)}get manage(){return new s.ManageClient(this.key,this.options)}get onprem(){return new o.OnPremClient(this.key,this.options)}}t.default=a},341:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.srt=t.webvtt=t.DeepgramClient=t.createClient=void 0;const o=s(r(274));t.DeepgramClient=o.default,t.createClient=(e,t={})=>new o.default(e,t),i(r(458),t),i(r(475),t),i(r(57),t),i(r(678),t),i(r(752),t);var a=r(993);Object.defineProperty(t,"webvtt",{enumerable:!0,get:function(){return a.webvtt}}),Object.defineProperty(t,"srt",{enumerable:!0,get:function(){return a.srt}})},678:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_OPTIONS=t.DEFAULT_FETCH_OPTIONS=t.DEFAULT_GLOBAL_OPTIONS=t.DEFAULT_URL=t.DEFAULT_HEADERS=void 0;const n=r(610),i=r(506);t.DEFAULT_HEADERS={"Content-Type":"application/json","X-Client-Info":`@deepgram/sdk; ${(0,n.isBrowser)()?"browser":"server"}; v${i.version}`,"User-Agent":`@deepgram/sdk/${i.version}`},t.DEFAULT_URL="api.deepgram.com",t.DEFAULT_GLOBAL_OPTIONS={url:t.DEFAULT_URL},t.DEFAULT_FETCH_OPTIONS={headers:t.DEFAULT_HEADERS},t.DEFAULT_OPTIONS={global:t.DEFAULT_GLOBAL_OPTIONS,fetch:t.DEFAULT_FETCH_OPTIONS}},615:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveConnectionState=void 0,(r=t.LiveConnectionState||(t.LiveConnectionState={}))[r.CONNECTING=0]="CONNECTING",r[r.OPEN=1]="OPEN",r[r.CLOSING=2]="CLOSING",r[r.CLOSED=3]="CLOSED"},178:(e,t)=>{"use strict";var r;Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=void 0,(r=t.LiveTranscriptionEvents||(t.LiveTranscriptionEvents={})).Open="open",r.Close="close",r.Transcript="Results",r.Metadata="Metadata",r.Error="error",r.Warning="warning"},57:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LiveTranscriptionEvents=t.LiveConnectionState=void 0;var n=r(615);Object.defineProperty(t,"LiveConnectionState",{enumerable:!0,get:function(){return n.LiveConnectionState}});var i=r(178);Object.defineProperty(t,"LiveTranscriptionEvents",{enumerable:!0,get:function(){return i.LiveTranscriptionEvents}})},752:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DeepgramUnknownError=t.DeepgramApiError=t.isDeepgramError=t.DeepgramError=void 0;class r extends Error{constructor(e){super(e),this.__dgError=!0,this.name="DeepgramError"}}t.DeepgramError=r,t.isDeepgramError=function(e){return"object"==typeof e&&null!==e&&"__dgError"in e},t.DeepgramApiError=class extends r{constructor(e,t){super(e),this.name="DeepgramApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}},t.DeepgramUnknownError=class extends r{constructor(e,t){super(e),this.name="DeepgramUnknownError",this.originalError=t}}},716:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveResponse=t.fetchWithAuth=t.resolveFetch=void 0;const u=a(r(98)),c=r(610);t.resolveFetch=()=>{let e;return e="undefined"==typeof fetch?u.default:fetch,(...t)=>e(...t)},t.fetchWithAuth=e=>{const r=(0,t.resolveFetch)(),n=(0,c.resolveHeadersConstructor)();return(t,i)=>o(void 0,void 0,void 0,(function*(){let s=new n(null==i?void 0:i.headers);return s.has("Authorization")||s.set("Authorization",`Token ${e}`),r(t,Object.assign(Object.assign({},i),{headers:s}))}))},t.resolveResponse=()=>o(void 0,void 0,void 0,(function*(){return"undefined"==typeof Response?(yield Promise.resolve().then((()=>s(r(98))))).Response:Response}))},610:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CallbackUrl=t.isFileSource=t.isUrlSource=t.resolveHeadersConstructor=t.appendSearchParams=t.applySettingDefaults=t.isServer=t.isBrowser=t.stripTrailingSlash=void 0;const i=r(98),s=n(r(996));t.stripTrailingSlash=function(e){return e.replace(/\/$/,"")},t.isBrowser=()=>"undefined"!=typeof window,t.isServer=()=>"undefined"!=typeof process,t.applySettingDefaults=function(e,t){return(0,s.default)(t,e)},t.appendSearchParams=function(e,t){Object.keys(t).forEach((r=>{Array.isArray(t[r])?t[r].forEach((t=>{e.append(r,String(t))})):e.append(r,String(t[r]))}))},t.resolveHeadersConstructor=()=>"undefined"==typeof Headers?i.Headers:Headers,t.isUrlSource=e=>!!e.url,t.isFileSource=e=>!(!a(e)&&!o(e));const o=e=>!!e,a=e=>!!e;class u extends URL{constructor(){super(...arguments),this.callbackUrl=!0}}t.CallbackUrl=u},475:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.version=void 0,t.version="0.0.0-automated"},910:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractClient=void 0;const n=r(678),i=r(610);t.AbstractClient=class{constructor(e,t){var r,s;if(this.key=e,this.options=t,this.key=e,e||(this.key=process.env.DEEPGRAM_API_KEY),!this.key)throw new Error("A deepgram API key is required");if(this.options=(0,i.applySettingDefaults)(t,n.DEFAULT_OPTIONS),!(null===(r=this.options.global)||void 0===r?void 0:r.url))throw new Error(`An API URL is required. It should be set to ${n.DEFAULT_URL} by default. No idea what happened!`);this.willProxy()?(this.baseUrl=this.resolveBaseUrl(null===(s=this.options.restProxy)||void 0===s?void 0:s.url),this.options.global.headers&&(this.options.global.headers["X-Deepgram-Proxy"]=this.options.global.url)):this.baseUrl=this.resolveBaseUrl(this.options.global.url)}resolveBaseUrl(e){return/^https?:\/\//i.test(e)||(e="https://"+e),new URL((0,i.stripTrailingSlash)(e))}willProxy(){var e;return!!(null===(e=this.options.restProxy)||void 0===e?void 0:e.url)}}},207:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractRestfulClient=void 0;const i=r(752),s=r(716),o=r(910),a=r(610);class u extends o.AbstractClient{constructor(e,t){if(super(e,t),this.key=e,this.options=t,(0,a.isBrowser)()&&!this.willProxy())throw new i.DeepgramError("Due to CORS we are unable to support REST-based API calls to our API from the browser. Please consider using a proxy, and including a `restProxy: { url: ''}` in your Deepgram client options.");this.fetch=(0,s.fetchWithAuth)(this.key)}_getErrorMessage(e){return e.msg||e.message||e.error_description||e.error||JSON.stringify(e)}handleError(e,t){return n(this,void 0,void 0,(function*(){const r=yield(0,s.resolveResponse)();e instanceof r?e.json().then((r=>{t(new i.DeepgramApiError(this._getErrorMessage(r),e.status||500))})).catch((e=>{t(new i.DeepgramUnknownError(this._getErrorMessage(e),e))})):t(new i.DeepgramUnknownError(this._getErrorMessage(e),e))}))}_getRequestParams(e,t,r,n){var i,s,o;const a=Object.assign(Object.assign({},null===(i=this.options)||void 0===i?void 0:i.fetch),{method:e,headers:Object.assign(Object.assign({},null===(o=null===(s=this.options)||void 0===s?void 0:s.fetch)||void 0===o?void 0:o.headers),t)||{}});return"GET"===e?a:(a.body=n,a.duplex="half",Object.assign(Object.assign({},a),r))}_handleRequest(e,t,r,i,s,o){return n(this,void 0,void 0,(function*(){return new Promise(((n,a)=>{e(r,this._getRequestParams(t,i,s,o)).then((e=>{if(!e.ok)throw e;return e.json()})).then((e=>n(e))).catch((e=>this.handleError(e,a)))}))}))}get(e,t,r,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"GET",t,r,i)}))}post(e,t,r,i,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"POST",t,i,s,r)}))}put(e,t,r,i,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PUT",t,i,s,r)}))}patch(e,t,r,i,s){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"PATCH",t,i,s,r)}))}delete(e,t,r,i){return n(this,void 0,void 0,(function*(){return this._handleRequest(e,"DELETE",t,r,i)}))}}t.AbstractRestfulClient=u},898:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AbstractWsClient=void 0;const n=r(187),i=r(678),s=r(610);class o extends n.EventEmitter{constructor(e,t=i.DEFAULT_OPTIONS){var r;if(super(),this.key=e,this.options=t,this.key=e,e||(this.key=process.env.DEEPGRAM_API_KEY),!this.key)throw new Error("A deepgram API key is required");if(this.options=(0,s.applySettingDefaults)(t,i.DEFAULT_OPTIONS),!(null===(r=this.options.global)||void 0===r?void 0:r.url))throw new Error(`An API URL is required. It should be set to ${i.DEFAULT_URL} by default. No idea what happened!`);let n=this.options.global.url;/^https?:\/\//i.test(n)||(n="https://"+n),this.baseUrl=new URL((0,s.stripTrailingSlash)(n)),this.baseUrl.protocol=this.baseUrl.protocol.toLowerCase().replace(/(http)(s)?/gi,"ws$2")}}t.AbstractWsClient=o},685:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ListenClient=void 0;const n=r(910),i=r(118),s=r(524);class o extends n.AbstractClient{get prerecorded(){return new s.PrerecordedClient(this.key,this.options)}live(e,t="v1/listen"){return new i.LiveClient(this.key,this.options,e,t)}}t.ListenClient=o},118:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.LiveClient=void 0;const i=r(898),s=r(610),o=r(752),a=r(678),u=r(57),c=n(r(792));class l extends i.AbstractWsClient{constructor(e,t=a.DEFAULT_OPTIONS,r={},n="v1/listen"){var i,o;super(e,t),this.key=e,this.options=t,this.transcriptionOptions=r;const l=new URL(n,this.baseUrl);l.protocol=l.protocol.toLowerCase().replace(/(http)(s)?/gi,"ws$2"),(0,s.appendSearchParams)(l.searchParams,this.transcriptionOptions),(0,s.isServer)()?this._socket=new c.default(l.toString(),{headers:Object.assign({Authorization:`token ${this.key}`},null===(o=null===(i=this.options)||void 0===i?void 0:i.global)||void 0===o?void 0:o.headers)}):this._socket=new c.default(l.toString(),["token",this.key]),this._socket.onopen=()=>{this.emit(u.LiveTranscriptionEvents.Open,this)},this._socket.onclose=e=>{const t=e.target;if(t._req){const r=t._req.res.rawHeaders.indexOf("dg-error");e.reason=t._req.res.rawHeaders[r+1]}this.emit(u.LiveTranscriptionEvents.Close,e)},this._socket.onerror=e=>{this.emit(u.LiveTranscriptionEvents.Error,e)},this._socket.onmessage=e=>{try{const t=JSON.parse(e.data.toString());t.type===u.LiveTranscriptionEvents.Metadata&&this.emit(u.LiveTranscriptionEvents.Metadata,t),t.type===u.LiveTranscriptionEvents.Transcript&&this.emit(u.LiveTranscriptionEvents.Transcript,t)}catch(t){this.emit(u.LiveTranscriptionEvents.Error,{event:e,message:"Unable to parse `data` as JSON.",error:t})}}}configure(e){this._socket.send(JSON.stringify({type:"Configure",processors:e}))}keepAlive(){this._socket.send(JSON.stringify({type:"KeepAlive"}))}getReadyState(){return this._socket.readyState}send(e){if(this._socket.readyState!==u.LiveConnectionState.OPEN)throw new o.DeepgramError("Could not send. Connection not open.");if("string"==typeof e)this._socket.send(e);else if(e instanceof Blob)this._socket.send(e);else{const t=e;t.byteLength>0?this._socket.send(t):this.emit(u.LiveTranscriptionEvents.Warning,"Zero-byte detected, skipping. Send `CloseStream` if trying to close the connection.")}}finish(){this._socket.send(JSON.stringify({type:"CloseStream"}))}}t.LiveClient=l},412:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.ManageClient=void 0;const i=r(207),s=r(752),o=r(610);class a extends i.AbstractRestfulClient{getProjects(e="v1/projects"){return n(this,void 0,void 0,(function*(){try{const t=new URL(this.baseUrl);return t.pathname=e,{result:yield this.get(this.fetch,t),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProject(e,t,r="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.patch(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProject(e,t="v1/projects/:projectId"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),yield this.delete(this.fetch,r),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}getProjectKeys(e,t="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createProjectKey(e,t,r="v1/projects/:projectId/keys"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.post(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectKey(e,t,r="v1/projects/:projectId/keys/:keyId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:keyId/,t),yield this.delete(this.fetch,n),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMembers(e,t="v1/projects/:projectId/members"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}removeProjectMember(e,t,r="v1/projects/:projectId/members/:memberId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),yield this.delete(this.fetch,n),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}getProjectMemberScopes(e,t,r="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:memberId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}updateProjectMemberScope(e,t,r,i="v1/projects/:projectId/members/:memberId/scopes"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=i.replace(/:projectId/,e).replace(/:memberId/,t);const s=JSON.stringify(r);return{result:yield this.put(this.fetch,n,s),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectInvites(e,t="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}sendProjectInvite(e,t,r="v1/projects/:projectId/invites"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.post(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteProjectInvite(e,t,r="v1/projects/:projectId/invites/:email"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:email/,t),yield this.delete(this.fetch,n),{error:null}}catch(e){if((0,s.isDeepgramError)(e))return{error:e};throw e}}))}leaveProject(e,t="v1/projects/:projectId/leave"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.delete(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequests(e,t,r="v1/projects/:projectId/requests"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageRequest(e,t,r="v1/projects/:projectId/requests/:requestId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:requestId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageSummary(e,t,r="v1/projects/:projectId/usage"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectUsageFields(e,t,r="v1/projects/:projectId/usage/fields"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e),(0,o.appendSearchParams)(n.searchParams,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalances(e,t="v1/projects/:projectId/balances"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getProjectBalance(e,t,r="v1/projects/:projectId/balances/:balanceId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:balanceId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.ManageClient=a},581:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.OnPremClient=void 0;const i=r(207),s=r(752);class o extends i.AbstractRestfulClient{listCredentials(e,t="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const r=new URL(this.baseUrl);return r.pathname=t.replace(/:projectId/,e),{result:yield this.get(this.fetch,r),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}getCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.get(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}createCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);n.pathname=r.replace(/:projectId/,e);const i=JSON.stringify(t);return{result:yield this.post(this.fetch,n,i),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}deleteCredentials(e,t,r="v1/projects/:projectId/onprem/distribution/credentials/:credentialsId"){return n(this,void 0,void 0,(function*(){try{const n=new URL(this.baseUrl);return n.pathname=r.replace(/:projectId/,e).replace(/:credentialsId/,t),{result:yield this.delete(this.fetch,n),error:null}}catch(e){if((0,s.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.OnPremClient=o},524:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,s){function o(e){try{u(n.next(e))}catch(e){s(e)}}function a(e){try{u(n.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.PrerecordedClient=void 0;const i=r(207),s=r(610),o=r(752);class a extends i.AbstractRestfulClient{transcribeUrl(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=JSON.stringify(e),void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const i=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,s.appendSearchParams)(a.searchParams,i),{result:yield this.post(this.fetch,a,n),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFile(e,t,r="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");if(n=e,void 0!==t&&"callback"in t)throw new o.DeepgramError("Callback cannot be provided as an option to a synchronous transcription. Use `asyncPrerecordedUrl` or `asyncPrerecordedFile` instead.");const i=Object.assign({},t),a=new URL(r,this.baseUrl);return(0,s.appendSearchParams)(a.searchParams,i),{result:yield this.post(this.fetch,a,n,{"Content-Type":"deepgram/audio+video"}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeUrlCallback(e,t,r,i="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isUrlSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=JSON.stringify(e);const a=Object.assign(Object.assign({},r),{callback:t.toString()}),u=new URL(i,this.baseUrl);return(0,s.appendSearchParams)(u.searchParams,a),{result:yield this.post(this.fetch,u,n),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}transcribeFileCallback(e,t,r,i="v1/listen"){return n(this,void 0,void 0,(function*(){try{let n;if(!(0,s.isFileSource)(e))throw new o.DeepgramError("Unknown transcription source type");n=e;const a=Object.assign(Object.assign({},r),{callback:t.toString()}),u=new URL(i,this.baseUrl);return(0,s.appendSearchParams)(u.searchParams,a),{result:yield this.post(this.fetch,u,n,{"Content-Type":"deepgram/audio+video"}),error:null}}catch(e){if((0,o.isDeepgramError)(e))return{result:null,error:e};throw e}}))}}t.PrerecordedClient=a},458:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PrerecordedClient=t.OnPremClient=t.ManageClient=t.LiveClient=t.ListenClient=t.AbstractWsClient=t.AbstractRestfulClient=t.AbstractClient=void 0;var n=r(910);Object.defineProperty(t,"AbstractClient",{enumerable:!0,get:function(){return n.AbstractClient}});var i=r(207);Object.defineProperty(t,"AbstractRestfulClient",{enumerable:!0,get:function(){return i.AbstractRestfulClient}});var s=r(898);Object.defineProperty(t,"AbstractWsClient",{enumerable:!0,get:function(){return s.AbstractWsClient}});var o=r(685);Object.defineProperty(t,"ListenClient",{enumerable:!0,get:function(){return o.ListenClient}});var a=r(118);Object.defineProperty(t,"LiveClient",{enumerable:!0,get:function(){return a.LiveClient}});var u=r(412);Object.defineProperty(t,"ManageClient",{enumerable:!0,get:function(){return u.ManageClient}});var c=r(581);Object.defineProperty(t,"OnPremClient",{enumerable:!0,get:function(){return c.OnPremClient}});var l=r(524);Object.defineProperty(t,"PrerecordedClient",{enumerable:!0,get:function(){return l.PrerecordedClient}})}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}return r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r(341)})()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepgram/sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "Isomorphic Javascript client for Deepgram",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -55,7 +55,8 @@
|
|
|
55
55
|
"cross-fetch": "^3.1.5",
|
|
56
56
|
"deepmerge": "^4.3.1",
|
|
57
57
|
"events": "^3.3.0",
|
|
58
|
-
"
|
|
58
|
+
"isomorphic-ws": "^5.0.0",
|
|
59
|
+
"ws": "^8.14.2"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
62
|
"@commitlint/cli": "^17.6.7",
|
|
@@ -81,8 +82,7 @@
|
|
|
81
82
|
"typedoc": "^0.22.16",
|
|
82
83
|
"typescript": "^4.5.5",
|
|
83
84
|
"webpack": "^5.69.1",
|
|
84
|
-
"webpack-cli": "^4.9.2"
|
|
85
|
-
"ws": "^8.13.0"
|
|
85
|
+
"webpack-cli": "^4.9.2"
|
|
86
86
|
},
|
|
87
87
|
"husky": {
|
|
88
88
|
"hooks": {
|
package/src/lib/helpers.ts
CHANGED
|
@@ -8,6 +8,7 @@ export function stripTrailingSlash(url: string): string {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const isBrowser = () => typeof window !== "undefined";
|
|
11
|
+
export const isServer = () => typeof process !== "undefined";
|
|
11
12
|
|
|
12
13
|
export function applySettingDefaults(
|
|
13
14
|
options: DeepgramClientOptions,
|
package/src/lib/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "3.0.0-beta.
|
|
1
|
+
export const version = "3.0.0-beta.4";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AbstractWsClient } from "./AbstractWsClient";
|
|
2
|
-
import { appendSearchParams,
|
|
2
|
+
import { appendSearchParams, isServer } from "../lib/helpers";
|
|
3
3
|
import { DeepgramError } from "../lib/errors";
|
|
4
4
|
import { DEFAULT_OPTIONS } from "../lib/constants";
|
|
5
5
|
import { LiveConnectionState, LiveTranscriptionEvents } from "../lib/enums";
|
|
6
|
-
import WebSocket from "
|
|
6
|
+
import WebSocket from "isomorphic-ws";
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
9
|
LiveSchema,
|
|
@@ -28,15 +28,15 @@ export class LiveClient extends AbstractWsClient {
|
|
|
28
28
|
url.protocol = url.protocol.toLowerCase().replace(/(http)(s)?/gi, "ws$2");
|
|
29
29
|
appendSearchParams(url.searchParams, this.transcriptionOptions);
|
|
30
30
|
|
|
31
|
-
if (
|
|
32
|
-
this._socket = new WebSocket(url.toString(), ["token", this.key]);
|
|
33
|
-
} else {
|
|
31
|
+
if (isServer()) {
|
|
34
32
|
this._socket = new WebSocket(url.toString(), {
|
|
35
33
|
headers: {
|
|
36
34
|
Authorization: `token ${this.key}`,
|
|
37
35
|
...this.options?.global?.headers,
|
|
38
36
|
},
|
|
39
37
|
});
|
|
38
|
+
} else {
|
|
39
|
+
this._socket = new WebSocket(url.toString(), ["token", this.key]);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
this._socket.onopen = () => {
|
|
@@ -146,10 +146,5 @@ export class LiveClient extends AbstractWsClient {
|
|
|
146
146
|
type: "CloseStream",
|
|
147
147
|
})
|
|
148
148
|
);
|
|
149
|
-
|
|
150
|
-
// close the socket from the client end
|
|
151
|
-
if (this._socket.readyState === LiveConnectionState.OPEN) {
|
|
152
|
-
this._socket.close();
|
|
153
|
-
}
|
|
154
149
|
}
|
|
155
150
|
}
|