@anam-ai/js-sdk 2.5.0 → 3.0.0
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/AnamClient.d.ts.map +1 -1
- package/dist/main/AnamClient.js +1 -3
- package/dist/main/AnamClient.js.map +1 -1
- package/dist/main/index.d.ts +1 -2
- package/dist/main/index.d.ts.map +1 -1
- package/dist/main/index.js +2 -2
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/constants.js +1 -1
- package/dist/main/types/AnamPublicClientOptions.d.ts +6 -0
- package/dist/main/types/AnamPublicClientOptions.d.ts.map +1 -1
- package/dist/main/types/PersonaConfig.d.ts +2 -7
- package/dist/main/types/PersonaConfig.d.ts.map +1 -1
- package/dist/main/types/PersonaConfig.js +1 -5
- package/dist/main/types/PersonaConfig.js.map +1 -1
- package/dist/module/AnamClient.d.ts.map +1 -1
- package/dist/module/AnamClient.js +1 -3
- package/dist/module/AnamClient.js.map +1 -1
- package/dist/module/index.d.ts +1 -2
- package/dist/module/index.d.ts.map +1 -1
- package/dist/module/index.js +2 -2
- package/dist/module/index.js.map +1 -1
- package/dist/module/lib/constants.js +1 -1
- package/dist/module/types/AnamPublicClientOptions.d.ts +6 -0
- package/dist/module/types/AnamPublicClientOptions.d.ts.map +1 -1
- package/dist/module/types/PersonaConfig.d.ts +2 -7
- package/dist/module/types/PersonaConfig.d.ts.map +1 -1
- package/dist/module/types/PersonaConfig.js +0 -3
- package/dist/module/types/PersonaConfig.js.map +1 -1
- package/dist/umd/anam.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnamClient.d.ts","sourceRoot":"","sources":["../../src/AnamClient.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,eAAe,EACf,aAAa,EAGd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;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amClient.js
CHANGED
|
@@ -62,9 +62,7 @@ class AnamClient {
|
|
|
62
62
|
(0, ClientError_1.setCurrentSessionInfo)(this.sessionId, this.organizationId);
|
|
63
63
|
const tokenType = (_a = decodedToken.type) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
64
64
|
if (tokenType === 'legacy') {
|
|
65
|
-
|
|
66
|
-
return 'Both session token and client are missing a persona configuration. Please provide a persona ID of a saved persona in the personaConfig parameter.';
|
|
67
|
-
}
|
|
65
|
+
return 'Legacy session tokens are no longer supported. Please define your persona when creating your session token. See https://docs.anam.ai/resources/migrating-legacy for more information.';
|
|
68
66
|
}
|
|
69
67
|
else if (tokenType === 'ephemeral' || tokenType === 'stateful') {
|
|
70
68
|
if (personaConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnamClient.js","sourceRoot":"","sources":["../../src/AnamClient.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mDAO2B;AAC3B,uCAMmB;AACnB,mCAQiB;AAEjB,mCAAgC;AAChC,MAAqB,UAAU;IAkB7B,YACE,YAAgC,EAChC,aAA6B,EAC7B,OAA2B;;QAbrB,oBAAe,GAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAEtD,cAAS,GAAkB,IAAI,CAAC;QAChC,mBAAc,GAAkB,IAAI,CAAC;QAErC,oBAAe,GAA2B,IAAI,CAAC;QAG/C,iBAAY,GAAG,KAAK,CAAC;QAO3B,MAAM,WAAW,GAAuB,IAAI,CAAC,oBAAoB,CAC/D,YAAY,EACZ,aAAa,EACb,OAAO,CACR,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,IAAI,yBAAW,CACnB,WAAW,EACX,uBAAS,CAAC,qCAAqC,EAC/C,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAE7B,IAAI,CAAA,MAAA,OA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A,IAAI,CAAC,aAAa,0CAAE,iBAAiB,CAAA,EAAE,CAAC;YACnE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,gBAAgB,EAAE,CAAC;QACjE,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,eAAe,mCACf,IAAI,CAAC,eAAe,KACvB,OAAO,EAAE,KAAK,GACf,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAEM,uBAAuB,CAAC,aAAsB;QACnD,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,8DAA8D,CAC/D,CAAC;QACJ,CAAC;QACD,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,eAAe,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACI,WAAW,CAChB,KAAQ,EACR,QAA2B;QAE3B,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAEM,cAAc,CACnB,KAAQ,EACR,QAA2B;QAE3B,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAhcD,6BAgcC"}
|
package/dist/main/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import AnamClient from './AnamClient';
|
|
2
2
|
import { PersonaConfig } from './types';
|
|
3
3
|
import { AnamPublicClientOptions } from './types/AnamPublicClientOptions';
|
|
4
|
-
import { SavedPersonaConfig } from './types/PersonaConfig';
|
|
5
4
|
/**
|
|
6
5
|
* Create a new Anam client.
|
|
7
6
|
* @param sessionToken - A session token can be obtained from the Anam API.
|
|
@@ -9,7 +8,7 @@ import { SavedPersonaConfig } from './types/PersonaConfig';
|
|
|
9
8
|
* @param options - Additional options.
|
|
10
9
|
* @returns A new Anam client instance.
|
|
11
10
|
*/
|
|
12
|
-
declare const createClient: (sessionToken: string,
|
|
11
|
+
declare const createClient: (sessionToken: string, options?: AnamPublicClientOptions) => AnamClient;
|
|
13
12
|
/**
|
|
14
13
|
* Create a new Anam client with an API key instead of a session token.
|
|
15
14
|
* This method is unsafe for production environments because it requires exposing your API key to the client side.
|
package/dist/main/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,iBACF,MAAM,YACV,uBAAuB,KAChC,UAEF,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,6BAA6B,WACzB,MAAM,iBACC,aAAa,YAClB,uBAAuB,KAChC,UAEF,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,6BAA6B,EAAE,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/main/index.js
CHANGED
|
@@ -26,8 +26,8 @@ const AnamClient_1 = __importDefault(require("./AnamClient"));
|
|
|
26
26
|
* @param options - Additional options.
|
|
27
27
|
* @returns A new Anam client instance.
|
|
28
28
|
*/
|
|
29
|
-
const createClient = (sessionToken,
|
|
30
|
-
return new AnamClient_1.default(sessionToken,
|
|
29
|
+
const createClient = (sessionToken, options) => {
|
|
30
|
+
return new AnamClient_1.default(sessionToken, undefined, options);
|
|
31
31
|
};
|
|
32
32
|
exports.createClient = createClient;
|
|
33
33
|
/**
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,8DAAsC;AAItC;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,CACnB,YAAoB,EACpB,OAAiC,EACrB,EAAE;IACd,OAAO,IAAI,oBAAU,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC,CAAC;AAmBO,oCAAY;AAjBrB;;;;;;;;GAQG;AACH,MAAM,6BAA6B,GAAG,CACpC,MAAc,EACd,aAA4B,EAC5B,OAAiC,EACrB,EAAE;IACd,OAAO,IAAI,oBAAU,CAAC,SAAS,EAAE,aAAa,kCAAO,OAAO,KAAE,MAAM,IAAG,CAAC;AAC1E,CAAC,CAAC;AAEqB,sEAA6B;AAEpD,0CAAwB"}
|
|
@@ -14,6 +14,6 @@ exports.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE = 'CONNECTIO
|
|
|
14
14
|
exports.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE = 'CONNECTION_CLOSED_CODE_WEBRTC_FAILURE';
|
|
15
15
|
exports.CLIENT_METADATA = {
|
|
16
16
|
client: 'js-sdk',
|
|
17
|
-
version: '
|
|
17
|
+
version: '3.0.0',
|
|
18
18
|
};
|
|
19
19
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { CoreApiRestClientOptions } from '../types';
|
|
2
2
|
import { VoiceDetectionOptions } from './VoiceDetectionOptions';
|
|
3
|
+
import { PersonaConfig } from './PersonaConfig';
|
|
3
4
|
export interface AnamPublicClientOptions {
|
|
4
5
|
api?: CoreApiRestClientOptions;
|
|
5
6
|
voiceDetection?: VoiceDetectionOptions;
|
|
6
7
|
audioDeviceId?: string;
|
|
7
8
|
disableInputAudio?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The persona configuration to use.
|
|
11
|
+
* This is the recommended way to pass persona configuration instead of using the deprecated personaConfig parameter.
|
|
12
|
+
*/
|
|
13
|
+
personaConfig?: PersonaConfig;
|
|
8
14
|
}
|
|
9
15
|
//# sourceMappingURL=AnamPublicClientOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnamPublicClientOptions.d.ts","sourceRoot":"","sources":["../../../src/types/AnamPublicClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"AnamPublicClientOptions.d.ts","sourceRoot":"","sources":["../../../src/types/AnamPublicClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,wBAAwB,CAAC;IAC/B,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export type PersonaConfig =
|
|
2
|
-
export interface SavedPersonaConfig {
|
|
3
|
-
personaId: string;
|
|
4
|
-
disableBrains?: boolean;
|
|
5
|
-
disableFillerPhrases?: boolean;
|
|
6
|
-
}
|
|
1
|
+
export type PersonaConfig = CustomPersonaConfig;
|
|
7
2
|
export interface CustomPersonaConfig {
|
|
3
|
+
personaId: string;
|
|
8
4
|
name: string;
|
|
9
5
|
avatarId: string;
|
|
10
6
|
voiceId: string;
|
|
@@ -13,6 +9,5 @@ export interface CustomPersonaConfig {
|
|
|
13
9
|
maxSessionLengthSeconds?: number;
|
|
14
10
|
languageCode?: string;
|
|
15
11
|
}
|
|
16
|
-
export declare function isSavedPersonaConfig(personaConfig: PersonaConfig): personaConfig is SavedPersonaConfig;
|
|
17
12
|
export declare function isCustomPersonaConfig(personaConfig: PersonaConfig): personaConfig is CustomPersonaConfig;
|
|
18
13
|
//# sourceMappingURL=PersonaConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonaConfig.d.ts","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"PersonaConfig.d.ts","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,mBAAmB,CAEtC"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isCustomPersonaConfig =
|
|
4
|
-
function isSavedPersonaConfig(personaConfig) {
|
|
5
|
-
return 'personaId' in personaConfig;
|
|
6
|
-
}
|
|
7
|
-
exports.isSavedPersonaConfig = isSavedPersonaConfig;
|
|
3
|
+
exports.isCustomPersonaConfig = void 0;
|
|
8
4
|
function isCustomPersonaConfig(personaConfig) {
|
|
9
5
|
return 'brainType' in personaConfig;
|
|
10
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonaConfig.js","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PersonaConfig.js","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":";;;AAaA,SAAgB,qBAAqB,CACnC,aAA4B;IAE5B,OAAO,WAAW,IAAI,aAAa,CAAC;AACtC,CAAC;AAJD,sDAIC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnamClient.d.ts","sourceRoot":"","sources":["../../src/AnamClient.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,eAAe,EACf,aAAa,EAGd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,oBAAoB,CAAuB;IAEnD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAuB;IAE5D,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,aAAa,CAAgC;IACrD,OAAO,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GACpC,OAAO,CAAC,WAAW,EAAE,CAAC;IAyCzB;;OAEG;IACU,6BAA6B,CACxC,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,WAAW,GACpC,OAAO,CAAC,IAAI,CAAC;IAOH,oBAAoB,CAC/B,cAAc,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,WAAW,GACpC,OAAO,CAAC,IAAI,CAAC;IAoCH,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe1C,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAQhC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAUpC,WAAW,IAAI,OAAO;IAItB,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI;IAIpD,gBAAgB,IAAI,aAAa,GAAG,SAAS;IAI7C,kBAAkB,IAAI,eAAe;IAYrC,cAAc,IAAI,eAAe;IAiBjC,gBAAgB,IAAI,eAAe;IAiBnC,uBAAuB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,iBAAiB;IAezE;;OAEG;IACI,WAAW,CAAC,CAAC,SAAS,SAAS,EACpC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAC1B,IAAI;IAIA,cAAc,CAAC,CAAC,SAAS,SAAS,EACvC,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAC1B,IAAI;IAIA,kBAAkB,IAAI,MAAM,GAAG,IAAI;CAG3C"}
|
|
@@ -60,9 +60,7 @@ export default class AnamClient {
|
|
|
60
60
|
setCurrentSessionInfo(this.sessionId, this.organizationId);
|
|
61
61
|
const tokenType = (_a = decodedToken.type) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
62
62
|
if (tokenType === 'legacy') {
|
|
63
|
-
|
|
64
|
-
return 'Both session token and client are missing a persona configuration. Please provide a persona ID of a saved persona in the personaConfig parameter.';
|
|
65
|
-
}
|
|
63
|
+
return 'Legacy session tokens are no longer supported. Please define your persona when creating your session token. See https://docs.anam.ai/resources/migrating-legacy for more information.';
|
|
66
64
|
}
|
|
67
65
|
else if (tokenType === 'ephemeral' || tokenType === 'stateful') {
|
|
68
66
|
if (personaConfig) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnamClient.js","sourceRoot":"","sources":["../../src/AnamClient.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,6BAA6B,EAC7B,SAAS,EACT,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,SAAS,GAMV,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,OAAO,OAAO,UAAU;IAkB7B,YACE,YAAgC,EAChC,aAA6B,EAC7B,OAA2B;;QAbrB,oBAAe,GAAoB,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAEtD,cAAS,GAAkB,IAAI,CAAC;QAChC,mBAAc,GAAkB,IAAI,CAAC;QAErC,oBAAe,GAA2B,IAAI,CAAC;QAG/C,iBAAY,GAAG,KAAK,CAAC;QAO3B,MAAM,WAAW,GAAuB,IAAI,CAAC,oBAAoB,CAC/D,YAAY,EACZ,aAAa,EACb,OAAO,CACR,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,IAAI,WAAW,CACnB,WAAW,EACX,SAAS,CAAC,qCAAqC,EAC/C,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAE7B,IAAI,CAAA,M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2B;QAE3B,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACvD,CAAC;IAEM,cAAc,CACnB,KAAQ,EACR,QAA2B;QAE3B,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAEM,kBAAkB;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF"}
|
package/dist/module/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import AnamClient from './AnamClient';
|
|
2
2
|
import { PersonaConfig } from './types';
|
|
3
3
|
import { AnamPublicClientOptions } from './types/AnamPublicClientOptions';
|
|
4
|
-
import { SavedPersonaConfig } from './types/PersonaConfig';
|
|
5
4
|
/**
|
|
6
5
|
* Create a new Anam client.
|
|
7
6
|
* @param sessionToken - A session token can be obtained from the Anam API.
|
|
@@ -9,7 +8,7 @@ import { SavedPersonaConfig } from './types/PersonaConfig';
|
|
|
9
8
|
* @param options - Additional options.
|
|
10
9
|
* @returns A new Anam client instance.
|
|
11
10
|
*/
|
|
12
|
-
declare const createClient: (sessionToken: string,
|
|
11
|
+
declare const createClient: (sessionToken: string, options?: AnamPublicClientOptions) => AnamClient;
|
|
13
12
|
/**
|
|
14
13
|
* Create a new Anam client with an API key instead of a session token.
|
|
15
14
|
* This method is unsafe for production environments because it requires exposing your API key to the client side.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAE1E;;;;;;GAMG;AACH,QAAA,MAAM,YAAY,iBACF,MAAM,YACV,uBAAuB,KAChC,UAEF,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,6BAA6B,WACzB,MAAM,iBACC,aAAa,YAClB,uBAAuB,KAChC,UAEF,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,6BAA6B,EAAE,CAAC;AACvD,YAAY,EAAE,UAAU,EAAE,CAAC;AAC3B,cAAc,SAAS,CAAC"}
|
package/dist/module/index.js
CHANGED
|
@@ -6,8 +6,8 @@ import AnamClient from './AnamClient';
|
|
|
6
6
|
* @param options - Additional options.
|
|
7
7
|
* @returns A new Anam client instance.
|
|
8
8
|
*/
|
|
9
|
-
const createClient = (sessionToken,
|
|
10
|
-
return new AnamClient(sessionToken,
|
|
9
|
+
const createClient = (sessionToken, options) => {
|
|
10
|
+
return new AnamClient(sessionToken, undefined, options);
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Create a new Anam client with an API key instead of a session token.
|
package/dist/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AAItC;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,CACnB,YAAoB,EACpB,OAAiC,EACrB,EAAE;IACd,OAAO,IAAI,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,6BAA6B,GAAG,CACpC,MAAc,EACd,aAA4B,EAC5B,OAAiC,EACrB,EAAE;IACd,OAAO,IAAI,UAAU,CAAC,SAAS,EAAE,aAAa,kCAAO,OAAO,KAAE,MAAM,IAAG,CAAC;AAC1E,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,6BAA6B,EAAE,CAAC;AAEvD,cAAc,SAAS,CAAC"}
|
|
@@ -11,6 +11,6 @@ export const CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE = 'CONN
|
|
|
11
11
|
export const CONNECTION_CLOSED_CODE_WEBRTC_FAILURE = 'CONNECTION_CLOSED_CODE_WEBRTC_FAILURE';
|
|
12
12
|
export const CLIENT_METADATA = {
|
|
13
13
|
client: 'js-sdk',
|
|
14
|
-
version: '
|
|
14
|
+
version: '3.0.0',
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { CoreApiRestClientOptions } from '../types';
|
|
2
2
|
import { VoiceDetectionOptions } from './VoiceDetectionOptions';
|
|
3
|
+
import { PersonaConfig } from './PersonaConfig';
|
|
3
4
|
export interface AnamPublicClientOptions {
|
|
4
5
|
api?: CoreApiRestClientOptions;
|
|
5
6
|
voiceDetection?: VoiceDetectionOptions;
|
|
6
7
|
audioDeviceId?: string;
|
|
7
8
|
disableInputAudio?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* The persona configuration to use.
|
|
11
|
+
* This is the recommended way to pass persona configuration instead of using the deprecated personaConfig parameter.
|
|
12
|
+
*/
|
|
13
|
+
personaConfig?: PersonaConfig;
|
|
8
14
|
}
|
|
9
15
|
//# sourceMappingURL=AnamPublicClientOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnamPublicClientOptions.d.ts","sourceRoot":"","sources":["../../../src/types/AnamPublicClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"AnamPublicClientOptions.d.ts","sourceRoot":"","sources":["../../../src/types/AnamPublicClientOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,uBAAuB;IACtC,GAAG,CAAC,EAAE,wBAAwB,CAAC;IAC/B,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
export type PersonaConfig =
|
|
2
|
-
export interface SavedPersonaConfig {
|
|
3
|
-
personaId: string;
|
|
4
|
-
disableBrains?: boolean;
|
|
5
|
-
disableFillerPhrases?: boolean;
|
|
6
|
-
}
|
|
1
|
+
export type PersonaConfig = CustomPersonaConfig;
|
|
7
2
|
export interface CustomPersonaConfig {
|
|
3
|
+
personaId: string;
|
|
8
4
|
name: string;
|
|
9
5
|
avatarId: string;
|
|
10
6
|
voiceId: string;
|
|
@@ -13,6 +9,5 @@ export interface CustomPersonaConfig {
|
|
|
13
9
|
maxSessionLengthSeconds?: number;
|
|
14
10
|
languageCode?: string;
|
|
15
11
|
}
|
|
16
|
-
export declare function isSavedPersonaConfig(personaConfig: PersonaConfig): personaConfig is SavedPersonaConfig;
|
|
17
12
|
export declare function isCustomPersonaConfig(personaConfig: PersonaConfig): personaConfig is CustomPersonaConfig;
|
|
18
13
|
//# sourceMappingURL=PersonaConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonaConfig.d.ts","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"PersonaConfig.d.ts","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,mBAAmB,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,mBAAmB,CAEtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersonaConfig.js","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PersonaConfig.js","sourceRoot":"","sources":["../../../src/types/PersonaConfig.ts"],"names":[],"mappings":"AAaA,MAAM,UAAU,qBAAqB,CACnC,aAA4B;IAE5B,OAAO,WAAW,IAAI,aAAa,CAAC;AACtC,CAAC"}
|
package/dist/umd/anam.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see anam.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.anam=e():t.anam=e()}(self,(()=>{return t={526:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,o=a(t),s=o[0],u=o[1],l=new r(function(t,e,n){return 3*(e+n)/4-n}(0,s,u)),c=0,h=u>0?s-4:s;for(n=0;n<h;n+=4)e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,l[c++]=255&e),1===u&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,o=[],s=16383,a=0,l=i-r;a<l;a+=s)o.push(u(t,a,a+s>l?l:a+s));return 1===r?(e=t[i-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],i[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function u(t,e,i){for(var r,o,s=[],a=e;a<i;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=r)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},287:(t,e,n)=>{"use strict";const i=n(526),r=n(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return l(t,e,n)}function l(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|p(t,e);let i=a(n);const r=i.write(t,e);return r!==n&&(i=i.slice(0,r)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return u.from(i,e,n);const r=function(t){if(u.isBuffer(t)){const e=0|E(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?a(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return c(t),a(t<0?0:0|E(t))}function d(t){const e=t.length<0?0:0|E(t.length),n=a(e);for(let i=0;i<e;i+=1)n[i]=255&t[i];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(i,u.prototype),i}function E(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function p(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return K(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(t).length;default:if(r)return i?-1:K(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return w(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return b(this,e,n);case"latin1":case"binary":return N(this,e,n);case"base64":return R(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function C(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function S(t,e,n,i,r){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:m(t,e,n,i,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,i,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,i,r){let o,s=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(r){let i=-1;for(o=n;o<a;o++)if(l(t,o)===l(e,-1===i?0:o-i)){if(-1===i&&(i=o),o-i+1===u)return i*s}else-1!==i&&(o-=o-i),i=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let i=0;i<u;i++)if(l(t,o+i)!==l(e,i)){n=!1;break}if(n)return o}return-1}function v(t,e,n,i){n=Number(n)||0;const r=t.length-n;i?(i=Number(i))>r&&(i=r):i=r;const o=e.length;let s;for(i>o/2&&(i=o/2),s=0;s<i;++s){const i=parseInt(e.substr(2*s,2),16);if(q(i))return s;t[n+s]=i}return s}function _(t,e,n,i){return Y(K(e,t.length-n),t,n,i)}function A(t,e,n,i){return Y(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,i)}function I(t,e,n,i){return Y(z(e),t,n,i)}function y(t,e,n,i){return Y(function(t,e){let n,i,r;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),i=n>>8,r=n%256,o.push(r),o.push(i);return o}(e,t.length-n),t,n,i)}function R(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const i=[];let r=e;for(;r<n;){const e=t[r];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(r+s<=n){let n,i,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[r+1],128==(192&n)&&(u=(31&e)<<6|63&n,u>127&&(o=u));break;case 3:n=t[r+1],i=t[r+2],128==(192&n)&&128==(192&i)&&(u=(15&e)<<12|(63&n)<<6|63&i,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=t[r+1],i=t[r+2],a=t[r+3],128==(192&n)&&128==(192&i)&&128==(192&a)&&(u=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),r+=s}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let n="",i=0;for(;i<e;)n+=String.fromCharCode.apply(String,t.slice(i,i+=T));return n}(i)}e.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,n){return l(t,e,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,n){return function(t,e,n){return c(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},u.allocUnsafe=function(t){return h(t)},u.allocUnsafeSlow=function(t){return h(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let r=0,o=Math.min(n,i);r<o;++r)if(t[r]!==e[r]){n=t[r],i=e[r];break}return n<i?-1:i<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const i=u.allocUnsafe(e);let r=0;for(n=0;n<t.length;++n){let e=t[n];if(J(e,Uint8Array))r+e.length>i.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(i,r)):Uint8Array.prototype.set.call(i,e,r);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,r)}r+=e.length}return i},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)C(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)C(this,e,e+3),C(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)C(this,e,e+7),C(this,e+1,e+6),C(this,e+2,e+5),C(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,n,i,r){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),e<0||n>t.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&e>=n)return 0;if(i>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(r>>>=0)-(i>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(o,s),l=this.slice(i,r),c=t.slice(e,n);for(let t=0;t<a;++t)if(l[t]!==c[t]){o=l[t],s=c[t];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return S(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return S(this,t,e,n,!1)},u.prototype.write=function(t,e,n,i){if(void 0===e)i="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)i=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-e;if((void 0===n||n>r)&&(n=r),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":case"latin1":case"binary":return A(this,t,e,n);case"base64":return I(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function b(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;r<n;++r)i+=String.fromCharCode(127&t[r]);return i}function N(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;r<n;++r)i+=String.fromCharCode(t[r]);return i}function w(t,e,n){const i=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>i)&&(n=i);let r="";for(let i=e;i<n;++i)r+=X[t[i]];return r}function M(t,e,n){const i=t.slice(e,n);let r="";for(let t=0;t<i.length-1;t+=2)r+=String.fromCharCode(i[t]+256*i[t+1]);return r}function D(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,n,i,r,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(n+i>t.length)throw new RangeError("Index out of range")}function U(t,e,n,i,r){G(e,i,r,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function B(t,e,n,i,r){G(e,i,r,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function P(t,e,n,i,r,o){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function k(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function j(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}u.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,u.prototype),i},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=this[t],r=1,o=0;for(;++o<e&&(r*=256);)i+=this[t+o]*r;return i},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=this[t+--e],r=1;for(;e>0&&(r*=256);)i+=this[t+--e]*r;return i},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||D(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||D(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||D(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||D(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||D(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(r)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<<BigInt(32))+BigInt(r)})),u.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=this[t],r=1,o=0;for(;++o<e&&(r*=256);)i+=this[t+o]*r;return r*=128,i>=r&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=e,r=1,o=this[t+--i];for(;i>0&&(r*=256);)o+=this[t+--i]*r;return r*=128,o>=r&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||D(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||D(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){t>>>=0,e||D(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||D(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||D(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||D(t,4,this.length),r.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||D(t,4,this.length),r.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||D(t,8,this.length),r.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||D(t,8,this.length),r.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||L(this,t,e,n,Math.pow(2,8*n)-1,0);let r=1,o=0;for(this[e]=255&t;++o<n&&(r*=256);)this[e+o]=t/r&255;return e+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||L(this,t,e,n,Math.pow(2,8*n)-1,0);let r=n-1,o=1;for(this[e+r]=255&t;--r>=0&&(o*=256);)this[e+r]=t/o&255;return e+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}let r=0,o=1,s=0;for(this[e]=255&t;++r<n&&(o*=256);)t<0&&0===s&&0!==this[e+r-1]&&(s=1),this[e+r]=(t/o|0)-s&255;return e+n},u.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}let r=n-1,o=1,s=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===s&&0!==this[e+r+1]&&(s=1),this[e+r]=(t/o|0)-s&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,n){return k(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return k(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return j(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return j(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,i){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);const r=i-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),r},u.prototype.fill=function(t,e,n,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let r;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r<n;++r)this[r]=t;else{const o=u.isBuffer(t)?t:u.from(t,i),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<n-e;++r)this[r+e]=o[r%s]}return this};const F={};function x(t,e,n){F[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function V(t){let e="",n=t.length;const i="-"===t[0]?1:0;for(;n>=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function G(t,e,n,i,r,o){if(t>n||t<e){const i="bigint"==typeof e?"n":"";let r;throw r=o>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new F.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,n){$(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||H(e,t.length-(n+1))}(i,r,o)}function $(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,n){if(Math.floor(t)!==t)throw $(t,n),new F.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}x("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),x("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),x("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=V(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),i+=` It must be ${e}. Received ${r}`,i}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function K(t,e){let n;e=e||1/0;const i=t.length;let r=null;const o=[];for(let s=0;s<i;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(e-=3)>-1&&o.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function z(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,n,i){let r;for(r=0;r<i&&!(r+n>=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)e[i+r]=t[n]+t[r]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251:(t,e)=>{e.read=function(t,e,n,i,r){var o,s,a=8*r-i-1,u=(1<<a)-1,l=u>>1,c=-7,h=n?r-1:0,d=n?-1:1,f=t[e+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=256*o+t[e+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=256*s+t[e+h],h+=d,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,i),o-=l}return(f?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,n,i,r,o){var s,a,u,l=8*o-r-1,c=(1<<l)-1,h=c>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,E=i?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,r),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;t[n+f]=255&a,f+=E,a/=256,r-=8);for(s=s<<r|a,l+=r;l>0;t[n+f]=255&s,f+=E,s/=256,l-=8);t[n+f-E]|=128*p}},816:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const r=n(71),o=n(958),s=n(170),a=n(287);e.default=class{constructor(t,e,n){var i,s;this.inputAudioState={isMuted:!1},this.sessionId=null,this.organizationId=null,this.streamingClient=null,this._isStreaming=!1;const a=this.validateClientConfig(t,e,n);if(a)throw new r.ClientError(a,r.ErrorCode.CLIENT_ERROR_CODE_CONFIGURATION_ERROR,400);this.personaConfig=e,this.clientOptions=n,((null===(i=null==n?void 0:n.api)||void 0===i?void 0:i.baseUrl)||(null===(s=null==n?void 0:n.api)||void 0===s?void 0:s.apiVersion))&&(0,r.setErrorMetricsBaseUrl)(n.api.baseUrl||r.DEFAULT_ANAM_METRICS_BASE_URL,n.api.apiVersion||r.DEFAULT_ANAM_API_VERSION),this.publicEventEmitter=new o.PublicEventEmitter,this.internalEventEmitter=new o.InternalEventEmitter,this.apiClient=new o.CoreApiRestClient(t,null==n?void 0:n.apiKey,null==n?void 0:n.api),this.messageHistoryClient=new o.MessageHistoryClient(this.publicEventEmitter,this.internalEventEmitter)}decodeJwt(t){try{const e=t.split(".")[1],n=a.Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch(t){throw new Error("Invalid session token format")}}validateClientConfig(t,e,n){var i;if(!t&&!(null==n?void 0:n.apiKey))return"Either sessionToken or apiKey must be provided";if((null==n?void 0:n.apiKey)&&t)return"Only one of sessionToken or apiKey should be used";if(t){const n=this.decodeJwt(t);this.organizationId=n.accountId,(0,r.setCurrentSessionInfo)(this.sessionId,this.organizationId);const o=null===(i=n.type)||void 0===i?void 0:i.toLowerCase();if("legacy"===o){if(!e||!("personaId"in e))return"Both session token and client are missing a persona configuration. Please provide a persona ID of a saved persona in the personaConfig parameter."}else if(("ephemeral"===o||"stateful"===o)&&e)return"This session token already contains a persona configuration. Please remove the personaConfig parameter."}else if(!e)return"Missing persona config. Persona configuration must be provided when using apiKey";if(null==n?void 0:n.voiceDetection){if(n.disableInputAudio)return"Voice detection is disabled because input audio is disabled. Please set disableInputAudio to false to enable voice detection.";if(void 0!==n.voiceDetection.endOfSpeechSensitivity){if("number"!=typeof n.voiceDetection.endOfSpeechSensitivity)return"End of speech sensitivity must be a number";if(n.voiceDetection.endOfSpeechSensitivity<0||n.voiceDetection.endOfSpeechSensitivity>1)return"End of speech sensitivity must be between 0 and 1"}}}buildStartSessionOptionsForClient(){var t;const e={};if((null===(t=this.clientOptions)||void 0===t?void 0:t.voiceDetection)&&(e.voiceDetection=this.clientOptions.voiceDetection),0!==Object.keys(e).length)return e}startSession(t){return i(this,void 0,void 0,(function*(){var e,n,i;const s=this.personaConfig,a=this.buildStartSessionOptionsForClient(),u=yield this.apiClient.startSession(s,a),{sessionId:l,clientConfig:c,engineHost:h,engineProtocol:d,signallingEndpoint:f}=u,{heartbeatIntervalSeconds:E,maxWsReconnectionAttempts:p,iceServers:g}=c;try{this.streamingClient=new o.StreamingClient(l,{engine:{baseUrl:`${d}://${h}`},signalling:{heartbeatIntervalSeconds:E,maxWsReconnectionAttempts:p,url:{baseUrl:h,protocol:d,signallingPath:f}},iceServers:g,inputAudio:{inputAudioState:this.inputAudioState,userProvidedMediaStream:(null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)?void 0:t,audioDeviceId:null===(n=this.clientOptions)||void 0===n?void 0:n.audioDeviceId,disableInputAudio:null===(i=this.clientOptions)||void 0===i?void 0:i.disableInputAudio}},this.publicEventEmitter,this.internalEventEmitter)}catch(t){throw new r.ClientError("Failed to initialize streaming client",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:t instanceof Error?t.message:String(t),sessionId:l})}return this.sessionId=l,(0,r.setCurrentSessionInfo)(this.sessionId,this.organizationId),l}))}startSessionIfNeeded(t){return i(this,void 0,void 0,(function*(){if(!(this.sessionId&&this.streamingClient||(yield this.startSession(t),this.sessionId&&this.streamingClient)))throw new r.ClientError("Session ID or streaming client is not available after starting session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:"Failed to initialize session properly"})}))}stream(t){return i(this,void 0,void 0,(function*(){var e;if((null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)&&t&&console.warn("AnamClient:Input audio is disabled. User provided audio stream will be ignored."),yield this.startSessionIfNeeded(t),this._isStreaming)throw new Error("Already streaming");return this._isStreaming=!0,new Promise((t=>{var e;const n=[];let i=!1,r=!1;this.publicEventEmitter.addListener(s.AnamEvent.VIDEO_STREAM_STARTED,(e=>{n.push(e),i=!0,r&&t(n)})),this.publicEventEmitter.addListener(s.AnamEvent.AUDIO_STREAM_STARTED,(e=>{n.push(e),r=!0,i&&t(n)})),null===(e=this.streamingClient)||void 0===e||e.startConnection()}))}))}streamToVideoAndAudioElements(t,e,n){return i(this,void 0,void 0,(function*(){console.warn("AnamClient: streamToVideoAndAudioElements is deprecated. To avoid possible audio issues, please use streamToVideoElement instead."),yield this.streamToVideoElement(t,n)}))}streamToVideoElement(t,e){return i(this,void 0,void 0,(function*(){var n;(null===(n=this.clientOptions)||void 0===n?void 0:n.disableInputAudio)&&e&&console.warn("AnamClient:Input audio is disabled. User provided audio stream will be ignored.");try{yield this.startSessionIfNeeded(e)}catch(t){if(t instanceof r.ClientError)throw t;throw new r.ClientError("Failed to start session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:t instanceof Error?t.message:String(t),sessionId:this.sessionId})}if(this._isStreaming)throw new Error("Already streaming");if(this._isStreaming=!0,!this.streamingClient)throw new Error("Failed to stream: streaming client is not available");this.streamingClient.setMediaStreamTargetById(t),this.streamingClient.startConnection()}))}talk(t){return i(this,void 0,void 0,(function*(){if(!this.streamingClient)throw new Error("Failed to send talk command: session is not started. Have you called startSession?");if(!this._isStreaming)throw new Error("Failed to send talk command: not currently streaming. Have you called stream?");yield this.streamingClient.sendTalkCommand(t)}))}sendDataMessage(t){if(!this.streamingClient)throw new Error("Failed to send message: session is not started.");this.streamingClient.sendDataMessage(t)}stopStreaming(){return i(this,void 0,void 0,(function*(){this.streamingClient&&(this.streamingClient.stopConnection(),this.streamingClient=null,this.sessionId=null,(0,r.setCurrentSessionInfo)(null,this.organizationId),this._isStreaming=!1)}))}isStreaming(){return this._isStreaming}setPersonaConfig(t){this.personaConfig=t}getPersonaConfig(){return this.personaConfig}getInputAudioState(){var t;return(null===(t=this.clientOptions)||void 0===t?void 0:t.disableInputAudio)&&console.warn("AnamClient: Audio state will not be used because input audio is disabled."),this.streamingClient&&(this.inputAudioState=this.streamingClient.getInputAudioState()),this.inputAudioState}muteInputAudio(){var t,e;return(null===(t=this.clientOptions)||void 0===t?void 0:t.disableInputAudio)&&console.warn("AnamClient: Input audio is disabled. Muting input audio will have no effect."),this.streamingClient&&!(null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)?this.inputAudioState=this.streamingClient.muteInputAudio():this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!0}),this.inputAudioState}unmuteInputAudio(){var t,e;return(null===(t=this.clientOptions)||void 0===t?void 0:t.disableInputAudio)&&console.warn("AnamClient: Input audio is disabled. Unmuting input audio will have no effect."),this.streamingClient&&!(null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)?this.inputAudioState=this.streamingClient.unmuteInputAudio():this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!1}),this.inputAudioState}createTalkMessageStream(t){if(!this.streamingClient)throw new Error("Failed to start talk message stream: session is not started.");if(t&&""===t.trim())throw new Error("Failed to start talk message stream: correlationId is empty");return this.streamingClient.startTalkMessageStream(t)}addListener(t,e){this.publicEventEmitter.addListener(t,e)}removeListener(t,e){this.publicEventEmitter.removeListener(t,e)}getActiveSessionId(){return this.sessionId}}},440:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.unsafe_createClientWithApiKey=e.createClient=void 0;const s=o(n(816));e.createClient=(t,e,n)=>new s.default(t,e,n),e.unsafe_createClientWithApiKey=(t,e,n)=>new s.default(void 0,e,Object.assign(Object.assign({},n),{apiKey:t})),r(n(170),e)},71:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.ClientError=e.sendErrorMetric=e.setCurrentSessionInfo=e.setErrorMetricsBaseUrl=e.ClientMetricMeasurement=e.DEFAULT_ANAM_API_VERSION=e.DEFAULT_ANAM_METRICS_BASE_URL=e.ErrorCode=void 0;const r=n(985);var o,s;!function(t){t.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED="CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED",t.CLIENT_ERROR_CODE_VALIDATION_ERROR="CLIENT_ERROR_CODE_VALIDATION_ERROR",t.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR="CLIENT_ERROR_CODE_AUTHENTICATION_ERROR",t.CLIENT_ERROR_CODE_SERVER_ERROR="CLIENT_ERROR_CODE_SERVER_ERROR",t.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED="CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED",t.CLIENT_ERROR_CODE_SERVICE_BUSY="CLIENT_ERROR_CODE_SERVICE_BUSY",t.CLIENT_ERROR_CODE_NO_PLAN_FOUND="CLIENT_ERROR_CODE_NO_PLAN_FOUND",t.CLIENT_ERROR_CODE_UNKNOWN_ERROR="CLIENT_ERROR_CODE_UNKNOWN_ERROR",t.CLIENT_ERROR_CODE_CONFIGURATION_ERROR="CLIENT_ERROR_CODE_CONFIGURATION_ERROR"}(o||(e.ErrorCode=o={})),e.DEFAULT_ANAM_METRICS_BASE_URL="https://api.anam.ai",e.DEFAULT_ANAM_API_VERSION="/v1",function(t){t.CLIENT_METRIC_MEASUREMENT_ERROR="client_error",t.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED="client_connection_closed",t.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED="client_connection_established"}(s||(e.ClientMetricMeasurement=s={}));let a=e.DEFAULT_ANAM_METRICS_BASE_URL,u=e.DEFAULT_ANAM_API_VERSION,l=null,c=null;e.setErrorMetricsBaseUrl=(t,n=e.DEFAULT_ANAM_API_VERSION)=>{a=t,u=n},e.setCurrentSessionInfo=(t,e)=>{l=t,c=e},e.sendErrorMetric=(t,e,n)=>i(void 0,void 0,void 0,(function*(){try{const i=Object.assign(Object.assign({},r.CLIENT_METADATA),n);l&&(i.sessionId=l),c&&(i.organizationId=c),yield fetch(`${a}${u}/metrics/client`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,value:e,tags:i})})}catch(t){console.error("Failed to send error metric:",t)}}));class h extends Error{constructor(t,n,i=500,r){super(t),this.name="ClientError",this.code=n,this.statusCode=i,this.details=r,Object.setPrototypeOf(this,h.prototype),(0,e.sendErrorMetric)(s.CLIENT_METRIC_MEASUREMENT_ERROR,n,{details:r,statusCode:i})}}e.ClientError=h},985:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CLIENT_METADATA=e.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE=e.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE=e.CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED=e.CONNECTION_CLOSED_CODE_NORMAL=e.DEFAULT_API_VERSION=e.DEFAULT_API_BASE_URL=e.DEFAULT_HEADERS=void 0,e.DEFAULT_HEADERS={"Content-Type":"application/json"},e.DEFAULT_API_BASE_URL="https://api.anam.ai",e.DEFAULT_API_VERSION="/v1",e.CONNECTION_CLOSED_CODE_NORMAL="CONNECTION_CLOSED_CODE_NORMAL",e.CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED="CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED",e.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE="CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE",e.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE="CONNECTION_CLOSED_CODE_WEBRTC_FAILURE",e.CLIENT_METADATA={client:"js-sdk",version:"2.5.0"}},18:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.CoreApiRestClient=void 0;const r=n(71),o=n(985),s=n(672);e.CoreApiRestClient=class{constructor(t,e,n){if(!t&&!e)throw new Error("Either sessionToken or apiKey must be provided");this.sessionToken=t||null,this.apiKey=e||null,this.baseUrl=(null==n?void 0:n.baseUrl)||o.DEFAULT_API_BASE_URL,this.apiVersion=(null==n?void 0:n.apiVersion)||o.DEFAULT_API_VERSION}startSession(t,e){return i(this,void 0,void 0,(function*(){if(!this.sessionToken){if(!t)throw new r.ClientError("Persona configuration must be provided when using apiKey",r.ErrorCode.CLIENT_ERROR_CODE_VALIDATION_ERROR,400);this.sessionToken=yield this.unsafe_getSessionToken(t)}try{const n=yield fetch(`${this.getApiUrl()}/engine/session`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({personaConfig:t,sessionOptions:e,clientMetadata:o.CLIENT_METADATA})}),i=yield n.json();switch(n.status){case 200:case 201:return i;case 400:throw new r.ClientError("Invalid request to start session",r.ErrorCode.CLIENT_ERROR_CODE_VALIDATION_ERROR,400,{cause:i.message});case 401:throw new r.ClientError("Authentication failed when starting session",r.ErrorCode.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR,401,{cause:i.message});case 402:throw new r.ClientError("Please sign up for a plan to start a session",r.ErrorCode.CLIENT_ERROR_CODE_NO_PLAN_FOUND,402,{cause:i.message});case 403:throw new r.ClientError("Authentication failed when starting session",r.ErrorCode.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR,403,{cause:i.message});case 429:throw new r.ClientError("Out of credits, please upgrade your plan",r.ErrorCode.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED,429,{cause:i.message});case 503:throw new r.ClientError("There are no available personas, please try again later",r.ErrorCode.CLIENT_ERROR_CODE_SERVICE_BUSY,503,{cause:i.message});default:throw new r.ClientError("Unknown error when starting session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:i.message})}}catch(t){if(t instanceof r.ClientError)throw t;throw new r.ClientError("Failed to start session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:t instanceof Error?t.message:String(t)})}}))}unsafe_getSessionToken(t){return i(this,void 0,void 0,(function*(){if(console.warn("Using unsecure method. This method should not be used in production."),!this.apiKey)throw new Error("No apiKey provided");let e={clientLabel:"js-sdk-api-key"};(0,s.isCustomPersonaConfig)(t)&&(e=Object.assign(Object.assign({},e),{personaConfig:t}));try{const t=yield fetch(`${this.getApiUrl()}/auth/session-token`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(e)});return(yield t.json()).sessionToken}catch(t){throw new Error("Failed to get session token")}}))}getApiUrl(){return`${this.baseUrl}${this.apiVersion}`}}},529:function(t,e){"use strict";var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.EngineApiRestClient=void 0,e.EngineApiRestClient=class{constructor(t,e){this.baseUrl=t,this.sessionId=e}sendTalkCommand(t){return n(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.baseUrl}/talk?session_id=${this.sessionId}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!e.ok)throw new Error(`Failed to send talk command: ${e.status} ${e.statusText}`)}catch(t){throw console.error(t),new Error("EngineApiRestClient - sendTalkCommand: Failed to send talk command")}}))}}},259:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEventEmitter=void 0,e.InternalEventEmitter=class{constructor(){this.listeners={}}addListener(t,e){this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e)}removeListener(t,e){this.listeners[t]&&this.listeners[t].delete(e)}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach((t=>{t(...e)}))}}},462:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MessageHistoryClient=void 0;const i=n(170);e.MessageHistoryClient=class{constructor(t,e){this.messages=[],this.publicEventEmitter=t,this.internalEventEmitter=e,this.internalEventEmitter.addListener(i.InternalEvent.WEBRTC_CHAT_MESSAGE_RECEIVED,this.processWebRtcTextMessageEvent.bind(this))}webRtcTextMessageEventToMessageStreamEvent(t){return{id:`${t.role}::${t.message_id}`,content:t.content,role:t.role,endOfSpeech:t.end_of_speech,interrupted:t.interrupted}}processUserMessage(t){const e={id:t.id,content:t.content,role:t.role};this.messages.push(e)}processPersonaMessage(t){const e={id:t.id,content:t.content,role:t.role,interrupted:t.interrupted},n=this.messages.findIndex((t=>t.id===e.id));if(-1!==n){const t=this.messages[n];this.messages[n]=Object.assign(Object.assign({},t),{content:t.content+e.content,interrupted:t.interrupted||e.interrupted})}else this.messages.push(e)}processWebRtcTextMessageEvent(t){const e=this.webRtcTextMessageEventToMessageStreamEvent(t);switch(this.publicEventEmitter.emit(i.AnamEvent.MESSAGE_STREAM_EVENT_RECEIVED,e),e.role){case i.MessageRole.USER:this.processUserMessage(e);break;case i.MessageRole.PERSONA:this.processPersonaMessage(e)}e.endOfSpeech&&this.publicEventEmitter.emit(i.AnamEvent.MESSAGE_HISTORY_UPDATED,this.messages)}}},995:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PublicEventEmitter=void 0;const i=n(71),r=n(170);e.PublicEventEmitter=class{constructor(){this.listeners={}}addListener(t,e){this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e)}removeListener(t,e){this.listeners[t]&&this.listeners[t].delete(e)}emit(t,...e){t===r.AnamEvent.CONNECTION_ESTABLISHED&&(0,i.sendErrorMetric)(i.ClientMetricMeasurement.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED,"1"),t===r.AnamEvent.CONNECTION_CLOSED&&(0,i.sendErrorMetric)(i.ClientMetricMeasurement.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED,e[0]),this.listeners[t]&&this.listeners[t].forEach((t=>{t(...e)}))}}},279:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.SignallingClient=void 0;const r=n(985),o=n(170);e.SignallingClient=class{constructor(t,e,n,i){var r;if(this.stopSignal=!1,this.sendingBuffer=[],this.wsConnectionAttempts=0,this.socket=null,this.heartBeatIntervalRef=null,this.publicEventEmitter=n,this.internalEventEmitter=i,!t)throw new Error("Signalling Client: sessionId is required");this.sessionId=t;const{heartbeatIntervalSeconds:o,maxWsReconnectionAttempts:s,url:a}=e;if(this.heartbeatIntervalSeconds=o||5,this.maxWsReconnectionAttempts=s||5,!a.baseUrl)throw new Error("Signalling Client: baseUrl is required");const u=`${a.protocol||"https"}://${a.baseUrl}`;this.url=new URL(u),this.url.protocol="http"===a.protocol?"ws:":"wss:",a.port&&(this.url.port=a.port),this.url.pathname=null!==(r=a.signallingPath)&&void 0!==r?r:"/ws",this.url.searchParams.append("session_id",t)}stop(){this.stopSignal=!0,this.closeSocket()}connect(){return this.socket=new WebSocket(this.url.href),this.socket.onopen=this.onOpen.bind(this),this.socket.onclose=this.onClose.bind(this),this.socket.onerror=this.onError.bind(this),this.socket}sendOffer(t){return i(this,void 0,void 0,(function*(){const e={connectionDescription:t,userUid:this.sessionId},n={actionType:o.SignalMessageAction.OFFER,sessionId:this.sessionId,payload:e};this.sendSignalMessage(n)}))}sendIceCandidate(t){return i(this,void 0,void 0,(function*(){const e={actionType:o.SignalMessageAction.ICE_CANDIDATE,sessionId:this.sessionId,payload:t.toJSON()};this.sendSignalMessage(e)}))}sendSignalMessage(t){var e;if((null===(e=this.socket)||void 0===e?void 0:e.readyState)===WebSocket.OPEN)try{this.socket.send(JSON.stringify(t))}catch(t){console.error("SignallingClient - sendSignalMessage: error sending message",t)}else this.sendingBuffer.push(t)}sendTalkMessage(t){return i(this,void 0,void 0,(function*(){const e={actionType:o.SignalMessageAction.TALK_STREAM_INPUT,sessionId:this.sessionId,payload:t};this.sendSignalMessage(e)}))}closeSocket(){this.socket&&(this.socket.close(),this.socket=null),this.heartBeatIntervalRef&&(clearInterval(this.heartBeatIntervalRef),this.heartBeatIntervalRef=null)}onOpen(){return i(this,void 0,void 0,(function*(){if(!this.socket)throw new Error("SignallingClient - onOpen: socket is null");try{this.wsConnectionAttempts=0,this.flushSendingBuffer(),this.socket.onmessage=this.onMessage.bind(this),this.startSendingHeartBeats(),this.internalEventEmitter.emit(o.InternalEvent.WEB_SOCKET_OPEN)}catch(t){console.error("SignallingClient - onOpen: error in onOpen",t),this.publicEventEmitter.emit(o.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE)}}))}onClose(){return i(this,void 0,void 0,(function*(){this.wsConnectionAttempts+=1,this.stopSignal||(this.wsConnectionAttempts<=this.maxWsReconnectionAttempts?(this.socket=null,setTimeout((()=>{this.connect()}),100*this.wsConnectionAttempts)):(this.heartBeatIntervalRef&&(clearInterval(this.heartBeatIntervalRef),this.heartBeatIntervalRef=null),this.publicEventEmitter.emit(o.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE)))}))}onError(t){this.stopSignal||console.error("SignallingClient - onError: ",t)}flushSendingBuffer(){const t=[];this.sendingBuffer.length>0&&this.sendingBuffer.forEach((e=>{var n;(null===(n=this.socket)||void 0===n?void 0:n.readyState)===WebSocket.OPEN?this.socket.send(JSON.stringify(e)):t.push(e)})),this.sendingBuffer=t}onMessage(t){return i(this,void 0,void 0,(function*(){const e=JSON.parse(t.data);this.internalEventEmitter.emit(o.InternalEvent.SIGNAL_MESSAGE_RECEIVED,e)}))}startSendingHeartBeats(){if(!this.socket)throw new Error("SignallingClient - startSendingHeartBeats: socket is null");this.heartBeatIntervalRef&&console.warn("SignallingClient - startSendingHeartBeats: heartbeat interval already set");const t=1e3*this.heartbeatIntervalSeconds,e={actionType:o.SignalMessageAction.HEARTBEAT,sessionId:this.sessionId,payload:""},n=JSON.stringify(e);this.heartBeatIntervalRef=setInterval((()=>{var t;this.stopSignal||(null===(t=this.socket)||void 0===t?void 0:t.readyState)===WebSocket.OPEN&&this.socket.send(n)}),t)}}},577:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StreamingClient=void 0;const r=n(985),o=n(958),s=n(170),a=n(711);e.StreamingClient=class{constructor(t,e,n,i){this.peerConnection=null,this.connectionReceivedAnswer=!1,this.remoteIceCandidateBuffer=[],this.inputAudioStream=null,this.dataChannel=null,this.videoElement=null,this.videoStream=null,this.audioStream=null,this.inputAudioState={isMuted:!1},this.publicEventEmitter=n,this.internalEventEmitter=i;const{inputAudio:r}=e;this.inputAudioState=r.inputAudioState,e.inputAudio.userProvidedMediaStream&&(this.inputAudioStream=e.inputAudio.userProvidedMediaStream),this.disableInputAudio=!0===e.inputAudio.disableInputAudio,this.internalEventEmitter.addListener(s.InternalEvent.WEB_SOCKET_OPEN,this.onSignallingClientConnected.bind(this)),this.internalEventEmitter.addListener(s.InternalEvent.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this)),this.iceServers=e.iceServers,this.signallingClient=new o.SignallingClient(t,e.signalling,this.publicEventEmitter,this.internalEventEmitter),this.engineApiRestClient=new o.EngineApiRestClient(e.engine.baseUrl,t),this.audioDeviceId=e.inputAudio.audioDeviceId}onInputAudioStateChange(t,e){t.isMuted!==e.isMuted&&(e.isMuted?this.muteAllAudioTracks():this.unmuteAllAudioTracks())}muteAllAudioTracks(){var t;null===(t=this.inputAudioStream)||void 0===t||t.getAudioTracks().forEach((t=>{t.enabled=!1}))}unmuteAllAudioTracks(){var t;null===(t=this.inputAudioStream)||void 0===t||t.getAudioTracks().forEach((t=>{t.enabled=!0}))}muteInputAudio(){const t=this.inputAudioState,e=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!0});return this.inputAudioState=e,this.onInputAudioStateChange(t,e),this.inputAudioState}unmuteInputAudio(){const t=this.inputAudioState,e=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!1});return this.inputAudioState=e,this.onInputAudioStateChange(t,e),this.inputAudioState}getInputAudioState(){return this.inputAudioState}getPeerConnection(){return this.peerConnection}getInputAudioStream(){return this.inputAudioStream}getVideoStream(){return this.videoStream}getAudioStream(){return this.audioStream}sendDataMessage(t){this.dataChannel&&"open"===this.dataChannel.readyState&&this.dataChannel.send(t)}setMediaStreamTargetById(t){if(t){const e=document.getElementById(t);if(!e)throw new Error(`StreamingClient: video element with id ${t} not found`);this.videoElement=e}}startConnection(){try{if(this.peerConnection)return void console.error("StreamingClient - startConnection: peer connection already exists");this.signallingClient.connect()}catch(t){console.log("StreamingClient - startConnection: error",t),this.handleWebrtcFailure(t)}}stopConnection(){this.shutdown()}sendTalkCommand(t){return i(this,void 0,void 0,(function*(){if(!this.peerConnection)throw new Error("StreamingClient - sendTalkCommand: peer connection is null");yield this.engineApiRestClient.sendTalkCommand(t)}))}startTalkMessageStream(t){return t||(t=Math.random().toString(36).substring(2,15)),new a.TalkMessageStream(t,this.internalEventEmitter,this.signallingClient)}initPeerConnection(){return i(this,void 0,void 0,(function*(){this.peerConnection=new RTCPeerConnection({iceServers:this.iceServers}),this.peerConnection.onicecandidate=this.onIceCandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this.onIceConnectionStateChange.bind(this),this.peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this.peerConnection.addEventListener("track",this.onTrackEventHandler.bind(this)),yield this.setupDataChannels(),this.peerConnection.addTransceiver("video",{direction:"recvonly"}),this.disableInputAudio?this.peerConnection.addTransceiver("audio",{direction:"recvonly"}):this.peerConnection.addTransceiver("audio",{direction:"sendrecv"})}))}onSignalMessage(t){return i(this,void 0,void 0,(function*(){if(this.peerConnection)switch(t.actionType){case s.SignalMessageAction.ANSWER:const e=t.payload;yield this.peerConnection.setRemoteDescription(e),this.connectionReceivedAnswer=!0,this.flushRemoteIceCandidateBuffer();break;case s.SignalMessageAction.ICE_CANDIDATE:const n=t.payload,i=new RTCIceCandidate(n);this.connectionReceivedAnswer?yield this.peerConnection.addIceCandidate(i):this.remoteIceCandidateBuffer.push(i);break;case s.SignalMessageAction.END_SESSION:const o=t.payload;console.log("StreamingClient - onSignalMessage: reason",o),this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_NORMAL),this.shutdown();break;case s.SignalMessageAction.WARNING:const a=t.payload;console.warn("Warning received from server: "+a),this.publicEventEmitter.emit(s.AnamEvent.SERVER_WARNING,a);break;case s.SignalMessageAction.TALK_STREAM_INTERRUPTED:const u=t.payload;this.publicEventEmitter.emit(s.AnamEvent.TALK_STREAM_INTERRUPTED,u.correlationId);break;case s.SignalMessageAction.SESSION_READY:const l=t.sessionId;this.publicEventEmitter.emit(s.AnamEvent.SESSION_READY,l);break;default:console.error("StreamingClient - onSignalMessage: unknown signal message action type. Is your anam-sdk version up to date?",t)}else console.error("StreamingClient - onSignalMessage: peerConnection is not initialized")}))}onSignallingClientConnected(){return i(this,void 0,void 0,(function*(){if(!this.peerConnection)try{yield this.initPeerConnectionAndSendOffer()}catch(t){console.error("StreamingClient - onSignallingClientConnected: Error initializing peer connection",t),this.handleWebrtcFailure(t)}}))}flushRemoteIceCandidateBuffer(){this.remoteIceCandidateBuffer.forEach((t=>{var e;null===(e=this.peerConnection)||void 0===e||e.addIceCandidate(t)})),this.remoteIceCandidateBuffer=[]}onIceCandidate(t){t.candidate&&this.signallingClient.sendIceCandidate(t.candidate)}onIceConnectionStateChange(){var t,e;"connected"!==(null===(t=this.peerConnection)||void 0===t?void 0:t.iceConnectionState)&&"completed"!==(null===(e=this.peerConnection)||void 0===e?void 0:e.iceConnectionState)||this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_ESTABLISHED)}onConnectionStateChange(){var t;"closed"===(null===(t=this.peerConnection)||void 0===t?void 0:t.connectionState)&&(console.error("StreamingClient - onConnectionStateChange: Connection closed"),this.handleWebrtcFailure("The connection to our servers was lost. Please try again."))}handleWebrtcFailure(t){console.error({message:"StreamingClient - handleWebrtcFailure: ",err:t}),"NotAllowedError"===t.name&&"Permission denied"===t.message?this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED):this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE);try{this.stopConnection()}catch(t){console.error("StreamingClient - handleWebrtcFailure: error stopping connection",t)}}onTrackEventHandler(t){if("video"===t.track.kind){if(this.videoStream=t.streams[0],this.publicEventEmitter.emit(s.AnamEvent.VIDEO_STREAM_STARTED,this.videoStream),this.videoElement){this.videoElement.srcObject=this.videoStream;const t=this.videoElement.requestVideoFrameCallback((()=>{var e;null===(e=this.videoElement)||void 0===e||e.cancelVideoFrameCallback(t),this.publicEventEmitter.emit(s.AnamEvent.VIDEO_PLAY_STARTED)}))}}else"audio"===t.track.kind&&(this.audioStream=t.streams[0],this.publicEventEmitter.emit(s.AnamEvent.AUDIO_STREAM_STARTED,this.audioStream))}setupDataChannels(){return i(this,void 0,void 0,(function*(){if(!this.peerConnection)return void console.error("StreamingClient - setupDataChannels: peer connection is not initialized");if(!this.disableInputAudio){if(this.inputAudioStream){if(!this.inputAudioStream.getAudioTracks().length)throw new Error("StreamingClient - setupDataChannels: user provided stream does not have audio tracks")}else{const t={echoCancellation:!0};this.audioDeviceId&&(t.deviceId={exact:this.audioDeviceId}),this.inputAudioStream=yield navigator.mediaDevices.getUserMedia({audio:t})}this.inputAudioState.isMuted&&this.muteAllAudioTracks();const t=this.inputAudioStream.getAudioTracks()[0];this.peerConnection.addTrack(t,this.inputAudioStream),this.publicEventEmitter.emit(s.AnamEvent.INPUT_AUDIO_STREAM_STARTED,this.inputAudioStream)}const t=this.peerConnection.createDataChannel("chat",{ordered:!0});t.onopen=()=>{this.dataChannel=null!=t?t:null},t.onclose=()=>{},t.onmessage=t=>{const e=JSON.parse(t.data);this.internalEventEmitter.emit(s.InternalEvent.WEBRTC_CHAT_MESSAGE_RECEIVED,e)}}))}initPeerConnectionAndSendOffer(){return i(this,void 0,void 0,(function*(){if(yield this.initPeerConnection(),this.peerConnection){try{const t=yield this.peerConnection.createOffer();yield this.peerConnection.setLocalDescription(t)}catch(t){console.error("StreamingClient - initPeerConnectionAndSendOffer: error creating offer",t)}if(!this.peerConnection.localDescription)throw new Error("StreamingClient - initPeerConnectionAndSendOffer: local description is null");yield this.signallingClient.sendOffer(this.peerConnection.localDescription)}else console.error("StreamingClient - initPeerConnectionAndSendOffer: peer connection is not initialized")}))}shutdown(){try{this.inputAudioStream&&this.inputAudioStream.getTracks().forEach((t=>{t.stop()})),this.inputAudioStream=null}catch(t){console.error("StreamingClient - shutdown: error stopping input audio stream",t)}try{this.signallingClient.stop()}catch(t){console.error("StreamingClient - shutdown: error stopping signallilng",t)}try{this.peerConnection&&"closed"!==this.peerConnection.connectionState&&(this.peerConnection.onconnectionstatechange=null,this.peerConnection.close(),this.peerConnection=null)}catch(t){console.error("StreamingClient - shutdown: error closing peer connection",t)}}}},958:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StreamingClient=e.PublicEventEmitter=e.MessageHistoryClient=e.InternalEventEmitter=e.EngineApiRestClient=e.CoreApiRestClient=e.SignallingClient=void 0;var i=n(279);Object.defineProperty(e,"SignallingClient",{enumerable:!0,get:function(){return i.SignallingClient}});var r=n(18);Object.defineProperty(e,"CoreApiRestClient",{enumerable:!0,get:function(){return r.CoreApiRestClient}});var o=n(529);Object.defineProperty(e,"EngineApiRestClient",{enumerable:!0,get:function(){return o.EngineApiRestClient}});var s=n(259);Object.defineProperty(e,"InternalEventEmitter",{enumerable:!0,get:function(){return s.InternalEventEmitter}});var a=n(462);Object.defineProperty(e,"MessageHistoryClient",{enumerable:!0,get:function(){return a.MessageHistoryClient}});var u=n(995);Object.defineProperty(e,"PublicEventEmitter",{enumerable:!0,get:function(){return u.PublicEventEmitter}});var l=n(577);Object.defineProperty(e,"StreamingClient",{enumerable:!0,get:function(){return l.StreamingClient}})},672:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isCustomPersonaConfig=e.isSavedPersonaConfig=void 0,e.isSavedPersonaConfig=function(t){return"personaId"in t},e.isCustomPersonaConfig=function(t){return"brainType"in t}},711:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.TalkMessageStream=void 0;const r=n(170),o=n(322);e.TalkMessageStream=class{constructor(t,e,n){this.state=o.TalkMessageStreamState.UNSTARTED,this.correlationId=t,this.internalEventEmitter=e,this.signallingClient=n,this.internalEventEmitter.addListener(r.InternalEvent.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this))}onDeactivate(){this.internalEventEmitter.removeListener(r.InternalEvent.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this))}onSignalMessage(t){return i(this,void 0,void 0,(function*(){t.actionType===r.SignalMessageAction.TALK_STREAM_INTERRUPTED&&t.payload.correlationId===this.correlationId&&(this.state=o.TalkMessageStreamState.INTERRUPTED,this.onDeactivate())}))}endMessage(){return i(this,void 0,void 0,(function*(){if(this.state===o.TalkMessageStreamState.ENDED)return void console.warn("Talk stream is already ended via end of speech. No need to call endMessage.");if(this.state!==o.TalkMessageStreamState.STREAMING)return void console.warn("Talk stream is not active state: "+this.state);const t={content:"",startOfSpeech:!1,endOfSpeech:!0,correlationId:this.correlationId};yield this.signallingClient.sendTalkMessage(t),this.state=o.TalkMessageStreamState.ENDED,this.onDeactivate()}))}streamMessageChunk(t,e){return i(this,void 0,void 0,(function*(){if(this.state!==o.TalkMessageStreamState.STREAMING&&this.state!==o.TalkMessageStreamState.UNSTARTED)throw new Error("Talk stream is not in an active state: "+this.state);const n={content:t,startOfSpeech:this.state===o.TalkMessageStreamState.UNSTARTED,endOfSpeech:e,correlationId:this.correlationId};this.state=e?o.TalkMessageStreamState.ENDED:o.TalkMessageStreamState.STREAMING,this.state===o.TalkMessageStreamState.ENDED&&this.onDeactivate(),yield this.signallingClient.sendTalkMessage(n)}))}getCorrelationId(){return this.correlationId}isActive(){return this.state===o.TalkMessageStreamState.STREAMING||this.state===o.TalkMessageStreamState.UNSTARTED}getState(){return this.state}}},322:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.TalkMessageStreamState=void 0,function(t){t[t.UNSTARTED=0]="UNSTARTED",t[t.STREAMING=1]="STREAMING",t[t.INTERRUPTED=2]="INTERRUPTED",t[t.ENDED=3]="ENDED"}(n||(e.TalkMessageStreamState=n={}))},878:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEvent=e.AnamEvent=void 0;var i=n(21);Object.defineProperty(e,"AnamEvent",{enumerable:!0,get:function(){return i.AnamEvent}});var r=n(645);Object.defineProperty(e,"InternalEvent",{enumerable:!0,get:function(){return r.InternalEvent}})},645:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEvent=void 0,function(t){t.WEB_SOCKET_OPEN="WEB_SOCKET_OPEN",t.SIGNAL_MESSAGE_RECEIVED="SIGNAL_MESSAGE_RECEIVED",t.WEBRTC_CHAT_MESSAGE_RECEIVED="WEBRTC_CHAT_MESSAGE_RECEIVED"}(n||(e.InternalEvent=n={}))},21:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AnamEvent=void 0,function(t){t.MESSAGE_HISTORY_UPDATED="MESSAGE_HISTORY_UPDATED",t.MESSAGE_STREAM_EVENT_RECEIVED="MESSAGE_STREAM_EVENT_RECEIVED",t.CONNECTION_ESTABLISHED="CONNECTION_ESTABLISHED",t.CONNECTION_CLOSED="CONNECTION_CLOSED",t.INPUT_AUDIO_STREAM_STARTED="INPUT_AUDIO_STREAM_STARTED",t.VIDEO_STREAM_STARTED="VIDEO_STREAM_STARTED",t.VIDEO_PLAY_STARTED="VIDEO_PLAY_STARTED",t.AUDIO_STREAM_STARTED="AUDIO_STREAM_STARTED",t.TALK_STREAM_INTERRUPTED="TALK_STREAM_INTERRUPTED",t.SESSION_READY="SESSION_READY",t.SERVER_WARNING="SERVER_WARNING"}(n||(e.AnamEvent=n={}))},170:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEvent=e.AnamEvent=e.MessageRole=e.SignalMessageAction=void 0;var i=n(295);Object.defineProperty(e,"SignalMessageAction",{enumerable:!0,get:function(){return i.SignalMessageAction}});var r=n(822);Object.defineProperty(e,"MessageRole",{enumerable:!0,get:function(){return r.MessageRole}});var o=n(878);Object.defineProperty(e,"AnamEvent",{enumerable:!0,get:function(){return o.AnamEvent}});var s=n(878);Object.defineProperty(e,"InternalEvent",{enumerable:!0,get:function(){return s.InternalEvent}})},273:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.MessageRole=void 0,function(t){t.USER="user",t.PERSONA="persona"}(n||(e.MessageRole=n={}))},822:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MessageRole=void 0;var i=n(273);Object.defineProperty(e,"MessageRole",{enumerable:!0,get:function(){return i.MessageRole}})},656:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SignalMessageAction=void 0,function(t){t.OFFER="offer",t.ANSWER="answer",t.ICE_CANDIDATE="icecandidate",t.END_SESSION="endsession",t.HEARTBEAT="heartbeat",t.WARNING="warning",t.TALK_STREAM_INTERRUPTED="talkinputstreaminterrupted",t.TALK_STREAM_INPUT="talkstream",t.SESSION_READY="sessionready"}(n||(e.SignalMessageAction=n={}))},295:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SignalMessageAction=void 0;var i=n(656);Object.defineProperty(e,"SignalMessageAction",{enumerable:!0,get:function(){return i.SignalMessageAction}})}},e={},function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(440);var t,e}));
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.anam=e():t.anam=e()}(self,(()=>{return t={526:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),n=e[0],i=e[1];return 3*(n+i)/4-i},e.toByteArray=function(t){var e,n,o=a(t),s=o[0],u=o[1],l=new r(function(t,e,n){return 3*(e+n)/4-n}(0,s,u)),c=0,h=u>0?s-4:s;for(n=0;n<h;n+=4)e=i[t.charCodeAt(n)]<<18|i[t.charCodeAt(n+1)]<<12|i[t.charCodeAt(n+2)]<<6|i[t.charCodeAt(n+3)],l[c++]=e>>16&255,l[c++]=e>>8&255,l[c++]=255&e;return 2===u&&(e=i[t.charCodeAt(n)]<<2|i[t.charCodeAt(n+1)]>>4,l[c++]=255&e),1===u&&(e=i[t.charCodeAt(n)]<<10|i[t.charCodeAt(n+1)]<<4|i[t.charCodeAt(n+2)]>>2,l[c++]=e>>8&255,l[c++]=255&e),l},e.fromByteArray=function(t){for(var e,i=t.length,r=i%3,o=[],s=16383,a=0,l=i-r;a<l;a+=s)o.push(u(t,a,a+s>l?l:a+s));return 1===r?(e=t[i-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===r&&(e=(t[i-2]<<8)+t[i-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),o.join("")};for(var n=[],i=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)n[s]=o[s],i[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}function u(t,e,i){for(var r,o,s=[],a=e;a<i;a+=3)r=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(o=r)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},287:(t,e,n)=>{"use strict";const i=n(526),r=n(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,n){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return l(t,e,n)}function l(t,e,n){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const n=0|p(t,e);let i=a(n);const r=i.write(t,e);return r!==n&&(i=i.slice(0,r)),i}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return f(e.buffer,e.byteOffset,e.byteLength)}return d(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return f(t,e,n);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return f(t,e,n);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const i=t.valueOf&&t.valueOf();if(null!=i&&i!==t)return u.from(i,e,n);const r=function(t){if(u.isBuffer(t)){const e=0|E(t.length),n=a(e);return 0===n.length||t.copy(n,0,0,e),n}return void 0!==t.length?"number"!=typeof t.length||q(t.length)?a(0):d(t):"Buffer"===t.type&&Array.isArray(t.data)?d(t.data):void 0}(t);if(r)return r;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function c(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return c(t),a(t<0?0:0|E(t))}function d(t){const e=t.length<0?0:0|E(t.length),n=a(e);for(let i=0;i<e;i+=1)n[i]=255&t[i];return n}function f(t,e,n){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(n||0))throw new RangeError('"length" is outside of buffer bounds');let i;return i=void 0===e&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,e):new Uint8Array(t,e,n),Object.setPrototypeOf(i,u.prototype),i}function E(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function p(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const n=t.length,i=arguments.length>2&&!0===arguments[2];if(!i&&0===n)return 0;let r=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return K(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(t).length;default:if(r)return i?-1:K(t).length;e=(""+e).toLowerCase(),r=!0}}function g(t,e,n){let i=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return w(this,e,n);case"utf8":case"utf-8":return O(this,e,n);case"ascii":return b(this,e,n);case"latin1":case"binary":return N(this,e,n);case"base64":return R(this,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,e,n);default:if(i)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),i=!0}}function C(t,e,n){const i=t[e];t[e]=t[n],t[n]=i}function S(t,e,n,i,r){if(0===t.length)return-1;if("string"==typeof n?(i=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),q(n=+n)&&(n=r?0:t.length-1),n<0&&(n=t.length+n),n>=t.length){if(r)return-1;n=t.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof e&&(e=u.from(e,i)),u.isBuffer(e))return 0===e.length?-1:m(t,e,n,i,r);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(t,e,n):Uint8Array.prototype.lastIndexOf.call(t,e,n):m(t,[e],n,i,r);throw new TypeError("val must be string, number or Buffer")}function m(t,e,n,i,r){let o,s=1,a=t.length,u=e.length;if(void 0!==i&&("ucs2"===(i=String(i).toLowerCase())||"ucs-2"===i||"utf16le"===i||"utf-16le"===i)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,n/=2}function l(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(r){let i=-1;for(o=n;o<a;o++)if(l(t,o)===l(e,-1===i?0:o-i)){if(-1===i&&(i=o),o-i+1===u)return i*s}else-1!==i&&(o-=o-i),i=-1}else for(n+u>a&&(n=a-u),o=n;o>=0;o--){let n=!0;for(let i=0;i<u;i++)if(l(t,o+i)!==l(e,i)){n=!1;break}if(n)return o}return-1}function v(t,e,n,i){n=Number(n)||0;const r=t.length-n;i?(i=Number(i))>r&&(i=r):i=r;const o=e.length;let s;for(i>o/2&&(i=o/2),s=0;s<i;++s){const i=parseInt(e.substr(2*s,2),16);if(q(i))return s;t[n+s]=i}return s}function _(t,e,n,i){return Y(K(e,t.length-n),t,n,i)}function A(t,e,n,i){return Y(function(t){const e=[];for(let n=0;n<t.length;++n)e.push(255&t.charCodeAt(n));return e}(e),t,n,i)}function I(t,e,n,i){return Y(z(e),t,n,i)}function y(t,e,n,i){return Y(function(t,e){let n,i,r;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)n=t.charCodeAt(s),i=n>>8,r=n%256,o.push(r),o.push(i);return o}(e,t.length-n),t,n,i)}function R(t,e,n){return 0===e&&n===t.length?i.fromByteArray(t):i.fromByteArray(t.slice(e,n))}function O(t,e,n){n=Math.min(t.length,n);const i=[];let r=e;for(;r<n;){const e=t[r];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(r+s<=n){let n,i,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:n=t[r+1],128==(192&n)&&(u=(31&e)<<6|63&n,u>127&&(o=u));break;case 3:n=t[r+1],i=t[r+2],128==(192&n)&&128==(192&i)&&(u=(15&e)<<12|(63&n)<<6|63&i,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:n=t[r+1],i=t[r+2],a=t[r+3],128==(192&n)&&128==(192&i)&&128==(192&a)&&(u=(15&e)<<18|(63&n)<<12|(63&i)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|1023&o),i.push(o),r+=s}return function(t){const e=t.length;if(e<=T)return String.fromCharCode.apply(String,t);let n="",i=0;for(;i<e;)n+=String.fromCharCode.apply(String,t.slice(i,i+=T));return n}(i)}e.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,n){return l(t,e,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,n){return function(t,e,n){return c(t),t<=0?a(t):void 0!==e?"string"==typeof n?a(t).fill(e,n):a(t).fill(e):a(t)}(t,e,n)},u.allocUnsafe=function(t){return h(t)},u.allocUnsafeSlow=function(t){return h(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,i=e.length;for(let r=0,o=Math.min(n,i);r<o;++r)if(t[r]!==e[r]){n=t[r],i=e[r];break}return n<i?-1:i<n?1:0},u.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let n;if(void 0===e)for(e=0,n=0;n<t.length;++n)e+=t[n].length;const i=u.allocUnsafe(e);let r=0;for(n=0;n<t.length;++n){let e=t[n];if(J(e,Uint8Array))r+e.length>i.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(i,r)):Uint8Array.prototype.set.call(i,e,r);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(i,r)}r+=e.length}return i},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)C(this,e,e+1);return this},u.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)C(this,e,e+3),C(this,e+1,e+2);return this},u.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)C(this,e,e+7),C(this,e+1,e+6),C(this,e+2,e+5),C(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const n=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,n).replace(/(.{2})/g,"$1 ").trim(),this.length>n&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,n,i,r){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===n&&(n=t?t.length:0),void 0===i&&(i=0),void 0===r&&(r=this.length),e<0||n>t.length||i<0||r>this.length)throw new RangeError("out of range index");if(i>=r&&e>=n)return 0;if(i>=r)return-1;if(e>=n)return 1;if(this===t)return 0;let o=(r>>>=0)-(i>>>=0),s=(n>>>=0)-(e>>>=0);const a=Math.min(o,s),l=this.slice(i,r),c=t.slice(e,n);for(let t=0;t<a;++t)if(l[t]!==c[t]){o=l[t],s=c[t];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,n){return-1!==this.indexOf(t,e,n)},u.prototype.indexOf=function(t,e,n){return S(this,t,e,n,!0)},u.prototype.lastIndexOf=function(t,e,n){return S(this,t,e,n,!1)},u.prototype.write=function(t,e,n,i){if(void 0===e)i="utf8",n=this.length,e=0;else if(void 0===n&&"string"==typeof e)i=e,n=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(n)?(n>>>=0,void 0===i&&(i="utf8")):(i=n,n=void 0)}const r=this.length-e;if((void 0===n||n>r)&&(n=r),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let o=!1;for(;;)switch(i){case"hex":return v(this,t,e,n);case"utf8":case"utf-8":return _(this,t,e,n);case"ascii":case"latin1":case"binary":return A(this,t,e,n);case"base64":return I(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return y(this,t,e,n);default:if(o)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const T=4096;function b(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;r<n;++r)i+=String.fromCharCode(127&t[r]);return i}function N(t,e,n){let i="";n=Math.min(t.length,n);for(let r=e;r<n;++r)i+=String.fromCharCode(t[r]);return i}function w(t,e,n){const i=t.length;(!e||e<0)&&(e=0),(!n||n<0||n>i)&&(n=i);let r="";for(let i=e;i<n;++i)r+=X[t[i]];return r}function M(t,e,n){const i=t.slice(e,n);let r="";for(let t=0;t<i.length-1;t+=2)r+=String.fromCharCode(i[t]+256*i[t+1]);return r}function D(t,e,n){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>n)throw new RangeError("Trying to access beyond buffer length")}function L(t,e,n,i,r,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>r||e<o)throw new RangeError('"value" argument is out of bounds');if(n+i>t.length)throw new RangeError("Index out of range")}function U(t,e,n,i,r){G(e,i,r,t,n,7);let o=Number(e&BigInt(4294967295));t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o,o>>=8,t[n++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,s>>=8,t[n++]=s,n}function B(t,e,n,i,r){G(e,i,r,t,n,7);let o=Number(e&BigInt(4294967295));t[n+7]=o,o>>=8,t[n+6]=o,o>>=8,t[n+5]=o,o>>=8,t[n+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[n+3]=s,s>>=8,t[n+2]=s,s>>=8,t[n+1]=s,s>>=8,t[n]=s,n+8}function P(t,e,n,i,r,o){if(n+i>t.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function k(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function j(t,e,n,i,o){return e=+e,n>>>=0,o||P(t,0,n,8),r.write(t,e,n,i,52,8),n+8}u.prototype.slice=function(t,e){const n=this.length;(t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t);const i=this.subarray(t,e);return Object.setPrototypeOf(i,u.prototype),i},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=this[t],r=1,o=0;for(;++o<e&&(r*=256);)i+=this[t+o]*r;return i},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=this[t+--e],r=1;for(;e>0&&(r*=256);)i+=this[t+--e]*r;return i},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||D(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||D(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||D(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||D(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||D(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,r=this[++t]+256*this[++t]+65536*this[++t]+n*2**24;return BigInt(i)+(BigInt(r)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=e*2**24+65536*this[++t]+256*this[++t]+this[++t],r=this[++t]*2**24+65536*this[++t]+256*this[++t]+n;return(BigInt(i)<<BigInt(32))+BigInt(r)})),u.prototype.readIntLE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=this[t],r=1,o=0;for(;++o<e&&(r*=256);)i+=this[t+o]*r;return r*=128,i>=r&&(i-=Math.pow(2,8*e)),i},u.prototype.readIntBE=function(t,e,n){t>>>=0,e>>>=0,n||D(t,e,this.length);let i=e,r=1,o=this[t+--i];for(;i>0&&(r*=256);)o+=this[t+--i]*r;return r*=128,o>=r&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||D(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||D(t,2,this.length);const n=this[t]|this[t+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(t,e){t>>>=0,e||D(t,2,this.length);const n=this[t+1]|this[t]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||D(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||D(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=this[t+4]+256*this[t+5]+65536*this[t+6]+(n<<24);return(BigInt(i)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((function(t){$(t>>>=0,"offset");const e=this[t],n=this[t+7];void 0!==e&&void 0!==n||H(t,this.length-8);const i=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(i)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+n)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||D(t,4,this.length),r.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||D(t,4,this.length),r.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||D(t,8,this.length),r.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||D(t,8,this.length),r.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||L(this,t,e,n,Math.pow(2,8*n)-1,0);let r=1,o=0;for(this[e]=255&t;++o<n&&(r*=256);)this[e+o]=t/r&255;return e+n},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,n,i){t=+t,e>>>=0,n>>>=0,i||L(this,t,e,n,Math.pow(2,8*n)-1,0);let r=n-1,o=1;for(this[e+r]=255&t;--r>=0&&(o*=256);)this[e+r]=t/o&255;return e+n},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return B(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}let r=0,o=1,s=0;for(this[e]=255&t;++r<n&&(o*=256);)t<0&&0===s&&0!==this[e+r-1]&&(s=1),this[e+r]=(t/o|0)-s&255;return e+n},u.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e>>>=0,!i){const i=Math.pow(2,8*n-1);L(this,t,e,n,i-1,-i)}let r=n-1,o=1,s=0;for(this[e+r]=255&t;--r>=0&&(o*=256);)t<0&&0===s&&0!==this[e+r+1]&&(s=1),this[e+r]=(t/o|0)-s&255;return e+n},u.prototype.writeInt8=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,n){return t=+t,e>>>=0,n||L(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return B(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,n){return k(this,t,e,!0,n)},u.prototype.writeFloatBE=function(t,e,n){return k(this,t,e,!1,n)},u.prototype.writeDoubleLE=function(t,e,n){return j(this,t,e,!0,n)},u.prototype.writeDoubleBE=function(t,e,n){return j(this,t,e,!1,n)},u.prototype.copy=function(t,e,n,i){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),i||0===i||(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);const r=i-n;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,n,i):Uint8Array.prototype.set.call(t,this.subarray(n,i),e),r},u.prototype.fill=function(t,e,n,i){if("string"==typeof t){if("string"==typeof e?(i=e,e=0,n=this.length):"string"==typeof n&&(i=n,n=this.length),void 0!==i&&"string"!=typeof i)throw new TypeError("encoding must be a string");if("string"==typeof i&&!u.isEncoding(i))throw new TypeError("Unknown encoding: "+i);if(1===t.length){const e=t.charCodeAt(0);("utf8"===i&&e<128||"latin1"===i)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;let r;if(e>>>=0,n=void 0===n?this.length:n>>>0,t||(t=0),"number"==typeof t)for(r=e;r<n;++r)this[r]=t;else{const o=u.isBuffer(t)?t:u.from(t,i),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(r=0;r<n-e;++r)this[r+e]=o[r%s]}return this};const F={};function x(t,e,n){F[t]=class extends n{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function V(t){let e="",n=t.length;const i="-"===t[0]?1:0;for(;n>=i+4;n-=3)e=`_${t.slice(n-3,n)}${e}`;return`${t.slice(0,n)}${e}`}function G(t,e,n,i,r,o){if(t>n||t<e){const i="bigint"==typeof e?"n":"";let r;throw r=o>3?0===e||e===BigInt(0)?`>= 0${i} and < 2${i} ** ${8*(o+1)}${i}`:`>= -(2${i} ** ${8*(o+1)-1}${i}) and < 2 ** ${8*(o+1)-1}${i}`:`>= ${e}${i} and <= ${n}${i}`,new F.ERR_OUT_OF_RANGE("value",r,t)}!function(t,e,n){$(e,"offset"),void 0!==t[e]&&void 0!==t[e+n]||H(e,t.length-(n+1))}(i,r,o)}function $(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function H(t,e,n){if(Math.floor(t)!==t)throw $(t,n),new F.ERR_OUT_OF_RANGE(n||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${e}`,t)}x("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),x("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),x("ERR_OUT_OF_RANGE",(function(t,e,n){let i=`The value of "${t}" is out of range.`,r=n;return Number.isInteger(n)&&Math.abs(n)>2**32?r=V(String(n)):"bigint"==typeof n&&(r=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(r=V(r)),r+="n"),i+=` It must be ${e}. Received ${r}`,i}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function K(t,e){let n;e=e||1/0;const i=t.length;let r=null;const o=[];for(let s=0;s<i;++s){if(n=t.charCodeAt(s),n>55295&&n<57344){if(!r){if(n>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===i){(e-=3)>-1&&o.push(239,191,189);continue}r=n;continue}if(n<56320){(e-=3)>-1&&o.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(e-=3)>-1&&o.push(239,191,189);if(r=null,n<128){if((e-=1)<0)break;o.push(n)}else if(n<2048){if((e-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((e-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function z(t){return i.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Y(t,e,n,i){let r;for(r=0;r<i&&!(r+n>=e.length||r>=t.length);++r)e[r+n]=t[r];return r}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function q(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let n=0;n<16;++n){const i=16*n;for(let r=0;r<16;++r)e[i+r]=t[n]+t[r]}return e}();function Z(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},251:(t,e)=>{e.read=function(t,e,n,i,r){var o,s,a=8*r-i-1,u=(1<<a)-1,l=u>>1,c=-7,h=n?r-1:0,d=n?-1:1,f=t[e+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=a;c>0;o=256*o+t[e+h],h+=d,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=i;c>0;s=256*s+t[e+h],h+=d,c-=8);if(0===o)o=1-l;else{if(o===u)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,i),o-=l}return(f?-1:1)*s*Math.pow(2,o-i)},e.write=function(t,e,n,i,r,o){var s,a,u,l=8*o-r-1,c=(1<<l)-1,h=c>>1,d=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:o-1,E=i?1:-1,p=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=c):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(a=0,s=c):s+h>=1?(a=(e*u-1)*Math.pow(2,r),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;t[n+f]=255&a,f+=E,a/=256,r-=8);for(s=s<<r|a,l+=r;l>0;t[n+f]=255&s,f+=E,s/=256,l-=8);t[n+f-E]|=128*p}},816:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0});const r=n(71),o=n(958),s=n(170),a=n(287);e.default=class{constructor(t,e,n){var i,s;this.inputAudioState={isMuted:!1},this.sessionId=null,this.organizationId=null,this.streamingClient=null,this._isStreaming=!1;const a=this.validateClientConfig(t,e,n);if(a)throw new r.ClientError(a,r.ErrorCode.CLIENT_ERROR_CODE_CONFIGURATION_ERROR,400);this.personaConfig=e,this.clientOptions=n,((null===(i=null==n?void 0:n.api)||void 0===i?void 0:i.baseUrl)||(null===(s=null==n?void 0:n.api)||void 0===s?void 0:s.apiVersion))&&(0,r.setErrorMetricsBaseUrl)(n.api.baseUrl||r.DEFAULT_ANAM_METRICS_BASE_URL,n.api.apiVersion||r.DEFAULT_ANAM_API_VERSION),this.publicEventEmitter=new o.PublicEventEmitter,this.internalEventEmitter=new o.InternalEventEmitter,this.apiClient=new o.CoreApiRestClient(t,null==n?void 0:n.apiKey,null==n?void 0:n.api),this.messageHistoryClient=new o.MessageHistoryClient(this.publicEventEmitter,this.internalEventEmitter)}decodeJwt(t){try{const e=t.split(".")[1],n=a.Buffer.from(e,"base64").toString("utf8");return JSON.parse(n)}catch(t){throw new Error("Invalid session token format")}}validateClientConfig(t,e,n){var i;if(!t&&!(null==n?void 0:n.apiKey))return"Either sessionToken or apiKey must be provided";if((null==n?void 0:n.apiKey)&&t)return"Only one of sessionToken or apiKey should be used";if(t){const n=this.decodeJwt(t);this.organizationId=n.accountId,(0,r.setCurrentSessionInfo)(this.sessionId,this.organizationId);const o=null===(i=n.type)||void 0===i?void 0:i.toLowerCase();if("legacy"===o)return"Legacy session tokens are no longer supported. Please define your persona when creating your session token. See https://docs.anam.ai/resources/migrating-legacy for more information.";if(("ephemeral"===o||"stateful"===o)&&e)return"This session token already contains a persona configuration. Please remove the personaConfig parameter."}else if(!e)return"Missing persona config. Persona configuration must be provided when using apiKey";if(null==n?void 0:n.voiceDetection){if(n.disableInputAudio)return"Voice detection is disabled because input audio is disabled. Please set disableInputAudio to false to enable voice detection.";if(void 0!==n.voiceDetection.endOfSpeechSensitivity){if("number"!=typeof n.voiceDetection.endOfSpeechSensitivity)return"End of speech sensitivity must be a number";if(n.voiceDetection.endOfSpeechSensitivity<0||n.voiceDetection.endOfSpeechSensitivity>1)return"End of speech sensitivity must be between 0 and 1"}}}buildStartSessionOptionsForClient(){var t;const e={};if((null===(t=this.clientOptions)||void 0===t?void 0:t.voiceDetection)&&(e.voiceDetection=this.clientOptions.voiceDetection),0!==Object.keys(e).length)return e}startSession(t){return i(this,void 0,void 0,(function*(){var e,n,i;const s=this.personaConfig,a=this.buildStartSessionOptionsForClient(),u=yield this.apiClient.startSession(s,a),{sessionId:l,clientConfig:c,engineHost:h,engineProtocol:d,signallingEndpoint:f}=u,{heartbeatIntervalSeconds:E,maxWsReconnectionAttempts:p,iceServers:g}=c;try{this.streamingClient=new o.StreamingClient(l,{engine:{baseUrl:`${d}://${h}`},signalling:{heartbeatIntervalSeconds:E,maxWsReconnectionAttempts:p,url:{baseUrl:h,protocol:d,signallingPath:f}},iceServers:g,inputAudio:{inputAudioState:this.inputAudioState,userProvidedMediaStream:(null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)?void 0:t,audioDeviceId:null===(n=this.clientOptions)||void 0===n?void 0:n.audioDeviceId,disableInputAudio:null===(i=this.clientOptions)||void 0===i?void 0:i.disableInputAudio}},this.publicEventEmitter,this.internalEventEmitter)}catch(t){throw new r.ClientError("Failed to initialize streaming client",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:t instanceof Error?t.message:String(t),sessionId:l})}return this.sessionId=l,(0,r.setCurrentSessionInfo)(this.sessionId,this.organizationId),l}))}startSessionIfNeeded(t){return i(this,void 0,void 0,(function*(){if(!(this.sessionId&&this.streamingClient||(yield this.startSession(t),this.sessionId&&this.streamingClient)))throw new r.ClientError("Session ID or streaming client is not available after starting session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:"Failed to initialize session properly"})}))}stream(t){return i(this,void 0,void 0,(function*(){var e;if((null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)&&t&&console.warn("AnamClient:Input audio is disabled. User provided audio stream will be ignored."),yield this.startSessionIfNeeded(t),this._isStreaming)throw new Error("Already streaming");return this._isStreaming=!0,new Promise((t=>{var e;const n=[];let i=!1,r=!1;this.publicEventEmitter.addListener(s.AnamEvent.VIDEO_STREAM_STARTED,(e=>{n.push(e),i=!0,r&&t(n)})),this.publicEventEmitter.addListener(s.AnamEvent.AUDIO_STREAM_STARTED,(e=>{n.push(e),r=!0,i&&t(n)})),null===(e=this.streamingClient)||void 0===e||e.startConnection()}))}))}streamToVideoAndAudioElements(t,e,n){return i(this,void 0,void 0,(function*(){console.warn("AnamClient: streamToVideoAndAudioElements is deprecated. To avoid possible audio issues, please use streamToVideoElement instead."),yield this.streamToVideoElement(t,n)}))}streamToVideoElement(t,e){return i(this,void 0,void 0,(function*(){var n;(null===(n=this.clientOptions)||void 0===n?void 0:n.disableInputAudio)&&e&&console.warn("AnamClient:Input audio is disabled. User provided audio stream will be ignored.");try{yield this.startSessionIfNeeded(e)}catch(t){if(t instanceof r.ClientError)throw t;throw new r.ClientError("Failed to start session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:t instanceof Error?t.message:String(t),sessionId:this.sessionId})}if(this._isStreaming)throw new Error("Already streaming");if(this._isStreaming=!0,!this.streamingClient)throw new Error("Failed to stream: streaming client is not available");this.streamingClient.setMediaStreamTargetById(t),this.streamingClient.startConnection()}))}talk(t){return i(this,void 0,void 0,(function*(){if(!this.streamingClient)throw new Error("Failed to send talk command: session is not started. Have you called startSession?");if(!this._isStreaming)throw new Error("Failed to send talk command: not currently streaming. Have you called stream?");yield this.streamingClient.sendTalkCommand(t)}))}sendDataMessage(t){if(!this.streamingClient)throw new Error("Failed to send message: session is not started.");this.streamingClient.sendDataMessage(t)}stopStreaming(){return i(this,void 0,void 0,(function*(){this.streamingClient&&(this.streamingClient.stopConnection(),this.streamingClient=null,this.sessionId=null,(0,r.setCurrentSessionInfo)(null,this.organizationId),this._isStreaming=!1)}))}isStreaming(){return this._isStreaming}setPersonaConfig(t){this.personaConfig=t}getPersonaConfig(){return this.personaConfig}getInputAudioState(){var t;return(null===(t=this.clientOptions)||void 0===t?void 0:t.disableInputAudio)&&console.warn("AnamClient: Audio state will not be used because input audio is disabled."),this.streamingClient&&(this.inputAudioState=this.streamingClient.getInputAudioState()),this.inputAudioState}muteInputAudio(){var t,e;return(null===(t=this.clientOptions)||void 0===t?void 0:t.disableInputAudio)&&console.warn("AnamClient: Input audio is disabled. Muting input audio will have no effect."),this.streamingClient&&!(null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)?this.inputAudioState=this.streamingClient.muteInputAudio():this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!0}),this.inputAudioState}unmuteInputAudio(){var t,e;return(null===(t=this.clientOptions)||void 0===t?void 0:t.disableInputAudio)&&console.warn("AnamClient: Input audio is disabled. Unmuting input audio will have no effect."),this.streamingClient&&!(null===(e=this.clientOptions)||void 0===e?void 0:e.disableInputAudio)?this.inputAudioState=this.streamingClient.unmuteInputAudio():this.inputAudioState=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!1}),this.inputAudioState}createTalkMessageStream(t){if(!this.streamingClient)throw new Error("Failed to start talk message stream: session is not started.");if(t&&""===t.trim())throw new Error("Failed to start talk message stream: correlationId is empty");return this.streamingClient.startTalkMessageStream(t)}addListener(t,e){this.publicEventEmitter.addListener(t,e)}removeListener(t,e){this.publicEventEmitter.removeListener(t,e)}getActiveSessionId(){return this.sessionId}}},440:function(t,e,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),r=this&&this.__exportStar||function(t,e){for(var n in t)"default"===n||Object.prototype.hasOwnProperty.call(e,n)||i(e,t,n)},o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.unsafe_createClientWithApiKey=e.createClient=void 0;const s=o(n(816));e.createClient=(t,e)=>new s.default(t,void 0,e),e.unsafe_createClientWithApiKey=(t,e,n)=>new s.default(void 0,e,Object.assign(Object.assign({},n),{apiKey:t})),r(n(170),e)},71:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.ClientError=e.sendErrorMetric=e.setCurrentSessionInfo=e.setErrorMetricsBaseUrl=e.ClientMetricMeasurement=e.DEFAULT_ANAM_API_VERSION=e.DEFAULT_ANAM_METRICS_BASE_URL=e.ErrorCode=void 0;const r=n(985);var o,s;!function(t){t.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED="CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED",t.CLIENT_ERROR_CODE_VALIDATION_ERROR="CLIENT_ERROR_CODE_VALIDATION_ERROR",t.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR="CLIENT_ERROR_CODE_AUTHENTICATION_ERROR",t.CLIENT_ERROR_CODE_SERVER_ERROR="CLIENT_ERROR_CODE_SERVER_ERROR",t.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED="CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED",t.CLIENT_ERROR_CODE_SERVICE_BUSY="CLIENT_ERROR_CODE_SERVICE_BUSY",t.CLIENT_ERROR_CODE_NO_PLAN_FOUND="CLIENT_ERROR_CODE_NO_PLAN_FOUND",t.CLIENT_ERROR_CODE_UNKNOWN_ERROR="CLIENT_ERROR_CODE_UNKNOWN_ERROR",t.CLIENT_ERROR_CODE_CONFIGURATION_ERROR="CLIENT_ERROR_CODE_CONFIGURATION_ERROR"}(o||(e.ErrorCode=o={})),e.DEFAULT_ANAM_METRICS_BASE_URL="https://api.anam.ai",e.DEFAULT_ANAM_API_VERSION="/v1",function(t){t.CLIENT_METRIC_MEASUREMENT_ERROR="client_error",t.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED="client_connection_closed",t.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED="client_connection_established"}(s||(e.ClientMetricMeasurement=s={}));let a=e.DEFAULT_ANAM_METRICS_BASE_URL,u=e.DEFAULT_ANAM_API_VERSION,l=null,c=null;e.setErrorMetricsBaseUrl=(t,n=e.DEFAULT_ANAM_API_VERSION)=>{a=t,u=n},e.setCurrentSessionInfo=(t,e)=>{l=t,c=e},e.sendErrorMetric=(t,e,n)=>i(void 0,void 0,void 0,(function*(){try{const i=Object.assign(Object.assign({},r.CLIENT_METADATA),n);l&&(i.sessionId=l),c&&(i.organizationId=c),yield fetch(`${a}${u}/metrics/client`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,value:e,tags:i})})}catch(t){console.error("Failed to send error metric:",t)}}));class h extends Error{constructor(t,n,i=500,r){super(t),this.name="ClientError",this.code=n,this.statusCode=i,this.details=r,Object.setPrototypeOf(this,h.prototype),(0,e.sendErrorMetric)(s.CLIENT_METRIC_MEASUREMENT_ERROR,n,{details:r,statusCode:i})}}e.ClientError=h},985:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CLIENT_METADATA=e.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE=e.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE=e.CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED=e.CONNECTION_CLOSED_CODE_NORMAL=e.DEFAULT_API_VERSION=e.DEFAULT_API_BASE_URL=e.DEFAULT_HEADERS=void 0,e.DEFAULT_HEADERS={"Content-Type":"application/json"},e.DEFAULT_API_BASE_URL="https://api.anam.ai",e.DEFAULT_API_VERSION="/v1",e.CONNECTION_CLOSED_CODE_NORMAL="CONNECTION_CLOSED_CODE_NORMAL",e.CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED="CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED",e.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE="CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE",e.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE="CONNECTION_CLOSED_CODE_WEBRTC_FAILURE",e.CLIENT_METADATA={client:"js-sdk",version:"3.0.0"}},18:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.CoreApiRestClient=void 0;const r=n(71),o=n(985),s=n(672);e.CoreApiRestClient=class{constructor(t,e,n){if(!t&&!e)throw new Error("Either sessionToken or apiKey must be provided");this.sessionToken=t||null,this.apiKey=e||null,this.baseUrl=(null==n?void 0:n.baseUrl)||o.DEFAULT_API_BASE_URL,this.apiVersion=(null==n?void 0:n.apiVersion)||o.DEFAULT_API_VERSION}startSession(t,e){return i(this,void 0,void 0,(function*(){if(!this.sessionToken){if(!t)throw new r.ClientError("Persona configuration must be provided when using apiKey",r.ErrorCode.CLIENT_ERROR_CODE_VALIDATION_ERROR,400);this.sessionToken=yield this.unsafe_getSessionToken(t)}try{const n=yield fetch(`${this.getApiUrl()}/engine/session`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.sessionToken}`},body:JSON.stringify({personaConfig:t,sessionOptions:e,clientMetadata:o.CLIENT_METADATA})}),i=yield n.json();switch(n.status){case 200:case 201:return i;case 400:throw new r.ClientError("Invalid request to start session",r.ErrorCode.CLIENT_ERROR_CODE_VALIDATION_ERROR,400,{cause:i.message});case 401:throw new r.ClientError("Authentication failed when starting session",r.ErrorCode.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR,401,{cause:i.message});case 402:throw new r.ClientError("Please sign up for a plan to start a session",r.ErrorCode.CLIENT_ERROR_CODE_NO_PLAN_FOUND,402,{cause:i.message});case 403:throw new r.ClientError("Authentication failed when starting session",r.ErrorCode.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR,403,{cause:i.message});case 429:throw new r.ClientError("Out of credits, please upgrade your plan",r.ErrorCode.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED,429,{cause:i.message});case 503:throw new r.ClientError("There are no available personas, please try again later",r.ErrorCode.CLIENT_ERROR_CODE_SERVICE_BUSY,503,{cause:i.message});default:throw new r.ClientError("Unknown error when starting session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:i.message})}}catch(t){if(t instanceof r.ClientError)throw t;throw new r.ClientError("Failed to start session",r.ErrorCode.CLIENT_ERROR_CODE_SERVER_ERROR,500,{cause:t instanceof Error?t.message:String(t)})}}))}unsafe_getSessionToken(t){return i(this,void 0,void 0,(function*(){if(console.warn("Using unsecure method. This method should not be used in production."),!this.apiKey)throw new Error("No apiKey provided");let e={clientLabel:"js-sdk-api-key"};(0,s.isCustomPersonaConfig)(t)&&(e=Object.assign(Object.assign({},e),{personaConfig:t}));try{const t=yield fetch(`${this.getApiUrl()}/auth/session-token`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(e)});return(yield t.json()).sessionToken}catch(t){throw new Error("Failed to get session token")}}))}getApiUrl(){return`${this.baseUrl}${this.apiVersion}`}}},529:function(t,e){"use strict";var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.EngineApiRestClient=void 0,e.EngineApiRestClient=class{constructor(t,e){this.baseUrl=t,this.sessionId=e}sendTalkCommand(t){return n(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.baseUrl}/talk?session_id=${this.sessionId}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t})});if(!e.ok)throw new Error(`Failed to send talk command: ${e.status} ${e.statusText}`)}catch(t){throw console.error(t),new Error("EngineApiRestClient - sendTalkCommand: Failed to send talk command")}}))}}},259:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEventEmitter=void 0,e.InternalEventEmitter=class{constructor(){this.listeners={}}addListener(t,e){this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e)}removeListener(t,e){this.listeners[t]&&this.listeners[t].delete(e)}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach((t=>{t(...e)}))}}},462:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MessageHistoryClient=void 0;const i=n(170);e.MessageHistoryClient=class{constructor(t,e){this.messages=[],this.publicEventEmitter=t,this.internalEventEmitter=e,this.internalEventEmitter.addListener(i.InternalEvent.WEBRTC_CHAT_MESSAGE_RECEIVED,this.processWebRtcTextMessageEvent.bind(this))}webRtcTextMessageEventToMessageStreamEvent(t){return{id:`${t.role}::${t.message_id}`,content:t.content,role:t.role,endOfSpeech:t.end_of_speech,interrupted:t.interrupted}}processUserMessage(t){const e={id:t.id,content:t.content,role:t.role};this.messages.push(e)}processPersonaMessage(t){const e={id:t.id,content:t.content,role:t.role,interrupted:t.interrupted},n=this.messages.findIndex((t=>t.id===e.id));if(-1!==n){const t=this.messages[n];this.messages[n]=Object.assign(Object.assign({},t),{content:t.content+e.content,interrupted:t.interrupted||e.interrupted})}else this.messages.push(e)}processWebRtcTextMessageEvent(t){const e=this.webRtcTextMessageEventToMessageStreamEvent(t);switch(this.publicEventEmitter.emit(i.AnamEvent.MESSAGE_STREAM_EVENT_RECEIVED,e),e.role){case i.MessageRole.USER:this.processUserMessage(e);break;case i.MessageRole.PERSONA:this.processPersonaMessage(e)}e.endOfSpeech&&this.publicEventEmitter.emit(i.AnamEvent.MESSAGE_HISTORY_UPDATED,this.messages)}}},995:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PublicEventEmitter=void 0;const i=n(71),r=n(170);e.PublicEventEmitter=class{constructor(){this.listeners={}}addListener(t,e){this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e)}removeListener(t,e){this.listeners[t]&&this.listeners[t].delete(e)}emit(t,...e){t===r.AnamEvent.CONNECTION_ESTABLISHED&&(0,i.sendErrorMetric)(i.ClientMetricMeasurement.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED,"1"),t===r.AnamEvent.CONNECTION_CLOSED&&(0,i.sendErrorMetric)(i.ClientMetricMeasurement.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED,e[0]),this.listeners[t]&&this.listeners[t].forEach((t=>{t(...e)}))}}},279:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.SignallingClient=void 0;const r=n(985),o=n(170);e.SignallingClient=class{constructor(t,e,n,i){var r;if(this.stopSignal=!1,this.sendingBuffer=[],this.wsConnectionAttempts=0,this.socket=null,this.heartBeatIntervalRef=null,this.publicEventEmitter=n,this.internalEventEmitter=i,!t)throw new Error("Signalling Client: sessionId is required");this.sessionId=t;const{heartbeatIntervalSeconds:o,maxWsReconnectionAttempts:s,url:a}=e;if(this.heartbeatIntervalSeconds=o||5,this.maxWsReconnectionAttempts=s||5,!a.baseUrl)throw new Error("Signalling Client: baseUrl is required");const u=`${a.protocol||"https"}://${a.baseUrl}`;this.url=new URL(u),this.url.protocol="http"===a.protocol?"ws:":"wss:",a.port&&(this.url.port=a.port),this.url.pathname=null!==(r=a.signallingPath)&&void 0!==r?r:"/ws",this.url.searchParams.append("session_id",t)}stop(){this.stopSignal=!0,this.closeSocket()}connect(){return this.socket=new WebSocket(this.url.href),this.socket.onopen=this.onOpen.bind(this),this.socket.onclose=this.onClose.bind(this),this.socket.onerror=this.onError.bind(this),this.socket}sendOffer(t){return i(this,void 0,void 0,(function*(){const e={connectionDescription:t,userUid:this.sessionId},n={actionType:o.SignalMessageAction.OFFER,sessionId:this.sessionId,payload:e};this.sendSignalMessage(n)}))}sendIceCandidate(t){return i(this,void 0,void 0,(function*(){const e={actionType:o.SignalMessageAction.ICE_CANDIDATE,sessionId:this.sessionId,payload:t.toJSON()};this.sendSignalMessage(e)}))}sendSignalMessage(t){var e;if((null===(e=this.socket)||void 0===e?void 0:e.readyState)===WebSocket.OPEN)try{this.socket.send(JSON.stringify(t))}catch(t){console.error("SignallingClient - sendSignalMessage: error sending message",t)}else this.sendingBuffer.push(t)}sendTalkMessage(t){return i(this,void 0,void 0,(function*(){const e={actionType:o.SignalMessageAction.TALK_STREAM_INPUT,sessionId:this.sessionId,payload:t};this.sendSignalMessage(e)}))}closeSocket(){this.socket&&(this.socket.close(),this.socket=null),this.heartBeatIntervalRef&&(clearInterval(this.heartBeatIntervalRef),this.heartBeatIntervalRef=null)}onOpen(){return i(this,void 0,void 0,(function*(){if(!this.socket)throw new Error("SignallingClient - onOpen: socket is null");try{this.wsConnectionAttempts=0,this.flushSendingBuffer(),this.socket.onmessage=this.onMessage.bind(this),this.startSendingHeartBeats(),this.internalEventEmitter.emit(o.InternalEvent.WEB_SOCKET_OPEN)}catch(t){console.error("SignallingClient - onOpen: error in onOpen",t),this.publicEventEmitter.emit(o.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE)}}))}onClose(){return i(this,void 0,void 0,(function*(){this.wsConnectionAttempts+=1,this.stopSignal||(this.wsConnectionAttempts<=this.maxWsReconnectionAttempts?(this.socket=null,setTimeout((()=>{this.connect()}),100*this.wsConnectionAttempts)):(this.heartBeatIntervalRef&&(clearInterval(this.heartBeatIntervalRef),this.heartBeatIntervalRef=null),this.publicEventEmitter.emit(o.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE)))}))}onError(t){this.stopSignal||console.error("SignallingClient - onError: ",t)}flushSendingBuffer(){const t=[];this.sendingBuffer.length>0&&this.sendingBuffer.forEach((e=>{var n;(null===(n=this.socket)||void 0===n?void 0:n.readyState)===WebSocket.OPEN?this.socket.send(JSON.stringify(e)):t.push(e)})),this.sendingBuffer=t}onMessage(t){return i(this,void 0,void 0,(function*(){const e=JSON.parse(t.data);this.internalEventEmitter.emit(o.InternalEvent.SIGNAL_MESSAGE_RECEIVED,e)}))}startSendingHeartBeats(){if(!this.socket)throw new Error("SignallingClient - startSendingHeartBeats: socket is null");this.heartBeatIntervalRef&&console.warn("SignallingClient - startSendingHeartBeats: heartbeat interval already set");const t=1e3*this.heartbeatIntervalSeconds,e={actionType:o.SignalMessageAction.HEARTBEAT,sessionId:this.sessionId,payload:""},n=JSON.stringify(e);this.heartBeatIntervalRef=setInterval((()=>{var t;this.stopSignal||(null===(t=this.socket)||void 0===t?void 0:t.readyState)===WebSocket.OPEN&&this.socket.send(n)}),t)}}},577:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.StreamingClient=void 0;const r=n(985),o=n(958),s=n(170),a=n(711);e.StreamingClient=class{constructor(t,e,n,i){this.peerConnection=null,this.connectionReceivedAnswer=!1,this.remoteIceCandidateBuffer=[],this.inputAudioStream=null,this.dataChannel=null,this.videoElement=null,this.videoStream=null,this.audioStream=null,this.inputAudioState={isMuted:!1},this.publicEventEmitter=n,this.internalEventEmitter=i;const{inputAudio:r}=e;this.inputAudioState=r.inputAudioState,e.inputAudio.userProvidedMediaStream&&(this.inputAudioStream=e.inputAudio.userProvidedMediaStream),this.disableInputAudio=!0===e.inputAudio.disableInputAudio,this.internalEventEmitter.addListener(s.InternalEvent.WEB_SOCKET_OPEN,this.onSignallingClientConnected.bind(this)),this.internalEventEmitter.addListener(s.InternalEvent.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this)),this.iceServers=e.iceServers,this.signallingClient=new o.SignallingClient(t,e.signalling,this.publicEventEmitter,this.internalEventEmitter),this.engineApiRestClient=new o.EngineApiRestClient(e.engine.baseUrl,t),this.audioDeviceId=e.inputAudio.audioDeviceId}onInputAudioStateChange(t,e){t.isMuted!==e.isMuted&&(e.isMuted?this.muteAllAudioTracks():this.unmuteAllAudioTracks())}muteAllAudioTracks(){var t;null===(t=this.inputAudioStream)||void 0===t||t.getAudioTracks().forEach((t=>{t.enabled=!1}))}unmuteAllAudioTracks(){var t;null===(t=this.inputAudioStream)||void 0===t||t.getAudioTracks().forEach((t=>{t.enabled=!0}))}muteInputAudio(){const t=this.inputAudioState,e=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!0});return this.inputAudioState=e,this.onInputAudioStateChange(t,e),this.inputAudioState}unmuteInputAudio(){const t=this.inputAudioState,e=Object.assign(Object.assign({},this.inputAudioState),{isMuted:!1});return this.inputAudioState=e,this.onInputAudioStateChange(t,e),this.inputAudioState}getInputAudioState(){return this.inputAudioState}getPeerConnection(){return this.peerConnection}getInputAudioStream(){return this.inputAudioStream}getVideoStream(){return this.videoStream}getAudioStream(){return this.audioStream}sendDataMessage(t){this.dataChannel&&"open"===this.dataChannel.readyState&&this.dataChannel.send(t)}setMediaStreamTargetById(t){if(t){const e=document.getElementById(t);if(!e)throw new Error(`StreamingClient: video element with id ${t} not found`);this.videoElement=e}}startConnection(){try{if(this.peerConnection)return void console.error("StreamingClient - startConnection: peer connection already exists");this.signallingClient.connect()}catch(t){console.log("StreamingClient - startConnection: error",t),this.handleWebrtcFailure(t)}}stopConnection(){this.shutdown()}sendTalkCommand(t){return i(this,void 0,void 0,(function*(){if(!this.peerConnection)throw new Error("StreamingClient - sendTalkCommand: peer connection is null");yield this.engineApiRestClient.sendTalkCommand(t)}))}startTalkMessageStream(t){return t||(t=Math.random().toString(36).substring(2,15)),new a.TalkMessageStream(t,this.internalEventEmitter,this.signallingClient)}initPeerConnection(){return i(this,void 0,void 0,(function*(){this.peerConnection=new RTCPeerConnection({iceServers:this.iceServers}),this.peerConnection.onicecandidate=this.onIceCandidate.bind(this),this.peerConnection.oniceconnectionstatechange=this.onIceConnectionStateChange.bind(this),this.peerConnection.onconnectionstatechange=this.onConnectionStateChange.bind(this),this.peerConnection.addEventListener("track",this.onTrackEventHandler.bind(this)),yield this.setupDataChannels(),this.peerConnection.addTransceiver("video",{direction:"recvonly"}),this.disableInputAudio?this.peerConnection.addTransceiver("audio",{direction:"recvonly"}):this.peerConnection.addTransceiver("audio",{direction:"sendrecv"})}))}onSignalMessage(t){return i(this,void 0,void 0,(function*(){if(this.peerConnection)switch(t.actionType){case s.SignalMessageAction.ANSWER:const e=t.payload;yield this.peerConnection.setRemoteDescription(e),this.connectionReceivedAnswer=!0,this.flushRemoteIceCandidateBuffer();break;case s.SignalMessageAction.ICE_CANDIDATE:const n=t.payload,i=new RTCIceCandidate(n);this.connectionReceivedAnswer?yield this.peerConnection.addIceCandidate(i):this.remoteIceCandidateBuffer.push(i);break;case s.SignalMessageAction.END_SESSION:const o=t.payload;console.log("StreamingClient - onSignalMessage: reason",o),this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_NORMAL),this.shutdown();break;case s.SignalMessageAction.WARNING:const a=t.payload;console.warn("Warning received from server: "+a),this.publicEventEmitter.emit(s.AnamEvent.SERVER_WARNING,a);break;case s.SignalMessageAction.TALK_STREAM_INTERRUPTED:const u=t.payload;this.publicEventEmitter.emit(s.AnamEvent.TALK_STREAM_INTERRUPTED,u.correlationId);break;case s.SignalMessageAction.SESSION_READY:const l=t.sessionId;this.publicEventEmitter.emit(s.AnamEvent.SESSION_READY,l);break;default:console.error("StreamingClient - onSignalMessage: unknown signal message action type. Is your anam-sdk version up to date?",t)}else console.error("StreamingClient - onSignalMessage: peerConnection is not initialized")}))}onSignallingClientConnected(){return i(this,void 0,void 0,(function*(){if(!this.peerConnection)try{yield this.initPeerConnectionAndSendOffer()}catch(t){console.error("StreamingClient - onSignallingClientConnected: Error initializing peer connection",t),this.handleWebrtcFailure(t)}}))}flushRemoteIceCandidateBuffer(){this.remoteIceCandidateBuffer.forEach((t=>{var e;null===(e=this.peerConnection)||void 0===e||e.addIceCandidate(t)})),this.remoteIceCandidateBuffer=[]}onIceCandidate(t){t.candidate&&this.signallingClient.sendIceCandidate(t.candidate)}onIceConnectionStateChange(){var t,e;"connected"!==(null===(t=this.peerConnection)||void 0===t?void 0:t.iceConnectionState)&&"completed"!==(null===(e=this.peerConnection)||void 0===e?void 0:e.iceConnectionState)||this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_ESTABLISHED)}onConnectionStateChange(){var t;"closed"===(null===(t=this.peerConnection)||void 0===t?void 0:t.connectionState)&&(console.error("StreamingClient - onConnectionStateChange: Connection closed"),this.handleWebrtcFailure("The connection to our servers was lost. Please try again."))}handleWebrtcFailure(t){console.error({message:"StreamingClient - handleWebrtcFailure: ",err:t}),"NotAllowedError"===t.name&&"Permission denied"===t.message?this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED):this.publicEventEmitter.emit(s.AnamEvent.CONNECTION_CLOSED,r.CONNECTION_CLOSED_CODE_WEBRTC_FAILURE);try{this.stopConnection()}catch(t){console.error("StreamingClient - handleWebrtcFailure: error stopping connection",t)}}onTrackEventHandler(t){if("video"===t.track.kind){if(this.videoStream=t.streams[0],this.publicEventEmitter.emit(s.AnamEvent.VIDEO_STREAM_STARTED,this.videoStream),this.videoElement){this.videoElement.srcObject=this.videoStream;const t=this.videoElement.requestVideoFrameCallback((()=>{var e;null===(e=this.videoElement)||void 0===e||e.cancelVideoFrameCallback(t),this.publicEventEmitter.emit(s.AnamEvent.VIDEO_PLAY_STARTED)}))}}else"audio"===t.track.kind&&(this.audioStream=t.streams[0],this.publicEventEmitter.emit(s.AnamEvent.AUDIO_STREAM_STARTED,this.audioStream))}setupDataChannels(){return i(this,void 0,void 0,(function*(){if(!this.peerConnection)return void console.error("StreamingClient - setupDataChannels: peer connection is not initialized");if(!this.disableInputAudio){if(this.inputAudioStream){if(!this.inputAudioStream.getAudioTracks().length)throw new Error("StreamingClient - setupDataChannels: user provided stream does not have audio tracks")}else{const t={echoCancellation:!0};this.audioDeviceId&&(t.deviceId={exact:this.audioDeviceId}),this.inputAudioStream=yield navigator.mediaDevices.getUserMedia({audio:t})}this.inputAudioState.isMuted&&this.muteAllAudioTracks();const t=this.inputAudioStream.getAudioTracks()[0];this.peerConnection.addTrack(t,this.inputAudioStream),this.publicEventEmitter.emit(s.AnamEvent.INPUT_AUDIO_STREAM_STARTED,this.inputAudioStream)}const t=this.peerConnection.createDataChannel("chat",{ordered:!0});t.onopen=()=>{this.dataChannel=null!=t?t:null},t.onclose=()=>{},t.onmessage=t=>{const e=JSON.parse(t.data);this.internalEventEmitter.emit(s.InternalEvent.WEBRTC_CHAT_MESSAGE_RECEIVED,e)}}))}initPeerConnectionAndSendOffer(){return i(this,void 0,void 0,(function*(){if(yield this.initPeerConnection(),this.peerConnection){try{const t=yield this.peerConnection.createOffer();yield this.peerConnection.setLocalDescription(t)}catch(t){console.error("StreamingClient - initPeerConnectionAndSendOffer: error creating offer",t)}if(!this.peerConnection.localDescription)throw new Error("StreamingClient - initPeerConnectionAndSendOffer: local description is null");yield this.signallingClient.sendOffer(this.peerConnection.localDescription)}else console.error("StreamingClient - initPeerConnectionAndSendOffer: peer connection is not initialized")}))}shutdown(){try{this.inputAudioStream&&this.inputAudioStream.getTracks().forEach((t=>{t.stop()})),this.inputAudioStream=null}catch(t){console.error("StreamingClient - shutdown: error stopping input audio stream",t)}try{this.signallingClient.stop()}catch(t){console.error("StreamingClient - shutdown: error stopping signallilng",t)}try{this.peerConnection&&"closed"!==this.peerConnection.connectionState&&(this.peerConnection.onconnectionstatechange=null,this.peerConnection.close(),this.peerConnection=null)}catch(t){console.error("StreamingClient - shutdown: error closing peer connection",t)}}}},958:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StreamingClient=e.PublicEventEmitter=e.MessageHistoryClient=e.InternalEventEmitter=e.EngineApiRestClient=e.CoreApiRestClient=e.SignallingClient=void 0;var i=n(279);Object.defineProperty(e,"SignallingClient",{enumerable:!0,get:function(){return i.SignallingClient}});var r=n(18);Object.defineProperty(e,"CoreApiRestClient",{enumerable:!0,get:function(){return r.CoreApiRestClient}});var o=n(529);Object.defineProperty(e,"EngineApiRestClient",{enumerable:!0,get:function(){return o.EngineApiRestClient}});var s=n(259);Object.defineProperty(e,"InternalEventEmitter",{enumerable:!0,get:function(){return s.InternalEventEmitter}});var a=n(462);Object.defineProperty(e,"MessageHistoryClient",{enumerable:!0,get:function(){return a.MessageHistoryClient}});var u=n(995);Object.defineProperty(e,"PublicEventEmitter",{enumerable:!0,get:function(){return u.PublicEventEmitter}});var l=n(577);Object.defineProperty(e,"StreamingClient",{enumerable:!0,get:function(){return l.StreamingClient}})},672:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isCustomPersonaConfig=void 0,e.isCustomPersonaConfig=function(t){return"brainType"in t}},711:function(t,e,n){"use strict";var i=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((i=i.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.TalkMessageStream=void 0;const r=n(170),o=n(322);e.TalkMessageStream=class{constructor(t,e,n){this.state=o.TalkMessageStreamState.UNSTARTED,this.correlationId=t,this.internalEventEmitter=e,this.signallingClient=n,this.internalEventEmitter.addListener(r.InternalEvent.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this))}onDeactivate(){this.internalEventEmitter.removeListener(r.InternalEvent.SIGNAL_MESSAGE_RECEIVED,this.onSignalMessage.bind(this))}onSignalMessage(t){return i(this,void 0,void 0,(function*(){t.actionType===r.SignalMessageAction.TALK_STREAM_INTERRUPTED&&t.payload.correlationId===this.correlationId&&(this.state=o.TalkMessageStreamState.INTERRUPTED,this.onDeactivate())}))}endMessage(){return i(this,void 0,void 0,(function*(){if(this.state===o.TalkMessageStreamState.ENDED)return void console.warn("Talk stream is already ended via end of speech. No need to call endMessage.");if(this.state!==o.TalkMessageStreamState.STREAMING)return void console.warn("Talk stream is not active state: "+this.state);const t={content:"",startOfSpeech:!1,endOfSpeech:!0,correlationId:this.correlationId};yield this.signallingClient.sendTalkMessage(t),this.state=o.TalkMessageStreamState.ENDED,this.onDeactivate()}))}streamMessageChunk(t,e){return i(this,void 0,void 0,(function*(){if(this.state!==o.TalkMessageStreamState.STREAMING&&this.state!==o.TalkMessageStreamState.UNSTARTED)throw new Error("Talk stream is not in an active state: "+this.state);const n={content:t,startOfSpeech:this.state===o.TalkMessageStreamState.UNSTARTED,endOfSpeech:e,correlationId:this.correlationId};this.state=e?o.TalkMessageStreamState.ENDED:o.TalkMessageStreamState.STREAMING,this.state===o.TalkMessageStreamState.ENDED&&this.onDeactivate(),yield this.signallingClient.sendTalkMessage(n)}))}getCorrelationId(){return this.correlationId}isActive(){return this.state===o.TalkMessageStreamState.STREAMING||this.state===o.TalkMessageStreamState.UNSTARTED}getState(){return this.state}}},322:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.TalkMessageStreamState=void 0,function(t){t[t.UNSTARTED=0]="UNSTARTED",t[t.STREAMING=1]="STREAMING",t[t.INTERRUPTED=2]="INTERRUPTED",t[t.ENDED=3]="ENDED"}(n||(e.TalkMessageStreamState=n={}))},878:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEvent=e.AnamEvent=void 0;var i=n(21);Object.defineProperty(e,"AnamEvent",{enumerable:!0,get:function(){return i.AnamEvent}});var r=n(645);Object.defineProperty(e,"InternalEvent",{enumerable:!0,get:function(){return r.InternalEvent}})},645:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEvent=void 0,function(t){t.WEB_SOCKET_OPEN="WEB_SOCKET_OPEN",t.SIGNAL_MESSAGE_RECEIVED="SIGNAL_MESSAGE_RECEIVED",t.WEBRTC_CHAT_MESSAGE_RECEIVED="WEBRTC_CHAT_MESSAGE_RECEIVED"}(n||(e.InternalEvent=n={}))},21:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.AnamEvent=void 0,function(t){t.MESSAGE_HISTORY_UPDATED="MESSAGE_HISTORY_UPDATED",t.MESSAGE_STREAM_EVENT_RECEIVED="MESSAGE_STREAM_EVENT_RECEIVED",t.CONNECTION_ESTABLISHED="CONNECTION_ESTABLISHED",t.CONNECTION_CLOSED="CONNECTION_CLOSED",t.INPUT_AUDIO_STREAM_STARTED="INPUT_AUDIO_STREAM_STARTED",t.VIDEO_STREAM_STARTED="VIDEO_STREAM_STARTED",t.VIDEO_PLAY_STARTED="VIDEO_PLAY_STARTED",t.AUDIO_STREAM_STARTED="AUDIO_STREAM_STARTED",t.TALK_STREAM_INTERRUPTED="TALK_STREAM_INTERRUPTED",t.SESSION_READY="SESSION_READY",t.SERVER_WARNING="SERVER_WARNING"}(n||(e.AnamEvent=n={}))},170:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.InternalEvent=e.AnamEvent=e.MessageRole=e.SignalMessageAction=void 0;var i=n(295);Object.defineProperty(e,"SignalMessageAction",{enumerable:!0,get:function(){return i.SignalMessageAction}});var r=n(822);Object.defineProperty(e,"MessageRole",{enumerable:!0,get:function(){return r.MessageRole}});var o=n(878);Object.defineProperty(e,"AnamEvent",{enumerable:!0,get:function(){return o.AnamEvent}});var s=n(878);Object.defineProperty(e,"InternalEvent",{enumerable:!0,get:function(){return s.InternalEvent}})},273:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.MessageRole=void 0,function(t){t.USER="user",t.PERSONA="persona"}(n||(e.MessageRole=n={}))},822:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.MessageRole=void 0;var i=n(273);Object.defineProperty(e,"MessageRole",{enumerable:!0,get:function(){return i.MessageRole}})},656:(t,e)=>{"use strict";var n;Object.defineProperty(e,"__esModule",{value:!0}),e.SignalMessageAction=void 0,function(t){t.OFFER="offer",t.ANSWER="answer",t.ICE_CANDIDATE="icecandidate",t.END_SESSION="endsession",t.HEARTBEAT="heartbeat",t.WARNING="warning",t.TALK_STREAM_INTERRUPTED="talkinputstreaminterrupted",t.TALK_STREAM_INPUT="talkstream",t.SESSION_READY="sessionready"}(n||(e.SignalMessageAction=n={}))},295:(t,e,n)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SignalMessageAction=void 0;var i=n(656);Object.defineProperty(e,"SignalMessageAction",{enumerable:!0,get:function(){return i.SignalMessageAction}})}},e={},function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(440);var t,e}));
|