@16x/webphone-sdk 3.1.17 → 3.1.19
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/CHANGELOG.md +267 -31
- package/LICENSE +1 -1
- package/README.md +214 -161
- package/dist/{Diagnostics-CK0ai_sy.cjs → Diagnostics-CgDSPlQx.cjs} +1 -1
- package/dist/{Diagnostics-B6xGNl8M.js → Diagnostics-DJdBDGad.js} +1 -1
- package/dist/{JsSipAdapter-l97xq1ao.cjs → JsSipAdapter-CgBtmR16.cjs} +1 -1
- package/dist/{JsSipAdapter-B8ueIoBA.js → JsSipAdapter-CiqM4KOq.js} +1 -1
- package/dist/SharedWorkerProtocol-4VARy5ma.cjs +1 -0
- package/dist/SharedWorkerProtocol-DvLUl0JZ.js +93 -0
- package/dist/core/CCBarCall.d.ts +1 -1
- package/dist/createJsSipFactory-9CPsweDR.js +9665 -0
- package/dist/createJsSipFactory-Dr8HbLl-.cjs +75 -0
- package/dist/crypto/legacySipTicket.d.ts +40 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.js +1 -1
- package/dist/errors/CCBarError.d.ts +2 -0
- package/dist/i18n/index.d.ts +22 -0
- package/dist/i18n/messages/en-US.d.ts +2 -0
- package/dist/i18n/messages/es-ES.d.ts +2 -0
- package/dist/i18n/messages/id-ID.d.ts +2 -0
- package/dist/i18n/messages/index.d.ts +7 -0
- package/dist/i18n/messages/zh-CN.d.ts +2 -0
- package/dist/i18n/types.d.ts +5 -0
- package/dist/i18n-BbEy6K9z.cjs +1 -0
- package/dist/i18n-D-DdHtGz.js +150 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +9 -8
- package/dist/index.umd.js +69 -16
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +10 -276
- package/dist/legacy/legacySessionProvider.d.ts +20 -9
- package/dist/legacySessionProvider-CKJyrade.cjs +1 -0
- package/dist/{CCBarClient-C2sC86Xi.js → legacySessionProvider-DBrRBB3S.js} +795 -493
- package/dist/shared/SharedWorkerFactory.d.ts +2 -0
- package/dist/shared/SharedWorkerProtocol.d.ts +2 -0
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +65 -64
- package/dist/styles.css +7 -7
- package/dist/ui/i18n/es-ES.d.ts +2 -0
- package/dist/ui/i18n/id-ID.d.ts +2 -0
- package/dist/ui/i18n/index.d.ts +2 -0
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +278 -170
- package/dist/version.d.ts +1 -1
- package/package.json +114 -109
- package/dist/CCBarClient-GQ3yxDur.cjs +0 -1
- package/dist/SharedWorkerProtocol-C-4KpECM.cjs +0 -1
- package/dist/SharedWorkerProtocol-CffZrUXg.js +0 -119
- package/dist/createJsSipFactory-B1ORbJiP.cjs +0 -22
- package/dist/createJsSipFactory-CoWZN-BC.js +0 -7410
|
@@ -10,6 +10,8 @@ export interface SharedWorkerFactoryOptions extends SharedWorkerOptions {
|
|
|
10
10
|
readonly tabId?: string;
|
|
11
11
|
readonly workerCtor?: SharedWorkerConstructor;
|
|
12
12
|
readonly locationHref?: string;
|
|
13
|
+
/** 界面语言,随 attach 请求带给 worker,让 worker 端的错误文案与主线程一致。 */
|
|
14
|
+
readonly locale?: string;
|
|
13
15
|
}
|
|
14
16
|
export interface SharedWorkerConnection {
|
|
15
17
|
readonly mode: 'shared';
|
|
@@ -17,6 +17,8 @@ export type WorkerRequest = {
|
|
|
17
17
|
readonly type: 'attach';
|
|
18
18
|
readonly requestId: string;
|
|
19
19
|
readonly tabId: string;
|
|
20
|
+
/** 主线程解析好的界面语言,worker 端用它生成错误文案(缺省回落默认语言)。 */
|
|
21
|
+
readonly locale?: string;
|
|
20
22
|
} | {
|
|
21
23
|
readonly version: typeof PROTOCOL_VERSION;
|
|
22
24
|
readonly type: 'detach';
|
package/dist/shared-worker.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./i18n-BbEy6K9z.cjs"),t=require("./SharedWorkerProtocol-4VARy5ma.cjs");require("./createJsSipFactory-Dr8HbLl-.cjs");var n=class{ports=new Map;requestResults=new Map;lifecycleState=`connected`;bootstrapOwner;options;constructor(e={}){this.options={timeoutMs:e.timeoutMs??15e3,...e}}attach(e,t){let n=e;s(t);let r=this.ports.get(t);r!==void 0&&r!==n&&this.detachPort(t,r),this.ports.set(t,n),n.onmessage=e=>{this.handlePortMessage(n,t,e.data)},n.start(),n.onclose=()=>{this.ports.get(t)===n&&this.detachPort(t,n)};let i=!1;return()=>{i||(i=!0,this.ports.get(t)===n&&this.detachPort(t,n))}}async handle(e){let n=t.t(e);if(!o(n))return a(e.requestId,new t.i(`SDK_INTERNAL_ERROR`,`internal`,!1));let r=`${n.tabId}:${n.requestId}`,i=this.requestResults.get(r);if(i!==void 0)return i;let s=this.execute(n).finally(()=>{this.requestResults.get(r)===s&&this.requestResults.delete(r)});return this.requestResults.set(r,s),s}broadcast(e){let t=i(e);this.ports.forEach(e=>e.postMessage(t))}getTabIds(){return[...this.ports.keys()]}getLifecycleState(){return this.lifecycleState}restart(){this.lifecycleState=`reconnecting`,this.bootstrapOwner=void 0,this.broadcast({version:1,type:`event`,event:`connection.stateChanged`,payload:{state:`reconnecting`}})}markReady(e=[]){this.lifecycleState=`connected`,this.bootstrapOwner=void 0,this.broadcast({version:1,type:`event`,event:`connection.stateChanged`,payload:{state:`connected`}}),e.forEach(e=>{this.broadcast({version:1,type:`event`,event:`call.snapshot`,payload:t.n(e)})})}async execute(e){try{if(this.assertCommandAllowed(e),e.type===`detach`){let t=this.ports.get(e.tabId);t!==void 0&&this.detachPort(e.tabId,t)}e.type===`command`&&e.command===`bootstrap`&&this.claimBootstrap(e.tabId);let t=await c(this.options.handleRequest?.(e)??Promise.resolve({attached:e.tabId}),this.options.timeoutMs);return{version:1,type:`response`,requestId:e.requestId,ok:!0,result:t}}catch(n){let r=n instanceof t.i?n:n instanceof l?new t.i(`NETWORK_TIMEOUT`,`network`,!0,{requestId:e.requestId}):new t.i(`SDK_INTERNAL_ERROR`,`internal`,!1,{requestId:e.requestId,cause:n});return a(e.requestId,r)}}assertCommandAllowed(e){if(e.type===`command`&&this.lifecycleState===`reconnecting`&&(e.command===`dial`||e.command===`answer`))throw new t.i(`CALL_OPERATION_NOT_ALLOWED`,`call`,!0,{callId:e.payload?.callId})}claimBootstrap(e){if(this.bootstrapOwner===void 0){this.bootstrapOwner=e;return}if(this.bootstrapOwner!==e)throw new t.i(`CALL_OPERATION_NOT_ALLOWED`,`call`,!0)}async handlePortMessage(e,n,r){try{let i=t.t(r);if(!o(i)||i.tabId!==n){e.postMessage(a(typeof r==`object`&&r&&`requestId`in r&&typeof r.requestId==`string`?r.requestId:``,new t.i(`SDK_INTERNAL_ERROR`,`internal`,!1)));return}e.postMessage(await this.handle(i))}catch(t){let n=typeof r==`object`&&r&&`requestId`in r&&typeof r.requestId==`string`?r.requestId:``;e.postMessage(a(n,t))}}detachPort(e,t){t.onmessage=null,t.onclose=null,this.ports.delete(e),this.options.onPortDetached?.(e)}};function r(r,i=new n){return r.onconnect=n=>{let r=n.ports[0];if(r===void 0)return;let s=!0;r.onmessage=n=>{try{let a=t.t(n.data);if(!o(a)||a.type!==`attach`)throw new t.i(`SDK_INTERNAL_ERROR`,`internal`,!1);s=!1,e.s(a.locale),i.attach(r,a.tabId),i.handle(a).then(e=>r.postMessage(e))}catch(e){let t=typeof n.data==`object`&&n.data!==null&&`requestId`in n.data&&typeof n.data.requestId==`string`?n.data.requestId:``;r.postMessage(a(t,e))}},r.start(),s||(r.onmessage=null)},i}function i(e){if((e.event===`call.snapshot`||e.event===`call.created`)&&typeof e.payload==`object`&&e.payload!==null)return{...e,payload:t.n(e.payload)};if(e.event===`call.failed`&&typeof e.payload==`object`&&e.payload!==null&&`error`in e.payload){let n=e.payload;return{...e,payload:{...typeof n.callId==`string`?{callId:n.callId}:{},error:t.r(n.error)}}}return e.event===`error`?{...e,payload:t.r(e.payload)}:structuredClone(e)}function a(e,n){return{version:1,type:`response`,requestId:e,ok:!1,error:t.r(n)}}function o(e){return typeof e==`object`&&!!e&&`requestId`in e&&`tabId`in e&&`type`in e&&(e.type===`attach`||e.type===`detach`||e.type===`command`)}function s(e){if(!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(e))throw new t.i(`SDK_INTERNAL_ERROR`,`internal`,!1)}async function c(e,t){let n;try{return await Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(new l),t)})])}finally{n!==void 0&&clearTimeout(n)}}var l=class extends Error{};function u(e){return r(e)}var d=typeof globalThis==`object`&&`onconnect`in globalThis?r(globalThis):void 0;exports.createSharedWorkerRuntime=u,exports.sharedWorkerRuntime=d;
|
package/dist/shared-worker.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as e } from "./i18n-D-DdHtGz.js";
|
|
2
|
+
import { i as t, n, r, t as i } from "./SharedWorkerProtocol-DvLUl0JZ.js";
|
|
2
3
|
//#region src/shared/SharedWorkerRuntime.ts
|
|
3
|
-
var
|
|
4
|
+
var a = class {
|
|
4
5
|
ports = /* @__PURE__ */ new Map();
|
|
5
6
|
requestResults = /* @__PURE__ */ new Map();
|
|
6
7
|
lifecycleState = "connected";
|
|
@@ -14,7 +15,7 @@ var i = class {
|
|
|
14
15
|
}
|
|
15
16
|
attach(e, t) {
|
|
16
17
|
let n = e;
|
|
17
|
-
|
|
18
|
+
u(t);
|
|
18
19
|
let r = this.ports.get(t);
|
|
19
20
|
r !== void 0 && r !== n && this.detachPort(t, r), this.ports.set(t, n), n.onmessage = (e) => {
|
|
20
21
|
this.handlePortMessage(n, t, e.data);
|
|
@@ -26,18 +27,18 @@ var i = class {
|
|
|
26
27
|
i || (i = !0, this.ports.get(t) === n && this.detachPort(t, n));
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
async handle(
|
|
30
|
-
let n =
|
|
31
|
-
if (!
|
|
32
|
-
let
|
|
30
|
+
async handle(e) {
|
|
31
|
+
let n = i(e);
|
|
32
|
+
if (!l(n)) return c(e.requestId, new t("SDK_INTERNAL_ERROR", "internal", !1));
|
|
33
|
+
let r = `${n.tabId}:${n.requestId}`, a = this.requestResults.get(r);
|
|
33
34
|
if (a !== void 0) return a;
|
|
34
35
|
let o = this.execute(n).finally(() => {
|
|
35
|
-
this.requestResults.get(
|
|
36
|
+
this.requestResults.get(r) === o && this.requestResults.delete(r);
|
|
36
37
|
});
|
|
37
|
-
return this.requestResults.set(
|
|
38
|
+
return this.requestResults.set(r, o), o;
|
|
38
39
|
}
|
|
39
40
|
broadcast(e) {
|
|
40
|
-
let t =
|
|
41
|
+
let t = s(e);
|
|
41
42
|
this.ports.forEach((e) => e.postMessage(t));
|
|
42
43
|
}
|
|
43
44
|
getTabIds() {
|
|
@@ -65,81 +66,81 @@ var i = class {
|
|
|
65
66
|
version: 1,
|
|
66
67
|
type: "event",
|
|
67
68
|
event: "call.snapshot",
|
|
68
|
-
payload:
|
|
69
|
+
payload: n(e)
|
|
69
70
|
});
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
|
-
async execute(
|
|
73
|
+
async execute(e) {
|
|
73
74
|
try {
|
|
74
|
-
if (this.assertCommandAllowed(
|
|
75
|
-
let
|
|
76
|
-
|
|
75
|
+
if (this.assertCommandAllowed(e), e.type === "detach") {
|
|
76
|
+
let t = this.ports.get(e.tabId);
|
|
77
|
+
t !== void 0 && this.detachPort(e.tabId, t);
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
let
|
|
79
|
+
e.type === "command" && e.command === "bootstrap" && this.claimBootstrap(e.tabId);
|
|
80
|
+
let t = await d(this.options.handleRequest?.(e) ?? Promise.resolve({ attached: e.tabId }), this.options.timeoutMs);
|
|
80
81
|
return {
|
|
81
82
|
version: 1,
|
|
82
83
|
type: "response",
|
|
83
|
-
requestId:
|
|
84
|
+
requestId: e.requestId,
|
|
84
85
|
ok: !0,
|
|
85
|
-
result:
|
|
86
|
+
result: t
|
|
86
87
|
};
|
|
87
88
|
} catch (n) {
|
|
88
|
-
let r = n instanceof
|
|
89
|
-
requestId:
|
|
89
|
+
let r = n instanceof t ? n : n instanceof f ? new t("NETWORK_TIMEOUT", "network", !0, { requestId: e.requestId }) : new t("SDK_INTERNAL_ERROR", "internal", !1, {
|
|
90
|
+
requestId: e.requestId,
|
|
90
91
|
cause: n
|
|
91
92
|
});
|
|
92
|
-
return
|
|
93
|
+
return c(e.requestId, r);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
assertCommandAllowed(
|
|
96
|
-
if (
|
|
96
|
+
assertCommandAllowed(e) {
|
|
97
|
+
if (e.type === "command" && this.lifecycleState === "reconnecting" && (e.command === "dial" || e.command === "answer")) throw new t("CALL_OPERATION_NOT_ALLOWED", "call", !0, { callId: e.payload?.callId });
|
|
97
98
|
}
|
|
98
|
-
claimBootstrap(
|
|
99
|
+
claimBootstrap(e) {
|
|
99
100
|
if (this.bootstrapOwner === void 0) {
|
|
100
|
-
this.bootstrapOwner =
|
|
101
|
+
this.bootstrapOwner = e;
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
|
-
if (this.bootstrapOwner !==
|
|
104
|
+
if (this.bootstrapOwner !== e) throw new t("CALL_OPERATION_NOT_ALLOWED", "call", !0);
|
|
104
105
|
}
|
|
105
|
-
async handlePortMessage(
|
|
106
|
+
async handlePortMessage(e, n, r) {
|
|
106
107
|
try {
|
|
107
|
-
let a = r
|
|
108
|
-
if (!
|
|
109
|
-
|
|
108
|
+
let a = i(r);
|
|
109
|
+
if (!l(a) || a.tabId !== n) {
|
|
110
|
+
e.postMessage(c(typeof r == "object" && r && "requestId" in r && typeof r.requestId == "string" ? r.requestId : "", new t("SDK_INTERNAL_ERROR", "internal", !1)));
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
|
-
|
|
113
|
-
} catch (
|
|
114
|
-
let n = typeof
|
|
115
|
-
|
|
113
|
+
e.postMessage(await this.handle(a));
|
|
114
|
+
} catch (t) {
|
|
115
|
+
let n = typeof r == "object" && r && "requestId" in r && typeof r.requestId == "string" ? r.requestId : "";
|
|
116
|
+
e.postMessage(c(n, t));
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
detachPort(e, t) {
|
|
119
120
|
t.onmessage = null, t.onclose = null, this.ports.delete(e), this.options.onPortDetached?.(e);
|
|
120
121
|
}
|
|
121
122
|
};
|
|
122
|
-
function
|
|
123
|
-
return
|
|
124
|
-
let
|
|
125
|
-
if (
|
|
126
|
-
let
|
|
127
|
-
|
|
123
|
+
function o(n, r = new a()) {
|
|
124
|
+
return n.onconnect = (n) => {
|
|
125
|
+
let a = n.ports[0];
|
|
126
|
+
if (a === void 0) return;
|
|
127
|
+
let o = !0;
|
|
128
|
+
a.onmessage = (n) => {
|
|
128
129
|
try {
|
|
129
|
-
let
|
|
130
|
-
if (!
|
|
131
|
-
|
|
130
|
+
let s = i(n.data);
|
|
131
|
+
if (!l(s) || s.type !== "attach") throw new t("SDK_INTERNAL_ERROR", "internal", !1);
|
|
132
|
+
o = !1, e(s.locale), r.attach(a, s.tabId), r.handle(s).then((e) => a.postMessage(e));
|
|
132
133
|
} catch (e) {
|
|
133
|
-
let
|
|
134
|
-
|
|
134
|
+
let t = typeof n.data == "object" && n.data !== null && "requestId" in n.data && typeof n.data.requestId == "string" ? n.data.requestId : "";
|
|
135
|
+
a.postMessage(c(t, e));
|
|
135
136
|
}
|
|
136
|
-
},
|
|
137
|
-
},
|
|
137
|
+
}, a.start(), o || (a.onmessage = null);
|
|
138
|
+
}, r;
|
|
138
139
|
}
|
|
139
|
-
function
|
|
140
|
+
function s(e) {
|
|
140
141
|
if ((e.event === "call.snapshot" || e.event === "call.created") && typeof e.payload == "object" && e.payload !== null) return {
|
|
141
142
|
...e,
|
|
142
|
-
payload:
|
|
143
|
+
payload: n(e.payload)
|
|
143
144
|
};
|
|
144
145
|
if (e.event === "call.failed" && typeof e.payload == "object" && e.payload !== null && "error" in e.payload) {
|
|
145
146
|
let t = e.payload;
|
|
@@ -147,46 +148,46 @@ function o(e) {
|
|
|
147
148
|
...e,
|
|
148
149
|
payload: {
|
|
149
150
|
...typeof t.callId == "string" ? { callId: t.callId } : {},
|
|
150
|
-
error:
|
|
151
|
+
error: r(t.error)
|
|
151
152
|
}
|
|
152
153
|
};
|
|
153
154
|
}
|
|
154
155
|
return e.event === "error" ? {
|
|
155
156
|
...e,
|
|
156
|
-
payload:
|
|
157
|
+
payload: r(e.payload)
|
|
157
158
|
} : structuredClone(e);
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
+
function c(e, t) {
|
|
160
161
|
return {
|
|
161
162
|
version: 1,
|
|
162
163
|
type: "response",
|
|
163
164
|
requestId: e,
|
|
164
165
|
ok: !1,
|
|
165
|
-
error:
|
|
166
|
+
error: r(t)
|
|
166
167
|
};
|
|
167
168
|
}
|
|
168
|
-
function
|
|
169
|
+
function l(e) {
|
|
169
170
|
return typeof e == "object" && !!e && "requestId" in e && "tabId" in e && "type" in e && (e.type === "attach" || e.type === "detach" || e.type === "command");
|
|
170
171
|
}
|
|
171
|
-
function
|
|
172
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(
|
|
172
|
+
function u(e) {
|
|
173
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/.test(e)) throw new t("SDK_INTERNAL_ERROR", "internal", !1);
|
|
173
174
|
}
|
|
174
|
-
async function
|
|
175
|
+
async function d(e, t) {
|
|
175
176
|
let n;
|
|
176
177
|
try {
|
|
177
178
|
return await Promise.race([e, new Promise((e, r) => {
|
|
178
|
-
n = setTimeout(() => r(new
|
|
179
|
+
n = setTimeout(() => r(new f()), t);
|
|
179
180
|
})]);
|
|
180
181
|
} finally {
|
|
181
182
|
n !== void 0 && clearTimeout(n);
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
|
-
var
|
|
185
|
+
var f = class extends Error {};
|
|
185
186
|
//#endregion
|
|
186
187
|
//#region src/shared/SharedWorkerEntry.ts
|
|
187
|
-
function
|
|
188
|
-
return
|
|
188
|
+
function p(e) {
|
|
189
|
+
return o(e);
|
|
189
190
|
}
|
|
190
|
-
var
|
|
191
|
+
var m = typeof globalThis == "object" && "onconnect" in globalThis ? o(globalThis) : void 0;
|
|
191
192
|
//#endregion
|
|
192
|
-
export {
|
|
193
|
+
export { p as createSharedWorkerRuntime, m as sharedWorkerRuntime };
|
package/dist/styles.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
@import './tokens.css';
|
|
2
|
-
@import './base.css';
|
|
3
|
-
@import './compact.css';
|
|
4
|
-
@import './panel.css';
|
|
5
|
-
@import './mobile.css';
|
|
6
|
-
@import './dark.css';
|
|
7
|
-
@import './reduced-motion.css';
|
|
1
|
+
@import './tokens.css';
|
|
2
|
+
@import './base.css';
|
|
3
|
+
@import './compact.css';
|
|
4
|
+
@import './panel.css';
|
|
5
|
+
@import './mobile.css';
|
|
6
|
+
@import './dark.css';
|
|
7
|
+
@import './reduced-motion.css';
|
package/dist/ui/i18n/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MessageResolver, UiMessages } from './types.js';
|
|
2
2
|
export type { MessageResolver, UiMessages } from './types.js';
|
|
3
3
|
export { enUS } from './en-US.js';
|
|
4
|
+
export { esES } from './es-ES.js';
|
|
5
|
+
export { idID } from './id-ID.js';
|
|
4
6
|
export { zhCN } from './zh-CN.js';
|
|
5
7
|
export declare function messagesForLocale(locale: string): UiMessages;
|
|
6
8
|
export declare function resolveMessages(locale: string, overlay?: Partial<UiMessages>, resolver?: MessageResolver): UiMessages;
|
package/dist/ui/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("../createJsSipFactory-B1ORbJiP.cjs");var e={call:`Call`,numberLabel:`Number`,statusReady:`Ready`,statusSetup:`Not initialized`,statusConnecting:`Connecting`,statusIncoming:`Incoming call`,statusActive:`On a call`,statusHeld:`On hold`,statusDialing:`Dialing`,statusEnded:`Call ended`,statusFailed:`Call failed`,statusUnsupported:`Unsupported browser`,statusPermission:`Microphone unavailable`,statusError:`Unable to continue`,incoming:`Incoming call`,answer:`Answer`,reject:`Decline`,hangup:`Hang up`,mute:`Mute`,unmute:`Unmute`,hold:`Hold`,resume:`Resume`,transfer:`Transfer`,blindTransfer:`Blind transfer`,more:`More`,devices:`Devices`,enablePhone:`Enable phone`,retryPermission:`Check again`,permissionTitle:`Microphone unavailable`,permissionBody:`Allow microphone access in the browser settings, then check again.`,errorTitle:`Unable to continue`,errorBody:`Check the network, origin allowlist, or agent permission, then retry.`,errorTokenUnavailable:`Could not get a sign-in token. Check that the token service is running and configured.`,currentCall:`Current call`,inbound:`Inbound`,outbound:`Outbound`,foregroundChecking:`Back in foreground, checking the connection`,foregroundFailed:`Foreground recovery failed. Retry.`,signIn:`Sign in`,signOut:`Sign out`,outboundCall:`Outbound`,internalCall:`Internal`,agentIdle:`Available`,agentBusy:`Busy`,agentBreak:`Break`,agentBusyHint:`Busy is controlled by the call or server`,rowSignIn:`Presence`,rowCall:`Call`,rowAgent:`Agent`,extensionLabel:`Extension`,extensionPlaceholder:`Optional, assigned by the server`},t={call:`呼叫`,numberLabel:`号码`,statusReady:`可拨号`,statusSetup:`未初始化`,statusConnecting:`正在连接`,statusIncoming:`来电`,statusActive:`通话中`,statusHeld:`保持中`,statusDialing:`正在拨号`,statusEnded:`通话结束`,statusFailed:`呼叫失败`,statusUnsupported:`不支持的浏览器`,statusPermission:`无法使用麦克风`,statusError:`无法继续通话`,incoming:`来电`,answer:`接听`,reject:`拒绝`,hangup:`挂断`,mute:`静音`,unmute:`取消静音`,hold:`保持`,resume:`恢复`,transfer:`转接`,blindTransfer:`盲转`,more:`更多`,devices:`设备`,enablePhone:`启用电话`,retryPermission:`重新检测`,permissionTitle:`无法使用麦克风`,permissionBody:`请在浏览器设置中允许本网站访问麦克风,然后重新检测。`,errorTitle:`无法继续通话`,errorBody:`请检查网络、域名授权或坐席权限后重试。`,errorTokenUnavailable:`无法获取登录凭证,请检查 token 服务是否启动及配置是否正确。`,currentCall:`当前通话`,inbound:`呼入`,outbound:`呼出`,foregroundChecking:`已返回前台,正在检查连接`,foregroundFailed:`前台恢复失败,请重试`,signIn:`签入`,signOut:`退签`,outboundCall:`外呼`,internalCall:`内呼`,agentIdle:`空闲`,agentBusy:`置忙`,agentBreak:`休息`,agentBusyHint:`置忙由通话或服务端状态控制`,rowSignIn:`签入`,rowCall:`通话`,rowAgent:`坐席`,extensionLabel:`分机`,extensionPlaceholder:`可空,由服务端分配`};function n(n){return n.toLowerCase().startsWith(`en`)?e:t}function r(e,t,r){return{...n(e),...r===void 0?{}:r(e),...t??{}}}async function i(e){await e.media.requestPermission(),await e.initialize(),await e.connect()}function a(e,t={}){let n=t.document??(typeof document>`u`?void 0:document);if(n===void 0)return()=>void 0;let r=()=>{if(n.visibilityState===`hidden`){t.onHidden?.();return}t.onChecking?.(),e.recover().then(()=>t.onRecovered?.()).catch(e=>t.onFailed?.(e))};return n.addEventListener(`visibilitychange`,r),()=>n.removeEventListener(`visibilitychange`,r)}function o(e){return e.replace(/\s+/g,``)}function s(e,t,n){return o(e).length>0&&n===`connected`&&t!==`denied`}async function c(e,t,n){let r=o(t);r!==``&&await e.dial({destination:r,...n===void 0?{}:{type:n}})}async function l(e,t){return t?await e.unmute():await e.mute(),!t}async function u(e){e.state===`held`?await e.resume():await e.hold()}async function d(e,t){await e.sendDtmf(t)}async function f(e,t){let n=o(t);n!==``&&await e.transfer({target:n,type:`blind`})}function p(e,t={}){let n=document.createElement(e);return t.className!==void 0&&(n.className=t.className),t.text!==void 0&&(n.textContent=t.text),Object.entries(t.attrs??{}).forEach(([e,t])=>n.setAttribute(e,t)),t.children?.forEach(e=>n.append(e)),n}function m(e){return p(`div`,{attrs:{part:`status-rail`,role:`status`,"aria-live":`polite`},text:e})}function h(e,t,n=`destination`){let r=p(`input`,{attrs:{id:e,type:`tel`,inputmode:`tel`,name:n,autocomplete:`tel`}});return{field:p(`div`,{children:[p(`label`,{attrs:{for:e},text:t}),r]}),input:r}}var g=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`*`,`0`,`#`];function _(e){return e.mode===`compact`?v(e):y(e)}function v(e){let{field:t,input:n}=h(`ccbar-destination`,e.messages.numberLabel??`号码`);n.value=e.destination;let r=e.view.kind===`ready`||e.view.kind===`setup`||e.view.kind===`ended`?p(`button`,{attrs:{type:`button`,"data-action":`dial`,part:`call-button`,...e.canDial?{}:{disabled:``}},text:e.messages.call??`呼叫`}):p(`button`,{attrs:{type:`button`,"data-action":`hangup`,part:`hangup-button`},text:e.messages.hangup??`挂断`}),i=[S(e.messages.status??``,e.floating),p(`div`,{className:`ccbar-toolbar`,children:[t,e.view.kind===`active`||e.view.kind===`held`?E(e):p(`span`),r,p(`button`,{attrs:{type:`button`,"data-action":`more`},text:e.messages.more??`更多`})]})];return e.moreOpen&&i.push(p(`div`,{className:`ccbar-more`,children:[D(e.view,e.messages),p(`button`,{attrs:{type:`button`,"data-action":`devices`},text:e.messages.devices??`设备`})]})),p(`div`,{attrs:{part:`panel`,"data-layout":`compact`},children:i})}function y(e){let{input:t}=h(`ccbar-destination`,e.messages.numberLabel??`号码`),{field:n}=h(`ccbar-transfer-target`,e.messages.transfer??`转接号码`,`transfer-target`);t.value=e.destination,t.placeholder=e.messages.numberLabel??`号码`,t.setAttribute(`aria-label`,e.messages.numberLabel??`号码`);let r=e.view.kind===`active`||e.view.kind===`held`||e.view.kind===`dialing`,i=e.view.kind===`held`,a=e.view.kind===`connecting`,o=[S(e.messages.status??``,e.floating,e.extension,e.messages.extensionLabel??`分机`),b(e.messages.rowSignIn??`签入`,[C(e),x(`signin`,e.messages.signIn??`签入`,{variant:`primary`,disabled:e.connected||a}),x(`signout`,e.messages.signOut??`退签`,{disabled:!e.connected})]),b(e.messages.numberLabel??`号码`,[t],{labelFor:t.id}),b(e.messages.rowCall??`通话`,[x(`dial`,e.messages.outboundCall??`外呼`,{variant:`primary`,disabled:!e.canDial}),x(`dial-internal`,e.messages.internalCall??`内呼`,{disabled:!e.canDial}),x(`hangup`,e.messages.hangup??`挂断`,{variant:`danger`,disabled:!r}),x(`transfer`,e.messages.transfer??`转接`,{disabled:!r}),x(`hold`,e.messages.hold??`保持`,{pressed:i,disabled:!r||i}),x(`resume`,e.messages.resume??`恢复`,{disabled:!i}),E(e)]),...r?[b(e.messages.transfer??`转接号码`,[n],{labelFor:`ccbar-transfer-target`})]:[],b(e.messages.rowAgent??`坐席`,[x(`agent-available`,e.messages.agentIdle??`空闲`,{pressed:e.agentStatus===`available`,disabled:!e.connected}),x(`agent-busy`,e.messages.agentBusy??`置忙`,{disabled:!0,title:e.messages.agentBusyHint??`置忙由通话或服务端状态控制`}),x(`agent-break`,e.messages.agentBreak??`休息`,{pressed:e.agentStatus===`break`,disabled:!e.connected})]),T()];return e.calls.length>1&&o.push(O(e.calls,e.messages)),p(`div`,{attrs:{part:`panel`,"data-layout":`panel`},children:o})}function b(e,t,n={}){return p(`div`,{className:`ccbar-bar-row`,children:[p(n.labelFor===void 0?`div`:`label`,{className:`ccbar-bar-label`,attrs:n.labelFor===void 0?{}:{for:n.labelFor},text:e}),p(`div`,{className:`ccbar-bar-keys`,children:t})]})}function x(e,t,n={}){let r=e===`dial`?`call-button`:e===`hangup`?`hangup-button`:void 0;return p(`button`,{attrs:{type:`button`,"data-action":e,...r===void 0?{}:{part:r},...n.variant===void 0?{}:{"data-variant":n.variant},...n.disabled===!0?{disabled:``}:{},...n.pressed===void 0?{}:{"aria-pressed":n.pressed?`true`:`false`},...n.title===void 0?{}:{title:n.title}},text:t})}function S(e,t,n=``,r=`分机`){let i=w(e);return t&&i.setAttribute(`data-drag-handle`,``),n!==``&&i.append(p(`span`,{className:`ccbar-ext-chip`,text:`${r} ${n}`})),i}function C(e){let t=p(`input`,{attrs:{id:`ccbar-extension`,type:`tel`,inputmode:`numeric`,name:`extension`,autocomplete:`off`,placeholder:e.messages.extensionPlaceholder??`可空,由服务端分配`,"aria-label":e.messages.extensionLabel??`分机`}});return t.value=e.extension,e.connected&&(t.readOnly=!0),t}function w(e){return m(e)}function T(){return p(`div`,{className:`ccbar-dialpad`,children:g.map(e=>p(`button`,{attrs:{type:`button`,"data-digit":e},text:e}))})}function E(e){return p(`button`,{attrs:{type:`button`,"data-action":`mute`,"aria-pressed":e.muted?`true`:`false`},text:e.muted?e.messages.unmute??`取消静音`:e.messages.mute??`静音`})}function D(e,t){let n=e.kind===`held`;return p(`button`,{attrs:{type:`button`,"data-action":`hold`,"aria-pressed":n?`true`:`false`},text:n?t.resume??`恢复`:t.hold??`保持`})}function O(e,t){return p(`ul`,{className:`ccbar-call-list`,children:e.map(e=>p(`li`,{children:[p(`button`,{attrs:{type:`button`,"data-call-id":e.id},children:[p(`span`,{text:`${e.destination} ${e.direction===`inbound`?t.inbound??`呼入`:t.outbound??`呼出`} ${k(e.state,t)}`}),...e.current?[p(`span`,{className:`ccbar-call-current`,text:t.currentCall??`当前通话`})]:[]]})]}))})}function k(e,t){return e===`held`?t.statusHeld??`保持中`:e===`active`?t.statusActive??`通话中`:e===`dialing`||e===`ringing`||e===`connecting`?t.statusDialing??`拨号中`:e}function A(e){switch(e.view.kind){case`permission-error`:return p(`div`,{attrs:{part:`panel`},children:[m(e.messages.permissionTitle??`无法使用麦克风`),p(`h2`,{text:e.messages.permissionTitle??`无法使用麦克风`}),p(`p`,{text:e.messages.permissionBody??`请在浏览器设置中允许本网站访问麦克风,然后重新检测。`}),p(`button`,{attrs:{type:`button`,"data-action":`retry-permission`},text:e.messages.retryPermission??`重新检测`})]});case`unrecoverable-error`:case`unsupported`:return p(`div`,{attrs:{part:`panel`},children:[p(`div`,{attrs:{role:`alert`,part:`status-rail`},text:e.messages.errorTitle??`无法继续通话`}),p(`p`,{text:e.view.kind===`unrecoverable-error`&&e.view.code===`AUTH_TOKEN_UNAVAILABLE`?e.messages.errorTokenUnavailable??`无法获取登录凭证,请检查 token 服务是否启动及配置是否正确。`:e.messages.errorBody??`请检查网络、域名授权或坐席权限后重试。`}),...e.view.kind===`unrecoverable-error`?[p(`code`,{attrs:{"data-error-code":e.view.code},text:e.view.code})]:[]]});case`setup`:case`connecting`:case`incoming`:case`active`:case`held`:case`dialing`:case`ended`:case`ready`:return p(`div`,{attrs:{part:`panel`},children:[m(e.messages.status??``)]});default:return e.view}}function j(e){return p(`div`,{attrs:{part:`panel`},children:[m(e.messages.status??`来电`),p(`p`,{text:e.view.from}),p(`button`,{attrs:{type:`button`,"data-action":`answer`},text:e.messages.answer??`接听`}),p(`button`,{attrs:{type:`button`,"data-action":`reject`},text:e.messages.reject??`拒绝`})]})}var M=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`*`,`0`,`#`];function N(e){return F(p(`div`,{attrs:{part:`panel`,"data-layout":`mobile`},children:[m(e.status),p(`button`,{attrs:{type:`button`,"data-action":`enable-phone`,...e.enabling?{disabled:``}:{}},text:e.enablePhone??`启用电话`})]}))}function P(e){let t=e.view.kind===`active`||e.view.kind===`dialing`,n=[m(e.messages.status??``)];if(t){let t=e.view.kind===`active`||e.view.kind===`dialing`?e.view.destination??``:``;n.push(p(`p`,{text:t}),I(p(`button`,{attrs:{type:`button`,"data-action":`mute`,"aria-pressed":e.muted?`true`:`false`},text:e.muted?e.messages.unmute??`取消静音`:e.messages.mute??`静音`}),44),L(),I(p(`button`,{attrs:{type:`button`,"data-action":`hangup`,part:`hangup-button`},text:e.messages.hangup??`挂断`}),52))}else{let{field:t,input:r}=h(`ccbar-destination`,e.messages.numberLabel??`号码`);r.value=e.destination,n.push(t,L(),p(`button`,{attrs:{type:`button`,"data-action":`dial`,part:`call-button`,...e.canDial?{}:{disabled:``}},text:e.messages.call??`呼叫`}))}return e.showOutputDevice&&n.push(p(`button`,{attrs:{type:`button`,"data-action":`devices`},text:e.messages.devices??`设备`})),F(p(`div`,{attrs:{part:`panel`,"data-layout":`mobile`},children:n}))}function F(e){return e.style.minHeight=`100dvh`,e.style.paddingBottom=`max(16px, env(safe-area-inset-bottom))`,e}function I(e,t){return e.style.minHeight=`${t}px`,e}function L(){return p(`div`,{className:`ccbar-dialpad`,children:M.map(e=>p(`button`,{attrs:{type:`button`,"data-digit":e},text:e}))})}var R={kind:`permission-error`,code:`MEDIA_PERMISSION_DENIED`,action:`retry-permission`};function z(e){if(e.supported===!1)return{kind:`unsupported`};if(e.permission===`denied`||e.error?.code===`MEDIA_PERMISSION_DENIED`)return R;if(e.error!==void 0&&e.error.code!==`MEDIA_PLAYBACK_BLOCKED`)return{kind:`unrecoverable-error`,code:e.error.code};let t=e.calls.find(e=>e.direction===`inbound`&&(e.state===`ringing`||e.state===`new`));if(t!==void 0)return{kind:`incoming`,callId:t.id,from:t.destination??``};let n=e.calls.find(e=>e.state===`active`);if(n!==void 0)return{kind:`active`,callId:n.id,destination:n.destination};let r=e.calls.find(e=>e.state===`held`);if(r!==void 0)return{kind:`held`,callId:r.id,destination:r.destination};let i=e.calls.find(e=>e.state===`dialing`||e.state===`ringing`||e.state===`connecting`);if(i!==void 0)return{kind:`dialing`,callId:i.id,destination:i.destination};let a=e.calls.find(e=>e.state===`ended`||e.state===`failed`);return a===void 0?e.connectionState===`connecting`||e.connectionState===`reconnecting`?{kind:`connecting`}:e.connectionState===`connected`?{kind:`ready`}:{kind:`setup`}:{kind:`ended`,callId:a.id}}var B=`:root,:host{--ccbar-color-surface:#fff;--ccbar-color-surface-muted:#f1f5f9;--ccbar-color-border:#d8e0ea;--ccbar-color-title:#0f172a;--ccbar-color-text:#334155;--ccbar-color-muted:#475569;--ccbar-color-primary:#2563eb;--ccbar-color-primary-hover:#1d4ed8;--ccbar-color-success:#15803d;--ccbar-color-warning:#a15c00;--ccbar-color-danger:#b91c1c;--ccbar-radius-sm:6px;--ccbar-radius:8px;--ccbar-radius-lg:12px;--ccbar-control-height:40px;--ccbar-control-height-touch:44px;--ccbar-space-1:4px;--ccbar-space-2:8px;--ccbar-space-3:12px;--ccbar-space-4:16px;--ccbar-space-6:24px;--ccbar-font-family:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--ccbar-panel-width:560px}:host{color:var(--ccbar-color-text);font-family:var(--ccbar-font-family);display:block}:host([floating]){z-index:2147483646;right:var(--ccbar-space-6);bottom:var(--ccbar-space-6);position:fixed}[part=panel]{background:var(--ccbar-color-surface);border:1px solid var(--ccbar-color-border);border-radius:var(--ccbar-radius-lg)}[part=status-rail]{align-items:center;gap:var(--ccbar-space-2);min-height:var(--ccbar-control-height);padding:var(--ccbar-space-2) var(--ccbar-space-3);border-bottom:1px solid var(--ccbar-color-border);color:var(--ccbar-color-muted);font-variant-numeric:tabular-nums;display:flex}[part=status-rail]:before{content:"";background:var(--ccbar-color-muted);border-radius:50%;flex:none;width:8px;height:8px}button{min-height:var(--ccbar-control-height);border:1px solid var(--ccbar-color-border);border-radius:var(--ccbar-radius-sm);background:var(--ccbar-color-surface);color:var(--ccbar-color-title);font:inherit}button[data-action=dial],button[data-action=signin],button[data-action=answer],button[data-variant=primary]{background:var(--ccbar-color-primary);border-color:var(--ccbar-color-primary);color:#fff}button[aria-pressed=true]{border-color:var(--ccbar-color-primary);color:var(--ccbar-color-primary);background:var(--ccbar-color-surface-muted)}button[data-action=hangup],button[data-action=reject]{background:var(--ccbar-color-danger);border-color:var(--ccbar-color-danger);color:#fff;margin-top:var(--ccbar-space-4)}button:disabled{opacity:.5}button:focus-visible,input:focus-visible{outline:2px solid var(--ccbar-color-primary);outline-offset:2px}input[type=tel]{width:100%;min-height:var(--ccbar-control-height);border:1px solid var(--ccbar-color-border);border-radius:var(--ccbar-radius-sm);font-variant-numeric:tabular-nums}.ccbar-call-list{gap:var(--ccbar-space-2);margin:var(--ccbar-space-3) 0 0;padding:0;list-style:none;display:grid}.ccbar-call-list button{text-align:left;width:100%}.ccbar-call-current{color:var(--ccbar-color-title);display:block}[data-layout=compact]{min-height:80px;max-height:96px}[data-layout=compact] .ccbar-toolbar{gap:var(--ccbar-space-2);padding:var(--ccbar-space-2) var(--ccbar-space-3);grid-template-columns:minmax(0,1fr) auto auto auto;align-items:center;display:grid}[data-layout=compact] .ccbar-more{right:var(--ccbar-space-3);gap:var(--ccbar-space-2);display:grid;position:absolute}[data-layout=panel]{width:min(var(--ccbar-panel-width), 100%);min-width:420px;max-width:560px;padding:var(--ccbar-space-3)}[data-layout=panel] .ccbar-bar-row{gap:var(--ccbar-space-2) var(--ccbar-space-3);grid-template-columns:48px minmax(0,1fr);align-items:center;min-height:36px;display:grid}[data-layout=panel] .ccbar-bar-row+.ccbar-bar-row{margin-top:var(--ccbar-space-2)}[data-layout=panel] .ccbar-bar-label{color:var(--ccbar-color-muted);font-size:12px}[data-layout=panel] .ccbar-bar-keys{align-items:center;gap:var(--ccbar-space-2);flex-wrap:wrap;display:flex}[data-layout=panel] .ccbar-bar-keys button{min-width:48px;min-height:32px;padding:0 10px;font-size:13px}[data-layout=panel] .ccbar-bar-keys input[type=tel]{max-width:320px}[data-layout=panel] .ccbar-bar-keys input[name=extension]{width:148px;max-width:148px}[data-layout=panel] .ccbar-ext-chip{background:var(--ccbar-color-surface-muted);height:28px;color:var(--ccbar-color-title);font-variant-numeric:tabular-nums;border-radius:999px;align-items:center;margin-left:auto;padding:0 10px;font-size:12px;display:inline-flex}[data-layout=panel] [data-action=hangup]{margin-top:0}[data-layout=panel] .ccbar-dialpad{gap:var(--ccbar-space-2);margin:var(--ccbar-space-3) 0 0;grid-template-columns:repeat(3,1fr);display:grid}[data-layout=panel] .ccbar-safe-actions{gap:var(--ccbar-space-2);flex-wrap:wrap;display:flex}[data-layout=mobile]{min-height:100vh;padding:var(--ccbar-space-4);padding-bottom:max(16px, env(safe-area-inset-bottom))}[data-layout=mobile] button{min-width:44px;min-height:44px}[data-layout=mobile] [data-action=enable-phone],[data-layout=mobile] [data-action=dial],[data-layout=mobile] [data-action=hangup]{min-height:52px}[data-layout=mobile] .ccbar-dialpad{gap:var(--ccbar-space-2);margin:var(--ccbar-space-3) 0;grid-template-columns:repeat(3,1fr);display:grid}:host([data-theme=dark]){--ccbar-color-surface:#0f172a;--ccbar-color-surface-muted:#1e293b;--ccbar-color-border:#334155;--ccbar-color-title:#f8fafc;--ccbar-color-text:#e2e8f0;--ccbar-color-muted:#94a3b8;--ccbar-color-primary:#3b82f6;--ccbar-color-primary-hover:#2563eb;--ccbar-color-success:#22c55e;--ccbar-color-warning:#f59e0b;--ccbar-color-danger:#ef4444}@media (prefers-reduced-motion:reduce){:host *,:host :before,:host :after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}`,V=typeof HTMLElement==`function`?HTMLElement:class{},H=new WeakSet,U=[`connection.stateChanged`,`connection.reconnecting`,`connection.failed`,`call.incoming`,`call.stateChanged`,`call.activeChanged`,`call.ended`,`call.failed`,`media.permissionChanged`,`agent.statusChanged`,`error`],W=class extends V{static get observedAttributes(){return[`mode`,`floating`,`draggable`,`locale`,`theme`]}#e;#t=!1;#n=[];#r=`idle`;#i=`unknown`;#a;#o=new Set;#s=``;#c=``;#l=`offline`;#u=!1;#d=!1;#f=Promise.resolve();#p;#m=!1;#h=!1;#g;#_;#v;#y;#b;get messageResolver(){return this.#y}set messageResolver(e){this.#y=e,this.shadowRoot!==null&&this.render()}get client(){return this.#e}set client(e){this.#O(),this.#e=e,this.#D(),this.render()}get ownsClient(){return this.#t}set ownsClient(e){this.#t=e===!0}connectedCallback(){this.#V(),this.#B(),this.render()}disconnectedCallback(){let e=this.#e,t=this.#t;this.#O(),this.#G(),this.#b?.(),this.#b=void 0,t&&(this.#e=void 0,e?.dispose())}attributeChangedCallback(e){this.#V(),e===`theme`&&this.#B(),this.shadowRoot!==null&&this.render()}render(){let e=this.#k();e!==void 0&&(e.innerHTML=`<style>${B}</style>`,e.append(this.#S(this.#x())))}#x(){let e=this.#e?.getCalls?.().map(e=>({id:e.id,state:e.state,destination:e.destination,direction:this.#o.has(e.id)?`inbound`:`outbound`}))??[];return z({connectionState:this.#r,permission:this.#i,calls:e,error:this.#a})}#S(e){let t=this.#z(),n=this.#_??this.#g??K(e,t),r={...t,status:n},i=this.#C(e,r,n);return i.setAttribute(`data-view`,this.#E()&&!this.#m?`setup`:e.kind),i.hasAttribute(`data-layout`)||i.setAttribute(`data-layout`,this.#E()?`mobile`:`panel`),i}#C(e,t,n){if(this.#E()&&!this.#m)return N({enabling:this.#h,status:n,enablePhone:t.enablePhone});switch(e.kind){case`permission-error`:case`unrecoverable-error`:case`unsupported`:return A({view:e,messages:t});case`incoming`:return this.#E()?P({view:{kind:`ready`},messages:t,destination:this.#s,muted:this.#u,canDial:s(this.#s,this.#i,this.#r),showOutputDevice:this.#e?.media.supportsOutputSelection()===!0}):j({view:e,messages:t});case`setup`:case`connecting`:case`ended`:case`ready`:case`active`:case`held`:case`dialing`:return this.#E()?P({view:e.kind===`held`?{kind:`ready`}:e,messages:t,destination:this.#s,muted:this.#u,canDial:s(this.#s,this.#i,this.#r),showOutputDevice:this.#e?.media.supportsOutputSelection()===!0}):_({mode:this.#T()===`compact`?`compact`:`panel`,view:e,messages:t,destination:this.#s,muted:this.#u,canDial:s(this.#s,this.#i,this.#r),moreOpen:this.#d,floating:this.hasAttribute(`floating`),connected:this.#r===`connected`,agentStatus:this.#l,extension:this.#c,calls:this.#w()});default:return e}}#w(){let e=this.#e?.getActiveCall?.()?.id;return this.#e?.getCalls?.().map(t=>({id:t.id,destination:t.destination,state:t.state,direction:this.#o.has(t.id)?`inbound`:`outbound`,current:t.id===e}))??[]}#T(){let e=this.getAttribute(`mode`);return e===`compact`||e===`mobile`?e:`panel`}#E(){return this.#T()===`mobile`}#D(){let e=this.#e;e!==void 0&&(this.#n.push(e.on(`connection.stateChanged`,t=>{if(this.#r=t.state,t.state!==`connected`&&(this.#l=`offline`),t.state===`connected`){let t=e.getAgent?.()?.extension?.trim();t!==void 0&&t!==``&&(this.#c=t)}})),this.#n.push(e.on(`agent.statusChanged`,e=>{(e.status===`available`||e.status===`offline`||e.status===`break`)&&(this.#l=e.status)})),this.#n.push(e.on(`connection.failed`,e=>{this.#r=`failed`,this.#a={code:e.error.code}})),this.#n.push(e.on(`media.permissionChanged`,e=>{this.#i=e.permission})),this.#n.push(e.on(`error`,e=>{this.#a={code:e.error.code}})),this.#n.push(e.on(`call.incoming`,e=>{this.#o.add(e.callId)})),this.#n.push(e.on(`call.ended`,e=>{this.#o.delete(e.callId),this.#u=!1})),this.#n.push(e.on(`call.failed`,()=>{this.#_=this.#z().statusFailed})),U.forEach(t=>{this.#n.push(e.on(t,()=>this.render()))}),this.#E()&&typeof e.recover==`function`&&(this.#v=a(e,{onChecking:()=>{this.#g=this.#z().foregroundChecking,this.render()},onRecovered:()=>{this.#g=void 0,this.render()},onFailed:()=>{this.#g=this.#z().foregroundFailed,this.render()}})))}#O(){let e=this.#n;this.#n=[],e.forEach(e=>e()),this.#r=`idle`,this.#i=`unknown`,this.#l=`offline`,this.#a=void 0,this.#o.clear(),this.#u=!1,this.#d=!1,this.#m=!1,this.#h=!1,this.#g=void 0,this.#v?.(),this.#v=void 0}#k(){if(typeof this.attachShadow!=`function`)return;let e=this.shadowRoot??this.attachShadow({mode:`open`});return H.has(e)||(H.add(e),e.addEventListener(`click`,e=>this.#A(e)),e.addEventListener(`input`,e=>this.#P(e)),e.addEventListener(`pointerdown`,e=>this.#H(e))),e}#A(e){let t=J(e,this),n=t?.closest(`[data-action="enable-phone"]`);n instanceof HTMLButtonElement&&(n.disabled=!0),this.#f=this.#f.then(()=>this.#F(t)).catch(e=>{this.#_=Y(e),this.render()})}#j(){let e=this.shadowRoot?.querySelector(`input[name="destination"]`);return e instanceof HTMLInputElement?e.value:this.#s}#M(){let e=this.shadowRoot?.querySelector(`input[name="extension"]`);return e instanceof HTMLInputElement?e.value.trim():this.#c}#N(){let e=this.shadowRoot?.querySelector(`input[name="transfer-target"]`);return e instanceof HTMLInputElement?e.value:``}#P(e){let t=J(e,this);if(t instanceof HTMLInputElement&&t.name!==`transfer-target`){if(t.name===`extension`){this.#c=t.value.trim();return}this.#s=t.value,this.#L()}}async#F(e){if(this.#_=void 0,e===void 0)return;let t=e.closest(`[data-call-id]`);if(t instanceof HTMLElement&&t.dataset.callId!==void 0){await this.#e?.setActiveCall(t.dataset.callId);return}let n=e.closest(`[data-digit]`);if(n instanceof HTMLElement&&n.dataset.digit!==void 0){await this.#I(n.dataset.digit);return}let r=e.closest(`[data-action]`);if(!(r instanceof HTMLElement)||r instanceof HTMLButtonElement&&r.disabled&&r.getAttribute(`data-action`)!==`enable-phone`)return;let a=this.#e?.getActiveCall?.();switch(r.getAttribute(`data-action`)){case`signin`:if(this.#e===void 0)return;this.#c=this.#M(),await this.#e.media?.requestPermission?.(),await this.#e.initialize(),await this.#e.connect();return;case`signout`:if(this.#e===void 0)return;this.#l=`offline`,await this.#e.disconnect();return;case`dial`:case`dial-internal`:if(this.#s=this.#j(),this.#e===void 0)return;this.#i!==`granted`&&await this.#e.media?.requestPermission?.(),await c(this.#e,this.#s,r.getAttribute(`data-action`)===`dial-internal`?`extension`:void 0);return;case`mute`:if(a===void 0)return;this.#u=await l(a,this.#u),this.#R();return;case`hold`:a!==void 0&&await u(a);return;case`resume`:a!==void 0&&await a.resume();return;case`transfer`:a!==void 0&&await f(a,this.#N());return;case`hangup`:await a?.hangup();return;case`answer`:a!==void 0&&await this.#e?.answer(a.id);return;case`reject`:await a?.reject();return;case`enable-phone`:if(this.#e===void 0||this.#m)return;this.#h=!0;try{await i(this.#e),this.#m=!0}finally{this.#h=!1,this.render()}return;case`more`:this.#d=!this.#d,this.render();return;case`retry-permission`:await this.#e?.media.requestPermission();return;case`devices`:return;case`agent-available`:await this.#e?.setAgentStatus(`available`);return;case`agent-break`:await this.#e?.setAgentStatus(`break`);return;case`agent-busy`:return;default:return}}async#I(e){let t=this.#e?.getActiveCall?.();if(t!==void 0&&(t.state===`active`||t.state===`held`)){await d(t,e);return}this.#s+=e;let n=this.shadowRoot?.querySelector(`input[name="destination"]`);n instanceof HTMLInputElement&&(n.value=this.#s),this.#L()}#L(){let e=!s(this.#s,this.#i,this.#r);for(let t of[`dial`,`dial-internal`]){let n=this.shadowRoot?.querySelector(`[data-action="${t}"]`);n instanceof HTMLButtonElement&&(n.disabled=e)}}#R(){let e=this.shadowRoot?.querySelector(`[data-action="mute"]`);e instanceof HTMLButtonElement&&(e.setAttribute(`aria-pressed`,this.#u?`true`:`false`),e.textContent=this.#u?this.#z().unmute:this.#z().mute)}#z(){return r(this.getAttribute(`locale`)??`zh-CN`,void 0,this.#y)}#B(){this.#b?.(),this.#b=void 0;let e=this.getAttribute(`theme`)??`light`;if(e===`dark`||e===`light`){this.setAttribute(`data-theme`,e);return}if(typeof window>`u`||typeof window.matchMedia!=`function`){this.setAttribute(`data-theme`,`light`);return}let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{this.setAttribute(`data-theme`,t.matches?`dark`:`light`)};n(),t.addEventListener(`change`,n),this.#b=()=>t.removeEventListener(`change`,n)}#V(){this.style.position=this.hasAttribute(`floating`)?`fixed`:``}#H(e){if(!(e instanceof PointerEvent)||!this.hasAttribute(`floating`)||!this.hasAttribute(`draggable`)||(e.target instanceof Element?e.target.closest(`[data-drag-handle]`):null)===null)return;e.preventDefault();let t=this.getBoundingClientRect();this.#p={pointerId:e.pointerId,offsetX:e.clientX-t.left,offsetY:e.clientY-t.top},window.addEventListener(`pointermove`,this.#U),window.addEventListener(`pointerup`,this.#W)}#U=e=>{if(this.#p===void 0||e.pointerId!==this.#p.pointerId)return;let t=window.visualViewport,n=t?.width??window.innerWidth,r=t?.height??window.innerHeight,i=q(e.clientX-this.#p.offsetX,0,Math.max(0,n-this.offsetWidth)),a=q(e.clientY-this.#p.offsetY,0,Math.max(0,r-this.offsetHeight));this.style.left=`${i}px`,this.style.top=`${a}px`,this.style.right=`auto`,this.style.bottom=`auto`};#W=e=>{this.#p!==void 0&&e.pointerId===this.#p.pointerId&&this.#G()};#G(){this.#p=void 0,window.removeEventListener(`pointermove`,this.#U),window.removeEventListener(`pointerup`,this.#W)}};function G(e={}){if(typeof customElements>`u`)return;let t=e.tagName??`xcall-ccbar`;if(customElements.get(t)!==void 0)return;let n=t===`xcall-ccbar`?W:class extends W{};customElements.define(t,n)}function K(e,t){switch(e.kind){case`unsupported`:return t.statusUnsupported;case`permission-error`:return t.statusPermission;case`unrecoverable-error`:return t.statusError;case`setup`:return t.statusSetup;case`connecting`:return t.statusConnecting;case`incoming`:return t.statusIncoming;case`active`:return t.statusActive;case`held`:return t.statusHeld;case`dialing`:return t.statusDialing;case`ended`:return t.statusEnded;case`ready`:return t.statusReady;default:return e}}function q(e,t,n){return Math.min(n,Math.max(t,e))}function J(e,t){for(let n of e.composedPath())if(n instanceof Element&&n!==t)return n;return e.target instanceof Element&&e.target!==t?e.target:void 0}function Y(e){return typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:`SDK_INTERNAL_ERROR`}var X=`0.1.0`;exports.XCallCCBarElement=W,exports.defineCCBarElement=G,exports.enUS=e,exports.resolveMessages=r,exports.uiVersion=X,exports.zhCN=t;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../i18n-BbEy6K9z.cjs");require("../createJsSipFactory-Dr8HbLl-.cjs");var t={call:`Call`,numberLabel:`Number`,statusReady:`Ready`,statusSetup:`Not initialized`,statusConnecting:`Connecting`,statusIncoming:`Incoming call`,statusActive:`On a call`,statusHeld:`On hold`,statusDialing:`Dialing`,statusEnded:`Call ended`,statusFailed:`Call failed`,statusUnsupported:`Unsupported browser`,statusPermission:`Microphone unavailable`,statusError:`Unable to continue`,incoming:`Incoming call`,answer:`Answer`,reject:`Decline`,hangup:`Hang up`,mute:`Mute`,unmute:`Unmute`,hold:`Hold`,resume:`Resume`,transfer:`Transfer`,blindTransfer:`Blind transfer`,more:`More`,devices:`Devices`,enablePhone:`Enable phone`,retryPermission:`Check again`,permissionTitle:`Microphone unavailable`,permissionBody:`Allow microphone access in the browser settings, then check again.`,errorTitle:`Unable to continue`,errorBody:`Check the network, origin allowlist, or agent permission, then retry.`,errorTokenUnavailable:`Could not get a sign-in token. Check that the token service is running and configured.`,currentCall:`Current call`,inbound:`Inbound`,outbound:`Outbound`,foregroundChecking:`Back in foreground, checking the connection`,foregroundFailed:`Foreground recovery failed. Retry.`,signIn:`Sign in`,signOut:`Sign out`,outboundCall:`Outbound`,internalCall:`Internal`,agentIdle:`Available`,agentBusy:`Busy`,agentBreak:`Break`,agentBusyHint:`Busy is controlled by the call or server`,rowSignIn:`Presence`,rowCall:`Call`,rowAgent:`Agent`,extensionLabel:`Extension`,extensionPlaceholder:`Optional, assigned by the server`},n={call:`Llamar`,numberLabel:`Número`,statusReady:`Listo`,statusSetup:`Sin inicializar`,statusConnecting:`Conectando`,statusIncoming:`Llamada entrante`,statusActive:`En llamada`,statusHeld:`En espera`,statusDialing:`Marcando`,statusEnded:`Llamada finalizada`,statusFailed:`Llamada fallida`,statusUnsupported:`Navegador no compatible`,statusPermission:`Micrófono no disponible`,statusError:`No se puede continuar`,incoming:`Llamada entrante`,answer:`Responder`,reject:`Rechazar`,hangup:`Colgar`,mute:`Silenciar`,unmute:`Activar sonido`,hold:`Retener`,resume:`Reanudar`,transfer:`Transferir`,blindTransfer:`Transferencia directa`,more:`Más`,devices:`Dispositivos`,enablePhone:`Activar teléfono`,retryPermission:`Comprobar de nuevo`,permissionTitle:`Micrófono no disponible`,permissionBody:`Permita el acceso al micrófono en la configuración del navegador y compruebe de nuevo.`,errorTitle:`No se puede continuar`,errorBody:`Compruebe la red, la autorización del dominio o el permiso del agente y vuelva a intentarlo.`,errorTokenUnavailable:`No se pudo obtener la credencial de acceso. Compruebe que el servicio de token esté activo y configurado.`,currentCall:`Llamada actual`,inbound:`Entrante`,outbound:`Saliente`,foregroundChecking:`De vuelta en primer plano, comprobando la conexión`,foregroundFailed:`Error al recuperar. Vuelva a intentarlo.`,signIn:`Iniciar sesión`,signOut:`Cerrar sesión`,outboundCall:`Saliente`,internalCall:`Interna`,agentIdle:`Disponible`,agentBusy:`Ocupado`,agentBreak:`Descanso`,agentBusyHint:`El estado ocupado lo controla la llamada o el servidor`,rowSignIn:`Presencia`,rowCall:`Llamada`,rowAgent:`Agente`,extensionLabel:`Extensión`,extensionPlaceholder:`Opcional, asignada por el servidor`},r={call:`Panggil`,numberLabel:`Nomor`,statusReady:`Siap menelepon`,statusSetup:`Belum diinisialisasi`,statusConnecting:`Menghubungkan`,statusIncoming:`Panggilan masuk`,statusActive:`Sedang menelepon`,statusHeld:`Ditahan`,statusDialing:`Sedang memanggil`,statusEnded:`Panggilan berakhir`,statusFailed:`Panggilan gagal`,statusUnsupported:`Browser tidak didukung`,statusPermission:`Mikrofon tidak tersedia`,statusError:`Tidak dapat melanjutkan panggilan`,incoming:`Panggilan masuk`,answer:`Jawab`,reject:`Tolak`,hangup:`Tutup`,mute:`Bisukan`,unmute:`Aktifkan suara`,hold:`Tahan`,resume:`Lanjutkan`,transfer:`Alihkan`,blindTransfer:`Alihkan langsung`,more:`Lainnya`,devices:`Perangkat`,enablePhone:`Aktifkan telepon`,retryPermission:`Periksa ulang`,permissionTitle:`Mikrofon tidak tersedia`,permissionBody:`Izinkan akses mikrofon untuk situs ini di pengaturan browser, lalu periksa ulang.`,errorTitle:`Tidak dapat melanjutkan panggilan`,errorBody:`Periksa jaringan, izin domain, atau izin agen, lalu coba lagi.`,errorTokenUnavailable:`Tidak dapat mendapatkan kredensial masuk. Periksa apakah layanan token berjalan dan konfigurasinya benar.`,currentCall:`Panggilan saat ini`,inbound:`Masuk`,outbound:`Keluar`,foregroundChecking:`Kembali ke depan, memeriksa koneksi`,foregroundFailed:`Pemulihan gagal, coba lagi`,signIn:`Masuk`,signOut:`Keluar`,outboundCall:`Panggilan keluar`,internalCall:`Panggilan internal`,agentIdle:`Tersedia`,agentBusy:`Sibuk`,agentBreak:`Istirahat`,agentBusyHint:`Status sibuk dikendalikan oleh panggilan atau server`,rowSignIn:`Kehadiran`,rowCall:`Panggilan`,rowAgent:`Agen`,extensionLabel:`Ekstensi`,extensionPlaceholder:`Opsional, ditentukan server`},i={call:`呼叫`,numberLabel:`号码`,statusReady:`可拨号`,statusSetup:`未初始化`,statusConnecting:`正在连接`,statusIncoming:`来电`,statusActive:`通话中`,statusHeld:`保持中`,statusDialing:`正在拨号`,statusEnded:`通话结束`,statusFailed:`呼叫失败`,statusUnsupported:`不支持的浏览器`,statusPermission:`无法使用麦克风`,statusError:`无法继续通话`,incoming:`来电`,answer:`接听`,reject:`拒绝`,hangup:`挂断`,mute:`静音`,unmute:`取消静音`,hold:`保持`,resume:`恢复`,transfer:`转接`,blindTransfer:`盲转`,more:`更多`,devices:`设备`,enablePhone:`启用电话`,retryPermission:`重新检测`,permissionTitle:`无法使用麦克风`,permissionBody:`请在浏览器设置中允许本网站访问麦克风,然后重新检测。`,errorTitle:`无法继续通话`,errorBody:`请检查网络、域名授权或坐席权限后重试。`,errorTokenUnavailable:`无法获取登录凭证,请检查 token 服务是否启动及配置是否正确。`,currentCall:`当前通话`,inbound:`呼入`,outbound:`呼出`,foregroundChecking:`已返回前台,正在检查连接`,foregroundFailed:`前台恢复失败,请重试`,signIn:`签入`,signOut:`退签`,outboundCall:`外呼`,internalCall:`内呼`,agentIdle:`空闲`,agentBusy:`置忙`,agentBreak:`休息`,agentBusyHint:`置忙由通话或服务端状态控制`,rowSignIn:`签入`,rowCall:`通话`,rowAgent:`坐席`,extensionLabel:`分机`,extensionPlaceholder:`可空,由服务端分配`},a={"zh-CN":i,"en-US":t,"id-ID":r,"es-ES":n};function o(t){return a[e.a(t)]}function s(e,t,n){return{...o(e),...n===void 0?{}:n(e),...t??{}}}async function c(e){await e.media.requestPermission(),await e.initialize(),await e.connect()}function l(e,t={}){let n=t.document??(typeof document>`u`?void 0:document);if(n===void 0)return()=>void 0;let r=()=>{if(n.visibilityState===`hidden`){t.onHidden?.();return}t.onChecking?.(),e.recover().then(()=>t.onRecovered?.()).catch(e=>t.onFailed?.(e))};return n.addEventListener(`visibilitychange`,r),()=>n.removeEventListener(`visibilitychange`,r)}function u(e){return e.replace(/\s+/g,``)}function d(e,t,n){return u(e).length>0&&n===`connected`&&t!==`denied`}async function f(e,t,n){let r=u(t);r!==``&&await e.dial({destination:r,...n===void 0?{}:{type:n}})}async function p(e,t){return t?await e.unmute():await e.mute(),!t}async function m(e){e.state===`held`?await e.resume():await e.hold()}async function h(e,t){await e.sendDtmf(t)}async function g(e,t){let n=u(t);n!==``&&await e.transfer({target:n,type:`blind`})}function _(e,t={}){let n=document.createElement(e);return t.className!==void 0&&(n.className=t.className),t.text!==void 0&&(n.textContent=t.text),Object.entries(t.attrs??{}).forEach(([e,t])=>n.setAttribute(e,t)),t.children?.forEach(e=>n.append(e)),n}function v(e){return _(`div`,{attrs:{part:`status-rail`,role:`status`,"aria-live":`polite`},text:e})}function y(e,t,n=`destination`){let r=_(`input`,{attrs:{id:e,type:`tel`,inputmode:`tel`,name:n,autocomplete:`tel`}});return{field:_(`div`,{children:[_(`label`,{attrs:{for:e},text:t}),r]}),input:r}}var b=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`*`,`0`,`#`];function x(e){return e.mode===`compact`?S(e):C(e)}function S(e){let{field:t,input:n}=y(`ccbar-destination`,e.messages.numberLabel??`号码`);n.value=e.destination;let r=e.view.kind===`ready`||e.view.kind===`setup`||e.view.kind===`ended`?_(`button`,{attrs:{type:`button`,"data-action":`dial`,part:`call-button`,...e.canDial?{}:{disabled:``}},text:e.messages.call??`呼叫`}):_(`button`,{attrs:{type:`button`,"data-action":`hangup`,part:`hangup-button`},text:e.messages.hangup??`挂断`}),i=[E(e.messages.status??``,e.floating),_(`div`,{className:`ccbar-toolbar`,children:[t,e.view.kind===`active`||e.view.kind===`held`?A(e):_(`span`),r,_(`button`,{attrs:{type:`button`,"data-action":`more`},text:e.messages.more??`更多`})]})];return e.moreOpen&&i.push(_(`div`,{className:`ccbar-more`,children:[j(e.view,e.messages),_(`button`,{attrs:{type:`button`,"data-action":`devices`},text:e.messages.devices??`设备`})]})),_(`div`,{attrs:{part:`panel`,"data-layout":`compact`},children:i})}function C(e){let{input:t}=y(`ccbar-destination`,e.messages.numberLabel??`号码`),{field:n}=y(`ccbar-transfer-target`,e.messages.transfer??`转接号码`,`transfer-target`);t.value=e.destination,t.placeholder=e.messages.numberLabel??`号码`,t.setAttribute(`aria-label`,e.messages.numberLabel??`号码`);let r=e.view.kind===`active`||e.view.kind===`held`||e.view.kind===`dialing`,i=e.view.kind===`held`,a=e.view.kind===`connecting`,o=[E(e.messages.status??``,e.floating,e.extension,e.messages.extensionLabel??`分机`),w(e.messages.rowSignIn??`签入`,[D(e),T(`signin`,e.messages.signIn??`签入`,{variant:`primary`,disabled:e.connected||a}),T(`signout`,e.messages.signOut??`退签`,{disabled:!e.connected})]),w(e.messages.numberLabel??`号码`,[t],{labelFor:t.id}),w(e.messages.rowCall??`通话`,[T(`dial`,e.messages.outboundCall??`外呼`,{variant:`primary`,disabled:!e.canDial}),T(`dial-internal`,e.messages.internalCall??`内呼`,{disabled:!e.canDial}),T(`hangup`,e.messages.hangup??`挂断`,{variant:`danger`,disabled:!r}),T(`transfer`,e.messages.transfer??`转接`,{disabled:!r}),T(`hold`,e.messages.hold??`保持`,{pressed:i,disabled:!r||i}),T(`resume`,e.messages.resume??`恢复`,{disabled:!i}),A(e)]),...r?[w(e.messages.transfer??`转接号码`,[n],{labelFor:`ccbar-transfer-target`})]:[],w(e.messages.rowAgent??`坐席`,[T(`agent-available`,e.messages.agentIdle??`空闲`,{pressed:e.agentStatus===`available`,disabled:!e.connected}),T(`agent-busy`,e.messages.agentBusy??`置忙`,{disabled:!0,title:e.messages.agentBusyHint??`置忙由通话或服务端状态控制`}),T(`agent-break`,e.messages.agentBreak??`休息`,{pressed:e.agentStatus===`break`,disabled:!e.connected})]),k()];return e.calls.length>1&&o.push(M(e.calls,e.messages)),_(`div`,{attrs:{part:`panel`,"data-layout":`panel`},children:o})}function w(e,t,n={}){return _(`div`,{className:`ccbar-bar-row`,children:[_(n.labelFor===void 0?`div`:`label`,{className:`ccbar-bar-label`,attrs:n.labelFor===void 0?{}:{for:n.labelFor},text:e}),_(`div`,{className:`ccbar-bar-keys`,children:t})]})}function T(e,t,n={}){let r=e===`dial`?`call-button`:e===`hangup`?`hangup-button`:void 0;return _(`button`,{attrs:{type:`button`,"data-action":e,...r===void 0?{}:{part:r},...n.variant===void 0?{}:{"data-variant":n.variant},...n.disabled===!0?{disabled:``}:{},...n.pressed===void 0?{}:{"aria-pressed":n.pressed?`true`:`false`},...n.title===void 0?{}:{title:n.title}},text:t})}function E(e,t,n=``,r=`分机`){let i=O(e);return t&&i.setAttribute(`data-drag-handle`,``),n!==``&&i.append(_(`span`,{className:`ccbar-ext-chip`,text:`${r} ${n}`})),i}function D(e){let t=_(`input`,{attrs:{id:`ccbar-extension`,type:`tel`,inputmode:`numeric`,name:`extension`,autocomplete:`off`,placeholder:e.messages.extensionPlaceholder??`可空,由服务端分配`,"aria-label":e.messages.extensionLabel??`分机`}});return t.value=e.extension,e.connected&&(t.readOnly=!0),t}function O(e){return v(e)}function k(){return _(`div`,{className:`ccbar-dialpad`,children:b.map(e=>_(`button`,{attrs:{type:`button`,"data-digit":e},text:e}))})}function A(e){return _(`button`,{attrs:{type:`button`,"data-action":`mute`,"aria-pressed":e.muted?`true`:`false`},text:e.muted?e.messages.unmute??`取消静音`:e.messages.mute??`静音`})}function j(e,t){let n=e.kind===`held`;return _(`button`,{attrs:{type:`button`,"data-action":`hold`,"aria-pressed":n?`true`:`false`},text:n?t.resume??`恢复`:t.hold??`保持`})}function M(e,t){return _(`ul`,{className:`ccbar-call-list`,children:e.map(e=>_(`li`,{children:[_(`button`,{attrs:{type:`button`,"data-call-id":e.id},children:[_(`span`,{text:`${e.destination} ${e.direction===`inbound`?t.inbound??`呼入`:t.outbound??`呼出`} ${N(e.state,t)}`}),...e.current?[_(`span`,{className:`ccbar-call-current`,text:t.currentCall??`当前通话`})]:[]]})]}))})}function N(e,t){return e===`held`?t.statusHeld??`保持中`:e===`active`?t.statusActive??`通话中`:e===`dialing`||e===`ringing`||e===`connecting`?t.statusDialing??`拨号中`:e}function P(e){switch(e.view.kind){case`permission-error`:return _(`div`,{attrs:{part:`panel`},children:[v(e.messages.permissionTitle??`无法使用麦克风`),_(`h2`,{text:e.messages.permissionTitle??`无法使用麦克风`}),_(`p`,{text:e.messages.permissionBody??`请在浏览器设置中允许本网站访问麦克风,然后重新检测。`}),_(`button`,{attrs:{type:`button`,"data-action":`retry-permission`},text:e.messages.retryPermission??`重新检测`})]});case`unrecoverable-error`:case`unsupported`:return _(`div`,{attrs:{part:`panel`},children:[_(`div`,{attrs:{role:`alert`,part:`status-rail`},text:e.messages.errorTitle??`无法继续通话`}),_(`p`,{text:e.view.kind===`unrecoverable-error`&&e.view.code===`AUTH_TOKEN_UNAVAILABLE`?e.messages.errorTokenUnavailable??`无法获取登录凭证,请检查 token 服务是否启动及配置是否正确。`:e.messages.errorBody??`请检查网络、域名授权或坐席权限后重试。`}),...e.view.kind===`unrecoverable-error`?[_(`code`,{attrs:{"data-error-code":e.view.code},text:e.view.code})]:[]]});case`setup`:case`connecting`:case`incoming`:case`active`:case`held`:case`dialing`:case`ended`:case`ready`:return _(`div`,{attrs:{part:`panel`},children:[v(e.messages.status??``)]});default:return e.view}}function F(e){return _(`div`,{attrs:{part:`panel`},children:[v(e.messages.status??`来电`),_(`p`,{text:e.view.from}),_(`button`,{attrs:{type:`button`,"data-action":`answer`},text:e.messages.answer??`接听`}),_(`button`,{attrs:{type:`button`,"data-action":`reject`},text:e.messages.reject??`拒绝`})]})}var I=[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`,`*`,`0`,`#`];function L(e){return z(_(`div`,{attrs:{part:`panel`,"data-layout":`mobile`},children:[v(e.status),_(`button`,{attrs:{type:`button`,"data-action":`enable-phone`,...e.enabling?{disabled:``}:{}},text:e.enablePhone??`启用电话`})]}))}function R(e){let t=e.view.kind===`active`||e.view.kind===`dialing`,n=[v(e.messages.status??``)];if(t){let t=e.view.kind===`active`||e.view.kind===`dialing`?e.view.destination??``:``;n.push(_(`p`,{text:t}),B(_(`button`,{attrs:{type:`button`,"data-action":`mute`,"aria-pressed":e.muted?`true`:`false`},text:e.muted?e.messages.unmute??`取消静音`:e.messages.mute??`静音`}),44),V(),B(_(`button`,{attrs:{type:`button`,"data-action":`hangup`,part:`hangup-button`},text:e.messages.hangup??`挂断`}),52))}else{let{field:t,input:r}=y(`ccbar-destination`,e.messages.numberLabel??`号码`);r.value=e.destination,n.push(t,V(),_(`button`,{attrs:{type:`button`,"data-action":`dial`,part:`call-button`,...e.canDial?{}:{disabled:``}},text:e.messages.call??`呼叫`}))}return e.showOutputDevice&&n.push(_(`button`,{attrs:{type:`button`,"data-action":`devices`},text:e.messages.devices??`设备`})),z(_(`div`,{attrs:{part:`panel`,"data-layout":`mobile`},children:n}))}function z(e){return e.style.minHeight=`100dvh`,e.style.paddingBottom=`max(16px, env(safe-area-inset-bottom))`,e}function B(e,t){return e.style.minHeight=`${t}px`,e}function V(){return _(`div`,{className:`ccbar-dialpad`,children:I.map(e=>_(`button`,{attrs:{type:`button`,"data-digit":e},text:e}))})}var H={kind:`permission-error`,code:`MEDIA_PERMISSION_DENIED`,action:`retry-permission`};function U(e){if(e.supported===!1)return{kind:`unsupported`};if(e.permission===`denied`||e.error?.code===`MEDIA_PERMISSION_DENIED`)return H;if(e.error!==void 0&&e.error.code!==`MEDIA_PLAYBACK_BLOCKED`)return{kind:`unrecoverable-error`,code:e.error.code};let t=e.calls.find(e=>e.direction===`inbound`&&(e.state===`ringing`||e.state===`new`));if(t!==void 0)return{kind:`incoming`,callId:t.id,from:t.destination??``};let n=e.calls.find(e=>e.state===`active`);if(n!==void 0)return{kind:`active`,callId:n.id,destination:n.destination};let r=e.calls.find(e=>e.state===`held`);if(r!==void 0)return{kind:`held`,callId:r.id,destination:r.destination};let i=e.calls.find(e=>e.state===`dialing`||e.state===`ringing`||e.state===`connecting`);if(i!==void 0)return{kind:`dialing`,callId:i.id,destination:i.destination};let a=e.calls.find(e=>e.state===`ended`||e.state===`failed`);return a===void 0?e.connectionState===`connecting`||e.connectionState===`reconnecting`?{kind:`connecting`}:e.connectionState===`connected`?{kind:`ready`}:{kind:`setup`}:{kind:`ended`,callId:a.id}}var W=`:root,:host{--ccbar-color-surface:#fff;--ccbar-color-surface-muted:#f1f5f9;--ccbar-color-border:#d8e0ea;--ccbar-color-title:#0f172a;--ccbar-color-text:#334155;--ccbar-color-muted:#475569;--ccbar-color-primary:#2563eb;--ccbar-color-primary-hover:#1d4ed8;--ccbar-color-success:#15803d;--ccbar-color-warning:#a15c00;--ccbar-color-danger:#b91c1c;--ccbar-radius-sm:6px;--ccbar-radius:8px;--ccbar-radius-lg:12px;--ccbar-control-height:40px;--ccbar-control-height-touch:44px;--ccbar-space-1:4px;--ccbar-space-2:8px;--ccbar-space-3:12px;--ccbar-space-4:16px;--ccbar-space-6:24px;--ccbar-font-family:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--ccbar-panel-width:560px}:host{color:var(--ccbar-color-text);font-family:var(--ccbar-font-family);display:block}:host([floating]){z-index:2147483646;right:var(--ccbar-space-6);bottom:var(--ccbar-space-6);position:fixed}[part=panel]{background:var(--ccbar-color-surface);border:1px solid var(--ccbar-color-border);border-radius:var(--ccbar-radius-lg)}[part=status-rail]{align-items:center;gap:var(--ccbar-space-2);min-height:var(--ccbar-control-height);padding:var(--ccbar-space-2) var(--ccbar-space-3);border-bottom:1px solid var(--ccbar-color-border);color:var(--ccbar-color-muted);font-variant-numeric:tabular-nums;display:flex}[part=status-rail]:before{content:"";background:var(--ccbar-color-muted);border-radius:50%;flex:none;width:8px;height:8px}button{min-height:var(--ccbar-control-height);border:1px solid var(--ccbar-color-border);border-radius:var(--ccbar-radius-sm);background:var(--ccbar-color-surface);color:var(--ccbar-color-title);font:inherit}button[data-action=dial],button[data-action=signin],button[data-action=answer],button[data-variant=primary]{background:var(--ccbar-color-primary);border-color:var(--ccbar-color-primary);color:#fff}button[aria-pressed=true]{border-color:var(--ccbar-color-primary);color:var(--ccbar-color-primary);background:var(--ccbar-color-surface-muted)}button[data-action=hangup],button[data-action=reject]{background:var(--ccbar-color-danger);border-color:var(--ccbar-color-danger);color:#fff;margin-top:var(--ccbar-space-4)}button:disabled{opacity:.5}button:focus-visible,input:focus-visible{outline:2px solid var(--ccbar-color-primary);outline-offset:2px}input[type=tel]{width:100%;min-height:var(--ccbar-control-height);border:1px solid var(--ccbar-color-border);border-radius:var(--ccbar-radius-sm);font-variant-numeric:tabular-nums}.ccbar-call-list{gap:var(--ccbar-space-2);margin:var(--ccbar-space-3) 0 0;padding:0;list-style:none;display:grid}.ccbar-call-list button{text-align:left;width:100%}.ccbar-call-current{color:var(--ccbar-color-title);display:block}[data-layout=compact]{min-height:80px;max-height:96px}[data-layout=compact] .ccbar-toolbar{gap:var(--ccbar-space-2);padding:var(--ccbar-space-2) var(--ccbar-space-3);grid-template-columns:minmax(0,1fr) auto auto auto;align-items:center;display:grid}[data-layout=compact] .ccbar-more{right:var(--ccbar-space-3);gap:var(--ccbar-space-2);display:grid;position:absolute}[data-layout=panel]{width:min(var(--ccbar-panel-width), 100%);min-width:420px;max-width:560px;padding:var(--ccbar-space-3)}[data-layout=panel] .ccbar-bar-row{gap:var(--ccbar-space-2) var(--ccbar-space-3);grid-template-columns:48px minmax(0,1fr);align-items:center;min-height:36px;display:grid}[data-layout=panel] .ccbar-bar-row+.ccbar-bar-row{margin-top:var(--ccbar-space-2)}[data-layout=panel] .ccbar-bar-label{color:var(--ccbar-color-muted);font-size:12px}[data-layout=panel] .ccbar-bar-keys{align-items:center;gap:var(--ccbar-space-2);flex-wrap:wrap;display:flex}[data-layout=panel] .ccbar-bar-keys button{min-width:48px;min-height:32px;padding:0 10px;font-size:13px}[data-layout=panel] .ccbar-bar-keys input[type=tel]{max-width:320px}[data-layout=panel] .ccbar-bar-keys input[name=extension]{width:148px;max-width:148px}[data-layout=panel] .ccbar-ext-chip{background:var(--ccbar-color-surface-muted);height:28px;color:var(--ccbar-color-title);font-variant-numeric:tabular-nums;border-radius:999px;align-items:center;margin-left:auto;padding:0 10px;font-size:12px;display:inline-flex}[data-layout=panel] [data-action=hangup]{margin-top:0}[data-layout=panel] .ccbar-dialpad{gap:var(--ccbar-space-2);margin:var(--ccbar-space-3) 0 0;grid-template-columns:repeat(3,1fr);display:grid}[data-layout=panel] .ccbar-safe-actions{gap:var(--ccbar-space-2);flex-wrap:wrap;display:flex}[data-layout=mobile]{min-height:100vh;padding:var(--ccbar-space-4);padding-bottom:max(16px, env(safe-area-inset-bottom))}[data-layout=mobile] button{min-width:44px;min-height:44px}[data-layout=mobile] [data-action=enable-phone],[data-layout=mobile] [data-action=dial],[data-layout=mobile] [data-action=hangup]{min-height:52px}[data-layout=mobile] .ccbar-dialpad{gap:var(--ccbar-space-2);margin:var(--ccbar-space-3) 0;grid-template-columns:repeat(3,1fr);display:grid}:host([data-theme=dark]){--ccbar-color-surface:#0f172a;--ccbar-color-surface-muted:#1e293b;--ccbar-color-border:#334155;--ccbar-color-title:#f8fafc;--ccbar-color-text:#e2e8f0;--ccbar-color-muted:#94a3b8;--ccbar-color-primary:#3b82f6;--ccbar-color-primary-hover:#2563eb;--ccbar-color-success:#22c55e;--ccbar-color-warning:#f59e0b;--ccbar-color-danger:#ef4444}@media (prefers-reduced-motion:reduce){:host *,:host :before,:host :after{transition-duration:.01ms!important;animation-duration:.01ms!important;animation-iteration-count:1!important}}`,G=typeof HTMLElement==`function`?HTMLElement:class{},K=new WeakSet,q=[`connection.stateChanged`,`connection.reconnecting`,`connection.failed`,`call.incoming`,`call.stateChanged`,`call.activeChanged`,`call.ended`,`call.failed`,`media.permissionChanged`,`agent.statusChanged`,`error`],J=class extends G{static get observedAttributes(){return[`mode`,`floating`,`draggable`,`locale`,`theme`]}#e;#t=!1;#n=[];#r=`idle`;#i=`unknown`;#a;#o=new Set;#s=``;#c=``;#l=`offline`;#u=!1;#d=!1;#f=Promise.resolve();#p;#m=!1;#h=!1;#g;#_;#v;#y;#b;get messageResolver(){return this.#y}set messageResolver(e){this.#y=e,this.shadowRoot!==null&&this.render()}get client(){return this.#e}set client(e){this.#O(),this.#e=e,this.#D(),this.render()}get ownsClient(){return this.#t}set ownsClient(e){this.#t=e===!0}connectedCallback(){this.#V(),this.#B(),this.render()}disconnectedCallback(){let e=this.#e,t=this.#t;this.#O(),this.#G(),this.#b?.(),this.#b=void 0,t&&(this.#e=void 0,e?.dispose())}attributeChangedCallback(e){this.#V(),e===`theme`&&this.#B(),this.shadowRoot!==null&&this.render()}render(){let e=this.#k();e!==void 0&&(e.innerHTML=`<style>${W}</style>`,e.append(this.#S(this.#x())))}#x(){let e=this.#e?.getCalls?.().map(e=>({id:e.id,state:e.state,destination:e.destination,direction:this.#o.has(e.id)?`inbound`:`outbound`}))??[];return U({connectionState:this.#r,permission:this.#i,calls:e,error:this.#a})}#S(e){let t=this.#z(),n=this.#_??this.#g??X(e,t),r={...t,status:n},i=this.#C(e,r,n);return i.setAttribute(`data-view`,this.#E()&&!this.#m?`setup`:e.kind),i.hasAttribute(`data-layout`)||i.setAttribute(`data-layout`,this.#E()?`mobile`:`panel`),i}#C(e,t,n){if(this.#E()&&!this.#m)return L({enabling:this.#h,status:n,enablePhone:t.enablePhone});switch(e.kind){case`permission-error`:case`unrecoverable-error`:case`unsupported`:return P({view:e,messages:t});case`incoming`:return this.#E()?R({view:{kind:`ready`},messages:t,destination:this.#s,muted:this.#u,canDial:d(this.#s,this.#i,this.#r),showOutputDevice:this.#e?.media.supportsOutputSelection()===!0}):F({view:e,messages:t});case`setup`:case`connecting`:case`ended`:case`ready`:case`active`:case`held`:case`dialing`:return this.#E()?R({view:e.kind===`held`?{kind:`ready`}:e,messages:t,destination:this.#s,muted:this.#u,canDial:d(this.#s,this.#i,this.#r),showOutputDevice:this.#e?.media.supportsOutputSelection()===!0}):x({mode:this.#T()===`compact`?`compact`:`panel`,view:e,messages:t,destination:this.#s,muted:this.#u,canDial:d(this.#s,this.#i,this.#r),moreOpen:this.#d,floating:this.hasAttribute(`floating`),connected:this.#r===`connected`,agentStatus:this.#l,extension:this.#c,calls:this.#w()});default:return e}}#w(){let e=this.#e?.getActiveCall?.()?.id;return this.#e?.getCalls?.().map(t=>({id:t.id,destination:t.destination,state:t.state,direction:this.#o.has(t.id)?`inbound`:`outbound`,current:t.id===e}))??[]}#T(){let e=this.getAttribute(`mode`);return e===`compact`||e===`mobile`?e:`panel`}#E(){return this.#T()===`mobile`}#D(){let e=this.#e;e!==void 0&&(this.#n.push(e.on(`connection.stateChanged`,t=>{if(this.#r=t.state,t.state!==`connected`&&(this.#l=`offline`),t.state===`connected`){let t=e.getAgent?.()?.extension?.trim();t!==void 0&&t!==``&&(this.#c=t)}})),this.#n.push(e.on(`agent.statusChanged`,e=>{(e.status===`available`||e.status===`offline`||e.status===`break`)&&(this.#l=e.status)})),this.#n.push(e.on(`connection.failed`,e=>{this.#r=`failed`,this.#a={code:e.error.code}})),this.#n.push(e.on(`media.permissionChanged`,e=>{this.#i=e.permission})),this.#n.push(e.on(`error`,e=>{this.#a={code:e.error.code}})),this.#n.push(e.on(`call.incoming`,e=>{this.#o.add(e.callId)})),this.#n.push(e.on(`call.ended`,e=>{this.#o.delete(e.callId),this.#u=!1})),this.#n.push(e.on(`call.failed`,()=>{this.#_=this.#z().statusFailed})),q.forEach(t=>{this.#n.push(e.on(t,()=>this.render()))}),this.#E()&&typeof e.recover==`function`&&(this.#v=l(e,{onChecking:()=>{this.#g=this.#z().foregroundChecking,this.render()},onRecovered:()=>{this.#g=void 0,this.render()},onFailed:()=>{this.#g=this.#z().foregroundFailed,this.render()}})))}#O(){let e=this.#n;this.#n=[],e.forEach(e=>e()),this.#r=`idle`,this.#i=`unknown`,this.#l=`offline`,this.#a=void 0,this.#o.clear(),this.#u=!1,this.#d=!1,this.#m=!1,this.#h=!1,this.#g=void 0,this.#v?.(),this.#v=void 0}#k(){if(typeof this.attachShadow!=`function`)return;let e=this.shadowRoot??this.attachShadow({mode:`open`});return K.has(e)||(K.add(e),e.addEventListener(`click`,e=>this.#A(e)),e.addEventListener(`input`,e=>this.#P(e)),e.addEventListener(`pointerdown`,e=>this.#H(e))),e}#A(e){let t=Q(e,this),n=t?.closest(`[data-action="enable-phone"]`);n instanceof HTMLButtonElement&&(n.disabled=!0),this.#f=this.#f.then(()=>this.#F(t)).catch(e=>{this.#_=$(e),this.render()})}#j(){let e=this.shadowRoot?.querySelector(`input[name="destination"]`);return e instanceof HTMLInputElement?e.value:this.#s}#M(){let e=this.shadowRoot?.querySelector(`input[name="extension"]`);return e instanceof HTMLInputElement?e.value.trim():this.#c}#N(){let e=this.shadowRoot?.querySelector(`input[name="transfer-target"]`);return e instanceof HTMLInputElement?e.value:``}#P(e){let t=Q(e,this);if(t instanceof HTMLInputElement&&t.name!==`transfer-target`){if(t.name===`extension`){this.#c=t.value.trim();return}this.#s=t.value,this.#L()}}async#F(e){if(this.#_=void 0,e===void 0)return;let t=e.closest(`[data-call-id]`);if(t instanceof HTMLElement&&t.dataset.callId!==void 0){await this.#e?.setActiveCall(t.dataset.callId);return}let n=e.closest(`[data-digit]`);if(n instanceof HTMLElement&&n.dataset.digit!==void 0){await this.#I(n.dataset.digit);return}let r=e.closest(`[data-action]`);if(!(r instanceof HTMLElement)||r instanceof HTMLButtonElement&&r.disabled&&r.getAttribute(`data-action`)!==`enable-phone`)return;let i=this.#e?.getActiveCall?.()??this.#e?.getCalls?.().find(e=>e.state===`held`);switch(r.getAttribute(`data-action`)){case`signin`:if(this.#e===void 0)return;this.#c=this.#M(),await this.#e.media?.requestPermission?.(),await this.#e.initialize(),await this.#e.connect();return;case`signout`:if(this.#e===void 0)return;this.#l=`offline`,await this.#e.disconnect();return;case`dial`:case`dial-internal`:if(this.#s=this.#j(),this.#e===void 0)return;this.#i!==`granted`&&await this.#e.media?.requestPermission?.(),await f(this.#e,this.#s,r.getAttribute(`data-action`)===`dial-internal`?`extension`:void 0);return;case`mute`:if(i===void 0)return;this.#u=await p(i,this.#u),this.#R();return;case`hold`:i!==void 0&&await m(i);return;case`resume`:i!==void 0&&await i.resume();return;case`transfer`:i!==void 0&&await g(i,this.#N());return;case`hangup`:await i?.hangup();return;case`answer`:i!==void 0&&await this.#e?.answer(i.id);return;case`reject`:await i?.reject();return;case`enable-phone`:if(this.#e===void 0||this.#m)return;this.#h=!0;try{await c(this.#e),this.#m=!0}finally{this.#h=!1,this.render()}return;case`more`:this.#d=!this.#d,this.render();return;case`retry-permission`:await this.#e?.media.requestPermission();return;case`devices`:return;case`agent-available`:await this.#e?.setAgentStatus(`available`);return;case`agent-break`:await this.#e?.setAgentStatus(`break`);return;case`agent-busy`:return;default:return}}async#I(e){let t=this.#e?.getActiveCall?.()??this.#e?.getCalls?.().find(e=>e.state===`held`);if(t!==void 0&&(t.state===`active`||t.state===`held`)){await h(t,e);return}this.#s+=e;let n=this.shadowRoot?.querySelector(`input[name="destination"]`);n instanceof HTMLInputElement&&(n.value=this.#s),this.#L()}#L(){let e=!d(this.#s,this.#i,this.#r);for(let t of[`dial`,`dial-internal`]){let n=this.shadowRoot?.querySelector(`[data-action="${t}"]`);n instanceof HTMLButtonElement&&(n.disabled=e)}}#R(){let e=this.shadowRoot?.querySelector(`[data-action="mute"]`);e instanceof HTMLButtonElement&&(e.setAttribute(`aria-pressed`,this.#u?`true`:`false`),e.textContent=this.#u?this.#z().unmute:this.#z().mute)}#z(){return s(this.getAttribute(`locale`)??`zh-CN`,void 0,this.#y)}#B(){this.#b?.(),this.#b=void 0;let e=this.getAttribute(`theme`)??`light`;if(e===`dark`||e===`light`){this.setAttribute(`data-theme`,e);return}if(typeof window>`u`||typeof window.matchMedia!=`function`){this.setAttribute(`data-theme`,`light`);return}let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{this.setAttribute(`data-theme`,t.matches?`dark`:`light`)};n(),t.addEventListener(`change`,n),this.#b=()=>t.removeEventListener(`change`,n)}#V(){this.style.position=this.hasAttribute(`floating`)?`fixed`:``}#H(e){if(!(e instanceof PointerEvent)||!this.hasAttribute(`floating`)||!this.hasAttribute(`draggable`)||(e.target instanceof Element?e.target.closest(`[data-drag-handle]`):null)===null)return;e.preventDefault();let t=this.getBoundingClientRect();this.#p={pointerId:e.pointerId,offsetX:e.clientX-t.left,offsetY:e.clientY-t.top},window.addEventListener(`pointermove`,this.#U),window.addEventListener(`pointerup`,this.#W)}#U=e=>{if(this.#p===void 0||e.pointerId!==this.#p.pointerId)return;let t=window.visualViewport,n=t?.width??window.innerWidth,r=t?.height??window.innerHeight,i=Z(e.clientX-this.#p.offsetX,0,Math.max(0,n-this.offsetWidth)),a=Z(e.clientY-this.#p.offsetY,0,Math.max(0,r-this.offsetHeight));this.style.left=`${i}px`,this.style.top=`${a}px`,this.style.right=`auto`,this.style.bottom=`auto`};#W=e=>{this.#p!==void 0&&e.pointerId===this.#p.pointerId&&this.#G()};#G(){this.#p=void 0,window.removeEventListener(`pointermove`,this.#U),window.removeEventListener(`pointerup`,this.#W)}};function Y(e={}){if(typeof customElements>`u`)return;let t=e.tagName??`xcall-ccbar`;if(customElements.get(t)!==void 0)return;let n=t===`xcall-ccbar`?J:class extends J{};customElements.define(t,n)}function X(e,t){switch(e.kind){case`unsupported`:return t.statusUnsupported;case`permission-error`:return t.statusPermission;case`unrecoverable-error`:return t.statusError;case`setup`:return t.statusSetup;case`connecting`:return t.statusConnecting;case`incoming`:return t.statusIncoming;case`active`:return t.statusActive;case`held`:return t.statusHeld;case`dialing`:return t.statusDialing;case`ended`:return t.statusEnded;case`ready`:return t.statusReady;default:return e}}function Z(e,t,n){return Math.min(n,Math.max(t,e))}function Q(e,t){for(let n of e.composedPath())if(n instanceof Element&&n!==t)return n;return e.target instanceof Element&&e.target!==t?e.target:void 0}function $(e){return typeof e==`object`&&e&&`code`in e&&typeof e.code==`string`?e.code:`SDK_INTERNAL_ERROR`}var ee=`0.1.0`;exports.XCallCCBarElement=J,exports.defineCCBarElement=Y,exports.enUS=t,exports.resolveMessages=s,exports.uiVersion=ee,exports.zhCN=i;
|