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