@airalogy/aimd-editor 1.14.0 → 1.15.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.
@@ -1,2352 +0,0 @@
1
- import { defineComponent as ve, computed as E, openBlock as g, createElementBlock as h, createElementVNode as i, createTextVNode as L, toDisplayString as v, Fragment as U, renderList as X, unref as Z, createCommentVNode as N, ref as $, watch as te, createBlock as be, Teleport as lt, withModifiers as me, normalizeStyle as Ee, normalizeClass as he, withDirectives as S, vModelText as q, createVNode as ae, vModelSelect as ye, vModelRadio as bt, vModelCheckbox as vt, nextTick as Re, inject as kt, h as et, onMounted as wt, onBeforeUnmount as Mt, resolveDynamicComponent as it, withKeys as _t, shallowRef as Je, vShow as nt } from "vue";
2
- import { callCommand as Tt, insert as Xe, replaceAll as Ue, getMarkdown as at } from "@milkdown/kit/utils";
3
- import "@milkdown/theme-nord/style.css";
4
- import { j as ft, m as Ae, k as Ct, h as ot, o as xt, i as $t, l as It, _ as Ft, n as zt } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-BR8KCFMg.js";
5
- import { u as ce, g as tt, f as pt, i as De, s as Ve, h as Se, a as Ye, j as Ze, c as At, b as ut, p as Vt } from "./lexer-DKU2sEoR.js";
6
- import { a as _e, c as Te, A as gt, b as St, u as Dt, d as Et } from "./fields-CC93ner-.js";
7
- import { _ as Bt } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-ey9GBO3X.js";
8
- import { protectAimdInlineTemplates as qt, restoreAimdInlineTemplates as Nt } from "@airalogy/aimd-core";
9
- import { parseAndExtract as Pt } from "@airalogy/aimd-renderer";
10
- import { insertTableCommand as Lt } from "@milkdown/kit/preset/gfm";
11
- var ke = 1e6, rt = 1e6, Be = "[big.js] ", qe = Be + "Invalid ", Oe = qe + "decimal places", Ut = qe + "rounding mode", ht = Be + "Division by zero", B = {}, oe = void 0;
12
- function we(e, n, t, a) {
13
- var o = e.c;
14
- if (t === oe && (t = e.constructor.RM), t !== 0 && t !== 1 && t !== 2 && t !== 3)
15
- throw Error(Ut);
16
- if (n < 1)
17
- a = t === 3 && (a || !!o[0]) || n === 0 && (t === 1 && o[0] >= 5 || t === 2 && (o[0] > 5 || o[0] === 5 && (a || o[1] !== oe))), o.length = 1, a ? (e.e = e.e - n + 1, o[0] = 1) : o[0] = e.e = 0;
18
- else if (n < o.length) {
19
- if (a = t === 1 && o[n] >= 5 || t === 2 && (o[n] > 5 || o[n] === 5 && (a || o[n + 1] !== oe || o[n - 1] & 1)) || t === 3 && (a || !!o[0]), o.length = n, a) {
20
- for (; ++o[--n] > 9; )
21
- if (o[n] = 0, n === 0) {
22
- ++e.e, o.unshift(1);
23
- break;
24
- }
25
- }
26
- for (n = o.length; !o[--n]; ) o.pop();
27
- }
28
- return e;
29
- }
30
- function Me(e, n, t) {
31
- var a = e.e, o = e.c.join(""), m = o.length;
32
- if (n)
33
- o = o.charAt(0) + (m > 1 ? "." + o.slice(1) : "") + (a < 0 ? "e" : "e+") + a;
34
- else if (a < 0) {
35
- for (; ++a; ) o = "0" + o;
36
- o = "0." + o;
37
- } else if (a > 0)
38
- if (++a > m)
39
- for (a -= m; a--; ) o += "0";
40
- else a < m && (o = o.slice(0, a) + "." + o.slice(a));
41
- else m > 1 && (o = o.charAt(0) + "." + o.slice(1));
42
- return e.s < 0 && t ? "-" + o : o;
43
- }
44
- B.abs = function() {
45
- var e = new this.constructor(this);
46
- return e.s = 1, e;
47
- };
48
- B.cmp = function(e) {
49
- var n, t = this, a = t.c, o = (e = new t.constructor(e)).c, m = t.s, f = e.s, u = t.e, l = e.e;
50
- if (!a[0] || !o[0]) return a[0] ? m : o[0] ? -f : 0;
51
- if (m != f) return m;
52
- if (n = m < 0, u != l) return u > l ^ n ? 1 : -1;
53
- for (f = (u = a.length) < (l = o.length) ? u : l, m = -1; ++m < f; )
54
- if (a[m] != o[m]) return a[m] > o[m] ^ n ? 1 : -1;
55
- return u == l ? 0 : u > l ^ n ? 1 : -1;
56
- };
57
- B.div = function(e) {
58
- var n = this, t = n.constructor, a = n.c, o = (e = new t(e)).c, m = n.s == e.s ? 1 : -1, f = t.DP;
59
- if (f !== ~~f || f < 0 || f > ke)
60
- throw Error(Oe);
61
- if (!o[0])
62
- throw Error(ht);
63
- if (!a[0])
64
- return e.s = m, e.c = [e.e = 0], e;
65
- var u, l, d, w, c, y = o.slice(), V = u = o.length, _ = a.length, A = a.slice(0, u), I = A.length, P = e, O = P.c = [], x = 0, F = f + (P.e = n.e - e.e) + 1;
66
- for (P.s = m, m = F < 0 ? 0 : F, y.unshift(0); I++ < u; ) A.push(0);
67
- do {
68
- for (d = 0; d < 10; d++) {
69
- if (u != (I = A.length))
70
- w = u > I ? 1 : -1;
71
- else
72
- for (c = -1, w = 0; ++c < u; )
73
- if (o[c] != A[c]) {
74
- w = o[c] > A[c] ? 1 : -1;
75
- break;
76
- }
77
- if (w < 0) {
78
- for (l = I == u ? o : y; I; ) {
79
- if (A[--I] < l[I]) {
80
- for (c = I; c && !A[--c]; ) A[c] = 9;
81
- --A[c], A[I] += 10;
82
- }
83
- A[I] -= l[I];
84
- }
85
- for (; !A[0]; ) A.shift();
86
- } else
87
- break;
88
- }
89
- O[x++] = w ? d : ++d, A[0] && w ? A[I] = a[V] || 0 : A = [a[V]];
90
- } while ((V++ < _ || A[0] !== oe) && m--);
91
- return !O[0] && x != 1 && (O.shift(), P.e--, F--), x > F && we(P, F, t.RM, A[0] !== oe), P;
92
- };
93
- B.eq = function(e) {
94
- return this.cmp(e) === 0;
95
- };
96
- B.gt = function(e) {
97
- return this.cmp(e) > 0;
98
- };
99
- B.gte = function(e) {
100
- return this.cmp(e) > -1;
101
- };
102
- B.lt = function(e) {
103
- return this.cmp(e) < 0;
104
- };
105
- B.lte = function(e) {
106
- return this.cmp(e) < 1;
107
- };
108
- B.minus = B.sub = function(e) {
109
- var n, t, a, o, m = this, f = m.constructor, u = m.s, l = (e = new f(e)).s;
110
- if (u != l)
111
- return e.s = -l, m.plus(e);
112
- var d = m.c.slice(), w = m.e, c = e.c, y = e.e;
113
- if (!d[0] || !c[0])
114
- return c[0] ? e.s = -l : d[0] ? e = new f(m) : e.s = 1, e;
115
- if (u = w - y) {
116
- for ((o = u < 0) ? (u = -u, a = d) : (y = w, a = c), a.reverse(), l = u; l--; ) a.push(0);
117
- a.reverse();
118
- } else
119
- for (t = ((o = d.length < c.length) ? d : c).length, u = l = 0; l < t; l++)
120
- if (d[l] != c[l]) {
121
- o = d[l] < c[l];
122
- break;
123
- }
124
- if (o && (a = d, d = c, c = a, e.s = -e.s), (l = (t = c.length) - (n = d.length)) > 0) for (; l--; ) d[n++] = 0;
125
- for (l = n; t > u; ) {
126
- if (d[--t] < c[t]) {
127
- for (n = t; n && !d[--n]; ) d[n] = 9;
128
- --d[n], d[t] += 10;
129
- }
130
- d[t] -= c[t];
131
- }
132
- for (; d[--l] === 0; ) d.pop();
133
- for (; d[0] === 0; )
134
- d.shift(), --y;
135
- return d[0] || (e.s = 1, d = [y = 0]), e.c = d, e.e = y, e;
136
- };
137
- B.mod = function(e) {
138
- var n, t = this, a = t.constructor, o = t.s, m = (e = new a(e)).s;
139
- if (!e.c[0])
140
- throw Error(ht);
141
- return t.s = e.s = 1, n = e.cmp(t) == 1, t.s = o, e.s = m, n ? new a(t) : (o = a.DP, m = a.RM, a.DP = a.RM = 0, t = t.div(e), a.DP = o, a.RM = m, this.minus(t.times(e)));
142
- };
143
- B.neg = function() {
144
- var e = new this.constructor(this);
145
- return e.s = -e.s, e;
146
- };
147
- B.plus = B.add = function(e) {
148
- var n, t, a, o = this, m = o.constructor;
149
- if (e = new m(e), o.s != e.s)
150
- return e.s = -e.s, o.minus(e);
151
- var f = o.e, u = o.c, l = e.e, d = e.c;
152
- if (!u[0] || !d[0])
153
- return d[0] || (u[0] ? e = new m(o) : e.s = o.s), e;
154
- if (u = u.slice(), n = f - l) {
155
- for (n > 0 ? (l = f, a = d) : (n = -n, a = u), a.reverse(); n--; ) a.push(0);
156
- a.reverse();
157
- }
158
- for (u.length - d.length < 0 && (a = d, d = u, u = a), n = d.length, t = 0; n; u[n] %= 10) t = (u[--n] = u[n] + d[n] + t) / 10 | 0;
159
- for (t && (u.unshift(t), ++l), n = u.length; u[--n] === 0; ) u.pop();
160
- return e.c = u, e.e = l, e;
161
- };
162
- B.pow = function(e) {
163
- var n = this, t = new n.constructor("1"), a = t, o = e < 0;
164
- if (e !== ~~e || e < -rt || e > rt)
165
- throw Error(qe + "exponent");
166
- for (o && (e = -e); e & 1 && (a = a.times(n)), e >>= 1, !!e; )
167
- n = n.times(n);
168
- return o ? t.div(a) : a;
169
- };
170
- B.prec = function(e, n) {
171
- if (e !== ~~e || e < 1 || e > ke)
172
- throw Error(qe + "precision");
173
- return we(new this.constructor(this), e, n);
174
- };
175
- B.round = function(e, n) {
176
- if (e === oe) e = 0;
177
- else if (e !== ~~e || e < -ke || e > ke)
178
- throw Error(Oe);
179
- return we(new this.constructor(this), e + this.e + 1, n);
180
- };
181
- B.sqrt = function() {
182
- var e, n, t, a = this, o = a.constructor, m = a.s, f = a.e, u = new o("0.5");
183
- if (!a.c[0]) return new o(a);
184
- if (m < 0)
185
- throw Error(Be + "No square root");
186
- m = Math.sqrt(+Me(a, !0, !0)), m === 0 || m === 1 / 0 ? (n = a.c.join(""), n.length + f & 1 || (n += "0"), m = Math.sqrt(n), f = ((f + 1) / 2 | 0) - (f < 0 || f & 1), e = new o((m == 1 / 0 ? "5e" : (m = m.toExponential()).slice(0, m.indexOf("e") + 1)) + f)) : e = new o(m + ""), f = e.e + (o.DP += 4);
187
- do
188
- t = e, e = u.times(t.plus(a.div(t)));
189
- while (t.c.slice(0, f).join("") !== e.c.slice(0, f).join(""));
190
- return we(e, (o.DP -= 4) + e.e + 1, o.RM);
191
- };
192
- B.times = B.mul = function(e) {
193
- var n, t = this, a = t.constructor, o = t.c, m = (e = new a(e)).c, f = o.length, u = m.length, l = t.e, d = e.e;
194
- if (e.s = t.s == e.s ? 1 : -1, !o[0] || !m[0])
195
- return e.c = [e.e = 0], e;
196
- for (e.e = l + d, f < u && (n = o, o = m, m = n, d = f, f = u, u = d), n = new Array(d = f + u); d--; ) n[d] = 0;
197
- for (l = u; l--; ) {
198
- for (u = 0, d = f + l; d > l; )
199
- u = n[d] + m[l] * o[d - l - 1] + u, n[d--] = u % 10, u = u / 10 | 0;
200
- n[d] = u;
201
- }
202
- for (u ? ++e.e : n.shift(), l = n.length; !n[--l]; ) n.pop();
203
- return e.c = n, e;
204
- };
205
- B.toExponential = function(e, n) {
206
- var t = this, a = t.c[0];
207
- if (e !== oe) {
208
- if (e !== ~~e || e < 0 || e > ke)
209
- throw Error(Oe);
210
- for (t = we(new t.constructor(t), ++e, n); t.c.length < e; ) t.c.push(0);
211
- }
212
- return Me(t, !0, !!a);
213
- };
214
- B.toFixed = function(e, n) {
215
- var t = this, a = t.c[0];
216
- if (e !== oe) {
217
- if (e !== ~~e || e < 0 || e > ke)
218
- throw Error(Oe);
219
- for (t = we(new t.constructor(t), e + t.e + 1, n), e = e + t.e + 1; t.c.length < e; ) t.c.push(0);
220
- }
221
- return Me(t, !1, !!a);
222
- };
223
- B[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = B.toJSON = B.toString = function() {
224
- var e = this, n = e.constructor;
225
- return Me(e, e.e <= n.NE || e.e >= n.PE, !!e.c[0]);
226
- };
227
- B.toNumber = function() {
228
- var e = +Me(this, !0, !0);
229
- if (this.constructor.strict === !0 && !this.eq(e.toString()))
230
- throw Error(Be + "Imprecise conversion");
231
- return e;
232
- };
233
- B.toPrecision = function(e, n) {
234
- var t = this, a = t.constructor, o = t.c[0];
235
- if (e !== oe) {
236
- if (e !== ~~e || e < 1 || e > ke)
237
- throw Error(qe + "precision");
238
- for (t = we(new a(t), e, n); t.c.length < e; ) t.c.push(0);
239
- }
240
- return Me(t, e <= t.e || t.e <= a.NE || t.e >= a.PE, !!o);
241
- };
242
- B.valueOf = function() {
243
- var e = this, n = e.constructor;
244
- if (n.strict === !0)
245
- throw Error(Be + "valueOf disallowed");
246
- return Me(e, e.e <= n.NE || e.e >= n.PE, !0);
247
- };
248
- const Rt = { class: "aimd-type-picker" }, Ot = ["value"], jt = { value: "" }, Ht = ["label"], Wt = ["value"], Kt = ["label"], Qt = ["value"], Jt = ["value", "placeholder"], Xt = /* @__PURE__ */ ve({
249
- __name: "AimdTypePicker",
250
- props: {
251
- modelValue: {},
252
- messages: {},
253
- varTypePlugins: {}
254
- },
255
- emits: ["update:modelValue"],
256
- setup(e, { emit: n }) {
257
- const t = e, a = n, o = pt();
258
- function m(d) {
259
- const w = tt(d)?.title;
260
- return w && w !== d ? `${w} (${d})` : d;
261
- }
262
- const f = E(() => [...new Map((t.varTypePlugins ?? []).map((d) => [d.value, d])).values()].filter((d) => !o.includes(d.value))), u = E(() => {
263
- const d = ce(t.modelValue);
264
- return tt(d)?.type_name ?? (f.value.some((w) => w.value === d) ? d : "");
265
- });
266
- function l(d) {
267
- const w = d.target.value;
268
- w && a("update:modelValue", w + (De(t.modelValue) ? " | None" : ""));
269
- }
270
- return (d, w) => (g(), h("div", Rt, [
271
- i("label", null, [
272
- L(v(e.messages.inputField.knownTypes) + " ", 1),
273
- i("select", {
274
- name: "knownType",
275
- value: u.value,
276
- onChange: l
277
- }, [
278
- i("option", jt, v(e.messages.inputField.customExpression), 1),
279
- i("optgroup", {
280
- label: e.messages.inputField.builtInTypes
281
- }, [
282
- (g(!0), h(U, null, X(Z(o), (c) => (g(), h("option", {
283
- key: c,
284
- value: c
285
- }, v(m(c)), 9, Wt))), 128))
286
- ], 8, Ht),
287
- f.value.length ? (g(), h("optgroup", {
288
- key: 0,
289
- label: e.messages.inputField.pluginTypes
290
- }, [
291
- (g(!0), h(U, null, X(f.value, (c) => (g(), h("option", {
292
- key: c.value,
293
- value: c.value
294
- }, v(c.label) + " (" + v(c.value) + ")", 9, Qt))), 128))
295
- ], 8, Kt)) : N("", !0)
296
- ], 40, Ot)
297
- ]),
298
- i("label", null, [
299
- L(v(e.messages.dialog.customType), 1),
300
- i("input", {
301
- name: "type",
302
- value: e.modelValue,
303
- placeholder: e.messages.placeholders.type,
304
- spellcheck: "false",
305
- onInput: w[0] || (w[0] = (c) => a("update:modelValue", c.target.value))
306
- }, null, 40, Jt)
307
- ])
308
- ]));
309
- }
310
- }), je = (e, n) => {
311
- const t = e.__vccOpts || e;
312
- for (const [a, o] of n)
313
- t[a] = o;
314
- return t;
315
- }, yt = /* @__PURE__ */ je(Xt, [["__scopeId", "data-v-be127780"]]), Yt = { class: "aimd-dialog" }, Zt = { class: "aimd-dialog-header" }, Gt = { class: "aimd-dialog-title" }, el = ["innerHTML"], tl = { class: "aimd-dialog-type-tabs" }, ll = ["onClick"], sl = ["innerHTML"], il = { class: "aimd-dialog-body" }, nl = { class: "aimd-field-row" }, al = { class: "aimd-field-label" }, ol = ["placeholder"], ul = { class: "aimd-field-row" }, rl = { class: "aimd-field-label" }, dl = { class: "aimd-field-hint" }, cl = { class: "aimd-var-type-grid" }, ml = ["onClick"], vl = { class: "aimd-var-type-card-title" }, fl = { class: "aimd-var-type-card-desc" }, pl = { class: "aimd-field-row" }, gl = { class: "aimd-field-label" }, hl = ["placeholder"], yl = { class: "aimd-field-row" }, bl = { class: "aimd-field-label" }, kl = ["placeholder"], wl = { class: "aimd-field-row" }, Ml = { class: "aimd-field-label" }, _l = ["placeholder"], Tl = { class: "aimd-field-row" }, Cl = { class: "aimd-field-label" }, xl = ["placeholder"], $l = { class: "aimd-field-hint" }, Il = { class: "aimd-field-row" }, Fl = { class: "aimd-field-label" }, zl = { class: "aimd-field-row" }, Al = { class: "aimd-field-label" }, Vl = ["placeholder"], Sl = { class: "aimd-field-row" }, Dl = { class: "aimd-field-label" }, El = { value: "1" }, Bl = { value: "2" }, ql = { value: "3" }, Nl = { class: "aimd-field-row" }, Pl = { class: "aimd-field-label" }, Ll = ["placeholder"], Ul = { class: "aimd-field-row" }, Rl = { class: "aimd-field-label" }, Ol = { value: "choice" }, jl = { value: "blank" }, Hl = { value: "open" }, Wl = { class: "aimd-field-row" }, Kl = { class: "aimd-field-label" }, Ql = ["placeholder"], Jl = { class: "aimd-field-row" }, Xl = { class: "aimd-field-label" }, Yl = ["placeholder"], Zl = {
316
- key: 0,
317
- class: "aimd-field-hint"
318
- }, Gl = { class: "aimd-field-row" }, es = { class: "aimd-field-label" }, ts = { value: "single" }, ls = { value: "multiple" }, ss = { class: "aimd-field-row" }, is = { class: "aimd-field-label" }, ns = { class: "aimd-collection-editor" }, as = ["onDragover", "onDrop"], os = ["title", "onDragstart"], us = ["onUpdate:modelValue", "placeholder"], rs = ["onUpdate:modelValue", "placeholder"], ds = { class: "aimd-option-answer-toggle" }, cs = ["value", "disabled"], ms = ["value", "disabled"], vs = ["disabled", "onClick"], fs = { class: "aimd-field-hint" }, ps = {
319
- key: 1,
320
- class: "aimd-field-row"
321
- }, gs = { class: "aimd-field-label" }, hs = { class: "aimd-collection-editor" }, ys = ["onUpdate:modelValue", "placeholder"], bs = ["onUpdate:modelValue", "placeholder"], ks = ["disabled", "onClick"], ws = { class: "aimd-field-hint" }, Ms = {
322
- key: 2,
323
- class: "aimd-field-row"
324
- }, _s = { class: "aimd-field-label" }, Ts = ["placeholder"], Cs = { class: "aimd-field-row" }, xs = { class: "aimd-field-label" }, $s = { class: "aimd-field-row" }, Is = { class: "aimd-field-label" }, Fs = ["placeholder"], zs = { class: "aimd-field-row" }, As = { class: "aimd-field-label" }, Vs = {
325
- key: 5,
326
- class: "aimd-field-row"
327
- }, Ss = { class: "aimd-field-label" }, Ds = ["placeholder"], Es = { id: "aimd-ref-suggestions" }, Bs = ["value"], qs = {
328
- key: 0,
329
- class: "aimd-field-hint"
330
- }, Ns = {
331
- key: 6,
332
- class: "aimd-field-row"
333
- }, Ps = { class: "aimd-field-label" }, Ls = ["placeholder"], Us = { class: "aimd-field-hint" }, Rs = { class: "aimd-dialog-preview" }, Os = { class: "aimd-preview-header" }, js = { class: "aimd-preview-panel" }, Hs = { class: "aimd-preview-code" }, Ws = {
334
- key: 7,
335
- class: "aimd-dialog-error"
336
- }, Ks = { class: "aimd-dialog-footer" }, Qs = /* @__PURE__ */ ve({
337
- __name: "AimdFieldDialog",
338
- props: {
339
- visible: { type: Boolean },
340
- initialType: {},
341
- messages: {},
342
- refSuggestions: {},
343
- varTypePlugins: {},
344
- allowedTypes: {},
345
- existingQuizIds: {}
346
- },
347
- emits: ["update:visible", "insert"],
348
- setup(e, { emit: n }) {
349
- const t = e, a = n, o = E(() => {
350
- const p = ft(t.messages);
351
- if (!t.allowedTypes || t.allowedTypes.length === 0)
352
- return p;
353
- const r = new Set(t.allowedTypes);
354
- return p.filter((s) => r.has(s.type));
355
- });
356
- function m(p) {
357
- return p && o.value.some((r) => r.type === p) ? p : o.value[0]?.type ?? p ?? "var";
358
- }
359
- const f = E(() => new Set(t.existingQuizIds || [])), u = $(m(t.initialType)), l = $(Ae(u.value, t.messages, f.value)), d = $([]), w = $([]), c = $([]), y = $(null), V = $(null), _ = $(""), A = E(
360
- () => Ct(t.messages, t.varTypePlugins ?? [])
361
- );
362
- function I(p) {
363
- return (p || "").trim().toLowerCase().replace(/[\s_-]/g, "");
364
- }
365
- function P(p) {
366
- return I(l.value.type) === I(p);
367
- }
368
- function O(p) {
369
- l.value.type = p;
370
- }
371
- function x(p, r) {
372
- const s = `quiz_${p}`;
373
- let k = 1;
374
- for (; r.has(`${s}_${k}`); )
375
- k += 1;
376
- return `${s}_${k}`;
377
- }
378
- function F(p) {
379
- const r = p.split(",").map((s) => s.trim()).filter(Boolean);
380
- return r.length === 0 ? [
381
- { key: "A", text: "" },
382
- { key: "B", text: "" }
383
- ] : r.map((s, k) => {
384
- const D = s.indexOf(":");
385
- if (D > 0) {
386
- const pe = s.slice(0, D).trim() || String.fromCharCode(65 + k), Ne = s.slice(D + 1).trim() || t.messages.defaults.optionText(pe);
387
- return { key: pe, text: Ne };
388
- }
389
- return { key: String.fromCharCode(65 + k), text: s };
390
- });
391
- }
392
- function J(p) {
393
- const r = p.map((s) => ({ key: s.key.trim(), text: s.text.trim() })).filter((s) => s.key && s.text);
394
- return r.length === 0 ? "A:, B:" : r.map((s) => `${s.key}:${s.text}`).join(", ");
395
- }
396
- function ne(p) {
397
- const r = p.split(",").map((s) => s.trim()).filter(Boolean);
398
- return r.length === 0 ? [{ key: "b1", answer: "" }] : r.map((s, k) => {
399
- const D = s.indexOf(":");
400
- if (D > 0) {
401
- const Fe = s.slice(0, D).trim() || `b${k + 1}`, pe = s.slice(D + 1).trim() || "";
402
- return { key: Fe, answer: pe };
403
- }
404
- return { key: `b${k + 1}`, answer: s };
405
- });
406
- }
407
- function j(p) {
408
- const r = p.map((s) => ({ key: s.key.trim(), answer: s.answer.trim() })).filter((s) => s.key);
409
- return r.length === 0 ? "b1:" : r.map((s) => `${s.key}:${s.answer}`).join(", ");
410
- }
411
- function H(p) {
412
- return p.split(",").map((r) => r.trim()).filter(Boolean);
413
- }
414
- function W() {
415
- u.value === "quiz" && (l.value.quizType === "choice" ? (d.value = F(l.value.options || ""), c.value = H(l.value.answer || "")) : l.value.quizType === "blank" && (w.value = ne(l.value.blanks || "")));
416
- }
417
- function G() {
418
- if (u.value !== "quiz" || l.value.quizType !== "choice") return;
419
- const p = new Set(
420
- d.value.map((r) => r.key.trim()).filter(Boolean)
421
- );
422
- if (l.value.mode === "multiple") {
423
- const r = c.value.map((s) => s.trim()).filter((s) => s && p.has(s));
424
- r.length !== c.value.length && (c.value = r);
425
- } else {
426
- const r = (l.value.answer || "").trim();
427
- r && !p.has(r) && (l.value.answer = "");
428
- }
429
- }
430
- function le() {
431
- const p = new Set(
432
- d.value.map((r) => r.key.trim().toUpperCase()).filter(Boolean)
433
- );
434
- for (let r = 0; r < 26; r++) {
435
- const s = String.fromCharCode(65 + r);
436
- if (!p.has(s)) return s;
437
- }
438
- return `K${d.value.length + 1}`;
439
- }
440
- function M() {
441
- const p = le();
442
- d.value.push({ key: p, text: "" });
443
- }
444
- function z(p) {
445
- d.value.length <= 1 || d.value.splice(p, 1);
446
- }
447
- function R(p) {
448
- y.value = p, V.value = p;
449
- }
450
- function Q(p) {
451
- y.value !== null && (V.value = p);
452
- }
453
- function T(p) {
454
- const r = y.value;
455
- if (r === null || r === p) {
456
- y.value = null, V.value = null;
457
- return;
458
- }
459
- const s = d.value.splice(r, 1)[0];
460
- d.value.splice(p, 0, s), y.value = null, V.value = null;
461
- }
462
- function b() {
463
- y.value = null, V.value = null;
464
- }
465
- function C() {
466
- const p = new Set(
467
- w.value.map((s) => s.key.trim().toLowerCase()).filter(Boolean)
468
- );
469
- let r = 1;
470
- for (; p.has(`b${r}`); )
471
- r += 1;
472
- return `b${r}`;
473
- }
474
- function K() {
475
- w.value.push({ key: C(), answer: "" });
476
- }
477
- function Y(p) {
478
- w.value.length <= 1 || w.value.splice(p, 1);
479
- }
480
- function ee(p) {
481
- const r = /* @__PURE__ */ new Set(), s = [];
482
- for (const k of p)
483
- r.has(k) && !s.includes(k) && s.push(k), r.add(k);
484
- return s;
485
- }
486
- function ue(p) {
487
- const r = [], s = /\[\[([^\[\]\s]+)\]\]/g;
488
- for (const k of p.matchAll(s))
489
- r.push(k[1]);
490
- return r;
491
- }
492
- function ie() {
493
- const p = w.value.map((ze) => ze.key.trim()).filter(Boolean);
494
- if (p.length === 0)
495
- return t.messages.errors.blankQuizRequiresBlankKey;
496
- const r = ee(p);
497
- if (r.length > 0)
498
- return t.messages.errors.blankKeysMustBeUnique(r);
499
- const s = l.value.stem || "", k = ue(s);
500
- if (k.length === 0)
501
- return t.messages.errors.blankStemRequiresPlaceholders;
502
- const D = ee(k);
503
- if (D.length > 0)
504
- return t.messages.errors.duplicatePlaceholders(D);
505
- const Fe = new Set(p), pe = new Set(k), Ne = [...pe].filter((ze) => !Fe.has(ze));
506
- if (Ne.length > 0)
507
- return t.messages.errors.undefinedPlaceholders(Ne);
508
- const st = [...Fe].filter((ze) => !pe.has(ze));
509
- return st.length > 0 ? t.messages.errors.missingPlaceholders(st) : null;
510
- }
511
- function fe() {
512
- return u.value !== "quiz" || l.value.quizType !== "blank" ? null : ie();
513
- }
514
- te(() => t.initialType, (p) => {
515
- const r = m(p);
516
- u.value = r, l.value = Ae(r, t.messages, f.value), W(), _.value = "";
517
- }), te(o, () => {
518
- const p = m(u.value);
519
- p !== u.value && (u.value = p, l.value = Ae(p, t.messages, f.value), W(), _.value = "");
520
- }), te(() => t.visible, (p) => {
521
- p && (l.value = Ae(u.value, t.messages, f.value), W(), _.value = "");
522
- });
523
- function re(p) {
524
- const r = m(p);
525
- u.value = r, l.value = Ae(r, t.messages, f.value), W(), _.value = "";
526
- }
527
- const Ce = E(() => ot(u.value, l.value, t.messages));
528
- function He(p) {
529
- return o.value.find((r) => r.type === p) || { type: p, label: p, icon: "?", svgIcon: "", desc: "", color: "#666" };
530
- }
531
- const xe = E(() => He(u.value)), $e = E(() => t.refSuggestions ? t.refSuggestions : []), We = E(() => u.value === "ref_step" ? t.messages.dialog.referencedStepId : u.value === "ref_var" ? t.messages.dialog.referencedVariableId : t.messages.dialog.referencedFigureId), Ke = E(() => u.value === "ref_step" ? "step_id" : u.value === "ref_var" ? "var_id" : "fig_id");
532
- te(() => [u.value, l.value.quizType], ([p, r], [s, k]) => {
533
- p === "quiz" && (p !== s || r !== k) && (r !== k && k && (l.value.id = x(r, f.value), r === "choice" ? (l.value.stem = t.messages.defaults.questionStem, l.value.mode = "single", l.value.options = "A:, B:", l.value.answer = "A", l.value.blanks = "", l.value.rubric = "") : r === "blank" ? (l.value.stem = t.messages.defaults.fillQuestionStem, l.value.blanks = "b1:", l.value.options = "", l.value.answer = "", l.value.mode = "", l.value.rubric = "", w.value = [{ key: "b1", answer: "" }]) : r === "open" && (l.value.stem = t.messages.defaults.fillQuestionStem, l.value.rubric = "", l.value.options = "", l.value.answer = "", l.value.blanks = "", l.value.mode = "")), W());
534
- }), te(() => l.value.mode, () => {
535
- G();
536
- }), te(d, (p) => {
537
- u.value === "quiz" && l.value.quizType === "choice" && (l.value.options = J(p), G());
538
- }, { deep: !0 }), te(w, (p) => {
539
- u.value === "quiz" && l.value.quizType === "blank" && (l.value.blanks = j(p));
540
- }, { deep: !0 }), te(c, (p) => {
541
- u.value === "quiz" && l.value.quizType === "choice" && l.value.mode === "multiple" && (l.value.answer = p.join(", "));
542
- }, { deep: !0 }), te(l, () => {
543
- _.value && (_.value = "");
544
- }, { deep: !0 }), te(w, () => {
545
- _.value && (_.value = "");
546
- }, { deep: !0 });
547
- function Qe() {
548
- const p = fe();
549
- if (p) {
550
- _.value = p;
551
- return;
552
- }
553
- _.value = "", a("insert", ot(u.value, l.value, t.messages)), a("update:visible", !1);
554
- }
555
- function Ie() {
556
- a("update:visible", !1);
557
- }
558
- return (p, r) => (g(), be(lt, { to: "body" }, [
559
- e.visible ? (g(), h("div", {
560
- key: 0,
561
- class: "aimd-dialog-overlay",
562
- onClick: me(Ie, ["self"])
563
- }, [
564
- i("div", Yt, [
565
- i("div", Zt, [
566
- i("span", Gt, [
567
- i("span", {
568
- class: "aimd-dialog-icon",
569
- style: Ee({ color: xe.value.color }),
570
- innerHTML: xe.value.svgIcon
571
- }, null, 12, el),
572
- L(" " + v(t.messages.dialog.title(xe.value.label)), 1)
573
- ]),
574
- i("button", {
575
- class: "aimd-dialog-close",
576
- onClick: Ie
577
- }, "×")
578
- ]),
579
- i("div", tl, [
580
- (g(!0), h(U, null, X(o.value, (s) => (g(), h("button", {
581
- key: s.type,
582
- class: he(["aimd-type-tab", { active: u.value === s.type }]),
583
- style: Ee(u.value === s.type ? { borderColor: s.color, color: s.color, background: `${s.color}14` } : {}),
584
- onClick: (k) => re(s.type)
585
- }, [
586
- i("span", {
587
- innerHTML: s.svgIcon,
588
- class: "aimd-type-tab-icon"
589
- }, null, 8, sl),
590
- L(" " + v(s.label), 1)
591
- ], 14, ll))), 128))
592
- ]),
593
- i("div", il, [
594
- u.value === "var" ? (g(), h(U, { key: 0 }, [
595
- i("label", nl, [
596
- i("span", al, [
597
- L(v(t.messages.dialog.variableId) + " ", 1),
598
- r[22] || (r[22] = i("em", null, "*", -1))
599
- ]),
600
- S(i("input", {
601
- "onUpdate:modelValue": r[0] || (r[0] = (s) => l.value.name = s),
602
- placeholder: t.messages.placeholders.variableId,
603
- class: "aimd-field-input"
604
- }, null, 8, ol), [
605
- [q, l.value.name]
606
- ])
607
- ]),
608
- i("div", ul, [
609
- i("span", rl, v(t.messages.dialog.typePresetLabel), 1),
610
- i("span", dl, v(t.messages.dialog.typeHint), 1),
611
- i("div", cl, [
612
- (g(!0), h(U, null, X(A.value, (s) => (g(), h("button", {
613
- key: s.key,
614
- type: "button",
615
- class: he(["aimd-var-type-card", { active: P(s.value) }]),
616
- onClick: (k) => O(s.value)
617
- }, [
618
- i("span", vl, v(s.label), 1),
619
- i("span", fl, v(s.desc), 1)
620
- ], 10, ml))), 128))
621
- ])
622
- ]),
623
- ae(yt, {
624
- modelValue: l.value.type,
625
- "onUpdate:modelValue": r[1] || (r[1] = (s) => l.value.type = s),
626
- messages: e.messages,
627
- "var-type-plugins": e.varTypePlugins
628
- }, null, 8, ["modelValue", "messages", "var-type-plugins"]),
629
- i("label", pl, [
630
- i("span", gl, v(t.messages.dialog.defaultValue), 1),
631
- S(i("input", {
632
- "onUpdate:modelValue": r[2] || (r[2] = (s) => l.value.default = s),
633
- placeholder: t.messages.placeholders.defaultValue,
634
- class: "aimd-field-input"
635
- }, null, 8, hl), [
636
- [q, l.value.default]
637
- ])
638
- ]),
639
- i("label", yl, [
640
- i("span", bl, v(t.messages.dialog.titleLabel), 1),
641
- S(i("input", {
642
- "onUpdate:modelValue": r[3] || (r[3] = (s) => l.value.title = s),
643
- placeholder: t.messages.placeholders.title,
644
- class: "aimd-field-input"
645
- }, null, 8, kl), [
646
- [q, l.value.title]
647
- ])
648
- ])
649
- ], 64)) : N("", !0),
650
- u.value === "var_table" ? (g(), h(U, { key: 1 }, [
651
- i("label", wl, [
652
- i("span", Ml, [
653
- L(v(t.messages.dialog.tableId) + " ", 1),
654
- r[23] || (r[23] = i("em", null, "*", -1))
655
- ]),
656
- S(i("input", {
657
- "onUpdate:modelValue": r[4] || (r[4] = (s) => l.value.name = s),
658
- placeholder: t.messages.placeholders.tableId,
659
- class: "aimd-field-input"
660
- }, null, 8, _l), [
661
- [q, l.value.name]
662
- ])
663
- ]),
664
- i("label", Tl, [
665
- i("span", Cl, v(t.messages.dialog.subVariableColumns), 1),
666
- S(i("input", {
667
- "onUpdate:modelValue": r[5] || (r[5] = (s) => l.value.subvars = s),
668
- placeholder: t.messages.placeholders.subVariableColumns,
669
- class: "aimd-field-input"
670
- }, null, 8, xl), [
671
- [q, l.value.subvars]
672
- ]),
673
- i("span", $l, v(t.messages.dialog.subVariableColumnsHint), 1)
674
- ])
675
- ], 64)) : N("", !0),
676
- u.value === "step" ? (g(), h(U, { key: 2 }, [
677
- i("label", Il, [
678
- i("span", Fl, v(t.messages.stepField.name), 1),
679
- S(i("input", {
680
- "onUpdate:modelValue": r[6] || (r[6] = (s) => l.value.title = s),
681
- class: "aimd-field-input"
682
- }, null, 512), [
683
- [q, l.value.title]
684
- ])
685
- ]),
686
- i("label", zl, [
687
- i("span", Al, [
688
- L(v(t.messages.dialog.stepId) + " ", 1),
689
- r[24] || (r[24] = i("em", null, "*", -1))
690
- ]),
691
- S(i("input", {
692
- "onUpdate:modelValue": r[7] || (r[7] = (s) => l.value.name = s),
693
- placeholder: t.messages.placeholders.stepId,
694
- class: "aimd-field-input"
695
- }, null, 8, Vl), [
696
- [q, l.value.name]
697
- ])
698
- ]),
699
- i("label", Sl, [
700
- i("span", Dl, v(t.messages.dialog.level), 1),
701
- S(i("select", {
702
- "onUpdate:modelValue": r[8] || (r[8] = (s) => l.value.level = s),
703
- class: "aimd-field-input"
704
- }, [
705
- i("option", El, v(t.messages.dialog.level1), 1),
706
- i("option", Bl, v(t.messages.dialog.level2), 1),
707
- i("option", ql, v(t.messages.dialog.level3), 1)
708
- ], 512), [
709
- [ye, l.value.level]
710
- ])
711
- ])
712
- ], 64)) : N("", !0),
713
- u.value === "quiz" ? (g(), h(U, { key: 3 }, [
714
- i("label", Nl, [
715
- i("span", Pl, [
716
- L(v(t.messages.dialog.quizId) + " ", 1),
717
- r[25] || (r[25] = i("em", null, "*", -1))
718
- ]),
719
- S(i("input", {
720
- "onUpdate:modelValue": r[9] || (r[9] = (s) => l.value.id = s),
721
- placeholder: t.messages.placeholders.quizId,
722
- class: "aimd-field-input"
723
- }, null, 8, Ll), [
724
- [q, l.value.id]
725
- ])
726
- ]),
727
- i("label", Ul, [
728
- i("span", Rl, v(t.messages.dialog.questionType), 1),
729
- S(i("select", {
730
- "onUpdate:modelValue": r[10] || (r[10] = (s) => l.value.quizType = s),
731
- class: "aimd-field-input"
732
- }, [
733
- i("option", Ol, v(t.messages.quiz.types.choice), 1),
734
- i("option", jl, v(t.messages.quiz.types.blank), 1),
735
- i("option", Hl, v(t.messages.quiz.types.open), 1)
736
- ], 512), [
737
- [ye, l.value.quizType]
738
- ])
739
- ]),
740
- i("label", Wl, [
741
- i("span", Kl, v(t.messages.dialog.score), 1),
742
- S(i("input", {
743
- "onUpdate:modelValue": r[11] || (r[11] = (s) => l.value.score = s),
744
- placeholder: t.messages.placeholders.score,
745
- class: "aimd-field-input"
746
- }, null, 8, Ql), [
747
- [q, l.value.score]
748
- ])
749
- ]),
750
- i("label", Jl, [
751
- i("span", Xl, [
752
- L(v(t.messages.dialog.stem) + " ", 1),
753
- r[26] || (r[26] = i("em", null, "*", -1))
754
- ]),
755
- S(i("textarea", {
756
- "onUpdate:modelValue": r[12] || (r[12] = (s) => l.value.stem = s),
757
- placeholder: t.messages.placeholders.stem,
758
- class: "aimd-field-input aimd-field-textarea"
759
- }, null, 8, Yl), [
760
- [q, l.value.stem]
761
- ]),
762
- l.value.quizType === "blank" ? (g(), h("span", Zl, v(t.messages.dialog.blankStemHint), 1)) : N("", !0)
763
- ]),
764
- l.value.quizType === "choice" ? (g(), h(U, { key: 0 }, [
765
- i("label", Gl, [
766
- i("span", es, v(t.messages.dialog.mode), 1),
767
- S(i("select", {
768
- "onUpdate:modelValue": r[13] || (r[13] = (s) => l.value.mode = s),
769
- class: "aimd-field-input"
770
- }, [
771
- i("option", ts, v(t.messages.quiz.modes.single), 1),
772
- i("option", ls, v(t.messages.quiz.modes.multiple), 1)
773
- ], 512), [
774
- [ye, l.value.mode]
775
- ])
776
- ]),
777
- i("div", ss, [
778
- i("span", is, v(t.messages.dialog.options), 1),
779
- i("div", ns, [
780
- (g(!0), h(U, null, X(d.value, (s, k) => (g(), h("div", {
781
- key: `choice-option-${k}`,
782
- class: he(["aimd-collection-row aimd-option-row", { "aimd-option-row-dragover": V.value === k && y.value !== null && y.value !== k }]),
783
- onDragover: me((D) => Q(k), ["prevent"]),
784
- onDrop: me((D) => T(k), ["prevent"])
785
- }, [
786
- i("span", {
787
- class: "aimd-drag-handle",
788
- title: t.messages.dialog.dragToReorder,
789
- draggable: "true",
790
- onDragstart: (D) => R(k),
791
- onDragend: b
792
- }, " ⋮⋮ ", 40, os),
793
- S(i("input", {
794
- "onUpdate:modelValue": (D) => s.key = D,
795
- placeholder: t.messages.placeholders.optionKey,
796
- class: "aimd-field-input"
797
- }, null, 8, us), [
798
- [q, s.key]
799
- ]),
800
- S(i("input", {
801
- "onUpdate:modelValue": (D) => s.text = D,
802
- placeholder: t.messages.placeholders.optionText,
803
- class: "aimd-field-input"
804
- }, null, 8, rs), [
805
- [q, s.text]
806
- ]),
807
- i("label", ds, [
808
- l.value.mode === "single" ? S((g(), h("input", {
809
- key: 0,
810
- "onUpdate:modelValue": r[14] || (r[14] = (D) => l.value.answer = D),
811
- type: "radio",
812
- name: "aimd-quiz-choice-answer",
813
- value: s.key.trim(),
814
- disabled: !s.key.trim()
815
- }, null, 8, cs)), [
816
- [bt, l.value.answer]
817
- ]) : S((g(), h("input", {
818
- key: 1,
819
- "onUpdate:modelValue": r[15] || (r[15] = (D) => c.value = D),
820
- type: "checkbox",
821
- value: s.key.trim(),
822
- disabled: !s.key.trim()
823
- }, null, 8, ms)), [
824
- [vt, c.value]
825
- ]),
826
- i("span", null, v(t.messages.dialog.correctAnswer), 1)
827
- ]),
828
- i("button", {
829
- type: "button",
830
- class: "aimd-mini-btn",
831
- disabled: d.value.length <= 1,
832
- onClick: (D) => z(k)
833
- }, v(t.messages.common.remove), 9, vs)
834
- ], 42, as))), 128)),
835
- i("button", {
836
- type: "button",
837
- class: "aimd-mini-btn aimd-mini-btn-add",
838
- onClick: M
839
- }, v(t.messages.actions.addOption), 1)
840
- ]),
841
- i("span", fs, v(t.messages.dialog.optionsHint), 1)
842
- ])
843
- ], 64)) : l.value.quizType === "blank" ? (g(), h("div", ps, [
844
- i("span", gs, v(t.messages.dialog.blanks), 1),
845
- i("div", hs, [
846
- (g(!0), h(U, null, X(w.value, (s, k) => (g(), h("div", {
847
- key: `blank-item-${k}`,
848
- class: "aimd-collection-row"
849
- }, [
850
- S(i("input", {
851
- "onUpdate:modelValue": (D) => s.key = D,
852
- placeholder: t.messages.placeholders.blankKey,
853
- class: "aimd-field-input"
854
- }, null, 8, ys), [
855
- [q, s.key]
856
- ]),
857
- S(i("input", {
858
- "onUpdate:modelValue": (D) => s.answer = D,
859
- placeholder: t.messages.placeholders.blankAnswer,
860
- class: "aimd-field-input"
861
- }, null, 8, bs), [
862
- [q, s.answer]
863
- ]),
864
- i("button", {
865
- type: "button",
866
- class: "aimd-mini-btn",
867
- disabled: w.value.length <= 1,
868
- onClick: (D) => Y(k)
869
- }, v(t.messages.common.remove), 9, ks)
870
- ]))), 128)),
871
- i("button", {
872
- type: "button",
873
- class: "aimd-mini-btn aimd-mini-btn-add",
874
- onClick: K
875
- }, v(t.messages.actions.addBlank), 1)
876
- ]),
877
- i("span", ws, v(t.messages.dialog.blanksHint), 1)
878
- ])) : (g(), h("label", Ms, [
879
- i("span", _s, v(t.messages.dialog.rubric), 1),
880
- S(i("textarea", {
881
- "onUpdate:modelValue": r[16] || (r[16] = (s) => l.value.rubric = s),
882
- placeholder: t.messages.placeholders.rubric,
883
- class: "aimd-field-input aimd-field-textarea"
884
- }, null, 8, Ts), [
885
- [q, l.value.rubric]
886
- ])
887
- ]))
888
- ], 64)) : N("", !0),
889
- u.value === "check" ? (g(), h(U, { key: 4 }, [
890
- i("label", Cs, [
891
- i("span", xs, v(t.messages.checkField.name), 1),
892
- S(i("input", {
893
- "onUpdate:modelValue": r[17] || (r[17] = (s) => l.value.title = s),
894
- class: "aimd-field-input"
895
- }, null, 512), [
896
- [q, l.value.title]
897
- ])
898
- ]),
899
- i("label", $s, [
900
- i("span", Is, [
901
- L(v(t.messages.dialog.checkpointId) + " ", 1),
902
- r[27] || (r[27] = i("em", null, "*", -1))
903
- ]),
904
- S(i("input", {
905
- "onUpdate:modelValue": r[18] || (r[18] = (s) => l.value.name = s),
906
- placeholder: t.messages.placeholders.checkpointId,
907
- class: "aimd-field-input"
908
- }, null, 8, Fs), [
909
- [q, l.value.name]
910
- ])
911
- ]),
912
- i("label", zs, [
913
- i("span", As, v(t.messages.checkField.checkedMessage), 1),
914
- S(i("input", {
915
- "onUpdate:modelValue": r[19] || (r[19] = (s) => l.value.checkedMessage = s),
916
- class: "aimd-field-input"
917
- }, null, 512), [
918
- [q, l.value.checkedMessage]
919
- ])
920
- ])
921
- ], 64)) : N("", !0),
922
- ["ref_step", "ref_var", "ref_fig"].includes(u.value) ? (g(), h("label", Vs, [
923
- i("span", Ss, [
924
- L(v(We.value) + " ", 1),
925
- r[28] || (r[28] = i("em", null, "*", -1))
926
- ]),
927
- S(i("input", {
928
- "onUpdate:modelValue": r[20] || (r[20] = (s) => l.value.name = s),
929
- placeholder: Ke.value,
930
- class: "aimd-field-input",
931
- list: "aimd-ref-suggestions"
932
- }, null, 8, Ds), [
933
- [q, l.value.name]
934
- ]),
935
- i("datalist", Es, [
936
- (g(!0), h(U, null, X($e.value, (s) => (g(), h("option", {
937
- key: s,
938
- value: s
939
- }, null, 8, Bs))), 128))
940
- ]),
941
- $e.value.length ? (g(), h("span", qs, v(t.messages.common.available) + ": " + v($e.value.join(", ")), 1)) : N("", !0)
942
- ])) : N("", !0),
943
- u.value === "cite" ? (g(), h("label", Ns, [
944
- i("span", Ps, [
945
- L(v(t.messages.dialog.citationId) + " ", 1),
946
- r[29] || (r[29] = i("em", null, "*", -1))
947
- ]),
948
- S(i("input", {
949
- "onUpdate:modelValue": r[21] || (r[21] = (s) => l.value.refs = s),
950
- placeholder: t.messages.placeholders.citationIds,
951
- class: "aimd-field-input"
952
- }, null, 8, Ls), [
953
- [q, l.value.refs]
954
- ]),
955
- i("span", Us, v(t.messages.dialog.citationHint), 1)
956
- ])) : N("", !0),
957
- i("div", Rs, [
958
- i("div", Os, v(t.messages.common.preview), 1),
959
- i("pre", js, [
960
- i("code", Hs, v(Ce.value), 1)
961
- ])
962
- ]),
963
- _.value ? (g(), h("div", Ws, v(_.value), 1)) : N("", !0)
964
- ]),
965
- i("div", Ks, [
966
- i("button", {
967
- class: "aimd-btn aimd-btn-cancel",
968
- onClick: Ie
969
- }, v(t.messages.common.cancel), 1),
970
- i("button", {
971
- class: "aimd-btn aimd-btn-primary",
972
- onClick: Qe
973
- }, v(t.messages.common.insert), 1)
974
- ])
975
- ])
976
- ])) : N("", !0)
977
- ]));
978
- }
979
- }), Js = ["aria-label"], Xs = ["value"], Ys = { class: "aimd-input-dialog__required" }, Zs = ["checked"], Gs = { key: 0 }, ei = { key: 1 }, ti = ["value"], li = ["value"], si = ["size"], ii = ["value", "selected"], ni = { value: "" }, ai = ["value"], oi = ["value", "type", "step", "placeholder"], ui = ["open"], ri = {
980
- key: 3,
981
- class: "aimd-input-dialog__error",
982
- role: "alert"
983
- }, di = {
984
- type: "submit",
985
- class: "aimd-input-dialog__save"
986
- }, de = "bool | None", Pe = "Literal[True, False]", ci = /* @__PURE__ */ ve({
987
- __name: "AimdInputFieldDialog",
988
- props: {
989
- visible: { type: Boolean },
990
- content: {},
991
- fieldContent: {},
992
- messages: {},
993
- varTypePlugins: {},
994
- reservedIds: {},
995
- initialPreset: {}
996
- },
997
- emits: ["update:visible", "save"],
998
- setup(e, { emit: n }) {
999
- const t = e, a = n, o = $(), m = $(), f = $(""), u = $(""), l = $("str"), d = $(""), w = $(""), c = $("str"), y = $(""), V = $(!1), _ = $(), A = $(!1), I = E(() => _.value ?? !De(l.value)), P = E(() => w.value.split(/\r?\n/).map((T) => T.trim()).filter(Boolean)), O = E(() => /^(?:(?:typing|typing_extensions)\.)?Optional\[/.test(l.value.trim()) ? Ve(Ve(l.value, !1), !0) : ""), x = E(() => {
1000
- const T = Se(d.value);
1001
- return Array.isArray(T) ? T : [];
1002
- });
1003
- function F(T) {
1004
- const b = Array.from(T.target.selectedOptions, (C) => C.value);
1005
- d.value = b.length ? JSON.stringify(b) : I.value ? "" : "None";
1006
- }
1007
- const J = E(() => c.value === de || c.value === "bool" ? [["True", t.messages.inputField.yes], ["False", t.messages.inputField.no]] : c.value === "choice" ? P.value.map((T) => [JSON.stringify(T), T]) : []);
1008
- function ne(T) {
1009
- const b = Se(T);
1010
- return J.value.find(([C]) => Object.is(Se(C), b))?.[0];
1011
- }
1012
- const j = E(() => ["str", "date", "time", "datetime"].includes(c.value)), H = E(() => c.value === "int" || c.value === "float" ? "number" : c.value === "date" || c.value === "time" ? c.value : "text"), W = E({
1013
- get() {
1014
- return d.value === "None" ? "" : j.value && /^(['"]).*\1$/s.test(d.value) ? String(Se(d.value)) : J.value.length && d.value ? ne(d.value) ?? d.value : d.value;
1015
- },
1016
- set(T) {
1017
- d.value = T === "" ? I.value ? "" : "None" : j.value ? JSON.stringify(T) : T;
1018
- }
1019
- }), G = pt().filter((T) => tt(T)?.storage_kind === "file-id"), le = E(() => [
1020
- ["str", t.messages.inputField.text],
1021
- ["int", t.messages.inputField.integer],
1022
- ["float", t.messages.inputField.number],
1023
- ["choice", t.messages.inputField.choice],
1024
- ["multiple-choice", t.messages.inputField.multipleChoice],
1025
- ["bool | None", t.messages.inputField.boolean],
1026
- ["bool", t.messages.inputField.checkbox],
1027
- ["date", t.messages.inputField.date],
1028
- ["time", t.messages.inputField.time],
1029
- ["datetime", t.messages.inputField.datetime],
1030
- ["file", t.messages.inputField.file],
1031
- ["list[str]", t.messages.inputField.list],
1032
- ...(t.varTypePlugins ?? []).map((T) => [T.value, T.label]),
1033
- ["custom", t.messages.inputField.custom]
1034
- ]);
1035
- te(() => t.visible, async (T) => {
1036
- if (!T) {
1037
- o.value?.close();
1038
- return;
1039
- }
1040
- const b = t.fieldContent ? Ye(t.fieldContent) : void 0;
1041
- f.value = b?.id ?? _e([...Te(t.content), ...t.reservedIds ?? []]), u.value = typeof b?.kwargs?.title == "string" ? b.kwargs.title : "", l.value = b?.type ?? (t.initialPreset === "file" ? "FileIdPDF" : ["choice", "multiple-choice", "custom"].includes(t.initialPreset ?? "") ? "str" : t.initialPreset ?? "str"), d.value = b?.defaultRaw ?? "", _.value = typeof b?.kwargs?.required == "boolean" ? b.kwargs.required : void 0, A.value = !1;
1042
- const C = ce(l.value);
1043
- c.value = l.value === Pe || C === "bool" && De(l.value) ? de : le.value.some(([ie]) => ie === C) ? C : "custom";
1044
- const K = Ze(l.value), Y = K.length ? K : b?.enum, ue = (Array.isArray(b?.kwargs?.enum) || /^(?:(?:typing|typing_extensions)\.)?(?:(?:list|List)\s*\[\s*(?:(?:typing|typing_extensions)\.)?)?Literal\s*\[/.test(ce(l.value))) && Array.isArray(Y) && Y.every((ie) => typeof ie == "string" && !ie.includes(`
1045
- `));
1046
- ue && (c.value = K.length ? "multiple-choice" : "choice"), G.includes(ce(l.value)) && (c.value = "file"), !b && t.initialPreset && (c.value = t.initialPreset), !b && c.value === de && (l.value = Pe), w.value = ue ? Y.join(`
1047
- `) : "", V.value = c.value === "custom", y.value = "", await Re(), o.value?.showModal(), m.value?.focus();
1048
- }, { immediate: !0 });
1049
- function M() {
1050
- const T = !I.value;
1051
- c.value === de ? l.value = T ? de : Pe : ["custom", "choice", "multiple-choice", "file"].includes(c.value) || (l.value = Ve(c.value, T)), c.value === "file" && !G.includes(ce(l.value)) && (l.value = Ve("FileIdPDF", T)), c.value === "custom" && (V.value = !0);
1052
- }
1053
- function z(T) {
1054
- A.value = !0, _.value = void 0, c.value === de ? l.value = T ? Pe : de : l.value = Ve(l.value, !T), c.value === "bool" && !T && (c.value = de), T && d.value === "None" && (d.value = ""), !T && !d.value.trim() && (d.value = "None");
1055
- }
1056
- function R(T) {
1057
- l.value = T.target.value + (De(l.value) ? " | None" : "");
1058
- }
1059
- function Q() {
1060
- const T = /* @__PURE__ */ new Set([...Te(t.content), ...t.reservedIds ?? []]), b = t.fieldContent ? Ye(t.fieldContent) : void 0, C = b?.id, K = f.value.trim() || _e(T);
1061
- if (!gt.test(K)) {
1062
- y.value = t.messages.inputField.invalidId, V.value = !0;
1063
- return;
1064
- }
1065
- if (K !== C && T.has(K)) {
1066
- y.value = t.messages.inputField.duplicateId, V.value = !0;
1067
- return;
1068
- }
1069
- let Y = l.value;
1070
- if (c.value === "choice" || c.value === "multiple-choice") {
1071
- if (!P.value.length || new Set(P.value).size !== P.value.length) {
1072
- y.value = t.messages.inputField.invalidOptions;
1073
- return;
1074
- }
1075
- Y = `Literal[${P.value.map((Ce) => JSON.stringify(Ce)).join(", ")}]`, c.value === "multiple-choice" && (Y = `list[${Y}]`), De(l.value) && (Y += " | None");
1076
- const re = c.value === "multiple-choice" ? Ze(b?.type) : b?.enum;
1077
- b?.type === l.value && !b?.kwargs?.enum && JSON.stringify(P.value) === JSON.stringify(re) && Ze(b.type).length > 0 == (c.value === "multiple-choice") && (Y = l.value);
1078
- }
1079
- const ee = d.value.trim(), ue = c.value === "multiple-choice" && ee && ee !== "None" && (!Array.isArray(Se(ee)) || x.value.some((re) => !P.value.includes(re)));
1080
- if (I.value && ee === "None" || J.value.length && ee && ee !== "None" && !ne(ee) || ue) {
1081
- y.value = t.messages.inputField.invalidDefault;
1082
- return;
1083
- }
1084
- const ie = St(t.fieldContent, {
1085
- id: K,
1086
- type: Y,
1087
- title: u.value,
1088
- defaultRaw: ee,
1089
- clearRequiredOverride: A.value,
1090
- clearEnum: c.value === "choice" || c.value === "multiple-choice" || ce(Y) !== ce(b?.type)
1091
- }), fe = At(Ye(ie));
1092
- if (fe.length) {
1093
- y.value = fe.join(" "), V.value = !0;
1094
- return;
1095
- }
1096
- a("save", ie), a("update:visible", !1);
1097
- }
1098
- return (T, b) => (g(), be(lt, { to: "body" }, [
1099
- i("dialog", {
1100
- ref_key: "dialog",
1101
- ref: o,
1102
- class: "aimd-input-dialog",
1103
- "aria-label": e.fieldContent ? e.messages.inputField.edit : e.messages.inputField.insert,
1104
- onClose: b[12] || (b[12] = (C) => a("update:visible", !1)),
1105
- onCancel: b[13] || (b[13] = (C) => a("update:visible", !1))
1106
- }, [
1107
- i("form", {
1108
- onSubmit: me(Q, ["prevent"])
1109
- }, [
1110
- i("h2", null, v(e.fieldContent ? e.messages.inputField.edit : e.messages.inputField.insert), 1),
1111
- i("label", null, [
1112
- L(v(e.messages.inputField.name), 1),
1113
- S(i("input", {
1114
- ref_key: "nameInput",
1115
- ref: m,
1116
- "onUpdate:modelValue": b[0] || (b[0] = (C) => u.value = C),
1117
- name: "title",
1118
- autocomplete: "off"
1119
- }, null, 512), [
1120
- [q, u.value]
1121
- ])
1122
- ]),
1123
- i("label", null, [
1124
- L(v(e.messages.dialog.type) + " ", 1),
1125
- S(i("select", {
1126
- "onUpdate:modelValue": b[1] || (b[1] = (C) => c.value = C),
1127
- name: "preset",
1128
- onChange: M
1129
- }, [
1130
- (g(!0), h(U, null, X(le.value, ([C, K]) => (g(), h("option", {
1131
- key: C,
1132
- value: C
1133
- }, v(K), 9, Xs))), 128))
1134
- ], 544), [
1135
- [ye, c.value]
1136
- ])
1137
- ]),
1138
- i("label", Ys, [
1139
- L(v(e.messages.inputField.required) + " ", 1),
1140
- i("input", {
1141
- name: "required",
1142
- type: "checkbox",
1143
- role: "switch",
1144
- checked: I.value,
1145
- onChange: b[2] || (b[2] = (C) => z(C.target.checked))
1146
- }, null, 40, Zs)
1147
- ]),
1148
- c.value === "choice" || c.value === "multiple-choice" ? (g(), h("label", Gs, [
1149
- L(v(e.messages.inputField.options), 1),
1150
- S(i("textarea", {
1151
- "onUpdate:modelValue": b[3] || (b[3] = (C) => w.value = C),
1152
- name: "options",
1153
- rows: "4"
1154
- }, null, 512), [
1155
- [q, w.value]
1156
- ])
1157
- ])) : N("", !0),
1158
- c.value === "file" ? (g(), h("label", ei, [
1159
- L(v(e.messages.inputField.fileFormat), 1),
1160
- i("select", {
1161
- name: "fileType",
1162
- value: Z(ce)(l.value),
1163
- onChange: R
1164
- }, [
1165
- (g(!0), h(U, null, X(Z(G), (C) => (g(), h("option", {
1166
- key: C,
1167
- value: C
1168
- }, v(C.replace(/^FileId/, "")), 9, li))), 128))
1169
- ], 40, ti)
1170
- ])) : N("", !0),
1171
- i("label", null, [
1172
- L(v(e.messages.dialog.defaultValue) + " ", 1),
1173
- c.value === "multiple-choice" ? (g(), h("select", {
1174
- key: 0,
1175
- name: "default",
1176
- multiple: "",
1177
- size: Math.min(4, Math.max(2, P.value.length)),
1178
- onChange: F
1179
- }, [
1180
- (g(!0), h(U, null, X(P.value, (C) => (g(), h("option", {
1181
- key: C,
1182
- value: C,
1183
- selected: x.value.includes(C)
1184
- }, v(C), 9, ii))), 128))
1185
- ], 40, si)) : J.value.length || c.value === "choice" ? S((g(), h("select", {
1186
- key: 1,
1187
- "onUpdate:modelValue": b[4] || (b[4] = (C) => W.value = C),
1188
- name: "default"
1189
- }, [
1190
- i("option", ni, v(e.messages.inputField.noDefault), 1),
1191
- (g(!0), h(U, null, X(J.value, ([C, K]) => (g(), h("option", {
1192
- key: C,
1193
- value: C
1194
- }, v(K), 9, ai))), 128))
1195
- ], 512)), [
1196
- [ye, W.value]
1197
- ]) : (g(), h("input", {
1198
- key: 2,
1199
- value: W.value,
1200
- name: "default",
1201
- type: H.value,
1202
- step: c.value === "float" ? "any" : void 0,
1203
- placeholder: e.messages.inputField.noDefault,
1204
- onInput: b[5] || (b[5] = (C) => W.value = C.target.value)
1205
- }, null, 40, oi))
1206
- ]),
1207
- O.value ? (g(), h("button", {
1208
- key: 2,
1209
- type: "button",
1210
- onClick: b[6] || (b[6] = (C) => l.value = O.value)
1211
- }, v(e.messages.inputField.useType(O.value)), 1)) : N("", !0),
1212
- i("details", {
1213
- open: V.value,
1214
- onToggle: b[10] || (b[10] = (C) => V.value = C.target.open)
1215
- }, [
1216
- i("summary", null, v(e.messages.inputField.advanced), 1),
1217
- i("label", null, [
1218
- L(v(e.messages.inputField.id), 1),
1219
- S(i("input", {
1220
- "onUpdate:modelValue": b[7] || (b[7] = (C) => f.value = C),
1221
- name: "id",
1222
- autocomplete: "off",
1223
- spellcheck: "false"
1224
- }, null, 512), [
1225
- [q, f.value]
1226
- ])
1227
- ]),
1228
- ae(yt, {
1229
- modelValue: l.value,
1230
- "onUpdate:modelValue": [
1231
- b[8] || (b[8] = (C) => l.value = C),
1232
- b[9] || (b[9] = (C) => c.value = "custom")
1233
- ],
1234
- messages: e.messages,
1235
- "var-type-plugins": e.varTypePlugins
1236
- }, null, 8, ["modelValue", "messages", "var-type-plugins"])
1237
- ], 40, ui),
1238
- y.value ? (g(), h("p", ri, v(y.value), 1)) : N("", !0),
1239
- i("footer", null, [
1240
- i("button", {
1241
- type: "button",
1242
- onClick: b[11] || (b[11] = (C) => a("update:visible", !1))
1243
- }, v(e.messages.common.cancel), 1),
1244
- i("button", di, v(e.fieldContent ? e.messages.inputField.save : e.messages.common.insert), 1)
1245
- ])
1246
- ], 32)
1247
- ], 40, Js)
1248
- ]));
1249
- }
1250
- }), mi = /* @__PURE__ */ je(ci, [["__scopeId", "data-v-e4307a72"]]), vi = ["aria-label"], fi = {
1251
- key: 0,
1252
- class: "aimd-step-dialog__check"
1253
- }, pi = ["open"], gi = ["readonly"], hi = { key: 0 }, yi = ["value"], bi = { value: "elapsed" }, ki = { value: "countdown" }, wi = { value: "both" }, Mi = {
1254
- key: 1,
1255
- role: "alert"
1256
- }, _i = {
1257
- type: "submit",
1258
- class: "aimd-step-dialog__save"
1259
- }, Ti = /* @__PURE__ */ ve({
1260
- __name: "AimdStepFieldDialog",
1261
- props: {
1262
- visible: { type: Boolean },
1263
- content: {},
1264
- fieldContent: {},
1265
- fieldType: {},
1266
- reservedIds: {},
1267
- messages: {}
1268
- },
1269
- emits: ["update:visible", "save"],
1270
- setup(e, { emit: n }) {
1271
- const t = e, a = n, o = $(), m = $(), f = $(""), u = $(""), l = $(1), d = $(!0), w = $(""), c = $("elapsed"), y = $(""), V = $(!1), _ = $(""), A = E(() => t.fieldType === "check"), I = E(() => A.value ? t.messages.checkField : t.messages.stepField);
1272
- te(() => t.visible, async (O) => {
1273
- if (!O) {
1274
- o.value?.close();
1275
- return;
1276
- }
1277
- const x = t.fieldContent && !A.value ? ut(t.fieldContent) : void 0, F = t.fieldContent && A.value ? Vt(t.fieldContent) : void 0;
1278
- f.value = (F ?? x)?.id ?? _e([...Te(t.content), ...t.reservedIds ?? []], A.value ? "check" : "step"), u.value = (F ?? x)?.title ?? "", _.value = F?.checked_message ?? "", l.value = x?.level ?? 1, d.value = x?.check ?? !0, w.value = String(x?.props.duration ?? ""), c.value = x?.timer_mode ?? "elapsed", y.value = "", V.value = !1, await Re(), o.value?.showModal(), m.value?.focus();
1279
- }, { immediate: !0 });
1280
- function P() {
1281
- const O = /* @__PURE__ */ new Set([...Te(t.content), ...t.reservedIds ?? []]), x = f.value.trim() || _e(O, A.value ? "check" : "step");
1282
- if (!gt.test(x)) {
1283
- y.value = t.messages.inputField.invalidId, V.value = !0;
1284
- return;
1285
- }
1286
- if (!t.fieldContent && O.has(x)) {
1287
- y.value = t.messages.inputField.duplicateId, V.value = !0;
1288
- return;
1289
- }
1290
- if (A.value) {
1291
- a("save", Dt(t.fieldContent, { id: x, title: u.value, checkedMessage: _.value })), a("update:visible", !1);
1292
- return;
1293
- }
1294
- const F = Et(t.fieldContent, { id: x, title: u.value, level: l.value, check: d.value, duration: w.value, timer: c.value }), J = ut(F);
1295
- if (w.value.trim() && J.estimated_duration_ms === void 0 || c.value !== "elapsed" && !J.estimated_duration_ms) {
1296
- y.value = t.messages.stepField.invalidDuration, V.value = !0;
1297
- return;
1298
- }
1299
- a("save", F), a("update:visible", !1);
1300
- }
1301
- return (O, x) => (g(), be(lt, { to: "body" }, [
1302
- i("dialog", {
1303
- ref_key: "dialog",
1304
- ref: o,
1305
- class: "aimd-step-dialog",
1306
- "aria-label": e.fieldContent ? I.value.edit : I.value.insert,
1307
- onClose: x[9] || (x[9] = (F) => a("update:visible", !1)),
1308
- onCancel: x[10] || (x[10] = (F) => a("update:visible", !1))
1309
- }, [
1310
- i("form", {
1311
- onSubmit: me(P, ["prevent"])
1312
- }, [
1313
- i("h2", null, v(e.fieldContent ? I.value.edit : I.value.insert), 1),
1314
- i("label", null, [
1315
- L(v(I.value.name), 1),
1316
- S(i("input", {
1317
- ref_key: "nameInput",
1318
- ref: m,
1319
- "onUpdate:modelValue": x[0] || (x[0] = (F) => u.value = F),
1320
- name: "title",
1321
- autocomplete: "off"
1322
- }, null, 512), [
1323
- [q, u.value]
1324
- ])
1325
- ]),
1326
- A.value ? N("", !0) : (g(), h("label", fi, [
1327
- S(i("input", {
1328
- "onUpdate:modelValue": x[1] || (x[1] = (F) => d.value = F),
1329
- name: "check",
1330
- type: "checkbox"
1331
- }, null, 512), [
1332
- [vt, d.value]
1333
- ]),
1334
- L(v(e.messages.stepField.check), 1)
1335
- ])),
1336
- i("details", {
1337
- open: V.value,
1338
- onToggle: x[7] || (x[7] = (F) => V.value = F.target.open)
1339
- }, [
1340
- i("summary", null, v(e.messages.inputField.advanced), 1),
1341
- i("label", null, [
1342
- L(v(I.value.id), 1),
1343
- S(i("input", {
1344
- "onUpdate:modelValue": x[2] || (x[2] = (F) => f.value = F),
1345
- name: "id",
1346
- readonly: !!e.fieldContent,
1347
- autocomplete: "off",
1348
- spellcheck: "false"
1349
- }, null, 8, gi), [
1350
- [q, f.value]
1351
- ])
1352
- ]),
1353
- A.value ? (g(), h("label", hi, [
1354
- L(v(e.messages.checkField.checkedMessage), 1),
1355
- S(i("input", {
1356
- "onUpdate:modelValue": x[3] || (x[3] = (F) => _.value = F),
1357
- name: "checkedMessage"
1358
- }, null, 512), [
1359
- [q, _.value]
1360
- ])
1361
- ])) : (g(), h(U, { key: 1 }, [
1362
- i("label", null, [
1363
- L(v(e.messages.dialog.level), 1),
1364
- S(i("select", {
1365
- "onUpdate:modelValue": x[4] || (x[4] = (F) => l.value = F),
1366
- name: "level"
1367
- }, [
1368
- (g(), h(U, null, X(3, (F) => i("option", {
1369
- key: F,
1370
- value: F
1371
- }, v(F), 9, yi)), 64))
1372
- ], 512), [
1373
- [ye, l.value]
1374
- ])
1375
- ]),
1376
- i("label", null, [
1377
- L(v(e.messages.stepField.duration), 1),
1378
- S(i("input", {
1379
- "onUpdate:modelValue": x[5] || (x[5] = (F) => w.value = F),
1380
- name: "duration",
1381
- placeholder: "2m"
1382
- }, null, 512), [
1383
- [q, w.value]
1384
- ])
1385
- ]),
1386
- i("label", null, [
1387
- L(v(e.messages.stepField.timer), 1),
1388
- S(i("select", {
1389
- "onUpdate:modelValue": x[6] || (x[6] = (F) => c.value = F),
1390
- name: "timer"
1391
- }, [
1392
- i("option", bi, v(e.messages.stepField.elapsed), 1),
1393
- i("option", ki, v(e.messages.stepField.countdown), 1),
1394
- i("option", wi, v(e.messages.stepField.both), 1)
1395
- ], 512), [
1396
- [ye, c.value]
1397
- ])
1398
- ])
1399
- ], 64))
1400
- ], 40, pi),
1401
- y.value ? (g(), h("p", Mi, v(y.value), 1)) : N("", !0),
1402
- i("footer", null, [
1403
- i("button", {
1404
- type: "button",
1405
- onClick: x[8] || (x[8] = (F) => a("update:visible", !1))
1406
- }, v(e.messages.common.cancel), 1),
1407
- i("button", _i, v(e.fieldContent ? e.messages.inputField.save : e.messages.common.insert), 1)
1408
- ])
1409
- ], 32)
1410
- ], 40, vi)
1411
- ]));
1412
- }
1413
- }), Ci = /* @__PURE__ */ je(Ti, [["__scopeId", "data-v-fc5a778d"]]);
1414
- const ge = {
1415
- xmlns: "http://www.w3.org/2000/svg",
1416
- width: 24,
1417
- height: 24,
1418
- viewBox: "0 0 24 24",
1419
- fill: "none",
1420
- stroke: "currentColor",
1421
- "stroke-width": 2,
1422
- "stroke-linecap": "round",
1423
- "stroke-linejoin": "round"
1424
- };
1425
- const dt = (...e) => e.filter((n, t, a) => !!n && n.trim() !== "" && a.indexOf(n) === t).join(" ").trim();
1426
- function Ge(e) {
1427
- return e != null;
1428
- }
1429
- function xi(e, n = {}) {
1430
- const t = n.attributeNames ?? {}, a = (y) => t[y] ?? y, o = e.size ?? e.width ?? ge.width, m = e.size ?? e.height ?? ge.height, f = e.aliases?.filter((y) => typeof y == "string" && y.trim() !== "").map((y) => `lucide-${y}`) ?? [], u = [...e.name ? [`lucide-${e.name}`] : [], ...f], l = n.className?.split(" ").filter(Boolean) ?? [], d = n.includeDefaultClasses === !1 ? dt(...l) : dt("lucide", ...u, ...l), w = n.absoluteStrokeWidth ? Number(n.strokeWidth ?? ge["stroke-width"]) * Number(e.size ?? e.width ?? ge.width) / Number(n.size ?? n.width ?? ge.width) : n.strokeWidth ?? ge["stroke-width"];
1431
- return [
1432
- "svg",
1433
- {
1434
- ...Object.entries(ge).reduce((y, [V, _]) => (y[a(V)] = _, y), {}),
1435
- ..."color" in n && n.color && {
1436
- [a("stroke")]: n.color
1437
- },
1438
- ..."size" in n && Ge(n.size) && {
1439
- [a("width")]: n.size,
1440
- [a("height")]: n.size
1441
- },
1442
- ..."width" in n && Ge(n.width) && {
1443
- [a("width")]: n.width
1444
- },
1445
- ..."height" in n && Ge(n.height) && {
1446
- [a("height")]: n.height
1447
- },
1448
- [a("stroke-width")]: w,
1449
- ...d && {
1450
- [a("class")]: d
1451
- },
1452
- [a("viewBox")]: `0 0 ${o} ${m}`,
1453
- ...n.hasA11yProp === !1 ? {
1454
- [a("aria-hidden")]: "true"
1455
- } : {},
1456
- ..."attributes" in n && n.attributes
1457
- },
1458
- e.node.map((y) => {
1459
- const [V, _, A] = y, I = n.nonScalingStroke ? { [a("vector-effect")]: "non-scaling-stroke", ..._ } : _;
1460
- return A ? [V, I, A] : [V, I];
1461
- })
1462
- ];
1463
- }
1464
- const $i = (e) => {
1465
- for (const n in e)
1466
- if (n.startsWith("aria-") || n === "role" || n === "title")
1467
- return !0;
1468
- return !1;
1469
- };
1470
- const Le = (e) => e === "";
1471
- const Ii = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1472
- const Fi = /* @__PURE__ */ Symbol("lucide-icons");
1473
- function zi() {
1474
- return kt(Fi, {});
1475
- }
1476
- const Ai = ({
1477
- name: e,
1478
- iconNode: n,
1479
- "icon-node": t,
1480
- icon: a = {
1481
- name: e && Ii(e),
1482
- node: n ?? t ?? [],
1483
- size: 24,
1484
- aliases: []
1485
- },
1486
- absoluteStrokeWidth: o,
1487
- "absolute-stroke-width": m,
1488
- nonScalingStroke: f,
1489
- "non-scaling-stroke": u,
1490
- strokeWidth: l,
1491
- "stroke-width": d,
1492
- size: w,
1493
- width: c = w,
1494
- height: y = w,
1495
- color: V,
1496
- ..._
1497
- }, { slots: A }) => {
1498
- const {
1499
- size: I,
1500
- color: P,
1501
- strokeWidth: O = 2,
1502
- absoluteStrokeWidth: x = !1,
1503
- nonScalingStroke: F = !1,
1504
- class: J = ""
1505
- } = zi(), ne = Le(o) || Le(m) || o === !0 || m === !0 || x === !0, j = Le(f) || Le(u) || f === !0 || u === !0 || F === !0;
1506
- delete _.class;
1507
- const H = A.default?.(), [, W, G = []] = xi(a, {
1508
- color: V ?? P,
1509
- width: c ?? w ?? I,
1510
- height: y ?? w ?? I,
1511
- strokeWidth: l ?? d ?? O,
1512
- absoluteStrokeWidth: ne,
1513
- nonScalingStroke: j,
1514
- className: J,
1515
- hasA11yProp: H != null && H.length > 0 || $i(_),
1516
- attributes: _
1517
- });
1518
- return et("svg", W, [
1519
- ...G.map(([le, M]) => et(le, M)),
1520
- ...H ?? []
1521
- ]);
1522
- };
1523
- function se(e, n = []) {
1524
- const t = typeof e == "string" ? {
1525
- name: e,
1526
- node: n
1527
- } : e;
1528
- return (a, { slots: o }) => et(
1529
- Ai,
1530
- {
1531
- ...a,
1532
- icon: t
1533
- },
1534
- o.default ? { default: o.default } : void 0
1535
- );
1536
- }
1537
- const Vi = {
1538
- name: "calendar-days",
1539
- size: 24,
1540
- node: [
1541
- ["path", { d: "M8 2v3", key: "1ioesn" }],
1542
- ["path", { d: "M16 2v3", key: "otl347" }],
1543
- ["rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", key: "h1oib" }],
1544
- ["path", { d: "M3 9h18", key: "1pudct" }],
1545
- ["path", { d: "M8 13h.01", key: "1sbv64" }],
1546
- ["path", { d: "M12 13h.01", key: "y0uutt" }],
1547
- ["path", { d: "M16 13h.01", key: "wip0gl" }],
1548
- ["path", { d: "M8 17h.01", key: "p3bg7i" }],
1549
- ["path", { d: "M12 17h.01", key: "p32p05" }],
1550
- ["path", { d: "M16 17h.01", key: "ql8jdd" }]
1551
- ]
1552
- }, ct = se(Vi);
1553
- const Si = {
1554
- name: "chevron-down",
1555
- size: 24,
1556
- node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
1557
- }, Di = se(Si);
1558
- const Ei = {
1559
- name: "circle-dot",
1560
- size: 24,
1561
- node: [
1562
- ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
1563
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
1564
- ]
1565
- }, Bi = se(Ei);
1566
- const qi = {
1567
- name: "clock",
1568
- size: 24,
1569
- node: [
1570
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
1571
- ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }]
1572
- ]
1573
- }, Ni = se(qi);
1574
- const Pi = {
1575
- name: "hash",
1576
- size: 24,
1577
- node: [
1578
- ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
1579
- ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
1580
- ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
1581
- ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
1582
- ]
1583
- }, mt = se(Pi);
1584
- const Li = {
1585
- name: "list-checks",
1586
- size: 24,
1587
- node: [
1588
- ["path", { d: "M13 5h8", key: "a7qcls" }],
1589
- ["path", { d: "M13 12h8", key: "h98zly" }],
1590
- ["path", { d: "M13 19h8", key: "c3s6r1" }],
1591
- ["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
1592
- ["path", { d: "m3 7 2 2 4-4", key: "1obspn" }]
1593
- ]
1594
- }, Ui = se(Li);
1595
- const Ri = {
1596
- name: "list-ordered",
1597
- size: 24,
1598
- node: [
1599
- ["path", { d: "M11 5h10", key: "1cz7ny" }],
1600
- ["path", { d: "M11 12h10", key: "1438ji" }],
1601
- ["path", { d: "M11 19h10", key: "11t30w" }],
1602
- ["path", { d: "M4 4h1v5", key: "10yrso" }],
1603
- ["path", { d: "M4 9h2", key: "r1h2o0" }],
1604
- ["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
1605
- ]
1606
- }, Oi = se(Ri);
1607
- const ji = {
1608
- name: "paperclip",
1609
- size: 24,
1610
- node: [
1611
- [
1612
- "path",
1613
- {
1614
- d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",
1615
- key: "1miecu"
1616
- }
1617
- ]
1618
- ]
1619
- }, Hi = se(ji);
1620
- const Wi = {
1621
- name: "settings-2",
1622
- size: 24,
1623
- node: [
1624
- ["path", { d: "M14 17H5", key: "gfn3mx" }],
1625
- ["path", { d: "M19 7h-9", key: "6i9tg" }],
1626
- ["circle", { cx: "17", cy: "17", r: "3", key: "18b49y" }],
1627
- ["circle", { cx: "7", cy: "7", r: "3", key: "dfmy0x" }]
1628
- ]
1629
- }, Ki = se(Wi);
1630
- const Qi = {
1631
- name: "square-check",
1632
- size: 24,
1633
- node: [
1634
- ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
1635
- ["path", { d: "m16 9-5.5 5.5L8 12", key: "xofnsj" }]
1636
- ],
1637
- aliases: ["check-square-2"]
1638
- }, Ji = se(Qi);
1639
- const Xi = {
1640
- name: "text-cursor-input",
1641
- size: 24,
1642
- node: [
1643
- ["path", { d: "M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6", key: "1528k5" }],
1644
- ["path", { d: "M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7", key: "13ksps" }],
1645
- ["path", { d: "M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1", key: "1n9rhb" }],
1646
- ["path", { d: "M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1", key: "1mj8rg" }],
1647
- ["path", { d: "M9 6v12", key: "velyjx" }]
1648
- ]
1649
- }, Yi = se(Xi);
1650
- const Zi = {
1651
- name: "toggle-left",
1652
- size: 24,
1653
- node: [
1654
- ["circle", { cx: "9", cy: "12", r: "3", key: "u3jwor" }],
1655
- ["rect", { width: "20", height: "14", x: "2", y: "5", rx: "7", key: "g7kal2" }]
1656
- ]
1657
- }, Gi = se(Zi), en = ["aria-label"], tn = ["title", "aria-label", "onClick"], ln = ["aria-label"], sn = ["title", "onClick"], nn = /* @__PURE__ */ ve({
1658
- __name: "AimdInputToolbar",
1659
- props: {
1660
- messages: {}
1661
- },
1662
- emits: ["insert"],
1663
- setup(e, { emit: n }) {
1664
- const t = e, a = n, o = $(), m = $(0), f = E(() => [
1665
- { preset: "str", label: t.messages.inputField.text, icon: Yi },
1666
- { preset: "int", label: t.messages.inputField.integer, icon: mt },
1667
- { preset: "float", label: t.messages.inputField.number, icon: mt },
1668
- { preset: "choice", label: t.messages.inputField.choice, icon: Bi },
1669
- { preset: "multiple-choice", label: t.messages.inputField.multipleChoice, icon: Ji },
1670
- { preset: "bool | None", label: t.messages.inputField.boolean, icon: Gi }
1671
- ]), u = E(() => [
1672
- { preset: "date", label: t.messages.inputField.date, icon: ct },
1673
- { preset: "time", label: t.messages.inputField.time, icon: Ni },
1674
- { preset: "datetime", label: t.messages.inputField.datetime, icon: ct },
1675
- { preset: "list[str]", label: t.messages.inputField.list, icon: Oi },
1676
- { preset: "file", label: t.messages.inputField.file, icon: Hi },
1677
- { preset: "custom", label: t.messages.inputField.custom, icon: Ki }
1678
- ]);
1679
- function l(y = !1) {
1680
- o.value?.open && (o.value.open = !1, y && o.value.querySelector("summary")?.focus());
1681
- }
1682
- function d(y) {
1683
- l(), a("insert", y);
1684
- }
1685
- function w(y) {
1686
- y.target instanceof Node && !o.value?.contains(y.target) && l();
1687
- }
1688
- function c() {
1689
- if (!o.value?.open) return;
1690
- const y = o.value.getBoundingClientRect().left;
1691
- m.value = Math.max(8 - y, Math.min(0, window.innerWidth - y - 198));
1692
- }
1693
- return wt(() => document.addEventListener("click", w)), Mt(() => document.removeEventListener("click", w)), (y, V) => (g(), h("div", {
1694
- class: "aimd-input-tools",
1695
- role: "group",
1696
- "aria-label": e.messages.inputField.insert
1697
- }, [
1698
- (g(!0), h(U, null, X(f.value, (_) => (g(), h("button", {
1699
- key: _.preset,
1700
- type: "button",
1701
- title: e.messages.inputField.insertType(_.label),
1702
- "aria-label": e.messages.inputField.insertType(_.label),
1703
- onMousedown: V[0] || (V[0] = me(() => {
1704
- }, ["prevent"])),
1705
- onClick: (A) => d(_.preset)
1706
- }, [
1707
- (g(), be(it(_.icon), {
1708
- size: 16,
1709
- "aria-hidden": "true"
1710
- })),
1711
- i("span", null, v(_.label), 1)
1712
- ], 40, tn))), 128)),
1713
- i("details", {
1714
- ref_key: "more",
1715
- ref: o,
1716
- class: "aimd-input-tools__more",
1717
- onToggle: c,
1718
- onKeydown: V[1] || (V[1] = _t(me((_) => l(!0), ["stop", "prevent"]), ["esc"]))
1719
- }, [
1720
- i("summary", null, [
1721
- ae(Z(Ui), {
1722
- size: 16,
1723
- "aria-hidden": "true"
1724
- }),
1725
- i("span", null, v(e.messages.inputField.more), 1),
1726
- ae(Z(Di), {
1727
- size: 14,
1728
- "aria-hidden": "true"
1729
- })
1730
- ]),
1731
- i("div", {
1732
- class: "aimd-input-tools__menu",
1733
- style: Ee({ left: `${m.value}px` }),
1734
- role: "group",
1735
- "aria-label": e.messages.inputField.more
1736
- }, [
1737
- (g(!0), h(U, null, X(u.value, (_) => (g(), h("button", {
1738
- key: _.preset,
1739
- type: "button",
1740
- title: e.messages.inputField.insertType(_.label),
1741
- onClick: (A) => d(_.preset)
1742
- }, [
1743
- (g(), be(it(_.icon), {
1744
- size: 16,
1745
- "aria-hidden": "true"
1746
- })),
1747
- i("span", null, v(_.label), 1)
1748
- ], 8, sn))), 128))
1749
- ], 12, ln)
1750
- ], 544)
1751
- ], 8, en));
1752
- }
1753
- }), an = /* @__PURE__ */ je(nn, [["__scopeId", "data-v-36cefb3e"]]), on = { class: "aimd-editor-toolbar" }, un = {
1754
- key: 0,
1755
- class: "aimd-editor-mode-switch"
1756
- }, rn = ["title"], dn = ["title"], cn = {
1757
- key: 1,
1758
- class: "aimd-editor-toolbar-sep"
1759
- }, mn = {
1760
- key: 0,
1761
- class: "aimd-editor-toolbar-sep"
1762
- }, vn = ["title", "onClick", "innerHTML"], fn = {
1763
- key: 3,
1764
- class: "aimd-editor-toolbar-divider"
1765
- }, pn = ["title", "onClick", "onMouseup"], gn = ["innerHTML"], hn = { class: "aimd-editor-aimd-btn-label" }, yn = /* @__PURE__ */ ve({
1766
- __name: "AimdEditorToolbar",
1767
- props: {
1768
- showTopBar: { type: Boolean },
1769
- showMdToolbar: { type: Boolean },
1770
- showAimdToolbar: { type: Boolean },
1771
- editorMode: {},
1772
- resolvedMessages: {},
1773
- localizedFieldTypes: {},
1774
- localizedMdToolbarItems: {}
1775
- },
1776
- emits: ["switch-mode", "md-action", "open-aimd-dialog", "quick-insert-aimd", "insert-input"],
1777
- setup(e, { emit: n }) {
1778
- const t = n;
1779
- return (a, o) => (g(), h("div", on, [
1780
- e.showTopBar ? (g(), h("div", un, [
1781
- i("button", {
1782
- type: "button",
1783
- class: he(["aimd-editor-mode-btn", { active: e.editorMode === "source" }]),
1784
- onClick: o[0] || (o[0] = (m) => t("switch-mode", "source")),
1785
- title: e.resolvedMessages.mode.sourceTitle
1786
- }, [
1787
- o[3] || (o[3] = i("span", {
1788
- class: "aimd-editor-mode-icon",
1789
- innerHTML: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>'
1790
- }, null, -1)),
1791
- i("span", null, v(e.resolvedMessages.mode.source), 1)
1792
- ], 10, rn),
1793
- i("button", {
1794
- type: "button",
1795
- class: he(["aimd-editor-mode-btn", { active: e.editorMode === "wysiwyg" }]),
1796
- onClick: o[1] || (o[1] = (m) => t("switch-mode", "wysiwyg")),
1797
- title: e.resolvedMessages.mode.wysiwygTitle
1798
- }, [
1799
- o[4] || (o[4] = i("span", {
1800
- class: "aimd-editor-mode-icon",
1801
- innerHTML: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
1802
- }, null, -1)),
1803
- i("span", null, v(e.resolvedMessages.mode.wysiwyg), 1)
1804
- ], 10, dn)
1805
- ])) : N("", !0),
1806
- e.showTopBar && e.showMdToolbar ? (g(), h("div", cn)) : N("", !0),
1807
- e.showMdToolbar ? (g(!0), h(U, { key: 2 }, X(e.localizedMdToolbarItems, (m) => (g(), h(U, {
1808
- key: m.action
1809
- }, [
1810
- m.action.startsWith("sep") ? (g(), h("div", mn)) : (g(), h("button", {
1811
- key: 1,
1812
- type: "button",
1813
- class: "aimd-editor-fmt-btn",
1814
- title: m.title,
1815
- onClick: (f) => t("md-action", m.action, f),
1816
- innerHTML: m.svgIcon
1817
- }, null, 8, vn))
1818
- ], 64))), 128)) : N("", !0),
1819
- e.showMdToolbar && e.showAimdToolbar ? (g(), h("div", fn)) : N("", !0),
1820
- e.showAimdToolbar ? (g(), h(U, { key: 4 }, [
1821
- (g(!0), h(U, null, X(e.localizedFieldTypes.filter((m) => m.type !== "var"), (m) => (g(), h("button", {
1822
- key: m.type,
1823
- type: "button",
1824
- class: "aimd-editor-fmt-btn aimd-editor-aimd-btn",
1825
- title: m.desc,
1826
- style: Ee({ "--aimd-color": m.color }),
1827
- onClick: (f) => t("open-aimd-dialog", m.type),
1828
- onMouseup: me((f) => t("quick-insert-aimd", m.type), ["middle", "prevent"])
1829
- }, [
1830
- i("span", {
1831
- class: "aimd-editor-aimd-btn-icon",
1832
- innerHTML: m.svgIcon
1833
- }, null, 8, gn),
1834
- i("span", hn, v(m.label), 1)
1835
- ], 44, pn))), 128)),
1836
- e.localizedFieldTypes.some((m) => m.type === "var") ? (g(), be(an, {
1837
- key: 0,
1838
- messages: e.resolvedMessages,
1839
- onInsert: o[2] || (o[2] = (m) => t("insert-input", m))
1840
- }, null, 8, ["messages"])) : N("", !0)
1841
- ], 64)) : N("", !0)
1842
- ]));
1843
- }
1844
- });
1845
- function bn(e) {
1846
- const { initialContent: n, initialMode: t, resolvedMessages: a, emitModelValue: o, emitMode: m } = e, f = $(t), u = $(n), l = Je(null), d = Je(null), w = $(!0), c = Je(null);
1847
- let y = !1;
1848
- function V(M) {
1849
- M !== u.value && (u.value = M, o(M));
1850
- }
1851
- function _(M) {
1852
- return qt(M).content;
1853
- }
1854
- function A(M) {
1855
- return /class="ProseMirror milkdown-editor-content editor"/.test(M) || /<div class="milkdown">/.test(M) || /<\/?[a-z][^>]*>/i.test(M) && /AIMDINLINETEMPLATE[0-9a-f]+TOKEN/.test(M);
1856
- }
1857
- function I(M, z) {
1858
- const R = xt(Nt(M));
1859
- return A(R) ? z : R;
1860
- }
1861
- function P(M) {
1862
- return /\{\{(?:var_table|var|quiz|step|check|ref_step|ref_var|ref_fig|cite|fig)\|/.test(M) || /```(?:quiz|fig|assigner|connectors)\b/.test(M);
1863
- }
1864
- function O() {
1865
- if (c.value)
1866
- try {
1867
- const M = c.value.action(at());
1868
- if (typeof M != "string")
1869
- return;
1870
- const z = I(M, u.value);
1871
- c.value.action(Ue(_(z)));
1872
- } catch {
1873
- }
1874
- }
1875
- const x = E(() => {
1876
- try {
1877
- return Pt(u.value);
1878
- } catch {
1879
- return null;
1880
- }
1881
- });
1882
- async function F(M) {
1883
- if (M !== f.value) {
1884
- if (f.value === "source" && l.value && (u.value = l.value.getValue()), f.value === "wysiwyg" && c.value)
1885
- try {
1886
- const z = c.value.action(at());
1887
- typeof z == "string" && (u.value = I(z, u.value));
1888
- } catch {
1889
- }
1890
- if (f.value = M, m(M), M === "source")
1891
- await Re(), l.value && (y = !0, l.value.setValue(u.value), y = !1);
1892
- else if (M === "wysiwyg" && (await Re(), c.value))
1893
- try {
1894
- y = !0, c.value.action(Ue(_(u.value))), y = !1;
1895
- } catch {
1896
- y = !1;
1897
- }
1898
- }
1899
- }
1900
- function J(M) {
1901
- if (M !== u.value) {
1902
- if (y = !0, u.value = M, f.value === "source" && l.value)
1903
- l.value.setValue(M);
1904
- else if (f.value === "wysiwyg" && c.value)
1905
- try {
1906
- c.value.action(Ue(_(M)));
1907
- } catch {
1908
- }
1909
- y = !1;
1910
- }
1911
- }
1912
- function ne(M) {
1913
- if (f.value === "source" && l.value) {
1914
- const z = l.value.getSelection(), R = l.value.getModel(), Q = l.value.getPosition(), K = R.getLineContent(Q.lineNumber).substring(0, Q.column - 1).trim() !== "" && !M.startsWith(`
1915
- `) ? `
1916
- ` + M : M;
1917
- l.value.executeEdits("toolbar", [{
1918
- range: z,
1919
- text: K,
1920
- forceMoveMarkers: !0
1921
- }]), l.value.focus();
1922
- } else if (f.value === "wysiwyg" && c.value)
1923
- try {
1924
- c.value.action(Xe(M)), P(M) && O();
1925
- } catch {
1926
- }
1927
- }
1928
- function j(M, z = "", R = "") {
1929
- if (f.value === "source" && l.value) {
1930
- const Q = l.value.getSelection(), T = l.value.getModel().getValueInRange(Q) || R, b = M + T + z;
1931
- l.value.executeEdits("toolbar", [{
1932
- range: Q,
1933
- text: b,
1934
- forceMoveMarkers: !0
1935
- }]), l.value.focus();
1936
- } else if (f.value === "wysiwyg" && c.value)
1937
- try {
1938
- c.value.action(Xe(M + R + z));
1939
- } catch {
1940
- }
1941
- }
1942
- function H(M, z = "") {
1943
- if (f.value === "source" && l.value) {
1944
- const R = l.value.getPosition(), T = l.value.getModel().getLineContent(R.lineNumber);
1945
- if (T.trim() === "") {
1946
- const b = { startLineNumber: R.lineNumber, startColumn: 1, endLineNumber: R.lineNumber, endColumn: T.length + 1 };
1947
- l.value.executeEdits("toolbar", [{ range: b, text: M + z, forceMoveMarkers: !0 }]);
1948
- } else {
1949
- const b = { startLineNumber: R.lineNumber, startColumn: T.length + 1, endLineNumber: R.lineNumber, endColumn: T.length + 1 };
1950
- l.value.executeEdits("toolbar", [{ range: b, text: `
1951
- ` + M + z, forceMoveMarkers: !0 }]);
1952
- }
1953
- l.value.focus();
1954
- } else if (f.value === "wysiwyg" && c.value)
1955
- try {
1956
- c.value.action(Xe(`
1957
- ` + M + z));
1958
- } catch {
1959
- }
1960
- }
1961
- function W(M) {
1962
- const z = a.value.snippets;
1963
- switch (M) {
1964
- case "h1":
1965
- H("# ", z.heading);
1966
- break;
1967
- case "h2":
1968
- H("## ", z.heading);
1969
- break;
1970
- case "h3":
1971
- H("### ", z.heading);
1972
- break;
1973
- case "bold":
1974
- j("**", "**", z.boldText);
1975
- break;
1976
- case "italic":
1977
- j("*", "*", z.italicText);
1978
- break;
1979
- case "strikethrough":
1980
- j("~~", "~~", z.strikethrough);
1981
- break;
1982
- case "ul":
1983
- H("- ", z.listItem);
1984
- break;
1985
- case "ol":
1986
- H("1. ", z.listItem);
1987
- break;
1988
- case "blockquote":
1989
- H("> ", z.quote);
1990
- break;
1991
- case "code":
1992
- j("`", "`", z.code);
1993
- break;
1994
- case "codeblock":
1995
- j("```\n", "\n```", z.codeBlock);
1996
- break;
1997
- case "link":
1998
- j("[", "](url)", z.linkText);
1999
- break;
2000
- case "image":
2001
- j("![", "](url)", z.altText);
2002
- break;
2003
- case "hr":
2004
- H("---");
2005
- break;
2006
- case "math":
2007
- j("$", "$", z.mathFormula);
2008
- break;
2009
- case "table":
2010
- if (f.value === "wysiwyg" && c.value)
2011
- try {
2012
- c.value.action(Tt(Lt.key, { row: 3, col: 3 }));
2013
- } catch {
2014
- }
2015
- else
2016
- H(
2017
- `| ${z.tableColumnA} | ${z.tableColumnB} | ${z.tableColumnC} |
2018
- |-------|-------|-------|
2019
- | `,
2020
- " | | |"
2021
- );
2022
- break;
2023
- }
2024
- }
2025
- function G(M, z, R) {
2026
- y || V(I(z, u.value));
2027
- }
2028
- function le(M) {
2029
- c.value = M;
2030
- }
2031
- return {
2032
- editorMode: f,
2033
- content: u,
2034
- commitUserContent: V,
2035
- monacoEditor: l,
2036
- monacoInstance: d,
2037
- monacoLoading: w,
2038
- milkdownEditorRef: c,
2039
- extractedFields: x,
2040
- toMilkdownMarkdown: _,
2041
- switchMode: F,
2042
- syncFromProp: J,
2043
- insertTextIntoActiveEditor: ne,
2044
- handleMdAction: W,
2045
- onMilkdownMarkdownUpdated: G,
2046
- onMilkdownReady: le
2047
- };
2048
- }
2049
- const kn = { class: "aimd-editor" }, wn = {
2050
- key: 0,
2051
- class: "aimd-editor-mode-host"
2052
- }, Mn = {
2053
- key: 1,
2054
- class: "aimd-editor-mode-host"
2055
- }, Nn = /* @__PURE__ */ ve({
2056
- __name: "AimdEditor",
2057
- props: {
2058
- modelValue: { default: "" },
2059
- locale: {},
2060
- messages: { default: () => ({}) },
2061
- mode: { default: "source" },
2062
- fieldDisplay: { default: "detailed" },
2063
- theme: { default: "aimd-light" },
2064
- showTopBar: { type: Boolean, default: !0 },
2065
- showToolbar: { type: Boolean, default: !0 },
2066
- showAimdToolbar: { type: Boolean, default: !0 },
2067
- showMdToolbar: { type: Boolean, default: !0 },
2068
- imageToolbarAction: { default: "markdown" },
2069
- enableBlockHandle: { type: Boolean, default: !0 },
2070
- enableSlashMenu: { type: Boolean, default: !0 },
2071
- keepInactiveEditorsMounted: { type: Boolean, default: !0 },
2072
- minHeight: { default: 500 },
2073
- readonly: { type: Boolean, default: !1 },
2074
- monacoOptions: { default: () => ({}) },
2075
- varTypePlugins: {}
2076
- },
2077
- emits: ["update:modelValue", "update:mode", "ready", "request-image"],
2078
- setup(e, { expose: n, emit: t }) {
2079
- const a = e, o = t, m = E(() => $t(a.locale, a.messages)), {
2080
- editorMode: f,
2081
- content: u,
2082
- commitUserContent: l,
2083
- monacoEditor: d,
2084
- monacoInstance: w,
2085
- milkdownEditorRef: c,
2086
- extractedFields: y,
2087
- toMilkdownMarkdown: V,
2088
- switchMode: _,
2089
- syncFromProp: A,
2090
- insertTextIntoActiveEditor: I,
2091
- handleMdAction: P,
2092
- onMilkdownMarkdownUpdated: O,
2093
- onMilkdownReady: x
2094
- } = bn({
2095
- initialContent: a.modelValue,
2096
- initialMode: a.mode,
2097
- resolvedMessages: m,
2098
- emitModelValue: (s) => o("update:modelValue", s),
2099
- emitMode: (s) => o("update:mode", s)
2100
- });
2101
- te(() => a.modelValue, (s) => A(s)), te(() => a.mode, (s) => {
2102
- s !== f.value && _(s);
2103
- });
2104
- const F = $(a.theme), J = E(() => a.keepInactiveEditorsMounted || f.value === "source"), ne = E(() => a.keepInactiveEditorsMounted || f.value === "wysiwyg"), j = E(() => ft(m.value)), H = E(() => It(m.value)), W = $(!1), G = $("var"), le = $(!1), M = $("str"), z = $(), R = $(!1), Q = $("step"), T = $();
2105
- function b(s) {
2106
- a.readonly || (Q.value = "step", T.value = s, R.value = !0);
2107
- }
2108
- function C(s) {
2109
- a.readonly || (Q.value = "check", T.value = s, R.value = !0);
2110
- }
2111
- function K(s) {
2112
- a.readonly || (T.value ? T.value.apply(s) : I(`{{${Q.value}|${s}}}${Q.value === "step" ? `
2113
-
2114
- ` : " "}`));
2115
- }
2116
- function Y(s) {
2117
- a.readonly || (z.value = s, le.value = !0);
2118
- }
2119
- function ee(s) {
2120
- a.readonly || (z.value ? z.value.apply(s) : I(`{{var|${s}}}`));
2121
- }
2122
- const ue = E(() => {
2123
- const s = y.value;
2124
- if (!s) return [];
2125
- const k = G.value;
2126
- return k === "ref_step" ? s.step || [] : k === "ref_var" ? s.var || [] : k === "ref_fig" ? s.ref_fig || [] : [];
2127
- }), ie = E(() => {
2128
- const s = y.value;
2129
- return s?.quiz ? s.quiz.map((k) => k.id) : [];
2130
- });
2131
- function fe(s) {
2132
- if (!a.readonly) {
2133
- if (s === "step" || s === "check") {
2134
- Q.value = s, T.value = void 0, R.value = !0;
2135
- return;
2136
- }
2137
- if (s === "var") {
2138
- re("str");
2139
- return;
2140
- }
2141
- G.value = s, W.value = !0;
2142
- }
2143
- }
2144
- function re(s) {
2145
- a.readonly || (z.value = void 0, M.value = s, le.value = !0);
2146
- }
2147
- function Ce(s) {
2148
- if (!a.readonly) {
2149
- if (s === "step") {
2150
- I(`{{step|${_e(Te(u.value), "step")}, check=True}}
2151
-
2152
- `);
2153
- return;
2154
- }
2155
- if (s === "var") {
2156
- const k = _e(Te(u.value));
2157
- I(`{{var|${k}: str}}`);
2158
- return;
2159
- }
2160
- I(zt(s, m.value));
2161
- }
2162
- }
2163
- function He(s) {
2164
- I(s);
2165
- }
2166
- function xe(s) {
2167
- if (!(s instanceof HTMLElement)) return;
2168
- const k = s.getBoundingClientRect();
2169
- return {
2170
- top: k.top,
2171
- right: k.right,
2172
- bottom: k.bottom,
2173
- left: k.left,
2174
- width: k.width,
2175
- height: k.height
2176
- };
2177
- }
2178
- function $e(s, k) {
2179
- if (s === "image" && a.imageToolbarAction === "custom") {
2180
- o("request-image", { buttonRect: xe(k.currentTarget) });
2181
- return;
2182
- }
2183
- P(s);
2184
- }
2185
- const We = $(null), Ke = $(null);
2186
- function Qe(s) {
2187
- l(s);
2188
- }
2189
- function Ie(s) {
2190
- o("ready", { monaco: s });
2191
- }
2192
- function p(s, k) {
2193
- w.value = s, d.value = k;
2194
- }
2195
- function r(s) {
2196
- x(s), o("ready", { milkdown: s });
2197
- }
2198
- return n({
2199
- getContent: () => u.value,
2200
- setContent: (s) => {
2201
- if (u.value = s, f.value === "source" && d.value)
2202
- d.value.setValue(s);
2203
- else if (c.value)
2204
- try {
2205
- c.value.action(Ue(V(s)));
2206
- } catch {
2207
- }
2208
- },
2209
- getMode: () => f.value,
2210
- setMode: (s) => _(s),
2211
- getMonacoEditor: () => d.value,
2212
- getMilkdownEditor: () => c.value,
2213
- insertText: I
2214
- }), (s, k) => (g(), h("div", kn, [
2215
- e.showToolbar ? (g(), be(yn, {
2216
- key: 0,
2217
- "show-top-bar": e.showTopBar,
2218
- "show-md-toolbar": e.showMdToolbar,
2219
- "show-aimd-toolbar": e.showAimdToolbar,
2220
- "editor-mode": Z(f),
2221
- "resolved-messages": m.value,
2222
- "localized-field-types": j.value,
2223
- "localized-md-toolbar-items": H.value,
2224
- onSwitchMode: Z(_),
2225
- onMdAction: $e,
2226
- onOpenAimdDialog: fe,
2227
- onQuickInsertAimd: Ce,
2228
- onInsertInput: re
2229
- }, null, 8, ["show-top-bar", "show-md-toolbar", "show-aimd-toolbar", "editor-mode", "resolved-messages", "localized-field-types", "localized-md-toolbar-items", "onSwitchMode"])) : N("", !0),
2230
- i("div", {
2231
- class: "aimd-editor-panel",
2232
- style: Ee({ minHeight: e.minHeight + "px" })
2233
- }, [
2234
- J.value ? S((g(), h("div", wn, [
2235
- ae(Bt, {
2236
- ref_key: "sourceEditorRef",
2237
- ref: We,
2238
- content: Z(u),
2239
- theme: F.value,
2240
- "min-height": e.minHeight,
2241
- readonly: e.readonly,
2242
- "monaco-options": e.monacoOptions,
2243
- "resolved-messages": m.value,
2244
- onContentChange: Qe,
2245
- onReady: Ie,
2246
- onMonacoLoaded: p
2247
- }, null, 8, ["content", "theme", "min-height", "readonly", "monaco-options", "resolved-messages"])
2248
- ], 512)), [
2249
- [nt, Z(f) === "source"]
2250
- ]) : N("", !0),
2251
- ne.value ? S((g(), h("div", Mn, [
2252
- ae(Ft, {
2253
- ref_key: "wysiwygEditorRef",
2254
- ref: Ke,
2255
- content: Z(u),
2256
- "min-height": e.minHeight,
2257
- "enable-block-handle": e.enableBlockHandle,
2258
- active: Z(f) === "wysiwyg",
2259
- "resolved-messages": m.value,
2260
- "localized-field-types": j.value,
2261
- "field-display": e.fieldDisplay,
2262
- "edit-input-fields": !0,
2263
- readonly: e.readonly,
2264
- onMarkdownUpdated: Z(O),
2265
- onReady: r,
2266
- onOpenAimdDialog: fe,
2267
- onEditInput: Y,
2268
- onEditStep: b,
2269
- onEditCheck: C
2270
- }, null, 8, ["content", "min-height", "enable-block-handle", "active", "resolved-messages", "localized-field-types", "field-display", "readonly", "onMarkdownUpdated"])
2271
- ], 512)), [
2272
- [nt, Z(f) === "wysiwyg"]
2273
- ]) : N("", !0)
2274
- ], 4),
2275
- ae(Ci, {
2276
- visible: R.value,
2277
- "onUpdate:visible": k[0] || (k[0] = (D) => R.value = D),
2278
- "field-type": Q.value,
2279
- content: Z(u),
2280
- "field-content": T.value?.content,
2281
- messages: m.value,
2282
- onSave: K
2283
- }, null, 8, ["visible", "field-type", "content", "field-content", "messages"]),
2284
- ae(mi, {
2285
- visible: le.value,
2286
- "onUpdate:visible": k[1] || (k[1] = (D) => le.value = D),
2287
- content: Z(u),
2288
- "field-content": z.value?.content,
2289
- "initial-preset": M.value,
2290
- "var-type-plugins": e.varTypePlugins,
2291
- messages: m.value,
2292
- onSave: ee
2293
- }, null, 8, ["visible", "content", "field-content", "initial-preset", "var-type-plugins", "messages"]),
2294
- ae(Qs, {
2295
- visible: W.value,
2296
- "initial-type": G.value,
2297
- messages: m.value,
2298
- "ref-suggestions": ue.value,
2299
- "var-type-plugins": e.varTypePlugins,
2300
- "existing-quiz-ids": ie.value,
2301
- "onUpdate:visible": k[2] || (k[2] = (D) => W.value = D),
2302
- onInsert: He
2303
- }, null, 8, ["visible", "initial-type", "messages", "ref-suggestions", "var-type-plugins", "existing-quiz-ids"])
2304
- ]));
2305
- }
2306
- }), _n = { class: "aimd-editor-mode-switch" }, Tn = ["title"], Cn = ["innerHTML"], xn = ["title"], $n = ["innerHTML"], Pn = /* @__PURE__ */ ve({
2307
- __name: "AimdEditorTopBar",
2308
- props: {
2309
- editorMode: {},
2310
- resolvedMessages: {}
2311
- },
2312
- emits: ["switch-mode"],
2313
- setup(e, { emit: n }) {
2314
- const t = n, a = {
2315
- source: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
2316
- wysiwyg: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
2317
- };
2318
- return (o, m) => (g(), h("div", _n, [
2319
- i("button", {
2320
- class: he(["aimd-editor-mode-btn", { active: e.editorMode === "source" }]),
2321
- onClick: m[0] || (m[0] = (f) => t("switch-mode", "source")),
2322
- title: e.resolvedMessages.mode.sourceTitle
2323
- }, [
2324
- i("span", {
2325
- class: "aimd-editor-mode-icon",
2326
- innerHTML: a.source
2327
- }, null, 8, Cn),
2328
- i("span", null, v(e.resolvedMessages.mode.source), 1)
2329
- ], 10, Tn),
2330
- i("button", {
2331
- class: he(["aimd-editor-mode-btn", { active: e.editorMode === "wysiwyg" }]),
2332
- onClick: m[1] || (m[1] = (f) => t("switch-mode", "wysiwyg")),
2333
- title: e.resolvedMessages.mode.wysiwygTitle
2334
- }, [
2335
- i("span", {
2336
- class: "aimd-editor-mode-icon",
2337
- innerHTML: a.wysiwyg
2338
- }, null, 8, $n),
2339
- i("span", null, v(e.resolvedMessages.mode.wysiwyg), 1)
2340
- ], 10, xn)
2341
- ]));
2342
- }
2343
- });
2344
- export {
2345
- mi as A,
2346
- Nn as _,
2347
- yn as a,
2348
- Pn as b,
2349
- Qs as c,
2350
- Ci as d,
2351
- bn as u
2352
- };