@dora-cell/sdk-react 0.1.1-beta.3 → 0.1.1-beta.30

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/index.js CHANGED
@@ -4,6 +4,533 @@ var react = require('react');
4
4
  var sdk = require('@dora-cell/sdk');
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
6
 
7
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/shared/src/utils.js
8
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
9
+ var toCamelCase = (string) => string.replace(
10
+ /^([A-Z])|[\s-_]+(\w)/g,
11
+ (match, p1, p2) => p2 ? p2.toUpperCase() : p1.toLowerCase()
12
+ );
13
+ var toPascalCase = (string) => {
14
+ const camelCase = toCamelCase(string);
15
+ return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
16
+ };
17
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
18
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
19
+ }).join(" ").trim();
20
+ var hasA11yProp = (props) => {
21
+ for (const prop in props) {
22
+ if (prop.startsWith("aria-") || prop === "role" || prop === "title") {
23
+ return true;
24
+ }
25
+ }
26
+ };
27
+
28
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/defaultAttributes.js
29
+ var defaultAttributes = {
30
+ xmlns: "http://www.w3.org/2000/svg",
31
+ width: 24,
32
+ height: 24,
33
+ viewBox: "0 0 24 24",
34
+ fill: "none",
35
+ stroke: "currentColor",
36
+ strokeWidth: 2,
37
+ strokeLinecap: "round",
38
+ strokeLinejoin: "round"
39
+ };
40
+
41
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/Icon.js
42
+ var Icon = react.forwardRef(
43
+ ({
44
+ color = "currentColor",
45
+ size = 24,
46
+ strokeWidth = 2,
47
+ absoluteStrokeWidth,
48
+ className = "",
49
+ children,
50
+ iconNode,
51
+ ...rest
52
+ }, ref) => react.createElement(
53
+ "svg",
54
+ {
55
+ ref,
56
+ ...defaultAttributes,
57
+ width: size,
58
+ height: size,
59
+ stroke: color,
60
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
61
+ className: mergeClasses("lucide", className),
62
+ ...!children && !hasA11yProp(rest) && { "aria-hidden": "true" },
63
+ ...rest
64
+ },
65
+ [
66
+ ...iconNode.map(([tag, attrs]) => react.createElement(tag, attrs)),
67
+ ...Array.isArray(children) ? children : [children]
68
+ ]
69
+ )
70
+ );
71
+
72
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/createLucideIcon.js
73
+ var createLucideIcon = (iconName, iconNode) => {
74
+ const Component = react.forwardRef(
75
+ ({ className, ...props }, ref) => react.createElement(Icon, {
76
+ ref,
77
+ iconNode,
78
+ className: mergeClasses(
79
+ `lucide-${toKebabCase(toPascalCase(iconName))}`,
80
+ `lucide-${iconName}`,
81
+ className
82
+ ),
83
+ ...props
84
+ })
85
+ );
86
+ Component.displayName = toPascalCase(iconName);
87
+ return Component;
88
+ };
89
+
90
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/arrow-down-left.js
91
+ var __iconNode = [
92
+ ["path", { d: "M17 7 7 17", key: "15tmo1" }],
93
+ ["path", { d: "M17 17H7V7", key: "1org7z" }]
94
+ ];
95
+ var ArrowDownLeft = createLucideIcon("arrow-down-left", __iconNode);
96
+
97
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/arrow-up-right.js
98
+ var __iconNode2 = [
99
+ ["path", { d: "M7 7h10v10", key: "1tivn9" }],
100
+ ["path", { d: "M7 17 17 7", key: "1vkiza" }]
101
+ ];
102
+ var ArrowUpRight = createLucideIcon("arrow-up-right", __iconNode2);
103
+
104
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/delete.js
105
+ var __iconNode3 = [
106
+ [
107
+ "path",
108
+ {
109
+ d: "M10 5a2 2 0 0 0-1.344.519l-6.328 5.74a1 1 0 0 0 0 1.481l6.328 5.741A2 2 0 0 0 10 19h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2z",
110
+ key: "1yo7s0"
111
+ }
112
+ ],
113
+ ["path", { d: "m12 9 6 6", key: "anjzzh" }],
114
+ ["path", { d: "m18 9-6 6", key: "1fp51s" }]
115
+ ];
116
+ var Delete = createLucideIcon("delete", __iconNode3);
117
+
118
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/maximize.js
119
+ var __iconNode4 = [
120
+ ["path", { d: "M8 3H5a2 2 0 0 0-2 2v3", key: "1dcmit" }],
121
+ ["path", { d: "M21 8V5a2 2 0 0 0-2-2h-3", key: "1e4gt3" }],
122
+ ["path", { d: "M3 16v3a2 2 0 0 0 2 2h3", key: "wsl5sc" }],
123
+ ["path", { d: "M16 21h3a2 2 0 0 0 2-2v-3", key: "18trek" }]
124
+ ];
125
+ var Maximize = createLucideIcon("maximize", __iconNode4);
126
+
127
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/mic-off.js
128
+ var __iconNode5 = [
129
+ ["path", { d: "M12 19v3", key: "npa21l" }],
130
+ ["path", { d: "M15 9.34V5a3 3 0 0 0-5.68-1.33", key: "1gzdoj" }],
131
+ ["path", { d: "M16.95 16.95A7 7 0 0 1 5 12v-2", key: "cqa7eg" }],
132
+ ["path", { d: "M18.89 13.23A7 7 0 0 0 19 12v-2", key: "16hl24" }],
133
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }],
134
+ ["path", { d: "M9 9v3a3 3 0 0 0 5.12 2.12", key: "r2i35w" }]
135
+ ];
136
+ var MicOff = createLucideIcon("mic-off", __iconNode5);
137
+
138
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/mic.js
139
+ var __iconNode6 = [
140
+ ["path", { d: "M12 19v3", key: "npa21l" }],
141
+ ["path", { d: "M19 10v2a7 7 0 0 1-14 0v-2", key: "1vc78b" }],
142
+ ["rect", { x: "9", y: "2", width: "6", height: "13", rx: "3", key: "s6n7sd" }]
143
+ ];
144
+ var Mic = createLucideIcon("mic", __iconNode6);
145
+
146
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/minimize-2.js
147
+ var __iconNode7 = [
148
+ ["path", { d: "m14 10 7-7", key: "oa77jy" }],
149
+ ["path", { d: "M20 10h-6V4", key: "mjg0md" }],
150
+ ["path", { d: "m3 21 7-7", key: "tjx5ai" }],
151
+ ["path", { d: "M4 14h6v6", key: "rmj7iw" }]
152
+ ];
153
+ var Minimize2 = createLucideIcon("minimize-2", __iconNode7);
154
+
155
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/phone.js
156
+ var __iconNode8 = [
157
+ [
158
+ "path",
159
+ {
160
+ d: "M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",
161
+ key: "9njp5v"
162
+ }
163
+ ]
164
+ ];
165
+ var Phone = createLucideIcon("phone", __iconNode8);
166
+
167
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/user.js
168
+ var __iconNode9 = [
169
+ ["path", { d: "M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2", key: "975kel" }],
170
+ ["circle", { cx: "12", cy: "7", r: "4", key: "17ys0d" }]
171
+ ];
172
+ var User = createLucideIcon("user", __iconNode9);
173
+
174
+ // ../../node_modules/.pnpm/lucide-react@0.555.0_react@19.2.3/node_modules/lucide-react/dist/esm/icons/x.js
175
+ var __iconNode10 = [
176
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
177
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
178
+ ];
179
+ var X = createLucideIcon("x", __iconNode10);
180
+ function CallInterface({
181
+ isOpen = false,
182
+ onOpenChange,
183
+ onCallEnded,
184
+ maximizeIcon,
185
+ minimizeIcon
186
+ }) {
187
+ const {
188
+ callStatus,
189
+ currentCall,
190
+ callDuration,
191
+ isMuted,
192
+ hangup,
193
+ answerCall,
194
+ toggleMute,
195
+ callError
196
+ } = useCall();
197
+ const [isMinimized, setIsMinimized] = react.useState(false);
198
+ const [wasConnected, setWasConnected] = react.useState(false);
199
+ const [closeCountdown, setCloseCountdown] = react.useState(null);
200
+ const [connectingCountdown, setConnectingCountdown] = react.useState(null);
201
+ const audioRef = react.useRef(null);
202
+ const ringtoneRef = react.useRef(null);
203
+ const isIncoming = currentCall?.direction === "inbound";
204
+ const remoteNumber = currentCall?.remoteNumber || "Unknown";
205
+ const displayName = remoteNumber;
206
+ react.useEffect(() => {
207
+ if (currentCall && audioRef.current) {
208
+ const stream = currentCall.getRemoteStream();
209
+ if (stream && audioRef.current.srcObject !== stream) {
210
+ audioRef.current.srcObject = stream;
211
+ }
212
+ }
213
+ }, [currentCall, callStatus]);
214
+ react.useEffect(() => {
215
+ if (callStatus === "ringing" && isIncoming) {
216
+ onOpenChange?.(true);
217
+ ringtoneRef.current?.play().catch(() => {
218
+ });
219
+ } else {
220
+ if (ringtoneRef.current) {
221
+ ringtoneRef.current.pause();
222
+ ringtoneRef.current.currentTime = 0;
223
+ }
224
+ }
225
+ }, [callStatus, isIncoming, onOpenChange]);
226
+ react.useEffect(() => {
227
+ if (callStatus === "connecting" || callStatus === "ringing") {
228
+ setWasConnected(false);
229
+ }
230
+ if (callStatus === "ongoing") {
231
+ setWasConnected(true);
232
+ }
233
+ }, [callStatus]);
234
+ react.useEffect(() => {
235
+ if (isOpen && callStatus === "ended") {
236
+ onCallEnded?.();
237
+ const closeDelay = wasConnected ? 1500 : 3e3;
238
+ const start = Date.now();
239
+ const iv = setInterval(() => {
240
+ const remaining = Math.max(0, closeDelay - (Date.now() - start));
241
+ setCloseCountdown(Math.ceil(remaining / 1e3));
242
+ if (remaining <= 0) {
243
+ clearInterval(iv);
244
+ onOpenChange?.(false);
245
+ setIsMinimized(false);
246
+ }
247
+ }, 100);
248
+ return () => clearInterval(iv);
249
+ } else {
250
+ setCloseCountdown(null);
251
+ }
252
+ }, [callStatus, isOpen, onOpenChange, wasConnected, onCallEnded]);
253
+ react.useEffect(() => {
254
+ let iv;
255
+ if (isOpen && callStatus === "connecting" && !isIncoming) {
256
+ setConnectingCountdown(60);
257
+ iv = setInterval(() => {
258
+ setConnectingCountdown((prev) => {
259
+ if (prev === null || prev <= 0) {
260
+ clearInterval(iv);
261
+ if (callStatus === "connecting") hangup();
262
+ return 0;
263
+ }
264
+ return prev - 1;
265
+ });
266
+ }, 1e3);
267
+ } else {
268
+ setConnectingCountdown(null);
269
+ }
270
+ return () => clearInterval(iv);
271
+ }, [callStatus, isOpen, isIncoming, hangup]);
272
+ if (!isOpen && callStatus === "idle") return null;
273
+ return /* @__PURE__ */ jsxRuntime.jsxs(
274
+ "div",
275
+ {
276
+ role: "dialog",
277
+ "aria-label": "Call interface",
278
+ className: `dora-fixed dora-top-14 md:dora-top-16 dora-right-0 md:dora-right-4 dora-z-50 dora-transform dora-transition-all dora-duration-300 dora-ease-in-out dora-bg-[#1E1E1E] dora-shadow-xl ${isOpen ? "dora-translate-x-0" : "dora-translate-x-[110%]"} ${isMinimized ? "dora-w-48 dora-h-20 dora-rounded-2xl dora-p-4 dora-flex dora-items-center dora-justify-between" : "dora-w-full sm:dora-w-96 md:dora-max-w-sm max-h-[calc(100vh-3.5rem)] md:dora-max-h-[calc(100vh-4rem)] dora-rounded-none md:dora-rounded-2xl"}`,
279
+ children: [
280
+ /* @__PURE__ */ jsxRuntime.jsx("audio", { ref: audioRef, autoPlay: true, className: "dora-hidden" }),
281
+ /* @__PURE__ */ jsxRuntime.jsx(
282
+ "audio",
283
+ {
284
+ ref: ringtoneRef,
285
+ src: "https://assets.mixkit.co/active_storage/sfx/2358/2358-preview.mp3",
286
+ loop: true,
287
+ preload: "auto",
288
+ className: "dora-hidden"
289
+ }
290
+ ),
291
+ isMinimized ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-items-center dora-justify-between dora-w-full dora-h-full", children: [
292
+ /* @__PURE__ */ jsxRuntime.jsx(
293
+ "button",
294
+ {
295
+ onClick: () => setIsMinimized(false),
296
+ className: "dora-w-10 dora-h-10 dora-rounded-full dora-bg-[#2A2A2A] dora-flex dora-items-center dora-justify-center dora-text-slate-400 hover:dora-text-white dora-transition-colors",
297
+ "aria-label": "Maximize",
298
+ children: maximizeIcon || /* @__PURE__ */ jsxRuntime.jsx(Maximize, { size: 18 })
299
+ }
300
+ ),
301
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-relative dora-flex dora-items-center", children: [
302
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-w-11 dora-h-11 dora-rounded-full dora-bg-white dora-flex dora-items-center dora-justify-center dora--mr-3", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-text-xl dora-text-slate-900 dora-font-bold", children: displayName.charAt(0).toUpperCase() }) }),
303
+ /* @__PURE__ */ jsxRuntime.jsx(
304
+ "button",
305
+ {
306
+ onClick: hangup,
307
+ className: "dora-w-11 dora-h-11 dora-rounded-full dora-bg-red-500 dora-text-white dora-flex dora-items-center dora-justify-center dora-shadow-lg hover:dora-bg-red-600 dora-transition-colors dora-z-10",
308
+ "aria-label": "End call",
309
+ children: /* @__PURE__ */ jsxRuntime.jsx(Phone, { size: 18, className: "dora-transform dora-rotate-[135deg]" })
310
+ }
311
+ )
312
+ ] })
313
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-flex-col dora-py-4 md:dora-py-6 dora-gap-2.5 md:dora-gap-3.5 dora-px-3 md:dora-px-5 dora-relative", children: [
314
+ /* @__PURE__ */ jsxRuntime.jsx(
315
+ "button",
316
+ {
317
+ onClick: () => setIsMinimized(true),
318
+ className: "dora-absolute dora-top-2 dora-right-2 dora-text-slate-500 hover:dora-text-white dora-transition-colors",
319
+ "aria-label": "Minimize",
320
+ children: minimizeIcon || /* @__PURE__ */ jsxRuntime.jsx(Minimize2, { size: 16 })
321
+ }
322
+ ),
323
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-justify-between dora-gap-2 dora-items-start md:dora-items-center", children: [
324
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-items-center dora-gap-2.5 md:dora-gap-4 dora-min-w-0", children: [
325
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-w-9 md:dora-w-11 dora-h-9 md:dora-h-11 dora-rounded-full dora-bg-white dora-flex dora-items-center dora-justify-center dora-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-text-lg md:dora-text-2xl dora-text-slate-900 dora-font-bold", children: displayName.charAt(0).toUpperCase() }) }),
326
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-min-w-0 dora-flex-1", children: [
327
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "dora-text-base md:dora-text-xl dora-font-normal dora-text-white dora-truncate", children: isIncoming ? displayName : displayName === "Unknown" ? "Outgoing Call" : displayName }),
328
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "dora-text-slate-400 dora-text-xs md:dora-text-sm dora-truncate", children: [
329
+ remoteNumber,
330
+ " \u2022",
331
+ " ",
332
+ isMuted ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-text-[#F99578]", children: "Call muted" }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
333
+ (callStatus === "connecting" || callStatus === "ringing") && /* @__PURE__ */ jsxRuntime.jsx("span", { children: isIncoming ? "Incoming Call..." : callStatus === "connecting" ? "Connecting..." : "Ringing..." }),
334
+ callStatus === "ongoing" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: "On Call" }),
335
+ callStatus === "ended" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Call Ended" })
336
+ ] })
337
+ ] })
338
+ ] })
339
+ ] }),
340
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-items-center dora-justify-center dora-gap-1.5 md:dora-gap-3 dora-shrink-0", children: [
341
+ isIncoming && callStatus === "ringing" && /* @__PURE__ */ jsxRuntime.jsx(
342
+ "button",
343
+ {
344
+ onClick: answerCall,
345
+ className: "dora-rounded-full dora-bg-green-500 dora-text-white hover:dora-bg-green-600 dora-transition-colors dora-w-8 md:dora-w-9 dora-h-8 md:dora-h-9 dora-flex dora-items-center dora-justify-center dora-shrink-0",
346
+ "aria-label": "Answer",
347
+ children: /* @__PURE__ */ jsxRuntime.jsx(Phone, { size: 18 })
348
+ }
349
+ ),
350
+ (callStatus === "ongoing" || isIncoming && callStatus === "ringing") && /* @__PURE__ */ jsxRuntime.jsx(
351
+ "button",
352
+ {
353
+ onClick: toggleMute,
354
+ className: `dora-rounded-full dora-transition-colors dora-w-8 md:dora-w-9 dora-h-8 md:dora-h-9 dora-flex dora-items-center dora-justify-center dora-shrink-0 ${isMuted ? "dora-bg-slate-700 hover:dora-bg-slate-600 dora-text-white" : "dora-bg-[#2A2A2A] hover:dora-bg-[#333333] dora-text-slate-400"}`,
355
+ "aria-label": "Toggle mute",
356
+ children: isMuted ? /* @__PURE__ */ jsxRuntime.jsx(MicOff, { size: 18 }) : /* @__PURE__ */ jsxRuntime.jsx(Mic, { size: 18 })
357
+ }
358
+ ),
359
+ /* @__PURE__ */ jsxRuntime.jsx(
360
+ "button",
361
+ {
362
+ onClick: hangup,
363
+ className: "dora-rounded-full dora-bg-red-600 dora-text-white hover:dora-bg-red-700 dora-transition-colors dora-w-8 md:dora-w-9 dora-h-8 md:dora-h-9 dora-flex dora-items-center dora-justify-center dora-shrink-0",
364
+ "aria-label": isIncoming && callStatus === "ringing" ? "Decline" : "End call",
365
+ children: /* @__PURE__ */ jsxRuntime.jsx(Phone, { size: 18, className: "dora-transform dora-rotate-[135deg]" })
366
+ }
367
+ )
368
+ ] })
369
+ ] }),
370
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-flex-1 dora-border-t dora-border-[#282828] dora-mt-2 dora-mb-2" }),
371
+ callError && callStatus === "ended" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-bg-red-900/20 dora-border dora-border-red-500/30 dora-rounded-lg dora-p-2 md:dora-p-3 dora-mb-2 md:dora-mb-3", children: [
372
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-red-400 dora-text-xs md:dora-text-sm dora-font-medium", children: "Call Failed" }),
373
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "dora-text-red-300 dora-text-xs dora-mt-0.5 md:dora-mt-1", children: callError }),
374
+ closeCountdown !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-mt-1.5 md:dora-mt-2", children: [
375
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-w-full dora-bg-red-900/30 dora-rounded-full dora-h-1.5 dora-overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
376
+ "div",
377
+ {
378
+ className: "dora-bg-red-500 dora-h-full dora-transition-all dora-duration-100",
379
+ style: {
380
+ width: `${Math.max(
381
+ 0,
382
+ closeCountdown / (wasConnected ? 1 : 5) * 100
383
+ )}%`
384
+ }
385
+ }
386
+ ) }),
387
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "dora-text-xs dora-text-red-300 dora-mt-0.5 md:dora-mt-1 dora-text-center", children: [
388
+ "Closing in ",
389
+ closeCountdown,
390
+ "s"
391
+ ] })
392
+ ] })
393
+ ] }),
394
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-justify-between dora-items-center", children: [
395
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-text-slate-400 dora-text-xs md:dora-text-sm dora-font-light dora-tracking-wide dora-flex dora-items-center dora-gap-1", children: [
396
+ (callStatus === "connecting" || callStatus === "ringing") && /* @__PURE__ */ jsxRuntime.jsx("span", { children: isIncoming ? "Incoming call" : "Outgoing call" }),
397
+ callStatus === "ongoing" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Ongoing" }),
398
+ callStatus === "ended" && /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Call ended" }),
399
+ (callStatus === "connecting" || callStatus === "ringing" || callStatus === "ongoing") && (isIncoming ? /* @__PURE__ */ jsxRuntime.jsx(ArrowDownLeft, { className: "dora-inline-block dora-ml-1 dora-text-green-400", size: 16 }) : /* @__PURE__ */ jsxRuntime.jsx(ArrowUpRight, { className: "dora-inline-block dora-ml-1 dora-text-blue-400", size: 16 }))
400
+ ] }),
401
+ callStatus === "ongoing" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-bg-[#272727] dora-h-6 md:dora-h-7 dora-rounded-full dora-px-3 md:dora-px-4 dora-text-white dora-font-normal dora-text-xs md:dora-text-sm dora-flex dora-items-center dora-justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { children: callDuration }) }),
402
+ callStatus === "ended" && closeCountdown !== null && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-bg-[#272727] dora-h-6 md:dora-h-7 dora-rounded-full dora-px-3 md:dora-px-4 dora-text-slate-400 dora-font-normal dora-text-xs dora-flex dora-items-center dora-justify-center dora-gap-1", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
403
+ "Closing in ",
404
+ closeCountdown,
405
+ "s"
406
+ ] }) }),
407
+ (connectingCountdown !== null || callStatus === "ringing") && !isIncoming && callStatus !== "ongoing" && callStatus !== "ended" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-bg-[#272727] dora-h-8 dora-rounded-full dora-px-3 md:dora-px-4 dora-text-white dora-font-normal dora-text-xs md:dora-text-sm dora-flex dora-items-center dora-justify-center dora-gap-2", children: [
408
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-text-[#F99578] dora-whitespace-nowrap", children: callStatus === "ringing" ? "Ringing..." : "Connecting..." }),
409
+ callStatus === "connecting" && connectingCountdown && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "dora-font-mono dora-ml-1 dora-text-slate-400", children: [
410
+ Math.floor(connectingCountdown / 60),
411
+ ":",
412
+ String(connectingCountdown % 60).padStart(2, "0")
413
+ ] })
414
+ ] })
415
+ ] })
416
+ ] })
417
+ ]
418
+ }
419
+ );
420
+ }
421
+ function Dialpad({
422
+ onCallInitiated,
423
+ initialNumber = "",
424
+ showKeys = true,
425
+ className = "",
426
+ availableExtensions = [],
427
+ selectedExtension,
428
+ onExtensionChange
429
+ }) {
430
+ const { call, callStatus } = useCall();
431
+ const { isConnected } = useConnectionStatus();
432
+ const [number, setNumber] = react.useState(initialNumber);
433
+ const [keysVisible, setKeysVisible] = react.useState(showKeys);
434
+ const append = (digit) => setNumber((s) => s + digit);
435
+ const backspace = () => setNumber((s) => s.slice(0, -1));
436
+ const handleCall = async () => {
437
+ if (!number || number.trim() === "") return;
438
+ try {
439
+ await call(number, selectedExtension);
440
+ onCallInitiated?.(number);
441
+ } catch (e) {
442
+ console.error("Call failed", e);
443
+ }
444
+ };
445
+ const isCallDisabled = !number || number.trim() === "" || !isConnected || callStatus === "ringing" || callStatus === "ongoing" || callStatus === "connecting";
446
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `dora-space-y-4 ${className}`, children: [
447
+ availableExtensions.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-gap-2 dora-bg-[#F6F7F9] dora-rounded-lg dora-flex dora-items-center dora-justify-between dora-p-2 md:dora-p-2.5 dora-mb-4", children: [
448
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-text-xs md:dora-text-sm dora-text-neutral-500 dora-font-normal dora-whitespace-nowrap", children: "Caller ID" }),
449
+ /* @__PURE__ */ jsxRuntime.jsx(
450
+ "select",
451
+ {
452
+ className: "dora-bg-transparent dora-text-sm dora-font-medium dora-outline-none",
453
+ value: selectedExtension,
454
+ onChange: (e) => onExtensionChange?.(e.target.value),
455
+ children: availableExtensions.map((ext) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: ext.value, children: ext.label }, ext.value))
456
+ }
457
+ )
458
+ ] }),
459
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-space-y-2 md:dora-space-y-3 dora-bg-[#F6F7F9] dora-p-2 md:dora-p-2.5 dora-rounded-lg", children: [
460
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex dora-items-center dora-gap-2 md:dora-gap-3", children: [
461
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-flex-1 dora-min-w-0 dora-flex dora-items-center dora-bg-white dora-rounded-md dora-px-3 dora-h-10 dora-border dora-border-transparent focus-within:dora-border-green-500 dora-transition-colors", children: [
462
+ /* @__PURE__ */ jsxRuntime.jsx(User, { className: "dora-text-gray-400 dora-mr-2", size: 18 }),
463
+ /* @__PURE__ */ jsxRuntime.jsx(
464
+ "input",
465
+ {
466
+ type: "tel",
467
+ placeholder: "Enter number",
468
+ value: number,
469
+ onChange: (e) => setNumber(e.target.value),
470
+ className: "dora-bg-transparent dora-border-none dora-outline-none dora-w-full dora-text-base dora-text-black"
471
+ }
472
+ )
473
+ ] }),
474
+ /* @__PURE__ */ jsxRuntime.jsx(
475
+ "button",
476
+ {
477
+ disabled: isCallDisabled,
478
+ onClick: handleCall,
479
+ title: "Place Call",
480
+ className: "dora-bg-green-500 dora-text-white hover:dora-bg-green-600 dora-rounded-lg dora-h-9 md:dora-h-10 dora-w-9 md:dora-w-11 dora-flex dora-items-center dora-justify-center disabled:dora-opacity-50 disabled:dora-cursor-not-allowed dora-transition-colors",
481
+ children: /* @__PURE__ */ jsxRuntime.jsx(Phone, { size: 16, fill: "currentColor" })
482
+ }
483
+ )
484
+ ] }),
485
+ /* @__PURE__ */ jsxRuntime.jsx("div", { children: keysVisible ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "dora-pt-3", children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-flex dora-items-center dora-gap-3 dora-mb-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
487
+ "button",
488
+ {
489
+ onClick: () => setKeysVisible(false),
490
+ className: "dora-px-2 md:dora-px-2.5 dora-h-8 dora-bg-white dora-rounded-full dora-shadow dora-text-neutral-500 dora-flex dora-items-center dora-gap-1.5 md:dora-gap-2 dora-text-xs md:dora-text-sm dora-font-normal hover:dora-bg-gray-50 dora-transition-colors",
491
+ children: [
492
+ /* @__PURE__ */ jsxRuntime.jsx(X, { color: "red", size: 16 }),
493
+ " Close keypad"
494
+ ]
495
+ }
496
+ ) }),
497
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-grid dora-grid-cols-3 dora-gap-2 md:dora-gap-3", children: [
498
+ "1",
499
+ "2",
500
+ "3",
501
+ "4",
502
+ "5",
503
+ "6",
504
+ "7",
505
+ "8",
506
+ "9",
507
+ "+",
508
+ "0",
509
+ "del"
510
+ ].map((d) => /* @__PURE__ */ jsxRuntime.jsx(
511
+ "button",
512
+ {
513
+ onClick: () => d === "del" ? backspace() : append(d),
514
+ className: "dora-h-10 md:dora-h-12 dora-bg-white dora-rounded-xl dora-shadow dora-flex dora-items-center dora-justify-center dora-text-base md:dora-text-lg dora-font-medium dora-text-slate-900 hover:dora-bg-gray-50 active:dora-bg-gray-100 dora-transition-colors",
515
+ "aria-label": d === "del" ? "Delete" : `Dial ${d}`,
516
+ children: d === "del" ? /* @__PURE__ */ jsxRuntime.jsx(Delete, { size: 18 }) : d
517
+ },
518
+ d
519
+ )) })
520
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "dora-pt-2 md:dora-pt-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
521
+ "button",
522
+ {
523
+ onClick: () => setKeysVisible(true),
524
+ className: "dora-rounded-full dora-bg-[#EDEEF1] dora-h-9 md:dora-h-10 dora-flex dora-justify-center dora-items-center dora-px-3 md:dora-px-4 dora-w-full dora-text-xs md:dora-text-sm hover:dora-bg-[#E3E4E8] dora-transition-colors",
525
+ children: [
526
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-mr-2", children: "\u{1F522}" }),
527
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "dora-text-xs md:dora-text-sm dora-text-neutral-500 dora-font-normal dora-ml-1.5", children: "Open dialer" })
528
+ ]
529
+ }
530
+ ) }) })
531
+ ] })
532
+ ] });
533
+ }
7
534
  var DoraCellContext = react.createContext(void 0);
