@webx-ui/module-notifications 0.2.1 → 0.3.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,1279 +0,0 @@
1
- import { defineComponent as L, useModel as H, computed as h, openBlock as u, createElementBlock as T, createVNode as w, unref as s, createBlock as y, withCtx as m, createTextVNode as _, toDisplayString as v, createCommentVNode as N, mergeModels as q, provide as ve, inject as be, ref as V, onMounted as re, isRef as we, Fragment as j, renderList as E, createElementVNode as P, defineAsyncComponent as ce } from "vue";
2
- import { useRouter as ge } from "vue-router";
3
- import { WxLink as ye, useModal as _e, WxDialog as ke, WxSkeleton as xe, WxAlert as R, WxEmpty as $e, WxCheckbox as Te, WxText as A, WxBadge as Z, WxSpace as ee, WxButton as F, createModal as Ce, WxInput as Q, WxAction as de, WxIcon as D, toast as te, WxSelect as Se, useLocales as ue, mustacheCompletions as Ae, mustacheProblems as We, WxCodeEditor as Ne, WxTooltip as Ve, localizedValue as ne, WxCard as je } from "@webx-ui/core";
4
- import { useAdmin as K, useTranslate as U, WxRelationsField as Fe, useErrorText as Oe } from "@webx-ui/module-admin";
5
- import ze from "mustache";
6
- const Me = {
7
- module: {
8
- title: "Notifications",
9
- channel: "Channel",
10
- statuses: {
11
- queued: "Queued",
12
- sent: "Sent",
13
- failed: "Failed",
14
- skipped: "Skipped"
15
- },
16
- reasons: {
17
- channel_deleted: "The channel is deleted",
18
- channel_disabled: "The channel is switched off",
19
- wrong_event: "The channel is for another event",
20
- provider_missing: "The provider is not installed",
21
- no_recipients: "The channel has no recipients",
22
- no_address: "The event brought no address",
23
- admin_deleted: "The administrator is deleted",
24
- admin_inactive: "The administrator is switched off"
25
- }
26
- },
27
- screen: {
28
- "any-event": "Any event"
29
- },
30
- panel: {
31
- channels: "Channels",
32
- log: "Log",
33
- bin: "Bin",
34
- new: "New channel",
35
- untitled: "Untitled channel",
36
- "new-title": "New channel",
37
- "new-help": "The kind is chosen once. An event is optional: with one, the editor knows its variables and only that event offers the channel.",
38
- "new-provider": "Kind",
39
- "new-event": "For the event",
40
- "new-create": "Continue",
41
- "any-event": "Any event",
42
- "event-undeclared": "Event not declared",
43
- "event-undeclared-text": "No installed module declares “:event” any more. The channel works as one for any event.",
44
- "provider-undeclared": "Provider not installed",
45
- "provider-undeclared-text": "The provider “:provider” is not installed on the site: the channel sends nothing.",
46
- unreadable: "The channel's secrets cannot be read: the application key has changed. Enter them again.",
47
- recipients: "Recipients: :count",
48
- "never-sent": "Nothing sent yet",
49
- off: "Off",
50
- enable: "Enabled",
51
- enabled: "Switched on.",
52
- disabled: "Switched off.",
53
- edit: "Edit",
54
- copy: "Make a copy",
55
- copied: "A copy is made, switched off: “:name”.",
56
- "copied-from": "The secrets were copied from channel #:id. Replace them if this channel needs another bot or server.",
57
- delete: "Delete",
58
- "delete-title": "Delete “:title”?",
59
- "delete-text": "The channel goes to the bin and sends nothing. The modules that chose it keep it, and it comes back to them when it is restored.",
60
- deleted: "The channel is in the bin.",
61
- restore: "Restore",
62
- restored: "The channel is back.",
63
- purge: "Delete for good",
64
- "purge-title": "Delete “:title” for good?",
65
- "purge-text": "The channel disappears from every module that chose it. Its lines in the log stay, without a link to it.",
66
- purged: "The channel is deleted for good.",
67
- cancel: "Cancel",
68
- save: "Save",
69
- saved: "Saved.",
70
- "saved-warning": "Saved, but look: :warning",
71
- "save-failed": "Not saved: look at the fields marked in red.",
72
- "leave-title": "Leave without saving?",
73
- "leave-text": "The changes to this channel will be lost.",
74
- leave: "Leave",
75
- "empty-channels-text": "A channel is where notifications go and how they read: a Telegram bot and its chats, or e-mail and its addresses.",
76
- "empty-bin": "The bin is empty",
77
- environment: "The site runs as “:environment”: notifications are sent all the same. Switch channels off on a copy of the site.",
78
- "mode-after-response": "The site has no queue worker: notifications are sent right after the page answers, without retries in the background.",
79
- "secret-set": "Set. Type a new one to replace it.",
80
- forget: "Forget :field",
81
- forgotten: ":field will be forgotten on save.",
82
- check: "Check the connection",
83
- "check-ok": "Connection works.",
84
- test: "Send a test",
85
- "test-title": "Send a test",
86
- "test-help": "Sent now, past the queue, with the example values of the event — even through a channel that is switched off. What the form has is used, saved or not.",
87
- "test-to": "To",
88
- "test-everybody": "Everybody on the list",
89
- "test-send": "Send",
90
- "test-sent": "Sent to :recipient.",
91
- "test-failed": "Not sent to :recipient: :error",
92
- "test-none": "The channel has no recipients to send a test to.",
93
- preview: "Preview",
94
- "preview-help": "The message as it goes out, on the example values of the event.",
95
- "preview-no-event": "For any event: the variables are empty here.",
96
- "preview-subject": "Subject",
97
- "preview-empty": "The message is empty.",
98
- "preview-truncated": "Longer than :limit characters: Telegram gets it as plain text, cut to fit.",
99
- "preview-unknown": "Empty in this message: :names.",
100
- "preview-refused": "The template cannot be drawn:",
101
- variables: "Variables",
102
- "variables-help": "A click puts it where the cursor is; type {{ to see them in the editor.",
103
- "variables-none": "A channel for any event knows no variables. Choose an event to get its list, or type the names it gives.",
104
- "variable-list": "list of :fields",
105
- "problem-unclosed": "The section {{#:name}} is not closed: end it with {{/:name}}.",
106
- "problem-stray": "{{/:name}} closes a section that was never opened.",
107
- "problem-unknown": "Not a variable of this event: :names.",
108
- "problem-refused": ":tag is not available in a message template.",
109
- "problem-broken": "A tag is not closed: end it with }}.",
110
- "hint-variable": "variable",
111
- "hint-list": "list",
112
- "hint-field": "field of :list",
113
- "hint-section": "shown when :name has a value",
114
- "hint-inverted": "shown when :name is empty",
115
- "hint-close": "closes :name",
116
- "hint-comment": "a comment, never printed",
117
- "hint-example": "Example: :example",
118
- "add-chat": "Add a chat",
119
- "chat-id": "Chat id",
120
- "chat-label": "Label",
121
- "find-chats": "Find chats",
122
- "find-title": "Chats the bot has seen",
123
- "find-help": "Write to the bot, or add it to a group and write there, then search again.",
124
- "find-add": "Add the chosen",
125
- "find-token": "Type the bot token first.",
126
- "find-added": "Chats added: :count.",
127
- "chat-private": "Private",
128
- "chat-group": "Group",
129
- "chat-supergroup": "Supergroup",
130
- "chat-channel": "Channel",
131
- addressee: "From the event: :label",
132
- "add-admin": "Add an administrator",
133
- "add-email": "Add an address",
134
- "admin-unknown": "Administrator #:id",
135
- remove: "Remove",
136
- "no-recipients": "No recipients yet.",
137
- "column-when": "When",
138
- "column-channel": "Channel",
139
- "column-recipient": "Recipient",
140
- "column-status": "Status",
141
- "column-attempts": "Attempts",
142
- "all-statuses": "Any status",
143
- "all-channels": "Any channel",
144
- "with-tests": "Tests too",
145
- "test-mark": "Test",
146
- "cut-mark": "Cut",
147
- "log-empty": "Nothing sent yet.",
148
- retry: "Send again",
149
- retried: "Queued again.",
150
- "open-subject": "Open",
151
- "unknown-variables": "Empty variables: :names",
152
- "channel-gone": "deleted",
153
- filters: "Filters",
154
- "pick-channels": "Choose channels",
155
- "set-up-channels": "Set up channels"
156
- },
157
- errors: {
158
- "template-unclosed": "The section {{#:section}} is not closed: end it with {{/:section}}.",
159
- "template-unexpected": "{{/:section}} closes a section that was never opened.",
160
- "template-tag": "The tag {{:tag is not closed: end it with }}.",
161
- "template-name": "{{:name}} is not a variable name: lowercase letters, digits and _, one dot at most.",
162
- "template-partial": "Partials ({{>name}}) are not available in a message template.",
163
- "template-delimiters": "Changing the delimiters ({{=<% %>=}}) is not available in a message template.",
164
- "template-pragma": "Pragmas and blocks ({{%…}}, {{$…}}) are not available in a message template."
165
- }
166
- }, ae = /* @__PURE__ */ new WeakSet();
167
- function I() {
168
- try {
169
- const { i18n: t } = K();
170
- ae.has(t) || (t.defaults("webx-notifications", Me), ae.add(t));
171
- } catch {
172
- }
173
- }
174
- const Ee = { class: "wx-notification-channels" }, Pe = /* @__PURE__ */ L({
175
- name: "WxNotificationChannelsField",
176
- __name: "ChannelsField",
177
- props: /* @__PURE__ */ q({
178
- event: {},
179
- disabled: { type: Boolean, default: !1 },
180
- base: { default: "/notifications" },
181
- addText: { default: void 0 },
182
- emptyText: { default: void 0 }
183
- }, {
184
- modelValue: { default: () => [] },
185
- modelModifiers: {}
186
- }),
187
- emits: ["update:modelValue"],
188
- setup(t) {
189
- const e = t, a = H(t, "modelValue");
190
- I();
191
- const i = K(), n = U("webx-notifications"), l = h(() => `notify-${e.event.replace(/[._]/g, "-")}`), o = h(() => i.can("notifications.manage")), d = ge(), g = h(() => `${i.basePath}${e.base}`.replace(/\/{2,}/g, "/"));
192
- function k(x) {
193
- x.metaKey || x.ctrlKey || x.shiftKey || x.button !== 0 || (x.preventDefault(), d.push(e.base));
194
- }
195
- return (x, $) => (u(), T("div", Ee, [
196
- w(s(Fe), {
197
- modelValue: a.value,
198
- "onUpdate:modelValue": $[0] || ($[0] = (C) => a.value = C),
199
- target: l.value,
200
- sortable: !1,
201
- disabled: e.disabled,
202
- "add-text": e.addText ?? s(n)("panel.pick-channels"),
203
- "empty-text": e.emptyText
204
- }, null, 8, ["modelValue", "target", "disabled", "add-text", "empty-text"]),
205
- o.value ? (u(), y(s(ye), {
206
- key: 0,
207
- href: g.value,
208
- size: "sm",
209
- onClick: k
210
- }, {
211
- default: m(() => [
212
- _(v(s(n)("panel.set-up-channels")), 1)
213
- ]),
214
- _: 1
215
- }, 8, ["href"])) : N("", !0)
216
- ]));
217
- }
218
- }), B = (t, e) => {
219
- const a = t.__vccOpts || t;
220
- for (const [i, n] of e)
221
- a[i] = n;
222
- return a;
223
- }, Le = /* @__PURE__ */ B(Pe, [["__scopeId", "data-v-e0a57880"]]), pe = /* @__PURE__ */ Symbol("wx-notifications-channel");
224
- function jt(t, e, a) {
225
- const i = {
226
- meta: t,
227
- values: e,
228
- id: a,
229
- provider: h(
230
- () => t.value?.providers.find((n) => n.key === e.value.provider) ?? null
231
- ),
232
- event: h(() => t.value?.events.find((n) => n.key === e.value.event) ?? null)
233
- };
234
- return ve(pe, i), i;
235
- }
236
- function G() {
237
- return be(pe, null) ?? {
238
- meta: V(null),
239
- values: V({}),
240
- id: V(null),
241
- provider: h(() => null),
242
- event: h(() => null)
243
- };
244
- }
245
- const Ue = "notifications";
246
- function Ie(t) {
247
- const e = new URLSearchParams();
248
- for (const [i, n] of Object.entries(t))
249
- n == null || n === "" || e.set(i, typeof n == "boolean" ? n ? "1" : "0" : String(n));
250
- const a = e.toString();
251
- return a === "" ? "" : `?${a}`;
252
- }
253
- function me(t) {
254
- const e = `${t.apiPath}/${Ue}`, a = (n) => n.data, i = (n) => n === null ? e : `${e}/channels/${n}`;
255
- return {
256
- meta: () => t.http.get(`${e}/meta`).then(a),
257
- channels: (n = {}) => {
258
- const l = new URLSearchParams();
259
- n.trashed && l.set("trashed", "1"), n.event && l.set("event", n.event);
260
- const o = l.toString();
261
- return t.http.get(`${e}/channels${o === "" ? "" : `?${o}`}`);
262
- },
263
- get: (n) => t.http.get(`${e}/channels/${n}`).then(a),
264
- create: (n) => t.http.post(`${e}/channels`, { values: n }).then(a),
265
- save: (n, l) => t.http.put(`${e}/channels/${n}`, { values: l }).then(a),
266
- remove: (n) => t.http.delete(`${e}/channels/${n}`).then(() => {
267
- }),
268
- restore: (n) => t.http.post(`${e}/channels/${n}/restore`, {}).then(a),
269
- purge: (n) => t.http.delete(`${e}/channels/${n}/purge`).then(() => {
270
- }),
271
- copy: (n, l) => t.http.post(`${e}/channels/${n}/copy`, l ? { name: l } : {}).then(a),
272
- test: (n, l, o) => t.http.post(`${i(n)}/test`, {
273
- values: l,
274
- ...o ? { recipient: o } : {}
275
- }).then((d) => d.data.results),
276
- preview: (n, l, o) => t.http.post(`${i(n)}/preview`, { values: l, locale: o }).then(a),
277
- check: (n, l) => t.http.post(`${e}/check`, { values: l, ...n ? { channel: n } : {} }).then(a),
278
- findRecipients: ({ provider: n, channel: l, token: o }) => t.http.post(
279
- `${e}/find-recipients`,
280
- { provider: n, ...l ? { channel: l } : {}, ...o ? { token: o } : {} }
281
- ).then(a),
282
- administrators: () => t.http.get(`${e}/administrators`).then(a),
283
- deliveries: (n = {}) => t.http.get(`${e}/deliveries${Ie(n)}`),
284
- retry: (n) => t.http.post(`${e}/deliveries/${n}/retry`, {}).then(a)
285
- };
286
- }
287
- const Be = {
288
- key: 3,
289
- class: "wx-notifications-found"
290
- }, Re = { class: "wx-notifications-found__text" }, De = /* @__PURE__ */ L({
291
- name: "WxNotificationsFindChats",
292
- __name: "FindChatsDialog",
293
- props: {
294
- channel: { default: null },
295
- token: { default: "" },
296
- chosen: { default: () => [] }
297
- },
298
- setup(t) {
299
- const e = t, { open: a, resolve: i, dismiss: n } = _e(), l = me(K());
300
- I();
301
- const o = U("webx-notifications"), d = Oe(), g = V([]), k = V(null), x = V(null), $ = V(!0), C = V(/* @__PURE__ */ new Set());
302
- async function S() {
303
- $.value = !0, x.value = null;
304
- try {
305
- const c = await l.findRecipients({
306
- provider: "telegram",
307
- channel: e.channel,
308
- token: e.token.trim() === "" ? void 0 : e.token.trim()
309
- });
310
- g.value = c.recipients, k.value = c.hint;
311
- } catch (c) {
312
- x.value = d(c);
313
- } finally {
314
- $.value = !1;
315
- }
316
- }
317
- re(() => {
318
- S();
319
- });
320
- const M = h(() => g.value.filter((c) => !e.chosen.includes(c.id)));
321
- function b(c, p) {
322
- const f = new Set(C.value);
323
- p ? f.add(c) : f.delete(c), C.value = f;
324
- }
325
- function r() {
326
- i(M.value.filter((c) => C.value.has(c.id)));
327
- }
328
- return (c, p) => (u(), y(s(ke), {
329
- open: s(a),
330
- "onUpdate:open": p[1] || (p[1] = (f) => we(a) ? a.value = f : null),
331
- title: s(o)("panel.find-title"),
332
- width: 480
333
- }, {
334
- footer: m(() => [
335
- w(s(ee), { size: "sm" }, {
336
- default: m(() => [
337
- w(s(F), {
338
- variant: "outline",
339
- disabled: $.value,
340
- onClick: S
341
- }, {
342
- default: m(() => [
343
- _(v(s(o)("panel.find-chats")), 1)
344
- ]),
345
- _: 1
346
- }, 8, ["disabled"]),
347
- w(s(F), {
348
- variant: "outline",
349
- onClick: p[0] || (p[0] = (f) => s(n)())
350
- }, {
351
- default: m(() => [
352
- _(v(s(o)("panel.cancel")), 1)
353
- ]),
354
- _: 1
355
- }),
356
- w(s(F), {
357
- type: "primary",
358
- disabled: C.value.size === 0,
359
- onClick: r
360
- }, {
361
- default: m(() => [
362
- _(v(s(o)("panel.find-add")), 1)
363
- ]),
364
- _: 1
365
- }, 8, ["disabled"])
366
- ]),
367
- _: 1
368
- })
369
- ]),
370
- default: m(() => [
371
- $.value ? (u(), y(s(xe), {
372
- key: 0,
373
- rows: 3
374
- })) : x.value ? (u(), y(s(R), {
375
- key: 1,
376
- type: "danger",
377
- variant: "soft",
378
- description: x.value
379
- }, null, 8, ["description"])) : g.value.length === 0 ? (u(), y(s($e), {
380
- key: 2,
381
- title: s(o)("panel.find-title"),
382
- description: k.value ?? s(o)("panel.find-help")
383
- }, null, 8, ["title", "description"])) : (u(), T("ul", Be, [
384
- (u(!0), T(j, null, E(g.value, (f) => (u(), T("li", {
385
- key: f.id,
386
- class: "wx-notifications-found__row"
387
- }, [
388
- w(s(Te), {
389
- "model-value": e.chosen.includes(f.id) || C.value.has(f.id),
390
- disabled: e.chosen.includes(f.id),
391
- "onUpdate:modelValue": (W) => b(f.id, W)
392
- }, {
393
- default: m(() => [
394
- P("span", Re, [
395
- w(s(A), { truncate: "" }, {
396
- default: m(() => [
397
- _(v(f.title), 1)
398
- ]),
399
- _: 2
400
- }, 1024),
401
- w(s(A), {
402
- size: "sm",
403
- tone: "muted",
404
- mono: "",
405
- truncate: ""
406
- }, {
407
- default: m(() => [
408
- _(v([f.id, f.username].filter(Boolean).join(" · ")), 1)
409
- ]),
410
- _: 2
411
- }, 1024)
412
- ])
413
- ]),
414
- _: 2
415
- }, 1032, ["model-value", "disabled", "onUpdate:modelValue"]),
416
- w(s(Z), null, {
417
- default: m(() => [
418
- _(v(s(o)(`panel.chat-${f.type}`)), 1)
419
- ]),
420
- _: 2
421
- }, 1024)
422
- ]))), 128))
423
- ]))
424
- ]),
425
- _: 1
426
- }, 8, ["open", "title"]));
427
- }
428
- }), He = /* @__PURE__ */ B(De, [["__scopeId", "data-v-71616d40"]]);
429
- function qe(t) {
430
- return (t?.variables ?? []).map((e) => ({
431
- name: e.name,
432
- label: e.label,
433
- example: e.example,
434
- fields: e.fields.length > 0 ? e.fields : void 0
435
- }));
436
- }
437
- function Ke(t, e = "value") {
438
- const a = t.name.endsWith(".*") ? `${t.name.slice(0, -2)}.name` : t.name;
439
- if ((t.fields?.length ?? 0) > 0) {
440
- const i = (t.fields ?? []).map((n) => `{{${n.name}}}`).join(" ");
441
- return `{{#${a}}}
442
- ${i}
443
- {{/${a}}}`;
444
- }
445
- return e === "has" ? `{{#${a}}}{{${a}}}{{/${a}}}` : e === "empty" ? `{{^${a}}}{{/${a}}}` : `{{${a}}}`;
446
- }
447
- function fe(t, e) {
448
- return (t?.variables ?? []).filter((a) => a.address === e);
449
- }
450
- const Ge = { class: "wx-notifications-recipients" }, Qe = /* @__PURE__ */ L({
451
- name: "WxNotificationsChatsField",
452
- __name: "ChatsField",
453
- props: /* @__PURE__ */ q({
454
- disabled: { type: Boolean, default: !1 }
455
- }, {
456
- modelValue: { default: () => [] },
457
- modelModifiers: {}
458
- }),
459
- emits: ["update:modelValue"],
460
- setup(t) {
461
- const e = t, a = H(t, "modelValue");
462
- I();
463
- const i = U("webx-notifications"), n = G(), l = Ce(He), o = h(() => Array.isArray(a.value) ? a.value : []), d = h(() => fe(n.event.value, "telegram")), g = h(
464
- () => d.value.filter((r) => !o.value.some((c) => c.variable === r.name))
465
- );
466
- function k(r) {
467
- return d.value.find((c) => c.name === r)?.label ?? `{{${r}}}`;
468
- }
469
- function x(r, c) {
470
- a.value = o.value.map((p, f) => f === r ? { ...p, ...c } : p);
471
- }
472
- function $(r) {
473
- a.value = [...o.value, r];
474
- }
475
- function C(r) {
476
- a.value = o.value.filter((c, p) => p !== r);
477
- }
478
- const S = h(() => {
479
- const r = n.values.value.token;
480
- return typeof r == "string" ? r : "";
481
- }), M = h(
482
- () => S.value.trim() !== "" || n.id.value !== null && n.values.value.provider === "telegram"
483
- );
484
- async function b() {
485
- if (!M.value) {
486
- te.warning(i("panel.find-token"));
487
- return;
488
- }
489
- const r = await l({
490
- channel: n.id.value,
491
- token: S.value,
492
- chosen: o.value.map((c) => c.chat_id ?? "").filter(Boolean)
493
- });
494
- !r || r.length === 0 || (a.value = [...o.value, ...r.map((c) => ({ chat_id: c.id, label: c.title }))], te.success(i("panel.find-added", { count: String(r.length) })));
495
- }
496
- return (r, c) => (u(), T("div", Ge, [
497
- o.value.length === 0 ? (u(), y(s(A), {
498
- key: 0,
499
- size: "sm",
500
- tone: "placeholder"
501
- }, {
502
- default: m(() => [
503
- _(v(s(i)("panel.no-recipients")), 1)
504
- ]),
505
- _: 1
506
- })) : N("", !0),
507
- (u(!0), T(j, null, E(o.value, (p, f) => (u(), T("div", {
508
- key: f,
509
- class: "wx-notifications-recipients__row"
510
- }, [
511
- p.variable ? (u(), y(s(Z), {
512
- key: 0,
513
- type: "primary",
514
- class: "wx-notifications-recipients__addressee"
515
- }, {
516
- default: m(() => [
517
- _(v(s(i)("panel.addressee", { label: k(p.variable) })), 1)
518
- ]),
519
- _: 2
520
- }, 1024)) : (u(), T(j, { key: 1 }, [
521
- w(s(Q), {
522
- class: "wx-notifications-recipients__id",
523
- "model-value": p.chat_id ?? "",
524
- placeholder: s(i)("panel.chat-id"),
525
- "aria-label": s(i)("panel.chat-id"),
526
- disabled: e.disabled,
527
- inputmode: "text",
528
- "onUpdate:modelValue": (W) => x(f, { chat_id: String(W ?? "") })
529
- }, null, 8, ["model-value", "placeholder", "aria-label", "disabled", "onUpdate:modelValue"]),
530
- w(s(Q), {
531
- class: "wx-notifications-recipients__label",
532
- "model-value": p.label ?? "",
533
- placeholder: s(i)("panel.chat-label"),
534
- "aria-label": s(i)("panel.chat-label"),
535
- disabled: e.disabled,
536
- "onUpdate:modelValue": (W) => x(f, { label: String(W ?? "") })
537
- }, null, 8, ["model-value", "placeholder", "aria-label", "disabled", "onUpdate:modelValue"])
538
- ], 64)),
539
- e.disabled ? N("", !0) : (u(), y(s(de), {
540
- key: 2,
541
- icon: "trash",
542
- tone: "danger",
543
- title: s(i)("panel.remove"),
544
- onClick: (W) => C(f)
545
- }, null, 8, ["title", "onClick"]))
546
- ]))), 128)),
547
- e.disabled ? N("", !0) : (u(), y(s(ee), {
548
- key: 1,
549
- size: "sm",
550
- wrap: ""
551
- }, {
552
- default: m(() => [
553
- w(s(F), {
554
- variant: "outline",
555
- size: "sm",
556
- onClick: c[0] || (c[0] = (p) => $({ chat_id: "", label: "" }))
557
- }, {
558
- icon: m(() => [
559
- w(s(D), { name: "plus" })
560
- ]),
561
- default: m(() => [
562
- _(" " + v(s(i)("panel.add-chat")), 1)
563
- ]),
564
- _: 1
565
- }),
566
- w(s(F), {
567
- variant: "outline",
568
- size: "sm",
569
- onClick: b
570
- }, {
571
- icon: m(() => [
572
- w(s(D), { name: "search" })
573
- ]),
574
- default: m(() => [
575
- _(" " + v(s(i)("panel.find-chats")), 1)
576
- ]),
577
- _: 1
578
- }),
579
- (u(!0), T(j, null, E(g.value, (p) => (u(), y(s(F), {
580
- key: p.name,
581
- variant: "outline",
582
- size: "sm",
583
- onClick: (f) => $({ variable: p.name })
584
- }, {
585
- default: m(() => [
586
- _(v(s(i)("panel.addressee", { label: p.label })), 1)
587
- ]),
588
- _: 2
589
- }, 1032, ["onClick"]))), 128))
590
- ]),
591
- _: 1
592
- }))
593
- ]));
594
- }
595
- }), Xe = /* @__PURE__ */ B(Qe, [["__scopeId", "data-v-00cd60ee"]]), Je = { class: "wx-notifications-recipients" }, Ye = /* @__PURE__ */ L({
596
- name: "WxNotificationsEmailsField",
597
- __name: "EmailsField",
598
- props: /* @__PURE__ */ q({
599
- disabled: { type: Boolean, default: !1 }
600
- }, {
601
- modelValue: { default: () => [] },
602
- modelModifiers: {}
603
- }),
604
- emits: ["update:modelValue"],
605
- setup(t) {
606
- const e = t, a = H(t, "modelValue");
607
- I();
608
- const i = U("webx-notifications"), n = G(), l = K(), o = V([]);
609
- re(async () => {
610
- try {
611
- o.value = await me(l).administrators();
612
- } catch {
613
- }
614
- });
615
- const d = h(() => Array.isArray(a.value) ? a.value : []), g = h(
616
- () => o.value.map((r) => ({ value: r.id, label: `${r.name} · ${r.email}` }))
617
- ), k = h(() => fe(n.event.value, "email")), x = h(
618
- () => k.value.filter((r) => !d.value.some((c) => c.variable === r.name))
619
- );
620
- function $(r) {
621
- return k.value.find((c) => c.name === r)?.label ?? `{{${r}}}`;
622
- }
623
- function C(r, c) {
624
- a.value = d.value.map((p, f) => f === r ? c : p);
625
- }
626
- function S(r) {
627
- a.value = [...d.value, r];
628
- }
629
- function M(r) {
630
- a.value = d.value.filter((c, p) => p !== r);
631
- }
632
- function b(r) {
633
- return g.value.some((c) => c.value === r) ? g.value : [...g.value, { value: r, label: i("panel.admin-unknown", { id: String(r) }) }];
634
- }
635
- return (r, c) => (u(), T("div", Je, [
636
- d.value.length === 0 ? (u(), y(s(A), {
637
- key: 0,
638
- size: "sm",
639
- tone: "placeholder"
640
- }, {
641
- default: m(() => [
642
- _(v(s(i)("panel.no-recipients")), 1)
643
- ]),
644
- _: 1
645
- })) : N("", !0),
646
- (u(!0), T(j, null, E(d.value, (p, f) => (u(), T("div", {
647
- key: f,
648
- class: "wx-notifications-recipients__row"
649
- }, [
650
- p.variable ? (u(), y(s(Z), {
651
- key: 0,
652
- type: "primary",
653
- class: "wx-notifications-recipients__wide"
654
- }, {
655
- default: m(() => [
656
- _(v(s(i)("panel.addressee", { label: $(p.variable) })), 1)
657
- ]),
658
- _: 2
659
- }, 1024)) : p.admin_id !== void 0 ? (u(), y(s(Se), {
660
- key: 1,
661
- class: "wx-notifications-recipients__wide",
662
- "model-value": p.admin_id,
663
- options: b(p.admin_id),
664
- disabled: e.disabled,
665
- "onUpdate:modelValue": (W) => C(f, { admin_id: Number(W) })
666
- }, null, 8, ["model-value", "options", "disabled", "onUpdate:modelValue"])) : (u(), y(s(Q), {
667
- key: 2,
668
- class: "wx-notifications-recipients__wide",
669
- type: "email",
670
- "model-value": p.email ?? "",
671
- placeholder: "manager@site.test",
672
- disabled: e.disabled,
673
- "onUpdate:modelValue": (W) => C(f, { email: String(W ?? "") })
674
- }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"])),
675
- e.disabled ? N("", !0) : (u(), y(s(de), {
676
- key: 3,
677
- icon: "trash",
678
- tone: "danger",
679
- title: s(i)("panel.remove"),
680
- onClick: (W) => M(f)
681
- }, null, 8, ["title", "onClick"]))
682
- ]))), 128)),
683
- e.disabled ? N("", !0) : (u(), y(s(ee), {
684
- key: 1,
685
- size: "sm",
686
- wrap: ""
687
- }, {
688
- default: m(() => [
689
- w(s(F), {
690
- variant: "outline",
691
- size: "sm",
692
- disabled: g.value.length === 0,
693
- onClick: c[0] || (c[0] = (p) => S({ admin_id: Number(g.value[0]?.value) }))
694
- }, {
695
- icon: m(() => [
696
- w(s(D), { name: "user" })
697
- ]),
698
- default: m(() => [
699
- _(" " + v(s(i)("panel.add-admin")), 1)
700
- ]),
701
- _: 1
702
- }, 8, ["disabled"]),
703
- w(s(F), {
704
- variant: "outline",
705
- size: "sm",
706
- onClick: c[1] || (c[1] = (p) => S({ email: "" }))
707
- }, {
708
- icon: m(() => [
709
- w(s(D), { name: "mail" })
710
- ]),
711
- default: m(() => [
712
- _(" " + v(s(i)("panel.add-email")), 1)
713
- ]),
714
- _: 1
715
- }),
716
- (u(!0), T(j, null, E(x.value, (p) => (u(), y(s(F), {
717
- key: p.name,
718
- variant: "outline",
719
- size: "sm",
720
- onClick: (f) => S({ variable: p.name })
721
- }, {
722
- default: m(() => [
723
- _(v(s(i)("panel.addressee", { label: p.label })), 1)
724
- ]),
725
- _: 2
726
- }, 1032, ["onClick"]))), 128))
727
- ]),
728
- _: 1
729
- }))
730
- ]));
731
- }
732
- }), Ze = /* @__PURE__ */ B(Ye, [["__scopeId", "data-v-ae639366"]]), et = { class: "wx-notifications-template" }, tt = { class: "wx-notifications-template__variables" }, nt = { class: "wx-notifications-template__chips" }, at = { class: "wx-notifications-template__name" }, it = /* @__PURE__ */ L({
733
- name: "WxNotificationsTemplateField",
734
- __name: "TemplateField",
735
- props: /* @__PURE__ */ q({
736
- localized: { type: Boolean, default: !1 },
737
- disabled: { type: Boolean, default: void 0 },
738
- minHeight: { default: "200px" }
739
- }, {
740
- modelValue: { default: "" },
741
- modelModifiers: {}
742
- }),
743
- emits: ["update:modelValue"],
744
- setup(t) {
745
- const e = t, a = H(t, "modelValue");
746
- I();
747
- const i = U("webx-notifications"), n = G(), l = ue(), o = V(null), d = h(() => qe(n.event.value)), g = h(
748
- () => n.provider.value?.key === "telegram" ? "mustache-html" : "mustache"
749
- ), k = h(
750
- () => Ae(d.value, {
751
- variable: i("panel.hint-variable"),
752
- list: i("panel.hint-list"),
753
- field: i("panel.hint-field"),
754
- section: i("panel.hint-section"),
755
- inverted: i("panel.hint-inverted"),
756
- close: i("panel.hint-close"),
757
- comment: i("panel.hint-comment"),
758
- example: i("panel.hint-example")
759
- })
760
- ), x = h(() => {
761
- const b = a.value;
762
- if (b == null) return "";
763
- if (typeof b == "string") return b;
764
- const r = l.active.value || l.list.value[0]?.code || "";
765
- return b[r] ?? "";
766
- }), $ = h(
767
- () => We(x.value, n.event.value === null ? void 0 : d.value)
768
- ), C = h(() => {
769
- const b = $.value;
770
- return [
771
- ...b.unclosed.map((r) => i("panel.problem-unclosed", { name: r })),
772
- ...b.stray.map((r) => i("panel.problem-stray", { name: r })),
773
- ...b.refused.map((r) => i("panel.problem-refused", { tag: r })),
774
- ...b.broken ? [i("panel.problem-broken")] : [],
775
- ...b.unknown.length > 0 ? [
776
- i("panel.problem-unknown", {
777
- names: b.unknown.map((r) => `{{${r}}}`).join(", ")
778
- })
779
- ] : []
780
- ];
781
- });
782
- function S(b) {
783
- if ((b.fields?.length ?? 0) > 0)
784
- return i("panel.variable-list", {
785
- fields: (b.fields ?? []).map((c) => c.name).join(", ")
786
- });
787
- const r = b.example;
788
- return typeof r == "string" || typeof r == "number" ? String(r) : "";
789
- }
790
- function M(b) {
791
- const r = o.value?.view;
792
- if (!r) return;
793
- const c = r.state.selection.main;
794
- r.dispatch({
795
- changes: { from: c.from, to: c.to, insert: b },
796
- selection: { anchor: c.from + b.length },
797
- scrollIntoView: !0
798
- }), r.focus();
799
- }
800
- return (b, r) => (u(), T("div", et, [
801
- w(s(Ne), {
802
- ref_key: "editor",
803
- ref: o,
804
- modelValue: a.value,
805
- "onUpdate:modelValue": r[0] || (r[0] = (c) => a.value = c),
806
- language: g.value,
807
- completions: k.value,
808
- localized: e.localized,
809
- disabled: e.disabled,
810
- "line-numbers": !1,
811
- "line-wrapping": "",
812
- "min-height": e.minHeight
813
- }, null, 8, ["modelValue", "language", "completions", "localized", "disabled", "min-height"]),
814
- (u(!0), T(j, null, E(C.value, (c) => (u(), y(s(R), {
815
- key: c,
816
- type: "warning",
817
- variant: "soft",
818
- description: c
819
- }, null, 8, ["description"]))), 128)),
820
- P("div", tt, [
821
- w(s(A), {
822
- size: "sm",
823
- weight: "medium"
824
- }, {
825
- default: m(() => [
826
- _(v(s(i)("panel.variables")), 1)
827
- ]),
828
- _: 1
829
- }),
830
- d.value.length === 0 ? (u(), y(s(A), {
831
- key: 0,
832
- size: "sm",
833
- tone: "muted"
834
- }, {
835
- default: m(() => [
836
- _(v(s(i)("panel.variables-none")), 1)
837
- ]),
838
- _: 1
839
- })) : (u(), T(j, { key: 1 }, [
840
- w(s(A), {
841
- size: "sm",
842
- tone: "muted"
843
- }, {
844
- default: m(() => [
845
- _(v(s(i)("panel.variables-help")), 1)
846
- ]),
847
- _: 1
848
- }),
849
- P("div", nt, [
850
- (u(!0), T(j, null, E(d.value, (c) => (u(), y(s(Ve), {
851
- key: c.name,
852
- content: [c.label, S(c)].filter(Boolean).join(" — ")
853
- }, {
854
- default: m(() => [
855
- w(s(F), {
856
- size: "sm",
857
- variant: "outline",
858
- class: "wx-notifications-template__chip",
859
- disabled: e.disabled,
860
- onClick: (p) => M(s(Ke)(c))
861
- }, {
862
- default: m(() => [
863
- P("span", at, v((c.fields?.length ?? 0) > 0 ? `#${c.name}` : c.name), 1)
864
- ]),
865
- _: 2
866
- }, 1032, ["disabled", "onClick"])
867
- ]),
868
- _: 2
869
- }, 1032, ["content"]))), 128))
870
- ])
871
- ], 64))
872
- ])
873
- ]));
874
- }
875
- }), st = /* @__PURE__ */ B(it, [["__scopeId", "data-v-29c287ae"]]);
876
- function Ft(t = {}) {
877
- const e = t.path ?? "/notifications";
878
- return {
879
- id: "notifications",
880
- path: e,
881
- routes: [
882
- {
883
- path: e,
884
- name: "webx.notifications",
885
- component: () => import("./NotificationsPage-qWdhMayl.js"),
886
- props: { base: e }
887
- },
888
- {
889
- path: `${e}/channels/new`,
890
- name: "webx.notifications.new",
891
- component: () => import("./ChannelPage-C47YoMPO.js"),
892
- props: { base: e }
893
- },
894
- {
895
- path: `${e}/channels/:id(\\d+)`,
896
- name: "webx.notifications.channel",
897
- component: () => import("./ChannelPage-C47YoMPO.js"),
898
- props: { base: e }
899
- }
900
- ],
901
- types: {
902
- "wx-notifications-template": { component: st, kind: "field", wide: !0 },
903
- "wx-notifications-chats": { component: Xe, kind: "field" },
904
- "wx-notifications-emails": { component: Ze, kind: "field" },
905
- "wx-notifications-channels": {
906
- component: Le,
907
- kind: "field",
908
- bind: (a) => ({ event: a.props?.event, base: e })
909
- }
910
- }
911
- };
912
- }
913
- class z extends Error {
914
- constructor(e, a = {}) {
915
- super(e), this.key = e, this.replace = a, this.name = "TemplateRefusal";
916
- }
917
- key;
918
- replace;
919
- }
920
- const lt = /^[a-z0-9_]+(\.[a-z0-9_]+)?$/;
921
- function ot(t) {
922
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
923
- }
924
- function ie(t) {
925
- return t.replace(/[\r\n]+/g, " ");
926
- }
927
- function rt(t) {
928
- return t === "telegram" ? ot : (e) => e;
929
- }
930
- function ct(t) {
931
- try {
932
- return ze.parse(t, ["{{", "}}"]);
933
- } catch (e) {
934
- const a = e instanceof Error ? e.message : String(e), i = /section "([^"]*)"/.exec(a)?.[1] ?? "";
935
- if (a.startsWith("Unopened section"))
936
- throw new z("template-unexpected", { section: i });
937
- if (a.startsWith("Unclosed section"))
938
- throw new z("template-unclosed", { section: i });
939
- const n = Number(/at (\d+)/.exec(a)?.[1] ?? t.lastIndexOf("{{")), l = t.slice(n).replace(/^\{\{\{?[#^/!&>=]?/, "").trim();
940
- throw new z("template-tag", { tag: l });
941
- }
942
- }
943
- function he(t) {
944
- for (const e of t) {
945
- const [a, i] = e;
946
- if (a === ">") throw new z("template-partial");
947
- if (a === "=") throw new z("template-delimiters");
948
- if (a === "text" || a === "!") continue;
949
- const n = i.trim();
950
- if (n.startsWith("<")) throw new z("template-partial");
951
- if (n.startsWith("%") || n.startsWith("$")) throw new z("template-pragma");
952
- if (!lt.test(n)) throw new z("template-name", { name: n });
953
- e[4] && he(e[4]);
954
- }
955
- }
956
- function dt(t) {
957
- const e = {};
958
- for (const [a, i] of Object.entries(t)) {
959
- if (!a.includes(".")) {
960
- e[a] = i;
961
- continue;
962
- }
963
- const [n, ...l] = a.split("."), o = n, d = e[o];
964
- (d === void 0 || O(d)) && (e[o] = { ...O(d) ? d : {}, [l.join(".")]: i });
965
- }
966
- return e;
967
- }
968
- function O(t) {
969
- return typeof t == "object" && t !== null && !Array.isArray(t);
970
- }
971
- function se(t) {
972
- return t == null || t === !1 || t === "" || t === "0" || t === 0 ? !0 : Array.isArray(t) ? t.length === 0 : O(t) ? Object.keys(t).length === 0 : !1;
973
- }
974
- function ut(t, e) {
975
- const [a, ...i] = e.split(".");
976
- let n;
977
- for (let l = t.length - 1; l >= 0; l--) {
978
- const o = t[l];
979
- if (O(o) && Object.prototype.hasOwnProperty.call(o, a)) {
980
- n = o[a];
981
- break;
982
- }
983
- }
984
- for (const l of i) {
985
- if (n === "" || n === void 0) return n;
986
- n = O(n) && Object.prototype.hasOwnProperty.call(n, l) ? n[l] : "";
987
- }
988
- return n;
989
- }
990
- function pt(t) {
991
- return typeof t == "string" ? t : typeof t == "number" ? String(t) : t === !0 ? "1" : "";
992
- }
993
- function X(t, e, a) {
994
- let i = "";
995
- for (const n of t) {
996
- const [l, o] = n;
997
- if (l === "text") {
998
- i += o;
999
- continue;
1000
- }
1001
- if (l === "!") continue;
1002
- const d = ut(e, o.trim());
1003
- if (l === "name" || l === "&") {
1004
- i += O(d) || Array.isArray(d) ? "" : a(pt(d));
1005
- continue;
1006
- }
1007
- const g = n[4] ?? [];
1008
- if (l === "#" && !se(d))
1009
- for (const k of Array.isArray(d) ? d : [d])
1010
- i += X(g, [...e, k], a);
1011
- l === "^" && se(d) && (i += X(g, e, a));
1012
- }
1013
- return i;
1014
- }
1015
- function J(t, e = [], a = []) {
1016
- for (const i of t) {
1017
- const [n, l] = i;
1018
- if (n === "text" || n === "!") continue;
1019
- const o = l.trim();
1020
- a.push({ name: o, sections: e }), n === "#" && J(i[4] ?? [], [...e, o], a), n === "^" && J(i[4] ?? [], e, a);
1021
- }
1022
- return a;
1023
- }
1024
- function le(t, e) {
1025
- const [a, ...i] = e.split(".");
1026
- for (const n of [...t].reverse()) {
1027
- if (!O(n) || !Object.prototype.hasOwnProperty.call(n, a)) continue;
1028
- let l = n[a];
1029
- for (const o of i) {
1030
- if (!O(l) || !Object.prototype.hasOwnProperty.call(l, o)) return null;
1031
- l = l[o];
1032
- }
1033
- return l ?? null;
1034
- }
1035
- return null;
1036
- }
1037
- function mt(t, e, a) {
1038
- const i = [t];
1039
- for (const n of a) {
1040
- const l = le(i, n);
1041
- Array.isArray(l) ? i.push(Object.assign({}, ...l.filter(O))) : O(l) && i.push(l);
1042
- }
1043
- return le(i, e) !== null;
1044
- }
1045
- function ft(t, e, a) {
1046
- for (const i of [...a].reverse()) {
1047
- const n = t.variables.find((l) => l.name === i);
1048
- if (n && n.fields.length > 0 && n.fields.some((l) => l.name === e))
1049
- return !0;
1050
- }
1051
- return t.variables.some(
1052
- (i) => i.name === e || i.name.endsWith(".*") && e.startsWith(i.name.slice(0, -1))
1053
- );
1054
- }
1055
- function oe(t, e, a, i) {
1056
- const n = ct(t);
1057
- he(n);
1058
- const l = dt(e), o = /* @__PURE__ */ new Set();
1059
- for (const d of J(n))
1060
- !mt(l, d.name, d.sections) && !i?.(d.name, d.sections) && o.add(d.name);
1061
- return { text: X(n, [l], a), unknown: [...o] };
1062
- }
1063
- function ht(t) {
1064
- const e = {};
1065
- for (const a of t?.variables ?? [])
1066
- a.name.endsWith(".*") || (e[a.name] = a.example);
1067
- return e;
1068
- }
1069
- function vt(t) {
1070
- return new DOMParser().parseFromString(`<body>${t}</body>`, "text/html").body.textContent ?? "";
1071
- }
1072
- function bt(t) {
1073
- const e = rt(t.provider), a = t.event ?? null, i = a === null ? void 0 : (k, x) => ft(a, k, x), n = oe(t.template, t.values, e, i);
1074
- let l = null, o = n.unknown;
1075
- if (t.hasSubject) {
1076
- const k = oe(t.subject ?? "", t.values, ie, i);
1077
- l = ie(k.text).trim(), o = [.../* @__PURE__ */ new Set([...o, ...k.unknown])];
1078
- }
1079
- const d = t.provider === "telegram" ? vt(n.text) : n.text, g = t.limit ?? null;
1080
- if (g !== null && [...d].length > g) {
1081
- const k = `${[...d].slice(0, g - 1).join("")}…`;
1082
- return { subject: l, body: e(k), plain: k, truncated: !0, unknown: o };
1083
- }
1084
- return { subject: l, body: n.text, plain: d, truncated: !1, unknown: o };
1085
- }
1086
- const wt = /* @__PURE__ */ new Set([
1087
- "b",
1088
- "strong",
1089
- "i",
1090
- "em",
1091
- "u",
1092
- "ins",
1093
- "s",
1094
- "strike",
1095
- "del",
1096
- "a",
1097
- "code",
1098
- "pre",
1099
- "blockquote",
1100
- "tg-spoiler",
1101
- "span"
1102
- ]);
1103
- function Y(t, e, a) {
1104
- for (const i of Array.from(t.childNodes)) {
1105
- if (i.nodeType === Node.TEXT_NODE) {
1106
- e.appendChild(a.createTextNode(i.textContent ?? ""));
1107
- continue;
1108
- }
1109
- if (!(i instanceof Element)) continue;
1110
- const n = i.tagName.toLowerCase();
1111
- if (!wt.has(n) || n === "span" && !i.classList.contains("tg-spoiler")) {
1112
- Y(i, e, a);
1113
- continue;
1114
- }
1115
- const l = a.createElement(n === "tg-spoiler" ? "span" : n);
1116
- if ((n === "tg-spoiler" || n === "span") && (l.className = "tg-spoiler"), n === "a") {
1117
- const o = i.getAttribute("href") ?? "";
1118
- /^(https?:|tg:)/i.test(o) && (l.setAttribute("href", o), l.setAttribute("target", "_blank"), l.setAttribute("rel", "noopener noreferrer"));
1119
- }
1120
- Y(i, l, a), e.appendChild(l);
1121
- }
1122
- }
1123
- function gt(t) {
1124
- const e = new DOMParser().parseFromString(`<body>${t}</body>`, "text/html"), a = document.implementation.createHTMLDocument(""), i = a.createElement("div");
1125
- return Y(e.body, i, a), i.innerHTML;
1126
- }
1127
- const yt = {
1128
- key: 0,
1129
- class: "wx-notifications-preview__chat"
1130
- }, _t = ["innerHTML"], kt = {
1131
- key: 1,
1132
- class: "wx-notifications-preview__bubble"
1133
- }, xt = {
1134
- key: 1,
1135
- class: "wx-notifications-preview__letter"
1136
- }, $t = { class: "wx-notifications-preview__subject" }, Tt = { class: "wx-notifications-preview__body" }, Ct = /* @__PURE__ */ L({
1137
- name: "WxNotificationsPreview",
1138
- __name: "MessagePreview",
1139
- setup(t) {
1140
- I();
1141
- const e = U("webx-notifications"), a = G(), i = ue(), n = h(() => i.active.value || i.list.value[0]?.code || ""), l = h(() => {
1142
- const $ = a.provider.value;
1143
- if ($ === null) return null;
1144
- const C = a.values.value;
1145
- try {
1146
- return {
1147
- message: bt({
1148
- provider: $.key,
1149
- template: ne(C.template, n.value),
1150
- subject: ne(C.subject, n.value),
1151
- hasSubject: $.subject,
1152
- limit: $.limit,
1153
- values: ht(a.event.value),
1154
- event: a.event.value
1155
- })
1156
- };
1157
- } catch (S) {
1158
- if (S instanceof z)
1159
- return { refusal: e(`errors.${S.key}`, S.replace) };
1160
- throw S;
1161
- }
1162
- }), o = h(
1163
- () => l.value !== null && "message" in l.value ? l.value.message : null
1164
- ), d = h(
1165
- () => l.value !== null && "refusal" in l.value ? l.value.refusal : null
1166
- ), g = h(
1167
- () => e("panel.preview-unknown", {
1168
- names: (o.value?.unknown ?? []).map(($) => "{{" + $ + "}}").join(", ")
1169
- })
1170
- ), k = h(() => a.provider.value?.key === "telegram"), x = h(
1171
- () => o.value === null || o.value.truncated ? "" : gt(o.value.body)
1172
- );
1173
- return ($, C) => (u(), y(s(je), {
1174
- title: s(e)("panel.preview"),
1175
- class: "wx-notifications-preview"
1176
- }, {
1177
- default: m(() => [
1178
- w(s(A), {
1179
- size: "sm",
1180
- tone: "muted"
1181
- }, {
1182
- default: m(() => [
1183
- _(v(s(a).event.value ? s(e)("panel.preview-help") : s(e)("panel.preview-no-event")), 1)
1184
- ]),
1185
- _: 1
1186
- }),
1187
- d.value ? (u(), y(s(R), {
1188
- key: 0,
1189
- type: "danger",
1190
- variant: "soft",
1191
- title: s(e)("panel.preview-refused"),
1192
- description: d.value
1193
- }, null, 8, ["title", "description"])) : o.value ? (u(), T(j, { key: 1 }, [
1194
- k.value ? (u(), T("div", yt, [
1195
- o.value.truncated ? (u(), T("div", kt, v(o.value.plain), 1)) : (u(), T("div", {
1196
- key: 0,
1197
- class: "wx-notifications-preview__bubble",
1198
- innerHTML: x.value
1199
- }, null, 8, _t))
1200
- ])) : (u(), T("div", xt, [
1201
- P("div", $t, [
1202
- w(s(A), {
1203
- size: "sm",
1204
- tone: "muted"
1205
- }, {
1206
- default: m(() => [
1207
- _(v(s(e)("panel.preview-subject")), 1)
1208
- ]),
1209
- _: 1
1210
- }),
1211
- w(s(A), { weight: "medium" }, {
1212
- default: m(() => [
1213
- _(v(o.value.subject || "—"), 1)
1214
- ]),
1215
- _: 1
1216
- })
1217
- ]),
1218
- P("div", Tt, v(o.value.body), 1)
1219
- ])),
1220
- o.value.plain.trim() === "" ? (u(), y(s(A), {
1221
- key: 2,
1222
- size: "sm",
1223
- tone: "muted"
1224
- }, {
1225
- default: m(() => [
1226
- _(v(s(e)("panel.preview-empty")), 1)
1227
- ]),
1228
- _: 1
1229
- })) : N("", !0),
1230
- o.value.truncated ? (u(), y(s(R), {
1231
- key: 3,
1232
- type: "warning",
1233
- variant: "soft",
1234
- description: s(e)("panel.preview-truncated", { limit: String(s(a).provider.value?.limit ?? "") })
1235
- }, null, 8, ["description"])) : N("", !0),
1236
- o.value.unknown.length > 0 && s(a).event.value ? (u(), y(s(A), {
1237
- key: 4,
1238
- size: "sm",
1239
- tone: "muted"
1240
- }, {
1241
- default: m(() => [
1242
- _(v(g.value), 1)
1243
- ]),
1244
- _: 1
1245
- })) : N("", !0)
1246
- ], 64)) : N("", !0)
1247
- ]),
1248
- _: 1
1249
- }, 8, ["title"]));
1250
- }
1251
- }), Ot = /* @__PURE__ */ B(Ct, [["__scopeId", "data-v-9ca19a74"]]), zt = ce(() => import("./NotificationsPage-qWdhMayl.js")), Mt = ce(() => import("./ChannelPage-C47YoMPO.js"));
1252
- export {
1253
- Le as C,
1254
- Ze as E,
1255
- Ot as M,
1256
- Ue as N,
1257
- z as T,
1258
- Mt as W,
1259
- B as _,
1260
- Xe as a,
1261
- zt as b,
1262
- me as c,
1263
- st as d,
1264
- fe as e,
1265
- rt as f,
1266
- ot as g,
1267
- ht as h,
1268
- Me as i,
1269
- oe as j,
1270
- G as k,
1271
- Ft as n,
1272
- jt as p,
1273
- bt as r,
1274
- Ke as s,
1275
- gt as t,
1276
- I as u,
1277
- qe as v
1278
- };
1279
- //# sourceMappingURL=index-DIeEPPSh.js.map