@onlive.ai/common-121 0.2.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +151 -0
  2. package/package.json +39 -0
  3. package/services/audio.service.cjs +75 -0
  4. package/services/audio.service.d.cts +14 -0
  5. package/services/audio.service.d.ts +14 -0
  6. package/services/audio.service.js +52 -0
  7. package/services/firebase/firebase-api.cjs +108 -0
  8. package/services/firebase/firebase-api.d.cts +54 -0
  9. package/services/firebase/firebase-api.d.ts +54 -0
  10. package/services/firebase/firebase-api.js +105 -0
  11. package/services/firebase/firebase.service.cjs +193 -0
  12. package/services/firebase/firebase.service.d.cts +40 -0
  13. package/services/firebase/firebase.service.d.ts +40 -0
  14. package/services/firebase/firebase.service.js +190 -0
  15. package/services/livekit.service.cjs +353 -0
  16. package/services/livekit.service.d.cts +131 -0
  17. package/services/livekit.service.d.ts +131 -0
  18. package/services/livekit.service.js +329 -0
  19. package/services/request.provider.cjs +48 -0
  20. package/services/request.provider.d.cts +27 -0
  21. package/services/request.provider.d.ts +27 -0
  22. package/services/request.provider.js +22 -0
  23. package/themes/dark.cjs +433 -0
  24. package/themes/dark.d.cts +5 -0
  25. package/themes/dark.d.ts +5 -0
  26. package/themes/dark.js +408 -0
  27. package/themes/light.cjs +433 -0
  28. package/themes/light.d.cts +5 -0
  29. package/themes/light.d.ts +5 -0
  30. package/themes/light.js +408 -0
  31. package/types/tracking-options.cjs +18 -0
  32. package/types/tracking-options.d.cts +27 -0
  33. package/types/tracking-options.d.ts +27 -0
  34. package/types/tracking-options.js +0 -0
  35. package/types/window-context.cjs +18 -0
  36. package/types/window-context.d.cts +8 -0
  37. package/types/window-context.d.ts +8 -0
  38. package/types/window-context.js +0 -0
  39. package/utils/adopt-styles.cjs +66 -0
  40. package/utils/adopt-styles.d.cts +5 -0
  41. package/utils/adopt-styles.d.ts +5 -0
  42. package/utils/adopt-styles.js +41 -0
  43. package/utils/browser-preferences.cjs +67 -0
  44. package/utils/browser-preferences.d.cts +18 -0
  45. package/utils/browser-preferences.d.ts +18 -0
  46. package/utils/browser-preferences.js +42 -0
  47. package/utils/classify-media.cjs +38 -0
  48. package/utils/classify-media.d.cts +9 -0
  49. package/utils/classify-media.d.ts +9 -0
  50. package/utils/classify-media.js +13 -0
  51. package/utils/decorators.cjs +53 -0
  52. package/utils/decorators.d.cts +34 -0
  53. package/utils/decorators.d.ts +34 -0
  54. package/utils/decorators.js +28 -0
  55. package/utils/detected-lang.cjs +47 -0
  56. package/utils/detected-lang.d.cts +10 -0
  57. package/utils/detected-lang.d.ts +10 -0
  58. package/utils/detected-lang.js +22 -0
  59. package/utils/fullscreen.cjs +52 -0
  60. package/utils/fullscreen.d.cts +16 -0
  61. package/utils/fullscreen.d.ts +16 -0
  62. package/utils/fullscreen.js +26 -0
  63. package/utils/insert-script.cjs +55 -0
  64. package/utils/insert-script.d.cts +29 -0
  65. package/utils/insert-script.d.ts +29 -0
  66. package/utils/insert-script.js +30 -0
  67. package/utils/markdown.cjs +103 -0
  68. package/utils/markdown.d.cts +12 -0
  69. package/utils/markdown.d.ts +12 -0
  70. package/utils/markdown.js +68 -0
  71. package/utils/merge.cjs +47 -0
  72. package/utils/merge.d.cts +23 -0
  73. package/utils/merge.d.ts +23 -0
  74. package/utils/merge.js +22 -0
  75. package/utils/multiband-track-volume.cjs +90 -0
  76. package/utils/multiband-track-volume.d.cts +27 -0
  77. package/utils/multiband-track-volume.d.ts +27 -0
  78. package/utils/multiband-track-volume.js +65 -0
  79. package/utils/onlive-url-params.cjs +38 -0
  80. package/utils/onlive-url-params.d.cts +14 -0
  81. package/utils/onlive-url-params.d.ts +14 -0
  82. package/utils/onlive-url-params.js +13 -0
  83. package/utils/pretty-distance.cjs +45 -0
  84. package/utils/pretty-distance.d.cts +46 -0
  85. package/utils/pretty-distance.d.ts +46 -0
  86. package/utils/pretty-distance.js +20 -0
  87. package/utils/random-string.cjs +37 -0
  88. package/utils/random-string.d.cts +9 -0
  89. package/utils/random-string.d.ts +9 -0
  90. package/utils/random-string.js +12 -0
  91. package/utils/resource-type.cjs +50 -0
  92. package/utils/resource-type.d.cts +16 -0
  93. package/utils/resource-type.d.ts +16 -0
  94. package/utils/resource-type.js +24 -0
  95. package/utils/safe-html.cjs +112 -0
  96. package/utils/safe-html.d.cts +12 -0
  97. package/utils/safe-html.d.ts +12 -0
  98. package/utils/safe-html.js +77 -0
  99. package/utils/sanitize.cjs +94 -0
  100. package/utils/sanitize.d.cts +11 -0
  101. package/utils/sanitize.d.ts +11 -0
  102. package/utils/sanitize.js +59 -0
  103. package/utils/spread.cjs +70 -0
  104. package/utils/spread.d.cts +14 -0
  105. package/utils/spread.d.ts +14 -0
  106. package/utils/spread.js +47 -0
  107. package/utils/watch.cjs +54 -0
  108. package/utils/watch.d.cts +28 -0
  109. package/utils/watch.d.ts +28 -0
  110. package/utils/watch.js +29 -0
  111. package/vite-env.d.ts +22 -0
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+
22
+ // services/firebase/firebase.service.ts
23
+ var firebase_service_exports = {};
24
+ __export(firebase_service_exports, {
25
+ FirebaseService: () => FirebaseService
26
+ });
27
+ module.exports = __toCommonJS(firebase_service_exports);
28
+ var import_tracker = require("@onlive.ai/tracker");
29
+
30
+ // services/firebase/firebase-api.ts
31
+ var import_app = require("firebase/app");
32
+ var import_database = require("firebase/database");
33
+ var FirebaseApi = class {
34
+ constructor(options) {
35
+ __publicField(this, "db");
36
+ /** Other listeners... */
37
+ __publicField(this, "onChildChanged", (path, cb) => (0, import_database.onChildChanged)(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
38
+ __publicField(this, "onChildRemoved", (path, cb) => (0, import_database.onChildRemoved)(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
39
+ const app = (0, import_app.initializeApp)(options.config);
40
+ this.db = (0, import_database.getDatabase)(app);
41
+ }
42
+ /** Get a DatabaseReference */
43
+ ref(path) {
44
+ return (0, import_database.ref)(this.db, path);
45
+ }
46
+ /** Read once */
47
+ async getOnce(path) {
48
+ const snap = await (0, import_database.get)(this.ref(path));
49
+ return snap.exists() ? snap.val() : null;
50
+ }
51
+ /** Listen to value changes */
52
+ onValue(path, cb) {
53
+ return (0, import_database.onValue)(
54
+ this.ref(path),
55
+ (snap) => cb(snap.key ?? "", snap.val(), snap),
56
+ (err) => console.error("onValue error", err)
57
+ );
58
+ }
59
+ /** Listen to child-added */
60
+ onChildAdded(path, cb) {
61
+ return (0, import_database.onChildAdded)(
62
+ this.ref(path),
63
+ (snap) => cb(snap.key, snap.val(), snap),
64
+ (err) => console.error("onChildAdded error", err)
65
+ );
66
+ }
67
+ /** Write/overwrite a node */
68
+ write(path, data) {
69
+ return (0, import_database.set)(this.ref(path), data);
70
+ }
71
+ /** Update (merge) a node */
72
+ update(path, data) {
73
+ return (0, import_database.update)(this.ref(path), data);
74
+ }
75
+ /** Remove a node */
76
+ remove(path) {
77
+ return (0, import_database.remove)(this.ref(path));
78
+ }
79
+ /** Push a child with generated key */
80
+ async push(path, data) {
81
+ const newRef = (0, import_database.push)(this.ref(path));
82
+ await (0, import_database.set)(newRef, data);
83
+ return newRef.key;
84
+ }
85
+ /** onDisconnect write */
86
+ onDisconnectUpdate(path, data) {
87
+ return (0, import_database.onDisconnect)(this.ref(path)).update(data);
88
+ }
89
+ /** Cancel onDisconnect operations */
90
+ cancelOnDisconnect(path) {
91
+ return (0, import_database.onDisconnect)(this.ref(path)).cancel();
92
+ }
93
+ /** Run a transaction */
94
+ transaction(path, updateFn) {
95
+ return (0, import_database.runTransaction)(this.ref(path), (cur) => updateFn(cur));
96
+ }
97
+ /** Build a query */
98
+ query(path, opts = {}) {
99
+ let q = this.ref(path);
100
+ if (opts.orderBy === "child" && opts.childKey) q = (0, import_database.query)(q, (0, import_database.orderByChild)(opts.childKey));
101
+ if (opts.orderBy === "key") q = (0, import_database.query)(q, (0, import_database.orderByKey)());
102
+ if (opts.orderBy === "value") q = (0, import_database.query)(q, (0, import_database.orderByValue)());
103
+ if (opts.limitFirst != null) q = (0, import_database.query)(q, (0, import_database.limitToFirst)(opts.limitFirst));
104
+ if (opts.limitLast != null) q = (0, import_database.query)(q, (0, import_database.limitToLast)(opts.limitLast));
105
+ return q;
106
+ }
107
+ };
108
+
109
+ // services/firebase/firebase.service.ts
110
+ var FirebaseService = class {
111
+ constructor(firebaseOptions, orgId) {
112
+ this.firebaseOptions = firebaseOptions;
113
+ this.orgId = orgId;
114
+ __publicField(this, "presencePath");
115
+ __publicField(this, "callsPath");
116
+ __publicField(this, "api");
117
+ this.api = new FirebaseApi({ config: this.firebaseOptions });
118
+ this.presencePath = `orgs/${this.orgId}/presence`;
119
+ this.callsPath = `orgs/${this.orgId}/calls`;
120
+ }
121
+ // Presence methods
122
+ getPresencePath(agentId) {
123
+ return `${this.presencePath}/${agentId}`;
124
+ }
125
+ async setAgentOnline(agentId, displayName) {
126
+ await this.api.write(this.getPresencePath(agentId), {
127
+ status: "online",
128
+ lastSeen: (/* @__PURE__ */ new Date()).toISOString(),
129
+ displayName
130
+ });
131
+ await this.api.onDisconnectUpdate(this.getPresencePath(agentId), {
132
+ status: "offline",
133
+ lastSeen: (/* @__PURE__ */ new Date()).toISOString()
134
+ });
135
+ }
136
+ onPresenceChange(cb) {
137
+ return this.api.onChildChanged(this.presencePath, (key, data) => cb(key, data));
138
+ }
139
+ onPresenceAgentChange(agentId, cb) {
140
+ return this.api.onValue(
141
+ this.getPresencePath(agentId),
142
+ (key, data) => cb(key, data)
143
+ );
144
+ }
145
+ // Requests methods
146
+ async createRequest(request) {
147
+ const id = import_tracker.Generator.uuid();
148
+ await this.api.write(`${this.callsPath}/${id}`, {
149
+ ...request,
150
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
151
+ status: "pending",
152
+ assignedAgentId: null
153
+ });
154
+ this.api.onDisconnectUpdate(`${this.callsPath}/${id}`, {
155
+ status: "disconnected"
156
+ });
157
+ return id;
158
+ }
159
+ onNewRequest(cb) {
160
+ return this.api.onChildAdded(
161
+ this.callsPath,
162
+ (key, data) => cb(key, { ...data, id: key })
163
+ );
164
+ }
165
+ onRequestChange(cb) {
166
+ return this.api.onChildChanged(
167
+ this.callsPath,
168
+ (key, data) => cb(key, { ...data, id: key })
169
+ );
170
+ }
171
+ onRequestRemoved(cb) {
172
+ return this.api.onChildRemoved(this.callsPath, (key) => cb(key));
173
+ }
174
+ async acceptRequest(requestId) {
175
+ await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
176
+ return this.api.update(`${this.callsPath}/${requestId}`, {
177
+ status: "accepted"
178
+ });
179
+ }
180
+ async cancelOnDisconnect(requestId) {
181
+ await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
182
+ }
183
+ async cancelRequest(requestId) {
184
+ await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
185
+ return this.api.update(`${this.callsPath}/${requestId}`, {
186
+ status: "cancelled"
187
+ });
188
+ }
189
+ };
190
+ // Annotate the CommonJS export names for ESM import in node:
191
+ 0 && (module.exports = {
192
+ FirebaseService
193
+ });
@@ -0,0 +1,40 @@
1
+ import * as firebase_database from 'firebase/database';
2
+ import { FirebaseConfig } from './firebase-api.cjs';
3
+
4
+ interface Call {
5
+ guestId: string;
6
+ agentId: string;
7
+ roomName: string;
8
+ startedAt: string;
9
+ endedAt: string | null;
10
+ }
11
+ interface Request {
12
+ guestId: string;
13
+ guestName?: string;
14
+ createdAt: string;
15
+ roomId?: string;
16
+ status: "pending" | "accepted" | "cancelled" | "not_response";
17
+ assignedAgentId: string | null;
18
+ id: string;
19
+ }
20
+ declare class FirebaseService {
21
+ private firebaseOptions;
22
+ private orgId;
23
+ private presencePath;
24
+ private callsPath;
25
+ private api;
26
+ constructor(firebaseOptions: FirebaseConfig, orgId: string);
27
+ private getPresencePath;
28
+ setAgentOnline(agentId: string, displayName?: string): Promise<void>;
29
+ onPresenceChange(cb: (agentId: string, data: any) => void): firebase_database.Unsubscribe;
30
+ onPresenceAgentChange(agentId: string, cb: (agentId: string, data: any) => void): firebase_database.Unsubscribe;
31
+ createRequest(request: Omit<Request, "status" | "createdAt">): Promise<string>;
32
+ onNewRequest(cb: (id: string, req: Request) => void): firebase_database.Unsubscribe;
33
+ onRequestChange(cb: (id: string, req: Request) => void): firebase_database.Unsubscribe;
34
+ onRequestRemoved(cb: (id: string) => void): firebase_database.Unsubscribe;
35
+ acceptRequest(requestId: string): Promise<void>;
36
+ cancelOnDisconnect(requestId: string): Promise<void>;
37
+ cancelRequest(requestId: string): Promise<void>;
38
+ }
39
+
40
+ export { type Call, FirebaseService, type Request };
@@ -0,0 +1,40 @@
1
+ import * as firebase_database from 'firebase/database';
2
+ import { FirebaseConfig } from './firebase-api.js';
3
+
4
+ interface Call {
5
+ guestId: string;
6
+ agentId: string;
7
+ roomName: string;
8
+ startedAt: string;
9
+ endedAt: string | null;
10
+ }
11
+ interface Request {
12
+ guestId: string;
13
+ guestName?: string;
14
+ createdAt: string;
15
+ roomId?: string;
16
+ status: "pending" | "accepted" | "cancelled" | "not_response";
17
+ assignedAgentId: string | null;
18
+ id: string;
19
+ }
20
+ declare class FirebaseService {
21
+ private firebaseOptions;
22
+ private orgId;
23
+ private presencePath;
24
+ private callsPath;
25
+ private api;
26
+ constructor(firebaseOptions: FirebaseConfig, orgId: string);
27
+ private getPresencePath;
28
+ setAgentOnline(agentId: string, displayName?: string): Promise<void>;
29
+ onPresenceChange(cb: (agentId: string, data: any) => void): firebase_database.Unsubscribe;
30
+ onPresenceAgentChange(agentId: string, cb: (agentId: string, data: any) => void): firebase_database.Unsubscribe;
31
+ createRequest(request: Omit<Request, "status" | "createdAt">): Promise<string>;
32
+ onNewRequest(cb: (id: string, req: Request) => void): firebase_database.Unsubscribe;
33
+ onRequestChange(cb: (id: string, req: Request) => void): firebase_database.Unsubscribe;
34
+ onRequestRemoved(cb: (id: string) => void): firebase_database.Unsubscribe;
35
+ acceptRequest(requestId: string): Promise<void>;
36
+ cancelOnDisconnect(requestId: string): Promise<void>;
37
+ cancelRequest(requestId: string): Promise<void>;
38
+ }
39
+
40
+ export { type Call, FirebaseService, type Request };
@@ -0,0 +1,190 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+
5
+ // services/firebase/firebase.service.ts
6
+ import { Generator } from "@onlive.ai/tracker";
7
+
8
+ // services/firebase/firebase-api.ts
9
+ import { initializeApp } from "firebase/app";
10
+ import {
11
+ query as dbQuery,
12
+ get,
13
+ getDatabase,
14
+ limitToFirst,
15
+ limitToLast,
16
+ onChildAdded,
17
+ onChildChanged,
18
+ onChildRemoved,
19
+ onDisconnect,
20
+ onValue,
21
+ orderByChild,
22
+ orderByKey,
23
+ orderByValue,
24
+ push,
25
+ ref,
26
+ remove,
27
+ runTransaction,
28
+ set,
29
+ update
30
+ } from "firebase/database";
31
+ var FirebaseApi = class {
32
+ constructor(options) {
33
+ __publicField(this, "db");
34
+ /** Other listeners... */
35
+ __publicField(this, "onChildChanged", (path, cb) => onChildChanged(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
36
+ __publicField(this, "onChildRemoved", (path, cb) => onChildRemoved(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
37
+ const app = initializeApp(options.config);
38
+ this.db = getDatabase(app);
39
+ }
40
+ /** Get a DatabaseReference */
41
+ ref(path) {
42
+ return ref(this.db, path);
43
+ }
44
+ /** Read once */
45
+ async getOnce(path) {
46
+ const snap = await get(this.ref(path));
47
+ return snap.exists() ? snap.val() : null;
48
+ }
49
+ /** Listen to value changes */
50
+ onValue(path, cb) {
51
+ return onValue(
52
+ this.ref(path),
53
+ (snap) => cb(snap.key ?? "", snap.val(), snap),
54
+ (err) => console.error("onValue error", err)
55
+ );
56
+ }
57
+ /** Listen to child-added */
58
+ onChildAdded(path, cb) {
59
+ return onChildAdded(
60
+ this.ref(path),
61
+ (snap) => cb(snap.key, snap.val(), snap),
62
+ (err) => console.error("onChildAdded error", err)
63
+ );
64
+ }
65
+ /** Write/overwrite a node */
66
+ write(path, data) {
67
+ return set(this.ref(path), data);
68
+ }
69
+ /** Update (merge) a node */
70
+ update(path, data) {
71
+ return update(this.ref(path), data);
72
+ }
73
+ /** Remove a node */
74
+ remove(path) {
75
+ return remove(this.ref(path));
76
+ }
77
+ /** Push a child with generated key */
78
+ async push(path, data) {
79
+ const newRef = push(this.ref(path));
80
+ await set(newRef, data);
81
+ return newRef.key;
82
+ }
83
+ /** onDisconnect write */
84
+ onDisconnectUpdate(path, data) {
85
+ return onDisconnect(this.ref(path)).update(data);
86
+ }
87
+ /** Cancel onDisconnect operations */
88
+ cancelOnDisconnect(path) {
89
+ return onDisconnect(this.ref(path)).cancel();
90
+ }
91
+ /** Run a transaction */
92
+ transaction(path, updateFn) {
93
+ return runTransaction(this.ref(path), (cur) => updateFn(cur));
94
+ }
95
+ /** Build a query */
96
+ query(path, opts = {}) {
97
+ let q = this.ref(path);
98
+ if (opts.orderBy === "child" && opts.childKey) q = dbQuery(q, orderByChild(opts.childKey));
99
+ if (opts.orderBy === "key") q = dbQuery(q, orderByKey());
100
+ if (opts.orderBy === "value") q = dbQuery(q, orderByValue());
101
+ if (opts.limitFirst != null) q = dbQuery(q, limitToFirst(opts.limitFirst));
102
+ if (opts.limitLast != null) q = dbQuery(q, limitToLast(opts.limitLast));
103
+ return q;
104
+ }
105
+ };
106
+
107
+ // services/firebase/firebase.service.ts
108
+ var FirebaseService = class {
109
+ constructor(firebaseOptions, orgId) {
110
+ this.firebaseOptions = firebaseOptions;
111
+ this.orgId = orgId;
112
+ __publicField(this, "presencePath");
113
+ __publicField(this, "callsPath");
114
+ __publicField(this, "api");
115
+ this.api = new FirebaseApi({ config: this.firebaseOptions });
116
+ this.presencePath = `orgs/${this.orgId}/presence`;
117
+ this.callsPath = `orgs/${this.orgId}/calls`;
118
+ }
119
+ // Presence methods
120
+ getPresencePath(agentId) {
121
+ return `${this.presencePath}/${agentId}`;
122
+ }
123
+ async setAgentOnline(agentId, displayName) {
124
+ await this.api.write(this.getPresencePath(agentId), {
125
+ status: "online",
126
+ lastSeen: (/* @__PURE__ */ new Date()).toISOString(),
127
+ displayName
128
+ });
129
+ await this.api.onDisconnectUpdate(this.getPresencePath(agentId), {
130
+ status: "offline",
131
+ lastSeen: (/* @__PURE__ */ new Date()).toISOString()
132
+ });
133
+ }
134
+ onPresenceChange(cb) {
135
+ return this.api.onChildChanged(this.presencePath, (key, data) => cb(key, data));
136
+ }
137
+ onPresenceAgentChange(agentId, cb) {
138
+ return this.api.onValue(
139
+ this.getPresencePath(agentId),
140
+ (key, data) => cb(key, data)
141
+ );
142
+ }
143
+ // Requests methods
144
+ async createRequest(request) {
145
+ const id = Generator.uuid();
146
+ await this.api.write(`${this.callsPath}/${id}`, {
147
+ ...request,
148
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
149
+ status: "pending",
150
+ assignedAgentId: null
151
+ });
152
+ this.api.onDisconnectUpdate(`${this.callsPath}/${id}`, {
153
+ status: "disconnected"
154
+ });
155
+ return id;
156
+ }
157
+ onNewRequest(cb) {
158
+ return this.api.onChildAdded(
159
+ this.callsPath,
160
+ (key, data) => cb(key, { ...data, id: key })
161
+ );
162
+ }
163
+ onRequestChange(cb) {
164
+ return this.api.onChildChanged(
165
+ this.callsPath,
166
+ (key, data) => cb(key, { ...data, id: key })
167
+ );
168
+ }
169
+ onRequestRemoved(cb) {
170
+ return this.api.onChildRemoved(this.callsPath, (key) => cb(key));
171
+ }
172
+ async acceptRequest(requestId) {
173
+ await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
174
+ return this.api.update(`${this.callsPath}/${requestId}`, {
175
+ status: "accepted"
176
+ });
177
+ }
178
+ async cancelOnDisconnect(requestId) {
179
+ await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
180
+ }
181
+ async cancelRequest(requestId) {
182
+ await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
183
+ return this.api.update(`${this.callsPath}/${requestId}`, {
184
+ status: "cancelled"
185
+ });
186
+ }
187
+ };
188
+ export {
189
+ FirebaseService
190
+ };