vendor: 5,745 bytes, lines 1-185
1var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 2 3function getDefaultExportFromCjs (x) { 4 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; 5} 6 7var prism = {exports: {}}; 8 9var hasRequiredPrism; 10 11function requirePrism () { 12 if (hasRequiredPrism) return prism.exports; 13 hasRequiredPrism = 1; 14 (function (module) { 15 /* ********************************************** 16 Begin prism-core.js 17 ********************************************** */ 18 19 /// <reference lib="WebWorker"/> 20 21 var _self = (typeof window !== 'undefined') 22 ? window // if in browser 23 : ( 24 (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) 25 ? self // if in worker 26 : {} // if in node js 27 ); 28 29 /** 30 * Prism: Lightweight, robust, elegant syntax highlighting 31 * 32 * @license MIT <https://opensource.org/licenses/MIT> 33 * @author Lea Verou <https://lea.verou.me> 34 * @namespace 35 * @public 36 */ 37 var Prism = (function (_self) { 38 39 // Private helper vars 40 var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i; 41 var uniqueId = 0; 42 43 // The grammar object for plaintext 44 var plainTextGrammar = {}; 45 46 47 var _ = { 48 /** 49 * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the 50 * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load 51 * additional languages or plugins yourself. 52 * 53 * By setting this value to `true`, Prism will not automatically highlight all code elements on the page. 54 * 55 * You obviously have to change this value before the automatic highlighting started. To do this, you can add an 56 * empty Prism object into the global scope before loading the Prism script like this: 57 * 58 * ```js 59 * window.Prism = window.Prism || {}; 60 * Prism.manual = true; 61 * // add a new <script> to load Prism's script 62 * ``` 63 * 64 * @default false 65 * @type {boolean} 66 * @memberof Prism 67 * @public 68 */ 69 manual: _self.Prism && _self.Prism.manual, 70 /** 71 * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses 72 * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your 73 * own worker, you don't want it to do this. 74 * 75 * By setting this value to `true`, Prism will not add its own listeners to the worker. 76 * 77 * You obviously have to change this value before Prism executes. To do this, you can add an 78 * empty Prism object into the global scope before loading the Prism script like this: 79 * 80 * ```js 81 * window.Prism = window.Prism || {}; 82 * Prism.disableWorkerMessageHandler = true; 83 * // Load Prism's script 84 * ``` 85 * 86 * @default false 87 * @type {boolean} 88 * @memberof Prism 89 * @public 90 */ 91 disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, 92 93 /** 94 * A namespace for utility methods. 95 * 96 * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may 97 * change or disappear at any time. 98 * 99 * @namespace 100 * @memberof Prism 101 */ 102 util: { 103 encode: function encode(tokens) { 104 if (tokens instanceof Token) { 105 return new Token(tokens.type, encode(tokens.content), tokens.alias); 106 } else if (Array.isArray(tokens)) { 107 return tokens.map(encode); 108 } else { 109 return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' '); 110 } 111 }, 112 113 /** 114 * Returns the name of the type of the given value. 115 * 116 * @param {any} o 117 * @returns {string} 118 * @example 119 * type(null) === 'Null' 120 * type(undefined) === 'Undefined' 121 * type(123) === 'Number' 122 * type('foo') === 'String' 123 * type(true) === 'Boolean' 124 * type([1, 2]) === 'Array' 125 * type({}) === 'Object' 126 * type(String) === 'Function' 127 * type(/abc+/) === 'RegExp' 128 */ 129 type: function (o) { 130 return Object.prototype.toString.call(o).slice(8, -1); 131 }, 132 133 /** 134 * Returns a unique number for the given object. Later calls will still return the same number. 135 * 136 * @param {Object} obj 137 * @returns {number} 138 */ 139 objId: function (obj) { 140 if (!obj['__id']) { 141 Object.defineProperty(obj, '__id', { value: ++uniqueId }); 142 } 143 return obj['__id']; 144 }, 145 146 /** 147 * Creates a deep clone of the given object. 148 * 149 * The main intended use of this function is to clone language definitions. 150 * 151 * @param {T} o 152 * @param {Record<number, any>} [visited] 153 * @returns {T} 154 * @template T 155 */ 156 clone: function deepClone(o, visited) { 157 visited = visited || {}; 158 159 var clone; var id; 160 switch (_.util.type(o)) { 161 case 'Object': 162 id = _.util.objId(o); 163 if (visited[id]) { 164 return visited[id]; 165 } 166 clone = /** @type {Record<string, any>} */ ({}); 167 visited[id] = clone; 168 169 for (var key in o) { 170 if (o.hasOwnProperty(key)) { 171 clone[key] = deepClone(o[key], visited); 172 } 173 } 174 175 return /** @type {any} */ (clone); 176 177 case 'Array': 178 id = _.util.objId(o); 179 if (visited[id]) { 180 return visited[id]; 181 } 182 clone = []; 183 visited[id] = clone; 184 185 (/** @type {Array} */(/** @type {any}
vendor: 4,983 bytes, lines 185-334
185 */(o))).forEach(function (v, i) { 186 clone[i] = deepClone(v, visited); 187 }); 188 189 return /** @type {any} */ (clone); 190 191 default: 192 return o; 193 } 194 }, 195 196 /** 197 * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class. 198 * 199 * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned. 200 * 201 * @param {Element} element 202 * @returns {string} 203 */ 204 getLanguage: function (element) { 205 while (element) { 206 var m = lang.exec(element.className); 207 if (m) { 208 return m[1].toLowerCase(); 209 } 210 element = element.parentElement; 211 } 212 return 'none'; 213 }, 214 215 /** 216 * Sets the Prism `language-xxxx` class of the given element. 217 * 218 * @param {Element} element 219 * @param {string} language 220 * @returns {void} 221 */ 222 setLanguage: function (element, language) { 223 // remove all `language-xxxx` classes 224 // (this might leave behind a leading space) 225 element.className = element.className.replace(RegExp(lang, 'gi'), ''); 226 227 // add the new `language-xxxx` class 228 // (using `classList` will automatically clean up spaces for us) 229 element.classList.add('language-' + language); 230 }, 231 232 /** 233 * Returns the script element that is currently executing. 234 * 235 * This does __not__ work for line script element. 236 * 237 * @returns {HTMLScriptElement | null} 238 */ 239 currentScript: function () { 240 if (typeof document === 'undefined') { 241 return null; 242 } 243 if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) { 244 return /** @type {any} */ (document.currentScript); 245 } 246 247 // IE11 workaround 248 // we'll get the src of the current script by parsing IE11's error stack trace 249 // this will not work for inline scripts 250 251 try { 252 throw new Error(); 253 } catch (err) { 254 // Get file src url from stack. Specifically works with the format of stack traces in IE. 255 // A stack will look like this: 256 // 257 // Error 258 // at _.util.currentScript (http://localhost/components/prism-core.js:119:5) 259 // at Global code (http://localhost/components/prism-core.js:606:1) 260 261 var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1]; 262 if (src) { 263 var scripts = document.getElementsByTagName('script'); 264 for (var i in scripts) { 265 if (scripts[i].src == src) { 266 return scripts[i]; 267 } 268 } 269 } 270 return null; 271 } 272 }, 273 274 /** 275 * Returns whether a given class is active for `element`. 276 * 277 * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated 278 * if `element` or one of its ancestors has the negated version of the given class. The _negated version_ of the 279 * given class is just the given class with a `no-` prefix. 280 * 281 * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is 282 * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its 283 * ancestors have the given class or the negated version of it, then the default activation will be returned. 284 * 285 * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated 286 * version of it, the class is considered active. 287 * 288 * @param {Element} element 289 * @param {string} className 290 * @param {boolean} [defaultActivation=false] 291 * @returns {boolean} 292 */ 293 isActive: function (element, className, defaultActivation) { 294 var no = 'no-' + className; 295 296 while (element) { 297 var classList = element.classList; 298 if (classList.contains(className)) { 299 return true; 300 } 301 if (classList.contains(no)) { 302 return false; 303 } 304 element = element.parentElement; 305 } 306 return !!defaultActivation; 307 } 308 }, 309 310 /** 311 * This namespace contains all currently loaded languages and the some helper functions to create and modify languages. 312 * 313 * @namespace 314 * @memberof Prism 315 * @public 316 */ 317 languages: { 318 /** 319 * The grammar for plain, unformatted text. 320 */ 321 plain: plainTextGrammar, 322 plaintext: plainTextGrammar, 323 text: plainTextGrammar, 324 txt: plainTextGrammar, 325 326 /** 327 * Creates a deep copy of the language with the given id and appends the given tokens. 328 * 329 * If a token in `redef` also appears in the copied language, then the existing token in the copied language 330 * will be overwritten at its original position. 331 * 332 * ## Best practices 333 * 334 * Since the position of overwriting tokens (token in `redef` that over
334write tokens in the copied language) 335 * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to 336 * understand the language definition because, normally, the order of tokens matters in Prism grammars. 337 * 338 * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens. 339 * Furthermore, all non-overwriting tokens should be placed after the overwriting ones. 340 * 341 * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`. 342 * @param {Grammar} redef The new tokens to append. 343 * @returns {Grammar} The new language created. 344 * @public 345 * @example 346 * Prism.languages['css-with-colors'] = Prism.languages.extend('css', { 347 * // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token 348 * // at its original position 349 * 'comment': { ... }, 350 * // CSS doesn't have a 'color' token, so this token will be appended 351 * 'color': /\b(?:red|green|blue)\b/ 352 * }); 353 */ 354 extend: function (id, redef) { 355 var lang = _.util.clone(_.languages[id]); 356 357 for (var key in redef) { 358 lang[key] = redef[key]; 359 } 360 361 return lang; 362 }, 363 364 /** 365 * Inserts tokens _before_ another token in a language definition or any other grammar. 366 * 367 * ## Usage 368 * 369 * This helper method makes it easy to modify existing languages. For example, the CSS language definition 370 * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded 371 * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the 372 * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do 373 * this: 374 * 375 * ```js 376 * Prism.languages.markup.style = { 377 * // token 378 * }; 379 * ``` 380 * 381 * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens 382 * before existing tokens. For the CSS example above, you would use it like this: 383 * 384 * ```js 385 * Prism.languages.insertBefore('markup', 'cdata', { 386 * 'style': { 387 * // token 388 * } 389 * }); 390 * ``` 391 * 392 * ## Special cases 393 * 394 * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar 395 * will be ignored. 396 * 397 * This behavior can be used to insert tokens after `before`: 398 * 399 * ```js 400 * Prism.languages.insertBefore('markup', 'comment', { 401 * 'comment': Prism.languages.markup.comment, 402 * // tokens after 'comment' 403 * }); 404 * ``` 405 * 406 * ## Limitations 407 * 408 * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object 409 * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave 410 * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily 411 * deleting properties which is necessary to insert at arbitrary positions. 412 * 413 * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object. 414 * Instead, it will create a new object and replace all references to the target object with the new one. This 415 * can be done without temporarily deleting properties, so the iteration order is well-defined. 416 * 417 * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if 418 * you hold the target object in a variable, then the value of the variable will not change. 419 * 420 * ```js 421 * var oldMarkup = Prism.languages.markup; 422 * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... }); 423 * 424 * assert(oldMarkup !== Prism.languages.markup); 425 * assert(newMarkup === Prism.languages.markup); 426 * ``` 427 * 428 * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the 429 * object to be modified. 430 * @param {string} before The key to insert before. 431 * @param {Grammar}
vendor: 7,557 bytes, lines 431-653
431 insert An object containing the key-value pairs to be inserted. 432 * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the 433 * object to be modified. 434 * 435 * Defaults to `Prism.languages`. 436 * @returns {Grammar} The new grammar object. 437 * @public 438 */ 439 insertBefore: function (inside, before, insert, root) { 440 root = root || /** @type {any} */ (_.languages); 441 var grammar = root[inside]; 442 /** @type {Grammar} */ 443 var ret = {}; 444 445 for (var token in grammar) { 446 if (grammar.hasOwnProperty(token)) { 447 448 if (token == before) { 449 for (var newToken in insert) { 450 if (insert.hasOwnProperty(newToken)) { 451 ret[newToken] = insert[newToken]; 452 } 453 } 454 } 455 456 // Do not insert token which also occur in insert. See #1525 457 if (!insert.hasOwnProperty(token)) { 458 ret[token] = grammar[token]; 459 } 460 } 461 } 462 463 var old = root[inside]; 464 root[inside] = ret; 465 466 // Update references in other language definitions 467 _.languages.DFS(_.languages, function (key, value) { 468 if (value === old && key != inside) { 469 this[key] = ret; 470 } 471 }); 472 473 return ret; 474 }, 475 476 // Traverse a language definition with Depth First Search 477 DFS: function DFS(o, callback, type, visited) { 478 visited = visited || {}; 479 480 var objId = _.util.objId; 481 482 for (var i in o) { 483 if (o.hasOwnProperty(i)) { 484 callback.call(o, i, o[i], type || i); 485 486 var property = o[i]; 487 var propertyType = _.util.type(property); 488 489 if (propertyType === 'Object' && !visited[objId(property)]) { 490 visited[objId(property)] = true; 491 DFS(property, callback, null, visited); 492 } else if (propertyType === 'Array' && !visited[objId(property)]) { 493 visited[objId(property)] = true; 494 DFS(property, callback, i, visited); 495 } 496 } 497 } 498 } 499 }, 500 501 plugins: {}, 502 503 /** 504 * This is the most high-level function in Prismâs API. 505 * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on 506 * each one of them. 507 * 508 * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`. 509 * 510 * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}. 511 * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}. 512 * @memberof Prism 513 * @public 514 */ 515 highlightAll: function (async, callback) { 516 _.highlightAllUnder(document, async, callback); 517 }, 518 519 /** 520 * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls 521 * {@link Prism.highlightElement} on each one of them. 522 * 523 * The following hooks will be run: 524 * 1. `before-highlightall` 525 * 2. `before-all-elements-highlight` 526 * 3. All hooks of {@link Prism.highlightElement} for each element. 527 * 528 * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted. 529 * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers. 530 * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done. 531 * @memberof Prism 532 * @public 533 */ 534 highlightAllUnder: function (container, async, callback) { 535 var env = { 536 callback: callback, 537 container: container, 538 selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code' 539 }; 540 541 _.hooks.run('before-highlightall', env); 542 543 env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector)); 544 545 _.hooks.run('before-all-elements-highlight', env); 546 547 for (var i = 0, element; (element = env.elements[i++]);) { 548 _.highlightElement(element, async === true, env.callback); 549 } 550 }, 551 552 /** 553 * Highlights the code inside a single element. 554 * 555 * The following hooks will be run: 556 * 1. `before-sanity-check` 557 * 2. `before-highlight` 558 * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`. 559 * 4. `before-insert` 560 * 5. `after-highlight` 561 * 6. `complete` 562 * 563 * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for 564 * the element's language. 565 * 566 * @param {Element} element The element containing the code. 567 * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier. 568 * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers 569 * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is 570 * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default). 571 * 572 * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for 573 * asynchronous highlighting to work. You can build your own bundle on the 574 * [Download page](https://prismjs.com/download.html). 575 * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done. 576 * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously. 577 * @memberof Prism 578 * @public 579 */ 580 highlightElement: function (element, async, callback) { 581 // Find language 582 var language = _.util.getLanguage(element); 583 var grammar = _.languages[language]; 584 585 // Set language on the element, if not present 586 _.util.setLanguage(element, language); 587 588 // Set language on the parent, for styling 589 var parent = element.parentElement; 590 if (parent && parent.nodeName.toLowerCase() === 'pre') { 591 _.util.setLanguage(parent, language); 592 } 593 594 var code = element.textContent; 595 596 var env = { 597 element: element, 598 language: language, 599 grammar: grammar, 600 code: code 601 }; 602 603 function insertHighlightedCode(highlightedCode) { 604 env.highlightedCode = highlightedCode; 605 606 _.hooks.run('before-insert', env); 607 608 env.element.innerHTML = env.highlightedCode; 609 610 _.hooks.run('after-highlight', env); 611 _.hooks.run('complete', env); 612 callback && callback.call(env.element); 613 } 614 615 _.hooks.run('before-sanity-check', env); 616 617 // plugins may change/add the parent/element 618 parent = env.element.parentElement; 619 if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) { 620 parent.setAttribute('tabindex', '0'); 621 } 622 623 if (!env.code) { 624 _.hooks.run('complete', env); 625 callback && callback.call(env.element); 626 return; 627 } 628 629 _.hooks.run('before-highlight', env); 630 631 if (!env.grammar) { 632 insertHighlightedCode(_.util.encode(env.code)); 633 return; 634 } 635 636 if (async && _self.Worker) { 637 var worker = new Worker(_.filename); 638 639 worker.onmessage = function (evt) { 640 insertHighlightedCode(evt.data); 641 }; 642 643 worker.postMessage(JSON.stringify({ 644 language: env.language, 645 code: env.code, 646 immediateClose: true 647 })); 648 } else { 649 insertHighlightedCode(_.highlight(env.code, env.grammar, env.language)); 650 } 651 }, 652 653 /**
654 * Low-level function, only use if you know what youâre doing. It accepts a string of text as input 655 * and the language definitions to use, and returns a string with the HTML produced. 656 * 657 * The following hooks will be run: 658 * 1. `before-tokenize` 659 * 2. `after-tokenize` 660 * 3. `wrap`: On each {@link Token}. 661 * 662 * @param {string} text A string with the code to be highlighted. 663 * @param {Grammar} grammar An object containing the tokens to use. 664 * 665 * Usually a language definition like `Prism.languages.markup`. 666 * @param {string} language The name of the language definition passed to `grammar`. 667 * @returns {string} The highlighted HTML. 668 * @memberof Prism 669 * @public 670 * @example 671 * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript'); 672 */ 673 highlight: function (text, grammar, language) { 674 var env = { 675 code: text, 676 grammar: grammar, 677 language: language 678 }; 679 _.hooks.run('before-tokenize', env); 680 if (!env.grammar) { 681 throw new Error('The language "' + env.language + '" has no grammar.'); 682 } 683 env.tokens = _.tokenize(env.code, env.grammar); 684 _.hooks.run('after-tokenize', env); 685 return Token.stringify(_.util.encode(env.tokens), env.language); 686 }, 687 688 /** 689 * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input 690 * and the language definitions to use, and returns an array with the tokenized code. 691 * 692 * When the language definition includes nested tokens, the function is called recursively on each of these tokens. 693 * 694 * This method could be useful in other contexts as well, as a very crude parser. 695 * 696 * @param {string} text A string with the code to be highlighted. 697 * @param {Grammar} grammar An object containing the tokens to use. 698 * 699 * Usually a language definition like `Prism.languages.markup`. 700 * @returns {TokenStream} An array of strings and tokens, a token stream. 701 * @memberof Prism 702 * @public 703 * @example 704 * let code = `var foo = 0;`; 705 * let tokens = Prism.tokenize(code, Prism.languages.javascript); 706 * tokens.forEach(token => { 707 * if (token instanceof Prism.Token && token.type === 'number') { 708 * console.log(`Found numeric literal: ${token.content}`); 709 * } 710 * }); 711 */ 712 tokenize: function (text, grammar) { 713 var rest = grammar.rest; 714 if (rest) { 715 for (var token in rest) { 716 grammar[token] = rest[token]; 717 } 718 719 delete grammar.rest; 720 } 721 722 var tokenList = new LinkedList(); 723 addAfter(tokenList, tokenList.head, text); 724 725 matchGrammar(text, tokenList, grammar, tokenList.head, 0); 726 727 return toArray(tokenList); 728 }, 729 730 /** 731 * @namespace 732 * @memberof Prism 733 * @public 734 */ 735 hooks: { 736 all: {}, 737 738 /** 739 * Adds the given callback to the list of callbacks for the given hook. 740 * 741 * The callback will be invoked when the hook it is registered for is run. 742 * Hooks are usually directly run by a highlight function but you can also run hooks yourself. 743 * 744 * One callback function can be registered to multiple hooks and the same hook multiple times. 745 * 746 * @param {string} name The name of the hook. 747 * @param {HookCallback} callback The callback function which is given environment variables. 748 * @public 749 */ 750 add: function (name, callback) { 751 var hooks = _.hooks.all; 752 753 hooks[name] = hooks[name] || []; 754 755 hooks[name].push(callback); 756 }, 757 758 /** 759 * Runs a hook invoking all registered callbacks with the given environment variables. 760 * 761 * Callbacks will be invoked synchronously and in the order in which they were registered. 762 * 763 * @param {string} name The name of the hook. 764 * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered. 765 * @public 766 */ 767 run: function (name, env) { 768 var callbacks = _.hooks.all[name]; 769 770 if (!callbacks || !callbacks.length) { 771 return; 772 } 773 774 for (var i = 0, callback; (callback = callbacks[i++]);) { 775 callback(env); 776 } 777 } 778 }, 779 780 Token: Token 781 }; 782 _self.Prism = _; 783 784 785 // Typescript note: 786 // The following can be used to import the Token type in JSDoc: 787 // 788 // @typedef {InstanceType<import("./prism-core")["Token"]>} Token 789 790 /** 791 * Creates a new token. 792 * 793 * @param {string} type See {@link Token#type type} 794 * @param {string | TokenStream} content See {@link Token#content content} 795 * @param {string|string[]} [alias] The alias(es) of the token. 796 * @param {string} [matchedStr=""] A copy of the full string this token was created from. 797 * @class 798 * @global 799 * @public 800 */ 801 function Token(type, content, alias, matchedStr) { 802 /** 803 * The type of the token. 804 * 805 * This is usually the key of a pattern in a {@link Grammar}. 806 * 807 * @type {string} 808 * @see GrammarToken 809 * @public 810 */ 811 this.type = type; 812 /** 813 * The strings or tokens contained by this token. 814 * 815 * This will be a token stream if the pattern matched also defined an `inside` grammar. 816 * 817 * @type {string | TokenStream} 818 * @public 819 */ 820 this.content = content; 821 /** 822 * The alias(es) of the token. 823 * 824 * @type {string|string[]} 825 * @see GrammarToken 826 * @public 827 */ 828 this.alias = alias; 829 // Copy of the full string this token was created from 830 this.length = (matchedStr || '').length | 0; 831 } 832 833 /**
vendor: 4,762 bytes, lines 834-996
834 * A token stream is an array of strings and {@link Token Token} objects. 835 * 836 * Token streams have to fulfill a few properties that are assumed by most functions (mostly internal ones) that process 837 * them. 838 * 839 * 1. No adjacent strings. 840 * 2. No empty strings. 841 * 842 * The only exception here is the token stream that only contains the empty string and nothing else. 843 * 844 * @typedef {Array<string | Token>} TokenStream 845 * @global 846 * @public 847 */ 848 849 /** 850 * Converts the given token or token stream to an HTML representation. 851 * 852 * The following hooks will be run: 853 * 1. `wrap`: On each {@link Token}. 854 * 855 * @param {string | Token | TokenStream} o The token or token stream to be converted. 856 * @param {string} language The name of current language. 857 * @returns {string} The HTML representation of the token or token stream. 858 * @memberof Token 859 * @static 860 */ 861 Token.stringify = function stringify(o, language) { 862 if (typeof o == 'string') { 863 return o; 864 } 865 if (Array.isArray(o)) { 866 var s = ''; 867 o.forEach(function (e) { 868 s += stringify(e, language); 869 }); 870 return s; 871 } 872 873 var env = { 874 type: o.type, 875 content: stringify(o.content, language), 876 tag: 'span', 877 classes: ['token', o.type], 878 attributes: {}, 879 language: language 880 }; 881 882 var aliases = o.alias; 883 if (aliases) { 884 if (Array.isArray(aliases)) { 885 Array.prototype.push.apply(env.classes, aliases); 886 } else { 887 env.classes.push(aliases); 888 } 889 } 890 891 _.hooks.run('wrap', env); 892 893 var attributes = ''; 894 for (var name in env.attributes) { 895 attributes += ' ' + name + '="' + (env.attributes[name] || '').replace(/"/g, '"') + '"'; 896 } 897 898 return '<' + env.tag + ' class="' + env.classes.join(' ') + '"' + attributes + '>' + env.content + '</' + env.tag + '>'; 899 }; 900 901 /** 902 * @param {RegExp} pattern 903 * @param {number} pos 904 * @param {string} text 905 * @param {boolean} lookbehind 906 * @returns {RegExpExecArray | null} 907 */ 908 function matchPattern(pattern, pos, text, lookbehind) { 909 pattern.lastIndex = pos; 910 var match = pattern.exec(text); 911 if (match && lookbehind && match[1]) { 912 // change the match to remove the text matched by the Prism lookbehind group 913 var lookbehindLength = match[1].length; 914 match.index += lookbehindLength; 915 match[0] = match[0].slice(lookbehindLength); 916 } 917 return match; 918 } 919 920 /** 921 * @param {string} text 922 * @param {LinkedList<string | Token>} tokenList 923 * @param {any} grammar 924 * @param {LinkedListNode<string | Token>} startNode 925 * @param {number} startPos 926 * @param {RematchOptions} [rematch] 927 * @returns {void} 928 * @private 929 * 930 * @typedef RematchOptions 931 * @property {string} cause 932 * @property {number} reach 933 */ 934 function matchGrammar(text, tokenList, grammar, startNode, startPos, rematch) { 935 for (var token in grammar) { 936 if (!grammar.hasOwnProperty(token) || !grammar[token]) { 937 continue; 938 } 939 940 var patterns = grammar[token]; 941 patterns = Array.isArray(patterns) ? patterns : [patterns]; 942 943 for (var j = 0; j < patterns.length; ++j) { 944 if (rematch && rematch.cause == token + ',' + j) { 945 return; 946 } 947 948 var patternObj = patterns[j]; 949 var inside = patternObj.inside; 950 var lookbehind = !!patternObj.lookbehind; 951 var greedy = !!patternObj.greedy; 952 var alias = patternObj.alias; 953 954 if (greedy && !patternObj.pattern.global) { 955 // Without the global flag, lastIndex won't work 956 var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0]; 957 patternObj.pattern = RegExp(patternObj.pattern.source, flags + 'g'); 958 } 959 960 /** @type {RegExp} */ 961 var pattern = patternObj.pattern || patternObj; 962 963 for ( // iterate the token list and keep track of the current token/string position 964 var currentNode = startNode.next, pos = startPos; 965 currentNode !== tokenList.tail; 966 pos += currentNode.value.length, currentNode = currentNode.next 967 ) { 968 969 if (rematch && pos >= rematch.reach) { 970 break; 971 } 972 973 var str = currentNode.value; 974 975 if (tokenList.length > text.length) { 976 // Something went terribly wrong, ABORT, ABORT! 977 return; 978 } 979 980 if (str instanceof Token) { 981 continue; 982 } 983 984 var removeCount = 1; // this is the to parameter of removeBetween 985 var match; 986 987 if (greedy) { 988 match = matchPattern(pattern, pos, text, lookbehind); 989 if (!match || match.index >= text.length) { 990 break; 991 } 992 993 var from = match.index; 994 var to = match.index + match[0].length; 995 var p = pos; 996
vendor: 6,526 bytes, lines 997-1236
997 // find the node that contains the match 998 p += currentNode.value.length; 999 while (from >= p) { 1000 currentNode = currentNode.next; 1001 p += currentNode.value.length; 1002 } 1003 // adjust pos (and p) 1004 p -= currentNode.value.length; 1005 pos = p; 1006 1007 // the current node is a Token, then the match starts inside another Token, which is invalid 1008 if (currentNode.value instanceof Token) { 1009 continue; 1010 } 1011 1012 // find the last node which is affected by this match 1013 for ( 1014 var k = currentNode; 1015 k !== tokenList.tail && (p < to || typeof k.value === 'string'); 1016 k = k.next 1017 ) { 1018 removeCount++; 1019 p += k.value.length; 1020 } 1021 removeCount--; 1022 1023 // replace with the new match 1024 str = text.slice(pos, p); 1025 match.index -= pos; 1026 } else { 1027 match = matchPattern(pattern, 0, str, lookbehind); 1028 if (!match) { 1029 continue; 1030 } 1031 } 1032 1033 // eslint-disable-next-line no-redeclare 1034 var from = match.index; 1035 var matchStr = match[0]; 1036 var before = str.slice(0, from); 1037 var after = str.slice(from + matchStr.length); 1038 1039 var reach = pos + str.length; 1040 if (rematch && reach > rematch.reach) { 1041 rematch.reach = reach; 1042 } 1043 1044 var removeFrom = currentNode.prev; 1045 1046 if (before) { 1047 removeFrom = addAfter(tokenList, removeFrom, before); 1048 pos += before.length; 1049 } 1050 1051 removeRange(tokenList, removeFrom, removeCount); 1052 1053 var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr); 1054 currentNode = addAfter(tokenList, removeFrom, wrapped); 1055 1056 if (after) { 1057 addAfter(tokenList, currentNode, after); 1058 } 1059 1060 if (removeCount > 1) { 1061 // at least one Token object was removed, so we have to do some rematching 1062 // this can only happen if the current pattern is greedy 1063 1064 /** @type {RematchOptions} */ 1065 var nestedRematch = { 1066 cause: token + ',' + j, 1067 reach: reach 1068 }; 1069 matchGrammar(text, tokenList, grammar, currentNode.prev, pos, nestedRematch); 1070 1071 // the reach might have been extended because of the rematching 1072 if (rematch && nestedRematch.reach > rematch.reach) { 1073 rematch.reach = nestedRematch.reach; 1074 } 1075 } 1076 } 1077 } 1078 } 1079 } 1080 1081 /** 1082 * @typedef LinkedListNode 1083 * @property {T} value 1084 * @property {LinkedListNode<T> | null} prev The previous node. 1085 * @property {LinkedListNode<T> | null} next The next node. 1086 * @template T 1087 * @private 1088 */ 1089 1090 /** 1091 * @template T 1092 * @private 1093 */ 1094 function LinkedList() { 1095 /** @type {LinkedListNode<T>} */ 1096 var head = { value: null, prev: null, next: null }; 1097 /** @type {LinkedListNode<T>} */ 1098 var tail = { value: null, prev: head, next: null }; 1099 head.next = tail; 1100 1101 /** @type {LinkedListNode<T>} */ 1102 this.head = head; 1103 /** @type {LinkedListNode<T>} */ 1104 this.tail = tail; 1105 this.length = 0; 1106 } 1107 1108 /** 1109 * Adds a new node with the given value to the list. 1110 * 1111 * @param {LinkedList<T>} list 1112 * @param {LinkedListNode<T>} node 1113 * @param {T} value 1114 * @returns {LinkedListNode<T>} The added node. 1115 * @template T 1116 */ 1117 function addAfter(list, node, value) { 1118 // assumes that node != list.tail && values.length >= 0 1119 var next = node.next; 1120 1121 var newNode = { value: value, prev: node, next: next }; 1122 node.next = newNode; 1123 next.prev = newNode; 1124 list.length++; 1125 1126 return newNode; 1127 } 1128 /** 1129 * Removes `count` nodes after the given node. The given node will not be removed. 1130 * 1131 * @param {LinkedList<T>} list 1132 * @param {LinkedListNode<T>} node 1133 * @param {number} count 1134 * @template T 1135 */ 1136 function removeRange(list, node, count) { 1137 var next = node.next; 1138 for (var i = 0; i < count && next !== list.tail; i++) { 1139 next = next.next; 1140 } 1141 node.next = next; 1142 next.prev = node; 1143 list.length -= i; 1144 } 1145 /** 1146 * @param {LinkedList<T>} list 1147 * @returns {T[]} 1148 * @template T 1149 */ 1150 function toArray(list) { 1151 var array = []; 1152 var node = list.head.next; 1153 while (node !== list.tail) { 1154 array.push(node.value); 1155 node = node.next; 1156 } 1157 return array; 1158 } 1159 1160 1161 if (!_self.document) { 1162 if (!_self.addEventListener) { 1163 // in Node.js 1164 return _; 1165 } 1166 1167 if (!_.disableWorkerMessageHandler) { 1168 // In worker 1169 _self.addEventListener('message', function (evt) { 1170 var message = JSON.parse(evt.data); 1171 var lang = message.language; 1172 var code = message.code; 1173 var immediateClose = message.immediateClose; 1174 1175 _self.postMessage(_.highlight(code, _.languages[lang], lang)); 1176 if (immediateClose) { 1177 _self.close(); 1178 } 1179 }, false); 1180 } 1181 1182 return _; 1183 } 1184 1185 // Get current script and highlight 1186 var script = _.util.currentScript(); 1187 1188 if (script) { 1189 _.filename = script.src; 1190 1191 if (script.hasAttribute('data-manual')) { 1192 _.manual = true; 1193 } 1194 } 1195 1196 function highlightAutomaticallyCallback() { 1197 if (!_.manual) { 1198 _.highlightAll(); 1199 } 1200 } 1201 1202 if (!_.manual) { 1203 // If the document state is "loading", then we'll use DOMContentLoaded. 1204 // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the 1205 // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they 1206 // might take longer one animation frame to execute which can create a race condition where only some plugins have 1207 // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded. 1208 // See https://github.com/PrismJS/prism/issues/2102 1209 var readyState = document.readyState; 1210 if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) { 1211 document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback); 1212 } else { 1213 if (window.requestAnimationFrame) { 1214 window.requestAnimationFrame(highlightAutomaticallyCallback); 1215 } else { 1216 window.setTimeout(highlightAutomaticallyCallback, 16); 1217 } 1218 } 1219 } 1220 1221 return _; 1222 1223 }(_self)); 1224 1225 if (module.exports) { 1226 module.exports = Prism; 1227 } 1228 1229 // hack for components to work correctly in node.js 1230 if (typeof commonjsGlobal !== 'undefined') { 1231 commonjsGlobal.Prism = Prism; 1232 } 1233 1234 // some additional documentation/types 1235 1236 /**
1237 * The expansion of a simple `RegExp` literal to support additional properties. 1238 * 1239 * @typedef GrammarToken 1240 * @property {RegExp} pattern The regular expression of the token. 1241 * @property {boolean} [lookbehind=false] If `true`, then the first capturing group of `pattern` will (effectively) 1242 * behave as a lookbehind group meaning that the captured text will not be part of the matched text of the new token. 1243 * @property {boolean} [greedy=false] Whether the token is greedy. 1244 * @property {string|string[]} [alias] An optional alias or list of aliases. 1245 * @property {Grammar} [inside] The nested grammar of this token. 1246 * 1247 * The `inside` grammar will be used to tokenize the text value of each token of this kind. 1248 * 1249 * This can be used to make nested and even recursive language definitions. 1250 * 1251 * Note: This can cause infinite recursion. Be careful when you embed different languages or even the same language into 1252 * each another. 1253 * @global 1254 * @public 1255 */ 1256 1257 /** 1258 * @typedef Grammar 1259 * @type {Object<string, RegExp | GrammarToken | Array<RegExp | GrammarToken>>} 1260 * @property {Grammar} [rest] An optional grammar object that will be appended to this grammar. 1261 * @global 1262 * @public 1263 */ 1264 1265 /** 1266 * A function which will invoked after an element was successfully highlighted. 1267 * 1268 * @callback HighlightCallback 1269 * @param {Element} element The element successfully highlighted. 1270 * @returns {void} 1271 * @global 1272 * @public 1273 */ 1274 1275 /** 1276 * @callback HookCallback 1277 * @param {Object<string, any>} env The environment variables of the hook. 1278 * @returns {void} 1279 * @global 1280 * @public 1281 */ 1282 1283 1284 /* ********************************************** 1285 Begin prism-markup.js 1286 ********************************************** */ 1287 1288 Prism.languages.markup = { 1289 'comment': { 1290 pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, 1291 greedy: true 1292 }, 1293 'prolog': { 1294 pattern: /<\?[\s\S]+?\?>/, 1295 greedy: true 1296 }, 1297 'doctype': { 1298 // https://www.w3.org/TR/xml/#NT-doctypedecl 1299 pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, 1300 greedy: true, 1301 inside: { 1302 'internal-subset': { 1303 pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, 1304 lookbehind: true, 1305 greedy: true, 1306 inside: null // see below 1307 }, 1308 'string': { 1309 pattern: /"[^"]*"|'[^']*'/, 1310 greedy: true 1311 }, 1312 'punctuation': /^<!|>$|[[\]]/, 1313 'doctype-tag': /^DOCTYPE/i, 1314 'name': /[^\s<>'"]+/ 1315 } 1316 }, 1317 'cdata': { 1318 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 1319 greedy: true 1320 }, 1321 'tag': { 1322 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, 1323 greedy: true, 1324 inside: { 1325 'tag': { 1326 pattern: /^<\/?[^\s>\/]+/, 1327 inside: { 1328 'punctuation': /^<\/?/, 1329 'namespace': /^[^\s>\/:]+:/ 1330 } 1331 }, 1332 'special-attr': [], 1333 'attr-value': { 1334 pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, 1335 inside: { 1336 'punctuation': [ 1337 { 1338 pattern: /^=/, 1339 alias: 'attr-equals' 1340 }, 1341 { 1342 pattern: /^(\s*)["']|["']$/, 1343 lookbehind: true 1344 } 1345 ] 1346 } 1347 }, 1348 'punctuation': /\/?>/, 1349 'attr-name': { 1350 pattern: /[^\s>\/]+/, 1351 inside: { 1352 'namespace': /^[^\s>\/:]+:/ 1353 } 1354 } 1355 1356 } 1357 }, 1358 'entity': [ 1359 { 1360 pattern: /&[\da-z]{1,8};/i, 1361 alias: 'named-entity' 1362 }, 1363 /&#x?[\da-f]{1,8};/i 1364 ] 1365 }; 1366 1367 Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = 1368 Prism.languages.markup['entity']; 1369 Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup; 1370 1371 // Plugin to make entity title show the real entity, idea by Roman Komarov 1372 Prism.hooks.add('wrap', function (env) { 1373 1374 if (env.type === 'entity') { 1375 env.attributes['title'] = env.content.replace(/&/, '&'); 1376 } 1377 }); 1378 1379 Object.defineProperty(Prism.languages.markup.tag, 'addInlined', { 1380 /** 1381 * Adds an inlined language to markup. 1382 * 1383 * An example of an inlined language is CSS with `<style>` tags. 1384 * 1385 * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as 1386 * case insensitive. 1387 * @param {string} lang The language key. 1388 * @example 1389 * addInlined('style', 'css'); 1390 */ 1391 value: function addInlined(tagName, lang) { 1392 var includedCdataInside = {};
vendor: 17,693 bytes, lines 1393-1949
1393 includedCdataInside['language-' + lang] = { 1394 pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, 1395 lookbehind: true, 1396 inside: Prism.languages[lang] 1397 }; 1398 includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i; 1399 1400 var inside = { 1401 'included-cdata': { 1402 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 1403 inside: includedCdataInside 1404 } 1405 }; 1406 inside['language-' + lang] = { 1407 pattern: /[\s\S]+/, 1408 inside: Prism.languages[lang] 1409 }; 1410 1411 var def = {}; 1412 def[tagName] = { 1413 pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'), 1414 lookbehind: true, 1415 greedy: true, 1416 inside: inside 1417 }; 1418 1419 Prism.languages.insertBefore('markup', 'cdata', def); 1420 } 1421 }); 1422 Object.defineProperty(Prism.languages.markup.tag, 'addAttribute', { 1423 /** 1424 * Adds an pattern to highlight languages embedded in HTML attributes. 1425 * 1426 * An example of an inlined language is CSS with `style` attributes. 1427 * 1428 * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as 1429 * case insensitive. 1430 * @param {string} lang The language key. 1431 * @example 1432 * addAttribute('style', 'css'); 1433 */ 1434 value: function (attrName, lang) { 1435 Prism.languages.markup.tag.inside['special-attr'].push({ 1436 pattern: RegExp( 1437 /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 1438 'i' 1439 ), 1440 lookbehind: true, 1441 inside: { 1442 'attr-name': /^[^\s=]+/, 1443 'attr-value': { 1444 pattern: /=[\s\S]+/, 1445 inside: { 1446 'value': { 1447 pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/, 1448 lookbehind: true, 1449 alias: [lang, 'language-' + lang], 1450 inside: Prism.languages[lang] 1451 }, 1452 'punctuation': [ 1453 { 1454 pattern: /^=/, 1455 alias: 'attr-equals' 1456 }, 1457 /"|'/ 1458 ] 1459 } 1460 } 1461 } 1462 }); 1463 } 1464 }); 1465 1466 Prism.languages.html = Prism.languages.markup; 1467 Prism.languages.mathml = Prism.languages.markup; 1468 Prism.languages.svg = Prism.languages.markup; 1469 1470 Prism.languages.xml = Prism.languages.extend('markup', {}); 1471 Prism.languages.ssml = Prism.languages.xml; 1472 Prism.languages.atom = Prism.languages.xml; 1473 Prism.languages.rss = Prism.languages.xml; 1474 1475 1476 /* ********************************************** 1477 Begin prism-css.js 1478 ********************************************** */ 1479 1480 (function (Prism) { 1481 1482 var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/; 1483 1484 Prism.languages.css = { 1485 'comment': /\/\*[\s\S]*?\*\//, 1486 'atrule': { 1487 pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source), 1488 inside: { 1489 'rule': /^@[\w-]+/, 1490 'selector-function-argument': { 1491 pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, 1492 lookbehind: true, 1493 alias: 'selector' 1494 }, 1495 'keyword': { 1496 pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, 1497 lookbehind: true 1498 } 1499 // See rest below 1500 } 1501 }, 1502 'url': { 1503 // https://drafts.csswg.org/css-values-3/#urls 1504 pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'), 1505 greedy: true, 1506 inside: { 1507 'function': /^url/i, 1508 'punctuation': /^\(|\)$/, 1509 'string': { 1510 pattern: RegExp('^' + string.source + '$'), 1511 alias: 'url' 1512 } 1513 } 1514 }, 1515 'selector': { 1516 pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'), 1517 lookbehind: true 1518 }, 1519 'string': { 1520 pattern: string, 1521 greedy: true 1522 }, 1523 'property': { 1524 pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, 1525 lookbehind: true 1526 }, 1527 'important': /!important\b/i, 1528 'function': { 1529 pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, 1530 lookbehind: true 1531 }, 1532 'punctuation': /[(){};:,]/ 1533 }; 1534 1535 Prism.languages.css['atrule'].inside.rest = Prism.languages.css; 1536 1537 var markup = Prism.languages.markup; 1538 if (markup) { 1539 markup.tag.addInlined('style', 'css'); 1540 markup.tag.addAttribute('style', 'css'); 1541 } 1542 1543 }(Prism)); 1544 1545 1546 /* ********************************************** 1547 Begin prism-clike.js 1548 ********************************************** */ 1549 1550 Prism.languages.clike = { 1551 'comment': [ 1552 { 1553 pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 1554 lookbehind: true, 1555 greedy: true 1556 }, 1557 { 1558 pattern: /(^|[^\\:])\/\/.*/, 1559 lookbehind: true, 1560 greedy: true 1561 } 1562 ], 1563 'string': { 1564 pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 1565 greedy: true 1566 }, 1567 'class-name': { 1568 pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, 1569 lookbehind: true, 1570 inside: { 1571 'punctuation': /[.\\]/ 1572 } 1573 }, 1574 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, 1575 'boolean': /\b(?:false|true)\b/, 1576 'function': /\b\w+(?=\()/, 1577 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, 1578 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, 1579 'punctuation': /[{}[\];(),.:]/ 1580 }; 1581 1582 1583 /* ********************************************** 1584 Begin prism-javascript.js 1585 ********************************************** */ 1586 1587 Prism.languages.javascript = Prism.languages.extend('clike', { 1588 'class-name': [ 1589 Prism.languages.clike['class-name'], 1590 { 1591 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, 1592 lookbehind: true 1593 } 1594 ], 1595 'keyword': [ 1596 { 1597 pattern: /((?:^|\})\s*)catch\b/, 1598 lookbehind: true 1599 }, 1600 { 1601 pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, 1602 lookbehind: true 1603 }, 1604 ], 1605 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) 1606 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, 1607 'number': { 1608 pattern: RegExp( 1609 /(^|[^\w$])/.source + 1610 '(?:' + 1611 ( 1612 // constant 1613 /NaN|Infinity/.source + 1614 '|' + 1615 // binary integer 1616 /0[bB][01]+(?:_[01]+)*n?/.source + 1617 '|' + 1618 // octal integer 1619 /0[oO][0-7]+(?:_[0-7]+)*n?/.source + 1620 '|' + 1621 // hexadecimal integer 1622 /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + 1623 '|' + 1624 // decimal bigint 1625 /\d+(?:_\d+)*n/.source + 1626 '|' + 1627 // decimal number (integer or float) but no bigint 1628 /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source 1629 ) + 1630 ')' + 1631 /(?![\w$])/.source 1632 ), 1633 lookbehind: true 1634 }, 1635 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ 1636 }); 1637 1638 Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; 1639 1640 Prism.languages.insertBefore('javascript', 'keyword', { 1641 'regex': { 1642 pattern: RegExp( 1643 // lookbehind 1644 // eslint-disable-next-line regexp/no-dupe-characters-character-class 1645 /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + 1646 // Regex pattern: 1647 // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character 1648 // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible 1649 // with the only syntax, so we have to define 2 different regex patterns. 1650 /\//.source + 1651 '(?:' + 1652 /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + 1653 '|' + 1654 // `v` flag syntax. This supports 3 levels of nested character classes. 1655 /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + 1656 ')' + 1657 // lookahead 1658 /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source 1659 ), 1660 lookbehind: true, 1661 greedy: true, 1662 inside: { 1663 'regex-source': { 1664 pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, 1665 lookbehind: true, 1666 alias: 'language-regex', 1667 inside: Prism.languages.regex 1668 }, 1669 'regex-delimiter': /^\/|\/$/, 1670 'regex-flags': /^[a-z]+$/, 1671 } 1672 }, 1673 // This must be declared before keyword because we use "function" inside the look-forward 1674 'function-variable': { 1675 pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, 1676 alias: 'function' 1677 }, 1678 'parameter': [ 1679 { 1680 pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, 1681 lookbehind: true, 1682 inside: Prism.languages.javascript 1683 }, 1684 { 1685 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, 1686 lookbehind: true, 1687 inside: Prism.languages.javascript 1688 }, 1689 { 1690 pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, 1691 lookbehind: true, 1692 inside: Prism.languages.javascript 1693 }, 1694 { 1695 pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, 1696 lookbehind: true, 1697 inside: Prism.languages.javascript 1698 } 1699 ], 1700 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/ 1701 }); 1702 1703 Prism.languages.insertBefore('javascript', 'string', { 1704 'hashbang': { 1705 pattern: /^#!.*/, 1706 greedy: true, 1707 alias: 'comment' 1708 }, 1709 'template-string': { 1710 pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, 1711 greedy: true, 1712 inside: { 1713 'template-punctuation': { 1714 pattern: /^`|`$/, 1715 alias: 'string' 1716 }, 1717 'interpolation': { 1718 pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, 1719 lookbehind: true, 1720 inside: { 1721 'interpolation-punctuation': { 1722 pattern: /^\$\{|\}$/, 1723 alias: 'punctuation' 1724 }, 1725 rest: Prism.languages.javascript 1726 } 1727 }, 1728 'string': /[\s\S]+/ 1729 } 1730 }, 1731 'string-property': { 1732 pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, 1733 lookbehind: true, 1734 greedy: true, 1735 alias: 'property' 1736 } 1737 }); 1738 1739 Prism.languages.insertBefore('javascript', 'operator', { 1740 'literal-property': { 1741 pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, 1742 lookbehind: true, 1743 alias: 'property' 1744 }, 1745 }); 1746 1747 if (Prism.languages.markup) { 1748 Prism.languages.markup.tag.addInlined('script', 'javascript'); 1749 1750 // add attribute support for all DOM events. 1751 // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events 1752 Prism.languages.markup.tag.addAttribute( 1753 /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 1754 'javascript' 1755 ); 1756 } 1757 1758 Prism.languages.js = Prism.languages.javascript; 1759 1760 1761 /* ********************************************** 1762 Begin prism-file-highlight.js 1763 ********************************************** */ 1764 1765 (function () { 1766 1767 if (typeof Prism === 'undefined' || typeof document === 'undefined') { 1768 return; 1769 } 1770 1771 // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill 1772 if (!Element.prototype.matches) { 1773 Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; 1774 } 1775 1776 var LOADING_MESSAGE = 'Loadingâ¦'; 1777 var FAILURE_MESSAGE = function (status, message) { 1778 return 'â Error ' + status + ' while fetching file: ' + message; 1779 }; 1780 var FAILURE_EMPTY_MESSAGE = 'â Error: File does not exist or is empty'; 1781 1782 var EXTENSIONS = { 1783 'js': 'javascript', 1784 'py': 'python', 1785 'rb': 'ruby', 1786 'ps1': 'powershell', 1787 'psm1': 'powershell', 1788 'sh': 'bash', 1789 'bat': 'batch', 1790 'h': 'c', 1791 'tex': 'latex' 1792 }; 1793 1794 var STATUS_ATTR = 'data-src-status'; 1795 var STATUS_LOADING = 'loading'; 1796 var STATUS_LOADED = 'loaded'; 1797 var STATUS_FAILED = 'failed'; 1798 1799 var SELECTOR = 'pre[data-src]:not([' + STATUS_ATTR + '="' + STATUS_LOADED + '"])' 1800 + ':not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])'; 1801 1802 /** 1803 * Loads the given file. 1804 * 1805 * @param {string} src The URL or path of the source file to load. 1806 * @param {(result: string) => void} success 1807 * @param {(reason: string) => void} error 1808 */ 1809 function loadFile(src, success, error) { 1810 var xhr = new XMLHttpRequest(); 1811 xhr.open('GET', src, true); 1812 xhr.onreadystatechange = function () { 1813 if (xhr.readyState == 4) { 1814 if (xhr.status < 400 && xhr.responseText) { 1815 success(xhr.responseText); 1816 } else { 1817 if (xhr.status >= 400) { 1818 error(FAILURE_MESSAGE(xhr.status, xhr.statusText)); 1819 } else { 1820 error(FAILURE_EMPTY_MESSAGE); 1821 } 1822 } 1823 } 1824 }; 1825 xhr.send(null); 1826 } 1827 1828 /** 1829 * Parses the given range. 1830 * 1831 * This returns a range with inclusive ends. 1832 * 1833 * @param {string | null | undefined} range 1834 * @returns {[number, number | undefined] | undefined} 1835 */ 1836 function parseRange(range) { 1837 var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || ''); 1838 if (m) { 1839 var start = Number(m[1]); 1840 var comma = m[2]; 1841 var end = m[3]; 1842 1843 if (!comma) { 1844 return [start, start]; 1845 } 1846 if (!end) { 1847 return [start, undefined]; 1848 } 1849 return [start, Number(end)]; 1850 } 1851 return undefined; 1852 } 1853 1854 Prism.hooks.add('before-highlightall', function (env) { 1855 env.selector += ', ' + SELECTOR; 1856 }); 1857 1858 Prism.hooks.add('before-sanity-check', function (env) { 1859 var pre = /** @type {HTMLPreElement} */ (env.element); 1860 if (pre.matches(SELECTOR)) { 1861 env.code = ''; // fast-path the whole thing and go to complete 1862 1863 pre.setAttribute(STATUS_ATTR, STATUS_LOADING); // mark as loading 1864 1865 // add code element with loading message 1866 var code = pre.appendChild(document.createElement('CODE')); 1867 code.textContent = LOADING_MESSAGE; 1868 1869 var src = pre.getAttribute('data-src'); 1870 1871 var language = env.language; 1872 if (language === 'none') { 1873 // the language might be 'none' because there is no language set; 1874 // in this case, we want to use the extension as the language 1875 var extension = (/\.(\w+)$/.exec(src) || [, 'none'])[1]; 1876 language = EXTENSIONS[extension] || extension; 1877 } 1878 1879 // set language classes 1880 Prism.util.setLanguage(code, language); 1881 Prism.util.setLanguage(pre, language); 1882 1883 // preload the language 1884 var autoloader = Prism.plugins.autoloader; 1885 if (autoloader) { 1886 autoloader.loadLanguages(language); 1887 } 1888 1889 // load file 1890 loadFile( 1891 src, 1892 function (text) { 1893 // mark as loaded 1894 pre.setAttribute(STATUS_ATTR, STATUS_LOADED); 1895 1896 // handle data-range 1897 var range = parseRange(pre.getAttribute('data-range')); 1898 if (range) { 1899 var lines = text.split(/\r\n?|\n/g); 1900 1901 // the range is one-based and inclusive on both ends 1902 var start = range[0]; 1903 var end = range[1] == null ? lines.length : range[1]; 1904 1905 if (start < 0) { start += lines.length; } 1906 start = Math.max(0, Math.min(start - 1, lines.length)); 1907 if (end < 0) { end += lines.length; } 1908 end = Math.max(0, Math.min(end, lines.length)); 1909 1910 text = lines.slice(start, end).join('\n'); 1911 1912 // add data-start for line numbers 1913 if (!pre.hasAttribute('data-start')) { 1914 pre.setAttribute('data-start', String(start + 1)); 1915 } 1916 } 1917 1918 // highlight code 1919 code.textContent = text; 1920 Prism.highlightElement(code); 1921 }, 1922 function (error) { 1923 // mark as failed 1924 pre.setAttribute(STATUS_ATTR, STATUS_FAILED); 1925 1926 code.textContent = error; 1927 } 1928 ); 1929 } 1930 }); 1931 1932 Prism.plugins.fileHighlight = { 1933 /** 1934 * Executes the File Highlight plugin for all matching `pre` elements under the given container. 1935 * 1936 * Note: Elements which are already loaded or currently loading will not be touched by this method. 1937 * 1938 * @param {ParentNode} [container=document] 1939 */ 1940 highlight: function highlight(container) { 1941 var elements = (container || document).querySelectorAll(SELECTOR); 1942 1943 for (var i = 0, element; (element = elements[i++]);) { 1944 Prism.highlightElement(element); 1945 } 1946 } 1947 }; 1948 1949 var logged = false;
vendor: 4,199 bytes, lines 1950-2116
1950 /** @deprecated Use `Prism.plugins.fileHighlight.highlight` instead. */ 1951 Prism.fileHighlight = function () { 1952 if (!logged) { 1953 console.warn('Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.'); 1954 logged = true; 1955 } 1956 Prism.plugins.fileHighlight.highlight.apply(this, arguments); 1957 }; 1958 1959 }()); 1960 } (prism)); 1961 return prism.exports; 1962} 1963 1964var prismExports = requirePrism(); 1965var Prism$1 = /*@__PURE__*/getDefaultExportFromCjs(prismExports); 1966 1967Prism$1.languages.clike = { 1968 'comment': [ 1969 { 1970 pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, 1971 lookbehind: true, 1972 greedy: true 1973 }, 1974 { 1975 pattern: /(^|[^\\:])\/\/.*/, 1976 lookbehind: true, 1977 greedy: true 1978 } 1979 ], 1980 'string': { 1981 pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, 1982 greedy: true 1983 }, 1984 'class-name': { 1985 pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i, 1986 lookbehind: true, 1987 inside: { 1988 'punctuation': /[.\\]/ 1989 } 1990 }, 1991 'keyword': /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/, 1992 'boolean': /\b(?:false|true)\b/, 1993 'function': /\b\w+(?=\()/, 1994 'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, 1995 'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, 1996 'punctuation': /[{}[\];(),.:]/ 1997}; 1998 1999Prism$1.languages.markup = { 2000 'comment': { 2001 pattern: /<!--(?:(?!<!--)[\s\S])*?-->/, 2002 greedy: true 2003 }, 2004 'prolog': { 2005 pattern: /<\?[\s\S]+?\?>/, 2006 greedy: true 2007 }, 2008 'doctype': { 2009 // https://www.w3.org/TR/xml/#NT-doctypedecl 2010 pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i, 2011 greedy: true, 2012 inside: { 2013 'internal-subset': { 2014 pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/, 2015 lookbehind: true, 2016 greedy: true, 2017 inside: null // see below 2018 }, 2019 'string': { 2020 pattern: /"[^"]*"|'[^']*'/, 2021 greedy: true 2022 }, 2023 'punctuation': /^<!|>$|[[\]]/, 2024 'doctype-tag': /^DOCTYPE/i, 2025 'name': /[^\s<>'"]+/ 2026 } 2027 }, 2028 'cdata': { 2029 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 2030 greedy: true 2031 }, 2032 'tag': { 2033 pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, 2034 greedy: true, 2035 inside: { 2036 'tag': { 2037 pattern: /^<\/?[^\s>\/]+/, 2038 inside: { 2039 'punctuation': /^<\/?/, 2040 'namespace': /^[^\s>\/:]+:/ 2041 } 2042 }, 2043 'special-attr': [], 2044 'attr-value': { 2045 pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, 2046 inside: { 2047 'punctuation': [ 2048 { 2049 pattern: /^=/, 2050 alias: 'attr-equals' 2051 }, 2052 { 2053 pattern: /^(\s*)["']|["']$/, 2054 lookbehind: true 2055 } 2056 ] 2057 } 2058 }, 2059 'punctuation': /\/?>/, 2060 'attr-name': { 2061 pattern: /[^\s>\/]+/, 2062 inside: { 2063 'namespace': /^[^\s>\/:]+:/ 2064 } 2065 } 2066 2067 } 2068 }, 2069 'entity': [ 2070 { 2071 pattern: /&[\da-z]{1,8};/i, 2072 alias: 'named-entity' 2073 }, 2074 /&#x?[\da-f]{1,8};/i 2075 ] 2076}; 2077 2078Prism$1.languages.markup['tag'].inside['attr-value'].inside['entity'] = 2079 Prism$1.languages.markup['entity']; 2080Prism$1.languages.markup['doctype'].inside['internal-subset'].inside = Prism$1.languages.markup; 2081 2082// Plugin to make entity title show the real entity, idea by Roman Komarov 2083Prism$1.hooks.add('wrap', function (env) { 2084 2085 if (env.type === 'entity') { 2086 env.attributes['title'] = env.content.replace(/&/, '&'); 2087 } 2088}); 2089 2090Object.defineProperty(Prism$1.languages.markup.tag, 'addInlined', { 2091 /** 2092 * Adds an inlined language to markup. 2093 * 2094 * An example of an inlined language is CSS with `<style>` tags. 2095 * 2096 * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as 2097 * case insensitive. 2098 * @param {string} lang The language key. 2099 * @example 2100 * addInlined('style', 'css'); 2101 */ 2102 value: function addInlined(tagName, lang) { 2103 var includedCdataInside = {}; 2104 includedCdataInside['language-' + lang] = { 2105 pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, 2106 lookbehind: true, 2107 inside: Prism$1.languages[lang] 2108 }; 2109 includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i; 2110 2111 var inside = { 2112 'included-cdata': { 2113 pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, 2114 inside: includedCdataInside 2115 } 2116 };
vendor: 6,612 bytes, lines 2117-2344
2117 inside['language-' + lang] = { 2118 pattern: /[\s\S]+/, 2119 inside: Prism$1.languages[lang] 2120 }; 2121 2122 var def = {}; 2123 def[tagName] = { 2124 pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'), 2125 lookbehind: true, 2126 greedy: true, 2127 inside: inside 2128 }; 2129 2130 Prism$1.languages.insertBefore('markup', 'cdata', def); 2131 } 2132}); 2133Object.defineProperty(Prism$1.languages.markup.tag, 'addAttribute', { 2134 /** 2135 * Adds an pattern to highlight languages embedded in HTML attributes. 2136 * 2137 * An example of an inlined language is CSS with `style` attributes. 2138 * 2139 * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as 2140 * case insensitive. 2141 * @param {string} lang The language key. 2142 * @example 2143 * addAttribute('style', 'css'); 2144 */ 2145 value: function (attrName, lang) { 2146 Prism$1.languages.markup.tag.inside['special-attr'].push({ 2147 pattern: RegExp( 2148 /(^|["'\s])/.source + '(?:' + attrName + ')' + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source, 2149 'i' 2150 ), 2151 lookbehind: true, 2152 inside: { 2153 'attr-name': /^[^\s=]+/, 2154 'attr-value': { 2155 pattern: /=[\s\S]+/, 2156 inside: { 2157 'value': { 2158 pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/, 2159 lookbehind: true, 2160 alias: [lang, 'language-' + lang], 2161 inside: Prism$1.languages[lang] 2162 }, 2163 'punctuation': [ 2164 { 2165 pattern: /^=/, 2166 alias: 'attr-equals' 2167 }, 2168 /"|'/ 2169 ] 2170 } 2171 } 2172 } 2173 }); 2174 } 2175}); 2176 2177Prism$1.languages.html = Prism$1.languages.markup; 2178Prism$1.languages.mathml = Prism$1.languages.markup; 2179Prism$1.languages.svg = Prism$1.languages.markup; 2180 2181Prism$1.languages.xml = Prism$1.languages.extend('markup', {}); 2182Prism$1.languages.ssml = Prism$1.languages.xml; 2183Prism$1.languages.atom = Prism$1.languages.xml; 2184Prism$1.languages.rss = Prism$1.languages.xml; 2185 2186(function (Prism) { 2187 2188 /** 2189 * Returns the placeholder for the given language id and index. 2190 * 2191 * @param {string} language 2192 * @param {string|number} index 2193 * @returns {string} 2194 */ 2195 function getPlaceholder(language, index) { 2196 return '___' + language.toUpperCase() + index + '___'; 2197 } 2198 2199 Object.defineProperties(Prism.languages['markup-templating'] = {}, { 2200 buildPlaceholders: { 2201 /** 2202 * Tokenize all inline templating expressions matching `placeholderPattern`. 2203 * 2204 * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns 2205 * `true` will be replaced. 2206 * 2207 * @param {object} env The environment of the `before-tokenize` hook. 2208 * @param {string} language The language id. 2209 * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders. 2210 * @param {(match: string) => boolean} [replaceFilter] 2211 */ 2212 value: function (env, language, placeholderPattern, replaceFilter) { 2213 if (env.language !== language) { 2214 return; 2215 } 2216 2217 var tokenStack = env.tokenStack = []; 2218 2219 env.code = env.code.replace(placeholderPattern, function (match) { 2220 if (typeof replaceFilter === 'function' && !replaceFilter(match)) { 2221 return match; 2222 } 2223 var i = tokenStack.length; 2224 var placeholder; 2225 2226 // Check for existing strings 2227 while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) { 2228 ++i; 2229 } 2230 2231 // Create a sparse array 2232 tokenStack[i] = match; 2233 2234 return placeholder; 2235 }); 2236 2237 // Switch the grammar to markup 2238 env.grammar = Prism.languages.markup; 2239 } 2240 }, 2241 tokenizePlaceholders: { 2242 /** 2243 * Replace placeholders with proper tokens after tokenizing. 2244 * 2245 * @param {object} env The environment of the `after-tokenize` hook. 2246 * @param {string} language The language id. 2247 */ 2248 value: function (env, language) { 2249 if (env.language !== language || !env.tokenStack) { 2250 return; 2251 } 2252 2253 // Switch the grammar back 2254 env.grammar = Prism.languages[language]; 2255 2256 var j = 0; 2257 var keys = Object.keys(env.tokenStack); 2258 2259 function walkTokens(tokens) { 2260 for (var i = 0; i < tokens.length; i++) { 2261 // all placeholders are replaced already 2262 if (j >= keys.length) { 2263 break; 2264 } 2265 2266 var token = tokens[i]; 2267 if (typeof token === 'string' || (token.content && typeof token.content === 'string')) { 2268 var k = keys[j]; 2269 var t = env.tokenStack[k]; 2270 var s = typeof token === 'string' ? token : token.content; 2271 var placeholder = getPlaceholder(language, k); 2272 2273 var index = s.indexOf(placeholder); 2274 if (index > -1) { 2275 ++j; 2276 2277 var before = s.substring(0, index); 2278 var middle = new Prism.Token(language, Prism.tokenize(t, env.grammar), 'language-' + language, t); 2279 var after = s.substring(index + placeholder.length); 2280 2281 var replacement = []; 2282 if (before) { 2283 replacement.push.apply(replacement, walkTokens([before])); 2284 } 2285 replacement.push(middle); 2286 if (after) { 2287 replacement.push.apply(replacement, walkTokens([after])); 2288 } 2289 2290 if (typeof token === 'string') { 2291 tokens.splice.apply(tokens, [i, 1].concat(replacement)); 2292 } else { 2293 token.content = replacement; 2294 } 2295 } 2296 } else if (token.content /* && typeof token.content !== 'string' */) { 2297 walkTokens(token.content); 2298 } 2299 } 2300 2301 return tokens; 2302 } 2303 2304 walkTokens(env.tokens); 2305 } 2306 } 2307 }); 2308 2309}(Prism$1)); 2310 2311var prismRuby = {}; 2312 2313var hasRequiredPrismRuby; 2314 2315function requirePrismRuby () { 2316 if (hasRequiredPrismRuby) return prismRuby; 2317 hasRequiredPrismRuby = 1; 2318 (function (Prism) { 2319 Prism.languages.ruby = Prism.languages.extend('clike', { 2320 'comment': { 2321 pattern: /#.*|^=begin\s[\s\S]*?^=end/m, 2322 greedy: true 2323 }, 2324 'class-name': { 2325 pattern: /(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/, 2326 lookbehind: true, 2327 inside: { 2328 'punctuation': /[.\\]/ 2329 } 2330 }, 2331 'keyword': /\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/, 2332 'operator': /\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/, 2333 'punctuation': /[(){}[\].,;]/, 2334 }); 2335 2336 Prism.languages.insertBefore('ruby', 'operator', { 2337 'double-colon': { 2338 pattern: /::/, 2339 alias: 'punctuation' 2340 }, 2341 }); 2342 2343 var interpolation = { 2344 pattern: /((?:^|[^\\])(?:\\{2}
2344)*)#\{(?:[^{}]|\{[^{}]*\})*\}/, 2345 lookbehind: true, 2346 inside: { 2347 'content': { 2348 pattern: /^(#\{)[\s\S]+(?=\}$)/, 2349 lookbehind: true, 2350 inside: Prism.languages.ruby 2351 }, 2352 'delimiter': { 2353 pattern: /^#\{|\}$/, 2354 alias: 'punctuation' 2355 } 2356 } 2357 }; 2358 2359 delete Prism.languages.ruby.function; 2360 2361 var percentExpression = '(?:' + [ 2362 /([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source, 2363 /\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source, 2364 /\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source, 2365 /\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source, 2366 /<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source 2367 ].join('|') + ')'; 2368 2369 var symbolName = /(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source; 2370 2371 Prism.languages.insertBefore('ruby', 'keyword', { 2372 'regex-literal': [ 2373 { 2374 pattern: RegExp(/%r/.source + percentExpression + /[egimnosux]{0,6}/.source), 2375 greedy: true, 2376 inside: { 2377 'interpolation': interpolation, 2378 'regex': /[\s\S]+/ 2379 } 2380 }, 2381 { 2382 pattern: /(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/, 2383 lookbehind: true, 2384 greedy: true, 2385 inside: { 2386 'interpolation': interpolation, 2387 'regex': /[\s\S]+/ 2388 } 2389 } 2390 ], 2391 'variable': /[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/, 2392 'symbol': [ 2393 { 2394 pattern: RegExp(/(^|[^:]):/.source + symbolName), 2395 lookbehind: true, 2396 greedy: true 2397 }, 2398 { 2399 pattern: RegExp(/([\r\n{(,][ \t]*)/.source + symbolName + /(?=:(?!:))/.source), 2400 lookbehind: true, 2401 greedy: true 2402 }, 2403 ], 2404 'method-definition': { 2405 pattern: /(\bdef\s+)\w+(?:\s*\.\s*\w+)?/, 2406 lookbehind: true, 2407 inside: { 2408 'function': /\b\w+$/, 2409 'keyword': /^self\b/, 2410 'class-name': /^\w+/, 2411 'punctuation': /\./ 2412 } 2413 } 2414 }); 2415 2416 Prism.languages.insertBefore('ruby', 'string', { 2417 'string-literal': [ 2418 { 2419 pattern: RegExp(/%[qQiIwWs]?/.source + percentExpression), 2420 greedy: true, 2421 inside: { 2422 'interpolation': interpolation, 2423 'string': /[\s\S]+/ 2424 } 2425 }, 2426 { 2427 pattern: /("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/, 2428 greedy: true, 2429 inside: { 2430 'interpolation': interpolation, 2431 'string': /[\s\S]+/ 2432 } 2433 }, 2434 { 2435 pattern: /<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i, 2436 alias: 'heredoc-string', 2437 greedy: true, 2438 inside: { 2439 'delimiter': { 2440 pattern: /^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i, 2441 inside: { 2442 'symbol': /\b\w+/, 2443 'punctuation': /^<<[-~]?/ 2444 } 2445 }, 2446 'interpolation': interpolation, 2447 'string': /[\s\S]+/ 2448 } 2449 }, 2450 { 2451 pattern: /<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i, 2452 alias: 'heredoc-string', 2453 greedy: true, 2454 inside: { 2455 'delimiter': { 2456 pattern: /^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i, 2457 inside: { 2458 'symbol': /\b\w+/, 2459 'punctuation': /^<<[-~]?'|'$/, 2460 } 2461 }, 2462 'string': /[\s\S]+/ 2463 } 2464 } 2465 ], 2466 'command-literal': [ 2467 { 2468 pattern: RegExp(/%x/.source + percentExpression), 2469 greedy: true, 2470 inside: { 2471 'interpolation': interpolation, 2472 'command': { 2473 pattern: /[\s\S]+/, 2474 alias: 'string' 2475 } 2476 } 2477 }, 2478 { 2479 pattern: /`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/, 2480 greedy: true, 2481 inside: { 2482 'interpolation': interpolation, 2483 'command': { 2484 pattern: /[\s\S]+/, 2485 alias: 'string' 2486 } 2487 } 2488 } 2489 ] 2490 }); 2491 2492 delete Prism.languages.ruby.string; 2493 2494 Prism.languages.insertBefore('ruby', 'number', { 2495 'builtin': /\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/, 2496 'constant': /\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/ 2497 }); 2498 2499 Prism.languages.rb = Prism.languages.ruby; 2500 }(Prism$1)); 2501 return prismRuby; 2502} 2503 2504requirePrismRuby(); 2505 2506var prismPhp = {}; 2507 2508var hasRequiredPrismPhp; 2509 2510function requirePrismPhp () { 2511 if (hasRequiredPrismPhp) return prismPhp; 2512 hasRequiredPrismPhp = 1; 2513 (function (Prism) { 2514 var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/; 2515 var constant = [ 2516 { 2517 pattern: /\b(?:false|true)\b/i, 2518 alias: 'boolean' 2519 }, 2520 { 2521 pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i, 2522 greedy: true, 2523 lookbehind: true, 2524 }, 2525 { 2526 pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i, 2527 greedy: true, 2528 lookbehind: true, 2529 }, 2530 /\b(?:null)\b/i, 2531 /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/, 2532 ]; 2533 var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i; 2534 var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/; 2535 var punctuation = /[{}\[\](),:;]/; 2536 2537 Prism.languages.php = { 2538 'delimiter': { 2539 pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
vendor: 10,661 bytes, lines 2540-2887
2540 alias: 'important' 2541 }, 2542 'comment': comment, 2543 'variable': /\$+(?:\w+\b|(?=\{))/, 2544 'package': { 2545 pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i, 2546 lookbehind: true, 2547 inside: { 2548 'punctuation': /\\/ 2549 } 2550 }, 2551 'class-name-definition': { 2552 pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i, 2553 lookbehind: true, 2554 alias: 'class-name' 2555 }, 2556 'function-definition': { 2557 pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i, 2558 lookbehind: true, 2559 alias: 'function' 2560 }, 2561 'keyword': [ 2562 { 2563 pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i, 2564 alias: 'type-casting', 2565 greedy: true, 2566 lookbehind: true 2567 }, 2568 { 2569 pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i, 2570 alias: 'type-hint', 2571 greedy: true, 2572 lookbehind: true 2573 }, 2574 { 2575 pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i, 2576 alias: 'return-type', 2577 greedy: true, 2578 lookbehind: true 2579 }, 2580 { 2581 pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i, 2582 alias: 'type-declaration', 2583 greedy: true 2584 }, 2585 { 2586 pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i, 2587 alias: 'type-declaration', 2588 greedy: true, 2589 lookbehind: true 2590 }, 2591 { 2592 pattern: /\b(?:parent|self|static)(?=\s*::)/i, 2593 alias: 'static-context', 2594 greedy: true 2595 }, 2596 { 2597 // yield from 2598 pattern: /(\byield\s+)from\b/i, 2599 lookbehind: true 2600 }, 2601 // `class` is always a keyword unlike other keywords 2602 /\bclass\b/i, 2603 { 2604 // https://www.php.net/manual/en/reserved.keywords.php 2605 // 2606 // keywords cannot be preceded by "->" 2607 // the complex lookbehind means `(?<!(?:->|::)\s*)` 2608 pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i, 2609 lookbehind: true 2610 } 2611 ], 2612 'argument-name': { 2613 pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i, 2614 lookbehind: true 2615 }, 2616 'class-name': [ 2617 { 2618 pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i, 2619 greedy: true, 2620 lookbehind: true 2621 }, 2622 { 2623 pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i, 2624 greedy: true, 2625 lookbehind: true 2626 }, 2627 { 2628 pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i, 2629 greedy: true 2630 }, 2631 { 2632 pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i, 2633 alias: 'class-name-fully-qualified', 2634 greedy: true, 2635 lookbehind: true, 2636 inside: { 2637 'punctuation': /\\/ 2638 } 2639 }, 2640 { 2641 pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i, 2642 alias: 'class-name-fully-qualified', 2643 greedy: true, 2644 inside: { 2645 'punctuation': /\\/ 2646 } 2647 }, 2648 { 2649 pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i, 2650 alias: 'class-name-fully-qualified', 2651 greedy: true, 2652 lookbehind: true, 2653 inside: { 2654 'punctuation': /\\/ 2655 } 2656 }, 2657 { 2658 pattern: /\b[a-z_]\w*(?=\s*\$)/i, 2659 alias: 'type-declaration', 2660 greedy: true 2661 }, 2662 { 2663 pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i, 2664 alias: ['class-name-fully-qualified', 'type-declaration'], 2665 greedy: true, 2666 inside: { 2667 'punctuation': /\\/ 2668 } 2669 }, 2670 { 2671 pattern: /\b[a-z_]\w*(?=\s*::)/i, 2672 alias: 'static-context', 2673 greedy: true 2674 }, 2675 { 2676 pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i, 2677 alias: ['class-name-fully-qualified', 'static-context'], 2678 greedy: true, 2679 inside: { 2680 'punctuation': /\\/ 2681 } 2682 }, 2683 { 2684 pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i, 2685 alias: 'type-hint', 2686 greedy: true, 2687 lookbehind: true 2688 }, 2689 { 2690 pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i, 2691 alias: ['class-name-fully-qualified', 'type-hint'], 2692 greedy: true, 2693 lookbehind: true, 2694 inside: { 2695 'punctuation': /\\/ 2696 } 2697 }, 2698 { 2699 pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i, 2700 alias: 'return-type', 2701 greedy: true, 2702 lookbehind: true 2703 }, 2704 { 2705 pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i, 2706 alias: ['class-name-fully-qualified', 'return-type'], 2707 greedy: true, 2708 lookbehind: true, 2709 inside: { 2710 'punctuation': /\\/ 2711 } 2712 } 2713 ], 2714 'constant': constant, 2715 'function': { 2716 pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i, 2717 lookbehind: true, 2718 inside: { 2719 'punctuation': /\\/ 2720 } 2721 }, 2722 'property': { 2723 pattern: /(->\s*)\w+/, 2724 lookbehind: true 2725 }, 2726 'number': number, 2727 'operator': operator, 2728 'punctuation': punctuation 2729 }; 2730 2731 var string_interpolation = { 2732 pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/, 2733 lookbehind: true, 2734 inside: Prism.languages.php 2735 }; 2736 2737 var string = [ 2738 { 2739 pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/, 2740 alias: 'nowdoc-string', 2741 greedy: true, 2742 inside: { 2743 'delimiter': { 2744 pattern: /^<<<'[^']+'|[a-z_]\w*;$/i, 2745 alias: 'symbol', 2746 inside: { 2747 'punctuation': /^<<<'?|[';]$/ 2748 } 2749 } 2750 } 2751 }, 2752 { 2753 pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i, 2754 alias: 'heredoc-string', 2755 greedy: true, 2756 inside: { 2757 'delimiter': { 2758 pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i, 2759 alias: 'symbol', 2760 inside: { 2761 'punctuation': /^<<<"?|[";]$/ 2762 } 2763 }, 2764 'interpolation': string_interpolation 2765 } 2766 }, 2767 { 2768 pattern: /`(?:\\[\s\S]|[^\\`])*`/, 2769 alias: 'backtick-quoted-string', 2770 greedy: true 2771 }, 2772 { 2773 pattern: /'(?:\\[\s\S]|[^\\'])*'/, 2774 alias: 'single-quoted-string', 2775 greedy: true 2776 }, 2777 { 2778 pattern: /"(?:\\[\s\S]|[^\\"])*"/, 2779 alias: 'double-quoted-string', 2780 greedy: true, 2781 inside: { 2782 'interpolation': string_interpolation 2783 } 2784 } 2785 ]; 2786 2787 Prism.languages.insertBefore('php', 'variable', { 2788 'string': string, 2789 'attribute': { 2790 pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im, 2791 greedy: true, 2792 inside: { 2793 'attribute-content': { 2794 pattern: /^(#\[)[\s\S]+(?=\]$)/, 2795 lookbehind: true, 2796 // inside can appear subset of php 2797 inside: { 2798 'comment': comment, 2799 'string': string, 2800 'attribute-class-name': [ 2801 { 2802 pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i, 2803 alias: 'class-name', 2804 greedy: true, 2805 lookbehind: true 2806 }, 2807 { 2808 pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i, 2809 alias: [ 2810 'class-name', 2811 'class-name-fully-qualified' 2812 ], 2813 greedy: true, 2814 lookbehind: true, 2815 inside: { 2816 'punctuation': /\\/ 2817 } 2818 } 2819 ], 2820 'constant': constant, 2821 'number': number, 2822 'operator': operator, 2823 'punctuation': punctuation 2824 } 2825 }, 2826 'delimiter': { 2827 pattern: /^#\[|\]$/, 2828 alias: 'punctuation' 2829 } 2830 } 2831 }, 2832 }); 2833 2834 Prism.hooks.add('before-tokenize', function (env) { 2835 if (!/<\?/.test(env.code)) { 2836 return; 2837 } 2838 2839 var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g; 2840 Prism.languages['markup-templating'].buildPlaceholders(env, 'php', phpPattern); 2841 }); 2842 2843 Prism.hooks.add('after-tokenize', function (env) { 2844 Prism.languages['markup-templating'].tokenizePlaceholders(env, 'php'); 2845 }); 2846 2847 }(Prism$1)); 2848 return prismPhp; 2849} 2850 2851requirePrismPhp(); 2852 2853Prism$1.languages.go = Prism$1.languages.extend('clike', { 2854 'string': { 2855 pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/, 2856 lookbehind: true, 2857 greedy: true 2858 }, 2859 'keyword': /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/, 2860 'boolean': /\b(?:_|false|iota|nil|true)\b/, 2861 'number': [ 2862 // binary and octal integers 2863 /\b0(?:b[01_]+|o[0-7_]+)i?\b/i, 2864 // hexadecimal integers and floats 2865 /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i, 2866 // decimal integers and floats 2867 /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i 2868 ], 2869 'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./, 2870 'builtin': /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/ 2871}); 2872 2873Prism$1.languages.insertBefore('go', 'string', { 2874 'char': { 2875 pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/, 2876 greedy: true 2877 } 2878}); 2879 2880delete Prism$1.languages.go['class-name']; 2881 2882(function (Prism) { 2883 // $ set | grep '^[A-Z][^[:space:]]*=' | cut -d= -f1 | tr '\n' '|' 2884 // + LC_ALL, RANDOM, REPLY, SECONDS. 2885 // + make sure PS1..4 are here as they are not always set, 2886 // - some useless things. 2887 var envVars = '\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_
2887CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b'; 2888 2889 var commandAfterHeredoc = { 2890 pattern: /(^(["']?)\w+\2)[ \t]+\S.*/, 2891 lookbehind: true, 2892 alias: 'punctuation', // this looks reasonably well in all themes 2893 inside: null // see below 2894 }; 2895 2896 var insideString = { 2897 'bash': commandAfterHeredoc, 2898 'environment': { 2899 pattern: RegExp('\\$' + envVars), 2900 alias: 'constant' 2901 }, 2902 'variable': [ 2903 // [0]: Arithmetic Environment 2904 { 2905 pattern: /\$?\(\([\s\S]+?\)\)/, 2906 greedy: true, 2907 inside: { 2908 // If there is a $ sign at the beginning highlight $(( and )) as variable 2909 'variable': [ 2910 { 2911 pattern: /(^\$\(\([\s\S]+)\)\)/, 2912 lookbehind: true 2913 }, 2914 /^\$\(\(/ 2915 ], 2916 'number': /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/, 2917 // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic 2918 'operator': /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/, 2919 // If there is no $ sign at the beginning highlight (( and )) as punctuation 2920 'punctuation': /\(\(?|\)\)?|,|;/ 2921 } 2922 }, 2923 // [1]: Command Substitution 2924 { 2925 pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/, 2926 greedy: true, 2927 inside: { 2928 'variable': /^\$\(|^`|\)$|`$/ 2929 } 2930 }, 2931 // [2]: Brace expansion 2932 { 2933 pattern: /\$\{[^}]+\}/, 2934 greedy: true, 2935 inside: { 2936 'operator': /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/, 2937 'punctuation': /[\[\]]/, 2938 'environment': { 2939 pattern: RegExp('(\\{)' + envVars), 2940 lookbehind: true, 2941 alias: 'constant' 2942 } 2943 } 2944 }, 2945 /\$(?:\w+|[#?*!@$])/ 2946 ], 2947 // Escape sequences from echo and printf's manuals, and escaped quotes. 2948 'entity': /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/ 2949 }; 2950 2951 Prism.languages.bash = { 2952 'shebang': { 2953 pattern: /^#!\s*\/.*/, 2954 alias: 'important' 2955 }, 2956 'comment': { 2957 pattern: /(^|[^"{\\$])#.*/, 2958 lookbehind: true 2959 }, 2960 'function-name': [ 2961 // a) function foo { 2962 // b) foo() { 2963 // c) function foo() { 2964 // but not âfoo {â 2965 { 2966 // a) and c) 2967 pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/, 2968 lookbehind: true, 2969 alias: 'function' 2970 }, 2971 { 2972 // b) 2973 pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/, 2974 alias: 'function' 2975 } 2976 ], 2977 // Highlight variable names as variables in for and select beginnings. 2978 'for-or-select': { 2979 pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/, 2980 alias: 'variable', 2981 lookbehind: true 2982 }, 2983 // Highlight variable names as variables in the left-hand part 2984 // of assignments (â=â and â+=â). 2985 'assign-left': { 2986 pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/, 2987 inside: { 2988 'environment': { 2989 pattern: RegExp('(^|[\\s;|&]|[<>]\\()' + envVars), 2990 lookbehind: true, 2991 alias: 'constant' 2992 } 2993 }, 2994 alias: 'variable', 2995 lookbehind: true 2996 }, 2997 // Highlight parameter names as variables 2998 'parameter': { 2999 pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/, 3000 alias: 'variable', 3001 lookbehind: true 3002 }, 3003 'string': [ 3004 // Support for Here-documents https://en.wikipedia.org/wiki/Here_document 3005 { 3006 pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/, 3007 lookbehind: true, 3008 greedy: true, 3009 inside: insideString 3010 }, 3011 // Here-document with quotes around the tag 3012 // â No expansion (so no âinsideâ). 3013 { 3014 pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/, 3015 lookbehind: true, 3016 greedy: true, 3017 inside: { 3018 'bash': commandAfterHeredoc 3019 } 3020 }, 3021 // âNormalâ string 3022 { 3023 // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html 3024 pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/, 3025 lookbehind: true, 3026 greedy: true, 3027 inside: insideString 3028 }, 3029 { 3030 // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html 3031 pattern: /(^|[^$\\])'[^']*'/, 3032 lookbehind: true, 3033 greedy: true 3034 }, 3035 { 3036 // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html 3037 pattern: /\$'(?:[^'\\]|\\[\s\S])*'/, 3038 greedy: true, 3039 inside: { 3040 'entity': insideString.entity 3041 } 3042 } 3043 ], 3044 'environment': { 3045 pattern: RegExp('\\$?' + envVars), 3046 alias: 'constant' 3047 }, 3048 'variable': insideString.variable, 3049 'function': { 3050 pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|
3050ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/, 3051 lookbehind: true 3052 }, 3053 'keyword': { 3054 pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/, 3055 lookbehind: true 3056 }, 3057 // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html 3058 'builtin': { 3059 pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/, 3060 lookbehind: true, 3061 // Alias added to make those easier to distinguish from strings. 3062 alias: 'class-name' 3063 }, 3064 'boolean': { 3065 pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/, 3066 lookbehind: true 3067 }, 3068 'file-descriptor': { 3069 pattern: /\B&\d\b/, 3070 alias: 'important' 3071 }, 3072 'operator': { 3073 // Lots of redirections here, but not just that. 3074 pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/, 3075 inside: { 3076 'file-descriptor': { 3077 pattern: /^\d/, 3078 alias: 'important' 3079 } 3080 } 3081 }, 3082 'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/, 3083 'number': { 3084 pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/, 3085 lookbehind: true 3086 } 3087 }; 3088 3089 commandAfterHeredoc.inside = Prism.languages.bash; 3090 3091 /* Patterns in command substitution. */ 3092 var toBeCopied = [ 3093 'comment', 3094 'function-name', 3095 'for-or-select', 3096 'assign-left', 3097 'parameter', 3098 'string', 3099 'environment', 3100 'function', 3101 'keyword', 3102 'builtin', 3103 'boolean', 3104 'file-descriptor', 3105 'operator', 3106 'punctuation', 3107 'number' 3108 ]; 3109 var inside = insideString.variable[1].inside; 3110 for (var i = 0; i < toBeCopied.length; i++) { 3111 inside[toBeCopied[i]] = Prism.languages.bash[toBeCopied[i]]; 3112 } 3113 3114 Prism.languages.sh = Prism.languages.bash; 3115 Prism.languages.shell = Prism.languages.bash; 3116}(Prism$1)); 3117 3118// https://www.json.org/json-en.html 3119Prism$1.languages.json = { 3120 'property': { 3121 pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/, 3122 lookbehind: true, 3123 greedy: true 3124 }, 3125 'string': { 3126 pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/, 3127 lookbehind: true, 3128 greedy: true 3129 }, 3130 'comment': { 3131 pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/, 3132 greedy: true 3133 }, 3134 'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i, 3135 'punctuation': /[{}[\],]/, 3136 'operator': /:/, 3137 'boolean': /\b(?:false|true)\b/, 3138 'null': { 3139 pattern: /\bnull\b/, 3140 alias: 'keyword' 3141 } 3142}; 3143 3144Prism$1.languages.webmanifest = Prism$1.languages.json; 3145 3146(function (Prism) { 3147 3148 Prism.languages.diff = { 3149 'coord': [ 3150 // Match all kinds of coord lines (prefixed by "+++", "---" or "***"). 3151 /^(?:\*{3}|-{3}|\+{3}).*$/m, 3152 // Match "@@ ... @@" coord lines in unified diff. 3153 /^@@.*@@$/m, 3154 // Match coord lines in normal diff (starts with a number). 3155 /^\d.*$/m 3156 ] 3157 3158 // deleted, inserted, unchanged, diff 3159 }; 3160 3161 /** 3162 * A map from the name of a block to its line prefix. 3163 * 3164 * @type {Object<string, string>} 3165 */ 3166 var PREFIXES = { 3167 'deleted-sign': '-', 3168 'deleted-arrow': '<', 3169 'inserted-sign': '+', 3170 'inserted-arrow': '>', 3171 'unchanged': ' ', 3172 'diff': '!', 3173 }; 3174 3175 // add a token for each prefix
vendor: 1,050 bytes, lines 3176-3216
3176 Object.keys(PREFIXES).forEach(function (name) { 3177 var prefix = PREFIXES[name]; 3178 3179 var alias = []; 3180 if (!/^\w+$/.test(name)) { // "deleted-sign" -> "deleted" 3181 alias.push(/\w+/.exec(name)[0]); 3182 } 3183 if (name === 'diff') { 3184 alias.push('bold'); 3185 } 3186 3187 Prism.languages.diff[name] = { 3188 pattern: RegExp('^(?:[' + prefix + '].*(?:\r\n?|\n|(?![\\s\\S])))+', 'm'), 3189 alias: alias, 3190 inside: { 3191 'line': { 3192 pattern: /(.)(?=[\s\S]).*(?:\r\n?|\n)?/, 3193 lookbehind: true 3194 }, 3195 'prefix': { 3196 pattern: /[\s\S]/, 3197 alias: /\w+/.exec(name)[0] 3198 } 3199 } 3200 }; 3201 3202 }); 3203 3204 // make prefixes available to Diff plugin 3205 Object.defineProperty(Prism.languages.diff, 'PREFIXES', { 3206 value: PREFIXES 3207 }); 3208 3209}(Prism$1)); 3210 3211// Configure Prism for manual highlighting mode 3212// This must be set before importing prismjs 3213window.Prism = window.Prism || {}; 3214window.Prism.manual = true; 3215 3216/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0
vendor: 17,189 bytes, lines 3216-3514
3216/LICENSE */ 3217 3218const { 3219 entries, 3220 setPrototypeOf, 3221 isFrozen, 3222 getPrototypeOf, 3223 getOwnPropertyDescriptor 3224} = Object; 3225let { 3226 freeze, 3227 seal, 3228 create 3229} = Object; // eslint-disable-line import/no-mutable-exports 3230let { 3231 apply, 3232 construct 3233} = typeof Reflect !== 'undefined' && Reflect; 3234if (!freeze) { 3235 freeze = function freeze(x) { 3236 return x; 3237 }; 3238} 3239if (!seal) { 3240 seal = function seal(x) { 3241 return x; 3242 }; 3243} 3244if (!apply) { 3245 apply = function apply(func, thisArg) { 3246 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { 3247 args[_key - 2] = arguments[_key]; 3248 } 3249 return func.apply(thisArg, args); 3250 }; 3251} 3252if (!construct) { 3253 construct = function construct(Func) { 3254 for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { 3255 args[_key2 - 1] = arguments[_key2]; 3256 } 3257 return new Func(...args); 3258 }; 3259} 3260const arrayForEach = unapply(Array.prototype.forEach); 3261const arrayLastIndexOf = unapply(Array.prototype.lastIndexOf); 3262const arrayPop = unapply(Array.prototype.pop); 3263const arrayPush = unapply(Array.prototype.push); 3264const arraySplice = unapply(Array.prototype.splice); 3265const stringToLowerCase = unapply(String.prototype.toLowerCase); 3266const stringToString = unapply(String.prototype.toString); 3267const stringMatch = unapply(String.prototype.match); 3268const stringReplace = unapply(String.prototype.replace); 3269const stringIndexOf = unapply(String.prototype.indexOf); 3270const stringTrim = unapply(String.prototype.trim); 3271const objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty); 3272const regExpTest = unapply(RegExp.prototype.test); 3273const typeErrorCreate = unconstruct(TypeError); 3274/** 3275 * Creates a new function that calls the given function with a specified thisArg and arguments. 3276 * 3277 * @param func - The function to be wrapped and called. 3278 * @returns A new function that calls the given function with a specified thisArg and arguments. 3279 */ 3280function unapply(func) { 3281 return function (thisArg) { 3282 if (thisArg instanceof RegExp) { 3283 thisArg.lastIndex = 0; 3284 } 3285 for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { 3286 args[_key3 - 1] = arguments[_key3]; 3287 } 3288 return apply(func, thisArg, args); 3289 }; 3290} 3291/** 3292 * Creates a new function that constructs an instance of the given constructor function with the provided arguments. 3293 * 3294 * @param func - The constructor function to be wrapped and called. 3295 * @returns A new function that constructs an instance of the given constructor function with the provided arguments. 3296 */ 3297function unconstruct(Func) { 3298 return function () { 3299 for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { 3300 args[_key4] = arguments[_key4]; 3301 } 3302 return construct(Func, args); 3303 }; 3304} 3305/** 3306 * Add properties to a lookup table 3307 * 3308 * @param set - The set to which elements will be added. 3309 * @param array - The array containing elements to be added to the set. 3310 * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set. 3311 * @returns The modified set with added elements. 3312 */ 3313function addToSet(set, array) { 3314 let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase; 3315 if (setPrototypeOf) { 3316 // Make 'in' and truthy checks like Boolean(set.constructor) 3317 // independent of any properties defined on Object.prototype. 3318 // Prevent prototype setters from intercepting set as a this value. 3319 setPrototypeOf(set, null); 3320 } 3321 let l = array.length; 3322 while (l--) { 3323 let element = array[l]; 3324 if (typeof element === 'string') { 3325 const lcElement = transformCaseFunc(element); 3326 if (lcElement !== element) { 3327 // Config presets (e.g. tags.js, attrs.js) are immutable. 3328 if (!isFrozen(array)) { 3329 array[l] = lcElement; 3330 } 3331 element = lcElement; 3332 } 3333 } 3334 set[element] = true; 3335 } 3336 return set; 3337} 3338/** 3339 * Clean up an array to harden against CSPP 3340 * 3341 * @param array - The array to be cleaned. 3342 * @returns The cleaned version of the array 3343 */ 3344function cleanArray(array) { 3345 for (let index = 0; index < array.length; index++) { 3346 const isPropertyExist = objectHasOwnProperty(array, index); 3347 if (!isPropertyExist) { 3348 array[index] = null; 3349 } 3350 } 3351 return array; 3352} 3353/** 3354 * Shallow clone an object 3355 * 3356 * @param object - The object to be cloned. 3357 * @returns A new object that copies the original. 3358 */ 3359function clone(object) { 3360 const newObject = create(null); 3361 for (const [property, value] of entries(object)) { 3362 const isPropertyExist = objectHasOwnProperty(object, property); 3363 if (isPropertyExist) { 3364 if (Array.isArray(value)) { 3365 newObject[property] = cleanArray(value); 3366 } else if (value && typeof value === 'object' && value.constructor === Object) { 3367 newObject[property] = clone(value); 3368 } else { 3369 newObject[property] = value; 3370 } 3371 } 3372 } 3373 return newObject; 3374} 3375/** 3376 * This method automatically checks if the prop is function or getter and behaves accordingly. 3377 * 3378 * @param object - The object to look up the getter function in its prototype chain. 3379 * @param prop - The property name for which to find the getter function. 3380 * @returns The getter function found in the prototype chain or a fallback function. 3381 */ 3382function lookupGetter(object, prop) { 3383 while (object !== null) { 3384 const desc = getOwnPropertyDescriptor(object, prop); 3385 if (desc) { 3386 if (desc.get) { 3387 return unapply(desc.get); 3388 } 3389 if (typeof desc.value === 'function') { 3390 return unapply(desc.value); 3391 } 3392 } 3393 object = getPrototypeOf(object); 3394 } 3395 function fallbackValue() { 3396 return null; 3397 } 3398 return fallbackValue; 3399} 3400 3401const html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']); 3402const svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']); 3403const svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']); 3404// List of SVG elements that are disallowed by default. 3405// We still need to know them so that we can do namespace 3406// checks properly in case one wants to add them to 3407// allow-list. 3408const svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']); 3409const mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']); 3410// Similarly to SVG, we want to know all MathML elements, 3411// even those that we disallow by default. 3412const mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']); 3413const text = freeze(['#text']); 3414 3415const html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']); 3416const svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']); 3417const mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']); 3418const xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']); 3419 3420// eslint-disable-next-line unicorn/better-regex 3421const MUSTACHE_EXPR = seal(/\{\{[\w\W]*|[\w\W]*\}\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode 3422const ERB_EXPR = seal(/<%[\w\W]*|[\w\W]*%>/gm); 3423const TMPLIT_EXPR = seal(/\$\{[\w\W]*/gm); // eslint-disable-line unicorn/better-regex 3424const DATA_ATTR = seal(/^data-[\-\w.\u00B7-\uFFFF]+$/); // eslint-disable-line no-useless-escape 3425const ARIA_ATTR = seal(/^aria-[\-\w]+$/); // eslint-disable-line no-useless-escape 3426const IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i // eslint-disable-line no-useless-escape 3427); 3428const IS_SCRIPT_OR_DATA = seal(/^(?:\w+script|data):/i); 3429const ATTR_WHITESPACE = seal(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g // eslint-disable-line no-control-regex 3430); 3431const DOCTYPE_NAME = seal(/^html$/i); 3432const CUSTOM_ELEMENT = seal(/^[a-z][.\w]*(-[.\w]+)+$/i); 3433 3434var EXPRESSIONS = /*#__PURE__*/Object.freeze({ 3435 __proto__: null, 3436 ARIA_ATTR: ARIA_ATTR, 3437 ATTR_WHITESPACE: ATTR_WHITESPACE, 3438 CUSTOM_ELEMENT: CUSTOM_ELEMENT, 3439 DATA_ATTR: DATA_ATTR, 3440 DOCTYPE_NAME: DOCTYPE_NAME, 3441 ERB_EXPR: ERB_EXPR, 3442 IS_ALLOWED_URI: IS_ALLOWED_URI, 3443 IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA, 3444 MUSTACHE_EXPR: MUSTACHE_EXPR, 3445 TMPLIT_EXPR: TMPLIT_EXPR 3446}); 3447 3448/* eslint-disable @typescript-eslint/indent */ 3449// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType 3450const NODE_TYPE = { 3451 element: 1, 3452 text: 3, 3453 // Deprecated 3454 progressingInstruction: 7, 3455 comment: 8, 3456 document: 9}; 3457const getGlobal = function getGlobal() { 3458 return typeof window === 'undefined' ? null : window; 3459}; 3460/** 3461 * Creates a no-op policy for internal use only. 3462 * Don't export this function outside this module! 3463 * @param trustedTypes The policy factory. 3464 * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix). 3465 * @return The policy created (or null, if Trusted Types 3466 * are not supported or creating the policy failed). 3467 */ 3468const _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) { 3469 if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') { 3470 return null; 3471 } 3472 // Allow the callers to control the unique policy name 3473 // by adding a data-tt-policy-suffix to the script element with the DOMPurify. 3474 // Policy creation with duplicate names throws in Trusted Types. 3475 let suffix = null; 3476 const ATTR_NAME = 'data-tt-policy-suffix'; 3477 if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) { 3478 suffix = purifyHostElement.getAttribute(ATTR_NAME); 3479 } 3480 const policyName = 'dompurify' + (suffix ? '#' + suffix : ''); 3481 try { 3482 return trustedTypes.createPolicy(policyName, { 3483 createHTML(html) { 3484 return html; 3485 }, 3486 createScriptURL(scriptUrl) { 3487 return scriptUrl; 3488 } 3489 }); 3490 } catch (_) { 3491 // Policy creation failed (most likely another DOMPurify script has 3492 // already run). Skip creating the policy, as this will only cause errors 3493 // if TT are enforced. 3494 console.warn('TrustedTypes policy ' + policyName + ' could not be created.'); 3495 return null; 3496 } 3497}; 3498const _createHooksMap = function _createHooksMap() { 3499 return { 3500 afterSanitizeAttributes: [], 3501 afterSanitizeElements: [], 3502 afterSanitizeShadowDOM: [], 3503 beforeSanitizeAttributes: [], 3504 beforeSanitizeElements: [], 3505 beforeSanitizeShadowDOM: [], 3506 uponSanitizeAttribute: [], 3507 uponSanitizeElement: [], 3508 uponSanitizeShadowNode: [] 3509 }; 3510}; 3511function createDOMPurify() { 3512 let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal(); 3513 const DOMPurify = root => createDOMPurify(root); 3514 DOMPurify.version = '3.3.
35140
vendor: 14,276 bytes, lines 3514-3809
3514'; 3515 DOMPurify.removed = []; 3516 if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) { 3517 // Not running in a browser, provide a factory function 3518 // so that you can pass your own Window 3519 DOMPurify.isSupported = false; 3520 return DOMPurify; 3521 } 3522 let { 3523 document 3524 } = window; 3525 const originalDocument = document; 3526 const currentScript = originalDocument.currentScript; 3527 const { 3528 DocumentFragment, 3529 HTMLTemplateElement, 3530 Node, 3531 Element, 3532 NodeFilter, 3533 NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap, 3534 HTMLFormElement, 3535 DOMParser, 3536 trustedTypes 3537 } = window; 3538 const ElementPrototype = Element.prototype; 3539 const cloneNode = lookupGetter(ElementPrototype, 'cloneNode'); 3540 const remove = lookupGetter(ElementPrototype, 'remove'); 3541 const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling'); 3542 const getChildNodes = lookupGetter(ElementPrototype, 'childNodes'); 3543 const getParentNode = lookupGetter(ElementPrototype, 'parentNode'); 3544 // As per issue #47, the web-components registry is inherited by a 3545 // new document created via createHTMLDocument. As per the spec 3546 // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries) 3547 // a new empty registry is used when creating a template contents owner 3548 // document, so we use that as our parent document to ensure nothing 3549 // is inherited. 3550 if (typeof HTMLTemplateElement === 'function') { 3551 const template = document.createElement('template'); 3552 if (template.content && template.content.ownerDocument) { 3553 document = template.content.ownerDocument; 3554 } 3555 } 3556 let trustedTypesPolicy; 3557 let emptyHTML = ''; 3558 const { 3559 implementation, 3560 createNodeIterator, 3561 createDocumentFragment, 3562 getElementsByTagName 3563 } = document; 3564 const { 3565 importNode 3566 } = originalDocument; 3567 let hooks = _createHooksMap(); 3568 /** 3569 * Expose whether this browser supports running the full DOMPurify. 3570 */ 3571 DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined; 3572 const { 3573 MUSTACHE_EXPR, 3574 ERB_EXPR, 3575 TMPLIT_EXPR, 3576 DATA_ATTR, 3577 ARIA_ATTR, 3578 IS_SCRIPT_OR_DATA, 3579 ATTR_WHITESPACE, 3580 CUSTOM_ELEMENT 3581 } = EXPRESSIONS; 3582 let { 3583 IS_ALLOWED_URI: IS_ALLOWED_URI$1 3584 } = EXPRESSIONS; 3585 /** 3586 * We consider the elements and attributes below to be safe. Ideally 3587 * don't add any new ones but feel free to remove unwanted ones. 3588 */ 3589 /* allowed element names */ 3590 let ALLOWED_TAGS = null; 3591 const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]); 3592 /* Allowed attribute names */ 3593 let ALLOWED_ATTR = null; 3594 const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]); 3595 /* 3596 * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements. 3597 * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements) 3598 * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list) 3599 * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`. 3600 */ 3601 let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, { 3602 tagNameCheck: { 3603 writable: true, 3604 configurable: false, 3605 enumerable: true, 3606 value: null 3607 }, 3608 attributeNameCheck: { 3609 writable: true, 3610 configurable: false, 3611 enumerable: true, 3612 value: null 3613 }, 3614 allowCustomizedBuiltInElements: { 3615 writable: true, 3616 configurable: false, 3617 enumerable: true, 3618 value: false 3619 } 3620 })); 3621 /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */ 3622 let FORBID_TAGS = null; 3623 /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */ 3624 let FORBID_ATTR = null; 3625 /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */ 3626 const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, { 3627 tagCheck: { 3628 writable: true, 3629 configurable: false, 3630 enumerable: true, 3631 value: null 3632 }, 3633 attributeCheck: { 3634 writable: true, 3635 configurable: false, 3636 enumerable: true, 3637 value: null 3638 } 3639 })); 3640 /* Decide if ARIA attributes are okay */ 3641 let ALLOW_ARIA_ATTR = true; 3642 /* Decide if custom data attributes are okay */ 3643 let ALLOW_DATA_ATTR = true; 3644 /* Decide if unknown protocols are okay */ 3645 let ALLOW_UNKNOWN_PROTOCOLS = false; 3646 /* Decide if self-closing tags in attributes are allowed. 3647 * Usually removed due to a mXSS issue in jQuery 3.0 */ 3648 let ALLOW_SELF_CLOSE_IN_ATTR = true; 3649 /* Output should be safe for common template engines. 3650 * This means, DOMPurify removes data attributes, mustaches and ERB 3651 */ 3652 let SAFE_FOR_TEMPLATES = false; 3653 /* Output should be safe even for XML used within HTML and alike. 3654 * This means, DOMPurify removes comments when containing risky content. 3655 */ 3656 let SAFE_FOR_XML = true; 3657 /* Decide if document with <html>... should be returned */ 3658 let WHOLE_DOCUMENT = false; 3659 /* Track whether config is already set on this instance of DOMPurify. */ 3660 let SET_CONFIG = false; 3661 /* Decide if all elements (e.g. style, script) must be children of 3662 * document.body. By default, browsers might move them to document.head */ 3663 let FORCE_BODY = false; 3664 /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html 3665 * string (or a TrustedHTML object if Trusted Types are supported). 3666 * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead 3667 */ 3668 let RETURN_DOM = false; 3669 /* Decide if a DOM `DocumentFragment` should be returned, instead of a html 3670 * string (or a TrustedHTML object if Trusted Types are supported) */ 3671 let RETURN_DOM_FRAGMENT = false; 3672 /* Try to return a Trusted Type object instead of a string, return a string in 3673 * case Trusted Types are not supported */ 3674 let RETURN_TRUSTED_TYPE = false; 3675 /* Output should be free from DOM clobbering attacks? 3676 * This sanitizes markups named with colliding, clobberable built-in DOM APIs. 3677 */ 3678 let SANITIZE_DOM = true; 3679 /* Achieve full DOM Clobbering protection by isolating the namespace of named 3680 * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules. 3681 * 3682 * HTML/DOM spec rules that enable DOM Clobbering: 3683 * - Named Access on Window (§7.3.3) 3684 * - DOM Tree Accessors (§3.1.5) 3685 * - Form Element Parent-Child Relations (§4.10.3) 3686 * - Iframe srcdoc / Nested WindowProxies (§4.8.5) 3687 * - HTMLCollection (§4.2.10.2) 3688 * 3689 * Namespace isolation is implemented by prefixing `id` and `name` attributes 3690 * with a constant string, i.e., `user-content-` 3691 */ 3692 let SANITIZE_NAMED_PROPS = false; 3693 const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-'; 3694 /* Keep element content when removing element? */ 3695 let KEEP_CONTENT = true; 3696 /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead 3697 * of importing it into a new Document and returning a sanitized copy */ 3698 let IN_PLACE = false; 3699 /* Allow usage of profiles like html, svg and mathMl */ 3700 let USE_PROFILES = {}; 3701 /* Tags to ignore content of when KEEP_CONTENT is true */ 3702 let FORBID_CONTENTS = null; 3703 const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']); 3704 /* Tags that are safe for data: URIs */ 3705 let DATA_URI_TAGS = null; 3706 const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']); 3707 /* Attributes safe for values like "javascript:" */ 3708 let URI_SAFE_ATTRIBUTES = null; 3709 const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']); 3710 const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML'; 3711 const SVG_NAMESPACE = 'http://www.w3.org/2000/svg'; 3712 const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml'; 3713 /* Document namespace */ 3714 let NAMESPACE = HTML_NAMESPACE; 3715 let IS_EMPTY_INPUT = false; 3716 /* Allowed XHTML+XML namespaces */ 3717 let ALLOWED_NAMESPACES = null; 3718 const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString); 3719 let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']); 3720 let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']); 3721 // Certain elements are allowed in both SVG and HTML 3722 // namespace. We need to specify them explicitly 3723 // so that they don't get erroneously deleted from 3724 // HTML namespace. 3725 const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']); 3726 /* Parsing of strict XHTML documents */ 3727 let PARSER_MEDIA_TYPE = null; 3728 const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html']; 3729 const DEFAULT_PARSER_MEDIA_TYPE = 'text/html'; 3730 let transformCaseFunc = null; 3731 /* Keep a reference to config to pass to hooks */ 3732 let CONFIG = null; 3733 /* Ideally, do not touch anything below this line */ 3734 /* ______________________________________________ */ 3735 const formElement = document.createElement('form'); 3736 const isRegexOrFunction = function isRegexOrFunction(testValue) { 3737 return testValue instanceof RegExp || testValue instanceof Function; 3738 }; 3739 /** 3740 * _parseConfig 3741 * 3742 * @param cfg optional config literal 3743 */ 3744 // eslint-disable-next-line complexity 3745 const _parseConfig = function _parseConfig() { 3746 let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 3747 if (CONFIG && CONFIG === cfg) { 3748 return; 3749 } 3750 /* Shield configuration object from tampering */ 3751 if (!cfg || typeof cfg !== 'object') { 3752 cfg = {}; 3753 } 3754 /* Shield configuration object from prototype pollution */ 3755 cfg = clone(cfg); 3756 PARSER_MEDIA_TYPE = 3757 // eslint-disable-next-line unicorn/prefer-includes 3758 SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE; 3759 // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is. 3760 transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase; 3761 /* Set configuration parameters */ 3762 ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS; 3763 ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR; 3764 ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES; 3765 URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES; 3766 DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS; 3767 FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS; 3768 FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({}); 3769 FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({}); 3770 USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false; 3771 ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true 3772 ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true 3773 ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false 3774 ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true 3775 SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false 3776 SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true 3777 WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false 3778 RETURN_DOM = cfg.RETURN_DOM || false; // Default false 3779 RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false 3780 RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false 3781 FORCE_BODY = cfg.FORCE_BODY || false; // Default false 3782 SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true 3783 SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false 3784 KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true 3785 IN_PLACE = cfg.IN_PLACE || false; // Default false 3786 IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI; 3787 NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE; 3788 MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS; 3789 HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS; 3790 CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {}; 3791 if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) { 3792 CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck; 3793 } 3794 if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) { 3795 CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck; 3796 } 3797 if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') { 3798 CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements; 3799 } 3800 if (SAFE_FOR_TEMPLATES) { 3801 ALLOW_DATA_ATTR = false; 3802 } 3803 if (RETURN_DOM_FRAGMENT) { 3804 RETURN_DOM = true; 3805 } 3806 /* Parse profile info */ 3807 if (USE_PROFILES) { 3808 ALLOWED_TAGS = addToSet({}, text); 3809 ALLOWED_ATTR =
vendor: 1,583 bytes, lines 3809-3856
3809[]; 3810 if (USE_PROFILES.html === true) { 3811 addToSet(ALLOWED_TAGS, html$1); 3812 addToSet(ALLOWED_ATTR, html); 3813 } 3814 if (USE_PROFILES.svg === true) { 3815 addToSet(ALLOWED_TAGS, svg$1); 3816 addToSet(ALLOWED_ATTR, svg); 3817 addToSet(ALLOWED_ATTR, xml); 3818 } 3819 if (USE_PROFILES.svgFilters === true) { 3820 addToSet(ALLOWED_TAGS, svgFilters); 3821 addToSet(ALLOWED_ATTR, svg); 3822 addToSet(ALLOWED_ATTR, xml); 3823 } 3824 if (USE_PROFILES.mathMl === true) { 3825 addToSet(ALLOWED_TAGS, mathMl$1); 3826 addToSet(ALLOWED_ATTR, mathMl); 3827 addToSet(ALLOWED_ATTR, xml); 3828 } 3829 } 3830 /* Merge configuration parameters */ 3831 if (cfg.ADD_TAGS) { 3832 if (typeof cfg.ADD_TAGS === 'function') { 3833 EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS; 3834 } else { 3835 if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) { 3836 ALLOWED_TAGS = clone(ALLOWED_TAGS); 3837 } 3838 addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc); 3839 } 3840 } 3841 if (cfg.ADD_ATTR) { 3842 if (typeof cfg.ADD_ATTR === 'function') { 3843 EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR; 3844 } else { 3845 if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) { 3846 ALLOWED_ATTR = clone(ALLOWED_ATTR); 3847 } 3848 addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc); 3849 } 3850 } 3851 if (cfg.ADD_URI_SAFE_ATTR) { 3852 addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc); 3853 } 3854 if (cfg.FORBID_CONTENTS) { 3855 if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) { 3856 FORBID_CONTENTS = clone
vendor: 8,107 bytes, lines 3856-4065
3856(FORBID_CONTENTS); 3857 } 3858 addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc); 3859 } 3860 /* Add #text in case KEEP_CONTENT is set to true */ 3861 if (KEEP_CONTENT) { 3862 ALLOWED_TAGS['#text'] = true; 3863 } 3864 /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */ 3865 if (WHOLE_DOCUMENT) { 3866 addToSet(ALLOWED_TAGS, ['html', 'head', 'body']); 3867 } 3868 /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */ 3869 if (ALLOWED_TAGS.table) { 3870 addToSet(ALLOWED_TAGS, ['tbody']); 3871 delete FORBID_TAGS.tbody; 3872 } 3873 if (cfg.TRUSTED_TYPES_POLICY) { 3874 if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') { 3875 throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); 3876 } 3877 if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') { 3878 throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); 3879 } 3880 // Overwrite existing TrustedTypes policy. 3881 trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY; 3882 // Sign local variables required by `sanitize`. 3883 emptyHTML = trustedTypesPolicy.createHTML(''); 3884 } else { 3885 // Uninitialized policy, attempt to initialize the internal dompurify policy. 3886 if (trustedTypesPolicy === undefined) { 3887 trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript); 3888 } 3889 // If creating the internal policy succeeded sign internal variables. 3890 if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') { 3891 emptyHTML = trustedTypesPolicy.createHTML(''); 3892 } 3893 } 3894 // Prevent further manipulation of configuration. 3895 // Not available in IE8, Safari 5, etc. 3896 if (freeze) { 3897 freeze(cfg); 3898 } 3899 CONFIG = cfg; 3900 }; 3901 /* Keep track of all possible SVG and MathML tags 3902 * so that we can perform the namespace checks 3903 * correctly. */ 3904 const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]); 3905 const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]); 3906 /** 3907 * @param element a DOM element whose namespace is being checked 3908 * @returns Return false if the element has a 3909 * namespace that a spec-compliant parser would never 3910 * return. Return true otherwise. 3911 */ 3912 const _checkValidNamespace = function _checkValidNamespace(element) { 3913 let parent = getParentNode(element); 3914 // In JSDOM, if we're inside shadow DOM, then parentNode 3915 // can be null. We just simulate parent in this case. 3916 if (!parent || !parent.tagName) { 3917 parent = { 3918 namespaceURI: NAMESPACE, 3919 tagName: 'template' 3920 }; 3921 } 3922 const tagName = stringToLowerCase(element.tagName); 3923 const parentTagName = stringToLowerCase(parent.tagName); 3924 if (!ALLOWED_NAMESPACES[element.namespaceURI]) { 3925 return false; 3926 } 3927 if (element.namespaceURI === SVG_NAMESPACE) { 3928 // The only way to switch from HTML namespace to SVG 3929 // is via <svg>. If it happens via any other tag, then 3930 // it should be killed. 3931 if (parent.namespaceURI === HTML_NAMESPACE) { 3932 return tagName === 'svg'; 3933 } 3934 // The only way to switch from MathML to SVG is via` 3935 // svg if parent is either <annotation-xml> or MathML 3936 // text integration points. 3937 if (parent.namespaceURI === MATHML_NAMESPACE) { 3938 return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]); 3939 } 3940 // We only allow elements that are defined in SVG 3941 // spec. All others are disallowed in SVG namespace. 3942 return Boolean(ALL_SVG_TAGS[tagName]); 3943 } 3944 if (element.namespaceURI === MATHML_NAMESPACE) { 3945 // The only way to switch from HTML namespace to MathML 3946 // is via <math>. If it happens via any other tag, then 3947 // it should be killed. 3948 if (parent.namespaceURI === HTML_NAMESPACE) { 3949 return tagName === 'math'; 3950 } 3951 // The only way to switch from SVG to MathML is via 3952 // <math> and HTML integration points 3953 if (parent.namespaceURI === SVG_NAMESPACE) { 3954 return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName]; 3955 } 3956 // We only allow elements that are defined in MathML 3957 // spec. All others are disallowed in MathML namespace. 3958 return Boolean(ALL_MATHML_TAGS[tagName]); 3959 } 3960 if (element.namespaceURI === HTML_NAMESPACE) { 3961 // The only way to switch from SVG to HTML is via 3962 // HTML integration points, and from MathML to HTML 3963 // is via MathML text integration points 3964 if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) { 3965 return false; 3966 } 3967 if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) { 3968 return false; 3969 } 3970 // We disallow tags that are specific for MathML 3971 // or SVG and should never appear in HTML namespace 3972 return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]); 3973 } 3974 // For XHTML and XML documents that support custom namespaces 3975 if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) { 3976 return true; 3977 } 3978 // The code should never reach this place (this means 3979 // that the element somehow got namespace that is not 3980 // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES). 3981 // Return false just in case. 3982 return false; 3983 }; 3984 /** 3985 * _forceRemove 3986 * 3987 * @param node a DOM node 3988 */ 3989 const _forceRemove = function _forceRemove(node) { 3990 arrayPush(DOMPurify.removed, { 3991 element: node 3992 }); 3993 try { 3994 // eslint-disable-next-line unicorn/prefer-dom-node-remove 3995 getParentNode(node).removeChild(node); 3996 } catch (_) { 3997 remove(node); 3998 } 3999 }; 4000 /** 4001 * _removeAttribute 4002 * 4003 * @param name an Attribute name 4004 * @param element a DOM node 4005 */ 4006 const _removeAttribute = function _removeAttribute(name, element) { 4007 try { 4008 arrayPush(DOMPurify.removed, { 4009 attribute: element.getAttributeNode(name), 4010 from: element 4011 }); 4012 } catch (_) { 4013 arrayPush(DOMPurify.removed, { 4014 attribute: null, 4015 from: element 4016 }); 4017 } 4018 element.removeAttribute(name); 4019 // We void attribute values for unremovable "is" attributes 4020 if (name === 'is') { 4021 if (RETURN_DOM || RETURN_DOM_FRAGMENT) { 4022 try { 4023 _forceRemove(element); 4024 } catch (_) {} 4025 } else { 4026 try { 4027 element.setAttribute(name, ''); 4028 } catch (_) {} 4029 } 4030 } 4031 }; 4032 /** 4033 * _initDocument 4034 * 4035 * @param dirty - a string of dirty markup 4036 * @return a DOM, filled with the dirty markup 4037 */ 4038 const _initDocument = function _initDocument(dirty) { 4039 /* Create a HTML document */ 4040 let doc = null; 4041 let leadingWhitespace = null; 4042 if (FORCE_BODY) { 4043 dirty = '<remove></remove>' + dirty; 4044 } else { 4045 /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */ 4046 const matches = stringMatch(dirty, /^[\r\n\t ]+/); 4047 leadingWhitespace = matches && matches[0]; 4048 } 4049 if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) { 4050 // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict) 4051 dirty = '<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>' + dirty + '</body></html>'; 4052 } 4053 const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty; 4054 /* 4055 * Use the DOMParser API by default, fallback later if needs be 4056 * DOMParser not work for svg when has multiple root element. 4057 */ 4058 if (NAMESPACE === HTML_NAMESPACE) { 4059 try { 4060 doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE); 4061 } catch (_) {} 4062 } 4063 /* Use createHTMLDocument in case DOMParser is not available */ 4064 if (!doc || !doc.documentElement) { 4065 doc = implementation.createDocument(NAMESPACE, 'template', null);
vendor: 4,359 bytes, lines 4066-4161
4066 try { 4067 doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload; 4068 } catch (_) { 4069 // Syntax error if dirtyPayload is invalid xml 4070 } 4071 } 4072 const body = doc.body || doc.documentElement; 4073 if (dirty && leadingWhitespace) { 4074 body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null); 4075 } 4076 /* Work on whole document or just its body */ 4077 if (NAMESPACE === HTML_NAMESPACE) { 4078 return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0]; 4079 } 4080 return WHOLE_DOCUMENT ? doc.documentElement : body; 4081 }; 4082 /** 4083 * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. 4084 * 4085 * @param root The root element or node to start traversing on. 4086 * @return The created NodeIterator 4087 */ 4088 const _createNodeIterator = function _createNodeIterator(root) { 4089 return createNodeIterator.call(root.ownerDocument || root, root, 4090 // eslint-disable-next-line no-bitwise 4091 NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null); 4092 }; 4093 /** 4094 * _isClobbered 4095 * 4096 * @param element element to check for clobbering attacks 4097 * @return true if clobbered, false if safe 4098 */ 4099 const _isClobbered = function _isClobbered(element) { 4100 return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function'); 4101 }; 4102 /** 4103 * Checks whether the given object is a DOM node. 4104 * 4105 * @param value object to check whether it's a DOM node 4106 * @return true is object is a DOM node 4107 */ 4108 const _isNode = function _isNode(value) { 4109 return typeof Node === 'function' && value instanceof Node; 4110 }; 4111 function _executeHooks(hooks, currentNode, data) { 4112 arrayForEach(hooks, hook => { 4113 hook.call(DOMPurify, currentNode, data, CONFIG); 4114 }); 4115 } 4116 /** 4117 * _sanitizeElements 4118 * 4119 * @protect nodeName 4120 * @protect textContent 4121 * @protect removeChild 4122 * @param currentNode to check for permission to exist 4123 * @return true if node was killed, false if left alive 4124 */ 4125 const _sanitizeElements = function _sanitizeElements(currentNode) { 4126 let content = null; 4127 /* Execute a hook if present */ 4128 _executeHooks(hooks.beforeSanitizeElements, currentNode, null); 4129 /* Check if element is clobbered or can clobber */ 4130 if (_isClobbered(currentNode)) { 4131 _forceRemove(currentNode); 4132 return true; 4133 } 4134 /* Now let's check the element's type and name */ 4135 const tagName = transformCaseFunc(currentNode.nodeName); 4136 /* Execute a hook if present */ 4137 _executeHooks(hooks.uponSanitizeElement, currentNode, { 4138 tagName, 4139 allowedTags: ALLOWED_TAGS 4140 }); 4141 /* Detect mXSS attempts abusing namespace confusion */ 4142 if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\w!]/g, currentNode.textContent)) { 4143 _forceRemove(currentNode); 4144 return true; 4145 } 4146 /* Remove any occurrence of processing instructions */ 4147 if (currentNode.nodeType === NODE_TYPE.progressingInstruction) { 4148 _forceRemove(currentNode); 4149 return true; 4150 } 4151 /* Remove any kind of possibly harmful comments */ 4152 if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\w]/g, currentNode.data)) { 4153 _forceRemove(currentNode); 4154 return true; 4155 } 4156 /* Remove element if anything forbids its presence */ 4157 if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) { 4158 /* Check if we have a custom element to handle */ 4159 if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) { 4160 if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) { 4161 return false;
vendor: 9,812 bytes, lines 4162-4365
4162 } 4163 if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) { 4164 return false; 4165 } 4166 } 4167 /* Keep content except for bad-listed elements */ 4168 if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) { 4169 const parentNode = getParentNode(currentNode) || currentNode.parentNode; 4170 const childNodes = getChildNodes(currentNode) || currentNode.childNodes; 4171 if (childNodes && parentNode) { 4172 const childCount = childNodes.length; 4173 for (let i = childCount - 1; i >= 0; --i) { 4174 const childClone = cloneNode(childNodes[i], true); 4175 childClone.__removalCount = (currentNode.__removalCount || 0) + 1; 4176 parentNode.insertBefore(childClone, getNextSibling(currentNode)); 4177 } 4178 } 4179 } 4180 _forceRemove(currentNode); 4181 return true; 4182 } 4183 /* Check whether element has a valid namespace */ 4184 if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) { 4185 _forceRemove(currentNode); 4186 return true; 4187 } 4188 /* Make sure that older browsers don't get fallback-tag mXSS */ 4189 if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\/no(script|embed|frames)/i, currentNode.innerHTML)) { 4190 _forceRemove(currentNode); 4191 return true; 4192 } 4193 /* Sanitize element content to be template-safe */ 4194 if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { 4195 /* Get the element's text content */ 4196 content = currentNode.textContent; 4197 arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { 4198 content = stringReplace(content, expr, ' '); 4199 }); 4200 if (currentNode.textContent !== content) { 4201 arrayPush(DOMPurify.removed, { 4202 element: currentNode.cloneNode() 4203 }); 4204 currentNode.textContent = content; 4205 } 4206 } 4207 /* Execute a hook if present */ 4208 _executeHooks(hooks.afterSanitizeElements, currentNode, null); 4209 return false; 4210 }; 4211 /** 4212 * _isValidAttribute 4213 * 4214 * @param lcTag Lowercase tag name of containing element. 4215 * @param lcName Lowercase attribute name. 4216 * @param value Attribute value. 4217 * @return Returns true if `value` is valid, otherwise false. 4218 */ 4219 // eslint-disable-next-line complexity 4220 const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) { 4221 /* Make sure attribute cannot clobber */ 4222 if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) { 4223 return false; 4224 } 4225 /* Allow valid data-* attributes: At least one character after "-" 4226 (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes) 4227 XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804) 4228 We don't need to check the value; it's always URI safe. */ 4229 if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) { 4230 if ( 4231 // First condition does a very basic check if a) it's basically a valid custom element tagname AND 4232 // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck 4233 // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck 4234 _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) || 4235 // Alternative, second condition checks if it's an `is`-attribute, AND 4236 // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck 4237 lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else { 4238 return false; 4239 } 4240 /* Check value is safe. First, is attr inert? If so, is safe */ 4241 } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) { 4242 return false; 4243 } else ; 4244 return true; 4245 }; 4246 /** 4247 * _isBasicCustomElement 4248 * checks if at least one dash is included in tagName, and it's not the first char 4249 * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name 4250 * 4251 * @param tagName name of the tag of the node to sanitize 4252 * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false. 4253 */ 4254 const _isBasicCustomElement = function _isBasicCustomElement(tagName) { 4255 return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT); 4256 }; 4257 /** 4258 * _sanitizeAttributes 4259 * 4260 * @protect attributes 4261 * @protect nodeName 4262 * @protect removeAttribute 4263 * @protect setAttribute 4264 * 4265 * @param currentNode to sanitize 4266 */ 4267 const _sanitizeAttributes = function _sanitizeAttributes(currentNode) { 4268 /* Execute a hook if present */ 4269 _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null); 4270 const { 4271 attributes 4272 } = currentNode; 4273 /* Check if we have attributes; if not we might have a text node */ 4274 if (!attributes || _isClobbered(currentNode)) { 4275 return; 4276 } 4277 const hookEvent = { 4278 attrName: '', 4279 attrValue: '', 4280 keepAttr: true, 4281 allowedAttributes: ALLOWED_ATTR, 4282 forceKeepAttr: undefined 4283 }; 4284 let l = attributes.length; 4285 /* Go backwards over all attributes; safely remove bad ones */ 4286 while (l--) { 4287 const attr = attributes[l]; 4288 const { 4289 name, 4290 namespaceURI, 4291 value: attrValue 4292 } = attr; 4293 const lcName = transformCaseFunc(name); 4294 const initValue = attrValue; 4295 let value = name === 'value' ? initValue : stringTrim(initValue); 4296 /* Execute a hook if present */ 4297 hookEvent.attrName = lcName; 4298 hookEvent.attrValue = value; 4299 hookEvent.keepAttr = true; 4300 hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set 4301 _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent); 4302 value = hookEvent.attrValue; 4303 /* Full DOM Clobbering protection via namespace isolation, 4304 * Prefix id and name attributes with `user-content-` 4305 */ 4306 if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) { 4307 // Remove the attribute with this value 4308 _removeAttribute(name, currentNode); 4309 // Prefix the value and later re-create the attribute with the sanitized value 4310 value = SANITIZE_NAMED_PROPS_PREFIX + value; 4311 } 4312 /* Work around a security issue with comments inside attributes */ 4313 if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\/(style|title|textarea)/i, value)) { 4314 _removeAttribute(name, currentNode); 4315 continue; 4316 } 4317 /* Make sure we cannot easily use animated hrefs, even if animations are allowed */ 4318 if (lcName === 'attributename' && stringMatch(value, 'href')) { 4319 _removeAttribute(name, currentNode); 4320 continue; 4321 } 4322 /* Did the hooks approve of the attribute? */ 4323 if (hookEvent.forceKeepAttr) { 4324 continue; 4325 } 4326 /* Did the hooks approve of the attribute? */ 4327 if (!hookEvent.keepAttr) { 4328 _removeAttribute(name, currentNode); 4329 continue; 4330 } 4331 /* Work around a security issue in jQuery 3.0 */ 4332 if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\/>/i, value)) { 4333 _removeAttribute(name, currentNode); 4334 continue; 4335 } 4336 /* Sanitize attribute content to be template-safe */ 4337 if (SAFE_FOR_TEMPLATES) { 4338 arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { 4339 value = stringReplace(value, expr, ' '); 4340 }); 4341 } 4342 /* Is `value` valid for this attribute? */ 4343 const lcTag = transformCaseFunc(currentNode.nodeName); 4344 if (!_isValidAttribute(lcTag, lcName, value)) { 4345 _removeAttribute(name, currentNode); 4346 continue; 4347 } 4348 /* Handle attributes that require Trusted Types */ 4349 if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') { 4350 if (namespaceURI) ; else { 4351 switch (trustedTypes.getAttributeType(lcTag, lcName)) { 4352 case 'TrustedHTML': 4353 { 4354 value = trustedTypesPolicy.createHTML(value); 4355 break; 4356 } 4357 case 'TrustedScriptURL': 4358 { 4359 value = trustedTypesPolicy.createScriptURL(value); 4360 break; 4361 } 4362 } 4363 } 4364 } 4365 /* Handle invalid data-* attribute set by try-catching it */
vendor: 8,193 bytes, lines 4366-4584
4366 if (value !== initValue) { 4367 try { 4368 if (namespaceURI) { 4369 currentNode.setAttributeNS(namespaceURI, name, value); 4370 } else { 4371 /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. "x-schema". */ 4372 currentNode.setAttribute(name, value); 4373 } 4374 if (_isClobbered(currentNode)) { 4375 _forceRemove(currentNode); 4376 } else { 4377 arrayPop(DOMPurify.removed); 4378 } 4379 } catch (_) { 4380 _removeAttribute(name, currentNode); 4381 } 4382 } 4383 } 4384 /* Execute a hook if present */ 4385 _executeHooks(hooks.afterSanitizeAttributes, currentNode, null); 4386 }; 4387 /** 4388 * _sanitizeShadowDOM 4389 * 4390 * @param fragment to iterate over recursively 4391 */ 4392 const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) { 4393 let shadowNode = null; 4394 const shadowIterator = _createNodeIterator(fragment); 4395 /* Execute a hook if present */ 4396 _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null); 4397 while (shadowNode = shadowIterator.nextNode()) { 4398 /* Execute a hook if present */ 4399 _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null); 4400 /* Sanitize tags and elements */ 4401 _sanitizeElements(shadowNode); 4402 /* Check attributes next */ 4403 _sanitizeAttributes(shadowNode); 4404 /* Deep shadow DOM detected */ 4405 if (shadowNode.content instanceof DocumentFragment) { 4406 _sanitizeShadowDOM(shadowNode.content); 4407 } 4408 } 4409 /* Execute a hook if present */ 4410 _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null); 4411 }; 4412 // eslint-disable-next-line complexity 4413 DOMPurify.sanitize = function (dirty) { 4414 let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 4415 let body = null; 4416 let importedNode = null; 4417 let currentNode = null; 4418 let returnNode = null; 4419 /* Make sure we have a string to sanitize. 4420 DO NOT return early, as this will return the wrong type if 4421 the user has requested a DOM object rather than a string */ 4422 IS_EMPTY_INPUT = !dirty; 4423 if (IS_EMPTY_INPUT) { 4424 dirty = '<!-->'; 4425 } 4426 /* Stringify, in case dirty is an object */ 4427 if (typeof dirty !== 'string' && !_isNode(dirty)) { 4428 if (typeof dirty.toString === 'function') { 4429 dirty = dirty.toString(); 4430 if (typeof dirty !== 'string') { 4431 throw typeErrorCreate('dirty is not a string, aborting'); 4432 } 4433 } else { 4434 throw typeErrorCreate('toString is not a function'); 4435 } 4436 } 4437 /* Return dirty HTML if DOMPurify cannot run */ 4438 if (!DOMPurify.isSupported) { 4439 return dirty; 4440 } 4441 /* Assign config vars */ 4442 if (!SET_CONFIG) { 4443 _parseConfig(cfg); 4444 } 4445 /* Clean up removed elements */ 4446 DOMPurify.removed = []; 4447 /* Check if dirty is correctly typed for IN_PLACE */ 4448 if (typeof dirty === 'string') { 4449 IN_PLACE = false; 4450 } 4451 if (IN_PLACE) { 4452 /* Do some early pre-sanitization to avoid unsafe root nodes */ 4453 if (dirty.nodeName) { 4454 const tagName = transformCaseFunc(dirty.nodeName); 4455 if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) { 4456 throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place'); 4457 } 4458 } 4459 } else if (dirty instanceof Node) { 4460 /* If dirty is a DOM element, append to an empty document to avoid 4461 elements being stripped by the parser */ 4462 body = _initDocument('<!---->'); 4463 importedNode = body.ownerDocument.importNode(dirty, true); 4464 if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') { 4465 /* Node is already a body, use as is */ 4466 body = importedNode; 4467 } else if (importedNode.nodeName === 'HTML') { 4468 body = importedNode; 4469 } else { 4470 // eslint-disable-next-line unicorn/prefer-dom-node-append 4471 body.appendChild(importedNode); 4472 } 4473 } else { 4474 /* Exit directly if we have nothing to do */ 4475 if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT && 4476 // eslint-disable-next-line unicorn/prefer-includes 4477 dirty.indexOf('<') === -1) { 4478 return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty; 4479 } 4480 /* Initialize the document to work on */ 4481 body = _initDocument(dirty); 4482 /* Check we have a DOM node from the data */ 4483 if (!body) { 4484 return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : ''; 4485 } 4486 } 4487 /* Remove first element node (ours) if FORCE_BODY is set */ 4488 if (body && FORCE_BODY) { 4489 _forceRemove(body.firstChild); 4490 } 4491 /* Get node iterator */ 4492 const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body); 4493 /* Now start iterating over the created document */ 4494 while (currentNode = nodeIterator.nextNode()) { 4495 /* Sanitize tags and elements */ 4496 _sanitizeElements(currentNode); 4497 /* Check attributes next */ 4498 _sanitizeAttributes(currentNode); 4499 /* Shadow DOM detected, sanitize it */ 4500 if (currentNode.content instanceof DocumentFragment) { 4501 _sanitizeShadowDOM(currentNode.content); 4502 } 4503 } 4504 /* If we sanitized `dirty` in-place, return it. */ 4505 if (IN_PLACE) { 4506 return dirty; 4507 } 4508 /* Return sanitized string or DOM */ 4509 if (RETURN_DOM) { 4510 if (RETURN_DOM_FRAGMENT) { 4511 returnNode = createDocumentFragment.call(body.ownerDocument); 4512 while (body.firstChild) { 4513 // eslint-disable-next-line unicorn/prefer-dom-node-append 4514 returnNode.appendChild(body.firstChild); 4515 } 4516 } else { 4517 returnNode = body; 4518 } 4519 if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) { 4520 /* 4521 AdoptNode() is not used because internal state is not reset 4522 (e.g. the past names map of a HTMLFormElement), this is safe 4523 in theory but we would rather not risk another attack vector. 4524 The state that is cloned by importNode() is explicitly defined 4525 by the specs. 4526 */ 4527 returnNode = importNode.call(originalDocument, returnNode, true); 4528 } 4529 return returnNode; 4530 } 4531 let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; 4532 /* Serialize doctype if allowed */ 4533 if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) { 4534 serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\n' + serializedHTML; 4535 } 4536 /* Sanitize final string template-safe */ 4537 if (SAFE_FOR_TEMPLATES) { 4538 arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => { 4539 serializedHTML = stringReplace(serializedHTML, expr, ' '); 4540 }); 4541 } 4542 return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML; 4543 }; 4544 DOMPurify.setConfig = function () { 4545 let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 4546 _parseConfig(cfg); 4547 SET_CONFIG = true; 4548 }; 4549 DOMPurify.clearConfig = function () { 4550 CONFIG = null; 4551 SET_CONFIG = false; 4552 }; 4553 DOMPurify.isValidAttribute = function (tag, attr, value) { 4554 /* Initialize shared config vars if necessary. */ 4555 if (!CONFIG) { 4556 _parseConfig({}); 4557 } 4558 const lcTag = transformCaseFunc(tag); 4559 const lcName = transformCaseFunc(attr); 4560 return _isValidAttribute(lcTag, lcName, value); 4561 }; 4562 DOMPurify.addHook = function (entryPoint, hookFunction) { 4563 if (typeof hookFunction !== 'function') { 4564 return; 4565 } 4566 arrayPush(hooks[entryPoint], hookFunction); 4567 }; 4568 DOMPurify.removeHook = function (entryPoint, hookFunction) { 4569 if (hookFunction !== undefined) { 4570 const index = arrayLastIndexOf(hooks[entryPoint], hookFunction); 4571 return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0]; 4572 } 4573 return arrayPop(hooks[entryPoint]); 4574 }; 4575 DOMPurify.removeHooks = function (entryPoint) { 4576 hooks[entryPoint] = []; 4577 }; 4578 DOMPurify.removeAllHooks = function () { 4579 hooks = _createHooksMap(); 4580 }; 4581 return DOMPurify; 4582} 4583var purify = createDOMPurify(); 4584
4585/** 4586 * Copyright (c) Meta Platforms, Inc. and affiliates. 4587 * 4588 * This source code is licensed under the MIT license found in the 4589 * LICENSE file in the root directory of this source tree. 4590 * 4591 */ 4592 4593function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);n.search=r.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`);}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,r=n&&"documentMode"in document?document.documentMode:null,i=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),o=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s$1=!(!n||!("InputEvent"in window)||r)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),c=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,a=n&&/Android/.test(navigator.userAgent),u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&a&&u,d$1=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&i&&!u;function h$1(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}const g$1=0,_$2=1,p=2,T$3=128,b$4=1,w$4=2,E$4=3,O$2=4,M$5=5,A$3=6,P$3=l||c||d$1?" ":"â",D$4="\n\n",F$5=o?" ":P$3,L$3="Ö-ß¿ï¬-﷽ﹰ-ﻼ",I$4="A-Za-zÃ-ÃÃ-öø-ʸÌ-Öà -á¿¿ââ°-ï¬ï¸-﹯﻽-ï¿¿",K$5=new RegExp("^[^"+I$4+"]*["+L$3+"]"),z$5=new RegExp("^[^"+L$3+"]*["+I$4+"]"),R$6={bold:1,capitalize:1024,code:16,highlight:T$3,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},B$4={directionless:1,unmergeable:2},W$7={center:2,end:6,justify:4,left:1,right:3,start:5},J$5={[w$4]:"center",[A$3]:"end",[O$2]:"justify",[b$4]:"left",[E$4]:"right",[M$5]:"start"},j$4={normal:0,segmented:2,token:1},$$4={[g$1]:"normal",[p]:"segmented",[_$2]:"token"},V$6="$config";function Y$4(t,e,n,r,i,o){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&(Si(s)&&Y$4(s,t,n,r,i,o),n.has(t)||o.delete(t),i.push(t)),s=s.getNextSibling();}}let q$5=false,H$3=0;function G$4(t){H$3=t.timeStamp;}function X$4(t,e,n){const r="BR"===t.nodeName,i=e.__lexicalLineBreak;return i&&(t===i||r&&t.previousSibling===i)||r&&void 0!==So(t,n)}function Q$5(t,e,n){const r=ps(ss(n));let i=null,o=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,o=r.focusOffset);const s=t.nodeValue;null!==s&&Fo(e,s,i,o,false);}function Z$4(t,e,n){if(yr(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return false}return co(e)&&n.isAttached()}function tt$4(t,e,n,r){for(let i=t;i&&!Fs(i);i=Zo(i)){const t=So(i,e);if(void 0!==t){const e=xo(t,n);if(e)return Ti(e)||!Cs(i)?void 0:[i,e]}else if(i===r)return [r,bo(n)]}}function et$4(t,e,n){q$5=true;const r=performance.now()-H$3>100;try{yi(t,()=>{const i=Lr()||function(t){return t.getEditorState().read(()=>{const t=Lr();return null!==t?t.clone():null})}(t),s=new Map,l=t.getRootElement(),c=t._editorState,a=t._blockCursorElement;let u=!1,f="";for(let n=0;n<e.length;n++){const d=e[n],h=d.type,g=d.target,_=tt$4(g,t,c,l);if(!_)continue;const[p,y]=_;if("characterData"===h)r&&lr(y)&&co(g)&&Z$4(i,g,y)&&Q$5(g,y,t);else if("childList"===h){u=!0;const e=d.addedNodes;for(let n=0;n<e.length;n++){const r=e[n],i=Co(r),s=r.parentNode;if(null!=s&&r!==a&&null===i&&!X$4(r,s,t)){if(o){const t=(Cs(r)?r.innerText:null)||r.nodeValue;t&&(f+=t);}s.removeChild(r);}}const n=d.removedNodes,r=n.length;if(r>0){let e=0;for(let i=0;i<r;i++){const r=n[i];(X$4(r,g,t)||a===r)&&(g.appendChild(r),e++);}r!==e&&s.set(p,y);}}}if(s.size>0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const d=n.takeRecords();if(d.length>0){for(let e=0;e<d.length;e++){const n=d[e],r=n.addedNodes,i=n.target;for(let e=0;e<r.length;e++){const n=r[e],o=n.parentNode;null==o||"BR"!==n.nodeName||X$4(n,i,t)||o.removeChild(n);}}n.takeRecords();}null!==i&&(u&&wo(i),o&&Ho(t)&&i.insertRawText(f));});}finally{q$5=false;}}function nt$4(t){const e=t._observer;if(null!==e){et$4(t,e.takeRecords(),e);}}function rt$3(t){!function(t){0===H$3&&ss(t).addEventListener("textInput",G$4,true);}(t),t._observer=new MutationObserver((e,n)=>{et$4(t,e,n);});}let it$4 = class it{key;parse;unparse;isEqual;defaultValue;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||gt$4).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0);}};function ot$5(t,e){return new it$4(t,e)}function st$4(t,e,n="latest"){const r=("latest"===n?t.getLatest():t).__state;return r?r.getValue(e):e.defaultValue}function ct$5(t,e,n){let r;if(ei(),"function"==typeof n){const i=t.getLatest(),o=st$4(i,e);if(r=n(o),e.isEqual(o,r))return i}else r=n;const i=t.getWritable();return ft$3(i).updateFromKnown(e,r),i}function at$3(t){const e=new Map,n=new Set;for(let r="function"==typeof t?t:t.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:t}=Is(r);if(t&&t.stateConfigs)for(const r of t.stateConfigs){let t;"stateConfig"in r?(t=r.stateConfig,r.flat&&n.add(t.key)):t=r,e.set(t.key,t);}}return {flatKeys:n,sharedConfigMap:e}}let ut$4 = class ut{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,r=new Map,i=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(t,e,n){let r=n.size;if(e)for(const i in e){const e=t.get(i);e&&n.has(e)||r++;}return r}(o,n,r);this.size=s;}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n);}return n}getInternalState(){return [this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return ht$4(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,r=new Map(this.knownState);return new ut(t,e,function(t,e,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=t.get(i);n?e.has(n)||e.set(n,n.parse(o)):(r=r||{},r[i]=o);}return r}(e.sharedConfigMap,r,n),r,this.size)}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:r,unknownState:i}=this;r.has(t)||i&&n in i||(i&&(delete i[n],this.unknownState=ht$4(i)),this.size++),r.set(t,e);}updateFromUnknown(t,e){const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e);}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n);}};function ft$3(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new ut$4(e,dt$4(e));return e.__state=n,n}function dt$4(t){return t.__state?t.__state.sharedNodeState:Gi(bs(),t.getType()).sharedNodeState}function ht$4(t){if(t)for(const e in t)return t}function gt$4(t){return t}function _t$5(t,e,n){for(const[r,i]of e.knownState){if(t.has(r.key))continue;t.add(r.key);const e=n?n.getValue(r):r.defaultValue;
4593if(e!==i&&!r.isEqual(e,i))return true}return false}function pt$4(t,e,n){const{unknownState:r}=e,i=n?n.unknownState:void 0;if(r)for(const[e,n]of Object.entries(r)){if(t.has(e))continue;t.add(e);if(n!==(i?i[e]:void 0))return true}return false}function yt$4(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function mt$2(t,e){const n=t.__mode,r=t.__format,i=t.__style,o=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return (null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return true;if(t&&e&&t.size!==e.size)return false;const n=new Set;return !(t&&_t$5(n,t,e)||e&&_t$5(n,e,t)||t&&pt$4(n,t,e)||e&&pt$4(n,e,t))}(c,a))}function xt$6(t,e){const n=t.mergeWithSibling(e),r=ii()._normalizedNodes;return r.add(t.__key),r.add(e.__key),n}function Ct$6(t){let e,n,r=t;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(e=r.getPreviousSibling())&&lr(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(mt$2(e,r)){r=xt$6(e,r);break}break}e.remove();}for(;null!==(n=r.getNextSibling())&&lr(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(mt$2(r,n)){r=xt$6(r,n);break}break}n.remove();}}else r.remove();}function St$6(t){return vt$4(t.anchor),vt$4(t.focus),t}function vt$4(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let r,i;if(n===e.getChildrenSize()?(r=e.getChildAtIndex(n-1),i=true):(r=e.getChildAtIndex(n),i=false),lr(r)){t.set(r.__key,i?r.getTextContentSize():0,"text",true);break}if(!Si(r))break;t.set(r.__key,i?r.getChildrenSize():0,"element",true);}}let kt$7,Tt$5,Nt$6,bt$6,wt$6,Et$5,Ot$5,Mt$4,At$6,Pt$5,Dt$4="",Ft$3=null,Lt$5="",It$4="",Kt$4=false,zt$3=false;function Rt$3(t,e){const n=Ot$5.get(t);if(null!==e){const n=ne$1(t);n.parentNode===e&&e.removeChild(n);}if(Mt$4.has(t)||Tt$5._keyToDOMMap.delete(t),Si(n)){const t=Xt$1(n,Ot$5);Bt$4(t,0,t.length-1,null);} void 0!==n&&Uo(Pt$5,Nt$6,bt$6,n,"destroyed");}function Bt$4(t,e,n,r){let i=e;for(;i<=n;++i){const e=t[i];void 0!==e&&Rt$3(e,r);}}function Wt$3(t,e){t.setProperty("text-align",e);}const Jt$2="40px";function jt$4(t,e){const n=kt$7.theme.indent;if("string"==typeof n){const r=t.classList.contains(n);e>0&&!r?t.classList.add(n):e<1&&r&&t.classList.remove(n);}const r=getComputedStyle(t).getPropertyValue("--lexical-indent-base-value")||Jt$2;t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * ${r})`);}function $t$4(t,e){const n=t.style;0===e?Wt$3(n,""):1===e?Wt$3(n,"left"):2===e?Wt$3(n,"center"):3===e?Wt$3(n,"right"):4===e?Wt$3(n,"justify"):5===e?Wt$3(n,"start"):6===e&&Wt$3(n,"end");}function Ut$3(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(bi(t))return null;const n=t.getParentOrThrow();return bi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir");}function Vt$1(e,n){const r=Mt$4.get(e);void 0===r&&t(60);const i=r.createDOM(kt$7,Tt$5);if(function(t,e,n){const r=n._keyToDOMMap;((function(t,e,n){const r=`__lexicalKey_${e._key}`;t[r]=n;}))(e,n,t),r.set(t,e);}(e,i,Tt$5),lr(r)?i.setAttribute("data-lexical-text","true"):Ti(r)&&i.setAttribute("data-lexical-decorator","true"),Si(r)){const t=r.__indent,e=r.__size;if(Ut$3(i,r),0!==t&&jt$4(i,t),0!==e){const t=e-1;Yt$1(Xt$1(r,Mt$4),r,0,t,r.getDOMSlot(i));}const n=r.__format;0!==n&&$t$4(i,n),r.isInline()||Ht$2(null,r,i),Xo(r)&&(Dt$4+=D$4,It$4+=D$4);}else {const t=r.getTextContent();if(Ti(r)){const t=r.decorate(Tt$5,kt$7);null!==t&&Zt$1(e,t),i.contentEditable="false";}Dt$4+=t,It$4+=t;}return null!==n&&n.insertChild(i),Uo(Pt$5,Nt$6,bt$6,r,"created"),i}function Yt$1(t,e,n,r,i){const o=Dt$4;Dt$4="";let s=n;for(;s<=r;++s){Vt$1(t[s],i);const e=Mt$4.get(t[s]);null!==e&&lr(e)&&(null===Ft$3&&(Ft$3=e.getFormat()),""===Lt$5&&(Lt$5=e.getStyle()));}Xo(e)&&(Dt$4+=D$4);i.element.__lexicalTextContent=Dt$4,Dt$4=o+Dt$4;}function qt$1(t,e){if(t){const n=t.__last;if(n){const t=e.get(n);if(t)return jn(t)?"line-break":Ti(t)&&t.isInline()?"decorator":null}return "empty"}return null}function Ht$2(t,e,n){const r=qt$1(t,Ot$5),i=qt$1(e,Mt$4);r!==i&&e.getDOMSlot(n).setManagedLineBreak(i);}function Gt$2(e,n,r){var i;Ft$3=null,Lt$5="",function(e,n,r){const i=Dt$4,o=e.__size,s=n.__size;Dt$4="";const l=r.element;if(1===o&&1===s){const t=e.__first,r=n.__first;if(t===r)Qt$1(t,l);else {const e=ne$1(t),n=Vt$1(r,null);try{l.replaceChild(n,e);}catch(i){if("object"==typeof i&&null!=i){const o=`${i.toString()} Parent: ${l.tagName}, new child: {tag: ${n.tagName} key: ${r}}, old child: {tag: ${e.tagName}, key: ${t}}.`;throw new Error(o)}throw i}Rt$3(t,null);}const i=Mt$4.get(r);lr(i)&&(null===Ft$3&&(Ft$3=i.getFormat()),""===Lt$5&&(Lt$5=i.getStyle()));}else {const i=Xt$1(e,Ot$5),c=Xt$1(n,Mt$4);if(i.length!==o&&t(227),c.length!==s&&t(228),0===o)0!==s&&Yt$1(c,n,0,s-1,r);
4593else if(0===s){if(0!==o){const t=null==r.after&&null==r.before&&null==r.element.__lexicalLineBreak;Bt$4(i,0,o-1,t?null:l),t&&(l.textContent="");}}else !function(t,e,n,r,i,o){const s=r-1,l=i-1;let c,a,u=o.getFirstChild(),f=0,d=0;for(;f<=s&&d<=l;){const t=e[f],r=n[d];if(t===r)u=te$1(Qt$1(r,o.element)),f++,d++;else { void 0===c&&(c=new Set(e)),void 0===a&&(a=new Set(n));const i=a.has(t),s=c.has(r);if(i)if(s){const t=Qo(Tt$5,r);t===u?u=te$1(Qt$1(r,o.element)):(o.withBefore(u).insertChild(t),Qt$1(r,o.element)),f++,d++;}else Vt$1(r,o.withBefore(u)),d++;else u=te$1(ne$1(t)),Rt$3(t,o.element),f++;}const i=Mt$4.get(r);null!==i&&lr(i)&&(null===Ft$3&&(Ft$3=i.getFormat()),""===Lt$5&&(Lt$5=i.getStyle()));}const h=f>s,g=d>l;if(h&&!g){const e=n[l+1],r=void 0===e?null:Tt$5.getElementByKey(e);Yt$1(n,t,d,l,o.withBefore(r));}else g&&!h&&Bt$4(e,f,s,o.element);}(n,i,c,o,s,r);}Xo(n)&&(Dt$4+=D$4);l.__lexicalTextContent=Dt$4,Dt$4=i+Dt$4;}(e,n,n.getDOMSlot(r)),i=n,null==Ft$3||Ft$3===i.__textFormat||zt$3||i.setTextFormat(Ft$3),function(t){""===Lt$5||Lt$5===t.__textStyle||zt$3||t.setTextStyle(Lt$5);}(n);}function Xt$1(e,n){const r=[];let i=e.__first;for(;null!==i;){const e=n.get(i);void 0===e&&t(101),r.push(i),i=e.__next;}return r}function Qt$1(e,n){const r=Ot$5.get(e);let i=Mt$4.get(e);void 0!==r&&void 0!==i||t(61);const o=Kt$4||Et$5.has(e)||wt$6.has(e),s=Qo(Tt$5,e);if(r===i&&!o){if(Si(r)){const t=s.__lexicalTextContent;void 0!==t&&(Dt$4+=t,It$4+=t);}else {const t=r.getTextContent();It$4+=t,Dt$4+=t;}return s}if(r!==i&&o&&Uo(Pt$5,Nt$6,bt$6,i,"updated"),i.updateDOM(r,s,kt$7)){const r=Vt$1(e,null);return null===n&&t(62),n.replaceChild(r,s),Rt$3(e,null),r}if(Si(r)&&Si(i)){const t=i.__indent;(Kt$4||t!==r.__indent)&&jt$4(s,t);const e=i.__format;if((Kt$4||e!==r.__format)&&$t$4(s,e),o&&(Gt$2(r,i,s),bi(i)||i.isInline()||Ht$2(r,i,s)),Xo(i)&&(Dt$4+=D$4,It$4+=D$4),(Kt$4||i.__dir!==r.__dir)&&(Ut$3(s,i),bi(i)&&!Kt$4))for(const t of i.getChildren())if(Si(t)){Ut$3(Qo(Tt$5,t.getKey()),t);}}else {const t=i.getTextContent();if(Ti(i)){const t=i.decorate(Tt$5,kt$7);null!==t&&Zt$1(e,t);}Dt$4+=t,It$4+=t;}if(!zt$3&&bi(i)&&i.__cachedText!==It$4){const t=i.getWritable();t.__cachedText=It$4,i=t;}return s}function Zt$1(t,e){let n=Tt$5._pendingDecorators;const r=Tt$5._decorators;if(null===n){if(r[t]===e)return;n=ko(Tt$5);}n[t]=e;}function te$1(t){let e=t.nextSibling;return null!==e&&e===Tt$5._blockCursorElement&&(e=e.nextSibling),e}function ee$1(t,e,n,r,i,o){Dt$4="",It$4="",Kt$4=2===r,Tt$5=n,kt$7=n._config,Nt$6=n._nodes,bt$6=Tt$5._listeners.mutation,wt$6=i,Et$5=o,Ot$5=t._nodeMap,Mt$4=e._nodeMap,zt$3=e._readOnly,At$6=new Map(n._keyToDOMMap);const s=new Map;return Pt$5=s,Qt$1("root",null),Tt$5=void 0,Nt$6=void 0,wt$6=void 0,Et$5=void 0,Ot$5=void 0,Mt$4=void 0,kt$7=void 0,At$6=void 0,Pt$5=void 0,s}function ne$1(e){const n=At$6.get(e);return void 0===n&&t(75,e),n}function re$1(t){return {type:t}}const ie$1=re$1("SELECTION_CHANGE_COMMAND"),oe$2=re$1("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),se$1=re$1("CLICK_COMMAND"),le$2=re$1("DELETE_CHARACTER_COMMAND"),ce$1=re$1("INSERT_LINE_BREAK_COMMAND"),ae$1=re$1("INSERT_PARAGRAPH_COMMAND"),ue$1=re$1("CONTROLLED_TEXT_INSERTION_COMMAND"),fe$1=re$1("PASTE_COMMAND"),de$1=re$1("REMOVE_TEXT_COMMAND"),he$1=re$1("DELETE_WORD_COMMAND"),ge$1=re$1("DELETE_LINE_COMMAND"),_e$1=re$1("FORMAT_TEXT_COMMAND"),pe$1=re$1("UNDO_COMMAND"),ye$1=re$1("REDO_COMMAND"),me$1=re$1("KEYDOWN_COMMAND"),xe$1=re$1("KEY_ARROW_RIGHT_COMMAND"),Ce$1=re$1("MOVE_TO_END"),Se$1=re$1("KEY_ARROW_LEFT_COMMAND"),ve$2=re$1("MOVE_TO_START"),ke$2=re$1("KEY_ARROW_UP_COMMAND"),Te$2=re$1("KEY_ARROW_DOWN_COMMAND"),Ne$2=re$1("KEY_ENTER_COMMAND"),be$1=re$1("KEY_SPACE_COMMAND"),we$1=re$1("KEY_BACKSPACE_COMMAND"),Ee$2=re$1("KEY_ESCAPE_COMMAND"),Oe$2=re$1("KEY_DELETE_COMMAND"),Me$2=re$1("KEY_TAB_COMMAND"),Ae$2=re$1("INSERT_TAB_COMMAND"),Pe$2=re$1("INDENT_CONTENT_COMMAND"),De$2=re$1("OUTDENT_CONTENT_COMMAND"),Fe$2=re$1("DROP_COMMAND"),Le$2=re$1("FORMAT_ELEMENT_COMMAND"),Ie$2=re$1("DRAGSTART_COMMAND"),Ke$2=re$1("DRAGOVER_COMMAND"),ze$2=re$1("DRAGEND_COMMAND"),Re$2=re$1("COPY_COMMAND"),Be$2=re$1("CUT_COMMAND"),We$2=re$1("SELECT_ALL_COMMAND"),Je$1=re$1("CLEAR_EDITOR_COMMAND"),je$2=re$1("CLEAR_HISTORY_COMMAND"),$e$2=re$1("CAN_REDO_COMMAND"),Ue$2=re$1("CAN_UNDO_COMMAND"),Ve$1=re$1("FOCUS_COMMAND"),Ye=re$1("BLUR_COMMAND"),qe$2=re$1("KEY_MODIFIER_COMMAND"),He$2=Object.freeze({}),Ge$2=[["keydown",function(t,e){if(Xe$1=t.timeStamp,Qe$1=t.key,e.isComposing())return;if(Go(e,me$1,t))return;if(null==t.key)return;if(cn$1&&Wo(t))return yi(e,()=>{mn$1(e,an$1);}),cn$1=false,void(an$1="");if(function(t){return zo(t,"ArrowRight",{shiftKey:"any"})}(t))Go(e,xe$1,t);else if(function(t){return zo(t,"ArrowRight",Ro)}(t))Go(e,Ce$1,t);else if(function(t){return zo(t,"ArrowLeft",{shiftKey:"any"})}(t))Go(e,Se$1,t);else if(function(t){return zo(t,"ArrowLeft",Ro)}(t))Go(e,ve$2,t);else if(function(t){return zo(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Go(e,ke$2,t);else if(function(t){return zo(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Go(e,Te$2,t);else if(function(t){return zo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:true})}(t))sn$1=true,Go(e,Ne$2,t);else if(function(t){return " "===t.key}(t))Go(e,be$1,t);else if(function(t){return i&&zo(t,"o",{ctrlKey:true})}(t))t.preventDefault(),sn$1=true,Go(e,ce$1,true);else if(function(t){return zo(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))sn$1=false,Go(e,Ne$2,t);else if(function(t){return zo(t,"Backspace",{shiftKey:"any"})||i&&zo(t,"h",{ctrlKey:true})}(t))Wo(t)?Go(e,we$1,t):(t.preventDefault(),Go(e,le$2,true));
4593else if(function(t){return "Escape"===t.key}(t))Go(e,Ee$2,t);else if(function(t){return zo(t,"Delete",{})||i&&zo(t,"d",{ctrlKey:true})}(t))!function(t){return "Delete"===t.key}(t)?(t.preventDefault(),Go(e,le$2,false)):Go(e,Oe$2,t);else if(function(t){return zo(t,"Backspace",Bo)}(t))t.preventDefault(),Go(e,he$1,true);else if(function(t){return zo(t,"Delete",Bo)}(t))t.preventDefault(),Go(e,he$1,false);else if(function(t){return i&&zo(t,"Backspace",{metaKey:true})}(t))t.preventDefault(),Go(e,ge$1,true);else if(function(t){return i&&(zo(t,"Delete",{metaKey:true})||zo(t,"k",{ctrlKey:true}))}(t))t.preventDefault(),Go(e,ge$1,false);else if(function(t){return zo(t,"b",Ro)}(t))t.preventDefault(),Go(e,_e$1,"bold");else if(function(t){return zo(t,"u",Ro)}(t))t.preventDefault(),Go(e,_e$1,"underline");else if(function(t){return zo(t,"i",Ro)}(t))t.preventDefault(),Go(e,_e$1,"italic");else if(function(t){return zo(t,"Tab",{shiftKey:"any"})}(t))Go(e,Me$2,t);else if(function(t){return zo(t,"z",Ro)}(t))t.preventDefault(),Go(e,pe$1,void 0);else if(function(t){if(i)return zo(t,"z",{metaKey:true,shiftKey:true});return zo(t,"y",{ctrlKey:true})||zo(t,"z",{ctrlKey:true,shiftKey:true})}(t))t.preventDefault(),Go(e,ye$1,void 0);else {const n=e._editorState._selection;null===n||yr(n)?Jo(t)&&(t.preventDefault(),Go(e,We$2,t)):!function(t){return zo(t,"c",Ro)}(t)?!function(t){return zo(t,"x",Ro)}(t)?Jo(t)&&(t.preventDefault(),Go(e,We$2,t)):(t.preventDefault(),Go(e,Be$2,t)):(t.preventDefault(),Go(e,Re$2,t));}(function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey})(t)&&Go(e,qe$2,t);}],["pointerdown",function(t,e){const n=t.target,r=t.pointerType;Ss(n)&&"touch"!==r&&"pen"!==r&&0===t.button&&yi(e,()=>{Zi(n)||(on$1=true);});}],["compositionstart",function(t,e){yi(e,()=>{const n=Lr();if(yr(n)&&!e.isComposing()){const r=n.anchor,i=n.anchor.getNode();yo(r.key),(t.timeStamp<Xe$1+30||"element"===r.type||!n.isCollapsed()||i.getFormat()!==n.format||lr(i)&&i.getStyle()!==n.style)&&Go(e,ue$1,F$5);}});}],["compositionend",function(t,e){o?ln$1=true:c||!l&&!d$1?yi(e,()=>{mn$1(e,t.data);}):(cn$1=true,an$1=t.data);}],["input",function(t,e){t.stopPropagation(),yi(e,()=>{if(Cs(t.target)&&Zi(t.target))return;const n=Lr(),r=t.data,i=yn$1(t);if(null!=r&&yr(n)&&dn$1(n,i,r,t.timeStamp,false)){ln$1&&(mn$1(e,r),ln$1=false);const i=n.anchor.getNode(),a=ps(ss(e));if(null===a)return;const u=n.isBackward(),f=u?n.anchor.offset:n.focus.offset,h=u?n.focus.offset:n.anchor.offset;s$1&&!n.isCollapsed()&&lr(i)&&null!==a.anchorNode&&i.getTextContent().slice(0,f)+r+i.getTextContent().slice(f+h)===Po(a.anchorNode)||Go(e,ue$1,r);const g=r.length;o&&g>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(n.anchor.offset-=g),l||c||d$1||!e.isComposing()||(Xe$1=0,yo(null));}else {Do(false,e,null!==r?r:void 0),ln$1&&(mn$1(e,r||void 0),ln$1=false);}!function(){ei();const t=ii();nt$4(t);}();},{event:t}),tn$1=null;}],["click",function(t,e){yi(e,()=>{const n=Lr(),r=ps(ss(e)),i=Ir();if(r)if(yr(n)){const e=n.anchor,o=e.getNode();if("element"===e.type&&0===e.offset&&n.isCollapsed()&&!bi(o)&&1===No().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=true;else if(3===t.detail&&!n.isCollapsed()){if(o!==n.focus.getNode()){const t=zs(o,t=>Si(t)&&!t.isInline());Si(t)&&t.select(0);}}}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=r.anchorNode;if(Cs(n)||co(n)){wo(Fr(i,r,e,t));}}Go(e,se$1,t);});}],["cut",He$2],["copy",He$2],["dragstart",He$2],["dragover",He$2],["dragend",He$2],["paste",He$2],["focus",He$2],["blur",He$2],["drop",He$2]];s$1&&Ge$2.push(["beforeinput",(e,n)=>function(e,n){const r=e.inputType,i=yn$1(e);if("deleteCompositionText"===r||o&&Ho(n))return;if("insertCompositionText"===r)return;yi(n,()=>{const o=Lr();if("deleteContentBackward"===r){if(null===o){const t=Ir();if(!yr(t))return;wo(t.clone());}if(yr(o)){const r=o.anchor.key===o.focus.key;if(s=e.timeStamp,"MediaLast"===Qe$1&&s<Xe$1+30&&n.isComposing()&&r){if(yo(null),Xe$1=0,setTimeout(()=>{yi(n,()=>{yo(null);});},30),yr(o)){const e=o.anchor.getNode();e.markDirty(),lr(e)||t(142),pn$1(o,e);}}else {yo(null),e.preventDefault();const t=o.anchor.getNode(),i=t.getTextContent(),s=t.canInsertTextAfter(),l=0===o.anchor.offset&&o.focus.offset===i.length;let c=f&&r&&!l&&s;if(c&&o.isCollapsed()&&(c=!Ti(qo(o.anchor,true))),!c){Go(n,le$2,true);const t=Lr();f&&yr(t)&&t.isCollapsed()&&(un$1=t,setTimeout(()=>un$1=null));}}return}}var s;if(!yr(o))return;const l=e.data;null!==tn$1&&Do(false,n,tn$1),o.dirty&&null===tn$1||!o.isCollapsed()||bi(o.anchor.getNode())||null===i||o.applyDOMRange(i),tn$1=null;const a=o.anchor,u=o.focus,d=a.getNode(),h=u.getNode();if("insertText"!==r&&"insertTranspose"!==r)switch(e.preventDefault(),r){case "insertFromYank":case "insertFromDrop":case "insertReplacementText":Go(n,ue$1,e);break;case "insertFromComposition":yo(null),Go(n,ue$1,e);break;case "insertLineBreak":yo(null),Go(n,ce$1,false);break;case "insertParagraph":yo(null),sn$1&&!c?(sn$1=false,Go(n,ce$1,false)):Go(n,ae$1,void 0);break;case "insertFromPaste":case "insertFromPasteAsQuotation":Go(n,fe$1,e);break;case "deleteByComposition":(function(t,e){return t!==e||Si(t)||Si(e)||!so(t)||!so(e)})(d,h)&&Go(n,de$1,e);break;case "deleteByDrag":case "deleteByCut":Go(n,de$1,e);break;case "deleteContent":Go(n,le$2,false);break;case "deleteWordBackward":Go(n,he$1,true);break;
4593case "deleteWordForward":Go(n,he$1,false);break;case "deleteHardLineBackward":case "deleteSoftLineBackward":Go(n,ge$1,true);break;case "deleteContentForward":case "deleteHardLineForward":case "deleteSoftLineForward":Go(n,ge$1,false);break;case "formatStrikeThrough":Go(n,_e$1,"strikethrough");break;case "formatBold":Go(n,_e$1,"bold");break;case "formatItalic":Go(n,_e$1,"italic");break;case "formatUnderline":Go(n,_e$1,"underline");break;case "historyUndo":Go(n,pe$1,void 0);break;case "historyRedo":Go(n,ye$1,void 0);}else {if("\n"===l)e.preventDefault(),Go(n,ce$1,false);else if(l===D$4)e.preventDefault(),Go(n,ae$1,void 0);else if(null==l&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),o.insertRawText(t);}else null!=l&&dn$1(o,i,l,e.timeStamp,true)?(e.preventDefault(),Go(n,ue$1,l)):tn$1=l;Ze$2=e.timeStamp;}});}(e,n)]);let Xe$1=0,Qe$1=null,Ze$2=0,tn$1=null;const en$1=new WeakMap,nn$1=new WeakMap;let rn$1=false,on$1=false,sn$1=false,ln$1=false,cn$1=false,an$1="",un$1=null,fn$1=[0,"",0,"root",0];function dn$1(t,e,n,r,i){const o=t.anchor,l=t.focus,c=o.getNode(),a=ii(),u=ps(ss(a)),f=null!==u?u.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==l.key||!lr(c)||(!i&&(!s$1||Ze$2<r+50)||c.isDirty()&&g<2||Oo(n))&&o.offset!==l.offset&&!c.isComposing()||lo(c)||c.isDirty()&&g>1||(i||!s$1)&&null!==h&&!c.isComposing()&&f!==uo(h)||null!==u&&null!==e&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||c.getFormat()!==t.format||c.getStyle()!==t.style||function(t,e){if(e.isSegmented())return true;if(!t.isCollapsed())return false;const n=t.anchor.offset,r=e.getParentOrThrow(),i=so(e);return 0===n?!e.canInsertTextBefore()||!r.canInsertTextBefore()&&!e.isComposing()||i||function(t){const e=t.getPreviousSibling();return (lr(e)||Si(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!r.canInsertTextAfter()&&!e.isComposing()||i)}(t,c)}function hn$1(t,e){return co(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function gn$1(e,n,r){const{anchorNode:i,anchorOffset:o,focusNode:s,focusOffset:l}=e;rn$1&&(rn$1=false,hn$1(i,o)&&hn$1(s,l)&&!un$1)||yi(n,()=>{if(!r)return void wo(null);if(!eo(n,i,s))return;let c=Lr();if(un$1&&yr(c)&&c.isCollapsed()){const t=c.anchor,e=un$1.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(c=un$1.clone(),wo(c));}if(un$1=null,yr(c)){const r=c.anchor,i=r.getNode();if(c.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(c.dirty=true);const o=ss(n).event,s=o?o.timeStamp:performance.now(),[l,a,u,f,d]=fn$1,h=No(),g=false===n.isComposing()&&""===h.getTextContent();if(s<d+200&&r.offset===u&&r.key===f)_n$1(c,l,a);else if("text"===r.type)lr(i)||t(141),pn$1(c,i);else if("element"===r.type&&!g){Si(i)||t(259);const e=r.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),r=e.getTextStyle();_n$1(t,n,r);}(c,e):_n$1(c,0,"");}}else {const t=r.key,e=c.focus.key,n=c.getNodes(),i=n.length,s=c.isBackward(),a=s?l:o,u=s?o:l,f=s?e:t,d=s?t:e;let h=2047,g=false;for(let t=0;t<i;t++){const e=n[t],r=e.getTextContentSize();if(lr(e)&&0!==r&&!(0===t&&e.__key===f&&a===r||t===i-1&&e.__key===d&&0===u)&&(g=true,h&=e.getFormat(),0===h))break}c.format=g?h:0;}}Go(n,ie$1,void 0);});}function _n$1(t,e,n){t.format===e&&t.style===n||(t.format=e,t.style=n,t.dirty=true);}function pn$1(t,e){_n$1(t,e.getFormat(),e.getStyle());}function yn$1(t){if(!t.getTargetRanges)return null;const e=t.getTargetRanges();return 0===e.length?null:e[0]}function mn$1(t,e){const n=t._compositionKey;if(yo(null),null!==n&&null!=e){if(""===e){const e=xo(n),r=uo(t.getElementByKey(n));return void(null!==r&&null!==r.nodeValue&&lr(e)&&Fo(e,r.nodeValue,null,null,true))}if("\n"===e[e.length-1]){const e=Lr();if(yr(e)){const n=e.focus;return e.anchor.set(n.key,n.offset,n.type),void Go(t,Ne$2,null)}}}Do(true,t,e);}function xn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const Cn$1=new Map;function Sn$1(t){const e=ys(t.target);if(null===e)return;const n=ro(e.anchorNode);
4593if(null===n)return;on$1&&(on$1=false,yi(n,()=>{const r=Ir(),i=e.anchorNode;if(Cs(i)||co(i)){wo(Fr(r,e,n,t));}}));const r=Mo(n),i=r[r.length-1],o=i._key,s=Cn$1.get(o),l=s||i;l!==n&&gn$1(e,l,false),gn$1(e,n,true),n!==i?Cn$1.set(o,n):s&&Cn$1.delete(o);}function vn(t){t._lexicalHandled=true;}function kn(t){return true===t._lexicalHandled}function Nn$1(e){const n=en$1.get(e);if(void 0===n)return void 0;const r=nn$1.get(n);if(void 0===r)return void 0;const i=r-1;i>=0||t(164),en$1.delete(e),nn$1.set(n,i),0===i&&n.removeEventListener("selectionchange",Sn$1);const o=io(e);no(o)?(!function(t){if(null!==t._parentEditor){const e=Mo(t),n=e[e.length-1]._key;Cn$1.get(n)===t&&Cn$1.delete(n);}else Cn$1.delete(t._key);}(o),e.__lexicalEditor=null):o&&t(198);const s=xn(e);for(let t=0;t<s.length;t++)s[t]();e.__lexicalEventHandles=[];}function bn(t,e,n){ei();const r=t.__key,i=t.getParent();if(null===i)return;const o=function(t){const e=Lr();if(!yr(e)||!Si(t))return e;const{anchor:n,focus:r}=e,i=n.getNode(),o=r.getNode();is(i,t)&&n.set(t.__key,0,"element");is(o,t)&&r.set(t.__key,0,"element");return e}(t);let s=false;if(yr(o)&&e){const e=o.anchor,n=o.focus;e.key===r&&(Rr(e,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true),n.key===r&&(Rr(n,t,i,t.getPreviousSibling(),t.getNextSibling()),s=true);}else xr(o)&&e&&t.isSelected()&&t.selectPrevious();if(yr(o)&&e&&!s){const e=t.getIndexWithinParent();_o(t),Kr(o,i,e,-1);}else _o(t);n||as(i)||i.canBeEmpty()||!i.isEmpty()||bn(i,e),e&&o&&bi(i)&&i.isEmpty()&&i.selectEnd();}function wn$1(t){return t}const En=Symbol.for("ephemeral");function On(t){return t[En]||false}class Mn{__type;__key;__parent;__prev;__next;__state;static getType(){const{ownNodeType:e}=Is(this);return void 0===e&&t(64,this.name),e}static clone(e){t(65,this.name);}$config(){return {}}config(t,e){const n=e.extends||Object.getPrototypeOf(this.constructor);return Object.assign(e,{extends:n,type:t}),{[t]:e}}afterCloneFrom(t){this.__key===t.__key?(this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state):t.__state&&(this.__state=t.__state.getWritable(this));}static importDOM;constructor(t){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",{configurable:true,enumerable:false,value:void 0,writable:true}),go(this,t);}getType(){return this.__type}isInline(){t(137,this.constructor.name);}isAttached(){let t=this.__key;for(;null!==t;){if("root"===t)return true;const e=xo(t);if(null===e)break;t=e.__parent;}return false}isSelected(t){const e=t||Lr();if(null==e)return false;const n=e.getNodes().some(t=>t.__key===this.__key);if(lr(this))return n;if(yr(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return false;const t=this.getParent();if(Ti(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return false}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return -1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling();}return -1}getParent(){const t=this.getLatest().__parent;return null===t?null:xo(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(as(n))return Si(e)||e===this&&Ti(e)||t(194),e;e=n;}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:xo(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:xo(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Si(this)?this:this.getParent(),n=Si(t)?t:t.getParent(),r=e&&n?ml(e,n):null;return r?r.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=ml(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===_l(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),false)))}isParentOf(t){const e=ml(this,t);return null!==e&&"ancestor"===e.type}getNodesBetween(e){const n=this.isBefore(e),r=[],i=new Set;let o=this;for(;null!==o;){const s=o.__key;if(i.has(s)||(i.add(s),r.push(o)),o===e)break;const l=Si(o)?n?o.getFirstChild():o.getLastChild():null;if(null!==l){o=l;continue}const c=n?o.getNextSibling():o.getPreviousSibling();if(null!==c){o=c;continue}const a=o.getParentOrThrow();if(i.has(a.__key)||r.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||i.has(f.__key)||r.push(f);}while(null===u);o=u;}return n||r.reverse(),r}isDirty(){const t=ii()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(On(this))return this;const e=xo(this.__key);return null===e&&t(113),e}getWritable(){if(On(this))return this;ei();const t=ri(),e=ii(),n=t._nodeMap,r=this.__key,i=this.getLatest(),o=e._cloneNotNeeded,s=Lr();if(null!==s&&s.setCachedNodes(null),o.has(r))return po(i),i;const l=Ms(i);return o.add(r),po(l),n.set(r,l),l}getTextContent(){return ""}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70);}updateDOM(e,n,r){t(71);}exportDOM(t){return {element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return {type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name);}updateFromJSON(t){return function(t,e){const n=t.getWritable(),r=e.$;let i=r;for(const t of dt$4(n).flatKeys)t in e&&(void 0!==i&&i!==r||(i={...r}),i[t]=e[t]);return (n.__state||i)&&ft$3(t).updateFromJSON(i),n}(this,t)}static transform(){return null}remove(t){bn(this,true,t);}replace(e,n){ei();let r=Lr();null!==r&&(r=r.clone()),ds(this,e);const i=this.getLatest(),o=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size;_o(l);const u=i.getPreviousSibling(),f=i.getNextSibling(),d=i.__prev,h=i.__next,g=i.__parent;if(bn(i,false,true),null===u)c.__first=s;else {u.getWritable().__next=s;}if(l.__prev=d,null===f)c.__last=s;else {f.getWritable().__prev=s;}if(l.__next=h,l.__parent=g,c.__size=a,n&&(Si(this)&&Si(l)||t(139),this.getChildren().forEac
4593h(t=>{l.append(t);})),yr(r)){wo(r);const t=r.anchor,e=r.focus;t.key===o&&_r(t,l),e.key===o&&_r(e,l);}return mo()===o&&yo(s),l}insertAfter(t,e=true){ei(),ds(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.getParent(),o=Lr();let s=false,l=false;if(null!==i){const e=t.getIndexWithinParent();if(_o(r),yr(o)){const t=i.__key,n=o.anchor,r=o.focus;s="element"===n.type&&n.key===t&&n.offset===e+1,l="element"===r.type&&r.key===t&&r.offset===e+1;}}const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=r.__key,f=n.__next;if(null===c)a.__last=u;else {c.getWritable().__prev=u;}if(a.__size++,n.__next=u,r.__next=f,r.__prev=n.__key,r.__parent=n.__parent,e&&yr(o)){const t=this.getIndexWithinParent();Kr(o,a,t+1);const e=a.__key;s&&o.anchor.set(e,t+2,"element"),l&&o.focus.set(e,t+2,"element");}return t}insertBefore(t,e=true){ei(),ds(this,t);const n=this.getWritable(),r=t.getWritable(),i=r.__key;_o(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,c=this.getIndexWithinParent();if(null===o)s.__first=i;else {o.getWritable().__next=i;}s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const a=Lr();if(e&&yr(a)){Kr(a,this.getParentOrThrow(),c);}return t}isParentRequired(){return false}createParentElementNode(){return Li()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ei();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(Si(n))return n.select();if(!lr(n)){const t=n.getIndexWithinParent()+1;return r.select(t,t)}return n.select(t,e)}selectNext(t,e){ei();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(Si(n))return n.select(0,0);if(!lr(n)){const t=n.getIndexWithinParent();return r.select(t,t)}return n.select(t,e)}markDirty(){this.getWritable();}reconcileObservedMutation(t,e){this.markDirty();}}const An="historic",Pn="history-push",Dn="history-merge",Fn="paste",Ln="collaboration",Kn="skip-scroll-into-view",zn="skip-dom-selection",Rn="skip-selection-focus";class Bn extends Mn{static getType(){return "linebreak"}static clone(t){return new Bn(t.__key)}constructor(t){super(t);}getTextContent(){return "\n"}createDOM(){return document.createElement("br")}updateDOM(){return false}isInline(){return true}static importDOM(){return {br:t=>function(t){const e=t.parentElement;if(null!==e&&Ts(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&$n(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&$n(n))return true}}return false}(t)||function(t){const e=t.parentElement;if(null!==e&&Ts(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&$n(n))return false;const r=e.lastChild;if(r===t||r.previousSibling===t&&$n(r))return true}return false}(t)?null:{conversion:Wn,priority:0}}}static importJSON(t){return Jn().updateFromJSON(t)}}function Wn(t){return {node:Jn()}}function Jn(){return fs(new Bn)}function jn(t){return t instanceof Bn}function $n(t){return co(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}function Un(t,e){return 16&e?"code":e&T$3?"mark":32&e?"sub":64&e?"sup":null}function Vn(t,e){return 1&e?"strong":2&e?"em":"span"}function Yn(t,e,n,r,i){const o=r.classList;let s=$o(i,"base");void 0!==s&&o.add(...s),s=$o(i,"underlineStrikethrough");let l=false;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=true,c||o.add(...s)):c&&o.remove(...s));for(const t in R$6){const r=R$6[t];if(s=$o(i,t),void 0!==s)if(n&r){if(l&&("underline"===t||"strikethrough"===t)){e&r&&o.remove(...s);continue}(0===(e&r)||c&&"underline"===t||"strikethrough"===t)&&o.add(...s);}else e&r&&o.remove(...s);}}function qn(t,e,n){const r=e.firstChild,i=n.isComposing(),s=t+(i?P$3:"");if(null==r)e.textContent=s;else {const t=r.nodeValue;if(t!==s)if(i||o){const[e,n,i]=function(t,e){const n=t.length,r=e.length;let i=0,o=0;for(;i<n&&i<r&&t[i]===e[i];)i++;for(;o+i<n&&o+i<r&&t[n-o-1]===e[r-o-1];)o++;return [i,n-i-o,e.slice(i,r-o)]}(t,s);0!==n&&r.deleteData(e,n),r.insertData(e,i);}else r.nodeValue=s;}}function Hn(t,e,n,r,i,o){qn(i,t,e);const s=o.theme.text;void 0!==s&&Yn(0,0,r,t,s);}function Gn(t,e){const n=document.createElement(e);return n.appendChild(t),n}class Xn extends Mn{__text;__format;__style;__mode;__detail;static getType(){return "text"}static clone(t){return new Xn(t.__text,t.__key)}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail;}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0;}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return $$4[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===mo()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return !!(1&this.getLatest().__detail)}isUnmergeable(){return !!(2&this.getLatest().__detail)}hasFormat(t){const e=R$6[t];return 0!==(this.getFormat()&e)}isSimpleText(){return "text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return fo(this.getLatest().__format,t,e)}canHaveFormat(){return true}isInline(){return true}createDOM(t,e){const n=this.__format,r=Un(0,n),i=Vn(0,n),o=null===r?i:r,s=document.createElement(o);let l=s;
4593this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==r&&(l=document.createElement(i),s.appendChild(l));Hn(l,this,0,n,this.__text,t);const c=this.__style;return ""!==c&&(s.style.cssText=c),s}updateDOM(e,n,r){const i=this.__text,o=e.__format,s=this.__format,l=Un(0,o),c=Un(0,s),a=Vn(0,o),u=Vn(0,s);if((null===l?a:l)!==(null===c?u:c))return true;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const o=document.createElement(u);return Hn(o,this,0,s,i,r),n.replaceChild(o,e),false}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),qn(i,f,this);const d=r.theme.text;void 0!==d&&o!==s&&Yn(0,o,s,f,d);const h=e.__style,g=this.__style;return h!==g&&(n.style.cssText=g),false}static importDOM(){return {"#text":()=>({conversion:nr,priority:0}),b:()=>({conversion:Zn,priority:0}),code:()=>({conversion:or,priority:0}),em:()=>({conversion:or,priority:0}),i:()=>({conversion:or,priority:0}),mark:()=>({conversion:or,priority:0}),s:()=>({conversion:or,priority:0}),span:()=>({conversion:Qn,priority:0}),strong:()=>({conversion:or,priority:0}),sub:()=>({conversion:or,priority:0}),sup:()=>({conversion:or,priority:0}),u:()=>({conversion:or,priority:0})}}static importJSON(t){return sr().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Cs(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Gn(n,"b")),this.hasFormat("italic")&&(n=Gn(n,"i")),this.hasFormat("strikethrough")&&(n=Gn(n,"s")),this.hasFormat("underline")&&(n=Gn(n,"u")),{element:n}}exportJSON(){return {detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?R$6[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?B$4[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=fo(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=j$4[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){ei();let n=t,r=e;const i=Lr(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const t=o.length;void 0===n&&(n=t),void 0===r&&(r=t);}else n=0,r=0;if(!yr(i))return Mr(s,n,s,r,"text","text");{const t=mo();t!==i.anchor.key&&t!==i.focus.key||yo(s),i.setTextNodeRange(this,n,this,r);}return i}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,r){const i=this.getWritable(),o=i.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Lr();if(r&&yr(c)){const e=t+s;c.setTextNodeRange(i,e,i,e);}const a=o.slice(0,l)+n+o.slice(l+e);return i.__text=a,i}canInsertTextBefore(){return true}canInsertTextAfter(){return true}splitText(...t){ei();const e=this.getLatest(),n=e.getTextContent();if(""===n)return [];const r=e.__key,i=mo(),o=n.length;t.sort((t,e)=>t-e),t.push(o);const s=[],l=t.length;for(let e=0,r=0;e<o&&r<=l;r++){const i=t[r];i>e&&(s.push(n.slice(e,i)),e=i);}const c=s.length;if(1===c)return [e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=false,p=null,y=null;const m=Lr();if(yr(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===r&&(p=t),"text"===e.type&&e.key===r&&(y=e);}e.isSegmented()?(f=sr(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=yt$4(e,f),_=true):f=e.setTextContent(a);const x=[f];for(let t=1;t<c;t++){const n=sr(s[t]);n.__format=d,n.__style=h,n.__detail=g,n.__state=yt$4(e,n);const o=n.__key;i===r&&yo(o),x.push(n);}const C=p?p.offset:null,S=y?y.offset:null;let v=0;for(const t of x){if(!p&&!y)break;const e=v+t.getTextContentSize();if(null!==p&&null!==C&&C<=e&&C>=v&&(p.set(t.getKey(),C-v,"text"),C<e&&(p=null)),null!==y&&null!==S&&S<=e&&S>=v){y.set(t.getKey(),S-v,"text");break}v=e;}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&po(e);null!==n&&po(n);}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),yr(m)&&Kr(m,u,e,c-1);}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const r=this.__key,i=e.__key,o=this.__text,s=o.length;mo()===i&&yo(r);const l=Lr();if(yr(l)){const t=l.anchor,o=l.focus;null!==t&&t.key===i&&Br(t,n,r,e,s),null!==o&&o.key===i&&Br(o,n,r,e,s);}const c=e.__text,a=n?c+o:o+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return false}}function Qn(t){return {forChild:cr(t.style),node:null}}function Zn(t){const e=t,n="normal"===e.style.fontWeight;return {forChild:cr(e.style,n?void 0:"bold"),node:null}}const tr=new WeakMap;function er(t){if(!Cs(t))return false;if("PRE"===t.nodeName)return true;const e=t.style.whiteSpace;return "string"==typeof e&&e.startsWith("pre")}function nr(e){const n=e;null===e.parentElement&&t(129);let r=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const r=[t];for(;null!==n&&void 0===(e=tr.get(n))&&!er(n);)r.push(n),n=n.parentNode;const i=void 0===e?n:e;for(let t=0;t<r.length;t++)tr.set(r[t],i);return i}(n)){const t=r.split(/(\r?\n|\t)/),e=[],n=t.length;for(let r=0;r<n;r++){const n=t[r];"\n"===n||"\r\n"===n?e.push(Jn()):"\t"===n?e.push(ur()):""!==n&&e.push(sr(n));}return {node:e}}if(r=r.replace(/\r/g,"").replace(/[ \t\n]+/g," "),""===r)return {node:null};if(" "===r[0]){let t=n,e=true;for(;null!==t&&null!==(t=rr(t,false));){const n=t.textContent||"";if(n.length>0){/[ \t\n]$/.test(n)&&(r=r.slice(1)),e=false;break}}e&&(r=r.slice(1));}if(" "===r[r.length-1]){let t=n,e=true;for(;null!==t&&null!==(t=rr(t,true));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=false;break}}e&&(r=r.slice(0,r.length-1));}return ""===r?{node:null}
4593:{node:sr(r)}}function rr(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t;}if(n=t,Cs(n)){const t=n.style.display;if(""===t&&!ks(n)||""!==t&&!t.startsWith("inline"))return null}let r=n;for(;null!==(r=e?n.firstChild:n.lastChild);)n=r;if(co(n))return n;if("BR"===n.nodeName)return null}}const ir={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function or(t){const e=ir[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:cr(t.style,e),node:null}}function sr(t=""){return fs(new Xn(t))}function lr(t){return t instanceof Xn}function cr(t,e){const n=t.fontWeight,r=t.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===t.fontStyle,l=r.includes("underline"),c=t.verticalAlign;return t=>lr(t)?(i&&!t.hasFormat("bold")&&t.toggleFormat("bold"),o&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class ar extends Xn{static getType(){return "tab"}static clone(t){return new ar(t.__key)}constructor(t){super("\t",t),this.__detail=2;}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),n=$o(t.theme,"tab");if(void 0!==n){e.classList.add(...n);}return e}static importJSON(t){return ur().updateFromJSON(t)}setTextContent(t){return "\t"!==t&&""!==t&&e(126),super.setTextContent("\t")}spliceText(e,n,r,i){return ""===r&&0===n||"\t"===r&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return "normal"!==e&&t(128),this}canInsertTextBefore(){return false}canInsertTextAfter(){return false}}function ur(){return fs(new ar)}function fr(t){return t instanceof ar}class dr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n;}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offset<t.offset;return gl(El(xl(this,"next")),El(xl(t,"next")))<0}getNode(){const e=xo(this.key);return null===e&&t(20),e}set(t,e,n,r){const i=this._selection,o=this.key;r&&this.key===t&&this.offset===e&&this.type===n||(this.key=t,this.offset=e,this.type=n,ti()||(mo()===o&&yo(t),null!==i&&(i.setCachedNodes(null),i.dirty=true)));}}function hr(t,e,n){return new dr(t,e,n)}function gr(t,e){let n=e.__key,r=t.offset,i="element";if(lr(e)){i="text";const t=e.getTextContentSize();r>t&&(r=t);}else if(!Si(e)){const t=e.getNextSibling();if(lr(t))n=t.__key,r=0,i="text";else {const t=e.getParent();t&&(n=t.__key,r=e.getIndexWithinParent()+1);}}t.set(n,r,i);}function _r(t,e){if(Si(e)){const n=e.getLastDescendant();Si(n)||lr(n)?gr(t,n):gr(t,e);}else gr(t,e);}class pr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=false;}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t;}is(t){if(!xr(t))return false;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return false}isBackward(){return false}getStartEndPoints(){return null}add(t){this.dirty=true,this._nodes.add(t),this._cachedNodes=null;}delete(t){this.dirty=true,this._nodes.delete(t),this._cachedNodes=null;}clear(){this.dirty=true,this._nodes.clear(),this._cachedNodes=null;}has(t){return this._nodes.has(t)}clone(){return new pr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),n=e.length,r=e[n-1];let i;if(lr(r))i=r.select();else {const t=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(t,t);}i.insertNodes(t);for(let t=0;t<n;t++)e[t].remove();}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=this._nodes,n=[];for(const t of e){const e=xo(t);null!==e&&n.push(e);}return ti()||(this._cachedNodes=n),n}getTextContent(){const t=this.getNodes();let e="";for(let n=0;n<t.length;n++)e+=t[n].getTextContent();return e}deleteNodes(){const t=this.getNodes();if((Lr()||Ir())===this&&t[0]){const e=tl(t[0],"next");Sl(dl(e,e));}for(const e of t)e.remove();}}function yr(t){return t instanceof mr}class mr{format;style;anchor;focus;_cachedNodes;dirty;constructor(t,e,n,r){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=n,this.style=r,this.dirty=false;}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t;}is(t){return !!yr(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,r]=t.getTextSlices();n&&e.push(n.caret.origin);const i=new Set,o=new Set;for(const n of t)if(Gs(n)){const{origin:t}=n;
45930===e.length?i.add(t):(o.add(t),e.push(t));}else {const{origin:t}=n;Si(t)&&o.has(t)||e.push(t);}r&&e.push(r.caret.origin);if(Hs(t.focus)&&Si(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=il(t.focus.origin,"previous");Gs(n)&&i.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=sl(n))i.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Si(t)||o.has(t)||t.isEmpty()||i.has(t))break;e.pop();}if(0===e.length&&t.isCollapsed()){const n=El(t.anchor),r=El(t.anchor.getFlipped()),i=t=>Ys(t)?t.origin:t.getNodeAtCaret(),o=i(n)||i(r)||(t.anchor.getNodeAtCaret()?n.origin:r.origin);e.push(o);}return e}(Al(kl(this),"next"));return ti()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,r){this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,r,"text");}getTextContent(){const t=this.getNodes();if(0===t.length)return "";const e=t[0],n=t[t.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=Sr(this);let c="",a=true;for(let u=0;u<t.length;u++){const f=t[u];if(Si(f)&&!f.isInline())a||(c+="\n"),a=!f.isEmpty();else if(a=false,lr(f)){let t=f.getTextContent();f===e?f===n?"element"===r.type&&"element"===i.type&&i.offset!==r.offset||(t=s<l?t.slice(s,l):t.slice(l,s)):t=o?t.slice(s):t.slice(l):f===n&&(t=o?t.slice(0,l):t.slice(0,s)),c+=t;}else !Ti(f)&&!jn(f)||f===n&&this.isCollapsed()||(c+=f.getTextContent());}return c}applyDOMRange(t){const e=ii(),n=e.getEditorState()._selection,r=Er(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,n);if(null===r)return;const[i,o]=r;this.anchor.set(i.key,i.offset,i.type,true),this.focus.set(o.key,o.offset,o.type,true),St$6(this);}clone(){const t=this.anchor,e=this.focus;return new mr(hr(t.key,t.offset,t.type),hr(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=fo(this.format,t,null),this.dirty=true;}setFormat(t){this.format=t,this.dirty=true;}setStyle(t){this.style=t,this.dirty=true;}hasFormat(t){const e=R$6[t];return 0!==(this.format&e)}insertRawText(t){const e=t.split(/(\r?\n|\t)/),n=[],r=e.length;for(let t=0;t<r;t++){const r=e[t];"\n"===r||"\r\n"===r?n.push(Jn()):"\t"===r?n.push(ur()):n.push(sr(r));}this.insertNodes(n);}insertText(e){const n=this.anchor,r=this.focus,i=this.format,o=this.style;let s=n,l=r;!this.isCollapsed()&&r.isBefore(n)&&(s=r,l=n),"element"===s.type&&function(t,e,n,r){const i=t.getNode(),o=i.getChildAtIndex(t.offset),s=sr();if(s.setFormat(n),s.setStyle(r),Ii(o))o.splice(0,0,[s]);else {const t=bi(i)?Li().append(s):s;null===o?i.append(t):o.insertBefore(t);}t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text");}(s,l,i,o),"element"===l.type&&Cl(l,El(xl(l,"next")));const c=s.offset;let a=l.offset;const u=this.getNodes(),f=u.length;let d=u[0];lr(d)||t(26);const h=d.getTextContent().length,g=d.getParentOrThrow();let _=u[f-1];if(1===f&&"element"===l.type&&(a=h,l.set(s.key,a,"text")),this.isCollapsed()&&c===h&&(lo(d)||!d.canInsertTextAfter()||!g.canInsertTextAfter()&&null===d.getNextSibling())){let t=d.getNextSibling();if(lr(t)&&t.canInsertTextBefore()&&!lo(t)||(t=sr(),t.setFormat(i),t.setStyle(o),g.canInsertTextAfter()?d.insertAfter(t):g.insertAfter(t)),t.select(0,0),d=t,""!==e)return void this.insertText(e)}else if(this.isCollapsed()&&0===c&&(lo(d)||!d.canInsertTextBefore()||!g.canInsertTextBefore()&&null===d.getPreviousSibling())){let t=d.getPreviousSibling();if(lr(t)&&!lo(t)||(t=sr(),t.setFormat(i),g.canInsertTextBefore()?d.insertBefore(t):g.insertBefore(t)),t.select(),d=t,""!==e)return void this.insertText(e)}else if(d.isSegmented()&&c!==h){const t=sr(d.getTextContent());t.setFormat(i),d.replace(t),d=t;}else if(!this.isCollapsed()&&""!==e){const t=_.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||Si(t)&&(!t.canInsertTextBefore()||!t.canInsertTextAfter()))return this.insertText(""),wr(this.anchor,this.focus,null),void this.insertText(e)}if(1===f){if(so(d)){const t=sr(e);return t.select(),void d.replace(t)}const t=d.getFormat(),n=d.getStyle();if(c!==a||t===i&&n===o){if(fr(d)){const t=sr(e);return t.setFormat(i),t.setStyle(o),t.select(),void d.replace(t)}}else {if(""!==d.getTextContent()){const t=sr(e);
4593if(t.setFormat(i),t.setStyle(o),t.select(),0===c)d.insertBefore(t,false);else {const[e]=d.splitText(c);e.insertAfter(t,false);}return void(t.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length))}d.setFormat(i),d.setStyle(o);}const r=a-c;d=d.spliceText(c,r,e,true),""===d.getTextContent()?d.remove():"text"===this.anchor.type&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=t,this.style=n));}else {const t=new Set([...d.getParentKeys(),..._.getParentKeys()]),n=Si(d)?d:d.getParentOrThrow();let r=Si(_)?_:_.getParentOrThrow(),i=_;if(!n.is(r)&&r.isInline())do{i=r,r=r.getParentOrThrow();}while(r.isInline());if("text"===l.type&&(0!==a||""===_.getTextContent())||"element"===l.type&&_.getIndexWithinParent()<a)if(lr(_)&&!so(_)&&a!==_.getTextContentSize()){if(_.isSegmented()){const t=sr(_.getTextContent());_.replace(t),_=t;}bi(l.getNode())||"text"!==l.type||(_=_.spliceText(0,a,"")),t.add(_.__key);}else {const t=_.getParentOrThrow();t.canBeEmpty()||1!==t.getChildrenSize()?_.remove():t.remove();}else t.add(_.__key);const o=r.getChildren(),s=new Set(u),g=n.is(r),p=n.isInline()&&null===d.getNextSibling()?n:d;for(let t=o.length-1;t>=0;t--){const e=o[t];
4593if(e.is(d)||Si(e)&&e.isParentOf(d))break;e.isAttached()&&(!s.has(e)||e.is(i)?g||p.insertAfter(e,false):e.remove());}if(!g){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent();}}if(so(d))if(c===h)d.select();else {const t=sr(e);t.select(),d.replace(t);}else d=d.spliceText(c,h-c,e,true),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e<f;e++){const n=u[e],r=n.__key;t.has(r)||n.remove();}}}removeText(){const t=Lr()===this;vl(this,wl(kl(this))),t&&Lr()!==this&&wo(this);}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void yo(null);const n=this.getNodes(),r=[];for(const t of n)lr(t)&&r.push(t);const i=e=>{n.forEach(n=>{if(Si(n)){const r=n.getFormatFlags(t,e);n.setTextFormat(r);}});},o=r.length;if(0===o)return this.toggleFormat(t),yo(null),void i(e);const s=this.anchor,l=this.focus,c=this.isBackward(),a=c?l:s,u=c?s:l;let f=0,d=r[0],h="element"===a.type?0:a.offset;if("text"===a.type&&h===d.getTextContentSize()&&(f=1,d=r[1],h=0),null==d)return;const g=d.getFormatFlags(t,e);i(g);const _=o-1;let p=r[_];const y="text"===u.type?u.offset:p.getTextContentSize();if(d.is(p)){if(h===y)return;if(lo(d)||0===h&&y===d.getTextContentSize())d.setFormat(g);else {const t=d.splitText(h,y),e=0===h?t[0]:t[1];e.setFormat(g),"text"===a.type&&a.set(e.__key,0,"text"),"text"===u.type&&u.set(e.__key,y-h,"text");}return void(this.format=g)}0===h||lo(d)||([,d]=d.splitText(h),h=0),d.setFormat(g);const m=p.getFormatFlags(t,g);y>0&&(y===p.getTextContentSize()||lo(p)||([p]=p.splitText(y)),p.setFormat(m));for(let e=f+1;e<_;e++){const n=r[e],i=n.getFormatFlags(t,m);n.setFormat(i);}"text"===a.type&&a.set(d.__key,h,"text"),"text"===u.type&&u.set(p.__key,y,"text"),this.format=g|m;}insertNodes(e){if(0===e.length)return;if(this.isCollapsed()||this.removeText(),"root"===this.anchor.key){this.insertParagraph();const n=Lr();return yr(n)||t(134),n.insertNodes(e)}const n=(this.isBackward()?this.focus:this.anchor).getNode(),r=zs(n,Ns),i=e[e.length-1];if(Si(r)&&"__language"in r){if("__language"in e[0])this.insertText(e[0].getTextContent());else {const t=Ur(this);r.splice(t,0,e),i.selectEnd();}return}if(!e.some(t=>(Si(t)||Ti(t))&&!t.isInline())){Si(r)||t(211,n.constructor.name,n.getType());const o=Ur(this);return r.splice(o,0,e),void i.selectEnd()}const o=function(t){const e=Li();let n=null;for(let r=0;r<t.length;r++){const i=t[r],o=jn(i);if(o||Ti(i)&&i.isInline()||Si(i)&&i.isInline()||lr(i)||i.isParentRequired()){if(null===n&&(n=i.createParentElementNode(),e.append(n),o))continue;null!==n&&n.append(i);}else e.append(i),n=null;}return e}(e),s=o.getLastDescendant(),l=o.getChildren(),c=!Si(r)||!r.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let u=l[0];var f;Si(f=u)&&Ns(f)&&!f.isEmpty()&&Si(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Si(r)||t(211,n.constructor.name,n.getType()),r.append(...u.getChildren()),u=l[1]),u&&(null===r&&t(212,n.constructor.name,n.getType()),function(e,n){const r=n.getParentOrThrow().getLastChild();let i=n;const o=[n];for(;i!==r;)i.getNextSibling()||t(140),i=i.getNextSibling(),o.push(i);let s=e;for(const t of o)s=s.insertAfter(t);}(r,u));const d=zs(s,Ns);c&&Si(d)&&(c.canMergeWhenEmpty()||Ns(a))&&(d.append(...c.getChildren()),c.remove()),Si(r)&&r.isEmpty()&&r.remove(),s.selectEnd();const h=Si(r)?r.getLastChild():null;jn(h)&&d!==r&&h.remove();}insertParagraph(){if("root"===this.anchor.key){const t=Li();return No().splice(this.anchor.offset,0,[t]),t.select(),t}const e=Ur(this),n=zs(this.anchor.getNode(),Ns);Si(n)||t(213);const r=n.getChildAtIndex(e),i=r?[r,...r.getNextSiblings()]:[],o=n.insertNewAfter(this,false);return o?(o.append(...i),o.selectStart(),o):null}insertLineBreak(t){const e=Jn();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n);}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],r=t[e-1];const[i,o]=Sr(this),s=this.isBackward(),[l,c]=s?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=s?[o,i]:[i,o];if(0===e)return [];if(1===e){if(lr(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return [n]}if(lr(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),lr(r)){const e=r.getTextContent().length;0===u?t.pop():u!==e&&([r]=r.splitText(u),t[t.length-1]=r,c.set(r.getKey(),r.getTextContentSize(),"text"));}return t}modify(t,e,n){if(Yr(this,t,e,n))return;const r="move"===t,i=ii(),o=ps(ss(i));if(!o)return;const s=i._blockCursorElement,l=i._rootElement,c=this.focus.getNode();if(null===l||null===s||!Si(c)||c.isInline()||c.canBeEmpty()||_s(s,i,l),this.dirty){let t=Qo(i,this.anchor.key),e=Qo(i,this.focus.key);"text"===this.anchor.type&&(t=uo(t)),"text"===this.focus.type&&(e=uo(e)),t&&e&&Wr(o,t,this.anchor.offset,e,this.focus.offset);}if(function(t,e,n,r){t.modify(e,n,r);}(o,t,e?"backward":"forward",n),o.rangeCount>0){const t=o.getRangeAt(0),n=this.anchor.getNode(),i=bi(n)?n:cs(n);if(this.applyDOMRange(t),this.dirty=true,!r){const n=this.getNodes(),r=[];let s=false;for(let t=0;t<n.length;t++){const e=n[t];is(e,i)?r.push(e):s=true;}if(s&&r.length>0)if(e){const t=r[0];Si(t)?t.selectStart():t.getParentOrThrow().selectStart();}else {const t=r[r.length-1];Si(t)?t.selectEnd():t.getParentOrThrow().selectEnd();}
4593o.anchorNode===t.startContainer&&o.anchorOffset===t.startOffset||function(t){const e=t.focus,n=t.anchor,r=n.key,i=n.offset,o=n.type;n.set(e.key,e.offset,e.type,true),e.set(r,i,o,true);}(this);}}"lineboundary"===n&&Yr(this,t,e,n,"decorators");}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Si(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Si(n)&&n.isShadowRoot())return true}return false}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const r=ul(xl(e,t?"previous":"next"));if(r.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of r.iterNodeCarets("shadowRoot"))if(Gs(e))if(e.origin.isInline());else {if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Si(r.anchor.origin)&&r.anchor.origin.isEmpty()){const t=El(e);vl(this,dl(t,t)),r.anchor.origin.remove();}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"});}else {if("merge-block"===t.type)break;if(Hs(e)){if(Si(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(r.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Ti(e.origin)){if(e.origin.isIsolated());else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Si(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),wo(t);}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;return vl(this,dl(!e.origin.isEmpty()&&n.isEmpty()?Tl(tl(n,e.direction)):r.anchor,e)),this.removeText()}}const i=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&0===e.offset&&vr(this,e.getNode()))return}else {const r="text"===i.type?i.getNode():null;if(n="text"===e.type?e.getNode():null,null!==r&&r.isSegmented()){const e=i.offset,o=r.getTextContentSize();if(r.is(n)||t&&e!==o||!t&&0!==e)return void Tr(r,t,e)}else if(null!==n&&n.isSegmented()){const i=e.offset,o=n.getTextContentSize();if(n.is(r)||t&&0!==i||!t&&i!==o)return void Tr(n,t,i)}!function(t,e){const n=t.anchor,r=t.focus,i=n.getNode(),o=r.getNode();if(i===o&&"text"===n.type&&"text"===r.type){const t=n.offset,o=r.offset,s=t<o,l=s?t:o,c=s?o:t,a=c-1;if(l!==a){(function(t){return !(Oo(t)||kr(t))})(i.getTextContent().slice(l,c))&&(e?r.set(r.key,a,r.type):n.set(n.key,a,n.type));}}}(this,t);}}if(this.removeText(),t&&!e&&this.isCollapsed()&&"element"===this.anchor.type&&0===this.anchor.offset){const t=this.anchor.getNode();t.isEmpty()&&bi(t.getParent())&&null===t.getPreviousSibling()&&vr(this,t);}}deleteLine(t){this.isCollapsed()&&this.modify("extend",t,"lineboundary"),this.isCollapsed()?this.deleteCharacter(t):this.removeText();}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,n=e.getNode();if(this.forwardDeletion(e,n,t))return;this.modify("extend",t,"word");}this.removeText();}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return [this.anchor,this.focus]}}function xr(t){return t instanceof pr}function Cr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function Sr(t){const e=t.getStartEndPoints();if(null===e)return [0,0];const[n,r]=e;return "element"===n.type&&"element"===r.type&&n.key===r.key&&n.offset===r.offset?[0,0]:[Cr(n),Cr(r)]}function vr(t,e){for(let n=e;n;n=n.getParent()){if(Si(n)){if(n.collapseAtStart(t))return true;if(as(n))break}if(n.getPreviousSibling())break}return false}const kr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("â¤ï¸")&&e("#ï¸â£")&&e("ð"))return e}catch(t){}return ()=>false})();function Tr(t,e,n){const r=t,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let t=0;t<o;t++){const r=t===o-1;if(l=s,s+=i[t].length,e&&s===n||s>n||r){i.splice(t,1),r&&(l=void 0);break}}const c=i.join("").trim();""===c?r.remove():(r.setTextContent(c),r.select(l,l));}function Nr(e,n,r,i){let o,s=n;if(Cs(e)){let l=false;const c=e.childNodes,a=c.length,u=i._blockCursorElement;s===a&&(l=true,s=a-1);let f=c[s],d=false;if(f===u)f=c[s+1],d=true;else if(null!==u){const t=u.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,u)&&s--;}}if(o=Eo(f),lr(o))s=nl(o,l?"next":"previous");else {let c=Eo(e);if(null===c)return null;if(Si(c)){const a=i.getElementByKey(c.getKey());null===a&&t(214);const u=c.getDOMSlot(a);
4593[c,s]=u.resolveChildIndex(c,a,e,n),Si(c)||t(215),l&&s>=c.getChildrenSize()&&(s=Math.max(0,c.getChildrenSize()-1));let f=c.getChildAtIndex(s);if(Si(f)&&function(t,e,n){const r=t.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(f,0,r)){const t=l?f.getLastDescendant():f.getFirstDescendant();null===t?c=f:(f=t,c=Si(f)?f:f.getParentOrThrow()),s=0;}lr(f)?(o=f,c=null,s=nl(f,l?"next":"previous")):f!==c&&l&&!d&&(Si(c)||t(216),s=Math.min(c.getChildrenSize(),s+1));}else {const t=c.getIndexWithinParent();s=0===n&&Ti(c)&&Eo(e)===c?t:t+1,c=c.getParentOrThrow();}if(Si(c))return hr(c.__key,s,"element")}}else o=Eo(e);return lr(o)?hr(o.__key,nl(o,s,"clamp"),"text"):null}function br(t,e,n){const r=t.offset,i=t.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(e){if((n||!e)&&null===r&&Si(o)&&o.isInline()){const e=o.getPreviousSibling();lr(e)&&t.set(e.__key,e.getTextContent().length,"text");}}else Si(r)&&!n&&r.isInline()?t.set(r.__key,r.getChildrenSize(),"element"):lr(r)&&t.set(r.__key,r.getTextContent().length,"text");}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(e&&Si(r)&&r.isInline())t.set(r.__key,0,"element");else if((n||e)&&null===r&&Si(o)&&o.isInline()&&!o.canInsertTextAfter()){const e=o.getNextSibling();lr(e)&&t.set(e.__key,0,"text");}}}function wr(t,e,n){if("text"===t.type&&"text"===e.type){const r=t.isBefore(e),i=t.is(e);br(t,r,i),br(e,!r,i),i&&e.set(t.key,t.offset,t.type);const o=ii();if(o.isComposing()&&o._compositionKey!==t.key&&yr(n)){const r=n.anchor,i=n.focus;t.set(r.key,r.offset,r.type,true),e.set(i.key,i.offset,i.type,true);}}}function Er(t,e,n,r,i,o){if(null===t||null===n||!eo(i,t,n))return null;const s=Nr(t,e,yr(o)?o.anchor:null,i);if(null===s)return null;const l=Nr(n,r,yr(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const e=Eo(t),r=Eo(n);if(Ti(e)&&Ti(r))return null}return wr(s,l,o),[s,l]}function Or(t){return Si(t)&&!t.isInline()}function Mr(t,e,n,r,i,o){const s=ri(),l=new mr(hr(t,e,i),hr(n,r,o),0,"");return l.dirty=true,s._selection=l,l}function Ar(){const t=hr("root",0,"element"),e=hr("root",0,"element");return new mr(t,e,0,"")}function Pr(){return new pr(new Set)}function Dr(t,e){return Fr(null,t,e,null)}function Fr(t,e,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,c=!q$5&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let a,u,f,d;if(yr(t)&&!c)return t.clone();if(null===e)return null;if(a=e.anchorNode,u=e.focusNode,f=e.anchorOffset,d=e.focusOffset,(l||void 0===s)&&yr(t)&&!eo(n,a,u))return t.clone();const h=Er(a,f,u,d,n,t);if(null===h)return null;const[g,_]=h;return new mr(g,_,yr(t)?t.format:0,yr(t)?t.style:"")}function Lr(){return ri()._selection}function Ir(){return ii()._editorState._selection}function Kr(t,e,n,r=1){const i=t.anchor,o=t.focus,s=i.getNode(),l=o.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=i.offset;if(n<=e&&r>0||n<e&&r<0){const n=Math.max(0,e+r);i.set(c,n,"element"),o.set(c,n,"element"),zr(t);}}else {const s=t.isBackward(),l=s?o:i,a=l.getNode(),u=s?i:o,f=u.getNode();if(e.is(a)){const t=l.offset;(n<=t&&r>0||n<t&&r<0)&&l.set(c,Math.max(0,t+r),"element");}if(e.is(f)){const t=u.offset;(n<=t&&r>0||n<t&&r<0)&&u.set(c,Math.max(0,t+r),"element");}}zr(t);}function zr(t){const e=t.anchor,n=e.offset,r=t.focus,i=r.offset,o=e.getNode(),s=r.getNode();if(t.isCollapsed()){if(!Si(o))return;const t=o.getChildrenSize(),i=n>=t,s=i?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(lr(s)){let t=0;i&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),r.set(s.__key,t,"text");}return}if(Si(o)){const t=o.getChildrenSize(),r=n>=t,i=r?o.getChildAtIndex(t-1):o.getChildAtIndex(n);if(lr(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text");}}if(Si(s)){const t=s.getChildrenSize(),e=i>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(i);if(lr(n)){let t=0;e&&(t=n.getTextContentSize()),r.set(n.__key,t,"text");}}}function Rr(t,e,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,lr(r)?(s=r.getTextContentSize(),l="text"):Si(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,lr(i)?l="text":Si(i)&&(l="element")),null!==o&&null!==l?t.set(o,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"));}function Br(t,e,n,r,i){"text"===t.type?t.set(n,t.offset+(e?0:i),"text"):t.offset>r.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element");}function Wr(t,e,n,r,i){try{t.setBaseAndExtent(e,n,r,i);}catch(t){}}function Jr(t,e,n,r,i,o,s){const l=r.anchorNode,c=r.focusNode,a=r.anchorOffset,u=r.focusOffset,f=document.activeElement;if(i.has(Ln)&&f!==o||null!==f&&to(f))return;if(!yr(e))return void(null!==t&&eo(n,l,c)&&r.removeAllRanges());const d=e.anchor,h=e.focus,g=d.key,_=h.key,p=Qo(n,g),y=Qo(n,_),m=d.offset,x=h.offset,C=e.format,S=e.style,v=e.isCollapsed();let k=p,T=y,N=false;if("text"===d.type){k=uo(p);const t=d.getNode();N=t.getFormat()!==C||t.getStyle()!==S;}else yr(t)&&"text"===t.anchor.type&&(N=true);var b,w,E,O,M;if(("text"===h.type&&(T=uo(y)),null!==k&&null!==T)&&(v&&(null===t||N||yr(t)&&(t.format!==C||t.style!==S))&&(b=C,w=S,E=m,O=g,M=performance.now(),fn$1=[b,w,E,O,M]),a!==m||u!==x||l!==k||c!==T||"Range"===r.type&&v||(null!==f&&o.contains(f)||i.has(Rn)||o.focus({preventScroll:true}),"element"===d.type))){if(Wr(r,k,m,T,x),!i.has(Kn)&&e.isCollapsed()&&null!==o&&o===document.activeElement){const t=yr(e)&&"element"===e.anchor.type?k.childNodes[m]||null:r.rangeCount>0?r.getRangeAt(0):null;if(null!==t){let e;if(t instanceof Text){const n=document.createRange();n.selectNode(t),e=n.getBoundingClientRect();}else e=t.getBoundingClientRect();!function(t,e,n){const r=ts(n),i=os(r);if(null===r||null===i)return;let{top:o,bottom:s}=e,l=0,c=0,a=n;for(;null!==a;){const e=a===r.body;if(e)l=0,c=ss(t).innerHeight;else {const t=a.getBoundingClientRect();l=t.top,c=t.bottom;}let n=0;if(o<l?n=-(l-o):s>c&&(n=s-c),0!==n)if(e)i.scrollBy(0,n);else {const t=a.scrollTop;a.scrollTop+=n;const e=a.scrollTop-t;o-=e,s-=e;}if(e)break;a=Zo(a);}}(n,e,o);}}rn$1=true;}}function jr(t){let e=Lr()||Ir();
4593null===e&&(e=No().selectEnd()),e.insertNodes(t);}function Ur(e){let n=e;e.isCollapsed()||n.removeText();const r=Lr();yr(r)&&(n=r),yr(n)||t(161);const i=n.anchor;let o=i.getNode(),s=i.offset;for(;!Ns(o);){const t=o;if([o,s]=Vr(o,s),t.is(o))break}return s}function Vr(t,e){const n=t.getParent();if(!n){const t=Li();return No().append(t),t.select(),[No(),0]}if(lr(t)){const r=t.splitText(e);if(0===r.length)return [n,t.getIndexWithinParent()];const i=0===e?0:1;return [n,r[0].getIndexWithinParent()+i]}if(!Si(t)||0===e)return [n,t.getIndexWithinParent()];const r=t.getChildAtIndex(e);if(r){const n=new mr(hr(t.__key,e,"element"),hr(t.__key,e,"element"),0,""),i=t.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings());}return [n,t.getIndexWithinParent()+1]}function Yr(t,e,n,r,i="decorators-and-blocks"){if("move"===e&&"character"===r&&!t.isCollapsed()){const[e,r]=n===t.isBackward()?[t.focus,t.anchor]:[t.anchor,t.focus];return r.set(e.key,e.offset,e.type),true}const o=xl(t.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===e;let c=o,a="decorators-and-blocks"===i;if(!Ol(c)){for(const t of c){a=false;const{origin:e}=t;if(!Ti(e)||e.isIsolated()||(c=t,!s||!e.isInline()))break}if(a)for(const t of ul(o).iterNodeCarets("extend"===e?"shadowRoot":"root")){if(Gs(t))t.origin.isInline()||(c=t);else {if(Si(t.origin))continue;Ti(t.origin)&&!t.origin.isInline()&&(c=t);}break}}if(c===o)return false;if(l&&!s&&Ti(c.origin)&&c.origin.isKeyboardSelectable()){const t=Pr();return t.add(c.origin.getKey()),wo(t),true}return c=El(c),l&&Cl(t.anchor,c),Cl(t.focus,c),a||!s}let qr=null,Hr=null,Gr=false,Xr=false,Qr=0;const Zr={characterData:true,childList:true,subtree:true};function ti(){return Gr||null!==qr&&qr._readOnly}function ei(){Gr&&t(13);}function ni(){Qr>99&&t(14);}function ri(){return null===qr&&t(195,oi()),qr}function ii(){return null===Hr&&t(196,oi()),Hr}function oi(){let t=0;const e=new Set,n=Ui.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=io(r);if(no(i))t++;else if(i){let t=String(i.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t);}}let r=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(r+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),r}function si(){return Hr}function li(t,e,n){const r=e.__type,i=Gi(t,r);let o=n.get(r);void 0===o&&(o=Array.from(i.transforms),n.set(r,o));const s=o.length;for(let t=0;t<s&&(o[t](e),e.isAttached());t++);}function ci(t,e){return void 0!==t&&t.__key!==e&&t.isAttached()}function ai(t,e){if(!e)return;const n=t._updateTags;let r=e;Array.isArray(e)||(r=[e]);for(const t of r)n.add(t);}function ui(t){return fi(t,ii()._nodes)}function fi(e,n){const r=e.type,i=n.get(r);void 0===i&&t(17,r);const o=i.klass;e.type!==o.getType()&&t(18,o.name);const s=o.importJSON(e),l=e.children;if(Si(s)&&Array.isArray(l))for(let t=0;t<l.length;t++){const e=fi(l[t],n);s.append(e);}return s}function di(t,e,n){const r=qr,i=Gr,o=Hr;qr=e,Gr=true,Hr=t;try{return n()}finally{qr=r,Gr=i,Hr=o;}}function hi(t,e){const n=t._pendingEditorState,r=t._rootElement,i=t._headless||null===r;if(null===n)return;const o=t._editorState,s=o._selection,l=n._selection,c=0!==t._dirtyType,a=qr,u=Gr,f=Hr,d=t._updating,g=t._observer;let _=null;if(t._pendingEditorState=null,t._editorState=n,!i&&c&&null!==g){Hr=t,qr=n,Gr=false,t._updating=true;try{const e=t._dirtyType,r=t._dirtyElements,i=t._dirtyLeaves;g.disconnect(),_=ee$1(o,n,t,e,r,i);}catch(e){if(e instanceof Error&&t._onError(e),Xr)throw e;return Ji(t,null,r,n),rt$3(t),t._dirtyType=2,Xr=true,hi(t,o),void(Xr=false)}finally{g.observe(r,Zr),t._updating=d,qr=a,Gr=u,Hr=f;}}n._readOnly||(n._readOnly=true);const p=t._dirtyLeaves,y=t._dirtyElements,m=t._normalizedNodes,x=t._updateTags,C=t._deferred;c&&(t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set,t._updateTags=new Set),function(t,e){const n=t._decorators;let r=t._pendingDecorators||n;const i=e._nodeMap;let o;
4593for(o in r)i.has(o)||(r===n&&(r=ko(t)),delete r[o]);}(t,n);const S=i?null:ps(ss(t));if(t._editable&&null!==S&&(c||null===l||l.dirty||!l.is(s))&&null!==r&&!x.has(zn)){Hr=t,qr=n;try{if(null!==g&&g.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&_s(e,t,r),Jr(s,l,t,S,x,r);}!function(t,e,n){let r=t._blockCursorElement;if(yr(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(document.activeElement)){const i=n.anchor,o=i.getNode(),s=i.offset;let l=!1,c=null;if(s===o.getChildrenSize()){gs(o.getChildAtIndex(s-1))&&(l=!0);}else {const e=o.getChildAtIndex(s);if(null!==e&&gs(e)){const n=e.getPreviousSibling();(null===n||gs(n))&&(l=!0,c=t.getElementByKey(e.__key));}}if(l){const n=t.getElementByKey(o.__key);return null===r&&(t._blockCursorElement=r=function(t){const e=t.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=e.blockCursor;if(void 0!==r){if("string"==typeof r){const t=h$1(r);r=e.blockCursor=t;}void 0!==r&&n.classList.add(...r);}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(r):n.insertBefore(r,c))}}null!==r&&_s(r,t,e);}(t,r,l);}finally{null!==g&&g.observe(r,Zr),Hr=f,qr=a;}}null!==_&&function(t,e,n,r,i){const o=Array.from(t._listeners.mutation),s=o.length;for(let t=0;t<s;t++){const[s,l]=o[t];for(const t of l){const o=e.get(t);void 0!==o&&s(o,{dirtyLeaves:r,prevEditorState:i,updateTags:n});}}}(t,_,x,p,o),yr(l)||null===l||null!==s&&s.is(l)||t.dispatchCommand(ie$1,void 0);const v=t._pendingDecorators;null!==v&&(t._decorators=v,t._pendingDecorators=null,gi("decorator",t,true,v)),function(t,e,n){const r=To(e),i=To(n);r!==i&&gi("textcontent",t,true,i);}(t,e||o,n),gi("update",t,true,{dirtyElements:y,dirtyLeaves:p,editorState:n,mutatedNodes:_,normalizedNodes:m,prevEditorState:e||o,tags:x}),function(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=true;try{for(let t=0;t<e.length;t++)e[t]();}finally{t._updating=n;}}}(t,C),function(t){const e=t._updates;if(0!==e.length){const n=e.shift();if(n){const[e,r]=n;pi(t,e,r);}}}(t);}function gi(t,e,n,...r){const i=e._updating;e._updating=n;try{const n=Array.from(e._listeners[t]);for(let t=0;t<n.length;t++)n[t].apply(null,r);}finally{e._updating=i;}}function _i(e,n){const r=e._updates;let i=n||false;for(;0!==r.length;){const n=r.shift();if(n){const[r,o]=n,s=e._pendingEditorState;let l;void 0!==o&&(l=o.onUpdate,o.skipTransforms&&(i=true),o.discrete&&(null===s&&t(191),s._flushSync=true),l&&e._deferred.push(l),ai(e,o.tag)),null==s?pi(e,r,o):r();}}return i}function pi(e,n,r){const i=e._updateTags;let o,s=false,l=false;void 0!==r&&(o=r.onUpdate,ai(e,r.tag),s=r.skipTransforms||false,l=r.discrete||false),o&&e._deferred.push(o);const c=e._editorState;let a=e._pendingEditorState,u=false;(null===a||a._readOnly)&&(a=e._pendingEditorState=wi(a||c),u=true),a._flushSync=l;const f=qr,d=Gr,h=Hr,g=e._updating;qr=a,Gr=false,e._updating=true,Hr=e;const _=e._headless||null===e.getRootElement();Yi(null);try{u&&(_?null!==c._selection&&(a._selection=c._selection.clone()):a._selection=function(t,e){const n=t.getEditorState()._selection,r=ps(ss(t));return yr(n)||null==n?Fr(n,r,t,e):n.clone()}(e,r&&r.event||null));const i=e._compositionKey;n(),s=_i(e,s),function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(yr(r)){const t=r.anchor,e=r.focus;let i;if("text"===t.type&&(i=t.getNode(),i.selectionTransform(n,r)),"text"===e.type){const t=e.getNode();i!==t&&t.selectionTransform(n,r);}}}(a,e),0!==e._dirtyType&&(s?function(t,e){const n=e._dirtyLeaves,r=t._nodeMap;for(const t of n){const e=r.get(t);lr(e)&&e.isAttached()&&e.isSimpleText()&&!e.isUnmergeable()&&Ct$6(e);}}(a,e):function(t,e){const n=e._dirtyLeaves,r=e._dirtyElements,i=t._nodeMap,o=mo(),s=new Map;let l=n,c=l.size,a=r,u=a.size;for(;c>0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const r=i.get(t);lr(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct$6(r),void 0!==r&&ci(r,o)&&li(e,r,s),n.add(t);}if(l=e._dirtyLeaves,c=l.size,c>0){Qr++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(r.set(n,l),!l)continue;const c=i.get(n);void 0!==c&&ci(c,o)&&li(e,c,s);}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,Qr++;}e._dirtyLeaves=n,e._dirtyElements=r;}(a,e),_i(e),function(t,e,n,r){const i=t._nodeMap,o=e._nodeMap,s=[];for(const[t]of r){const e=o.get(t);void 0!==e&&(e.isAttached()||(Si(e)&&Y$4(e,t,i,o,s,r),i.has(t)||r.delete(t),s.push(t)));}for(const t of s)o.delete(t);for(const t of n){const e=o.get(t);void 0===e||e.isAttached()||(i.has(t)||n.delete(t),o.delete(t));}}(c,a,e._dirtyLeaves,e._dirtyElements));i!==e._compositionKey&&(a._flushSync=!0);const o=a._selection;if(yr(o)){const e=a._nodeMap,n=o.anchor.key,r=o.focus.key;void 0!==e.get(n)&&void 0!==e.get(r)||t(19);}else xr(o)&&0===o._nodes.size&&(a._selection=null);}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void hi(e)}finally{qr=f,Gr=d,Hr=h,e._updating=g,Qr=0;}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,r=t._selection;if(null!==r){if(r.dirty||!r.is(n))return true}else if(null!==n)return true;return false}(a,e);p?a._flushSync?(a._flushSync=false,hi(e)):u&&Qi(()=>{hi(e);}):(a._flushSync=false,u&&(i.clear(),e._deferred=[],e._pendingEditorState=null));}function yi(t,e,n){Hr===t&&void 0===n?e():pi(t,e,n);}class mi{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null;}withBefore(t){return new mi(this.element,t,this.after)}withAfter(t){return new mi(this.element,this.before,t)}withElement(t){return this.element===t?this:new mi(t,this.before,this.after)}insertChild(e){const n=this.before||this.getManagedLineBreak();return null!==n&&n.parentElement!==this.element&&t(222),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(223),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(224),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(null===t)this.removeManagedLineBreak();else {const e="decorator"===t&&(d$1||c||l);this.insertManagedLineBreak(e);}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0;}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak();}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),t){const t=document.createElement("img");t.setAttribute("data-lexical-linebreak","true"),t.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",t.alt="",n.insertBefore(t,i),n.__lexicalLineBreak=t;}else n.__lexicalLineBreak=i;}getFirstChildOffset(){let t=0;for(let e=this.after;null!==e;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,n,r){if(n===this.element){const e=this.getFirstChildOffset();return [t,Math.min(e+t.getChildrenSize(),Math.max(e,r))]}const i=xi(e,n);i.push(r);const o=xi(e,this.element);let s=t.getIndexWithinParent();for(let t=0;t<o.length;t++){const e=i[t],n=o[t];if(void 0===e||e<n)break;if(e>n){s+=1;break}}return [t.getParentOrThrow(),s]}}function xi(e,n){const r=[];let i=n;for(;i!==e&&null!==i;i=i.parentNode){let t=0;for(let e=i.previousSibling;null!==e;e=e.previousSibling)t++;r.push(t);}return i!==e&&t(225),r.reverse()}class Ci extends Mn{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle="";}afterCloneFrom(t){super.afterCloneFrom(t),this.__key===t.__key&&(this.__first=t.__first,this.__last=t.__last,this.__size=t.__size),this.__indent=t.__indent,this.__format=t.__format,this.__style=t.__style,this.__dir=t.__dir,this.__textFormat=t.__textFormat,this.__textStyle=t.__textStyle;}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return J$5[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const t=ii()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];let e=this.getFirstChild();for(;null!==e;){if(lr(e)&&t.push(e),Si(e)){const n=e.getAllTextNodes();t.push(...n);}e=e.getNextSibling();}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Si(t);){const e=t.getFirstChild();if(null===e)break;t=e;}return t}getLastDescendant(){let t=this.getLastChild();for(;Si(t);){const e=t.getLastChild();if(null===e)break;t=e;}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>
vendor: 2,106 bytes, line 4593
4593=n){const t=e[n-1];return Si(t)&&t.getLastDescendant()||t||null}const r=e[t];return Si(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:xo(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:xo(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,r;if(t<e/2){for(n=this.getFirstChild(),r=0;null!==n&&r<=t;){if(r===t)return n;n=n.getNextSibling(),r++;}return null}for(n=this.getLastChild(),r=e-1;null!==n&&r>=t;){if(r===t)return n;n=n.getPreviousSibling(),r--;}return null}getTextContent(){let t="";const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContent(),Si(i)&&r!==n-1&&!i.isInline()&&(t+=D$4);}return t}getTextContentSize(){let t=0;const e=this.getChildren(),n=e.length;for(let r=0;r<n;r++){const i=e[r];t+=i.getTextContentSize(),Si(i)&&r!==n-1&&!i.isInline()&&(t+=2);}return t}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(t){if(""!==t){const e=W$7[t];return 0!==(this.getFormat()&e)}return false}hasTextFormat(t){const e=R$6[t];return 0!==(this.getTextFormat()&e)}getFormatFlags(t,e){return fo(this.getLatest().__textFormat,t,e)}getTextStyle(){return this.getLatest().__textStyle}select(t,e){ei();const n=Lr();let r=t,i=e;const o=this.getChildrenSize();if(!this.canBeEmpty())if(0===t&&0===e){const t=this.getFirstChild();if(lr(t)||Si(t))return t.select(0,0)}else if(!(void 0!==t&&t!==o||void 0!==e&&e!==o)){const t=this.getLastChild();if(lr(t)||Si(t))return t.select()} void 0===r&&(r=o),void 0===i&&(i=o);const s=this.__key;return yr(n)?(n.anchor.set(s,r,"element"),n.focus.set(s,i,"element"),n.dirty=true,n):Mr(s,r,s,i,"element","element")}selectStart(){const t=this.getFirstDescendant();return t?t.selectStart():this.select()}selectEnd(){const t=this.getLastDescendant();return t?t.selectEnd():this.select()}clear(){const t=this.getWritable();
4593return this.getChildren().forEach(t=>t.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t?W$7[t]:0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,r){On(this)&&t(324,this.__key,this.__type);const i=this.getChildrenSize(),o=this.getWritable();e+n<=i||t(226,String(e),String(n),String(i));const s=o.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=i-n+r.length;if(0!==e)if(e===i)u=this.getLastChild();else {const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling());}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let r=0;r<n;r++){null===e&&t(100);const n=e.getNextSibling(),r=e.__key;_o(e.getWritable()),c.push(r),e=n;}}let d=u;for(const e of r){null!==d&&e.is(d)&&(u=d=d.getPreviousSibling());const n=e.getWritable();n.__parent===s&&f--,_o(n);const r=e.__key;if(null===d)o.__first=r,n.__prev=null;else {const t=d.getWritable();t.__next=r,n.__prev=t.__key;}e.__key===s&&t(76),n.__parent=s,l.push(r),d=e;}if(e+n===i){if(null!==d){d.getWritable().__next=null,o.__last=d.__key;}}else if(null!==a){const t=a.getWritable();if(null!==d){const e=d.getWritable();t.__prev=d.__key,e.__next=a.__key;}else t.__prev=null;}if(o.__size=f,c.length){const t=Lr();if(yr(t)){const e=new Set(c),n=new Set(l),{anchor:r,focus:i}=t;vi(r,e,n)&&Rr(r,r.getNode(),this,u,a),vi(i,e,n)&&Rr(i,i.getNode(),this,u,a),0!==f||this.canBeEmpty()||as(this)||this.remove();}}return o}getDOMSlot(t){return new mi(t)}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){const t=this.getIndent();t>0&&(e.style.paddingInlineStart=40*t+"px");const n=this.getDirection();n&&(e.dir=n);}return {element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return true}collapseAtStart(t){return false}excludeFromCopy(t){return false}canReplaceWith(t){return true}canInsertAfter(t){return true}canBeEmpty(){return true}canInsertTextBefore(){return true}canInsertTextAfter(){return true}isInline(){return false}isShadowRoot(){return false}canMergeWith(t){return false}extractWithChild(t,e,n){return false}canMergeWhenEmpty(){return false}reconcileObservedMutation(t,e){const n=this.getDOMSlot(t);let r=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const i=e.getElementByKey(t.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling);}}}function Si(t){return t instanceof Ci}function vi(t,e,n){let r=t.getNode();for(;r;){const t=r.__key;if(e.has(t)&&!n.has(t))return true;r=r.getParent();}return false}class ki extends Mn{decorate(t,e){return null}isIsolated(){return false}isInline(){return true}isKeyboardSelectable(){return true}}function Ti(t){return t instanceof ki}class Ni extends Ci{__cachedText;static getType(){return "root"}static clone(){return new Ni}constructor(){super("root"),this.__cachedText=null;}getTopLevelElementOrThrow(){t(51);}getTextContent(){const t=this.__cachedText;return !ti()&&0!==ii()._dirtyType||null===t?super.getTextContent():t}remove(){t(52);}replace(e){t(53);}insertBefore(e){t(54);}insertAfter(e){t(55);}updateDOM(t,e){return false}splice(e,n,r){for(const e of r)Si(e)||Ti(e)||t(282);return super.splice(e,n,r)}static importJSON(t){return No().updateFromJSON(t)}collapseAtStart(){return true}}function bi(t){return t instanceof Ni}function wi(t){return new Ai(new Map(t._nodeMap))}
4593function Ei(){return new Ai(new Map([["root",new Ni]]))}function Oi(e){const n=e.exportJSON(),r=e.constructor;if(n.type!==r.getType()&&t(130,r.name),Si(e)){const i=n.children;Array.isArray(i)||t(59,r.name);const o=e.getChildren();for(let t=0;t<o.length;t++){const e=Oi(o[t]);i.push(e);}}return n}function Mi(t){return t instanceof Ai}class Ai{_nodeMap;_selection;_flushSync;_readOnly;constructor(t,e){this._nodeMap=t,this._selection=e||null,this._flushSync=false,this._readOnly=false;}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return di(e&&e.editor||null,this,t)}clone(t){const e=new Ai(this._nodeMap,void 0===t?this._selection:t);return e._readOnly=true,e}toJSON(){return di(null,this,()=>({root:Oi(No())}))}}class Pi extends Ci{static getType(){return "artificial"}createDOM(t){return document.createElement("div")}}class Di extends Ci{static getType(){return "paragraph"}static clone(t){return new Di(t.__key)}createDOM(t){const e=document.createElement("p"),n=$o(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n);}return e}updateDOM(t,e,n){return false}static importDOM(){return {p:t=>({conversion:Fi,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);}return {element:e}}static importJSON(t){return Li().updateFromJSON(t)}exportJSON(){return {...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(t,e){const n=Li();n.setTextFormat(t.format),n.setTextStyle(t.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||lr(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),true;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),true}return false}}function Fi(t){const e=Li();return t.style&&(e.setFormat(t.style.textAlign),Ps(t,e)),{node:e}}function Li(){return fs(new Di)}function Ii(t){return t instanceof Di}const Ki=0,zi=1,Ri=2,Bi=3,Wi=4;function Ji(t,e,n,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Ei(),t._pendingEditorState=r,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,t._updateTags=new Set,t._updates=[],t._blockCursorElement=null;const o=t._observer;null!==o&&(o.disconnect(),t._observer=null),null!==e&&(e.textContent=""),null!==n&&(n.textContent="",i.set("root",n));}function ji(t){const e=new Set,n=new Set;let r=t;for(;r;){const{ownNodeConfig:t}=Is(r),i=r.transform;if(!n.has(i)){n.add(i);const t=r.transform();t&&e.add(t);}if(t){const n=t.$transform;n&&e.add(n),r=t.extends;}else {const t=Object.getPrototypeOf(r);r=t.prototype instanceof Mn&&t!==Mn?t:void 0;}}return e}function $i(t){const e=t||{},n=si(),r=e.theme||{},i=void 0===t?n:e.parentEditor||null,o=e.disableEvents||false,s=Ei(),l=e.namespace||(null!==i?i._config.namespace:Ao()),c=e.editorState,a=[Ni,Xn,Bn,ar,Di,Pi,...e.nodes||[]],{onError:u,html:f}=e,d=void 0===e.editable||e.editable;let h;if(void 0===t&&null!==n)h=n._nodes;else {h=new Map;for(let t=0;t<a.length;t++){let e=a[t],n=null,r=null;if("function"!=typeof e){const t=e;e=t.replace,n=t.with,r=t.withKlass||null;}Is(e);const i=e.getType(),o=ji(e);h.set(i,{exportDOM:f&&f.export?f.export.get(e):void 0,klass:e,replace:n,replaceWithKlass:r,sharedNodeState:at$3(a[t]),transforms:o});}}const g=new Ui(s,i,h,{disableEvents:o,namespace:l,theme:r},u||console.error,function(t,e){const n=new Map,r=new Set,i=t=>{Object.keys(t).forEach(e=>{let r=n.get(e);void 0===r&&(r=[],n.set(e,r)),r.push(t[e]);});};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||r.has(e))return;r.add(e);const n=e.call(t.klass);null!==n&&i(n);}),e&&i(e),n}(h,f?f.import:void 0),d,t);return void 0!==c&&(g._pendingEditorState=c,g._dirtyType=2),g}class Ui{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(t,e,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=false,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ao(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null;}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){const e=this._listeners.update;return e.add(t),()=>{e.delete(t);}}
4593registerEditableListener(t){const e=this._listeners.editable;return e.add(t),()=>{e.delete(t);}}registerDecoratorListener(t){const e=this._listeners.decorator;return e.add(t),()=>{e.delete(t);}}registerTextContentListener(t){const e=this._listeners.textcontent;return e.add(t),()=>{e.delete(t);}}registerRootListener(t){const e=this._listeners.root;return t(this._rootElement,null),e.add(t),()=>{t(null,this._rootElement),e.delete(t);}}registerCommand(e,n,r){ void 0===r&&t(35);const i=this._commands;i.has(e)||i.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=i.get(e);void 0===o&&t(36,String(e));const s=o[r];return s.add(n),()=>{s.delete(n),o.every(t=>0===t.size)&&i.delete(e);}}registerMutationListener(t,e,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,i=this._listeners.mutation;let o=i.get(e);void 0===o&&(o=new Set,i.set(e,o)),o.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,r),()=>{o.delete(r),0===o.size&&i.delete(e);}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,r=Os(n).get(e.getType());if(!r)return;const i=new Map;for(const t of r.keys())i.set(t,"created");i.size>0&&t(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])});}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),r=[n],i=n.replaceWithKlass;if(null!=i){const t=this.registerNodeTransformToKlass(i,e);r.push(t);}return function(t,e){const n=Os(t.getEditorState()),r=[];for(const t of e){const e=n.get(t);e&&r.push(e);}if(0===r.length)return;t.update(()=>{for(const t of r)for(const e of t.keys()){const t=xo(e);t&&t.markDirty();}},null===t._pendingEditorState?{tag:Dn}:void 0);}(this,r.map(t=>t.klass.getType())),()=>{r.forEach(t=>t.transforms.delete(e));}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return Go(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=$o(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=t,Ji(this,e,t,r),null!==e&&(this._config.disableEvents||Nn$1(e),null!=n&&e.classList.remove(...n)),null!==t){const e=os(t),r=t.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,rt$3(this),this._updateTags.add(Dn),hi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;en$1.set(t,n);const r=nn$1.get(n)??0;r<1&&n.addEventListener("selectionchange",Sn$1),nn$1.set(n,r+1),t.__lexicalEditor=e;const i=xn(t);for(let n=0;n<Ge$2.length;n++){const[r,o]=Ge$2[n],s="function"==typeof o?t=>{kn(t)||(vn(t),(e.isEditable()||"click"===r)&&o(t,e));}:t=>{if(kn(t))return;vn(t);const n=e.isEditable();switch(r){case "cut":return n&&Go(e,Be$2,t);case "copy":return Go(e,Re$2,t);case "paste":return n&&Go(e,fe$1,t);case "dragstart":return n&&Go(e,Ie$2,t);case "dragover":return n&&Go(e,Ke$2,t);case "dragend":return n&&Go(e,ze$2,t);case "focus":return n&&Go(e,Ve$1,t);case "blur":return n&&Go(e,Ye,t);case "drop":return n&&Go(e,Fe$2,t)}};t.addEventListener(r,s),i.push(()=>{t.removeEventListener(r,s);});}}(t,this),null!=n&&t.classList.add(...n);}else this._window=null,this._updateTags.add(Dn),hi(this);gi("root",this,false,t,e);}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let r=e;r._readOnly&&(r=wi(e),r._selection=e._selection?e._selection.clone():null),nt$4(this);const i=this._pendingEditorState,o=this._updateTags,s=void 0!==n?n.tag:null;null===i||i.isEmpty()||(null!=s&&o.add(s),hi(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",false),this._compositionKey=null,null!=s&&o.add(s),this._updating||hi(this);}parseEditorState(t,e){return function(t,e,n){const r=Ei(),i=qr,o=Gr,s=Hr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,qr=r,Gr=false,Hr=e,Yi(null);try{const i=e._nodes;fi(t.root,i),n&&n(),r._readOnly=!0;}catch(t){t instanceof Error&&e._onError(t);}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,qr=i,Gr=o,Hr=s;}return r}("string"==typeof t?JSON.parse(t):t,this,e)}read(t){return hi(this),this.getEditorState().read(t,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):pi(t,e,n);}(this,t,e);}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),yi(this,()=>{const r=Lr(),i=No();null!==r?r.dirty||wo(r.clone()):0!==i.getChildrenSize()&&("rootStart"===e.defaultSelection?i.selectStart():i.selectEnd()),ns("focus"),rs(()=>{n.removeAttribute("autocapitalize"),t&&t();});}
4593),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"));}blur(){const t=this._rootElement;null!==t&&t.blur();const e=ps(this._window);null!==e&&e.removeAllRanges();}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,gi("editable",this,true,t));}toJSON(){return {editorState:this._editorState.toJSON()}}}Ui.version="0.38.2+prod.esm";let Vi=null;function Yi(t){Vi=t;}let qi=1;function Gi(e,n){const r=Xi(e,n);return void 0===r&&t(30,n),r}function Xi(t,e){return t._nodes.get(e)}const Qi="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t);};function Zi(t){return Ti(vo(t))}function to(t){const e=document.activeElement;if(!Cs(e))return false;const n=e.nodeName;return Ti(vo(t))&&("INPUT"===n||"TEXTAREA"===n||"true"===e.contentEditable&&null==io(e))}function eo(t,e,n){const r=t.getRootElement();try{return null!==r&&r.contains(e)&&r.contains(n)&&null!==e&&!to(e)&&ro(e)===t}catch(t){return false}}function no(t){return t instanceof Ui}function ro(t){let e=t;for(;null!=e;){const t=io(e);if(no(t))return t;e=Zo(e);}return null}function io(t){return t?t.__lexicalEditor:null}function oo(t){return K$5.test(t)?"rtl":z$5.test(t)?"ltr":null}function so(t){return fr(t)||t.isToken()}function lo(t){return so(t)||t.isSegmented()}function co(t){return Ss(t)&&3===t.nodeType}function ao(t){return Ss(t)&&9===t.nodeType}function uo(t){let e=t;for(;null!=e;){if(co(e))return e;e=e.firstChild;}return null}function fo(t,e,n){const r=R$6[e];if(null!==n&&(t&r)===(n&r))return t;let i=t^r;return "subscript"===e?i&=-65:"superscript"===e?i&=-33:"lowercase"===e?(i&=-513,i&=-1025):"uppercase"===e?(i&=-257,i&=-1025):"capitalize"===e&&(i&=-257,i&=-513),i}function ho(t){return lr(t)||jn(t)||Ti(t)}function go(t,e){const n=function(){const t=Vi;return Vi=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);ei(),ni();const r=ii(),i=ri(),o=""+qi++;i._nodeMap.set(o,t),Si(t)?r._dirtyElements.set(o,true):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,t.__key=o;}function _o(t){const e=t.getParent();if(null!==e){const n=t.getWritable(),r=e.getWritable(),i=t.getPreviousSibling(),o=t.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,c=null!==i?i.getWritable():null,a=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--;}}function po(e){ni(),On(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),r=n.__parent,i=ri(),o=ii(),s=i._nodeMap,l=o._dirtyElements;null!==r&&function(t,e,n){let r=t;for(;null!==r;){if(n.has(r))return;const t=e.get(r);if(void 0===t)break;n.set(r,false),r=t.__parent;}}(r,s,l);const c=n.__key;o._dirtyType=1,Si(e)?l.set(c,true):o._dirtyLeaves.add(c);}function yo(t){ei();const e=ii(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=xo(n);null!==t&&t.getWritable();}if(null!==t){const e=xo(t);null!==e&&e.getWritable();}}}function mo(){if(ti())return null;return ii()._compositionKey}function xo(t,e){const n=(e||ri())._nodeMap.get(t);return void 0===n?null:n}function Co(t,e){const n=So(t,ii());return void 0!==n?xo(n,e):null}function So(t,e){return t[`__lexicalKey_${e._key}`]}function vo(t,e){let n=t;for(;null!=n;){const t=Co(n,e);if(null!==t)return t;n=Zo(n);}return null}function ko(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function To(t){return t.read(()=>No().getTextContent())}function No(){return bo(ri())}function bo(t){return t._nodeMap.get("root")}function wo(t){ei();const e=ri();null!==t&&(t.dirty=true,t.setCachedNodes(null)),e._selection=t;}function Eo(t){const e=ii(),n=function(t,e){let n=t;for(;null!=n;){const t=So(n,e);if(void 0!==t)return t;n=Zo(n);}return null}(t,e);if(null===n){return t===e.getRootElement()?xo("root"):null}return xo(n)}function Oo(t){return /[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Mo(t){const e=[];let n=t;for(;null!==n;)e.push(n),n=n._parentEditor;return e}function Ao(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Po(t){return co(t)?t.nodeValue:null}function Do(t,e,n){const r=ps(ss(e));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let e=Po(i);const r=vo(i);if(null!==e&&lr(r)){if(e===P$3&&n){const t=n.length;e=n,o=t,s=t;}null!==e&&Fo(r,e,o,s,t);}}}function Fo(t,e,n,r,i){let o=t;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let a=e;(s||i)&&e[e.length-1]===P$3&&(a=e.slice(0,-1));const u=o.getTextContent();if(i||a!==u){if(""===a){if(yo(null),l||c||d$1)o.remove();else {const t=ii();setTimeout(()=>{t.update(()=>{o.isAttached()&&o.remove();});},20);}return}const e=o.getParent(),i=Ir(),u=o.getTextContentSize(),f=mo(),h=o.getKey();if(o.isToken()||null!==f&&h===f&&!s||yr(i)&&(null!==e&&!e.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===t.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!s||i.focus.key===t.__key&&i.focus.offset===u&&!o.canInsertTextAfter()&&!s))return void o.markDirty();const g=Lr();if(!yr(g)||null===n||null===r)return void Lo(o,a,g);if(g.setTextNodeRange(o,n,o,r),o.isSegmented()){const t=sr(o.getTextContent());o.replace(t),o=t;}Lo(o,a,g);}}}function Lo(t,e,n){if(t.setTextContent(e),yr(n)){const e=t.getKey();for(const r of ["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=nl(t,i.offset,"clamp"));}}}function Io(t,e,n){const r=e[n]||false;return "any"===r||r===t[n]}function Ko(t,e){return Io(t,e,"altKey")&&Io(t,e,"ctrlKey")&&Io(t,e,"shiftKey")&&Io(t,e,"metaKey")}function zo(t,e,n){return Ko(t,n)&&t.key.toLowerCase()===e.toLowerCase()}const Ro={ctrlKey:!i,metaKey:i},Bo={altKey:i,ctrlKey:!i};function Wo(t){return "Backspace"===t.key}function Jo(t){return zo(t,"a",Ro)}function jo(t){const e=No();if(yr(t)){const e=t.anchor,n=t.focus,r=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),St$6(t),t}{const t=e.select(0,e.getChildrenSize());return wo(St$6(t)),t}}
vendor: 15,807 bytes, line 4593
4593function $o(t,e){ void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,r=n[e];if(void 0!==r)return r;const i=t[e];if("string"==typeof i){const t=h$1(i);return n[e]=t,t}return i}function Uo(e,n,r,i,o){if(0===r.size)return;const s=i.__type,l=i.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===o;(void 0===f||d)&&u.set(l,d?"updated":o);}function Yo(t,e,n){const r=t.getParent();let i=n,o=t;return null!==r&&(e&&0===n?(i=o.getIndexWithinParent(),o=r):e||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(e?i-1:i)}function qo(t,e){const n=t.offset;if("element"===t.type){return Yo(t.getNode(),e,n)}{const r=t.getNode();if(e&&0===n||!e&&n===r.getTextContentSize()){const t=e?r.getPreviousSibling():r.getNextSibling();return null===t?Yo(r.getParentOrThrow(),e,r.getIndexWithinParent()+(e?0:1)):t}}return null}function Ho(t){const e=ss(t).event,n=e&&e.inputType;return "insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Go(t,e,n){return function(t,e,n){const r=Mo(t);for(let i=4;i>=0;i--)for(let o=0;o<r.length;o++){const s=r[o],l=s._commands.get(e);if(void 0!==l){const e=l[i];if(void 0!==e){const r=Array.from(e),i=r.length;let o=false;if(yi(s,()=>{for(let e=0;e<i;e++)if(r[e](n,t))return void(o=true)}),o)return o}}}return false}(t,e,n)}function Xo(t){return !bi(t)&&!t.isLastChild()&&!t.isInline()}function Qo(e,n){const r=e._keyToDOMMap.get(n);return void 0===r&&t(75,n),r}function Zo(t){const e=t.assignedSlot||t.parentElement;return vs(e)?e.host:e}function ts(t){return ao(t)?t:Cs(t)?t.ownerDocument:null}function es(t){return ii()._updateTags.has(t)}function ns(t){ei();ii()._updateTags.add(t);}function rs(t){ei();ii()._deferred.push(t);}function is(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return true;n=n.getParent();}return false}function os(t){const e=ts(t);return e?e.defaultView:null}function ss(e){const n=e._window;return null===n&&t(78),n}function ls(t){return Si(t)&&t.isInline()||Ti(t)&&t.isInline()}function cs(t){let e=t.getParentOrThrow();for(;null!==e;){if(as(e))return e;e=e.getParentOrThrow();}return e}function as(t){return bi(t)||Si(t)&&t.isShadowRoot()}function us(t){const e=t.constructor.clone(t);return go(e,null),e.afterCloneFrom(t),e}function fs(e){const n=ii(),r=e.getType(),i=Xi(n,r);void 0===i&&t(200,e.constructor.name,r);const{replace:o,replaceWithKlass:s}=i;if(null!==o){const n=o(e),i=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),i.name,i.getType(),e.constructor.name,r):n instanceof e.constructor&&i!==e.constructor||t(202,i.name,i.getType(),e.constructor.name,r),n.__key===e.__key&&t(203,e.constructor.name,r,i.name,i.getType()),n}return e}function ds(e,n){!bi(e.getParent())||Si(n)||Ti(n)||t(99);}function hs(e){const n=xo(e);return null===n&&t(63,e),n}function gs(t){return (Ti(t)||Si(t)&&!t.canBeEmpty())&&!t.isInline()}function _s(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const r=t.parentElement;null!==r&&r.removeChild(t);}function ps(t){return n?(t||window).getSelection():null}function ys(t){const e=os(t);return e?e.getSelection():null}function xs(t){return Cs(t)&&"A"===t.tagName}function Cs(t){return Ss(t)&&1===t.nodeType}function Ss(t){return "object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function vs(t){return Ss(t)&&11===t.nodeType}function ks(t){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return null!==t.nodeName.match(e)}function Ts(t){const e=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return null!==t.nodeName.match(e)}function Ns(t){if(Ti(t)&&!t.isInline())return true;if(!Si(t)||as(t))return false;const e=t.getFirstChild(),n=null===e||jn(e)||lr(e)||e.isInline();return !t.isInline()&&false!==t.canBeEmpty()&&n}function bs(){return ii()}const ws=new WeakMap,Es=new Map;function Os(e){if(!e._readOnly&&e.isEmpty())return Es;e._readOnly||t(192);let n=ws.get(e);return n||(n=function(t){const e=new Map;for(const[n,r]of t._nodeMap){const t=r.__type;let i=e.get(t);i||(i=new Map,e.set(t,i)),i.set(n,r);}return e}(e),ws.set(e,n)),n}function Ms(t){const e=t.constructor.clone(t);return e.afterCloneFrom(t),e}function As(t){return (e=Ms(t))[En]=true,e;var e;}function Ps(t,e){const n=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(n/40);e.setIndent(r);}function Ds(t){t.__lexicalUnmanaged=true;}function Fs(t){return true===t.__lexicalUnmanaged}function Ls(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==Mn[e]}function Is(e){const n=V$6 in e.prototype?e.prototype[V$6]():void 0,r=function(e){if(!(e===Mn||e.prototype instanceof Mn)){let n="<unknown>",r="<unknown>";try{n=e.getType();}catch(t){}try{Ui.version&&(r=JSON.parse(Ui.version));}catch(t){}t(290,e.name,n,r);}return e===ki||e===Ci||e===Mn}(e),i=!r&&Ls(e,"getType")?e.getType():void 0;let o,s=i;if(n)if(i)o=n[i];else for(const[t,e]of Object.entries(n))s=t,o=e;if(!r&&s&&(Ls(e,"getType")||(e.getType=()=>s),Ls(e,"clone")||(e.clone=t=>(Yi(t),new e)),Ls(e,"importJSON")||(e.importJSON=o&&o.$importJSON||(t=>(new e).updateFromJSON(t))),!Ls(e,"importDOM")&&o)){const{importDOM:t}=o;t&&(e.importDOM=()=>t);}return {ownNodeConfig:o,ownNodeType:s}}function Ks(t){const e=bs();ei();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const zs=(t,e)=>{let n=t;for(;null!=n&&!bi(n);){if(e(n))return n;n=n.getParent();}return null},Rs={next:"previous",previous:"next"};class Bs{origin;constructor(t){this.origin=t;}[Symbol.iterator](){return hl({hasNext:Hs,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return tl(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return tl(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,r="next"){const i=r===this.direction?n:Array.from(n).reverse();let o=this;const s=this.getParentAtCaret(),l=new Map;for(let t=o.getAdjacentCaret();null!==t&&l.size<e;t=t.getAdjacentCaret()){const e=t.origin.getWritable();l.set(e.getKey(),e);}for(const e of i){if(l.size>0){const n=o.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||o.origin.is(e));else {const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e);}else null===n&&t(263,Array.from(l).join(" "));}else o.insert(e);o=tl(e,this.direction);}for(const t of l.values())t.remove();return this}}class Ws extends Bs{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:il(t,this.direction)}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=js(this.direction);return tl(this.getNodeAtCaret(),t)||il(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof Ws&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Js={root:bi,shadowRoot:as};function js(t){return Rs[t]}function $s(t,e="root"){return Js[e](t)?null:t}class Us extends Bs{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:tl(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Si(this.origin)?il(this.origin,this.direction):null}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=js(this.direction);return tl(this.getNodeAtCaret(),t)||il(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Us&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return (t instanceof Us||t instanceof Vs)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Vs extends Bs{type="text";offset;constructor(t,e){super(t),this.offset=e;}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:el(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return tl($s(this.getParentAtCaret(),t),this.direction)}getFlipped(){return el(this.origin,js(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Vs&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return (t instanceof Us||t instanceof Vs)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return tl(this.origin,this.direction)}}function Ys(t){return t instanceof Vs}function Hs(t){return t instanceof Us}function Gs(t){return t instanceof Ws}const Xs={next:class extends Vs{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Vs{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Qs={next:class extends Us{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Us{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Zs={next:class extends Ws{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends Ws{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function tl(t,e){return t?new Qs[e](t):null}function el(t,e,n){return t?new Xs[e](t,nl(t,n)):null}function nl(t,n,r="error"){const i=t.getTextContentSize();let o="next"===n?i:"previous"===n?0:n;return (o<0||o>i)&&("clamp"!==r&&e(284,String(n),String(i),t.getKey()),o=o<0?0:i),o}function rl(t,e){return new cl(t,e)}function il(t,e){return Si(t)?new Zs[e](t):null}function ol(t){return t&&t.getChildCaret()||t}function sl(t){return t&&ol(t.getAdjacentCaret())}class ll{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n;}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new ll(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return Ys(e)?function(t,e){const{direction:n,origin:r}=t,i=nl(r,"focus"===e?js(n):n);return rl(t,i-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:r}=n;if(t.isSameNodeCaret(r))return [rl(t,r.offset-t.offset),null]}return [e,n]}iterNodeCarets(t="root"){const e=Ys(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=Ys(n),i=e=>e.isSameNodeCaret(n)?null:sl(e)||e.getParentCaret(t);return hl({hasNext:t=>null!==t&&!(r&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:i(e),map:t=>t,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class cl{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e;}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n<e?[n,e]:[e,n]}getTextContent(){const[t,e]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(t,e)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){const{caret:{origin:t,direction:e}}=this,[n,r]=this.getSliceIndices(),i=t.getTextContent();return el(t.setTextContent(i.slice(0,n)+i.slice(r)),e,n)}}function ul(t){return dl(t,tl(No(),t.direction))}function fl(t){return dl(t,t)}function dl(e,n){return e.direction!==n.direction&&t(265),new ll(e,n,e.direction)}function hl(t){const{initial:e,hasNext:n,step:r,map:i}=t;let o=e;return {[Symbol.iterator](){return this},next(){if(!n(o))return {done:true,value:void 0};const t={done:false,value:i(o)};return o=r(o),t}}}function gl(e,n){const r=ml(e.origin,n.origin);switch(null===r&&t(275,e.origin.getKey(),n.origin.getKey()),r.type){case "same":{const t="text"===e.type,r="text"===n.type;return t&&r?function(t,e){return Math.sign(t-e)}(e.offset,n.offset):e.type===n.type?0:t?-1:r?1:"child"===e.type?-1:1}case "ancestor":return "child"===e.type?-1:1;case "descendant":return "child"===n.type?1:-1;case "branch":return _l(r)}}function _l(t){const{a:e,b:n}=t,r=e.__key,i=n.__key;let o=e,s=n;for(;o&&s;o=o.getNextSibling(),s=s.getNextSibling()){if(o.__key===i)return -1;if(s.__key===r)return 1}return null===o?1:-1}function pl(t,e){return e.is(t)}function yl(t){return Si(t)?[t.getLatest(),null]:[t.getParent(),t.getLatest()]}function ml(e,n){if(e.is(n))return {commonAncestor:e,type:"same"};const r=new Map;for(let[t,n]=yl(e);t;n=t,t=t.getParent())r.set(t,n);for(let[i,o]=yl(n);i;o=i,i=i.getParent()){const s=r.get(i);if(void 0!==s)return null===s?(pl(e,i)||t(276),{commonAncestor:i,type:"ancestor"}):null===o?(pl(n,i)||t(277),{commonAncestor:i,type:"descendant"}):((Si(s)||pl(e,s))&&(Si(o)||pl(n,o))&&i.is(s.getParent())&&i.is(o.getParent())||t(278),{a:s,b:o,commonAncestor:i,type:"branch"})}return null}function xl(e,n){const{type:r,key:i,offset:o}=e,s=hs(e.key);return "text"===r?(lr(s)||t(266,s.getType(),i),el(s,n,o)):(Si(s)||t(267,s.getType(),i),Pl(s,e.offset,n))}function Cl(e,n){const{origin:r,direction:i}=n,o="next"===i;Ys(n)?e.set(r.getKey(),n.offset,"text"):Hs(n)?lr(r)?e.set(r.getKey(),nl(r,i),"text"):e.set(r.getParentOrThrow().getKey(),r.getIndexWithinParent()+(o?1:0),"element"):(Gs(n)&&Si(r)||t(268),e.set(r.getKey(),o?0:r.getChildrenSize(),"element"));}function Sl(t){const e=Lr(),n=yr(e)?e:Ar();return vl(n,t),wo(n),n}function vl(t,e){Cl(t.anchor,e.anchor),Cl(t.focus,e.focus);}function kl(t){const{anchor:e,focus:n}=t,r=xl(e,"next"),i=xl(n,"next"),o=gl(r,i)<=0?"next":"previous";return dl(Ml(r,o),Ml(i,o))}function Tl(t){const{direction:e,origin:n}=t,r=tl(n,js(e)).getNodeAtCaret();return r?tl(r,e):il(n.getParentOrThrow(),e)}function Nl(t,e="root"){const n=[t];for(let r=Gs(t)?t.getParentCaret(e):t.getSiblingCaret();null!==r;r=r.getParentCaret(e))n.push(Tl(r));return n}function bl(t){return !!t&&t.origin.isAttached()}function wl(e,n="removeEmptySlices"){if(e.isCollapsed())return e;const r="root",i="next";let o=n;const s=Al(e,i),l=Nl(s.anchor,r),c=Nl(s.focus.getFlipped(),r),a=new Set,u=[];for(const t of s.iterNodeCarets(r))if(Gs(t))a.add(t.origin.getKey());else if(Hs(t)){const{origin:e}=t;Si(e)&&!a.has(e.getKey())||u.push(e);}for(const t of u)t.remove();for(const t of s.getTextSlices()){if(!t)continue;const{origin:e}=t.caret,n=e.getTextContentSize(),r=Tl(tl(e,i)),s=e.getMode();if(Math.abs(t.distance)===n&&"removeEmptySlices"===o||"token"===s&&0!==t.distance)r.remove();else if(0!==t.distance){o="removeEmptySlices";let e=t.removeTextSlice();const n=t.caret.origin;if("segmented"===s){const t=e.origin,n=sr(t.getTextContent()).setStyle(t.getStyle()).setFormat(t.getFormat());r.replaceOrInsert(n),e=el(n,i,e.offset);}n.is(l[0].origin)&&(l[0]=e),n.is(c[0].origin)&&(c[0]=e.getFlipped());}}let f,d;for(const t of l)if(bl(t)){f=El(t);break}for(const t of c)if(bl(t)){d=El(t);break}const h=function(t,e,n){if(!t||!e)return null;const r=t.getParentAtCaret(),i=e.getParentAtCaret();if(!r||!i)return null;const o=r.getParents().reverse();o.push(r);const s=i.getParents().reverse();s.push(i);const l=Math.min(o.length,s.length);let c;for(c=0;c<l&&o[c]===s[c];c++);const a=(t,e)=>{let n;for(let r=c;r<t.length;r++){const i=t[r];
4593if(as(i))return;!n&&e(i)&&(n=i);}return n},u=a(o,Ns),f=u&&a(s,t=>n.has(t.getKey())&&Ns(t));return u&&f?[u,f]:null}(f,d,a);if(h){const[t,e]=h;il(t,"previous").splice(0,e.getChildren()),e.remove();}const g=[f,d,...l,...c].find(bl);if(g){return fl(Ml(El(g),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)));}function El(t){const e=function(t){let e=t;for(;Gs(e);){const t=sl(e);if(!Gs(t))break;e=t;}return e}(t.getLatest()),{direction:n}=e;if(lr(e.origin))return Ys(e)?e:el(e.origin,n,n);const r=e.getAdjacentCaret();return Hs(r)&&lr(r.origin)?el(r.origin,n,js(n)):e}function Ol(t){return Ys(t)&&t.offset!==nl(t.origin,t.direction)}function Ml(t,e){return t.direction===e?t:t.getFlipped()}function Al(t,e){return t.direction===e?t:dl(Ml(t.focus,e),Ml(t.anchor,e))}function Pl(t,e,n){let r=il(t,"next");for(let t=0;t<e;t++){const t=r.getAdjacentCaret();if(null===t)break;r=t;}return Ml(r,n)}function Fl(e){const{origin:n,offset:r,direction:i}=e;if(r===nl(n,i))return e.getSiblingCaret();if(r===nl(n,js(i)))return Tl(e.getSiblingCaret());const[o]=n.splitText(r);return lr(o)||t(281),Ml(tl(o,"next"),i)}function Ll(t,e){return true}function Il(t,{$copyElementNode:e=us,$splitTextPointCaretNext:n=Fl,rootMode:r="shadowRoot",$shouldSplit:i=Ll}={}){if(Ys(t))return n(t);const o=t.getParentCaret(r);if(o){const{origin:n}=o;if(Gs(t)&&(!n.canBeEmpty()||!i(n,"first")))return Tl(o);const r=function(t){const e=[];for(let n=t.getAdjacentCaret();n;n=n.getAdjacentCaret())e.push(n.origin);return e}(t);(r.length>0||n.canBeEmpty()&&i(n,"last"))&&o.insert(e(n).splice(0,0,r));}return o}function Kl(t){return t}function zl(...t){return t}function Bl(t){return t}function Wl(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return {...t,...e};return t} 4594 4595/** 4596 * Copyright (c) Meta Platforms, Inc. and affiliates. 4597 * 4598 * This source code is licensed under the MIT license found in the 4599 * LICENSE file in the root directory of this source tree. 4600 * 4601 */ 4602 4603function K$4(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const P$2=new Map;function F$4(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim());}return t}function b$3(e){let t=P$2.get(e);return void 0===t&&(t=F$4(e),P$2.set(e,t)),t}function R$5(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function O$1(e){const n=bs().getElementByKey(e.getKey());if(null===n)return null;const o=n.ownerDocument.defaultView;return null===o?null:o.getComputedStyle(n)}function z$4(e){return O$1(bi(e)?e:e.getParentOrThrow())}function A$2(e){const t=z$4(e);return null!==t&&"rtl"===t.direction}function M$4(e,t,n="self"){const o=e.getStartEndPoints();if(t.isSelected(e)&&!lo(t)&&null!==o){const[l,r]=o,s=e.isBackward(),i=l.getNode(),c=r.getNode(),f=t.is(i),u=t.is(c);if(f||u){const[o,l]=Sr(e),r=i.is(c),f=t.is(s?c:i),u=t.is(s?i:c);let d,p=0;if(r)p=o>l?l:o,d=o>l?o:l;else if(f){p=s?l:o,d=void 0;}else if(u){p=0,d=s?o:l;}const h=t.__text.slice(p,d);h!==t.__text&&("clone"===n&&(t=As(t)),t.__text=h);}}return t}function $$3(e){const t=e.getStyle(),n=F$4(t);P$2.set(t,n);}function D$3(t,n){(yr(t)?t.isCollapsed():lr(t)||Si(t))||K$4(280);const l=b$3(yr(t)?t.style:lr(t)?t.getStyle():t.getTextStyle()),r=Object.entries(n).reduce((e,[n,o])=>("function"==typeof o?e[n]=o(l[n],t):null===o?delete e[n]:e[n]=o,e),{...l}),s=R$5(r);yr(t)||lr(t)?t.setStyle(s):t.setTextStyle(s),P$2.set(s,r);}function U$5(e,t){if(yr(e)&&e.isCollapsed()){D$3(e,t);const n=e.anchor.getNode();Si(n)&&n.isEmpty()&&D$3(n,t);}j$3(e=>{D$3(e,t);});}function j$3(t){const n=Lr();if(!n)return;const o=new Map,l=e=>o.get(e.getKey())||[0,e.getTextContentSize()];if(yr(n))for(const e of kl(n).getTextSlices())e&&o.set(e.caret.origin.getKey(),e.getSliceIndices());const r=n.getNodes();for(const n of r){if(!lr(n)||!n.canHaveFormat())continue;const[o,r]=l(n);if(r!==o)if(lo(n)||0===o&&r===n.getTextContentSize())t(n);else {t(n.splitText(o,r)[0===o?0:1]);}}yr(n)&&"text"===n.anchor.type&&"text"===n.focus.type&&n.anchor.key===n.focus.key&&H$2(n);}function H$2(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:l,type:r}=t;t.set(n.key,n.offset,n.type),n.set(o,l,r);}}function Q$4(e){const t=Y$3(e);return null!==t&&"vertical-rl"===t.writingMode}function Y$3(e){const t=e.anchor.getNode();return Si(t)?O$1(t):z$4(t)}function Z$3(e,t){let n=Q$4(e)?!t:t;te(e)&&(n=!n);
4603const l=xl(e.focus,n?"previous":"next");if(Ol(l))return false;for(const e of ul(l)){if(Gs(e))return !e.origin.isInline();if(!Si(e.origin)){if(Ti(e.origin))return true;break}}return false}function ee(e,t,n,o){e.modify(t?"extend":"move",n,o);}function te(e){const t=Y$3(e);return null!==t&&"rtl"===t.direction}function ne(e,t,n){const o=te(e);let l;l=Q$4(e)||o?!n:n,ee(e,t,l,"character");}function oe$1(e,t,n){const o=b$3(e.getStyle());return null!==o&&o[t]||n}function le$1(t,n,o=""){let l=null;const r=t.getNodes(),s=t.anchor,c=t.focus,f=t.isBackward(),u=f?c.offset:s.offset,g=f?c.getNode():s.getNode();if(yr(t)&&t.isCollapsed()&&""!==t.style){const e=b$3(t.style);if(null!==e&&n in e)return e[n]}for(let t=0;t<r.length;t++){const s=r[t];if((0===t||0!==u||!s.is(g))&&lr(s)){const e=oe$1(s,n,o);if(null===l)l=e;else if(l!==e){l="";break}}}return null===l?o:l} 4604 4605function deepMerge(target, source) { 4606 const result = { ...target, ...source }; 4607 for (const [ key, value ] of Object.entries(source)) { 4608 if (arePlainHashes(target[key], value)) { 4609 result[key] = deepMerge(target[key], value); 4610 } 4611 } 4612 4613 return result 4614} 4615 4616function arePlainHashes(...values) { 4617 return values.every(value => value && value.constructor == Object) 4618} 4619 4620class Configuration { 4621 #tree = {} 4622 4623 constructor(...configs) { 4624 this.merge(...configs); 4625 } 4626 4627 merge(...configs) { 4628 return this.#tree = configs.reduce(deepMerge, this.#tree) 4629 } 4630 4631 get(path) { 4632 const keys = path.split("."); 4633 return keys.reduce((node, key) => node[key], this.#tree) 4634 } 4635} 4636 4637function range(from, to) { 4638 return [ ...Array(1 + to - from).keys() ].map(i => i + from) 4639} 4640 4641const global$1 = new Configuration({ 4642 attachmentTagName: "action-text-attachment", 4643 attachmentContentTypeNamespace: "actiontext", 4644 authenticatedUploads: false, 4645 extensions: [] 4646}); 4647 4648const presets = new Configuration({ 4649 default: { 4650 attachments: true, 4651 markdown: true, 4652 multiLine: true, 4653 richText: true, 4654 toolbar: true, 4655 highlight: { 4656 buttons: { 4657 color: range(1, 9).map(n => `var(--highlight-${n})`), 4658 "background-color": range(1, 9).map(n => `var(--highlight-bg-${n})`), 4659 }, 4660 permit: { 4661 color: [], 4662 "background-color": [] 4663 } 4664 } 4665 } 4666}); 4667 4668var Lexxy = { 4669 global: global$1, 4670 presets, 4671 configure({ global: newGlobal, ...newPresets }) { 4672 if (newGlobal) { 4673 global$1.merge(newGlobal); 4674 } 4675 presets.merge(newPresets); 4676 } 4677}; 4678 4679const ALLOWED_HTML_TAGS = [ "a", "b", "blockquote", "br", "code", "em", 4680 "figcaption", "figure", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "li", "mark", "ol", "p", "pre", "q", "s", "strong", "ul", "table", "tbody", "tr", "th", "td" ]; 4681 4682const ALLOWED_HTML_ATTRIBUTES = [ "alt", "caption", "class", "content", "content-type", "contenteditable", 4683 "data-direct-upload-id", "data-sgid", "filename", "filesize", "height", "href", "presentation", 4684 "previewable", "sgid", "src", "style", "title", "url", "width" ]; 4685 4686const ALLOWED_STYLE_PROPERTIES = [ "color", "background-color" ]; 4687 4688function styleFilterHook(_currentNode, hookEvent) { 4689 if (hookEvent.attrName === "style" && hookEvent.attrValue) { 4690 const styles = { ...b$3(hookEvent.attrValue) }; 4691 const sanitizedStyles = { }; 4692 4693 for (const property in styles) { 4694 if (ALLOWED_STYLE_PROPERTIES.includes(property)) { 4695 sanitizedStyles[property] = styles[property]; 4696 } 4697 } 4698 4699 if (Object.keys(sanitizedStyles).length) { 4700 hookEvent.attrValue = R$5(sanitizedStyles); 4701 } else { 4702 hookEvent.keepAttr = false; 4703 } 4704 } 4705} 4706 4707purify.addHook("uponSanitizeAttribute", styleFilterHook); 4708 4709purify.addHook("uponSanitizeElement", (node, data) => { 4710 if (data.tagName === "strong" || data.tagName === "em") { 4711 node.removeAttribute("class"); 4712 } 4713}); 4714 4715function buildConfig() { 4716 return { 4717 ALLOWED_TAGS: ALLOWED_HTML_TAGS.concat(Lexxy.global.get("attachmentTagName")), 4718 ALLOWED_ATTR: ALLOWED_HTML_ATTRIBUTES, 4719 ADD_URI_SAFE_ATTR: [ "caption", "filename" ], 4720 SAFE_FOR_XML: false // So that it does not strip attributes that contains serialized HTML (like content) 4721 } 4722} 4723 4724function getNonce() { 4725 const element = document.head.querySelector("meta[name=csp-nonce]"); 4726 return element?.content 4727} 4728 4729function handleRollingTabIndex(elements, event) { 4730 const previousActiveElement = document.activeElement; 4731 4732 if (elements.includes(previousActiveElement)) { 4733 const finder = new NextElementFinder(elements, event.key); 4734 4735 if (finder.selectNext(previousActiveElement)) { 4736 event.preventDefault(); 4737 } 4738 } 4739} 4740 4741class NextElementFinder { 4742 constructor(elements, key) { 4743 this.elements = elements; 4744 this.key = key; 4745 } 4746 4747 selectNext(fromElement) { 4748 const nextElement = this.#findNextElement(fromElement); 4749 4750 if (nextElement) { 4751 const inactiveElements = this.elements.filter(element => element !== nextElement); 4752 this.#unsetTabIndex(inactiveElements); 4753 this.#focusWithActiveTabIndex(nextElement); 4754 return true 4755 } 4756 4757 return false 4758 } 4759 4760 #findNextElement(fromElement) { 4761 switch (this.key) { 4762 case "ArrowRight": 4763 case "ArrowDown": 4764 return this.#findNextSibling(fromElement) 4765 4766 case "ArrowLeft": 4767 case "ArrowUp": 4768 return this.#findPreviousSibling(fromElement) 4769 4770 case "Home": 4771 return this.#findFirst() 4772 4773 case "End": 4774 return this.#findLast() 4775 } 4776 } 4777 4778 #findFirst(elements = this.elements) { 4779 return elements.find(isActiveAndVisible) 4780 } 4781 4782 #findLast(elements = this.elements) { 4783 return elements.findLast(isActiveAndVisible) 4784 } 4785 4786 #findNextSibling(element) { 4787 const afterElements = this.elements.slice(this.#indexOf(element) + 1); 4788 return this.#findFirst(afterElements) 4789 } 4790 4791 #findPreviousSibling(element) { 4792 const beforeElements = this.elements.slice(0, this.#indexOf(element)); 4793 return this.#findLast(beforeElements) 4794 } 4795 4796 #indexOf(element) { 4797 return this.elements.indexOf(element) 4798 } 4799 4800 #focusWithActiveTabIndex(element) { 4801 if (isActiveAndVisible(element)) { 4802 element.tabIndex = 0; 4803 element.focus(); 4804 } 4805 } 4806 4807 #unsetTabIndex(elements) {
4808 elements.forEach(element => element.tabIndex = -1); 4809 } 4810} 4811 4812function isActiveAndVisible(element) { 4813 return element && !element.disabled && element.checkVisibility() 4814} 4815 4816class LexicalToolbarElement extends HTMLElement { 4817 static observedAttributes = [ "connected" ] 4818 4819 constructor() { 4820 super(); 4821 this.internals = this.attachInternals(); 4822 this.internals.role = "toolbar"; 4823 4824 this.#createEditorPromise(); 4825 } 4826 4827 connectedCallback() { 4828 requestAnimationFrame(() => this.#refreshToolbarOverflow()); 4829 this.setAttribute("role", "toolbar"); 4830 this.#installResizeObserver(); 4831 } 4832 4833 disconnectedCallback() { 4834 this.#uninstallResizeObserver(); 4835 this.#unbindHotkeys(); 4836 this.#unbindFocusListeners(); 4837 } 4838 4839 attributeChangedCallback(name, oldValue, newValue) { 4840 if (name === "connected" && this.isConnected && oldValue != null && oldValue !== newValue) { 4841 requestAnimationFrame(() => this.#reconnect()); 4842 } 4843 } 4844 4845 setEditor(editorElement) { 4846 this.editorElement = editorElement; 4847 this.editor = editorElement.editor; 4848 this.selection = editorElement.selection; 4849 this.#bindButtons(); 4850 this.#bindHotkeys(); 4851 this.#resetTabIndexValues(); 4852 this.#setItemPositionValues(); 4853 this.#monitorSelectionChanges(); 4854 this.#monitorHistoryChanges(); 4855 this.#refreshToolbarOverflow(); 4856 this.#bindFocusListeners(); 4857 4858 this.resolveEditorPromise(editorElement); 4859 4860 this.toggleAttribute("connected", true); 4861 } 4862 4863 async getEditorElement() { 4864 return this.editorElement || await this.editorPromise 4865 } 4866 4867 #reconnect() { 4868 this.disconnectedCallback(); 4869 this.connectedCallback(); 4870 } 4871 4872 #createEditorPromise() { 4873 this.editorPromise = new Promise((resolve) => { 4874 this.resolveEditorPromise = resolve; 4875 }); 4876 } 4877 4878 #installResizeObserver() { 4879 this.resizeObserver = new ResizeObserver(() => this.#refreshToolbarOverflow()); 4880 this.resizeObserver.observe(this); 4881 } 4882 4883 #uninstallResizeObserver() { 4884 if (this.resizeObserver) { 4885 this.resizeObserver.disconnect(); 4886 this.resizeObserver = null; 4887 } 4888 } 4889 4890 #bindButtons() { 4891 this.addEventListener("click", this.#handleButtonClicked.bind(this)); 4892 } 4893 4894 #handleButtonClicked(event) { 4895 this.#handleTargetClicked(event, "[data-command]", this.#dispatchButtonCommand.bind(this)); 4896 } 4897 4898 #handleTargetClicked(event, selector, callback) { 4899 const button = event.target.closest(selector); 4900 if (button) { 4901 callback(event, button); 4902 } 4903 } 4904 4905 #dispatchButtonCommand(event, { dataset: { command, payload } }) { 4906 const isKeyboard = event instanceof PointerEvent && event.pointerId === -1; 4907 4908 this.editor.update(() => { 4909 this.editor.dispatchCommand(command, payload); 4910 }, { tag: isKeyboard ? zn : undefined }); 4911 } 4912 4913 #bindHotkeys() { 4914 this.editorElement.addEventListener("keydown", this.#handleHotkey); 4915 } 4916 4917 #unbindHotkeys() { 4918 this.editorElement?.removeEventListener("keydown", this.#handleHotkey); 4919 } 4920 4921 #handleHotkey = (event) => { 4922 const buttons = this.querySelectorAll("[data-hotkey]"); 4923 buttons.forEach((button) => { 4924 const hotkeys = button.dataset.hotkey.toLowerCase().split(/\s+/); 4925 if (hotkeys.includes(this.#keyCombinationFor(event))) { 4926 event.preventDefault(); 4927 event.stopPropagation(); 4928 button.click(); 4929 } 4930 }); 4931 } 4932 4933 #keyCombinationFor(event) { 4934 const pressedKey = event.key.toLowerCase(); 4935 const modifiers = [ 4936 event.ctrlKey ? "ctrl" : null, 4937 event.metaKey ? "cmd" : null, 4938 event.altKey ? "alt" : null, 4939 event.shiftKey ? "shift" : null, 4940 ].filter(Boolean); 4941 4942 return [ ...modifiers, pressedKey ].join("+") 4943 } 4944 4945 #bindFocusListeners() { 4946 this.editorElement.addEventListener("lexxy:focus", this.#handleEditorFocus); 4947 this.editorElement.addEventListener("lexxy:blur", this.#handleEditorBlur); 4948 this.addEventListener("keydown", this.#handleKeydown); 4949 } 4950 4951 #unbindFocusListeners() { 4952 this.editorElement.removeEventListener("lexxy:focus", this.#handleEditorFocus); 4953 this.editorElement.removeEventListener("lexxy:blur", this.#handleEditorBlur); 4954 this.removeEventListener("keydown", this.#handleKeydown); 4955 } 4956 4957 #handleEditorFocus = () => { 4958 this.#focusableItems[0].tabIndex = 0; 4959 } 4960 4961 #handleEditorBlur = () => { 4962 this.#resetTabIndexValues(); 4963 this.#closeDropdowns(); 4964 } 4965 4966 #handleKeydown = (event) => { 4967 handleRollingTabIndex(this.#focusableItems, event); 4968 } 4969 4970 #resetTabIndexValues() {
4971 this.#focusableItems.forEach((button) => { 4972 button.tabIndex = -1; 4973 }); 4974 } 4975 4976 #monitorSelectionChanges() { 4977 this.editor.registerUpdateListener(() => { 4978 this.editor.getEditorState().read(() => { 4979 this.#updateButtonStates(); 4980 this.#closeDropdowns(); 4981 }); 4982 }); 4983 } 4984 4985 #monitorHistoryChanges() { 4986 this.editor.registerUpdateListener(() => { 4987 this.#updateUndoRedoButtonStates(); 4988 }); 4989 } 4990 4991 #updateUndoRedoButtonStates() { 4992 this.editor.getEditorState().read(() => { 4993 const historyState = this.editorElement.historyState; 4994 if (historyState) { 4995 this.#setButtonDisabled("undo", historyState.undoStack.length === 0); 4996 this.#setButtonDisabled("redo", historyState.redoStack.length === 0); 4997 } 4998 }); 4999 } 5000 5001 #updateButtonStates() { 5002 const selection = Lr(); 5003 if (!yr(selection)) return 5004 5005 const anchorNode = selection.anchor.getNode(); 5006 if (!anchorNode.getParent()) { return } 5007 5008 const { isBold, isItalic, isStrikethrough, isHighlight, isInLink, isInQuote, isInHeading, 5009 isInCode, isInList, listType, isInTable } = this.selection.getFormat(); 5010 5011 this.#setButtonPressed("bold", isBold); 5012 this.#setButtonPressed("italic", isItalic); 5013 this.#setButtonPressed("strikethrough", isStrikethrough); 5014 this.#setButtonPressed("highlight", isHighlight); 5015 this.#setButtonPressed("link", isInLink); 5016 this.#setButtonPressed("quote", isInQuote); 5017 this.#setButtonPressed("heading", isInHeading); 5018 this.#setButtonPressed("code", isInCode); 5019 this.#setButtonPressed("unordered-list", isInList && listType === "bullet"); 5020 this.#setButtonPressed("ordered-list", isInList && listType === "number"); 5021 this.#setButtonPressed("table", isInTable); 5022 5023 this.#updateUndoRedoButtonStates(); 5024 } 5025 5026 #setButtonPressed(name, isPressed) { 5027 const button = this.querySelector(`[name="${name}"]`); 5028 if (button) { 5029 button.setAttribute("aria-pressed", isPressed.toString()); 5030 } 5031 } 5032 5033 #setButtonDisabled(name, isDisabled) { 5034 const button = this.querySelector(`[name="${name}"]`); 5035 if (button) { 5036 button.disabled = isDisabled; 5037 button.setAttribute("aria-disabled", isDisabled.toString()); 5038 } 5039 } 5040 5041 #toolbarIsOverflowing() { 5042 // Safari can report inconsistent clientWidth values on more than 100% window zoom level, 5043 // that was affecting the toolbar overflow calculation. We're adding +1 to get around this issue. 5044 return (this.scrollWidth - this.#overflow.clientWidth) > this.clientWidth + 1 5045 } 5046 5047 #refreshToolbarOverflow = () => { 5048 this.#resetToolbarOverflow(); 5049 this.#compactMenu(); 5050 5051 this.#overflow.style.display = this.#overflowMenu.children.length ? "block" : "none"; 5052 this.#overflow.setAttribute("nonce", getNonce()); 5053 5054 const isOverflowing = this.#overflowMenu.children.length > 0; 5055 this.toggleAttribute("overflowing", isOverflowing); 5056 this.#overflowMenu.toggleAttribute("disabled", !isOverflowing); 5057 } 5058 5059 #compactMenu() { 5060 const buttons = this.#buttons.reverse(); 5061 let movedToOverflow = false; 5062 5063 for (const button of buttons) { 5064 if (this.#toolbarIsOverflowing()) { 5065 this.#overflowMenu.prepend(button); 5066 movedToOverflow = true; 5067 } else { 5068 if (movedToOverflow) this.#overflowMenu.prepend(button); 5069 break 5070 } 5071 } 5072 } 5073 5074 #resetToolbarOverflow() { 5075 const items = Array.from(this.#overflowMenu.children); 5076 items.sort((a, b) => this.#itemPosition(b) - this.#itemPosition(a)); 5077 5078 items.forEach((item) => {
5079 const nextItem = this.querySelector(`[data-position="${this.#itemPosition(item) + 1}"]`) ?? this.#overflow; 5080 this.insertBefore(item, nextItem); 5081 }); 5082 } 5083 5084 #itemPosition(item) { 5085 return parseInt(item.dataset.position ?? "999") 5086 } 5087 5088 #setItemPositionValues() { 5089 this.#toolbarItems.forEach((item, index) => { 5090 if (item.dataset.position === undefined) { 5091 item.dataset.position = index; 5092 } 5093 }); 5094 } 5095 5096 #closeDropdowns() { 5097 this.#dropdowns.forEach((details) => { 5098 details.open = false; 5099 }); 5100 } 5101 5102 get #dropdowns() { 5103 return this.querySelectorAll("details") 5104 } 5105 5106 get #overflow() { 5107 return this.querySelector(".lexxy-editor__toolbar-overflow") 5108 } 5109 5110 get #overflowMenu() { 5111 return this.querySelector(".lexxy-editor__toolbar-overflow-menu") 5112 } 5113 5114 get #buttons() { 5115 return Array.from(this.querySelectorAll(":scope > button")) 5116 } 5117 5118 get #focusableItems() { 5119 return Array.from(this.querySelectorAll(":scope button, :scope > details > summary")) 5120 } 5121 5122 get #toolbarItems() { 5123 return Array.from(this.querySelectorAll(":scope > *:not(.lexxy-editor__toolbar-overflow)")) 5124 } 5125 5126 static get defaultTemplate() { 5127 return ` 5128 <button class="lexxy-editor__toolbar-button" type="button" name="bold" data-command="bold" title="Bold"> 5129 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5 22V2h8.183c1.764 0 3.174.435 4.228 1.304 1.055.87 1.582 2.076 1.582 3.62 0 .8-.148 1.503-.445 2.109a3.94 3.94 0 01-1.194 1.465 4.866 4.866 0 01-1.726.806v.176c.786.078 1.51.312 2.172.703a4.293 4.293 0 011.596 1.627c.403.693.604 1.543.604 2.549 0 1.192-.292 2.207-.877 3.048-.585.84-1.39 1.484-2.416 1.934-1.026.44-2.206.659-3.538.659H5zM8.854 4.974v5.348h2.56c.873 0 1.582-.107 2.129-.322.556-.215.963-.523 1.222-.923.269-.41.403-.904.403-1.48 0-.82-.254-1.46-.762-1.92-.499-.468-1.204-.703-2.115-.703H8.854zm0 8.103v5.949h2.877c1.534 0 2.636-.245 3.307-.733.671-.498 1.007-1.221 1.007-2.168 0-.635-.134-1.178-.403-1.627-.268-.459-.666-.81-1.193-1.055-.518-.244-1.156-.366-1.913-.366H8.854z"/></svg> 5130 </button> 5131 5132 <button class="lexxy-editor__toolbar-button" type="button" name="italic" data-command="italic" title="Italic"> 5133 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17.1 4h-1.5l-3.2 16h1.5l-.4 2h-7l.4-2h1.5l3.2-16h-1.5l.4-2h7l-.4 2z"/></svg> 5134 </button> 5135 5136 <button class="lexxy-editor__toolbar-button" type="button" name="strikethrough" data-command="strikethrough" title="Strikethrough"> 5137 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 5138 <path fill-rule="evenodd" clip-rule="evenodd" d="M4.70588 16.1591C4.81459 19.7901 7.48035 22 11.6668 22C15.9854 22 18.724 19.6296 18.724 15.8779C18.724 15.5007 18.6993 15.1427 18.6474 14.8066H14.3721C14.8637 15.2085 15.0799 15.7037 15.0799 16.3471C15.0799 17.7668 13.7532 18.7984 11.8113 18.7984C9.88053 18.7984 8.38582 17.7531 8.21659 16.1591H4.70588ZM5.23953 9.31962H9.88794C9.10723 8.88889 8.75888 8.33882 8.75888 7.57339C8.75888 6.13992 9.96576 5.18793 11.7631 5.18793C13.5852 5.18793 14.8761 6.1797 14.9959 7.81344H18.4102C18.3485 4.31824 15.8038 2 11.752 2C7.867 2 5.09129 4.35802 5.09129 7.92044C5.09129 8.41838 5.14071 8.88477 5.23953 9.31962ZM2.23529 10.6914C1.90767 10.6914 1.59347 10.8359 1.36181 11.0931C1.13015 11.3504 1 11.6993 1 12.0631C1 12.4269 1.13015 12.7758 1.36181 13.0331C1.59347 13.2903 1.90767 13.4348 2.23529 13.4348H20.7647C21.0923 13.4348 21.4065 13.2903 21.6382 13.0331C21.8699 12.7758 22 12.4269 22 12.0631C22 11.6993 21.8699 11.3504 21.6382 11.0931C21.4065 10.8359 21.0923 10.6914 20.7647 10.6914H2.23529Z"/> 5139 </svg> 5140 </button> 5141 5142 <details class="lexxy-editor__toolbar-dropdown" name="lexxy-dropdown"> 5143 <summary class="lexxy-editor__toolbar-button" name="highlight" title="Color highlight"> 5144 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M7.65422 0.711575C7.1856 0.242951 6.42579 0.242951 5.95717 0.711575C5.48853 1.18021 5.48853 1.94 5.95717 2.40864L8.70864 5.16011L2.85422 11.0145C1.44834 12.4204 1.44833 14.6998 2.85422 16.1057L7.86011 21.1115C9.26599 22.5174 11.5454 22.5174 12.9513 21.1115L19.6542 14.4087C20.1228 13.94 20.1228 13.1802 19.6542 12.7115L11.8544 4.911
514471L11.2542 4.31158L7.65422 0.711575ZM4.55127 12.7115L10.4057 6.85716L17.1087 13.56H4.19981C4.19981 13.253 4.31696 12.9459 4.55127 12.7115ZM23.6057 20.76C23.6057 22.0856 22.5311 23.16 21.2057 23.16C19.8802 23.16 18.8057 22.0856 18.8057 20.76C18.8057 19.5408 19.8212 18.5339 20.918 17.4462C21.0135 17.3516 21.1096 17.2563 21.2057 17.16C21.3018 17.2563 21.398 17.3516 21.4935 17.4462C22.5903 18.5339 23.6057 19.5408 23.6057 20.76Z"/></svg> 5145 </summary> 5146 <lexxy-highlight-dropdown class="lexxy-editor__toolbar-dropdown-content"> 5147 <div class="lexxy-highlight-colors"></div> 5148 <button data-command="removeHighlight" class="lexxy-editor__toolbar-button lexxy-editor__toolbar-dropdown-reset">Remove all coloring</button> 5149 </lexxy-highlight-dropdown> 5150 </details> 5151 5152 <details class="lexxy-editor__toolbar-dropdown" name="lexxy-dropdown"> 5153 <summary class="lexxy-editor__toolbar-button" name="link" title="Link" data-hotkey="cmd+k ctrl+k"> 5154 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.111 9.546a1.5 1.5 0 012.121 0 5.5 5.5 0 010 7.778l-2.828 2.828a5.5 5.5 0 01-7.778 0 5.498 5.498 0 010-7.777l2.828-2.83a1.5 1.5 0 01.355-.262 6.52 6.52 0 00.351 3.799l-1.413 1.414a2.499 2.499 0 000 3.535 2.499 2.499 0 003.535 0l2.83-2.828a2.5 2.5 0 000-3.536 1.5 1.5 0 010-2.121z"/><path d="M12.111 3.89a5.5 5.5 0 117.778 7.777l-2.828 2.829a1.496 1.496 0 01-.355.262 6.522 6.522 0 00-.351-3.8l1.413-1.412a2.5 2.5 0 10-3.536-3.535l-2.828 2.828a2.5 2.5 0 000 3.536 1.5 1.5 0 01-2.122 2.12 5.5 5.5 0 010-7.777l2.83-2.829z"/></svg> 5155 </summary> 5156 <lexxy-link-dropdown class="lexxy-editor__toolbar-dropdown-content"> 5157 <form method="dialog"> 5158 <input type="url" placeholder="Enter a URLâ¦" class="input"> 5159 <div class="lexxy-editor__toolbar-dropdown-actions"> 5160 <button type="submit" class="lexxy-editor__toolbar-button" value="link">Link</button> 5161 <button type="button" class="lexxy-editor__toolbar-button" value="unlink">Unlink</button> 5162 </div> 5163 </form> 5164 </lexxy-link-dropdown> 5165 </details> 5166 5167 <button class="lexxy-editor__toolbar-button" type="button" name="quote" data-command="insertQuoteBlock" title="Quote"> 5168 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M6.5 5C8.985 5 11 7.09 11 9.667c0 2.694-.962 5.005-2.187 6.644-.613.82-1.3 1.481-1.978 1.943-.668.454-1.375.746-2.022.746a.563.563 0 01-.52-.36.602.602 0 01.067-.57l.055-.066.009-.009.041-.048a4.25 4.25 0 00.168-.21c.143-.188.336-.47.53-.84a6.743 6.743 0 00.75-2.605C3.705 13.994 2 12.038 2 9.667 2 7.089 4.015 5 6.5 5zM17.5 5C19.985 5 22 7.09 22 9.667c0 2.694-.962 5.005-2.187 6.644-.613.82-1.3 1.481-1.978 1.943-.668.454-1.375.746-2.023.746a.563.563 0 01-.52-.36.602.602 0 01.068-.57l.055-.066.009-.009.041-.048c.039-.045.097-.115.168-.21a6.16 6.16 0 00.53-.84 6.745 6.745 0 00.75-2.605C14.705 13.994 13 12.038 13 9.667 13 7.089 15.015 5 17.5 5z"/></svg> 5169 </button> 5170 5171 <button class="lexxy-editor__toolbar-button" type="button" name="heading" data-command="rotateHeadingFormat" title="Heading"> 5172 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M15.322 5.315H9.64V22H5.684V5.315H0v-3.31h15.322v3.31z"/><path d="M23.957 11.79H19.92V22h-3.402V11.79H12.48V9.137h11.477v2.653z"/></svg> 5173 </button> 5174 5175 <button class="lexxy-editor__toolbar-button" type="button" name="code" data-command="insertCodeBlock" title="Code"> 5176 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.121 6l-6 6 6 6-2.12 2.121-7.061-7.06a1.5 1.5 0 010-2.121L8 3.879 10.121 6zM23.06 10.94a1.5 1.5 0 010 2.12L16 20.121 13.88 18l6-6-6-6L16 3.879l7.06 7.06z"/></svg> 5177 </button> 5178 5179 <button class="lexxy-editor__toolbar-button" type="button" name="unordered-list" data-command="insertUnorderedList" title="Bullet list"> 5180 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5 5a2 2 0 11-4 0 2 2 0 014 0zM5 12a2 2 0 11-4 0 2 2 0 014 0zM5 19a2 2 0 11-4 0 2 2 0 014 0zM7 5.25C7 4.56 7.56 4 8.25 4h13.5a1.25 1.25 0 110 2.5H8.25C7.56 6.5 7 5.94 7 5.25zM7 12.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM7 19.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25z"/></svg> 5181 </button> 5182 5183 <button class="lexxy-editor__toolbar-button" type="button" name="ordered-list" data-command="insertOrderedList" title="Numbered list"> 5184 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 5.25C7 4.56 7.56 4 8.25 4h13.5a1.25 1.25 0 110 2.5H8.25C7.56 6.5 7 5.94 7 5.25zM7 12.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM7 19.25c0-.69.56-1.25 1.25-1.25h13.5a1.25 1.25 0 110 2.5H8.25c-.69 0-1.25-.56-1.25-1.25zM4.438 8H3.39V3.684H3.34c-.133.093-.267.188-.402.285l-.407.289a129.5 129.5 0 00-.402.285v-.969l.633-.453c.21-.15.42-.302.629-.453h1.046V8zM2.672 11.258h-1v-.051c0-.206.036-.405.11-.598.075-.195.188-.37.34-.527.15-.156.339-.281.566-.375.229-.094.498-.14.808-.14.367 0 .688.065.961.195s.484.308.633.535c.15.224.226.478.226.762 0 .244-.046.463-.14.656-.091.19-.209.368-.352.535-.14.164-.289.332-.445.504L3.168 14.09v.05h2.238V15H1.723v-.656l1.949-2.102c.096-.101.19-.207.281-.316.091-.112.167-.232.227-.36a.953.953 0 00.09-.41.712.712 0 00-.387-.648.845.845 0 00-.41-.098.81.81 0 00-.43.11.75.75 0 00-.277.293.824.824 0 00-.094.386V11.258zM2.852 19.66v-.812h.562a.917.917 0 00.43-.098.742.742 0 00.293-.266.673.673 0 00.
5184101-.379.654.654 0 00-.234-.523.87.87 0 00-.59-.2.987.987 0 00-.336.055.837.837 0 00-.258.149.712.712 0 00-.172.215.66.66 0 00-.066.25h-.98c.007-.209.053-.403.136-.582.084-.18.203-.336.36-.469.156-.135.346-.24.57-.316.227-.076.486-.115.777-.118a2.33 2.33 0 01.965.176c.271.12.48.285.63.496.15.209.227.448.23.719a1.11 1.11 0 01-.16.637 1.28 1.28 0 01-.825.586v.054c.162.016.33.07.504.164.177.094.328.232.453.415.125.18.189.411.192.695a1.37 1.37 0 01-.157.676c-.104.197-.25.365-.437.503-.188.136-.404.24-.649.313-.242.07-.5.105-.777.105-.401 0-.743-.067-1.027-.203a1.608 1.608 0 01-.649-.547 1.46 1.46 0 01-.238-.75h.969c.01.128.057.243.14.344a.885.885 0 00.332.238c.141.058.3.088.477.09.195 0 .366-.034.512-.101a.798.798 0 00.336-.29.744.744 0 00.117-.425.74.74 0 00-.446-.695 1.082 1.082 0 00-.496-.106h-.59z"/></svg> 5185 </button> 5186 5187 <button class="lexxy-editor__toolbar-button" type="button" name="upload" data-command="uploadAttachments" title="Upload file"> 5188 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M16 8a2 2 0 110 4 2 2 0 010-4z""/><path d="M22 2a1 1 0 011 1v18a1 1 0 01-1 1H2a1 1 0 01-1-1V3a1 1 0 011-1h20zM3 18.714L9 11l5.25 6.75L17 15l4 4V4H3v14.714z"/></svg> 5189 </button> 5190 5191 <button class="lexxy-editor__toolbar-button" type="button" name="table" data-command="insertTable" title="Insert a table"> 5192 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M20.2041 2.01074C21.2128 2.113 22 2.96435 22 4V20L21.9893 20.2041C21.8938 21.1457 21.1457 21.8938 20.2041 21.9893L20 22H4C2.96435 22 2.113 21.2128 2.01074 20.2041L2 20V4C2 2.89543 2.89543 2 4 2H20L20.2041 2.01074ZM4 13V20H11V13H4ZM13 13V20H20V13H13ZM4 11H11V4H4V11ZM13 11H20V4H13V11Z"/></svg> 5193 </button> 5194 5195 <button class="lexxy-editor__toolbar-button" type="button" name="divider" data-command="insertHorizontalDivider" title="Insert a divider"> 5196 <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0 12C0 11.4477 0.447715 11 1 11H23C23.5523 11 24 11.4477 24 12C24 12.5523 23.5523 13 23 13H1C0.447716 13 0 12.5523 0 12Z"/><path d="M4 5C4 3.89543 4.89543 3 6 3H18C19.1046 3 20 3.89543 20 5C20 6.10457 19.1046 7 18 7H6C4.89543 7 4 6.10457 4 5Z"/><path d="M4 19C4 17.8954 4.89543 17 6 17H18C19.1046 17 20 17.8954 20 19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19Z"/></svg> 5197 </button> 5198 5199 <div class="lexxy-editor__toolbar-spacer" role="separator"></div> 5200 5201 <button class="lexxy-editor__toolbar-button" type="button" name="undo" data-command="undo" title="Undo"> 5202 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M5.64648 8.26531C7.93911 6.56386 10.7827 5.77629 13.624 6.05535C16.4655 6.33452 19.1018 7.66079 21.0195 9.77605C22.5839 11.5016 23.5799 13.6516 23.8936 15.9352C24.0115 16.7939 23.2974 17.4997 22.4307 17.4997C21.5641 17.4997 20.8766 16.7915 20.7148 15.9401C20.4295 14.4379 19.7348 13.0321 18.6943 11.8844C17.3 10.3464 15.3835 9.38139 13.3174 9.17839C11.2514 8.97546 9.18359 9.54856 7.5166 10.7858C6.38259 11.6275 5.48981 12.7361 4.90723 13.9997H8.5C9.3283 13.9997 9.99979 14.6714 10 15.4997C10 16.3281 9.32843 16.9997 8.5 16.9997H1.5C0.671573 16.9997 0 16.3281 0 15.4997V8.49968C0.000213656 7.67144 0.671705 6.99968 1.5 6.99968C2.3283 6.99968 2.99979 7.67144 3 8.49968V11.0212C3.7166 9.9704 4.60793 9.03613 5.64648 8.26531Z"/></svg> 5203 </button> 5204 5205 <button class="lexxy-editor__toolbar-button" type="button" name="redo" data-command="redo" title="Redo"> 5206 <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M18.2599 8.26531C15.9672 6.56386 13.1237 5.77629 10.2823 6.05535C7.4408 6.33452 4.80455 7.66079 2.88681 9.77605C1.32245 11.5016 0.326407 13.6516 0.0127834 15.9352C-0.105117 16.7939 0.608975 17.4997 1.47567 17.4997C2.34228 17.4997 3.02969 16.7915 3.19149 15.9401C3.47682 14.4379 4.17156 13.0321 5.212 11.8844C6.60637 10.3464 8.52287 9.38139 10.589 9.17839C12.655 8.97546 14.7227 9.54856 16.3897 10.7858C17.5237 11.6275 18.4165 12.7361 18.9991 13.9997H15.4063C14.578 13.9997 13.9066 14.6714 13.9063 15.4997C13.9063 16.3281 14.5779 16.9997 15.4063 16.9997H22.4063C23.2348 16.9997 23.9063 16.3281 23.9063 15.4997V8.49968C23.9061 7.67144 23.2346 6.99968 22.4063 6.99968C21.578 6.99968 20.9066 7.67144 20.9063 8.49968V11.0212C20.1897 9.9704 19.2984 9.03613 18.2599 8.26531Z"/></svg> 5207 </button> 5208 5209 <details class="lexxy-editor__toolbar-dropdown lexxy-editor__toolbar-overflow" name="lexxy-dropdown"> 5210 <summary class="lexxy-editor__toolbar-button" aria-label="Show more toolbar buttons">â¢â¢â¢</summary> 5211 <div class="lexxy-editor__toolbar-dropdown-content lexxy-editor__toolbar-overflow-menu" aria-label="More toolbar buttons"></div> 5212 </details> 5213 ` 5214 } 5215} 5216 5217/** 5218 * Copyright (c) Meta Platforms, Inc. and affiliates. 5219 * 5220 * This source code is licensed under the MIT license found in the 5221 * LICENSE file in the root directory of this source tree. 5222 * 5223 */ 5224 5225function R$4(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}
5225const T$2="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,B$3=T$2&&"documentMode"in document?document.documentMode:null;!(!T$2||!("InputEvent"in window)||B$3)&&"getTargetRanges"in new window.InputEvent("input");function F$3(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function U$4(...t){return ()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0;}}function lt$4(t,...e){const n=F$3(...e);n.length>0&&t.classList.add(...n);}function ut$3(t,...e){const n=F$3(...e);n.length>0&&t.classList.remove(...n);}function ft$2(t){return t?t.getAdjacentCaret():null}function wt$5(t,e){let n=t;for(;null!=n;){if(n instanceof e)return n;n=n.getParent();}return null}function xt$5(t){const e=zs(t,t=>Si(t)&&!t.isInline());return Si(e)||R$4(4,t.__key),e}function At$5(t){const o=Lr()||Ir();let r;if(yr(o))r=xl(o.focus,"next");else {if(null!=o){const t=o.getNodes(),e=t[t.length-1];e&&(r=tl(e,"next"));}r=r||il(No(),"previous").getFlipped().insert(Li());}const i=Ct$5(t,r),u=sl(i),s=Gs(u)?El(u):i;return Sl(fl(s)),t.getLatest()}function Ct$5(t,e,n){let o=Ml(e,"next");for(let t=o;t;t=Il(t,n))o=t;return Ys(o)&&R$4(283),o.insert(t.isInline()?Li().append(t):t),Ml(tl(t.getLatest(),"next"),e.direction)}function Lt$4(t,e){return null!==t&&Object.getPrototypeOf(t).constructor.name===e.name}function Nt$5(t,e){il(t,"next").insert(e);}function Bt$3(t,e){return _t$4(t,e,null)}function _t$4(t,e,n){let r=false;for(const i of Kt$3(t))e(i)?null!==n&&n(i):(r=true,Si(i)&&_t$4(i,e,n||(t=>i.insertAfter(t))),i.remove());return r}function kt$6(t,e){const n=[],r=Array.from(t).reverse();for(let t=r.pop();void 0!==t;t=r.pop())if(e(t))n.push(t);else if(Si(t))for(const e of Kt$3(t))r.push(e);return n}function $t$3(t){return Ot$4(il(t,"next"))}function Kt$3(t){return Ot$4(il(t,"previous"))}function Ot$4(t){return hl({hasNext:Hs,initial:t.getAdjacentCaret(),map:t=>t.origin.getLatest(),step:t=>t.getAdjacentCaret()})} 5226 5227/** 5228 * Copyright (c) Meta Platforms, Inc. and affiliates. 5229 * 5230 * This source code is licensed under the MIT license found in the 5231 * LICENSE file in the root directory of this source tree. 5232 * 5233 */ 5234 5235const T$1=Symbol.for("preact-signals");function B$2(){if(Z$2>1)return void Z$2--;let t,e=false;for(;void 0!==V$5;){let n=V$5;for(V$5=void 0,J$4++;void 0!==n;){const i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Y$2(n))try{n.c();}catch(n){e||(t=n,e=true);}n=i;}}if(J$4=0,Z$2--,e)throw t}function F$2(t){if(Z$2>0)return t();Z$2++;try{return t()}finally{B$2();}}let G$3,V$5;function W$6(t){const e=G$3;G$3=void 0;try{return t()}finally{G$3=e;}}let Z$2=0,J$4=0,H$1=0;function q$4(t){if(void 0===G$3)return;let e=t.n;return void 0===e||e.t!==G$3?(e={i:0,S:t,p:G$3.s,n:void 0,t:G$3,e:void 0,x:void 0,r:e},void 0!==G$3.s&&(G$3.s.n=e),G$3.s=e,t.n=e,32&G$3.f&&t.S(e),e):-1===e.i?(e.i=0,void 0!==e.n&&(e.n.p=e.p,void 0!==e.p&&(e.p.n=e.n),e.p=G$3.s,e.n=void 0,G$3.s.n=e,G$3.s=e),e):void 0}function Q$3(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function X$3(t,e){return new Q$3(t,e)}function Y$2(t){for(let e=t.s;void 0!==e;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return true;return false}function tt$3(t){for(let e=t.s;void 0!==e;e=e.n){const n=e.S.n;if(void 0!==n&&(e.r=n),e.S.n=e,e.i=-1,void 0===e.n){t.s=e;break}}}
5235function et$3(t){let e,n=t.s;for(;void 0!==n;){const t=n.p;-1===n.i?(n.S.U(n),void 0!==t&&(t.n=n.n),void 0!==n.n&&(n.n.p=t)):e=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=t;}t.s=e;}function nt$3(t,e){Q$3.call(this,void 0),this.x=t,this.s=void 0,this.g=H$1-1,this.f=4,this.W=null==e?void 0:e.watched,this.Z=null==e?void 0:e.unwatched,this.name=null==e?void 0:e.name;}function ot$4(t){const e=t.u;if(t.u=void 0,"function"==typeof e){Z$2++;const n=G$3;G$3=void 0;try{e();}catch(e){throw t.f&=-2,t.f|=8,st$3(t),e}finally{G$3=n,B$2();}}}function st$3(t){for(let e=t.s;void 0!==e;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,ot$4(t);}function rt$2(t){if(G$3!==this)throw new Error("Out-of-order effect");et$3(this),G$3=t,this.f&=-2,8&this.f&&st$3(this),B$2();}function ct$4(t,e){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==e?void 0:e.name;}function dt$3(t,e){const n=new ct$4(t,e);try{n.c();}catch(t){throw n.d(),t}const i=n.d.bind(n);return i[Symbol.dispose]=i,i}function at$2(t,e={}){const n={};for(const i in t){const o=e[i],s=X$3(void 0===o?t[i]:o);n[i]=s;}return n}Q$3.prototype.brand=T$1,Q$3.prototype.h=function(){return true},Q$3.prototype.S=function(t){const e=this.t;e!==t&&void 0===t.e&&(t.x=e,this.t=t,void 0!==e?e.e=t:W$6(()=>{var t;null==(t=this.W)||t.call(this);}));},Q$3.prototype.U=function(t){if(void 0!==this.t){const e=t.e,n=t.x;void 0!==e&&(e.x=n,t.e=void 0),void 0!==n&&(n.e=e,t.x=void 0),t===this.t&&(this.t=n,void 0===n&&W$6(()=>{var t;null==(t=this.Z)||t.call(this);}));}},Q$3.prototype.subscribe=function(t){return dt$3(()=>{const e=this.value,n=G$3;G$3=void 0;try{t(e);}finally{G$3=n;}},{name:"sub"})},Q$3.prototype.valueOf=function(){return this.value},Q$3.prototype.toString=function(){return this.value+""},Q$3.prototype.toJSON=function(){return this.value},Q$3.prototype.peek=function(){const t=G$3;G$3=void 0;try{return this.value}finally{G$3=t;}},Object.defineProperty(Q$3.prototype,"value",{get(){const t=q$4(this);return void 0!==t&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(J$4>100)throw new Error("Cycle detected");this.v=t,this.i++,H$1++,Z$2++;try{for(let t=this.t;void 0!==t;t=t.x)t.t.N();}finally{B$2();}}}}),nt$3.prototype=new Q$3,nt$3.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if(32==(36&this.f))return true;if(this.f&=-5,this.g===H$1)return true;if(this.g=H$1,this.f|=1,this.i>0&&!Y$2(this))return this.f&=-2,true;const t=G$3;try{tt$3(this),G$3=this;const t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++);}catch(t){this.v=t,this.f|=16,this.i++;}return G$3=t,et$3(this),this.f&=-2,true},nt$3.prototype.S=function(t){if(void 0===this.t){this.f|=36;for(let t=this.s;void 0!==t;t=t.n)t.S.S(t);}Q$3.prototype.S.call(this,t);},nt$3.prototype.U=function(t){if(void 0!==this.t&&(Q$3.prototype.U.call(this,t),void 0===this.t)){this.f&=-33;for(let t=this.s;void 0!==t;t=t.n)t.S.U(t);}},nt$3.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;void 0!==t;t=t.x)t.t.N();}}
5235,Object.defineProperty(nt$3.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const t=q$4(this);if(this.h(),void 0!==t&&(t.i=this.i),16&this.f)throw this.v;return this.v}}),ct$4.prototype.c=function(){const t=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const t=this.x();"function"==typeof t&&(this.u=t);}finally{t();}},ct$4.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ot$4(this),tt$3(this),Z$2++;const t=G$3;return G$3=this,rt$2.bind(this,t)},ct$4.prototype.N=function(){2&this.f||(this.f|=2,this.o=V$5,V$5=this);},ct$4.prototype.d=function(){this.f|=8,1&this.f||st$3(this);},ct$4.prototype.dispose=function(){this.d();};function pt$3(t){return ("function"==typeof t.nodes?t.nodes():t.nodes)||[]}function xt$4(t,...e){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const t of e)i.append("v",t);throw n.search=i.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function yt$3(t,e){if(t&&e&&!Array.isArray(e)&&"object"==typeof t&&"object"==typeof e){const n=t,i=e;for(const t in i)n[t]=yt$3(n[t],i[t]);return t}return e}const St$5=0,Et$4=1,bt$5=2,wt$4=3,Nt$4=4,Ot$3=5,Rt$2=6,Mt$3=7;function Ct$4(t){return t.id===St$5}function Dt$3(t){return t.id===bt$5}function _t$3(t){return function(t){return t.id===Et$4}(t)||xt$4(305,String(t.id),String(Et$4)),Object.assign(t,{id:bt$5})}const It$3=new Set;let jt$3 = class jt{builder;configs;_dependency;_peerNameSet;extension;state;_signal;constructor(t,e){this.builder=t,this.extension=e,this.configs=new Set,this.state={id:St$5};}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):Wl;for(const n of this.configs)t=e(t,n);return t}init(t){const e=this.state;Dt$3(e)||xt$4(306,String(e.id));const n={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...n,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},o=function(t,e,n){return Object.assign(t,{config:e,id:wt$4,registerState:n})}(e,this.mergeConfigs(),n);let s;this.state=o,this.extension.init&&(s=this.extension.init(t,o.config,n)),this.state=function(t,e,n){return Object.assign(t,{id:Nt$4,initResult:e,registerState:n})}(o,s,i);}build(t){const e=this.state;let n;e.id!==Nt$4&&xt$4(307,String(e.id),String(Ot$3)),this.extension.build&&(n=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>n,getSignal:this.getSignal.bind(this)};this.state=function(t,e,n){return Object.assign(t,{id:Ot$3,output:e,registerState:n})}(e,n,i);}register(t,e){this._signal=e;const n=this.state;n.id!==Ot$3&&xt$4(308,String(n.id),String(Ot$3));const i=this.extension.register&&this.extension.register(t,n.config,n.registerState);return this.state=function(t){return Object.assign(t,{id:Rt$2})}(n),()=>{const t=this.state;t.id!==Mt$3&&xt$4(309,String(n.id),String(Mt$3)),this.state=function(t){return Object.assign(t,{id:Ot$3})}(t),i&&i();}}afterRegistration(t){const e=this.state;let n;return e.id!==Rt$2&&xt$4(310,String(e.id),String(Rt$2)),this.extension.afterRegistration&&(n=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(t){return Object.assign(t,{id:Mt$3})}(e),n}getSignal(){return void 0===this._signal&&xt$4(311),this._signal}getInitResult(){ void 0===this.extension.init&&xt$4(312,this.extension.name);const t=this.state;return function(t){return t.id>=Nt$4}(t)||xt$4(313,String(t.id),String(Nt$4)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(t){return t.id>=wt$4}(t)||xt$4(314,String(t.id),String(wt$4)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&xt$4(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return void 0===e&&xt$4(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(t){return t.id>=Mt$3}(t)||xt$4(316,String(t.id),String(Mt$3)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||It$3}getPeerNameSet(){let t=this._peerNameSet;
5235return t||(t=new Set((this.extension.peerDependencies||[]).map(([t])=>t)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;((function(t){return t.id>=Ot$3}))(t)||xt$4(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output};}return this._dependency}};const At$4={tag:Dn};function Pt$4(){const t=No();t.isEmpty()&&t.append(Li());}const Kt$2=Kl({config:Bl({setOptions:At$4,updateOptions:At$4}),init:({$initialEditorState:t=Pt$4})=>({$initialEditorState:t,initialized:false}),afterRegistration(t,{updateOptions:e,setOptions:n},i){const o=i.getInitResult();if(!o.initialized){o.initialized=true;const{$initialEditorState:i}=o;if(Mi(i))t.setEditorState(i,n);else if("function"==typeof i)t.update(()=>{i(t);},e);else if(i&&("string"==typeof i||"object"==typeof i)){const e=t.parseEditorState(i);t.setEditorState(e,n);}}return ()=>{}},name:"@lexical/extension/InitialState",nodes:[Ni,Xn,Bn,ar,Di]}),kt$5=Symbol.for("@lexical/extension/LexicalBuilder");function $t$2(...t){return Bt$2.fromExtensions(t).buildEditor()}function zt$2(){}function Ut$2(t){throw t}function Lt$3(t){return Array.isArray(t)?t:[t]}const Tt$4="0.38.2+prod.esm";let Bt$2 = class Bt{roots;extensionNameMap;outgoingConfigEdges;incomingEdges;conflicts;_sortedExtensionReps;PACKAGE_VERSION;constructor(t){this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Tt$4,this.roots=t;for(const e of t)this.addExtension(e);}static fromExtensions(t){const e=[Lt$3(Kt$2)];for(const n of t)e.push(Lt$3(n));return new Bt(e)}static maybeFromEditor(t){const e=t[kt$5];return e&&(e.PACKAGE_VERSION!==Tt$4&&xt$4(292,e.PACKAGE_VERSION,Tt$4),e instanceof Bt||xt$4(293)),e}static fromEditor(t){const e=Bt.maybeFromEditor(t);return void 0===e&&xt$4(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...n}=this.buildCreateEditorArgs(),i=Object.assign($i({...n,...e?{onError:t=>{e(t,i);}}:{}}),{[kt$5]:this});for(const t of this.sortedExtensionReps())t.build(i);return i}buildEditor(){let t=zt$2;function e(){try{t();}finally{t=zt$2;}}const n=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});
5235return t=U$4(this.registerEditor(n),()=>n.setRootElement(null)),n}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&xt$4(295,t.name),e}addEdge(t,e,n){const i=this.outgoingConfigEdges.get(t);i?i.set(e,n):this.outgoingConfigEdges.set(t,new Map([[e,n]]));const o=this.incomingEdges.get(e);o?o.add(t):this.incomingEdges.set(e,new Set([t]));}addExtension(t){ void 0!==this._sortedExtensionReps&&xt$4(296);const e=Lt$3(t),[n]=e;"string"!=typeof n.name&&xt$4(297,typeof n.name);let i=this.extensionNameMap.get(n.name);if(void 0!==i&&i.extension!==n&&xt$4(298,n.name),!i){i=new jt$3(this,n),this.extensionNameMap.set(n.name,i);const t=this.conflicts.get(n.name);"string"==typeof t&&xt$4(299,n.name,t);for(const t of n.conflictsWith||[])this.extensionNameMap.has(t)&&xt$4(299,n.name,t),this.conflicts.set(t,n.name);for(const t of n.dependencies||[]){const e=Lt$3(t);this.addEdge(n.name,e[0].name,e.slice(1)),this.addExtension(e);}for(const[t,e]of n.peerDependencies||[])this.addEdge(n.name,t,e?[e]:[]);}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(n,i)=>{let o=n.state;if(Dt$3(o))return;const s=n.extension.name;var r;Ct$4(o)||xt$4(300,s,i||"[unknown]"),Ct$4(r=o)||xt$4(304,String(r.id),String(St$5)),o=Object.assign(r,{id:Et$4}),n.state=o;const c=this.outgoingConfigEdges.get(s);if(c)for(const t of c.keys()){const n=this.extensionNameMap.get(t);n&&e(n,s);}o=_t$3(o),n.state=o,t.push(n);};for(const t of this.extensionNameMap.values())Ct$4(t.state)&&e(t);for(const e of t)for(const[t,n]of this.outgoingConfigEdges.get(e.extension.name)||[])if(n.length>0){const e=this.extensionNameMap.get(t);if(e)for(const t of n)e.configs.add(t);}for(const[t,...e]of this.roots)if(e.length>0){const n=this.extensionNameMap.get(t.name);void 0===n&&xt$4(301,t.name);for(const t of e)n.configs.add(t);}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),n=new AbortController,i=[()=>n.abort()],o=n.signal;for(const n of e){const e=n.register(t,o);e&&i.push(e);}for(const n of e){const e=n.afterRegistration(t);e&&i.push(e);}return U$4(...i)}buildCreateEditorArgs(){const t={},e=new Set,n=new Map,i=new Map,o={},s={},r=this.sortedExtensionReps();for(const c of r){const{extension:r}=c;if(void 0!==r.onError&&(t.onError=r.onError),void 0!==r.disableEvents&&(t.disableEvents=r.disableEvents),void 0!==r.parentEditor&&(t.parentEditor=r.parentEditor),void 0!==r.editable&&(t.editable=r.editable),void 0!==r.namespace&&(t.namespace=r.namespace),void 0!==r.$initialEditorState&&(t.$initialEditorState=r.$initialEditorState),r.nodes)for(const t of pt$3(r)){if("function"!=typeof t){const e=n.get(t.replace);e&&xt$4(302,r.name,t.replace.name,e.extension.name),n.set(t.replace,c);}e.add(t);}if(r.html){if(r.html.export)for(const[t,e]of r.html.export.entries())i.set(t,e);r.html.import&&Object.assign(o,r.html.import);}r.theme&&yt$3(s,r.theme);}Object.keys(s).length>0&&(t.theme=s),e.size&&(t.nodes=[...e]);const c=Object.keys(o).length>0,d=i.size>0;(c||d)&&(t.html={},c&&(t.html.import=o),d&&(t.html.export=i));for(const e of r)e.init(t);return t.onError||(t.onError=Ut$2),t}};function Gt$1(t,e){const n=Bt$2.fromEditor(t).extensionNameMap.get(e);return n?n.getExtensionDependency():void 0} 5236 5237/** 5238 * Copyright (c) Meta Platforms, Inc. and affiliates. 5239 * 5240 * This source code is licensed under the MIT license found in the 5241 * LICENSE file in the root directory of this source tree. 5242 * 5243 */ 5244 5245function K$3(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function W$5(t){let e=1,n=t.getParent();for(;null!=n;){if(ot$3(n)){const t=n.getParent();if(dt$2(t)){e++,n=t.getParent();continue}K$3(40);}return e}return e}function J$3(t){let e=t.getParent();dt$2(e)||K$3(40);let n=e;for(;null!==n;)n=n.getParent(),dt$2(n)&&(e=n);return e}function U$3(t){let e=[];const n=t.getChildren().filter(ot$3);for(let t=0;t<n.length;t++){const r=n[t],i=r.getFirstChild();dt$2(i)?e=e.concat(U$3(i)):e.push(r);}return e}function $$2(t){return ot$3(t)&&dt$2(t.getFirstChild())}function V$4(t){return st$2().append(t)}function z$3(t,e){return ot$3(t)&&(0===e.length||1===e.length&&t.is(e[0])&&0===t.getChildrenSize())}function j$2(t){const e=Lr();if(null!==e){let n=e.getNodes();if(yr(e)){const r=e.getStartEndPoints();null===r&&K$3(143);const[i]=r,s=i.getNode(),o=s.getParent();if(as(s)){const t=s.getFirstChild();if(t)n=t.selectStart().getNodes();else {const t=Li();s.append(t),n=t.select().getNodes();}}else if(z$3(s,n)){const e=ht$3(t);if(as(o)){s.replace(e);const t=st$2();Si(s)&&(t.setFormat(s.getFormatType()),t.setIndent(s.getIndent())),e.append(t);}else if(ot$3(s)){const t=s.getParentOrThrow();q$3(e,t.getChildren()),t.replace(e);}return}}const r=new Set;for(let e=0;e<n.length;e++){const i=n[e];if(Si(i)&&i.isEmpty()&&!ot$3(i)&&!r.has(i.getKey())){H(i,t);continue}let s=ho(i)?i.getParent():ot$3(i)&&i.isEmpty()?i:null;for(;null!=s;){const e=s.getKey();if(dt$2(s)){if(!r.has(e)){const n=ht$3(t);q$3(n,s.getChildren()),s.replace(n),r.add(e);}break}{const n=s.getParent();if(as(n)&&!r.has(e)){r.add(e),H(s,t);break}s=n;}}}}}function q$3(t,e){t.splice(t.getChildrenSize(),0,e);}function H(t,e){if(dt$2(t))return t;const n=t.getPreviousSibling(),r=t.getNextSibling(),i=st$2();let s;if(q$3(i,t.getChildren()),dt$2(n)&&e===n.getListType())n.append(i),dt$2(r)&&e===r.getListType()&&(q$3(n,r.getChildren()),r.remove()),s=n;else if(dt$2(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else {const n=ht$3(e);n.append(i),t.replace(n),s=n;}return i.setFormat(t.getFormatType()),i.setIndent(t.getIndent()),t.remove(),s}function X$2(t,e){const n=t.getLastChild(),r=e.getFirstChild();n&&r&&$$2(n)&&$$2(r)&&(X$2(n.getFirstChild(),r.getFirstChild()),r.remove());const i=e.getChildren();i.length>0&&t.append(...i),e.remove();}function G$2(){const t=Lr();if(yr(t)){const e=new Set,r=t.getNodes(),i=t.anchor.getNode();if(z$3(i,r))e.add(J$3(i));else for(let t=0;t<r.length;t++){const i=r[t];if(ho(i)){const t=wt$5(i,nt$2);null!=t&&e.add(J$3(t));}}for(const n of e){let e=n;const r=U$3(n);for(const n of r){const r=Li().setTextStyle(t.style).setTextFormat(t.format);
5245q$3(r,n.getChildren()),e.insertAfter(r),e=r,n.__key===t.anchor.key&&Cl(t.anchor,El(il(r,"next"))),n.__key===t.focus.key&&Cl(t.focus,El(il(r,"next"))),n.remove();}n.remove();}}}function Q$2(t){const e="check"!==t.getListType();let n=t.getStart();for(const r of t.getChildren())ot$3(r)&&(r.getValue()!==n&&r.setValue(n),e&&null!=r.getLatest().__checked&&r.setChecked(void 0),dt$2(r.getFirstChild())||n++);}function Y$1(t){const e=new Set;if($$2(t)||e.has(t.getKey()))return;const n=t.getParent(),r=t.getNextSibling(),i=t.getPreviousSibling();if($$2(r)&&$$2(i)){const n=i.getFirstChild();if(dt$2(n)){n.append(t);const i=r.getFirstChild();if(dt$2(i)){q$3(n,i.getChildren()),r.remove(),e.add(r.getKey());}}}else if($$2(r)){const e=r.getFirstChild();if(dt$2(e)){const n=e.getFirstChild();null!==n&&n.insertBefore(t);}}else if($$2(i)){const e=i.getFirstChild();dt$2(e)&&e.append(t);}else if(dt$2(n)){const e=st$2().setTextFormat(t.getTextFormat()).setTextStyle(t.getTextStyle()),s=ht$3(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());e.append(s),s.append(t),i?i.insertAfter(e):r?r.insertBefore(e):n.append(e);}}function Z$1(t){if($$2(t))return;const e=t.getParent(),n=e?e.getParent():void 0;if(dt$2(n?n.getParent():void 0)&&ot$3(n)&&dt$2(e)){const r=e?e.getFirstChild():void 0,i=e?e.getLastChild():void 0;if(t.is(r))n.insertBefore(t),e.isEmpty()&&n.remove();else if(t.is(i))n.insertAfter(t),e.isEmpty()&&n.remove();else {const r=e.getListType(),i=st$2(),s=ht$3(r);
5245i.append(s),t.getPreviousSiblings().forEach(t=>s.append(t));const o=st$2(),l=ht$3(r);o.append(l),q$3(l,t.getNextSiblings()),n.insertBefore(i),n.insertAfter(o),n.replace(t);}}}function tt$2(){const t=Lr();if(!yr(t)||!t.isCollapsed())return false;const e=t.anchor.getNode();if(!ot$3(e)||0!==e.getChildrenSize())return false;const n=J$3(e),r=e.getParent();dt$2(r)||K$3(40);const i=r.getParent();let s;if(as(i))s=Li(),n.insertAfter(s);else {if(!ot$3(i))return false;s=st$2(),i.insertAfter(s);}s.setTextStyle(t.style).setTextFormat(t.format).select();const o=e.getNextSiblings();if(o.length>0){const t=ht$3(r.getListType());if(ot$3(s)){const e=st$2();e.append(t),s.insertAfter(e);}else s.insertAfter(t);t.append(...o);}return function(t){let e=t;for(;null==e.getNextSibling()&&null==e.getPreviousSibling();){const t=e.getParent();if(null==t||!ot$3(t)&&!dt$2(t))break;e=t;}e.remove();}(e),true}function et$2(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}let nt$2 = class nt extends Ci{__value;__checked;$config(){return this.config("listitem",{$transform:t=>{if(null==t.__checked)return;const e=t.getParent();dt$2(e)&&"check"!==e.getListType()&&null!=t.getChecked()&&t.setChecked(void 0);},extends:Ci,importDOM:wn$1({li:()=>({conversion:rt$1,priority:0})})})}constructor(t=1,e=void 0,n){super(n),this.__value=void 0===t?1:t,this.__checked=e;}afterCloneFrom(t){super.afterCloneFrom(t),this.__value=t.__value,this.__checked=t.__checked;}createDOM(t){const e=document.createElement("li");return this.updateListItemDOM(null,e,t),e}updateListItemDOM(t,e,n){!function(t,e,n){const r=e.getParent();!dt$2(r)||"check"!==r.getListType()||dt$2(e.getFirstChild())?(t.removeAttribute("role"),t.removeAttribute("tabIndex"),t.removeAttribute("aria-checked")):(t.setAttribute("role","checkbox"),t.setAttribute("tabIndex","-1"),n&&e.__checked===n.__checked||t.setAttribute("aria-checked",e.getChecked()?"true":"false"));}(e,this,t),e.value=this.__value,function(t,e,n){const s=[],o=[],l=e.list,c=l?l.listitem:void 0;let a;l&&l.nested&&(a=l.nested.listitem);void 0!==c&&s.push(...et$2(c));if(l){const t=n.getParent(),e=dt$2(t)&&"check"===t.getListType(),r=n.getChecked();e&&!r||o.push(l.listitemUnchecked),e&&r||o.push(l.listitemChecked),e&&s.push(r?l.listitemChecked:l.listitemUnchecked);}if(void 0!==a){const t=et$2(a);n.getChildren().some(t=>dt$2(t))?s.push(...t):o.push(...t);}o.length>0&&ut$3(t,...o);s.length>0&<$4(t,...s);}(e,n.theme,this);const s=t?t.__style:"",o=this.__style;s!==o&&(""===o?e.removeAttribute("style"):e.style.cssText=o),function(t,e,n){const r=b$3(e.__textStyle);for(const e in r)t.style.setProperty(`--listitem-marker-${e}`,r[e]);if(n)for(const e in b$3(n.__textStyle))e in r||t.style.removeProperty(`--listitem-marker-${e}`);}(e,this,t);}updateDOM(t,e,n){const r=e;return this.updateListItemDOM(t,r,n),false}updateFromJSON(t){return super.updateFromJSON(t).setValue(t.value).setChecked(t.checked)}exportDOM(t){const e=this.createDOM(t._config),n=this.getFormatType();n&&(e.style.textAlign=n);const r=this.getDirection();return r&&(e.dir=r),{element:e}}exportJSON(){return {...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...t){for(let e=0;e<t.length;e++){const n=t[e];if(Si(n)&&this.canMergeWith(n)){const t=n.getChildren();this.append(...t),n.remove();}else super.append(n);}return this}replace(t,e){if(ot$3(t))return super.replace(t);this.setIndent(0);const n=this.getParentOrThrow();if(!dt$2(n))return t;if(n.__first===this.getKey())n.insertBefore(t);else if(n.__last===this.getKey())n.insertAfter(t);else {const e=ht$3(n.getListType());let r=this.getNextSibling();for(;r;){const t=r;r=r.getNextSibling(),e.append(t);}n.insertAfter(t),t.insertAfter(e);}
5245return e&&(Si(t)||K$3(139),this.getChildren().forEach(e=>{t.append(e);})),this.remove(),0===n.getChildrenSize()&&n.remove(),t}insertAfter(t,e=true){const n=this.getParentOrThrow();if(dt$2(n)||K$3(39),ot$3(t))return super.insertAfter(t,e);const r=this.getNextSiblings();if(n.insertAfter(t,e),0!==r.length){const i=ht$3(n.getListType());r.forEach(t=>i.append(t)),t.insertAfter(i,e);}return t}remove(t){const e=this.getPreviousSibling(),n=this.getNextSibling();super.remove(t),e&&n&&$$2(e)&&$$2(n)&&(X$2(e.getFirstChild(),n.getFirstChild()),n.remove());}insertNewAfter(t,e=true){const n=st$2().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,e),n}collapseAtStart(t){const e=Li();this.getChildren().forEach(t=>e.append(t));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=ot$3(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else {n.insertBefore(e),n.remove();const r=t.anchor,i=t.focus,s=e.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(s,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(s,i.offset,"element");}else n.insertBefore(e),this.remove();return true}getValue(){return this.getLatest().__value}setValue(t){const e=this.getWritable();return e.__value=t,e}getChecked(){const t=this.getLatest();let e;const n=this.getParent();return dt$2(n)&&(e=n.getListType()),"check"===e?Boolean(t.__checked):void 0}setChecked(t){const e=this.getWritable();return e.__checked=t,e}toggleChecked(){const t=this.getWritable();return t.setChecked(!t.__checked)}getIndent(){const t=this.getParent();if(null===t||!this.isAttached())return this.getLatest().__indent;let e=t.getParentOrThrow(),n=0;for(;ot$3(e);)e=e.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(t){"number"!=typeof t&&K$3(117),(t=Math.floor(t))>=0||K$3(199);let e=this.getIndent();for(;e!==t;)e<t?(Y$1(this),e++):(Z$1(this),e--);return this}canInsertAfter(t){return ot$3(t)}canReplaceWith(t){return ot$3(t)}canMergeWith(t){return ot$3(t)||Ii(t)}extractWithChild(t,e){if(!yr(e))return false;const n=e.anchor.getNode(),r=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(r)&&this.getTextContent().length===e.getTextContent().length}isParentRequired(){return true}createParentElementNode(){return ht$3("bullet")}canMergeWhenEmpty(){return true}};function rt$1(t){if(t.classList.contains("task-list-item"))for(const e of t.children)if("INPUT"===e.tagName)return it$3(e);if(t.classList.contains("joplin-checkbox"))for(const e of t.children)if(e.classList.contains("checkbox-wrapper")&&e.children.length>0&&"INPUT"===e.children[0].tagName)return it$3(e.children[0]);const e=t.getAttribute("aria-checked");return {node:st$2("true"===e||"false"!==e&&void 0)}}function it$3(t){if(!("checkbox"===t.getAttribute("type")))return {node:null};return {node:st$2(t.hasAttribute("checked"))}}function st$2(t){return fs(new nt$2(void 0,t))}function ot$3(t){return t instanceof nt$2}let lt$3 = class lt extends Ci{__tag;__start;__listType;$config(){return this.config("list",{$transform:t=>{!function(t){const e=t.getNextSibling();dt$2(e)&&t.getListType()===e.getListType()&&X$2(t,e);}(t),Q$2(t);},extends:Ci,importDOM:wn$1({ol:()=>({conversion:gt$3,priority:0}),ul:()=>({conversion:gt$3,priority:0})})})}constructor(t="number",e=1,n){super(n);const r=ut$2[t]||t;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=e;}afterCloneFrom(t){super.afterCloneFrom(t),this.__listType=t.__listType,this.__tag=t.__tag,this.__start=t.__start;}getTag(){return this.getLatest().__tag}setListType(t){const e=this.getWritable();return e.__listType=t,e.__tag="number"===t?"ol":"ul",e}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(t){const e=this.getWritable();return e.__start=t,e}createDOM(t,e){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,ct$3(r,t.theme,this),r}updateDOM(t,e,n){return t.__tag!==this.__tag||t.__listType!==this.__listType||(ct$3(e,n.theme,this),false)}updateFromJSON(t){return super.updateFromJSON(t).setListType(t.listType).setStart(t.start)}exportDOM(t){const e=this.createDOM(t._config,t);return Cs(e)&&(1!==this.__start&&e.setAttribute("start",String(this.__start)),"check"===this.__listType&&e.setAttribute("__lexicalListType","check")),{element:e}}exportJSON(){return {...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return false}canIndent(){return false}splice(t,e,n){let r=n;for(let t=0;t<n.length;t++){const e=n[t];ot$3(e)||(r===n&&(r=[...n]),r[t]=st$2().append(!Si(e)||dt$2(e)||e.isInline()?e:sr(e.getTextContent())));}return super.splice(t,e,r)}extractWithChild(t){return ot$3(t)}};function ct$3(t,e,n){const s=[],o=[],l=e.list;if(void 0!==l){const t=l[`${n.__tag}Depth`]||[],e=W$5(n)-1,r=e%t.length,i=t[r],c=l[n.__tag];let a;const g=l.nested,u=l.checklist;if(void 0!==g&&g.list&&(a=g.list),void 0!==c&&s.push(c),void 0!==u&&"check"===n.__listType&&s.push(u),void 0!==i){s.push(...et$2(i));for(let e=0;e<t.length;e++)e!==r&&o.push(n.__tag+e);}if(void 0!==a){const t=et$2(a);e>1?s.push(...t):o.push(...t);}}o.length>0&&ut$3(t,...o),s.length>0&<$4(t,...s);}function at$1(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(ot$3(r)){e.push(r);const t=r.getChildren();t.length>1&&t.forEach(t=>{dt$2(t)&&e.push(V$4(t));});}else e.push(V$4(r));}return e}function gt$3(t){const e=t.nodeName.toLowerCase();let n=null;if("ol"===e){n=ht$3("number",t.start);}else "ul"===e&&(n=function(t){if("check"===t.getAttribute("__lexicallisttype")||t.classList.contains("contains-task-list")||"1"===t.getAttribute("data-is-checklist"))return true;for(const e of t.childNodes)if(Cs(e)&&e.hasAttribute("aria-checked"))return true;return false}(t)?ht$3("check"):ht$3("bullet"));return {after:at$1,node:n}}
5245const ut$2={ol:"number",ul:"bullet"};function ht$3(t="number",e=1){return fs(new lt$3(t,e))}function dt$2(t){return t instanceof lt$3}const vt$3=re$1("UPDATE_LIST_START_COMMAND"),St$4=re$1("INSERT_UNORDERED_LIST_COMMAND"),xt$3=re$1("INSERT_ORDERED_LIST_COMMAND"),kt$4=re$1("REMOVE_LIST_COMMAND");function bt$4(t){return U$4(t.registerCommand(xt$3,()=>(j$2("number"),true),zi),t.registerCommand(vt$3,t=>{const{listNodeKey:e,newStart:n}=t,r=xo(e);return !!dt$2(r)&&("number"===r.getListType()&&(r.setStart(n),Q$2(r)),true)},zi),t.registerCommand(St$4,()=>(j$2("bullet"),true),zi),t.registerCommand(kt$4,()=>(G$2(),true),zi),t.registerCommand(ae$1,()=>tt$2(),zi),t.registerNodeTransform(nt$2,t=>{const e=t.getFirstChild();if(e){if(lr(e)){const n=e.getStyle(),r=e.getFormat();t.getTextStyle()!==n&&t.setTextStyle(n),t.getTextFormat()!==r&&t.setTextFormat(r);}}else {const e=Lr();yr(e)&&(e.style!==t.getTextStyle()||e.format!==t.getTextFormat())&&e.isCollapsed()&&t.is(e.anchor.getNode())&&t.setTextStyle(e.style).setTextFormat(e.format);}}),t.registerNodeTransform(Xn,t=>{const e=t.getParent();if(ot$3(e)&&t.is(e.getFirstChild())){const n=t.getStyle(),r=t.getFormat();n===e.getTextStyle()&&r===e.getTextFormat()||e.setTextStyle(n).setTextFormat(r);}}))} 5246 5247/** 5248 * Copyright (c) Meta Platforms, Inc. and affiliates. 5249 * 5250 * This source code is licensed under the MIT license found in the 5251 * LICENSE file in the root directory of this source tree. 5252 * 5253 */ 5254 5255const R$3=new Set(["http:","https:","mailto:","sms:","tel:"]);let y$2 = class y extends Ci{__url;__target;__rel;__title;static getType(){return "link"}static clone(t){return new y(t.__url,{rel:t.__rel,target:t.__target,title:t.__title},t.__key)}constructor(t="",e={},n){super(n);const{target:r=null,rel:i=null,title:l=null}=e;this.__url=t,this.__target=r,this.__rel=i,this.__title=l;}createDOM(e){const n=document.createElement("a");return this.updateLinkDOM(null,n,e),lt$4(n,e.theme.link),n}updateLinkDOM(t,n,r){if(xs(n)){t&&t.__url===this.__url||(n.href=this.sanitizeUrl(this.__url));for(const e of ["target","rel","title"]){const r=`__${e}`,i=this[r];t&&t[r]===i||(i?n[e]=i:n.removeAttribute(e));}}}updateDOM(t,e,n){return this.updateLinkDOM(t,e,n),false}static importDOM(){return {a:t=>({conversion:N$2,priority:1})}}static importJSON(t){return D$2().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setURL(t.url).setRel(t.rel||null).setTarget(t.target||null).setTitle(t.title||null)}sanitizeUrl(t){t=W$4(t);try{const e=new URL(W$4(t));if(!R$3.has(e.protocol))return "about:blank"}catch(e){return t}return t}exportJSON(){return {...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(t){const e=this.getWritable();return e.__url=t,e}getTarget(){return this.getLatest().__target}setTarget(t){const e=this.getWritable();return e.__target=t,e}getRel(){return this.getLatest().__rel}setRel(t){const e=this.getWritable();return e.__rel=t,e}getTitle(){return this.getLatest().__title}setTitle(t){const e=this.getWritable();return e.__title=t,e}insertNewAfter(t,e=true){const n=D$2(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,e),n}canInsertTextBefore(){return false}canInsertTextAfter(){return false}canBeEmpty(){return false}isInline(){return true}extractWithChild(t,e,n){if(!yr(e))return false;const r=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&e.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function N$2(t){let n=null;if(xs(t)){const e=t.textContent;(null!==e&&""!==e||t.children.length>0)&&(n=D$2(t.getAttribute("href")||"",{rel:t.getAttribute("rel"),target:t.getAttribute("target"),title:t.getAttribute("title")}));}return {node:n}}function D$2(t="",e){return fs(new y$2(t,e))}function w$3(t){return t instanceof y$2}let A$1 = class A extends y$2{__isUnlinked;constructor(t="",e={},n){super(t,e,n),this.__isUnlinked=void 0!==e.isUnlinked&&null!==e.isUnlinked&&e.isUnlinked;}static getType(){return "autolink"}static clone(t){return new A(t.__url,{isUnlinked:t.__isUnlinked,rel:t.__rel,target:t.__target,title:t.__title},t.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(t){const e=this.getWritable();return e.__isUnlinked=t,e}createDOM(t){return this.__isUnlinked?document.createElement("span"):super.createDOM(t)}updateDOM(t,e,n){return super.updateDOM(t,e,n)||t.__isUnlinked!==this.__isUnlinked}static importJSON(t){return I$3().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIsUnlinked(t.isUnlinked||false)}static importDOM(){return null}exportJSON(){return {...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(t,e=true){const n=this.getParentOrThrow().insertNewAfter(t,e);if(Si(n)){const t=I$3(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(t),t}return null}};function I$3(t="",e){return fs(new A$1(t,e))}function E$3(t){return t instanceof A$1}function M$3(t,e){if("element"===t.type){const n=t.getNode();Si(n)||function(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(252);return n.getChildren()[t.offset+e]||null}return null}function J$2(t,e={}){let r;if(t&&"object"==typeof t){const{url:n,...i}=t;r=n,e={...i,...e};}else r=t;const{target:i,title:l}=e,s=void 0===e.rel?"noreferrer":e.rel,u=Lr();if(null===u||!yr(u)&&!xr(u))return;if(xr(u)){const t=u.getNodes();if(0===t.length)return;return void t.forEach(t=>{if(null===r){const e=zs(t,t=>!E$3(t)&&w$3(t));e&&(e.insertBefore(t),0===e.getChildren().length&&e.remove());}else {const e=zs(t,t=>!E$3(t)&&w$3(t));if(e)e.setURL(r),void 0!==i&&e.setTarget(i),void 0!==s&&e.setRel(s);else {const e=D$2(r,{rel:s,target:i});t.insertBefore(e),e.append(t);}}})}const h=u.extract();if(null===r){const t=new Set;
5255return void h.forEach(e=>{const n=e.getParent();if(w$3(n)&&!E$3(n)){const e=n.getKey();if(t.has(e))return;!function(t,e){const n=new Set(e.filter(e=>t.isParentOf(e)).map(t=>t.getKey())),r=t.getChildren(),i=r.filter(t=>n.has(t.getKey()));if(i.length===r.length)return r.forEach(e=>t.insertBefore(e)),void t.remove();const l=r.findIndex(t=>n.has(t.getKey())),s=r.findLastIndex(t=>n.has(t.getKey())),o=0===l,u=s===r.length-1;if(o)i.forEach(e=>t.insertBefore(e));else if(u)for(let e=i.length-1;e>=0;e--)t.insertAfter(i[e]);else {for(let e=i.length-1;e>=0;e--)t.insertAfter(i[e]);const e=r.slice(s+1);if(e.length>0){const n=D$2(t.getURL(),{rel:t.getRel(),target:t.getTarget(),title:t.getTitle()});i[i.length-1].insertAfter(n),e.forEach(t=>n.append(t));}}}(n,h),t.add(e);}})}const p=new Set,_=t=>{p.has(t.getKey())||(p.add(t.getKey()),t.setURL(r),void 0!==i&&t.setTarget(i),void 0!==s&&t.setRel(s),void 0!==l&&t.setTitle(l));};if(1===h.length){const t=h[0],e=zs(t,w$3);if(null!==e)return _(e)}!function(t){const e=Lr();if(!yr(e))return t();const n=St$6(e),r=n.isBackward(),i=M$3(n.anchor,r?-1:0),l=M$3(n.focus,r?0:-1);t();if(i||l){const t=Lr();if(yr(t)){const e=t.clone();if(i){const t=i.getParent();t&&e.anchor.set(t.getKey(),i.getIndexWithinParent()+(r?1:0),"element");}if(l){const t=l.getParent();t&&e.focus.set(t.getKey(),l.getIndexWithinParent()+(r?0:1),"element");}wo(St$6(e));}}}(()=>{let t=null;for(const e of h){if(!e.isAttached())continue;const o=zs(e,w$3);if(o){_(o);continue}if(Si(e)){if(!e.isInline())continue;if(w$3(e)){if(!(E$3(e)||null!==t&&t.getParentOrThrow().isParentOf(e))){_(e),t=e;continue}for(const t of e.getChildren())e.insertBefore(t);e.remove();continue}}const u=e.getPreviousSibling();w$3(u)&&u.is(t)?u.append(e):(t=D$2(r,{rel:s,target:i,title:l}),e.insertAfter(t),t.append(e));}});}const K$2=/^\+?[0-9\s()-]{5,}$/;function W$4(t){return t.match(/^[a-z][a-z0-9+.-]*:/i)||t.match(/^[/#.]/)?t:t.includes("@")?`mailto:${t}`:K$2.test(t)?`tel:${t}`:`https://${t}`} 5256 5257/** 5258 * Copyright (c) Meta Platforms, Inc. and affiliates. 5259 * 5260 * This source code is licensed under the MIT license found in the 5261 * LICENSE file in the root directory of this source tree. 5262 * 5263 */ 5264 5265function m$1(e,n){const t=ao(n)?n.body.childNodes:n.childNodes;let l=[];const r=[];for(const n of t)if(!w$2.has(n.nodeName)){const t=y$1(n,e,r,false);null!==t&&(l=l.concat(t));}return function(e){for(const n of e)n.getNextSibling()instanceof Pi&&n.insertAfter(Jn());for(const n of e){const e=n.getChildren();for(const t of e)n.insertBefore(t);n.remove();}}(r),l}function g(e,n){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),o=No().getChildren();for(let l=0;l<o.length;l++){x$2(e,o[l],t,n);}return t.innerHTML}function x$2(t,o,l,u=null){let f=null===u||o.isSelected(u);const a=Si(o)&&o.excludeFromCopy("html");let d=o;null!==u&&lr(o)&&(d=M$4(u,o,"clone"));const p=Si(d)?d.getChildren():[],h=Xi(t,d.getType());let m;m=h&&void 0!==h.exportDOM?h.exportDOM(t,d):d.exportDOM(t);const{element:g,after:w}=m;if(!g)return false;const y=document.createDocumentFragment();for(let e=0;e<p.length;e++){const n=p[e],l=x$2(t,n,y,u);!f&&Si(o)&&l&&o.extractWithChild(n,u,"html")&&(f=true);}if(f&&!a){if((Cs(g)||vs(g))&&g.append(y),l.append(g),w){const e=w.call(d,g);e&&(vs(g)?g.replaceChildren(e):g.replaceWith(e));}}else l.append(y);return f}const w$2=new Set(["STYLE","SCRIPT"]);function y$1(e,n,o,l,i=new Map,s){let c=[];if(w$2.has(e.nodeName))return c;let m=null;const g=function(e,n){const{nodeName:t}=e,o=n._htmlConversions.get(t.toLowerCase());let l=null;if(void 0!==o)for(const n of o){const t=n(e);null!==t&&(null===l||(l.priority||0)<=(t.priority||0))&&(l=t);}return null!==l?l.conversion:null}(e,n),x=g?g(e):null;let b=null;if(null!==x){b=x.after;const n=x.node;if(m=Array.isArray(n)?n[n.length-1]:n,null!==m){for(const[,e]of i)if(m=e(m,s),!m)break;m&&c.push(...Array.isArray(n)?n:[m]);}null!=x.forChild&&i.set(e.nodeName,x.forChild);}const S=e.childNodes;let v=[];const N=(null==m||!as(m))&&(null!=m&&Or(m)||l);for(let e=0;e<S.length;
5265e++)v.push(...y$1(S[e],n,o,N,new Map(i),m));return null!=b&&(v=b(v)),Ts(e)&&(v=C$2(e,v,N?()=>{const e=new Pi;return o.push(e),e}:Li)),null==m?v.length>0?c=c.concat(v):Ts(e)&&function(e){if(null==e.nextSibling||null==e.previousSibling)return false;return ks(e.nextSibling)&&ks(e.previousSibling)}(e)&&(c=c.concat(Jn())):Si(m)&&m.append(...v),c}function C$2(e,n,t){const o=e.style.textAlign,l=[];let r=[];for(let e=0;e<n.length;e++){const i=n[e];if(Or(i))o&&!i.getFormat()&&i.setFormat(o),l.push(i);else if(r.push(i),e===n.length-1||e<n.length-1&&Or(n[e+1])){const e=t();e.setFormat(o),e.append(...r),l.push(e),r=[];}}return l} 5266 5267/** 5268 * Copyright (c) Meta Platforms, Inc. and affiliates. 5269 * 5270 * This source code is licensed under the MIT license found in the 5271 * LICENSE file in the root directory of this source tree. 5272 * 5273 */ 5274 5275function v$2(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function D$1(e,n=Lr()){return null==n&&v$2(166),yr(n)&&n.isCollapsed()||0===n.getNodes().length?"":g(e,n)}function S$2(t,e=Lr()){return null==e&&v$2(166),yr(e)&&e.isCollapsed()||0===e.getNodes().length?null:JSON.stringify(E$2(t,e))}function N$1(t,e){const n=t.getData("text/plain")||t.getData("text/uri-list");null!=n&&e.insertRawText(n);}function R$2(t,n,o){const r=t.getData("application/x-lexical-editor");if(r)try{const t=JSON.parse(r);if(t.namespace===o._config.namespace&&Array.isArray(t.nodes)){return A(o,L$2(t.nodes),n)}}catch(t){console.error(t);}const c=t.getData("text/html"),a=t.getData("text/plain");if(c&&a!==c)try{const t=(new DOMParser).parseFromString(function(t){if(window.trustedTypes&&window.trustedTypes.createPolicy){return window.trustedTypes.createPolicy("lexical",{createHTML:t=>t}).createHTML(t)}return t}(c),"text/html");return A(o,m$1(o,t),n)}catch(t){console.error(t);}const u=a||t.getData("text/uri-list");if(null!=u)if(yr(n)){const t=u.split(/(\r?\n|\t)/);""===t[t.length-1]&&t.pop();for(let e=0;e<t.length;e++){const n=Lr();if(yr(n)){const o=t[e];"\n"===o||"\r\n"===o?n.insertParagraph():"\t"===o?n.insertNodes([ur()]):n.insertText(o);}}}else n.insertRawText(u);}function A(t,e,n){t.dispatchCommand(oe$2,{nodes:e,selection:n})||(n.insertNodes(e),function(t){if(yr(t)&&t.isCollapsed()){const e=t.anchor;let n=null;const o=xl(e,"previous");if(o)if(Ys(o))n=o.origin;else {const t=dl(o,il(No(),"next").getFlipped());for(const e of t){if(lr(e.origin)){n=e.origin;break}if(Si(e.origin)&&!e.origin.isInline())break}}if(n&&lr(n)){const e=n.getFormat(),o=n.getStyle();t.format===e&&t.style===o||(t.format=e,t.style=o,t.dirty=true);}}}(n));}function P$1(t,e,n,r=[]){let i=null===e||n.isSelected(e);const l=Si(n)&&n.excludeFromCopy("html");let s=n;null!==e&&lr(s)&&(s=M$4(e,s,"clone"));const c=Si(s)?s.getChildren():[],a=function(t){const e=t.exportJSON(),n=t.constructor;if(e.type!==n.getType()&&v$2(58,n.name),Si(t)){const t=e.children;Array.isArray(t)||v$2(59,n.name);}return e}(s);lr(s)&&0===s.getTextContentSize()&&(i=false);for(let o=0;o<c.length;o++){const r=c[o],l=P$1(t,e,r,a.children);!i&&Si(n)&&l&&n.extractWithChild(r,e,"clone")&&(i=true);}if(i&&!l)r.push(a);else if(Array.isArray(a.children))for(let t=0;t<a.children.length;t++){const e=a.children[t];r.push(e);}return i}function E$2(t,e){const n=[],o=No().getChildren();for(let r=0;r<o.length;r++){P$1(t,e,o[r],n);}return {namespace:t._config.namespace,nodes:n}}function L$2(t){const e=[];for(let o=0;o<t.length;o++){const r=t[o],i=ui(r);lr(i)&&$$3(i),e.push(i);}return e}let b$2=null;async function F$1(t,e,n){if(null!==b$2)return false;if(null!==e)return new Promise((o,r)=>{t.update(()=>{o(M$2(t,e,n));});});const o=t.getRootElement(),i=t._window||window,l=i.document,s=ps(i);if(null===o||null===s)return false;const c=l.createElement("span");c.style.cssText="position: fixed; top: -1000px;",c.append(l.createTextNode("#")),o.append(c);const a=new Range;return a.setStart(c,0),a.setEnd(c,1),s.removeAllRanges(),s.addRange(a),new Promise((e,o)=>{const s=t.registerCommand(Re$2,o=>(Lt$4(o,ClipboardEvent)&&(s(),null!==b$2&&(i.clearTimeout(b$2),b$2=null),e(M$2(t,o,n))),true),Wi);b$2=i.setTimeout(()=>{s(),b$2=null,e(false);},50),l.execCommand("copy"),c.remove();})}function M$2(t,e,n){if(void 0===n){const e=ps(t._window),o=Lr();if(!o||o.isCollapsed())return false;if(!e)return false;
5275const r=e.anchorNode,l=e.focusNode;if(null!==r&&null!==l&&!eo(t,r,l))return false;n=_$1(o);}e.preventDefault();const o=e.clipboardData;return null!==o&&(J$1(o,n),true)}const O=[["text/html",D$1],["application/x-lexical-editor",S$2]];function _$1(t=Lr()){const e={"text/plain":t?t.getTextContent():""};if(t){const n=bs();for(const[o,r]of O){const i=r(n,t);null!==i&&(e[o]=i);}}return e}function J$1(t,e){for(const[n]of O) void 0===e[n]&&t.setData(n,"");for(const n in e){const o=e[n];void 0!==o&&t.setData(n,o);}} 5276 5277/** 5278 * Copyright (c) Meta Platforms, Inc. and affiliates. 5279 * 5280 * This source code is licensed under the MIT license found in the 5281 * LICENSE file in the root directory of this source tree. 5282 * 5283 */ 5284 5285function s(e){const t=window.location.origin,n=n=>{if(n.origin!==t)return;const o=e.getRootElement();if(document.activeElement!==o)return;const s=n.data;if("string"==typeof s){let t;try{t=JSON.parse(s);}catch(e){return}if(t&&"nuanria_messaging"===t.protocol&&"request"===t.type){const o=t.payload;if(o&&"makeChanges"===o.functionId){const t=o.args;if(t){const[o,s,d,c,g]=t;e.update(()=>{const e=Lr();if(yr(e)){const t=e.anchor;let i=t.getNode(),a=0,l=0;if(lr(i)&&o>=0&&s>=0&&(a=o,l=o+s,e.setTextNodeRange(i,a,i,l)),a===l&&""===d||(e.insertRawText(d),i=t.getNode()),lr(i)){a=c,l=c+g;const t=i.getTextContentSize();a=a>t?t:a,l=l>t?t:l,e.setTextNodeRange(i,a,i,l);}n.stopImmediatePropagation();}});}}}}};return window.addEventListener("message",n,true),()=>{window.removeEventListener("message",n,true);}}const d=Kl({build:(e,n,o)=>at$2(n),config:Bl({disabled:"undefined"==typeof window}),name:"@lexical/dragon",register:(t,n,o)=>dt$3(()=>o.getOutput().disabled.value?void 0:s(t))}); 5286 5287/** 5288 * Copyright (c) Meta Platforms, Inc. and affiliates. 5289 * 5290 * This source code is licensed under the MIT license found in the 5291 * LICENSE file in the root directory of this source tree. 5292 * 5293 */ 5294 5295const L$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,S$1=L$1&&"documentMode"in document?document.documentMode:null,W$3=L$1&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),B$1=!(!L$1||!("InputEvent"in window)||S$1)&&"getTargetRanges"in new window.InputEvent("input"),I$2=L$1&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),R$1=L$1&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,V$3=L$1&&/^(?=.*Chrome).*/i.test(navigator.userAgent),j$1=L$1&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&W$3&&!V$3;function q$2(e,n){n.update(()=>{if(null!==e){const r=Lt$4(e,KeyboardEvent)?null:e.clipboardData,o=Lr();if(null!==o&&!o.isCollapsed()&&null!=r){e.preventDefault();const i=D$1(n);null!==i&&r.setData("text/html",i),r.setData("text/plain",o.getTextContent());}}});}function z$2(t){return U$4(t.registerCommand(le$2,e=>{const t=Lr();return !!yr(t)&&(t.deleteCharacter(e),true)},Ki),t.registerCommand(he$1,e=>{const t=Lr();return !!yr(t)&&(t.deleteWord(e),true)},Ki),t.registerCommand(ge$1,e=>{const t=Lr();return !!yr(t)&&(t.deleteLine(e),true)},Ki),t.registerCommand(ue$1,t=>{const n=Lr();if(!yr(n))return false;if("string"==typeof t)n.insertText(t);else {const r=t.dataTransfer;if(null!=r)N$1(r,n);else {const e=t.data;e&&n.insertText(e);}}return true},Ki),t.registerCommand(de$1,()=>{const e=Lr();return !!yr(e)&&(e.removeText(),true)},Ki),t.registerCommand(ce$1,e=>{const t=Lr();return !!yr(t)&&(t.insertLineBreak(e),true)},Ki),t.registerCommand(ae$1,()=>{const e=Lr();return !!yr(e)&&(e.insertLineBreak(),true)},Ki),t.registerCommand(Se$1,e=>{const t=Lr();if(!yr(t))return false;const n=e,i=n.shiftKey;return !!Z$3(t,true)&&(n.preventDefault(),ne(t,i,true),true)},Ki),t.registerCommand(xe$1,e=>{const t=Lr();if(!yr(t))return false;const n=e,i=n.shiftKey;return !!Z$3(t,false)&&(n.preventDefault(),ne(t,i,false),true)},Ki),t.registerCommand(we$1,e=>{const n=Lr();return !!yr(n)&&((!R$1||"ko-KR"!==navigator.language)&&(e.preventDefault(),t.dispatchCommand(le$2,true)))},Ki),t.registerCommand(Oe$2,e=>{const n=Lr();return !!yr(n)&&(e.preventDefault(),t.dispatchCommand(le$2,false))},Ki),t.registerCommand(Ne$2,e=>{const n=Lr();if(!yr(n))return false;if(null!==e){if((R$1||I$2||j$1)&&B$1)return false;e.preventDefault();}return t.dispatchCommand(ce$1,false)},Ki),t.registerCommand(We$2,()=>(jo(),true),Ki),t.registerCommand(Re$2,e=>{const n=Lr();return !!yr(n)&&(q$2(e,t),true)},Ki),t.registerCommand(Be$2,e=>{const n=Lr();return !!yr(n)&&(function(e,t){q$2(e,t),t.update(()=>{const e=Lr();yr(e)&&e.removeText();});}(e,t),true)},Ki),t.registerCommand(fe$1,n=>{const r=Lr();return !!yr(r)&&(function(t,n){t.preventDefault(),n.update(()=>{const n=Lr(),r=Lt$4(t,ClipboardEvent)?t.clipboardData:null;null!=r&&yr(n)&&N$1(r,n);},{tag:Fn});}(n,t),true)},Ki),t.registerCommand(Fe$2,e=>{const t=Lr();return !!yr(t)&&(e.preventDefault(),true)},Ki),t.registerCommand(Ie$2,e=>{const t=Lr();return !!yr(t)&&(e.preventDefault(),true)},Ki))} 5296
5297/** 5298 * Copyright (c) Meta Platforms, Inc. and affiliates. 5299 * 5300 * This source code is licensed under the MIT license found in the 5301 * LICENSE file in the root directory of this source tree. 5302 * 5303 */ 5304 5305function gt$2(t,e){if(void 0!==document.caretRangeFromPoint){const n=document.caretRangeFromPoint(t,e);return null===n?null:{node:n.startContainer,offset:n.startOffset}}if("undefined"!==document.caretPositionFromPoint){const n=document.caretPositionFromPoint(t,e);return null===n?null:{node:n.offsetNode,offset:n.offset}}return null}const pt$2="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,ht$2=pt$2&&"documentMode"in document?document.documentMode:null,vt$2=pt$2&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Ct$3=!(!pt$2||!("InputEvent"in window)||ht$2)&&"getTargetRanges"in new window.InputEvent("input"),yt$2=pt$2&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xt$2=pt$2&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dt$2=pt$2&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Nt$3=pt$2&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&vt$2&&!Dt$2,wt$3=re$1("DRAG_DROP_PASTE_FILE");let Et$3 = class Et extends Ci{static getType(){return "quote"}static clone(t){return new Et(t.__key)}createDOM(t){const e=document.createElement("blockquote");return lt$4(e,t.theme.quote),e}updateDOM(t,e){return false}static importDOM(){return {blockquote:t=>({conversion:Ft$2,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return _t$2().updateFromJSON(t)}insertNewAfter(t,e){const n=Li(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,e),n}collapseAtStart(){const t=Li();
5305return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}canMergeWhenEmpty(){return true}};function _t$2(){return fs(new Et$3)}function Ot$2(t){return t instanceof Et$3}let Pt$3 = class Pt extends Ci{__tag;static getType(){return "heading"}static clone(t){return new Pt(t.__tag,t.__key)}constructor(t,e){super(e),this.__tag=t;}getTag(){return this.__tag}setTag(t){const e=this.getWritable();return this.__tag=t,e}createDOM(t){const e=this.__tag,n=document.createElement(e),r=t.theme.heading;if(void 0!==r){const t=r[e];lt$4(n,t);}return n}updateDOM(t,e,n){return t.__tag!==this.__tag}static importDOM(){return {h1:t=>({conversion:At$3,priority:0}),h2:t=>({conversion:At$3,priority:0}),h3:t=>({conversion:At$3,priority:0}),h4:t=>({conversion:At$3,priority:0}),h5:t=>({conversion:At$3,priority:0}),h6:t=>({conversion:At$3,priority:0}),p:t=>{const e=t.firstChild;return null!==e&&Tt$3(e)?{conversion:()=>({node:null}),priority:3}:null},span:t=>Tt$3(t)?{conversion:t=>({node:St$3("h1")}),priority:3}:null}}exportDOM(t){const{element:e}=super.exportDOM(t);if(Cs(e)){this.isEmpty()&&e.append(document.createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t);const n=this.getDirection();n&&(e.dir=n);}return {element:e}}static importJSON(t){return St$3(t.tag).updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setTag(t.tag)}exportJSON(){return {...super.exportJSON(),tag:this.getTag()}}insertNewAfter(t,e=true){const n=t?t.anchor.offset:0,r=this.getLastDescendant(),o=!r||t&&t.anchor.key===r.getKey()&&n===r.getTextContentSize()||!t?Li():St$3(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,e),0===n&&!this.isEmpty()&&t){const t=Li();t.select(),this.replace(t,true);}return o}collapseAtStart(){const t=this.isEmpty()?Li():St$3(this.getTag());
5305return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}extractWithChild(){return true}};function Tt$3(t){return "span"===t.nodeName.toLowerCase()&&"26pt"===t.style.fontSize}function At$3(t){const e=t.nodeName.toLowerCase();let n=null;return "h1"!==e&&"h2"!==e&&"h3"!==e&&"h4"!==e&&"h5"!==e&&"h6"!==e||(n=St$3(e),null!==t.style&&(Ps(t,n),n.setFormat(t.style.textAlign))),{node:n}}function Ft$2(t){const e=_t$2();return null!==t.style&&(e.setFormat(t.style.textAlign),Ps(t,e)),{node:e}}function St$3(t="h1"){return fs(new Pt$3(t))}function It$2(t){return t instanceof Pt$3}function Mt$2(t){let e=null;if(Lt$4(t,DragEvent)?e=t.dataTransfer:Lt$4(t,ClipboardEvent)&&(e=t.clipboardData),null===e)return [false,[],false];const n=e.types,r=n.includes("Files"),o=n.includes("text/html")||n.includes("text/plain");return [r,Array.from(e.files),o]}function bt$3(t){const e=Lr();if(!yr(e))return false;const n=new Set,r=e.getNodes();for(let e=0;e<r.length;e++){const o=r[e],i=o.getKey();if(n.has(i))continue;const s=zs(o,t=>Si(t)&&!t.isInline());if(null===s)continue;const c=s.getKey();s.canIndent()&&!n.has(c)&&(n.add(c),t(s));}return n.size>0}function Kt$1(t){const e=vo(t);return Ti(e)}function kt$3(t){for(const e of ["lowercase","uppercase","capitalize"])t.hasFormat(e)&&t.toggleFormat(e);}function Jt$1(n){return U$4(n.registerCommand(se$1,t=>{const e=Lr();return !!xr(e)&&(e.clear(),true)},Ki),n.registerCommand(le$2,t=>{const e=Lr();return yr(e)?(e.deleteCharacter(t),true):!!xr(e)&&(e.deleteNodes(),true)},Ki),n.registerCommand(he$1,t=>{const e=Lr();return !!yr(e)&&(e.deleteWord(t),true)},Ki),n.registerCommand(ge$1,t=>{const e=Lr();return !!yr(e)&&(e.deleteLine(t),true)},Ki),n.registerCommand(ue$1,e=>{const r=Lr();if("string"==typeof e)null!==r&&r.insertText(e);else {if(null===r)return false;const o=e.dataTransfer;if(null!=o)R$2(o,r,n);else if(yr(r)){const t=e.data;return t&&r.insertText(t),true}}return true},Ki),n.registerCommand(de$1,()=>{const t=Lr();return !!yr(t)&&(t.removeText(),true)},Ki),n.registerCommand(_e$1,t=>{const e=Lr();return !!yr(e)&&(e.formatText(t),true)},Ki),n.registerCommand(Le$2,t=>{const e=Lr();if(!yr(e)&&!xr(e))return false;const n=e.getNodes();for(const e of n){const n=zs(e,t=>Si(t)&&!t.isInline());null!==n&&n.setFormat(t);}return true},Ki),n.registerCommand(ce$1,t=>{const e=Lr();return !!yr(e)&&(e.insertLineBreak(t),true)},Ki),n.registerCommand(ae$1,()=>{const t=Lr();return !!yr(t)&&(t.insertParagraph(),true)},Ki),n.registerCommand(Ae$2,()=>(jr([ur()]),true),Ki),n.registerCommand(Pe$2,()=>bt$3(t=>{const e=t.getIndent();t.setIndent(e+1);}),Ki),n.registerCommand(De$2,()=>bt$3(t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1));}),Ki),n.registerCommand(ke$2,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectPrevious(),true}else if(yr(e)){const n=qo(e.focus,true);if(!t.shiftKey&&Ti(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),t.preventDefault(),true}return false},Ki),n.registerCommand(Te$2,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),n[0].selectNext(0,0),true}else if(yr(e)){if(function(t){const e=t.focus;return "root"===e.key&&e.offset===No().getChildrenSize()}(e))return t.preventDefault(),true;const n=qo(e.focus,false);if(!t.shiftKey&&Ti(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),t.preventDefault(),true}return false},Ki),n.registerCommand(Se$1,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$2(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),true}if(!yr(e))return false;if(Z$3(e,true)){const n=t.shiftKey;return t.preventDefault(),ne(e,n,true),true}return false},Ki),n.registerCommand(xe$1,t=>{const e=Lr();if(xr(e)){const n=e.getNodes();if(n.length>0)return t.preventDefault(),A$2(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),true}if(!yr(e))return false;const n=t.shiftKey;return !!Z$3(e,false)&&(t.preventDefault(),ne(e,n,false),true)},Ki),n.registerCommand(we$1,t=>{if(Kt$1(t.target))return false;const e=Lr();if(yr(e)){if(function(t){if(!t.isCollapsed())return false;
5305const{anchor:e}=t;if(0!==e.offset)return false;const n=e.getNode();if(bi(n))return false;const r=xt$5(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(e))return t.preventDefault(),n.dispatchCommand(De$2,void 0);if(xt$2&&"ko-KR"===navigator.language)return false}else if(!xr(e))return false;return t.preventDefault(),n.dispatchCommand(le$2,true)},Ki),n.registerCommand(Oe$2,t=>{if(Kt$1(t.target))return false;const e=Lr();return !(!yr(e)&&!xr(e))&&(t.preventDefault(),n.dispatchCommand(le$2,false))},Ki),n.registerCommand(Ne$2,t=>{const e=Lr();if(!yr(e))return false;if(kt$3(e),null!==t){if((xt$2||yt$2||Nt$3)&&Ct$3)return false;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(ce$1,false)}return n.dispatchCommand(ae$1,void 0)},Ki),n.registerCommand(Ee$2,()=>{const t=Lr();return !!yr(t)&&(n.blur(),true)},Ki),n.registerCommand(Fe$2,t=>{const[,e]=Mt$2(t);if(e.length>0){const r=gt$2(t.clientX,t.clientY);if(null!==r){const{offset:t,node:o}=r,i=vo(o);if(null!==i){const e=Ar();if(lr(i))e.anchor.set(i.getKey(),t,"text"),e.focus.set(i.getKey(),t,"text");else {const t=i.getParentOrThrow().getKey(),n=i.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element");}const n=St$6(e);wo(n);}n.dispatchCommand(wt$3,e);}return t.preventDefault(),true}const r=Lr();return !!yr(r)},Ki),n.registerCommand(Ie$2,t=>{const[e]=Mt$2(t),n=Lr();return !(e&&!yr(n))},Ki),n.registerCommand(Ke$2,t=>{const[e]=Mt$2(t),n=Lr();if(e&&!yr(n))return false;const r=gt$2(t.clientX,t.clientY);if(null!==r){const e=vo(r.node);Ti(e)&&t.preventDefault();}return true},Ki),n.registerCommand(We$2,()=>(jo(),true),Ki),n.registerCommand(Re$2,t=>(F$1(n,Lt$4(t,ClipboardEvent)?t:null),true),Ki),n.registerCommand(Be$2,t=>(async function(t,n){await F$1(n,Lt$4(t,ClipboardEvent)?t:null),n.update(()=>{const t=Lr();yr(t)?t.removeText():xr(t)&&t.getNodes().forEach(t=>t.remove());});}(t,n),true),Ki),n.registerCommand(fe$1,e=>{const[,r,o]=Mt$2(e);if(r.length>0&&!o)return n.dispatchCommand(wt$3,r),true;if(Ss(e.target)&&to(e.target))return false;return null!==Lr()&&(function(e,n){e.preventDefault(),n.update(()=>{const r=Lr(),o=Lt$4(e,InputEvent)||Lt$4(e,KeyboardEvent)?null:e.clipboardData;null!=o&&null!==r&&R$2(o,r,n);},{tag:Fn});}(e,n),true)},Ki),n.registerCommand(be$1,t=>{const e=Lr();return yr(e)&&kt$3(e),false},Ki),n.registerCommand(Me$2,t=>{const e=Lr();return yr(e)&&kt$3(e),false},Ki))}const Wt$2=Kl({conflictsWith:["@lexical/plain-text"],dependencies:[d],name:"@lexical/rich-text",nodes:[Pt$3,Et$3],register:Jt$1}); 5306 5307Prism$1.languages.javascript = Prism$1.languages.extend('clike', { 5308 'class-name': [ 5309 Prism$1.languages.clike['class-name'], 5310 { 5311 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/, 5312 lookbehind: true 5313 } 5314 ], 5315 'keyword': [ 5316 { 5317 pattern: /((?:^|\})\s*)catch\b/, 5318 lookbehind: true 5319 }, 5320 { 5321 pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/, 5322 lookbehind: true 5323 }, 5324 ], 5325 // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) 5326 'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, 5327 'number': { 5328 pattern: RegExp( 5329 /(^|[^\w$])/.source + 5330 '(?:' + 5331 ( 5332 // constant 5333 /NaN|Infinity/.source + 5334 '|' + 5335 // binary integer 5336 /0[bB][01]+(?:_[01]+)*n?/.source + 5337 '|' + 5338 // octal integer 5339 /0[oO][0-7]+(?:_[0-7]+)*n?/.source + 5340 '|' + 5341 // hexadecimal integer 5342 /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + 5343 '|' + 5344 // decimal bigint 5345 /\d+(?:_\d+)*n/.source + 5346 '|' + 5347 // decimal number (integer or float) but no bigint
vendor: 4,609 bytes, lines 5348-5473
5348 /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source 5349 ) + 5350 ')' + 5351 /(?![\w$])/.source 5352 ), 5353 lookbehind: true 5354 }, 5355 'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ 5356}); 5357 5358Prism$1.languages.javascript['class-name'][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/; 5359 5360Prism$1.languages.insertBefore('javascript', 'keyword', { 5361 'regex': { 5362 pattern: RegExp( 5363 // lookbehind 5364 // eslint-disable-next-line regexp/no-dupe-characters-character-class 5365 /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + 5366 // Regex pattern: 5367 // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character 5368 // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible 5369 // with the only syntax, so we have to define 2 different regex patterns. 5370 /\//.source + 5371 '(?:' + 5372 /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + 5373 '|' + 5374 // `v` flag syntax. This supports 3 levels of nested character classes. 5375 /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + 5376 ')' + 5377 // lookahead 5378 /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source 5379 ), 5380 lookbehind: true, 5381 greedy: true, 5382 inside: { 5383 'regex-source': { 5384 pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, 5385 lookbehind: true, 5386 alias: 'language-regex', 5387 inside: Prism$1.languages.regex 5388 }, 5389 'regex-delimiter': /^\/|\/$/, 5390 'regex-flags': /^[a-z]+$/, 5391 } 5392 }, 5393 // This must be declared before keyword because we use "function" inside the look-forward 5394 'function-variable': { 5395 pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, 5396 alias: 'function' 5397 }, 5398 'parameter': [ 5399 { 5400 pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, 5401 lookbehind: true, 5402 inside: Prism$1.languages.javascript 5403 }, 5404 { 5405 pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, 5406 lookbehind: true, 5407 inside: Prism$1.languages.javascript 5408 }, 5409 { 5410 pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, 5411 lookbehind: true, 5412 inside: Prism$1.languages.javascript 5413 }, 5414 { 5415 pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, 5416 lookbehind: true, 5417 inside: Prism$1.languages.javascript 5418 } 5419 ], 5420 'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/ 5421}); 5422 5423Prism$1.languages.insertBefore('javascript', 'string', { 5424 'hashbang': { 5425 pattern: /^#!.*/, 5426 greedy: true, 5427 alias: 'comment' 5428 }, 5429 'template-string': { 5430 pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/, 5431 greedy: true, 5432 inside: { 5433 'template-punctuation': { 5434 pattern: /^`|`$/, 5435 alias: 'string' 5436 }, 5437 'interpolation': { 5438 pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/, 5439 lookbehind: true, 5440 inside: { 5441 'interpolation-punctuation': { 5442 pattern: /^\$\{|\}$/, 5443 alias: 'punctuation' 5444 }, 5445 rest: Prism$1.languages.javascript 5446 } 5447 }, 5448 'string': /[\s\S]+/ 5449 } 5450 }, 5451 'string-property': { 5452 pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m, 5453 lookbehind: true, 5454 greedy: true, 5455 alias: 'property' 5456 } 5457}); 5458 5459Prism$1.languages.insertBefore('javascript', 'operator', { 5460 'literal-property': { 5461 pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m, 5462 lookbehind: true, 5463 alias: 'property' 5464 }, 5465}); 5466 5467if (Prism$1.languages.markup) { 5468 Prism$1.languages.markup.tag.addInlined('script', 'javascript'); 5469 5470 // add attribute support for all DOM events. 5471 // https://developer.mozilla.org/en-US/docs/Web/Events#Standard_events 5472 Prism$1.languages.markup.tag.addAttribute( 5473 /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?
vendor: 12,928 bytes, lines 5473-5950
5473:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source, 5474 'javascript' 5475 ); 5476} 5477 5478Prism$1.languages.js = Prism$1.languages.javascript; 5479 5480(function (Prism) { 5481 5482 // Allow only one line break 5483 var inner = /(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source; 5484 5485 /** 5486 * This function is intended for the creation of the bold or italic pattern. 5487 * 5488 * This also adds a lookbehind group to the given pattern to ensure that the pattern is not backslash-escaped. 5489 * 5490 * _Note:_ Keep in mind that this adds a capturing group. 5491 * 5492 * @param {string} pattern 5493 * @returns {RegExp} 5494 */ 5495 function createInline(pattern) { 5496 pattern = pattern.replace(/<inner>/g, function () { return inner; }); 5497 return RegExp(/((?:^|[^\\])(?:\\{2})*)/.source + '(?:' + pattern + ')'); 5498 } 5499 5500 5501 var tableCell = /(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source; 5502 var tableRow = /\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g, function () { return tableCell; }); 5503 var tableLine = /\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source; 5504 5505 5506 Prism.languages.markdown = Prism.languages.extend('markup', {}); 5507 Prism.languages.insertBefore('markdown', 'prolog', { 5508 'front-matter-block': { 5509 pattern: /(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/, 5510 lookbehind: true, 5511 greedy: true, 5512 inside: { 5513 'punctuation': /^---|---$/, 5514 'front-matter': { 5515 pattern: /\S+(?:\s+\S+)*/, 5516 alias: ['yaml', 'language-yaml'], 5517 inside: Prism.languages.yaml 5518 } 5519 } 5520 }, 5521 'blockquote': { 5522 // > ... 5523 pattern: /^>(?:[\t ]*>)*/m, 5524 alias: 'punctuation' 5525 }, 5526 'table': { 5527 pattern: RegExp('^' + tableRow + tableLine + '(?:' + tableRow + ')*', 'm'), 5528 inside: { 5529 'table-data-rows': { 5530 pattern: RegExp('^(' + tableRow + tableLine + ')(?:' + tableRow + ')*$'), 5531 lookbehind: true, 5532 inside: { 5533 'table-data': { 5534 pattern: RegExp(tableCell), 5535 inside: Prism.languages.markdown 5536 }, 5537 'punctuation': /\|/ 5538 } 5539 }, 5540 'table-line': { 5541 pattern: RegExp('^(' + tableRow + ')' + tableLine + '$'), 5542 lookbehind: true, 5543 inside: { 5544 'punctuation': /\||:?-{3,}:?/ 5545 } 5546 }, 5547 'table-header-row': { 5548 pattern: RegExp('^' + tableRow + '$'), 5549 inside: { 5550 'table-header': { 5551 pattern: RegExp(tableCell), 5552 alias: 'important', 5553 inside: Prism.languages.markdown 5554 }, 5555 'punctuation': /\|/ 5556 } 5557 } 5558 } 5559 }, 5560 'code': [ 5561 { 5562 // Prefixed by 4 spaces or 1 tab and preceded by an empty line 5563 pattern: /((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/, 5564 lookbehind: true, 5565 alias: 'keyword' 5566 }, 5567 { 5568 // ```optional language 5569 // code block 5570 // ``` 5571 pattern: /^```[\s\S]*?^```$/m, 5572 greedy: true, 5573 inside: { 5574 'code-block': { 5575 pattern: /^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m, 5576 lookbehind: true 5577 }, 5578 'code-language': { 5579 pattern: /^(```).+/, 5580 lookbehind: true 5581 }, 5582 'punctuation': /```/ 5583 } 5584 } 5585 ], 5586 'title': [ 5587 { 5588 // title 1 5589 // ======= 5590 5591 // title 2 5592 // ------- 5593 pattern: /\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m, 5594 alias: 'important', 5595 inside: { 5596 punctuation: /==+$|--+$/ 5597 } 5598 }, 5599 { 5600 // # title 1 5601 // ###### title 6 5602 pattern: /(^\s*)#.+/m, 5603 lookbehind: true, 5604 alias: 'important', 5605 inside: { 5606 punctuation: /^#+|#+$/ 5607 } 5608 } 5609 ], 5610 'hr': { 5611 // *** 5612 // --- 5613 // * * * 5614 // ----------- 5615 pattern: /(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m, 5616 lookbehind: true, 5617 alias: 'punctuation' 5618 }, 5619 'list': { 5620 // * item 5621 // + item 5622 // - item 5623 // 1. item 5624 pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m, 5625 lookbehind: true, 5626 alias: 'punctuation' 5627 }, 5628 'url-reference': { 5629 // [id]: http://example.com "Optional title" 5630 // [id]: http://example.com 'Optional title' 5631 // [id]: http://example.com (Optional title) 5632 // [id]: <http://example.com> "Optional title" 5633 pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/, 5634 inside: { 5635 'variable': { 5636 pattern: /^(!?\[)[^\]]+/, 5637 lookbehind: true 5638 }, 5639 'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/, 5640 'punctuation': /^[\[\]!:]|[<>]/ 5641 }, 5642 alias: 'url' 5643 }, 5644 'bold': { 5645 // **strong** 5646 // __strong__ 5647 5648 // allow one nested instance of italic text using the same delimiter 5649 pattern: createInline(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source), 5650 lookbehind: true, 5651 greedy: true, 5652 inside: { 5653 'content': { 5654 pattern: /(^..)[\s\S]+(?=..$)/, 5655 lookbehind: true, 5656 inside: {} // see below 5657 }, 5658 'punctuation': /\*\*|__/ 5659 } 5660 }, 5661 'italic': { 5662 // *em* 5663 // _em_ 5664 5665 // allow one nested instance of bold text using the same delimiter 5666 pattern: createInline(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source), 5667 lookbehind: true, 5668 greedy: true, 5669 inside: { 5670 'content': { 5671 pattern: /(^.)[\s\S]+(?=.$)/, 5672 lookbehind: true, 5673 inside: {} // see below 5674 }, 5675 'punctuation': /[*_]/ 5676 } 5677 }, 5678 'strike': { 5679 // ~~strike through~~ 5680 // ~strike~ 5681 // eslint-disable-next-line regexp/strict 5682 pattern: createInline(/(~~?)(?:(?!~)<inner>)+\2/.source), 5683 lookbehind: true, 5684 greedy: true, 5685 inside: { 5686 'content': { 5687 pattern: /(^~~?)[\s\S]+(?=\1$)/, 5688 lookbehind: true, 5689 inside: {} // see below 5690 }, 5691 'punctuation': /~~?/ 5692 } 5693 }, 5694 'code-snippet': { 5695 // `code` 5696 // ``code`` 5697 pattern: /(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/, 5698 lookbehind: true, 5699 greedy: true, 5700 alias: ['code', 'keyword'] 5701 }, 5702 'url': { 5703 // [example](http://example.com "Optional title") 5704 // [example][id] 5705 // [example] [id] 5706 pattern: createInline(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source), 5707 lookbehind: true, 5708 greedy: true, 5709 inside: { 5710 'operator': /^!/, 5711 'content': { 5712 pattern: /(^\[)[^\]]+(?=\])/, 5713 lookbehind: true, 5714 inside: {} // see below 5715 }, 5716 'variable': { 5717 pattern: /(^\][ \t]?\[)[^\]]+(?=\]$)/, 5718 lookbehind: true 5719 }, 5720 'url': { 5721 pattern: /(^\]\()[^\s)]+/, 5722 lookbehind: true 5723 }, 5724 'string': { 5725 pattern: /(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/, 5726 lookbehind: true 5727 } 5728 } 5729 } 5730 }); 5731 5732 ['url', 'bold', 'italic', 'strike'].forEach(function (token) { 5733 ['url', 'bold', 'italic', 'strike', 'code-snippet'].forEach(function (inside) { 5734 if (token !== inside) { 5735 Prism.languages.markdown[token].inside.content.inside[inside] = Prism.languages.markdown[inside]; 5736 } 5737 }); 5738 }); 5739 5740 Prism.hooks.add('after-tokenize', function (env) { 5741 if (env.language !== 'markdown' && env.language !== 'md') { 5742 return; 5743 } 5744 5745 function walkTokens(tokens) { 5746 if (!tokens || typeof tokens === 'string') { 5747 return; 5748 } 5749 5750 for (var i = 0, l = tokens.length; i < l; i++) { 5751 var token = tokens[i]; 5752 5753 if (token.type !== 'code') { 5754 walkTokens(token.content); 5755 continue; 5756 } 5757 5758 /* 5759 * Add the correct `language-xxxx` class to this code block. Keep in mind that the `code-language` token 5760 * is optional. But the grammar is defined so that there is only one case we have to handle: 5761 * 5762 * token.content = [ 5763 * <span class="punctuation">```</span>, 5764 * <span class="code-language">xxxx</span>, 5765 * '\n', // exactly one new lines (\r or \n or \r\n) 5766 * <span class="code-block">...</span>, 5767 * '\n', // exactly one new lines again 5768 * <span class="punctuation">```</span> 5769 * ]; 5770 */ 5771 5772 var codeLang = token.content[1]; 5773 var codeBlock = token.content[3]; 5774 5775 if (codeLang && codeBlock && 5776 codeLang.type === 'code-language' && codeBlock.type === 'code-block' && 5777 typeof codeLang.content === 'string') { 5778 5779 // this might be a language that Prism does not support 5780 5781 // do some replacements to support C++, C#, and F# 5782 var lang = codeLang.content.replace(/\b#/g, 'sharp').replace(/\b\+\+/g, 'pp'); 5783 // only use the first word 5784 lang = (/[a-z][\w-]*/i.exec(lang) || [''])[0].toLowerCase(); 5785 var alias = 'language-' + lang; 5786 5787 // add alias 5788 if (!codeBlock.alias) { 5789 codeBlock.alias = [alias]; 5790 } else if (typeof codeBlock.alias === 'string') { 5791 codeBlock.alias = [codeBlock.alias, alias]; 5792 } else { 5793 codeBlock.alias.push(alias); 5794 } 5795 } 5796 } 5797 } 5798 5799 walkTokens(env.tokens); 5800 }); 5801 5802 Prism.hooks.add('wrap', function (env) { 5803 if (env.type !== 'code-block') { 5804 return; 5805 } 5806 5807 var codeLang = ''; 5808 for (var i = 0, l = env.classes.length; i < l; i++) { 5809 var cls = env.classes[i]; 5810 var match = /language-(.+)/.exec(cls); 5811 if (match) { 5812 codeLang = match[1]; 5813 break; 5814 } 5815 } 5816 5817 var grammar = Prism.languages[codeLang]; 5818 5819 if (!grammar) { 5820 if (codeLang && codeLang !== 'none' && Prism.plugins.autoloader) { 5821 var id = 'md-' + new Date().valueOf() + '-' + Math.floor(Math.random() * 1e16); 5822 env.attributes['id'] = id; 5823 5824 Prism.plugins.autoloader.loadLanguages(codeLang, function () { 5825 var ele = document.getElementById(id); 5826 if (ele) { 5827 ele.innerHTML = Prism.highlight(ele.textContent, Prism.languages[codeLang], codeLang); 5828 } 5829 }); 5830 } 5831 } else { 5832 env.content = Prism.highlight(textContent(env.content), grammar, codeLang); 5833 } 5834 }); 5835 5836 var tagPattern = RegExp(Prism.languages.markup.tag.pattern.source, 'gi'); 5837 5838 /** 5839 * A list of known entity names. 5840 * 5841 * This will always be incomplete to save space. The current list is the one used by lowdash's unescape function. 5842 * 5843 * @see {@link https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2} 5844 */ 5845 var KNOWN_ENTITY_NAMES = { 5846 'amp': '&', 5847 'lt': '<', 5848 'gt': '>', 5849 'quot': '"', 5850 }; 5851 5852 // IE 11 doesn't support `String.fromCodePoint` 5853 var fromCodePoint = String.fromCodePoint || String.fromCharCode; 5854 5855 /** 5856 * Returns the text content of a given HTML source code string. 5857 * 5858 * @param {string} html 5859 * @returns {string} 5860 */ 5861 function textContent(html) { 5862 // remove all tags 5863 var text = html.replace(tagPattern, ''); 5864 5865 // decode known entities 5866 text = text.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function (m, code) { 5867 code = code.toLowerCase(); 5868 5869 if (code[0] === '#') { 5870 var value; 5871 if (code[1] === 'x') { 5872 value = parseInt(code.slice(2), 16); 5873 } else { 5874 value = Number(code.slice(1)); 5875 } 5876 5877 return fromCodePoint(value); 5878 } else { 5879 var known = KNOWN_ENTITY_NAMES[code]; 5880 if (known) { 5881 return known; 5882 } 5883 5884 // unable to decode 5885 return m; 5886 } 5887 }); 5888 5889 return text; 5890 } 5891 5892 Prism.languages.md = Prism.languages.markdown; 5893 5894}(Prism$1)); 5895 5896Prism$1.languages.c = Prism$1.languages.extend('clike', { 5897 'comment': { 5898 pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/, 5899 greedy: true 5900 }, 5901 'string': { 5902 // https://en.cppreference.com/w/c/language/string_literal 5903 pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/, 5904 greedy: true 5905 }, 5906 'class-name': { 5907 pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/, 5908 lookbehind: true 5909 }, 5910 'keyword': /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/, 5911 'function': /\b[a-z_]\w*(?=\s*\()/i, 5912 'number': /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i, 5913 'operator': />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/ 5914}); 5915 5916Prism$1.languages.insertBefore('c', 'string', { 5917 'char': { 5918 // https://en.cppreference.com/w/c/language/character_constant 5919 pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/, 5920 greedy: true 5921 } 5922}); 5923 5924Prism$1.languages.insertBefore('c', 'string', { 5925 'macro': { 5926 // allow for multiline macro definitions 5927 // spaces after the # character compile fine with gcc 5928 pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im, 5929 lookbehind: true, 5930 greedy: true, 5931 alias: 'property', 5932 inside: { 5933 'string': [ 5934 { 5935 // highlight the path of the include statement as a string 5936 pattern: /^(#\s*include\s*)<[^>]+>/, 5937 lookbehind: true 5938 }, 5939 Prism$1.languages.c['string'] 5940 ], 5941 'char': Prism$1.languages.c['char'], 5942 'comment': Prism$1.languages.c['comment'], 5943 'macro-name': [ 5944 { 5945 pattern: /(^#\s*define\s+)\w+\b(?!\()/i, 5946 lookbehind: true 5947 }, 5948 { 5949 pattern: /(^#\s*define\s+)\w+\b(?=\()/i, 5950 lookbehind: true,
5951 alias: 'function' 5952 } 5953 ], 5954 // highlight macro directives as keywords 5955 'directive': { 5956 pattern: /^(#\s*)[a-z]+/, 5957 lookbehind: true, 5958 alias: 'keyword' 5959 }, 5960 'directive-hash': /^#/, 5961 'punctuation': /##|\\(?=[\r\n])/, 5962 'expression': { 5963 pattern: /\S[\s\S]*/, 5964 inside: Prism$1.languages.c 5965 } 5966 } 5967 } 5968}); 5969 5970Prism$1.languages.insertBefore('c', 'function', { 5971 // highlight predefined macros as constants 5972 'constant': /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/ 5973}); 5974 5975delete Prism$1.languages.c['boolean']; 5976 5977(function (Prism) { 5978 5979 var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/; 5980 5981 Prism.languages.css = { 5982 'comment': /\/\*[\s\S]*?\*\//, 5983 'atrule': { 5984 pattern: RegExp('@[\\w-](?:' + /[^;{\s"']|\s+(?!\s)/.source + '|' + string.source + ')*?' + /(?:;|(?=\s*\{))/.source), 5985 inside: { 5986 'rule': /^@[\w-]+/, 5987 'selector-function-argument': { 5988 pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, 5989 lookbehind: true, 5990 alias: 'selector' 5991 }, 5992 'keyword': { 5993 pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/, 5994 lookbehind: true 5995 } 5996 // See rest below 5997 } 5998 }, 5999 'url': { 6000 // https://drafts.csswg.org/css-values-3/#urls 6001 pattern: RegExp('\\burl\\((?:' + string.source + '|' + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ')\\)', 'i'), 6002 greedy: true, 6003 inside: { 6004 'function': /^url/i, 6005 'punctuation': /^\(|\)$/, 6006 'string': { 6007 pattern: RegExp('^' + string.source + '$'), 6008 alias: 'url' 6009 } 6010 } 6011 }, 6012 'selector': { 6013 pattern: RegExp('(^|[{}\\s])[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'), 6014 lookbehind: true 6015 }, 6016 'string': { 6017 pattern: string, 6018 greedy: true 6019 }, 6020 'property': { 6021 pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, 6022 lookbehind: true 6023 }, 6024 'important': /!important\b/i, 6025 'function': { 6026 pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i, 6027 lookbehind: true 6028 }, 6029 'punctuation': /[(){};:,]/ 6030 }; 6031 6032 Prism.languages.css['atrule'].inside.rest = Prism.languages.css; 6033 6034 var markup = Prism.languages.markup; 6035 if (markup) { 6036 markup.tag.addInlined('style', 'css'); 6037 markup.tag.addAttribute('style', 'css'); 6038 } 6039 6040}(Prism$1)); 6041 6042Prism$1.languages.objectivec = Prism$1.languages.extend('c', { 6043 'string': { 6044 pattern: /@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/, 6045 greedy: true 6046 }, 6047 'keyword': /\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/, 6048 'operator': /-[->]?|\+\+?|!=?|<<?=?|>>?=?|==?|&&?|\|\|?|[~^%?*\/@]/ 6049}); 6050 6051delete Prism$1.languages.objectivec['class-name']; 6052 6053Prism$1.languages.objc = Prism$1.languages.objectivec; 6054 6055Prism$1.languages.sql = { 6056 'comment': { 6057 pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/, 6058 lookbehind: true 6059 }, 6060 'variable': [ 6061 { 6062 pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/, 6063 greedy: true 6064 }, 6065 /@[\w.$]+/ 6066 ], 6067 'string': { 6068 pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/, 6069 greedy: true, 6070 lookbehind: true 6071 }, 6072 'identifier': { 6073 pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/, 6074 greedy: true, 6075 lookbehind: true, 6076 inside: { 6077 'punctuation': /^`|`$/ 6078 } 6079 }, 6080 'function': /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i, // Should we highlight user defined functions too? 6081 'keyword': /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECI
6081MAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i, 6082 'boolean': /\b(?:FALSE|NULL|TRUE)\b/i, 6083 'number': /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i, 6084 'operator': /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i, 6085 'punctuation': /[;[\]()`,.]/ 6086}; 6087 6088(function (Prism) { 6089 6090 var powershell = Prism.languages.powershell = { 6091 'comment': [ 6092 { 6093 pattern: /(^|[^`])<#[\s\S]*?#>/, 6094 lookbehind: true 6095 }, 6096 { 6097 pattern: /(^|[^`])#.*/, 6098 lookbehind: true 6099 } 6100 ], 6101 'string': [ 6102 { 6103 pattern: /"(?:`[\s\S]|[^`"])*"/, 6104 greedy: true, 6105 inside: null // see below 6106 }, 6107 { 6108 pattern: /'(?:[^']|'')*'/, 6109 greedy: true 6110 } 6111 ], 6112 // Matches name spaces as well as casts, attribute decorators. Force starting with letter to avoid matching array indices 6113 // Supports two levels of nested brackets (e.g. `[OutputType([System.Collections.Generic.List[int]])]`) 6114 'namespace': /\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i, 6115 'boolean': /\$(?:false|true)\b/i, 6116 'variable': /\$\w+\b/, 6117 // Cmdlets and aliases. Aliases should come last, otherwise "write" gets preferred over "write-host" for example 6118 // Get-Command | ?{ $_.ModuleName -match "Microsoft.PowerShell.(Util|Core|Management)" } 6119 // Get-Alias | ?{ $_.ReferencedCommand.Module.Name -match "Microsoft.PowerShell.(Util|Core|Management)" } 6120 'function': [ 6121 /\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,
6122 /\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i 6123 ], 6124 // per http://technet.microsoft.com/en-us/library/hh847744.aspx 6125 'keyword': /\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i, 6126 'operator': { 6127 pattern: /(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i, 6128 lookbehind: true 6129 }, 6130 'punctuation': /[|{}[\];(),.]/ 6131 }; 6132 6133 // Variable interpolation inside strings, and nested expressions 6134 powershell.string[0].inside = { 6135 'function': { 6136 // Allow for one level of nesting 6137 pattern: /(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/, 6138 lookbehind: true, 6139 inside: powershell 6140 }, 6141 'boolean': powershell.boolean, 6142 'variable': powershell.variable, 6143 }; 6144 6145}(Prism$1)); 6146 6147var prismPython = {}; 6148 6149var hasRequiredPrismPython; 6150 6151function requirePrismPython () { 6152 if (hasRequiredPrismPython) return prismPython; 6153 hasRequiredPrismPython = 1; 6154 Prism$1.languages.python = { 6155 'comment': { 6156 pattern: /(^|[^\\])#.*/, 6157 lookbehind: true, 6158 greedy: true 6159 }, 6160 'string-interpolation': { 6161 pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i, 6162 greedy: true, 6163 inside: { 6164 'interpolation': { 6165 // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}" 6166 pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/, 6167 lookbehind: true, 6168 inside: { 6169 'format-spec': { 6170 pattern: /(:)[^:(){}]+(?=\}$)/, 6171 lookbehind: true 6172 }, 6173 'conversion-option': { 6174 pattern: //, 6175 alias: 'punctuation' 6176 }, 6177 rest: null 6178 } 6179 }, 6180 'string': /[\s\S]+/ 6181 } 6182 }, 6183 'triple-quoted-string': { 6184 pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i, 6185 greedy: true, 6186 alias: 'string' 6187 }, 6188 'string': { 6189 pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i, 6190 greedy: true 6191 }, 6192 'function': { 6193 pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g, 6194 lookbehind: true 6195 }, 6196 'class-name': { 6197 pattern: /(\bclass\s+)\w+/i, 6198 lookbehind: true 6199 }, 6200 'decorator': { 6201 pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m, 6202 lookbehind: true, 6203 alias: ['annotation', 'punctuation'], 6204 inside: { 6205 'punctuation': /\./ 6206 } 6207 }, 6208 'keyword': /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/, 6209 'builtin': /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/, 6210 'boolean': /\b(?:False|None|True)\b/, 6211 'number': /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i, 6212 'operator': /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/, 6213 'punctuation': /[{}[\];(),.:]/ 6214 }; 6215 6216 Prism$1.languages.python['string-interpolation'].inside['interpolation'].inside.rest = Prism$1.languages.python; 6217 6218 Prism$1.languages.py = Prism$1.languages.python; 6219 return prismPython; 6220} 6221 6222requirePrismPython(); 6223 6224var prismRust = {}; 6225 6226var hasRequiredPrismRust; 6227 6228function requirePrismRust () { 6229 if (hasRequiredPrismRust) return prismRust; 6230 hasRequiredPrismRust = 1; 6231 (function (Prism) { 6232 6233 var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source; 6234 for (var i = 0; i < 2; i++) { 6235 // support 4 levels of nested comments 6236 multilineComment = multilineComment.replace(/<self>/g, function () { return multilineComment; }); 6237 } 6238 multilineComment = multilineComment.replace(/<self>/g, function () { return /[^\s\S]/.source; }); 6239 6240 6241 Prism.languages.rust = { 6242 'comment': [ 6243 { 6244 pattern: RegExp(/(^|[^\\])/.source + multilineComment), 6245 lookbehind: true, 6246 greedy: true 6247 }, 6248 { 6249 pattern: /(^|[^\\:])\/\/.*/, 6250 lookbehind: true, 6251 greedy: true 6252 } 6253 ], 6254 'string': {
6255 pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/, 6256 greedy: true 6257 }, 6258 'char': { 6259 pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/, 6260 greedy: true 6261 }, 6262 'attribute': { 6263 pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/, 6264 greedy: true, 6265 alias: 'attr-name', 6266 inside: { 6267 'string': null // see below 6268 } 6269 }, 6270 6271 // Closure params should not be confused with bitwise OR | 6272 'closure-params': { 6273 pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/, 6274 lookbehind: true, 6275 greedy: true, 6276 inside: { 6277 'closure-punctuation': { 6278 pattern: /^\||\|$/, 6279 alias: 'punctuation' 6280 }, 6281 rest: null // see below 6282 } 6283 }, 6284 6285 'lifetime-annotation': { 6286 pattern: /'\w+/, 6287 alias: 'symbol' 6288 }, 6289 6290 'fragment-specifier': { 6291 pattern: /(\$\w+:)[a-z]+/, 6292 lookbehind: true, 6293 alias: 'punctuation' 6294 }, 6295 'variable': /\$\w+/, 6296 6297 'function-definition': { 6298 pattern: /(\bfn\s+)\w+/, 6299 lookbehind: true, 6300 alias: 'function' 6301 }, 6302 'type-definition': { 6303 pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/, 6304 lookbehind: true, 6305 alias: 'class-name' 6306 }, 6307 'module-declaration': [ 6308 { 6309 pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/, 6310 lookbehind: true, 6311 alias: 'namespace' 6312 }, 6313 { 6314 pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/, 6315 lookbehind: true, 6316 alias: 'namespace', 6317 inside: { 6318 'punctuation': /::/ 6319 } 6320 } 6321 ], 6322 'keyword': [ 6323 // https://github.com/rust-lang/reference/blob/master/src/keywords.md 6324 /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/, 6325 // primitives and str 6326 // https://doc.rust-lang.org/stable/rust-by-example/primitives.html 6327 /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/ 6328 ], 6329 6330 // functions can technically start with an upper-case letter, but this will introduce a lot of false positives 6331 // and Rust's naming conventions recommend snake_case anyway. 6332 // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html 6333 'function': /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/, 6334 'macro': { 6335 pattern: /\b\w+!/, 6336 alias: 'property' 6337 }, 6338 'constant': /\b[A-Z_][A-Z_\d]+\b/, 6339 'class-name': /\b[A-Z]\w*\b/, 6340 6341 'namespace': { 6342 pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/, 6343 inside: { 6344 'punctuation': /::/ 6345 } 6346 }, 6347 6348 // Hex, oct, bin, dec numbers with visual separators and type suffix 6349 'number': /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/, 6350 'boolean': /\b(?:false|true)\b/, 6351 'punctuation': /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/, 6352 'operator': /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/ 6353 }; 6354 6355 Prism.languages.rust['closure-params'].inside.rest = Prism.languages.rust; 6356 Prism.languages.rust['attribute'].inside['string'] = Prism.languages.rust['string']; 6357 6358 }(Prism$1)); 6359 return prismRust; 6360} 6361 6362requirePrismRust(); 6363 6364Prism$1.languages.swift = { 6365 'comment': { 6366 // Nested comments are supported up to 2 levels 6367 pattern: /(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/, 6368 lookbehind: true, 6369 greedy: true 6370 }, 6371 'string-literal': [ 6372 // https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html 6373 { 6374 pattern: RegExp( 6375 /(^|[^"#])/.source 6376 + '(?:' 6377 // single-line string
6378 + /"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source 6379 + '|' 6380 // multi-line string 6381 + /"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source 6382 + ')' 6383 + /(?!["#])/.source 6384 ), 6385 lookbehind: true, 6386 greedy: true, 6387 inside: { 6388 'interpolation': { 6389 pattern: /(\\\()(?:[^()]|\([^()]*\))*(?=\))/, 6390 lookbehind: true, 6391 inside: null // see below 6392 }, 6393 'interpolation-punctuation': { 6394 pattern: /^\)|\\\($/, 6395 alias: 'punctuation' 6396 }, 6397 'punctuation': /\\(?=[\r\n])/, 6398 'string': /[\s\S]+/ 6399 } 6400 }, 6401 { 6402 pattern: RegExp( 6403 /(^|[^"#])(#+)/.source 6404 + '(?:' 6405 // single-line string 6406 + /"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source 6407 + '|' 6408 // multi-line string 6409 + /"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source 6410 + ')' 6411 + '\\2' 6412 ), 6413 lookbehind: true, 6414 greedy: true, 6415 inside: { 6416 'interpolation': { 6417 pattern: /(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/, 6418 lookbehind: true, 6419 inside: null // see below 6420 }, 6421 'interpolation-punctuation': { 6422 pattern: /^\)|\\#+\($/, 6423 alias: 'punctuation' 6424 }, 6425 'string': /[\s\S]+/ 6426 } 6427 }, 6428 ], 6429 6430 'directive': { 6431 // directives with conditions 6432 pattern: RegExp( 6433 /#/.source 6434 + '(?:' 6435 + ( 6436 /(?:elseif|if)\b/.source 6437 + '(?:[ \t]*' 6438 // This regex is a little complex. It's equivalent to this: 6439 // (?:![ \t]*)?(?:\b\w+\b(?:[ \t]*<round>)?|<round>)(?:[ \t]*(?:&&|\|\|))? 6440 // where <round> is a general parentheses expression. 6441 + /(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source 6442 + ')+' 6443 ) 6444 + '|' 6445 + /(?:else|endif)\b/.source 6446 + ')' 6447 ), 6448 alias: 'property', 6449 inside: { 6450 'directive-name': /^#\w+/, 6451 'boolean': /\b(?:false|true)\b/, 6452 'number': /\b\d+(?:\.\d+)*\b/, 6453 'operator': /!|&&|\|\||[<>]=?/, 6454 'punctuation': /[(),]/ 6455 } 6456 }, 6457 'literal': { 6458 pattern: /#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/, 6459 alias: 'constant' 6460 }, 6461 'other-directive': { 6462 pattern: /#\w+\b/, 6463 alias: 'property' 6464 }, 6465 6466 'attribute': { 6467 pattern: /@\w+/, 6468 alias: 'atrule' 6469 }, 6470 6471 'function-definition': { 6472 pattern: /(\bfunc\s+)\w+/, 6473 lookbehind: true, 6474 alias: 'function' 6475 }, 6476 'label': { 6477 // https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html#ID141 6478 pattern: /\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/, 6479 lookbehind: true, 6480 alias: 'important' 6481 }, 6482 6483 'keyword': /\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/, 6484 'boolean': /\b(?:false|true)\b/, 6485 'nil': { 6486 pattern: /\bnil\b/, 6487 alias: 'constant' 6488 }, 6489 6490 'short-argument': /\$\d+\b/, 6491 'omit': { 6492 pattern: /\b_\b/, 6493 alias: 'keyword' 6494 }, 6495 'number': /\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i, 6496 6497 // A class name must start with an upper-case letter and be either 1 letter long or contain a lower-case letter. 6498 'class-name': /\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/, 6499 'function': /\b[a-z_]\w*(?=\s*\()/i, 6500 'constant': /\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/, 6501 6502 // Operators are generic in Swift. Developers can even create new operators (e.g. +++). 6503 // https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html#ID481 6504 // This regex only supports ASCII operators. 6505 'operator': /[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/, 6506 'punctuation': /[{}[\]();,.:\\]/ 6507}; 6508 6509Prism$1.languages.swift['string-literal'].forEach(function (rule) {
6510 rule.inside['interpolation'].inside = Prism$1.languages.swift; 6511}); 6512 6513var prismTypescript = {}; 6514 6515var hasRequiredPrismTypescript; 6516 6517function requirePrismTypescript () { 6518 if (hasRequiredPrismTypescript) return prismTypescript; 6519 hasRequiredPrismTypescript = 1; 6520 (function (Prism) { 6521 6522 Prism.languages.typescript = Prism.languages.extend('javascript', { 6523 'class-name': { 6524 pattern: /(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/, 6525 lookbehind: true, 6526 greedy: true, 6527 inside: null // see below 6528 }, 6529 'builtin': /\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/, 6530 }); 6531 6532 // The keywords TypeScript adds to JavaScript 6533 Prism.languages.typescript.keyword.push( 6534 /\b(?:abstract|declare|is|keyof|readonly|require)\b/, 6535 // keywords that have to be followed by an identifier 6536 /\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/, 6537 // This is for `import type *, {}` 6538 /\btype\b(?=\s*(?:[\{*]|$))/ 6539 ); 6540 6541 // doesn't work with TS because TS is too complex 6542 delete Prism.languages.typescript['parameter']; 6543 delete Prism.languages.typescript['literal-property']; 6544 6545 // a version of typescript specifically for highlighting types 6546 var typeInside = Prism.languages.extend('typescript', {}); 6547 delete typeInside['class-name']; 6548 6549 Prism.languages.typescript['class-name'].inside = typeInside; 6550 6551 Prism.languages.insertBefore('typescript', 'function', { 6552 'decorator': { 6553 pattern: /@[$\w\xA0-\uFFFF]+/, 6554 inside: { 6555 'at': { 6556 pattern: /^@/, 6557 alias: 'operator' 6558 }, 6559 'function': /^[\s\S]+/ 6560 } 6561 }, 6562 'generic-function': { 6563 // e.g. foo<T extends "bar" | "baz">( ... 6564 pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/, 6565 greedy: true, 6566 inside: { 6567 'function': /^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/, 6568 'generic': { 6569 pattern: /<[\s\S]+/, // everything after the first < 6570 alias: 'class-name', 6571 inside: typeInside 6572 } 6573 } 6574 } 6575 }); 6576 6577 Prism.languages.ts = Prism.languages.typescript; 6578 6579 }(Prism$1)); 6580 return prismTypescript; 6581} 6582 6583requirePrismTypescript(); 6584 6585var prismJava = {}; 6586 6587var hasRequiredPrismJava; 6588 6589function requirePrismJava () { 6590 if (hasRequiredPrismJava) return prismJava; 6591 hasRequiredPrismJava = 1; 6592 (function (Prism) { 6593 6594 var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/; 6595 6596 // full package (optional) + parent classes (optional) 6597 var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source; 6598 6599 // based on the java naming conventions 6600 var className = { 6601 pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source), 6602 lookbehind: true, 6603 inside: { 6604 'namespace': { 6605 pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/, 6606 inside: { 6607 'punctuation': /\./ 6608 } 6609 }, 6610 'punctuation': /\./ 6611 } 6612 }; 6613 6614 Prism.languages.java = Prism.languages.extend('clike', { 6615 'string': { 6616 pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/, 6617 lookbehind: true, 6618 greedy: true 6619 }, 6620 'class-name': [ 6621 className, 6622 { 6623 // variables, parameters, and constructor references 6624 // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) 6625 pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source), 6626 lookbehind: true, 6627 inside: className.inside 6628 }, 6629 {
vendor: 4,272 bytes, lines 6630-6743
6630 // class names based on keyword 6631 // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods) 6632 pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source), 6633 lookbehind: true, 6634 inside: className.inside 6635 } 6636 ], 6637 'keyword': keywords, 6638 'function': [ 6639 Prism.languages.clike.function, 6640 { 6641 pattern: /(::\s*)[a-z_]\w*/, 6642 lookbehind: true 6643 } 6644 ], 6645 'number': /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i, 6646 'operator': { 6647 pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m, 6648 lookbehind: true 6649 }, 6650 'constant': /\b[A-Z][A-Z_\d]+\b/ 6651 }); 6652 6653 Prism.languages.insertBefore('java', 'string', { 6654 'triple-quoted-string': { 6655 // http://openjdk.java.net/jeps/355#Description 6656 pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/, 6657 greedy: true, 6658 alias: 'string' 6659 }, 6660 'char': { 6661 pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/, 6662 greedy: true 6663 } 6664 }); 6665 6666 Prism.languages.insertBefore('java', 'class-name', { 6667 'annotation': { 6668 pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/, 6669 lookbehind: true, 6670 alias: 'punctuation' 6671 }, 6672 'generics': { 6673 pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/, 6674 inside: { 6675 'class-name': className, 6676 'keyword': keywords, 6677 'punctuation': /[<>(),.:]/, 6678 'operator': /[?&|]/ 6679 } 6680 }, 6681 'import': [ 6682 { 6683 pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source), 6684 lookbehind: true, 6685 inside: { 6686 'namespace': className.inside.namespace, 6687 'punctuation': /\./, 6688 'operator': /\*/, 6689 'class-name': /\w+/ 6690 } 6691 }, 6692 { 6693 pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source), 6694 lookbehind: true, 6695 alias: 'static', 6696 inside: { 6697 'namespace': className.inside.namespace, 6698 'static': /\b\w+$/, 6699 'punctuation': /\./, 6700 'operator': /\*/, 6701 'class-name': /\w+/ 6702 } 6703 } 6704 ], 6705 'namespace': { 6706 pattern: RegExp( 6707 /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/ 6708 .source.replace(/<keyword>/g, function () { return keywords.source; })), 6709 lookbehind: true, 6710 inside: { 6711 'punctuation': /\./, 6712 } 6713 } 6714 }); 6715 }(Prism$1)); 6716 return prismJava; 6717} 6718 6719requirePrismJava(); 6720 6721var prismCpp = {}; 6722 6723var hasRequiredPrismCpp; 6724 6725function requirePrismCpp () { 6726 if (hasRequiredPrismCpp) return prismCpp; 6727 hasRequiredPrismCpp = 1; 6728 (function (Prism) { 6729 6730 var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/; 6731 var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function () { return keyword.source; }); 6732 6733 Prism.languages.cpp = Prism.languages.extend('c', { 6734 'class-name': [ 6735 { 6736 pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source 6737 .replace(/<keyword>/g, function () { return keyword.source; })), 6738 lookbehind: true 6739 }, 6740 // This is intended to capture the class name of method implementations like: 6741 // void foo::bar() const {} 6742 // However! The `foo` in the above example could also be a namespace, so we only capture the class name if 6743 // it starts with an uppercase letter. This approximation should give decent results.
6744 /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/, 6745 // This will capture the class name before destructors like: 6746 // Foo::~Foo() {} 6747 /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i, 6748 // This also intends to capture the class name of method implementations but here the class has template 6749 // parameters, so it can't be a namespace (until C++ adds generic namespaces). 6750 /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/ 6751 ], 6752 'keyword': keyword, 6753 'number': { 6754 pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i, 6755 greedy: true 6756 }, 6757 'operator': />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/, 6758 'boolean': /\b(?:false|true)\b/ 6759 }); 6760 6761 Prism.languages.insertBefore('cpp', 'string', { 6762 'module': { 6763 // https://en.cppreference.com/w/cpp/language/modules 6764 pattern: RegExp( 6765 /(\b(?:import|module)\s+)/.source + 6766 '(?:' + 6767 // header-name 6768 /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + 6769 '|' + 6770 // module name or partition or both 6771 /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function () { return modName; }) + 6772 ')' 6773 ), 6774 lookbehind: true, 6775 greedy: true, 6776 inside: { 6777 'string': /^[<"][\s\S]+/, 6778 'operator': /:/, 6779 'punctuation': /\./ 6780 } 6781 }, 6782 'raw-string': { 6783 pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/, 6784 alias: 'string', 6785 greedy: true 6786 } 6787 }); 6788 6789 Prism.languages.insertBefore('cpp', 'keyword', { 6790 'generic-function': { 6791 pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i, 6792 inside: { 6793 'function': /^\w+/, 6794 'generic': { 6795 pattern: /<[\s\S]+/, 6796 alias: 'class-name', 6797 inside: Prism.languages.cpp 6798 } 6799 } 6800 } 6801 }); 6802 6803 Prism.languages.insertBefore('cpp', 'operator', { 6804 'double-colon': { 6805 pattern: /::/, 6806 alias: 'punctuation' 6807 } 6808 }); 6809 6810 Prism.languages.insertBefore('cpp', 'class-name', { 6811 // the base clause is an optional list of parent classes 6812 // https://en.cppreference.com/w/cpp/language/class 6813 'base-clause': { 6814 pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/, 6815 lookbehind: true, 6816 greedy: true, 6817 inside: Prism.languages.extend('cpp', {}) 6818 } 6819 }); 6820 6821 Prism.languages.insertBefore('inside', 'double-colon', { 6822 // All untokenized words that are not namespaces should be class names 6823 'class-name': /\b[a-z_]\w*\b(?!\s*::)/i 6824 }, Prism.languages.cpp['base-clause']); 6825 6826 }(Prism$1)); 6827 return prismCpp; 6828} 6829 6830requirePrismCpp(); 6831 6832/** 6833 * Copyright (c) Meta Platforms, Inc. and affiliates. 6834 * 6835 * This source code is licensed under the MIT license found in the 6836 * LICENSE file in the root directory of this source tree. 6837 * 6838 */ 6839 6840function I$1(t,...e){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",t);for(const t of e)r.append("v",t);throw n.search=r.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const M$1="javascript";function R(e,n){for(const r of e.childNodes){if(Cs(r)&&r.tagName===n)return true;R(r,n);}return false}const K$1="data-language",$$1="data-highlight-language",W$2="data-theme";let q$1 = class q extends Ci{__language;__theme;__isSyntaxHighlightSupported;static getType(){return "code"}static clone(t){return new q(t.__language,t.__key)}constructor(t,e){super(e),this.__language=t||void 0,this.__isSyntaxHighlightSupported=false,this.__theme=void 0;}afterCloneFrom(t){super.afterCloneFrom(t),this.__language=t.__language,this.__theme=t.__theme,this.__isSyntaxHighlightSupported=t.__isSyntaxHighlightSupported;}createDOM(t){const n=document.createElement("code");lt$4(n,t.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(K$1,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute($$1,r));const i=this.getTheme();i&&n.setAttribute(W$2,i);const o=this.getStyle();return o&&n.setAttribute("style",o),n}updateDOM(t,e,n){const r=this.__language,i=t.__language;r?r!==i&&e.setAttribute(K$1,r):i&&e.removeAttribute(K$1);const o=this.__isSyntaxHighlightSupported;t.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&e.setAttribute($$1,r):e.removeAttribute($$1):o&&r&&e.setAttribute($$1,r);const s=this.__theme,l=t.__theme;s?s!==l&&e.setAttribute(W$2,s):l&&e.removeAttribute(W$2);const u=this.__style,c=t.__style;return u?u!==c&&e.setAttribute("style",u):c&&e.removeAttribute("style"),false}exportDOM(t){const n=document.createElement("pre");
6840lt$4(n,t._config.theme.code),n.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(n.setAttribute(K$1,r),this.getIsSyntaxHighlightSupported()&&n.setAttribute($$1,r));const i=this.getTheme();i&&n.setAttribute(W$2,i);const o=this.getStyle();return o&&n.setAttribute("style",o),{element:n}}static importDOM(){return {code:t=>null!=t.textContent&&(/\r?\n/.test(t.textContent)||R(t,"BR"))?{conversion:Q$1,priority:1}:null,div:()=>({conversion:G$1,priority:1}),pre:()=>({conversion:Q$1,priority:0}),table:t=>tt$1(t)?{conversion:V$2,priority:3}:null,td:t=>{const e=t,n=e.closest("table");return e.classList.contains("js-file-line")||n&&tt$1(n)?{conversion:Y,priority:3}:null},tr:t=>{const e=t.closest("table");return e&&tt$1(e)?{conversion:Y,priority:3}:null}}}static importJSON(t){return U$2().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setLanguage(t.language).setTheme(t.theme)}exportJSON(){return {...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(t,e=true){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&t.isCollapsed()&&t.anchor.key===this.__key&&t.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const t=Li();return this.insertAfter(t,e),t}const{anchor:i,focus:o}=t,a=(i.isBefore(o)?i:o).getNode();if(lr(a)){let t=st$1(a);const e=[];for(;;)if(fr(t))e.push(ur()),t=t.getNextSibling();else {if(!it$2(t))break;{let n=0;const r=t.getTextContent(),i=t.getTextContentSize();for(;n<i&&" "===r[n];)n++;if(0!==n&&e.push(rt(" ".repeat(n))),n!==i)break;t=t.getNextSibling();}}const n=a.splitText(i.offset)[0],r=0===i.offset?0:1,o=n.getIndexWithinParent()+r,s=a.getParentOrThrow(),l=[Jn(),...e];s.splice(o,0,l);const f=e[e.length-1];f?f.select():0===i.offset?n.selectPrevious():n.getNextSibling().selectNext(0,0);}if(X$1(a)){const{offset:e}=t.anchor;a.splice(e,0,[Jn()]),a.select(e+1,e+1);}return null}canIndent(){return false}collapseAtStart(){const t=Li();
6840return this.getChildren().forEach(e=>t.append(e)),this.replace(t),true}setLanguage(t){const e=this.getWritable();return e.__language=t||void 0,e}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(t){const e=this.getWritable();return e.__isSyntaxHighlightSupported=t,e}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(t){const e=this.getWritable();return e.__theme=t||void 0,e}getTheme(){return this.getLatest().__theme}};function U$2(t,e){return Ks(q$1).setLanguage(t).setTheme(e)}function X$1(t){return t instanceof q$1}function Q$1(t){return {node:U$2(t.getAttribute(K$1))}}function G$1(t){const e=t,n=Z(e);return n||function(t){let e=t.parentElement;for(;null!==e;){if(Z(e))return true;e=e.parentElement;}return false}(e)?{node:n?U$2():null}:{node:null}}function V$2(){return {node:U$2()}}function Y(){return {node:null}}function Z(t){return null!==t.style.fontFamily.match("monospace")}function tt$1(t){return t.classList.contains("js-file-line-container")}let et$1 = class et extends Xn{__highlightType;constructor(t="",e,n){super(t,n),this.__highlightType=e;}static getType(){return "code-highlight"}static clone(t){return new et(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(t){const e=this.getWritable();return e.__highlightType=t||void 0,e}canHaveFormat(){return false}createDOM(t){const n=super.createDOM(t),r=nt$1(t.theme,this.__highlightType);return lt$4(n,r),n}updateDOM(t,r,i){const o=super.updateDOM(t,r,i),s=nt$1(i.theme,t.__highlightType),l=nt$1(i.theme,this.__highlightType);return s!==l&&(s&&ut$3(r,s),l&<$4(r,l)),o}static importJSON(t){return rt().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setHighlightType(t.highlightType)}exportJSON(){return {...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(t){return this}isParentRequired(){return true}createParentElementNode(){return U$2()}};function nt$1(t,e){return e&&t&&t.codeHighlight&&t.codeHighlight[e]}function rt(t="",e){return fs(new et$1(t,e))}function it$2(t){return t instanceof et$1}function ot$2(t,e){let n=t;for(let i=tl(t,e);i&&(it$2(i.origin)||fr(i.origin));i=ft$2(i))n=i.origin;return n}function st$1(t){return ot$2(t,"previous")}function lt$2(t){return ot$2(t,"next")}function ut$1(t){const e=st$1(t),n=lt$2(t);let r=e;for(;null!==r;){if(it$2(r)){const t=oo(r.getTextContent());if(null!==t)return t}if(r===n)break;r=r.getNextSibling();}const i=e.getParent();if(Si(i)){const t=i.getDirection();if("ltr"===t||"rtl"===t)return t}return null}function ct$2(t,e){let n=null,r=null,i=t,o=e,s=t.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(it$2(i)||fr(i)||jn(i)||I$1(167),jn(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent();}else o--;const t=s[o];it$2(i)&&" "!==t&&(r={node:i,offset:o});}if(null!==r)return r;let l=null;if(e<t.getTextContentSize())it$2(t)&&(l=t.getTextContent()[e]);else {const e=t.getNextSibling();it$2(e)&&(l=e.getTextContent()[0]);}if(null!==l&&" "!==l)return n;{const r=function(t,e){let n=t,r=e,i=t.getTextContent(),o=t.getTextContentSize();for(;;){if(!it$2(n)||r===o){if(n=n.getNextSibling(),null===n||jn(n))return null;it$2(n)&&(r=0,i=n.getTextContent(),o=n.getTextContentSize());}if(it$2(n)){if(" "!==i[r])return {node:n,offset:r};r++;}}}(t,e);return null!==r?r:n}}function gt$1(t){const e=lt$2(t);return jn(e)&&I$1(168),e}!function(t){t.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach(function(n){var r=e[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),t.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:true},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}};}),Object.defineProperty(t.languages.diff,"PREFIXES",{value:e});}(Prism);const ft$1=globalThis.Prism||window.Prism,pt$1={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},ht$1={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function dt$1(t){return ht$1[t]||t}function St$2(t){return "string"==typeof t?t:Array.isArray(t)?t.map(St$2).join(""):St$2(t.content)}function vt$1(t,e){const n=/^diff-([\w-]+)/i.exec(e),r=t.getTextContent();let i=ft$1.tokenize(r,ft$1.languages[n?"diff":e]);return n&&(i=function(t,e){const n=e,r=ft$1.languages[n],i={tokens:t},o=ft$1.languages.diff.PREFIXES;for(const t of i.tokens){if("string"==typeof t||!(t.type in o)||!Array.isArray(t.content))continue;const e=t.type;let n=0;const i=()=>(n++,new ft$1.Token("prefix",o[e],e.replace(/^(\w+).*/,"$1"))),s=t.content.filter(t=>"string"==typeof t||"prefix"!==t.type),l=t.content.length-s.length,u=ft$1.tokenize(St$2(s),r);u.unshift(i());const c=/\r\n|\n/g,g=t=>{const e=[];c.lastIndex=0;let r,o=0;for(;n<l&&(r=c.exec(t));){const n=r.index+r[0].length;e.push(t.slice(o,n)),o=n,e.push(i());}if(0!==e.length)return o<t.length&&e.push(t.slice(o)),e},a=t=>{for(let e=0;e<t.length&&n<l;e++){const n=t[e];if("string"==typeof n){const r=g(n);r&&(t.splice(e,1,...r),e+=r.length-1);}else if("string"==typeof n.content){const t=g(n.content);t&&(n.content=t);}else Array.isArray(n.content)?a(n.content):a([n.content]);}};a(u),n<l&&u.push(i()),t.content=u;}return i.tokens}(i,n[1])),Tt$2(i)}function Tt$2(t,e){const n=[];for(const r of t)if("string"==typeof r){const t=r.split(/(\n|\t)/),i=t.length;for(let r=0;r<i;r++){const i=t[r];"\n"===i||"\r\n"===i?n.push(Jn()):"\t"===i?n.push(ur()):i.length>0&&n.push(rt(i,e));}}else {const{content:t,alias:e}=r;"string"==typeof t?n.push(...Tt$2([t],"prefix"===r.type&&"string"==typeof e?e:r.type)):Array.isArray(t)&&n.push(...Tt$2(t,"unchanged"===r.type?void 0:r.type));}return n}const bt$2={$tokenize(t,e){return vt$1(t,e||this.defaultLanguage)},defaultLanguage:M$1,tokenize(t,e){return ft$1.tokenize(t,ft$1.languages[e||""]||ft$1.languages[this.defaultLanguage])}};function Ct$2(t,e,n){const r=t.getParent();X$1(r)?wt$2(r,e,n):it$2(t)&&t.replace(sr(t.__text));}function Nt$2(t,e){const n=e.getElementByKey(t.getKey());if(null===n)return;const r=t.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let t=0;t<i;t++)jn(r[t])&&(o+="\n"+ ++s);n.setAttribute("data-gutter",o);}const jt$2=new Set;function wt$2(t,e,n){const r=t.getKey();void 0===t.getLanguage()&&t.setLanguage(n.defaultLanguage);const i=t.getLanguage()||n.defaultLanguage;if(!function(t){const e=function(t){const e=/^diff-([\w-]+)/i.exec(t);return e?e[1]:null}(t),n=e||t;try{return !!n&&ft$1.languages.hasOwnProperty(n)}catch(t){return false}}(i))return t.getIsSyntaxHighlightSupported()&&t.setIsSyntaxHighlightSupported(false),void async function(){}();t.getIsSyntaxHighlightSupported()||t.setIsSyntaxHighlightSupported(true),jt$2.has(r)||(jt$2.add(r),e.update(()=>{!function(t,e){const n=xo(t);if(!X$1(n)||!n.isAttached())return;const r=Lr();if(!yr(r))return void e();const i=r.anchor,o=i.offset,s="element"===i.type&&jn(n.getChildAtIndex(i.offset-1));let u=0;if(!s){const t=i.getNode();u=o+t.getPreviousSiblings().reduce((t,e)=>t+e.getTextContentSize(),0);}if(!e())return;if(s)return void i.getNode().select(o,o);n.getChildren().some(t=>{const e=lr(t);if(e||jn(t)){const n=t.getTextContentSize();if(e&&n>=u)return t.select(u,u),true;u-=n;}return false});}(r,()=>{const e=xo(r);if(!X$1(e)||!e.isAttached())return false;
6840const i=e.getLanguage()||n.defaultLanguage,o=n.$tokenize(e,i),s=function(t,e){let n=0;for(;n<t.length&&kt$2(t[n],e[n]);)n++;const r=t.length,i=e.length,o=Math.min(r,i)-n;let s=0;for(;s<o;)if(s++,!kt$2(t[r-s],e[i-s])){s--;break}const l=n,u=r-s,c=e.slice(n,i-s);return {from:l,nodesForReplacement:c,to:u}}(e.getChildren(),o),{from:l,to:u,nodesForReplacement:c}=s;return !(l===u&&!c.length)&&(t.splice(l,u-l,c),true)});},{onUpdate:()=>{jt$2.delete(r);},skipTransforms:true}));}function kt$2(t,e){return it$2(t)&&it$2(e)&&t.__text===e.__text&&t.__highlightType===e.__highlightType||fr(t)&&fr(e)||jn(t)&&jn(e)}function At$2(t){if(!yr(t))return false;const e=t.anchor.getNode(),n=X$1(e)?e:e.getParent(),r=t.focus.getNode(),i=X$1(r)?r:r.getParent();return X$1(n)&&n.is(i)}function Pt$2(t){const e=t.getNodes(),n=[];if(1===e.length&&X$1(e[0]))return n;let r=[];for(let t=0;t<e.length;t++){const i=e[t];it$2(i)||fr(i)||jn(i)||I$1(169),jn(i)?r.length>0&&(n.push(r),r=[]):r.push(i);}if(r.length>0){const e=t.isBackward()?t.anchor:t.focus,i=hr(r[0].getKey(),0,"text");e.is(i)||n.push(r);}return n}function Lt$2(t){const e=Lr();if(!yr(e)||!At$2(e))return false;const n=Pt$2(e),r=n.length;if(0===r&&e.isCollapsed())return t===Pe$2&&e.insertNodes([ur()]),true;if(0===r&&t===Pe$2&&"\n"===e.getTextContent()){const t=ur(),n=Jn(),r=e.isBackward()?"previous":"next";return e.insertNodes([t,n]),Sl(Al(dl(el(t,"next",0),El(tl(n,"next"))),r)),true}for(let i=0;i<r;i++){const r=n[i];if(r.length>0){let n=r[0];if(0===i&&(n=st$1(n)),t===Pe$2){const t=ur();if(n.insertBefore(t),0===i){const r=e.isBackward()?"focus":"anchor",i=hr(n.getKey(),0,"text");e[r].is(i)&&e[r].set(t.getKey(),0,"text");}}else fr(n)&&n.remove();}}return true}function Ot$1(t,e){const n=Lr();if(!yr(n))return false;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),c=i.getNode(),g=t===ke$2;if(!At$2(n)||!it$2(l)&&!fr(l)||!it$2(c)&&!fr(c))return false;if(!e.altKey){if(n.isCollapsed()){const t=l.getParentOrThrow();if(g&&0===o&&null===l.getPreviousSibling()){if(null===t.getPreviousSibling())return t.selectPrevious(),e.preventDefault(),true}else if(!g&&o===l.getTextContentSize()&&null===l.getNextSibling()){if(null===t.getNextSibling())return t.selectNext(),e.preventDefault(),true}}return false}let a,f;if(l.isBefore(c)?(a=st$1(l),f=lt$2(c)):(a=st$1(c),f=lt$2(l)),null==a||null==f)return false;const p=a.getNodesBetween(f);for(let t=0;t<p.length;t++){const e=p[t];if(!it$2(e)&&!fr(e)&&!jn(e))return false}e.preventDefault(),e.stopPropagation();const h=g?a.getPreviousSibling():f.getNextSibling();if(!jn(h))return true;const d=g?h.getPreviousSibling():h.getNextSibling();if(null==d)return true;const m=it$2(d)||fr(d)||jn(d)?g?st$1(d):lt$2(d):null;let x=null!=m?m:d;return h.remove(),p.forEach(t=>t.remove()),t===ke$2?(p.forEach(t=>x.insertBefore(t)),x.insertBefore(h)):(x.insertAfter(h),x=h,p.forEach(t=>{x.insertAfter(t),x=t;})),n.setTextNodeRange(l,o,c,s),true}function Ht$1(t,e){const n=Lr();if(!yr(n))return false;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=t===ve$2;if(!At$2(n)||!it$2(o)&&!fr(o)||!it$2(s)&&!fr(s))return false;const c=s;if("rtl"===ut$1(c)?!l:l){const t=ct$2(c,i.offset);if(null!==t){const{node:e,offset:r}=t;jn(e)?e.selectNext(0,0):n.setTextNodeRange(e,r,e,r);}else c.getParentOrThrow().selectStart();}else {gt$1(c).select();}return e.preventDefault(),e.stopPropagation(),true}function Et$2(t,e){if(!t.hasNodes([q$1,et$1]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==e&&(e=bt$2);const n=[];return true!==t._headless&&n.push(t.registerMutationListener(q$1,e=>{t.getEditorState().read(()=>{for(const[n,r]of e)if("destroyed"!==r){const e=xo(n);null!==e&&Nt$2(e,t);}});},{skipInitialization:false})),n.push(t.registerNodeTransform(q$1,n=>wt$2(n,t,e)),t.registerNodeTransform(Xn,n=>Ct$2(n,t,e)),t.registerNodeTransform(et$1,n=>Ct$2(n,t,e)),t.registerCommand(Me$2,e=>{const n=function(t){const e=Lr();if(!yr(e)||!At$2(e))return null;const n=t?De$2:Pe$2,r=t?De$2:Ae$2,i=e.anchor,o=e.focus;if(i.is(o))return r;const s=Pt$2(e);if(1!==s.length)return n;const l=s[0];let u,c;0===l.length&&I$1(285),e.isBackward()?(u=o,c=i):(u=i,c=o);const g=st$1(l[0]),a=lt$2(l[0]),f=hr(g.getKey(),0,"text"),p=hr(a.getKey(),a.getTextContentSize(),"text");return u.isBefore(f)||p.isBefore(c)?n:f.isBefore(u)||c.isBefore(p)?r:n}(e.shiftKey);
6840return null!==n&&(e.preventDefault(),t.dispatchCommand(n,void 0),true)},zi),t.registerCommand(Ae$2,()=>!!At$2(Lr())&&(jr([ur()]),true),zi),t.registerCommand(Pe$2,t=>Lt$2(Pe$2),zi),t.registerCommand(De$2,t=>Lt$2(De$2),zi),t.registerCommand(ke$2,t=>{const e=Lr();if(!yr(e))return false;const{anchor:n}=e,r=n.getNode();return !!At$2(e)&&(e.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&X$1(r.getParentOrThrow())?(t.preventDefault(),true):Ot$1(ke$2,t))},zi),t.registerCommand(Te$2,t=>{const e=Lr();if(!yr(e))return false;const{anchor:n}=e,r=n.getNode();return !!At$2(e)&&(e.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&X$1(r.getParentOrThrow())?(t.preventDefault(),true):Ot$1(Te$2,t))},zi),t.registerCommand(ve$2,t=>Ht$1(ve$2,t),zi),t.registerCommand(Ce$1,t=>Ht$1(Ce$1,t),zi)),U$4(...n)} 6841 6842/** 6843 * Copyright (c) Meta Platforms, Inc. and affiliates. 6844 * 6845 * This source code is licensed under the MIT license found in the 6846 * LICENSE file in the root directory of this source tree. 6847 * 6848 */ 6849 6850function z$1(t,e){const n={};for(const o of t){const t=e(o);t&&(n[t]?n[t].push(o):n[t]=[o]);}return n}function U$1(t){const e=z$1(t,t=>t.type);return {element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const W$1=/[!-/:-@[-`{-~\s]/;function V$1(t){return lr(t)&&!t.hasFormat("code")}function et(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const nt=/^(\s*)(\d{1,})\.\s/,ot$1=/^(\s*)[-*+]\s/,it$1=/^(#{1,6})\s/,st=/^>\s/,lt$1=/^[ \t]*```([\w-]+)?/,ct$1=/[ \t]*```$/,mt$1=ot$5("mdListMarker",{parse:t=>"string"==typeof t&&/^[-*+]$/.test(t)?t:"-"}),ht=t=>(e,n,o,r)=>{const i=t(o);i.append(...n),e.replace(i),r||i.select(0,0);};const xt$1=t=>(e,n,o,r)=>{const i=e.getPreviousSibling(),s=e.getNextSibling(),l=st$2("check"===t?"x"===o[3]:void 0),c=o[0].trim()[0],f="bullet"!==t&&"check"!==t||c!==mt$1.parse(c)?void 0:c;if(dt$2(s)&&s.getListType()===t){f&&ct$5(s,mt$1,f);const t=s.getFirstChild();null!==t?t.insertBefore(l):s.append(l),e.remove();}else if(dt$2(i)&&i.getListType()===t)f&&ct$5(i,mt$1,f),i.append(l),e.remove();else {const n=ht$3(t,"number"===t?Number(o[2]):void 0);f&&ct$5(n,mt$1,f),n.append(l),e.replace(n);}l.append(...n),r||l.select(0,0);const a=function(t){const e=t.match(/\t/g),n=t.match(/ /g);let o=0;return e&&(o+=e.length),n&&(o+=Math.floor(n.length/4)),o}(o[1]);a&&l.setIndent(a);},Tt$1=(t,e,n)=>{const o=[],r=t.getChildren();let i=0;for(const s of r)if(ot$3(s)){if(1===s.getChildrenSize()){const t=s.getFirstChild();if(dt$2(t)){o.push(Tt$1(t,e,n+1));continue}}const r=" ".repeat(4*n),l=t.getListType(),c=st$4(t,mt$1),f="number"===l?`${t.getStart()+i}. `:"check"===l?`${c} [${s.getChecked()?"x":" "}] `:c+" ";o.push(r+f+e(s)),i++;}return o.join("\n")},Et$1={dependencies:[Pt$3],export:(t,e)=>{if(!It$2(t))return null;const n=Number(t.getTag().slice(1));return "#".repeat(n)+" "+e(t)},regExp:it$1,replace:ht(t=>{const e="h"+t[1].length;return St$3(e)}),type:"element"},Ct$1={dependencies:[Et$3],export:(t,e)=>{if(!Ot$2(t))return null;const n=e(t).split("\n"),o=[];for(const t of n)o.push("> "+t);return o.join("\n")},regExp:st,replace:(t,e,n,o)=>{if(o){const n=t.getPreviousSibling();if(Ot$2(n))return n.splice(n.getChildrenSize(),0,[Jn(),...e]),void t.remove()}const r=_t$2();r.append(...e),t.replace(r),o||r.select(0,0);},type:"element"},yt$1={dependencies:[q$1],export:t=>
6850{if(!X$1(t))return null;const e=t.getTextContent();return "```"+(t.getLanguage()||"")+(e?"\n"+e:"")+"\n```"},regExpEnd:{optional:true,regExp:ct$1},regExpStart:lt$1,replace:(t,e,n,o,r,i)=>{let s,c;if(!e&&r){if(1===r.length)o?(s=U$2(),c=n[1]+r[0]):(s=U$2(n[1]),c=r[0].startsWith(" ")?r[0].slice(1):r[0]);else {if(s=U$2(n[1]),0===r[0].trim().length)for(;r.length>0&&!r[0].length;)r.shift();else r[0]=r[0].startsWith(" ")?r[0].slice(1):r[0];for(;r.length>0&&!r[r.length-1].length;)r.pop();c=r.join("\n");}const e=sr(c);s.append(e),t.append(s);}else e&&ht(t=>U$2(t?t[1]:void 0))(t,e,n,i);},type:"multiline-element"},$t$1={dependencies:[lt$3,nt$2],export:(t,e)=>dt$2(t)?Tt$1(t,e,0):null,regExp:ot$1,replace:xt$1("bullet"),type:"element"},St$1={dependencies:[lt$3,nt$2],export:(t,e)=>dt$2(t)?Tt$1(t,e,0):null,regExp:nt,replace:xt$1("number"),type:"element"},bt$1={format:["code"],tag:"`",type:"text-format"},Ft$1={format:["highlight"],tag:"==",type:"text-format"},It$1={format:["bold","italic"],tag:"***",type:"text-format"},wt$1={format:["bold","italic"],intraword:false,tag:"___",type:"text-format"},Nt$1={format:["bold"],tag:"**",type:"text-format"},kt$1={format:["bold"],intraword:false,tag:"__",type:"text-format"},Rt$1={format:["strikethrough"],tag:"~~",type:"text-format"},Lt$1={format:["italic"],tag:"*",type:"text-format"},_t$1={format:["italic"],intraword:false,tag:"_",type:"text-format"},Pt$1={dependencies:[y$2],export:(t,e,n)=>{if(!w$3(t)||E$3(t))return null;const o=t.getTitle(),r=e(t);return o?`[${r}](${t.getURL()} "${o}")`:`[${r}](${t.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(t,e)=>{const[,n,o,r]=e,i=D$2(o,{title:r}),s=n.split("[").length-1,c=n.split("]").length-1;let f=n,a="";if(s<c)return;if(s>c){const t=n.split("[");a="["+t[0],f=t.slice(1).join("[");}const u=sr(f);return u.setFormat(t.getFormat()),i.append(u),t.replace(i),a&&i.insertBefore(sr(a)),u},trigger:")",type:"text-match"},Bt$1=[Et$1,Ct$1,$t$1,St$1],Mt$1=[yt$1],jt$1=[bt$1,It$1,wt$1,Nt$1,kt$1,Ft$1,Lt$1,_t$1,Rt$1],At$1=[Pt$1],zt$1=[...Bt$1,...Mt$1,...jt$1,...At$1];function Ut$1(t,e,n){const o=n.length;for(let r=e;r>=o;r--){const e=r-o;if(Wt$1(t,e,n,0,o)&&" "!==t[e+o])return e}return -1}function Wt$1(t,e,n,o,r){for(let i=0;i<r;i++)if(t[e+i]!==n[o+i])return false;return true}function Dt$1(t,n=zt$1){const o=U$1(n),r=z$1(o.textFormat,({tag:t})=>t[t.length-1]),l=z$1(o.textMatch,({trigger:t})=>t);for(const e of n){const n=e.type;if("element"===n||"text-match"===n||"multiline-element"===n){const n=e.dependencies;for(const e of n)t.hasNode(e)||et(173,e.getType());}}const c=(t,n,c)=>{(function(t,e,n,o){const r=t.getParent();if(!as(r)||t.getFirstChild()!==e)return false;const i=e.getTextContent();if(" "!==i[n-1])return false;for(const{regExp:r,replace:s}of o){const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(false!==s(t,l?[l,...r]:r,o,false))return i.remove(),true}}return false})(t,n,c,o.element)||function(t,e,n,o){const r=t.getParent();if(!as(r)||t.getFirstChild()!==e)return false;const i=e.getTextContent();if(" "!==i[n-1])return false;for(const{regExpStart:r,replace:s,regExpEnd:l}of o){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const o=i.match(r);if(o&&o[0].length===(o[0].endsWith(" ")?n:n-1)){const r=e.getNextSiblings(),[i,l]=e.splitText(n);if(false!==s(t,l?[l,...r]:r,o,null,null,false))return i.remove(),true}}return false}(t,n,c,o.multilineElement)||function(t,e,n){let o=t.getTextContent();const r=n[o[e-1]];if(null==r)return false;e<o.length&&(o=o.slice(0,e));for(const e of r){if(!e.replace||!e.regExp)continue;const n=o.match(e.regExp);if(null===n)continue;const r=n.index||0,i=r+n[0].length;let s;return 0===r?[s]=t.splitText(i):[,s]=t.splitText(r,i),s.selectNext(0,0),e.replace(s,n),true}return false}(n,c,l)||function(t,n,o){const r=t.getTextContent(),l=n-1,c=r[l],f=o[c];if(!f)return false;for(const n of f){const{tag:o}=n,f=o.length,a=l-f+1;if(f>1&&!Wt$1(r,a,o,0,f))continue;if(" "===r[a-1])continue;const u=r[l+1];if(false===n.intraword&&u&&!W$1.test(u))continue;const g=t;let p=g,d=Ut$1(r,a,o),h=p;for(;d<0&&(h=h.getPreviousSibling())&&!jn(h);)if(lr(h)){if(h.hasFormat("code"))continue;const t=h.getTextContent();p=h,d=Ut$1(t,t.length,o);}if(d<0)continue;if(p===g&&d+f===a)continue;const E=p.getTextContent();if(d>0&&E[d-1]===c)continue;const C=E[d-1];if(false===n.intraword&&C&&!W$1.test(C))continue;const y=g.getTextContent(),$=y.slice(0,a)+y.slice(l+1);g.setTextContent($);const v=p===g?$:E;p.setTextContent(v.slice(0,d)+v.slice(d+f));const S=Lr(),b=Ar();wo(b);const F=l-f*(p===g?2:1)+1;b.anchor.set(p.__key,d,"text"),b.focus.set(g.__key,F,"text");for(const t of n.format)b.hasFormat(t)||b.formatText(t);
6850b.anchor.set(b.focus.key,b.focus.offset,b.focus.type);for(const t of n.format)b.hasFormat(t)&&b.toggleFormat(t);return yr(S)&&(b.format=S.format),true}}(n,c,r);};return t.registerUpdateListener(({tags:n,dirtyLeaves:o,editorState:r,prevEditorState:i})=>{if(n.has(Ln)||n.has(An))return;if(t.isComposing())return;const l=r.read(Lr),f=i.read(Lr);if(!yr(f)||!yr(l)||!l.isCollapsed()||l.is(f))return;const a=l.anchor.key,u=l.anchor.offset,g=r._nodeMap.get(a);!lr(g)||!o.has(a)||1!==u&&u>f.anchor.offset+1||t.update(()=>{if(!V$1(g))return;const t=g.getParent();null===t||X$1(t)||c(t,g,l.anchor.offset);});})} 6851 6852/** 6853 * Copyright (c) Meta Platforms, Inc. and affiliates. 6854 * 6855 * This source code is licensed under the MIT license found in the 6856 * LICENSE file in the root directory of this source tree. 6857 * 6858 */ 6859 6860function x$1(t,e,n,r,o){if(null===t||0===n.size&&0===r.size&&!o)return 0;const i=e._selection,a=t._selection;if(o)return 1;if(!(yr(i)&&yr(a)&&a.isCollapsed()&&i.isCollapsed()))return 0;const s=function(t,e,n){const r=t._nodeMap,o=[];for(const t of e){const e=r.get(t);void 0!==e&&o.push(e);}for(const[t,e]of n){if(!e)continue;const n=r.get(t);void 0===n||bi(n)||o.push(n);}return o}(e,n,r);if(0===s.length)return 0;if(s.length>1){const n=e._nodeMap,r=n.get(i.anchor.key),o=n.get(a.anchor.key);return r&&o&&!t._nodeMap.has(r.__key)&&lr(r)&&1===r.__text.length&&1===i.anchor.offset?2:0}const c=s[0],d=t._nodeMap.get(c.__key);if(!lr(d)||!lr(c)||d.__mode!==c.__mode)return 0;const u=d.__text,l=c.__text;if(u===l)return 0;const f=i.anchor,p=a.anchor;if(f.key!==p.key||"text"!==f.type)return 0;const h=f.offset,m=p.offset,y=l.length-u.length;return 1===y&&m===h-1?2:-1===y&&m===h+1?3:-1===y&&m===h?4:0}function C$1(t,e){let n=Date.now(),r=0;return (o,i,a,s,c,d)=>{const u=Date.now();if(d.has(An))return r=0,n=u,2;const l=x$1(o,i,s,c,t.isComposing()),f=(()=>{const f=null===a||a.editor===t,p=d.has(Pn);if(!p&&f&&d.has(Dn))return 0;if(null===o)return 1;const h=i._selection;if(!(s.size>0||c.size>0))return null!==h?0:2;const m="number"==typeof e?e:e.peek();if(false===p&&0!==l&&l===r&&u<n+m&&f)return 0;if(1===s.size){if(function(t,e,n){const r=e._nodeMap.get(t),o=n._nodeMap.get(t),i=e._selection,a=n._selection;return !(yr(i)&&yr(a)&&"element"===i.anchor.type&&"element"===i.focus.type&&"text"===a.anchor.type&&"text"===a.focus.type||!lr(r)||!lr(o)||r.__parent!==o.__parent)&&JSON.stringify(e.read(()=>r.exportJSON()))===JSON.stringify(n.read(()=>o.exportJSON()))}(Array.from(s)[0],o,i))return 0}return 1})();return n=u,r=l,f}}function v$1(t){t.undoStack=[],t.redoStack=[],t.current=null;}function b$1(t,e,n){const r=C$1(t,n),i=U$4(t.registerCommand(pe$1,()=>(function(t,e){const n=e.redoStack,r=e.undoStack;if(0!==r.length){const o=e.current,i=r.pop();null!==o&&(n.push(o),t.dispatchCommand($e$2,true)),0===r.length&&t.dispatchCommand(Ue$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:An});}}(t,e),true),Ki),t.registerCommand(ye$1,()=>(function(t,e){const n=e.redoStack,r=e.undoStack;if(0!==n.length){const o=e.current;null!==o&&(r.push(o),t.dispatchCommand(Ue$2,true));const i=n.pop();0===n.length&&t.dispatchCommand($e$2,false),e.current=i||null,i&&i.editor.setEditorState(i.editorState,{tag:An});}}(t,e),true),Ki),t.registerCommand(Je$1,()=>(v$1(e),false),Ki),t.registerCommand(je$2,()=>(v$1(e),t.dispatchCommand($e$2,false),t.dispatchCommand(Ue$2,false),true),Ki),t.registerUpdateListener(({editorState:n,prevEditorState:o,dirtyLeaves:i,dirtyElements:a,tags:s})=>{const c=e.current,d=e.redoStack,u=e.undoStack,l=null===c?null:c.editorState;if(null!==c&&n===l)return;const f=r(o,n,c,i,a,s);if(1===f)0!==d.length&&(e.redoStack=[],t.dispatchCommand($e$2,false)),null!==c&&(u.push({...c}),t.dispatchCommand(Ue$2,true));else if(2===f)return;e.current={editor:t,editorState:n};}));return i}function w$1(){return {current:null,redoStack:[],undoStack:[]}}const E$1=Kl({build:(e,{delay:n,createInitialHistoryState:r,disabled:o})=>at$2({delay:n,disabled:o,historyState:r(e)}),config:Bl({createInitialHistoryState:w$1,delay:300,disabled:"undefined"==typeof window}),name:"@lexical/history/History",register:(t,n,r)=>{const o=r.getOutput();return dt$3(()=>o.disabled.value?void 0:b$1(t,o.historyState.value,o.delay))}});Kl({dependencies:[zl(E$1,{createInitialHistoryState:()=>{throw new Error("SharedHistory did not inherit parent history")},disabled:true})],name:"@lexical/history/SharedHistory",register(t,o,i){const{output:a}=i.getDependency(E$1),s=function(t){return t?Gt$1(t,E$1.name):null}(t._parentEditor);if(!s)return ()=>{};const c=s.output;return dt$3(()=>F$2(()=>{a.delay.value=c.delay.value,a.historyState.value=c.historyState.value,a.disabled.value=c.disabled.value;}))}}); 6861 6862var theme = { 6863 text: { 6864 bold: "lexxy-content__bold", 6865 italic: "lexxy-content__italic", 6866 strikethrough: "lexxy-content__strikethrough", 6867 underline: "lexxy-content__underline", 6868 highlight: "lexxy-content__highlight" 6869 }, 6870 tableCellHeader: "lexxy-content__table-cell--header", 6871 tableCellSelected: "lexxy-content__table-cell--selected", 6872 tableSelection: "lexxy-content__table--selection", 6873 tableScrollableWrapper: "lexxy-content__table-wrapper", 6874 tableCellHighlight: "lexxy-content__table-cell--highlight", 6875 tableCellFocus: "lexxy-content__table-cell--focus", 6876 list: { 6877 nested: { 6878 listitem: "lexxy-nested-listitem", 6879 } 6880 }, 6881 codeHighlight: { 6882 addition: "code-token__selector", 6883 atrule: "code-token__attr", 6884 attr: "code-token__attr", 6885 "attr-name": "code-token__attr", 6886 "attr-value": "code-token__selector", 6887 boolean: "code-token__property", 6888 bold: "code-token__variable", 6889 builtin: "code-token__selector", 6890 cdata: "code-token__comment", 6891 char: "code-token__selector", 6892 class: "code-token__function", 6893 "class-name": "code-token__function", 6894 color: "code-token__property", 6895 comment: "code-token__comment", 6896 constant: "code-token__property", 6897 coord: "code-token__comment", 6898 decorator: "code-token__function", 6899 deleted: "code-token__operator",
6900 deletion: "code-token__operator", 6901 directive: "code-token__attr", 6902 "directive-hash": "code-token__property", 6903 doctype: "code-token__comment", 6904 entity: "code-token__operator", 6905 function: "code-token__function", 6906 hexcode: "code-token__property", 6907 important: "code-token__function", 6908 inserted: "code-token__selector", 6909 italic: "code-token__comment", 6910 keyword: "code-token__attr", 6911 line: "code-token__selector", 6912 namespace: "code-token__variable", 6913 number: "code-token__property", 6914 macro: "code-token__function", 6915 operator: "code-token__operator", 6916 parameter: "code-token__variable", 6917 prolog: "code-token__comment", 6918 property: "code-token__property", 6919 punctuation: "code-token__punctuation", 6920 "raw-string": "code-token__operator", 6921 regex: "code-token__variable", 6922 script: "code-token__function", 6923 selector: "code-token__selector", 6924 string: "code-token__selector", 6925 style: "code-token__function", 6926 symbol: "code-token__property", 6927 tag: "code-token__property", 6928 title: "code-token__function", 6929 "type-definition": "code-token__function", 6930 url: "code-token__operator", 6931 variable: "code-token__variable", 6932 } 6933}; 6934 6935function createElement(name, properties, content = "") { 6936 const element = document.createElement(name); 6937 for (const [ key, value ] of Object.entries(properties || {})) { 6938 if (key in element) { 6939 element[key] = value; 6940 } else if (value !== null && value !== undefined) { 6941 element.setAttribute(key, value); 6942 } 6943 } 6944 if (content) { 6945 element.innerHTML = content; 6946 } 6947 return element 6948} 6949 6950function parseHtml(html) { 6951 const parser = new DOMParser(); 6952 return parser.parseFromString(html, "text/html") 6953} 6954 6955function createAttachmentFigure(contentType, isPreviewable, fileName) { 6956 const extension = fileName ? fileName.split(".").pop().toLowerCase() : "unknown"; 6957 return createElement("figure", { 6958 className: `attachment attachment--${isPreviewable ? "preview" : "file"} attachment--${extension}`, 6959 "data-content-type": contentType 6960 }) 6961} 6962 6963function isPreviewableImage(contentType) { 6964 return contentType.startsWith("image/") && !contentType.includes("svg") 6965} 6966 6967function dispatch(element, eventName, detail = null, cancelable = false) { 6968 return element.dispatchEvent(new CustomEvent(eventName, { bubbles: true, detail, cancelable })) 6969} 6970 6971function generateDomId(prefix) { 6972 const randomPart = Math.random().toString(36).slice(2, 10); 6973 return `${prefix}-${randomPart}` 6974} 6975 6976function bytesToHumanSize(bytes) { 6977 if (bytes === 0) return "0 B" 6978 const sizes = [ "B", "KB", "MB", "GB", "TB", "PB" ]; 6979 const i = Math.floor(Math.log(bytes) / Math.log(1024)); 6980 const value = bytes / Math.pow(1024, i); 6981 return `${ value.toFixed(2) } ${ sizes[i] }` 6982} 6983 6984class ActionTextAttachmentNode extends ki { 6985 static getType() { 6986 return "action_text_attachment" 6987 } 6988 6989 static clone(node) { 6990 return new ActionTextAttachmentNode({ ...node }, node.__key) 6991 } 6992 6993 static importJSON(serializedNode) { 6994 return new ActionTextAttachmentNode({ ...serializedNode }) 6995 } 6996 6997 static importDOM() { 6998 return { 6999 [this.TAG_NAME]: () => { 7000 return { 7001 conversion: (attachment) => ({ 7002 node: new ActionTextAttachmentNode({ 7003 sgid: attachment.getAttribute("sgid"), 7004 src: attachment.getAttribute("url"), 7005 previewable: attachment.getAttribute("previewable"), 7006 altText: attachment.getAttribute("alt"), 7007 caption: attachment.getAttribute("caption"), 7008 contentType: attachment.getAttribute("content-type"), 7009 fileName: attachment.getAttribute("filename"), 7010 fileSize: attachment.getAttribute("filesize"), 7011 width: attachment.getAttribute("width"), 7012 height: attachment.getAttribute("height") 7013 }) 7014 }), priority: 1 7015 } 7016 }, 7017 "img": () => { 7018 return { 7019 conversion: (img) => ({ 7020 node: new ActionTextAttachmentNode({ 7021 src: img.getAttribute("src"), 7022 caption: img.getAttribute("alt") || "", 7023 contentType: "image/*", 7024 width: img.getAttribute("width"), 7025 height: img.getAttribute("height") 7026 }) 7027 }), priority: 1 7028 } 7029 }, 7030 "video": () => { 7031 return { 7032 conversion: (video) => { 7033 const videoSource = video.getAttribute("src") || video.querySelector("source")?.src; 7034 const fileName = videoSource?.split("/")?.pop(); 7035 const contentType = video.querySelector("source")?.getAttribute("content-type") || "video/*"; 7036 7037 return { 7038 node: new ActionTextAttachmentNode({ 7039 src: videoSource, 7040 fileName: fileName, 7041 contentType: contentType 7042 }) 7043 } 7044 }, priority: 1 7045 } 7046 } 7047 } 7048 } 7049 7050 static get TAG_NAME() { 7051 return Lexxy.global.get("attachmentTagName") 7052 } 7053 7054 constructor({ tagName, sgid, src, previewable, altText, caption, contentType, fileName, fileSize, width, height }, key) { 7055 super(key); 7056 7057 this.tagName = tagName || ActionTextAttachmentNode.TAG_NAME; 7058 this.sgid = sgid; 7059 this.src = src; 7060 this.previewable = previewable; 7061 this.altText = altText || ""; 7062 this.caption = caption || ""; 7063 this.contentType = contentType || ""; 7064 this.fileName = fileName || ""; 7065 this.fileSize = fileSize; 7066 this.width = width; 7067 this.height = height; 7068 7069 this.editor = bs(); 7070 } 7071 7072 createDOM() { 7073 const figure = this.createAttachmentFigure(); 7074 7075 if (this.isPreviewableAttachment) { 7076 figure.appendChild(this.#createDOMForImage()); 7077 figure.appendChild(this.#createEditableCaption()); 7078 } else { 7079 figure.appendChild(this.#createDOMForFile()); 7080 figure.appendChild(this.#createDOMForNotImage()); 7081 } 7082 7083 return figure 7084 } 7085 7086 updateDOM(_prevNode, dom) { 7087 const caption = dom.querySelector("figcaption textarea"); 7088 if (caption && this.caption) { 7089 caption.value = this.caption; 7090 } 7091 7092 return false 7093 } 7094 7095 getTextContent() { 7096 return `[${this.caption || this.fileName}]\n\n` 7097 } 7098 7099 isInline() { 7100 return false 7101 } 7102 7103 exportDOM() { 7104 const attachment = createElement(this.tagName, { 7105 sgid: this.sgid, 7106 previewable: this.previewable || null, 7107 url: this.src, 7108 alt: this.altText, 7109 caption: this.caption, 7110 "content-type": this.contentType, 7111 filename: this.fileName, 7112 filesize: this.fileSize, 7113 width: this.width, 7114 height: this.height, 7115 presentation: "gallery" 7116 }); 7117 7118 return { element: attachment } 7119 } 7120 7121 exportJSON() { 7122 return { 7123 type: "action_text_attachment", 7124 version: 1, 7125 tagName: this.tagName, 7126 sgid: this.sgid, 7127 src: this.src, 7128 previewable: this.previewable, 7129 altText: this.altText, 7130 caption: this.caption, 7131 contentType: this.contentType, 7132 fileName: this.fileName, 7133 fileSize: this.fileSize, 7134 width: this.width, 7135 height: this.height 7136 } 7137 } 7138 7139 decorate() { 7140 return null 7141 } 7142 7143 createAttachmentFigure() { 7144 return createAttachmentFigure(this.contentType, this.isPreviewableAttachment, this.fileName) 7145 } 7146 7147 get #isPreviewableImage() { 7148 return isPreviewableImage(this.contentType) 7149 } 7150 7151 get isPreviewableAttachment() { 7152 return this.#isPreviewableImage || this.previewable 7153 } 7154 7155 #createDOMForImage() { 7156 return createElement("img", { src: this.src, alt: this.altText, ...this.#imageDimensions }) 7157 } 7158 7159 get #imageDimensions() { 7160 if (this.width && this.height) { 7161 return { width: this.width, height: this.height } 7162 } else { 7163 return {} 7164 } 7165 } 7166 7167 #createDOMForFile() { 7168 const extension = this.fileName ? this.fileName.split(".").pop().toLowerCase() : "unknown"; 7169 return createElement("span", { className: "attachment__icon", textContent: `${extension}` }) 7170 } 7171 7172 #createDOMForNotImage() { 7173 const figcaption = createElement("figcaption", { className: "attachment__caption" }); 7174 7175 const nameTag = createElement("strong", { className: "attachment__name", textContent: this.caption || this.fileName }); 7176 7177 figcaption.appendChild(nameTag); 7178 7179 if (this.fileSize) { 7180 const sizeSpan = createElement("span", { className: "attachment__size", textContent: bytesToHumanSize(this.fileSize) }); 7181 figcaption.appendChild(sizeSpan); 7182 } 7183 7184 return figcaption 7185 } 7186 7187 #createEditableCaption() { 7188 const caption = createElement("figcaption", { className: "attachment__caption" }); 7189 const input = createElement("textarea", { 7190 value: this.caption, 7191 placeholder: this.fileName, 7192 rows: "1" 7193 }); 7194 7195 input.addEventListener("focusin", () => input.placeholder = "Add caption..."); 7196 input.addEventListener("blur", (event) => this.#handleCaptionInputBlurred(event)); 7197 input.addEventListener("keydown", (event) => this.#handleCaptionInputKeydown(event)); 7198 7199 caption.appendChild(input); 7200 7201 return caption 7202 } 7203 7204 #handleCaptionInputBlurred(event) { 7205 this.#updateCaptionValueFromInput(event.target); 7206 } 7207 7208 #updateCaptionValueFromInput(input) { 7209 input.placeholder = this.fileName; 7210 this.editor.update(() => { 7211 this.getWritable().caption = input.value; 7212 }); 7213 } 7214 7215 #handleCaptionInputKeydown(event) { 7216 if (event.key === "Enter") { 7217 event.preventDefault(); 7218 event.stopPropagation(); 7219 event.target.blur(); 7220 7221 this.editor.update(() => { 7222 // Place the cursor after the current image 7223 this.selectNext(0, 0); 7224 }, { 7225 tag: Dn 7226 }); 7227 } 7228 7229 } 7230} 7231 7232const SILENT_UPDATE_TAGS = [ Dn, zn, Kn ]; 7233 7234function $createNodeSelectionWith(...nodes) { 7235 const selection = Pr();
7236 nodes.forEach(node => selection.add(node.getKey())); 7237 return selection 7238} 7239 7240function getListType(node) { 7241 const list = wt$5(node, lt$3); 7242 return list?.getListType() ?? null 7243} 7244 7245function extendTextNodeConversion(conversionName, ...callbacks) { 7246 return extendConversion(Xn, conversionName, (conversionOutput, element) => ({ 7247 ...conversionOutput, 7248 forChild: (lexicalNode, parentNode) => { 7249 const originalForChild = conversionOutput?.forChild ?? (x => x); 7250 let childNode = originalForChild(lexicalNode, parentNode); 7251 7252 7253 if (lr(childNode)) { 7254 childNode = callbacks.reduce( 7255 (childNode, callback) => callback(childNode, element) ?? childNode, 7256 childNode 7257 ); 7258 return childNode 7259 } 7260 } 7261 })) 7262} 7263 7264function extendConversion(nodeKlass, conversionName, callback = (output => output)) { 7265 return (element) => { 7266 const converter = nodeKlass.importDOM()?.[conversionName]?.(element); 7267 if (!converter) return null 7268 7269 const conversionOutput = converter.conversion(element); 7270 if (!conversionOutput) return conversionOutput 7271 7272 return callback(conversionOutput, element) ?? conversionOutput 7273 } 7274} 7275 7276async function loadFileIntoImage(file, image) { 7277 return new Promise((resolve) => { 7278 const reader = new FileReader(); 7279 7280 image.addEventListener("load", () => { 7281 resolve(image); 7282 }); 7283 7284 reader.onload = (event) => { 7285 image.src = event.target.result || null; 7286 }; 7287 7288 reader.readAsDataURL(file); 7289 }) 7290} 7291 7292class ActionTextAttachmentUploadNode extends ActionTextAttachmentNode { 7293 static getType() { 7294 return "action_text_attachment_upload" 7295 } 7296 7297 static clone(node) { 7298 return new ActionTextAttachmentUploadNode({ ...node }, node.__key) 7299 } 7300 7301 static importJSON(serializedNode) { 7302 return new ActionTextAttachmentUploadNode({ ...serializedNode }) 7303 } 7304 7305 // Should never run since this is a transient node. Defined to remove console warning. 7306 static importDOM() { 7307 return null 7308 } 7309 7310 constructor(node, key) { 7311 const { file, uploadUrl, blobUrlTemplate, progress, width, height, uploadError } = node; 7312 super({ ...node, contentType: file.type }, key); 7313 this.file = file; 7314 this.uploadUrl = uploadUrl; 7315 this.blobUrlTemplate = blobUrlTemplate; 7316 this.progress = progress ?? null; 7317 this.width = width; 7318 this.height = height; 7319 this.uploadError = uploadError; 7320 } 7321 7322 createDOM() { 7323 if (this.uploadError) return this.#createDOMForError() 7324 7325 // This side-effect is trigged on DOM load to fire only once and avoid multiple 7326 // uploads through cloning. The upload is guarded from restarting in case the 7327 // node is reloaded from saved state such as from history. 7328 this.#startUploadIfNeeded(); 7329 7330 const figure = this.createAttachmentFigure(); 7331 7332 if (this.isPreviewableAttachment) { 7333 const img = figure.appendChild(this.#createDOMForImage()); 7334 7335 // load file locally to set dimensions and prevent vertical shifting 7336 loadFileIntoImage(this.file, img).then(img => this.#setDimensionsFromImage(img)); 7337 } else { 7338 figure.appendChild(this.#createDOMForFile()); 7339 } 7340 7341 figure.appendChild(this.#createCaption()); 7342 figure.appendChild(this.#createProgressBar()); 7343 7344 return figure 7345 } 7346 7347 updateDOM(prevNode, dom) { 7348 if (this.uploadError !== prevNode.uploadError) return true 7349 7350 if (prevNode.progress !== this.progress) { 7351 const progress = dom.querySelector("progress"); 7352 progress.value = this.progress ?? 0; 7353 } 7354 7355 return false 7356 } 7357 7358 exportDOM() { 7359 return { element: null } 7360 } 7361 7362 exportJSON() { 7363 return { 7364 ...super.exportJSON(), 7365 type: "action_text_attachment_upload", 7366 version: 1, 7367 uploadUrl: this.uploadUrl, 7368 blobUrlTemplate: this.blobUrlTemplate, 7369 progress: this.progress, 7370 width: this.width, 7371 height: this.height, 7372 uploadError: this.uploadError 7373 } 7374 } 7375 7376 get #uploadStarted() { 7377 return this.progress !== null 7378 } 7379 7380 #createDOMForError() { 7381 const figure = this.createAttachmentFigure(); 7382 figure.classList.add("attachment--error"); 7383 figure.appendChild(createElement("div", { innerText: `Error uploading ${this.file?.name ?? "file"}` })); 7384 return figure 7385 } 7386 7387 #createDOMForImage() { 7388 return createElement("img") 7389 } 7390 7391 #createDOMForFile() { 7392 const extension = this.#getFileExtension(); 7393 const span = createElement("span", { className: "attachment__icon", textContent: extension }); 7394 return span 7395 } 7396 7397 #getFileExtension() { 7398 return this.file.name.split(".").pop().toLowerCase() 7399 } 7400 7401 #createCaption() { 7402 const figcaption = createElement("figcaption", { className: "attachment__caption" }); 7403 7404 const nameSpan = createElement("span", { className: "attachment__name", textContent: this.file.name || "" }); 7405 const sizeSpan = createElement("span", { className: "attachment__size", textContent: bytesToHumanSize(this.file.size) }); 7406 figcaption.appendChild(nameSpan); 7407 figcaption.appendChild(sizeSpan); 7408 7409 return figcaption 7410 } 7411 7412 #createProgressBar() { 7413 return createElement("progress", { value: this.progress ?? 0, max: 100 }) 7414 } 7415 7416 #setDimensionsFromImage({ width, height }) { 7417 if (this.#hasDimensions) return 7418 7419 this.editor.update(() => { 7420 const writable = this.getWritable(); 7421 writable.width = width; 7422 writable.height = height; 7423 }, { tag: SILENT_UPDATE_TAGS }); 7424 } 7425 7426 get #hasDimensions() { 7427 return Boolean(this.width && this.height) 7428 } 7429 7430 async #startUploadIfNeeded() { 7431 if (this.#uploadStarted) return 7432 7433 this.#setUploadStarted(); 7434 7435 const { DirectUpload } = await import('@rails/activestorage'); 7436 7437 const upload = new DirectUpload(this.file, this.uploadUrl, this); 7438 upload.delegate = this.#createUploadDelegate(); 7439 upload.create((error, blob) => { 7440 if (error) { 7441 this.#handleUploadError(error); 7442 } else { 7443 this.#showUploadedAttachment(blob); 7444 } 7445 }); 7446 } 7447 7448 #createUploadDelegate() { 7449 const shouldAuthenticateUploads = Lexxy.global.get("authenticatedUploads"); 7450 7451 return { 7452 directUploadWillCreateBlobWithXHR: (request) => { 7453 if (shouldAuthenticateUploads) request.withCredentials = true; 7454 }, 7455 directUploadWillStoreFileWithXHR: (request) => { 7456 if (shouldAuthenticateUploads) request.withCredentials = true; 7457 7458 const uploadProgressHandler = (event) => this.#handleUploadProgress(event); 7459 request.upload.addEventListener("progress", uploadProgressHandler); 7460 } 7461 } 7462 } 7463 7464 #setUploadStarted() { 7465 this.#setProgress(1); 7466 } 7467 7468 #handleUploadProgress(event) { 7469 this.#setProgress(Math.round(event.loaded / event.total * 100)); 7470 } 7471 7472 #setProgress(progress) { 7473 this.editor.update(() => { 7474 this.getWritable().progress = progress; 7475 }, { tag: SILENT_UPDATE_TAGS }); 7476 } 7477 7478 #handleUploadError(error) { 7479 console.warn(`Upload error for ${this.file?.name ?? "file"}: ${error}`); 7480 this.editor.update(() => { 7481 this.getWritable().uploadError = true; 7482 }, { tag: SILENT_UPDATE_TAGS }); 7483 } 7484 7485 async #showUploadedAttachment(blob) { 7486 this.editor.update(() => { 7487 this.replace(this.#toActionTextAttachmentNodeWith(blob)); 7488 }, { tag: SILENT_UPDATE_TAGS }); 7489 } 7490 7491 #toActionTextAttachmentNodeWith(blob) { 7492 const conversion = new AttachmentNodeConversion(this, blob); 7493 return conversion.toAttachmentNode() 7494 } 7495} 7496 7497class AttachmentNodeConversion { 7498 constructor(uploadNode, blob) { 7499 this.uploadNode = uploadNode; 7500 this.blob = blob; 7501 } 7502 7503 toAttachmentNode() { 7504 return new ActionTextAttachmentNode({ 7505 ...this.uploadNode, 7506 ...this.#propertiesFromBlob, 7507 src: this.#src 7508 }) 7509 } 7510 7511 get #propertiesFromBlob() { 7512 const { blob } = this; 7513 return { 7514 sgid: blob.attachable_sgid, 7515 altText: blob.filename, 7516 contentType: blob.content_type, 7517 fileName: blob.filename, 7518 fileSize: blob.byte_size, 7519 previewable: blob.previewable, 7520 } 7521 } 7522 7523 get #src() { 7524 return this.blob.previewable ? this.blob.url : this.#blobSrc 7525 } 7526 7527 get #blobSrc() { 7528 return this.uploadNode.blobUrlTemplate 7529 .replace(":signed_id", this.blob.signed_id) 7530 .replace(":filename", encodeURIComponent(this.blob.filename)) 7531 } 7532} 7533 7534class HorizontalDividerNode extends ki { 7535 static getType() { 7536 return "horizontal_divider" 7537 } 7538 7539 static clone(node) { 7540 return new HorizontalDividerNode(node.__key) 7541 } 7542 7543 static importJSON(serializedNode) { 7544 return new HorizontalDividerNode() 7545 } 7546 7547 static importDOM() { 7548 return { 7549 "hr": (hr) => { 7550 return { 7551 conversion: () => ({ 7552 node: new HorizontalDividerNode() 7553 }), 7554 priority: 1 7555 } 7556 } 7557 } 7558 } 7559 7560 constructor(key) { 7561 super(key); 7562 } 7563 7564 createDOM() { 7565 const figure = createElement("figure", { className: "horizontal-divider" }); 7566 const hr = createElement("hr"); 7567 7568 figure.appendChild(hr); 7569 7570 return figure 7571 } 7572 7573 updateDOM() { 7574 return true 7575 } 7576 7577 getTextContent() { 7578 return "â\n\n" 7579 } 7580 7581 isInline() { 7582 return false 7583 } 7584 7585 exportDOM() { 7586 const hr = createElement("hr"); 7587 return { element: hr } 7588 } 7589 7590 exportJSON() { 7591 return { 7592 type: "horizontal_divider", 7593 version: 1 7594 } 7595 } 7596 7597 decorate() { 7598 return null 7599 } 7600} 7601 7602/** 7603 * Copyright (c) Meta Platforms, Inc. and affiliates. 7604 * 7605 * This source code is licensed under the MIT license found in the 7606 * LICENSE file in the root directory of this source tree. 7607 * 7608 */ 7609 7610const Ne$1=/^(\d+(?:\.\d+)?)px$/,ve$1={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};class xe extends Ci{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return "tablecell"}static clone(e){return new xe(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign;}static importDOM(){return {td:e=>({conversion:Re$1,priority:0}),th:e=>({conversion:Re$1,priority:0})}}static importJSON(e){return Fe$1().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroun
7610dColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=ve$1.NO_STATUS,t=1,n,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0;}createDOM(t){const n=document.createElement(this.getTag());return this.__width&&(n.style.width=`${this.__width}px`),this.__colSpan>1&&(n.colSpan=this.__colSpan),this.__rowSpan>1&&(n.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(n.style.backgroundColor=this.__backgroundColor),Te$1(this.__verticalAlign)&&(n.style.verticalAlign=this.__verticalAlign),lt$4(n,t.theme.tableCell,this.hasHeader()&&t.theme.tableCellHeader),n}exportDOM(e){const t=super.exportDOM(e);if(Cs(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5");}return t}exportJSON(){return {...super.exportJSON(),...Te$1(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=ve$1.BOTH){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return (t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return (this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==ve$1.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return true}collapseAtStart(){return true}canBeEmpty(){return false}canIndent(){return false}}function Te$1(e){return "middle"===e||"bottom"===e}function Re$1(e){const t=e,n=e.nodeName.toLowerCase();let o;Ne$1.test(t.style.width)&&(o=parseFloat(t.style.width));const r=Fe$1("th"===n?ve$1.ROW:ve$1.NO_STATUS,t.colSpan,o);r.__rowSpan=t.rowSpan;const l=t.style.backgroundColor;""!==l&&(r.__backgroundColor=l);const s=t.style.verticalAlign;Te$1(s)&&(r.__verticalAlign=s);const i=t.style,c=(i&&i.textDecoration||"").split(" "),a="700"===i.fontWeight||"bold"===i.fontWeight,u=c.includes("line-through"),h="italic"===i.fontStyle,p=c.includes("underline");return {after:e=>{const t=[];let n=null;const o=()=>{if(n){const e=n.getFirstChild();jn(e)&&1===n.getChildrenSize()&&e.remove();}};for(const r of e)ls(r)||lr(r)||jn(r)?(lr(r)&&(a&&r.toggleFormat("bold"),u&&r.toggleFormat("strikethrough"),h&&r.toggleFormat("italic"),p&&r.toggleFormat("underline")),n?n.append(r):(n=Li().append(r),t.push(n))):(t.push(r),o(),n=null);return o(),0===t.length&&t.push(Li()),t},node:r}}function Fe$1(e=ve$1.NO_STATUS,t=1,n){return fs(new xe(e,t,n))}function Oe$1(e){return e instanceof xe}const Ae$1=re$1("INSERT_TABLE_COMMAND");function Ke$1(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Ee$1 = class Ee extends Ci{__height;static getType(){return "tablerow"}static clone(e){return new Ee(e.__height,e.__key)}static importDOM(){return {tr:e=>({conversion:ke$1,priority:0})}}static importJSON(e){return Me$1().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e;}exportJSON(){const e=this.getHeight();return {...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(t){const n=document.createElement("tr");return this.__height&&(n.style.height=`${this.__height}px`),lt$4(n,t.theme.tableRow),n}extractWithChild(e,t,n){return "html"===n}isShadowRoot(){return true}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return false}canIndent(){return false}};function ke$1(e){const n=e;let o;return Ne$1.test(n.style.height)&&(o=parseFloat(n.style.height)),{after:e=>kt$6(e,Oe$1),node:Me$1(o)}}function Me$1(e){return fs(new Ee$1(e))}function $e$1(e){return e instanceof Ee$1}const ze$1="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,We$1=ze$1&&"documentMode"in document?document.documentMode:null,He$1=ze$1&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Le$1(e,t,n=true){const o=gn();for(let r=0;r<e;r++){const e=Me$1();for(let o=0;o<t;o++){let t=ve$1.NO_STATUS;"object"==typeof n?(0===r&&n.rows&&(t|=ve$1.ROW),0===o&&n.columns&&(t|=ve$1.COLUMN)):n&&(0===r&&(t|=ve$1.ROW),0===o&&(t|=ve$1.COLUMN));const l=Fe$1(t),s=Li();s.append(sr()),l.append(s),e.append(l);}o.append(e);}return o}function Be$1(e){const t=zs(e,e=>Oe$1(e));return Oe$1(t)?t:null}function Pe$1(e){const t=zs(e,e=>$e$1(e));if($e$1(t))return t;throw new Error("Expected table cell to be inside of table row.")}function De$1(e){const t=zs(e,e=>mn(e));if(mn(t))return t;throw new Error("Expected table cell to be inside of table.")}function Ie$1(e){const t=Pe$1(e);return De$1(t).getChildren().findIndex(e=>e.is(t))}function Ue$1(e){return Pe$1(e).getChildren().findIndex(t=>t.is(e))}ze$1&&"InputEvent"in window&&!We$1&&new window.InputEvent("input");const qe$1=(e,t)=>e===ve$1.BOTH||e===t?t:ve$1.NO_STATUS;function je$1(e=true){const t=Lr();yr(t)||wt(t)||Ke$1(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=mt(n),[l,,s]=mt(o),[,i,c]=ft(s,l,r),{startRow:a}=c,{startRow:u}=i;return e?Ge$1(a+r.__rowSpan>u+l.__rowSpan?r:l,true):Ge$1(u<a?l:r,false)}function Ge$1(e,t=true){const[,,n]=mt(e),[o,r]=ft(n,e,e),l=o[0].length,{startRow:s}=r;let i=null;if(t){const t=s+e.__rowSpan-1,r=o[t],c=Me$1();for(let e=0;e<l;e++){const{cell:n,startRow:o}=r[e];if(o+n.__rowSpan-1<=t){const t=r[e].cell.__headerState,n=qe$1(t,ve$1.COLUMN);c.append(Fe$1(n).append(Li()));}else n.setRowSpan(n.__rowSpan+1);}const a=n.getChildAtIndex(t);$e$1(a)||Ke$1(256),a.insertAfter(c),i=c;}else {const e=s,t=o[e],r=Me$1();for(let n=0;n<l;n++){const{cell:o,startRow:l}=t[n];if(l===e){const e=t[n].cell.__headerState,o=qe$1(e,ve$1.COLUMN);r.append(Fe$1(o).append(Li()));}else o.setRowSpan(o.__rowSpan+1);}const c=n.getChildAtIndex(e);$e$1(c)||Ke$1(257),c.insertBefore(r),i=r;}return i}function Ze$1(e=true){const t=Lr();yr(t)||wt(t)||Ke$1(188);const n=t.anchor.getNode(),o=t.focus.getNode(),[r]=mt(n),[l,,s]=mt(o),[,i,c]=ft(s,l,r),{startColumn:a}=c,{startColumn:u}=i;return e?tt(a+r.__colSpan>u+l.__colSpan?r:l,true):tt(u<a?l:r,false)}function tt(e,t=true,n=true){const[,,o]=mt(e),[r,l]=ft(o,e,e),s=r.length,{startColumn:i}=l,c=t?i+e.__colSpan-1:i-1,a=o.getFirstChild();$e$1(a)||Ke$1(120);let u=null;function h(e=ve$1.NO_STATUS){const t=Fe$1(e).append(Li());return null===u&&(u=t),t}let d=a;e:for(let e=0;e<s;e++){if(0!==e){const e=d.getNextSibling();$e$1(e)||Ke$1(121),d=e;}const t=r[e],n=t[c<0?0:c].cell.__headerState,o=qe$1(n,ve$1.ROW);if(c<0){ct(d,h(o));continue}const{cell:l,startColumn:s,startRow:i}=t[c];if(s+l.__colSpan-1<=c){let n=l,r=i,s=c;for(;r!==e&&n.__rowSpan>1;){if(s-=l.__colSpan,!(s>=0)){d.append(h(o));continue e}{const{cell:e,startRow:o}=t[s];n=e,r=o;}}n.insertAfter(h(o));}else l.setColSpan(l.__colSpan+1);}null!==u&&n&&it(u);const f=o.getColWidths();if(f){const e=[...f],t=c<0?0:c,n=e[t];e.splice(t,0,n),o.setColWidths(e);}return u}function ot(){const e=Lr();yr(e)||wt(e)||Ke$1(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[o,,r]=mt(t),[l]=mt(n),[s,i,c]=ft(r,o,l),{startRow:a}=i,{startRow:u}=c,h=u+l.__rowSpan-1;
7610if(s.length===h-a+1)return void r.remove();const d=s[0].length,f=s[h+1],g=r.getChildAtIndex(h+1);for(let e=h;e>=a;e--){for(let t=d-1;t>=0;t--){const{cell:n,startRow:o,startColumn:r}=s[e][t];if(r===t){if(o<a||o+n.__rowSpan-1>h){const e=Math.max(o,a),t=Math.min(n.__rowSpan+o-1,h),r=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-r);}if(o>=a&&o+n.__rowSpan-1>h&&e===h){null===g&&Ke$1(122);let o=null;for(let n=0;n<t;n++){const t=f[n],r=t.cell;t.startRow===e+1&&(o=r),r.__colSpan>1&&(n+=r.__colSpan-1);}null===o?ct(g,n):o.insertAfter(n);}}}const t=r.getChildAtIndex(e);$e$1(t)||Ke$1(206,String(e)),t.remove();}if(void 0!==f){const{cell:e}=f[0];it(e);}else {const e=s[a-1],{cell:t}=e[0];it(t);}}function lt(){const e=Lr();yr(e)||wt(e)||Ke$1(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[o,,r]=mt(t),[l]=mt(n),[s,i,c]=ft(r,o,l),{startColumn:a}=i,{startRow:u,startColumn:h}=c,d=Math.min(a,h),f=Math.max(a+o.__colSpan-1,h+l.__colSpan-1),g=f-d+1;if(s[0].length===f-d+1)return r.selectPrevious(),void r.remove();const m=s.length;for(let e=0;e<m;e++)for(let t=d;t<=f;t++){const{cell:n,startColumn:o}=s[e][t];if(o<d){if(t===d){const e=d-o;n.setColSpan(n.__colSpan-Math.min(g,n.__colSpan-e));}}else if(o+n.__colSpan-1>f){if(t===f){const e=f-o+1;n.setColSpan(n.__colSpan-e);}}else n.remove();}const p=s[u],C=a>h?p[a+o.__colSpan]:p[h+l.__colSpan];if(void 0!==C){const{cell:e}=C;it(e);}else {const e=h<a?p[h-1]:p[a-1],{cell:t}=e;it(t);}const _=r.getColWidths();if(_){const e=[..._];e.splice(d,g),r.setColWidths(e);}}function it(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart();}function ct(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t);}function at(e){if(0===e.length)return null;const t=De$1(e[0]),[n]=gt(t,null,null);let o=1/0,r=-1/0,l=1/0,s=-1/0;const i=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!i.has(t)&&e.some(e=>e.is(n.cell))){i.add(t);const e=n.startRow,c=n.startColumn,a=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;o=Math.min(o,e),r=Math.max(r,e+a-1),l=Math.min(l,c),s=Math.max(s,c+u-1);}}if(o===1/0||l===1/0)return null;const c=r-o+1,a=s-l+1,u=n[o][l];if(!u.cell)return null;const h=u.cell;h.setColSpan(a),h.setRowSpan(c);const d=new Set([h.getKey()]);for(let e=o;e<=r;e++)for(let t=l;t<=s;t++){const o=n[e][t];if(!o.cell)continue;const r=o.cell,l=r.getKey();if(!d.has(l)){d.add(l);ut(r)||h.append(...r.getChildren()),r.remove();}}return 0===h.getChildrenSize()&&h.append(Li()),h}function ut(e){if(1!==e.getChildrenSize())return false;const t=e.getFirstChildOrThrow();return !(!Ii(t)||!t.isEmpty())}function dt(e){const[t,n,o]=mt(e),r=t.__colSpan,l=t.__rowSpan;if(1===r&&1===l)return;const[s,i]=ft(o,t,t),{startColumn:c,startRow:a}=i,u=t.__headerState&ve$1.COLUMN,h=Array.from({length:r},(e,t)=>{let n=u;for(let e=0;0!==n&&e<s.length;e++)n&=s[e][t+c].cell.__headerState;return n}),d=t.__headerState&ve$1.ROW,f=Array.from({length:l},(e,t)=>{let n=d;for(let e=0;0!==n&&e<s[0].length;e++)n&=s[t+a][e].cell.__headerState;return n});if(r>1){for(let e=1;e<r;e++)t.insertAfter(Fe$1(h[e]|f[0]).append(Li()));t.setColSpan(1);}if(l>1){let e;for(let t=1;t<l;t++){const o=a+t,l=s[o];e=(e||n).getNextSibling(),$e$1(e)||Ke$1(125);let i=null;for(let e=0;e<c;e++){const t=l[e],n=t.cell;t.startRow===o&&(i=n),n.__colSpan>1&&(e+=n.__colSpan-1);}if(null===i)for(let n=r-1;n>=0;n--)ct(e,Fe$1(h[n]|f[t]).append(Li()));else for(let e=r-1;e>=0;e--)i.insertAfter(Fe$1(h[e]|f[t]).append(Li()));}t.setRowSpan(1);}}function ft(e,t,n){const[o,r,l]=gt(e,t,n);return null===r&&Ke$1(207),null===l&&Ke$1(208),[o,r,l]}function gt(e,t,n){const o=[];let r=null,l=null;function s(e){let t=o[e];return void 0===t&&(o[e]=t=[]),t}const i=e.getChildren();for(let e=0;e<i.length;e++){const o=i[e];$e$1(o)||Ke$1(209);const c=s(e);for(let a=o.getFirstChild(),u=0;null!=a;a=a.getNextSibling()){for(Oe$1(a)||Ke$1(147);void 0!==c[u];)u++;const o={cell:a,startColumn:u,startRow:e},{__rowSpan:h,__colSpan:d}=a;for(let t=0;t<h&&!(e+t>=i.length);t++){const n=s(e+t);for(let e=0;e<d;e++)n[u+e]=o;}null!==t&&null===r&&t.is(a)&&(r=o),null!==n&&null===l&&n.is(a)&&(l=o);}}return [o,r,l]}function mt(e){let t;if(e instanceof xe)t=e;else if("__type"in e){const o=zs(e,Oe$1);
vendor: 4,886 bytes, line 7610
7610Oe$1(o)||Ke$1(148),t=o;}else {const o=zs(e.getNode(),Oe$1);Oe$1(o)||Ke$1(148),t=o;}const o=t.getParent();$e$1(o)||Ke$1(149);const r=o.getParent();return mn(r)||Ke$1(210),[t,o,r]}function pt(e,t,n){let o,r=Math.min(t.startColumn,n.startColumn),l=Math.min(t.startRow,n.startRow),s=Math.max(t.startColumn+t.cell.__colSpan-1,n.startColumn+n.cell.__colSpan-1),i=Math.max(t.startRow+t.cell.__rowSpan-1,n.startRow+n.cell.__rowSpan-1);do{o=false;for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const c=e[t][n];if(!c)continue;const a=c.startColumn+c.cell.__colSpan-1,u=c.startRow+c.cell.__rowSpan-1,h=c.startColumn<=s&&a>=r,d=c.startRow<=i&&u>=l;if(h&&d){const e=Math.min(r,c.startColumn),t=Math.max(s,a),n=Math.min(l,c.startRow),h=Math.max(i,u);e===r&&t===s&&n===l&&h===i||(r=e,s=t,l=n,i=h,o=true);}}}while(o);return {maxColumn:s,maxRow:i,minColumn:r,minRow:l}}function Ct(e){const[t,,n]=mt(e),o=n.getChildren(),r=o.length,l=o[0].getChildren().length,s=new Array(r);for(let e=0;e<r;e++)s[e]=new Array(l);for(let e=0;e<r;e++){const n=o[e].getChildren();let r=0;for(let o=0;o<n.length;o++){for(;s[e][r];)r++;const l=n[o],i=l.__rowSpan||1,c=l.__colSpan||1;for(let t=0;t<i;t++)for(let n=0;n<c;n++)s[e+t][r+n]=l;if(t===l)return {colSpan:c,columnIndex:r,rowIndex:e,rowSpan:i};r+=c;}}return null}function _t(e){const[[t,o,r,l],[s,i,c,a]]=["anchor","focus"].map(t=>{const o=e[t].getNode(),r=zs(o,Oe$1);Oe$1(r)||Ke$1(238,t,o.getKey(),o.getType());const l=r.getParent();$e$1(l)||Ke$1(239,t);const s=l.getParent();return mn(s)||Ke$1(240,t),[o,r,l,s]});return l.is(a)||Ke$1(241),{anchorCell:o,anchorNode:t,anchorRow:r,anchorTable:l,focusCell:i,focusNode:s,focusRow:c,focusTable:a}}class St{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=false,this.tableKey=e;}getStartEndPoints(){return [this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return false;const e=xo(this.tableKey),t=xo(this.anchor.key),n=xo(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e;}is(e){return wt(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null;}clone(){return new St(this.tableKey,hr(this.anchor.key,this.anchor.offset,this.anchor.type),hr(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return false}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(Oe$1).forEach(e=>{const n=e.getFirstChild();Ii(n)&&(t|=n.getTextFormat());});const n=R$6[e];return 0!==(t&n)}insertNodes(e){const t=this.focus.getNode();Si(t)||Ke$1(151);St$6(t.select(0,t.getChildrenSize())).insertNodes(e);}getShape(){const{anchorCell:e,focusCell:t}=_t(this),n=Ct(e);null===n&&Ke$1(153);const o=Ct(t);null===o&&Ke$1(155);const r=Math.min(n.columnIndex,o.columnIndex),l=Math.max(n.columnIndex+n.colSpan-1,o.columnIndex+o.colSpan-1),s=Math.min(n.rowIndex,o.rowIndex),i=Math.max(n.rowIndex+n.rowSpan-1,o.rowIndex+o.rowSpan-1);return {fromX:Math.min(r,l),fromY:Math.min(s,i),toX:Math.max(r,l),toY:Math.max(s,i)}}getNodes(){if(!this.isValid())return [];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:o}=_t(this),r=o.getParents()[1];if(r!==t){if(t.isParentOf(o)){const e=r.getParent();null==e&&Ke$1(159),this.set(this.tableKey,o.getKey(),e.getKey());}else {const e=t.getParent();null==e&&Ke$1(158),this.set(this.tableKey,e.getKey(),o.getKey());}return this.getNodes()}const[l,s,i]=ft(t,n,o),{minColumn:c,maxColumn:a,minRow:u,maxRow:h}=pt(l,s,i),d=new Map([[t.getKey(),t]]);let f=null;for(let e=u;e<=h;e++)for(let t=c;t<=a;t++){const{cell:n}=l[e][t],o=n.getParent();$e$1(o)||Ke$1(160),o!==f&&(d.set(o.getKey(),o),f=o),d.has(n.getKey())||Nt(n,e=>{d.set(e.getKey(),e);});}const g=Array.from(d.values());return ti()||(this._cachedNodes=g),g}getTextContent(){const e=this.getNodes().filter(e=>Oe$1(e));let t="";for(let n=0;n<e.length;n++){const o=e[n],r=o.__parent,l=(e[n+1]||{}).__parent;t+=o.getTextContent()+(l!==r?"\n":"\t");}return t}}function wt(e){return e instanceof St}function bt(){const e=hr("root",0,"element"),t=hr("root",0,"element");return new St("root",e,t)}function yt(e,t,n){e.getKey(),t.getKey(),n.getKey();const o=Lr(),r=wt(o)?o.clone():bt();return r.set(e.getKey(),t.getKey(),n.getKey()),r}function Nt(e,t){const n=[[e]];for(let e=n.at(-1);void 0!==e&&n.length>0;e=n.at(-1)){const o=e.pop();void 0===o?n.pop():false!==t(o)&&Si(o)&&n.push(o.getChildren());}}
7610function vt(e,t=bs()){const n=xo(e);mn(n)||Ke$1(231,e);const o=Ft(n,t.getElementByKey(e));return null===o&&Ke$1(232,e),{tableElement:o,tableNode:n}}class xt{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=false,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=false,this.isSelecting=false,this.pointerType=null,this.shouldCheckSelection=false,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable();}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear();}$lookup(){return vt(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(e=>{this.editor.getEditorState().read(()=>{let t=false;for(let n=0;n<e.length;n++){const o=e[n].target.nodeName;if("TABLE"===o||"TBODY"===o||"THEAD"===o||"TR"===o){t=true;break}}if(!t)return;const{tableNode:n,tableElement:o}=this.$lookup();this.table=Ht(n,o);},{editor:this.editor});});this.editor.getEditorState().read(()=>{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Ht(t,n),e.observe(n,{attributes:true,childList:true,subtree:true});},{editor:this.editor});}$clearHighlight(){const e=this.editor;this.isHighlightingCells=false,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=false,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();Lt(e,Ht(t,n),null),null!==Lr()&&(wo(null),e.dispatchCommand(ie$1,void 0));}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();ut$3(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=false;}$disableHighlightStyle(){const{tableElement:t}=this.$lookup();lt$4(t,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=true;}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Ke$1(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=true,this.$disableHighlightStyle(),this.updateDOMSelection(),Lt(t,this.table,this.tableSelection);}else this.$clearHighlight();}setShouldCheckSelection(){this.shouldCheckSelection=true;}getAndClearShouldCheckSelection(){return !!this.shouldCheckSelection&&(this.shouldCheckSelection=false,true)}setNextFocus(e){this.nextFocus=e;}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=ps(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges();}}$setFocusCellForSelection(e,t=false){const n=this.editor,{tableNode:o}=this.$lookup(),r=e.x,l=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===r&&this.anchorY===l&&!t){if(r===this.focusX&&l===this.focusY)return false}else this.isHighlightingCells=true,this.$disableHighlightStyle();if(this.focusX=r,this.focusY=l,this.isHighlightingCells){const t=ln(o,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=yt(o,this.$getAnchorTableCellOrThrow(),t),wo(this.tableSelection),n.dispatchCommand(ie$1,void 0),Lt(n,this.table,this.tableSelection),true}return false}$getAnchorTableCell(){return this.anchorCellNodeKey?xo(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Ke$1(234),e}$getFocusTableCell(){return this.focusCellNodeKey?xo(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Ke$1(235),e}
7610$setAnchorCellForSelection(e){this.isHighlightingCells=false,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=ln(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():bt(),this.anchorCellNodeKey=e;}}$formatCells(e){const t=Lr();wt(t)||Ke$1(236);const n=Ar(),o=n.anchor,r=n.focus,l=t.getNodes().filter(Oe$1);l.length>0||Ke$1(237);const s=l[0].getFirstChild(),i=Ii(s)?s.getFormatFlags(e,null):null;l.forEach(t=>{o.set(t.getKey(),0,"element"),r.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,i);}),wo(t),this.editor.dispatchCommand(ie$1,void 0);}$clearText(){const{editor:e}=this,t=xo(this.tableNodeKey);if(!mn(t))throw new Error("Expected TableNode.");const n=Lr();wt(n)||Ke$1(253);const o=n.getNodes().filter(Oe$1),r=t.getFirstChild(),l=t.getLastChild();if(o.length>0&&null!==r&&null!==l&&$e$1(r)&&$e$1(l)&&o[0]===r.getFirstChild()&&o[o.length-1]===l.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(bi(n)&&n.isEmpty()&&e.dispatchCommand(ae$1,void 0))}o.forEach(e=>{if(Si(e)){const t=Li(),n=sr();
7610t.append(n),e.append(t),e.getChildren().forEach(e=>{e!==t&&e.remove();});}}),Lt(e,this.table,null),wo(null),e.dispatchCommand(ie$1,void 0);}}const Tt="__lexicalTableSelection";function Rt(e){return Cs(e)&&"TABLE"===e.nodeName}function Ft(e,t){if(!t)return t;const n=Rt(t)?t:e.getDOMSlot(t).element;return "TABLE"!==n.nodeName&&Ke$1(245,t.nodeName),n}function Ot(e){return e._window}function At(e,t){for(let n=t,o=null;null!==n;n=n.getParent()){if(e.is(n))return o;Oe$1(n)&&(o=n);}return null}const Kt=[[Te$2,"down"],[ke$2,"up"],[Se$1,"backward"],[xe$1,"forward"]],Et=[he$1,ge$1,le$2],kt=[we$1,Oe$2];function Mt(e,t,o,l){const s=o.getRootElement(),i=Ot(o);null!==s&&null!==i||Ke$1(246);const c=new xt(o,e.getKey()),a=Ft(e,t);!function(e,t){null!==$t(e)&&Ke$1(205);e[Tt]=t;}(a,c),c.listenersToRemove.add(()=>function(e,t){$t(e)===t&&delete e[Tt];}(a,c));const u=t=>{if(c.pointerType=t.pointerType,0!==t.button||!Ss(t.target)||!i)return;const n=zt(t.target);null!==n&&o.update(()=>{const o=Ir();if(He$1&&t.shiftKey&&Xt(o,e)&&(yr(o)||wt(o))){const r=o.anchor.getNode(),l=At(e,o.anchor.getNode());if(l)c.$setAnchorCellForSelection(rn(c,l)),c.$setFocusCellForSelection(n),tn(t);else {(e.isBefore(r)?e.selectStart():e.selectEnd()).anchor.set(o.anchor.key,o.anchor.offset,o.anchor.type);}}else "touch"!==t.pointerType&&c.$setAnchorCellForSelection(n);}),(()=>{if(c.isSelecting)return;const e=()=>{c.isSelecting=false,i.removeEventListener("pointerup",e),i.removeEventListener("pointermove",t);},t=n=>{if(1&~n.buttons&&c.isSelecting)return c.isSelecting=false,i.removeEventListener("pointerup",e),void i.removeEventListener("pointermove",t);if(!Ss(n.target))return;let r=null;const l=!(He$1||a.contains(n.target));if(l)r=Wt(a,n.target);else for(const e of document.elementsFromPoint(n.clientX,n.clientY))if(r=Wt(a,e),r)break;!r||null!==c.focusCell&&r.elem===c.focusCell.elem||(c.setNextFocus({focusCell:r,override:l}),o.dispatchCommand(ie$1,void 0));};c.isSelecting=true,i.addEventListener("pointerup",e,c.listenerOptions),i.addEventListener("pointermove",t,c.listenerOptions);})();};a.addEventListener("pointerdown",u,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("pointerdown",u);});const h=e=>{if(e.detail>=3&&Ss(e.target)){null!==zt(e.target)&&e.preventDefault();}};a.addEventListener("mousedown",h,c.listenerOptions),c.listenersToRemove.add(()=>{a.removeEventListener("mousedown",h);});const d=e=>{const t=e.target;0===e.button&&Ss(t)&&o.update(()=>{const e=Lr();wt(e)&&e.tableKey===c.tableNodeKey&&s.contains(t)&&c.$clearHighlight();});};i.addEventListener("pointerdown",d,c.listenerOptions),c.listenersToRemove.add(()=>{i.removeEventListener("pointerdown",d);});for(const[t,n]of Kt)c.listenersToRemove.add(o.registerCommand(t,t=>en(o,t,n,e,c),Bi));c.listenersToRemove.add(o.registerCommand(Ee$2,t=>{const n=Lr();if(wt(n)){const o=At(e,n.focus.getNode());if(null!==o)return tn(t),o.selectEnd(),true}return false},Bi));const g=t=>()=>{const o=Lr();if(!Xt(o,e))return false;if(wt(o))return c.$clearText(),true;if(yr(o)){if(!Oe$1(At(e,o.anchor.getNode())))return false;const r=o.anchor.getNode(),l=o.focus.getNode(),s=e.isParentOf(r),i=e.isParentOf(l);if(s&&!i||i&&!s)return c.$clearText(),true;const a=zs(o.anchor.getNode(),e=>Si(e)),u=a&&zs(a,e=>Si(e)&&Oe$1(e.getParent()));if(!Si(u)||!Si(a))return false;if(t===ge$1&&null===u.getPreviousSibling())return true}return false};for(const e of Et)c.listenersToRemove.add(o.registerCommand(e,g(e),Bi));const p=t=>{const n=Lr();if(!wt(n)&&!yr(n))return false;const o=e.isParentOf(n.anchor.getNode());if(o!==e.isParentOf(n.focus.getNode())){const t=o?"anchor":"focus",r=o?"focus":"anchor",{key:l,offset:s,type:i}=n[r];return e[n[t].isBefore(n[r])?"selectPrevious":"selectNext"]()[r].set(l,s,i),false}return !!Xt(n,e)&&(!!wt(n)&&(t&&(t.preventDefault(),t.stopPropagation()),c.$clearText(),true))};for(const e of kt)c.listenersToRemove.add(o.registerCommand(e,p,Bi));return c.listenersToRemove.add(o.registerCommand(Be$2,e=>{const t=Lr();if(t){if(!wt(t)&&!yr(t))return false;F$1(o,Lt$4(e,ClipboardEvent)?e:null,_$1(t));const n=p(e);return yr(t)?(t.removeText(),true):n}return false},Bi)),c.listenersToRemove.add(o.registerCommand(_e$1,t=>{const o=Lr();if(!Xt(o,e))return false;if(wt(o))return c.$formatCells(t),true;if(yr(o)){const e=zs(o.anchor.getNode(),e=>Oe$1(e));if(!Oe$1(e))return false}return false},Bi)),c.listenersToRemove.add(o.registerCommand(Le$2,t=>{const n=Lr();if(!wt(n)||!Xt(n,e))return false;
7610const o=n.anchor.getNode(),r=n.focus.getNode();if(!Oe$1(o)||!Oe$1(r))return false;if(function(e,t){if(wt(e)){const n=e.anchor.getNode(),o=e.focus.getNode();if(t&&n&&o){const[e]=ft(t,n,o);return n.getKey()===e[0][0].cell.getKey()&&o.getKey()===e[e.length-1].at(-1).cell.getKey()}}return false}(n,e))return e.setFormat(t),true;const[l,s,i]=ft(e,o,r),c=Math.max(s.startRow+s.cell.__rowSpan-1,i.startRow+i.cell.__rowSpan-1),a=Math.max(s.startColumn+s.cell.__colSpan-1,i.startColumn+i.cell.__colSpan-1),u=Math.min(s.startRow,i.startRow),h=Math.min(s.startColumn,i.startColumn),d=new Set;for(let e=u;e<=c;e++)for(let n=h;n<=a;n++){const o=l[e][n].cell;if(d.has(o))continue;d.add(o),o.setFormat(t);const r=o.getChildren();for(let e=0;e<r.length;e++){const n=r[e];Si(n)&&!n.isInline()&&n.setFormat(t);}}return true},Bi)),c.listenersToRemove.add(o.registerCommand(ue$1,t=>{const r=Lr();if(!Xt(r,e))return false;if(wt(r))return c.$clearHighlight(),false;if(yr(r)){const l=zs(r.anchor.getNode(),e=>Oe$1(e));if(!Oe$1(l))return false;if("string"==typeof t){const n=on(o,r,e);if(n)return nn(n,e,[sr(t)]),true}}return false},Bi)),l&&c.listenersToRemove.add(o.registerCommand(Me$2,t=>{const o=Lr();if(!yr(o)||!o.isCollapsed()||!Xt(o,e))return false;const r=Gt(o.anchor.getNode());return !(null===r||!e.is(Qt(r)))&&(tn(t),function(e,t){const o="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",l=e[o]();if(Si(l))return l.selectEnd();const s=zs(e,$e$1);null===s&&Ke$1(247);for(let e=s[o]();$e$1(e);e=e[o]()){const t=e[r]();if(Si(t))return t.selectEnd()}const i=zs(s,mn);null===i&&Ke$1(248);"next"===t?i.selectNext():i.selectPrevious();}(r,t.shiftKey?"previous":"next"),true)},Bi)),c.listenersToRemove.add(o.registerCommand(Ve$1,t=>e.isSelected(),Bi)),c.listenersToRemove.add(o.registerCommand(oe$2,(e,t)=>{if(o!==t)return false;const{nodes:r,selection:l}=e,s=l.getStartEndPoints(),i=wt(l),c=yr(l)&&null!==zs(l.anchor.getNode(),e=>Oe$1(e))&&null!==zs(l.focus.getNode(),e=>Oe$1(e))||i;if(1!==r.length||!mn(r[0])||!c||null===s)return false;const[a,u]=s,[h,d,g]=mt(a),p=zs(u.getNode(),e=>Oe$1(e));if(!(Oe$1(h)&&Oe$1(p)&&$e$1(d)&&mn(g)))return false;const C=r[0],[_,S,b]=ft(g,h,p),[y]=gt(C,null,null),N=_.length,v=N>0?_[0].length:0;let x=S.startRow,T=S.startColumn,R=y.length,F=R>0?y[0].length:0;if(i){const e=pt(_,S,b),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;x=e.minRow,T=e.minColumn,R=Math.min(R,t),F=Math.min(F,n);}let O=false;const A=Math.min(N,x+R)-1,K=Math.min(v,T+F)-1,E=new Set;for(let e=x;e<=A;e++)for(let t=T;t<=K;t++){const n=_[e][t];E.has(n.cell.getKey())||(1===n.cell.__rowSpan&&1===n.cell.__colSpan||(dt(n.cell),E.add(n.cell.getKey()),O=true));}let[k]=gt(g.getWritable(),null,null);const M=R-N+x;for(let e=0;e<M;e++){Ge$1(k[N-1][0].cell);}const $=F-v+T;for(let e=0;e<$;e++){tt(k[0][v-1].cell,true,false);}[k]=gt(g.getWritable(),null,null);for(let e=x;e<x+R;e++)for(let t=T;t<T+F;t++){const n=e-x,o=t-T,r=y[n][o];if(r.startRow!==n||r.startColumn!==o)continue;const l=r.cell;if(1!==l.__rowSpan||1!==l.__colSpan){const n=[],o=Math.min(e+l.__rowSpan,x+R)-1,r=Math.min(t+l.__colSpan,T+F)-1;for(let l=e;l<=o;l++)for(let e=t;e<=r;e++){const t=k[l][e];n.push(t.cell);}at(n),O=true;}const{cell:s}=k[e][t],i=s.getChildren();
7610l.getChildren().forEach(e=>{if(lr(e)){Li().append(e),s.append(e);}else s.append(e);}),i.forEach(e=>e.remove());}if(i&&O){const[e]=gt(g.getWritable(),null,null);e[S.startRow][S.startColumn].cell.selectEnd();}return true},Bi)),c.listenersToRemove.add(o.registerCommand(ie$1,()=>{const t=Lr(),r=Ir(),l=c.getAndClearNextFocus();if(null!==l){const{focusCell:n}=l;if(wt(t)&&t.tableKey===c.tableNodeKey)return (n.x!==c.focusX||n.y!==c.focusY)&&(c.$setFocusCellForSelection(n),true);if(n!==c.anchorCell&&Xt(t,e))return c.$setFocusCellForSelection(n),true}if(c.getAndClearShouldCheckSelection()&&yr(r)&&yr(t)&&t.isCollapsed()){const o=t.anchor.getNode(),r=e.getFirstChild(),l=Gt(o);if(null!==l&&$e$1(r)){const t=r.getFirstChild();if(Oe$1(t)&&e.is(zs(l,n=>n.is(e)||n.is(t))))return t.selectStart(),true}}if(yr(t)){const{anchor:n,focus:l}=t,s=n.getNode(),i=l.getNode(),a=Gt(s),u=Gt(i),h=!(!a||!e.is(Qt(a))),d=!(!u||!e.is(Qt(u))),f=h!==d,g=h&&d,m=t.isBackward();if(f){const n=t.clone();if(d){const[t]=ft(e,u,u),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.focus.set(m?o.getKey():r.getKey(),m?o.getChildrenSize():r.getChildrenSize(),"element");}else if(h){const[t]=ft(e,a,a),o=t[0][0].cell,r=t[t.length-1].at(-1).cell;n.anchor.set(m?r.getKey():o.getKey(),m?r.getChildrenSize():0,"element");}wo(n),Pt(o,c);}else if(g&&(a.is(u)||(c.$setAnchorCellForSelection(rn(c,a)),c.$setFocusCellForSelection(rn(c,u),true)),"touch"===c.pointerType&&c.isSelecting&&t.isCollapsed()&&yr(r)&&r.isCollapsed())){const e=Gt(r.anchor.getNode());e&&!e.is(u)&&(c.$setAnchorCellForSelection(rn(c,e)),c.$setFocusCellForSelection(rn(c,u),true),c.pointerType=null);}}else if(t&&wt(t)&&t.is(r)&&t.tableKey===e.getKey()){const n=ps(i);if(n&&n.anchorNode&&n.focusNode){const r=vo(n.focusNode),l=r&&!e.isParentOf(r),s=vo(n.anchorNode),i=s&&e.isParentOf(s);if(l&&i&&n.rangeCount>0){const r=Dr(n,o);r&&(r.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),n.removeAllRanges(),wo(r));}}}return t&&!t.is(r)&&(wt(t)||wt(r))&&c.tableSelection&&!c.tableSelection.is(r)?(wt(t)&&t.tableKey===c.tableNodeKey?c.$updateTableTableSelection(t):!wt(t)&&wt(r)&&r.tableKey===c.tableNodeKey&&c.$updateTableTableSelection(null),false):(c.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),Bt(t.table,t=>{const n=t.elem;t.highlighted=false,Vt(e,t),n.getAttribute("style")||n.removeAttribute("style");});}(o,c):!c.hasHijackedSelectionStyles&&e.isSelected()&&Pt(o,c),false)},Bi)),c.listenersToRemove.add(o.registerCommand(ae$1,()=>{const t=Lr();if(!yr(t)||!t.isCollapsed()||!Xt(t,e))return false;const n=on(o,t,e);return !!n&&(nn(n,e),true)},Bi)),c}function $t(e){return e[Tt]||null}function zt(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode;}return null}function Wt(e,t){if(!e.contains(t))return null;let n=null;for(let o=t;null!=o;o=o.parentNode){if(o===e)return n;const t=o.nodeName;"TD"!==t&&"TH"!==t||(n=o._cell||null);}return null}function Ht(e,t){const n=[],o={columns:0,domRows:n,rows:0};let r=Ft(e,t).querySelector("tr"),l=0,s=0;for(n.length=0;null!=r;){const e=r.nodeName;if("TD"===e||"TH"===e){const e={elem:r,hasBackgroundColor:""!==r.style.backgroundColor,highlighted:false,x:l,y:s};r._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[l]=e;}else {const e=r.firstChild;if(null!=e){r=e;continue}}const t=r.nextSibling;if(null!=t){l++,r=t;continue}const o=r.parentNode;if(null!=o){const e=o.nextSibling;if(null==e)break;s++,l=0,r=e;}}return o.columns=l+1,o.rows=s+1,o}function Lt(e,t,n){const o=new Set(n?n.getNodes():[]);Bt(t,(t,n)=>{const r=t.elem;o.has(n)?(t.highlighted=true,jt(e,t)):(t.highlighted=false,Vt(e,t),r.getAttribute("style")||r.removeAttribute("style"));});}function Bt(e,t){const{domRows:n}=e;for(let e=0;e<n.length;e++){const o=n[e];if(o)for(let n=0;n<o.length;n++){const r=o[n];if(!r)continue;const l=vo(r.elem);null!==l&&t(r,l,{x:n,y:e});}}}function Pt(e,t){t.$disableHighlightStyle(),Bt(t.table,t=>{t.highlighted=true,jt(e,t);});}const Dt=(e,t,n,o,r)=>{const l="forward"===r;switch(r){case "backward":case "forward":return n!==(l?e.table.columns-1:0)?qt(t.getCellNodeFromCordsOrThrow(n+(l?1:-1),o,e.table),l):o!==(l?e.table.rows-1:0)?qt(t.getCellNodeFromCordsOrThrow(l?0:e.table.columns-1,o+(l?1:-1),e.table),l):l?t.selectNext():t.selectPrevious(),true;case "up":return 0!==o?qt(t.getCellNodeFromCordsOrThrow(n,o-1,e.table),false):t.selectPrevious(),true;case "down":return o!==e.table.rows-1?qt(t.getCellNodeFromCordsOrThrow(n,o+1,e.table),true):t.selectNext(),true;default:return false}};function It(e,t){let n,o;
7610if(t.startColumn===e.minColumn)n="minColumn";else {if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn";}if(t.startRow===e.minRow)o="minRow";else {if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;o="maxRow";}return [n,o]}function Ut([e,t]){return ["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Jt(e,t,[n,o]){const r=t[o],l=e[r];void 0===l&&Ke$1(250,o,String(r));const s=t[n],i=l[s];return void 0===i&&Ke$1(250,n,String(s)),i}function Yt(e,t,n,o,r){const l=pt(t,n,o),s=function(e,t){const{minColumn:n,maxColumn:o,minRow:r,maxRow:l}=t;let s=1,i=1,c=1,a=1;const u=e[r],h=e[l];for(let e=n;e<=o;e++)s=Math.max(s,u[e].cell.__rowSpan),a=Math.max(a,h[e].cell.__rowSpan);for(let t=r;t<=l;t++)i=Math.max(i,e[t][n].cell.__colSpan),c=Math.max(c,e[t][o].cell.__colSpan);return {bottomSpan:a,leftSpan:i,rightSpan:c,topSpan:s}}(t,l),{topSpan:i,leftSpan:c,bottomSpan:a,rightSpan:u}=s,h=function(e,t){const n=It(e,t);return null===n&&Ke$1(249,t.cell.getKey()),n}(l,n),[d,f]=Ut(h);let g=l[d],m=l[f];"forward"===r?g+="maxColumn"===d?1:c:"backward"===r?g-="minColumn"===d?1:u:"down"===r?m+="maxRow"===f?1:i:"up"===r&&(m-="minRow"===f?1:a);const p=t[m];if(void 0===p)return false;const C=p[g];if(void 0===C)return false;const[_,S]=function(e,t,n){const o=pt(e,t,n),r=It(o,t);if(r)return [Jt(e,o,r),Jt(e,o,Ut(r))];const l=It(o,n);if(l)return [Jt(e,o,Ut(l)),Jt(e,o,l)];const s=["minColumn","minRow"];return [Jt(e,o,s),Jt(e,o,Ut(s))]}(t,n,C),w=rn(e,_.cell),b=rn(e,S.cell);return e.$setAnchorCellForSelection(w),e.$setFocusCellForSelection(b,true),true}function Xt(e,t){if(yr(e)||wt(e)){const n=t.isParentOf(e.anchor.getNode()),o=t.isParentOf(e.focus.getNode());return n&&o}return false}function qt(e,t){t?e.selectStart():e.selectEnd();}function jt(t,n){const o=n.elem,r=t._config.theme;Oe$1(vo(o))||Ke$1(131),lt$4(o,r.tableCellSelected);}function Vt(e,t){const n=t.elem;Oe$1(vo(n))||Ke$1(131);const r=e._config.theme;ut$3(n,r.tableCellSelected);}function Gt(e){const t=zs(e,Oe$1);return Oe$1(t)?t:null}function Qt(e){const t=zs(e,mn);return mn(t)?t:null}function Zt(e,t,o,r,l,s,i){const c=xl(o.focus,l?"previous":"next");if(Ol(c))return false;let a=c;for(const e of ul(c).iterNodeCarets("shadowRoot")){if(!Hs(e)||!Si(e.origin))return false;a=e;}const u=a.getParentAtCaret();if(!Oe$1(u))return false;const h=u,d=function(e){for(const t of ul(e).iterNodeCarets("root")){const{origin:n}=t;if(Oe$1(n)){if(Gs(t))return il(n,e.direction)}else if(!$e$1(n))break}return null}(tl(h,a.direction)),f=zs(h,mn);if(!f||!f.is(s))return false;const g=e.getElementByKey(h.getKey()),m=zt(g);if(!g||!m)return false;const p=dn(e,f);if(i.table=p,d)if("extend"===r){const t=zt(e.getElementByKey(d.origin.getKey()));if(!t)return false;i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(t,true);}else {const e=El(d);Cl(o.anchor,e),Cl(o.focus,e);}else if("extend"===r)i.$setAnchorCellForSelection(m),i.$setFocusCellForSelection(m,true);else {const e=function(e){const t=sl(e);return Gs(t)?El(t):e}(tl(f,c.direction));Cl(o.anchor,e),Cl(o.focus,e);}return tn(t),true}function en(e,t,o,r,l){if(("up"===o||"down"===o)&&function(e){const t=e.getRootElement();if(!t)return false;return t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls")}(e))return false;const s=Lr();if(!Xt(s,r)){if(yr(s)){if("backward"===o){if(s.focus.offset>0)return false;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(Si(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(s.focus.getNode());if(!e)return false;const n=e.getPreviousSibling();return !!mn(n)&&(tn(t),t.shiftKey?s.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),true)}if(t.shiftKey&&("up"===o||"down"===o)){const e=s.focus.getNode();if(!s.isCollapsed()&&("up"===o&&!s.isBackward()||"down"===o&&s.isBackward())){let l=zs(e,e=>mn(e));if(Oe$1(l)&&(l=zs(l,mn)),l!==r)return false;if(!l)return false;const i="down"===o?l.getNextSibling():l.getPreviousSibling();if(!i)return false;let c=0;"up"===o&&Si(i)&&(c=i.getChildrenSize());let a=i;if("up"===o&&Si(i)){const e=i.getLastChild();a=e||i,c=lr(a)?a.getTextContentSize():0;}const u=s.clone();return u.focus.set(a.getKey(),c,lr(a)?"text":"element"),wo(u),tn(t),true}if(as(e)){const e="up"===o?s.getNodes()[s.getNodes().length-1]:s.getNodes()[0];if(e){if(null!==At(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return false;
7610const[n]=mt(e),[o]=mt(t),s=r.getCordsFromCellNode(n,l.table),i=r.getCordsFromCellNode(o,l.table),c=r.getDOMCellFromCordsOrThrow(s.x,s.y,l.table),a=r.getDOMCellFromCordsOrThrow(i.x,i.y,l.table);return l.$setAnchorCellForSelection(c),l.$setFocusCellForSelection(a,true),true}}return false}{let r=zs(e,e=>Si(e)&&!e.isInline());if(Oe$1(r)&&(r=zs(r,mn)),!r)return false;const i="down"===o?r.getNextSibling():r.getPreviousSibling();if(mn(i)&&l.tableNodeKey===i.getKey()){const e=i.getFirstDescendant(),n=i.getLastDescendant();if(!e||!n)return false;const[r]=mt(e),[l]=mt(n),c=s.clone();return c.focus.set(("up"===o?r:l).getKey(),"up"===o?0:l.getChildrenSize(),"element"),tn(t),wo(c),true}}}}return "down"===o&&an(e)&&l.setShouldCheckSelection(),false}if(yr(s)){if("backward"===o||"forward"===o){return Zt(e,t,s,t.shiftKey?"extend":"move","backward"===o,r,l)}if(s.isCollapsed()){const{anchor:i,focus:c}=s,a=zs(i.getNode(),Oe$1),u=zs(c.getNode(),Oe$1);if(!Oe$1(a)||!a.is(u))return false;const h=Qt(a);if(h!==r&&null!=h){const n=Ft(h,e.getElementByKey(h.getKey()));if(null!=n)return l.table=Ht(h,n),en(e,t,o,h,l)}const d=e.getElementByKey(a.__key),f=e.getElementByKey(i.key);if(null==f||null==d)return false;let g;if("element"===i.type)g=f.getBoundingClientRect();else {const t=ps(Ot(e));if(null===t||0===t.rangeCount)return false;g=t.getRangeAt(0).getBoundingClientRect();}const m="up"===o?a.getFirstChild():a.getLastChild();if(null==m)return false;const p=e.getElementByKey(m.__key);if(null==p)return false;const C=p.getBoundingClientRect();if("up"===o?C.top>g.top-g.height:g.bottom+g.height>C.bottom){tn(t);const e=r.getCordsFromCellNode(a,l.table);if(!t.shiftKey)return Dt(l,r,e.x,e.y,o);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,l.table);l.$setAnchorCellForSelection(t),l.$setFocusCellForSelection(t,true);}return true}}}else if(wt(s)){const{anchor:i,focus:c}=s,a=zs(i.getNode(),Oe$1),u=zs(c.getNode(),Oe$1),[h]=s.getNodes();mn(h)||Ke$1(251);const d=Ft(h,e.getElementByKey(h.getKey()));if(!Oe$1(a)||!Oe$1(u)||!mn(h)||null==d)return false;l.$updateTableTableSelection(s);const f=Ht(h,d),g=r.getCordsFromCellNode(a,f),m=r.getDOMCellFromCordsOrThrow(g.x,g.y,f);
7610if(l.$setAnchorCellForSelection(m),tn(t),t.shiftKey){const[e,t,n]=ft(r,a,u);return Yt(l,e,t,n,o)}return u.selectEnd(),true}return false}function tn(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation();}function nn(e,t,n){const o=Li();"first"===e?t.insertBefore(o):t.insertAfter(o),o.append(...n||[]),o.selectEnd();}function on(e,t,o){const r=o.getParent();if(!r)return;const l=ps(Ot(e));if(!l)return;const s=l.anchorNode,i=e.getElementByKey(r.getKey()),c=Ft(o,e.getElementByKey(o.getKey()));if(!s||!i||!c||!i.contains(s)||c.contains(s))return;const a=zs(t.anchor.getNode(),e=>Oe$1(e));if(!a)return;const u=zs(a,e=>mn(e));if(!mn(u)||!u.is(o))return;const[h,d]=ft(o,a,a),f=h[0][0],g=h[h.length-1][h[0].length-1],{startRow:m,startColumn:p}=d,C=m===f.startRow&&p===f.startColumn,_=m===g.startRow&&p===g.startColumn;return C?"first":_?"last":void 0}function rn(e,t){const{tableNode:n}=e.$lookup(),o=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(o.x,o.y,e.table)}function ln(e,t,n){return At(e,vo(t,n))}function sn(t,n,r){if(!n.theme.tableAlignment)return;const l=[],s=[];for(const e of ["center","right"]){const t=n.theme.tableAlignment[e];t&&(e===r?s:l).push(t);}ut$3(t,...l),lt$4(t,...s);}const cn=new WeakSet;function an(e=bs()){return cn.has(e)}function un(e,t){cn.add(e);}class hn extends Ci{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return "table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new hn(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount;}static importDOM(){return {table:e=>({conversion:fn,priority:1})}}static importJSON(e){return gn().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||false).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=false,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0;}exportJSON(){return {...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return "html"===n}getDOMSlot(e){const t=Rt(e)?e:e.querySelector("table");return Rt(t)||Ke$1(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(t,n){const o=document.createElement("table");this.__style&&(o.style.cssText=this.__style);const r=document.createElement("colgroup");if(o.appendChild(r),Ds(r),lt$4(o,t.theme.table),this.updateTableElement(null,o,t),an(n)){const n=document.createElement("div"),r=t.theme.tableScrollableWrapper;return r?lt$4(n,r):n.style.cssText="overflow-x: auto;",n.appendChild(o),this.updateTableWrapper(null,n,o,t),n}return o}updateTableWrapper(t,n,r,l){this.__frozenColumnCount!==(t?t.__frozenColumnCount:0)&&function(t,n,r,l){l>0?(lt$4(t,r.theme.tableFrozenColumn),n.setAttribute("data-lexical-frozen-column","true")):(ut$3(t,r.theme.tableFrozenColumn),n.removeAttribute("data-lexical-frozen-column"));}(n,r,l,this.__frozenColumnCount),this.__frozenRowCount!==(t?t.__frozenRowCount:0)&&function(t,n,r,l){l>0?(lt$4(t,r.theme.tableFrozenRow),n.setAttribute("data-lexical-frozen-row","true")):(ut$3(t,r.theme.tableFrozenRow),n.removeAttribute("data-lexical-frozen-row"));}(n,r,l,this.__frozenRowCount);}updateTableElement(t,n,r){this.__style!==(t?t.__style:"")&&(n.style.cssText=this.__style),this.__rowStriping!==(!!t&&t.__rowStriping)&&function(t,n,r){r?(lt$4(t,n.theme.tableRowStriping),t.setAttribute("data-lexical-row-striping","true")):(ut$3(t,n.theme.tableRowStriping),t.removeAttribute("data-lexical-row-striping"));}(n,r,this.__rowStriping),function(e,t,n,o){const r=e.querySelector("colgroup");if(!r)return;const l=[];for(let e=0;e<n;e++){const t=document.createElement("col"),n=o&&o[e];n&&(t.style.width=`${n}px`),l.push(t);}r.replaceChildren(...l);}(n,0,this.getColumnCount(),this.getColWidths()),sn(n,r,this.getFormatType());}updateDOM(e,t,n){const o=this.getDOMSlot(t).element;return t===o===an()||(Cs(r=t)&&"DIV"===r.nodeName&&this.updateTableWrapper(e,t,o,n),this.updateTableElement(e,o,n),false);var r;}exportDOM(e){const t=super.exportDOM(e),{element:n}=t;return {after:n=>{if(t.after&&(n=t.after(n)),!Rt(n)&&Cs(n)&&(n=n.querySelector("table")),!Rt(n))return null;sn(n,e._config,this.getFormatType());const[o]=gt(this,null,null),r=new Map;for(const e of o)for(const t of e){const e=t.cell.getKey();r.has(e)||r.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn});}const s=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=r.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){r.delete(t);for(let e=0;e<n.colSpan;e++)s.add(e+n.startColumn);}}}const i=n.querySelector(":scope > colgroup");if(i){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter((e,t)=>
7610s.has(t));i.replaceChildren(...e);}const c=n.querySelectorAll(":scope > tr");if(c.length>0){const e=document.createElement("tbody");for(const t of c)e.appendChild(t);n.append(e);}return n},element:!Rt(n)&&Cs(n)?n.querySelector("table"):n}}canBeEmpty(){return false}isShadowRoot(){return true}getCordsFromCellNode(e,t){const{rows:n,domRows:o}=t;for(let t=0;t<n;t++){const n=o[t];if(null!=n)for(let o=0;o<n.length;o++){const r=n[o];if(null==r)continue;const{elem:l}=r,s=ln(this,l);if(null!==s&&e.is(s))return {x:o,y:t}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,n){const{domRows:o}=n,r=o[t];if(null==r)return null;const l=r[e<r.length?e:r.length-1];return null==l?null:l}getDOMCellFromCordsOrThrow(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,n){const o=this.getDOMCellFromCords(e,t,n);if(null==o)return null;const r=vo(o.elem);return Oe$1(r)?r:null}getCellNodeFromCordsOrThrow(e,t,n){const o=this.getCellNodeFromCords(e,t,n);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return Boolean(this.getLatest().__rowStriping)}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return true}canIndent(){return false}getColumnCount(){const e=this.getFirstChild();if(!e)return 0;let t=0;
7610return e.getChildren().forEach(e=>{Oe$1(e)&&(t+=e.getColSpan());}),t}}function dn(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Ke$1(230),Ht(t,n)}function fn(e){const n=gn();e.hasAttribute("data-lexical-row-striping")&&n.setRowStriping(true),e.hasAttribute("data-lexical-frozen-column")&&n.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&n.setFrozenRows(1);const o=e.querySelector(":scope > colgroup");if(o){let e=[];for(const t of o.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!Ne$1.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n));}e&&n.setColWidths(e);}return {after:e=>kt$6(e,$e$1),node:n}}function gn(){return fs(new hn)}function mn(e){return e instanceof hn}function pn({rows:e,columns:t,includeHeaders:n}){const o=Lr()||Ir();if(!o||!yr(o))return false;if(Qt(o.anchor.getNode()))return false;const r=Le$1(Number(e),Number(t),n);At$5(r);const l=r.getFirstDescendant();return lr(l)&&l.select(),true}function Cn(e){$e$1(e.getParent())?e.isEmpty()&&e.append(Li()):e.remove();}function _n(e){mn(e.getParent())?Bt$3(e,Oe$1):e.remove();}function Sn(e){Bt$3(e,$e$1);const[t]=gt(e,null,null),n=t.reduce((e,t)=>Math.max(e,t.length),0),o=e.getChildren();for(let e=0;e<t.length;++e){const r=o[e];if(!r)continue;$e$1(r)||Ke$1(254,r.constructor.name,r.getType());const l=t[e].reduce((e,t)=>t?1+e:e,0);if(l!==n)for(let e=l;e<n;++e){const e=Fe$1();e.append(Li()),r.append(e);}}}function wn(e){if(e.detail<3||!Ss(e.target))return false;const t=vo(e.target);if(null===t)return false;const o=zs(t,e=>Si(e)&&!e.isInline());if(null===o)return false;return !!Oe$1(o.getParent())&&(o.select(0),true)}function yn(e,t=true){const n=new Map,o=(o,r,l)=>{const s=Ft(o,l),i=Mt(o,s,e,t);n.set(r,[i,s]);},r=e.registerMutationListener(hn,t=>{e.getEditorState().read(()=>{for(const[e,r]of t){const t=n.get(e);if("created"===r||"updated"===r){const{tableNode:r,tableElement:l}=vt(e);void 0===t?o(r,e,l):l!==t[1]&&(t[0].removeListeners(),n.delete(e),o(r,e,l));}else "destroyed"===r&&void 0!==t&&(t[0].removeListeners(),n.delete(e));}},{editor:e});},{skipInitialization:false});return ()=>{r();for(const[,[e]]of n)e.removeListeners();}}function Nn(e){return e.hasNodes([hn])||Ke$1(255),U$4(e.registerCommand(Ae$1,pn,Ki),e.registerCommand(oe$2,({nodes:t,selection:n},o)=>{if(e!==o||!yr(n))return false;return null!==Qt(n.anchor.getNode())&&t.some(mn)},Ki),e.registerCommand(se$1,wn,Ki),e.registerNodeTransform(hn,Sn),e.registerNodeTransform(Ee$1,_n),e.registerNodeTransform(xe,Cn))} 7611 7612function isSelectionHighlighted(selection) { 7613 if (!yr(selection)) return false 7614 7615 if (selection.isCollapsed()) { 7616 return hasHighlightStyles(selection.style) 7617 } else { 7618 return selection.hasFormat("highlight") 7619 } 7620} 7621 7622function hasHighlightStyles(cssOrStyles) { 7623 const styles = typeof cssOrStyles === "string" ? b$3(cssOrStyles) : cssOrStyles; 7624 return !!(styles.color || styles["background-color"]) 7625} 7626 7627function applyCanonicalizers(styles, canonicalizers = []) { 7628 return canonicalizers.reduce((css, canonicalizer) => { 7629 return canonicalizer.applyCanonicalization(css) 7630 }, styles) 7631} 7632 7633class StyleCanonicalizer { 7634 constructor(property, allowedValues= []) { 7635 this._property = property; 7636 this._allowedValues = allowedValues; 7637 this._canonicalValues = this.#allowedValuesIdentityObject; 7638 } 7639 7640 applyCanonicalization(css) { 7641 const styles = { ...b$3(css) }; 7642 7643 styles[this._property] = this.getCanonicalAllowedValue(styles[this._property]); 7644 if (!styles[this._property]) { 7645 delete styles[this._property]; 7646 } 7647 7648 return R$5(styles) 7649 } 7650 7651 getCanonicalAllowedValue(value) { 7652 return this._canonicalValues[value] ||= this.#resolveCannonicalValue(value) 7653 } 7654 7655 // Private 7656 7657 get #allowedValuesIdentityObject() { 7658 return this._allowedValues.reduce((object, value) => ({ ...object, [value]: value }), {}) 7659 } 7660 7661 #resolveCannonicalValue(value) { 7662 let index = this.#computedAllowedValues.indexOf(value); 7663 index ||= this.#computedAllowedValues.indexOf(getComputedStyleForProperty(this._property, value)); 7664 return index === -1 ? null : this._allowedValues[index] 7665 } 7666 7667 get #computedAllowedValues() { 7668 return this._computedAllowedValues ||= this._allowedValues.map( 7669 value => getComputedStyleForProperty(this._property, value) 7670 ) 7671 } 7672} 7673 7674function getComputedStyleForProperty(property, value) { 7675 const style = `${property}: ${value};`; 7676 7677 // the element has to be attached to the DOM have computed styles 7678 const element = document.body.appendChild(createElement("span", { style: "display: none;" + style })); 7679 const computedStyle = window.getComputedStyle(element).getPropertyValue(property); 7680 element.remove(); 7681 7682 return computedStyle 7683} 7684 7685class LexxyExtension { 7686 #editorElement 7687 7688 constructor(editorElement) { 7689 this.#editorElement = editorElement; 7690 } 7691 7692 get editorElement() { 7693 return this.#editorElement 7694 } 7695 7696 get editorConfig() { 7697 return this.#editorElement.config 7698 } 7699 7700 // optional: defaults to true 7701 get enabled() { 7702 return true 7703 } 7704 7705 get lexicalExtension() { 7706 return null 7707 } 7708 7709 initializeToolbar(_lexxyToolbar) { 7710 7711 } 7712} 7713 7714const TOGGLE_HIGHLIGHT_COMMAND = re$1(); 7715const REMOVE_HIGHLIGHT_COMMAND = re$1(); 7716const BLANK_STYLES = { "color": null, "background-color": null }; 7717 7718const hasPastedStylesState = ot$5("hasPastedStyles", { 7719 parse: (value) => value || false 7720}); 7721 7722class HighlightExtension extends LexxyExtension { 7723 get enabled() { 7724 return this.editorElement.supportsRichText 7725 } 7726 7727 get lexicalExtension() { 7728 const extension = Kl({ 7729 dependencies: [ Wt$2 ], 7730 name: "lexxy/highlight", 7731 config: { 7732 color: { buttons: [], permit: [] }, 7733 "background-color": { buttons: [], permit: [] } 7734 }, 7735 html: { 7736 import: { 7737 mark: $markConversion 7738 } 7739 }, 7740 register(editor, config) { 7741 // keep the ref to the canonicalizers for optimized css conversion 7742 const canonicalizers = buildCanonicalizers(config); 7743 7744 return U$4( 7745 editor.registerCommand(TOGGLE_HIGHLIGHT_COMMAND, $toggleSelectionStyles, Ri), 7746 editor.registerCommand(REMOVE_HIGHLIGHT_COMMAND, () => $toggleSelectionStyles(BLANK_STYLES), Ri), 7747 editor.registerNodeTransform(Xn, $syncHighlightWithStyle), 7748 editor.registerNodeTransform(Xn, (textNode) => $canonicalizePastedStyles(textNode, canonicalizers)) 7749 ) 7750 } 7751 }); 7752 7753 return [ extension, this.editorConfig.get("highlight") ] 7754 } 7755} 7756 7757function $applyHighlightStyle(textNode, element) { 7758 const elementStyles = { 7759 color: element.style?.color, 7760 "background-color": element.style?.backgroundColor 7761 }; 7762 7763 if (es(Fn)) { $setPastedStyles(textNode); } 7764 const highlightStyle = R$5(elementStyles); 7765 7766 if (highlightStyle.length) { 7767 return textNode.setStyle(textNode.getStyle() + highlightStyle) 7768 } 7769} 7770 7771function $markConversion() { 7772 return { 7773 conversion: extendTextNodeConversion("mark", $applyHighlightStyle), 7774 priority: 1 7775 } 7776} 7777 7778function buildCanonicalizers(config) { 7779 return [ 7780 new StyleCanonicalizer("color", [ ...config.buttons.color, ...config.permit.color ]), 7781 new StyleCanonicalizer("background-color", [ ...config.buttons["background-color"], ...config.permit["background-color"] ]) 7782 ] 7783} 7784 7785function $toggleSelectionStyles(styles) { 7786 const selection = Lr(); 7787 if (!yr(selection)) return 7788 7789 const patch = {}; 7790 for (const property in styles) { 7791 const oldValue = le$1(selection, property); 7792 patch[property] = toggleOrReplace(oldValue, styles[property]); 7793 } 7794 7795 U$5(selection, patch); 7796} 7797 7798function toggleOrReplace(oldValue, newValue) { 7799 return oldValue === newValue ? null : newValue 7800} 7801 7802function $syncHighlightWithStyle(textNode) { 7803 if (hasHighlightStyles(textNode.getStyle()) !== textNode.hasFormat("highlight")) { 7804 textNode.toggleFormat("highlight"); 7805 } 7806} 7807 7808function $canonicalizePastedStyles(textNode, canonicalizers = []) { 7809 if ($hasPastedStyles(textNode)) { 7810 $setPastedStyles(textNode, false); 7811 7812 const canonicalizedCSS = applyCanonicalizers(textNode.getStyle(), canonicalizers); 7813 textNode.setStyle(canonicalizedCSS); 7814 7815 const selection = Lr(); 7816 if (textNode.isSelected(selection)) { 7817 selection.setStyle(textNode.getStyle()); 7818 selection.setFormat(textNode.getFormat()); 7819 } 7820 } 7821} 7822 7823function $setPastedStyles(textNode, value = true) { 7824 ct$5(textNode, hasPastedStylesState, value); 7825} 7826 7827function $hasPastedStyles(textNode) { 7828 return st$4(textNode, hasPastedStylesState) 7829} 7830 7831const COMMANDS = [ 7832 "bold", 7833 "italic", 7834 "strikethrough", 7835 "link", 7836 "unlink", 7837 "toggleHighlight", 7838 "removeHighlight", 7839 "rotateHeadingFormat", 7840 "insertUnorderedList", 7841 "insertOrderedList", 7842 "insertQuoteBlock", 7843 "insertCodeBlock", 7844 "insertHorizontalDivider", 7845 "uploadAttachments", 7846 7847 "insertTable", 7848 7849 "undo", 7850 "redo" 7851]; 7852
7853class CommandDispatcher { 7854 static configureFor(editorElement) { 7855 new CommandDispatcher(editorElement); 7856 } 7857 7858 constructor(editorElement) { 7859 this.editorElement = editorElement; 7860 this.editor = editorElement.editor; 7861 this.selection = editorElement.selection; 7862 this.contents = editorElement.contents; 7863 this.clipboard = editorElement.clipboard; 7864 7865 this.#registerCommands(); 7866 this.#registerKeyboardCommands(); 7867 this.#registerDragAndDropHandlers(); 7868 } 7869 7870 dispatchPaste(event) { 7871 return this.clipboard.paste(event) 7872 } 7873 7874 dispatchBold() { 7875 this.editor.dispatchCommand(_e$1, "bold"); 7876 } 7877 7878 dispatchItalic() { 7879 this.editor.dispatchCommand(_e$1, "italic"); 7880 } 7881 7882 dispatchStrikethrough() { 7883 this.editor.dispatchCommand(_e$1, "strikethrough"); 7884 } 7885 7886 dispatchToggleHighlight(styles) { 7887 this.editor.dispatchCommand(TOGGLE_HIGHLIGHT_COMMAND, styles); 7888 } 7889 7890 dispatchRemoveHighlight() { 7891 this.editor.dispatchCommand(REMOVE_HIGHLIGHT_COMMAND); 7892 } 7893 7894 dispatchLink(url) { 7895 this.editor.update(() => { 7896 const selection = Lr(); 7897 if (!yr(selection)) return 7898 7899 if (selection.isCollapsed()) { 7900 const autoLinkNode = I$3(url); 7901 const textNode = sr(url); 7902 autoLinkNode.append(textNode); 7903 selection.insertNodes([ autoLinkNode ]); 7904 } else { 7905 J$2(url); 7906 } 7907 }); 7908 } 7909 7910 dispatchUnlink() { 7911 this.#toggleLink(null); 7912 } 7913 7914 dispatchInsertUnorderedList() { 7915 const selection = Lr(); 7916 if (!selection) return 7917 7918 const anchorNode = selection.anchor.getNode(); 7919 7920 if (this.selection.isInsideList && anchorNode && getListType(anchorNode) === "bullet") { 7921 this.contents.unwrapSelectedListItems(); 7922 } else { 7923 this.editor.dispatchCommand(St$4, undefined); 7924 } 7925 } 7926 7927 dispatchInsertOrderedList() { 7928 const selection = Lr(); 7929 if (!selection) return 7930 7931 const anchorNode = selection.anchor.getNode(); 7932 7933 if (this.selection.isInsideList && anchorNode && getListType(anchorNode) === "number") { 7934 this.contents.unwrapSelectedListItems(); 7935 } else { 7936 this.editor.dispatchCommand(xt$3, undefined); 7937 } 7938 } 7939 7940 dispatchInsertQuoteBlock() { 7941 this.contents.toggleNodeWrappingAllSelectedNodes((node) => Ot$2(node), () => _t$2()); 7942 } 7943 7944 dispatchInsertCodeBlock() { 7945 this.editor.update(() => { 7946 if (this.selection.hasSelectedWordsInSingleLine) { 7947 this.editor.dispatchCommand(_e$1, "code"); 7948 } else { 7949 this.contents.toggleNodeWrappingAllSelectedLines((node) => X$1(node), () => new q$1("plain")); 7950 } 7951 }); 7952 } 7953 7954 dispatchInsertHorizontalDivider() { 7955 this.contents.insertAtCursorEnsuringLineBelow(new HorizontalDividerNode()); 7956 this.editor.focus(); 7957 } 7958 7959 dispatchRotateHeadingFormat() { 7960 const selection = Lr(); 7961 if (!yr(selection)) return 7962 7963 if (as(selection.anchor.getNode())) { 7964 selection.insertNodes([ St$3("h2") ]); 7965 return 7966 } 7967 7968 const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow(); 7969 let nextTag = "h2"; 7970 if (It$2(topLevelElement)) { 7971 const currentTag = topLevelElement.getTag(); 7972 if (currentTag === "h2") { 7973 nextTag = "h3"; 7974 } else if (currentTag === "h3") { 7975 nextTag = "h4"; 7976 } else if (currentTag === "h4") { 7977 nextTag = null; 7978 } else { 7979 nextTag = "h2"; 7980 } 7981 } 7982 7983 if (nextTag) { 7984 this.contents.insertNodeWrappingEachSelectedLine(() => St$3(nextTag)); 7985 } else { 7986 this.contents.removeFormattingFromSelectedLines(); 7987 } 7988 } 7989 7990 dispatchUploadAttachments() { 7991 const input = createElement("input", { 7992 type: "file", 7993 multiple: true, 7994 style: "display: none;", 7995 onchange: ({ target }) => { 7996 const files = Array.from(target.files); 7997 if (!files.length) return 7998 7999 for (const file of files) { 8000 this.contents.uploadFile(file); 8001 } 8002 } 8003 }); 8004 8005 this.editorElement.appendChild(input); // Append and remove just for the sake of making it testable 8006 input.click(); 8007 setTimeout(() => input.remove(), 1000); 8008 } 8009 8010 dispatchInsertTable() { 8011 this.editor.dispatchCommand(Ae$1, { "rows": 3, "columns": 3, "includeHeaders": true }); 8012 } 8013 8014 dispatchUndo() { 8015 this.editor.dispatchCommand(pe$1, undefined); 8016 } 8017 8018 dispatchRedo() { 8019 this.editor.dispatchCommand(ye$1, undefined); 8020 } 8021 8022 #registerCommands() { 8023 for (const command of COMMANDS) { 8024 const methodName = `dispatch${capitalize(command)}`; 8025 this.#registerCommandHandler(command, 0, this[methodName].bind(this)); 8026 } 8027 8028 this.#registerCommandHandler(fe$1, zi, this.dispatchPaste.bind(this)); 8029 } 8030 8031 #registerCommandHandler(command, priority, handler) { 8032 this.editor.registerCommand(command, handler, priority); 8033 } 8034 8035 #registerKeyboardCommands() { 8036 this.editor.registerCommand(Me$2, this.#handleTabKey.bind(this), Ri); 8037 } 8038 8039 #registerDragAndDropHandlers() { 8040 if (this.editorElement.supportsAttachments) { 8041 this.dragCounter = 0; 8042 this.editor.getRootElement().addEventListener("dragover", this.#handleDragOver.bind(this)); 8043 this.editor.getRootElement().addEventListener("drop", this.#handleDrop.bind(this)); 8044 this.editor.getRootElement().addEventListener("dragenter", this.#handleDragEnter.bind(this)); 8045 this.editor.getRootElement().addEventListener("dragleave", this.#handleDragLeave.bind(this)); 8046 } 8047 } 8048 8049 #handleDragEnter(event) { 8050 this.dragCounter++; 8051 if (this.dragCounter === 1) { 8052 this.editor.getRootElement().classList.add("lexxy-editor--drag-over"); 8053 } 8054 } 8055 8056 #handleDragLeave(event) { 8057 this.dragCounter--; 8058 if (this.dragCounter === 0) { 8059 this.editor.getRootElement().classList.remove("lexxy-editor--drag-over"); 8060 } 8061 } 8062 8063 #handleDragOver(event) { 8064 event.preventDefault(); 8065 } 8066 8067 #handleDrop(event) { 8068 event.preventDefault(); 8069 8070 this.dragCounter = 0; 8071 this.editor.getRootElement().classList.remove("lexxy-editor--drag-over"); 8072 8073 const dataTransfer = event.dataTransfer; 8074 if (!dataTransfer) return 8075 8076 const files = Array.from(dataTransfer.files); 8077 if (!files.length) return 8078 8079 for (const file of files) { 8080 this.contents.uploadFile(file); 8081 } 8082 8083 this.editor.focus(); 8084 } 8085 8086 #handleTabKey(event) { 8087 if (this.selection.isInsideList) { 8088 return this.#handleTabForList(event) 8089 } else if (this.selection.isInsideCodeBlock) { 8090 return this.#handleTabForCode() 8091 } 8092 return false 8093 } 8094 8095 #handleTabForList(event) { 8096 if (event.shiftKey && !this.selection.isIndentedList) return false 8097 8098 event.preventDefault(); 8099 const command = event.shiftKey? De$2 : Pe$2; 8100 return this.editor.dispatchCommand(command) 8101 } 8102 8103 #handleTabForCode() { 8104 const selection = Lr(); 8105 return yr(selection) && selection.isCollapsed() 8106 } 8107 8108 // Not using TOGGLE_LINK_COMMAND because it's not handled unless you use React/LinkPlugin 8109 #toggleLink(url) { 8110 this.editor.update(() => { 8111 if (url === null) { 8112 J$2(null); 8113 } else { 8114 J$2(url); 8115 } 8116 }); 8117 } 8118} 8119 8120function capitalize(str) { 8121 return str.charAt(0).toUpperCase() + str.slice(1) 8122} 8123 8124function debounceAsync(fn, wait) { 8125 let timeout; 8126 8127 return (...args) => { 8128 clearTimeout(timeout); 8129 8130 return new Promise((resolve, reject) => { 8131 timeout = setTimeout(async () => { 8132 try { 8133 const result = await fn(...args); 8134 resolve(result); 8135 } catch (err) { 8136 reject(err); 8137 } 8138 }, wait); 8139 }) 8140 } 8141} 8142 8143function nextFrame() { 8144 return new Promise(requestAnimationFrame) 8145} 8146 8147class Selection { 8148 constructor(editorElement) { 8149 this.editorElement = editorElement; 8150 this.editorContentElement = editorElement.editorContentElement; 8151 this.editor = this.editorElement.editor; 8152 this.previouslySelectedKeys = new Set(); 8153 8154 this.#listenForNodeSelections(); 8155 this.#processSelectionChangeCommands(); 8156 this.#containEditorFocus(); 8157 } 8158 8159 set current(selection) { 8160 this.editor.update(() => { 8161 this.#syncSelectedClasses(); 8162 }); 8163 } 8164 8165 get hasNodeSelection() { 8166 return this.editor.getEditorState().read(() => { 8167 const selection = Lr(); 8168 return selection !== null && xr(selection) 8169 }) 8170 } 8171 8172 get cursorPosition() { 8173 let position = { x: 0, y: 0 }; 8174 8175 this.editor.getEditorState().read(() => { 8176 const range = this.#getValidSelectionRange(); 8177 if (!range) return 8178 8179 const rect = this.#getReliableRectFromRange(range); 8180 if (!rect) return 8181 8182 position = this.#calculateCursorPosition(rect, range); 8183 }); 8184 8185 return position 8186 } 8187 8188 placeCursorAtTheEnd() { 8189 this.editor.update(() => { 8190 const root = No(); 8191 const lastDescendant = root.getLastDescendant(); 8192 8193 if (lastDescendant && lr(lastDescendant)) { 8194 lastDescendant.selectEnd(); 8195 } else { 8196 root.selectEnd(); 8197 } 8198 }); 8199 } 8200 8201 selectedNodeWithOffset() { 8202 const selection = Lr(); 8203 if (!selection) return { node: null, offset: 0 } 8204 8205 if (yr(selection)) { 8206 return { 8207 node: selection.anchor.getNode(), 8208 offset: selection.anchor.offset 8209 } 8210 } else if (xr(selection)) { 8211 const [ node ] = selection.getNodes(); 8212 return { 8213 node, 8214 offset: 0 8215 } 8216 } 8217 8218 return { node: null, offset: 0 } 8219 } 8220 8221 preservingSelection(fn) { 8222 let selectionState = null; 8223 8224 this.editor.getEditorState().read(() => { 8225 const selection = Lr(); 8226 if (selection && yr(selection)) { 8227 selectionState = { 8228 anchor: { key: selection.anchor.key, offset: selection.anchor.offset }, 8229 focus: { key: selection.focus.key, offset: selection.focus.offset } 8230 }; 8231 } 8232 }); 8233 8234 fn(); 8235 8236 if (selectionState) { 8237 this.editor.update(() => { 8238 const selection = Lr(); 8239 if (selection && yr(selection)) { 8240 selection.anchor.set(selectionState.anchor.key, selectionState.anchor.offset, "text"); 8241 selection.focus.set(selectionState.focus.key, selectionState.focus.offset, "text"); 8242 } 8243 }); 8244 } 8245 } 8246 8247 getFormat() { 8248 const selection = Lr(); 8249 if (!yr(selection)) return {} 8250 8251 const anchorNode = selection.anchor.getNode(); 8252 if (!anchorNode.getParent()) return {} 8253 8254 const topLevelElement = anchorNode.getTopLevelElementOrThrow(); 8255 const listType = getListType(anchorNode); 8256 8257 return { 8258 isBold: selection.hasFormat("bold"), 8259 isItalic: selection.hasFormat("italic"), 8260 isStrikethrough: selection.hasFormat("strikethrough"), 8261 isHighlight: isSelectionHighlighted(selection), 8262 isInLink: wt$5(anchorNode, y$2) !== null, 8263 isInQuote: Ot$2(topLevelElement), 8264 isInHeading: It$2(topLevelElement), 8265 isInCode: selection.hasFormat("code") || wt$5(anchorNode, q$1) !== null, 8266 isInList: listType !== null, 8267 listType, 8268 isInTable: Be$1(anchorNode) !== null 8269 } 8270 } 8271 8272 nearestNodeOfType(nodeType) { 8273 const anchorNode = Lr()?.anchor?.getNode(); 8274 return wt$5(anchorNode, nodeType) 8275 } 8276 8277 get hasSelectedWordsInSingleLine() { 8278 const selection = Lr(); 8279 if (!yr(selection)) return false 8280 8281 if (selection.isCollapsed()) return false 8282 8283 const anchorNode = selection.anchor.getNode(); 8284 const focusNode = selection.focus.getNode(); 8285 8286 if (anchorNode.getTopLevelElement() !== focusNode.getTopLevelElement()) { 8287 return false 8288 } 8289 8290 const anchorElement = anchorNode.getTopLevelElement(); 8291 if (!anchorElement) return false 8292 8293 const nodes = selection.getNodes(); 8294 for (const node of nodes) { 8295 if (jn(node)) { 8296 return false 8297 } 8298 } 8299 8300 return true 8301 } 8302 8303 get isInsideList() { 8304 return this.nearestNodeOfType(nt$2) 8305 } 8306 8307 get isIndentedList() { 8308 const closestListNode = this.nearestNodeOfType(lt$3); 8309 return closestListNode && (W$5(closestListNode) > 1) 8310 } 8311 8312 get isInsideCodeBlock() { 8313 return this.nearestNodeOfType(q$1) !== null 8314 } 8315 8316 get isTableCellSelected() { 8317 return this.nearestNodeOfType(xe) !== null 8318 } 8319 8320 get nodeAfterCursor() { 8321 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8322 if (!anchorNode) return null 8323 8324 if (lr(anchorNode)) { 8325 return this.#getNodeAfterTextNode(anchorNode, offset) 8326 } 8327 8328 if (Si(anchorNode)) { 8329 return this.#getNodeAfterElementNode(anchorNode, offset) 8330 } 8331 8332 return this.#findNextSiblingUp(anchorNode) 8333 } 8334 8335 get topLevelNodeAfterCursor() { 8336 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8337 if (!anchorNode) return null 8338 8339 if (lr(anchorNode)) { 8340 return this.#getNextNodeFromTextEnd(anchorNode) 8341 } 8342 8343 if (Si(anchorNode)) { 8344 return this.#getNodeAfterElementNode(anchorNode, offset) 8345 } 8346 8347 return this.#findNextSiblingUp(anchorNode) 8348 } 8349
8350 get nodeBeforeCursor() { 8351 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8352 if (!anchorNode) return null 8353 8354 if (lr(anchorNode)) { 8355 return this.#getNodeBeforeTextNode(anchorNode, offset) 8356 } 8357 8358 if (Si(anchorNode)) { 8359 return this.#getNodeBeforeElementNode(anchorNode, offset) 8360 } 8361 8362 return this.#findPreviousSiblingUp(anchorNode) 8363 } 8364 8365 get topLevelNodeBeforeCursor() { 8366 const { anchorNode, offset } = this.#getCollapsedSelectionData(); 8367 if (!anchorNode) return null 8368 8369 if (lr(anchorNode)) { 8370 return this.#getPreviousNodeFromTextStart(anchorNode) 8371 } 8372 8373 if (Si(anchorNode)) { 8374 return this.#getNodeBeforeElementNode(anchorNode, offset) 8375 } 8376 8377 return this.#findPreviousSiblingUp(anchorNode) 8378 } 8379 8380 get #currentlySelectedKeys() { 8381 if (this.currentlySelectedKeys) { return this.currentlySelectedKeys } 8382 8383 this.currentlySelectedKeys = new Set(); 8384 8385 const selection = Lr(); 8386 if (selection && xr(selection)) { 8387 for (const node of selection.getNodes()) { 8388 this.currentlySelectedKeys.add(node.getKey()); 8389 } 8390 } 8391 8392 return this.currentlySelectedKeys 8393 } 8394 8395 #processSelectionChangeCommands() { 8396 this.editor.registerCommand(Se$1, this.#selectPreviousNode.bind(this), zi); 8397 this.editor.registerCommand(xe$1, this.#selectNextNode.bind(this), zi); 8398 this.editor.registerCommand(ke$2, this.#selectPreviousTopLevelNode.bind(this), zi); 8399 this.editor.registerCommand(Te$2, this.#selectNextTopLevelNode.bind(this), zi); 8400 8401 this.editor.registerCommand(le$2, this.#selectDecoratorNodeBeforeDeletion.bind(this), zi); 8402 8403 this.editor.registerCommand(ie$1, () => { 8404 this.current = Lr(); 8405 }, zi); 8406 } 8407 8408 #listenForNodeSelections() { 8409 this.editor.registerCommand(se$1, ({ target }) => { 8410 if (!Ss(target)) return false 8411 8412 const targetNode = vo(target); 8413 return Ti(targetNode) && this.#selectInLexical(targetNode) 8414 }, zi); 8415 8416 this.editor.getRootElement().addEventListener("lexxy:internal:move-to-next-line", (event) => { 8417 this.#selectOrAppendNextLine(); 8418 }); 8419 } 8420 8421 #containEditorFocus() { 8422 // Workaround for a bizarre Chrome bug where the cursor abandons the editor to focus on not-focusable elements 8423 // above when navigating UP/DOWN when Lexical shows its fake cursor on custom decorator nodes. 8424 this.editorContentElement.addEventListener("keydown", (event) => { 8425 if (event.key === "ArrowUp") { 8426 const lexicalCursor = this.editor.getRootElement().querySelector("[data-lexical-cursor]"); 8427 8428 if (lexicalCursor) { 8429 let currentElement = lexicalCursor.previousElementSibling; 8430 while (currentElement && currentElement.hasAttribute("data-lexical-cursor")) { 8431 currentElement = currentElement.previousElementSibling; 8432 } 8433 8434 if (!currentElement) { 8435 event.preventDefault(); 8436 } 8437 } 8438 } 8439 8440 if (event.key === "ArrowDown") { 8441 const lexicalCursor = this.editor.getRootElement().querySelector("[data-lexical-cursor]"); 8442 8443 if (lexicalCursor) { 8444 let currentElement = lexicalCursor.nextElementSibling; 8445 while (currentElement && currentElement.hasAttribute("data-lexical-cursor")) { 8446 currentElement = currentElement.nextElementSibling; 8447 } 8448 8449 if (!currentElement) { 8450 event.preventDefault(); 8451 } 8452 } 8453 } 8454 }, true); 8455 } 8456 8457 #syncSelectedClasses() { 8458 this.#clearPreviouslyHighlightedItems(); 8459 this.#highlightNewItems(); 8460 8461 this.previouslySelectedKeys = this.#currentlySelectedKeys; 8462 this.currentlySelectedKeys = null; 8463 } 8464 8465 #clearPreviouslyHighlightedItems() { 8466 for (const key of this.previouslySelectedKeys) { 8467 if (!this.#currentlySelectedKeys.has(key)) { 8468 const dom = this.editor.getElementByKey(key); 8469 if (dom) dom.classList.remove("node--selected"); 8470 } 8471 } 8472 } 8473 8474 #highlightNewItems() { 8475 for (const key of this.#currentlySelectedKeys) { 8476 if (!this.previouslySelectedKeys.has(key)) { 8477 const nodeElement = this.editor.getElementByKey(key); 8478 if (nodeElement) nodeElement.classList.add("node--selected"); 8479 } 8480 } 8481 } 8482 8483 async #selectPreviousNode() { 8484 if (this.hasNodeSelection) { 8485 return await this.#withCurrentNode((currentNode) => currentNode.selectPrevious()) 8486 } else { 8487 return this.#selectInLexical(this.nodeBeforeCursor) 8488 } 8489 } 8490 8491 async #selectNextNode() { 8492 if (this.hasNodeSelection) { 8493 return await this.#withCurrentNode((currentNode) => currentNode.selectNext(0, 0)) 8494 } else { 8495 return this.#selectInLexical(this.nodeAfterCursor) 8496 } 8497 } 8498 8499 async #selectPreviousTopLevelNode() { 8500 if (this.hasNodeSelection) { 8501 return await this.#withCurrentNode((currentNode) => currentNode.getTopLevelElement().selectPrevious()) 8502 } else { 8503 return this.#selectInLexical(this.topLevelNodeBeforeCursor) 8504 } 8505 } 8506 8507 async #selectNextTopLevelNode() { 8508 if (this.hasNodeSelection) { 8509 return await this.#withCurrentNode((currentNode) => currentNode.getTopLevelElement().selectNext(0, 0)) 8510 } else { 8511 return this.#selectInLexical(this.topLevelNodeAfterCursor) 8512 } 8513 } 8514 8515 async #withCurrentNode(fn) { 8516 await nextFrame(); 8517 if (this.hasNodeSelection) { 8518 this.editor.update(() => { 8519 fn(Lr().getNodes()[0]); 8520 this.editor.focus(); 8521 }); 8522 } 8523 } 8524 8525 async #selectOrAppendNextLine() { 8526 this.editor.update(() => { 8527 const topLevelElement = this.#getTopLevelElementFromSelection(); 8528 if (!topLevelElement) return 8529 8530 this.#moveToOrCreateNextLine(topLevelElement); 8531 }); 8532 } 8533 8534 #getTopLevelElementFromSelection() { 8535 const selection = Lr(); 8536 if (!selection) return null 8537 8538 if (xr(selection)) { 8539 return this.#getTopLevelFromNodeSelection(selection) 8540 } 8541 8542 if (yr(selection)) { 8543 return this.#getTopLevelFromRangeSelection(selection) 8544 } 8545 8546 return null 8547 } 8548 8549 #getTopLevelFromNodeSelection(selection) { 8550 const nodes = selection.getNodes(); 8551 return nodes.length > 0 ? nodes[0].getTopLevelElement() : null 8552 } 8553 8554 #getTopLevelFromRangeSelection(selection) { 8555 const anchorNode = selection.anchor.getNode(); 8556 return anchorNode.getTopLevelElement() 8557 } 8558 8559 #moveToOrCreateNextLine(topLevelElement) { 8560 const nextSibling = topLevelElement.getNextSibling(); 8561 8562 if (nextSibling) { 8563 nextSibling.selectStart(); 8564 } else { 8565 this.#createAndSelectNewParagraph(); 8566 } 8567 } 8568 8569 #createAndSelectNewParagraph() { 8570 const root = No(); 8571 const newParagraph = Li(); 8572 root.append(newParagraph); 8573 newParagraph.selectStart(); 8574 } 8575 8576 #selectInLexical(node) { 8577 if (Ti(node)) { 8578 const selection = $createNodeSelectionWith(node); 8579 wo(selection); 8580 return selection 8581 } else { 8582 return false 8583 } 8584 } 8585 8586 #selectDecoratorNodeBeforeDeletion(backwards) { 8587 const node = backwards ? this.nodeBeforeCursor : this.nodeAfterCursor; 8588 if (node instanceof ki) { 8589 this.#selectInLexical(node); 8590 8591 return true 8592 } else { 8593 return false 8594 } 8595 } 8596 8597 #getValidSelectionRange() { 8598 const lexicalSelection = Lr(); 8599 if (!lexicalSelection || !lexicalSelection.isCollapsed()) return null 8600 8601 const nativeSelection = window.getSelection(); 8602 if (!nativeSelection || nativeSelection.rangeCount === 0) return null 8603 8604 return nativeSelection.getRangeAt(0) 8605 } 8606 8607 #getReliableRectFromRange(range) { 8608 let rect = range.getBoundingClientRect(); 8609 8610 if (this.#isRectUnreliable(rect)) { 8611 const marker = this.#createAndInsertMarker(range); 8612 rect = marker.getBoundingClientRect(); 8613 this.#restoreSelectionAfterMarker(marker); 8614 marker.remove(); 8615 } 8616 8617 return rect 8618 } 8619 8620 #isRectUnreliable(rect) { 8621 return rect.width === 0 && rect.height === 0 || rect.top === 0 && rect.left === 0 8622 } 8623 8624 #createAndInsertMarker(range) { 8625 const marker = this.#createMarker();
8626 range.insertNode(marker); 8627 return marker 8628 } 8629 8630 #createMarker() { 8631 const marker = document.createElement("span"); 8632 marker.textContent = "\u200b"; 8633 marker.style.display = "inline-block"; 8634 marker.style.width = "1px"; 8635 marker.style.height = "1em"; 8636 marker.style.lineHeight = "normal"; 8637 marker.setAttribute("nonce", getNonce()); 8638 return marker 8639 } 8640 8641 #restoreSelectionAfterMarker(marker) { 8642 const nativeSelection = window.getSelection(); 8643 nativeSelection.removeAllRanges(); 8644 const newRange = document.createRange(); 8645 newRange.setStartAfter(marker); 8646 newRange.collapse(true); 8647 nativeSelection.addRange(newRange); 8648 } 8649 8650 #calculateCursorPosition(rect, range) { 8651 const rootRect = this.editor.getRootElement().getBoundingClientRect(); 8652 const x = rect.left - rootRect.left; 8653 let y = rect.top - rootRect.top; 8654 8655 const fontSize = this.#getFontSizeForCursor(range); 8656 if (!isNaN(fontSize)) { 8657 y += fontSize; 8658 } 8659 8660 return { x, y, fontSize } 8661 } 8662 8663 #getFontSizeForCursor(range) { 8664 const nativeSelection = window.getSelection(); 8665 const anchorNode = nativeSelection.anchorNode; 8666 const parentElement = this.#getElementFromNode(anchorNode); 8667 8668 if (parentElement instanceof HTMLElement) { 8669 const computed = window.getComputedStyle(parentElement); 8670 return parseFloat(computed.fontSize) 8671 } 8672 8673 return 0 8674 } 8675 8676 #getElementFromNode(node) { 8677 return node?.nodeType === Node.TEXT_NODE ? node.parentElement : node 8678 } 8679 8680 #getCollapsedSelectionData() { 8681 const selection = Lr(); 8682 if (!yr(selection) || !selection.isCollapsed()) { 8683 return { anchorNode: null, offset: 0 } 8684 } 8685 8686 const { anchor } = selection; 8687 return { anchorNode: anchor.getNode(), offset: anchor.offset } 8688 } 8689 8690 #getNodeAfterTextNode(anchorNode, offset) { 8691 if (offset === anchorNode.getTextContentSize()) { 8692 return this.#getNextNodeFromTextEnd(anchorNode) 8693 } 8694 return null 8695 } 8696 8697 #getNextNodeFromTextEnd(anchorNode) { 8698 if (anchorNode.getNextSibling() instanceof ki) { 8699 return anchorNode.getNextSibling() 8700 } 8701 const parent = anchorNode.getParent(); 8702 return parent ? parent.getNextSibling() : null 8703 } 8704 8705 #getNodeAfterElementNode(anchorNode, offset) { 8706 if (offset < anchorNode.getChildrenSize()) { 8707 return anchorNode.getChildAtIndex(offset) 8708 } 8709 return this.#findNextSiblingUp(anchorNode) 8710 } 8711 8712 #getNodeBeforeTextNode(anchorNode, offset) { 8713 if (offset === 0) { 8714 return this.#getPreviousNodeFromTextStart(anchorNode) 8715 } 8716 return null 8717 } 8718 8719 #getPreviousNodeFromTextStart(anchorNode) { 8720 if (anchorNode.getPreviousSibling() instanceof ki) { 8721 return anchorNode.getPreviousSibling() 8722 } 8723 const parent = anchorNode.getParent(); 8724 return parent.getPreviousSibling() 8725 } 8726 8727 #getNodeBeforeElementNode(anchorNode, offset) { 8728 if (offset > 0) { 8729 return anchorNode.getChildAtIndex(offset - 1) 8730 } 8731 return this.#findPreviousSiblingUp(anchorNode) 8732 } 8733 8734 #findNextSiblingUp(node) { 8735 let current = node; 8736 while (current && current.getNextSibling() == null) { 8737 current = current.getParent(); 8738 } 8739 return current ? current.getNextSibling() : null 8740 } 8741 8742 #findPreviousSiblingUp(node) { 8743 let current = node; 8744 while (current && current.getPreviousSibling() == null) { 8745 current = current.getParent(); 8746 } 8747 return current ? current.getPreviousSibling() : null 8748 } 8749} 8750 8751function sanitize(html) { 8752 return purify.sanitize(html, buildConfig()) 8753} 8754 8755function dasherize(value) { 8756 return value.replace(/([A-Z])/g, (_, char) => `-${char.toLowerCase()}`) 8757} 8758 8759function isUrl(string) { 8760 try { 8761 new URL(string); 8762 return true 8763 } catch { 8764 return false 8765 } 8766} 8767 8768function normalizeFilteredText(string) { 8769 return string 8770 .toLowerCase() 8771 .normalize("NFD").replace(/[\u0300-\u036f]/g, "") // Remove diacritics 8772} 8773 8774function filterMatches(text, potentialMatch) { 8775 return normalizeFilteredText(text).includes(normalizeFilteredText(potentialMatch)) 8776} 8777 8778function upcaseFirst(string) { 8779 return string.charAt(0).toUpperCase() + string.slice(1) 8780} 8781 8782class EditorConfiguration { 8783 #editorElement 8784 #config 8785 8786 constructor(editorElement) { 8787 this.#editorElement = editorElement; 8788 this.#config = new Configuration( 8789 Lexxy.presets.get("default"), 8790 Lexxy.presets.get(editorElement.preset), 8791 this.#overrides 8792 ); 8793 } 8794 8795 get(path) { 8796 return this.#config.get(path) 8797 } 8798 8799 get #overrides() { 8800 const overrides = {}; 8801 for (const option of this.#defaultOptions) { 8802 const attribute = dasherize(option); 8803 if (this.#editorElement.hasAttribute(attribute)) { 8804 overrides[option] = this.#parseAttribute(attribute); 8805 } 8806 } 8807 return overrides 8808 } 8809 8810 get #defaultOptions() { 8811 return Object.keys(Lexxy.presets.get("default")) 8812 } 8813 8814 #parseAttribute(attribute) { 8815 const value = this.#editorElement.getAttribute(attribute); 8816 try { 8817 return JSON.parse(value) 8818 } catch { 8819 return value 8820 } 8821 } 8822} 8823 8824class CustomActionTextAttachmentNode extends ki { 8825 static getType() { 8826 return "custom_action_text_attachment" 8827 } 8828 8829 static clone(node) { 8830 return new CustomActionTextAttachmentNode({ ...node }, node.__key) 8831 } 8832 8833 static importJSON(serializedNode) { 8834 return new CustomActionTextAttachmentNode({ ...serializedNode }) 8835 } 8836 8837 static importDOM() { 8838 8839 return { 8840 [this.TAG_NAME]: (element) => { 8841 if (!element.getAttribute("content")) { 8842 return null 8843 } 8844 8845 return { 8846 conversion: (attachment) => { 8847 // Preserve initial space if present since Lexical removes it 8848 const nodes = []; 8849 const previousSibling = attachment.previousSibling; 8850 if (previousSibling && previousSibling.nodeType === Node.TEXT_NODE && /\s$/.test(previousSibling.textContent)) { 8851 nodes.push(sr(" ")); 8852 } 8853 8854 nodes.push(new CustomActionTextAttachmentNode({ 8855 sgid: attachment.getAttribute("sgid"), 8856 innerHtml: JSON.parse(attachment.getAttribute("content")), 8857 contentType: attachment.getAttribute("content-type") 8858 })); 8859 8860 nodes.push(sr(" ")); 8861 8862 return { node: nodes } 8863 }, 8864 priority: 2 8865 } 8866 } 8867 } 8868 } 8869 8870 static get TAG_NAME() { 8871 return Lexxy.global.get("attachmentTagName") 8872 } 8873 8874 constructor({ tagName, sgid, contentType, innerHtml }, key) { 8875 super(key); 8876 8877 const contentTypeNamespace = Lexxy.global.get("attachmentContentTypeNamespace"); 8878 8879 this.tagName = tagName || CustomActionTextAttachmentNode.TAG_NAME; 8880 this.sgid = sgid; 8881 this.contentType = contentType || `application/vnd.${contentTypeNamespace}.unknown`; 8882 this.innerHtml = innerHtml; 8883 } 8884 8885 createDOM() { 8886 const figure = createElement(this.tagName, { "content-type": this.contentType, "data-lexxy-decorator": true }); 8887 8888 figure.insertAdjacentHTML("beforeend", this.innerHtml); 8889 8890 return figure 8891 } 8892 8893 updateDOM() { 8894 return false 8895 } 8896 8897 getTextContent() { 8898 return this.createDOM().textContent.trim() || `[${this.contentType}]` 8899 } 8900 8901 isInline() { 8902 return true 8903 } 8904 8905 exportDOM() { 8906 const attachment = createElement(this.tagName, { 8907 sgid: this.sgid, 8908 content: JSON.stringify(this.innerHtml), 8909 "content-type": this.contentType 8910 }); 8911 8912 return { element: attachment } 8913 } 8914 8915 exportJSON() { 8916 return { 8917 type: "custom_action_text_attachment", 8918 version: 1, 8919 tagName: this.tagName, 8920 sgid: this.sgid, 8921 contentType: this.contentType, 8922 innerHtml: this.innerHtml 8923 } 8924 } 8925 8926 decorate() { 8927 return null 8928 } 8929} 8930 8931class FormatEscaper { 8932 constructor(editorElement) { 8933 this.editorElement = editorElement; 8934 this.editor = editorElement.editor; 8935 } 8936 8937 monitor() { 8938 this.editor.registerCommand( 8939 Ne$2, 8940 (event) => this.#handleEnterKey(event), 8941 Bi 8942 ); 8943 } 8944 8945 #handleEnterKey(event) { 8946 const selection = Lr(); 8947 if (!yr(selection)) return false 8948 8949 const anchorNode = selection.anchor.getNode(); 8950 8951 if (!this.#isInsideBlockquote(anchorNode)) return false 8952
8953 return this.#handleLists(event, anchorNode) 8954 || this.#handleBlockquotes(event, anchorNode) 8955 } 8956 8957 #handleLists(event, anchorNode) { 8958 if (this.#shouldEscapeFromEmptyListItem(anchorNode) || this.#shouldEscapeFromEmptyParagraphInListItem(anchorNode)) { 8959 event.preventDefault(); 8960 this.#escapeFromList(anchorNode); 8961 return true 8962 } 8963 8964 return false 8965 } 8966 8967 #handleBlockquotes(event, anchorNode) { 8968 if (this.#shouldEscapeFromEmptyParagraphInBlockquote(anchorNode)) { 8969 event.preventDefault(); 8970 this.#escapeFromBlockquote(anchorNode); 8971 return true 8972 } 8973 8974 return false 8975 } 8976 8977 #isInsideBlockquote(node) { 8978 let currentNode = node; 8979 8980 while (currentNode) { 8981 if (Ot$2(currentNode)) { 8982 return true 8983 } 8984 currentNode = currentNode.getParent(); 8985 } 8986 8987 return false 8988 } 8989 8990 #shouldEscapeFromEmptyListItem(node) { 8991 const listItem = this.#getListItemNode(node); 8992 if (!listItem) return false 8993 8994 return this.#isNodeEmpty(listItem) 8995 } 8996 8997 #shouldEscapeFromEmptyParagraphInListItem(node) { 8998 const paragraph = this.#getParagraphNode(node); 8999 if (!paragraph) return false 9000 9001 if (!this.#isNodeEmpty(paragraph)) return false 9002 9003 const parent = paragraph.getParent(); 9004 return parent && ot$3(parent) 9005 } 9006 9007 #isNodeEmpty(node) { 9008 if (node.getTextContent().trim() !== "") return false 9009 9010 const children = node.getChildren(); 9011 if (children.length === 0) return true 9012 9013 return children.every(child => { 9014 if (jn(child)) return true 9015 return this.#isNodeEmpty(child) 9016 }) 9017 } 9018 9019 #getListItemNode(node) { 9020 let currentNode = node; 9021 9022 while (currentNode) { 9023 if (ot$3(currentNode)) { 9024 return currentNode 9025 } 9026 currentNode = currentNode.getParent(); 9027 } 9028 9029 return null 9030 } 9031 9032 #escapeFromList(anchorNode) { 9033 const listItem = this.#getListItemNode(anchorNode); 9034 if (!listItem) return 9035 9036 const parentList = listItem.getParent(); 9037 if (!parentList || !dt$2(parentList)) return 9038 9039 const blockquote = parentList.getParent(); 9040 const isInBlockquote = blockquote && Ot$2(blockquote); 9041 9042 if (isInBlockquote) { 9043 const listItemsAfter = this.#getListItemSiblingsAfter(listItem); 9044 const nonEmptyListItems = listItemsAfter.filter(item => !this.#isNodeEmpty(item)); 9045 9046 if (nonEmptyListItems.length > 0) { 9047 this.#splitBlockquoteWithList(blockquote, parentList, listItem, nonEmptyListItems); 9048 return 9049 } 9050 } 9051 9052 const paragraph = Li(); 9053 parentList.insertAfter(paragraph); 9054 9055 listItem.remove(); 9056 paragraph.selectStart(); 9057 } 9058 9059 #shouldEscapeFromEmptyParagraphInBlockquote(node) { 9060 const paragraph = this.#getParagraphNode(node); 9061 if (!paragraph) return false 9062 9063 if (!this.#isNodeEmpty(paragraph)) return false 9064 9065 const parent = paragraph.getParent(); 9066 return parent && Ot$2(parent) 9067 } 9068 9069 #getParagraphNode(node) { 9070 let currentNode = node; 9071 9072 while (currentNode) { 9073 if (Ii(currentNode)) { 9074 return currentNode 9075 } 9076 currentNode = currentNode.getParent(); 9077 } 9078 9079 return null 9080 } 9081 9082 #escapeFromBlockquote(anchorNode) { 9083 const paragraph = this.#getParagraphNode(anchorNode); 9084 if (!paragraph) return 9085 9086 const blockquote = paragraph.getParent(); 9087 if (!blockquote || !Ot$2(blockquote)) return 9088 9089 const siblingsAfter = this.#getSiblingsAfter(paragraph); 9090 const nonEmptySiblings = siblingsAfter.filter(sibling => !this.#isNodeEmpty(sibling)); 9091 9092 if (nonEmptySiblings.length > 0) { 9093 this.#splitBlockquote(blockquote, paragraph, nonEmptySiblings); 9094 } else { 9095 const newParagraph = Li(); 9096 blockquote.insertAfter(newParagraph); 9097 paragraph.remove(); 9098 newParagraph.selectStart(); 9099 } 9100 } 9101 9102 #getSiblingsAfter(node) { 9103 const siblings = []; 9104 let sibling = node.getNextSibling(); 9105 9106 while (sibling) { 9107 siblings.push(sibling); 9108 sibling = sibling.getNextSibling(); 9109 } 9110 9111 return siblings 9112 } 9113 9114 #getListItemSiblingsAfter(listItem) { 9115 const siblings = []; 9116 let sibling = listItem.getNextSibling(); 9117 9118 while (sibling) { 9119 if (ot$3(sibling)) { 9120 siblings.push(sibling); 9121 } 9122 sibling = sibling.getNextSibling(); 9123 } 9124 9125 return siblings 9126 } 9127 9128 #splitBlockquoteWithList(blockquote, parentList, emptyListItem, listItemsAfter) { 9129 const blockquoteSiblingsAfterList = this.#getSiblingsAfter(parentList); 9130 const nonEmptyBlockquoteSiblings = blockquoteSiblingsAfterList.filter(sibling => !this.#isNodeEmpty(sibling)); 9131 9132 const middleParagraph = Li(); 9133 blockquote.insertAfter(middleParagraph); 9134 9135 const newList = ht$3(parentList.getListType()); 9136 9137 const newBlockquote = _t$2(); 9138 middleParagraph.insertAfter(newBlockquote); 9139 newBlockquote.append(newList); 9140 9141 listItemsAfter.forEach(item => { 9142 newList.append(item); 9143 }); 9144
9145 nonEmptyBlockquoteSiblings.forEach(sibling => { 9146 newBlockquote.append(sibling); 9147 }); 9148 9149 emptyListItem.remove(); 9150 9151 this.#removeTrailingEmptyListItems(parentList); 9152 this.#removeTrailingEmptyNodes(newBlockquote); 9153 9154 if (parentList.getChildrenSize() === 0) { 9155 parentList.remove(); 9156 9157 if (blockquote.getChildrenSize() === 0) { 9158 blockquote.remove(); 9159 } 9160 } else { 9161 this.#removeTrailingEmptyNodes(blockquote); 9162 } 9163 9164 middleParagraph.selectStart(); 9165 } 9166 9167 #removeTrailingEmptyListItems(list) { 9168 const items = list.getChildren(); 9169 for (let i = items.length - 1; i >= 0; i--) { 9170 const item = items[i]; 9171 if (ot$3(item) && this.#isNodeEmpty(item)) { 9172 item.remove(); 9173 } else { 9174 break 9175 } 9176 } 9177 } 9178 9179 #removeTrailingEmptyNodes(blockquote) { 9180 const children = blockquote.getChildren(); 9181 for (let i = children.length - 1; i >= 0; i--) { 9182 const child = children[i]; 9183 if (this.#isNodeEmpty(child)) { 9184 child.remove(); 9185 } else { 9186 break 9187 } 9188 } 9189 } 9190 9191 #splitBlockquote(blockquote, emptyParagraph, siblingsAfter) { 9192 const newParagraph = Li(); 9193 blockquote.insertAfter(newParagraph); 9194 9195 const newBlockquote = _t$2(); 9196 newParagraph.insertAfter(newBlockquote); 9197 9198 siblingsAfter.forEach(sibling => { 9199 newBlockquote.append(sibling); 9200 }); 9201 9202 emptyParagraph.remove(); 9203 9204 this.#removeTrailingEmptyNodes(blockquote); 9205 this.#removeTrailingEmptyNodes(newBlockquote); 9206 9207 newParagraph.selectStart(); 9208 } 9209} 9210 9211class Contents { 9212 constructor(editorElement) { 9213 this.editorElement = editorElement; 9214 this.editor = editorElement.editor; 9215 9216 new FormatEscaper(editorElement).monitor(); 9217 } 9218 9219 insertHtml(html, { tag } = {}) { 9220 this.editor.update(() => { 9221 const selection = Lr(); 9222 if (!yr(selection)) return 9223 9224 const nodes = m$1(this.editor, parseHtml(html)); 9225 selection.insertNodes(nodes); 9226 }, { tag }); 9227 } 9228 9229 insertAtCursor(node) { 9230 const selection = Lr(); 9231 const selectedNodes = selection?.getNodes(); 9232 9233 if (yr(selection)) { 9234 jr([ node ]); 9235 } else if (xr(selection) && selectedNodes && selectedNodes.length > 0) { 9236 const lastNode = selectedNodes.at(-1); 9237 lastNode.insertAfter(node); 9238 } else { 9239 const root = No(); 9240 root.append(node); 9241 } 9242 } 9243 9244 insertAtCursorEnsuringLineBelow(node) { 9245 this.insertAtCursor(node); 9246 this.#insertLineBelowIfLastNode(node); 9247 } 9248 9249 insertNodeWrappingEachSelectedLine(newNodeFn) { 9250 this.editor.update(() => { 9251 const selection = Lr(); 9252 if (!yr(selection)) return 9253 9254 const selectedNodes = selection.extract(); 9255 9256 selectedNodes.forEach((node) => { 9257 const parent = node.getParent(); 9258 if (!parent) { return } 9259 9260 const topLevelElement = node.getTopLevelElementOrThrow(); 9261 const wrappingNode = newNodeFn(); 9262 wrappingNode.append(...topLevelElement.getChildren()); 9263 topLevelElement.replace(wrappingNode); 9264 }); 9265 }); 9266 } 9267 9268 toggleNodeWrappingAllSelectedLines(isFormatAppliedFn, newNodeFn) { 9269 this.editor.update(() => { 9270 const selection = Lr(); 9271 if (!yr(selection)) return 9272 9273 const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow(); 9274 9275 // Check if format is already applied 9276 if (isFormatAppliedFn(topLevelElement)) { 9277 this.removeFormattingFromSelectedLines(); 9278 } else { 9279 this.#insertNodeWrappingAllSelectedLines(newNodeFn); 9280 } 9281 }); 9282 } 9283 9284 toggleNodeWrappingAllSelectedNodes(isFormatAppliedFn, newNodeFn) { 9285 this.editor.update(() => { 9286 const selection = Lr(); 9287 if (!yr(selection)) return 9288 9289 const topLevelElement = selection.anchor.getNode().getTopLevelElement(); 9290 9291 // Check if format is already applied 9292 if (topLevelElement && isFormatAppliedFn(topLevelElement)) { 9293 this.#unwrap(topLevelElement); 9294 } else { 9295 this.#insertNodeWrappingAllSelectedNodes(newNodeFn); 9296 } 9297 }); 9298 } 9299 9300 removeFormattingFromSelectedLines() { 9301 this.editor.update(() => { 9302 const selection = Lr(); 9303 if (!yr(selection)) return 9304 9305 const topLevelElement = selection.anchor.getNode().getTopLevelElementOrThrow(); 9306 const paragraph = Li(); 9307 paragraph.append(...topLevelElement.getChildren()); 9308 topLevelElement.replace(paragraph); 9309 }); 9310 } 9311 9312 hasSelectedText() { 9313 let result = false;
9314 9315 this.editor.read(() => { 9316 const selection = Lr(); 9317 result = yr(selection) && !selection.isCollapsed(); 9318 }); 9319 9320 return result 9321 } 9322 9323 unwrapSelectedListItems() { 9324 this.editor.update(() => { 9325 const selection = Lr(); 9326 if (!yr(selection)) return 9327 9328 const { listItems, parentLists } = this.#collectSelectedListItems(selection); 9329 if (listItems.size > 0) { 9330 const newParagraphs = this.#convertListItemsToParagraphs(listItems); 9331 this.#removeEmptyParentLists(parentLists); 9332 this.#selectNewParagraphs(newParagraphs); 9333 } 9334 }); 9335 } 9336 9337 createLink(url) { 9338 let linkNodeKey = null; 9339 9340 this.editor.update(() => { 9341 const textNode = sr(url); 9342 const linkNode = D$2(url); 9343 linkNode.append(textNode); 9344 9345 const selection = Lr(); 9346 if (yr(selection)) { 9347 selection.insertNodes([ linkNode ]); 9348 linkNodeKey = linkNode.getKey(); 9349 } 9350 }); 9351 9352 return linkNodeKey 9353 } 9354 9355 createLinkWithSelectedText(url) { 9356 if (!this.hasSelectedText()) return 9357 9358 this.editor.update(() => { 9359 J$2(url); 9360 }); 9361 } 9362 9363 textBackUntil(string) { 9364 let result = ""; 9365 9366 this.editor.getEditorState().read(() => { 9367 const selection = Lr(); 9368 if (!selection || !selection.isCollapsed()) return 9369 9370 const anchor = selection.anchor; 9371 const anchorNode = anchor.getNode(); 9372 9373 if (!lr(anchorNode)) return 9374 9375 const fullText = anchorNode.getTextContent(); 9376 const offset = anchor.offset; 9377 9378 const textBeforeCursor = fullText.slice(0, offset); 9379 9380 const lastIndex = textBeforeCursor.lastIndexOf(string); 9381 if (lastIndex !== -1) { 9382 result = textBeforeCursor.slice(lastIndex + string.length); 9383 } 9384 }); 9385 9386 return result 9387 } 9388 9389 containsTextBackUntil(string) { 9390 let result = false;
9391 9392 this.editor.getEditorState().read(() => { 9393 const selection = Lr(); 9394 if (!selection || !selection.isCollapsed()) return 9395 9396 const anchor = selection.anchor; 9397 const anchorNode = anchor.getNode(); 9398 9399 if (!lr(anchorNode)) return 9400 9401 const fullText = anchorNode.getTextContent(); 9402 const offset = anchor.offset; 9403 9404 const textBeforeCursor = fullText.slice(0, offset); 9405 9406 result = textBeforeCursor.includes(string); 9407 }); 9408 9409 return result 9410 } 9411 9412 replaceTextBackUntil(stringToReplace, replacementNodes) { 9413 replacementNodes = Array.isArray(replacementNodes) ? replacementNodes : [ replacementNodes ]; 9414 9415 this.editor.update(() => { 9416 const { anchorNode, offset } = this.#getTextAnchorData(); 9417 if (!anchorNode) return 9418 9419 const lastIndex = this.#findLastIndexBeforeCursor(anchorNode, offset, stringToReplace); 9420 if (lastIndex === -1) return 9421 9422 this.#performTextReplacement(anchorNode, offset, lastIndex, replacementNodes); 9423 }); 9424 } 9425 9426 createParagraphAfterNode(node, text) { 9427 const newParagraph = Li(); 9428 node.insertAfter(newParagraph); 9429 newParagraph.selectStart(); 9430 9431 // Insert the typed text 9432 if (text) { 9433 newParagraph.append(sr(text)); 9434 newParagraph.select(1, 1); // Place cursor after the text 9435 } 9436 } 9437 9438 createParagraphBeforeNode(node, text) { 9439 const newParagraph = Li(); 9440 node.insertBefore(newParagraph); 9441 newParagraph.selectStart(); 9442 9443 // Insert the typed text 9444 if (text) { 9445 newParagraph.append(sr(text)); 9446 newParagraph.select(1, 1); // Place cursor after the text 9447 } 9448 } 9449 9450 uploadFile(file) { 9451 if (!this.editorElement.supportsAttachments) { 9452 console.warn("This editor does not supports attachments (it's configured with [attachments=false])"); 9453 return 9454 } 9455 9456 if (!this.#shouldUploadFile(file)) { 9457 return 9458 } 9459 9460 const uploadUrl = this.editorElement.directUploadUrl; 9461 const blobUrlTemplate = this.editorElement.blobUrlTemplate; 9462 9463 this.editor.update(() => { 9464 const uploadedImageNode = new ActionTextAttachmentUploadNode({ file: file, uploadUrl: uploadUrl, blobUrlTemplate: blobUrlTemplate }); 9465 this.insertAtCursor(uploadedImageNode); 9466 }, { tag: Dn }); 9467 } 9468 9469 replaceNodeWithHTML(nodeKey, html, options = {}) { 9470 this.editor.update(() => { 9471 const node = xo(nodeKey); 9472 if (!node) return 9473 9474 const selection = Lr(); 9475 let wasSelected = false; 9476 9477 if (yr(selection)) { 9478 const selectedNodes = selection.getNodes(); 9479 wasSelected = selectedNodes.includes(node) || selectedNodes.some(n => n.getParent() === node); 9480 9481 if (wasSelected) { 9482 wo(null); 9483 } 9484 } 9485 9486 const replacementNode = options.attachment ? this.#createCustomAttachmentNodeWithHtml(html, options.attachment) : this.#createHtmlNodeWith(html); 9487 node.replace(replacementNode); 9488 9489 if (wasSelected) { 9490 replacementNode.selectEnd(); 9491 } 9492 }); 9493 } 9494 9495 insertHTMLBelowNode(nodeKey, html, options = {}) { 9496 this.editor.update(() => { 9497 const node = xo(nodeKey); 9498 if (!node) return 9499 9500 const previousNode = node.getTopLevelElement() || node; 9501 9502 const newNode = options.attachment ? this.#createCustomAttachmentNodeWithHtml(html, options.attachment) : this.#createHtmlNodeWith(html); 9503 previousNode.insertAfter(newNode); 9504 }); 9505 } 9506 9507 #insertLineBelowIfLastNode(node) { 9508 this.editor.update(() => { 9509 const nextSibling = node.getNextSibling(); 9510 if (!nextSibling) { 9511 const newParagraph = Li(); 9512 node.insertAfter(newParagraph); 9513 newParagraph.selectStart(); 9514 } 9515 }); 9516 } 9517 9518 #unwrap(node) { 9519 const children = node.getChildren(); 9520 9521 if (children.length == 0) { 9522 node.insertBefore(Li()); 9523 } else { 9524 children.forEach((child) => { 9525 if (lr(child) && child.getTextContent().trim() !== "") { 9526 const newParagraph = Li(); 9527 newParagraph.append(child); 9528 node.insertBefore(newParagraph); 9529 } else if (!jn(child)) { 9530 node.insertBefore(child); 9531 } 9532 }); 9533 } 9534 9535 node.remove(); 9536 } 9537
9538 #insertNodeWrappingAllSelectedNodes(newNodeFn) { 9539 this.editor.update(() => { 9540 const selection = Lr(); 9541 if (!yr(selection)) return 9542 9543 const selectedNodes = selection.extract(); 9544 if (selectedNodes.length === 0) { 9545 return 9546 } 9547 9548 const topLevelElements = new Set(); 9549 selectedNodes.forEach((node) => { 9550 const topLevel = node.getTopLevelElementOrThrow(); 9551 topLevelElements.add(topLevel); 9552 }); 9553 9554 const elements = this.#withoutTrailingEmptyParagraphs(Array.from(topLevelElements)); 9555 if (elements.length === 0) { 9556 this.#removeStandaloneEmptyParagraph(); 9557 this.insertAtCursor(newNodeFn()); 9558 return 9559 } 9560 9561 const wrappingNode = newNodeFn(); 9562 elements[0].insertBefore(wrappingNode); 9563 elements.forEach((element) => { 9564 wrappingNode.append(element); 9565 }); 9566 }); 9567 } 9568 9569 #withoutTrailingEmptyParagraphs(elements) { 9570 let lastNonEmptyIndex = elements.length - 1; 9571 9572 // Find the last non-empty paragraph 9573 while (lastNonEmptyIndex >= 0) { 9574 const element = elements[lastNonEmptyIndex]; 9575 if (!Ii(element) || !this.#isElementEmpty(element)) { 9576 break 9577 } 9578 lastNonEmptyIndex--; 9579 } 9580 9581 return elements.slice(0, lastNonEmptyIndex + 1) 9582 } 9583 9584 #isElementEmpty(element) { 9585 // Check text content first 9586 if (element.getTextContent().trim() !== "") return false 9587 9588 // Check if it only contains line breaks 9589 const children = element.getChildren(); 9590 return children.length === 0 || children.every(child => jn(child)) 9591 } 9592 9593 #removeStandaloneEmptyParagraph() { 9594 const root = No(); 9595 if (root.getChildrenSize() === 1) { 9596 const firstChild = root.getFirstChild(); 9597 if (firstChild && Ii(firstChild) && this.#isElementEmpty(firstChild)) { 9598 firstChild.remove(); 9599 } 9600 } 9601 } 9602 9603 #insertNodeWrappingAllSelectedLines(newNodeFn) { 9604 this.editor.update(() => { 9605 const selection = Lr(); 9606 if (!yr(selection)) return 9607 9608 if (selection.isCollapsed()) { 9609 this.#wrapCurrentLine(selection, newNodeFn); 9610 } else { 9611 this.#wrapMultipleSelectedLines(selection, newNodeFn); 9612 } 9613 }); 9614 } 9615 9616 #wrapCurrentLine(selection, newNodeFn) { 9617 const anchorNode = selection.anchor.getNode(); 9618 9619 const topLevelElement = anchorNode.getTopLevelElementOrThrow(); 9620 9621 if (topLevelElement.getTextContent()) { 9622 const wrappingNode = newNodeFn(); 9623 wrappingNode.append(...topLevelElement.getChildren()); 9624 topLevelElement.replace(wrappingNode); 9625 } else { 9626 jr([ newNodeFn() ]); 9627 } 9628 } 9629 9630 #wrapMultipleSelectedLines(selection, newNodeFn) { 9631 const selectedParagraphs = this.#extractSelectedParagraphs(selection); 9632 if (selectedParagraphs.length === 0) return 9633 9634 const { lineSet, nodesToDelete } = this.#extractUniqueLines(selectedParagraphs); 9635 if (lineSet.size === 0) return 9636 9637 const wrappingNode = this.#createWrappingNodeWithLines(newNodeFn, lineSet); 9638 this.#replaceWithWrappingNode(selection, wrappingNode); 9639 this.#removeNodes(nodesToDelete); 9640 } 9641 9642 #extractSelectedParagraphs(selection) { 9643 const selectedNodes = selection.extract(); 9644 const selectedParagraphs = selectedNodes 9645 .map((node) => this.#getParagraphFromNode(node)) 9646 .filter(Boolean); 9647 9648 wo(null); 9649 return selectedParagraphs 9650 } 9651 9652 #getParagraphFromNode(node) { 9653 if (Ii(node)) return node 9654 if (lr(node) && node.getParent() && Ii(node.getParent())) { 9655 return node.getParent() 9656 } 9657 return null 9658 } 9659 9660 #extractUniqueLines(selectedParagraphs) { 9661 const lineSet = new Set(); 9662 const nodesToDelete = new Set(); 9663 9664 selectedParagraphs.forEach((paragraphNode) => { 9665 const textContent = paragraphNode.getTextContent(); 9666 if (textContent) { 9667 textContent.split("\n").forEach((line) => { 9668 if (line.trim()) lineSet.add(line); 9669 }); 9670 } 9671 nodesToDelete.add(paragraphNode); 9672 }); 9673 9674 return { lineSet, nodesToDelete } 9675 } 9676 9677 #createWrappingNodeWithLines(newNodeFn, lineSet) { 9678 const wrappingNode = newNodeFn(); 9679 const lines = Array.from(lineSet); 9680
9681 lines.forEach((lineText, index) => { 9682 wrappingNode.append(sr(lineText)); 9683 if (index < lines.length - 1) { 9684 wrappingNode.append(Jn()); 9685 } 9686 }); 9687 9688 return wrappingNode 9689 } 9690 9691 #replaceWithWrappingNode(selection, wrappingNode) { 9692 const anchorNode = selection.anchor.getNode(); 9693 const parent = anchorNode.getParent(); 9694 if (parent) { 9695 parent.replace(wrappingNode); 9696 } 9697 } 9698 9699 #removeNodes(nodesToDelete) { 9700 nodesToDelete.forEach((node) => node.remove()); 9701 } 9702 9703 #collectSelectedListItems(selection) { 9704 const nodes = selection.getNodes(); 9705 const listItems = new Set(); 9706 const parentLists = new Set(); 9707 9708 for (const node of nodes) { 9709 const listItem = wt$5(node, nt$2); 9710 if (listItem) { 9711 listItems.add(listItem); 9712 const parentList = listItem.getParent(); 9713 if (parentList && dt$2(parentList)) { 9714 parentLists.add(parentList); 9715 } 9716 } 9717 } 9718 9719 return { listItems, parentLists } 9720 } 9721 9722 #convertListItemsToParagraphs(listItems) { 9723 const newParagraphs = []; 9724 9725 for (const listItem of listItems) { 9726 const paragraph = this.#convertListItemToParagraph(listItem); 9727 if (paragraph) { 9728 newParagraphs.push(paragraph); 9729 } 9730 } 9731 9732 return newParagraphs 9733 } 9734 9735 #convertListItemToParagraph(listItem) { 9736 const parentList = listItem.getParent(); 9737 if (!parentList || !dt$2(parentList)) return null 9738 9739 const paragraph = Li(); 9740 const sublists = this.#extractSublistsAndContent(listItem, paragraph); 9741 9742 listItem.insertAfter(paragraph); 9743 this.#insertSublists(paragraph, sublists); 9744 listItem.remove(); 9745 9746 return paragraph 9747 } 9748 9749 #extractSublistsAndContent(listItem, paragraph) { 9750 const sublists = []; 9751
9752 listItem.getChildren().forEach((child) => { 9753 if (dt$2(child)) { 9754 sublists.push(child); 9755 } else { 9756 paragraph.append(child); 9757 } 9758 }); 9759 9760 return sublists 9761 } 9762 9763 #insertSublists(paragraph, sublists) { 9764 sublists.forEach((sublist) => { 9765 paragraph.insertAfter(sublist); 9766 }); 9767 } 9768 9769 #removeEmptyParentLists(parentLists) { 9770 for (const parentList of parentLists) { 9771 if (dt$2(parentList) && parentList.getChildrenSize() === 0) { 9772 parentList.remove(); 9773 } 9774 } 9775 } 9776 9777 #selectNewParagraphs(newParagraphs) { 9778 if (newParagraphs.length === 0) return 9779 9780 const firstParagraph = newParagraphs[0]; 9781 const lastParagraph = newParagraphs[newParagraphs.length - 1]; 9782 9783 if (newParagraphs.length === 1) { 9784 firstParagraph.selectEnd(); 9785 } else { 9786 this.#selectParagraphRange(firstParagraph, lastParagraph); 9787 } 9788 } 9789 9790 #selectParagraphRange(firstParagraph, lastParagraph) { 9791 firstParagraph.selectStart(); 9792 const currentSelection = Lr(); 9793 if (currentSelection && yr(currentSelection)) { 9794 currentSelection.anchor.set(firstParagraph.getKey(), 0, "element"); 9795 currentSelection.focus.set(lastParagraph.getKey(), lastParagraph.getChildrenSize(), "element"); 9796 } 9797 } 9798 9799 #getTextAnchorData() { 9800 const selection = Lr(); 9801 if (!selection || !selection.isCollapsed()) return { anchorNode: null, offset: 0 } 9802 9803 const anchor = selection.anchor; 9804 const anchorNode = anchor.getNode(); 9805 9806 if (!lr(anchorNode)) return { anchorNode: null, offset: 0 } 9807 9808 return { anchorNode, offset: anchor.offset } 9809 } 9810 9811 #findLastIndexBeforeCursor(anchorNode, offset, stringToReplace) { 9812 const fullText = anchorNode.getTextContent(); 9813 const textBeforeCursor = fullText.slice(0, offset); 9814 return textBeforeCursor.lastIndexOf(stringToReplace) 9815 } 9816 9817 #performTextReplacement(anchorNode, offset, lastIndex, replacementNodes) { 9818 const fullText = anchorNode.getTextContent(); 9819 const textBeforeString = fullText.slice(0, lastIndex); 9820 const textAfterCursor = fullText.slice(offset); 9821 9822 const textNodeBefore = sr(textBeforeString); 9823 const textNodeAfter = sr(textAfterCursor || " "); 9824 9825 anchorNode.replace(textNodeBefore); 9826 9827 const lastInsertedNode = this.#insertReplacementNodes(textNodeBefore, replacementNodes); 9828 lastInsertedNode.insertAfter(textNodeAfter); 9829 9830 this.#appendLineBreakIfNeeded(textNodeAfter.getParentOrThrow()); 9831 const cursorOffset = textAfterCursor ? 0 : 1; 9832 textNodeAfter.select(cursorOffset, cursorOffset); 9833 } 9834 9835 #insertReplacementNodes(startNode, replacementNodes) { 9836 let previousNode = startNode; 9837 for (const node of replacementNodes) { 9838 previousNode.insertAfter(node); 9839 previousNode = node; 9840 } 9841 return previousNode 9842 } 9843 9844 #appendLineBreakIfNeeded(paragraph) { 9845 if (Ii(paragraph) && this.editorElement.supportsMultiLine) { 9846 const children = paragraph.getChildren(); 9847 const last = children[children.length - 1]; 9848 const beforeLast = children[children.length - 2]; 9849 9850 if (lr(last) && last.getTextContent() === "" && (beforeLast && !lr(beforeLast))) { 9851 paragraph.append(Jn()); 9852 } 9853 } 9854 } 9855 9856 #createCustomAttachmentNodeWithHtml(html, options = {}) { 9857 const attachmentConfig = typeof options === "object" ? options : {}; 9858 9859 return new CustomActionTextAttachmentNode({ 9860 sgid: attachmentConfig.sgid || null, 9861 contentType: "text/html", 9862 innerHtml: html 9863 }) 9864 } 9865 9866 #createHtmlNodeWith(html) { 9867 const htmlNodes = m$1(this.editor, parseHtml(html)); 9868 return htmlNodes[0] || Li() 9869 } 9870 9871 #shouldUploadFile(file) { 9872 return dispatch(this.editorElement, "lexxy:file-accept", { file }, true) 9873 } 9874} 9875 9876/** 9877 * marked v16.4.1 - a markdown parser 9878 * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed) 9879 * https://github.com/markedjs/marked 9880 */ 9881 9882/** 9883 * DO NOT EDIT THIS FILE 9884 * The code in this file is generated from files in ./src/ 9885 */ 9886 9887function L(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var T=L();function G(u){T=u;}var I={exec:()=>null};function h(u,e=""){let t=typeof u=="string"?u:u.source,n={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(m.caret,"$1"),t=t.replace(r,s),n},getRegex:()=>new RegExp(t,e)};return n}var m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine
vendor: 4,627 bytes, line 9887
9887:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:u=>new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}#`),htmlBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i")},be=/^(?:[ \t]*(?:\n|$))+/,Re=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Te=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,E=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=h(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),we=h(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),j=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ye=/^[^\n]+/,Q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Pe=h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Se=h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),v="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$e=h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",U).replace("tag",v).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ae=h(j).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),_e=h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ae).getRegex(),K={blockquote:_e,code:Re,def:Pe,fences:Te,heading:Oe,hr:E,html:$e,lheading:oe,list:Se,newline:be,paragraph:ae,table:I,text:ye},re=h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",E
vendor: 7,033 bytes, lines 9887-9889
9887).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Le={...K,lheading:we,table:re,paragraph:h(j).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex()},Me={...K,html:h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",U).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:h(j).replace("hr",E).replace("heading",` *#{1,6} *[^ 9888]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ze=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ae=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,le=/^( {2,}|\\)\n(?!\s*$)/,Ie=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,W=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Ee=h(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W).getRegex(),pe=/(?!~)[\p{P}\p{S}]/u,Ce=/(?!~)[\s\p{P}\p{S}]/u,Be=/(?:[^\s\p{P}\p{S}]|~)/u,qe=h(/link|code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<!`)(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("code",/(?<!`)(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ve=h(ce,"u").replace(/punct/g,D).getRegex(),De=h(ce,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",He=h(he,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ze=h(he,"gu").replace(/notPunctSpace/g,Be).replace(/punctSpace/g,Ce).replace(/punct/g,pe).getRegex(),Ge=h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ne=h(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),Fe=h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),je=h(U).replace("(?:-->|$)","-->").getRegex(),Qe=h("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ue=h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=h(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Q).getRegex(),ke=h(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q).getRegex(),Ke=h("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",ke).getRegex(),se=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:I,anyPunctuation:Ne,autolink:Fe,blockSkip:qe,br:le,code:Ae,del:I,emStrongLDelim:ve,emStrongRDelimAst:He,emStrongRDelimUnd:Ge,escape:ze,link:Ue,nolink:ke,punctuation:Ee,reflink:de,reflinkSearch:Ke,tag:Qe,text:Ie,url:I},We={...X,link:h(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...X,emStrongRDelimAst:Ze,emStrongLDelim:De,url:h(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",se).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:h(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",se).getRegex()},Xe={...N,br:h(le).replace("{2,}","*").getRegex(),text:h(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},C={normal:K,gfm:Le,pedantic:Me},M={normal:X,gfm:N,breaks:Xe,pedantic:We};var Je={"&":"&","<":"<",">":">",'"':""","'":"'"},ge=u=>Je[u];function w(u,e){if(e){if(m.escapeTest.test(u))return u.replace(m.escapeReplace,ge)}else if(m.escapeTestNoEncode.test(u))return u.replace(m.escapeReplaceNoEncode,ge);return u}function J(u){try{u=encodeURI(u).replace(m.percentDecode,"%");}catch{return null}return u}function V(u,e){let t=u.replace(m.findPipe,(i,s,o)=>{let a=false,l=s;for(;--l>=0&&o[l]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function z(u,e,t){let n=u.length;if(n===0)return "";let r=0;for(;r<n;){let i=u.charAt(n-r-1);if(i===e&&true)r++;else break}return u.slice(0,n-r)}function fe(u,e){if(u.indexOf(e[1])===-1)return -1;let t=0;for(let n=0;n<u.length;n++)if(u[n]==="\\")n++;else if(u[n]===e[0])t++;else if(u[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function me(u,e,t,n,r){let i=e.href,s=e.title||null,o=u[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=true;let a={type:u[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:s,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=false,a}function Ve(u,e,t){let n=u.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(` 9889`).map(i=>{let s=i.match(t.other.beginningSpace);if(s===null)return i;let[o]=s;return o.length>
vendor: 6,982 bytes, lines 9889-9912
9889=r.length?i.slice(r.length):i}).join(` 9890`)}var y=class{options;rules;lexer;constructor(e){this.options=e||T;}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return {type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:z(n,` 9891`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Ve(n,t[3]||"",this.rules);return {type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim());}return {type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return {type:"hr",raw:z(t[0],` 9892`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=z(t[0],` 9893`).split(` 9894`),r="",i="",s=[];for(;n.length>0;){let o=false,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=true;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(` 9895`),p=c.replace(this.rules.other.blockquoteSetextReplace,` 9896 $1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r} 9897${c}`:c,i=i?`${i} 9898${p}`:p;let g=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(p,s,true),this.lexer.state.top=g,n.length===0)break;let d=s.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let R=d,f=R.raw+` 9899`+n.join(` 9900`),O=this.blockquote(f);s[s.length-1]=O,r=r.substring(0,r.length-R.raw.length)+O.raw,i=i.substring(0,i.length-R.text.length)+O.text;break}else if(d?.type==="list"){let R=d,f=R.raw+` 9901`+n.join(` 9902`),O=this.list(f);s[s.length-1]=O,r=r.substring(0,r.length-d.raw.length)+O.raw,i=i.substring(0,i.length-R.raw.length)+O.raw,n=f.substring(s.at(-1).raw.length).split(` 9903`);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=false;for(;e;){let l=false,c="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let g=t[2].split(` 9904`,1)[0].replace(this.rules.other.listReplaceTabs,H=>" ".repeat(3*H.length)),d=e.split(` 9905`,1)[0],R=!g.trim(),f=0;if(this.options.pedantic?(f=2,p=g.trimStart()):R?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=g.slice(f),f+=t[1].length),R&&this.rules.other.blankLine.test(d)&&(c+=d+` 9906`,e=e.substring(d.length+1),l=true),!l){let H=this.rules.other.nextBulletRegex(f),ee=this.rules.other.hrRegex(f),te=this.rules.other.fencesBeginRegex(f),ne=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f);for(;e;){let Z=e.split(` 9907`,1)[0],A;if(d=Z,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),A=d):A=d.replace(this.rules.other.tabCharGlobal," "),te.test(d)||ne.test(d)||xe.test(d)||H.test(d)||ee.test(d))break;if(A.search(this.rules.other.nonSpaceChar)>=f||!d.trim())p+=` 9908`+A.slice(f);else {if(R||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||te.test(g)||ne.test(g)||ee.test(g))break;p+=` 9909`+d;}!R&&!d.trim()&&(R=true),c+=Z+` 9910`,e=e.substring(Z.length+1),g=A.slice(f);}}i.loose||(o?i.loose=true:this.rules.other.doubleBlankLine.test(c)&&(o=true));let O=null,Y;this.options.gfm&&(O=this.rules.other.listIsTask.exec(p),O&&(Y=O[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!O,checked:Y,loose:false,text:p,tokens:[]}),i.raw+=c;}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l=0;l<i.items.length;l++)if(this.lexer.state.top=false,i.items[l].tokens=this.lexer.blockTokens(i.items[l].text,[]),!i.loose){let c=i.items[l].tokens.filter(g=>g.type==="space"),p=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));i.loose=p;}if(i.loose)for(let l=0;l<i.items.length;l++)i.items[l].loose=true;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return {type:"html",block:true,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return {type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=V(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(` 9911`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:true,align:s.align[o]});for(let o of i)s.rows.push(V(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:false,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return {type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===` 9912`?t[1].slice(0,-1):t[1];return {type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return {type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return {type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return !this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if
vendor: 19,520 bytes, lines 9912-9946
9912(!this.rules.other.endAngleBracket.test(n))return;let s=z(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=fe(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]="";}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3]);}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),me(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return {type:"text",raw:s,text:s}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,o,a,l=s,c=0,p=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+s);(r=p.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){l+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){c+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+c);let g=[...r[0]][0].length,d=e.slice(0,s+r.index+g+a);if(Math.min(s,a)%2){let f=d.slice(1,-1);return {type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}let R=d.slice(2,-2);return {type:"strong",raw:d,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return {type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return {type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else {let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0];}return {type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return {type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class u{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||T,this.options.tokenizer=this.options.tokenizer||new y,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:false,inRawBlock:false,top:true};let t={other:m,block:C.normal,inline:M.normal};this.options.pedantic?(t.block=C.pedantic,t.inline=M.pedantic):this.options.gfm&&(t.block=C.gfm,this.options.breaks?t.inline=M.breaks:t.inline=M.gfm),this.tokenizer.rules=t;}static get rules(){return {block:C,inline:M}}static lex(e,t){return new u(t).lex(e)}static lexInline(e,t){return new u(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,` 9913`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens);}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=false){for(this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(s=>(r=s.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),true):false))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let s=t.at(-1);r.raw.length===1&&s!==void 0?s.raw+=` 9914`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(` 9915`)?"":` 9916`)+r.raw,s.text+=` 9917`+r.text,this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(` 9918`)?"":` 9919`)+r.raw,s.text+=` 9920`+r.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let s=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(l=>{a=l.call({lexer:this},o),typeof a=="number"&&a>=0&&(s=Math.min(s,a));}),s<1/0&&s>=0&&(i=e.substring(0,s+1));}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=t.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(` 9921`)?"":` 9922`)+r.raw,s.text+=` 9923`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(` 9924`)?"":` 9925`)+r.raw,s.text+=` 9926`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=false,s="";for(;e;){i||(s=""),i=false;let o;if(this.options.extensions?.inline?.some(l=>(o=l.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),true):false))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let l=t.at(-1);o.type==="text"&&l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,s)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let l=1/0,c=e.slice(1),p;this.options.extensions.startInline.forEach(g=>{p=g.call({lexer:this},c),typeof p=="number"&&p>=0&&(l=Math.min(l,p));}),l<1/0&&l>=0&&(a=e.substring(0,l+1));}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(s=o.raw.slice(-1)),i=true;let l=t.at(-1);l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return t}};var P=class{options;parser;constructor(e){this.options=e||T;}space(e){return ""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+` 9927`;return r?'<pre><code class="language-'+w(r)+'">'+(n?i:w(i,true))+`</code></pre> 9928`:"<pre><code>"+(n?i:w(i,true))+`</code></pre> 9929`}blockquote({tokens:e}){return `<blockquote> 9930${this.parser.parse(e)}</blockquote> 9931`}html({text:e}){return e}def(e){return ""}heading({tokens:e,depth:t}){return `<h${t}>${this.parser.parseInline(e)}</h${t}> 9932`}hr(e){return `<hr> 9933`}list(e){let t=e.ordered,n=e.start,r="";for(let o=0;o<e.items.length;o++){let a=e.items[o];r+=this.listitem(a);}let i=t?"ol":"ul",s=t&&n!==1?' start="'+n+'"':"";return "<"+i+s+`> 9934`+r+"</"+i+`> 9935`}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type==="paragraph"?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=n+" "+w(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=true)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:true}):t+=n+" ";}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li> 9936`}checkbox({checked:e}){return "<input "+(e?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:e}){return `<p>${this.parser.parseInline(e)}</p> 9937`}table(e){let t="",n="";for(let i=0;i<e.header.length;i++)n+=this.tablecell(e.header[i]);t+=this.tablerow({text:n});let r="";for(let i=0;i<e.rows.length;i++){let s=e.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n});}return r&&(r=`<tbody>${r}</tbody>`),`<table> 9938<thead> 9939`+t+`</thead> 9940`+r+`</table> 9941`}tablerow({text:e}){return `<tr> 9942${e}</tr> 9943`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return (e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}> 9944`}strong({tokens:e}){return `<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return `<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return `<code>${w(e,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=J(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+w(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=J(e);if(i===null)return w(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${w(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:w(e.text)}};var $=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return ""+e}image({text:e}){return ""+e}br(){return ""}};var b=class u{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new P,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $;}static parse(e,t){return new u(t).parse(e)}static parseInline(e,t){return new u(t).parseInline(e)}parse(e,t=true){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case "space":{n+=this.renderer.space(s);continue}case "hr":{n+=this.renderer.hr(s);continue}case "heading":{n+=this.renderer.heading(s);continue}case "code":{n+=this.renderer.code(s);continue}case "table":{n+=this.renderer.table(s);continue}case "blockquote":{n+=this.renderer.blockquote(s);continue}case "list":{n+=this.renderer.list(s);continue}case "html":{n+=this.renderer.html(s);continue}case "def":{n+=this.renderer.def(s);continue}case "paragraph":{n+=this.renderer.paragraph(s);continue}case "text":{let o=s,a=this.renderer.text(o);for(;r+1<e.length&&e[r+1].type==="text";)o=e[++r],a+=` 9945`+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:true}]}):n+=a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var S=class{options;block;constructor(e){this.options=e||T;}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?x.lex:x.lexInline}provideParser(){return this.block?b.parse:b.parseInline}};var B=class{defaults=L();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=P;TextRenderer=$;Lexer=x;Tokenizer=y;Hooks=S;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===false&&(a=s.apply(this,o)),a}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new P(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new y(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new S;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,a=n.hooks[o],l=i[o];S.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async&&S.passThroughHooksRespectAsync.has(s))return (async()=>{let g=await a.call(i,c);return l.call(i,g)})();let p=a.call(i,c);return l.call(i,p)}:i[o]=(...c)=>{if(this.defaults.async)return (async()=>{let g=await a.apply(i,c);return g===false&&(g=await l.apply(i,c)),g})();let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a};}this.defaults={...this.defaults,...r};}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return (n,r)=>{let i={...r},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return (async()=>{let a=s.hooks?await s.hooks.preprocess(n):n,c=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(a,s),p=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(p,s.walkTokens));let d=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(p,s);return s.hooks?await s.hooks.postprocess(d):d})().catch(o);try{s.hooks&&(n=s.hooks.preprocess(n));let l=(s.hooks?s.hooks.provideLexer():e?x.lex:x.lexInline)(n,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let p=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(p=s.hooks.postprocess(p)),p}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=` 9946Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+w(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var _=new B;function k(u,e){return _.parse(u,e)}
9946k.options=k.setOptions=function(u){return _.setOptions(u),k.defaults=_.defaults,G(k.defaults),k};k.getDefaults=L;k.defaults=T;k.use=function(...u){return _.use(...u),k.defaults=_.defaults,G(k.defaults),k};k.walkTokens=function(u,e){return _.walkTokens(u,e)};k.parseInline=_.parseInline;k.Parser=b;k.parser=b.parse;k.Renderer=P;k.TextRenderer=$;k.Lexer=x;k.lexer=x.lex;k.Tokenizer=y;k.Hooks=S;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;b.parse;x.lex; 9947 9948class Clipboard { 9949 constructor(editorElement) { 9950 this.editorElement = editorElement; 9951 this.editor = editorElement.editor; 9952 this.contents = editorElement.contents; 9953 } 9954 9955 paste(event) { 9956 const clipboardData = event.clipboardData; 9957 9958 if (!clipboardData) return false 9959 9960 if (this.#isPlainTextOrURLPasted(clipboardData) && !this.#isPastingIntoCodeBlock()) { 9961 this.#pastePlainText(clipboardData); 9962 event.preventDefault(); 9963 return true 9964 } 9965 9966 this.#handlePastedFiles(clipboardData); 9967 } 9968 9969 #isPlainTextOrURLPasted(clipboardData) { 9970 return this.#isOnlyPlainTextPasted(clipboardData) || this.#isOnlyURLPasted(clipboardData) 9971 } 9972 9973 #isOnlyPlainTextPasted(clipboardData) { 9974 const types = Array.from(clipboardData.types); 9975 return types.length === 1 && types[0] === "text/plain" 9976 } 9977 9978 #isOnlyURLPasted(clipboardData) { 9979 // Safari URLs are copied as a text/plain + text/uri-list object 9980 const types = Array.from(clipboardData.types); 9981 return types.length === 2 && types.includes("text/uri-list") && types.includes("text/plain") 9982 } 9983 9984 #isPastingIntoCodeBlock() { 9985 let result = false;
9986 9987 this.editor.getEditorState().read(() => { 9988 const selection = Lr(); 9989 if (!yr(selection)) return 9990 9991 let currentNode = selection.anchor.getNode(); 9992 9993 while (currentNode) { 9994 if (X$1(currentNode)) { 9995 result = true; 9996 return 9997 } 9998 currentNode = currentNode.getParent(); 9999 } 10000 }); 10001 10002 return result 10003 } 10004 10005 #pastePlainText(clipboardData) { 10006 const item = clipboardData.items[0]; 10007 item.getAsString((text) => { 10008 if (isUrl(text) && this.contents.hasSelectedText()) { 10009 this.contents.createLinkWithSelectedText(text); 10010 } else if (isUrl(text)) { 10011 const nodeKey = this.contents.createLink(text); 10012 this.#dispatchLinkInsertEvent(nodeKey, { url: text }); 10013 } else if (this.editorElement.supportsMarkdown) { 10014 this.#pasteMarkdown(text); 10015 } else { 10016 this.#pasteRichText(clipboardData); 10017 } 10018 }); 10019 } 10020 10021 #dispatchLinkInsertEvent(nodeKey, payload) { 10022 const linkManipulationMethods = { 10023 replaceLinkWith: (html, options) => this.contents.replaceNodeWithHTML(nodeKey, html, options), 10024 insertBelowLink: (html, options) => this.contents.insertHTMLBelowNode(nodeKey, html, options) 10025 }; 10026 10027 dispatch(this.editorElement, "lexxy:insert-link", { 10028 ...payload, 10029 ...linkManipulationMethods 10030 }); 10031 } 10032 10033 #pasteMarkdown(text) { 10034 const html = k(text); 10035 this.contents.insertHtml(html, { tag: [ Fn ] }); 10036 } 10037 10038 #pasteRichText(clipboardData) { 10039 this.editor.update(() => { 10040 const selection = Lr(); 10041 R$2(clipboardData, selection, this.editor); 10042 }, { tag: Fn }); 10043 } 10044 10045 #handlePastedFiles(clipboardData) { 10046 if (!this.editorElement.supportsAttachments) return 10047 10048 const html = clipboardData.getData("text/html"); 10049 if (html) return // Ignore if image copied from browser since we will load it as a remote image 10050 10051 this.#preservingScrollPosition(() => { 10052 for (const item of clipboardData.items) { 10053 const file = item.getAsFile(); 10054 if (!file) continue 10055 10056 this.contents.uploadFile(file); 10057 } 10058 }); 10059 } 10060 10061 // Deals with an issue in Safari where it scrolls to the tops after pasting attachments 10062 async #preservingScrollPosition(callback) { 10063 const scrollY = window.scrollY; 10064 const scrollX = window.scrollX; 10065 10066 callback(); 10067 10068 await nextFrame(); 10069 10070 window.scrollTo(scrollX, scrollY); 10071 this.editor.focus(); 10072 } 10073} 10074 10075class Extensions { 10076 10077 constructor(lexxyElement) { 10078 this.lexxyElement = lexxyElement; 10079 10080 this.enabledExtensions = this.#initializeExtensions(); 10081 } 10082 10083 get lexicalExtensions() { 10084 return this.enabledExtensions.map(ext => ext.lexicalExtension).filter(Boolean) 10085 } 10086 10087 initializeToolbars() { 10088 if (this.#lexxyToolbar) { 10089 this.enabledExtensions.forEach(ext => ext.initializeToolbar(this.#lexxyToolbar)); 10090 } 10091 } 10092 10093 get #lexxyToolbar() { 10094 return this.lexxyElement.toolbar 10095 } 10096 10097 get #baseExtensions() { 10098 return this.lexxyElement.baseExtensions 10099 } 10100 10101 get #configuredExtensions() { 10102 return Lexxy.global.get("extensions") 10103 } 10104 10105 #initializeExtensions() { 10106 const extensionDefinitions = this.#baseExtensions.concat(this.#configuredExtensions); 10107 10108 return extensionDefinitions.map( 10109 extension => new extension(this.lexxyElement) 10110 ).filter(extension => extension.enabled) 10111 } 10112} 10113 10114class ProvisionalParagraphNode extends Di { 10115 $config() { 10116 return this.config("provisonal_paragraph", { 10117 extends: Di, 10118 importDOM: () => null, 10119 $transform: (node) => { 10120 node.concretizeIfEdited(node); 10121 node.removeUnlessRequired(node); 10122 } 10123 }) 10124 } 10125 10126 static neededBetween(nodeBefore, nodeAfter) { 10127 return !$isSelectableElement(nodeBefore, "next") 10128 && !$isSelectableElement(nodeAfter, "previous") 10129 } 10130 10131 createDOM(editor) { 10132 const p = super.createDOM(editor); 10133 const selected = this.isSelected(Lr()); 10134 p.classList.add("provisional-paragraph"); 10135 p.classList.toggle("hidden", !selected); 10136 return p 10137 } 10138 10139 updateDOM(_prevNode, dom) { 10140 const selected = this.isSelected(Lr()); 10141 dom.classList.toggle("hidden", !selected); 10142 return false 10143 } 10144 10145 getTextContent() { 10146 return "" 10147 } 10148 10149 exportDOM() { 10150 return { 10151 element: null 10152 } 10153 } 10154
vendor: 5,972 bytes, lines 10155-10358
10155 // override as Lexical has an interesting view of collapsed selection in ElementNodes 10156 // https://github.com/facebook/lexical/blob/f1e4f66014377b1f2595aec2b0ee17f5b7ef4dfc/packages/lexical/src/LexicalNode.ts#L646 10157 isSelected(selection = null) { 10158 const targetSelection = selection || Lr(); 10159 return targetSelection?.getNodes().some(node => node.is(this) || this.isParentOf(node)) 10160 } 10161 10162 removeUnlessRequired(self = this.getLatest()) { 10163 if (!self.required) self.remove(); 10164 } 10165 10166 concretizeIfEdited(self = this.getLatest()) { 10167 if (self.getTextContentSize() > 0) { 10168 self.replace(Li(), true); 10169 } 10170 } 10171 10172 10173 get required() { 10174 return this.isDirectRootChild && ProvisionalParagraphNode.neededBetween(...this.immediateSiblings) 10175 } 10176 10177 get isDirectRootChild() { 10178 const parent = this.getParent(); 10179 return as(parent) 10180 } 10181 10182 get immediateSiblings() { 10183 return [ this.getPreviousSibling(), this.getNextSibling() ] 10184 } 10185} 10186 10187function $isProvisionalParagraphNode(node) { 10188 return node instanceof ProvisionalParagraphNode 10189} 10190 10191function $isSelectableElement(node, direction) { 10192 return Si(node) && (direction === "next" ? node.canInsertTextBefore() : node.canInsertTextAfter()) 10193} 10194 10195class ProvisionalParagraphExtension extends LexxyExtension { 10196 get lexicalExtension() { 10197 return Kl({ 10198 name: "lexxy/provisional-paragraph", 10199 nodes: [ 10200 ProvisionalParagraphNode 10201 ], 10202 register(editor) { 10203 return U$4( 10204 // Process Provisional Paragraph Nodes on RootNode changes as sibling status influences whether 10205 // they are required and their visible/hidden status 10206 editor.registerNodeTransform(Ni, $insertRequiredProvisionalParagraphs), 10207 editor.registerNodeTransform(Ni, $removeUnneededProvisionalParagraphs), 10208 editor.registerCommand(ie$1, $markAllProvisionalParagraphsDirty, Bi) 10209 ) 10210 } 10211 }) 10212 } 10213} 10214 10215function $insertRequiredProvisionalParagraphs(rootNode) { 10216 const firstNode = rootNode.getFirstChild(); 10217 if (ProvisionalParagraphNode.neededBetween(null, firstNode)) { 10218 Nt$5(rootNode, new ProvisionalParagraphNode); 10219 } 10220 10221 for (const node of $t$3(rootNode)) { 10222 const nextNode = node.getNextSibling(); 10223 if (ProvisionalParagraphNode.neededBetween(node, nextNode)) { 10224 node.insertAfter(new ProvisionalParagraphNode); 10225 } 10226 } 10227} 10228 10229function $removeUnneededProvisionalParagraphs(rootNode) { 10230 for (const provisionalParagraph of $getAllProvisionalParagraphs(rootNode)) { 10231 provisionalParagraph.removeUnlessRequired(); 10232 } 10233} 10234 10235function $markAllProvisionalParagraphsDirty() { 10236 for (const provisionalParagraph of $getAllProvisionalParagraphs()) { 10237 provisionalParagraph.markDirty(); 10238 } 10239} 10240 10241function $getAllProvisionalParagraphs(rootNode = No()) { 10242 return kt$6(rootNode.getChildren(), $isProvisionalParagraphNode) 10243} 10244 10245const TRIX_LANGUAGE_ATTR = "language"; 10246 10247class TrixContentExtension extends LexxyExtension { 10248 10249 get enabled() { 10250 return this.editorElement.supportsRichText 10251 } 10252 10253 get lexicalExtension() { 10254 return Kl({ 10255 name: "lexxy/trix-content", 10256 html: { 10257 import: { 10258 em: (element) => onlyStyledElements(element, { 10259 conversion: extendTextNodeConversion("i", $applyHighlightStyle), 10260 priority: 1 10261 }), 10262 span: (element) => onlyStyledElements(element, { 10263 conversion: extendTextNodeConversion("mark", $applyHighlightStyle), 10264 priority: 1 10265 }), 10266 strong: (element) => onlyStyledElements(element, { 10267 conversion: extendTextNodeConversion("b", $applyHighlightStyle), 10268 priority: 1 10269 }), 10270 del: () => ({ 10271 conversion: extendTextNodeConversion("s", $applyStrikethrough, $applyHighlightStyle), 10272 priority: 1 10273 }), 10274 pre: (element) => onlyPreLanguageElements(element, { 10275 conversion: extendConversion(q$1, "pre", $applyLanguage), 10276 priority: 1 10277 }) 10278 } 10279 } 10280 }) 10281 } 10282} 10283 10284function onlyStyledElements(element, conversion) { 10285 const elementHighlighted = element.style.color !== "" || element.style.backgroundColor !== ""; 10286 return elementHighlighted ? conversion : null 10287} 10288 10289function $applyStrikethrough(textNode) { 10290 if (!textNode.hasFormat("strikethrough")) textNode.toggleFormat("strikethrough"); 10291 return textNode 10292} 10293 10294function onlyPreLanguageElements(element, conversion) { 10295 return element.hasAttribute(TRIX_LANGUAGE_ATTR) ? conversion : null 10296} 10297 10298function $applyLanguage(conversionOutput, element) { 10299 const language = dt$1(element.getAttribute(TRIX_LANGUAGE_ATTR)); 10300 conversionOutput.node.setLanguage(language); 10301} 10302 10303class WrappedTableNode extends hn { 10304 $config() { 10305 return this.config("wrapped_table_node", { extends: hn }) 10306 } 10307 10308 static importDOM() { 10309 return super.importDOM() 10310 } 10311 10312 exportDOM(editor) { 10313 const superExport = super.exportDOM(editor); 10314 10315 return { 10316 ...superExport, 10317 after: (tableElement) => { 10318 if (superExport.after) { 10319 tableElement = superExport.after(tableElement); 10320 const clonedTable = tableElement.cloneNode(true); 10321 const wrappedTable = createElement("figure", { className: "lexxy-content__table-wrapper" }, clonedTable.outerHTML); 10322 return wrappedTable 10323 } 10324 10325 return tableElement 10326 } 10327 } 10328 } 10329} 10330 10331class TablesExtension extends LexxyExtension { 10332 10333 get enabled() { 10334 return this.editorElement.supportsRichText 10335 } 10336 10337 get lexicalExtension() { 10338 return Kl({ 10339 name: "lexxy/tables", 10340 nodes: [ 10341 WrappedTableNode, 10342 { 10343 replace: hn, 10344 with: () => new WrappedTableNode(), 10345 withKlass: WrappedTableNode 10346 }, 10347 xe, 10348 Ee$1 10349 ], 10350 register(editor) { 10351 return U$4( 10352 // Register Lexical table plugins 10353 Nn(editor), 10354 yn(editor, true), 10355 un(editor), 10356 10357 // Bug fix: Prevent hardcoded background color (Lexical #8089) 10358 editor.registerNodeTransform(xe, (node) => {
10359 if (node.getBackgroundColor() === null) { 10360 node.setBackgroundColor(""); 10361 } 10362 }), 10363 10364 // Bug fix: Fix column header states (Lexical #8090) 10365 editor.registerNodeTransform(xe, (node) => { 10366 const headerState = node.getHeaderStyles(); 10367 10368 if (headerState !== ve$1.ROW) return 10369 10370 const rowParent = node.getParent(); 10371 const tableNode = rowParent?.getParent(); 10372 if (!tableNode) return 10373 10374 const rows = tableNode.getChildren(); 10375 const cellIndex = rowParent.getChildren().indexOf(node); 10376 10377 const cellsInRow = rowParent.getChildren(); 10378 const isHeaderRow = cellsInRow.every(cell => 10379 cell.getHeaderStyles() !== ve$1.NO_STATUS 10380 ); 10381 10382 const isHeaderColumn = rows.every(row => { 10383 const cell = row.getChildren()[cellIndex]; 10384 return cell && cell.getHeaderStyles() !== ve$1.NO_STATUS 10385 }); 10386 10387 let newHeaderState = ve$1.NO_STATUS; 10388 10389 if (isHeaderRow) newHeaderState |= ve$1.ROW; 10390 if (isHeaderColumn) newHeaderState |= ve$1.COLUMN; 10391 10392 if (newHeaderState !== headerState) { 10393 node.setHeaderStyles(newHeaderState, ve$1.BOTH); 10394 } 10395 }), 10396 10397 editor.registerCommand("insertTableRowAfter", () => { 10398 je$1(true); 10399 }, Ri), 10400 10401 editor.registerCommand("insertTableRowBefore", () => { 10402 je$1(false); 10403 }, Ri), 10404 10405 editor.registerCommand("insertTableColumnAfter", () => { 10406 Ze$1(true); 10407 }, Ri), 10408 10409 editor.registerCommand("insertTableColumnBefore", () => { 10410 Ze$1(false); 10411 }, Ri), 10412 10413 editor.registerCommand("deleteTableRow", () => { 10414 ot(); 10415 }, Ri), 10416 10417 editor.registerCommand("deleteTableColumn", () => { 10418 lt(); 10419 }, Ri), 10420 10421 editor.registerCommand("deleteTable", () => { 10422 const selection = Lr(); 10423 if (!yr(selection)) return false 10424 Qt(selection.anchor.getNode())?.remove(); 10425 }, Ri) 10426 ) 10427 } 10428 }) 10429 } 10430} 10431 10432class LexicalEditorElement extends HTMLElement { 10433 static formAssociated = true 10434 static debug = false 10435 static commands = [ "bold", "italic", "strikethrough" ] 10436 10437 static observedAttributes = [ "connected", "required" ] 10438 10439 #initialValue = "" 10440 #validationTextArea = document.createElement("textarea") 10441 10442 constructor() { 10443 super(); 10444 this.internals = this.attachInternals(); 10445 this.internals.role = "presentation"; 10446 } 10447 10448 connectedCallback() { 10449 this.id ??= generateDomId("lexxy-editor"); 10450 this.config = new EditorConfiguration(this); 10451 this.extensions = new Extensions(this); 10452 10453 this.editor = this.#createEditor(); 10454 10455 this.contents = new Contents(this); 10456 this.selection = new Selection(this); 10457 this.clipboard = new Clipboard(this); 10458 10459 CommandDispatcher.configureFor(this); 10460 this.#initialize(); 10461 10462 requestAnimationFrame(() => dispatch(this, "lexxy:initialize")); 10463 this.toggleAttribute("connected", true); 10464 10465 this.#handleAutofocus(); 10466 10467 this.valueBeforeDisconnect = null; 10468 } 10469 10470 disconnectedCallback() { 10471 this.valueBeforeDisconnect = this.value; 10472 this.#reset(); // Prevent hangs with Safari when morphing 10473 } 10474 10475 attributeChangedCallback(name, oldValue, newValue) { 10476 if (name === "connected" && this.isConnected && oldValue != null && oldValue !== newValue) { 10477 requestAnimationFrame(() => this.#reconnect()); 10478 } 10479 10480 if (name === "required" && this.isConnected) { 10481 this.#validationTextArea.required = this.hasAttribute("required"); 10482 this.#setValidity(); 10483 } 10484 } 10485 10486 formResetCallback() { 10487 this.value = this.#initialValue; 10488 this.editor.dispatchCommand(je$2, undefined); 10489 } 10490 10491 toString() { 10492 if (!this.cachedStringValue) { 10493 this.editor?.getEditorState().read(() => { 10494 this.cachedStringValue = No().getTextContent(); 10495 }); 10496 } 10497 10498 return this.cachedStringValue 10499 } 10500 10501 get form() { 10502 return this.internals.form 10503 } 10504 10505 get name() { 10506 return this.getAttribute("name") 10507 } 10508 10509 get toolbarElement() { 10510 if (!this.#hasToolbar) return null 10511 10512 this.toolbar = this.toolbar || this.#findOrCreateDefaultToolbar(); 10513 return this.toolbar 10514 } 10515 10516 get baseExtensions() { 10517 return [ 10518 ProvisionalParagraphExtension, 10519 HighlightExtension, 10520 TrixContentExtension, 10521 TablesExtension 10522 ] 10523 } 10524
10525 get directUploadUrl() { 10526 return this.dataset.directUploadUrl 10527 } 10528 10529 get blobUrlTemplate() { 10530 return this.dataset.blobUrlTemplate 10531 } 10532 10533 get isEmpty() { 10534 return [ "<p><br></p>", "<p></p>", "" ].includes(this.value.trim()) 10535 } 10536 10537 get isBlank() { 10538 return this.isEmpty || this.toString().match(/^\s*$/g) !== null 10539 } 10540 10541 get hasOpenPrompt() { 10542 return this.querySelector(".lexxy-prompt-menu.lexxy-prompt-menu--visible") !== null 10543 } 10544 10545 get preset() { 10546 return this.getAttribute("preset") || "default" 10547 } 10548 10549 get supportsAttachments() { 10550 return this.config.get("attachments") 10551 } 10552 10553 get supportsMarkdown() { 10554 return this.supportsRichText && this.config.get("markdown") 10555 } 10556 10557 get supportsMultiLine() { 10558 return this.config.get("multiLine") && !this.isSingleLineMode 10559 } 10560 10561 get supportsRichText() { 10562 return this.config.get("richText") 10563 } 10564 10565 // TODO: Deprecate `single-line` attribute 10566 get isSingleLineMode() { 10567 return this.hasAttribute("single-line") 10568 } 10569 10570 get contentTabIndex() { 10571 return parseInt(this.editorContentElement?.getAttribute("tabindex") ?? "0") 10572 } 10573 10574 focus() { 10575 this.editor.focus(() => this.#onFocus()); 10576 } 10577 10578 get value() { 10579 if (!this.cachedValue) { 10580 this.editor?.getEditorState().read(() => { 10581 this.cachedValue = sanitize(g(this.editor, null)); 10582 }); 10583 } 10584 10585 return this.cachedValue 10586 } 10587 10588 set value(html) { 10589 this.editor.update(() => { 10590 ns(zn); 10591 const root = No(); 10592 root.clear(); 10593 root.append(...this.#parseHtmlIntoLexicalNodes(html)); 10594 root.selectEnd(); 10595 10596 this.#toggleEmptyStatus(); 10597 10598 // The first time you set the value, when the editor is empty, it seems to leave Lexical 10599 // in an inconsistent state until, at least, you focus. You can type but adding attachments 10600 // fails because no root node detected. This is a workaround to deal with the issue. 10601 requestAnimationFrame(() => this.editor?.update(() => { })); 10602 }); 10603 } 10604 10605 #parseHtmlIntoLexicalNodes(html) { 10606 if (!html) html = "<p></p>"; 10607 const nodes = m$1(this.editor, parseHtml(`${html}`)); 10608 10609 return nodes 10610 .map(this.#wrapTextNode) 10611 .map(this.#unwrapDecoratorNode) 10612 } 10613 10614 // Raw string values produce TextNodes which cannot be appended directly to the RootNode. 10615 // We wrap those in <p> 10616 #wrapTextNode(node) { 10617 if (!lr(node)) return node 10618 10619 const paragraph = Li(); 10620 paragraph.append(node); 10621 return paragraph 10622 } 10623 10624 // Custom decorator block elements such as action-text-attachments get wrapped into <p> automatically by Lexical. 10625 // We unwrap those. 10626 #unwrapDecoratorNode(node) { 10627 if (Ii(node) && node.getChildrenSize() === 1) { 10628 const child = node.getFirstChild(); 10629 if (Ti(child) && !child.isInline()) { 10630 return child 10631 } 10632 } 10633 return node 10634 } 10635 10636 #initialize() { 10637 this.#synchronizeWithChanges(); 10638 this.#registerComponents(); 10639 this.#handleEnter(); 10640 this.#registerFocusEvents(); 10641 this.#attachDebugHooks(); 10642 this.#attachToolbar(); 10643 this.#loadInitialValue(); 10644 this.#resetBeforeTurboCaches(); 10645 } 10646 10647 #createEditor() { 10648 this.editorContentElement ||= this.#createEditorContentElement(); 10649 10650 const editor = $t$2({ 10651 name: "lexxy/core", 10652 namespace: "Lexxy", 10653 theme: theme, 10654 nodes: this.#lexicalNodes 10655 }, 10656 ...this.extensions.lexicalExtensions 10657 ); 10658 10659 editor.setRootElement(this.editorContentElement); 10660 10661 return editor 10662 } 10663 10664 get #lexicalNodes() { 10665 const nodes = [ CustomActionTextAttachmentNode ]; 10666 10667 if (this.supportsRichText) { 10668 nodes.push( 10669 Et$3, 10670 Pt$3, 10671 lt$3, 10672 nt$2, 10673 q$1, 10674 et$1, 10675 y$2, 10676 A$1, 10677 HorizontalDividerNode 10678 ); 10679 } 10680 10681 if (this.supportsAttachments) { 10682 nodes.push(ActionTextAttachmentNode, ActionTextAttachmentUploadNode); 10683 } 10684 10685 return nodes 10686 } 10687 10688 #createEditorContentElement() { 10689 const editorContentElement = createElement("div", { 10690 classList: "lexxy-editor__content", 10691 contenteditable: true, 10692 role: "textbox", 10693 "aria-multiline": true, 10694 "aria-label": this.#labelText, 10695 placeholder: this.getAttribute("placeholder") 10696 }); 10697 editorContentElement.id = `${this.id}-content`;
10698 this.#ariaAttributes.forEach(attribute => editorContentElement.setAttribute(attribute.name, attribute.value)); 10699 this.appendChild(editorContentElement); 10700 10701 if (this.getAttribute("tabindex")) { 10702 editorContentElement.setAttribute("tabindex", this.getAttribute("tabindex")); 10703 this.removeAttribute("tabindex"); 10704 } else { 10705 editorContentElement.setAttribute("tabindex", 0); 10706 } 10707 10708 return editorContentElement 10709 } 10710 10711 get #labelText() { 10712 return Array.from(this.internals.labels).map(label => label.textContent).join(" ") 10713 } 10714 10715 get #ariaAttributes() { 10716 return Array.from(this.attributes).filter(attribute => attribute.name.startsWith("aria-")) 10717 } 10718 10719 set #internalFormValue(html) { 10720 const changed = this.#internalFormValue !== undefined && this.#internalFormValue !== this.value; 10721 10722 this.internals.setFormValue(html); 10723 this._internalFormValue = html; 10724 this.#validationTextArea.value = this.isEmpty ? "" : html; 10725 10726 if (changed) { 10727 dispatch(this, "lexxy:change"); 10728 } 10729 } 10730 10731 get #internalFormValue() { 10732 return this._internalFormValue 10733 } 10734 10735 #loadInitialValue() { 10736 const initialHtml = this.valueBeforeDisconnect || this.getAttribute("value") || "<p></p>"; 10737 this.value = this.#initialValue = initialHtml; 10738 } 10739 10740 #resetBeforeTurboCaches() { 10741 document.addEventListener("turbo:before-cache", this.#handleTurboBeforeCache); 10742 } 10743 10744 #handleTurboBeforeCache = (event) => { 10745 this.#reset(); 10746 } 10747 10748 #synchronizeWithChanges() { 10749 this.#addUnregisterHandler(this.editor.registerUpdateListener(({ editorState }) => { 10750 this.#clearCachedValues(); 10751 this.#internalFormValue = this.value; 10752 this.#toggleEmptyStatus(); 10753 this.#setValidity(); 10754 })); 10755 } 10756 10757 #clearCachedValues() { 10758 this.cachedValue = null; 10759 this.cachedStringValue = null; 10760 } 10761 10762 #addUnregisterHandler(handler) { 10763 this.unregisterHandlers = this.unregisterHandlers || []; 10764 this.unregisterHandlers.push(handler); 10765 } 10766 10767 #unregisterHandlers() { 10768 this.unregisterHandlers?.forEach((handler) => { 10769 handler(); 10770 }); 10771 this.unregisterHandlers = null; 10772 } 10773 10774 #registerComponents() { 10775 if (this.supportsRichText) { 10776 Jt$1(this.editor); 10777 bt$4(this.editor); 10778 this.#registerTableComponents(); 10779 this.#registerCodeHiglightingComponents(); 10780 if (this.supportsMarkdown) { 10781 Dt$1(this.editor, zt$1); 10782 } 10783 } else { 10784 z$2(this.editor); 10785 } 10786 this.historyState = w$1(); 10787 b$1(this.editor, this.historyState, 20); 10788 } 10789 10790 #registerTableComponents() { 10791 this.tableTools = createElement("lexxy-table-tools"); 10792 this.append(this.tableTools); 10793 } 10794 10795 #registerCodeHiglightingComponents() { 10796 Et$2(this.editor); 10797 this.codeLanguagePicker = createElement("lexxy-code-language-picker"); 10798 this.append(this.codeLanguagePicker); 10799 } 10800 10801 #handleEnter() { 10802 // We can't prevent these externally using regular keydown because Lexical handles it first. 10803 this.editor.registerCommand( 10804 Ne$2, 10805 (event) => { 10806 // Prevent CTRL+ENTER 10807 if (event.ctrlKey || event.metaKey) { 10808 event.preventDefault(); 10809 return true 10810 } 10811 10812 // In single line mode, prevent ENTER 10813 if (!this.supportsMultiLine) { 10814 event.preventDefault(); 10815 return true 10816 } 10817 10818 return false 10819 }, 10820 Ri 10821 ); 10822 } 10823 10824 #registerFocusEvents() { 10825 this.addEventListener("focusin", this.#handleFocusIn); 10826 this.addEventListener("focusout", this.#handleFocusOut); 10827 } 10828 10829 #handleFocusIn(event) { 10830 if (this.#elementInEditorOrToolbar(event.target) && !this.currentlyFocused) { 10831 dispatch(this, "lexxy:focus"); 10832 this.currentlyFocused = true; 10833 } 10834 } 10835 10836 #handleFocusOut(event) { 10837 if (!this.#elementInEditorOrToolbar(event.relatedTarget)) { 10838 dispatch(this, "lexxy:blur"); 10839 this.currentlyFocused = false; 10840 } 10841 } 10842 10843 #elementInEditorOrToolbar(element) { 10844 return this.contains(element) || this.toolbarElement?.contains(element) 10845 } 10846 10847 #onFocus() { 10848 if (this.isEmpty) { 10849 this.selection.placeCursorAtTheEnd(); 10850 } 10851 } 10852 10853 #handleAutofocus() { 10854 if (!document.querySelector(":focus")) { 10855 if (this.hasAttribute("autofocus") && document.querySelector("[autofocus]") === this) { 10856 this.focus(); 10857 } 10858 } 10859 } 10860 10861 10862 #attachDebugHooks() { 10863 return 10864 } 10865 10866 #attachToolbar() { 10867 if (this.#hasToolbar) { 10868 this.toolbarElement.setEditor(this); 10869 this.extensions.initializeToolbars(); 10870 } 10871 } 10872 10873 #findOrCreateDefaultToolbar() { 10874 const toolbarId = this.config.get("toolbar"); 10875 if (toolbarId && toolbarId !== true) { 10876 return document.getElementById(toolbarId) 10877 } else { 10878 return this.#createDefaultToolbar() 10879 } 10880 } 10881 10882 get #hasToolbar() { 10883 return this.supportsRichText && this.config.get("toolbar") 10884 } 10885 10886 #createDefaultToolbar() { 10887 const toolbar = createElement("lexxy-toolbar"); 10888 toolbar.innerHTML = LexicalToolbarElement.defaultTemplate; 10889 toolbar.setAttribute("data-attachments", this.supportsAttachments); // Drives toolbar CSS styles 10890 this.prepend(toolbar); 10891 return toolbar 10892 } 10893 10894 #toggleEmptyStatus() { 10895 this.classList.toggle("lexxy-editor--empty", this.isEmpty); 10896 } 10897 10898 #setValidity() { 10899 if (this.#validationTextArea.validity.valid) { 10900 this.internals.setValidity({}); 10901 } else { 10902 this.internals.setValidity(this.#validationTextArea.validity, this.#validationTextArea.validationMessage, this.editorContentElement); 10903 } 10904 } 10905 10906 #reset() { 10907 this.#unregisterHandlers(); 10908 10909 if (this.editorContentElement) { 10910 this.editorContentElement.remove(); 10911 this.editorContentElement = null; 10912 } 10913 10914 this.contents = null; 10915 this.editor = null; 10916 10917 if (this.toolbar) { 10918 if (!this.getAttribute("toolbar")) { this.toolbar.remove(); } 10919 this.toolbar = null; 10920 } 10921 10922 if (this.codeLanguagePicker) { 10923 this.codeLanguagePicker.remove(); 10924 this.codeLanguagePicker = null; 10925 } 10926 10927 if (this.tableHandler) { 10928 this.tableHandler.remove(); 10929 this.tableHandler = null; 10930 } 10931 10932 this.selection = null; 10933 10934 document.removeEventListener("turbo:before-cache", this.#handleTurboBeforeCache); 10935 } 10936 10937 #reconnect() { 10938 this.disconnectedCallback(); 10939 this.valueBeforeDisconnect = null; 10940 this.connectedCallback(); 10941 } 10942} 10943 10944class ToolbarDropdown extends HTMLElement { 10945 connectedCallback() { 10946 this.container = this.closest("details"); 10947 10948 this.container.addEventListener("toggle", this.#handleToggle.bind(this)); 10949 this.container.addEventListener("keydown", this.#handleKeyDown.bind(this)); 10950 10951 this.#onToolbarEditor(this.initialize.bind(this)); 10952 } 10953 10954 disconnectedCallback() { 10955 this.container.removeEventListener("keydown", this.#handleKeyDown.bind(this)); 10956 } 10957 10958 get toolbar() { 10959 return this.closest("lexxy-toolbar") 10960 } 10961 10962 get editorElement() { 10963 return this.toolbar.editorElement 10964 } 10965 10966 get editor() { 10967 return this.toolbar.editor 10968 } 10969 10970 initialize() { 10971 // Any post-editor initialization 10972 } 10973 10974 close() { 10975 this.editor.focus(); 10976 this.container.open = false;
10977 } 10978 10979 async #onToolbarEditor(callback) { 10980 await this.toolbar.editorConnected; 10981 callback(); 10982 } 10983 10984 #handleToggle() { 10985 if (this.container.open) { 10986 this.#handleOpen(); 10987 } 10988 } 10989 10990 async #handleOpen() { 10991 this.#interactiveElements[0].focus(); 10992 this.#resetTabIndexValues(); 10993 } 10994 10995 #handleKeyDown(event) { 10996 if (event.key === "Escape") { 10997 event.stopPropagation(); 10998 this.close(); 10999 } 11000 } 11001 11002 async #resetTabIndexValues() { 11003 await nextFrame(); 11004 this.#buttons.forEach((element, index) => { 11005 element.setAttribute("tabindex", index === 0 ? 0 : "-1"); 11006 }); 11007 } 11008 11009 get #interactiveElements() { 11010 return Array.from(this.querySelectorAll("button, input")) 11011 } 11012 11013 get #buttons() { 11014 return Array.from(this.querySelectorAll("button")) 11015 } 11016} 11017 11018class LinkDropdown extends ToolbarDropdown { 11019 connectedCallback() { 11020 super.connectedCallback(); 11021 this.input = this.querySelector("input"); 11022 11023 this.#registerHandlers(); 11024 } 11025 11026 #registerHandlers() { 11027 this.container.addEventListener("toggle", this.#handleToggle.bind(this)); 11028 this.addEventListener("submit", this.#handleSubmit.bind(this)); 11029 this.querySelector("[value='unlink']").addEventListener("click", this.#handleUnlink.bind(this)); 11030 } 11031 11032 #handleToggle({ newState }) { 11033 this.input.value = this.#selectedLinkUrl; 11034 this.input.required = newState === "open"; 11035 } 11036 11037 #handleSubmit(event) { 11038 const command = event.submitter?.value; 11039 this.editor.dispatchCommand(command, this.input.value); 11040 this.close(); 11041 } 11042 11043 #handleUnlink() { 11044 this.editor.dispatchCommand("unlink"); 11045 this.close(); 11046 } 11047 11048 get #selectedLinkUrl() { 11049 let url = ""; 11050 11051 this.editor.getEditorState().read(() => { 11052 const selection = Lr(); 11053 if (!yr(selection)) return 11054 11055 let node = selection.getNodes()[0]; 11056 while (node && node.getParent()) { 11057 if (w$3(node)) { 11058 url = node.getURL(); 11059 break 11060 } 11061 node = node.getParent(); 11062 } 11063 }); 11064 11065 return url 11066 } 11067} 11068 11069const APPLY_HIGHLIGHT_SELECTOR = "button.lexxy-highlight-button"; 11070const REMOVE_HIGHLIGHT_SELECTOR = "[data-command='removeHighlight']"; 11071 11072// Use Symbol instead of null since $getSelectionStyleValueForProperty 11073// responds differently for backward selections if null is the default 11074// see https://github.com/facebook/lexical/issues/8013 11075const NO_STYLE = Symbol("no_style"); 11076 11077class HighlightDropdown extends ToolbarDropdown { 11078 connectedCallback() { 11079 super.connectedCallback(); 11080 this.#registerToggleHandler(); 11081 } 11082 11083 initialize() { 11084 this.#setUpButtons(); 11085 this.#registerButtonHandlers(); 11086 } 11087 11088 #registerToggleHandler() { 11089 this.container.addEventListener("toggle", this.#handleToggle.bind(this)); 11090 } 11091 11092 #registerButtonHandlers() { 11093 this.#colorButtons.forEach(button => button.addEventListener("click", this.#handleColorButtonClick.bind(this))); 11094 this.querySelector(REMOVE_HIGHLIGHT_SELECTOR).addEventListener("click", this.#handleRemoveHighlightClick.bind(this)); 11095 } 11096 11097 #setUpButtons() { 11098 const colorGroups = this.editorElement.config.get("highlight.buttons"); 11099 11100 this.#populateButtonGroup("color", colorGroups.color); 11101 this.#populateButtonGroup("background-color", colorGroups["background-color"]); 11102 11103 const maxNumberOfColors = Math.max(colorGroups.color.length, colorGroups["background-color"].length); 11104 this.style.setProperty("--max-colors", maxNumberOfColors); 11105 } 11106 11107 #populateButtonGroup(attribute, values) { 11108 values.forEach((value, index) => { 11109 this.#buttonContainer.appendChild(this.#createButton(attribute, value, index)); 11110 }); 11111 } 11112 11113 #createButton(attribute, value, index) { 11114 const button = document.createElement("button"); 11115 button.dataset.style = attribute; 11116 button.style.setProperty(attribute, value); 11117 button.dataset.value = value; 11118 button.classList.add("lexxy-editor__toolbar-button", "lexxy-highlight-button"); 11119 button.name = attribute + "-" + index; 11120 return button 11121 } 11122 11123 #handleToggle({ newState }) { 11124 if (newState === "open") { 11125 this.editor.getEditorState().read(() => { 11126 this.#updateColorButtonStates(Lr()); 11127 }); 11128 } 11129 } 11130 11131 #handleColorButtonClick(event) { 11132 event.preventDefault(); 11133 11134 const button = event.target.closest(APPLY_HIGHLIGHT_SELECTOR); 11135 if (!button) return 11136 11137 const attribute = button.dataset.style; 11138 const value = button.dataset.value; 11139 11140 this.editor.dispatchCommand("toggleHighlight", { [attribute]: value }); 11141 this.close(); 11142 } 11143 11144 #handleRemoveHighlightClick(event) { 11145 event.preventDefault(); 11146 11147 this.editor.dispatchCommand("removeHighlight"); 11148 this.close(); 11149 } 11150 11151 #updateColorButtonStates(selection) { 11152 if (!yr(selection)) { return } 11153 11154 // Use non-"" default, so "" indicates mixed highlighting 11155 const textColor = le$1(selection, "color", NO_STYLE); 11156 const backgroundColor = le$1(selection, "background-color", NO_STYLE); 11157 11158 this.#colorButtons.forEach(button => { 11159 const matchesSelection = button.dataset.value === textColor || button.dataset.value === backgroundColor; 11160 button.setAttribute("aria-pressed", matchesSelection); 11161 }); 11162 11163 const hasHighlight = textColor !== NO_STYLE || backgroundColor !== NO_STYLE; 11164 this.querySelector(REMOVE_HIGHLIGHT_SELECTOR).disabled = !hasHighlight; 11165 } 11166 11167 get #buttonContainer() { 11168 return this.querySelector(".lexxy-highlight-colors") 11169 } 11170 11171 get #colorButtons() { 11172 return Array.from(this.querySelectorAll(APPLY_HIGHLIGHT_SELECTOR)) 11173 } 11174} 11175 11176class BaseSource { 11177 // Template method to override 11178 async buildListItems(filter = "") { 11179 return Promise.resolve([]) 11180 } 11181 11182 // Template method to override 11183 promptItemFor(listItem) { 11184 return null 11185 } 11186 11187 // Protected 11188 11189 buildListItemElementFor(promptItemElement) { 11190 const template = promptItemElement.querySelector("template[type='menu']"); 11191 const fragment = template.content.cloneNode(true); 11192 const listItemElement = createElement("li", { role: "option", id: generateDomId("prompt-item"), tabindex: "0" }); 11193 listItemElement.classList.add("lexxy-prompt-menu__item"); 11194 listItemElement.appendChild(fragment); 11195 return listItemElement 11196 } 11197 11198 async loadPromptItemsFromUrl(url) { 11199 try { 11200 const response = await fetch(url); 11201 const html = await response.text(); 11202 const promptItems = parseHtml(html).querySelectorAll("lexxy-prompt-item"); 11203 return Promise.resolve(Array.from(promptItems)) 11204 } catch (error) { 11205 return Promise.reject(error) 11206 } 11207 } 11208} 11209
11210class LocalFilterSource extends BaseSource { 11211 async buildListItems(filter = "") { 11212 const promptItems = await this.fetchPromptItems(); 11213 return this.#buildListItemsFromPromptItems(promptItems, filter) 11214 } 11215 11216 // Template method to override 11217 async fetchPromptItems(filter) { 11218 return Promise.resolve([]) 11219 } 11220 11221 promptItemFor(listItem) { 11222 return this.promptItemByListItem.get(listItem) 11223 } 11224 11225 #buildListItemsFromPromptItems(promptItems, filter) { 11226 const listItems = []; 11227 this.promptItemByListItem = new WeakMap(); 11228 promptItems.forEach((promptItem) => { 11229 const searchableText = promptItem.getAttribute("search"); 11230 11231 if (!filter || filterMatches(searchableText, filter)) { 11232 const listItem = this.buildListItemElementFor(promptItem); 11233 this.promptItemByListItem.set(listItem, promptItem); 11234 listItems.push(listItem); 11235 } 11236 }); 11237 11238 return listItems 11239 } 11240} 11241 11242class InlinePromptSource extends LocalFilterSource { 11243 constructor(inlinePromptItems) { 11244 super(); 11245 this.inlinePromptItemElements = Array.from(inlinePromptItems); 11246 } 11247 11248 async fetchPromptItems() { 11249 return Promise.resolve(this.inlinePromptItemElements) 11250 } 11251} 11252 11253class DeferredPromptSource extends LocalFilterSource { 11254 constructor(url) { 11255 super(); 11256 this.url = url; 11257 11258 this.fetchPromptItems(); 11259 } 11260 11261 async fetchPromptItems() { 11262 this.promptItems ??= await this.loadPromptItemsFromUrl(this.url); 11263 11264 return Promise.resolve(this.promptItems) 11265 } 11266} 11267 11268const DEBOUNCE_INTERVAL = 200; 11269 11270class RemoteFilterSource extends BaseSource { 11271 constructor(url) { 11272 super(); 11273 11274 this.baseURL = url; 11275 this.loadAndFilterListItems = debounceAsync(this.fetchFilteredListItems.bind(this), DEBOUNCE_INTERVAL); 11276 } 11277 11278 async buildListItems(filter = "") { 11279 return await this.loadAndFilterListItems(filter) 11280 } 11281 11282 promptItemFor(listItem) { 11283 return this.promptItemByListItem.get(listItem) 11284 } 11285 11286 async fetchFilteredListItems(filter) { 11287 const promptItems = await this.loadPromptItemsFromUrl(this.#urlFor(filter)); 11288 return this.#buildListItemsFromPromptItems(promptItems) 11289 } 11290 11291 #urlFor(filter) { 11292 const url = new URL(this.baseURL, window.location.origin); 11293 url.searchParams.append("filter", filter); 11294 return url.toString() 11295 } 11296 11297 #buildListItemsFromPromptItems(promptItems) { 11298 const listItems = []; 11299 this.promptItemByListItem = new WeakMap(); 11300 11301 for (const promptItem of promptItems) { 11302 const listItem = this.buildListItemElementFor(promptItem); 11303 this.promptItemByListItem.set(listItem, promptItem); 11304 listItems.push(listItem); 11305 } 11306 11307 return listItems 11308 } 11309} 11310 11311const NOTHING_FOUND_DEFAULT_MESSAGE = "Nothing found"; 11312 11313class LexicalPromptElement extends HTMLElement { 11314 constructor() { 11315 super(); 11316 this.keyListeners = []; 11317 } 11318 11319 static observedAttributes = [ "connected" ] 11320 11321 connectedCallback() { 11322 this.source = this.#createSource(); 11323 11324 this.#addTriggerListener(); 11325 this.toggleAttribute("connected", true); 11326 } 11327 11328 disconnectedCallback() { 11329 this.source = null; 11330 this.popoverElement = null; 11331 } 11332 11333 11334 attributeChangedCallback(name, oldValue, newValue) { 11335 if (name === "connected" && this.isConnected && oldValue != null && oldValue !== newValue) { 11336 requestAnimationFrame(() => this.#reconnect()); 11337 } 11338 } 11339 11340 get name() { 11341 return this.getAttribute("name") 11342 } 11343 11344 get trigger() { 11345 return this.getAttribute("trigger") 11346 } 11347 11348 get supportsSpaceInSearches() { 11349 return this.hasAttribute("supports-space-in-searches") 11350 } 11351 11352 get open() { 11353 return this.popoverElement?.classList?.contains("lexxy-prompt-menu--visible") 11354 } 11355 11356 get closed() { 11357 return !this.open 11358 } 11359 11360 get #doesSpaceSelect() { 11361 return !this.supportsSpaceInSearches 11362 } 11363 11364 #createSource() { 11365 const src = this.getAttribute("src"); 11366 if (src) { 11367 if (this.hasAttribute("remote-filtering")) { 11368 return new RemoteFilterSource(src) 11369 } else { 11370 return new DeferredPromptSource(src) 11371 } 11372 } else { 11373 return new InlinePromptSource(this.querySelectorAll("lexxy-prompt-item")) 11374 } 11375 } 11376 11377 #addTriggerListener() { 11378 const unregister = this.#editor.registerUpdateListener(({ editorState }) => { 11379 editorState.read(() => { 11380 const { node, offset } = this.#selection.selectedNodeWithOffset(); 11381 if (!node) return 11382 11383 if (lr(node)) { 11384 const fullText = node.getTextContent(); 11385 const triggerLength = this.trigger.length; 11386 11387 // Check if we have enough characters for the trigger 11388 if (offset >= triggerLength) { 11389 const textBeforeCursor = fullText.slice(offset - triggerLength, offset); 11390 11391 // Check if trigger is at the start of the text node (new line case) or preceded by space or newline 11392 if (textBeforeCursor === this.trigger) { 11393 const isAtStart = offset === triggerLength; 11394 11395 const charBeforeTrigger = offset > triggerLength ? fullText[offset - triggerLength - 1] : null; 11396 const isPrecededBySpaceOrNewline = charBeforeTrigger === " " || charBeforeTrigger === "\n"; 11397 11398 if (isAtStart || isPrecededBySpaceOrNewline) { 11399 unregister(); 11400 this.#showPopover(); 11401 } 11402 } 11403 } 11404 } 11405 }); 11406 }); 11407 } 11408 11409 #addCursorPositionListener() { 11410 this.cursorPositionListener = this.#editor.registerUpdateListener(() => { 11411 if (this.closed) return 11412 11413 this.#editor.read(() => { 11414 const { node, offset } = this.#selection.selectedNodeWithOffset(); 11415 if (!node) return 11416 11417 if (lr(node) && offset > 0) { 11418 const fullText = node.getTextContent(); 11419 const textBeforeCursor = fullText.slice(0, offset); 11420 const lastTriggerIndex = textBeforeCursor.lastIndexOf(this.trigger); 11421 const triggerEndIndex = lastTriggerIndex + this.trigger.length - 1; 11422 11423 // If trigger is not found, or cursor is at or before the trigger end position, hide popover 11424 if (lastTriggerIndex === -1 || offset <= triggerEndIndex) { 11425 this.#hidePopover(); 11426 } 11427 } else { 11428 // Cursor is not in a text node or at offset 0, hide popover 11429 this.#hidePopover(); 11430 } 11431 }); 11432 }); 11433 } 11434 11435 #removeCursorPositionListener() { 11436 if (this.cursorPositionListener) { 11437 this.cursorPositionListener(); 11438 this.cursorPositionListener = null; 11439 } 11440 } 11441 11442 get #editor() { 11443 return this.#editorElement.editor 11444 } 11445 11446 get #editorElement() { 11447 return this.closest("lexxy-editor") 11448 } 11449 11450 get #selection() { 11451 return this.#editorElement.selection 11452 } 11453 11454 async #showPopover() { 11455 this.popoverElement ??= await this.#buildPopover(); 11456 this.#resetPopoverPosition(); 11457 await this.#filterOptions(); 11458 this.popoverElement.classList.toggle("lexxy-prompt-menu--visible", true); 11459 this.#selectFirstOption(); 11460 11461 this.#editorElement.addEventListener("keydown", this.#handleKeydownOnPopover); 11462 this.#editorElement.addEventListener("lexxy:change", this.#filterOptions); 11463 11464 this.#registerKeyListeners(); 11465 this.#addCursorPositionListener(); 11466 } 11467 11468 #registerKeyListeners() {
11469 // We can't use a regular keydown for Enter as Lexical handles it first 11470 this.keyListeners.push(this.#editor.registerCommand(Ne$2, this.#handleSelectedOption.bind(this), Bi)); 11471 this.keyListeners.push(this.#editor.registerCommand(Me$2, this.#handleSelectedOption.bind(this), Bi)); 11472 11473 if (this.#doesSpaceSelect) { 11474 this.keyListeners.push(this.#editor.registerCommand(be$1, this.#handleSelectedOption.bind(this), Bi)); 11475 } 11476 11477 // Register arrow keys with HIGH priority to prevent Lexical's selection handlers from running 11478 this.keyListeners.push(this.#editor.registerCommand(ke$2, this.#handleArrowUp.bind(this), Bi)); 11479 this.keyListeners.push(this.#editor.registerCommand(Te$2, this.#handleArrowDown.bind(this), Bi)); 11480 } 11481 11482 #handleArrowUp(event) { 11483 this.#moveSelectionUp(); 11484 event.preventDefault(); 11485 return true 11486 } 11487 11488 #handleArrowDown(event) { 11489 this.#moveSelectionDown(); 11490 event.preventDefault(); 11491 return true 11492 } 11493 11494 #selectFirstOption() { 11495 const firstOption = this.#listItemElements[0]; 11496 11497 if (firstOption) { 11498 this.#selectOption(firstOption); 11499 } 11500 } 11501 11502 get #listItemElements() { 11503 return Array.from(this.popoverElement.querySelectorAll(".lexxy-prompt-menu__item")) 11504 } 11505 11506 #selectOption(listItem) { 11507 this.#clearSelection(); 11508 listItem.toggleAttribute("aria-selected", true); 11509 listItem.scrollIntoView({ block: "nearest", behavior: "smooth" }); 11510 listItem.focus(); 11511 11512 // Preserve selection to prevent cursor jump 11513 this.#selection.preservingSelection(() => { 11514 this.#editorElement.focus(); 11515 }); 11516 11517 this.#editorContentElement.setAttribute("aria-controls", this.popoverElement.id); 11518 this.#editorContentElement.setAttribute("aria-activedescendant", listItem.id); 11519 this.#editorContentElement.setAttribute("aria-haspopup", "listbox"); 11520 } 11521 11522 #clearSelection() { 11523 this.#listItemElements.forEach((item) => { item.toggleAttribute("aria-selected", false); }); 11524 this.#editorContentElement.removeAttribute("aria-controls"); 11525 this.#editorContentElement.removeAttribute("aria-activedescendant"); 11526 this.#editorContentElement.removeAttribute("aria-haspopup"); 11527 } 11528 11529 #positionPopover() { 11530 const { x, y, fontSize } = this.#selection.cursorPosition; 11531 const editorRect = this.#editorElement.getBoundingClientRect(); 11532 const contentRect = this.#editorContentElement.getBoundingClientRect(); 11533 const verticalOffset = contentRect.top - editorRect.top; 11534 11535 if (!this.popoverElement.hasAttribute("data-anchored")) { 11536 this.popoverElement.style.left = `${x}px`; 11537 this.popoverElement.toggleAttribute("data-anchored", true); 11538 } 11539 11540 this.popoverElement.style.top = `${y + verticalOffset}px`; 11541 this.popoverElement.style.bottom = "auto"; 11542 11543 const popoverRect = this.popoverElement.getBoundingClientRect(); 11544 const isClippedAtBottom = popoverRect.bottom > window.innerHeight; 11545 11546 if (isClippedAtBottom || this.popoverElement.hasAttribute("data-clipped-at-bottom")) { 11547 this.popoverElement.style.top = `${y + verticalOffset - popoverRect.height - fontSize}px`; 11548 this.popoverElement.style.bottom = "auto"; 11549 this.popoverElement.toggleAttribute("data-clipped-at-bottom", true); 11550 } 11551 } 11552 11553 #resetPopoverPosition() { 11554 this.popoverElement.removeAttribute("data-clipped-at-bottom"); 11555 this.popoverElement.removeAttribute("data-anchored"); 11556 } 11557 11558 async #hidePopover() { 11559 this.#clearSelection(); 11560 this.popoverElement.classList.toggle("lexxy-prompt-menu--visible", false); 11561 this.#editorElement.removeEventListener("lexxy:change", this.#filterOptions); 11562 this.#editorElement.removeEventListener("keydown", this.#handleKeydownOnPopover); 11563 11564 this.#unregisterKeyListeners(); 11565 this.#removeCursorPositionListener(); 11566 11567 await nextFrame(); 11568 this.#addTriggerListener(); 11569 } 11570 11571 #unregisterKeyListeners() { 11572 this.keyListeners.forEach((unregister) => unregister()); 11573 this.keyListeners = []; 11574 } 11575 11576 #filterOptions = async () => { 11577 if (this.initialPrompt) { 11578 this.initialPrompt = false; 11579 return 11580 } 11581 11582 if (this.#editorContents.containsTextBackUntil(this.trigger)) { 11583 await this.#showFilteredOptions(); 11584 await nextFrame(); 11585 this.#positionPopover(); 11586 } else { 11587 this.#hidePopover(); 11588 } 11589 } 11590 11591 async #showFilteredOptions() { 11592 const filter = this.#editorContents.textBackUntil(this.trigger); 11593 const filteredListItems = await this.source.buildListItems(filter); 11594 this.popoverElement.innerHTML = ""; 11595 11596 if (filteredListItems.length > 0) { 11597 this.#showResults(filteredListItems); 11598 } else { 11599 this.#showEmptyResults(); 11600 } 11601 this.#selectFirstOption(); 11602 } 11603 11604 #showResults(filteredListItems) { 11605 this.popoverElement.classList.remove("lexxy-prompt-menu--empty"); 11606 this.popoverElement.append(...filteredListItems); 11607 } 11608 11609 #showEmptyResults() { 11610 this.popoverElement.classList.add("lexxy-prompt-menu--empty"); 11611 const el = createElement("li", { innerHTML: this.#emptyResultsMessage }); 11612 el.classList.add("lexxy-prompt-menu__item--empty"); 11613 this.popoverElement.append(el); 11614 } 11615 11616 get #emptyResultsMessage() { 11617 return this.getAttribute("empty-results") || NOTHING_FOUND_DEFAULT_MESSAGE 11618 } 11619 11620 #handleKeydownOnPopover = (event) => { 11621 if (event.key === "Escape") { 11622 this.#hidePopover(); 11623 this.#editorElement.focus(); 11624 event.stopPropagation(); 11625 } 11626 // Arrow keys are now handled via Lexical commands with HIGH priority 11627 } 11628 11629 #moveSelectionDown() { 11630 const nextIndex = this.#selectedIndex + 1; 11631 if (nextIndex < this.#listItemElements.length) this.#selectOption(this.#listItemElements[nextIndex]); 11632 } 11633 11634 #moveSelectionUp() { 11635 const previousIndex = this.#selectedIndex - 1; 11636 if (previousIndex >= 0) this.#selectOption(this.#listItemElements[previousIndex]); 11637 } 11638 11639 get #selectedIndex() { 11640 return this.#listItemElements.findIndex((item) => item.hasAttribute("aria-selected")) 11641 } 11642 11643 get #selectedListItem() { 11644 return this.#listItemElements[this.#selectedIndex] 11645 } 11646 11647 #handleSelectedOption(event) { 11648 event.preventDefault(); 11649 event.stopPropagation(); 11650 this.#optionWasSelected(); 11651 return true 11652 } 11653 11654 #optionWasSelected() { 11655 this.#replaceTriggerWithSelectedItem(); 11656 this.#hidePopover(); 11657 this.#editorElement.focus(); 11658 } 11659 11660 #replaceTriggerWithSelectedItem() { 11661 const promptItem = this.source.promptItemFor(this.#selectedListItem); 11662 11663 if (!promptItem) { return } 11664 11665 const templates = Array.from(promptItem.querySelectorAll("template[type='editor']")); 11666 const stringToReplace = `${this.trigger}${this.#editorContents.textBackUntil(this.trigger)}`; 11667 11668 if (this.hasAttribute("insert-editable-text")) { 11669 this.#insertTemplatesAsEditableText(templates, stringToReplace); 11670 } else { 11671 this.#insertTemplatesAsAttachments(templates, stringToReplace, promptItem.getAttribute("sgid")); 11672 } 11673 } 11674 11675 #insertTemplatesAsEditableText(templates, stringToReplace) { 11676 this.#editor.update(() => { 11677 const nodes = templates.flatMap(template => this.#buildEditableTextNodes(template)); 11678 this.#editorContents.replaceTextBackUntil(stringToReplace, nodes); 11679 }); 11680 } 11681 11682 #buildEditableTextNodes(template) { 11683 return m$1(this.#editor, parseHtml(`${template.innerHTML}`)) 11684 } 11685 11686 #insertTemplatesAsAttachments(templates, stringToReplace, fallbackSgid = null) { 11687 this.#editor.update(() => { 11688 const attachmentNodes = this.#buildAttachmentNodes(templates, fallbackSgid); 11689 const spacedAttachmentNodes = attachmentNodes.flatMap(node => [ node, this.#getSpacerTextNode() ]).slice(0, -1); 11690 this.#editorContents.replaceTextBackUntil(stringToReplace, spacedAttachmentNodes); 11691 }); 11692 } 11693 11694 #buildAttachmentNodes(templates, fallbackSgid = null) { 11695 return templates.map( 11696 template => this.#buildAttachmentNode( 11697 template.innerHTML, 11698 template.getAttribute("content-type") || this.#defaultPromptContentType, 11699 template.getAttribute("sgid") || fallbackSgid 11700 )) 11701 } 11702 11703 #getSpacerTextNode() { 11704 return sr(" ") 11705 } 11706 11707 get #defaultPromptContentType() { 11708 const attachmentContentTypeNamespace = Lexxy.global.get("attachmentContentTypeNamespace"); 11709 return `application/vnd.${attachmentContentTypeNamespace}.${this.name}` 11710 } 11711 11712 #buildAttachmentNode(innerHtml, contentType, sgid) { 11713 return new CustomActionTextAttachmentNode({ sgid, contentType, innerHtml }) 11714 } 11715 11716 get #editorContents() { 11717 return this.#editorElement.contents 11718 } 11719 11720 get #editorContentElement() { 11721 return this.#editorElement.editorContentElement 11722 } 11723 11724 async #buildPopover() { 11725 const popoverContainer = createElement("ul", { role: "listbox", id: generateDomId("prompt-popover") }); // Avoiding [popover] due to not being able to position at an arbitrary X, Y position. 11726 popoverContainer.classList.add("lexxy-prompt-menu"); 11727 popoverContainer.style.position = "absolute"; 11728 popoverContainer.setAttribute("nonce", getNonce()); 11729 popoverContainer.append(...await this.source.buildListItems()); 11730 popoverContainer.addEventListener("click", this.#handlePopoverClick);
11731 this.#editorElement.appendChild(popoverContainer); 11732 return popoverContainer 11733 } 11734 11735 #handlePopoverClick = (event) => { 11736 const listItem = event.target.closest(".lexxy-prompt-menu__item"); 11737 if (listItem) { 11738 this.#selectOption(listItem); 11739 this.#optionWasSelected(); 11740 } 11741 } 11742 11743 #reconnect() { 11744 this.disconnectedCallback(); 11745 this.connectedCallback(); 11746 } 11747} 11748 11749class CodeLanguagePicker extends HTMLElement { 11750 connectedCallback() { 11751 this.editorElement = this.closest("lexxy-editor"); 11752 this.editor = this.editorElement.editor; 11753 11754 this.#attachLanguagePicker(); 11755 this.#monitorForCodeBlockSelection(); 11756 } 11757 11758 #attachLanguagePicker() { 11759 this.languagePickerElement = this.#createLanguagePicker(); 11760 11761 this.languagePickerElement.addEventListener("change", () => { 11762 this.#updateCodeBlockLanguage(this.languagePickerElement.value); 11763 }); 11764 11765 this.languagePickerElement.setAttribute("nonce", getNonce()); 11766 this.appendChild(this.languagePickerElement); 11767 } 11768 11769 #createLanguagePicker() { 11770 const selectElement = createElement("select", { className: "lexxy-code-language-picker", "aria-label": "Pick a languageâ¦", name: "lexxy-code-language" }); 11771 11772 for (const [ value, label ] of Object.entries(this.#languages)) { 11773 const option = document.createElement("option"); 11774 option.value = value; 11775 option.textContent = label; 11776 selectElement.appendChild(option); 11777 } 11778 11779 return selectElement 11780 } 11781 11782 get #languages() { 11783 const languages = { ...pt$1 }; 11784 11785 if (!languages.ruby) languages.ruby = "Ruby"; 11786 if (!languages.php) languages.php = "PHP"; 11787 if (!languages.go) languages.go = "Go"; 11788 if (!languages.bash) languages.bash = "Bash"; 11789 if (!languages.json) languages.json = "JSON"; 11790 if (!languages.diff) languages.diff = "Diff"; 11791 11792 const sortedEntries = Object.entries(languages) 11793 .sort(([ , a ], [ , b ]) => a.localeCompare(b)); 11794 11795 // Place the "plain" entry first, then the rest of language sorted alphabetically 11796 const plainIndex = sortedEntries.findIndex(([ key ]) => key === "plain"); 11797 const plainEntry = sortedEntries.splice(plainIndex, 1)[0]; 11798 return Object.fromEntries([ plainEntry, ...sortedEntries ]) 11799 } 11800 11801 #updateCodeBlockLanguage(language) { 11802 this.editor.update(() => { 11803 const codeNode = this.#getCurrentCodeNode(); 11804 11805 if (codeNode) { 11806 codeNode.setLanguage(language); 11807 } 11808 }); 11809 } 11810 11811 #monitorForCodeBlockSelection() { 11812 this.editor.registerUpdateListener(() => { 11813 this.editor.getEditorState().read(() => { 11814 const codeNode = this.#getCurrentCodeNode(); 11815 11816 if (codeNode) { 11817 this.#codeNodeWasSelected(codeNode); 11818 } else { 11819 this.#hideLanguagePicker(); 11820 } 11821 }); 11822 }); 11823 } 11824 11825 #getCurrentCodeNode() { 11826 const selection = Lr(); 11827 11828 if (!yr(selection)) { 11829 return null 11830 } 11831 11832 const anchorNode = selection.anchor.getNode(); 11833 const parentNode = anchorNode.getParent(); 11834 11835 if (X$1(anchorNode)) { 11836 return anchorNode 11837 } else if (X$1(parentNode)) { 11838 return parentNode 11839 } 11840 11841 return null 11842 } 11843 11844 #codeNodeWasSelected(codeNode) { 11845 const language = codeNode.getLanguage(); 11846 11847 this.#updateLanguagePickerWith(language); 11848 this.#showLanguagePicker(); 11849 this.#positionLanguagePicker(codeNode); 11850 } 11851 11852 #updateLanguagePickerWith(language) { 11853 if (this.languagePickerElement && language) { 11854 const normalizedLanguage = dt$1(language); 11855 this.languagePickerElement.value = normalizedLanguage; 11856 } 11857 } 11858 11859 #positionLanguagePicker(codeNode) { 11860 const codeElement = this.editor.getElementByKey(codeNode.getKey()); 11861 if (!codeElement) return 11862 11863 const codeRect = codeElement.getBoundingClientRect(); 11864 const editorRect = this.editorElement.getBoundingClientRect(); 11865 const relativeTop = codeRect.top - editorRect.top; 11866 const relativeRight = editorRect.right - codeRect.right; 11867 11868 this.style.top = `${relativeTop}px`; 11869 this.style.right = `${relativeRight}px`; 11870 } 11871 11872 #showLanguagePicker() { 11873 this.hidden = false; 11874 } 11875 11876 #hideLanguagePicker() { 11877 this.hidden = true; 11878 } 11879} 11880 11881class TableController { 11882 constructor(editorElement) { 11883 this.editor = editorElement.editor; 11884 this.contents = editorElement.contents; 11885 this.selection = editorElement.selection; 11886 11887 this.currentTableNodeKey = null; 11888 this.currentCellKey = null; 11889 11890 this.#registerKeyHandlers(); 11891 } 11892 11893 destroy() { 11894 this.currentTableNodeKey = null; 11895 this.currentCellKey = null; 11896 11897 this.#unregisterKeyHandlers(); 11898 } 11899
vendor: 6,913 bytes, lines 11900-12177
11900 get currentCell() { 11901 if (!this.currentCellKey) return null 11902 11903 return this.editor.getEditorState().read(() => { 11904 const cell = xo(this.currentCellKey); 11905 return (cell instanceof xe) ? cell : null 11906 }) 11907 } 11908 11909 get currentTableNode() { 11910 if (!this.currentTableNodeKey) return null 11911 11912 return this.editor.getEditorState().read(() => { 11913 const tableNode = xo(this.currentTableNodeKey); 11914 return (tableNode instanceof hn) ? tableNode : null 11915 }) 11916 } 11917 11918 get currentRowCells() { 11919 const currentRowIndex = this.currentRowIndex; 11920 11921 const rows = this.tableRows; 11922 if (!rows) return null 11923 11924 return this.editor.getEditorState().read(() => { 11925 return rows[currentRowIndex]?.getChildren() ?? null 11926 }) ?? null 11927 } 11928 11929 get currentRowIndex() { 11930 const currentCell = this.currentCell; 11931 if (!currentCell) return 0 11932 11933 return this.editor.getEditorState().read(() => { 11934 return Ie$1(currentCell) 11935 }) ?? 0 11936 } 11937 11938 get currentColumnCells() { 11939 const columnIndex = this.currentColumnIndex; 11940 11941 const rows = this.tableRows; 11942 if (!rows) return null 11943 11944 return this.editor.getEditorState().read(() => { 11945 return rows.map(row => row.getChildAtIndex(columnIndex)) 11946 }) ?? null 11947 } 11948 11949 get currentColumnIndex() { 11950 const currentCell = this.currentCell; 11951 if (!currentCell) return 0 11952 11953 return this.editor.getEditorState().read(() => { 11954 return Ue$1(currentCell) 11955 }) ?? 0 11956 } 11957 11958 get tableRows() { 11959 return this.editor.getEditorState().read(() => { 11960 return this.currentTableNode?.getChildren() 11961 }) ?? null 11962 } 11963 11964 updateSelectedTable() { 11965 let cellNode = null; 11966 let tableNode = null; 11967 11968 this.editor.getEditorState().read(() => { 11969 const selection = Lr(); 11970 if (!selection || !this.selection.isTableCellSelected) return 11971 11972 const node = selection.getNodes()[0]; 11973 11974 cellNode = Gt(node); 11975 tableNode = Qt(node); 11976 }); 11977 11978 this.currentCellKey = cellNode?.getKey() ?? null; 11979 this.currentTableNodeKey = tableNode?.getKey() ?? null; 11980 } 11981 11982 executeTableCommand(command, customIndex = null) { 11983 if (command.action === "delete" && command.childType === "table") { 11984 this.#deleteTable(); 11985 return 11986 } 11987 11988 if (command.action === "toggle") { 11989 this.#executeToggleStyle(command); 11990 return 11991 } 11992 11993 this.#executeCommand(command, customIndex); 11994 } 11995 11996 #executeCommand(command, customIndex = null) { 11997 this.#selectCellAtSelection(); 11998 this.editor.dispatchCommand(this.#commandName(command)); 11999 this.#selectNextBestCell(command, customIndex); 12000 } 12001 12002 #executeToggleStyle(command) { 12003 const childType = command.childType; 12004 12005 let cells = null; 12006 let headerState = null; 12007 12008 if (childType === "row") { 12009 cells = this.currentRowCells; 12010 headerState = ve$1.ROW; 12011 } else if (childType === "column") { 12012 cells = this.currentColumnCells; 12013 headerState = ve$1.COLUMN; 12014 } 12015 12016 if (!cells || cells.length === 0) return 12017 12018 this.editor.update(() => { 12019 const firstCell = Be$1(cells[0]); 12020 if (!firstCell) return 12021 12022 const currentStyle = firstCell.getHeaderStyles(); 12023 const newStyle = currentStyle ^ headerState; 12024 12025 cells.forEach(cell => { 12026 this.#setHeaderStyle(cell, newStyle, headerState); 12027 }); 12028 }); 12029 } 12030 12031 #deleteTable() { 12032 this.#selectCellAtSelection(); 12033 this.editor.dispatchCommand("deleteTable"); 12034 } 12035 12036 #selectCellAtSelection() { 12037 this.editor.update(() => { 12038 const selection = Lr(); 12039 if (!selection) return 12040 12041 const node = selection.getNodes()[0]; 12042 12043 Gt(node)?.selectEnd(); 12044 }); 12045 } 12046 12047 #commandName(command) { 12048 const { action, childType, direction } = command; 12049 12050 const childTypeSuffix = upcaseFirst(childType); 12051 const directionSuffix = action == "insert" ? upcaseFirst(direction) : ""; 12052 return `${action}Table${childTypeSuffix}${directionSuffix}` 12053 } 12054 12055 #setHeaderStyle(cell, newStyle, headerState) { 12056 const tableCellNode = Be$1(cell); 12057 tableCellNode?.setHeaderStyles(newStyle, headerState); 12058 } 12059 12060 async #selectCellAtIndex(rowIndex, columnIndex) { 12061 // We wait for next frame, otherwise table operations might not have completed yet. 12062 await nextFrame(); 12063 12064 if (!this.currentTableNode) return 12065 12066 const rows = this.tableRows; 12067 if (!rows) return 12068 12069 const row = rows[rowIndex]; 12070 if (!row) return 12071 12072 this.editor.update(() => { 12073 const cell = Be$1(row.getChildAtIndex(columnIndex)); 12074 cell?.selectEnd(); 12075 }); 12076 } 12077 12078 #selectNextBestCell(command, customIndex = null) { 12079 const { childType, direction } = command; 12080 12081 let rowIndex = this.currentRowIndex; 12082 let columnIndex = customIndex !== null ? customIndex : this.currentColumnIndex; 12083 12084 const deleteOffset = command.action === "delete" ? -1 : 0; 12085 const offset = direction === "after" ? 1 : deleteOffset; 12086 12087 if (childType === "row") { 12088 rowIndex += offset; 12089 } else if (childType === "column") { 12090 columnIndex += offset; 12091 } 12092 12093 this.#selectCellAtIndex(rowIndex, columnIndex); 12094 } 12095 12096 #selectNextRow() { 12097 const rows = this.tableRows; 12098 if (!rows) return 12099 12100 const nextRow = rows.at(this.currentRowIndex + 1); 12101 if (!nextRow) return 12102 12103 this.editor.update(() => { 12104 nextRow.getChildAtIndex(this.currentColumnIndex)?.selectEnd(); 12105 }); 12106 } 12107 12108 #selectPreviousCell() { 12109 const cell = this.currentCell; 12110 if (!cell) return 12111 12112 this.editor.update(() => { 12113 cell.selectPrevious(); 12114 }); 12115 } 12116 12117 #insertRowAndSelectFirstCell() { 12118 this.executeTableCommand({ action: "insert", childType: "row", direction: "after" }, 0); 12119 } 12120 12121 #deleteRowAndSelectLastCell() { 12122 this.executeTableCommand({ action: "delete", childType: "row" }, -1); 12123 } 12124 12125 #deleteRowAndSelectNextNode() { 12126 const tableNode = this.currentTableNode; 12127 this.executeTableCommand({ action: "delete", childType: "row" }); 12128 12129 this.editor.update(() => { 12130 const next = tableNode?.getNextSibling(); 12131 if (Ii(next)) { 12132 next.selectStart(); 12133 } else { 12134 const newParagraph = Li(); 12135 this.currentTableNode.insertAfter(newParagraph); 12136 newParagraph.selectStart(); 12137 } 12138 }); 12139 } 12140 12141 #isCurrentCellEmpty() { 12142 if (!this.currentTableNode) return false 12143 12144 const cell = this.currentCell; 12145 if (!cell) return false 12146 12147 return cell.getTextContent().trim() === "" 12148 } 12149 12150 #isCurrentRowLast() { 12151 if (!this.currentTableNode) return false 12152 12153 const rows = this.tableRows; 12154 if (!rows) return false 12155 12156 return rows.length === this.currentRowIndex + 1 12157 } 12158 12159 #isCurrentRowEmpty() { 12160 if (!this.currentTableNode) return false 12161 12162 const cells = this.currentRowCells; 12163 if (!cells) return false 12164 12165 return cells.every(cell => cell.getTextContent().trim() === "") 12166 } 12167 12168 #isFirstCellInRow() { 12169 if (!this.currentTableNode) return false 12170 12171 const cells = this.currentRowCells; 12172 if (!cells) return false 12173 12174 return cells.indexOf(this.currentCell) === 0 12175 } 12176 12177 #registerKeyHandlers() {
12178 // We can't prevent these externally using regular keydown because Lexical handles it first. 12179 this.unregisterBackspaceKeyHandler = this.editor.registerCommand(we$1, (event) => this.#handleBackspaceKey(event), Bi); 12180 this.unregisterEnterKeyHandler = this.editor.registerCommand(Ne$2, (event) => this.#handleEnterKey(event), Bi); 12181 } 12182 12183 #unregisterKeyHandlers() { 12184 this.unregisterBackspaceKeyHandler?.(); 12185 this.unregisterEnterKeyHandler?.(); 12186 12187 this.unregisterBackspaceKeyHandler = null; 12188 this.unregisterEnterKeyHandler = null; 12189 } 12190 12191 #handleBackspaceKey(event) { 12192 if (!this.currentTableNode) return false 12193 12194 if (this.#isCurrentRowEmpty() && this.#isFirstCellInRow()) { 12195 event.preventDefault(); 12196 this.#deleteRowAndSelectLastCell(); 12197 return true 12198 } 12199 12200 if (this.#isCurrentCellEmpty() && !this.#isFirstCellInRow()) { 12201 event.preventDefault(); 12202 this.#selectPreviousCell(); 12203 return true 12204 } 12205 12206 return false 12207 } 12208 12209 #handleEnterKey(event) { 12210 if ((event.ctrlKey || event.metaKey) || event.shiftKey || !this.currentTableNode) return false 12211 12212 if (this.selection.isInsideList || this.selection.isInsideCodeBlock) return false 12213 12214 event.preventDefault(); 12215 12216 if (this.#isCurrentRowLast() && this.#isCurrentRowEmpty()) { 12217 this.#deleteRowAndSelectNextNode(); 12218 } else if (this.#isCurrentRowLast()) { 12219 this.#insertRowAndSelectFirstCell(); 12220 } else { 12221 this.#selectNextRow(); 12222 } 12223 12224 return true 12225 } 12226} 12227 12228var TableIcons = { 12229 "insert-row-before": 12230 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12231 <path fill-rule="evenodd" clip-rule="evenodd" d="M7.86804e-07 15C8.29055e-07 15.8284 0.671574 16.5 1.5 16.5H15L15.1533 16.4922C15.8593 16.4205 16.4205 15.8593 16.4922 15.1533L16.5 15V4.5L16.4922 4.34668C16.4154 3.59028 15.7767 3 15 3H13.5L13.5 4.5H15V9H1.5L1.5 4.5L3 4.5V3H1.5C0.671574 3 1.20956e-06 3.67157 1.24577e-06 4.5L7.86804e-07 15ZM15 10.5V15H1.5L1.5 10.5H15Z"/> 12232 <path d="M4.5 4.5H7.5V7.5H9V4.5H12L12 3L9 3V6.55671e-08L7.5 0V3L4.5 3V4.5Z"/> 12233 </svg>`, 12234 12235 "insert-row-after": 12236 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12237 <path fill-rule="evenodd" clip-rule="evenodd" d="M7.86804e-07 13.5C7.50592e-07 14.3284 0.671574 15 1.5 15H3V13.5H1.5L1.5 9L15 9V13.5H13.5V15H15C15.7767 15 16.4154 14.4097 16.4922 13.6533L16.5 13.5V3L16.4922 2.84668C16.4205 2.14069 15.8593 1.57949 15.1533 1.50781L15 1.5L1.5 1.5C0.671574 1.5 1.28803e-06 2.17157 1.24577e-06 3L7.86804e-07 13.5ZM15 3V7.5L1.5 7.5L1.5 3L15 3Z"/> 12238 <path d="M7.5 15V18H9V15H12V13.5H9V10.5H7.5V13.5H4.5V15H7.5Z"/> 12239 </svg>`, 12240 12241 "delete-row": 12242 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12243 <path d="M16.4922 12.1533C16.4154 12.9097 15.7767 13.5 15 13.5L12 13.5V12H15V6L1.5 6L1.5 12H4.5V13.5H1.5C0.723337 13.5 0.0846104 12.9097 0.00781328 12.1533L7.86804e-07 12L1.04907e-06 6C1.17362e-06 5.22334 0.590278 4.58461 1.34668 4.50781L1.5 4.5L15 4.5C15.8284 4.5 16.5 5.17157 16.5 6V12L16.4922 12.1533Z"/> 12244 <path d="M10.3711 15.9316L8.25 13.8096L6.12793 15.9316L5.06738 14.8711L7.18945 12.75L5.06738 10.6289L6.12793 9.56836L8.25 11.6895L10.3711 9.56836L11.4316 10.6289L9.31055 12.75L11.4316 14.8711L10.3711 15.9316Z"/> 12245 </svg>`, 12246 12247 "toggle-row": 12248 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12249 <path fill-rule="evenodd" clip-rule="evenodd" d="M0.00781328 13.6533C0.0846108 14.4097 0.723337 15 1.5 15L15 15L15.1533 14.9922C15.8593 14.9205 16.4205 14.3593 16.4922 13.6533L16.5 13.5V4.5L16.4922 4.34668C16.4205 3.64069 15.8593 3.07949 15.1533 3.00781L15 3L1.5 3C0.671574 3 1.24863e-06 3.67157 1.18021e-06 4.5L7.86804e-07 13.5L0.00781328 13.6533ZM15 9V13.5L1.5 13.5L1.5 9L15 9Z"/> 12250 </svg>`, 12251 12252 "insert-column-before": 12253 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12254 <path fill-rule="evenodd" clip-rule="evenodd" d="M4.5 0C3.67157 0 3 0.671573 3 1.5V3H4.5V1.5H9V15H4.5V13.5H3V15C3 15.7767 3.59028 16.4154 4.34668 16.4922L4.5 16.5H15L15.1533 16.4922C15.8593 16.4205 16.4205 15.8593 16.4922 15.1533L16.5 15V1.5C16.5 0.671573 15.8284 6.03989e-09 15 0H4.5ZM15 15H10.5V1.5H15V15Z"/> 12255 <path d="M3 7.5H0V9H3V12H4.5V9H7.5V7.5H4.5V4.5H3V7.5Z"/> 12256 </svg>`, 12257 12258 "insert-column-after": 12259 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12260 <path fill-rule="evenodd" clip-rule="evenodd" d="M13.5 0C14.3284 0 15 0.671573 15 1.5V3H13.5V1.5H9V15H13.5V13.5H15V15C15 15.7767 14.4097 16.4154 13.6533 16.4922L13.5 16.5H3L2.84668 16.4922C2.14069 16.4205 1.57949 15.8593 1.50781 15.1533L1.5 15V1.5C1.5 0.671573 2.17157 6.03989e-09 3 0H13.5ZM3
1226015H7.5V1.5H3V15Z"/> 12261 <path d="M15 7.5H18V9H15V12H13.5V9H10.5V7.5H13.5V4.5H15V7.5Z"/> 12262 </svg>`, 12263 12264 "delete-column": 12265 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12266 <path d="M12.1533 0.0078125C12.9097 0.0846097 13.5 0.723336 13.5 1.5V4.5H12V1.5H6V15H12V12H13.5V15C13.5 15.7767 12.9097 16.4154 12.1533 16.4922L12 16.5H6C5.22334 16.5 4.58461 15.9097 4.50781 15.1533L4.5 15V1.5C4.5 0.671573 5.17157 2.41596e-08 6 0H12L12.1533 0.0078125Z"/> 12267 <path d="M15.9316 6.12891L13.8105 8.24902L15.9326 10.3711L14.8711 11.4316L12.75 9.31055L10.6289 11.4316L9.56738 10.3711L11.6885 8.24902L9.56836 6.12891L10.6289 5.06836L12.75 7.18848L14.8711 5.06836L15.9316 6.12891Z"/> 12268 </svg>`, 12269 12270 "toggle-column": 12271 `<svg viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg"> 12272 <path fill-rule="evenodd" clip-rule="evenodd" d="M13.6533 17.9922C14.4097 17.9154 15 17.2767 15 16.5L15 3L14.9922 2.84668C14.9205 2.14069 14.3593 1.57949 13.6533 1.50781L13.5 1.5L4.5 1.5L4.34668 1.50781C3.59028 1.58461 3 2.22334 3 3L3 16.5C3 17.2767 3.59028 17.9154 4.34668 17.9922L4.5 18L13.5 18L13.6533 17.9922ZM9 3L13.5 3L13.5 16.5L9 16.5L9 3Z" /> 12273 </svg>`, 12274 12275 "delete-table": 12276 `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"> 12277 <path d="M18.2129 19.2305C18.0925 20.7933 16.7892 22 15.2217 22H7.77832C6.21084 22 4.90753 20.7933 4.78711 19.2305L4 9H19L18.2129 19.2305Z"/><path d="M13 2C14.1046 2 15 2.89543 15 4H19C19.5523 4 20 4.44772 20 5V6C20 6.55228 19.5523 7 19 7H4C3.44772 7 3 6.55228 3 6V5C3 4.44772 3.44772 4 4 4H8C8 2.89543 8.89543 2 10 2H13Z"/> 12278 </svg>` 12279}; 12280 12281class TableTools extends HTMLElement { 12282 connectedCallback() { 12283 this.tableController = new TableController(this.#editorElement); 12284 12285 this.#setUpButtons(); 12286 this.#monitorForTableSelection(); 12287 this.#registerKeyboardShortcuts(); 12288 } 12289 12290 disconnectedCallback() { 12291 this.#unregisterKeyboardShortcuts(); 12292 12293 this.unregisterUpdateListener?.(); 12294 this.unregisterUpdateListener = null; 12295 12296 this.removeEventListener("keydown", this.#handleToolsKeydown); 12297 12298 this.tableController?.destroy(); 12299 this.tableController = null; 12300 } 12301 12302 get #editor() { 12303 return this.#editorElement.editor 12304 } 12305 12306 get #editorElement() { 12307 return this.closest("lexxy-editor") 12308 } 12309 12310 get #tableToolsButtons() { 12311 return Array.from(this.querySelectorAll("button, details > summary")) 12312 } 12313 12314 #setUpButtons() { 12315 this.appendChild(this.#createRowButtonsContainer()); 12316 this.appendChild(this.#createColumnButtonsContainer()); 12317 12318 this.appendChild(this.#createDeleteTableButton()); 12319 this.addEventListener("keydown", this.#handleToolsKeydown); 12320 } 12321 12322 #createButtonsContainer(childType, setCountProperty, moreMenu) { 12323 const container = createElement("div", { className: `lexxy-table-control lexxy-table-control--${childType}` }); 12324 12325 const plusButton = this.#createButton(`Add ${childType}`, { action: "insert", childType, direction: "after" }, "+"); 12326 const minusButton = this.#createButton(`Remove ${childType}`, { action: "delete", childType }, "â"); 12327 12328 const dropdown = createElement("details", { className: "lexxy-table-control__more-menu" }); 12329 dropdown.setAttribute("name", "lexxy-dropdown"); 12330 dropdown.tabIndex = -1; 12331 12332 const count = createElement("summary", {}, `_ ${childType}s`); 12333 setCountProperty(count); 12334 dropdown.appendChild(count); 12335 12336 dropdown.appendChild(moreMenu); 12337 12338 container.appendChild(minusButton); 12339 container.appendChild(dropdown); 12340 container.appendChild(plusButton); 12341 12342 return container 12343 } 12344 12345 #createRowButtonsContainer() { 12346 return this.#createButtonsContainer( 12347 "row", 12348 (count) => { this.rowCount = count; }, 12349 this.#createMoreMenuSection("row") 12350 ) 12351 } 12352 12353 #createColumnButtonsContainer() { 12354 return this.#createButtonsContainer( 12355 "column", 12356 (count) => { this.columnCount = count; }, 12357 this.#createMoreMenuSection("column") 12358 ) 12359 } 12360 12361 #createMoreMenuSection(childType) { 12362 const section = createElement("div", { className: "lexxy-table-control__more-menu-details" }); 12363 const addBeforeButton = this.#createButton(`Add ${childType} before`, { action: "insert", childType, direction: "before" }); 12364 const addAfterButton = this.#createButton(`Add ${childType} after`, { action: "insert", childType, direction: "after" }); 12365 const toggleStyleButton = this.#createButton(`Toggle ${childType} style`, { action: "toggle", childType }); 12366 const deleteButton = this.#createButton(`Remove ${childType}`, { action: "delete", childType }); 12367 12368 section.appendChild(addBeforeButton); 12369 section.appendChild(addAfterButton); 12370 section.appendChild(toggleStyleButton); 12371 section.appendChild(deleteButton); 12372 12373 return section 12374 } 12375 12376 #createDeleteTableButton() { 12377 const container = createElement("div", { className: "lexxy-table-control" }); 12378 12379 const deleteTableButton = this.#createButton("Delete this table?", { action: "delete", childType: "table" }); 12380 deleteTableButton.classList.add("lexxy-table-control__button--delete-table"); 12381 12382 container.appendChild(deleteTableButton); 12383 12384 this.deleteContainer = container; 12385 12386 return container 12387 } 12388 12389 #createButton(label, command = {}, icon = this.#icon(command)) { 12390 const button = createElement("button", { 12391 className: "lexxy-table-control__button", 12392 "aria-label": label, 12393 type: "button" 12394 }); 12395 button.tabIndex = -1; 12396 button.innerHTML = `${icon} <span>${label}</span>`;
12397 12398 button.dataset.action = command.action; 12399 button.dataset.childType = command.childType; 12400 button.dataset.direction = command.direction; 12401 12402 button.addEventListener("click", () => this.#executeTableCommand(command)); 12403 12404 button.addEventListener("mouseover", () => this.#handleCommandButtonHover()); 12405 button.addEventListener("focus", () => this.#handleCommandButtonHover()); 12406 button.addEventListener("mouseout", () => this.#handleCommandButtonHover()); 12407 12408 return button 12409 } 12410 12411 #registerKeyboardShortcuts() { 12412 this.unregisterKeyboardShortcuts = this.#editor.registerCommand(me$1, this.#handleAccessibilityShortcutKey, Bi); 12413 } 12414 12415 #unregisterKeyboardShortcuts() { 12416 this.unregisterKeyboardShortcuts?.(); 12417 this.unregisterKeyboardShortcuts = null; 12418 } 12419 12420 #handleAccessibilityShortcutKey = (event) => { 12421 if ((event.ctrlKey || event.metaKey) && event.shiftKey && event.key === "F10") { 12422 const firstButton = this.querySelector("button, [tabindex]:not([tabindex='-1'])"); 12423 firstButton?.focus(); 12424 } 12425 } 12426 12427 #handleToolsKeydown = (event) => { 12428 if (event.key === "Escape") { 12429 this.#handleEscapeKey(); 12430 } else { 12431 handleRollingTabIndex(this.#tableToolsButtons, event); 12432 } 12433 } 12434 12435 #handleEscapeKey() { 12436 const cell = this.tableController.currentCell; 12437 if (!cell) return 12438 12439 this.#editor.update(() => { 12440 cell.select(); 12441 this.#editor.focus(); 12442 }); 12443 12444 this.#update(); 12445 } 12446 12447 async #handleCommandButtonHover() { 12448 await nextFrame(); 12449 12450 this.#clearCellStyles(); 12451 12452 const activeElement = this.querySelector("button:hover, button:focus"); 12453 if (!activeElement) return 12454 12455 const command = { 12456 action: activeElement.dataset.action, 12457 childType: activeElement.dataset.childType, 12458 direction: activeElement.dataset.direction 12459 }; 12460 12461 let cellsToHighlight = null; 12462 12463 switch (command.childType) { 12464 case "row": 12465 cellsToHighlight = this.tableController.currentRowCells; 12466 break 12467 case "column": 12468 cellsToHighlight = this.tableController.currentColumnCells; 12469 break 12470 case "table": 12471 cellsToHighlight = this.tableController.tableRows; 12472 break 12473 } 12474 12475 if (!cellsToHighlight) return 12476 12477 cellsToHighlight.forEach(cell => { 12478 const cellElement = this.#editor.getElementByKey(cell.getKey()); 12479 if (!cellElement) return 12480 12481 cellElement.classList.toggle(theme.tableCellHighlight, true); 12482 Object.assign(cellElement.dataset, command); 12483 }); 12484 } 12485 12486 #monitorForTableSelection() { 12487 this.unregisterUpdateListener = this.#editor.registerUpdateListener(() => { 12488 this.tableController.updateSelectedTable(); 12489 12490 const tableNode = this.tableController.currentTableNode; 12491 if (tableNode) { 12492 this.#show(); 12493 } else { 12494 this.#hide(); 12495 } 12496 }); 12497 } 12498 12499 #executeTableCommand(command) { 12500 this.tableController.executeTableCommand(command); 12501 this.#update(); 12502 } 12503 12504 #show() { 12505 this.style.display = "flex"; 12506 this.#update(); 12507 } 12508 12509 #hide() { 12510 this.style.display = "none"; 12511 this.#clearCellStyles(); 12512 } 12513 12514 #update() { 12515 this.#updateButtonsPosition(); 12516 this.#updateRowColumnCount(); 12517 this.#closeMoreMenu(); 12518 this.#handleCommandButtonHover(); 12519 } 12520 12521 #closeMoreMenu() { 12522 this.querySelector("details[open]")?.removeAttribute("open"); 12523 } 12524 12525 #updateButtonsPosition() { 12526 const tableNode = this.tableController.currentTableNode; 12527 if (!tableNode) return 12528 12529 const tableElement = this.#editor.getElementByKey(tableNode.getKey()); 12530 if (!tableElement) return 12531 12532 const tableRect = tableElement.getBoundingClientRect(); 12533 const editorRect = this.#editorElement.getBoundingClientRect(); 12534 12535 const relativeTop = tableRect.top - editorRect.top; 12536 const relativeCenter = (tableRect.left + tableRect.right) / 2 - editorRect.left; 12537 this.style.top = `${relativeTop}px`; 12538 this.style.left = `${relativeCenter}px`; 12539 } 12540 12541 #updateRowColumnCount() { 12542 const tableNode = this.tableController.currentTableNode; 12543 if (!tableNode) return 12544 12545 const tableElement = dn(this.#editor, tableNode); 12546 if (!tableElement) return 12547 12548 const rowCount = tableElement.rows; 12549 const columnCount = tableElement.columns; 12550 12551 this.rowCount.textContent = `${rowCount} row${rowCount === 1 ? "" : "s"}`; 12552 this.columnCount.textContent = `${columnCount} column${columnCount === 1 ? "" : "s"}`; 12553 } 12554 12555 #setTableCellFocus() { 12556 const cell = this.tableController.currentCell; 12557 if (!cell) return 12558 12559 const cellElement = this.#editor.getElementByKey(cell.getKey()); 12560 if (!cellElement) return 12561 12562 cellElement.classList.add(theme.tableCellFocus); 12563 } 12564 12565 #clearCellStyles() { 12566 this.#editorElement.querySelectorAll(`.${theme.tableCellFocus}`)?.forEach(cell => { 12567 cell.classList.remove(theme.tableCellFocus); 12568 }); 12569 12570 this.#editorElement.querySelectorAll(`.${theme.tableCellHighlight}`)?.forEach(cell => { 12571 cell.classList.remove(theme.tableCellHighlight); 12572 cell.removeAttribute("data-action"); 12573 cell.removeAttribute("data-child-type"); 12574 cell.removeAttribute("data-direction"); 12575 }); 12576 12577 this.#setTableCellFocus(); 12578 } 12579 12580 #icon(command) { 12581 const { action, childType } = command; 12582 const direction = (action == "insert" ? command.direction : null);
12583 const iconId = [ action, childType, direction ].filter(Boolean).join("-"); 12584 return TableIcons[iconId] 12585 } 12586} 12587 12588function defineElements() { 12589 const elements = { 12590 "lexxy-toolbar": LexicalToolbarElement, 12591 "lexxy-editor": LexicalEditorElement, 12592 "lexxy-link-dropdown": LinkDropdown, 12593 "lexxy-highlight-dropdown": HighlightDropdown, 12594 "lexxy-prompt": LexicalPromptElement, 12595 "lexxy-code-language-picker": CodeLanguagePicker, 12596 "lexxy-table-tools": TableTools, 12597 }; 12598 12599 Object.entries(elements).forEach(([ name, element ]) => { 12600 customElements.define(name, element); 12601 }); 12602} 12603 12604function highlightCode() { 12605 const elements = document.querySelectorAll("pre[data-language]"); 12606 12607 elements.forEach(preElement => { 12608 highlightElement(preElement); 12609 }); 12610} 12611 12612function highlightElement(preElement) { 12613 const language = preElement.getAttribute("data-language"); 12614 let code = preElement.innerHTML.replace(/<br\s*\/?>/gi, "\n"); 12615 12616 const grammar = Prism$1.languages?.[language]; 12617 if (!grammar) return 12618 12619 // unescape HTML entities in the code block 12620 code = new DOMParser().parseFromString(code, "text/html").body.textContent || ""; 12621 12622 const highlightedHtml = Prism$1.highlight(code, grammar, language); 12623 const codeElement = createElement("code", { "data-language": language, innerHTML: highlightedHtml }); 12624 preElement.replaceWith(codeElement); 12625} 12626 12627const configure = Lexxy.configure; 12628 12629// Pushing elements definition to after the current call stack to allow global configuration to take place first 12630setTimeout(defineElements, 0); 12631 12632export { ActionTextAttachmentNode, ActionTextAttachmentUploadNode, CustomActionTextAttachmentNode, LexxyExtension as Extension, HorizontalDividerNode, configure, highlightCode as highlightAll, highlightCode }; 12633//# sourceMappingURL=/assets/lexxy-29dd3cbe.js.map
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.