wysio 0.0.1 → 0.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +241 -3
  4. package/dist/auto-init.d.ts +12 -0
  5. package/dist/auto-init.d.ts.map +1 -0
  6. package/dist/cdn-full.d.ts +3 -0
  7. package/dist/cdn-full.d.ts.map +1 -0
  8. package/dist/cdn.d.ts +2 -0
  9. package/dist/cdn.d.ts.map +1 -0
  10. package/dist/commands.d.ts +19 -0
  11. package/dist/commands.d.ts.map +1 -0
  12. package/dist/content.d.ts +31 -0
  13. package/dist/content.d.ts.map +1 -0
  14. package/dist/editor.d.ts +158 -0
  15. package/dist/editor.d.ts.map +1 -0
  16. package/dist/emitter.d.ts +9 -0
  17. package/dist/emitter.d.ts.map +1 -0
  18. package/dist/format-html.d.ts +7 -0
  19. package/dist/format-html.d.ts.map +1 -0
  20. package/dist/i18n.d.ts +16 -0
  21. package/dist/i18n.d.ts.map +1 -0
  22. package/dist/icons.d.ts +34 -0
  23. package/dist/icons.d.ts.map +1 -0
  24. package/dist/index.d.ts +17 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/locales/nl.d.ts +81 -0
  27. package/dist/locales/nl.d.ts.map +1 -0
  28. package/dist/markdown/index.d.ts +17 -0
  29. package/dist/markdown/index.d.ts.map +1 -0
  30. package/dist/markdown.js +179 -0
  31. package/dist/markdown.js.map +1 -0
  32. package/dist/messages.d.ts +83 -0
  33. package/dist/messages.d.ts.map +1 -0
  34. package/dist/plugin.d.ts +94 -0
  35. package/dist/plugin.d.ts.map +1 -0
  36. package/dist/plugins/alignment.d.ts +10 -0
  37. package/dist/plugins/alignment.d.ts.map +1 -0
  38. package/dist/plugins/base.d.ts +7 -0
  39. package/dist/plugins/base.d.ts.map +1 -0
  40. package/dist/plugins/blocks.d.ts +4 -0
  41. package/dist/plugins/blocks.d.ts.map +1 -0
  42. package/dist/plugins/clear-formatting.d.ts +10 -0
  43. package/dist/plugins/clear-formatting.d.ts.map +1 -0
  44. package/dist/plugins/color.d.ts +36 -0
  45. package/dist/plugins/color.d.ts.map +1 -0
  46. package/dist/plugins/heading.d.ts +3 -0
  47. package/dist/plugins/heading.d.ts.map +1 -0
  48. package/dist/plugins/history.d.ts +2 -0
  49. package/dist/plugins/history.d.ts.map +1 -0
  50. package/dist/plugins/image.d.ts +56 -0
  51. package/dist/plugins/image.d.ts.map +1 -0
  52. package/dist/plugins/index.d.ts +29 -0
  53. package/dist/plugins/index.d.ts.map +1 -0
  54. package/dist/plugins/link.d.ts +15 -0
  55. package/dist/plugins/link.d.ts.map +1 -0
  56. package/dist/plugins/lists.d.ts +2 -0
  57. package/dist/plugins/lists.d.ts.map +1 -0
  58. package/dist/plugins/marks.d.ts +7 -0
  59. package/dist/plugins/marks.d.ts.map +1 -0
  60. package/dist/plugins/paste.d.ts +9 -0
  61. package/dist/plugins/paste.d.ts.map +1 -0
  62. package/dist/plugins/placeholder.d.ts +3 -0
  63. package/dist/plugins/placeholder.d.ts.map +1 -0
  64. package/dist/plugins/source.d.ts +5 -0
  65. package/dist/plugins/source.d.ts.map +1 -0
  66. package/dist/plugins/table.d.ts +14 -0
  67. package/dist/plugins/table.d.ts.map +1 -0
  68. package/dist/registry-BfhH2s8N.js +19 -0
  69. package/dist/registry-BfhH2s8N.js.map +1 -0
  70. package/dist/registry.d.ts +10 -0
  71. package/dist/registry.d.ts.map +1 -0
  72. package/dist/schema.d.ts +5 -0
  73. package/dist/schema.d.ts.map +1 -0
  74. package/dist/style.css +824 -0
  75. package/dist/toolbar/toolbar.d.ts +56 -0
  76. package/dist/toolbar/toolbar.d.ts.map +1 -0
  77. package/dist/ui/menu.d.ts +20 -0
  78. package/dist/ui/menu.d.ts.map +1 -0
  79. package/dist/ui/popover.d.ts +29 -0
  80. package/dist/ui/popover.d.ts.map +1 -0
  81. package/dist/url.d.ts +23 -0
  82. package/dist/url.d.ts.map +1 -0
  83. package/dist/web-component.d.ts +21 -0
  84. package/dist/web-component.d.ts.map +1 -0
  85. package/dist/wysio.full.iife.js +72 -0
  86. package/dist/wysio.iife.js +49 -0
  87. package/dist/wysio.js +2668 -0
  88. package/dist/wysio.js.map +1 -0
  89. package/package.json +68 -6
  90. package/index.js +0 -1
@@ -0,0 +1,72 @@
1
+ var Wysio=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r=Object.setPrototypeOf({},null);for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n&1||t(r,Symbol.toStringTag,{value:`Module`}),n&2?r:Object.preventExtensions(r)},r={};function i(e){let t=r[e];if(t)return t;t=r[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);t.push(n)}for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t[r]=`%`+(`0`+r.toString(16).toUpperCase()).slice(-2)}return t}function a(e,t){typeof t!=`string`&&(t=a.defaultChars);let n=i(t);return e.replace(/(%[a-f0-9]{2})+/gi,function(e){let t=``;for(let r=0,i=e.length;r<i;r+=3){let a=parseInt(e.slice(r+1,r+3),16);if(a<128)t+=n[a];else{if((a&224)==192&&r+3<i){let n=parseInt(e.slice(r+4,r+6),16);if((n&192)==128){let e=a<<6&1984|n&63;t+=e<128?`��`:String.fromCharCode(e),r+=3;continue}}if((a&240)==224&&r+6<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16);if((n&192)==128&&(i&192)==128){let e=a<<12&61440|n<<6&4032|i&63;t+=e<2048||e>=55296&&e<=57343?`���`:String.fromCharCode(e),r+=6;continue}}if((a&248)==240&&r+9<i){let n=parseInt(e.slice(r+4,r+6),16),i=parseInt(e.slice(r+7,r+9),16),o=parseInt(e.slice(r+10,r+12),16);if((n&192)==128&&(i&192)==128&&(o&192)==128){let e=a<<18&1835008|n<<12&258048|i<<6&4032|o&63;e<65536||e>1114111?t+=`����`:(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(e&1023))),r+=9;continue}}t+=`�`}}return t})}a.defaultChars=`;/?:@&=+$,#`,a.componentChars=``;var o={};function s(e){let t=o[e];if(t)return t;t=o[e]=[];for(let e=0;e<128;e++){let n=String.fromCharCode(e);/^[0-9a-z]$/i.test(n)?t.push(n):t.push(`%`+(`0`+e.toString(16).toUpperCase()).slice(-2))}for(let n=0;n<e.length;n++)t[e.charCodeAt(n)]=e[n];return t}function c(e,t,n){typeof t!=`string`&&(n=t,t=c.defaultChars),n===void 0&&(n=!0);let r=s(t),i=``;for(let t=0,a=e.length;t<a;t++){let o=e.charCodeAt(t);if(n&&o===37&&t+2<a&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3)))i+=e.slice(t,t+3),t+=2;else if(o<128)i+=r[o];else if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<a){let n=e.charCodeAt(t+1);if(n>=56320&&n<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+=`%EF%BF%BD`}else i+=encodeURIComponent(e[t])}return i}c.defaultChars=`;/?:@&=+$,-_.!~*'()#`,c.componentChars=`-_.!~*'()`;function l(e){let t=``;return t+=e.protocol||``,t+=e.slashes?`//`:``,t+=e.auth?e.auth+`@`:``,e.hostname&&e.hostname.indexOf(`:`)!==-1?t+=`[`+e.hostname+`]`:t+=e.hostname||``,t+=e.port?`:`+e.port:``,t+=e.pathname||``,t+=e.search||``,t+=e.hash||``,t}function u(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}var d=/^([a-z0-9.+-]+:)/i,f=/:[0-9]*$/,p=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,m=[`%`,`/`,`?`,`;`,`#`,`'`,`{`,`}`,`|`,`\\`,`^`,"`",`<`,`>`,`"`,"`",` `,`\r`,`
2
+ `,` `],h=[`/`,`?`,`#`],g=255,_=/^[+a-z0-9A-Z_-]{0,63}$/,v=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},b={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function x(e,t){if(e&&e instanceof u)return e;let n=new u;return n.parse(e,t),n}u.prototype.parse=function(e,t){let n,r,i,a=e;if(a=a.trim(),!t&&e.split(`#`).length===1){let e=p.exec(a);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=d.exec(a);if(o&&(o=o[0],n=o.toLowerCase(),this.protocol=o,a=a.substr(o.length)),(t||o||a.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i=a.substr(0,2)===`//`,i&&!(o&&y[o])&&(a=a.substr(2),this.slashes=!0)),!y[o]&&(i||o&&!b[o])){let e=-1;for(let t=0;t<h.length;t++)r=a.indexOf(h[t]),r!==-1&&(e===-1||r<e)&&(e=r);let t,n;n=e===-1?a.lastIndexOf(`@`):a.lastIndexOf(`@`,e),n!==-1&&(t=a.slice(0,n),a=a.slice(n+1),this.auth=t),e=-1;for(let t=0;t<m.length;t++)r=a.indexOf(m[t]),r!==-1&&(e===-1||r<e)&&(e=r);e===-1&&(e=a.length),a[e-1]===`:`&&e--;let i=a.slice(0,e);a=a.slice(e),this.parseHost(i),this.hostname=this.hostname||``;let o=this.hostname[0]===`[`&&this.hostname[this.hostname.length-1]===`]`;if(!o){let e=this.hostname.split(/\./);for(let t=0,n=e.length;t<n;t++){let n=e[t];if(n&&!n.match(_)){let r=``;for(let e=0,t=n.length;e<t;e++)n.charCodeAt(e)>127?r+=`x`:r+=n[e];if(!r.match(_)){let r=e.slice(0,t),i=e.slice(t+1),o=n.match(v);o&&(r.push(o[1]),i.unshift(o[2])),i.length&&(a=i.join(`.`)+a),this.hostname=r.join(`.`);break}}}}this.hostname.length>g&&(this.hostname=``),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}let s=a.indexOf(`#`);s!==-1&&(this.hash=a.substr(s),a=a.slice(0,s));let c=a.indexOf(`?`);return c!==-1&&(this.search=a.substr(c),a=a.slice(0,c)),a&&(this.pathname=a),b[n]&&this.hostname&&!this.pathname&&(this.pathname=``),this},u.prototype.parseHost=function(e){let t=f.exec(e);t&&(t=t[0],t!==`:`&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var ee=n({decode:()=>a,encode:()=>c,format:()=>l,parse:()=>x}),te=n({Any:()=>ne,Cc:()=>re,Cf:()=>ie,P:()=>ae,S:()=>oe,Z:()=>se}),ne=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,re=/[\0-\x1F\x7F-\x9F]/,ie=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,ae=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B4E\u1B4F\u1B5A-\u1B60\u1B7D-\u1B7F\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDD6E\uDEAD\uDED0\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9\uDFD4\uDFD5\uDFD7\uDFD8]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09\uDFE1]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDD6D-\uDD6F\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD839\uDDFF|\uD83A[\uDD5E\uDD5F]/,oe=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C1\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2429\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E5\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBD2\uFD40-\uFD4F\uFD90\uFD91\uFDC8-\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD803[\uDD8E\uDD8F\uDED1-\uDED8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDC00-\uDCEF\uDCFA-\uDCFC\uDD00-\uDEB3\uDEBA-\uDED0\uDEE0-\uDEF0\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED8\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0-\uDCBB\uDCC0\uDCC1\uDCD0-\uDCD8\uDD00-\uDE57\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF-\uDEF8\uDF00-\uDF92\uDF94-\uDFEF\uDFFA]/,se=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,ce=[8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0,0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376];function le(e){return e===0||e>=55296&&e<=57343||e>1114111}function ue(e){return le(e)?65533:e>=128&&e<=159&&ce[e-128]||e}function de(e){return e-1>>>0<127||e-160>>>0<55136?String.fromCharCode(e):String.fromCodePoint(ue(e))}var fe=(()=>{let e=new Uint8Array(127),t=0;for(let n=33;n<=126;n++)n!==34&&n!==36&&n!==92&&(e[n]=t++);return e})();function pe(e,t,n,r,i,a){let o=e.length,s=a*90,c=0,l=()=>{let t=fe[e.charCodeAt(c++)];return t<a?t:t*91-s+fe[e.charCodeAt(c++)]},u=n-r,d=n+i,f=new Int32Array(d);f.fill(-1,r,a),f.fill(-1,a+u,d);let p=new Int32Array(d),m=new Int32Array(d);function h(t,n){let r=0,i=n,a=n+t;for(;i<a;){let t=fe[e.charCodeAt(c++)];if(t<89)r+=t,f[i++]=r;else if(t===89){let t=fe[e.charCodeAt(c++)]+2;for(;t--;)f[i++]=++r}else{let t=fe[e.charCodeAt(c++)];r+=89+(t<90?t*91+fe[e.charCodeAt(c++)]:fe[e.charCodeAt(c++)]*8281+fe[e.charCodeAt(c++)]*91+fe[e.charCodeAt(c++)]),f[i++]=r}}}h(r,0),h(u,a);let g=new Int32Array(i*2),_=0,v=0;function y(e,t){for(let n=0;n<e;n++){let e=t+n,r=l(),i=l();g[v*2]=r,g[v*2+1]=i,v+=1,p[e]=_;let a=(f[r]<0?m[r]:1)+(f[i]<0?m[i]:1);m[e]=a,_+=a}}y(i-a+r,a+u),y(a-r,r);let b=new Uint16Array(_),x=0;for(let e=0;e<v;e++)for(let t=0;t<2;t++){let n=g[e*2+t],r=f[n];if(r<0){let e=p[n],t=e+m[n];for(;e<t;)b[x++]=b[e++]}else b[x++]=r}let ee=new Uint16Array(t),te=0;for(;c<o;){let t=fe[e.charCodeAt(c++)];t>=a&&(t=t*91-s+fe[e.charCodeAt(c++)]);let n=f[t];if(n<0){let e=p[t],n=e+m[t];for(;e<n;)ee[te++]=b[e++]}else ee[te++]=n}return ee}var me=pe("!}.&u%}'&}*'~!6*)%&,~!J~!J~%L~y<~!R,~~%Lu~~#GD~~#|)1#%}^%}2%+#.##%##%}&%##%'#%##&%#%#'%#&#%#&#'#%%#&#%##%#)%''%&%#%#'%#%%#%%}%%%#%#&(23#%%#&-%0%('1#(##%#'##+%'*.:1}#%#6-+(%'%%#%%%}#L'2351&('%}&/N'(0(/*-%(%%}#'+&T%7.2}#&%&#%#36/5##%&%%#&#%%#))2%%##%&&'0~!#*+&'%1~!%).'3q?&%'1~!.##%6(~!+%%%(Gw'rT~!E#<nA%#jZ~!H%(~!42##~!*31&~!G%U~#)5~#`3~!J~!Z~%]~%Y~%C~!q~!u~#kz~%#~!6'~!D~!U~!?~#T~!c%~!G#'~%7|~!G~!J~!G&~#pb~(Df}#%}*&}#%##%##%##&#-}&'#'&%#.++}%mI,#,@&(}*%}*'%&##&#%##%}&0}#.},U},%}+%}&%}#%##&}B%(}(%}+%)})%##%#&}&%##%&}<%}>%#%&}*%}(%}9%}/%})%}*%}*%}?&}&%}3%}&*#%})%#%#)}#&#-#+*%E%%'%'#%}#*V##&##I}#&&##%&%#&&Qf%%))w/0+&%#(#.%-''''++++7}>%4'',##1,#%#&%##&#'##&#*#9)%&%}#*}%,#+P(%A&%#'&##wSD',9E00#y#@}(+}&%&>~!#~!X}#*}(&&}(&}(,%}%&#+&}#&}I%#%}%)#(},'%#*}4%%#%}(''}#/##(##),%-##%%)#&}(.}&%#&}%%}*&#%},&&}&%}#%*'#%})%}D&}&%}-&}6&#&}-,%}#%})-(~+`~,=?~I9'9%~!,#%})%})%}@%}?%}(~!?~#<~#pP~#BG~#=1#%K+~#?#~%;)~#A~#mF1~#A'~'X%'~#lR~#N~'N~#r~#m#-~#i'?%#'%~#B%##%,%#~#_%#0%~#]732~,w~2+#:&#%&'0%&>%}#>##F+)#%&&#(+_}4&}-%}(&}@&}O7Fdf0@+/v4}&WU##&/0#&'('B#%}.%}'+#%}#%%&#&%#%##+#&#)#6#'#.},%}c%},%#%##%&#&%#&~#>'*-.%##%##%}#%%}%'~#)D1}#%*&~#_%%'(~#S2%'.}#~#=##*'*-%}&'%'##&&~'E%.#&~#M4}%%##&'%#~#O1##%&#'+~#<B%##%%'%+~#;#@%}#&%#&&%#(~#H1}'%'##&&~#?A}&'~#D#%32}'&&&&~#[}'(#%}'~#;C})&}%%#%~#=&%,3}%'(#%%~#^'#&&)#%'~#Y%-~#d-%'~#^%%&#&&&}#~#b~2t*&'~&(~&@~0%~e~3}%*''0})&}+~!9##-}#%-hD*)1fC#%/&/fB#40~!+#)*4~!+~!K'&:~!/*7~!.#~!H~!L':~%x&~!H#~!*~%1~!I#~!+A~#p'~!F~~#-#~,,(~.Z~!V~%;'B'mq-W~!N~%I%#&&#&}#%},%%}'%}+X#%}#&}(%}'%}<%}#%}%%'}'%}:~![)9@~%>~#UA%-%##&~!C%~!-.9:~!1~!-^2/:a~!y,D*J#-5)/4~%23,~#G~!L1~!0X3`~!2+~!!0-~&E~!W~!o,>Y&]~%cZx_&~#O*9#A#'#+I'%#)~!0B*-5A+-((F&*M#)(-7-5+'-3a5Vi~!Y~!?+[)%3),ERHm~!+:D,VG.+)?fB%%*(%)'(#&80%1'8`K8?`+'Z#&O&'H5#*9)A%%5&3))0%39+.*7#()&&*=4@**L)<'_&*+..;(#*+)./&0#3)%')-8(4ixD(&.}%,('aI:,)%,k2231T)I'#/-W7,/'Q#.'Y24+h')37</31&83##&0#),H(?'&?/1##%#&&#%''-%&&&#(&''&#.-'%#%%(,')*'&#&#'##%(%(#%('#&##%%%%('%#%#%%#%#&%##h>w+v<ayvyvcg.uuhKr}g/v|g>u9i[~>g5uI~=RvdwEg;v/g;uk!!TTSx]@RT!U!#!@VBRUU!'UTe-d0c`e&gSdicedFcrdTaqb.kYcAohdYd@a3e+d}dMdtd.aJ#bqcK`dle/e.e'dwdPdodddjbEb}ogd^ofdpduc6j?l%d{drdqc)d7bacOdQ%T#Y)X.sR[yH>6Vyv3[xwLu>vo'!*.[yBacahoj>6Rew3[xqdZa#!a&#^(X-[yG>6Vyu3[xvg3sEr|g.u/Ri9db0T#^(Xa)!-[y;>6Vylg4wKs{JwNZt3@3r=c4Z([xlg;wKt!cpq's@v7A'*a(a+!-a#[y<3Dt?3Dt'>6Vym3[xmg9rxsNJwLZt4~?r?db1T#`-!(Xa,!0[yS>6Vz%NuQs.g4wKtnJwNZtS@3r>c4Z([y%g;wKtrdga8!a(!#&T*Y-Xa#!a0<or[yc3Dtq>6Vz43[y3JwNZtf@3s!Ju}!%Dti:pm3c_%X#tjB5pkd6q!r]u?voC'*-a.a2!0a&a+[yI3DtI3Ds~3DtH>6Vyw3[xx;:s#~<5pKJwNZtE@3r~d`a)!a2T#a.(!+U.X1[yT3Dt`3Dtv>6Vz&3[y&g9rxwzcxstPu.<rAJwLZtT~?r@dZa%!a.&^*Za(/Reu[ya>6Vz23[y1g3sEr}wkg{NuQRg{ci(U#5@b`~,cg#U(2WnH5wugcRh7dX#T(Y,a'Ta!!a,[yZ<]mj>6Vz,3[y+Pv#5ReZKu+=,%!H}7ABwkaS?Rh:BcW(X#<]mrj:ubv/ARekdg%!(!a.*Ta(Y.X1!#sP>Rl*Dt6[y>>6Vyo3Wf*jOvuumvuRgRJuq*!:9<B@bX~3jVv&v@s@5Re[d/rQt{uAvo&a&a*)a2!,0Wf!3Dt0=Bs'>6Re}3[xy~<5s%JwJZt1~Gs)c;&!#2sJkNuXvzq7rxu,Re8dka4!a8(aEZ+a@Y.X1Xa)[yd=Bs(3DtP>6Vz53[y4cX#X&Re:avRe9~<5s&JwJZtQ~Gs*i^rzvdRg+Jv{%!2sbB@bX}kdga,!Za?&^*T1/!a'Dt+[y6>6Vyf3Wf%g/u;s4hGu6?Rh-JvZ,!c%#&RoX54Rivj7uyvf8RgTKvZB%*!2sGh<vu5Rgq<=C::9bb~#dZ#T&Ta6Y.X*Dt>[y93Wf)coZ(T,6VyifluvRgC@95@B@bX~/hFu34cC#T,k/unq8w8Q5RkUklwQuzunq8w8Q5Rk8d/rJu?v8w9)-&!a0a;a&aIWejg3sEr/h1s<DtDJvyZqY5aws3Jvy!&Wei~Hr1:au5@Bag>23E~5c:Z&bX};kKv?w&unuVu5Rjc;>bs)#~@:Rh.=ay<a]C;b`}Vd6s/t{uAvoaxa()!a,a7%-a#a2Dt,[yF2Wo[>6Vyt3[xuNuPRi&NuPwpi#RoWh?vf8Ri%Jv]!%Ri:KvxD!.'2WeAjZu`q9rxu,Re7woeAg-unLq(qA_/*2Wg_g3u5q^9:4E}/jTrxrzv=Wkkd~0UX#^^Xa-a1a5T&a=U1a'*aEa]!a*aPaA-adok[y54Rn>;:p3~Dp5g9rpsFNvZqjg3uJp4~<5p0Pw;5qlJwNZt*@3p1Pw:5p/Ou!5p2JvG'!6Vye=<qnJvh_[xhg3v,Rh3kOwOw-sDuev/Re^dha[a%!%!a+#Ta7)-5TaCaO!aka!a)sf[yb2>Rl!9ARiq5E}Qg=ucRkBE|oJrJ_@Wk~@Wk{JrJ_@Wk|@WkyJrJ_@Wk}@WkzJvO_[y2g-vMRmiKuYC!)&>Ri;>Ri<@3RkNc](X#@9Rk=g5vuRmhKvDB!+'=]meg3u4Rmgd)#Y'Vz3CARmfd`a+!%T'!+#Ta1Ta6TaM-sTDt9[yA9sYd'%Y#s[[xpj:ueunaXRgEjRq,v-vuqdd2'`#6Rev<32@5>:2<E}5xIo9a*X#Y(;5RePJvD_g>vyRgNj8w)v8<wggs:RgXiZt|vjx,hSq3ah!-(~@:Ro/Ou!5RhWj^v(pyw8unRhUdx-UY#^Ua.a3a70!)%UX1TaDa)'omRiRRhE[y:3Dsz=Br,>6Vyj3[xkg6ruwjcqsrPw;5r*Ku]D'Zt-@3r(~?r.i[vwv]dU1a--U#`a4(g/vsRhPOu!5RhLj:rmu9Wo!~@:wdh@g/vsRiTjXuvvNr}:RhBj^v(pyw8unRn]dz1UYa'a+^Y(!aETZalaRY.Ta?a4[yDJw1!#qLsW>6Vyrfzq-pLflpwRe|Js>%!Dt@3Dt&Jvy_[xs~HrnjMuwpsw'RecKu+D#'!t<~Grl~?rjg5u-x,gwp{ah!-(~@:Rg~Ou!5Rh'jXuvvNr}:Rh#cW#X/c;&!#2sLi[v7u7RgpJv)(!iLrxu,Re6j7v@s@5Se[e7d`aW!Za(a`T.a#!a3!&aDa-!9)Dt_=6s+3[x~~DR|h~DS6avhGun5RkZj3w)v-]mkKunB!&*]kb97R|i<ARk<c:Z(6Vy}Juh'!wziMRoS:F|vkLuauJv5vtvQRh1d='T+Y#VyO~DR|jcF#T'7R|g97R|kJv3'!ay<Rj,Jvh&!:ReXcsa6*a+#a#_aIRf9aLRf?c,Z&Rf5Rf7c.Z&Rf;Rf>cQ#%T'p-Rf8Rf=ct#%'(*!,p,Rf4p+Rf6Rf:Rf<d~'Ua%U*^UYa(!a,-!#a4YaTalaEX0a8a<Weo3Dt/3Dsx=Br93Wen~Dr;~<5p<JwNZt2@3p=Pw:5p;Ou!5r3c7&!#:p>3Ds}KvGB)_6Vyk2sM=<r7x'eovA(!hFu1ARf}cV#X&@r5j6rvwQa^Rf3c=Za'wkghJv__g;unRggA53B9=b^}%j6uduo5Jq;!(hIv%2Re`Ou4ARe_e%a#^^^Xa&!a*a2!&a6YaP!*ad!#a:aE/5Rn?[y@>6Vyp;:pE~DrY~<5pBJwNZt8@3pCh=rt3rWPw:5pAJup_[xoNuPpF9c!#'45pD5ARn)d8#X'X*3@rU72s]h>v<<sSjJpqvewOJq/(!hNw'5ReBk0s2u3w/w'5ReE5@Jq.!a+JQ!&WeU23d(#Y&RjG5]jBk!u7w&u0udARjEe#+^^^Ub#!a2/a`Z(agT1!a-a;|@TaG!aS[yV=Re~fow'RguNuPRe?bz#'>RoUWeL>:Cbb|?JwPZtVg6ruRmzJvD'!6Vz(g/vmRh~Jvy_[y(g9voRgyx*cy(#2>Ri2B9b]~9kIw9u7rluJu3Rg]dI#a%UY'@=p%CAx.gQZ&RhwwygtRm{x5g_Z'+ABqR9Woa=Bp&dV#^*Xa'!&@o{g4v]Rk;Jv{!%Rk[wkkiA5RkiwwfUB=x,fUuqC&*!>RfTg8v0RfV~ARfSd;rJsAuAv9wR'ae+/aO!a@aza/a#[yQ@Wg!2Wemg3sEr0JvB_g>uvReWg2v+Re=KupB_+[y!2AbY~-~Hr2AJwD!(h<~El>h<~El?Kun@+_:9b`}Kg-v/Ri3g;vtwyk_9]k_d=&T#*U.6qh@Ab`|K9:H|CJv[!&3Dtex'fDwC%!Rf[9WlMd[(^X,!a%Z06Vz!@WgBg=v~Rgvg,QRe@awd,#Y+jTv|Q~EfWj]uNr|~FRfXdy#Y&^Ua%!aO.!(a)Ua;=!a@aKap!a-,a!Ta]a[rSa]p?[y82sK=Bq~;:p:~<5p8Pw:5p7d'#Y'Wf(;RnRi[u4w&RgJJvG'!6Vyh=<r#ijuuv/sIKuYD'ZtG@3p9~Gr&d2#`(g<vtRgFj`u5w&rqpxRf2CJuY!+:wfnTOu!5Rg}jNs1ucv&RfwJvA!&3@q|BDcC#T,k/unq8w8Q5RkTklwQuzunq8w8Q5Rk9dga#!a'!a=#a0!:+Tb*b@aO.a4!aba8aFJv^}?!VyR~Dr<g;u%Rn.~<5p[x'e`wNZtR@3p]Pw:5pZhNvjBp.woe_g5u-r4JwF!%DtO3:ooc7&!#:p^3DtpLuGw(!+%)Dtk6Vz#2sd=<r8d'#Y([y#<x3gJt`w@!)%}MRiowzikRij=]ilxAf3,U(#B2Rf#g0v-Rm[ck{`U#]giKv3>)!&6Ri154s,KuGB_%@r68r:dJ|t`#X(9<E|u2@H|rx3gJu?w'!+'1Nu7Reg4=H~+9<wxgY95Rm]xLggZ-`(X}U2:Ri4h<uOawRmsJv__5@bb{jbV~3dka#a'a]!,#a+U=a>b6a3b%!/aKa/)!arwve^VyJ;:pR~DpTg3uJpS~<5pOPw;5qmPw:5pNOu!5pQJvG'!6Vyx=<qoJvA!{~Jup!%@qk7Rn/KvyD!}''[xz;>wkh'?Rh,x8gyt`w5D!&),(SgyccRgztJ@3pPB5p#d'(Y#<]mmifubw&RgoJvE&!82s^JvF&!8Rf,ADb]~;x=h'rNu]vK!,%'*0RnORh)4Rh*AqQg-vaRnNg;wHwkh'ba~4cE#Ta*x3gctyw@'!+%RnFRnD<4Rn@hFvK5RnCxWg[#`&a0Ua()`1Rm75Rg[c]%X#qi8Rg^NvdRj>BwzgZauwji7Rm6A4wgg]d1#&(*,.0a#Rm;Rm<Rm=Rm>Rm?Rm@RmARmBe%#^^^Xaea?aC/b+(,!a+a#!a/!>a&Ta<aKbD!2wphBRnk[yPw}hE|.=Br-3Dtm>6Vy~g6urRf.x,hPrNav!%'RnqRo%Ro#Nu;q[Pw;5r+JwNZtM@3r)d'#Y'Weh;xChL#`&RnmRnoKu}>%(!Rne~Bs-;2wjcussJv+'!aYSO}6@B<5?ba~8LrNvj!.%*ROwungw~ng~:9;Ri^>wtnig;wHRnixDh@|(UZ.x1h@|)!#:2<H|*xHn]#-UX'3Ro)z=iT}6ARns=Bwsn_wpnaRncw]aR(#UXa&Ua*a/=]iPd'#Y&Ro'WnXf{QRm2hNvj]nZd`'T~&1`{|`#9b]{}c:'!#Wl{>@=be}]?cl{{U#:5Abb}Jds#^YaF!a*b4a#a3aPa>&Tb!bH!*a_!Eau?/a&RjY<]gj>6Vz*;:pe~DrZg,QRj1JwNZtX@wihspcJvZ&!VyX9WmOJu|!|N2WmHJvh&!]ht~Bpbcn&T(!#RmQ<s7Nu;padH#X'`+WmJ@>RmKCARhnKup=!)&Wf+:RhqNuPpf9c!#'45pd5AwghpARn(Ls@w!%,)!RmP@Wfe<E|IJva!&WmNg8vsRmLd`*.`#Y'Xa!axRn*]hrA8Rhug5s@rXg8u!RmMd8#X'X*3@rV72smdI*#UY&RmICARho~GsgxVgd)Ta'U-Y&Xa!T#RnEWnA@Wffg1uDRi0hFvK5RnBxGnG&#`%owp)@wsf+bX}Ze-*1!a*^^^Ua|!#a.aq&Ya2!a>.a6!a:aO`aJDtL[y`@Wg#>6Vz12@wzoYRoZNuPRi!NuPRhzg=ucRi,@=b`{Yg=ucRi-ACJvB!&Sh[ebSh]ebi`wUuFRm4Jw2_[y0JvB!.<Ju(!&SoG}6Shd}6<Ju(!&SoH}6She}6Kur@._g5vHRieJvx!{L2G{Kx6gd'T#?Rh82Wi5cZ#X(g1w)Rm5dW-Y(Ta#!a)!#aYa=wnfE=su2>>bU{0j9udv:<svj8uQv-7RgHdE%#^'sq9sp=>Bb_{TJv`!&g/r|snj6v(us5d,#Y(56H}[978H}]Jw5!&g1rushJvB!+j;v{u5?zDhd}6}bj;v{u5?zDhe}6}ce*#`(^^^a[aea!=!a6a*aoXb1a.!aAbL!b>,b'aL!aV@Wf|2Wlg3[y/JwNZt^@3piPw:5pgJunZou3@rsJva&!Vy_g<v~Rm#JvG'!6Vz0=<r{Ju{%!:pj@WfsiXuJu3Rm:JvZ&!WfA~Bph@c4Z&Dtwax5rubx(#:awRk1@d,#Y&RfjRfid1#,Y(@Wfp2Wlrg5s@ryKu[@!,'=]ig9wlk?Rk>g5u-rqJvy'!@9RkQcH(T#=>Ri~@<wkj(Wj(KuZB*!&<7rw@9RkRcH(T#=>Ri}@<wkj)Wj)dg(Ta2Xa9X#`-!a*CARhg@@=I}d9x;c~#X%so=<sj>2@@=aybb}XjWv0Q~EfEj3vLv;<d,#Y(56H}`978H}_dgaPaFa'a/!#a3Y0a_a;a|!1(a7-[yE3[xt;:pJNvZrrg3uJrvJwNZt=@3pIh=rt3rxPw:5pGOu!5rpJvG'!6Vys=<rz@c4Z&Dt(ax5rtJvZ!&~BpH@wsfNg-vaRlNci*U#=<wei<F}a5@Jq.!a*JQ!%@qZ23d(#Y&RjH5]jCk!u7w&u0udARjFd/prq=tyvpaEa(a:.!a1aZ(@@=I}:9wpd%=<sX55w_h}@@=I{t=ay<aU@@=I}T=ay<2@@=I})?C9:9au@9Cb]}DP~=x-fAZ(2Wl1=ay<aU@@=I}>5@d##Y+jTv|vV~EfFj]uNpn~FRfGdgaK!Z2&!a8a-Tb({E!acTbM*!a(DtY[yYd'%Y#sl[y*hHvh>Re5x2c{Z}.j4uCvcawRiMd+#X+_x&d!},<5RkX;2Hzw@x,gavfB-!{CcF&T#Roe;RodwWbBg5urRgaKvHC*_6Vz+<4opieuew&Rmq@d]&Y)X,T#X0Rh}<BqP=4qS9:ReMg/ujReNJw0!/<Jui%!bd{kawwnemRelAxUa?a3#*.&UX(Ya+a/RhvRnQ<o}9Wmtd-#Y&RgSRmw9;Rmxay=Rmyg-vaRmuxEhSrNu,v-voC!%(aR.a(a7+1Ro1>Ro5CE{A9b]{@;5x#eO{:g;urRi+KrNA!%(Ro3>Ro79;Ri_Ku@>{;&!x%gX|{KunA_+g5QRj/g3u5Rj#g>uERj%wio/xRhS&!,!#^1U}wba{8>>@=be}qC@:D5ba{7Ku+A&!}x?ba}t>>@=be}se(aA^^^Uat!b0#{pa+awUazbGa#aLb9bgaWac'a5TbS=Br!d1#`%scp_Jvl!#rT>Re0JvX&!VyN=H{Fcm#U&:pY=ReaJv2&!]h0=]nUJvG'!6Vy|=<r%JrM_=]h2@Wlud'#)U'Wf'b]{i=]h/Jvh!&~BpWg=v]RnMx+ny#'Nu;pVwjnu=]nwxJnx,T#`&Reqwjnt=]nvieu9vrRjLLuYwP(#+!th@wih5pX~Gr'g5v/Rh4KunA'!-CARnP@wwiN:Rm_9x'cvw>!|l=<saKvAA!0&3@q}>w^e1bp#&Re2Re3BDx7gH#T|f5H|eKuZ>!%(:qNAH{]Jv6!+3B2B9=b^{X<5<B92:E{ZLvhwA(a;a%!igQuyRmad+#Y}m@3Rh5d8#X'X*:AqUAHzmaxwbh<aXRnVcF}RT#Nw&cj#U(BWnug/vsRntdka)(a3+.Zb7aYYan1!bVa@Xa}[y^@b[{G=H{+hFu73Rj&Pv#5ReQcK%T#sig1v{Rj'Ku+D#'!t]~Grm~?rkKuMB!01d5#`'Vy.ta3Dtu~Hroc8#'{^45s85AwZbP&!#Rn!wghxWn#KvEA!)&2RlA2RlBx:h|#(T,=]j09Wobz>x]z/@awRoTd+#Y(az]hFhCrm4d,#Y+jTv|Q~EfMj]uNr|~FRfOdCa!Xa9_X#@<plJvf!%b`{(9;Rgwc;.!#2x7cw#T|UDb]|T5Ju={(!=@E{&Jv)&!Ab`{'awJvf!~*>>@=be{#KuY>!+&4Ezyi[ugv&RjIdea+T)#UXa&T-T&a!Rh9auRmW=]kLg5vuRn+g3u4Rn-Ow6ARn,hHus5xNk?#UX(U~)/g8v0RkD~AwkkF?Ri.OuNBwkkA?Ri/d|a2`a*^UYa.!aBTZaTa'Xa;!(!2!-a#b2[yC>6Vyq3[xr2Wi?g1rusVh%s?DtF~<5rbJs;%!DtBfswKtCj[uvuSsEu3RgVx3o:u+wN'*Zt;@3rd~Grh~?rfg8w)Lq)qE&-a%!>bI|`jWv0vV~EfCjTv|vV~Ef@j]uNpn~FRfBcK#T']gWNu7x,k7q4ai(0!hHv8<RhmkMu9vrsBuev/RhlCJvB!,g<v{wchh~@:Rhji[vrv{wchi~@:RhkdS&a5UY#Ta!RgPwwiI5BwciI~@:Rh`x'iJvj'!5]iJPu8Bwch]~@:Rhach)U#h3rp]gLh@t|Ax,hTq3ah!-(~@:Ro0Ou!5RhXj^v(pyw8unRhVd|)`,^UYas!a?/a2Z'a^Ta{Tb7Ta(a#!a,Wf&9sZ3DtAadamov=Bqt3[xig8vsRm~>waiL2b`{QJv*_Ouv2qgj<v]v2BqfdR'X*X#Y-@3qr~Gqv~?p6hHv-]glPup5Lq+q?_%*b_{qF{n9b^{rOu4ARhpKvCD!+&~Bqp:5Dbb}nwoiKl&unuTuBv]v+ueunaXRf0=Jvh!0nKufu8v1w&w7q%w&uHrz:Rgnj5w,uxDJq/(!hNw'5ReCk0s2u3w/w'5ReFd>Za&!*UaA=<wkgsRnSJv^!%Refifw3vyRgOKu_B'!,<]gkiiu:w&Rh<=C@a^<B57@2F{[<B5@aW:=3away9A5aW=<B=C@a^<B57@2F{Ie-#`(^^^bCara.b8aza6!/bZ,!adTbnTbOb+aFaS!aAT9@Wf~2Wli3Dtl2@d,#Y&RfnRfmJwJZtN~GqyJva&!VyMg<v~Rm%iXuJu3Rm9Jv[_=]ih9wlkDRkCd1#`(@Wg>2Wls3cH#T(@<Rj*=>Ri|b~'#23s9h<~El.d'#Y&Dtxi^rzvdRl#d*#U%(o|B2s`hJwSaxRmDKv4B&!1:Rmdd5#`'Vx}to~Hq{x'f1v3(!BA5ba|bJv_&!Wfug1v]ReIdO+U/Y#&G}-8wze=Rh{g1v]ReHg/uQRf/by#)ibQwERl/cH#T(@<Rj+=>Ri{cNu+vlax-!(#a0qa9<Rii2;;bU{H;x<i=&X#Rk`<4wwi=C9H~8xAI(Y#<azRi@45wXI<B9;5bb~7dL(X#Xa(+!aL6Vy{g5QqOau:5au2@ay547EzbxOcU(UX-T#Ta#:Cbb|A?wjh/b_|SOw6ARgtihr}u7Rhy<d1#T)X1@@=I|~=ay<2@@=aybb}Sj3vLv;<d,#Y(56H}A978H}@dGpvs@uAu`vcw9*!aFa+ai%(b!aXa8.a?a[ozWey=sU2@G}Nch&U#Rf_WexKu+D#'!t:~Gr`~?r^j]uNr|~FRg*j^psurwJt|RmcKv)@&!)7Rkv~Br[@wxfO:Rl3co#U'6Rezj_q#vIuavjRltwzeyh@vr5JqD0!>aY?C9:9au@9Cb]}9cl#U*5;5<H||jbuus1ucv&Rfvg1v~d/pppzqFr^a--a~!aMat1(hFv;Wiz@@=Izoj5uuv-7Rix~Cw`fk2WlVcZ#X,k)u3vWs@u2]ktg;wEx'fBq(_2Wg/jTv|vV~EfoJv]!15x'hzqG!(P~EfU~CRl_j6v(us5x4i-#T(2WmZ?C2F|d>Kq<aj1!*jTqIsBv=Wl`~Cw`fi2WlWj`v0u*~>RlR=c>Z,k#u3vWs@u2]kr<c1Z+jTqIsBv=Wla~Cw`fm2WlXdmb3!a{(arZa`bkTa%TbQTa-a9+c'!aM!/[yL=Bqug.w'RifhFvyDRj.g>vgwyk^9]k^Jv3_@WfbAARkhJw2_[x|JvB_wkoIRoKwkoJRoLd'(Y#<]gm=<9<H|yd'%_X#skDtb3awwqkgNulRkgdB#^',9:p'hJwSaxRmEBwVb8@4=H|qLu+w50&!)@3qs~?pU>Awwn;;Rn=c:Z'ARn<=<qwKvC@!/&~BqqJv6!&]eVb^z^xRge'/a%+^`#Sge}6<4Rn3=]n0Pw2>Rn8Jw0!&>Rn:>Rn6cY#a7+!a&=<wkaNw~h3z_c5Z{=wjh#=]nLKv^D!&)Vyz=bW|swYb<WetcG#T(2wxa@qVx@gD#Y&b^|V5JwG&!5bb|pg/w&RgD@x=kHs=uAvn!a%%/'+RmSRh694Ro`g-vaRmRhHv-]mlxCcS#`&ba~.5cD#Ta)P~=d,#Y(56H{>978H{Dd_#{2^Y%_+qbbb{6g3sERhsbU{?dfa.,`a(Xa<!aiX#(55RiG54RiHcI#T'WiU3RiVNvdwtfcRlKNvdd,#Y&RlHRlExQgf.1*^T'X#Sgf}6Wn4=]hfPrk>Rn7Jw0!&>Rn5>Rn9Lunw?&a2!,5<oq@@wqfdRlJj5Q~=d,#Y(~ARfcOuN]fdDKw;ay(}i!547E}j?cI#T(@5bV}iCbV}hdv(^^Tb?a40,b##Tbo!a*bR!a<b|a/!aKai!aU[yK=]o^g:v>ReGJwPZtK<7Rh+h<~El,Pv#5ReR@awwxjCg,ulRjDJv6&!]j!z?aQeeg>w=Sh<eeJw;!&axEzOg,Qosc!#*:wkeJ]eJ>x'h-u(!%Ro.w~h.zPdNZ(X,Ya![x{;9ReY;wkgxRiF:x?ap#Y&RmUg<s2Rkod]+UY0TZ'!a&A9sw<=bczLNvuw{gqzNhJwSaxRmCKuLay!#&s_Rf-55b^{uJvZa!!c%#(55Ri654wmiu5RiuawLu,vp!+}^%b_}Y9;wkgxba}o>A9:=b^}zKuh=a''!3awRk3c*'!#aHRk6c+Z&Rk5Rk4Jv)&!awRjSawd9*`#0?C2@EzMj8u<uJ5RmbjQrquJu3x,k>uq@_+=ayb^|W~ARkEOuN]k@7dhzV^X/X&a-#zRzSb`zXcJzTT#2WkVKvDBzW!%FzY9;5bbzWjQrquJu3Jw3%!b`zU=ayb^zQd:#X(T-a!6Vyywxh}=b]{Jg=u1RiAdGp~qHtzv!w(wA+a+a;<!aJaYai'anasb(=azRmV:Cbb{MLq2vb!%')RjuRjrRjtRjqx3jnqCw3!%')Rk(Rk+Rk&Rk)Lq2vb!%')Rj{RjxRjzRjwLq2vb!%')RjsRjpRjfRjex3jcqCw3!%')Rk'Rk*RjkRjl9<CbbzfOu4ARhxLq2vb!%')RjyRjvRjhRjgx=joq*uKvb!%')+-Rk.Rk%Rj~Rk-Rk#Rj}x=jdq*uKvb!%')+-Rk,Rk!Rj|RjmRjjRjidAq&qKs@uAv8Aa.'*-a@a&0!aM@a5[y73Dsy3Ds|3Dt):wxgI2sHJwJZt.~Gqxwsf0ikrzt}Rl0Jvy_[xj~HqzKv_A|D!&WfP8axRoVcf,U#k(v]v+ueunaXRf1Ju}'!g8u#Ri=jQw!sCunLprq>!,')~<5qeGzq9F{W=c##%s5au:5aU3CBE|;d4#X(D!a&6Vygx(b;#(=]ed?C2F{N<capoq2r[a&!aPa9,'Pw;5s:@@=I|,55w_h|@@=IzcP~=x'fCqB_2Wl2>aU@@=I|1OuNBc1Z+jTqIsBv=Wlc~Cw`fl2WlZ~AcTa%!Z+jTqIsBv=Wlb~Cw`fh2WlYk+uNqJsBv=WlSg,u3dca3#UXaMYa)TaB-=cM|7T#<bI}l5@B932:aV2G{BOuNBJq:|M!5Ezt=<B=C@a^<B57@2F{v>cB{/T#=ay<bI{3Jv6!a.6BKq0ah&+!5E}HP~Ef{978BaU@@=Iza<7d#.Y#978BaU@@=IzH~AJq0!(@@=IzG978BaU@@=IzFe,aU*Y&^^^bvJb,b:bFad!a,c2Ta>aL.bo6!a#CbTa'T#Re{2Wlh2@G{yg6t~Ro_NvdRfticuRQRllJv3&!x&c|zs@Jw3!%RflwpfkRlpKuL;%(!Re<@G|C2GzdhIvuBwgjAg-u0RjAKQB%!(GzZ@G|5NuuRl7d='T+Y#Vy[g<v~Rm!==G|>JvA!)@wma=]m1ifuaw&RmnLs@vT'!|/+[y,g:v>ReTJw1!#qX=x!eC{bLu+wT&)ZtZauq_~Graci&U#F|89:r_Lupvq!.)&2RlG8RfaC=x!eF{_h?rpWlmd&'!#X|&]k::xJey#`'T|+<E|&2@H|%dE#(^,g;u.RiEg6vjRiC9xCkA{O|zY#g=ucRmXKs0@!&*@G|m@awRknJuh!,3d(}gY}eJvj!%Rm):Jw3!%Rm+Rm-Ls0w(&!a(a#@b[|6cZ#X'7RkxWgAOu4ARn'dH'U#Y*Vz-Wm'CARm}d]*#a%^a*T'aK!a<9bV{PC=p*Jw4!&SgxcbB5r]idw(wBRmF7xFkt#&`(Rm/Rm8E|!JuY_9:Rl5=wrgr2:bbxd@xXfB(a*#T+!.X0X1Ta/a'T&RlDRfL>RlyARl9b[z[>RfZ:RlL:RfRwlg/ARl;9;RlxKv,A/!%7s69<74=BA5ba{-8Bde#`a<XaKYa1,a'P~=wxfB2bZ}}?C972@@=I}r8@55B9;5bb}G978B2@@=aybb}3j3vLv;<Jw3&!>Rfk=ayb^}4~Ad1#`*@@=aybb{w2@>==<bbz]dx+UY#^UaF!a9!bB'Ya1.!ajXa#%olRhD[y=3Dt#Ov5BrHKuMB%!(Rf^Wep~HrJwkiQjKr|~FRg)Ku+D#'!t5~GrF~?rDdV)UY,Z/_7RkuG{<~BrBg,rlsO:235B@bX}|d?a1!#`(6Vyn5@d##Y+jTv|vV~EfIj]uNpn~FRfH7Lq2vb1!a9-978BaU@@=Iz9978BbU}#~AJq0!(@@=Iz8978BaU@@=Iz7~AJQ|}!978BbU}!JvkaK!AdUa21-U#`a+(g/vsRn~Ou!5RPj:rmu9WhOjXuvvNr}:RhAj^v(pyw8unRn[kPr}p|u7vwv]RiSBd;pppzq@qHQa?(b.!a.a`@.|xa(hFv;Wiyj5uuv-7Riw~Cw`fg2WlU978BbU|wOuNBJqG!(P~EfD~CRlQcZ#X,k)u3vWs@u2]ksg;wEx'f@q1_2Wg.j]uNpn~FRfqJv]!15x'h{qG!(@@=IzK~CRl^j6v(us5x4i,#T(2WmY?C2F{1>Kq<aj1!*jTqIsBv=Wld~Cw`fj2Wl[j`v0u*~>RlT=c>Z,k#u3vWs@u2]kq<c1Z+jTqIsBv=Wle~Cw`fn2Wl]dn1#c(a(b^a2!b/bAT(bj!aDa7bu,a_a{c0!2T0g:v>ReD2@G{42@G{5~DpM~<5rc=Bx6i>{RT#RnI@zCx]y]z:2Jv[!zr5Awyk]9]k]dD(Y+X#6Vz.g=wKtgwhaCwgmTWj2Lu,w%_+/[y-B;b^xeg3u3Rj-2@bX{*KrJ<!+'@Wg(g?QRlC@Jv`!%b[zIwsfII}8JQ_@w|kW|=Jv(%!AqcOuNBJvEzh!bYzjLs@wP#(0!oy@>RkdJwMZtc3Dtd@BcG#T'9bWxg2@2Fznd*#Y+;2x'c}w<zizixNgwa#Z'U+!/!a'!a+w~g~z6wcn{Rn}wcnzRn|5Rh%=]nJg5vuRmvNvdRlvcprJu}w*az*a#!%.a.'Bot9qT]kj@Wg'ay2Gzv@Jv`!%b[zEwsfHI}1;ck#Ux`<Cbbx_Lu+w!a&0*!wko*wwo,So,}6Juqxf!E}PigQuyRm`d3(`#8>Rn%:A5B;bZ~%KvhCa!a2!x>k7#Uxb@b{#xaRk7Jw0!)>wwhlShl}6>wwhmShm}6CJvB!.x'hhvj{!!5Bwkhhbaz}x'hivjz~!5Bwkhibaz|xEhTrNu,v-vpD!a%&/)a3a.,%Ro2t[CE{)@3re9b]{%wjo09:rgc:Z&Ro6=<riifuaw&RmoKrNA!%(Ro4>Ro89;Ri`dSaL'UYzxZb)7Rka3xRhT&!,!#^1U}vbaz{>>@=be}yC@:D5bazzKu+A&!}{?ba}y>>@=be}wxBh[t`u~vJvr!%a!a()a,a0a4RoC=]o;Ju(!%RoGRhdwjh`=]oAg>w#Ro?g5vuRo=NvdRl|Ku]C.!&;RoEJvB!%RoORoMBx'h[v+_?w~h`}~5?w~hd~!xKh]oiptu-utv.vp!#%&a30a@a'a+(a/aOp(o~p!RoDJu(!%RoHRhewjha=]oBNvdRl}g>w#Ro@g5vuRo>c[#X']o<CauRoRAd-#Y':RkpauRoQKu]C.!&;RoFJvB!%RoNRoPBx'h]v+_?w~ha}t5?w~he}ue!/UbhYacXaW^Tc&a;b:a-c/#b&aja1(!cL+!bKbt!bmcRc9aIc?8[yW3Dtt94Rg`Jv}!&SiRMzBhEebShEMNuPRe>x7gL#TzuwjirRipc<Z&>on;>z=h-MSh.Mwqczx'a7vj&!>Re4@=ResJt__NuPRi*NuPRi)j]uNr|~FRfzKrJ>_+@Wfy@Wf]2WocKrJ<!+'@Wg%g/QRl@@Jv`!&awRl<wsfFIzgLu(w*!.*&ShBMwvhIRhI9;RhNx1hK'!#Sn]Mx1hK~0!#:2<H~7cNu+w7D*'1ZtW>Rn1~?rOc:Z&Rn2=<rQ<7wjh&=BSnLMc]#X(6Vz)w[b=a!U#9wzgMc3#&(RgMRitRis<x,gKt`ax!&+SioM=BSilMc3#&(RgKRinRimKurB,!&SiQMzBhDebShDM6BJQ!(P~Efx978B2@@=I}WLrJw!!,a*&@G}O@9wkibRid@@x'fKwC!&SlDMSfLMjUv~Q~EfKKv3@a+!(hFv-]mpx/hYZ(C5RiWz<o/MwkhY?So/M@x,gbvfB*&!SgEM:SoeeehFu3:Rgbda(,^TZa)X/7Sg[eb:2RgI~BrMC@wgkc:wwkcRerx3h(uUvK!&*,SnOM4Sh*MArRg;wHRh(x=h;rJvPwI!a4',a'0@Wg&=BSh/Mg>w=Rh=g3w*wwgGRgGcW(X#;Sg}M2Gzk@Jv`!&awRl=wsfGIz`dKZ*T'Y-:RhR7RhQg5u-p`j6v(us5d,#Y+~Awkia?RicOuNBwkibba}Ld6p~tyu_vbAa'a+!a/'a3aEa8a!>Sh,ebJv{!&Sh@ebSaReb9;SgwebNuPRi(NvdRl)NuPRi'hHu^<Rm^Jvv_@Wl(g;u1Si/ebKu'B&!*Sh?eb@Wl'z@aPeb95Si.ebcpputyvjB)!,&a+0a%ShAMWeK@G}C@WfJ9;RhMwvhH9w{ia}ix,hJvRA1(!zAn[MRhHx1hJ~*!#hFv(BSn[MBJQ!(@@=I~'978B2@@=I}2db.Ua<'X}+T#a0XaG2G}E;wkg|wuh!Rh!x,hZu,@)!&So0MVy)C5RiXACJvB!&5RiY5RiZg8w)cG}*T#2@bU}=KsA>(!a.3wkhZba~(x,h^u(A!&(SoCMRhb5Bz=h[eb?w~hb~6x,h_u(A!&(SoDMRhc5Bz=h]eb?w~hc~6e)aA1T#T,^^^c-bMb&blcPaP(a/!0!bA=b5c@a(!bfbrc#2afwmhARnjwchORnp2Wlf3DtsNvdRl-2@wpa<]m0bx(#:awRk2@Jw3!%RfhwpfgRlnKQB%!(G{V@G|'NuuRl6d='T+Y#VyUg<v~Rl~==G|<Jv+'!aYShC}6@B<5?ba~8@Jw3'!g2QRljhLrpWlOd+#Y'g.w'rIg>w*wgj@g-u0Rj@Lu+wT&)ZtUauq]~GrGci&U#F|39:rELrNvj!.%*RhCwunfw~nf~:9;Ri]>wtnhg;wHRnhx3hDs@v~!/+'@Wfr@9RkSNu&Rlo=@<5GzoKs0@_+@Wl+@awRkmJuh!-3d(}pY#qWJvj!%Rm(:Jw3!%Rm,Rm*de&!1U-U#`)Re;@G|.@9Ri82@wjfvRlq=@<5GzpLvOvr!).&2RlF8Rf`C=x!eE{.Jw3_g2QRlkhLrpWlPde(!#U{s,UXa*Ta'[y'g:v>ReS;x0PZ&RnlRnn~HrKJw1}f!=x!eB|2w]aP(#Xa&a*Ta.Ua2a7=]iOd'#Y&Ro&WnWg;u.RiDg6vjRiBNvdRlzhNvj]nYJuW_2Wm3x)kFze{9d])!a.!,Y01!#&aC!a3RndC=ox~BrC@2b^{pg,rlse7x'ksuq!%Rm.E{xidw(wBRmGx9o+)X#wwo-So-}69:Rl4@xSf@a#XZ'X)X,Ta(/ARl8b[xc>RfY:RlI:RfQwlg.ARl:9;Rlwdn'#^XafaQa1X1TaHTa)@b[{zcZ#X'7RkwWg@Ou4ARn&x)kG#{,g7u/RkGdH'U#Y*Vz'Wm&CARm|bx#(A]gUbUzJj9Q~=d,#Y(56H}l978H{U7d,0#U*2>ABb_xZ978BbU{e~AJQ{g!978BbU{hxMh?ad{oUYZ.x1h?{l!#:2<H{mx3n[t{vl!,&a%3Ro(z=iS}6ARnr=Bwsn^wvn`Rnbd`*T}B0!#^X'BG{c9b]{a>>@=be}F?JvS!&BG{d7BG}(Bde#`a1X,Ya@!a'P~=wxf@2bZ}I56B2@@=aybb}08@55B9;5bb}<j3vLv;<Jw3&!>Rfg=ayb^}&OuNBKuLA!)a!P~=x#fD{f2@>==<bbzl?C972@@=Ix^d6rSu,v7w*C(0a)a6#B+a%!sQ[y?3Dt%3[xn~<5rLOu!5p@Ku+D#'!t7~GrP~?rNKvlaya7'!h+v-5qMg=t|cd,U#5AAaa5Abb{S@52B5@a[@52B5Gx[iXueu;d<#`a(!/549C;ag>23ExY5@Dah89b^~689Jv)!~2b[~1Lv'w(%*!a#bX|aPrmawRe]keu7uhv-q6rxu,q`xTo]/a5aU!bNaDXbi!b-!ao!b<bwA!#5@B932:aV2G|:d-)Y#hJrL>RhG<7@C5<H|_=Cau:5aj5@B932:bJ|ng>vIbs)#?C2F|9jPv0w.vISh-MKvUaz(.!9ABbb|[5;5<H|Eg>unwfh;9:4E|YjQsBt|vjx'hYq3!(?C2F|J:2<BaY?C2F|GOu!5x,g|p{ah!-(?C2F|c9:4E|OjXuvvNr}:Rh&i[w*t|cd+U#jJvsu)vsSn~Mkfrmu9p}u7vwv]So!McW#Xa!ax5@A5aY:5;5<H|>kJv~vYrquJu3x4ib#T)2@SmZM?C2F|Bj:rmu9@xPhI(a*a#U#`a3-5Abb|L~@:RhK9:4E|0@52B5G|#C::aY?C2F|-:2<BaY?C2F|.5Jvk!a)javYrquJu3x4ia#T)2@SmYM?C2F|HAxPhH(!a#U#`a*-5Abb|4~@:RhJ9:4E|R@52B5G|F:2<BaY?C2F|Sc^#Xa2j=Qq5CJvB!-g<v{z;hhM?C2F|Zi[vrv{z;hiM?C2F|XKsA>!a)-g<v{z;h[eb?C2F|]i[vrv{z;h]eb?C2F|^iZu.vix,hZq3ah!.(?C2F|QOu!5ShXM:2<BaY?C2F|P",13494,2713,49,25,61),S;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.FLAG13=8192]=`FLAG13`,e[e.BRANCH_LENGTH=8064]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`,e[e.VALUE_MASK=8191]=`VALUE_MASK`})(S||={});var C;(function(e){e[e.AMP=38]=`AMP`,e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_X=120]=`LOWER_X`})(C||={});var he=32,ge=21,_e=2097151,ve=2047,ye=0;function be(e){let t=e>>>ge;return t===ve?ye:t}function xe(e){return e-C.ZERO>>>0<=9}function Se(e){return(e|he)-C.LOWER_A>>>0<=5}function Ce(e){return(e|he)-C.LOWER_A>>>0<=25}function we(e){return e===C.EQUALS||Ce(e)||xe(e)}var Te;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(Te||={});var Ee;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(Ee||={});function De(e,t,n,r){let i=(t&S.BRANCH_LENGTH)>>7,a=t&S.JUMP_TABLE;if(a){if(i===0)return r===a?n:-1;let t=r-a;if(t>>>0>=i)return-1;let o=e[n+t];return o===0?-1:n+i+o-1&65535}if(i===0)return-1;let o=i+1>>1,s=n+o+i;for(let t=0;t<i;t++){let i=e[n+(t>>1)]>>((t&1)<<3)&255;if(i===r)return s+e[n+o+t]&65535;if(i>r)return-1}return-1}function Oe(e,t,n){return n===1?String.fromCharCode(e[t]&S.VALUE_MASK):n===2?String.fromCharCode(e[t+1]):String.fromCharCode(e[t+1],e[t+2])}function ke(e,t,n){let r=t+1,i=0,a=r;if(r<n&&(e.charCodeAt(r)|he)===C.LOWER_X)for(r+=1,a=r;r<n;){let t=e.charCodeAt(r);if(xe(t))i=i*16+(t-C.ZERO);else if(Se(t))i=i*16+((t|he)-C.LOWER_A+10);else break;r+=1}else for(;r<n;){let t=e.charCodeAt(r)-C.ZERO;if(t>>>0>9)break;i=i*10+t,r+=1}if(r===a)return 0;r<n&&e.charCodeAt(r)===C.SEMI&&(r+=1),i>1114111&&(i=1114112);let o=r-t;return o>=ve&&(ye=o,o=ve),o<<ge|i}function Ae(e,t,n){let r=me,i=e.indexOf(`&`);if(i<0)return e;let a=e.length,o=0,s=``,c=r[0],l=c&S.JUMP_TABLE,u=(c&S.BRANCH_LENGTH)>>7;do{let c=i+1,d=e.charCodeAt(c),f,p;if(d===C.NUM){let n=ke(e,c,a);f=be(n),t&&f>0&&e.charCodeAt(c+f-1)!==C.SEMI&&(f=0),p=f===0?``:de(n&_e)}else if(Ce(d)){f=0,p=``;let n=d-l,i;if(n>>>0<u){let e=r[1+n];i=e===0?-1:u+e&65535}else i=-1;let o=0,s=0,m=i<0?0:r[i],h=c+1;e:for(;h<a;){for(;(m&(S.VALUE_LENGTH|S.FLAG13))===0&&(m&S.JUMP_TABLE)!==0;){let t=m&S.JUMP_TABLE,n=(m&S.BRANCH_LENGTH)>>7;if(n===0){if(e.charCodeAt(h)!==t)break e;i+=1}else{let a=e.charCodeAt(h)-t;if(a>>>0>=n)break e;let o=r[i+1+a];if(o===0)break e;i=i+n+o&65535}if(m=r[i],h+=1,h>=a)break e}if((m&(S.VALUE_LENGTH|S.FLAG13))===S.FLAG13){let t=(m&S.BRANCH_LENGTH)>>7;if(e.charCodeAt(h)!==(m&S.JUMP_TABLE))break;h+=1;let n=t-1,a=i+1,o=0;for(;o+1<n;o+=2){let t=r[a];if(e.charCodeAt(h)!==(t&255)||(h+=1,e.charCodeAt(h)!==(t>>8&255)))break e;h+=1,a+=1}if(o<n){if(e.charCodeAt(h)!==(r[a]&255))break;h+=1}i+=1+(t>>1),m=r[i];continue}let n=m>>>14,l=e.charCodeAt(h);if(n!==0){if(l===C.SEMI){f=h-c+1,p=n===1?String.fromCharCode(m&S.VALUE_MASK):Oe(r,i,n);break}if(!t&&(m&S.FLAG13)===0&&(f=h-c,o=i,s=n),n===1)break}let u=De(r,m,i+(n||1),l);if(u<0)break;i=u,m=r[i],h+=1}if(p===``){let e=m>>>14;e!==0&&!t&&(m&S.FLAG13)===0&&(f=h-c,o=i,s=e),f>0&&(p=Oe(r,o,s))}}else f=0,p=``;f===0||n&&d!==C.NUM&&e.charCodeAt(c+f-1)!==C.SEMI&&c+f<a&&we(e.charCodeAt(c+f))?i=c:(o<i&&(s+=e.slice(o,i)),s+=p,i=o=c+f),e.charCodeAt(i)!==C.AMP&&(i=e.indexOf(`&`,i))}while(i>=0);return s+e.slice(o)}function je(e){return Ae(e,!0,!1)}var Me=class{src_Any=ne.source;src_Cc=re.source;src_Z=se.source;src_P=ae.source;src_ZPCc=[this.src_Z,this.src_P,this.src_Cc].join(`|`);src_ZCc=[this.src_Z,this.src_Cc].join(`|`);cache={};opts={maxLength:1e4,urlAuth:!1,schema_names:[]};constructor(e={}){this.opts={...this.opts,...e}}set(e={}){return this.opts={...this.opts,...e},this.cache={},this}escapeRE(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,`\\$&`)}nestedPairRE(e,t,n=4){let r=this.escapeRE(e),i=this.escapeRE(t),a=`(?:(?!${this.src_ZCc}|${r}|${i}).)`,o=`${r}${a}{0,1000}${i}`;for(let e=2;e<=n;e++)o=`${r}(?:${a}|${o}){0,1000}${i}`;return o}get_text_separators(){return this.cache.text_separators??=/[><\uff5c]/}get_pseudo_letter(){return this.cache.src_pseudo_letter??=RegExp(`(?:(?!${this.get_text_separators().source}|${this.src_ZPCc})${this.src_Any})`)}get_ipv4_addr(){return this.cache.src_ip4??=RegExp(`(?:(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])[.]){3}(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])`)}get_ipv6_addr(){let e=`[0-9A-Fa-f]{1,4}`,t=`(?:(?:${e}:${e})|${this.get_ipv4_addr().source})`;return this.cache.src_ip6_addr??=RegExp(`(?:(?:${e}:){6}${t}|::(?:${e}:){5}${t}|(?:${e})?::(?:${e}:){4}${t}|(?:(?:${e}:){0,1}${e})?::(?:${e}:){3}${t}|(?:(?:${e}:){0,2}${e})?::(?:${e}:){2}${t}|(?:(?:${e}:){0,3}${e})?::${e}:${t}|(?:(?:${e}:){0,4}${e})?::${t}|(?:(?:${e}:){0,5}${e})?::${e}|(?:(?:${e}:){0,6}${e})?::)`)}get_ipv6_url_host(){return this.cache.src_ip6_host??=RegExp(`\\[${this.get_ipv6_addr().source}\\]`)}get_ipv6_mail_host(){return this.cache.src_ipv6_mail_host??=RegExp(`\\[IPv6:${this.get_ipv6_addr().source}\\]`)}get_auth(){return this.cache.src_auth??=RegExp(`(?:(?:(?!${this.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`)}get_port(){return this.cache.src_port??=RegExp(`(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?`)}get_host_terminator(){return this.cache.src_host_terminator??=RegExp(`(?=$|${this.get_text_separators().source}|${this.src_ZPCc})(?!${this.opts[`---`]?`-(?!--)|`:`-|`}_|:\\d|\\.-|\\.(?!$|${this.src_ZPCc}))`)}get_path_terminator(){return this.cache.src_path_terminator??=RegExp(`${this.src_ZPCc}|${this.get_text_separators().source}`)}get_path(){return this.cache.src_path??=RegExp(`(?:[/?#](?:${this.nestedPairRE(`[`,`]`)}|${this.nestedPairRE(`(`,`)`)}|${this.nestedPairRE(`{`,`}`)}|\\"(?:(?!${this.src_ZCc}|["]).){1,100}\\"|\\'(?:(?!${this.src_ZCc}|[']).){1,100}\\'|\\'(?=${this.get_pseudo_letter().source}|[-])|\\.{2,20}[:]?[a-zA-Z0-9%/&]|\\.(?!${this.src_ZCc}|[.]|$)|`+(this.opts[`---`]?`\\-(?!--(?:[^-]|$))(?:-{0,19})|`:`\\-{1,20}|`)+`,(?!${this.src_ZCc}|$)|;(?!${this.src_ZCc}|$)|\\!{1,20}(?!${this.src_ZCc}|[!]|$)|\\?(?!${this.src_ZCc}|[?]|$)|`+this.get_path_extra().source+`[\\\\/:%@#&=_~*]|(?!${this.get_path_terminator().source}).){1,${this.opts.maxLength}}|\\/)?`)}get_mail_name(){return this.cache.src_mail_name??=RegExp("[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9](?:[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9]|[.](?=[-!#$%&'*+/=?^_`{|}~a-zA-Z0-9])){0,63}")}get_xn(){return this.cache.src_xn??=RegExp(`xn--[a-z0-9\\-]{1,59}`)}get_tld(){if(this.cache.tld)return this.cache.tld;let e=[...new Set(this.opts.tlds||[])].sort().reverse().join(`|`);return this.cache.tld=RegExp(`${e||`$#none#$`}|${this.get_xn().source}`),this.cache.tld}get_domain_root(){return this.cache.src_domain_root??=RegExp(`(?:`+this.get_xn().source+`|${this.get_pseudo_letter().source}{1,63})`)}get_domain(){return this.cache.src_domain??=RegExp(`(?:`+this.get_xn().source+`|(?:${this.get_pseudo_letter().source})|(?:${this.get_pseudo_letter().source}(?:-|${this.get_pseudo_letter().source}){0,61}${this.get_pseudo_letter().source}))`)}get_url_host_port(){return this.cache.url_host_port??=RegExp(`(?:`+this.get_ipv6_url_host().source+`|(?:(?:(?:${this.get_domain().source})\\.){0,10}${this.get_domain().source}))`+this.get_port().source+this.get_host_terminator().source)}get_fuzzy_url_host_port(){return this.cache.fuzzy_url_host_port??=RegExp(`(?:`+(this.opts.fuzzyIP?this.get_ipv4_addr().source+`|`:``)+`(?:(?:(?:${this.get_domain().source})\\.){1,10}(?:${this.get_tld().source})))`+this.get_host_terminator().source)}get_mail_host(){return this.cache.src_mail_host??=RegExp(`(?:`+this.get_ipv6_mail_host().source+`|(?:(?:(?:${this.get_domain().source})\\.){0,4}${this.get_domain().source}))`+this.get_host_terminator().source)}get_fuzzy_mail_host(){return this.cache.src_fuzzy_mail_host??=RegExp(`(?:`+this.get_ipv6_mail_host().source+`|(?:(?:(?:${this.get_domain().source})[.]){1,4}${this.get_domain_root().source}))`+this.get_host_terminator().source)}get_path_extra(){return this.cache.src_path_extra??=RegExp(``)}get_fuzzy_mail_host_search(){return this.cache.mail_fuzzy_host_search??=RegExp(`@${this.get_fuzzy_mail_host().source}`,`ig`)}get_fuzzy_link_search(){return this.cache.link_fuzzy_search??=RegExp(`(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${this.src_ZPCc}))(?:(?![$+<=>^\`|\uff5c])${this.get_fuzzy_url_host_port().source}${this.get_path().source})`,`ig`)}get_http_validator(){return this.cache.http_validator??=RegExp(`\\/\\/`+(this.opts.urlAuth?this.get_auth().source:``)+this.get_url_host_port().source+this.get_path().source,`iy`)}get_relative_proto_validator(){return this.cache.relative_proto_validator??=RegExp((this.opts.urlAuth?this.get_auth().source:``)+`(?:localhost|${this.get_ipv6_url_host().source}|(?:(?:${this.get_domain().source})[.]){1,10}${this.get_domain_root().source})`+this.get_port().source+this.get_host_terminator().source+this.get_path().source,`iy`)}get_mail_name_validator(){return this.cache.mail_name_validator??=RegExp(`(?:^|${this.get_text_separators().source}|"|\\(|${this.src_ZCc})(${this.get_mail_name().source})$`)}get_mailto_validator(){return this.cache.mailto_validator??=RegExp(`${this.get_mail_name().source}@${this.get_mail_host().source}`,`iy`)}get_schema_names(){return this.cache.schema_names??=new RegExp((this.opts.schema_names||[]).map(e=>this.escapeRE(e)).join(`|`))}get_schema_search(){return this.cache.schema_search??=RegExp(`(^|(?!_)(?:[><\uff5c]|${this.src_ZPCc}))(${this.get_schema_names().source})`,`ig`)}get_schema_at_start(){return this.cache.schema_at_start??=RegExp(`^${this.get_schema_search().source}`,`i`)}},Ne={validate:(e,t,n)=>{let r=n.re.get_http_validator();r.lastIndex=t;let i=r.exec(e);return i?i[0].length:0},normalize:(e,t)=>t.normalize(e)},Pe={"http:":Ne,"https:":Ne,"ftp:":Ne,"//":{validate:function(e,t,n){let r=n.re.get_relative_proto_validator();r.lastIndex=t;let i=r.exec(e);return i?t>=3&&e[t-3]===`:`||t>=3&&e[t-3]===`/`?0:i[0].length:0},normalize:(e,t)=>t.normalize(e)},"mailto:":{validate:function(e,t,n){let r=n.re.get_mailto_validator();r.lastIndex=t;let i=r.exec(e);return i?i[0].length:0},normalize:(e,t)=>t.normalize(e)}},Fe=`a:cdefgilmnoqrstuwxz|b:abdefghijmnorstvwyz|c:acdfghiklmnoruvwxyz|d:ejkmoz|e:cegrstu|f:ijkmor|g:abdefghilmnpqrstuwy|h:kmnrtu|i:delmnoqrst|j:emop|k:eghimnprwyz|l:abcikrstuvy|m:acdeghklmnopqrstuvwxyz|n:acefgilopruz|o:m|p:aefghklmnrstwy|q:a|r:eosuw|s:abcdeghijklmnortuvxyz|t:cdfghjklmnortvwz|u:agksyz|v:aceginu|w:fs|y:et|z:amw`,Ie=`biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф`;function Le(){let e=Ie.split(`|`);return Fe.split(`|`).forEach(t=>{let n=t.indexOf(`:`),r=t.slice(0,n);for(let i of t.slice(n+1))e.push(r+i)}),e}var Re={fuzzyLink:!1,fuzzyEmail:!0,fuzzyIP:!1,"---":!1,tlds:Le(),urlAuth:!1,maxLength:1e4},ze=class{schema;index;lastIndex;raw;text;url;constructor(e,t,n,r){let i=e.slice(n,r);this.schema=t.toLowerCase(),this.index=n,this.lastIndex=r,this.raw=i,this.text=i,this.url=i}},Be=class{__opts__;__schemas__;re;constructor(e={}){let{rebuilder:t,...n}=e;this.__opts__={...Re,...n},this.__schemas__={...Pe},this.re=t||new Me,this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)})}add(e,t=null){if(!t)delete this.__schemas__[e];else{let n={normalize:(e,t)=>t.normalize(e),...t};this.__schemas__[e]=n}return this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}set(e={}){return this.__opts__={...this.__opts__,...e},this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}test(e){if(!e.length)return!1;let t,n;for(n=this.re.get_schema_search(),n.lastIndex=0;(t=n.exec(e))!==null;)if(this.testSchemaAt(e,t[2],n.lastIndex))return!0;if(this.__opts__.fuzzyLink&&this.__schemas__[`http:`]&&(n=this.re.get_fuzzy_link_search(),n.lastIndex=0,n.exec(e)!==null))return!0;if(this.__opts__.fuzzyEmail&&this.__schemas__[`mailto:`]&&e.indexOf(`@`)>=0){let n=this.re.get_fuzzy_mail_host_search(),r=this.re.get_mail_name_validator();for(n.lastIndex=0;(t=n.exec(e))!==null;){let n=e.slice(Math.max(0,t.index-65),t.index);if(r.test(n))return!0}}return!1}testSchemaAt(e,t,n){return this.__schemas__[t.toLowerCase()]?this.__schemas__[t.toLowerCase()].validate(e.slice(0,n+this.__opts__.maxLength),n,this):0}match(e){let t=[],n=this.re.get_schema_search(),r,i,a,o,s,c,l=!1,u=!1,d=!1,f=0;if(!e.length)return null;for(n.lastIndex=0,this.__opts__.fuzzyLink&&this.__schemas__[`http:`]&&(r=this.re.get_fuzzy_link_search(),r.lastIndex=0),this.__opts__.fuzzyEmail&&this.__schemas__[`mailto:`]&&(i=this.re.get_fuzzy_mail_host_search(),i.lastIndex=0,a=this.re.get_mail_name_validator());;){let p=Math.max(f-1,0);if(i&&a&&!d&&(!s||s.index<f))for(i.lastIndex<p&&(i.lastIndex=p);;){let t=i.exec(e);if(!t){d=!0,s=void 0;break}let n=a.exec(e.slice(Math.max(0,t.index-65),t.index));if(n){if(s={schema:`mailto:`,index:t.index-n[1].length,lastIndex:t.index+t[0].length},s.index>=f)break;i.lastIndex<p&&(i.lastIndex=p)}}if(r&&!u&&(!o||o.index<f))for(r.lastIndex<p&&(r.lastIndex=p);;){let t=r.exec(e);if(!t){u=!0,o=void 0;break}if(o={schema:``,index:t.index+t[1].length,lastIndex:t.index+t[0].length},o.index>=f)break;r.lastIndex<p&&(r.lastIndex=p)}let m=s;(!m||o&&(o.index<m.index||o.index===m.index&&o.lastIndex>m.lastIndex))&&(m=o);let h;if(!l)for(;;){if(!c){n.lastIndex<p&&(n.lastIndex=p);let t=n.exec(e);if(!t){l=!0;break}c={schema:t[2],index:t.index+t[1].length,lastIndex:t.index+t[0].length}}if(c.index<f){c=void 0;continue}if(m&&c.index>m.index)break;let t=c;c=void 0;let r=this.testSchemaAt(e,t.schema,t.lastIndex);if(r){h={schema:t.schema,index:t.index,lastIndex:t.lastIndex+r};break}}let g=h;if((!g||s&&(s.index<g.index||s.index===g.index&&s.lastIndex>g.lastIndex))&&(g=s),(!g||o&&(o.index<g.index||o.index===g.index&&o.lastIndex>g.lastIndex))&&(g=o),!g)break;g===s?s=void 0:g===o&&(o=void 0);let _=new ze(e,g.schema,g.index,g.lastIndex);_.schema?this.__schemas__[_.schema].normalize(_,this):this.normalize(_),t.push(_),f=g.lastIndex}return t.length?t:null}matchAtStart(e){if(!e.length)return null;let t=this.re.get_schema_at_start().exec(e);if(!t)return null;let n=this.testSchemaAt(e,t[2],t[0].length);if(!n)return null;let r=new ze(e,t[2],t.index+t[1].length,t.index+t[0].length+n);return this.__schemas__[r.schema].normalize(r,this),r}tlds(e,t=!1){return e=Array.isArray(e)?e:[e],t?this.__opts__.tlds=this.__opts__.tlds.concat(e):this.__opts__.tlds=e,this.re.set({...this.__opts__,schema_names:Object.keys(this.__schemas__)}),this}normalize(e){e.schema||(e.url=`http://${e.url}`),e.schema===`mailto:`&&!/^mailto:/i.test(e.url)&&(e.url=`mailto:${e.url}`)}},Ve=0x7fffffff,He=36,Ue=1,We=26,Ge=38,Ke=700,qe=72,Je=128,Ye=`-`,Xe=/^xn--/,Ze=/[^\0-\x7F]/,Qe=/[\x2E\u3002\uFF0E\uFF61]/g,$e={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},et=35,tt=Math.floor,nt=String.fromCharCode;function rt(e){throw RangeError($e[e])}function it(e,t){let n=[],r=e.length;for(;r--;)n[r]=t(e[r]);return n}function at(e,t){let n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(Qe,`.`);let i=it(e.split(`.`),t).join(`.`);return r+i}function ot(e){let t=[],n=0,r=e.length;for(;n<r;){let i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){let r=e.charCodeAt(n++);(r&64512)==56320?t.push(((i&1023)<<10)+(r&1023)+65536):(t.push(i),n--)}else t.push(i)}return t}var st=e=>String.fromCodePoint(...e),ct=function(e){return e>=48&&e<58?26+(e-48):e>=65&&e<91?e-65:e>=97&&e<123?e-97:He},lt=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},ut=function(e,t,n){let r=0;for(e=n?tt(e/Ke):e>>1,e+=tt(e/t);e>455;r+=He)e=tt(e/et);return tt(r+36*e/(e+Ge))},dt=function(e){let t=[],n=e.length,r=0,i=Je,a=qe,o=e.lastIndexOf(Ye);o<0&&(o=0);for(let n=0;n<o;++n)e.charCodeAt(n)>=128&&rt(`not-basic`),t.push(e.charCodeAt(n));for(let s=o>0?o+1:0;s<n;){let o=r;for(let t=1,i=He;;i+=He){s>=n&&rt(`invalid-input`);let o=ct(e.charCodeAt(s++));o>=He&&rt(`invalid-input`),o>tt((Ve-r)/t)&&rt(`overflow`),r+=o*t;let c=i<=a?Ue:i>=a+We?We:i-a;if(o<c)break;let l=He-c;t>tt(Ve/l)&&rt(`overflow`),t*=l}let c=t.length+1;a=ut(r-o,c,o==0),tt(r/c)>Ve-i&&rt(`overflow`),i+=tt(r/c),r%=c,t.splice(r++,0,i)}return String.fromCodePoint(...t)},ft=function(e){let t=[];e=ot(e);let n=e.length,r=Je,i=0,a=qe;for(let n of e)n<128&&t.push(nt(n));let o=t.length,s=o;for(o&&t.push(Ye);s<n;){let n=Ve;for(let t of e)t>=r&&t<n&&(n=t);let c=s+1;n-r>tt((Ve-i)/c)&&rt(`overflow`),i+=(n-r)*c,r=n;for(let n of e)if(n<r&&++i>Ve&&rt(`overflow`),n===r){let e=i;for(let n=He;;n+=He){let r=n<=a?Ue:n>=a+We?We:n-a;if(e<r)break;let i=e-r,o=He-r;t.push(nt(lt(r+i%o,0))),e=tt(i/o)}t.push(nt(lt(e,0))),a=ut(i,c,s===o),i=0,++s}++i,++r}return t.join(``)},pt={version:`2.3.1`,ucs2:{decode:ot,encode:st},decode:dt,encode:ft,toASCII:function(e){return at(e,function(e){return Ze.test(e)?`xn--`+ft(e):e})},toUnicode:function(e){return at(e,function(e){return Xe.test(e)?dt(e.slice(4).toLowerCase()):e})}},mt=Object.defineProperty,ht=(e,t)=>{let n={};for(var r in e)mt(n,r,{get:e[r],enumerable:!0});return t||mt(n,Symbol.toStringTag,{value:`Module`}),n},gt=ht({arrayReplaceAt:()=>vt,asciiTrim:()=>Bt,callable:()=>_t,escapeHtml:()=>jt,escapeRE:()=>Nt,fromCodePoint:()=>bt,isMdAsciiPunct:()=>Lt,isPunctChar:()=>Ft,isPunctCharCode:()=>It,isSpace:()=>w,isValidEntityCode:()=>yt,isWhiteSpace:()=>Pt,lib:()=>Vt,normalizeReference:()=>Rt,unescapeAll:()=>Et,unescapeMd:()=>Tt});function _t(e){let t=function(...n){return Reflect.construct(e,n,new.target&&new.target!==t?new.target:e)};return Object.defineProperty(t,"name",{value:e.name}),Object.setPrototypeOf(t,e),t.prototype=e.prototype,t}function vt(e,t,n){return[].concat(e.slice(0,t),n,e.slice(t+1))}function yt(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||(e&65535)==65535||(e&65535)==65534||e>=0&&e<=8||e===11||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function bt(e){if(e>65535){e-=65536;let t=55296+(e>>10),n=56320+(e&1023);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var xt=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,St=RegExp(`${xt.source}|&([a-z#][a-z0-9]{1,31});`,`gi`),Ct=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function wt(e,t){if(t.charCodeAt(0)===35&&Ct.test(t)){let n=t[1].toLowerCase()===`x`?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return yt(n)?bt(n):e}let n=je(e);return n===e?e:n}function Tt(e){return e.indexOf(`\\`)<0?e:e.replace(xt,`$1`)}function Et(e){return e.indexOf(`\\`)<0&&e.indexOf(`&`)<0?e:e.replace(St,function(e,t,n){return t||wt(e,n)})}var Dt=/[&<>"]/,Ot=/[&<>"]/g,kt={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`};function At(e){return kt[e]}function jt(e){return Dt.test(e)?e.replace(Ot,At):e}var Mt=/[.?*+^$[\]\\(){}|-]/g;function Nt(e){return e.replace(Mt,`\\$&`)}function w(e){switch(e){case 9:case 32:return!0}return!1}function Pt(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function Ft(e){return ae.test(e)||oe.test(e)}function It(e){return Ft(bt(e))}function Lt(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function Rt(e){return e=e.trim().replace(/\s+/g,` `),e.toLowerCase().toUpperCase()}function zt(e){return e===32||e===9||e===10||e===13}function Bt(e){let t=0;for(;t<e.length&&zt(e.charCodeAt(t));t++);let n=e.length-1;for(;n>=t&&zt(e.charCodeAt(n));n--);return e.slice(t,n+1)}var Vt={mdurl:ee,ucmicro:te};function Ht(e,t,n){let r,i,a,o,s=e.posMax,c=e.pos;for(e.pos=t+1,r=1;e.pos<s;){if(a=e.src.charCodeAt(e.pos),a===93&&(r--,r===0)){i=!0;break}if(o=e.pos,e.md.inline.skipToken(e),a===91){if(o===e.pos-1)r++;else if(n)return e.pos=c,-1}}let l=-1;return i&&(l=e.pos),e.pos=c,l}function Ut(e,t,n){let r,i=t,a={ok:!1,pos:0,str:``};if(e.charCodeAt(i)===60){for(i++;i<n;){if(r=e.charCodeAt(i),r===10||r===60)return a;if(r===62)return a.pos=i+1,a.str=Et(e.slice(t+1,i)),a.ok=!0,a;r===92&&i+1<n?i+=2:i++}return a}let o=0;for(;i<n&&(r=e.charCodeAt(i),!(r===32||r<32||r===127));)if(r===92&&i+1<n){if(e.charCodeAt(i+1)===32){i++;continue}i+=2}else{if(r===40&&(o++,o>32))return a;if(r===41){if(o===0)break;o--}i++}return t===i||o!==0||(a.str=Et(e.slice(t,i)),a.pos=i,a.ok=!0),a}function Wt(e,t,n,r){let i,a=t,o={ok:!1,can_continue:!1,pos:0,str:``,marker:0};if(r)o.str=r.str,o.marker=r.marker;else{if(a>=n)return o;let r=e.charCodeAt(a);if(r!==34&&r!==39&&r!==40)return o;t++,a++,r===40&&(r=41),o.marker=r}for(;a<n;){if(i=e.charCodeAt(a),i===o.marker)return o.pos=a+1,o.str+=Et(e.slice(t,a)),o.ok=!0,o;if(i===40&&o.marker===41)return o;i===92&&a+1<n&&a++,a++}return o.can_continue=!0,o.str+=Et(e.slice(t,a)),o}var Gt=ht({parseLinkDestination:()=>Ut,parseLinkLabel:()=>Ht,parseLinkTitle:()=>Wt});function Kt(e){"@babel/helpers - typeof";return Kt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Kt(e)}function qt(e,t){if(Kt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Kt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Jt(e){var t=qt(e,`string`);return Kt(t)==`symbol`?t:t+``}function T(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Yt=class{constructor(e,t,n){T(this,`map`,null),T(this,`level`,0),T(this,`children`,null),T(this,`content`,``),T(this,`markup`,``),T(this,`info`,``),T(this,`block`,!1),T(this,`hidden`,!1),this.type=e,this.tag=t,this.attrs=null,this.nesting=n,this.meta=null}attrIndex(e){if(!this.attrs)return-1;let t=this.attrs;for(let n=0,r=t.length;n<r;n++)if(t[n][0]===e)return n;return-1}attrPush(e){this.attrs?this.attrs.push(e):this.attrs=[e]}attrSet(e,t){let n=this.attrIndex(e),r=[e,t];n<0?this.attrPush(r):this.attrs[n]=r}attrGet(e){let t=this.attrIndex(e),n=null;return t>=0&&(n=this.attrs[t][1]),n}attrJoin(e,t){let n=this.attrIndex(e);n<0?this.attrPush([e,t]):this.attrs[n][1]=`${this.attrs[n][1]} ${t}`}},Xt=class{constructor(){T(this,`__rules__`,[]),T(this,`__cache__`,null)}__find__(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1}__compile__(){let e=new Set;this.__rules__.forEach(t=>{t.enabled&&t.alt.forEach(t=>{t&&e.add(t)})}),this.__cache__=Object.create(null),this.__cache__[``]=[],this.__rules__.forEach(e=>{e.enabled&&this.__cache__[``].push(e.fn)}),e.forEach(e=>{this.__cache__[e]=[],this.__rules__.forEach(t=>{t.enabled&&t.alt.indexOf(e)>=0&&this.__cache__[e].push(t.fn)})})}at(e,t,n={}){let r=this.__find__(e);if(r===-1)throw Error(`Parser rule not found: ${e}`);this.__rules__[r].fn=t,this.__rules__[r].alt=n.alt||[],this.__cache__=null}before(e,t,n,r={}){let i=this.__find__(e);if(i===-1)throw Error(`Parser rule not found: ${e}`);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:n,alt:r.alt||[]}),this.__cache__=null}after(e,t,n,r={}){let i=this.__find__(e);if(i===-1)throw Error(`Parser rule not found: ${e}`);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:n,alt:r.alt||[]}),this.__cache__=null}push(e,t,n={}){this.__rules__.push({name:e,enabled:!0,fn:t,alt:n.alt||[]}),this.__cache__=null}enable(e,t=!1){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(e=>{let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name ${e}`)}this.__rules__[r].enabled=!0,n.push(e)}),this.__cache__=null,n}enableOnly(e,t=!1){Array.isArray(e)||(e=[e]),this.__rules__.forEach(e=>{e.enabled=!1}),this.enable(e,t)}disable(e,t=!1){Array.isArray(e)||(e=[e]);let n=[];return e.forEach(e=>{let r=this.__find__(e);if(r<0){if(t)return;throw Error(`Rules manager: invalid rule name ${e}`)}this.__rules__[r].enabled=!1,n.push(e)}),this.__cache__=null,n}getRules(e){return this.__cache__||this.__compile__(),this.__cache__[e]||[]}},Zt={};Zt.code_inline=function(e,t,n,r,i){let a=e[t];return`<code${i.renderAttrs(a)}>${jt(a.content)}</code>`},Zt.code_block=function(e,t,n,r,i){let a=e[t];return`<pre${i.renderAttrs(a)}><code>${jt(e[t].content)}</code></pre>\n`},Zt.fence=function(e,t,n,r,i){let a=e[t],o=a.info?Et(a.info).trim():``,s=``,c=``;if(o){let e=o.split(/(\s+)/g);s=e[0],c=e.slice(2).join(``)}let l;if(l=n.highlight&&n.highlight(a.content,s,c)||jt(a.content),l.indexOf(`<pre`)===0)return l+`
3
+ `;if(o){let e=a.attrIndex(`class`),t=a.attrs?a.attrs.slice():[];e<0?t.push([`class`,`${n.langPrefix}${s}`]):(t[e]=[t[e][0],t[e][1]],t[e][1]+=` ${n.langPrefix}${s}`);let r={attrs:t};return`<pre><code${i.renderAttrs(r)}>${l}</code></pre>\n`}return`<pre><code${i.renderAttrs(a)}>${l}</code></pre>\n`},Zt.image=function(e,t,n,r,i){let a=e[t];return a.attrs[a.attrIndex(`alt`)][1]=i.renderInlineAsText(a.children,n,r),i.renderToken(e,t,n)},Zt.hardbreak=function(e,t,n){return n.xhtmlOut?`<br />
4
+ `:`<br>
5
+ `},Zt.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?`<br />
6
+ `:`<br>
7
+ `:`
8
+ `},Zt.text=function(e,t){return jt(e[t].content)},Zt.html_block=function(e,t){return e[t].content},Zt.html_inline=function(e,t){return e[t].content};var Qt=class{constructor(){T(this,`rules`,Object.assign({},Zt))}renderAttrs(e){let t,n,r;if(!e.attrs)return``;for(r=``,t=0,n=e.attrs.length;t<n;t++)r+=` ${jt(e.attrs[t][0])}="${jt(String(e.attrs[t][1]))}"`;return r}renderToken(e,t,n){let r=e[t],i=``;if(r.hidden)return``;let a=t-1;for(;a>=0&&e[a].hidden&&e[a].nesting===0;)a--;r.block&&r.nesting!==-1&&a>=0&&e[a].hidden&&e[a].nesting===-1&&(i+=`
9
+ `),i+=(r.nesting===-1?`</`:`<`)+r.tag,i+=this.renderAttrs(r),r.nesting===0&&n.xhtmlOut&&(i+=` /`);let o=!1;if(r.block&&(o=!0,r.nesting===1)){let n=t+1;for(;n<e.length&&e[n].hidden&&e[n].nesting===0;)n++;if(n<e.length){let t=e[n];(t.type===`inline`||t.hidden||t.nesting===-1&&t.tag===r.tag)&&(o=!1)}}return i+=o?`>
10
+ `:`>`,i}renderInline(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;i[o]===void 0?r+=this.renderToken(e,a,t):r+=i[o](e,a,t,n,this)}return r}renderInlineAsText(e,t,n){let r=``;for(let i=0,a=e.length;i<a;i++)switch(e[i].type){case`text`:case`code_inline`:r+=e[i].content;break;case`image`:r+=this.renderInlineAsText(e[i].children,t,n);break;case`html_inline`:case`html_block`:r+=e[i].content;break;case`softbreak`:case`hardbreak`:r+=`
11
+ `}return r}render(e,t,n){let r=``,i=this.rules;for(let a=0,o=e.length;a<o;a++){let o=e[a].type;o===`inline`?r+=this.renderInline(e[a].children,t,n):i[o]===void 0?r+=this.renderToken(e,a,t):r+=i[o](e,a,t,n,this)}return r}},$t=class{constructor(e,t,n){T(this,`tokens`,[]),T(this,`inlineMode`,!1),T(this,`Token`,Yt),this.src=e,this.env=n,this.md=t}},en=/\r\n?/g,tn=/\0/g;function nn(e){let t;t=e.src.replace(en,`
12
+ `),t=t.replace(tn,`�`),e.src=t}function rn(e){let t;e.inlineMode?(t=new e.Token(`inline`,``,0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}function an(e){let t=e.tokens,n=0;for(let e=0;e<t.length;e++)t[e].type!==`reference_definition`&&(e!==n&&(t[n]=t[e]),n++);t.length!==n&&(t.length=n)}function on(e){let t=e.tokens;for(let n=0,r=t.length;n<r;n++){let r=t[n];r.type===`inline`&&e.md.inline.parse(r.content,e.md,e.env,r.children)}}function sn(e){return/^<a[>\s]/i.test(e)}function cn(e){return/^<\/a\s*>/i.test(e)}function ln(e){let t=e.tokens;if(e.md.options.linkify)for(let n=0,r=t.length;n<r;n++){if(t[n].type!==`inline`||!e.md.linkify.test(t[n].content))continue;let r=t[n].children,i=[],a=0;for(let t=r.length-1;t>=0;t--){let n=r[t];if(n.type===`link_close`)for(t--;r[t].level!==n.level&&r[t].type!==`link_open`;)t--;else if(n.type===`html_inline`&&(sn(n.content)&&a>0&&a--,cn(n.content)&&a++),!(a>0)&&n.type===`text`&&e.md.linkify.test(n.content)){let a=n.content,o=e.md.linkify.match(a),s=[],c=n.level,l=0;o.length>0&&o[0].index===0&&t>0&&r[t-1].type===`text_special`&&(o=o.slice(1));for(let t=0;t<o.length;t++){let n=o[t].url,r=e.md.normalizeLink(n);if(!e.md.validateLink(r))continue;let i=o[t].text;i=o[t].schema?o[t].schema===`mailto:`&&!/^mailto:/i.test(i)?e.md.normalizeLinkText(`mailto:${i}`).replace(/^mailto:/,``):e.md.normalizeLinkText(i):e.md.normalizeLinkText(`http://${i}`).replace(/^http:\/\//,``);let u=o[t].index;if(u>l){let t=new e.Token(`text`,``,0);t.content=a.slice(l,u),t.level=c,s.push(t)}let d=new e.Token(`link_open`,`a`,1);d.attrs=[[`href`,r]],d.level=c++,d.markup=`linkify`,d.info=`auto`,s.push(d);let f=new e.Token(`text`,``,0);f.content=i,f.level=c,s.push(f);let p=new e.Token(`link_close`,`a`,-1);p.level=--c,p.markup=`linkify`,p.info=`auto`,s.push(p),l=o[t].lastIndex}if(l<a.length){let t=new e.Token(`text`,``,0);t.content=a.slice(l),t.level=c,s.push(t)}i.push({index:t,nodes:s})}}if(i.length>0){let e=r.length;for(let t of i)e+=t.nodes.length-1;let a=Array(e),o=0,s=0;i.reverse();for(let e=0;e<r.length;e++){let t=i[o];if(t?.index===e){for(let e of t.nodes)a[s++]=e;o++}else a[s++]=r[e]}t[n].children=a}}}var un=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,dn=/\((c|tm|r)\)/i,fn=/\((c|tm|r)\)/gi,pn={c:`©`,r:`®`,tm:`™`};function mn(e,t){return pn[t.toLowerCase()]}function hn(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&(r.content=r.content.replace(fn,mn)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function gn(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];r.type===`text`&&!t&&un.test(r.content)&&(r.content=r.content.replace(/\+-/g,`±`).replace(/\.{2,}/g,`…`).replace(/([?!])…/g,`$1..`).replace(/([?!]){4,}/g,`$1$1$1`).replace(/,{2,}/g,`,`).replace(/(^|[^-])---(?=[^-]|$)/gm,`$1—`).replace(/(^|\s)--(?=\s|$)/gm,`$1–`).replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,`$1–`)),r.type===`link_open`&&r.info===`auto`&&t--,r.type===`link_close`&&r.info===`auto`&&t++}}function _n(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&(dn.test(e.tokens[t].content)&&hn(e.tokens[t].children),un.test(e.tokens[t].content)&&gn(e.tokens[t].children))}var vn=/['"]/,yn=/['"]/g,bn=`’`,xn=1e3;function Sn(e,t,n){for(;e.length>n;){let n=e.pop();n.isSingleQuote?t.single=n.prevSameQuoteIdx:t.double=n.prevSameQuoteIdx}}function Cn(e,t,n,r){e[t]||(e[t]=[]),e[t].push({pos:n,ch:r})}function wn(e,t){let n=``,r=0;t.sort((e,t)=>e.pos-t.pos);for(let i=0;i<t.length;i++){let a=t[i];n+=e.slice(r,a.pos)+a.ch,r=a.pos+1}return n+e.slice(r)}function Tn(e,t){let n,r=[],i={single:-1,double:-1},a={};for(let o=0;o<e.length;o++){let s=e[o],c=e[o].level;for(n=r.length-1;n>=0&&!(r[n].level<=c);n--);if(Sn(r,i,n+1),s.type!==`text`)continue;let l=s.content,u=0,d=l.length;for(;u<d;){yn.lastIndex=u;let s=yn.exec(l);if(!s)break;let f=!0,p=!0;u=s.index+1;let m=s[0]===`'`,h=32;if(s.index-1>=0)h=l.charCodeAt(s.index-1);else for(n=o-1;n>=0&&e[n].type!==`softbreak`&&e[n].type!==`hardbreak`;n--)if(e[n].content){h=e[n].content.charCodeAt(e[n].content.length-1);break}let g=32;if(u<d)g=l.charCodeAt(u);else for(n=o+1;n<e.length&&e[n].type!==`softbreak`&&e[n].type!==`hardbreak`;n++)if(e[n].content){g=e[n].content.charCodeAt(0);break}let _=Lt(h)||It(h),v=Lt(g)||It(g),y=Pt(h),b=Pt(g);if(b?f=!1:v&&(y||_||(f=!1)),y?p=!1:_&&(b||v||(p=!1)),g===34&&s[0]===`"`&&h>=48&&h<=57&&(p=f=!1),f&&p&&(f=_,p=v),!f&&!p)m&&Cn(a,o,s.index,bn);else{if(p&&(n=m?i.single:i.double,n>=0&&r[n].level===c)){let e=r[n],c,l;m?(c=t.md.options.quotes[2],l=t.md.options.quotes[3]):(c=t.md.options.quotes[0],l=t.md.options.quotes[1]),Cn(a,o,s.index,l),Cn(a,e.tokenIdx,e.contentPos,c),Sn(r,i,n);continue}if(f){if(r.length>=xn)return;r.push({tokenIdx:o,contentPos:s.index,isSingleQuote:m,level:c,prevSameQuoteIdx:m?i.single:i.double}),m?i.single=r.length-1:i.double=r.length-1}else p&&m&&Cn(a,o,s.index,bn)}}}Object.keys(a).forEach(function(t){let n=Number(t);e[n].content=wn(e[n].content,a[t])})}function En(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)e.tokens[t].type===`inline`&&vn.test(e.tokens[t].content)&&Tn(e.tokens[t].children,e)}function Dn(e){let t,n,r=e.length;for(t=0;t<r;t++)e[t].type===`text_special`&&(e[t].type=`text`);for(t=n=0;t<r;t++)e[t].type===`text`&&t+1<r&&e[t+1].type===`text`?e[t+1].content=e[t].content+e[t+1].content:(t!==n&&(e[n]=e[t]),n++);t!==n&&(e.length=n)}function On(e){let t,n,r=e.tokens,i=r.length;for(let e=0;e<i;e++){if(r[e].type!==`inline`)continue;let i=r[e].children,a=i.length;for(t=0;t<a;t++)i[t].type===`text_special`&&(i[t].type=`text`),i[t].children&&Dn(i[t].children);for(t=n=0;t<a;t++)i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}}var kn=[[`normalize`,nn],[`block`,rn],[`strip_references`,an],[`inline`,on],[`linkify`,ln],[`replacements`,_n],[`smartquotes`,En],[`text_join`,On]],An=class{constructor(){T(this,`ruler`,new Xt),T(this,`State`,$t);for(let e=0;e<kn.length;e++)this.ruler.push(kn[e][0],kn[e][1])}process(e){let t=this.ruler.getRules(``);for(let n=0,r=t.length;n<r;n++)t[n](e)}},jn=class{constructor(e,t,n,r){T(this,`bMarks`,[]),T(this,`eMarks`,[]),T(this,`tShift`,[]),T(this,`sCount`,[]),T(this,`bsCount`,[]),T(this,`blkIndent`,0),T(this,`line`,0),T(this,`lineMax`,0),T(this,`tight`,!1),T(this,`listIndent`,-1),T(this,`parentType`,`root`),T(this,`level`,0),T(this,`Token`,Yt),this.src=e,this.md=t,this.env=n,this.tokens=r;let i=this.src;for(let e=0,t=0,n=0,r=0,a=i.length,o=!1;t<a;t++){let s=i.charCodeAt(t);if(!o){if(w(s)){n++,s===9?r+=4-r%4:r++;continue}o=!0}(s===10||t===a-1)&&(s!==10&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(n),this.sCount.push(r),this.bsCount.push(0),o=!1,n=0,r=0,e=t+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}push(e,t,n){let r=new Yt(e,t,n);return r.block=!0,n<0&&this.level--,r.level=this.level,n>0&&this.level++,this.tokens.push(r),r}isEmpty(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]}skipEmptyLines(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e}skipSpaces(e){for(let t=this.src.length;e<t&&w(this.src.charCodeAt(e));e++);return e}skipSpacesBack(e,t){if(e<=t)return e;for(;e>t;)if(!w(this.src.charCodeAt(--e)))return e+1;return e}skipChars(e,t){for(let n=this.src.length;e<n&&this.src.charCodeAt(e)===t;e++);return e}skipCharsBack(e,t,n){if(e<=n)return e;for(;e>n;)if(t!==this.src.charCodeAt(--e))return e+1;return e}getLines(e,t,n,r){if(e>=t)return``;let i=Array(t-e);for(let a=0,o=e;o<t;o++,a++){let e=0,s=this.bMarks[o],c=s,l;for(l=o+1<t||r?this.eMarks[o]+1:this.eMarks[o];c<l&&e<n;){let t=this.src.charCodeAt(c);if(w(t))t===9?e+=4-(e+this.bsCount[o])%4:e++;else if(c-s<this.tShift[o])e++;else break;c++}e>n?i[a]=Array(e-n+1).join(` `)+this.src.slice(c,l):i[a]=this.src.slice(c,l)}return i.join(``)}},Mn=65536;function Nn(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(n,r)}function Pn(e){let t=[],n=e.length,r=0,i=e.charCodeAt(r),a=!1,o=0,s=``;for(;r<n;)i===124&&(a?(s+=e.substring(o,r-1),o=r):(t.push(s+e.substring(o,r)),s=``,o=r+1)),a=i===92,r++,i=e.charCodeAt(r);return t.push(s+e.substring(o)),t}function Fn(e,t,n,r){if(t+2>n)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent||e.sCount[i]-e.blkIndent>=4)return!1;let a=e.bMarks[i]+e.tShift[i];if(a>=e.eMarks[i])return!1;let o=e.src.charCodeAt(a++);if(o!==124&&o!==45&&o!==58||a>=e.eMarks[i])return!1;let s=e.src.charCodeAt(a++);if(s!==124&&s!==45&&s!==58&&!w(s)||o===45&&w(s))return!1;for(;a<e.eMarks[i];){let t=e.src.charCodeAt(a);if(t!==124&&t!==45&&t!==58&&!w(t))return!1;a++}let c=Nn(e,t+1),l=c.split(`|`),u=[];for(let e=0;e<l.length;e++){let t=l[e].trim();if(!t){if(e===0||e===l.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;t.charCodeAt(t.length-1)===58?u.push(t.charCodeAt(0)===58?`center`:`right`):t.charCodeAt(0)===58?u.push(`left`):u.push(``)}if(c=Nn(e,t).trim(),c.indexOf(`|`)===-1||e.sCount[t]-e.blkIndent>=4)return!1;l=Pn(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop();let d=l.length;if(d===0||d!==u.length)return!1;if(r)return!0;let f=e.parentType;e.parentType=`table`;let p=e.md.block.ruler.getRules(`blockquote`),m=e.push(`table_open`,`table`,1),h=[t,0];m.map=h;let g=e.push(`thead_open`,`thead`,1);g.map=[t,t+1];let _=e.push(`tr_open`,`tr`,1);_.map=[t,t+1];for(let t=0;t<l.length;t++){let n=e.push(`th_open`,`th`,1);u[t]&&(n.attrs=[[`style`,`text-align:${u[t]}`]]);let r=e.push(`inline`,``,0);r.content=l[t].trim(),r.children=[],e.push(`th_close`,`th`,-1)}e.push(`tr_close`,`tr`,-1),e.push(`thead_close`,`thead`,-1);let v,y=0;for(i=t+2;i<n&&!(e.sCount[i]<e.blkIndent);i++){let r=!1;for(let t=0,a=p.length;t<a;t++)if(p[t](e,i,n,!0)){r=!0;break}if(r||(c=Nn(e,i).trim(),!c)||e.sCount[i]-e.blkIndent>=4||(l=Pn(c),l.length&&l[0]===``&&l.shift(),l.length&&l[l.length-1]===``&&l.pop(),y+=d-l.length,y>Mn))break;if(i===t+2){let n=e.push(`tbody_open`,`tbody`,1);n.map=v=[t+2,0]}let a=e.push(`tr_open`,`tr`,1);a.map=[i,i+1];for(let t=0;t<d;t++){let n=e.push(`td_open`,`td`,1);u[t]&&(n.attrs=[[`style`,`text-align:${u[t]}`]]);let r=e.push(`inline`,``,0);r.content=l[t]?l[t].trim():``,r.children=[],e.push(`td_close`,`td`,-1)}e.push(`tr_close`,`tr`,-1)}return v&&(e.push(`tbody_close`,`tbody`,-1),v[1]=i),e.push(`table_close`,`table`,-1),h[1]=i,e.parentType=f,e.line=i,!0}function In(e,t,n){if(e.sCount[t]-e.blkIndent<4)return!1;let r=t+1,i=r;for(;r<n;)if(e.isEmpty(r))r++;else if(e.sCount[r]-e.blkIndent>=4)r++,i=r;else break;e.line=i;let a=e.push(`code_block`,`code`,0);return a.content=e.getLines(t,i,4+e.blkIndent,!1)+`
13
+ `,a.map=[t,e.line],!0}function Ln(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||i+3>a)return!1;let o=e.src.charCodeAt(i);if(o!==126&&o!==96)return!1;let s=i;i=e.skipChars(i,o);let c=i-s;if(c<3)return!1;let l=e.src.slice(s,i),u=e.src.slice(i,a);if(o===96&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(r)return!0;let d=t,f=!1;for(;d++,!(d>=n||(i=s=e.bMarks[d]+e.tShift[d],a=e.eMarks[d],i<a&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4)&&(i=e.skipChars(i,o),!(i-s<c)&&(i=e.skipSpaces(i),!(i<a)))){f=!0;break}c=e.sCount[t],e.line=d+ +!!f;let p=e.push(`fence`,`code`,0);return p.info=u,p.content=e.getLines(t+1,d,c,!0),p.markup=l,p.map=[t,e.line],!0}function Rn(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t],o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4||e.src.charCodeAt(i)!==62)return!1;if(r)return!0;let s=[],c=[],l=[],u=[],d=e.md.block.ruler.getRules(`blockquote`),f=e.parentType;e.parentType=`blockquote`;let p=!1,m;for(m=t;m<n;m++){let t=e.sCount[m]<e.blkIndent;if(i=e.bMarks[m]+e.tShift[m],a=e.eMarks[m],i>=a)break;if(e.src.charCodeAt(i++)===62&&!t){let t=e.sCount[m]+1,n,r;e.src.charCodeAt(i)===32?(i++,t++,r=!1,n=!0):e.src.charCodeAt(i)===9?(n=!0,(e.bsCount[m]+t)%4==3?(i++,t++,r=!1):r=!0):n=!1;let o=t;for(s.push(e.bMarks[m]),e.bMarks[m]=i;i<a;){let t=e.src.charCodeAt(i);if(w(t))t===9?o+=4-(o+e.bsCount[m]+ +!!r)%4:o++;else break;i++}p=i>=a,c.push(e.bsCount[m]),e.bsCount[m]=e.sCount[m]+1+ +!!n,l.push(e.sCount[m]),e.sCount[m]=o-t,u.push(e.tShift[m]),e.tShift[m]=i-e.bMarks[m];continue}if(p)break;let r=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,m,n,!0)){r=!0;break}if(r){e.lineMax=m,e.blkIndent!==0&&(s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]-=e.blkIndent);break}s.push(e.bMarks[m]),c.push(e.bsCount[m]),u.push(e.tShift[m]),l.push(e.sCount[m]),e.sCount[m]=-1}let h=e.blkIndent;e.blkIndent=0;let g=e.push(`blockquote_open`,`blockquote`,1);g.markup=`>`;let _=[t,0];g.map=_,e.md.block.tokenize(e,t,m);let v=e.push(`blockquote_close`,`blockquote`,-1);v.markup=`>`,e.lineMax=o,e.parentType=f,_[1]=e.line;for(let n=0;n<u.length;n++)e.bMarks[n+t]=s[n],e.tShift[n+t]=u[n],e.sCount[n+t]=l[n],e.bsCount[n+t]=c[n];return e.blkIndent=h,!0}function zn(e,t,n,r){let i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let a=e.bMarks[t]+e.tShift[t],o=e.src.charCodeAt(a++);if(o!==42&&o!==45&&o!==95)return!1;let s=1;for(;a<i;){let t=e.src.charCodeAt(a++);if(t!==o&&!w(t))return!1;t===o&&s++}if(s<3)return!1;if(r)return!0;e.line=t+1;let c=e.push(`hr`,`hr`,0);return c.map=[t,e.line],c.markup=Array(s+1).join(String.fromCharCode(o)),!0}function Bn(e,t){let n=e.eMarks[t],r=e.bMarks[t]+e.tShift[t],i=e.src.charCodeAt(r++);return i!==42&&i!==45&&i!==43||r<n&&!w(e.src.charCodeAt(r))?-1:r}function Vn(e,t){let n=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],i=n;if(i+1>=r)return-1;let a=e.src.charCodeAt(i++);if(a<48||a>57)return-1;for(;;){if(i>=r)return-1;if(a=e.src.charCodeAt(i++),a>=48&&a<=57){if(i-n>=10)return-1}else{if(a===41||a===46)break;return-1}}return i<r&&(a=e.src.charCodeAt(i),!w(a))?-1:i}function Hn(e,t){let n=e.level+2;for(let r=t+2,i=e.tokens.length-2;r<i;r++)e.tokens[r].level===n&&e.tokens[r].type===`paragraph_open`&&(e.tokens[r+2].hidden=!0,e.tokens[r].hidden=!0,r+=2)}function Un(e,t,n,r){let i,a,o,s,c=t,l=!0;if(e.sCount[c]-e.blkIndent>=4||e.listIndent>=0&&e.sCount[c]-e.listIndent>=4&&e.sCount[c]<e.blkIndent)return!1;let u=!1;r&&e.parentType===`paragraph`&&e.sCount[c]>=e.blkIndent&&(u=!0);let d,f,p;if((p=Vn(e,c))>=0){if(d=!0,o=e.bMarks[c]+e.tShift[c],f=Number(e.src.slice(o,p-1)),u&&f!==1)return!1}else if((p=Bn(e,c))>=0)d=!1;else return!1;if(u&&e.skipSpaces(p)>=e.eMarks[c])return!1;if(r)return!0;let m=e.src.charCodeAt(p-1),h=e.tokens.length;d?(s=e.push(`ordered_list_open`,`ol`,1),f!==1&&(s.attrs=[[`start`,f]])):s=e.push(`bullet_list_open`,`ul`,1);let g=[c,0];s.map=g,s.markup=String.fromCharCode(m);let _=!1,v=e.md.block.ruler.getRules(`list`),y=e.parentType;for(e.parentType=`list`;c<n;){a=p,i=e.eMarks[c];let t=e.sCount[c]+p-(e.bMarks[c]+e.tShift[c]),r=t;for(;a<i;){let t=e.src.charCodeAt(a);if(t===9)r+=4-(r+e.bsCount[c])%4;else if(t===32)r++;else break;a++}let u=a,f;f=u>=i?1:r-t,f>4&&(f=1);let h=t+f;s=e.push(`list_item_open`,`li`,1),s.markup=String.fromCharCode(m);let g=[c,0];s.map=g,d&&(s.info=e.src.slice(o,p-1));let y=e.tight,b=e.tShift[c],x=e.sCount[c],ee=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=h,e.tight=!0,e.tShift[c]=u-e.bMarks[c],e.sCount[c]=r,u>=i&&e.isEmpty(c+1)?e.line=Math.min(e.line+2,n):e.md.block.tokenize(e,c,n),(!e.tight||_)&&(l=!1),_=e.line-c>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=ee,e.tShift[c]=b,e.sCount[c]=x,e.tight=y,s=e.push(`list_item_close`,`li`,-1),s.markup=String.fromCharCode(m),c=e.line,g[1]=c,c>=n||e.sCount[c]<e.blkIndent||e.sCount[c]-e.blkIndent>=4)break;let te=!1;for(let t=0,r=v.length;t<r;t++)if(v[t](e,c,n,!0)){te=!0;break}if(te)break;if(d){if(p=Vn(e,c),p<0)break;o=e.bMarks[c]+e.tShift[c]}else if(p=Bn(e,c),p<0)break;if(m!==e.src.charCodeAt(p-1))break}return s=d?e.push(`ordered_list_close`,`ol`,-1):e.push(`bullet_list_close`,`ul`,-1),s.markup=String.fromCharCode(m),g[1]=c,e.line=c,e.parentType=y,l&&Hn(e,h),!0}var Wn=999;function Gn(e){let t=e.length;for(let n=0;n<e.length-1;n++){let r=e.charCodeAt(n);if(r<55296||r>56319)continue;let i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(t--,n++)}return t}function Kn(e,t){return Math.min(e.eMarks[t]+1,e.src.length)}function qn(e,t){let n=e.lineMax;if(t>=n||e.isEmpty(t))return-1;let r=!1;if(e.sCount[t]-e.blkIndent>3&&(r=!0),e.sCount[t]<0&&(r=!0),!r){let r=e.md.block.ruler.getRules(`reference`),i=e.parentType;e.parentType=`reference`;let a=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,t,n,!0)){a=!0;break}if(e.parentType=i,a)return-1}return e.bMarks[t]+e.tShift[t]}function Jn(e,t,n,r){let i=e.src,a=e.bMarks[t]+e.tShift[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4||i.charCodeAt(a)!==91)return!1;let s=Kn(e,t),c=``,l=-1,u=++a;for(;a<s;){if(c.length+a-u>Wn*2)return!1;let t=i.charCodeAt(a);if(t===91)return!1;if(t===93){l=a;break}if(t===92&&(t=i.charCodeAt(++a)),t===10&&a<s){let t=qn(e,o);if(t<0)return!1;c+=i.slice(u,s),a=u=t,s=Kn(e,o++)}else a++}if(l<0||i.charCodeAt(l+1)!==58||(c+=i.slice(u,l),c.length>Wn&&Gn(c)>Wn))return!1;for(a=l+2;a<s;){let t=i.charCodeAt(a);if(t===10){let t=qn(e,o);if(t<0)break;a=t,s=Kn(e,o++)}else if(w(t))a++;else break}let d=e.md.helpers.parseLinkDestination(i,a,s);if(!d.ok)return!1;let f=e.md.normalizeLink(d.str);if(!e.md.validateLink(f))return!1;a=d.pos;let p=a,m=s,h=o;for(;a<s;){let t=i.charCodeAt(a);if(t===10){let t=qn(e,o);if(t<0)break;a=t,s=Kn(e,o++)}else if(w(t))a++;else break}let g=a,_=e.md.helpers.parseLinkTitle(i,a,s);for(;_.can_continue;){let t=qn(e,o);if(t<0)break;a=t,s=Kn(e,o++),_=e.md.helpers.parseLinkTitle(i,a,s,_)}let v;for(g!==p&&_.ok?(v=_.str,a=_.pos):(v=``,a=p,s=m,o=h);a<s&&w(i.charCodeAt(a));)a++;if(a<s&&i.charCodeAt(a)!==10&&v)for(v=``,a=p,s=m,o=h;a<s&&w(i.charCodeAt(a));)a++;if(a<s&&i.charCodeAt(a)!==10)return!1;let y=Rt(c);if(!y)return!1;if(r)return!0;e.env.references===void 0&&(e.env.references={}),e.env.references[y]===void 0&&(e.env.references[y]={title:v,href:f});let b=e.push(`reference_definition`,``,0);b.map=[t,o],b.hidden=!0;let x=Object.create(null);return x.label=y,b.meta=x,e.line=o,!0}var Yn=`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.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),Xn=`<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^"'=<>\`\\x00-\\x20]+|'[^']*'|"[^"]*"))?)*\\s*\\/?>`,Zn=`<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>`;RegExp(`^(?:${Xn}|${Zn}|<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)`);var Qn=RegExp(`^(?:${Xn}|${Zn})`),$n=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Za-z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[RegExp(`^</?(${Yn.join(`|`)})(?=(\\s|/?>|$))`,`i`),/^$/,!0],[RegExp(`${Qn.source}\\s*$`),/^$/,!1]];function er(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4||!e.md.options.html||e.src.charCodeAt(i)!==60)return!1;let o=e.src.slice(i,a),s=0;for(;s<$n.length&&!$n[s][0].test(o);s++);if(s===$n.length)return!1;if(r)return $n[s][2];let c=t+1,l=$n[s][1].test(``);if(!$n[s][1].test(o)){for(;c<n&&!(e.sCount[c]<e.blkIndent&&(l||!e.isEmpty(c)));c++)if(i=e.bMarks[c]+e.tShift[c],a=e.eMarks[c],o=e.src.slice(i,a),$n[s][1].test(o)){o.length!==0&&c++;break}}e.line=c;let u=e.push(`html_block`,``,0);return u.map=[t,c],u.content=e.getLines(t,c,e.blkIndent,!0),!0}function tr(e,t,n,r){let i=e.bMarks[t]+e.tShift[t],a=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(o!==35||i>=a)return!1;let s=1;for(o=e.src.charCodeAt(++i);o===35&&i<a&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<a&&!w(o))return!1;if(r)return!0;a=e.skipSpacesBack(a,i);let c=e.skipCharsBack(a,35,i);c>i&&w(e.src.charCodeAt(c-1))&&(a=c),e.line=t+1;let l=e.push(`heading_open`,`h${s}`,1);l.markup=`########`.slice(0,s),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=Bt(e.src.slice(i,a)),u.map=[t,e.line],u.children=[];let d=e.push(`heading_close`,`h${s}`,-1);return d.markup=`########`.slice(0,s),!0}function nr(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`);if(e.sCount[t]-e.blkIndent>=4)return!1;let i=e.parentType;e.parentType=`paragraph`;let a=0,o,s=t+1;for(;s<n&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s],n=e.eMarks[s];if(t<n&&(o=e.src.charCodeAt(t),(o===45||o===61)&&(t=e.skipChars(t,o),t=e.skipSpaces(t),t>=n))){a=o===61?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,a=r.length;i<a;i++)if(r[i](e,s,n,!0)){t=!0;break}if(t)break}if(!a)return e.parentType=i,!1;let c=Bt(e.getLines(t,s,e.blkIndent,!1));e.line=s+1;let l=e.push(`heading_open`,`h${a}`,1);l.markup=String.fromCharCode(o),l.map=[t,e.line];let u=e.push(`inline`,``,0);u.content=c,u.map=[t,e.line-1],u.children=[];let d=e.push(`heading_close`,`h${a}`,-1);return d.markup=String.fromCharCode(o),e.parentType=i,!0}function rr(e,t,n){let r=e.md.block.ruler.getRules(`paragraph`),i=e.parentType,a=t+1;for(e.parentType=`paragraph`;a<n&&!e.isEmpty(a);a++){if(e.sCount[a]-e.blkIndent>3||e.sCount[a]<0)continue;let t=!1;for(let i=0,o=r.length;i<o;i++)if(r[i](e,a,n,!0)){t=!0;break}if(t)break}let o=Bt(e.getLines(t,a,e.blkIndent,!1));e.line=a;let s=e.push(`paragraph_open`,`p`,1);s.map=[t,e.line];let c=e.push(`inline`,``,0);return c.content=o,c.map=[t,e.line],c.children=[],e.push(`paragraph_close`,`p`,-1),e.parentType=i,!0}var ir=[[`table`,Fn,[`paragraph`,`reference`]],[`code`,In],[`fence`,Ln,[`paragraph`,`reference`,`blockquote`,`list`]],[`blockquote`,Rn,[`paragraph`,`reference`,`blockquote`,`list`]],[`hr`,zn,[`paragraph`,`reference`,`blockquote`,`list`]],[`list`,Un,[`paragraph`,`reference`,`blockquote`]],[`reference`,Jn],[`html_block`,er,[`paragraph`,`reference`,`blockquote`]],[`heading`,tr,[`paragraph`,`reference`,`blockquote`]],[`lheading`,nr],[`paragraph`,rr]],ar=class{constructor(){T(this,`ruler`,new Xt),T(this,`State`,jn);for(let e=0;e<ir.length;e++)this.ruler.push(ir[e][0],ir[e][1],{alt:(ir[e][2]||[]).slice()})}tokenize(e,t,n){let r=this.ruler.getRules(``),i=r.length,a=e.md.options.maxNesting,o=t,s=!1;for(;o<n&&(e.line=o=e.skipEmptyLines(o),!(o>=n||e.sCount[o]<e.blkIndent));){if(e.level>=a){e.line=n;break}let t=e.line,c=!1;for(let a=0;a<i;a++)if(c=r[a](e,o,n,!1),c){if(t>=e.line)throw Error(`block rule didn't increment state.line`);break}if(!c)throw Error(`none of the block rules matched`);e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<n&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}}parse(e,t,n,r){if(!e)return;let i=new this.State(e,t,n,r);this.tokenize(i,i.line,i.lineMax)}},or=class{constructor(e,t,n,r){T(this,`pos`,0),T(this,`level`,0),T(this,`pending`,``),T(this,`pendingLevel`,0),T(this,`cache`,{}),T(this,`backticks`,{}),T(this,`backticksScanned`,!1),T(this,`skipHtmlSpecial`,!1),T(this,`linkLevel`,0),T(this,`delimiters`,[]),T(this,`_prev_delimiters`,[]),T(this,`Token`,Yt),this.src=e,this.env=n,this.md=t,this.tokens=r,this.tokens_meta=Array(r.length),this.posMax=this.src.length}pushPending(){let e=new Yt(`text`,``,0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending=``,e}push(e,t,n){this.pending&&this.pushPending();let r=new Yt(e,t,n),i;return n<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),r.level=this.level,n>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(r),this.tokens_meta.push(i),r}scanDelims(e,t){let n=this.posMax,r=this.src.charCodeAt(e),i;if(e===0)i=32;else if(e===1)i=this.src.charCodeAt(0),(i&63488)==55296&&(i=65533);else if(i=this.src.charCodeAt(e-1),(i&64512)==56320){let t=this.src.charCodeAt(e-2);i=(t&64512)==55296?65536+(t-55296<<10)+(i-56320):65533}else(i&64512)==55296&&(i=65533);let a=e;for(;a<n&&this.src.charCodeAt(a)===r;)a++;let o=a-e,s=a<n?this.src.charCodeAt(a):32;if((s&64512)==55296){let e=this.src.charCodeAt(a+1);s=(e&64512)==56320?65536+(s-55296<<10)+(e-56320):65533}else(s&64512)==56320&&(s=65533);let c=Lt(i)||It(i),l=Lt(s)||It(s),u=Pt(i),d=Pt(s),f=!d&&(!l||u||c),p=!u&&(!c||d||l);return{can_open:f&&(t||!p||c),can_close:p&&(t||!f||l),length:o}}};function sr(e){switch(e){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}function cr(e,t){let n=e.pos;for(;n<e.posMax&&!sr(e.src.charCodeAt(n));)n++;return n!==e.pos&&(t||(e.pending+=e.src.slice(e.pos,n)),e.pos=n,!0)}function lr(e){return e>=65&&e<=90||e>=97&&e<=122}function ur(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||e===43||e===45||e===46}function dr(e,t){if(!e.md.options.linkify||e.linkLevel>0)return!1;let n=e.pos,r=e.posMax;if(n+3>r||e.src.charCodeAt(n)!==58||e.src.charCodeAt(n+1)!==47||e.src.charCodeAt(n+2)!==47)return!1;let i=n-Math.min(10,e.pending.length,n),a=n;for(;a>i&&ur(e.src.charCodeAt(a-1));)a--;if(a===n||!lr(e.src.charCodeAt(a)))return!1;let o=n-a,s=e.md.linkify.matchAtStart(e.src.slice(a));if(!s)return!1;let c=s.url;if(c.length<=o)return!1;let l=c.length;for(;l>0&&c.charCodeAt(l-1)===42;)l--;l!==c.length&&(c=c.slice(0,l));let u=e.md.normalizeLink(c);if(!e.md.validateLink(u))return!1;if(!t){e.pending=e.pending.slice(0,-o);let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,u]],t.markup=`linkify`,t.info=`auto`;let n=e.push(`text`,``,0);n.content=e.md.normalizeLinkText(c);let r=e.push(`link_close`,`a`,-1);r.markup=`linkify`,r.info=`auto`}return e.pos+=c.length-o,!0}function fr(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==10)return!1;let r=e.pending.length-1,i=e.posMax;if(!t){if(r>=0&&e.pending.charCodeAt(r)===32){if(r>=1&&e.pending.charCodeAt(r-1)===32){let t=r-1;for(;t>=1&&e.pending.charCodeAt(t-1)===32;)t--;e.pending=e.pending.slice(0,t),e.push(`hardbreak`,`br`,0)}else e.pending=e.pending.slice(0,-1),e.push(`softbreak`,`br`,0)}else e.push(`softbreak`,`br`,0)}for(n++;n<i&&w(e.src.charCodeAt(n));)n++;return e.pos=n,!0}var pr=[];for(let e=0;e<256;e++)pr.push(0);`\\!"#$%&'()*+,./:;<=>?@[]^_\`{|}~-`.split(``).forEach(function(e){pr[e.charCodeAt(0)]=1});function mr(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==92||(n++,n>=r))return!1;let i=e.src.charCodeAt(n);if(i===10){for(t||e.push(`hardbreak`,`br`,0),n++;n<r&&(i=e.src.charCodeAt(n),w(i));)n++;return e.pos=n,!0}if(i===32){if(!t){let t=e.push(`text_special`,``,0);t.content=`\\`,t.markup=`\\`,t.info=`escape`}return e.pos=n,!0}let a=e.src[n];if(i>=55296&&i<=56319&&n+1<r){let t=e.src.charCodeAt(n+1);t>=56320&&t<=57343&&(a+=e.src[n+1],n++)}let o=`\\`+a;if(!t){let t=e.push(`text_special`,``,0);t.content=i<256&&pr[i]!==0?a:o,t.markup=o,t.info=`escape`}return e.pos=n+1,!0}function hr(e){let t={},n=0;for(;(n=e.indexOf("`",n))!==-1;){let r=n;for(;e.charCodeAt(++n)===96;);t[n-r]=r}return t}function gr(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==96)return!1;let r=e.posMax,i=n+1;for(;i<r&&e.src.charCodeAt(i)===96;)i++;let a=e.src.slice(n,i),o=a.length;if(e.backticksScanned||=(e.backticks=hr(e.src),!0),(e.backticks[o]??-1)>=i){let n=i,s;for(;(s=e.src.indexOf("`",n))!==-1&&s<r;){for(n=s+1;e.src.charCodeAt(n)===96;)n++;if(n>r)break;if(n-s===o){if(!t){let t=e.push(`code_inline`,`code`,0);t.markup=a;let n=e.src.slice(i,s).replace(/\n/g,` `);n.startsWith(` `)&&n.endsWith(` `)&&/[^ ]/.test(n)&&(n=n.slice(1,-1)),t.content=n}return e.pos=n,!0}}}return t||(e.pending+=a),e.pos=i,!0}function _r(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==126)return!1;let i=e.scanDelims(e.pos,!0),a=i.length,o=String.fromCharCode(r);if(a<2)return!1;let s;a%2&&(s=e.push(`text`,``,0),s.content=o,a--);for(let t=0;t<a;t+=2)s=e.push(`text`,``,0),s.content=o+o,e.delimiters.push({marker:r,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0}function vr(e,t){let n,r=[],i=t.length;for(let a=0;a<i;a++){let i=t[a];if(i.marker!==126||i.end===-1)continue;let o=t[i.end];n=e.tokens[i.token],n.type=`s_open`,n.tag=`s`,n.nesting=1,n.markup=`~~`,n.content=``,n=e.tokens[o.token],n.type=`s_close`,n.tag=`s`,n.nesting=-1,n.markup=`~~`,n.content=``,e.tokens[o.token-1].type===`text`&&e.tokens[o.token-1].content===`~`&&r.push(o.token-1)}for(;r.length;){let t=r.pop(),i=t+1;for(;i<e.tokens.length&&e.tokens[i].type===`s_close`;)i++;i--,t!==i&&(n=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=n)}}function yr(e){let t=e.tokens_meta,n=e.tokens_meta.length;vr(e,e.delimiters);for(let r=0;r<n;r++){let n=t[r]?.delimiters;n&&vr(e,n)}}var br={tokenize:_r,postProcess:yr};function xr(e,t){let n=e.pos,r=e.src.charCodeAt(n);if(t||r!==95&&r!==42)return!1;let i=e.scanDelims(e.pos,r===42);for(let t=0;t<i.length;t++){let t=e.push(`text`,``,0);t.content=String.fromCharCode(r),e.delimiters.push({marker:r,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0}function Sr(e,t){let n=t.length;for(let r=n-1;r>=0;r--){let n=t[r];if(n.marker!==95&&n.marker!==42||n.end===-1)continue;let i=t[n.end],a=r>0&&t[r-1].end===n.end+1&&t[r-1].marker===n.marker&&t[r-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=a?`strong_open`:`em_open`,s.tag=a?`strong`:`em`,s.nesting=1,s.markup=a?o+o:o,s.content=``;let c=e.tokens[i.token];c.type=a?`strong_close`:`em_close`,c.tag=a?`strong`:`em`,c.nesting=-1,c.markup=a?o+o:o,c.content=``,a&&(e.tokens[t[r-1].token].content=``,e.tokens[t[n.end+1].token].content=``,r--)}}function Cr(e){let t=e.tokens_meta,n=e.tokens_meta.length;Sr(e,e.delimiters);for(let r=0;r<n;r++){let n=t[r]?.delimiters;n&&Sr(e,n)}}var wr={tokenize:xr,postProcess:Cr};function Tr(e,t){let n,r,i,a,o=``,s=``,c=e.pos,l=!0;if(e.src.charCodeAt(e.pos)!==91)return!1;let u=e.pos,d=e.posMax,f=e.pos+1,p=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(p<0)return!1;let m=p+1;if(m<d&&e.src.charCodeAt(m)===40){for(l=!1,m++;m<d&&(n=e.src.charCodeAt(m),w(n)||n===10);m++);if(m>=d)return!1;if(c=m,i=e.md.helpers.parseLinkDestination(e.src,m,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?m=i.pos:o=``,c=m;m<d&&(n=e.src.charCodeAt(m),w(n)||n===10);m++);if(i=e.md.helpers.parseLinkTitle(e.src,m,e.posMax),m<d&&c!==m&&i.ok)for(s=i.str,m=i.pos;m<d&&(n=e.src.charCodeAt(m),w(n)||n===10);m++);}(m>=d||e.src.charCodeAt(m)!==41)&&(l=!0),m++}if(l){if(e.env.references===void 0)return!1;if(m<d&&e.src.charCodeAt(m)===91?(c=m+1,m=e.md.helpers.parseLinkLabel(e,m),m>=0?r=e.src.slice(c,m++):m=p+1):m=p+1,r||=e.src.slice(f,p),r=Rt(r),a=e.env.references[r],!a)return e.pos=u,!1;o=a.href,s=a.title}if(!t){e.pos=f,e.posMax=p;let t=e.push(`link_open`,`a`,1),n=[[`href`,o]];if(t.attrs=n,s&&n.push([`title`,s]),r){let e=Object.create(null);e.label=r,t.meta=e}e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push(`link_close`,`a`,-1)}return e.pos=m,e.posMax=d,!0}function Er(e,t){let n,r,i,a,o,s,c,l,u=``,d=e.pos,f=e.posMax;if(e.src.charCodeAt(e.pos)!==33||e.src.charCodeAt(e.pos+1)!==91)return!1;let p=e.pos+2,m=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(m<0)return!1;if(a=m+1,a<f&&e.src.charCodeAt(a)===40){for(a++;a<f&&(n=e.src.charCodeAt(a),w(n)||n===10);a++);if(a>=f)return!1;for(l=a,s=e.md.helpers.parseLinkDestination(e.src,a,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?a=s.pos:u=``),l=a;a<f&&(n=e.src.charCodeAt(a),w(n)||n===10);a++);if(s=e.md.helpers.parseLinkTitle(e.src,a,e.posMax),a<f&&l!==a&&s.ok)for(c=s.str,a=s.pos;a<f&&(n=e.src.charCodeAt(a),w(n)||n===10);a++);else c=``;if(a>=f||e.src.charCodeAt(a)!==41)return e.pos=d,!1;a++}else{if(e.env.references===void 0)return!1;if(a<f&&e.src.charCodeAt(a)===91?(l=a+1,a=e.md.helpers.parseLinkLabel(e,a),a>=0?i=e.src.slice(l,a++):a=m+1):a=m+1,i||=e.src.slice(p,m),i=Rt(i),o=e.env.references[i],!o)return e.pos=d,!1;u=o.href,c=o.title}if(!t){r=e.src.slice(p,m);let t=[];e.md.inline.parse(r,e.md,e.env,t);let n=e.push(`image`,`img`,0),a=[[`src`,u],[`alt`,``]];if(n.attrs=a,n.children=t,n.content=r,c&&a.push([`title`,c]),i){let e=Object.create(null);e.label=i,n.meta=e}}return e.pos=a,e.posMax=f,!0}var Dr=/^([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])?)*)$/,Or=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;function kr(e,t){let n=e.pos;if(e.src.charCodeAt(n)!==60)return!1;let r=e.pos,i=e.posMax;for(;;){if(++n>=i)return!1;let t=e.src.charCodeAt(n);if(t===60)return!1;if(t===62)break}let a=e.src.slice(r+1,n);if(Or.test(a)){let n=e.md.normalizeLink(a);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}if(Dr.test(a)){let n=e.md.normalizeLink(`mailto:${a}`);if(!e.md.validateLink(n))return!1;if(!t){let t=e.push(`link_open`,`a`,1);t.attrs=[[`href`,n]],t.markup=`autolink`,t.info=`auto`;let r=e.push(`text`,``,0);r.content=e.md.normalizeLinkText(a);let i=e.push(`link_close`,`a`,-1);i.markup=`autolink`,i.info=`auto`}return e.pos+=a.length+2,!0}return!1}function Ar(e){return/^<a[>\s]/i.test(e)}function jr(e){return/^<\/a\s*>/i.test(e)}function Mr(e){let t=e|32;return t>=97&&t<=122}function Nr(e,t){let n=e.src,r,i;if(n.startsWith(`<!--`,t)){if(n.startsWith(`>`,t+4))return t+5;if(n.startsWith(`->`,t+4))return t+6;r=t+4,i=`-->`}else if(n.startsWith(`<![CDATA[`,t))r=t+9,i=`]]>`;else if(n.charCodeAt(t+1)===63)r=t+2,i=`?>`;else if(Mr(n.charCodeAt(t+2)))r=t+3,i=`>`;else return-1;if(e.skipHtmlSpecial)return-1;let a=n.indexOf(i,r);return a<0?(e.skipHtmlSpecial=!0,-1):a+i.length}function Pr(e,t){if(!e.md.options.html)return!1;let n=e.posMax,r=e.pos;if(e.src.charCodeAt(r)!==60||r+2>=n)return!1;let i,a=e.src.charCodeAt(r+1);if(a===33||a===63)i=Nr(e,r);else if(a===47||Mr(a)){let t=e.src.slice(r).match(Qn);i=t?r+t[0].length:-1}else return!1;if(i<0)return!1;if(!t){let t=e.push(`html_inline`,``,0);t.content=e.src.slice(r,i),Ar(t.content)&&e.linkLevel++,jr(t.content)&&e.linkLevel--}return e.pos=i,!0}var Fr=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,Ir=/^&([a-z][a-z0-9]{1,31});/i;function Lr(e,t){let n=e.pos,r=e.posMax;if(e.src.charCodeAt(n)!==38||n+1>=r)return!1;if(e.src.charCodeAt(n+1)===35){let r=e.src.slice(n).match(Fr);if(r){if(!t){let t=r[1][0].toLowerCase()===`x`?parseInt(r[1].slice(1),16):parseInt(r[1],10),n=e.push(`text_special`,``,0);n.content=yt(t)?bt(t):bt(65533),n.markup=r[0],n.info=`entity`}return e.pos+=r[0].length,!0}}else{let r=e.src.slice(n).match(Ir);if(r){let n=je(r[0]);if(n!==r[0]){if(!t){let t=e.push(`text_special`,``,0);t.content=n,t.markup=r[0],t.info=`entity`}return e.pos+=r[0].length,!0}}}return!1}function Rr(e){let t={},n=e.length;if(!n)return;let r=0,i=-2,a=[];for(let o=0;o<n;o++){let n=e[o];if(a.push(0),(e[r].marker!==n.marker||i!==n.token-1)&&(r=o),i=n.token,n.length=n.length||0,!n.close)continue;t.hasOwnProperty(n.marker)||(t[n.marker]=[-1,-1,-1,-1,-1,-1]);let s=t[n.marker][(n.open?3:0)+n.length%3],c=r-a[r]-1,l=c;for(;c>s;c-=a[c]+1){let t=e[c];if(t.marker===n.marker&&t.open&&t.end<0){let r=!1;if((t.close||n.open)&&(t.length+n.length)%3==0&&(t.length%3!=0||n.length%3!=0)&&(r=!0),!r){let r=c>0&&!e[c-1].open?a[c-1]+1:0;a[o]=o-c+r,a[c]=r,n.open=!1,t.end=o,t.close=!1,l=-1,i=-2;break}}}l!==-1&&(t[n.marker][(n.open?3:0)+(n.length||0)%3]=l)}}function zr(e){let t=e.tokens_meta,n=e.tokens_meta.length;Rr(e.delimiters);for(let e=0;e<n;e++){let n=t[e]?.delimiters;n&&Rr(n)}}function Br(e){let t,n,r=0,i=e.tokens,a=e.tokens.length;for(t=n=0;t<a;t++)i[t].nesting<0&&r--,i[t].level=r,i[t].nesting>0&&r++,i[t].type===`text`&&t+1<a&&i[t+1].type===`text`?i[t+1].content=i[t].content+i[t+1].content:(t!==n&&(i[n]=i[t]),n++);t!==n&&(i.length=n)}var Vr=[[`text`,cr],[`linkify`,dr],[`newline`,fr],[`escape`,mr],[`backticks`,gr],[`strikethrough`,br.tokenize],[`emphasis`,wr.tokenize],[`link`,Tr],[`image`,Er],[`autolink`,kr],[`html_inline`,Pr],[`entity`,Lr]],Hr=[[`balance_pairs`,zr],[`strikethrough`,br.postProcess],[`emphasis`,wr.postProcess],[`fragments_join`,Br]],Ur=class{constructor(){T(this,`ruler`,new Xt),T(this,`ruler2`,new Xt),T(this,`State`,or);for(let e=0;e<Vr.length;e++)this.ruler.push(Vr[e][0],Vr[e][1]);for(let e=0;e<Hr.length;e++)this.ruler2.push(Hr[e][0],Hr[e][1])}skipToken(e){let t=e.pos,n=this.ruler.getRules(``),r=n.length,i=e.md.options.maxNesting,a=e.cache;if(a[t]!==void 0){e.pos=a[t];return}let o=!1;if(e.level<i){for(let i=0;i<r;i++)if(e.level++,o=n[i](e,!0),e.level--,o){if(t>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}else e.pos=e.posMax;o||e.pos++,a[t]=e.pos}tokenize(e){let t=this.ruler.getRules(``),n=t.length,r=e.posMax,i=e.md.options.maxNesting;for(;e.pos<r;){let a=e.pos,o=!1;if(e.level<i){for(let r=0;r<n;r++)if(o=t[r](e,!1),o){if(a>=e.pos)throw Error(`inline rule didn't increment state.pos`);break}}if(o){if(e.pos>=r)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()}parse(e,t,n,r){let i=new this.State(e,t,n,r);this.tokenize(i);let a=this.ruler2.getRules(``),o=a.length;for(let e=0;e<o;e++)a[e](i)}},Wr={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:20},components:{core:{rules:[`normalize`,`block`,`strip_references`,`inline`,`text_join`]},block:{rules:[`paragraph`]},inline:{rules:[`text`],rules2:[`balance_pairs`,`fragments_join`]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:`language-`,linkify:!1,typographer:!1,quotes:`“”‘’`,highlight:null,maxNesting:20},components:{core:{rules:[`normalize`,`block`,`strip_references`,`inline`,`text_join`]},block:{rules:[`blockquote`,`code`,`fence`,`heading`,`hr`,`html_block`,`lheading`,`list`,`reference`,`paragraph`]},inline:{rules:[`autolink`,`backticks`,`emphasis`,`entity`,`escape`,`html_inline`,`image`,`link`,`newline`,`text`],rules2:[`balance_pairs`,`emphasis`,`fragments_join`]}}}},Gr=/^(vbscript|javascript|file|data):/,Kr=/^data:image\/(gif|png|jpeg|webp);/,qr=[`http:`,`https:`,`mailto:`],Jr=class{validateLink(e){let t=e.trim().toLowerCase();return!Gr.test(t)||Kr.test(t)}normalizeLink(e){let t=x(e,!0);if(t.hostname&&(!t.protocol||qr.indexOf(t.protocol)>=0))try{t.hostname=pt.toASCII(t.hostname)}catch{}return t.auth&&=c(t.auth),t.hostname&&=c(t.hostname),t.pathname&&=c(t.pathname),t.search&&=c(t.search),t.hash&&=c(t.hash),l(t)}normalizeLinkText(e){let t=x(e,!0);if(t.hostname&&(!t.protocol||qr.indexOf(t.protocol)>=0))try{t.hostname=pt.toUnicode(t.hostname)}catch{}return a(l(t),a.defaultChars+`%`)}constructor(...e){T(this,`inline`,new Ur),T(this,`block`,new ar),T(this,`core`,new An),T(this,`renderer`,new Qt),T(this,`linkify`,new Be),T(this,`utils`,gt),T(this,`helpers`,Object.assign({},Gt));let[t,n]=e;typeof t==`string`?(this.configure(t),n&&this.set(n)):(this.configure(`default`),this.set(t||{}))}set(e){return Object.assign(this.options,e),this}configure(e){let t;if(typeof e==`string`){let n=e;if(t=Wr[n],!t)throw Error(`Wrong 'markdown-it' preset "${n}", check name`)}else t=e;if(!t)throw Error("Wrong `markdown-it` preset, can't be empty");t.options&&(this.options={...t.options});let n=t.components;if(n){[`core`,`block`,`inline`].forEach(e=>{let t=n[e]?.rules;t&&this[e].ruler.enableOnly(t)});let e=n.inline?.rules2;e&&this.inline.ruler2.enableOnly(e)}return this}enable(e,t=!1){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(t=>{n=n.concat(this[t].ruler.enable(e,!0))}),n=n.concat(this.inline.ruler2.enable(e,!0));let r=e.filter(e=>n.indexOf(e)<0);if(r.length&&!t)throw Error(`MarkdownIt. Failed to enable unknown rule(s): ${r}`);return this}disable(e,t=!1){let n=[];Array.isArray(e)||(e=[e]),[`core`,`block`,`inline`].forEach(t=>{n=n.concat(this[t].ruler.disable(e,!0))}),n=n.concat(this.inline.ruler2.disable(e,!0));let r=e.filter(e=>n.indexOf(e)<0);if(r.length&&!t)throw Error(`MarkdownIt. Failed to disable unknown rule(s): ${r}`);return this}use(e,...t){return e.apply(e,[this,...t]),this}parse(e,t){if(typeof e!=`string`)throw Error(`Input data should be a String`);let n=new this.core.State(e,this,t);return this.core.process(n),n.tokens}render(e,t={}){return this.renderer.render(this.parse(e,t),this.options,t)}parseInline(e,t){let n=new this.core.State(e,this,t);return n.inlineMode=!0,this.core.process(n),n.tokens}renderInline(e,t={}){return this.renderer.render(this.parseInline(e,t),this.options,t)}};T(Jr,`Token`,Yt),T(Jr,`Ruler`,Xt),T(Jr,`Renderer`,Qt),T(Jr,`ParserCore`,An),T(Jr,`StateCore`,$t),T(Jr,`ParserBlock`,ar),T(Jr,`StateBlock`,jn),T(Jr,`ParserInline`,Ur),T(Jr,`StateInline`,or);var Yr=_t(Jr);function E(e){this.content=e}E.prototype={constructor:E,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new E(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new E(n)},addToStart:function(e,t){return new E([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new E(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new E(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=E.from(e),e.size?new E(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=E.from(e),e.size?new E(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=E.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},E.from=function(e){if(e instanceof E)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new E(t)};function Xr(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a)n+=i.nodeSize;else{if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&$r(e.charCodeAt(r-1))&&Qr(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=Xr(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}}function Zr(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s)n-=c,r-=c;else{if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&$r(e.charCodeAt(i-1))&&Qr(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=Zr(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}}function Qr(e){return e>=56320&&e<57344}function $r(e){return e>=55296&&e<56320}var D=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return Xr(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Zr(this,e,t,n)}findIndex(e){if(e==0)return ti(0,e);if(e==this.size)return ti(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?ti(t+1,i):ti(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};D.empty=new D([],0);var ei={index:0,offset:0};function ti(e,t){return ei.index=e,ei.offset=t,ei}function ni(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!ni(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!ni(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var O=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ni(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);return n.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};O.none=[];var ri=class extends Error{},k=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=ai(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ii(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(D.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};k.empty=new k(D.empty,0,0);function ii(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ii(a.content,t-i-1,n-i-1)))}function ai(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=ai(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function oi(e,t,n){if(n.openStart>e.depth)throw new ri(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new ri(`Inconsistent open depths`);return si(e,t,n,0)}function si(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=si(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}if(!n.content.size)return fi(a,mi(e,t,r));if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return fi(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}{let{start:i,end:o}=hi(n,e);return fi(a,pi(e,i,o,t,r))}}function ci(e,t){if(!t.type.compatibleContent(e.type))throw new ri(`Cannot join `+t.type.name+` onto `+e.type.name)}function li(e,t,n){let r=e.node(n);return ci(r,t.node(n)),r}function ui(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function di(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(ui(e.nodeAfter,r),a++));for(let e=a;e<o;e++)ui(i.child(e),r);t&&t.depth==n&&t.textOffset&&ui(t.nodeBefore,r)}function fi(e,t){if(!e.type.validContent(t))throw new ri(`Invalid content for node `+e.type.name);return e.copy(t)}function pi(e,t,n,r,i){let a=e.depth>i&&li(e,t,i+1),o=r.depth>i&&li(n,r,i+1),s=[];return di(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(ci(a,o),ui(fi(a,pi(e,t,n,r,i+1)),s)):(a&&ui(fi(a,mi(e,t,i+1)),s),di(t,n,i,s),o&&ui(fi(o,mi(n,r,i+1)),s)),di(r,null,i,s),new D(s)}function mi(e,t,n){let r=[];return di(null,e,n,r),e.depth>n&&ui(fi(li(e,t,n+1),mi(e,t,n+1)),r),di(t,null,n,r),new D(r)}function hi(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(D.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var gi=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return O.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive!==!1||r&&i[a].isInSet(r.marks)||(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive!==!1||r&&n[i].isInSet(r.marks)||(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new bi(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=yi.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else yi.set(t,r=new _i);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%vi,i}},_i=class{constructor(){this.elts=[],this.i=0}},vi=12,yi=new WeakMap,bi=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},xi=Object.create(null),Si=class e{constructor(e,t,n,r=O.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&ni(this.attrs,t||e.defaultAttrs||xi)&&O.sameSet(this.marks,n||O.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return k.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new k(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return oi(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return gi.resolveCached(this,e)}resolveNoCache(e){return gi.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Ti(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=D.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ei(this.type.attrs,this.attrs,`node`,this.type.name);let e=O.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];Ei(n.type.attrs,n.attrs,`mark`,n.type.name),e=n.addToSet(e)}if(!O.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=D.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};Si.prototype.text=void 0;var Ci=(()=>{let{stack:e}=Error(`/`);if(!e||!/\n\s*at\s/.test(e))return e=>e;let t=Object.create(null);return e=>(t[e],e)})(),wi=class e extends Si{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ti(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return Ci(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(Ci(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ti(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function Ei(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var Di=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Oi(t,n);if(r.next==null)return e.empty;let i=ki(r);r.next&&r.err(`Unexpected trailing text`);let a=zi(Ii(i));return Bi(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return D.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];a.isLeaf||a.hasRequiredAttrs()||a.name in t||r.type&&!o.validEnd||(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
14
+ `)}};Di.empty=new Di(!0);var Oi=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function ki(e){let t=[];do t.push(Ai(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function Ai(e){let t=[];do t.push(ji(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ji(e){let t=Fi(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=Ni(e,t);else break;return t}function Mi(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function Ni(e,t){let n=Mi(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Mi(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Pi(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Fi(e){if(e.eat(`(`)){let t=ki(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Pi(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Ii(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Li(e,t){return t-e}function Ri(e,t){let n=[];return r(t),n.sort(Li);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function zi(e){let t=Object.create(null);return n(Ri(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ri(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Di(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Li);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Bi(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Vi(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Hi(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0){if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r)}else i.validate&&i.validate(a);n[r]=a}return n}function Ui(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Ki(e,r,t[r]);return n}var Wi=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Ui(e,n.attrs),this.defaultAttrs=Vi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Di.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Hi(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Si(this,this.computeAttrs(e),D.from(t),O.setFrom(n))}createChecked(e=null,t,n){return t=D.from(t),this.checkContent(t),new Si(this,this.computeAttrs(e),t,O.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=D.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(D.empty,!0);return i?new Si(this,e,t.append(i),O.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:O.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Gi(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var Ki=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Gi(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},qi=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Ui(e,r.attrs),this.excluded=null;let i=Vi(this.attrs);this.instance=i?new O(this,i):null}create(e=null){return!e&&this.instance?this.instance:new O(this,Hi(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Ji=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=E.from(e.nodes),t.marks=E.from(e.marks||{}),this.nodes=Wi.compile(this.spec.nodes,this),this.marks=qi.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Di.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?Yi(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:Yi(this,n.split(` `))}this.nodeFromJSON=e=>Si.fromJSON(this,e),this.markFromJSON=e=>O.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Wi))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new wi(n,n.defaultAttrs,e,O.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function Yi(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function Xi(e){return e.tag!=null}function Zi(e){return e.style!=null}var Qi=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(Xi(e))this.tags.push(e);else if(Zi(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new sa(this,t,!1);return n.addAll(e,O.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new sa(this,t,!0);return n.addAll(e,O.none,t.from,t.to),k.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(la(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ua(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ua(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},$i={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},ea={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ta={ol:!0,ul:!0},na=1,ra=2,ia=4;function aa(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?na:0)|(t===`full`?ra:0)}var oa=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=O.none,this.match=i||(a&ia?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&na)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!$i.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},sa=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=aa(null,t.preserveWhitespace,0)|(n?ia:0);i=r?new oa(r.type,r.attrs,O.none,!0,t.topMatch||r.type.contentMatch,a):n?new oa(null,null,O.none,!0,null,a):new oa(e.schema.topNodeType,null,O.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&ra?`full`:this.localPreserveWS||(r.options&na)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
15
+ `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;ta.hasOwnProperty(a)&&this.parser.normalizeLists&&ca(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));e:if(s?s.ignore:ea.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if($i.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
16
+ `),t)}ignoreFallback(e,t){e.nodeName!=`BR`||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=O.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):da(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=aa(e,i,a.options);a.options&ia&&a.content.length==0&&(o|=ia);let s=O.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):da(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new oa(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=na);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function ca(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&ta.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function la(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ua(e){let t={};for(let n in e)t[n]=e[n];return t}function da(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var fa=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=ma(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name])a++;else{if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return ma(t).createTextNode(e.text);let{dom:n,contentDOM:r}=va(ma(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&va(ma(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:va(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=pa(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return pa(e.marks)}};function pa(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function ma(e){return e.document||window.document}var ha=new WeakMap;function ga(e){let t=ha.get(e);return t===void 0&&ha.set(e,t=_a(e)),t}function _a(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t])}else for(let t in e)n(e[t])}}return n(e),t}function va(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=ga(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=va(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var ya=new Ji({nodes:{doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return[`p`,0]}},blockquote:{content:`block+`,group:`block`,parseDOM:[{tag:`blockquote`}],toDOM(){return[`blockquote`,0]}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return[`div`,[`hr`]]}},heading:{attrs:{level:{default:1,validate:`number`}},content:`(text | image)*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+ +e.attrs.level,0]}},code_block:{content:`text*`,group:`block`,code:!0,defining:!0,marks:``,attrs:{params:{default:``}},parseDOM:[{tag:`pre`,preserveWhitespace:`full`,getAttrs:e=>({params:e.getAttribute(`data-params`)||``})}],toDOM(e){return[`pre`,e.attrs.params?{"data-params":e.attrs.params}:{},[`code`,0]]}},ordered_list:{content:`list_item+`,group:`block`,attrs:{order:{default:1},tight:{default:!1}},parseDOM:[{tag:`ol`,getAttrs(e){return{order:e.hasAttribute(`start`)?+e.getAttribute(`start`):1,tight:e.hasAttribute(`data-tight`)}}}],toDOM(e){return[`ol`,{start:e.attrs.order==1?null:e.attrs.order,"data-tight":e.attrs.tight?`true`:null},0]}},bullet_list:{content:`list_item+`,group:`block`,attrs:{tight:{default:!1}},parseDOM:[{tag:`ul`,getAttrs:e=>({tight:e.hasAttribute(`data-tight`)})}],toDOM(e){return[`ul`,{"data-tight":e.attrs.tight?`true`:null},0]}},list_item:{content:`block+`,defining:!0,parseDOM:[{tag:`li`}],toDOM(){return[`li`,0]}},text:{group:`inline`},image:{inline:!0,attrs:{src:{},alt:{default:null},title:{default:null}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){return[`img`,e.attrs]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}},marks:{em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return[`em`]}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return[`strong`]}},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){return[`a`,e.attrs]}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return[`code`]}}}});function ba(e,t){if(e.isText&&t.isText&&O.sameSet(e.marks,t.marks))return e.withText(e.text+t.text)}var xa=class{constructor(e,t){this.schema=e,this.tokenHandlers=t,this.stack=[{type:e.topNodeType,attrs:null,content:[],marks:O.none}]}top(){return this.stack[this.stack.length-1]}push(e){this.stack.length&&this.top().content.push(e)}addText(e){if(!e)return;let t=this.top(),n=t.content,r=n[n.length-1],i=this.schema.text(e,t.marks),a;r&&(a=ba(r,i))?n[n.length-1]=a:n.push(i)}openMark(e){let t=this.top();t.marks=e.addToSet(t.marks)}closeMark(e){let t=this.top();t.marks=e.removeFromSet(t.marks)}parseTokens(e){for(let t=0;t<e.length;t++){let n=e[t],r=this.tokenHandlers[n.type];if(!r)throw Error("Token type `"+n.type+"` not supported by Markdown parser");r(this,n,e,t)}}addNode(e,t,n){let r=this.top(),i=e.createAndFill(t,n,r?r.marks:[]);return i?(this.push(i),i):null}openNode(e,t){this.stack.push({type:e,attrs:t,content:[],marks:O.none})}closeNode(){let e=this.stack.pop();return this.addNode(e.type,e.attrs,e.content)}};function Sa(e,t,n,r){return e.getAttrs?e.getAttrs(t,n,r):e.attrs instanceof Function?e.attrs(t):e.attrs}function Ca(e,t){return e.noCloseToken||t==`code_inline`||t==`code_block`||t==`fence`}function wa(e){return e[e.length-1]==`
17
+ `?e.slice(0,e.length-1):e}function Ta(){}function Ea(e,t){let n=Object.create(null);for(let r in t){let i=t[r];if(i.block){let t=e.nodeType(i.block);Ca(i,r)?n[r]=(e,n,r,a)=>{e.openNode(t,Sa(i,n,r,a)),e.addText(wa(n.content)),e.closeNode()}:(n[r+`_open`]=(e,n,r,a)=>e.openNode(t,Sa(i,n,r,a)),n[r+`_close`]=e=>e.closeNode())}else if(i.node){let t=e.nodeType(i.node);n[r]=(e,n,r,a)=>e.addNode(t,Sa(i,n,r,a))}else if(i.mark){let t=e.marks[i.mark];Ca(i,r)?n[r]=(e,n,r,a)=>{e.openMark(t.create(Sa(i,n,r,a))),e.addText(wa(n.content)),e.closeMark(t)}:(n[r+`_open`]=(e,n,r,a)=>e.openMark(t.create(Sa(i,n,r,a))),n[r+`_close`]=e=>e.closeMark(t))}else if(i.ignore)Ca(i,r)?n[r]=Ta:(n[r+`_open`]=Ta,n[r+`_close`]=Ta);else throw RangeError(`Unrecognized parsing spec `+JSON.stringify(i))}return n.text=(e,t)=>e.addText(t.content),n.inline=(e,t)=>e.parseTokens(t.children),n.softbreak=n.softbreak||(e=>e.addText(` `)),n}var Da=class{constructor(e,t,n){this.schema=e,this.tokenizer=t,this.tokens=n,this.tokenHandlers=Ea(e,n)}parse(e,t={}){let n=new xa(this.schema,this.tokenHandlers),r;n.parseTokens(this.tokenizer.parse(e,t));do r=n.closeNode();while(n.stack.length);return r||this.schema.topNodeType.createAndFill()}};function Oa(e,t){for(;++t<e.length;)if(e[t].type!=`list_item_open`)return e[t].hidden;return!1}new Da(ya,Yr(`commonmark`,{html:!1}),{blockquote:{block:`blockquote`},paragraph:{block:`paragraph`},list_item:{block:`list_item`},bullet_list:{block:`bullet_list`,getAttrs:(e,t,n)=>({tight:Oa(t,n)})},ordered_list:{block:`ordered_list`,getAttrs:(e,t,n)=>({order:+e.attrGet(`start`)||1,tight:Oa(t,n)})},heading:{block:`heading`,getAttrs:e=>({level:+e.tag.slice(1)})},code_block:{block:`code_block`,noCloseToken:!0},fence:{block:`code_block`,getAttrs:e=>({params:e.info||``}),noCloseToken:!0},hr:{node:`horizontal_rule`},image:{node:`image`,getAttrs:e=>({src:e.attrGet(`src`),title:e.attrGet(`title`)||null,alt:e.children[0]&&e.children[0].content||null})},hardbreak:{node:`hard_break`},em:{mark:`em`},strong:{mark:`strong`},link:{mark:`link`,getAttrs:e=>({href:e.attrGet(`href`),title:e.attrGet(`title`)||null})},code_inline:{mark:`code`,noCloseToken:!0}});var ka={open:``,close:``,mixable:!0},Aa=class{constructor(e,t,n={}){this.nodes=e,this.marks=t,this.options=n}serialize(e,t={}){t=Object.assign({},this.options,t);let n=new Pa(this.nodes,this.marks,t);return n.renderContent(e),n.out}},ja=new Aa({blockquote(e,t){e.wrapBlock(`> `,null,t,()=>e.renderContent(t))},code_block(e,t){let n=t.textContent.match(/`{3,}/gm),r=n?n.sort().slice(-1)[0]+"`":"```";e.write(r+(t.attrs.params||``)+`
18
+ `),e.text(t.textContent,!1),e.write(`
19
+ `),e.write(r),e.closeBlock(t)},heading(e,t){e.write(e.repeat(`#`,t.attrs.level)+` `),e.renderInline(t,!1),e.closeBlock(t)},horizontal_rule(e,t){e.write(t.attrs.markup||`---`),e.closeBlock(t)},bullet_list(e,t){e.renderList(t,` `,()=>(t.attrs.bullet||`*`)+` `)},ordered_list(e,t){let n=t.attrs.order??1,r=String(n+t.childCount-1).length,i=e.repeat(` `,r+2);e.renderList(t,i,t=>{let i=String(n+t);return e.repeat(` `,r-i.length)+i+`. `})},list_item(e,t){e.renderContent(t)},paragraph(e,t){e.renderInline(t),e.closeBlock(t)},image(e,t){e.write(`![`+e.esc(t.attrs.alt||``)+`](`+t.attrs.src.replace(/[\(\)]/g,`\\$&`)+(t.attrs.title?` "`+t.attrs.title.replace(/"/g,`\\"`)+`"`:``)+`)`)},hard_break(e,t,n,r){for(let i=r+1;i<n.childCount;i++)if(n.child(i).type!=t.type){e.write(`\\
20
+ `);return}},text(e,t){e.text(t.text,!e.inAutolink)}},{em:{open:`*`,close:`*`,mixable:!0,expelEnclosingWhitespace:!0},strong:{open:`**`,close:`**`,mixable:!0,expelEnclosingWhitespace:!0},link:{open(e,t,n,r){return e.inAutolink=Na(t,n,r),e.inAutolink?`<`:`[`},close(e,t,n,r){let{inAutolink:i}=e;return e.inAutolink=void 0,i?`>`:`](`+t.attrs.href.replace(/[\(\)"]/g,`\\$&`)+(t.attrs.title?` "${t.attrs.title.replace(/"/g,`\\"`)}"`:``)+`)`},mixable:!0},code:{open(e,t,n,r){return Ma(n.child(r),-1)},close(e,t,n,r){return Ma(n.child(r-1),1)},escape:!1}});function Ma(e,t){let n=/`+/g,r,i=0;if(e.isText)for(;r=n.exec(e.text);)i=Math.max(i,r[0].length);let a=i>0&&t>0?" `":"`";for(let e=0;e<i;e++)a+="`";return i>0&&t<0&&(a+=` `),a}function Na(e,t,n){if(e.attrs.title||!/^\w+:/.test(e.attrs.href))return!1;let r=t.child(n);return!r.isText||r.text!=e.attrs.href||r.marks[r.marks.length-1]!=e?!1:n==t.childCount-1||!e.isInSet(t.child(n+1).marks)}var Pa=class{constructor(e,t,n){this.nodes=e,this.marks=t,this.options=n,this.delim=``,this.out=``,this.last=``,this.closed=null,this.inAutolink=void 0,this.atBlockStart=!1,this.inTightList=!1,this.options.tightLists===void 0&&(this.options.tightLists=!1),this.options.hardBreakNodeName===void 0&&(this.options.hardBreakNodeName=`hard_break`)}flushClose(e=2){if(this.closed){if(this.atBlank()||this.append(`
21
+ `),e>1){let t=this.delim,n=/\s+$/.exec(t);n&&(t=t.slice(0,t.length-n[0].length));for(let n=1;n<e;n++)this.append(t+`
22
+ `)}this.closed=null}}getMark(e){let t=this.marks[e];if(!t){if(this.options.strict!==!1)throw Error(`Mark type \`${e}\` not supported by Markdown renderer`);t=ka}return t}wrapBlock(e,t,n,r){let i=this.delim;this.write(t??e),this.delim+=e,r(),this.delim=i,this.closeBlock(n)}atBlank(){return!this.out||this.last[this.last.length-1]==`
23
+ `}ensureNewLine(){this.atBlank()||this.append(`
24
+ `)}append(e){e&&(this.out+=e,this.last=e.length>1?e:this.last.slice(-1)+e)}write(e){this.flushClose(),this.delim&&this.atBlank()&&this.append(this.delim),e&&this.append(e)}closeBlock(e){this.closed=e}text(e,t=!0){let n=e.split(`
25
+ `);for(let e=0;e<n.length;e++){if(this.write(),!t&&n[e][0]==`[`&&/\!$/.test(this.last)){let e=this.last.length>1&&this.last[this.last.length-2]==`\\`;if(e){let t=1;for(let e=this.out.length-2;e>0&&this.out[e-1]==`\\`;e--)t++;e=t%2>0}e||(this.out=this.out.slice(0,this.out.length-1)+`\\!`)}this.append(t?this.esc(n[e],this.atBlockStart):n[e]),e!=n.length-1&&this.append(`
26
+ `)}}render(e,t,n){if(this.nodes[e.type.name])this.nodes[e.type.name](this,e,t,n);else if(this.options.strict!==!1)throw Error("Token type `"+e.type.name+"` not supported by Markdown renderer");else e.type.isLeaf||(e.type.inlineContent?this.renderInline(e):this.renderContent(e),e.isBlock&&this.closeBlock(e))}renderContent(e){e.forEach((t,n,r)=>this.render(t,e,r))}renderInline(e,t=!0){this.atBlockStart=t;let n=[],r=``,i=(t,i,a)=>{let o=t?t.marks:[];t&&t.type.name===this.options.hardBreakNodeName&&(o=o.filter(t=>{if(a+1==e.childCount)return!1;let n=e.child(a+1);return t.isInSet(n.marks)&&(!n.isText||/\S/.test(n.text))}));let s=o.length?o[o.length-1]:null,c=s&&this.getMark(s.type.name).escape===!1,l=o.length-+!!c;e:for(let e=0;e<l;e++){let t=o[e];if(!this.getMark(t.type.name).mixable)break;for(let r=0;r<n.length;r++){let i=n[r];if(!this.getMark(i.type.name).mixable)break;if(t.eq(i)){e>r?o=o.slice(0,r).concat(t).concat(o.slice(r,e)).concat(o.slice(e+1,l)):r>e&&(o=o.slice(0,e).concat(o.slice(e+1,r)).concat(t).concat(o.slice(r,l)));continue e}}}let u=0;for(;u<Math.min(n.length,l)&&o[u].eq(n[u]);)++u;let d=r;if(r=``,t&&t.isText&&o.length>u&&this.getMark(o[o.length-1].type.name)?.expelEnclosingWhitespace){let[e,r,i]=/^(\s*)(.*)$/m.exec(t.text);r&&(d+=r,t=i?t.withText(i):null,t||(o=n))}if(t&&t.isText&&o.length)for(let i=o.length-1;i>=0;i--){let s=o[i];if(!this.getMark(s.type.name)?.expelEnclosingWhitespace)break;if(!this.isMarkAhead(e,a+1,s)){let[e,i,a]=/^(.*?)(\s*)$/m.exec(t.text);a&&(r=a,t=i?t.withText(i):null,t||(o=n));break}}if(t||a==e.childCount)for(;u<n.length;)this.text(this.markString(n.pop(),!1,e,a),!1);if(d&&this.text(d),t){for(;n.length<l;){let t=o[n.length];n.push(t),this.text(this.markString(t,!0,e,a),!1),this.atBlockStart=!1}c&&t.isText?this.text(this.markString(s,!0,e,a)+t.text+this.markString(s,!1,e,a+1),!1):this.render(t,e,a),this.atBlockStart=!1,t.isText&&t.nodeSize>0&&(this.atBlockStart=!1)}};e.forEach(i),i(null,0,e.childCount),this.atBlockStart=!1}renderList(e,t,n){this.closed&&this.closed.type==e.type?this.flushClose(3):this.inTightList&&this.flushClose(1);let r=e.attrs.tight===void 0?this.options.tightLists:e.attrs.tight,i=this.inTightList;this.inTightList=r,e.forEach((i,a,o)=>{o&&r&&this.flushClose(1),this.wrapBlock(t,n(o),e,()=>this.render(i,e,o))}),this.inTightList=i}esc(e,t=!1){return e=e.replace(/[`*\\~\[\]_]/g,(t,n)=>t==`_`&&n>0&&n+1<e.length&&e[n-1].match(/\w/)&&e[n+1].match(/\w/)?t:`\\`+t),t&&(e=e.replace(/^(\+[ ]|[\-*>])/,`\\$&`).replace(/^(\s*)(#{1,6})(\s|$)/,`$1\\$2$3`).replace(/^(\s*\d+)\.\s/,`$1\\. `)),this.options.escapeExtraCharacters&&(e=e.replace(this.options.escapeExtraCharacters,`\\$&`)),e}quote(e){let t=e.indexOf(`"`)==-1?`""`:e.indexOf(`'`)==-1?`''`:`()`;return t[0]+e+t[1]}repeat(e,t){let n=``;for(let r=0;r<t;r++)n+=e;return n}markString(e,t,n,r){let i=this.getMark(e.type.name),a=t?i.open:i.close;return typeof a==`string`?a:a(this,e,n,r)}getEnclosingWhitespace(e){return{leading:(e.match(/^(\s+)/)||[void 0])[0],trailing:(e.match(/(\s+)$/)||[void 0])[0]}}isMarkAhead(e,t,n){for(;;t++){if(t>=e.childCount)return!1;let r=e.child(t);if(r.type.name!=this.options.hardBreakNodeName&&(!r.text||/\S/.test(r.text))){for(let e=r.marks.length-1;e>=0;e--){let t=r.marks[e];if(t.eq(n))return!0;if(!this.getMark(t.type.name)?.mixable)break}return!1}t++}}};function A(e){return e}var Fa=new Map;function Ia(e,t){Fa.set(e,t)}function La(e){return e.flatMap(e=>{if(typeof e!=`string`)return[e];let t=Fa.get(e);return t?[t()]:(console.warn(`[wysio] Unknown plugin "${e}". Register it with registerPlugin() (wysio/markdown registers "markdown").`),[])})}function Ra(){let e=new Yr(`commonmark`,{html:!1,linkify:!1}).enable([`table`,`strikethrough`]);return e.core.ruler.push(`wysio`,e=>{let t=[],n=t=>{let n=new e.Token(t===1?`paragraph_open`:`paragraph_close`,`p`,t);return n.block=!0,n};for(let r of e.tokens)if(r.type===`fence`||r.type===`code_block`){let i=new e.Token(`inline`,``,0);i.children=[],r.content.replace(/\n$/,``).split(`
27
+ `).forEach((t,n)=>{if(n&&i.children.push(new e.Token(`hardbreak`,`br`,0)),!t)return;let r=new e.Token(`code_inline`,`code`,0);r.content=t,i.children.push(r)}),t.push(n(1),i,n(-1))}else r.type===`th_open`||r.type===`td_open`?t.push(r,n(1)):r.type===`th_close`||r.type===`td_close`?t.push(n(-1),r):t.push(r);e.tokens=t}),e}function za(e){let t=t=>!!e.nodes[t],n=t=>!!e.marks[t],r={ignore:!0};return{paragraph:{block:`paragraph`},heading:t(`heading`)?{block:`heading`,getAttrs:e=>({level:Math.min(4,Number(e.tag.slice(1)))})}:{block:`paragraph`},blockquote:t(`blockquote`)?{block:`blockquote`}:r,bullet_list:t(`bullet_list`)?{block:`bullet_list`}:r,ordered_list:t(`ordered_list`)?{block:`ordered_list`,getAttrs:e=>({start:Number(e.attrGet(`start`))||1})}:r,list_item:t(`list_item`)?{block:`list_item`}:r,hr:t(`horizontal_rule`)?{node:`horizontal_rule`}:{ignore:!0,noCloseToken:!0},image:t(`image`)?{node:`image`,getAttrs:e=>({src:e.attrGet(`src`)??``,alt:e.content||null,title:e.attrGet(`title`)||null})}:{ignore:!0,noCloseToken:!0},hardbreak:t(`hard_break`)?{node:`hard_break`}:{ignore:!0,noCloseToken:!0},table:t(`table`)?{block:`table`}:r,thead:r,tbody:r,tr:t(`table_row`)?{block:`table_row`}:r,th:t(`table_header`)?{block:`table_header`}:r,td:t(`table_cell`)?{block:`table_cell`}:r,em:n(`italic`)?{mark:`italic`}:r,strong:n(`bold`)?{mark:`bold`}:r,s:n(`strike`)?{mark:`strike`}:r,link:n(`link`)?{mark:`link`,getAttrs:e=>({href:e.attrGet(`href`)??``})}:r,code_inline:n(`code`)?{mark:`code`,noCloseToken:!0}:{ignore:!0,noCloseToken:!0}}}var Ba={open:``,close:``,mixable:!0};function Va(e){let t={blockquote:ja.nodes.blockquote,heading:(e,t)=>{e.write(`${e.repeat(`#`,t.attrs.level)} `),e.renderInline(t,!1),e.closeBlock(t)},horizontal_rule:(e,t)=>{e.write(`---`),e.closeBlock(t)},bullet_list:(e,t)=>e.renderList(t,` `,()=>`- `),ordered_list:(e,t)=>{let n=t.attrs.start||1,r=String(n+t.childCount-1).length,i=e.repeat(` `,r+2);e.renderList(t,i,t=>{let i=String(n+t);return`${e.repeat(` `,r-i.length)}${i}. `})},list_item:(e,t)=>e.renderContent(t),paragraph:ja.nodes.paragraph,image:(e,t)=>{let n=e.esc(t.attrs.alt??``),r=t.attrs.src.replace(/[()\s]/g,e=>encodeURIComponent(e)),i=t.attrs.title?` "${t.attrs.title.replace(/"/g,`\\"`)}"`:``;e.write(`![${n}](${r}${i})`)},hard_break:ja.nodes.hard_break,text:ja.nodes.text,table:(e,t)=>{let n=[];t.forEach(e=>{let t=[];e.forEach(e=>{t.push(a(e));for(let n=1;n<(e.attrs.colspan||1);n++)t.push(``)}),n.push(t)});let r=Math.max(...n.map(e=>e.length)),i=e=>`| ${Array.from({length:r},(t,n)=>e[n]??``).join(` | `)} |`;[i(n[0]??[]),i(Array(r).fill(`---`)),...n.slice(1).map(i)].forEach((t,n)=>{n&&e.ensureNewLine(),e.write(t)}),e.closeBlock(t)}};for(let[n,r]of Object.entries(e.nodes))t[n]||n===`doc`||(t[n]=r.isTextblock?(e,t)=>{e.renderInline(t),e.closeBlock(t)}:r.isLeaf?()=>{}:(e,t)=>e.renderContent(t));let n=e=>({open:e,close:e,mixable:!0,expelEnclosingWhitespace:!0}),r={italic:n(`*`),bold:n(`**`),strike:n(`~~`),code:ja.marks.code,link:ja.marks.link};for(let t of Object.keys(e.marks))r[t]??=Ba;let i=new Aa(t,r,{escapeExtraCharacters:/[<>&]/g});function a(e){return i.serialize(e,{tightLists:!0}).replace(/\\\n/g,` `).replace(/\s*\n+\s*/g,` `).replace(/\|/g,`\\|`).trim()}return i}var Ha=Ra(),Ua=new WeakMap;function Wa(e){let t=Ua.get(e);return t||(t={parser:new Da(e,Ha,za(e)),serializer:Va(e)},Ua.set(e,t)),t}function Ga(e,t){return Wa(t).parser.parse(e)}function Ka(e){return Wa(e.type.schema).serializer.serialize(e,{tightLists:!0})}function qa(){return A({name:`markdown`,formats:()=>({markdown:{parse:(e,t)=>Ga(e,t),serialize:Ka}})})}Ia(`markdown`,qa);var Ja=65535,Ya=2**16;function Xa(e,t){return e+t*Ya}function Za(e){return e&Ja}function Qa(e){return(e-(e&Ja))/Ya}var $a=1,eo=2,to=4,no=8,ro=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&no)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&to)>0}},io=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Za(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Qa(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Xa(o/3,e-s),f=0;return c&&(f|=e==s?eo:e==u?$a:to,(t<0?e!=s:e!=u)&&(f|=no)),new ro(a,f,d)}r+=l-c}return n?e+r:new ro(e+r,0,null)}touches(e,t){let n=0,r=Za(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};io.empty=new io([]);var ao=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,n=this._maps.length;t<e.to;t++){let r=e.getMirror(t);r!=null&&(r=r<t&&r>=e.from?n+(r-e.from):void 0),this.appendMap(e._maps[t],r)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.to-1,n=this._maps.length+e._maps.length;t>=e.from;t--){let r=e.getMirror(t);r!=null&&(r=r>t&&r<e.to?n-(r-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),r)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new ro(e,r,null)}},oo=Object.create(null),j=class{getMap(){return io.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=oo[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in oo)throw RangeError(`Duplicate use of step JSON ID `+e);return oo[e]=t,t.prototype.jsonID=e,t}},M=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof ri)return e.fail(t.message);throw t}}};function so(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(so(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return D.fromArray(r)}var co=class e extends j{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new k(so(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return M.fromReplace(e,this.from,this.to,i)}invert(t){let n=[];return t.nodesBetween(this.from,this.to,(t,r)=>{if(t.isInline&&t.isAtom){let i=this.mark.addToSet(t.marks);if(!O.sameSet(i,t.marks)){let a=Math.max(this.from,r),o=Math.min(this.to,r+t.nodeSize);uo(lo,a,o,this.mark,n);for(let r of t.marks)r.isInSet(i)||uo(e,a,o,r,n)}}}),n.length==1?n[0]:new fo(n)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};j.jsonID(`addMark`,co);var lo=class e extends j{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new k(so(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return M.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(e,n)=>{e.isInline&&e.isAtom&&this.mark.isInSet(e.marks)&&uo(co,Math.max(this.from,n),Math.min(this.to,n+e.nodeSize),this.mark,t)}),t.length==1?t[0]:new fo(t)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};j.jsonID(`removeMark`,lo);function uo(e,t,n,r,i){let a=i.length?i[i.length-1]:null;a&&a instanceof e&&a.to==t&&a.mark.eq(r)?i[i.length-1]=new e(a.from,n,r):i.push(new e(t,n,r))}var fo=class e extends j{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new M(e,null)}invert(t){return new e(this.steps.map(e=>e.invert(t)))}map(t){let n=[];for(let e of this.steps){let r=e.map(t);r&&n.push(r)}return n.length?new e(n):null}toJSON(){return{stepType:`markSet`,steps:this.steps.map(e=>e.toJSON())}}static fromJSON(t,n){if(!Array.isArray(n.steps)||!n.steps.every(e=>e.stepType==`addMark`||e.stepType==`removeMark`))throw RangeError(`Invalid JSON for MarkSetStep`);return new e(n.steps.map(e=>j.fromJSON(t,e)))}};j.jsonID(`markSet`,fo);var po=class e extends j{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return M.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return M.fromReplace(e,this.pos,this.pos+1,new k(D.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new mo(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};j.jsonID(`addNodeMark`,po);var mo=class e extends j{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return M.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return M.fromReplace(e,this.pos,this.pos+1,new k(D.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new po(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};j.jsonID(`removeNodeMark`,mo);var ho=class e extends j{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&_o(e,this.from,this.to)?M.fail(`Structure replace would overwrite content`):M.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new io([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?k.empty:new k(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?k.empty:new k(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,k.fromJSON(t,n.slice),!!n.structure)}};ho.MAP_BIAS=1,j.jsonID(`replace`,ho);var go=class e extends j{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(_o(e,this.from,this.gapFrom)||_o(e,this.gapTo,this.to)))return M.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return M.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?M.fromReplace(e,this.from,this.to,n):M.fail(`Content does not fit in gap`)}getMap(){return new io([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos||i>a?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,k.fromJSON(t,n.slice),n.insert,!!n.structure)}};j.jsonID(`replaceAround`,go);function _o(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function vo(e,t,n,r){let i=[];e.doc.nodesBetween(t,n,(e,a,o)=>{if(!e.isInline)return;let s=e.marks;!r.isInSet(s)&&o.type.allowsMarkType(r.type)&&uo(co,Math.max(a,t),Math.min(a+e.nodeSize,n),r,i)}),i.forEach(t=>e.step(t))}function yo(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline||!e.isAtom)return;a++;let s=null;if(r instanceof qi){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new lo(t.from,t.to,t.style)))}function bo(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new ho(s,l,k.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new lo(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new k(D.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new ho(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(D.empty,!0);e.replace(s,s,new k(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function xo(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function So(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!xo(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Co(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=D.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=D.from(r.node(e).copy(u)),d++):c--;let f=D.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=D.from(i.node(e).copy(f)),p++):l++;e.step(new go(c,l,o,s,new k(u.append(f),d,p),u.size-d,!0))}function wo(e,t,n=null,r=e){let i=Eo(e,t),a=i&&Do(r,t);return a?i.map(To).concat({type:t,attrs:n}).concat(a.map(To)):null}function To(e){return{type:e,attrs:null}}function Eo(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function Do(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function Oo(e,t,n){let r=D.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=D.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new go(i,a,i,a,new k(r,0,0),n.length,!0))}function ko(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Mo(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&jo(e,t,n,a),bo(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new go(c,l,c+1,l-1,new k(D.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Ao(e,t,n,a),!1}})}function Ao(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function jo(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
28
+ `))}})}function Mo(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function No(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new go(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new k(D.from(o),0,0),1,!0))}function Po(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Fo(e,t,n=1,r){let i=e.doc.resolve(t),a=D.empty,o=D.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=D.from(i.node(e).copy(a));let t=r&&r[s];o=D.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new ho(t,t,new k(a.append(o),n,n),!0))}function Io(e,t){let n=e.resolve(t),r=n.index();return Ro(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Lo(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Ro(e,t){return!!(e&&t&&!e.isLeaf&&Lo(e,t))}function zo(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);jo(e,r.node(),r.before(),s)}o.inlineContent&&bo(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new ho(l,c.map(t+n,-1),k.empty,!0)),r===!0){let t=e.doc.resolve(l);Ao(e,t.node(),t.before(),e.steps.length)}return e}function Bo(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Vo(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!n)break;n=-n}let o=r.index(t)+ +(n>0),s=r.node(t),c=!1;if(e==1)c=s.canReplace(o,o,i);else{let e=s.contentMatchAt(o).findWrapping(i.firstChild.type);c=e&&s.canReplaceWith(o,o,e[0])}if(c)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}}return null}function Ho(e,t,n=t,r=k.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Uo(i,a,r)?new ho(t,n,r):new Wo(i,a,r).fit()}function Uo(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Wo=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=D.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=D.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new k(i,a,o);return e>-1?new go(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new ho(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=qo(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(D.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return Qo(e,-1)<=t?!1:(this.unplaced.size>1&&Qo(e,1)>n&&n++,this.unplaced=new k(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=qo(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new k(Go(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new k(Go(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Jo(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Ko(this.placed,t,D.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l[l.length-1];t&&e<f;e++)this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),t=t.lastChild;this.unplaced=p?e==0?k.empty:new k(Go(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new k(Go(a.content,e,c),e,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Yo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Yo(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Yo(e,n,r,t,!0);if(!i||i.childCount)continue e}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ko(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Ko(this.placed,this.depth,D.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(D.empty,!0);e.childCount&&(this.placed=Ko(this.placed,this.frontier.length,e))}};function Go(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Go(e.firstChild.content,t-1,n)))}function Ko(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Ko(e.lastChild.content,t-1,n)))}function qo(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Jo(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Jo(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(D.empty,!0)))),e.copy(r)}function Yo(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Xo(n,a.content,o)?s:null}function Xo(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Zo(e){return e.spec.defining||e.spec.definingForContent}function Qo(e,t){for(let n=0;;n++){let r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}function $o(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Uo(i,a,r))return e.step(new ho(t,n,r));let o=rs(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Zo(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new k(es(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function es(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(es(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(D.empty,!0))}return e}function ts(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Bo(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new k(D.from(r),0,0))}function ns(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=rs(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function rs(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var is=class e extends j{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return M.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return M.fromReplace(e,this.pos,this.pos+1,new k(D.from(r),0,+!t.isLeaf))}getMap(){return io.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};j.jsonID(`attr`,is);var as=class e extends j{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return M.ok(n)}getMap(){return io.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};j.jsonID(`docAttr`,as);var ss=class extends Error{};ss=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},ss.prototype=Object.create(Error.prototype),ss.prototype.constructor=ss,ss.prototype.name=`TransformError`;var cs=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ao}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ss(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=k.empty){let r=Ho(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new k(D.from(n),0,0))}delete(e,t){return this.replace(e,t,k.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return $o(this,e,t,n),this}replaceRangeWith(e,t,n){return ts(this,e,t,n),this}deleteRange(e,t){return ns(this,e,t),this}lift(e,t){return Co(this,e,t),this}join(e,t=1){return zo(this,e,t),this}wrap(e,t){return Oo(this,e,t),this}setBlockType(e,t=e,n,r=null){return ko(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return No(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new is(e,t,n)),this}setDocAttribute(e,t){return this.step(new as(e,t)),this}addNodeMark(e,t){return this.step(new po(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof O)t.isInSet(n.marks)&&this.step(new mo(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new mo(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Fo(this,e,t,n),this}addMark(e,t,n){return vo(this,e,t,n),this}removeMark(e,t,n){return yo(this,e,t,n),this}clearIncompatible(e,t,n){return bo(this,e,t,n),this}},ls=Object.create(null),N=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new us(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=k.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?k.empty:t),o==0&&vs(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),vs(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new P(e):_s(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?_s(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):_s(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new hs(e.node(0))}static atStart(e){return _s(e,e,0,0,1)||new hs(e)}static atEnd(e){return _s(e,e,e.content.size,e.childCount,-1)||new hs(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=ls[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ls)throw RangeError(`Duplicate use of selection JSON ID `+e);return ls[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}};N.prototype.visible=!0;var us=class{constructor(e,t){this.$from=e,this.$to=t}},ds=!1;function fs(e){!ds&&!e.parent.inlineContent&&(ds=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var P=class e extends N{constructor(e,t=e){fs(e),fs(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return N.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=k.empty){if(super.replace(e,t),t==k.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ps(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=N.findFrom(n,r,!0)||N.findFrom(n,-r,!0);if(e)n=e.$head;else return N.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(N.findFrom(t,-r,!0)||N.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};N.jsonID(`text`,P);var ps=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}},F=class e extends N{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?N.near(a):new e(a)}content(){return new k(D.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new ms(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};F.prototype.visible=!1,N.jsonID(`node`,F);var ms=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new ps(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&F.isSelectable(n)?new F(t):N.near(t)}},hs=class e extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=k.empty){if(t==k.empty){e.delete(0,e.doc.content.size);let t=N.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return gs}};N.jsonID(`all`,hs);var gs={map(){return this},resolve(e){return new hs(e)}};function _s(e,t,n,r,i,a=!1){if(t.inlineContent)return P.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=_s(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&F.isSelectable(r))return F.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function vs(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof ho||i instanceof go))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(N.near(e.doc.resolve(o),n))}var ys=1,bs=2,xs=4,Ss=class extends cs{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ys)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&ys)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=bs,this}ensureMarks(e){return O.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&bs)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||O.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(N.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=xs,this}get scrolledIntoView(){return(this.updated&xs)>0}};function Cs(e,t){return!t||!e?e:e.bind(t)}var ws=class{constructor(e,t,n){this.name=e,this.init=Cs(t.init,n),this.apply=Cs(t.apply,n)}},Ts=[new ws(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new ws(`selection`,{init(e,t){return e.selection||N.atStart(t.doc)},apply(e){return e.selection}}),new ws(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new ws(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Es=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ts.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new ws(e.key,e.spec.state,e))})}},Ds=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new Ss(this)}static create(t){let n=new Es(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new Es(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Es(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Si.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=N.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function Os(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=Os(i,t,{})),n[r]=i}return n}var ks=class{constructor(e){this.spec=e,this.props={},e.props&&Os(e.props,this,this.props),this.key=e.key?e.key.key:js(`plugin`)}getState(e){return e[this.key]}},As=Object.create(null);function js(e){return e in As?e+`$`+ ++As[e]:(As[e]=0,e+`$`)}var Ms=class{constructor(e=`key`){this.key=js(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Ns=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ps(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Fs=(e,t,n)=>{let r=Ps(e,n);if(!r)return!1;let i=Rs(r);if(!i){let n=r.blockRange(),i=n&&So(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if($s(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Is(a,`end`)||F.isSelectable(a)))for(let n=r.depth;;n--){let o=Ho(e.doc,r.before(n),r.after(n),k.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(Is(a,`end`)?N.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):F.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function Is(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Ls=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Rs(r)}let o=a&&a.nodeBefore;return!o||!F.isSelectable(o)?!1:(t&&t(e.tr.setSelection(F.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Rs(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function zs(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var Bs=(e,t,n)=>{let r=zs(e,n);if(!r)return!1;let i=Hs(r);if(!i)return!1;let a=i.nodeAfter;if($s(e,i,t,1))return!0;if(r.parent.content.size==0&&(Is(a,`start`)||F.isSelectable(a))){let n=Ho(e.doc,r.before(),r.after(),k.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Is(a,`start`)?N.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):F.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},Vs=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=Hs(r)}let o=a&&a.nodeAfter;return!o||!F.isSelectable(o)?!1:(t&&t(e.tr.setSelection(F.create(e.doc,a.pos)).scrollIntoView()),!0)};function Hs(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var Us=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&So(i);return a!=null&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},Ws=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
29
+ `).scrollIntoView()),!0)};function Gs(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var Ks=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=Gs(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(N.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},qs=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof hs||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Gs(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(P.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},Js=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Po(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&So(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Ys(e){return(t,n)=>{if(t.selection instanceof F&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Po(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof P||t.selection instanceof hs)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=Gs(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Po(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Po(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var Xs=Ys(),Zs=(e,t)=>(t&&t(e.tr.setSelection(new hs(e.doc))),!0);function Qs(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Io(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function $s(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Qs(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=D.empty;for(let e=o.length-1;e>=0;e--)s=D.from(o[e].create(null,s));s=D.from(i.copy(s));let c=e.tr.step(new go(t.pos-1,r,t.pos,r,new k(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Io(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:N.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&So(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Is(a,`start`,!0)&&Is(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=D.empty;for(let e=o.length-1;e>=0;e--)r=D.from(o[e].copy(r));n(e.tr.step(new go(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new k(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ec(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(P.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var tc=ec(-1),nc=ec(1);function rc(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&wo(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function ic(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function ac(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function oc(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new us(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new us(r,i))}return t}function sc(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!ac(n.doc,l,e,i))return!1;if(o){if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=oc(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}}return!0}}function cc(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var lc=cc(Ns,Fs,Ls),uc=cc(Ns,Bs,Vs),dc={Enter:cc(Ws,qs,Js,Xs),"Mod-Enter":Ks,Backspace:lc,"Mod-Backspace":lc,"Shift-Backspace":lc,Delete:uc,"Mod-Delete":uc,"Mod-a":Zs},fc={"Ctrl-h":dc.Backspace,"Alt-Backspace":dc[`Mod-Backspace`],"Ctrl-d":dc.Delete,"Ctrl-Alt-Backspace":dc[`Mod-Delete`],"Alt-Delete":dc[`Mod-Delete`],"Alt-d":dc[`Mod-Delete`],"Ctrl-a":tc,"Ctrl-e":nc};for(let e in dc)fc[e]=dc[e];var pc=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?fc:dc,mc=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?hc(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function hc(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var gc=500;function _c({rules:e}){let t=new ks({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return vc(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&vc(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function vc(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=e.state.selection,l=s.parent.textBetween(Math.max(0,s.parentOffset-gc),s.parentOffset,null,``)+r,u=t==c.from&&n==c.to&&e.state.storedMarks||(t==n?s.marks():s.marksAcross(o.doc.resolve(n))||[]);for(let c=0;c<i.length;c++){let d=i[c];if(!d.inCodeMark&&u.some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode===`only`)continue;let f=d.match.exec(l);if(!f||f[0].length<r.length)continue;let p=t-(f[0].length-r.length);if(!d.inCodeMark){let e=!1;if(o.doc.nodesBetween(p,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let m=d.handler(o,f,p,n,r);if(m)return d.undoable&&m.setMeta(a,{transform:m,from:t,to:n,text:r}),e.dispatch(m),!0}return!1}var yc=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new mc(/--$/,`—`,{inCodeMark:!1}),new mc(/\.\.\.$/,`…`,{inCodeMark:!1}),new mc(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new mc(/"$/,`”`,{inCodeMark:!1}),new mc(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new mc(/'$/,`’`,{inCodeMark:!1});function bc(e,t,n,r){let i,a;return t instanceof Wi?a=t:(i=t,a=t.nodeType,n=t.getAttrs,r=t.joinPredicate),new mc(e,(e,t,i,o)=>{let s=n instanceof Function?n(t):n,c=e.tr.delete(i,o),l=c.doc.resolve(i).blockRange(),u=l&&wo(l,a,s);if(!u)return null;c.wrap(l,u);let d=c.doc.resolve(i-1).nodeBefore;return d&&d.type==a&&Io(c.doc,i-1)&&(!r||r(t,d))&&c.join(i-1),c},i)}function xc(e,t,n){let r,i;return t instanceof Wi?i=t:(r=t,i=t.nodeType,n=t.getAttrs),new mc(e,(e,t,r,a)=>{let o=e.doc.resolve(r),s=n instanceof Function?n(t):n;return o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),i)?e.tr.delete(r,a).setBlockType(r,r,i,s):null},r)}for(var Sc={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Cc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},wc=typeof navigator<`u`&&/Mac/.test(navigator.platform),Tc=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),I=0;I<10;I++)Sc[48+I]=Sc[96+I]=String(I);for(var I=1;I<=24;I++)Sc[I+111]=`F`+I;for(var I=65;I<=90;I++)Sc[I]=String.fromCharCode(I+32),Cc[I]=String.fromCharCode(I);for(var Ec in Sc)Cc.hasOwnProperty(Ec)||(Cc[Ec]=Sc[Ec]);function Dc(e){var t=!(wc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Tc&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Cc:Sc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Oc=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),kc=typeof navigator<`u`&&/Win/.test(navigator.platform);function Ac(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))Oc?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function jc(e){let t=Object.create(null);for(let n in e)t[Ac(n)]=e[n];return t}function Mc(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function Nc(e){return new ks({props:{handleKeyDown:Pc(e)}})}function Pc(e){let t=jc(e);return function(e,n){let r=Dc(n),i,a=t[Mc(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Mc(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(kc&&n.ctrlKey&&n.altKey)&&(i=Sc[n.keyCode])&&i!=r){let r=t[Mc(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var L=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t};function Fc(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t}var Ic=null;function Lc(e,t,n){let r=Ic||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r}function Rc(){Ic=null}function zc(e,t,n,r){return n&&(Vc(e,t,n,r,-1)||Vc(e,t,n,r,1))}var Bc=/^(img|br|input|textarea|hr)$/i;function Vc(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:R(e))){let n=e.parentNode;if(!n||!z(n)||Kc(e)||Bc.test(e.nodeName)||e.contentEditable==`false`)return!1;t=L(e)+(i<0?0:1),e=n}else if(z(e)){let n=e.childNodes[t+(i<0?-1:0)];if(z(n)&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else if(Kc(n)||Bc.test(n.nodeName))return!1;else e=n,t=i<0?R(e):0}else return!1}}function R(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function z(e){return e.nodeType==1}function B(e){return e.nodeType==3}function Hc(e,t){return t?e.contains(z(t)?t:t.parentNode):!1}function Uc(e,t){for(;;){if(B(e)&&t)return e;if(z(e)&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=R(e)}else if(e.parentNode&&!Kc(e,!0))t=L(e),e=e.parentNode;else return null}}function Wc(e,t){for(;;){if(B(e)&&t<e.nodeValue.length)return e;if(z(e)&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Kc(e,!0))t=L(e)+1,e=e.parentNode;else return null}}function Gc(e,t,n){for(let r=t==0,i=t==R(e);r||i;){if(e==n)return!0;let t=L(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==R(e)}}function Kc(e,t=!1){let n;for(let t=e;t&&!(n=t.pmViewDesc);t=t.parentNode);return n&&n.node&&(!t||n.node.isBlock)&&(n.dom==e||n.contentDOM==e)}function qc(e){return e.focusNode&&zc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)}function Jc(e,t){e.collapse(t.anchorNode,t.anchorOffset),(t.focusNode!=t.anchorNode||t.focusOffset!=t.anchorOffset)&&e.extend(t.focusNode,t.focusOffset)}function Yc(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Xc(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function Zc(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(R(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(R(r.startContainer),r.startOffset)}}}var Qc=typeof navigator<`u`?navigator:null,$c=typeof document<`u`?document:null,el=Qc&&Qc.userAgent||``,tl=/gecko\/(\d+)/i.test(el)&&!/edge?\//i.test(el);tl&&+(/Firefox\/(\d+)/.exec(el)||[0,0])[1];var nl=/Chrome\/(\d+)/.exec(el),V=!!nl,rl=nl?+nl[1]:0,H=!!Qc&&/Apple Computer/.test(Qc.vendor),il=H&&(/Mobile\/\w+/.test(el)||!!Qc&&Qc.maxTouchPoints>2),al=il||(Qc?/Mac/.test(Qc.platform):!1),ol=Qc?/Win/.test(Qc.platform):!1,sl=/Android \d/.test(el),cl=!!$c&&`webkitFontSmoothing`in $c.documentElement.style,ll=cl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ul(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function dl(e,t){return typeof e==`number`?e:e[t]}function fl(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function pl(e,t,n){for(;;)if(n<0?t:t<R(e)){if(B(e))return Ml(Lc(e,t+(n<0?-1:0),t+ +(n>0)),-n);let r=e.childNodes[n<0?t-1:t];if(B(r))e=r,t=n<0?r.nodeValue.length:0;else if(z(r))return Ml(r,-n);else return null}else if(Kc(e,!0)||!e.parentNode)return null;else t=L(e)+(n<0?0:1),e=e.parentNode}function ml(e,t,n){if(!jl(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(!z(o)){o=Fc(o);continue}let e=o==a.body,n=e?ul(a):fl(o),s=0,c=0;if(t.top<n.top+dl(r,`top`)?c=-(n.top-t.top+dl(i,`top`)):t.bottom>n.bottom-dl(r,`bottom`)&&(c=t.bottom-t.top>n.bottom-n.top?t.top+dl(i,`top`)-n.top:t.bottom-n.bottom+dl(i,`bottom`)),t.left<n.left+dl(r,`left`)?s=-(n.left-t.left+dl(i,`left`)):t.right>n.right-dl(r,`right`)&&(s=t.right-n.right+dl(i,`right`)),s||c){if(e)a.defaultView.scrollBy(s,c);else{let e=o.scrollLeft,n=o.scrollTop;c&&(o.scrollTop+=c),s&&(o.scrollLeft+=s);let r=o.scrollLeft-e,i=o.scrollTop-n;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}}let l=e?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(l))break;o=l==`absolute`?o.offsetParent:Fc(o)}}function hl(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:gl(e.dom)}}function gl(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Fc(r));return t}function _l({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;vl(n,r==0?0:r-t)}function vl(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var yl=null;function bl(e){if(e.setActive)return e.setActive();if(yl)return e.focus(yl);let t=gl(e);e.focus(yl==null?{get preventScroll(){return yl={preventScroll:!0},!0}}:void 0),yl||(yl=!1,vl(t,0))}function xl(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(z(u))e=u.getClientRects();else if(B(u))e=Lc(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&B(n)?{left:p.right<t.left?p.right:p.left,top:t.top}:t,z(u)&&e&&(a=d+ +(t.left>=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&B(n)?Sl(n,i):!n||r?{node:e,offset:a}:xl(n,i)}function Sl(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=Ml(r,1);if(n.top!=n.bottom&&Cl(t,n)){i={node:e,offset:a+ +(t.left>=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function Cl(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function wl(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function Tl(e,t,n){let{node:r,offset:i}=xl(t,n),a=-1;if(z(r)&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return{pos:e.docView.posFromDOM(r,i,a),affinity:Dl(r,i,n)}}function El(e,t){return e<t.left?t.left-e:e>t.right?e-t.right:0}function Dl(e,t,n){let r=pl(e,t,-1),i=pl(e,t,1);return r?i?r.bottom<=i.top?n.top>(r.bottom+i.top)/2?1:-1:El(n.left,r)<El(n.left,i)?-1:1:-1:1}function Ol(e,t,n,r){let i=-1;for(let n=t;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),a;if(!t)return null;if(z(t.dom)&&((a=t.dom.getBoundingClientRect()).width||a.height)){if(!t.contentDOM&&!t.node.isText&&r.left>=a.left&&r.left<=a.right&&r.top>=a.top&&r.top<=a.bottom){let e=t.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2;return{pos:e?t.posBefore:t.posAfter,affinity:e?1:-1}}t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(r.top<a.top||r.top>a.bottom)&&(i=r.top<a.top?t.posBefore:t.posAfter)}n=t.dom.parentNode}return i>-1?{pos:i,affinity:0}:{pos:e.docView.posFromDOM(t,n,-1),affinity:Dl(t,n,r)}}function kl(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(z(n)){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(Cl(t,i))return kl(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function Al(e,t){let n=e.dom.ownerDocument,r,i=0,a=Zc(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s,c=0;if(!o||!e.dom.contains(o)){let n=e.dom.getBoundingClientRect();if(!Cl(t,n)||(o=kl(e.dom,t,n),!o))return null}if(H)for(let e=o;r&&e;e=Fc(e))e.draggable&&(r=void 0);if(o=wl(o,t),r){if(tl&&z(r)&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;if(cl&&i&&z(r)&&z(n=r.childNodes[i-1])&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&z(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom)s=e.state.doc.content.size;else if(i==0||!z(r)||r.childNodes[i-1].nodeName!=`BR`){let n=Ol(e,r,i,t);n&&({pos:s,affinity:c}=n)}}s??({pos:s,affinity:c}=Tl(e,o,t));let l=e.docView.nearestDesc(o,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1,affinity:c}}function jl(e){return e.top<e.bottom||e.left<e.right}function Ml(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(jl(e))return e}return Array.prototype.find.call(n,jl)||e.getBoundingClientRect()}var Nl=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pl(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=cl||tl;if(B(r)){if(o&&(Nl.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=Ml(Lc(r,i,i),n);if(tl&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Ml(Lc(r,i-1,i-1),-1);if(t.top==e.top){let n=Ml(Lc(r,i,i+1),-1);if(n.top!=e.top)return Fl(n,n.left<t.left)}}return e}{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Fl(Ml(Lc(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==R(r))){let e=r.childNodes[i-1];if(z(e))return Il(e.getBoundingClientRect(),!1)}if(a==null&&i<R(r)){let e=r.childNodes[i];if(z(e))return Il(e.getBoundingClientRect(),!0)}return Il(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==R(r))){let e=r.childNodes[i-1],t=B(e)?Lc(e,R(e)-+!o):z(e)&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Fl(Ml(t,1),!1)}if(a==null&&i<R(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?B(e)?Lc(e,0,+!o):z(e)?e:null:null;if(t)return Fl(Ml(t,-1),!0)}return Fl(Ml(B(r)?Lc(r):r,-n),n>=0)}function Fl(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Il(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Ll(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Rl(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Ll(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Pl(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(z(e))t=e.getClientRects();else if(B(e))t=Lc(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var zl=/[\u0590-\u08ac]/;function Bl(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!zl.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Ll(e,t,()=>{let t=e.domSel.readRange(),i=s.caretBidiLevel;s.modify(`move`,n,`character`);let a=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:o,focusOffset:c}=e.domSel.readRange(),l=o&&!Hc(a,o)||t.focusNode==o&&t.focusOffset==c;return Jc(s,t),i!=null&&(s.caretBidiLevel=i),l}):r.pos==r.start()||r.pos==r.end()}var Vl=null,Hl=null,Ul=!1;function Wl(e,t,n){return Vl==t&&Hl==n?Ul:(Vl=t,Hl=n,Ul=n==`up`||n==`down`?Rl(e,t,n):Bl(e,t,n))}var Gl=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.damage=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&Hc(this.contentDOM,e)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>L(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=n&16?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(n&4)}else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(z(a)?Hc(a,e):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof Ql||e instanceof Kl&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?L(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?L(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=L(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=L(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!z(t)||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Kl=class extends Gl{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=z(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ql=class extends Gl{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Jl=class e extends Gl{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=fa.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)==null||t.markDamage(2)}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=hu(a,n,o,r)),t>0&&(a=hu(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Yl=class e extends Gl{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!B(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=fa.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ou(u,r,n),l?c=new $l(t,n,r,i,u,d||null,f,l):n.isText?new Zl(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>z(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>D.empty}}return t}matchesNode(e,t,n){return!this.damage&&e.eq(this.node)&&su(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new lu(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;fu(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?O.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(f=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,u,f,e,r)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.damage&2)&&(a&&this.protectLocalComposition(e,a),eu(this.contentDOM,this.children,e),il&&pu(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof P)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=mu(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new ql(this,i,t,r);e.input.compositionNodes.push(a),this.children=hu(this.children,n,n+r.length,e,a)}update(e,t,n,r,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r,i),!0)}updateInner(e,t,n,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,i+1),this.damage=0}updateOuterDeco(e){if(su(e,this.outerDeco))return;let t=!z(this.nodeDOM),n=this.dom;this.dom=iu(this.dom,this.nodeDOM,ru(this.outerDeco,this.node,t),ru(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){z(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){z(this.nodeDOM)&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Xl(e,t,n,r,i,a){a?iu(r,r,ru(a,e,!1),ru(t,e,!1)):ou(r,t,e);let o=new Yl(void 0,e,t,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}var Zl=class e extends Yl{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return!1}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ql=class extends Gl{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},$l=class extends Yl{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,t,n);return a&&this.updateInner(e,t,n,r,i),a}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function eu(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=cu(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Jl){let t=r?r.previousSibling:e.lastChild;eu(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=cu(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var tu=function(e){e&&(this.nodeName=e)};tu.prototype=Object.create(null);var nu=[new tu];function ru(e,t,n){if(e.length==0)return nu;let r=n?nu[0]:new tu,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new tu(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new tu(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function iu(e,t,n,r){if(n==nu&&r==nu)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName||(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=nu[0]),i=t}au(i,o||nu[0],a)}return i}function au(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function ou(e,t,n){return iu(e,e,nu,ru(t,n,!z(e)))}function su(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function cu(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var lu=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=uu(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof Jl&&!(t.damage&4)&&t.mark.type==e[a].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[a])&&(t.mark=e[a],i=this.index,this.changed=!0)}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Jl.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i,a){let o=this.top.children[r];return o.damage&4&&o.dom==o.contentDOM&&(o.damage=2),o.update(e,t,n,i,a)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Yl){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&!(s.damage&4)&&su(t,s.outerDeco));if(!d&&s.update(e,t,n,r,a))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.damage|=2,u.updateChildren(r,a+1),u.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!su(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Yl.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Yl.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Kl(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Jl;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Zl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((H||V)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Ql(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||z(e)&&e.contains(this.lock.parentNode))}};function uu(e,t){let n=t,r=n.children.length,i=[],a=e.childCount,o=new Map,s=[];e:for(;a>0;){let c;for(;;)if(r){let e=n.children[r-1];if(e instanceof Jl)i.push(r-1),n=e,r=e.children.length;else{c=e,r--;break}}else if(n==t)break e;else r=i.pop(),n=n.parent;let l=c.node;if(l){if(l!=e.child(a-1))break;--a,o.set(c,a),s.push(c)}}return{index:a,matched:o,matches:s.reverse()}}function du(e,t){return e.type.side-t.type.side}function fu(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u){if(d){d.sort(du);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c)}let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function pu(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function mu(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function hu(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function gu(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&N.findFrom(a,t)}function _u(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function vu(e,t,n){let r=e.state.selection;if(r instanceof P){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return _u(e,new P(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=gu(e.state,t);return n&&n instanceof F?_u(e,n):!1}if(!al||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?F.isSelectable(i)?_u(e,new F(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):_u(e,new P(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof F&&r.node.isInline)return _u(e,new P(t>0?r.$to:r.$from));else{let n=gu(e.state,t);return n?_u(e,n):!1}}function yu(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):z(e)&&e.contentEditable==`false`}function bu(e,t){return t<0?xu(e):Su(e)}function xu(e){let t=e.domSel.readRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(tl&&z(n)&&r<R(n)&&yu(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!z(n))break;let e=n.childNodes[r-1];if(yu(e,-1))i=n,a=--r;else if(B(e))n=e,r=n.nodeValue.length;else break}else if(Cu(n))break;else{let t=n.previousSibling;for(;t&&yu(t,-1);)i=n.parentNode,a=L(t),t=t.previousSibling;if(t)n=t,r=R(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?wu(e,n,r):i&&wu(e,i,a)}function Su(e){let t=e.domSel.readRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=R(n),a,o;for(;;)if(r<i){if(!z(n))break;if(yu(n.childNodes[r],1))a=n,o=++r;else break}else if(Cu(n))break;else{let t=n.nextSibling;for(;t&&yu(t,1);)a=t.parentNode,o=L(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=R(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&wu(e,a,o)}function Cu(e){for(let t=e;t;t=t.parentNode){let e=t.pmViewDesc;if(e)return e.node?e.node.isBlock:!1}return!1}function wu(e,t,n){if(!B(t)){let e,r;(r=Wc(t,n))?(t=r,n=0):(e=Uc(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection(),i=e.domSel.readRange();if(!r)return;qc(i)?r.collapse(t,n):r.extend&&(r.collapse(i.anchorNode,i.anchorOffset),r.extend(t,n)),e.domSel.ignore();let{state:a}=e;setTimeout(()=>{e.state==a&&e.domSel.sync()},50)}function Tu(e,t){let n=e.state.doc.resolve(t);if(!(V||ol)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function Eu(e,t,n){let r=e.state.selection;if(r instanceof P&&!r.empty||n.indexOf(`s`)>-1||al&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=gu(e.state,t);if(n&&n instanceof F)return _u(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof hs?N.near(n,t):N.findFrom(n,t);return o?_u(e,o):!1}return!1}function Du(e,t){if(!(e.state.selection instanceof P))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Ou(e,t,n){e.domObserver.stopped(()=>t.contentEditable=n)}function ku(e){if(!H||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSel.readRange();if(t&&z(t)&&n==0&&t.firstChild&&z(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Ou(e,n,`true`),setTimeout(()=>Ou(e,n,`false`),20)}return!1}function Au(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function ju(e,t){let n=t.keyCode,r=Au(t);if(n==8||al&&n==72&&r==`c`)return Du(e,-1)||bu(e,-1);if(n==46&&!t.shiftKey||al&&n==68&&r==`c`)return Du(e,1)||bu(e,1);if(n==13||n==27)return!0;if(n==37||al&&n==66&&r==`c`){let t=n==37?Tu(e,e.state.selection.from)==`ltr`?-1:1:-1;return vu(e,t,r)||bu(e,t)}if(n==39||al&&n==70&&r==`c`){let t=n==39?Tu(e,e.state.selection.from)==`ltr`?1:-1:1;return vu(e,t,r)||bu(e,t)}return n==38||al&&n==80&&r==`c`?Eu(e,-1,r)||bu(e,-1):n==40||al&&n==78&&r==`c`?ku(e)||Eu(e,1,r)||bu(e,1):!(r!=(al?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Mu(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||fa.fromSchema(e.state.schema),s=Hu(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&z(l)&&(u=Vu[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&z(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
30
+
31
+ `),slice:t}}function Nu(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new k(D.from(e.state.schema.text(t.replace(/\r\n?/g,`
32
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=fa.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=Gu(n),cl&&Ku(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&!z(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Qi.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Pu.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=qu(Bu(s,+u[1],+u[2]),u[4]);else if(s=k.maxOpen(Fu(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Bu(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,r)}),s}var Pu=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Fu(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&Lu(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Ru(a[a.length-1],i.length));let n=Iu(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return D.from(a)}return e}function Iu(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,D.from(e));return e}function Lu(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Lu(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(D.from(Iu(n,e,i+1))))}}function Ru(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Ru(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(D.empty,!0);return e.copy(n.append(r))}function zu(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=zu(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(D.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Bu(e,t,n){return t<e.openStart&&(e=new k(zu(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new k(zu(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var Vu={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function Hu(){return document.implementation.createHTMLDocument(`title`)}var Uu=null;function Wu(e){let t=window.trustedTypes;if(!t)return e;if(!Uu){if(Uu=t.defaultPolicy)try{return Uu.createHTML(e)}catch{}Uu=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return Uu.createHTML(e)}function Gu(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=Hu(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&Vu[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=Wu(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function Ku(e){let t=e.querySelectorAll(V?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function qu(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs()||!t.createAndFill(null,i))break;try{i=D.from(t.create(r[e+1],i))}catch{break}a++,o++}return new k(i,a,o)}var Ju=class e{constructor(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}static from(t){return t instanceof e?t:new e(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Ju.null=new Ju(null,0,null,0);var Yu=class{constructor(e){this.view=e,this.range=Ju.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener(`selectionchange`,this.onSelectionChange),this.currentDocument=e,e.addEventListener(`selectionchange`,this.onSelectionChange))}destroy(){this.currentDocument&&=(this.currentDocument.removeEventListener(`selectionchange`,this.onSelectionChange),null),this.active=!1,this.range=Ju.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?H&&e.root.nodeType===11&&Xc(e.dom.ownerDocument)==e.dom?Ju.from(Xu(e,t)||t):Ju.from(t):Ju.null}read(){this.ensureListener();let e=fd(this.view);if(!e)this.active=!1,this.range=Ju.null;else return this.active=!0,!this.range.eq(e)&&(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{ld(t,t.state.selection);let n=t.state.selection;if(t.input.mouseSelecting||$u(t)){let{desc:r,start:i}=td(t.docView,n.from,n.to,0);t.cursorWrapper?cd(t):r instanceof $l&&r.spec.setSelection?r.spec.setSelection(n.anchor-i,n.head-i,t.root):ed(t,e,r,i),this.synced=this.active=!0}n.visible==t.dom.classList.contains(`ProseMirror-hideselection`)&&(n.visible?t.dom.classList.remove(`ProseMirror-hideselection`):(t.dom.classList.add(`ProseMirror-hideselection`),sd(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Ju.from(e),this.synced=!0}deactivate(){this.range=Ju.null,this.active=this.synced=!1}};function Xu(e,t){if(t.getComposedRanges){let n=t.getComposedRanges({shadowRoots:[e.root]})[0];if(n)return Zu(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?Zu(e,n):null}function Zu(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return zc(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),new Ju(n,r,i,a)}function Qu(e,t,n=null){let r=e.state.doc;if(!t.focusNode)return null;let i=e.docView.nearestDesc(t.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(qc(t)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&F.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Gc(t.focusNode,t.focusOffset,i.dom))){let e=i.posBefore;l=new F(o==e?s:r.resolve(e))}else if(tl&&n==`key`&&o>e.state.selection.to&&z(t.focusNode)&&t.focusOffset==t.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=t.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=N.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!z(e.parentNode))break}}else{if(t instanceof e.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let n=o,i=o;for(let r=0;r<t.rangeCount;r++){let a=t.getRangeAt(r);n=Math.min(n,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(n<0)return null;[c,o]=i==e.state.selection.anchor?[i,n]:[n,i],s=r.resolve(o)}else c=e.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let t=n==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=dd(e,u,s,t)}return l}function $u(e){return e.editable?e.hasFocus():pd(e,e.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(e.dom))}function ed(e,t,n,r){let i=e.state.selection,{anchor:a,head:o}=i,s,c;rd&&!(i instanceof P)&&(i.$from.parent.inlineContent||(s=id(e,i.from)),!i.empty&&!i.$from.parent.inlineContent&&(c=id(e,i.to)));let l=n.domFromPos(a-r,a>r?-1:1);nd(a,o,l,o==a?l:n.domFromPos(o-r,o>r?-1:1),e,t),rd&&(s&&od(s),c&&od(c))}function td(e,t,n,r=0){for(let i=0,a=r;i<e.children.length;i++){let r=e.children[i],o=a+r.size;if(t>a&&n<o)return td(r,t,n,a+r.border);a=o}return{desc:e,start:r}}function nd(e,t,n,r,i,a){let o=!1;if((tl||H)&&e==t){let{node:e,offset:t}=n;if(B(e)){if(o=!!(t&&e.nodeValue[t-1]==`
33
+ `),o&&t==e.nodeValue.length)for(let t=e,i;t;t=t.parentNode){if(i=t.nextSibling){i.nodeName==`BR`&&(n=r={node:i.parentNode,offset:L(i)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];o=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}let s=i.domSel.readRange();if(tl&&s.focusNode&&s.focusNode!=r.node&&z(s.focusNode)){let e=s.focusNode.childNodes[s.focusOffset];e&&e.contentEditable==`false`&&(a=!0)}if(!(a||o&&H)&&zc(n.node,n.offset,s.anchorNode,s.anchorOffset)&&zc(r.node,r.offset,s.focusNode,s.focusOffset))return;let c=i.domSelection(),l=i.input.mouseSelecting;if(l&&l.affinity&&e==t&&l.pos==e){let{affinity:e}=l,{node:t,offset:n}=r,a,o=0;if(B(t)&&(e>0?n<R(t):n>0)?(a=t,o=n+e):(a=(e>0?Wc:Uc)(t,n),a&&(o=e>0?1:a.nodeValue.length-1)),a){c.collapse(a,o),c.modify(`move`,e>0?`backward`:`forward`,`lineboundary`);let{focusNode:r,focusOffset:s}=c;if(H&&i.root.nodeType==11){let e=c.getComposedRanges({shadowRoots:[i.root]});e.length&&(r=e[0].startContainer,s=e[0].startOffset)}if(zc(t,n,r,s))return}}Jc(c,{focusNode:r.node,focusOffset:r.offset,anchorNode:n.node,anchorOffset:n.offset})}var rd=H||V&&rl<63;function id(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(H&&i&&i.contentEditable==`false`)return ad(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return ad(i);if(a)return ad(a)}}function ad(e){return e.contentEditable=`true`,H&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function od(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function sd(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSel.readRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!$u(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function cd(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom;n.nodeName==`IMG`?t.collapse(n.parentNode,L(n)+1):t.collapse(n,0)}function ld(e,t){if(t instanceof F){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ud(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ud(e)}function ud(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function dd(e,t,n,r){let i=e.someProp(`createSelectionBetween`,r=>r(e,t,n))||P.between(t,n,r);return e.someProp(`adjustSelectionFromDOM`,t=>{i=t(e,i)}),i}function fd(e){if(e.editable&&!e.hasFocus())return null;let t=e.domSel.readRange();return t&&pd(e,t)?t:null}function pd(e,t){if(!t.anchorNode)return!1;try{return Hc(e.dom,t.anchorNode)&&(e.editable||Hc(e.dom,t.focusNode))}catch{return!1}}var U={},W={},md={touchstart:!0,touchmove:!0},hd=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.mouseSelecting=null,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function gd(e){for(let t in U){let n=U[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{xd(e,t)&&(e.input.composing&&(t.type==`keydown`||t.type==`beforeinput`)&&t.isComposing===!1&&Wd(e,!0),bd(e,t)||!e.editable&&t.type in W||n(e,t))},md[t]?{passive:!0}:void 0)}H&&e.dom.addEventListener(`input`,()=>null),yd(e)}function _d(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function vd(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function yd(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>bd(e,t))})}function bd(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function xd(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Sd(e,t){!bd(e,t)&&U[t.type]&&(e.editable||!(t.type in W))&&U[t.type](e,t)}function Cd(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Yc(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}W.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(sl&&V&&n.keyCode==13)){if(il&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(Cd(e,`Enter`),e.input.lastIOSEnter=0)},200)}else n.keyCode!=229&&e.domObserver.forceFlush(!0),Cd(e,n)||ju(e,n)?n.preventDefault():_d(e,`key`)}},W.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},W.keypress=(e,t)=>{let n=t;if(Vd(e)||!n.charCode||n.ctrlKey&&!n.altKey||al&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function wd(e){return{left:e.clientX,top:e.clientY}}function Td(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Ed(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Dd(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Od(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&F.isSelectable(r)?(Dd(e,new F(n)),!0):!1}function kd(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof F&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(F.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Dd(e,F.create(e.state.doc,i)),!0)}function Ad(e,t,n,r,i){return Ed(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?kd(e,n):Od(e,n))}function jd(e,t,n,r){return Ed(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Md(e,t,n,r){return Ed(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))}function Nd(e,t,n){if(t==-1)return e.inlineContent?P.create(e,0,e.content.size):null;let r=e.resolve(t);for(let t=r.depth+1;t>0;t--){let i=t>r.depth?r.nodeAfter:r.node(t),a=r.before(t);if(i.inlineContent)return P.create(e,a+1,a+1+i.content.size);if(n&&F.isSelectable(i))return F.create(e,a)}return null}var Pd=/[\w_\u00a1-\uffff]+/g;try{Pd=RegExp(`[\\p{L}\\p{N}_]+`,`gu`)}catch{}function Fd(e,t){let n=e.resolve(t),r=n.node(),i=``,a=t,o=t;for(let e=n.indexAfter(),o=!1;e>0;e--){let s=r.child(e-1);if(!s.text)break;let c=a==t?t-n.posAtIndex(e-1):s.text.length,l=c;for(;l>0;l--)if(/\S/.test(s.text[l-1]))o=!0;else if(o)break;if(i=s.text.slice(l,c)+i,a-=c-l,l||a<t-50)break}for(let e=n.index(),a=!1;e<r.childCount;e++){let s=r.child(e);if(!s.text)break;let c=o==t?t-n.posAtIndex(e):0,l=c;for(;l<s.text.length;l++)if(/\S/.test(s.text[l]))a=!0;else if(a)break;if(i+=s.text.slice(c,l),o+=l-c,l<s.text.length||o>t+50)break}let s=a,c=o;if(Intl.Segmenter){for(let n of new Intl.Segmenter(void 0,{granularity:`word`}).segment(i))if(n.isWordLike){let r=n.index+a,i=r+n.segment.length;if(i<t)s=i;else if(r>t){c=r;break}else return P.create(e,r,i)}}else{Pd.lastIndex=0;for(let n;n=Pd.exec(i);){let r=n.index+a,i=r+n[0].length;if(i<t)s=i;else if(r>t){c=r;break}else return P.create(e,r,i)}}let l=i.slice(s-a,t-a),u=i.slice(t-a,c-a),d=/\S*$/.exec(l)[0].length,f=/^\S*/.exec(u)[0].length;if(d||f)return P.create(e,t-d,t+f);let p=/\s*$/.exec(l)[0].length,m=/^\s*/.exec(u)[0].length;return P.create(e,t-p,t+m)}var Id=al?`metaKey`:`ctrlKey`;U.mousedown=(e,t)=>{let n=t,r=Date.now();if(e.input.shiftKey=n.shiftKey,e.input.lastTouch>r-500)return!1;Jd(e);let i=`singleClick`;r-e.input.lastClick.time<500&&Td(n,e.input.lastClick)&&!n[Id]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?i=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(i=`tripleClick`)),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let a=e.posAtCoords(wd(n));if(a){if(n.button==0){if(!e.hasFocus()){bl(e.dom);let t=e.root.activeElement;t&&!t.contains(e.dom)&&t.blur()}(e.input.mouseDown=new Ld(e,a,n,i)).mightDrag||n.preventDefault()}else _d(e,`pointer`)}};var Ld=class{constructor(e,t,n,r){this.view=e,this.startPos=t,this.event=n,this.type=r,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!n[Id],this.extend=n.shiftKey,this.anchorDoc=this.startDoc;let i=Rd(e);if(this.extend){let t=e.state.selection;this.anchorRange=t instanceof F?{from:t.from,to:t.to}:{from:t.anchor,to:t.anchor};let n=t instanceof F?e.nodeDOM(t.from).getBoundingClientRect():e.coordsAtPos(t.anchor);this.anchorOffset={x:(n.left+n.right)/2-i.x,y:(n.top+n.bottom)/2-i.y}}else this.anchorOffset={x:n.clientX-i.x,y:n.clientY-i.y};if(r==`singleClick`){let{selection:r}=e.state,i,a,o=!1;if(r instanceof F&&r.from<=t.pos&&r.to>=t.pos)a=r.from,i=r.node,o=!0;else if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():-1}if(o||a>-1&&i.type.spec.draggable&&i.type.spec.selectable!==!1){let t=e.docView.descAt(a)?.nodeDOM;this.mightDrag={node:i,elt:t,pos:a,addAttr:!1},t&&!t.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>t.draggable=!0))}else this.mightDrag=Bd(e,n)}else this.mightDrag=!1;e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag==`object`&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute(`draggable`))}maybeRunHandler(e,t){return(this.type==`singleClick`?Ad:this.type==`doubleClick`?jd:Md)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(wd(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0)this.done();else{if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(wd(e));t&&this.select(t,!1)}e.preventDefault()}}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:n}=this,{doc:r}=n.state,i=this.type==`singleClick`?zd(n,r,e):this.type==`doubleClick`?Fd(r,e.pos):Nd(r,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(r.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=dd(n,r.resolve(this.anchorRange.from),r.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=dd(n,r.resolve(this.anchorRange.to),r.resolve(i.from)))),i.eq(n.state.selection)||(n.input.mouseSelecting=e,n.dispatch(n.state.tr.setSelection(i).setMeta(`pointer`,!0).scrollIntoView()),n.input.mouseSelecting=null))}restoreAnchor(){let e=Rd(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:e}=this.view.state;this.anchorRange=this.type==`singleClick`?zd(this.view,e,t):this.type==`doubleClick`?Fd(e,t.pos):Nd(e,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function Rd(e){let t=e.dom.getBoundingClientRect();return{x:t.left-e.dom.scrollLeft,y:t.top-e.dom.scrollTop}}function zd(e,t,n){if(n.inside>-1){let e=t.nodeAt(n.inside);if(e.isAtom&&F.isSelectable(e))return F.create(t,n.inside)}let r=t.resolve(n.pos);return dd(e,r,r)}function Bd(e,t){let{selection:n}=e.state;if(n.empty)return!1;let r=e.domSelection();if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}U.touchstart=e=>{e.input.lastTouch=Date.now(),Jd(e),_d(e,`pointer`)},U.touchmove=e=>{e.input.lastTouch=Date.now(),_d(e,`pointer`)},U.contextmenu=e=>Jd(e);function Vd(e,t){return e.composing?!0:H&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Hd=sl?5e3:-1;W.compositionstart=W.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof P&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||V&&ol&&Ud(e)))e.markCursor=e.state.storedMarks||n.marks(),Jd(e,!0),e.markCursor=null;else if(Jd(e,!t.selection.empty),tl&&e.domSel.active&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(let{focusNode:t,focusOffset:n}=e.domSel.range;t&&z(t)&&n!=0;){let r=n<0?t.lastChild:t.childNodes[n-1];if(!r)break;if(B(r)){let t=e.domSelection();t&&t.collapse(r,r.nodeValue.length);break}t=r,n=-1}e.input.composing=!0}Gd(e,Hd)};function Ud(e){let{focusNode:t,focusOffset:n}=e.domSel.range;if(!t||!z(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return z(r)&&r.contentEditable==`false`}W.compositionend=(e,t)=>{e.composing&&Wd(e)};function Wd(e,t=!1){e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,t?Jd(e):Gd(e,20)}function Gd(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Jd(e),t))}function Kd(e){e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());for(let t;t=e.input.compositionNodes.pop();)t.markParentDamage()}function qd(e){let t=e.domSel.range;if(!e.domSel.active||!t.focusNode)return null;let n=Uc(t.focusNode,t.focusOffset),r=Wc(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Jd(e,t=!1){if(!(sl&&e.domObserver.flushingSoon>=0)&&(e.domObserver.forceFlush(),Kd(e),t||e.docView&&e.docView.damage)){let n=Qu(e,e.domSel.readRange()),r=e.state.selection;n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state)}}function Yd(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Xd=il&&ll<604;U.copy=W.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Xd?null:n.clipboardData,{dom:o,text:s}=Mu(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Yd(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Zd(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Qd(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?$d(e,r.value,null,i,t):$d(e,r.textContent,r.innerHTML,i,t)},50)}function $d(e,t,n,r,i){let a=Nu(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||k.empty)))return!0;if(!a)return!1;let o=Zd(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function ef(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}W.paste=(e,t)=>{let n=t;if(e.composing&&!sl)return;let r=Xd?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&$d(e,ef(r),r.getData(`text/html`),i,n)?n.preventDefault():Qd(e,n)};var tf=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},nf=al?`altKey`:`ctrlKey`;function rf(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[nf]:!n}U.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(wd(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof F?i.to-1:i.to))){if(r&&typeof r.mightDrag==`object`)o=F.create(e.state.doc,r.mightDrag.pos);else if(n.target&&z(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=F.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Mu(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!V||rl>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xd?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Xd||n.dataTransfer.setData(`text/plain`,c),e.dragging=new tf(l,rf(e,n),o)},U.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},W.dragover=W.dragenter=(e,t)=>t.preventDefault(),W.drop=(e,t)=>{try{af(e,t,e.dragging)}finally{e.dragging=null}};function af(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(wd(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Nu(e,ef(t.dataTransfer),Xd?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&rf(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||k.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Vo(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&F.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new F(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(dd(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}U.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused&&(e.domObserver.stopped(()=>e.dom.classList.add(`ProseMirror-focused`)),e.focused=!0,e.domSel.read(),!e.domSel.synced)){let t=e.domSel.range;setTimeout(()=>{let n=e.domSel.readRange();n&&t.eq(n)&&e.domSel.sync()},20)}},U.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stopped(()=>e.dom.classList.remove(`ProseMirror-focused`)),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domSel.deactivate(),!1)},U.beforeinput=(e,t)=>{if(sl&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),Cd(e,`Backspace`)))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in W)U[e]=W[e];function of(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var sf=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},cf=class e{constructor(e,t){this.toDOM=e,this.spec=t||pf,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new df(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&of(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},lf=class e{constructor(e,t){this.attrs=e,this.spec=t||pf}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new df(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&of(this.attrs,t.attrs)&&of(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},uf=class e{constructor(e,t){this.attrs=e,this.spec=t||pf}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new df(i.pos-n,a.pos-n,this)}valid(e,t,n){let r=n.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(t){return this==t||t instanceof e&&of(this.attrs,t.attrs)&&of(this.spec,t.spec)}destroy(){}},df=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new cf(n,r))}static inline(t,n,r,i){return new e(t,n,new lf(r,i))}static node(t,n,r,i){return new e(t,n,new uf(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof lf}get widget(){return this.type instanceof cf}},ff=[],pf={},G=class e{constructor(e,t){this.local=e.length?e:ff,this.children=t.length?t:ff}static create(e,t){return t.length?bf(t,e,0,pf):K}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];if(o.from>t)break;o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length&&!(this.children[a]>=t);a+=3)if(this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==K||e.maps.length==0?this:this.mapInner(e,t,0,0,n||pf)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new sf(n.content);for(let s=0;s<this.local.length;s++){let c=this.local[s].map(t,r,i);c&&c.type.valid(n,c,e)?(o||=[]).push(c):a.onRemove&&a.onRemove(this.local[s].spec)}}return this.children.length?hf(this.children,o||[],t,n,r,i,a):o?new e(o.sort(xf),ff):K}add(t,n){return n.length?this==K?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=vf(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,bf(s,e,o+1,pf)),a+=3}});let o=gf(a?yf(n):n,-r).sort(xf);if(o.length){let e=new sf(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||o.splice(n--,1)}return new e(o.length?this.local.concat(o).sort(xf):this.local,i||this.children)}remove(e){return e.length==0||this==K?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==K?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):K}forChild(t,n){if(this==K)return this;if(n.isLeaf)return e.empty;let r,i,a=0,o=this.children.length/3;for(;a<o;){let e=a+o>>>1,n=e*3,i=this.children[n];if(i<t)a=e+1;else if(i>t)o=e;else{r=this.children[n+2];break}}let s=t+1,c=s+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<c&&t.to>s&&t.type instanceof lf){let e=Math.max(s,t.from)-s,n=Math.min(c,t.to)-s;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(xf),ff);return r?new mf([t,r]):t}return r||K}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return Sf(this.localsInner(e))}localsInner(e){if(this==K)return ff;if(e.inlineContent||!this.local.some(lf.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof lf||t.push(this.local[e]);return t}forEachSet(e){e(this)}};G.empty=new G([],[]),G.removeOverlap=Sf;var K=G.empty,mf=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,pf));return e.from(r)}forChild(t,n){if(n.isLeaf)return G.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=K&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length){if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}}return t?Sf(n?t:t.sort(xf)):ff}static from(t){switch(t.length){case 0:return K;case 1:return t[0];default:return new e(t.every(e=>e instanceof G)?t:t.reduce((e,t)=>e.concat(t instanceof G?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hf(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==K?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=bf(_f(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new G(t.sort(xf),s)}function gf(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new df(i.from+t,i.to+t,i.type))}return n}function _f(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function vf(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function yf(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function bf(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=vf(e,t,o+n);if(s){a=!0;let e=bf(s,t,n+o+1,r);e!=K&&i.push(o,o+t.nodeSize,e)}});let o=gf(a?yf(e):e,-n).sort(xf);if(o.length){let e=new sf(t.content);for(let n=0;n<o.length;n++)o[n].type.valid(t,o[n],e)||(r.onRemove&&r.onRemove(o[n].spec),o.splice(n--,1))}return o.length||i.length?new G(o,i):K}function xf(e,t){return e.from-t.from||e.to-t.to}function Sf(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from)a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),Cf(t,i+1,a.copy(r.to,a.to)));else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),Cf(t,i,r.copy(a.from,r.to)));break}}}return t}function Cf(e,t,n){for(;t<e.length&&xf(n,e[t])>0;)t++;e.splice(t,0,n)}function wf(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=K&&t.push(r)}),e.cursorWrapper&&t.push(G.create(e.state.doc,[e.cursorWrapper.deco])),mf.from(t)}function Tf(e,t,n,r){let{node:i,fromOffset:a,toOffset:o,from:s,to:c}=e.docView.parseRange(t,n),l=e.domSel.range,u,d=l.anchorNode;if(d&&Hc(e.dom,d)&&(u=[{node:d,offset:l.anchorOffset}],qc(l)||u.push({node:l.focusNode,offset:l.focusOffset})),V&&e.input.lastKeyCode===8)for(let e=o;e>a;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||Qi.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Ef(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Ef=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(H&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||H&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},Df=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Of(e,t,n,r,i,a){let o=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Qu(e,e.domSel.range,t);if(n&&!e.state.selection.eq(n)&&e.domSel.active){if(V&&sl&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&Cd(e,`Enter`))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),o&&r.setMeta(`composition`,o),e.dispatch(r)}return}let s=e.state.doc.resolve(t),c=s.sharedDepth(n);t=s.before(c+1),n=e.state.doc.resolve(n).after(c+1);let l=e.state.selection,u=Tf(e,t,n,a),d=e.state.doc,f=d.slice(u.from,u.to),p,m;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(p=e.state.selection.to,m=`end`):(p=e.state.selection.from,m=`start`),e.input.lastKeyCode=null;let h=Pf(f.content,u.doc.content,u.from,p,m);if(h&&e.input.domChangeCount++,(il&&e.input.lastIOSEnter>Date.now()-225||sl)&&a.some(e=>z(e)&&!Df.test(e.nodeName))&&(!h||h.endA>=h.endB)&&Cd(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!h){if(i&&l instanceof P&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(u.sel){let t=kf(e,e.state.doc,u.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);o&&n.setMeta(`composition`,o),e.dispatch(n)}}return}}e.state.selection.from<e.state.selection.to&&h.start==h.endB&&e.state.selection instanceof P&&(h.start>e.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=u.from?h.start=e.state.selection.from:h.endA<e.state.selection.to&&h.endA>=e.state.selection.to-2&&e.state.selection.to<=u.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to));let g=u.doc.resolveNoCache(h.start-u.from),_=u.doc.resolveNoCache(h.endB-u.from),v=d.resolve(h.start),y=g.sameParent(_)&&g.parent.inlineContent&&v.end()>=h.endA;if((il&&e.input.lastIOSEnter>Date.now()-225&&(!y||a.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!y&&Mf(u.doc,g.pos,_.pos))&&Cd(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&(y?h.endA>h.start&&h.endB==h.start:jf(d,h.start,h.endA,g,_))&&Cd(e,`Backspace`)){sl&&V&&e.domSel.suppressChanges();return}V&&h.endB==h.start&&(e.input.lastChromeDelete=Date.now()),sl&&!y&&g.start()!=_.start()&&_.parentOffset==0&&g.depth==_.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,_=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>Cd(e,`Enter`),20));let b=h.start,x=h.endA,ee=t=>{let n=t||e.state.tr.replace(b,x,u.doc.slice(h.start-u.from,h.endB-u.from));if(u.sel){let t=kf(e,n.doc,u.sel);t&&!(V&&e.composing&&t.empty&&(h.start!=h.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==b||t.head==n.mapping.map(x)-1))&&n.setSelection(t)}return o&&n.setMeta(`composition`,o),n.scrollIntoView()},te;if(y){if(g.pos==_.pos){let t=ee(e.state.tr.delete(b,x)),n=d.resolve(h.start).marksAcross(d.resolve(h.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(h.endA==h.endB&&(te=Af(g.parent.content.cut(g.parentOffset,_.parentOffset),v.parent.content.cut(v.parentOffset,h.endA-v.start())))){let t=ee(e.state.tr);te.type==`add`?t.addMark(b,x,te.mark):t.removeMark(b,x,te.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==_.index()-+!_.textOffset){let t=g.parent.textBetween(g.parentOffset,_.parentOffset),n=()=>ee(e.state.tr.insertText(t,b,x));e.someProp(`handleTextInput`,r=>r(e,b,x,t,n))||e.dispatch(n())}else e.dispatch(ee())}else e.dispatch(ee())}function kf(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:dd(e,t.resolve(n.anchor),t.resolve(n.head))}function Af(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(D.from(l).eq(e))return{mark:s,type:o}}function jf(e,t,n,r,i){if(n-t<=i.pos-r.pos||Nf(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.inlineContent){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Nf(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Nf(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Mf(e,t,n){let r=0,i=0;return e.nodesBetween(t,n,(e,a)=>{e.isTextblock&&a>=t&&a<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-a),Math.min(e.nodeSize,n-a))):e.isLeaf)&&i++}),i==0&&r==1}function Nf(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Pf(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c<a&&o<s){let e=r<=a&&r>=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l<a){let e=r<=a&&r>=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var Ff={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},If=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);H&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,Ff),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Fc(n))t.add(n);for(let r=e.anchorNode;r;r=Fc(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:B(n)?n.parentNode:n}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]),e&&t.domSel.read();let r=!t.domSel.suppress&&!t.domSel.synced&&!!fd(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,a=-1,o=!1,s=[];if(t.editable)for(let e=0;e<n.length;e++){let t=this.registerMutation(n[e],s);t&&(i=i<0?t.from:Math.min(t.from,i),a=a<0?t.to:Math.max(t.to,a),t.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||V&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&n.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&z(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(tl&&s.length){let e=s.filter(e=>e.nodeName==`BR`);if(e.length==2){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=t.domSel.range;for(let r of e){let e=r.parentNode;e&&e.nodeName==`LI`&&(!n||Bf(t,n)!=e)&&r.remove()}}}let c=null;i<0&&r&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&t.input.lastTouch<Date.now()-300&&qc(t.domSel.range)&&(c=Qu(t,t.domSel.range))&&c.eq(N.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||r)&&(i>-1&&zf(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Vf(t,s)),Of(this.view,i,a,r,o,s),t.docView&&t.docView.damage?t.updateState(t.state):r&&t.domSel.sync())}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n;for(let t=e.target;t&&!(n=this.view.docView.getDesc(t));t=t.parentNode);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),B(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return n.markDamage(4),{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling,a=r&&r.parentNode==e.target?L(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?L(i):e.target.childNodes.length,c=n.localPosFromDOM(e.target,s,1);return n.markDamage(n.contentDOM?.contains(e.target)?2:4),{from:o,to:c}}return e.type==`attributes`?(n.markDamage(4),{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}):(this.lastChangedTextNode=e.target,n.markDamage(n instanceof Zl&&e.target==n.nodeDOM?8:4),{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Lf=new WeakMap,Rf=!1;function zf(e){if(!Lf.has(e)&&(Lf.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=tl,Rf)return;console.warn(`ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.`),Rf=!0}}function Bf(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Vf(e,t){let{focusNode:n,focusOffset:r}=e.domSel.range;for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||!z(e)||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}var Hf=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new hd,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Yf),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Gf(this),Wf(this),this.nodeViews=qf(this),this.docView=Xl(this.state.doc,Uf(this),wf(this),this.dom,this),this.domObserver=new If(this),this.domSel=new Yu(this),this.domObserver.start(),this.domSel.read(),gd(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&yd(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Yf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Kd(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=qf(this);Jf(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&yd(this),this.editable=Gf(this),Wf(this);let o=wf(this),s=Uf(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&hl(this);i&&this.domObserver.stopped(()=>{let t=l&&V&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Kf(n.selection,e.selection);if(l){let n=V?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=qd(this)),r||!this.docView.update(e.doc,s,o,this,-1)){let t=this.docView.outerDeco;this.docView.destroy(),this.docView=Xl(e.doc,s,o,this.dom,this,t)}!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}this.domSel.sync(t)}),this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&_l(u)}scrollToSelection(){let e=this.domSel.range.focusNode;if(e&&this.domSel.active&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof F){let t=this.docView.domAfterPos(this.state.selection.from);z(t)&&ml(this,t.getBoundingClientRect(),e)}else ml(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new tf(e.slice,e.move,r<0?void 0:F.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&bl(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return t||document}updateRoot(){this._root=null}posAtCoords(e){return Al(this,e)}coordsAtPos(e,t=1){return Pl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Wl(this,t||this.state,e)}pasteHTML(e,t){return $d(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return $d(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Mu(this,e)}destroy(){this.docView&&(vd(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wf(this),this,-1),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Rc())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Sd(this,e)}domSelection(){return this.root.getSelection()}};Hf.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Uf(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[df.node(0,e.state.doc.content.size,t)]}function Wf(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:df.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Gf(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Kf(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function qf(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Jf(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Yf(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}function Xf(e){let t=e??globalThis.document;if(!t)throw Error(`[wysio] A DOM document is required.`);return t}function Zf(e,t,n){let r=new((Xf(n).defaultView?.DOMParser)??globalThis.DOMParser)().parseFromString(t,`text/html`).body;return Qi.fromSchema(e).parse(r)}function Qf(e,t,n){let r=Xf(n),i=r.createElement(`div`);return i.appendChild(fa.fromSchema(e).serializeFragment(t.content,{document:r})),i.innerHTML}function $f(e,t,n){let r=Xf(n),i=r.createElement(`div`);return i.appendChild(fa.fromSchema(e).serializeFragment(t.content,{document:r})),Qi.fromSchema(e).parse(i)}function ep(e,t,n){let r=Si.fromJSON(e,t);return r.check(),$f(e,r,n)}function tp(e,t,n){return t==null||t===``?e.topNodeType.createAndFill():typeof t==`string`?Zf(e,t,n):ep(e,t,n)}function np(e){let t=e.firstChild;return e.childCount===0||e.childCount===1&&!!t?.isTextblock&&t.content.size===0}var rp=class{listeners=new Map;on(e,t){let n=this.listeners.get(e);return n||this.listeners.set(e,n=new Set),n.add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...t){for(let n of[...this.listeners.get(e)??[]])n(...t)}has(e){return(this.listeners.get(e)?.size??0)>0}clear(){this.listeners.clear()}},ip={toolbar:`Opmaak`,"toolbar.more":`Meer`,editor:`Teksteditor`,bold:`Vet`,italic:`Cursief`,underline:`Onderstrepen`,strike:`Doorhalen`,code:`Code`,heading:`Tekststijl`,paragraph:`Alinea`,heading1:`Kop 1`,heading2:`Kop 2`,heading3:`Kop 3`,heading4:`Kop 4`,bulletList:`Opsommingslijst`,orderedList:`Genummerde lijst`,blockquote:`Citaat`,horizontalRule:`Horizontale lijn`,link:`Link`,unlink:`Link verwijderen`,image:`Afbeelding`,"image.dialog":`Afbeelding`,"image.url":`Afbeeldings-URL`,"image.alt":`Alternatieve tekst`,"image.altHint":`Beschrijf de afbeelding voor wie ze niet kan zien. Laat leeg als ze enkel decoratief is.`,"image.upload":`Uploaden vanaf computer…`,"image.uploading":`Bezig met uploaden van {name}`,"image.invalid":`Voer een geldige afbeeldings-URL in (http of https).`,"image.align":`Uitlijning`,"image.alignNone":`Geen`,"image.alignLeft":`Links`,"image.alignCenter":`Gecentreerd`,"image.alignRight":`Rechts`,"image.remove":`Afbeelding verwijderen`,table:`Tabel`,"table.insert":`Tabel invoegen`,"table.size":`Tabelgrootte`,"table.cells":`{rows} × {cols}`,"table.header":`Kopregel`,"table.addRowBefore":`Rij erboven invoegen`,"table.addRowAfter":`Rij eronder invoegen`,"table.addColumnBefore":`Kolom links invoegen`,"table.addColumnAfter":`Kolom rechts invoegen`,"table.deleteRow":`Rij verwijderen`,"table.deleteColumn":`Kolom verwijderen`,"table.toggleHeaderRow":`Kopregel aan/uit`,"table.delete":`Tabel verwijderen`,align:`Uitlijning`,alignLeft:`Links uitlijnen`,alignCenter:`Centreren`,alignRight:`Rechts uitlijnen`,alignJustify:`Uitvullen`,textColor:`Tekstkleur`,highlight:`Markeren`,"color.remove":`Kleur verwijderen`,"highlight.remove":`Markering verwijderen`,"color.gray":`Grijs`,"color.red":`Rood`,"color.orange":`Oranje`,"color.yellow":`Geel`,"color.green":`Groen`,"color.teal":`Blauwgroen`,"color.blue":`Blauw`,"color.violet":`Violet`,"color.pink":`Roze`,clearFormatting:`Opmaak wissen`,source:`Broncode`,"source.label":`HTML-broncode`,undo:`Ongedaan maken`,redo:`Opnieuw`,"link.dialog":`Link bewerken`,"link.url":`URL`,"link.newTab":`Openen in nieuw tabblad`,"dialog.apply":`Toepassen`,"dialog.cancel":`Annuleren`,"link.remove":`Verwijderen`,"link.invalid":`Voer een geldige URL in (http, https, mailto of tel).`},ap={toolbar:`Formatting`,"toolbar.more":`More`,editor:`Rich text editor`,bold:`Bold`,italic:`Italic`,underline:`Underline`,strike:`Strikethrough`,code:`Inline code`,heading:`Text style`,paragraph:`Paragraph`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,heading4:`Heading 4`,bulletList:`Bulleted list`,orderedList:`Numbered list`,blockquote:`Quote`,horizontalRule:`Horizontal line`,link:`Link`,unlink:`Remove link`,image:`Image`,"image.dialog":`Image`,"image.url":`Image URL`,"image.alt":`Alternative text`,"image.altHint":`Describe the image for people who cannot see it. Leave empty if it is decorative.`,"image.upload":`Upload from computer…`,"image.uploading":`Uploading {name}`,"image.invalid":`Enter a valid image URL (http or https).`,"image.align":`Alignment`,"image.alignNone":`None`,"image.alignLeft":`Left`,"image.alignCenter":`Center`,"image.alignRight":`Right`,"image.remove":`Remove image`,table:`Table`,"table.insert":`Insert table`,"table.size":`Table size`,"table.cells":`{rows} × {cols}`,"table.header":`Header row`,"table.addRowBefore":`Insert row above`,"table.addRowAfter":`Insert row below`,"table.addColumnBefore":`Insert column left`,"table.addColumnAfter":`Insert column right`,"table.deleteRow":`Delete row`,"table.deleteColumn":`Delete column`,"table.toggleHeaderRow":`Toggle header row`,"table.delete":`Delete table`,align:`Alignment`,alignLeft:`Align left`,alignCenter:`Align center`,alignRight:`Align right`,alignJustify:`Justify`,textColor:`Text color`,highlight:`Highlight`,"color.remove":`Remove color`,"highlight.remove":`Remove highlight`,"color.gray":`Gray`,"color.red":`Red`,"color.orange":`Orange`,"color.yellow":`Yellow`,"color.green":`Green`,"color.teal":`Teal`,"color.blue":`Blue`,"color.violet":`Violet`,"color.pink":`Pink`,clearFormatting:`Clear formatting`,source:`Source code`,"source.label":`HTML source`,undo:`Undo`,redo:`Redo`,"link.dialog":`Edit link`,"link.url":`URL`,"link.newTab":`Open in new tab`,"dialog.apply":`Apply`,"dialog.cancel":`Cancel`,"link.remove":`Remove`,"link.invalid":`Enter a valid URL (http, https, mailto or tel).`},op=new Map([[`en`,ap],[`nl`,ip]]);function sp(e){let t=e.toLowerCase().replace(`_`,`-`);for(let e of[t,t.split(`-`)[0]]){let t=op.get(e);if(t)return{code:e,messages:t}}return null}function cp(e,t){return t?e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):e}var q=e=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${e}</svg>`,J={bold:`<span class="wysio-glyph" style="font-weight:700">B</span>`,italic:`<span class="wysio-glyph" style="font-style:italic;font-family:Georgia,serif">I</span>`,underline:`<span class="wysio-glyph" style="text-decoration:underline">U</span>`,strike:`<span class="wysio-glyph" style="text-decoration:line-through">S</span>`,code:q(`<path d="m8 7-5 5 5 5M16 7l5 5-5 5"/>`),bulletList:q(`<path d="M9 6h11M9 12h11M9 18h11"/><circle cx="4.5" cy="6" r="1" fill="currentColor"/><circle cx="4.5" cy="12" r="1" fill="currentColor"/><circle cx="4.5" cy="18" r="1" fill="currentColor"/>`),orderedList:q(`<path d="M10 6h10M10 12h10M10 18h10"/><path d="M4 4h1.5v5M4 9h3" stroke-width="1.5"/><path d="M4 14.5c.4-.8 2.8-.9 2.8.6 0 1.2-2.8 2.2-2.8 3.4h3" stroke-width="1.5"/>`),blockquote:q(`<path d="M4 7h5v5c0 3-2 4.5-4 5M14 7h5v5c0 3-2 4.5-4 5"/>`),horizontalRule:q(`<path d="M3 12h18"/>`),link:q(`<path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1"/><path d="M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1"/>`),unlink:q(`<path d="M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1"/><path d="M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1"/><path d="M3 3l18 18"/>`),image:q(`<rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="m21 16-5-5-9 9"/>`),table:q(`<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M3 15h18M9 4v16M15 4v16"/>`),tableRowBefore:q(`<path d="M3 14h18v6H3zM3 17h18M12 3v7M8.5 6.5h7"/>`),tableRowAfter:q(`<path d="M3 4h18v6H3zM3 7h18M12 14v7M8.5 17.5h7"/>`),tableColumnBefore:q(`<path d="M14 3h6v18h-6zM17 3v18M3 12h7M6.5 8.5v7"/>`),tableColumnAfter:q(`<path d="M4 3h6v18H4zM7 3v18M14 12h7M17.5 8.5v7"/>`),tableDeleteRow:q(`<path d="M3 9h18v6H3zM9 9v6M15 9v6M8 4l8 0M8 20h8"/>`),tableDeleteColumn:q(`<path d="M9 3h6v18H9zM9 9h6M9 15h6M4 8v8M20 8v8"/>`),tableHeaderRow:q(`<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 10h18M9 10v10M15 10v10"/><path d="M3 6h18" stroke-width="4"/>`),tableDelete:q(`<rect x="3" y="4" width="18" height="16" rx="2"/><path d="m9 9 6 6M15 9l-6 6"/>`),alignLeft:q(`<path d="M4 6h16M4 10h10M4 14h16M4 18h10"/>`),alignCenter:q(`<path d="M4 6h16M7 10h10M4 14h16M7 18h10"/>`),alignRight:q(`<path d="M4 6h16M10 10h10M4 14h16M10 18h10"/>`),alignJustify:q(`<path d="M4 6h16M4 10h16M4 14h16M4 18h16"/>`),textColor:q(`<path d="m6 16 6-12 6 12M8.5 11h7"/><path d="M4 20h16" stroke-width="3" stroke="var(--wysio-icon-accent, currentColor)"/>`),highlight:q(`<path d="m9 11-5 5v3h3l5-5M9 11l4-4 4 4-4 4zM13 7l2-2a1.4 1.4 0 0 1 2 0l2 2a1.4 1.4 0 0 1 0 2l-2 2"/><path d="M14 20h6" stroke-width="3" stroke="var(--wysio-icon-accent, currentColor)"/>`),clearFormatting:q(`<path d="M6 5h11M11.5 5 8 19M4 4l16 16"/><path d="M12 19h3"/>`),source:q(`<rect x="3" y="4" width="18" height="16" rx="2"/><path d="m10 9-3 3 3 3M14 9l3 3-3 3"/>`),undo:q(`<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>`),redo:q(`<path d="m15 14 5-5-5-5"/><path d="M20 9H9.5a5.5 5.5 0 0 0 0 11H13"/>`)},lp=0,up=class{editor;dom;key=``;uid=`wysio-pop-${++lp}`;constructor(e,t){this.editor=e,this.dom=e.dom.ownerDocument.createElement(`div`),this.dom.className=`wysio-popover`,this.dom.setAttribute(`role`,`dialog`),e.locale&&(this.dom.lang=e.locale),this.dom.setAttribute(`aria-label`,t),this.dom.hidden=!0,this.dom.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t&&!this.dom.contains(t)&&this.close(!1)}),this.dom.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.close())}),e.dom.appendChild(this.dom)}get isOpen(){return!this.dom.hidden}show(e,t){this.dom.hidden=!1,this.notify(!0),this.position(e),this.editor.dom.ownerDocument.addEventListener(`mousedown`,this.onOutside,!0),t.focus()}close(e=!0){this.isOpen&&(this.dom.hidden=!0,this.editor.dom.ownerDocument.removeEventListener(`mousedown`,this.onOutside,!0),this.notify(!1),e&&this.editor.focus())}notify(e){this.editor.dom.dispatchEvent(new CustomEvent(`wysio:popover`,{detail:{key:this.key,open:e}}))}destroy(){this.close(!1),this.dom.remove()}position(e){let{view:t}=this.editor;try{let n=t.coordsAtPos(Math.min(e,t.state.doc.content.size)),r=this.editor.dom.getBoundingClientRect(),i=Math.max(0,Math.min(n.left-r.left,r.width-this.dom.offsetWidth));this.dom.style.left=`${i}px`,this.dom.style.top=`${n.bottom-r.top+6}px`}catch{}}onOutside=e=>{this.dom.contains(e.target)||this.close(!1)}},dp=new WeakMap;function fp(e,t,n){let r=dp.get(e);if(!r){let t=new Map;dp.set(e,r=t),e.on(`destroy`,()=>{for(let e of t.values())e.destroy();dp.delete(e)})}let i=r.get(t);return i||(i=n(),i.key=t,r.set(t,i)),i}function pp(e,t,n){let r=e.createElement(`form`);return r.noValidate=!0,r.innerHTML=n.replaceAll(`{id}`,t),r}function Y(e,t){let n=e.querySelector(t);if(!n)throw Error(`[wysio] Missing element ${t}`);return n}var mp=class extends up{buttons=[];constructor(e,t,n){super(e,t);let r=e.dom.ownerDocument,i=r.createElement(`div`);i.className=`wysio-menu`;for(let e of n){let t=r.createElement(`button`);t.type=`button`,t.className=`wysio-menu-item`,t.dataset.action=e.id,t.innerHTML=e.icon??``,t.append(r.createTextNode(e.label)),e.isActive&&t.setAttribute(`aria-pressed`,`false`),t.addEventListener(`click`,()=>{this.close(!1),e.run(this.editor)}),i.appendChild(t),this.buttons.push({button:t,item:e})}i.addEventListener(`keydown`,this.onKey),this.dom.appendChild(i)}open(){let{state:e}=this.editor.view;for(let{button:t,item:n}of this.buttons)t.disabled=n.isEnabled?!n.isEnabled(e):!1,n.isActive&&t.setAttribute(`aria-pressed`,String(n.isActive(e)));let t=this.buttons.filter(e=>!e.button.disabled),n=t.find(e=>e.button.getAttribute(`aria-pressed`)===`true`)??t[0];this.show(e.selection.from,n?.button??this.dom)}onKey=e=>{let t=this.buttons.map(e=>e.button).filter(e=>!e.disabled),n=t.indexOf(e.target),r=null;e.key===`ArrowDown`?r=(n+1)%t.length:e.key===`ArrowUp`?r=(n-1+t.length)%t.length:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r]?.focus())}},hp=[`left`,`center`,`right`,`justify`],gp=[`paragraph`,`heading`],_p=e=>e===`center`||e===`right`||e===`justify`?e:null;function vp(e){for(let t of hp)if(e.classList.contains(`wysio-align-${t}`))return t;let t=(e.style.textAlign||e.getAttribute(`align`)||``).toLowerCase();return hp.includes(t)?t:null}function yp(e,t){if(!Array.isArray(e))return e;let[n,r,...i]=e;if(typeof r==`object`&&r&&!Array.isArray(r)&&!(typeof Node<`u`&&r instanceof Node)){let e={...r};return e.class=e.class?`${e.class} ${t}`:t,[n,e,...i]}return[n,{class:t},...r===void 0?[]:[r],...i]}function bp(e){let t=e.toDOM;return{...e,attrs:{...e.attrs,align:{default:null,validate:`string|null`}},parseDOM:e.parseDOM?.map(e=>{if(!(`tag`in e))return e;let t=e;return{...t,attrs:void 0,getAttrs:e=>{let n=t.getAttrs?t.getAttrs(e):null;return n!==!1&&{...t.attrs,...n,align:_p(vp(e))}}}}),toDOM:t?e=>{let n=t(e),r=_p(e.attrs.align);return r?yp(n,`wysio-align-${r}`):n}:void 0}}function xp(e){let t=[];for(let{$from:n,$to:r}of e.selection.ranges)e.doc.nodesBetween(n.pos,r.pos,(e,n)=>(e.isTextblock&&`align`in e.type.spec.attrs&&t.push({node:e,pos:n}),!e.isTextblock));return t}function Sp(e){return(t,n)=>{let r=xp(t);if(!r.length)return!1;if(n){let i=t.tr,a=_p(e);for(let{node:e,pos:t}of r)i.setNodeMarkup(t,void 0,{...e.attrs,align:a});n(i.scrollIntoView())}return!0}}function Cp(e,t){let n=xp(e);return n.length>0&&n.every(({node:e})=>(_p(e.attrs.align)??`left`)===t)}var wp={left:`Mod-Shift-l`,center:`Mod-Shift-e`,right:`Mod-Shift-r`,justify:`Mod-Shift-j`},Tp=e=>`align${e[0].toUpperCase()}${e.slice(1)}`;function Ep(e){e.isEditable&&fp(e,`alignment`,()=>new mp(e,e.t(`align`),hp.map(t=>({id:Tp(t),label:e.t(Tp(t)),icon:J[Tp(t)],run:e=>e.exec(Sp(t)),isActive:e=>Cp(e,t),isEnabled:e=>Sp(t)(e)})))).open()}var Dp=A({name:`alignment`,schema:{extendNodes:Object.fromEntries(gp.map(e=>[e,bp]))},keymap:()=>Object.fromEntries(hp.map(e=>[wp[e],Sp(e)])),toolbarItems:({editor:e})=>{let t={align:{label:e.t(`align`),icon:J.alignLeft,run:Ep,popover:`alignment`,dropdown:!0,render:(e,t)=>{let n=hp.find(t=>Cp(e,t))??`left`;t.setIcon(J[Tp(n)])},isActive:e=>hp.slice(1).some(t=>Cp(e,t)),isEnabled:e=>Sp(`left`)(e)}};for(let n of hp)t[Tp(n)]={label:e.t(Tp(n)),icon:J[Tp(n)],shortcut:wp[n],command:Sp(n),isActive:e=>Cp(e,n)};return t}});function Op(e={}){return new ks({view(t){return new kp(t,e)}})}var kp=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Vo(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},Ap=class e extends N{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):N.near(r)}content(){return k.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new jp(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Np(e)||!Pp(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){e:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!F.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};Ap.prototype.visible=!1,Ap.findFrom=Ap.findGapCursorFrom,N.jsonID(`gapcursor`,Ap);var jp=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ap.valid(t)?new Ap(t):N.near(t)}};function Mp(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Np(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Mp(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Pp(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Mp(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Fp(){return new ks({props:{decorations:Bp,createSelectionBetween(e,t,n){return t.pos==n.pos&&Ap.valid(n)?new Ap(n):null},handleClick:Rp,handleKeyDown:Ip,handleDOMEvents:{beforeinput:zp}}})}var Ip=Pc({ArrowLeft:Lp(`horiz`,-1),ArrowRight:Lp(`horiz`,1),ArrowUp:Lp(`vert`,-1),ArrowDown:Lp(`vert`,1)});function Lp(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof P){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=Ap.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new Ap(c))),!0):!1}}function Rp(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!Ap.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&F.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new Ap(r))),!0)}function zp(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof Ap))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let e=r.length-1;e>=0;e--)i=D.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new k(i,0,0));return a.setSelection(P.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Bp(e){if(!(e.selection instanceof Ap))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,G.create(e.doc,[df.widget(e.selection.head,t,{key:`gapcursor`})])}var Vp=A({name:`base`,schema:{nodes:{doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM:()=>[`p`,0]},text:{group:`inline`}}},prosemirrorPlugins:()=>[Fp(),Op({class:`wysio-dropcursor`})]});function Hp(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let s=r?n.tr:null;return Up(s,o,e,t)?(r&&r(s.scrollIntoView()),!0):!1}}function Up(e,t,n,r=null){let i=!1,a=t,o=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new bi(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new bi(t.$from,o.resolve(t.$to.end(t.depth)),t.depth)),i=!0}let s=wo(a,n,r,t);return s?(e&&Wp(e,t,s,i,n),!0):!1}function Wp(e,t,n,r,i){let a=D.empty;for(let e=n.length-1;e>=0;e--)a=D.from(n[e].type.create(n[e].attrs,a));e.step(new go(t.start-(r?2:0),t.end,t.start,t.end,new k(a,0,0),n.length,!0));let o=0;for(let e=0;e<n.length;e++)n[e].type==i&&(o=e+1);let s=n.length-o,c=t.start+n.length-(r?2:0),l=t.parent;for(let n=t.startIndex,r=t.endIndex,i=!0;n<r;n++,i=!1)!i&&s&&Po(e.doc,c,s)&&(e.split(c,s),c+=2*s),c+=l.child(n).nodeSize;return e}function Gp(e,t){return e instanceof Wi?t==e:e.indexOf(t)>-1}function Kp(e,t){return function(n,r){let{$from:i,$to:a,node:o}=n.selection;if(o&&o.isBlock||i.depth<2||!i.sameParent(a))return!1;let s=i.node(-1);if(!Gp(e,s.type))return!1;if(i.parent.content.size==0&&i.node(-1).childCount==i.indexAfter(-1)){if(i.depth==3||!Gp(e,i.node(-3).type)||i.index(-2)!=i.node(-2).childCount-1)return!1;if(r){let e=D.empty,t=i.index(-1)?1:i.index(-2)?2:3;for(let n=i.depth-t;n>=i.depth-3;n--)e=D.from(i.node(n).copy(e));let a=i.indexAfter(-1)<i.node(-2).childCount?1:i.indexAfter(-2)<i.node(-3).childCount?2:3;e=e.append(D.from(i.node(-3).type.createAndFill()));let o=i.before(i.depth-(t-1)),s=n.tr.replace(o,i.after(-a),new k(e,4-t,0)),c=-1;s.doc.nodesBetween(o,s.doc.content.size,(e,t)=>{if(c>-1)return!1;e.isTextblock&&e.content.size==0&&(c=t+1)}),c>-1&&s.setSelection(N.near(s.doc.resolve(c))),r(s.scrollIntoView())}return!0}let c=a.pos==i.end()?s.contentMatchAt(0).defaultType:null,l=n.tr.delete(i.pos,a.pos),u=c||t?[t?{type:s.type,attrs:t}:null,c?{type:c}:null]:void 0;return Po(l.doc,i.pos,2,u)?(r&&r(l.split(i.pos,2,u).scrollIntoView()),!0):!1}}function qp(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&Gp(e,t.firstChild.type));return a?n?Gp(e,r.node(a.depth-1).type)?Jp(t,n,a):Yp(t,n,a):!0:!1}}function Jp(e,t,n){let r=e.tr,i=n.end,a=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;i<a&&(r.step(new go(i-1,a,i,a,new k(D.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new bi(r.doc.resolve(n.$from.pos),r.doc.resolve(a),n.depth));let s=So(n);if(s==null)return!1;r.lift(n,s);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return Io(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),t(r.scrollIntoView()),!0}function Yp(e,t,n){let r=e.tr,i=n.parent;for(let e=n.end,t=n.endIndex-1,a=n.startIndex;t>a;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?D.empty:D.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new go(d-+!!s,f+ +!!c,d+1,f-1,new k((s?D.empty:D.from(i.copy(D.empty))).append(c?D.empty:D.from(i.copy(D.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function Xp(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&Gp(e,t.firstChild.type));if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(!Gp(e,c.type))return!1;if(n){let e=c.lastChild&&c.lastChild.type==s.type,r=D.from(e?c.lastChild.lastChild.type.create():null),i=new k(D.from(c.type.create(null,D.from(s.type.create(null,r)))),e?3:1,0),o=a.start,l=a.end;n(t.tr.step(new go(o-(e?3:1),l,o,l,i,1,!0)).scrollIntoView())}return!0}}function Zp(e,t){let{from:n,to:r,empty:i,$from:a}=e.selection;return i?!!t.isInSet(e.storedMarks??a.marks()):e.doc.rangeHasMark(n,r,t)}function Qp(e,t){let{$from:n}=e.selection;for(let e=n.depth;e>0;e--){let r=n.node(e);if(t.includes(r.type))return{node:r,depth:e,pos:n.before(e)}}return null}function $p(e,t,n){return(r,i)=>{let a=Qp(r,n);return a?a.node.type===e?qp(t)(r,i):(i&&i(r.tr.setNodeMarkup(a.pos,e).scrollIntoView()),!0):Hp(e)(r,i)}}function em(e){return(t,n)=>Qp(t,[e])?Us(t,n):rc(e)(t,n)}function tm(e,t){let n=e.parent,r=n.childAfter(e.parentOffset),i=r.node?t.isInSet(r.node.marks):void 0;if(!i&&(r=n.childBefore(e.parentOffset),i=r.node?t.isInSet(r.node.marks):void 0,!i||!r.node))return null;let a=e.start(),o=r.index,s=a+r.offset;for(;o>0&&i.isInSet(n.child(o-1).marks);)o--,s-=n.child(o).nodeSize;let c=r.index+1,l=a+r.offset+n.child(r.index).nodeSize;for(;c<n.childCount&&i.isInSet(n.child(c).marks);)l+=n.child(c).nodeSize,c++;return{from:s,to:l,mark:i}}var nm=A({name:`blockquote`,schema:{nodes:{blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM:()=>[`blockquote`,0]}}},keymap:({schema:e})=>({"Mod-Shift-b":em(e.nodes.blockquote)}),inputRules:({schema:e})=>[bc(/^\s*>\s$/,e.nodes.blockquote)],toolbarItems:({schema:e,editor:t})=>{let n=e.nodes.blockquote;return{blockquote:{label:t.t(`blockquote`),icon:J.blockquote,shortcut:`Mod-Shift-b`,command:em(n),isActive:e=>!!Qp(e,[n])}}}}),rm=A({name:`horizontalRule`,schema:{nodes:{horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM:()=>[`hr`]}}},inputRules:({schema:e})=>[new mc(/^(?:---|___|\*\*\*)$/,(t,n,r,i)=>{let a=t.doc.resolve(r),o=e.nodes.horizontal_rule.create();return!a.parent.isTextblock||a.parent.content.size!==i-r+1?null:t.tr.replaceRangeWith(a.before(),a.after(),o).scrollIntoView()})],toolbarItems:({schema:e,editor:t})=>{let n=e.nodes.horizontal_rule;return{horizontalRule:{label:t.t(`horizontalRule`),icon:J.horizontalRule,command:(e,t)=>!e.selection.$from.parent.canReplaceWith(0,0,n)&&!e.selection.$from.parent.isTextblock?!1:(t&&t(e.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0)}}}}),im=A({name:`hardBreak`,schema:{nodes:{hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM:()=>[`br`]}}},keymap:({schema:e})=>{let t=e.nodes.hard_break,n=cc(Ks,(e,n)=>(n&&n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0));return{"Shift-Enter":n,"Mod-Enter":n}}}),am=[`align`],om=new Set([`link`]),sm=(e,t)=>{let n=e.tr,r=!1,i=Object.values(e.schema.marks).filter(e=>!om.has(e.name)),a=e=>{let t=n.doc.nodeAt(e);if(!t)return;let i={};for(let e of am)e in t.type.spec.attrs&&t.attrs[e]!=null&&(i[e]=null);Object.keys(i).length&&(n.setNodeMarkup(e,void 0,{...t.attrs,...i}),r=!0)};for(let{$from:t,$to:o}of e.selection.ranges){let s=t.pos,c=o.pos;for(let t of i)s<c&&e.doc.rangeHasMark(s,c,t)&&(n.removeMark(s,c,t),r=!0);s===c?t.depth>0&&a(t.before()):e.doc.nodesBetween(s,c,(e,t)=>(e.isTextblock&&a(t),!e.isTextblock))}if(e.selection.empty){let t=e.storedMarks??e.selection.$from.marks();t.some(e=>!om.has(e.type.name))&&(n.setStoredMarks(t.filter(e=>om.has(e.type.name))),r=!0)}return r?(t&&t(n.scrollIntoView()),!0):!1},cm=A({name:`clearFormatting`,keymap:()=>({"Mod-\\":sm}),toolbarItems:({editor:e})=>({clearFormatting:{label:e.t(`clearFormatting`),icon:J.clearFormatting,shortcut:`Mod-\\`,command:sm}})}),lm=[{name:`gray`,value:`#868e96`},{name:`red`,value:`#e03131`},{name:`orange`,value:`#e8590c`},{name:`green`,value:`#2f9e44`},{name:`teal`,value:`#0c8599`},{name:`blue`,value:`#1971c2`},{name:`violet`,value:`#6741d9`},{name:`pink`,value:`#c2255c`}],um=[{name:`yellow`,value:`#ffec99`},{name:`green`,value:`#b2f2bb`},{name:`blue`,value:`#a5d8ff`},{name:`pink`,value:`#fcc2d7`},{name:`orange`,value:`#ffd8a8`},{name:`violet`,value:`#d0bfff`},{name:`red`,value:`#ffc9c9`},{name:`gray`,value:`#e9ecef`}],dm=e=>e.toString(16).padStart(2,`0`);function fm(e){if(typeof e!=`string`)return null;let t=e.trim().toLowerCase(),n=/^#([0-9a-f])([0-9a-f])([0-9a-f])$/.exec(t);if(n)return`#${n[1]}${n[1]}${n[2]}${n[2]}${n[3]}${n[3]}`;if(/^#[0-9a-f]{6}$/.test(t))return t;if(n=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/.exec(t),n){let e=[n[1],n[2],n[3]].map(Number);if(e.every(e=>e<=255))return`#${e.map(dm).join(``)}`}return null}var pm=/^[a-z][a-z0-9-]*$/;function mm(e){let t=e.map(e=>{let t=fm(e.value);if(!t||!pm.test(e.name))throw Error(`[wysio] Invalid palette colour "${e.name}" (${e.value}).`);return{...e,value:t}}),n=new Map(t.map(e=>[e.name,e])),r=new Map(t.map(e=>[e.value,e.name]));return{colors:t,name:e=>typeof e==`string`&&n.has(e)?e:null,fromCSS:e=>r.get(fm(e)??``)??null,fromClass:(e,t)=>{for(let r of e.classList)if(r.startsWith(t)&&n.has(r.slice(t.length)))return r.slice(t.length);return null},value:e=>n.get(e)?.value??null}}function hm(e,t,n){let r=n?t.value(n):null;r?e.style.setProperty(`--wysio-icon-accent`,r):e.style.removeProperty(`--wysio-icon-accent`)}function gm(e,t){return(n,r)=>{if(!sc(e)(n))return!1;if(r){let i=e.create({color:t}),a=n.tr;if(n.selection.empty)a.addStoredMark(i);else for(let{$from:e,$to:t}of n.selection.ranges)a.addMark(e.pos,t.pos,i);r(a.scrollIntoView())}return!0}}function _m(e){return(t,n)=>{if(n){let r=t.tr;if(t.selection.empty)r.removeStoredMark(e);else for(let{$from:n,$to:i}of t.selection.ranges)r.removeMark(n.pos,i.pos,e);n(r.scrollIntoView())}return!0}}function vm(e,t){let{empty:n,$from:r,from:i,to:a}=e.selection;if(n)return t.isInSet(e.storedMarks??r.marks())?.attrs.color??null;let o,s=!1;return e.doc.nodesBetween(i,a,e=>{if(!e.isText)return;let n=t.isInSet(e.marks)?.attrs.color??null;o===void 0?o=n:o!==n&&(s=!0)}),s?null:o??null}var ym=(e,t)=>{if(t.label)return t.label;let n=`color.${t.name}`,r=e.t(n);return r===n?t.name:r},bm=4,xm=class extends up{type;swatches=[];constructor(e,t,n,r,i,a){super(e,t),this.type=n;let o=e.dom.ownerDocument,s=o.createElement(`div`);s.className=`wysio-palette`,s.setAttribute(`role`,`group`),s.setAttribute(`aria-label`,t);for(let t of r.colors){let n=o.createElement(`button`);n.type=`button`,n.className=`wysio-swatch wysio-swatch-${a}`,n.style.setProperty(`--wysio-swatch`,t.value),n.setAttribute(`aria-label`,ym(e,t)),n.title=ym(e,t),n.setAttribute(`aria-pressed`,`false`),n.tabIndex=-1,a===`text`&&(n.textContent=`A`),n.addEventListener(`click`,()=>this.apply(t.name)),s.appendChild(n),this.swatches.push({button:n,value:t.name})}s.addEventListener(`keydown`,this.onKey);let c=o.createElement(`button`);c.type=`button`,c.className=`wysio-button wysio-palette-remove`,c.dataset.action=`remove`,c.textContent=i,c.addEventListener(`click`,()=>{this.close(!1),this.editor.exec(_m(this.type))}),this.dom.append(s,c)}open(){let{state:e}=this.editor.view,t=vm(e,this.type),n=this.swatches[0];for(let e of this.swatches){let r=e.value===t;e.button.setAttribute(`aria-pressed`,String(r)),r&&(n=e)}for(let e of this.swatches)e.button.tabIndex=e===n?0:-1;this.show(e.selection.from,n?.button??this.dom)}apply(e){this.close(!1),this.editor.exec(gm(this.type,e))}onKey=e=>{let t=this.swatches.map(e=>e.button),n=t.indexOf(e.target);if(n===-1)return;let r={ArrowRight:1,ArrowLeft:-1,ArrowDown:bm,ArrowUp:-4},i=null;e.key in r?i=Math.min(t.length-1,Math.max(0,n+r[e.key])):e.key===`Home`?i=0:e.key===`End`&&(i=t.length-1),i!==null&&(e.preventDefault(),t.forEach((e,t)=>e.tabIndex=t===i?0:-1),t[i]?.focus())}};function Sm(e={}){let t=mm(e.colors??lm);return A({name:`textColor`,schema:{marks:{text_color:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`span`,getAttrs:e=>{let n=t.fromClass(e,`wysio-color-`);return n?{color:n}:!1}},{style:`color`,getAttrs:e=>{let n=t.fromCSS(e);return n?{color:n}:!1}}],toDOM:e=>{let n=t.name(e.attrs.color);return[`span`,n?{class:`wysio-color-${n}`}:{},0]}}}},toolbarItems:({schema:e,editor:n})=>{let r=e.marks.text_color;return{textColor:{label:n.t(`textColor`),icon:J.textColor,popover:`textColor`,dropdown:!0,render:(e,n)=>hm(n.el,t,vm(e,r)),run:e=>fp(e,`textColor`,()=>new xm(e,e.t(`textColor`),r,t,e.t(`color.remove`),`text`)).open(),isActive:e=>vm(e,r)!==null,isEnabled:e=>sc(r)(e)}}}})}function Cm(e={}){let t=mm(e.colors??um),n=t.colors[0]?.name;return A({name:`highlight`,schema:{marks:{highlight:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`mark`,getAttrs:e=>{let r=e,i=t.fromClass(r,`wysio-highlight-`)??t.fromCSS(r.style.backgroundColor)??n;return i?{color:i}:!1}},{style:`background-color`,getAttrs:e=>{let n=t.fromCSS(e);return n?{color:n}:!1}}],toDOM:e=>{let n=t.name(e.attrs.color);return[`mark`,n?{class:`wysio-highlight-${n}`}:{},0]}}}},toolbarItems:({schema:e,editor:n})=>{let r=e.marks.highlight;return{highlight:{label:n.t(`highlight`),icon:J.highlight,popover:`highlight`,dropdown:!0,render:(e,n)=>hm(n.el,t,vm(e,r)),run:e=>fp(e,`highlight`,()=>new xm(e,e.t(`highlight`),r,t,e.t(`highlight.remove`),`background`)).open(),isActive:e=>vm(e,r)!==null,isEnabled:e=>sc(r)(e)}}}})}var wm=[1,2,3,4],Tm=e=>Math.min(4,Math.max(1,Math.trunc(Number(e))||1)),Em=A({name:`heading`,schema:{nodes:{heading:{attrs:{level:{default:1,validate:`number`}},content:`inline*`,group:`block`,defining:!0,parseDOM:[...wm.map(e=>({tag:`h${e}`,attrs:{level:e}})),{tag:`h5`,attrs:{level:4}},{tag:`h6`,attrs:{level:4}}],toDOM:e=>[`h${Tm(e.attrs.level)}`,0]}}},keymap:({schema:e})=>{let t={"Mod-Alt-0":ic(e.nodes.paragraph)};for(let n of wm)t[`Mod-Alt-${n}`]=ic(e.nodes.heading,{level:n});return t},inputRules:({schema:e})=>[xc(/^(#{1,4})\s$/,e.nodes.heading,e=>({level:e[1].length}))],toolbarItems:({schema:e,editor:t})=>{let{paragraph:n,heading:r}=e.nodes;return{heading:{type:`select`,label:t.t(`heading`),options:[{value:`p`,label:t.t(`paragraph`)},...wm.map(e=>({value:`h${e}`,label:t.t(`heading${e}`)}))],getValue:e=>{let{$from:t,$to:i}=e.selection,a=t.parent;return!t.sameParent(i)&&a!==i.parent?``:a.type===n?`p`:a.type===r?`h${a.attrs.level}`:``},isEnabled:e=>ic(n)(e)||ic(r,{level:1})(e),onSelect:(e,t)=>{let i=t===`p`?ic(n):ic(r,{level:Tm(t.slice(1))});e.exec(i)}}}}}),Dm=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Dm&&this.leafAppend(e)||this.length<Dm&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new km(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},X.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},X.from=function(e){return e instanceof X?e:e&&e.length?new Om(e):X.empty};var Om=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Dm)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Dm)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(X);X.empty=new Om([]);var km=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(X),Am=500,jm=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new Nm(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Nm(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new Nm(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>Fm&&(s=Mm(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ao;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Nm(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Nm(i,o,l))}else r.push(new Nm(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new Nm(a.maps[e]));let u=this.items.slice(0,i).append(l).append(r),d=new e(u,s);return d.emptyItemCount()>Am&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Nm(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(X.from(i.reverse()),a)}};jm.empty=new jm(X.empty,0);function Mm(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Nm=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Pm=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Fm=20;function Im(e,t,n,r){let i=n.getMeta(Gm),a;if(i)return i.historyState;n.getMeta(Km)&&(e=new Pm(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Gm))return o.getMeta(Gm).redo?new Pm(e.done.addTransform(n,void 0,r,Wm(t)),e.undone,Rm(n.mapping.maps),e.prevTime,e.prevComposition):new Pm(e.done,e.undone.addTransform(n,void 0,r,Wm(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Lm(n,e.prevRanges)),s=o?zm(e.prevRanges,n.mapping):Rm(n.mapping.maps);return new Pm(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Wm(t)),jm.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new Pm(e.done.rebased(n,a),e.undone.rebased(n,a),zm(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Pm(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),zm(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Lm(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function Rm(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function zm(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function Bm(e,t){for(let n=0;n<t.steps.length;n++){let r=t.mapping.maps[n],i=-1;if(r.forEach((e,t)=>i=t),i<0){let e=t.steps[n];(e instanceof co||e instanceof lo)&&(i=e.to)}if(i>-1)return N.near(e.doc.resolve(i))}return e.selection}function Vm(e,t,n){let r=Wm(t),i=Gm.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,Bm(t,a.transform).getBookmark(),i,r),c=new Pm(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(Gm,{redo:n,historyState:c})}var Hm=!1,Um=null;function Wm(e){let t=e.plugins;if(Um!=t){Hm=!1,Um=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Hm=!0;break}}return Hm}var Gm=new Ms(`history`),Km=new Ms(`closeHistory`);function qm(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new ks({key:Gm,state:{init(){return new Pm(jm.empty,jm.empty,null,0,-1)},apply(t,n,r){return Im(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?Ym:n==`historyRedo`?Xm:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Jm(e,t){return(n,r)=>{let i=Gm.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Vm(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Ym=Jm(!1,!0),Xm=Jm(!0,!0),Zm=()=>typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Qm=A({name:`history`,prosemirrorPlugins:()=>[qm()],keymap:()=>({"Mod-z":Ym,"Mod-Shift-z":Xm,...Zm()?{}:{"Mod-y":Xm}}),toolbarItems:({editor:e})=>({undo:{label:e.t(`undo`),icon:J.undo,shortcut:`Mod-z`,command:Ym},redo:{label:e.t(`redo`),icon:J.redo,shortcut:`Mod-Shift-z`,command:Xm}})}),$m=new Set([`http`,`https`,`mailto`,`tel`]),eh=/[\u0000- \u007f-\u009f]/g,th=/[\u0000-\u001f\u007f-\u009f]/g;function nh(e){if(typeof e!=`string`)return null;let t=e.trim().replace(th,``);if(!t)return null;let n=t.replace(eh,``),r=/^([a-z][a-z0-9+.-]*):/i.exec(n);if(r)return $m.has(r[1].toLowerCase())?t:null;let i=n.indexOf(`:`);if(i!==-1){let e=n.search(/[/?#]/);if(e===-1||i<e)return null}return t}function rh(e){let t=e.trim();if(!t)return null;let n=/^[a-z][a-z0-9+.-]*:/i.test(t),r=/^([/?#.]|\/\/)/.test(t);if(!n&&!r){if(/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(t))t=`mailto:${t}`;else if(/^[^\s/]+\.[^\s/]+/.test(t))t=`https://${t}`;else return null}let i=nh(t);if(!i)return null;if(/^https?:/i.test(i))try{if(!new URL(i).hostname)return null}catch{return null}return i}var ih=/^data:image\/(png|gif|jpe?g|webp|avif|bmp);base64,[a-z0-9+/=\s]+$/i;function ah(e,{allowDataUrls:t=!1}={}){if(typeof e!=`string`)return null;let n=e.trim();if(/^data:/i.test(n.replace(eh,``)))return t&&ih.test(n)?n:null;let r=nh(n);return!r||/^(mailto|tel):/i.test(r.replace(eh,``))?null:r}var oh=[`left`,`center`,`right`],sh=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/avif`],ch=e=>{let t=typeof e==`number`?String(e):typeof e==`string`?e.trim():``;if(!/^\d+$/.test(t))return null;let n=Number(t);return n>0&&n<=1e4?n:null},lh=e=>typeof e==`string`?e:null,uh=e=>oh.includes(e)?e:null;function dh(e){for(let t of oh)if(e.classList.contains(`wysio-image-${t}`))return t;let t=e.style.cssFloat||e.style.getPropertyValue(`float`);if(t===`left`||t===`right`)return t;if(e.style.display===`block`&&e.style.marginLeft===`auto`&&e.style.marginRight===`auto`)return`center`;let n=e.getAttribute(`align`)?.toLowerCase();return n===`left`||n===`right`?n:n===`middle`||n===`center`?`center`:null}var fh=new WeakMap,ph=e=>fh.get(e)??{allowDataUrls:!1,types:sh};function mh(e,t){let n=ah(e.src,t);return n?{src:n,alt:lh(e.alt),title:lh(e.title),width:ch(e.width),height:ch(e.height),align:uh(e.align)}:null}var hh=new Ms(`wysio-upload`),gh=new WeakMap;function _h(e,t){let n=hh.getState(e)?.find(void 0,void 0,e=>e.id===t);return n?.length?n[0].from:null}function vh(e,t){let n=e.dom.ownerDocument,r=n.createElement(`span`);r.className=`wysio-upload`,r.setAttribute(`role`,`status`),r.setAttribute(`aria-label`,e.t(`image.uploading`,{name:t.name})),r.style.setProperty(`--wysio-progress`,`0`);let i=``;if(typeof URL.createObjectURL==`function`){i=URL.createObjectURL(t);let e=n.createElement(`img`);e.src=i,e.alt=``,r.appendChild(e)}let a=n.createElement(`span`);return a.className=`wysio-upload-bar`,r.appendChild(a),{dom:r,revoke:()=>i&&URL.revokeObjectURL(i)}}function yh(e,t,n){let r=e.options.upload,i=e.schema.nodes.image;if(!r||!i||!e.isEditable)return[];let a=ph(e),o=gh.get(e);if(!o){let t=new Set;gh.set(e,o=t),e.on(`destroy`,()=>t.forEach(e=>e.abort()))}let s=o;return[...t].map(async t=>{if(!a.types.includes(t.type)){e.reportError(Error(`Unsupported image type: ${t.type||`unknown`}`),{source:`upload`,file:t});return}let{view:o}=e,c={},l=vh(e,t),u=o.state.tr;n===void 0&&!u.selection.empty&&u.deleteSelection();let d=n??u.selection.from;o.dispatch(u.setMeta(hh,{add:{id:c,pos:d,dom:l.dom}}).setMeta(`addToHistory`,!1));let f=new AbortController;s.add(f);try{let n=await r(t,{editor:e,signal:f.signal,onProgress:e=>l.dom.style.setProperty(`--wysio-progress`,String(Math.min(1,Math.max(0,e))))});if(f.signal.aborted)return;let{url:o,...s}=typeof n==`string`?{url:n}:n,u=mh({...s,src:o},a);if(!u)throw Error(`Upload handler returned an unsafe or empty URL`);let d=_h(e.view.state,c);if(d===null)return;e.view.dispatch(e.view.state.tr.insert(d,i.create(u)).setMeta(hh,{remove:{id:c}}))}catch(n){if(f.signal.aborted)return;_h(e.view.state,c)!==null&&e.view.dispatch(e.view.state.tr.setMeta(hh,{remove:{id:c}}).setMeta(`addToHistory`,!1)),e.reportError(n,{source:`upload`,file:t})}finally{s.delete(f),l.revoke()}})}function bh(e,t){let{types:n}=ph(e);return[...t??[]].filter(e=>n.includes(e.type))}function xh(e){return new ks({key:hh,state:{init:()=>G.empty,apply(e,t){let n=t.map(e.mapping,e.doc),r=e.getMeta(hh);if(r?.add&&(n=n.add(e.doc,[df.widget(r.add.pos,r.add.dom,{id:r.add.id})])),r?.remove){let{id:e}=r.remove;n=n.remove(n.find(void 0,void 0,t=>t.id===e))}return n}},props:{decorations:e=>hh.getState(e),handlePaste:(t,n)=>{if(!e.options.upload)return!1;let r=n.clipboardData;if(!r||r.getData(`text/html`)||r.getData(`text/plain`))return!1;let i=bh(e,r.files);return i.length?(n.preventDefault(),yh(e,i),!0):!1},handleDrop:(t,n,r,i)=>{if(i||!e.options.upload)return!1;let a=bh(e,n.dataTransfer?.files);return a.length?(n.preventDefault(),yh(e,a,t.posAtCoords({left:n.clientX,top:n.clientY})?.pos??t.state.selection.from),!0):!1}}})}function Sh(e,t){let{selection:n}=e;return n instanceof F&&n.node.type===t?n.node:null}function Ch(e,t){let n=e.schema.nodes.image,r=n&&mh(t,ph(e));return!n||!r?!1:e.exec((e,i)=>{let a=Sh(e,n);if(i){let o=Object.fromEntries(Object.entries(r).filter(([e])=>t[e]!==void 0));i((a?e.tr.setNodeMarkup(e.selection.from,void 0,{...a.attrs,...o}):e.tr.replaceSelectionWith(n.create(r))).scrollIntoView())}return!0})}function wh(e){let t=e.schema.nodes.image;return e.exec((e,n)=>!t||!Sh(e,t)?!1:(n&&n(e.tr.deleteSelection().scrollIntoView()),!0))}function Th(e){e.isEditable&&e.schema.nodes.image&&fp(e,`image`,()=>new Eh(e)).open()}var Eh=class extends up{src;alt;align;error;file;uploadRow;removeButton;pos=0;original=``;constructor(e){super(e,e.t(`image.dialog`));let t=pp(e.dom.ownerDocument,this.uid,`<label class="wysio-field" for="{id}-src" data-text="image.url"></label>
34
+ <input class="wysio-input" id="{id}-src" name="src" type="text" inputmode="url" autocomplete="off" spellcheck="false" aria-describedby="{id}-error">
35
+ <p class="wysio-error" id="{id}-error" role="alert" hidden></p>
36
+ <div class="wysio-upload-row">
37
+ <button type="button" class="wysio-button" data-action="upload" data-text="image.upload"></button>
38
+ <input type="file" name="file" hidden>
39
+ </div>
40
+ <label class="wysio-field" for="{id}-alt" data-text="image.alt"></label>
41
+ <input class="wysio-input" id="{id}-alt" name="alt" type="text" aria-describedby="{id}-alt-hint">
42
+ <p class="wysio-hint" id="{id}-alt-hint" data-text="image.altHint"></p>
43
+ <label class="wysio-field" for="{id}-align" data-text="image.align"></label>
44
+ <select class="wysio-input" id="{id}-align" name="align">
45
+ <option value="" data-text="image.alignNone"></option>
46
+ <option value="left" data-text="image.alignLeft"></option>
47
+ <option value="center" data-text="image.alignCenter"></option>
48
+ <option value="right" data-text="image.alignRight"></option>
49
+ </select>
50
+ <div class="wysio-actions">
51
+ <button type="submit" class="wysio-button wysio-button-primary" data-text="dialog.apply"></button>
52
+ <button type="button" class="wysio-button" data-action="remove" data-text="image.remove"></button>
53
+ <button type="button" class="wysio-button" data-action="cancel" data-text="dialog.cancel"></button>
54
+ </div>`);for(let n of t.querySelectorAll(`[data-text]`))n.textContent=e.t(n.dataset.text);this.src=Y(t,`input[name=src]`),this.alt=Y(t,`input[name=alt]`),this.align=Y(t,`select[name=align]`),this.error=Y(t,`.wysio-error`),this.file=Y(t,`input[name=file]`),this.file.accept=ph(e).types.join(`,`),this.file.multiple=!0,this.uploadRow=Y(t,`.wysio-upload-row`),this.removeButton=Y(t,`[data-action=remove]`),t.addEventListener(`submit`,e=>{e.preventDefault(),this.apply()}),Y(t,`[data-action=cancel]`).addEventListener(`click`,()=>this.close()),this.removeButton.addEventListener(`click`,()=>{this.close(!1),wh(this.editor)}),Y(t,`[data-action=upload]`).addEventListener(`click`,()=>this.file.click()),this.file.addEventListener(`change`,()=>{let e=[...this.file.files??[]];this.file.value=``,e.length&&(this.close(!1),this.editor.focus(),yh(this.editor,e,this.pos))}),this.src.addEventListener(`input`,()=>this.setError(!1)),this.dom.appendChild(t)}open(){let{state:e}=this.editor.view,t=Sh(e,this.editor.schema.nodes.image);this.pos=e.selection.from,this.original=t?.attrs.src??``,this.src.value=this.original,this.alt.value=t?.attrs.alt??``,this.align.value=t?.attrs.align??``,this.uploadRow.hidden=!this.editor.options.upload||!!t,this.removeButton.hidden=!t,this.setError(!1),this.show(this.pos,this.src),this.src.select()}apply(){let e=this.src.value.trim(),t=ph(this.editor),n=e===this.original||/^data:/i.test(e)||/^[^/:]+\.(png|jpe?g|gif|webp|avif|svg|bmp)$/i.test(e)?ah(e,t):ah(rh(e),t);n?(this.close(!1),Ch(this.editor,{src:n,alt:this.alt.value.trim(),align:uh(this.align.value)})):(this.setError(!0),this.src.focus())}setError(e){this.error.hidden=!e,this.error.textContent=e?this.editor.t(`image.invalid`):``,this.src.setAttribute(`aria-invalid`,String(e))}};function Dh(e={}){let t={allowDataUrls:e.allowDataUrls??!1,types:e.types??sh};return A({name:`image`,schema:{nodes:{image:{inline:!0,group:`inline`,draggable:!0,attrs:{src:{validate:`string`},alt:{default:null,validate:`string|null`},title:{default:null,validate:`string|null`},width:{default:null,validate:`number|null`},height:{default:null,validate:`number|null`},align:{default:null,validate:`string|null`}},parseDOM:[{tag:`img[src]`,getAttrs:e=>{let n=e;return mh({src:n.getAttribute(`src`)??``,alt:n.getAttribute(`alt`),title:n.getAttribute(`title`),width:ch(n.getAttribute(`width`)),height:ch(n.getAttribute(`height`)),align:dh(n)},t)??!1}}],toDOM:e=>{let n={},r=ah(e.attrs.src,t);r&&(n.src=r),typeof e.attrs.alt==`string`&&(n.alt=e.attrs.alt),typeof e.attrs.title==`string`&&(n.title=e.attrs.title);let i=ch(e.attrs.width),a=ch(e.attrs.height);i&&(n.width=String(i)),a&&(n.height=String(a));let o=uh(e.attrs.align);return o&&(n.class=`wysio-image-${o}`),[`img`,n]}}}},prosemirrorPlugins:({editor:e})=>(fh.set(e,t),[xh(e)]),toolbarItems:({schema:e,editor:t})=>{let n=e.nodes.image;return{image:{label:t.t(`image`),icon:J.image,run:Th,popover:`image`,isActive:e=>!!Sh(e,n),isEnabled:e=>!!Sh(e,n)||e.selection.$from.parent.inlineContent}}}})}function Oh(e,t){let{from:n,to:r,empty:i,$from:a}=e.selection;if(!i)return{from:n,to:r};let o=tm(a,t);return o?{from:o.from,to:o.to}:null}function kh(e){return(t,n)=>{let r=Oh(t,e);return!r||!t.doc.rangeHasMark(r.from,r.to,e)?!1:(n&&n(t.tr.removeMark(r.from,r.to,e).scrollIntoView()),!0)}}function Ah(e){let t=e.schema.marks.link;e.isEditable&&t&&fp(e,`link`,()=>new jh(e,t)).open()}var jh=class extends up{type;input;newTab;error;removeButton;range=null;constructor(e,t){super(e,e.t(`link.dialog`)),this.type=t;let n=pp(e.dom.ownerDocument,this.uid,`<label class="wysio-field" for="{id}-url"></label>
55
+ <input class="wysio-input" id="{id}-url" name="href" type="text" inputmode="url" autocomplete="off" spellcheck="false" aria-describedby="{id}-error">
56
+ <p class="wysio-error" id="{id}-error" role="alert" hidden></p>
57
+ <label class="wysio-check"><input type="checkbox" name="newTab"> <span></span></label>
58
+ <div class="wysio-actions">
59
+ <button type="submit" class="wysio-button wysio-button-primary" data-action="apply"></button>
60
+ <button type="button" class="wysio-button" data-action="remove"></button>
61
+ <button type="button" class="wysio-button" data-action="cancel"></button>
62
+ </div>`);Y(n,`.wysio-field`).textContent=e.t(`link.url`),Y(n,`.wysio-check span`).textContent=e.t(`link.newTab`),Y(n,`[data-action=apply]`).textContent=e.t(`dialog.apply`);let r=Y(n,`[data-action=cancel]`);r.textContent=e.t(`dialog.cancel`),this.removeButton=Y(n,`[data-action=remove]`),this.removeButton.textContent=e.t(`link.remove`),this.input=Y(n,`input[name=href]`),this.newTab=Y(n,`input[name=newTab]`),this.error=Y(n,`.wysio-error`),n.addEventListener(`submit`,e=>{e.preventDefault(),this.apply()}),this.removeButton.addEventListener(`click`,()=>this.remove()),r.addEventListener(`click`,()=>this.close()),this.input.addEventListener(`input`,()=>this.setError(!1)),this.dom.appendChild(n)}open(){let{state:e}=this.editor.view,{from:t,to:n}=e.selection,r=tm(e.selection.$from,this.type);this.range=r&&(e.selection.empty||r.from<=t&&r.to>=n)?{from:r.from,to:r.to}:{from:t,to:n};let i=r?.mark;this.input.value=i?.attrs.href??``,this.newTab.checked=i?.attrs.target===`_blank`,this.removeButton.hidden=!i&&!Zp(e,this.type),this.setError(!1),this.show(this.range.from,this.input),this.input.select()}apply(){let e=rh(this.input.value);if(!e){this.setError(!0),this.input.focus();return}let{view:t}=this.editor,n=this.clampRange(),r=this.type.create({href:e,target:this.newTab.checked?`_blank`:null}),i=t.state.tr;n.from===n.to?i.insertText(e,n.from).addMark(n.from,n.from+e.length,r):i.removeMark(n.from,n.to,this.type).addMark(n.from,n.to,r),t.dispatch(i.scrollIntoView()),this.close(!1),this.editor.focus()}remove(){let e=this.clampRange(),{view:t}=this.editor;t.dispatch(t.state.tr.removeMark(e.from,e.to,this.type)),this.close(!1),this.editor.focus()}clampRange(){let e=this.editor.view.state.doc.content.size,t=Math.min(this.range?.from??0,e);return{from:t,to:Math.min(this.range?.to??t,e)}}setError(e){this.error.hidden=!e,this.error.textContent=e?this.editor.t(`link.invalid`):``,this.input.setAttribute(`aria-invalid`,String(e))}},Mh=A({name:`link`,schema:{marks:{link:{attrs:{href:{validate:`string`},target:{default:null,validate:`string|null`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs:e=>{let t=e,n=nh(t.getAttribute(`href`));return n?{href:n,target:t.getAttribute(`target`)===`_blank`?`_blank`:null}:!1}}],toDOM:e=>{let t=nh(e.attrs.href),n={};return t&&(n.href=t),e.attrs.target===`_blank`&&(n.target=`_blank`,n.rel=`noopener noreferrer`),[`a`,n,0]}}}},keymap:({editor:e})=>({"Mod-k":(t,n)=>e.isEditable?(n&&Ah(e),!0):!1}),toolbarItems:({schema:e,editor:t})=>{let n=e.marks.link;return{link:{label:t.t(`link`),icon:J.link,shortcut:`Mod-k`,run:Ah,popover:`link`,isActive:e=>Zp(e,n),isEnabled:()=>!0},unlink:{label:t.t(`unlink`),icon:J.unlink,command:kh(n)}}}}),Nh=e=>{let t=Math.trunc(Number(e));return Number.isFinite(t)?t:1},Ph=A({name:`lists`,schema:{nodes:{bullet_list:{content:`list_item+`,group:`block`,parseDOM:[{tag:`ul`}],toDOM:()=>[`ul`,0]},ordered_list:{attrs:{start:{default:1,validate:`number`}},content:`list_item+`,group:`block`,parseDOM:[{tag:`ol`,getAttrs:e=>({start:Nh(e.getAttribute(`start`)??1)})}],toDOM:e=>{let t=Nh(e.attrs.start);return t===1?[`ol`,0]:[`ol`,{start:String(t)},0]}},list_item:{content:`paragraph block*`,defining:!0,parseDOM:[{tag:`li`}],toDOM:()=>[`li`,0]}}},keymap:({schema:e})=>{let t=e.nodes.list_item,n=[e.nodes.bullet_list,e.nodes.ordered_list];return{Enter:Kp(t),Tab:Xp(t),"Shift-Tab":qp(t),"Mod-Shift-8":$p(n[0],t,n),"Mod-Shift-7":$p(n[1],t,n)}},inputRules:({schema:e})=>[bc(/^\s*([-+*])\s$/,e.nodes.bullet_list),bc(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({start:Nh(e[1])}),(e,t)=>t.childCount+t.attrs.start===Nh(e[1]))],toolbarItems:({schema:e,editor:t})=>{let n=e.nodes.list_item,r=e.nodes.bullet_list,i=e.nodes.ordered_list,a=[r,i],o=e=>t=>Qp(t,a)?.node.type===e;return{bulletList:{label:t.t(`bulletList`),icon:J.bulletList,shortcut:`Mod-Shift-8`,command:$p(r,n,a),isActive:o(r)},orderedList:{label:t.t(`orderedList`),icon:J.orderedList,shortcut:`Mod-Shift-7`,command:$p(i,n,a),isActive:o(i)}}}});function Fh(e,t,n){return A({name:e,schema:{marks:{[e]:t}},keymap:({schema:t})=>({[n]:sc(t.marks[e])}),toolbarItems:({schema:t,editor:r})=>{let i=t.marks[e];return{[e]:{label:r.t(e),icon:J[e],shortcut:n,command:sc(i),isActive:e=>Zp(e,i)}}}})}var Ih=(e,t)=>e.includes(t)&&null,Lh=Fh(`bold`,{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===`bold`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>[`strong`,0]},`Mod-b`),Rh=Fh(`italic`,{parseDOM:[{tag:`em`},{tag:`i`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name===`italic`}],toDOM:()=>[`em`,0]},`Mod-i`),zh=Fh(`underline`,{parseDOM:[{tag:`u`},{style:`text-decoration`,getAttrs:e=>Ih(e,`underline`)},{style:`text-decoration-line`,getAttrs:e=>Ih(e,`underline`)}],toDOM:()=>[`u`,0]},`Mod-u`),Bh=Fh(`strike`,{parseDOM:[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,getAttrs:e=>Ih(e,`line-through`)},{style:`text-decoration-line`,getAttrs:e=>Ih(e,`line-through`)}],toDOM:()=>[`s`,0]},`Mod-Shift-x`),Vh=Fh(`code`,{code:!0,parseDOM:[{tag:`code`}],toDOM:()=>[`code`,0]},`Mod-e`),Hh=`script, style, meta, link, title, xml, template, noscript, object, embed, iframe, svg, canvas, video, audio, button, input, select, textarea`,Uh=new Set(`P H1 H2 H3 H4 H5 H6 UL OL LI TABLE DIV BLOCKQUOTE HR PRE FIGURE SECTION ARTICLE HEADER FOOTER`.split(` `)),Wh=new Set([`href`,`target`,`src`,`alt`,`title`,`width`,`height`,`colspan`,`rowspan`,`start`]),Gh=`h1, h2, h3, h4, h5, h6`;function Kh(e){e.replaceWith(...e.childNodes)}function qh(e,t){if(!t.length)return;let n=e.ownerDocument,r=n.createElement(t[0]),i=r;for(let e of t.slice(1))i=i.appendChild(n.createElement(e));i.append(...e.childNodes),e.appendChild(r)}function Jh(e){let t=e.style,n=[],r=t.fontWeight;/^(bold(er)?|[6-9]\d\d)$/.test(r)&&!e.closest(Gh)&&n.push(`strong`),(t.fontStyle===`italic`||t.fontStyle===`oblique`)&&n.push(`em`);let i=`${t.textDecoration} ${t.getPropertyValue(`text-decoration-line`)}`;return i.includes(`underline`)&&!e.closest(`a`)&&n.push(`u`),i.includes(`line-through`)&&n.push(`s`),n}var Yh=e=>/mso-list\s*:\s*l\d+/i.test(e.getAttribute(`style`)??``),Xh=e=>/mso-list\s*:\s*ignore/i.test(e.getAttribute(`style`)??``);function Zh(e){let t=null;for(let n of[...e.querySelectorAll(`p`)].filter(Yh)){let e=[...n.querySelectorAll(`span`)].find(Xh),r=(e?.textContent??``).replace(/[\s\u00a0]+/g,``),i=/^\(?(\d+|[a-z]{1,3})[.)]$/i.test(r)?`OL`:`UL`;e?.remove(),t&&t.tagName===i&&n.previousElementSibling===t||(t=n.ownerDocument.createElement(i),n.before(t));let a=n.ownerDocument.createElement(`li`);a.appendChild(n),t.appendChild(a)}}function Qh(e){let t=(e,t)=>{for(;e&&e.nodeType===Node.TEXT_NODE&&$h(e.textContent);)e=e[t];return e},n=e=>!e||Uh.has(e.tagName);return n(t(e.previousSibling,`previousSibling`))&&n(t(e.nextSibling,`nextSibling`))}var $h=e=>!(e??``).replace(/[\s\u00a0\u200b]/g,``);function eg(e,t=document){if(/<[^>]+\sdata-pm-slice=/.test(e))return e;let n=new((t.defaultView?.DOMParser)??DOMParser)().parseFromString(e,`text/html`),r=n.body,i=[],a=n.createTreeWalker(r,NodeFilter.SHOW_COMMENT);for(;a.nextNode();)i.push(a.currentNode);i.forEach(e=>e.parentNode?.removeChild(e)),r.querySelectorAll(Hh).forEach(e=>e.remove()),r.querySelectorAll(`br.Apple-interchange-newline`).forEach(e=>e.remove()),Zh(r),r.querySelectorAll(`span[style]`).forEach(e=>{if(Xh(e)){let t=(e.textContent??``).replace(/[\s\u00a0]+/g,` `).trim();e.replaceWith(n.createTextNode(t?`${t} `:``))}}),r.querySelectorAll(`b, strong`).forEach(e=>{(/^(normal|[1-4]00)$/.test(e.style.fontWeight)||e.id.startsWith(`docs-internal-guid`))&&Kh(e)}),r.querySelectorAll(`span`).forEach(e=>{e.textContent&&/^[\s\u00a0]+$/.test(e.textContent)&&!e.children.length&&e.replaceWith(n.createTextNode(` `))}),[...r.querySelectorAll(`span[style], font[style]`)].reverse().forEach(e=>qh(e,Jh(e)));for(let e of[...r.querySelectorAll(`*`)]){if(e.tagName===`IMG`)continue;let t=[...e.classList].filter(e=>e.startsWith(`wysio-`));for(let t of[...e.attributes])Wh.has(t.name.toLowerCase())||e.removeAttribute(t.name);t.length&&e.setAttribute(`class`,t.join(` `))}return[...r.querySelectorAll(`*`)].reverse().forEach(e=>{((e.tagName===`SPAN`||e.tagName===`FONT`)&&!e.hasAttribute(`class`)||e.tagName.includes(`:`))&&Kh(e)}),r.querySelectorAll(`br`).forEach(e=>{Qh(e)&&e.remove()}),r.querySelectorAll(`p`).forEach(e=>{$h(e.textContent)&&!e.querySelector(`img, br, table, hr`)&&e.remove()}),r.innerHTML}var tg=A({name:`paste`,prosemirrorPlugins:({editor:e})=>[new ks({props:{transformPastedHTML:t=>eg(t,e.dom.ownerDocument)}})]}),ng=A({name:`placeholder`,prosemirrorPlugins:({editor:e})=>[new ks({props:{decorations:t=>{let n=e.options.placeholder,r=t.doc.firstChild;return!n||!r||!np(t.doc)?null:G.create(t.doc,[df.node(0,r.nodeSize,{class:`wysio-placeholder`,"data-placeholder":n})])},attributes:()=>{let t=e.options.placeholder;return t?{"aria-placeholder":t}:{}}}})]}),rg=new Set([`UL`,`OL`,`LI`,`BLOCKQUOTE`,`TABLE`,`THEAD`,`TBODY`,`TR`,`TD`,`TH`]),ig=new Set([...rg,`P`,`H1`,`H2`,`H3`,`H4`,`H5`,`H6`,`HR`,`PRE`,`DIV`]),ag=e=>[...e.children].some(e=>ig.has(e.tagName));function og(e){let t=e.cloneNode(!1).outerHTML,n=t.lastIndexOf(`</`);return n===-1?t:t.slice(0,n)}function sg(e,t=` `,n=document){let r=n.createElement(`div`);r.innerHTML=e;let i=[],a=(e,n)=>{let r=t.repeat(n);if(e.nodeType===Node.TEXT_NODE){(e.textContent??``).trim()&&i.push(r+e.data.trim());return}if(e.nodeType!==Node.ELEMENT_NODE)return;let o=e;rg.has(o.tagName)&&ag(o)?(i.push(r+og(o)),o.childNodes.forEach(e=>a(e,n+1)),i.push(`${r}</${o.tagName.toLowerCase()}>`)):i.push(r+o.outerHTML)};return r.childNodes.forEach(e=>a(e,0)),i.join(`
63
+ `)}var cg=new Ms(`wysio-source`),lg=class{editor;textarea;ownDoc=null;applying=!1;constructor(e){this.editor=e;let t=e.dom.ownerDocument;this.textarea=t.createElement(`textarea`),this.textarea.className=`wysio-source`,this.textarea.spellcheck=!1,this.textarea.hidden=!0,this.textarea.setAttribute(`aria-label`,e.t(`source.label`)),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`autocomplete`,`off`),this.textarea.addEventListener(`input`,()=>this.apply()),e.view.dom.parentElement.after(this.textarea)}get body(){return this.editor.view.dom.parentElement}open(){this.ownDoc=this.editor.view.state.doc,this.textarea.value=sg(this.editor.getHTML(),` `,this.editor.dom.ownerDocument),this.textarea.readOnly=!this.editor.isEditable;let e=this.body.offsetHeight;e&&(this.textarea.style.height=`${e}px`),this.body.hidden=!0,this.textarea.hidden=!1,this.editor.setMode(`source`),this.textarea.focus(),this.textarea.setSelectionRange(0,0),this.textarea.scrollTop=0}close(){this.textarea.hidden=!0,this.body.hidden=!1,this.editor.setMode(`wysiwyg`),this.editor.focus()}apply(){let{view:e,schema:t}=this.editor,n=tp(t,this.textarea.value,this.editor.dom.ownerDocument);if(!n.eq(e.state.doc)){this.applying=!0;try{e.dispatch(e.state.tr.replaceWith(0,e.state.doc.content.size,n.content).setMeta(cg,!0))}finally{this.applying=!1}this.ownDoc=e.state.doc}}sync(){if(this.editor.mode!==`source`||this.applying)return;this.textarea.readOnly=!this.editor.isEditable;let{doc:e}=this.editor.view.state;e!==this.ownDoc&&(this.ownDoc=e,this.textarea.value=sg(this.editor.getHTML(),` `,this.editor.dom.ownerDocument))}},ug=new WeakMap;function dg(e){let t=ug.get(e);return t||ug.set(e,t=new lg(e)),t}function fg(e){if(!e.hasPlugin(`source`))return;let t=dg(e);e.mode===`source`?t.close():t.open()}var pg=A({name:`source`,prosemirrorPlugins:({editor:e})=>[new ks({key:cg,view:()=>(ug.get(e)?.sync(),{update:()=>ug.get(e)?.sync()})})],toolbarItems:({editor:e})=>({source:{label:e.t(`source`),icon:J.source,run:fg,isActive:()=>e.mode===`source`,isEnabled:()=>!0,availableInSourceMode:!0}})}),mg,hg;if(typeof WeakMap<`u`){let e=new WeakMap;mg=t=>e.get(t),hg=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;mg=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},hg=(n,r)=>(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Z=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){let n=this.map[t];if(n!=e)continue;let r=t%this.width,i=t/this.width|0,a=r+1,o=i+1;for(let e=1;a<this.width&&this.map[t+e]==n;e++)a++;for(let e=1;o<this.height&&this.map[t+this.width*e]==n;e++)o++;return{left:r,top:i,right:a,bottom:o}}throw RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){let{left:r,right:i,top:a,bottom:o}=this.findCell(e);return t==`horiz`?(n<0?r==0:i==this.width)?null:this.map[a*this.width+(n<0?r-1:i)]:(n<0?a==0:o==this.height)?null:this.map[r+this.width*(n<0?a-1:o)]}rectBetween(e,t){let{left:n,right:r,top:i,bottom:a}=this.findCell(e),{left:o,right:s,top:c,bottom:l}=this.findCell(t);return{left:Math.min(n,o),top:Math.min(i,c),right:Math.max(r,s),bottom:Math.max(a,l)}}cellsInRect(e){let t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let i=e.left;i<e.right;i++){let a=r*this.width+i,o=this.map[a];n[o]||(n[o]=!0,i==e.left&&i&&this.map[a-1]==o||r==e.top&&r&&this.map[a-this.width]==o||t.push(o))}return t}positionAt(e,t,n){for(let r=0,i=0;;r++){let a=i+n.child(r).nodeSize;if(r==e){let n=t+e*this.width,r=(e+1)*this.width;for(;n<r&&this.map[n]<i;)n++;return n==r?a-1:this.map[n]}i=a}}static get(e){return mg(e)||hg(e,gg(e))}};function gg(e){if(e.type.spec.tableRole!=`table`)throw RangeError(`Not a table node: `+e.type.name);let t=_g(e),n=e.childCount,r=[],i=0,a=null,o=[];for(let e=0,i=t*n;e<i;e++)r[e]=0;for(let s=0,c=0;s<n;s++){let l=e.child(s);c++;for(let e=0;;e++){for(;i<r.length&&r[i]!=0;)i++;if(e==l.childCount)break;let u=l.child(e),{colspan:d,rowspan:f,colwidth:p}=u.attrs;for(let e=0;e<f;e++){if(e+s>=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;e<d;e++){r[l+e]==0?r[l+e]=c:(a||=[]).push({type:`collision`,row:s,pos:c,n:d-e});let n=p&&p[e];if(n){let r=(l+e)%t*2,i=o[r];i==null||i!=n&&o[r+1]==1?(o[r]=n,o[r+1]=1):i==n&&o[r+1]++}}}i+=d,c+=u.nodeSize}let u=(s+1)*t,d=0;for(;i<u;)r[i++]==0&&d++;d&&(a||=[]).push({type:`missing`,row:s,n:d}),c++}(t===0||n===0)&&(a||=[]).push({type:`zero_sized`});let s=new Z(t,n,r,a),c=!1;for(let e=0;!c&&e<o.length;e+=2)o[e]!=null&&o[e+1]<n&&(c=!0);return c&&vg(s,o,e),s}function _g(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){let i=e.child(r),a=0;if(n)for(let t=0;t<r;t++){let n=e.child(t);for(let e=0;e<n.childCount;e++){let i=n.child(e);t+i.attrs.rowspan>r&&(a+=i.attrs.colspan)}}for(let e=0;e<i.childCount;e++){let t=i.child(e);a+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function vg(e,t,n){e.problems||=[];let r={};for(let i=0;i<e.map.length;i++){let a=e.map[i];if(r[a])continue;r[a]=!0;let o=n.nodeAt(a);if(!o)throw RangeError(`No cell with offset ${a} found`);let s=null,c=o.attrs;for(let n=0;n<c.colspan;n++){let r=t[(i+n)%e.width*2];r==null||c.colwidth&&c.colwidth[n]==r||((s||=yg(c))[n]=r)}s&&e.problems.unshift({type:`colwidth mismatch`,pos:a,colwidth:s})}}function yg(e){if(e.colwidth)return e.colwidth.slice();let t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function bg(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(let n in e.nodes){let r=e.nodes[n],i=r.spec.tableRole;i&&(t[i]=r)}}return t}var xg=new Ms(`selectingCells`);function Sg(e){for(let t=e.depth-1;t>0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Q(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Cg(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Sg(t.$head)||wg(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function wg(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Tg(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Eg(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Dg(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Og(e,t,n){let r=e.node(-1),i=Z.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function kg(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Ag(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}function jg(e,t,n){let r=bg(t.type.schema).header_cell;for(let i=0;i<e.height;i++)if(t.nodeAt(e.map[n+i*e.width]).type!=r)return!1;return!0}var $=class e extends N{constructor(e,t=e){let n=e.node(-1),r=Z.get(n),i=e.start(-1),a=r.rectBetween(e.pos-i,t.pos-i),o=e.node(0),s=r.cellsInRect(a).filter(e=>e!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new us(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Tg(r)&&Tg(i)&&Dg(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return P.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Z.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n<r.bottom;n++){let o=[];for(let a=n*t.width+r.left,s=r.left;s<r.right;s++,a++){let n=t.map[a];if(i[n])continue;i[n]=!0;let s=t.findCell(n),c=e.nodeAt(n);if(!c)throw RangeError(`No cell with offset ${n} found`);let l=r.left-s.left,u=s.right-r.right;if(l>0||u>0){let e=c.attrs;if(l>0&&(e=kg(e,0,l)),u>0&&(e=kg(e,e.colspan-u,u)),s.left<r.left){if(c=c.type.createAndFill(e),!c)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else c=c.type.create(e,c.content)}if(s.top<r.top||s.bottom>r.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top<r.top?c.type.createAndFill(e):c.type.create(e,c.content)}o.push(c)}a.push(e.child(n).copy(D.from(o)))}let o=this.isColSelection()&&this.isRowSelection()?e:a;return new k(D.from(o),1,1)}replace(e,t=k.empty){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n);e.replace(s.map(a.pos),s.map(o.pos),i?k.empty:t)}let i=N.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new k(D.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),n=Z.get(t),r=this.$anchorCell.start(-1),i=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<i.length;n++)e(t.nodeAt(i[n]),r+i[n])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Z.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom<i.height&&(n=c.resolve(a+i.map[i.width*(i.height-1)+s.right-1]))):(s.top>0&&(n=c.resolve(a+i.map[s.left])),o.bottom<i.height&&(t=c.resolve(a+i.map[i.width*(i.height-1)+o.right-1]))),new e(t,n)}isRowSelection(){let e=this.$anchorCell.node(-1),t=Z.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),i=t.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Z.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right<i.width&&(n=c.resolve(a+i.map[i.width*(s.top+1)-1]))):(s.left>0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right<i.width&&(t=c.resolve(a+i.map[i.width*(o.top+1)-1]))),new e(t,n)}toJSON(){return{type:`cell`,anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new Mg(this.$anchorCell.pos,this.$headCell.pos)}};$.prototype.visible=!1,N.jsonID(`cell`,$);var Mg=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){let t=e.resolve(this.anchor),n=e.resolve(this.head);return t.parent.type.spec.tableRole==`row`&&n.parent.type.spec.tableRole==`row`&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Dg(t,n)?new $(t,n):N.near(n,1)}};function Ng(e){if(!(e.selection instanceof $))return null;let t=[];return e.selection.forEachCell((e,n)=>{t.push(df.node(n,n+e.nodeSize,{class:`selectedCell`}))}),G.create(e.doc,t)}function Pg({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,i=e.depth;for(;i>=0&&!(e.after(i+1)<e.end(i));i--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Fg({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Ig(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof F&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=$.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=$.rowSelection(e,e)}else if(!n){let e=Z.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=$.create(i,t+1,n)}}else r instanceof P&&Pg(r)?a=P.create(i,r.from):r instanceof P&&Fg(r)&&(a=P.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Lg=new Ms(`fix-tables`);function Rg(e,t,n,r){let i=e.childCount,a=t.childCount;e:for(let o=0,s=0;o<a;o++){let a=t.child(o);for(let t=s,r=Math.min(i,o+3);t<r;t++)if(e.child(t)==a){s=t+1,n+=a.nodeSize;continue e}r(a,n),s<i&&e.child(s).sameMarkup(a)?Rg(e.child(s),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function zg(e,t){let n,r=(t,r)=>{t.type.spec.tableRole==`table`&&(n=Bg(e,t,r,n))};return t?t.doc!=e.doc&&Rg(t.doc,e.doc,0,r):e.doc.descendants(r),n}function Bg(e,t,n,r){let i=Z.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e<i.height;e++)a.push(0);for(let e=0;e<i.problems.length;e++){let o=i.problems[e];if(o.type==`collision`){let e=t.nodeAt(o.pos);if(!e)continue;let i=e.attrs;for(let e=0;e<i.rowspan;e++)a[o.row+e]+=o.n;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,kg(i,i.colspan-o.n,o.n))}else if(o.type==`missing`)a[o.row]+=o.n;else if(o.type==`overlong_rowspan`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-o.n})}else if(o.type==`colwidth mismatch`){let e=t.nodeAt(o.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+o.pos),null,{...e.attrs,colwidth:o.colwidth})}else if(o.type==`zero_sized`){let e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let o,s;for(let e=0;e<a.length;e++)a[e]&&(o??=e,s=e);for(let c=0,l=n+1;c<i.height;c++){let n=t.child(c),i=l+n.nodeSize,u=a[c];if(u>0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n<u;n++){let n=bg(e.schema)[t].createAndFill();n&&a.push(n)}let d=(c==0||o==c-1)&&s==c?l+1:i-1;r.insert(r.mapping.map(d),a)}l=i}return r.setMeta(Lg,{fixTables:!0})}function Vg(e){let t=e.selection,n=Cg(e),r=n.node(-1),i=n.start(-1),a=Z.get(r);return{...t instanceof $?a.rectBetween(t.$anchorCell.pos-i,t.$headCell.pos-i):a.findCell(n.pos-i),tableStart:i,map:a,table:r}}function Hg(e,{map:t,tableStart:n,table:r},i){let a=i>0?-1:0;jg(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o<t.height;o++){let s=o*t.width+i;if(i>0&&i<t.width&&t.map[s-1]==t.map[s]){let a=t.map[s],c=r.nodeAt(a);e.setNodeMarkup(e.mapping.map(n+a),null,Ag(c.attrs,i-t.colCount(a))),o+=c.attrs.rowspan-1}else{let c=a==null?bg(r.type.schema).cell:r.nodeAt(t.map[s+a]).type,l=t.positionAt(o,i,r);e.insert(e.mapping.map(n+l),c.createAndFill())}}return e}function Ug(e,t){if(!Q(e))return!1;if(t){let n=Vg(e);t(Hg(e.tr,n,n.left))}return!0}function Wg(e,t){if(!Q(e))return!1;if(t){let n=Vg(e);t(Hg(e.tr,n,n.right))}return!0}function Gg(e,{map:t,table:n,tableStart:r},i){let a=e.mapping.maps.length;for(let o=0;o<t.height;){let s=o*t.width+i,c=t.map[s],l=n.nodeAt(c),u=l.attrs;if(i>0&&t.map[s-1]==c||i<t.width-1&&t.map[s+1]==c)e.setNodeMarkup(e.mapping.slice(a).map(r+c),null,kg(u,i-t.colCount(c)));else{let t=e.mapping.slice(a).map(r+c);e.delete(t,t+l.nodeSize)}o+=u.rowspan}}function Kg(e,t){if(!Q(e))return!1;if(t){let n=Vg(e),r=e.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let e=n.right-1;Gg(r,n,e),e!=n.left;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Z.get(e)}t(r)}return!0}function qg(e,t,n){let r=bg(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if(t.nodeAt(e.map[i+n*e.width])?.type!=r)return!1;return!0}function Jg(e,{map:t,tableStart:n,table:r},i){let a=n;for(let e=0;e<i;e++)a+=r.child(e).nodeSize;let o=[],s=i>0?-1:0;qg(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a<t.width;a++,c++)if(i>0&&i<t.height&&t.map[c]==t.map[c-t.width]){let i=t.map[c],o=r.nodeAt(i).attrs;e.setNodeMarkup(n+i,null,{...o,rowspan:o.rowspan+1}),a+=o.colspan-1}else{let e=(s==null?bg(r.type.schema).cell:r.nodeAt(t.map[c+s*t.width])?.type)?.createAndFill();e&&o.push(e)}return e.insert(a,bg(r.type.schema).row.create(null,o)),e}function Yg(e,t){if(!Q(e))return!1;if(t){let n=Vg(e);t(Jg(e.tr,n,n.top))}return!0}function Xg(e,t){if(!Q(e))return!1;if(t){let n=Vg(e);t(Jg(e.tr,n,n.bottom))}return!0}function Zg(e,{map:t,table:n,tableStart:r},i){let a=0;for(let e=0;e<i;e++)a+=n.child(e).nodeSize;let o=a+n.child(i).nodeSize,s=e.mapping.maps.length;e.delete(a+r,o+r);let c=new Set;for(let a=0,o=i*t.width;a<t.width;a++,o++){let l=t.map[o];if(!c.has(l)){if(c.add(l),i>0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i<t.height&&l==t.map[o+t.width]){let o=n.nodeAt(l),c=o.attrs,u=o.type.create({...c,rowspan:o.attrs.rowspan-1},o.content),d=t.positionAt(i+1,a,n);e.insert(e.mapping.slice(s).map(r+d),u),a+=c.colspan-1}}}}function Qg(e,t){if(!Q(e))return!1;if(t){let n=Vg(e),r=e.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;Zg(r,n,e),e!=n.top;e--){let e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw RangeError(`No table found`);n.table=e,n.map=Z.get(n.table)}t(r)}return!0}function $g(e){return function(t,n){if(!Q(t))return!1;if(n){let r=bg(t.schema),i=Vg(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e<o.length;e++)s[e].type==r.header_cell&&a.setNodeMarkup(i.tableStart+o[e],r.cell,s[e].attrs);if(a.steps.length===0)for(let e=0;e<o.length;e++)a.setNodeMarkup(i.tableStart+o[e],r.header_cell,s[e].attrs);n(a)}return!0}}function e_(e,t,n){let r=t.map.cellsInRect({left:0,top:0,right:e==`row`?t.map.width:1,bottom:e==`column`?t.map.height:1});for(let e=0;e<r.length;e++){let i=t.table.nodeAt(r[e]);if(i&&i.type!==n.header_cell)return!1}return!0}function t_(e,t){return t||={useDeprecatedLogic:!1},t.useDeprecatedLogic?$g(e):function(t,n){if(!Q(t))return!1;if(n){let r=bg(t.schema),i=Vg(t),a=t.tr,o=e_(`row`,i,r),s=e_(`column`,i,r),c=(e===`column`?o:e===`row`&&s)?1:0,l=e==`column`?{left:0,top:c,right:1,bottom:i.map.height}:e==`row`?{left:c,top:0,right:i.map.width,bottom:1}:i,u=e==`column`?s?r.cell:r.header_cell:e==`row`?o?r.cell:r.header_cell:r.cell;i.map.cellsInRect(l).forEach(e=>{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}t_(`row`,{useDeprecatedLogic:!0}),t_(`column`,{useDeprecatedLogic:!0}),t_(`cell`,{useDeprecatedLogic:!0});function n_(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;let t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){let e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}function r_(e){return function(t,n){if(!Q(t))return!1;let r=n_(Cg(t),e);if(r==null)return!1;if(n){let e=t.doc.resolve(r);n(t.tr.setSelection(P.between(e,Eg(e))).scrollIntoView())}return!0}}function i_(e,t){let n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function a_(e,t){let n=e.selection;if(!(n instanceof $))return!1;if(t){let r=e.tr,i=bg(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new k(i,0,0))}),r.docChanged&&t(r)}return!0}function o_(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e<t.childCount;e++){let i=t.child(e).content,a=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(a||c)&&(i=c_(bg(o).row,new k(i,a,c)).content),s.push(i)}else if(a==`cell`||a==`header_cell`)s.push(n||r?c_(bg(o).row,new k(t,n,r)).content:t);else return null;return s_(o,s)}function s_(e,t){let n=[];for(let e=0;e<t.length;e++){let r=t[e];for(let t=r.childCount-1;t>=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t<e+i;t++)n[t]=(n[t]||0)+a}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(D.empty),n[i]<r){let a=bg(e).cell.createAndFill(),o=[];for(let e=n[i];e<r;e++)o.push(a);t[i]=t[i].append(D.from(o))}return{height:t.length,width:r,rows:t}}function c_(e,t){let n=e.createAndFill();return new cs(n).replace(0,n.content.size,t).doc}function l_({width:e,height:t,rows:n},r,i){if(e!=r){let t=[],i=[];for(let e=0;e<n.length;e++){let a=n[e],o=[];for(let n=t[e]||0,i=0;n<r;i++){let s=a.child(i%a.childCount);n+s.attrs.colspan>r&&(s=s.type.createChecked(kg(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}i.push(D.from(o))}n=i,e=r}if(t!=i){let e=[];for(let r=0,a=0;r<i;r++,a++){let o=[],s=n[a%t];for(let e=0;e<s.childCount;e++){let t=s.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(D.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function u_(e,t,n,r,i,a,o){let s=bg(e.doc.type.schema),c,l;if(i>t.width)for(let a=0,u=0;a<t.height;a++){let d=n.child(a);u+=d.nodeSize;let f=[],p;p=d.lastChild==null||d.lastChild.type==s.cell?c||=s.cell.createAndFill():l||=s.header_cell.createAndFill();for(let e=t.width;e<i;e++)f.push(p);e.insert(e.mapping.slice(o).map(u-1+r),f)}if(a>t.height){let u=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){let i=e>=t.width?!1:n.nodeAt(t.map[r+e]).type==s.header_cell;u.push(i?l||=s.header_cell.createAndFill():c||=s.cell.createAndFill())}let d=s.row.create(null,D.from(u)),f=[];for(let e=t.height;e<a;e++)f.push(d);e.insert(e.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||l)}function d_(e,t,n,r,i,a,o,s){if(o==0||o==t.height)return!1;let c=!1;for(let l=i;l<a;l++){let i=o*t.width+l,a=t.map[i];if(t.map[i-t.width]==a){c=!0;let i=n.nodeAt(a),{top:u,left:d}=t.findCell(a);e.setNodeMarkup(e.mapping.slice(s).map(a+r),null,{...i.attrs,rowspan:o-u}),e.insert(e.mapping.slice(s).map(t.positionAt(o,d,n)),i.type.createAndFill({...i.attrs,rowspan:u+i.attrs.rowspan-o})),l+=i.attrs.colspan-1}}return c}function f_(e,t,n,r,i,a,o,s){if(o==0||o==t.width)return!1;let c=!1;for(let l=i;l<a;l++){let i=l*t.width+o,a=t.map[i];if(t.map[i-1]==a){c=!0;let i=n.nodeAt(a),u=t.colCount(a),d=e.mapping.slice(s).map(a+r);e.setNodeMarkup(d,null,kg(i.attrs,o-u,i.attrs.colspan-(o-u))),e.insert(d+i.nodeSize,i.type.createAndFill(kg(i.attrs,0,o-u))),l+=i.attrs.rowspan-1}}return c}function p_(e,t,n,r,i){let a=n?e.doc.nodeAt(n-1):e.doc;if(!a)throw Error(`No table found`);let o=Z.get(a),{top:s,left:c}=r,l=c+i.width,u=s+i.height,d=e.tr,f=0;function p(){if(a=n?d.doc.nodeAt(n-1):d.doc,!a)throw Error(`No table found`);o=Z.get(a),f=d.mapping.maps.length}u_(d,o,a,n,l,u,f)&&p(),d_(d,o,a,n,c,l,s,f)&&p(),d_(d,o,a,n,c,l,u,f)&&p(),f_(d,o,a,n,s,u,c,f)&&p(),f_(d,o,a,n,s,u,l,f)&&p();for(let e=s;e<u;e++){let t=o.positionAt(e,c,a),r=o.positionAt(e,l,a);d.replace(d.mapping.slice(f).map(t+n),d.mapping.slice(f).map(r+n),new k(i.rows[e-s],0,0))}p(),d.setSelection(new $(d.doc.resolve(n+o.positionAt(s,c,a)),d.doc.resolve(n+o.positionAt(u-1,l-1,a)))),t(d)}var m_=Pc({ArrowLeft:g_(`horiz`,-1),ArrowRight:g_(`horiz`,1),ArrowUp:g_(`vert`,-1),ArrowDown:g_(`vert`,1),"Shift-ArrowLeft":__(`horiz`,-1),"Shift-ArrowRight":__(`horiz`,1),"Shift-ArrowUp":__(`vert`,-1),"Shift-ArrowDown":__(`vert`,1),Backspace:a_,"Mod-Backspace":a_,Delete:a_,"Mod-Delete":a_});function h_(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function g_(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection;if(a instanceof $)return h_(n,r,N.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=x_(i,e,t);if(o==null)return!1;if(e==`horiz`)return h_(n,r,N.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Og(i,e,t),s;return s=a?N.near(a,1):t<0?N.near(n.doc.resolve(i.before(-1)),-1):N.near(n.doc.resolve(i.after(-1)),1),h_(n,r,s)}}}function __(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof $)o=a;else{let r=x_(i,e,t);if(r==null)return!1;o=new $(n.doc.resolve(r))}let s=Og(o.$headCell,e,t);return s?h_(n,r,new $(o.$anchorCell,s)):!1}}function v_(e,t){let n=Sg(e.state.doc.resolve(t));return n?(e.dispatch(e.state.tr.setSelection(new $(n))),!0):!1}function y_(e,t,n){if(!Q(e.state))return!1;let r=o_(n),i=e.state.selection;if(i instanceof $){r||={width:1,height:1,rows:[D.from(c_(bg(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Z.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=l_(r,o.right-o.left,o.bottom-o.top),p_(e.state,e.dispatch,a,o,r),!0}if(r){let t=Cg(e.state),n=t.start(-1);return p_(e.state,e.dispatch,n,Z.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function b_(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=S_(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof $)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Sg(e.state.selection.$anchor))!=null&&C_(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=C_(e,n),i=xg.getState(e.state)==null;if(!r||!Dg(t,r)){if(i)r=t;else return}let a=new $(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(xg,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),xg.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(xg,-1))}function o(r){let o=r,s=xg.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(S_(e,o.target)!=n&&(c=C_(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function x_(e,t,n){if(!(e.state.selection instanceof P))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function S_(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function C_(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Sg(e.state.doc.resolve(r))||Sg(e.state.doc.resolve(i))}new Ms(`tableColumnResizing`);function w_({allowTableNodeSelection:e=!1}={}){return new ks({key:xg,state:{init(){return null},apply(e,t){let n=e.getMeta(xg);if(n!=null)return n==-1?null:n;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:Ng,handleDOMEvents:{mousedown:b_},createSelectionBetween(e){return xg.getState(e.state)==null?null:e.state.selection},handleTripleClick:v_,handleKeyDown:m_,handlePaste:y_},appendTransaction(t,n,r){return Ig(r,zg(r,n),e)}})}var T_=10,E_=50,D_=e=>{let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=E_?t:1},O_={colspan:{default:1,validate:`number`},rowspan:{default:1,validate:`number`},colwidth:{default:null}};function k_(e,t){return{content:`block+`,attrs:O_,tableRole:t,isolating:!0,parseDOM:[{tag:e,getAttrs:e=>{let t=e;return{colspan:D_(t.getAttribute(`colspan`)??1),rowspan:D_(t.getAttribute(`rowspan`)??1)}}}],toDOM:t=>{let n={},r=D_(t.attrs.colspan),i=D_(t.attrs.rowspan);return r!==1&&(n.colspan=String(r)),i!==1&&(n.rowspan=String(i)),[e,n,0]}}}function A_(e,t,n,r=!0){let{table:i,table_row:a,table_cell:o,table_header:s}=e.nodes;if(!i||!a||!o||!s)throw Error(`[wysio] The table plugin is not enabled.`);let c=e=>Math.min(10,Math.max(1,Math.trunc(e)||1));return i.create(null,Array.from({length:c(t)},(e,t)=>a.create(null,Array.from({length:c(n)},()=>(r&&t===0?s:o).createAndFill()))))}function j_(e,t,n=!0){return(r,i)=>{if(!r.schema.nodes.table||Q(r))return!1;let a=A_(r.schema,e,t,n),{$from:o}=r.selection,s=!1;for(let e=o.depth;e>=0&&!s;e--){let t=o.index(e);s=o.node(e).canReplaceWith(t,t,a.type)}if(!s)return!1;if(i){let e=r.tr.replaceSelectionWith(a),t=-1;e.doc.descendants((e,n)=>(e===a&&(t=n),t===-1)),t!==-1&&e.setSelection(P.near(e.doc.resolve(t+4))),i(e.scrollIntoView())}return!0}}var M_=(e,t)=>{let{table:n,table_cell:r,table_header:i}=e.schema.nodes,a=n&&r&&i?Qp(e,[n]):null,o=a?.node.firstChild;if(!a||!o||!r||!i)return!1;if(t){let n=o.content.content.some(e=>e.type!==i),s=e.tr;o.forEach((e,t)=>{s.setNodeMarkup(a.pos+2+t,n?i:r,e.attrs)}),t(s)}return!0},N_=(e,t,n)=>Q(e)?r_(1)(e,t,n)?!0:!t||!n?Xg(e):(Xg(e,t),r_(1)(n.state,t,n)):!1;function P_(e){return[{name:`tableAddRowBefore`,label:`table.addRowBefore`,command:Yg,icon:J.tableRowBefore},{name:`tableAddRowAfter`,label:`table.addRowAfter`,command:Xg,icon:J.tableRowAfter},{name:`tableAddColumnBefore`,label:`table.addColumnBefore`,command:Ug,icon:J.tableColumnBefore},{name:`tableAddColumnAfter`,label:`table.addColumnAfter`,command:Wg,icon:J.tableColumnAfter},{name:`tableDeleteRow`,label:`table.deleteRow`,command:Qg,icon:J.tableDeleteRow},{name:`tableDeleteColumn`,label:`table.deleteColumn`,command:Kg,icon:J.tableDeleteColumn},{name:`tableToggleHeaderRow`,label:`table.toggleHeaderRow`,command:M_,icon:J.tableHeaderRow},{name:`tableDelete`,label:`table.delete`,command:i_,icon:J.tableDelete}].map(t=>({...t,label:e.t(t.label)}))}function F_(e){e.isEditable&&e.schema.nodes.table&&fp(e,`table`,()=>new I_(e)).open()}var I_=class extends up{picker;actions;cells=[];size;header;actionButtons=[];constructor(e){super(e,e.t(`table`));let t=e.dom.ownerDocument;this.dom.classList.add(`wysio-popover-table`);let n=pp(t,this.uid,`<div class="wysio-table-picker">
64
+ <div class="wysio-table-grid" role="group"></div>
65
+ <p class="wysio-table-size" aria-live="polite"></p>
66
+ <label class="wysio-check"><input type="checkbox" name="header" checked> <span></span></label>
67
+ </div>
68
+ <div class="wysio-table-actions"></div>`);this.picker=Y(n,`.wysio-table-picker`),this.actions=Y(n,`.wysio-table-actions`),this.size=Y(n,`.wysio-table-size`),this.header=Y(n,`input[name=header]`),Y(n,`.wysio-check span`).textContent=e.t(`table.header`);let r=Y(n,`.wysio-table-grid`);r.setAttribute(`aria-label`,e.t(`table.size`));for(let e=1;e<=10;e++)for(let n=1;n<=10;n++){let i=t.createElement(`button`);i.type=`button`,i.className=`wysio-table-cell`,i.tabIndex=-1,i.dataset.rows=String(e),i.dataset.cols=String(n),i.setAttribute(`aria-label`,this.sizeLabel(e,n)),i.addEventListener(`mouseenter`,()=>this.highlight(e,n)),i.addEventListener(`focus`,()=>this.highlight(e,n)),i.addEventListener(`click`,()=>this.insert(e,n)),r.appendChild(i),this.cells.push(i)}r.addEventListener(`keydown`,this.onGridKey);for(let n of P_(e)){let e=t.createElement(`button`);e.type=`button`,e.className=`wysio-menu-item`,e.dataset.action=n.name,e.innerHTML=n.icon,e.append(t.createTextNode(n.label)),e.addEventListener(`click`,()=>{this.close(!1),this.editor.exec(n.command)}),this.actions.appendChild(e),this.actionButtons.push({button:e,action:n})}this.actions.addEventListener(`keydown`,this.onActionsKey),this.dom.appendChild(n)}open(){let{state:e}=this.editor.view,t=Q(e);if(this.picker.hidden=t,this.actions.hidden=!t,this.dom.setAttribute(`aria-label`,this.editor.t(t?`table`:`table.insert`)),t){for(let{button:t,action:n}of this.actionButtons)t.disabled=!n.command(e);let t=this.actionButtons.find(e=>!e.button.disabled)?.button;this.show(e.selection.from,t??this.actions)}else this.highlight(1,1),this.show(e.selection.from,this.cell(1,1))}sizeLabel(e,t){return this.editor.t(`table.cells`,{rows:e,cols:t})}cell(e,t){return this.cells[(e-1)*10+(t-1)]}highlight(e,t){for(let n of this.cells){let r=Number(n.dataset.rows)<=e&&Number(n.dataset.cols)<=t;n.classList.toggle(`wysio-active`,r),n.tabIndex=Number(n.dataset.rows)===e&&Number(n.dataset.cols)===t?0:-1}this.size.textContent=this.sizeLabel(e,t)}insert(e,t){this.close(!1),this.editor.exec(j_(e,t,this.header.checked))}onGridKey=e=>{let t=e.target,n=Number(t.dataset.rows),r=Number(t.dataset.cols);if(n&&r){if(e.key===`ArrowRight`)r++;else if(e.key===`ArrowLeft`)r--;else if(e.key===`ArrowDown`)n++;else if(e.key===`ArrowUp`)n--;else if(e.key===`Home`)r=1;else if(e.key===`End`)r=10;else return;e.preventDefault(),n=Math.min(10,Math.max(1,n)),r=Math.min(10,Math.max(1,r)),this.cell(n,r)?.focus()}};onActionsKey=e=>{let t=this.actionButtons.map(e=>e.button).filter(e=>!e.disabled),n=t.indexOf(e.target),r=null;e.key===`ArrowDown`?r=(n+1)%t.length:e.key===`ArrowUp`?r=(n-1+t.length)%t.length:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r]?.focus())}},L_=e=>t=>Q(t)&&e(t),R_=A({name:`table`,schema:{nodes:{table:{content:`table_row+`,tableRole:`table`,isolating:!0,group:`block`,parseDOM:[{tag:`table`}],toDOM:()=>[`table`,[`tbody`,0]]},table_row:{content:`(table_cell | table_header)*`,tableRole:`row`,parseDOM:[{tag:`tr`}],toDOM:()=>[`tr`,0]},table_cell:k_(`td`,`cell`),table_header:k_(`th`,`header_cell`)}},keymap:()=>({Tab:N_,"Shift-Tab":r_(-1)}),prosemirrorPlugins:()=>[w_()],toolbarItems:({editor:e})=>{let t={table:{label:e.t(`table`),icon:J.table,run:F_,popover:`table`,isActive:e=>Q(e),isEnabled:e=>Q(e)||j_(1,1)(e)}};for(let n of P_(e))t[n.name]={label:n.label,icon:n.icon,command:n.command,isEnabled:L_(n.command)};return t}}),z_=[Vp,Em,nm,Ph,rm,R_,im,Dh(),Mh,Lh,Rh,zh,Bh,Vh,Sm(),Cm(),Dp,cm,tg,pg,Qm,ng];function B_(e){let t={},n={};for(let r of e){for(let[e,n]of Object.entries(r.schema?.nodes??{})){if(e in t)throw Error(`[wysio] Node "${e}" is defined twice (plugin "${r.name}").`);t[e]=n}for(let[e,t]of Object.entries(r.schema?.marks??{})){if(e in n)throw Error(`[wysio] Mark "${e}" is defined twice (plugin "${r.name}").`);n[e]=t}}for(let n of e)for(let[e,r]of Object.entries(n.schema?.extendNodes??{})){let n=t[e];n&&(t[e]=r(n))}return new Ji({nodes:t,marks:n})}var V_=()=>typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function H_(e){let t=V_();return e.split(`-`).map(e=>{switch(e){case`Mod`:return t?`⌘`:`Ctrl`;case`Shift`:return t?`⇧`:`Shift`;case`Alt`:return t?`⌥`:`Alt`;case`Ctrl`:return t?`⌃`:`Ctrl`;default:return e.length===1?e.toUpperCase():e}}).join(t?``:`+`)}function U_(e,t){let n=0;for(;n<e.length&&e[n]<=t;)n++;return n}var W_=`<svg class="wysio-caret" viewBox="0 0 10 10" width="8" height="8" aria-hidden="true" focusable="false"><path d="m2 3.5 3 3 3-3" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>`,G_=0,K_=class{editor;dom;controls=[];entries=[];more=null;panel=null;observer=null;constructor(e,t,n,{warnUnknown:r=!0,mode:i=`overflow`}={}){this.editor=e;let a=e.dom.ownerDocument;this.dom=a.createElement(`div`),this.dom.className=`wysio-toolbar`,this.dom.dataset.mode=i,this.dom.setAttribute(`role`,`toolbar`),e.locale&&(this.dom.lang=e.locale),this.dom.setAttribute(`aria-label`,e.t(`toolbar`)),this.dom.setAttribute(`aria-controls`,e.view.dom.id);let o=!0;for(let e of t){if(e===`|`){if(o)continue;let e=a.createElement(`span`);e.className=`wysio-separator`,e.setAttribute(`role`,`separator`),e.setAttribute(`aria-orientation`,`vertical`),this.entries.push(e),o=!0;continue}let t=n.get(e);if(!t){r&&console.warn(`[wysio] Unknown toolbar item "${e}".`);continue}let i=t.type===`select`?this.createSelect(e,t):this.createButton(e,t);this.controls.push(i),this.entries.push(i.el),o=!1}this.entries.at(-1)?.classList.contains(`wysio-separator`)&&this.entries.pop(),this.dom.append(...this.entries),i===`overflow`&&this.setUpOverflow(),this.dom.addEventListener(`keydown`,this.onKeyDown),this.dom.addEventListener(`focusin`,this.onFocusIn),e.dom.addEventListener(`wysio:popover`,this.onPopover),this.controls[0]?.el.setAttribute(`tabindex`,`0`)}label(e,t){return t.labelKey?this.editor.t(t.labelKey):t.label??e}createButton(e,t){let n=this.editor.dom.ownerDocument,r=n.createElement(`button`),i=this.label(e,t);r.type=`button`,r.className=`wysio-tool`,r.dataset.item=e,r.tabIndex=-1;let a=n.createElement(`span`);return a.className=`wysio-icon`,a.innerHTML=t.icon,r.appendChild(a),t.dropdown&&r.insertAdjacentHTML(`beforeend`,W_),r.setAttribute(`aria-label`,i),r.title=t.shortcut?`${i} (${H_(t.shortcut)})`:i,t.isActive&&r.setAttribute(`aria-pressed`,`false`),t.popover&&(r.setAttribute(`aria-haspopup`,`dialog`),r.setAttribute(`aria-expanded`,`false`)),r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,()=>{r.getAttribute(`aria-disabled`)!==`true`&&(t.run?t.run(this.editor):t.command&&this.editor.exec(t.command))}),{kind:`button`,item:t,el:r,icon:a}}createSelect(e,t){let n=this.editor.dom.ownerDocument,r=n.createElement(`select`),i=this.label(e,t);r.className=`wysio-select`,r.dataset.item=e,r.tabIndex=-1,r.setAttribute(`aria-label`,i),r.title=i;let a=n.createElement(`option`);a.value=``,a.hidden=!0,a.textContent=`—`,r.appendChild(a);for(let e of t.options){let t=n.createElement(`option`);t.value=e.value,t.textContent=e.label,r.appendChild(t)}return r.addEventListener(`change`,()=>{r.value&&t.onSelect(this.editor,r.value)}),{kind:`select`,item:t,el:r}}update(e){let t=this.editor.isEditable,n=this.editor.mode===`wysiwyg`;for(let r of this.controls){let{item:i,el:a}=r,o=i.availableInSourceMode||t&&n;if(o&&(i.isEnabled?o=i.isEnabled(e,this.editor):r.kind===`button`&&r.item.command&&(o=r.item.command(e))),r.kind===`select`){r.el.disabled=!o,r.el.value=r.item.getValue(e);continue}if(a.setAttribute(`aria-disabled`,String(!o)),r.item.isActive){let t=(n||!!i.availableInSourceMode)&&r.item.isActive(e);a.setAttribute(`aria-pressed`,String(t))}let{icon:s}=r;r.item.render?.(e,{el:r.el,setIcon:e=>{s.innerHTML!==e&&(s.innerHTML=e)}})}}focus(){let e=this.focusable();(e.find(e=>e.tabIndex===0)??e[0])?.focus()}destroy(){this.observer?.disconnect(),this.closePanel(!1),this.editor.dom.removeEventListener(`wysio:popover`,this.onPopover),this.dom.remove()}setUpOverflow(){let e=this.editor.dom.ownerDocument,t=`wysio-toolbar-more-${++G_}`;this.more=e.createElement(`button`),this.more.type=`button`,this.more.className=`wysio-tool wysio-more`,this.more.tabIndex=-1,this.more.hidden=!0,this.more.innerHTML=`<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true" focusable="false"><circle cx="5" cy="12" r="1.75" fill="currentColor"/><circle cx="12" cy="12" r="1.75" fill="currentColor"/><circle cx="19" cy="12" r="1.75" fill="currentColor"/></svg>`,this.more.setAttribute(`aria-label`,this.editor.t(`toolbar.more`)),this.more.title=this.editor.t(`toolbar.more`),this.more.setAttribute(`aria-expanded`,`false`),this.more.setAttribute(`aria-controls`,t),this.more.addEventListener(`mousedown`,e=>e.preventDefault()),this.more.addEventListener(`click`,()=>{this.panel?.hidden?this.openPanel():this.closePanel(!0)}),this.panel=e.createElement(`div`),this.panel.id=t,this.panel.className=`wysio-toolbar-panel`,this.panel.hidden=!0,this.panel.setAttribute(`role`,`group`),this.panel.setAttribute(`aria-label`,this.editor.t(`toolbar.more`)),this.panel.addEventListener(`keydown`,this.onPanelKey),this.panel.addEventListener(`click`,e=>{let t=e.target.closest(`button`);t&&t.getAttribute(`aria-disabled`)!==`true`&&this.closePanel(!1)}),this.panel.addEventListener(`change`,()=>this.closePanel(!1)),this.dom.append(this.more,this.panel),typeof ResizeObserver<`u`&&(this.observer=new ResizeObserver(()=>this.layout()),this.observer.observe(this.dom))}layout(){let{more:e,panel:t}=this;if(!e||!t)return;let n=this.editor.dom.ownerDocument.activeElement;for(let t of this.entries)this.dom.insertBefore(t,e);if(e.hidden=!0,this.dom.scrollWidth<=this.dom.clientWidth){this.closePanel(!1),this.ensureTabStop();return}e.hidden=!1;let r=getComputedStyle(this.dom),i=parseFloat(r.columnGap)||0,a=this.dom.clientWidth-(parseFloat(r.paddingRight)||0)-e.offsetWidth-i,o=U_(this.entries.map(e=>e.offsetLeft+e.offsetWidth),a);for(;o>0&&this.entries[o-1].classList.contains(`wysio-separator`);)o--;for(let e of this.entries.slice(o))t.appendChild(e);this.ensureTabStop(),n instanceof HTMLElement&&this.dom.contains(n)&&n.focus()}openPanel(){let{more:e,panel:t}=this;e&&t&&(t.hidden=!1,e.setAttribute(`aria-expanded`,`true`),this.editor.dom.ownerDocument.addEventListener(`mousedown`,this.onOutside,!0),this.panelItems()[0]?.focus())}closePanel(e){let{more:t,panel:n}=this;t&&n&&!n.hidden&&(n.hidden=!0,t.setAttribute(`aria-expanded`,`false`),this.editor.dom.ownerDocument.removeEventListener(`mousedown`,this.onOutside,!0),e&&t.focus())}panelItems(){return this.panel?this.controls.map(e=>e.el).filter(e=>this.panel.contains(e)&&!(e instanceof HTMLSelectElement&&e.disabled)):[]}onOutside=e=>{let t=e.target;!this.panel?.contains(t)&&!this.more?.contains(t)&&this.closePanel(!1)};onPanelKey=e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),this.closePanel(!0);return}if(e.target instanceof HTMLSelectElement&&(e.key===`ArrowUp`||e.key===`ArrowDown`))return;let t=this.panelItems(),n=t.indexOf(e.target),r=null;e.key===`ArrowRight`||e.key===`ArrowDown`?r=(n+1)%t.length:e.key===`ArrowLeft`||e.key===`ArrowUp`?r=(n-1+t.length)%t.length:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r]?.focus())};focusable(){let e=this.controls.map(e=>e.el).filter(e=>e.parentElement===this.dom&&!(e instanceof HTMLSelectElement&&e.disabled));return this.more&&!this.more.hidden?[...e,this.more]:e}ensureTabStop(){let e=this.focusable();if(!e.some(e=>e.tabIndex===0)){for(let e of this.controls)e.el.tabIndex=-1;this.more&&(this.more.tabIndex=-1),e[0]&&(e[0].tabIndex=0)}}onFocusIn=e=>{let t=e.target;if(this.focusable().includes(t)){for(let e of this.controls)e.el.tabIndex=e.el===t?0:-1;this.more&&(this.more.tabIndex=this.more===t?0:-1)}};onKeyDown=e=>{if(e.key===`Escape`){e.preventDefault(),this.editor.focus();return}let t=this.focusable();if(!t.length)return;let n=t.indexOf(e.target);if(n===-1)return;let r=null;e.key===`ArrowRight`?r=(n+1)%t.length:e.key===`ArrowLeft`?r=(n-1+t.length)%t.length:e.key===`Home`?r=0:e.key===`End`&&(r=t.length-1),r!==null&&(e.preventDefault(),t[r]?.focus())};onPopover=e=>{let{key:t,open:n}=e.detail;for(let e of this.controls)e.kind===`button`&&e.item.popover===t&&e.el.setAttribute(`aria-expanded`,String(n))}},q_=[`heading`,`|`,`bold`,`italic`,`underline`,`strike`,`code`,`|`,`textColor`,`highlight`,`clearFormatting`,`|`,`align`,`bulletList`,`orderedList`,`blockquote`,`horizontalRule`,`table`,`|`,`link`,`image`,`|`,`undo`,`redo`],J_=0,Y_=class{dom;view;schema;options;emitter=new rp;toolbar=null;textarea=null;input=null;form=null;initialContent=null;plugins;messages;locale;formats=new Map;editable;currentMode=`wysiwyg`;destroyed=!1;constructor(e,t={}){let n=typeof e==`string`?document.querySelector(e):e;if(!n)throw Error(`[wysio] Element not found: ${String(e)}`);this.options=t;let{locale:r,messages:i}=X_(t.locale);this.locale=r,this.messages={...ap,...i,...t.messages},this.editable=t.editable??!0,this.plugins=Z_(t),this.schema=B_(this.plugins);let a=t.content,o=t.format;n instanceof HTMLTextAreaElement?(this.textarea=n,a??=n.value,this.dom=n.ownerDocument.createElement(`div`),n.insertAdjacentElement(`afterend`,this.dom),n.hidden=!0):(this.dom=n,a===void 0&&(a=n.innerHTML.trim(),o=`html`),n.innerHTML=``),this.dom.classList.add(`wysio`);let s=this.dom.ownerDocument,c={schema:this.schema,editor:this};for(let e of this.plugins)for(let[t,n]of Object.entries(e.formats?.(c)??{}))this.formats.set(t,n);let l=s.createElement(`div`);l.className=`wysio-body`,this.dom.appendChild(l);let u=`wysio-${++J_}`;if(this.view=new Hf(l,{state:Ds.create({doc:this.parseContent(a,o),plugins:this.createProseMirrorPlugins(c)}),editable:()=>this.editable,attributes:{id:u,class:`wysio-content`,role:`textbox`,"aria-multiline":`true`,"aria-label":t.ariaLabel??this.t(`editor`)},dispatchTransaction:e=>this.dispatch(e),handleDOMEvents:{focus:(e,t)=>(this.emitter.emit(`focus`,this,t),!1),blur:(e,t)=>(this.emitter.emit(`blur`,this,t),!1)}}),t.toolbar!==!1){let e=new Map;for(let t of this.plugins)for(let[n,r]of Object.entries(t.toolbarItems?.(c)??{}))e.set(n,r);if(this.toolbar=new K_(this,t.toolbar??q_,e,{warnUnknown:!!t.toolbar,mode:t.toolbarMode??`overflow`}),t.sticky){this.dom.classList.add(`wysio-sticky`);let e=typeof t.sticky==`number`?t.sticky:0;this.dom.style.setProperty(`--wysio-sticky-top`,`${e}px`)}this.dom.insertBefore(this.toolbar.dom,l),this.toolbar.update(this.view.state)}t.name&&this.textarea?this.textarea.name=t.name:t.name&&(this.input=s.createElement(`input`),this.input.type=`hidden`,this.input.name=t.name,this.dom.appendChild(this.input)),this.form=(this.textarea??this.input)?.form??null,this.form?.addEventListener(`reset`,this.onFormReset),this.initialContent=this.isEmpty?null:this.getJSON(),this.syncTextarea()}createProseMirrorPlugins(e){return[_c({rules:this.plugins.flatMap(t=>t.inputRules?.(e)??[])}),Nc({Backspace:yc,"Alt-F10":()=>(this.toolbar?.focus(),!!this.toolbar)}),...this.plugins.flatMap(t=>t.keymap?[Nc(t.keymap(e))]:[]),Nc(pc),...this.plugins.flatMap(t=>t.prosemirrorPlugins?.(e)??[])]}dispatch(e){this.destroyed||(this.view.updateState(this.view.state.apply(e)),this.toolbar?.update(this.view.state),this.emitter.emit(`transaction`,this,e),e.docChanged&&this.changed())}changed(){this.syncTextarea(),this.emitter.emit(`change`,this),this.options.onChange?.(this)}syncTextarea(){if(!this.textarea&&!this.input)return;let e=this.serialize(this.options.format??`html`);this.textarea&&(this.textarea.value=e),this.input&&(this.input.value=e)}onFormReset=()=>{queueMicrotask(()=>{this.destroyed||this.setContent(this.initialContent,{emitChange:!0})})};get state(){return this.view.state}get mode(){return this.currentMode}setMode(e){e!==this.currentMode&&(this.currentMode=e,this.dom.dataset.mode=e,this.toolbar?.update(this.view.state),this.emitter.emit(`mode`,this,e))}get isEditable(){return this.editable}get isEmpty(){return np(this.view.state.doc)}t(e,t){return cp(this.messages[e]??e,t)}getHTML(){return this.isEmpty?``:Qf(this.schema,this.view.state.doc,this.dom.ownerDocument)}getJSON(){return this.view.state.doc.toJSON()}getMarkdown(){return this.serialize(`markdown`)}serialize(e){if(e===`html`)return this.getHTML();if(e===`json`)return this.isEmpty?``:JSON.stringify(this.getJSON());let t=this.formatHandler(e);return this.isEmpty?``:t.serialize(this.view.state.doc)}formatHandler(e){let t=this.formats.get(e);if(!t)throw Error(`[wysio] No plugin provides the "${e}" format.${e===`markdown`?` Add it with: import { markdown } from 'wysio/markdown'; plugins: [markdown()]. On a CDN, use wysio.full.iife.js.`:``}`);return t}parseContent(e,t=`html`){let n=this.dom.ownerDocument;return typeof e!=`string`||e===``||t===`html`?tp(this.schema,e,n):t===`json`?tp(this.schema,JSON.parse(e),n):$f(this.schema,this.formatHandler(t).parse(e,this.schema),n)}getText(){let{doc:e}=this.view.state;return e.textBetween(0,e.content.size,`
69
+
70
+ `)}setContent(e,{emitChange:t=!1,format:n=this.options.format}={}){let r=Ds.create({doc:this.parseContent(e,n),plugins:this.view.state.plugins});this.view.updateState(r),this.toolbar?.update(r),this.syncTextarea(),t&&(this.emitter.emit(`change`,this),this.options.onChange?.(this))}setEditable(e){this.editable=e,this.view.setProps({}),this.toolbar?.update(this.view.state)}exec(e){if(!this.editable)return!1;let t=e(this.view.state,this.view.dispatch,this.view);return this.focus(),t}reportError(e,t){this.emitter.has(`error`)?this.emitter.emit(`error`,this,e,t):console.error(`[wysio] ${t.source} failed:`,e)}hasPlugin(e){return this.plugins.some(t=>t.name===e)}focus(){this.destroyed||this.view.focus()}on(e,t){return this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}destroy(){if(this.destroyed)return;let e=this.getHTML(),t=this.serialize(this.options.format??`html`);this.emitter.emit(`destroy`,this),this.destroyed=!0,this.emitter.clear(),this.view.destroy(),this.toolbar?.destroy(),this.form?.removeEventListener(`reset`,this.onFormReset),this.input?.remove(),this.textarea?(this.textarea.value=t,this.textarea.hidden=!1,this.dom.remove()):(this.dom.classList.remove(`wysio`,`wysio-sticky`),this.dom.style.removeProperty(`--wysio-sticky-top`),delete this.dom.dataset.mode,this.dom.innerHTML=e)}};function X_(e){if(e==null)return{locale:`en`,messages:{}};if(typeof e!=`string`)return{locale:null,messages:e};let t=sp(e);return t?{locale:t.code,messages:t.messages}:(console.warn(`[wysio] Unknown locale "${e}", using English. Add it with registerLocale().`),{locale:`en`,messages:{}})}function Z_(e){let t=new Set(e.removePlugins??[]);if(t.has(`base`))throw Error(`[wysio] The "base" plugin cannot be removed.`);let n=La(e.plugins??[]);return[...z_.filter(e=>!t.has(e.name)).map(e=>{let t=n.findIndex(t=>t.name===e.name);return t===-1?e:n.splice(t,1)[0]}),...n]}function Q_(e,t){return new Y_(e,t)}var $_=[`readonly`,`disabled`];function e1(){return class extends HTMLElement{static formAssociated=!0;static observedAttributes=[`value`,`placeholder`,...$_];#e=null;#t=null;#n=null;#r=!1;constructor(){super();try{this.#t=this.attachInternals()}catch{this.#t=null}}get editor(){return this.#e}get#i(){return this.getAttribute(`format`)||`html`}get#a(){return typeof this.#t?.setFormValue==`function`}get value(){return this.#e?this.#e.serialize(this.#i):this.#n??this.getAttribute(`value`)??``}set value(e){let t=e==null?``:String(e);this.#e?this.#e.setContent(t):this.#n=t,this.#s()}get form(){return this.#t?.form??this.closest(`form`)}get name(){return this.getAttribute(`name`)??``}connectedCallback(){if(this.#e)return;let e=this.getAttribute(`toolbar`),t=this.getAttribute(`plugins`);this.#e=Q_(this,{content:this.#n??this.getAttribute(`value`)??``,format:this.#i,plugins:t?t.split(/[\s,]+/).filter(Boolean):void 0,name:this.#a?void 0:this.getAttribute(`name`)||void 0,placeholder:this.getAttribute(`placeholder`)??void 0,locale:this.getAttribute(`locale`)??void 0,ariaLabel:this.getAttribute(`aria-label`)??void 0,toolbar:e===`false`?!1:e?e.split(/[\s,]+/).filter(Boolean):void 0,editable:this.#o(),onChange:()=>{this.#s(),this.dispatchEvent(new Event(`change`,{bubbles:!0}))}}),this.#n=null,this.#s()}disconnectedCallback(){this.#e&&(this.#n=this.#e.serialize(this.#i),this.#e.destroy(),this.#e=null,this.innerHTML=``)}attributeChangedCallback(e,t,n){t!==n&&this.#e&&(e===`value`?(n??``)!==this.value&&(this.value=n??``):$_.includes(e)&&this.#e.setEditable(this.#o()))}formResetCallback(){this.value=this.getAttribute(`value`)??``}formDisabledCallback(e){this.#r=e,this.#e?.setEditable(this.#o())}formStateRestoreCallback(e){typeof e==`string`&&(this.value=e)}#o(){return!this.#r&&$_.every(e=>!this.hasAttribute(e))}#s(){this.#a&&this.#t.setFormValue(this.value)}}}function t1(e=`wysio-editor`){typeof customElements>`u`||customElements.get(e)||customElements.define(e,e1())}var n1=new WeakMap;return t1(),Ia(`markdown`,qa),e.ALIGNMENTS=hp,e.DEFAULT_HIGHLIGHT_COLORS=um,e.DEFAULT_IMAGE_TYPES=sh,e.DEFAULT_TEXT_COLORS=lm,e.Editor=Y_,e.FORMATTING_ATTRIBUTES=am,e.IMAGE_ALIGNMENTS=oh,e.MAX_TABLE_SIZE=T_,e.activeColor=vm,e.alignment=Dp,e.autoInit=function(e={},t=document){let n=[];for(let r of t.querySelectorAll(`[data-wysio]`)){if(n1.has(r))continue;let t;try{let e=r.dataset.wysioOptions;t=e?JSON.parse(e):{}}catch(e){console.error(`[wysio] Invalid JSON in data-wysio-options:`,r,e);continue}let i=typeof e==`function`?e(r):e,a;try{a=Q_(r,{...i,...t,plugins:[...i.plugins??[],...t.plugins??[]],messages:{...i.messages,...t.messages}})}catch(e){console.error(`[wysio] Could not create an editor for`,r,e);continue}n1.set(r,a),a.on(`destroy`,()=>n1.delete(r)),n.push(a)}return n},e.availableLocales=function(){return[...op.keys()]},e.base=Vp,e.blockquote=nm,e.bold=Lh,e.cleanPastedHTML=eg,e.clearFormatting=sm,e.clearFormattingPlugin=cm,e.code=Vh,e.createEditor=Q_,e.createTable=A_,e.defaultMessages=ap,e.defaultPlugins=z_,e.defaultToolbar=q_,e.definePlugin=A,e.defineWysioElement=t1,e.findAncestor=Qp,e.fitCount=U_,e.formatHTML=sg,e.getEditor=function(e){return n1.get(e)??null},e.getMarkRange=tm,e.hardBreak=im,e.heading=Em,e.highlight=Cm,e.history=Qm,e.horizontalRule=rm,e.image=Dh,e.insertImage=Ch,e.insertTable=j_,e.isAlignmentActive=Cp,e.isMarkActive=Zp,e.italic=Rh,e.link=Mh,e.lists=Ph,e.markdown=qa,e.nl=ip,e.normalizeColor=fm,e.openAlignmentMenu=Ep,e.openImageDialog=Th,e.openLinkDialog=Ah,e.openTableMenu=F_,e.paletteCSS=function(e,t){return mm(t).colors.map(t=>e===`text`?`.wysio-color-${t.name} { color: ${t.value}; }`:`.wysio-highlight-${t.name} { background-color: ${t.value}; }`).join(`
71
+ `)},e.parseMarkdown=Ga,e.paste=tg,e.placeholder=ng,e.registerLocale=function(e,t){op.set(e.toLowerCase(),t)},e.registerPlugin=Ia,e.removeColorMark=_m,e.removeImage=wh,e.removeLink=kh,e.sanitizeImageUrl=ah,e.sanitizeUrl=nh,e.serializeMarkdown=Ka,e.setAlignment=Sp,e.setColorMark=gm,e.setLink=function(e,t){return(n,r)=>{let i=nh(t.href);if(!i)return!1;let a=e.create({href:i,target:t.target===`_blank`?`_blank`:null}),o=Oh(n,e);if(r){let t=n.tr;if(o)t.removeMark(o.from,o.to,e).addMark(o.from,o.to,a);else{let{from:e}=n.selection;t.insertText(i,e).addMark(e,e+i.length,a)}r(t.scrollIntoView())}return!0}},e.source=pg,e.strike=Bh,e.table=R_,e.textColor=Sm,e.toggleHeaderRow=M_,e.toggleList=$p,e.toggleSourceView=fg,e.toggleWrap=em,e.underline=zh,e.uploadImages=yh,e.version=`0.2.0-alpha.0`,e})({});
72
+ //# sourceMappingURL=wysio.full.iife.js.map