@alfadocs/ui-kit 1.147.2 → 1.149.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/{appointment-timeline-D5qbZ7in.js → appointment-timeline-CuZW-CGT.js} +2 -2
- package/dist/_chunks/{bill-line-table-DnkFqMnM.js → bill-line-table-B8Cc2pTH.js} +2 -2
- package/dist/_chunks/button-group-CHQD8GJ0.js +449 -0
- package/dist/_chunks/{calendar-appointment-editor-dialog-CoIFwj9g.js → calendar-appointment-editor-dialog-Dx9_KIWA.js} +7 -7
- package/dist/_chunks/{calendar-waiting-list-panel-DuALuqLD.js → calendar-waiting-list-panel-BKBHfBpn.js} +3 -3
- package/dist/_chunks/{calendar.sheets-CueyPkTT.js → calendar.sheets-lgAqJB34.js} +3 -3
- package/dist/_chunks/{data-grid-CujX-2tF.js → data-grid-CkzbCZSo.js} +486 -476
- package/dist/_chunks/{default-tabs-CqP1uWdx.js → default-tabs-C45FVzsG.js} +3 -3
- package/dist/_chunks/{face-scheme-ByYeboH9.js → face-scheme-BC2whb1S.js} +2 -2
- package/dist/_chunks/{invoice-upload-list-srvWy5_d.js → invoice-upload-list-BReimsvV.js} +3 -3
- package/dist/_chunks/notes-panel-Cw06dLDm.js +1135 -0
- package/dist/_chunks/prescription-history-CQuJmd4H.js +1846 -0
- package/dist/_chunks/rich-text-editor-eGdYDPK2.js +4405 -0
- package/dist/_chunks/task-editor-4zFL10oM.js +1153 -0
- package/dist/_chunks/{tasks-panel-DsjfS_k5.js → tasks-panel-BDPQPOP6.js} +475 -461
- package/dist/_chunks/{toolbar-z_6tE7zG.js → toolbar-B9oh9XY9.js} +2 -2
- package/dist/_chunks/{use-appointment-details-read-CC74Y-r5.js → use-appointment-details-read-Bl1DHXQ2.js} +568 -554
- package/dist/agent-catalog.json +9 -7
- package/dist/agent-i18n/en.json +4 -4
- package/dist/appointment-editor-panel/index.js +1 -1
- package/dist/aws-transcribe/index.js +287 -181
- package/dist/browser-support.js +1 -1
- package/dist/calendar-action-buttons/index.js +1 -1
- package/dist/components/_shared/save-outcome.d.ts +23 -0
- package/dist/components/appointment-details-panel/index.js +1 -1
- package/dist/components/appointment-timeline/index.js +1 -1
- package/dist/components/bill-line-table/index.js +1 -1
- package/dist/components/bill-table/index.js +1 -1
- package/dist/components/button-group/button-group.d.ts +2 -1
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/data-grid/data-grid.variants.d.ts +7 -1
- package/dist/components/data-grid/index.js +2 -2
- package/dist/components/face-scheme/index.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/invoice-upload-list/index.js +1 -1
- package/dist/components/notes-panel/index.js +1 -1
- package/dist/components/rich-text-editor/help-me-write-overlay.d.ts +12 -1
- package/dist/components/rich-text-editor/index.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.d.ts +5 -3
- package/dist/components/task-editor/index.js +1 -1
- package/dist/components/task-editor/use-task-editor-form.d.ts +7 -1
- package/dist/components/tasks-panel/index.js +1 -1
- package/dist/core.css +1 -1
- package/dist/find-free-slots-panel/index.js +1 -1
- package/dist/host-compat.css +7 -1
- package/dist/i18n/locales/ar.d.ts +1 -0
- package/dist/i18n/locales/ar.js +2 -1
- package/dist/i18n/locales/de.d.ts +1 -0
- package/dist/i18n/locales/de.js +2 -1
- package/dist/i18n/locales/el.d.ts +1 -0
- package/dist/i18n/locales/el.js +2 -1
- package/dist/i18n/locales/en.d.ts +1 -0
- package/dist/i18n/locales/en.js +2 -1
- package/dist/i18n/locales/es.d.ts +1 -0
- package/dist/i18n/locales/es.js +2 -1
- package/dist/i18n/locales/fr.d.ts +1 -0
- package/dist/i18n/locales/fr.js +2 -1
- package/dist/i18n/locales/hi.d.ts +1 -0
- package/dist/i18n/locales/hi.js +2 -1
- package/dist/i18n/locales/it.d.ts +1 -0
- package/dist/i18n/locales/it.js +2 -1
- package/dist/i18n/locales/ja.d.ts +1 -0
- package/dist/i18n/locales/ja.js +2 -1
- package/dist/i18n/locales/nl.d.ts +1 -0
- package/dist/i18n/locales/nl.js +2 -1
- package/dist/i18n/locales/pl.d.ts +1 -0
- package/dist/i18n/locales/pl.js +2 -1
- package/dist/i18n/locales/pt.d.ts +1 -0
- package/dist/i18n/locales/pt.js +2 -1
- package/dist/i18n/locales/ro.d.ts +1 -0
- package/dist/i18n/locales/ro.js +2 -1
- package/dist/i18n/locales/ru.d.ts +1 -0
- package/dist/i18n/locales/ru.js +2 -1
- package/dist/i18n/locales/sq.d.ts +1 -0
- package/dist/i18n/locales/sq.js +2 -1
- package/dist/i18n/locales/sv.d.ts +1 -0
- package/dist/i18n/locales/sv.js +2 -1
- package/dist/i18n/locales/tr.d.ts +1 -0
- package/dist/i18n/locales/tr.js +2 -1
- package/dist/i18n/locales/zh.d.ts +1 -0
- package/dist/i18n/locales/zh.js +2 -1
- package/dist/index.js +1408 -1404
- package/dist/locales/ar.json +2 -1
- package/dist/locales/de.json +2 -1
- package/dist/locales/el.json +2 -1
- package/dist/locales/en.json +2 -1
- package/dist/locales/es.json +2 -1
- package/dist/locales/fr.json +2 -1
- package/dist/locales/hi.json +2 -1
- package/dist/locales/it.json +2 -1
- package/dist/locales/ja.json +2 -1
- package/dist/locales/nl.json +2 -1
- package/dist/locales/pl.json +2 -1
- package/dist/locales/pt.json +2 -1
- package/dist/locales/ro.json +2 -1
- package/dist/locales/ru.json +2 -1
- package/dist/locales/sq.json +2 -1
- package/dist/locales/sv.json +2 -1
- package/dist/locales/tr.json +2 -1
- package/dist/locales/zh.json +2 -1
- package/dist/online-bookings-panel/index.js +1 -1
- package/dist/patterns/calendar/index.js +2 -2
- package/dist/patterns/prescription/index.d.ts +1 -1
- package/dist/patterns/prescription/index.js +1 -1
- package/dist/patterns/prescription/prescription-history.d.ts +28 -0
- package/dist/save-outcome/index.js +20 -0
- package/dist/speech/aws-transcribe.d.ts +30 -6
- package/dist/tokens.css +1 -1
- package/dist/waiting-list-panel/index.js +2 -2
- package/package.json +5 -1
- package/dist/_chunks/button-group-N60L3HMa.js +0 -408
- package/dist/_chunks/notes-panel-BHMnLbEH.js +0 -1116
- package/dist/_chunks/prescription-history-CFs3JMIE.js +0 -1773
- package/dist/_chunks/rich-text-editor-BAcJq1PO.js +0 -4359
- package/dist/_chunks/task-editor-B9YpfwcW.js +0 -1095
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
const
|
|
1
|
+
var we = Object.defineProperty;
|
|
2
|
+
var ye = (t, e, n) => e in t ? we(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var re = (t, e, n) => ye(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
const me = (() => {
|
|
5
5
|
const t = new Uint32Array(256);
|
|
6
6
|
for (let e = 0; e < 256; e++) {
|
|
7
7
|
let n = e;
|
|
@@ -11,59 +11,59 @@ const Z = (() => {
|
|
|
11
11
|
}
|
|
12
12
|
return t;
|
|
13
13
|
})();
|
|
14
|
-
function
|
|
14
|
+
function j(t) {
|
|
15
15
|
let e = 4294967295;
|
|
16
16
|
for (let n = 0; n < t.length; n++)
|
|
17
|
-
e = (
|
|
17
|
+
e = (me[(e ^ t[n]) & 255] ^ e >>> 8) >>> 0;
|
|
18
18
|
return (e ^ 4294967295) >>> 0;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
function
|
|
22
|
-
const e = Object.entries(t).map(([
|
|
23
|
-
const
|
|
24
|
-
1 +
|
|
25
|
-
),
|
|
26
|
-
let
|
|
27
|
-
return
|
|
28
|
-
}), n = new Uint8Array(e.reduce((
|
|
20
|
+
const ue = 7, k = 12, oe = new TextEncoder(), se = new TextDecoder();
|
|
21
|
+
function ge(t) {
|
|
22
|
+
const e = Object.entries(t).map(([o, i]) => {
|
|
23
|
+
const s = oe.encode(o), a = oe.encode(i), l = new Uint8Array(
|
|
24
|
+
1 + s.length + 1 + 2 + a.length
|
|
25
|
+
), w = new DataView(l.buffer);
|
|
26
|
+
let d = 0;
|
|
27
|
+
return w.setUint8(d, s.length), d += 1, l.set(s, d), d += s.length, w.setUint8(d, ue), d += 1, w.setUint16(d, a.length), d += 2, l.set(a, d), l;
|
|
28
|
+
}), n = new Uint8Array(e.reduce((o, i) => o + i.length, 0));
|
|
29
29
|
let r = 0;
|
|
30
|
-
for (const
|
|
31
|
-
n.set(
|
|
30
|
+
for (const o of e)
|
|
31
|
+
n.set(o, r), r += o.length;
|
|
32
32
|
return n;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
const n =
|
|
36
|
-
return
|
|
34
|
+
function be(t, e) {
|
|
35
|
+
const n = ge(t), r = k + n.length + e.length + 4, o = new Uint8Array(r), i = new DataView(o.buffer);
|
|
36
|
+
return i.setUint32(0, r), i.setUint32(4, n.length), i.setUint32(8, j(o.subarray(0, 8))), o.set(n, k), o.set(e, k + n.length), i.setUint32(r - 4, j(o.subarray(0, r - 4))), o;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Ee(t) {
|
|
39
39
|
const e = new Uint8Array(t);
|
|
40
|
-
if (e.length <
|
|
40
|
+
if (e.length < k + 4)
|
|
41
41
|
throw new Error("event-stream: frame too short");
|
|
42
|
-
const n = new DataView(t), r = n.getUint32(0),
|
|
43
|
-
if (r !== e.length ||
|
|
42
|
+
const n = new DataView(t), r = n.getUint32(0), o = n.getUint32(4);
|
|
43
|
+
if (r !== e.length || k + o + 4 > r)
|
|
44
44
|
throw new Error("event-stream: lengths do not match the frame");
|
|
45
|
-
if (n.getUint32(8) !==
|
|
45
|
+
if (n.getUint32(8) !== j(e.subarray(0, 8)))
|
|
46
46
|
throw new Error("event-stream: prelude checksum mismatch");
|
|
47
|
-
if (n.getUint32(r - 4) !==
|
|
47
|
+
if (n.getUint32(r - 4) !== j(e.subarray(0, r - 4)))
|
|
48
48
|
throw new Error("event-stream: message checksum mismatch");
|
|
49
|
-
const
|
|
50
|
-
let
|
|
51
|
-
const
|
|
52
|
-
for (;
|
|
53
|
-
const l = n.getUint8(
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
e.subarray(
|
|
61
|
-
),
|
|
49
|
+
const i = {};
|
|
50
|
+
let s = k;
|
|
51
|
+
const a = k + o;
|
|
52
|
+
for (; s < a; ) {
|
|
53
|
+
const l = n.getUint8(s);
|
|
54
|
+
s += 1;
|
|
55
|
+
const w = se.decode(e.subarray(s, s + l));
|
|
56
|
+
if (s += l, n.getUint8(s) !== ue) break;
|
|
57
|
+
s += 1;
|
|
58
|
+
const d = n.getUint16(s);
|
|
59
|
+
s += 2, i[w] = se.decode(
|
|
60
|
+
e.subarray(s, s + d)
|
|
61
|
+
), s += d;
|
|
62
62
|
}
|
|
63
|
-
return { headers:
|
|
63
|
+
return { headers: i, payload: e.slice(a, r - 4) };
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
65
|
+
function ce(t) {
|
|
66
|
+
return be(
|
|
67
67
|
{
|
|
68
68
|
":content-type": "application/octet-stream",
|
|
69
69
|
":event-type": "AudioEvent",
|
|
@@ -72,16 +72,17 @@ function z(t) {
|
|
|
72
72
|
t
|
|
73
73
|
);
|
|
74
74
|
}
|
|
75
|
-
class
|
|
76
|
-
constructor(n, r) {
|
|
75
|
+
class h extends Error {
|
|
76
|
+
constructor(n, r, o) {
|
|
77
77
|
super(
|
|
78
|
-
r ? `AWS Transcribe: ${n} (${r})` : `AWS Transcribe: ${n}
|
|
78
|
+
r ? `AWS Transcribe: ${n} (${r})` : `AWS Transcribe: ${n}`,
|
|
79
|
+
o !== void 0 ? { cause: o } : void 0
|
|
79
80
|
);
|
|
80
|
-
|
|
81
|
+
re(this, "code");
|
|
81
82
|
this.name = "AwsTranscribeError", this.code = n;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
84
|
-
const
|
|
85
|
+
const Te = {
|
|
85
86
|
de: "de-DE",
|
|
86
87
|
en: "en-GB",
|
|
87
88
|
es: "es-ES",
|
|
@@ -89,52 +90,62 @@ const re = {
|
|
|
89
90
|
it: "it-IT",
|
|
90
91
|
pt: "pt-PT"
|
|
91
92
|
};
|
|
92
|
-
function
|
|
93
|
-
return
|
|
93
|
+
function Pe(t) {
|
|
94
|
+
return Te[t.toLowerCase().split(/[-_]/)[0] ?? ""] ?? null;
|
|
94
95
|
}
|
|
95
|
-
const
|
|
96
|
-
function
|
|
96
|
+
const ve = [8e3, 16e3, 44100, 48e3];
|
|
97
|
+
function Ae(t) {
|
|
97
98
|
const e = Math.round(t);
|
|
98
|
-
return
|
|
99
|
+
return ve.reduce(
|
|
99
100
|
(n, r) => Math.abs(r - e) < Math.abs(n - e) ? r : n
|
|
100
101
|
);
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function Ce(t, e, n) {
|
|
103
104
|
if (e === n) return t;
|
|
104
|
-
const r = e / n,
|
|
105
|
-
for (let
|
|
106
|
-
const
|
|
107
|
-
|
|
105
|
+
const r = e / n, o = new Float32Array(Math.max(1, Math.round(t.length / r)));
|
|
106
|
+
for (let i = 0; i < o.length; i++) {
|
|
107
|
+
const s = i * r, a = Math.floor(s), l = t[a] ?? 0, w = t[a + 1] ?? l;
|
|
108
|
+
o[i] = l + (w - l) * (s - a);
|
|
108
109
|
}
|
|
109
|
-
return
|
|
110
|
+
return o;
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
+
function Se(t) {
|
|
112
113
|
const e = new Uint8Array(t.length * 2), n = new DataView(e.buffer);
|
|
113
114
|
for (let r = 0; r < t.length; r++) {
|
|
114
|
-
const
|
|
115
|
-
n.setInt16(r * 2,
|
|
115
|
+
const o = Math.max(-1, Math.min(1, t[r] ?? 0));
|
|
116
|
+
n.setInt16(r * 2, o < 0 ? o * 32768 : o * 32767, !0);
|
|
116
117
|
}
|
|
117
118
|
return e;
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
var r,
|
|
120
|
+
function Ue(t) {
|
|
121
|
+
var r, o, i;
|
|
121
122
|
const e = t;
|
|
122
|
-
return (((r = e == null ? void 0 : e.Transcript) == null ? void 0 : r.Results) ?? ((
|
|
123
|
-
var l,
|
|
124
|
-
const
|
|
125
|
-
return typeof
|
|
123
|
+
return (((r = e == null ? void 0 : e.Transcript) == null ? void 0 : r.Results) ?? ((i = (o = e == null ? void 0 : e.TranscriptEvent) == null ? void 0 : o.Transcript) == null ? void 0 : i.Results) ?? []).flatMap((s) => {
|
|
124
|
+
var l, w;
|
|
125
|
+
const a = (w = (l = s.Alternatives) == null ? void 0 : l[0]) == null ? void 0 : w.Transcript;
|
|
126
|
+
return typeof a == "string" ? [{ text: a, partial: s.IsPartial === !0 }] : [];
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
|
-
function
|
|
129
|
+
function le() {
|
|
129
130
|
if (typeof window > "u") return;
|
|
130
131
|
const t = window;
|
|
131
132
|
return t.AudioContext ?? t.webkitAudioContext;
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
+
function ke() {
|
|
134
135
|
var t;
|
|
135
|
-
return typeof navigator < "u" && typeof ((t = navigator.mediaDevices) == null ? void 0 : t.getUserMedia) == "function" &&
|
|
136
|
+
return typeof navigator < "u" && typeof ((t = navigator.mediaDevices) == null ? void 0 : t.getUserMedia) == "function" && le() !== void 0 && typeof WebSocket < "u";
|
|
136
137
|
}
|
|
137
|
-
const
|
|
138
|
+
const Ne = 3e3, Me = 10, Oe = 250, ie = 4, xe = 6e4, Re = 1e4;
|
|
139
|
+
function ae(t) {
|
|
140
|
+
if (typeof t == "string") return { url: t, reconnectToken: null };
|
|
141
|
+
if (!t || typeof t != "object") return null;
|
|
142
|
+
const { url: e, reconnectToken: n } = t;
|
|
143
|
+
return typeof e != "string" || e === "" ? null : {
|
|
144
|
+
url: e,
|
|
145
|
+
reconnectToken: typeof n == "string" && n !== "" ? n : null
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const de = "alfadocs-aws-transcribe-capture", Le = `class Capture extends AudioWorkletProcessor {
|
|
138
149
|
constructor(options) {
|
|
139
150
|
super();
|
|
140
151
|
this.size = (options && options.processorOptions && options.processorOptions.chunk) || 2048;
|
|
@@ -154,91 +165,91 @@ const le = 3e3, de = 10, K = "alfadocs-aws-transcribe-capture", fe = `class Capt
|
|
|
154
165
|
return true;
|
|
155
166
|
}
|
|
156
167
|
}
|
|
157
|
-
registerProcessor(${JSON.stringify(
|
|
158
|
-
async function
|
|
168
|
+
registerProcessor(${JSON.stringify(de)}, Capture);`;
|
|
169
|
+
async function We(t, e, n) {
|
|
159
170
|
if (t.audioWorklet && typeof AudioWorkletNode < "u") {
|
|
160
|
-
const
|
|
161
|
-
new Blob([
|
|
171
|
+
const i = URL.createObjectURL(
|
|
172
|
+
new Blob([Le], { type: "text/javascript" })
|
|
162
173
|
);
|
|
163
174
|
try {
|
|
164
|
-
await t.audioWorklet.addModule(
|
|
165
|
-
const
|
|
175
|
+
await t.audioWorklet.addModule(i);
|
|
176
|
+
const s = new AudioWorkletNode(t, de, {
|
|
166
177
|
processorOptions: { chunk: e }
|
|
167
178
|
});
|
|
168
|
-
return
|
|
179
|
+
return s.port.onmessage = (a) => n(a.data), s;
|
|
169
180
|
} catch {
|
|
170
181
|
} finally {
|
|
171
|
-
URL.revokeObjectURL(
|
|
182
|
+
URL.revokeObjectURL(i);
|
|
172
183
|
}
|
|
173
184
|
}
|
|
174
185
|
let r = 1024;
|
|
175
186
|
for (; r < e && r < 16384; ) r *= 2;
|
|
176
|
-
const
|
|
177
|
-
return
|
|
187
|
+
const o = t.createScriptProcessor(r, 1, 1);
|
|
188
|
+
return o.onaudioprocess = (i) => n(i.inputBuffer.getChannelData(0).slice()), o;
|
|
178
189
|
}
|
|
179
|
-
function
|
|
190
|
+
function De(t) {
|
|
180
191
|
return t && typeof t == "object" && "name" in t ? String(t.name) : void 0;
|
|
181
192
|
}
|
|
182
|
-
function
|
|
193
|
+
function je(t) {
|
|
183
194
|
return async ({
|
|
184
195
|
signal: e,
|
|
185
196
|
onPartialTranscript: n,
|
|
186
197
|
onFinalTranscript: r,
|
|
187
|
-
onStatus:
|
|
198
|
+
onStatus: o
|
|
188
199
|
}) => {
|
|
189
|
-
const
|
|
190
|
-
if (!
|
|
191
|
-
throw new
|
|
200
|
+
const i = le();
|
|
201
|
+
if (!i || !ke())
|
|
202
|
+
throw new h("unsupported");
|
|
192
203
|
if (e.aborted) return;
|
|
193
|
-
let
|
|
204
|
+
let s = null, a;
|
|
194
205
|
try {
|
|
195
|
-
|
|
206
|
+
a = new i({ sampleRate: 48e3 });
|
|
196
207
|
} catch {
|
|
197
|
-
|
|
208
|
+
a = new i();
|
|
198
209
|
}
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
const
|
|
202
|
-
for (const
|
|
203
|
-
"port" in
|
|
210
|
+
const l = a.sampleRate || 48e3, w = Ae(l), d = Math.max(1024, Math.round(l * 0.05));
|
|
211
|
+
let T = null;
|
|
212
|
+
const $ = [], N = () => {
|
|
213
|
+
for (const c of $.splice(0)) {
|
|
214
|
+
"port" in c && (c.port.onmessage = null), "onaudioprocess" in c && (c.onaudioprocess = null);
|
|
204
215
|
try {
|
|
205
|
-
|
|
216
|
+
c.disconnect();
|
|
206
217
|
} catch {
|
|
207
218
|
}
|
|
208
219
|
}
|
|
209
|
-
|
|
220
|
+
T == null || T.getTracks().forEach((c) => c.stop()), T = null, a.state !== "closed" && a.close().catch(() => {
|
|
210
221
|
});
|
|
211
|
-
},
|
|
212
|
-
let
|
|
213
|
-
const
|
|
214
|
-
!
|
|
215
|
-
|
|
222
|
+
}, K = Math.round(l * Me);
|
|
223
|
+
let m = new Float32Array(0), v = null;
|
|
224
|
+
const J = (c) => {
|
|
225
|
+
!v || v.readyState !== WebSocket.OPEN || c.length === 0 || v.send(
|
|
226
|
+
ce(Se(Ce(c, l, w)))
|
|
216
227
|
);
|
|
217
|
-
},
|
|
218
|
-
if (!(!
|
|
219
|
-
for (;
|
|
220
|
-
|
|
221
|
-
|
|
228
|
+
}, G = (c) => {
|
|
229
|
+
if (!(!v || v.readyState !== WebSocket.OPEN)) {
|
|
230
|
+
for (; m.length >= d; )
|
|
231
|
+
J(m.subarray(0, d)), m = m.slice(d);
|
|
232
|
+
c && m.length && (J(m), m = new Float32Array(0));
|
|
222
233
|
}
|
|
223
|
-
},
|
|
224
|
-
const f = new Float32Array(
|
|
225
|
-
f.set(
|
|
226
|
-
},
|
|
227
|
-
const f = await
|
|
228
|
-
if (!
|
|
234
|
+
}, fe = (c) => {
|
|
235
|
+
const f = new Float32Array(m.length + c.length);
|
|
236
|
+
f.set(m), f.set(c, m.length), m = f.length > K ? f.slice(f.length - K) : f, G(!1);
|
|
237
|
+
}, he = async (c) => {
|
|
238
|
+
const f = await We(a, d, fe);
|
|
239
|
+
if (!T) {
|
|
229
240
|
"port" in f && (f.port.onmessage = null), "onaudioprocess" in f && (f.onaudioprocess = null);
|
|
230
241
|
return;
|
|
231
242
|
}
|
|
232
|
-
const
|
|
233
|
-
g.gain.value = 0,
|
|
243
|
+
const b = a.createMediaStreamSource(c), g = a.createGain();
|
|
244
|
+
g.gain.value = 0, $.push(b, f, g), b.connect(f), f.connect(g), g.connect(a.destination);
|
|
234
245
|
};
|
|
235
246
|
try {
|
|
236
|
-
|
|
247
|
+
a.state === "suspended" && await a.resume();
|
|
237
248
|
} catch {
|
|
238
|
-
throw
|
|
249
|
+
throw N(), new h("unsupported", "audio context");
|
|
239
250
|
}
|
|
240
|
-
|
|
241
|
-
const X = typeof t.languageCode == "function" ? t.languageCode() : t.languageCode, [
|
|
251
|
+
o == null || o("connecting");
|
|
252
|
+
const X = typeof t.languageCode == "function" ? t.languageCode() : t.languageCode, [S, x] = await Promise.allSettled([
|
|
242
253
|
navigator.mediaDevices.getUserMedia({
|
|
243
254
|
audio: {
|
|
244
255
|
channelCount: 1,
|
|
@@ -246,99 +257,194 @@ function ye(t) {
|
|
|
246
257
|
noiseSuppression: !0,
|
|
247
258
|
autoGainControl: !0
|
|
248
259
|
}
|
|
249
|
-
}).then(async (
|
|
250
|
-
if (
|
|
260
|
+
}).then(async (c) => {
|
|
261
|
+
if (T = c, e.aborted) return c;
|
|
251
262
|
try {
|
|
252
|
-
await
|
|
263
|
+
await he(c);
|
|
253
264
|
} catch {
|
|
254
|
-
throw new
|
|
265
|
+
throw new h("unsupported", "audio graph");
|
|
255
266
|
}
|
|
256
|
-
return !e.aborted &&
|
|
267
|
+
return !e.aborted && T && (o == null || o("listening")), c;
|
|
257
268
|
}),
|
|
258
269
|
t.getUrl(
|
|
259
|
-
{ languageCode: X, mediaEncoding: "pcm", sampleRate:
|
|
270
|
+
{ languageCode: X, mediaEncoding: "pcm", sampleRate: w },
|
|
260
271
|
e
|
|
261
272
|
)
|
|
262
273
|
]);
|
|
263
|
-
if (
|
|
264
|
-
if (
|
|
265
|
-
if (
|
|
266
|
-
if (
|
|
267
|
-
const
|
|
268
|
-
throw
|
|
274
|
+
if (S.status === "fulfilled" && (T = S.value), e.aborted || S.status === "rejected" || x.status === "rejected") {
|
|
275
|
+
if (N(), e.aborted) return;
|
|
276
|
+
if (S.status === "rejected") {
|
|
277
|
+
if (S.reason instanceof h) throw S.reason;
|
|
278
|
+
const c = De(S.reason);
|
|
279
|
+
throw c === "NotAllowedError" || c === "PermissionDeniedError" || c === "SecurityError" ? new h("permission") : new h("unsupported", c);
|
|
269
280
|
}
|
|
270
|
-
throw new
|
|
281
|
+
throw new h(
|
|
271
282
|
"url",
|
|
272
|
-
|
|
283
|
+
x.status === "rejected" && x.reason instanceof Error ? x.reason.message : void 0
|
|
273
284
|
);
|
|
274
285
|
}
|
|
275
|
-
const
|
|
276
|
-
|
|
286
|
+
const I = ae(x.value);
|
|
287
|
+
if (I === null)
|
|
288
|
+
throw N(), new h("url", "no url");
|
|
289
|
+
s = I.reconnectToken;
|
|
290
|
+
let R;
|
|
277
291
|
try {
|
|
278
|
-
|
|
292
|
+
R = new WebSocket(I.url), R.binaryType = "arraybuffer";
|
|
279
293
|
} catch {
|
|
280
|
-
throw
|
|
294
|
+
throw N(), new h("connection");
|
|
281
295
|
}
|
|
282
|
-
return
|
|
283
|
-
let
|
|
284
|
-
const
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
296
|
+
return v = R, new Promise((c, f) => {
|
|
297
|
+
let b = !1, g = "", B = null, Y, H = !1, y = R, z = 0;
|
|
298
|
+
const L = [];
|
|
299
|
+
let D = !1, F, V, M = null;
|
|
300
|
+
const q = () => {
|
|
301
|
+
G(!0), y == null || y.send(ce(new Uint8Array(0))), Y = setTimeout(() => A(), Ne);
|
|
302
|
+
}, Q = (u) => {
|
|
303
|
+
if (u && (u.onopen = u.onmessage = u.onerror = u.onclose = null, u.readyState === WebSocket.OPEN || u.readyState === WebSocket.CONNECTING))
|
|
304
|
+
try {
|
|
305
|
+
u.close();
|
|
306
|
+
} catch {
|
|
307
|
+
}
|
|
308
|
+
}, A = (u) => {
|
|
309
|
+
if (b) return;
|
|
310
|
+
b = !0, clearTimeout(Y), clearTimeout(F), clearTimeout(V), M == null || M.abort(), D = !1, e.removeEventListener("abort", Z), N(), Q(y), y = v = null;
|
|
311
|
+
const E = g.trim();
|
|
312
|
+
g = "", n(""), E && r(E), u && !e.aborted ? f(u) : c();
|
|
291
313
|
};
|
|
292
|
-
function
|
|
293
|
-
|
|
314
|
+
function Z() {
|
|
315
|
+
b || (N(), D || !y ? A() : y.readyState === WebSocket.OPEN ? q() : y.readyState === WebSocket.CONNECTING && m.length > 0 ? H = !0 : A());
|
|
294
316
|
}
|
|
295
|
-
e.addEventListener("abort",
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
y = ne(S.data);
|
|
303
|
-
} catch {
|
|
317
|
+
e.addEventListener("abort", Z, { once: !0 });
|
|
318
|
+
const ee = () => {
|
|
319
|
+
const u = Date.now();
|
|
320
|
+
for (; L.length > 0 && u - (L[0] ?? 0) >= xe; )
|
|
321
|
+
L.shift();
|
|
322
|
+
if (z >= ie || L.length >= ie) {
|
|
323
|
+
A(new h("connection", "reconnect limit"));
|
|
304
324
|
return;
|
|
305
325
|
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
326
|
+
z += 1, L.push(u), D = !0, F = setTimeout(() => void pe(), Oe);
|
|
327
|
+
}, pe = async () => {
|
|
328
|
+
if (F = void 0, b || e.aborted) return;
|
|
329
|
+
let u;
|
|
330
|
+
const E = new AbortController();
|
|
331
|
+
M = E;
|
|
332
|
+
const W = () => E.abort();
|
|
333
|
+
e.addEventListener("abort", W, { once: !0 });
|
|
334
|
+
try {
|
|
335
|
+
const p = new Promise((O, _) => {
|
|
336
|
+
V = setTimeout(() => {
|
|
337
|
+
_(new h("url", "timeout")), E.abort();
|
|
338
|
+
}, Re);
|
|
339
|
+
});
|
|
340
|
+
u = await Promise.race([
|
|
341
|
+
t.getUrl(
|
|
342
|
+
{
|
|
343
|
+
languageCode: X,
|
|
344
|
+
mediaEncoding: "pcm",
|
|
345
|
+
sampleRate: w,
|
|
346
|
+
...s !== null ? { reconnectToken: s } : {}
|
|
347
|
+
},
|
|
348
|
+
E.signal
|
|
349
|
+
),
|
|
350
|
+
p
|
|
351
|
+
]);
|
|
352
|
+
} catch (p) {
|
|
353
|
+
if (b || e.aborted) return;
|
|
354
|
+
A(
|
|
355
|
+
p instanceof h ? p : new h(
|
|
356
|
+
"url",
|
|
357
|
+
p instanceof Error ? p.message : void 0,
|
|
358
|
+
p
|
|
359
|
+
)
|
|
311
360
|
);
|
|
312
361
|
return;
|
|
362
|
+
} finally {
|
|
363
|
+
clearTimeout(V), e.removeEventListener("abort", W), M === E && (M = null);
|
|
313
364
|
}
|
|
314
|
-
if (
|
|
365
|
+
if (b || e.aborted) return;
|
|
366
|
+
const U = ae(u);
|
|
367
|
+
if (U === null) {
|
|
368
|
+
A(new h("url", "no url"));
|
|
315
369
|
return;
|
|
316
|
-
|
|
370
|
+
}
|
|
371
|
+
U.reconnectToken && (s = U.reconnectToken);
|
|
372
|
+
let C;
|
|
317
373
|
try {
|
|
318
|
-
|
|
374
|
+
C = new WebSocket(U.url), C.binaryType = "arraybuffer";
|
|
319
375
|
} catch {
|
|
376
|
+
ee();
|
|
320
377
|
return;
|
|
321
378
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
379
|
+
D = !1, y = v = C, te(C, !0);
|
|
380
|
+
};
|
|
381
|
+
function te(u, E) {
|
|
382
|
+
let W = !1;
|
|
383
|
+
u.onopen = () => {
|
|
384
|
+
if (u === y) {
|
|
385
|
+
if (W = !0, H) return q();
|
|
386
|
+
if (!T) return A();
|
|
387
|
+
G(!1);
|
|
388
|
+
}
|
|
389
|
+
}, u.onmessage = (C) => {
|
|
390
|
+
if (u !== y) return;
|
|
391
|
+
let p;
|
|
392
|
+
try {
|
|
393
|
+
p = Ee(C.data);
|
|
394
|
+
} catch {
|
|
395
|
+
return;
|
|
329
396
|
}
|
|
330
|
-
|
|
397
|
+
const O = p.headers[":message-type"];
|
|
398
|
+
if (O === "exception") {
|
|
399
|
+
B = new h(
|
|
400
|
+
"service",
|
|
401
|
+
p.headers[":exception-type"] ?? p.headers[":error-code"]
|
|
402
|
+
);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (O !== "event" || p.headers[":event-type"] !== "TranscriptEvent")
|
|
406
|
+
return;
|
|
407
|
+
let _;
|
|
408
|
+
try {
|
|
409
|
+
_ = JSON.parse(new TextDecoder().decode(p.payload));
|
|
410
|
+
} catch {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
for (const P of Ue(_))
|
|
414
|
+
if (P.partial)
|
|
415
|
+
g = P.text, n(P.text);
|
|
416
|
+
else {
|
|
417
|
+
g = "", z = 0, n("");
|
|
418
|
+
const ne = P.text.trim();
|
|
419
|
+
ne && r(ne);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
const U = (C) => {
|
|
423
|
+
if (u !== y) return;
|
|
424
|
+
if (!(!b && !e.aborted && B === null && s !== null && (W || E))) {
|
|
425
|
+
A(
|
|
426
|
+
B ?? (C ? new h("connection") : void 0)
|
|
427
|
+
);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
Q(u), y = v = null;
|
|
431
|
+
const O = g.trim();
|
|
432
|
+
g = "", n(""), O && r(O), ee();
|
|
433
|
+
};
|
|
434
|
+
u.onerror = () => U(!0), u.onclose = () => U(!1);
|
|
435
|
+
}
|
|
436
|
+
te(R, !1);
|
|
331
437
|
});
|
|
332
438
|
};
|
|
333
439
|
}
|
|
334
440
|
export {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
441
|
+
h as AwsTranscribeError,
|
|
442
|
+
Pe as awsLanguageCode,
|
|
443
|
+
je as createAwsTranscribeDictation,
|
|
444
|
+
ke as isAwsTranscribeSupported,
|
|
445
|
+
Ce as resample,
|
|
446
|
+
Se as toPcm16,
|
|
447
|
+
Ue as transcriptResults,
|
|
448
|
+
Ae as transmitSampleRate
|
|
343
449
|
};
|
|
344
450
|
//# sourceMappingURL=index.js.map
|