8
535
  function DoraCellProvider({
9
536
  config,
@@ -169,15 +696,17 @@ function useDoraCell() {
169
696
  return context;
170
697
  }
171
698
  function useCall() {
172
- const { call, hangup, toggleMute, callStatus, callDuration, isMuted, currentCall } = useDoraCell();
699
+ const { call, hangup, toggleMute, answerCall, callStatus, callDuration, isMuted, currentCall, error } = useDoraCell();
173
700
  return {
174
701
  call,
175
702
  hangup,
176
703
  toggleMute,
704
+ answerCall,
177
705
  callStatus,
178
706
  callDuration,
179
707
  isMuted,
180
- currentCall
708
+ currentCall,
709
+ callError: error?.message
181
710
  };
182
711
  }
183
712
  function useConnectionStatus() {
@@ -189,7 +718,33 @@ function useConnectionStatus() {
189
718
  error
190
719
  };
191
720
  }
721
+ /*! Bundled license information:
722
+
723
+ lucide-react/dist/esm/shared/src/utils.js:
724
+ lucide-react/dist/esm/defaultAttributes.js:
725
+ lucide-react/dist/esm/Icon.js:
726
+ lucide-react/dist/esm/createLucideIcon.js:
727
+ lucide-react/dist/esm/icons/arrow-down-left.js:
728
+ lucide-react/dist/esm/icons/arrow-up-right.js:
729
+ lucide-react/dist/esm/icons/delete.js:
730
+ lucide-react/dist/esm/icons/maximize.js:
731
+ lucide-react/dist/esm/icons/mic-off.js:
732
+ lucide-react/dist/esm/icons/mic.js:
733
+ lucide-react/dist/esm/icons/minimize-2.js:
734
+ lucide-react/dist/esm/icons/phone.js:
735
+ lucide-react/dist/esm/icons/user.js:
736
+ lucide-react/dist/esm/icons/x.js:
737
+ lucide-react/dist/esm/lucide-react.js:
738
+ (**
739
+ * @license lucide-react v0.555.0 - ISC
740
+ *
741
+ * This source code is licensed under the ISC license.
742
+ * See the LICENSE file in the root directory of this source tree.
743
+ *)
744
+ */
192
745
 
746
+ exports.CallInterface = CallInterface;
747
+ exports.Dialpad = Dialpad;
193
748
  exports.DoraCellProvider = DoraCellProvider;
194
749
  exports.useCall = useCall;
195
750
  exports.useConnectionStatus = useConnectionStatus;