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