vendor: 103,008 bytes, lines 1-3185
1//#region node_modules/orderedmap/dist/index.js 2function e(e) { 3 this.content = e; 4} 5e.prototype = { 6 constructor: e, 7 find: function(e) { 8 for (var t = 0; t < this.content.length; t += 2) if (this.content[t] === e) return t; 9 return -1; 10 }, 11 get: function(e) { 12 var t = this.find(e); 13 return t == -1 ? void 0 : this.content[t + 1]; 14 }, 15 update: function(t, n, r) { 16 var i = r && r != t ? this.remove(r) : this, a = i.find(t), o = i.content.slice(); 17 return a == -1 ? o.push(r || t, n) : (o[a + 1] = n, r && (o[a] = r)), new e(o); 18 }, 19 remove: function(t) { 20 var n = this.find(t); 21 if (n == -1) return this; 22 var r = this.content.slice(); 23 return r.splice(n, 2), new e(r); 24 }, 25 addToStart: function(t, n) { 26 return new e([t, n].concat(this.remove(t).content)); 27 }, 28 addToEnd: function(t, n) { 29 var r = this.remove(t).content.slice(); 30 return r.push(t, n), new e(r); 31 }, 32 addBefore: function(t, n, r) { 33 var i = this.remove(n), a = i.content.slice(), o = i.find(t); 34 return a.splice(o == -1 ? a.length : o, 0, n, r), new e(a); 35 }, 36 forEach: function(e) { 37 for (var t = 0; t < this.content.length; t += 2) e(this.content[t], this.content[t + 1]); 38 }, 39 prepend: function(t) { 40 return t = e.from(t), t.size ? new e(t.content.concat(this.subtract(t).content)) : this; 41 }, 42 append: function(t) { 43 return t = e.from(t), t.size ? new e(this.subtract(t).content.concat(t.content)) : this; 44 }, 45 subtract: function(t) { 46 var n = this; 47 t = e.from(t); 48 for (var r = 0; r < t.content.length; r += 2) n = n.remove(t.content[r]); 49 return n; 50 }, 51 toObject: function() { 52 var e = {}; 53 return this.forEach(function(t, n) { 54 e[t] = n; 55 }), e; 56 }, 57 get size() { 58 return this.content.length >> 1; 59 } 60}, e.from = function(t) { 61 if (t instanceof e) return t; 62 var n = []; 63 if (t) for (var r in t) n.push(r, t[r]); 64 return new e(n); 65}; 66//#endregion 67//#region node_modules/prosemirror-model/dist/index.js 68function t(e, n, a) { 69 for (let o = 0;; o++) { 70 if (o == e.childCount || o == n.childCount) return e.childCount == n.childCount ? null : a; 71 let s = e.child(o), c = n.child(o); 72 if (s == c) { 73 a += s.nodeSize; 74 continue; 75 } 76 if (!s.sameMarkup(c)) return a; 77 if (s.isText && s.text != c.text) { 78 let e = s.text, t = c.text, n = 0; 79 for (; e[n] == t[n]; n++) a++; 80 return n && n < e.length && n < t.length && i(e.charCodeAt(n - 1)) && r(e.charCodeAt(n)) && a--, a; 81 } 82 if (s.content.size || c.content.size) { 83 let e = t(s.content, c.content, a + 1); 84 if (e != null) return e; 85 } 86 a += s.nodeSize; 87 } 88} 89function n(e, t, a, o) { 90 for (let s = e.childCount, c = t.childCount;;) { 91 if (s == 0 || c == 0) return s == c ? null : { 92 a, 93 b: o 94 }; 95 let l = e.child(--s), u = t.child(--c), d = l.nodeSize; 96 if (l == u) { 97 a -= d, o -= d; 98 continue; 99 } 100 if (!l.sameMarkup(u)) return { 101 a, 102 b: o 103 }; 104 if (l.isText && l.text != u.text) { 105 let e = l.text, t = u.text, n = e.length, s = t.length; 106 for (; n > 0 && s > 0 && e[n - 1] == t[s - 1];) n--, s--, a--, o--; 107 return n && s && n < e.length && i(e.charCodeAt(n - 1)) && r(e.charCodeAt(n)) && (a++, o++), { 108 a, 109 b: o 110 }; 111 } 112 if (l.content.size || u.content.size) { 113 let e = n(l.content, u.content, a - 1, o - 1); 114 if (e) return e; 115 } 116 a -= d, o -= d; 117 } 118} 119function r(e) { 120 return e >= 56320 && e < 57344; 121} 122function i(e) { 123 return e >= 55296 && e < 56320; 124} 125var a = class e { 126 constructor(e, t) { 127 if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize; 128 } 129 nodesBetween(e, t, n, r = 0, i) { 130 for (let a = 0, o = 0; o < t; a++) { 131 let s = this.content[a], c = o + s.nodeSize; 132 if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) { 133 let i = o + 1; 134 s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i); 135 } 136 o = c; 137 } 138 } 139 descendants(e) { 140 this.nodesBetween(0, this.size, e); 141 } 142 textBetween(e, t, n, r) { 143 let i = "", a = !0; 144 return this.nodesBetween(e, t, (o, s) => { 145 let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : ""; 146 o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c; 147 }, 0), i; 148 } 149 append(t) { 150 if (!t.size) return this; 151 if (!this.size) return t; 152 let n = this.lastChild, r = t.firstChild, i = this.content.slice(), a = 0; 153 for (n.isText && n.sameMarkup(r) && (i[i.length - 1] = n.withText(n.text + r.text), a = 1); a < t.content.length; a++) i.push(t.content[a]); 154 return new e(i, this.size + t.size); 155 } 156 cut(t, n = this.size) { 157 if (t == 0 && n == this.size) return this; 158 let r = [], i = 0; 159 if (n > t) for (let e = 0, a = 0; a < n; e++) { 160 let o = this.content[e], s = a + o.nodeSize; 161 s > t && ((a < t || s > n) && (o = o.isText ? o.cut(Math.max(0, t - a), Math.min(o.text.length, n - a)) : o.cut(Math.max(0, t - a - 1), Math.min(o.content.size, n - a - 1))), r.push(o), i += o.nodeSize), a = s; 162 } 163 return new e(r, i); 164 } 165 cutByIndex(t, n) { 166 return t == n ? e.empty : t == 0 && n == this.content.length ? this : new e(this.content.slice(t, n)); 167 } 168 replaceChild(t, n) { 169 let r = this.content[t]; 170 if (r == n) return this; 171 let i = this.content.slice(), a = this.size + n.nodeSize - r.nodeSize; 172 return i[t] = n, new e(i, a); 173 } 174 addToStart(t) { 175 return new e([t].concat(this.content), this.size + t.nodeSize); 176 } 177 addToEnd(t) { 178 return new e(this.content.concat(t), this.size + t.nodeSize); 179 } 180 eq(e) { 181 if (this.content.length != e.content.length) return !1; 182 for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1; 183 return !0; 184 } 185 get firstChild() { 186 return this.content.length ? this.content[0] : null; 187 } 188 get lastChild() { 189 return this.content.length ? this.content[this.content.length - 1] : null; 190 } 191 get childCount() { 192 return this.content.length; 193 } 194 child(e) { 195 let t = this.content[e]; 196 if (!t) throw RangeError("Index " + e + " out of range for " + this); 197 return t; 198 } 199 maybeChild(e) { 200 return this.content[e] || null; 201 } 202 forEach(e) { 203 for (let t = 0, n = 0; t < this.content.length; t++) { 204 let r = this.content[t]; 205 e(r, n, t), n += r.nodeSize; 206 } 207 } 208 findDiffStart(e, n = 0) { 209 return t(this, e, n); 210 } 211 findDiffEnd(e, t = this.size, r = e.size) { 212 return n(this, e, t, r); 213 } 214 findIndex(e) { 215 if (e == 0) return s(0, e); 216 if (e == this.size) return s(this.content.length, e); 217 if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`); 218 for (let t = 0, n = 0;; t++) { 219 let r = this.child(t), i = n + r.nodeSize; 220 if (i >= e) return i == e ? s(t + 1, i) : s(t, n); 221 n = i; 222 } 223 } 224 toString() { 225 return "<" + this.toStringInner() + ">"; 226 } 227 toStringInner() { 228 return this.content.join(", "); 229 } 230 toJSON() { 231 return this.content.length ? this.content.map((e) => e.toJSON()) : null; 232 } 233 static fromJSON(t, n) { 234 if (!n) return e.empty; 235 if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON"); 236 return e.fromArray(n.map(t.nodeFromJSON)); 237 } 238 static fromArray(t) { 239 if (!t.length) return e.empty; 240 let n, r = 0; 241 for (let e = 0; e < t.length; e++) { 242 let i = t[e]; 243 r += i.nodeSize, e && i.isText && t[e - 1].sameMarkup(i) ? (n ||= t.slice(0, e), n[n.length - 1] = i.withText(n[n.length - 1].text + i.text)) : n && n.push(i); 244 } 245 return new e(n || t, r); 246 } 247 static from(t) { 248 if (!t) return e.empty; 249 if (t instanceof e) return t; 250 if (Array.isArray(t)) return this.fromArray(t); 251 if (t.attrs) return new e([t], t.nodeSize); 252 throw RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : "")); 253 } 254}; 255a.empty = new a([], 0); 256var o = { 257 index: 0, 258 offset: 0 259}; 260function s(e, t) { 261 return o.index = e, o.offset = t, o; 262} 263function c(e, t) { 264 if (e === t) return !0; 265 if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1; 266 let n = Array.isArray(e); 267 if (Array.isArray(t) != n) return !1; 268 if (n) { 269 if (e.length != t.length) return !1; 270 for (let n = 0; n < e.length; n++) if (!c(e[n], t[n])) return !1; 271 } else { 272 for (let n in e) if (!(n in t) || !c(e[n], t[n])) return !1; 273 for (let n in t) if (!(n in e)) return !1; 274 } 275 return !0; 276} 277var l = class e { 278 constructor(e, t) { 279 this.type = e, this.attrs = t; 280 } 281 addToSet(e) { 282 let t, n = !1; 283 for (let r = 0; r < e.length; r++) { 284 let i = e[r]; 285 if (this.eq(i)) return e; 286 if (this.type.excludes(i.type)) t ||= e.slice(0, r); 287 else if (i.type.excludes(this.type)) return e; 288 else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i); 289 } 290 return t ||= e.slice(), n || t.push(this), t; 291 } 292 removeFromSet(e) { 293 for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1)); 294 return e; 295 } 296 isInSet(e) { 297 for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0; 298 return !1; 299 } 300 eq(e) { 301 return this == e || this.type == e.type && c(this.attrs, e.attrs); 302 } 303 toJSON() { 304 let e = { type: this.type.name }; 305 for (let t in this.attrs) { 306 e.attrs = this.attrs; 307 break; 308 } 309 return e; 310 } 311 static fromJSON(e, t) { 312 if (!t) throw RangeError("Invalid input for Mark.fromJSON"); 313 let n = e.marks[t.type]; 314 if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`); 315 let r = n.create(t.attrs); 316 return n.checkAttrs(r.attrs), r; 317 } 318 static sameSet(e, t) { 319 if (e == t) return !0; 320 if (e.length != t.length) return !1; 321 for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1; 322 return !0; 323 } 324 static setFrom(t) { 325 if (!t || Array.isArray(t) && t.length == 0) return e.none; 326 if (t instanceof e) return [t]; 327 let n = t.slice(); 328 return n.sort((e, t) => e.type.rank - t.type.rank), n; 329 } 330}; 331l.none = []; 332var u = class extends Error {}, d = class e { 333 constructor(e, t, n) { 334 this.content = e, this.openStart = t, this.openEnd = n; 335 } 336 get size() { 337 return this.content.size - this.openStart - this.openEnd; 338 } 339 insertAt(t, n) { 340 let r = p(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1); 341 return r && new e(r, this.openStart, this.openEnd); 342 } 343 removeBetween(t, n) { 344 return new e(f(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd); 345 } 346 eq(e) { 347 return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd; 348 } 349 toString() { 350 return this.content + "(" + this.openStart + "," + this.openEnd + ")"; 351 } 352 toJSON() { 353 if (!this.content.size) return null; 354 let e = { content: this.content.toJSON() }; 355 return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e; 356 } 357 static fromJSON(t, n) { 358 if (!n) return e.empty; 359 let r = n.openStart || 0, i = n.openEnd || 0; 360 if (typeof r != "number" || typeof i != "number") throw RangeError("Invalid input for Slice.fromJSON"); 361 return new e(a.fromJSON(t, n.content), r, i); 362 } 363 static maxOpen(t, n = !0) { 364 let r = 0, i = 0; 365 for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++; 366 for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++; 367 return new e(t, r, i); 368 } 369}; 370d.empty = new d(a.empty, 0, 0); 371function f(e, t, n) { 372 let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n); 373 if (i == t || a.isText) { 374 if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range"); 375 return e.cut(0, t).append(e.cut(n)); 376 } 377 if (r != o) throw RangeError("Removing non-flat range"); 378 return e.replaceChild(r, a.copy(f(a.content, t - i - 1, n - i - 1))); 379} 380function p(e, t, n, r, i, a) { 381 let { index: o, offset: s } = e.findIndex(t), c = e.maybeChild(o); 382 if (s == t || c.isText) return a && r <= 0 && i <= 0 && !a.canReplace(o, o, n) ? null : e.cut(0, t).append(n).append(e.cut(t)); 383 let l = p(c.content, t - s - 1, n, o == 0 ? r - 1 : 0, o == e.childCount - 1 ? i - 1 : 0, c); 384 return l && e.replaceChild(o, c.copy(l)); 385} 386function m(e, t, n) { 387 if (n.openStart > e.depth) throw new u("Inserted content deeper than insertion position"); 388 if (e.depth - n.openStart != t.depth - n.openEnd) throw new u("Inconsistent open depths"); 389 return h(e, t, n, 0); 390} 391function h(e, t, n, r) { 392 let i = e.index(r), a = e.node(r); 393 if (i == t.index(r) && r < e.depth - n.openStart) { 394 let o = h(e, t, n, r + 1); 395 return a.copy(a.content.replaceChild(i, o)); 396 } else if (!n.content.size) return y(a, te(e, t, r)); 397 else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) { 398 let r = e.parent, i = r.content; 399 return y(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset))); 400 } else { 401 let { start: i, end: o } = ne(n, e); 402 return y(a, b(e, i, o, t, r)); 403 } 404} 405function g(e, t) { 406 if (!t.type.compatibleContent(e.type)) throw new u("Cannot join " + t.type.name + " onto " + e.type.name); 407} 408function _(e, t, n) { 409 let r = e.node(n); 410 return g(r, t.node(n)), r; 411} 412function ee(e, t) { 413 let n = t.length - 1; 414 n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e); 415} 416function v(e, t, n, r) { 417 let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount; 418 e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (ee(e.nodeAfter, r), a++)); 419 for (let e = a; e < o; e++) ee(i.child(e), r); 420 t && t.depth == n && t.textOffset && ee(t.nodeBefore, r); 421} 422function y(e, t) { 423 if (!e.type.validContent(t)) throw new u("Invalid content for node " + e.type.name); 424 return e.copy(t); 425} 426function b(e, t, n, r, i) { 427 let o = e.depth > i && _(e, t, i + 1), s = r.depth > i && _(n, r, i + 1), c = []; 428 return v(null, e, i, c), o && s && t.index(i) == n.index(i) ? (g(o, s), ee(y(o, b(e, t, n, r, i + 1)), c)) : (o && ee(y(o, te(e, t, i + 1)), c), v(t, n, i, c), s && ee(y(s, te(n, r, i + 1)), c)), v(r, null, i, c), new a(c); 429} 430function te(e, t, n) { 431 let r = []; 432 return v(null, e, n, r), e.depth > n && ee(y(_(e, t, n + 1), te(e, t, n + 1)), r), v(t, null, n, r), new a(r); 433} 434function ne(e, t) { 435 let n = t.depth - e.openStart, r = t.node(n).copy(e.content); 436 for (let e = n - 1; e >= 0; e--) r = t.node(e).copy(a.from(r)); 437 return { 438 start: r.resolveNoCache(e.openStart + n), 439 end: r.resolveNoCache(r.content.size - e.openEnd - n) 440 }; 441} 442var re = class e { 443 constructor(e, t, n) { 444 this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1; 445 } 446 resolveDepth(e) { 447 return e == null ? this.depth : e < 0 ? this.depth + e : e; 448 } 449 get parent() { 450 return this.node(this.depth); 451 } 452 get doc() { 453 return this.node(0); 454 } 455 node(e) { 456 return this.path[this.resolveDepth(e) * 3]; 457 } 458 index(e) { 459 return this.path[this.resolveDepth(e) * 3 + 1]; 460 } 461 indexAfter(e) { 462 return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1); 463 } 464 start(e) { 465 return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1; 466 } 467 end(e) { 468 return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size; 469 } 470 before(e) { 471 if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node"); 472 return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1]; 473 } 474 after(e) { 475 if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node"); 476 return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize; 477 } 478 get textOffset() { 479 return this.pos - this.path[this.path.length - 1]; 480 } 481 get nodeAfter() { 482 let e = this.parent, t = this.index(this.depth); 483 if (t == e.childCount) return null; 484 let n = this.pos - this.path[this.path.length - 1], r = e.child(t); 485 return n ? e.child(t).cut(n) : r; 486 } 487 get nodeBefore() { 488 let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1]; 489 return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1); 490 } 491 posAtIndex(e, t) { 492 t = this.resolveDepth(t); 493 let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1; 494 for (let t = 0; t < e; t++) r += n.child(t).nodeSize; 495 return r; 496 } 497 marks() { 498 let e = this.parent, t = this.index(); 499 if (e.content.size == 0) return l.none; 500 if (this.textOffset) return e.child(t).marks; 501 let n = e.maybeChild(t - 1), r = e.maybeChild(t); 502 if (!n) { 503 let e = n; 504 n = r, r = e; 505 } 506 let i = n.marks; 507 for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i)); 508 return i; 509 } 510 marksAcross(e) { 511 let t = this.parent.maybeChild(this.index()); 512 if (!t || !t.isInline) return null; 513 let n = t.marks, r = e.parent.maybeChild(e.index()); 514 for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n)); 515 return n; 516 } 517 sharedDepth(e) { 518 for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t; 519 return 0; 520 } 521 blockRange(e = this, t) { 522 if (e.pos < this.pos) return e.blockRange(this); 523 for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new se(this, e, n); 524 return null; 525 } 526 sameParent(e) { 527 return this.pos - this.parentOffset == e.pos - e.parentOffset; 528 } 529 max(e) { 530 return e.pos > this.pos ? e : this; 531 } 532 min(e) { 533 return e.pos < this.pos ? e : this; 534 } 535 toString() { 536 let e = ""; 537 for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1); 538 return e + ":" + this.parentOffset; 539 } 540 static resolve(t, n) { 541 if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range"); 542 let r = [], i = 0, a = n; 543 for (let e = t;;) { 544 let { index: t, offset: n } = e.content.findIndex(a), o = a - n; 545 if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break; 546 a = o - 1, i += n + 1; 547 } 548 return new e(n, r, a); 549 } 550 static resolveCached(t, n) { 551 let r = oe.get(t); 552 if (r) for (let e = 0; e < r.elts.length; e++) { 553 let t = r.elts[e]; 554 if (t.pos == n) return t; 555 } 556 else oe.set(t, r = new ie()); 557 let i = r.elts[r.i] = e.resolve(t, n); 558 return r.i = (r.i + 1) % ae, i; 559 } 560}, ie = class { 561 constructor() { 562 this.elts = [], this.i = 0; 563 } 564}, ae = 12, oe = /* @__PURE__ */ new WeakMap(), se = class { 565 constructor(e, t, n) { 566 this.$from = e, this.$to = t, this.depth = n; 567 } 568 get start() { 569 return this.$from.before(this.depth + 1); 570 } 571 get end() { 572 return this.$to.after(this.depth + 1); 573 } 574 get parent() { 575 return this.$from.node(this.depth); 576 } 577 get startIndex() { 578 return this.$from.index(this.depth); 579 } 580 get endIndex() { 581 return this.$to.indexAfter(this.depth); 582 } 583}, ce = Object.create(null), le = class e { 584 constructor(e, t, n, r = l.none) { 585 this.type = e, this.attrs = t, this.marks = r, this.content = n || a.empty; 586 } 587 get children() { 588 return this.content.content; 589 } 590 get nodeSize() { 591 return this.isLeaf ? 1 : 2 + this.content.size; 592 } 593 get childCount() { 594 return this.content.childCount; 595 } 596 child(e) { 597 return this.content.child(e); 598 } 599 maybeChild(e) { 600 return this.content.maybeChild(e); 601 } 602 forEach(e) { 603 this.content.forEach(e); 604 } 605 nodesBetween(e, t, n, r = 0) { 606 this.content.nodesBetween(e, t, n, r, this); 607 } 608 descendants(e) { 609 this.nodesBetween(0, this.content.size, e); 610 } 611 get textContent() { 612 return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, ""); 613 } 614 textBetween(e, t, n, r) { 615 return this.content.textBetween(e, t, n, r); 616 } 617 get firstChild() { 618 return this.content.firstChild; 619 } 620 get lastChild() { 621 return this.content.lastChild; 622 } 623 eq(e) { 624 return this == e || this.sameMarkup(e) && this.content.eq(e.content); 625 } 626 sameMarkup(e) { 627 return this.hasMarkup(e.type, e.attrs, e.marks); 628 } 629 hasMarkup(e, t, n) { 630 return this.type == e && c(this.attrs, t || e.defaultAttrs || ce) && l.sameSet(this.marks, n || l.none); 631 } 632 copy(t = null) { 633 return t == this.content ? this : new e(this.type, this.attrs, t, this.marks); 634 } 635 mark(t) { 636 return t == this.marks ? this : new e(this.type, this.attrs, this.content, t); 637 } 638 cut(e, t = this.content.size) { 639 return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t)); 640 } 641 slice(e, t = this.content.size, n = !1) { 642 if (e == t) return d.empty; 643 let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a); 644 return new d(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a); 645 } 646 replace(e, t, n) { 647 return m(this.resolve(e), this.resolve(t), n); 648 } 649 nodeAt(e) { 650 for (let t = this;;) { 651 let { index: n, offset: r } = t.content.findIndex(e); 652 if (t = t.maybeChild(n), !t) return null; 653 if (r == e || t.isText) return t; 654 e -= r + 1; 655 } 656 } 657 childAfter(e) { 658 let { index: t, offset: n } = this.content.findIndex(e); 659 return { 660 node: this.content.maybeChild(t), 661 index: t, 662 offset: n 663 }; 664 } 665 childBefore(e) { 666 if (e == 0) return { 667 node: null, 668 index: 0, 669 offset: 0 670 }; 671 let { index: t, offset: n } = this.content.findIndex(e); 672 if (n < e) return { 673 node: this.content.child(t), 674 index: t, 675 offset: n 676 }; 677 let r = this.content.child(t - 1); 678 return { 679 node: r, 680 index: t - 1, 681 offset: n - r.nodeSize 682 }; 683 } 684 resolve(e) { 685 return re.resolveCached(this, e); 686 } 687 resolveNoCache(e) { 688 return re.resolve(this, e); 689 } 690 rangeHasMark(e, t, n) { 691 let r = !1; 692 return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r; 693 } 694 get isBlock() { 695 return this.type.isBlock; 696 } 697 get isTextblock() { 698 return this.type.isTextblock; 699 } 700 get inlineContent() { 701 return this.type.inlineContent; 702 } 703 get isInline() { 704 return this.type.isInline; 705 } 706 get isText() { 707 return this.type.isText; 708 } 709 get isLeaf() { 710 return this.type.isLeaf; 711 } 712 get isAtom() { 713 return this.type.isAtom; 714 } 715 toString() { 716 if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this); 717 let e = this.type.name; 718 return this.content.size && (e += "(" + this.content.toStringInner() + ")"), de(this.marks, e); 719 } 720 contentMatchAt(e) { 721 let t = this.type.contentMatch.matchFragment(this.content, 0, e); 722 if (!t) throw Error("Called contentMatchAt on a node with invalid content"); 723 return t; 724 } 725 canReplace(e, t, n = a.empty, r = 0, i = n.childCount) { 726 let o = this.contentMatchAt(e).matchFragment(n, r, i), s = o && o.matchFragment(this.content, t); 727 if (!s || !s.validEnd) return !1; 728 for (let e = r; e < i; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1; 729 return !0; 730 } 731 canReplaceWith(e, t, n, r) { 732 if (r && !this.type.allowsMarks(r)) return !1; 733 let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t); 734 return a ? a.validEnd : !1; 735 } 736 canAppend(e) { 737 return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type); 738 } 739 check() { 740 this.type.checkContent(this.content), this.type.checkAttrs(this.attrs); 741 let e = l.none; 742 for (let t = 0; t < this.marks.length; t++) { 743 let n = this.marks[t]; 744 n.type.checkAttrs(n.attrs), e = n.addToSet(e); 745 } 746 if (!l.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`); 747 this.content.forEach((e) => e.check()); 748 } 749 toJSON() { 750 let e = { type: this.type.name }; 751 for (let t in this.attrs) { 752 e.attrs = this.attrs; 753 break; 754 } 755 return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e; 756 } 757 static fromJSON(e, t) { 758 if (!t) throw RangeError("Invalid input for Node.fromJSON"); 759 let n; 760 if (t.marks) { 761 if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON"); 762 n = t.marks.map(e.markFromJSON); 763 } 764 if (t.type == "text") { 765 if (typeof t.text != "string") throw RangeError("Invalid text node in JSON"); 766 return e.text(t.text, n); 767 } 768 let r = a.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, r, n); 769 return i.type.checkAttrs(i.attrs), i; 770 } 771}; 772le.prototype.text = void 0; 773var ue = class e extends le { 774 constructor(e, t, n, r) { 775 if (super(e, t, null, r), !n) throw RangeError("Empty text nodes are not allowed"); 776 this.text = n; 777 } 778 toString() { 779 return this.type.spec.toDebugString ? this.type.spec.toDebugString(this) : de(this.marks, JSON.stringify(this.text)); 780 } 781 get textContent() { 782 return this.text; 783 } 784 textBetween(e, t) { 785 return this.text.slice(e, t); 786 } 787 get nodeSize() { 788 return this.text.length; 789 } 790 mark(t) { 791 return t == this.marks ? this : new e(this.type, this.attrs, this.text, t); 792 } 793 withText(t) { 794 return t == this.text ? this : new e(this.type, this.attrs, t, this.marks); 795 } 796 cut(e = 0, t = this.text.length) { 797 return e == 0 && t == this.text.length ? this : this.withText(this.text.slice(e, t)); 798 } 799 eq(e) { 800 return this.sameMarkup(e) && this.text == e.text; 801 } 802 toJSON() { 803 let e = super.toJSON(); 804 return e.text = this.text, e; 805 } 806}; 807function de(e, t) { 808 for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")"; 809 return t; 810} 811var fe = class e { 812 constructor(e) { 813 this.validEnd = e, this.next = [], this.wrapCache = []; 814 } 815 static parse(t, n) { 816 let r = new pe(t, n); 817 if (r.next == null) return e.empty; 818 let i = me(r); 819 r.next && r.err("Unexpected trailing text"); 820 let a = we(xe(i)); 821 return Te(a, r), a; 822 } 823 matchType(e) { 824 for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next; 825 return null; 826 } 827 matchFragment(e, t = 0, n = e.childCount) { 828 let r = this; 829 for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type); 830 return r; 831 } 832 get inlineContent() { 833 return this.next.length != 0 && this.next[0].type.isInline; 834 } 835 get defaultType() { 836 for (let e = 0; e < this.next.length; e++) { 837 let { type: t } = this.next[e]; 838 if (!(t.isText || t.hasRequiredAttrs())) return t; 839 } 840 return null; 841 } 842 compatible(e) { 843 for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0; 844 return !1; 845 } 846 fillBefore(e, t = !1, n = 0) { 847 let r = [this]; 848 function i(o, s) { 849 let c = o.matchFragment(e, n); 850 if (c && (!t || c.validEnd)) return a.from(s.map((e) => e.createAndFill())); 851 for (let e = 0; e < o.next.length; e++) { 852 let { type: t, next: n } = o.next[e]; 853 if (!(t.isText || t.hasRequiredAttrs()) && r.indexOf(n) == -1) { 854 r.push(n); 855 let e = i(n, s.concat(t)); 856 if (e) return e; 857 } 858 } 859 return null; 860 } 861 return i(this, []); 862 } 863 findWrapping(e) { 864 for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1]; 865 let t = this.computeWrapping(e); 866 return this.wrapCache.push(e, t), t; 867 } 868 computeWrapping(e) { 869 let t = Object.create(null), n = [{ 870 match: this, 871 type: null, 872 via: null 873 }]; 874 for (; n.length;) { 875 let r = n.shift(), i = r.match; 876 if (i.matchType(e)) { 877 let e = []; 878 for (let t = r; t.type; t = t.via) e.push(t.type); 879 return e.reverse(); 880 } 881 for (let e = 0; e < i.next.length; e++) { 882 let { type: a, next: o } = i.next[e]; 883 !a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({ 884 match: a.contentMatch, 885 type: a, 886 via: r 887 }), t[a.name] = !0); 888 } 889 } 890 return null; 891 } 892 get edgeCount() { 893 return this.next.length; 894 } 895 edge(e) { 896 if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`); 897 return this.next[e]; 898 } 899 toString() { 900 let e = []; 901 function t(n) { 902 e.push(n); 903 for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next); 904 } 905 return t(this), e.map((t, n) => { 906 let r = n + (t.validEnd ? "*" : " ") + " "; 907 for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next); 908 return r; 909 }).join("\n"); 910 } 911}; 912fe.empty = new fe(!0); 913var pe = class { 914 constructor(e, t) { 915 this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift(); 916 } 917 get next() { 918 return this.tokens[this.pos]; 919 } 920 eat(e) { 921 return this.next == e && (this.pos++ || !0); 922 } 923 err(e) { 924 throw SyntaxError(e + " (in content expression '" + this.string + "')"); 925 } 926}; 927function me(e) { 928 let t = []; 929 do 930 t.push(he(e)); 931 while (e.eat("|")); 932 return t.length == 1 ? t[0] : { 933 type: "choice", 934 exprs: t 935 }; 936} 937function he(e) { 938 let t = []; 939 do 940 t.push(ge(e)); 941 while (e.next && e.next != ")" && e.next != "|"); 942 return t.length == 1 ? t[0] : { 943 type: "seq", 944 exprs: t 945 }; 946} 947function ge(e) { 948 let t = be(e); 949 for (;;) if (e.eat("+")) t = { 950 type: "plus", 951 expr: t 952 }; 953 else if (e.eat("*")) t = { 954 type: "star", 955 expr: t 956 }; 957 else if (e.eat("?")) t = { 958 type: "opt", 959 expr: t 960 }; 961 else if (e.eat("{")) t = ve(e, t); 962 else break; 963 return t; 964} 965function _e(e) { 966 /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'"); 967 let t = Number(e.next); 968 return e.pos++, t; 969} 970function ve(e, t) { 971 let n = _e(e), r = n; 972 return e.eat(",") && (r = e.next == "}" ? -1 : _e(e)), e.eat("}") || e.err("Unclosed braced range"), { 973 type: "range", 974 min: n, 975 max: r, 976 expr: t 977 }; 978} 979function ye(e, t) { 980 let n = e.nodeTypes, r = n[t]; 981 if (r) return [r]; 982 let i = []; 983 for (let e in n) { 984 let r = n[e]; 985 r.isInGroup(t) && i.push(r); 986 } 987 return i.length == 0 && e.err("No node type or group '" + t + "' found"), i; 988} 989function be(e) { 990 if (e.eat("(")) { 991 let t = me(e); 992 return e.eat(")") || e.err("Missing closing paren"), t; 993 } else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'"); 994 else { 995 let t = ye(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), { 996 type: "name", 997 value: t 998 })); 999 return e.pos++, t.length == 1 ? t[0] : { 1000 type: "choice", 1001 exprs: t 1002 }; 1003 } 1004} 1005function xe(e) { 1006 let t = [[]]; 1007 return i(a(e, 0), n()), t; 1008 function n() { 1009 return t.push([]) - 1; 1010 } 1011 function r(e, n, r) { 1012 let i = { 1013 term: r, 1014 to: n 1015 }; 1016 return t[e].push(i), i; 1017 } 1018 function i(e, t) { 1019 e.forEach((e) => e.to = t); 1020 } 1021 function a(e, t) { 1022 if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []); 1023 if (e.type == "seq") for (let r = 0;; r++) { 1024 let o = a(e.exprs[r], t); 1025 if (r == e.exprs.length - 1) return o; 1026 i(o, t = n()); 1027 } 1028 else if (e.type == "star") { 1029 let o = n(); 1030 return r(t, o), i(a(e.expr, o), o), [r(o)]; 1031 } else if (e.type == "plus") { 1032 let o = n(); 1033 return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)]; 1034 } else if (e.type == "opt") return [r(t)].concat(a(e.expr, t)); 1035 else if (e.type == "range") { 1036 let o = t; 1037 for (let t = 0; t < e.min; t++) { 1038 let t = n(); 1039 i(a(e.expr, o), t), o = t; 1040 } 1041 if (e.max == -1) i(a(e.expr, o), o); 1042 else for (let t = e.min; t < e.max; t++) { 1043 let t = n(); 1044 r(o, t), i(a(e.expr, o), t), o = t; 1045 } 1046 return [r(o)]; 1047 } else if (e.type == "name") return [r(t, void 0, e.value)]; 1048 else throw Error("Unknown expr type"); 1049 } 1050} 1051function Se(e, t) { 1052 return t - e; 1053} 1054function Ce(e, t) { 1055 let n = []; 1056 return r(t), n.sort(Se); 1057 function r(t) { 1058 let i = e[t]; 1059 if (i.length == 1 && !i[0].term) return r(i[0].to); 1060 n.push(t); 1061 for (let e = 0; e < i.length; e++) { 1062 let { term: t, to: a } = i[e]; 1063 !t && n.indexOf(a) == -1 && r(a); 1064 } 1065 } 1066} 1067function we(e) { 1068 let t = Object.create(null); 1069 return n(Ce(e, 0)); 1070 function n(r) { 1071 let i = []; 1072 r.forEach((t) => { 1073 e[t].forEach(({ term: t, to: n }) => { 1074 if (!t) return; 1075 let r; 1076 for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]); 1077 Ce(e, n).forEach((e) => { 1078 r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e); 1079 }); 1080 }); 1081 }); 1082 let a = t[r.join(",")] = new fe(r.indexOf(e.length - 1) > -1); 1083 for (let e = 0; e < i.length; e++) { 1084 let r = i[e][1].sort(Se); 1085 a.next.push({ 1086 type: i[e][0], 1087 next: t[r.join(",")] || n(r) 1088 }); 1089 } 1090 return a; 1091 } 1092} 1093function Te(e, t) { 1094 for (let n = 0, r = [e]; n < r.length; n++) { 1095 let e = r[n], i = !e.validEnd, a = []; 1096 for (let t = 0; t < e.next.length; t++) { 1097 let { type: n, next: o } = e.next[t]; 1098 a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o); 1099 } 1100 i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)"); 1101 } 1102} 1103function Ee(e) { 1104 let t = Object.create(null); 1105 for (let n in e) { 1106 let r = e[n]; 1107 if (!r.hasDefault) return null; 1108 t[n] = r.default; 1109 } 1110 return t; 1111} 1112function De(e, t) { 1113 let n = Object.create(null); 1114 for (let r in e) { 1115 let i = t && t[r]; 1116 if (i === void 0) { 1117 let t = e[r]; 1118 if (t.hasDefault) i = t.default; 1119 else throw RangeError("No value supplied for attribute " + r); 1120 } 1121 n[r] = i; 1122 } 1123 return n; 1124} 1125function Oe(e, t, n, r) { 1126 for (let i in t) if (!(i in e)) throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`); 1127 for (let n in e) e[n].validate && e[n].validate(t[n]); 1128} 1129function ke(e, t) { 1130 let n = Object.create(null); 1131 if (t) for (let r in t) n[r] = new Me(e, r, t[r]); 1132 return n; 1133} 1134var Ae = class e { 1135 constructor(e, t, n) { 1136 this.name = e, this.schema = t, this.spec = n, this.markSet = null, this.groups = n.group ? n.group.split(" ") : [], this.attrs = ke(e, n.attrs), this.defaultAttrs = Ee(this.attrs), this.contentMatch = null, this.inlineContent = null, this.isBlock = !(n.inline || e == "text"), this.isText = e == "text"; 1137 } 1138 get isInline() { 1139 return !this.isBlock; 1140 } 1141 get isTextblock() { 1142 return this.isBlock && this.inlineContent; 1143 } 1144 get isLeaf() { 1145 return this.contentMatch == fe.empty; 1146 } 1147 get isAtom() { 1148 return this.isLeaf || !!this.spec.atom; 1149 } 1150 isInGroup(e) { 1151 return this.groups.indexOf(e) > -1; 1152 } 1153 get whitespace() { 1154 return this.spec.whitespace || (this.spec.code ? "pre" : "normal"); 1155 } 1156 hasRequiredAttrs() { 1157 for (let e in this.attrs) if (this.attrs[e].isRequired) return !0; 1158 return !1; 1159 } 1160 compatibleContent(e) { 1161 return this == e || this.contentMatch.compatible(e.contentMatch); 1162 } 1163 computeAttrs(e) { 1164 return !e && this.defaultAttrs ? this.defaultAttrs : De(this.attrs, e); 1165 } 1166 create(e = null, t, n) { 1167 if (this.isText) throw Error("NodeType.create can't construct text nodes"); 1168 return new le(this, this.computeAttrs(e), a.from(t), l.setFrom(n)); 1169 } 1170 createChecked(e = null, t, n) { 1171 return t = a.from(t), this.checkContent(t), new le(this, this.computeAttrs(e), t, l.setFrom(n)); 1172 } 1173 createAndFill(e = null, t, n) { 1174 if (e = this.computeAttrs(e), t = a.from(t), t.size) { 1175 let e = this.contentMatch.fillBefore(t); 1176 if (!e) return null; 1177 t = e.append(t); 1178 } 1179 let r = this.contentMatch.matchFragment(t), i = r && r.fillBefore(a.empty, !0); 1180 return i ? new le(this, e, t.append(i), l.setFrom(n)) : null; 1181 } 1182 validContent(e) { 1183 let t = this.contentMatch.matchFragment(e); 1184 if (!t || !t.validEnd) return !1; 1185 for (let t = 0; t < e.childCount; t++) if (!this.allowsMarks(e.child(t).marks)) return !1; 1186 return !0; 1187 } 1188 checkContent(e) { 1189 if (!this.validContent(e)) throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0, 50)}`); 1190 } 1191 checkAttrs(e) { 1192 Oe(this.attrs, e, "node", this.name); 1193 } 1194 allowsMarkType(e) { 1195 return this.markSet == null || this.markSet.indexOf(e) > -1; 1196 } 1197 allowsMarks(e) { 1198 if (this.markSet == null) return !0; 1199 for (let t = 0; t < e.length; t++) if (!this.allowsMarkType(e[t].type)) return !1; 1200 return !0; 1201 } 1202 allowedMarks(e) { 1203 if (this.markSet == null) return e; 1204 let t; 1205 for (let n = 0; n < e.length; n++) this.allowsMarkType(e[n].type) ? t && t.push(e[n]) : t ||= e.slice(0, n); 1206 return t ? t.length ? t : l.none : e; 1207 } 1208 static compile(t, n) { 1209 let r = Object.create(null); 1210 t.forEach((t, i) => r[t] = new e(t, n, i)); 1211 let i = n.spec.topNode || "doc"; 1212 if (!r[i]) throw RangeError("Schema is missing its top node type ('" + i + "')"); 1213 if (!r.text) throw RangeError("Every schema needs a 'text' type"); 1214 for (let e in r.text.attrs) throw RangeError("The text node type should not have attributes"); 1215 return r; 1216 } 1217}; 1218function je(e, t, n) { 1219 let r = n.split("|"); 1220 return (n) => { 1221 let i = n === null ? "null" : typeof n; 1222 if (r.indexOf(i) < 0) throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`); 1223 }; 1224} 1225var Me = class { 1226 constructor(e, t, n) { 1227 this.hasDefault = Object.prototype.hasOwnProperty.call(n, "default"), this.default = n.default, this.validate = typeof n.validate == "string" ? je(e, t, n.validate) : n.validate; 1228 } 1229 get isRequired() { 1230 return !this.hasDefault; 1231 } 1232}, Ne = class e { 1233 constructor(e, t, n, r) { 1234 this.name = e, this.rank = t, this.schema = n, this.spec = r, this.attrs = ke(e, r.attrs), this.excluded = null; 1235 let i = Ee(this.attrs); 1236 this.instance = i ? new l(this, i) : null; 1237 } 1238 create(e = null) { 1239 return !e && this.instance ? this.instance : new l(this, De(this.attrs, e)); 1240 } 1241 static compile(t, n) { 1242 let r = Object.create(null), i = 0; 1243 return t.forEach((t, a) => r[t] = new e(t, i++, n, a)), r; 1244 } 1245 removeFromSet(e) { 1246 for (var t = 0; t < e.length; t++) e[t].type == this && (e = e.slice(0, t).concat(e.slice(t + 1)), t--); 1247 return e; 1248 } 1249 isInSet(e) { 1250 for (let t = 0; t < e.length; t++) if (e[t].type == this) return e[t]; 1251 } 1252 checkAttrs(e) { 1253 Oe(this.attrs, e, "mark", this.name); 1254 } 1255 excludes(e) { 1256 return this.excluded.indexOf(e) > -1; 1257 } 1258}, Pe = class { 1259 constructor(t) { 1260 this.linebreakReplacement = null, this.cached = Object.create(null); 1261 let n = this.spec = {}; 1262 for (let e in t) n[e] = t[e]; 1263 n.nodes = e.from(t.nodes), n.marks = e.from(t.marks || {}), this.nodes = Ae.compile(this.spec.nodes, this), this.marks = Ne.compile(this.spec.marks, this); 1264 let r = Object.create(null); 1265 for (let e in this.nodes) { 1266 if (e in this.marks) throw RangeError(e + " can not be both a node and a mark"); 1267 let t = this.nodes[e], n = t.spec.content || "", i = t.spec.marks; 1268 if (t.contentMatch = r[n] || (r[n] = fe.parse(n, this.nodes)), t.inlineContent = t.contentMatch.inlineContent, t.spec.linebreakReplacement) { 1269 if (this.linebreakReplacement) throw RangeError("Multiple linebreak nodes defined"); 1270 if (!t.isInline || !t.isLeaf) throw RangeError("Linebreak replacement nodes must be inline leaf nodes"); 1271 this.linebreakReplacement = t; 1272 } 1273 t.markSet = i == "_" ? null : i ? Fe(this, i.split(" ")) : i == "" || !t.inlineContent ? [] : null; 1274 } 1275 for (let e in this.marks) { 1276 let t = this.marks[e], n = t.spec.excludes; 1277 t.excluded = n == null ? [t] : n == "" ? [] : Fe(this, n.split(" ")); 1278 } 1279 this.nodeFromJSON = (e) => le.fromJSON(this, e), this.markFromJSON = (e) => l.fromJSON(this, e), this.topNodeType = this.nodes[this.spec.topNode || "doc"], this.cached.wrappings = Object.create(null); 1280 } 1281 node(e, t = null, n, r) { 1282 if (typeof e == "string") e = this.nodeType(e); 1283 else if (!(e instanceof Ae)) throw RangeError("Invalid node type: " + e); 1284 else if (e.schema != this) throw RangeError("Node type from different schema used (" + e.name + ")"); 1285 return e.createChecked(t, n, r); 1286 } 1287 text(e, t) { 1288 let n = this.nodes.text; 1289 return new ue(n, n.defaultAttrs, e, l.setFrom(t)); 1290 } 1291 mark(e, t) { 1292 return typeof e == "string" && (e = this.marks[e]), e.create(t); 1293 } 1294 nodeType(e) { 1295 let t = this.nodes[e]; 1296 if (!t) throw RangeError("Unknown node type: " + e); 1297 return t; 1298 } 1299}; 1300function Fe(e, t) { 1301 let n = []; 1302 for (let r = 0; r < t.length; r++) { 1303 let i = t[r], a = e.marks[i], o = a; 1304 if (a) n.push(a); 1305 else for (let t in e.marks) { 1306 let r = e.marks[t]; 1307 (i == "_" || r.spec.group && r.spec.group.split(" ").indexOf(i) > -1) && n.push(o = r); 1308 } 1309 if (!o) throw SyntaxError("Unknown mark type: '" + t[r] + "'"); 1310 } 1311 return n; 1312} 1313function Ie(e) { 1314 return e.tag != null; 1315} 1316function Le(e) { 1317 return e.style != null; 1318} 1319var Re = class e { 1320 constructor(e, t) { 1321 this.schema = e, this.rules = t, this.tags = [], this.styles = []; 1322 let n = this.matchedStyles = []; 1323 t.forEach((e) => { 1324 if (Ie(e)) this.tags.push(e); 1325 else if (Le(e)) { 1326 let t = /[^=]*/.exec(e.style)[0]; 1327 n.indexOf(t) < 0 && n.push(t), this.styles.push(e); 1328 } 1329 }), this.normalizeLists = !this.tags.some((t) => { 1330 if (!/^(ul|ol)\b/.test(t.tag) || !t.node) return !1; 1331 let n = e.nodes[t.node]; 1332 return n.contentMatch.matchType(n); 1333 }); 1334 } 1335 parse(e, t = {}) { 1336 let n = new qe(this, t, !1); 1337 return n.addAll(e, l.none, t.from, t.to), n.finish(); 1338 } 1339 parseSlice(e, t = {}) { 1340 let n = new qe(this, t, !0); 1341 return n.addAll(e, l.none, t.from, t.to), d.maxOpen(n.finish()); 1342 } 1343 matchTag(e, t, n) { 1344 for (let r = n ? this.tags.indexOf(n) + 1 : 0; r < this.tags.length; r++) { 1345 let n = this.tags[r]; 1346 if (Ye(e, n.tag) && (n.namespace === void 0 || e.namespaceURI == n.namespace) && (!n.context || t.matchesContext(n.context))) { 1347 if (n.getAttrs) { 1348 let t = n.getAttrs(e); 1349 if (t === !1) continue; 1350 n.attrs = t || void 0; 1351 } 1352 return n; 1353 } 1354 } 1355 } 1356 matchStyle(e, t, n, r) { 1357 for (let i = r ? this.styles.indexOf(r) + 1 : 0; i < this.styles.length; i++) { 1358 let r = this.styles[i], a = r.style; 1359 if (!(a.indexOf(e) != 0 || r.context && !n.matchesContext(r.context) || a.length > e.length && (a.charCodeAt(e.length) != 61 || a.slice(e.length + 1) != t))) { 1360 if (r.getAttrs) { 1361 let e = r.getAttrs(t); 1362 if (e === !1) continue; 1363 r.attrs = e || void 0; 1364 } 1365 return r; 1366 } 1367 } 1368 } 1369 static schemaRules(e) { 1370 let t = []; 1371 function n(e) { 1372 let n = e.priority == null ? 50 : e.priority, r = 0; 1373 for (; r < t.length; r++) { 1374 let e = t[r]; 1375 if ((e.priority == null ? 50 : e.priority) < n) break; 1376 } 1377 t.splice(r, 0, e); 1378 } 1379 for (let t in e.marks) { 1380 let r = e.marks[t].spec.parseDOM; 1381 r && r.forEach((e) => { 1382 n(e = Xe(e)), e.mark || e.ignore || e.clearMark || (e.mark = t); 1383 }); 1384 } 1385 for (let t in e.nodes) { 1386 let r = e.nodes[t].spec.parseDOM; 1387 r && r.forEach((e) => { 1388 n(e = Xe(e)), e.node || e.ignore || e.mark || (e.node = t); 1389 }); 1390 } 1391 return t; 1392 } 1393 static fromSchema(t) { 1394 return t.cached.domParser || (t.cached.domParser = new e(t, e.schemaRules(t))); 1395 } 1396}, ze = { 1397 address: !0, 1398 article: !0, 1399 aside: !0, 1400 blockquote: !0, 1401 canvas: !0, 1402 dd: !0, 1403 div: !0, 1404 dl: !0, 1405 fieldset: !0, 1406 figcaption: !0, 1407 figure: !0, 1408 footer: !0, 1409 form: !0, 1410 h1: !0, 1411 h2: !0, 1412 h3: !0, 1413 h4: !0, 1414 h5: !0, 1415 h6: !0, 1416 header: !0, 1417 hgroup: !0, 1418 hr: !0, 1419 li: !0, 1420 noscript: !0, 1421 ol: !0, 1422 output: !0, 1423 p: !0, 1424 pre: !0, 1425 section: !0, 1426 table: !0, 1427 tfoot: !0, 1428 ul: !0 1429}, Be = { 1430 head: !0, 1431 noscript: !0, 1432 object: !0, 1433 script: !0, 1434 style: !0, 1435 title: !0 1436}, Ve = { 1437 ol: !0, 1438 ul: !0 1439}, He = 1, Ue = 2, We = 4; 1440function Ge(e, t, n) { 1441 return t == null ? e && e.whitespace == "pre" ? 3 : n & -5 : (t ? He : 0) | (t === "full" ? Ue : 0); 1442} 1443var Ke = class { 1444 constructor(e, t, n, r, i, a) { 1445 this.type = e, this.attrs = t, this.marks = n, this.solid = r, this.options = a, this.content = [], this.activeMarks = l.none, this.match = i || (a & We ? null : e.contentMatch); 1446 } 1447 findWrapping(e) { 1448 if (!this.match) { 1449 if (!this.type) return []; 1450 let t = this.type.contentMatch.fillBefore(a.from(e)); 1451 if (t) this.match = this.type.contentMatch.matchFragment(t); 1452 else { 1453 let t = this.type.contentMatch, n; 1454 return (n = t.findWrapping(e.type)) ? (this.match = t, n) : null; 1455 } 1456 } 1457 return this.match.findWrapping(e.type); 1458 } 1459 finish(e) { 1460 if (!(this.options & He)) { 1461 let e = this.content[this.content.length - 1], t; 1462 if (e && e.isText && (t = /[ \t\r\n\u000c]+$/.exec(e.text))) { 1463 let n = e; 1464 e.text.length == t[0].length ? this.content.pop() : this.content[this.content.length - 1] = n.withText(n.text.slice(0, n.text.length - t[0].length)); 1465 } 1466 } 1467 let t = a.from(this.content); 1468 return !e && this.match && (t = t.append(this.match.fillBefore(a.empty, !0))), this.type ? this.type.create(this.attrs, t, this.marks) : t; 1469 } 1470 inlineContext(e) { 1471 return this.type ? this.type.inlineContent : this.content.length ? this.content[0].isInline : e.parentNode && !ze.hasOwnProperty(e.parentNode.nodeName.toLowerCase()); 1472 } 1473}, qe = class { 1474 constructor(e, t, n) { 1475 this.parser = e, this.options = t, this.isOpen = n, this.open = 0, this.localPreserveWS = !1; 1476 let r = t.topNode, i, a = Ge(null, t.preserveWhitespace, 0) | (n ? We : 0); 1477 i = r ? new Ke(r.type, r.attrs, l.none, !0, t.topMatch || r.type.contentMatch, a) : n ? new Ke(null, null, l.none, !0, null, a) : new Ke(e.schema.topNodeType, null, l.none, !0, null, a), this.nodes = [i], this.find = t.findPositions, this.needsBlock = !1; 1478 } 1479 get top() { 1480 return this.nodes[this.open]; 1481 } 1482 addDOM(e, t) { 1483 e.nodeType == 3 ? this.addTextNode(e, t) : e.nodeType == 1 && this.addElement(e, t); 1484 } 1485 addTextNode(e, t) { 1486 let n = e.nodeValue, r = this.top, i = r.options & Ue ? "full" : this.localPreserveWS || (r.options & He) > 0, { schema: a } = this.parser; 1487 if (i === "full" || r.inlineContext(e) || /[^ \t\r\n\u000c]/.test(n)) { 1488 if (!i) { 1489 if (n = n.replace(/[ \t\r\n\u000c]+/g, " "), /^[ \t\r\n\u000c]/.test(n) && this.open == this.nodes.length - 1) { 1490 let t = r.content[r.content.length - 1], i = e.previousSibling; 1491 (!t || i && i.nodeName == "BR" || t.isText && /[ \t\r\n\u000c]$/.test(t.text)) && (n = n.slice(1)); 1492 } 1493 } else if (i === "full") n = n.replace(/\r\n?/g, "\n"); 1494 else if (a.linebreakReplacement && /[\r\n]/.test(n) && this.top.findWrapping(a.linebreakReplacement.create())) { 1495 let e = n.split(/\r?\n|\r/); 1496 for (let n = 0; n < e.length; n++) n && this.insertNode(a.linebreakReplacement.create(), t, !0), e[n] && this.insertNode(a.text(e[n]), t, !/\S/.test(e[n])); 1497 n = ""; 1498 } else n = n.replace(/\r?\n|\r/g, " "); 1499 n && this.insertNode(a.text(n), t, !/\S/.test(n)), this.findInText(e); 1500 } else this.findInside(e); 1501 } 1502 addElement(e, t, n) { 1503 let r = this.localPreserveWS, i = this.top; 1504 (e.tagName == "PRE" || /pre/.test(e.style && e.style.whiteSpace)) && (this.localPreserveWS = !0); 1505 let a = e.nodeName.toLowerCase(), o; 1506 Ve.hasOwnProperty(a) && this.parser.normalizeLists && Je(e); 1507 let s = this.options.ruleFromNode && this.options.ruleFromNode(e) || (o = this.parser.matchTag(e, this, n)); 1508 out: if (s ? s.ignore : Be.hasOwnProperty(a)) this.findInside(e), this.ignoreFallback(e, t); 1509 else if (!s || s.skip || s.closeParent) { 1510 s && s.closeParent ? this.open = Math.max(0, this.open - 1) : s && s.skip.nodeType && (e = s.skip); 1511 let n, r = this.needsBlock; 1512 if (ze.hasOwnProperty(a)) i.content.length && i.content[0].isInline && this.open && (this.open--, i = this.top), n = !0, i.type || (this.needsBlock = !0); 1513 else if (!e.firstChild) { 1514 this.leafFallback(e, t); 1515 break out; 1516 } 1517 let o = s && s.skip ? t : this.readStyles(e, t); 1518 o && this.addAll(e, o), n && this.sync(i), this.needsBlock = r; 1519 } else { 1520 let n = this.readStyles(e, t); 1521 n && this.addElementByRule(e, s, n, s.consuming === !1 ? o : void 0); 1522 } 1523 this.localPreserveWS = r; 1524 } 1525 leafFallback(e, t) { 1526 e.nodeName == "BR" && this.top.type && this.top.type.inlineContent && this.addTextNode(e.ownerDocument.createTextNode("\n"), t); 1527 } 1528 ignoreFallback(e, t) { 1529 e.nodeName == "BR" && (!this.top.type || !this.top.type.inlineContent) && this.findPlace(this.parser.schema.text("-"), t, !0); 1530 } 1531 readStyles(e, t) { 1532 let n = e.style; 1533 if (n && n.length) for (let e = 0; e < this.parser.matchedStyles.length; e++) { 1534 let r = this.parser.matchedStyles[e], i = n.getPropertyValue(r); 1535 if (i) for (let e;;) { 1536 let n = this.parser.matchStyle(r, i, this, e); 1537 if (!n) break; 1538 if (n.ignore) return null; 1539 if (t = n.clearMark ? t.filter((e) => !n.clearMark(e)) : t.concat(this.parser.schema.marks[n.mark].create(n.attrs)), n.consuming === !1) e = n; 1540 else break; 1541 } 1542 } 1543 return t; 1544 } 1545 addElementByRule(e, t, n, r) { 1546 let i, a; 1547 if (t.node) if (a = this.parser.schema.nodes[t.node], a.isLeaf) this.insertNode(a.create(t.attrs), n, e.nodeName == "BR") || this.leafFallback(e, n); 1548 else { 1549 let e = this.enter(a, t.attrs || null, n, t.preserveWhitespace); 1550 e && (i = !0, n = e); 1551 } 1552 else { 1553 let e = this.parser.schema.marks[t.mark]; 1554 n = n.concat(e.create(t.attrs)); 1555 } 1556 let o = this.top; 1557 if (a && a.isLeaf) this.findInside(e); 1558 else if (r) this.addElement(e, n, r); 1559 else if (t.getContent) this.findInside(e), t.getContent(e, this.parser.schema).forEach((e) => this.insertNode(e, n, !1)); 1560 else { 1561 let r = e; 1562 typeof t.contentElement == "string" ? r = e.querySelector(t.contentElement) : typeof t.contentElement == "function" ? r = t.contentElement(e) : t.contentElement && (r = t.contentElement), this.findAround(e, r, !0), this.addAll(r, n), this.findAround(e, r, !1); 1563 } 1564 i && this.sync(o) && this.open--; 1565 } 1566 addAll(e, t, n, r) { 1567 let i = n || 0; 1568 for (let a = n ? e.childNodes[n] : e.firstChild, o = r == null ? null : e.childNodes[r]; a != o; a = a.nextSibling, ++i) this.findAtPoint(e, i), this.addDOM(a, t); 1569 this.findAtPoint(e, i); 1570 } 1571 findPlace(e, t, n) { 1572 let r, i; 1573 for (let t = this.open, a = 0; t >= 0; t--) { 1574 let o = this.nodes[t], s = o.findWrapping(e); 1575 if (s && (!r || r.length > s.length + a) && (r = s, i = o, !s.length)) break; 1576 if (o.solid) { 1577 if (n) break; 1578 a += 2; 1579 } 1580 } 1581 if (!r) return null; 1582 this.sync(i); 1583 for (let e = 0; e < r.length; e++) t = this.enterInner(r[e], null, t, !1); 1584 return t; 1585 } 1586 insertNode(e, t, n) { 1587 if (e.isInline && this.needsBlock && !this.top.type) { 1588 let e = this.textblockFromContext(); 1589 e && (t = this.enterInner(e, null, t)); 1590 } 1591 let r = this.findPlace(e, t, n); 1592 if (r) { 1593 this.closeExtra(); 1594 let t = this.top; 1595 t.match &&= t.match.matchType(e.type); 1596 let n = l.none; 1597 for (let i of r.concat(e.marks)) (t.type ? t.type.allowsMarkType(i.type) : Ze(i.type, e.type)) && (n = i.addToSet(n)); 1598 return t.content.push(e.mark(n)), !0; 1599 } 1600 return !1; 1601 } 1602 enter(e, t, n, r) { 1603 let i = this.findPlace(e.create(t), n, !1); 1604 return i &&= this.enterInner(e, t, n, !0, r), i; 1605 } 1606 enterInner(e, t, n, r = !1, i) { 1607 this.closeExtra(); 1608 let a = this.top; 1609 a.match = a.match && a.match.matchType(e); 1610 let o = Ge(e, i, a.options); 1611 a.options & We && a.content.length == 0 && (o |= We); 1612 let s = l.none; 1613 return n = n.filter((t) => (a.type ? a.type.allowsMarkType(t.type) : Ze(t.type, e)) ? (s = t.addToSet(s), !1) : !0), this.nodes.push(new Ke(e, t, s, r, null, o)), this.open++, n; 1614 } 1615 closeExtra(e = !1) { 1616 let t = this.nodes.length - 1; 1617 if (t > this.open) { 1618 for (; t > this.open; t--) this.nodes[t - 1].content.push(this.nodes[t].finish(e)); 1619 this.nodes.length = this.open + 1; 1620 } 1621 } 1622 finish() { 1623 return this.open = 0, this.closeExtra(this.isOpen), this.nodes[0].finish(!!(this.isOpen || this.options.topOpen)); 1624 } 1625 sync(e) { 1626 for (let t = this.open; t >= 0; t--) if (this.nodes[t] == e) return this.open = t, !0; 1627 else this.localPreserveWS && (this.nodes[t].options |= He); 1628 return !1; 1629 } 1630 get currentPos() { 1631 this.closeExtra(); 1632 let e = 0; 1633 for (let t = this.open; t >= 0; t--) { 1634 let n = this.nodes[t].content; 1635 for (let t = n.length - 1; t >= 0; t--) e += n[t].nodeSize; 1636 t && e++; 1637 } 1638 return e; 1639 } 1640 findAtPoint(e, t) { 1641 if (this.find) for (let n = 0; n < this.find.length; n++) this.find[n].node == e && this.find[n].offset == t && (this.find[n].pos = this.currentPos); 1642 } 1643 findInside(e) { 1644 if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].pos == null && e.nodeType == 1 && e.contains(this.find[t].node) && (this.find[t].pos = this.currentPos); 1645 } 1646 findAround(e, t, n) { 1647 if (e != t && this.find) for (let r = 0; r < this.find.length; r++) this.find[r].pos == null && e.nodeType == 1 && e.contains(this.find[r].node) && t.compareDocumentPosition(this.find[r].node) & (n ? 2 : 4) && (this.find[r].pos = this.currentPos); 1648 } 1649 findInText(e) { 1650 if (this.find) for (let t = 0; t < this.find.length; t++) this.find[t].node == e && (this.find[t].pos = this.currentPos - (e.nodeValue.length - this.find[t].offset)); 1651 } 1652 matchesContext(e) { 1653 if (e.indexOf("|") > -1) return e.split(/\s*\|\s*/).some(this.matchesContext, this); 1654 let t = e.split("/"), n = this.options.context, r = !this.isOpen && (!n || n.parent.type == this.nodes[0].type), i = -(n ? n.depth + 1 : 0) + +!r, a = (e, o) => { 1655 for (; e >= 0; e--) { 1656 let s = t[e]; 1657 if (s == "") { 1658 if (e == t.length - 1 || e == 0) continue; 1659 for (; o >= i; o--) if (a(e - 1, o)) return !0; 1660 return !1; 1661 } else { 1662 let e = o > 0 || o == 0 && r ? this.nodes[o].type : n && o >= i ? n.node(o - i).type : null; 1663 if (!e || e.name != s && !e.isInGroup(s)) return !1; 1664 o--; 1665 } 1666 } 1667 return !0; 1668 }; 1669 return a(t.length - 1, this.open); 1670 } 1671 textblockFromContext() { 1672 let e = this.options.context; 1673 if (e) for (let t = e.depth; t >= 0; t--) { 1674 let n = e.node(t).contentMatchAt(e.indexAfter(t)).defaultType; 1675 if (n && n.isTextblock && n.defaultAttrs) return n; 1676 } 1677 for (let e in this.parser.schema.nodes) { 1678 let t = this.parser.schema.nodes[e]; 1679 if (t.isTextblock && t.defaultAttrs) return t; 1680 } 1681 } 1682}; 1683function Je(e) { 1684 for (let t = e.firstChild, n = null; t; t = t.nextSibling) { 1685 let e = t.nodeType == 1 ? t.nodeName.toLowerCase() : null; 1686 e && Ve.hasOwnProperty(e) && n ? (n.appendChild(t), t = n) : e == "li" ? n = t : e && (n = null); 1687 } 1688} 1689function Ye(e, t) { 1690 return (e.matches || e.msMatchesSelector || e.webkitMatchesSelector || e.mozMatchesSelector).call(e, t); 1691} 1692function Xe(e) { 1693 let t = {}; 1694 for (let n in e) t[n] = e[n]; 1695 return t; 1696} 1697function Ze(e, t) { 1698 let n = t.schema.nodes; 1699 for (let r in n) { 1700 let i = n[r]; 1701 if (!i.allowsMarkType(e)) continue; 1702 let a = [], o = (e) => { 1703 a.push(e); 1704 for (let n = 0; n < e.edgeCount; n++) { 1705 let { type: r, next: i } = e.edge(n); 1706 if (r == t || a.indexOf(i) < 0 && o(i)) return !0; 1707 } 1708 }; 1709 if (o(i.contentMatch)) return !0; 1710 } 1711} 1712var Qe = class e { 1713 constructor(e, t) { 1714 this.nodes = e, this.marks = t; 1715 } 1716 serializeFragment(e, t = {}, n) { 1717 n ||= et(t).createDocumentFragment(); 1718 let r = n, i = []; 1719 return e.forEach((e) => { 1720 if (i.length || e.marks.length) { 1721 let n = 0, a = 0; 1722 for (; n < i.length && a < e.marks.length;) { 1723 let t = e.marks[a]; 1724 if (!this.marks[t.type.name]) { 1725 a++; 1726 continue; 1727 } 1728 if (!t.eq(i[n][0]) || t.type.spec.spanning === !1) break; 1729 n++, a++; 1730 } 1731 for (; n < i.length;) r = i.pop()[1]; 1732 for (; a < e.marks.length;) { 1733 let n = e.marks[a++], o = this.serializeMark(n, e.isInline, t); 1734 o && (i.push([n, r]), r.appendChild(o.dom), r = o.contentDOM || o.dom); 1735 } 1736 } 1737 r.appendChild(this.serializeNodeInner(e, t)); 1738 }), n; 1739 } 1740 serializeNodeInner(e, t) { 1741 if (e.isText) return et(t).createTextNode(e.text); 1742 let { dom: n, contentDOM: r } = it(et(t), this.nodes[e.type.name](e), null, e.attrs); 1743 if (r) { 1744 if (e.isLeaf) throw RangeError("Content hole not allowed in a leaf node spec"); 1745 this.serializeFragment(e.content, t, r); 1746 } 1747 return n; 1748 } 1749 serializeNode(e, t = {}) { 1750 let n = this.serializeNodeInner(e, t); 1751 for (let r = e.marks.length - 1; r >= 0; r--) { 1752 let i = this.serializeMark(e.marks[r], e.isInline, t); 1753 i && ((i.contentDOM || i.dom).appendChild(n), n = i.dom); 1754 } 1755 return n; 1756 } 1757 serializeMark(e, t, n = {}) { 1758 let r = this.marks[e.type.name]; 1759 return r && it(et(n), r(e, t), null, e.attrs); 1760 } 1761 static renderSpec(e, t, n = null, r) { 1762 return typeof t == "string" ? { dom: e.createTextNode(t) } : it(e, t, n, r); 1763 } 1764 static fromSchema(t) { 1765 return t.cached.domSerializer || (t.cached.domSerializer = new e(this.nodesFromSchema(t), this.marksFromSchema(t))); 1766 } 1767 static nodesFromSchema(e) { 1768 let t = $e(e.nodes); 1769 return t.text ||= (e) => e.text, t; 1770 } 1771 static marksFromSchema(e) { 1772 return $e(e.marks); 1773 } 1774}; 1775function $e(e) { 1776 let t = {}; 1777 for (let n in e) { 1778 let r = e[n].spec.toDOM; 1779 r && (t[n] = r); 1780 } 1781 return t; 1782} 1783function et(e) { 1784 return e.document || window.document; 1785} 1786var tt = /* @__PURE__ */ new WeakMap(); 1787function nt(e) { 1788 let t = tt.get(e); 1789 return t === void 0 && tt.set(e, t = rt(e)), t; 1790} 1791function rt(e) { 1792 let t = null; 1793 function n(e) { 1794 if (e && typeof e == "object") if (Array.isArray(e)) if (typeof e[0] == "string") t ||= [], t.push(e); 1795 else for (let t = 0; t < e.length; t++) n(e[t]); 1796 else for (let t in e) n(e[t]); 1797 } 1798 return n(e), t; 1799} 1800function it(e, t, n, r) { 1801 if (t.nodeType == 1) return { dom: t }; 1802 if (t.dom && t.dom.nodeType == 1) return t; 1803 let i = t[0], a; 1804 if (typeof i != "string") throw RangeError("Invalid array passed to renderSpec"); 1805 if (r && (a = nt(r)) && a.indexOf(t) > -1) throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack."); 1806 let o = i.indexOf(" "); 1807 o > 0 && (n = i.slice(0, o), i = i.slice(o + 1)); 1808 let s, c = n ? e.createElementNS(n, i) : e.createElement(i), l = t[1], u = 1; 1809 if (l && typeof l == "object" && l.nodeType == null && !Array.isArray(l)) { 1810 u = 2; 1811 for (let e in l) if (l[e] != null) { 1812 let t = e.indexOf(" "); 1813 t > 0 ? c.setAttributeNS(e.slice(0, t), e.slice(t + 1), l[e]) : e == "style" && c.style ? c.style.cssText = l[e] : c.setAttribute(e, l[e]); 1814 } 1815 } 1816 for (let i = u; i < t.length; i++) { 1817 let a = t[i]; 1818 if (a === 0) { 1819 if (i < t.length - 1 || i > u) throw RangeError("Content hole must be the only child of its parent node"); 1820 return { 1821 dom: c, 1822 contentDOM: c 1823 }; 1824 } else if (typeof a == "string") c.appendChild(e.createTextNode(a)); 1825 else { 1826 let { dom: t, contentDOM: i } = it(e, a, n, r); 1827 if (c.appendChild(t), i) { 1828 if (s) throw RangeError("Multiple content holes"); 1829 s = i; 1830 } 1831 } 1832 } 1833 return { 1834 dom: c, 1835 contentDOM: s 1836 }; 1837} 1838//#endregion 1839//#region node_modules/prosemirror-transform/dist/index.js 1840var at = 65535, ot = 2 ** 16; 1841function st(e, t) { 1842 return e + t * ot; 1843} 1844function ct(e) { 1845 return e & at; 1846} 1847function lt(e) { 1848 return (e - (e & at)) / ot; 1849} 1850var ut = 1, dt = 2, ft = 4, pt = 8, mt = class { 1851 constructor(e, t, n) { 1852 this.pos = e, this.delInfo = t, this.recover = n; 1853 } 1854 get deleted() { 1855 return (this.delInfo & pt) > 0; 1856 } 1857 get deletedBefore() { 1858 return (this.delInfo & 5) > 0; 1859 } 1860 get deletedAfter() { 1861 return (this.delInfo & 6) > 0; 1862 } 1863 get deletedAcross() { 1864 return (this.delInfo & ft) > 0; 1865 } 1866}, ht = class e { 1867 constructor(t, n = !1) { 1868 if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty; 1869 } 1870 recover(e) { 1871 let t = 0, n = ct(e); 1872 if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1]; 1873 return this.ranges[n * 3] + t + lt(e); 1874 } 1875 mapResult(e, t = 1) { 1876 return this._map(e, t, !1); 1877 } 1878 map(e, t = 1) { 1879 return this._map(e, t, !0); 1880 } 1881 _map(e, t, n) { 1882 let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2; 1883 for (let o = 0; o < this.ranges.length; o += 3) { 1884 let s = this.ranges[o] - (this.inverted ? r : 0); 1885 if (s > e) break; 1886 let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c; 1887 if (e <= u) { 1888 let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l); 1889 if (n) return a; 1890 let d = e == (t < 0 ? s : u) ? null : st(o / 3, e - s), f = e == s ? dt : e == u ? ut : ft; 1891 return (t < 0 ? e != s : e != u) && (f |= pt), new mt(a, f, d); 1892 } 1893 r += l - c; 1894 } 1895 return n ? e + r : new mt(e + r, 0, null); 1896 } 1897 touches(e, t) { 1898 let n = 0, r = ct(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2; 1899 for (let t = 0; t < this.ranges.length; t += 3) { 1900 let o = this.ranges[t] - (this.inverted ? n : 0); 1901 if (o > e) break; 1902 let s = this.ranges[t + i]; 1903 if (e <= o + s && t == r * 3) return !0; 1904 n += this.ranges[t + a] - s; 1905 } 1906 return !1; 1907 } 1908 forEach(e) { 1909 let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2; 1910 for (let r = 0, i = 0; r < this.ranges.length; r += 3) { 1911 let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n]; 1912 e(o, o + c, s, s + l), i += l - c; 1913 } 1914 } 1915 invert() { 1916 return new e(this.ranges, !this.inverted); 1917 } 1918 toString() { 1919 return (this.inverted ? "-" : "") + JSON.stringify(this.ranges); 1920 } 1921 static offset(t) { 1922 return t == 0 ? e.empty : new e(t < 0 ? [ 1923 0, 1924 -t, 1925 0 1926 ] : [ 1927 0, 1928 0, 1929 t 1930 ]); 1931 } 1932}; 1933ht.empty = new ht([]); 1934var gt = class e { 1935 constructor(e, t, n = 0, r = e ? e.length : 0) { 1936 this.mirror = t, this.from = n, this.to = r, this._maps = e || [], this.ownData = !(e || t); 1937 } 1938 get maps() { 1939 return this._maps; 1940 } 1941 slice(t = 0, n = this.maps.length) { 1942 return new e(this._maps, this.mirror, t, n); 1943 } 1944 appendMap(e, t) { 1945 this.ownData ||= (this._maps = this._maps.slice(), this.mirror = this.mirror && this.mirror.slice(), !0), this.to = this._maps.push(e), t != null && this.setMirror(this._maps.length - 1, t); 1946 } 1947 appendMapping(e) { 1948 for (let t = 0, n = this._maps.length; t < e._maps.length; t++) { 1949 let r = e.getMirror(t); 1950 this.appendMap(e._maps[t], r != null && r < t ? n + r : void 0); 1951 } 1952 } 1953 getMirror(e) { 1954 if (this.mirror) { 1955 for (let t = 0; t < this.mirror.length; t++) if (this.mirror[t] == e) return this.mirror[t + (t % 2 ? -1 : 1)]; 1956 } 1957 } 1958 setMirror(e, t) { 1959 this.mirror ||= [], this.mirror.push(e, t); 1960 } 1961 appendMappingInverted(e) { 1962 for (let t = e.maps.length - 1, n = this._maps.length + e._maps.length; t >= 0; t--) { 1963 let r = e.getMirror(t); 1964 this.appendMap(e._maps[t].invert(), r != null && r > t ? n - r - 1 : void 0); 1965 } 1966 } 1967 invert() { 1968 let t = new e(); 1969 return t.appendMappingInverted(this), t; 1970 } 1971 map(e, t = 1) { 1972 if (this.mirror) return this._map(e, t, !0); 1973 for (let n = this.from; n < this.to; n++) e = this._maps[n].map(e, t); 1974 return e; 1975 } 1976 mapResult(e, t = 1) { 1977 return this._map(e, t, !1); 1978 } 1979 _map(e, t, n) { 1980 let r = 0; 1981 for (let n = this.from; n < this.to; n++) { 1982 let i = this._maps[n].mapResult(e, t); 1983 if (i.recover != null) { 1984 let t = this.getMirror(n); 1985 if (t != null && t > n && t < this.to) { 1986 n = t, e = this._maps[t].recover(i.recover); 1987 continue; 1988 } 1989 } 1990 r |= i.delInfo, e = i.pos; 1991 } 1992 return n ? e : new mt(e, r, null); 1993 } 1994}, _t = Object.create(null), x = class { 1995 getMap() { 1996 return ht.empty; 1997 } 1998 merge(e) { 1999 return null; 2000 } 2001 static fromJSON(e, t) { 2002 if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON"); 2003 let n = _t[t.stepType]; 2004 if (!n) throw RangeError(`No step type ${t.stepType} defined`); 2005 return n.fromJSON(e, t); 2006 } 2007 static jsonID(e, t) { 2008 if (e in _t) throw RangeError("Duplicate use of step JSON ID " + e); 2009 return _t[e] = t, t.prototype.jsonID = e, t; 2010 } 2011}, S = class e { 2012 constructor(e, t) { 2013 this.doc = e, this.failed = t; 2014 } 2015 static ok(t) { 2016 return new e(t, null); 2017 } 2018 static fail(t) { 2019 return new e(null, t); 2020 } 2021 static fromReplace(t, n, r, i) { 2022 try { 2023 return e.ok(t.replace(n, r, i)); 2024 } catch (t) { 2025 if (t instanceof u) return e.fail(t.message); 2026 throw t; 2027 } 2028 } 2029}; 2030function vt(e, t, n) { 2031 let r = []; 2032 for (let i = 0; i < e.childCount; i++) { 2033 let a = e.child(i); 2034 a.content.size && (a = a.copy(vt(a.content, t, a))), a.isInline && (a = t(a, n, i)), r.push(a); 2035 } 2036 return a.fromArray(r); 2037} 2038var yt = class e extends x { 2039 constructor(e, t, n) { 2040 super(), this.from = e, this.to = t, this.mark = n; 2041 } 2042 apply(e) { 2043 let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new d(vt(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd); 2044 return S.fromReplace(e, this.from, this.to, i); 2045 } 2046 invert() { 2047 return new bt(this.from, this.to, this.mark); 2048 } 2049 map(t) { 2050 let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1); 2051 return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark); 2052 } 2053 merge(t) { 2054 return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null; 2055 } 2056 toJSON() { 2057 return { 2058 stepType: "addMark", 2059 mark: this.mark.toJSON(), 2060 from: this.from, 2061 to: this.to 2062 }; 2063 } 2064 static fromJSON(t, n) { 2065 if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON"); 2066 return new e(n.from, n.to, t.markFromJSON(n.mark)); 2067 } 2068}; 2069x.jsonID("addMark", yt); 2070var bt = class e extends x { 2071 constructor(e, t, n) { 2072 super(), this.from = e, this.to = t, this.mark = n; 2073 } 2074 apply(e) { 2075 let t = e.slice(this.from, this.to), n = new d(vt(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd); 2076 return S.fromReplace(e, this.from, this.to, n); 2077 } 2078 invert() { 2079 return new yt(this.from, this.to, this.mark); 2080 } 2081 map(t) { 2082 let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1); 2083 return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark); 2084 } 2085 merge(t) { 2086 return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null; 2087 } 2088 toJSON() { 2089 return { 2090 stepType: "removeMark", 2091 mark: this.mark.toJSON(), 2092 from: this.from, 2093 to: this.to 2094 }; 2095 } 2096 static fromJSON(t, n) { 2097 if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON"); 2098 return new e(n.from, n.to, t.markFromJSON(n.mark)); 2099 } 2100}; 2101x.jsonID("removeMark", bt); 2102var xt = class e extends x { 2103 constructor(e, t) { 2104 super(), this.pos = e, this.mark = t; 2105 } 2106 apply(e) { 2107 let t = e.nodeAt(this.pos); 2108 if (!t) return S.fail("No node at mark step's position"); 2109 let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks)); 2110 return S.fromReplace(e, this.pos, this.pos + 1, new d(a.from(n), 0, +!t.isLeaf)); 2111 } 2112 invert(t) { 2113 let n = t.nodeAt(this.pos); 2114 if (n) { 2115 let t = this.mark.addToSet(n.marks); 2116 if (t.length == n.marks.length) { 2117 for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]); 2118 return new e(this.pos, this.mark); 2119 } 2120 } 2121 return new St(this.pos, this.mark); 2122 } 2123 map(t) { 2124 let n = t.mapResult(this.pos, 1); 2125 return n.deletedAfter ? null : new e(n.pos, this.mark); 2126 } 2127 toJSON() { 2128 return { 2129 stepType: "addNodeMark", 2130 pos: this.pos, 2131 mark: this.mark.toJSON() 2132 }; 2133 } 2134 static fromJSON(t, n) { 2135 if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON"); 2136 return new e(n.pos, t.markFromJSON(n.mark)); 2137 } 2138}; 2139x.jsonID("addNodeMark", xt); 2140var St = class e extends x { 2141 constructor(e, t) { 2142 super(), this.pos = e, this.mark = t; 2143 } 2144 apply(e) { 2145 let t = e.nodeAt(this.pos); 2146 if (!t) return S.fail("No node at mark step's position"); 2147 let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks)); 2148 return S.fromReplace(e, this.pos, this.pos + 1, new d(a.from(n), 0, +!t.isLeaf)); 2149 } 2150 invert(e) { 2151 let t = e.nodeAt(this.pos); 2152 return !t || !this.mark.isInSet(t.marks) ? this : new xt(this.pos, this.mark); 2153 } 2154 map(t) { 2155 let n = t.mapResult(this.pos, 1); 2156 return n.deletedAfter ? null : new e(n.pos, this.mark); 2157 } 2158 toJSON() { 2159 return { 2160 stepType: "removeNodeMark", 2161 pos: this.pos, 2162 mark: this.mark.toJSON() 2163 }; 2164 } 2165 static fromJSON(t, n) { 2166 if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON"); 2167 return new e(n.pos, t.markFromJSON(n.mark)); 2168 } 2169}; 2170x.jsonID("removeNodeMark", St); 2171var Ct = class e extends x { 2172 constructor(e, t, n, r = !1) { 2173 super(), this.from = e, this.to = t, this.slice = n, this.structure = r; 2174 } 2175 apply(e) { 2176 return this.structure && wt(e, this.from, this.to) ? S.fail("Structure replace would overwrite content") : S.fromReplace(e, this.from, this.to, this.slice); 2177 } 2178 getMap() { 2179 return new ht([ 2180 this.from, 2181 this.to - this.from, 2182 this.slice.size 2183 ]); 2184 } 2185 invert(t) { 2186 return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to)); 2187 } 2188 map(t) { 2189 let n = t.mapResult(this.to, -1), r = this.from == this.to && e.MAP_BIAS < 0 ? n : t.mapResult(this.from, 1); 2190 return r.deletedAcross && n.deletedAcross ? null : new e(r.pos, Math.max(r.pos, n.pos), this.slice, this.structure); 2191 } 2192 merge(t) { 2193 if (!(t instanceof e) || t.structure || this.structure) return null; 2194 if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) { 2195 let n = this.slice.size + t.slice.size == 0 ? d.empty : new d(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd); 2196 return new e(this.from, this.to + (t.to - t.from), n, this.structure); 2197 } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) { 2198 let n = this.slice.size + t.slice.size == 0 ? d.empty : new d(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd); 2199 return new e(t.from, this.to, n, this.structure); 2200 } else return null; 2201 } 2202 toJSON() { 2203 let e = { 2204 stepType: "replace", 2205 from: this.from, 2206 to: this.to 2207 }; 2208 return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e; 2209 } 2210 static fromJSON(t, n) { 2211 if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON"); 2212 return new e(n.from, n.to, d.fromJSON(t, n.slice), !!n.structure); 2213 } 2214}; 2215Ct.MAP_BIAS = 1, x.jsonID("replace", Ct); 2216var C = class e extends x { 2217 constructor(e, t, n, r, i, a, o = !1) { 2218 super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o; 2219 } 2220 apply(e) { 2221 if (this.structure && (wt(e, this.from, this.gapFrom) || wt(e, this.gapTo, this.to))) return S.fail("Structure gap-replace would overwrite content"); 2222 let t = e.slice(this.gapFrom, this.gapTo); 2223 if (t.openStart || t.openEnd) return S.fail("Gap is not a flat range"); 2224 let n = this.slice.insertAt(this.insert, t.content); 2225 return n ? S.fromReplace(e, this.from, this.to, n) : S.fail("Content does not fit in gap"); 2226 } 2227 getMap() { 2228 return new ht([ 2229 this.from, 2230 this.gapFrom - this.from, 2231 this.insert, 2232 this.gapTo, 2233 this.to - this.gapTo, 2234 this.slice.size - this.insert 2235 ]); 2236 } 2237 invert(t) { 2238 let n = this.gapTo - this.gapFrom; 2239 return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure); 2240 } 2241 map(t) { 2242 let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1); 2243 return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure); 2244 } 2245 toJSON() { 2246 let e = { 2247 stepType: "replaceAround", 2248 from: this.from, 2249 to: this.to, 2250 gapFrom: this.gapFrom, 2251 gapTo: this.gapTo, 2252 insert: this.insert 2253 }; 2254 return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e; 2255 } 2256 static fromJSON(t, n) { 2257 if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON"); 2258 return new e(n.from, n.to, n.gapFrom, n.gapTo, d.fromJSON(t, n.slice), n.insert, !!n.structure); 2259 } 2260}; 2261x.jsonID("replaceAround", C); 2262function wt(e, t, n) { 2263 let r = e.resolve(t), i = n - t, a = r.depth; 2264 for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--; 2265 if (i > 0) { 2266 let e = r.node(a).maybeChild(r.indexAfter(a)); 2267 for (; i > 0;) { 2268 if (!e || e.isLeaf) return !0; 2269 e = e.firstChild, i--; 2270 } 2271 } 2272 return !1; 2273} 2274function Tt(e, t, n, r) { 2275 let i = [], a = [], o, s; 2276 e.doc.nodesBetween(t, n, (e, c, l) => { 2277 if (!e.isInline) return; 2278 let u = e.marks; 2279 if (!r.isInSet(u) && l.type.allowsMarkType(r.type)) { 2280 let l = Math.max(c, t), d = Math.min(c + e.nodeSize, n), f = r.addToSet(u); 2281 for (let e = 0; e < u.length; e++) u[e].isInSet(f) || (o && o.to == l && o.mark.eq(u[e]) ? o.to = d : i.push(o = new bt(l, d, u[e]))); 2282 s && s.to == l ? s.to = d : a.push(s = new yt(l, d, r)); 2283 } 2284 }), i.forEach((t) => e.step(t)), a.forEach((t) => e.step(t)); 2285} 2286function Et(e, t, n, r) { 2287 let i = [], a = 0; 2288 e.doc.nodesBetween(t, n, (e, o) => { 2289 if (!e.isInline) return; 2290 a++; 2291 let s = null; 2292 if (r instanceof Ne) { 2293 let t = e.marks, n; 2294 for (; n = r.isInSet(t);) (s ||= []).push(n), t = n.removeFromSet(t); 2295 } else r ? r.isInSet(e.marks) && (s = [r]) : s = e.marks; 2296 if (s && s.length) { 2297 let r = Math.min(o + e.nodeSize, n); 2298 for (let e = 0; e < s.length; e++) { 2299 let n = s[e], c; 2300 for (let e = 0; e < i.length; e++) { 2301 let t = i[e]; 2302 t.step == a - 1 && n.eq(i[e].style) && (c = t); 2303 } 2304 c ? (c.to = r, c.step = a) : i.push({ 2305 style: n, 2306 from: Math.max(o, t), 2307 to: r, 2308 step: a 2309 }); 2310 } 2311 } 2312 }), i.forEach((t) => e.step(new bt(t.from, t.to, t.style))); 2313} 2314function Dt(e, t, n, r = n.contentMatch, i = !0) { 2315 let o = e.doc.nodeAt(t), s = [], c = t + 1; 2316 for (let t = 0; t < o.childCount; t++) { 2317 let l = o.child(t), u = c + l.nodeSize, f = r.matchType(l.type); 2318 if (!f) s.push(new Ct(c, u, d.empty)); 2319 else { 2320 r = f; 2321 for (let t = 0; t < l.marks.length; t++) n.allowsMarkType(l.marks[t].type) || e.step(new bt(c, u, l.marks[t])); 2322 if (i && l.isText && n.whitespace != "pre") { 2323 let e, t = /\r?\n|\r/g, r; 2324 for (; e = t.exec(l.text);) r ||= new d(a.from(n.schema.text(" ", n.allowedMarks(l.marks))), 0, 0), s.push(new Ct(c + e.index, c + e.index + e[0].length, r)); 2325 } 2326 } 2327 c = u; 2328 } 2329 if (!r.validEnd) { 2330 let t = r.fillBefore(a.empty, !0); 2331 e.replace(c, c, new d(t, 0, 0)); 2332 } 2333 for (let t = s.length - 1; t >= 0; t--) e.step(s[t]); 2334} 2335function Ot(e, t, n) { 2336 return (t == 0 || e.canReplace(t, e.childCount)) && (n == e.childCount || e.canReplace(0, n)); 2337} 2338function kt(e) { 2339 let t = e.parent.content.cutByIndex(e.startIndex, e.endIndex); 2340 for (let n = e.depth, r = 0, i = 0;; --n) { 2341 let a = e.$from.node(n), o = e.$from.index(n) + r, s = e.$to.indexAfter(n) - i; 2342 if (n < e.depth && a.canReplace(o, s, t)) return n; 2343 if (n == 0 || a.type.spec.isolating || !Ot(a, o, s)) break; 2344 o && (r = 1), s < a.childCount && (i = 1); 2345 } 2346 return null; 2347} 2348function At(e, t, n) { 2349 let { $from: r, $to: i, depth: o } = t, s = r.before(o + 1), c = i.after(o + 1), l = s, u = c, f = a.empty, p = 0; 2350 for (let e = o, t = !1; e > n; e--) t || r.index(e) > 0 ? (t = !0, f = a.from(r.node(e).copy(f)), p++) : l--; 2351 let m = a.empty, h = 0; 2352 for (let e = o, t = !1; e > n; e--) t || i.after(e + 1) < i.end(e) ? (t = !0, m = a.from(i.node(e).copy(m)), h++) : u++; 2353 e.step(new C(l, u, s, c, new d(f.append(m), p, h), f.size - p, !0)); 2354} 2355function jt(e, t, n = null, r = e) { 2356 let i = Nt(e, t), a = i && Pt(r, t); 2357 return a ? i.map(Mt).concat({ 2358 type: t, 2359 attrs: n 2360 }).concat(a.map(Mt)) : null; 2361} 2362function Mt(e) { 2363 return { 2364 type: e, 2365 attrs: null 2366 }; 2367} 2368function Nt(e, t) { 2369 let { parent: n, startIndex: r, endIndex: i } = e, a = n.contentMatchAt(r).findWrapping(t); 2370 if (!a) return null; 2371 let o = a.length ? a[0] : t; 2372 return n.canReplaceWith(r, i, o) ? a : null; 2373} 2374function Pt(e, t) { 2375 let { parent: n, startIndex: r, endIndex: i } = e, a = n.child(r), o = t.contentMatch.findWrapping(a.type); 2376 if (!o) return null; 2377 let s = (o.length ? o[o.length - 1] : t).contentMatch; 2378 for (let e = r; s && e < i; e++) s = s.matchType(n.child(e).type); 2379 return !s || !s.validEnd ? null : o; 2380} 2381function Ft(e, t, n) { 2382 let r = a.empty; 2383 for (let e = n.length - 1; e >= 0; e--) { 2384 if (r.size) { 2385 let t = n[e].type.contentMatch.matchFragment(r); 2386 if (!t || !t.validEnd) throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper"); 2387 } 2388 r = a.from(n[e].type.create(n[e].attrs, r)); 2389 } 2390 let i = t.start, o = t.end; 2391 e.step(new C(i, o, i, o, new d(r, 0, 0), n.length, !0)); 2392} 2393function It(e, t, n, r, i) { 2394 if (!r.isTextblock) throw RangeError("Type given to setBlockType should be a textblock"); 2395 let o = e.steps.length; 2396 e.doc.nodesBetween(t, n, (t, n) => { 2397 let s = typeof i == "function" ? i(t) : i; 2398 if (t.isTextblock && !t.hasMarkup(r, s) && zt(e.doc, e.mapping.slice(o).map(n), r)) { 2399 let i = null; 2400 if (r.schema.linebreakReplacement) { 2401 let e = r.whitespace == "pre", t = !!r.contentMatch.matchType(r.schema.linebreakReplacement); 2402 e && !t ? i = !1 : !e && t && (i = !0); 2403 } 2404 i === !1 && Rt(e, t, n, o), Dt(e, e.mapping.slice(o).map(n, 1), r, void 0, i === null); 2405 let c = e.mapping.slice(o), l = c.map(n, 1), u = c.map(n + t.nodeSize, 1); 2406 return e.step(new C(l, u, l + 1, u - 1, new d(a.from(r.create(s, null, t.marks)), 0, 0), 1, !0)), i === !0 && Lt(e, t, n, o), !1; 2407 } 2408 }); 2409} 2410function Lt(e, t, n, r) { 2411 t.forEach((i, a) => { 2412 if (i.isText) { 2413 let o, s = /\r?\n|\r/g; 2414 for (; o = s.exec(i.text);) { 2415 let i = e.mapping.slice(r).map(n + 1 + a + o.index); 2416 e.replaceWith(i, i + 1, t.type.schema.linebreakReplacement.create()); 2417 } 2418 } 2419 }); 2420} 2421function Rt(e, t, n, r) { 2422 t.forEach((i, a) => { 2423 if (i.type == i.type.schema.linebreakReplacement) { 2424 let i = e.mapping.slice(r).map(n + 1 + a); 2425 e.replaceWith(i, i + 1, t.type.schema.text("\n")); 2426 } 2427 }); 2428} 2429function zt(e, t, n) { 2430 let r = e.resolve(t), i = r.index(); 2431 return r.parent.canReplaceWith(i, i + 1, n); 2432} 2433function Bt(e, t, n, r, i) { 2434 let o = e.doc.nodeAt(t); 2435 if (!o) throw RangeError("No node at given position"); 2436 n ||= o.type; 2437 let s = n.create(r, null, i || o.marks); 2438 if (o.isLeaf) return e.replaceWith(t, t + o.nodeSize, s); 2439 if (!n.validContent(o.content)) throw RangeError("Invalid content for node type " + n.name); 2440 e.step(new C(t, t + o.nodeSize, t + 1, t + o.nodeSize - 1, new d(a.from(s), 0, 0), 1, !0)); 2441} 2442function Vt(e, t, n = 1, r) { 2443 let i = e.resolve(t), a = i.depth - n, o = r && r[r.length - 1] || i.parent; 2444 if (a < 0 || i.parent.type.spec.isolating || !i.parent.canReplace(i.index(), i.parent.childCount) || !o.type.validContent(i.parent.content.cutByIndex(i.index(), i.parent.childCount))) return !1; 2445 for (let e = i.depth - 1, t = n - 2; e > a; e--, t--) { 2446 let n = i.node(e), a = i.index(e); 2447 if (n.type.spec.isolating) return !1; 2448 let o = n.content.cutByIndex(a, n.childCount), s = r && r[t + 1]; 2449 s && (o = o.replaceChild(0, s.type.create(s.attrs))); 2450 let c = r && r[t] || n; 2451 if (!n.canReplace(a + 1, n.childCount) || !c.type.validContent(o)) return !1; 2452 } 2453 let s = i.indexAfter(a), c = r && r[0]; 2454 return i.node(a).canReplaceWith(s, s, c ? c.type : i.node(a + 1).type); 2455} 2456function Ht(e, t, n = 1, r) { 2457 let i = e.doc.resolve(t), o = a.empty, s = a.empty; 2458 for (let e = i.depth, t = i.depth - n, c = n - 1; e > t; e--, c--) { 2459 o = a.from(i.node(e).copy(o)); 2460 let t = r && r[c]; 2461 s = a.from(t ? t.type.create(t.attrs, s) : i.node(e).copy(s)); 2462 } 2463 e.step(new Ct(t, t, new d(o.append(s), n, n), !0)); 2464} 2465function Ut(e, t) { 2466 let n = e.resolve(t), r = n.index(); 2467 return Gt(n.nodeBefore, n.nodeAfter) && n.parent.canReplace(r, r + 1); 2468} 2469function Wt(e, t) { 2470 t.content.size || e.type.compatibleContent(t.type); 2471 let n = e.contentMatchAt(e.childCount), { linebreakReplacement: r } = e.type.schema; 2472 for (let i = 0; i < t.childCount; i++) { 2473 let a = t.child(i), o = a.type == r ? e.type.schema.nodes.text : a.type; 2474 if (n = n.matchType(o), !n || !e.type.allowsMarks(a.marks)) return !1; 2475 } 2476 return n.validEnd; 2477} 2478function Gt(e, t) { 2479 return !!(e && t && !e.isLeaf && Wt(e, t)); 2480} 2481function Kt(e, t, n = -1) { 2482 let r = e.resolve(t); 2483 for (let e = r.depth;; e--) { 2484 let i, a, o = r.index(e); 2485 if (e == r.depth ? (i = r.nodeBefore, a = r.nodeAfter) : n > 0 ? (i = r.node(e + 1), o++, a = r.node(e).maybeChild(o)) : (i = r.node(e).maybeChild(o - 1), a = r.node(e + 1)), i && !i.isTextblock && Gt(i, a) && r.node(e).canReplace(o, o + 1)) return t; 2486 if (e == 0) break; 2487 t = n < 0 ? r.before(e) : r.after(e); 2488 } 2489} 2490function qt(e, t, n) { 2491 let r = null, { linebreakReplacement: i } = e.doc.type.schema, a = e.doc.resolve(t - n), o = a.node().type; 2492 if (i && o.inlineContent) { 2493 let e = o.whitespace == "pre", t = !!o.contentMatch.matchType(i); 2494 e && !t ? r = !1 : !e && t && (r = !0); 2495 } 2496 let s = e.steps.length; 2497 if (r === !1) { 2498 let r = e.doc.resolve(t + n); 2499 Rt(e, r.node(), r.before(), s); 2500 } 2501 o.inlineContent && Dt(e, t + n - 1, o, a.node().contentMatchAt(a.index()), r == null); 2502 let c = e.mapping.slice(s), l = c.map(t - n); 2503 if (e.step(new Ct(l, c.map(t + n, -1), d.empty, !0)), r === !0) { 2504 let t = e.doc.resolve(l); 2505 Lt(e, t.node(), t.before(), e.steps.length); 2506 } 2507 return e; 2508} 2509function Jt(e, t, n) { 2510 let r = e.resolve(t); 2511 if (r.parent.canReplaceWith(r.index(), r.index(), n)) return t; 2512 if (r.parentOffset == 0) for (let e = r.depth - 1; e >= 0; e--) { 2513 let t = r.index(e); 2514 if (r.node(e).canReplaceWith(t, t, n)) return r.before(e + 1); 2515 if (t > 0) return null; 2516 } 2517 if (r.parentOffset == r.parent.content.size) for (let e = r.depth - 1; e >= 0; e--) { 2518 let t = r.indexAfter(e); 2519 if (r.node(e).canReplaceWith(t, t, n)) return r.after(e + 1); 2520 if (t < r.node(e).childCount) return null; 2521 } 2522 return null; 2523} 2524function Yt(e, t, n) { 2525 let r = e.resolve(t); 2526 if (!n.content.size) return t; 2527 let i = n.content; 2528 for (let e = 0; e < n.openStart; e++) i = i.firstChild.content; 2529 for (let e = 1; e <= (n.openStart == 0 && n.size ? 2 : 1); e++) for (let t = r.depth; t >= 0; t--) { 2530 let n = t == r.depth ? 0 : r.pos <= (r.start(t + 1) + r.end(t + 1)) / 2 ? -1 : 1, a = r.index(t) + +(n > 0), o = r.node(t), s = !1; 2531 if (e == 1) s = o.canReplace(a, a, i); 2532 else { 2533 let e = o.contentMatchAt(a).findWrapping(i.firstChild.type); 2534 s = e && o.canReplaceWith(a, a, e[0]); 2535 } 2536 if (s) return n == 0 ? r.pos : n < 0 ? r.before(t + 1) : r.after(t + 1); 2537 } 2538 return null; 2539} 2540function Xt(e, t, n = t, r = d.empty) { 2541 if (t == n && !r.size) return null; 2542 let i = e.resolve(t), a = e.resolve(n); 2543 return Zt(i, a, r) ? new Ct(t, n, r) : new Qt(i, a, r).fit(); 2544} 2545function Zt(e, t, n) { 2546 return !n.openStart && !n.openEnd && e.start() == t.start() && e.parent.canReplace(e.index(), t.index(), n.content); 2547} 2548var Qt = class { 2549 constructor(e, t, n) { 2550 this.$from = e, this.$to = t, this.unplaced = n, this.frontier = [], this.placed = a.empty; 2551 for (let t = 0; t <= e.depth; t++) { 2552 let n = e.node(t); 2553 this.frontier.push({ 2554 type: n.type, 2555 match: n.contentMatchAt(e.indexAfter(t)) 2556 }); 2557 } 2558 for (let t = e.depth; t > 0; t--) this.placed = a.from(e.node(t).copy(this.placed)); 2559 } 2560 get depth() { 2561 return this.frontier.length - 1; 2562 } 2563 fit() { 2564 for (; this.unplaced.size;) { 2565 let e = this.findFittable(); 2566 e ? this.placeNodes(e) : this.openMore() || this.dropNode(); 2567 } 2568 let e = this.mustMoveInline(), t = this.placed.size - this.depth - this.$from.depth, n = this.$from, r = this.close(e < 0 ? this.$to : n.doc.resolve(e)); 2569 if (!r) return null; 2570 let i = this.placed, a = n.depth, o = r.depth; 2571 for (; a && o && i.childCount == 1;) i = i.firstChild.content, a--, o--; 2572 let s = new d(i, a, o); 2573 return e > -1 ? new C(n.pos, e, this.$to.pos, this.$to.end(), s, t) : s.size || n.pos != this.$to.pos ? new Ct(n.pos, r.pos, s) : null; 2574 } 2575 findFittable() { 2576 let e = this.unplaced.openStart; 2577 for (let t = this.unplaced.content, n = 0, r = this.unplaced.openEnd; n < e; n++) { 2578 let i = t.firstChild; 2579 if (t.childCount > 1 && (r = 0), i.type.spec.isolating && r <= n) { 2580 e = n; 2581 break; 2582 } 2583 t = i.content; 2584 } 2585 for (let t = 1; t <= 2; t++) for (let n = t == 1 ? e : this.unplaced.openStart; n >= 0; n--) { 2586 let e, r = null; 2587 n ? (r = tn(this.unplaced.content, n - 1).firstChild, e = r.content) : e = this.unplaced.content; 2588 let i = e.firstChild; 2589 for (let e = this.depth; e >= 0; e--) { 2590 let { type: o, match: s } = this.frontier[e], c, l = null; 2591 if (t == 1 && (i ? s.matchType(i.type) || (l = s.fillBefore(a.from(i), !1)) : r && o.compatibleContent(r.type))) return { 2592 sliceDepth: n, 2593 frontierDepth: e, 2594 parent: r, 2595 inject: l 2596 }; 2597 if (t == 2 && i && (c = s.findWrapping(i.type))) return { 2598 sliceDepth: n, 2599 frontierDepth: e, 2600 parent: r, 2601 wrap: c 2602 }; 2603 if (r && s.matchType(r.type)) break; 2604 } 2605 } 2606 } 2607 openMore() { 2608 let { content: e, openStart: t, openEnd: n } = this.unplaced, r = tn(e, t); 2609 return !r.childCount || r.firstChild.isLeaf ? !1 : (this.unplaced = new d(e, t + 1, Math.max(n, r.size + t >= e.size - n ? t + 1 : 0)), !0); 2610 } 2611 dropNode() { 2612 let { content: e, openStart: t, openEnd: n } = this.unplaced, r = tn(e, t); 2613 if (r.childCount <= 1 && t > 0) { 2614 let i = e.size - t <= t + r.size; 2615 this.unplaced = new d($t(e, t - 1, 1), t - 1, i ? t - 1 : n); 2616 } else this.unplaced = new d($t(e, t, 1), t, n); 2617 } 2618 placeNodes({ sliceDepth: e, frontierDepth: t, parent: n, inject: r, wrap: i }) { 2619 for (; this.depth > t;) this.closeFrontierNode(); 2620 if (i) for (let e = 0; e < i.length; e++) this.openFrontierNode(i[e]); 2621 let o = this.unplaced, s = n ? n.content : o.content, c = o.openStart - e, l = 0, u = [], { match: f, type: p } = this.frontier[t]; 2622 if (r) { 2623 for (let e = 0; e < r.childCount; e++) u.push(r.child(e)); 2624 f = f.matchFragment(r); 2625 } 2626 let m = s.size + e - (o.content.size - o.openEnd); 2627 for (; l < s.childCount;) { 2628 let e = s.child(l), t = f.matchType(e.type); 2629 if (!t) break; 2630 l++, (l > 1 || c == 0 || e.content.size) && (f = t, u.push(nn(e.mark(p.allowedMarks(e.marks)), l == 1 ? c : 0, l == s.childCount ? m : -1))); 2631 } 2632 let h = l == s.childCount; 2633 h || (m = -1), this.placed = en(this.placed, t, a.from(u)), this.frontier[t].match = f, h && m < 0 && n && n.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode(); 2634 for (let e = 0, t = s; e < m; e++) { 2635 let e = t.lastChild; 2636 this.frontier.push({ 2637 type: e.type, 2638 match: e.contentMatchAt(e.childCount) 2639 }), t = e.content; 2640 } 2641 this.unplaced = h ? e == 0 ? d.empty : new d($t(o.content, e - 1, 1), e - 1, m < 0 ? o.openEnd : e - 1) : new d($t(o.content, e, l), o.openStart, o.openEnd); 2642 } 2643 mustMoveInline() { 2644 if (!this.$to.parent.isTextblock) return -1; 2645 let e = this.frontier[this.depth], t; 2646 if (!e.type.isTextblock || !rn(this.$to, this.$to.depth, e.type, e.match, !1) || this.$to.depth == this.depth && (t = this.findCloseLevel(this.$to)) && t.depth == this.depth) return -1; 2647 let { depth: n } = this.$to, r = this.$to.after(n); 2648 for (; n > 1 && r == this.$to.end(--n);) ++r; 2649 return r; 2650 } 2651 findCloseLevel(e) { 2652 scan: for (let t = Math.min(this.depth, e.depth); t >= 0; t--) { 2653 let { match: n, type: r } = this.frontier[t], i = t < e.depth && e.end(t + 1) == e.pos + (e.depth - (t + 1)), a = rn(e, t, r, n, i); 2654 if (a) { 2655 for (let n = t - 1; n >= 0; n--) { 2656 let { match: t, type: r } = this.frontier[n], i = rn(e, n, r, t, !0); 2657 if (!i || i.childCount) continue scan; 2658 } 2659 return { 2660 depth: t, 2661 fit: a, 2662 move: i ? e.doc.resolve(e.after(t + 1)) : e 2663 }; 2664 } 2665 } 2666 } 2667 close(e) { 2668 let t = this.findCloseLevel(e); 2669 if (!t) return null; 2670 for (; this.depth > t.depth;) this.closeFrontierNode(); 2671 t.fit.childCount && (this.placed = en(this.placed, t.depth, t.fit)), e = t.move; 2672 for (let n = t.depth + 1; n <= e.depth; n++) { 2673 let t = e.node(n), r = t.type.contentMatch.fillBefore(t.content, !0, e.index(n)); 2674 this.openFrontierNode(t.type, t.attrs, r); 2675 } 2676 return e; 2677 } 2678 openFrontierNode(e, t = null, n) { 2679 let r = this.frontier[this.depth]; 2680 r.match = r.match.matchType(e), this.placed = en(this.placed, this.depth, a.from(e.create(t, n))), this.frontier.push({ 2681 type: e, 2682 match: e.contentMatch 2683 }); 2684 } 2685 closeFrontierNode() { 2686 let e = this.frontier.pop().match.fillBefore(a.empty, !0); 2687 e.childCount && (this.placed = en(this.placed, this.frontier.length, e)); 2688 } 2689}; 2690function $t(e, t, n) { 2691 return t == 0 ? e.cutByIndex(n, e.childCount) : e.replaceChild(0, e.firstChild.copy($t(e.firstChild.content, t - 1, n))); 2692} 2693function en(e, t, n) { 2694 return t == 0 ? e.append(n) : e.replaceChild(e.childCount - 1, e.lastChild.copy(en(e.lastChild.content, t - 1, n))); 2695} 2696function tn(e, t) { 2697 for (let n = 0; n < t; n++) e = e.firstChild.content; 2698 return e; 2699} 2700function nn(e, t, n) { 2701 if (t <= 0) return e; 2702 let r = e.content; 2703 return t > 1 && (r = r.replaceChild(0, nn(r.firstChild, t - 1, r.childCount == 1 ? n - 1 : 0))), t > 0 && (r = e.type.contentMatch.fillBefore(r).append(r), n <= 0 && (r = r.append(e.type.contentMatch.matchFragment(r).fillBefore(a.empty, !0)))), e.copy(r); 2704} 2705function rn(e, t, n, r, i) { 2706 let a = e.node(t), o = i ? e.indexAfter(t) : e.index(t); 2707 if (o == a.childCount && !n.compatibleContent(a.type)) return null; 2708 let s = r.fillBefore(a.content, !0, o); 2709 return s && !an(n, a.content, o) ? s : null; 2710} 2711function an(e, t, n) { 2712 for (let r = n; r < t.childCount; r++) if (!e.allowsMarks(t.child(r).marks)) return !0; 2713 return !1; 2714} 2715function on(e) { 2716 return e.spec.defining || e.spec.definingForContent; 2717} 2718function sn(e, t, n, r) { 2719 if (!r.size) return e.deleteRange(t, n); 2720 let i = e.doc.resolve(t), a = e.doc.resolve(n); 2721 if (Zt(i, a, r)) return e.step(new Ct(t, n, r)); 2722 let o = dn(i, a); 2723 o[o.length - 1] == 0 && o.pop(); 2724 let s = -(i.depth + 1); 2725 o.unshift(s); 2726 for (let e = i.depth, t = i.pos - 1; e > 0; e--, t--) { 2727 let n = i.node(e).type.spec; 2728 if (n.defining || n.definingAsContext || n.isolating) break; 2729 o.indexOf(e) > -1 ? s = e : i.before(e) == t && o.splice(1, 0, -e); 2730 } 2731 let c = o.indexOf(s), l = [], u = r.openStart; 2732 for (let e = r.content, t = 0;; t++) { 2733 let n = e.firstChild; 2734 if (l.push(n), t == r.openStart) break; 2735 e = n.content; 2736 } 2737 for (let e = u - 1; e >= 0; e--) { 2738 let t = l[e], n = on(t.type); 2739 if (n && !t.sameMarkup(i.node(Math.abs(s) - 1))) u = e; 2740 else if (n || !t.type.isTextblock) break; 2741 } 2742 for (let t = r.openStart; t >= 0; t--) { 2743 let s = (t + u + 1) % (r.openStart + 1), f = l[s]; 2744 if (f) for (let t = 0; t < o.length; t++) { 2745 let l = o[(t + c) % o.length], u = !0; 2746 l < 0 && (u = !1, l = -l); 2747 let p = i.node(l - 1), m = i.index(l - 1); 2748 if (p.canReplaceWith(m, m, f.type, f.marks)) return e.replace(i.before(l), u ? a.after(l) : n, new d(cn(r.content, 0, r.openStart, s), s, r.openEnd)); 2749 } 2750 } 2751 let f = e.steps.length; 2752 for (let s = o.length - 1; s >= 0 && (e.replace(t, n, r), !(e.steps.length > f)); s--) { 2753 let e = o[s]; 2754 e < 0 || (t = i.before(e), n = a.after(e)); 2755 } 2756} 2757function cn(e, t, n, r, i) { 2758 if (t < n) { 2759 let i = e.firstChild; 2760 e = e.replaceChild(0, i.copy(cn(i.content, t + 1, n, r, i))); 2761 } 2762 if (t > r) { 2763 let t = i.contentMatchAt(0), n = t.fillBefore(e).append(e); 2764 e = n.append(t.matchFragment(n).fillBefore(a.empty, !0)); 2765 } 2766 return e; 2767} 2768function ln(e, t, n, r) { 2769 if (!r.isInline && t == n && e.doc.resolve(t).parent.content.size) { 2770 let i = Jt(e.doc, t, r.type); 2771 i != null && (t = n = i); 2772 } 2773 e.replaceRange(t, n, new d(a.from(r), 0, 0)); 2774} 2775function un(e, t, n) { 2776 let r = e.doc.resolve(t), i = e.doc.resolve(n); 2777 if (r.parent.isTextblock && i.parent.isTextblock && r.start() != i.start() && r.parentOffset == 0 && i.parentOffset == 0) { 2778 let a = r.sharedDepth(n), o = !1; 2779 for (let e = r.depth; e > a; e--) r.node(e).type.spec.isolating && (o = !0); 2780 for (let e = i.depth; e > a; e--) i.node(e).type.spec.isolating && (o = !0); 2781 if (!o) { 2782 for (let e = r.depth; e > 0 && t == r.start(e); e--) t = r.before(e); 2783 for (let e = i.depth; e > 0 && n == i.start(e); e--) n = i.before(e); 2784 r = e.doc.resolve(t), i = e.doc.resolve(n); 2785 } 2786 } 2787 let a = dn(r, i); 2788 for (let t = 0; t < a.length; t++) { 2789 let n = a[t], o = t == a.length - 1; 2790 if (o && n == 0 || r.node(n).type.contentMatch.validEnd) return e.delete(r.start(n), i.end(n)); 2791 if (n > 0 && (o || r.node(n - 1).canReplace(r.index(n - 1), i.indexAfter(n - 1)))) return e.delete(r.before(n), i.after(n)); 2792 } 2793 for (let a = 1; a <= r.depth && a <= i.depth; a++) if (t - r.start(a) == r.depth - a && n > r.end(a) && i.end(a) - n != i.depth - a && r.start(a - 1) == i.start(a - 1) && r.node(a - 1).canReplace(r.index(a - 1), i.index(a - 1))) return e.delete(r.before(a), n); 2794 e.delete(t, n); 2795} 2796function dn(e, t) { 2797 let n = [], r = Math.min(e.depth, t.depth); 2798 for (let i = r; i >= 0; i--) { 2799 let r = e.start(i); 2800 if (r < e.pos - (e.depth - i) || t.end(i) > t.pos + (t.depth - i) || e.node(i).type.spec.isolating || t.node(i).type.spec.isolating) break; 2801 (r == t.start(i) || i == e.depth && i == t.depth && e.parent.inlineContent && t.parent.inlineContent && i && t.start(i - 1) == r - 1) && n.push(i); 2802 } 2803 return n; 2804} 2805var fn = class e extends x { 2806 constructor(e, t, n) { 2807 super(), this.pos = e, this.attr = t, this.value = n; 2808 } 2809 apply(e) { 2810 let t = e.nodeAt(this.pos); 2811 if (!t) return S.fail("No node at attribute step's position"); 2812 let n = Object.create(null); 2813 for (let e in t.attrs) n[e] = t.attrs[e]; 2814 n[this.attr] = this.value; 2815 let r = t.type.create(n, null, t.marks); 2816 return S.fromReplace(e, this.pos, this.pos + 1, new d(a.from(r), 0, +!t.isLeaf)); 2817 } 2818 getMap() { 2819 return ht.empty; 2820 } 2821 invert(t) { 2822 return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]); 2823 } 2824 map(t) { 2825 let n = t.mapResult(this.pos, 1); 2826 return n.deletedAfter ? null : new e(n.pos, this.attr, this.value); 2827 } 2828 toJSON() { 2829 return { 2830 stepType: "attr", 2831 pos: this.pos, 2832 attr: this.attr, 2833 value: this.value 2834 }; 2835 } 2836 static fromJSON(t, n) { 2837 if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON"); 2838 return new e(n.pos, n.attr, n.value); 2839 } 2840}; 2841x.jsonID("attr", fn); 2842var pn = class e extends x { 2843 constructor(e, t) { 2844 super(), this.attr = e, this.value = t; 2845 } 2846 apply(e) { 2847 let t = Object.create(null); 2848 for (let n in e.attrs) t[n] = e.attrs[n]; 2849 t[this.attr] = this.value; 2850 let n = e.type.create(t, e.content, e.marks); 2851 return S.ok(n); 2852 } 2853 getMap() { 2854 return ht.empty; 2855 } 2856 invert(t) { 2857 return new e(this.attr, t.attrs[this.attr]); 2858 } 2859 map(e) { 2860 return this; 2861 } 2862 toJSON() { 2863 return { 2864 stepType: "docAttr", 2865 attr: this.attr, 2866 value: this.value 2867 }; 2868 } 2869 static fromJSON(t, n) { 2870 if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON"); 2871 return new e(n.attr, n.value); 2872 } 2873}; 2874x.jsonID("docAttr", pn); 2875var mn = class extends Error {}; 2876mn = function e(t) { 2877 let n = Error.call(this, t); 2878 return n.__proto__ = e.prototype, n; 2879}, mn.prototype = Object.create(Error.prototype), mn.prototype.constructor = mn, mn.prototype.name = "TransformError"; 2880var hn = class { 2881 constructor(e) { 2882 this.doc = e, this.steps = [], this.docs = [], this.mapping = new gt(); 2883 } 2884 get before() { 2885 return this.docs.length ? this.docs[0] : this.doc; 2886 } 2887 step(e) { 2888 let t = this.maybeStep(e); 2889 if (t.failed) throw new mn(t.failed); 2890 return this; 2891 } 2892 maybeStep(e) { 2893 let t = e.apply(this.doc); 2894 return t.failed || this.addStep(e, t.doc), t; 2895 } 2896 get docChanged() { 2897 return this.steps.length > 0; 2898 } 2899 changedRange() { 2900 let e = 1e9, t = -1e9; 2901 for (let n = 0; n < this.mapping.maps.length; n++) { 2902 let r = this.mapping.maps[n]; 2903 n && (e = r.map(e, 1), t = r.map(t, -1)), r.forEach((n, r, i, a) => { 2904 e = Math.min(e, i), t = Math.max(t, a); 2905 }); 2906 } 2907 return e == 1e9 ? null : { 2908 from: e, 2909 to: t 2910 }; 2911 } 2912 addStep(e, t) { 2913 this.docs.push(this.doc), this.steps.push(e), this.mapping.appendMap(e.getMap()), this.doc = t; 2914 } 2915 replace(e, t = e, n = d.empty) { 2916 let r = Xt(this.doc, e, t, n); 2917 return r && this.step(r), this; 2918 } 2919 replaceWith(e, t, n) { 2920 return this.replace(e, t, new d(a.from(n), 0, 0)); 2921 } 2922 delete(e, t) { 2923 return this.replace(e, t, d.empty); 2924 } 2925 insert(e, t) { 2926 return this.replaceWith(e, e, t); 2927 } 2928 replaceRange(e, t, n) { 2929 return sn(this, e, t, n), this; 2930 } 2931 replaceRangeWith(e, t, n) { 2932 return ln(this, e, t, n), this; 2933 } 2934 deleteRange(e, t) { 2935 return un(this, e, t), this; 2936 } 2937 lift(e, t) { 2938 return At(this, e, t), this; 2939 } 2940 join(e, t = 1) { 2941 return qt(this, e, t), this; 2942 } 2943 wrap(e, t) { 2944 return Ft(this, e, t), this; 2945 } 2946 setBlockType(e, t = e, n, r = null) { 2947 return It(this, e, t, n, r), this; 2948 } 2949 setNodeMarkup(e, t, n = null, r) { 2950 return Bt(this, e, t, n, r), this; 2951 } 2952 setNodeAttribute(e, t, n) { 2953 return this.step(new fn(e, t, n)), this; 2954 } 2955 setDocAttribute(e, t) { 2956 return this.step(new pn(e, t)), this; 2957 } 2958 addNodeMark(e, t) { 2959 return this.step(new xt(e, t)), this; 2960 } 2961 removeNodeMark(e, t) { 2962 let n = this.doc.nodeAt(e); 2963 if (!n) throw RangeError("No node at position " + e); 2964 if (t instanceof l) t.isInSet(n.marks) && this.step(new St(e, t)); 2965 else { 2966 let r = n.marks, i, a = []; 2967 for (; i = t.isInSet(r);) a.push(new St(e, i)), r = i.removeFromSet(r); 2968 for (let e = a.length - 1; e >= 0; e--) this.step(a[e]); 2969 } 2970 return this; 2971 } 2972 split(e, t = 1, n) { 2973 return Ht(this, e, t, n), this; 2974 } 2975 addMark(e, t, n) { 2976 return Tt(this, e, t, n), this; 2977 } 2978 removeMark(e, t, n) { 2979 return Et(this, e, t, n), this; 2980 } 2981 clearIncompatible(e, t, n) { 2982 return Dt(this, e, t, n), this; 2983 } 2984}, gn = Object.create(null), w = class { 2985 constructor(e, t, n) { 2986 this.$anchor = e, this.$head = t, this.ranges = n || [new _n(e.min(t), e.max(t))]; 2987 } 2988 get anchor() { 2989 return this.$anchor.pos; 2990 } 2991 get head() { 2992 return this.$head.pos; 2993 } 2994 get from() { 2995 return this.$from.pos; 2996 } 2997 get to() { 2998 return this.$to.pos; 2999 } 3000 get $from() { 3001 return this.ranges[0].$from; 3002 } 3003 get $to() { 3004 return this.ranges[0].$to; 3005 } 3006 get empty() { 3007 let e = this.ranges; 3008 for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1; 3009 return !0; 3010 } 3011 content() { 3012 return this.$from.doc.slice(this.from, this.to, !0); 3013 } 3014 replace(e, t = d.empty) { 3015 let n = t.content.lastChild, r = null; 3016 for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild; 3017 let i = e.steps.length, a = this.ranges; 3018 for (let o = 0; o < a.length; o++) { 3019 let { $from: s, $to: c } = a[o], l = e.mapping.slice(i); 3020 e.replaceRange(l.map(s.pos), l.map(c.pos), o ? d.empty : t), o == 0 && Tn(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1); 3021 } 3022 } 3023 replaceWith(e, t) { 3024 let n = e.steps.length, r = this.ranges; 3025 for (let i = 0; i < r.length; i++) { 3026 let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos); 3027 i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), Tn(e, n, t.isInline ? -1 : 1)); 3028 } 3029 } 3030 static findFrom(e, t, n = !1) { 3031 let r = e.parent.inlineContent ? new T(e) : wn(e.node(0), e.parent, e.pos, e.index(), t, n); 3032 if (r) return r; 3033 for (let r = e.depth - 1; r >= 0; r--) { 3034 let i = t < 0 ? wn(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : wn(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n); 3035 if (i) return i; 3036 } 3037 return null; 3038 } 3039 static near(e, t = 1) { 3040 return this.findFrom(e, t) || this.findFrom(e, -t) || new Sn(e.node(0)); 3041 } 3042 static atStart(e) { 3043 return wn(e, e, 0, 0, 1) || new Sn(e); 3044 } 3045 static atEnd(e) { 3046 return wn(e, e, e.content.size, e.childCount, -1) || new Sn(e); 3047 } 3048 static fromJSON(e, t) { 3049 if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON"); 3050 let n = gn[t.type]; 3051 if (!n) throw RangeError(`No selection type ${t.type} defined`); 3052 return n.fromJSON(e, t); 3053 } 3054 static jsonID(e, t) { 3055 if (e in gn) throw RangeError("Duplicate use of selection JSON ID " + e); 3056 return gn[e] = t, t.prototype.jsonID = e, t; 3057 } 3058 getBookmark() { 3059 return T.between(this.$anchor, this.$head).getBookmark(); 3060 } 3061}; 3062w.prototype.visible = !0; 3063var _n = class { 3064 constructor(e, t) { 3065 this.$from = e, this.$to = t; 3066 } 3067}, vn = !1; 3068function yn(e) { 3069 !vn && !e.parent.inlineContent && (vn = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")")); 3070} 3071var T = class e extends w { 3072 constructor(e, t = e) { 3073 yn(e), yn(t), super(e, t); 3074 } 3075 get $cursor() { 3076 return this.$anchor.pos == this.$head.pos ? this.$head : null; 3077 } 3078 map(t, n) { 3079 let r = t.resolve(n.map(this.head)); 3080 if (!r.parent.inlineContent) return w.near(r); 3081 let i = t.resolve(n.map(this.anchor)); 3082 return new e(i.parent.inlineContent ? i : r, r); 3083 } 3084 replace(e, t = d.empty) { 3085 if (super.replace(e, t), t == d.empty) { 3086 let t = this.$from.marksAcross(this.$to); 3087 t && e.ensureMarks(t); 3088 } 3089 } 3090 eq(t) { 3091 return t instanceof e && t.anchor == this.anchor && t.head == this.head; 3092 } 3093 getBookmark() { 3094 return new bn(this.anchor, this.head); 3095 } 3096 toJSON() { 3097 return { 3098 type: "text", 3099 anchor: this.anchor, 3100 head: this.head 3101 }; 3102 } 3103 static fromJSON(t, n) { 3104 if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON"); 3105 return new e(t.resolve(n.anchor), t.resolve(n.head)); 3106 } 3107 static create(e, t, n = t) { 3108 let r = e.resolve(t); 3109 return new this(r, n == t ? r : e.resolve(n)); 3110 } 3111 static between(t, n, r) { 3112 let i = t.pos - n.pos; 3113 if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) { 3114 let e = w.findFrom(n, r, !0) || w.findFrom(n, -r, !0); 3115 if (e) n = e.$head; 3116 else return w.near(n, r); 3117 } 3118 return t.parent.inlineContent || (i == 0 ? t = n : (t = (w.findFrom(t, -r, !0) || w.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n); 3119 } 3120}; 3121w.jsonID("text", T); 3122var bn = class e { 3123 constructor(e, t) { 3124 this.anchor = e, this.head = t; 3125 } 3126 map(t) { 3127 return new e(t.map(this.anchor), t.map(this.head)); 3128 } 3129 resolve(e) { 3130 return T.between(e.resolve(this.anchor), e.resolve(this.head)); 3131 } 3132}, E = class e extends w { 3133 constructor(e) { 3134 let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize); 3135 super(e, n), this.node = t; 3136 } 3137 map(t, n) { 3138 let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i); 3139 return r ? w.near(a) : new e(a); 3140 } 3141 content() { 3142 return new d(a.from(this.node), 0, 0); 3143 } 3144 eq(t) { 3145 return t instanceof e && t.anchor == this.anchor; 3146 } 3147 toJSON() { 3148 return { 3149 type: "node", 3150 anchor: this.anchor 3151 }; 3152 } 3153 getBookmark() { 3154 return new xn(this.anchor); 3155 } 3156 static fromJSON(t, n) { 3157 if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON"); 3158 return new e(t.resolve(n.anchor)); 3159 } 3160 static create(t, n) { 3161 return new e(t.resolve(n)); 3162 } 3163 static isSelectable(e) { 3164 return !e.isText && e.type.spec.selectable !== !1; 3165 } 3166}; 3167E.prototype.visible = !1, w.jsonID("node", E); 3168var xn = class e { 3169 constructor(e) { 3170 this.anchor = e; 3171 } 3172 map(t) { 3173 let { deleted: n, pos: r } = t.mapResult(this.anchor); 3174 return n ? new bn(r, r) : new e(r); 3175 } 3176 resolve(e) { 3177 let t = e.resolve(this.anchor), n = t.nodeAfter; 3178 return n && E.isSelectable(n) ? new E(t) : w.near(t); 3179 } 3180}, Sn = class e extends w { 3181 constructor(e) { 3182 super(e.resolve(0), e.resolve(e.content.size)); 3183 } 3184 replace(e, t = d.empty) { 3185 if (t == d.empty) {
3186 e.delete(0, e.doc.content.size); 3187 let t = w.atStart(e.doc); 3188 t.eq(e.selection) || e.setSelection(t); 3189 } else super.replace(e, t); 3190 } 3191 toJSON() { 3192 return { type: "all" }; 3193 } 3194 static fromJSON(t) { 3195 return new e(t); 3196 } 3197 map(t) { 3198 return new e(t); 3199 } 3200 eq(t) { 3201 return t instanceof e; 3202 } 3203 getBookmark() { 3204 return Cn; 3205 } 3206}; 3207w.jsonID("all", Sn); 3208var Cn = { 3209 map() { 3210 return this; 3211 }, 3212 resolve(e) { 3213 return new Sn(e); 3214 } 3215}; 3216function wn(e, t, n, r, i, a = !1) { 3217 if (t.inlineContent) return T.create(e, n); 3218 for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) { 3219 let r = t.child(o); 3220 if (!r.isAtom) { 3221 let t = wn(e, r, n + i, i < 0 ? r.childCount : 0, i, a); 3222 if (t) return t; 3223 } else if (!a && E.isSelectable(r)) return E.create(e, n - (i < 0 ? r.nodeSize : 0)); 3224 n += r.nodeSize * i; 3225 } 3226 return null; 3227} 3228function Tn(e, t, n) { 3229 let r = e.steps.length - 1; 3230 if (r < t) return; 3231 let i = e.steps[r]; 3232 if (!(i instanceof Ct || i instanceof C)) return; 3233 let a = e.mapping.maps[r], o; 3234 a.forEach((e, t, n, r) => { 3235 o ??= r; 3236 }), e.setSelection(w.near(e.doc.resolve(o), n)); 3237} 3238var En = 1, Dn = 2, On = 4, kn = class extends hn { 3239 constructor(e) { 3240 super(e.doc), this.curSelectionFor = 0, this.updated = 0, this.meta = Object.create(null), this.time = Date.now(), this.curSelection = e.selection, this.storedMarks = e.storedMarks; 3241 } 3242 get selection() { 3243 return this.curSelectionFor < this.steps.length && (this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor)), this.curSelectionFor = this.steps.length), this.curSelection; 3244 } 3245 setSelection(e) { 3246 if (e.$from.doc != this.doc) throw RangeError("Selection passed to setSelection must point at the current document"); 3247 return this.curSelection = e, this.curSelectionFor = this.steps.length, this.updated = (this.updated | En) & -3, this.storedMarks = null, this; 3248 } 3249 get selectionSet() { 3250 return (this.updated & En) > 0; 3251 } 3252 setStoredMarks(e) { 3253 return this.storedMarks = e, this.updated |= Dn, this; 3254 } 3255 ensureMarks(e) { 3256 return l.sameSet(this.storedMarks || this.selection.$from.marks(), e) || this.setStoredMarks(e), this; 3257 } 3258 addStoredMark(e) { 3259 return this.ensureMarks(e.addToSet(this.storedMarks || this.selection.$head.marks())); 3260 } 3261 removeStoredMark(e) { 3262 return this.ensureMarks(e.removeFromSet(this.storedMarks || this.selection.$head.marks())); 3263 } 3264 get storedMarksSet() { 3265 return (this.updated & Dn) > 0; 3266 } 3267 addStep(e, t) { 3268 super.addStep(e, t), this.updated &= -3, this.storedMarks = null; 3269 } 3270 setTime(e) { 3271 return this.time = e, this; 3272 } 3273 replaceSelection(e) { 3274 return this.selection.replace(this, e), this; 3275 } 3276 replaceSelectionWith(e, t = !0) { 3277 let n = this.selection; 3278 return t && (e = e.mark(this.storedMarks || (n.empty ? n.$from.marks() : n.$from.marksAcross(n.$to) || l.none))), n.replaceWith(this, e), this; 3279 } 3280 deleteSelection() { 3281 return this.selection.replace(this), this; 3282 } 3283 insertText(e, t, n) { 3284 let r = this.doc.type.schema; 3285 if (t == null) return e ? this.replaceSelectionWith(r.text(e), !0) : this.deleteSelection(); 3286 { 3287 if (n ??= t, !e) return this.deleteRange(t, n); 3288 let i = this.storedMarks; 3289 if (!i) { 3290 let e = this.doc.resolve(t); 3291 i = n == t ? e.marks() : e.marksAcross(this.doc.resolve(n)); 3292 } 3293 return this.replaceRangeWith(t, n, r.text(e, i)), !this.selection.empty && this.selection.to == t + e.length && this.setSelection(w.near(this.selection.$to)), this; 3294 } 3295 } 3296 setMeta(e, t) { 3297 return this.meta[typeof e == "string" ? e : e.key] = t, this; 3298 } 3299 getMeta(e) { 3300 return this.meta[typeof e == "string" ? e : e.key]; 3301 } 3302 get isGeneric() { 3303 for (let e in this.meta) return !1; 3304 return !0; 3305 } 3306 scrollIntoView() { 3307 return this.updated |= On, this; 3308 } 3309 get scrolledIntoView() { 3310 return (this.updated & On) > 0; 3311 } 3312}; 3313function An(e, t) { 3314 return !t || !e ? e : e.bind(t); 3315} 3316var jn = class { 3317 constructor(e, t, n) { 3318 this.name = e, this.init = An(t.init, n), this.apply = An(t.apply, n); 3319 } 3320}, Mn = [ 3321 new jn("doc", { 3322 init(e) { 3323 return e.doc || e.schema.topNodeType.createAndFill(); 3324 }, 3325 apply(e) { 3326 return e.doc; 3327 } 3328 }), 3329 new jn("selection", { 3330 init(e, t) { 3331 return e.selection || w.atStart(t.doc); 3332 }, 3333 apply(e) { 3334 return e.selection; 3335 } 3336 }), 3337 new jn("storedMarks", { 3338 init(e) { 3339 return e.storedMarks || null; 3340 }, 3341 apply(e, t, n, r) { 3342 return r.selection.$cursor ? e.storedMarks : null; 3343 } 3344 }), 3345 new jn("scrollToSelection", { 3346 init() { 3347 return 0; 3348 }, 3349 apply(e, t) { 3350 return e.scrolledIntoView ? t + 1 : t; 3351 } 3352 }) 3353], Nn = class { 3354 constructor(e, t) { 3355 this.schema = e, this.plugins = [], this.pluginsByKey = Object.create(null), this.fields = Mn.slice(), t && t.forEach((e) => { 3356 if (this.pluginsByKey[e.key]) throw RangeError("Adding different instances of a keyed plugin (" + e.key + ")"); 3357 this.plugins.push(e), this.pluginsByKey[e.key] = e, e.spec.state && this.fields.push(new jn(e.key, e.spec.state, e)); 3358 }); 3359 } 3360}, Pn = class e { 3361 constructor(e) { 3362 this.config = e; 3363 } 3364 get schema() { 3365 return this.config.schema; 3366 } 3367 get plugins() { 3368 return this.config.plugins; 3369 } 3370 apply(e) { 3371 return this.applyTransaction(e).state; 3372 } 3373 filterTransaction(e, t = -1) { 3374 for (let n = 0; n < this.config.plugins.length; n++) if (n != t) { 3375 let t = this.config.plugins[n]; 3376 if (t.spec.filterTransaction && !t.spec.filterTransaction.call(t, e, this)) return !1; 3377 } 3378 return !0; 3379 } 3380 applyTransaction(e) { 3381 if (!this.filterTransaction(e)) return { 3382 state: this, 3383 transactions: [] 3384 }; 3385 let t = [e], n = this.applyInner(e), r = null; 3386 for (;;) { 3387 let i = !1; 3388 for (let a = 0; a < this.config.plugins.length; a++) { 3389 let o = this.config.plugins[a]; 3390 if (o.spec.appendTransaction) { 3391 let s = r ? r[a].n : 0, c = r ? r[a].state : this, l = s < t.length && o.spec.appendTransaction.call(o, s ? t.slice(s) : t, c, n); 3392 if (l && n.filterTransaction(l, a)) { 3393 if (l.setMeta("appendedTransaction", e), !r) { 3394 r = []; 3395 for (let e = 0; e < this.config.plugins.length; e++) r.push(e < a ? { 3396 state: n, 3397 n: t.length 3398 } : { 3399 state: this, 3400 n: 0 3401 }); 3402 } 3403 t.push(l), n = n.applyInner(l), i = !0; 3404 } 3405 r && (r[a] = { 3406 state: n, 3407 n: t.length 3408 }); 3409 } 3410 } 3411 if (!i) return { 3412 state: n, 3413 transactions: t 3414 }; 3415 } 3416 } 3417 applyInner(t) { 3418 if (!t.before.eq(this.doc)) throw RangeError("Applying a mismatched transaction"); 3419 let n = new e(this.config), r = this.config.fields; 3420 for (let e = 0; e < r.length; e++) { 3421 let i = r[e]; 3422 n[i.name] = i.apply(t, this[i.name], this, n); 3423 } 3424 return n; 3425 } 3426 get tr() { 3427 return new kn(this); 3428 } 3429 static create(t) { 3430 let n = new Nn(t.doc ? t.doc.type.schema : t.schema, t.plugins), r = new e(n); 3431 for (let e = 0; e < n.fields.length; e++) r[n.fields[e].name] = n.fields[e].init(t, r); 3432 return r; 3433 } 3434 reconfigure(t) { 3435 let n = new Nn(this.schema, t.plugins), r = n.fields, i = new e(n); 3436 for (let e = 0; e < r.length; e++) { 3437 let n = r[e].name; 3438 i[n] = this.hasOwnProperty(n) ? this[n] : r[e].init(t, i); 3439 } 3440 return i; 3441 } 3442 toJSON(e) { 3443 let t = { 3444 doc: this.doc.toJSON(), 3445 selection: this.selection.toJSON() 3446 }; 3447 if (this.storedMarks && (t.storedMarks = this.storedMarks.map((e) => e.toJSON())), e && typeof e == "object") for (let n in e) { 3448 if (n == "doc" || n == "selection") throw RangeError("The JSON fields `doc` and `selection` are reserved"); 3449 let r = e[n], i = r.spec.state; 3450 i && i.toJSON && (t[n] = i.toJSON.call(r, this[r.key])); 3451 } 3452 return t; 3453 } 3454 static fromJSON(t, n, r) { 3455 if (!n) throw RangeError("Invalid input for EditorState.fromJSON"); 3456 if (!t.schema) throw RangeError("Required config field 'schema' missing"); 3457 let i = new Nn(t.schema, t.plugins), a = new e(i); 3458 return i.fields.forEach((e) => { 3459 if (e.name == "doc") a.doc = le.fromJSON(t.schema, n.doc); 3460 else if (e.name == "selection") a.selection = w.fromJSON(a.doc, n.selection); 3461 else if (e.name == "storedMarks") n.storedMarks && (a.storedMarks = n.storedMarks.map(t.schema.markFromJSON)); 3462 else { 3463 if (r) for (let i in r) { 3464 let o = r[i], s = o.spec.state; 3465 if (o.key == e.name && s && s.fromJSON && Object.prototype.hasOwnProperty.call(n, i)) { 3466 a[e.name] = s.fromJSON.call(o, t, n[i], a); 3467 return; 3468 } 3469 } 3470 a[e.name] = e.init(t, a); 3471 } 3472 }), a; 3473 } 3474}; 3475function Fn(e, t, n) { 3476 for (let r in e) { 3477 let i = e[r]; 3478 i instanceof Function ? i = i.bind(t) : r == "handleDOMEvents" && (i = Fn(i, t, {})), n[r] = i; 3479 } 3480 return n; 3481} 3482var D = class { 3483 constructor(e) { 3484 this.spec = e, this.props = {}, e.props && Fn(e.props, this, this.props), this.key = e.key ? e.key.key : Ln("plugin"); 3485 } 3486 getState(e) { 3487 return e[this.key]; 3488 } 3489}, In = Object.create(null); 3490function Ln(e) {
vendor: 85,007 bytes, lines 3491-5853
3491 return e in In ? e + "$" + ++In[e] : (In[e] = 0, e + "$"); 3492} 3493var O = class { 3494 constructor(e = "key") { 3495 this.key = Ln(e); 3496 } 3497 get(e) { 3498 return e.config.pluginsByKey[this.key]; 3499 } 3500 getState(e) { 3501 return e[this.key]; 3502 } 3503}, Rn = (e, t) => e.selection.empty ? !1 : (t && t(e.tr.deleteSelection().scrollIntoView()), !0); 3504function zn(e, t) { 3505 let { $cursor: n } = e.selection; 3506 return !n || (t ? !t.endOfTextblock("backward", e) : n.parentOffset > 0) ? null : n; 3507} 3508var Bn = (e, t, n) => { 3509 let r = zn(e, n); 3510 if (!r) return !1; 3511 let i = Kn(r); 3512 if (!i) { 3513 let n = r.blockRange(), i = n && kt(n); 3514 return i == null ? !1 : (t && t(e.tr.lift(n, i).scrollIntoView()), !0); 3515 } 3516 let a = i.nodeBefore; 3517 if (ur(e, i, t, -1)) return !0; 3518 if (r.parent.content.size == 0 && (Wn(a, "end") || E.isSelectable(a))) for (let n = r.depth;; n--) { 3519 let o = Xt(e.doc, r.before(n), r.after(n), d.empty); 3520 if (o && o.slice.size < o.to - o.from) { 3521 if (t) { 3522 let n = e.tr.step(o); 3523 n.setSelection(Wn(a, "end") ? w.findFrom(n.doc.resolve(n.mapping.map(i.pos, -1)), -1) : E.create(n.doc, i.pos - a.nodeSize)), t(n.scrollIntoView()); 3524 } 3525 return !0; 3526 } 3527 if (n == 1 || r.node(n - 1).childCount > 1) break; 3528 } 3529 return a.isAtom && i.depth == r.depth - 1 ? (t && t(e.tr.delete(i.pos - a.nodeSize, i.pos).scrollIntoView()), !0) : !1; 3530}, Vn = (e, t, n) => { 3531 let r = zn(e, n); 3532 if (!r) return !1; 3533 let i = Kn(r); 3534 return i ? Un(e, i, t) : !1; 3535}, Hn = (e, t, n) => { 3536 let r = qn(e, n); 3537 if (!r) return !1; 3538 let i = Xn(r); 3539 return i ? Un(e, i, t) : !1; 3540}; 3541function Un(e, t, n) { 3542 let r = t.nodeBefore, i = t.pos - 1; 3543 for (; !r.isTextblock; i--) { 3544 if (r.type.spec.isolating) return !1; 3545 let e = r.lastChild; 3546 if (!e) return !1; 3547 r = e; 3548 } 3549 let a = t.nodeAfter, o = t.pos + 1; 3550 for (; !a.isTextblock; o++) { 3551 if (a.type.spec.isolating) return !1; 3552 let e = a.firstChild; 3553 if (!e) return !1; 3554 a = e; 3555 } 3556 let s = Xt(e.doc, i, o, d.empty); 3557 if (!s || s.from != i || s instanceof Ct && s.slice.size >= o - i) return !1; 3558 if (n) { 3559 let t = e.tr.step(s); 3560 t.setSelection(T.create(t.doc, i)), n(t.scrollIntoView()); 3561 } 3562 return !0; 3563} 3564function Wn(e, t, n = !1) { 3565 for (let r = e; r; r = t == "start" ? r.firstChild : r.lastChild) { 3566 if (r.isTextblock) return !0; 3567 if (n && r.childCount != 1) return !1; 3568 } 3569 return !1; 3570} 3571var Gn = (e, t, n) => { 3572 let { $head: r, empty: i } = e.selection, a = r; 3573 if (!i) return !1; 3574 if (r.parent.isTextblock) { 3575 if (n ? !n.endOfTextblock("backward", e) : r.parentOffset > 0) return !1; 3576 a = Kn(r); 3577 } 3578 let o = a && a.nodeBefore; 3579 return !o || !E.isSelectable(o) ? !1 : (t && t(e.tr.setSelection(E.create(e.doc, a.pos - o.nodeSize)).scrollIntoView()), !0); 3580}; 3581function Kn(e) { 3582 if (!e.parent.type.spec.isolating) for (let t = e.depth - 1; t >= 0; t--) { 3583 if (e.index(t) > 0) return e.doc.resolve(e.before(t + 1)); 3584 if (e.node(t).type.spec.isolating) break; 3585 } 3586 return null; 3587} 3588function qn(e, t) { 3589 let { $cursor: n } = e.selection; 3590 return !n || (t ? !t.endOfTextblock("forward", e) : n.parentOffset < n.parent.content.size) ? null : n; 3591} 3592var Jn = (e, t, n) => { 3593 let r = qn(e, n); 3594 if (!r) return !1; 3595 let i = Xn(r); 3596 if (!i) return !1; 3597 let a = i.nodeAfter; 3598 if (ur(e, i, t, 1)) return !0; 3599 if (r.parent.content.size == 0 && (Wn(a, "start") || E.isSelectable(a))) { 3600 let n = Xt(e.doc, r.before(), r.after(), d.empty); 3601 if (n && n.slice.size < n.to - n.from) { 3602 if (t) { 3603 let r = e.tr.step(n); 3604 r.setSelection(Wn(a, "start") ? w.findFrom(r.doc.resolve(r.mapping.map(i.pos)), 1) : E.create(r.doc, r.mapping.map(i.pos))), t(r.scrollIntoView()); 3605 } 3606 return !0; 3607 } 3608 } 3609 return a.isAtom && i.depth == r.depth - 1 ? (t && t(e.tr.delete(i.pos, i.pos + a.nodeSize).scrollIntoView()), !0) : !1; 3610}, Yn = (e, t, n) => { 3611 let { $head: r, empty: i } = e.selection, a = r; 3612 if (!i) return !1; 3613 if (r.parent.isTextblock) { 3614 if (n ? !n.endOfTextblock("forward", e) : r.parentOffset < r.parent.content.size) return !1; 3615 a = Xn(r); 3616 } 3617 let o = a && a.nodeAfter; 3618 return !o || !E.isSelectable(o) ? !1 : (t && t(e.tr.setSelection(E.create(e.doc, a.pos)).scrollIntoView()), !0); 3619}; 3620function Xn(e) { 3621 if (!e.parent.type.spec.isolating) for (let t = e.depth - 1; t >= 0; t--) { 3622 let n = e.node(t); 3623 if (e.index(t) + 1 < n.childCount) return e.doc.resolve(e.after(t + 1)); 3624 if (n.type.spec.isolating) break; 3625 } 3626 return null; 3627} 3628var Zn = (e, t) => { 3629 let n = e.selection, r = n instanceof E, i; 3630 if (r) { 3631 if (n.node.isTextblock || !Ut(e.doc, n.from)) return !1; 3632 i = n.from; 3633 } else if (i = Kt(e.doc, n.from, -1), i == null) return !1; 3634 if (t) { 3635 let n = e.tr.join(i); 3636 r && n.setSelection(E.create(n.doc, i - e.doc.resolve(i).nodeBefore.nodeSize)), t(n.scrollIntoView()); 3637 } 3638 return !0; 3639}, Qn = (e, t) => { 3640 let n = e.selection, r; 3641 if (n instanceof E) { 3642 if (n.node.isTextblock || !Ut(e.doc, n.to)) return !1; 3643 r = n.to; 3644 } else if (r = Kt(e.doc, n.to, 1), r == null) return !1; 3645 return t && t(e.tr.join(r).scrollIntoView()), !0; 3646}, $n = (e, t) => { 3647 let { $from: n, $to: r } = e.selection, i = n.blockRange(r), a = i && kt(i); 3648 return a == null ? !1 : (t && t(e.tr.lift(i, a).scrollIntoView()), !0); 3649}, er = (e, t) => { 3650 let { $head: n, $anchor: r } = e.selection; 3651 return !n.parent.type.spec.code || !n.sameParent(r) ? !1 : (t && t(e.tr.insertText("\n").scrollIntoView()), !0); 3652}; 3653function tr(e) { 3654 for (let t = 0; t < e.edgeCount; t++) { 3655 let { type: n } = e.edge(t); 3656 if (n.isTextblock && !n.hasRequiredAttrs()) return n; 3657 } 3658 return null; 3659} 3660var nr = (e, t) => { 3661 let { $head: n, $anchor: r } = e.selection; 3662 if (!n.parent.type.spec.code || !n.sameParent(r)) return !1; 3663 let i = n.node(-1), a = n.indexAfter(-1), o = tr(i.contentMatchAt(a)); 3664 if (!o || !i.canReplaceWith(a, a, o)) return !1; 3665 if (t) { 3666 let r = n.after(), i = e.tr.replaceWith(r, r, o.createAndFill()); 3667 i.setSelection(w.near(i.doc.resolve(r), 1)), t(i.scrollIntoView()); 3668 } 3669 return !0; 3670}, rr = (e, t) => { 3671 let n = e.selection, { $from: r, $to: i } = n; 3672 if (n instanceof Sn || r.parent.inlineContent || i.parent.inlineContent) return !1; 3673 let a = tr(i.parent.contentMatchAt(i.indexAfter())); 3674 if (!a || !a.isTextblock) return !1; 3675 if (t) { 3676 let n = (!r.parentOffset && i.index() < i.parent.childCount ? r : i).pos, o = e.tr.insert(n, a.createAndFill()); 3677 o.setSelection(T.create(o.doc, n + 1)), t(o.scrollIntoView()); 3678 } 3679 return !0; 3680}, ir = (e, t) => { 3681 let { $cursor: n } = e.selection; 3682 if (!n || n.parent.content.size) return !1; 3683 if (n.depth > 1 && n.after() != n.end(-1)) { 3684 let r = n.before(); 3685 if (Vt(e.doc, r)) return t && t(e.tr.split(r).scrollIntoView()), !0; 3686 } 3687 let r = n.blockRange(), i = r && kt(r); 3688 return i == null ? !1 : (t && t(e.tr.lift(r, i).scrollIntoView()), !0); 3689}; 3690function ar(e) { 3691 return (t, n) => { 3692 let { $from: r, $to: i } = t.selection; 3693 if (t.selection instanceof E && t.selection.node.isBlock) return !r.parentOffset || !Vt(t.doc, r.pos) ? !1 : (n && n(t.tr.split(r.pos).scrollIntoView()), !0); 3694 if (!r.depth) return !1; 3695 let a = [], o, s, c = !1, l = !1; 3696 for (let t = r.depth;; t--) if (r.node(t).isBlock) { 3697 c = r.end(t) == r.pos + (r.depth - t), l = r.start(t) == r.pos - (r.depth - t), s = tr(r.node(t - 1).contentMatchAt(r.indexAfter(t - 1))); 3698 let n = e && e(i.parent, c, r); 3699 a.unshift(n || (c && s ? { type: s } : null)), o = t; 3700 break; 3701 } else { 3702 if (t == 1) return !1; 3703 a.unshift(null); 3704 } 3705 let u = t.tr; 3706 (t.selection instanceof T || t.selection instanceof Sn) && u.deleteSelection(); 3707 let d = u.mapping.map(r.pos), f = Vt(u.doc, d, a.length, a); 3708 if (f ||= (a[0] = s ? { type: s } : null, Vt(u.doc, d, a.length, a)), !f) return !1; 3709 if (u.split(d, a.length, a), !c && l && r.node(o).type != s) { 3710 let e = u.mapping.map(r.before(o)), t = u.doc.resolve(e); 3711 s && r.node(o - 1).canReplaceWith(t.index(), t.index() + 1, s) && u.setNodeMarkup(u.mapping.map(r.before(o)), s); 3712 } 3713 return n && n(u.scrollIntoView()), !0; 3714 }; 3715} 3716var or = ar(), sr = (e, t) => { 3717 let { $from: n, to: r } = e.selection, i, a = n.sharedDepth(r); 3718 return a == 0 ? !1 : (i = n.before(a), t && t(e.tr.setSelection(E.create(e.doc, i))), !0); 3719}, cr = (e, t) => (t && t(e.tr.setSelection(new Sn(e.doc))), !0); 3720function lr(e, t, n) { 3721 let r = t.nodeBefore, i = t.nodeAfter, a = t.index(); 3722 return !r || !i || !r.type.compatibleContent(i.type) ? !1 : !r.content.size && t.parent.canReplace(a - 1, a) ? (n && n(e.tr.delete(t.pos - r.nodeSize, t.pos).scrollIntoView()), !0) : !t.parent.canReplace(a, a + 1) || !(i.isTextblock || Ut(e.doc, t.pos)) ? !1 : (n && n(e.tr.join(t.pos).scrollIntoView()), !0); 3723} 3724function ur(e, t, n, r) { 3725 let i = t.nodeBefore, o = t.nodeAfter, s, c, l = i.type.spec.isolating || o.type.spec.isolating; 3726 if (!l && lr(e, t, n)) return !0; 3727 let u = !l && t.parent.canReplace(t.index(), t.index() + 1); 3728 if (u && (s = (c = i.contentMatchAt(i.childCount)).findWrapping(o.type)) && c.matchType(s[0] || o.type).validEnd) { 3729 if (n) { 3730 let r = t.pos + o.nodeSize, c = a.empty; 3731 for (let e = s.length - 1; e >= 0; e--) c = a.from(s[e].create(null, c)); 3732 c = a.from(i.copy(c)); 3733 let l = e.tr.step(new C(t.pos - 1, r, t.pos, r, new d(c, 1, 0), s.length, !0)), u = l.doc.resolve(r + 2 * s.length); 3734 u.nodeAfter && u.nodeAfter.type == i.type && Ut(l.doc, u.pos) && l.join(u.pos), n(l.scrollIntoView()); 3735 } 3736 return !0; 3737 } 3738 let f = o.type.spec.isolating || r > 0 && l ? null : w.findFrom(t, 1), p = f && f.$from.blockRange(f.$to), m = p && kt(p); 3739 if (m != null && m >= t.depth) return n && n(e.tr.lift(p, m).scrollIntoView()), !0; 3740 if (u && Wn(o, "start", !0) && Wn(i, "end")) { 3741 let r = i, s = []; 3742 for (; s.push(r), !r.isTextblock;) r = r.lastChild; 3743 let c = o, l = 1; 3744 for (; !c.isTextblock; c = c.firstChild) l++; 3745 if (r.canReplace(r.childCount, r.childCount, c.content)) { 3746 if (n) { 3747 let r = a.empty; 3748 for (let e = s.length - 1; e >= 0; e--) r = a.from(s[e].copy(r)); 3749 n(e.tr.step(new C(t.pos - s.length, t.pos + o.nodeSize, t.pos + l, t.pos + o.nodeSize - l, new d(r, s.length, 0), 0, !0)).scrollIntoView()); 3750 } 3751 return !0; 3752 } 3753 } 3754 return !1; 3755} 3756function dr(e) { 3757 return function(t, n) { 3758 let r = t.selection, i = e < 0 ? r.$from : r.$to, a = i.depth; 3759 for (; i.node(a).isInline;) { 3760 if (!a) return !1; 3761 a--; 3762 } 3763 return i.node(a).isTextblock ? (n && n(t.tr.setSelection(T.create(t.doc, e < 0 ? i.start(a) : i.end(a)))), !0) : !1; 3764 }; 3765} 3766var fr = dr(-1), pr = dr(1); 3767function mr(e, t = null) { 3768 return function(n, r) { 3769 let { $from: i, $to: a } = n.selection, o = i.blockRange(a), s = o && jt(o, e, t); 3770 return s ? (r && r(n.tr.wrap(o, s).scrollIntoView()), !0) : !1; 3771 }; 3772} 3773function hr(e, t = null) { 3774 return function(n, r) { 3775 let i = !1; 3776 for (let r = 0; r < n.selection.ranges.length && !i; r++) { 3777 let { $from: { pos: a }, $to: { pos: o } } = n.selection.ranges[r]; 3778 n.doc.nodesBetween(a, o, (r, a) => { 3779 if (i) return !1; 3780 if (!(!r.isTextblock || r.hasMarkup(e, t))) if (r.type == e) i = !0; 3781 else { 3782 let t = n.doc.resolve(a), r = t.index(); 3783 i = t.parent.canReplaceWith(r, r + 1, e); 3784 } 3785 }); 3786 } 3787 if (!i) return !1; 3788 if (r) { 3789 let i = n.tr; 3790 for (let r = 0; r < n.selection.ranges.length; r++) { 3791 let { $from: { pos: a }, $to: { pos: o } } = n.selection.ranges[r]; 3792 i.setBlockType(a, o, e, t); 3793 } 3794 r(i.scrollIntoView()); 3795 } 3796 return !0; 3797 }; 3798} 3799function gr(...e) { 3800 return function(t, n, r) { 3801 for (let i = 0; i < e.length; i++) if (e[i](t, n, r)) return !0; 3802 return !1; 3803 }; 3804} 3805var _r = gr(Rn, Bn, Gn), vr = gr(Rn, Jn, Yn), yr = { 3806 Enter: gr(er, rr, ir, or), 3807 "Mod-Enter": nr, 3808 Backspace: _r, 3809 "Mod-Backspace": _r, 3810 "Shift-Backspace": _r, 3811 Delete: vr, 3812 "Mod-Delete": vr, 3813 "Mod-a": cr 3814}, br = { 3815 "Ctrl-h": yr.Backspace, 3816 "Alt-Backspace": yr["Mod-Backspace"], 3817 "Ctrl-d": yr.Delete, 3818 "Ctrl-Alt-Backspace": yr["Mod-Delete"], 3819 "Alt-Delete": yr["Mod-Delete"], 3820 "Alt-d": yr["Mod-Delete"], 3821 "Ctrl-a": fr, 3822 "Ctrl-e": pr 3823}; 3824for (let e in yr) br[e] = yr[e]; 3825typeof navigator < "u" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os < "u" && os.platform && os.platform(); 3826//#endregion 3827//#region node_modules/prosemirror-schema-list/dist/index.js 3828function xr(e, t = null) { 3829 return function(n, r) { 3830 let { $from: i, $to: a } = n.selection, o = i.blockRange(a); 3831 if (!o) return !1; 3832 let s = r ? n.tr : null; 3833 return Sr(s, o, e, t) ? (r && r(s.scrollIntoView()), !0) : !1; 3834 }; 3835} 3836function Sr(e, t, n, r = null) { 3837 let i = !1, a = t, o = t.$from.doc; 3838 if (t.depth >= 2 && t.$from.node(t.depth - 1).type.compatibleContent(n) && t.startIndex == 0) { 3839 if (t.$from.index(t.depth - 1) == 0) return !1; 3840 let e = o.resolve(t.start - 2); 3841 a = new se(e, e, t.depth), t.endIndex < t.parent.childCount && (t = new se(t.$from, o.resolve(t.$to.end(t.depth)), t.depth)), i = !0; 3842 } 3843 let s = jt(a, n, r, t); 3844 return s ? (e && Cr(e, t, s, i, n), !0) : !1; 3845} 3846function Cr(e, t, n, r, i) { 3847 let o = a.empty; 3848 for (let e = n.length - 1; e >= 0; e--) o = a.from(n[e].type.create(n[e].attrs, o)); 3849 e.step(new C(t.start - (r ? 2 : 0), t.end, t.start, t.end, new d(o, 0, 0), n.length, !0)); 3850 let s = 0; 3851 for (let e = 0; e < n.length; e++) n[e].type == i && (s = e + 1); 3852 let c = n.length - s, l = t.start + n.length - (r ? 2 : 0), u = t.parent; 3853 for (let n = t.startIndex, r = t.endIndex, i = !0; n < r; n++, i = !1) !i && Vt(e.doc, l, c) && (e.split(l, c), l += 2 * c), l += u.child(n).nodeSize; 3854 return e; 3855} 3856function wr(e) { 3857 return function(t, n) { 3858 let { $from: r, $to: i } = t.selection, a = r.blockRange(i, (t) => t.childCount > 0 && t.firstChild.type == e); 3859 return a ? n ? r.node(a.depth - 1).type == e ? Tr(t, n, e, a) : Er(t, n, a) : !0 : !1; 3860 }; 3861} 3862function Tr(e, t, n, r) { 3863 let i = e.tr, o = r.end, s = r.$to.end(r.depth); 3864 o < s && (i.step(new C(o - 1, s, o, s, new d(a.from(n.create(null, r.parent.copy())), 1, 0), 1, !0)), r = new se(i.doc.resolve(r.$from.pos), i.doc.resolve(s), r.depth)); 3865 let c = kt(r); 3866 if (c == null) return !1; 3867 i.lift(r, c); 3868 let l = i.doc.resolve(i.mapping.map(o, -1) - 1); 3869 return Ut(i.doc, l.pos) && l.nodeBefore.type == l.nodeAfter.type && i.join(l.pos), t(i.scrollIntoView()), !0; 3870} 3871function Er(e, t, n) { 3872 let r = e.tr, i = n.parent; 3873 for (let e = n.end, t = n.endIndex - 1, a = n.startIndex; t > a; t--) e -= i.child(t).nodeSize, r.delete(e - 1, e + 1); 3874 let o = r.doc.resolve(n.start), s = o.nodeAfter; 3875 if (r.mapping.map(n.end) != n.start + o.nodeAfter.nodeSize) return !1; 3876 let c = n.startIndex == 0, l = n.endIndex == i.childCount, u = o.node(-1), f = o.index(-1); 3877 if (!u.canReplace(f + +!c, f + 1, s.content.append(l ? a.empty : a.from(i)))) return !1; 3878 let p = o.pos, m = p + s.nodeSize; 3879 return r.step(new C(p - +!!c, m + +!!l, p + 1, m - 1, new d((c ? a.empty : a.from(i.copy(a.empty))).append(l ? a.empty : a.from(i.copy(a.empty))), +!c, +!l), +!c)), t(r.scrollIntoView()), !0; 3880} 3881function Dr(e) { 3882 return function(t, n) { 3883 let { $from: r, $to: i } = t.selection, o = r.blockRange(i, (t) => t.childCount > 0 && t.firstChild.type == e); 3884 if (!o) return !1; 3885 let s = o.startIndex; 3886 if (s == 0) return !1; 3887 let c = o.parent, l = c.child(s - 1); 3888 if (l.type != e) return !1; 3889 if (n) { 3890 let r = l.lastChild && l.lastChild.type == c.type, i = a.from(r ? e.create() : null), s = new d(a.from(e.create(null, a.from(c.type.create(null, i)))), r ? 3 : 1, 0), u = o.start, f = o.end; 3891 n(t.tr.step(new C(u - (r ? 3 : 1), f, u, f, s, 1, !0)).scrollIntoView()); 3892 } 3893 return !0; 3894 }; 3895} 3896//#endregion 3897//#region node_modules/prosemirror-view/dist/index.js 3898var k = function(e) { 3899 for (var t = 0;; t++) if (e = e.previousSibling, !e) return t; 3900}, Or = function(e) { 3901 let t = e.assignedSlot || e.parentNode; 3902 return t && t.nodeType == 11 ? t.host : t; 3903}, kr = null, Ar = function(e, t, n) { 3904 let r = kr ||= document.createRange(); 3905 return r.setEnd(e, n ?? e.nodeValue.length), r.setStart(e, t || 0), r; 3906}, jr = function() { 3907 kr = null; 3908}, Mr = function(e, t, n, r) { 3909 return n && (Pr(e, t, n, r, -1) || Pr(e, t, n, r, 1)); 3910}, Nr = /^(img|br|input|textarea|hr)$/i; 3911function Pr(e, t, n, r, i) { 3912 for (;;) { 3913 if (e == n && t == r) return !0; 3914 if (t == (i < 0 ? 0 : Fr(e))) { 3915 let n = e.parentNode; 3916 if (!n || n.nodeType != 1 || zr(e) || Nr.test(e.nodeName) || e.contentEditable == "false") return !1; 3917 t = k(e) + (i < 0 ? 0 : 1), e = n; 3918 } else if (e.nodeType == 1) { 3919 let n = e.childNodes[t + (i < 0 ? -1 : 0)]; 3920 if (n.nodeType == 1 && n.contentEditable == "false") if (n.pmViewDesc?.ignoreForSelection) t += i; 3921 else return !1; 3922 else e = n, t = i < 0 ? Fr(e) : 0; 3923 } else return !1; 3924 } 3925} 3926function Fr(e) { 3927 return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length; 3928} 3929function Ir(e, t) { 3930 for (;;) { 3931 if (e.nodeType == 3 && t) return e; 3932 if (e.nodeType == 1 && t > 0) { 3933 if (e.contentEditable == "false") return null; 3934 e = e.childNodes[t - 1], t = Fr(e); 3935 } else if (e.parentNode && !zr(e)) t = k(e), e = e.parentNode; 3936 else return null; 3937 } 3938} 3939function Lr(e, t) { 3940 for (;;) { 3941 if (e.nodeType == 3 && t < e.nodeValue.length) return e; 3942 if (e.nodeType == 1 && t < e.childNodes.length) { 3943 if (e.contentEditable == "false") return null; 3944 e = e.childNodes[t], t = 0; 3945 } else if (e.parentNode && !zr(e)) t = k(e) + 1, e = e.parentNode; 3946 else return null; 3947 } 3948} 3949function Rr(e, t, n) { 3950 for (let r = t == 0, i = t == Fr(e); r || i;) { 3951 if (e == n) return !0; 3952 let t = k(e); 3953 if (e = e.parentNode, !e) return !1; 3954 r &&= t == 0, i &&= t == Fr(e); 3955 } 3956} 3957function zr(e) { 3958 let t; 3959 for (let n = e; n && !(t = n.pmViewDesc); n = n.parentNode); 3960 return t && t.node && t.node.isBlock && (t.dom == e || t.contentDOM == e); 3961} 3962var Br = function(e) { 3963 return e.focusNode && Mr(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset); 3964}; 3965function Vr(e, t) { 3966 let n = document.createEvent("Event"); 3967 return n.initEvent("keydown", !0, !0), n.keyCode = e, n.key = n.code = t, n; 3968} 3969function Hr(e) { 3970 let t = e.activeElement; 3971 for (; t && t.shadowRoot;) t = t.shadowRoot.activeElement; 3972 return t; 3973} 3974function Ur(e, t, n) { 3975 if (e.caretPositionFromPoint) try { 3976 let r = e.caretPositionFromPoint(t, n); 3977 if (r) return { 3978 node: r.offsetNode, 3979 offset: Math.min(Fr(r.offsetNode), r.offset) 3980 }; 3981 } catch {} 3982 if (e.caretRangeFromPoint) { 3983 let r = e.caretRangeFromPoint(t, n); 3984 if (r) return { 3985 node: r.startContainer, 3986 offset: Math.min(Fr(r.startContainer), r.startOffset) 3987 }; 3988 } 3989} 3990var Wr = typeof navigator < "u" ? navigator : null, Gr = typeof document < "u" ? document : null, Kr = Wr && Wr.userAgent || "", qr = /Edge\/(\d+)/.exec(Kr), Jr = /MSIE \d/.exec(Kr), Yr = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Kr), Xr = !!(Jr || Yr || qr), Zr = Jr ? document.documentMode : Yr ? +Yr[1] : qr ? +qr[1] : 0, Qr = !Xr && /gecko\/(\d+)/i.test(Kr); 3991Qr && +(/Firefox\/(\d+)/.exec(Kr) || [0, 0])[1]; 3992var $r = !Xr && /Chrome\/(\d+)/.exec(Kr), A = !!$r, ei = $r ? +$r[1] : 0, j = !Xr && !!Wr && /Apple Computer/.test(Wr.vendor), ti = j && (/Mobile\/\w+/.test(Kr) || !!Wr && Wr.maxTouchPoints > 2), ni = ti || (Wr ? /Mac/.test(Wr.platform) : !1), ri = Wr ? /Win/.test(Wr.platform) : !1, ii = /Android \d/.test(Kr), ai = !!Gr && "webkitFontSmoothing" in Gr.documentElement.style, oi = ai ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0; 3993function si(e) { 3994 let t = e.defaultView && e.defaultView.visualViewport; 3995 return t ? { 3996 left: 0, 3997 right: t.width, 3998 top: 0, 3999 bottom: t.height 4000 } : { 4001 left: 0, 4002 right: e.documentElement.clientWidth, 4003 top: 0, 4004 bottom: e.documentElement.clientHeight 4005 }; 4006} 4007function ci(e, t) { 4008 return typeof e == "number" ? e : e[t]; 4009} 4010function li(e) { 4011 let t = e.getBoundingClientRect(), n = t.width / e.offsetWidth || 1, r = t.height / e.offsetHeight || 1; 4012 return { 4013 left: t.left, 4014 right: t.left + e.clientWidth * n, 4015 top: t.top, 4016 bottom: t.top + e.clientHeight * r 4017 }; 4018} 4019function ui(e, t, n) { 4020 let r = e.someProp("scrollThreshold") || 0, i = e.someProp("scrollMargin") || 5, a = e.dom.ownerDocument; 4021 for (let o = n || e.dom; o;) { 4022 if (o.nodeType != 1) { 4023 o = Or(o); 4024 continue; 4025 } 4026 let e = o, n = e == a.body, s = n ? si(a) : li(e), c = 0, l = 0; 4027 if (t.top < s.top + ci(r, "top") ? l = -(s.top - t.top + ci(i, "top")) : t.bottom > s.bottom - ci(r, "bottom") && (l = t.bottom - t.top > s.bottom - s.top ? t.top + ci(i, "top") - s.top : t.bottom - s.bottom + ci(i, "bottom")), t.left < s.left + ci(r, "left") ? c = -(s.left - t.left + ci(i, "left")) : t.right > s.right - ci(r, "right") && (c = t.right - s.right + ci(i, "right")), c || l) if (n) a.defaultView.scrollBy(c, l); 4028 else { 4029 let n = e.scrollLeft, r = e.scrollTop; 4030 l && (e.scrollTop += l), c && (e.scrollLeft += c); 4031 let i = e.scrollLeft - n, a = e.scrollTop - r; 4032 t = { 4033 left: t.left - i, 4034 top: t.top - a, 4035 right: t.right - i, 4036 bottom: t.bottom - a 4037 }; 4038 } 4039 let u = n ? "fixed" : getComputedStyle(o).position; 4040 if (/^(fixed|sticky)$/.test(u)) break; 4041 o = u == "absolute" ? o.offsetParent : Or(o); 4042 } 4043} 4044function di(e) { 4045 let t = e.dom.getBoundingClientRect(), n = Math.max(0, t.top), r, i; 4046 for (let a = (t.left + t.right) / 2, o = n + 1; o < Math.min(innerHeight, t.bottom); o += 5) { 4047 let t = e.root.elementFromPoint(a, o); 4048 if (!t || t == e.dom || !e.dom.contains(t)) continue; 4049 let s = t.getBoundingClientRect(); 4050 if (s.top >= n - 20) { 4051 r = t, i = s.top; 4052 break; 4053 } 4054 } 4055 return { 4056 refDOM: r, 4057 refTop: i, 4058 stack: fi(e.dom) 4059 }; 4060} 4061function fi(e) { 4062 let t = [], n = e.ownerDocument; 4063 for (let r = e; r && (t.push({ 4064 dom: r, 4065 top: r.scrollTop, 4066 left: r.scrollLeft 4067 }), e != n); r = Or(r)); 4068 return t; 4069} 4070function pi({ refDOM: e, refTop: t, stack: n }) { 4071 let r = e ? e.getBoundingClientRect().top : 0; 4072 mi(n, r == 0 ? 0 : r - t); 4073} 4074function mi(e, t) { 4075 for (let n = 0; n < e.length; n++) { 4076 let { dom: r, top: i, left: a } = e[n]; 4077 r.scrollTop != i + t && (r.scrollTop = i + t), r.scrollLeft != a && (r.scrollLeft = a); 4078 } 4079} 4080var hi = null; 4081function gi(e) { 4082 if (e.setActive) return e.setActive(); 4083 if (hi) return e.focus(hi); 4084 let t = fi(e); 4085 e.focus(hi == null ? { get preventScroll() { 4086 return hi = { preventScroll: !0 }, !0; 4087 } } : void 0), hi || (hi = !1, mi(t, 0)); 4088} 4089function _i(e, t) { 4090 let n, r = 2e8, i, a = 0, o = t.top, s = t.top, c, l; 4091 for (let u = e.firstChild, d = 0; u; u = u.nextSibling, d++) { 4092 let e; 4093 if (u.nodeType == 1) e = u.getClientRects(); 4094 else if (u.nodeType == 3) e = Ar(u).getClientRects(); 4095 else continue; 4096 for (let f = 0; f < e.length; f++) { 4097 let p = e[f]; 4098 if (p.top <= o && p.bottom >= s) { 4099 o = Math.max(p.bottom, o), s = Math.min(p.top, s); 4100 let e = p.left > t.left ? p.left - t.left : p.right < t.left ? t.left - p.right : 0; 4101 if (e < r) { 4102 n = u, r = e, i = e && n.nodeType == 3 ? { 4103 left: p.right < t.left ? p.right : p.left, 4104 top: t.top 4105 } : t, u.nodeType == 1 && e && (a = d + +(t.left >= (p.left + p.right) / 2)); 4106 continue; 4107 } 4108 } else p.top > t.top && !c && p.left <= t.left && p.right >= t.left && (c = u, l = { 4109 left: Math.max(p.left, Math.min(p.right, t.left)), 4110 top: p.top 4111 }); 4112 !n && (t.left >= p.right && t.top >= p.top || t.left >= p.left && t.top >= p.bottom) && (a = d + 1); 4113 } 4114 } 4115 return !n && c && (n = c, i = l, r = 0), n && n.nodeType == 3 ? vi(n, i) : !n || r && n.nodeType == 1 ? { 4116 node: e, 4117 offset: a 4118 } : _i(n, i); 4119} 4120function vi(e, t) { 4121 let n = e.nodeValue.length, r = document.createRange(), i; 4122 for (let a = 0; a < n; a++) { 4123 r.setEnd(e, a + 1), r.setStart(e, a); 4124 let n = Ei(r, 1); 4125 if (n.top != n.bottom && yi(t, n)) { 4126 i = { 4127 node: e, 4128 offset: a + +(t.left >= (n.left + n.right) / 2) 4129 }; 4130 break; 4131 } 4132 } 4133 return r.detach(), i || { 4134 node: e, 4135 offset: 0 4136 }; 4137} 4138function yi(e, t) { 4139 return e.left >= t.left - 1 && e.left <= t.right + 1 && e.top >= t.top - 1 && e.top <= t.bottom + 1; 4140} 4141function bi(e, t) { 4142 let n = e.parentNode; 4143 return n && /^li$/i.test(n.nodeName) && t.left < e.getBoundingClientRect().left ? n : e; 4144} 4145function xi(e, t, n) { 4146 let { node: r, offset: i } = _i(t, n), a = -1; 4147 if (r.nodeType == 1 && !r.firstChild) { 4148 let e = r.getBoundingClientRect(); 4149 a = e.left != e.right && n.left > (e.left + e.right) / 2 ? 1 : -1; 4150 } 4151 return e.docView.posFromDOM(r, i, a); 4152} 4153function Si(e, t, n, r) { 4154 let i = -1; 4155 for (let n = t, a = !1; n != e.dom;) { 4156 let t = e.docView.nearestDesc(n, !0), o; 4157 if (!t) return null; 4158 if (t.dom.nodeType == 1 && (t.node.isBlock && t.parent || !t.contentDOM) && ((o = t.dom.getBoundingClientRect()).width || o.height) && (t.node.isBlock && t.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName) && (!a && o.left > r.left || o.top > r.top ? i = t.posBefore : (!a && o.right < r.left || o.bottom < r.top) && (i = t.posAfter), a = !0), !t.contentDOM && i < 0 && !t.node.isText)) return (t.node.isBlock ? r.top < (o.top + o.bottom) / 2 : r.left < (o.left + o.right) / 2) ? t.posBefore : t.posAfter; 4159 n = t.dom.parentNode; 4160 } 4161 return i > -1 ? i : e.docView.posFromDOM(t, n, -1); 4162} 4163function Ci(e, t, n) { 4164 let r = e.childNodes.length; 4165 if (r && n.top < n.bottom) for (let i = Math.max(0, Math.min(r - 1, Math.floor(r * (t.top - n.top) / (n.bottom - n.top)) - 2)), a = i;;) { 4166 let n = e.childNodes[a]; 4167 if (n.nodeType == 1) { 4168 let e = n.getClientRects(); 4169 for (let r = 0; r < e.length; r++) { 4170 let i = e[r]; 4171 if (yi(t, i)) return Ci(n, t, i); 4172 } 4173 } 4174 if ((a = (a + 1) % r) == i) break; 4175 } 4176 return e; 4177} 4178function wi(e, t) { 4179 let n = e.dom.ownerDocument, r, i = 0, a = Ur(n, t.left, t.top); 4180 a && ({node: r, offset: i} = a); 4181 let o = (e.root.elementFromPoint ? e.root : n).elementFromPoint(t.left, t.top), s; 4182 if (!o || !e.dom.contains(o.nodeType == 1 ? o : o.parentNode)) { 4183 let n = e.dom.getBoundingClientRect(); 4184 if (!yi(t, n) || (o = Ci(e.dom, t, n), !o)) return null; 4185 } 4186 if (j) for (let e = o; r && e; e = Or(e)) e.draggable && (r = void 0); 4187 if (o = bi(o, t), r) { 4188 if (Qr && r.nodeType == 1 && (i = Math.min(i, r.childNodes.length), i < r.childNodes.length)) { 4189 let e = r.childNodes[i], n; 4190 e.nodeName == "IMG" && (n = e.getBoundingClientRect()).right <= t.left && n.bottom > t.top && i++; 4191 } 4192 let n; 4193 ai && i && r.nodeType == 1 && (n = r.childNodes[i - 1]).nodeType == 1 && n.contentEditable == "false" && n.getBoundingClientRect().top >= t.top && i--, r == e.dom && i == r.childNodes.length - 1 && r.lastChild.nodeType == 1 && t.top > r.lastChild.getBoundingClientRect().bottom ? s = e.state.doc.content.size : (i == 0 || r.nodeType != 1 || r.childNodes[i - 1].nodeName != "BR") && (s = Si(e, r, i, t)); 4194 } 4195 s ??= xi(e, o, t); 4196 let c = e.docView.nearestDesc(o, !0); 4197 return { 4198 pos: s, 4199 inside: c ? c.posAtStart - c.border : -1 4200 }; 4201} 4202function Ti(e) { 4203 return e.top < e.bottom || e.left < e.right; 4204} 4205function Ei(e, t) { 4206 let n = e.getClientRects(); 4207 if (n.length) { 4208 let e = n[t < 0 ? 0 : n.length - 1]; 4209 if (Ti(e)) return e; 4210 } 4211 return Array.prototype.find.call(n, Ti) || e.getBoundingClientRect(); 4212} 4213var Di = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/; 4214function Oi(e, t, n) { 4215 let { node: r, offset: i, atom: a } = e.docView.domFromPos(t, n < 0 ? -1 : 1), o = ai || Qr; 4216 if (r.nodeType == 3) if (o && (Di.test(r.nodeValue) || (n < 0 ? !i : i == r.nodeValue.length))) { 4217 let e = Ei(Ar(r, i, i), n); 4218 if (Qr && i && /\s/.test(r.nodeValue[i - 1]) && i < r.nodeValue.length) { 4219 let t = Ei(Ar(r, i - 1, i - 1), -1); 4220 if (t.top == e.top) { 4221 let n = Ei(Ar(r, i, i + 1), -1); 4222 if (n.top != e.top) return ki(n, n.left < t.left); 4223 } 4224 } 4225 return e; 4226 } else { 4227 let e = i, t = i, a = n < 0 ? 1 : -1; 4228 return n < 0 && !i ? (t++, a = -1) : n >= 0 && i == r.nodeValue.length ? (e--, a = 1) : n < 0 ? e-- : t++, ki(Ei(Ar(r, e, t), a), a < 0); 4229 } 4230 if (!e.state.doc.resolve(t - (a || 0)).parent.inlineContent) { 4231 if (a == null && i && (n < 0 || i == Fr(r))) { 4232 let e = r.childNodes[i - 1]; 4233 if (e.nodeType == 1) return Ai(e.getBoundingClientRect(), !1); 4234 } 4235 if (a == null && i < Fr(r)) { 4236 let e = r.childNodes[i]; 4237 if (e.nodeType == 1) return Ai(e.getBoundingClientRect(), !0); 4238 } 4239 return Ai(r.getBoundingClientRect(), n >= 0); 4240 } 4241 if (a == null && i && (n < 0 || i == Fr(r))) { 4242 let e = r.childNodes[i - 1], t = e.nodeType == 3 ? Ar(e, Fr(e) - +!o) : e.nodeType == 1 && (e.nodeName != "BR" || !e.nextSibling) ? e : null; 4243 if (t) return ki(Ei(t, 1), !1); 4244 } 4245 if (a == null && i < Fr(r)) { 4246 let e = r.childNodes[i]; 4247 for (; e.pmViewDesc && e.pmViewDesc.ignoreForCoords;) e = e.nextSibling; 4248 let t = e ? e.nodeType == 3 ? Ar(e, 0, +!o) : e.nodeType == 1 ? e : null : null; 4249 if (t) return ki(Ei(t, -1), !0); 4250 } 4251 return ki(Ei(r.nodeType == 3 ? Ar(r) : r, -n), n >= 0); 4252} 4253function ki(e, t) { 4254 if (e.width == 0) return e; 4255 let n = t ? e.left : e.right; 4256 return { 4257 top: e.top, 4258 bottom: e.bottom, 4259 left: n, 4260 right: n 4261 }; 4262} 4263function Ai(e, t) { 4264 if (e.height == 0) return e; 4265 let n = t ? e.top : e.bottom; 4266 return { 4267 top: n, 4268 bottom: n, 4269 left: e.left, 4270 right: e.right 4271 }; 4272} 4273function ji(e, t, n) { 4274 let r = e.state, i = e.root.activeElement; 4275 r != t && e.updateState(t), i != e.dom && e.focus(); 4276 try { 4277 return n(); 4278 } finally { 4279 r != t && e.updateState(r), i != e.dom && i && i.focus(); 4280 } 4281} 4282function Mi(e, t, n) { 4283 let r = t.selection, i = n == "up" ? r.$from : r.$to; 4284 return ji(e, t, () => { 4285 let { node: t } = e.docView.domFromPos(i.pos, n == "up" ? -1 : 1); 4286 for (;;) { 4287 let n = e.docView.nearestDesc(t, !0); 4288 if (!n) break; 4289 if (n.node.isBlock) { 4290 t = n.contentDOM || n.dom; 4291 break; 4292 } 4293 t = n.dom.parentNode; 4294 } 4295 let r = Oi(e, i.pos, 1); 4296 for (let e = t.firstChild; e; e = e.nextSibling) { 4297 let t; 4298 if (e.nodeType == 1) t = e.getClientRects(); 4299 else if (e.nodeType == 3) t = Ar(e, 0, e.nodeValue.length).getClientRects(); 4300 else continue; 4301 for (let e = 0; e < t.length; e++) { 4302 let i = t[e]; 4303 if (i.bottom > i.top + 1 && (n == "up" ? r.top - i.top > (i.bottom - r.top) * 2 : i.bottom - r.bottom > (r.bottom - i.top) * 2)) return !1; 4304 } 4305 } 4306 return !0; 4307 }); 4308} 4309var Ni = /[\u0590-\u08ac]/; 4310function Pi(e, t, n) { 4311 let { $head: r } = t.selection; 4312 if (!r.parent.isTextblock) return !1; 4313 let i = r.parentOffset, a = !i, o = i == r.parent.content.size, s = e.domSelection(); 4314 return s ? !Ni.test(r.parent.textContent) || !s.modify ? n == "left" || n == "backward" ? a : o : ji(e, t, () => { 4315 let { focusNode: t, focusOffset: i, anchorNode: a, anchorOffset: o } = e.domSelectionRange(), c = s.caretBidiLevel; 4316 s.modify("move", n, "character"); 4317 let l = r.depth ? e.docView.domAfterPos(r.before()) : e.dom, { focusNode: u, focusOffset: d } = e.domSelectionRange(), f = u && !l.contains(u.nodeType == 1 ? u : u.parentNode) || t == u && i == d; 4318 try { 4319 s.collapse(a, o), t && (t != a || i != o) && s.extend && s.extend(t, i); 4320 } catch {} 4321 return c != null && (s.caretBidiLevel = c), f; 4322 }) : r.pos == r.start() || r.pos == r.end(); 4323} 4324var Fi = null, Ii = null, Li = !1; 4325function Ri(e, t, n) { 4326 return Fi == t && Ii == n ? Li : (Fi = t, Ii = n, Li = n == "up" || n == "down" ? Mi(e, t, n) : Pi(e, t, n)); 4327} 4328var zi = 0, Bi = 1, Vi = 2, Hi = 3, Ui = class { 4329 constructor(e, t, n, r) { 4330 this.parent = e, this.children = t, this.dom = n, this.contentDOM = r, this.dirty = zi, n.pmViewDesc = this; 4331 } 4332 matchesWidget(e) { 4333 return !1; 4334 } 4335 matchesMark(e) { 4336 return !1; 4337 } 4338 matchesNode(e, t, n) { 4339 return !1; 4340 } 4341 matchesHack(e) { 4342 return !1; 4343 } 4344 parseRule() { 4345 return null; 4346 } 4347 stopEvent(e) { 4348 return !1; 4349 } 4350 get size() { 4351 let e = 0; 4352 for (let t = 0; t < this.children.length; t++) e += this.children[t].size; 4353 return e; 4354 } 4355 get border() { 4356 return 0; 4357 } 4358 destroy() { 4359 this.parent = void 0, this.dom.pmViewDesc == this && (this.dom.pmViewDesc = void 0); 4360 for (let e = 0; e < this.children.length; e++) this.children[e].destroy(); 4361 } 4362 posBeforeChild(e) { 4363 for (let t = 0, n = this.posAtStart;; t++) { 4364 let r = this.children[t]; 4365 if (r == e) return n; 4366 n += r.size; 4367 } 4368 } 4369 get posBefore() { 4370 return this.parent.posBeforeChild(this); 4371 } 4372 get posAtStart() { 4373 return this.parent ? this.parent.posBeforeChild(this) + this.border : 0; 4374 } 4375 get posAfter() { 4376 return this.posBefore + this.size; 4377 } 4378 get posAtEnd() { 4379 return this.posAtStart + this.size - 2 * this.border; 4380 } 4381 localPosFromDOM(e, t, n) { 4382 if (this.contentDOM && this.contentDOM.contains(e.nodeType == 1 ? e : e.parentNode)) if (n < 0) { 4383 let n, r; 4384 if (e == this.contentDOM) n = e.childNodes[t - 1]; 4385 else { 4386 for (; e.parentNode != this.contentDOM;) e = e.parentNode; 4387 n = e.previousSibling; 4388 } 4389 for (; n && !((r = n.pmViewDesc) && r.parent == this);) n = n.previousSibling; 4390 return n ? this.posBeforeChild(r) + r.size : this.posAtStart; 4391 } else { 4392 let n, r; 4393 if (e == this.contentDOM) n = e.childNodes[t]; 4394 else { 4395 for (; e.parentNode != this.contentDOM;) e = e.parentNode; 4396 n = e.nextSibling; 4397 } 4398 for (; n && !((r = n.pmViewDesc) && r.parent == this);) n = n.nextSibling; 4399 return n ? this.posBeforeChild(r) : this.posAtEnd; 4400 } 4401 let r; 4402 if (e == this.dom && this.contentDOM) r = t > k(this.contentDOM); 4403 else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) r = e.compareDocumentPosition(this.contentDOM) & 2; 4404 else if (this.dom.firstChild) { 4405 if (t == 0) for (let t = e;; t = t.parentNode) { 4406 if (t == this.dom) { 4407 r = !1; 4408 break; 4409 } 4410 if (t.previousSibling) break; 4411 } 4412 if (r == null && t == e.childNodes.length) for (let t = e;; t = t.parentNode) { 4413 if (t == this.dom) { 4414 r = !0; 4415 break; 4416 } 4417 if (t.nextSibling) break; 4418 } 4419 } 4420 return r ?? n > 0 ? this.posAtEnd : this.posAtStart; 4421 } 4422 nearestDesc(e, t = !1) { 4423 for (let n = !0, r = e; r; r = r.parentNode) { 4424 let i = this.getDesc(r), a; 4425 if (i && (!t || i.node)) if (n && (a = i.nodeDOM) && !(a.nodeType == 1 ? a.contains(e.nodeType == 1 ? e : e.parentNode) : a == e)) n = !1; 4426 else return i; 4427 } 4428 } 4429 getDesc(e) { 4430 let t = e.pmViewDesc; 4431 for (let e = t; e; e = e.parent) if (e == this) return t; 4432 } 4433 posFromDOM(e, t, n) { 4434 for (let r = e; r; r = r.parentNode) { 4435 let i = this.getDesc(r); 4436 if (i) return i.localPosFromDOM(e, t, n); 4437 } 4438 return -1; 4439 } 4440 descAt(e) { 4441 for (let t = 0, n = 0; t < this.children.length; t++) { 4442 let r = this.children[t], i = n + r.size; 4443 if (n == e && i != n) { 4444 for (; !r.border && r.children.length;) for (let e = 0; e < r.children.length; e++) { 4445 let t = r.children[e]; 4446 if (t.size) { 4447 r = t; 4448 break; 4449 } 4450 } 4451 return r; 4452 } 4453 if (e < i) return r.descAt(e - n - r.border); 4454 n = i; 4455 } 4456 } 4457 domFromPos(e, t) { 4458 if (!this.contentDOM) return { 4459 node: this.dom, 4460 offset: 0, 4461 atom: e + 1 4462 }; 4463 let n = 0, r = 0; 4464 for (let t = 0; n < this.children.length; n++) { 4465 let i = this.children[n], a = t + i.size; 4466 if (a > e || i instanceof Xi) { 4467 r = e - t; 4468 break; 4469 } 4470 t = a; 4471 } 4472 if (r) return this.children[n].domFromPos(r - this.children[n].border, t); 4473 for (let e; n && !(e = this.children[n - 1]).size && e instanceof Wi && e.side >= 0; n--); 4474 if (t <= 0) { 4475 let e, r = !0; 4476 for (; e = n ? this.children[n - 1] : null, !(!e || e.dom.parentNode == this.contentDOM); n--, r = !1); 4477 return e && t && r && !e.border && !e.domAtom ? e.domFromPos(e.size, t) : { 4478 node: this.contentDOM, 4479 offset: e ? k(e.dom) + 1 : 0 4480 }; 4481 } else { 4482 let e, r = !0; 4483 for (; e = n < this.children.length ? this.children[n] : null, !(!e || e.dom.parentNode == this.contentDOM); n++, r = !1); 4484 return e && r && !e.border && !e.domAtom ? e.domFromPos(0, t) : { 4485 node: this.contentDOM, 4486 offset: e ? k(e.dom) : this.contentDOM.childNodes.length 4487 }; 4488 } 4489 } 4490 parseRange(e, t, n = 0) { 4491 if (this.children.length == 0) return { 4492 node: this.contentDOM, 4493 from: e, 4494 to: t, 4495 fromOffset: 0, 4496 toOffset: this.contentDOM.childNodes.length 4497 }; 4498 let r = -1, i = -1; 4499 for (let a = n, o = 0;; o++) { 4500 let n = this.children[o], s = a + n.size; 4501 if (r == -1 && e <= s) { 4502 let i = a + n.border; 4503 if (e >= i && t <= s - n.border && n.node && n.contentDOM && this.contentDOM.contains(n.contentDOM)) return n.parseRange(e, t, i); 4504 e = a; 4505 for (let t = o; t > 0; t--) { 4506 let n = this.children[t - 1]; 4507 if (n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(1)) { 4508 r = k(n.dom) + 1; 4509 break; 4510 } 4511 e -= n.size; 4512 } 4513 r == -1 && (r = 0); 4514 } 4515 if (r > -1 && (s > t || o == this.children.length - 1)) { 4516 t = s; 4517 for (let e = o + 1; e < this.children.length; e++) { 4518 let n = this.children[e]; 4519 if (n.size && n.dom.parentNode == this.contentDOM && !n.emptyChildAt(-1)) { 4520 i = k(n.dom); 4521 break; 4522 } 4523 t += n.size; 4524 } 4525 i == -1 && (i = this.contentDOM.childNodes.length); 4526 break; 4527 } 4528 a = s; 4529 } 4530 return { 4531 node: this.contentDOM, 4532 from: e, 4533 to: t, 4534 fromOffset: r, 4535 toOffset: i 4536 }; 4537 } 4538 emptyChildAt(e) { 4539 if (this.border || !this.contentDOM || !this.children.length) return !1; 4540 let t = this.children[e < 0 ? 0 : this.children.length - 1]; 4541 return t.size == 0 || t.emptyChildAt(e); 4542 } 4543 domAfterPos(e) { 4544 let { node: t, offset: n } = this.domFromPos(e, 0); 4545 if (t.nodeType != 1 || n == t.childNodes.length) throw RangeError("No node after pos " + e); 4546 return t.childNodes[n]; 4547 } 4548 setSelection(e, t, n, r = !1) { 4549 let i = Math.min(e, t), a = Math.max(e, t); 4550 for (let o = 0, s = 0; o < this.children.length; o++) { 4551 let c = this.children[o], l = s + c.size; 4552 if (i > s && a < l) return c.setSelection(e - s - c.border, t - s - c.border, n, r); 4553 s = l; 4554 } 4555 let o = this.domFromPos(e, e ? -1 : 1), s = t == e ? o : this.domFromPos(t, t ? -1 : 1), c = n.root.getSelection(), l = n.domSelectionRange(), u = !1; 4556 if ((Qr || j) && e == t) { 4557 let { node: e, offset: t } = o; 4558 if (e.nodeType == 3) { 4559 if (u = !!(t && e.nodeValue[t - 1] == "\n"), u && t == e.nodeValue.length) for (let t = e, n; t; t = t.parentNode) { 4560 if (n = t.nextSibling) { 4561 n.nodeName == "BR" && (o = s = { 4562 node: n.parentNode, 4563 offset: k(n) + 1 4564 }); 4565 break; 4566 } 4567 let e = t.pmViewDesc; 4568 if (e && e.node && e.node.isBlock) break; 4569 } 4570 } else { 4571 let n = e.childNodes[t - 1]; 4572 u = n && (n.nodeName == "BR" || n.contentEditable == "false"); 4573 } 4574 } 4575 if (Qr && l.focusNode && l.focusNode != s.node && l.focusNode.nodeType == 1) { 4576 let e = l.focusNode.childNodes[l.focusOffset]; 4577 e && e.contentEditable == "false" && (r = !0); 4578 } 4579 if (!(r || u && j) && Mr(o.node, o.offset, l.anchorNode, l.anchorOffset) && Mr(s.node, s.offset, l.focusNode, l.focusOffset)) return; 4580 let d = !1; 4581 if ((c.extend || e == t) && !(u && Qr)) { 4582 c.collapse(o.node, o.offset); 4583 try { 4584 e != t && c.extend(s.node, s.offset), d = !0; 4585 } catch {} 4586 } 4587 if (!d) { 4588 if (e > t) { 4589 let e = o; 4590 o = s, s = e; 4591 } 4592 let n = document.createRange(); 4593 n.setEnd(s.node, s.offset), n.setStart(o.node, o.offset), c.removeAllRanges(), c.addRange(n); 4594 } 4595 } 4596 ignoreMutation(e) { 4597 return !this.contentDOM && e.type != "selection"; 4598 } 4599 get contentLost() { 4600 return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM); 4601 } 4602 markDirty(e, t) { 4603 for (let n = 0, r = 0; r < this.children.length; r++) { 4604 let i = this.children[r], a = n + i.size; 4605 if (n == a ? e <= a && t >= n : e < a && t > n) { 4606 let r = n + i.border, o = a - i.border; 4607 if (e >= r && t <= o) { 4608 this.dirty = e == n || t == a ? Vi : Bi, e == r && t == o && (i.contentLost || i.dom.parentNode != this.contentDOM) ? i.dirty = Hi : i.markDirty(e - r, t - r); 4609 return; 4610 } else i.dirty = i.dom == i.contentDOM && i.dom.parentNode == this.contentDOM && !i.children.length ? Vi : Hi; 4611 } 4612 n = a; 4613 } 4614 this.dirty = Vi; 4615 } 4616 markParentsDirty() { 4617 let e = 1; 4618 for (let t = this.parent; t; t = t.parent, e++) { 4619 let n = e == 1 ? Vi : Bi; 4620 t.dirty < n && (t.dirty = n); 4621 } 4622 } 4623 get domAtom() { 4624 return !1; 4625 } 4626 get ignoreForCoords() { 4627 return !1; 4628 } 4629 get ignoreForSelection() { 4630 return !1; 4631 } 4632 isText(e) { 4633 return !1; 4634 } 4635}, Wi = class extends Ui { 4636 constructor(e, t, n, r) { 4637 let i, a = t.type.toDOM; 4638 if (typeof a == "function" && (a = a(n, () => { 4639 if (!i) return r; 4640 if (i.parent) return i.parent.posBeforeChild(i); 4641 })), !t.type.spec.raw) { 4642 if (a.nodeType != 1) { 4643 let e = document.createElement("span"); 4644 e.appendChild(a), a = e; 4645 } 4646 a.contentEditable = "false", a.classList.add("ProseMirror-widget"); 4647 } 4648 super(e, [], a, null), this.widget = t, this.widget = t, i = this; 4649 } 4650 matchesWidget(e) { 4651 return this.dirty == zi && e.type.eq(this.widget.type); 4652 } 4653 parseRule() { 4654 return { ignore: !0 }; 4655 } 4656 stopEvent(e) { 4657 let t = this.widget.spec.stopEvent; 4658 return t ? t(e) : !1; 4659 } 4660 ignoreMutation(e) { 4661 return e.type != "selection" || this.widget.spec.ignoreSelection; 4662 } 4663 destroy() { 4664 this.widget.type.destroy(this.dom), super.destroy(); 4665 } 4666 get domAtom() { 4667 return !0; 4668 } 4669 get ignoreForSelection() { 4670 return !!this.widget.type.spec.relaxedSide; 4671 } 4672 get side() { 4673 return this.widget.type.side; 4674 } 4675}, Gi = class extends Ui { 4676 constructor(e, t, n, r) { 4677 super(e, [], t, null), this.textDOM = n, this.text = r; 4678 } 4679 get size() { 4680 return this.text.length; 4681 } 4682 localPosFromDOM(e, t) { 4683 return e == this.textDOM ? this.posAtStart + t : this.posAtStart + (t ? this.size : 0); 4684 } 4685 domFromPos(e) { 4686 return { 4687 node: this.textDOM, 4688 offset: e 4689 }; 4690 } 4691 ignoreMutation(e) { 4692 return e.type === "characterData" && e.target.nodeValue == e.oldValue; 4693 } 4694}, Ki = class e extends Ui { 4695 constructor(e, t, n, r, i) { 4696 super(e, [], n, r), this.mark = t, this.spec = i; 4697 } 4698 static create(t, n, r, i) { 4699 let a = i.nodeViews[n.type.name], o = a && a(n, i, r); 4700 return (!o || !o.dom) && (o = Qe.renderSpec(document, n.type.spec.toDOM(n, r), null, n.attrs)), new e(t, n, o.dom, o.contentDOM || o.dom, o); 4701 } 4702 parseRule() { 4703 return this.dirty & Hi || this.mark.type.spec.reparseInView ? null : { 4704 mark: this.mark.type.name, 4705 attrs: this.mark.attrs, 4706 contentElement: this.contentDOM 4707 }; 4708 } 4709 matchesMark(e) { 4710 return this.dirty != Hi && this.mark.eq(e); 4711 } 4712 markDirty(e, t) { 4713 if (super.markDirty(e, t), this.dirty != zi) { 4714 let e = this.parent; 4715 for (; !e.node;) e = e.parent; 4716 e.dirty < this.dirty && (e.dirty = this.dirty), this.dirty = zi; 4717 } 4718 } 4719 slice(t, n, r) { 4720 let i = e.create(this.parent, this.mark, !0, r), a = this.children, o = this.size; 4721 n < o && (a = pa(a, n, o, r)), t > 0 && (a = pa(a, 0, t, r)); 4722 for (let e = 0; e < a.length; e++) a[e].parent = i; 4723 return i.children = a, i; 4724 } 4725 ignoreMutation(e) { 4726 return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e); 4727 } 4728 destroy() { 4729 this.spec.destroy && this.spec.destroy(), super.destroy(); 4730 } 4731}, qi = class e extends Ui { 4732 constructor(e, t, n, r, i, a, o, s, c) { 4733 super(e, [], i, a), this.node = t, this.outerDeco = n, this.innerDeco = r, this.nodeDOM = o; 4734 } 4735 static create(t, n, r, i, a, o) { 4736 let s = a.nodeViews[n.type.name], c, l = s && s(n, a, () => { 4737 if (!c) return o; 4738 if (c.parent) return c.parent.posBeforeChild(c); 4739 }, r, i), u = l && l.dom, d = l && l.contentDOM; 4740 if (n.isText) { 4741 if (!u) u = document.createTextNode(n.text); 4742 else if (u.nodeType != 3) throw RangeError("Text must be rendered as a DOM text node"); 4743 } else if (!u) { 4744 let e = Qe.renderSpec(document, n.type.spec.toDOM(n), null, n.attrs); 4745 ({dom: u, contentDOM: d} = e); 4746 } 4747 !d && !n.isText && u.nodeName != "BR" && (u.hasAttribute("contenteditable") || (u.contentEditable = "false"), n.type.spec.draggable && (u.draggable = !0)); 4748 let f = u; 4749 return u = ia(u, r, n), l ? c = new Zi(t, n, r, i, u, d || null, f, l, a, o + 1) : n.isText ? new Yi(t, n, r, i, u, f, a) : new e(t, n, r, i, u, d || null, f, a, o + 1); 4750 } 4751 parseRule() { 4752 if (this.node.type.spec.reparseInView) return null; 4753 let e = { 4754 node: this.node.type.name, 4755 attrs: this.node.attrs 4756 }; 4757 if (this.node.type.whitespace == "pre" && (e.preserveWhitespace = "full"), !this.contentDOM) e.getContent = () => this.node.content; 4758 else if (!this.contentLost) e.contentElement = this.contentDOM; 4759 else { 4760 for (let t = this.children.length - 1; t >= 0; t--) { 4761 let n = this.children[t]; 4762 if (this.dom.contains(n.dom.parentNode)) { 4763 e.contentElement = n.dom.parentNode; 4764 break; 4765 } 4766 } 4767 e.contentElement || (e.getContent = () => a.empty); 4768 } 4769 return e; 4770 } 4771 matchesNode(e, t, n) { 4772 return this.dirty == zi && e.eq(this.node) && aa(t, this.outerDeco) && n.eq(this.innerDeco); 4773 } 4774 get size() { 4775 return this.node.nodeSize; 4776 } 4777 get border() { 4778 return +!this.node.isLeaf; 4779 } 4780 updateChildren(e, t) { 4781 let n = this.node.inlineContent, r = t, i = e.composing ? this.localCompositionInfo(e, t) : null, a = i && i.pos > -1 ? i : null, o = i && i.pos < 0, s = new sa(this, a && a.node, e); 4782 ua(this.node, this.innerDeco, (t, i, a) => { 4783 t.spec.marks ? s.syncToMarks(t.spec.marks, n, e, i) : t.type.side >= 0 && !a && s.syncToMarks(i == this.node.childCount ? l.none : this.node.child(i).marks, n, e, i), s.placeWidget(t, e, r); 4784 }, (t, a, c, l) => { 4785 s.syncToMarks(t.marks, n, e, l); 4786 let u; 4787 s.findNodeMatch(t, a, c, l) || o && e.state.selection.from > r && e.state.selection.to < r + t.nodeSize && (u = s.findIndexWithChild(i.node)) > -1 && s.updateNodeAt(t, a, c, u, e) || s.updateNextNode(t, a, c, e, l, r) || s.addNode(t, a, c, e, r), r += t.nodeSize; 4788 }), s.syncToMarks([], n, e, 0), this.node.isTextblock && s.addTextblockHacks(), s.destroyRest(), (s.changed || this.dirty == Vi) && (a && this.protectLocalComposition(e, a), Qi(this.contentDOM, this.children, e), ti && da(this.dom)); 4789 } 4790 localCompositionInfo(e, t) { 4791 let { from: n, to: r } = e.state.selection; 4792 if (!(e.state.selection instanceof T) || n < t || r > t + this.node.content.size) return null; 4793 let i = e.input.compositionNode; 4794 if (!i || !this.dom.contains(i.parentNode)) return null; 4795 if (this.node.inlineContent) { 4796 let e = i.nodeValue, a = fa(this.node.content, e, n - t, r - t); 4797 return a < 0 ? null : { 4798 node: i, 4799 pos: a, 4800 text: e 4801 }; 4802 } else return { 4803 node: i, 4804 pos: -1, 4805 text: "" 4806 }; 4807 } 4808 protectLocalComposition(e, { node: t, pos: n, text: r }) { 4809 if (this.getDesc(t)) return; 4810 let i = t; 4811 for (; i.parentNode != this.contentDOM; i = i.parentNode) { 4812 for (; i.previousSibling;) i.parentNode.removeChild(i.previousSibling); 4813 for (; i.nextSibling;) i.parentNode.removeChild(i.nextSibling); 4814 i.pmViewDesc &&= void 0; 4815 } 4816 let a = new Gi(this, i, t, r); 4817 e.input.compositionNodes.push(a), this.children = pa(this.children, n, n + r.length, e, a); 4818 } 4819 update(e, t, n, r) { 4820 return this.dirty == Hi || !e.sameMarkup(this.node) ? !1 : (this.updateInner(e, t, n, r), !0); 4821 } 4822 updateInner(e, t, n, r) { 4823 this.updateOuterDeco(t), this.node = e, this.innerDeco = n, this.contentDOM && this.updateChildren(r, this.posAtStart), this.dirty = zi; 4824 } 4825 updateOuterDeco(e) { 4826 if (aa(e, this.outerDeco)) return; 4827 let t = this.nodeDOM.nodeType != 1, n = this.dom; 4828 this.dom = na(this.dom, this.nodeDOM, ta(this.outerDeco, this.node, t), ta(e, this.node, t)), this.dom != n && (n.pmViewDesc = void 0, this.dom.pmViewDesc = this), this.outerDeco = e; 4829 } 4830 selectNode() { 4831 this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.add("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && (this.nodeDOM.draggable = !0)); 4832 } 4833 deselectNode() { 4834 this.nodeDOM.nodeType == 1 && (this.nodeDOM.classList.remove("ProseMirror-selectednode"), (this.contentDOM || !this.node.type.spec.draggable) && this.nodeDOM.removeAttribute("draggable")); 4835 } 4836 get domAtom() { 4837 return this.node.isAtom; 4838 } 4839}; 4840function Ji(e, t, n, r, i) { 4841 ia(r, t, e); 4842 let a = new qi(void 0, e, t, n, r, r, r, i, 0); 4843 return a.contentDOM && a.updateChildren(i, 0), a; 4844} 4845var Yi = class e extends qi { 4846 constructor(e, t, n, r, i, a, o) { 4847 super(e, t, n, r, i, null, a, o, 0); 4848 } 4849 parseRule() { 4850 let e = this.nodeDOM.parentNode; 4851 for (; e && e != this.dom && !e.pmIsDeco;) e = e.parentNode; 4852 return { skip: e || !0 }; 4853 } 4854 update(e, t, n, r) { 4855 return this.dirty == Hi || this.dirty != zi && !this.inParent() || !e.sameMarkup(this.node) ? !1 : (this.updateOuterDeco(t), (this.dirty != zi || e.text != this.node.text) && e.text != this.nodeDOM.nodeValue && (this.nodeDOM.nodeValue = e.text, r.trackWrites == this.nodeDOM && (r.trackWrites = null)), this.node = e, this.dirty = zi, !0); 4856 } 4857 inParent() { 4858 let e = this.parent.contentDOM; 4859 for (let t = this.nodeDOM; t; t = t.parentNode) if (t == e) return !0; 4860 return !1; 4861 } 4862 domFromPos(e) { 4863 return { 4864 node: this.nodeDOM, 4865 offset: e 4866 }; 4867 } 4868 localPosFromDOM(e, t, n) { 4869 return e == this.nodeDOM ? this.posAtStart + Math.min(t, this.node.text.length) : super.localPosFromDOM(e, t, n); 4870 } 4871 ignoreMutation(e) { 4872 return e.type != "characterData" && e.type != "selection"; 4873 } 4874 slice(t, n, r) { 4875 let i = this.node.cut(t, n), a = document.createTextNode(i.text); 4876 return new e(this.parent, i, this.outerDeco, this.innerDeco, a, a, r); 4877 } 4878 markDirty(e, t) { 4879 super.markDirty(e, t), this.dom != this.nodeDOM && (e == 0 || t == this.nodeDOM.nodeValue.length) && (this.dirty = Hi); 4880 } 4881 get domAtom() { 4882 return !1; 4883 } 4884 isText(e) { 4885 return this.node.text == e; 4886 } 4887}, Xi = class extends Ui { 4888 parseRule() { 4889 return { ignore: !0 }; 4890 } 4891 matchesHack(e) { 4892 return this.dirty == zi && this.dom.nodeName == e; 4893 } 4894 get domAtom() { 4895 return !0; 4896 } 4897 get ignoreForCoords() { 4898 return this.dom.nodeName == "IMG"; 4899 } 4900}, Zi = class extends qi { 4901 constructor(e, t, n, r, i, a, o, s, c, l) { 4902 super(e, t, n, r, i, a, o, c, l), this.spec = s; 4903 } 4904 update(e, t, n, r) { 4905 if (this.dirty == Hi) return !1; 4906 if (this.spec.update && (this.node.type == e.type || this.spec.multiType)) { 4907 let i = this.spec.update(e, t, n); 4908 return i && this.updateInner(e, t, n, r), i; 4909 } else if (!this.contentDOM && !e.isLeaf) return !1; 4910 else return super.update(e, t, n, r); 4911 } 4912 selectNode() { 4913 this.spec.selectNode ? this.spec.selectNode() : super.selectNode(); 4914 } 4915 deselectNode() { 4916 this.spec.deselectNode ? this.spec.deselectNode() : super.deselectNode(); 4917 } 4918 setSelection(e, t, n, r) { 4919 this.spec.setSelection ? this.spec.setSelection(e, t, n.root) : super.setSelection(e, t, n, r); 4920 } 4921 destroy() { 4922 this.spec.destroy && this.spec.destroy(), super.destroy(); 4923 } 4924 stopEvent(e) { 4925 return this.spec.stopEvent ? this.spec.stopEvent(e) : !1; 4926 } 4927 ignoreMutation(e) { 4928 return this.spec.ignoreMutation ? this.spec.ignoreMutation(e) : super.ignoreMutation(e); 4929 } 4930}; 4931function Qi(e, t, n) { 4932 let r = e.firstChild, i = !1; 4933 for (let a = 0; a < t.length; a++) { 4934 let o = t[a], s = o.dom; 4935 if (s.parentNode == e) { 4936 for (; s != r;) r = oa(r), i = !0; 4937 r = r.nextSibling; 4938 } else i = !0, e.insertBefore(s, r); 4939 if (o instanceof Ki) { 4940 let t = r ? r.previousSibling : e.lastChild; 4941 Qi(o.contentDOM, o.children, n), r = t ? t.nextSibling : e.firstChild; 4942 } 4943 } 4944 for (; r;) r = oa(r), i = !0; 4945 i && n.trackWrites == e && (n.trackWrites = null); 4946} 4947var $i = function(e) { 4948 e && (this.nodeName = e); 4949}; 4950$i.prototype = Object.create(null); 4951var ea = [new $i()]; 4952function ta(e, t, n) { 4953 if (e.length == 0) return ea; 4954 let r = n ? ea[0] : new $i(), i = [r]; 4955 for (let a = 0; a < e.length; a++) { 4956 let o = e[a].type.attrs; 4957 if (o) { 4958 o.nodeName && i.push(r = new $i(o.nodeName)); 4959 for (let e in o) { 4960 let a = o[e]; 4961 a != null && (n && i.length == 1 && i.push(r = new $i(t.isInline ? "span" : "div")), e == "class" ? r.class = (r.class ? r.class + " " : "") + a : e == "style" ? r.style = (r.style ? r.style + ";" : "") + a : e != "nodeName" && (r[e] = a)); 4962 } 4963 } 4964 } 4965 return i; 4966} 4967function na(e, t, n, r) { 4968 if (n == ea && r == ea) return t; 4969 let i = t; 4970 for (let t = 0; t < r.length; t++) { 4971 let a = r[t], o = n[t]; 4972 if (t) { 4973 let t; 4974 o && o.nodeName == a.nodeName && i != e && (t = i.parentNode) && t.nodeName.toLowerCase() == a.nodeName ? i = t : (t = document.createElement(a.nodeName), t.pmIsDeco = !0, t.appendChild(i), o = ea[0], i = t); 4975 } 4976 ra(i, o || ea[0], a); 4977 } 4978 return i; 4979} 4980function ra(e, t, n) { 4981 for (let r in t) r != "class" && r != "style" && r != "nodeName" && !(r in n) && e.removeAttribute(r); 4982 for (let r in n) r != "class" && r != "style" && r != "nodeName" && n[r] != t[r] && e.setAttribute(r, n[r]); 4983 if (t.class != n.class) { 4984 let r = t.class ? t.class.split(" ").filter(Boolean) : [], i = n.class ? n.class.split(" ").filter(Boolean) : []; 4985 for (let t = 0; t < r.length; t++) i.indexOf(r[t]) == -1 && e.classList.remove(r[t]); 4986 for (let t = 0; t < i.length; t++) r.indexOf(i[t]) == -1 && e.classList.add(i[t]); 4987 e.classList.length == 0 && e.removeAttribute("class"); 4988 } 4989 if (t.style != n.style) { 4990 if (t.style) { 4991 let n = /\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g, r; 4992 for (; r = n.exec(t.style);) e.style.removeProperty(r[1]); 4993 } 4994 n.style && (e.style.cssText += n.style); 4995 } 4996} 4997function ia(e, t, n) { 4998 return na(e, e, ea, ta(t, n, e.nodeType != 1)); 4999} 5000function aa(e, t) { 5001 if (e.length != t.length) return !1; 5002 for (let n = 0; n < e.length; n++) if (!e[n].type.eq(t[n].type)) return !1; 5003 return !0; 5004} 5005function oa(e) { 5006 let t = e.nextSibling; 5007 return e.parentNode.removeChild(e), t; 5008} 5009var sa = class { 5010 constructor(e, t, n) { 5011 this.lock = t, this.view = n, this.index = 0, this.stack = [], this.changed = !1, this.top = e, this.preMatch = ca(e.node.content, e); 5012 } 5013 destroyBetween(e, t) { 5014 if (e != t) { 5015 for (let n = e; n < t; n++) this.top.children[n].destroy(); 5016 this.top.children.splice(e, t - e), this.changed = !0; 5017 } 5018 } 5019 destroyRest() { 5020 this.destroyBetween(this.index, this.top.children.length); 5021 } 5022 syncToMarks(e, t, n, r) { 5023 let i = 0, a = this.stack.length >> 1, o = Math.min(a, e.length); 5024 for (; i < o && (i == a - 1 ? this.top : this.stack[i + 1 << 1]).matchesMark(e[i]) && e[i].type.spec.spanning !== !1;) i++; 5025 for (; i < a;) this.destroyRest(), this.top.dirty = zi, this.index = this.stack.pop(), this.top = this.stack.pop(), a--; 5026 for (; a < e.length;) { 5027 this.stack.push(this.top, this.index + 1); 5028 let i = -1, o = this.top.children.length; 5029 r < this.preMatch.index && (o = Math.min(this.index + 3, o)); 5030 for (let t = this.index; t < o; t++) { 5031 let n = this.top.children[t]; 5032 if (n.matchesMark(e[a]) && !this.isLocked(n.dom)) { 5033 i = t; 5034 break; 5035 } 5036 } 5037 if (i > -1) i > this.index && (this.changed = !0, this.destroyBetween(this.index, i)), this.top = this.top.children[this.index]; 5038 else { 5039 let r = Ki.create(this.top, e[a], t, n); 5040 this.top.children.splice(this.index, 0, r), this.top = r, this.changed = !0; 5041 } 5042 this.index = 0, a++; 5043 } 5044 } 5045 findNodeMatch(e, t, n, r) { 5046 let i = -1, a; 5047 if (r >= this.preMatch.index && (a = this.preMatch.matches[r - this.preMatch.index]).parent == this.top && a.matchesNode(e, t, n)) i = this.top.children.indexOf(a, this.index); 5048 else for (let r = this.index, a = Math.min(this.top.children.length, r + 5); r < a; r++) { 5049 let a = this.top.children[r]; 5050 if (a.matchesNode(e, t, n) && !this.preMatch.matched.has(a)) { 5051 i = r; 5052 break; 5053 } 5054 } 5055 return i < 0 ? !1 : (this.destroyBetween(this.index, i), this.index++, !0); 5056 } 5057 updateNodeAt(e, t, n, r, i) { 5058 let a = this.top.children[r]; 5059 return a.dirty == Hi && a.dom == a.contentDOM && (a.dirty = Vi), a.update(e, t, n, i) ? (this.destroyBetween(this.index, r), this.index++, !0) : !1; 5060 } 5061 findIndexWithChild(e) { 5062 for (;;) { 5063 let t = e.parentNode; 5064 if (!t) return -1; 5065 if (t == this.top.contentDOM) { 5066 let t = e.pmViewDesc; 5067 if (t) { 5068 for (let e = this.index; e < this.top.children.length; e++) if (this.top.children[e] == t) return e; 5069 } 5070 return -1; 5071 } 5072 e = t; 5073 } 5074 } 5075 updateNextNode(e, t, n, r, i, a) { 5076 for (let o = this.index; o < this.top.children.length; o++) { 5077 let s = this.top.children[o]; 5078 if (s instanceof qi) { 5079 let c = this.preMatch.matched.get(s); 5080 if (c != null && c != i) return !1; 5081 let l = s.dom, u, d = this.isLocked(l) && !(e.isText && s.node && s.node.isText && s.nodeDOM.nodeValue == e.text && s.dirty != Hi && aa(t, s.outerDeco)); 5082 if (!d && s.update(e, t, n, r)) return this.destroyBetween(this.index, o), s.dom != l && (this.changed = !0), this.index++, !0; 5083 if (!d && (u = this.recreateWrapper(s, e, t, n, r, a))) return this.destroyBetween(this.index, o), this.top.children[this.index] = u, u.contentDOM && (u.dirty = Vi, u.updateChildren(r, a + 1), u.dirty = zi), this.changed = !0, this.index++, !0; 5084 break; 5085 } 5086 } 5087 return !1; 5088 } 5089 recreateWrapper(e, t, n, r, i, a) { 5090 if (e.dirty || t.isAtom || !e.children.length || !e.node.content.eq(t.content) || !aa(n, e.outerDeco) || !r.eq(e.innerDeco)) return null; 5091 let o = qi.create(this.top, t, n, r, i, a); 5092 if (o.contentDOM) { 5093 o.children = e.children, e.children = []; 5094 for (let e of o.children) e.parent = o; 5095 } 5096 return e.destroy(), o; 5097 } 5098 addNode(e, t, n, r, i) { 5099 let a = qi.create(this.top, e, t, n, r, i); 5100 a.contentDOM && a.updateChildren(r, i + 1), this.top.children.splice(this.index++, 0, a), this.changed = !0; 5101 } 5102 placeWidget(e, t, n) { 5103 let r = this.index < this.top.children.length ? this.top.children[this.index] : null; 5104 if (r && r.matchesWidget(e) && (e == r.widget || !r.widget.type.toDOM.parentNode)) this.index++; 5105 else { 5106 let r = new Wi(this.top, e, t, n); 5107 this.top.children.splice(this.index++, 0, r), this.changed = !0; 5108 } 5109 } 5110 addTextblockHacks() { 5111 let e = this.top.children[this.index - 1], t = this.top; 5112 for (; e instanceof Ki;) t = e, e = t.children[t.children.length - 1]; 5113 (!e || !(e instanceof Yi) || /\n$/.test(e.node.text) || this.view.requiresGeckoHackNode && /\s$/.test(e.node.text)) && ((j || A) && e && e.dom.contentEditable == "false" && this.addHackNode("IMG", t), this.addHackNode("BR", this.top)); 5114 } 5115 addHackNode(e, t) { 5116 if (t == this.top && this.index < t.children.length && t.children[this.index].matchesHack(e)) this.index++; 5117 else { 5118 let n = document.createElement(e); 5119 e == "IMG" && (n.className = "ProseMirror-separator", n.alt = ""), e == "BR" && (n.className = "ProseMirror-trailingBreak"); 5120 let r = new Xi(this.top, [], n, null); 5121 t == this.top ? t.children.splice(this.index++, 0, r) : t.children.push(r), this.changed = !0; 5122 } 5123 } 5124 isLocked(e) { 5125 return this.lock && (e == this.lock || e.nodeType == 1 && e.contains(this.lock.parentNode)); 5126 } 5127}; 5128function ca(e, t) { 5129 let n = t, r = n.children.length, i = e.childCount, a = /* @__PURE__ */ new Map(), o = []; 5130 outer: for (; i > 0;) { 5131 let s; 5132 for (;;) if (r) { 5133 let e = n.children[r - 1]; 5134 if (e instanceof Ki) n = e, r = e.children.length; 5135 else { 5136 s = e, r--; 5137 break; 5138 } 5139 } else if (n == t) break outer; 5140 else r = n.parent.children.indexOf(n), n = n.parent; 5141 let c = s.node; 5142 if (c) { 5143 if (c != e.child(i - 1)) break; 5144 --i, a.set(s, i), o.push(s); 5145 } 5146 } 5147 return { 5148 index: i, 5149 matched: a, 5150 matches: o.reverse() 5151 }; 5152} 5153function la(e, t) { 5154 return e.type.side - t.type.side; 5155} 5156function ua(e, t, n, r) { 5157 let i = t.locals(e), a = 0; 5158 if (i.length == 0) { 5159 for (let n = 0; n < e.childCount; n++) { 5160 let o = e.child(n); 5161 r(o, i, t.forChild(a, o), n), a += o.nodeSize; 5162 } 5163 return; 5164 } 5165 let o = 0, s = [], c = null; 5166 for (let l = 0;;) { 5167 let u, d; 5168 for (; o < i.length && i[o].to == a;) { 5169 let e = i[o++]; 5170 e.widget && (u ? (d ||= [u]).push(e) : u = e); 5171 } 5172 if (u) if (d) { 5173 d.sort(la); 5174 for (let e = 0; e < d.length; e++) n(d[e], l, !!c); 5175 } else n(u, l, !!c); 5176 let f, p; 5177 if (c) p = -1, f = c, c = null; 5178 else if (l < e.childCount) p = l, f = e.child(l++); 5179 else break; 5180 for (let e = 0; e < s.length; e++) s[e].to <= a && s.splice(e--, 1); 5181 for (; o < i.length && i[o].from <= a && i[o].to > a;) s.push(i[o++]); 5182 let m = a + f.nodeSize; 5183 if (f.isText) { 5184 let e = m; 5185 o < i.length && i[o].from < e && (e = i[o].from); 5186 for (let t = 0; t < s.length; t++) s[t].to < e && (e = s[t].to); 5187 e < m && (c = f.cut(e - a), f = f.cut(0, e - a), m = e, p = -1); 5188 } else for (; o < i.length && i[o].to < m;) o++; 5189 let h = f.isInline && !f.isLeaf ? s.filter((e) => !e.inline) : s.slice(); 5190 r(f, h, t.forChild(a, f), p), a = m; 5191 } 5192} 5193function da(e) { 5194 if (e.nodeName == "UL" || e.nodeName == "OL") { 5195 let t = e.style.cssText; 5196 e.style.cssText = t + "; list-style: square !important", window.getComputedStyle(e).listStyle, e.style.cssText = t; 5197 } 5198} 5199function fa(e, t, n, r) { 5200 for (let i = 0, a = 0; i < e.childCount && a <= r;) { 5201 let o = e.child(i++), s = a; 5202 if (a += o.nodeSize, !o.isText) continue; 5203 let c = o.text; 5204 for (; i < e.childCount;) { 5205 let t = e.child(i++); 5206 if (a += t.nodeSize, !t.isText) break; 5207 c += t.text; 5208 } 5209 if (a >= n) { 5210 if (a >= r && c.slice(r - t.length - s, r - s) == t) return r - t.length; 5211 let e = s < r ? c.lastIndexOf(t, r - s - 1) : -1; 5212 if (e >= 0 && e + t.length + s >= n) return s + e; 5213 if (n == r && c.length >= r + t.length - s && c.slice(r - s, r - s + t.length) == t) return r; 5214 } 5215 } 5216 return -1; 5217} 5218function pa(e, t, n, r, i) { 5219 let a = []; 5220 for (let o = 0, s = 0; o < e.length; o++) { 5221 let c = e[o], l = s, u = s += c.size; 5222 l >= n || u <= t ? a.push(c) : (l < t && a.push(c.slice(0, t - l, r)), i &&= (a.push(i), void 0), u > n && a.push(c.slice(n - l, c.size, r))); 5223 } 5224 return a; 5225} 5226function ma(e, t = null) { 5227 let n = e.domSelectionRange(), r = e.state.doc; 5228 if (!n.focusNode) return null; 5229 let i = e.docView.nearestDesc(n.focusNode), a = i && i.size == 0, o = e.docView.posFromDOM(n.focusNode, n.focusOffset, 1); 5230 if (o < 0) return null; 5231 let s = r.resolve(o), c, l; 5232 if (Br(n)) { 5233 for (c = o; i && !i.node;) i = i.parent; 5234 let e = i.node; 5235 if (i && e.isAtom && E.isSelectable(e) && i.parent && !(e.isInline && Rr(n.focusNode, n.focusOffset, i.dom))) { 5236 let e = i.posBefore; 5237 l = new E(o == e ? s : r.resolve(e)); 5238 } 5239 } else { 5240 if (n instanceof e.dom.ownerDocument.defaultView.Selection && n.rangeCount > 1) { 5241 let t = o, i = o; 5242 for (let r = 0; r < n.rangeCount; r++) { 5243 let a = n.getRangeAt(r); 5244 t = Math.min(t, e.docView.posFromDOM(a.startContainer, a.startOffset, 1)), i = Math.max(i, e.docView.posFromDOM(a.endContainer, a.endOffset, -1)); 5245 } 5246 if (t < 0) return null; 5247 [c, o] = i == e.state.selection.anchor ? [i, t] : [t, i], s = r.resolve(o); 5248 } else c = e.docView.posFromDOM(n.anchorNode, n.anchorOffset, 1); 5249 if (c < 0) return null; 5250 } 5251 let u = r.resolve(c); 5252 if (!l) { 5253 let n = t == "pointer" || e.state.selection.head < s.pos && !a ? 1 : -1; 5254 l = Ta(e, u, s, n); 5255 } 5256 return l; 5257} 5258function ha(e) { 5259 return e.editable ? e.hasFocus() : Da(e) && document.activeElement && document.activeElement.contains(e.dom); 5260} 5261function ga(e, t = !1) { 5262 let n = e.state.selection; 5263 if (Ca(e, n), !ha(e)) return; 5264 let r = e.input.mouseDown; 5265 if (!t && A && r) { 5266 let t = e.domSelectionRange(), n = e.domObserver.currentSelection; 5267 if (t.anchorNode && n.anchorNode && Mr(t.anchorNode, t.anchorOffset, n.anchorNode, n.anchorOffset) && r.delaySelUpdate()) { 5268 e.domObserver.setCurSelection(); 5269 return; 5270 } 5271 } 5272 if (e.domObserver.disconnectSelection(), e.cursorWrapper) Sa(e); 5273 else { 5274 let { anchor: r, head: i } = n, a, o; 5275 _a && !(n instanceof T) && (n.$from.parent.inlineContent || (a = va(e, n.from)), !n.empty && !n.$from.parent.inlineContent && (o = va(e, n.to))), e.docView.setSelection(r, i, e, t), _a && (a && ba(a), o && ba(o)), n.visible ? e.dom.classList.remove("ProseMirror-hideselection") : (e.dom.classList.add("ProseMirror-hideselection"), "onselectionchange" in document && xa(e)); 5276 } 5277 e.domObserver.setCurSelection(), e.domObserver.connectSelection(); 5278} 5279var _a = j || A && ei < 63; 5280function va(e, t) { 5281 let { node: n, offset: r } = e.docView.domFromPos(t, 0), i = r < n.childNodes.length ? n.childNodes[r] : null, a = r ? n.childNodes[r - 1] : null; 5282 if (j && i && i.contentEditable == "false") return ya(i); 5283 if ((!i || i.contentEditable == "false") && (!a || a.contentEditable == "false")) { 5284 if (i) return ya(i); 5285 if (a) return ya(a); 5286 } 5287} 5288function ya(e) { 5289 return e.contentEditable = "true", j && e.draggable && (e.draggable = !1, e.wasDraggable = !0), e; 5290} 5291function ba(e) { 5292 e.contentEditable = "false", e.wasDraggable &&= (e.draggable = !0, null); 5293} 5294function xa(e) { 5295 let t = e.dom.ownerDocument; 5296 t.removeEventListener("selectionchange", e.input.hideSelectionGuard); 5297 let n = e.domSelectionRange(), r = n.anchorNode, i = n.anchorOffset; 5298 t.addEventListener("selectionchange", e.input.hideSelectionGuard = () => { 5299 (n.anchorNode != r || n.anchorOffset != i) && (t.removeEventListener("selectionchange", e.input.hideSelectionGuard), setTimeout(() => { 5300 (!ha(e) || e.state.selection.visible) && e.dom.classList.remove("ProseMirror-hideselection"); 5301 }, 20)); 5302 }); 5303} 5304function Sa(e) { 5305 let t = e.domSelection(); 5306 if (!t) return; 5307 let n = e.cursorWrapper.dom, r = n.nodeName == "IMG"; 5308 r ? t.collapse(n.parentNode, k(n) + 1) : t.collapse(n, 0), !r && !e.state.selection.visible && Xr && Zr <= 11 && (n.disabled = !0, n.disabled = !1); 5309} 5310function Ca(e, t) { 5311 if (t instanceof E) { 5312 let n = e.docView.descAt(t.from); 5313 n != e.lastSelectedViewDesc && (wa(e), n && n.selectNode(), e.lastSelectedViewDesc = n); 5314 } else wa(e); 5315} 5316function wa(e) { 5317 e.lastSelectedViewDesc &&= (e.lastSelectedViewDesc.parent && e.lastSelectedViewDesc.deselectNode(), void 0); 5318} 5319function Ta(e, t, n, r) { 5320 return e.someProp("createSelectionBetween", (r) => r(e, t, n)) || T.between(t, n, r); 5321} 5322function Ea(e) { 5323 return e.editable && !e.hasFocus() ? !1 : Da(e); 5324} 5325function Da(e) { 5326 let t = e.domSelectionRange(); 5327 if (!t.anchorNode) return !1; 5328 try { 5329 return e.dom.contains(t.anchorNode.nodeType == 3 ? t.anchorNode.parentNode : t.anchorNode) && (e.editable || e.dom.contains(t.focusNode.nodeType == 3 ? t.focusNode.parentNode : t.focusNode)); 5330 } catch { 5331 return !1; 5332 } 5333} 5334function Oa(e) { 5335 let t = e.docView.domFromPos(e.state.selection.anchor, 0), n = e.domSelectionRange(); 5336 return Mr(t.node, t.offset, n.anchorNode, n.anchorOffset); 5337} 5338function ka(e, t) { 5339 let { $anchor: n, $head: r } = e.selection, i = t > 0 ? n.max(r) : n.min(r), a = i.parent.inlineContent ? i.depth ? e.doc.resolve(t > 0 ? i.after() : i.before()) : null : i; 5340 return a && w.findFrom(a, t); 5341} 5342function Aa(e, t) { 5343 return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()), !0; 5344} 5345function ja(e, t, n) { 5346 let r = e.state.selection; 5347 if (r instanceof T) { 5348 if (n.indexOf("s") > -1) { 5349 let { $head: n } = r, i = n.textOffset ? null : t < 0 ? n.nodeBefore : n.nodeAfter; 5350 if (!i || i.isText || !i.isLeaf) return !1; 5351 let a = e.state.doc.resolve(n.pos + i.nodeSize * (t < 0 ? -1 : 1)); 5352 return Aa(e, new T(r.$anchor, a)); 5353 } else if (!r.empty) return !1; 5354 else if (e.endOfTextblock(t > 0 ? "forward" : "backward")) { 5355 let n = ka(e.state, t); 5356 return n && n instanceof E ? Aa(e, n) : !1; 5357 } else if (!(ni && n.indexOf("m") > -1)) { 5358 let n = r.$head, i = n.textOffset ? null : t < 0 ? n.nodeBefore : n.nodeAfter, a; 5359 if (!i || i.isText) return !1; 5360 let o = t < 0 ? n.pos - i.nodeSize : n.pos; 5361 return i.isAtom || (a = e.docView.descAt(o)) && !a.contentDOM ? E.isSelectable(i) ? Aa(e, new E(t < 0 ? e.state.doc.resolve(n.pos - i.nodeSize) : n)) : ai ? Aa(e, new T(e.state.doc.resolve(t < 0 ? o : o + i.nodeSize))) : !1 : !1; 5362 } 5363 } else if (r instanceof E && r.node.isInline) return Aa(e, new T(t > 0 ? r.$to : r.$from)); 5364 else { 5365 let n = ka(e.state, t); 5366 return n ? Aa(e, n) : !1; 5367 } 5368} 5369function Ma(e) { 5370 return e.nodeType == 3 ? e.nodeValue.length : e.childNodes.length; 5371} 5372function Na(e, t) { 5373 let n = e.pmViewDesc; 5374 return n && n.size == 0 && (t < 0 || e.nextSibling || e.nodeName != "BR"); 5375} 5376function Pa(e, t) { 5377 return t < 0 ? Fa(e) : Ia(e); 5378} 5379function Fa(e) { 5380 let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset; 5381 if (!n) return; 5382 let i, a, o = !1; 5383 for (Qr && n.nodeType == 1 && r < Ma(n) && Na(n.childNodes[r], -1) && (o = !0);;) if (r > 0) { 5384 if (n.nodeType != 1) break; 5385 { 5386 let e = n.childNodes[r - 1]; 5387 if (Na(e, -1)) i = n, a = --r; 5388 else if (e.nodeType == 3) n = e, r = n.nodeValue.length; 5389 else break; 5390 } 5391 } else if (La(n)) break; 5392 else { 5393 let t = n.previousSibling; 5394 for (; t && Na(t, -1);) i = n.parentNode, a = k(t), t = t.previousSibling; 5395 if (t) n = t, r = Ma(n); 5396 else { 5397 if (n = n.parentNode, n == e.dom) break; 5398 r = 0; 5399 } 5400 } 5401 o ? Ba(e, n, r) : i && Ba(e, i, a); 5402} 5403function Ia(e) { 5404 let t = e.domSelectionRange(), n = t.focusNode, r = t.focusOffset; 5405 if (!n) return; 5406 let i = Ma(n), a, o; 5407 for (;;) if (r < i) { 5408 if (n.nodeType != 1) break; 5409 let e = n.childNodes[r]; 5410 if (Na(e, 1)) a = n, o = ++r; 5411 else break; 5412 } else if (La(n)) break; 5413 else { 5414 let t = n.nextSibling; 5415 for (; t && Na(t, 1);) a = t.parentNode, o = k(t) + 1, t = t.nextSibling; 5416 if (t) n = t, r = 0, i = Ma(n); 5417 else { 5418 if (n = n.parentNode, n == e.dom) break; 5419 r = i = 0; 5420 } 5421 } 5422 a && Ba(e, a, o); 5423} 5424function La(e) { 5425 let t = e.pmViewDesc; 5426 return t && t.node && t.node.isBlock; 5427} 5428function Ra(e, t) { 5429 for (; e && t == e.childNodes.length && !zr(e);) t = k(e) + 1, e = e.parentNode; 5430 for (; e && t < e.childNodes.length;) { 5431 let n = e.childNodes[t]; 5432 if (n.nodeType == 3) return n; 5433 if (n.nodeType == 1 && n.contentEditable == "false") break; 5434 e = n, t = 0; 5435 } 5436} 5437function za(e, t) { 5438 for (; e && !t && !zr(e);) t = k(e), e = e.parentNode; 5439 for (; e && t;) { 5440 let n = e.childNodes[t - 1]; 5441 if (n.nodeType == 3) return n; 5442 if (n.nodeType == 1 && n.contentEditable == "false") break; 5443 e = n, t = e.childNodes.length; 5444 } 5445} 5446function Ba(e, t, n) { 5447 if (t.nodeType != 3) { 5448 let e, r; 5449 (r = Ra(t, n)) ? (t = r, n = 0) : (e = za(t, n)) && (t = e, n = e.nodeValue.length); 5450 } 5451 let r = e.domSelection(); 5452 if (!r) return; 5453 if (Br(r)) { 5454 let e = document.createRange(); 5455 e.setEnd(t, n), e.setStart(t, n), r.removeAllRanges(), r.addRange(e); 5456 } else r.extend && r.extend(t, n); 5457 e.domObserver.setCurSelection(); 5458 let { state: i } = e; 5459 setTimeout(() => { 5460 e.state == i && ga(e); 5461 }, 50); 5462} 5463function Va(e, t) { 5464 let n = e.state.doc.resolve(t); 5465 if (!(A || ri) && n.parent.inlineContent) { 5466 let r = e.coordsAtPos(t); 5467 if (t > n.start()) { 5468 let n = e.coordsAtPos(t - 1), i = (n.top + n.bottom) / 2; 5469 if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left < r.left ? "ltr" : "rtl"; 5470 } 5471 if (t < n.end()) { 5472 let n = e.coordsAtPos(t + 1), i = (n.top + n.bottom) / 2; 5473 if (i > r.top && i < r.bottom && Math.abs(n.left - r.left) > 1) return n.left > r.left ? "ltr" : "rtl"; 5474 } 5475 } 5476 return getComputedStyle(e.dom).direction == "rtl" ? "rtl" : "ltr"; 5477} 5478function Ha(e, t, n) { 5479 let r = e.state.selection; 5480 if (r instanceof T && !r.empty || n.indexOf("s") > -1 || ni && n.indexOf("m") > -1) return !1; 5481 let { $from: i, $to: a } = r; 5482 if (!i.parent.inlineContent || e.endOfTextblock(t < 0 ? "up" : "down")) { 5483 let n = ka(e.state, t); 5484 if (n && n instanceof E) return Aa(e, n); 5485 } 5486 if (!i.parent.inlineContent) { 5487 let n = t < 0 ? i : a, o = r instanceof Sn ? w.near(n, t) : w.findFrom(n, t); 5488 return o ? Aa(e, o) : !1; 5489 } 5490 return !1; 5491} 5492function Ua(e, t) { 5493 if (!(e.state.selection instanceof T)) return !0; 5494 let { $head: n, $anchor: r, empty: i } = e.state.selection; 5495 if (!n.sameParent(r)) return !0; 5496 if (!i) return !1; 5497 if (e.endOfTextblock(t > 0 ? "forward" : "backward")) return !0; 5498 let a = !n.textOffset && (t < 0 ? n.nodeBefore : n.nodeAfter); 5499 if (a && !a.isText) { 5500 let r = e.state.tr; 5501 return t < 0 ? r.delete(n.pos - a.nodeSize, n.pos) : r.delete(n.pos, n.pos + a.nodeSize), e.dispatch(r), !0; 5502 } 5503 return !1; 5504} 5505function Wa(e, t, n) { 5506 e.domObserver.stop(), t.contentEditable = n, e.domObserver.start(); 5507} 5508function Ga(e) { 5509 if (!j || e.state.selection.$head.parentOffset > 0) return !1; 5510 let { focusNode: t, focusOffset: n } = e.domSelectionRange(); 5511 if (t && t.nodeType == 1 && n == 0 && t.firstChild && t.firstChild.contentEditable == "false") { 5512 let n = t.firstChild; 5513 Wa(e, n, "true"), setTimeout(() => Wa(e, n, "false"), 20); 5514 } 5515 return !1; 5516} 5517function Ka(e) { 5518 let t = ""; 5519 return e.ctrlKey && (t += "c"), e.metaKey && (t += "m"), e.altKey && (t += "a"), e.shiftKey && (t += "s"), t; 5520} 5521function qa(e, t) { 5522 let n = t.keyCode, r = Ka(t); 5523 if (n == 8 || ni && n == 72 && r == "c") return Ua(e, -1) || Pa(e, -1); 5524 if (n == 46 && !t.shiftKey || ni && n == 68 && r == "c") return Ua(e, 1) || Pa(e, 1); 5525 if (n == 13 || n == 27) return !0; 5526 if (n == 37 || ni && n == 66 && r == "c") { 5527 let t = n == 37 ? Va(e, e.state.selection.from) == "ltr" ? -1 : 1 : -1; 5528 return ja(e, t, r) || Pa(e, t); 5529 } else if (n == 39 || ni && n == 70 && r == "c") { 5530 let t = n == 39 ? Va(e, e.state.selection.from) == "ltr" ? 1 : -1 : 1; 5531 return ja(e, t, r) || Pa(e, t); 5532 } else if (n == 38 || ni && n == 80 && r == "c") return Ha(e, -1, r) || Pa(e, -1); 5533 else if (n == 40 || ni && n == 78 && r == "c") return Ga(e) || Ha(e, 1, r) || Pa(e, 1); 5534 else if (r == (ni ? "m" : "c") && (n == 66 || n == 73 || n == 89 || n == 90)) return !0; 5535 return !1; 5536} 5537function Ja(e, t) { 5538 e.someProp("transformCopied", (n) => { 5539 t = n(t, e); 5540 }); 5541 let n = [], { content: r, openStart: i, openEnd: a } = t; 5542 for (; i > 1 && a > 1 && r.childCount == 1 && r.firstChild.childCount == 1;) { 5543 i--, a--; 5544 let e = r.firstChild; 5545 n.push(e.type.name, e.attrs == e.type.defaultAttrs ? null : e.attrs), r = e.content; 5546 } 5547 let o = e.someProp("clipboardSerializer") || Qe.fromSchema(e.state.schema), s = ao(), c = s.createElement("div"); 5548 c.appendChild(o.serializeFragment(r, { document: s })); 5549 let l = c.firstChild, u, d = 0; 5550 for (; l && l.nodeType == 1 && (u = ro[l.nodeName.toLowerCase()]);) { 5551 for (let e = u.length - 1; e >= 0; e--) { 5552 let t = s.createElement(u[e]); 5553 for (; c.firstChild;) t.appendChild(c.firstChild); 5554 c.appendChild(t), d++; 5555 } 5556 l = c.firstChild; 5557 } 5558 return l && l.nodeType == 1 && l.setAttribute("data-pm-slice", `${i} ${a}${d ? ` -${d}` : ""} ${JSON.stringify(n)}`), { 5559 dom: c, 5560 text: e.someProp("clipboardTextSerializer", (n) => n(t, e)) || t.content.textBetween(0, t.content.size, "\n\n"), 5561 slice: t 5562 }; 5563} 5564function Ya(e, t, n, r, i) { 5565 let o = i.parent.type.spec.code, s, c; 5566 if (!n && !t) return null; 5567 let l = !!t && (r || o || !n); 5568 if (l) { 5569 if (e.someProp("transformPastedText", (n) => { 5570 t = n(t, o || r, e); 5571 }), o) return c = new d(a.from(e.state.schema.text(t.replace(/\r\n?/g, "\n"))), 0, 0), e.someProp("transformPasted", (t) => { 5572 c = t(c, e, !0); 5573 }), c; 5574 let n = e.someProp("clipboardTextParser", (n) => n(t, i, r, e)); 5575 if (n) c = n; 5576 else { 5577 let n = i.marks(), { schema: r } = e.state, a = Qe.fromSchema(r); 5578 s = document.createElement("div"), t.split(/(?:\r\n?|\n)+/).forEach((e) => { 5579 let t = s.appendChild(document.createElement("p")); 5580 e && t.appendChild(a.serializeNode(r.text(e, n))); 5581 }); 5582 } 5583 } else e.someProp("transformPastedHTML", (t) => { 5584 n = t(n, e); 5585 }), s = co(n), ai && lo(s); 5586 let u = s && s.querySelector("[data-pm-slice]"), f = u && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice") || ""); 5587 if (f && f[3]) for (let e = +f[3]; e > 0; e--) { 5588 let e = s.firstChild; 5589 for (; e && e.nodeType != 1;) e = e.nextSibling; 5590 if (!e) break; 5591 s = e; 5592 } 5593 if (c ||= (e.someProp("clipboardParser") || e.someProp("domParser") || Re.fromSchema(e.state.schema)).parseSlice(s, { 5594 preserveWhitespace: !!(l || f), 5595 context: i, 5596 ruleFromNode(e) { 5597 return e.nodeName == "BR" && !e.nextSibling && e.parentNode && !Xa.test(e.parentNode.nodeName) ? { ignore: !0 } : null; 5598 } 5599 }), f) c = uo(no(c, +f[1], +f[2]), f[4]); 5600 else if (c = d.maxOpen(Za(c.content, i), !0), c.openStart || c.openEnd) { 5601 let e = 0, t = 0; 5602 for (let t = c.content.firstChild; e < c.openStart && !t.type.spec.isolating; e++, t = t.firstChild); 5603 for (let e = c.content.lastChild; t < c.openEnd && !e.type.spec.isolating; t++, e = e.lastChild); 5604 c = no(c, e, t); 5605 } 5606 return e.someProp("transformPasted", (t) => { 5607 c = t(c, e, l); 5608 }), c; 5609} 5610var Xa = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i; 5611function Za(e, t) { 5612 if (e.childCount < 2) return e; 5613 for (let n = t.depth; n >= 0; n--) { 5614 let r = t.node(n).contentMatchAt(t.index(n)), i, o = []; 5615 if (e.forEach((e) => { 5616 if (!o) return; 5617 let t = r.findWrapping(e.type), n; 5618 if (!t) return o = null; 5619 if (n = o.length && i.length && $a(t, i, e, o[o.length - 1], 0)) o[o.length - 1] = n; 5620 else { 5621 o.length && (o[o.length - 1] = eo(o[o.length - 1], i.length)); 5622 let n = Qa(e, t); 5623 o.push(n), r = r.matchType(n.type), i = t; 5624 } 5625 }), o) return a.from(o); 5626 } 5627 return e; 5628} 5629function Qa(e, t, n = 0) { 5630 for (let r = t.length - 1; r >= n; r--) e = t[r].create(null, a.from(e)); 5631 return e; 5632} 5633function $a(e, t, n, r, i) { 5634 if (i < e.length && i < t.length && e[i] == t[i]) { 5635 let o = $a(e, t, n, r.lastChild, i + 1); 5636 if (o) return r.copy(r.content.replaceChild(r.childCount - 1, o)); 5637 if (r.contentMatchAt(r.childCount).matchType(i == e.length - 1 ? n.type : e[i + 1])) return r.copy(r.content.append(a.from(Qa(n, e, i + 1)))); 5638 } 5639} 5640function eo(e, t) { 5641 if (t == 0) return e; 5642 let n = e.content.replaceChild(e.childCount - 1, eo(e.lastChild, t - 1)), r = e.contentMatchAt(e.childCount).fillBefore(a.empty, !0); 5643 return e.copy(n.append(r)); 5644} 5645function to(e, t, n, r, i, o) { 5646 let s = t < 0 ? e.firstChild : e.lastChild, c = s.content; 5647 return e.childCount > 1 && (o = 0), i < r - 1 && (c = to(c, t, n, r, i + 1, o)), i >= n && (c = t < 0 ? s.contentMatchAt(0).fillBefore(c, o <= i).append(c) : c.append(s.contentMatchAt(s.childCount).fillBefore(a.empty, !0))), e.replaceChild(t < 0 ? 0 : e.childCount - 1, s.copy(c)); 5648} 5649function no(e, t, n) { 5650 return t < e.openStart && (e = new d(to(e.content, -1, t, e.openStart, 0, e.openEnd), t, e.openEnd)), n < e.openEnd && (e = new d(to(e.content, 1, n, e.openEnd, 0, 0), e.openStart, n)), e; 5651} 5652var ro = { 5653 thead: ["table"], 5654 tbody: ["table"], 5655 tfoot: ["table"], 5656 caption: ["table"], 5657 colgroup: ["table"], 5658 col: ["table", "colgroup"], 5659 tr: ["table", "tbody"], 5660 td: [ 5661 "table", 5662 "tbody", 5663 "tr" 5664 ], 5665 th: [ 5666 "table", 5667 "tbody", 5668 "tr" 5669 ] 5670}, io = null; 5671function ao() { 5672 return io ||= document.implementation.createHTMLDocument("title"); 5673} 5674var oo = null; 5675function so(e) { 5676 let t = window.trustedTypes; 5677 return t ? (oo ||= t.defaultPolicy || t.createPolicy("ProseMirrorClipboard", { createHTML: (e) => e }), oo.createHTML(e)) : e; 5678} 5679function co(e) { 5680 let t = /^(\s*<meta [^>]*>)*/.exec(e); 5681 t && (e = e.slice(t[0].length)); 5682 let n = ao().createElement("div"), r = /<([a-z][^>\s]+)/i.exec(e), i; 5683 if ((i = r && ro[r[1].toLowerCase()]) && (e = i.map((e) => "<" + e + ">").join("") + e + i.map((e) => "</" + e + ">").reverse().join("")), n.innerHTML = so(e), i) for (let e = 0; e < i.length; e++) n = n.querySelector(i[e]) || n; 5684 return n; 5685} 5686function lo(e) { 5687 let t = e.querySelectorAll(A ? "span:not([class]):not([style])" : "span.Apple-converted-space"); 5688 for (let n = 0; n < t.length; n++) { 5689 let r = t[n]; 5690 r.childNodes.length == 1 && r.textContent == "\xA0" && r.parentNode && r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "), r); 5691 } 5692} 5693function uo(e, t) { 5694 if (!e.size) return e; 5695 let n = e.content.firstChild.type.schema, r; 5696 try { 5697 r = JSON.parse(t); 5698 } catch { 5699 return e; 5700 } 5701 let { content: i, openStart: o, openEnd: s } = e; 5702 for (let e = r.length - 2; e >= 0; e -= 2) { 5703 let t = n.nodes[r[e]]; 5704 if (!t || t.hasRequiredAttrs()) break; 5705 i = a.from(t.create(r[e + 1], i)), o++, s++; 5706 } 5707 return new d(i, o, s); 5708} 5709var M = {}, N = {}, fo = { 5710 touchstart: !0, 5711 touchmove: !0 5712}, po = class { 5713 constructor() { 5714 this.shiftKey = !1, this.mouseDown = null, this.lastKeyCode = null, this.lastKeyCodeTime = 0, this.lastClick = { 5715 time: 0, 5716 x: 0, 5717 y: 0, 5718 type: "", 5719 button: 0 5720 }, this.lastSelectionOrigin = null, this.lastSelectionTime = 0, this.lastIOSEnter = 0, this.lastIOSEnterFallbackTimeout = -1, this.lastFocus = 0, this.lastTouch = 0, this.lastChromeDelete = 0, this.composing = !1, this.compositionNode = null, this.composingTimeout = -1, this.compositionNodes = [], this.compositionEndedAt = -2e8, this.compositionID = 1, this.badSafariComposition = !1, this.compositionPendingChanges = 0, this.domChangeCount = 0, this.eventHandlers = Object.create(null), this.hideSelectionGuard = null; 5721 } 5722}; 5723function mo(e) { 5724 for (let t in M) { 5725 let n = M[t]; 5726 e.dom.addEventListener(t, e.input.eventHandlers[t] = (t) => { 5727 yo(e, t) && !vo(e, t) && (e.editable || !(t.type in N)) && n(e, t); 5728 }, fo[t] ? { passive: !0 } : void 0); 5729 } 5730 j && e.dom.addEventListener("input", () => null), _o(e); 5731} 5732function ho(e, t) { 5733 e.input.lastSelectionOrigin = t, e.input.lastSelectionTime = Date.now(); 5734} 5735function go(e) { 5736 e.input.mouseDown && e.input.mouseDown.done(), e.domObserver.stop(); 5737 for (let t in e.input.eventHandlers) e.dom.removeEventListener(t, e.input.eventHandlers[t]); 5738 clearTimeout(e.input.composingTimeout), clearTimeout(e.input.lastIOSEnterFallbackTimeout); 5739} 5740function _o(e) { 5741 e.someProp("handleDOMEvents", (t) => { 5742 for (let n in t) e.input.eventHandlers[n] || e.dom.addEventListener(n, e.input.eventHandlers[n] = (t) => vo(e, t)); 5743 }); 5744} 5745function vo(e, t) { 5746 return e.someProp("handleDOMEvents", (n) => { 5747 let r = n[t.type]; 5748 return r ? r(e, t) || t.defaultPrevented : !1; 5749 }); 5750} 5751function yo(e, t) { 5752 if (!t.bubbles) return !0; 5753 if (t.defaultPrevented) return !1; 5754 for (let n = t.target; n != e.dom; n = n.parentNode) if (!n || n.nodeType == 11 || n.pmViewDesc && n.pmViewDesc.stopEvent(t)) return !1; 5755 return !0; 5756} 5757function bo(e, t) { 5758 !vo(e, t) && M[t.type] && (e.editable || !(t.type in N)) && M[t.type](e, t); 5759} 5760N.keydown = (e, t) => { 5761 let n = t; 5762 if (e.input.shiftKey = n.keyCode == 16 || n.shiftKey, !Lo(e) && (e.input.lastKeyCode = n.keyCode, e.input.lastKeyCodeTime = Date.now(), !(ii && A && n.keyCode == 13))) if (n.keyCode != 229 && e.domObserver.forceFlush(), ti && n.keyCode == 13 && !n.ctrlKey && !n.altKey && !n.metaKey) { 5763 let t = Date.now(); 5764 e.input.lastIOSEnter = t, e.input.lastIOSEnterFallbackTimeout = setTimeout(() => { 5765 e.input.lastIOSEnter == t && (e.someProp("handleKeyDown", (t) => t(e, Vr(13, "Enter"))), e.input.lastIOSEnter = 0); 5766 }, 200); 5767 } else e.someProp("handleKeyDown", (t) => t(e, n)) || qa(e, n) ? n.preventDefault() : ho(e, "key"); 5768}, N.keyup = (e, t) => { 5769 t.keyCode == 16 && (e.input.shiftKey = !1); 5770}, N.keypress = (e, t) => { 5771 let n = t; 5772 if (Lo(e) || !n.charCode || n.ctrlKey && !n.altKey || ni && n.metaKey) return; 5773 if (e.someProp("handleKeyPress", (t) => t(e, n))) { 5774 n.preventDefault(); 5775 return; 5776 } 5777 let r = e.state.selection; 5778 if (!(r instanceof T) || !r.$from.sameParent(r.$to)) { 5779 let t = String.fromCharCode(n.charCode), i = () => e.state.tr.insertText(t).scrollIntoView(); 5780 !/[\r\n]/.test(t) && !e.someProp("handleTextInput", (n) => n(e, r.$from.pos, r.$to.pos, t, i)) && e.dispatch(i()), n.preventDefault(); 5781 } 5782}; 5783function xo(e) { 5784 return { 5785 left: e.clientX, 5786 top: e.clientY 5787 }; 5788} 5789function So(e, t) { 5790 let n = t.x - e.clientX, r = t.y - e.clientY; 5791 return n * n + r * r < 100; 5792} 5793function Co(e, t, n, r, i) { 5794 if (r == -1) return !1; 5795 let a = e.state.doc.resolve(r); 5796 for (let r = a.depth + 1; r > 0; r--) if (e.someProp(t, (t) => r > a.depth ? t(e, n, a.nodeAfter, a.before(r), i, !0) : t(e, n, a.node(r), a.before(r), i, !1))) return !0; 5797 return !1; 5798} 5799function wo(e, t, n) { 5800 if (e.focused || e.focus(), e.state.selection.eq(t)) return; 5801 let r = e.state.tr.setSelection(t); 5802 n == "pointer" && r.setMeta("pointer", !0), e.dispatch(r); 5803} 5804function To(e, t) { 5805 if (t == -1) return !1; 5806 let n = e.state.doc.resolve(t), r = n.nodeAfter; 5807 return r && r.isAtom && E.isSelectable(r) ? (wo(e, new E(n), "pointer"), !0) : !1; 5808} 5809function Eo(e, t) { 5810 if (t == -1) return !1; 5811 let n = e.state.selection, r, i; 5812 n instanceof E && (r = n.node); 5813 let a = e.state.doc.resolve(t); 5814 for (let e = a.depth + 1; e > 0; e--) { 5815 let t = e > a.depth ? a.nodeAfter : a.node(e); 5816 if (E.isSelectable(t)) { 5817 i = r && n.$from.depth > 0 && e >= n.$from.depth && a.before(n.$from.depth + 1) == n.$from.pos ? a.before(n.$from.depth) : a.before(e); 5818 break; 5819 } 5820 } 5821 return i == null ? !1 : (wo(e, E.create(e.state.doc, i), "pointer"), !0); 5822} 5823function Do(e, t, n, r, i) { 5824 return Co(e, "handleClickOn", t, n, r) || e.someProp("handleClick", (n) => n(e, t, r)) || (i ? Eo(e, n) : To(e, n)); 5825} 5826function Oo(e, t, n, r) { 5827 return Co(e, "handleDoubleClickOn", t, n, r) || e.someProp("handleDoubleClick", (n) => n(e, t, r)); 5828} 5829function ko(e, t, n, r) { 5830 return Co(e, "handleTripleClickOn", t, n, r) || e.someProp("handleTripleClick", (n) => n(e, t, r)) || Ao(e, n, r); 5831} 5832function Ao(e, t, n) { 5833 if (n.button != 0) return !1; 5834 let r = jo(e, t, !0), i = e.state.doc; 5835 return r ? (wo(e, r, "pointer"), r instanceof T && i.eq(e.state.doc) && (e.input.mouseDown = new Io(e, r)), !0) : !1; 5836} 5837function jo(e, t, n) { 5838 let r = e.state.doc; 5839 if (t == -1) return r.inlineContent ? T.create(r, 0, r.content.size) : null; 5840 let i = r.resolve(t); 5841 for (let e = i.depth + 1; e > 0; e--) { 5842 let t = e > i.depth ? i.nodeAfter : i.node(e), a = i.before(e); 5843 if (t.inlineContent) return T.create(r, a + 1, a + 1 + t.content.size); 5844 if (n && E.isSelectable(t)) return E.create(r, a); 5845 } 5846 return null; 5847} 5848function Mo(e) { 5849 return Uo(e); 5850} 5851var No = ni ? "metaKey" : "ctrlKey"; 5852M.mousedown = (e, t) => { 5853 let n = t;
5854 e.input.shiftKey = n.shiftKey; 5855 let r = Mo(e), i = Date.now(), a = "singleClick"; 5856 i - e.input.lastClick.time < 500 && So(n, e.input.lastClick) && !n[No] && e.input.lastClick.button == n.button && (e.input.lastClick.type == "singleClick" ? a = "doubleClick" : e.input.lastClick.type == "doubleClick" && (a = "tripleClick")), e.input.lastClick = { 5857 time: i, 5858 x: n.clientX, 5859 y: n.clientY, 5860 type: a, 5861 button: n.button 5862 }, e.input.mouseDown && e.input.mouseDown.done(); 5863 let o = e.posAtCoords(xo(n)); 5864 o && (a == "singleClick" ? e.input.mouseDown = new Fo(e, o, n, !!r) : (a == "doubleClick" ? Oo : ko)(e, o.pos, o.inside, n) ? n.preventDefault() : ho(e, "pointer")); 5865}; 5866var Po = class { 5867 constructor(e) { 5868 this.view = e, this.mightDrag = null, e.root.addEventListener("mouseup", this.up = this.up.bind(this)), e.root.addEventListener("mousemove", this.move = this.move.bind(this)); 5869 } 5870 up(e) { 5871 this.done(); 5872 } 5873 move(e) { 5874 e.buttons == 0 && this.done(); 5875 } 5876 done() { 5877 this.view.root.removeEventListener("mouseup", this.up), this.view.root.removeEventListener("mousemove", this.move), this.view.input.mouseDown == this && (this.view.input.mouseDown = null); 5878 } 5879 delaySelUpdate() { 5880 return !1; 5881 } 5882}, Fo = class extends Po { 5883 constructor(e, t, n, r) { 5884 super(e), this.pos = t, this.event = n, this.flushed = r, this.delayedSelectionSync = !1, this.startDoc = e.state.doc, this.selectNode = !!n[No], this.allowDefault = n.shiftKey; 5885 let i, a; 5886 if (t.inside > -1) i = e.state.doc.nodeAt(t.inside), a = t.inside; 5887 else { 5888 let n = e.state.doc.resolve(t.pos); 5889 i = n.parent, a = n.depth ? n.before() : 0; 5890 } 5891 let o = r ? null : n.target, s = o ? e.docView.nearestDesc(o, !0) : null; 5892 this.target = s && s.nodeDOM.nodeType == 1 ? s.nodeDOM : null; 5893 let { selection: c } = e.state; 5894 n.button == 0 && (i.type.spec.draggable && i.type.spec.selectable !== !1 || c instanceof E && c.from <= a && c.to > a) && (this.mightDrag = { 5895 node: i, 5896 pos: a, 5897 addAttr: !!(this.target && !this.target.draggable), 5898 setUneditable: !!(this.target && Qr && !this.target.hasAttribute("contentEditable")) 5899 }), this.target && this.mightDrag && (this.mightDrag.addAttr || this.mightDrag.setUneditable) && (this.view.domObserver.stop(), this.mightDrag.addAttr && (this.target.draggable = !0), this.mightDrag.setUneditable && setTimeout(() => { 5900 this.view.input.mouseDown == this && this.target.setAttribute("contentEditable", "false"); 5901 }, 20), this.view.domObserver.start()), ho(e, "pointer"); 5902 } 5903 done() { 5904 super.done(), this.mightDrag && this.target && (this.view.domObserver.stop(), this.mightDrag.addAttr && this.target.removeAttribute("draggable"), this.mightDrag.setUneditable && this.target.removeAttribute("contentEditable"), this.view.domObserver.start()), this.delayedSelectionSync && setTimeout(() => { 5905 this.view.isDestroyed || ga(this.view); 5906 }); 5907 } 5908 up(e) { 5909 if (this.done(), !this.view.dom.contains(e.target)) return; 5910 let t = this.pos; 5911 this.view.state.doc != this.startDoc && (t = this.view.posAtCoords(xo(e))), this.updateAllowDefault(e), this.allowDefault || !t ? ho(this.view, "pointer") : Do(this.view, t.pos, t.inside, e, this.selectNode) ? e.preventDefault() : e.button == 0 && (this.flushed || j && this.mightDrag && !this.mightDrag.node.isAtom || A && !this.view.state.selection.visible && Math.min(Math.abs(t.pos - this.view.state.selection.from), Math.abs(t.pos - this.view.state.selection.to)) <= 2) ? (wo(this.view, w.near(this.view.state.doc.resolve(t.pos)), "pointer"), e.preventDefault()) : ho(this.view, "pointer"); 5912 } 5913 move(e) { 5914 this.updateAllowDefault(e), ho(this.view, "pointer"), super.move(e); 5915 } 5916 updateAllowDefault(e) { 5917 !this.allowDefault && (Math.abs(this.event.x - e.clientX) > 4 || Math.abs(this.event.y - e.clientY) > 4) && (this.allowDefault = !0); 5918 } 5919 delaySelUpdate() { 5920 return this.allowDefault ? (this.delayedSelectionSync = !0, !0) : !1; 5921 } 5922}, Io = class extends Po { 5923 constructor(e, t) { 5924 super(e), this.startSelection = t, this.startDoc = e.state.doc; 5925 } 5926 move(e) { 5927 if (e.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) { 5928 this.done(); 5929 return; 5930 } 5931 e.preventDefault(), ho(this.view, "pointer"); 5932 let t = this.view.posAtCoords(xo(e)), n = t && jo(this.view, t.inside, !1); 5933 if (!n) return; 5934 let { doc: r } = this.view.state, i = this.startSelection, [a, o] = n.from < i.from ? [i.to, n.from] : [i.from, n.to]; 5935 wo(this.view, T.create(r, a, o), "pointer"); 5936 } 5937}; 5938M.touchstart = (e) => { 5939 e.input.lastTouch = Date.now(), Mo(e), ho(e, "pointer"); 5940}, M.touchmove = (e) => { 5941 e.input.lastTouch = Date.now(), ho(e, "pointer"); 5942}, M.contextmenu = (e) => Mo(e); 5943function Lo(e, t) { 5944 return e.composing ? !0 : j && Math.abs(Date.now() - e.input.compositionEndedAt) < 500 ? (e.input.compositionEndedAt = -2e8, !0) : !1; 5945} 5946var Ro = ii ? 5e3 : -1; 5947N.compositionstart = N.compositionupdate = (e) => { 5948 if (!e.composing) { 5949 e.domObserver.flush(); 5950 let { state: t } = e, n = t.selection.$to; 5951 if (t.selection instanceof T && (t.storedMarks || !n.textOffset && n.parentOffset && n.nodeBefore.marks.some((e) => e.type.spec.inclusive === !1) || A && ri && zo(e))) e.markCursor = e.state.storedMarks || n.marks(), Uo(e, !0), e.markCursor = null; 5952 else if (Uo(e, !t.selection.empty), Qr && t.selection.empty && n.parentOffset && !n.textOffset && n.nodeBefore.marks.length) { 5953 let t = e.domSelectionRange(); 5954 for (let n = t.focusNode, r = t.focusOffset; n && n.nodeType == 1 && r != 0;) { 5955 let t = r < 0 ? n.lastChild : n.childNodes[r - 1]; 5956 if (!t) break; 5957 if (t.nodeType == 3) { 5958 let n = e.domSelection(); 5959 n && n.collapse(t, t.nodeValue.length); 5960 break; 5961 } else n = t, r = -1; 5962 } 5963 } 5964 e.input.composing = !0; 5965 } 5966 Bo(e, Ro); 5967}; 5968function zo(e) { 5969 let { focusNode: t, focusOffset: n } = e.domSelectionRange(); 5970 if (!t || t.nodeType != 1 || n >= t.childNodes.length) return !1; 5971 let r = t.childNodes[n]; 5972 return r.nodeType == 1 && r.contentEditable == "false"; 5973} 5974N.compositionend = (e, t) => { 5975 e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Date.now(), e.input.compositionPendingChanges = e.domObserver.pendingRecords().length ? e.input.compositionID : 0, e.input.compositionNode = null, e.input.badSafariComposition ? e.domObserver.forceFlush() : e.input.compositionPendingChanges && Promise.resolve().then(() => e.domObserver.flush()), e.input.compositionID++, Bo(e, 20)); 5976}; 5977function Bo(e, t) { 5978 clearTimeout(e.input.composingTimeout), t > -1 && (e.input.composingTimeout = setTimeout(() => Uo(e), t)); 5979} 5980function Vo(e) { 5981 for (e.composing && (e.input.composing = !1, e.input.compositionEndedAt = Date.now()); e.input.compositionNodes.length > 0;) e.input.compositionNodes.pop().markParentsDirty(); 5982} 5983function Ho(e) { 5984 let t = e.domSelectionRange(); 5985 if (!t.focusNode) return null;
vendor: 94,949 bytes, lines 5986-8679
5986 let n = Ir(t.focusNode, t.focusOffset), r = Lr(t.focusNode, t.focusOffset); 5987 if (n && r && n != r) { 5988 let t = r.pmViewDesc, i = e.domObserver.lastChangedTextNode; 5989 if (n == i || r == i) return i; 5990 if (!t || !t.isText(r.nodeValue)) return r; 5991 if (e.input.compositionNode == r) { 5992 let e = n.pmViewDesc; 5993 if (!(!e || !e.isText(n.nodeValue))) return r; 5994 } 5995 } 5996 return n || r; 5997} 5998function Uo(e, t = !1) { 5999 if (!(ii && e.domObserver.flushingSoon >= 0)) { 6000 if (e.domObserver.forceFlush(), Vo(e), t || e.docView && e.docView.dirty) { 6001 let n = ma(e), r = e.state.selection; 6002 return n && !n.eq(r) ? e.dispatch(e.state.tr.setSelection(n)) : (e.markCursor || t) && !r.$from.node(r.$from.sharedDepth(r.to)).inlineContent ? e.dispatch(e.state.tr.deleteSelection()) : e.updateState(e.state), !0; 6003 } 6004 return !1; 6005 } 6006} 6007function Wo(e, t) { 6008 if (!e.dom.parentNode) return; 6009 let n = e.dom.parentNode.appendChild(document.createElement("div")); 6010 n.appendChild(t), n.style.cssText = "position: fixed; left: -10000px; top: 10px"; 6011 let r = getSelection(), i = document.createRange(); 6012 i.selectNodeContents(t), e.dom.blur(), r.removeAllRanges(), r.addRange(i), setTimeout(() => { 6013 n.parentNode && n.parentNode.removeChild(n), e.focus(); 6014 }, 50); 6015} 6016var Go = Xr && Zr < 15 || ti && oi < 604; 6017M.copy = N.cut = (e, t) => { 6018 let n = t, r = e.state.selection, i = n.type == "cut"; 6019 if (r.empty) return; 6020 let a = Go ? null : n.clipboardData, { dom: o, text: s } = Ja(e, r.content()); 6021 a ? (n.preventDefault(), a.clearData(), a.setData("text/html", o.innerHTML), a.setData("text/plain", s)) : Wo(e, o), i && e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent", "cut")); 6022}; 6023function Ko(e) { 6024 return e.openStart == 0 && e.openEnd == 0 && e.content.childCount == 1 ? e.content.firstChild : null; 6025} 6026function qo(e, t) { 6027 if (!e.dom.parentNode) return; 6028 let n = e.input.shiftKey || e.state.selection.$from.parent.type.spec.code, r = e.dom.parentNode.appendChild(document.createElement(n ? "textarea" : "div")); 6029 n || (r.contentEditable = "true"), r.style.cssText = "position: fixed; left: -10000px; top: 10px", r.focus(); 6030 let i = e.input.shiftKey && e.input.lastKeyCode != 45; 6031 setTimeout(() => { 6032 e.focus(), r.parentNode && r.parentNode.removeChild(r), n ? Jo(e, r.value, null, i, t) : Jo(e, r.textContent, r.innerHTML, i, t); 6033 }, 50); 6034} 6035function Jo(e, t, n, r, i) { 6036 let a = Ya(e, t, n, r, e.state.selection.$from); 6037 if (e.someProp("handlePaste", (t) => t(e, i, a || d.empty))) return !0; 6038 if (!a) return !1; 6039 let o = Ko(a), s = o ? e.state.tr.replaceSelectionWith(o, r) : e.state.tr.replaceSelection(a); 6040 return e.dispatch(s.scrollIntoView().setMeta("paste", !0).setMeta("uiEvent", "paste")), !0; 6041} 6042function Yo(e) { 6043 let t = e.getData("text/plain") || e.getData("Text"); 6044 if (t) return t; 6045 let n = e.getData("text/uri-list"); 6046 return n ? n.replace(/\r?\n/g, " ") : ""; 6047} 6048N.paste = (e, t) => { 6049 let n = t; 6050 if (e.composing && !ii) return; 6051 let r = Go ? null : n.clipboardData, i = e.input.shiftKey && e.input.lastKeyCode != 45; 6052 r && Jo(e, Yo(r), r.getData("text/html"), i, n) ? n.preventDefault() : qo(e, n); 6053}; 6054var Xo = class { 6055 constructor(e, t, n) { 6056 this.slice = e, this.move = t, this.node = n; 6057 } 6058}, Zo = ni ? "altKey" : "ctrlKey"; 6059function Qo(e, t) { 6060 let n; 6061 return e.someProp("dragCopies", (e) => { 6062 n ||= e(t); 6063 }), n == null ? !t[Zo] : !n; 6064} 6065M.dragstart = (e, t) => { 6066 let n = t, r = e.input.mouseDown; 6067 if (r && r.done(), !n.dataTransfer) return; 6068 let i = e.state.selection, a = i.empty ? null : e.posAtCoords(xo(n)), o; 6069 if (!(a && a.pos >= i.from && a.pos <= (i instanceof E ? i.to - 1 : i.to))) { 6070 if (r && r.mightDrag) o = E.create(e.state.doc, r.mightDrag.pos); 6071 else if (n.target && n.target.nodeType == 1) { 6072 let t = e.docView.nearestDesc(n.target, !0); 6073 t && t.node.type.spec.draggable && t != e.docView && (o = E.create(e.state.doc, t.posBefore)); 6074 } 6075 } 6076 let { dom: s, text: c, slice: l } = Ja(e, (o || e.state.selection).content()); 6077 (!n.dataTransfer.files.length || !A || ei > 120) && n.dataTransfer.clearData(), n.dataTransfer.setData(Go ? "Text" : "text/html", s.innerHTML), n.dataTransfer.effectAllowed = "copyMove", Go || n.dataTransfer.setData("text/plain", c), e.dragging = new Xo(l, Qo(e, n), o); 6078}, M.dragend = (e) => { 6079 let t = e.dragging; 6080 window.setTimeout(() => { 6081 e.dragging == t && (e.dragging = null); 6082 }, 50); 6083}, N.dragover = N.dragenter = (e, t) => t.preventDefault(), N.drop = (e, t) => { 6084 try { 6085 $o(e, t, e.dragging); 6086 } finally { 6087 e.dragging = null; 6088 } 6089}; 6090function $o(e, t, n) { 6091 if (!t.dataTransfer) return; 6092 let r = e.posAtCoords(xo(t)); 6093 if (!r) return; 6094 let i = e.state.doc.resolve(r.pos), a = n && n.slice; 6095 a ? e.someProp("transformPasted", (t) => { 6096 a = t(a, e, !1); 6097 }) : a = Ya(e, Yo(t.dataTransfer), Go ? null : t.dataTransfer.getData("text/html"), !1, i); 6098 let o = !!(n && Qo(e, t)); 6099 if (e.someProp("handleDrop", (n) => n(e, t, a || d.empty, o))) { 6100 t.preventDefault(); 6101 return; 6102 } 6103 if (!a) return; 6104 t.preventDefault(); 6105 let s = a ? Yt(e.state.doc, i.pos, a) : i.pos; 6106 s ??= i.pos; 6107 let c = e.state.tr; 6108 if (o) { 6109 let { node: e } = n; 6110 e ? e.replace(c) : c.deleteSelection(); 6111 } 6112 let l = c.mapping.map(s), u = a.openStart == 0 && a.openEnd == 0 && a.content.childCount == 1, f = c.doc; 6113 if (u ? c.replaceRangeWith(l, l, a.content.firstChild) : c.replaceRange(l, l, a), c.doc.eq(f)) return; 6114 let p = c.doc.resolve(l); 6115 if (u && E.isSelectable(a.content.firstChild) && p.nodeAfter && p.nodeAfter.sameMarkup(a.content.firstChild)) c.setSelection(new E(p)); 6116 else { 6117 let t = c.mapping.map(s); 6118 c.mapping.maps[c.mapping.maps.length - 1].forEach((e, n, r, i) => t = i), c.setSelection(Ta(e, p, c.doc.resolve(t))); 6119 } 6120 e.focus(), e.dispatch(c.setMeta("uiEvent", "drop")); 6121} 6122M.focus = (e) => { 6123 e.input.lastFocus = Date.now(), e.focused || (e.domObserver.stop(), e.dom.classList.add("ProseMirror-focused"), e.domObserver.start(), e.focused = !0, setTimeout(() => { 6124 e.docView && e.hasFocus() && !e.domObserver.currentSelection.eq(e.domSelectionRange()) && ga(e); 6125 }, 20)); 6126}, M.blur = (e, t) => { 6127 let n = t; 6128 e.focused &&= (e.domObserver.stop(), e.dom.classList.remove("ProseMirror-focused"), e.domObserver.start(), n.relatedTarget && e.dom.contains(n.relatedTarget) && e.domObserver.currentSelection.clear(), !1); 6129}, M.beforeinput = (e, t) => { 6130 if (A && ii && t.inputType == "deleteContentBackward") { 6131 e.domObserver.flushSoon(); 6132 let { domChangeCount: t } = e.input; 6133 setTimeout(() => { 6134 if (e.input.domChangeCount != t || (e.dom.blur(), e.focus(), e.someProp("handleKeyDown", (t) => t(e, Vr(8, "Backspace"))))) return; 6135 let { $cursor: n } = e.state.selection; 6136 n && n.pos > 0 && e.dispatch(e.state.tr.delete(n.pos - 1, n.pos).scrollIntoView()); 6137 }, 50); 6138 } 6139}; 6140for (let e in N) M[e] = N[e]; 6141function es(e, t) { 6142 if (e == t) return !0; 6143 for (let n in e) if (e[n] !== t[n]) return !1; 6144 for (let n in t) if (!(n in e)) return !1; 6145 return !0; 6146} 6147var ts = class e { 6148 constructor(e, t) { 6149 this.toDOM = e, this.spec = t || ss, this.side = this.spec.side || 0; 6150 } 6151 map(e, t, n, r) { 6152 let { pos: i, deleted: a } = e.mapResult(t.from + r, this.side < 0 ? -1 : 1); 6153 return a ? null : new is(i - n, i - n, this); 6154 } 6155 valid() { 6156 return !0; 6157 } 6158 eq(t) { 6159 return this == t || t instanceof e && (this.spec.key && this.spec.key == t.spec.key || this.toDOM == t.toDOM && es(this.spec, t.spec)); 6160 } 6161 destroy(e) { 6162 this.spec.destroy && this.spec.destroy(e); 6163 } 6164}, ns = class e { 6165 constructor(e, t) { 6166 this.attrs = e, this.spec = t || ss; 6167 } 6168 map(e, t, n, r) { 6169 let i = e.map(t.from + r, this.spec.inclusiveStart ? -1 : 1) - n, a = e.map(t.to + r, this.spec.inclusiveEnd ? 1 : -1) - n; 6170 return i >= a ? null : new is(i, a, this); 6171 } 6172 valid(e, t) { 6173 return t.from < t.to; 6174 } 6175 eq(t) { 6176 return this == t || t instanceof e && es(this.attrs, t.attrs) && es(this.spec, t.spec); 6177 } 6178 static is(t) { 6179 return t.type instanceof e; 6180 } 6181 destroy() {} 6182}, rs = class e { 6183 constructor(e, t) { 6184 this.attrs = e, this.spec = t || ss; 6185 } 6186 map(e, t, n, r) { 6187 let i = e.mapResult(t.from + r, 1); 6188 if (i.deleted) return null; 6189 let a = e.mapResult(t.to + r, -1); 6190 return a.deleted || a.pos <= i.pos ? null : new is(i.pos - n, a.pos - n, this); 6191 } 6192 valid(e, t) { 6193 let { index: n, offset: r } = e.content.findIndex(t.from), i; 6194 return r == t.from && !(i = e.child(n)).isText && r + i.nodeSize == t.to; 6195 } 6196 eq(t) { 6197 return this == t || t instanceof e && es(this.attrs, t.attrs) && es(this.spec, t.spec); 6198 } 6199 destroy() {} 6200}, is = class e { 6201 constructor(e, t, n) { 6202 this.from = e, this.to = t, this.type = n; 6203 } 6204 copy(t, n) { 6205 return new e(t, n, this.type); 6206 } 6207 eq(e, t = 0) { 6208 return this.type.eq(e.type) && this.from + t == e.from && this.to + t == e.to; 6209 } 6210 map(e, t, n) { 6211 return this.type.map(e, this, t, n); 6212 } 6213 static widget(t, n, r) { 6214 return new e(t, t, new ts(n, r)); 6215 } 6216 static inline(t, n, r, i) { 6217 return new e(t, n, new ns(r, i)); 6218 } 6219 static node(t, n, r, i) { 6220 return new e(t, n, new rs(r, i)); 6221 } 6222 get spec() { 6223 return this.type.spec; 6224 } 6225 get inline() { 6226 return this.type instanceof ns; 6227 } 6228 get widget() { 6229 return this.type instanceof ts; 6230 } 6231}, as = [], ss = {}, P = class e { 6232 constructor(e, t) { 6233 this.local = e.length ? e : as, this.children = t.length ? t : as; 6234 } 6235 static create(e, t) { 6236 return t.length ? ms(t, e, 0, ss) : F; 6237 } 6238 find(e, t, n) { 6239 let r = []; 6240 return this.findInner(e ?? 0, t ?? 1e9, r, 0, n), r; 6241 } 6242 findInner(e, t, n, r, i) { 6243 for (let a = 0; a < this.local.length; a++) { 6244 let o = this.local[a]; 6245 o.from <= t && o.to >= e && (!i || i(o.spec)) && n.push(o.copy(o.from + r, o.to + r)); 6246 } 6247 for (let a = 0; a < this.children.length; a += 3) if (this.children[a] < t && this.children[a + 1] > e) { 6248 let o = this.children[a] + 1; 6249 this.children[a + 2].findInner(e - o, t - o, n, r + o, i); 6250 } 6251 } 6252 map(e, t, n) { 6253 return this == F || e.maps.length == 0 ? this : this.mapInner(e, t, 0, 0, n || ss); 6254 } 6255 mapInner(t, n, r, i, a) { 6256 let o; 6257 for (let e = 0; e < this.local.length; e++) { 6258 let s = this.local[e].map(t, r, i); 6259 s && s.type.valid(n, s) ? (o ||= []).push(s) : a.onRemove && a.onRemove(this.local[e].spec); 6260 } 6261 return this.children.length ? ls(this.children, o || [], t, n, r, i, a) : o ? new e(o.sort(hs), as) : F; 6262 } 6263 add(t, n) { 6264 return n.length ? this == F ? e.create(t, n) : this.addInner(t, n, 0) : this; 6265 } 6266 addInner(t, n, r) { 6267 let i, a = 0; 6268 t.forEach((e, t) => { 6269 let o = t + r, s; 6270 if (s = fs(n, e, o)) { 6271 for (i ||= this.children.slice(); a < i.length && i[a] < t;) a += 3; 6272 i[a] == t ? i[a + 2] = i[a + 2].addInner(e, s, o + 1) : i.splice(a, 0, t, t + e.nodeSize, ms(s, e, o + 1, ss)), a += 3; 6273 } 6274 }); 6275 let o = us(a ? ps(n) : n, -r); 6276 for (let e = 0; e < o.length; e++) o[e].type.valid(t, o[e]) || o.splice(e--, 1); 6277 return new e(o.length ? this.local.concat(o).sort(hs) : this.local, i || this.children); 6278 } 6279 remove(e) { 6280 return e.length == 0 || this == F ? this : this.removeInner(e, 0); 6281 } 6282 removeInner(t, n) { 6283 let r = this.children, i = this.local; 6284 for (let e = 0; e < r.length; e += 3) { 6285 let i, a = r[e] + n, o = r[e + 1] + n; 6286 for (let e = 0, n; e < t.length; e++) (n = t[e]) && n.from > a && n.to < o && (t[e] = null, (i ||= []).push(n)); 6287 if (!i) continue; 6288 r == this.children && (r = this.children.slice()); 6289 let s = r[e + 2].removeInner(i, a + 1); 6290 s == F ? (r.splice(e, 3), e -= 3) : r[e + 2] = s; 6291 } 6292 if (i.length) { 6293 for (let e = 0, r; e < t.length; e++) if (r = t[e]) for (let e = 0; e < i.length; e++) i[e].eq(r, n) && (i == this.local && (i = this.local.slice()), i.splice(e--, 1)); 6294 } 6295 return r == this.children && i == this.local ? this : i.length || r.length ? new e(i, r) : F; 6296 } 6297 forChild(t, n) { 6298 if (this == F) return this; 6299 if (n.isLeaf) return e.empty; 6300 let r, i; 6301 for (let e = 0; e < this.children.length; e += 3) if (this.children[e] >= t) { 6302 this.children[e] == t && (r = this.children[e + 2]); 6303 break; 6304 } 6305 let a = t + 1, o = a + n.content.size; 6306 for (let e = 0; e < this.local.length; e++) { 6307 let t = this.local[e]; 6308 if (t.from < o && t.to > a && t.type instanceof ns) { 6309 let e = Math.max(a, t.from) - a, n = Math.min(o, t.to) - a; 6310 e < n && (i ||= []).push(t.copy(e, n)); 6311 } 6312 } 6313 if (i) { 6314 let t = new e(i.sort(hs), as); 6315 return r ? new cs([t, r]) : t; 6316 } 6317 return r || F; 6318 } 6319 eq(t) { 6320 if (this == t) return !0; 6321 if (!(t instanceof e) || this.local.length != t.local.length || this.children.length != t.children.length) return !1; 6322 for (let e = 0; e < this.local.length; e++) if (!this.local[e].eq(t.local[e])) return !1; 6323 for (let e = 0; e < this.children.length; e += 3) if (this.children[e] != t.children[e] || this.children[e + 1] != t.children[e + 1] || !this.children[e + 2].eq(t.children[e + 2])) return !1; 6324 return !0; 6325 } 6326 locals(e) { 6327 return gs(this.localsInner(e)); 6328 } 6329 localsInner(e) { 6330 if (this == F) return as; 6331 if (e.inlineContent || !this.local.some(ns.is)) return this.local; 6332 let t = []; 6333 for (let e = 0; e < this.local.length; e++) this.local[e].type instanceof ns || t.push(this.local[e]); 6334 return t; 6335 } 6336 forEachSet(e) { 6337 e(this); 6338 } 6339}; 6340P.empty = new P([], []), P.removeOverlap = gs; 6341var F = P.empty, cs = class e { 6342 constructor(e) { 6343 this.members = e; 6344 } 6345 map(t, n) { 6346 let r = this.members.map((e) => e.map(t, n, ss)); 6347 return e.from(r); 6348 } 6349 forChild(t, n) { 6350 if (n.isLeaf) return P.empty; 6351 let r = []; 6352 for (let i = 0; i < this.members.length; i++) { 6353 let a = this.members[i].forChild(t, n); 6354 a != F && (a instanceof e ? r = r.concat(a.members) : r.push(a)); 6355 } 6356 return e.from(r); 6357 } 6358 eq(t) { 6359 if (!(t instanceof e) || t.members.length != this.members.length) return !1; 6360 for (let e = 0; e < this.members.length; e++) if (!this.members[e].eq(t.members[e])) return !1; 6361 return !0; 6362 } 6363 locals(e) { 6364 let t, n = !0; 6365 for (let r = 0; r < this.members.length; r++) { 6366 let i = this.members[r].localsInner(e); 6367 if (i.length) if (!t) t = i; 6368 else { 6369 n &&= (t = t.slice(), !1); 6370 for (let e = 0; e < i.length; e++) t.push(i[e]); 6371 } 6372 } 6373 return t ? gs(n ? t : t.sort(hs)) : as; 6374 } 6375 static from(t) { 6376 switch (t.length) { 6377 case 0: return F; 6378 case 1: return t[0]; 6379 default: return new e(t.every((e) => e instanceof P) ? t : t.reduce((e, t) => e.concat(t instanceof P ? t : t.members), [])); 6380 } 6381 } 6382 forEachSet(e) { 6383 for (let t = 0; t < this.members.length; t++) this.members[t].forEachSet(e); 6384 } 6385}; 6386function ls(e, t, n, r, i, a, o) { 6387 let s = e.slice(); 6388 for (let e = 0, t = a; e < n.maps.length; e++) { 6389 let r = 0; 6390 n.maps[e].forEach((e, n, i, a) => { 6391 let o = a - i - (n - e); 6392 for (let i = 0; i < s.length; i += 3) { 6393 let a = s[i + 1]; 6394 if (a < 0 || e > a + t - r) continue; 6395 let c = s[i] + t - r; 6396 n >= c ? s[i + 1] = e <= c ? -2 : -1 : e >= t && o && (s[i] += o, s[i + 1] += o); 6397 } 6398 r += o; 6399 }), t = n.maps[e].map(t, -1); 6400 } 6401 let c = !1; 6402 for (let t = 0; t < s.length; t += 3) if (s[t + 1] < 0) { 6403 if (s[t + 1] == -2) { 6404 c = !0, s[t + 1] = -1; 6405 continue; 6406 } 6407 let l = n.map(e[t] + a), u = l - i; 6408 if (u < 0 || u >= r.content.size) { 6409 c = !0; 6410 continue; 6411 } 6412 let d = n.map(e[t + 1] + a, -1) - i, { index: f, offset: p } = r.content.findIndex(u), m = r.maybeChild(f); 6413 if (m && p == u && p + m.nodeSize == d) { 6414 let r = s[t + 2].mapInner(n, m, l + 1, e[t] + a + 1, o); 6415 r == F ? (s[t + 1] = -2, c = !0) : (s[t] = u, s[t + 1] = d, s[t + 2] = r); 6416 } else c = !0; 6417 } 6418 if (c) { 6419 let c = ms(ds(s, e, t, n, i, a, o), r, 0, o); 6420 t = c.local; 6421 for (let e = 0; e < s.length; e += 3) s[e + 1] < 0 && (s.splice(e, 3), e -= 3); 6422 for (let e = 0, t = 0; e < c.children.length; e += 3) { 6423 let n = c.children[e]; 6424 for (; t < s.length && s[t] < n;) t += 3; 6425 s.splice(t, 0, c.children[e], c.children[e + 1], c.children[e + 2]); 6426 } 6427 } 6428 return new P(t.sort(hs), s); 6429} 6430function us(e, t) { 6431 if (!t || !e.length) return e; 6432 let n = []; 6433 for (let r = 0; r < e.length; r++) { 6434 let i = e[r]; 6435 n.push(new is(i.from + t, i.to + t, i.type)); 6436 } 6437 return n; 6438} 6439function ds(e, t, n, r, i, a, o) { 6440 function s(e, t) { 6441 for (let a = 0; a < e.local.length; a++) { 6442 let s = e.local[a].map(r, i, t); 6443 s ? n.push(s) : o.onRemove && o.onRemove(e.local[a].spec); 6444 } 6445 for (let n = 0; n < e.children.length; n += 3) s(e.children[n + 2], e.children[n] + t + 1); 6446 } 6447 for (let n = 0; n < e.length; n += 3) e[n + 1] == -1 && s(e[n + 2], t[n] + a + 1); 6448 return n; 6449} 6450function fs(e, t, n) { 6451 if (t.isLeaf) return null; 6452 let r = n + t.nodeSize, i = null; 6453 for (let t = 0, a; t < e.length; t++) (a = e[t]) && a.from > n && a.to < r && ((i ||= []).push(a), e[t] = null); 6454 return i; 6455} 6456function ps(e) { 6457 let t = []; 6458 for (let n = 0; n < e.length; n++) e[n] != null && t.push(e[n]); 6459 return t; 6460} 6461function ms(e, t, n, r) { 6462 let i = [], a = !1; 6463 t.forEach((t, o) => { 6464 let s = fs(e, t, o + n); 6465 if (s) { 6466 a = !0; 6467 let e = ms(s, t, n + o + 1, r); 6468 e != F && i.push(o, o + t.nodeSize, e); 6469 } 6470 }); 6471 let o = us(a ? ps(e) : e, -n).sort(hs); 6472 for (let e = 0; e < o.length; e++) o[e].type.valid(t, o[e]) || (r.onRemove && r.onRemove(o[e].spec), o.splice(e--, 1)); 6473 return o.length || i.length ? new P(o, i) : F; 6474} 6475function hs(e, t) { 6476 return e.from - t.from || e.to - t.to; 6477} 6478function gs(e) { 6479 let t = e; 6480 for (let n = 0; n < t.length - 1; n++) { 6481 let r = t[n]; 6482 if (r.from != r.to) for (let i = n + 1; i < t.length; i++) { 6483 let a = t[i]; 6484 if (a.from == r.from) { 6485 a.to != r.to && (t == e && (t = e.slice()), t[i] = a.copy(a.from, r.to), _s(t, i + 1, a.copy(r.to, a.to))); 6486 continue; 6487 } else { 6488 a.from < r.to && (t == e && (t = e.slice()), t[n] = r.copy(r.from, a.from), _s(t, i, r.copy(a.from, r.to))); 6489 break; 6490 } 6491 } 6492 } 6493 return t; 6494} 6495function _s(e, t, n) { 6496 for (; t < e.length && hs(n, e[t]) > 0;) t++; 6497 e.splice(t, 0, n); 6498} 6499function vs(e) { 6500 let t = []; 6501 return e.someProp("decorations", (n) => { 6502 let r = n(e.state); 6503 r && r != F && t.push(r); 6504 }), e.cursorWrapper && t.push(P.create(e.state.doc, [e.cursorWrapper.deco])), cs.from(t); 6505} 6506var ys = { 6507 childList: !0, 6508 characterData: !0, 6509 characterDataOldValue: !0, 6510 attributes: !0, 6511 attributeOldValue: !0, 6512 subtree: !0 6513}, bs = Xr && Zr <= 11, xs = class { 6514 constructor() { 6515 this.anchorNode = null, this.anchorOffset = 0, this.focusNode = null, this.focusOffset = 0; 6516 } 6517 set(e) { 6518 this.anchorNode = e.anchorNode, this.anchorOffset = e.anchorOffset, this.focusNode = e.focusNode, this.focusOffset = e.focusOffset; 6519 } 6520 clear() { 6521 this.anchorNode = this.focusNode = null; 6522 } 6523 eq(e) { 6524 return e.anchorNode == this.anchorNode && e.anchorOffset == this.anchorOffset && e.focusNode == this.focusNode && e.focusOffset == this.focusOffset; 6525 } 6526}, Ss = class { 6527 constructor(e, t) { 6528 this.view = e, this.handleDOMChange = t, this.queue = [], this.flushingSoon = -1, this.observer = null, this.currentSelection = new xs(), this.onCharData = null, this.suppressingSelectionUpdates = !1, this.lastChangedTextNode = null, this.observer = window.MutationObserver && new window.MutationObserver((t) => { 6529 for (let e = 0; e < t.length; e++) this.queue.push(t[e]); 6530 Xr && Zr <= 11 && t.some((e) => e.type == "childList" && e.removedNodes.length || e.type == "characterData" && e.oldValue.length > e.target.nodeValue.length) ? this.flushSoon() : j && e.composing && t.some((e) => e.type == "childList" && e.target.nodeName == "TR") ? (e.input.badSafariComposition = !0, this.flushSoon()) : this.flush(); 6531 }), bs && (this.onCharData = (e) => { 6532 this.queue.push({ 6533 target: e.target, 6534 type: "characterData", 6535 oldValue: e.prevValue 6536 }), this.flushSoon(); 6537 }), this.onSelectionChange = this.onSelectionChange.bind(this); 6538 } 6539 flushSoon() { 6540 this.flushingSoon < 0 && (this.flushingSoon = window.setTimeout(() => { 6541 this.flushingSoon = -1, this.flush(); 6542 }, 20)); 6543 } 6544 forceFlush() { 6545 this.flushingSoon > -1 && (window.clearTimeout(this.flushingSoon), this.flushingSoon = -1, this.flush()); 6546 } 6547 start() { 6548 this.observer && (this.observer.takeRecords(), this.observer.observe(this.view.dom, ys)), this.onCharData && this.view.dom.addEventListener("DOMCharacterDataModified", this.onCharData), this.connectSelection(); 6549 } 6550 stop() { 6551 if (this.observer) { 6552 let e = this.observer.takeRecords(); 6553 if (e.length) { 6554 for (let t = 0; t < e.length; t++) this.queue.push(e[t]); 6555 window.setTimeout(() => this.flush(), 20); 6556 } 6557 this.observer.disconnect(); 6558 } 6559 this.onCharData && this.view.dom.removeEventListener("DOMCharacterDataModified", this.onCharData), this.disconnectSelection(); 6560 } 6561 connectSelection() { 6562 this.view.dom.ownerDocument.addEventListener("selectionchange", this.onSelectionChange); 6563 } 6564 disconnectSelection() { 6565 this.view.dom.ownerDocument.removeEventListener("selectionchange", this.onSelectionChange); 6566 } 6567 suppressSelectionUpdates() { 6568 this.suppressingSelectionUpdates = !0, setTimeout(() => this.suppressingSelectionUpdates = !1, 50); 6569 } 6570 onSelectionChange() { 6571 if (Ea(this.view)) { 6572 if (this.suppressingSelectionUpdates) return ga(this.view); 6573 if (Xr && Zr <= 11 && !this.view.state.selection.empty) { 6574 let e = this.view.domSelectionRange(); 6575 if (e.focusNode && Mr(e.focusNode, e.focusOffset, e.anchorNode, e.anchorOffset)) return this.flushSoon(); 6576 } 6577 this.flush(); 6578 } 6579 } 6580 setCurSelection() { 6581 this.currentSelection.set(this.view.domSelectionRange()); 6582 } 6583 ignoreSelectionChange(e) { 6584 if (!e.focusNode) return !0; 6585 let t = /* @__PURE__ */ new Set(), n; 6586 for (let n = e.focusNode; n; n = Or(n)) t.add(n); 6587 for (let r = e.anchorNode; r; r = Or(r)) if (t.has(r)) { 6588 n = r; 6589 break; 6590 } 6591 let r = n && this.view.docView.nearestDesc(n); 6592 if (r && r.ignoreMutation({ 6593 type: "selection", 6594 target: n.nodeType == 3 ? n.parentNode : n 6595 })) return this.setCurSelection(), !0; 6596 } 6597 pendingRecords() { 6598 if (this.observer) for (let e of this.observer.takeRecords()) this.queue.push(e); 6599 return this.queue; 6600 } 6601 flush() { 6602 let { view: e } = this; 6603 if (!e.docView || this.flushingSoon > -1) return; 6604 let t = this.pendingRecords(); 6605 t.length && (this.queue = []); 6606 let n = e.domSelectionRange(), r = !this.suppressingSelectionUpdates && !this.currentSelection.eq(n) && Ea(e) && !this.ignoreSelectionChange(n), i = -1, a = -1, o = !1, s = []; 6607 if (e.editable) for (let e = 0; e < t.length; e++) { 6608 let n = this.registerMutation(t[e], s); 6609 n && (i = i < 0 ? n.from : Math.min(n.from, i), a = a < 0 ? n.to : Math.max(n.to, a), n.typeOver && (o = !0)); 6610 } 6611 if (s.some((e) => e.nodeName == "BR") && (e.input.lastKeyCode == 8 || e.input.lastKeyCode == 46 || A && (e.composing || e.input.compositionEndedAt > Date.now() - 50) && t.some((e) => e.type == "childList" && e.removedNodes.length))) { 6612 for (let e of s) if (e.nodeName == "BR" && e.parentNode) { 6613 let t = e.nextSibling; 6614 for (; t && t.nodeType == 1;) { 6615 if (t.contentEditable == "false") { 6616 e.parentNode.removeChild(e); 6617 break; 6618 } 6619 t = t.firstChild; 6620 } 6621 } 6622 } else if (Qr && s.length) { 6623 let t = s.filter((e) => e.nodeName == "BR"); 6624 if (t.length == 2) { 6625 let [e, n] = t; 6626 e.parentNode && e.parentNode.parentNode == n.parentNode ? n.remove() : e.remove(); 6627 } else { 6628 let { focusNode: n } = this.currentSelection; 6629 for (let r of t) { 6630 let t = r.parentNode; 6631 t && t.nodeName == "LI" && (!n || Os(e, n) != t) && r.remove(); 6632 } 6633 } 6634 } 6635 let c = null; 6636 i < 0 && r && e.input.lastFocus > Date.now() - 200 && Math.max(e.input.lastTouch, e.input.lastClick.time) < Date.now() - 300 && Br(n) && (c = ma(e)) && c.eq(w.near(e.state.doc.resolve(0), 1)) ? (e.input.lastFocus = 0, ga(e), this.currentSelection.set(n), e.scrollToSelection()) : (i > -1 || r) && (i > -1 && (e.docView.markDirty(i, a), Ts(e)), e.input.badSafariComposition && (e.input.badSafariComposition = !1, ks(e, s)), this.handleDOMChange(i, a, o, s), e.docView && e.docView.dirty ? e.updateState(e.state) : this.currentSelection.eq(n) || ga(e), this.currentSelection.set(n)); 6637 } 6638 registerMutation(e, t) { 6639 if (t.indexOf(e.target) > -1) return null; 6640 let n = this.view.docView.nearestDesc(e.target); 6641 if (e.type == "attributes" && (n == this.view.docView || e.attributeName == "contenteditable" || e.attributeName == "style" && !e.oldValue && !e.target.getAttribute("style")) || !n || n.ignoreMutation(e)) return null; 6642 if (e.type == "childList") { 6643 for (let n = 0; n < e.addedNodes.length; n++) { 6644 let r = e.addedNodes[n]; 6645 t.push(r), r.nodeType == 3 && (this.lastChangedTextNode = r); 6646 } 6647 if (n.contentDOM && n.contentDOM != n.dom && !n.contentDOM.contains(e.target)) return { 6648 from: n.posBefore, 6649 to: n.posAfter 6650 }; 6651 let r = e.previousSibling, i = e.nextSibling; 6652 if (Xr && Zr <= 11 && e.addedNodes.length) for (let t = 0; t < e.addedNodes.length; t++) { 6653 let { previousSibling: n, nextSibling: a } = e.addedNodes[t]; 6654 (!n || Array.prototype.indexOf.call(e.addedNodes, n) < 0) && (r = n), (!a || Array.prototype.indexOf.call(e.addedNodes, a) < 0) && (i = a); 6655 } 6656 let a = r && r.parentNode == e.target ? k(r) + 1 : 0, o = n.localPosFromDOM(e.target, a, -1), s = i && i.parentNode == e.target ? k(i) : e.target.childNodes.length; 6657 return { 6658 from: o, 6659 to: n.localPosFromDOM(e.target, s, 1) 6660 }; 6661 } else if (e.type == "attributes") return { 6662 from: n.posAtStart - n.border, 6663 to: n.posAtEnd + n.border 6664 }; 6665 else return this.lastChangedTextNode = e.target, { 6666 from: n.posAtStart, 6667 to: n.posAtEnd, 6668 typeOver: e.target.nodeValue == e.oldValue 6669 }; 6670 } 6671}, Cs = /* @__PURE__ */ new WeakMap(), ws = !1; 6672function Ts(e) { 6673 if (!Cs.has(e) && (Cs.set(e, null), [ 6674 "normal", 6675 "nowrap", 6676 "pre-line" 6677 ].indexOf(getComputedStyle(e.dom).whiteSpace) !== -1)) { 6678 if (e.requiresGeckoHackNode = Qr, ws) return; 6679 console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."), ws = !0; 6680 } 6681} 6682function Es(e, t) { 6683 let n = t.startContainer, r = t.startOffset, i = t.endContainer, a = t.endOffset, o = e.domAtPos(e.state.selection.anchor); 6684 return Mr(o.node, o.offset, i, a) && ([n, r, i, a] = [ 6685 i, 6686 a, 6687 n, 6688 r 6689 ]), { 6690 anchorNode: n, 6691 anchorOffset: r, 6692 focusNode: i, 6693 focusOffset: a 6694 }; 6695} 6696function Ds(e, t) { 6697 if (t.getComposedRanges) { 6698 let n = t.getComposedRanges(e.root)[0]; 6699 if (n) return Es(e, n); 6700 } 6701 let n; 6702 function r(e) { 6703 e.preventDefault(), e.stopImmediatePropagation(), n = e.getTargetRanges()[0]; 6704 } 6705 return e.dom.addEventListener("beforeinput", r, !0), document.execCommand("indent"), e.dom.removeEventListener("beforeinput", r, !0), n ? Es(e, n) : null; 6706} 6707function Os(e, t) { 6708 for (let n = t.parentNode; n && n != e.dom; n = n.parentNode) { 6709 let t = e.docView.nearestDesc(n, !0); 6710 if (t && t.node.isBlock) return n; 6711 } 6712 return null; 6713} 6714function ks(e, t) { 6715 let { focusNode: n, focusOffset: r } = e.domSelectionRange(); 6716 for (let i of t) if (i.parentNode?.nodeName == "TR") { 6717 let t = i.nextSibling; 6718 for (; t && t.nodeName != "TD" && t.nodeName != "TH";) t = t.nextSibling; 6719 if (t) { 6720 let a = t; 6721 for (;;) { 6722 let e = a.firstChild; 6723 if (!e || e.nodeType != 1 || e.contentEditable == "false" || /^(BR|IMG)$/.test(e.nodeName)) break; 6724 a = e; 6725 } 6726 a.insertBefore(i, a.firstChild), n == i && e.domSelection().collapse(i, r); 6727 } else i.parentNode.removeChild(i); 6728 } 6729} 6730function As(e, t, n) { 6731 let { node: r, fromOffset: i, toOffset: a, from: o, to: s } = e.docView.parseRange(t, n), c = e.domSelectionRange(), l, u = c.anchorNode; 6732 if (u && e.dom.contains(u.nodeType == 1 ? u : u.parentNode) && (l = [{ 6733 node: u, 6734 offset: c.anchorOffset 6735 }], Br(c) || l.push({ 6736 node: c.focusNode, 6737 offset: c.focusOffset 6738 })), A && e.input.lastKeyCode === 8) for (let e = a; e > i; e--) { 6739 let t = r.childNodes[e - 1], n = t.pmViewDesc; 6740 if (t.nodeName == "BR" && !n) { 6741 a = e; 6742 break; 6743 } 6744 if (!n || n.size) break; 6745 } 6746 let d = e.state.doc, f = e.someProp("domParser") || Re.fromSchema(e.state.schema), p = d.resolve(o), m = null, h = f.parse(r, { 6747 topNode: p.parent, 6748 topMatch: p.parent.contentMatchAt(p.index()), 6749 topOpen: !0, 6750 from: i, 6751 to: a, 6752 preserveWhitespace: p.parent.type.whitespace == "pre" ? "full" : !0, 6753 findPositions: l, 6754 ruleFromNode: js, 6755 context: p 6756 }); 6757 if (l && l[0].pos != null) { 6758 let e = l[0].pos, t = l[1] && l[1].pos; 6759 t ??= e, m = { 6760 anchor: e + o, 6761 head: t + o 6762 }; 6763 } 6764 return { 6765 doc: h, 6766 sel: m, 6767 from: o, 6768 to: s 6769 }; 6770} 6771function js(e) { 6772 let t = e.pmViewDesc; 6773 if (t) return t.parseRule(); 6774 if (e.nodeName == "BR" && e.parentNode) { 6775 if (j && /^(ul|ol)$/i.test(e.parentNode.nodeName)) { 6776 let e = document.createElement("div"); 6777 return e.appendChild(document.createElement("li")), { skip: e }; 6778 } else if (e.parentNode.lastChild == e || j && /^(tr|table)$/i.test(e.parentNode.nodeName)) return { ignore: !0 }; 6779 } else if (e.nodeName == "IMG" && e.getAttribute("mark-placeholder")) return { ignore: !0 }; 6780 return null; 6781} 6782var Ms = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i; 6783function Ns(e, t, n, r, i) { 6784 let a = e.input.compositionPendingChanges || (e.composing ? e.input.compositionID : 0); 6785 if (e.input.compositionPendingChanges = 0, t < 0) { 6786 let t = e.input.lastSelectionTime > Date.now() - 50 ? e.input.lastSelectionOrigin : null, n = ma(e, t); 6787 if (n && !e.state.selection.eq(n)) { 6788 if (A && ii && e.input.lastKeyCode === 13 && Date.now() - 100 < e.input.lastKeyCodeTime && e.someProp("handleKeyDown", (t) => t(e, Vr(13, "Enter")))) return; 6789 let r = e.state.tr.setSelection(n); 6790 t == "pointer" ? r.setMeta("pointer", !0) : t == "key" && r.scrollIntoView(), a && r.setMeta("composition", a), e.dispatch(r); 6791 } 6792 return; 6793 } 6794 let o = e.state.doc.resolve(t), s = o.sharedDepth(n); 6795 t = o.before(s + 1), n = e.state.doc.resolve(n).after(s + 1); 6796 let c = e.state.selection, l = As(e, t, n), u = e.state.doc, d = u.slice(l.from, l.to), f, p; 6797 e.input.lastKeyCode === 8 && Date.now() - 100 < e.input.lastKeyCodeTime ? (f = e.state.selection.to, p = "end") : (f = e.state.selection.from, p = "start"), e.input.lastKeyCode = null; 6798 let m = Rs(d.content, l.doc.content, l.from, f, p); 6799 if (m && e.input.domChangeCount++, (ti && e.input.lastIOSEnter > Date.now() - 225 || ii) && i.some((e) => e.nodeType == 1 && !Ms.test(e.nodeName)) && (!m || m.endA >= m.endB) && e.someProp("handleKeyDown", (t) => t(e, Vr(13, "Enter")))) { 6800 e.input.lastIOSEnter = 0; 6801 return; 6802 } 6803 if (!m) if (r && c instanceof T && !c.empty && c.$head.sameParent(c.$anchor) && !e.composing && !(l.sel && l.sel.anchor != l.sel.head)) m = { 6804 start: c.from, 6805 endA: c.to, 6806 endB: c.to 6807 }; 6808 else { 6809 if (l.sel) { 6810 let t = Ps(e, e.state.doc, l.sel); 6811 if (t && !t.eq(e.state.selection)) { 6812 let n = e.state.tr.setSelection(t); 6813 a && n.setMeta("composition", a), e.dispatch(n); 6814 } 6815 } 6816 return; 6817 } 6818 e.state.selection.from < e.state.selection.to && m.start == m.endB && e.state.selection instanceof T && (m.start > e.state.selection.from && m.start <= e.state.selection.from + 2 && e.state.selection.from >= l.from ? m.start = e.state.selection.from : m.endA < e.state.selection.to && m.endA >= e.state.selection.to - 2 && e.state.selection.to <= l.to && (m.endB += e.state.selection.to - m.endA, m.endA = e.state.selection.to)), Xr && Zr <= 11 && m.endB == m.start + 1 && m.endA == m.start && m.start > l.from && l.doc.textBetween(m.start - l.from - 1, m.start - l.from + 1) == " \xA0" && (m.start--, m.endA--, m.endB--); 6819 let h = l.doc.resolveNoCache(m.start - l.from), g = l.doc.resolveNoCache(m.endB - l.from), _ = u.resolve(m.start), ee = h.sameParent(g) && h.parent.inlineContent && _.end() >= m.endA; 6820 if ((ti && e.input.lastIOSEnter > Date.now() - 225 && (!ee || i.some((e) => e.nodeName == "DIV" || e.nodeName == "P")) || !ee && h.pos < l.doc.content.size && (!h.sameParent(g) || !h.parent.inlineContent) && h.pos < g.pos && !/\S/.test(l.doc.textBetween(h.pos, g.pos, "", ""))) && e.someProp("handleKeyDown", (t) => t(e, Vr(13, "Enter")))) { 6821 e.input.lastIOSEnter = 0; 6822 return; 6823 } 6824 if (e.state.selection.anchor > m.start && Is(u, m.start, m.endA, h, g) && e.someProp("handleKeyDown", (t) => t(e, Vr(8, "Backspace")))) { 6825 ii && A && e.domObserver.suppressSelectionUpdates(); 6826 return; 6827 } 6828 A && m.endB == m.start && (e.input.lastChromeDelete = Date.now()), ii && !ee && h.start() != g.start() && g.parentOffset == 0 && h.depth == g.depth && l.sel && l.sel.anchor == l.sel.head && l.sel.head == m.endA && (m.endB -= 2, g = l.doc.resolveNoCache(m.endB - l.from), setTimeout(() => { 6829 e.someProp("handleKeyDown", function(t) { 6830 return t(e, Vr(13, "Enter")); 6831 }); 6832 }, 20)); 6833 let v = m.start, y = m.endA, b = (t) => { 6834 let n = t || e.state.tr.replace(v, y, l.doc.slice(m.start - l.from, m.endB - l.from)); 6835 if (l.sel) { 6836 let t = Ps(e, n.doc, l.sel); 6837 t && !(A && e.composing && t.empty && (m.start != m.endB || e.input.lastChromeDelete < Date.now() - 100) && (t.head == v || t.head == n.mapping.map(y) - 1) || Xr && t.empty && t.head == v) && n.setSelection(t); 6838 } 6839 return a && n.setMeta("composition", a), n.scrollIntoView(); 6840 }, te; 6841 if (ee) if (h.pos == g.pos) { 6842 Xr && Zr <= 11 && h.parentOffset == 0 && (e.domObserver.suppressSelectionUpdates(), setTimeout(() => ga(e), 20)); 6843 let t = b(e.state.tr.delete(v, y)), n = u.resolve(m.start).marksAcross(u.resolve(m.endA)); 6844 n && t.ensureMarks(n), e.dispatch(t); 6845 } else if (m.endA == m.endB && (te = Fs(h.parent.content.cut(h.parentOffset, g.parentOffset), _.parent.content.cut(_.parentOffset, m.endA - _.start())))) { 6846 let t = b(e.state.tr); 6847 te.type == "add" ? t.addMark(v, y, te.mark) : t.removeMark(v, y, te.mark), e.dispatch(t); 6848 } else if (h.parent.child(h.index()).isText && h.index() == g.index() - +!g.textOffset) { 6849 let t = h.parent.textBetween(h.parentOffset, g.parentOffset), n = () => b(e.state.tr.insertText(t, v, y)); 6850 e.someProp("handleTextInput", (r) => r(e, v, y, t, n)) || e.dispatch(n()); 6851 } else e.dispatch(b()); 6852 else e.dispatch(b()); 6853} 6854function Ps(e, t, n) { 6855 return Math.max(n.anchor, n.head) > t.content.size ? null : Ta(e, t.resolve(n.anchor), t.resolve(n.head)); 6856} 6857function Fs(e, t) { 6858 let n = e.firstChild.marks, r = t.firstChild.marks, i = n, o = r, s, c, l; 6859 for (let e = 0; e < r.length; e++) i = r[e].removeFromSet(i); 6860 for (let e = 0; e < n.length; e++) o = n[e].removeFromSet(o); 6861 if (i.length == 1 && o.length == 0) c = i[0], s = "add", l = (e) => e.mark(c.addToSet(e.marks)); 6862 else if (i.length == 0 && o.length == 1) c = o[0], s = "remove", l = (e) => e.mark(c.removeFromSet(e.marks)); 6863 else return null; 6864 let u = []; 6865 for (let e = 0; e < t.childCount; e++) u.push(l(t.child(e))); 6866 if (a.from(u).eq(e)) return { 6867 mark: c, 6868 type: s 6869 }; 6870} 6871function Is(e, t, n, r, i) { 6872 if (n - t <= i.pos - r.pos || Ls(r, !0, !1) < i.pos) return !1; 6873 let a = e.resolve(t); 6874 if (!r.parent.isTextblock) { 6875 let e = a.nodeAfter; 6876 return e != null && n == t + e.nodeSize; 6877 } 6878 if (a.parentOffset < a.parent.content.size || !a.parent.isTextblock) return !1; 6879 let o = e.resolve(Ls(a, !0, !0)); 6880 return !o.parent.isTextblock || o.pos > n || Ls(o, !0, !1) < n ? !1 : r.parent.content.cut(r.parentOffset).eq(o.parent.content); 6881} 6882function Ls(e, t, n) { 6883 let r = e.depth, i = t ? e.end() : e.pos; 6884 for (; r > 0 && (t || e.indexAfter(r) == e.node(r).childCount);) r--, i++, t = !1; 6885 if (n) { 6886 let t = e.node(r).maybeChild(e.indexAfter(r)); 6887 for (; t && !t.isLeaf;) t = t.firstChild, i++; 6888 } 6889 return i; 6890} 6891function Rs(e, t, n, r, i) { 6892 let a = e.findDiffStart(t, n), o = n + e.size, s = n + t.size; 6893 if (a == null) return null; 6894 let { a: c, b: l } = e.findDiffEnd(t, o, s); 6895 if (i == "end") { 6896 let e = Math.max(0, a - Math.min(c, l)); 6897 r -= c + e - a; 6898 } 6899 if (c < a && o < s) { 6900 let e = r <= a && r >= c ? a - r : 0; 6901 a -= e, l = a + (l - c), c = a; 6902 } else if (l < a) { 6903 let e = r <= a && r >= l ? a - r : 0; 6904 a -= e, c = a + (c - l), l = a; 6905 } 6906 return { 6907 start: a, 6908 endA: c, 6909 endB: l 6910 }; 6911} 6912var zs = class { 6913 constructor(e, t) { 6914 this._root = null, this.focused = !1, this.trackWrites = null, this.mounted = !1, this.markCursor = null, this.cursorWrapper = null, this.lastSelectedViewDesc = void 0, this.input = new po(), this.prevDirectPlugins = [], this.pluginViews = [], this.requiresGeckoHackNode = !1, this.dragging = null, this._props = t, this.state = t.state, this.directPlugins = t.plugins || [], this.directPlugins.forEach(Ks), this.dispatch = this.dispatch.bind(this), this.dom = e && e.mount || document.createElement("div"), e && (e.appendChild ? e.appendChild(this.dom) : typeof e == "function" ? e(this.dom) : e.mount && (this.mounted = !0)), this.editable = Hs(this), Vs(this), this.nodeViews = Ws(this), this.docView = Ji(this.state.doc, Bs(this), vs(this), this.dom, this), this.domObserver = new Ss(this, (e, t, n, r) => Ns(this, e, t, n, r)), this.domObserver.start(), mo(this), this.updatePluginViews(); 6915 } 6916 get composing() { 6917 return this.input.composing; 6918 } 6919 get props() { 6920 if (this._props.state != this.state) { 6921 let e = this._props; 6922 this._props = {}; 6923 for (let t in e) this._props[t] = e[t]; 6924 this._props.state = this.state; 6925 } 6926 return this._props; 6927 } 6928 update(e) { 6929 e.handleDOMEvents != this._props.handleDOMEvents && _o(this); 6930 let t = this._props; 6931 this._props = e, e.plugins && (e.plugins.forEach(Ks), this.directPlugins = e.plugins), this.updateStateInner(e.state, t); 6932 } 6933 setProps(e) { 6934 let t = {}; 6935 for (let e in this._props) t[e] = this._props[e]; 6936 t.state = this.state; 6937 for (let n in e) t[n] = e[n]; 6938 this.update(t); 6939 } 6940 updateState(e) { 6941 this.updateStateInner(e, this._props); 6942 } 6943 updateStateInner(e, t) { 6944 let n = this.state, r = !1, i = !1; 6945 e.storedMarks && this.composing && (Vo(this), i = !0), this.state = e; 6946 let a = n.plugins != e.plugins || this._props.plugins != t.plugins; 6947 if (a || this._props.plugins != t.plugins || this._props.nodeViews != t.nodeViews) { 6948 let e = Ws(this); 6949 Gs(e, this.nodeViews) && (this.nodeViews = e, r = !0); 6950 } 6951 (a || t.handleDOMEvents != this._props.handleDOMEvents) && _o(this), this.editable = Hs(this), Vs(this); 6952 let o = vs(this), s = Bs(this), c = n.plugins != e.plugins && !n.doc.eq(e.doc) ? "reset" : e.scrollToSelection > n.scrollToSelection ? "to selection" : "preserve", l = r || !this.docView.matchesNode(e.doc, s, o); 6953 (l || !e.selection.eq(n.selection)) && (i = !0); 6954 let u = c == "preserve" && i && this.dom.style.overflowAnchor == null && di(this); 6955 if (i) { 6956 this.domObserver.stop(); 6957 let t = l && (Xr || A) && !this.composing && !n.selection.empty && !e.selection.empty && Us(n.selection, e.selection); 6958 if (l) { 6959 let n = A ? this.trackWrites = this.domSelectionRange().focusNode : null; 6960 this.composing && (this.input.compositionNode = Ho(this)), (r || !this.docView.update(e.doc, s, o, this)) && (this.docView.updateOuterDeco(s), this.docView.destroy(), this.docView = Ji(e.doc, s, o, this.dom, this)), n && (!this.trackWrites || !this.dom.contains(this.trackWrites)) && (t = !0); 6961 } 6962 let i = this.input.mouseDown; 6963 t || !(i && this.domObserver.currentSelection.eq(this.domSelectionRange()) && Oa(this) && i.delaySelUpdate()) ? ga(this, t) : (Ca(this, e.selection), this.domObserver.setCurSelection()), this.domObserver.start(); 6964 } 6965 this.updatePluginViews(n), this.dragging?.node && !n.doc.eq(e.doc) && this.updateDraggedNode(this.dragging, n), c == "reset" ? this.dom.scrollTop = 0 : c == "to selection" ? this.scrollToSelection() : u && pi(u); 6966 } 6967 scrollToSelection() { 6968 let e = this.domSelectionRange().focusNode; 6969 if (!(!e || !this.dom.contains(e.nodeType == 1 ? e : e.parentNode)) && !this.someProp("handleScrollToSelection", (e) => e(this))) if (this.state.selection instanceof E) { 6970 let t = this.docView.domAfterPos(this.state.selection.from); 6971 t.nodeType == 1 && ui(this, t.getBoundingClientRect(), e); 6972 } else ui(this, this.coordsAtPos(this.state.selection.head, 1), e); 6973 } 6974 destroyPluginViews() { 6975 let e; 6976 for (; e = this.pluginViews.pop();) e.destroy && e.destroy(); 6977 } 6978 updatePluginViews(e) { 6979 if (!e || e.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) { 6980 this.prevDirectPlugins = this.directPlugins, this.destroyPluginViews(); 6981 for (let e = 0; e < this.directPlugins.length; e++) { 6982 let t = this.directPlugins[e]; 6983 t.spec.view && this.pluginViews.push(t.spec.view(this)); 6984 } 6985 for (let e = 0; e < this.state.plugins.length; e++) { 6986 let t = this.state.plugins[e]; 6987 t.spec.view && this.pluginViews.push(t.spec.view(this)); 6988 } 6989 } else for (let t = 0; t < this.pluginViews.length; t++) { 6990 let n = this.pluginViews[t]; 6991 n.update && n.update(this, e); 6992 } 6993 } 6994 updateDraggedNode(e, t) { 6995 let n = e.node, r = -1; 6996 if (n.from < this.state.doc.content.size && this.state.doc.nodeAt(n.from) == n.node) r = n.from; 6997 else { 6998 let e = n.from + (this.state.doc.content.size - t.doc.content.size); 6999 (e > 0 && e < this.state.doc.content.size && this.state.doc.nodeAt(e)) == n.node && (r = e); 7000 } 7001 this.dragging = new Xo(e.slice, e.move, r < 0 ? void 0 : E.create(this.state.doc, r)); 7002 } 7003 someProp(e, t) { 7004 let n = this._props && this._props[e], r; 7005 if (n != null && (r = t ? t(n) : n)) return r; 7006 for (let n = 0; n < this.directPlugins.length; n++) { 7007 let i = this.directPlugins[n].props[e]; 7008 if (i != null && (r = t ? t(i) : i)) return r; 7009 } 7010 let i = this.state.plugins; 7011 if (i) for (let n = 0; n < i.length; n++) { 7012 let a = i[n].props[e]; 7013 if (a != null && (r = t ? t(a) : a)) return r; 7014 } 7015 } 7016 hasFocus() { 7017 if (Xr) { 7018 let e = this.root.activeElement; 7019 if (e == this.dom) return !0; 7020 if (!e || !this.dom.contains(e)) return !1; 7021 for (; e && this.dom != e && this.dom.contains(e);) { 7022 if (e.contentEditable == "false") return !1; 7023 e = e.parentElement; 7024 } 7025 return !0; 7026 } 7027 return this.root.activeElement == this.dom; 7028 } 7029 focus() { 7030 this.domObserver.stop(), this.editable && gi(this.dom), ga(this), this.domObserver.start(); 7031 } 7032 get root() { 7033 let e = this._root; 7034 if (e == null) { 7035 for (let e = this.dom.parentNode; e; e = e.parentNode) if (e.nodeType == 9 || e.nodeType == 11 && e.host) return e.getSelection || (Object.getPrototypeOf(e).getSelection = () => e.ownerDocument.getSelection()), this._root = e; 7036 } 7037 return e || document; 7038 } 7039 updateRoot() { 7040 this._root = null; 7041 } 7042 posAtCoords(e) { 7043 return wi(this, e); 7044 } 7045 coordsAtPos(e, t = 1) { 7046 return Oi(this, e, t); 7047 } 7048 domAtPos(e, t = 0) { 7049 return this.docView.domFromPos(e, t); 7050 } 7051 nodeDOM(e) { 7052 let t = this.docView.descAt(e); 7053 return t ? t.nodeDOM : null; 7054 } 7055 posAtDOM(e, t, n = -1) { 7056 let r = this.docView.posFromDOM(e, t, n); 7057 if (r == null) throw RangeError("DOM position not inside the editor"); 7058 return r; 7059 } 7060 endOfTextblock(e, t) { 7061 return Ri(this, t || this.state, e); 7062 } 7063 pasteHTML(e, t) { 7064 return Jo(this, "", e, !1, t || new ClipboardEvent("paste")); 7065 } 7066 pasteText(e, t) { 7067 return Jo(this, e, null, !0, t || new ClipboardEvent("paste")); 7068 } 7069 serializeForClipboard(e) { 7070 return Ja(this, e); 7071 } 7072 destroy() { 7073 this.docView && (go(this), this.destroyPluginViews(), this.mounted ? (this.docView.update(this.state.doc, [], vs(this), this), this.dom.textContent = "") : this.dom.parentNode && this.dom.parentNode.removeChild(this.dom), this.docView.destroy(), this.docView = null, jr()); 7074 } 7075 get isDestroyed() { 7076 return this.docView == null; 7077 } 7078 dispatchEvent(e) { 7079 return bo(this, e); 7080 } 7081 domSelectionRange() { 7082 let e = this.domSelection(); 7083 return e ? j && this.root.nodeType === 11 && Hr(this.dom.ownerDocument) == this.dom && Ds(this, e) || e : { 7084 focusNode: null, 7085 focusOffset: 0, 7086 anchorNode: null, 7087 anchorOffset: 0 7088 }; 7089 } 7090 domSelection() { 7091 return this.root.getSelection(); 7092 } 7093}; 7094zs.prototype.dispatch = function(e) { 7095 let t = this._props.dispatchTransaction; 7096 t ? t.call(this, e) : this.updateState(this.state.apply(e)); 7097}; 7098function Bs(e) { 7099 let t = Object.create(null); 7100 return t.class = "ProseMirror", t.contenteditable = String(e.editable), e.someProp("attributes", (n) => { 7101 if (typeof n == "function" && (n = n(e.state)), n) for (let e in n) e == "class" ? t.class += " " + n[e] : e == "style" ? t.style = (t.style ? t.style + ";" : "") + n[e] : !t[e] && e != "contenteditable" && e != "nodeName" && (t[e] = String(n[e])); 7102 }), t.translate ||= "no", [is.node(0, e.state.doc.content.size, t)]; 7103} 7104function Vs(e) { 7105 if (e.markCursor) { 7106 let t = document.createElement("img"); 7107 t.className = "ProseMirror-separator", t.setAttribute("mark-placeholder", "true"), t.setAttribute("alt", ""), e.cursorWrapper = { 7108 dom: t, 7109 deco: is.widget(e.state.selection.from, t, { 7110 raw: !0, 7111 marks: e.markCursor 7112 }) 7113 }; 7114 } else e.cursorWrapper = null; 7115} 7116function Hs(e) { 7117 return !e.someProp("editable", (t) => t(e.state) === !1); 7118} 7119function Us(e, t) { 7120 let n = Math.min(e.$anchor.sharedDepth(e.head), t.$anchor.sharedDepth(t.head)); 7121 return e.$anchor.start(n) != t.$anchor.start(n); 7122} 7123function Ws(e) { 7124 let t = Object.create(null); 7125 function n(e) { 7126 for (let n in e) Object.prototype.hasOwnProperty.call(t, n) || (t[n] = e[n]); 7127 } 7128 return e.someProp("nodeViews", n), e.someProp("markViews", n), t; 7129} 7130function Gs(e, t) { 7131 let n = 0, r = 0; 7132 for (let r in e) { 7133 if (e[r] != t[r]) return !0; 7134 n++; 7135 } 7136 for (let e in t) r++; 7137 return n != r; 7138} 7139function Ks(e) { 7140 if (e.spec.state || e.spec.filterTransaction || e.spec.appendTransaction) throw RangeError("Plugins passed directly to the view must not have a state component"); 7141} 7142for (var qs = { 7143 8: "Backspace", 7144 9: "Tab", 7145 10: "Enter", 7146 12: "NumLock", 7147 13: "Enter", 7148 16: "Shift", 7149 17: "Control", 7150 18: "Alt", 7151 20: "CapsLock", 7152 27: "Escape", 7153 32: " ", 7154 33: "PageUp", 7155 34: "PageDown", 7156 35: "End", 7157 36: "Home", 7158 37: "ArrowLeft", 7159 38: "ArrowUp", 7160 39: "ArrowRight", 7161 40: "ArrowDown", 7162 44: "PrintScreen", 7163 45: "Insert", 7164 46: "Delete", 7165 59: ";", 7166 61: "=", 7167 91: "Meta", 7168 92: "Meta", 7169 106: "*", 7170 107: "+", 7171 108: ",", 7172 109: "-", 7173 110: ".", 7174 111: "/", 7175 144: "NumLock", 7176 145: "ScrollLock", 7177 160: "Shift", 7178 161: "Shift", 7179 162: "Control", 7180 163: "Control", 7181 164: "Alt", 7182 165: "Alt", 7183 173: "-", 7184 186: ";", 7185 187: "=", 7186 188: ",", 7187 189: "-", 7188 190: ".", 7189 191: "/", 7190 192: "`", 7191 219: "[", 7192 220: "\\", 7193 221: "]", 7194 222: "'" 7195}, Js = { 7196 48: ")", 7197 49: "!", 7198 50: "@", 7199 51: "#", 7200 52: "$", 7201 53: "%", 7202 54: "^", 7203 55: "&", 7204 56: "*", 7205 57: "(", 7206 59: ":", 7207 61: "+", 7208 173: "_", 7209 186: ":", 7210 187: "+", 7211 188: "<", 7212 189: "_", 7213 190: ">", 7214 191: "?", 7215 192: "~", 7216 219: "{", 7217 220: "|", 7218 221: "}", 7219 222: "\"" 7220}, Ys = typeof navigator < "u" && /Mac/.test(navigator.platform), Xs = typeof navigator < "u" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent), I = 0; I < 10; I++) qs[48 + I] = qs[96 + I] = String(I); 7221for (var I = 1; I <= 24; I++) qs[I + 111] = "F" + I; 7222for (var I = 65; I <= 90; I++) qs[I] = String.fromCharCode(I + 32), Js[I] = String.fromCharCode(I); 7223for (var Zs in qs) Js.hasOwnProperty(Zs) || (Js[Zs] = qs[Zs]); 7224function Qs(e) { 7225 var t = !(Ys && e.metaKey && e.shiftKey && !e.ctrlKey && !e.altKey || Xs && e.shiftKey && e.key && e.key.length == 1 || e.key == "Unidentified") && e.key || (e.shiftKey ? Js : qs)[e.keyCode] || e.key || "Unidentified"; 7226 return t == "Esc" && (t = "Escape"), t == "Del" && (t = "Delete"), t == "Left" && (t = "ArrowLeft"), t == "Up" && (t = "ArrowUp"), t == "Right" && (t = "ArrowRight"), t == "Down" && (t = "ArrowDown"), t; 7227} 7228//#endregion 7229//#region node_modules/prosemirror-keymap/dist/index.js 7230var $s = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), ec = typeof navigator < "u" && /Win/.test(navigator.platform); 7231function tc(e) { 7232 let t = e.split(/-(?!$)/), n = t[t.length - 1]; 7233 n == "Space" && (n = " "); 7234 let r, i, a, o; 7235 for (let e = 0; e < t.length - 1; e++) { 7236 let n = t[e]; 7237 if (/^(cmd|meta|m)$/i.test(n)) o = !0; 7238 else if (/^a(lt)?$/i.test(n)) r = !0; 7239 else if (/^(c|ctrl|control)$/i.test(n)) i = !0; 7240 else if (/^s(hift)?$/i.test(n)) a = !0; 7241 else if (/^mod$/i.test(n)) $s ? o = !0 : i = !0; 7242 else throw Error("Unrecognized modifier name: " + n); 7243 } 7244 return r && (n = "Alt-" + n), i && (n = "Ctrl-" + n), o && (n = "Meta-" + n), a && (n = "Shift-" + n), n; 7245} 7246function nc(e) { 7247 let t = Object.create(null); 7248 for (let n in e) t[tc(n)] = e[n]; 7249 return t; 7250} 7251function rc(e, t, n = !0) { 7252 return t.altKey && (e = "Alt-" + e), t.ctrlKey && (e = "Ctrl-" + e), t.metaKey && (e = "Meta-" + e), n && t.shiftKey && (e = "Shift-" + e), e; 7253} 7254function ic(e) { 7255 return new D({ props: { handleKeyDown: ac(e) } }); 7256} 7257function ac(e) { 7258 let t = nc(e); 7259 return function(e, n) { 7260 let r = Qs(n), i, a = t[rc(r, n)]; 7261 if (a && a(e.state, e.dispatch, e)) return !0; 7262 if (r.length == 1 && r != " ") { 7263 if (n.shiftKey) { 7264 let i = t[rc(r, n, !1)]; 7265 if (i && i(e.state, e.dispatch, e)) return !0; 7266 } 7267 if ((n.altKey || n.metaKey || n.ctrlKey) && !(ec && n.ctrlKey && n.altKey) && (i = qs[n.keyCode]) && i != r) { 7268 let r = t[rc(i, n)]; 7269 if (r && r(e.state, e.dispatch, e)) return !0; 7270 } 7271 } 7272 return !1; 7273 }; 7274} 7275//#endregion 7276//#region node_modules/@tiptap/core/dist/index.js 7277var oc = Object.defineProperty, sc = (e, t) => { 7278 for (var n in t) oc(e, n, { 7279 get: t[n], 7280 enumerable: !0 7281 }); 7282}; 7283function cc(e) { 7284 let { state: t, transaction: n } = e, { selection: r } = n, { doc: i } = n, { storedMarks: a } = n; 7285 return { 7286 ...t, 7287 apply: t.apply.bind(t), 7288 applyTransaction: t.applyTransaction.bind(t), 7289 plugins: t.plugins, 7290 schema: t.schema, 7291 reconfigure: t.reconfigure.bind(t), 7292 toJSON: t.toJSON.bind(t), 7293 get storedMarks() { 7294 return a; 7295 }, 7296 get selection() { 7297 return r; 7298 }, 7299 get doc() { 7300 return i; 7301 }, 7302 get tr() { 7303 return r = n.selection, i = n.doc, a = n.storedMarks, n; 7304 } 7305 }; 7306} 7307var lc = class { 7308 constructor(e) { 7309 this.editor = e.editor, this.rawCommands = this.editor.extensionManager.commands, this.customState = e.state; 7310 } 7311 get hasCustomState() { 7312 return !!this.customState; 7313 } 7314 get state() { 7315 return this.customState || this.editor.state; 7316 } 7317 get commands() { 7318 let { rawCommands: e, editor: t, state: n } = this, { view: r } = t, { tr: i } = n, a = this.buildProps(i); 7319 return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, (...e) => { 7320 let n = t(...e)(a); 7321 return !i.getMeta("preventDispatch") && !this.hasCustomState && r.dispatch(i), n; 7322 }])); 7323 } 7324 get chain() { 7325 return () => this.createChain(); 7326 } 7327 get can() { 7328 return () => this.createCan(); 7329 } 7330 createChain(e, t = !0) { 7331 let { rawCommands: n, editor: r, state: i } = this, { view: a } = r, o = [], s = !!e, c = e || i.tr, l = () => (!s && t && !c.getMeta("preventDispatch") && !this.hasCustomState && a.dispatch(c), o.every((e) => e === !0)), u = { 7332 ...Object.fromEntries(Object.entries(n).map(([e, n]) => [e, (...e) => { 7333 let r = this.buildProps(c, t), i = n(...e)(r); 7334 return o.push(i), u; 7335 }])), 7336 run: l 7337 }; 7338 return u; 7339 } 7340 createCan(e) { 7341 let { rawCommands: t, state: n } = this, r = e || n.tr, i = this.buildProps(r, !1); 7342 return { 7343 ...Object.fromEntries(Object.entries(t).map(([e, t]) => [e, (...e) => t(...e)({ 7344 ...i, 7345 dispatch: void 0 7346 })])), 7347 chain: () => this.createChain(r, !1) 7348 }; 7349 } 7350 buildProps(e, t = !0) { 7351 let { rawCommands: n, editor: r, state: i } = this, { view: a } = r, o = { 7352 tr: e, 7353 editor: r, 7354 view: a, 7355 state: cc({ 7356 state: i, 7357 transaction: e 7358 }), 7359 dispatch: t ? () => void 0 : void 0, 7360 chain: () => this.createChain(e, t), 7361 can: () => this.createCan(e), 7362 get commands() { 7363 return Object.fromEntries(Object.entries(n).map(([e, t]) => [e, (...e) => t(...e)(o)])); 7364 } 7365 }; 7366 return o; 7367 } 7368}, uc = {}; 7369sc(uc, { 7370 blur: () => dc, 7371 clearContent: () => fc, 7372 clearNodes: () => pc, 7373 command: () => mc, 7374 createParagraphNear: () => hc, 7375 cut: () => gc, 7376 deleteCurrentNode: () => _c, 7377 deleteNode: () => vc, 7378 deleteRange: () => yc, 7379 deleteSelection: () => Cc, 7380 enter: () => wc, 7381 exitCode: () => Tc, 7382 extendMarkRange: () => Mc, 7383 first: () => Nc, 7384 focus: () => Bc, 7385 forEach: () => Vc, 7386 insertContent: () => Hc, 7387 insertContentAt: () => Jc, 7388 joinBackward: () => Zc, 7389 joinDown: () => Xc, 7390 joinForward: () => Qc, 7391 joinItemBackward: () => $c, 7392 joinItemForward: () => el, 7393 joinTextblockBackward: () => tl, 7394 joinTextblockForward: () => nl, 7395 joinUp: () => Yc, 7396 keyboardShortcut: () => al, 7397 lift: () => sl, 7398 liftEmptyBlock: () => cl, 7399 liftListItem: () => ll, 7400 newlineInCode: () => ul, 7401 resetAttributes: () => pl, 7402 scrollIntoView: () => ml, 7403 selectAll: () => hl, 7404 selectNodeBackward: () => gl, 7405 selectNodeForward: () => _l, 7406 selectParentNode: () => vl, 7407 selectTextblockEnd: () => yl, 7408 selectTextblockStart: () => bl, 7409 setContent: () => Sl, 7410 setMark: () => _u, 7411 setMeta: () => vu, 7412 setNode: () => yu, 7413 setNodeSelection: () => bu, 7414 setTextDirection: () => xu, 7415 setTextSelection: () => Su, 7416 sinkListItem: () => Cu, 7417 splitBlock: () => Tu, 7418 splitListItem: () => Eu, 7419 toggleList: () => Mu, 7420 toggleMark: () => Nu, 7421 toggleNode: () => Pu, 7422 toggleWrap: () => Fu, 7423 undoInputRule: () => Iu, 7424 unsetAllMarks: () => Lu, 7425 unsetMark: () => Ru, 7426 unsetTextDirection: () => zu, 7427 updateAttributes: () => Bu, 7428 wrapIn: () => Vu, 7429 wrapInList: () => Hu 7430}); 7431var dc = () => ({ editor: e, view: t }) => (requestAnimationFrame(() => { 7432 var n; 7433 e.isDestroyed || (t.dom.blur(), (n = window == null ? void 0 : window.getSelection()) == null || n.removeAllRanges()); 7434}), !0), fc = (e = !0) => ({ commands: t }) => t.setContent("", { emitUpdate: e }), pc = () => ({ state: e, tr: t, dispatch: n }) => { 7435 let { selection: r } = t, { ranges: i } = r; 7436 return n && i.forEach(({ $from: n, $to: r }) => { 7437 e.doc.nodesBetween(n.pos, r.pos, (e, n) => { 7438 if (e.type.isText) return; 7439 let { doc: r, mapping: i } = t, a = r.resolve(i.map(n)), o = r.resolve(i.map(n + e.nodeSize)), s = a.blockRange(o); 7440 if (!s) return; 7441 let c = kt(s); 7442 if (e.type.isTextblock) { 7443 let { defaultType: e } = a.parent.contentMatchAt(a.index()); 7444 t.setNodeMarkup(s.start, e); 7445 } 7446 (c || c === 0) && t.lift(s, c); 7447 }); 7448 }), !0; 7449}, mc = (e) => (t) => e(t), hc = () => ({ state: e, dispatch: t }) => rr(e, t), gc = (e, t) => ({ editor: n, tr: r }) => { 7450 let { state: i } = n, a = i.doc.slice(e.from, e.to); 7451 r.deleteRange(e.from, e.to); 7452 let o = r.mapping.map(t); 7453 return r.insert(o, a.content), r.setSelection(new T(r.doc.resolve(Math.max(o - 1, 0)))), !0; 7454}, _c = () => ({ tr: e, dispatch: t }) => { 7455 let { selection: n } = e, r = n.$anchor.node(); 7456 if (r.content.size > 0) return !1; 7457 let i = e.selection.$anchor; 7458 for (let n = i.depth; n > 0; --n) if (i.node(n).type === r.type) { 7459 if (t) { 7460 let t = i.before(n), r = i.after(n); 7461 e.delete(t, r).scrollIntoView(); 7462 } 7463 return !0; 7464 } 7465 return !1; 7466}; 7467function L(e, t) { 7468 if (typeof e == "string") { 7469 if (!t.nodes[e]) throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`); 7470 return t.nodes[e]; 7471 } 7472 return e; 7473} 7474var vc = (e) => ({ tr: t, state: n, dispatch: r }) => { 7475 let i = L(e, n.schema), a = t.selection.$anchor; 7476 for (let e = a.depth; e > 0; --e) if (a.node(e).type === i) { 7477 if (r) { 7478 let n = a.before(e), r = a.after(e); 7479 t.delete(n, r).scrollIntoView(); 7480 } 7481 return !0; 7482 } 7483 return !1; 7484}, yc = (e) => ({ tr: t, dispatch: n }) => { 7485 let { from: r, to: i } = e; 7486 return n && t.delete(r, i), !0; 7487}, bc = (e) => e.content ? /^text(\*|\+)/.test(e.content) : !1, xc = (e, t, n) => { 7488 if (!e.parent.isInline || n === "left" && e.pos > e.start() || n === "right" && e.pos < e.end()) return e.pos; 7489 let r = t.nodes[e.parent.type.name].spec; 7490 return bc(r) ? n === "left" ? e.start() - 1 : e.end() + 1 : e.pos; 7491}, Sc = (e, t, n) => ({ 7492 from: xc(e, n, "left"), 7493 to: xc(t, n, "right") 7494}), Cc = () => ({ state: e, dispatch: t }) => { 7495 let { $from: n, $to: r } = e.selection; 7496 if (e.selection.empty) return !1; 7497 let { from: i, to: a } = Sc(n, r, e.schema); 7498 return t && (e.tr.deleteRange(i, a).scrollIntoView(), t(e.tr)), !0; 7499}, wc = () => ({ commands: e }) => e.keyboardShortcut("Enter"), Tc = () => ({ state: e, dispatch: t }) => nr(e, t); 7500function Ec(e) { 7501 return Object.prototype.toString.call(e) === "[object RegExp]"; 7502} 7503function Dc(e, t, n = { strict: !0 }) { 7504 let r = Object.keys(t); 7505 return r.length ? r.every((r) => n.strict ? t[r] === e[r] : Ec(t[r]) ? t[r].test(e[r]) : t[r] === e[r]) : !0; 7506} 7507function Oc(e, t, n = {}) { 7508 return e.find((e) => e.type === t && Dc(Object.fromEntries(Object.keys(n).map((t) => [t, e.attrs[t]])), n)); 7509} 7510function kc(e, t, n = {}) { 7511 return !!Oc(e, t, n); 7512} 7513function Ac(e, t, n) { 7514 if (!e || !t) return; 7515 let r = e.parent.childAfter(e.parentOffset); 7516 if ((!r.node || !r.node.marks.some((e) => e.type === t)) && (r = e.parent.childBefore(e.parentOffset)), !r.node || !r.node.marks.some((e) => e.type === t)) return; 7517 if (!n) { 7518 let e = r.node.marks.find((e) => e.type === t); 7519 e && (n = e.attrs); 7520 } 7521 if (!Oc([...r.node.marks], t, n)) return; 7522 let i = r.index, a = e.start() + r.offset, o = i + 1, s = a + r.node.nodeSize; 7523 for (; i > 0 && kc([...e.parent.child(i - 1).marks], t, n);) --i, a -= e.parent.child(i).nodeSize; 7524 for (; o < e.parent.childCount && kc([...e.parent.child(o).marks], t, n);) s += e.parent.child(o).nodeSize, o += 1; 7525 return { 7526 from: a, 7527 to: s 7528 }; 7529} 7530function jc(e, t) { 7531 if (typeof e == "string") { 7532 if (!t.marks[e]) throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`); 7533 return t.marks[e]; 7534 } 7535 return e; 7536} 7537var Mc = (e, t) => ({ tr: n, state: r, dispatch: i }) => { 7538 let a = jc(e, r.schema), { doc: o, selection: s } = n, { $from: c, from: l, to: u } = s; 7539 if (i) { 7540 let e = Ac(c, a, t); 7541 if (e && e.from <= l && e.to >= u) { 7542 let t = T.create(o, e.from, e.to); 7543 n.setSelection(t); 7544 } 7545 } 7546 return !0; 7547}, Nc = (e) => (t) => { 7548 let n = typeof e == "function" ? e(t) : e; 7549 for (let e = 0; e < n.length; e += 1) if (n[e](t)) return !0; 7550 return !1; 7551}; 7552function Pc(e) { 7553 return e instanceof T; 7554} 7555function Fc(e = 0, t = 0, n = 0) { 7556 return Math.min(Math.max(e, t), n); 7557} 7558function Ic(e, t = null) { 7559 if (!t) return null; 7560 let n = w.atStart(e), r = w.atEnd(e); 7561 if (t === "start" || t === !0) return n; 7562 if (t === "end") return r; 7563 let i = n.from, a = r.to; 7564 return t === "all" ? T.create(e, Fc(0, i, a), Fc(e.content.size, i, a)) : T.create(e, Fc(t, i, a), Fc(t, i, a)); 7565} 7566function Lc() { 7567 return navigator.platform === "Android" || /android/i.test(navigator.userAgent); 7568} 7569function Rc() { 7570 return [ 7571 "iPad Simulator", 7572 "iPhone Simulator", 7573 "iPod Simulator", 7574 "iPad", 7575 "iPhone", 7576 "iPod" 7577 ].includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document; 7578} 7579function zc() { 7580 return typeof navigator < "u" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : !1; 7581} 7582var Bc = (e = null, t = {}) => ({ editor: n, view: r, tr: i, dispatch: a }) => { 7583 t = { 7584 scrollIntoView: !0, 7585 ...t 7586 }; 7587 let o = () => { 7588 (Rc() || Lc()) && r.dom.focus(), zc() && !Rc() && !Lc() && r.dom.focus({ preventScroll: !0 }), requestAnimationFrame(() => { 7589 n.isDestroyed || (r.focus(), t?.scrollIntoView && n.commands.scrollIntoView()); 7590 }); 7591 }; 7592 try { 7593 if (r.hasFocus() && e === null || e === !1) return !0; 7594 } catch { 7595 return !1; 7596 } 7597 if (a && e === null && !Pc(n.state.selection)) return o(), !0; 7598 let s = Ic(i.doc, e) || n.state.selection, c = n.state.selection.eq(s); 7599 return a && (c || i.setSelection(s), c && i.storedMarks && i.setStoredMarks(i.storedMarks), o()), !0; 7600}, Vc = (e, t) => (n) => e.every((e, r) => t(e, { 7601 ...n, 7602 index: r 7603})), Hc = (e, t) => ({ tr: n, commands: r }) => r.insertContentAt({ 7604 from: n.selection.from, 7605 to: n.selection.to 7606}, e, t), Uc = (e) => { 7607 let t = e.childNodes; 7608 for (let n = t.length - 1; n >= 0; --n) { 7609 let r = t[n]; 7610 r.nodeType === 3 && r.nodeValue && /^(\n\s\s|\n)$/.test(r.nodeValue) ? e.removeChild(r) : r.nodeType === 1 && Uc(r); 7611 } 7612 return e; 7613}; 7614function Wc(e) { 7615 if (typeof window > "u") throw Error("[tiptap error]: there is no window object available, so this function cannot be used"); 7616 let t = `<body>${e}</body>`, n = new window.DOMParser().parseFromString(t, "text/html").body; 7617 return Uc(n); 7618} 7619function Gc(e, t, n) { 7620 if (e instanceof le || e instanceof a) return e; 7621 n = { 7622 slice: !0, 7623 parseOptions: {}, 7624 ...n 7625 }; 7626 let r = typeof e == "object" && !!e, i = typeof e == "string"; 7627 if (r) try { 7628 if (Array.isArray(e) && e.length > 0) return a.fromArray(e.map((e) => t.nodeFromJSON(e))); 7629 let r = t.nodeFromJSON(e); 7630 return n.errorOnInvalidContent && r.check(), r; 7631 } catch (r) { 7632 if (n.errorOnInvalidContent) throw Error("[tiptap error]: Invalid JSON content", { cause: r }); 7633 return console.warn("[tiptap warn]: Invalid content.", "Passed value:", e, "Error:", r), Gc("", t, n); 7634 } 7635 if (i) { 7636 if (n.errorOnInvalidContent) { 7637 let r = !1, i = "", a = new Pe({ 7638 topNode: t.spec.topNode, 7639 marks: t.spec.marks, 7640 nodes: t.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: { 7641 content: "inline*", 7642 group: "block", 7643 parseDOM: [{ 7644 tag: "*", 7645 getAttrs: (e) => (r = !0, i = typeof e == "string" ? e : e.outerHTML, null) 7646 }] 7647 } }) 7648 }); 7649 if (n.slice ? Re.fromSchema(a).parseSlice(Wc(e), n.parseOptions) : Re.fromSchema(a).parse(Wc(e), n.parseOptions), n.errorOnInvalidContent && r) throw Error("[tiptap error]: Invalid HTML content", { cause: /* @__PURE__ */ Error(`Invalid element found: ${i}`) }); 7650 } 7651 let r = Re.fromSchema(t); 7652 return n.slice ? r.parseSlice(Wc(e), n.parseOptions).content : r.parse(Wc(e), n.parseOptions); 7653 } 7654 return Gc("", t, n); 7655} 7656function Kc(e, t, n) { 7657 let r = e.steps.length - 1; 7658 if (r < t) return; 7659 let i = e.steps[r]; 7660 if (!(i instanceof Ct || i instanceof C)) return; 7661 let a = e.mapping.maps[r], o = 0; 7662 a.forEach((e, t, n, r) => { 7663 o === 0 && (o = r); 7664 }), e.setSelection(w.near(e.doc.resolve(o), n)); 7665} 7666var qc = (e) => !("type" in e), Jc = (e, t, n) => ({ tr: r, dispatch: i, editor: o }) => { 7667 if (i) { 7668 n = { 7669 parseOptions: o.options.parseOptions, 7670 updateSelection: !0, 7671 applyInputRules: !1, 7672 applyPasteRules: !1, 7673 ...n 7674 }; 7675 let i, s = (e) => { 7676 o.emit("contentError", { 7677 editor: o, 7678 error: e, 7679 disableCollaboration: () => { 7680 "collaboration" in o.storage && typeof o.storage.collaboration == "object" && o.storage.collaboration && (o.storage.collaboration.isDisabled = !0); 7681 } 7682 }); 7683 }, c = { 7684 preserveWhitespace: "full", 7685 ...n.parseOptions 7686 }; 7687 if (!n.errorOnInvalidContent && !o.options.enableContentCheck && o.options.emitContentError) try { 7688 Gc(t, o.schema, { 7689 parseOptions: c, 7690 errorOnInvalidContent: !0 7691 }); 7692 } catch (e) { 7693 s(e); 7694 } 7695 try { 7696 i = Gc(t, o.schema, { 7697 parseOptions: c, 7698 errorOnInvalidContent: n.errorOnInvalidContent ?? o.options.enableContentCheck 7699 }); 7700 } catch (e) { 7701 return s(e), !1; 7702 } 7703 let { from: l, to: u } = typeof e == "number" ? { 7704 from: e, 7705 to: e 7706 } : { 7707 from: e.from, 7708 to: e.to 7709 }, d = !0, f = !0; 7710 if ((qc(i) ? i : [i]).forEach((e) => { 7711 e.check(), d = d ? e.isText && e.marks.length === 0 : !1, f = f ? e.isBlock : !1; 7712 }), l === u && f) { 7713 let { parent: e } = r.doc.resolve(l); 7714 e.isTextblock && !e.type.spec.code && !e.childCount && (--l, u += 1); 7715 } 7716 let p; 7717 if (d) { 7718 if (Array.isArray(t)) p = t.map((e) => e.text || "").join(""); 7719 else if (t instanceof a) { 7720 let e = ""; 7721 t.forEach((t) => { 7722 t.text && (e += t.text); 7723 }), p = e; 7724 } else p = typeof t == "object" && t && t.text ? t.text : t; 7725 r.insertText(p, l, u); 7726 } else { 7727 p = i; 7728 let e = r.doc.resolve(l), t = e.node(), n = e.parentOffset === 0, a = t.isText || t.isTextblock, o = t.content.size > 0; 7729 n && a && o && f && (l = Math.max(0, l - 1)), r.replaceWith(l, u, p); 7730 } 7731 n.updateSelection && Kc(r, r.steps.length - 1, -1), n.applyInputRules && r.setMeta("applyInputRules", { 7732 from: l, 7733 text: p 7734 }), n.applyPasteRules && r.setMeta("applyPasteRules", { 7735 from: l, 7736 text: p 7737 }); 7738 } 7739 return !0; 7740}, Yc = () => ({ state: e, dispatch: t }) => Zn(e, t), Xc = () => ({ state: e, dispatch: t }) => Qn(e, t), Zc = () => ({ state: e, dispatch: t }) => Bn(e, t), Qc = () => ({ state: e, dispatch: t }) => Jn(e, t), $c = () => ({ state: e, dispatch: t, tr: n }) => { 7741 try { 7742 let r = Kt(e.doc, e.selection.$from.pos, -1); 7743 return r == null ? !1 : (n.join(r, 2), t && t(n), !0); 7744 } catch { 7745 return !1; 7746 } 7747}, el = () => ({ state: e, dispatch: t, tr: n }) => { 7748 try { 7749 let r = Kt(e.doc, e.selection.$from.pos, 1); 7750 return r == null ? !1 : (n.join(r, 2), t && t(n), !0); 7751 } catch { 7752 return !1; 7753 } 7754}, tl = () => ({ state: e, dispatch: t }) => Vn(e, t), nl = () => ({ state: e, dispatch: t }) => Hn(e, t); 7755function rl() { 7756 return typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1; 7757} 7758function il(e) { 7759 let t = e.split(/-(?!$)/), n = t[t.length - 1]; 7760 n === "Space" && (n = " "); 7761 let r, i, a, o; 7762 for (let e = 0; e < t.length - 1; e += 1) { 7763 let n = t[e]; 7764 if (/^(cmd|meta|m)$/i.test(n)) o = !0; 7765 else if (/^a(lt)?$/i.test(n)) r = !0; 7766 else if (/^(c|ctrl|control)$/i.test(n)) i = !0; 7767 else if (/^s(hift)?$/i.test(n)) a = !0; 7768 else if (/^mod$/i.test(n)) Rc() || rl() ? o = !0 : i = !0; 7769 else throw Error(`Unrecognized modifier name: ${n}`); 7770 } 7771 return r && (n = `Alt-${n}`), i && (n = `Ctrl-${n}`), o && (n = `Meta-${n}`), a && (n = `Shift-${n}`), n; 7772} 7773var al = (e) => ({ editor: t, view: n, tr: r, dispatch: i }) => { 7774 let a = il(e).split(/-(?!$)/), o = a.find((e) => ![ 7775 "Alt", 7776 "Ctrl", 7777 "Meta", 7778 "Shift" 7779 ].includes(e)), s = new KeyboardEvent("keydown", { 7780 key: o === "Space" ? " " : o, 7781 altKey: a.includes("Alt"), 7782 ctrlKey: a.includes("Ctrl"), 7783 metaKey: a.includes("Meta"), 7784 shiftKey: a.includes("Shift"), 7785 bubbles: !0, 7786 cancelable: !0 7787 }); 7788 return t.captureTransaction(() => { 7789 n.someProp("handleKeyDown", (e) => e(n, s)); 7790 })?.steps.forEach((e) => { 7791 let t = e.map(r.mapping); 7792 t && i && r.maybeStep(t); 7793 }), !0; 7794}; 7795function ol(e, t, n = {}) { 7796 let { from: r, to: i, empty: a } = e.selection, o = t ? L(t, e.schema) : null, s = []; 7797 e.doc.nodesBetween(r, i, (e, t) => { 7798 if (e.isText) return; 7799 let n = Math.max(r, t), a = Math.min(i, t + e.nodeSize); 7800 s.push({ 7801 node: e, 7802 from: n, 7803 to: a 7804 }); 7805 }); 7806 let c = i - r, l = s.filter((e) => o ? o.name === e.node.type.name : !0).filter((e) => Dc(e.node.attrs, n, { strict: !1 })); 7807 return a ? !!l.length : l.reduce((e, t) => e + t.to - t.from, 0) >= c; 7808} 7809var sl = (e, t = {}) => ({ state: n, dispatch: r }) => ol(n, L(e, n.schema), t) ? $n(n, r) : !1, cl = () => ({ state: e, dispatch: t }) => ir(e, t), ll = (e) => ({ state: t, dispatch: n }) => wr(L(e, t.schema))(t, n), ul = () => ({ state: e, dispatch: t }) => er(e, t); 7810function dl(e, t) { 7811 return t.nodes[e] ? "node" : t.marks[e] ? "mark" : null; 7812} 7813function fl(e, t) { 7814 let n = typeof t == "string" ? [t] : t; 7815 return Object.keys(e).reduce((t, r) => (n.includes(r) || (t[r] = e[r]), t), {}); 7816} 7817var pl = (e, t) => ({ tr: n, state: r, dispatch: i }) => { 7818 let a = null, o = null, s = dl(typeof e == "string" ? e : e.name, r.schema); 7819 if (!s) return !1; 7820 s === "node" && (a = L(e, r.schema)), s === "mark" && (o = jc(e, r.schema)); 7821 let c = !1; 7822 return n.selection.ranges.forEach((e) => { 7823 r.doc.nodesBetween(e.$from.pos, e.$to.pos, (e, r) => { 7824 a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, fl(e.attrs, t))), o && e.marks.length && e.marks.forEach((a) => { 7825 o === a.type && (c = !0, i && n.addMark(r, r + e.nodeSize, o.create(fl(a.attrs, t)))); 7826 }); 7827 }); 7828 }), c; 7829}, ml = () => ({ tr: e, dispatch: t }) => (t && e.scrollIntoView(), !0), hl = () => ({ tr: e, dispatch: t }) => { 7830 if (t) { 7831 let t = new Sn(e.doc); 7832 e.setSelection(t); 7833 } 7834 return !0; 7835}, gl = () => ({ state: e, dispatch: t }) => Gn(e, t), _l = () => ({ state: e, dispatch: t }) => Yn(e, t), vl = () => ({ state: e, dispatch: t }) => sr(e, t), yl = () => ({ state: e, dispatch: t }) => pr(e, t), bl = () => ({ state: e, dispatch: t }) => fr(e, t); 7836function xl(e, t, n = {}, r = {}) { 7837 return Gc(e, t, { 7838 slice: !1, 7839 parseOptions: n, 7840 errorOnInvalidContent: r.errorOnInvalidContent 7841 }); 7842} 7843var Sl = (e, { errorOnInvalidContent: t, emitUpdate: n = !0, parseOptions: r = {} } = {}) => ({ editor: i, tr: a, dispatch: o, commands: s }) => { 7844 let { doc: c } = a; 7845 if (r.preserveWhitespace !== "full") { 7846 let s = xl(e, i.schema, r, { errorOnInvalidContent: t ?? i.options.enableContentCheck }); 7847 return o && a.replaceWith(0, c.content.size, s).setMeta("preventUpdate", !n), !0; 7848 } 7849 return o && a.setMeta("preventUpdate", !n), s.insertContentAt({ 7850 from: 0, 7851 to: c.content.size 7852 }, e, { 7853 parseOptions: r, 7854 errorOnInvalidContent: t ?? i.options.enableContentCheck 7855 }); 7856}; 7857function Cl(e, t) { 7858 let n = jc(t, e.schema), { from: r, to: i, empty: a } = e.selection, o = []; 7859 a ? (e.storedMarks && o.push(...e.storedMarks), o.push(...e.selection.$head.marks())) : e.doc.nodesBetween(r, i, (e) => { 7860 o.push(...e.marks); 7861 }); 7862 let s = o.find((e) => e.type.name === n.name); 7863 return s ? { ...s.attrs } : {}; 7864} 7865function wl(e, t) { 7866 let n = new hn(e); 7867 return t.forEach((e) => { 7868 e.steps.forEach((e) => { 7869 n.step(e); 7870 }); 7871 }), n; 7872} 7873function Tl(e) { 7874 for (let t = 0; t < e.edgeCount; t += 1) { 7875 let { type: n } = e.edge(t); 7876 if (n.isTextblock && !n.hasRequiredAttrs()) return n; 7877 } 7878 return null; 7879} 7880function El(e, t, n) { 7881 let r = []; 7882 return e.nodesBetween(t.from, t.to, (e, t) => { 7883 n(e) && r.push({ 7884 node: e, 7885 pos: t 7886 }); 7887 }), r; 7888} 7889function Dl(e, t) { 7890 for (let n = e.depth; n > 0; --n) { 7891 let r = e.node(n); 7892 if (t(r)) return { 7893 pos: n > 0 ? e.before(n) : 0, 7894 start: e.start(n), 7895 depth: n, 7896 node: r 7897 }; 7898 } 7899} 7900function Ol(e) { 7901 return (t) => Dl(t.$from, e); 7902} 7903function R(e, t, n) { 7904 return e.config[t] === void 0 && e.parent ? R(e.parent, t, n) : typeof e.config[t] == "function" ? e.config[t].bind({ 7905 ...n, 7906 parent: e.parent ? R(e.parent, t, n) : null 7907 }) : e.config[t]; 7908} 7909function kl(e) { 7910 return e.map((e) => { 7911 let t = R(e, "addExtensions", { 7912 name: e.name, 7913 options: e.options, 7914 storage: e.storage 7915 }); 7916 return t ? [e, ...kl(t())] : e; 7917 }).flat(10); 7918} 7919function Al(e, t) { 7920 let n = Qe.fromSchema(t).serializeFragment(e), r = document.implementation.createHTMLDocument().createElement("div"); 7921 return r.appendChild(n), r.innerHTML; 7922} 7923function jl(e) { 7924 return typeof e == "function"; 7925} 7926function z(e, t = void 0, ...n) { 7927 return jl(e) ? t ? e.bind(t)(...n) : e(...n) : e; 7928} 7929function Ml(e = {}) { 7930 return Object.keys(e).length === 0 && e.constructor === Object; 7931} 7932function Nl(e) { 7933 return { 7934 baseExtensions: e.filter((e) => e.type === "extension"), 7935 nodeExtensions: e.filter((e) => e.type === "node"), 7936 markExtensions: e.filter((e) => e.type === "mark") 7937 }; 7938} 7939function Pl(e) { 7940 let t = [], { nodeExtensions: n, markExtensions: r } = Nl(e), i = [...n, ...r], a = { 7941 default: null, 7942 validate: void 0, 7943 rendered: !0, 7944 renderHTML: null, 7945 parseHTML: null, 7946 keepOnSplit: !0, 7947 isRequired: !1 7948 }, o = n.filter((e) => e.name !== "text").map((e) => e.name), s = r.map((e) => e.name), c = [...o, ...s]; 7949 return e.forEach((e) => { 7950 let n = R(e, "addGlobalAttributes", { 7951 name: e.name, 7952 options: e.options, 7953 storage: e.storage, 7954 extensions: i 7955 }); 7956 n && n().forEach((e) => { 7957 let n; 7958 n = Array.isArray(e.types) ? e.types : e.types === "*" ? c : e.types === "nodes" ? o : e.types === "marks" ? s : [], n.forEach((n) => { 7959 Object.entries(e.attributes).forEach(([e, r]) => { 7960 t.push({ 7961 type: n, 7962 name: e, 7963 attribute: { 7964 ...a, 7965 ...r 7966 } 7967 }); 7968 }); 7969 }); 7970 }); 7971 }), i.forEach((e) => { 7972 let n = R(e, "addAttributes", { 7973 name: e.name, 7974 options: e.options, 7975 storage: e.storage 7976 }); 7977 if (!n) return; 7978 let r = n(); 7979 Object.entries(r).forEach(([n, r]) => { 7980 let i = { 7981 ...a, 7982 ...r 7983 }; 7984 typeof i?.default == "function" && (i.default = i.default()), i?.isRequired && i?.default === void 0 && delete i.default, t.push({ 7985 type: e.name, 7986 name: n, 7987 attribute: i 7988 }); 7989 }); 7990 }), t; 7991} 7992function Fl(e) { 7993 let t = [], n = "", r = !1, i = !1, a = 0, o = e.length; 7994 for (let s = 0; s < o; s += 1) { 7995 let o = e[s]; 7996 if (o === "'" && !i) { 7997 r = !r, n += o; 7998 continue; 7999 } 8000 if (o === "\"" && !r) { 8001 i = !i, n += o; 8002 continue; 8003 } 8004 if (!r && !i) { 8005 if (o === "(") { 8006 a += 1, n += o; 8007 continue; 8008 } 8009 if (o === ")" && a > 0) { 8010 --a, n += o; 8011 continue; 8012 } 8013 if (o === ";" && a === 0) { 8014 t.push(n), n = ""; 8015 continue; 8016 } 8017 } 8018 n += o; 8019 } 8020 return n && t.push(n), t; 8021} 8022function Il(e) { 8023 let t = [], n = Fl(e || ""), r = n.length; 8024 for (let e = 0; e < r; e += 1) { 8025 let r = n[e], i = r.indexOf(":"); 8026 if (i === -1) continue; 8027 let a = r.slice(0, i).trim(), o = r.slice(i + 1).trim(); 8028 a && o && t.push([a, o]); 8029 } 8030 return t; 8031} 8032function B(...e) { 8033 return e.filter((e) => !!e).reduce((e, t) => { 8034 let n = { ...e }; 8035 return Object.entries(t).forEach(([e, t]) => { 8036 if (!n[e]) { 8037 n[e] = t; 8038 return; 8039 } 8040 if (e === "class") { 8041 let r = t ? String(t).split(" ") : [], i = n[e] ? n[e].split(" ") : [], a = r.filter((e) => !i.includes(e)); 8042 n[e] = [...i, ...a].join(" "); 8043 } else if (e === "style") { 8044 let r = new Map([...Il(n[e]), ...Il(t)]); 8045 n[e] = Array.from(r.entries()).map(([e, t]) => `${e}: ${t}`).join("; "); 8046 } else n[e] = t; 8047 }), n; 8048 }, {}); 8049} 8050function Ll(e, t) { 8051 return t.filter((t) => t.type === e.type.name).filter((e) => e.attribute.rendered).map((t) => t.attribute.renderHTML ? t.attribute.renderHTML(e.attrs) || {} : { [t.name]: e.attrs[t.name] }).reduce((e, t) => B(e, t), {}); 8052} 8053function Rl(e) { 8054 return typeof e == "string" ? e.match(/^[+-]?(?:\d*\.)?\d+$/) ? Number(e) : e === "true" ? !0 : e === "false" ? !1 : e : e; 8055} 8056function zl(e, t) { 8057 return "style" in e ? e : { 8058 ...e, 8059 getAttrs: (n) => { 8060 let r = e.getAttrs ? e.getAttrs(n) : e.attrs; 8061 if (r === !1) return !1; 8062 let i = t.reduce((e, t) => { 8063 let r = t.attribute.parseHTML ? t.attribute.parseHTML(n) : Rl(n.getAttribute(t.name)); 8064 return r == null ? e : { 8065 ...e, 8066 [t.name]: r 8067 }; 8068 }, {}); 8069 return { 8070 ...r, 8071 ...i 8072 }; 8073 } 8074 }; 8075} 8076function Bl(e) { 8077 return Object.fromEntries(Object.entries(e).filter(([e, t]) => e === "attrs" && Ml(t) ? !1 : t != null)); 8078} 8079function Vl(e) { 8080 let t = {}; 8081 return !e?.attribute?.isRequired && "default" in (e?.attribute || {}) && (t.default = e.attribute.default), e?.attribute?.validate !== void 0 && (t.validate = e.attribute.validate), [e.name, t]; 8082} 8083function Hl(e, t) { 8084 let n = Pl(e), { nodeExtensions: r, markExtensions: i } = Nl(e); 8085 return new Pe({ 8086 topNode: r.find((e) => R(e, "topNode"))?.name, 8087 nodes: Object.fromEntries(r.map((r) => { 8088 let i = n.filter((e) => e.type === r.name), a = { 8089 name: r.name, 8090 options: r.options, 8091 storage: r.storage, 8092 editor: t 8093 }, o = Bl({ 8094 ...e.reduce((e, t) => { 8095 let n = R(t, "extendNodeSchema", a); 8096 return { 8097 ...e, 8098 ...n ? n(r) : {} 8099 }; 8100 }, {}), 8101 content: z(R(r, "content", a)), 8102 marks: z(R(r, "marks", a)), 8103 group: z(R(r, "group", a)), 8104 inline: z(R(r, "inline", a)), 8105 atom: z(R(r, "atom", a)), 8106 selectable: z(R(r, "selectable", a)), 8107 draggable: z(R(r, "draggable", a)), 8108 code: z(R(r, "code", a)), 8109 whitespace: z(R(r, "whitespace", a)), 8110 linebreakReplacement: z(R(r, "linebreakReplacement", a)), 8111 defining: z(R(r, "defining", a)), 8112 isolating: z(R(r, "isolating", a)), 8113 attrs: Object.fromEntries(i.map(Vl)) 8114 }), s = z(R(r, "parseHTML", a)); 8115 s && (o.parseDOM = s.map((e) => zl(e, i))); 8116 let c = R(r, "renderHTML", a); 8117 c && (o.toDOM = (e) => c({ 8118 node: e, 8119 HTMLAttributes: Ll(e, i) 8120 })); 8121 let l = R(r, "renderText", a); 8122 return l && (o.toText = l), [r.name, o]; 8123 })), 8124 marks: Object.fromEntries(i.map((r) => { 8125 let i = n.filter((e) => e.type === r.name), a = { 8126 name: r.name, 8127 options: r.options, 8128 storage: r.storage, 8129 editor: t 8130 }, o = Bl({ 8131 ...e.reduce((e, t) => { 8132 let n = R(t, "extendMarkSchema", a); 8133 return { 8134 ...e, 8135 ...n ? n(r) : {} 8136 }; 8137 }, {}), 8138 inclusive: z(R(r, "inclusive", a)), 8139 excludes: z(R(r, "excludes", a)), 8140 group: z(R(r, "group", a)), 8141 spanning: z(R(r, "spanning", a)), 8142 code: z(R(r, "code", a)), 8143 attrs: Object.fromEntries(i.map(Vl)) 8144 }), s = z(R(r, "parseHTML", a)); 8145 s && (o.parseDOM = s.map((e) => zl(e, i))); 8146 let c = R(r, "renderHTML", a); 8147 return c && (o.toDOM = (e) => c({ 8148 mark: e, 8149 HTMLAttributes: Ll(e, i) 8150 })), [r.name, o]; 8151 })) 8152 }); 8153} 8154function Ul(e) { 8155 let t = e.filter((t, n) => e.indexOf(t) !== n); 8156 return Array.from(new Set(t)); 8157} 8158function Wl(e) { 8159 return e.sort((e, t) => { 8160 let n = R(e, "priority") || 100, r = R(t, "priority") || 100; 8161 return n > r ? -1 : +(n < r); 8162 }); 8163} 8164function Gl(e) { 8165 let t = Wl(kl(e)), n = Ul(t.map((e) => e.name)); 8166 return n.length && console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((e) => `'${e}'`).join(", ")}]. This can lead to issues.`), t; 8167} 8168function Kl(e, t, n) { 8169 let { from: r, to: i } = t, { blockSeparator: a = "\n\n", textSerializers: o = {} } = n || {}, s = ""; 8170 return e.nodesBetween(r, i, (e, n, c, l) => { 8171 e.isBlock && n > r && (s += a); 8172 let u = o?.[e.type.name]; 8173 if (u) return c && (s += u({ 8174 node: e, 8175 pos: n, 8176 parent: c, 8177 index: l, 8178 range: t 8179 })), !1; 8180 e.isText && (s += (e?.text)?.slice(Math.max(r, n) - n, i - n)); 8181 }), s; 8182} 8183function ql(e, t) { 8184 return Kl(e, { 8185 from: 0, 8186 to: e.content.size 8187 }, t); 8188} 8189function Jl(e) { 8190 return Object.fromEntries(Object.entries(e.nodes).filter(([, e]) => e.spec.toText).map(([e, t]) => [e, t.spec.toText])); 8191} 8192function Yl(e, t) { 8193 let n = L(t, e.schema), { from: r, to: i } = e.selection, a = []; 8194 e.doc.nodesBetween(r, i, (e) => { 8195 a.push(e); 8196 }); 8197 let o = a.reverse().find((e) => e.type.name === n.name); 8198 return o ? { ...o.attrs } : {}; 8199} 8200function Xl(e, t) { 8201 let n = dl(typeof t == "string" ? t : t.name, e.schema); 8202 return n === "node" ? Yl(e, t) : n === "mark" ? Cl(e, t) : {}; 8203} 8204function Zl(e, t = JSON.stringify) { 8205 let n = {}; 8206 return e.filter((e) => { 8207 let r = t(e); 8208 return Object.prototype.hasOwnProperty.call(n, r) ? !1 : n[r] = !0; 8209 }); 8210} 8211function Ql(e) { 8212 let t = Zl(e); 8213 return t.length === 1 ? t : t.filter((e, n) => !t.filter((e, t) => t !== n).some((t) => e.oldRange.from >= t.oldRange.from && e.oldRange.to <= t.oldRange.to && e.newRange.from >= t.newRange.from && e.newRange.to <= t.newRange.to)); 8214} 8215function $l(e) { 8216 let { mapping: t, steps: n } = e, r = []; 8217 return t.maps.forEach((e, i) => { 8218 let a = []; 8219 if (e.ranges.length) e.forEach((e, t) => { 8220 a.push({ 8221 from: e, 8222 to: t 8223 }); 8224 }); 8225 else { 8226 let { from: e, to: t } = n[i]; 8227 if (e === void 0 || t === void 0) return; 8228 a.push({ 8229 from: e, 8230 to: t 8231 }); 8232 } 8233 a.forEach(({ from: e, to: n }) => { 8234 let a = t.slice(i).map(e, -1), o = t.slice(i).map(n), s = t.invert().map(a, -1), c = t.invert().map(o); 8235 r.push({ 8236 oldRange: { 8237 from: s, 8238 to: c 8239 }, 8240 newRange: { 8241 from: a, 8242 to: o 8243 } 8244 }); 8245 }); 8246 }), Ql(r); 8247} 8248function eu(e, t, n) { 8249 let r = []; 8250 return e === t ? n.resolve(e).marks().forEach((t) => { 8251 let i = Ac(n.resolve(e), t.type); 8252 i && r.push({ 8253 mark: t, 8254 ...i 8255 }); 8256 }) : n.nodesBetween(e, t, (e, t) => { 8257 !e || e?.nodeSize === void 0 || r.push(...e.marks.map((n) => ({ 8258 from: t, 8259 to: t + e.nodeSize, 8260 mark: n 8261 }))); 8262 }), r; 8263} 8264var tu = (e, t, n, r = 20) => { 8265 let i = e.doc.resolve(n), a = r, o = null; 8266 for (; a > 0 && o === null;) { 8267 let e = i.node(a); 8268 e?.type.name === t ? o = e : --a; 8269 } 8270 return [o, a]; 8271}; 8272function nu(e, t) { 8273 return t.nodes[e] || t.marks[e] || null; 8274} 8275function ru(e, t, n) { 8276 return Object.fromEntries(Object.entries(n).filter(([n]) => { 8277 let r = e.find((e) => e.type === t && e.name === n); 8278 return r ? r.attribute.keepOnSplit : !1; 8279 })); 8280} 8281var iu = (e, t = 500) => { 8282 let n = "", r = e.parentOffset; 8283 return e.parent.nodesBetween(Math.max(0, r - t), r, (e, t, i, a) => { 8284 var o; 8285 let s = (o = e.type.spec).toText?.call(o, { 8286 node: e, 8287 pos: t, 8288 parent: i, 8289 index: a 8290 }) || e.textContent || "%leaf%"; 8291 n += e.isAtom && !e.isText ? s : s.slice(0, Math.max(0, r - t)); 8292 }), n; 8293}; 8294function au(e, t, n = {}) { 8295 let { empty: r, ranges: i } = e.selection, a = t ? jc(t, e.schema) : null; 8296 if (r) return !!(e.storedMarks || e.selection.$from.marks()).filter((e) => a ? a.name === e.type.name : !0).find((e) => Dc(e.attrs, n, { strict: !1 })); 8297 let o = 0, s = []; 8298 if (i.forEach(({ $from: t, $to: n }) => { 8299 let r = t.pos, i = n.pos; 8300 e.doc.nodesBetween(r, i, (e, t) => { 8301 if (a && e.inlineContent && !e.type.allowsMarkType(a)) return !1; 8302 if (!e.isText && !e.marks.length) return; 8303 let n = Math.max(r, t), c = Math.min(i, t + e.nodeSize), l = c - n; 8304 o += l, s.push(...e.marks.map((e) => ({ 8305 mark: e, 8306 from: n, 8307 to: c 8308 }))); 8309 }); 8310 }), o === 0) return !1; 8311 let c = s.filter((e) => a ? a.name === e.mark.type.name : !0).filter((e) => Dc(e.mark.attrs, n, { strict: !1 })).reduce((e, t) => e + t.to - t.from, 0), l = s.filter((e) => a ? e.mark.type !== a && e.mark.type.excludes(a) : !0).reduce((e, t) => e + t.to - t.from, 0); 8312 return (c > 0 ? c + l : c) >= o; 8313} 8314function ou(e, t, n = {}) { 8315 if (!t) return ol(e, null, n) || au(e, null, n); 8316 let r = dl(t, e.schema); 8317 return r === "node" ? ol(e, t, n) : r === "mark" ? au(e, t, n) : !1; 8318} 8319var su = (e, t) => { 8320 let { $from: n, $to: r, $anchor: i } = e.selection; 8321 if (t) { 8322 let n = Ol((e) => e.type.name === t)(e.selection); 8323 if (!n) return !1; 8324 let r = e.doc.resolve(n.pos + 1); 8325 return i.pos + 1 === r.end(); 8326 } 8327 return !(r.parentOffset < r.parent.nodeSize - 2 || n.pos !== r.pos); 8328}, cu = (e) => { 8329 let { $from: t, $to: n } = e.selection; 8330 return !(t.parentOffset > 0 || t.pos !== n.pos); 8331}; 8332function lu(e, t) { 8333 return Array.isArray(t) ? t.some((t) => (typeof t == "string" ? t : t.name) === e.name) : t; 8334} 8335function uu(e, t) { 8336 let { nodeExtensions: n } = Nl(t), r = n.find((t) => t.name === e); 8337 if (!r) return !1; 8338 let i = z(R(r, "group", { 8339 name: r.name, 8340 options: r.options, 8341 storage: r.storage 8342 })); 8343 return typeof i == "string" ? i.split(" ").includes("list") : !1; 8344} 8345function du(e, { checkChildren: t = !0, ignoreWhitespace: n = !1 } = {}) { 8346 if (n) { 8347 if (e.type.name === "hardBreak") return !0; 8348 if (e.isText) return !/\S/.test(e.text ?? ""); 8349 } 8350 if (e.isText) return !e.text; 8351 if (e.isAtom || e.isLeaf) return !1; 8352 if (e.content.childCount === 0) return !0; 8353 if (t) { 8354 let r = !0; 8355 return e.content.forEach((e) => { 8356 r !== !1 && (du(e, { 8357 ignoreWhitespace: n, 8358 checkChildren: t 8359 }) || (r = !1)); 8360 }), r; 8361 } 8362 return !1; 8363} 8364function fu(e) { 8365 return e instanceof E; 8366} 8367var pu = class e { 8368 constructor(e) { 8369 this.position = e; 8370 } 8371 static fromJSON(t) { 8372 return new e(t.position); 8373 } 8374 toJSON() { 8375 return { position: this.position }; 8376 } 8377}; 8378function mu(e, t) { 8379 let n = t.mapping.mapResult(e.position); 8380 return { 8381 position: new pu(n.pos), 8382 mapResult: n 8383 }; 8384} 8385function hu(e) { 8386 return new pu(e); 8387} 8388function gu(e, t, n) { 8389 let { selection: r } = t, i = null; 8390 if (Pc(r) && (i = r.$cursor), i) { 8391 let t = e.storedMarks ?? i.marks(); 8392 return i.parent.type.allowsMarkType(n) && (!!n.isInSet(t) || !t.some((e) => e.type.excludes(n))); 8393 } 8394 let { ranges: a } = r; 8395 return a.some(({ $from: t, $to: r }) => { 8396 let i = t.depth === 0 ? e.doc.inlineContent && e.doc.type.allowsMarkType(n) : !1; 8397 return e.doc.nodesBetween(t.pos, r.pos, (e, t, r) => { 8398 if (i) return !1; 8399 if (e.isInline) { 8400 let t = !r || r.type.allowsMarkType(n), a = !!n.isInSet(e.marks) || !e.marks.some((e) => e.type.excludes(n)); 8401 i = t && a; 8402 } 8403 return !i; 8404 }), i; 8405 }); 8406} 8407var _u = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => { 8408 let { selection: a } = n, { empty: o, ranges: s } = a, c = jc(e, r.schema); 8409 if (i) if (o) { 8410 let e = Cl(r, c); 8411 n.addStoredMark(c.create({ 8412 ...e, 8413 ...t 8414 })); 8415 } else s.forEach((e) => { 8416 let i = e.$from.pos, a = e.$to.pos; 8417 r.doc.nodesBetween(i, a, (e, r) => { 8418 let o = Math.max(r, i), s = Math.min(r + e.nodeSize, a); 8419 e.marks.find((e) => e.type === c) ? e.marks.forEach((e) => { 8420 c === e.type && n.addMark(o, s, c.create({ 8421 ...e.attrs, 8422 ...t 8423 })); 8424 }) : n.addMark(o, s, c.create(t)); 8425 }); 8426 }); 8427 return gu(r, n, c); 8428}, vu = (e, t) => ({ tr: n }) => (n.setMeta(e, t), !0), yu = (e, t = {}) => ({ state: n, dispatch: r, chain: i }) => { 8429 let a = L(e, n.schema), o; 8430 return n.selection.$anchor.sameParent(n.selection.$head) && (o = n.selection.$anchor.parent.attrs), a.isTextblock ? i().command(({ commands: e }) => hr(a, { 8431 ...o, 8432 ...t 8433 })(n) ? !0 : e.clearNodes()).command(({ state: e }) => hr(a, { 8434 ...o, 8435 ...t 8436 })(e, r)).run() : (console.warn("[tiptap warn]: Currently \"setNode()\" only supports text block nodes."), !1); 8437}, bu = (e) => ({ tr: t, dispatch: n }) => { 8438 if (n) { 8439 let { doc: n } = t, r = Fc(e, 0, n.content.size), i = E.create(n, r); 8440 t.setSelection(i); 8441 } 8442 return !0; 8443}, xu = (e, t) => ({ tr: n, state: r, dispatch: i }) => { 8444 let { selection: a } = r, o, s; 8445 return typeof t == "number" ? (o = t, s = t) : t && "from" in t && "to" in t ? (o = t.from, s = t.to) : (o = a.from, s = a.to), i && n.doc.nodesBetween(o, s, (t, r) => { 8446 t.isText || n.setNodeMarkup(r, void 0, { 8447 ...t.attrs, 8448 dir: e 8449 }); 8450 }), !0; 8451}, Su = (e) => ({ tr: t, dispatch: n }) => { 8452 if (n) { 8453 let { doc: n } = t, { from: r, to: i } = typeof e == "number" ? { 8454 from: e, 8455 to: e 8456 } : e, a = T.atStart(n).from, o = T.atEnd(n).to, s = Fc(r, a, o), c = Fc(i, a, o), l = T.create(n, s, c); 8457 t.setSelection(l); 8458 } 8459 return !0; 8460}, Cu = (e) => ({ state: t, dispatch: n }) => Dr(L(e, t.schema))(t, n); 8461function wu(e, t) { 8462 let n = e.storedMarks || e.selection.$to.parentOffset && e.selection.$from.marks(); 8463 if (n) { 8464 let r = n.filter((e) => t?.includes(e.type.name)); 8465 e.tr.ensureMarks(r); 8466 } 8467} 8468var Tu = ({ keepMarks: e = !0 } = {}) => ({ tr: t, state: n, dispatch: r, editor: i }) => { 8469 let { selection: a, doc: o } = t, { $from: s, $to: c } = a, l = i.extensionManager.attributes, u = ru(l, s.node().type.name, s.node().attrs); 8470 if (a instanceof E && a.node.isBlock) return !s.parentOffset || !Vt(o, s.pos) ? !1 : (r && (e && wu(n, i.extensionManager.splittableMarks), t.split(s.pos).scrollIntoView()), !0); 8471 if (!s.parent.isBlock) return !1; 8472 let d = c.parentOffset === c.parent.content.size, f = s.depth === 0 ? void 0 : Tl(s.node(-1).contentMatchAt(s.indexAfter(-1))), p = d && f ? [{ 8473 type: f, 8474 attrs: u 8475 }] : void 0, m = Vt(t.doc, t.mapping.map(s.pos), 1, p); 8476 if (!p && !m && Vt(t.doc, t.mapping.map(s.pos), 1, f ? [{ type: f }] : void 0) && (m = !0, p = f ? [{ 8477 type: f, 8478 attrs: u 8479 }] : void 0), r) { 8480 if (m && (a instanceof T && t.deleteSelection(), t.split(t.mapping.map(s.pos), 1, p), f && !d && !s.parentOffset && s.parent.type !== f)) { 8481 let e = t.mapping.map(s.before()), n = t.doc.resolve(e); 8482 s.node(-1).canReplaceWith(n.index(), n.index() + 1, f) && t.setNodeMarkup(t.mapping.map(s.before()), f); 8483 } 8484 e && wu(n, i.extensionManager.splittableMarks), t.scrollIntoView(); 8485 } 8486 return m; 8487}, Eu = (e, t = {}) => ({ tr: n, state: r, dispatch: i, editor: o }) => { 8488 let s = L(e, r.schema), { $from: c, $to: l } = r.selection, u = r.selection.node; 8489 if (u && u.isBlock || c.depth < 2 || !c.sameParent(l)) return !1; 8490 let f = c.node(-1); 8491 if (f.type !== s) return !1; 8492 let p = o.extensionManager.attributes; 8493 if (c.parent.content.size === 0 && c.node(-1).childCount === c.indexAfter(-1)) { 8494 if (c.depth === 2 || c.node(-3).type !== s || c.index(-2) !== c.node(-2).childCount - 1) return !1; 8495 if (i) { 8496 let e = a.empty, r = c.index(-1) ? 1 : c.index(-2) ? 2 : 3; 8497 for (let t = c.depth - r; t >= c.depth - 3; --t) e = a.from(c.node(t).copy(e)); 8498 let i = c.indexAfter(-1) < c.node(-2).childCount ? 1 : c.indexAfter(-2) < c.node(-3).childCount ? 2 : 3, o = { 8499 ...ru(p, c.node().type.name, c.node().attrs), 8500 ...t 8501 }, l = s.contentMatch.defaultType?.createAndFill(o) || void 0; 8502 e = e.append(a.from(s.createAndFill(null, l) || void 0)); 8503 let u = c.before(c.depth - (r - 1)); 8504 n.replace(u, c.after(-i), new d(e, 4 - r, 0)); 8505 let f = -1; 8506 n.doc.nodesBetween(u, n.doc.content.size, (e, t) => { 8507 if (f > -1) return !1; 8508 e.isTextblock && e.content.size === 0 && (f = t + 1); 8509 }), f > -1 && n.setSelection(T.near(n.doc.resolve(f))), n.scrollIntoView(); 8510 } 8511 return !0; 8512 } 8513 let m = l.pos === c.end() ? f.contentMatchAt(0).defaultType : null, h = { 8514 ...ru(p, f.type.name, f.attrs), 8515 ...t 8516 }, g = { 8517 ...ru(p, c.node().type.name, c.node().attrs), 8518 ...t 8519 }; 8520 n.delete(c.pos, l.pos); 8521 let _ = m ? [{ 8522 type: s, 8523 attrs: h 8524 }, { 8525 type: m, 8526 attrs: g 8527 }] : [{ 8528 type: s, 8529 attrs: h 8530 }]; 8531 if (!Vt(n.doc, c.pos, 2)) return !1; 8532 if (i) { 8533 let { selection: e, storedMarks: t } = r, { splittableMarks: a } = o.extensionManager, s = t || e.$to.parentOffset && e.$from.marks(); 8534 if (n.split(c.pos, 2, _).scrollIntoView(), !s || !i) return !0; 8535 let l = s.filter((e) => a.includes(e.type.name)); 8536 n.ensureMarks(l); 8537 } 8538 return !0; 8539}; 8540function Du(e) { 8541 return !e || e === "1" ? null : e; 8542} 8543function Ou(e, t) { 8544 return Du(e) === Du(t); 8545} 8546var ku = (e, t) => { 8547 let n = Ol((e) => e.type === t)(e.selection); 8548 if (!n) return !0; 8549 let r = e.doc.resolve(Math.max(0, n.pos - 1)).before(n.depth); 8550 if (r === void 0) return !0; 8551 let i = e.doc.nodeAt(r); 8552 return !(n.node.type === i?.type && Ut(e.doc, n.pos)) || !Ou(n.node.attrs.type, i?.attrs.type) || e.join(n.pos), !0; 8553}, Au = (e, t) => { 8554 let n = Ol((e) => e.type === t)(e.selection); 8555 if (!n) return !0; 8556 let r = e.doc.resolve(n.start).after(n.depth); 8557 if (r === void 0) return !0; 8558 let i = e.doc.nodeAt(r); 8559 return !(n.node.type === i?.type && Ut(e.doc, r)) || !Ou(n.node.attrs.type, i?.attrs.type) || e.join(r), !0; 8560}; 8561function ju(e) { 8562 let t = e.doc, n = t.firstChild; 8563 if (!n) return null; 8564 let r = t.resolve(1), i = t.resolve(n.nodeSize - 1); 8565 return T.between(r, i); 8566} 8567var Mu = (e, t, n, r = {}) => ({ editor: i, tr: a, state: o, dispatch: s, chain: c, commands: l, can: u }) => { 8568 let { extensions: d, splittableMarks: f } = i.extensionManager, p = L(e, o.schema), m = L(t, o.schema), { selection: h, storedMarks: g } = o, { $from: _, $to: ee } = h, v = _.blockRange(ee), y = g || h.$to.parentOffset && h.$from.marks(); 8569 if (!v) return !1; 8570 let b = Ol((e) => uu(e.type.name, d))(h), te = h.from === 0 && h.to === o.doc.content.size, ne = o.doc.content.content, re = ne.length === 1 ? ne[0] : null, ie = te && re && uu(re.type.name, d) ? { 8571 node: re, 8572 pos: 0, 8573 depth: 0 8574 } : null, ae = b ?? ie, oe = !!b && v.depth >= 1 && v.depth - b.depth <= 1, se = !!ie; 8575 if ((oe || se) && ae) { 8576 if (ae.node.type === p) return te && se ? c().command(({ tr: e, dispatch: t }) => { 8577 let n = ju(e); 8578 return n ? (e.setSelection(n), t && t(e), !0) : !1; 8579 }).liftListItem(m).run() : l.liftListItem(m); 8580 if (uu(ae.node.type.name, d) && p.validContent(ae.node.content)) return c().command(() => (a.setNodeMarkup(ae.pos, p), !0)).command(() => ku(a, p)).command(() => Au(a, p)).run(); 8581 } 8582 return !n || !y || !s ? c().command(() => u().wrapInList(p, r) ? !0 : l.clearNodes()).wrapInList(p, r).command(() => ku(a, p)).command(() => Au(a, p)).run() : c().command(() => { 8583 let e = u().wrapInList(p, r), t = y.filter((e) => f.includes(e.type.name)); 8584 return a.ensureMarks(t), e ? !0 : l.clearNodes(); 8585 }).wrapInList(p, r).command(() => ku(a, p)).command(() => Au(a, p)).run(); 8586}, Nu = (e, t = {}, n = {}) => ({ state: r, commands: i }) => { 8587 let { extendEmptyMarkRange: a = !1 } = n, o = jc(e, r.schema); 8588 return au(r, o, t) ? i.unsetMark(o, { extendEmptyMarkRange: a }) : i.setMark(o, t); 8589}, Pu = (e, t, n = {}) => ({ state: r, commands: i }) => { 8590 let a = L(e, r.schema), o = L(t, r.schema), s = ol(r, a, n), c; 8591 return r.selection.$anchor.sameParent(r.selection.$head) && (c = r.selection.$anchor.parent.attrs), s ? i.setNode(o, c) : i.setNode(a, { 8592 ...c, 8593 ...n 8594 }); 8595}, Fu = (e, t = {}) => ({ state: n, commands: r }) => { 8596 let i = L(e, n.schema); 8597 return ol(n, i, t) ? r.lift(i) : r.wrapIn(i, t); 8598}, Iu = () => ({ state: e, dispatch: t }) => { 8599 let n = e.plugins; 8600 for (let r = 0; r < n.length; r += 1) { 8601 let i = n[r], a; 8602 if (i.spec.isInputRules && (a = i.getState(e))) { 8603 if (t) { 8604 let t = e.tr, n = a.transform; 8605 for (let e = n.steps.length - 1; e >= 0; --e) t.step(n.steps[e].invert(n.docs[e])); 8606 if (a.text) { 8607 let n = t.doc.resolve(a.from).marks(); 8608 t.replaceWith(a.from, a.to, e.schema.text(a.text, n)); 8609 } else t.delete(a.from, a.to); 8610 } 8611 return !0; 8612 } 8613 } 8614 return !1; 8615}, Lu = (e = {}) => ({ tr: t, dispatch: n, editor: r }) => { 8616 let { ignoreClearable: i = !1 } = e, { selection: a } = t, { empty: o, ranges: s } = a; 8617 if (o) return !0; 8618 let { nonClearableMarks: c } = r.extensionManager; 8619 if (n) { 8620 let e = Object.values(r.schema.marks).filter((e) => i || !c.includes(e.name)); 8621 s.forEach((n) => { 8622 for (let r of e) t.removeMark(n.$from.pos, n.$to.pos, r); 8623 }); 8624 } 8625 return !0; 8626}, Ru = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => { 8627 let { extendEmptyMarkRange: a = !1 } = t, { selection: o } = n, s = jc(e, r.schema), { $from: c, empty: l, ranges: u } = o; 8628 if (!i) return !0; 8629 if (l && a) { 8630 let { from: e, to: t } = o, r = Ac(c, s, c.marks().find((e) => e.type === s)?.attrs); 8631 r && (e = r.from, t = r.to), n.removeMark(e, t, s); 8632 } else u.forEach((e) => { 8633 n.removeMark(e.$from.pos, e.$to.pos, s); 8634 }); 8635 return n.removeStoredMark(s), !0; 8636}, zu = (e) => ({ tr: t, state: n, dispatch: r }) => { 8637 let { selection: i } = n, a, o; 8638 return typeof e == "number" ? (a = e, o = e) : e && "from" in e && "to" in e ? (a = e.from, o = e.to) : (a = i.from, o = i.to), r && t.doc.nodesBetween(a, o, (e, n) => { 8639 if (e.isText) return; 8640 let r = { ...e.attrs }; 8641 delete r.dir, t.setNodeMarkup(n, void 0, r); 8642 }), !0; 8643}, Bu = (e, t = {}) => ({ tr: n, state: r, dispatch: i }) => { 8644 let a = null, o = null, s = dl(typeof e == "string" ? e : e.name, r.schema); 8645 if (!s) return !1; 8646 s === "node" && (a = L(e, r.schema)), s === "mark" && (o = jc(e, r.schema)); 8647 let c = !1; 8648 return n.selection.ranges.forEach((e) => { 8649 let s = e.$from.pos, l = e.$to.pos, u, d, f, p; 8650 n.selection.empty ? r.doc.nodesBetween(s, l, (e, t) => { 8651 a && a === e.type && (c = !0, f = Math.max(t, s), p = Math.min(t + e.nodeSize, l), u = t, d = e); 8652 }) : r.doc.nodesBetween(s, l, (e, r) => { 8653 r < s && a && a === e.type && (c = !0, f = Math.max(r, s), p = Math.min(r + e.nodeSize, l), u = r, d = e), r >= s && r <= l && (a && a === e.type && (c = !0, i && n.setNodeMarkup(r, void 0, { 8654 ...e.attrs, 8655 ...t 8656 })), o && e.marks.length && e.marks.forEach((a) => { 8657 if (o === a.type && (c = !0, i)) { 8658 let i = Math.max(r, s), c = Math.min(r + e.nodeSize, l); 8659 n.addMark(i, c, o.create({ 8660 ...a.attrs, 8661 ...t 8662 })); 8663 } 8664 })); 8665 }), d && (u !== void 0 && i && n.setNodeMarkup(u, void 0, { 8666 ...d.attrs, 8667 ...t 8668 }), o && d.marks.length && d.marks.forEach((e) => { 8669 o === e.type && i && n.addMark(f, p, o.create({ 8670 ...e.attrs, 8671 ...t 8672 })); 8673 })); 8674 }), c; 8675}, Vu = (e, t = {}) => ({ state: n, dispatch: r }) => mr(L(e, n.schema), t)(n, r), Hu = (e, t = {}) => ({ state: n, dispatch: r }) => xr(L(e, n.schema), t)(n, r), Uu = class { 8676 constructor() { 8677 this.callbacks = {}; 8678 } 8679 on(e, t) {
8680 return this.callbacks[e] || (this.callbacks[e] = []), this.callbacks[e].push(t), this; 8681 } 8682 emit(e, ...t) { 8683 let n = this.callbacks[e]; 8684 return n && n.forEach((e) => e.apply(this, t)), this; 8685 } 8686 off(e, t) { 8687 let n = this.callbacks[e]; 8688 return n && (t ? this.callbacks[e] = n.filter((e) => e !== t) : delete this.callbacks[e]), this; 8689 } 8690 once(e, t) { 8691 let n = (...r) => { 8692 this.off(e, n), t.apply(this, r); 8693 }; 8694 return this.on(e, n); 8695 } 8696 removeAllListeners() { 8697 this.callbacks = {}; 8698 } 8699}; 8700function Wu(e, t) { 8701 let { selection: n } = e, { $from: r } = n; 8702 if (n instanceof E) { 8703 let e = r.index(); 8704 return r.parent.canReplaceWith(e, e + 1, t); 8705 } 8706 let i = r.depth; 8707 for (; i >= 0;) { 8708 let e = r.index(i); 8709 if (r.node(i).contentMatchAt(e).matchType(t)) return !0; 8710 --i; 8711 } 8712 return !1; 8713} 8714function Gu(e, t, n) { 8715 let r = document.querySelector(`style[data-tiptap-style${n ? `-${n}` : ""}]`); 8716 if (r !== null) return r; 8717 let i = document.createElement("style"); 8718 return t && i.setAttribute("nonce", t), i.setAttribute(`data-tiptap-style${n ? `-${n}` : ""}`, ""), i.innerHTML = e, document.getElementsByTagName("head")[0].appendChild(i), i; 8719} 8720function Ku(e) { 8721 return typeof e == "number"; 8722} 8723function qu(e) { 8724 return Object.prototype.toString.call(e).slice(8, -1); 8725} 8726function Ju(e) { 8727 return qu(e) === "Object" ? e.constructor === Object && Object.getPrototypeOf(e) === Object.prototype : !1; 8728} 8729sc({}, { 8730 createAtomBlockMarkdownSpec: () => Zu, 8731 createBlockMarkdownSpec: () => Qu, 8732 createInlineMarkdownSpec: () => td, 8733 parseAttributes: () => Yu, 8734 parseIndentedBlocks: () => nd, 8735 renderNestedMarkdownContent: () => rd, 8736 serializeAttributes: () => Xu 8737}); 8738function Yu(e) { 8739 if (!e?.trim()) return {}; 8740 let t = {}, n = [], r = e.replace(/["']([^"']*)["']/g, (e) => (n.push(e), `__QUOTED_${n.length - 1}__`)), i = r.match(/(?:^|\s)\.([\w-]+)/g); 8741 i && (t.class = i.map((e) => e.trim().slice(1)).join(" ")); 8742 let a = r.match(/(?:^|\s)#([\w-]+)/); 8743 a && (t.id = a[1]), Array.from(r.matchAll(/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g)).forEach(([, e, r]) => { 8744 let i = n[parseInt(r.match(/__QUOTED_(\d+)__/)?.[1] || "0", 10)]; 8745 i && (t[e] = i.slice(1, -1)); 8746 }); 8747 let o = r.replace(/(?:^|\s)\.([\w-]+)/g, "").replace(/(?:^|\s)#([\w-]+)/g, "").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g, "").trim(); 8748 return o && o.split(/\s+/).filter(Boolean).forEach((e) => {
vendor: 26,298 bytes, lines 8749-9685
8749 e.match(/^[a-zA-Z][\w-]*$/) && (t[e] = !0); 8750 }), t; 8751} 8752function Xu(e) { 8753 if (!e || Object.keys(e).length === 0) return ""; 8754 let t = []; 8755 return e.class && String(e.class).split(/\s+/).filter(Boolean).forEach((e) => t.push(`.${e}`)), e.id && t.push(`#${e.id}`), Object.entries(e).forEach(([e, n]) => { 8756 e === "class" || e === "id" || (n === !0 ? t.push(e) : n !== !1 && n != null && t.push(`${e}="${String(n)}"`)); 8757 }), t.join(" "); 8758} 8759function Zu(e) { 8760 let { nodeName: t, name: n, parseAttributes: r = Yu, serializeAttributes: i = Xu, defaultAttributes: a = {}, requiredAttributes: o = [], allowedAttributes: s } = e, c = n || t, l = (e) => { 8761 if (!s) return e; 8762 let t = {}; 8763 return s.forEach((n) => { 8764 n in e && (t[n] = e[n]); 8765 }), t; 8766 }; 8767 return { 8768 parseMarkdown: (e, n) => { 8769 let r = { 8770 ...a, 8771 ...e.attributes 8772 }; 8773 return n.createNode(t, r, []); 8774 }, 8775 markdownTokenizer: { 8776 name: t, 8777 level: "block", 8778 start(e) { 8779 let t = RegExp(`^:::${c}(?:\\s|$)`, "m"), n = e.match(t)?.index; 8780 return n === void 0 ? -1 : n; 8781 }, 8782 tokenize(e, n, i) { 8783 let a = RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`), s = e.match(a); 8784 if (!s) return; 8785 let l = r(s[1] || ""); 8786 if (!o.find((e) => !(e in l))) return { 8787 type: t, 8788 raw: s[0], 8789 attributes: l 8790 }; 8791 } 8792 }, 8793 renderMarkdown: (e) => { 8794 let t = i(l(e.attrs || {})); 8795 return `:::${c}${t ? ` {${t}}` : ""} :::`; 8796 } 8797 }; 8798} 8799function Qu(e) { 8800 let { nodeName: t, name: n, getContent: r, parseAttributes: i = Yu, serializeAttributes: a = Xu, defaultAttributes: o = {}, content: s = "block", allowedAttributes: c } = e, l = n || t, u = (e) => { 8801 if (!c) return e; 8802 let t = {}; 8803 return c.forEach((n) => { 8804 n in e && (t[n] = e[n]); 8805 }), t; 8806 }; 8807 return { 8808 parseMarkdown: (e, n) => { 8809 let i; 8810 if (r) { 8811 let t = r(e); 8812 i = typeof t == "string" ? [{ 8813 type: "text", 8814 text: t 8815 }] : t; 8816 } else i = s === "block" ? n.parseChildren(e.tokens || []) : n.parseInline(e.tokens || []); 8817 let a = { 8818 ...o, 8819 ...e.attributes 8820 }; 8821 return n.createNode(t, a, i); 8822 }, 8823 markdownTokenizer: { 8824 name: t, 8825 level: "block", 8826 start(e) { 8827 let t = RegExp(`^:::${l}`, "m"), n = e.match(t)?.index; 8828 return n === void 0 ? -1 : n; 8829 }, 8830 tokenize(e, n, r) { 8831 let a = RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*\\n`), o = e.match(a); 8832 if (!o) return; 8833 let [c, u = ""] = o, d = i(u), f = 1, p = c.length, m = "", h = /^:::([\w-]*)(\s.*)?/gm, g = e.slice(p); 8834 for (h.lastIndex = 0;;) { 8835 let n = h.exec(g); 8836 if (n === null) break; 8837 let i = n.index, a = n[1]; 8838 if (!n[2]?.endsWith(":::")) { 8839 if (a) f += 1; 8840 else if (--f, f === 0) { 8841 let a = g.slice(0, i); 8842 m = a.trim(); 8843 let o = e.slice(0, p + i + n[0].length), c = []; 8844 if (m) if (s === "block") for (c = r.blockTokens(a), c.forEach((e) => { 8845 e.text && (!e.tokens || e.tokens.length === 0) && (e.tokens = r.inlineTokens(e.text)); 8846 }); c.length > 0;) { 8847 let e = c[c.length - 1]; 8848 if (e.type === "paragraph" && (!e.text || e.text.trim() === "")) c.pop(); 8849 else break; 8850 } 8851 else c = r.inlineTokens(m); 8852 return { 8853 type: t, 8854 raw: o, 8855 attributes: d, 8856 content: m, 8857 tokens: c 8858 }; 8859 } 8860 } 8861 } 8862 } 8863 }, 8864 renderMarkdown: (e, t) => { 8865 let n = a(u(e.attrs || {})); 8866 return `:::${l}${n ? ` {${n}}` : ""} 8867 8868${t.renderChildren(e.content || [], "\n\n")} 8869 8870:::`; 8871 } 8872 }; 8873} 8874function $u(e) { 8875 if (!e.trim()) return {}; 8876 let t = {}, n = /(\w+)=(?:"([^"]*)"|'([^']*)')/g, r = n.exec(e); 8877 for (; r !== null;) { 8878 let [, i, a, o] = r; 8879 t[i] = a || o, r = n.exec(e); 8880 } 8881 return t; 8882} 8883function ed(e) { 8884 return Object.entries(e).filter(([, e]) => e != null).map(([e, t]) => `${e}="${t}"`).join(" "); 8885} 8886function td(e) { 8887 let { nodeName: t, name: n, getContent: r, parseAttributes: i = $u, serializeAttributes: a = ed, defaultAttributes: o = {}, selfClosing: s = !1, allowedAttributes: c } = e, l = n || t, u = (e) => { 8888 if (!c) return e; 8889 let t = {}; 8890 return c.forEach((n) => { 8891 let r = typeof n == "string" ? n : n.name, i = typeof n == "string" ? void 0 : n.skipIfDefault; 8892 if (r in e) { 8893 let n = e[r]; 8894 if (i !== void 0 && n === i) return; 8895 t[r] = n; 8896 } 8897 }), t; 8898 }, d = l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); 8899 return { 8900 parseMarkdown: (e, n) => { 8901 let i = { 8902 ...o, 8903 ...e.attributes 8904 }; 8905 if (s) return n.createNode(t, i); 8906 let a = r ? r(e) : e.content || ""; 8907 return a ? n.createNode(t, i, [n.createTextNode(a)]) : n.createNode(t, i, []); 8908 }, 8909 markdownTokenizer: { 8910 name: t, 8911 level: "inline", 8912 start(e) { 8913 let t = RegExp(s ? `\\[${d}\\s*[^\\]]*\\]` : `\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`), n = e.match(t)?.index; 8914 return n === void 0 ? -1 : n; 8915 }, 8916 tokenize(e, n, r) { 8917 let a = RegExp(s ? `^\\[${d}\\s*([^\\]]*)\\]` : `^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`), o = e.match(a); 8918 if (!o) return; 8919 let c = "", l = ""; 8920 if (s) { 8921 let [, e] = o; 8922 l = e; 8923 } else { 8924 let [, e, t] = o; 8925 l = e, c = t || ""; 8926 } 8927 let u = i(l.trim()); 8928 return { 8929 type: t, 8930 raw: o[0], 8931 content: c.trim(), 8932 attributes: u 8933 }; 8934 } 8935 }, 8936 renderMarkdown: (e) => { 8937 let t = ""; 8938 r ? t = r(e) : e.content && e.content.length > 0 && (t = e.content.filter((e) => e.type === "text").map((e) => e.text).join("")); 8939 let n = a(u(e.attrs || {})), i = n ? ` ${n}` : ""; 8940 return s ? `[${l}${i}]` : `[${l}${i}]${t}[/${l}]`; 8941 } 8942 }; 8943} 8944function nd(e, t, n) { 8945 let r = e.split("\n"), i = [], a = "", o = 0, s = t.baseIndentSize || 2; 8946 for (; o < r.length;) { 8947 let e = r[o], c = e.match(t.itemPattern); 8948 if (!c) { 8949 if (i.length > 0) break; 8950 if (e.trim() === "") { 8951 o += 1, a = `${a}${e} 8952`; 8953 continue; 8954 } else return; 8955 } 8956 let l = t.extractItemData(c), { indentLevel: u, mainContent: d } = l; 8957 a = `${a}${e} 8958`; 8959 let f = [d]; 8960 for (o += 1; o < r.length;) { 8961 let e = r[o]; 8962 if (e.trim() === "") { 8963 let t = r.slice(o + 1).findIndex((e) => e.trim() !== ""); 8964 if (t === -1) break; 8965 if ((r[o + 1 + t].match(/^(\s*)/)?.[1]?.length || 0) > u) { 8966 f.push(e), a = `${a}${e} 8967`, o += 1; 8968 continue; 8969 } else break; 8970 } 8971 if ((e.match(/^(\s*)/)?.[1]?.length || 0) > u) f.push(e), a = `${a}${e} 8972`, o += 1; 8973 else break; 8974 } 8975 let p, m = f.slice(1); 8976 if (m.length > 0) { 8977 let e = m.map((e) => e.slice(u + s)).join("\n"); 8978 e.trim() && (p = t.customNestedParser ? t.customNestedParser(e) : n.blockTokens(e)); 8979 } 8980 let h = t.createToken(l, p); 8981 i.push(h); 8982 } 8983 if (i.length !== 0) return { 8984 items: i, 8985 raw: a 8986 }; 8987} 8988function rd(e, t, n, r) { 8989 if (!e || !Array.isArray(e.content)) return ""; 8990 let i = typeof n == "function" ? n(r) : n, [a, ...o] = e.content, s = `${i}${t.renderChildren([a])}`; 8991 return o && o.length > 0 && o.forEach((e, n) => { 8992 let r = t.renderChild?.call(t, e, n + 1) ?? t.renderChildren([e]); 8993 if (r != null) { 8994 let n = r.split("\n").map((e) => e ? t.indent(e) : t.indent("")).join("\n"); 8995 s += e.type === "paragraph" ? ` 8996 8997${n}` : ` 8998${n}`; 8999 } 9000 }), s; 9001} 9002function id(e, t) { 9003 let n = { ...e }; 9004 return Ju(e) && Ju(t) && Object.keys(t).forEach((r) => { 9005 Ju(t[r]) && Ju(e[r]) ? n[r] = id(e[r], t[r]) : n[r] = t[r]; 9006 }), n; 9007} 9008function ad(e, t, n = {}) { 9009 let { state: r } = t, { doc: i, tr: a } = r, o = e; 9010 i.descendants((t, r) => { 9011 let i = a.mapping.map(r), s = a.mapping.map(r) + t.nodeSize, c = null; 9012 if (t.marks.forEach((e) => { 9013 if (e !== o) return !1; 9014 c = e; 9015 }), !c) return; 9016 let l = !1; 9017 if (Object.keys(n).forEach((e) => { 9018 n[e] !== c.attrs[e] && (l = !0); 9019 }), l) { 9020 let t = e.type.create({ 9021 ...e.attrs, 9022 ...n 9023 }); 9024 a.removeMark(i, s, e.type), a.addMark(i, s, t); 9025 } 9026 }), a.docChanged && t.view.dispatch(a); 9027} 9028var od = class { 9029 constructor(e) { 9030 this.find = e.find, this.handler = e.handler, this.undoable = e.undoable ?? !0; 9031 } 9032}, sd = (e, t) => { 9033 if (Ec(t)) return t.exec(e); 9034 let n = t(e); 9035 if (!n) return null; 9036 let r = [n.text]; 9037 return r.index = n.index, r.input = e, r.data = n.data, n.replaceWith && (n.text.includes(n.replaceWith) || console.warn("[tiptap warn]: \"inputRuleMatch.replaceWith\" must be part of \"inputRuleMatch.text\"."), r.push(n.replaceWith)), r; 9038}; 9039function cd(e) { 9040 let { editor: t, from: n, to: r, text: i, rules: a, plugin: o } = e, { view: s } = t; 9041 if (s.composing) return !1; 9042 let c = s.state.doc.resolve(n); 9043 if (c.parent.type.spec.code || (c.nodeBefore || c.nodeAfter)?.marks.find((e) => e.type.spec.code)) return !1; 9044 let l = !1, u = iu(c) + i; 9045 return a.forEach((e) => { 9046 if (l) return; 9047 let a = sd(u, e.find); 9048 if (!a) return; 9049 let c = s.state.tr, d = cc({ 9050 state: s.state, 9051 transaction: c 9052 }), f = { 9053 from: n - (a[0].length - i.length), 9054 to: r 9055 }, { commands: p, chain: m, can: h } = new lc({ 9056 editor: t, 9057 state: d 9058 }); 9059 e.handler({ 9060 state: d, 9061 range: f, 9062 match: a, 9063 commands: p, 9064 chain: m, 9065 can: h 9066 }) === null || !c.steps.length || (e.undoable && c.setMeta(o, { 9067 transform: c, 9068 from: n, 9069 to: r, 9070 text: i 9071 }), s.dispatch(c), l = !0); 9072 }), l; 9073} 9074function ld(e) { 9075 let { editor: t, rules: n } = e, r = new D({ 9076 state: { 9077 init() { 9078 return null; 9079 }, 9080 apply(e, i, o) { 9081 let s = e.getMeta(r); 9082 if (s) return s; 9083 let c = e.getMeta("applyInputRules"); 9084 return c && setTimeout(() => { 9085 let { text: e } = c; 9086 e = typeof e == "string" ? e : Al(a.from(e), o.schema); 9087 let { from: i } = c; 9088 cd({ 9089 editor: t, 9090 from: i, 9091 to: i + e.length, 9092 text: e, 9093 rules: n, 9094 plugin: r 9095 }); 9096 }), e.selectionSet || e.docChanged ? null : i; 9097 } 9098 }, 9099 props: { 9100 handleTextInput(e, i, a, o) { 9101 return cd({ 9102 editor: t, 9103 from: i, 9104 to: a, 9105 text: o, 9106 rules: n, 9107 plugin: r 9108 }); 9109 }, 9110 handleDOMEvents: { compositionend: (e) => (setTimeout(() => { 9111 let { $cursor: i } = e.state.selection; 9112 i && cd({ 9113 editor: t, 9114 from: i.pos, 9115 to: i.pos, 9116 text: "", 9117 rules: n, 9118 plugin: r 9119 }); 9120 }), !1) }, 9121 handleKeyDown(e, i) { 9122 if (i.key !== "Enter") return !1; 9123 let { $cursor: a } = e.state.selection; 9124 return a ? cd({ 9125 editor: t, 9126 from: a.pos, 9127 to: a.pos, 9128 text: "\n", 9129 rules: n, 9130 plugin: r 9131 }) : !1; 9132 } 9133 }, 9134 isInputRules: !0 9135 }); 9136 return r; 9137} 9138var ud = class { 9139 constructor(e = {}) { 9140 this.type = "extendable", this.parent = null, this.child = null, this.name = "", this.config = { name: this.name }, this.config = { 9141 ...this.config, 9142 ...e 9143 }, this.name = this.config.name; 9144 } 9145 get options() { 9146 return { ...z(R(this, "addOptions", { name: this.name })) }; 9147 } 9148 get storage() { 9149 return { ...z(R(this, "addStorage", { 9150 name: this.name, 9151 options: this.options 9152 })) }; 9153 } 9154 configure(e = {}) { 9155 let t = this.extend({ 9156 ...this.config, 9157 addOptions: () => id(this.options, e) 9158 }); 9159 return t.name = this.name, t.parent = this.parent, this.child = null, t; 9160 } 9161 extend(e = {}) { 9162 let t = new this.constructor({ 9163 ...this.config, 9164 ...e 9165 }); 9166 return t.parent = this, this.child = t, t.name = "name" in e ? e.name : t.parent.name, t; 9167 } 9168}, dd = class e extends ud { 9169 constructor() { 9170 super(...arguments), this.type = "mark"; 9171 } 9172 static create(t = {}) { 9173 return new e(typeof t == "function" ? t() : t); 9174 } 9175 static handleExit({ editor: e, mark: t }) { 9176 let { tr: n } = e.state, r = e.state.selection.$from; 9177 if (r.pos === r.end()) { 9178 let i = r.marks(); 9179 if (!i.find((e) => e?.type.name === t.name)) return !1; 9180 let a = i.find((e) => e?.type.name === t.name); 9181 return a && n.removeStoredMark(a), n.insertText(" ", r.pos), e.view.dispatch(n), !0; 9182 } 9183 return !1; 9184 } 9185 configure(e) { 9186 return super.configure(e); 9187 } 9188 extend(e) { 9189 let t = typeof e == "function" ? e() : e; 9190 return super.extend(t); 9191 } 9192}, fd = class { 9193 constructor(e) { 9194 this.find = e.find, this.handler = e.handler; 9195 } 9196}, pd = (e, t, n) => { 9197 if (Ec(t)) return [...e.matchAll(t)]; 9198 let r = t(e, n); 9199 return r ? r.map((t) => { 9200 let n = [t.text]; 9201 return n.index = t.index, n.input = e, n.data = t.data, t.replaceWith && (t.text.includes(t.replaceWith) || console.warn("[tiptap warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\"."), n.push(t.replaceWith)), n; 9202 }) : []; 9203}; 9204function md(e) { 9205 let { editor: t, state: n, from: r, to: i, rule: a, pasteEvent: o, dropEvent: s } = e, { commands: c, chain: l, can: u } = new lc({ 9206 editor: t, 9207 state: n 9208 }), d = []; 9209 return n.doc.nodesBetween(r, i, (e, t) => { 9210 if (e.type?.spec?.code || !(e.isText || e.isTextblock || e.isInline)) return; 9211 let f = e.content?.size ?? e.nodeSize ?? 0, p = Math.max(r, t), m = Math.min(i, t + f); 9212 p >= m || pd(e.isText ? e.text || "" : e.textBetween(p - t, m - t, void 0, ""), a.find, o).forEach((e) => { 9213 if (e.index === void 0) return; 9214 let t = p + e.index + 1, r = t + e[0].length, i = { 9215 from: n.tr.mapping.map(t), 9216 to: n.tr.mapping.map(r) 9217 }, f = a.handler({ 9218 state: n, 9219 range: i, 9220 match: e, 9221 commands: c, 9222 chain: l, 9223 can: u, 9224 pasteEvent: o, 9225 dropEvent: s 9226 }); 9227 d.push(f); 9228 }); 9229 }), d.every((e) => e !== null); 9230} 9231var hd = null, gd = (e) => { 9232 var t; 9233 let n = new ClipboardEvent("paste", { clipboardData: new DataTransfer() }); 9234 return (t = n.clipboardData) == null || t.setData("text/html", e), n; 9235}; 9236function _d(e) { 9237 let { editor: t, rules: n } = e, r = null, i = !1, o = !1, s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, c; 9238 try { 9239 c = typeof DragEvent < "u" ? new DragEvent("drop") : null; 9240 } catch { 9241 c = null; 9242 } 9243 let l = ({ state: e, from: n, to: r, rule: i, pasteEvt: a }) => { 9244 let o = e.tr; 9245 if (!(!md({ 9246 editor: t, 9247 state: cc({ 9248 state: e, 9249 transaction: o 9250 }), 9251 from: Math.max(n - 1, 0), 9252 to: r.b - 1, 9253 rule: i, 9254 pasteEvent: a, 9255 dropEvent: c 9256 }) || !o.steps.length)) { 9257 try { 9258 c = typeof DragEvent < "u" ? new DragEvent("drop") : null; 9259 } catch { 9260 c = null; 9261 } 9262 return s = typeof ClipboardEvent < "u" ? new ClipboardEvent("paste") : null, o; 9263 } 9264 }; 9265 return n.map((e) => new D({ 9266 view(e) { 9267 let n = (n) => { 9268 r = e.dom.parentElement?.contains(n.target) ? e.dom.parentElement : null, r && (hd = t); 9269 }, i = () => { 9270 hd &&= null; 9271 }; 9272 return window.addEventListener("dragstart", n), window.addEventListener("dragend", i), { destroy() { 9273 window.removeEventListener("dragstart", n), window.removeEventListener("dragend", i); 9274 } }; 9275 }, 9276 props: { handleDOMEvents: { 9277 drop: (e, t) => { 9278 if (o = r === e.dom.parentElement, c = t, !o) { 9279 let e = hd; 9280 e?.isEditable && setTimeout(() => { 9281 let t = e.state.selection; 9282 t && e.commands.deleteRange({ 9283 from: t.from, 9284 to: t.to 9285 }); 9286 }, 10); 9287 } 9288 return !1; 9289 }, 9290 paste: (e, t) => { 9291 let n = t.clipboardData?.getData("text/html"); 9292 return s = t, i = !!n?.includes("data-pm-slice"), !1; 9293 } 9294 } }, 9295 appendTransaction: (t, n, r) => { 9296 let c = t[0], u = c.getMeta("uiEvent") === "paste" && !i, d = c.getMeta("uiEvent") === "drop" && !o, f = c.getMeta("applyPasteRules"), p = !!f; 9297 if (!u && !d && !p) return; 9298 if (p) { 9299 let { text: t } = f; 9300 t = typeof t == "string" ? t : Al(a.from(t), r.schema); 9301 let { from: n } = f, i = n + t.length, o = gd(t); 9302 return l({ 9303 rule: e, 9304 state: r, 9305 from: n, 9306 to: { b: i }, 9307 pasteEvt: o 9308 }); 9309 } 9310 let m = n.doc.content.findDiffStart(r.doc.content), h = n.doc.content.findDiffEnd(r.doc.content); 9311 if (!(!Ku(m) || !h || m === h.b)) return l({ 9312 rule: e, 9313 state: r, 9314 from: m, 9315 to: h, 9316 pasteEvt: s 9317 }); 9318 } 9319 })); 9320} 9321var vd = class { 9322 constructor(e, t) { 9323 this.splittableMarks = [], this.nonClearableMarks = [], this.editor = t, this.baseExtensions = e, this.extensions = Gl(e), this.schema = Hl(this.extensions, t), this.setupExtensions(); 9324 } 9325 get commands() { 9326 return this.extensions.reduce((e, t) => { 9327 let n = R(t, "addCommands", { 9328 name: t.name, 9329 options: t.options, 9330 storage: this.editor.extensionStorage[t.name], 9331 editor: this.editor, 9332 type: nu(t.name, this.schema) 9333 }); 9334 return n ? { 9335 ...e, 9336 ...n() 9337 } : e; 9338 }, {}); 9339 } 9340 get plugins() { 9341 let { editor: e } = this; 9342 return Wl([...this.extensions].reverse()).flatMap((t) => { 9343 let n = { 9344 name: t.name, 9345 options: t.options, 9346 storage: this.editor.extensionStorage[t.name], 9347 editor: e, 9348 type: nu(t.name, this.schema) 9349 }, r = [], i = R(t, "addKeyboardShortcuts", n), a = {}; 9350 if (t.type === "mark" && R(t, "exitable", n) && (a.ArrowRight = () => dd.handleExit({ 9351 editor: e, 9352 mark: t 9353 })), i) { 9354 let t = Object.fromEntries(Object.entries(i()).map(([t, n]) => [t, () => n({ editor: e })])); 9355 a = { 9356 ...a, 9357 ...t 9358 }; 9359 } 9360 let o = ic(a); 9361 r.push(o); 9362 let s = R(t, "addInputRules", n); 9363 if (lu(t, e.options.enableInputRules) && s) { 9364 let t = s(); 9365 if (t && t.length) { 9366 let n = ld({ 9367 editor: e, 9368 rules: t 9369 }), i = Array.isArray(n) ? n : [n]; 9370 r.push(...i); 9371 } 9372 } 9373 let c = R(t, "addPasteRules", n); 9374 if (lu(t, e.options.enablePasteRules) && c) { 9375 let t = c(); 9376 if (t && t.length) { 9377 let n = _d({ 9378 editor: e, 9379 rules: t 9380 }); 9381 r.push(...n); 9382 } 9383 } 9384 let l = R(t, "addProseMirrorPlugins", n); 9385 if (l) { 9386 let e = l(); 9387 r.push(...e); 9388 } 9389 return r; 9390 }); 9391 } 9392 get attributes() { 9393 return Pl(this.extensions); 9394 } 9395 get nodeViews() { 9396 let { editor: e } = this, { nodeExtensions: t } = Nl(this.extensions); 9397 return Object.fromEntries(t.filter((e) => !!R(e, "addNodeView")).map((t) => { 9398 let n = this.attributes.filter((e) => e.type === t.name), r = R(t, "addNodeView", { 9399 name: t.name, 9400 options: t.options, 9401 storage: this.editor.extensionStorage[t.name], 9402 editor: e, 9403 type: L(t.name, this.schema) 9404 }); 9405 if (!r) return []; 9406 let i = r(); 9407 return i ? [t.name, (r, a, o, s, c) => i({ 9408 node: r, 9409 view: a, 9410 getPos: o, 9411 decorations: s, 9412 innerDecorations: c, 9413 editor: e, 9414 extension: t, 9415 HTMLAttributes: Ll(r, n) 9416 })] : []; 9417 })); 9418 } 9419 dispatchTransaction(e) { 9420 let { editor: t } = this; 9421 return Wl([...this.extensions].reverse()).reduceRight((e, n) => { 9422 let r = { 9423 name: n.name, 9424 options: n.options, 9425 storage: this.editor.extensionStorage[n.name], 9426 editor: t, 9427 type: nu(n.name, this.schema) 9428 }, i = R(n, "dispatchTransaction", r); 9429 return i ? (t) => { 9430 i.call(r, { 9431 transaction: t, 9432 next: e 9433 }); 9434 } : e; 9435 }, e); 9436 } 9437 transformPastedHTML(e) { 9438 let { editor: t } = this; 9439 return Wl([...this.extensions]).reduce((e, n) => { 9440 let r = { 9441 name: n.name, 9442 options: n.options, 9443 storage: this.editor.extensionStorage[n.name], 9444 editor: t, 9445 type: nu(n.name, this.schema) 9446 }, i = R(n, "transformPastedHTML", r); 9447 return i ? (t, n) => { 9448 let a = e(t, n); 9449 return i.call(r, a); 9450 } : e; 9451 }, e || ((e) => e)); 9452 } 9453 get markViews() { 9454 let { editor: e } = this, { markExtensions: t } = Nl(this.extensions); 9455 return Object.fromEntries(t.filter((e) => !!R(e, "addMarkView")).map((t) => { 9456 let n = this.attributes.filter((e) => e.type === t.name), r = R(t, "addMarkView", { 9457 name: t.name, 9458 options: t.options, 9459 storage: this.editor.extensionStorage[t.name], 9460 editor: e, 9461 type: jc(t.name, this.schema) 9462 }); 9463 return r ? [t.name, (i, a, o) => { 9464 let s = Ll(i, n); 9465 return r()({ 9466 mark: i, 9467 view: a, 9468 inline: o, 9469 editor: e, 9470 extension: t, 9471 HTMLAttributes: s, 9472 updateAttributes: (t) => { 9473 ad(i, e, t); 9474 } 9475 }); 9476 }] : []; 9477 })); 9478 } 9479 destroy() { 9480 this.extensions.forEach((e) => { 9481 let t = e; 9482 for (; t.parent;) { 9483 let e = t.parent; 9484 e.child === t && (e.child = null), t = e; 9485 } 9486 }), this.extensions = [], this.baseExtensions = [], this.schema = null, this.editor = null; 9487 } 9488 setupExtensions() { 9489 let e = this.extensions; 9490 this.editor.extensionStorage = Object.fromEntries(e.map((e) => [e.name, e.storage])), e.forEach((e) => { 9491 let t = { 9492 name: e.name, 9493 options: e.options, 9494 storage: this.editor.extensionStorage[e.name], 9495 editor: this.editor, 9496 type: nu(e.name, this.schema) 9497 }; 9498 e.type === "mark" && ((z(R(e, "keepOnSplit", t)) ?? !0) && this.splittableMarks.push(e.name), (z(R(e, "clearable", t)) ?? !0) || this.nonClearableMarks.push(e.name)); 9499 let n = R(e, "onBeforeCreate", t), r = R(e, "onCreate", t), i = R(e, "onUpdate", t), a = R(e, "onSelectionUpdate", t), o = R(e, "onTransaction", t), s = R(e, "onFocus", t), c = R(e, "onBlur", t), l = R(e, "onDestroy", t); 9500 n && this.editor.on("beforeCreate", n), r && this.editor.on("create", r), i && this.editor.on("update", i), a && this.editor.on("selectionUpdate", a), o && this.editor.on("transaction", o), s && this.editor.on("focus", s), c && this.editor.on("blur", c), l && this.editor.on("destroy", l); 9501 }); 9502 } 9503}; 9504vd.resolve = Gl, vd.sort = Wl, vd.flatten = kl, sc({}, { 9505 ClipboardTextSerializer: () => yd, 9506 Commands: () => bd, 9507 Delete: () => xd, 9508 Drop: () => Sd, 9509 Editable: () => Cd, 9510 FocusEvents: () => Td, 9511 Keymap: () => Ed, 9512 Paste: () => Dd, 9513 Tabindex: () => Od, 9514 TextDirection: () => kd, 9515 focusEventsPluginKey: () => wd 9516}); 9517var V = class e extends ud { 9518 constructor() { 9519 super(...arguments), this.type = "extension"; 9520 } 9521 static create(t = {}) { 9522 return new e(typeof t == "function" ? t() : t); 9523 } 9524 configure(e) { 9525 return super.configure(e); 9526 } 9527 extend(e) { 9528 let t = typeof e == "function" ? e() : e; 9529 return super.extend(t); 9530 } 9531}, yd = V.create({ 9532 name: "clipboardTextSerializer", 9533 addOptions() { 9534 return { blockSeparator: void 0 }; 9535 }, 9536 addProseMirrorPlugins() { 9537 return [new D({ 9538 key: new O("clipboardTextSerializer"), 9539 props: { clipboardTextSerializer: () => { 9540 let { editor: e } = this, { state: t, schema: n } = e, { doc: r, selection: i } = t, a = Jl(n), { blockSeparator: o } = this.options, s = { 9541 ...o === void 0 ? {} : { blockSeparator: o }, 9542 textSerializers: a 9543 }; 9544 return [...i.ranges].sort((e, t) => e.$from.pos - t.$from.pos).map(({ $from: e, $to: t }) => Kl(r, { 9545 from: e.pos, 9546 to: t.pos 9547 }, s)).join(o ?? "\n\n"); 9548 } } 9549 })]; 9550 } 9551}), bd = V.create({ 9552 name: "commands", 9553 addCommands() { 9554 return { ...uc }; 9555 } 9556}), xd = V.create({ 9557 name: "delete", 9558 onUpdate({ transaction: e, appendedTransactions: t }) { 9559 let n = () => { 9560 var n; 9561 if (((n = this.editor.options.coreExtensionOptions?.delete)?.filterTransaction)?.call(n, e) ?? e.getMeta("y-sync$")) return; 9562 let r = wl(e.before, [e, ...t]); 9563 $l(r).forEach((t) => { 9564 r.mapping.mapResult(t.oldRange.from).deletedAfter && r.mapping.mapResult(t.oldRange.to).deletedBefore && r.before.nodesBetween(t.oldRange.from, t.oldRange.to, (n, i) => { 9565 let a = i + n.nodeSize - 2, o = t.oldRange.from <= i && a <= t.oldRange.to; 9566 this.editor.emit("delete", { 9567 type: "node", 9568 node: n, 9569 from: i, 9570 to: a, 9571 newFrom: r.mapping.map(i), 9572 newTo: r.mapping.map(a), 9573 deletedRange: t.oldRange, 9574 newRange: t.newRange, 9575 partial: !o, 9576 editor: this.editor, 9577 transaction: e, 9578 combinedTransform: r 9579 }); 9580 }); 9581 }); 9582 let i = r.mapping; 9583 r.steps.forEach((t, n) => { 9584 if (t instanceof bt) { 9585 let a = i.slice(n).map(t.from, -1), o = i.slice(n).map(t.to), s = i.invert().map(a, -1), c = i.invert().map(o), l = a > 0 ? r.doc.nodeAt(a - 1)?.marks.some((e) => e.eq(t.mark)) : !1, u = r.doc.nodeAt(o)?.marks.some((e) => e.eq(t.mark)); 9586 this.editor.emit("delete", { 9587 type: "mark", 9588 mark: t.mark, 9589 from: t.from, 9590 to: t.to, 9591 deletedRange: { 9592 from: s, 9593 to: c 9594 }, 9595 newRange: { 9596 from: a, 9597 to: o 9598 }, 9599 partial: !!(u || l), 9600 editor: this.editor, 9601 transaction: e, 9602 combinedTransform: r 9603 }); 9604 } 9605 }); 9606 }; 9607 this.editor.options.coreExtensionOptions?.delete?.async ?? !0 ? setTimeout(n, 0) : n(); 9608 } 9609}), Sd = V.create({ 9610 name: "drop", 9611 addProseMirrorPlugins() { 9612 return [new D({ 9613 key: new O("tiptapDrop"), 9614 props: { handleDrop: (e, t, n, r) => { 9615 this.editor.emit("drop", { 9616 editor: this.editor, 9617 event: t, 9618 slice: n, 9619 moved: r 9620 }); 9621 } } 9622 })]; 9623 } 9624}), Cd = V.create({ 9625 name: "editable", 9626 addProseMirrorPlugins() { 9627 return [new D({ 9628 key: new O("editable"), 9629 props: { editable: () => this.editor.options.editable } 9630 })]; 9631 } 9632}), wd = new O("focusEvents"), Td = V.create({ 9633 name: "focusEvents", 9634 addProseMirrorPlugins() { 9635 let { editor: e } = this; 9636 return [new D({ 9637 key: wd, 9638 props: { handleDOMEvents: { 9639 focus: (t, n) => { 9640 e.isFocused = !0; 9641 let r = e.state.tr.setMeta("focus", { event: n }).setMeta("addToHistory", !1); 9642 return t.dispatch(r), !1; 9643 }, 9644 blur: (t, n) => { 9645 e.isFocused = !1; 9646 let r = e.state.tr.setMeta("blur", { event: n }).setMeta("addToHistory", !1); 9647 return t.dispatch(r), !1; 9648 } 9649 } } 9650 })]; 9651 } 9652}), Ed = V.create({ 9653 name: "keymap", 9654 addKeyboardShortcuts() { 9655 let e = () => this.editor.commands.first(({ commands: e }) => [ 9656 () => e.undoInputRule(), 9657 () => e.command(({ tr: t }) => { 9658 let { selection: n, doc: r } = t, { empty: i, $anchor: a } = n, { pos: o, parent: s } = a, c = a.parent.isTextblock && o > 0 ? t.doc.resolve(o - 1) : a, l = c.parent.type.spec.isolating, u = a.pos - a.parentOffset, d = l && c.parent.childCount === 1 ? u === a.pos : w.atStart(r).from === o; 9659 return !i || !s.type.isTextblock || s.textContent.length || !d || d && a.parent.type.name === "paragraph" ? !1 : e.clearNodes(); 9660 }), 9661 () => e.deleteSelection(), 9662 () => e.joinBackward(), 9663 () => e.selectNodeBackward() 9664 ]), t = () => this.editor.commands.first(({ commands: e }) => [ 9665 () => e.deleteSelection(), 9666 () => e.deleteCurrentNode(), 9667 () => e.joinForward(), 9668 () => e.selectNodeForward() 9669 ]), n = { 9670 Enter: () => this.editor.commands.first(({ commands: e }) => [ 9671 () => e.newlineInCode(), 9672 () => e.createParagraphNear(), 9673 () => e.liftEmptyBlock(), 9674 () => e.splitBlock() 9675 ]), 9676 "Mod-Enter": () => this.editor.commands.exitCode(), 9677 Backspace: e, 9678 "Mod-Backspace": e, 9679 "Shift-Backspace": e, 9680 Delete: t, 9681 "Mod-Delete": t, 9682 "Mod-a": () => this.editor.commands.selectAll() 9683 }, r = { ...n }, i = { 9684 ...n, 9685 "Ctrl-h": e,
9686 "Alt-Backspace": e, 9687 "Ctrl-d": t, 9688 "Ctrl-Alt-Backspace": t, 9689 "Alt-Delete": t, 9690 "Alt-d": t, 9691 "Ctrl-a": () => this.editor.commands.selectTextblockStart(), 9692 "Ctrl-e": () => this.editor.commands.selectTextblockEnd() 9693 }; 9694 return Rc() || rl() ? i : r; 9695 }, 9696 addProseMirrorPlugins() { 9697 return [new D({ 9698 key: new O("clearDocument"), 9699 appendTransaction: (e, t, n) => { 9700 if (e.some((e) => e.getMeta("composition"))) return; 9701 let r = e.some((e) => e.docChanged) && !t.doc.eq(n.doc), i = e.some((e) => e.getMeta("preventClearDocument")); 9702 if (!r || i) return; 9703 let { empty: a, from: o, to: s } = t.selection, c = w.atStart(t.doc).from, l = w.atEnd(t.doc).to; 9704 if (a || !(o === c && s === l) || !du(n.doc)) return; 9705 let u = n.tr, d = cc({ 9706 state: n, 9707 transaction: u 9708 }), { commands: f } = new lc({ 9709 editor: this.editor, 9710 state: d 9711 }); 9712 if (f.clearNodes(), u.steps.length) return u; 9713 } 9714 })]; 9715 } 9716}), Dd = V.create({ 9717 name: "paste", 9718 addProseMirrorPlugins() { 9719 return [new D({ 9720 key: new O("tiptapPaste"), 9721 props: { handlePaste: (e, t, n) => { 9722 this.editor.emit("paste", { 9723 editor: this.editor, 9724 event: t, 9725 slice: n 9726 }); 9727 } } 9728 })]; 9729 } 9730}), Od = V.create({ 9731 name: "tabindex", 9732 addOptions() { 9733 return { value: void 0 }; 9734 }, 9735 addProseMirrorPlugins() { 9736 return [new D({ 9737 key: new O("tabindex"), 9738 props: { attributes: () => !this.editor.isEditable && this.options.value === void 0 ? {} : { tabindex: this.options.value ?? "0" } } 9739 })]; 9740 } 9741}), kd = V.create({ 9742 name: "textDirection", 9743 addOptions() { 9744 return { direction: void 0 }; 9745 }, 9746 addGlobalAttributes() { 9747 if (!this.options.direction) return []; 9748 let { nodeExtensions: e } = Nl(this.extensions); 9749 return [{ 9750 types: e.filter((e) => e.name !== "text").map((e) => e.name), 9751 attributes: { dir: { 9752 default: this.options.direction, 9753 parseHTML: (e) => { 9754 let t = e.getAttribute("dir"); 9755 return t && (t === "ltr" || t === "rtl" || t === "auto") ? t : this.options.direction; 9756 }, 9757 renderHTML: (e) => e.dir ? { dir: e.dir } : {} 9758 } } 9759 }]; 9760 }, 9761 addProseMirrorPlugins() { 9762 return [new D({ 9763 key: new O("textDirection"), 9764 props: { attributes: () => { 9765 let e = this.options.direction; 9766 return e ? { dir: e } : {}; 9767 } } 9768 })]; 9769 } 9770}), Ad = class e { 9771 constructor(e, t, n = !1, r = null) { 9772 this.currentNode = null, this.actualDepth = null, this.isBlock = n, this.resolvedPos = e, this.editor = t, this.currentNode = r; 9773 } 9774 get name() { 9775 return this.node.type.name; 9776 } 9777 get node() { 9778 return this.currentNode || this.resolvedPos.node(); 9779 } 9780 get element() { 9781 return this.editor.view.domAtPos(this.pos).node; 9782 } 9783 get depth() { 9784 return this.actualDepth ?? this.resolvedPos.depth; 9785 } 9786 get pos() { 9787 return this.resolvedPos.pos; 9788 } 9789 get content() { 9790 return this.node.content; 9791 } 9792 set content(e) { 9793 let t = this.from, n = this.to; 9794 if (this.isBlock) { 9795 if (this.content.size === 0) { 9796 console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`); 9797 return; 9798 } 9799 t = this.from + 1, n = this.to - 1; 9800 } 9801 this.editor.commands.insertContentAt({ 9802 from: t, 9803 to: n 9804 }, e); 9805 } 9806 get attributes() { 9807 return this.node.attrs; 9808 } 9809 get textContent() { 9810 return this.node.textContent; 9811 } 9812 get size() { 9813 return this.node.nodeSize; 9814 } 9815 get from() { 9816 return this.isBlock ? this.pos : this.resolvedPos.start(this.resolvedPos.depth); 9817 } 9818 get range() { 9819 return { 9820 from: this.from, 9821 to: this.to 9822 }; 9823 } 9824 get to() { 9825 return this.isBlock ? this.pos + this.size : this.resolvedPos.end(this.resolvedPos.depth) + +!this.node.isText; 9826 } 9827 get parent() { 9828 if (this.depth === 0) return null; 9829 let t = this.resolvedPos.start(this.resolvedPos.depth - 1); 9830 return new e(this.resolvedPos.doc.resolve(t), this.editor); 9831 } 9832 get before() { 9833 let t = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2)); 9834 return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.from - 3)), new e(t, this.editor); 9835 } 9836 get after() { 9837 let t = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1)); 9838 return t.depth !== this.depth && (t = this.resolvedPos.doc.resolve(this.to + 3)), new e(t, this.editor); 9839 } 9840 get children() { 9841 let t = [];
9842 return this.node.content.forEach((n, r) => { 9843 let i = n.isBlock && !n.isTextblock, a = n.isAtom && !n.isText, o = n.isInline, s = this.pos + r + +!a; 9844 if (s < 0 || s > this.resolvedPos.doc.nodeSize - 2) return; 9845 let c = this.resolvedPos.doc.resolve(s); 9846 if (!i && !o && c.depth <= this.depth) return; 9847 let l = new e(c, this.editor, i, i || o ? n : null); 9848 i && (l.actualDepth = this.depth + 1), t.push(l); 9849 }), t; 9850 } 9851 get firstChild() { 9852 return this.children[0] || null; 9853 } 9854 get lastChild() { 9855 let e = this.children; 9856 return e[e.length - 1] || null; 9857 } 9858 closest(e, t = {}) { 9859 let n = null, r = this.parent; 9860 for (; r && !n;) { 9861 if (r.node.type.name === e) if (Object.keys(t).length > 0) { 9862 let e = r.node.attrs, n = Object.keys(t); 9863 for (let r = 0; r < n.length; r += 1) { 9864 let i = n[r]; 9865 if (e[i] !== t[i]) break; 9866 } 9867 } else n = r; 9868 r = r.parent; 9869 } 9870 return n; 9871 } 9872 querySelector(e, t = {}) { 9873 return this.querySelectorAll(e, t, !0)[0] || null; 9874 } 9875 querySelectorAll(e, t = {}, n = !1) { 9876 let r = []; 9877 if (!this.children || this.children.length === 0) return r; 9878 let i = Object.keys(t); 9879 return this.children.forEach((a) => { 9880 n && r.length > 0 || (a.node.type.name === e && i.every((e) => t[e] === a.node.attrs[e]) && r.push(a), !(n && r.length > 0) && (r = r.concat(a.querySelectorAll(e, t, n)))); 9881 }), r; 9882 } 9883 setAttribute(e) { 9884 let { tr: t } = this.editor.state;
9885 t.setNodeMarkup(this.from, void 0, { 9886 ...this.node.attrs, 9887 ...e 9888 }), this.editor.view.dispatch(t); 9889 } 9890}, jd = ".ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}", Md = class extends Uu { 9891 constructor(e = {}) { 9892 super(), this.css = null, this.className = "tiptap", this.editorView = null, this.isFocused = !1, this.destroyed = !1, this.isInitialized = !1, this.extensionStorage = {}, this.instanceId = Math.random().toString(36).slice(2, 9), this.options = { 9893 element: typeof document < "u" ? document.createElement("div") : null, 9894 content: "", 9895 injectCSS: !0, 9896 injectNonce: void 0, 9897 extensions: [], 9898 autofocus: !1, 9899 editable: !0, 9900 textDirection: void 0, 9901 editorProps: {}, 9902 parseOptions: {}, 9903 coreExtensionOptions: {}, 9904 enableInputRules: !0, 9905 enablePasteRules: !0, 9906 enableCoreExtensions: !0, 9907 enableContentCheck: !1, 9908 emitContentError: !1, 9909 onBeforeCreate: () => null, 9910 onCreate: () => null, 9911 onMount: () => null, 9912 onUnmount: () => null, 9913 onUpdate: () => null, 9914 onSelectionUpdate: () => null, 9915 onTransaction: () => null, 9916 onFocus: () => null, 9917 onBlur: () => null, 9918 onDestroy: () => null, 9919 onContentError: ({ error: e }) => { 9920 throw e; 9921 }, 9922 onPaste: () => null, 9923 onDrop: () => null, 9924 onDelete: () => null, 9925 enableExtensionDispatchTransaction: !0 9926 }, this.isCapturingTransaction = !1, this.capturedTransaction = null, this.utils = { 9927 getUpdatedPosition: mu, 9928 createMappablePosition: hu 9929 }, this.setOptions(e), this.createExtensionManager(), this.createCommandManager(), this.createSchema(), this.on("beforeCreate", this.options.onBeforeCreate), this.emit("beforeCreate", { editor: this }), this.on("mount", this.options.onMount), this.on("unmount", this.options.onUnmount), this.on("contentError", this.options.onContentError), this.on("create", this.options.onCreate), this.on("update", this.options.onUpdate), this.on("selectionUpdate", this.options.onSelectionUpdate), this.on("transaction", this.options.onTransaction), this.on("focus", this.options.onFocus), this.on("blur", this.options.onBlur), this.on("destroy", this.options.onDestroy), this.on("drop", ({ event: e, slice: t, moved: n }) => this.options.onDrop(e, t, n)), this.on("paste", ({ event: e, slice: t }) => this.options.onPaste(e, t)), this.on("delete", this.options.onDelete); 9930 let t = this.createDoc(), n = Ic(t, this.options.autofocus); 9931 this.editorState = Pn.create({ 9932 doc: t, 9933 schema: this.schema, 9934 selection: n || void 0 9935 }), this.options.element && this.mount(this.options.element); 9936 } 9937 mount(e) { 9938 if (typeof document > "u") throw Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");
9939 this.createView(e), this.emit("mount", { editor: this }), this.css && !document.head.contains(this.css) && document.head.appendChild(this.css), window.setTimeout(() => { 9940 this.isDestroyed || (this.options.autofocus !== !1 && this.options.autofocus !== null && this.commands.focus(this.options.autofocus), this.emit("create", { editor: this }), this.isInitialized = !0); 9941 }, 0); 9942 } 9943 unmount() { 9944 if (this.editorView) { 9945 let e = this.editorView.dom; 9946 e?.editor && delete e.editor, this.editorView.destroy(); 9947 } 9948 if (this.editorView = null, this.isInitialized = !1, this.css && !document.querySelectorAll(`.${this.className}`).length) try { 9949 typeof this.css.remove == "function" ? this.css.remove() : this.css.parentNode && this.css.parentNode.removeChild(this.css); 9950 } catch (e) { 9951 console.warn("Failed to remove CSS element:", e); 9952 } 9953 this.css = null, this.emit("unmount", { editor: this }); 9954 } 9955 get storage() { 9956 return this.extensionStorage; 9957 } 9958 get commands() { 9959 return this.commandManager.commands; 9960 } 9961 chain() { 9962 return this.commandManager.chain(); 9963 } 9964 can() { 9965 return this.commandManager.can(); 9966 } 9967 injectCSS() { 9968 this.options.injectCSS && typeof document < "u" && (this.css = Gu(jd, this.options.injectNonce)); 9969 } 9970 setOptions(e = {}) { 9971 this.options = { 9972 ...this.options, 9973 ...e 9974 }, !(!this.editorView || !this.state || this.isDestroyed) && (this.options.editorProps && this.view.setProps(this.options.editorProps), this.view.updateState(this.state)); 9975 } 9976 setEditable(e, t = !0) { 9977 this.setOptions({ editable: e }), t && this.emit("update", { 9978 editor: this, 9979 transaction: this.state.tr, 9980 appendedTransactions: [] 9981 }); 9982 } 9983 get isEditable() { 9984 return this.options.editable && this.view && this.view.editable; 9985 } 9986 get view() { 9987 return this.editorView ? this.editorView : new Proxy({ 9988 state: this.editorState, 9989 updateState: (e) => { 9990 this.editorState = e; 9991 }, 9992 dispatch: (e) => { 9993 this.dispatchTransaction(e); 9994 }, 9995 composing: !1, 9996 dragging: null, 9997 editable: !0, 9998 isDestroyed: !1 9999 }, { get: (e, t) => { 10000 if (this.editorView) return this.editorView[t]; 10001 if (t === "state") return this.editorState; 10002 if (t in e) return Reflect.get(e, t); 10003 throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`); 10004 } }); 10005 } 10006 get state() { 10007 return this.editorView && (this.editorState = this.view.state), this.editorState; 10008 } 10009 registerPlugin(e, t) { 10010 let n = jl(t) ? t(e, [...this.state.plugins]) : [...this.state.plugins, e], r = this.state.reconfigure({ plugins: n }); 10011 return this.view.updateState(r), r; 10012 } 10013 unregisterPlugin(e) { 10014 if (this.isDestroyed) return; 10015 let t = this.state.plugins, n = t; 10016 if ([].concat(e).forEach((e) => { 10017 let t = typeof e == "string" ? `${e}$` : e.key; 10018 n = n.filter((e) => !e.key.startsWith(t)); 10019 }), t.length === n.length) return; 10020 let r = this.state.reconfigure({ plugins: n }); 10021 return this.view.updateState(r), r; 10022 } 10023 createExtensionManager() { 10024 let e = [...this.options.enableCoreExtensions ? [ 10025 Cd, 10026 yd.configure({ blockSeparator: this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator }), 10027 bd, 10028 Td, 10029 Ed, 10030 Od.configure({ value: this.options.coreExtensionOptions?.tabindex?.value }), 10031 Sd, 10032 Dd, 10033 xd, 10034 kd.configure({ direction: this.options.textDirection }) 10035 ].filter((e) => typeof this.options.enableCoreExtensions == "object" ? this.options.enableCoreExtensions[e.name] !== !1 : !0) : [], ...this.options.extensions].filter((e) => [ 10036 "extension", 10037 "node", 10038 "mark" 10039 ].includes(e?.type)); 10040 this.extensionManager = new vd(e, this); 10041 } 10042 createCommandManager() { 10043 this.commandManager = new lc({ editor: this }); 10044 } 10045 createSchema() { 10046 this.schema = this.extensionManager.schema; 10047 } 10048 createDoc() { 10049 let e; 10050 try { 10051 e = xl(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck }); 10052 } catch (t) { 10053 if (!(t instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(t.message)) throw t;
10054 this.emit("contentError", { 10055 editor: this, 10056 error: t, 10057 disableCollaboration: () => { 10058 "collaboration" in this.storage && typeof this.storage.collaboration == "object" && this.storage.collaboration && (this.storage.collaboration.isDisabled = !0), this.options.extensions = this.options.extensions.filter((e) => e.name !== "collaboration"), this.createExtensionManager(); 10059 } 10060 }), e = xl(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: !1 }); 10061 } 10062 return e; 10063 } 10064 createView(e) { 10065 let { editorProps: t, enableExtensionDispatchTransaction: n } = this.options, r = t.dispatchTransaction || this.dispatchTransaction.bind(this), i = n ? this.extensionManager.dispatchTransaction(r) : r, a = t.transformPastedHTML, o = this.extensionManager.transformPastedHTML(a); 10066 this.editorView = new zs(e, { 10067 ...t, 10068 attributes: { 10069 role: "textbox", 10070 ...t?.attributes 10071 }, 10072 dispatchTransaction: i, 10073 transformPastedHTML: o, 10074 state: this.editorState, 10075 markViews: this.extensionManager.markViews, 10076 nodeViews: this.extensionManager.nodeViews 10077 }); 10078 let s = this.state.reconfigure({ plugins: this.extensionManager.plugins }); 10079 this.view.updateState(s), this.prependClass(), this.injectCSS(); 10080 let c = this.view.dom; 10081 c.editor = this; 10082 } 10083 createNodeViews() { 10084 this.view.isDestroyed || this.view.setProps({ 10085 markViews: this.extensionManager.markViews, 10086 nodeViews: this.extensionManager.nodeViews 10087 }); 10088 } 10089 prependClass() { 10090 this.view.dom.className = `${this.className} ${this.view.dom.className}`; 10091 } 10092 captureTransaction(e) { 10093 this.isCapturingTransaction = !0, e(), this.isCapturingTransaction = !1; 10094 let t = this.capturedTransaction; 10095 return this.capturedTransaction = null, t; 10096 } 10097 dispatchTransaction(e) { 10098 if (this.view.isDestroyed) return; 10099 if (this.isCapturingTransaction) { 10100 if (!this.capturedTransaction) { 10101 this.capturedTransaction = e; 10102 return; 10103 } 10104 e.steps.forEach((e) => this.capturedTransaction?.step(e)); 10105 return; 10106 } 10107 let { state: t, transactions: n } = this.state.applyTransaction(e), r = !this.state.selection.eq(t.selection), i = n.includes(e), a = this.state;
10108 if (this.emit("beforeTransaction", { 10109 editor: this, 10110 transaction: e, 10111 nextState: t 10112 }), !i) return; 10113 this.view.updateState(t), this.emit("transaction", { 10114 editor: this, 10115 transaction: e, 10116 appendedTransactions: n.slice(1) 10117 }), r && this.emit("selectionUpdate", { 10118 editor: this, 10119 transaction: e 10120 }); 10121 let o = n.findLast((e) => e.getMeta("focus") || e.getMeta("blur")), s = o?.getMeta("focus"), c = o?.getMeta("blur"); 10122 s && this.emit("focus", { 10123 editor: this, 10124 event: s.event, 10125 transaction: o 10126 }), c && this.emit("blur", { 10127 editor: this, 10128 event: c.event, 10129 transaction: o 10130 }), !(e.getMeta("preventUpdate") || !n.some((e) => e.docChanged) || a.doc.eq(t.doc)) && this.emit("update", { 10131 editor: this, 10132 transaction: e, 10133 appendedTransactions: n.slice(1) 10134 }); 10135 } 10136 getAttributes(e) { 10137 return Xl(this.state, e); 10138 } 10139 isActive(e, t) { 10140 let n = typeof e == "string" ? e : null, r = typeof e == "string" ? t : e; 10141 return ou(this.state, n, r); 10142 } 10143 getJSON() { 10144 return this.state.doc.toJSON(); 10145 } 10146 getHTML() { 10147 return Al(this.state.doc.content, this.schema); 10148 } 10149 getText(e) {
vendor: 76,179 bytes, lines 10150-12578
10150 let { blockSeparator: t = "\n\n", textSerializers: n = {} } = e || {}; 10151 return ql(this.state.doc, { 10152 blockSeparator: t, 10153 textSerializers: { 10154 ...Jl(this.schema), 10155 ...n 10156 } 10157 }); 10158 } 10159 get isEmpty() { 10160 return du(this.state.doc); 10161 } 10162 destroy() { 10163 this.destroyed || (this.destroyed = !0, this.emit("destroy"), this.unmount(), this.removeAllListeners(), this.extensionManager.destroy(), this.extensionManager = null, this.schema = null, this.commandManager = null, this.extensionStorage = {}); 10164 } 10165 get isDestroyed() { 10166 return this.editorView?.isDestroyed ?? !0; 10167 } 10168 $node(e, t) { 10169 return this.$doc?.querySelector(e, t) || null; 10170 } 10171 $nodes(e, t) { 10172 return this.$doc?.querySelectorAll(e, t) || null; 10173 } 10174 $pos(e) { 10175 let t = this.state.doc.resolve(e), n = e > 0 && t.nodeAfter && !t.nodeAfter.isText ? t.nodeAfter : null; 10176 return new Ad(t, this, !1, n); 10177 } 10178 get $doc() { 10179 return this.$pos(0); 10180 } 10181}; 10182function Nd(e) { 10183 return new od({ 10184 find: e.find, 10185 handler: ({ state: t, range: n, match: r }) => { 10186 let i = z(e.getAttributes, void 0, r); 10187 if (i === !1 || i === null) return null; 10188 let { tr: a } = t, o = r[r.length - 1], s = r[0]; 10189 if (o) { 10190 let r = s.search(/\S/), c = n.from + s.indexOf(o), l = c + o.length; 10191 if (eu(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > c).length) return null; 10192 l < n.to && a.delete(l, n.to), c > n.from && a.delete(n.from + r, c); 10193 let u = n.from + r + o.length; 10194 a.addMark(n.from + r, u, e.type.create(i || {})), a.removeStoredMark(e.type); 10195 } 10196 }, 10197 undoable: e.undoable 10198 }); 10199} 10200function Pd(e) { 10201 return new od({ 10202 find: e.find, 10203 handler: ({ state: t, range: n, match: r }) => { 10204 let i = z(e.getAttributes, void 0, r) || {}, { tr: a } = t, o = n.from, s = n.to, c = e.type.create(i); 10205 if (r[1]) { 10206 let e = o + r[0].lastIndexOf(r[1]); 10207 e > s ? e = s : s = e + r[1].length; 10208 let t = r[0][r[0].length - 1]; 10209 a.insertText(t, o + r[0].length - 1), a.replaceWith(e, s, c); 10210 } else if (r[0]) { 10211 let t = e.type.isInline ? o : o - 1; 10212 a.insert(t, e.type.create(i)).delete(a.mapping.map(o), a.mapping.map(s)); 10213 } 10214 a.scrollIntoView(); 10215 }, 10216 undoable: e.undoable 10217 }); 10218} 10219function Fd(e) { 10220 return new od({ 10221 find: e.find, 10222 handler: ({ state: t, range: n, match: r }) => { 10223 let i = t.doc.resolve(n.from), a = z(e.getAttributes, void 0, r) || {}; 10224 if (!i.node(-1).canReplaceWith(i.index(-1), i.indexAfter(-1), e.type)) return null; 10225 t.tr.delete(n.from, n.to).setBlockType(n.from, n.from, e.type, a); 10226 }, 10227 undoable: e.undoable 10228 }); 10229} 10230function Id(e) { 10231 return new od({ 10232 find: e.find, 10233 handler: ({ state: t, range: n, match: r, chain: i }) => { 10234 let a = z(e.getAttributes, void 0, r) || {}, o = t.tr.delete(n.from, n.to), s = o.doc.resolve(n.from).blockRange(), c = s && jt(s, e.type, a); 10235 if (!c) return null; 10236 if (o.wrap(s, c), e.keepMarks && e.editor) { 10237 let { selection: n, storedMarks: r } = t, { splittableMarks: i } = e.editor.extensionManager, a = r || n.$to.parentOffset && n.$from.marks(); 10238 if (a) { 10239 let e = a.filter((e) => i.includes(e.type.name)); 10240 o.ensureMarks(e); 10241 } 10242 } 10243 if (e.keepAttributes) { 10244 let t = e.type.name === "bulletList" || e.type.name === "orderedList" ? "listItem" : "taskList"; 10245 i().updateAttributes(t, a).run(); 10246 } 10247 let l = o.doc.resolve(n.from - 1).nodeBefore; 10248 l && l.type === e.type && Ut(o.doc, n.from - 1) && (!e.joinPredicate || e.joinPredicate(r, l)) && o.join(n.from - 1); 10249 }, 10250 undoable: e.undoable 10251 }); 10252} 10253var H = class e extends ud { 10254 constructor() { 10255 super(...arguments), this.type = "node"; 10256 } 10257 static create(t = {}) { 10258 return new e(typeof t == "function" ? t() : t); 10259 } 10260 configure(e) { 10261 return super.configure(e); 10262 } 10263 extend(e) { 10264 let t = typeof e == "function" ? e() : e; 10265 return super.extend(t); 10266 } 10267}; 10268function Ld(e) { 10269 return new fd({ 10270 find: e.find, 10271 handler: ({ state: t, range: n, match: r, pasteEvent: i }) => { 10272 let a = z(e.getAttributes, void 0, r, i); 10273 if (a === !1 || a === null) return null; 10274 let { tr: o } = t, s = r[r.length - 1], c = r[0], l = n.to; 10275 if (s) { 10276 let i = c.search(/\S/), u = n.from + c.indexOf(s), d = u + s.length; 10277 if (eu(n.from, n.to, t.doc).filter((t) => t.mark.type.excluded.find((n) => n === e.type && n !== t.mark.type)).filter((e) => e.to > u).length) return null; 10278 d < n.to && o.delete(d, n.to), u > n.from && o.delete(n.from + i, u), l = n.from + i + s.length, o.addMark(n.from + i, l, e.type.create(a || {})), r.index !== void 0 && r.input !== void 0 && r.index + r[0].length >= r.input.length || o.removeStoredMark(e.type); 10279 } 10280 } 10281 }); 10282} 10283//#endregion 10284//#region node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js 10285var Rd = (e, t) => { 10286 if (e === "slot") return 0; 10287 if (e instanceof Function) return e(t); 10288 let { children: n, ...r } = t ?? {}; 10289 if (e === "svg") throw Error("SVG elements are not supported in the JSX syntax, use the array syntax instead"); 10290 return [ 10291 e, 10292 r, 10293 n 10294 ]; 10295}; 10296//#endregion 10297//#region node_modules/@tiptap/extension-blockquote/dist/index.js 10298function zd(e, t, n) { 10299 for (let r = 0;; r++) { 10300 if (r == e.childCount || r == t.childCount) return e.childCount == t.childCount ? null : n; 10301 let i = e.child(r), a = t.child(r); 10302 if (i == a) { 10303 n += i.nodeSize; 10304 continue; 10305 } 10306 if (!i.sameMarkup(a)) return n; 10307 if (i.isText && i.text != a.text) { 10308 for (let e = 0; i.text[e] == a.text[e]; e++) n++; 10309 return n; 10310 } 10311 if (i.content.size || a.content.size) { 10312 let e = zd(i.content, a.content, n + 1); 10313 if (e != null) return e; 10314 } 10315 n += i.nodeSize; 10316 } 10317} 10318function Bd(e, t, n, r) { 10319 for (let i = e.childCount, a = t.childCount;;) { 10320 if (i == 0 || a == 0) return i == a ? null : { 10321 a: n, 10322 b: r 10323 }; 10324 let o = e.child(--i), s = t.child(--a), c = o.nodeSize; 10325 if (o == s) { 10326 n -= c, r -= c; 10327 continue; 10328 } 10329 if (!o.sameMarkup(s)) return { 10330 a: n, 10331 b: r 10332 }; 10333 if (o.isText && o.text != s.text) { 10334 let e = 0, t = Math.min(o.text.length, s.text.length); 10335 for (; e < t && o.text[o.text.length - e - 1] == s.text[s.text.length - e - 1];) e++, n--, r--; 10336 return { 10337 a: n, 10338 b: r 10339 }; 10340 } 10341 if (o.content.size || s.content.size) { 10342 let e = Bd(o.content, s.content, n - 1, r - 1); 10343 if (e) return e; 10344 } 10345 n -= c, r -= c; 10346 } 10347} 10348var U = class e { 10349 constructor(e, t) { 10350 if (this.content = e, this.size = t || 0, t == null) for (let t = 0; t < e.length; t++) this.size += e[t].nodeSize; 10351 } 10352 nodesBetween(e, t, n, r = 0, i) { 10353 for (let a = 0, o = 0; o < t; a++) { 10354 let s = this.content[a], c = o + s.nodeSize; 10355 if (c > e && n(s, r + o, i || null, a) !== !1 && s.content.size) { 10356 let i = o + 1; 10357 s.nodesBetween(Math.max(0, e - i), Math.min(s.content.size, t - i), n, r + i); 10358 } 10359 o = c; 10360 } 10361 } 10362 descendants(e) { 10363 this.nodesBetween(0, this.size, e); 10364 } 10365 textBetween(e, t, n, r) { 10366 let i = "", a = !0; 10367 return this.nodesBetween(e, t, (o, s) => { 10368 let c = o.isText ? o.text.slice(Math.max(e, s) - s, t - s) : o.isLeaf ? r ? typeof r == "function" ? r(o) : r : o.type.spec.leafText ? o.type.spec.leafText(o) : "" : ""; 10369 o.isBlock && (o.isLeaf && c || o.isTextblock) && n && (a ? a = !1 : i += n), i += c; 10370 }, 0), i; 10371 } 10372 append(t) { 10373 if (!t.size) return this; 10374 if (!this.size) return t; 10375 let n = this.lastChild, r = t.firstChild, i = this.content.slice(), a = 0; 10376 for (n.isText && n.sameMarkup(r) && (i[i.length - 1] = n.withText(n.text + r.text), a = 1); a < t.content.length; a++) i.push(t.content[a]); 10377 return new e(i, this.size + t.size); 10378 } 10379 cut(t, n = this.size) { 10380 if (t == 0 && n == this.size) return this; 10381 let r = [], i = 0; 10382 if (n > t) for (let e = 0, a = 0; a < n; e++) { 10383 let o = this.content[e], s = a + o.nodeSize; 10384 s > t && ((a < t || s > n) && (o = o.isText ? o.cut(Math.max(0, t - a), Math.min(o.text.length, n - a)) : o.cut(Math.max(0, t - a - 1), Math.min(o.content.size, n - a - 1))), r.push(o), i += o.nodeSize), a = s; 10385 } 10386 return new e(r, i); 10387 } 10388 cutByIndex(t, n) { 10389 return t == n ? e.empty : t == 0 && n == this.content.length ? this : new e(this.content.slice(t, n)); 10390 } 10391 replaceChild(t, n) { 10392 let r = this.content[t]; 10393 if (r == n) return this; 10394 let i = this.content.slice(), a = this.size + n.nodeSize - r.nodeSize; 10395 return i[t] = n, new e(i, a); 10396 } 10397 addToStart(t) { 10398 return new e([t].concat(this.content), this.size + t.nodeSize); 10399 } 10400 addToEnd(t) { 10401 return new e(this.content.concat(t), this.size + t.nodeSize); 10402 } 10403 eq(e) { 10404 if (this.content.length != e.content.length) return !1; 10405 for (let t = 0; t < this.content.length; t++) if (!this.content[t].eq(e.content[t])) return !1; 10406 return !0; 10407 } 10408 get firstChild() { 10409 return this.content.length ? this.content[0] : null; 10410 } 10411 get lastChild() { 10412 return this.content.length ? this.content[this.content.length - 1] : null; 10413 } 10414 get childCount() { 10415 return this.content.length; 10416 } 10417 child(e) { 10418 let t = this.content[e]; 10419 if (!t) throw RangeError("Index " + e + " out of range for " + this); 10420 return t; 10421 } 10422 maybeChild(e) { 10423 return this.content[e] || null; 10424 } 10425 forEach(e) { 10426 for (let t = 0, n = 0; t < this.content.length; t++) { 10427 let r = this.content[t]; 10428 e(r, n, t), n += r.nodeSize; 10429 } 10430 } 10431 findDiffStart(e, t = 0) { 10432 return zd(this, e, t); 10433 } 10434 findDiffEnd(e, t = this.size, n = e.size) { 10435 return Bd(this, e, t, n); 10436 } 10437 findIndex(e) { 10438 if (e == 0) return Hd(0, e); 10439 if (e == this.size) return Hd(this.content.length, e); 10440 if (e > this.size || e < 0) throw RangeError(`Position ${e} outside of fragment (${this})`); 10441 for (let t = 0, n = 0;; t++) { 10442 let r = this.child(t), i = n + r.nodeSize; 10443 if (i >= e) return i == e ? Hd(t + 1, i) : Hd(t, n); 10444 n = i; 10445 } 10446 } 10447 toString() { 10448 return "<" + this.toStringInner() + ">"; 10449 } 10450 toStringInner() { 10451 return this.content.join(", "); 10452 } 10453 toJSON() { 10454 return this.content.length ? this.content.map((e) => e.toJSON()) : null; 10455 } 10456 static fromJSON(t, n) { 10457 if (!n) return e.empty; 10458 if (!Array.isArray(n)) throw RangeError("Invalid input for Fragment.fromJSON"); 10459 return e.fromArray(n.map(t.nodeFromJSON)); 10460 } 10461 static fromArray(t) { 10462 if (!t.length) return e.empty; 10463 let n, r = 0; 10464 for (let e = 0; e < t.length; e++) { 10465 let i = t[e]; 10466 r += i.nodeSize, e && i.isText && t[e - 1].sameMarkup(i) ? (n ||= t.slice(0, e), n[n.length - 1] = i.withText(n[n.length - 1].text + i.text)) : n && n.push(i); 10467 } 10468 return new e(n || t, r); 10469 } 10470 static from(t) { 10471 if (!t) return e.empty; 10472 if (t instanceof e) return t; 10473 if (Array.isArray(t)) return this.fromArray(t); 10474 if (t.attrs) return new e([t], t.nodeSize); 10475 throw RangeError("Can not convert " + t + " to a Fragment" + (t.nodesBetween ? " (looks like multiple versions of prosemirror-model were loaded)" : "")); 10476 } 10477}; 10478U.empty = new U([], 0); 10479var Vd = { 10480 index: 0, 10481 offset: 0 10482}; 10483function Hd(e, t) { 10484 return Vd.index = e, Vd.offset = t, Vd; 10485} 10486function Ud(e, t) { 10487 if (e === t) return !0; 10488 if (!(e && typeof e == "object") || !(t && typeof t == "object")) return !1; 10489 let n = Array.isArray(e); 10490 if (Array.isArray(t) != n) return !1; 10491 if (n) { 10492 if (e.length != t.length) return !1; 10493 for (let n = 0; n < e.length; n++) if (!Ud(e[n], t[n])) return !1; 10494 } else { 10495 for (let n in e) if (!(n in t) || !Ud(e[n], t[n])) return !1; 10496 for (let n in t) if (!(n in e)) return !1; 10497 } 10498 return !0; 10499} 10500var Wd = class e { 10501 constructor(e, t) { 10502 this.type = e, this.attrs = t; 10503 } 10504 addToSet(e) { 10505 let t, n = !1; 10506 for (let r = 0; r < e.length; r++) { 10507 let i = e[r]; 10508 if (this.eq(i)) return e; 10509 if (this.type.excludes(i.type)) t ||= e.slice(0, r); 10510 else if (i.type.excludes(this.type)) return e; 10511 else !n && i.type.rank > this.type.rank && (t ||= e.slice(0, r), t.push(this), n = !0), t && t.push(i); 10512 } 10513 return t ||= e.slice(), n || t.push(this), t; 10514 } 10515 removeFromSet(e) { 10516 for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return e.slice(0, t).concat(e.slice(t + 1)); 10517 return e; 10518 } 10519 isInSet(e) { 10520 for (let t = 0; t < e.length; t++) if (this.eq(e[t])) return !0; 10521 return !1; 10522 } 10523 eq(e) { 10524 return this == e || this.type == e.type && Ud(this.attrs, e.attrs); 10525 } 10526 toJSON() { 10527 let e = { type: this.type.name }; 10528 for (let t in this.attrs) { 10529 e.attrs = this.attrs; 10530 break; 10531 } 10532 return e; 10533 } 10534 static fromJSON(e, t) { 10535 if (!t) throw RangeError("Invalid input for Mark.fromJSON"); 10536 let n = e.marks[t.type]; 10537 if (!n) throw RangeError(`There is no mark type ${t.type} in this schema`); 10538 let r = n.create(t.attrs); 10539 return n.checkAttrs(r.attrs), r; 10540 } 10541 static sameSet(e, t) { 10542 if (e == t) return !0; 10543 if (e.length != t.length) return !1; 10544 for (let n = 0; n < e.length; n++) if (!e[n].eq(t[n])) return !1; 10545 return !0; 10546 } 10547 static setFrom(t) { 10548 if (!t || Array.isArray(t) && t.length == 0) return e.none; 10549 if (t instanceof e) return [t]; 10550 let n = t.slice(); 10551 return n.sort((e, t) => e.type.rank - t.type.rank), n; 10552 } 10553}; 10554Wd.none = []; 10555var Gd = class extends Error {}, W = class e { 10556 constructor(e, t, n) { 10557 this.content = e, this.openStart = t, this.openEnd = n; 10558 } 10559 get size() { 10560 return this.content.size - this.openStart - this.openEnd; 10561 } 10562 insertAt(t, n) { 10563 let r = qd(this.content, t + this.openStart, n, this.openStart + 1, this.openEnd + 1); 10564 return r && new e(r, this.openStart, this.openEnd); 10565 } 10566 removeBetween(t, n) { 10567 return new e(Kd(this.content, t + this.openStart, n + this.openStart), this.openStart, this.openEnd); 10568 } 10569 eq(e) { 10570 return this.content.eq(e.content) && this.openStart == e.openStart && this.openEnd == e.openEnd; 10571 } 10572 toString() { 10573 return this.content + "(" + this.openStart + "," + this.openEnd + ")"; 10574 } 10575 toJSON() { 10576 if (!this.content.size) return null; 10577 let e = { content: this.content.toJSON() }; 10578 return this.openStart > 0 && (e.openStart = this.openStart), this.openEnd > 0 && (e.openEnd = this.openEnd), e; 10579 } 10580 static fromJSON(t, n) { 10581 if (!n) return e.empty; 10582 let r = n.openStart || 0, i = n.openEnd || 0; 10583 if (typeof r != "number" || typeof i != "number") throw RangeError("Invalid input for Slice.fromJSON"); 10584 return new e(U.fromJSON(t, n.content), r, i); 10585 } 10586 static maxOpen(t, n = !0) { 10587 let r = 0, i = 0; 10588 for (let e = t.firstChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.firstChild) r++; 10589 for (let e = t.lastChild; e && !e.isLeaf && (n || !e.type.spec.isolating); e = e.lastChild) i++; 10590 return new e(t, r, i); 10591 } 10592}; 10593W.empty = new W(U.empty, 0, 0); 10594function Kd(e, t, n) { 10595 let { index: r, offset: i } = e.findIndex(t), a = e.maybeChild(r), { index: o, offset: s } = e.findIndex(n); 10596 if (i == t || a.isText) { 10597 if (s != n && !e.child(o).isText) throw RangeError("Removing non-flat range"); 10598 return e.cut(0, t).append(e.cut(n)); 10599 } 10600 if (r != o) throw RangeError("Removing non-flat range"); 10601 return e.replaceChild(r, a.copy(Kd(a.content, t - i - 1, n - i - 1))); 10602} 10603function qd(e, t, n, r, i, a) { 10604 let { index: o, offset: s } = e.findIndex(t), c = e.maybeChild(o); 10605 if (s == t || c.isText) return a && r <= 0 && i <= 0 && !a.canReplace(o, o, n) ? null : e.cut(0, t).append(n).append(e.cut(t)); 10606 let l = qd(c.content, t - s - 1, n, o == 0 ? r - 1 : 0, o == e.childCount - 1 ? i - 1 : 0, c); 10607 return l && e.replaceChild(o, c.copy(l)); 10608} 10609function Jd(e, t, n) { 10610 if (n.openStart > e.depth) throw new Gd("Inserted content deeper than insertion position"); 10611 if (e.depth - n.openStart != t.depth - n.openEnd) throw new Gd("Inconsistent open depths"); 10612 return Yd(e, t, n, 0); 10613} 10614function Yd(e, t, n, r) { 10615 let i = e.index(r), a = e.node(r); 10616 if (i == t.index(r) && r < e.depth - n.openStart) { 10617 let o = Yd(e, t, n, r + 1); 10618 return a.copy(a.content.replaceChild(i, o)); 10619 } else if (!n.content.size) return ef(a, nf(e, t, r)); 10620 else if (!n.openStart && !n.openEnd && e.depth == r && t.depth == r) { 10621 let r = e.parent, i = r.content; 10622 return ef(r, i.cut(0, e.parentOffset).append(n.content).append(i.cut(t.parentOffset))); 10623 } else { 10624 let { start: i, end: o } = rf(n, e); 10625 return ef(a, tf(e, i, o, t, r)); 10626 } 10627} 10628function Xd(e, t) { 10629 if (!t.type.compatibleContent(e.type)) throw new Gd("Cannot join " + t.type.name + " onto " + e.type.name); 10630} 10631function Zd(e, t, n) { 10632 let r = e.node(n); 10633 return Xd(r, t.node(n)), r; 10634} 10635function Qd(e, t) { 10636 let n = t.length - 1; 10637 n >= 0 && e.isText && e.sameMarkup(t[n]) ? t[n] = e.withText(t[n].text + e.text) : t.push(e); 10638} 10639function $d(e, t, n, r) { 10640 let i = (t || e).node(n), a = 0, o = t ? t.index(n) : i.childCount; 10641 e && (a = e.index(n), e.depth > n ? a++ : e.textOffset && (Qd(e.nodeAfter, r), a++)); 10642 for (let e = a; e < o; e++) Qd(i.child(e), r); 10643 t && t.depth == n && t.textOffset && Qd(t.nodeBefore, r); 10644} 10645function ef(e, t) { 10646 return e.type.checkContent(t), e.copy(t); 10647} 10648function tf(e, t, n, r, i) { 10649 let a = e.depth > i && Zd(e, t, i + 1), o = r.depth > i && Zd(n, r, i + 1), s = []; 10650 return $d(null, e, i, s), a && o && t.index(i) == n.index(i) ? (Xd(a, o), Qd(ef(a, tf(e, t, n, r, i + 1)), s)) : (a && Qd(ef(a, nf(e, t, i + 1)), s), $d(t, n, i, s), o && Qd(ef(o, nf(n, r, i + 1)), s)), $d(r, null, i, s), new U(s); 10651} 10652function nf(e, t, n) { 10653 let r = []; 10654 return $d(null, e, n, r), e.depth > n && Qd(ef(Zd(e, t, n + 1), nf(e, t, n + 1)), r), $d(t, null, n, r), new U(r); 10655} 10656function rf(e, t) { 10657 let n = t.depth - e.openStart, r = t.node(n).copy(e.content); 10658 for (let e = n - 1; e >= 0; e--) r = t.node(e).copy(U.from(r)); 10659 return { 10660 start: r.resolveNoCache(e.openStart + n), 10661 end: r.resolveNoCache(r.content.size - e.openEnd - n) 10662 }; 10663} 10664var af = class e { 10665 constructor(e, t, n) { 10666 this.pos = e, this.path = t, this.parentOffset = n, this.depth = t.length / 3 - 1; 10667 } 10668 resolveDepth(e) { 10669 return e == null ? this.depth : e < 0 ? this.depth + e : e; 10670 } 10671 get parent() { 10672 return this.node(this.depth); 10673 } 10674 get doc() { 10675 return this.node(0); 10676 } 10677 node(e) { 10678 return this.path[this.resolveDepth(e) * 3]; 10679 } 10680 index(e) { 10681 return this.path[this.resolveDepth(e) * 3 + 1]; 10682 } 10683 indexAfter(e) { 10684 return e = this.resolveDepth(e), this.index(e) + (e == this.depth && !this.textOffset ? 0 : 1); 10685 } 10686 start(e) { 10687 return e = this.resolveDepth(e), e == 0 ? 0 : this.path[e * 3 - 1] + 1; 10688 } 10689 end(e) { 10690 return e = this.resolveDepth(e), this.start(e) + this.node(e).content.size; 10691 } 10692 before(e) { 10693 if (e = this.resolveDepth(e), !e) throw RangeError("There is no position before the top-level node"); 10694 return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1]; 10695 } 10696 after(e) { 10697 if (e = this.resolveDepth(e), !e) throw RangeError("There is no position after the top-level node"); 10698 return e == this.depth + 1 ? this.pos : this.path[e * 3 - 1] + this.path[e * 3].nodeSize; 10699 } 10700 get textOffset() { 10701 return this.pos - this.path[this.path.length - 1]; 10702 } 10703 get nodeAfter() { 10704 let e = this.parent, t = this.index(this.depth); 10705 if (t == e.childCount) return null; 10706 let n = this.pos - this.path[this.path.length - 1], r = e.child(t); 10707 return n ? e.child(t).cut(n) : r; 10708 } 10709 get nodeBefore() { 10710 let e = this.index(this.depth), t = this.pos - this.path[this.path.length - 1]; 10711 return t ? this.parent.child(e).cut(0, t) : e == 0 ? null : this.parent.child(e - 1); 10712 } 10713 posAtIndex(e, t) { 10714 t = this.resolveDepth(t); 10715 let n = this.path[t * 3], r = t == 0 ? 0 : this.path[t * 3 - 1] + 1; 10716 for (let t = 0; t < e; t++) r += n.child(t).nodeSize; 10717 return r; 10718 } 10719 marks() { 10720 let e = this.parent, t = this.index(); 10721 if (e.content.size == 0) return Wd.none; 10722 if (this.textOffset) return e.child(t).marks; 10723 let n = e.maybeChild(t - 1), r = e.maybeChild(t); 10724 if (!n) { 10725 let e = n; 10726 n = r, r = e; 10727 } 10728 let i = n.marks; 10729 for (var a = 0; a < i.length; a++) i[a].type.spec.inclusive === !1 && (!r || !i[a].isInSet(r.marks)) && (i = i[a--].removeFromSet(i)); 10730 return i; 10731 } 10732 marksAcross(e) { 10733 let t = this.parent.maybeChild(this.index()); 10734 if (!t || !t.isInline) return null; 10735 let n = t.marks, r = e.parent.maybeChild(e.index()); 10736 for (var i = 0; i < n.length; i++) n[i].type.spec.inclusive === !1 && (!r || !n[i].isInSet(r.marks)) && (n = n[i--].removeFromSet(n)); 10737 return n; 10738 } 10739 sharedDepth(e) { 10740 for (let t = this.depth; t > 0; t--) if (this.start(t) <= e && this.end(t) >= e) return t; 10741 return 0; 10742 } 10743 blockRange(e = this, t) { 10744 if (e.pos < this.pos) return e.blockRange(this); 10745 for (let n = this.depth - (this.parent.inlineContent || this.pos == e.pos ? 1 : 0); n >= 0; n--) if (e.pos <= this.end(n) && (!t || t(this.node(n)))) return new lf(this, e, n); 10746 return null; 10747 } 10748 sameParent(e) { 10749 return this.pos - this.parentOffset == e.pos - e.parentOffset; 10750 } 10751 max(e) { 10752 return e.pos > this.pos ? e : this; 10753 } 10754 min(e) { 10755 return e.pos < this.pos ? e : this; 10756 } 10757 toString() { 10758 let e = ""; 10759 for (let t = 1; t <= this.depth; t++) e += (e ? "/" : "") + this.node(t).type.name + "_" + this.index(t - 1); 10760 return e + ":" + this.parentOffset; 10761 } 10762 static resolve(t, n) { 10763 if (!(n >= 0 && n <= t.content.size)) throw RangeError("Position " + n + " out of range"); 10764 let r = [], i = 0, a = n; 10765 for (let e = t;;) { 10766 let { index: t, offset: n } = e.content.findIndex(a), o = a - n; 10767 if (r.push(e, t, i + n), !o || (e = e.child(t), e.isText)) break; 10768 a = o - 1, i += n + 1; 10769 } 10770 return new e(n, r, a); 10771 } 10772 static resolveCached(t, n) { 10773 let r = cf.get(t); 10774 if (r) for (let e = 0; e < r.elts.length; e++) { 10775 let t = r.elts[e]; 10776 if (t.pos == n) return t; 10777 } 10778 else cf.set(t, r = new of()); 10779 let i = r.elts[r.i] = e.resolve(t, n); 10780 return r.i = (r.i + 1) % sf, i; 10781 } 10782}, of = class { 10783 constructor() { 10784 this.elts = [], this.i = 0; 10785 } 10786}, sf = 12, cf = /* @__PURE__ */ new WeakMap(), lf = class { 10787 constructor(e, t, n) { 10788 this.$from = e, this.$to = t, this.depth = n; 10789 } 10790 get start() { 10791 return this.$from.before(this.depth + 1); 10792 } 10793 get end() { 10794 return this.$to.after(this.depth + 1); 10795 } 10796 get parent() { 10797 return this.$from.node(this.depth); 10798 } 10799 get startIndex() { 10800 return this.$from.index(this.depth); 10801 } 10802 get endIndex() { 10803 return this.$to.indexAfter(this.depth); 10804 } 10805}, uf = /* @__PURE__ */ Object.create(null), df = class e { 10806 constructor(e, t, n, r = Wd.none) { 10807 this.type = e, this.attrs = t, this.marks = r, this.content = n || U.empty; 10808 } 10809 get children() { 10810 return this.content.content; 10811 } 10812 get nodeSize() { 10813 return this.isLeaf ? 1 : 2 + this.content.size; 10814 } 10815 get childCount() { 10816 return this.content.childCount; 10817 } 10818 child(e) { 10819 return this.content.child(e); 10820 } 10821 maybeChild(e) { 10822 return this.content.maybeChild(e); 10823 } 10824 forEach(e) { 10825 this.content.forEach(e); 10826 } 10827 nodesBetween(e, t, n, r = 0) { 10828 this.content.nodesBetween(e, t, n, r, this); 10829 } 10830 descendants(e) { 10831 this.nodesBetween(0, this.content.size, e); 10832 } 10833 get textContent() { 10834 return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, ""); 10835 } 10836 textBetween(e, t, n, r) { 10837 return this.content.textBetween(e, t, n, r); 10838 } 10839 get firstChild() { 10840 return this.content.firstChild; 10841 } 10842 get lastChild() { 10843 return this.content.lastChild; 10844 } 10845 eq(e) { 10846 return this == e || this.sameMarkup(e) && this.content.eq(e.content); 10847 } 10848 sameMarkup(e) { 10849 return this.hasMarkup(e.type, e.attrs, e.marks); 10850 } 10851 hasMarkup(e, t, n) { 10852 return this.type == e && Ud(this.attrs, t || e.defaultAttrs || uf) && Wd.sameSet(this.marks, n || Wd.none); 10853 } 10854 copy(t = null) { 10855 return t == this.content ? this : new e(this.type, this.attrs, t, this.marks); 10856 } 10857 mark(t) { 10858 return t == this.marks ? this : new e(this.type, this.attrs, this.content, t); 10859 } 10860 cut(e, t = this.content.size) { 10861 return e == 0 && t == this.content.size ? this : this.copy(this.content.cut(e, t)); 10862 } 10863 slice(e, t = this.content.size, n = !1) { 10864 if (e == t) return W.empty; 10865 let r = this.resolve(e), i = this.resolve(t), a = n ? 0 : r.sharedDepth(t), o = r.start(a); 10866 return new W(r.node(a).content.cut(r.pos - o, i.pos - o), r.depth - a, i.depth - a); 10867 } 10868 replace(e, t, n) { 10869 return Jd(this.resolve(e), this.resolve(t), n); 10870 } 10871 nodeAt(e) { 10872 for (let t = this;;) { 10873 let { index: n, offset: r } = t.content.findIndex(e); 10874 if (t = t.maybeChild(n), !t) return null; 10875 if (r == e || t.isText) return t; 10876 e -= r + 1; 10877 } 10878 } 10879 childAfter(e) { 10880 let { index: t, offset: n } = this.content.findIndex(e); 10881 return { 10882 node: this.content.maybeChild(t), 10883 index: t, 10884 offset: n 10885 }; 10886 } 10887 childBefore(e) { 10888 if (e == 0) return { 10889 node: null, 10890 index: 0, 10891 offset: 0 10892 }; 10893 let { index: t, offset: n } = this.content.findIndex(e); 10894 if (n < e) return { 10895 node: this.content.child(t), 10896 index: t, 10897 offset: n 10898 }; 10899 let r = this.content.child(t - 1); 10900 return { 10901 node: r, 10902 index: t - 1, 10903 offset: n - r.nodeSize 10904 }; 10905 } 10906 resolve(e) { 10907 return af.resolveCached(this, e); 10908 } 10909 resolveNoCache(e) { 10910 return af.resolve(this, e); 10911 } 10912 rangeHasMark(e, t, n) { 10913 let r = !1; 10914 return t > e && this.nodesBetween(e, t, (e) => (n.isInSet(e.marks) && (r = !0), !r)), r; 10915 } 10916 get isBlock() { 10917 return this.type.isBlock; 10918 } 10919 get isTextblock() { 10920 return this.type.isTextblock; 10921 } 10922 get inlineContent() { 10923 return this.type.inlineContent; 10924 } 10925 get isInline() { 10926 return this.type.isInline; 10927 } 10928 get isText() { 10929 return this.type.isText; 10930 } 10931 get isLeaf() { 10932 return this.type.isLeaf; 10933 } 10934 get isAtom() { 10935 return this.type.isAtom; 10936 } 10937 toString() { 10938 if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this); 10939 let e = this.type.name; 10940 return this.content.size && (e += "(" + this.content.toStringInner() + ")"), ff(this.marks, e); 10941 } 10942 contentMatchAt(e) { 10943 let t = this.type.contentMatch.matchFragment(this.content, 0, e); 10944 if (!t) throw Error("Called contentMatchAt on a node with invalid content"); 10945 return t; 10946 } 10947 canReplace(e, t, n = U.empty, r = 0, i = n.childCount) { 10948 let a = this.contentMatchAt(e).matchFragment(n, r, i), o = a && a.matchFragment(this.content, t); 10949 if (!o || !o.validEnd) return !1; 10950 for (let e = r; e < i; e++) if (!this.type.allowsMarks(n.child(e).marks)) return !1; 10951 return !0; 10952 } 10953 canReplaceWith(e, t, n, r) { 10954 if (r && !this.type.allowsMarks(r)) return !1; 10955 let i = this.contentMatchAt(e).matchType(n), a = i && i.matchFragment(this.content, t); 10956 return a ? a.validEnd : !1; 10957 } 10958 canAppend(e) { 10959 return e.content.size ? this.canReplace(this.childCount, this.childCount, e.content) : this.type.compatibleContent(e.type); 10960 } 10961 check() { 10962 this.type.checkContent(this.content), this.type.checkAttrs(this.attrs); 10963 let e = Wd.none; 10964 for (let t = 0; t < this.marks.length; t++) { 10965 let n = this.marks[t]; 10966 n.type.checkAttrs(n.attrs), e = n.addToSet(e); 10967 } 10968 if (!Wd.sameSet(e, this.marks)) throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e) => e.type.name)}`); 10969 this.content.forEach((e) => e.check()); 10970 } 10971 toJSON() { 10972 let e = { type: this.type.name }; 10973 for (let t in this.attrs) { 10974 e.attrs = this.attrs; 10975 break; 10976 } 10977 return this.content.size && (e.content = this.content.toJSON()), this.marks.length && (e.marks = this.marks.map((e) => e.toJSON())), e; 10978 } 10979 static fromJSON(e, t) { 10980 if (!t) throw RangeError("Invalid input for Node.fromJSON"); 10981 let n; 10982 if (t.marks) { 10983 if (!Array.isArray(t.marks)) throw RangeError("Invalid mark data for Node.fromJSON"); 10984 n = t.marks.map(e.markFromJSON); 10985 } 10986 if (t.type == "text") { 10987 if (typeof t.text != "string") throw RangeError("Invalid text node in JSON"); 10988 return e.text(t.text, n); 10989 } 10990 let r = U.fromJSON(e, t.content), i = e.nodeType(t.type).create(t.attrs, r, n); 10991 return i.type.checkAttrs(i.attrs), i; 10992 } 10993}; 10994df.prototype.text = void 0; 10995function ff(e, t) { 10996 for (let n = e.length - 1; n >= 0; n--) t = e[n].type.name + "(" + t + ")"; 10997 return t; 10998} 10999var pf = class e { 11000 constructor(e) { 11001 this.validEnd = e, this.next = [], this.wrapCache = []; 11002 } 11003 static parse(t, n) { 11004 let r = new mf(t, n); 11005 if (r.next == null) return e.empty; 11006 let i = hf(r); 11007 r.next && r.err("Unexpected trailing text"); 11008 let a = Tf(Sf(i)); 11009 return Ef(a, r), a; 11010 } 11011 matchType(e) { 11012 for (let t = 0; t < this.next.length; t++) if (this.next[t].type == e) return this.next[t].next; 11013 return null; 11014 } 11015 matchFragment(e, t = 0, n = e.childCount) { 11016 let r = this; 11017 for (let i = t; r && i < n; i++) r = r.matchType(e.child(i).type); 11018 return r; 11019 } 11020 get inlineContent() { 11021 return this.next.length != 0 && this.next[0].type.isInline; 11022 } 11023 get defaultType() { 11024 for (let e = 0; e < this.next.length; e++) { 11025 let { type: t } = this.next[e]; 11026 if (!(t.isText || t.hasRequiredAttrs())) return t; 11027 } 11028 return null; 11029 } 11030 compatible(e) { 11031 for (let t = 0; t < this.next.length; t++) for (let n = 0; n < e.next.length; n++) if (this.next[t].type == e.next[n].type) return !0; 11032 return !1; 11033 } 11034 fillBefore(e, t = !1, n = 0) { 11035 let r = [this]; 11036 function i(a, o) { 11037 let s = a.matchFragment(e, n); 11038 if (s && (!t || s.validEnd)) return U.from(o.map((e) => e.createAndFill())); 11039 for (let e = 0; e < a.next.length; e++) { 11040 let { type: t, next: n } = a.next[e]; 11041 if (!(t.isText || t.hasRequiredAttrs()) && r.indexOf(n) == -1) { 11042 r.push(n); 11043 let e = i(n, o.concat(t)); 11044 if (e) return e; 11045 } 11046 } 11047 return null; 11048 } 11049 return i(this, []); 11050 } 11051 findWrapping(e) { 11052 for (let t = 0; t < this.wrapCache.length; t += 2) if (this.wrapCache[t] == e) return this.wrapCache[t + 1]; 11053 let t = this.computeWrapping(e); 11054 return this.wrapCache.push(e, t), t; 11055 } 11056 computeWrapping(e) { 11057 let t = /* @__PURE__ */ Object.create(null), n = [{ 11058 match: this, 11059 type: null, 11060 via: null 11061 }]; 11062 for (; n.length;) { 11063 let r = n.shift(), i = r.match; 11064 if (i.matchType(e)) { 11065 let e = []; 11066 for (let t = r; t.type; t = t.via) e.push(t.type); 11067 return e.reverse(); 11068 } 11069 for (let e = 0; e < i.next.length; e++) { 11070 let { type: a, next: o } = i.next[e]; 11071 !a.isLeaf && !a.hasRequiredAttrs() && !(a.name in t) && (!r.type || o.validEnd) && (n.push({ 11072 match: a.contentMatch, 11073 type: a, 11074 via: r 11075 }), t[a.name] = !0); 11076 } 11077 } 11078 return null; 11079 } 11080 get edgeCount() { 11081 return this.next.length; 11082 } 11083 edge(e) { 11084 if (e >= this.next.length) throw RangeError(`There's no ${e}th edge in this content match`); 11085 return this.next[e]; 11086 } 11087 toString() { 11088 let e = []; 11089 function t(n) { 11090 e.push(n); 11091 for (let r = 0; r < n.next.length; r++) e.indexOf(n.next[r].next) == -1 && t(n.next[r].next); 11092 } 11093 return t(this), e.map((t, n) => { 11094 let r = n + (t.validEnd ? "*" : " ") + " "; 11095 for (let n = 0; n < t.next.length; n++) r += (n ? ", " : "") + t.next[n].type.name + "->" + e.indexOf(t.next[n].next); 11096 return r; 11097 }).join("\n"); 11098 } 11099}; 11100pf.empty = new pf(!0); 11101var mf = class { 11102 constructor(e, t) { 11103 this.string = e, this.nodeTypes = t, this.inline = null, this.pos = 0, this.tokens = e.split(/\s*(?=\b|\W|$)/), this.tokens[this.tokens.length - 1] == "" && this.tokens.pop(), this.tokens[0] == "" && this.tokens.shift(); 11104 } 11105 get next() { 11106 return this.tokens[this.pos]; 11107 } 11108 eat(e) { 11109 return this.next == e && (this.pos++ || !0); 11110 } 11111 err(e) { 11112 throw SyntaxError(e + " (in content expression '" + this.string + "')"); 11113 } 11114}; 11115function hf(e) { 11116 let t = []; 11117 do 11118 t.push(gf(e)); 11119 while (e.eat("|")); 11120 return t.length == 1 ? t[0] : { 11121 type: "choice", 11122 exprs: t 11123 }; 11124} 11125function gf(e) { 11126 let t = []; 11127 do 11128 t.push(_f(e)); 11129 while (e.next && e.next != ")" && e.next != "|"); 11130 return t.length == 1 ? t[0] : { 11131 type: "seq", 11132 exprs: t 11133 }; 11134} 11135function _f(e) { 11136 let t = xf(e); 11137 for (;;) if (e.eat("+")) t = { 11138 type: "plus", 11139 expr: t 11140 }; 11141 else if (e.eat("*")) t = { 11142 type: "star", 11143 expr: t 11144 }; 11145 else if (e.eat("?")) t = { 11146 type: "opt", 11147 expr: t 11148 }; 11149 else if (e.eat("{")) t = yf(e, t); 11150 else break; 11151 return t; 11152} 11153function vf(e) { 11154 /\D/.test(e.next) && e.err("Expected number, got '" + e.next + "'"); 11155 let t = Number(e.next); 11156 return e.pos++, t; 11157} 11158function yf(e, t) { 11159 let n = vf(e), r = n; 11160 return e.eat(",") && (r = e.next == "}" ? -1 : vf(e)), e.eat("}") || e.err("Unclosed braced range"), { 11161 type: "range", 11162 min: n, 11163 max: r, 11164 expr: t 11165 }; 11166} 11167function bf(e, t) { 11168 let n = e.nodeTypes, r = n[t]; 11169 if (r) return [r]; 11170 let i = []; 11171 for (let e in n) { 11172 let r = n[e]; 11173 r.isInGroup(t) && i.push(r); 11174 } 11175 return i.length == 0 && e.err("No node type or group '" + t + "' found"), i; 11176} 11177function xf(e) { 11178 if (e.eat("(")) { 11179 let t = hf(e); 11180 return e.eat(")") || e.err("Missing closing paren"), t; 11181 } else if (/\W/.test(e.next)) e.err("Unexpected token '" + e.next + "'"); 11182 else { 11183 let t = bf(e, e.next).map((t) => (e.inline == null ? e.inline = t.isInline : e.inline != t.isInline && e.err("Mixing inline and block content"), { 11184 type: "name", 11185 value: t 11186 })); 11187 return e.pos++, t.length == 1 ? t[0] : { 11188 type: "choice", 11189 exprs: t 11190 }; 11191 } 11192} 11193function Sf(e) { 11194 let t = [[]]; 11195 return i(a(e, 0), n()), t; 11196 function n() { 11197 return t.push([]) - 1; 11198 } 11199 function r(e, n, r) { 11200 let i = { 11201 term: r, 11202 to: n 11203 }; 11204 return t[e].push(i), i; 11205 } 11206 function i(e, t) { 11207 e.forEach((e) => e.to = t); 11208 } 11209 function a(e, t) { 11210 if (e.type == "choice") return e.exprs.reduce((e, n) => e.concat(a(n, t)), []); 11211 if (e.type == "seq") for (let r = 0;; r++) { 11212 let o = a(e.exprs[r], t); 11213 if (r == e.exprs.length - 1) return o; 11214 i(o, t = n()); 11215 } 11216 else if (e.type == "star") { 11217 let o = n(); 11218 return r(t, o), i(a(e.expr, o), o), [r(o)]; 11219 } else if (e.type == "plus") { 11220 let o = n(); 11221 return i(a(e.expr, t), o), i(a(e.expr, o), o), [r(o)]; 11222 } else if (e.type == "opt") return [r(t)].concat(a(e.expr, t)); 11223 else if (e.type == "range") { 11224 let o = t; 11225 for (let t = 0; t < e.min; t++) { 11226 let t = n(); 11227 i(a(e.expr, o), t), o = t; 11228 } 11229 if (e.max == -1) i(a(e.expr, o), o); 11230 else for (let t = e.min; t < e.max; t++) { 11231 let t = n(); 11232 r(o, t), i(a(e.expr, o), t), o = t; 11233 } 11234 return [r(o)]; 11235 } else if (e.type == "name") return [r(t, void 0, e.value)]; 11236 else throw Error("Unknown expr type"); 11237 } 11238} 11239function Cf(e, t) { 11240 return t - e; 11241} 11242function wf(e, t) { 11243 let n = []; 11244 return r(t), n.sort(Cf); 11245 function r(t) { 11246 let i = e[t]; 11247 if (i.length == 1 && !i[0].term) return r(i[0].to); 11248 n.push(t); 11249 for (let e = 0; e < i.length; e++) { 11250 let { term: t, to: a } = i[e]; 11251 !t && n.indexOf(a) == -1 && r(a); 11252 } 11253 } 11254} 11255function Tf(e) { 11256 let t = /* @__PURE__ */ Object.create(null); 11257 return n(wf(e, 0)); 11258 function n(r) { 11259 let i = []; 11260 r.forEach((t) => { 11261 e[t].forEach(({ term: t, to: n }) => { 11262 if (!t) return; 11263 let r; 11264 for (let e = 0; e < i.length; e++) i[e][0] == t && (r = i[e][1]); 11265 wf(e, n).forEach((e) => { 11266 r || i.push([t, r = []]), r.indexOf(e) == -1 && r.push(e); 11267 }); 11268 }); 11269 }); 11270 let a = t[r.join(",")] = new pf(r.indexOf(e.length - 1) > -1); 11271 for (let e = 0; e < i.length; e++) { 11272 let r = i[e][1].sort(Cf); 11273 a.next.push({ 11274 type: i[e][0], 11275 next: t[r.join(",")] || n(r) 11276 }); 11277 } 11278 return a; 11279 } 11280} 11281function Ef(e, t) { 11282 for (let n = 0, r = [e]; n < r.length; n++) { 11283 let e = r[n], i = !e.validEnd, a = []; 11284 for (let t = 0; t < e.next.length; t++) { 11285 let { type: n, next: o } = e.next[t]; 11286 a.push(n.name), i && !(n.isText || n.hasRequiredAttrs()) && (i = !1), r.indexOf(o) == -1 && r.push(o); 11287 } 11288 i && t.err("Only non-generatable nodes (" + a.join(", ") + ") in a required position (see https://prosemirror.net/docs/guide/#generatable)"); 11289 } 11290} 11291var Df = 65535, Of = 2 ** 16; 11292function kf(e, t) { 11293 return e + t * Of; 11294} 11295function Af(e) { 11296 return e & Df; 11297} 11298function jf(e) { 11299 return (e - (e & Df)) / Of; 11300} 11301var Mf = 1, Nf = 2, Pf = 4, Ff = 8, If = class { 11302 constructor(e, t, n) { 11303 this.pos = e, this.delInfo = t, this.recover = n; 11304 } 11305 get deleted() { 11306 return (this.delInfo & Ff) > 0; 11307 } 11308 get deletedBefore() { 11309 return (this.delInfo & (Mf | Pf)) > 0; 11310 } 11311 get deletedAfter() { 11312 return (this.delInfo & (Nf | Pf)) > 0; 11313 } 11314 get deletedAcross() { 11315 return (this.delInfo & Pf) > 0; 11316 } 11317}, Lf = class e { 11318 constructor(t, n = !1) { 11319 if (this.ranges = t, this.inverted = n, !t.length && e.empty) return e.empty; 11320 } 11321 recover(e) { 11322 let t = 0, n = Af(e); 11323 if (!this.inverted) for (let e = 0; e < n; e++) t += this.ranges[e * 3 + 2] - this.ranges[e * 3 + 1]; 11324 return this.ranges[n * 3] + t + jf(e); 11325 } 11326 mapResult(e, t = 1) { 11327 return this._map(e, t, !1); 11328 } 11329 map(e, t = 1) { 11330 return this._map(e, t, !0); 11331 } 11332 _map(e, t, n) { 11333 let r = 0, i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2; 11334 for (let o = 0; o < this.ranges.length; o += 3) { 11335 let s = this.ranges[o] - (this.inverted ? r : 0); 11336 if (s > e) break; 11337 let c = this.ranges[o + i], l = this.ranges[o + a], u = s + c; 11338 if (e <= u) { 11339 let i = c ? e == s ? -1 : e == u ? 1 : t : t, a = s + r + (i < 0 ? 0 : l); 11340 if (n) return a; 11341 let d = e == (t < 0 ? s : u) ? null : kf(o / 3, e - s), f = e == s ? Nf : e == u ? Mf : Pf; 11342 return (t < 0 ? e != s : e != u) && (f |= Ff), new If(a, f, d); 11343 } 11344 r += l - c; 11345 } 11346 return n ? e + r : new If(e + r, 0, null); 11347 } 11348 touches(e, t) { 11349 let n = 0, r = Af(t), i = this.inverted ? 2 : 1, a = this.inverted ? 1 : 2; 11350 for (let t = 0; t < this.ranges.length; t += 3) { 11351 let o = this.ranges[t] - (this.inverted ? n : 0); 11352 if (o > e) break; 11353 let s = this.ranges[t + i]; 11354 if (e <= o + s && t == r * 3) return !0; 11355 n += this.ranges[t + a] - s; 11356 } 11357 return !1; 11358 } 11359 forEach(e) { 11360 let t = this.inverted ? 2 : 1, n = this.inverted ? 1 : 2; 11361 for (let r = 0, i = 0; r < this.ranges.length; r += 3) { 11362 let a = this.ranges[r], o = a - (this.inverted ? i : 0), s = a + (this.inverted ? 0 : i), c = this.ranges[r + t], l = this.ranges[r + n]; 11363 e(o, o + c, s, s + l), i += l - c; 11364 } 11365 } 11366 invert() { 11367 return new e(this.ranges, !this.inverted); 11368 } 11369 toString() { 11370 return (this.inverted ? "-" : "") + JSON.stringify(this.ranges); 11371 } 11372 static offset(t) { 11373 return t == 0 ? e.empty : new e(t < 0 ? [ 11374 0, 11375 -t, 11376 0 11377 ] : [ 11378 0, 11379 0, 11380 t 11381 ]); 11382 } 11383}; 11384Lf.empty = new Lf([]); 11385var Rf = /* @__PURE__ */ Object.create(null), G = class { 11386 getMap() { 11387 return Lf.empty; 11388 } 11389 merge(e) { 11390 return null; 11391 } 11392 static fromJSON(e, t) { 11393 if (!t || !t.stepType) throw RangeError("Invalid input for Step.fromJSON"); 11394 let n = Rf[t.stepType]; 11395 if (!n) throw RangeError(`No step type ${t.stepType} defined`); 11396 return n.fromJSON(e, t); 11397 } 11398 static jsonID(e, t) { 11399 if (e in Rf) throw RangeError("Duplicate use of step JSON ID " + e); 11400 return Rf[e] = t, t.prototype.jsonID = e, t; 11401 } 11402}, K = class e { 11403 constructor(e, t) { 11404 this.doc = e, this.failed = t; 11405 } 11406 static ok(t) { 11407 return new e(t, null); 11408 } 11409 static fail(t) { 11410 return new e(null, t); 11411 } 11412 static fromReplace(t, n, r, i) { 11413 try { 11414 return e.ok(t.replace(n, r, i)); 11415 } catch (t) { 11416 if (t instanceof Gd) return e.fail(t.message); 11417 throw t; 11418 } 11419 } 11420}; 11421function zf(e, t, n) { 11422 let r = []; 11423 for (let i = 0; i < e.childCount; i++) { 11424 let a = e.child(i); 11425 a.content.size && (a = a.copy(zf(a.content, t, a))), a.isInline && (a = t(a, n, i)), r.push(a); 11426 } 11427 return U.fromArray(r); 11428} 11429var Bf = class e extends G { 11430 constructor(e, t, n) { 11431 super(), this.from = e, this.to = t, this.mark = n; 11432 } 11433 apply(e) { 11434 let t = e.slice(this.from, this.to), n = e.resolve(this.from), r = n.node(n.sharedDepth(this.to)), i = new W(zf(t.content, (e, t) => !e.isAtom || !t.type.allowsMarkType(this.mark.type) ? e : e.mark(this.mark.addToSet(e.marks)), r), t.openStart, t.openEnd); 11435 return K.fromReplace(e, this.from, this.to, i); 11436 } 11437 invert() { 11438 return new Vf(this.from, this.to, this.mark); 11439 } 11440 map(t) { 11441 let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1); 11442 return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark); 11443 } 11444 merge(t) { 11445 return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null; 11446 } 11447 toJSON() { 11448 return { 11449 stepType: "addMark", 11450 mark: this.mark.toJSON(), 11451 from: this.from, 11452 to: this.to 11453 }; 11454 } 11455 static fromJSON(t, n) { 11456 if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for AddMarkStep.fromJSON"); 11457 return new e(n.from, n.to, t.markFromJSON(n.mark)); 11458 } 11459}; 11460G.jsonID("addMark", Bf); 11461var Vf = class e extends G { 11462 constructor(e, t, n) { 11463 super(), this.from = e, this.to = t, this.mark = n; 11464 } 11465 apply(e) { 11466 let t = e.slice(this.from, this.to), n = new W(zf(t.content, (e) => e.mark(this.mark.removeFromSet(e.marks)), e), t.openStart, t.openEnd); 11467 return K.fromReplace(e, this.from, this.to, n); 11468 } 11469 invert() { 11470 return new Bf(this.from, this.to, this.mark); 11471 } 11472 map(t) { 11473 let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1); 11474 return n.deleted && r.deleted || n.pos >= r.pos ? null : new e(n.pos, r.pos, this.mark); 11475 } 11476 merge(t) { 11477 return t instanceof e && t.mark.eq(this.mark) && this.from <= t.to && this.to >= t.from ? new e(Math.min(this.from, t.from), Math.max(this.to, t.to), this.mark) : null; 11478 } 11479 toJSON() { 11480 return { 11481 stepType: "removeMark", 11482 mark: this.mark.toJSON(), 11483 from: this.from, 11484 to: this.to 11485 }; 11486 } 11487 static fromJSON(t, n) { 11488 if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for RemoveMarkStep.fromJSON"); 11489 return new e(n.from, n.to, t.markFromJSON(n.mark)); 11490 } 11491}; 11492G.jsonID("removeMark", Vf); 11493var Hf = class e extends G { 11494 constructor(e, t) { 11495 super(), this.pos = e, this.mark = t; 11496 } 11497 apply(e) { 11498 let t = e.nodeAt(this.pos); 11499 if (!t) return K.fail("No node at mark step's position"); 11500 let n = t.type.create(t.attrs, null, this.mark.addToSet(t.marks)); 11501 return K.fromReplace(e, this.pos, this.pos + 1, new W(U.from(n), 0, +!t.isLeaf)); 11502 } 11503 invert(t) { 11504 let n = t.nodeAt(this.pos); 11505 if (n) { 11506 let t = this.mark.addToSet(n.marks); 11507 if (t.length == n.marks.length) { 11508 for (let r = 0; r < n.marks.length; r++) if (!n.marks[r].isInSet(t)) return new e(this.pos, n.marks[r]); 11509 return new e(this.pos, this.mark); 11510 } 11511 } 11512 return new Uf(this.pos, this.mark); 11513 } 11514 map(t) { 11515 let n = t.mapResult(this.pos, 1); 11516 return n.deletedAfter ? null : new e(n.pos, this.mark); 11517 } 11518 toJSON() { 11519 return { 11520 stepType: "addNodeMark", 11521 pos: this.pos, 11522 mark: this.mark.toJSON() 11523 }; 11524 } 11525 static fromJSON(t, n) { 11526 if (typeof n.pos != "number") throw RangeError("Invalid input for AddNodeMarkStep.fromJSON"); 11527 return new e(n.pos, t.markFromJSON(n.mark)); 11528 } 11529}; 11530G.jsonID("addNodeMark", Hf); 11531var Uf = class e extends G { 11532 constructor(e, t) { 11533 super(), this.pos = e, this.mark = t; 11534 } 11535 apply(e) { 11536 let t = e.nodeAt(this.pos); 11537 if (!t) return K.fail("No node at mark step's position"); 11538 let n = t.type.create(t.attrs, null, this.mark.removeFromSet(t.marks)); 11539 return K.fromReplace(e, this.pos, this.pos + 1, new W(U.from(n), 0, +!t.isLeaf)); 11540 } 11541 invert(e) { 11542 let t = e.nodeAt(this.pos); 11543 return !t || !this.mark.isInSet(t.marks) ? this : new Hf(this.pos, this.mark); 11544 } 11545 map(t) { 11546 let n = t.mapResult(this.pos, 1); 11547 return n.deletedAfter ? null : new e(n.pos, this.mark); 11548 } 11549 toJSON() { 11550 return { 11551 stepType: "removeNodeMark", 11552 pos: this.pos, 11553 mark: this.mark.toJSON() 11554 }; 11555 } 11556 static fromJSON(t, n) { 11557 if (typeof n.pos != "number") throw RangeError("Invalid input for RemoveNodeMarkStep.fromJSON"); 11558 return new e(n.pos, t.markFromJSON(n.mark)); 11559 } 11560}; 11561G.jsonID("removeNodeMark", Uf); 11562var Wf = class e extends G { 11563 constructor(e, t, n, r = !1) { 11564 super(), this.from = e, this.to = t, this.slice = n, this.structure = r; 11565 } 11566 apply(e) { 11567 return this.structure && Kf(e, this.from, this.to) ? K.fail("Structure replace would overwrite content") : K.fromReplace(e, this.from, this.to, this.slice); 11568 } 11569 getMap() { 11570 return new Lf([ 11571 this.from, 11572 this.to - this.from, 11573 this.slice.size 11574 ]); 11575 } 11576 invert(t) { 11577 return new e(this.from, this.from + this.slice.size, t.slice(this.from, this.to)); 11578 } 11579 map(t) { 11580 let n = t.mapResult(this.to, -1), r = this.from == this.to && e.MAP_BIAS < 0 ? n : t.mapResult(this.from, 1); 11581 return r.deletedAcross && n.deletedAcross ? null : new e(r.pos, Math.max(r.pos, n.pos), this.slice, this.structure); 11582 } 11583 merge(t) { 11584 if (!(t instanceof e) || t.structure || this.structure) return null; 11585 if (this.from + this.slice.size == t.from && !this.slice.openEnd && !t.slice.openStart) { 11586 let n = this.slice.size + t.slice.size == 0 ? W.empty : new W(this.slice.content.append(t.slice.content), this.slice.openStart, t.slice.openEnd); 11587 return new e(this.from, this.to + (t.to - t.from), n, this.structure); 11588 } else if (t.to == this.from && !this.slice.openStart && !t.slice.openEnd) { 11589 let n = this.slice.size + t.slice.size == 0 ? W.empty : new W(t.slice.content.append(this.slice.content), t.slice.openStart, this.slice.openEnd); 11590 return new e(t.from, this.to, n, this.structure); 11591 } else return null; 11592 } 11593 toJSON() { 11594 let e = { 11595 stepType: "replace", 11596 from: this.from, 11597 to: this.to 11598 }; 11599 return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e; 11600 } 11601 static fromJSON(t, n) { 11602 if (typeof n.from != "number" || typeof n.to != "number") throw RangeError("Invalid input for ReplaceStep.fromJSON"); 11603 return new e(n.from, n.to, W.fromJSON(t, n.slice), !!n.structure); 11604 } 11605}; 11606Wf.MAP_BIAS = 1, G.jsonID("replace", Wf); 11607var Gf = class e extends G { 11608 constructor(e, t, n, r, i, a, o = !1) { 11609 super(), this.from = e, this.to = t, this.gapFrom = n, this.gapTo = r, this.slice = i, this.insert = a, this.structure = o; 11610 } 11611 apply(e) { 11612 if (this.structure && (Kf(e, this.from, this.gapFrom) || Kf(e, this.gapTo, this.to))) return K.fail("Structure gap-replace would overwrite content"); 11613 let t = e.slice(this.gapFrom, this.gapTo); 11614 if (t.openStart || t.openEnd) return K.fail("Gap is not a flat range"); 11615 let n = this.slice.insertAt(this.insert, t.content); 11616 return n ? K.fromReplace(e, this.from, this.to, n) : K.fail("Content does not fit in gap"); 11617 } 11618 getMap() { 11619 return new Lf([ 11620 this.from, 11621 this.gapFrom - this.from, 11622 this.insert, 11623 this.gapTo, 11624 this.to - this.gapTo, 11625 this.slice.size - this.insert 11626 ]); 11627 } 11628 invert(t) { 11629 let n = this.gapTo - this.gapFrom; 11630 return new e(this.from, this.from + this.slice.size + n, this.from + this.insert, this.from + this.insert + n, t.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure); 11631 } 11632 map(t) { 11633 let n = t.mapResult(this.from, 1), r = t.mapResult(this.to, -1), i = this.from == this.gapFrom ? n.pos : t.map(this.gapFrom, -1), a = this.to == this.gapTo ? r.pos : t.map(this.gapTo, 1); 11634 return n.deletedAcross && r.deletedAcross || i < n.pos || a > r.pos ? null : new e(n.pos, r.pos, i, a, this.slice, this.insert, this.structure); 11635 } 11636 toJSON() { 11637 let e = { 11638 stepType: "replaceAround", 11639 from: this.from, 11640 to: this.to, 11641 gapFrom: this.gapFrom, 11642 gapTo: this.gapTo, 11643 insert: this.insert 11644 }; 11645 return this.slice.size && (e.slice = this.slice.toJSON()), this.structure && (e.structure = !0), e; 11646 } 11647 static fromJSON(t, n) { 11648 if (typeof n.from != "number" || typeof n.to != "number" || typeof n.gapFrom != "number" || typeof n.gapTo != "number" || typeof n.insert != "number") throw RangeError("Invalid input for ReplaceAroundStep.fromJSON"); 11649 return new e(n.from, n.to, n.gapFrom, n.gapTo, W.fromJSON(t, n.slice), n.insert, !!n.structure); 11650 } 11651}; 11652G.jsonID("replaceAround", Gf); 11653function Kf(e, t, n) { 11654 let r = e.resolve(t), i = n - t, a = r.depth; 11655 for (; i > 0 && a > 0 && r.indexAfter(a) == r.node(a).childCount;) a--, i--; 11656 if (i > 0) { 11657 let e = r.node(a).maybeChild(r.indexAfter(a)); 11658 for (; i > 0;) { 11659 if (!e || e.isLeaf) return !0; 11660 e = e.firstChild, i--; 11661 } 11662 } 11663 return !1; 11664} 11665var qf = class e extends G { 11666 constructor(e, t, n) { 11667 super(), this.pos = e, this.attr = t, this.value = n; 11668 } 11669 apply(e) { 11670 let t = e.nodeAt(this.pos); 11671 if (!t) return K.fail("No node at attribute step's position"); 11672 let n = /* @__PURE__ */ Object.create(null); 11673 for (let e in t.attrs) n[e] = t.attrs[e]; 11674 n[this.attr] = this.value; 11675 let r = t.type.create(n, null, t.marks); 11676 return K.fromReplace(e, this.pos, this.pos + 1, new W(U.from(r), 0, +!t.isLeaf)); 11677 } 11678 getMap() { 11679 return Lf.empty; 11680 } 11681 invert(t) { 11682 return new e(this.pos, this.attr, t.nodeAt(this.pos).attrs[this.attr]); 11683 } 11684 map(t) { 11685 let n = t.mapResult(this.pos, 1); 11686 return n.deletedAfter ? null : new e(n.pos, this.attr, this.value); 11687 } 11688 toJSON() { 11689 return { 11690 stepType: "attr", 11691 pos: this.pos, 11692 attr: this.attr, 11693 value: this.value 11694 }; 11695 } 11696 static fromJSON(t, n) { 11697 if (typeof n.pos != "number" || typeof n.attr != "string") throw RangeError("Invalid input for AttrStep.fromJSON"); 11698 return new e(n.pos, n.attr, n.value); 11699 } 11700}; 11701G.jsonID("attr", qf); 11702var Jf = class e extends G { 11703 constructor(e, t) { 11704 super(), this.attr = e, this.value = t; 11705 } 11706 apply(e) { 11707 let t = /* @__PURE__ */ Object.create(null); 11708 for (let n in e.attrs) t[n] = e.attrs[n]; 11709 t[this.attr] = this.value; 11710 let n = e.type.create(t, e.content, e.marks); 11711 return K.ok(n); 11712 } 11713 getMap() { 11714 return Lf.empty; 11715 } 11716 invert(t) { 11717 return new e(this.attr, t.attrs[this.attr]); 11718 } 11719 map(e) { 11720 return this; 11721 } 11722 toJSON() { 11723 return { 11724 stepType: "docAttr", 11725 attr: this.attr, 11726 value: this.value 11727 }; 11728 } 11729 static fromJSON(t, n) { 11730 if (typeof n.attr != "string") throw RangeError("Invalid input for DocAttrStep.fromJSON"); 11731 return new e(n.attr, n.value); 11732 } 11733}; 11734G.jsonID("docAttr", Jf); 11735var Yf = class extends Error {}; 11736Yf = function e(t) { 11737 let n = Error.call(this, t); 11738 return n.__proto__ = e.prototype, n; 11739}, Yf.prototype = Object.create(Error.prototype), Yf.prototype.constructor = Yf, Yf.prototype.name = "TransformError"; 11740var Xf = /* @__PURE__ */ Object.create(null), q = class { 11741 constructor(e, t, n) { 11742 this.$anchor = e, this.$head = t, this.ranges = n || [new Zf(e.min(t), e.max(t))]; 11743 } 11744 get anchor() { 11745 return this.$anchor.pos; 11746 } 11747 get head() { 11748 return this.$head.pos; 11749 } 11750 get from() { 11751 return this.$from.pos; 11752 } 11753 get to() { 11754 return this.$to.pos; 11755 } 11756 get $from() { 11757 return this.ranges[0].$from; 11758 } 11759 get $to() { 11760 return this.ranges[0].$to; 11761 } 11762 get empty() { 11763 let e = this.ranges; 11764 for (let t = 0; t < e.length; t++) if (e[t].$from.pos != e[t].$to.pos) return !1; 11765 return !0; 11766 } 11767 content() { 11768 return this.$from.doc.slice(this.from, this.to, !0); 11769 } 11770 replace(e, t = W.empty) { 11771 let n = t.content.lastChild, r = null; 11772 for (let e = 0; e < t.openEnd; e++) r = n, n = n.lastChild; 11773 let i = e.steps.length, a = this.ranges; 11774 for (let o = 0; o < a.length; o++) { 11775 let { $from: s, $to: c } = a[o], l = e.mapping.slice(i); 11776 e.replaceRange(l.map(s.pos), l.map(c.pos), o ? W.empty : t), o == 0 && sp(e, i, (n ? n.isInline : r && r.isTextblock) ? -1 : 1); 11777 } 11778 } 11779 replaceWith(e, t) { 11780 let n = e.steps.length, r = this.ranges; 11781 for (let i = 0; i < r.length; i++) { 11782 let { $from: a, $to: o } = r[i], s = e.mapping.slice(n), c = s.map(a.pos), l = s.map(o.pos); 11783 i ? e.deleteRange(c, l) : (e.replaceRangeWith(c, l, t), sp(e, n, t.isInline ? -1 : 1)); 11784 } 11785 } 11786 static findFrom(e, t, n = !1) { 11787 let r = e.parent.inlineContent ? new ep(e) : op(e.node(0), e.parent, e.pos, e.index(), t, n); 11788 if (r) return r; 11789 for (let r = e.depth - 1; r >= 0; r--) { 11790 let i = t < 0 ? op(e.node(0), e.node(r), e.before(r + 1), e.index(r), t, n) : op(e.node(0), e.node(r), e.after(r + 1), e.index(r) + 1, t, n); 11791 if (i) return i; 11792 } 11793 return null; 11794 } 11795 static near(e, t = 1) { 11796 return this.findFrom(e, t) || this.findFrom(e, -t) || new ip(e.node(0)); 11797 } 11798 static atStart(e) { 11799 return op(e, e, 0, 0, 1) || new ip(e); 11800 } 11801 static atEnd(e) { 11802 return op(e, e, e.content.size, e.childCount, -1) || new ip(e); 11803 } 11804 static fromJSON(e, t) { 11805 if (!t || !t.type) throw RangeError("Invalid input for Selection.fromJSON"); 11806 let n = Xf[t.type]; 11807 if (!n) throw RangeError(`No selection type ${t.type} defined`); 11808 return n.fromJSON(e, t); 11809 } 11810 static jsonID(e, t) { 11811 if (e in Xf) throw RangeError("Duplicate use of selection JSON ID " + e); 11812 return Xf[e] = t, t.prototype.jsonID = e, t; 11813 } 11814 getBookmark() { 11815 return ep.between(this.$anchor, this.$head).getBookmark(); 11816 } 11817}; 11818q.prototype.visible = !0; 11819var Zf = class { 11820 constructor(e, t) { 11821 this.$from = e, this.$to = t; 11822 } 11823}, Qf = !1; 11824function $f(e) { 11825 !Qf && !e.parent.inlineContent && (Qf = !0, console.warn("TextSelection endpoint not pointing into a node with inline content (" + e.parent.type.name + ")")); 11826} 11827var ep = class e extends q { 11828 constructor(e, t = e) { 11829 $f(e), $f(t), super(e, t); 11830 } 11831 get $cursor() { 11832 return this.$anchor.pos == this.$head.pos ? this.$head : null; 11833 } 11834 map(t, n) { 11835 let r = t.resolve(n.map(this.head)); 11836 if (!r.parent.inlineContent) return q.near(r); 11837 let i = t.resolve(n.map(this.anchor)); 11838 return new e(i.parent.inlineContent ? i : r, r); 11839 } 11840 replace(e, t = W.empty) { 11841 if (super.replace(e, t), t == W.empty) { 11842 let t = this.$from.marksAcross(this.$to); 11843 t && e.ensureMarks(t); 11844 } 11845 } 11846 eq(t) { 11847 return t instanceof e && t.anchor == this.anchor && t.head == this.head; 11848 } 11849 getBookmark() { 11850 return new tp(this.anchor, this.head); 11851 } 11852 toJSON() { 11853 return { 11854 type: "text", 11855 anchor: this.anchor, 11856 head: this.head 11857 }; 11858 } 11859 static fromJSON(t, n) { 11860 if (typeof n.anchor != "number" || typeof n.head != "number") throw RangeError("Invalid input for TextSelection.fromJSON"); 11861 return new e(t.resolve(n.anchor), t.resolve(n.head)); 11862 } 11863 static create(e, t, n = t) { 11864 let r = e.resolve(t); 11865 return new this(r, n == t ? r : e.resolve(n)); 11866 } 11867 static between(t, n, r) { 11868 let i = t.pos - n.pos; 11869 if ((!r || i) && (r = i >= 0 ? 1 : -1), !n.parent.inlineContent) { 11870 let e = q.findFrom(n, r, !0) || q.findFrom(n, -r, !0); 11871 if (e) n = e.$head; 11872 else return q.near(n, r); 11873 } 11874 return t.parent.inlineContent || (i == 0 ? t = n : (t = (q.findFrom(t, -r, !0) || q.findFrom(t, r, !0)).$anchor, t.pos < n.pos != i < 0 && (t = n))), new e(t, n); 11875 } 11876}; 11877q.jsonID("text", ep); 11878var tp = class e { 11879 constructor(e, t) { 11880 this.anchor = e, this.head = t; 11881 } 11882 map(t) { 11883 return new e(t.map(this.anchor), t.map(this.head)); 11884 } 11885 resolve(e) { 11886 return ep.between(e.resolve(this.anchor), e.resolve(this.head)); 11887 } 11888}, np = class e extends q { 11889 constructor(e) { 11890 let t = e.nodeAfter, n = e.node(0).resolve(e.pos + t.nodeSize); 11891 super(e, n), this.node = t; 11892 } 11893 map(t, n) { 11894 let { deleted: r, pos: i } = n.mapResult(this.anchor), a = t.resolve(i); 11895 return r ? q.near(a) : new e(a); 11896 } 11897 content() { 11898 return new W(U.from(this.node), 0, 0); 11899 } 11900 eq(t) { 11901 return t instanceof e && t.anchor == this.anchor; 11902 } 11903 toJSON() { 11904 return { 11905 type: "node", 11906 anchor: this.anchor 11907 }; 11908 } 11909 getBookmark() { 11910 return new rp(this.anchor); 11911 } 11912 static fromJSON(t, n) { 11913 if (typeof n.anchor != "number") throw RangeError("Invalid input for NodeSelection.fromJSON"); 11914 return new e(t.resolve(n.anchor)); 11915 } 11916 static create(t, n) { 11917 return new e(t.resolve(n)); 11918 } 11919 static isSelectable(e) { 11920 return !e.isText && e.type.spec.selectable !== !1; 11921 } 11922}; 11923np.prototype.visible = !1, q.jsonID("node", np); 11924var rp = class e { 11925 constructor(e) { 11926 this.anchor = e; 11927 } 11928 map(t) { 11929 let { deleted: n, pos: r } = t.mapResult(this.anchor); 11930 return n ? new tp(r, r) : new e(r); 11931 } 11932 resolve(e) { 11933 let t = e.resolve(this.anchor), n = t.nodeAfter; 11934 return n && np.isSelectable(n) ? new np(t) : q.near(t); 11935 } 11936}, ip = class e extends q { 11937 constructor(e) { 11938 super(e.resolve(0), e.resolve(e.content.size)); 11939 } 11940 replace(e, t = W.empty) { 11941 if (t == W.empty) { 11942 e.delete(0, e.doc.content.size); 11943 let t = q.atStart(e.doc); 11944 t.eq(e.selection) || e.setSelection(t); 11945 } else super.replace(e, t); 11946 } 11947 toJSON() { 11948 return { type: "all" }; 11949 } 11950 static fromJSON(t) { 11951 return new e(t); 11952 } 11953 map(t) { 11954 return new e(t); 11955 } 11956 eq(t) { 11957 return t instanceof e; 11958 } 11959 getBookmark() { 11960 return ap; 11961 } 11962}; 11963q.jsonID("all", ip); 11964var ap = { 11965 map() { 11966 return this; 11967 }, 11968 resolve(e) { 11969 return new ip(e); 11970 } 11971}; 11972function op(e, t, n, r, i, a = !1) { 11973 if (t.inlineContent) return ep.create(e, n); 11974 for (let o = r - (i > 0 ? 0 : 1); i > 0 ? o < t.childCount : o >= 0; o += i) { 11975 let r = t.child(o); 11976 if (!r.isAtom) { 11977 let t = op(e, r, n + i, i < 0 ? r.childCount : 0, i, a); 11978 if (t) return t; 11979 } else if (!a && np.isSelectable(r)) return np.create(e, n - (i < 0 ? r.nodeSize : 0)); 11980 n += r.nodeSize * i; 11981 } 11982 return null; 11983} 11984function sp(e, t, n) { 11985 let r = e.steps.length - 1; 11986 if (r < t) return; 11987 let i = e.steps[r]; 11988 if (!(i instanceof Wf || i instanceof Gf)) return; 11989 let a = e.mapping.maps[r], o; 11990 a.forEach((e, t, n, r) => { 11991 o ??= r; 11992 }), e.setSelection(q.near(e.doc.resolve(o), n)); 11993} 11994function cp(e, t) { 11995 return !t || !e ? e : e.bind(t); 11996} 11997var lp = class { 11998 constructor(e, t, n) { 11999 this.name = e, this.init = cp(t.init, n), this.apply = cp(t.apply, n); 12000 } 12001}; 12002new lp("doc", { 12003 init(e) { 12004 return e.doc || e.schema.topNodeType.createAndFill(); 12005 }, 12006 apply(e) { 12007 return e.doc; 12008 } 12009}), new lp("selection", { 12010 init(e, t) { 12011 return e.selection || q.atStart(t.doc); 12012 }, 12013 apply(e) { 12014 return e.selection; 12015 } 12016}), new lp("storedMarks", { 12017 init(e) { 12018 return e.storedMarks || null; 12019 }, 12020 apply(e, t, n, r) { 12021 return r.selection.$cursor ? e.storedMarks : null; 12022 } 12023}), new lp("scrollToSelection", { 12024 init() { 12025 return 0; 12026 }, 12027 apply(e, t) { 12028 return e.scrolledIntoView ? t + 1 : t; 12029 } 12030}); 12031var up = (e, t) => { 12032 let { state: n, view: r } = e, { selection: i } = n; 12033 if (!i.empty) return !1; 12034 let { $from: a } = i; 12035 if (a.parentOffset !== 0) return !1; 12036 let o = a.depth - 1, s = a.node(o), c = a.index(o); 12037 if (c === 0) return !1; 12038 if (s.type === t) return e.commands.lift(t.name); 12039 let l = s.child(c - 1); 12040 if (l.type !== t || !l.lastChild?.isTextblock) return !1; 12041 let u = a.before(), d = u - 1 - 1, { tr: f } = n; 12042 return f.delete(u, a.after()).insert(d, a.parent.content), f.setSelection(ep.create(f.doc, d)), r.dispatch(f.scrollIntoView()), !0; 12043}, dp = /^\s*>\s$/, fp = H.create({ 12044 name: "blockquote", 12045 addOptions() { 12046 return { HTMLAttributes: {} }; 12047 }, 12048 content: "block+", 12049 group: "block", 12050 defining: !0, 12051 parseHTML() { 12052 return [{ tag: "blockquote" }]; 12053 }, 12054 renderHTML({ HTMLAttributes: e }) { 12055 return /* @__PURE__ */ Rd("blockquote", { 12056 ...B(this.options.HTMLAttributes, e), 12057 children: /* @__PURE__ */ Rd("slot", {}) 12058 }); 12059 }, 12060 parseMarkdown: (e, t) => { 12061 let n = t.parseBlockChildren ?? t.parseChildren; 12062 return t.createNode("blockquote", void 0, n(e.tokens || [])); 12063 }, 12064 renderMarkdown: (e, t) => { 12065 if (!e.content) return ""; 12066 let n = []; 12067 return e.content.forEach((e, r) => { 12068 let i = (t.renderChild?.call(t, e, r) ?? t.renderChildren([e])).split("\n").map((e) => e.trim() === "" ? ">" : `> ${e}`); 12069 n.push(i.join("\n")); 12070 }), n.join("\n>\n"); 12071 }, 12072 addCommands() { 12073 return { 12074 setBlockquote: () => ({ commands: e }) => e.wrapIn(this.name), 12075 toggleBlockquote: () => ({ commands: e }) => e.toggleWrap(this.name), 12076 unsetBlockquote: () => ({ commands: e }) => e.lift(this.name) 12077 }; 12078 }, 12079 addKeyboardShortcuts() { 12080 return { 12081 "Mod-Shift-b": () => this.editor.commands.toggleBlockquote(), 12082 Backspace: () => up(this.editor, this.type) 12083 }; 12084 }, 12085 addInputRules() { 12086 return [Id({ 12087 find: dp, 12088 type: this.type 12089 })]; 12090 } 12091}), pp = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, mp = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, hp = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, gp = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, _p = dd.create({ 12092 name: "bold", 12093 addOptions() { 12094 return { HTMLAttributes: {} }; 12095 }, 12096 parseHTML() { 12097 return [ 12098 { tag: "strong" }, 12099 { 12100 tag: "b", 12101 getAttrs: (e) => e.style.fontWeight !== "normal" && null 12102 }, 12103 { 12104 style: "font-weight=400", 12105 clearMark: (e) => e.type.name === this.name 12106 }, 12107 { 12108 style: "font-weight", 12109 getAttrs: (e) => /^(bold(er)?|[5-9]\d{2,})$/.test(e) && null 12110 } 12111 ]; 12112 }, 12113 renderHTML({ HTMLAttributes: e }) { 12114 return /* @__PURE__ */ Rd("strong", { 12115 ...B(this.options.HTMLAttributes, e), 12116 children: /* @__PURE__ */ Rd("slot", {}) 12117 }); 12118 }, 12119 markdownTokenName: "strong", 12120 parseMarkdown: (e, t) => t.applyMark("bold", t.parseInline(e.tokens || [])), 12121 markdownOptions: { htmlReopen: { 12122 open: "<strong>", 12123 close: "</strong>" 12124 } }, 12125 renderMarkdown: (e, t) => `**${t.renderChildren(e)}**`, 12126 addCommands() { 12127 return { 12128 setBold: () => ({ commands: e }) => e.setMark(this.name), 12129 toggleBold: () => ({ commands: e }) => e.toggleMark(this.name), 12130 unsetBold: () => ({ commands: e }) => e.unsetMark(this.name) 12131 }; 12132 }, 12133 addKeyboardShortcuts() { 12134 return { 12135 "Mod-b": () => this.editor.commands.toggleBold(), 12136 "Mod-B": () => this.editor.commands.toggleBold() 12137 }; 12138 }, 12139 addInputRules() { 12140 return [Nd({ 12141 find: pp, 12142 type: this.type 12143 }), Nd({ 12144 find: hp, 12145 type: this.type 12146 })]; 12147 }, 12148 addPasteRules() { 12149 return [Ld({ 12150 find: mp, 12151 type: this.type 12152 }), Ld({ 12153 find: gp, 12154 type: this.type 12155 })]; 12156 } 12157}), vp = (e) => { 12158 let t = /`([^`]+)`(?!`)$/.exec(e); 12159 return !t || t.index > 0 && e[t.index - 1] === "`" ? null : { 12160 index: t.index, 12161 text: t[0], 12162 replaceWith: t[1] 12163 }; 12164}, yp = (e) => { 12165 let t = /`([^`]+)`(?!`)/g, n = [], r; 12166 for (; (r = t.exec(e)) !== null;) r.index > 0 && e[r.index - 1] === "`" || n.push({ 12167 index: r.index, 12168 text: r[0], 12169 replaceWith: r[1] 12170 }); 12171 return n; 12172}, bp = dd.create({ 12173 name: "code", 12174 addOptions() { 12175 return { HTMLAttributes: {} }; 12176 }, 12177 excludes: "_", 12178 code: !0, 12179 exitable: !0, 12180 parseHTML() { 12181 return [{ tag: "code" }]; 12182 }, 12183 renderHTML({ HTMLAttributes: e }) { 12184 return [ 12185 "code", 12186 B(this.options.HTMLAttributes, e), 12187 0 12188 ]; 12189 }, 12190 markdownTokenName: "codespan", 12191 parseMarkdown: (e, t) => t.applyMark("code", [{ 12192 type: "text", 12193 text: e.text || "" 12194 }]), 12195 renderMarkdown: (e, t) => e.content ? `\`${t.renderChildren(e.content)}\`` : "", 12196 addCommands() { 12197 return { 12198 setCode: () => ({ commands: e }) => e.setMark(this.name), 12199 toggleCode: () => ({ commands: e }) => e.toggleMark(this.name), 12200 unsetCode: () => ({ commands: e }) => e.unsetMark(this.name) 12201 }; 12202 }, 12203 addKeyboardShortcuts() { 12204 return { "Mod-e": () => this.editor.commands.toggleCode() }; 12205 }, 12206 addInputRules() { 12207 return [Nd({ 12208 find: vp, 12209 type: this.type 12210 })]; 12211 }, 12212 addPasteRules() { 12213 return [Ld({ 12214 find: yp, 12215 type: this.type 12216 })]; 12217 } 12218}), xp = 4, Sp = /^```([a-z]+)?[\s\n]$/, Cp = /^~~~([a-z]+)?[\s\n]$/, wp = H.create({ 12219 name: "codeBlock", 12220 addOptions() { 12221 return { 12222 languageClassPrefix: "language-", 12223 exitOnTripleEnter: !0, 12224 exitOnArrowDown: !0, 12225 defaultLanguage: null, 12226 enableTabIndentation: !1, 12227 tabSize: xp, 12228 HTMLAttributes: {} 12229 }; 12230 }, 12231 content: "text*", 12232 marks: "", 12233 group: "block", 12234 code: !0, 12235 defining: !0, 12236 addAttributes() { 12237 return { language: { 12238 default: this.options.defaultLanguage, 12239 parseHTML: (e) => { 12240 let { languageClassPrefix: t } = this.options; 12241 return t && [...e.firstElementChild?.classList || []].filter((e) => e.startsWith(t)).map((e) => e.replace(t, ""))[0] || null; 12242 }, 12243 rendered: !1 12244 } }; 12245 }, 12246 parseHTML() { 12247 return [{ 12248 tag: "pre", 12249 preserveWhitespace: "full" 12250 }]; 12251 }, 12252 renderHTML({ node: e, HTMLAttributes: t }) { 12253 return [ 12254 "pre", 12255 B(this.options.HTMLAttributes, t), 12256 [ 12257 "code", 12258 { class: e.attrs.language ? this.options.languageClassPrefix + e.attrs.language : null }, 12259 0 12260 ] 12261 ]; 12262 }, 12263 markdownTokenName: "code", 12264 parseMarkdown: (e, t) => e.raw?.startsWith("```") === !1 && e.raw?.startsWith("~~~") === !1 && e.codeBlockStyle !== "indented" ? [] : t.createNode("codeBlock", { language: e.lang || null }, e.text ? [t.createTextNode(e.text)] : []), 12265 renderMarkdown: (e, t) => { 12266 let n = "", r = e.attrs?.language || ""; 12267 return n = e.content ? [ 12268 `\`\`\`${r}`, 12269 t.renderChildren(e.content), 12270 "```" 12271 ].join("\n") : `\`\`\`${r} 12272 12273\`\`\``, n; 12274 }, 12275 addCommands() { 12276 return { 12277 setCodeBlock: (e) => ({ commands: t }) => t.setNode(this.name, e), 12278 toggleCodeBlock: (e) => ({ commands: t }) => t.toggleNode(this.name, "paragraph", e) 12279 }; 12280 }, 12281 addKeyboardShortcuts() { 12282 return { 12283 "Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(), 12284 Backspace: () => { 12285 let { empty: e, $anchor: t } = this.editor.state.selection, n = t.pos === 1; 12286 return !e || t.parent.type.name !== this.name ? !1 : n || !t.parent.textContent.length ? this.editor.commands.clearNodes() : !1; 12287 }, 12288 Tab: ({ editor: e }) => { 12289 if (!this.options.enableTabIndentation) return !1; 12290 let t = this.options.tabSize ?? xp, { state: n } = e, { selection: r } = n, { $from: i, empty: a } = r; 12291 if (i.parent.type !== this.type) return !1; 12292 let o = " ".repeat(t); 12293 return a ? e.commands.insertContent(o) : e.commands.command(({ tr: e }) => { 12294 let { from: t, to: i } = r, a = n.doc.textBetween(t, i, "\n", "\n").split("\n").map((e) => o + e).join("\n"); 12295 return e.replaceWith(t, i, n.schema.text(a)), !0; 12296 }); 12297 }, 12298 "Shift-Tab": ({ editor: e }) => { 12299 if (!this.options.enableTabIndentation) return !1; 12300 let t = this.options.tabSize ?? xp, { state: n } = e, { selection: r } = n, { $from: i, empty: a } = r; 12301 return i.parent.type === this.type ? a ? e.commands.command(({ tr: e }) => { 12302 let { pos: r } = i, a = i.start(), o = i.end(), s = n.doc.textBetween(a, o, "\n", "\n").split("\n"), c = 0, l = 0, u = r - a; 12303 for (let e = 0; e < s.length; e += 1) { 12304 if (l + s[e].length >= u) { 12305 c = e; 12306 break; 12307 } 12308 l += s[e].length + 1; 12309 } 12310 let d = s[c].match(/^ */)?.[0] || "", f = Math.min(d.length, t); 12311 if (f === 0) return !0; 12312 let p = a; 12313 for (let e = 0; e < c; e += 1) p += s[e].length + 1; 12314 return e.delete(p, p + f), r - p <= f && e.setSelection(T.create(e.doc, p)), !0; 12315 }) : e.commands.command(({ tr: e }) => { 12316 let { from: i, to: a } = r, o = n.doc.textBetween(i, a, "\n", "\n").split("\n").map((e) => { 12317 let n = e.match(/^ */)?.[0] || "", r = Math.min(n.length, t); 12318 return e.slice(r); 12319 }).join("\n"); 12320 return e.replaceWith(i, a, n.schema.text(o)), !0; 12321 }) : !1; 12322 }, 12323 Enter: ({ editor: e }) => { 12324 if (!this.options.exitOnTripleEnter) return !1; 12325 let { state: t } = e, { selection: n } = t, { $from: r, empty: i } = n; 12326 if (!i || r.parent.type !== this.type) return !1; 12327 let a = r.parentOffset === r.parent.nodeSize - 2, o = r.parent.textContent.endsWith("\n\n"); 12328 return !a || !o ? !1 : e.chain().command(({ tr: e }) => (e.delete(r.pos - 2, r.pos), !0)).exitCode().run(); 12329 }, 12330 ArrowDown: ({ editor: e }) => { 12331 if (!this.options.exitOnArrowDown) return !1; 12332 let { state: t } = e, { selection: n, doc: r } = t, { $from: i, empty: a } = n; 12333 if (!a || i.parent.type !== this.type || i.parentOffset !== i.parent.nodeSize - 2) return !1; 12334 let o = i.after(); 12335 return o === void 0 ? !1 : r.nodeAt(o) ? e.commands.command(({ tr: e }) => (e.setSelection(w.near(r.resolve(o))), !0)) : e.commands.exitCode(); 12336 } 12337 }; 12338 }, 12339 addInputRules() { 12340 return [Fd({ 12341 find: Sp, 12342 type: this.type, 12343 getAttributes: (e) => ({ language: e[1] }) 12344 }), Fd({ 12345 find: Cp, 12346 type: this.type, 12347 getAttributes: (e) => ({ language: e[1] }) 12348 })]; 12349 }, 12350 addProseMirrorPlugins() { 12351 return [new D({ 12352 key: new O("codeBlockVSCodeHandler"), 12353 props: { handlePaste: (e, t) => { 12354 if (!t.clipboardData || this.editor.isActive(this.type.name)) return !1; 12355 let n = t.clipboardData.getData("text/plain"), r = t.clipboardData.getData("vscode-editor-data"), i = (r ? JSON.parse(r) : void 0)?.mode; 12356 if (!n || !i) return !1; 12357 let { tr: a, schema: o } = e.state, s = o.text(n.replace(/\r\n?/g, "\n")); 12358 return a.replaceSelectionWith(this.type.create({ language: i }, s)), a.selection.$from.parent.type !== this.type && a.setSelection(T.near(a.doc.resolve(Math.max(0, a.selection.from - 2)))), a.setMeta("paste", !0), e.dispatch(a), !0; 12359 } } 12360 })]; 12361 } 12362}), Tp = H.create({ 12363 name: "doc", 12364 topNode: !0, 12365 content: "block+", 12366 renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n\n") : "" 12367}), Ep = H.create({ 12368 name: "hardBreak", 12369 markdownTokenName: "br", 12370 addOptions() { 12371 return { 12372 keepMarks: !0, 12373 HTMLAttributes: {} 12374 }; 12375 }, 12376 inline: !0, 12377 group: "inline", 12378 selectable: !1, 12379 linebreakReplacement: !0, 12380 parseHTML() { 12381 return [{ tag: "br" }]; 12382 }, 12383 renderHTML({ HTMLAttributes: e }) { 12384 return ["br", B(this.options.HTMLAttributes, e)]; 12385 }, 12386 renderText() { 12387 return "\n"; 12388 }, 12389 renderMarkdown: () => " \n", 12390 parseMarkdown: () => ({ type: "hardBreak" }), 12391 addCommands() { 12392 return { setHardBreak: () => ({ commands: e, chain: t, state: n, editor: r }) => e.first([() => e.exitCode(), () => e.command(() => { 12393 let { selection: e, storedMarks: i } = n; 12394 if (e.$from.parent.type.spec.isolating) return !1; 12395 let { keepMarks: a } = this.options, { splittableMarks: o } = r.extensionManager, s = i || e.$to.parentOffset && e.$from.marks(); 12396 return t().insertContent({ type: this.name }).command(({ tr: e, dispatch: t }) => { 12397 if (t && s && a) { 12398 let t = s.filter((e) => o.includes(e.type.name)); 12399 e.ensureMarks(t); 12400 } 12401 return !0; 12402 }).run(); 12403 })]) }; 12404 }, 12405 addKeyboardShortcuts() { 12406 return { 12407 "Mod-Enter": () => this.editor.commands.setHardBreak(), 12408 "Shift-Enter": () => this.editor.commands.setHardBreak() 12409 }; 12410 } 12411}), Dp = H.create({ 12412 name: "heading", 12413 addOptions() { 12414 return { 12415 levels: [ 12416 1, 12417 2, 12418 3, 12419 4, 12420 5, 12421 6 12422 ], 12423 HTMLAttributes: {} 12424 }; 12425 }, 12426 content: "inline*", 12427 group: "block", 12428 defining: !0, 12429 addAttributes() { 12430 return { level: { 12431 default: 1, 12432 rendered: !1 12433 } }; 12434 }, 12435 parseHTML() { 12436 return this.options.levels.map((e) => ({ 12437 tag: `h${e}`, 12438 attrs: { level: e } 12439 })); 12440 }, 12441 renderHTML({ node: e, HTMLAttributes: t }) { 12442 return [ 12443 `h${this.options.levels.includes(e.attrs.level) ? e.attrs.level : this.options.levels[0]}`, 12444 B(this.options.HTMLAttributes, t), 12445 0 12446 ]; 12447 }, 12448 parseMarkdown: (e, t) => t.createNode("heading", { level: e.depth || 1 }, t.parseInline(e.tokens || [])), 12449 renderMarkdown: (e, t) => { 12450 let n = e.attrs?.level ? parseInt(e.attrs.level, 10) : 1, r = "#".repeat(n); 12451 return e.content ? `${r} ${t.renderChildren(e.content)}` : ""; 12452 }, 12453 addCommands() { 12454 return { 12455 setHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.setNode(this.name, e) : !1, 12456 toggleHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.toggleNode(this.name, "paragraph", e) : !1 12457 }; 12458 }, 12459 addKeyboardShortcuts() { 12460 return this.options.levels.reduce((e, t) => ({ 12461 ...e, 12462 [`Mod-Alt-${t}`]: () => this.editor.commands.toggleHeading({ level: t }) 12463 }), {}); 12464 }, 12465 addInputRules() { 12466 return this.options.levels.map((e) => Fd({ 12467 find: RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`), 12468 type: this.type, 12469 getAttributes: { level: e } 12470 })); 12471 } 12472}), Op = H.create({ 12473 name: "horizontalRule", 12474 addOptions() { 12475 return { 12476 HTMLAttributes: {}, 12477 nextNodeType: "paragraph" 12478 }; 12479 }, 12480 group: "block", 12481 parseHTML() { 12482 return [{ tag: "hr" }]; 12483 }, 12484 renderHTML({ HTMLAttributes: e }) { 12485 return ["hr", B(this.options.HTMLAttributes, e)]; 12486 }, 12487 markdownTokenName: "hr", 12488 parseMarkdown: (e, t) => t.createNode("horizontalRule"), 12489 renderMarkdown: () => "---", 12490 addCommands() { 12491 return { setHorizontalRule: () => ({ chain: e, state: t }) => { 12492 if (!Wu(t, t.schema.nodes[this.name])) return !1; 12493 let { selection: n } = t, { $to: r } = n, i = e(); 12494 return fu(n) ? i.insertContentAt(r.pos, { type: this.name }) : i.insertContent({ type: this.name }), i.command(({ state: e, tr: t, dispatch: n }) => { 12495 if (n) { 12496 let { $to: n } = t.selection, r = n.end(); 12497 if (n.nodeAfter) n.nodeAfter.isTextblock ? t.setSelection(T.create(t.doc, n.pos + 1)) : n.nodeAfter.isBlock ? t.setSelection(E.create(t.doc, n.pos)) : t.setSelection(T.create(t.doc, n.pos)); 12498 else { 12499 let i = (e.schema.nodes[this.options.nextNodeType] || n.parent.type.contentMatch.defaultType)?.create(); 12500 i && (t.insert(r, i), t.setSelection(T.create(t.doc, r + 1))); 12501 } 12502 t.scrollIntoView(); 12503 } 12504 return !0; 12505 }).run(); 12506 } }; 12507 }, 12508 addInputRules() { 12509 return [Pd({ 12510 find: /^(?:---|â-|___\s|\*\*\*\s)$/, 12511 type: this.type 12512 })]; 12513 } 12514}), kp = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, Ap = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, jp = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, Mp = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, Np = dd.create({ 12515 name: "italic", 12516 addOptions() { 12517 return { HTMLAttributes: {} }; 12518 }, 12519 parseHTML() { 12520 return [ 12521 { tag: "em" }, 12522 { 12523 tag: "i", 12524 getAttrs: (e) => e.style.fontStyle !== "normal" && null 12525 }, 12526 { 12527 style: "font-style=normal", 12528 clearMark: (e) => e.type.name === this.name 12529 }, 12530 { style: "font-style=italic" } 12531 ]; 12532 }, 12533 renderHTML({ HTMLAttributes: e }) { 12534 return [ 12535 "em", 12536 B(this.options.HTMLAttributes, e), 12537 0 12538 ]; 12539 }, 12540 addCommands() { 12541 return { 12542 setItalic: () => ({ commands: e }) => e.setMark(this.name), 12543 toggleItalic: () => ({ commands: e }) => e.toggleMark(this.name), 12544 unsetItalic: () => ({ commands: e }) => e.unsetMark(this.name) 12545 }; 12546 }, 12547 markdownTokenName: "em", 12548 parseMarkdown: (e, t) => t.applyMark("italic", t.parseInline(e.tokens || [])), 12549 markdownOptions: { htmlReopen: { 12550 open: "<em>", 12551 close: "</em>" 12552 } }, 12553 renderMarkdown: (e, t) => `*${t.renderChildren(e)}*`, 12554 addKeyboardShortcuts() { 12555 return { 12556 "Mod-i": () => this.editor.commands.toggleItalic(), 12557 "Mod-I": () => this.editor.commands.toggleItalic() 12558 }; 12559 }, 12560 addInputRules() { 12561 return [Nd({ 12562 find: kp, 12563 type: this.type 12564 }), Nd({ 12565 find: jp, 12566 type: this.type 12567 })]; 12568 }, 12569 addPasteRules() { 12570 return [Ld({ 12571 find: Ap, 12572 type: this.type 12573 }), Ld({ 12574 find: Mp, 12575 type: this.type 12576 })]; 12577 } 12578}), Pp = "aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2
12578ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2", Fp = "ελ1Ï
2бг1ел3деÑи4еÑ2каÑолик6ом3мÐ
vendor: 87,395 bytes, lines 12578-15409
12578ºÐ´2он1Ñква6онлайн5Ñг3ÑÑÑ2Ñ2ÑайÑ3Ñб3ÑкÑ3Òаз3Õ°Õ¡Õµ3×שר××5×§××3Ø§Ø¨ÙØ¸Ø¨Ù5را٠ÙÙ5ÙØ§Ø±Ø¯Ù4Ø¨ØØ±ÙÙ5جزائر5Ø³Ø¹ÙØ¯ÙØ©6عÙÙØ§Ù5٠غرب5٠ارات5ÛØ±Ø§Ù5بارت2زار4ÙØªÙ3ھارت5تÙÙØ³4Ø³ÙØ¯Ø§Ù3Ø±ÙØ©5Ø´Ø¨ÙØ©4عراÙ2ب2٠اÙ4ÙÙØ³Ø·ÙÙ6ÙØ·Ø±3ÙØ§Ø«ÙÙÙÙ6ÙÙ 3٠صر2ÙÙØ³Ùا5ÙØ±ÙتاÙÙØ§7ÙØ¹4Ù٠راÙ5پاکستاÙ7ÚØ§Ø±Øª4à¤à¥à¤®3नà¥à¤3à¤à¤¾à¤°à¤¤0मà¥3à¥à¤¤5सà¤à¤à¤ न5বাà¦à¦²à¦¾5à¦à¦¾à¦°à¦¤2ৰত4à¨à¨¾à¨°à¨¤4àªàª¾àª°àª¤4à¬à¬¾à¬°à¬¤4à®à®¨à¯à®¤à®¿à®¯à®¾6லà®à¯à®à¯6à®à®¿à®à¯à®à®ªà¯à®ªà¯à®°à¯11à°à°¾à°°à°¤à±5à²à²¾à²°à²¤4à´à´¾à´°à´¤à´5à¶½à¶à¶à·4à¸à¸à¸¡3à¹à¸à¸¢3ລາວ3áá2ã¿ããª3ã¢ãã¾ã³4ã¯ã©ã¦ã4ã°ã¼ã°ã«4ã³ã 2ã¹ãã¢3ã»ã¼ã«3ãã¡ãã·ã§ã³6ãã¤ã³ã4ä¸ç2ä¸ä¿¡1å½1å1æç½3äºé©¬é3ä¼ä¸2ä½å±±2ä¿¡æ¯2å¥åº·2å «å¦2å ¬å¸1ç2å°æ¹¾1ç£2åå1åº1æ 2åé0大é åº5å¨çº¿2大æ¿2天主æ3娱ä¹2å®¶é»2广ä¸2å¾®å2æ å2æç±ä½ 3ææº2æè2æ¿å¡1åº2æ°å å¡2é»2æ¶å°2æ¸ç±2æºæ2淡马é¡3游æ2æ¾³é2ç¹ç2ç§»å¨2ç»ç»æºæ4ç½å1åº1ç«1ç»2èé2è°·æ2è´ç©2é販2éå¢2é»è¨çç§4é£å©æµ¦3é£å2é¤å 2馿 ¼éæ3港2ë·ë·1ì»´2ì¼ì±2íêµ2", Ip = "numeric", Lp = "ascii", Rp = "alpha", zp = "asciinumeric", Bp = "alphanumeric", Vp = "domain", Hp = "emoji", Up = "scheme", Wp = "slashscheme", Gp = "whitespace"; 12579function Kp(e, t) { 12580 return e in t || (t[e] = []), t[e]; 12581} 12582function qp(e, t, n) { 12583 t[Ip] && (t[zp] = !0, t[Bp] = !0), t[Lp] && (t[zp] = !0, t[Rp] = !0), t[zp] && (t[Bp] = !0), t[Rp] && (t[Bp] = !0), t[Bp] && (t[Vp] = !0), t[Hp] && (t[Vp] = !0); 12584 for (let r in t) { 12585 let t = Kp(r, n); 12586 t.indexOf(e) < 0 && t.push(e); 12587 } 12588} 12589function Jp(e, t) { 12590 let n = {}; 12591 for (let r in t) t[r].indexOf(e) >= 0 && (n[r] = !0); 12592 return n; 12593} 12594function J(e = null) { 12595 this.j = {}, this.jr = [], this.jd = null, this.t = e; 12596} 12597J.groups = {}, J.prototype = { 12598 accepts() { 12599 return !!this.t; 12600 }, 12601 go(e) { 12602 let t = this, n = t.j[e]; 12603 if (n) return n; 12604 for (let n = 0; n < t.jr.length; n++) { 12605 let r = t.jr[n][0], i = t.jr[n][1]; 12606 if (i && r.test(e)) return i; 12607 } 12608 return t.jd; 12609 }, 12610 has(e, t = !1) { 12611 return t ? e in this.j : !!this.go(e); 12612 }, 12613 ta(e, t, n, r) { 12614 for (let i = 0; i < e.length; i++) this.tt(e[i], t, n, r); 12615 }, 12616 tr(e, t, n, r) { 12617 r ||= J.groups; 12618 let i; 12619 return t && t.j ? i = t : (i = new J(t), n && r && qp(t, n, r)), this.jr.push([e, i]), i; 12620 }, 12621 ts(e, t, n, r) { 12622 let i = this, a = e.length; 12623 if (!a) return i; 12624 for (let t = 0; t < a - 1; t++) i = i.tt(e[t]); 12625 return i.tt(e[a - 1], t, n, r); 12626 }, 12627 tt(e, t, n, r) { 12628 r ||= J.groups; 12629 let i = this; 12630 if (t && t.j) return i.j[e] = t, t; 12631 let a = t, o, s = i.go(e); 12632 return s ? (o = new J(), Object.assign(o.j, s.j), o.jr.push.apply(o.jr, s.jr), o.jd = s.jd, o.t = s.t) : o = new J(), a && (r && (o.t && typeof o.t == "string" ? qp(a, Object.assign(Jp(o.t, r), n), r) : n && qp(a, n, r)), o.t = a), i.j[e] = o, o; 12633 } 12634}; 12635var Y = (e, t, n, r, i) => e.ta(t, n, r, i), X = (e, t, n, r, i) => e.tr(t, n, r, i), Yp = (e, t, n, r, i) => e.ts(t, n, r, i), Z = (e, t, n, r, i) => e.tt(t, n, r, i), Xp = "WORD", Zp = "UWORD", Qp = "ASCIINUMERICAL", $p = "ALPHANUMERICAL", em = "LOCALHOST", tm = "TLD", nm = "UTLD", rm = "SCHEME", im = "SLASH_SCHEME", am = "NUM", om = "WS", sm = "NL", cm = "OPENBRACE", lm = "CLOSEBRACE", um = "OPENBRACKET", dm = "CLOSEBRACKET", fm = "OPENPAREN", pm = "CLOSEPAREN", mm = "OPENANGLEBRACKET", hm = "CLOSEANGLEBRACKET", gm = "FULLWIDTHLEFTPAREN", _m = "FULLWIDTHRIGHTPAREN", vm = "LEFTCORNERBRACKET", ym = "RIGHTCORNERBRACKET", bm = "LEFTWHITECORNERBRACKET", xm = "RIGHTWHITECORNERBRACKET", Sm = "FULLWIDTHLESSTHAN", Cm = "FULLWIDTHGREATERTHAN", wm = "AMPERSAND", Tm = "APOSTROPHE", Em = "ASTERISK", Dm = "AT", Om = "BACKSLASH", km = "BACKTICK", Am = "CARET", jm = "COLON", Mm = "COMMA", Nm = "DOLLAR", Pm = "DOT", Fm = "EQUALS", Im = "EXCLAMATION", Lm = "HYPHEN", Rm = "PERCENT", zm = "PIPE", Bm = "PLUS", Vm = "POUND", Hm = "QUERY", Um = "QUOTE", Wm = "FULLWIDTHMIDDLEDOT", Gm = "SEMI", Km = "SLASH", qm = "TILDE", Jm = "UNDERSCORE", Ym = "EMOJI", Xm = "SYM", Zm = /*#__PURE__*/ Object.freeze({ 12636 __proto__: null, 12637 ALPHANUMERICAL: $p, 12638 AMPERSAND: wm, 12639 APOSTROPHE: Tm, 12640 ASCIINUMERICAL: Qp, 12641 ASTERISK: Em, 12642 AT: Dm, 12643 BACKSLASH: Om, 12644 BACKTICK: km, 12645 CARET: Am, 12646 CLOSEANGLEBRACKET: hm, 12647 CLOSEBRACE: lm, 12648 CLOSEBRACKET: dm, 12649 CLOSEPAREN: pm, 12650 COLON: jm, 12651 COMMA: Mm, 12652 DOLLAR: Nm, 12653 DOT: Pm, 12654 EMOJI: Ym, 12655 EQUALS: Fm, 12656 EXCLAMATION: Im, 12657 FULLWIDTHGREATERTHAN: Cm, 12658 FULLWIDTHLEFTPAREN: gm, 12659 FULLWIDTHLESSTHAN: Sm, 12660 FULLWIDTHMIDDLEDOT: Wm, 12661 FULLWIDTHRIGHTPAREN: _m, 12662 HYPHEN: Lm, 12663 LEFTCORNERBRACKET: vm, 12664 LEFTWHITECORNERBRACKET: bm, 12665 LOCALHOST: em, 12666 NL: sm, 12667 NUM: am, 12668 OPENANGLEBRACKET: mm, 12669 OPENBRACE: cm, 12670 OPENBRACKET: um, 12671 OPENPAREN: fm, 12672 PERCENT: Rm, 12673 PIPE: zm, 12674 PLUS: Bm, 12675 POUND: Vm, 12676 QUERY: Hm, 12677 QUOTE: Um, 12678 RIGHTCORNERBRACKET: ym, 12679 RIGHTWHITECORNERBRACKET: xm, 12680 SCHEME: rm, 12681 SEMI: Gm, 12682 SLASH: Km, 12683 SLASH_SCHEME: im, 12684 SYM: Xm, 12685 TILDE: qm, 12686 TLD: tm, 12687 UNDERSCORE: Jm, 12688 UTLD: nm, 12689 UWORD: Zp, 12690 WORD: Xp, 12691 WS: om 12692}), Qm = /[a-z]/, $m = /\p{L}/u, eh = /\p{Emoji}/u, th = /\d/, nh = /\s/, rh = "\r", ih = "\n", ah = "ï¸", oh = "â", sh = "", ch = null, lh = null; 12693function uh(e = []) { 12694 let t = {}; 12695 J.groups = t; 12696 let n = new J(); 12697 ch ??= mh(Pp), lh ??= mh(Fp), Z(n, "'", Tm), Z(n, "{", cm), Z(n, "}", lm), Z(n, "[", um), Z(n, "]", dm), Z(n, "(", fm), Z(n, ")", pm), Z(n, "<", mm), Z(n, ">", hm), Z(n, "ï¼", gm), Z(n, "ï¼", _m), Z(n, "ã", vm), Z(n, "ã", ym), Z(n, "ã", bm), Z(n, "ã", xm), Z(n, "ï¼", Sm), Z(n, "ï¼", Cm), Z(n, "&", wm), Z(n, "*", Em), Z(n, "@", Dm), Z(n, "`", km), Z(n, "^", Am), Z(n, ":", jm), Z(n, ",", Mm), Z(n, "$", Nm), Z(n, ".", Pm), Z(n, "=", Fm), Z(n, "!", Im), Z(n, "-", Lm), Z(n, "%", Rm), Z(n, "|", zm), Z(n, "+", Bm), Z(n, "#", Vm), Z(n, "?", Hm), Z(n, "\"", Um), Z(n, "/", Km), Z(n, ";", Gm), Z(n, "~", qm), Z(n, "_", Jm), Z(n, "\\", Om), Z(n, "ã»", Wm); 12698 let r = X(n, th, am, { [Ip]: !0 }); 12699 X(r, th, r); 12700 let i = X(r, Qm, Qp, { [zp]: !0 }), a = X(r, $m, $p, { [Bp]: !0 }), o = X(n, Qm, Xp, { [Lp]: !0 }); 12701 X(o, th, i), X(o, Qm, o), X(i, th, i), X(i, Qm, i); 12702 let s = X(n, $m, Zp, { [Rp]: !0 }); 12703 X(s, Qm), X(s, th, a), X(s, $m, s), X(a, th, a), X(a, Qm), X(a, $m, a); 12704 let c = Z(n, ih, sm, { [Gp]: !0 }), l = Z(n, rh, om, { [Gp]: !0 }), u = X(n, nh, om, { [Gp]: !0 }); 12705 Z(n, sh, u), Z(l, ih, c), Z(l, sh, u), X(l, nh, u), Z(u, rh), Z(u, ih), X(u, nh, u), Z(u, sh, u); 12706 let d = X(n, eh, Ym, { [Hp]: !0 }); 12707 Z(d, "#"), X(d, eh, d), Z(d, ah, d); 12708 let f = Z(d, oh); 12709 Z(f, "#"), X(f, eh, d); 12710 let p = [[Qm, o], [th, i]], m = [ 12711 [Qm, null], 12712 [$m, s], 12713 [th, a] 12714 ]; 12715 for (let e = 0; e < ch.length; e++) ph(n, ch[e], tm, Xp, p); 12716 for (let e = 0; e < lh.length; e++) ph(n, lh[e], nm, Zp, m); 12717 qp(tm, { 12718 tld: !0, 12719 ascii: !0 12720 }, t), qp(nm, { 12721 utld: !0, 12722 alpha: !0 12723 }, t), ph(n, "file", rm, Xp, p), ph(n, "mailto", rm, Xp, p), ph(n, "http", im, Xp, p), ph(n, "https", im, Xp, p), ph(n, "ftp", im, Xp, p), ph(n, "ftps", im, Xp, p), qp(rm, { 12724 scheme: !0, 12725 ascii: !0 12726 }, t), qp(im, { 12727 slashscheme: !0, 12728 ascii: !0 12729 }, t), e = e.sort((e, t) => e[0] > t[0] ? 1 : -1); 12730 for (let t = 0; t < e.length; t++) { 12731 let r = e[t][0], i = e[t][1] ? { [Up]: !0 } : { [Wp]: !0 }; 12732 r.indexOf("-") >= 0 ? i[Vp] = !0 : Qm.test(r) ? th.test(r) ? i[zp] = !0 : i[Lp] = !0 : i[Ip] = !0, Yp(n, r, r, i); 12733 } 12734 return Yp(n, "localhost", em, { ascii: !0 }), n.jd = new J(Xm), { 12735 start: n, 12736 tokens: Object.assign({ groups: t }, Zm) 12737 }; 12738} 12739function dh(e, t) { 12740 let n = fh(t.replace(/[A-Z]/g, (e) => e.toLowerCase())), r = n.length, i = [], a = 0, o = 0; 12741 for (; o < r;) { 12742 let s = e, c = null, l = 0, u = null, d = -1, f = -1; 12743 for (; o < r && (c = s.go(n[o]));) s = c, s.accepts() ? (d = 0, f = 0, u = s) : d >= 0 && (d += n[o].length, f++), l += n[o].length, a += n[o].length, o++; 12744 a -= d, o -= f, l -= d, i.push({ 12745 t: u.t, 12746 v: t.slice(a - l, a), 12747 s: a - l, 12748 e: a 12749 }); 12750 } 12751 return i; 12752} 12753function fh(e) { 12754 let t = [], n = e.length, r = 0; 12755 for (; r < n;) { 12756 let i = e.charCodeAt(r), a, o = i < 55296 || i > 56319 || r + 1 === n || (a = e.charCodeAt(r + 1)) < 56320 || a > 57343 ? e[r] : e.slice(r, r + 2); 12757 t.push(o), r += o.length; 12758 } 12759 return t; 12760} 12761function ph(e, t, n, r, i) { 12762 let a, o = t.length; 12763 for (let n = 0; n < o - 1; n++) { 12764 let o = t[n]; 12765 e.j[o] ? a = e.j[o] : (a = new J(r), a.jr = i.slice(), e.j[o] = a), e = a; 12766 } 12767 return a = new J(n), a.jr = i.slice(), e.j[t[o - 1]] = a, a; 12768} 12769function mh(e) { 12770 let t = [], n = [], r = 0; 12771 for (; r < e.length;) { 12772 let i = 0; 12773 for (; "0123456789".indexOf(e[r + i]) >= 0;) i++; 12774 if (i > 0) { 12775 t.push(n.join("")); 12776 for (let t = parseInt(e.substring(r, r + i), 10); t > 0; t--) n.pop(); 12777 r += i; 12778 } else n.push(e[r]), r++; 12779 } 12780 return t; 12781} 12782var hh = { 12783 defaultProtocol: "http", 12784 events: null, 12785 format: _h, 12786 formatHref: _h, 12787 nl2br: !1, 12788 tagName: "a", 12789 target: null, 12790 rel: null, 12791 validate: !0, 12792 truncate: Infinity, 12793 className: null, 12794 attributes: null, 12795 ignoreTags: [], 12796 render: null 12797}; 12798function gh(e, t = null) { 12799 let n = Object.assign({}, hh); 12800 e && (n = Object.assign(n, e instanceof gh ? e.o : e)); 12801 let r = n.ignoreTags, i = []; 12802 for (let e = 0; e < r.length; e++) i.push(r[e].toUpperCase()); 12803 this.o = n, t && (this.defaultRender = t), this.ignoreTags = i; 12804} 12805gh.prototype = { 12806 o: hh, 12807 ignoreTags: [], 12808 defaultRender(e) { 12809 return e; 12810 }, 12811 check(e) { 12812 return this.get("validate", e.toString(), e); 12813 }, 12814 get(e, t, n) { 12815 let r = t != null, i = this.o[e]; 12816 return i && (typeof i == "object" ? (i = n.t in i ? i[n.t] : hh[e], typeof i == "function" && r && (i = i(t, n))) : typeof i == "function" && r && (i = i(t, n.t, n)), i); 12817 }, 12818 getObj(e, t, n) { 12819 let r = this.o[e]; 12820 return typeof r == "function" && t != null && (r = r(t, n.t, n)), r; 12821 }, 12822 render(e) { 12823 let t = e.render(this); 12824 return (this.get("render", null, e) || this.defaultRender)(t, e.t, e); 12825 } 12826}; 12827function _h(e) { 12828 return e; 12829} 12830function vh(e, t) { 12831 this.t = "token", this.v = e, this.tk = t; 12832} 12833vh.prototype = { 12834 isLink: !1, 12835 toString() { 12836 return this.v; 12837 }, 12838 toHref(e) { 12839 return this.toString(); 12840 }, 12841 toFormattedString(e) { 12842 let t = this.toString(), n = e.get("truncate", t, this), r = e.get("format", t, this); 12843 return n && r.length > n ? r.substring(0, n) + "â¦" : r; 12844 }, 12845 toFormattedHref(e) { 12846 return e.get("formatHref", this.toHref(e.get("defaultProtocol")), this); 12847 }, 12848 startIndex() { 12849 return this.tk[0].s; 12850 }, 12851 endIndex() { 12852 return this.tk[this.tk.length - 1].e; 12853 }, 12854 toObject(e = hh.defaultProtocol) { 12855 return { 12856 type: this.t, 12857 value: this.toString(), 12858 isLink: this.isLink, 12859 href: this.toHref(e), 12860 start: this.startIndex(), 12861 end: this.endIndex() 12862 }; 12863 }, 12864 toFormattedObject(e) { 12865 return { 12866 type: this.t, 12867 value: this.toFormattedString(e), 12868 isLink: this.isLink, 12869 href: this.toFormattedHref(e), 12870 start: this.startIndex(), 12871 end: this.endIndex() 12872 }; 12873 }, 12874 validate(e) { 12875 return e.get("validate", this.toString(), this); 12876 }, 12877 render(e) { 12878 let t = this, n = this.toHref(e.get("defaultProtocol")), r = e.get("formatHref", n, this), i = e.get("tagName", n, t), a = this.toFormattedString(e), o = {}, s = e.get("className", n, t), c = e.get("target", n, t), l = e.get("rel", n, t), u = e.getObj("attributes", n, t), d = e.getObj("events", n, t); 12879 return o.href = r, s && (o.class = s), c && (o.target = c), l && (o.rel = l), u && Object.assign(o, u), { 12880 tagName: i, 12881 attributes: o, 12882 content: a, 12883 eventListeners: d 12884 }; 12885 } 12886}; 12887function yh(e, t) { 12888 class n extends vh { 12889 constructor(t, n) { 12890 super(t, n), this.t = e; 12891 } 12892 } 12893 for (let e in t) n.prototype[e] = t[e]; 12894 return n.t = e, n; 12895} 12896var bh = yh("email", { 12897 isLink: !0, 12898 toHref() { 12899 return "mailto:" + this.toString(); 12900 } 12901}), xh = yh("text"), Sh = yh("nl"), Ch = yh("url", { 12902 isLink: !0, 12903 toHref(e = hh.defaultProtocol) { 12904 return this.hasProtocol() ? this.v : `${e}://${this.v}`; 12905 }, 12906 hasProtocol() { 12907 let e = this.tk; 12908 return e.length >= 2 && e[0].t !== em && e[1].t === jm; 12909 } 12910}), wh = (e) => new J(e); 12911function Th({ groups: e }) { 12912 let t = e.domain.concat([ 12913 wm, 12914 Em, 12915 Dm, 12916 Om, 12917 km, 12918 Am, 12919 Nm, 12920 Fm, 12921 Lm, 12922 am, 12923 Rm, 12924 zm, 12925 Bm, 12926 Vm, 12927 Km, 12928 Xm, 12929 qm, 12930 Jm 12931 ]), n = [ 12932 Tm, 12933 jm, 12934 Mm, 12935 Pm, 12936 Im, 12937 Rm, 12938 Hm, 12939 Um, 12940 Gm, 12941 mm, 12942 hm, 12943 cm, 12944 lm, 12945 dm, 12946 um, 12947 fm, 12948 pm, 12949 gm, 12950 _m, 12951 vm, 12952 ym, 12953 bm, 12954 xm, 12955 Sm, 12956 Cm 12957 ], r = [ 12958 wm, 12959 Tm, 12960 Em, 12961 Om, 12962 km, 12963 Am, 12964 Nm, 12965 Fm, 12966 Lm, 12967 cm, 12968 lm, 12969 Rm, 12970 zm, 12971 Bm, 12972 Vm, 12973 Hm, 12974 Km, 12975 Xm, 12976 qm, 12977 Jm 12978 ], i = wh(), a = Z(i, qm); 12979 Y(a, r, a), Y(a, e.domain, a); 12980 let o = wh(), s = wh(), c = wh(); 12981 Y(i, e.domain, o), Y(i, e.scheme, s), Y(i, e.slashscheme, c), Y(o, r, a), Y(o, e.domain, o); 12982 let l = Z(o, Dm); 12983 Z(a, Dm, l), Z(s, Dm, l), Z(c, Dm, l); 12984 let u = Z(a, Pm); 12985 Y(u, r, a), Y(u, e.domain, a); 12986 let d = wh(); 12987 Y(l, e.domain, d), Y(d, e.domain, d); 12988 let f = Z(d, Pm); 12989 Y(f, e.domain, d); 12990 let p = wh(bh); 12991 Y(f, e.tld, p), Y(f, e.utld, p), Z(l, em, p); 12992 let m = Z(d, Lm); 12993 Z(m, Lm, m), Y(m, e.domain, d), Y(p, e.domain, d), Z(p, Pm, f), Z(p, Lm, m); 12994 let h = Z(o, Lm), g = Z(o, Pm); 12995 Z(h, Lm, h), Y(h, e.domain, o), Y(g, r, a), Y(g, e.domain, o); 12996 let _ = wh(Ch); 12997 Y(g, e.tld, _), Y(g, e.utld, _), Y(_, e.domain, o), Y(_, r, a), Z(_, Pm, g), Z(_, Lm, h), Z(_, Dm, l); 12998 let ee = Z(_, jm), v = wh(Ch); 12999 Y(ee, e.numeric, v); 13000 let y = wh(Ch), b = wh(); 13001 Y(y, t, y), Y(y, n, b), Y(b, t, y), Y(b, n, b), Z(_, Km, y), Z(v, Km, y); 13002 let te = Z(s, jm), ne = Z(Z(Z(c, jm), Km), Km); 13003 Y(s, e.domain, o), Z(s, Pm, g), Z(s, Lm, h), Y(c, e.domain, o), Z(c, Pm, g), Z(c, Lm, h), Y(te, e.domain, y), Z(te, Km, y), Z(te, Hm, y), Y(ne, e.domain, y), Y(ne, t, y), Z(ne, Km, y); 13004 let re = [ 13005 [cm, lm], 13006 [um, dm], 13007 [fm, pm], 13008 [mm, hm], 13009 [gm, _m], 13010 [vm, ym], 13011 [bm, xm], 13012 [Sm, Cm] 13013 ]; 13014 for (let e = 0; e < re.length; e++) { 13015 let [r, i] = re[e], a = Z(y, r); 13016 Z(b, r, a); 13017 let o = wh(Ch); 13018 Y(a, t, o); 13019 let s = wh(); 13020 Y(a, n, s), Z(a, i, y), Y(o, t, o), Y(o, n, s), Y(s, t, o), Y(s, n, s), Z(o, i, y), Z(s, i, y); 13021 } 13022 return Z(i, em, _), Z(i, sm, Sh), { 13023 start: i, 13024 tokens: Zm 13025 }; 13026} 13027function Eh(e, t, n) { 13028 let r = n.length, i = 0, a = [], o = []; 13029 for (; i < r;) { 13030 let s = e, c = null, l = null, u = 0, d = null, f = -1; 13031 for (; i < r && !(c = s.go(n[i].t));) o.push(n[i++]); 13032 for (; i < r && (l = c || s.go(n[i].t));) c = null, s = l, s.accepts() ? (f = 0, d = s) : f >= 0 && f++, i++, u++; 13033 if (f < 0) i -= u, i < r && (o.push(n[i]), i++); 13034 else { 13035 o.length > 0 && (a.push(Dh(xh, t, o)), o = []), i -= f, u -= f; 13036 let e = d.t, r = n.slice(i - u, i); 13037 a.push(Dh(e, t, r)); 13038 } 13039 } 13040 return o.length > 0 && a.push(Dh(xh, t, o)), a; 13041} 13042function Dh(e, t, n) { 13043 let r = n[0].s, i = n[n.length - 1].e; 13044 return new e(t.slice(r, i), n); 13045} 13046var Oh = typeof console < "u" && console && console.warn || (() => {}), kh = "until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.", Q = { 13047 scanner: null, 13048 parser: null, 13049 tokenQueue: [], 13050 pluginQueue: [], 13051 customSchemes: [], 13052 initialized: !1 13053}; 13054function Ah() { 13055 return J.groups = {}, Q.scanner = null, Q.parser = null, Q.tokenQueue = [], Q.pluginQueue = [], Q.customSchemes = [], Q.initialized = !1, Q; 13056} 13057function jh(e, t = !1) { 13058 if (Q.initialized && Oh(`linkifyjs: already initialized - will not register custom scheme "${e}" ${kh}`), !/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e)) throw Error("linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or \"-\"\n2. Cannot start or end with \"-\"\n3. \"-\" cannot repeat"); 13059 Q.customSchemes.push([e, t]); 13060} 13061function Mh() { 13062 Q.scanner = uh(Q.customSchemes); 13063 for (let e = 0; e < Q.tokenQueue.length; e++) Q.tokenQueue[e][1]({ scanner: Q.scanner }); 13064 Q.parser = Th(Q.scanner.tokens); 13065 for (let e = 0; e < Q.pluginQueue.length; e++) Q.pluginQueue[e][1]({ 13066 scanner: Q.scanner, 13067 parser: Q.parser 13068 }); 13069 return Q.initialized = !0, Q; 13070} 13071function Nh(e) { 13072 return Q.initialized || Mh(), Eh(Q.parser.start, e, dh(Q.scanner.start, e)); 13073} 13074Nh.scan = dh; 13075function Ph(e, t = null, n = null) { 13076 if (t && typeof t == "object") { 13077 if (n) throw Error(`linkifyjs: Invalid link type ${t}; must be a string`); 13078 n = t, t = null; 13079 } 13080 let r = new gh(n), i = Nh(e), a = []; 13081 for (let e = 0; e < i.length; e++) { 13082 let n = i[e]; 13083 n.isLink && (!t || n.t === t) && r.check(n) && a.push(n.toFormattedObject(r)); 13084 } 13085 return a; 13086} 13087//#endregion 13088//#region node_modules/@tiptap/extension-link/dist/index.js 13089var Fh = "[\0- \xA0áá â-\u2029âã]", Ih = new RegExp(Fh), Lh = RegExp(`${Fh}$`), Rh = new RegExp(Fh, "g"); 13090function zh(e) { 13091 return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1; 13092} 13093function Bh(e) { 13094 return new D({ 13095 key: new O("autolink"), 13096 appendTransaction: (t, n, r) => { 13097 let i = t.some((e) => e.docChanged) && !n.doc.eq(r.doc), a = t.some((e) => e.getMeta("preventAutolink")); 13098 if (!i || a) return; 13099 let { tr: o } = r; 13100 if ($l(wl(n.doc, [...t])).forEach(({ newRange: t }) => { 13101 let n = El(r.doc, t, (e) => e.isTextblock), i, a; 13102 if (n.length > 1) i = n[0], a = r.doc.textBetween(i.pos, i.pos + i.node.nodeSize, void 0, " "); 13103 else if (n.length) { 13104 let e = r.doc.textBetween(t.from, t.to, " ", " "); 13105 if (!Lh.test(e)) return; 13106 i = n[0], a = r.doc.textBetween(i.pos, t.to, void 0, " "); 13107 } 13108 if (i && a) { 13109 let t = a.split(Ih).filter(Boolean); 13110 if (t.length <= 0) return !1; 13111 let n = t[t.length - 1], s = i.pos + a.lastIndexOf(n); 13112 if (!n) return !1; 13113 let c = Nh(n).map((t) => t.toObject(e.defaultProtocol)); 13114 if (!zh(c)) return !1; 13115 c.filter((e) => e.isLink).map((e) => ({ 13116 ...e, 13117 from: s + e.start + 1, 13118 to: s + e.end + 1 13119 })).filter((e) => r.schema.marks.code ? !r.doc.rangeHasMark(e.from, e.to, r.schema.marks.code) : !0).filter((t) => e.validate(t.value)).filter((t) => e.shouldAutoLink(t.value)).forEach((t) => { 13120 eu(t.from, t.to, r.doc).some((t) => t.mark.type === e.type) || o.addMark(t.from, t.to, e.type.create({ href: t.href })); 13121 }); 13122 } 13123 }), o.steps.length) return o; 13124 } 13125 }); 13126} 13127function Vh(e) { 13128 return new D({ 13129 key: new O("handleClickLink"), 13130 props: { handleClick: (t, n, r) => { 13131 if (r.button !== 0 || !t.editable) return !1; 13132 let i = null; 13133 if (r.target instanceof HTMLAnchorElement) i = r.target; 13134 else { 13135 let t = r.target; 13136 if (!t) return !1; 13137 let n = e.editor.view.dom; 13138 i = t.closest("a"), i && !n.contains(i) && (i = null); 13139 } 13140 if (!i) return !1; 13141 let a = !1; 13142 if (e.enableClickSelection && (a = e.editor.commands.extendMarkRange(e.type.name)), e.openOnClick) { 13143 let n = Xl(t.state, e.type.name), r = i.href ?? n.href, o = i.target ?? n.target; 13144 r && (window.open(r, o), a = !0); 13145 } 13146 return a; 13147 } } 13148 }); 13149} 13150function Hh(e) { 13151 return new D({ 13152 key: new O("handlePasteLink"), 13153 props: { handlePaste: (t, n, r) => { 13154 let { shouldAutoLink: i } = e, { state: a } = t, { selection: o } = a, { empty: s } = o; 13155 if (s) return !1; 13156 let c = ""; 13157 r.content.forEach((e) => { 13158 c += e.textContent; 13159 }); 13160 let l = Ph(c, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === c); 13161 return !c || !l || i !== void 0 && !i(l.value) ? !1 : e.editor.commands.setMark(e.type, { href: l.href }); 13162 } } 13163 }); 13164} 13165function Uh(e, t) { 13166 let n = [ 13167 "http", 13168 "https", 13169 "ftp", 13170 "ftps", 13171 "mailto", 13172 "tel", 13173 "callto", 13174 "sms", 13175 "cid", 13176 "xmpp" 13177 ]; 13178 return t && t.forEach((e) => { 13179 let t = typeof e == "string" ? e : e.scheme; 13180 t && n.push(t); 13181 }), !e || e.replace(Rh, "").match(RegExp(`^(?:(?:${n.map((e) => e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`, "i")); 13182} 13183var Wh = dd.create({ 13184 name: "link", 13185 priority: 1e3, 13186 keepOnSplit: !1, 13187 exitable: !0, 13188 onCreate() { 13189 this.options.validate && !this.options.shouldAutoLink && (this.options.shouldAutoLink = this.options.validate, console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")), this.options.protocols.forEach((e) => { 13190 if (typeof e == "string") { 13191 jh(e); 13192 return; 13193 } 13194 jh(e.scheme, e.optionalSlashes); 13195 }); 13196 }, 13197 onDestroy() { 13198 Ah(); 13199 }, 13200 inclusive() { 13201 return this.options.autolink; 13202 }, 13203 addOptions() { 13204 return { 13205 openOnClick: !0, 13206 enableClickSelection: !1, 13207 linkOnPaste: !0, 13208 autolink: !0, 13209 protocols: [], 13210 defaultProtocol: "http", 13211 HTMLAttributes: { 13212 target: "_blank", 13213 rel: "noopener noreferrer nofollow", 13214 class: null 13215 }, 13216 isAllowedUri: (e, t) => !!Uh(e, t.protocols), 13217 validate: (e) => !!e, 13218 shouldAutoLink: (e) => { 13219 let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e); 13220 if (t || n && !e.includes("@")) return !0; 13221 let r = (e.includes("@") ? e.split("@").pop() : e).split(/[/?#:]/)[0]; 13222 return !(/^\d{1,3}(\.\d{1,3}){3}$/.test(r) || !/\./.test(r)); 13223 } 13224 }; 13225 }, 13226 addAttributes() { 13227 return { 13228 href: { 13229 default: null, 13230 parseHTML(e) { 13231 return e.getAttribute("href"); 13232 } 13233 }, 13234 target: { default: this.options.HTMLAttributes.target }, 13235 rel: { default: this.options.HTMLAttributes.rel }, 13236 class: { default: this.options.HTMLAttributes.class }, 13237 title: { default: null } 13238 }; 13239 }, 13240 parseHTML() { 13241 return [{ 13242 tag: "a[href]", 13243 getAttrs: (e) => { 13244 let t = e.getAttribute("href"); 13245 return !t || !this.options.isAllowedUri(t, { 13246 defaultValidate: (e) => !!Uh(e, this.options.protocols), 13247 protocols: this.options.protocols, 13248 defaultProtocol: this.options.defaultProtocol 13249 }) ? !1 : null; 13250 } 13251 }]; 13252 }, 13253 renderHTML({ HTMLAttributes: e }) { 13254 return this.options.isAllowedUri(e.href, { 13255 defaultValidate: (e) => !!Uh(e, this.options.protocols), 13256 protocols: this.options.protocols, 13257 defaultProtocol: this.options.defaultProtocol 13258 }) ? [ 13259 "a", 13260 B(this.options.HTMLAttributes, e), 13261 0 13262 ] : [ 13263 "a", 13264 B(this.options.HTMLAttributes, { 13265 ...e, 13266 href: "" 13267 }), 13268 0 13269 ]; 13270 }, 13271 markdownTokenName: "link", 13272 parseMarkdown: (e, t) => t.applyMark("link", t.parseInline(e.tokens || []), { 13273 href: e.href, 13274 title: e.title || null 13275 }), 13276 renderMarkdown: (e, t) => { 13277 let n = e.attrs?.href ?? "", r = e.attrs?.title ?? "", i = t.renderChildren(e); 13278 return r ? `[${i}](${n} "${r}")` : `[${i}](${n})`; 13279 }, 13280 addCommands() { 13281 return { 13282 setLink: (e) => ({ chain: t }) => { 13283 let { href: n } = e; 13284 return this.options.isAllowedUri(n, { 13285 defaultValidate: (e) => !!Uh(e, this.options.protocols), 13286 protocols: this.options.protocols, 13287 defaultProtocol: this.options.defaultProtocol 13288 }) ? t().setMark(this.name, e).setMeta("preventAutolink", !0).run() : !1; 13289 }, 13290 toggleLink: (e) => ({ chain: t }) => { 13291 let { href: n } = e || {}; 13292 return n && !this.options.isAllowedUri(n, { 13293 defaultValidate: (e) => !!Uh(e, this.options.protocols), 13294 protocols: this.options.protocols, 13295 defaultProtocol: this.options.defaultProtocol 13296 }) ? !1 : t().toggleMark(this.name, e, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run(); 13297 }, 13298 unsetLink: () => ({ chain: e }) => e().unsetMark(this.name, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run() 13299 }; 13300 }, 13301 addPasteRules() { 13302 return [Ld({ 13303 find: (e) => { 13304 let t = []; 13305 if (e) { 13306 let { protocols: n, defaultProtocol: r } = this.options, i = Ph(e).filter((e) => e.isLink && this.options.isAllowedUri(e.value, { 13307 defaultValidate: (e) => !!Uh(e, n), 13308 protocols: n, 13309 defaultProtocol: r 13310 })); 13311 i.length && i.forEach((e) => { 13312 this.options.shouldAutoLink(e.value) && t.push({ 13313 text: e.value, 13314 data: { href: e.href }, 13315 index: e.start 13316 }); 13317 }); 13318 } 13319 return t; 13320 }, 13321 type: this.type, 13322 getAttributes: (e) => ({ href: e.data?.href }) 13323 })]; 13324 }, 13325 addProseMirrorPlugins() { 13326 let e = [], { protocols: t, defaultProtocol: n } = this.options; 13327 return this.options.autolink && e.push(Bh({ 13328 type: this.type, 13329 defaultProtocol: this.options.defaultProtocol, 13330 validate: (e) => this.options.isAllowedUri(e, { 13331 defaultValidate: (e) => !!Uh(e, t), 13332 protocols: t, 13333 defaultProtocol: n 13334 }), 13335 shouldAutoLink: this.options.shouldAutoLink 13336 })), e.push(Vh({ 13337 type: this.type, 13338 editor: this.editor, 13339 openOnClick: this.options.openOnClick === "whenNotEditable" ? !0 : this.options.openOnClick, 13340 enableClickSelection: this.options.enableClickSelection 13341 })), this.options.linkOnPaste && e.push(Hh({ 13342 editor: this.editor, 13343 defaultProtocol: this.options.defaultProtocol, 13344 type: this.type, 13345 shouldAutoLink: this.options.shouldAutoLink 13346 })), e; 13347 } 13348}), Gh = Object.defineProperty, Kh = (e, t) => { 13349 for (var n in t) Gh(e, n, { 13350 get: t[n], 13351 enumerable: !0 13352 }); 13353}, qh = "listItem", Jh = "textStyle", Yh = /^\s*([-+*])\s$/, Xh = H.create({ 13354 name: "bulletList", 13355 addOptions() { 13356 return { 13357 itemTypeName: "listItem", 13358 HTMLAttributes: {}, 13359 keepMarks: !1, 13360 keepAttributes: !1 13361 }; 13362 }, 13363 group: "block list", 13364 content() { 13365 return `${this.options.itemTypeName}+`; 13366 }, 13367 parseHTML() { 13368 return [{ tag: "ul" }]; 13369 }, 13370 renderHTML({ HTMLAttributes: e }) { 13371 return [ 13372 "ul", 13373 B(this.options.HTMLAttributes, e), 13374 0 13375 ]; 13376 }, 13377 markdownTokenName: "list", 13378 parseMarkdown: (e, t) => e.type !== "list" || e.ordered ? [] : { 13379 type: "bulletList", 13380 content: e.items ? t.parseChildren(e.items) : [] 13381 }, 13382 renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n") : "", 13383 markdownOptions: { indentsContent: !0 }, 13384 addCommands() { 13385 return { toggleBulletList: () => ({ commands: e, chain: t }) => this.options.keepAttributes ? t().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(qh, this.editor.getAttributes(Jh)).run() : e.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks) }; 13386 }, 13387 addKeyboardShortcuts() { 13388 return { "Mod-Shift-8": () => this.editor.commands.toggleBulletList() }; 13389 }, 13390 addInputRules() { 13391 let e = Id({ 13392 find: Yh, 13393 type: this.type 13394 }); 13395 return (this.options.keepMarks || this.options.keepAttributes) && (e = Id({ 13396 find: Yh, 13397 type: this.type, 13398 keepMarks: this.options.keepMarks, 13399 keepAttributes: this.options.keepAttributes, 13400 getAttributes: () => this.editor.getAttributes(Jh), 13401 editor: this.editor 13402 })), [e]; 13403 } 13404}), Zh = (e, t, n) => { 13405 let { selection: r } = e; 13406 if (!r.empty) return null; 13407 let { $from: i } = r; 13408 if (!i.parent.isTextblock || i.parentOffset !== i.parent.content.size) return null; 13409 let a = -1; 13410 for (let e = i.depth; e > 0; --e) if (i.node(e).type.name === t) { 13411 a = e; 13412 break; 13413 } 13414 if (a < 0) return null; 13415 let o = i.node(a), s = i.index(a); 13416 if (s + 1 >= o.childCount) return null; 13417 let c = o.child(s + 1); 13418 if (!n.includes(c.type.name)) return null; 13419 let l = e.schema.nodes[t], u = !1; 13420 if (c.forEach((e) => { 13421 e.type === l && e.childCount > 1 && (u = !0); 13422 }), !u) return null; 13423 let d = e.doc.resolve(i.after()).nodeAfter; 13424 if (!d || !n.includes(d.type.name)) return null; 13425 let f = []; 13426 return d.forEach((e) => { 13427 f.push(e); 13428 }), f.length === 0 ? null : { 13429 listItemDepth: a, 13430 nestedList: d, 13431 nestedListPos: i.after(), 13432 insertPos: i.after(a), 13433 items: f 13434 }; 13435}, Qh = (e, t, n, r) => { 13436 let i = Zh(e, n, r); 13437 if (!i) return !1; 13438 let { selection: o } = e, { nestedList: s, nestedListPos: c, insertPos: l, items: u } = i, d = e.tr; 13439 d.delete(c, c + s.nodeSize); 13440 let f = d.mapping.map(l); 13441 return d.insert(f, a.from(u)), d.setSelection(o.map(d.doc, d.mapping)), t && t(d), !0; 13442}, $h = (e, t, n) => Qh(e.state, e.view.dispatch, t, n), eg = (e, t) => V.create({ 13443 name: `${e}BranchingDeleteKeymap`, 13444 priority: 101, 13445 addKeyboardShortcuts() { 13446 let n = () => $h(this.editor, e, t); 13447 return { 13448 Delete: n, 13449 "Mod-Delete": n 13450 }; 13451 } 13452}), tg = [ 13453 [1e3, "m"], 13454 [900, "cm"], 13455 [500, "d"], 13456 [400, "cd"], 13457 [100, "c"], 13458 [90, "xc"], 13459 [50, "l"], 13460 [40, "xl"], 13461 [10, "x"], 13462 [9, "ix"], 13463 [5, "v"], 13464 [4, "iv"], 13465 [1, "i"] 13466], ng = "abcdefghijklmnopqrstuvwxyz", rg = String.raw`\d+|[ivxlcdmIVXLCDM]+|${"[a-zA-Z]{1,2}"}`; 13467function ig(e) { 13468 let t = e, n = ""; 13469 for (let [e, r] of tg) for (; t >= e;) n += r, t -= e; 13470 return n; 13471} 13472function ag(e) { 13473 return ig(e).toUpperCase(); 13474} 13475function og(e) { 13476 let t = e.toLowerCase(), n = 0, r = 0; 13477 for (; n < t.length;) { 13478 let e = !1; 13479 for (let [i, a] of tg) if (t.startsWith(a, n)) { 13480 r += i, n += a.length, e = !0; 13481 break; 13482 } 13483 if (!e) return 0; 13484 } 13485 return r; 13486} 13487function sg(e) { 13488 if (!/^[ivxlcdmIVXLCDM]+$/.test(e)) return !1; 13489 let t = og(e); 13490 return t <= 0 ? !1 : (e === e.toLowerCase() ? ig(t) : ag(t)) === e; 13491} 13492function cg(e) { 13493 let t = e.toLowerCase(); 13494 if (t.length === 1) return t.charCodeAt(0) - 97 + 1; 13495 if (t.length === 2) { 13496 let e = t.charCodeAt(0) - 97, n = t.charCodeAt(1) - 97; 13497 return (e + 1) * 26 + n + 1; 13498 } 13499 return 0; 13500} 13501function lg(e) { 13502 if (e <= 26) return ng[e - 1]; 13503 let t = Math.floor((e - 1) / 26) - 1, n = (e - 1) % 26; 13504 return t < 0 ? ng[n] : ng[t] + ng[n]; 13505} 13506function ug(e) { 13507 if (!(!e || /^\d+$/.test(e))) { 13508 if (sg(e)) return e === e.toLowerCase() ? "i" : "I"; 13509 if (/^[a-z]{1,2}$/.test(e)) return "a"; 13510 if (/^[A-Z]{1,2}$/.test(e)) return "A"; 13511 } 13512} 13513function dg(e) { 13514 if (/^\d+$/.test(e)) return parseInt(e, 10); 13515 let t = ug(e); 13516 if (t === "i" || t === "I") return og(e); 13517 if (t === "a" || t === "A") { 13518 let t = cg(e); 13519 return t > 0 ? t : 1; 13520 } 13521 let n = parseInt(e, 10); 13522 return Number.isNaN(n) ? 1 : n; 13523} 13524function fg(e, t) { 13525 if (e === "numeric") return String(t); 13526 switch (e) { 13527 case "a": return lg(t); 13528 case "A": return lg(t).toUpperCase(); 13529 case "i": return ig(t); 13530 case "I": return ag(t); 13531 default: return String(t); 13532 } 13533} 13534function pg(e) { 13535 if (e.length === 0) return !1; 13536 let t = ug(e[0]) ?? "numeric", n = dg(e[0]); 13537 if (n < 1) return !1; 13538 for (let r = 0; r < e.length; r++) { 13539 let i = fg(t, n + r); 13540 if (e[r] !== i) return !1; 13541 } 13542 return !0; 13543} 13544function mg(e) { 13545 return { 13546 type: ug(e), 13547 start: dg(e) 13548 }; 13549} 13550function hg(e) { 13551 let { type: t, start: n } = mg(e), r = {}; 13552 return t && (r.type = t), n !== 1 && (r.start = n), r; 13553} 13554function gg(e, t, n = ". ") { 13555 let r = t + 1; 13556 if (!e || e === "1") return `${r}${n}`; 13557 switch (e) { 13558 case "a": return `${lg(r)}${n}`; 13559 case "A": return `${lg(r).toUpperCase()}${n}`; 13560 case "i": return `${ig(r)}${n}`; 13561 case "I": return `${ag(r)}${n}`; 13562 default: return `${r}${n}`; 13563 } 13564} 13565function _g(e) { 13566 let t = e.tokens?.[0]; 13567 return !!(e.text && e.tokens?.length === 1 && t?.type === "list" && t.ordered && t.raw === e.text); 13568} 13569function vg(e, t) { 13570 return t.tokenizeInline ? t.parseInline(t.tokenizeInline(e)) : t.parseInline([{ 13571 type: "text", 13572 raw: e, 13573 text: e 13574 }]); 13575} 13576var yg = H.create({ 13577 name: "listItem", 13578 addOptions() { 13579 return { 13580 HTMLAttributes: {}, 13581 bulletListTypeName: "bulletList", 13582 orderedListTypeName: "orderedList" 13583 }; 13584 }, 13585 content: "paragraph block*", 13586 defining: !0, 13587 parseHTML() { 13588 return [{ tag: "li" }]; 13589 }, 13590 renderHTML({ HTMLAttributes: e }) { 13591 return [ 13592 "li", 13593 B(this.options.HTMLAttributes, e), 13594 0 13595 ]; 13596 }, 13597 markdownTokenName: "list_item", 13598 parseMarkdown: (e, t) => { 13599 if (e.type !== "list_item") return []; 13600 let n = t.parseBlockChildren ?? t.parseChildren, r = []; 13601 if (e.tokens && e.tokens.length > 0) { 13602 if (_g(e)) return { 13603 type: "listItem", 13604 content: [{ 13605 type: "paragraph", 13606 content: vg(e.text || "", t) 13607 }] 13608 }; 13609 if (e.tokens.some((e) => e.type === "paragraph")) r = n(e.tokens); 13610 else { 13611 let i = e.tokens[0]; 13612 if (i && i.type === "text" && i.tokens && i.tokens.length > 0) { 13613 if (r = [{ 13614 type: "paragraph", 13615 content: t.parseInline(i.tokens) 13616 }], e.tokens.length > 1) { 13617 let t = n(e.tokens.slice(1)); 13618 r.push(...t); 13619 } 13620 } else r = n(e.tokens); 13621 } 13622 } 13623 return r.length === 0 && (r = [{ 13624 type: "paragraph", 13625 content: [] 13626 }]), { 13627 type: "listItem", 13628 content: r 13629 }; 13630 }, 13631 renderMarkdown: (e, t, n) => rd(e, t, (e) => { 13632 if (e.parentType === "bulletList") return "- "; 13633 if (e.parentType === "orderedList") { 13634 let t = e.meta?.parentAttrs?.start || 1; 13635 return gg(e.meta?.parentAttrs?.type, t - 1 + (e.index || 0), ". "); 13636 } 13637 return "- "; 13638 }, n), 13639 addExtensions() { 13640 return [eg(this.name, [this.options.bulletListTypeName, this.options.orderedListTypeName])]; 13641 }, 13642 addKeyboardShortcuts() { 13643 return { 13644 Enter: () => this.editor.commands.splitListItem(this.name), 13645 Tab: () => this.editor.commands.sinkListItem(this.name), 13646 "Shift-Tab": () => this.editor.commands.liftListItem(this.name) 13647 }; 13648 } 13649}); 13650Kh({}, { 13651 findListItemPos: () => bg, 13652 getNextListDepth: () => xg, 13653 handleBackspace: () => Cg, 13654 handleDelete: () => Eg, 13655 hasListBefore: () => Sg, 13656 hasListItemAfter: () => Dg, 13657 hasListItemBefore: () => Og, 13658 listItemHasSubList: () => kg, 13659 nextListIsDeeper: () => wg, 13660 nextListIsHigher: () => Tg 13661}); 13662var bg = (e, t) => { 13663 let { $from: n } = t.selection, r = L(e, t.schema), i = null, a = n.depth, o = n.pos, s = null; 13664 for (; a > 0 && s === null;) i = n.node(a), i.type === r ? s = a : (--a, --o); 13665 return s === null ? null : { 13666 $pos: t.doc.resolve(o), 13667 depth: s 13668 }; 13669}, xg = (e, t) => { 13670 let n = bg(e, t); 13671 if (!n) return !1; 13672 let [, r] = tu(t, e, n.$pos.pos + 4); 13673 return r; 13674}, Sg = (e, t, n) => { 13675 let { $anchor: r } = e.selection, i = Math.max(0, r.pos - 2), a = e.doc.resolve(i).node(); 13676 return !(!a || !n.includes(a.type.name)); 13677}, Cg = (e, t, n) => { 13678 if (e.commands.undoInputRule()) return !0; 13679 if (e.state.selection.from !== e.state.selection.to) return !1; 13680 if (!ol(e.state, t) && Sg(e.state, t, n)) { 13681 let { $anchor: n } = e.state.selection, r = e.state.doc.resolve(n.before() - 1), i = []; 13682 r.node().descendants((e, n) => { 13683 e.type.name === t && i.push({ 13684 node: e, 13685 pos: n 13686 }); 13687 }); 13688 let a = i.at(-1); 13689 if (!a) return !1; 13690 let o = e.state.doc.resolve(r.start() + a.pos + 1); 13691 return e.chain().cut({ 13692 from: n.start() - 1, 13693 to: n.end() + 1 13694 }, o.end()).joinForward().run(); 13695 } 13696 return !ol(e.state, t) || !cu(e.state) ? !1 : e.chain().liftListItem(t).run(); 13697}, wg = (e, t) => { 13698 let n = xg(e, t), r = bg(e, t); 13699 return !r || !n ? !1 : n > r.depth; 13700}, Tg = (e, t) => { 13701 let n = xg(e, t), r = bg(e, t); 13702 return !r || !n ? !1 : n < r.depth; 13703}, Eg = (e, t) => { 13704 if (!ol(e.state, t) || !su(e.state, t)) return !1; 13705 let { selection: n } = e.state, { $from: r, $to: i } = n; 13706 return !n.empty && r.sameParent(i) ? !1 : wg(t, e.state) ? e.chain().focus(e.state.selection.from + 4).lift(t).joinBackward().run() : Tg(t, e.state) ? e.chain().joinForward().joinBackward().run() : e.commands.joinItemForward(); 13707}, Dg = (e, t) => { 13708 let { $anchor: n } = t.selection, r = t.doc.resolve(n.pos - n.parentOffset - 2); 13709 return !(r.index() === r.parent.childCount - 1 || r.nodeAfter?.type.name !== e); 13710}, Og = (e, t) => { 13711 let { $anchor: n } = t.selection, r = t.doc.resolve(n.pos - 2); 13712 return !(r.index() === 0 || r.nodeBefore?.type.name !== e); 13713}, kg = (e, t, n) => { 13714 if (!n) return !1; 13715 let r = L(e, t.schema), i = !1; 13716 return n.descendants((e) => { 13717 e.type === r && (i = !0); 13718 }), i; 13719}, Ag = V.create({ 13720 name: "listKeymap", 13721 addOptions() { 13722 return { listTypes: [{ 13723 itemName: "listItem", 13724 wrapperNames: ["bulletList", "orderedList"] 13725 }, { 13726 itemName: "taskItem", 13727 wrapperNames: ["taskList"] 13728 }] }; 13729 }, 13730 addKeyboardShortcuts() { 13731 return { 13732 Delete: ({ editor: e }) => { 13733 let t = !1; 13734 return this.options.listTypes.forEach(({ itemName: n }) => { 13735 e.state.schema.nodes[n] !== void 0 && Eg(e, n) && (t = !0); 13736 }), t; 13737 }, 13738 "Mod-Delete": ({ editor: e }) => { 13739 let t = !1; 13740 return this.options.listTypes.forEach(({ itemName: n }) => { 13741 e.state.schema.nodes[n] !== void 0 && Eg(e, n) && (t = !0); 13742 }), t; 13743 }, 13744 Backspace: ({ editor: e }) => { 13745 let t = !1; 13746 return this.options.listTypes.forEach(({ itemName: n, wrapperNames: r }) => { 13747 e.state.schema.nodes[n] !== void 0 && Cg(e, n, r) && (t = !0); 13748 }), t; 13749 }, 13750 "Mod-Backspace": ({ editor: e }) => { 13751 let t = !1; 13752 return this.options.listTypes.forEach(({ itemName: n, wrapperNames: r }) => { 13753 e.state.schema.nodes[n] !== void 0 && Cg(e, n, r) && (t = !0); 13754 }), t; 13755 } 13756 }; 13757 } 13758}), jg = RegExp(`^(\\s*)(${rg})([.)])\\s+(.*)$`), Mg = RegExp(`^(\\s*)(${rg})([.)])\\s+`), Ng = /^\s/; 13759function Pg(e) { 13760 return jg.test(e.trimStart()); 13761} 13762function Fg(e) { 13763 let t = e.trimStart(); 13764 return /^[-+*]\s+/.test(t) || Pg(t) || /^>\s?/.test(t) || /^```/.test(t) || /^~~~/.test(t); 13765} 13766function Ig(e) { 13767 let t = [], n = [], r = !1; 13768 return e.forEach((e) => { 13769 if (r) { 13770 n.push(e); 13771 return; 13772 } 13773 if (e.trim() === "") { 13774 r = !0, n.push(e); 13775 return; 13776 } 13777 if (t.length > 0 && Fg(e)) { 13778 r = !0, n.push(e); 13779 return; 13780 } 13781 t.push(e); 13782 }), { 13783 paragraphLines: t, 13784 blockLines: n 13785 }; 13786} 13787function Lg(e) { 13788 let t = [], n = 0, r = 0; 13789 for (; n < e.length;) { 13790 let i = e[n], a = i.match(jg); 13791 if (!a) break; 13792 let [, o, s, c, l] = a, u = o.length, d = parseInt(s, 10), f = isNaN(d) ? ug(s) : void 0, p = isNaN(d) ? dg(s) : d, m = [l], h = n + 1, g = [i], _ = !1; 13793 for (; h < e.length;) { 13794 let t = e[h]; 13795 if (t.match(jg)) break; 13796 if (t.trim() === "") g.push(t), m.push(""), _ = !0, h += 1; 13797 else if (t.match(Ng)) { 13798 let e = t.length - t.trimStart().length, n = u + s.length + 1; 13799 g.push(t), m.push(t.slice(Math.min(e, n))), h += 1; 13800 } else { 13801 if (_) break; 13802 g.push(t), m.push(t), h += 1; 13803 } 13804 } 13805 t.push({ 13806 indent: u, 13807 number: p, 13808 type: f, 13809 content: m.join("\n").trim(), 13810 contentLines: m, 13811 raw: g.join("\n") 13812 }), r = h, n = h; 13813 } 13814 return [t, r]; 13815} 13816var Rg = RegExp(`^(${rg})([.)])\\s+(.+)$`); 13817function zg(e) { 13818 let t = e.split("\n").filter((e) => e.trim().length > 0); 13819 if (t.length === 0) return null; 13820 let n = []; 13821 for (let e of t) { 13822 let t = e.trim().match(Rg); 13823 if (!t) return null; 13824 n.push({ 13825 marker: t[1], 13826 content: t[3] 13827 }); 13828 } 13829 return pg(n.map((e) => e.marker)) ? { 13830 type: "orderedList", 13831 attrs: hg(n[0].marker), 13832 content: n.map((e) => ({ 13833 type: "listItem", 13834 content: [{ 13835 type: "paragraph", 13836 content: [{ 13837 type: "text", 13838 text: e.content 13839 }] 13840 }] 13841 })) 13842 } : null; 13843} 13844function Bg(e, t, n) { 13845 let r = [], i = 0; 13846 for (; i < e.length;) { 13847 let a = e[i]; 13848 if (a.indent === t) { 13849 let { paragraphLines: o, blockLines: s } = Ig(a.contentLines), c = o.join("\n").trim(), l = []; 13850 c && l.push({ 13851 type: "paragraph", 13852 raw: c, 13853 tokens: n.inlineTokens(c) 13854 }); 13855 let u = s.join("\n").trim(); 13856 if (u) { 13857 let e = n.blockTokens(u); 13858 l.push(...e); 13859 } 13860 let d = i + 1, f = []; 13861 for (; d < e.length && e[d].indent > t;) f.push(e[d]), d += 1; 13862 if (f.length > 0) { 13863 let e = Bg(f, Math.min(...f.map((e) => e.indent)), n); 13864 l.push({ 13865 type: "list", 13866 ordered: !0, 13867 start: f[0].number, 13868 typeMarker: f[0].type, 13869 items: e, 13870 raw: f.map((e) => e.raw).join("\n") 13871 }); 13872 } 13873 r.push({ 13874 type: "list_item", 13875 raw: a.raw, 13876 tokens: l 13877 }), i = d; 13878 } else i += 1; 13879 } 13880 return r; 13881} 13882function Vg(e, t) { 13883 return e.map((e) => { 13884 if (e.type !== "list_item") return t.parseChildren([e])[0]; 13885 let n = []; 13886 return e.tokens && e.tokens.length > 0 && e.tokens.forEach((e) => { 13887 if (e.type === "paragraph" || e.type === "list" || e.type === "blockquote" || e.type === "code") n.push(...t.parseChildren([e])); 13888 else if (e.type === "text" && e.tokens) { 13889 let r = t.parseChildren([e]); 13890 n.push({ 13891 type: "paragraph", 13892 content: r 13893 }); 13894 } else { 13895 let r = t.parseChildren([e]); 13896 r.length > 0 && n.push(...r); 13897 } 13898 }), { 13899 type: "listItem", 13900 content: n 13901 }; 13902 }); 13903} 13904var Hg = "listItem", Ug = "textStyle", Wg = /^(\d+)\.\s$/; 13905function Gg(e) { 13906 let t = e.match(/list-style-type\s*:\s*([^;]+)/i); 13907 if (!t) return null; 13908 switch (t[1].trim().toLowerCase()) { 13909 case "upper-roman": return "I"; 13910 case "lower-roman": return "i"; 13911 case "upper-alpha": 13912 case "upper-latin": return "A"; 13913 case "lower-alpha": 13914 case "lower-latin": return "a"; 13915 default: return null; 13916 } 13917} 13918var Kg = H.create({ 13919 name: "orderedList", 13920 addOptions() { 13921 return { 13922 itemTypeName: "listItem", 13923 HTMLAttributes: {}, 13924 keepMarks: !1, 13925 keepAttributes: !1 13926 }; 13927 }, 13928 group: "block list", 13929 content() { 13930 return `${this.options.itemTypeName}+`; 13931 }, 13932 addAttributes() { 13933 return { 13934 start: { 13935 default: 1, 13936 parseHTML: (e) => e.hasAttribute("start") ? parseInt(e.getAttribute("start") || "", 10) : 1 13937 }, 13938 type: { 13939 default: null, 13940 parseHTML: (e) => { 13941 let t = e.getAttribute("type"); 13942 if (t) return t; 13943 let n = e.getAttribute("style"); 13944 if (n) { 13945 let e = Gg(n); 13946 if (e) return e; 13947 } 13948 let r = e.querySelector("li"); 13949 if (r) { 13950 let e = r.getAttribute("style"); 13951 if (e) { 13952 let t = Gg(e); 13953 if (t) return t; 13954 } 13955 } 13956 return null; 13957 } 13958 } 13959 }; 13960 }, 13961 parseHTML() { 13962 return [{ tag: "ol" }]; 13963 }, 13964 renderHTML({ HTMLAttributes: e }) { 13965 let { start: t, type: n, ...r } = e, i = B(this.options.HTMLAttributes, r); 13966 return t !== 1 && (i.start = t), n && n !== "1" && (i.type = n), [ 13967 "ol", 13968 i, 13969 0 13970 ]; 13971 }, 13972 markdownTokenName: "list", 13973 parseMarkdown: (e, t) => { 13974 if (e.type !== "list" || !e.ordered) return []; 13975 let n = e.start || 1, r = e.typeMarker, i = e.items ? Vg(e.items, t) : [], a = {}; 13976 return n !== 1 && (a.start = n), r && (a.type = r), Object.keys(a).length > 0 ? { 13977 type: "orderedList", 13978 attrs: a, 13979 content: i 13980 } : { 13981 type: "orderedList", 13982 content: i 13983 }; 13984 }, 13985 renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n") : "", 13986 markdownTokenizer: { 13987 name: "orderedList", 13988 level: "block", 13989 start: (e) => { 13990 let t = e.match(Mg)?.index; 13991 return t === void 0 ? -1 : t; 13992 }, 13993 tokenize: (e, t, n) => { 13994 let r = e.split("\n"), [i, a] = Lg(r); 13995 if (i.length === 0) return; 13996 let o = Bg(i, 0, n); 13997 if (o.length !== 0) return { 13998 type: "list", 13999 ordered: !0, 14000 start: i[0]?.number || 1, 14001 typeMarker: i[0]?.type, 14002 items: o, 14003 raw: r.slice(0, a).join("\n") 14004 }; 14005 } 14006 }, 14007 markdownOptions: { indentsContent: !0 }, 14008 addCommands() { 14009 return { toggleOrderedList: () => ({ commands: e, chain: t }) => this.options.keepAttributes ? t().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Hg, this.editor.getAttributes(Ug)).run() : e.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks) }; 14010 }, 14011 addKeyboardShortcuts() { 14012 return { "Mod-Shift-7": () => this.editor.commands.toggleOrderedList() }; 14013 }, 14014 addProseMirrorPlugins() { 14015 return [new D({ props: { handlePaste: (e, t) => { 14016 if ((t.clipboardData?.getData("text/html"))?.trim()) return !1; 14017 let n = t.clipboardData?.getData("text/plain"); 14018 if (!n) return !1; 14019 let r = zg(n); 14020 if (!r) return !1; 14021 try { 14022 let t = e.state.schema.nodeFromJSON(r), n = e.state.tr.replaceSelectionWith(t); 14023 return e.dispatch(n), !0; 14024 } catch { 14025 return !1; 14026 } 14027 } } })]; 14028 }, 14029 addInputRules() { 14030 let e = (e, t) => (!t.attrs.type || t.attrs.type === "1") && t.childCount + t.attrs.start === +e[1], t = Id({ 14031 find: Wg, 14032 type: this.type, 14033 getAttributes: (e) => ({ start: +e[1] }), 14034 joinPredicate: e 14035 }); 14036 return (this.options.keepMarks || this.options.keepAttributes) && (t = Id({ 14037 find: Wg, 14038 type: this.type, 14039 keepMarks: this.options.keepMarks, 14040 keepAttributes: this.options.keepAttributes, 14041 getAttributes: (e) => ({ 14042 start: +e[1], 14043 ...this.editor.getAttributes(Ug) 14044 }), 14045 joinPredicate: e, 14046 editor: this.editor 14047 })), [t]; 14048 } 14049}), qg = /^\s*(\[([( |x])?\])\s$/, Jg = H.create({ 14050 name: "taskItem", 14051 addOptions() { 14052 return { 14053 nested: !1, 14054 HTMLAttributes: {}, 14055 taskListTypeName: "taskList", 14056 a11y: void 0 14057 }; 14058 }, 14059 content() { 14060 return this.options.nested ? "paragraph block*" : "paragraph+"; 14061 }, 14062 defining: !0, 14063 addAttributes() { 14064 return { checked: { 14065 default: !1, 14066 keepOnSplit: !1, 14067 parseHTML: (e) => { 14068 let t = e.getAttribute("data-checked"); 14069 return t === "" || t === "true"; 14070 }, 14071 renderHTML: (e) => ({ "data-checked": e.checked }) 14072 } }; 14073 }, 14074 parseHTML() { 14075 return [{ 14076 tag: `li[data-type="${this.name}"]`, 14077 priority: 51 14078 }]; 14079 }, 14080 renderHTML({ node: e, HTMLAttributes: t }) { 14081 return [ 14082 "li", 14083 B(this.options.HTMLAttributes, t, { "data-type": this.name }), 14084 [ 14085 "label", 14086 ["input", { 14087 type: "checkbox", 14088 checked: e.attrs.checked ? "checked" : null 14089 }], 14090 ["span"] 14091 ], 14092 ["div", 0] 14093 ]; 14094 }, 14095 parseMarkdown: (e, t) => { 14096 let n = []; 14097 if (e.tokens && e.tokens.length > 0 ? n.push(t.createNode("paragraph", {}, t.parseInline(e.tokens))) : e.text ? n.push(t.createNode("paragraph", {}, [t.createNode("text", { text: e.text })])) : n.push(t.createNode("paragraph", {}, [])), e.nestedTokens && e.nestedTokens.length > 0) { 14098 let r = t.parseChildren(e.nestedTokens); 14099 n.push(...r); 14100 } 14101 return t.createNode("taskItem", { checked: e.checked || !1 }, n); 14102 }, 14103 renderMarkdown: (e, t) => rd(e, t, `- [${e.attrs?.checked ? "x" : " "}] `), 14104 addExtensions() { 14105 return this.options.nested ? [eg(this.name, [this.options.taskListTypeName])] : []; 14106 }, 14107 addKeyboardShortcuts() { 14108 let e = { 14109 Enter: () => this.editor.commands.splitListItem(this.name), 14110 "Shift-Tab": () => this.editor.commands.liftListItem(this.name) 14111 }; 14112 return this.options.nested ? { 14113 ...e, 14114 Tab: () => this.editor.commands.sinkListItem(this.name) 14115 } : e; 14116 }, 14117 addNodeView() { 14118 return ({ node: e, HTMLAttributes: t, getPos: n, editor: r }) => { 14119 let i = document.createElement("li"), a = document.createElement("label"), o = document.createElement("span"), s = document.createElement("input"), c = document.createElement("div"), l = (e) => { 14120 var t; 14121 s.ariaLabel = ((t = this.options.a11y)?.checkboxLabel)?.call(t, e, s.checked) || `Task item checkbox for ${e.textContent || "empty task item"}`; 14122 }; 14123 l(e), a.contentEditable = "false", s.type = "checkbox", s.addEventListener("mousedown", (e) => e.preventDefault()), s.addEventListener("change", (t) => { 14124 if (!r.isEditable && !this.options.onReadOnlyChecked) { 14125 s.checked = !s.checked; 14126 return; 14127 } 14128 let { checked: i } = t.target; 14129 r.isEditable && typeof n == "function" && r.chain().focus(void 0, { scrollIntoView: !1 }).command(({ tr: e }) => { 14130 let t = n(); 14131 if (typeof t != "number") return !1; 14132 let r = e.doc.nodeAt(t); 14133 return e.setNodeMarkup(t, void 0, { 14134 ...r?.attrs, 14135 checked: i 14136 }), !0; 14137 }).run(), !r.isEditable && this.options.onReadOnlyChecked && (this.options.onReadOnlyChecked(e, i) || (s.checked = !s.checked)); 14138 }), Object.entries(this.options.HTMLAttributes).forEach(([e, t]) => { 14139 i.setAttribute(e, t); 14140 }), i.dataset.checked = e.attrs.checked, s.checked = e.attrs.checked, a.append(s, o), i.append(a, c), Object.entries(t).forEach(([e, t]) => { 14141 i.setAttribute(e, t); 14142 }); 14143 let u = new Set(Object.keys(t)); 14144 return { 14145 dom: i, 14146 contentDOM: c, 14147 update: (e) => { 14148 if (e.type !== this.type) return !1; 14149 i.dataset.checked = e.attrs.checked, s.checked = e.attrs.checked, l(e); 14150 let t = r.extensionManager.attributes, n = Ll(e, t), a = new Set(Object.keys(n)), o = this.options.HTMLAttributes; 14151 return u.forEach((e) => { 14152 a.has(e) || (e in o ? i.setAttribute(e, o[e]) : i.removeAttribute(e)); 14153 }), Object.entries(n).forEach(([e, t]) => { 14154 t == null ? e in o ? i.setAttribute(e, o[e]) : i.removeAttribute(e) : i.setAttribute(e, t); 14155 }), u = a, !0; 14156 } 14157 }; 14158 }; 14159 }, 14160 addInputRules() { 14161 return [Id({ 14162 find: qg, 14163 type: this.type, 14164 getAttributes: (e) => ({ checked: e[e.length - 1] === "x" }) 14165 })]; 14166 } 14167}), Yg = H.create({ 14168 name: "taskList", 14169 addOptions() { 14170 return { 14171 itemTypeName: "taskItem", 14172 HTMLAttributes: {} 14173 }; 14174 }, 14175 group: "block list", 14176 content() { 14177 return `${this.options.itemTypeName}+`; 14178 }, 14179 parseHTML() { 14180 return [{ 14181 tag: `ul[data-type="${this.name}"]`, 14182 priority: 51 14183 }]; 14184 }, 14185 renderHTML({ HTMLAttributes: e }) { 14186 return [ 14187 "ul", 14188 B(this.options.HTMLAttributes, e, { "data-type": this.name }), 14189 0 14190 ]; 14191 }, 14192 parseMarkdown: (e, t) => t.createNode("taskList", {}, t.parseChildren(e.items || [])), 14193 renderMarkdown: (e, t) => e.content ? t.renderChildren(e.content, "\n") : "", 14194 markdownTokenizer: { 14195 name: "taskList", 14196 level: "block", 14197 start(e) { 14198 let t = e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index; 14199 return t === void 0 ? -1 : t; 14200 }, 14201 tokenize(e, t, n) { 14202 let r = (e) => { 14203 let t = nd(e, { 14204 itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/, 14205 extractItemData: (e) => ({ 14206 indentLevel: e[1].length, 14207 mainContent: e[4], 14208 checked: e[3].toLowerCase() === "x" 14209 }), 14210 createToken: (e, t) => ({ 14211 type: "taskItem", 14212 raw: "", 14213 mainContent: e.mainContent, 14214 indentLevel: e.indentLevel, 14215 checked: e.checked, 14216 text: e.mainContent, 14217 tokens: n.inlineTokens(e.mainContent), 14218 nestedTokens: t 14219 }), 14220 customNestedParser: r 14221 }, n); 14222 return t ? [{ 14223 type: "taskList", 14224 raw: t.raw, 14225 items: t.items 14226 }] : n.blockTokens(e); 14227 }, i = nd(e, { 14228 itemPattern: /^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/, 14229 extractItemData: (e) => ({ 14230 indentLevel: e[1].length, 14231 mainContent: e[4], 14232 checked: e[3].toLowerCase() === "x" 14233 }), 14234 createToken: (e, t) => ({ 14235 type: "taskItem", 14236 raw: "", 14237 mainContent: e.mainContent, 14238 indentLevel: e.indentLevel, 14239 checked: e.checked, 14240 text: e.mainContent, 14241 tokens: n.inlineTokens(e.mainContent), 14242 nestedTokens: t 14243 }), 14244 customNestedParser: r 14245 }, n); 14246 if (i) return { 14247 type: "taskList", 14248 raw: i.raw, 14249 items: i.items 14250 }; 14251 } 14252 }, 14253 markdownOptions: { indentsContent: !0 }, 14254 addCommands() { 14255 return { toggleTaskList: () => ({ commands: e }) => e.toggleList(this.name, this.options.itemTypeName) }; 14256 }, 14257 addKeyboardShortcuts() { 14258 return { "Mod-Shift-9": () => this.editor.commands.toggleTaskList() }; 14259 } 14260}); 14261V.create({ 14262 name: "listKit", 14263 addExtensions() { 14264 let e = []; 14265 return this.options.bulletList !== !1 && e.push(Xh.configure(this.options.bulletList)), this.options.listItem !== !1 && e.push(yg.configure(this.options.listItem)), this.options.listKeymap !== !1 && e.push(Ag.configure(this.options.listKeymap)), this.options.orderedList !== !1 && e.push(Kg.configure(this.options.orderedList)), this.options.taskItem !== !1 && e.push(Jg.configure(this.options.taskItem)), this.options.taskList !== !1 && e.push(Yg.configure(this.options.taskList)), e; 14266 } 14267}); 14268//#endregion 14269//#region node_modules/@tiptap/extension-paragraph/dist/index.js 14270var Xg = " ", Zg = "\xA0", Qg = H.create({ 14271 name: "paragraph", 14272 priority: 1e3, 14273 addOptions() { 14274 return { HTMLAttributes: {} }; 14275 }, 14276 group: "block", 14277 content: "inline*", 14278 parseHTML() { 14279 return [{ tag: "p" }]; 14280 }, 14281 renderHTML({ HTMLAttributes: e }) { 14282 return [ 14283 "p", 14284 B(this.options.HTMLAttributes, e), 14285 0 14286 ]; 14287 }, 14288 parseMarkdown: (e, t) => { 14289 let n = e.tokens || []; 14290 if (n.length === 1 && n[0].type === "image") return t.parseChildren([n[0]]); 14291 let r = t.parseInline(n); 14292 return n.length === 1 && n[0].type === "text" && (n[0].raw === Xg || n[0].text === Xg || n[0].raw === Zg || n[0].text === Zg) && r.length === 1 && r[0].type === "text" && (r[0].text === Xg || r[0].text === Zg) ? t.createNode("paragraph", void 0, []) : t.createNode("paragraph", void 0, r); 14293 }, 14294 renderMarkdown: (e, t, n) => { 14295 if (!e) return ""; 14296 let r = Array.isArray(e.content) ? e.content : []; 14297 if (r.length === 0) { 14298 let e = Array.isArray(n?.previousNode?.content) ? n.previousNode.content : []; 14299 return n?.previousNode?.type === "paragraph" && e.length === 0 ? Xg : ""; 14300 } 14301 return t.renderChildren(r); 14302 }, 14303 addCommands() { 14304 return { setParagraph: () => ({ commands: e }) => e.setNode(this.name) }; 14305 }, 14306 addKeyboardShortcuts() { 14307 return { "Mod-Alt-0": () => this.editor.commands.setParagraph() }; 14308 } 14309}), $g = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, e_ = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, t_ = dd.create({ 14310 name: "strike", 14311 addOptions() { 14312 return { HTMLAttributes: {} }; 14313 }, 14314 parseHTML() { 14315 return [ 14316 { tag: "s" }, 14317 { tag: "del" }, 14318 { tag: "strike" }, 14319 { 14320 style: "text-decoration", 14321 consuming: !1, 14322 getAttrs: (e) => e.includes("line-through") ? {} : !1 14323 } 14324 ]; 14325 }, 14326 renderHTML({ HTMLAttributes: e }) { 14327 return [ 14328 "s", 14329 B(this.options.HTMLAttributes, e), 14330 0 14331 ]; 14332 }, 14333 markdownTokenName: "del", 14334 parseMarkdown: (e, t) => t.applyMark("strike", t.parseInline(e.tokens || [])), 14335 renderMarkdown: (e, t) => `~~${t.renderChildren(e)}~~`, 14336 addCommands() { 14337 return { 14338 setStrike: () => ({ commands: e }) => e.setMark(this.name), 14339 toggleStrike: () => ({ commands: e }) => e.toggleMark(this.name), 14340 unsetStrike: () => ({ commands: e }) => e.unsetMark(this.name) 14341 }; 14342 }, 14343 addKeyboardShortcuts() { 14344 return { "Mod-Shift-s": () => this.editor.commands.toggleStrike() }; 14345 }, 14346 addInputRules() { 14347 return [Nd({ 14348 find: $g, 14349 type: this.type 14350 })]; 14351 }, 14352 addPasteRules() { 14353 return [Ld({ 14354 find: e_, 14355 type: this.type 14356 })]; 14357 } 14358}), n_ = H.create({ 14359 name: "text", 14360 group: "inline", 14361 parseMarkdown: (e) => ({ 14362 type: "text", 14363 text: e.text || "" 14364 }), 14365 renderMarkdown: (e) => e.text || "" 14366}), r_ = dd.create({ 14367 name: "underline", 14368 addOptions() { 14369 return { HTMLAttributes: {} }; 14370 }, 14371 parseHTML() { 14372 return [{ tag: "u" }, { 14373 style: "text-decoration", 14374 consuming: !1, 14375 getAttrs: (e) => e.includes("underline") ? {} : !1 14376 }]; 14377 }, 14378 renderHTML({ HTMLAttributes: e }) { 14379 return [ 14380 "u", 14381 B(this.options.HTMLAttributes, e), 14382 0 14383 ]; 14384 }, 14385 parseMarkdown(e, t) { 14386 return t.applyMark(this.name || "underline", t.parseInline(e.tokens || [])); 14387 }, 14388 renderMarkdown(e, t) { 14389 return `++${t.renderChildren(e)}++`; 14390 }, 14391 markdownTokenizer: { 14392 name: "underline", 14393 level: "inline", 14394 start(e) { 14395 return e.indexOf("++"); 14396 }, 14397 tokenize(e, t, n) { 14398 let r = /^(\+\+)([\s\S]+?)(\+\+)/.exec(e); 14399 if (!r) return; 14400 let i = r[2].trim(); 14401 return { 14402 type: "underline", 14403 raw: r[0], 14404 text: i, 14405 tokens: n.inlineTokens(i) 14406 }; 14407 } 14408 }, 14409 addCommands() { 14410 return { 14411 setUnderline: () => ({ commands: e }) => e.setMark(this.name), 14412 toggleUnderline: () => ({ commands: e }) => e.toggleMark(this.name), 14413 unsetUnderline: () => ({ commands: e }) => e.unsetMark(this.name) 14414 }; 14415 }, 14416 addKeyboardShortcuts() { 14417 return { 14418 "Mod-u": () => this.editor.commands.toggleUnderline(), 14419 "Mod-U": () => this.editor.commands.toggleUnderline() 14420 }; 14421 } 14422}); 14423//#endregion 14424//#region node_modules/prosemirror-dropcursor/dist/index.js 14425function i_(e = {}) { 14426 return new D({ view(t) { 14427 return new a_(t, e); 14428 } }); 14429} 14430var a_ = class { 14431 constructor(e, t) { 14432 this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = t.width ?? 1, this.color = t.color === !1 ? void 0 : t.color || "black", this.class = t.class, this.handlers = [ 14433 "dragover", 14434 "dragend", 14435 "drop", 14436 "dragleave" 14437 ].map((t) => { 14438 let n = (e) => { 14439 this[t](e); 14440 }; 14441 return e.dom.addEventListener(t, n), { 14442 name: t, 14443 handler: n 14444 }; 14445 }); 14446 } 14447 destroy() { 14448 this.handlers.forEach(({ name: e, handler: t }) => this.editorView.dom.removeEventListener(e, t)); 14449 } 14450 update(e, t) { 14451 this.cursorPos != null && t.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay()); 14452 } 14453 setCursor(e) { 14454 e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay()); 14455 } 14456 updateOverlay() { 14457 let e = this.editorView.state.doc.resolve(this.cursorPos), t = !e.parent.inlineContent, n, r = this.editorView.dom, i = r.getBoundingClientRect(), a = i.width / r.offsetWidth, o = i.height / r.offsetHeight; 14458 if (t) { 14459 let t = e.nodeBefore, r = e.nodeAfter; 14460 if (t || r) { 14461 let e = this.editorView.nodeDOM(this.cursorPos - (t ? t.nodeSize : 0)); 14462 if (e) { 14463 let i = e.getBoundingClientRect(), a = t ? i.bottom : i.top; 14464 t && r && (a = (a + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2); 14465 let s = this.width / 2 * o; 14466 n = { 14467 left: i.left, 14468 right: i.right, 14469 top: a - s, 14470 bottom: a + s 14471 }; 14472 } 14473 } 14474 } 14475 if (!n) { 14476 let e = this.editorView.coordsAtPos(this.cursorPos), t = this.width / 2 * a; 14477 n = { 14478 left: e.left - t, 14479 right: e.left + t, 14480 top: e.top, 14481 bottom: e.bottom 14482 }; 14483 } 14484 let s = this.editorView.dom.offsetParent; 14485 this.element || (this.element = s.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", t), this.element.classList.toggle("prosemirror-dropcursor-inline", !t); 14486 let c, l; 14487 if (!s || s == document.body && getComputedStyle(s).position == "static") c = -pageXOffset, l = -pageYOffset; 14488 else { 14489 let e = s.getBoundingClientRect(), t = e.width / s.offsetWidth, n = e.height / s.offsetHeight; 14490 c = e.left - s.scrollLeft * t, l = e.top - s.scrollTop * n; 14491 } 14492 this.element.style.left = (n.left - c) / a + "px", this.element.style.top = (n.top - l) / o + "px", this.element.style.width = (n.right - n.left) / a + "px", this.element.style.height = (n.bottom - n.top) / o + "px"; 14493 } 14494 scheduleRemoval(e) { 14495 clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e); 14496 } 14497 dragover(e) { 14498 if (!this.editorView.editable) return; 14499 let t = this.editorView.posAtCoords({ 14500 left: e.clientX, 14501 top: e.clientY 14502 }), n = t && t.inside >= 0 && this.editorView.state.doc.nodeAt(t.inside), r = n && n.type.spec.disableDropCursor, i = typeof r == "function" ? r(this.editorView, t, e) : r; 14503 if (t && !i) { 14504 let e = t.pos; 14505 if (this.editorView.dragging && this.editorView.dragging.slice) { 14506 let t = Yt(this.editorView.state.doc, e, this.editorView.dragging.slice); 14507 t != null && (e = t); 14508 } 14509 this.setCursor(e), this.scheduleRemoval(5e3); 14510 } 14511 } 14512 dragend() { 14513 this.scheduleRemoval(20); 14514 } 14515 drop() { 14516 this.scheduleRemoval(20); 14517 } 14518 dragleave(e) { 14519 this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null); 14520 } 14521}, o_ = class e extends w { 14522 constructor(e) { 14523 super(e, e); 14524 } 14525 map(t, n) { 14526 let r = t.resolve(n.map(this.head)); 14527 return e.valid(r) ? new e(r) : w.near(r); 14528 } 14529 content() { 14530 return d.empty; 14531 } 14532 eq(t) { 14533 return t instanceof e && t.head == this.head; 14534 } 14535 toJSON() { 14536 return { 14537 type: "gapcursor", 14538 pos: this.head 14539 }; 14540 } 14541 static fromJSON(t, n) { 14542 if (typeof n.pos != "number") throw RangeError("Invalid input for GapCursor.fromJSON"); 14543 return new e(t.resolve(n.pos)); 14544 } 14545 getBookmark() { 14546 return new s_(this.anchor); 14547 } 14548 static valid(e) { 14549 let t = e.parent; 14550 if (t.inlineContent || !l_(e) || !u_(e)) return !1; 14551 let n = t.type.spec.allowGapCursor; 14552 if (n != null) return n; 14553 let r = t.contentMatchAt(e.index()).defaultType; 14554 return r && r.isTextblock; 14555 } 14556 static findGapCursorFrom(t, n, r = !1) { 14557 search: for (;;) { 14558 if (!r && e.valid(t)) return t; 14559 let i = t.pos, a = null; 14560 for (let r = t.depth;; r--) { 14561 let o = t.node(r); 14562 if (n > 0 ? t.indexAfter(r) < o.childCount : t.index(r) > 0) { 14563 a = o.child(n > 0 ? t.indexAfter(r) : t.index(r) - 1); 14564 break; 14565 } else if (r == 0) return null; 14566 i += n; 14567 let s = t.doc.resolve(i); 14568 if (e.valid(s)) return s; 14569 } 14570 for (;;) { 14571 let o = n > 0 ? a.firstChild : a.lastChild; 14572 if (!o) { 14573 if (a.isAtom && !a.isText && !E.isSelectable(a)) { 14574 t = t.doc.resolve(i + a.nodeSize * n), r = !1; 14575 continue search; 14576 } 14577 break; 14578 } 14579 a = o, i += n; 14580 let s = t.doc.resolve(i); 14581 if (e.valid(s)) return s; 14582 } 14583 return null; 14584 } 14585 } 14586}; 14587o_.prototype.visible = !1, o_.findFrom = o_.findGapCursorFrom, w.jsonID("gapcursor", o_); 14588var s_ = class e { 14589 constructor(e) { 14590 this.pos = e; 14591 } 14592 map(t) { 14593 return new e(t.map(this.pos)); 14594 } 14595 resolve(e) { 14596 let t = e.resolve(this.pos); 14597 return o_.valid(t) ? new o_(t) : w.near(t); 14598 } 14599}; 14600function c_(e) { 14601 return e.isAtom || e.spec.isolating || e.spec.createGapCursor; 14602} 14603function l_(e) { 14604 for (let t = e.depth; t >= 0; t--) { 14605 let n = e.index(t), r = e.node(t); 14606 if (n == 0) { 14607 if (r.type.spec.isolating) return !0; 14608 continue; 14609 } 14610 for (let e = r.child(n - 1);; e = e.lastChild) { 14611 if (e.childCount == 0 && !e.inlineContent || c_(e.type)) return !0; 14612 if (e.inlineContent) return !1; 14613 } 14614 } 14615 return !0; 14616} 14617function u_(e) { 14618 for (let t = e.depth; t >= 0; t--) { 14619 let n = e.indexAfter(t), r = e.node(t); 14620 if (n == r.childCount) { 14621 if (r.type.spec.isolating) return !0; 14622 continue; 14623 } 14624 for (let e = r.child(n);; e = e.firstChild) { 14625 if (e.childCount == 0 && !e.inlineContent || c_(e.type)) return !0; 14626 if (e.inlineContent) return !1; 14627 } 14628 } 14629 return !0; 14630} 14631function d_() { 14632 return new D({ props: { 14633 decorations: g_, 14634 createSelectionBetween(e, t, n) { 14635 return t.pos == n.pos && o_.valid(n) ? new o_(n) : null; 14636 }, 14637 handleClick: m_, 14638 handleKeyDown: f_, 14639 handleDOMEvents: { beforeinput: h_ } 14640 } }); 14641} 14642var f_ = ac({ 14643 ArrowLeft: p_("horiz", -1), 14644 ArrowRight: p_("horiz", 1), 14645 ArrowUp: p_("vert", -1), 14646 ArrowDown: p_("vert", 1) 14647}); 14648function p_(e, t) { 14649 let n = e == "vert" ? t > 0 ? "down" : "up" : t > 0 ? "right" : "left"; 14650 return function(e, r, i) { 14651 let a = e.selection, o = t > 0 ? a.$to : a.$from, s = a.empty; 14652 if (a instanceof T) { 14653 if (!i.endOfTextblock(n) || o.depth == 0) return !1; 14654 s = !1, o = e.doc.resolve(t > 0 ? o.after() : o.before()); 14655 } 14656 let c = o_.findGapCursorFrom(o, t, s); 14657 return c ? (r && r(e.tr.setSelection(new o_(c))), !0) : !1; 14658 }; 14659} 14660function m_(e, t, n) { 14661 if (!e || !e.editable) return !1; 14662 let r = e.state.doc.resolve(t); 14663 if (!o_.valid(r)) return !1; 14664 let i = e.posAtCoords({ 14665 left: n.clientX, 14666 top: n.clientY 14667 }); 14668 return i && i.inside > -1 && E.isSelectable(e.state.doc.nodeAt(i.inside)) ? !1 : (e.dispatch(e.state.tr.setSelection(new o_(r))), !0); 14669} 14670function h_(e, t) { 14671 if (t.inputType != "insertCompositionText" || !(e.state.selection instanceof o_)) return !1; 14672 let { $from: n } = e.state.selection, r = n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text); 14673 if (!r) return !1; 14674 let i = a.empty; 14675 for (let e = r.length - 1; e >= 0; e--) i = a.from(r[e].createAndFill(null, i)); 14676 let o = e.state.tr.replace(n.pos, n.pos, new d(i, 0, 0)); 14677 return o.setSelection(T.near(o.doc.resolve(n.pos + 1))), e.dispatch(o), !1; 14678} 14679function g_(e) { 14680 if (!(e.selection instanceof o_)) return null; 14681 let t = document.createElement("div"); 14682 return t.className = "ProseMirror-gapcursor", P.create(e.doc, [is.widget(e.selection.head, t, { key: "gapcursor" })]); 14683} 14684//#endregion 14685//#region node_modules/rope-sequence/dist/index.js 14686var __ = 200, $ = function() {}; 14687$.prototype.append = function(e) { 14688 return e.length ? (e = $.from(e), !this.length && e || e.length < __ && this.leafAppend(e) || this.length < __ && e.leafPrepend(this) || this.appendInner(e)) : this; 14689}, $.prototype.prepend = function(e) { 14690 return e.length ? $.from(e).append(this) : this; 14691}, $.prototype.appendInner = function(e) { 14692 return new y_(this, e); 14693}, $.prototype.slice = function(e, t) { 14694 return e === void 0 && (e = 0), t === void 0 && (t = this.length), e >= t ? $.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, t)); 14695}, $.prototype.get = function(e) { 14696 if (!(e < 0 || e >= this.length)) return this.getInner(e); 14697}, $.prototype.forEach = function(e, t, n) { 14698 t === void 0 && (t = 0), n === void 0 && (n = this.length), t <= n ? this.forEachInner(e, t, n, 0) : this.forEachInvertedInner(e, t, n, 0); 14699}, $.prototype.map = function(e, t, n) { 14700 t === void 0 && (t = 0), n === void 0 && (n = this.length); 14701 var r = []; 14702 return this.forEach(function(t, n) { 14703 return r.push(e(t, n)); 14704 }, t, n), r; 14705}, $.from = function(e) { 14706 return e instanceof $ ? e : e && e.length ? new v_(e) : $.empty; 14707}; 14708var v_ = /* @__PURE__ */ function(e) { 14709 function t(t) { 14710 e.call(this), this.values = t; 14711 } 14712 e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t; 14713 var n = { 14714 length: { configurable: !0 }, 14715 depth: { configurable: !0 } 14716 }; 14717 return t.prototype.flatten = function() { 14718 return this.values; 14719 }, t.prototype.sliceInner = function(e, n) { 14720 return e == 0 && n == this.length ? this : new t(this.values.slice(e, n)); 14721 }, t.prototype.getInner = function(e) { 14722 return this.values[e]; 14723 }, t.prototype.forEachInner = function(e, t, n, r) { 14724 for (var i = t; i < n; i++) if (e(this.values[i], r + i) === !1) return !1; 14725 }, t.prototype.forEachInvertedInner = function(e, t, n, r) { 14726 for (var i = t - 1; i >= n; i--) if (e(this.values[i], r + i) === !1) return !1; 14727 }, t.prototype.leafAppend = function(e) { 14728 if (this.length + e.length <= __) return new t(this.values.concat(e.flatten())); 14729 }, t.prototype.leafPrepend = function(e) { 14730 if (this.length + e.length <= __) return new t(e.flatten().concat(this.values)); 14731 }, n.length.get = function() { 14732 return this.values.length; 14733 }, n.depth.get = function() { 14734 return 0; 14735 }, Object.defineProperties(t.prototype, n), t; 14736}($); 14737$.empty = new v_([]); 14738var y_ = /* @__PURE__ */ function(e) { 14739 function t(t, n) { 14740 e.call(this), this.left = t, this.right = n, this.length = t.length + n.length, this.depth = Math.max(t.depth, n.depth) + 1; 14741 } 14742 return e && (t.__proto__ = e), t.prototype = Object.create(e && e.prototype), t.prototype.constructor = t, t.prototype.flatten = function() { 14743 return this.left.flatten().concat(this.right.flatten()); 14744 }, t.prototype.getInner = function(e) { 14745 return e < this.left.length ? this.left.get(e) : this.right.get(e - this.left.length); 14746 }, t.prototype.forEachInner = function(e, t, n, r) { 14747 var i = this.left.length; 14748 if (t < i && this.left.forEachInner(e, t, Math.min(n, i), r) === !1 || n > i && this.right.forEachInner(e, Math.max(t - i, 0), Math.min(this.length, n) - i, r + i) === !1) return !1; 14749 }, t.prototype.forEachInvertedInner = function(e, t, n, r) { 14750 var i = this.left.length; 14751 if (t > i && this.right.forEachInvertedInner(e, t - i, Math.max(n, i) - i, r + i) === !1 || n < i && this.left.forEachInvertedInner(e, Math.min(t, i), n, r) === !1) return !1; 14752 }, t.prototype.sliceInner = function(e, t) { 14753 if (e == 0 && t == this.length) return this; 14754 var n = this.left.length; 14755 return t <= n ? this.left.slice(e, t) : e >= n ? this.right.slice(e - n, t - n) : this.left.slice(e, n).append(this.right.slice(0, t - n)); 14756 }, t.prototype.leafAppend = function(e) { 14757 var n = this.right.leafAppend(e); 14758 if (n) return new t(this.left, n); 14759 }, t.prototype.leafPrepend = function(e) { 14760 var n = this.left.leafPrepend(e); 14761 if (n) return new t(n, this.right); 14762 }, t.prototype.appendInner = function(e) { 14763 return this.left.depth >= Math.max(this.right.depth, e.depth) + 1 ? new t(this.left, new t(this.right, e)) : new t(this, e); 14764 }, t; 14765}($), b_ = 500, x_ = class e { 14766 constructor(e, t) { 14767 this.items = e, this.eventCount = t; 14768 } 14769 popEvent(t, n) { 14770 if (this.eventCount == 0) return null; 14771 let r = this.items.length; 14772 for (;; r--) if (this.items.get(r - 1).selection) { 14773 --r; 14774 break; 14775 } 14776 let i, a; 14777 n && (i = this.remapping(r, this.items.length), a = i.maps.length); 14778 let o = t.tr, s, c, l = [], u = []; 14779 return this.items.forEach((t, n) => { 14780 if (!t.step) { 14781 i || (i = this.remapping(r, n + 1), a = i.maps.length), a--, u.push(t); 14782 return; 14783 } 14784 if (i) { 14785 u.push(new C_(t.map)); 14786 let e = t.step.map(i.slice(a)), n; 14787 e && o.maybeStep(e).doc && (n = o.mapping.maps[o.mapping.maps.length - 1], l.push(new C_(n, void 0, void 0, l.length + u.length))), a--, n && i.appendMap(n, a); 14788 } else o.maybeStep(t.step); 14789 if (t.selection) return s = i ? t.selection.map(i.slice(a)) : t.selection, c = new e(this.items.slice(0, r).append(u.reverse().concat(l)), this.eventCount - 1), !1; 14790 }, this.items.length, 0), { 14791 remaining: c, 14792 transform: o, 14793 selection: s 14794 }; 14795 } 14796 addTransform(t, n, r, i) { 14797 let a = [], o = this.eventCount, s = this.items, c = !i && s.length ? s.get(s.length - 1) : null; 14798 for (let e = 0; e < t.steps.length; e++) { 14799 let r = t.steps[e].invert(t.docs[e]), l = new C_(t.mapping.maps[e], r, n), u; 14800 (u = c && c.merge(l)) && (l = u, e ? a.pop() : s = s.slice(0, s.length - 1)), a.push(l), n &&= (o++, void 0), i || (c = l); 14801 } 14802 let l = o - r.depth; 14803 return l > T_ && (s = S_(s, l), o -= l), new e(s.append(a), o); 14804 } 14805 remapping(e, t) { 14806 let n = new gt(); 14807 return this.items.forEach((t, r) => { 14808 let i = t.mirrorOffset != null && r - t.mirrorOffset >= e ? n.maps.length - t.mirrorOffset : void 0; 14809 n.appendMap(t.map, i); 14810 }, e, t), n; 14811 } 14812 addMaps(t) { 14813 return this.eventCount == 0 ? this : new e(this.items.append(t.map((e) => new C_(e))), this.eventCount); 14814 } 14815 rebased(t, n) { 14816 if (!this.eventCount) return this; 14817 let r = [], i = Math.max(0, this.items.length - n), a = t.mapping, o = t.steps.length, s = this.eventCount; 14818 this.items.forEach((e) => { 14819 e.selection && s--; 14820 }, i); 14821 let c = n; 14822 this.items.forEach((e) => { 14823 let n = a.getMirror(--c); 14824 if (n == null) return; 14825 o = Math.min(o, n); 14826 let i = a.maps[n]; 14827 if (e.step) { 14828 let o = t.steps[n].invert(t.docs[n]), l = e.selection && e.selection.map(a.slice(c + 1, n)); 14829 l && s++, r.push(new C_(i, o, l)); 14830 } else r.push(new C_(i)); 14831 }, i); 14832 let l = []; 14833 for (let e = n; e < o; e++) l.push(new C_(a.maps[e])); 14834 let u = new e(this.items.slice(0, i).append(l).append(r), s); 14835 return u.emptyItemCount() > b_ && (u = u.compress(this.items.length - r.length)), u; 14836 } 14837 emptyItemCount() { 14838 let e = 0; 14839 return this.items.forEach((t) => { 14840 t.step || e++; 14841 }), e; 14842 } 14843 compress(t = this.items.length) { 14844 let n = this.remapping(0, t), r = n.maps.length, i = [], a = 0; 14845 return this.items.forEach((e, o) => { 14846 if (o >= t) i.push(e), e.selection && a++; 14847 else if (e.step) { 14848 let t = e.step.map(n.slice(r)), o = t && t.getMap(); 14849 if (r--, o && n.appendMap(o, r), t) { 14850 let s = e.selection && e.selection.map(n.slice(r)); 14851 s && a++; 14852 let c = new C_(o.invert(), t, s), l, u = i.length - 1; 14853 (l = i.length && i[u].merge(c)) ? i[u] = l : i.push(c); 14854 } 14855 } else e.map && r--; 14856 }, this.items.length, 0), new e($.from(i.reverse()), a); 14857 } 14858}; 14859x_.empty = new x_($.empty, 0); 14860function S_(e, t) { 14861 let n; 14862 return e.forEach((e, r) => { 14863 if (e.selection && t-- == 0) return n = r, !1; 14864 }), e.slice(n); 14865} 14866var C_ = class e { 14867 constructor(e, t, n, r) { 14868 this.map = e, this.step = t, this.selection = n, this.mirrorOffset = r; 14869 } 14870 merge(t) { 14871 if (this.step && t.step && !t.selection) { 14872 let n = t.step.merge(this.step); 14873 if (n) return new e(n.getMap().invert(), n, this.selection); 14874 } 14875 } 14876}, w_ = class { 14877 constructor(e, t, n, r, i) { 14878 this.done = e, this.undone = t, this.prevRanges = n, this.prevTime = r, this.prevComposition = i; 14879 } 14880}, T_ = 20; 14881function E_(e, t, n, r) { 14882 let i = n.getMeta(P_), a; 14883 if (i) return i.historyState; 14884 n.getMeta(F_) && (e = new w_(e.done, e.undone, null, 0, -1)); 14885 let o = n.getMeta("appendedTransaction"); 14886 if (n.steps.length == 0) return e; 14887 if (o && o.getMeta(P_)) return o.getMeta(P_).redo ? new w_(e.done.addTransform(n, void 0, r, N_(t)), e.undone, O_(n.mapping.maps), e.prevTime, e.prevComposition) : new w_(e.done, e.undone.addTransform(n, void 0, r, N_(t)), null, e.prevTime, e.prevComposition); 14888 if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) { 14889 let i = n.getMeta("composition"), a = e.prevTime == 0 || !o && e.prevComposition != i && (e.prevTime < (n.time || 0) - r.newGroupDelay || !D_(n, e.prevRanges)), s = o ? k_(e.prevRanges, n.mapping) : O_(n.mapping.maps); 14890 return new w_(e.done.addTransform(n, a ? t.selection.getBookmark() : void 0, r, N_(t)), x_.empty, s, n.time, i ?? e.prevComposition); 14891 } else if (a = n.getMeta("rebased")) return new w_(e.done.rebased(n, a), e.undone.rebased(n, a), k_(e.prevRanges, n.mapping), e.prevTime, e.prevComposition); 14892 else return new w_(e.done.addMaps(n.mapping.maps), e.undone.addMaps(n.mapping.maps), k_(e.prevRanges, n.mapping), e.prevTime, e.prevComposition); 14893} 14894function D_(e, t) { 14895 if (!t) return !1; 14896 if (!e.docChanged) return !0; 14897 let n = !1; 14898 return e.mapping.maps[0].forEach((e, r) => { 14899 for (let i = 0; i < t.length; i += 2) e <= t[i + 1] && r >= t[i] && (n = !0); 14900 }), n; 14901} 14902function O_(e) { 14903 let t = []; 14904 for (let n = e.length - 1; n >= 0 && t.length == 0; n--) e[n].forEach((e, n, r, i) => t.push(r, i)); 14905 return t; 14906} 14907function k_(e, t) { 14908 if (!e) return null; 14909 let n = []; 14910 for (let r = 0; r < e.length; r += 2) { 14911 let i = t.map(e[r], 1), a = t.map(e[r + 1], -1); 14912 i <= a && n.push(i, a); 14913 } 14914 return n; 14915} 14916function A_(e, t, n) { 14917 let r = N_(t), i = P_.get(t).spec.config, a = (n ? e.undone : e.done).popEvent(t, r); 14918 if (!a) return null; 14919 let o = a.selection.resolve(a.transform.doc), s = (n ? e.done : e.undone).addTransform(a.transform, t.selection.getBookmark(), i, r), c = new w_(n ? s : a.remaining, n ? a.remaining : s, null, 0, -1); 14920 return a.transform.setSelection(o).setMeta(P_, { 14921 redo: n, 14922 historyState: c 14923 }); 14924} 14925var j_ = !1, M_ = null; 14926function N_(e) { 14927 let t = e.plugins; 14928 if (M_ != t) { 14929 j_ = !1, M_ = t; 14930 for (let e = 0; e < t.length; e++) if (t[e].spec.historyPreserveItems) { 14931 j_ = !0; 14932 break; 14933 } 14934 } 14935 return j_; 14936} 14937var P_ = new O("history"), F_ = new O("closeHistory"); 14938function I_(e = {}) { 14939 return e = { 14940 depth: e.depth || 100, 14941 newGroupDelay: e.newGroupDelay || 500 14942 }, new D({ 14943 key: P_, 14944 state: { 14945 init() { 14946 return new w_(x_.empty, x_.empty, null, 0, -1); 14947 }, 14948 apply(t, n, r) { 14949 return E_(n, r, t, e); 14950 } 14951 }, 14952 config: e, 14953 props: { handleDOMEvents: { beforeinput(e, t) { 14954 let n = t.inputType, r = n == "historyUndo" ? R_ : n == "historyRedo" ? z_ : null; 14955 return !r || !e.editable ? !1 : (t.preventDefault(), r(e.state, e.dispatch)); 14956 } } } 14957 }); 14958} 14959function L_(e, t) { 14960 return (n, r) => { 14961 let i = P_.getState(n); 14962 if (!i || (e ? i.undone : i.done).eventCount == 0) return !1; 14963 if (r) { 14964 let a = A_(i, n, e); 14965 a && r(t ? a.scrollIntoView() : a); 14966 } 14967 return !0; 14968 }; 14969} 14970var R_ = L_(!1, !0), z_ = L_(!0, !0); 14971V.create({ 14972 name: "characterCount", 14973 addOptions() { 14974 return { 14975 limit: null, 14976 autoTrim: !0, 14977 mode: "textSize", 14978 textCounter: (e) => e.length, 14979 wordCounter: (e) => e.split(" ").filter((e) => e !== "").length 14980 }; 14981 }, 14982 addStorage() { 14983 return { 14984 characters: () => 0, 14985 words: () => 0 14986 }; 14987 }, 14988 onBeforeCreate() { 14989 this.storage.characters = (e) => { 14990 let t = e?.node || this.editor.state.doc; 14991 if ((e?.mode || this.options.mode) === "textSize") { 14992 let e = t.textBetween(0, t.content.size, void 0, " "); 14993 return this.options.textCounter(e); 14994 } 14995 return t.nodeSize; 14996 }, this.storage.words = (e) => { 14997 let t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " "); 14998 return this.options.wordCounter(n); 14999 }; 15000 }, 15001 addProseMirrorPlugins() { 15002 let e = !1; 15003 return [new D({ 15004 key: new O("characterCount"), 15005 appendTransaction: (t, n, r) => { 15006 if (e) return; 15007 let i = this.options.limit, a = this.options.autoTrim; 15008 if (i == null || i === 0 || a === !1) { 15009 e = !0; 15010 return; 15011 } 15012 let o = this.storage.characters({ node: r.doc }); 15013 if (o > i) { 15014 let t = o - i; 15015 console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`); 15016 let n = r.tr.deleteRange(0, t); 15017 return e = !0, n; 15018 } 15019 e = !0; 15020 }, 15021 filterTransaction: (e, t) => { 15022 let n = this.options.limit; 15023 if (!e.docChanged || n === 0 || n == null) return !0; 15024 let r = this.storage.characters({ node: t.doc }), i = this.storage.characters({ node: e.doc }); 15025 if (i <= n || r > n && i > n && i <= r) return !0; 15026 if (r > n && i > n && i > r || !e.getMeta("paste")) return !1; 15027 let a = e.selection.$head.pos, o = a - (i - n), s = a; 15028 return e.deleteRange(o, s), !(this.storage.characters({ node: e.doc }) > n); 15029 } 15030 })]; 15031 } 15032}); 15033var B_ = V.create({ 15034 name: "dropCursor", 15035 addOptions() { 15036 return { 15037 color: "currentColor", 15038 width: 1, 15039 class: void 0 15040 }; 15041 }, 15042 addProseMirrorPlugins() { 15043 return [i_(this.options)]; 15044 } 15045}); 15046V.create({ 15047 name: "focus", 15048 addOptions() { 15049 return { 15050 className: "has-focus", 15051 mode: "all" 15052 }; 15053 }, 15054 addProseMirrorPlugins() { 15055 return [new D({ 15056 key: new O("focus"), 15057 props: { decorations: ({ doc: e, selection: t }) => { 15058 let { isEditable: n, isFocused: r } = this.editor, { anchor: i } = t, a = []; 15059 if (!n || !r) return P.create(e, []); 15060 let o = 0; 15061 this.options.mode === "deepest" && e.descendants((e, t) => { 15062 if (!e.isText) { 15063 if (!(i >= t && i <= t + e.nodeSize - 1)) return !1; 15064 o += 1; 15065 } 15066 }); 15067 let s = 0; 15068 return e.descendants((e, t) => { 15069 if (e.isText || !(i >= t && i <= t + e.nodeSize - 1)) return !1; 15070 if (s += 1, this.options.mode === "deepest" && o - s > 0 || this.options.mode === "shallowest" && s > 1) return this.options.mode === "deepest"; 15071 a.push(is.node(t, t + e.nodeSize, { class: this.options.className })); 15072 }), P.create(e, a); 15073 } } 15074 })]; 15075 } 15076}); 15077var V_ = V.create({ 15078 name: "gapCursor", 15079 addProseMirrorPlugins() { 15080 return [d_()]; 15081 }, 15082 extendNodeSchema(e) { 15083 return { allowGapCursor: z(R(e, "allowGapCursor", { 15084 name: e.name, 15085 options: e.options, 15086 storage: e.storage 15087 })) ?? null }; 15088 } 15089}), H_ = "placeholder", U_ = new O("tiptap__placeholder"), W_ = 200; 15090function G_(e) { 15091 let { editor: t, placeholder: n, dataAttribute: r, pos: i, node: a, isEmptyDoc: o, hasAnchor: s, classes: { emptyNode: c, emptyEditor: l } } = e, u = [c]; 15092 return o && u.push(l), is.node(i, i + a.nodeSize, { 15093 class: u.join(" "), 15094 [r]: typeof n == "function" ? n({ 15095 editor: t, 15096 node: a, 15097 pos: i, 15098 hasAnchor: s 15099 }) : n 15100 }); 15101} 15102function K_(e, t) { 15103 return typeof e == "function" ? e(t) : e; 15104} 15105function q_({ editor: e, options: t, dataAttribute: n, doc: r, selection: i }) { 15106 if (!(e.isEditable || !t.showOnlyWhenEditable)) return null; 15107 let { anchor: a } = i, o = [], s = e.isEmpty; 15108 if (t.showOnlyCurrent && !t.includeChildren) { 15109 let i = r.resolve(a), c = i.depth > 0 ? i.node(1) : i.nodeAfter, l = i.depth > 0 ? i.before(1) : a; 15110 if (c && c.type.isTextblock && du(c)) { 15111 let r = a >= l && a <= l + c.nodeSize; 15112 o.push(G_({ 15113 editor: e, 15114 isEmptyDoc: s, 15115 dataAttribute: n, 15116 hasAnchor: r, 15117 placeholder: t.placeholder, 15118 classes: { 15119 emptyEditor: t.emptyEditorClass, 15120 emptyNode: K_(t.emptyNodeClass, { 15121 editor: e, 15122 node: c, 15123 pos: l, 15124 hasAnchor: r 15125 }) 15126 }, 15127 node: c, 15128 pos: l 15129 })); 15130 } 15131 } else { 15132 let i = U_.getState(e.state), c = i?.topPos ?? 0, l = i?.bottomPos ?? r.content.size; 15133 r.nodesBetween(c, l, (r, i) => { 15134 let c = a >= i && a <= i + r.nodeSize, l = !r.isLeaf && du(r); 15135 return r.type.isTextblock && (c || !t.showOnlyCurrent) && l && o.push(G_({ 15136 editor: e, 15137 isEmptyDoc: s, 15138 dataAttribute: n, 15139 hasAnchor: c, 15140 placeholder: t.placeholder, 15141 classes: { 15142 emptyEditor: t.emptyEditorClass, 15143 emptyNode: K_(t.emptyNodeClass, { 15144 editor: e, 15145 node: r, 15146 pos: i, 15147 hasAnchor: c 15148 }) 15149 }, 15150 node: r, 15151 pos: i 15152 })), t.includeChildren; 15153 }); 15154 } 15155 return P.create(r, o); 15156} 15157function J_(e) { 15158 return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase(); 15159} 15160function Y_(e) { 15161 let t = getComputedStyle(e), n = `${t.overflow} ${t.overflowY} ${t.overflowX}`; 15162 return /auto|scroll|overlay/.test(n); 15163} 15164function X_(e) { 15165 let t = e; 15166 for (; t;) { 15167 if (Y_(t)) return t; 15168 let e = t.parentElement; 15169 if (!e) { 15170 let e = t.getRootNode(); 15171 if (e instanceof ShadowRoot) { 15172 t = e.host; 15173 continue; 15174 } 15175 return window; 15176 } 15177 t = e; 15178 } 15179 return window; 15180} 15181function Z_(e) { 15182 return e === window ? { 15183 top: 0, 15184 bottom: window.innerHeight 15185 } : e.getBoundingClientRect(); 15186} 15187function Q_({ view: e, scrollContainer: t }) { 15188 let n = e.dom.getBoundingClientRect(); 15189 if (n.width <= 0 || n.height <= 0) return null; 15190 let r = t ? Z_(t) : { 15191 top: 0, 15192 bottom: window.innerHeight 15193 }, i = Math.max(n.top, r.top) - W_, a = Math.min(n.bottom, r.bottom) + W_; 15194 if (i >= a) return null; 15195 let o = n.left + 1, s = n.right - 1; 15196 if (o > s) return null; 15197 let c = getComputedStyle(e.dom).direction === "rtl" ? n.right - 2 : n.left + 2, l = Math.min(Math.max(c, o), s), u = Math.max(i + 2, n.top + 1), d = Math.min(a - 2, n.bottom - 1); 15198 if (u > d) return null; 15199 let f = e.posAtCoords({ 15200 left: l, 15201 top: u 15202 }), p = e.posAtCoords({ 15203 left: l, 15204 top: d 15205 }); 15206 return !f || !p ? null : { 15207 top: f.pos, 15208 bottom: p.pos 15209 }; 15210} 15211var $_ = { 15212 init() { 15213 return { 15214 topPos: null, 15215 bottomPos: null 15216 }; 15217 }, 15218 apply(e, t) { 15219 let n = e.getMeta(U_); 15220 return n?.positions ? { 15221 topPos: n.positions.top, 15222 bottomPos: n.positions.bottom 15223 } : e.docChanged ? { 15224 topPos: t.topPos === null ? null : e.mapping.map(t.topPos), 15225 bottomPos: t.bottomPos === null ? null : e.mapping.map(t.bottomPos) 15226 } : t; 15227 } 15228}; 15229function ev(e) { 15230 let t = X_(e.dom), n = () => { 15231 let n = Q_({ 15232 view: e, 15233 scrollContainer: t 15234 }); 15235 if (n === null) return; 15236 let r = U_.getState(e.state); 15237 if (r?.topPos === n.top && r?.bottomPos === n.bottom) return; 15238 let i = e.state.tr.setMeta(U_, { positions: n }); 15239 e.dispatch(i); 15240 }, r = null, i = 0, a = () => { 15241 r === null && (r = requestAnimationFrame(() => { 15242 r = null; 15243 let e = performance.now(); 15244 e - i >= 150 ? (i = e, n()) : a(); 15245 })); 15246 }; 15247 t.addEventListener("scroll", a, { passive: !0 }); 15248 let o = typeof ResizeObserver < "u" ? new ResizeObserver(a) : null; 15249 o?.observe(e.dom); 15250 let s = typeof IntersectionObserver < "u" ? new IntersectionObserver(a) : null; 15251 return s?.observe(e.dom), e.dom.addEventListener("focus", a), n(), { 15252 update(t, n) { 15253 e.state.doc.content.size !== n.doc.content.size && a(); 15254 }, 15255 destroy: () => { 15256 r !== null && cancelAnimationFrame(r), t.removeEventListener("scroll", a), o?.disconnect(), s?.disconnect(), e.dom.removeEventListener("focus", a); 15257 } 15258 }; 15259} 15260function tv({ editor: e, options: t }) { 15261 let n = t.dataAttribute ? `data-${J_(t.dataAttribute)}` : `data-${H_}`; 15262 return new D({ 15263 key: U_, 15264 state: $_, 15265 view: ev, 15266 props: { decorations: ({ doc: r, selection: i }) => q_({ 15267 editor: e, 15268 options: t, 15269 dataAttribute: n, 15270 doc: r, 15271 selection: i 15272 }) } 15273 }); 15274} 15275V.create({ 15276 name: "placeholder", 15277 addOptions() { 15278 return { 15279 emptyEditorClass: "is-editor-empty", 15280 emptyNodeClass: "is-empty", 15281 dataAttribute: H_, 15282 placeholder: "Write something â¦", 15283 showOnlyWhenEditable: !0, 15284 showOnlyCurrent: !0, 15285 includeChildren: !1 15286 }; 15287 }, 15288 addProseMirrorPlugins() { 15289 return [tv({ 15290 editor: this.editor, 15291 options: this.options 15292 })]; 15293 } 15294}); 15295var nv = ".ProseMirror:not(.ProseMirror-focused) *::selection {\n background: transparent;\n}\n\n.ProseMirror:not(.ProseMirror-focused) *::-moz-selection {\n background: transparent;\n}"; 15296V.create({ 15297 name: "selection", 15298 addOptions() { 15299 return { className: "selection" }; 15300 }, 15301 addProseMirrorPlugins() { 15302 let { editor: e, options: t } = this; 15303 return e.options.injectCSS && typeof document < "u" && Gu(nv, e.options.injectNonce, "selection"), [new D({ 15304 key: new O("selection"), 15305 props: { decorations(n) { 15306 return n.selection.empty || e.isFocused || !e.isEditable || fu(n.selection) || e.view.dragging ? null : P.create(n.doc, [is.inline(n.selection.from, n.selection.to, { class: t.className })]); 15307 } } 15308 })]; 15309 } 15310}); 15311function rv({ types: e, node: t }) { 15312 return t && Array.isArray(e) && e.includes(t.type) || t?.type === e; 15313} 15314var iv = V.create({ 15315 name: "trailingNode", 15316 addOptions() { 15317 return { 15318 node: void 0, 15319 notAfter: [] 15320 }; 15321 }, 15322 addProseMirrorPlugins() { 15323 let e = new O(this.name), t = this.options.node || this.editor.schema.topNodeType.contentMatch.defaultType?.name || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, e]) => e).filter((e) => (this.options.notAfter || []).concat(t).includes(e.name)); 15324 return [new D({ 15325 key: e, 15326 appendTransaction: (n, r, i) => { 15327 let { doc: a, tr: o, schema: s } = i, c = e.getState(i), l = a.content.size, u = s.nodes[t]; 15328 if (!n.some((e) => e.getMeta("skipTrailingNode")) && c) return o.insert(l, u.create()); 15329 }, 15330 state: { 15331 init: (e, t) => { 15332 let r = t.tr.doc.lastChild; 15333 return !rv({ 15334 node: r, 15335 types: n 15336 }); 15337 }, 15338 apply: (e, t) => { 15339 if (!e.docChanged || e.getMeta("__uniqueIDTransaction")) return t; 15340 let r = e.doc.lastChild; 15341 return !rv({ 15342 node: r, 15343 types: n 15344 }); 15345 } 15346 } 15347 })]; 15348 } 15349}), av = V.create({ 15350 name: "undoRedo", 15351 addOptions() { 15352 return { 15353 depth: 100, 15354 newGroupDelay: 500 15355 }; 15356 }, 15357 addCommands() { 15358 return { 15359 undo: () => ({ state: e, dispatch: t }) => R_(e, t), 15360 redo: () => ({ state: e, dispatch: t }) => z_(e, t) 15361 }; 15362 }, 15363 addProseMirrorPlugins() { 15364 return [I_(this.options)]; 15365 }, 15366 addKeyboardShortcuts() { 15367 return { 15368 "Mod-z": () => this.editor.commands.undo(), 15369 "Shift-Mod-z": () => this.editor.commands.redo(), 15370 "Mod-y": () => this.editor.commands.redo(), 15371 "Mod-Ñ": () => this.editor.commands.undo(), 15372 "Shift-Mod-Ñ": () => this.editor.commands.redo() 15373 }; 15374 } 15375}), ov = V.create({ 15376 name: "starterKit", 15377 addExtensions() { 15378 let e = []; 15379 return this.options.bold !== !1 && e.push(_p.configure(this.options.bold)), this.options.blockquote !== !1 && e.push(fp.configure(this.options.blockquote)), this.options.bulletList !== !1 && e.push(Xh.configure(this.options.bulletList)), this.options.code !== !1 && e.push(bp.configure(this.options.code)), this.options.codeBlock !== !1 && e.push(wp.configure(this.options.codeBlock)), this.options.document !== !1 && e.push(Tp.configure(this.options.document)), this.options.dropcursor !== !1 && e.push(B_.configure(this.options.dropcursor)), this.options.gapcursor !== !1 && e.push(V_.configure(this.options.gapcursor)), this.options.hardBreak !== !1 && e.push(Ep.configure(this.options.hardBreak)), this.options.heading !== !1 && e.push(Dp.configure(this.options.heading)), this.options.undoRedo !== !1 && e.push(av.configure(this.options.undoRedo)), this.options.horizontalRule !== !1 && e.push(Op.configure(this.options.horizontalRule)), this.options.italic !== !1 && e.push(Np.configure(this.options.italic)), this.options.listItem !== !1 && e.push(yg.configure(this.options.listItem)), this.options.listKeymap !== !1 && e.push(Ag.configure(this.options?.listKeymap)), this.options.link !== !1 && e.push(Wh.configure(this.options?.link)), this.options.orderedList !== !1 && e.push(Kg.configure(this.options.orderedList)), this.options.paragraph !== !1 && e.push(Qg.configure(this.options.paragraph)), this.options.strike !== !1 && e.push(t_.configure(this.options.strike)), this.options.text !== !1 && e.push(n_.configure(this.options.text)), this.options.underline !== !1 && e.push(r_.configure(this.options?.underline)), this.options.trailingNode !== !1 && e.push(iv.configure(this.options?.trailingNode)), e; 15380 } 15381}), sv = H.create({ 15382 name: "mediaImage", 15383 group: "block", 15384 inline: !1, 15385 draggable: !0, 15386 selectable: !0, 15387 atom: !0, 15388 addAttributes() { 15389 return { 15390 mediaId: { 15391 default: null, 15392 parseHTML: (e) => e.getAttribute("data-media-id") 15393 }, 15394 src: { default: null }, 15395 alt: { default: "" }, 15396 width: { default: null }, 15397 height: { default: null }, 15398 class: { default: null }, 15399 style: { default: null } 15400 }; 15401 }, 15402 parseHTML() { 15403 return [{ tag: "img[data-media-id]" }]; 15404 }, 15405 renderHTML({ HTMLAttributes: e }) { 15406 let { mediaId: t, ...n } = e; 15407 return ["img", B(n, { 15408 "data-media-id": t, 15409 loading: "lazy"
15410 })]; 15411 }, 15412 addCommands() { 15413 return { 15414 insertMediaImage: (e) => ({ commands: t }) => t.insertContent({ 15415 type: this.name, 15416 attrs: e 15417 }), 15418 updateMediaImage: (e) => ({ commands: t }) => t.updateAttributes(this.name, e) 15419 }; 15420 } 15421}); 15422//#endregion 15423//#region resources/js/editor.js 15424function cv(e = {}) { 15425 let t = null, n = null; 15426 return { 15427 image: { 15428 active: !1, 15429 width: "", 15430 height: "", 15431 align: "none", 15432 style: "" 15433 }, 15434 selectionTick: 0, 15435 init() { 15436 let e = this.$refs.editor; 15437 if (e.__cmsEditor) { 15438 t = e.__cmsEditor; 15439 return; 15440 } 15441 t = new Md({ 15442 element: e, 15443 extensions: [ov.configure({ link: { openOnClick: !1 } }), sv], 15444 content: this.initialContent(), 15445 onUpdate: ({ editor: e }) => { 15446 this.pushToLivewire(e), this.selectionTick++; 15447 }, 15448 onSelectionUpdate: () => { 15449 this.syncImagePanel(), this.selectionTick++; 15450 } 15451 }), e.__cmsEditor = t, e.addEventListener("cms-editor:open-picker", () => { 15452 this.$wire.openPicker(); 15453 }), this.$wire.on("cms-editor:insert-image", ({ media: e }) => { 15454 t && t.chain().focus().insertMediaImage({ 15455 mediaId: e.mediaId, 15456 src: e.src, 15457 alt: e.alt ?? "", 15458 width: e.width ?? null, 15459 height: e.height ?? null 15460 }).run(); 15461 }), this.$wire.on("cms-editor:load-document", ({ doc: e }) => { 15462 t?.commands.setContent(e, !1); 15463 }); 15464 }, 15465 destroy() { 15466 let e = this.$refs?.editor; 15467 e && e.__cmsEditor === t && delete e.__cmsEditor, t?.destroy(), t = null; 15468 }, 15469 initialContent() { 15470 let t = this.$wire.get(e.property ?? "content"); 15471 return t && Object.keys(t).length ? t : ""; 15472 }, 15473 pushToLivewire(t) { 15474 clearTimeout(n), n = setTimeout(() => { 15475 this.$wire.set(e.property ?? "content", t.getJSON()); 15476 }, e.debounce ?? 400); 15477 }, 15478 cmd(e) { 15479 if (!t) return; 15480 let n = t.chain().focus(); 15481 ({ 15482 bold: () => n.toggleBold(), 15483 italic: () => n.toggleItalic(), 15484 underline: () => n.toggleUnderline(), 15485 strike: () => n.toggleStrike(), 15486 h2: () => n.toggleHeading({ level: 2 }), 15487 h3: () => n.toggleHeading({ level: 3 }), 15488 paragraph: () => n.setParagraph(), 15489 bulletList: () => n.toggleBulletList(), 15490 orderedList: () => n.toggleOrderedList(), 15491 blockquote: () => n.toggleBlockquote(), 15492 link: () => this.promptLink(n), 15493 image: () => (this.$wire.openPicker(), n), 15494 undo: () => n.undo(), 15495 redo: () => n.redo() 15496 }[e]?.() ?? n).run(); 15497 }, 15498 isActive(e, n = {}) { 15499 return this.selectionTick, t?.isActive(e, n) ?? !1; 15500 }, 15501 promptLink(e) { 15502 let t = window.prompt("Link URL"); 15503 return t === null ? e : t === "" ? e.unsetLink() : e.setLink({ href: t }); 15504 }, 15505 _alignClasses: { 15506 left: "alignleft", 15507 center: "aligncenter", 15508 right: "alignright" 15509 }, 15510 syncImagePanel() { 15511 if (!t) return; 15512 let e = t.isActive("mediaImage"); 15513 if (this.image.active = e, !e) return; 15514 let n = t.getAttributes("mediaImage"); 15515 this.image.width = n.width ?? "", this.image.height = n.height ?? "", this.image.style = n.style ?? "", this.image.align = this.alignFromClass(n.class); 15516 }, 15517 alignFromClass(e) { 15518 for (let [t, n] of Object.entries(this._alignClasses)) if ((e ?? "").split(/\s+/).includes(n)) return t; 15519 return "none"; 15520 }, 15521 setImageSize(e, t) { 15522 let n = t === "" || t === null ? null : Number(t); 15523 this.updateSelectedImage({ [e]: Number.isFinite(n) ? n : null }); 15524 }, 15525 setImageAlign(e) { 15526 this.image.align = e, this.updateSelectedImage({ class: this._alignClasses[e] ?? null }); 15527 }, 15528 setImageStyle(e) { 15529 this.updateSelectedImage({ style: e?.trim() ? e.trim() : null }); 15530 }, 15531 updateSelectedImage(e) { 15532 t?.chain().focus().updateMediaImage(e).run(); 15533 } 15534 }; 15535} 15536//#endregion 15537//#region resources/js/index.js 15538function lv(e) { 15539 e.data("cmsEditor", cv); 15540} 15541typeof window < "u" && window.Alpine ? lv(window.Alpine) : typeof document < "u" && document.addEventListener("alpine:init", () => { 15542 window.Alpine && lv(window.Alpine); 15543}); 15544//#endregion 15545export { sv as MediaImage, cv as cmsEditor, lv as registerCmsEditor };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.