@andares/pdeditor 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js ADDED
@@ -0,0 +1,937 @@
1
+ var He = Object.defineProperty;
2
+ var Pe = (r, i, s) => i in r ? He(r, i, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[i] = s;
3
+ var w = (r, i, s) => Pe(r, typeof i != "symbol" ? i + "" : i, s);
4
+ import { forwardRef as Ke, useRef as j, useImperativeHandle as je, useEffect as Oe, createElement as qe, useLayoutEffect as Ue } from "react";
5
+ import { hasLiteralColon as xe, matchKeyValue as ke, findKeyValueSeparator as _e, splitInlineCode as We } from "@andares/pdfoundation";
6
+ import { format as yt, jsonToPdText as xt, pdToJsonText as kt } from "@andares/pdfoundation";
7
+ function Ge(r, i, { signal: s, edges: t } = {}) {
8
+ let a, e = null;
9
+ const l = t != null && t.includes("leading"), c = t == null || t.includes("trailing"), d = () => {
10
+ e !== null && (r.apply(a, e), a = void 0, e = null);
11
+ }, S = () => {
12
+ c && d(), $();
13
+ };
14
+ let m = null;
15
+ const L = () => {
16
+ m != null && clearTimeout(m), m = setTimeout(() => {
17
+ m = null, S();
18
+ }, i);
19
+ }, E = () => {
20
+ m !== null && (clearTimeout(m), m = null);
21
+ }, $ = () => {
22
+ E(), a = void 0, e = null;
23
+ }, x = () => {
24
+ d();
25
+ }, k = function(...f) {
26
+ if (s != null && s.aborted) return;
27
+ a = this, e = f;
28
+ const g = m == null;
29
+ L(), l && g && d();
30
+ };
31
+ return k.schedule = L, k.cancel = $, k.flush = x, s == null || s.addEventListener("abort", $, { once: !0 }), k;
32
+ }
33
+ function re(r, i) {
34
+ const s = r, t = s.key.toLowerCase(), a = i.split("+"), e = a.slice(0, -1), l = a[a.length - 1];
35
+ return !(t !== l || e.includes("shift") !== s.shiftKey || e.includes("ctrl") !== s.ctrlKey || e.includes("alt") !== s.altKey || e.includes("meta") !== s.metaKey);
36
+ }
37
+ function Le(r, i) {
38
+ var a;
39
+ const t = r.slice(0, i).split(`
40
+ `);
41
+ return { line: t.length - 1, col: ((a = t[t.length - 1]) == null ? void 0 : a.length) ?? 0 };
42
+ }
43
+ function X(r, i, s) {
44
+ var a;
45
+ let t = 0;
46
+ for (let e = 0; e < i; e++) t += (((a = r[e]) == null ? void 0 : a.length) ?? 0) + 1;
47
+ return t + s;
48
+ }
49
+ function Se() {
50
+ return (r, i) => {
51
+ var S;
52
+ if (i.type !== "keydown" || !re(i, "enter")) return;
53
+ const { value: s, selectionStart: t, selectionEnd: a } = r, e = s.slice(0, t).split(`
54
+ `).pop() ?? "", l = ((S = /^\s*/.exec(e)) == null ? void 0 : S[0]) ?? "";
55
+ i.preventDefault();
56
+ const c = /^(\s*)-(?=[ ]|$)/.test(e), d = `
57
+ ${l}${c ? "- " : ""}`;
58
+ return {
59
+ value: s.slice(0, t) + d + s.slice(a),
60
+ selectionStart: t + d.length,
61
+ selectionEnd: t + d.length
62
+ };
63
+ };
64
+ }
65
+ function Je(r) {
66
+ return /^(\s*)-(?=[ ]|$)/.test(r);
67
+ }
68
+ function Ee(r, i) {
69
+ return r.startsWith(i) ? i.length : r.startsWith(" ") ? 1 : 0;
70
+ }
71
+ function $e(r) {
72
+ return (i, s) => {
73
+ if (s.type !== "keydown") return;
74
+ const { value: t, selectionStart: a, selectionEnd: e } = i, l = t.split(`
75
+ `), c = t.slice(0, a).split(`
76
+ `).length - 1, d = t.slice(0, e).split(`
77
+ `).length - 1, S = Le(t, a), m = Le(t, e);
78
+ if (re(s, "shift+tab")) {
79
+ s.preventDefault();
80
+ const L = l.map(
81
+ (f, g) => g >= c && g <= d ? f.slice(Ee(f, r)) : f
82
+ ), E = L.join(`
83
+ `);
84
+ if (E === t) return;
85
+ const $ = (f) => {
86
+ const g = Ee(l[f.line] ?? "", r);
87
+ return { line: f.line, col: Math.max(0, f.col - g) };
88
+ }, x = $(S), k = $(m);
89
+ return {
90
+ value: E,
91
+ selectionStart: X(L, x.line, x.col),
92
+ selectionEnd: X(L, k.line, k.col)
93
+ };
94
+ }
95
+ if (re(s, "tab")) {
96
+ s.preventDefault();
97
+ const L = l.map((x, k) => ({ l: x, i: k })).filter(({ i: x }) => x >= c && x <= d);
98
+ if (L.length > 0 && L.every(({ l: x }) => Je(x)) || a !== e) {
99
+ const x = l.map(
100
+ (_, b) => b >= c && b <= d && _ !== "" ? r + _ : _
101
+ ), k = x.join(`
102
+ `), f = (_) => {
103
+ const b = l[_.line] ?? "", D = _.line >= c && _.line <= d;
104
+ return {
105
+ line: _.line,
106
+ col: D && b !== "" ? _.col + r.length : _.col
107
+ };
108
+ }, g = f(S), o = f(m);
109
+ return {
110
+ value: k,
111
+ selectionStart: X(x, g.line, g.col),
112
+ selectionEnd: X(x, o.line, o.col)
113
+ };
114
+ }
115
+ const $ = a + r.length;
116
+ return {
117
+ value: t.slice(0, a) + r + t.slice(e),
118
+ selectionStart: $,
119
+ selectionEnd: $
120
+ };
121
+ }
122
+ };
123
+ }
124
+ function De(r) {
125
+ return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
126
+ }
127
+ function P(r) {
128
+ return r.replace(/\r\n?/g, `
129
+ `);
130
+ }
131
+ function Xe(r, i) {
132
+ const s = document.createRange();
133
+ s.selectNodeContents(r), r.replaceChildren(s.createContextualFragment(i));
134
+ }
135
+ function Ye(r, i) {
136
+ const s = Math.min(r.length, i.length);
137
+ let t = 0;
138
+ for (; t < s && r.charCodeAt(t) === i.charCodeAt(t); ) t++;
139
+ return t;
140
+ }
141
+ const Ze = /* @__PURE__ */ new Set([
142
+ "padding",
143
+ "paddingTop",
144
+ "paddingRight",
145
+ "paddingBottom",
146
+ "paddingLeft"
147
+ ]);
148
+ function Ce(r) {
149
+ var t;
150
+ const i = {
151
+ top: "0px",
152
+ right: "0px",
153
+ bottom: "0px",
154
+ left: "0px"
155
+ }, s = (t = r.padding) == null ? void 0 : t.trim();
156
+ if (s) {
157
+ const a = s.split(/\s+/);
158
+ if (a.length === 1) {
159
+ const e = a[0] ?? "0px";
160
+ i.top = i.right = i.bottom = i.left = e;
161
+ } else a.length === 2 ? (i.top = i.bottom = a[0] ?? "0px", i.right = i.left = a[1] ?? "0px") : a.length === 3 ? (i.top = a[0] ?? "0px", i.right = i.left = a[1] ?? "0px", i.bottom = a[2] ?? "0px") : (i.top = a[0] ?? "0px", i.right = a[1] ?? "0px", i.bottom = a[2] ?? "0px", i.left = a[3] ?? "0px");
162
+ }
163
+ return r.paddingTop && (i.top = r.paddingTop), r.paddingRight && (i.right = r.paddingRight), r.paddingBottom && (i.bottom = r.paddingBottom), r.paddingLeft && (i.left = r.paddingLeft), i;
164
+ }
165
+ function Qe(r) {
166
+ return r.startsWith("--") ? r : r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
167
+ }
168
+ const Ae = "position:relative;display:block;box-sizing:border-box;width:100%;height:auto;max-height:inherit;overflow:hidden;text-align:start;margin:0;border:0;font-family:var(--pd-font-family,inherit);font-size:var(--pd-font-size,inherit);line-height:var(--pd-line-height,1.5);letter-spacing:var(--pd-letter-spacing,inherit);color:var(--pd-color,inherit);background:var(--pd-background,transparent);tab-size:4;font-variant-ligatures:none;font-kerning:normal;", we = "position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;margin:0;border:0;outline:none;resize:none;background:transparent;-webkit-text-fill-color:transparent;caret-color:var(--pd-caret-color,currentColor);overflow:auto;scrollbar-gutter:stable;white-space:pre-wrap;overflow-wrap:break-word;word-break:normal;font:inherit;line-height:inherit;letter-spacing:inherit;tab-size:inherit;z-index:2;", Te = "position:relative;left:auto;top:auto;width:100%;height:auto;box-sizing:border-box;margin:0;border:0;overflow:hidden;scrollbar-gutter:stable;pointer-events:none;user-select:none;white-space:pre-wrap;overflow-wrap:break-word;word-break:normal;font:inherit;line-height:inherit;letter-spacing:inherit;tab-size:inherit;color:inherit;z-index:1;", et = "position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;margin:0;border:0;overflow:hidden;scrollbar-gutter:stable;pointer-events:none;user-select:none;white-space:pre-wrap;overflow-wrap:break-word;word-break:normal;font:inherit;line-height:inherit;letter-spacing:inherit;tab-size:inherit;color:inherit;z-index:0;", Ve = "position:absolute;left:0;top:0;width:100%;height:100%;box-sizing:border-box;margin:0;border:0;overflow:hidden;scrollbar-gutter:stable;pointer-events:none;user-select:none;white-space:pre-wrap;overflow-wrap:break-word;word-break:normal;font:inherit;line-height:inherit;letter-spacing:inherit;tab-size:inherit;color:inherit;opacity:var(--pd-placeholder-opacity,0.5);z-index:1;";
169
+ function Y(r, i, s, t, a = {}) {
170
+ const e = document.createElement(r);
171
+ e.className = i, e.setAttribute("part", s), e.style.cssText = t;
172
+ for (const [l, c] of Object.entries(a)) e.setAttribute(l, c);
173
+ return e;
174
+ }
175
+ function tt(r, i, s) {
176
+ let t = { ...i }, a = t.language ?? "pd", e = P(t.value ?? ""), l = e, c = !1, d = !1, S = !1, m = t.lineNumbers ?? !1, L = Q(), E = "", $ = !1, x = 0, k = null;
177
+ const f = Y("div", "pd-root", "root", Ae), g = Y("pre", "pd-highlight", "highlight", Te, {
178
+ "aria-hidden": "true"
179
+ }), o = Y("textarea", "pd-input", "input", we), _ = Y("div", "pd-placeholder", "placeholder", Ve, {
180
+ "aria-hidden": "true"
181
+ });
182
+ let b = null;
183
+ o.spellcheck = t.spellcheck ?? !1, o.setAttribute("autocapitalize", "off"), o.setAttribute("autocorrect", "off"), o.setAttribute("autocomplete", "off"), o.setAttribute("wrap", "soft"), o.value = e, o.readOnly = t.readOnly ?? !1, o.disabled = t.disabled ?? !1, ((n) => {
184
+ n !== void 0 && n >= 0 ? o.maxLength = n : o.removeAttribute("maxlength");
185
+ })(t.maxLength), t.dir && (o.dir = t.dir), G(), f.appendChild(g), f.appendChild(_), f.appendChild(o), r.appendChild(f), W(), ee(), V(), z();
186
+ function p() {
187
+ c || (g.scrollTop = o.scrollTop, g.scrollLeft = o.scrollLeft, b && (b.scrollTop = o.scrollTop, b.scrollLeft = o.scrollLeft));
188
+ }
189
+ function F() {
190
+ if (typeof getComputedStyle != "function") return 0;
191
+ const n = getComputedStyle(r), u = Number.parseFloat(n.paddingTop) || 0, h = Number.parseFloat(n.paddingBottom) || 0;
192
+ return Math.max(0, r.clientHeight - u - h);
193
+ }
194
+ function M() {
195
+ $ ? (g.style.position = "absolute", g.style.left = "0", g.style.top = "0", g.style.height = "100%") : (g.style.position = "relative", g.style.left = "auto", g.style.top = "auto", g.style.height = "auto");
196
+ }
197
+ function z() {
198
+ if (c) return;
199
+ const n = F(), u = g.scrollHeight;
200
+ if (!$) {
201
+ n > 0 && u > n + 1 && ($ = !0, M(), f.style.height = `${n}px`, p());
202
+ return;
203
+ }
204
+ if (n <= 0 || u <= n + 1) {
205
+ $ = !1, M(), f.style.height = "", o.scrollTop = 0;
206
+ return;
207
+ }
208
+ const h = Number.parseFloat(f.style.height) || 0;
209
+ Math.abs(h - n) > 0.5 && (f.style.height = `${n}px`), p();
210
+ }
211
+ function N() {
212
+ if (!x) {
213
+ if (typeof requestAnimationFrame != "function") {
214
+ z();
215
+ return;
216
+ }
217
+ x = requestAnimationFrame(() => {
218
+ x = 0, z();
219
+ });
220
+ }
221
+ }
222
+ typeof ResizeObserver < "u" && (k = new ResizeObserver(() => N()), k.observe(r), k.observe(f));
223
+ const I = () => p(), U = (n, u, h) => {
224
+ var v;
225
+ e = n, l = n, Z({ value: n, selStart: u, selEnd: h }), (v = t.onValueChange) == null || v.call(t, n);
226
+ }, oe = (n) => {
227
+ if (c) return;
228
+ const u = P(o.value);
229
+ if (d || n != null && n.isComposing) {
230
+ e = u, V();
231
+ return;
232
+ }
233
+ u !== e && (e = u, V()), u !== l && U(u, o.selectionStart, o.selectionEnd);
234
+ }, le = () => {
235
+ d = !0;
236
+ }, se = () => {
237
+ d = !1;
238
+ const n = P(o.value);
239
+ n !== e && (e = n, V());
240
+ }, Ie = Math.max(0, t.historyLimit ?? 5), ae = Math.max(0, t.historyDebounce ?? 1e3), A = [
241
+ { value: e, selStart: -1, selEnd: -1 }
242
+ ], H = [], ce = () => {
243
+ A.length > Ie + 1 && A.splice(1, 1);
244
+ }, ue = (n) => {
245
+ const u = A[0];
246
+ if (u !== void 0 && u.selStart < 0 && u.value !== n.value) {
247
+ const v = Ye(u.value, n.value);
248
+ u.selStart = v, u.selEnd = v;
249
+ }
250
+ const h = A.at(-1);
251
+ h !== void 0 && h.value === n.value || (H.length = 0, A.push(n), ce());
252
+ }, K = Ge(ue, ae), Z = (n) => {
253
+ ae === 0 ? ue(n) : K(n);
254
+ }, de = (n) => {
255
+ var v;
256
+ const u = n.selStart >= 0 ? n.selStart : Math.min(n.value.length, o.selectionStart), h = n.selEnd >= 0 ? n.selEnd : u;
257
+ e = n.value, l = n.value, o.value = n.value, o.setSelectionRange(
258
+ Math.max(0, Math.min(u, n.value.length)),
259
+ Math.max(0, Math.min(h, n.value.length))
260
+ ), V(), p(), (v = t.onValueChange) == null || v.call(t, n.value);
261
+ }, he = () => {
262
+ if (K.flush(), A.length <= 1) return !1;
263
+ const n = A.pop();
264
+ n !== void 0 && H.push(n);
265
+ const u = A.at(-1);
266
+ return u !== void 0 && de(u), !0;
267
+ }, pe = () => {
268
+ if (K.flush(), H.length === 0) return !1;
269
+ const n = H.pop();
270
+ return n === void 0 ? !1 : (A.push(n), ce(), de(n), !0);
271
+ }, fe = (n) => {
272
+ var T;
273
+ if (c || n.isComposing || d || o.readOnly || o.disabled) return;
274
+ const u = n.ctrlKey || n.metaKey, h = n.key.toLowerCase();
275
+ if (u && (h === "z" || h === "y")) {
276
+ n.preventDefault(), h === "y" || h === "z" && n.shiftKey ? pe() : he();
277
+ return;
278
+ }
279
+ if (h === "escape") {
280
+ (t.tabBehavior ?? "indent") === "indent" && (S = !0);
281
+ return;
282
+ }
283
+ if (h === "tab" && (t.tabBehavior ?? "indent") === "focus") return;
284
+ if (h === "tab" && S) {
285
+ S = !1;
286
+ return;
287
+ }
288
+ const v = {
289
+ value: e,
290
+ selectionStart: o.selectionStart,
291
+ selectionEnd: o.selectionEnd
292
+ };
293
+ let y = v;
294
+ for (const O of ne) {
295
+ const R = O(y, n);
296
+ R && (y = { ...y, ...R });
297
+ }
298
+ (y.value !== v.value || y.selectionStart !== v.selectionStart || y.selectionEnd !== v.selectionEnd) && (n.preventDefault(), e = y.value, o.value = y.value, o.setSelectionRange(y.selectionStart, y.selectionEnd), l = y.value, V(), Z({
299
+ value: y.value,
300
+ selStart: y.selectionStart,
301
+ selEnd: y.selectionEnd
302
+ }), (T = t.onValueChange) == null || T.call(t, y.value), p());
303
+ }, ge = () => f.classList.add("pd-focused"), be = () => f.classList.remove("pd-focused");
304
+ o.addEventListener("input", oe), o.addEventListener("compositionstart", le), o.addEventListener("compositionend", se), o.addEventListener("scroll", I, { passive: !0 }), o.addEventListener("keydown", fe), o.addEventListener("focus", ge), o.addEventListener("blur", be);
305
+ function Q() {
306
+ return t.highlight ? (n) => {
307
+ var u;
308
+ return ((u = t.highlight) == null ? void 0 : u.call(t, n, a)) ?? "";
309
+ } : s(a);
310
+ }
311
+ function V() {
312
+ if (c) return;
313
+ const n = t.highlightThreshold ?? 1e5, u = e.length > n ? De(e) : L(e);
314
+ Xe(g, `${u}<br/>`), m && me(), ee(), k || N();
315
+ }
316
+ function me() {
317
+ if (!m) return;
318
+ b || (b = document.createElement("pre"), b.className = "pd-lines", b.setAttribute("part", "gutter"), b.setAttribute("aria-hidden", "true"), f.insertBefore(b, _));
319
+ const n = e.split(`
320
+ `), h = `${String(n.length).length + 1}ch`, v = Ce(t.styles ?? {}), y = `position:absolute;inset-inline-start:${v.left};width:${h};text-align:end;opacity:var(--pd-gutter-opacity,0.35);color:var(--pd-gutter-color,inherit)`, T = document.createDocumentFragment();
321
+ n.forEach((O, R) => {
322
+ const J = document.createElement("span");
323
+ J.className = "pd-ln", J.style.cssText = y, J.textContent = String(R + 1);
324
+ const ie = document.createElement("span");
325
+ ie.style.color = "transparent", ie.textContent = O, T.append(J, ie), R < n.length - 1 && T.append(document.createTextNode(`
326
+ `));
327
+ }), T.append(document.createElement("br")), b.replaceChildren(T), h !== E && (E = h, W(), b.style.cssText = ye(v));
328
+ }
329
+ function ee() {
330
+ const n = t.placeholder ?? "";
331
+ _.textContent = n, _.style.display = n && e.length === 0 ? "block" : "none", n ? o.setAttribute("aria-placeholder", n) : o.removeAttribute("aria-placeholder");
332
+ }
333
+ function ve(n) {
334
+ const u = E ? `calc(${n.left} + ${E})` : n.left;
335
+ return `padding:${n.top} ${n.right} ${n.bottom} ${u};`;
336
+ }
337
+ function te(n, u) {
338
+ return u + ve(n);
339
+ }
340
+ function ye(n) {
341
+ return et + ve(n);
342
+ }
343
+ function W() {
344
+ const n = t.styles ?? {}, u = Ce(n), h = Object.entries(n).filter(([v]) => !Ze.has(v)).map(([v, y]) => `${Qe(v)}:${y};`).join("");
345
+ f.style.cssText = Ae + h, g.style.cssText = te(u, Te), o.style.cssText = te(u, we), _.style.cssText = te(u, Ve), b && (b.style.cssText = ye(u)), M(), t.dir && (f.dir = t.dir, o.dir = t.dir, g.dir = t.dir, _.dir = t.dir, b && (b.dir = t.dir));
346
+ }
347
+ function G() {
348
+ t.ariaLabel ? o.setAttribute("aria-label", t.ariaLabel) : o.removeAttribute("aria-label"), t.ariaLabelledby ? o.setAttribute("aria-labelledby", t.ariaLabelledby) : o.removeAttribute("aria-labelledby"), t.ariaDescribedby ? o.setAttribute("aria-describedby", t.ariaDescribedby) : o.removeAttribute("aria-describedby"), t.readOnly ? o.setAttribute("aria-readonly", "true") : o.removeAttribute("aria-readonly"), t.disabled ? o.setAttribute("aria-disabled", "true") : o.removeAttribute("aria-disabled");
349
+ }
350
+ m && me();
351
+ const ne = [Se(), $e(t.indentUnit ?? " ")];
352
+ return {
353
+ setValue(n, u) {
354
+ if (c || d) return;
355
+ let h = P(n);
356
+ t.maxLength !== void 0 && t.maxLength >= 0 && (h = h.slice(0, t.maxLength)), K.cancel(), e = h, l = h, o.value = h, o.setSelectionRange(h.length, h.length), ((u == null ? void 0 : u.resetHistory) ?? !0) && (A.length = 0, A.push({ value: h, selStart: -1, selEnd: -1 }), H.length = 0), V(), p();
357
+ },
358
+ getValue() {
359
+ return e;
360
+ },
361
+ setLanguage(n) {
362
+ a = n, t = { ...t, language: n }, L = Q(), V();
363
+ },
364
+ setPlaceholder(n) {
365
+ t = { ...t, placeholder: n }, ee();
366
+ },
367
+ setReadOnly(n) {
368
+ t = { ...t, readOnly: n }, o.readOnly = n, G();
369
+ },
370
+ setDisabled(n) {
371
+ t = { ...t, disabled: n }, o.disabled = n, G();
372
+ },
373
+ setLineNumbers(n) {
374
+ m !== n && (m = n, !n && b && (b.remove(), b = null, E = ""), W(), V());
375
+ },
376
+ update(n) {
377
+ c || (t = { ...t, ...n }, n.indentUnit !== void 0 && ne.splice(0, ne.length, Se(), $e(n.indentUnit)), n.language !== void 0 && (a = n.language), ("highlight" in n || n.language !== void 0) && (L = Q()), n.lineNumbers !== void 0 && (m = n.lineNumbers, !m && b && (b.remove(), b = null, E = "")), n.value !== void 0 && (e = P(n.value), l = e, o.value = e, A.length = 0, A.push({ value: e, selStart: -1, selEnd: -1 }), H.length = 0), n.readOnly !== void 0 && (o.readOnly = n.readOnly), n.disabled !== void 0 && (o.disabled = n.disabled), n.maxLength !== void 0 && (n.maxLength >= 0 ? o.maxLength = n.maxLength : o.removeAttribute("maxlength")), n.spellcheck !== void 0 && (o.spellcheck = n.spellcheck), n.dir !== void 0 && (o.dir = n.dir), G(), W(), V(), p());
378
+ },
379
+ focus() {
380
+ o.focus();
381
+ },
382
+ blur() {
383
+ o.blur();
384
+ },
385
+ undo() {
386
+ he();
387
+ },
388
+ redo() {
389
+ pe();
390
+ },
391
+ insertText(n) {
392
+ var O;
393
+ if (c || o.readOnly || o.disabled) return;
394
+ const u = o.selectionStart, h = o.selectionEnd;
395
+ let v = P(n);
396
+ if (t.maxLength !== void 0 && t.maxLength >= 0) {
397
+ const R = t.maxLength - (e.length - (h - u));
398
+ if (R <= 0) return;
399
+ v.length > R && (v = v.slice(0, R));
400
+ }
401
+ const y = e.slice(0, u) + v + e.slice(h);
402
+ e = y, l = y, o.value = y;
403
+ const T = u + v.length;
404
+ o.setSelectionRange(T, T), V(), Z({ value: y, selStart: T, selEnd: T }), (O = t.onValueChange) == null || O.call(t, y), p();
405
+ },
406
+ getSelection() {
407
+ return { start: o.selectionStart, end: o.selectionEnd };
408
+ },
409
+ setSelection(n, u = n) {
410
+ const h = (v) => Math.max(0, Math.min(e.length, Number.isFinite(v) ? v : 0));
411
+ o.setSelectionRange(h(n), h(u));
412
+ },
413
+ destroy() {
414
+ c || (c = !0, K.cancel(), k == null || k.disconnect(), x && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(x), o.removeEventListener("input", oe), o.removeEventListener("compositionstart", le), o.removeEventListener("compositionend", se), o.removeEventListener("scroll", I), o.removeEventListener("keydown", fe), o.removeEventListener("focus", ge), o.removeEventListener("blur", be), f.remove());
415
+ },
416
+ textarea: o,
417
+ root: f,
418
+ pre: g
419
+ };
420
+ }
421
+ function C(r) {
422
+ return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
423
+ }
424
+ const B = {
425
+ key: "pd-key",
426
+ keyPunct: "pd-key-punct",
427
+ item: "pd-item",
428
+ section: "pd-section",
429
+ sep: "pd-sep",
430
+ ref: "pd-ref",
431
+ inlineCode: "pd-inline-code",
432
+ fence: "pd-fence"
433
+ };
434
+ function nt(r) {
435
+ return `<span class="${B.inlineCode}">${C(r)}</span>`;
436
+ }
437
+ const Re = /(?:^|\s):([^\s-][^\s]*)(?=\s|$)/g;
438
+ function it(r) {
439
+ let i = "", s = 0;
440
+ Re.lastIndex = 0;
441
+ let t;
442
+ for (; (t = Re.exec(r)) !== null; ) {
443
+ const a = /^\s/.test(t[0]) ? 1 : 0, e = t.index + a;
444
+ i += C(r.slice(s, e)), i += `<span class="${B.ref}">${C(r.slice(e, t.index + t[0].length))}</span>`, s = t.index + t[0].length;
445
+ }
446
+ return i += C(r.slice(s)), i;
447
+ }
448
+ function q(r) {
449
+ let i = "";
450
+ for (const { code: s, seg: t } of We(r))
451
+ i += s ? nt(t) : it(t);
452
+ return i;
453
+ }
454
+ function Be(r, i, s, t) {
455
+ const a = `<span class="${B.key}">${q(s)}</span>`, e = `<span class="${B.keyPunct}">:</span>`;
456
+ return `${r}${i}${a}${e}${q(t)}`;
457
+ }
458
+ function rt(r) {
459
+ const i = r.trim();
460
+ if (/^\/\/!pd(?:\s+[^\s]+)?$/.test(i)) {
461
+ const t = /^(\s*)(\/\/!pd)(\s*.*)$/.exec(r), a = (t == null ? void 0 : t[1]) ?? "", e = (t == null ? void 0 : t[2]) ?? "//!pd", l = (t == null ? void 0 : t[3]) ?? "";
462
+ return `${C(a)}<span class="${B.section}">${C(e)}</span>${q(l)}`;
463
+ }
464
+ if (i === "---")
465
+ return `<span class="${B.sep}">${C(r)}</span>`;
466
+ const s = /^(\s*)(-)(?=[ ]|$)/.exec(r);
467
+ if (s) {
468
+ const t = C(s[1] ?? ""), a = (s[1] ?? "").length + 1, e = r.slice(a), l = e.trimStart(), c = e.slice(0, e.length - l.length), d = `<span class="${B.item}">-</span>`;
469
+ if (!xe(l) && ke(l)) {
470
+ const m = _e(l), L = l.slice(0, m), E = l.slice(m + 1);
471
+ return `${t}${d}${C(c)}${Be("", "", L, E)}`;
472
+ }
473
+ return `${t}${d}${C(c)}${q(l)}`;
474
+ }
475
+ if (!xe(i) && ke(i)) {
476
+ const a = r.length - r.trimStart().length, e = r.slice(a), l = _e(e), c = e.slice(0, l).trim(), d = e.slice(l + 1);
477
+ return Be(C(r.slice(0, a)), "", c, d);
478
+ }
479
+ return q(r);
480
+ }
481
+ function ot(r) {
482
+ const i = r.split(`
483
+ `);
484
+ let s = !1;
485
+ const t = [];
486
+ for (const a of i) {
487
+ const e = a.trimStart();
488
+ if (s) {
489
+ e.startsWith("```") ? (s = !1, t.push(`<span class="${B.fence}">${C(a)}</span>`)) : t.push(C(a));
490
+ continue;
491
+ }
492
+ if (e.startsWith("```")) {
493
+ s = !0, t.push(`<span class="${B.fence}">${C(a)}</span>`);
494
+ continue;
495
+ }
496
+ t.push(rt(a));
497
+ }
498
+ return t.join(`
499
+ `);
500
+ }
501
+ function lt(r) {
502
+ return (i) => r === "pd" ? ot(i) : De(i);
503
+ }
504
+ function Me(r) {
505
+ const i = r;
506
+ return `
507
+ ${i}.pd-key{color:var(--pd-token-key,color-mix(in oklab,currentColor 66%,transparent))}
508
+ ${i}.pd-key-punct{color:var(--pd-token-punct,color-mix(in oklab,currentColor 45%,transparent))}
509
+ ${i}.pd-item{color:var(--pd-token-item,color-mix(in oklab,currentColor 78%,transparent))}
510
+ ${i}.pd-section{color:var(--pd-token-section,color-mix(in oklab,currentColor 62%,transparent))}
511
+ ${i}.pd-sep{color:var(--pd-token-sep,color-mix(in oklab,currentColor 45%,transparent))}
512
+ ${i}.pd-ref{color:var(--pd-token-ref,color-mix(in oklab,currentColor 74%,transparent))}
513
+ ${i}.pd-inline-code{color:var(--pd-token-code,color-mix(in oklab,currentColor 84%,transparent))}
514
+ ${i}.pd-fence{color:var(--pd-token-fence,color-mix(in oklab,currentColor 55%,transparent))}
515
+ ${i}.token.comment,${i}.token.prolog,${i}.token.doctype,${i}.token.cdata{color:var(--pd-token-comment,color-mix(in oklab,currentColor 52%,transparent))}
516
+ ${i}.token.string,${i}.token.attr-value{color:var(--pd-token-string,color-mix(in oklab,currentColor 78%,transparent))}
517
+ ${i}.token.keyword,${i}.token.tag,${i}.token.operator{color:var(--pd-token-keyword,color-mix(in oklab,currentColor 64%,transparent))}
518
+ ${i}.token.number,${i}.token.boolean{color:var(--pd-token-number,color-mix(in oklab,currentColor 72%,transparent))}
519
+ ${i}.token.property,${i}.token.function{color:var(--pd-token-property,color-mix(in oklab,currentColor 68%,transparent))}
520
+ ${i}.token.punctuation{color:var(--pd-token-punctuation,color-mix(in oklab,currentColor 50%,transparent))}
521
+ `;
522
+ }
523
+ function ze(r) {
524
+ const i = r;
525
+ return `
526
+ @supports not (color: color-mix(in oklab, red, blue)){
527
+ ${i}.pd-key{opacity:.72}${i}.pd-key-punct{opacity:.5}${i}.pd-item{opacity:.8}
528
+ ${i}.pd-section{opacity:.65}${i}.pd-sep{opacity:.5}${i}.pd-ref{opacity:.78}
529
+ ${i}.pd-inline-code{opacity:.88}${i}.pd-fence{opacity:.6}
530
+ }`;
531
+ }
532
+ const Fe = `
533
+ :host{display:block;min-width:0;max-width:100%;height:auto;max-height:inherit;font:inherit;color:inherit;background:transparent}
534
+ :host([disabled]){opacity:var(--pd-disabled-opacity,.6)}
535
+ :host(:focus-within){outline:var(--pd-focus-ring,2px solid color-mix(in oklab,currentColor 32%,transparent));outline-offset:var(--pd-focus-ring-offset,2px);border-radius:var(--pd-focus-radius,2px)}
536
+ ${Me("")}
537
+ ${ze("")}
538
+ `;
539
+ function st() {
540
+ const r = "pd-editor ";
541
+ return `
542
+ pd-editor{display:block;min-width:0;max-width:100%;height:auto;max-height:inherit;font:inherit;color:inherit;background:transparent}
543
+ pd-editor[disabled]{opacity:var(--pd-disabled-opacity,.6)}
544
+ pd-editor:focus-within{outline:var(--pd-focus-ring,2px solid color-mix(in oklab,currentColor 32%,transparent));outline-offset:var(--pd-focus-ring-offset,2px);border-radius:var(--pd-focus-radius,2px)}
545
+ ${Me(r)}
546
+ ${ze(r)}
547
+ `;
548
+ }
549
+ const Ne = /* @__PURE__ */ new WeakSet();
550
+ function at(r) {
551
+ if (Ne.has(r)) return;
552
+ Ne.add(r);
553
+ const i = r.createElement("style");
554
+ i.setAttribute("data-pd-editor", ""), i.textContent = st(), (r.head ?? r.documentElement).appendChild(i);
555
+ }
556
+ function ct(r) {
557
+ if (r.querySelector("style[data-pd-editor]")) return;
558
+ try {
559
+ if (typeof CSSStyleSheet < "u" && "replaceSync" in CSSStyleSheet.prototype) {
560
+ const s = new CSSStyleSheet();
561
+ s.replaceSync(Fe), r.adoptedStyleSheets = [...r.adoptedStyleSheets, s];
562
+ return;
563
+ }
564
+ } catch {
565
+ }
566
+ const i = document.createElement("style");
567
+ i.setAttribute("data-pd-editor", ""), i.textContent = Fe, r.appendChild(i);
568
+ }
569
+ const ut = [
570
+ "value",
571
+ "language",
572
+ "placeholder",
573
+ "indent-unit",
574
+ "line-numbers",
575
+ "tab-behavior",
576
+ "readonly",
577
+ "disabled",
578
+ "maxlength",
579
+ "name",
580
+ "spellcheck",
581
+ "inputmode",
582
+ "enterkeyhint",
583
+ "dir",
584
+ "aria-label",
585
+ "aria-labelledby",
586
+ "aria-describedby",
587
+ "shadow"
588
+ ];
589
+ function dt(r = "pd-editor") {
590
+ if (typeof HTMLElement > "u" || typeof customElements > "u")
591
+ return null;
592
+ const i = customElements.get(r);
593
+ if (i) return i;
594
+ class s extends HTMLElement {
595
+ constructor() {
596
+ super();
597
+ w(this, "_editor", null);
598
+ w(this, "_internals", null);
599
+ w(this, "_container", null);
600
+ w(this, "_shadow", null);
601
+ w(this, "_value", "");
602
+ w(this, "_defaultValue", null);
603
+ w(this, "_highlight", null);
604
+ w(this, "_formDisabled", !1);
605
+ w(this, "_focusValue", "");
606
+ w(this, "_onFocus", () => {
607
+ this._focusValue = this._value, this._emit("pd-focus", { value: this._value });
608
+ });
609
+ w(this, "_onBlur", () => {
610
+ this._value !== this._focusValue && this._emit("pd-change", { value: this._value }), this._emit("pd-blur", { value: this._value });
611
+ });
612
+ try {
613
+ this._internals = typeof this.attachInternals == "function" ? this.attachInternals() : null;
614
+ } catch {
615
+ this._internals = null;
616
+ }
617
+ }
618
+ static get observedAttributes() {
619
+ return ut;
620
+ }
621
+ // ---- 属性 / 属性反射 ----
622
+ get value() {
623
+ return this._editor ? this._editor.getValue() : this._value;
624
+ }
625
+ set value(e) {
626
+ var c;
627
+ const l = e == null ? "" : String(e);
628
+ this._value = l, (c = this._editor) == null || c.setValue(l), this._syncFormValue();
629
+ }
630
+ get language() {
631
+ return this.getAttribute("language") ?? "pd";
632
+ }
633
+ set language(e) {
634
+ this.setAttribute("language", String(e));
635
+ }
636
+ get placeholder() {
637
+ return this.getAttribute("placeholder") ?? "";
638
+ }
639
+ set placeholder(e) {
640
+ this.setAttribute("placeholder", String(e));
641
+ }
642
+ get readOnly() {
643
+ return this.hasAttribute("readonly");
644
+ }
645
+ set readOnly(e) {
646
+ this.toggleAttribute("readonly", !!e);
647
+ }
648
+ get disabled() {
649
+ return this.hasAttribute("disabled");
650
+ }
651
+ set disabled(e) {
652
+ this.toggleAttribute("disabled", !!e);
653
+ }
654
+ get lineNumbers() {
655
+ return this.hasAttribute("line-numbers");
656
+ }
657
+ set lineNumbers(e) {
658
+ this.toggleAttribute("line-numbers", !!e);
659
+ }
660
+ get indentUnit() {
661
+ return this.getAttribute("indent-unit") ?? " ";
662
+ }
663
+ set indentUnit(e) {
664
+ this.setAttribute("indent-unit", String(e));
665
+ }
666
+ get tabBehavior() {
667
+ return this.getAttribute("tab-behavior") === "focus" ? "focus" : "indent";
668
+ }
669
+ set tabBehavior(e) {
670
+ this.setAttribute("tab-behavior", e === "focus" ? "focus" : "indent");
671
+ }
672
+ get maxLength() {
673
+ const e = this.getAttribute("maxlength");
674
+ if (e === null || e === "") return -1;
675
+ const l = Number.parseInt(e, 10);
676
+ return Number.isFinite(l) ? l : -1;
677
+ }
678
+ set maxLength(e) {
679
+ !Number.isFinite(e) || e < 0 ? this.removeAttribute("maxlength") : this.setAttribute("maxlength", String(Math.floor(e)));
680
+ }
681
+ get name() {
682
+ return this.getAttribute("name") ?? "";
683
+ }
684
+ set name(e) {
685
+ this.setAttribute("name", String(e));
686
+ }
687
+ get highlight() {
688
+ return this._highlight;
689
+ }
690
+ set highlight(e) {
691
+ this._highlight = typeof e == "function" ? e : null, this._syncOptions();
692
+ }
693
+ get editor() {
694
+ return this._editor;
695
+ }
696
+ get textarea() {
697
+ var e;
698
+ return ((e = this._editor) == null ? void 0 : e.textarea) ?? null;
699
+ }
700
+ // ---- 生命周期 ----
701
+ connectedCallback() {
702
+ this._upgradeProperties();
703
+ const e = this.getAttribute("value");
704
+ if (e !== null && this._value === "" && (this._value = e), this._defaultValue === null && (this._defaultValue = this._value), this._editor) return;
705
+ const l = this.getAttribute("shadow") === "false";
706
+ l ? at(this.ownerDocument) : (this._shadow ?? (this._shadow = this.attachShadow({
707
+ mode: "open",
708
+ delegatesFocus: !0
709
+ })), ct(this._shadow));
710
+ const c = l ? this : this._shadow, d = document.createElement("div");
711
+ d.className = "pd-container", d.setAttribute("part", "container"), d.style.cssText = "display:block;height:100%;max-height:inherit;min-width:0", c.appendChild(d), this._container = d;
712
+ const S = {
713
+ value: this._value,
714
+ language: this.language,
715
+ placeholder: this.placeholder,
716
+ readOnly: this.readOnly,
717
+ disabled: this.disabled || this._formDisabled,
718
+ lineNumbers: this.lineNumbers,
719
+ indentUnit: this.indentUnit,
720
+ tabBehavior: this.tabBehavior,
721
+ maxLength: this.maxLength,
722
+ spellcheck: this.getAttribute("spellcheck") === "true",
723
+ dir: this.getAttribute("dir") ?? "",
724
+ ariaLabel: this.getAttribute("aria-label") ?? void 0,
725
+ ariaLabelledby: this.getAttribute("aria-labelledby") ?? void 0,
726
+ ariaDescribedby: this.getAttribute("aria-describedby") ?? void 0,
727
+ highlight: this._highlight ?? void 0,
728
+ onValueChange: (m) => this._handleValueChange(m)
729
+ };
730
+ this._editor = tt(d, S, lt), this._editor.textarea.addEventListener("focus", this._onFocus), this._editor.textarea.addEventListener("blur", this._onBlur), this._focusValue = this._value, this._applyInputHints(), this._syncFormValue(), queueMicrotask(() => {
731
+ this._editor && this._emit("pd-ready", { editor: this._editor });
732
+ });
733
+ }
734
+ disconnectedCallback() {
735
+ var e, l, c, d;
736
+ this._editor && (this._value = this._editor.getValue()), (e = this._editor) == null || e.textarea.removeEventListener("focus", this._onFocus), (l = this._editor) == null || l.textarea.removeEventListener("blur", this._onBlur), (c = this._editor) == null || c.destroy(), this._editor = null, (d = this._container) == null || d.remove(), this._container = null;
737
+ }
738
+ attributeChangedCallback(e, l, c) {
739
+ var d;
740
+ if (l !== c) {
741
+ if (e === "value") {
742
+ this._value = c ?? "", (d = this._editor) == null || d.setValue(this._value), this._syncFormValue();
743
+ return;
744
+ }
745
+ e !== "shadow" && this._editor && (this._syncOptions(), e === "language" && this._emit("pd-language-change", { value: this.language }));
746
+ }
747
+ }
748
+ // ---- 表单关联 ----
749
+ formResetCallback() {
750
+ this.value = this._defaultValue ?? "";
751
+ }
752
+ formDisabledCallback(e) {
753
+ var l;
754
+ this._formDisabled = e, (l = this._editor) == null || l.setDisabled(e || this.disabled);
755
+ }
756
+ formStateRestoreCallback(e) {
757
+ typeof e == "string" && (this.value = e);
758
+ }
759
+ // ---- 公共方法 ----
760
+ setValue(e) {
761
+ this.value = e;
762
+ }
763
+ getValue() {
764
+ return this.value;
765
+ }
766
+ setLanguage(e) {
767
+ this.language = e;
768
+ }
769
+ insertText(e) {
770
+ var l;
771
+ (l = this._editor) == null || l.insertText(e);
772
+ }
773
+ getSelection() {
774
+ var e;
775
+ return ((e = this._editor) == null ? void 0 : e.getSelection()) ?? null;
776
+ }
777
+ setSelection(e, l) {
778
+ var c;
779
+ (c = this._editor) == null || c.setSelection(e, l);
780
+ }
781
+ undo() {
782
+ var e;
783
+ (e = this._editor) == null || e.undo();
784
+ }
785
+ redo() {
786
+ var e;
787
+ (e = this._editor) == null || e.redo();
788
+ }
789
+ focus() {
790
+ var e;
791
+ (e = this._editor) == null || e.focus();
792
+ }
793
+ blur() {
794
+ var e;
795
+ (e = this._editor) == null || e.blur();
796
+ }
797
+ // ---- 内部 ----
798
+ _upgradeProperties() {
799
+ const e = [
800
+ "value",
801
+ "language",
802
+ "placeholder",
803
+ "readOnly",
804
+ "disabled",
805
+ "lineNumbers",
806
+ "indentUnit",
807
+ "tabBehavior",
808
+ "maxLength",
809
+ "name",
810
+ "highlight"
811
+ ];
812
+ for (const l of e)
813
+ if (Object.prototype.hasOwnProperty.call(this, l)) {
814
+ const c = this, d = c[l];
815
+ delete c[l], c[l] = d;
816
+ }
817
+ }
818
+ _syncOptions() {
819
+ var e;
820
+ (e = this._editor) == null || e.update({
821
+ language: this.language,
822
+ placeholder: this.placeholder,
823
+ readOnly: this.readOnly,
824
+ disabled: this.disabled || this._formDisabled,
825
+ lineNumbers: this.lineNumbers,
826
+ indentUnit: this.indentUnit,
827
+ tabBehavior: this.tabBehavior,
828
+ maxLength: this.maxLength,
829
+ spellcheck: this.getAttribute("spellcheck") === "true",
830
+ dir: this.getAttribute("dir") ?? "",
831
+ ariaLabel: this.getAttribute("aria-label") ?? void 0,
832
+ ariaLabelledby: this.getAttribute("aria-labelledby") ?? void 0,
833
+ ariaDescribedby: this.getAttribute("aria-describedby") ?? void 0,
834
+ highlight: this._highlight ?? void 0
835
+ }), this._applyInputHints();
836
+ }
837
+ /** 移动端输入提示:inputmode / enterkeyhint 原样转发到内部 textarea */
838
+ _applyInputHints() {
839
+ var l;
840
+ const e = (l = this._editor) == null ? void 0 : l.textarea;
841
+ if (e)
842
+ for (const c of ["inputmode", "enterkeyhint"]) {
843
+ const d = this.getAttribute(c);
844
+ d ? e.setAttribute(c, d) : e.removeAttribute(c);
845
+ }
846
+ }
847
+ _handleValueChange(e) {
848
+ this._value = e, this._syncFormValue(), this._emit("pd-input", { value: e });
849
+ }
850
+ _syncFormValue() {
851
+ var e;
852
+ typeof ((e = this._internals) == null ? void 0 : e.setFormValue) == "function" && this._internals.setFormValue(this._value);
853
+ }
854
+ _emit(e, l) {
855
+ this.dispatchEvent(
856
+ new CustomEvent(e, { detail: l, bubbles: !0, composed: !0 })
857
+ );
858
+ }
859
+ }
860
+ return w(s, "formAssociated", !0), customElements.define(r, s), s;
861
+ }
862
+ const ht = typeof window > "u" ? Oe : Ue, bt = Ke(
863
+ function(i, s) {
864
+ const {
865
+ value: t,
866
+ defaultValue: a,
867
+ language: e,
868
+ placeholder: l,
869
+ readOnly: c,
870
+ disabled: d,
871
+ lineNumbers: S,
872
+ indentUnit: m,
873
+ tabBehavior: L,
874
+ maxLength: E,
875
+ highlight: $,
876
+ onValueChange: x,
877
+ onReady: k,
878
+ ...f
879
+ } = i, g = j(null), o = j(!0), _ = j(x);
880
+ _.current = x;
881
+ const b = j(k);
882
+ b.current = k;
883
+ const D = j(!1);
884
+ return je(
885
+ s,
886
+ () => g.current,
887
+ []
888
+ ), ht(() => {
889
+ dt();
890
+ const p = g.current;
891
+ if (p) {
892
+ if (o.current) {
893
+ o.current = !1;
894
+ const F = t ?? a;
895
+ F !== void 0 && p.value !== F && (p.value = F);
896
+ } else t !== void 0 && p.value !== t && (p.value = t);
897
+ e !== void 0 && p.language !== e && (p.language = e), l !== void 0 && p.placeholder !== l && (p.placeholder = l), c !== void 0 && (p.readOnly = c), d !== void 0 && (p.disabled = d), S !== void 0 && (p.lineNumbers = S), m !== void 0 && p.indentUnit !== m && (p.indentUnit = m), L !== void 0 && (p.tabBehavior = L), E !== void 0 && (p.maxLength = E), $ !== void 0 && (p.highlight = $);
898
+ }
899
+ }, [
900
+ t,
901
+ a,
902
+ e,
903
+ l,
904
+ c,
905
+ d,
906
+ S,
907
+ m,
908
+ L,
909
+ E,
910
+ $
911
+ ]), Oe(() => {
912
+ const p = g.current;
913
+ if (!p) return;
914
+ const F = (N) => {
915
+ var U;
916
+ const I = N.detail;
917
+ (U = _.current) == null || U.call(_, (I == null ? void 0 : I.value) ?? p.value);
918
+ }, M = () => {
919
+ var N;
920
+ D.current || (D.current = !0, (N = b.current) == null || N.call(b, p));
921
+ }, z = () => M();
922
+ return p.addEventListener("pd-input", F), p.addEventListener("pd-ready", z), queueMicrotask(() => {
923
+ p.editor && M();
924
+ }), () => {
925
+ p.removeEventListener("pd-input", F), p.removeEventListener("pd-ready", z), D.current = !1;
926
+ };
927
+ }, []), qe("pd-editor", { ...f, ref: g });
928
+ }
929
+ );
930
+ export {
931
+ bt as PdEditor,
932
+ dt as definePdEditor,
933
+ yt as format,
934
+ ot as highlightPd,
935
+ xt as jsonToPdText,
936
+ kt as pdToJsonText
937
+ };