@paroicms/internal-link-plugin 0.14.1 → 0.16.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,750 @@
1
+ const ft = (t, e) => t === e, V = {
2
+ equals: ft
3
+ };
4
+ let et = st;
5
+ const E = 1, R = 2, nt = {
6
+ owned: null,
7
+ cleanups: null,
8
+ context: null,
9
+ owner: null
10
+ };
11
+ var k = null;
12
+ let F = null, dt = null, w = null, b = null, I = null, H = 0;
13
+ function ht(t, e) {
14
+ const n = w, l = k, i = t.length === 0, s = l, o = i ? nt : {
15
+ owned: null,
16
+ cleanups: null,
17
+ context: s ? s.context : null,
18
+ owner: s
19
+ }, r = i ? t : () => t(() => A(() => x(o)));
20
+ k = o, w = null;
21
+ try {
22
+ return N(r, !0);
23
+ } finally {
24
+ w = n, k = l;
25
+ }
26
+ }
27
+ function S(t, e) {
28
+ e = e ? Object.assign({}, V, e) : V;
29
+ const n = {
30
+ value: t,
31
+ observers: null,
32
+ observerSlots: null,
33
+ comparator: e.equals || void 0
34
+ }, l = (i) => (typeof i == "function" && (i = i(n.value)), it(n, i));
35
+ return [lt.bind(n), l];
36
+ }
37
+ function C(t, e, n) {
38
+ const l = K(t, e, !1, E);
39
+ B(l);
40
+ }
41
+ function q(t, e, n) {
42
+ et = $t;
43
+ const l = K(t, e, !1, E);
44
+ l.user = !0, I ? I.push(l) : B(l);
45
+ }
46
+ function P(t, e, n) {
47
+ n = n ? Object.assign({}, V, n) : V;
48
+ const l = K(t, e, !0, 0);
49
+ return l.observers = null, l.observerSlots = null, l.comparator = n.equals || void 0, B(l), lt.bind(l);
50
+ }
51
+ function A(t) {
52
+ if (w === null) return t();
53
+ const e = w;
54
+ w = null;
55
+ try {
56
+ return t();
57
+ } finally {
58
+ w = e;
59
+ }
60
+ }
61
+ function lt() {
62
+ if (this.sources && this.state)
63
+ if (this.state === E) B(this);
64
+ else {
65
+ const t = b;
66
+ b = null, N(() => M(this), !1), b = t;
67
+ }
68
+ if (w) {
69
+ const t = this.observers ? this.observers.length : 0;
70
+ w.sources ? (w.sources.push(this), w.sourceSlots.push(t)) : (w.sources = [this], w.sourceSlots = [t]), this.observers ? (this.observers.push(w), this.observerSlots.push(w.sources.length - 1)) : (this.observers = [w], this.observerSlots = [w.sources.length - 1]);
71
+ }
72
+ return this.value;
73
+ }
74
+ function it(t, e, n) {
75
+ let l = t.value;
76
+ return (!t.comparator || !t.comparator(l, e)) && (t.value = e, t.observers && t.observers.length && N(() => {
77
+ for (let i = 0; i < t.observers.length; i += 1) {
78
+ const s = t.observers[i], o = F && F.running;
79
+ o && F.disposed.has(s), (o ? !s.tState : !s.state) && (s.pure ? b.push(s) : I.push(s), s.observers && rt(s)), o || (s.state = E);
80
+ }
81
+ if (b.length > 1e6)
82
+ throw b = [], new Error();
83
+ }, !1)), e;
84
+ }
85
+ function B(t) {
86
+ if (!t.fn) return;
87
+ x(t);
88
+ const e = H;
89
+ pt(t, t.value, e);
90
+ }
91
+ function pt(t, e, n) {
92
+ let l;
93
+ const i = k, s = w;
94
+ w = k = t;
95
+ try {
96
+ l = t.fn(e);
97
+ } catch (o) {
98
+ return t.pure && (t.state = E, t.owned && t.owned.forEach(x), t.owned = null), t.updatedAt = n + 1, ot(o);
99
+ } finally {
100
+ w = s, k = i;
101
+ }
102
+ (!t.updatedAt || t.updatedAt <= n) && (t.updatedAt != null && "observers" in t ? it(t, l) : t.value = l, t.updatedAt = n);
103
+ }
104
+ function K(t, e, n, l = E, i) {
105
+ const s = {
106
+ fn: t,
107
+ state: l,
108
+ updatedAt: null,
109
+ owned: null,
110
+ sources: null,
111
+ sourceSlots: null,
112
+ cleanups: null,
113
+ value: e,
114
+ owner: k,
115
+ context: k ? k.context : null,
116
+ pure: n
117
+ };
118
+ return k === null || k !== nt && (k.owned ? k.owned.push(s) : k.owned = [s]), s;
119
+ }
120
+ function j(t) {
121
+ if (t.state === 0) return;
122
+ if (t.state === R) return M(t);
123
+ if (t.suspense && A(t.suspense.inFallback)) return t.suspense.effects.push(t);
124
+ const e = [t];
125
+ for (; (t = t.owner) && (!t.updatedAt || t.updatedAt < H); )
126
+ t.state && e.push(t);
127
+ for (let n = e.length - 1; n >= 0; n--)
128
+ if (t = e[n], t.state === E)
129
+ B(t);
130
+ else if (t.state === R) {
131
+ const l = b;
132
+ b = null, N(() => M(t, e[0]), !1), b = l;
133
+ }
134
+ }
135
+ function N(t, e) {
136
+ if (b) return t();
137
+ let n = !1;
138
+ e || (b = []), I ? n = !0 : I = [], H++;
139
+ try {
140
+ const l = t();
141
+ return gt(n), l;
142
+ } catch (l) {
143
+ n || (I = null), b = null, ot(l);
144
+ }
145
+ }
146
+ function gt(t) {
147
+ if (b && (st(b), b = null), t) return;
148
+ const e = I;
149
+ I = null, e.length && N(() => et(e), !1);
150
+ }
151
+ function st(t) {
152
+ for (let e = 0; e < t.length; e++) j(t[e]);
153
+ }
154
+ function $t(t) {
155
+ let e, n = 0;
156
+ for (e = 0; e < t.length; e++) {
157
+ const l = t[e];
158
+ l.user ? t[n++] = l : j(l);
159
+ }
160
+ for (e = 0; e < n; e++) j(t[e]);
161
+ }
162
+ function M(t, e) {
163
+ t.state = 0;
164
+ for (let n = 0; n < t.sources.length; n += 1) {
165
+ const l = t.sources[n];
166
+ if (l.sources) {
167
+ const i = l.state;
168
+ i === E ? l !== e && (!l.updatedAt || l.updatedAt < H) && j(l) : i === R && M(l, e);
169
+ }
170
+ }
171
+ }
172
+ function rt(t) {
173
+ for (let e = 0; e < t.observers.length; e += 1) {
174
+ const n = t.observers[e];
175
+ n.state || (n.state = R, n.pure ? b.push(n) : I.push(n), n.observers && rt(n));
176
+ }
177
+ }
178
+ function x(t) {
179
+ let e;
180
+ if (t.sources)
181
+ for (; t.sources.length; ) {
182
+ const n = t.sources.pop(), l = t.sourceSlots.pop(), i = n.observers;
183
+ if (i && i.length) {
184
+ const s = i.pop(), o = n.observerSlots.pop();
185
+ l < i.length && (s.sourceSlots[o] = l, i[l] = s, n.observerSlots[l] = o);
186
+ }
187
+ }
188
+ if (t.tOwned) {
189
+ for (e = t.tOwned.length - 1; e >= 0; e--) x(t.tOwned[e]);
190
+ delete t.tOwned;
191
+ }
192
+ if (t.owned) {
193
+ for (e = t.owned.length - 1; e >= 0; e--) x(t.owned[e]);
194
+ t.owned = null;
195
+ }
196
+ if (t.cleanups) {
197
+ for (e = t.cleanups.length - 1; e >= 0; e--) t.cleanups[e]();
198
+ t.cleanups = null;
199
+ }
200
+ t.state = 0;
201
+ }
202
+ function mt(t) {
203
+ return t instanceof Error ? t : new Error(typeof t == "string" ? t : "Unknown error", {
204
+ cause: t
205
+ });
206
+ }
207
+ function ot(t, e = k) {
208
+ throw mt(t);
209
+ }
210
+ function T(t, e) {
211
+ return A(() => t(e || {}));
212
+ }
213
+ const yt = (t) => `Stale read from <${t}>.`;
214
+ function X(t) {
215
+ const e = t.keyed, n = P(() => t.when, void 0, void 0), l = e ? n : P(n, void 0, {
216
+ equals: (i, s) => !i == !s
217
+ });
218
+ return P(() => {
219
+ const i = l();
220
+ if (i) {
221
+ const s = t.children;
222
+ return typeof s == "function" && s.length > 0 ? A(() => s(e ? i : () => {
223
+ if (!A(l)) throw yt("Show");
224
+ return n();
225
+ })) : s;
226
+ }
227
+ return t.fallback;
228
+ }, void 0, void 0);
229
+ }
230
+ const L = (t) => P(() => t());
231
+ function wt(t, e, n) {
232
+ let l = n.length, i = e.length, s = l, o = 0, r = 0, c = e[i - 1].nextSibling, m = null;
233
+ for (; o < i || r < s; ) {
234
+ if (e[o] === n[r]) {
235
+ o++, r++;
236
+ continue;
237
+ }
238
+ for (; e[i - 1] === n[s - 1]; )
239
+ i--, s--;
240
+ if (i === o) {
241
+ const $ = s < l ? r ? n[r - 1].nextSibling : n[s - r] : c;
242
+ for (; r < s; ) t.insertBefore(n[r++], $);
243
+ } else if (s === r)
244
+ for (; o < i; )
245
+ (!m || !m.has(e[o])) && e[o].remove(), o++;
246
+ else if (e[o] === n[s - 1] && n[r] === e[i - 1]) {
247
+ const $ = e[--i].nextSibling;
248
+ t.insertBefore(n[r++], e[o++].nextSibling), t.insertBefore(n[--s], $), e[i] = n[s];
249
+ } else {
250
+ if (!m) {
251
+ m = /* @__PURE__ */ new Map();
252
+ let f = r;
253
+ for (; f < s; ) m.set(n[f], f++);
254
+ }
255
+ const $ = m.get(e[o]);
256
+ if ($ != null)
257
+ if (r < $ && $ < s) {
258
+ let f = o, g = 1, a;
259
+ for (; ++f < i && f < s && !((a = m.get(e[f])) == null || a !== $ + g); )
260
+ g++;
261
+ if (g > $ - r) {
262
+ const d = e[o];
263
+ for (; r < $; ) t.insertBefore(n[r++], d);
264
+ } else t.replaceChild(n[r++], e[o++]);
265
+ } else o++;
266
+ else e[o++].remove();
267
+ }
268
+ }
269
+ }
270
+ const J = "_$DX_DELEGATE";
271
+ function y(t, e, n, l) {
272
+ let i;
273
+ const s = () => {
274
+ const r = document.createElement("template");
275
+ return r.innerHTML = t, r.content.firstChild;
276
+ }, o = () => (i || (i = s())).cloneNode(!0);
277
+ return o.cloneNode = o, o;
278
+ }
279
+ function Q(t, e = window.document) {
280
+ const n = e[J] || (e[J] = /* @__PURE__ */ new Set());
281
+ for (let l = 0, i = t.length; l < i; l++) {
282
+ const s = t[l];
283
+ n.has(s) || (n.add(s), e.addEventListener(s, kt));
284
+ }
285
+ }
286
+ function bt(t, e) {
287
+ e == null ? t.removeAttribute("class") : t.className = e;
288
+ }
289
+ function p(t, e, n, l) {
290
+ if (n !== void 0 && !l && (l = []), typeof e != "function") return U(t, e, l, n);
291
+ C((i) => U(t, e(), i, n), l);
292
+ }
293
+ function kt(t) {
294
+ let e = t.target;
295
+ const n = `$$${t.type}`, l = t.target, i = t.currentTarget, s = (c) => Object.defineProperty(t, "target", {
296
+ configurable: !0,
297
+ value: c
298
+ }), o = () => {
299
+ const c = e[n];
300
+ if (c && !e.disabled) {
301
+ const m = e[`${n}Data`];
302
+ if (m !== void 0 ? c.call(e, m, t) : c.call(e, t), t.cancelBubble) return;
303
+ }
304
+ return e.host && typeof e.host != "string" && !e.host._$host && e.contains(t.target) && s(e.host), !0;
305
+ }, r = () => {
306
+ for (; o() && (e = e._$host || e.parentNode || e.host); ) ;
307
+ };
308
+ if (Object.defineProperty(t, "currentTarget", {
309
+ configurable: !0,
310
+ get() {
311
+ return e || document;
312
+ }
313
+ }), t.composedPath) {
314
+ const c = t.composedPath();
315
+ s(c[0]);
316
+ for (let m = 0; m < c.length - 2 && (e = c[m], !!o()); m++) {
317
+ if (e._$host) {
318
+ e = e._$host, r();
319
+ break;
320
+ }
321
+ if (e.parentNode === i)
322
+ break;
323
+ }
324
+ } else r();
325
+ s(l);
326
+ }
327
+ function U(t, e, n, l, i) {
328
+ for (; typeof n == "function"; ) n = n();
329
+ if (e === n) return n;
330
+ const s = typeof e, o = l !== void 0;
331
+ if (t = o && n[0] && n[0].parentNode || t, s === "string" || s === "number") {
332
+ if (s === "number" && (e = e.toString(), e === n))
333
+ return n;
334
+ if (o) {
335
+ let r = n[0];
336
+ r && r.nodeType === 3 ? r.data !== e && (r.data = e) : r = document.createTextNode(e), n = D(t, n, l, r);
337
+ } else
338
+ n !== "" && typeof n == "string" ? n = t.firstChild.data = e : n = t.textContent = e;
339
+ } else if (e == null || s === "boolean")
340
+ n = D(t, n, l);
341
+ else {
342
+ if (s === "function")
343
+ return C(() => {
344
+ let r = e();
345
+ for (; typeof r == "function"; ) r = r();
346
+ n = U(t, r, n, l);
347
+ }), () => n;
348
+ if (Array.isArray(e)) {
349
+ const r = [], c = n && Array.isArray(n);
350
+ if (G(r, e, n, i))
351
+ return C(() => n = U(t, r, n, l, !0)), () => n;
352
+ if (r.length === 0) {
353
+ if (n = D(t, n, l), o) return n;
354
+ } else c ? n.length === 0 ? Y(t, r, l) : wt(t, n, r) : (n && D(t), Y(t, r));
355
+ n = r;
356
+ } else if (e.nodeType) {
357
+ if (Array.isArray(n)) {
358
+ if (o) return n = D(t, n, l, e);
359
+ D(t, n, null, e);
360
+ } else n == null || n === "" || !t.firstChild ? t.appendChild(e) : t.replaceChild(e, t.firstChild);
361
+ n = e;
362
+ }
363
+ }
364
+ return n;
365
+ }
366
+ function G(t, e, n, l) {
367
+ let i = !1;
368
+ for (let s = 0, o = e.length; s < o; s++) {
369
+ let r = e[s], c = n && n[t.length], m;
370
+ if (!(r == null || r === !0 || r === !1)) if ((m = typeof r) == "object" && r.nodeType)
371
+ t.push(r);
372
+ else if (Array.isArray(r))
373
+ i = G(t, r, c) || i;
374
+ else if (m === "function")
375
+ if (l) {
376
+ for (; typeof r == "function"; ) r = r();
377
+ i = G(t, Array.isArray(r) ? r : [r], Array.isArray(c) ? c : [c]) || i;
378
+ } else
379
+ t.push(r), i = !0;
380
+ else {
381
+ const $ = String(r);
382
+ c && c.nodeType === 3 && c.data === $ ? t.push(c) : t.push(document.createTextNode($));
383
+ }
384
+ }
385
+ return i;
386
+ }
387
+ function Y(t, e, n = null) {
388
+ for (let l = 0, i = e.length; l < i; l++) t.insertBefore(e[l], n);
389
+ }
390
+ function D(t, e, n, l) {
391
+ if (n === void 0) return t.textContent = "";
392
+ const i = l || document.createTextNode("");
393
+ if (e.length) {
394
+ let s = !1;
395
+ for (let o = e.length - 1; o >= 0; o--) {
396
+ const r = e[o];
397
+ if (i !== r) {
398
+ const c = r.parentNode === t;
399
+ !s && !o ? c ? t.replaceChild(i, r) : t.insertBefore(i, n) : c && r.remove();
400
+ } else s = !0;
401
+ }
402
+ } else t.insertBefore(i, n);
403
+ return [i];
404
+ }
405
+ const ct = (t) => t != null && (t = Object.getPrototypeOf(t), t === Array.prototype || t === Object.prototype);
406
+ function at(t, e, n) {
407
+ for (const [l, i] of Object.entries(e)) {
408
+ const s = `${n}.${l}`;
409
+ t[s] = i, ct(i) && at(t, i, s);
410
+ }
411
+ }
412
+ function vt(t) {
413
+ const e = { ...t };
414
+ for (const [n, l] of Object.entries(t))
415
+ ct(l) && at(e, l, n);
416
+ return e;
417
+ }
418
+ const _t = (t) => t;
419
+ function Lt(t, e = _t) {
420
+ return (n, ...l) => {
421
+ n[0] === "." && (n = n.slice(1));
422
+ const i = t()?.[n];
423
+ switch (typeof i) {
424
+ case "function":
425
+ return i(...l);
426
+ case "string":
427
+ return e(i, l[0]);
428
+ default:
429
+ return i;
430
+ }
431
+ };
432
+ }
433
+ const It = { insertLink: "Insert link", change: "Change", editor: { noResult: "No results found", draft: "Draft", published: "Published", sheduled: "Sheduled" }, dialog: { title: "Insert an internal link", removeLink: "Remove link", changeLink: "Find another link", ok: "OK" } }, St = {
434
+ InternalLink: It
435
+ }, Et = { insertLink: "Insérer un lien", change: "Modifier", editor: { noResult: "Aucun résultat trouvé", draft: "Brouillon", published: "Publié", sheduled: "Programmé" }, dialog: { title: "Insérer un lien interne", removeLink: "Supprimer le lien", changeLink: "Trouver un autre lien", ok: "OK" } }, Dt = {
436
+ InternalLink: Et
437
+ }, Z = { en: St, fr: Dt };
438
+ function W(t) {
439
+ const e = P(() => {
440
+ const l = t(), i = l in Z ? l : "en";
441
+ return vt(Z[i]);
442
+ });
443
+ return { t: Lt(e) };
444
+ }
445
+ var Pt = /* @__PURE__ */ y("<div class=ILResult>"), Ct = /* @__PURE__ */ y('<div class=ILNoResult><span class=ILNoResult-message></span><span class="pi pi-exclamation-circle">'), At = /* @__PURE__ */ y("<div class=InternalLinkEditor><form class=ILForm><input class=InternalLinkEditor-input type=text placeholder=Search>"), xt = /* @__PURE__ */ y("<div class=ILResultItem><div class=ILResultItem-title></div><span>");
446
+ function ut(t) {
447
+ const {
448
+ value: e,
449
+ setValue: n,
450
+ service: l
451
+ } = t, [i, s] = S(""), [o, r] = S([]), {
452
+ t: c
453
+ } = W(t.language);
454
+ q(async () => {
455
+ const f = e();
456
+ if (!f) return;
457
+ const g = await l.getDocument(f);
458
+ s(g?.title ?? ""), await m();
459
+ });
460
+ const m = async (f) => {
461
+ if (f?.preventDefault(), i().length < 3) return;
462
+ const g = await l.searchDocuments({
463
+ searchString: i()
464
+ });
465
+ r(g);
466
+ }, $ = (f) => f && new Date(f).getTime() < Date.now();
467
+ return (() => {
468
+ var f = At(), g = f.firstChild, a = g.firstChild;
469
+ return g.addEventListener("submit", m), a.$$input = (d) => s(d.currentTarget.value), p(f, T(X, {
470
+ when: o,
471
+ get children() {
472
+ var d = Pt();
473
+ return p(d, () => o().map((u) => (
474
+ // biome-ignore lint/correctness/useJsxKeyInIterable: key not needed in SolidJS div
475
+ (() => {
476
+ var h = xt(), _ = h.firstChild, v = _.nextSibling;
477
+ return h.$$click = () => {
478
+ n(u.id);
479
+ }, p(_, () => u.title), p(v, (() => {
480
+ var O = L(() => !!u.ready);
481
+ return () => O() ? L(() => !!$(u.publishDate))() ? c("InternalLink.editor.published") : c("InternalLink.editor.sheduled") : c("InternalLink.editor.draft");
482
+ })()), C(() => bt(v, `ILResultItem-status
483
+ ${u.ready ? $(u.publishDate) ? "published" : "sheduled" : "draft"}`)), h;
484
+ })()
485
+ ))), d;
486
+ }
487
+ }), null), p(f, T(X, {
488
+ get when() {
489
+ return !o() || o().length === 0;
490
+ },
491
+ get children() {
492
+ var d = Ct(), u = d.firstChild;
493
+ return p(u, () => c("InternalLink.editor.noResult")), d;
494
+ }
495
+ }), null), C(() => a.value = i()), f;
496
+ })();
497
+ }
498
+ Q(["input", "click"]);
499
+ var Tt = /* @__PURE__ */ y("<div class=InternalLinkDialog-header><span class=InternalLinkDialog-title>"), Bt = /* @__PURE__ */ y('<button class="PlgBtn pi pi-arrow-left"type=button>'), Nt = /* @__PURE__ */ y("<div class=InternalLinkDialog-content>"), Ot = /* @__PURE__ */ y('<div class=ILPreview><div class=ILPreview-title></div><button class="PlgBtn outlined iconBtn pi pi-pencil"type=button>'), z = /* @__PURE__ */ y("<div>"), Vt = /* @__PURE__ */ y('<div><button class="PlgBtn primary"type=button>'), Rt = /* @__PURE__ */ y('<button type=button class="PlgBtn danger outlined">'), tt = /* @__PURE__ */ y("<button class=PlgBtn type=button>"), jt = /* @__PURE__ */ y('<button class="PlgBtn primary"type=button>'), Mt = /* @__PURE__ */ y('<div class=InternalLinkDialog-linkPreview><div></div><button class="PlgBtn iconBtn pi pi-pencil"type=button>');
500
+ function Ut({
501
+ service: t,
502
+ setValue: e,
503
+ value: n,
504
+ language: l
505
+ }) {
506
+ const {
507
+ t: i
508
+ } = W(l), [s, o] = S(), [r, c] = S(!!n());
509
+ q(async () => {
510
+ const a = n();
511
+ if (!a) return;
512
+ const d = await t.getDocument(a);
513
+ if (!d) return;
514
+ const {
515
+ title: u,
516
+ typeName: h
517
+ } = d;
518
+ o({
519
+ title: u,
520
+ typeName: h
521
+ });
522
+ });
523
+ const m = (() => {
524
+ var a = Tt(), d = a.firstChild;
525
+ return p(a, (() => {
526
+ var u = L(() => !!(n() && !r()));
527
+ return () => u() && (() => {
528
+ var h = Bt();
529
+ return h.$$click = () => {
530
+ c(!0);
531
+ }, h;
532
+ })();
533
+ })(), d), p(d, () => i("InternalLink.dialog.title")), a;
534
+ })(), $ = (() => {
535
+ var a = Nt();
536
+ return p(a, (() => {
537
+ var d = L(() => !!(r() && n()));
538
+ return () => d() ? (() => {
539
+ var u = Ot(), h = u.firstChild, _ = h.nextSibling;
540
+ return p(h, () => s()?.title), _.$$click = () => {
541
+ const v = n(), O = s()?.typeName;
542
+ !v || !O || (g.close(), t.openDocumentEdition(v, O));
543
+ }, u;
544
+ })() : T(ut, {
545
+ service: t,
546
+ language: l,
547
+ value: n,
548
+ setValue: (u) => {
549
+ e(u), c(!0), g.hide();
550
+ }
551
+ });
552
+ })()), a;
553
+ })(), f = (() => {
554
+ var a = z();
555
+ return p(a, (() => {
556
+ var d = L(() => !!r());
557
+ return () => d() ? (() => {
558
+ var u = Vt(), h = u.firstChild;
559
+ return p(u, (() => {
560
+ var _ = L(() => !!n());
561
+ return () => _() && [(() => {
562
+ var v = Rt();
563
+ return v.$$click = () => {
564
+ e(void 0), g.hide();
565
+ }, p(v, () => i("InternalLink.dialog.removeLink")), v;
566
+ })(), (() => {
567
+ var v = tt();
568
+ return v.$$click = () => c(!1), p(v, () => i("InternalLink.dialog.changeLink")), v;
569
+ })()];
570
+ })(), h), h.$$click = () => {
571
+ g.hide();
572
+ }, p(h, () => i("InternalLink.dialog.ok")), u;
573
+ })() : (() => {
574
+ var u = jt();
575
+ return u.$$click = () => {
576
+ g.hide();
577
+ }, p(u, () => i("InternalLink.dialog.ok")), u;
578
+ })();
579
+ })()), a;
580
+ })(), g = t.createModalDialog({
581
+ content: $,
582
+ footer: f,
583
+ header: m
584
+ });
585
+ return (() => {
586
+ var a = z();
587
+ return p(a, (() => {
588
+ var d = L(() => !!n());
589
+ return () => d() ? (() => {
590
+ var u = Mt(), h = u.firstChild, _ = h.nextSibling;
591
+ return p(h, () => s()?.title), _.$$click = () => g.show(), u;
592
+ })() : (() => {
593
+ var u = tt();
594
+ return u.$$click = () => g.show(), p(u, () => i("InternalLink.insertLink")), u;
595
+ })();
596
+ })()), a;
597
+ })();
598
+ }
599
+ Q(["click"]);
600
+ var Ht = /* @__PURE__ */ y("<div class=InternalLinkDialog-header><span class=InternalLinkDialog-title>"), Ft = /* @__PURE__ */ y('<button class="PlgBtn pi pi-arrow-left"type=button>'), Gt = /* @__PURE__ */ y("<div>"), qt = /* @__PURE__ */ y('<div><button class="PlgBtn primary"type=button>'), Kt = /* @__PURE__ */ y('<button type=button class="PlgBtn danger outlined">'), Qt = /* @__PURE__ */ y("<button class=PlgBtn type=button>"), Wt = /* @__PURE__ */ y('<button class="PlgBtn primary"type=button>'), Xt = /* @__PURE__ */ y("<div class=InternalLinkDialog-content>"), Jt = /* @__PURE__ */ y('<div class=ILPreview><div class=ILPreview-title></div><button class="PlgBtn outlined iconBtn pi pi-pencil"type=button>');
601
+ async function Yt({
602
+ value: t,
603
+ getLanguage: e,
604
+ service: n
605
+ }) {
606
+ const [l, i] = S(), {
607
+ t: s
608
+ } = W(e), [o, r] = S(!!t());
609
+ q(async () => {
610
+ const f = t();
611
+ if (!f) return;
612
+ const g = await n.getDocument(f);
613
+ if (!g) return;
614
+ const {
615
+ title: a,
616
+ typeName: d
617
+ } = g;
618
+ i({
619
+ title: a,
620
+ typeName: d
621
+ });
622
+ });
623
+ const c = (() => {
624
+ var f = Ht(), g = f.firstChild;
625
+ return p(f, (() => {
626
+ var a = L(() => !!(t() && !o()));
627
+ return () => a() && (() => {
628
+ var d = Ft();
629
+ return d.$$click = () => {
630
+ r(!0);
631
+ }, d;
632
+ })();
633
+ })(), g), p(g, () => s("InternalLink.dialog.title")), f;
634
+ })(), m = (() => {
635
+ var f = Gt();
636
+ return p(f, (() => {
637
+ var g = L(() => !!o());
638
+ return () => g() ? (() => {
639
+ var a = qt(), d = a.firstChild;
640
+ return p(a, (() => {
641
+ var u = L(() => !!t());
642
+ return () => u() && [(() => {
643
+ var h = Kt();
644
+ return h.$$click = () => $.close("remove"), p(h, () => s("InternalLink.dialog.removeLink")), h;
645
+ })(), (() => {
646
+ var h = Qt();
647
+ return h.$$click = () => r(!1), p(h, () => s("InternalLink.dialog.changeLink")), h;
648
+ })()];
649
+ })(), d), d.$$click = () => $.close(), p(d, () => s("InternalLink.dialog.ok")), a;
650
+ })() : (() => {
651
+ var a = Wt();
652
+ return a.$$click = () => $.close(), p(a, () => s("InternalLink.dialog.ok")), a;
653
+ })();
654
+ })()), f;
655
+ })(), $ = n.createModalDialog({
656
+ content: (() => {
657
+ var f = Xt();
658
+ return p(f, (() => {
659
+ var g = L(() => !!(o() && t()));
660
+ return () => g() ? (() => {
661
+ var a = Jt(), d = a.firstChild, u = d.nextSibling;
662
+ return p(d, () => l()?.title), u.$$click = () => {
663
+ const h = t(), _ = l()?.typeName;
664
+ !h || !_ || ($.close(), n.openDocumentEdition(h, _));
665
+ }, a;
666
+ })() : T(ut, {
667
+ service: n,
668
+ language: e,
669
+ value: t,
670
+ setValue: (a) => $.close(a)
671
+ });
672
+ })()), f;
673
+ })(),
674
+ header: c,
675
+ footer: m
676
+ });
677
+ return await $.open();
678
+ }
679
+ Q(["click"]);
680
+ const ne = {
681
+ create: ee,
682
+ init: te
683
+ };
684
+ function Zt(t) {
685
+ t.executeHook("htmlEditorServiceProvider").forEach((n) => {
686
+ n.registerInternalLinkPlugin(zt(t));
687
+ });
688
+ }
689
+ function zt(t) {
690
+ return {
691
+ async getDocumentTitle(e) {
692
+ return (await t.getDocument(e))?.title;
693
+ },
694
+ async openDialog(e, n) {
695
+ const l = await Yt({
696
+ value: () => e,
697
+ getLanguage: n.getLanguage,
698
+ service: t
699
+ });
700
+ if (e) {
701
+ if (!l) return;
702
+ if (l === "remove") return {
703
+ documentId: void 0
704
+ };
705
+ }
706
+ return {
707
+ documentId: l
708
+ };
709
+ }
710
+ };
711
+ }
712
+ function te({
713
+ pluginBaseUrl: t,
714
+ addAfterInitListener: e
715
+ }) {
716
+ const n = `${t}/internal-link.css`, l = document.createElement("link");
717
+ l.rel = "stylesheet", l.href = n, document.head.appendChild(l), e(Zt);
718
+ }
719
+ function ee(t) {
720
+ const {
721
+ fieldType: e,
722
+ initialValue: n
723
+ } = t;
724
+ if (e.dataType !== "string")
725
+ throw new Error(`field type '${e.name}' is incompatible with internal-link plugin, needs data type 'string'`);
726
+ if (n !== void 0 && typeof n != "string")
727
+ throw new Error(`field type '${e.name}' is incompatible, should be a string, got '${typeof n}'`);
728
+ return ht((l) => {
729
+ const [i, s] = S(n ?? ""), [o, r] = S(t.language);
730
+ return {
731
+ element: T(Ut, {
732
+ language: o,
733
+ value: i,
734
+ setValue: (c) => {
735
+ s(c ?? ""), t.setModifiedValue(c ?? null);
736
+ },
737
+ service: t
738
+ }),
739
+ setLanguage: r,
740
+ setValue: s,
741
+ getValue() {
742
+ return i();
743
+ },
744
+ dispose: l
745
+ };
746
+ });
747
+ }
748
+ export {
749
+ ne as default
750
+ };