@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/pd.js CHANGED
@@ -1,338 +1,423 @@
1
- import { format as he, jsonToPdText as de, pdToJsonText as pe } from "@andares/pdfoundation";
2
- function _(s, e, { signal: n, edges: t } = {}) {
3
- let i, o = null;
4
- const a = t != null && t.includes("leading"), c = t == null || t.includes("trailing"), l = () => {
5
- o !== null && (s.apply(i, o), i = void 0, o = null);
6
- }, f = () => {
7
- c && l(), E();
1
+ import { hasLiteralColon as me, matchKeyValue as be, findKeyValueSeparator as ve, splitInlineCode as De } from "@andares/pdfoundation";
2
+ import { format as Qe, jsonToPdText as Ue, pdToJsonText as et } from "@andares/pdfoundation";
3
+ function Fe(i, o, { signal: s, edges: e } = {}) {
4
+ let l, r = null;
5
+ const u = e != null && e.includes("leading"), p = e == null || e.includes("trailing"), b = () => {
6
+ r !== null && (i.apply(l, r), l = void 0, r = null);
7
+ }, w = () => {
8
+ p && b(), $();
8
9
  };
9
- let h = null;
10
- const y = () => {
11
- h != null && clearTimeout(h), h = setTimeout(() => {
12
- h = null, f();
13
- }, e);
14
- }, b = () => {
15
- h !== null && (clearTimeout(h), h = null);
16
- }, E = () => {
17
- b(), i = void 0, o = null;
18
- }, u = () => {
19
- l();
20
- }, p = function(...g) {
21
- if (n != null && n.aborted) return;
22
- i = this, o = g;
23
- const S = h == null;
24
- y(), a && S && l();
10
+ let v = null;
11
+ const E = () => {
12
+ v != null && clearTimeout(v), v = setTimeout(() => {
13
+ v = null, w();
14
+ }, o);
15
+ }, S = () => {
16
+ v !== null && (clearTimeout(v), v = null);
17
+ }, $ = () => {
18
+ S(), l = void 0, r = null;
19
+ }, y = () => {
20
+ b();
21
+ }, L = function(...d) {
22
+ if (s != null && s.aborted) return;
23
+ l = this, r = d;
24
+ const h = v == null;
25
+ E(), u && h && b();
25
26
  };
26
- return p.schedule = y, p.cancel = E, p.flush = u, n == null || n.addEventListener("abort", E, { once: !0 }), p;
27
+ return L.schedule = E, L.cancel = $, L.flush = y, s == null || s.addEventListener("abort", $, { once: !0 }), L;
27
28
  }
28
- const A = { position: "relative", boxSizing: "border-box", overflow: "hidden", fontSize: "16px", fontFamily: 'Menlo, Consolas, "Liberation Mono", Monaco, "Lucida Console", monospace' }, J = { lineHeight: "inherit", whiteSpace: "pre-wrap", wordBreak: "keep-all", overflowWrap: "break-word", background: "none", position: "absolute", width: "100%", height: "100%", zIndex: "1", resize: "none", caretColor: "currentColor", padding: "inherit", outline: "none", fontSize: "inherit", fontFamily: "inherit", letterSpacing: "inherit", boxSizing: "border-box", border: "none", top: "0px", left: "0px", color: "inherit", overflow: "hidden", "-webkit-font-smoothing": "antialiased", "-webkit-text-fill-color": "transparent" }, G = { lineHeight: "inherit", position: "relative", whiteSpace: "pre-wrap", wordBreak: "keep-all", padding: "0", width: "100%", margin: "0", pointerEvents: "none", boxSizing: "border-box", overflowWrap: "break-word", fontFamily: "inherit" }, Q = { lineHeight: "inherit", position: "absolute", width: "100%", height: "100%", whiteSpace: "pre-wrap", wordBreak: "keep-all", padding: "inherit", margin: "0", top: "0px", left: "0px", pointerEvents: "none", boxSizing: "border-box", overflowWrap: "break-word", fontFamily: "inherit" }, q = (s) => B(s);
29
- function D(s) {
30
- const e = Array.isArray(s) ? s : [s];
31
- return e.length === 0 ? q : (n) => e.reduce((t, i, o) => i(t, { html: o > 0 }), n);
29
+ function Z(i, o) {
30
+ const s = i, e = s.key.toLowerCase(), l = o.split("+"), r = l.slice(0, -1), u = l[l.length - 1];
31
+ return !(e !== u || r.includes("shift") !== s.shiftKey || r.includes("ctrl") !== s.ctrlKey || r.includes("alt") !== s.altKey || r.includes("meta") !== s.metaKey);
32
32
  }
33
- class X {
34
- constructor(e, n = {}) {
35
- if (this.lines = null, !e) throw new Error("selector is not defined");
36
- if (this.root = e instanceof Node ? e : document.querySelector(e), !this.root) throw new Error(`element with "${e}" selector is not exist`);
37
- const t = { value: "", styles: {}, plugins: [], highlighter: q }, { highlighters: i, ...o } = n;
38
- this.options = { ...t, ...o, highlighter: i ? D(i) : t.highlighter }, this.options.value = this.options.value == null ? "" : String(this.options.value), this.init();
39
- }
40
- init() {
41
- this.textarea = document.createElement("textarea"), this.textarea.setAttribute("spellcheck", "false"), this.textarea.setAttribute("autocapitalize", "off"), this.textarea.setAttribute("autocorrect", "off"), this.textarea.setAttribute("autocomplete", "off"), this.pre = document.createElement("pre");
42
- const e = Object.keys(A).concat(Object.keys(this.options.styles)).concat(["paddingLeft"]);
43
- this.initialRootStyles = {};
44
- const n = this.root.style;
45
- e.forEach((t) => {
46
- this.initialRootStyles[t] = n[t] || "";
47
- }), Object.assign(this.root.style, A, this.options.styles), Object.assign(this.textarea.style, J), Object.assign(this.pre.style, G), this.basePaddingLeft = this.root.style.paddingLeft || "", this.root.appendChild(this.textarea), this.root.appendChild(this.pre), this.addTextareaEvents(), this.update({ value: this.options.value }), this.updateLines();
48
- }
49
- addTextareaEvents() {
50
- this.handleEvent = (e) => {
51
- if (e.type === "keydown" && this.textarea.readOnly) return;
52
- const n = e;
53
- if (n.isComposing || n.keyCode === 229) return;
54
- const t = (function(i, o) {
55
- const { value: a, selectionStart: c, selectionEnd: l } = o.target;
56
- return i.reduce((f, h) => ({ ...f, ...h(f, o) }), { value: a, selectionStart: c, selectionEnd: l });
57
- })(this.options.plugins, e);
58
- this.update(t);
59
- }, this.textarea.addEventListener("input", this.handleEvent), this.textarea.addEventListener("keydown", this.handleEvent), this.textarea.addEventListener("compositionend", this.handleEvent);
60
- }
61
- update(e) {
62
- if (!this.textarea) return;
63
- let { value: n, selectionStart: t, selectionEnd: i } = e;
64
- n != null && (n = String(n), t == null && (t = this.textarea.selectionStart), i == null && (i = this.textarea.selectionEnd), this.textarea.value !== n && (this.textarea.value = n)), t != null && (this.textarea.selectionStart = t), i != null && (this.textarea.selectionEnd = i), n !== this.value && n != null && (this.value = n, this.render(), this.updateCallback && this.updateCallback(n));
65
- }
66
- updateOptions(e) {
67
- if (!this.textarea) return;
68
- const { highlighters: n, ...t } = e;
69
- if (this.options = { ...this.options, ...t, highlighter: n ? D(n) : this.options.highlighter }, e.styles) {
70
- const i = this.root.style;
71
- Object.keys(e.styles).forEach((o) => {
72
- o in this.initialRootStyles || (this.initialRootStyles[o] = i[o] || "");
73
- }), Object.assign(this.root.style, e.styles), ("paddingLeft" in e.styles || "padding" in e.styles) && (this.basePaddingLeft = this.root.style.paddingLeft || "");
74
- }
75
- this.lines && !this.options.lineNumbers && (T(this.lines), this.lines = null, this.root.style.paddingLeft = this.basePaddingLeft), e.value != null && this.update({ value: e.value }), this.render();
76
- }
77
- render() {
78
- const e = this.options.highlighter(this.value);
79
- this.pre.innerHTML = e + "<br/>", this.updateLines();
80
- }
81
- updateLines() {
82
- if (!this.options.lineNumbers) return;
83
- this.lines || (this.lines = document.createElement("pre"), this.root.appendChild(this.lines), Object.assign(this.lines.style, Q));
84
- const e = this.value.split(`
85
- `), n = e.length.toString().length;
86
- this.root.style.paddingLeft = `${n + 1}ch`, this.lines.innerHTML = e.map((t, i) => `${`<span class="yace-line" style="position: absolute; opacity: .3; left: 0; width: ${n}ch; text-align: right">${1 + i}</span>`}${`<span style="color: transparent; pointer-events: none">${B(t)}</span>`}`).join(`
33
+ function ye(i, o) {
34
+ var l;
35
+ const e = i.slice(0, o).split(`
87
36
  `);
88
- }
89
- destroy() {
90
- this.textarea && (this.textarea.removeEventListener("input", this.handleEvent), this.textarea.removeEventListener("keydown", this.handleEvent), this.textarea.removeEventListener("compositionend", this.handleEvent), T(this.textarea), T(this.pre), T(this.lines), Object.assign(this.root.style, this.initialRootStyles), Object.assign(this, { textarea: null, pre: null, lines: null, updateCallback: null, handleEvent: null, initialRootStyles: null, options: null, root: null }));
91
- }
92
- onUpdate(e) {
93
- this.updateCallback = e;
94
- }
37
+ return { line: e.length - 1, col: ((l = e[e.length - 1]) == null ? void 0 : l.length) ?? 0 };
95
38
  }
96
- function T(s) {
97
- s && s.parentNode && s.parentNode.removeChild(s);
98
- }
99
- function B(s) {
100
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
101
- }
102
- function K(s, e) {
103
- const n = s, t = n.key.toLowerCase(), i = e.split("+"), o = i.slice(0, -1), a = i[i.length - 1];
104
- return !(t !== a || o.includes("shift") !== n.shiftKey || o.includes("ctrl") !== n.ctrlKey || o.includes("alt") !== n.altKey || o.includes("meta") !== n.metaKey);
105
- }
106
- function M(s, e) {
107
- var i;
108
- const t = s.slice(0, e).split(`
109
- `);
110
- return { line: t.length - 1, col: ((i = t[t.length - 1]) == null ? void 0 : i.length) ?? 0 };
111
- }
112
- function O(s, e, n) {
113
- var i;
114
- let t = 0;
115
- for (let o = 0; o < e; o++) t += (((i = s[o]) == null ? void 0 : i.length) ?? 0) + 1;
116
- return t + n;
39
+ function O(i, o, s) {
40
+ var l;
41
+ let e = 0;
42
+ for (let r = 0; r < o; r++) e += (((l = i[r]) == null ? void 0 : l.length) ?? 0) + 1;
43
+ return e + s;
117
44
  }
118
- function Y() {
119
- return (s, e) => {
120
- var f;
121
- if (e.type !== "keydown" || !K(e, "enter")) return;
122
- const { value: n, selectionStart: t, selectionEnd: i } = s, o = n.slice(0, t).split(`
123
- `).pop() ?? "", a = ((f = /^\s*/.exec(o)) == null ? void 0 : f[0]) ?? "";
124
- e.preventDefault();
125
- const c = /^(\s*)-(?=\s|$)/.test(o), l = `
126
- ${a}${c ? "- " : ""}`;
45
+ function Le() {
46
+ return (i, o) => {
47
+ var w;
48
+ if (o.type !== "keydown" || !Z(o, "enter")) return;
49
+ const { value: s, selectionStart: e, selectionEnd: l } = i, r = s.slice(0, e).split(`
50
+ `).pop() ?? "", u = ((w = /^\s*/.exec(r)) == null ? void 0 : w[0]) ?? "";
51
+ o.preventDefault();
52
+ const p = /^(\s*)-(?=[ ]|$)/.test(r), b = `
53
+ ${u}${p ? "- " : ""}`;
127
54
  return {
128
- value: n.slice(0, t) + l + n.slice(i),
129
- selectionStart: t + l.length,
130
- selectionEnd: t + l.length
55
+ value: s.slice(0, e) + b + s.slice(l),
56
+ selectionStart: e + b.length,
57
+ selectionEnd: e + b.length
131
58
  };
132
59
  };
133
60
  }
134
- function Z(s) {
135
- return /^(\s*)-(?=\s|$)/.test(s);
61
+ function Pe(i) {
62
+ return /^(\s*)-(?=[ ]|$)/.test(i);
136
63
  }
137
- function F(s, e) {
138
- return s.startsWith(e) ? e.length : s.startsWith(" ") ? 1 : 0;
64
+ function xe(i, o) {
65
+ return i.startsWith(o) ? o.length : i.startsWith(" ") ? 1 : 0;
139
66
  }
140
- function U(s) {
141
- return (e, n) => {
142
- if (n.type !== "keydown") return;
143
- const { value: t, selectionStart: i, selectionEnd: o } = e, a = t.split(`
144
- `), c = t.slice(0, i).split(`
145
- `).length - 1, l = t.slice(0, o).split(`
146
- `).length - 1, f = M(t, i), h = M(t, o);
147
- if (K(n, "shift+tab")) {
148
- n.preventDefault();
149
- const y = a.map(
150
- (g, S) => S >= c && S <= l ? g.slice(F(g, s)) : g
151
- ), b = y.join(`
67
+ function Ee(i) {
68
+ return (o, s) => {
69
+ if (s.type !== "keydown") return;
70
+ const { value: e, selectionStart: l, selectionEnd: r } = o, u = e.split(`
71
+ `), p = e.slice(0, l).split(`
72
+ `).length - 1, b = e.slice(0, r).split(`
73
+ `).length - 1, w = ye(e, l), v = ye(e, r);
74
+ if (Z(s, "shift+tab")) {
75
+ s.preventDefault();
76
+ const E = u.map(
77
+ (d, h) => h >= p && h <= b ? d.slice(xe(d, i)) : d
78
+ ), S = E.join(`
152
79
  `);
153
- if (b === t) return;
154
- const E = (g) => {
155
- const S = F(a[g.line] ?? "", s);
156
- return { line: g.line, col: Math.max(0, g.col - S) };
157
- }, u = E(f), p = E(h);
80
+ if (S === e) return;
81
+ const $ = (d) => {
82
+ const h = xe(u[d.line] ?? "", i);
83
+ return { line: d.line, col: Math.max(0, d.col - h) };
84
+ }, y = $(w), L = $(v);
158
85
  return {
159
- value: b,
160
- selectionStart: O(y, u.line, u.col),
161
- selectionEnd: O(y, p.line, p.col)
86
+ value: S,
87
+ selectionStart: O(E, y.line, y.col),
88
+ selectionEnd: O(E, L.line, L.col)
162
89
  };
163
90
  }
164
- if (K(n, "tab")) {
165
- n.preventDefault();
166
- const y = a.map((u, p) => ({ l: u, i: p })).filter(({ i: u }) => u >= c && u <= l);
167
- if (y.length > 0 && y.every(({ l: u }) => Z(u)) || i !== o) {
168
- const u = a.map(
169
- (x, $) => $ >= c && $ <= l && x !== "" ? s + x : x
170
- ), p = u.join(`
171
- `), g = (x) => {
172
- const $ = a[x.line] ?? "", j = x.line >= c && x.line <= l;
91
+ if (Z(s, "tab")) {
92
+ s.preventDefault();
93
+ const E = u.map((y, L) => ({ l: y, i: L })).filter(({ i: y }) => y >= p && y <= b);
94
+ if (E.length > 0 && E.every(({ l: y }) => Pe(y)) || l !== r) {
95
+ const y = u.map(
96
+ (x, g) => g >= p && g <= b && x !== "" ? i + x : x
97
+ ), L = y.join(`
98
+ `), d = (x) => {
99
+ const g = u[x.line] ?? "", Q = x.line >= p && x.line <= b;
173
100
  return {
174
101
  line: x.line,
175
- col: j && $ !== "" ? x.col + s.length : x.col
102
+ col: Q && g !== "" ? x.col + i.length : x.col
176
103
  };
177
- }, S = g(f), k = g(h);
104
+ }, h = d(w), n = d(v);
178
105
  return {
179
- value: p,
180
- selectionStart: O(u, S.line, S.col),
181
- selectionEnd: O(u, k.line, k.col)
106
+ value: L,
107
+ selectionStart: O(y, h.line, h.col),
108
+ selectionEnd: O(y, n.line, n.col)
182
109
  };
183
110
  }
184
- const E = i + s.length;
111
+ const $ = l + i.length;
185
112
  return {
186
- value: t.slice(0, i) + s + t.slice(o),
187
- selectionStart: E,
188
- selectionEnd: E
113
+ value: e.slice(0, l) + i + e.slice(r),
114
+ selectionStart: $,
115
+ selectionEnd: $
189
116
  };
190
117
  }
191
118
  };
192
119
  }
193
- function ee(s) {
194
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
120
+ function ze(i) {
121
+ return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
195
122
  }
196
- function te(s, e) {
197
- const n = Math.min(s.length, e.length);
198
- let t = 0;
199
- for (; t < n && s.charCodeAt(t) === e.charCodeAt(t); ) t++;
200
- return t;
123
+ function F(i) {
124
+ return i.replace(/\r\n?/g, `
125
+ `);
201
126
  }
202
- function ne(s, e, n) {
203
- let t = e.language ?? "pd";
204
- const i = e.onValueChange;
205
- let o = !1;
206
- const a = e.indentUnit ?? " ", c = new X(s, {
207
- value: e.value ?? "",
208
- lineNumbers: e.lineNumbers ?? !1,
209
- styles: e.styles ?? {},
210
- highlighters: [
211
- e.highlight ? (r) => {
212
- var d;
213
- return ((d = e.highlight) == null ? void 0 : d.call(e, r, t)) ?? "";
214
- } : n(t)
215
- ],
216
- // 编辑行为:pd 语义插件(续行补 `- `/保留缩进、序列项行 Tab 整行缩进/缩出)。
217
- // 撤销/重做不在此接入 Yace history 插件(初始快照缺陷),由组件自实现(见下)。
218
- plugins: [Y(), U(a)]
219
- });
220
- c.onUpdate((r) => {
221
- o || (x(r), i == null || i(r));
127
+ function Be(i, o) {
128
+ const s = document.createRange();
129
+ s.selectNodeContents(i), i.replaceChildren(s.createContextualFragment(o));
130
+ }
131
+ function He(i, o) {
132
+ const s = Math.min(i.length, o.length);
133
+ let e = 0;
134
+ for (; e < s && i.charCodeAt(e) === o.charCodeAt(e); ) e++;
135
+ return e;
136
+ }
137
+ const Ke = /* @__PURE__ */ new Set([
138
+ "padding",
139
+ "paddingTop",
140
+ "paddingRight",
141
+ "paddingBottom",
142
+ "paddingLeft"
143
+ ]);
144
+ function Se(i) {
145
+ var e;
146
+ const o = {
147
+ top: "0px",
148
+ right: "0px",
149
+ bottom: "0px",
150
+ left: "0px"
151
+ }, s = (e = i.padding) == null ? void 0 : e.trim();
152
+ if (s) {
153
+ const l = s.split(/\s+/);
154
+ if (l.length === 1) {
155
+ const r = l[0] ?? "0px";
156
+ o.top = o.right = o.bottom = o.left = r;
157
+ } else l.length === 2 ? (o.top = o.bottom = l[0] ?? "0px", o.right = o.left = l[1] ?? "0px") : l.length === 3 ? (o.top = l[0] ?? "0px", o.right = o.left = l[1] ?? "0px", o.bottom = l[2] ?? "0px") : (o.top = l[0] ?? "0px", o.right = l[1] ?? "0px", o.bottom = l[2] ?? "0px", o.left = l[3] ?? "0px");
158
+ }
159
+ return i.paddingTop && (o.top = i.paddingTop), i.paddingRight && (o.right = i.paddingRight), i.paddingBottom && (o.bottom = i.paddingBottom), i.paddingLeft && (o.left = i.paddingLeft), o;
160
+ }
161
+ function Ie(i) {
162
+ return i.startsWith("--") ? i : i.replace(/[A-Z]/g, (o) => `-${o.toLowerCase()}`);
163
+ }
164
+ const $e = "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;", ke = "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;", Ce = "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;", Oe = "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;", we = "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;";
165
+ function V(i, o, s, e, l = {}) {
166
+ const r = document.createElement(i);
167
+ r.className = o, r.setAttribute("part", s), r.style.cssText = e;
168
+ for (const [u, p] of Object.entries(l)) r.setAttribute(u, p);
169
+ return r;
170
+ }
171
+ function Ve(i, o, s) {
172
+ let e = { ...o }, l = e.language ?? "pd", r = F(e.value ?? ""), u = r, p = !1, b = !1, w = !1, v = e.lineNumbers ?? !1, E = q(), S = "", $ = !1, y = 0, L = null;
173
+ const d = V("div", "pd-root", "root", $e), h = V("pre", "pd-highlight", "highlight", Ce, {
174
+ "aria-hidden": "true"
175
+ }), n = V("textarea", "pd-input", "input", ke), x = V("div", "pd-placeholder", "placeholder", we, {
176
+ "aria-hidden": "true"
222
177
  });
223
- const l = c.textarea;
224
- let f = !1;
225
- const h = () => {
226
- f = !0;
227
- }, y = () => {
228
- f = !1;
229
- }, b = () => {
230
- f && (o = !0, c.update({
231
- value: l.value,
232
- selectionStart: l.selectionStart,
233
- selectionEnd: l.selectionEnd
234
- }), o = !1);
235
- };
236
- l.addEventListener("compositionstart", h), l.addEventListener("compositionend", y), l.addEventListener("input", b);
237
- const E = 5, u = [
238
- { value: c.value, selStart: -1, selEnd: -1 }
239
- ], p = [], g = () => {
240
- u.length > E + 1 && u.splice(1, 1);
241
- }, k = _((r) => {
242
- const d = u[0];
243
- if (d !== void 0 && d.selStart < 0 && d.value !== r.value) {
244
- const I = te(d.value, r.value);
245
- d.selStart = I, d.selEnd = I;
178
+ let g = null;
179
+ n.spellcheck = e.spellcheck ?? !1, n.setAttribute("autocapitalize", "off"), n.setAttribute("autocorrect", "off"), n.setAttribute("autocomplete", "off"), n.setAttribute("wrap", "soft"), n.value = r, n.readOnly = e.readOnly ?? !1, n.disabled = e.disabled ?? !1, ((t) => {
180
+ t !== void 0 && t >= 0 ? n.maxLength = t : n.removeAttribute("maxlength");
181
+ })(e.maxLength), e.dir && (n.dir = e.dir), K(), d.appendChild(h), d.appendChild(x), d.appendChild(n), i.appendChild(d), H(), G(), T(), _();
182
+ function M() {
183
+ p || (h.scrollTop = n.scrollTop, h.scrollLeft = n.scrollLeft, g && (g.scrollTop = n.scrollTop, g.scrollLeft = n.scrollLeft));
184
+ }
185
+ function Re() {
186
+ if (typeof getComputedStyle != "function") return 0;
187
+ const t = getComputedStyle(i), a = Number.parseFloat(t.paddingTop) || 0, c = Number.parseFloat(t.paddingBottom) || 0;
188
+ return Math.max(0, i.clientHeight - a - c);
189
+ }
190
+ function j() {
191
+ $ ? (h.style.position = "absolute", h.style.left = "0", h.style.top = "0", h.style.height = "100%") : (h.style.position = "relative", h.style.left = "auto", h.style.top = "auto", h.style.height = "auto");
192
+ }
193
+ function _() {
194
+ if (p) return;
195
+ const t = Re(), a = h.scrollHeight;
196
+ if (!$) {
197
+ t > 0 && a > t + 1 && ($ = !0, j(), d.style.height = `${t}px`, M());
198
+ return;
246
199
  }
247
- const v = u.at(-1);
248
- v !== void 0 && v.value === r.value || (p.length = 0, u.push(r), g());
249
- }, 1e3), x = (r) => {
250
- const d = l.selectionStart, v = l.selectionEnd;
251
- k({ value: r, selStart: d, selEnd: v });
252
- }, $ = (r) => {
253
- const d = r.selStart >= 0 ? r.selStart : r.value.length, v = r.selEnd >= 0 ? r.selEnd : r.value.length;
254
- o = !0, c.update({
255
- value: r.value,
256
- selectionStart: d,
257
- selectionEnd: v
258
- }), l.value === r.value && l.setSelectionRange(d, v), o = !1;
259
- }, j = (r) => {
260
- const d = r.ctrlKey || r.metaKey, v = r.key.toLowerCase();
261
- if (!d || v !== "z" && v !== "y") return;
262
- if (v === "y" || v === "z" && r.shiftKey) {
263
- if (k.flush(), p.length === 0) return;
264
- r.preventDefault();
265
- const C = p.pop();
266
- C !== void 0 && (u.push(C), g(), $(C));
267
- } else {
268
- if (k.flush(), u.length <= 1) return;
269
- r.preventDefault();
270
- const C = u.pop();
271
- C !== void 0 && p.push(C);
272
- const P = u.at(-1);
273
- P !== void 0 && $(P);
200
+ if (t <= 0 || a <= t + 1) {
201
+ $ = !1, j(), d.style.height = "", n.scrollTop = 0;
202
+ return;
274
203
  }
275
- };
276
- return l.addEventListener("keydown", j), {
277
- setValue(r) {
278
- o = !0, c.update({ value: r }), o = !1;
204
+ const c = Number.parseFloat(d.style.height) || 0;
205
+ Math.abs(c - t) > 0.5 && (d.style.height = `${t}px`), M();
206
+ }
207
+ function U() {
208
+ if (!y) {
209
+ if (typeof requestAnimationFrame != "function") {
210
+ _();
211
+ return;
212
+ }
213
+ y = requestAnimationFrame(() => {
214
+ y = 0, _();
215
+ });
216
+ }
217
+ }
218
+ typeof ResizeObserver < "u" && (L = new ResizeObserver(() => U()), L.observe(i), L.observe(d));
219
+ const ee = () => M(), Me = (t, a, c) => {
220
+ var f;
221
+ r = t, u = t, W({ value: t, selStart: a, selEnd: c }), (f = e.onValueChange) == null || f.call(e, t);
222
+ }, te = (t) => {
223
+ if (p) return;
224
+ const a = F(n.value);
225
+ if (b || t != null && t.isComposing) {
226
+ r = a, T();
227
+ return;
228
+ }
229
+ a !== r && (r = a, T()), a !== u && Me(a, n.selectionStart, n.selectionEnd);
230
+ }, ne = () => {
231
+ b = !0;
232
+ }, ie = () => {
233
+ b = !1;
234
+ const t = F(n.value);
235
+ t !== r && (r = t, T());
236
+ }, Ne = Math.max(0, e.historyLimit ?? 5), re = Math.max(0, e.historyDebounce ?? 1e3), C = [
237
+ { value: r, selStart: -1, selEnd: -1 }
238
+ ], D = [], oe = () => {
239
+ C.length > Ne + 1 && C.splice(1, 1);
240
+ }, le = (t) => {
241
+ const a = C[0];
242
+ if (a !== void 0 && a.selStart < 0 && a.value !== t.value) {
243
+ const f = He(a.value, t.value);
244
+ a.selStart = f, a.selEnd = f;
245
+ }
246
+ const c = C.at(-1);
247
+ c !== void 0 && c.value === t.value || (D.length = 0, C.push(t), oe());
248
+ }, P = Fe(le, re), W = (t) => {
249
+ re === 0 ? le(t) : P(t);
250
+ }, se = (t) => {
251
+ var f;
252
+ const a = t.selStart >= 0 ? t.selStart : Math.min(t.value.length, n.selectionStart), c = t.selEnd >= 0 ? t.selEnd : a;
253
+ r = t.value, u = t.value, n.value = t.value, n.setSelectionRange(
254
+ Math.max(0, Math.min(a, t.value.length)),
255
+ Math.max(0, Math.min(c, t.value.length))
256
+ ), T(), M(), (f = e.onValueChange) == null || f.call(e, t.value);
257
+ }, ae = () => {
258
+ if (P.flush(), C.length <= 1) return !1;
259
+ const t = C.pop();
260
+ t !== void 0 && D.push(t);
261
+ const a = C.at(-1);
262
+ return a !== void 0 && se(a), !0;
263
+ }, ce = () => {
264
+ if (P.flush(), D.length === 0) return !1;
265
+ const t = D.pop();
266
+ return t === void 0 ? !1 : (C.push(t), oe(), se(t), !0);
267
+ }, ue = (t) => {
268
+ var A;
269
+ if (p || t.isComposing || b || n.readOnly || n.disabled) return;
270
+ const a = t.ctrlKey || t.metaKey, c = t.key.toLowerCase();
271
+ if (a && (c === "z" || c === "y")) {
272
+ t.preventDefault(), c === "y" || c === "z" && t.shiftKey ? ce() : ae();
273
+ return;
274
+ }
275
+ if (c === "escape") {
276
+ (e.tabBehavior ?? "indent") === "indent" && (w = !0);
277
+ return;
278
+ }
279
+ if (c === "tab" && (e.tabBehavior ?? "indent") === "focus") return;
280
+ if (c === "tab" && w) {
281
+ w = !1;
282
+ return;
283
+ }
284
+ const f = {
285
+ value: r,
286
+ selectionStart: n.selectionStart,
287
+ selectionEnd: n.selectionEnd
288
+ };
289
+ let m = f;
290
+ for (const N of X) {
291
+ const z = N(m, t);
292
+ z && (m = { ...m, ...z });
293
+ }
294
+ (m.value !== f.value || m.selectionStart !== f.selectionStart || m.selectionEnd !== f.selectionEnd) && (t.preventDefault(), r = m.value, n.value = m.value, n.setSelectionRange(m.selectionStart, m.selectionEnd), u = m.value, T(), W({
295
+ value: m.value,
296
+ selStart: m.selectionStart,
297
+ selEnd: m.selectionEnd
298
+ }), (A = e.onValueChange) == null || A.call(e, m.value), M());
299
+ }, de = () => d.classList.add("pd-focused"), fe = () => d.classList.remove("pd-focused");
300
+ n.addEventListener("input", te), n.addEventListener("compositionstart", ne), n.addEventListener("compositionend", ie), n.addEventListener("scroll", ee, { passive: !0 }), n.addEventListener("keydown", ue), n.addEventListener("focus", de), n.addEventListener("blur", fe);
301
+ function q() {
302
+ return e.highlight ? (t) => {
303
+ var a;
304
+ return ((a = e.highlight) == null ? void 0 : a.call(e, t, l)) ?? "";
305
+ } : s(l);
306
+ }
307
+ function T() {
308
+ if (p) return;
309
+ const t = e.highlightThreshold ?? 1e5, a = r.length > t ? ze(r) : E(r);
310
+ Be(h, `${a}<br/>`), v && pe(), G(), L || U();
311
+ }
312
+ function pe() {
313
+ if (!v) return;
314
+ g || (g = document.createElement("pre"), g.className = "pd-lines", g.setAttribute("part", "gutter"), g.setAttribute("aria-hidden", "true"), d.insertBefore(g, x));
315
+ const t = r.split(`
316
+ `), c = `${String(t.length).length + 1}ch`, f = Se(e.styles ?? {}), m = `position:absolute;inset-inline-start:${f.left};width:${c};text-align:end;opacity:var(--pd-gutter-opacity,0.35);color:var(--pd-gutter-color,inherit)`, A = document.createDocumentFragment();
317
+ t.forEach((N, z) => {
318
+ const I = document.createElement("span");
319
+ I.className = "pd-ln", I.style.cssText = m, I.textContent = String(z + 1);
320
+ const Y = document.createElement("span");
321
+ Y.style.color = "transparent", Y.textContent = N, A.append(I, Y), z < t.length - 1 && A.append(document.createTextNode(`
322
+ `));
323
+ }), A.append(document.createElement("br")), g.replaceChildren(A), c !== S && (S = c, H(), g.style.cssText = ge(f));
324
+ }
325
+ function G() {
326
+ const t = e.placeholder ?? "";
327
+ x.textContent = t, x.style.display = t && r.length === 0 ? "block" : "none", t ? n.setAttribute("aria-placeholder", t) : n.removeAttribute("aria-placeholder");
328
+ }
329
+ function he(t) {
330
+ const a = S ? `calc(${t.left} + ${S})` : t.left;
331
+ return `padding:${t.top} ${t.right} ${t.bottom} ${a};`;
332
+ }
333
+ function J(t, a) {
334
+ return a + he(t);
335
+ }
336
+ function ge(t) {
337
+ return Oe + he(t);
338
+ }
339
+ function H() {
340
+ const t = e.styles ?? {}, a = Se(t), c = Object.entries(t).filter(([f]) => !Ke.has(f)).map(([f, m]) => `${Ie(f)}:${m};`).join("");
341
+ d.style.cssText = $e + c, h.style.cssText = J(a, Ce), n.style.cssText = J(a, ke), x.style.cssText = J(a, we), g && (g.style.cssText = ge(a)), j(), e.dir && (d.dir = e.dir, n.dir = e.dir, h.dir = e.dir, x.dir = e.dir, g && (g.dir = e.dir));
342
+ }
343
+ function K() {
344
+ e.ariaLabel ? n.setAttribute("aria-label", e.ariaLabel) : n.removeAttribute("aria-label"), e.ariaLabelledby ? n.setAttribute("aria-labelledby", e.ariaLabelledby) : n.removeAttribute("aria-labelledby"), e.ariaDescribedby ? n.setAttribute("aria-describedby", e.ariaDescribedby) : n.removeAttribute("aria-describedby"), e.readOnly ? n.setAttribute("aria-readonly", "true") : n.removeAttribute("aria-readonly"), e.disabled ? n.setAttribute("aria-disabled", "true") : n.removeAttribute("aria-disabled");
345
+ }
346
+ v && pe();
347
+ const X = [Le(), Ee(e.indentUnit ?? " ")];
348
+ return {
349
+ setValue(t, a) {
350
+ if (p || b) return;
351
+ let c = F(t);
352
+ e.maxLength !== void 0 && e.maxLength >= 0 && (c = c.slice(0, e.maxLength)), P.cancel(), r = c, u = c, n.value = c, n.setSelectionRange(c.length, c.length), ((a == null ? void 0 : a.resetHistory) ?? !0) && (C.length = 0, C.push({ value: c, selStart: -1, selEnd: -1 }), D.length = 0), T(), M();
279
353
  },
280
354
  getValue() {
281
- return c.value;
355
+ return r;
282
356
  },
283
- setLanguage(r) {
284
- t = r, c.updateOptions({
285
- highlighters: [
286
- e.highlight ? (d) => {
287
- var v;
288
- return ((v = e.highlight) == null ? void 0 : v.call(e, d, t)) ?? "";
289
- } : n(t)
290
- ]
291
- });
357
+ setLanguage(t) {
358
+ l = t, e = { ...e, language: t }, E = q(), T();
359
+ },
360
+ setPlaceholder(t) {
361
+ e = { ...e, placeholder: t }, G();
362
+ },
363
+ setReadOnly(t) {
364
+ e = { ...e, readOnly: t }, n.readOnly = t, K();
365
+ },
366
+ setDisabled(t) {
367
+ e = { ...e, disabled: t }, n.disabled = t, K();
368
+ },
369
+ setLineNumbers(t) {
370
+ v !== t && (v = t, !t && g && (g.remove(), g = null, S = ""), H(), T());
371
+ },
372
+ update(t) {
373
+ p || (e = { ...e, ...t }, t.indentUnit !== void 0 && X.splice(0, X.length, Le(), Ee(t.indentUnit)), t.language !== void 0 && (l = t.language), ("highlight" in t || t.language !== void 0) && (E = q()), t.lineNumbers !== void 0 && (v = t.lineNumbers, !v && g && (g.remove(), g = null, S = "")), t.value !== void 0 && (r = F(t.value), u = r, n.value = r, C.length = 0, C.push({ value: r, selStart: -1, selEnd: -1 }), D.length = 0), t.readOnly !== void 0 && (n.readOnly = t.readOnly), t.disabled !== void 0 && (n.disabled = t.disabled), t.maxLength !== void 0 && (t.maxLength >= 0 ? n.maxLength = t.maxLength : n.removeAttribute("maxlength")), t.spellcheck !== void 0 && (n.spellcheck = t.spellcheck), t.dir !== void 0 && (n.dir = t.dir), K(), H(), T(), M());
374
+ },
375
+ focus() {
376
+ n.focus();
377
+ },
378
+ blur() {
379
+ n.blur();
380
+ },
381
+ undo() {
382
+ ae();
383
+ },
384
+ redo() {
385
+ ce();
386
+ },
387
+ insertText(t) {
388
+ var N;
389
+ if (p || n.readOnly || n.disabled) return;
390
+ const a = n.selectionStart, c = n.selectionEnd;
391
+ let f = F(t);
392
+ if (e.maxLength !== void 0 && e.maxLength >= 0) {
393
+ const z = e.maxLength - (r.length - (c - a));
394
+ if (z <= 0) return;
395
+ f.length > z && (f = f.slice(0, z));
396
+ }
397
+ const m = r.slice(0, a) + f + r.slice(c);
398
+ r = m, u = m, n.value = m;
399
+ const A = a + f.length;
400
+ n.setSelectionRange(A, A), T(), W({ value: m, selStart: A, selEnd: A }), (N = e.onValueChange) == null || N.call(e, m), M();
401
+ },
402
+ getSelection() {
403
+ return { start: n.selectionStart, end: n.selectionEnd };
404
+ },
405
+ setSelection(t, a = t) {
406
+ const c = (f) => Math.max(0, Math.min(r.length, Number.isFinite(f) ? f : 0));
407
+ n.setSelectionRange(c(t), c(a));
292
408
  },
293
409
  destroy() {
294
- k.cancel(), l.removeEventListener("compositionstart", h), l.removeEventListener("compositionend", y), l.removeEventListener("input", b), l.removeEventListener("keydown", j), c.destroy();
410
+ p || (p = !0, P.cancel(), L == null || L.disconnect(), y && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(y), n.removeEventListener("input", te), n.removeEventListener("compositionstart", ne), n.removeEventListener("compositionend", ie), n.removeEventListener("scroll", ee), n.removeEventListener("keydown", ue), n.removeEventListener("focus", de), n.removeEventListener("blur", fe), d.remove());
295
411
  },
296
- textarea: l
412
+ textarea: n,
413
+ root: d,
414
+ pre: h
297
415
  };
298
416
  }
299
- function H(s) {
300
- const e = [];
301
- let n = "", t = !1;
302
- for (const i of s)
303
- i === "`" ? t ? (e.push({ code: !0, seg: n + "`" }), n = "", t = !1) : (n && e.push({ code: !1, seg: n }), n = "`", t = !0) : n += i;
304
- return n && e.push({ code: !1, seg: n }), e;
305
- }
306
- function R(s) {
307
- for (const { code: e, seg: n } of H(s))
308
- if (!e && (n.includes(":-") || n.includes(":-")))
309
- return !0;
310
- return !1;
311
- }
312
- function z(s) {
313
- let e = 0;
314
- for (const { code: n, seg: t } of H(s)) {
315
- if (!n) {
316
- const i = t.indexOf(":");
317
- if (i !== -1) return e + i;
318
- }
319
- e += t.length;
320
- }
321
- return -1;
322
- }
323
- function N(s) {
324
- if (R(s)) return null;
325
- const e = z(s);
326
- if (e <= 0) return null;
327
- const n = s.slice(0, e), t = s.slice(e + 1);
328
- if (/\s$/.test(n) || t !== "" && !/^\s/.test(t)) return null;
329
- const i = t.trim();
330
- return { key: n.trim(), value: i === "" ? void 0 : i };
331
- }
332
- function m(s) {
333
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
417
+ function k(i) {
418
+ return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
334
419
  }
335
- const L = {
420
+ const R = {
336
421
  key: "pd-key",
337
422
  keyPunct: "pd-key-punct",
338
423
  item: "pd-item",
@@ -342,84 +427,83 @@ const L = {
342
427
  inlineCode: "pd-inline-code",
343
428
  fence: "pd-fence"
344
429
  };
345
- function se(s) {
346
- return `<span class="${L.inlineCode}">${m(s)}</span>`;
430
+ function je(i) {
431
+ return `<span class="${R.inlineCode}">${k(i)}</span>`;
347
432
  }
348
- const W = /(?:^|\s):([^\s-][^\s]*)(?=\s|$)/g;
349
- function ie(s) {
350
- let e = "", n = 0;
351
- W.lastIndex = 0;
352
- let t;
353
- for (; (t = W.exec(s)) !== null; ) {
354
- const i = /^\s/.test(t[0]) ? 1 : 0, o = t.index + i;
355
- e += m(s.slice(n, o)), e += `<span class="${L.ref}">${m(s.slice(o, t.index + t[0].length))}</span>`, n = t.index + t[0].length;
433
+ const Ae = /(?:^|\s):([^\s-][^\s]*)(?=\s|$)/g;
434
+ function _e(i) {
435
+ let o = "", s = 0;
436
+ Ae.lastIndex = 0;
437
+ let e;
438
+ for (; (e = Ae.exec(i)) !== null; ) {
439
+ const l = /^\s/.test(e[0]) ? 1 : 0, r = e.index + l;
440
+ o += k(i.slice(s, r)), o += `<span class="${R.ref}">${k(i.slice(r, e.index + e[0].length))}</span>`, s = e.index + e[0].length;
356
441
  }
357
- return e += m(s.slice(n)), e;
442
+ return o += k(i.slice(s)), o;
358
443
  }
359
- function w(s) {
360
- let e = "";
361
- for (const { code: n, seg: t } of H(s))
362
- e += n ? se(t) : ie(t);
363
- return e;
444
+ function B(i) {
445
+ let o = "";
446
+ for (const { code: s, seg: e } of De(i))
447
+ o += s ? je(e) : _e(e);
448
+ return o;
364
449
  }
365
- function V(s, e, n, t) {
366
- const i = `<span class="${L.key}">${w(n)}</span>`, o = `<span class="${L.keyPunct}">:</span>`;
367
- return `${s}${e}${i}${o}${w(t)}`;
450
+ function Te(i, o, s, e) {
451
+ const l = `<span class="${R.key}">${B(s)}</span>`, r = `<span class="${R.keyPunct}">:</span>`;
452
+ return `${i}${o}${l}${r}${B(e)}`;
368
453
  }
369
- function oe(s) {
370
- const e = s.trim();
371
- if (/^\/\/!pd(?:\s+[^\s]+)?$/.test(e)) {
372
- const t = /^(\s*)(\/\/!pd)(\s*.*)$/.exec(s), i = (t == null ? void 0 : t[1]) ?? "", o = (t == null ? void 0 : t[2]) ?? "//!pd", a = (t == null ? void 0 : t[3]) ?? "";
373
- return `${m(i)}<span class="${L.section}">${m(o)}</span>${w(a)}`;
454
+ function We(i) {
455
+ const o = i.trim();
456
+ if (/^\/\/!pd(?:\s+[^\s]+)?$/.test(o)) {
457
+ const e = /^(\s*)(\/\/!pd)(\s*.*)$/.exec(i), l = (e == null ? void 0 : e[1]) ?? "", r = (e == null ? void 0 : e[2]) ?? "//!pd", u = (e == null ? void 0 : e[3]) ?? "";
458
+ return `${k(l)}<span class="${R.section}">${k(r)}</span>${B(u)}`;
374
459
  }
375
- if (e === "---")
376
- return `<span class="${L.sep}">${m(s)}</span>`;
377
- const n = /^(\s*)(-)(?=\s|$)/.exec(s);
378
- if (n) {
379
- const t = m(n[1] ?? ""), i = (n[1] ?? "").length + 1, o = s.slice(i), a = o.trimStart(), c = o.slice(0, o.length - a.length), l = `<span class="${L.item}">-</span>`;
380
- if (!R(a) && N(a)) {
381
- const h = z(a), y = a.slice(0, h), b = a.slice(h + 1);
382
- return `${t}${l}${m(c)}${V("", "", y, b)}`;
460
+ if (o === "---")
461
+ return `<span class="${R.sep}">${k(i)}</span>`;
462
+ const s = /^(\s*)(-)(?=[ ]|$)/.exec(i);
463
+ if (s) {
464
+ const e = k(s[1] ?? ""), l = (s[1] ?? "").length + 1, r = i.slice(l), u = r.trimStart(), p = r.slice(0, r.length - u.length), b = `<span class="${R.item}">-</span>`;
465
+ if (!me(u) && be(u)) {
466
+ const v = ve(u), E = u.slice(0, v), S = u.slice(v + 1);
467
+ return `${e}${b}${k(p)}${Te("", "", E, S)}`;
383
468
  }
384
- return `${t}${l}${m(c)}${w(a)}`;
469
+ return `${e}${b}${k(p)}${B(u)}`;
385
470
  }
386
- if (!R(e) && N(e)) {
387
- const i = s.length - s.trimStart().length, o = s.slice(i), a = z(o), c = o.slice(0, a).trim(), l = o.slice(a + 1);
388
- return V(m(s.slice(0, i)), "", c, l);
471
+ if (!me(o) && be(o)) {
472
+ const l = i.length - i.trimStart().length, r = i.slice(l), u = ve(r), p = r.slice(0, u).trim(), b = r.slice(u + 1);
473
+ return Te(k(i.slice(0, l)), "", p, b);
389
474
  }
390
- return w(s);
475
+ return B(i);
391
476
  }
392
- function le(s) {
393
- const e = s.split(`
477
+ function qe(i) {
478
+ const o = i.split(`
394
479
  `);
395
- let n = !1;
396
- const t = [];
397
- for (const i of e) {
398
- const o = i.trimStart();
399
- if (n) {
400
- o.startsWith("```") ? (n = !1, t.push(`<span class="${L.fence}">${m(i)}</span>`)) : t.push(m(i));
480
+ let s = !1;
481
+ const e = [];
482
+ for (const l of o) {
483
+ const r = l.trimStart();
484
+ if (s) {
485
+ r.startsWith("```") ? (s = !1, e.push(`<span class="${R.fence}">${k(l)}</span>`)) : e.push(k(l));
401
486
  continue;
402
487
  }
403
- if (o.startsWith("```")) {
404
- n = !0, t.push(`<span class="${L.fence}">${m(i)}</span>`);
488
+ if (r.startsWith("```")) {
489
+ s = !0, e.push(`<span class="${R.fence}">${k(l)}</span>`);
405
490
  continue;
406
491
  }
407
- t.push(oe(i));
492
+ e.push(We(l));
408
493
  }
409
- return t.join(`
494
+ return e.join(`
410
495
  `);
411
496
  }
412
- function re(s) {
413
- return (e) => s === "pd" ? le(e) : ee(e);
497
+ function Ge(i) {
498
+ return (o) => i === "pd" ? qe(o) : ze(o);
414
499
  }
415
- function ae(s, e = {}) {
416
- return ne(s, e, re);
500
+ function Xe(i, o = {}) {
501
+ return Ve(i, o, Ge);
417
502
  }
418
503
  export {
419
- ae as createPdEditor,
420
- he as format,
421
- le as highlightPd,
422
- de as jsonToPdText,
423
- pe as pdToJsonText
504
+ Xe as createPdEditor,
505
+ Qe as format,
506
+ qe as highlightPd,
507
+ Ue as jsonToPdText,
508
+ et as pdToJsonText
424
509
  };
425
- //# sourceMappingURL=pd.js.map