@deepagents/react-input 7.8.1 → 7.9.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/COMPOSER_FEATURE_MATRIX.md +3 -2
- package/dist/browser.d.ts +4 -0
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1178 -861
- package/dist/browser.js.map +1 -1
- package/dist/lib/Composer.d.ts +5 -0
- package/dist/lib/Composer.d.ts.map +1 -1
- package/dist/lib/dictation/ComposerDictationContext.d.ts +34 -0
- package/dist/lib/dictation/ComposerDictationContext.d.ts.map +1 -0
- package/dist/lib/dictation/ComposerDictationParts.d.ts +14 -0
- package/dist/lib/dictation/ComposerDictationParts.d.ts.map +1 -0
- package/dist/lib/dictation/DictationError.d.ts +6 -0
- package/dist/lib/dictation/DictationError.d.ts.map +1 -0
- package/dist/lib/dictation/MicrophonePermission.d.ts +7 -0
- package/dist/lib/dictation/MicrophonePermission.d.ts.map +1 -0
- package/dist/lib/dictation/Recording.d.ts +23 -0
- package/dist/lib/dictation/Recording.d.ts.map +1 -0
- package/dist/lib/dictation/useDictationController.d.ts +12 -0
- package/dist/lib/dictation/useDictationController.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -4,24 +4,24 @@ import { Button as a } from "@base-ui/react/button";
|
|
|
4
4
|
import { EditorContent as o, useEditor as s } from "@tiptap/react";
|
|
5
5
|
import { useClock as c } from "@zukhruf/ui";
|
|
6
6
|
import { cn as l } from "cn";
|
|
7
|
-
import { Children as u, Fragment as d, createContext as f, isValidElement as p,
|
|
8
|
-
import { Package as
|
|
9
|
-
import { Fragment as
|
|
10
|
-
import { escapeRegExp as
|
|
11
|
-
import { Extension as
|
|
12
|
-
import
|
|
13
|
-
import { Slice as
|
|
14
|
-
import { Plugin as
|
|
15
|
-
import
|
|
7
|
+
import { Children as u, Fragment as d, createContext as f, isValidElement as p, startTransition as m, use as h, useActionState as g, useEffect as _, useMemo as v, useRef as y, useState as b, useSyncExternalStore as x } from "react";
|
|
8
|
+
import { Package as S, X as ee } from "lucide-react";
|
|
9
|
+
import { Fragment as te, jsx as C, jsxs as w } from "react/jsx-runtime";
|
|
10
|
+
import { escapeRegExp as T } from "lodash-es";
|
|
11
|
+
import { Extension as E, Mark as D, Node as O, mergeAttributes as k } from "@tiptap/core";
|
|
12
|
+
import ne from "@tiptap/extension-link";
|
|
13
|
+
import { Slice as re } from "@tiptap/pm/model";
|
|
14
|
+
import { Plugin as A, TextSelection as j } from "@tiptap/pm/state";
|
|
15
|
+
import M from "@tiptap/starter-kit";
|
|
16
16
|
//#region src/lib/ComposerContext.ts
|
|
17
|
-
var
|
|
18
|
-
function
|
|
19
|
-
let t =
|
|
17
|
+
var ie = f(null);
|
|
18
|
+
function N(e) {
|
|
19
|
+
let t = h(ie);
|
|
20
20
|
if (!t) throw Error(`${e} must be used inside Composer.Root.`);
|
|
21
21
|
return t;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
let t = i(9), n =
|
|
23
|
+
function P(e) {
|
|
24
|
+
let t = i(9), n = N(e === void 0 ? "useComposer" : e), r;
|
|
25
25
|
t[0] !== n.activePopup || t[1] !== n.disabled || t[2] !== n.meta || t[3] !== n.suggestions ? (r = {
|
|
26
26
|
...n.meta,
|
|
27
27
|
disabled: n.disabled,
|
|
@@ -37,10 +37,10 @@ function oe(e) {
|
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
39
|
//#region src/lib/ComposerAttachments.tsx
|
|
40
|
-
function
|
|
40
|
+
function F(e) {
|
|
41
41
|
let t = i(23), n, r;
|
|
42
42
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
43
|
-
let { state: a, attachedImages: o } =
|
|
43
|
+
let { state: a, attachedImages: o } = N("Composer.Attachments"), s = a.imageAttachments, c, u, d, f, p, m;
|
|
44
44
|
if (t[3] !== o || t[4] !== n || t[5] !== r || t[6] !== a.imageAttachments) {
|
|
45
45
|
m = Symbol.for("react.early_return_sentinel");
|
|
46
46
|
bb0: {
|
|
@@ -51,13 +51,13 @@ function se(e) {
|
|
|
51
51
|
m = null;
|
|
52
52
|
break bb0;
|
|
53
53
|
}
|
|
54
|
-
c = "list", u = "Attached files", t[15] === n ? d = t[16] : (d = l("flex flex-wrap gap-2", n), t[15] = n, t[16] = d), f = r, p = i.map(
|
|
54
|
+
c = "list", u = "Attached files", t[15] === n ? d = t[16] : (d = l("flex flex-wrap gap-2", n), t[15] = n, t[16] = d), f = r, p = i.map(I);
|
|
55
55
|
}
|
|
56
56
|
t[3] = o, t[4] = n, t[5] = r, t[6] = a.imageAttachments, t[7] = c, t[8] = u, t[9] = d, t[10] = f, t[11] = p, t[12] = m;
|
|
57
57
|
} else c = t[7], u = t[8], d = t[9], f = t[10], p = t[11], m = t[12];
|
|
58
58
|
if (m !== Symbol.for("react.early_return_sentinel")) return m;
|
|
59
59
|
let h;
|
|
60
|
-
return t[17] !== c || t[18] !== u || t[19] !== d || t[20] !== f || t[21] !== p ? (h = /* @__PURE__ */
|
|
60
|
+
return t[17] !== c || t[18] !== u || t[19] !== d || t[20] !== f || t[21] !== p ? (h = /* @__PURE__ */ C("div", {
|
|
61
61
|
role: c,
|
|
62
62
|
"aria-label": u,
|
|
63
63
|
className: d,
|
|
@@ -65,35 +65,35 @@ function se(e) {
|
|
|
65
65
|
children: p
|
|
66
66
|
}), t[17] = c, t[18] = u, t[19] = d, t[20] = f, t[21] = p, t[22] = h) : h = t[22], h;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return /* @__PURE__ */
|
|
68
|
+
function I(e) {
|
|
69
|
+
return /* @__PURE__ */ C(L, { attachment: e }, e.id);
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
let t = i(18), { attachment: n } = e, { id: r, placeholder: o, media: s } = n, { attachedImages: c, disabled: l, actions: u } =
|
|
71
|
+
function L(e) {
|
|
72
|
+
let t = i(18), { attachment: n } = e, { id: r, placeholder: o, media: s } = n, { attachedImages: c, disabled: l, actions: u } = N("Composer.Attachments"), d;
|
|
73
73
|
t[0] !== c || t[1] !== r ? (d = c.get(r), t[0] = c, t[1] = r, t[2] = d) : d = t[2];
|
|
74
74
|
let f = d;
|
|
75
75
|
if (!f) return null;
|
|
76
76
|
let p;
|
|
77
|
-
t[3] !== f || t[4] !== s || t[5] !== o ? (p = s === "video" ? /* @__PURE__ */
|
|
77
|
+
t[3] !== f || t[4] !== s || t[5] !== o ? (p = s === "video" ? /* @__PURE__ */ C(B, {
|
|
78
78
|
placeholder: o,
|
|
79
79
|
file: f
|
|
80
|
-
}) : s === "audio" ? /* @__PURE__ */
|
|
80
|
+
}) : s === "audio" ? /* @__PURE__ */ C(H, {
|
|
81
81
|
placeholder: o,
|
|
82
82
|
file: f,
|
|
83
83
|
glyph: "♪"
|
|
84
|
-
}) : /* @__PURE__ */
|
|
84
|
+
}) : /* @__PURE__ */ C(z, {
|
|
85
85
|
placeholder: o,
|
|
86
86
|
file: f
|
|
87
87
|
}), t[3] = f, t[4] = s, t[5] = o, t[6] = p) : p = t[6];
|
|
88
88
|
let m = `Remove ${o}`, h;
|
|
89
89
|
t[7] !== u || t[8] !== r ? (h = () => u.removeImageAttachment(r), t[7] = u, t[8] = r, t[9] = h) : h = t[9];
|
|
90
90
|
let g;
|
|
91
|
-
t[10] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */
|
|
91
|
+
t[10] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ C(ee, {
|
|
92
92
|
"aria-hidden": !0,
|
|
93
93
|
className: "size-3"
|
|
94
94
|
}), t[10] = g) : g = t[10];
|
|
95
95
|
let _;
|
|
96
|
-
t[11] !== l || t[12] !== m || t[13] !== h ? (_ = /* @__PURE__ */
|
|
96
|
+
t[11] !== l || t[12] !== m || t[13] !== h ? (_ = /* @__PURE__ */ C(a, {
|
|
97
97
|
type: "button",
|
|
98
98
|
"aria-label": m,
|
|
99
99
|
disabled: l,
|
|
@@ -102,26 +102,26 @@ function A(e) {
|
|
|
102
102
|
children: g
|
|
103
103
|
}), t[11] = l, t[12] = m, t[13] = h, t[14] = _) : _ = t[14];
|
|
104
104
|
let v;
|
|
105
|
-
return t[15] !== p || t[16] !== _ ? (v = /* @__PURE__ */
|
|
105
|
+
return t[15] !== p || t[16] !== _ ? (v = /* @__PURE__ */ w("div", {
|
|
106
106
|
role: "listitem",
|
|
107
107
|
className: "relative",
|
|
108
108
|
children: [p, _]
|
|
109
109
|
}), t[15] = p, t[16] = _, t[17] = v) : v = t[17], v;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
112
|
-
let t = i(3), [n, r] =
|
|
111
|
+
function R(e) {
|
|
112
|
+
let t = i(3), [n, r] = b(null), a, o;
|
|
113
113
|
return t[0] === e ? (a = t[1], o = t[2]) : (a = () => {
|
|
114
114
|
let t = URL.createObjectURL(e);
|
|
115
115
|
return r(t), () => URL.revokeObjectURL(t);
|
|
116
|
-
}, o = [e], t[0] = e, t[1] = a, t[2] = o),
|
|
116
|
+
}, o = [e], t[0] = e, t[1] = a, t[2] = o), _(a, o), n;
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
let t = i(5), { placeholder: n, file: r } = e, a =
|
|
120
|
-
return t[0] !== o || t[1] !== r || t[2] !== a || t[3] !== n ? (c = a === null ? null : a === o ? /* @__PURE__ */
|
|
118
|
+
function z(e) {
|
|
119
|
+
let t = i(5), { placeholder: n, file: r } = e, a = R(r), [o, s] = b(null), c;
|
|
120
|
+
return t[0] !== o || t[1] !== r || t[2] !== a || t[3] !== n ? (c = a === null ? null : a === o ? /* @__PURE__ */ C(H, {
|
|
121
121
|
placeholder: n,
|
|
122
122
|
file: r,
|
|
123
123
|
glyph: "🖼"
|
|
124
|
-
}) : /* @__PURE__ */
|
|
124
|
+
}) : /* @__PURE__ */ C("img", {
|
|
125
125
|
src: a,
|
|
126
126
|
alt: n,
|
|
127
127
|
title: r.name,
|
|
@@ -129,11 +129,11 @@ function M(e) {
|
|
|
129
129
|
onError: () => s(a)
|
|
130
130
|
}), t[0] = o, t[1] = r, t[2] = a, t[3] = n, t[4] = c) : c = t[4], c;
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
let t = i(11), { placeholder: n, file: r } = e, a =
|
|
132
|
+
function B(e) {
|
|
133
|
+
let t = i(11), { placeholder: n, file: r } = e, a = R(r), [o, s] = b(null), c = a ?? void 0, l;
|
|
134
134
|
t[0] === Symbol.for("react.memo_cache_sentinel") ? (l = (e) => s(e.currentTarget.duration), t[0] = l) : l = t[0];
|
|
135
135
|
let u;
|
|
136
|
-
t[1] === c ? u = t[2] : (u = /* @__PURE__ */
|
|
136
|
+
t[1] === c ? u = t[2] : (u = /* @__PURE__ */ C("video", {
|
|
137
137
|
src: c,
|
|
138
138
|
muted: !0,
|
|
139
139
|
playsInline: !0,
|
|
@@ -142,18 +142,18 @@ function N(e) {
|
|
|
142
142
|
onLoadedMetadata: l
|
|
143
143
|
}), t[1] = c, t[2] = u);
|
|
144
144
|
let d;
|
|
145
|
-
t[3] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */
|
|
145
|
+
t[3] === Symbol.for("react.memo_cache_sentinel") ? (d = /* @__PURE__ */ C("span", {
|
|
146
146
|
"aria-hidden": !0,
|
|
147
147
|
className: "pointer-events-none absolute inset-0 flex items-center justify-center text-lg text-white drop-shadow",
|
|
148
148
|
children: "▶"
|
|
149
149
|
}), t[3] = d) : d = t[3];
|
|
150
150
|
let f;
|
|
151
|
-
t[4] === o ? f = t[5] : (f = o !== null && Number.isFinite(o) ? /* @__PURE__ */
|
|
151
|
+
t[4] === o ? f = t[5] : (f = o !== null && Number.isFinite(o) ? /* @__PURE__ */ C("span", {
|
|
152
152
|
className: "absolute right-0.5 bottom-0.5 rounded bg-black/70 px-1 text-[10px] leading-4 text-white",
|
|
153
|
-
children:
|
|
153
|
+
children: V(o)
|
|
154
154
|
}) : null, t[4] = o, t[5] = f);
|
|
155
155
|
let p;
|
|
156
|
-
return t[6] !== r.name || t[7] !== n || t[8] !== u || t[9] !== f ? (p = /* @__PURE__ */
|
|
156
|
+
return t[6] !== r.name || t[7] !== n || t[8] !== u || t[9] !== f ? (p = /* @__PURE__ */ w("div", {
|
|
157
157
|
role: "img",
|
|
158
158
|
"aria-label": n,
|
|
159
159
|
title: r.name,
|
|
@@ -165,28 +165,28 @@ function N(e) {
|
|
|
165
165
|
]
|
|
166
166
|
}), t[6] = r.name, t[7] = n, t[8] = u, t[9] = f, t[10] = p) : p = t[10], p;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function V(e) {
|
|
169
169
|
let t = Math.round(e);
|
|
170
170
|
return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function H(e) {
|
|
173
173
|
let t = i(12), { placeholder: n, file: r, glyph: a } = e, o;
|
|
174
|
-
t[0] === a ? o = t[1] : (o = /* @__PURE__ */
|
|
174
|
+
t[0] === a ? o = t[1] : (o = /* @__PURE__ */ w("span", {
|
|
175
175
|
"aria-hidden": !0,
|
|
176
176
|
children: [a, " "]
|
|
177
177
|
}), t[0] = a, t[1] = o);
|
|
178
178
|
let s = r.name || n, c;
|
|
179
|
-
t[2] !== o || t[3] !== s ? (c = /* @__PURE__ */
|
|
179
|
+
t[2] !== o || t[3] !== s ? (c = /* @__PURE__ */ w("span", {
|
|
180
180
|
className: "text-foreground truncate",
|
|
181
181
|
children: [o, s]
|
|
182
182
|
}), t[2] = o, t[3] = s, t[4] = c) : c = t[4];
|
|
183
183
|
let l = r.type || "file", u;
|
|
184
|
-
t[5] === l ? u = t[6] : (u = /* @__PURE__ */
|
|
184
|
+
t[5] === l ? u = t[6] : (u = /* @__PURE__ */ C("span", {
|
|
185
185
|
className: "truncate",
|
|
186
186
|
children: l
|
|
187
187
|
}), t[5] = l, t[6] = u);
|
|
188
188
|
let d;
|
|
189
|
-
return t[7] !== r.name || t[8] !== n || t[9] !== c || t[10] !== u ? (d = /* @__PURE__ */
|
|
189
|
+
return t[7] !== r.name || t[8] !== n || t[9] !== c || t[10] !== u ? (d = /* @__PURE__ */ w("div", {
|
|
190
190
|
role: "img",
|
|
191
191
|
"aria-label": n,
|
|
192
192
|
title: r.name,
|
|
@@ -196,15 +196,15 @@ function F(e) {
|
|
|
196
196
|
}
|
|
197
197
|
//#endregion
|
|
198
198
|
//#region src/lib/ComposerVisibility.ts
|
|
199
|
-
function
|
|
199
|
+
function U(e, t) {
|
|
200
200
|
return e === "hidden" ? !1 : e === "before-interaction" ? !t : e !== "after-interaction" || t;
|
|
201
201
|
}
|
|
202
202
|
//#endregion
|
|
203
203
|
//#region src/lib/ComposerSlashCommands.ts
|
|
204
|
-
function
|
|
205
|
-
let r =
|
|
204
|
+
function W(e, t, n) {
|
|
205
|
+
let r = K(e), i = t.filter((e) => ae(e) && U(e.visibility, n));
|
|
206
206
|
return r ? i.map((e, t) => {
|
|
207
|
-
let n =
|
|
207
|
+
let n = se(r, e);
|
|
208
208
|
return n === null ? null : {
|
|
209
209
|
command: e,
|
|
210
210
|
rank: n,
|
|
@@ -212,52 +212,52 @@ function L(e, t, n) {
|
|
|
212
212
|
};
|
|
213
213
|
}).filter((e) => !!e).sort((e, t) => e.rank - t.rank || e.index - t.index).map((e) => e.command).slice(0, 10) : i.slice(0, 10);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function G(e, t) {
|
|
216
216
|
let n = e.toLowerCase();
|
|
217
|
-
return t.find((e) =>
|
|
217
|
+
return t.find((e) => ae(e) && (e.value.toLowerCase() === n || oe(e).some((e) => e === n)));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function K(e) {
|
|
220
220
|
return e.slice(1).toLowerCase();
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function ae(e) {
|
|
223
223
|
return e.availability !== "disabled";
|
|
224
224
|
}
|
|
225
|
-
function
|
|
225
|
+
function oe(e) {
|
|
226
226
|
return (e.aliases ?? []).map((e) => e.toLowerCase());
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
let n = t.value.toLowerCase(), r =
|
|
228
|
+
function se(e, t) {
|
|
229
|
+
let n = t.value.toLowerCase(), r = oe(t), i = [t.label.toLowerCase(), ...(t.searchTerms ?? []).map((e) => e.toLowerCase())];
|
|
230
230
|
return n === e ? 0 : r.some((t) => t === e) ? 1 : n.startsWith(e) ? 2 : r.some((t) => t.startsWith(e)) ? 3 : i.some((t) => t.startsWith(e)) ? 4 : null;
|
|
231
231
|
}
|
|
232
232
|
//#endregion
|
|
233
233
|
//#region src/lib/ComposerTriggers.ts
|
|
234
|
-
function
|
|
235
|
-
return e.map(
|
|
234
|
+
function q(e) {
|
|
235
|
+
return e.map(T).join("|");
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
return `(?:${
|
|
237
|
+
function ce(e) {
|
|
238
|
+
return `(?:${q(e)})[A-Za-z0-9_:-]+`;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
241
|
-
return `(?:${
|
|
240
|
+
function J(e) {
|
|
241
|
+
return `(?:${q(e)})[^\\s]+`;
|
|
242
242
|
}
|
|
243
|
-
function
|
|
243
|
+
function le(e, t) {
|
|
244
244
|
let n = [];
|
|
245
|
-
return t.length > 0 && n.push(
|
|
245
|
+
return t.length > 0 && n.push(J(t)), e.length > 0 && n.push(ce(e)), n.length > 0 ? new RegExp(n.join("|"), "g") : null;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function ue(e, t) {
|
|
248
248
|
return t.some((t) => e.startsWith(t));
|
|
249
249
|
}
|
|
250
|
-
function
|
|
250
|
+
function Y(e) {
|
|
251
251
|
return `${e.trigger}${e.value}`;
|
|
252
252
|
}
|
|
253
253
|
//#endregion
|
|
254
254
|
//#region src/lib/ComposerCore.ts
|
|
255
|
-
function
|
|
255
|
+
function de({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandidates: r = [], commandTriggers: i = [], remoteImageUrls: a = [], isTaskRunning: o = !1, queueSubmissions: s = !1 } = {}) {
|
|
256
256
|
let c = e?.text ?? t, l = r.flatMap((e) => {
|
|
257
|
-
let t =
|
|
257
|
+
let t = Me("mention", Y(e), c, { detail: e.detail });
|
|
258
258
|
return t ? [t] : [];
|
|
259
259
|
}), u = l.flatMap((e) => {
|
|
260
|
-
let t = r.find((t) =>
|
|
260
|
+
let t = r.find((t) => Y(t) === e.label);
|
|
261
261
|
return t ? [{
|
|
262
262
|
id: e.id,
|
|
263
263
|
trigger: t.trigger,
|
|
@@ -266,13 +266,13 @@ function W({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandid
|
|
|
266
266
|
persistsAs: t.persistsAs
|
|
267
267
|
}] : [];
|
|
268
268
|
}), d = e?.remoteImages ?? (e?.remoteImageUrls ?? a).map((e, t) => ({
|
|
269
|
-
id:
|
|
269
|
+
id: ct("remote-image", e, t),
|
|
270
270
|
url: e
|
|
271
271
|
}));
|
|
272
272
|
return {
|
|
273
273
|
text: c,
|
|
274
274
|
cursor: c.length,
|
|
275
|
-
elements:
|
|
275
|
+
elements: Q(e?.elements ?? [...ge(c, n, i), ...l]),
|
|
276
276
|
mentionBindings: e?.mentionBindings ?? u,
|
|
277
277
|
imageAttachments: [],
|
|
278
278
|
remoteImages: d,
|
|
@@ -288,47 +288,47 @@ function W({ initialDraft: e, text: t = "", slashCommands: n = [], mentionCandid
|
|
|
288
288
|
killBuffer: ""
|
|
289
289
|
};
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function fe(e) {
|
|
292
292
|
return e.text.length === 0 && e.imageAttachments.length === 0 && e.remoteImages.length === 0 && e.pendingPastes.length === 0;
|
|
293
293
|
}
|
|
294
|
-
function
|
|
295
|
-
return
|
|
294
|
+
function pe(e, t, n) {
|
|
295
|
+
return he(e, t, n);
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function me(e, t) {
|
|
298
298
|
if (!t || t < 1) return null;
|
|
299
299
|
let n = ze(e.prompt);
|
|
300
300
|
return n <= t ? null : `Prompt is too long after expanding pasted content (${n} chars; max ${t} chars).`;
|
|
301
301
|
}
|
|
302
|
-
function
|
|
303
|
-
let r =
|
|
304
|
-
r = [...r.filter((e) => e.kind !== "slash-command"), ...
|
|
302
|
+
function X(e, t, n) {
|
|
303
|
+
let r = Ee(e.elements, e.text);
|
|
304
|
+
r = [...r.filter((e) => e.kind !== "slash-command"), ...ge(e.text, t, n)];
|
|
305
305
|
let i = e.mentionBindings.filter((e) => r.some((t) => t.id === e.id)), a = e.imageAttachments.filter((e) => r.some((t) => t.kind === "image" && t.label === e.placeholder)), o = e.pendingPastes.filter((e) => r.some((t) => t.kind === "paste" && t.label === e.placeholder));
|
|
306
306
|
return {
|
|
307
307
|
...e,
|
|
308
|
-
elements:
|
|
308
|
+
elements: Q(r),
|
|
309
309
|
mentionBindings: i,
|
|
310
310
|
imageAttachments: Le(a, e.remoteImages.length),
|
|
311
311
|
pendingPastes: o
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
|
-
function
|
|
315
|
-
let r = e.text.trim(), i =
|
|
314
|
+
function he(e, t, n) {
|
|
315
|
+
let r = e.text.trim(), i = Se(e.text, r, e.elements), a = be(e.text, e.elements, e.pendingPastes), o = a.text, s = o.trim(), c = Se(o, s, a.elements), l = e.imageAttachments.filter((t) => e.text.includes(t.placeholder)), u = Ce(r, i), d = $({
|
|
316
316
|
text: u.text,
|
|
317
317
|
elements: u.elements,
|
|
318
318
|
mentionBindings: e.mentionBindings
|
|
319
|
-
}), f =
|
|
319
|
+
}), f = $({
|
|
320
320
|
text: s,
|
|
321
321
|
elements: c,
|
|
322
322
|
mentionBindings: e.mentionBindings
|
|
323
323
|
});
|
|
324
324
|
if (!s && l.length === 0 && e.remoteImages.length === 0) return null;
|
|
325
|
-
let p =
|
|
325
|
+
let p = ue(o, n) ? Z(s, c, t, n) : null, m = p?.prompt === void 0 ? null : p.args ? `${p.prompt}\n\n${$({
|
|
326
326
|
text: p.args,
|
|
327
327
|
elements: p.argsElements,
|
|
328
328
|
mentionBindings: e.mentionBindings
|
|
329
329
|
})}` : p.prompt, h = p?.prompt === void 0 ? null : p.args ? (() => {
|
|
330
|
-
let t =
|
|
331
|
-
return `${p.prompt}\n\n${
|
|
330
|
+
let t = Ce(p.args, p.argsElements);
|
|
331
|
+
return `${p.prompt}\n\n${$({
|
|
332
332
|
text: t.text,
|
|
333
333
|
elements: t.elements,
|
|
334
334
|
mentionBindings: e.mentionBindings
|
|
@@ -377,16 +377,16 @@ function ve(e, t, n) {
|
|
|
377
377
|
mentionBindings: e.mentionBindings
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function ge(e, t, n) {
|
|
381
381
|
let r = [];
|
|
382
382
|
if (n.length === 0) return r;
|
|
383
|
-
let i = e.matchAll(RegExp(`(^|\\s)((?:${
|
|
383
|
+
let i = e.matchAll(RegExp(`(^|\\s)((?:${q(n)})([A-Za-z0-9_:-]+))(?=\\s|$)`, "g"));
|
|
384
384
|
for (let e of i) {
|
|
385
|
-
let n =
|
|
385
|
+
let n = G(e[3], t);
|
|
386
386
|
if (!n) continue;
|
|
387
387
|
let i = e[2], a = e.index + e[1].length;
|
|
388
388
|
r.push({
|
|
389
|
-
id:
|
|
389
|
+
id: ct("slash-command", i, a),
|
|
390
390
|
kind: "slash-command",
|
|
391
391
|
label: i,
|
|
392
392
|
range: {
|
|
@@ -398,10 +398,10 @@ function G(e, t, n) {
|
|
|
398
398
|
}
|
|
399
399
|
return r;
|
|
400
400
|
}
|
|
401
|
-
function
|
|
402
|
-
let i = e.match(RegExp(`^(?:${
|
|
401
|
+
function Z(e, t, n, r) {
|
|
402
|
+
let i = e.match(RegExp(`^(?:${q(r)})([A-Za-z0-9_:-]+)(?:\\s+([\\s\\S]+))?$`));
|
|
403
403
|
if (!i) return null;
|
|
404
|
-
let a =
|
|
404
|
+
let a = G(i[1], n);
|
|
405
405
|
if (!a) return null;
|
|
406
406
|
let o = i[2] ?? "";
|
|
407
407
|
if (!o.trim()) return {
|
|
@@ -414,15 +414,15 @@ function ye(e, t, n, r) {
|
|
|
414
414
|
command: a.value,
|
|
415
415
|
prompt: a.expandsTo,
|
|
416
416
|
args: u,
|
|
417
|
-
argsElements:
|
|
417
|
+
argsElements: xe(t, l, l + u.length)
|
|
418
418
|
};
|
|
419
419
|
}
|
|
420
|
-
function
|
|
420
|
+
function _e(e, t, n) {
|
|
421
421
|
if (n.length === 0) return null;
|
|
422
|
-
let r = e.match(RegExp(`^(?:${
|
|
423
|
-
return !r ||
|
|
422
|
+
let r = e.match(RegExp(`^(?:${q(n)})([A-Za-z0-9_:-]+)(?:\\s+[\\s\\S]*)?$`));
|
|
423
|
+
return !r || G(r[1], t) || ye(r[1]) ? null : r[1];
|
|
424
424
|
}
|
|
425
|
-
var
|
|
425
|
+
var ve = /* @__PURE__ */ new Set([
|
|
426
426
|
"Applications",
|
|
427
427
|
"Library",
|
|
428
428
|
"System",
|
|
@@ -441,10 +441,10 @@ var xe = /* @__PURE__ */ new Set([
|
|
|
441
441
|
"var",
|
|
442
442
|
"workspace"
|
|
443
443
|
]);
|
|
444
|
-
function
|
|
445
|
-
return
|
|
444
|
+
function ye(e) {
|
|
445
|
+
return ve.has(e);
|
|
446
446
|
}
|
|
447
|
-
function
|
|
447
|
+
function be(e, t, n) {
|
|
448
448
|
if (n.length === 0 || t.length === 0) return {
|
|
449
449
|
text: e,
|
|
450
450
|
elements: t
|
|
@@ -455,7 +455,7 @@ function Se(e, t, n) {
|
|
|
455
455
|
t.push(e.content), r.set(e.placeholder, t);
|
|
456
456
|
}
|
|
457
457
|
let i = "", a = [], o = 0;
|
|
458
|
-
for (let n of
|
|
458
|
+
for (let n of Q(t)) {
|
|
459
459
|
let t = Math.min(n.range.start, e.length), s = Math.min(n.range.end, e.length);
|
|
460
460
|
if (t > s) continue;
|
|
461
461
|
t > o && (i += e.slice(o, t));
|
|
@@ -478,7 +478,7 @@ function Se(e, t, n) {
|
|
|
478
478
|
elements: a
|
|
479
479
|
};
|
|
480
480
|
}
|
|
481
|
-
function
|
|
481
|
+
function xe(e, t, n) {
|
|
482
482
|
return e.filter((e) => e.range.end > t && e.range.start < n).map((e) => ({
|
|
483
483
|
...e,
|
|
484
484
|
range: {
|
|
@@ -487,7 +487,7 @@ function Ce(e, t, n) {
|
|
|
487
487
|
}
|
|
488
488
|
})).filter((e) => e.range.start < e.range.end);
|
|
489
489
|
}
|
|
490
|
-
function
|
|
490
|
+
function Se(e, t, n) {
|
|
491
491
|
let r = e.indexOf(t);
|
|
492
492
|
return r <= 0 ? n : n.filter((e) => e.range.end > r).map((e) => ({
|
|
493
493
|
...e,
|
|
@@ -497,13 +497,13 @@ function we(e, t, n) {
|
|
|
497
497
|
}
|
|
498
498
|
}));
|
|
499
499
|
}
|
|
500
|
-
function
|
|
501
|
-
let n =
|
|
502
|
-
for (let t of n.toReversed()) e =
|
|
500
|
+
function Ce(e, t) {
|
|
501
|
+
let n = Q(t.filter((e) => e.kind === "image"));
|
|
502
|
+
for (let t of n.toReversed()) e = Te(e, t.range, "");
|
|
503
503
|
let r = (e) => n.reduce((t, n) => t + Math.max(0, Math.min(e, n.range.end) - n.range.start), 0);
|
|
504
504
|
return {
|
|
505
505
|
text: e,
|
|
506
|
-
elements:
|
|
506
|
+
elements: Q(t.filter((e) => e.kind !== "image")).map((e) => ({
|
|
507
507
|
...e,
|
|
508
508
|
range: {
|
|
509
509
|
start: e.range.start - r(e.range.start),
|
|
@@ -512,25 +512,25 @@ function Te(e, t) {
|
|
|
512
512
|
}))
|
|
513
513
|
};
|
|
514
514
|
}
|
|
515
|
-
function
|
|
515
|
+
function we(e, t, n, r) {
|
|
516
516
|
return e < r && t > n;
|
|
517
517
|
}
|
|
518
|
-
function
|
|
518
|
+
function Te(e, t, n) {
|
|
519
519
|
return e.slice(0, t.start) + n + e.slice(t.end);
|
|
520
520
|
}
|
|
521
|
-
function
|
|
521
|
+
function Ee(e, t) {
|
|
522
522
|
let n = /* @__PURE__ */ new Map();
|
|
523
|
-
return
|
|
524
|
-
let r =
|
|
523
|
+
return Q(e).map((e) => {
|
|
524
|
+
let r = De(t, e.label);
|
|
525
525
|
if (r.length === 0) return null;
|
|
526
|
-
let i = `${e.kind}:${e.label}`, a = n.get(i) ?? [], o =
|
|
526
|
+
let i = `${e.kind}:${e.label}`, a = n.get(i) ?? [], o = Oe(r, e, a) ?? ke(r, e, a) ?? Ae(r, e);
|
|
527
527
|
return n.set(i, [...a, o]), {
|
|
528
528
|
...e,
|
|
529
529
|
range: o
|
|
530
530
|
};
|
|
531
531
|
}).filter((e) => !!e);
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function De(e, t) {
|
|
534
534
|
if (!t) return [];
|
|
535
535
|
let n = [], r = e.indexOf(t);
|
|
536
536
|
for (; r !== -1;) n.push({
|
|
@@ -539,22 +539,22 @@ function ke(e, t) {
|
|
|
539
539
|
}), r = e.indexOf(t, r + t.length);
|
|
540
540
|
return n;
|
|
541
541
|
}
|
|
542
|
-
function
|
|
543
|
-
return e.find((e) => e.start === t.range.start && e.end === t.range.end && !
|
|
542
|
+
function Oe(e, t, n) {
|
|
543
|
+
return e.find((e) => e.start === t.range.start && e.end === t.range.end && !je(e, n));
|
|
544
544
|
}
|
|
545
|
-
function
|
|
546
|
-
return
|
|
545
|
+
function ke(e, t, n) {
|
|
546
|
+
return Ae(e.filter((e) => !je(e, n)), t);
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function Ae(e, t) {
|
|
549
549
|
return [...e].sort((e, n) => Math.abs(e.start - t.range.start) - Math.abs(n.start - t.range.start) || e.start - n.start)[0];
|
|
550
550
|
}
|
|
551
|
-
function
|
|
552
|
-
return t.some((t) => e.start === t.start && e.end === t.end &&
|
|
551
|
+
function je(e, t) {
|
|
552
|
+
return t.some((t) => e.start === t.start && e.end === t.end && we(e.start, e.end, t.start, t.end));
|
|
553
553
|
}
|
|
554
|
-
function
|
|
554
|
+
function Me(e, t, n, r = {}) {
|
|
555
555
|
let i = n.indexOf(t);
|
|
556
556
|
return i === -1 ? null : {
|
|
557
|
-
id:
|
|
557
|
+
id: ct(e, t, i),
|
|
558
558
|
kind: e,
|
|
559
559
|
label: t,
|
|
560
560
|
range: {
|
|
@@ -564,23 +564,23 @@ function Pe(e, t, n, r = {}) {
|
|
|
564
564
|
detail: r.detail
|
|
565
565
|
};
|
|
566
566
|
}
|
|
567
|
-
function
|
|
567
|
+
function Q(e) {
|
|
568
568
|
return [...e].sort((e, t) => e.range.start - t.range.start);
|
|
569
569
|
}
|
|
570
|
-
var
|
|
570
|
+
var Ne = {
|
|
571
571
|
image: "Image",
|
|
572
572
|
video: "Video",
|
|
573
573
|
audio: "Audio"
|
|
574
574
|
};
|
|
575
|
-
function
|
|
575
|
+
function Pe(e) {
|
|
576
576
|
let t = e.type.split("/")[0];
|
|
577
577
|
return t === "image" || t === "video" || t === "audio" ? t : null;
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function Fe(e) {
|
|
580
580
|
return e === "video" || e === "audio" ? e : "image";
|
|
581
581
|
}
|
|
582
582
|
function Ie(e, t) {
|
|
583
|
-
return `[${
|
|
583
|
+
return `[${Ne[e]} #${t}]`;
|
|
584
584
|
}
|
|
585
585
|
function Le(e, t) {
|
|
586
586
|
return e.map((e, n) => ({
|
|
@@ -597,7 +597,7 @@ function ze(e) {
|
|
|
597
597
|
return Array.from(e).length;
|
|
598
598
|
}
|
|
599
599
|
function Be(e) {
|
|
600
|
-
let t =
|
|
600
|
+
let t = Ce(e.text, e.elements);
|
|
601
601
|
return {
|
|
602
602
|
text: t.text,
|
|
603
603
|
elements: et(t.elements),
|
|
@@ -618,11 +618,11 @@ function He(e, t) {
|
|
|
618
618
|
return !n.persistedPrompt.trim() && n.remoteImages.length === 0 && n.pendingPastes.length === 0 ? e.history : [n, ...e.history].slice(0, 8);
|
|
619
619
|
}
|
|
620
620
|
function Ue({ text: e, slashCommands: t = [], commandTriggers: n = [], mentionCandidates: r = [] }) {
|
|
621
|
-
let i =
|
|
622
|
-
return Be(
|
|
621
|
+
let i = Ke(e, r), a = Ze(i.text, i.elements, i.protectedRanges, t, r);
|
|
622
|
+
return Be(X(de({
|
|
623
623
|
initialDraft: {
|
|
624
624
|
text: i.text,
|
|
625
|
-
elements:
|
|
625
|
+
elements: Q([...i.elements, ...a.elements]),
|
|
626
626
|
mentionBindings: [...i.mentionBindings, ...a.mentionBindings]
|
|
627
627
|
},
|
|
628
628
|
slashCommands: t
|
|
@@ -634,25 +634,25 @@ function We({ source: e, slashCommands: t = [], mentionCandidates: n = [] }) {
|
|
|
634
634
|
slashCommands: t,
|
|
635
635
|
mentionCandidates: n
|
|
636
636
|
}), i = [...e.pendingPastes.flatMap((e) => {
|
|
637
|
-
let t =
|
|
637
|
+
let t = Me("paste", e.placeholder, r.text ?? "", { detail: `${ze(e.content)} chars` });
|
|
638
638
|
return t ? [t] : [];
|
|
639
639
|
})];
|
|
640
640
|
return {
|
|
641
641
|
...r,
|
|
642
|
-
elements:
|
|
642
|
+
elements: Q([...r.elements ?? [], ...i]),
|
|
643
643
|
remoteImages: e.remoteImages.map((e) => ({ ...e })),
|
|
644
644
|
pendingPastes: nt(e.pendingPastes)
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
|
-
function
|
|
648
|
-
let t = e.text ?? "", n =
|
|
649
|
-
for (let e of n) t =
|
|
647
|
+
function $(e) {
|
|
648
|
+
let t = e.text ?? "", n = Q(e.elements ?? []).map((t) => $e(t, e)).filter((e) => !!e).sort((e, t) => t.range.start - e.range.start);
|
|
649
|
+
for (let e of n) t = Te(t, e.range, e.text);
|
|
650
650
|
return t;
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Ge(e) {
|
|
653
653
|
return e.startsWith("composer-text-link://") ? decodeURIComponent(e.replace(/^composer-text-link:\/\//, "")) : e;
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function Ke(e, t) {
|
|
656
656
|
let n = [], i = [], a = [], o = "";
|
|
657
657
|
for (let s of r(e)) {
|
|
658
658
|
if (s.kind === "inline-code" || s.kind === "code-block") {
|
|
@@ -667,9 +667,9 @@ function X(e, t) {
|
|
|
667
667
|
o += s.source;
|
|
668
668
|
continue;
|
|
669
669
|
}
|
|
670
|
-
let e = s.label, r = s.href, c =
|
|
670
|
+
let e = s.label, r = s.href, c = Ge(r), l = qe(e, t), u = l ? Y(l) : e, d = o.length;
|
|
671
671
|
if (o += u, l) {
|
|
672
|
-
let e =
|
|
672
|
+
let e = ct("mention", u, d);
|
|
673
673
|
n.push({
|
|
674
674
|
id: e,
|
|
675
675
|
kind: "mention",
|
|
@@ -687,7 +687,7 @@ function X(e, t) {
|
|
|
687
687
|
persistsAs: l.persistsAs
|
|
688
688
|
});
|
|
689
689
|
} else n.push({
|
|
690
|
-
id:
|
|
690
|
+
id: ct("link", u, d),
|
|
691
691
|
kind: "link",
|
|
692
692
|
label: u,
|
|
693
693
|
range: {
|
|
@@ -705,14 +705,14 @@ function X(e, t) {
|
|
|
705
705
|
};
|
|
706
706
|
}
|
|
707
707
|
function qe(e, t) {
|
|
708
|
-
return t.find((t) =>
|
|
708
|
+
return t.find((t) => Y(t) === e) ?? null;
|
|
709
709
|
}
|
|
710
710
|
function Je(e) {
|
|
711
711
|
return [...new Set(e.map((e) => e.trigger).filter(Boolean))].sort((e, t) => t.length - e.length);
|
|
712
712
|
}
|
|
713
713
|
function Ye(e) {
|
|
714
714
|
let t = Je(e);
|
|
715
|
-
return t.length === 0 ? null : RegExp(`(?:${t.map(
|
|
715
|
+
return t.length === 0 ? null : RegExp(`(?:${t.map(T).join("|")})[A-Za-z0-9_:-]+`, "g");
|
|
716
716
|
}
|
|
717
717
|
function Xe(e, t) {
|
|
718
718
|
return Je(t).find((t) => e.startsWith(t))?.length ?? 0;
|
|
@@ -721,13 +721,13 @@ function Ze(e, t, n, r, i) {
|
|
|
721
721
|
let a = [], o = [], s = [], c = (r, i) => {
|
|
722
722
|
let a = r + i.length;
|
|
723
723
|
return (r === 0 || /\s/.test(e[r - 1] ?? "")) && !Qe(r, i, t) && !s.some((e) => r < e.end && a > e.start) && !n.some((e) => r < e.end && a > e.start);
|
|
724
|
-
}, l = [...i].sort((e, t) =>
|
|
724
|
+
}, l = [...i].sort((e, t) => Y(t).length - Y(e).length);
|
|
725
725
|
for (let t of l) {
|
|
726
|
-
let n =
|
|
726
|
+
let n = Y(t);
|
|
727
727
|
if (n) for (let r = e.indexOf(n); r !== -1; r = e.indexOf(n, r + n.length)) {
|
|
728
728
|
let i = r + n.length;
|
|
729
729
|
if (/[\w-]/.test(e[i] ?? "") || !c(r, n)) continue;
|
|
730
|
-
let l =
|
|
730
|
+
let l = ct("mention", n, r);
|
|
731
731
|
s.push({
|
|
732
732
|
start: r,
|
|
733
733
|
end: i
|
|
@@ -753,12 +753,12 @@ function Ze(e, t, n, r, i) {
|
|
|
753
753
|
for (let t of u ? e.matchAll(u) : []) {
|
|
754
754
|
let e = t.index ?? 0, n = t[0];
|
|
755
755
|
if (!c(e, n)) continue;
|
|
756
|
-
let i =
|
|
756
|
+
let i = G(n.slice(Xe(n, r)), r);
|
|
757
757
|
i && (s.push({
|
|
758
758
|
start: e,
|
|
759
759
|
end: e + n.length
|
|
760
760
|
}), a.push({
|
|
761
|
-
id:
|
|
761
|
+
id: ct("slash-command", n, e),
|
|
762
762
|
kind: "slash-command",
|
|
763
763
|
label: n,
|
|
764
764
|
range: {
|
|
@@ -823,82 +823,82 @@ function it(e, t, n) {
|
|
|
823
823
|
return n === -1 ? t === 0 || !e.slice(0, t).includes("\n") : t === e.length || !e.slice(t).includes("\n");
|
|
824
824
|
}
|
|
825
825
|
function at(e, t) {
|
|
826
|
-
let n =
|
|
827
|
-
for (; n > 0 &&
|
|
826
|
+
let n = lt(e, t);
|
|
827
|
+
for (; n > 0 && gt(ft(e, n));) n = ut(e, n);
|
|
828
828
|
if (n === 0) return 0;
|
|
829
|
-
let r =
|
|
830
|
-
if (r === "cjk") return
|
|
831
|
-
for (; n > 0 &&
|
|
829
|
+
let r = yt(ft(e, n));
|
|
830
|
+
if (r === "cjk") return ut(e, n);
|
|
831
|
+
for (; n > 0 && yt(ft(e, n)) === r;) n = ut(e, n);
|
|
832
832
|
return n;
|
|
833
833
|
}
|
|
834
834
|
function ot(e, t) {
|
|
835
|
-
let n =
|
|
836
|
-
for (; n < e.length &&
|
|
835
|
+
let n = lt(e, t);
|
|
836
|
+
for (; n < e.length && gt(pt(e, n));) n = dt(e, n);
|
|
837
837
|
if (n >= e.length) return e.length;
|
|
838
|
-
let r =
|
|
839
|
-
if (r === "cjk") return
|
|
840
|
-
for (; n < e.length &&
|
|
838
|
+
let r = yt(pt(e, n));
|
|
839
|
+
if (r === "cjk") return dt(e, n);
|
|
840
|
+
for (; n < e.length && yt(pt(e, n)) === r;) n = dt(e, n);
|
|
841
841
|
return n;
|
|
842
842
|
}
|
|
843
843
|
function st(e, t) {
|
|
844
844
|
return (e % t + t) % t;
|
|
845
845
|
}
|
|
846
|
-
function
|
|
846
|
+
function ct(e, t, n) {
|
|
847
847
|
return `${e}:${n}:${t}`;
|
|
848
848
|
}
|
|
849
|
-
function ct(e, t) {
|
|
850
|
-
let n = Math.max(0, Math.min(t, e.length));
|
|
851
|
-
return n > 0 && n < e.length && mt(e.charCodeAt(n)) && --n, n;
|
|
852
|
-
}
|
|
853
849
|
function lt(e, t) {
|
|
854
|
-
let n = t
|
|
855
|
-
return n > 0 &&
|
|
850
|
+
let n = Math.max(0, Math.min(t, e.length));
|
|
851
|
+
return n > 0 && n < e.length && ht(e.charCodeAt(n)) && --n, n;
|
|
856
852
|
}
|
|
857
853
|
function ut(e, t) {
|
|
858
|
-
let n = t
|
|
859
|
-
return Math.
|
|
854
|
+
let n = t - 1;
|
|
855
|
+
return n > 0 && ht(e.charCodeAt(n)) ? n - 1 : Math.max(n, 0);
|
|
860
856
|
}
|
|
861
857
|
function dt(e, t) {
|
|
862
|
-
let n =
|
|
863
|
-
return
|
|
858
|
+
let n = t + (mt(e.charCodeAt(t)) ? 2 : 1);
|
|
859
|
+
return Math.min(n, e.length);
|
|
864
860
|
}
|
|
865
861
|
function ft(e, t) {
|
|
866
|
-
|
|
862
|
+
let n = ut(e, t);
|
|
863
|
+
return e.slice(n, t);
|
|
867
864
|
}
|
|
868
|
-
function pt(e) {
|
|
869
|
-
return e
|
|
865
|
+
function pt(e, t) {
|
|
866
|
+
return e.slice(t, dt(e, t));
|
|
870
867
|
}
|
|
871
868
|
function mt(e) {
|
|
872
|
-
return e >=
|
|
869
|
+
return e >= 55296 && e <= 56319;
|
|
873
870
|
}
|
|
874
871
|
function ht(e) {
|
|
875
|
-
return
|
|
872
|
+
return e >= 56320 && e <= 57343;
|
|
876
873
|
}
|
|
877
874
|
function gt(e) {
|
|
878
|
-
return
|
|
875
|
+
return /\s/u.test(e);
|
|
879
876
|
}
|
|
880
877
|
function _t(e) {
|
|
881
|
-
return /[\p{
|
|
878
|
+
return !vt(e) && /[\p{Letter}\p{Number}_]/u.test(e);
|
|
882
879
|
}
|
|
883
880
|
function vt(e) {
|
|
884
|
-
return
|
|
881
|
+
return /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(e);
|
|
882
|
+
}
|
|
883
|
+
function yt(e) {
|
|
884
|
+
return vt(e) ? "cjk" : _t(e) ? "word" : "separator";
|
|
885
885
|
}
|
|
886
886
|
//#endregion
|
|
887
887
|
//#region src/lib/ComposerDraft.ts
|
|
888
|
-
var
|
|
889
|
-
function
|
|
890
|
-
let t = localStorage.getItem(`${
|
|
888
|
+
var bt = "composer-draft:v1:";
|
|
889
|
+
function xt(e) {
|
|
890
|
+
let t = localStorage.getItem(`${bt}${e}`);
|
|
891
891
|
if (!t) return null;
|
|
892
892
|
try {
|
|
893
893
|
let e = JSON.parse(t);
|
|
894
|
-
return
|
|
894
|
+
return wt(e) ? e : null;
|
|
895
895
|
} catch {
|
|
896
896
|
return null;
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
|
-
function
|
|
900
|
-
let n = `${
|
|
901
|
-
if (!t ||
|
|
899
|
+
function St(e, t) {
|
|
900
|
+
let n = `${bt}${e}`;
|
|
901
|
+
if (!t || Ct(t)) {
|
|
902
902
|
localStorage.removeItem(n);
|
|
903
903
|
return;
|
|
904
904
|
}
|
|
@@ -906,26 +906,22 @@ function xt(e, t) {
|
|
|
906
906
|
localStorage.setItem(n, JSON.stringify(t));
|
|
907
907
|
} catch {}
|
|
908
908
|
}
|
|
909
|
-
function
|
|
909
|
+
function Ct(e) {
|
|
910
910
|
return !e.persistedPrompt.trim() && e.remoteImages.length === 0 && e.pendingPastes.length === 0;
|
|
911
911
|
}
|
|
912
|
-
function
|
|
913
|
-
return
|
|
912
|
+
function wt(e) {
|
|
913
|
+
return Tt(e) && Object.keys(e).every((e) => [
|
|
914
914
|
"persistedPrompt",
|
|
915
915
|
"remoteImages",
|
|
916
916
|
"pendingPastes"
|
|
917
917
|
].includes(e)) && typeof e.persistedPrompt == "string" && Array.isArray(e.remoteImages) && Array.isArray(e.pendingPastes);
|
|
918
918
|
}
|
|
919
|
-
function
|
|
919
|
+
function Tt(e) {
|
|
920
920
|
return typeof e == "object" && !!e;
|
|
921
921
|
}
|
|
922
922
|
//#endregion
|
|
923
923
|
//#region src/lib/ComposerRegistry.tsx
|
|
924
|
-
var
|
|
925
|
-
function Ot(e) {
|
|
926
|
-
return null;
|
|
927
|
-
}
|
|
928
|
-
Ot.role = Tt;
|
|
924
|
+
var Et = Symbol.for("composer.registry.trigger"), Dt = Symbol.for("composer.registry.command"), Ot = Symbol.for("composer.registry.mention");
|
|
929
925
|
function kt(e) {
|
|
930
926
|
return null;
|
|
931
927
|
}
|
|
@@ -935,6 +931,10 @@ function At(e) {
|
|
|
935
931
|
}
|
|
936
932
|
At.role = Dt;
|
|
937
933
|
function jt(e) {
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
jt.role = Ot;
|
|
937
|
+
function Mt(e) {
|
|
938
938
|
let t = [], n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = !1, o = (e) => {
|
|
939
939
|
for (let s of u.toArray(e)) {
|
|
940
940
|
if (!p(s)) {
|
|
@@ -945,8 +945,8 @@ function jt(e) {
|
|
|
945
945
|
p(s) && o(s.props.children);
|
|
946
946
|
continue;
|
|
947
947
|
}
|
|
948
|
-
if (
|
|
949
|
-
p(s) &&
|
|
948
|
+
if (Lt(s.type, Et)) {
|
|
949
|
+
p(s) && Ft(s.props, {
|
|
950
950
|
slashCommands: t,
|
|
951
951
|
mentionCandidates: n,
|
|
952
952
|
commandTriggers: r,
|
|
@@ -954,7 +954,7 @@ function jt(e) {
|
|
|
954
954
|
});
|
|
955
955
|
continue;
|
|
956
956
|
}
|
|
957
|
-
if (
|
|
957
|
+
if (Lt(s.type, Dt) || Lt(s.type, Ot)) throw Error("Composer.Command and Composer.Mention must be placed inside a <Composer.Trigger>.");
|
|
958
958
|
a = !0;
|
|
959
959
|
}
|
|
960
960
|
};
|
|
@@ -966,29 +966,29 @@ function jt(e) {
|
|
|
966
966
|
hasLayoutChildren: a
|
|
967
967
|
};
|
|
968
968
|
}
|
|
969
|
-
function
|
|
969
|
+
function Nt(e) {
|
|
970
970
|
return JSON.stringify([
|
|
971
|
-
e.slashCommands.map(
|
|
972
|
-
e.mentionCandidates.map(
|
|
971
|
+
e.slashCommands.map(Pt),
|
|
972
|
+
e.mentionCandidates.map(Pt),
|
|
973
973
|
e.commandTriggers,
|
|
974
974
|
e.mentionTriggers
|
|
975
975
|
]);
|
|
976
976
|
}
|
|
977
|
-
function
|
|
977
|
+
function Pt(e) {
|
|
978
978
|
let { icon: t, ...n } = e;
|
|
979
979
|
return n;
|
|
980
980
|
}
|
|
981
|
-
function
|
|
981
|
+
function Ft(e, t) {
|
|
982
982
|
let { trigger: n } = e;
|
|
983
983
|
for (let r of u.toArray(e.children)) if (p(r)) {
|
|
984
984
|
if (r.type === d) {
|
|
985
|
-
p(r) &&
|
|
985
|
+
p(r) && Ft({
|
|
986
986
|
trigger: n,
|
|
987
987
|
children: r.props.children
|
|
988
988
|
}, t);
|
|
989
989
|
continue;
|
|
990
990
|
}
|
|
991
|
-
if (
|
|
991
|
+
if (Lt(r.type, Dt)) {
|
|
992
992
|
if (t.mentionTriggers.has(n)) throw Error(`Composer.Trigger "${n}" already holds mentions; a trigger carries either commands or mentions, not both.`);
|
|
993
993
|
t.commandTriggers.add(n), p(r) && t.slashCommands.push({
|
|
994
994
|
...r.props,
|
|
@@ -997,15 +997,15 @@ function Pt(e, t) {
|
|
|
997
997
|
});
|
|
998
998
|
continue;
|
|
999
999
|
}
|
|
1000
|
-
if (
|
|
1000
|
+
if (Lt(r.type, Ot)) {
|
|
1001
1001
|
if (t.commandTriggers.has(n)) throw Error(`Composer.Trigger "${n}" already holds commands; a trigger carries either commands or mentions, not both.`);
|
|
1002
|
-
t.mentionTriggers.add(n), p(r) && t.mentionCandidates.push(
|
|
1002
|
+
t.mentionTriggers.add(n), p(r) && t.mentionCandidates.push(It(r.props, n));
|
|
1003
1003
|
continue;
|
|
1004
1004
|
}
|
|
1005
1005
|
throw Error(`<Composer.Trigger trigger="${n}"> accepts only <Composer.Command> and <Composer.Mention> children; wrap them in a fragment rather than a component, which the registry cannot see through.`);
|
|
1006
1006
|
}
|
|
1007
1007
|
}
|
|
1008
|
-
function
|
|
1008
|
+
function It(e, t) {
|
|
1009
1009
|
return {
|
|
1010
1010
|
id: e.id,
|
|
1011
1011
|
trigger: t,
|
|
@@ -1019,43 +1019,341 @@ function Ft(e, t) {
|
|
|
1019
1019
|
visibility: e.visibility
|
|
1020
1020
|
};
|
|
1021
1021
|
}
|
|
1022
|
-
function
|
|
1022
|
+
function Lt(e, t) {
|
|
1023
1023
|
return typeof e == "function" && "role" in e && e.role === t;
|
|
1024
1024
|
}
|
|
1025
1025
|
//#endregion
|
|
1026
1026
|
//#region src/lib/ComposerSuggestions.ts
|
|
1027
|
-
function
|
|
1028
|
-
return [...
|
|
1027
|
+
function Rt(e, t, n, r) {
|
|
1028
|
+
return [...W(e.query, t.filter((t) => t.trigger === e.trigger), r), ...zt(e.query, n.filter((t) => t.trigger === e.trigger), r)];
|
|
1029
1029
|
}
|
|
1030
|
-
function
|
|
1030
|
+
function zt(e, t, n) {
|
|
1031
1031
|
let r = e.slice(1).toLowerCase();
|
|
1032
|
-
return t.filter((e) =>
|
|
1032
|
+
return t.filter((e) => U(e.visibility, n) && (e.label.toLowerCase().includes(r) || Y(e).slice(1).toLowerCase().includes(r))).slice(0, 10);
|
|
1033
|
+
}
|
|
1034
|
+
//#endregion
|
|
1035
|
+
//#region src/lib/dictation/ComposerDictationContext.ts
|
|
1036
|
+
var Bt = f(null);
|
|
1037
|
+
function Vt(e) {
|
|
1038
|
+
let t = e === void 0 ? "useComposerDictation" : e;
|
|
1039
|
+
N(t);
|
|
1040
|
+
let n = h(Bt);
|
|
1041
|
+
if (!n) throw Error(`${t} needs the dictation prop of Composer.Root.`);
|
|
1042
|
+
return n;
|
|
1043
|
+
}
|
|
1044
|
+
//#endregion
|
|
1045
|
+
//#region src/lib/dictation/ComposerDictationParts.tsx
|
|
1046
|
+
function Ht(e, t) {
|
|
1047
|
+
return typeof e == "function" ? (n) => e(n, t) : e;
|
|
1048
|
+
}
|
|
1049
|
+
function Ut(e) {
|
|
1050
|
+
let t = i(15), n, r, o;
|
|
1051
|
+
t[0] === e ? (n = t[1], r = t[2], o = t[3]) : ({render: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o);
|
|
1052
|
+
let { disabled: s } = N("Composer.Dictate"), { state: c, start: l, stop: u } = Vt("Composer.Dictate"), d = c.status === "recording", f = (c.status === "idle" || c.status === "failed") && n !== !0 && !s, p = c.status, m = c.status === "finishing" ? c.end : void 0, h = !d && !f, g = d ? u : l, _;
|
|
1053
|
+
t[4] !== o || t[5] !== c ? (_ = Ht(o, c), t[4] = o, t[5] = c, t[6] = _) : _ = t[6];
|
|
1054
|
+
let v;
|
|
1055
|
+
return t[7] !== r || t[8] !== d || t[9] !== c.status || t[10] !== m || t[11] !== h || t[12] !== g || t[13] !== _ ? (v = /* @__PURE__ */ C(a, {
|
|
1056
|
+
...r,
|
|
1057
|
+
"data-status": p,
|
|
1058
|
+
"data-end": m,
|
|
1059
|
+
"aria-pressed": d,
|
|
1060
|
+
disabled: h,
|
|
1061
|
+
onClick: g,
|
|
1062
|
+
render: _
|
|
1063
|
+
}), t[7] = r, t[8] = d, t[9] = c.status, t[10] = m, t[11] = h, t[12] = g, t[13] = _, t[14] = v) : v = t[14], v;
|
|
1064
|
+
}
|
|
1065
|
+
function Wt(e) {
|
|
1066
|
+
let t = i(13), n, r, o;
|
|
1067
|
+
t[0] === e ? (n = t[1], r = t[2], o = t[3]) : ({render: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o);
|
|
1068
|
+
let { state: s, cancel: c } = Vt("Composer.CancelDictation"), l = s.status === "starting" || s.status === "recording" || s.status === "finishing", u = s.status, d = !l || n === !0, f;
|
|
1069
|
+
t[4] !== o || t[5] !== s ? (f = Ht(o, s), t[4] = o, t[5] = s, t[6] = f) : f = t[6];
|
|
1070
|
+
let p;
|
|
1071
|
+
return t[7] !== c || t[8] !== r || t[9] !== s.status || t[10] !== d || t[11] !== f ? (p = /* @__PURE__ */ C(a, {
|
|
1072
|
+
...r,
|
|
1073
|
+
"data-status": u,
|
|
1074
|
+
disabled: d,
|
|
1075
|
+
onClick: c,
|
|
1076
|
+
render: f
|
|
1077
|
+
}), t[7] = c, t[8] = r, t[9] = s.status, t[10] = d, t[11] = f, t[12] = p) : p = t[12], p;
|
|
1078
|
+
}
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/lib/dictation/DictationError.ts
|
|
1081
|
+
var Gt = class extends Error {
|
|
1082
|
+
code;
|
|
1083
|
+
constructor(e, t) {
|
|
1084
|
+
super(`Dictation failed: ${e}`, t), this.name = "DictationError", this.code = e;
|
|
1085
|
+
}
|
|
1086
|
+
}, Kt = class {
|
|
1087
|
+
#e = "unknown";
|
|
1088
|
+
subscribe = (e) => {
|
|
1089
|
+
let t = new AbortController();
|
|
1090
|
+
return navigator.permissions.query({ name: "microphone" }).then((n) => {
|
|
1091
|
+
if (t.signal.aborted) return;
|
|
1092
|
+
let r = () => {
|
|
1093
|
+
this.#e = n.state, e();
|
|
1094
|
+
};
|
|
1095
|
+
r(), n.addEventListener("change", r, { signal: t.signal });
|
|
1096
|
+
}, (e) => {
|
|
1097
|
+
if (!(e instanceof TypeError)) throw e;
|
|
1098
|
+
}), () => {
|
|
1099
|
+
t.abort();
|
|
1100
|
+
};
|
|
1101
|
+
};
|
|
1102
|
+
getSnapshot = () => this.#e;
|
|
1103
|
+
}, qt = /* @__PURE__ */ new Map([
|
|
1104
|
+
["NotAllowedError", "permission-denied"],
|
|
1105
|
+
["NotFoundError", "no-microphone"],
|
|
1106
|
+
["NotReadableError", "microphone-in-use"]
|
|
1107
|
+
]), Jt = class e {
|
|
1108
|
+
#e = { status: "starting" };
|
|
1109
|
+
#t = /* @__PURE__ */ new Set();
|
|
1110
|
+
#n;
|
|
1111
|
+
constructor(e) {
|
|
1112
|
+
this.#n = e;
|
|
1113
|
+
}
|
|
1114
|
+
static start(t) {
|
|
1115
|
+
let n = new e(t);
|
|
1116
|
+
return n.#r(), n;
|
|
1117
|
+
}
|
|
1118
|
+
subscribe = (e) => (this.#t.add(e), () => {
|
|
1119
|
+
this.#t.delete(e);
|
|
1120
|
+
});
|
|
1121
|
+
getSnapshot = () => this.#e;
|
|
1122
|
+
stop() {
|
|
1123
|
+
let e = this.#e;
|
|
1124
|
+
if (e.status === "starting") {
|
|
1125
|
+
this.cancel();
|
|
1126
|
+
return;
|
|
1127
|
+
}
|
|
1128
|
+
e.status === "recording" && (this.#a({
|
|
1129
|
+
...e,
|
|
1130
|
+
status: "stopping"
|
|
1131
|
+
}), e.recorder.stop());
|
|
1132
|
+
}
|
|
1133
|
+
cancel() {
|
|
1134
|
+
this.#i({ status: "ended" });
|
|
1135
|
+
}
|
|
1136
|
+
async #r() {
|
|
1137
|
+
let e;
|
|
1138
|
+
try {
|
|
1139
|
+
e = await navigator.mediaDevices.getUserMedia({ audio: !0 });
|
|
1140
|
+
} catch (e) {
|
|
1141
|
+
let t = e instanceof DOMException ? qt.get(e.name) : void 0;
|
|
1142
|
+
if (!t) throw e;
|
|
1143
|
+
this.#i({
|
|
1144
|
+
status: "failed",
|
|
1145
|
+
error: new Gt(t, { cause: e })
|
|
1146
|
+
});
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
if (this.#e.status !== "starting") {
|
|
1150
|
+
for (let t of e.getTracks()) t.stop();
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
let t = new MediaRecorder(e), n = [];
|
|
1154
|
+
t.addEventListener("dataavailable", (e) => {
|
|
1155
|
+
n.push(e.data);
|
|
1156
|
+
}), t.addEventListener("stop", () => {
|
|
1157
|
+
this.#e.status === "stopping" && (this.#i({ status: "ended" }), this.#n(new Blob(n, { type: t.mimeType })));
|
|
1158
|
+
}), t.addEventListener("error", (e) => {
|
|
1159
|
+
this.#i({
|
|
1160
|
+
status: "failed",
|
|
1161
|
+
error: new Gt("interrupted", { cause: e })
|
|
1162
|
+
});
|
|
1163
|
+
});
|
|
1164
|
+
for (let t of e.getAudioTracks()) t.addEventListener("ended", () => {
|
|
1165
|
+
this.#i({
|
|
1166
|
+
status: "failed",
|
|
1167
|
+
error: new Gt("interrupted")
|
|
1168
|
+
});
|
|
1169
|
+
});
|
|
1170
|
+
t.start(), this.#a({
|
|
1171
|
+
status: "recording",
|
|
1172
|
+
stream: e,
|
|
1173
|
+
recorder: t
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
#i(e) {
|
|
1177
|
+
let t = this.#e;
|
|
1178
|
+
if (!(t.status === "ended" || t.status === "failed")) {
|
|
1179
|
+
if (t.status !== "starting") {
|
|
1180
|
+
t.recorder.state !== "inactive" && t.recorder.stop();
|
|
1181
|
+
for (let e of t.stream.getTracks()) e.stop();
|
|
1182
|
+
}
|
|
1183
|
+
this.#a(e);
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
#a(e) {
|
|
1187
|
+
this.#e = e;
|
|
1188
|
+
for (let e of this.#t) e();
|
|
1189
|
+
}
|
|
1190
|
+
}, Yt = () => () => void 0, Xt = { status: "ended" }, Zt = () => Xt, Qt = () => "unknown";
|
|
1191
|
+
function $t(e) {
|
|
1192
|
+
let t = i(47), { dictation: n, disabled: r, insertTranscript: a, submitDraft: o } = e, s = "MediaRecorder" in globalThis && "mediaDevices" in navigator, c = n !== void 0, [l] = b(en), u = x(c && s ? l.subscribe : Yt, l.getSnapshot, Qt), [d, f] = b(null), p = x(d ? d.subscribe : Yt, d ? d.getSnapshot : Zt, Zt), [h, v] = b(0), [S, ee] = b("insert"), te = y("insert"), C = y(null), w;
|
|
1193
|
+
t[0] !== n || t[1] !== a || t[2] !== o ? (w = {
|
|
1194
|
+
dictation: n,
|
|
1195
|
+
insertTranscript: a,
|
|
1196
|
+
submitDraft: o
|
|
1197
|
+
}, t[0] = n, t[1] = a, t[2] = o, t[3] = w) : w = t[3];
|
|
1198
|
+
let T = y(w), E;
|
|
1199
|
+
t[4] !== n || t[5] !== a || t[6] !== o ? (E = () => {
|
|
1200
|
+
T.current = {
|
|
1201
|
+
dictation: n,
|
|
1202
|
+
insertTranscript: a,
|
|
1203
|
+
submitDraft: o
|
|
1204
|
+
};
|
|
1205
|
+
}, t[4] = n, t[5] = a, t[6] = o, t[7] = E) : E = t[7], _(E);
|
|
1206
|
+
let D, O;
|
|
1207
|
+
t[8] === Symbol.for("react.memo_cache_sentinel") ? (D = async (e, t) => {
|
|
1208
|
+
let n = new AbortController();
|
|
1209
|
+
C.current = n;
|
|
1210
|
+
try {
|
|
1211
|
+
let { text: e } = await t.transcribe(t.clip, { signal: n.signal });
|
|
1212
|
+
if (!n.signal.aborted) {
|
|
1213
|
+
let t = e.trim();
|
|
1214
|
+
t && T.current.insertTranscript(t), te.current === "send" && T.current.submitDraft();
|
|
1215
|
+
}
|
|
1216
|
+
return {
|
|
1217
|
+
attempt: t.attempt,
|
|
1218
|
+
failure: null
|
|
1219
|
+
};
|
|
1220
|
+
} catch (e) {
|
|
1221
|
+
let r = e;
|
|
1222
|
+
return n.signal.aborted ? {
|
|
1223
|
+
attempt: t.attempt,
|
|
1224
|
+
failure: null
|
|
1225
|
+
} : {
|
|
1226
|
+
attempt: t.attempt,
|
|
1227
|
+
failure: new Gt("transcription-failed", { cause: r })
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
}, O = {
|
|
1231
|
+
attempt: 0,
|
|
1232
|
+
failure: null
|
|
1233
|
+
}, t[8] = D, t[9] = O) : (D = t[8], O = t[9]);
|
|
1234
|
+
let [k, ne, re] = g(D, O), A, j;
|
|
1235
|
+
t[10] !== r || t[11] !== c || t[12] !== d ? (A = () => {
|
|
1236
|
+
(r || !c) && (d?.cancel(), C.current?.abort());
|
|
1237
|
+
}, j = [
|
|
1238
|
+
r,
|
|
1239
|
+
c,
|
|
1240
|
+
d
|
|
1241
|
+
], t[10] = r, t[11] = c, t[12] = d, t[13] = A, t[14] = j) : (A = t[13], j = t[14]), _(A, j);
|
|
1242
|
+
let M, ie;
|
|
1243
|
+
if (t[15] === d ? (M = t[16], ie = t[17]) : (M = () => () => {
|
|
1244
|
+
d?.cancel(), C.current?.abort();
|
|
1245
|
+
}, ie = [d], t[15] = d, t[16] = M, t[17] = ie), _(M, ie), !n) return null;
|
|
1246
|
+
let N, P;
|
|
1247
|
+
if (t[18] !== h || t[19] !== S || t[20] !== k || t[21] !== u || t[22] !== p || t[23] !== re) {
|
|
1248
|
+
P = e(), N = P.status === "starting" || P.status === "recording" || P.status === "finishing";
|
|
1249
|
+
function e() {
|
|
1250
|
+
if (!s) return {
|
|
1251
|
+
status: "unavailable",
|
|
1252
|
+
reason: "unsupported"
|
|
1253
|
+
};
|
|
1254
|
+
switch (p.status) {
|
|
1255
|
+
case "starting": return { status: "starting" };
|
|
1256
|
+
case "recording": return { status: "recording" };
|
|
1257
|
+
case "stopping": return {
|
|
1258
|
+
status: "finishing",
|
|
1259
|
+
end: S
|
|
1260
|
+
};
|
|
1261
|
+
case "ended":
|
|
1262
|
+
case "failed":
|
|
1263
|
+
}
|
|
1264
|
+
return re ? {
|
|
1265
|
+
status: "finishing",
|
|
1266
|
+
end: S
|
|
1267
|
+
} : u === "denied" ? {
|
|
1268
|
+
status: "unavailable",
|
|
1269
|
+
reason: "blocked"
|
|
1270
|
+
} : p.status === "failed" ? {
|
|
1271
|
+
status: "failed",
|
|
1272
|
+
error: p.error
|
|
1273
|
+
} : k.failure && k.attempt === h ? {
|
|
1274
|
+
status: "failed",
|
|
1275
|
+
error: k.failure
|
|
1276
|
+
} : { status: "idle" };
|
|
1277
|
+
}
|
|
1278
|
+
t[18] = h, t[19] = S, t[20] = k, t[21] = u, t[22] = p, t[23] = re, t[24] = N, t[25] = P;
|
|
1279
|
+
} else N = t[24], P = t[25];
|
|
1280
|
+
let F;
|
|
1281
|
+
t[26] === Symbol.for("react.memo_cache_sentinel") ? (F = function(e) {
|
|
1282
|
+
te.current = e, ee(e);
|
|
1283
|
+
}, t[26] = F) : F = t[26];
|
|
1284
|
+
let I = F, L;
|
|
1285
|
+
t[27] !== N || t[28] !== h || t[29] !== r || t[30] !== P ? (L = function() {
|
|
1286
|
+
if (r || N || P.status === "unavailable") return;
|
|
1287
|
+
let e = h + 1;
|
|
1288
|
+
v(e), I("insert"), f(Jt.start((t) => {
|
|
1289
|
+
let n = T.current.dictation;
|
|
1290
|
+
n && m(() => {
|
|
1291
|
+
ne({
|
|
1292
|
+
clip: t,
|
|
1293
|
+
attempt: e,
|
|
1294
|
+
transcribe: n.transcribe
|
|
1295
|
+
});
|
|
1296
|
+
});
|
|
1297
|
+
}));
|
|
1298
|
+
}, t[27] = N, t[28] = h, t[29] = r, t[30] = P, t[31] = L) : L = t[31];
|
|
1299
|
+
let R = L, z;
|
|
1300
|
+
t[32] === d ? z = t[33] : (z = function() {
|
|
1301
|
+
d?.stop();
|
|
1302
|
+
}, t[32] = d, t[33] = z);
|
|
1303
|
+
let B = z, V;
|
|
1304
|
+
t[34] === d ? V = t[35] : (V = function() {
|
|
1305
|
+
d?.cancel(), C.current?.abort();
|
|
1306
|
+
}, t[34] = d, t[35] = V);
|
|
1307
|
+
let H = V, U;
|
|
1308
|
+
t[36] !== d || t[37] !== P ? (U = function() {
|
|
1309
|
+
switch (P.status) {
|
|
1310
|
+
case "starting": return d?.cancel(), !1;
|
|
1311
|
+
case "recording": return I("send"), d?.stop(), !0;
|
|
1312
|
+
case "finishing": return I("send"), !0;
|
|
1313
|
+
default: return !1;
|
|
1314
|
+
}
|
|
1315
|
+
}, t[36] = d, t[37] = P, t[38] = U) : U = t[38];
|
|
1316
|
+
let W = U, G;
|
|
1317
|
+
t[39] !== H || t[40] !== R || t[41] !== P || t[42] !== B ? (G = {
|
|
1318
|
+
state: P,
|
|
1319
|
+
start: R,
|
|
1320
|
+
stop: B,
|
|
1321
|
+
cancel: H
|
|
1322
|
+
}, t[39] = H, t[40] = R, t[41] = P, t[42] = B, t[43] = G) : G = t[43];
|
|
1323
|
+
let K;
|
|
1324
|
+
return t[44] !== W || t[45] !== G ? (K = {
|
|
1325
|
+
api: G,
|
|
1326
|
+
endWithSend: W
|
|
1327
|
+
}, t[44] = W, t[45] = G, t[46] = K) : K = t[46], K;
|
|
1328
|
+
}
|
|
1329
|
+
function en() {
|
|
1330
|
+
return new Kt();
|
|
1033
1331
|
}
|
|
1034
1332
|
//#endregion
|
|
1035
1333
|
//#region src/lib/tiptap/ComposerTiptapDomain.ts
|
|
1036
|
-
function
|
|
1334
|
+
function tn(e) {
|
|
1037
1335
|
return [
|
|
1038
|
-
|
|
1039
|
-
|
|
1336
|
+
M.configure({ link: !1 }),
|
|
1337
|
+
ne.configure({
|
|
1040
1338
|
autolink: !0,
|
|
1041
1339
|
linkOnPaste: !1,
|
|
1042
1340
|
openOnClick: !1,
|
|
1043
1341
|
HTMLAttributes: { "data-token": "link" }
|
|
1044
1342
|
}),
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1343
|
+
an,
|
|
1344
|
+
on,
|
|
1345
|
+
sn,
|
|
1346
|
+
cn(e)
|
|
1049
1347
|
];
|
|
1050
1348
|
}
|
|
1051
|
-
var
|
|
1052
|
-
function
|
|
1349
|
+
var nn = 1e3;
|
|
1350
|
+
function rn(e, t) {
|
|
1053
1351
|
return {
|
|
1054
1352
|
default: t,
|
|
1055
1353
|
parseHTML: (n) => n.getAttribute(e) ?? t
|
|
1056
1354
|
};
|
|
1057
1355
|
}
|
|
1058
|
-
var
|
|
1356
|
+
var an = D.create({
|
|
1059
1357
|
name: "composerSlashCommand",
|
|
1060
1358
|
inclusive: !1,
|
|
1061
1359
|
addAttributes() {
|
|
@@ -1070,14 +1368,14 @@ var Ht = T.create({
|
|
|
1070
1368
|
renderHTML({ HTMLAttributes: e }) {
|
|
1071
1369
|
return [
|
|
1072
1370
|
"span",
|
|
1073
|
-
|
|
1371
|
+
k(e, {
|
|
1074
1372
|
"data-token": "slash-command",
|
|
1075
1373
|
"data-composer-slash-command": e.value
|
|
1076
1374
|
}),
|
|
1077
1375
|
0
|
|
1078
1376
|
];
|
|
1079
1377
|
}
|
|
1080
|
-
}),
|
|
1378
|
+
}), on = O.create({
|
|
1081
1379
|
name: "composerMention",
|
|
1082
1380
|
group: "inline",
|
|
1083
1381
|
inline: !0,
|
|
@@ -1085,12 +1383,12 @@ var Ht = T.create({
|
|
|
1085
1383
|
selectable: !0,
|
|
1086
1384
|
addAttributes() {
|
|
1087
1385
|
return {
|
|
1088
|
-
id:
|
|
1089
|
-
trigger:
|
|
1090
|
-
value:
|
|
1091
|
-
label:
|
|
1092
|
-
detail:
|
|
1093
|
-
persistsAs:
|
|
1386
|
+
id: rn("id", null),
|
|
1387
|
+
trigger: rn("trigger", ""),
|
|
1388
|
+
value: rn("value", ""),
|
|
1389
|
+
label: rn("label", ""),
|
|
1390
|
+
detail: rn("detail", ""),
|
|
1391
|
+
persistsAs: rn("persistsAs", null),
|
|
1094
1392
|
payload: {
|
|
1095
1393
|
default: null,
|
|
1096
1394
|
renderHTML: (e) => e.payload === null || e.payload === void 0 ? {} : { payload: JSON.stringify(e.payload) },
|
|
@@ -1113,7 +1411,7 @@ var Ht = T.create({
|
|
|
1113
1411
|
let n = e.attrs.label || `${e.attrs.trigger ?? ""}${e.attrs.value ?? ""}`;
|
|
1114
1412
|
return [
|
|
1115
1413
|
"span",
|
|
1116
|
-
|
|
1414
|
+
k(t, {
|
|
1117
1415
|
"data-token": "mention",
|
|
1118
1416
|
"data-composer-mention": e.attrs.value,
|
|
1119
1417
|
"data-composer-mention-trigger": e.attrs.trigger
|
|
@@ -1124,7 +1422,7 @@ var Ht = T.create({
|
|
|
1124
1422
|
renderText({ node: e }) {
|
|
1125
1423
|
return e.attrs.label || `${e.attrs.trigger ?? ""}${e.attrs.value ?? ""}`;
|
|
1126
1424
|
}
|
|
1127
|
-
}),
|
|
1425
|
+
}), sn = O.create({
|
|
1128
1426
|
name: "composerAtom",
|
|
1129
1427
|
group: "inline",
|
|
1130
1428
|
inline: !0,
|
|
@@ -1155,7 +1453,7 @@ var Ht = T.create({
|
|
|
1155
1453
|
let n = String(e.attrs.kind ?? "paste"), r = String(e.attrs.label ?? "");
|
|
1156
1454
|
return [
|
|
1157
1455
|
"span",
|
|
1158
|
-
|
|
1456
|
+
k(t, {
|
|
1159
1457
|
"data-token": n,
|
|
1160
1458
|
"data-composer-atom": n,
|
|
1161
1459
|
"data-composer-atom-detail": e.attrs.detail
|
|
@@ -1167,81 +1465,81 @@ var Ht = T.create({
|
|
|
1167
1465
|
return String(e.attrs.label ?? "");
|
|
1168
1466
|
}
|
|
1169
1467
|
});
|
|
1170
|
-
function
|
|
1171
|
-
return
|
|
1468
|
+
function cn(e) {
|
|
1469
|
+
return E.create({
|
|
1172
1470
|
name: "composerClipboard",
|
|
1173
1471
|
addProseMirrorPlugins() {
|
|
1174
|
-
return [new
|
|
1472
|
+
return [new A({ props: {
|
|
1175
1473
|
handlePaste(t, n) {
|
|
1176
1474
|
let r = n.clipboardData;
|
|
1177
1475
|
if (!r) return !1;
|
|
1178
|
-
let i = Array.from(r.files).find((e) =>
|
|
1179
|
-
if (i) return n.preventDefault(),
|
|
1180
|
-
let a = Array.from(r.files).find((e) =>
|
|
1181
|
-
if (a) return n.preventDefault(),
|
|
1182
|
-
let o =
|
|
1476
|
+
let i = Array.from(r.files).find((e) => Pe(e) !== null);
|
|
1477
|
+
if (i) return n.preventDefault(), Ln(t, e.getRemoteImageCount(), i, e.attachImageFile), !0;
|
|
1478
|
+
let a = Array.from(r.files).find((e) => Pe(e) === null);
|
|
1479
|
+
if (a) return n.preventDefault(), Rn(t, a.name || "pasted-file", e.getMentionTrigger()), !0;
|
|
1480
|
+
let o = pr(yr(r.getData("text/uri-list")) || br(r.getData("DownloadURL")) || r.getData("text/plain") || r.getData("text")), s = o.trim();
|
|
1183
1481
|
if (!o) return !1;
|
|
1184
|
-
let c =
|
|
1185
|
-
if (c &&
|
|
1482
|
+
let c = An(t);
|
|
1483
|
+
if (c && xr(s)) {
|
|
1186
1484
|
n.preventDefault();
|
|
1187
|
-
let e =
|
|
1188
|
-
return r ?
|
|
1485
|
+
let e = Sr(s), r = t.state.schema.marks.link;
|
|
1486
|
+
return r ? Mn(t, c, e, r) : !1;
|
|
1189
1487
|
}
|
|
1190
|
-
return
|
|
1488
|
+
return hr(s) && !s.includes("\n") ? (n.preventDefault(), Rn(t, s, e.getMentionTrigger()), !0) : xr(s) && !s.includes("\n") ? (n.preventDefault(), Fn(t, s, Sr(s))) : c && o && !o.includes("\n") && mr(o) <= nn ? (n.preventDefault(), In(t, o, c), !0) : mr(o) > nn ? (n.preventDefault(), kn(t, o), !0) : !1;
|
|
1191
1489
|
},
|
|
1192
1490
|
handleDrop(t, n) {
|
|
1193
1491
|
let r = n.dataTransfer;
|
|
1194
|
-
return r &&
|
|
1492
|
+
return r && ln(t, r, e.getRemoteImageCount(), e.getMentionTrigger(), e.attachImageFile) ? (n.preventDefault(), !0) : !1;
|
|
1195
1493
|
}
|
|
1196
1494
|
} })];
|
|
1197
1495
|
}
|
|
1198
1496
|
});
|
|
1199
1497
|
}
|
|
1200
|
-
function
|
|
1201
|
-
let a = Array.from(t.files).find((e) =>
|
|
1202
|
-
if (a) return
|
|
1203
|
-
let o = Array.from(t.files).find((e) =>
|
|
1204
|
-
if (o) return
|
|
1205
|
-
let s =
|
|
1206
|
-
return s ?
|
|
1498
|
+
function ln(e, t, n, r, i) {
|
|
1499
|
+
let a = Array.from(t.files).find((e) => Pe(e) !== null);
|
|
1500
|
+
if (a) return Ln(e, n, a, i), !0;
|
|
1501
|
+
let o = Array.from(t.files).find((e) => Pe(e) === null);
|
|
1502
|
+
if (o) return Rn(e, o.name || "dropped-file", r), !0;
|
|
1503
|
+
let s = pr(yr(t.getData("text/uri-list")) || br(t.getData("DownloadURL")) || t.getData("text/plain")).trim();
|
|
1504
|
+
return s ? hr(s) && !s.includes("\n") ? (Rn(e, s, r), !0) : xr(s) && !s.includes("\n") ? (Fn(e, s, Sr(s)), !0) : !1 : !1;
|
|
1207
1505
|
}
|
|
1208
|
-
function
|
|
1209
|
-
return e ?
|
|
1506
|
+
function un({ state: e, text: t, slashCommands: n, mentionCandidates: r, triggers: i }) {
|
|
1507
|
+
return e ? dn(de({
|
|
1210
1508
|
initialDraft: e,
|
|
1211
1509
|
slashCommands: n,
|
|
1212
1510
|
commandTriggers: i.commandTriggers,
|
|
1213
1511
|
mentionCandidates: r
|
|
1214
|
-
}), n, r, i) :
|
|
1512
|
+
}), n, r, i) : fn(t ?? "", n, r, i);
|
|
1215
1513
|
}
|
|
1216
|
-
function
|
|
1217
|
-
if (e.elements.length === 0) return
|
|
1514
|
+
function dn(e, t, n, r) {
|
|
1515
|
+
if (e.elements.length === 0) return fn(e.text, t, n, r);
|
|
1218
1516
|
let i = [], a = 0;
|
|
1219
|
-
for (let o of
|
|
1220
|
-
o.range.start > a && i.push(...
|
|
1517
|
+
for (let o of dr(e.elements)) {
|
|
1518
|
+
o.range.start > a && i.push(...pn(e.text.slice(a, o.range.start), t, n, r.commandTriggers, r.mentionTriggers));
|
|
1221
1519
|
let s = e.mentionBindings.find((e) => e.id === o.id || `${e.trigger}${e.value}` === o.label), c = e.pendingPastes.find((e) => e.placeholder === o.label);
|
|
1222
|
-
o.kind === "mention" && s ? i.push(
|
|
1520
|
+
o.kind === "mention" && s ? i.push(Cn(wn(s, o, n))) : o.kind === "paste" && c ? i.push(Tn({
|
|
1223
1521
|
kind: "paste",
|
|
1224
1522
|
label: c.placeholder,
|
|
1225
|
-
detail: o.detail ?? `${
|
|
1523
|
+
detail: o.detail ?? `${mr(c.content)} chars`,
|
|
1226
1524
|
content: c.content
|
|
1227
|
-
})) : o.kind === "rich-link" ? i.push(
|
|
1525
|
+
})) : o.kind === "rich-link" ? i.push(Tn({
|
|
1228
1526
|
kind: "rich-link",
|
|
1229
1527
|
label: o.label,
|
|
1230
1528
|
detail: o.detail ?? "",
|
|
1231
1529
|
href: o.detail ?? "",
|
|
1232
1530
|
metadata: o.metadata
|
|
1233
|
-
})) : o.kind === "link" ? i.push(
|
|
1531
|
+
})) : o.kind === "link" ? i.push(xn(o.label, [Sn(o.detail ?? "")])) : i.push(...pn(e.text.slice(o.range.start, o.range.end), t, n, r.commandTriggers, r.mentionTriggers)), a = o.range.end;
|
|
1234
1532
|
}
|
|
1235
|
-
return a < e.text.length && i.push(...
|
|
1533
|
+
return a < e.text.length && i.push(...pn(e.text.slice(a), t, n, r.commandTriggers, r.mentionTriggers)), yn(i);
|
|
1236
1534
|
}
|
|
1237
|
-
function
|
|
1535
|
+
function fn(e, t, n, r) {
|
|
1238
1536
|
let i = Ue({
|
|
1239
1537
|
text: e,
|
|
1240
1538
|
slashCommands: t,
|
|
1241
1539
|
commandTriggers: r.commandTriggers,
|
|
1242
1540
|
mentionCandidates: n
|
|
1243
1541
|
});
|
|
1244
|
-
return (i.elements?.length ?? 0) > 0 ?
|
|
1542
|
+
return (i.elements?.length ?? 0) > 0 ? dn(de({
|
|
1245
1543
|
initialDraft: i,
|
|
1246
1544
|
slashCommands: t,
|
|
1247
1545
|
commandTriggers: r.commandTriggers,
|
|
@@ -1250,39 +1548,39 @@ function Yt(e, t, n, r) {
|
|
|
1250
1548
|
type: "doc",
|
|
1251
1549
|
content: e.split("\n").map((e) => ({
|
|
1252
1550
|
type: "paragraph",
|
|
1253
|
-
content:
|
|
1551
|
+
content: pn(e, t, n, r.commandTriggers, r.mentionTriggers)
|
|
1254
1552
|
}))
|
|
1255
1553
|
};
|
|
1256
1554
|
}
|
|
1257
|
-
function
|
|
1258
|
-
return r(e).flatMap((e) => e.kind === "inline-code" || e.kind === "code-block" || e.kind === "link" || e.kind === "skill-link" ? [
|
|
1555
|
+
function pn(e, t, n, i, a) {
|
|
1556
|
+
return r(e).flatMap((e) => e.kind === "inline-code" || e.kind === "code-block" || e.kind === "link" || e.kind === "skill-link" ? [xn(e.source)] : mn(e.source, t, n, i, a));
|
|
1259
1557
|
}
|
|
1260
|
-
function
|
|
1261
|
-
let a = [], o =
|
|
1262
|
-
if (!o) return [
|
|
1558
|
+
function mn(e, t, n, r, i) {
|
|
1559
|
+
let a = [], o = le(r, i);
|
|
1560
|
+
if (!o) return [xn(e)];
|
|
1263
1561
|
let s = 0;
|
|
1264
1562
|
for (let r of e.matchAll(o)) {
|
|
1265
1563
|
let o = r.index ?? 0, c = r[0];
|
|
1266
1564
|
if (o === 0 || /\s/.test(e[o - 1] ?? "")) {
|
|
1267
|
-
if (o > s && a.push(
|
|
1268
|
-
let e = n.find((e) =>
|
|
1269
|
-
a.push(e ?
|
|
1565
|
+
if (o > s && a.push(xn(e.slice(s, o))), ue(c, i)) {
|
|
1566
|
+
let e = n.find((e) => Y(e) === c);
|
|
1567
|
+
a.push(e ? Cn(e) : xn(c));
|
|
1270
1568
|
} else {
|
|
1271
|
-
let e =
|
|
1272
|
-
a.push(e ?
|
|
1569
|
+
let e = G(c.replace(/^\//, ""), t);
|
|
1570
|
+
a.push(e ? xn(c, [{
|
|
1273
1571
|
type: "composerSlashCommand",
|
|
1274
1572
|
attrs: {
|
|
1275
1573
|
value: e.value,
|
|
1276
1574
|
detail: e.detail
|
|
1277
1575
|
}
|
|
1278
|
-
}]) :
|
|
1576
|
+
}]) : xn(c));
|
|
1279
1577
|
}
|
|
1280
1578
|
s = o + c.length;
|
|
1281
1579
|
}
|
|
1282
1580
|
}
|
|
1283
|
-
return s < e.length && a.push(
|
|
1581
|
+
return s < e.length && a.push(xn(e.slice(s))), a;
|
|
1284
1582
|
}
|
|
1285
|
-
function
|
|
1583
|
+
function hn(e, t, n, r, i, a) {
|
|
1286
1584
|
let o = {
|
|
1287
1585
|
text: "",
|
|
1288
1586
|
elements: [],
|
|
@@ -1290,8 +1588,8 @@ function Qt(e, t, n, r, i, a) {
|
|
|
1290
1588
|
imageAttachments: [],
|
|
1291
1589
|
pendingPastes: []
|
|
1292
1590
|
};
|
|
1293
|
-
|
|
1294
|
-
let s =
|
|
1591
|
+
gn(e, o, n);
|
|
1592
|
+
let s = de({
|
|
1295
1593
|
text: o.text,
|
|
1296
1594
|
slashCommands: n,
|
|
1297
1595
|
isTaskRunning: r,
|
|
@@ -1300,22 +1598,22 @@ function Qt(e, t, n, r, i, a) {
|
|
|
1300
1598
|
return {
|
|
1301
1599
|
...s,
|
|
1302
1600
|
cursor: a,
|
|
1303
|
-
elements:
|
|
1601
|
+
elements: fr([...s.elements, ...o.elements]),
|
|
1304
1602
|
mentionBindings: o.mentionBindings,
|
|
1305
1603
|
imageAttachments: o.imageAttachments,
|
|
1306
1604
|
remoteImages: t,
|
|
1307
1605
|
pendingPastes: o.pendingPastes
|
|
1308
1606
|
};
|
|
1309
1607
|
}
|
|
1310
|
-
function
|
|
1608
|
+
function gn(e, t, n) {
|
|
1311
1609
|
if (e.type === "doc") {
|
|
1312
1610
|
e.content?.forEach((e, r) => {
|
|
1313
|
-
r > 0 && t.text.length > 0 && (t.text += "\n"),
|
|
1611
|
+
r > 0 && t.text.length > 0 && (t.text += "\n"), gn(e, t, n);
|
|
1314
1612
|
});
|
|
1315
1613
|
return;
|
|
1316
1614
|
}
|
|
1317
1615
|
if (e.type === "paragraph") {
|
|
1318
|
-
e.content?.forEach((e) =>
|
|
1616
|
+
e.content?.forEach((e) => gn(e, t, n));
|
|
1319
1617
|
return;
|
|
1320
1618
|
}
|
|
1321
1619
|
if (e.type === "hardBreak") {
|
|
@@ -1326,7 +1624,7 @@ function $t(e, t, n) {
|
|
|
1326
1624
|
let r = e.text ?? "", i = t.text.length;
|
|
1327
1625
|
t.text += r;
|
|
1328
1626
|
for (let a of e.marks ?? []) if (a.type === "link" && a.attrs?.href && t.elements.push({
|
|
1329
|
-
id:
|
|
1627
|
+
id: wr("link", r, i),
|
|
1330
1628
|
kind: "link",
|
|
1331
1629
|
label: r,
|
|
1332
1630
|
range: {
|
|
@@ -1335,10 +1633,10 @@ function $t(e, t, n) {
|
|
|
1335
1633
|
},
|
|
1336
1634
|
detail: String(a.attrs.href)
|
|
1337
1635
|
}), a.type === "composerSlashCommand") {
|
|
1338
|
-
let e =
|
|
1636
|
+
let e = G(r.replace(/^\//, ""), n);
|
|
1339
1637
|
if (!e) continue;
|
|
1340
1638
|
t.elements.push({
|
|
1341
|
-
id:
|
|
1639
|
+
id: wr("slash-command", r, i),
|
|
1342
1640
|
kind: "slash-command",
|
|
1343
1641
|
label: r,
|
|
1344
1642
|
range: {
|
|
@@ -1351,7 +1649,7 @@ function $t(e, t, n) {
|
|
|
1351
1649
|
return;
|
|
1352
1650
|
}
|
|
1353
1651
|
if (e.type === "composerMention") {
|
|
1354
|
-
let n = String(e.attrs?.label ?? "") || `${String(e.attrs?.trigger ?? "")}${String(e.attrs?.value ?? "")}`, r = t.text.length, i = String(e.attrs?.id ??
|
|
1652
|
+
let n = String(e.attrs?.label ?? "") || `${String(e.attrs?.trigger ?? "")}${String(e.attrs?.value ?? "")}`, r = t.text.length, i = String(e.attrs?.id ?? wr("mention", n, r));
|
|
1355
1653
|
t.text += n, t.elements.push({
|
|
1356
1654
|
id: i,
|
|
1357
1655
|
kind: "mention",
|
|
@@ -1373,11 +1671,11 @@ function $t(e, t, n) {
|
|
|
1373
1671
|
return;
|
|
1374
1672
|
}
|
|
1375
1673
|
if (e.type === "composerAtom") {
|
|
1376
|
-
let n = String(e.attrs?.label ?? ""), r =
|
|
1674
|
+
let n = String(e.attrs?.label ?? ""), r = vn(e.attrs?.kind), i = t.text.length, a = String(e.attrs?.attachmentId ?? "");
|
|
1377
1675
|
if (r === "image" && !a) return;
|
|
1378
|
-
let o = r === "image" ? a :
|
|
1676
|
+
let o = r === "image" ? a : wr(r, n, i);
|
|
1379
1677
|
t.text += n;
|
|
1380
|
-
let s = r === "rich-link" ?
|
|
1678
|
+
let s = r === "rich-link" ? _n(e.attrs?.metadata) : void 0;
|
|
1381
1679
|
t.elements.push({
|
|
1382
1680
|
id: o,
|
|
1383
1681
|
kind: r,
|
|
@@ -1391,7 +1689,7 @@ function $t(e, t, n) {
|
|
|
1391
1689
|
}), r === "image" && t.imageAttachments.push({
|
|
1392
1690
|
id: o,
|
|
1393
1691
|
placeholder: n,
|
|
1394
|
-
media:
|
|
1692
|
+
media: Fe(e.attrs?.media)
|
|
1395
1693
|
}), r === "paste" && t.pendingPastes.push({
|
|
1396
1694
|
id: o,
|
|
1397
1695
|
placeholder: n,
|
|
@@ -1399,7 +1697,7 @@ function $t(e, t, n) {
|
|
|
1399
1697
|
});
|
|
1400
1698
|
}
|
|
1401
1699
|
}
|
|
1402
|
-
function
|
|
1700
|
+
function _n(e) {
|
|
1403
1701
|
if (!e || typeof e != "object") return;
|
|
1404
1702
|
let t = {};
|
|
1405
1703
|
for (let n of [
|
|
@@ -1415,7 +1713,7 @@ function en(e) {
|
|
|
1415
1713
|
}
|
|
1416
1714
|
return Object.keys(t).length > 0 ? t : void 0;
|
|
1417
1715
|
}
|
|
1418
|
-
function
|
|
1716
|
+
function vn(e) {
|
|
1419
1717
|
switch (e) {
|
|
1420
1718
|
case "slash-command":
|
|
1421
1719
|
case "mention":
|
|
@@ -1426,7 +1724,7 @@ function tn(e) {
|
|
|
1426
1724
|
default: return "paste";
|
|
1427
1725
|
}
|
|
1428
1726
|
}
|
|
1429
|
-
function
|
|
1727
|
+
function yn(e) {
|
|
1430
1728
|
return {
|
|
1431
1729
|
type: "doc",
|
|
1432
1730
|
content: [{
|
|
@@ -1435,13 +1733,13 @@ function nn(e) {
|
|
|
1435
1733
|
}]
|
|
1436
1734
|
};
|
|
1437
1735
|
}
|
|
1438
|
-
function
|
|
1736
|
+
function bn() {
|
|
1439
1737
|
return {
|
|
1440
1738
|
type: "doc",
|
|
1441
1739
|
content: [{ type: "paragraph" }]
|
|
1442
1740
|
};
|
|
1443
1741
|
}
|
|
1444
|
-
function
|
|
1742
|
+
function xn(e, t) {
|
|
1445
1743
|
return t && t.length > 0 ? {
|
|
1446
1744
|
type: "text",
|
|
1447
1745
|
text: e,
|
|
@@ -1451,29 +1749,29 @@ function Q(e, t) {
|
|
|
1451
1749
|
text: e
|
|
1452
1750
|
};
|
|
1453
1751
|
}
|
|
1454
|
-
function
|
|
1752
|
+
function Sn(e) {
|
|
1455
1753
|
return {
|
|
1456
1754
|
type: "link",
|
|
1457
1755
|
attrs: { href: e }
|
|
1458
1756
|
};
|
|
1459
1757
|
}
|
|
1460
|
-
function
|
|
1758
|
+
function Cn(e) {
|
|
1461
1759
|
return {
|
|
1462
1760
|
type: "composerMention",
|
|
1463
1761
|
attrs: {
|
|
1464
1762
|
id: e.id,
|
|
1465
1763
|
trigger: e.trigger,
|
|
1466
1764
|
value: e.value,
|
|
1467
|
-
label:
|
|
1765
|
+
label: Y(e),
|
|
1468
1766
|
detail: e.detail,
|
|
1469
1767
|
payload: e.payload,
|
|
1470
1768
|
persistsAs: e.persistsAs
|
|
1471
1769
|
}
|
|
1472
1770
|
};
|
|
1473
1771
|
}
|
|
1474
|
-
function
|
|
1772
|
+
function wn(e, t, n) {
|
|
1475
1773
|
let r = `${e.trigger}${e.value}`;
|
|
1476
|
-
return n.find((e) =>
|
|
1774
|
+
return n.find((e) => Y(e) === t.label || Y(e) === r) || {
|
|
1477
1775
|
id: e.id,
|
|
1478
1776
|
trigger: e.trigger,
|
|
1479
1777
|
value: e.value,
|
|
@@ -1483,7 +1781,7 @@ function sn(e, t, n) {
|
|
|
1483
1781
|
payload: e.payload
|
|
1484
1782
|
};
|
|
1485
1783
|
}
|
|
1486
|
-
function
|
|
1784
|
+
function Tn({ kind: e, label: t, detail: n = "", content: r = "", href: i = "", metadata: a }) {
|
|
1487
1785
|
return {
|
|
1488
1786
|
type: "composerAtom",
|
|
1489
1787
|
attrs: {
|
|
@@ -1496,7 +1794,7 @@ function cn({ kind: e, label: t, detail: n = "", content: r = "", href: i = "",
|
|
|
1496
1794
|
}
|
|
1497
1795
|
};
|
|
1498
1796
|
}
|
|
1499
|
-
function
|
|
1797
|
+
function En(e, t, n = "image") {
|
|
1500
1798
|
return {
|
|
1501
1799
|
type: "composerAtom",
|
|
1502
1800
|
attrs: {
|
|
@@ -1507,12 +1805,12 @@ function ln(e, t, n = "image") {
|
|
|
1507
1805
|
}
|
|
1508
1806
|
};
|
|
1509
1807
|
}
|
|
1510
|
-
function
|
|
1808
|
+
function Dn(e, t) {
|
|
1511
1809
|
let { selection: n } = e.state;
|
|
1512
1810
|
if (!n.empty) return null;
|
|
1513
1811
|
let r = n.$from, i = r.parent.textBetween(0, r.parentOffset, void 0, ""), a = r.parent.textBetween(r.parentOffset, r.parent.content.size, void 0, ""), o = [...t.commandTriggers, ...t.mentionTriggers];
|
|
1514
1812
|
if (o.length === 0) return null;
|
|
1515
|
-
let s =
|
|
1813
|
+
let s = On(i, a, o);
|
|
1516
1814
|
if (!s) return null;
|
|
1517
1815
|
let c = o.find((e) => s.token.startsWith(e));
|
|
1518
1816
|
return !c || s.token.slice(c.length).includes(c) ? null : {
|
|
@@ -1522,8 +1820,8 @@ function un(e, t) {
|
|
|
1522
1820
|
to: n.from + s.tail.length
|
|
1523
1821
|
};
|
|
1524
1822
|
}
|
|
1525
|
-
function
|
|
1526
|
-
let r = `(?:${
|
|
1823
|
+
function On(e, t, n) {
|
|
1824
|
+
let r = `(?:${q(n)})`, i = e.search(RegExp(`(?:^|\\s|\\ufffc)(${r}[^\\s\\ufffc]*)$`));
|
|
1527
1825
|
if (i === -1) return null;
|
|
1528
1826
|
let a = /[\s\ufffc]/.test(e[i] ?? "") ? i + 1 : i, o = t.match(/^[^\s\ufffc]*/)?.[0] ?? "";
|
|
1529
1827
|
return {
|
|
@@ -1532,16 +1830,16 @@ function dn(e, t, n) {
|
|
|
1532
1830
|
tail: o
|
|
1533
1831
|
};
|
|
1534
1832
|
}
|
|
1535
|
-
function
|
|
1536
|
-
let n =
|
|
1833
|
+
function kn(e, t) {
|
|
1834
|
+
let n = Un(e.state.doc.toJSON(), mr(t)), r = e.state.schema.nodes.composerAtom?.create({
|
|
1537
1835
|
kind: "paste",
|
|
1538
1836
|
label: n,
|
|
1539
|
-
detail: `${
|
|
1837
|
+
detail: `${mr(t)} chars`,
|
|
1540
1838
|
content: t
|
|
1541
1839
|
});
|
|
1542
1840
|
r && e.dispatch(e.state.tr.replaceSelectionWith(r).scrollIntoView());
|
|
1543
1841
|
}
|
|
1544
|
-
function
|
|
1842
|
+
function An(e) {
|
|
1545
1843
|
let t = e.dom.ownerDocument.getSelection();
|
|
1546
1844
|
if (t && t.rangeCount > 0 && !t.isCollapsed) {
|
|
1547
1845
|
let n = t.getRangeAt(0);
|
|
@@ -1550,7 +1848,7 @@ function pn(e) {
|
|
|
1550
1848
|
if (r !== i) return {
|
|
1551
1849
|
from: Math.min(r, i),
|
|
1552
1850
|
to: Math.max(r, i),
|
|
1553
|
-
selectedAtomLabels:
|
|
1851
|
+
selectedAtomLabels: jn(n, e.dom),
|
|
1554
1852
|
selectedText: t.toString()
|
|
1555
1853
|
};
|
|
1556
1854
|
}
|
|
@@ -1560,14 +1858,14 @@ function pn(e) {
|
|
|
1560
1858
|
to: e.state.selection.to
|
|
1561
1859
|
};
|
|
1562
1860
|
}
|
|
1563
|
-
function
|
|
1861
|
+
function jn(e, t) {
|
|
1564
1862
|
return Array.from(t.querySelectorAll("[data-composer-atom]")).filter((t) => e.intersectsNode(t)).map((e) => e.textContent ?? "").filter(Boolean);
|
|
1565
1863
|
}
|
|
1566
|
-
function
|
|
1567
|
-
let i =
|
|
1568
|
-
return e.dispatch(s.setSelection(
|
|
1864
|
+
function Mn(e, t, n, r) {
|
|
1865
|
+
let i = Nn(e.state.doc, t), a = Pn(e.state.doc, i.from, i.to) || n, o = e.state.schema.text(a, [r.create({ href: n })]), s = e.state.tr.replaceWith(i.from, i.to, o), c = i.from + a.length;
|
|
1866
|
+
return e.dispatch(s.setSelection(j.create(s.doc, c)).scrollIntoView()), !0;
|
|
1569
1867
|
}
|
|
1570
|
-
function
|
|
1868
|
+
function Nn(e, t) {
|
|
1571
1869
|
if (!t.selectedText && !t.selectedAtomLabels?.length) return t;
|
|
1572
1870
|
let n = {
|
|
1573
1871
|
from: t.from,
|
|
@@ -1590,7 +1888,7 @@ function gn(e, t) {
|
|
|
1590
1888
|
});
|
|
1591
1889
|
return n;
|
|
1592
1890
|
}
|
|
1593
|
-
function
|
|
1891
|
+
function Pn(e, t, n) {
|
|
1594
1892
|
let r = "";
|
|
1595
1893
|
return e.nodesBetween(t, n, (e, i) => {
|
|
1596
1894
|
if (e.isText) {
|
|
@@ -1600,119 +1898,119 @@ function _n(e, t, n) {
|
|
|
1600
1898
|
return e.type.name === "composerMention" ? (r += String(e.attrs.label ?? ""), !1) : e.type.name === "composerAtom" ? (e.attrs.kind === "rich-link" && (r += String(e.attrs.label ?? "")), !1) : e.type.name === "hardBreak" ? (r += "\n", !1) : !0;
|
|
1601
1899
|
}), r.replace(/\n+/g, " ").trim();
|
|
1602
1900
|
}
|
|
1603
|
-
function
|
|
1901
|
+
function Fn(e, t, n) {
|
|
1604
1902
|
let r = e.state.schema.marks.link;
|
|
1605
1903
|
if (!r) return !1;
|
|
1606
1904
|
let { from: i, to: a } = e.state.selection, o = e.state.tr.insertText(t, i, a);
|
|
1607
1905
|
return o.addMark(i, i + t.length, r.create({ href: n })), e.dispatch(o.scrollIntoView()), !0;
|
|
1608
1906
|
}
|
|
1609
|
-
function
|
|
1907
|
+
function In(e, t, n) {
|
|
1610
1908
|
e.dispatch(e.state.tr.replaceWith(n.from, n.to, e.state.schema.text(t)).scrollIntoView());
|
|
1611
1909
|
}
|
|
1612
|
-
function
|
|
1910
|
+
function Ln(e, t, n, r) {
|
|
1613
1911
|
let i = r(n);
|
|
1614
1912
|
if (i === null) return;
|
|
1615
|
-
let a = t +
|
|
1913
|
+
let a = t + Wn(e.state.doc.toJSON(), "image") + 1, o = Pe(n) ?? "image", s = e.state.schema.nodeFromJSON(En(i, Ie(o, a), o));
|
|
1616
1914
|
if (!s) return;
|
|
1617
1915
|
let c = e.state.tr.replaceSelectionWith(s);
|
|
1618
1916
|
c = c.insertText(" ", c.selection.from), e.dispatch(c.scrollIntoView());
|
|
1619
1917
|
}
|
|
1620
|
-
function
|
|
1621
|
-
let r =
|
|
1622
|
-
id:
|
|
1918
|
+
function Rn(e, t, n) {
|
|
1919
|
+
let r = gr(t), i = _r(r), a = `${n}${i}`, o = e.state.schema.nodes.composerMention?.create({
|
|
1920
|
+
id: wr("mention", a, e.state.selection.from),
|
|
1623
1921
|
trigger: n,
|
|
1624
1922
|
value: i,
|
|
1625
1923
|
label: a,
|
|
1626
|
-
detail:
|
|
1924
|
+
detail: vr(r) ? "directory" : "file",
|
|
1627
1925
|
payload: {
|
|
1628
1926
|
path: r,
|
|
1629
|
-
type:
|
|
1927
|
+
type: vr(r) ? "directory" : "file"
|
|
1630
1928
|
}
|
|
1631
1929
|
});
|
|
1632
1930
|
if (!o) return;
|
|
1633
1931
|
let s = e.state.tr.replaceSelectionWith(o);
|
|
1634
1932
|
s = s.insertText(" ", s.selection.from), e.dispatch(s.scrollIntoView());
|
|
1635
1933
|
}
|
|
1636
|
-
function
|
|
1934
|
+
function zn(e, t) {
|
|
1637
1935
|
let n = 0;
|
|
1638
|
-
return
|
|
1936
|
+
return Bn(e, (e) => e.type !== "composerAtom" || e.attrs?.kind !== "image" ? e : (n += 1, {
|
|
1639
1937
|
...e,
|
|
1640
1938
|
attrs: {
|
|
1641
1939
|
...e.attrs,
|
|
1642
|
-
label: Ie(
|
|
1940
|
+
label: Ie(Fe(e.attrs?.media), t + n)
|
|
1643
1941
|
}
|
|
1644
1942
|
}));
|
|
1645
1943
|
}
|
|
1646
|
-
function
|
|
1944
|
+
function Bn(e, t) {
|
|
1647
1945
|
let n = t(e);
|
|
1648
1946
|
return {
|
|
1649
1947
|
...n,
|
|
1650
|
-
content: n.content?.map((e) =>
|
|
1948
|
+
content: n.content?.map((e) => Bn(e, t))
|
|
1651
1949
|
};
|
|
1652
1950
|
}
|
|
1653
|
-
function
|
|
1654
|
-
return
|
|
1951
|
+
function Vn(e, t) {
|
|
1952
|
+
return Hn(e, (e) => e.type !== "composerAtom" || e.attrs?.kind !== "image" || e.attrs?.attachmentId !== t);
|
|
1655
1953
|
}
|
|
1656
|
-
function
|
|
1954
|
+
function Hn(e, t) {
|
|
1657
1955
|
return {
|
|
1658
1956
|
...e,
|
|
1659
|
-
content: e.content?.filter(t).map((e) =>
|
|
1957
|
+
content: e.content?.filter(t).map((e) => Hn(e, t))
|
|
1660
1958
|
};
|
|
1661
1959
|
}
|
|
1662
|
-
function
|
|
1960
|
+
function Un(e, t) {
|
|
1663
1961
|
let n = `[Pasted Content ${t} chars]`, r = /* @__PURE__ */ new Set();
|
|
1664
|
-
if (
|
|
1962
|
+
if (Gn(e, (e) => {
|
|
1665
1963
|
e.type === "composerAtom" && e.attrs?.kind === "paste" && r.add(String(e.attrs.label ?? ""));
|
|
1666
1964
|
}), !r.has(n)) return n;
|
|
1667
1965
|
let i = 2;
|
|
1668
1966
|
for (; r.has(`${n} #${i}`);) i += 1;
|
|
1669
1967
|
return `${n} #${i}`;
|
|
1670
1968
|
}
|
|
1671
|
-
function
|
|
1969
|
+
function Wn(e, t) {
|
|
1672
1970
|
let n = 0;
|
|
1673
|
-
return
|
|
1971
|
+
return Gn(e, (e) => {
|
|
1674
1972
|
e.type === "composerAtom" && e.attrs?.kind === t && (n += 1);
|
|
1675
1973
|
}), n;
|
|
1676
1974
|
}
|
|
1677
|
-
function
|
|
1678
|
-
t(e), e.content?.forEach((e) =>
|
|
1975
|
+
function Gn(e, t) {
|
|
1976
|
+
t(e), e.content?.forEach((e) => Gn(e, t));
|
|
1679
1977
|
}
|
|
1680
|
-
function
|
|
1978
|
+
function Kn(e) {
|
|
1681
1979
|
let { selection: t } = e.state, n = t.from;
|
|
1682
|
-
return
|
|
1980
|
+
return tr(e, n, t.empty ? t.$from.end() : t.to);
|
|
1683
1981
|
}
|
|
1684
|
-
function
|
|
1685
|
-
let { selection: t } = e.state, n = t.empty ?
|
|
1686
|
-
return
|
|
1982
|
+
function qn(e) {
|
|
1983
|
+
let { selection: t } = e.state, n = t.empty ? Zn(e, t.from) : t.from, r = t.to;
|
|
1984
|
+
return tr(e, n, r);
|
|
1687
1985
|
}
|
|
1688
|
-
function
|
|
1986
|
+
function Jn(e) {
|
|
1689
1987
|
let { selection: t } = e.state;
|
|
1690
|
-
if (!t.empty) return
|
|
1691
|
-
let n = t.$from.parent.textBetween(0, t.$from.parentOffset, void 0,
|
|
1692
|
-
return
|
|
1988
|
+
if (!t.empty) return tr(e, t.from, t.to);
|
|
1989
|
+
let n = t.$from.parent.textBetween(0, t.$from.parentOffset, void 0, nr), r = at(n, n.length);
|
|
1990
|
+
return tr(e, $n(t.$from.parent, t.$from.start(), r), t.from);
|
|
1693
1991
|
}
|
|
1694
|
-
function
|
|
1695
|
-
let t = e.state.selection.to, n =
|
|
1992
|
+
function Yn(e) {
|
|
1993
|
+
let t = e.state.selection.to, n = Qn(e, t), r = e.state.tr.setSelection(j.create(e.state.doc, n)).scrollIntoView();
|
|
1696
1994
|
e.view.dispatch(r), e.view.focus();
|
|
1697
1995
|
}
|
|
1698
|
-
function
|
|
1699
|
-
let { selection: n } = e.state, r = t === -1 ? n.from : n.to, i = e.state.doc.resolve(r), a = i.parent.textBetween(0, i.parent.content.size, void 0,
|
|
1996
|
+
function Xn(e, t) {
|
|
1997
|
+
let { selection: n } = e.state, r = t === -1 ? n.from : n.to, i = e.state.doc.resolve(r), a = i.parent.textBetween(0, i.parent.content.size, void 0, nr), o = i.parent.textBetween(0, i.parentOffset, void 0, nr).length, s = t === -1 ? at(a, o) : ot(a, o), c = $n(i.parent, i.start(), s), l = e.state.tr.setSelection(j.create(e.state.doc, c)).scrollIntoView();
|
|
1700
1998
|
e.view.dispatch(l), e.view.focus();
|
|
1701
1999
|
}
|
|
1702
|
-
function
|
|
2000
|
+
function Zn(e, t) {
|
|
1703
2001
|
let { selection: n } = e.state, r = n.$from.start();
|
|
1704
2002
|
return e.state.doc.nodesBetween(r, t, (e, t) => {
|
|
1705
2003
|
e.type.name === "hardBreak" && (r = t + e.nodeSize);
|
|
1706
2004
|
}), r;
|
|
1707
2005
|
}
|
|
1708
|
-
function
|
|
2006
|
+
function Qn(e, t) {
|
|
1709
2007
|
let n = e.state.doc.resolve(t).end();
|
|
1710
2008
|
return e.state.doc.nodesBetween(t, n, (e, r) => e.type.name === "hardBreak" && r >= t ? (n = r, !1) : !0), n;
|
|
1711
2009
|
}
|
|
1712
|
-
function
|
|
2010
|
+
function $n(e, t, n) {
|
|
1713
2011
|
let r = 0, i = t;
|
|
1714
2012
|
for (let t = 0; t < e.childCount; t += 1) {
|
|
1715
|
-
let a = e.child(t), o =
|
|
2013
|
+
let a = e.child(t), o = er(a);
|
|
1716
2014
|
if (o === null) {
|
|
1717
2015
|
i += a.nodeSize;
|
|
1718
2016
|
continue;
|
|
@@ -1723,13 +2021,13 @@ function In(e, t, n) {
|
|
|
1723
2021
|
}
|
|
1724
2022
|
return i;
|
|
1725
2023
|
}
|
|
1726
|
-
function
|
|
1727
|
-
return e.isText ? e.text ?? "" : e.type.name === "hardBreak" ? "\n" : e.type.name === "composerMention" || e.type.name === "composerAtom" ?
|
|
2024
|
+
function er(e) {
|
|
2025
|
+
return e.isText ? e.text ?? "" : e.type.name === "hardBreak" ? "\n" : e.type.name === "composerMention" || e.type.name === "composerAtom" ? nr(e) : null;
|
|
1728
2026
|
}
|
|
1729
|
-
function
|
|
2027
|
+
function tr(e, t, n) {
|
|
1730
2028
|
if (n <= t) return null;
|
|
1731
2029
|
let r = e.state.doc.slice(t, n), i = {
|
|
1732
|
-
text: e.state.doc.textBetween(t, n, "\n",
|
|
2030
|
+
text: e.state.doc.textBetween(t, n, "\n", nr),
|
|
1733
2031
|
slice: r.toJSON()
|
|
1734
2032
|
};
|
|
1735
2033
|
return e.chain().focus().deleteRange({
|
|
@@ -1737,10 +2035,10 @@ function Rn(e, t, n) {
|
|
|
1737
2035
|
to: n
|
|
1738
2036
|
}).run(), i;
|
|
1739
2037
|
}
|
|
1740
|
-
function
|
|
2038
|
+
function nr(e) {
|
|
1741
2039
|
return e.type.name === "composerMention" ? String(e.attrs.label ?? "") || `${String(e.attrs.trigger ?? "")}${String(e.attrs.value ?? "")}` : e.type.name === "composerAtom" ? String(e.attrs.label ?? "") : "";
|
|
1742
2040
|
}
|
|
1743
|
-
function
|
|
2041
|
+
function rr(e, t) {
|
|
1744
2042
|
let { selection: n } = e.state;
|
|
1745
2043
|
if (typeof t == "string") {
|
|
1746
2044
|
if (!n.empty) {
|
|
@@ -1750,60 +2048,60 @@ function Bn(e, t) {
|
|
|
1750
2048
|
e.chain().focus().insertContent(t).run();
|
|
1751
2049
|
return;
|
|
1752
2050
|
}
|
|
1753
|
-
let r =
|
|
2051
|
+
let r = re.fromJSON(e.state.schema, t.slice);
|
|
1754
2052
|
e.view.dispatch(e.state.tr.replaceSelection(r).scrollIntoView()), e.view.focus();
|
|
1755
2053
|
}
|
|
1756
|
-
function
|
|
2054
|
+
function ir(e, t) {
|
|
1757
2055
|
let { selection: n } = e.state;
|
|
1758
2056
|
if (!n.empty) return !1;
|
|
1759
2057
|
let r = n.$from, i = t === "Backspace" ? r.nodeBefore : r.nodeAfter;
|
|
1760
|
-
if (!i || !
|
|
2058
|
+
if (!i || !ar(i)) return !1;
|
|
1761
2059
|
let a = t === "Backspace" ? n.from - i.nodeSize : n.from, o = t === "Backspace" ? n.from : n.from + i.nodeSize;
|
|
1762
2060
|
return e.chain().focus().deleteRange({
|
|
1763
2061
|
from: a,
|
|
1764
2062
|
to: o
|
|
1765
2063
|
}).run(), !0;
|
|
1766
2064
|
}
|
|
1767
|
-
function
|
|
2065
|
+
function ar(e) {
|
|
1768
2066
|
return e.isAtom && (e.type.name === "composerMention" || e.type.name === "composerAtom");
|
|
1769
2067
|
}
|
|
1770
|
-
function
|
|
2068
|
+
function or(e) {
|
|
1771
2069
|
try {
|
|
1772
2070
|
return e.state.doc.textBetween(0, e.state.selection.from, "\n", "").length;
|
|
1773
2071
|
} catch {
|
|
1774
2072
|
return 0;
|
|
1775
2073
|
}
|
|
1776
2074
|
}
|
|
1777
|
-
function
|
|
1778
|
-
return e.state.selection.empty &&
|
|
2075
|
+
function sr(e) {
|
|
2076
|
+
return e.state.selection.empty && or(e) === 0;
|
|
1779
2077
|
}
|
|
1780
|
-
function
|
|
1781
|
-
return
|
|
2078
|
+
function cr(e, t) {
|
|
2079
|
+
return ue(e.persistedPrompt, t) ? "ParseSlash" : e.action;
|
|
1782
2080
|
}
|
|
1783
|
-
function
|
|
2081
|
+
function lr(e) {
|
|
1784
2082
|
return e.key === "ArrowUp" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "p";
|
|
1785
2083
|
}
|
|
1786
|
-
function
|
|
2084
|
+
function ur(e) {
|
|
1787
2085
|
return e.key === "ArrowDown" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "n";
|
|
1788
2086
|
}
|
|
1789
|
-
function
|
|
2087
|
+
function dr(e) {
|
|
1790
2088
|
return [...e].sort((e, t) => e.range.start - t.range.start);
|
|
1791
2089
|
}
|
|
1792
|
-
function
|
|
2090
|
+
function fr(e) {
|
|
1793
2091
|
let t = /* @__PURE__ */ new Map();
|
|
1794
2092
|
for (let n of e) t.set(`${n.kind}:${n.range.start}:${n.range.end}:${n.label}`, n);
|
|
1795
|
-
return
|
|
2093
|
+
return dr([...t.values()]);
|
|
1796
2094
|
}
|
|
1797
|
-
function
|
|
2095
|
+
function pr(e) {
|
|
1798
2096
|
return e.replace(/\r\n?/g, "\n");
|
|
1799
2097
|
}
|
|
1800
|
-
function
|
|
2098
|
+
function mr(e) {
|
|
1801
2099
|
return Array.from(e).length;
|
|
1802
2100
|
}
|
|
1803
|
-
function
|
|
2101
|
+
function hr(e) {
|
|
1804
2102
|
return e.startsWith("file://") || e.startsWith("/") || e.startsWith("./") || e.startsWith("../") || /^[A-Za-z]:[\\/]/.test(e);
|
|
1805
2103
|
}
|
|
1806
|
-
function
|
|
2104
|
+
function gr(e) {
|
|
1807
2105
|
let t = e.trim();
|
|
1808
2106
|
if (!t.startsWith("file://")) return t;
|
|
1809
2107
|
try {
|
|
@@ -1812,21 +2110,21 @@ function Qn(e) {
|
|
|
1812
2110
|
return t;
|
|
1813
2111
|
}
|
|
1814
2112
|
}
|
|
1815
|
-
function
|
|
2113
|
+
function _r(e) {
|
|
1816
2114
|
let t = e.replace(/[\\/]+$/, "").split(/[\\/]/).filter(Boolean).pop();
|
|
1817
2115
|
return t ? decodeURIComponent(t) : e;
|
|
1818
2116
|
}
|
|
1819
|
-
function
|
|
2117
|
+
function vr(e) {
|
|
1820
2118
|
return /[\\/]$/.test(e);
|
|
1821
2119
|
}
|
|
1822
|
-
function
|
|
2120
|
+
function yr(e) {
|
|
1823
2121
|
return e.split(/\r?\n/).map((e) => e.trim()).find((e) => e && !e.startsWith("#")) ?? "";
|
|
1824
2122
|
}
|
|
1825
|
-
function
|
|
1826
|
-
let t =
|
|
2123
|
+
function br(e) {
|
|
2124
|
+
let t = yr(e);
|
|
1827
2125
|
return t ? t.match(/^[\w.+-]+\/[\w.+-]+:[^:\n]+:(.+)$/)?.[1]?.trim() ?? t : "";
|
|
1828
2126
|
}
|
|
1829
|
-
function
|
|
2127
|
+
function xr(e) {
|
|
1830
2128
|
try {
|
|
1831
2129
|
let t = new URL(e);
|
|
1832
2130
|
return t.protocol === "http:" || t.protocol === "https:";
|
|
@@ -1834,69 +2132,69 @@ function rr(e) {
|
|
|
1834
2132
|
return !1;
|
|
1835
2133
|
}
|
|
1836
2134
|
}
|
|
1837
|
-
function
|
|
1838
|
-
return
|
|
2135
|
+
function Sr(e) {
|
|
2136
|
+
return Ge(e.trim());
|
|
1839
2137
|
}
|
|
1840
|
-
function
|
|
2138
|
+
function Cr(e, t) {
|
|
1841
2139
|
return (e % t + t) % t;
|
|
1842
2140
|
}
|
|
1843
|
-
function
|
|
2141
|
+
function wr(e, t, n) {
|
|
1844
2142
|
return `${e}:${n}:${t}`;
|
|
1845
2143
|
}
|
|
1846
2144
|
//#endregion
|
|
1847
2145
|
//#region src/lib/Composer.tsx
|
|
1848
|
-
function
|
|
2146
|
+
function Tr(e) {
|
|
1849
2147
|
let t = i(3), n = e.draftKey ?? "", r;
|
|
1850
|
-
return t[0] !== e || t[1] !== n ? (r = /* @__PURE__ */
|
|
2148
|
+
return t[0] !== e || t[1] !== n ? (r = /* @__PURE__ */ C(Dr, { ...e }, n), t[0] = e, t[1] = n, t[2] = r) : r = t[2], r;
|
|
1851
2149
|
}
|
|
1852
|
-
function
|
|
2150
|
+
function Er(e) {
|
|
1853
2151
|
return typeof e == "object" && !!e && "then" in e && typeof e.then == "function";
|
|
1854
2152
|
}
|
|
1855
|
-
function
|
|
1856
|
-
let
|
|
1857
|
-
signature:
|
|
1858
|
-
slashCommands:
|
|
1859
|
-
mentionCandidates:
|
|
1860
|
-
commandTriggers:
|
|
1861
|
-
mentionTriggers:
|
|
1862
|
-
}),
|
|
1863
|
-
|
|
1864
|
-
signature:
|
|
1865
|
-
slashCommands:
|
|
1866
|
-
mentionCandidates:
|
|
1867
|
-
commandTriggers:
|
|
1868
|
-
mentionTriggers:
|
|
2153
|
+
function Dr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r = !1, queueSubmissions: i = !1, hasInteracted: a = !1, maxExpandedTextChars: o, editorAriaLabel: u = "Rich prompt composer", className: d, children: f, dictation: p, validateSubmission: m, onSubmit: h, onStateChange: g }) {
|
|
2154
|
+
let x = c(), S = Mt(f), ee = y({
|
|
2155
|
+
signature: Nt(S),
|
|
2156
|
+
slashCommands: S.slashCommands,
|
|
2157
|
+
mentionCandidates: S.mentionCandidates,
|
|
2158
|
+
commandTriggers: S.commandTriggers,
|
|
2159
|
+
mentionTriggers: S.mentionTriggers
|
|
2160
|
+
}), te = Nt(S);
|
|
2161
|
+
te !== ee.current.signature && (ee.current = {
|
|
2162
|
+
signature: te,
|
|
2163
|
+
slashCommands: S.slashCommands,
|
|
2164
|
+
mentionCandidates: S.mentionCandidates,
|
|
2165
|
+
commandTriggers: S.commandTriggers,
|
|
2166
|
+
mentionTriggers: S.mentionTriggers
|
|
1869
2167
|
});
|
|
1870
|
-
let { slashCommands: T, mentionCandidates: E, commandTriggers: D, mentionTriggers:
|
|
2168
|
+
let { slashCommands: T, mentionCandidates: E, commandTriggers: D, mentionTriggers: O } = ee.current, k = v(() => ({
|
|
1871
2169
|
commandTriggers: D,
|
|
1872
|
-
mentionTriggers:
|
|
1873
|
-
}), [D,
|
|
1874
|
-
ne.current =
|
|
1875
|
-
let [re] =
|
|
2170
|
+
mentionTriggers: O
|
|
2171
|
+
}), [D, O]), ne = y(O);
|
|
2172
|
+
ne.current = O;
|
|
2173
|
+
let [re] = b(() => {
|
|
1876
2174
|
if (e) return e;
|
|
1877
2175
|
if (t === void 0) return;
|
|
1878
|
-
let n =
|
|
2176
|
+
let n = xt(t);
|
|
1879
2177
|
return n ? We({
|
|
1880
2178
|
source: n,
|
|
1881
2179
|
slashCommands: T,
|
|
1882
2180
|
mentionCandidates: E
|
|
1883
2181
|
}) : void 0;
|
|
1884
|
-
}),
|
|
2182
|
+
}), A = y(re?.remoteImages ?? []), j = y(un({
|
|
1885
2183
|
state: re,
|
|
1886
2184
|
slashCommands: T,
|
|
1887
2185
|
mentionCandidates: E,
|
|
1888
|
-
triggers:
|
|
1889
|
-
})),
|
|
1890
|
-
|
|
1891
|
-
|
|
2186
|
+
triggers: k
|
|
2187
|
+
})), M = y(0), N = y(!0);
|
|
2188
|
+
_(() => (N.current = !0, () => {
|
|
2189
|
+
N.current = !1;
|
|
1892
2190
|
}), []);
|
|
1893
|
-
let [
|
|
1894
|
-
extensions:
|
|
2191
|
+
let [P, F] = b(A.current), [I, L] = b(null), [R, z] = b(() => hn(j.current, A.current, T, r, i, 0)), B = y(R), V = y(P), H = y(I), U = y(null), W = y(null), G = y(void 0), K = y(null), ae = y(null), oe = y(null), se = y(g), q = y(m), ce = y(h), J = y(/* @__PURE__ */ new Map()), le = y(() => null), ue = y(() => void 0), Y = y(() => void 0), de = y(() => !1), X = s({
|
|
2192
|
+
extensions: v(() => tn({
|
|
1895
2193
|
getMentionTrigger: () => ne.current[0] ?? "@",
|
|
1896
|
-
getRemoteImageCount: () =>
|
|
1897
|
-
attachImageFile: (e) =>
|
|
2194
|
+
getRemoteImageCount: () => V.current.length,
|
|
2195
|
+
attachImageFile: (e) => le.current(e)
|
|
1898
2196
|
}), []),
|
|
1899
|
-
content:
|
|
2197
|
+
content: j.current,
|
|
1900
2198
|
editable: !n,
|
|
1901
2199
|
editorProps: {
|
|
1902
2200
|
attributes: {
|
|
@@ -1908,66 +2206,66 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
1908
2206
|
spellcheck: "false"
|
|
1909
2207
|
},
|
|
1910
2208
|
handleKeyDown(e, t) {
|
|
1911
|
-
return
|
|
2209
|
+
return de.current(t);
|
|
1912
2210
|
}
|
|
1913
2211
|
},
|
|
1914
2212
|
immediatelyRender: !1,
|
|
1915
2213
|
onUpdate({ editor: e }) {
|
|
1916
|
-
|
|
2214
|
+
ue.current(e), Y.current(e);
|
|
1917
2215
|
},
|
|
1918
2216
|
onSelectionUpdate({ editor: e }) {
|
|
1919
|
-
|
|
2217
|
+
ue.current(e), Y.current(e);
|
|
1920
2218
|
}
|
|
1921
|
-
}),
|
|
1922
|
-
|
|
2219
|
+
}), he = v(() => I ? Rt(I, T, E, a) : [], [
|
|
2220
|
+
I,
|
|
1923
2221
|
a,
|
|
1924
2222
|
E,
|
|
1925
2223
|
T
|
|
1926
|
-
]),
|
|
2224
|
+
]), ge = v(() => pe(R, T, D), [
|
|
1927
2225
|
D,
|
|
1928
|
-
|
|
2226
|
+
R,
|
|
1929
2227
|
T
|
|
1930
2228
|
]);
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
}, [
|
|
1934
|
-
|
|
1935
|
-
}, [
|
|
1936
|
-
|
|
1937
|
-
}, [
|
|
1938
|
-
|
|
2229
|
+
_(() => {
|
|
2230
|
+
B.current = R;
|
|
2231
|
+
}, [R]), _(() => {
|
|
2232
|
+
V.current = P;
|
|
2233
|
+
}, [P]), _(() => {
|
|
2234
|
+
H.current = I;
|
|
2235
|
+
}, [I]), _(() => {
|
|
2236
|
+
R.shortcutsOpen && (I || R.reverseSearch !== null || !fe(R)) && z((e) => e.shortcutsOpen ? {
|
|
1939
2237
|
...e,
|
|
1940
2238
|
shortcutsOpen: !1
|
|
1941
2239
|
} : e);
|
|
1942
|
-
}, [
|
|
1943
|
-
|
|
1944
|
-
}, [
|
|
1945
|
-
|
|
1946
|
-
}, [
|
|
1947
|
-
|
|
1948
|
-
}, [
|
|
1949
|
-
|
|
1950
|
-
}, [n,
|
|
1951
|
-
|
|
1952
|
-
}, [
|
|
1953
|
-
|
|
2240
|
+
}, [I, R]), _(() => {
|
|
2241
|
+
se.current = g;
|
|
2242
|
+
}, [g]), _(() => {
|
|
2243
|
+
q.current = m;
|
|
2244
|
+
}, [m]), _(() => {
|
|
2245
|
+
ce.current = h;
|
|
2246
|
+
}, [h]), _(() => {
|
|
2247
|
+
X && (X.setEditable(!n), X.view.dom.setAttribute("aria-disabled", n ? "true" : "false"), n && L(null));
|
|
2248
|
+
}, [n, X]), _(() => {
|
|
2249
|
+
X?.view.dom.setAttribute("aria-label", u);
|
|
2250
|
+
}, [X, u]), _(() => {
|
|
2251
|
+
se.current?.(R, ge), t !== void 0 && (ge ? St(t, Ve(R, ge.persistedPrompt)) : M.current === 0 && St(t, null));
|
|
1954
2252
|
}, [
|
|
1955
|
-
|
|
2253
|
+
R,
|
|
1956
2254
|
t,
|
|
1957
|
-
|
|
1958
|
-
]),
|
|
1959
|
-
|
|
2255
|
+
ge
|
|
2256
|
+
]), _(() => {
|
|
2257
|
+
z((e) => e.isTaskRunning === r && e.queueSubmissions === i ? e : {
|
|
1960
2258
|
...e,
|
|
1961
2259
|
isTaskRunning: r,
|
|
1962
2260
|
queueSubmissions: i
|
|
1963
2261
|
});
|
|
1964
|
-
}, [r, i]),
|
|
2262
|
+
}, [r, i]), ue.current = (e) => {
|
|
1965
2263
|
if (n) return;
|
|
1966
|
-
let t =
|
|
1967
|
-
|
|
1968
|
-
let n = o === void 0 ?
|
|
1969
|
-
|
|
1970
|
-
let r = e.shortcutsOpen &&
|
|
2264
|
+
let t = hn(e.getJSON(), V.current, T, r, i, or(e)), a = W.current, o = G.current;
|
|
2265
|
+
W.current = null, G.current = void 0, z((e) => {
|
|
2266
|
+
let n = o === void 0 ? K.current : o;
|
|
2267
|
+
K.current = n;
|
|
2268
|
+
let r = e.shortcutsOpen && fe(t);
|
|
1971
2269
|
return {
|
|
1972
2270
|
...t,
|
|
1973
2271
|
error: e.error,
|
|
@@ -1979,14 +2277,14 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
1979
2277
|
selectedRemoteImageId: a
|
|
1980
2278
|
};
|
|
1981
2279
|
});
|
|
1982
|
-
},
|
|
2280
|
+
}, Y.current = (e) => {
|
|
1983
2281
|
if (n) {
|
|
1984
|
-
|
|
2282
|
+
L(null);
|
|
1985
2283
|
return;
|
|
1986
2284
|
}
|
|
1987
|
-
let t =
|
|
2285
|
+
let t = Dn(e, k);
|
|
1988
2286
|
if (!t) {
|
|
1989
|
-
|
|
2287
|
+
L(null);
|
|
1990
2288
|
return;
|
|
1991
2289
|
}
|
|
1992
2290
|
if (D.includes(t.trigger)) {
|
|
@@ -1994,31 +2292,31 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
1994
2292
|
trigger: t.trigger,
|
|
1995
2293
|
query: t.query,
|
|
1996
2294
|
selectedIndex: 0
|
|
1997
|
-
}, n =
|
|
1998
|
-
|
|
2295
|
+
}, n = Rt(e, T, E, a);
|
|
2296
|
+
L((t) => n.length === 0 ? null : {
|
|
1999
2297
|
...e,
|
|
2000
2298
|
selectedIndex: t?.trigger === e.trigger ? Math.min(t.selectedIndex, n.length - 1) : 0
|
|
2001
2299
|
});
|
|
2002
2300
|
return;
|
|
2003
2301
|
}
|
|
2004
|
-
|
|
2302
|
+
L((e) => {
|
|
2005
2303
|
let n = t.trigger, r = {
|
|
2006
2304
|
trigger: n,
|
|
2007
2305
|
query: t.query,
|
|
2008
2306
|
selectedIndex: e?.trigger === n ? e.selectedIndex : 0
|
|
2009
|
-
}, i =
|
|
2307
|
+
}, i = Rt(r, T, E, a);
|
|
2010
2308
|
return {
|
|
2011
2309
|
...r,
|
|
2012
2310
|
selectedIndex: e?.trigger === n ? Math.min(e.selectedIndex, Math.max(i.length - 1, 0)) : 0
|
|
2013
2311
|
};
|
|
2014
2312
|
});
|
|
2015
2313
|
};
|
|
2016
|
-
function
|
|
2017
|
-
|
|
2314
|
+
function Z(e) {
|
|
2315
|
+
X?.commands.setContent(e), X && (ue.current(X), Y.current(X));
|
|
2018
2316
|
}
|
|
2019
|
-
function
|
|
2020
|
-
if (n || !
|
|
2021
|
-
let t =
|
|
2317
|
+
function ve(e) {
|
|
2318
|
+
if (n || !X) return;
|
|
2319
|
+
let t = Dn(X, k), r = [{
|
|
2022
2320
|
type: "text",
|
|
2023
2321
|
text: `${e.trigger}${e.value}`,
|
|
2024
2322
|
marks: [{
|
|
@@ -2032,168 +2330,168 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2032
2330
|
type: "text",
|
|
2033
2331
|
text: " "
|
|
2034
2332
|
}];
|
|
2035
|
-
t && t.trigger === e.trigger ?
|
|
2333
|
+
t && t.trigger === e.trigger ? X.chain().focus().deleteRange({
|
|
2036
2334
|
from: t.from,
|
|
2037
2335
|
to: t.to
|
|
2038
|
-
}).insertContent(r).run() :
|
|
2336
|
+
}).insertContent(r).run() : X.chain().focus().insertContent(r).run(), L(null);
|
|
2039
2337
|
}
|
|
2040
|
-
function
|
|
2041
|
-
let t =
|
|
2042
|
-
if (n || !
|
|
2043
|
-
let r =
|
|
2338
|
+
function ye({ index: e = H.current?.selectedIndex ?? 0 } = {}) {
|
|
2339
|
+
let t = H.current;
|
|
2340
|
+
if (n || !X || !t) return;
|
|
2341
|
+
let r = Rt(t, T, E, a), i = r[e] ?? r[0];
|
|
2044
2342
|
if (!i) return;
|
|
2045
2343
|
if (!i.atomic) {
|
|
2046
|
-
|
|
2344
|
+
ve(i);
|
|
2047
2345
|
return;
|
|
2048
2346
|
}
|
|
2049
|
-
let o =
|
|
2347
|
+
let o = Dn(X, k), s = o?.trigger === t.trigger, c = X.chain().focus();
|
|
2050
2348
|
s && o && c.deleteRange({
|
|
2051
2349
|
from: o.from,
|
|
2052
2350
|
to: o.to
|
|
2053
|
-
}), c.insertContent([
|
|
2351
|
+
}), c.insertContent([Cn(i), {
|
|
2054
2352
|
type: "text",
|
|
2055
2353
|
text: " "
|
|
2056
|
-
}]).run(),
|
|
2354
|
+
}]).run(), L(null);
|
|
2057
2355
|
}
|
|
2058
|
-
function
|
|
2059
|
-
if (n || !
|
|
2060
|
-
|
|
2356
|
+
function be() {
|
|
2357
|
+
if (n || !X) return;
|
|
2358
|
+
X.commands.focus();
|
|
2061
2359
|
let e = D[0];
|
|
2062
|
-
e &&
|
|
2360
|
+
e && L((t) => t?.trigger === e ? null : {
|
|
2063
2361
|
trigger: e,
|
|
2064
2362
|
query: "",
|
|
2065
2363
|
selectedIndex: 0
|
|
2066
2364
|
});
|
|
2067
2365
|
}
|
|
2068
|
-
function
|
|
2069
|
-
return
|
|
2366
|
+
function xe(e) {
|
|
2367
|
+
return fe(e) && e.reverseSearch === null && H.current === null;
|
|
2070
2368
|
}
|
|
2071
|
-
function
|
|
2072
|
-
n ||
|
|
2369
|
+
function Se() {
|
|
2370
|
+
n || z((e) => xe(e) && !e.shortcutsOpen ? {
|
|
2073
2371
|
...e,
|
|
2074
2372
|
shortcutsOpen: !0,
|
|
2075
2373
|
selectedRemoteImageId: null,
|
|
2076
2374
|
error: null
|
|
2077
2375
|
} : e);
|
|
2078
2376
|
}
|
|
2079
|
-
function
|
|
2080
|
-
|
|
2377
|
+
function Ce() {
|
|
2378
|
+
z((e) => e.shortcutsOpen ? {
|
|
2081
2379
|
...e,
|
|
2082
2380
|
shortcutsOpen: !1
|
|
2083
2381
|
} : e);
|
|
2084
2382
|
}
|
|
2085
|
-
function
|
|
2086
|
-
n ||
|
|
2383
|
+
function we() {
|
|
2384
|
+
n || z((e) => e.shortcutsOpen ? {
|
|
2087
2385
|
...e,
|
|
2088
2386
|
shortcutsOpen: !1
|
|
2089
|
-
} :
|
|
2387
|
+
} : xe(e) ? {
|
|
2090
2388
|
...e,
|
|
2091
2389
|
shortcutsOpen: !0,
|
|
2092
2390
|
selectedRemoteImageId: null,
|
|
2093
2391
|
error: null
|
|
2094
2392
|
} : e);
|
|
2095
2393
|
}
|
|
2096
|
-
function
|
|
2097
|
-
n || !
|
|
2394
|
+
function Te(e) {
|
|
2395
|
+
n || !X || !e || X.chain().focus().insertContent(e).run();
|
|
2098
2396
|
}
|
|
2099
|
-
function
|
|
2100
|
-
if (
|
|
2397
|
+
function Ee(e) {
|
|
2398
|
+
if (Pe(e) === null) return z((t) => ({
|
|
2101
2399
|
...t,
|
|
2102
2400
|
error: `Only image, video, or audio files can be attached: ${e.name || "unnamed file"}`,
|
|
2103
2401
|
shortcutsOpen: !1
|
|
2104
|
-
})),
|
|
2402
|
+
})), L(null), null;
|
|
2105
2403
|
let t = crypto.randomUUID();
|
|
2106
|
-
return
|
|
2404
|
+
return J.current.set(t, e), t;
|
|
2107
2405
|
}
|
|
2108
|
-
function
|
|
2109
|
-
let n =
|
|
2406
|
+
function De(e, t) {
|
|
2407
|
+
let n = Ee(t);
|
|
2110
2408
|
if (n === null) return;
|
|
2111
|
-
let r =
|
|
2112
|
-
e.chain().focus().insertContent([
|
|
2409
|
+
let r = $(), i = r.remoteImages.length + r.imageAttachments.length + 1, a = Pe(t) ?? "image";
|
|
2410
|
+
e.chain().focus().insertContent([En(n, Ie(a, i), a), {
|
|
2113
2411
|
type: "text",
|
|
2114
2412
|
text: " "
|
|
2115
2413
|
}]).run();
|
|
2116
2414
|
}
|
|
2117
|
-
function
|
|
2118
|
-
if (!(n || !
|
|
2415
|
+
function Oe(e) {
|
|
2416
|
+
if (!(n || !X)) for (let t of e) De(X, t);
|
|
2119
2417
|
}
|
|
2120
|
-
function
|
|
2121
|
-
n || !
|
|
2418
|
+
function ke(e) {
|
|
2419
|
+
n || !X || (J.current.delete(e), Z(zn(Vn(X.getJSON(), e), V.current.length)));
|
|
2122
2420
|
}
|
|
2123
|
-
function
|
|
2124
|
-
if (n || !
|
|
2125
|
-
let t = [...
|
|
2126
|
-
id:
|
|
2421
|
+
function Ae(e) {
|
|
2422
|
+
if (n || !X) return;
|
|
2423
|
+
let t = [...V.current, {
|
|
2424
|
+
id: wr("remote-image", e, x.Date.now()),
|
|
2127
2425
|
url: e
|
|
2128
2426
|
}];
|
|
2129
|
-
|
|
2427
|
+
V.current = t, F(t), Z(zn(X.getJSON(), t.length));
|
|
2130
2428
|
}
|
|
2131
|
-
function
|
|
2132
|
-
return n || !
|
|
2429
|
+
function je(e) {
|
|
2430
|
+
return n || !X ? !1 : ln(X.view, e, V.current.length, O[0] ?? "@", Ee);
|
|
2133
2431
|
}
|
|
2134
|
-
function
|
|
2432
|
+
function Me(e) {
|
|
2135
2433
|
if (n) return;
|
|
2136
|
-
let t =
|
|
2137
|
-
t && (
|
|
2434
|
+
let t = V.current[e] ?? B.current.remoteImages[e];
|
|
2435
|
+
t && (W.current = t.id, z((e) => ({
|
|
2138
2436
|
...e,
|
|
2139
2437
|
selectedRemoteImageId: t.id,
|
|
2140
2438
|
shortcutsOpen: !1
|
|
2141
2439
|
})));
|
|
2142
2440
|
}
|
|
2143
|
-
function
|
|
2144
|
-
n || (
|
|
2441
|
+
function Q() {
|
|
2442
|
+
n || (W.current = null, z((e) => e.selectedRemoteImageId ? {
|
|
2145
2443
|
...e,
|
|
2146
2444
|
selectedRemoteImageId: null,
|
|
2147
2445
|
shortcutsOpen: !1
|
|
2148
2446
|
} : e));
|
|
2149
2447
|
}
|
|
2150
|
-
function
|
|
2151
|
-
return
|
|
2448
|
+
function Ne(e) {
|
|
2449
|
+
return B.current.selectedRemoteImageId ? e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "Escape" || (e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a" ? (Q(), L(null), !0) : e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey ? (Q(), !0) : !1 : !1;
|
|
2152
2450
|
}
|
|
2153
|
-
function
|
|
2451
|
+
function Fe(e) {
|
|
2154
2452
|
if (n) return e.preventDefault(), !0;
|
|
2155
|
-
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") return e.preventDefault(),
|
|
2156
|
-
let t =
|
|
2157
|
-
if (!
|
|
2453
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "a") return e.preventDefault(), Q(), L(null), X?.commands.selectAll(), !0;
|
|
2454
|
+
let t = $(), r = B.current.selectedRemoteImageId;
|
|
2455
|
+
if (!H.current && e.key === "ArrowUp") {
|
|
2158
2456
|
let n = Re({
|
|
2159
2457
|
...t,
|
|
2160
2458
|
selectedRemoteImageId: r
|
|
2161
2459
|
}, r);
|
|
2162
|
-
if (n !== null) return e.preventDefault(),
|
|
2163
|
-
if ((
|
|
2460
|
+
if (n !== null) return e.preventDefault(), Me(Math.max(0, n - 1)), !0;
|
|
2461
|
+
if ((X && sr(X) || t.cursor === 0) && t.remoteImages.length > 0) return e.preventDefault(), Me(t.remoteImages.length - 1), !0;
|
|
2164
2462
|
}
|
|
2165
|
-
if (!
|
|
2463
|
+
if (!H.current && r && e.key === "ArrowDown") {
|
|
2166
2464
|
e.preventDefault();
|
|
2167
2465
|
let n = Re({
|
|
2168
2466
|
...t,
|
|
2169
2467
|
selectedRemoteImageId: r
|
|
2170
2468
|
}, r);
|
|
2171
|
-
return n !== null && n + 1 < t.remoteImages.length ?
|
|
2469
|
+
return n !== null && n + 1 < t.remoteImages.length ? Me(n + 1) : Q(), !0;
|
|
2172
2470
|
}
|
|
2173
|
-
return !
|
|
2471
|
+
return !H.current && r && (e.key === "Backspace" || e.key === "Delete") ? (e.preventDefault(), Le(r), !0) : (Ne(e), !1);
|
|
2174
2472
|
}
|
|
2175
|
-
function
|
|
2176
|
-
if (n || !
|
|
2177
|
-
let t =
|
|
2178
|
-
|
|
2473
|
+
function Le(e) {
|
|
2474
|
+
if (n || !X) return;
|
|
2475
|
+
let t = $(), r = t.remoteImages.findIndex((t) => t.id === e), i = t.remoteImages.filter((t) => t.id !== e), a = r === -1 ? null : i[r] ?? i[r - 1] ?? null;
|
|
2476
|
+
W.current = a?.id ?? null, V.current = i, F(i), Z(zn(X.getJSON(), i.length)), z((e) => ({
|
|
2179
2477
|
...e,
|
|
2180
2478
|
remoteImages: i,
|
|
2181
2479
|
selectedRemoteImageId: a?.id ?? null,
|
|
2182
2480
|
shortcutsOpen: !1
|
|
2183
2481
|
}));
|
|
2184
2482
|
}
|
|
2185
|
-
function
|
|
2186
|
-
if (n || !
|
|
2187
|
-
let t =
|
|
2188
|
-
|
|
2483
|
+
function ze(e) {
|
|
2484
|
+
if (n || !X) return;
|
|
2485
|
+
let t = Un(X.getJSON(), mr(e));
|
|
2486
|
+
X.chain().focus().insertContent(Tn({
|
|
2189
2487
|
kind: "paste",
|
|
2190
2488
|
label: t,
|
|
2191
|
-
detail: `${
|
|
2489
|
+
detail: `${mr(e)} chars`,
|
|
2192
2490
|
content: e
|
|
2193
2491
|
})).run();
|
|
2194
2492
|
}
|
|
2195
|
-
function
|
|
2196
|
-
n ||
|
|
2493
|
+
function Ue(e, t = e, r) {
|
|
2494
|
+
n || X?.chain().focus().insertContent(Tn({
|
|
2197
2495
|
kind: "rich-link",
|
|
2198
2496
|
label: t,
|
|
2199
2497
|
detail: e,
|
|
@@ -2201,38 +2499,45 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2201
2499
|
metadata: r
|
|
2202
2500
|
})).run();
|
|
2203
2501
|
}
|
|
2204
|
-
function
|
|
2205
|
-
return
|
|
2206
|
-
...
|
|
2207
|
-
error:
|
|
2208
|
-
history:
|
|
2209
|
-
historyCursor:
|
|
2210
|
-
killBuffer:
|
|
2211
|
-
reverseSearch:
|
|
2212
|
-
shortcutsOpen:
|
|
2213
|
-
selectedRemoteImageId:
|
|
2214
|
-
} :
|
|
2215
|
-
}
|
|
2216
|
-
function
|
|
2217
|
-
let t =
|
|
2218
|
-
return t ? (
|
|
2502
|
+
function $() {
|
|
2503
|
+
return X ? {
|
|
2504
|
+
...hn(X.getJSON(), V.current, T, r, i, or(X)),
|
|
2505
|
+
error: B.current.error,
|
|
2506
|
+
history: B.current.history,
|
|
2507
|
+
historyCursor: K.current ?? B.current.historyCursor,
|
|
2508
|
+
killBuffer: B.current.killBuffer,
|
|
2509
|
+
reverseSearch: B.current.reverseSearch,
|
|
2510
|
+
shortcutsOpen: B.current.shortcutsOpen,
|
|
2511
|
+
selectedRemoteImageId: B.current.selectedRemoteImageId
|
|
2512
|
+
} : B.current;
|
|
2513
|
+
}
|
|
2514
|
+
function Ge(e) {
|
|
2515
|
+
let t = q.current?.(e);
|
|
2516
|
+
return t ? (z((e) => ({
|
|
2219
2517
|
...e,
|
|
2220
2518
|
error: t,
|
|
2221
2519
|
shortcutsOpen: !1
|
|
2222
|
-
})),
|
|
2520
|
+
})), L(null), !0) : !1;
|
|
2521
|
+
}
|
|
2522
|
+
function Ke(e) {
|
|
2523
|
+
let t = $(), n = t.text.slice(0, t.cursor);
|
|
2524
|
+
Te(n && !/\s$/.test(n) ? ` ${e}` : e);
|
|
2525
|
+
}
|
|
2526
|
+
function qe() {
|
|
2527
|
+
ut?.endWithSend() || Je();
|
|
2223
2528
|
}
|
|
2224
2529
|
function Je() {
|
|
2225
2530
|
if (n) return;
|
|
2226
|
-
let e =
|
|
2531
|
+
let e = $(), r = X?.getJSON() ?? bn(), i = e.isTaskRunning || e.queueSubmissions, a = i ? null : _e(e.text, T, D);
|
|
2227
2532
|
if (a) {
|
|
2228
|
-
|
|
2533
|
+
z((e) => ({
|
|
2229
2534
|
...e,
|
|
2230
2535
|
error: `Unrecognized command: /${a}`,
|
|
2231
2536
|
shortcutsOpen: !1
|
|
2232
|
-
})),
|
|
2537
|
+
})), L(null);
|
|
2233
2538
|
return;
|
|
2234
2539
|
}
|
|
2235
|
-
let s =
|
|
2540
|
+
let s = pe(e, T, D), c = s ?? {
|
|
2236
2541
|
mode: "submitted",
|
|
2237
2542
|
prompt: "",
|
|
2238
2543
|
persistedPrompt: "",
|
|
@@ -2244,24 +2549,24 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2244
2549
|
elements: [],
|
|
2245
2550
|
payloadElements: [],
|
|
2246
2551
|
mentionBindings: []
|
|
2247
|
-
}, l =
|
|
2552
|
+
}, l = me(c, o);
|
|
2248
2553
|
if (l) {
|
|
2249
|
-
|
|
2554
|
+
z((e) => ({
|
|
2250
2555
|
...e,
|
|
2251
2556
|
error: l,
|
|
2252
2557
|
shortcutsOpen: !1
|
|
2253
|
-
})),
|
|
2558
|
+
})), L(null);
|
|
2254
2559
|
return;
|
|
2255
2560
|
}
|
|
2256
2561
|
let u = /* @__PURE__ */ new Map(), d = [];
|
|
2257
2562
|
for (let t of e.imageAttachments) {
|
|
2258
|
-
let e =
|
|
2563
|
+
let e = J.current.get(t.id);
|
|
2259
2564
|
if (!e) {
|
|
2260
|
-
|
|
2565
|
+
z((e) => ({
|
|
2261
2566
|
...e,
|
|
2262
2567
|
error: `Attached image is no longer available: ${t.placeholder}`,
|
|
2263
2568
|
shortcutsOpen: !1
|
|
2264
|
-
})),
|
|
2569
|
+
})), L(null);
|
|
2265
2570
|
return;
|
|
2266
2571
|
}
|
|
2267
2572
|
u.set(t.id, e), d.push({
|
|
@@ -2276,31 +2581,31 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2276
2581
|
...c.items.filter((e) => e.type !== "remote_image")
|
|
2277
2582
|
], p = {
|
|
2278
2583
|
id: crypto.randomUUID(),
|
|
2279
|
-
at: new Date(
|
|
2584
|
+
at: new Date(x.Date.now()).toLocaleTimeString(),
|
|
2280
2585
|
mode: i ? "queued" : c.mode,
|
|
2281
2586
|
prompt: c.prompt,
|
|
2282
2587
|
persistedPrompt: c.persistedPrompt,
|
|
2283
|
-
action: i ?
|
|
2588
|
+
action: i ? cr(c, D) : c.action,
|
|
2284
2589
|
command: c.command,
|
|
2285
2590
|
args: c.args,
|
|
2286
2591
|
items: f
|
|
2287
2592
|
};
|
|
2288
|
-
if (
|
|
2289
|
-
for (let e of u.keys())
|
|
2290
|
-
let m = Ve(e, c.persistedPrompt), h =
|
|
2291
|
-
|
|
2292
|
-
t !== void 0 &&
|
|
2593
|
+
if (Ge(p)) return;
|
|
2594
|
+
for (let e of u.keys()) J.current.delete(e);
|
|
2595
|
+
let m = Ve(e, c.persistedPrompt), h = ce.current?.(p, { editableSource: m });
|
|
2596
|
+
Er(h) && (M.current += 1, h.then(() => {
|
|
2597
|
+
t !== void 0 && St(t, null);
|
|
2293
2598
|
}).catch((e) => {
|
|
2294
|
-
for (let [e, t] of u)
|
|
2295
|
-
t !== void 0 &&
|
|
2599
|
+
for (let [e, t] of u) J.current.set(e, t);
|
|
2600
|
+
t !== void 0 && St(t, m), N.current && (Z(r), X?.commands.focus("end"), z((t) => ({
|
|
2296
2601
|
...t,
|
|
2297
2602
|
error: e instanceof Error ? e.message : "Could not send prompt"
|
|
2298
2603
|
})));
|
|
2299
2604
|
}).finally(() => {
|
|
2300
|
-
--
|
|
2605
|
+
--M.current;
|
|
2301
2606
|
}));
|
|
2302
2607
|
let g = s ? He(e, c.historyPrompt) : e.history;
|
|
2303
|
-
|
|
2608
|
+
K.current = null, V.current = [], F([]), L(null), Z(bn()), z((e) => ({
|
|
2304
2609
|
...e,
|
|
2305
2610
|
text: "",
|
|
2306
2611
|
cursor: 0,
|
|
@@ -2318,8 +2623,8 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2318
2623
|
}
|
|
2319
2624
|
function Ye() {
|
|
2320
2625
|
if (n) return;
|
|
2321
|
-
let e =
|
|
2322
|
-
|
|
2626
|
+
let e = B.current.history, t = B.current.killBuffer;
|
|
2627
|
+
K.current = null, oe.current = null, J.current.clear(), V.current = A.current, F(A.current), L(null), Z(j.current), X?.commands.focus("end"), z((n) => ({
|
|
2323
2628
|
...n,
|
|
2324
2629
|
history: e,
|
|
2325
2630
|
historyCursor: null,
|
|
@@ -2331,14 +2636,14 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2331
2636
|
}));
|
|
2332
2637
|
}
|
|
2333
2638
|
function Xe(e) {
|
|
2334
|
-
if (n || !
|
|
2335
|
-
let t =
|
|
2336
|
-
if (e > 0 && r === 0 &&
|
|
2337
|
-
Qe(
|
|
2639
|
+
if (n || !X || B.current.history.length === 0) return;
|
|
2640
|
+
let t = B.current, r = K.current ?? t.historyCursor;
|
|
2641
|
+
if (e > 0 && r === 0 && ae.current) {
|
|
2642
|
+
Qe(ae.current, null), ae.current = null;
|
|
2338
2643
|
return;
|
|
2339
2644
|
}
|
|
2340
|
-
let i = r === null ? e < 0 ? 0 : t.history.length - 1 :
|
|
2341
|
-
r === null && (
|
|
2645
|
+
let i = r === null ? e < 0 ? 0 : t.history.length - 1 : Cr(r + e, t.history.length);
|
|
2646
|
+
r === null && (ae.current = Be($()));
|
|
2342
2647
|
let a = t.history[i];
|
|
2343
2648
|
Ze(a, i);
|
|
2344
2649
|
}
|
|
@@ -2351,23 +2656,23 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2351
2656
|
}
|
|
2352
2657
|
function Qe(e, t) {
|
|
2353
2658
|
let n = e.remoteImages ?? [];
|
|
2354
|
-
|
|
2355
|
-
...
|
|
2659
|
+
V.current = n, B.current = {
|
|
2660
|
+
...B.current,
|
|
2356
2661
|
historyCursor: t,
|
|
2357
2662
|
shortcutsOpen: !1
|
|
2358
|
-
},
|
|
2663
|
+
}, K.current = t, G.current = t, F(n), Z(un({
|
|
2359
2664
|
state: e,
|
|
2360
2665
|
slashCommands: T,
|
|
2361
2666
|
mentionCandidates: E,
|
|
2362
|
-
triggers:
|
|
2363
|
-
})),
|
|
2667
|
+
triggers: k
|
|
2668
|
+
})), X?.commands.focus("end"), z((e) => ({
|
|
2364
2669
|
...e,
|
|
2365
2670
|
historyCursor: t,
|
|
2366
2671
|
shortcutsOpen: !1
|
|
2367
2672
|
}));
|
|
2368
2673
|
}
|
|
2369
2674
|
function $e() {
|
|
2370
|
-
n || (
|
|
2675
|
+
n || (L(null), K.current = null, oe.current = $(), z((e) => ({
|
|
2371
2676
|
...e,
|
|
2372
2677
|
reverseSearch: "",
|
|
2373
2678
|
historyCursor: null,
|
|
@@ -2380,11 +2685,11 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2380
2685
|
return;
|
|
2381
2686
|
}
|
|
2382
2687
|
if (e.preventDefault(), e.key === "Escape") {
|
|
2383
|
-
ot(null),
|
|
2688
|
+
ot(null), oe.current = null;
|
|
2384
2689
|
return;
|
|
2385
2690
|
}
|
|
2386
2691
|
if (e.key === "Enter") {
|
|
2387
|
-
|
|
2692
|
+
oe.current = null, z((e) => ({
|
|
2388
2693
|
...e,
|
|
2389
2694
|
reverseSearch: null,
|
|
2390
2695
|
shortcutsOpen: !1
|
|
@@ -2407,32 +2712,32 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2407
2712
|
}
|
|
2408
2713
|
function tt(e) {
|
|
2409
2714
|
if (n) return;
|
|
2410
|
-
let t =
|
|
2411
|
-
if (!
|
|
2715
|
+
let t = B.current, r = e(t.reverseSearch ?? ""), i = rt(t.history, r, null);
|
|
2716
|
+
if (!X || !i) {
|
|
2412
2717
|
ot(r);
|
|
2413
2718
|
return;
|
|
2414
2719
|
}
|
|
2415
2720
|
at(i.entry, i.index, r);
|
|
2416
2721
|
}
|
|
2417
2722
|
function nt(e) {
|
|
2418
|
-
if (n || !
|
|
2419
|
-
let t =
|
|
2723
|
+
if (n || !X) return;
|
|
2724
|
+
let t = B.current, r = t.reverseSearch ?? "", i = rt(t.history, r, t.historyCursor, e);
|
|
2420
2725
|
i && at(i.entry, i.index, r);
|
|
2421
2726
|
}
|
|
2422
2727
|
function at(e, t, n) {
|
|
2423
|
-
let r =
|
|
2728
|
+
let r = X;
|
|
2424
2729
|
if (!r) return;
|
|
2425
2730
|
let i = We({
|
|
2426
2731
|
source: e,
|
|
2427
2732
|
slashCommands: T,
|
|
2428
2733
|
mentionCandidates: E
|
|
2429
2734
|
}), a = i.remoteImages ?? [];
|
|
2430
|
-
|
|
2735
|
+
V.current = a, F(a), Z(un({
|
|
2431
2736
|
state: i,
|
|
2432
2737
|
slashCommands: T,
|
|
2433
2738
|
mentionCandidates: E,
|
|
2434
|
-
triggers:
|
|
2435
|
-
})), r.commands.focus("end"),
|
|
2739
|
+
triggers: k
|
|
2740
|
+
})), r.commands.focus("end"), z((e) => ({
|
|
2436
2741
|
...e,
|
|
2437
2742
|
historyCursor: t,
|
|
2438
2743
|
reverseSearch: n,
|
|
@@ -2442,9 +2747,9 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2442
2747
|
}
|
|
2443
2748
|
function ot(e) {
|
|
2444
2749
|
if (n) return;
|
|
2445
|
-
let t =
|
|
2446
|
-
if (!t || !
|
|
2447
|
-
|
|
2750
|
+
let t = oe.current;
|
|
2751
|
+
if (!t || !X) {
|
|
2752
|
+
z((t) => ({
|
|
2448
2753
|
...t,
|
|
2449
2754
|
reverseSearch: e,
|
|
2450
2755
|
shortcutsOpen: !1
|
|
@@ -2453,269 +2758,278 @@ function lr({ initialDraft: e, draftKey: t, disabled: n = !1, isTaskRunning: r =
|
|
|
2453
2758
|
}
|
|
2454
2759
|
let r = {
|
|
2455
2760
|
...t,
|
|
2456
|
-
history:
|
|
2457
|
-
killBuffer:
|
|
2761
|
+
history: B.current.history,
|
|
2762
|
+
killBuffer: B.current.killBuffer,
|
|
2458
2763
|
reverseSearch: e,
|
|
2459
2764
|
historyCursor: null,
|
|
2460
2765
|
selectedRemoteImageId: null,
|
|
2461
2766
|
shortcutsOpen: !1
|
|
2462
2767
|
};
|
|
2463
|
-
|
|
2768
|
+
K.current = null, V.current = r.remoteImages, F(r.remoteImages), Z(un({
|
|
2464
2769
|
state: r,
|
|
2465
2770
|
slashCommands: T,
|
|
2466
2771
|
mentionCandidates: E,
|
|
2467
|
-
triggers:
|
|
2468
|
-
})),
|
|
2772
|
+
triggers: k
|
|
2773
|
+
})), X.commands.focus("end"), z(r);
|
|
2469
2774
|
}
|
|
2470
|
-
|
|
2775
|
+
de.current = n ? (e) => (e.preventDefault(), !0) : Fe, le.current = Ee;
|
|
2471
2776
|
function st(e) {
|
|
2472
2777
|
if (!(e.target instanceof Element) || !e.target.closest("[data-slot=\"composer-editor\"]")) return;
|
|
2473
2778
|
if (n) {
|
|
2474
2779
|
e.preventDefault();
|
|
2475
2780
|
return;
|
|
2476
2781
|
}
|
|
2477
|
-
if (!
|
|
2478
|
-
if (
|
|
2782
|
+
if (!X || Fe(e)) return;
|
|
2783
|
+
if (B.current.reverseSearch !== null) {
|
|
2479
2784
|
et(e);
|
|
2480
2785
|
return;
|
|
2481
2786
|
}
|
|
2482
|
-
if (
|
|
2483
|
-
e.preventDefault(),
|
|
2787
|
+
if (B.current.shortcutsOpen && e.key === "Escape") {
|
|
2788
|
+
e.preventDefault(), Ce();
|
|
2484
2789
|
return;
|
|
2485
2790
|
}
|
|
2486
|
-
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey &&
|
|
2487
|
-
e.preventDefault(),
|
|
2791
|
+
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey && xe($())) {
|
|
2792
|
+
e.preventDefault(), we();
|
|
2488
2793
|
return;
|
|
2489
2794
|
}
|
|
2490
|
-
if (
|
|
2491
|
-
e.preventDefault(),
|
|
2795
|
+
if (Xr(e)) {
|
|
2796
|
+
e.preventDefault(), X.chain().focus().setHardBreak().run(), K.current = null, L(null);
|
|
2492
2797
|
return;
|
|
2493
2798
|
}
|
|
2494
|
-
if (
|
|
2495
|
-
if (
|
|
2496
|
-
e.preventDefault(),
|
|
2799
|
+
if (H.current) {
|
|
2800
|
+
if (lr(e) || ur(e)) {
|
|
2801
|
+
e.preventDefault(), lt(lr(e) ? -1 : 1);
|
|
2497
2802
|
return;
|
|
2498
2803
|
}
|
|
2499
2804
|
if (e.key === "Tab") {
|
|
2500
|
-
e.preventDefault(),
|
|
2805
|
+
e.preventDefault(), ye();
|
|
2501
2806
|
return;
|
|
2502
2807
|
}
|
|
2503
2808
|
if (e.key === "Enter" && !e.shiftKey) {
|
|
2504
|
-
if (e.preventDefault(),
|
|
2505
|
-
|
|
2809
|
+
if (e.preventDefault(), he.length === 0) {
|
|
2810
|
+
L(null), qe();
|
|
2506
2811
|
return;
|
|
2507
2812
|
}
|
|
2508
|
-
|
|
2813
|
+
ye();
|
|
2509
2814
|
return;
|
|
2510
2815
|
}
|
|
2511
2816
|
if (e.key === "Escape") {
|
|
2512
|
-
e.preventDefault(),
|
|
2817
|
+
e.preventDefault(), L(null);
|
|
2513
2818
|
return;
|
|
2514
2819
|
}
|
|
2515
2820
|
}
|
|
2516
|
-
if (
|
|
2517
|
-
let t =
|
|
2518
|
-
t && (e.preventDefault(),
|
|
2821
|
+
if (Zr(e)) {
|
|
2822
|
+
let t = Jn(X);
|
|
2823
|
+
t && (e.preventDefault(), U.current = t, z((e) => ({
|
|
2519
2824
|
...e,
|
|
2520
2825
|
killBuffer: t.text
|
|
2521
|
-
}))),
|
|
2826
|
+
}))), K.current = null;
|
|
2522
2827
|
return;
|
|
2523
2828
|
}
|
|
2524
|
-
let t =
|
|
2829
|
+
let t = Qr(e);
|
|
2525
2830
|
if (t !== null) {
|
|
2526
|
-
e.preventDefault(),
|
|
2831
|
+
e.preventDefault(), Xn(X, t), K.current = null;
|
|
2527
2832
|
return;
|
|
2528
2833
|
}
|
|
2529
2834
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "e") {
|
|
2530
|
-
e.preventDefault(),
|
|
2835
|
+
e.preventDefault(), Yn(X), K.current = null;
|
|
2531
2836
|
return;
|
|
2532
2837
|
}
|
|
2533
2838
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "k") {
|
|
2534
|
-
let t =
|
|
2535
|
-
t && (e.preventDefault(),
|
|
2839
|
+
let t = Kn(X);
|
|
2840
|
+
t && (e.preventDefault(), U.current = t, z((e) => ({
|
|
2536
2841
|
...e,
|
|
2537
2842
|
killBuffer: t.text
|
|
2538
2843
|
})));
|
|
2539
2844
|
return;
|
|
2540
2845
|
}
|
|
2541
2846
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "u") {
|
|
2542
|
-
let t =
|
|
2543
|
-
t && (e.preventDefault(),
|
|
2847
|
+
let t = qn(X);
|
|
2848
|
+
t && (e.preventDefault(), U.current = t, z((e) => ({
|
|
2544
2849
|
...e,
|
|
2545
2850
|
killBuffer: t.text
|
|
2546
2851
|
})));
|
|
2547
2852
|
return;
|
|
2548
2853
|
}
|
|
2549
|
-
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "y" &&
|
|
2550
|
-
e.preventDefault(),
|
|
2854
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "y" && B.current.killBuffer) {
|
|
2855
|
+
e.preventDefault(), rr(X, U.current ?? B.current.killBuffer);
|
|
2551
2856
|
return;
|
|
2552
2857
|
}
|
|
2553
2858
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "r") {
|
|
2554
2859
|
e.preventDefault(), $e();
|
|
2555
2860
|
return;
|
|
2556
2861
|
}
|
|
2557
|
-
if ((e.key === "Backspace" || e.key === "Delete") &&
|
|
2558
|
-
e.preventDefault(),
|
|
2862
|
+
if ((e.key === "Backspace" || e.key === "Delete") && ei(X)) {
|
|
2863
|
+
e.preventDefault(), K.current = null, L(null);
|
|
2559
2864
|
return;
|
|
2560
2865
|
}
|
|
2561
|
-
if ((e.key === "Backspace" || e.key === "Delete") &&
|
|
2562
|
-
e.preventDefault(),
|
|
2866
|
+
if ((e.key === "Backspace" || e.key === "Delete") && ir(X, e.key)) {
|
|
2867
|
+
e.preventDefault(), K.current = null;
|
|
2563
2868
|
return;
|
|
2564
2869
|
}
|
|
2565
|
-
if ((e.key === "Backspace" || e.key === "Delete" || e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) && (
|
|
2566
|
-
e.preventDefault(),
|
|
2870
|
+
if ((e.key === "Backspace" || e.key === "Delete" || e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) && (K.current = null), e.key === "Enter" && !e.shiftKey && !e.altKey) {
|
|
2871
|
+
e.preventDefault(), qe();
|
|
2567
2872
|
return;
|
|
2568
2873
|
}
|
|
2569
|
-
let r =
|
|
2570
|
-
if (r !== null && !
|
|
2571
|
-
let t =
|
|
2572
|
-
if (e.key === "ArrowUp" && (
|
|
2573
|
-
e.preventDefault(),
|
|
2874
|
+
let r = $r(e);
|
|
2875
|
+
if (r !== null && !H.current) {
|
|
2876
|
+
let t = $();
|
|
2877
|
+
if (e.key === "ArrowUp" && (sr(X) || t.cursor === 0) && t.remoteImages.length > 0) {
|
|
2878
|
+
e.preventDefault(), Me(t.remoteImages.length - 1);
|
|
2574
2879
|
return;
|
|
2575
2880
|
}
|
|
2576
2881
|
it(t.text, t.cursor, r) && (e.preventDefault(), Xe(r));
|
|
2577
2882
|
}
|
|
2578
2883
|
}
|
|
2579
|
-
function
|
|
2884
|
+
function ct(e) {
|
|
2580
2885
|
if (n) {
|
|
2581
2886
|
e.preventDefault();
|
|
2582
2887
|
return;
|
|
2583
2888
|
}
|
|
2584
|
-
e.target instanceof Element && e.target.closest("[data-slot=\"composer-editor\"]") &&
|
|
2889
|
+
e.target instanceof Element && e.target.closest("[data-slot=\"composer-editor\"]") && Q();
|
|
2585
2890
|
}
|
|
2586
|
-
function
|
|
2587
|
-
n ||
|
|
2891
|
+
function lt(e) {
|
|
2892
|
+
n || L((t) => {
|
|
2588
2893
|
if (!t) return t;
|
|
2589
|
-
let n =
|
|
2894
|
+
let n = Rt(t, T, E, a).length;
|
|
2590
2895
|
return n === 0 ? t : {
|
|
2591
2896
|
...t,
|
|
2592
|
-
selectedIndex:
|
|
2897
|
+
selectedIndex: Cr(t.selectedIndex + e, n)
|
|
2593
2898
|
};
|
|
2594
2899
|
});
|
|
2595
2900
|
}
|
|
2596
|
-
|
|
2901
|
+
let ut = $t({
|
|
2902
|
+
dictation: p,
|
|
2903
|
+
disabled: n,
|
|
2904
|
+
insertTranscript: Ke,
|
|
2905
|
+
submitDraft: Je
|
|
2906
|
+
});
|
|
2907
|
+
return /* @__PURE__ */ C(ie, {
|
|
2597
2908
|
value: {
|
|
2598
|
-
state:
|
|
2909
|
+
state: R,
|
|
2599
2910
|
disabled: n,
|
|
2600
2911
|
commandTriggers: D,
|
|
2601
|
-
activePopup:
|
|
2602
|
-
suggestions:
|
|
2603
|
-
attachedImages:
|
|
2912
|
+
activePopup: I,
|
|
2913
|
+
suggestions: he,
|
|
2914
|
+
attachedImages: J.current,
|
|
2604
2915
|
actions: {
|
|
2605
|
-
acceptSuggestion:
|
|
2606
|
-
toggleSlashMenu:
|
|
2607
|
-
insertText:
|
|
2608
|
-
attachImageFiles:
|
|
2609
|
-
removeImageAttachment:
|
|
2610
|
-
addRemoteImage:
|
|
2611
|
-
handleDrop:
|
|
2612
|
-
insertPaste:
|
|
2613
|
-
insertRichLink:
|
|
2614
|
-
openShortcuts:
|
|
2615
|
-
closeShortcuts:
|
|
2616
|
-
toggleShortcuts:
|
|
2617
|
-
submit:
|
|
2916
|
+
acceptSuggestion: ye,
|
|
2917
|
+
toggleSlashMenu: be,
|
|
2918
|
+
insertText: Te,
|
|
2919
|
+
attachImageFiles: Oe,
|
|
2920
|
+
removeImageAttachment: ke,
|
|
2921
|
+
addRemoteImage: Ae,
|
|
2922
|
+
handleDrop: je,
|
|
2923
|
+
insertPaste: ze,
|
|
2924
|
+
insertRichLink: Ue,
|
|
2925
|
+
openShortcuts: Se,
|
|
2926
|
+
closeShortcuts: Ce,
|
|
2927
|
+
toggleShortcuts: we,
|
|
2928
|
+
submit: qe,
|
|
2618
2929
|
reset: Ye
|
|
2619
2930
|
},
|
|
2620
|
-
meta: { editor:
|
|
2931
|
+
meta: { editor: X }
|
|
2621
2932
|
},
|
|
2622
|
-
children: /* @__PURE__ */
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2933
|
+
children: /* @__PURE__ */ C(Bt, {
|
|
2934
|
+
value: ut?.api ?? null,
|
|
2935
|
+
children: /* @__PURE__ */ C("section", {
|
|
2936
|
+
"data-slot": "composer",
|
|
2937
|
+
className: l("border-border bg-card relative border font-[inherit]", d),
|
|
2938
|
+
children: /* @__PURE__ */ w("div", {
|
|
2939
|
+
onKeyDownCapture: st,
|
|
2940
|
+
onMouseDownCapture: ct,
|
|
2941
|
+
children: [f, S.hasLayoutChildren ? null : /* @__PURE__ */ C(Or, {})]
|
|
2942
|
+
})
|
|
2629
2943
|
})
|
|
2630
2944
|
})
|
|
2631
2945
|
});
|
|
2632
2946
|
}
|
|
2633
|
-
function
|
|
2947
|
+
function Or() {
|
|
2634
2948
|
let e = i(2), t;
|
|
2635
|
-
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */
|
|
2949
|
+
e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ C(Pr, {}), e[0] = t) : t = e[0];
|
|
2636
2950
|
let n;
|
|
2637
|
-
return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */
|
|
2951
|
+
return e[1] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ w(te, { children: [
|
|
2638
2952
|
t,
|
|
2639
|
-
/* @__PURE__ */
|
|
2640
|
-
/* @__PURE__ */
|
|
2641
|
-
/* @__PURE__ */
|
|
2642
|
-
/* @__PURE__ */
|
|
2643
|
-
/* @__PURE__ */
|
|
2953
|
+
/* @__PURE__ */ w(kr, { children: [
|
|
2954
|
+
/* @__PURE__ */ C(jr, {}),
|
|
2955
|
+
/* @__PURE__ */ C(F, {}),
|
|
2956
|
+
/* @__PURE__ */ C(Mr, {}),
|
|
2957
|
+
/* @__PURE__ */ C(Nr, {})
|
|
2644
2958
|
] }),
|
|
2645
|
-
/* @__PURE__ */
|
|
2646
|
-
/* @__PURE__ */
|
|
2959
|
+
/* @__PURE__ */ C(Rr, {}),
|
|
2960
|
+
/* @__PURE__ */ C(Vr, {})
|
|
2647
2961
|
] }), e[1] = n) : n = e[1], n;
|
|
2648
2962
|
}
|
|
2649
|
-
function
|
|
2963
|
+
function kr(e) {
|
|
2650
2964
|
let t = i(8), n, r;
|
|
2651
2965
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2652
2966
|
let a;
|
|
2653
2967
|
t[3] === n ? a = t[4] : (a = l("space-y-2", n), t[3] = n, t[4] = a);
|
|
2654
2968
|
let o;
|
|
2655
|
-
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */
|
|
2969
|
+
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ C("div", {
|
|
2656
2970
|
className: a,
|
|
2657
2971
|
...r
|
|
2658
2972
|
}), t[5] = r, t[6] = a, t[7] = o) : o = t[7], o;
|
|
2659
2973
|
}
|
|
2660
|
-
function
|
|
2974
|
+
function Ar(e) {
|
|
2661
2975
|
let t = i(8), n, r;
|
|
2662
2976
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2663
2977
|
let a;
|
|
2664
2978
|
t[3] === n ? a = t[4] : (a = l("flex flex-wrap items-center gap-1.5", n), t[3] = n, t[4] = a);
|
|
2665
2979
|
let o;
|
|
2666
|
-
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */
|
|
2980
|
+
return t[5] !== r || t[6] !== a ? (o = /* @__PURE__ */ C("div", {
|
|
2667
2981
|
className: a,
|
|
2668
2982
|
...r
|
|
2669
2983
|
}), t[5] = r, t[6] = a, t[7] = o) : o = t[7], o;
|
|
2670
2984
|
}
|
|
2671
|
-
function
|
|
2985
|
+
function jr(e) {
|
|
2672
2986
|
let t = i(14), n, r;
|
|
2673
2987
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2674
|
-
let { state: a } =
|
|
2988
|
+
let { state: a } = N("Composer.RemoteImages");
|
|
2675
2989
|
if (a.remoteImages.length === 0) return null;
|
|
2676
2990
|
let o;
|
|
2677
2991
|
t[3] === n ? o = t[4] : (o = l("border-border space-y-1 border-b pb-2 text-sm", n), t[3] = n, t[4] = o);
|
|
2678
2992
|
let s;
|
|
2679
2993
|
if (t[5] !== a.remoteImages || t[6] !== a.selectedRemoteImageId) {
|
|
2680
2994
|
let e;
|
|
2681
|
-
t[8] === a.selectedRemoteImageId ? e = t[9] : (e = (e, t) => /* @__PURE__ */
|
|
2995
|
+
t[8] === a.selectedRemoteImageId ? e = t[9] : (e = (e, t) => /* @__PURE__ */ w("div", {
|
|
2682
2996
|
className: l("flex h-6 items-center gap-2 rounded-sm px-2", a.selectedRemoteImageId === e.id ? "bg-primary text-primary-foreground" : "text-sky-500"),
|
|
2683
|
-
children: [/* @__PURE__ */
|
|
2997
|
+
children: [/* @__PURE__ */ w("span", {
|
|
2684
2998
|
className: "shrink-0",
|
|
2685
2999
|
children: [
|
|
2686
3000
|
"[Image #",
|
|
2687
3001
|
t + 1,
|
|
2688
3002
|
"]"
|
|
2689
3003
|
]
|
|
2690
|
-
}), /* @__PURE__ */
|
|
3004
|
+
}), /* @__PURE__ */ C("span", {
|
|
2691
3005
|
className: "truncate text-xs opacity-70",
|
|
2692
3006
|
children: e.url
|
|
2693
3007
|
})]
|
|
2694
3008
|
}, e.id), t[8] = a.selectedRemoteImageId, t[9] = e), s = a.remoteImages.map(e), t[5] = a.remoteImages, t[6] = a.selectedRemoteImageId, t[7] = s;
|
|
2695
3009
|
} else s = t[7];
|
|
2696
3010
|
let c;
|
|
2697
|
-
return t[10] !== r || t[11] !== o || t[12] !== s ? (c = /* @__PURE__ */
|
|
3011
|
+
return t[10] !== r || t[11] !== o || t[12] !== s ? (c = /* @__PURE__ */ C("div", {
|
|
2698
3012
|
className: o,
|
|
2699
3013
|
...r,
|
|
2700
3014
|
children: s
|
|
2701
3015
|
}), t[10] = r, t[11] = o, t[12] = s, t[13] = c) : c = t[13], c;
|
|
2702
3016
|
}
|
|
2703
|
-
function
|
|
3017
|
+
function Mr(e) {
|
|
2704
3018
|
let t = i(21), n, r, a, s;
|
|
2705
3019
|
t[0] === e ? (n = t[1], r = t[2], a = t[3], s = t[4]) : ({className: n, onDrop: r, placeholder: s, ...a} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = s);
|
|
2706
|
-
let c = s === void 0 ? "Type a message or / for commands" : s, { state: l, disabled: u, meta: d, actions: f } =
|
|
3020
|
+
let c = s === void 0 ? "Type a message or / for commands" : s, { state: l, disabled: u, meta: d, actions: f } = N("Composer.Editor"), p = u ? "" : void 0, m;
|
|
2707
3021
|
t[5] !== f || t[6] !== r ? (m = (e) => {
|
|
2708
3022
|
r?.(e), !e.defaultPrevented && f.handleDrop(e.dataTransfer) && e.preventDefault();
|
|
2709
3023
|
}, t[5] = f, t[6] = r, t[7] = m) : m = t[7];
|
|
2710
3024
|
let h;
|
|
2711
|
-
t[8] !== c || t[9] !== l.text.length ? (h = l.text.length === 0 ? /* @__PURE__ */
|
|
3025
|
+
t[8] !== c || t[9] !== l.text.length ? (h = l.text.length === 0 ? /* @__PURE__ */ C("div", {
|
|
2712
3026
|
"data-slot": "composer-placeholder",
|
|
2713
3027
|
children: c
|
|
2714
3028
|
}) : null, t[8] = c, t[9] = l.text.length, t[10] = h) : h = t[10];
|
|
2715
3029
|
let g;
|
|
2716
|
-
t[11] === d.editor ? g = t[12] : (g = /* @__PURE__ */
|
|
3030
|
+
t[11] === d.editor ? g = t[12] : (g = /* @__PURE__ */ C(o, { editor: d.editor }), t[11] = d.editor, t[12] = g);
|
|
2717
3031
|
let _;
|
|
2718
|
-
return t[13] !== n || t[14] !== u || t[15] !== a || t[16] !== p || t[17] !== m || t[18] !== h || t[19] !== g ? (_ = /* @__PURE__ */
|
|
3032
|
+
return t[13] !== n || t[14] !== u || t[15] !== a || t[16] !== p || t[17] !== m || t[18] !== h || t[19] !== g ? (_ = /* @__PURE__ */ w("div", {
|
|
2719
3033
|
"data-slot": "composer-frame",
|
|
2720
3034
|
className: n,
|
|
2721
3035
|
"aria-disabled": u,
|
|
@@ -2725,111 +3039,112 @@ function mr(e) {
|
|
|
2725
3039
|
children: [h, g]
|
|
2726
3040
|
}), t[13] = n, t[14] = u, t[15] = a, t[16] = p, t[17] = m, t[18] = h, t[19] = g, t[20] = _) : _ = t[20], _;
|
|
2727
3041
|
}
|
|
2728
|
-
function
|
|
3042
|
+
function Nr(e) {
|
|
2729
3043
|
let t = i(9), n, r;
|
|
2730
3044
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2731
|
-
let { state: a } =
|
|
3045
|
+
let { state: a } = N("Composer.Error");
|
|
2732
3046
|
if (!a.error) return null;
|
|
2733
3047
|
let o;
|
|
2734
3048
|
t[3] === n ? o = t[4] : (o = l("border-primary/30 bg-primary/10 text-primary rounded-md border px-3 py-2 text-xs", n), t[3] = n, t[4] = o);
|
|
2735
3049
|
let s;
|
|
2736
|
-
return t[5] !== r || t[6] !== a.error || t[7] !== o ? (s = /* @__PURE__ */
|
|
3050
|
+
return t[5] !== r || t[6] !== a.error || t[7] !== o ? (s = /* @__PURE__ */ C("div", {
|
|
3051
|
+
role: "alert",
|
|
2737
3052
|
className: o,
|
|
2738
3053
|
...r,
|
|
2739
3054
|
children: a.error
|
|
2740
3055
|
}), t[5] = r, t[6] = a.error, t[7] = o, t[8] = s) : s = t[8], s;
|
|
2741
3056
|
}
|
|
2742
|
-
function
|
|
3057
|
+
function Pr(e) {
|
|
2743
3058
|
let t = i(25), n, r;
|
|
2744
3059
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2745
|
-
let { activePopup: a, suggestions: o, actions: s } =
|
|
3060
|
+
let { activePopup: a, suggestions: o, actions: s } = N("Composer.Popup"), { acceptSuggestion: c } = s;
|
|
2746
3061
|
if (!a) return null;
|
|
2747
3062
|
let u;
|
|
2748
|
-
t[3] === o ? u = t[4] : (u = o.some(
|
|
3063
|
+
t[3] === o ? u = t[4] : (u = o.some(Fr), t[3] = o, t[4] = u);
|
|
2749
3064
|
let d = u, f;
|
|
2750
3065
|
t[5] === n ? f = t[6] : (f = l("border-border bg-popover absolute inset-x-0 bottom-[calc(100%+0.5rem)] z-10 rounded-xl border shadow-lg", n), t[5] = n, t[6] = f);
|
|
2751
3066
|
let p;
|
|
2752
3067
|
if (t[7] !== c || t[8] !== a || t[9] !== o || t[10] !== d) {
|
|
2753
3068
|
let e;
|
|
2754
|
-
t[12] !== c || t[13] !== a || t[14] !== d ? (e = (e, t) => /* @__PURE__ */
|
|
3069
|
+
t[12] !== c || t[13] !== a || t[14] !== d ? (e = (e, t) => /* @__PURE__ */ C(Ir, {
|
|
2755
3070
|
selected: t === a.selectedIndex,
|
|
2756
3071
|
icon: d ? e.icon : null,
|
|
2757
|
-
token:
|
|
3072
|
+
token: Y(e),
|
|
2758
3073
|
takesArgs: e.supportsArgs === !0,
|
|
2759
3074
|
description: e.detail,
|
|
2760
3075
|
onMouseDown: () => c({ index: t })
|
|
2761
3076
|
}, `item:${e.id}`), t[12] = c, t[13] = a, t[14] = d, t[15] = e) : e = t[15], p = o.map(e), t[7] = c, t[8] = a, t[9] = o, t[10] = d, t[11] = p;
|
|
2762
3077
|
} else p = t[11];
|
|
2763
3078
|
let m;
|
|
2764
|
-
t[16] === o.length ? m = t[17] : (m = o.length === 0 ? /* @__PURE__ */
|
|
3079
|
+
t[16] === o.length ? m = t[17] : (m = o.length === 0 ? /* @__PURE__ */ C("div", {
|
|
2765
3080
|
className: "text-muted-foreground px-2 py-1 text-[13px] leading-4",
|
|
2766
3081
|
children: "no matches"
|
|
2767
3082
|
}) : null, t[16] = o.length, t[17] = m);
|
|
2768
3083
|
let h;
|
|
2769
|
-
t[18] !== p || t[19] !== m ? (h = /* @__PURE__ */
|
|
3084
|
+
t[18] !== p || t[19] !== m ? (h = /* @__PURE__ */ w("div", {
|
|
2770
3085
|
className: "flex max-h-72 flex-col gap-1 overflow-y-auto p-1",
|
|
2771
3086
|
role: "listbox",
|
|
2772
3087
|
"aria-label": "Suggestions",
|
|
2773
3088
|
children: [p, m]
|
|
2774
3089
|
}), t[18] = p, t[19] = m, t[20] = h) : h = t[20];
|
|
2775
3090
|
let g;
|
|
2776
|
-
return t[21] !== r || t[22] !== f || t[23] !== h ? (g = /* @__PURE__ */
|
|
3091
|
+
return t[21] !== r || t[22] !== f || t[23] !== h ? (g = /* @__PURE__ */ C("div", {
|
|
2777
3092
|
className: f,
|
|
2778
3093
|
...r,
|
|
2779
3094
|
children: h
|
|
2780
3095
|
}), t[21] = r, t[22] = f, t[23] = h, t[24] = g) : g = t[24], g;
|
|
2781
3096
|
}
|
|
2782
|
-
function
|
|
3097
|
+
function Fr(e) {
|
|
2783
3098
|
return e.icon;
|
|
2784
3099
|
}
|
|
2785
|
-
function
|
|
2786
|
-
let t = i(23), { selected: n, icon: r, token: a, takesArgs: o, description: s, onMouseDown: c } = e, u =
|
|
3100
|
+
function Ir(e) {
|
|
3101
|
+
let t = i(23), { selected: n, icon: r, token: a, takesArgs: o, description: s, onMouseDown: c } = e, u = y(null), d, f;
|
|
2787
3102
|
t[0] === n ? (d = t[1], f = t[2]) : (d = () => {
|
|
2788
3103
|
n && u.current?.scrollIntoView({ block: "nearest" });
|
|
2789
|
-
}, f = [n], t[0] = n, t[1] = d, t[2] = f),
|
|
3104
|
+
}, f = [n], t[0] = n, t[1] = d, t[2] = f), _(d, f);
|
|
2790
3105
|
let p = n ? "bg-accent text-foreground" : "text-foreground/80 hover:bg-accent/60", m;
|
|
2791
3106
|
t[3] === p ? m = t[4] : (m = l("flex w-full items-center gap-2 rounded-md px-2 py-1 text-start text-[13px] leading-4 [&_svg]:size-4 [&_svg]:shrink-0", p), t[3] = p, t[4] = m);
|
|
2792
|
-
let
|
|
2793
|
-
t[5] === c ?
|
|
3107
|
+
let h;
|
|
3108
|
+
t[5] === c ? h = t[6] : (h = (e) => {
|
|
2794
3109
|
e.preventDefault(), c();
|
|
2795
|
-
}, t[5] = c, t[6] =
|
|
2796
|
-
let
|
|
2797
|
-
t[7] === r ?
|
|
3110
|
+
}, t[5] = c, t[6] = h);
|
|
3111
|
+
let g;
|
|
3112
|
+
t[7] === r ? g = t[8] : (g = r === null ? null : /* @__PURE__ */ C("span", {
|
|
2798
3113
|
className: "flex size-4 shrink-0 items-center justify-center",
|
|
2799
3114
|
children: r
|
|
2800
|
-
}), t[7] = r, t[8] =
|
|
2801
|
-
let
|
|
2802
|
-
t[9] === a ?
|
|
3115
|
+
}), t[7] = r, t[8] = g);
|
|
3116
|
+
let v;
|
|
3117
|
+
t[9] === a ? v = t[10] : (v = /* @__PURE__ */ C("span", {
|
|
2803
3118
|
className: "truncate",
|
|
2804
3119
|
children: a
|
|
2805
|
-
}), t[9] = a, t[10] =
|
|
3120
|
+
}), t[9] = a, t[10] = v);
|
|
2806
3121
|
let b;
|
|
2807
|
-
t[11] === o ? b = t[12] : (b = o ? /* @__PURE__ */
|
|
3122
|
+
t[11] === o ? b = t[12] : (b = o ? /* @__PURE__ */ C("span", {
|
|
2808
3123
|
className: "text-muted-foreground shrink-0",
|
|
2809
3124
|
children: "args"
|
|
2810
3125
|
}) : null, t[11] = o, t[12] = b);
|
|
2811
3126
|
let x;
|
|
2812
|
-
t[13] === s ? x = t[14] : (x = /* @__PURE__ */
|
|
3127
|
+
t[13] === s ? x = t[14] : (x = /* @__PURE__ */ C("span", {
|
|
2813
3128
|
className: "text-muted-foreground truncate",
|
|
2814
3129
|
children: s
|
|
2815
3130
|
}), t[13] = s, t[14] = x);
|
|
2816
|
-
let
|
|
2817
|
-
return t[15] !== n || t[16] !== m || t[17] !==
|
|
3131
|
+
let S;
|
|
3132
|
+
return t[15] !== n || t[16] !== m || t[17] !== h || t[18] !== g || t[19] !== v || t[20] !== b || t[21] !== x ? (S = /* @__PURE__ */ w("button", {
|
|
2818
3133
|
ref: u,
|
|
2819
3134
|
type: "button",
|
|
2820
3135
|
role: "option",
|
|
2821
3136
|
"aria-selected": n,
|
|
2822
3137
|
className: m,
|
|
2823
|
-
onMouseDown:
|
|
3138
|
+
onMouseDown: h,
|
|
2824
3139
|
children: [
|
|
3140
|
+
g,
|
|
2825
3141
|
v,
|
|
2826
|
-
y,
|
|
2827
3142
|
b,
|
|
2828
3143
|
x
|
|
2829
3144
|
]
|
|
2830
|
-
}), t[15] = n, t[16] = m, t[17] =
|
|
3145
|
+
}), t[15] = n, t[16] = m, t[17] = h, t[18] = g, t[19] = v, t[20] = b, t[21] = x, t[22] = S) : S = t[22], S;
|
|
2831
3146
|
}
|
|
2832
|
-
var
|
|
3147
|
+
var Lr = [
|
|
2833
3148
|
{
|
|
2834
3149
|
title: "Send",
|
|
2835
3150
|
items: [
|
|
@@ -2857,22 +3172,22 @@ var yr = [
|
|
|
2857
3172
|
]
|
|
2858
3173
|
}
|
|
2859
3174
|
];
|
|
2860
|
-
function
|
|
3175
|
+
function Rr(e) {
|
|
2861
3176
|
let t = i(13), n, r;
|
|
2862
3177
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2863
|
-
let { state: a, actions: o } =
|
|
2864
|
-
if (!a.shortcutsOpen || !
|
|
3178
|
+
let { state: a, actions: o } = N("Composer.Shortcuts"), { closeShortcuts: s } = o;
|
|
3179
|
+
if (!a.shortcutsOpen || !fe(a)) return null;
|
|
2865
3180
|
let c;
|
|
2866
3181
|
t[3] === n ? c = t[4] : (c = l("border-border bg-popover border-t px-3 py-3 text-xs", n), t[3] = n, t[4] = c);
|
|
2867
3182
|
let u;
|
|
2868
|
-
t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */
|
|
3183
|
+
t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ C("div", {
|
|
2869
3184
|
className: "text-foreground font-medium",
|
|
2870
3185
|
children: "Keyboard shortcuts"
|
|
2871
3186
|
}), t[5] = u) : u = t[5];
|
|
2872
3187
|
let d;
|
|
2873
|
-
t[6] === s ? d = t[7] : (d = /* @__PURE__ */
|
|
3188
|
+
t[6] === s ? d = t[7] : (d = /* @__PURE__ */ w("div", {
|
|
2874
3189
|
className: "mb-3 flex items-center justify-between gap-3",
|
|
2875
|
-
children: [u, /* @__PURE__ */
|
|
3190
|
+
children: [u, /* @__PURE__ */ C("button", {
|
|
2876
3191
|
type: "button",
|
|
2877
3192
|
className: "text-muted-foreground hover:bg-muted hover:text-foreground rounded-sm px-2 py-1",
|
|
2878
3193
|
onClick: s,
|
|
@@ -2880,12 +3195,12 @@ function br(e) {
|
|
|
2880
3195
|
})]
|
|
2881
3196
|
}), t[6] = s, t[7] = d);
|
|
2882
3197
|
let f;
|
|
2883
|
-
t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */
|
|
3198
|
+
t[8] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ C("div", {
|
|
2884
3199
|
className: "grid gap-3 sm:grid-cols-3",
|
|
2885
|
-
children:
|
|
3200
|
+
children: Lr.map(zr)
|
|
2886
3201
|
}), t[8] = f) : f = t[8];
|
|
2887
3202
|
let p;
|
|
2888
|
-
return t[9] !== r || t[10] !== c || t[11] !== d ? (p = /* @__PURE__ */
|
|
3203
|
+
return t[9] !== r || t[10] !== c || t[11] !== d ? (p = /* @__PURE__ */ w("div", {
|
|
2889
3204
|
role: "dialog",
|
|
2890
3205
|
"aria-label": "Keyboard shortcuts",
|
|
2891
3206
|
className: c,
|
|
@@ -2893,52 +3208,52 @@ function br(e) {
|
|
|
2893
3208
|
children: [d, f]
|
|
2894
3209
|
}), t[9] = r, t[10] = c, t[11] = d, t[12] = p) : p = t[12], p;
|
|
2895
3210
|
}
|
|
2896
|
-
function
|
|
2897
|
-
return /* @__PURE__ */
|
|
3211
|
+
function zr(e) {
|
|
3212
|
+
return /* @__PURE__ */ w("div", {
|
|
2898
3213
|
className: "space-y-2",
|
|
2899
|
-
children: [/* @__PURE__ */
|
|
3214
|
+
children: [/* @__PURE__ */ C("div", {
|
|
2900
3215
|
className: "text-muted-foreground text-[11px]",
|
|
2901
3216
|
children: e.title
|
|
2902
|
-
}), /* @__PURE__ */
|
|
3217
|
+
}), /* @__PURE__ */ C("div", {
|
|
2903
3218
|
className: "space-y-1",
|
|
2904
|
-
children: e.items.map(
|
|
3219
|
+
children: e.items.map(Br)
|
|
2905
3220
|
})]
|
|
2906
3221
|
}, e.title);
|
|
2907
3222
|
}
|
|
2908
|
-
function
|
|
3223
|
+
function Br(e) {
|
|
2909
3224
|
let [t, n] = e;
|
|
2910
|
-
return /* @__PURE__ */
|
|
3225
|
+
return /* @__PURE__ */ w("div", {
|
|
2911
3226
|
className: "flex items-center justify-between gap-2",
|
|
2912
|
-
children: [/* @__PURE__ */
|
|
3227
|
+
children: [/* @__PURE__ */ C("kbd", {
|
|
2913
3228
|
className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
|
|
2914
3229
|
children: t
|
|
2915
|
-
}), /* @__PURE__ */
|
|
3230
|
+
}), /* @__PURE__ */ C("span", {
|
|
2916
3231
|
className: "text-muted-foreground text-right",
|
|
2917
3232
|
children: n
|
|
2918
3233
|
})]
|
|
2919
3234
|
}, `${t}-${n}`);
|
|
2920
3235
|
}
|
|
2921
|
-
function
|
|
3236
|
+
function Vr(e) {
|
|
2922
3237
|
let t = i(30), n, r;
|
|
2923
3238
|
t[0] === e ? (n = t[1], r = t[2]) : ({className: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
2924
|
-
let { activePopup: a, state: o, commandTriggers: s } =
|
|
3239
|
+
let { activePopup: a, state: o, commandTriggers: s } = N("Composer.Footer");
|
|
2925
3240
|
if (o.reverseSearch !== null) {
|
|
2926
3241
|
let e;
|
|
2927
3242
|
t[3] === n ? e = t[4] : (e = l("border-border text-muted-foreground flex items-center gap-2 border-t px-3 py-2 text-[11px]", n), t[3] = n, t[4] = e);
|
|
2928
3243
|
let i, a;
|
|
2929
|
-
t[5] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */
|
|
3244
|
+
t[5] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ C("kbd", {
|
|
2930
3245
|
className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
|
|
2931
3246
|
children: "Ctrl R"
|
|
2932
|
-
}), a = /* @__PURE__ */
|
|
3247
|
+
}), a = /* @__PURE__ */ C("span", { children: "reverse-i-search:" }), t[5] = i, t[6] = a) : (i = t[5], a = t[6]);
|
|
2933
3248
|
let s = o.reverseSearch || "_", c;
|
|
2934
|
-
t[7] === s ? c = t[8] : (c = /* @__PURE__ */
|
|
3249
|
+
t[7] === s ? c = t[8] : (c = /* @__PURE__ */ C("span", {
|
|
2935
3250
|
className: "text-foreground",
|
|
2936
3251
|
children: s
|
|
2937
3252
|
}), t[7] = s, t[8] = c);
|
|
2938
3253
|
let u, d, f, p;
|
|
2939
|
-
t[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */
|
|
3254
|
+
t[9] === Symbol.for("react.memo_cache_sentinel") ? (u = /* @__PURE__ */ C("span", { children: "Ctrl R previous" }), d = /* @__PURE__ */ C("span", { children: "Ctrl S next" }), f = /* @__PURE__ */ C("span", { children: "Enter accept" }), p = /* @__PURE__ */ C("span", { children: "Esc cancel" }), t[9] = u, t[10] = d, t[11] = f, t[12] = p) : (u = t[9], d = t[10], f = t[11], p = t[12]);
|
|
2940
3255
|
let m;
|
|
2941
|
-
return t[13] !== r || t[14] !== e || t[15] !== c ? (m = /* @__PURE__ */
|
|
3256
|
+
return t[13] !== r || t[14] !== e || t[15] !== c ? (m = /* @__PURE__ */ w("div", {
|
|
2942
3257
|
className: e,
|
|
2943
3258
|
...r,
|
|
2944
3259
|
children: [
|
|
@@ -2973,31 +3288,31 @@ function Cr(e) {
|
|
|
2973
3288
|
let u = c, d;
|
|
2974
3289
|
t[22] === n ? d = t[23] : (d = l("border-border text-muted-foreground flex flex-wrap items-center gap-x-4 gap-y-1 border-t px-3 py-2 text-[11px]", n), t[22] = n, t[23] = d);
|
|
2975
3290
|
let f;
|
|
2976
|
-
t[24] === u ? f = t[25] : (f = u.map(
|
|
3291
|
+
t[24] === u ? f = t[25] : (f = u.map(Hr), t[24] = u, t[25] = f);
|
|
2977
3292
|
let p;
|
|
2978
|
-
return t[26] !== r || t[27] !== d || t[28] !== f ? (p = /* @__PURE__ */
|
|
3293
|
+
return t[26] !== r || t[27] !== d || t[28] !== f ? (p = /* @__PURE__ */ C("div", {
|
|
2979
3294
|
className: d,
|
|
2980
3295
|
...r,
|
|
2981
3296
|
children: f
|
|
2982
3297
|
}), t[26] = r, t[27] = d, t[28] = f, t[29] = p) : p = t[29], p;
|
|
2983
3298
|
}
|
|
2984
|
-
function
|
|
3299
|
+
function Hr(e) {
|
|
2985
3300
|
let [t, n] = e;
|
|
2986
|
-
return /* @__PURE__ */
|
|
3301
|
+
return /* @__PURE__ */ w("span", {
|
|
2987
3302
|
className: "inline-flex items-center gap-1",
|
|
2988
|
-
children: [/* @__PURE__ */
|
|
3303
|
+
children: [/* @__PURE__ */ C("kbd", {
|
|
2989
3304
|
className: "border-border bg-muted text-foreground rounded border px-1.5 py-0.5 font-[inherit]",
|
|
2990
3305
|
children: t
|
|
2991
3306
|
}), n]
|
|
2992
3307
|
}, `${t}-${n}`);
|
|
2993
3308
|
}
|
|
2994
|
-
function
|
|
3309
|
+
function Ur(e) {
|
|
2995
3310
|
let t = i(19), n, r, a, o;
|
|
2996
3311
|
t[0] === e ? (n = t[1], r = t[2], a = t[3], o = t[4]) : ({accept: a, multiple: o, disabled: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = o);
|
|
2997
|
-
let s = a === void 0 ? "image/*,video/*,audio/*" : a, c = o === void 0 || o, { actions: l, disabled: u } =
|
|
3312
|
+
let s = a === void 0 ? "image/*,video/*,audio/*" : a, c = o === void 0 || o, { actions: l, disabled: u } = N("Composer.AttachFiles"), d = y(null), f;
|
|
2998
3313
|
t[5] === Symbol.for("react.memo_cache_sentinel") ? (f = () => d.current?.click(), t[5] = f) : f = t[5];
|
|
2999
3314
|
let p;
|
|
3000
|
-
t[6] !== n || t[7] !== r ? (p = /* @__PURE__ */
|
|
3315
|
+
t[6] !== n || t[7] !== r ? (p = /* @__PURE__ */ C(Yr, {
|
|
3001
3316
|
action: f,
|
|
3002
3317
|
disabled: n,
|
|
3003
3318
|
...r
|
|
@@ -3008,7 +3323,7 @@ function Tr(e) {
|
|
|
3008
3323
|
t.files && l.attachImageFiles(t.files), t.value = "";
|
|
3009
3324
|
}, t[9] = l, t[10] = h);
|
|
3010
3325
|
let g;
|
|
3011
|
-
t[11] !== s || t[12] !== c || t[13] !== m || t[14] !== h ? (g = /* @__PURE__ */
|
|
3326
|
+
t[11] !== s || t[12] !== c || t[13] !== m || t[14] !== h ? (g = /* @__PURE__ */ C("input", {
|
|
3012
3327
|
ref: d,
|
|
3013
3328
|
type: "file",
|
|
3014
3329
|
accept: s,
|
|
@@ -3018,83 +3333,83 @@ function Tr(e) {
|
|
|
3018
3333
|
disabled: m,
|
|
3019
3334
|
onChange: h
|
|
3020
3335
|
}), t[11] = s, t[12] = c, t[13] = m, t[14] = h, t[15] = g) : g = t[15];
|
|
3021
|
-
let
|
|
3022
|
-
return t[16] !== p || t[17] !== g ? (
|
|
3336
|
+
let _;
|
|
3337
|
+
return t[16] !== p || t[17] !== g ? (_ = /* @__PURE__ */ w(te, { children: [p, g] }), t[16] = p, t[17] = g, t[18] = _) : _ = t[18], _;
|
|
3023
3338
|
}
|
|
3024
|
-
function
|
|
3339
|
+
function Wr(e) {
|
|
3025
3340
|
let t = i(9), n, r;
|
|
3026
3341
|
t[0] === e ? (n = t[1], r = t[2]) : ({url: r, ...n} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3027
|
-
let { actions: a } =
|
|
3342
|
+
let { actions: a } = N("Composer.AddRemoteImage"), o;
|
|
3028
3343
|
t[3] !== a || t[4] !== r ? (o = () => a.addRemoteImage(r), t[3] = a, t[4] = r, t[5] = o) : o = t[5];
|
|
3029
3344
|
let s;
|
|
3030
|
-
return t[6] !== n || t[7] !== o ? (s = /* @__PURE__ */
|
|
3345
|
+
return t[6] !== n || t[7] !== o ? (s = /* @__PURE__ */ C(Yr, {
|
|
3031
3346
|
action: o,
|
|
3032
3347
|
...n
|
|
3033
3348
|
}), t[6] = n, t[7] = o, t[8] = s) : s = t[8], s;
|
|
3034
3349
|
}
|
|
3035
|
-
function
|
|
3350
|
+
function Gr(e) {
|
|
3036
3351
|
let t = i(9), n, r;
|
|
3037
3352
|
t[0] === e ? (n = t[1], r = t[2]) : ({content: n, ...r} = e, t[0] = e, t[1] = n, t[2] = r);
|
|
3038
|
-
let { actions: a } =
|
|
3353
|
+
let { actions: a } = N("Composer.InsertPaste"), o;
|
|
3039
3354
|
t[3] !== a || t[4] !== n ? (o = () => a.insertPaste(n), t[3] = a, t[4] = n, t[5] = o) : o = t[5];
|
|
3040
3355
|
let s;
|
|
3041
|
-
return t[6] !== r || t[7] !== o ? (s = /* @__PURE__ */
|
|
3356
|
+
return t[6] !== r || t[7] !== o ? (s = /* @__PURE__ */ C(Yr, {
|
|
3042
3357
|
action: o,
|
|
3043
3358
|
...r
|
|
3044
3359
|
}), t[6] = r, t[7] = o, t[8] = s) : s = t[8], s;
|
|
3045
3360
|
}
|
|
3046
|
-
function
|
|
3361
|
+
function Kr(e) {
|
|
3047
3362
|
let t = i(13), n, r, a, o;
|
|
3048
3363
|
t[0] === e ? (n = t[1], r = t[2], a = t[3], o = t[4]) : ({href: n, label: r, metadata: a, ...o} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = a, t[4] = o);
|
|
3049
|
-
let { actions: s } =
|
|
3364
|
+
let { actions: s } = N("Composer.InsertRichLink"), c;
|
|
3050
3365
|
t[5] !== s || t[6] !== n || t[7] !== r || t[8] !== a ? (c = () => s.insertRichLink(n, r, a), t[5] = s, t[6] = n, t[7] = r, t[8] = a, t[9] = c) : c = t[9];
|
|
3051
3366
|
let l;
|
|
3052
|
-
return t[10] !== o || t[11] !== c ? (l = /* @__PURE__ */
|
|
3367
|
+
return t[10] !== o || t[11] !== c ? (l = /* @__PURE__ */ C(Yr, {
|
|
3053
3368
|
action: c,
|
|
3054
3369
|
...o
|
|
3055
3370
|
}), t[10] = o, t[11] = c, t[12] = l) : l = t[12], l;
|
|
3056
3371
|
}
|
|
3057
|
-
function
|
|
3058
|
-
let t = i(3), { actions: n } =
|
|
3059
|
-
return t[0] !== n.submit || t[1] !== e ? (r = /* @__PURE__ */
|
|
3372
|
+
function qr(e) {
|
|
3373
|
+
let t = i(3), { actions: n } = N("Composer.Submit"), r;
|
|
3374
|
+
return t[0] !== n.submit || t[1] !== e ? (r = /* @__PURE__ */ C(Yr, {
|
|
3060
3375
|
action: n.submit,
|
|
3061
3376
|
...e
|
|
3062
3377
|
}), t[0] = n.submit, t[1] = e, t[2] = r) : r = t[2], r;
|
|
3063
3378
|
}
|
|
3064
|
-
function
|
|
3065
|
-
let t = i(3), { actions: n } =
|
|
3066
|
-
return t[0] !== n.reset || t[1] !== e ? (r = /* @__PURE__ */
|
|
3379
|
+
function Jr(e) {
|
|
3380
|
+
let t = i(3), { actions: n } = N("Composer.Reset"), r;
|
|
3381
|
+
return t[0] !== n.reset || t[1] !== e ? (r = /* @__PURE__ */ C(Yr, {
|
|
3067
3382
|
action: n.reset,
|
|
3068
3383
|
...e
|
|
3069
3384
|
}), t[0] = n.reset, t[1] = e, t[2] = r) : r = t[2], r;
|
|
3070
3385
|
}
|
|
3071
|
-
function
|
|
3386
|
+
function Yr(e) {
|
|
3072
3387
|
let t = i(12), n, r, o, s;
|
|
3073
3388
|
t[0] === e ? (n = t[1], r = t[2], o = t[3], s = t[4]) : ({action: n, onClick: o, disabled: r, ...s} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = o, t[4] = s);
|
|
3074
|
-
let { disabled: c } =
|
|
3389
|
+
let { disabled: c } = N("Composer.ActionTrigger"), l = c || r, u;
|
|
3075
3390
|
t[5] !== n || t[6] !== o ? (u = (e) => {
|
|
3076
3391
|
o?.(e), e.defaultPrevented || n();
|
|
3077
3392
|
}, t[5] = n, t[6] = o, t[7] = u) : u = t[7];
|
|
3078
3393
|
let d;
|
|
3079
|
-
return t[8] !== s || t[9] !== l || t[10] !== u ? (d = /* @__PURE__ */
|
|
3394
|
+
return t[8] !== s || t[9] !== l || t[10] !== u ? (d = /* @__PURE__ */ C(a, {
|
|
3080
3395
|
...s,
|
|
3081
3396
|
disabled: l,
|
|
3082
3397
|
onClick: u
|
|
3083
3398
|
}), t[8] = s, t[9] = l, t[10] = u, t[11] = d) : d = t[11], d;
|
|
3084
3399
|
}
|
|
3085
|
-
function
|
|
3400
|
+
function Xr(e) {
|
|
3086
3401
|
if (e.metaKey) return !1;
|
|
3087
3402
|
if (e.key === "Enter") return e.altKey && !e.ctrlKey;
|
|
3088
3403
|
let t = e.key.toLowerCase();
|
|
3089
3404
|
return e.ctrlKey && !e.altKey && (t === "j" || t === "m");
|
|
3090
3405
|
}
|
|
3091
|
-
function
|
|
3406
|
+
function Zr(e) {
|
|
3092
3407
|
if (e.metaKey) return !1;
|
|
3093
3408
|
if (e.key === "Backspace") return e.ctrlKey || e.altKey;
|
|
3094
3409
|
let t = e.key.toLowerCase();
|
|
3095
3410
|
return e.ctrlKey && !e.altKey && t === "w" || e.ctrlKey && e.altKey && t === "h";
|
|
3096
3411
|
}
|
|
3097
|
-
function
|
|
3412
|
+
function Qr(e) {
|
|
3098
3413
|
if (e.metaKey || e.shiftKey) return null;
|
|
3099
3414
|
if (e.key === "ArrowLeft" && (e.altKey || e.ctrlKey)) return -1;
|
|
3100
3415
|
if (e.key === "ArrowRight" && (e.altKey || e.ctrlKey)) return 1;
|
|
@@ -3102,53 +3417,55 @@ function Pr(e) {
|
|
|
3102
3417
|
let t = e.key.toLowerCase();
|
|
3103
3418
|
return t === "b" ? -1 : t === "f" ? 1 : null;
|
|
3104
3419
|
}
|
|
3105
|
-
function
|
|
3420
|
+
function $r(e) {
|
|
3106
3421
|
if (e.key === "ArrowUp") return -1;
|
|
3107
3422
|
if (e.key === "ArrowDown") return 1;
|
|
3108
3423
|
if (e.metaKey || e.altKey || e.shiftKey || !e.ctrlKey) return null;
|
|
3109
3424
|
let t = e.key.toLowerCase();
|
|
3110
3425
|
return t === "p" ? -1 : t === "n" ? 1 : null;
|
|
3111
3426
|
}
|
|
3112
|
-
function
|
|
3427
|
+
function ei(e) {
|
|
3113
3428
|
let { doc: t, selection: n } = e.state;
|
|
3114
|
-
return n.empty || n.from > 1 || n.to < t.content.size - 1 ? !1 : (e.commands.setContent(
|
|
3115
|
-
}
|
|
3116
|
-
var
|
|
3117
|
-
Root:
|
|
3118
|
-
Trigger:
|
|
3119
|
-
Command:
|
|
3120
|
-
Mention:
|
|
3121
|
-
Content:
|
|
3122
|
-
Toolbar:
|
|
3123
|
-
RemoteImages:
|
|
3124
|
-
Attachments:
|
|
3125
|
-
Editor:
|
|
3126
|
-
Error:
|
|
3127
|
-
Popup:
|
|
3128
|
-
Shortcuts:
|
|
3129
|
-
Footer:
|
|
3130
|
-
AttachFiles:
|
|
3131
|
-
AddRemoteImage:
|
|
3132
|
-
InsertPaste:
|
|
3133
|
-
InsertRichLink:
|
|
3134
|
-
|
|
3135
|
-
|
|
3429
|
+
return n.empty || n.from > 1 || n.to < t.content.size - 1 ? !1 : (e.commands.setContent(bn(), { emitUpdate: !0 }), e.commands.focus("start"), e.commands.setTextSelection(1), !0);
|
|
3430
|
+
}
|
|
3431
|
+
var ti = {
|
|
3432
|
+
Root: Tr,
|
|
3433
|
+
Trigger: kt,
|
|
3434
|
+
Command: At,
|
|
3435
|
+
Mention: jt,
|
|
3436
|
+
Content: kr,
|
|
3437
|
+
Toolbar: Ar,
|
|
3438
|
+
RemoteImages: jr,
|
|
3439
|
+
Attachments: F,
|
|
3440
|
+
Editor: Mr,
|
|
3441
|
+
Error: Nr,
|
|
3442
|
+
Popup: Pr,
|
|
3443
|
+
Shortcuts: Rr,
|
|
3444
|
+
Footer: Vr,
|
|
3445
|
+
AttachFiles: Ur,
|
|
3446
|
+
AddRemoteImage: Wr,
|
|
3447
|
+
InsertPaste: Gr,
|
|
3448
|
+
InsertRichLink: Kr,
|
|
3449
|
+
Dictate: Ut,
|
|
3450
|
+
CancelDictation: Wt,
|
|
3451
|
+
Submit: qr,
|
|
3452
|
+
Reset: Jr
|
|
3136
3453
|
};
|
|
3137
3454
|
//#endregion
|
|
3138
3455
|
//#region src/lib/ComposerTokenText.tsx
|
|
3139
|
-
function
|
|
3456
|
+
function ni(e) {
|
|
3140
3457
|
let t = i(5), { text: n, elements: r } = e, a;
|
|
3141
|
-
t[0] !== r || t[1] !== n ? (a =
|
|
3458
|
+
t[0] !== r || t[1] !== n ? (a = ii(n, r).map(ri), t[0] = r, t[1] = n, t[2] = a) : a = t[2];
|
|
3142
3459
|
let o;
|
|
3143
|
-
return t[3] === a ? o = t[4] : (o = /* @__PURE__ */
|
|
3460
|
+
return t[3] === a ? o = t[4] : (o = /* @__PURE__ */ C(te, { children: a }), t[3] = a, t[4] = o), o;
|
|
3144
3461
|
}
|
|
3145
|
-
function
|
|
3146
|
-
return e.element ? /* @__PURE__ */
|
|
3462
|
+
function ri(e) {
|
|
3463
|
+
return e.element ? /* @__PURE__ */ C("span", {
|
|
3147
3464
|
"data-token": e.element.kind,
|
|
3148
3465
|
children: e.text
|
|
3149
|
-
}, `${e.start}-${e.end}-${e.element.id}`) : /* @__PURE__ */
|
|
3466
|
+
}, `${e.start}-${e.end}-${e.element.id}`) : /* @__PURE__ */ C("span", { children: e.text }, `${e.start}-${e.end}`);
|
|
3150
3467
|
}
|
|
3151
|
-
function
|
|
3468
|
+
function ii(e, t) {
|
|
3152
3469
|
let n = t.toSorted((e, t) => e.range.start - t.range.start).filter((t) => t.range.start >= 0 && t.range.end <= e.length && e.slice(t.range.start, t.range.end) === t.label), r = [], i = 0;
|
|
3153
3470
|
for (let t of n) t.range.start > i && r.push({
|
|
3154
3471
|
text: e.slice(i, t.range.start),
|
|
@@ -3172,7 +3489,7 @@ function Br(e, t) {
|
|
|
3172
3489
|
}
|
|
3173
3490
|
//#endregion
|
|
3174
3491
|
//#region src/lib/persisted-prompt-selection.ts
|
|
3175
|
-
function
|
|
3492
|
+
function ai(e, t) {
|
|
3176
3493
|
if (!t || t.isCollapsed || t.rangeCount === 0) return null;
|
|
3177
3494
|
let n = t.getRangeAt(0);
|
|
3178
3495
|
if (!e.contains(n.commonAncestorContainer)) return null;
|
|
@@ -3185,51 +3502,51 @@ function Vr(e, t) {
|
|
|
3185
3502
|
}
|
|
3186
3503
|
//#endregion
|
|
3187
3504
|
//#region src/lib/PersistedPromptText.tsx
|
|
3188
|
-
function
|
|
3505
|
+
function oi(e) {
|
|
3189
3506
|
let t = i(6), { text: n } = e, a, o;
|
|
3190
3507
|
if (t[0] !== n) {
|
|
3191
3508
|
let e = r(n);
|
|
3192
|
-
a =
|
|
3509
|
+
a = li, o = e.map(si), t[0] = n, t[1] = a, t[2] = o;
|
|
3193
3510
|
} else a = t[1], o = t[2];
|
|
3194
3511
|
let s;
|
|
3195
|
-
return t[3] !== a || t[4] !== o ? (s = /* @__PURE__ */
|
|
3512
|
+
return t[3] !== a || t[4] !== o ? (s = /* @__PURE__ */ C("span", {
|
|
3196
3513
|
onCopy: a,
|
|
3197
3514
|
children: o
|
|
3198
3515
|
}), t[3] = a, t[4] = o, t[5] = s) : s = t[5], s;
|
|
3199
3516
|
}
|
|
3200
|
-
function
|
|
3517
|
+
function si(e) {
|
|
3201
3518
|
switch (e.kind) {
|
|
3202
3519
|
case "text": return e.value;
|
|
3203
|
-
case "inline-code": return /* @__PURE__ */
|
|
3520
|
+
case "inline-code": return /* @__PURE__ */ C("code", {
|
|
3204
3521
|
"data-persisted-source": e.source,
|
|
3205
3522
|
className: "bg-muted rounded px-1 py-0.5 font-mono text-[0.9em]",
|
|
3206
3523
|
children: e.value
|
|
3207
3524
|
}, e.start);
|
|
3208
|
-
case "code-block": return /* @__PURE__ */
|
|
3525
|
+
case "code-block": return /* @__PURE__ */ C("span", {
|
|
3209
3526
|
"data-persisted-source": e.source,
|
|
3210
3527
|
className: "bg-muted my-2 block overflow-x-auto rounded-md px-3 py-2",
|
|
3211
|
-
children: /* @__PURE__ */
|
|
3528
|
+
children: /* @__PURE__ */ C("code", {
|
|
3212
3529
|
className: "font-mono text-[0.9em]",
|
|
3213
3530
|
children: e.value
|
|
3214
3531
|
})
|
|
3215
3532
|
}, e.start);
|
|
3216
|
-
case "skill-link": return /* @__PURE__ */
|
|
3533
|
+
case "skill-link": return /* @__PURE__ */ C(ci, {
|
|
3217
3534
|
name: e.name,
|
|
3218
3535
|
source: e.source,
|
|
3219
3536
|
skillId: e.skillId,
|
|
3220
3537
|
title: e.href
|
|
3221
3538
|
}, e.start);
|
|
3222
|
-
case "standalone-skill": return /* @__PURE__ */
|
|
3539
|
+
case "standalone-skill": return /* @__PURE__ */ C(ci, {
|
|
3223
3540
|
name: e.name,
|
|
3224
3541
|
source: e.source
|
|
3225
3542
|
}, e.start);
|
|
3226
|
-
case "mention": return /* @__PURE__ */
|
|
3543
|
+
case "mention": return /* @__PURE__ */ C("span", {
|
|
3227
3544
|
"data-token": "mention",
|
|
3228
3545
|
"data-persisted-source": e.source,
|
|
3229
3546
|
className: "bg-foreground/10 rounded-sm px-0.5 font-medium",
|
|
3230
3547
|
children: e.label
|
|
3231
3548
|
}, e.start);
|
|
3232
|
-
case "link": return /^(?:https?:|mailto:)/.test(e.href) ? /* @__PURE__ */
|
|
3549
|
+
case "link": return /^(?:https?:|mailto:)/.test(e.href) ? /* @__PURE__ */ C("a", {
|
|
3233
3550
|
href: e.href,
|
|
3234
3551
|
"data-persisted-source": e.source,
|
|
3235
3552
|
className: "text-primary underline underline-offset-2",
|
|
@@ -3239,16 +3556,16 @@ function Ur(e) {
|
|
|
3239
3556
|
}, e.start) : e.source;
|
|
3240
3557
|
}
|
|
3241
3558
|
}
|
|
3242
|
-
function
|
|
3559
|
+
function ci(e) {
|
|
3243
3560
|
let t = i(9), { name: n, source: r, skillId: a, title: o } = e, s = a ? void 0 : n, c;
|
|
3244
|
-
t[0] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ S
|
|
3561
|
+
t[0] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ C(S, {
|
|
3245
3562
|
"aria-hidden": "true",
|
|
3246
3563
|
className: "size-3.5 self-center"
|
|
3247
3564
|
}), t[0] = c) : c = t[0];
|
|
3248
3565
|
let l;
|
|
3249
|
-
t[1] === n ? l = t[2] : (l = /* @__PURE__ */
|
|
3566
|
+
t[1] === n ? l = t[2] : (l = /* @__PURE__ */ C("span", { children: n }), t[1] = n, t[2] = l);
|
|
3250
3567
|
let u;
|
|
3251
|
-
return t[3] !== a || t[4] !== r || t[5] !== s || t[6] !== l || t[7] !== o ? (u = /* @__PURE__ */
|
|
3568
|
+
return t[3] !== a || t[4] !== r || t[5] !== s || t[6] !== l || t[7] !== o ? (u = /* @__PURE__ */ w("span", {
|
|
3252
3569
|
"data-skill-id": a,
|
|
3253
3570
|
"data-skill-name": s,
|
|
3254
3571
|
"data-persisted-source": r,
|
|
@@ -3257,11 +3574,11 @@ function Wr(e) {
|
|
|
3257
3574
|
children: [c, l]
|
|
3258
3575
|
}), t[3] = a, t[4] = r, t[5] = s, t[6] = l, t[7] = o, t[8] = u) : u = t[8], u;
|
|
3259
3576
|
}
|
|
3260
|
-
function
|
|
3261
|
-
let t =
|
|
3577
|
+
function li(e) {
|
|
3578
|
+
let t = ai(e.currentTarget, window.getSelection());
|
|
3262
3579
|
t !== null && (e.clipboardData.setData("text/plain", t), e.preventDefault());
|
|
3263
3580
|
}
|
|
3264
3581
|
//#endregion
|
|
3265
|
-
export {
|
|
3582
|
+
export { ti as Composer, ni as ComposerTokenText, Gt as DictationError, oi as PersistedPromptText, Ve as createComposerDraftSource, de as createComposerState, Ue as createDraftFromPersistedText, We as createDraftFromSource, Be as createDraftFromState, $ as createPersistedTextFromDraft, Ge as decodeComposerTextLinkHref, U as isVisibleInPhase, pe as prepareComposerPayload, He as pushComposerHistory, ai as reconstructPersistedPromptSelection, e as serializeMentionPromptLink, t as serializePersistedPromptLink, n as serializeSkillPromptLink, r as tokenizePersistedPrompt, P as useComposer, Vt as useComposerDictation };
|
|
3266
3583
|
|
|
3267
3584
|
//# sourceMappingURL=browser.js.map
|