@webx-ui/module-inbox 0.9.1 → 0.11.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.
@@ -0,0 +1,889 @@
1
+ import { defineComponent as D, useModel as H, computed as g, openBlock as v, createBlock as V, unref as e, withCtx as t, createVNode as l, isRef as T, createTextVNode as k, toDisplayString as y, createCommentVNode as W, mergeModels as oe, createElementBlock as A, createElementVNode as B, ref as I, onMounted as be, Fragment as te, renderList as ue, reactive as xe, watch as ye } from "vue";
2
+ import { useRouter as pe, useRoute as ge } from "vue-router";
3
+ import { useTranslate as G, useAdmin as ie, emptyLink as de, WxLinkPicker as _e, WxRelationsField as he, useErrorText as ke, WxScreenHead as Ve } from "@webx-ui/module-admin";
4
+ import { WxCard as q, WxFormItem as z, WxSwitch as me, WxInputNumber as re, WxSelect as ae, WxText as F, WxAlert as J, WxAction as K, WxTable as we, toast as P, WxInput as M, WxRadioGroup as $e, WxSpace as Ue, WxButton as ne, WxIcon as We, WxLink as ze, confirm as Fe, useLocales as Se, localizedValue as Ce, WxSkeleton as Te, WxBadge as Ae, WxTabs as Be, WxTab as R, WxActionBar as qe } from "@webx-ui/core";
5
+ import { o as C, u as ce, _ as Q, a as Ie, c as fe, F as Ne } from "./index-gLN73Ici.js";
6
+ const Ee = /* @__PURE__ */ D({
7
+ __name: "FormAntispam",
8
+ props: /* @__PURE__ */ oe({
9
+ site: {}
10
+ }, {
11
+ modelValue: { required: !0 },
12
+ modelModifiers: {}
13
+ }),
14
+ emits: ["update:modelValue"],
15
+ setup(c) {
16
+ const m = H(c, "modelValue"), u = c, s = G("webx-inbox"), w = C(m, "antispam.honeypot", !0), o = C(m, "antispam.min_seconds", 3), $ = C(m, "antispam.throttle", 5), r = C(m, "antispam.captcha", "off"), U = g(() => [
17
+ { value: "off", label: s("panel.captcha-off") },
18
+ { value: "recaptcha", label: s("panel.captcha-recaptcha") },
19
+ { value: "turnstile", label: s("panel.captcha-turnstile") }
20
+ ]), f = g(() => {
21
+ const p = r.value;
22
+ return p !== "recaptcha" && p !== "turnstile" ? null : { provider: p, site: u.site?.[p] ?? null };
23
+ }), _ = g(() => {
24
+ const p = f.value?.site;
25
+ return p ? s(`panel.captcha-${f.value.provider}-${p.type}`) : null;
26
+ });
27
+ return (p, i) => (v(), V(e(q), null, {
28
+ default: t(() => [
29
+ l(e(z), {
30
+ help: e(s)("panel.honeypot-help")
31
+ }, {
32
+ default: t(() => [
33
+ l(e(me), {
34
+ modelValue: e(w),
35
+ "onUpdate:modelValue": i[0] || (i[0] = (h) => T(w) ? w.value = h : null),
36
+ label: e(s)("panel.honeypot")
37
+ }, null, 8, ["modelValue", "label"])
38
+ ]),
39
+ _: 1
40
+ }, 8, ["help"]),
41
+ l(e(z), {
42
+ label: e(s)("panel.min-seconds"),
43
+ help: e(s)("panel.min-seconds-help")
44
+ }, {
45
+ default: t(() => [
46
+ l(e(re), {
47
+ modelValue: e(o),
48
+ "onUpdate:modelValue": i[1] || (i[1] = (h) => T(o) ? o.value = h : null),
49
+ min: 0,
50
+ max: 120
51
+ }, null, 8, ["modelValue"])
52
+ ]),
53
+ _: 1
54
+ }, 8, ["label", "help"]),
55
+ l(e(z), {
56
+ label: e(s)("panel.throttle"),
57
+ help: e(s)("panel.throttle-help")
58
+ }, {
59
+ default: t(() => [
60
+ l(e(re), {
61
+ modelValue: e($),
62
+ "onUpdate:modelValue": i[2] || (i[2] = (h) => T($) ? $.value = h : null),
63
+ min: 0,
64
+ max: 120
65
+ }, null, 8, ["modelValue"])
66
+ ]),
67
+ _: 1
68
+ }, 8, ["label", "help"]),
69
+ l(e(z), {
70
+ label: e(s)("panel.captcha"),
71
+ help: e(s)("panel.captcha-keys")
72
+ }, {
73
+ default: t(() => [
74
+ l(e(ae), {
75
+ modelValue: e(r),
76
+ "onUpdate:modelValue": i[3] || (i[3] = (h) => T(r) ? r.value = h : null),
77
+ options: U.value
78
+ }, null, 8, ["modelValue", "options"])
79
+ ]),
80
+ _: 1
81
+ }, 8, ["label", "help"]),
82
+ _.value ? (v(), V(e(F), {
83
+ key: 0,
84
+ size: "sm",
85
+ tone: "muted"
86
+ }, {
87
+ default: t(() => [
88
+ k(y(_.value), 1)
89
+ ]),
90
+ _: 1
91
+ })) : W("", !0),
92
+ f.value?.site && !f.value.site.configured ? (v(), V(e(J), {
93
+ key: 1,
94
+ type: "warning",
95
+ variant: "soft",
96
+ closable: !1,
97
+ description: e(s)("panel.captcha-unconfigured")
98
+ }, null, 8, ["description"])) : W("", !0)
99
+ ]),
100
+ _: 1
101
+ }));
102
+ }
103
+ }), Le = { class: "wx-inbox-embed" }, Me = { class: "wx-inbox-embed__snippet" }, Oe = { class: "wx-inbox-embed__snippet" }, Re = { class: "wx-inbox-embed__snippet" }, Pe = /* @__PURE__ */ D({
104
+ __name: "FormEmbed",
105
+ props: {
106
+ form: {},
107
+ slug: {},
108
+ fields: {}
109
+ },
110
+ setup(c) {
111
+ const m = c;
112
+ ce();
113
+ const u = G("webx-inbox"), s = ie(), w = g(
114
+ () => s.state.manifest?.modules.some((i) => i.id === "blocks") ?? !1
115
+ ), o = g(() => `<x-webx-inbox::form slug="${m.slug}" />`), $ = g(
116
+ () => w.value ? o.value : `{{-- resources/views/blocks/contact.blade.php --}}
117
+ <x-webx-inbox::form slug="${m.slug}" />`
118
+ ), r = g(
119
+ () => m.fields.find((i) => i.type === "hidden" && i.is_enabled)?.key ?? "page"
120
+ ), U = g(
121
+ () => `<x-webx-inbox::form slug="${m.slug}" :values="['${r.value}' => url()->current()]" />
122
+ <x-webx-inbox::form slug="${m.slug}" placement="footer" />`
123
+ ), f = g(() => [
124
+ { key: "key", label: u("fields.name") },
125
+ { key: "title", label: u("fields.title") },
126
+ { key: "type", label: u("fields.type"), hideBelow: 520 }
127
+ ]), _ = g(() => m.fields.filter((i) => i.is_enabled));
128
+ async function p(i) {
129
+ try {
130
+ await navigator.clipboard.writeText(i), P.success(u("panel.copied"));
131
+ } catch {
132
+ }
133
+ }
134
+ return (i, h) => (v(), A("div", Le, [
135
+ l(e(q), {
136
+ title: e(u)("panel.embed-blade")
137
+ }, {
138
+ default: t(() => [
139
+ l(e(F), {
140
+ size: "sm",
141
+ tone: "muted"
142
+ }, {
143
+ default: t(() => [
144
+ k(y(e(u)("panel.embed-blade-help")), 1)
145
+ ]),
146
+ _: 1
147
+ }),
148
+ B("div", Me, [
149
+ B("code", null, y(o.value), 1),
150
+ l(e(K), {
151
+ icon: "copy",
152
+ title: e(u)("panel.copy"),
153
+ onClick: h[0] || (h[0] = (b) => p(o.value))
154
+ }, null, 8, ["title"])
155
+ ])
156
+ ]),
157
+ _: 1
158
+ }, 8, ["title"]),
159
+ l(e(q), {
160
+ title: e(u)("panel.embed-block")
161
+ }, {
162
+ default: t(() => [
163
+ l(e(F), {
164
+ size: "sm",
165
+ tone: "muted"
166
+ }, {
167
+ default: t(() => [
168
+ k(y(e(u)(w.value ? "panel.embed-block-panel-help" : "panel.embed-block-help")), 1)
169
+ ]),
170
+ _: 1
171
+ }),
172
+ B("div", Oe, [
173
+ B("code", null, y($.value), 1),
174
+ l(e(K), {
175
+ icon: "copy",
176
+ title: e(u)("panel.copy"),
177
+ onClick: h[1] || (h[1] = (b) => p($.value))
178
+ }, null, 8, ["title"])
179
+ ])
180
+ ]),
181
+ _: 1
182
+ }, 8, ["title"]),
183
+ l(e(q), {
184
+ title: e(u)("panel.embed-extras")
185
+ }, {
186
+ default: t(() => [
187
+ l(e(F), {
188
+ size: "sm",
189
+ tone: "muted"
190
+ }, {
191
+ default: t(() => [
192
+ k(y(e(u)("panel.embed-extras-help")), 1)
193
+ ]),
194
+ _: 1
195
+ }),
196
+ B("div", Re, [
197
+ B("code", null, y(U.value), 1),
198
+ l(e(K), {
199
+ icon: "copy",
200
+ title: e(u)("panel.copy"),
201
+ onClick: h[2] || (h[2] = (b) => p(U.value))
202
+ }, null, 8, ["title"])
203
+ ])
204
+ ]),
205
+ _: 1
206
+ }, 8, ["title"]),
207
+ l(e(q), {
208
+ title: e(u)("panel.embed-names")
209
+ }, {
210
+ default: t(() => [
211
+ l(e(F), {
212
+ size: "sm",
213
+ tone: "muted"
214
+ }, {
215
+ default: t(() => [
216
+ k(y(e(u)("panel.embed-names-help")), 1)
217
+ ]),
218
+ _: 1
219
+ }),
220
+ l(e(we), {
221
+ data: _.value,
222
+ columns: f.value,
223
+ "row-key": "id",
224
+ flush: "",
225
+ "empty-text": e(u)("fields.no-fields")
226
+ }, {
227
+ "cell-key": t(({ row: b }) => [
228
+ l(e(F), {
229
+ mono: "",
230
+ size: "sm"
231
+ }, {
232
+ default: t(() => [
233
+ k("fields[" + y(b.key) + "]", 1)
234
+ ]),
235
+ _: 2
236
+ }, 1024)
237
+ ]),
238
+ "cell-title": t(({ row: b }) => [
239
+ k(y(Object.values(b.title)[0] ?? b.key), 1)
240
+ ]),
241
+ "cell-type": t(({ row: b }) => [
242
+ k(y(e(u)(`fields.type-${b.type}`)), 1)
243
+ ]),
244
+ _: 1
245
+ }, 8, ["data", "columns", "empty-text"])
246
+ ]),
247
+ _: 1
248
+ }, 8, ["title"])
249
+ ]));
250
+ }
251
+ }), De = /* @__PURE__ */ Q(Pe, [["__scopeId", "data-v-7f9788ed"]]), Ge = { class: "wx-inbox-general" }, Ke = /* @__PURE__ */ D({
252
+ __name: "FormGeneral",
253
+ props: /* @__PURE__ */ oe({
254
+ errors: {}
255
+ }, {
256
+ settings: { required: !0 },
257
+ settingsModifiers: {},
258
+ options: { required: !0 },
259
+ optionsModifiers: {}
260
+ }),
261
+ emits: ["update:settings", "update:options"],
262
+ setup(c) {
263
+ const m = H(
264
+ c,
265
+ "settings"
266
+ ), u = H(c, "options"), s = G("webx-inbox"), w = C(u, "description", {}), o = C(u, "thank-you.heading", {}), $ = C(u, "thank-you.text", {}), r = C(u, "design.submit-text", {}), U = C(u, "redirect", null), f = g({
267
+ get: () => {
268
+ const _ = U.value;
269
+ return typeof _ == "string" ? { ...de(), target: "url", url: _ } : _ ?? { ...de(), target: "none" };
270
+ },
271
+ set: (_) => {
272
+ U.value = _ === null || _.target === "none" ? null : _;
273
+ }
274
+ });
275
+ return (_, p) => (v(), A("div", Ge, [
276
+ l(e(q), null, {
277
+ default: t(() => [
278
+ l(e(z), {
279
+ label: e(s)("panel.title"),
280
+ error: c.errors.title?.[0],
281
+ required: ""
282
+ }, {
283
+ default: t(() => [
284
+ l(e(M), {
285
+ modelValue: m.value.title,
286
+ "onUpdate:modelValue": p[0] || (p[0] = (i) => m.value.title = i),
287
+ localized: ""
288
+ }, null, 8, ["modelValue"])
289
+ ]),
290
+ _: 1
291
+ }, 8, ["label", "error"]),
292
+ l(e(z), {
293
+ label: e(s)("panel.description"),
294
+ help: e(s)("panel.description-help")
295
+ }, {
296
+ default: t(() => [
297
+ l(e(M), {
298
+ modelValue: e(w),
299
+ "onUpdate:modelValue": p[1] || (p[1] = (i) => T(w) ? w.value = i : null),
300
+ localized: ""
301
+ }, null, 8, ["modelValue"])
302
+ ]),
303
+ _: 1
304
+ }, 8, ["label", "help"]),
305
+ l(e(z), {
306
+ label: e(s)("panel.slug"),
307
+ help: e(s)("panel.slug-help"),
308
+ error: c.errors.slug?.[0],
309
+ required: ""
310
+ }, {
311
+ default: t(() => [
312
+ l(e(M), {
313
+ modelValue: m.value.slug,
314
+ "onUpdate:modelValue": p[2] || (p[2] = (i) => m.value.slug = i),
315
+ placeholder: "contact"
316
+ }, null, 8, ["modelValue"])
317
+ ]),
318
+ _: 1
319
+ }, 8, ["label", "help", "error"]),
320
+ l(e(z), {
321
+ help: e(s)("panel.is-enabled-help")
322
+ }, {
323
+ default: t(() => [
324
+ l(e(me), {
325
+ modelValue: m.value.is_enabled,
326
+ "onUpdate:modelValue": p[3] || (p[3] = (i) => m.value.is_enabled = i),
327
+ label: e(s)("panel.is-enabled")
328
+ }, null, 8, ["modelValue", "label"])
329
+ ]),
330
+ _: 1
331
+ }, 8, ["help"])
332
+ ]),
333
+ _: 1
334
+ }),
335
+ l(e(q), {
336
+ title: e(s)("panel.after-sending")
337
+ }, {
338
+ default: t(() => [
339
+ l(e(z), {
340
+ label: e(s)("panel.submit-text")
341
+ }, {
342
+ default: t(() => [
343
+ l(e(M), {
344
+ modelValue: e(r),
345
+ "onUpdate:modelValue": p[4] || (p[4] = (i) => T(r) ? r.value = i : null),
346
+ localized: ""
347
+ }, null, 8, ["modelValue"])
348
+ ]),
349
+ _: 1
350
+ }, 8, ["label"]),
351
+ l(e(z), {
352
+ label: e(s)("panel.thank-you-heading")
353
+ }, {
354
+ default: t(() => [
355
+ l(e(M), {
356
+ modelValue: e(o),
357
+ "onUpdate:modelValue": p[5] || (p[5] = (i) => T(o) ? o.value = i : null),
358
+ localized: ""
359
+ }, null, 8, ["modelValue"])
360
+ ]),
361
+ _: 1
362
+ }, 8, ["label"]),
363
+ l(e(z), {
364
+ label: e(s)("panel.thank-you-text")
365
+ }, {
366
+ default: t(() => [
367
+ l(Ie, {
368
+ modelValue: e($),
369
+ "onUpdate:modelValue": p[6] || (p[6] = (i) => T($) ? $.value = i : null)
370
+ }, null, 8, ["modelValue"])
371
+ ]),
372
+ _: 1
373
+ }, 8, ["label"]),
374
+ l(e(z), {
375
+ label: e(s)("panel.redirect"),
376
+ help: e(s)("panel.redirect-help"),
377
+ error: c.errors["options.redirect"]?.[0]
378
+ }, {
379
+ default: t(() => [
380
+ l(e(_e), {
381
+ modelValue: f.value,
382
+ "onUpdate:modelValue": p[7] || (p[7] = (i) => f.value = i),
383
+ attributes: !1
384
+ }, null, 8, ["modelValue"])
385
+ ]),
386
+ _: 1
387
+ }, 8, ["label", "help", "error"])
388
+ ]),
389
+ _: 1
390
+ }, 8, ["title"])
391
+ ]));
392
+ }
393
+ }), je = /* @__PURE__ */ Q(Ke, [["__scopeId", "data-v-1065e341"]]), He = /^[^\s@]+@[^\s@]+$/;
394
+ function j(c) {
395
+ return "admin_id" in c;
396
+ }
397
+ function ve(c, m = []) {
398
+ return j(c) ? m.find(
399
+ (s) => s.type === "admin" && s.admin_id === c.admin_id
400
+ )?.problem ?? null : He.test((c.email ?? "").trim()) ? null : "invalid_email";
401
+ }
402
+ function Je(c, m = []) {
403
+ return (c ?? []).some((u) => ve(u, m) === null);
404
+ }
405
+ const Qe = {
406
+ key: 1,
407
+ class: "wx-inbox-notifications__way",
408
+ "data-way": "email"
409
+ }, Xe = {
410
+ key: 1,
411
+ class: "wx-inbox-notifications__route"
412
+ }, Ye = { class: "wx-inbox-recipients" }, Ze = { class: "wx-inbox-recipients__row" }, el = {
413
+ key: 2,
414
+ class: "wx-inbox-notifications__way",
415
+ "data-way": "channels"
416
+ }, ll = { class: "wx-inbox-channels" }, tl = /* @__PURE__ */ D({
417
+ __name: "FormNotifications",
418
+ props: /* @__PURE__ */ oe({
419
+ fields: {},
420
+ errors: {},
421
+ reported: {},
422
+ notifications: { type: Boolean },
423
+ via: {},
424
+ mail: {}
425
+ }, {
426
+ modelValue: { required: !0 },
427
+ modelModifiers: {}
428
+ }),
429
+ emits: ["update:modelValue"],
430
+ setup(c) {
431
+ const m = c, u = H(c, "modelValue"), s = ie(), w = fe(s), o = G("webx-inbox"), $ = I([]), r = C(u, "recipients", []), U = C(u, "email_field", ""), f = C(u, "notify_channels", []), _ = g({
432
+ get: () => u.value.notify_via ?? m.via ?? "email",
433
+ set: (d) => {
434
+ u.value = { ...u.value, notify_via: d };
435
+ }
436
+ }), p = g(() => [
437
+ { value: "email", label: o("panel.via-email") },
438
+ { value: "channels", label: o("panel.via-channels") }
439
+ ]), i = g(() => !m.notifications || _.value === "email"), h = pe(), b = g(() => s.can("notifications.manage")), S = g(() => `${s.basePath}/notifications`.replace(/\/{2,}/g, "/"));
440
+ function se(d) {
441
+ d.metaKey || d.ctrlKey || d.shiftKey || d.button !== 0 || (d.preventDefault(), h.push("/notifications"));
442
+ }
443
+ be(async () => {
444
+ try {
445
+ $.value = await w.recipients();
446
+ } catch {
447
+ }
448
+ });
449
+ const E = g(
450
+ () => $.value.map((d) => ({ value: d.id, label: `${d.name} · ${d.email}` }))
451
+ ), X = g(() => [
452
+ { value: "", label: o("panel.no-email-field") },
453
+ ...m.fields.filter((d) => d.type === "email").map((d) => ({ value: d.key, label: Y(d) }))
454
+ ]);
455
+ function Y(d) {
456
+ const a = Object.values(d.title ?? {}).find(
457
+ (n) => typeof n == "string" && n.trim() !== ""
458
+ );
459
+ return a === void 0 ? d.name ?? d.key : d.name ? `${a} · ${d.name}` : a;
460
+ }
461
+ function O(d) {
462
+ if (!j(d)) return null;
463
+ const a = ve(d, m.reported);
464
+ return a === null ? null : o(`panel.recipient-${a}`);
465
+ }
466
+ function N(d) {
467
+ r.value = [...r.value, d];
468
+ }
469
+ async function Z(d) {
470
+ const a = r.value[d];
471
+ a !== void 0 && (j(a) || (a.email ?? "").trim() !== "") && !await Fe({
472
+ title: o("panel.remove-recipient-title"),
473
+ message: o("panel.remove-recipient-text"),
474
+ confirmText: o("panel.remove"),
475
+ cancelText: o("panel.cancel"),
476
+ tone: "danger"
477
+ }) || (r.value = r.value.filter((x, L) => L !== d));
478
+ }
479
+ function ee(d, a) {
480
+ r.value = r.value.map((n, x) => x === d ? { admin_id: a } : n);
481
+ }
482
+ function le(d, a) {
483
+ r.value = r.value.map((n, x) => x === d ? { email: a } : n);
484
+ }
485
+ return (d, a) => (v(), V(e(q), {
486
+ class: "wx-inbox-notifications",
487
+ title: m.notifications ? void 0 : e(o)("panel.recipients")
488
+ }, {
489
+ default: t(() => [
490
+ l(e(z), {
491
+ label: e(o)("panel.email-field"),
492
+ help: m.notifications ? e(o)("panel.email-field-help-channels") : e(o)("panel.email-field-help"),
493
+ error: c.errors["options.email_field"]?.[0]
494
+ }, {
495
+ default: t(() => [
496
+ l(e(ae), {
497
+ modelValue: e(U),
498
+ "onUpdate:modelValue": a[0] || (a[0] = (n) => T(U) ? U.value = n : null),
499
+ options: X.value
500
+ }, null, 8, ["modelValue", "options"])
501
+ ]),
502
+ _: 1
503
+ }, 8, ["label", "help", "error"]),
504
+ m.notifications ? (v(), V(e(z), {
505
+ key: 0,
506
+ label: e(o)("panel.notify-via")
507
+ }, {
508
+ default: t(() => [
509
+ l(e($e), {
510
+ modelValue: _.value,
511
+ "onUpdate:modelValue": a[1] || (a[1] = (n) => _.value = n),
512
+ options: p.value,
513
+ inline: ""
514
+ }, null, 8, ["modelValue", "options"])
515
+ ]),
516
+ _: 1
517
+ }, 8, ["label"])) : W("", !0),
518
+ i.value ? (v(), A("section", Qe, [
519
+ m.notifications ? (v(), V(e(F), {
520
+ key: 0,
521
+ weight: "medium"
522
+ }, {
523
+ default: t(() => [
524
+ k(y(e(o)("panel.recipients")), 1)
525
+ ]),
526
+ _: 1
527
+ })) : W("", !0),
528
+ l(e(F), {
529
+ size: "sm",
530
+ tone: "muted"
531
+ }, {
532
+ default: t(() => [
533
+ k(y(e(o)("panel.recipients-help")), 1)
534
+ ]),
535
+ _: 1
536
+ }),
537
+ c.mail ? (v(), A("div", Xe, [
538
+ l(e(F), {
539
+ size: "sm",
540
+ tone: "muted"
541
+ }, {
542
+ default: t(() => [
543
+ k(y(e(o)("panel.mail-route")) + " ", 1),
544
+ B("code", null, y(c.mail.route.label), 1)
545
+ ]),
546
+ _: 1
547
+ }),
548
+ c.mail.queue.hint ? (v(), V(e(F), {
549
+ key: 0,
550
+ size: "sm",
551
+ tone: "muted"
552
+ }, {
553
+ default: t(() => [
554
+ k(y(c.mail.queue.hint), 1)
555
+ ]),
556
+ _: 1
557
+ })) : W("", !0),
558
+ (v(!0), A(te, null, ue(c.mail.warnings, (n) => (v(), V(e(J), {
559
+ key: n.code,
560
+ type: "warning",
561
+ variant: "soft",
562
+ description: n.message
563
+ }, null, 8, ["description"]))), 128))
564
+ ])) : W("", !0),
565
+ c.errors["options.recipients"] ? (v(), V(e(J), {
566
+ key: 2,
567
+ type: "danger",
568
+ variant: "soft",
569
+ description: c.errors["options.recipients"]?.[0]
570
+ }, null, 8, ["description"])) : W("", !0),
571
+ B("div", Ye, [
572
+ e(r).length === 0 ? (v(), V(e(F), {
573
+ key: 0,
574
+ size: "sm",
575
+ tone: "placeholder"
576
+ }, {
577
+ default: t(() => [
578
+ k(y(e(o)("panel.no-recipients")), 1)
579
+ ]),
580
+ _: 1
581
+ })) : W("", !0),
582
+ (v(!0), A(te, null, ue(e(r), (n, x) => (v(), A("div", {
583
+ key: x,
584
+ class: "wx-inbox-recipients__item"
585
+ }, [
586
+ B("div", Ze, [
587
+ e(j)(n) ? (v(), V(e(ae), {
588
+ key: 0,
589
+ "model-value": n.admin_id,
590
+ options: E.value,
591
+ "onUpdate:modelValue": (L) => ee(x, Number(L))
592
+ }, null, 8, ["model-value", "options", "onUpdate:modelValue"])) : (v(), V(e(M), {
593
+ key: 1,
594
+ "model-value": n.email,
595
+ type: "email",
596
+ placeholder: "sales@example.com",
597
+ "onUpdate:modelValue": (L) => le(x, String(L))
598
+ }, null, 8, ["model-value", "onUpdate:modelValue"])),
599
+ l(e(K), {
600
+ icon: "trash",
601
+ tone: "danger",
602
+ title: e(o)("panel.remove"),
603
+ onClick: (L) => Z(x)
604
+ }, null, 8, ["title", "onClick"])
605
+ ]),
606
+ O(n) ? (v(), V(e(F), {
607
+ key: 0,
608
+ size: "sm",
609
+ tone: "danger"
610
+ }, {
611
+ default: t(() => [
612
+ k(y(O(n)), 1)
613
+ ]),
614
+ _: 2
615
+ }, 1024)) : W("", !0)
616
+ ]))), 128))
617
+ ]),
618
+ l(e(Ue), { size: "sm" }, {
619
+ default: t(() => [
620
+ l(e(ne), {
621
+ variant: "outline",
622
+ icon: "user",
623
+ disabled: E.value.length === 0,
624
+ onClick: a[2] || (a[2] = (n) => N({ admin_id: Number(E.value[0]?.value) }))
625
+ }, {
626
+ default: t(() => [
627
+ k(y(e(o)("panel.add-admin")), 1)
628
+ ]),
629
+ _: 1
630
+ }, 8, ["disabled"]),
631
+ l(e(ne), {
632
+ variant: "outline",
633
+ onClick: a[3] || (a[3] = (n) => N({ email: "" }))
634
+ }, {
635
+ icon: t(() => [
636
+ l(e(We), { name: "mail" })
637
+ ]),
638
+ default: t(() => [
639
+ k(" " + y(e(o)("panel.add-email")), 1)
640
+ ]),
641
+ _: 1
642
+ })
643
+ ]),
644
+ _: 1
645
+ })
646
+ ])) : (v(), A("section", el, [
647
+ l(e(F), { weight: "medium" }, {
648
+ default: t(() => [
649
+ k(y(e(o)("panel.notify-through")), 1)
650
+ ]),
651
+ _: 1
652
+ }),
653
+ l(e(F), {
654
+ size: "sm",
655
+ tone: "muted"
656
+ }, {
657
+ default: t(() => [
658
+ k(y(e(o)("panel.notify-through-help")), 1)
659
+ ]),
660
+ _: 1
661
+ }),
662
+ B("div", ll, [
663
+ l(e(he), {
664
+ modelValue: e(f),
665
+ "onUpdate:modelValue": a[4] || (a[4] = (n) => T(f) ? f.value = n : null),
666
+ target: "notify-inbox-submission",
667
+ sortable: !1,
668
+ "add-text": e(o)("panel.pick-channels"),
669
+ "empty-text": e(o)("panel.no-channels"),
670
+ "none-text": e(o)("panel.no-channels-yet")
671
+ }, null, 8, ["modelValue", "add-text", "empty-text", "none-text"]),
672
+ b.value ? (v(), V(e(ze), {
673
+ key: 0,
674
+ href: S.value,
675
+ size: "sm",
676
+ onClick: se
677
+ }, {
678
+ default: t(() => [
679
+ k(y(e(o)("panel.set-up-channels")), 1)
680
+ ]),
681
+ _: 1
682
+ }, 8, ["href"])) : W("", !0)
683
+ ])
684
+ ]))
685
+ ]),
686
+ _: 1
687
+ }, 8, ["title"]));
688
+ }
689
+ }), al = /* @__PURE__ */ Q(tl, [["__scopeId", "data-v-5fc21abd"]]), nl = { class: "wx-inbox-editor" }, ol = /* @__PURE__ */ D({
690
+ __name: "FormEditorPage",
691
+ props: {
692
+ base: { default: "/inbox" }
693
+ },
694
+ setup(c) {
695
+ const m = c, u = ie(), s = fe(u), w = ge(), o = pe(), $ = Se();
696
+ ce();
697
+ const r = G("webx-inbox"), U = ke(), f = I(null), _ = I([]), p = I(!0), i = I(!1), h = I({});
698
+ let b = xe({
699
+ slug: "",
700
+ title: {},
701
+ is_enabled: !0
702
+ });
703
+ const S = I({}), E = I(["general", "fields", "notifications", "antispam", "embed"].includes(String(w.query.tab)) ? String(w.query.tab) : "general"), X = g(
704
+ () => b.is_enabled && !Je(S.value.recipients, f.value?.recipients) && !Y.value
705
+ ), Y = g(() => {
706
+ if (f.value?.notifications !== !0) return !1;
707
+ const a = f.value.channels ?? [];
708
+ return (S.value.notify_channels ?? []).some(
709
+ (n) => a.find((x) => x.id === n)?.sends ?? !0
710
+ );
711
+ }), O = g(() => u.can("inbox.manage")), N = g(() => Number(w.params.id)), Z = g(
712
+ () => f.value === null ? "" : Ce(b.title, $.active.value, b.slug)
713
+ ), ee = g(() => `${m.base}?form=${N.value}`);
714
+ async function le() {
715
+ p.value = !0;
716
+ try {
717
+ const a = await s.form(N.value);
718
+ f.value = a, _.value = a.fields ?? [], b.slug = a.slug, b.title = { ...a.title }, b.is_enabled = a.is_enabled, S.value = { ...a.options };
719
+ } catch (a) {
720
+ P.danger(U(a)), o.replace(m.base);
721
+ } finally {
722
+ p.value = !1;
723
+ }
724
+ }
725
+ ye(N, () => {
726
+ le();
727
+ }, { immediate: !0 });
728
+ async function d() {
729
+ i.value = !0, h.value = {};
730
+ try {
731
+ const a = await s.saveForm(N.value, {
732
+ slug: b.slug.trim(),
733
+ title: b.title,
734
+ is_enabled: b.is_enabled,
735
+ options: S.value
736
+ });
737
+ f.value = a, P.success(r("panel.saved"));
738
+ } catch (a) {
739
+ const n = a.body;
740
+ n?.errors ? (h.value = n.errors, P.danger(r("panel.failed"))) : P.danger(U(a));
741
+ } finally {
742
+ i.value = !1;
743
+ }
744
+ }
745
+ return (a, n) => (v(), A("div", nl, [
746
+ p.value ? (v(), V(e(q), { key: 0 }, {
747
+ default: t(() => [
748
+ l(e(Te), {
749
+ title: "",
750
+ rows: 8
751
+ })
752
+ ]),
753
+ _: 1
754
+ })) : f.value ? (v(), A(te, { key: 1 }, [
755
+ l(e(Ve), {
756
+ class: "wx-inbox-editor__head",
757
+ title: Z.value,
758
+ subtitle: f.value.slug,
759
+ back: ee.value,
760
+ "back-label": e(r)("panel.forms")
761
+ }, {
762
+ "title-after": t(() => [
763
+ e(b).is_enabled ? W("", !0) : (v(), V(e(Ae), {
764
+ key: 0,
765
+ type: "default"
766
+ }, {
767
+ default: t(() => [
768
+ k(y(e(r)("panel.off")), 1)
769
+ ]),
770
+ _: 1
771
+ }))
772
+ ]),
773
+ _: 1
774
+ }, 8, ["title", "subtitle", "back", "back-label"]),
775
+ X.value ? (v(), V(e(J), {
776
+ key: 0,
777
+ class: "wx-inbox-editor__silent",
778
+ type: "warning",
779
+ variant: "soft",
780
+ closable: !1,
781
+ title: e(r)("panel.notifies-nobody"),
782
+ description: e(r)("panel.notifies-nobody-text")
783
+ }, null, 8, ["title", "description"])) : W("", !0),
784
+ l(e(Be), {
785
+ modelValue: E.value,
786
+ "onUpdate:modelValue": n[5] || (n[5] = (x) => E.value = x),
787
+ class: "wx-inbox-editor__tabs",
788
+ "keep-alive": ""
789
+ }, {
790
+ default: t(() => [
791
+ l(e(R), {
792
+ value: "general",
793
+ label: e(r)("panel.tab-general")
794
+ }, {
795
+ default: t(() => [
796
+ l(je, {
797
+ settings: e(b),
798
+ "onUpdate:settings": n[0] || (n[0] = (x) => T(b) ? b.value = x : b = x),
799
+ options: S.value,
800
+ "onUpdate:options": n[1] || (n[1] = (x) => S.value = x),
801
+ errors: h.value
802
+ }, null, 8, ["settings", "options", "errors"])
803
+ ]),
804
+ _: 1
805
+ }, 8, ["label"]),
806
+ l(e(R), {
807
+ value: "fields",
808
+ label: e(r)("panel.tab-fields")
809
+ }, {
810
+ default: t(() => [
811
+ l(Ne, {
812
+ modelValue: _.value,
813
+ "onUpdate:modelValue": n[2] || (n[2] = (x) => _.value = x),
814
+ form: f.value,
815
+ "can-manage": O.value
816
+ }, null, 8, ["modelValue", "form", "can-manage"])
817
+ ]),
818
+ _: 1
819
+ }, 8, ["label"]),
820
+ l(e(R), {
821
+ value: "notifications",
822
+ label: e(r)("panel.tab-notifications")
823
+ }, {
824
+ default: t(() => [
825
+ l(al, {
826
+ modelValue: S.value,
827
+ "onUpdate:modelValue": n[3] || (n[3] = (x) => S.value = x),
828
+ fields: _.value,
829
+ errors: h.value,
830
+ reported: f.value.recipients,
831
+ notifications: f.value.notifications,
832
+ via: f.value.notify_via,
833
+ mail: f.value.mail
834
+ }, null, 8, ["modelValue", "fields", "errors", "reported", "notifications", "via", "mail"])
835
+ ]),
836
+ _: 1
837
+ }, 8, ["label"]),
838
+ l(e(R), {
839
+ value: "antispam",
840
+ label: e(r)("panel.tab-antispam")
841
+ }, {
842
+ default: t(() => [
843
+ l(Ee, {
844
+ modelValue: S.value,
845
+ "onUpdate:modelValue": n[4] || (n[4] = (x) => S.value = x),
846
+ site: f.value.captcha
847
+ }, null, 8, ["modelValue", "site"])
848
+ ]),
849
+ _: 1
850
+ }, 8, ["label"]),
851
+ l(e(R), {
852
+ value: "embed",
853
+ label: e(r)("panel.tab-embed")
854
+ }, {
855
+ default: t(() => [
856
+ l(De, {
857
+ form: f.value,
858
+ slug: e(b).slug,
859
+ fields: _.value
860
+ }, null, 8, ["form", "slug", "fields"])
861
+ ]),
862
+ _: 1
863
+ }, 8, ["label"])
864
+ ]),
865
+ _: 1
866
+ }, 8, ["modelValue"]),
867
+ O.value ? (v(), V(e(qe), { key: 1 }, {
868
+ default: t(() => [
869
+ l(e(ne), {
870
+ type: "primary",
871
+ loading: i.value,
872
+ onClick: d
873
+ }, {
874
+ default: t(() => [
875
+ k(y(e(r)("panel.save")), 1)
876
+ ]),
877
+ _: 1
878
+ }, 8, ["loading"])
879
+ ]),
880
+ _: 1
881
+ })) : W("", !0)
882
+ ], 64)) : W("", !0)
883
+ ]));
884
+ }
885
+ }), pl = /* @__PURE__ */ Q(ol, [["__scopeId", "data-v-1d18ccd2"]]);
886
+ export {
887
+ pl as default
888
+ };
889
+ //# sourceMappingURL=FormEditorPage-B2Q0gTp3.js.map